diff --git a/custom_components/houseplan/frontend/houseplan-assets.json b/custom_components/houseplan/frontend/houseplan-assets.json index 887ca531..aaf7b142 100644 --- a/custom_components/houseplan/frontend/houseplan-assets.json +++ b/custom_components/houseplan/frontend/houseplan-assets.json @@ -1,309 +1,309 @@ { "schema": 1, - "fingerprint": "ed91b3971428d2b8e7bfceb8025d2be4c0db7c58754eeb4ba03f835b8d7c84c6", + "fingerprint": "d31b0b1e184ab2863684b758f839bdb6809a33cc742c6e9bb36c5ea034e3d309", "entry": "houseplan-card.js", "panelEntry": "houseplan-panel.js", "initialViewFiles": [ - "houseplan-assets/houseplan-card-BiUNLHFh.js", + "houseplan-assets/houseplan-card-W9mG3gab.js", "houseplan-card.js" ], - "initialViewGzipBytes": 291522, + "initialViewGzipBytes": 291530, "initialPanelFiles": [ - "houseplan-assets/houseplan-card-BiUNLHFh.js", + "houseplan-assets/houseplan-card-W9mG3gab.js", "houseplan-panel.js" ], - "initialPanelGzipBytes": 293044, + "initialPanelGzipBytes": 293053, "initialPanelOnlyFiles": [ "houseplan-panel.js" ], - "initialPanelOnlyGzipBytes": 2325, + "initialPanelOnlyGzipBytes": 2326, "lazyFiles": [ - "houseplan-assets/backdrop-pick-Ev52LRir.js", - "houseplan-assets/de-DHIqglxm.js", - "houseplan-assets/editor-Dc4-BCoL.js", - "houseplan-assets/form-kit.styles-BQTkV2m1.js", - "houseplan-assets/fr-BUCrcPpM.js", - "houseplan-assets/furniture-plan-art.generated-O7K1vBfu.js", - "houseplan-assets/houseplan-editor-runtime-BG2wMJ7n.js", - "houseplan-assets/houseplan-onboarding-runtime-BAx8bJB2.js", - "houseplan-assets/hp-zigbee-topology-overlay-SYVcVGiq.js", - "houseplan-assets/iso-scene-render-CR59iy_N.js", - "houseplan-assets/live-interaction-runtime-C7FQnbBF.js", - "houseplan-assets/pdf-export-FjKO_S28.js", - "houseplan-assets/summary-panel-runtime-loaded-B9-PG-Gw.js", - "houseplan-assets/zigbee-topology-B31-i8CL.js", - "houseplan-assets/zigbee-topology-runtime-CuXFHyzq.js" + "houseplan-assets/backdrop-pick-ToIYfsVt.js", + "houseplan-assets/de-lgvVUcKp.js", + "houseplan-assets/editor-0Mj9gnAf.js", + "houseplan-assets/form-kit.styles-BSWYQ2Fp.js", + "houseplan-assets/fr-CHBDMDsG.js", + "houseplan-assets/furniture-plan-art.generated-B9qZ5DM-.js", + "houseplan-assets/houseplan-editor-runtime-DOSm4OKX.js", + "houseplan-assets/houseplan-onboarding-runtime-G7DfDSe_.js", + "houseplan-assets/hp-zigbee-topology-overlay-CAehZ6TG.js", + "houseplan-assets/iso-scene-render-CCwC6ZHk.js", + "houseplan-assets/live-interaction-runtime-DpDkGNJh.js", + "houseplan-assets/pdf-export-B1B1amDF.js", + "houseplan-assets/summary-panel-runtime-loaded-C3VkX0bk.js", + "houseplan-assets/zigbee-topology-3KJks91U.js", + "houseplan-assets/zigbee-topology-runtime-DvCmPEhl.js" ], - "lazyGzipBytes": 439294, + "lazyGzipBytes": 439327, "lazyEditorFiles": [ - "houseplan-assets/backdrop-pick-Ev52LRir.js", - "houseplan-assets/editor-Dc4-BCoL.js", - "houseplan-assets/form-kit.styles-BQTkV2m1.js", - "houseplan-assets/furniture-plan-art.generated-O7K1vBfu.js", - "houseplan-assets/houseplan-editor-runtime-BG2wMJ7n.js", - "houseplan-assets/zigbee-topology-B31-i8CL.js" + "houseplan-assets/backdrop-pick-ToIYfsVt.js", + "houseplan-assets/editor-0Mj9gnAf.js", + "houseplan-assets/form-kit.styles-BSWYQ2Fp.js", + "houseplan-assets/furniture-plan-art.generated-B9qZ5DM-.js", + "houseplan-assets/houseplan-editor-runtime-DOSm4OKX.js", + "houseplan-assets/zigbee-topology-3KJks91U.js" ], - "lazyEditorGzipBytes": 222190, + "lazyEditorGzipBytes": 222198, "lazyOnboardingFiles": [ - "houseplan-assets/backdrop-pick-Ev52LRir.js", - "houseplan-assets/houseplan-onboarding-runtime-BAx8bJB2.js" + "houseplan-assets/backdrop-pick-ToIYfsVt.js", + "houseplan-assets/houseplan-onboarding-runtime-G7DfDSe_.js" ], - "lazyOnboardingGzipBytes": 13916, + "lazyOnboardingGzipBytes": 13921, "lazyLocaleFiles": [ - "houseplan-assets/de-DHIqglxm.js", - "houseplan-assets/fr-BUCrcPpM.js" + "houseplan-assets/de-lgvVUcKp.js", + "houseplan-assets/fr-CHBDMDsG.js" ], - "lazyLocaleGzipBytes": 56354, + "lazyLocaleGzipBytes": 56365, "lazyIsometricFiles": [ - "houseplan-assets/iso-scene-render-CR59iy_N.js" + "houseplan-assets/iso-scene-render-CCwC6ZHk.js" ], - "lazyIsometricGzipBytes": 15013, + "lazyIsometricGzipBytes": 15016, "lazyFurnitureArtFiles": [ - "houseplan-assets/furniture-plan-art.generated-O7K1vBfu.js" + "houseplan-assets/furniture-plan-art.generated-B9qZ5DM-.js" ], - "lazyFurnitureArtGzipBytes": 16943, + "lazyFurnitureArtGzipBytes": 16940, "lazyPdfFiles": [ - "houseplan-assets/furniture-plan-art.generated-O7K1vBfu.js", - "houseplan-assets/pdf-export-FjKO_S28.js" + "houseplan-assets/furniture-plan-art.generated-B9qZ5DM-.js", + "houseplan-assets/pdf-export-B1B1amDF.js" ], - "lazyPdfGzipBytes": 126817, + "lazyPdfGzipBytes": 126813, "files": [ { - "path": "houseplan-assets/backdrop-pick-Ev52LRir.js", - "sha256": "2a15e36abcf8b5df52a6e96f347157949fc51572d177a7b4604f9ba0c2cc0563", + "path": "houseplan-assets/backdrop-pick-ToIYfsVt.js", + "sha256": "467a4c0884298f63173094735389446e86f2b04943d9518f822c9206f7d220ed", "rawBytes": 19959, - "gzipBytes": 6881, + "gzipBytes": 6883, "isEntry": false, "imports": [ - "houseplan-assets/houseplan-card-BiUNLHFh.js" + "houseplan-assets/houseplan-card-W9mG3gab.js" ], "dynamicImports": [] }, { - "path": "houseplan-assets/de-DHIqglxm.js", - "sha256": "336585ab9807040f4ae15d678086d6a681ffc62742b00350b466a2b9d35f7f25", + "path": "houseplan-assets/de-lgvVUcKp.js", + "sha256": "1654ca87abcb74a6e64db4624456cb3d9e9742b96501f0e0f85ac9cd3313717e", "rawBytes": 93989, - "gzipBytes": 28442, + "gzipBytes": 28448, "isEntry": false, "imports": [], "dynamicImports": [] }, { - "path": "houseplan-assets/editor-Dc4-BCoL.js", - "sha256": "06f0d6b2e83bd049f7cde67da7fb484b164ceb10db965662a80b9172cd60a650", + "path": "houseplan-assets/editor-0Mj9gnAf.js", + "sha256": "03ec9fa26b6d517aa05ee39a2ef60f59a3e9be81b6499475ba8184f9fb026235", "rawBytes": 3833, - "gzipBytes": 1581, + "gzipBytes": 1583, "isEntry": false, "imports": [ - "houseplan-assets/houseplan-card-BiUNLHFh.js" + "houseplan-assets/houseplan-card-W9mG3gab.js" ], "dynamicImports": [] }, { - "path": "houseplan-assets/form-kit.styles-BQTkV2m1.js", - "sha256": "20f850ea621e9310a86d26ecd9c2a37bc34ceadca8a7049a4c5cf12963fd24a9", + "path": "houseplan-assets/form-kit.styles-BSWYQ2Fp.js", + "sha256": "6d0965d557fe14691b2842a8f8ed0069ebd6cfed7facab7c02d0995106a908c8", "rawBytes": 3615, - "gzipBytes": 1233, + "gzipBytes": 1234, "isEntry": false, "imports": [], "dynamicImports": [] }, { - "path": "houseplan-assets/fr-BUCrcPpM.js", - "sha256": "cfdba0ac7ae0114c12c8ba8216f3197fc58c2fcb0b020ec839199551faaff1c1", + "path": "houseplan-assets/fr-CHBDMDsG.js", + "sha256": "029c8f373570ea5c5798775d49f0500057dac01b3cbd4c74d2b4c7cad411cf21", "rawBytes": 96460, - "gzipBytes": 27912, + "gzipBytes": 27917, "isEntry": false, "imports": [], "dynamicImports": [] }, { - "path": "houseplan-assets/furniture-plan-art.generated-O7K1vBfu.js", - "sha256": "add6e49eaea5b500246044a0fd3835258efc75e9e70374fd361a0c9011f66fa9", + "path": "houseplan-assets/furniture-plan-art.generated-B9qZ5DM-.js", + "sha256": "0ff4bf848333842e22567d52d5e2591c63cf994f5ab877d1e6f6143a7a6d65d9", "rawBytes": 52033, - "gzipBytes": 16943, + "gzipBytes": 16940, "isEntry": false, "imports": [], "dynamicImports": [] }, { - "path": "houseplan-assets/houseplan-card-BiUNLHFh.js", - "sha256": "26013d506b7b7dc5c7f876ec2ab7204ad69e2a42e0f164cf1c6ff075e9c1f9be", + "path": "houseplan-assets/houseplan-card-W9mG3gab.js", + "sha256": "fd3620fc81c2b5149ebfab53fa49392b6340b17a5d7d300ff70797a777a73d6c", "rawBytes": 1035518, - "gzipBytes": 290719, + "gzipBytes": 290727, "isEntry": false, "imports": [], "dynamicImports": [ - "houseplan-assets/de-DHIqglxm.js", - "houseplan-assets/editor-Dc4-BCoL.js", - "houseplan-assets/fr-BUCrcPpM.js", - "houseplan-assets/furniture-plan-art.generated-O7K1vBfu.js", - "houseplan-assets/houseplan-editor-runtime-BG2wMJ7n.js", - "houseplan-assets/houseplan-onboarding-runtime-BAx8bJB2.js", - "houseplan-assets/hp-zigbee-topology-overlay-SYVcVGiq.js", - "houseplan-assets/iso-scene-render-CR59iy_N.js", - "houseplan-assets/live-interaction-runtime-C7FQnbBF.js", - "houseplan-assets/pdf-export-FjKO_S28.js", - "houseplan-assets/summary-panel-runtime-loaded-B9-PG-Gw.js" + "houseplan-assets/de-lgvVUcKp.js", + "houseplan-assets/editor-0Mj9gnAf.js", + "houseplan-assets/fr-CHBDMDsG.js", + "houseplan-assets/furniture-plan-art.generated-B9qZ5DM-.js", + "houseplan-assets/houseplan-editor-runtime-DOSm4OKX.js", + "houseplan-assets/houseplan-onboarding-runtime-G7DfDSe_.js", + "houseplan-assets/hp-zigbee-topology-overlay-CAehZ6TG.js", + "houseplan-assets/iso-scene-render-CCwC6ZHk.js", + "houseplan-assets/live-interaction-runtime-DpDkGNJh.js", + "houseplan-assets/pdf-export-B1B1amDF.js", + "houseplan-assets/summary-panel-runtime-loaded-C3VkX0bk.js" ] }, { - "path": "houseplan-assets/houseplan-editor-runtime-BG2wMJ7n.js", - "sha256": "b52c53a198b616ef643aa161da2fcd6f92f8d80c08b1b0ab906f8e8357f2bb9d", - "rawBytes": 689960, - "gzipBytes": 188126, + "path": "houseplan-assets/houseplan-editor-runtime-DOSm4OKX.js", + "sha256": "d9564d0a4326d66d0cac3b24dde8c625d4ff64fdee9eaa5093e776992d41f177", + "rawBytes": 689688, + "gzipBytes": 188131, "isEntry": false, "imports": [ - "houseplan-assets/backdrop-pick-Ev52LRir.js", - "houseplan-assets/form-kit.styles-BQTkV2m1.js", - "houseplan-assets/furniture-plan-art.generated-O7K1vBfu.js", - "houseplan-assets/houseplan-card-BiUNLHFh.js", - "houseplan-assets/zigbee-topology-B31-i8CL.js" + "houseplan-assets/backdrop-pick-ToIYfsVt.js", + "houseplan-assets/form-kit.styles-BSWYQ2Fp.js", + "houseplan-assets/furniture-plan-art.generated-B9qZ5DM-.js", + "houseplan-assets/houseplan-card-W9mG3gab.js", + "houseplan-assets/zigbee-topology-3KJks91U.js" ], "dynamicImports": [ - "houseplan-assets/zigbee-topology-runtime-CuXFHyzq.js" + "houseplan-assets/zigbee-topology-runtime-DvCmPEhl.js" ] }, { - "path": "houseplan-assets/houseplan-onboarding-runtime-BAx8bJB2.js", - "sha256": "c3c0544f9a5ed52b84b238e91afb6a9af0eb4a549fee2b400d8b57250d479888", + "path": "houseplan-assets/houseplan-onboarding-runtime-G7DfDSe_.js", + "sha256": "05d9e7466cb5ffa0763f31a7726fdb8ca986b339e7129cbfeb8d16fca3d895d8", "rawBytes": 28289, - "gzipBytes": 7035, + "gzipBytes": 7038, "isEntry": false, "imports": [ - "houseplan-assets/backdrop-pick-Ev52LRir.js", - "houseplan-assets/houseplan-card-BiUNLHFh.js" + "houseplan-assets/backdrop-pick-ToIYfsVt.js", + "houseplan-assets/houseplan-card-W9mG3gab.js" ], "dynamicImports": [] }, { - "path": "houseplan-assets/hp-zigbee-topology-overlay-SYVcVGiq.js", - "sha256": "337c5b2f969e0f5eea68e9ed35c57ee887b22d1258ee74ea472e0697bf002405", + "path": "houseplan-assets/hp-zigbee-topology-overlay-CAehZ6TG.js", + "sha256": "ccec4f13dadb1057da1bb7118c7af575813d5273c4db6b3c5a18ec8440a25c00", "rawBytes": 10759, - "gzipBytes": 3684, + "gzipBytes": 3687, "isEntry": false, "imports": [ - "houseplan-assets/houseplan-card-BiUNLHFh.js", - "houseplan-assets/zigbee-topology-B31-i8CL.js", - "houseplan-assets/zigbee-topology-runtime-CuXFHyzq.js" + "houseplan-assets/houseplan-card-W9mG3gab.js", + "houseplan-assets/zigbee-topology-3KJks91U.js", + "houseplan-assets/zigbee-topology-runtime-DvCmPEhl.js" ], "dynamicImports": [] }, { - "path": "houseplan-assets/iso-scene-render-CR59iy_N.js", - "sha256": "bf6302158fdd208e01f51d4bca57a6442759477513d3bc0e050217f9fa1e1c04", + "path": "houseplan-assets/iso-scene-render-CCwC6ZHk.js", + "sha256": "8a570b1a301b025da5bc9be1bd4732a747bd5215951931fa7f9fe7acea744b33", "rawBytes": 44439, - "gzipBytes": 15013, + "gzipBytes": 15016, "isEntry": false, "imports": [ - "houseplan-assets/houseplan-card-BiUNLHFh.js" + "houseplan-assets/houseplan-card-W9mG3gab.js" ], "dynamicImports": [] }, { - "path": "houseplan-assets/live-interaction-runtime-C7FQnbBF.js", - "sha256": "0e125dd3cdeefbe4e37ded88c24b200ae1adeefd58e094249b68b0ae0a16bb68", + "path": "houseplan-assets/live-interaction-runtime-DpDkGNJh.js", + "sha256": "621740a374701977939421138d4c4da260c30891d4d5e49e054cfcbb23a68815", "rawBytes": 8216, - "gzipBytes": 3208, + "gzipBytes": 3210, "isEntry": false, "imports": [ - "houseplan-assets/houseplan-card-BiUNLHFh.js" + "houseplan-assets/houseplan-card-W9mG3gab.js" ], "dynamicImports": [] }, { - "path": "houseplan-assets/pdf-export-FjKO_S28.js", - "sha256": "b707974196d7ef9dbb7849dd027ec41ba56dc5e43d53909a734adf61422ff8c9", + "path": "houseplan-assets/pdf-export-B1B1amDF.js", + "sha256": "f8d3a8f8d5a00e07ee20b6f4104a0eb3eec644deb08c2785c5212faacccb132f", "rawBytes": 236247, - "gzipBytes": 109874, + "gzipBytes": 109873, "isEntry": false, "imports": [ - "houseplan-assets/furniture-plan-art.generated-O7K1vBfu.js", - "houseplan-assets/houseplan-card-BiUNLHFh.js" + "houseplan-assets/furniture-plan-art.generated-B9qZ5DM-.js", + "houseplan-assets/houseplan-card-W9mG3gab.js" ], "dynamicImports": [] }, { - "path": "houseplan-assets/summary-panel-editor-ClwrL_O4.js", - "sha256": "dfeac4341c2e3ac1d1b4d4b3b826967e3fab5ddfca8552c786249d05440722d7", + "path": "houseplan-assets/summary-panel-editor-Dq397KvS.js", + "sha256": "7798f08816a813b97c0fcce7a2c67eade8722964a0bb18f936d4aacc4bc2693b", "rawBytes": 14862, - "gzipBytes": 3424, + "gzipBytes": 3427, "isEntry": false, "imports": [ - "houseplan-assets/form-kit.styles-BQTkV2m1.js", - "houseplan-assets/houseplan-card-BiUNLHFh.js", - "houseplan-assets/summary-panel-runtime-loaded-B9-PG-Gw.js" + "houseplan-assets/form-kit.styles-BSWYQ2Fp.js", + "houseplan-assets/houseplan-card-W9mG3gab.js", + "houseplan-assets/summary-panel-runtime-loaded-C3VkX0bk.js" ], "dynamicImports": [] }, { - "path": "houseplan-assets/summary-panel-metrics-BjFIAkz0.js", - "sha256": "1b42c42876dcc1f3bdc74a00c7f2fecc37ef977f68fc38fc2e50b9ae910d892e", + "path": "houseplan-assets/summary-panel-metrics-Kwu_Jan4.js", + "sha256": "cca1e153c9eb77397b874df8c1b6d13eb05846dac1d20840375ec1c6115769cd", "rawBytes": 2611, - "gzipBytes": 1306, + "gzipBytes": 1308, "isEntry": false, "imports": [ - "houseplan-assets/houseplan-card-BiUNLHFh.js" + "houseplan-assets/houseplan-card-W9mG3gab.js" ], "dynamicImports": [] }, { - "path": "houseplan-assets/summary-panel-runtime-loaded-B9-PG-Gw.js", - "sha256": "c768f6cd041edce5ccedfd1bc1bd14ab75a5e69db9b05c3ced5a07a3d504e62b", + "path": "houseplan-assets/summary-panel-runtime-loaded-C3VkX0bk.js", + "sha256": "dca2b7848fe8afae7efad07e18a55652681c4ece3153759671f4495fbb556f47", "rawBytes": 72733, - "gzipBytes": 20175, + "gzipBytes": 20176, "isEntry": false, "imports": [ - "houseplan-assets/form-kit.styles-BQTkV2m1.js", - "houseplan-assets/houseplan-card-BiUNLHFh.js" + "houseplan-assets/form-kit.styles-BSWYQ2Fp.js", + "houseplan-assets/houseplan-card-W9mG3gab.js" ], "dynamicImports": [ - "houseplan-assets/summary-panel-editor-ClwrL_O4.js", - "houseplan-assets/summary-panel-metrics-BjFIAkz0.js" + "houseplan-assets/summary-panel-editor-Dq397KvS.js", + "houseplan-assets/summary-panel-metrics-Kwu_Jan4.js" ] }, { - "path": "houseplan-assets/zigbee-topology-B31-i8CL.js", - "sha256": "0758d5e433d1d0c5a6fea70281a8107f47861b7788a62f6604dc299f005843f4", + "path": "houseplan-assets/zigbee-topology-3KJks91U.js", + "sha256": "2431b5564b832bb307e7bb1fd96fa2fbd4af5790fe2c8218fbd2da566203454a", "rawBytes": 18962, - "gzipBytes": 7426, + "gzipBytes": 7427, "isEntry": false, "imports": [ - "houseplan-assets/houseplan-card-BiUNLHFh.js" + "houseplan-assets/houseplan-card-W9mG3gab.js" ], "dynamicImports": [] }, { - "path": "houseplan-assets/zigbee-topology-runtime-CuXFHyzq.js", - "sha256": "387eeadd92923ba31787102edb4382aa9a3f41fa535208ad22de6d96de945c4c", + "path": "houseplan-assets/zigbee-topology-runtime-DvCmPEhl.js", + "sha256": "1c7c46872e354ce04d529d33dcb929788c9bcad045ac0b787f3da38ffc96a861", "rawBytes": 3942, - "gzipBytes": 1761, + "gzipBytes": 1764, "isEntry": false, "imports": [ - "houseplan-assets/houseplan-card-BiUNLHFh.js", - "houseplan-assets/zigbee-topology-B31-i8CL.js" + "houseplan-assets/houseplan-card-W9mG3gab.js", + "houseplan-assets/zigbee-topology-3KJks91U.js" ], "dynamicImports": [] }, { "path": "houseplan-card.js", - "sha256": "62a1b4e12d0cb9b39367af3a13159d35a6589e5e2045e0c362e44a0a1b2815d5", + "sha256": "5aceb492cf13dcfe40d540a80ed83a334f1373ca33415a350fef7516db21783a", "rawBytes": 1205, "gzipBytes": 803, "isEntry": true, "imports": [ - "houseplan-assets/houseplan-card-BiUNLHFh.js" + "houseplan-assets/houseplan-card-W9mG3gab.js" ], "dynamicImports": [] }, { "path": "houseplan-panel.js", - "sha256": "04e67b0cbcf54b60e8373a2683d1a73f2346aa2655fd2ee2fac2cd225dddc56b", + "sha256": "f4d6406322e54766b3ad98ccca7cc877dd307a9c0f0af849a5d5f8be4ced70a3", "rawBytes": 6165, - "gzipBytes": 2325, + "gzipBytes": 2326, "isEntry": true, "imports": [ - "houseplan-assets/houseplan-card-BiUNLHFh.js" + "houseplan-assets/houseplan-card-W9mG3gab.js" ], "dynamicImports": [] } diff --git a/custom_components/houseplan/frontend/houseplan-assets/backdrop-pick-Ev52LRir.js b/custom_components/houseplan/frontend/houseplan-assets/backdrop-pick-ToIYfsVt.js similarity index 93% rename from custom_components/houseplan/frontend/houseplan-assets/backdrop-pick-Ev52LRir.js rename to custom_components/houseplan/frontend/houseplan-assets/backdrop-pick-ToIYfsVt.js index 1a51c183..e9ea54a0 100644 --- a/custom_components/houseplan/frontend/houseplan-assets/backdrop-pick-Ev52LRir.js +++ b/custom_components/houseplan/frontend/houseplan-assets/backdrop-pick-ToIYfsVt.js @@ -1,6 +1,6 @@ -globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db7c58754eeb4ba03f835b8d7c84c6";import{aA as e,c as t,A as i,aH as o,aI as n,dG as r}from"./houseplan-card-BiUNLHFh.js";function s(e){const t=e.visualViewport;return t&&Number.isFinite(t.width)&&Number.isFinite(t.height)?{left:Number(t.offsetLeft)||0,top:Number(t.offsetTop)||0,width:Math.max(0,Number(t.width)||0),height:Math.max(0,Number(t.height)||0)}:{left:0,top:0,width:e.innerWidth,height:e.innerHeight}}function a(e,t,i,o=7,n=8){const r=i.left+n,s=i.top+n,a=Math.max(r,i.left+i.width-n),l=Math.max(s,i.top+i.height-n),h=Math.max(0,a-r),d=Math.max(0,l-s),c=Math.min(Math.max(0,t.width),h),u=Math.min(Math.max(0,t.height),d);let p=e.left;p+c>a&&(p=e.right-c),p=Math.min(Math.max(r,p),Math.max(r,a-c));const g=e.bottom+o,_=e.top-o-u;let m="bottom",f=g;return g+u>l&&_>=s?(m="top",f=Math.min(Math.max(s,_),Math.max(s,l-u))):f=Math.min(Math.max(s,g),Math.max(s,l-u)),{left:Math.round(p),top:Math.round(f),side:m,maxWidth:Math.round(h),maxHeight:Math.round(d)}}class l{constructor(e,t,i){this.owner=e,this.name=t,this.keydown=i,this.host=null,this.root=null}window(){return this.owner.ownerDocument.defaultView}dialog(){return this.owner.closest("hp-dialog")}usesPopover(e=!1){const t=this.window();return!e&&!!t&&function(e){const t=e.HTMLElement?.prototype;return"function"==typeof t?.showPopover&&"function"==typeof t?.hidePopover}(t)}get hasFallback(){return!!this.host}containsPath(e){return e.includes(this.owner)||!!this.host&&e.includes(this.host)}ownsActiveElement(){let e=this.owner.ownerDocument.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;return!(!e||e!==this.owner&&!this.owner.shadowRoot?.contains(e)&&!this.root?.contains(e))}renderFallback(i,o){const n=this.ensureFallback();return n?(e(t`${i}`,n),n):null}surface(e,t){return t?this.owner.shadowRoot?.querySelector(e)||null:this.root?.querySelector(e)||null}destroy(){this.root&&e(i,this.root),this.host?.remove(),this.host=null,this.root=null}ensureFallback(){if(this.root?.isConnected)return this.root;const e=this.dialog()?.overlayPortal()||this.owner.ownerDocument.body;if(!e)return null;const t=this.owner.ownerDocument.createElement("div");return t.dataset.hpOverlay=this.name,t.style.display="contents",this.keydown&&t.addEventListener("keydown",this.keydown,!0),e.append(t),this.host=t,this.root=t.attachShadow({mode:"open"}),this.root}}let h=0;class d extends n{constructor(){super(...arguments),this.text="",this.ariaLabel="",this.pointerHover=!1,this._open=!1,this._openTimer=0,this._closeTimer=0,this._positionRaf=0,this._forceFallback=!1,this._hoverOwned=!1,this._overlayDispose=null,this._scrollDialog=null,this._descriptionId="hp-help-description-"+ ++h,this._surfacePointerEnter=()=>{const e=this._window();this._closeTimer&&e?.clearTimeout(this._closeTimer),this._closeTimer=0},this._surfacePointerLeave=()=>{this._scheduleClose()},this._outsidePointerDown=e=>{if(!this._open)return;const t=e.composedPath();this._floating.containsPath(t)||this._closeHelp(!1,"outside")},this._dialogScroll=e=>{const t=this._floating.containsPath(e.composedPath()),i=e.target,o=this._dialog(),n=i instanceof Node&&(i===o||i instanceof Element&&i.contains(this));var r;this._open&&(r=n,!t&&r)&&this._closeHelp(!1,"scroll")},this._keyDown=e=>{if(!this._open||e.defaultPrevented)return;if("Escape"===e.key)return e.preventDefault(),e.stopImmediatePropagation(),void this._closeHelp(this._floating.ownsActiveElement(),"escape");const t=this.renderRoot.querySelector(".trigger");if(!t||!e.composedPath().includes(t))return;const i=this._surface();if(!i||i.scrollHeight<=i.clientHeight)return;const o=Math.max(40,.8*i.clientHeight),n={ArrowDown:40,ArrowUp:-40,PageDown:o,PageUp:-o};if("Home"===e.key)i.scrollTop=0;else if("End"===e.key)i.scrollTop=i.scrollHeight;else{if(!(e.key in n))return;i.scrollBy({top:n[e.key],behavior:"auto"})}e.preventDefault(),e.stopImmediatePropagation()},this._floating=new l(this,"help",this._keyDown),this._queuePosition=()=>{if(!this._open||this._positionRaf)return;const e=this._window();e&&(this._positionRaf=e.requestAnimationFrame(()=>{this._positionRaf=0,this._position()||this._closeHelp()}))}}connectedCallback(){super.connectedCallback(),this.addEventListener("keydown",this._keyDown,!0)}willUpdate(){this.toggleAttribute("data-has-content",this._hasContent())}disconnectedCallback(){const e=this.ownerDocument.defaultView;this._unsubscribeOpenListeners(),this.removeEventListener("keydown",this._keyDown,!0),this._clearTimers(),this._positionRaf&&e?.cancelAnimationFrame(this._positionRaf),this._positionRaf=0,this._closeHelp(!1,"disconnect"),super.disconnectedCallback()}updated(e){if(e.has("pointerHover")&&!this.pointerHover){const e=this._window();this._openTimer&&e?.clearTimeout(this._openTimer),this._openTimer=0,this._hoverOwned&&this._closeHelp(!1,"outside")}this._hasContent()||!this._open?this._open&&e.has("text")&&(this._usesPopover()||this._renderFallback(),this._queuePosition()):this._closeHelp()}_window(){return this._floating.window()}_dialog(){return this._floating.dialog()}_usesPopover(){return this._floating.usesPopover(this._forceFallback)}_hasContent(){return e=this.text,t=this.ariaLabel,"string"==typeof e&&e.trim().length>0&&"string"==typeof t&&t.trim().length>0;var e,t}_clearTimers(){const e=this._window();this._openTimer&&e?.clearTimeout(this._openTimer),this._closeTimer&&e?.clearTimeout(this._closeTimer),this._openTimer=0,this._closeTimer=0}_scheduleOpen(){const e=this._window();this.pointerHover&&e&&!this._open&&!this._openTimer&&(this._closeTimer&&e.clearTimeout(this._closeTimer),this._closeTimer=0,this._openTimer=e.setTimeout(()=>{this._openTimer=0,this.isConnected&&(this._hoverOwned=!0,this._openHelp())},300))}_scheduleClose(){const e=this._window(),t=this.renderRoot.querySelector(".trigger");e&&!t?.matches(":focus-visible")&&(this._openTimer&&e.clearTimeout(this._openTimer),this._closeTimer&&e.clearTimeout(this._closeTimer),this._openTimer=0,this._closeTimer=e.setTimeout(()=>{this._closeTimer=0,this.isConnected&&this._closeHelp()},150))}_triggerPointerEnter(e){this.pointerHover&&"mouse"===e.pointerType&&this._scheduleOpen()}_triggerPointerLeave(e){"mouse"===e.pointerType&&this._scheduleClose()}_triggerFocus(){queueMicrotask(()=>{const e=this.renderRoot.querySelector(".trigger");e?.matches(":focus-visible")&&(this._hoverOwned=!1,this._openHelp())})}_triggerBlur(){this._scheduleClose()}_triggerClick(){this._open?this._closeHelp():(this._hoverOwned=!1,this._openHelp())}_subscribeOpenListeners(){this.ownerDocument.addEventListener("pointerdown",this._outsidePointerDown,!0),this.ownerDocument.addEventListener("keydown",this._keyDown,!0);const e=this._window();e?.addEventListener("resize",this._queuePosition),e?.addEventListener("orientationchange",this._queuePosition),e?.visualViewport?.addEventListener("resize",this._queuePosition),e?.visualViewport?.addEventListener("scroll",this._queuePosition),this._scrollDialog=this._dialog(),this._scrollDialog?.addEventListener("scroll",this._dialogScroll,!0)}_unsubscribeOpenListeners(){this.ownerDocument.removeEventListener("pointerdown",this._outsidePointerDown,!0),this.ownerDocument.removeEventListener("keydown",this._keyDown,!0);const e=this._window();e?.removeEventListener("resize",this._queuePosition),e?.removeEventListener("orientationchange",this._queuePosition),e?.visualViewport?.removeEventListener("resize",this._queuePosition),e?.visualViewport?.removeEventListener("scroll",this._queuePosition),this._scrollDialog?.removeEventListener("scroll",this._dialogScroll,!0),this._scrollDialog=null}async _openHelp(){!this._open&&this._hasContent()&&(this._clearTimers(),this._forceFallback=!1,this._open=!0,this._subscribeOpenListeners(),await this.updateComplete,this._open&&(this._usesPopover()||this._renderFallback(),this._position()?this._overlayDispose=this._dialog()?.registerOverlay({owner:this,group:"transient",close:e=>this._closeHelp("escape"===e&&this._floating.ownsActiveElement(),e)})||null:this._closeHelp()))}_closeHelp(e=!1,t="exclusive"){if(!this._open&&!this._floating.hasFallback)return;this._clearTimers();const i=this._overlayDispose;this._overlayDispose=null,i?.();const o=this.renderRoot.querySelector(".tooltip");if(o?.hidePopover)try{o.matches(":popover-open")&&o.hidePopover()}catch{}this._open=!1,this._hoverOwned=!1,this._unsubscribeOpenListeners(),this._floating.destroy(),e&&this.updateComplete.then(()=>this.renderRoot.querySelector(".trigger")?.focus())}_tooltipTemplate(e){return t`
a&&(p=e.right-d),p=Math.min(Math.max(r,p),Math.max(r,a-d));const g=e.bottom+o,_=e.top-o-u;let m="bottom",f=g;return g+u>l&&_>=s?(m="top",f=Math.min(Math.max(s,_),Math.max(s,l-u))):f=Math.min(Math.max(s,g),Math.max(s,l-u)),{left:Math.round(p),top:Math.round(f),side:m,maxWidth:Math.round(h),maxHeight:Math.round(c)}}class l{constructor(e,t,i){this.owner=e,this.name=t,this.keydown=i,this.host=null,this.root=null}window(){return this.owner.ownerDocument.defaultView}dialog(){return this.owner.closest("hp-dialog")}usesPopover(e=!1){const t=this.window();return!e&&!!t&&function(e){const t=e.HTMLElement?.prototype;return"function"==typeof t?.showPopover&&"function"==typeof t?.hidePopover}(t)}get hasFallback(){return!!this.host}containsPath(e){return e.includes(this.owner)||!!this.host&&e.includes(this.host)}ownsActiveElement(){let e=this.owner.ownerDocument.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;return!(!e||e!==this.owner&&!this.owner.shadowRoot?.contains(e)&&!this.root?.contains(e))}renderFallback(i,o){const n=this.ensureFallback();return n?(e(t`${i}`,n),n):null}surface(e,t){return t?this.owner.shadowRoot?.querySelector(e)||null:this.root?.querySelector(e)||null}destroy(){this.root&&e(i,this.root),this.host?.remove(),this.host=null,this.root=null}ensureFallback(){if(this.root?.isConnected)return this.root;const e=this.dialog()?.overlayPortal()||this.owner.ownerDocument.body;if(!e)return null;const t=this.owner.ownerDocument.createElement("div");return t.dataset.hpOverlay=this.name,t.style.display="contents",this.keydown&&t.addEventListener("keydown",this.keydown,!0),e.append(t),this.host=t,this.root=t.attachShadow({mode:"open"}),this.root}}let h=0;class c extends n{constructor(){super(...arguments),this.text="",this.ariaLabel="",this.pointerHover=!1,this._open=!1,this._openTimer=0,this._closeTimer=0,this._positionRaf=0,this._forceFallback=!1,this._hoverOwned=!1,this._overlayDispose=null,this._scrollDialog=null,this._descriptionId="hp-help-description-"+ ++h,this._surfacePointerEnter=()=>{const e=this._window();this._closeTimer&&e?.clearTimeout(this._closeTimer),this._closeTimer=0},this._surfacePointerLeave=()=>{this._scheduleClose()},this._outsidePointerDown=e=>{if(!this._open)return;const t=e.composedPath();this._floating.containsPath(t)||this._closeHelp(!1,"outside")},this._dialogScroll=e=>{const t=this._floating.containsPath(e.composedPath()),i=e.target,o=this._dialog(),n=i instanceof Node&&(i===o||i instanceof Element&&i.contains(this));var r;this._open&&(r=n,!t&&r)&&this._closeHelp(!1,"scroll")},this._keyDown=e=>{if(!this._open||e.defaultPrevented)return;if("Escape"===e.key)return e.preventDefault(),e.stopImmediatePropagation(),void this._closeHelp(this._floating.ownsActiveElement(),"escape");const t=this.renderRoot.querySelector(".trigger");if(!t||!e.composedPath().includes(t))return;const i=this._surface();if(!i||i.scrollHeight<=i.clientHeight)return;const o=Math.max(40,.8*i.clientHeight),n={ArrowDown:40,ArrowUp:-40,PageDown:o,PageUp:-o};if("Home"===e.key)i.scrollTop=0;else if("End"===e.key)i.scrollTop=i.scrollHeight;else{if(!(e.key in n))return;i.scrollBy({top:n[e.key],behavior:"auto"})}e.preventDefault(),e.stopImmediatePropagation()},this._floating=new l(this,"help",this._keyDown),this._queuePosition=()=>{if(!this._open||this._positionRaf)return;const e=this._window();e&&(this._positionRaf=e.requestAnimationFrame(()=>{this._positionRaf=0,this._position()||this._closeHelp()}))}}connectedCallback(){super.connectedCallback(),this.addEventListener("keydown",this._keyDown,!0)}willUpdate(){this.toggleAttribute("data-has-content",this._hasContent())}disconnectedCallback(){const e=this.ownerDocument.defaultView;this._unsubscribeOpenListeners(),this.removeEventListener("keydown",this._keyDown,!0),this._clearTimers(),this._positionRaf&&e?.cancelAnimationFrame(this._positionRaf),this._positionRaf=0,this._closeHelp(!1,"disconnect"),super.disconnectedCallback()}updated(e){if(e.has("pointerHover")&&!this.pointerHover){const e=this._window();this._openTimer&&e?.clearTimeout(this._openTimer),this._openTimer=0,this._hoverOwned&&this._closeHelp(!1,"outside")}this._hasContent()||!this._open?this._open&&e.has("text")&&(this._usesPopover()||this._renderFallback(),this._queuePosition()):this._closeHelp()}_window(){return this._floating.window()}_dialog(){return this._floating.dialog()}_usesPopover(){return this._floating.usesPopover(this._forceFallback)}_hasContent(){return e=this.text,t=this.ariaLabel,"string"==typeof e&&e.trim().length>0&&"string"==typeof t&&t.trim().length>0;var e,t}_clearTimers(){const e=this._window();this._openTimer&&e?.clearTimeout(this._openTimer),this._closeTimer&&e?.clearTimeout(this._closeTimer),this._openTimer=0,this._closeTimer=0}_scheduleOpen(){const e=this._window();this.pointerHover&&e&&!this._open&&!this._openTimer&&(this._closeTimer&&e.clearTimeout(this._closeTimer),this._closeTimer=0,this._openTimer=e.setTimeout(()=>{this._openTimer=0,this.isConnected&&(this._hoverOwned=!0,this._openHelp())},300))}_scheduleClose(){const e=this._window(),t=this.renderRoot.querySelector(".trigger");e&&!t?.matches(":focus-visible")&&(this._openTimer&&e.clearTimeout(this._openTimer),this._closeTimer&&e.clearTimeout(this._closeTimer),this._openTimer=0,this._closeTimer=e.setTimeout(()=>{this._closeTimer=0,this.isConnected&&this._closeHelp()},150))}_triggerPointerEnter(e){this.pointerHover&&"mouse"===e.pointerType&&this._scheduleOpen()}_triggerPointerLeave(e){"mouse"===e.pointerType&&this._scheduleClose()}_triggerFocus(){queueMicrotask(()=>{const e=this.renderRoot.querySelector(".trigger");e?.matches(":focus-visible")&&(this._hoverOwned=!1,this._openHelp())})}_triggerBlur(){this._scheduleClose()}_triggerClick(){this._open?this._closeHelp():(this._hoverOwned=!1,this._openHelp())}_subscribeOpenListeners(){this.ownerDocument.addEventListener("pointerdown",this._outsidePointerDown,!0),this.ownerDocument.addEventListener("keydown",this._keyDown,!0);const e=this._window();e?.addEventListener("resize",this._queuePosition),e?.addEventListener("orientationchange",this._queuePosition),e?.visualViewport?.addEventListener("resize",this._queuePosition),e?.visualViewport?.addEventListener("scroll",this._queuePosition),this._scrollDialog=this._dialog(),this._scrollDialog?.addEventListener("scroll",this._dialogScroll,!0)}_unsubscribeOpenListeners(){this.ownerDocument.removeEventListener("pointerdown",this._outsidePointerDown,!0),this.ownerDocument.removeEventListener("keydown",this._keyDown,!0);const e=this._window();e?.removeEventListener("resize",this._queuePosition),e?.removeEventListener("orientationchange",this._queuePosition),e?.visualViewport?.removeEventListener("resize",this._queuePosition),e?.visualViewport?.removeEventListener("scroll",this._queuePosition),this._scrollDialog?.removeEventListener("scroll",this._dialogScroll,!0),this._scrollDialog=null}async _openHelp(){!this._open&&this._hasContent()&&(this._clearTimers(),this._forceFallback=!1,this._open=!0,this._subscribeOpenListeners(),await this.updateComplete,this._open&&(this._usesPopover()||this._renderFallback(),this._position()?this._overlayDispose=this._dialog()?.registerOverlay({owner:this,group:"transient",close:e=>this._closeHelp("escape"===e&&this._floating.ownsActiveElement(),e)})||null:this._closeHelp()))}_closeHelp(e=!1,t="exclusive"){if(!this._open&&!this._floating.hasFallback)return;this._clearTimers();const i=this._overlayDispose;this._overlayDispose=null,i?.();const o=this.renderRoot.querySelector(".tooltip");if(o?.hidePopover)try{o.matches(":popover-open")&&o.hidePopover()}catch{}this._open=!1,this._hoverOwned=!1,this._unsubscribeOpenListeners(),this._floating.destroy(),e&&this.updateComplete.then(()=>this.renderRoot.querySelector(".trigger")?.focus())}_tooltipTemplate(e){return t``}_renderFallback(){const e=d.styles.cssText;this._floating.renderFallback(this._tooltipTemplate(!1),e)}_surface(){return this._floating.surface(".tooltip",this._usesPopover())}_position(){if(!this._open)return!1;const e=this._window(),t=this.renderRoot.querySelector(".trigger");let i=this._surface();if(!e||!t?.isConnected||!i?.isConnected)return!1;const o=s(e);if(i.style.maxWidth=`${Math.max(0,Math.min(320,o.width-16))}px`,i.style.maxHeight=`${Math.max(0,o.height-16)}px`,i.style.visibility="hidden",this._usesPopover()&&i.showPopover)try{i.matches(":popover-open")||i.showPopover()}catch{if(this._forceFallback=!0,this._renderFallback(),i=this._surface(),!i?.isConnected)return!1;i.style.visibility="hidden"}const n=t.getBoundingClientRect(),r=i.getBoundingClientRect();if(!(n.width&&n.height&&r.width&&r.height))return!1;const l=a(n,r,o);return i.style.left=`${l.left}px`,i.style.top=`${l.top}px`,i.dataset.side=l.side,i.style.visibility="",!0}render(){if(!this._hasContent())return i;const e=this.ariaLabel.trim();return t` + @pointerenter=${this._surfacePointerEnter} @pointerleave=${this._surfacePointerLeave}>${this.text}
`}_renderFallback(){const e=c.styles.cssText;this._floating.renderFallback(this._tooltipTemplate(!1),e)}_surface(){return this._floating.surface(".tooltip",this._usesPopover())}_position(){if(!this._open)return!1;const e=this._window(),t=this.renderRoot.querySelector(".trigger");let i=this._surface();if(!e||!t?.isConnected||!i?.isConnected)return!1;const o=s(e);if(i.style.maxWidth=`${Math.max(0,Math.min(320,o.width-16))}px`,i.style.maxHeight=`${Math.max(0,o.height-16)}px`,i.style.visibility="hidden",this._usesPopover()&&i.showPopover)try{i.matches(":popover-open")||i.showPopover()}catch{if(this._forceFallback=!0,this._renderFallback(),i=this._surface(),!i?.isConnected)return!1;i.style.visibility="hidden"}const n=t.getBoundingClientRect(),r=i.getBoundingClientRect();if(!(n.width&&n.height&&r.width&&r.height))return!1;const l=a(n,r,o);return i.style.left=`${l.left}px`,i.style.top=`${l.top}px`,i.dataset.side=l.side,i.style.visibility="",!0}render(){if(!this._hasContent())return i;const e=this.ariaLabel.trim();return t` ${this.text} `:G} - `}}_g.properties={hass:{attribute:!1},_config:{state:!0},_snap:{state:!0},_continuityEpoch:{state:!0}},_g.styles=[ap,o`.hp-static-title{font-weight:700;padding:10px 14px 6px;font-size:16px;color:var(--primary-text-color);}.hp-static-body{position:relative;}.hp-static-stage{position:relative;width:100%;container-type:inline-size;overflow:hidden;pointer-events:none;background:var(--ha-card-background,var(--card-background-color,#111));}.hp-static-stage>svg{position:absolute;inset:0;width:100%;height:100%;display:block;z-index:1;}.hp-static-stage>.hp-paper-outline-svg{z-index:0;overflow:visible;}.hp-paper{fill:var(--ha-card-background,var(--card-background-color,#111));stroke:none;}.wallbody-fill{fill:var(--wall-fill,#ffffff);fill-opacity:var(--wall-fill-op,1);fill-rule:evenodd;stroke:none;pointer-events:none;}.wallbody{fill:url(#hp-wall-hatch);fill-rule:evenodd;stroke:var(--room-stroke,var(--hp-muted,#607d8b));stroke-width:calc(0.6px * var(--hp-cell-visual-scale,1));pointer-events:none;}.wallbody.solid{fill:none;}.hp-static-stage .devlayer{position:absolute;inset:0;z-index:2;}.hp-static-foot{padding:8px 12px 12px;pointer-events:auto;}.hp-static-btn{width:100%;padding:9px 14px;border:none;border-radius:10px;background:var(--primary-color,#3ea6ff);color:var(--text-primary-color,#fff);font-size:14px;font-weight:600;cursor:pointer;}:host([data-pointer-hover]) .hp-static-btn:hover{filter:brightness(1.08);}.hp-static-error{padding:24px;text-align:center;color:var(--secondary-text-color,#9aa4ad);}`],customElements.get("houseplan-space-card")||customElements.define("houseplan-space-card",_g),window.customCards=window.customCards||[],window.customCards.find(e=>"houseplan-space-card"===e.type)||window.customCards.push({type:"houseplan-space-card",name:"House Plan — Space (static)",description:"Read-only live schematic of a single houseplan space, with a deep-link button.",preview:!1,documentation:"https://github.com/Matysh/houseplan-card"});const mg=o`:host{--hp-editor-tray-bg-fallback:color-mix(in srgb,var(--card-background-color,var(--hp-bg)) 94%,var(--hp-line));--hp-editor-tray-bg:color-mix(in srgb,var(--card-background-color,var(--hp-bg)) 86%,transparent);--hp-editor-tray-border:color-mix(in srgb,var(--hp-line) 82%,var(--hp-accent));--hp-editor-tray-blur:8px;--hp-editor-tray-shadow:var(--shadow-2);}.editor-secondary-host{position:absolute;inset:var(--sp-2) var(--sp-4) auto;z-index:70;display:flex;justify-content:flex-end;pointer-events:none;}.editor-secondary-host.kind-palette,.editor-secondary-host.kind-group{justify-content:flex-start;}.editor-secondary{pointer-events:none;max-width:100%;display:flex;align-items:center;gap:var(--sp-3);padding:var(--sp-3) var(--sp-4);color:var(--hp-txt);background:var(--card-background-color,var(--hp-bg));background:var(--hp-editor-tray-bg-fallback);border:1px solid var(--hp-line);border-color:var(--hp-editor-tray-border);border-radius:var(--rad-l);box-shadow:var(--hp-editor-tray-shadow);opacity:0;visibility:hidden;transform:translateY(-4px);transition:opacity 0.1s ease,transform 0.1s cubic-bezier(0.2,0.7,0.2,1),visibility 0s linear 0.1s;touch-action:auto;}.editor-secondary-host.open .editor-secondary{pointer-events:auto;opacity:1;visibility:visible;transform:translateY(0);transition-duration:0.14s,0.14s,0s;transition-delay:0s;}.editor-secondary-host.blocked .editor-secondary{pointer-events:none;}@supports ((backdrop-filter:blur(1px)) or (-webkit-backdrop-filter:blur(1px))){.editor-secondary{background:var(--hp-editor-tray-bg);-webkit-backdrop-filter:blur(var(--hp-editor-tray-blur));backdrop-filter:blur(var(--hp-editor-tray-blur));}}.editor-secondary-content,.editor-group-items{display:flex;align-items:center;gap:var(--sp-3);min-width:0;}.editor-context-label{max-width:14rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding-inline-end:var(--sp-4);border-inline-end:1px solid var(--hp-line);color:var(--hp-muted);font-size:var(--fs-s);}.editor-secondary.kind-palette{width:min(760px,100%);align-items:stretch;padding:0;overflow:hidden;}.editor-secondary.kind-palette .editor-secondary-content,.editor-secondary.kind-palette .furnpalette{width:100%;}.editor-secondary.kind-palette .furnpalette{max-height:38vh;border:0;background:transparent;}.editor-group-launcher .group-chevron{--mdc-icon-size:16px;transition:transform 0.14s ease;}.editor-group-launcher[aria-expanded="true"] .group-chevron{transform:rotate(180deg);}.editor-secondary .bdhint{font-size:var(--fs-s);color:var(--hp-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}.editor-secondary .dfill{display:inline-flex;align-items:center;gap:var(--sp-2);font-size:var(--fs-s);cursor:pointer;}.editor-secondary .dfill input[type="checkbox"]{width:16px;height:16px;flex:none;margin:0;padding:0;}.editor-secondary hp-color-opacity{flex:0 0 auto;}.editor-secondary input{width:74px;background:transparent;border:1px solid var(--hp-line);color:var(--hp-txt);border-radius:var(--rad-s);padding:var(--sp-3) var(--sp-4);font-size:var(--fs-m);}.editor-secondary label,.editor-secondary .hint{color:var(--hp-muted);font-size:var(--fs-s);}.editor-secondary .drawwall{display:inline-flex;align-items:center;gap:var(--sp-3);white-space:nowrap;}.editor-secondary .drawwall input{width:4.2em;}.editor-secondary .drawwall .opl{color:var(--hp-muted);font-size:var(--fs-s);}@container (min-width:560px) and (max-width:899px){.editor-secondary-content,.editor-group-items{flex-wrap:wrap;justify-content:flex-end;}}@container (max-width:559px){.editor-secondary-host{inset-inline:var(--sp-4);}.editor-secondary{max-width:100%;}.editor-secondary-content,.editor-group-items{overflow-x:auto;scrollbar-width:thin;}.editor-secondary-content>*,.editor-group-items>*{flex:none;}.editor-context-label{display:none;}}@media (prefers-reduced-motion:reduce){.editor-secondary{transition:none;}.editor-group-launcher .group-chevron{transition:none;}}`;class gg{constructor(e=50){this._undo=[],this._redo=[],this._limit=Math.max(30,Math.floor(e))}get canUndo(){return this._undo.length>0}get canRedo(){return this._redo.length>0}get undoName(){return this._undo[this._undo.length-1]?.name??null}get redoName(){return this._redo[this._redo.length-1]?.name??null}get size(){return this._undo.length}push(e){this._undo.push(e),this._undo.length>this._limit&&this._undo.splice(0,this._undo.length-this._limit),this._redo=[]}undo(){const e=this._undo.pop()??null;return e&&this._redo.push(e),e}redo(){const e=this._redo.pop()??null;return e&&this._undo.push(e),e}removeWhere(e){const t=this._undo.length,i=this._redo.length;return this._undo=this._undo.filter(t=>!e(t)),this._redo=this._redo.filter(t=>!e(t)),t+i-this._undo.length-this._redo.length}clear(){this._undo=[],this._redo=[]}}function fg(e,t){const i=e[t];return i&&Number.isFinite(i.x)&&Number.isFinite(i.y)?{x:i.x,y:i.y,..."string"==typeof i.s?{s:i.s}:{}}:null}function vg(e,t,i){if(null===i){if(!(t in e))return e;const i={...e};return delete i[t],i}const n={...e[t]||{}};delete n.x,delete n.y,delete n.s;const r={...n,x:i.x,y:i.y,...void 0!==i.s?{s:i.s}:{}};return{...e,[t]:r}}const yg="houseplan-card:version-reload-target:v1";function bg(e){if("string"!=typeof e)return null;return e.trim()||null}class wg{constructor(e){this.hooks=e,this._input={frontendVersion:null,backendVersion:null,kiosk:!1,reducedMotion:!1},this._relation={kind:"unknown"},this._banner=null,this._connected=!1,this._attemptTarget=null,this._attemptState=null,this._noticeToken=0}get relation(){return this._relation}get banner(){return this._banner}get hasCurrentMismatchNotice(){return"mismatch"===this._relation.kind&&"visible"===this._banner?.phase}connect(){this._connected||(this._connected=!0,this._attemptTarget=null,this._attemptState=null,this._reconcile())}disconnect(){(this._connected||this._banner)&&(this._connected=!1,this._cancelTimer(),this._banner&&(this._banner=null,this.hooks.changed()))}update(e){const t={frontendVersion:bg(e.frontendVersion),backendVersion:bg(e.backendVersion),kiosk:!0===e.kiosk,reducedMotion:!0===e.reducedMotion},i=function(e,t){const i=bg(e),n=bg(t);return i&&n?i===n?{kind:"equal",frontend:i,backend:n}:{kind:"mismatch",frontend:i,backend:n}:{kind:"unknown"}}(t.frontendVersion,t.backendVersion),n=!((e,t)=>e.frontendVersion===t.frontendVersion&&e.backendVersion===t.backendVersion&&e.kiosk===t.kiosk&&e.reducedMotion===t.reducedMotion)(this._input,t)||!((e,t)=>e.kind===t.kind&&("unknown"===e.kind||"unknown"!==t.kind&&e.frontend===t.frontend&&e.backend===t.backend))(this._relation,i);this._input=t,this._relation=i,n&&this._reconcile()}finishBannerExit(e){this._banner&&"leaving"===this._banner.phase&&this._banner.token===e&&(this._banner=null,this.hooks.changed())}_reconcile(){if(this._cancelTimer(),!this._connected||"mismatch"!==this._relation.kind)return this._attemptTarget=null,this._attemptState=null,void this._hideBanner();if(!this._input.kiosk)return this._attemptTarget=null,this._attemptState=null,void this._showBanner(this._relation.frontend,this._relation.backend);const e=this._relation.backend;if(this._attemptTarget===e&&null!==this._attemptState||(this._attemptTarget=e,this._attemptState=function(e,t){try{const i=e();return i?i.getItem(yg)===t?"attempted":"fresh":"unavailable"}catch{return"unavailable"}}(this.hooks.storage,e)),"fresh"===this._attemptState)return this._hideBanner(),void this._armTimer();this._showBanner(this._relation.frontend,e)}_armTimer(){this._connected&&void 0===this._timer&&"mismatch"===this._relation.kind&&this._input.kiosk&&"fresh"===this._attemptState&&(this._timer=this.hooks.clock.setTimeout(()=>{this._timer=void 0,this._tick()},250))}_cancelTimer(){void 0!==this._timer&&(this.hooks.clock.clearTimeout(this._timer),this._timer=void 0)}_tick(){if(!this._connected||"mismatch"!==this._relation.kind||!this._input.kiosk||"fresh"!==this._attemptState)return;if(!function(e){return e.connected&&e.initialFrameSettled&&e.viewOnly&&e.surfacesIdle&&e.configWritesIdle&&e.physicalWritesIdle&&e.layoutWritesIdle&&e.gesturesIdle&&e.interactionPauseElapsed&&e.baseZoom}(this.hooks.safety()))return void this._armTimer();const e=this._relation.backend,t=function(e,t){try{const i=e();return i?i.getItem(yg)===t?"attempted":(i.setItem(yg,t),"claimed"):"unavailable"}catch{return"unavailable"}}(this.hooks.storage,e);if(this._attemptTarget=e,this._attemptState="claimed"===t?"attempted":t,"claimed"===t){this._showBanner(this._relation.frontend,e);try{this.hooks.reload()}catch{}}else this._showBanner(this._relation.frontend,e)}_showBanner(e,t){"visible"===this._banner?.phase&&this._banner.frontend===e&&this._banner.backend===t||(this._banner={frontend:e,backend:t,phase:"visible",token:++this._noticeToken},this.hooks.changed())}_hideBanner(){if(this._banner)return this._input.reducedMotion?(this._banner=null,void this.hooks.changed()):void("leaving"!==this._banner.phase&&(this._banner={...this._banner,phase:"leaving",token:++this._noticeToken},this.hooks.changed()))}}const kg=1;function xg(e,t){const i=t&&"object"==typeof t?t:{};e._haIntegrationVersion=bg(i.integration_version);const n=i.support_api;e._haSupportApi="number"==typeof n&&Number.isSafeInteger(n)?n:null,e._haDecorAssetsApi=1===i.decor_assets_api?1:null,e._haSummaryPanelApi=1===i.summary_panel_api?1:null,e._haRadarStage1Api=1===i.radar_stage1_api?1:null,e._syncVersionRecovery()}function Sg(e){const t=e._stageEl,i=e._loadOk&&!e._loading&&e._continuityDataReady&&!e._resumeSettling&&!e._connectionWasLost&&!e._booting&&!e._bootFading&&!e._bootSettling&&!e._bootSoft&&e._continuity.hasCompleteFrame&&"steady"===e._continuity.state&&!e._continuity.overlayBlocksInteraction&&!!t&&t.clientWidth>0&&t.clientHeight>0,n=!(0!==e._pointers.size||0!==e._touchContacts.size||e._touchSequenceMultitouch||e._roomPointer||e._panStart||e._panLock||e._pinchStart||e._swipeStart||e._tabDrag||e._tabDragRelease||e._drag||e._deviceDrag||e._rlResize||e._resize?.dragging||e._physicalDrag||e._physicalRotate||e._opDrag||e._decorDraft||e._decorMove||e._dtDrag||e._bdDrag||e._furnTouchPending||e._compassDrag||e._viewportGestureDirty||e._devicePositionBusy||e._modeTransitionBusy||e._cameraTransition.active||e._slide||0!==e._warmModeRequest),r=!(e._editorSecondaryDialogBlocked||e._partitionDeleteDialog||e._roomDeleteDialog||e._backdropGuard||e._vacFit||e._editorSecondary?.hasOpenGroup||e._furnPalette||e._decorImagePalette);return{connected:e.isConnected,initialFrameSettled:i,viewOnly:!0===e._config?.kiosk&&"view"===e._mode&&!e._editing,surfacesIdle:r,configWritesIdle:0===e._writesPending&&!e._saveConfigDebounced.pending(),physicalWritesIdle:0===e._pendingPhysicalWrites.size,layoutWritesIdle:!e._persistLayout.pending()&&0===e._dirtyPos.size&&0===e._sentPos.size&&!e._devicePositionBusy,gesturesIdle:n,interactionPauseElapsed:Date.now()>=e._cyclePausedUntil,baseZoom:e._zoom<=1.001}}class $g{constructor(){this.seen=null,this.diagnosticsCache=null}observe(e,t,i,n){this.invalidateDiagnosticsForHass(e,t,i),this.intake(t,n)}intake(e,t){e&&this.seen!==e&&(this.seen=e,t())}invalidate(){this.diagnosticsCache=null}invalidateDiagnosticsForHass(e,t,i){this.diagnosticsCache&&(e?.entities!==t?.entities||e?.devices!==t?.devices||[...i?.entityIds||[]].some(i=>!!e?.states?.[i]!=!!t?.states?.[i]))&&this.invalidate()}diagnostics(e,t,i){if(this.diagnosticsCache)return this.diagnosticsCache;const n={active:0,ha_disabled:0,orphaned:0,unverified:0};for(const e of t)e.removed||"virtual"===e.binding||n[i(e.binding).kind]++;return this.diagnosticsCache={registry:ud(e),bindings:n},this.diagnosticsCache}}function Mg(e){const t=e;t._hassSequence++,t._renderSnapshotAt=Date.now(),t._continuity.note("hass-snapshot"),t._ensureHaRegistryAuthority(),t._planHassMemo=null,t._hookConnection(),!t._loadOk&&!t._loading&&t._loadTries<8&&t._loadFromServer(),t._maybeRebuildDevices(),t._vacTick(),t._activityTick()}function Rg(e){return!!e&&"object"==typeof e&&1===e.version}function Cg(e,t){const i=e.radar;return e.space===t&&!0!==e.hidden&&!0!==e.removed&&Rg(i)&&!0===i.enabled&&!1!==i.show_live}const Tg={ok:"radar.health_ok",off:"radar.health_off",stale:"radar.health_stale",partial:"radar.health_partial",restricted:"radar.health_restricted",incomplete:"radar.health_incomplete",position_unavailable:"radar.health_position_unavailable",unavailable:"radar.health_unavailable",needs_setup:"radar.health_needs_setup",inconsistent:"radar.health_inconsistent",unknown:"radar.health_unknown"};const Dg=e=>"number"==typeof e&&Number.isFinite(e);class Ag{constructor(e){this.host=e,this.frames=new Map,this.connection=null,this.space="",this.generation=0,this.expiryTimer=0,this.deadlines=new Map}sync(e,t){const i=this.host.hass?.connection;if(!t||!i||!this.host.isConnected)return void this.stop();if(this.unsubscribe&&this.connection===i&&this.space===e)return;this.stop(),this.connection=i,this.space=e;const n=++this.generation,r=i.subscribeMessage?.bind(i);"function"==typeof r&&Promise.resolve(r(e=>{if(n!==this.generation||!this.host.isConnected)return;const t=function(e){if(!e||"object"!=typeof e)return null;const t=e;if("string"!=typeof t.marker_id||"string"!=typeof t.server_session_id||!Number.isSafeInteger(t.seq)||"string"!=typeof t.health)return null;const i=Array.isArray(t.targets)?t.targets.slice(0,256).flatMap(e=>{if(!e||"object"!=typeof e)return[];const t=e;return"string"==typeof t.slot&&Dg(t.x)&&Dg(t.y)&&Dg(t.expires_at)&&Dg(t.reported_at)&&("bounded_latest"===t.pair_quality||"coherent"===t.pair_quality)?[{...t,included:!0===t.included,smooth:!0===t.smooth}]:[]}):[],n=Array.isArray(t.ranges)?t.ranges.slice(0,64).flatMap(e=>{if(!e||"object"!=typeof e)return[];const t=e;if(!("string"==typeof t.id&&Dg(t.x)&&Dg(t.y)&&Dg(t.radius)&&Dg(t.expires_at)&&Dg(t.reported_at)))return[];const i=Array.isArray(t.segments)?t.segments.slice(0,64).flatMap(e=>{if(!Array.isArray(e))return[];const t=e.slice(0,181).flatMap(e=>Array.isArray(e)&&2===e.length&&Dg(e[0])&&Dg(e[1])?[[e[0],e[1]]]:[]);return t.length>=2?[t]:[]}):void 0;return[{...t,...i?{segments:i}:{}}]}):[],r=Array.isArray(t.zones)?t.zones.slice(0,64).flatMap(e=>{if(!e||"object"!=typeof e)return[];const t=e;if("string"!=typeof t.id)return[];const i=t.state;if(null!==i&&"boolean"!=typeof i&&!Dg(i))return[];const n=Array.isArray(t.polygon)?t.polygon.slice(0,64).flatMap(e=>Array.isArray(e)&&2===e.length&&Dg(e[0])&&Dg(e[1])?[[e[0],e[1]]]:[]):[];return[{id:t.id,state:i,...n.length>=3?{polygon:n}:{}}]}):[];return{server_session_id:t.server_session_id,marker_id:t.marker_id,source_generation:"string"==typeof t.source_generation?t.source_generation:void 0,calibration_revision:"string"==typeof t.calibration_revision?t.calibration_revision:void 0,seq:t.seq,reported_at:Dg(t.reported_at)?t.reported_at:void 0,expires_at:Dg(t.expires_at)?t.expires_at:void 0,health:t.health,reported_presence:"boolean"==typeof t.reported_presence?t.reported_presence:null,complete:!0===t.complete,targets:i,ranges:n,zones:r}}(e);if(!t)return;if(!function(e,t){return!e||t.server_session_id!==e.server_session_id||t.source_generation!==e.source_generation||t.calibration_revision!==e.calibration_revision||t.seq>e.seq}(this.frames.get(t.marker_id),t))return;const i=function(e,t=Date.now()){if(!Dg(e.expires_at))return null;if(!Dg(e.reported_at))return Math.max(0,1e3*e.expires_at-t);const i=Math.max(0,1e3*(e.expires_at-e.reported_at)),n=Math.max(0,t-1e3*e.reported_at);return Math.max(0,i-n)}(t);"restricted"===t.health||"disabled"===t.health||0===i?(this.frames.delete(t.marker_id),this.deadlines.delete(t.marker_id)):(this.frames.set(t.marker_id,t),null==i?this.deadlines.delete(t.marker_id):this.deadlines.set(t.marker_id,this.monotonicNow()+i)),this.armExpiry(),this.host.requestUpdate()},{type:"houseplan/radar/subscribe",space_id:e})).then(e=>{n===this.generation&&this.host.isConnected?"function"==typeof e&&(this.unsubscribe=e):"function"==typeof e&&e()}).catch(()=>{n===this.generation&&this.stop()})}stop(){this.generation++,this.unsubscribe?.(),this.unsubscribe=void 0,this.connection=null,this.space="",clearTimeout(this.expiryTimer),this.expiryTimer=0,this.frames.size&&(this.frames.clear(),this.host.isConnected&&this.host.requestUpdate()),this.deadlines.clear()}armExpiry(){clearTimeout(this.expiryTimer);const e=this.monotonicNow(),t=[...this.deadlines.values()].filter(t=>t>e);if(!t.length)return;const i=Math.max(20,Math.min(...t)-e+10);this.expiryTimer=window.setTimeout(()=>{this.expiryTimer=0;let e=!1;const t=this.monotonicNow();for(const[i,n]of this.deadlines)n>t||(this.deadlines.delete(i),this.frames.delete(i),e=!0);this.armExpiry(),e&&this.host.isConnected&&this.host.requestUpdate()},i)}monotonicNow(){return globalThis.performance?.now?.()??Date.now()}}const Pg=Object.freeze({enabled:!1,z2mBaseTopics:Object.freeze([])});function Fg(e){if("string"!=typeof e)return null;const t=e.trim().replace(/^\/+|\/+$/g,"").replace(/\/{2,}/g,"/");return!t||t.length>180||/[#+\u0000-\u001f\u007f]/.test(t)?null:t}function zg(e){const t=e?.zigbee_topology;if(!t||"object"!=typeof t)return Pg;const i=t,n=Array.isArray(i.z2m_base_topics)?i.z2m_base_topics:Array.isArray(i.z2mBaseTopics)?i.z2mBaseTopics:[],r=new Set,o=[];for(const e of n){const t=Fg(e);if(t&&!r.has(t)&&(r.add(t),o.push(t),8===o.length))break}return{enabled:!0===i.enabled,z2mBaseTopics:o}}function Ig(e,t){const i={...e},n=t.z2mBaseTopics.map(Fg).filter(Boolean);return t.enabled||n.length?i.zigbee_topology={enabled:!0===t.enabled,z2m_base_topics:[...new Set(n)].slice(0,8)}:delete i.zigbee_topology,i}const Og={now:()=>performance.now(),requestFrame:e=>requestAnimationFrame(e),cancelFrame:e=>cancelAnimationFrame(e)},Eg=e=>Math.max(0,Math.min(1,e)),Ng=(e,t,i)=>e+(t-e)*i,Hg=(e,t,i)=>{const n=1-e;return 3*n*n*e*t+3*n*e*e*i+e*e*e},Lg=e=>{const t=Eg(e);if(0===t||1===t)return t;let i=0,n=1,r=t;for(let e=0;e<12;e++)r=(i+n)/2,Hg(r,.2,.2)0&&e.w>0?t/e.w:1,viewBox:{...e}}}function qg(e,t,i){const n=Math.max(1e-9,e.pixelsPerUnit),r=Math.max(1e-9,t/n),o=Math.max(1e-9,i/n);return{x:e.centerX-r/2,y:e.centerY-o/2,w:r,h:o}}function jg(e){const t=e.trim(),i=/^rgba?\(\s*([\d.]+)[, ]+([\d.]+)[, ]+([\d.]+)(?:\s*[,/]\s*([\d.]+))?\s*\)$/i.exec(t);if(i)return[Number(i[1]),Number(i[2]),Number(i[3]),null==i[4]?1:Number(i[4])];const n=/^#([0-9a-f]{6}|[0-9a-f]{8})$/i.exec(t)?.[1];return n?[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16),8===n.length?parseInt(n.slice(6,8),16)/255:1]:null}function Wg(e,t,i){const n=jg(e),r=jg(t);if(!n||!r)return i<.5?e:t;const o=Eg(i);return`rgba(${Math.round(Ng(n[0],r[0],o))}, ${Math.round(Ng(n[1],r[1],o))}, ${Math.round(Ng(n[2],r[2],o))}, ${Ng(n[3],r[3],o).toFixed(3)})`}class Ug{constructor(e,t=Og){this._hooks=e,this._clock=t,this._token=0,this._raf=0,this._state=null}get state(){return this._state}get active(){return"running"===this._state?.phase||"preparing"===this._state?.phase}get presented(){return this._state?.presented||null}start(e,t,i,n=220){this.cancel(!1);const r=++this._token,o=this._clock.now();if(this._state={token:r,phase:n<=0?"settling":"running",from:e,to:t,presented:n<=0?t:e,startedAt:o,duration:Math.max(0,n),targetMode:i},n<=0)return this._hooks.frame(this._state),this._hooks.settled(this._state),this._state=null,r;this._hooks.frame(this._state);const s=e=>{const t=this._state;if(!t||t.token!==r)return;const i=Eg((e-t.startedAt)/t.duration);t.presented=i>=1?t.to:function(e,t,i){const n=Lg(i),r=Ng(e.stageWidth,t.stageWidth,n),o=Ng(e.stageHeight,t.stageHeight,n),s=Math.max(1e-9,e.viewport.pixelsPerUnit),a=Math.max(1e-9,t.viewport.pixelsPerUnit),l={centerX:Ng(e.viewport.centerX,t.viewport.centerX,n),centerY:Ng(e.viewport.centerY,t.viewport.centerY,n),pixelsPerUnit:Math.exp(Ng(Math.log(s),Math.log(a),n))};return{presentedMode:n<.5?e.presentedMode:t.presentedMode,editorChromeHeight:Ng(e.editorChromeHeight,t.editorChromeHeight,n),stageWidth:r,stageHeight:o,viewport:{...l,viewBox:qg(l,r,o)},stageColor:Wg(e.stageColor,t.stageColor,n),paperColor:Wg(e.paperColor,t.paperColor,n),sceneBrightness:Ng(e.sceneBrightness,t.sceneBrightness,n),architectureOpacity:Ng(e.architectureOpacity,t.architectureOpacity,n),backdropOpacity:Ng(e.backdropOpacity,t.backdropOpacity,n),viewWeight:Ng(e.viewWeight,t.viewWeight,n),editorWeight:Ng(e.editorWeight,t.editorWeight,n),toolbarContentOpacity:Ng(e.toolbarContentOpacity,t.toolbarContentOpacity,n)}}(t.from,t.to,i),t.phase=i>=1?"settling":"running",this._hooks.frame(t),i<1?this._raf=this._clock.requestFrame(s):(this._raf=0,this._hooks.settled(t),this._state?.token===r&&(this._state=null))};return this._raf=this._clock.requestFrame(s),r}cancel(e=!0){this._raf&&this._clock.cancelFrame(this._raf),this._raf=0;const t=this._state;this._state=null,this._token++,t&&e&&(t.phase="settling",t.presented=t.to,this._hooks.frame(t),this._hooks.settled(t))}dispose(){this.cancel(!1)}}const Gg={now:()=>"undefined"!=typeof performance?performance.now():Date.now(),requestFrame:e=>"function"==typeof requestAnimationFrame?requestAnimationFrame(e):null,cancelFrame:e=>{"function"==typeof cancelAnimationFrame&&cancelAnimationFrame(e)}},Vg=e=>Number.isFinite(e);function Kg(e){return!!e&&Vg(e.zoom)&&e.zoom>0&&Vg(e.viewBox.x)&&Vg(e.viewBox.y)&&Vg(e.viewBox.w)&&e.viewBox.w>0&&Vg(e.viewBox.h)&&e.viewBox.h>0}function Yg(e){return{zoom:e.zoom,viewBox:{...e.viewBox}}}function Xg(e,t){return Math.abs(e.zoom-t.zoom)<1e-9&&Math.abs(e.viewBox.x-t.viewBox.x)<1e-6&&Math.abs(e.viewBox.y-t.viewBox.y)<1e-6&&Math.abs(e.viewBox.w-t.viewBox.w)<1e-6&&Math.abs(e.viewBox.h-t.viewBox.h)<1e-6}const Zg=(e,t,i)=>e+(t-e)*i,Jg=(e,t,i)=>Math.exp(Zg(Math.log(e),Math.log(t),i));class Qg{constructor(e,t=Gg){this._hooks=e,this._clock=t,this._token=0,this._raf=null,this._state=null}get state(){return this._state}get active(){return"running"===this._state?.phase}get presented(){return this._state?.presented||null}get target(){return this._state?.to||null}start(e,t,i,n){this.cancel(!1);const r=++this._token,o=Yg(e),s=Yg(t),a=n>0&&Kg(o)&&Kg(s),l=this._clock.now(),c={token:r,phase:a?"running":"settling",from:o,to:s,presented:Yg(a?o:s),startedAt:l,duration:a?n:0,reason:i};if(this._state=c,this._hooks.frame(c),!a)return this._settle(r),r;const h=e=>{const t=this._state;if(!t||t.token!==r)return;const i=Math.max(0,Math.min(1,(e-t.startedAt)/t.duration));if(t.presented=i>=1?Yg(t.to):function(e,t,i){if(!Kg(e))return Yg(t);if(!Kg(t))return Yg(e);const n=Lg(i);if(n<=0)return Yg(e);if(n>=1)return Yg(t);const r=e.viewBox.x+e.viewBox.w/2,o=e.viewBox.y+e.viewBox.h/2,s=t.viewBox.x+t.viewBox.w/2,a=t.viewBox.y+t.viewBox.h/2,l=Jg(e.viewBox.w,t.viewBox.w,n),c=Jg(e.viewBox.h,t.viewBox.h,n),h=Zg(r,s,n),d=Zg(o,a,n);return{zoom:Jg(e.zoom,t.zoom,n),viewBox:{x:h-l/2,y:d-c/2,w:l,h:c}}}(t.from,t.to,i),t.phase=i>=1?"settling":"running",this._hooks.frame(t),i>=1)return this._raf=null,void this._settle(r);this._raf=this._clock.requestFrame(h),null===this._raf&&this._settle(r)};return this._raf=this._clock.requestFrame(h),null===this._raf&&(c.phase="settling",c.presented=Yg(s),this._hooks.frame(c),this._settle(r)),r}cancel(e=!0){null!==this._raf&&this._clock.cancelFrame(this._raf),this._raf=null;const t=this._state;this._state=null,this._token++,t&&e&&(t.phase="settling",t.presented=Yg(t.to),this._hooks.frame(t),this._hooks.settled(t))}dispose(){this.cancel(!1)}_settle(e){const t=this._state;t&&t.token===e&&(t.phase="settling",t.presented=Yg(t.to),this._hooks.settled(t),this._state?.token===e&&(this._state=null))}}function ef(e,t,i){const n=e.querySelector("ha-card");if(!n)return null;const r=n.getBoundingClientRect(),o=t.getBoundingClientRect().top-r.top,s=i?0:Math.min(Math.max(r.top,0),120),a=Math.round(o+s);return a>=0?a:null}const tf=Object.freeze({rotDeg:0,tiltDeg:20,xyScale:1,zScale:1,origin:Object.freeze([500,500])}),nf=84,rf=10,of=4,sf=4;function af(e){return[e.rotDeg,e.tiltDeg,e.xyScale,e.zScale,e.origin[0],e.origin[1]].every(Number.isFinite)&&Math.abs(e.xyScale)>1e-12&&Math.abs(Math.cos(e.tiltDeg*Math.PI/180))>1e-12}function lf(e,t,i=tf){if(!Number.isFinite(e[0])||!Number.isFinite(e[1]))throw new Error("invalid isometric projection input");return function(e,t){if(!Number.isFinite(e[0])||!Number.isFinite(e[1])||!t.every(Number.isFinite))throw new Error("invalid isometric affine input");const[i,n,r,o,s,a]=t;return[i*e[0]+r*e[1]+s,n*e[0]+o*e[1]+a]}(e,hf(t,i))}function cf(e,t=tf){if(!af(t)||!Number.isFinite(e[0])||!Number.isFinite(e[1]))throw new Error("invalid isometric projection input");const i=t.rotDeg*Math.PI/180,n=t.tiltDeg*Math.PI/180,r=(e[0]-t.origin[0])/t.xyScale,o=(e[1]-t.origin[1])/(t.xyScale*Math.cos(n));return[t.origin[0]+r*Math.cos(i)+o*Math.sin(i),t.origin[1]-r*Math.sin(i)+o*Math.cos(i)]}function hf(e=0,t=tf){if(!af(t)||!Number.isFinite(e))throw new Error("invalid isometric camera");const i=t.rotDeg*Math.PI/180,n=t.tiltDeg*Math.PI/180,r=t.xyScale*Math.cos(i),o=-t.xyScale*Math.sin(i),s=t.xyScale*Math.sin(i)*Math.cos(n),a=t.xyScale*Math.cos(i)*Math.cos(n);return[r,s,o,a,t.origin[0]-r*t.origin[0]-o*t.origin[1],t.origin[1]-s*t.origin[0]-a*t.origin[1]-e*t.zScale*Math.sin(n)]}function df(e=tf){return function(e=0,t=tf){return`matrix(${hf(e,t).map(e=>Number(e.toFixed(12))).join(" ")})`}(0,e)}function uf(e,t=tf){const{rect:i,wallHeight:n}=e,r=e.openingHeight??n,o=e.floorDepth??0,s=e.raisedHeight??n;if(!(i.w>=0)||!(i.h>=0)||!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(o)||!Number.isFinite(s)||n<0||r<0||o<0||s<0)throw new Error("invalid isometric frame");const a=[[i.x,i.y],[i.x+i.w,i.y],[i.x+i.w,i.y+i.h],[i.x,i.y+i.h]],l=Math.max(n,r,s),c=a.flatMap(e=>[lf(e,-o,t),lf(e,l,t)]),h=c.map(e=>e[0]),d=c.map(e=>e[1]),u=Math.min(...h),p=Math.min(...d);return{x:u,y:p,w:Math.max(...h)-u,h:Math.max(...d)-p}}const pf=[".dev",".vacpuck",".oplock",".op-hit",".opening",".rlgo","a","button","input","select","textarea",'[contenteditable]:not([contenteditable="false"])',"[data-room-fit-block]",'[role="link"]','[role="button"]'].join(","),_f=(e,t)=>{try{return"function"==typeof e?.matches&&e.matches(t)}catch{return!1}};function mf(e){for(const t of e){const e=t;if(_f(e,".roomlabel[data-id]")){const t=e.getAttribute?.("data-id");return t?{kind:"room",roomId:t}:{kind:"interactive"}}if(_f(e,pf))return{kind:"interactive"};if(_f(e,'[data-hp="room"][data-id]')){const t=e.getAttribute?.("data-id");return t?{kind:"room",roomId:t}:{kind:"interactive"}}if(_f(e,".stage"))return{kind:"background"}}return{kind:"outside"}}function gf(e){const t=mf(e);return"room"===t.kind?t.roomId:null}class ff{constructor(){this.pointer=null,this.sequence=null}clear(){this.pointer=null,this.sequence=null}clearOutside(e){let t={kind:"outside"};try{t=mf(e.composedPath())}catch{}"outside"===t.kind&&this.clear()}pointerDown(e,t,i){let n={kind:"outside"};try{n=mf(e.composedPath())}catch{}this.pointer=function(e){const t="mouse"===(i=e.pointerType)||"touch"===i||"pen"===i?i:null;var i;return t&&"view"===e.mode&&"background"===e.owner.kind&&!e.blocked&&e.isPrimary&&0===e.button&&Number.isFinite(e.x)&&Number.isFinite(e.y)?{pointerId:e.pointerId,spaceId:e.spaceId,modality:t,x:e.x,y:e.y}:null}({pointerId:e.pointerId,pointerType:e.pointerType,isPrimary:e.isPrimary,button:e.button,spaceId:t,mode:i?"view":"blocked",owner:n,blocked:!i,x:e.clientX,y:e.clientY}),this.pointer||(this.sequence=null)}pointerUp(e,t,i,n,r=Date.now()){let o={kind:"outside"};try{o=mf(e.composedPath())}catch{}const s=function(e,t,i){if(!t||"view"!==i.mode||"background"!==i.owner.kind||i.blocked||t.pointerId!==i.pointerId||t.spaceId!==i.spaceId||!Number.isFinite(i.x)||!Number.isFinite(i.y)||!Number.isFinite(i.now)||Math.abs(i.x-t.x)+Math.abs(i.y-t.y)>=8)return{sequence:null,trigger:!1};const n=e?i.now-e.at:Number.POSITIVE_INFINITY;return e&&e.spaceId===i.spaceId&&e.modality===t.modality&&n>=0&&n<=350?{sequence:null,trigger:!0}:{sequence:{at:i.now,spaceId:i.spaceId,modality:t.modality},trigger:!1}}(this.sequence,this.pointer,{pointerId:e.pointerId,spaceId:t,mode:i?"view":"blocked",owner:o,blocked:n||!i,x:e.clientX,y:e.clientY,now:r});return this.pointer=null,this.sequence=s.sequence,s.trigger}}const vf=e=>e.length>=2&&Number.isFinite(e[0])&&Number.isFinite(e[1]);function yf(e){return!!e&&Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.w)&&e.w>0&&Number.isFinite(e.h)&&e.h>0}function bf(e,t=0){if(!e.length||!Number.isFinite(t)||t<0||!e.every(vf))return null;let i=1/0,n=1/0,r=-1/0,o=-1/0;for(const t of e)i=Math.min(i,t[0]),n=Math.min(n,t[1]),r=Math.max(r,t[0]),o=Math.max(o,t[1]);const s=r-i,a=o-n;return s>0&&a>0?{x:i-t,y:n-t,w:s+2*t,h:a+2*t}:null}function wf(e,t,i){const n="string"!=typeof t||"invalid"!==t&&"no-borders"!==t&&"unverified"!==t&&!/^[a-z0-9]{1,8}$/i.test(t)?"redacted":t;return Object.freeze({kind:e,fingerprint:n,terminal:!!i})}function kf(e,t){return`${e("editor.load_failed")} ${e(t.terminal?"editor.refresh_advice":"editor.retry_advice")}`}class xf extends Error{}class Sf{constructor(e){this.options=e,this._state="idle",this._inFlight=null}get state(){return this._state}ensure(){return"ready"===this._state?Promise.resolve(!0):"failed"===this._state?Promise.resolve(!1):(this._inFlight||(this._setState("loading"),this._inFlight=this._loadWithRetry().finally(()=>{this._inFlight=null})),this._inFlight)}async _loadWithRetry(){let e=new Error("Editor runtime did not load"),t=!1;for(const i of[0,1])try{const e=await this.options.load(i);if(e.fingerprint!==this.options.expectedFingerprint)throw new xf(`Editor runtime fingerprint mismatch: expected ${this.options.expectedFingerprint}, got ${e.fingerprint}`);const t=e.create();return this.options.install(t),this._setState("ready"),!0}catch(i){e=i,i instanceof xf&&(t=!0)}return this._setState(t?"failed":"idle"),this.options.failed?.(e,{terminal:t}),!1}_setState(e){e!==this._state&&(this._state=e,this.options.stateChanged?.(e))}}const $f=(e,t)=>{if(!e.has(t))return{hit:!1};const i=e.get(t);return e.delete(t),e.set(t,i),{hit:!0,value:i}},Mf=(e,t,i,n)=>{for(e.delete(t),e.set(t,i);e.size>n;){const t=e.keys().next().value;if(void 0===t)break;e.delete(t)}},Rf=new Set(["select","draw","column","merge","split","resize","opening","wallthick","delroom"]),Cf=e=>`${window.innerWidth}x${window.innerHeight}|${location.pathname}|${JSON.stringify(e??{})}`,Tf="houseplan_card_alpha_v1",Df=Object.freeze([Object.freeze({id:"iso",issue:89,summary:"Volumetric plan renderer"})]);function Af(e){return/^[a-z][a-z0-9-]*$/.test(e.id)&&Number.isInteger(e.issue)&&e.issue>0&&!!e.summary.trim()}function Pf(e){const t=String(e||"").replace(/^#/,"");return new URLSearchParams(t)}function Ff(e){return Pf(e).get("space")||""}function zf(e,t,i=Df){const n=function(e){const t=new Set;for(const i of e){if(!Af(i)||t.has(i.id))return!1;t.add(i.id)}return!0}(i),r=function(e){let t,i=!1;const n=e=>{for(const n of e.getAll("hp_alpha"))i=!0,"1"===n?t=!0:"0"===n&&(t=!1)};return n(new URLSearchParams(String(e.search||"").replace(/^\?/,""))),n(Pf(e.hash)),{present:i,value:t}}(e),o=void 0!==r.value,s="1"===t,a=o?!0===r.value:!r.present&&s,l=n&&a;return{alpha:l,active:Object.freeze(l?i.map(e=>e.id).sort():[]),space:Ff(e.hash),persist:n&&o?l?"1":"0":void 0,knownUrlOperation:o}}let If={alpha:!1,active:Object.freeze([]),space:""},Of=!1,Ef="";const Nf=new Set;function Hf(){if("undefined"==typeof window)return If;const e=zf(window.location,function(){try{return window.localStorage.getItem(Tf)}catch{return null}}());void 0!==e.persist&&function(e){try{window.localStorage.setItem(Tf,e)}catch{}}(e.persist),If={alpha:e.alpha,active:e.active,space:e.space},window.__hpAlpha=e.alpha,window.__hpLabs=e.active;for(const e of Nf)e(If);return If}function Lf(){Hf()}function Bf(){if("undefined"==typeof window)return If;if(!Of){Of=!0,window.__hpLabsListenerCleanup?.(),window.addEventListener("hashchange",Lf),window.addEventListener("popstate",Lf);const e=()=>{window.removeEventListener("hashchange",Lf),window.removeEventListener("popstate",Lf),window.__hpLabsListenerCleanup===e&&delete window.__hpLabsListenerCleanup};window.__hpLabsListenerCleanup=e}return Hf()}const qf={window:120,door:90,passage:90,gate:300};function jf(e){return qf[e]}function Wf(e,t){return{type:e,lengthCm:jf(e),flipH:!1,flipV:!1,revision:t}}function Uf(e,t){const i=Math.max(0,e.renderedLength)/2,n=Math.max(0,e.target.physicalHalfWidth),r=n+.18*Math.max(0,t),o=e=>({x1:e,y1:-r,x2:e,y2:r});return{rect:{x:-i,y:n?-n:0,width:2*i,height:2*n},boundaries:[o(-i),o(i)]}}function Gf(e,t){const i=[e[0],e[1]],n=[t[0],t[1]];return function(e,t){return e[0]-t[0]||e[1]-t[1]}(i,n)<=0?{a:i,b:n}:{a:n,b:i}}function Vf(e){const t=new Map;return e.forEach((e,i)=>{if(!e.kind||e.open)return;const n=Gf(e.a,e.b);if(Math.hypot(n.b[0]-n.a[0],n.b[1]-n.a[1])<=1e-9)return;const r=function(e,t){const i=e=>(Math.abs(e)<=5e-10?0:Math.round(1e6*e)/1e6).toFixed(6);return`${i(e[0])},${i(e[1])}>${i(t[0])},${i(t[1])}`}(n.a,n.b),o=t.get(r);if(o)return o.physicalHalfWidth=Math.max(o.physicalHalfWidth,e.half||0),o.sourceOrder=Math.min(o.sourceOrder,i),void(e.partitionHost&&(o.partitionHost&&o.partitionHost.id!==e.partitionHost.id?o.ambiguousPartitionHost=!0:o.partitionHost=e.partitionHost));t.set(r,{segmentKey:r,a:n.a,b:n.b,physicalHalfWidth:Math.max(0,e.half||0),sourceOrder:i,...e.partitionHost?{partitionHost:e.partitionHost}:{}})}),[...t.values()]}function Kf(e,t){if(Math.abs(e.distance-t.distance)>1e-9)return e.distance-t.distance;if(Math.abs(e.perpendicular-t.perpendicular)>1e-9)return e.perpendicular-t.perpendicular;return(e.target.segmentKeyt.target.segmentKey?1:0)||e.target.sourceOrder-t.target.sourceOrder}function Yf(e){const t=Vf(e.intervals).map(t=>{const i=function(e,t){const i=t.b[0]-t.a[0],n=t.b[1]-t.a[1],r=Math.hypot(i,n),o=i/r,s=n/r,a=(e[0]-t.a[0])*o+(e[1]-t.a[1])*s,l=Math.max(0,Math.min(r,a)),c=t.a[0]+l*o,h=t.a[1]+l*s;return{along:l,length:r,x:c,y:h,distance:Math.hypot(e[0]-c,e[1]-h),perpendicular:Math.abs((e[0]-t.a[0])*s-(e[1]-t.a[1])*o)}}(e.pointer,t);return{target:t,...i,envelope:Math.max(e.baseTolerance,t.physicalHalfWidth+e.bodyPointerPadding)}}).filter(e=>e.distance<=e.envelope+1e-9).filter(t=>!function(e,t,i,n,r){const o=t.b[0]-t.a[0],s=t.b[1]-t.a[1],a=Math.hypot(o,s);if(!(a>1e-9))return!1;const l=o/a,c=s/a;for(const o of i){if(!o.open&&o.kind)continue;const i=Gf(o.a,o.b),s=i.b[0]-i.a[0],a=i.b[1]-i.a[1],h=Math.hypot(s,a);if(!(h>1e-9))continue;const d=s/h,u=a/h;if(Math.abs(l*u-c*d)>1e-6)continue;if(Math.abs((i.a[0]-t.a[0])*c-(i.a[1]-t.a[1])*l)>r)continue;const p=(e[0]-i.a[0])*d+(e[1]-i.a[1])*u,_=1e-9;if(!(p<=_||p>=h-_)&&Math.abs((e[0]-i.a[0])*u-(e[1]-i.a[1])*d)<=n+1e-9)return!0}return!1}(e.pointer,t.target,e.intervals,t.envelope,Math.max(1e-9,Math.min(e.baseTolerance,.04*e.gridStep)))),i=t.filter(t=>!!t.target.partitionHost&&e.renderedLength+2*t.target.physicalHalfWidth>t.length+1e-9).sort(Kf),n=t.filter(t=>!t.target.partitionHost||e.renderedLength+2*t.target.physicalHalfWidth<=t.length+1e-9).sort(Kf);let r=n[0];if(!r)return{candidate:null,jambBlockedTarget:i[0]?.target||null};const o=n.filter(e=>Math.abs(e.distance-r.distance)<=1e-9&&Math.abs(e.perpendicular-r.perpendicular)<=1e-9),s=o.filter(e=>e.target.partitionHost);if(s.length){if(1!==new Set(s.map(e=>e.target.partitionHost.id)).size||s.some(e=>e.target.ambiguousPartitionHost))return{candidate:null,jambBlockedTarget:null};const e=s[0],t=e.target.b[0]-e.target.a[0],i=e.target.b[1]-e.target.a[1],n=Math.hypot(t,i),a=t/n,l=i/n;if(!o.every(t=>{const i=t.target.b[0]-t.target.a[0],n=t.target.b[1]-t.target.a[1],r=Math.hypot(i,n),o=i/r,s=n/r,c=Math.abs(a*s-l*o)<=1e-6,h=Math.abs((t.target.a[0]-e.target.a[0])*l-(t.target.a[1]-e.target.a[1])*a);return c&&h<=1e-9}))return{candidate:null,jambBlockedTarget:null};r=e}if(r.target.ambiguousPartitionHost)return{candidate:null,jambBlockedTarget:null};const{target:a,length:l}=r,c=a.b[0]-a.a[0],h=a.b[1]-a.a[1],d=c/l,u=h/l,p=a.partitionHost?a.physicalHalfWidth:0,_=Math.min(Math.max(0,e.renderedLength)/2+p,l/2);let m=r.along;const g=Math.max(e.gridStep,1e-9),f=l/2;m=Math.abs(m-f)<=g/2?f:Math.round(m/g)*g,m=Math.max(_,Math.min(l-_,m));const v=a.a[0]+d*m,y=a.a[1]+u*m,b=Math.max(0,e.renderedLength)/2,w=m-b,k=m+b,x=Math.max(0,w),S=Math.max(0,l-k),$=[a.a[0]+d*(w-x/2),a.a[1]+u*(w-x/2)],M=[a.a[0]+d*(k+S/2),a.a[1]+u*(k+S/2)];let R=180*Math.atan2(h,c)/Math.PI;R>=90?R-=180:R<-90&&(R+=180);const C=Math.abs(m-f)<=1e-9;return{candidate:{presetRevision:e.preset.revision,geometryRevision:e.geometryRevision,pointer:[e.pointer[0],e.pointer[1]],type:e.preset.type,lengthCm:e.preset.lengthCm,flipH:e.preset.flipH,flipV:e.preset.flipV,x:v,y:y,angle:R,renderedLength:e.renderedLength,target:a,...a.partitionHost?{host:{...a.partitionHost,t:l>0?m/l:0}}:{},measure:{labels:[{distance:x,midpoint:$},{distance:S,midpoint:M}],guide:C?{x:v,y:y,angle:R}:null}},jambBlockedTarget:null}}function Xf(e,t,i,n,r=1e-6){return e.presetRevision===i&&e.geometryRevision===n&&Math.hypot(e.pointer[0]-t[0],e.pointer[1]-t[1])<=r}function Zf(e){return!(!e.canEdit||e.kiosk||e.fixedFloor)&&("view"!==e.mode&&("mouse"===e.pointerType&&e.spaceCount>1))}class Jf{constructor(e,t,i){this.loader=e,this.host=t,this.adopted=i,this.attachment=null}connect(){if(this.runtime)return void this.runtime.connect();this.attachment?.cancel();const e=this.loader.attach(this.host,e=>this.adopt(e));this.runtime||(this.attachment=e)}disconnect(){this.attachment?.cancel(),this.attachment=null,this.runtime?.disconnect()}adopt(e){this.attachment=null,this.runtime||(this.runtime=e,this.adopted(e))}}const Qf=new class{constructor(e){this.load=e,this.factory=null,this.pending=null}get warm(){return null!==this.factory}create(e){return this.factory?this.factory(e):null}attach(e,t){let i=!0;const n={cancel:()=>{i=!1}},r=this.create(e);return r?(t(r),n):(this.ensure().then(n=>{i&&t(n(e))},()=>{}),n)}ensure(){return this.factory?Promise.resolve(this.factory):(this.pending||(this.pending=this.load().then(e=>(this.factory=e,this.pending=null,e),e=>{throw this.pending=null,e})),this.pending)}reset(){this.factory=null,this.pending=null}}(()=>import("./summary-panel-runtime-loaded-B9-PG-Gw.js").then(function(e){return e.e}).then(({LoadedSummaryPanelRuntime:e})=>t=>new e(t)));function ev(e){const t=globalThis.__HP_VERSION_OVERRIDE__;return"string"==typeof t&&t.length>0?t:e}let tv=0;const iv="1.77.0-beta.1",nv="ed91b3971428d2b8e7bfceb8025d2be4c0db7c58754eeb4ba03f835b8d7c84c6",rv=1500,ov=new Map;let sv=0,av=1e4;const lv="houseplan_card_layout_v1",cv="houseplan_card_cfg_v1",hv="houseplan_card_zoom_v1",dv="houseplan_card_nav_v1",uv="houseplan_card_view_v1",pv="hp-dialog, hp-help, hp-color-opacity, hp-device-preview",_v=1e3,mv=(e,t)=>{const i=Math.min(e.x,t.x),n=Math.min(e.y,t.y);return{x:i,y:n,w:Math.max(e.x+e.w,t.x+t.w)-i,h:Math.max(e.y+e.h,t.y+t.h)-n}},gv=(e,t,i)=>{const n=new Event(t,{bubbles:!0,composed:!0});n.detail=i??{},e.dispatchEvent(n)},fv=e=>{history.pushState(null,"",e),gv(window,"location-changed",{replace:!1})},vv=(e,t)=>{let i,n=null;const r=(...r)=>{clearTimeout(i),n=r,i=window.setTimeout(()=>{i=void 0;const t=n;n=null,t&&e(...t)},t)};return r.flush=()=>{if(void 0===i)return;clearTimeout(i),i=void 0;const t=n;n=null,t&&e(...t)},r.cancel=()=>{clearTimeout(i),i=void 0,n=null},r.pending=()=>void 0!==i,r},yv=e=>{try{e.target?.setPointerCapture?.(e.pointerId)}catch{}},bv=["edges","corners"];class wv extends he{constructor(){var e;super(...arguments),this._editorRuntime=null,this._liveRt=null,this._onboardingRuntime=null,this._editorRuntimeLoadingVisible=!1,this._backdropGuard=null,this._editorModeRequest=0,this._warmModeRequest=0,this._editorRuntimeLoader=new Sf({expectedFingerprint:nv,load:async e=>{const t=0===e?await import("./houseplan-editor-runtime-BG2wMJ7n.js"):await import((()=>{const e=new URL("./houseplan-editor-runtime-BG2wMJ7n.js",import.meta.url);return e.searchParams.set("hp_retry",`${iv}-${++tv}`),e.href})());return{fingerprint:t.EDITOR_RUNTIME_FINGERPRINT,create:()=>new t.HouseplanEditorRuntime(this)}},install:e=>{this._editorRuntime=e},stateChanged:e=>this._editorRuntimeStateChanged(e),failed:(e,t)=>{console.error("[houseplan] unable to load editor runtime",e),t.terminal&&this._versionRecovery.hasCurrentMismatchNotice||this._showToast(kf(e=>this._t(e),t))}}),this._onboardingRuntimeLoader=new Sf({expectedFingerprint:nv,load:async e=>{const t=0===e?await import("./houseplan-onboarding-runtime-BAx8bJB2.js"):await import((()=>{const e=new URL("./houseplan-onboarding-runtime-BAx8bJB2.js",import.meta.url);return e.searchParams.set("hp_retry",`${iv}-${++tv}`),e.href})());return{fingerprint:t.ONBOARDING_RUNTIME_FINGERPRINT,create:()=>new t.HouseplanOnboardingRuntime(this)}},install:e=>{this._onboardingRuntime=e},failed:(e,t)=>{console.error("[houseplan] unable to load onboarding runtime",e),t.terminal&&this._versionRecovery.hasCurrentMismatchNotice||this._showToast(kf(e=>this._t(e),t))}}),this._isoSceneRuntime=null,this._isoSceneRuntimeLoader=new Sf({expectedFingerprint:nv,load:async e=>{const t=0===e?await import("./iso-scene-render-CR59iy_N.js"):await import((()=>{const e=new URL("./iso-scene-render-CR59iy_N.js",import.meta.url);return e.searchParams.set("hp_retry",`${iv}-${++tv}`),e.href})());return{fingerprint:t.ISO_SCENE_RUNTIME_FINGERPRINT,create:()=>t}},install:e=>{const t=this._effectiveProjection();this._isoSceneRuntime=e,this._isoProjectionSnapshot=null;const i=this._effectiveProjection();this._convertProjectionView(t,i),this.isConnected&&this.requestUpdate()},failed:(e,t)=>{console.warn("[houseplan] hidden isometric runtime diagnostic",wf("runtime-load","unverified",t.terminal)),this.isConnected&&this.requestUpdate()}}),this._pdfRuntime=null,this._pdfRuntimeLoader=new Sf({expectedFingerprint:nv,load:async e=>{const t=0===e?await import("./pdf-export-FjKO_S28.js"):await import((()=>{const e=new URL("./pdf-export-FjKO_S28.js",import.meta.url);return e.searchParams.set("hp_retry",`${iv}-${++tv}`),e.href})());return{fingerprint:t.PDF_EXPORT_FINGERPRINT,create:()=>new t.PdfExportRuntime}},install:e=>{this._pdfRuntime=e,this.isConnected&&this.requestUpdate()},failed:(e,t)=>{if(console.error("[houseplan] unable to load PDF export runtime",e),!t.terminal||!this._versionRecovery.hasCurrentMismatchNotice){const e=kf(e=>this._t(e),t),i=this._t("editor.load_failed"),n=e.startsWith(i)?e.slice(i.length).trim():e;this._showToast(`${this._t("pdf.failed")} ${n}`.trim())}}}),this.panelHost=!1,this.narrow=null,this._space="f1",this._adoption=new qu((e,t)=>this.requestUpdate(e,t)),this._serverStorage=!1,this._loadOk=!1,this._serverCanWrite=null,this._loading=!1,this._loadTries=0,this._unsubCfg=null,this._unsubLayout=null,this._unsubVirtual=null,this._liveSyncAttempt=null,this._liveSyncGeneration=0,this._liveSyncConnection=null,this._configReloadAuthority=new Gu,this._virtualLights=Hh(null),this._canOptimizeUndo=!1,this._undoKind=null,this._devices=[],this._regSignature="",this._defPos={},this._newSyncKey="",this._areaRelocationIds=new Set,this._areaSnapshotCleanupCandidates=new Map,this._areaRelocationSyncKey="",this._areaRelocationWrite=Promise.resolve(),this._tip=null,this._hoverRoom=null,this._pointerModality=new sg(this,()=>this._syncPointerHoverTargets()),this._devicePressAnimations=new Map,this._selId=null,this._toast="",this._mode="view",this._pendingNavMode=null,this._decorTool="select",this._decorStyle={...Cr},this._decorStyleSeeded=!1,this._decorDraft=null,this._decorMove=null,this._decorSel=null,this._decorEraseConfirm=null,this._decorTextDialog=null,this._decorShapeDialog=null,this._backdropDialog=null,this._decorTextSelection={start:0,end:0},this._furnPalette=null,this._decorImagePalette=null,this._decorAssetCatalog=[],this._decorAssets=new Map,this._decorAssetBusy=!1,this._furnCategory=null,this._furnPreviewInput=null,this._furnTouchPending=null,this._dtBox=null,this._dtDrag=null,this._bdDrag=null,this._slide="",this._reducedMotion=!1,this._onMotionChange=e=>{this._reducedMotion=e.matches,this._cancelDevicePressFeedback(),e.matches&&this._cancelCameraTransition(!0),e.matches&&this._modeTransitionPreparing?this._modeTransitionForceAtomic=!0:e.matches&&this._modeTransition.active&&this._cancelModeTransition(!0),this._syncVersionRecovery(),this.requestUpdate()},this._editorChromeMode="plan",this._modeTransitionVisual=null,this._modeTransitionPreparing=!1,this._modeTransitionForceAtomic=!1,this._modeTransitionRequest=0,this._modeTransitionTargetZoom=1,this._modeTransitionEditorCamera=null,this._modeTransition=new Ug({frame:e=>this._applyModeTransitionFrame(e),settled:e=>this._settleModeTransition(e)}),this._cameraTransitionFit=null,this._cameraTransition=new Qg({frame:e=>this._applyCameraTransitionFrame(e),settled:e=>this._settleCameraTransition(e)}),this._editorSecondaryCopy={groupActive:(e,t)=>this._t("editor.group_active",{group:e,item:t}),openGroup:e=>this._t("editor.open_group",{group:e}),disabledAction:(e,t)=>this._t("editor.disabled_action",{action:e,reason:t})},this._tool="draw",this._geometryHistory=new gg(50),this._devicePositionHistory=new gg(50),this._devicePositionBusy=!1,this._wallDialog=null,this._drawWallField=null,this._activeWallChainId=null,this._activeWallChainPartitionIds=[],this._wallChainRedo=[],this._physicalSel=null,this._physicalDialog=null,this._partitionDeleteDialog=null,this._roomDeleteDialog=null,this._physicalDrag=null,this._physicalRotate=null,this._physicalLastTap=null,this._physicalPickCycle=null,this._wallUnionCacheValue=null,this._wallUnionPool=new Map,this._isoGeometryCache=new Map,this._renderIsoScene=null,this._isoProjectionSnapshot=null,this._isoStructuralBuildCount=0,this._isoFallback=new Set,this._openingTunnelCache=null,this._openingWallIndexCache=new Map,this._openingPlacementIntervalsCache=null,this._openingDimensionContextCache=null,this._planSnapGeometryCache=null,this._planStructuralGeometryCache=null,this._hiddenWallDiagnosticCache=null,this._physicalBodiesCache=null,this._lightPhysicalBodiesCache=null,this._cleanFloorCache=new Map,this._innerContourCache=new Map,this._glowRuntimeState=bm(),this._glowRuntimeHost={window:()=>this.ownerDocument.defaultView||window,isConnected:()=>this.isConnected,requestUpdate:()=>this.requestUpdate(),reducedMotion:()=>this._reducedMotion},this._lightBarrierCache=null,this._lightBarrierPool=new Map,this._glowScreenBlend=!1,this._duplicateColumnId=null,this._duplicateColumnTimer=0,this._rszLimitViolation=null,this._path=[],this._cursorPt=null,this._planSnapHover=null,this._mergeSel=null,this._openingPreset=null,this._openingRebindId=null,this._openingPresetRevision=0,this._openingHoverCandidate=null,this._openingJambBlockCm=null,this._openingDialog=null,this._openingInfo=null,this._opDrag=null,this._opMeasure=null,this._mergeDialog=null,this._splitSel=null,this._pendingSplit=null,this._wallFaceBatch=null,this._wallRepairDiagnostic=null,this._wallFaceGraphCache=[],this._areaSel="",this._nameSel="",this._roomDialog=!1,this._roomEditId=null,this._roomFill="",this._roomCustomFill=null,this._roomTempMin="",this._roomTempMax="",this._roomTempSrc="",this._roomHumSrc="",this._roomSrcOpen=null,this._roomSrcFilter="",this._roomNameScale=1,this._roomLabelScale=1,this._zoom=1,this._view=null,this._zoomBySpace={},this._viewModeSnap=null,this._roomFocus=null,this._roomPointer=null,this._doubleFit=new ff,this._deviceHits=new wc,this._pointers=new Map,this._panStart=null,this._panLock=null,this._pinchStart=null,this._safeDayCycleOutline=!1,this._suppressClick=!1,this._viewportGestureDirty=!1,this._touchContacts=new Map,this._touchClickGuard=new pc,this._connectedPath="",this._routeDepartureHandled=!1,this._onLocationChanged=()=>{this._connectedPath&&location.pathname!==this._connectedPath?this._leaveCardRoute():location.pathname===this._connectedPath&&(this._routeDepartureHandled=!1)},this._touchGestureGuard={capture:!0,handleEvent:e=>this._guardTouchGesture(e)},this._hdrH=118,this._booting=!0,this._bootFading=!1,this._bootSettling=!1,this._bootSettleRaf=0,this._bootLastH=-1,this._bootStart=0,this._bootLastChange=0,this._bootSoft=!1,this._tapConfirm=null,this._dangerConfirm=null,this._dangerConfirmController=new ze(e=>{this._dangerConfirm=e}),this._confirmDanger=e=>this._config&&this.hass?"warm"===this._syncDangerConfirmLocaleGate()||this._dangerConfirmMissingSpace()?Promise.resolve(!1):this._dangerConfirmController.confirm(e):Promise.resolve(!1),this._cancelDangerConfirm=()=>{this._dangerConfirmController.cancel()},this._onDangerConfirmDecision=e=>{this._dangerConfirmController.resolve(e.detail.token,e.detail.accepted)},this._onboardingShown=!1,this._rulesDialog=null,this._preflightClipboardFallback=null,this._haIntegrationVersion=null,this._versionRecovery=(e=this,new wg({clock:{setTimeout:(e,t)=>window.setTimeout(e,t),clearTimeout:e=>window.clearTimeout(e)},storage:()=>e.ownerDocument.defaultView?.sessionStorage??null,safety:()=>Sg(e),reload:()=>e._reloadDocument(),changed:()=>{e.requestUpdate()}})),this._haSupportApi=null,this._haDecorAssetsApi=null,this._haSummaryPanelApi=null,this._haRadarStage1Api=null,this._radarLive=new Ag(this),this._decorAssetSyncToken=0,this._alignDialog=null,this._settingsDialog=null,this._pdfDialog=!1,this._supportDialog=null,this._backupExportDialog=null,this._backupImportDialog=null,this._sunRaysCache=null,this._dayCycleTimer=0,this._dayCycleClockKey="",this._compassDrag=!1,this._importDialog=null,this._importQueue=[],this._importTotal=0,this._rulesCompiledSrc="",this._infoCard=null,this._nativeMoreInfoEntity=null,this._deviceInbox=null,this._deviceInboxReturn=null,this._deviceInboxMemo=null,this._markerDialog=null,this._spaceDialog=null,this._keyHandler=e=>this._onKey(e),this._warmVp=null,this._warmVpArmed=!1,this._warmLongReturn=!1,this._warmRevivePending=!1,this._warmGen=++sv,this._warmKey=null,this._warmSlot=null,this._hashApplied=!1,this._navApplied=!1,this._labs={alpha:!1,active:Object.freeze([]),space:""},this._viewPreference={},this._renderProjection="flat",this._kioskScale={icon:1,font:1},this._kioskDialog=!1,this._summarySlot=new Jf(Qf,this,e=>{this._summary=e,this._capturedSnapshotSequence=-1,this.isConnected&&(e.connect(),this.hasUpdated&&this.requestUpdate())}),this._activityRt=new Map,this._vacRt=new Map,this._vacViewKey="",this._vacLastView=null,this._vacRaf=0,this._vacSrvTrails={},this._vacJumpOnce=!1,this._continuity=this._newContinuityController(),this._continuityHistory=[],this._continuityEpoch=0,this._continuityDataReady=!0,this._continuityPaintToken=-1,this._continuityDisposed=!1,this._renderSnapshotAt=Date.now(),this._hassSequence=0,this._visibleDeviceSnapshot=null,this._candidateDeviceSnapshot=null,this._stagedDeviceSnapshotToken=-1,this._capturedSnapshotSequence=-1,this._capturedSnapshotDevices=null,this._capturedSnapshotLayout=null,this._capturedSnapshotActivity="",this._capturedSnapshotConfigEpoch=-1,this._capturedSnapshotVirtual="",this._lastValidStageSize=null,this._pendingRefitSize=null,this._refitRaf=0,this._pageVisibility=e=>{if(this._continuity.visibility(e),this._dayCycleVisibility(e),this._summary?.visibility(e.kind),"hidden"===e.kind)return this._radarLive.stop(),this._editorRuntime?._cancelRadarSetup(),this._clearRoomFocus(!0),this._clearTransientHover(!0),this._cancelDevicePressFeedback(),this._cancelCameraTransition(!0),void(this._modeTransitionPreparing?this._modeTransitionForceAtomic=!0:this._cancelModeTransition(!0));if(this._vacJumpOnce=!0,this._syncRadarLive(),!e.long){const e=Date.now();let t=!1;for(const i of this._activityRt.values())!i.flashKind||(i.expiresAt||i.flashTs+tg)>e||(i.flashTs=0,i.flashKind=null,i.expiresAt=0,t=!0);return void(t&&this.requestUpdate())}Date.now()-this._renderSnapshotAt>1e3&&this._continuity.note("device-snapshot-stale"),this._continuityDataReady=!1,this._continuityPaintToken=-1,this._resumeSettling=!0,this._loading?this.requestUpdate():this._loadFromServer()},this._resumeSettling=!1,this._viewportInvalidAt=0,this._vacFit=null,this._vacAllCamerasFor=null,this._vacAllCameraCache=null,this._vacCalConfirm=null,this._kioskDots=!1,this._cyclePausedUntil=0,this._swipeStart=null,this._tabDrag=null,this._tabDragRelease=null,this._tabSuppressClick=!1,this._tabOrderWarned=!1,this._onLabsSnapshot=e=>{const t=this._effectiveProjection();this._labs=e,this._isoProjectionSnapshot=null,this._labsIso&&this._ensureIsoSceneRuntime();const i=this._effectiveProjection();this._convertProjectionView(t,i),this.requestUpdate()},this._onHashChange=()=>{if(this._hasFixedFloor)return;const e=this._hashSpace();if(e&&this._model.find(t=>t.id===e)&&e!==this._space){if(this._wallFaceBatch&&this._roomDialogCancel(),"plan"===this._mode&&"draw"===this._tool&&!this._finishWallChain())return;this._commitSpace(e),this._selId=null,this._path=[],this._clearPlanSnapHover(),this._clearOpeningPlacement(!0),this._tool="draw",this._activeWallChainId=null,this._activeWallChainPartitionIds=[],this._wallChainSegmentCms=[],this._closingWallCm=null,this._restoreZoom(),this.requestUpdate()}},this._drag=null,this._deviceDrag=null,this._rlResize=null,this._holdFired=!1,this._retryContinuity=()=>{this._continuityDataReady=!1,this._continuityPaintToken=-1,this._continuity.retry(this._continuity.recoveryReason||"plan"),this._loading||this._loadFromServer()},this._cfgEpoch=0,this._cfgEpochPreservedConfig=null,this._terminalFrame=0,this._modelCache=null,this._emptySpaceStateActive=!1,this._decorSnapCache=null,this._markerPreviewMemo=null,this._markerPreviewDevicesMemo=null,this._showHidden=!1,this._connHooked=null,this._connectionWasLost=!1,this._haRegistryConnection=null,this._haRegistryRev=-1,this._haBindingCacheKey="",this._planHassMemo=null,this._renderLife=new $g,this._liveEditorPaintCount=0,this._onHaRegistryUpdate=()=>{const e=nd(this.hass);e.revision===this._haRegistryRev&&this._devices.length||(this._haRegistryRev=e.revision,this._renderLife.invalidate(),this._planHassMemo=null,this._regSignature="",this._maybeRebuildDevices(),this.requestUpdate())},this._onConnReady=()=>{if(this._loadTries=0,clearTimeout(this._loadRetryTimer),this._loadRetryTimer=void 0,id(this.hass),this._saveConfigDebounced.pending()&&this._saveConfigDebounced.flush(),this._cfgWriting)return clearTimeout(this._reloadRetry),void(this._reloadRetry=window.setTimeout(this._onConnReady,400));!this._connectionWasLost&&this._continuity.hasCompleteFrame?this._beginContinuityCandidate("connection-ready",!1,"plan"):(this._continuityDataReady=!1,this._continuityPaintToken=-1),this._loading||this._loadFromServer()},this._onConnLost=()=>{this._booting&&!this._continuity.hasCompleteFrame||(this._connectionWasLost=!0,this._continuityDataReady=!1,this._continuityPaintToken=-1,this._continuity.connectionLost())},this._signer=new uc(()=>this.requestUpdate()),this._dirtyPos=new Set,this._sentPos=new Map,this._persistLayout=vv(()=>{if(this._serverStorage){const e=[...this._dirtyPos];this._dirtyPos.clear();for(const t of e){const e=xo(this._layout[t]);e&&(this._layout={...this._layout,[t]:e},this._sentPos.set(t,e),this.hass.callWS({type:"houseplan/layout/update",device_id:t,pos:e}).then(e=>this._noteLayoutRev(e)).catch(e=>this._showToast(this._t("toast.pos_save_failed",{err:this._errText(e)}))).finally(()=>{this._sentPos.get(t)===e&&this._sentPos.delete(t)}))}this._cacheSnapshot()}else this._persistLocalLayout()},600),this._frame=null,this._showFar=!1,this._writesPending=0,this._writeChain=Promise.resolve(),this._pendingPhysicalWrites=new Map,this._undoGeometry=()=>this._editorRuntimeOrThrow()._undoGeometry(),this._redoGeometry=()=>this._editorRuntimeOrThrow()._redoGeometry(),this._saveConfigDebounced=vv(()=>{this._serverCfg&&this._writeConfig().catch(e=>{const t=!0===e?.physicalGeometryRolledBack;"geometry-unsafe"!==e?.code&&("wall_model_client_outdated"===e?.code?this._showToast(this._t("toast.wall_model_client_outdated")):"conflict"===e?.code?(this._showToast(this._t("toast.conflict")),t||(this._cancelPath(),this._reloadConfigOnly(!0))):this._showToast(this._t("toast.cfg_save_failed",{err:this._errText(e)})),t&&this._reloadRejectedPhysicalWrite())})},500),this._wallChainSegmentCms=[],this._closingWallCm=null,this._savePhysicalDialog=()=>this._editorRuntimeOrThrow()._savePhysicalDialog(),this._deletePhysicalSelection=()=>this._editorRuntimeOrThrow()._deletePhysicalSelection(),this._confirmPartitionDelete=()=>this._editorRuntimeOrThrow()._confirmPartitionDelete(),this._confirmRoomDelete=e=>this._editorRuntimeOrThrow()._confirmRoomDelete(e),this._rebindPartitionOpening=()=>this._editorRuntimeOrThrow()._rebindPartitionOpening(),this._keepClosedAsPartitions=()=>this._editorRuntimeOrThrow()._keepClosedAsPartitions(),this._toggleServerPlans=async()=>this._onboardingRuntime&&this._spaceDialogUsesOnboardingRuntime("create")?this._onboardingRuntime._toggleServerPlans():this._editorRuntimeOrThrow()._toggleServerPlans(),this._aspectJob=null,this._dayCycleTick=()=>{if(!this.isConnected||"hidden"===this.ownerDocument.visibilityState)return;const e=this._dayCycleState();if(!e)return this._dayCycleTimer&&(clearInterval(this._dayCycleTimer),this._dayCycleTimer=0),void(this._dayCycleClockKey="");const t=cr(e);t!==this._dayCycleClockKey&&(this._dayCycleClockKey=t,this.requestUpdate())},this._sunShown=!1,this._sunOut=!1,this._sunOutTimer=0,this._openSettingsDialog=()=>{if(this._editorRuntime)return this._editorRuntime._openSettingsDialog();this._ensureEditorRuntime().then(e=>{e&&this._openSettingsDialog()})},this._openSupportDialog=()=>{this._editorRuntime?this._editorRuntime._openSupportDialog():this._ensureEditorRuntime().then(e=>{e&&this._openSupportDialog()})},this._openPdfDialog=()=>{this._pdfRuntimeLoader.ensure().then(e=>{e&&(this._pdfDialog=!0,this.requestUpdate())})},this._reportedPreflightFingerprint=null,this._openAlignDialog=()=>this._editorRuntimeOrThrow()._openAlignDialog(),this._toggleOptimizeLivePositions=()=>this._editorRuntimeOrThrow()._toggleOptimizeLivePositions(),this._optimizeUndoBusy=!1,this._openBackupExport=()=>this._editorRuntimeOrThrow()._openBackupExport(),this._openRulesDialog=()=>this._editorRuntimeOrThrow()._openRulesDialog(),this._climateCache=null,this._gearPtCache=new WeakMap}requestUpdate(e,t,i){if("hass"===e&&this.hass&&this._liveRt){const e=this._visibleDeviceSnapshot||this._candidateDeviceSnapshot;if(!this._liveRt.hass(t,this.hass,e?{entityIds:e.entityIds}:null,()=>Mg(this))&&!this._summary?.observeHassComposition())return}void 0!==e&&(this._terminalFrame=0),this._editorRuntime?._routeLiveEditorUpdate(e,t)||(this._liveRt?.clear(),super.requestUpdate(e,t,i))}_editorRuntimeOrThrow(){if(!this._editorRuntime)throw new Error("Houseplan editor runtime is not loaded");return this._editorRuntime}async _ensureEditorRuntime(){return this._editorRuntimeLoader.ensure()}async _ensureOnboardingRuntime(){return this._onboardingRuntimeLoader.ensure()}async _ensureIsoSceneRuntime(){return this._isoSceneRuntimeLoader.ensure()}_editorRuntimeStateChanged(e){clearTimeout(this._editorRuntimeLoadingTimer),this._editorRuntimeLoadingTimer=void 0,"loading"!==e?(this._editorRuntimeLoadingVisible=!1,this.requestUpdate()):this._editorRuntimeLoadingTimer=window.setTimeout(()=>{this._editorRuntimeLoadingVisible=!0,this.requestUpdate()},150)}async _requestMode(e,t=!0,i=!1){const n=++this._editorModeRequest;if(i&&(this._warmModeRequest=n,this._refitRaf&&(cancelAnimationFrame(this._refitRaf),this._refitRaf=0),this._pendingRefitSize=null),"view"===e||await this._ensureEditorRuntime()){if(n===this._editorModeRequest&&this.isConnected)return i?(this._adoptMode(e),this._warmRevivePending&&(clearTimeout(this._warmReviveTimer),this._warmReviveTimer=void 0,this._warmReviveDialog()),this.requestUpdate(),void this.updateComplete.then(()=>requestAnimationFrame(()=>requestAnimationFrame(()=>{if(this._warmModeRequest!==n||n!==this._editorModeRequest)return;const e=this._stageEl;this._lastValidStageSize=e&&e.clientWidth>0&&e.clientHeight>0?[e.clientWidth,e.clientHeight]:null,this._pendingRefitSize=null,this._warmModeRequest=0})))):void this._setMode(e,t);this._warmModeRequest===n&&(this._warmModeRequest=0)}else this._warmModeRequest===n&&(this._warmModeRequest=0)}get _layout(){return this._adoption.layout}set _layout(e){this._adoption.stageLocalLayout(e)}get _layoutRev(){return this._adoption.layoutRev}set _layoutRev(e){this._adoption.seedIdentity({layoutRev:e})}get _layoutContentFingerprint(){return this._adoption.layoutFingerprint}set _layoutContentFingerprint(e){this._adoption.seedIdentity({layoutFingerprint:e})}get _serverCfg(){return this._adoption.config}set _serverCfg(e){this._adoption.stageLocalConfig(e)}get _cfgRev(){return this._adoption.configRev}set _cfgRev(e){this._adoption.seedIdentity({configRev:e})}get _cfgContentFingerprint(){return this._adoption.configFingerprint}set _cfgContentFingerprint(e){this._adoption.seedIdentity({configFingerprint:e})}_seedDecorStyle(e){var t,i;if(t=Ol,i=this,Fl(e,Bl)&&"pending"===t.state()&&(t.art("",i),t.ensure()),this._decorStyleSeeded||!e)return;this._decorStyleSeeded=!0;const n=e.settings?.decor_default_style;n&&(this._decorStyle=function(e,t){if(!e||"object"!=typeof e)return{...t};const i=e,n="string"==typeof i.color&&i.color?i.color:t.color,r="string"==typeof i.fill_color&&i.fill_color?i.fill_color:t.fillColor,o=Number(i.width_cm);return{color:n,opacity:Tr(i.opacity,t.opacity),widthCm:Number.isFinite(o)&&o>0?Math.max(.1,Math.min(100,o)):t.widthCm,fill:"boolean"==typeof i.fill?i.fill:t.fill,fillColor:r,fillOpacity:Tr(i.fill_opacity,t.fillOpacity)}}(n,Cr))}get _canManageConfiguration(){return null!==this._serverCanWrite?this._serverCanWrite:!0===this.hass?.user?.is_admin}get _canEdit(){return this._norm&&this._canManageConfiguration}get _kiosk(){return!!this._config?.kiosk}_showKioskDots(){this._kioskDots=!0,clearTimeout(this._kioskDotsTimer),this._kioskDotsTimer=window.setTimeout(()=>this._kioskDots=!1,2500)}get _modeTransitionBusy(){return this._modeTransitionPreparing||this._modeTransition.active}get _doubleFitEnabled(){return!("view"!==this._mode||this._vacFit||this._modeTransitionBusy||this._touchSequenceMultitouch||"steady"!==this._continuity.state||this._continuity.overlayBlocksInteraction)}_cameraState(){const e=this._viewOr(this._baseVb());return{zoom:this._zoom,viewBox:{...e}}}_normalizeCameraState(e){const t=this._cameraTransitionFit||Oi(this._baseVb(),this._stageAspect());return{zoom:Math.min(wv.ZOOM_MAX,Math.max(wv.ZOOM_MIN,e.zoom)),viewBox:this._clampView({...e.viewBox},t)}}_applyCameraTransitionFrame(e){const t=this._normalizeCameraState(e.presented);e.presented=t,this._zoom=t.zoom,this._view={...t.viewBox},this._liveVp(!0)}_settleCameraTransition(e){const t=this._normalizeCameraState(e.to);this._zoom=t.zoom,this._view={...t.viewBox},this._cameraTransitionFit=null,"room"!==e.reason&&this._saveZoom(),this.requestUpdate()}_cancelCameraTransition(e=!1,t=!1){const i=this._cameraTransition.state?.reason,n=t&&this._cameraTransition.active?this._cameraTransition.presented?.zoom:void 0;this._cameraTransition.cancel(e),this._cameraTransitionFit=null,void 0!==n&&"room"!==i&&this._saveZoom()}_prepareCameraCommand(){this._bootSoftCancel(),this._modeTransitionBusy&&this._cancelModeTransition(!0),"opening"===this._tool&&(this._cursorPt=null,this._clearOpeningPlacement(!1))}_startCameraTransition(e,t,i,n){const r=this._cameraState(),o=this._cameraTransition.target;return(!o||!Xg(o,e))&&(Xg(r,e)?(this._cancelCameraTransition(!1),!1):(this._activateSafeDayCycleOutline(),this._cameraTransitionFit={...t},this._cameraTransition.start(r,e,i,this._reducedMotion?0:n),!0))}_cssColor(e,t){const i=String(e||"").trim();if(!i)return t;const n=document.createElement("span");n.style.cssText=`position:absolute;visibility:hidden;color:${i}`,this.renderRoot.append(n);const r=getComputedStyle(n).color||t;return n.remove(),r}_currentModeVisual(e=this._mode){const t=this._modeTransition.presented||this._modeTransitionVisual;if(t)return{...t,viewport:{...t.viewport,viewBox:{...t.viewport.viewBox}}};const i=this._stageEl;if(!i||i.clientWidth<=0||i.clientHeight<=0)return null;const n=this.renderRoot.querySelector(".editorchrome"),r=this._viewOr(this._baseVb()),o=this.renderRoot.querySelector(".hp-paper"),s=this.renderRoot.querySelector(".hp-backdrop"),a=this.renderRoot.querySelector(".zoomwrap"),l=a?getComputedStyle(a).filter:"",c=Number(/brightness\(([^)]+)\)/.exec(l)?.[1]);return{presentedMode:e,editorChromeHeight:"view"===e?0:n?.getBoundingClientRect().height||0,stageWidth:i.clientWidth,stageHeight:i.clientHeight,viewport:Bg(r,i.clientWidth),stageColor:getComputedStyle(i).backgroundColor||"rgb(255, 255, 255)",paperColor:o?getComputedStyle(o).fill:"rgb(255, 255, 255)",sceneBrightness:Number.isFinite(c)?c:1,architectureOpacity:"decor"===e?.35:1,backdropOpacity:s&&Number(getComputedStyle(s).opacity)||1,viewWeight:"view"===e?1:0,editorWeight:"view"===e?0:1,toolbarContentOpacity:"view"===e?0:1}}_viewForModeTarget(e,t,i,n,r){const o=Oi(this._baseVb(),n/r),s=Math.min(wv.ZOOM_MAX,Math.max(wv.ZOOM_MIN,e)),a=o.w/s,l=o.h/s,c=t??o.x+o.w/2,h=i??o.y+o.h/2;return this._clampView({x:c-a/2,y:h-l/2,w:a,h:l},o)}_targetStageColor(e){return"view"!==e?"rgb(255, 255, 255)":this._cssColor(this._stageBg(this._spaceDisplayForRender()),this._cssColor("var(--ha-card-background, var(--card-background-color, #111))","rgb(17, 17, 17)"))}_targetPaperColor(e){return"view"===e&&this._spaceModel()?.bg?this._cssColor("var(--ha-card-background, var(--card-background-color, #111))","rgb(17, 17, 17)"):"rgb(255, 255, 255)"}_targetBrightness(e){return 1}_applyModeTransitionFrame(e){e.targetMode===this._mode&&(this._modeTransitionVisual=e.presented,this._view={...e.presented.viewport.viewBox},this.requestUpdate())}_settleModeTransition(e){if(e.targetMode!==this._mode)return;const t=this._modeTransitionRequest;this._view={...e.to.viewport.viewBox},this._zoom=this._modeTransitionTargetZoom,this._modeTransitionVisual=null,this._modeTransitionPreparing=!1,this._lastValidStageSize=[e.to.stageWidth,e.to.stageHeight],"view"===this._mode&&(this._saveZoom(),this._viewModeSnap=null,this._modeTransitionEditorCamera=null),this.requestUpdate(),this.updateComplete.then(()=>{if(!this.isConnected||t!==this._modeTransitionRequest||this._modeTransitionBusy||e.targetMode!==this._mode)return;const i=this._stageEl;if(i&&i.clientWidth>0&&i.clientHeight>0&&(Math.abs(i.clientWidth-e.to.stageWidth)>.5||Math.abs(i.clientHeight-e.to.stageHeight)>.5)){const e=this._view;this._lastValidStageSize=[i.clientWidth,i.clientHeight],this._applyView(this._zoom,e?e.x+e.w/2:void 0,e?e.y+e.h/2:void 0),this.requestUpdate()}const n=this.renderRoot.activeElement;(!n||!n.isConnected||!!n.closest?.(".editorchrome, .stage"))&&this.renderRoot.querySelector(".modetab.active")?.focus?.({preventScroll:!0})})}_cancelModeTransition(e=!0){this._cancelCameraTransition(!1);const t=!!this._modeTransition.state;this._modeTransitionRequest++,this._modeTransitionPreparing=!1,this._modeTransitionForceAtomic=!1,this._modeTransition.cancel(e),e&&t||(this._modeTransitionVisual=null)}_adoptMode(e){e!==this._mode&&(this._clearRoomFocus(!0),this._resetDeviceHitState()),this._cancelModeTransition(!1),this._mode=e,this._isoProjectionSnapshot=null,"view"!==e&&(this._editorChromeMode=e)}_commitViewModeAtomic(e,t,i,n){if(this._modeTransitionPreparing=!1,this._modeTransitionVisual=null,this._modeTransitionForceAtomic=!1,this._zoom=t,e){const r=this._stageEl?.clientWidth||e.stageWidth,o=Math.max(1,e.stageHeight+e.editorChromeHeight);this._view=this._viewForModeTarget(t,i,n,r,o),this._lastValidStageSize=[r,o]}else this._view=null;this._viewModeSnap=null,this._modeTransitionEditorCamera=null,this._saveZoom(),this.requestUpdate()}_prepareModeTransition(e,t,i,n,r,o){this.updateComplete.then(()=>{if(!this.isConnected||e!==this._modeTransitionRequest||this._mode!==i)return void(e===this._modeTransitionRequest&&(this._modeTransitionPreparing=!1,this._modeTransitionVisual=null,this._modeTransitionForceAtomic=!1,this.requestUpdate()));const s=this.renderRoot.querySelector(".editorchrome-inner"),a="view"===i?0:s?.scrollHeight||0,l=Math.max(1,(this.panelHost?this.clientHeight:innerHeight)-ef(this.renderRoot,this._stageEl,this.panelHost)),c=this._stageEl?.clientWidth||t.stageWidth,h=this._viewForModeTarget(n,r,o,c,l),d={presentedMode:i,editorChromeHeight:a,stageWidth:c,stageHeight:l,viewport:Bg(h,c),stageColor:this._targetStageColor(i),paperColor:this._targetPaperColor(i),sceneBrightness:this._targetBrightness(i),architectureOpacity:"decor"===i?.35:1,backdropOpacity:"decor"===i&&"backdrop"!==this._decorTool?.5:1,viewWeight:"view"===i?1:0,editorWeight:"view"===i?0:1,toolbarContentOpacity:"view"===i?0:1};this._modeTransitionPreparing=!1;const u=this._modeTransitionForceAtomic;this._modeTransitionForceAtomic=!1,this._modeTransition.start(t,d,i,this._reducedMotion||u?0:220)})}get _hasFixedFloor(){return!!this._config&&Object.prototype.hasOwnProperty.call(this._config,"floor")}_fixedFloorState(e=this._model,t=this._loadOk){const i=this._config?.floor,n=function(e){if(!e.hasFloor)return{kind:"absent"};const t=e.floor;if("string"==typeof t)return t.length?e.spaceIds.includes(t)?{kind:"valid",id:t,source:"id"}:{kind:"invalid",reason:"unknown-id",value:t}:{kind:"invalid",reason:"empty-id",value:t};if("number"==typeof t){if(!Number.isFinite(t))return{kind:"invalid",reason:"non-finite-index",value:t};if(!Number.isInteger(t))return{kind:"invalid",reason:"fractional-index",value:t};if(t<0)return{kind:"invalid",reason:"negative-index",value:t};const i=e.spaceIds[t];return void 0===i?{kind:"invalid",reason:"out-of-range-index",value:t}:{kind:"valid",id:i,source:"index"}}return{kind:"invalid",reason:"invalid-type",value:t}}({spaceIds:e.map(e=>e.id),hasFloor:this._hasFixedFloor,floor:i});return!this._hasFixedFloor||t?n:"number"==typeof i?"valid"===n.kind||"invalid"===n.kind&&"out-of-range-index"===n.reason?{kind:"pending",value:i}:n:"valid"===n.kind||"invalid"===n.kind&&"unknown-id"!==n.reason?n:{kind:"pending",value:i}}_canCommitSpace(e,t=!1){if(t||!this._hasFixedFloor)return!0;const i=this._fixedFloorState();return"valid"===i.kind&&i.id===e}_commitSpace(e,t=!1){return!!this._canCommitSpace(e,t)&&(e!==this._space&&(this._clearRoomFocus(!0),this._resetDeviceHitState(),this._cancelDangerConfirm(),this._cancelCameraTransition(!1),this._clearTransientHover(!0),this._cancelDevicePressFeedback(),this._editorRuntime?._clearFurniturePreview()),this._space=e,this._isoProjectionSnapshot=null,!0)}_slideTo(e,t){if(e===this._space)return!0;if(!this._canCommitSpace(e))return!1;if(this._wallFaceBatch&&this._roomDialogCancel(),"plan"===this._mode&&"draw"===this._tool&&!this._finishWallChain())return!1;this._cancelModeTransition(!0);const i=window.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches;return this._commitSpace(e),this._path=[],this._clearPlanSnapHover(),this._clearOpeningPlacement(!0),this._tool="draw",this._activeWallChainId=null,this._activeWallChainPartitionIds=[],this._wallChainSegmentCms=[],this._closingWallCm=null,this._selId=null,this._physicalSel=null,this._editorSecondary?.closeForNavigation(),this._physicalDialog=null,this._physicalDrag=null,this._restoreZoom(),i||(this._slide=t,clearTimeout(this._slideTimer),this._slideTimer=window.setTimeout(()=>{this._slideTimer=void 0,this._slide="",this.requestUpdate()},190),this.requestUpdate()),!0}get _canReorderTabs(){return Zf({canEdit:this._canEdit,kiosk:this._kiosk,mode:this._mode,pointerType:"mouse",spaceCount:this._model.length,fixedFloor:this._hasFixedFloor})}_tabPointerDown(e,t){Zf({canEdit:this._canEdit,kiosk:this._kiosk,mode:this._mode,pointerType:e.pointerType,spaceCount:this._model.length,fixedFloor:this._hasFixedFloor})&&(yv(e),this._tabDragRelease=e=>this._tabPointerUp(e),window.addEventListener("pointerup",this._tabDragRelease),window.addEventListener("pointercancel",this._tabDragRelease),this._tabDrag={id:t,pointerId:e.pointerId,x:e.clientX,y:e.clientY,moved:!1,targetId:null,placement:null})}_tabDropTargetAt(e,t,i){const n=this._model.map(e=>e.id),r=n.indexOf(i);if(r<0)return null;const o=this.renderRoot.querySelectorAll('[data-hp="space-tab"]');for(const s of o){const o=s.dataset.id||"";if(!o||o===i)continue;const a=s.getBoundingClientRect();if(ea.right||ta.bottom)continue;const l=n.indexOf(o);return l<0?null:{targetId:o,placement:l=4)))return;var i,n;const r=this._tabDropTargetAt(e.clientX,e.clientY,t.id);t.moved&&t.targetId===r?.targetId&&t.placement===r?.placement||(this._tabDrag={...t,moved:!0,targetId:r?.targetId||null,placement:r?.placement||null})}_tabPointerUp(e){const t=this._tabDrag;if(t&&t.pointerId!==e.pointerId)return;const i="pointerup"===e.type&&t?.moved?this._tabDropTargetAt(e.clientX,e.clientY,t.id):null;"pointerup"===e.type&&t?.moved&&this._suppressNextTabClick(),this._endTabDrag(),t?.moved&&i&&this._commitTabOrder(t.id,i.targetId)}_endTabDrag(){this._tabDrag=null,this._tabDragRelease&&(window.removeEventListener("pointerup",this._tabDragRelease),window.removeEventListener("pointercancel",this._tabDragRelease),this._tabDragRelease=null)}_tabClick(e){if(this._tabSuppressClick)return this._tabSuppressClick=!1,clearTimeout(this._tabSuppressClickTimer),void(this._tabSuppressClickTimer=void 0);this._pickSpace(e)}_suppressNextTabClick(){this._tabSuppressClick=!0,clearTimeout(this._tabSuppressClickTimer),this._tabSuppressClickTimer=window.setTimeout(()=>{this._tabSuppressClick=!1,this._tabSuppressClickTimer=void 0},0)}_commitTabOrder(e,t){const i=this._serverCfg;if(!i||!this._canReorderTabs)return;const n=this._model.map(e=>e.id),r=function(e,t,i){const n=e.indexOf(t),r=e.indexOf(i);if(n<0||r<0||n===r)return e;const o=e.slice();return o.splice(n,1),o.splice(r,0,t),o}(n,e,t);if(r===n)return;const o=new Map(this._devices.map(e=>[String(e.id),String(e.area||"")])),s=function(e,t,i,n=()=>""){if(!i)return[];const r=[];for(const o of e){if(!o||!0===o.removed)continue;const e="string"==typeof o.id?o.id:"";if(!e)continue;if("string"==typeof o.space&&o.space)continue;const s=("string"==typeof o.area?o.area:"")||n(e)||"";s&&t[s]||r.push({id:e,space:i})}return r}(i.markers||[],Object.fromEntries(Object.entries(this._areaToSpace).map(([e,t])=>[e,t.space])),n[0]||"",e=>o.get(e)||"");if(s.length){const e=new Map(s.map(e=>[e.id,e.space]));for(const t of i.markers||[]){const i=e.get(String(t.id));i&&(t.space=i)}}i.spaces=function(e,t){const i=new Map(t.map((e,t)=>[e,t]));return e.map((e,t)=>({space:e,index:t})).sort((e,t)=>(i.get(String(e.space?.id))??Number.MAX_SAFE_INTEGER)-(i.get(String(t.space?.id))??Number.MAX_SAFE_INTEGER)||e.index-t.index).map(e=>e.space)}(i.spaces||[],r),this._saveConfig(),this._tabOrderWarned||(this._tabOrderWarned=!0,this._showToast(this._t("toast.space_order_changed")))}_pickSpace(e){if(this._endTabDrag(),e===this._space)return;const t=this._model.map(e=>e.id),i=t.indexOf(this._space),n=t.indexOf(e);this._navApplied=!0,this._showFar=!1,this._frame=null,this._slideTo(e,i>=0&&n0&&Date.now()>=this._cyclePausedUntil&&this._model.length>1&&this._zoom<=1.001){const e=this._model.map(e=>e.id),t=e.indexOf(this._space);this._slideTo(e[(t+1)%e.length],"left"),this._showKioskDots()}}_syncCycleTimer(){clearInterval(this._cycleTimer),this._cycleTimer=void 0,this.isConnected&&!this._hasFixedFloor&&this._config?.kiosk&&Number(this._config.cycle)>0&&(this._cycleTimer=window.setInterval(()=>this._cycleTick(),1e3*Number(this._config.cycle)))}get _editing(){return"plan"===this._mode||"devices"===this._mode||"decor"===this._mode}get _markup(){return"plan"===this._mode}get _wallUnionCache(){return this._wallUnionCacheValue}set _wallUnionCache(e){this._wallUnionCacheValue=e,null===e&&this._wallUnionPool.clear()}get _glowClipCache(){return this._glowRuntimeState.clipCache}get _glowGeometryWarnings(){return this._glowRuntimeState.geometryWarnings}get _glowFeatherUnits(){return this._glowRuntimeState.featherUnits}set _glowFeatherUnits(e){this._glowRuntimeState.featherUnits=e}get _glowRenderedSources(){return this._glowRuntimeState.renderedSources}get _glowLastAppearance(){return this._glowRuntimeState.lastAppearance}get _glowFeatherSuspendUntil(){return this._glowRuntimeState.featherSuspendUntil}set _glowFeatherSuspendUntil(e){this._glowRuntimeState.featherSuspendUntil=e}get _glowFeatherResumeTimer(){return this._glowRuntimeState.featherResumeTimer}set _glowFeatherResumeTimer(e){this._glowRuntimeState.featherResumeTimer=e}get _glowSourceSeq(){return this._glowRuntimeState.sourceSeq}set _glowSourceSeq(e){this._glowRuntimeState.sourceSeq=e}_activateSafeDayCycleOutline(){this._safeDayCycleOutline=!0,this._stageEl?.classList.add("hp-safe-daycycle-outline")}get _touchSequenceMultitouch(){return this._touchClickGuard.sequenceMultitouch}_syncDangerConfirmLocaleGate(){return this._config&&this.hass?dp(this,gp,kp(this.hass,this._config.language)):"ready"}_dangerConfirmMissingSpace(){const e=this._model;if(!e.length)return!1;const t=this._fixedFloorState(e);return"pending"!==t.kind&&"invalid"!==t.kind&&!this._spaceModel()}_syncVersionRecovery(){this._versionRecovery.update({frontendVersion:ev(iv),backendVersion:this._haIntegrationVersion,kiosk:!0===this._config?.kiosk,reducedMotion:this._reducedMotion})}_newContinuityController(){return new lc(()=>{this._resumeSettling="steady"!==this._continuity.state,this._continuityEpoch++,this.isConnected&&this.requestUpdate()})}get _labsIso(){return this._labs.active.includes("iso")}get _desiredProjection(){return"view"===this._mode&&this._labsIso&&"iso"===this._viewPreference[this._space]?"iso":"flat"}_saveViewPreference(){try{localStorage.setItem(uv,JSON.stringify(this._viewPreference))}catch{}}_logicalViewCenter(e){const t=this._view;if(!t)return null;const i=[t.x+t.w/2,t.y+t.h/2],n="iso"===e?cf(i):i;return{x:n[0],y:n[1]}}_convertProjectionView(e,t){if(e===t)return;this._clearRoomFocus(!0);const i=this._logicalViewCenter(e);this._view=null;const n=i?"iso"===t?lf([i.x,i.y],0):[i.x,i.y]:null;this._applyView(this._zoom,n?.[0],n?.[1]),this._warmPatch({vp:this._warmViewportState()}),this.requestUpdate()}_setProjection(e){if(!this._labsIso||"view"!==this._mode)return;const t=this._effectiveProjection();if(this._viewPreference={...this._viewPreference,[this._space]:e},"iso"===e){this._ensureIsoSceneRuntime();const e=this._isoSceneKey();e&&this._isoFallback.delete(e),this._isoFallback.delete(`${this._space}|no-borders`),this._clearIsoInvalidFallback()}this._saveViewPreference(),this._isoProjectionSnapshot=null;const i=this._effectiveProjection();this._convertProjectionView(t,i)}_hashSpace(){return Ff(window.location.hash||"")}connectedCallback(){this._connectedPath=location.pathname,this._routeDepartureHandled=!1,this._configReloadAuthority.observeContext(Vu(this)),window.addEventListener("location-changed",this._onLocationChanged),window.addEventListener("popstate",this._onLocationChanged),this._continuityDisposed&&(this._continuity=this._newContinuityController(),this._continuityDisposed=!1,this._continuityPaintToken=-1);const e=dg(this.ownerDocument);var t;void 0!==e&&(this._glowScreenBlend=e),this._continuityUnsub?.(),this._continuityUnsub=sc(this.ownerDocument,this._pageVisibility),this._languageFailureUnsub?.(),this._languageFailureUnsub=function(...e){return()=>{for(const t of e)t()}}((t=()=>{this._showToast(this._t("toast.locale_load_failed"))},mp.add(t),()=>mp.delete(t)),function(e){return Il.add(e),()=>{Il.delete(e)}}(()=>this._showToast(this._t("toast.furniture_art_load_failed")))),super.connectedCallback(),this._summarySlot.connect(),this._ensureLiveRuntime().catch(()=>this.requestUpdate()),this._pointerModality.connect(this.ownerDocument.defaultView);const i=this.ownerDocument.defaultView?.MutationObserver;i&&(this._pointerHoverObserver=new i(e=>{let t=!1;for(const i of e){for(const e of i.addedNodes)this._syncPointerHoverSubtree(e);const e=e=>{if(e.nodeType!==Node.ELEMENT_NODE)return!1;const t=e;return t.matches(".devlayer, .devlayer *")||!!t.querySelector?.(".devlayer")};(e(i.target)||[...i.addedNodes,...i.removedNodes].some(e))&&(t=!0)}t&&this._invalidateDeviceHitGeometry()}),this._pointerHoverObserver.observe(this.renderRoot,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style","data-id"]})),this._motionMedia=window.matchMedia?.("(prefers-reduced-motion: reduce)"),this._reducedMotion=!!this._motionMedia?.matches,this._motionMedia?.addEventListener?.("change",this._onMotionChange),this._syncVersionRecovery(),this._versionRecovery.connect(),hg(this.ownerDocument).then(e=>{e!==this._glowScreenBlend&&(this._glowScreenBlend=e,this.isConnected&&this.requestUpdate())}),this.hass&&this._ensureHaRegistryAuthority(),window.addEventListener("keydown",this._keyHandler),this._signer.start(()=>this.hass,()=>this._referencedContentUrls()),this._syncCycleTimer(),window.addEventListener("hashchange",this._onHashChange),this._labsUnsub?.(),this._labsUnsub=function(e){Nf.add(e);const t=Bf();return"undefined"==typeof window&&e(t),()=>{Nf.delete(e)}}(this._onLabsSnapshot),this._labsIso&&this._ensureIsoSceneRuntime(),this._booting?this._bootWatch():this._bootFading&&(clearTimeout(this._bootTimer),this._bootTimer=window.setTimeout(()=>{this._bootFading=!1},220)),this._bootSoft&&(clearTimeout(this._bootSoftTimer),this._bootSoftTimer=window.setTimeout(()=>{this._bootSoft=!1},rv)),!this._loadOk&&this._serverCfg&&this.hass&&this._scheduleLoadRetry(),!this._warmSlot&&this._config&&this._warmAdopt(),this._loadOk&&this._ensureLiveSyncSubscriptions(),this._warmVp&&!this._warmRevivePending&&void 0===this._warmReviveTimer&&(this._warmRevivePending=!0,this._warmReviveTimer=window.setTimeout(()=>this._warmReviveDialog(),0)),this._warmLongReturn&&this._beginResumeSettle(),this._warmLongReturn=!1,this.requestUpdate()}disconnectedCallback(){this._versionRecovery.disconnect(),this._configReloadAuthority.invalidateLifecycle(),this._liveRt?.dispose(),this._radarLive.stop(),this._editorRuntime?._disposeLiveEditor(),this._clearRoomFocus(!0),this._cancelDangerConfirm(),this._connectedPath&&location.pathname!==this._connectedPath&&this._leaveCardRoute(),window.removeEventListener("location-changed",this._onLocationChanged),window.removeEventListener("popstate",this._onLocationChanged),this._continuityUnsub?.(),this._continuityUnsub=void 0,this._languageFailureUnsub?.(),this._languageFailureUnsub=void 0,this._motionMedia?.removeEventListener?.("change",this._onMotionChange),this._motionMedia=void 0,this._vacRaf&&(cancelAnimationFrame(this._vacRaf),this._vacRaf=0),this._refitRaf&&(cancelAnimationFrame(this._refitRaf),this._refitRaf=0),this._warmModeRequest=0,this._dayCycleTimer&&(clearInterval(this._dayCycleTimer),this._dayCycleTimer=0),this._summarySlot.disconnect(),this._dayCycleClockKey="",this._bootSettleRaf&&(cancelAnimationFrame(this._bootSettleRaf),this._bootSettleRaf=0),this._bootSettling=!1;for(const e of this._activityRt.values())clearTimeout(e.timer);window.removeEventListener("keydown",this._keyHandler),this._endTabDrag(),clearTimeout(this._tabSuppressClickTimer),this._tabSuppressClickTimer=void 0,this._tabSuppressClick=!1,clearInterval(this._cycleTimer),clearTimeout(this._kioskDotsTimer),clearTimeout(this._kioskHoldTimer),clearTimeout(this._reloadRetry),clearTimeout(this._loadRetryTimer),this._loadRetryTimer=void 0,this._connHooked?.removeEventListener?.("ready",this._onConnReady),this._connHooked?.removeEventListener?.("disconnected",this._onConnLost),this._connHooked?.removeEventListener?.("reconnect-error",this._onConnLost),this._connHooked=null,this._haRegistryRelease?.(),this._haRegistryRelease=void 0,this._haRegistryConnection=null,this._signer.dispose(),clearTimeout(this._toastTimer),clearTimeout(this._slideTimer),clearTimeout(this._editorRuntimeLoadingTimer),this._editorRuntimeLoadingTimer=void 0,this._editorRuntimeLoadingVisible=!1,this._modeTransition.dispose(),this._cameraTransition.dispose(),this._cameraTransitionFit=null,this._modeTransitionVisual=null,this._modeTransitionPreparing=!1,this._modeTransitionForceAtomic=!1,this._modeTransitionRequest++,this._slideTimer=void 0,this._slide="",clearTimeout(this._bootTimer),this._bootTimer=void 0,clearTimeout(this._bootSoftTimer),this._saveConfigDebounced.flush(),this._cancelDeviceDrag(),window.removeEventListener("hashchange",this._onHashChange),this._labsUnsub?.(),this._labsUnsub=void 0,clearTimeout(this._holdTimer),this._roViewport?.disconnect(),this._roViewport=void 0,this._roHdr?.disconnect(),this._roHdr=void 0,this._onWinResize&&(window.removeEventListener("resize",this._onWinResize),this._onWinResize=void 0),this._unsubCfg&&(this._unsubCfg(),this._unsubCfg=null),this._unsubLayout&&(this._unsubLayout(),this._unsubLayout=null),this._unsubVirtual&&(this._unsubVirtual(),this._unsubVirtual=null),this._unsubTrail&&(this._unsubTrail(),this._unsubTrail=void 0),this._liveSyncGeneration++,this._liveSyncAttempt=null,this._liveSyncConnection=null,clearTimeout(this._layoutSyncTimer),clearTimeout(this._duplicateColumnTimer),Fm(this._glowRuntimeState,this._glowRuntimeHost),this._warmSnapshot(),this._warmRevivePending=!1,clearTimeout(this._warmReviveTimer),this._warmReviveTimer=void 0,this._warmRelease(),this._clearPlanSnapHover(),this._clearOpeningPlacement(!0),this._editorRuntime?._clearFurniturePreview(),this._editorRuntime?._furnShiftDetach(),this._touchContacts.clear(),this._touchClickGuard.reset(),this._resetDeviceHitState(),this._clearTransientHover(!0),this._cancelDevicePressFeedback(),this._pointerHoverObserver?.disconnect(),this._pointerHoverObserver=void 0,this._pointerModality.disconnect(),this._editorSecondary?.reset(),this._resumeSettling=!1,this._continuityHistory=[...this._continuityHistory,...this._continuity.trace].slice(-80),this._continuity.dispose(),this._continuityDisposed=!0,super.disconnectedCallback()}_onKey(e){if("Escape"===e.key&&this._vacFit){if(this._vacFit.busy)return;return this._vacFit=null,this._showToast(this._t("vac.cal_cancelled")),void e.stopPropagation()}if("Escape"===e.key){if(this._tapConfirm)return void(this._tapConfirm=null);if(this._vacCalConfirm)return void(this._vacCalConfirm.busy||(this._vacCalConfirm=null));if(this._decorEraseConfirm)return void(this._decorEraseConfirm=null);if(this._openingInfo)return void(this._openingInfo=null);if(this._infoCard)return void this._closeInfoCard();if(this._rulesDialog)return void(this._rulesDialog=null);if(this._alignDialog)return this._alignDialog=null,void(this._preflightClipboardFallback=null);if(this._backupImportDialog)return void(this._backupImportDialog=null);if(this._backupExportDialog)return void(this._backupExportDialog=null);if(this._pdfDialog)return void(this._pdfDialog=!1);if(this._supportDialog)return void this._editorRuntime?._closeSupportDialog();if(this._settingsDialog)return void(this._settingsDialog=null);if(this._summary?.closeDialogIfIdle())return;if(this._markerDialog)return void this._closeMarkerDialog();if(this._deviceInbox)return void(this._deviceInbox=null);if(this._openingDialog)return void(this._openingDialog=null);if(this._physicalDialog)return void(this._physicalDialog=null);if(this._backdropDialog)return void(this._backdropDialog=null);if(this._decorShapeDialog)return void(this._decorShapeDialog=null);if(this._decorTextDialog)return void(this._decorTextDialog=null);if(this._spaceDialog&&!this._roomDialog)return this._spaceDialog=null,this._importQueue=[],void(this._importTotal=0);if(this._editorSecondary?.hasOpenGroup)return e.preventDefault(),void this._editorSecondary?.closeGroup(!0)}const t=e.composedPath?.()||[e.target],i=t.some(e=>e?.matches?.('input, textarea, select, [contenteditable="true"]')),n=t.some(e=>e?.classList?.contains?.("editor-secondary")),r=e.ctrlKey||e.metaKey,o=e.key.toLowerCase(),s=/^[a-z]$/.test(o),a="z"===o||!s&&"KeyZ"===e.code,l="y"===o||!s&&"KeyY"===e.code,c=r&&(a&&e.shiftKey||l),h=r&&a&&!e.shiftKey;if("decor"===this._mode){if((h||c)&&i)return;if(c)return e.preventDefault(),void this._redoGeometry();if(h)return e.preventDefault(),this._decorDraft?void(this._decorDraft=null):this._decorMove||this._dtDrag||this._bdDrag?void this._cancelDecorGesture():void this._undoGeometry();if(("Delete"===e.key||"Backspace"===e.key)&&this._decorSel&&!i&&!n)return e.preventDefault(),void this._decorDeleteSel();const t="ArrowLeft"===e.key?[-this._gridPitch,0]:"ArrowRight"===e.key?[this._gridPitch,0]:"ArrowUp"===e.key?[0,-this._gridPitch]:"ArrowDown"===e.key?[0,this._gridPitch]:null;return!t||r||e.altKey||"select"!==this._decorTool||!this._decorSel||!this._decorList.some(e=>e.id===this._decorSel)||this._decorDraft||this._decorMove||this._dtDrag||this._bdDrag||i||n||this._editorSecondaryDialogBlocked?void("Escape"===e.key&&(e.preventDefault(),this._decorDraft?this._decorDraft=null:this._decorMove||this._dtDrag||this._bdDrag?this._cancelDecorGesture():"furniture"===this._decorTool?(this._editorRuntime?._clearFurniturePreview(),this._editorRuntime?._furnShiftDetach(),this._furnPalette=null,this._furnCategory=null,this._decorTool="select"):this._decorSel?this._decorSel=null:"select"!==this._decorTool?this._decorTool="select":this._setMode("view"))):(e.preventDefault(),void this._decorNudge(t[0],t[1]))}if("devices"===this._mode){if((h||c)&&i)return;return c?(e.preventDefault(),void this._redoDevicePosition()):h?(e.preventDefault(),void this._undoDevicePosition()):void("Escape"===e.key&&this._deviceDrag&&(e.preventDefault(),this._cancelDeviceDrag()))}if(this._markup&&(!h&&!c||!i)){if(("Delete"===e.key||"Backspace"===e.key)&&this._physicalSel&&!i&&!n)return e.preventDefault(),void this._deletePhysicalSelection();if(c)return e.preventDefault(),void this._redoGeometry();if(h)return e.preventDefault(),this._resize?.dragging?void this._rszCancelDrag():this._wallFaceBatch?(this._roomDialogCancel(),void(this._activeWallChainId&&this._path.length>1?this._undoActiveWallPoint():this._undoPoint())):"draw"===this._tool&&this._path.length?void(this._activeWallChainId&&this._path.length>1?this._undoActiveWallPoint():this._undoPoint()):"split"===this._tool&&this._splitSel?.pts?.length?(this._splitSel={...this._splitSel,pts:this._splitSel.pts.slice(0,-1)},void(this._splitSel.pts.length||(this._cursorPt=null))):void this._undoGeometry();if("Escape"===e.key)return this._physicalDrag||this._physicalRotate?(e.preventDefault(),void this._cancelPhysicalGesture()):this._roomDialog?(e.preventDefault(),void this._roomDialogCancel()):"draw"===this._tool&&this._path.length?(e.preventDefault(),void this._finishWallChain()):this._physicalSel?(e.preventDefault(),void(this._physicalSel=null)):"resize"===this._tool?(e.preventDefault(),this._resize?.dragging?void this._rszCancelDrag():("exit-tool"===this._resize?.escapeIdle()&&(this._tool="draw"),void this.requestUpdate())):"split"===this._tool?(e.preventDefault(),void(this._splitSel?.pts?.length?(this._splitSel={...this._splitSel,pts:this._splitSel.pts.slice(0,-1)},this._splitSel.pts.length||(this._cursorPt=null)):this._splitSel?this._splitSel=null:this._tool="draw")):"merge"===this._tool?(e.preventDefault(),void(this._mergeSel?this._mergeSel=null:this._tool="draw")):this._wallDialog?(e.preventDefault(),void(this._wallDialog=null)):void("opening"!==this._tool&&"wallthick"!==this._tool&&"delroom"!==this._tool&&"column"!==this._tool||(e.preventDefault(),"opening"===this._tool&&this._clearOpeningPlacement(!0),this._tool="draw"))}}_undoPoint(){if(this._path.length)return this._contourClosed?(this._path=this._path.slice(0,-1),void(this._closingWallCm=null)):void(this._activeWallChainPartitionIds.length&&this._path.length>1?this._undoActiveWallPoint():this._path=this._path.slice(0,-1))}_undoActiveWallPoint(){const e=[...this._activeWallChainPartitionIds],t=e[e.length-1],i=this._spaceModel()?.partitions.find(e=>e.id===t),n=this._path[0]?[...this._path[0]]:null,r=this._path.slice(0,-1).map(e=>[...e]),o=this._wallChainSegmentCms.slice(0,-1),s=this._geometryHistory.undo();if(!s)return this._activeWallChainPartitionIds=[],this._wallChainSegmentCms=[],this._wallChainRedo=[],void(this._path=n?[n]:[]);this._applyGeometryState(s.before,!0)?(this._activeWallChainId||=`chain-${Date.now().toString(36)}`,this._activeWallChainPartitionIds=e.slice(0,-1),this._path=r.length?r:n?[n]:[],this._wallChainSegmentCms=o,i&&this._wallChainRedo.push({id:i.id,point:[...i.b],cm:i.cm}),this._clearPlanSnapHover(),this._showToast(this._t("history.undone",{name:s.name}))):this._geometryHistory.clear()}static async getConfigElement(){return await import("./editor-Dc4-BCoL.js"),document.createElement("houseplan-card-editor")}static getStubConfig(){return{type:"custom:houseplan-card"}}static _warmBootReset(e){for(const e of ov.values())for(const t of e)clearTimeout(t.evict);ov.clear(),av=e&&e>0?e:1e4}static _warmBootStats(){let e=0,t=0;const i=[];for(const n of ov.values())for(const r of n)e++,r.dlg&&(t++,i.push(r.dlg.kind));return{keys:ov.size,slots:e,dlgs:t,drafts:i}}setConfig(e){const t=this._config,i=!!t&&Object.prototype.hasOwnProperty.call(t,"floor");this._config={icon_size:2.5,show_temperature:!0,live_states:!0,show_signal:!0,...e};(i!==this._hasFixedFloor||t?.floor!==this._config.floor)&&(this._hashApplied=!1,this._navApplied=!1,this._warmVpArmed=!1),this._config.kiosk&&(this._booting=!1,this._bootFading=!1),!this._hasFixedFloor&&e.default_floor&&this._commitSpace(e.default_floor,!0);try{this._zoomBySpace=JSON.parse(localStorage.getItem(hv)||"{}")||{}}catch{this._zoomBySpace={}}try{const e=JSON.parse(localStorage.getItem(uv)||"{}")||{};this._viewPreference=Object.fromEntries(Object.entries(e).filter(e=>"flat"===e[1]||"iso"===e[1]))}catch{this._viewPreference={}}if(this._labs=Bf(),this.isConnected&&this._labsIso&&this._ensureIsoSceneRuntime(),!this._summary?.applyLocalScaleForCurrentIdentity())try{const e=JSON.parse(localStorage.getItem("houseplan_card_kiosk_v1")||"null");this._kioskScale={icon:jn(e?.icon),font:jn(e?.font)}}catch{}try{const e=JSON.parse(localStorage.getItem(cv)||"null");this._adoption.restoreCached(e)&&(this._seedDecorStyle(this._serverCfg),this._cfgEpoch++,this._virtualLights=Hh(e.virtual_lights,this._cfgRev),this._serverStorage=!0)}catch{}this._adoptInitialSpace(this._model,this._loadOk),"view"!==this._mode||this._view||(this._zoom=this._zoomBySpace[this._space]||1),this.isConnected&&(this._syncCycleTimer(),this._warmAdopt(),this._warmLongReturn&&this._beginResumeSettle(),this._warmLongReturn=!1),this._syncVersionRecovery()}_warmAdopt(){if(this._config?.kiosk)return;const e=Cf(this._config);if(this._warmKey===e&&this._warmSlot)return;this._warmSlot&&this._warmRelease();const t=this.parentNode,i=this._warmIdx(t),n=ov.get(e);if(!n||!n.length)return;const r=n.find(e=>e.owner===this._warmGen);if(r)return this._warmLongReturn=!!r.freed&&Date.now()-r.freed>=nc,clearTimeout(r.evict),r.evict=0,r.freed=0,r.live=!0,this._warmSlot=r,this._warmKey=e,r.frameFingerprint&&this._continuity.adoptCompleteFrame(r.frameFingerprint),void(!this._devices.length&&r.devices?.length&&(this._devices=[...r.devices]));const{slot:o,sure:s}=((e,t,i,n)=>{const r=e=>{const t=!!i&&e.place?.deref()===i;return t&&e.idx===n?4:e.live?0:t?3:2};let o=null,s=0,a=0,l=null;for(const i of e){if(i.owner===t)continue;l=i;const e=r(i);e<=0||(e>s?(o=i,s=e,a=1):e===s&&a++)}return!o||a>1?{slot:o||l,sure:!1}:{slot:o,sure:!0}})(n,this._warmGen,t,i);o&&(this._warmLongReturn=!!o.freed&&Date.now()-o.freed>=nc,this._booting=!1,this._bootFading=!1,this._hdrH=o.hdrH,this._bootSoft=!0,this.isConnected&&(clearTimeout(this._bootSoftTimer),this._bootSoftTimer=window.setTimeout(()=>{this._bootSoft=!1},rv)),this._warmKey=e,s?(clearTimeout(o.evict),o.evict=0,o.owner=this._warmGen,o.place=t?new WeakRef(t):null,o.idx=i,o.live=!0,this._warmSlot=o,this._warmVp=o.vp,o.frameFingerprint&&this._continuity.adoptCompleteFrame(o.frameFingerprint),!this._devices.length&&o.devices?.length&&(this._devices=[...o.devices]),this._warmAdoptViewport(this._config)):(this._warmSlot={owner:this._warmGen,path:location.pathname,place:t?new WeakRef(t):null,idx:i,live:!0,hdrH:o.hdrH,stageH:o.stageH,vp:null,frameFingerprint:"",devices:null,dlg:null,freed:0,evict:0},n.push(this._warmSlot),this._warmTrim(n)))}_warmIdx(e){const t=e?.children;if(!t)return-1;for(let e=0;e4;){const t=e.findIndex(e=>!e.live);if(t<0)break;clearTimeout(e[t].evict),e.splice(t,1)}}_warmScheduleEvict(e,t){if(clearTimeout(e.evict),!(e.dlg||e.vp&&"view"!==e.vp.mode))return;const i=e.freed,n=e.owner;e.evict=window.setTimeout(()=>{if(e.evict=0,e.freed!==i||e.owner!==n)return;var r;e.dlg=null,e.vp=(r=e.vp)&&"view"!==r.mode?{...r,mode:"view",zoom:r.snap?.space===r.space?r.snap.zoom:r.zoom,view:null,snap:null,tool:"draw",decorTool:"select",showHidden:!1,selId:null,rszSel:null,decorSel:null}:r,e.frameFingerprint="";const o=ov.get(t);if(!e.live&&o&&o.length>1){const t=o.indexOf(e);t>=0&&o.splice(t,1)}},av+250)}_warmAdoptViewport(e){const t=this._warmVp;if(!t||this._warmSlot?.path!==location.pathname)return void(this._warmVp=null);const i=this._fixedFloorState();if(this._hashApplied||!this._model.find(e=>e.id===t.space)||"valid"===i.kind&&i.id!==t.space||this._hasFixedFloor&&"valid"!==i.kind)return void(this._warmVp=null);this._commitSpace(t.space,!0),this._navApplied=!0;const n="view"!==t.mode&&this._canEdit&&!e.kiosk?t.mode:"view";this._adoptMode("view"),this._pendingNavMode="view"===t.mode||this._canEdit||e.kiosk?null:t.mode,this._zoom=t.zoom;const r=this._effectiveProjection(),o=r===t.projection&&this._labsIso===t.activeLabsIso;if(this._view=o&&t.view?{...t.view}:null,this._viewModeSnap=o&&t.snap?{...t.snap}:null,!o&&t.logicalCenter){const e="iso"===r?lf([t.logicalCenter.x,t.logicalCenter.y],0):[t.logicalCenter.x,t.logicalCenter.y];this._applyView(t.zoom,e[0],e[1])}var s;this._tool="opening"===(s=function(e){return"partition"===e?"draw":e}(s=t.tool))?"draw":"string"==typeof s&&Rf.has(s)?s:"draw",this._decorTool=t.decorTool,this._showHidden=t.showHidden,this._showFar!==t.showFar&&(this._showFar=t.showFar,this._frame=null),this._selId=t.selId,this._resize?.restoreSelection(t.rszSel),this._decorSel=t.decorSel,this._warmVpArmed=!0,"view"!==n&&this._requestMode(n,!1,!0)}_warmPatch(e,t=!1){if(this._config?.kiosk)return;const i=Cf(this._config);if(!this._warmSlot||this._warmKey===i){if(!this._warmSlot){if(!t)return;const e=this.parentNode;this._warmKey=i,this._warmSlot={owner:this._warmGen,path:location.pathname,place:e?new WeakRef(e):null,idx:this._warmIdx(e),live:!0,hdrH:this._hdrH,stageH:0,vp:null,frameFingerprint:"",devices:null,dlg:null,freed:0,evict:0};const n=ov.get(i)||[];for(n.push(this._warmSlot),ov.set(i,n),this._warmTrim(n);ov.size>8;){const e=ov.keys().next().value;if(void 0===e||e===i)break;for(const t of ov.get(e)||[])clearTimeout(t.evict);ov.delete(e)}}Object.assign(this._warmSlot,e)}}_warmViewportState(){const e=this._effectiveProjection();return{space:this._space,mode:this._mode,projection:e,activeLabsIso:this._labsIso,logicalCenter:this._logicalViewCenter(e),zoom:this._zoom,view:this._view?{...this._view}:null,snap:this._viewModeSnap?{...this._viewModeSnap}:null,tool:this._tool,decorTool:this._decorTool,showHidden:this._showHidden,showFar:this._showFar,selId:this._selId,rszSel:this._resize?.selectedRoomId,decorSel:this._decorSel}}_warmDialogState(){const e=(e,t)=>({kind:e,space:this._space,mode:this._mode,data:t});return this._tapConfirm||this._alignDialog||this._mergeDialog||this._importDialog||this._backupExportDialog||this._backupImportDialog?null:this._openingInfo?e("openingInfo",this._openingInfo.id):this._infoCard?e("info",this._infoCard.id):this._rulesDialog?this._rulesDialog.busy?null:e("rules",this._rulesDialog):this._settingsDialog?this._settingsDialog.busy?null:e("settings",this._settingsDialog):this._markerDialog?this._markerDialog.busy?null:e("marker",this._markerDialog):this._openingDialog?e("opening",this._openingDialog):this._backdropDialog?e("backdrop",this._backdropDialog):this._decorShapeDialog?e("decorShape",this._decorShapeDialog):this._decorTextDialog?e("decorText",this._decorTextDialog):this._roomDialog?e("room",{editId:this._roomEditId,fill:this._roomFill,customFill:this._roomCustomFill,tempMin:this._roomTempMin,tempMax:this._roomTempMax,tempSrc:this._roomTempSrc,humSrc:this._roomHumSrc,srcOpen:this._roomSrcOpen,srcFilter:this._roomSrcFilter,nameScale:this._roomNameScale,labelScale:this._roomLabelScale,areaSel:this._areaSel,nameSel:this._nameSel,pendingSplit:this._pendingSplit,wallFaceBatch:this._wallFaceBatch,path:this._path}):this._spaceDialog?this._spaceDialog.busy?null:e("space",this._spaceDialog):null}_warmSnapshot(){if(this._booting||this._config?.kiosk||"steady"!==this._continuity.state)return;const e={vp:this._warmViewportState(),frameFingerprint:this._continuity.frameFingerprint,devices:this._devices,hdrH:this._hdrH};if(this._warmRevivePending||(e.dlg=this._warmDialogState()),this.isConnected&&this._warmSlot?.owner===this._warmGen){const t=this.parentNode;e.place=t?new WeakRef(t):null,e.idx=this._warmIdx(t)}this._warmPatch(e)}_warmReviveDialog(){const e=this._warmSlot;if(this._warmReviveTimer=void 0,!e||!e.dlg)return void(this._warmRevivePending=!1);const t=e.dlg,i=e.freed;if(t.mode===this._mode||"view"===t.mode||this._warmVp?.mode!==t.mode||this._editorRuntime){if(this._warmRevivePending=!1,e.dlg=null,e.freed=0,clearTimeout(e.evict),e.evict=0,i&&!(Date.now()-i>av)&&t.space===this._space&&t.mode===this._mode){switch(t.kind){case"space":this._spaceDialog={...t.data,busy:!1,savedBusy:!1};break;case"marker":this._markerDialog={...t.data,busy:!1};break;case"settings":this._settingsDialog={...t.data,busy:!1};break;case"rules":this._rulesDialog={...t.data,busy:!1};break;case"opening":this._openingDialog={...t.data};break;case"backdrop":this._backdropDialog={...t.data};break;case"decorShape":this._decorShapeDialog={...t.data};break;case"decorText":{this._decorTextDialog={...t.data};const e=String(this._decorTextDialog?.text??"").length;this._decorTextSelection={start:e,end:e};break}case"room":{const e=t.data;this._roomEditId=e.editId,this._roomFill=e.fill,this._roomCustomFill=e.customFill||null,this._roomTempMin=e.tempMin||"",this._roomTempMax=e.tempMax||"",this._roomTempSrc=e.tempSrc,this._roomHumSrc=e.humSrc,this._roomSrcOpen=e.srcOpen,this._roomSrcFilter=e.srcFilter,this._roomNameScale=e.nameScale,this._roomLabelScale=e.labelScale,this._areaSel=e.areaSel,this._nameSel=e.nameSel,this._pendingSplit=e.pendingSplit,this._wallFaceBatch=e.wallFaceBatch||null,this._path=e.path,this._wallFaceBatch&&(this._activeWallChainId=`chain-${Date.now().toString(36)}`,this._activeWallChainPartitionIds=[...this._wallFaceBatch.activePartitionIds],this._wallChainSegmentCms=[...this._wallFaceBatch.activeCms]),this._roomDialog=!0;break}case"info":{const e=this._devices.find(e=>e.id===t.data);e&&(this._infoCard=e);break}case"openingInfo":{const e=(this._curSpaceCfg?.openings||[]).find(e=>e.id===t.data);e&&(this._openingInfo=e);break}}this.requestUpdate()}}else this._warmRevivePending=!0}_cacheSnapshot(){if(this._serverCfg)try{this._virtualLights=function(e,t,i){if(e.configRev===i)return e;const n=new Set((Array.isArray(t?.markers)?t.markers:[]).filter(qh).map(e=>e.id));return{...e,configRev:i,off:new Set([...e.off].filter(e=>n.has(e)))}}(this._virtualLights,this._serverCfg,this._cfgRev);const e=this._adoption.snapshot(function(e){return{rev:e.rev,config_rev:e.configRev,off:[...e.off].sort()}}(this._virtualLights));e&&localStorage.setItem(cv,JSON.stringify(e))}catch{}}_beginContinuityCandidate(e,t,i="plan"){return this._booting&&!this._continuity.hasCompleteFrame?this._continuity.token:(this._continuityDataReady=t,this._continuityPaintToken=-1,this._stagedDeviceSnapshotToken=-1,this._resumeSettling=!0,this._continuity.beginCandidate(e,i))}_continuityStageValid(){const e=this._stageEl;return!!e&&e.clientWidth>0&&e.clientHeight>0}_versionReloadSafetySnapshot(){return Sg(this)}_continuityAssetsReady(){if(!this._model.length)return!1;const e=this._model.length?this._spaceModel():null;return!e?.bg?.href||this._signer.isReady(this.hass,e.bg.href)}_initialSpaceSelection(e,t=this._loadOk){const i=this._fixedFloorState(e,t);return"valid"===i.kind?{id:i.id,source:"fixed"}:this._hasFixedFloor?{id:null,source:"none"}:function(e){const t=new Set(e.spaceIds.filter(e=>!!e));if(!t.size)return{id:null,source:"none"};const i=[["hash",!1===e.acceptHash?null:e.hashSpace],["current",e.preserveCurrent?e.currentSpace:null],["saved",e.savedSpace],["default",e.defaultSpace],["first",e.spaceIds[0]]];for(const[e,n]of i)if(n&&t.has(n))return{id:n,source:e};return{id:null,source:"none"}}({spaceIds:e.map(e=>e.id),hashSpace:this._hashSpace(),acceptHash:!this._hashApplied,currentSpace:this._space,preserveCurrent:this._hashApplied||this._navApplied||this._warmVpArmed,savedSpace:this._savedNav()?.space,defaultSpace:this._config?.default_floor})}_adoptInitialSpace(e,t=this._loadOk){const i=this._initialSpaceSelection(e,t);return i.id?(this._commitSpace(i.id,!0),"hash"===i.source&&(this._hashApplied=!0),"saved"===i.source&&(this._navApplied=!0),i):i}_candidateBackdrop(e,t=this._space){const i=el(e),n=this._fixedFloorState(i,!0);if(this._hasFixedFloor&&"valid"!==n.kind)return"";const r=this._initialSpaceSelection(i,!0).id||(i.some(e=>e.id===t)?t:i[0]?.id);return i.find(e=>e.id===r)?.bg?.href||""}_visualFrameFingerprint(){const e=this._stageEl,t=e?[e.clientWidth,e.clientHeight]:[0,0];return hc([this._cfgRev,this._adoption.currentConfigFingerprint(),this._layoutRev,this._adoption.currentLayoutFingerprint(),this._space,this._mode,this._view,t,this._glowScreenBlend?"screen":"normal",this.hass?.themes?.darkMode??this.hass?.themes?.default_theme??""])}_settleContinuityFrame(){if(this._booting||!this._continuityStageValid())return;if(!this._continuity.hasCompleteFrame&&"steady"===this._continuity.state)return void(this._continuityAssetsReady()&&(this._renderSnapshotAt=Date.now(),this._continuity.markCompleteFrame(this._visualFrameFingerprint())));if(!this._continuityDataReady)return;if(!["holding","offline-stale","overlay-pending","overlay-visible","candidate-ready"].includes(this._continuity.state))return;const e=this._continuity.token;if(this._candidateDeviceSnapshot&&this._candidateDeviceSnapshot!==this._visibleDeviceSnapshot&&this._stagedDeviceSnapshotToken!==e)return this._stagedDeviceSnapshotToken=e,void this.requestUpdate();this._continuityPaintToken!==e&&(this._continuityPaintToken=e,this._continuity.candidateReady(e)&&this._continuity.commitAfterPaint(e,{updateComplete:()=>this.updateComplete,stageValid:()=>this.isConnected&&this._continuityStageValid(),assetsReady:()=>this._continuityAssetsReady(),frameFingerprint:()=>this._visualFrameFingerprint()}).then(t=>{t&&e===this._continuity.token?(this._resumeSettling=!1,this._renderSnapshotAt=Date.now(),this._candidateDeviceSnapshot&&(this._visibleDeviceSnapshot=this._candidateDeviceSnapshot),this._candidateDeviceSnapshot=null,this._stagedDeviceSnapshotToken=-1,this._warmSnapshot()):e===this._continuity.token&&(this._continuityPaintToken=-1,this._stagedDeviceSnapshotToken=-1,this._candidateDeviceSnapshot=null,this.requestUpdate())}))}_onBackdropLoaded(e,t){this._signer.markLoaded(this.hass,e,t),this._continuity.note("asset-ready"),this._continuityPaintToken=-1,"steady"!==this._continuity.state&&this.requestUpdate()}_renderRecoveryOverlay(){if(!this._continuity.overlayVisible&&"recovery-error"!==this._continuity.state)return G;const e="connection"===this._continuity.recoveryReason;return j`
svg{position:absolute;inset:0;width:100%;height:100%;display:block;z-index:1;}.hp-static-stage>.hp-paper-outline-svg{z-index:0;overflow:visible;}.hp-paper{fill:var(--ha-card-background,var(--card-background-color,#111));stroke:none;}.wallbody-fill{fill:var(--wall-fill,#ffffff);fill-opacity:var(--wall-fill-op,1);fill-rule:evenodd;stroke:none;pointer-events:none;}.wallbody{fill:url(#hp-wall-hatch);fill-rule:evenodd;stroke:var(--room-stroke,var(--hp-muted,#607d8b));stroke-width:calc(0.6px * var(--hp-cell-visual-scale,1));pointer-events:none;}.wallbody.solid{fill:none;}.hp-static-stage .devlayer{position:absolute;inset:0;z-index:2;}.hp-static-foot{padding:8px 12px 12px;pointer-events:auto;}.hp-static-btn{width:100%;padding:9px 14px;border:none;border-radius:10px;background:var(--primary-color,#3ea6ff);color:var(--text-primary-color,#fff);font-size:14px;font-weight:600;cursor:pointer;}:host([data-pointer-hover]) .hp-static-btn:hover{filter:brightness(1.08);}.hp-static-error{padding:24px;text-align:center;color:var(--secondary-text-color,#9aa4ad);}`],customElements.get("houseplan-space-card")||customElements.define("houseplan-space-card",_g),window.customCards=window.customCards||[],window.customCards.find(e=>"houseplan-space-card"===e.type)||window.customCards.push({type:"houseplan-space-card",name:"House Plan — Space (static)",description:"Read-only live schematic of a single houseplan space, with a deep-link button.",preview:!1,documentation:"https://github.com/Matysh/houseplan-card"});const mg=o`:host{--hp-editor-tray-bg-fallback:color-mix(in srgb,var(--card-background-color,var(--hp-bg)) 94%,var(--hp-line));--hp-editor-tray-bg:color-mix(in srgb,var(--card-background-color,var(--hp-bg)) 86%,transparent);--hp-editor-tray-border:color-mix(in srgb,var(--hp-line) 82%,var(--hp-accent));--hp-editor-tray-blur:8px;--hp-editor-tray-shadow:var(--shadow-2);}.editor-secondary-host{position:absolute;inset:var(--sp-2) var(--sp-4) auto;z-index:70;display:flex;justify-content:flex-end;pointer-events:none;}.editor-secondary-host.kind-palette,.editor-secondary-host.kind-group{justify-content:flex-start;}.editor-secondary{pointer-events:none;max-width:100%;display:flex;align-items:center;gap:var(--sp-3);padding:var(--sp-3) var(--sp-4);color:var(--hp-txt);background:var(--card-background-color,var(--hp-bg));background:var(--hp-editor-tray-bg-fallback);border:1px solid var(--hp-line);border-color:var(--hp-editor-tray-border);border-radius:var(--rad-l);box-shadow:var(--hp-editor-tray-shadow);opacity:0;visibility:hidden;transform:translateY(-4px);transition:opacity 0.1s ease,transform 0.1s cubic-bezier(0.2,0.7,0.2,1),visibility 0s linear 0.1s;touch-action:auto;}.editor-secondary-host.open .editor-secondary{pointer-events:auto;opacity:1;visibility:visible;transform:translateY(0);transition-duration:0.14s,0.14s,0s;transition-delay:0s;}.editor-secondary-host.blocked .editor-secondary{pointer-events:none;}@supports ((backdrop-filter:blur(1px)) or (-webkit-backdrop-filter:blur(1px))){.editor-secondary{background:var(--hp-editor-tray-bg);-webkit-backdrop-filter:blur(var(--hp-editor-tray-blur));backdrop-filter:blur(var(--hp-editor-tray-blur));}}.editor-secondary-content,.editor-group-items{display:flex;align-items:center;gap:var(--sp-3);min-width:0;}.editor-context-label{max-width:14rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding-inline-end:var(--sp-4);border-inline-end:1px solid var(--hp-line);color:var(--hp-muted);font-size:var(--fs-s);}.editor-secondary.kind-palette{width:min(760px,100%);align-items:stretch;padding:0;overflow:hidden;}.editor-secondary.kind-palette .editor-secondary-content,.editor-secondary.kind-palette .furnpalette{width:100%;}.editor-secondary.kind-palette .furnpalette{max-height:38vh;border:0;background:transparent;}.editor-group-launcher .group-chevron{--mdc-icon-size:16px;transition:transform 0.14s ease;}.editor-group-launcher[aria-expanded="true"] .group-chevron{transform:rotate(180deg);}.editor-secondary .bdhint{font-size:var(--fs-s);color:var(--hp-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}.editor-secondary .dfill{display:inline-flex;align-items:center;gap:var(--sp-2);font-size:var(--fs-s);cursor:pointer;}.editor-secondary .dfill input[type="checkbox"]{width:16px;height:16px;flex:none;margin:0;padding:0;}.editor-secondary hp-color-opacity{flex:0 0 auto;}.editor-secondary input{width:74px;background:transparent;border:1px solid var(--hp-line);color:var(--hp-txt);border-radius:var(--rad-s);padding:var(--sp-3) var(--sp-4);font-size:var(--fs-m);}.editor-secondary label,.editor-secondary .hint{color:var(--hp-muted);font-size:var(--fs-s);}.editor-secondary .drawwall{display:inline-flex;align-items:center;gap:var(--sp-3);white-space:nowrap;}.editor-secondary .drawwall input{width:4.2em;}.editor-secondary .drawwall .opl{color:var(--hp-muted);font-size:var(--fs-s);}@container (min-width:560px) and (max-width:899px){.editor-secondary-content,.editor-group-items{flex-wrap:wrap;justify-content:flex-end;}}@container (max-width:559px){.editor-secondary-host{inset-inline:var(--sp-4);}.editor-secondary{max-width:100%;}.editor-secondary-content,.editor-group-items{overflow-x:auto;scrollbar-width:thin;}.editor-secondary-content>*,.editor-group-items>*{flex:none;}.editor-context-label{display:none;}}@media (prefers-reduced-motion:reduce){.editor-secondary{transition:none;}.editor-group-launcher .group-chevron{transition:none;}}`;class gg{constructor(e=50){this._undo=[],this._redo=[],this._limit=Math.max(30,Math.floor(e))}get canUndo(){return this._undo.length>0}get canRedo(){return this._redo.length>0}get undoName(){return this._undo[this._undo.length-1]?.name??null}get redoName(){return this._redo[this._redo.length-1]?.name??null}get size(){return this._undo.length}push(e){this._undo.push(e),this._undo.length>this._limit&&this._undo.splice(0,this._undo.length-this._limit),this._redo=[]}undo(){const e=this._undo.pop()??null;return e&&this._redo.push(e),e}redo(){const e=this._redo.pop()??null;return e&&this._undo.push(e),e}removeWhere(e){const t=this._undo.length,i=this._redo.length;return this._undo=this._undo.filter(t=>!e(t)),this._redo=this._redo.filter(t=>!e(t)),t+i-this._undo.length-this._redo.length}clear(){this._undo=[],this._redo=[]}}function fg(e,t){const i=e[t];return i&&Number.isFinite(i.x)&&Number.isFinite(i.y)?{x:i.x,y:i.y,..."string"==typeof i.s?{s:i.s}:{}}:null}function vg(e,t,i){if(null===i){if(!(t in e))return e;const i={...e};return delete i[t],i}const n={...e[t]||{}};delete n.x,delete n.y,delete n.s;const r={...n,x:i.x,y:i.y,...void 0!==i.s?{s:i.s}:{}};return{...e,[t]:r}}const yg="houseplan-card:version-reload-target:v1";function bg(e){if("string"!=typeof e)return null;return e.trim()||null}class wg{constructor(e){this.hooks=e,this._input={frontendVersion:null,backendVersion:null,kiosk:!1,reducedMotion:!1},this._relation={kind:"unknown"},this._banner=null,this._connected=!1,this._attemptTarget=null,this._attemptState=null,this._noticeToken=0}get relation(){return this._relation}get banner(){return this._banner}get hasCurrentMismatchNotice(){return"mismatch"===this._relation.kind&&"visible"===this._banner?.phase}connect(){this._connected||(this._connected=!0,this._attemptTarget=null,this._attemptState=null,this._reconcile())}disconnect(){(this._connected||this._banner)&&(this._connected=!1,this._cancelTimer(),this._banner&&(this._banner=null,this.hooks.changed()))}update(e){const t={frontendVersion:bg(e.frontendVersion),backendVersion:bg(e.backendVersion),kiosk:!0===e.kiosk,reducedMotion:!0===e.reducedMotion},i=function(e,t){const i=bg(e),n=bg(t);return i&&n?i===n?{kind:"equal",frontend:i,backend:n}:{kind:"mismatch",frontend:i,backend:n}:{kind:"unknown"}}(t.frontendVersion,t.backendVersion),n=!((e,t)=>e.frontendVersion===t.frontendVersion&&e.backendVersion===t.backendVersion&&e.kiosk===t.kiosk&&e.reducedMotion===t.reducedMotion)(this._input,t)||!((e,t)=>e.kind===t.kind&&("unknown"===e.kind||"unknown"!==t.kind&&e.frontend===t.frontend&&e.backend===t.backend))(this._relation,i);this._input=t,this._relation=i,n&&this._reconcile()}finishBannerExit(e){this._banner&&"leaving"===this._banner.phase&&this._banner.token===e&&(this._banner=null,this.hooks.changed())}_reconcile(){if(this._cancelTimer(),!this._connected||"mismatch"!==this._relation.kind)return this._attemptTarget=null,this._attemptState=null,void this._hideBanner();if(!this._input.kiosk)return this._attemptTarget=null,this._attemptState=null,void this._showBanner(this._relation.frontend,this._relation.backend);const e=this._relation.backend;if(this._attemptTarget===e&&null!==this._attemptState||(this._attemptTarget=e,this._attemptState=function(e,t){try{const i=e();return i?i.getItem(yg)===t?"attempted":"fresh":"unavailable"}catch{return"unavailable"}}(this.hooks.storage,e)),"fresh"===this._attemptState)return this._hideBanner(),void this._armTimer();this._showBanner(this._relation.frontend,e)}_armTimer(){this._connected&&void 0===this._timer&&"mismatch"===this._relation.kind&&this._input.kiosk&&"fresh"===this._attemptState&&(this._timer=this.hooks.clock.setTimeout(()=>{this._timer=void 0,this._tick()},250))}_cancelTimer(){void 0!==this._timer&&(this.hooks.clock.clearTimeout(this._timer),this._timer=void 0)}_tick(){if(!this._connected||"mismatch"!==this._relation.kind||!this._input.kiosk||"fresh"!==this._attemptState)return;if(!function(e){return e.connected&&e.initialFrameSettled&&e.viewOnly&&e.surfacesIdle&&e.configWritesIdle&&e.physicalWritesIdle&&e.layoutWritesIdle&&e.gesturesIdle&&e.interactionPauseElapsed&&e.baseZoom}(this.hooks.safety()))return void this._armTimer();const e=this._relation.backend,t=function(e,t){try{const i=e();return i?i.getItem(yg)===t?"attempted":(i.setItem(yg,t),"claimed"):"unavailable"}catch{return"unavailable"}}(this.hooks.storage,e);if(this._attemptTarget=e,this._attemptState="claimed"===t?"attempted":t,"claimed"===t){this._showBanner(this._relation.frontend,e);try{this.hooks.reload()}catch{}}else this._showBanner(this._relation.frontend,e)}_showBanner(e,t){"visible"===this._banner?.phase&&this._banner.frontend===e&&this._banner.backend===t||(this._banner={frontend:e,backend:t,phase:"visible",token:++this._noticeToken},this.hooks.changed())}_hideBanner(){if(this._banner)return this._input.reducedMotion?(this._banner=null,void this.hooks.changed()):void("leaving"!==this._banner.phase&&(this._banner={...this._banner,phase:"leaving",token:++this._noticeToken},this.hooks.changed()))}}const kg=1;function xg(e,t){const i=t&&"object"==typeof t?t:{};e._haIntegrationVersion=bg(i.integration_version);const n=i.support_api;e._haSupportApi="number"==typeof n&&Number.isSafeInteger(n)?n:null,e._haDecorAssetsApi=1===i.decor_assets_api?1:null,e._haSummaryPanelApi=1===i.summary_panel_api?1:null,e._haRadarStage1Api=1===i.radar_stage1_api?1:null,e._syncVersionRecovery()}function Sg(e){const t=e._stageEl,i=e._loadOk&&!e._loading&&e._continuityDataReady&&!e._resumeSettling&&!e._connectionWasLost&&!e._booting&&!e._bootFading&&!e._bootSettling&&!e._bootSoft&&e._continuity.hasCompleteFrame&&"steady"===e._continuity.state&&!e._continuity.overlayBlocksInteraction&&!!t&&t.clientWidth>0&&t.clientHeight>0,n=!(0!==e._pointers.size||0!==e._touchContacts.size||e._touchSequenceMultitouch||e._roomPointer||e._panStart||e._panLock||e._pinchStart||e._swipeStart||e._tabDrag||e._tabDragRelease||e._drag||e._deviceDrag||e._rlResize||e._resize?.dragging||e._physicalDrag||e._physicalRotate||e._opDrag||e._decorDraft||e._decorMove||e._dtDrag||e._bdDrag||e._furnTouchPending||e._compassDrag||e._viewportGestureDirty||e._devicePositionBusy||e._modeTransitionBusy||e._cameraTransition.active||e._slide||0!==e._warmModeRequest),r=!(e._editorSecondaryDialogBlocked||e._partitionDeleteDialog||e._roomDeleteDialog||e._backdropGuard||e._vacFit||e._editorSecondary?.hasOpenGroup||e._furnPalette||e._decorImagePalette);return{connected:e.isConnected,initialFrameSettled:i,viewOnly:!0===e._config?.kiosk&&"view"===e._mode&&!e._editing,surfacesIdle:r,configWritesIdle:0===e._writesPending&&!e._saveConfigDebounced.pending(),physicalWritesIdle:0===e._pendingPhysicalWrites.size,layoutWritesIdle:!e._persistLayout.pending()&&0===e._dirtyPos.size&&0===e._sentPos.size&&!e._devicePositionBusy,gesturesIdle:n,interactionPauseElapsed:Date.now()>=e._cyclePausedUntil,baseZoom:e._zoom<=1.001}}class $g{constructor(){this.seen=null,this.diagnosticsCache=null}observe(e,t,i,n){this.invalidateDiagnosticsForHass(e,t,i),this.intake(t,n)}intake(e,t){e&&this.seen!==e&&(this.seen=e,t())}invalidate(){this.diagnosticsCache=null}invalidateDiagnosticsForHass(e,t,i){this.diagnosticsCache&&(e?.entities!==t?.entities||e?.devices!==t?.devices||[...i?.entityIds||[]].some(i=>!!e?.states?.[i]!=!!t?.states?.[i]))&&this.invalidate()}diagnostics(e,t,i){if(this.diagnosticsCache)return this.diagnosticsCache;const n={active:0,ha_disabled:0,orphaned:0,unverified:0};for(const e of t)e.removed||"virtual"===e.binding||n[i(e.binding).kind]++;return this.diagnosticsCache={registry:ud(e),bindings:n},this.diagnosticsCache}}function Mg(e){const t=e;t._hassSequence++,t._renderSnapshotAt=Date.now(),t._continuity.note("hass-snapshot"),t._ensureHaRegistryAuthority(),t._planHassMemo=null,t._hookConnection(),!t._loadOk&&!t._loading&&t._loadTries<8&&t._loadFromServer(),t._maybeRebuildDevices(),t._vacTick(),t._activityTick()}function Rg(e){return!!e&&"object"==typeof e&&1===e.version}function Cg(e,t){const i=e.radar;return e.space===t&&!0!==e.hidden&&!0!==e.removed&&Rg(i)&&!0===i.enabled&&!1!==i.show_live}const Tg={ok:"radar.health_ok",off:"radar.health_off",stale:"radar.health_stale",partial:"radar.health_partial",restricted:"radar.health_restricted",incomplete:"radar.health_incomplete",position_unavailable:"radar.health_position_unavailable",unavailable:"radar.health_unavailable",needs_setup:"radar.health_needs_setup",inconsistent:"radar.health_inconsistent",unknown:"radar.health_unknown"};const Dg=e=>"number"==typeof e&&Number.isFinite(e);class Ag{constructor(e){this.host=e,this.frames=new Map,this.connection=null,this.space="",this.generation=0,this.expiryTimer=0,this.deadlines=new Map}sync(e,t){const i=this.host.hass?.connection;if(!t||!i||!this.host.isConnected)return void this.stop();if(this.unsubscribe&&this.connection===i&&this.space===e)return;this.stop(),this.connection=i,this.space=e;const n=++this.generation,r=i.subscribeMessage?.bind(i);"function"==typeof r&&Promise.resolve(r(e=>{if(n!==this.generation||!this.host.isConnected)return;const t=function(e){if(!e||"object"!=typeof e)return null;const t=e;if("string"!=typeof t.marker_id||"string"!=typeof t.server_session_id||!Number.isSafeInteger(t.seq)||"string"!=typeof t.health)return null;const i=Array.isArray(t.targets)?t.targets.slice(0,256).flatMap(e=>{if(!e||"object"!=typeof e)return[];const t=e;return"string"==typeof t.slot&&Dg(t.x)&&Dg(t.y)&&Dg(t.expires_at)&&Dg(t.reported_at)&&("bounded_latest"===t.pair_quality||"coherent"===t.pair_quality)?[{...t,included:!0===t.included,smooth:!0===t.smooth}]:[]}):[],n=Array.isArray(t.ranges)?t.ranges.slice(0,64).flatMap(e=>{if(!e||"object"!=typeof e)return[];const t=e;if(!("string"==typeof t.id&&Dg(t.x)&&Dg(t.y)&&Dg(t.radius)&&Dg(t.expires_at)&&Dg(t.reported_at)))return[];const i=Array.isArray(t.segments)?t.segments.slice(0,64).flatMap(e=>{if(!Array.isArray(e))return[];const t=e.slice(0,181).flatMap(e=>Array.isArray(e)&&2===e.length&&Dg(e[0])&&Dg(e[1])?[[e[0],e[1]]]:[]);return t.length>=2?[t]:[]}):void 0;return[{...t,...i?{segments:i}:{}}]}):[],r=Array.isArray(t.zones)?t.zones.slice(0,64).flatMap(e=>{if(!e||"object"!=typeof e)return[];const t=e;if("string"!=typeof t.id)return[];const i=t.state;if(null!==i&&"boolean"!=typeof i&&!Dg(i))return[];const n=Array.isArray(t.polygon)?t.polygon.slice(0,64).flatMap(e=>Array.isArray(e)&&2===e.length&&Dg(e[0])&&Dg(e[1])?[[e[0],e[1]]]:[]):[];return[{id:t.id,state:i,...n.length>=3?{polygon:n}:{}}]}):[];return{server_session_id:t.server_session_id,marker_id:t.marker_id,source_generation:"string"==typeof t.source_generation?t.source_generation:void 0,calibration_revision:"string"==typeof t.calibration_revision?t.calibration_revision:void 0,seq:t.seq,reported_at:Dg(t.reported_at)?t.reported_at:void 0,expires_at:Dg(t.expires_at)?t.expires_at:void 0,health:t.health,reported_presence:"boolean"==typeof t.reported_presence?t.reported_presence:null,complete:!0===t.complete,targets:i,ranges:n,zones:r}}(e);if(!t)return;if(!function(e,t){return!e||t.server_session_id!==e.server_session_id||t.source_generation!==e.source_generation||t.calibration_revision!==e.calibration_revision||t.seq>e.seq}(this.frames.get(t.marker_id),t))return;const i=function(e,t=Date.now()){if(!Dg(e.expires_at))return null;if(!Dg(e.reported_at))return Math.max(0,1e3*e.expires_at-t);const i=Math.max(0,1e3*(e.expires_at-e.reported_at)),n=Math.max(0,t-1e3*e.reported_at);return Math.max(0,i-n)}(t);"restricted"===t.health||"disabled"===t.health||0===i?(this.frames.delete(t.marker_id),this.deadlines.delete(t.marker_id)):(this.frames.set(t.marker_id,t),null==i?this.deadlines.delete(t.marker_id):this.deadlines.set(t.marker_id,this.monotonicNow()+i)),this.armExpiry(),this.host.requestUpdate()},{type:"houseplan/radar/subscribe",space_id:e})).then(e=>{n===this.generation&&this.host.isConnected?"function"==typeof e&&(this.unsubscribe=e):"function"==typeof e&&e()}).catch(()=>{n===this.generation&&this.stop()})}stop(){this.generation++,this.unsubscribe?.(),this.unsubscribe=void 0,this.connection=null,this.space="",clearTimeout(this.expiryTimer),this.expiryTimer=0,this.frames.size&&(this.frames.clear(),this.host.isConnected&&this.host.requestUpdate()),this.deadlines.clear()}armExpiry(){clearTimeout(this.expiryTimer);const e=this.monotonicNow(),t=[...this.deadlines.values()].filter(t=>t>e);if(!t.length)return;const i=Math.max(20,Math.min(...t)-e+10);this.expiryTimer=window.setTimeout(()=>{this.expiryTimer=0;let e=!1;const t=this.monotonicNow();for(const[i,n]of this.deadlines)n>t||(this.deadlines.delete(i),this.frames.delete(i),e=!0);this.armExpiry(),e&&this.host.isConnected&&this.host.requestUpdate()},i)}monotonicNow(){return globalThis.performance?.now?.()??Date.now()}}const Pg=Object.freeze({enabled:!1,z2mBaseTopics:Object.freeze([])});function Fg(e){if("string"!=typeof e)return null;const t=e.trim().replace(/^\/+|\/+$/g,"").replace(/\/{2,}/g,"/");return!t||t.length>180||/[#+\u0000-\u001f\u007f]/.test(t)?null:t}function zg(e){const t=e?.zigbee_topology;if(!t||"object"!=typeof t)return Pg;const i=t,n=Array.isArray(i.z2m_base_topics)?i.z2m_base_topics:Array.isArray(i.z2mBaseTopics)?i.z2mBaseTopics:[],r=new Set,o=[];for(const e of n){const t=Fg(e);if(t&&!r.has(t)&&(r.add(t),o.push(t),8===o.length))break}return{enabled:!0===i.enabled,z2mBaseTopics:o}}function Ig(e,t){const i={...e},n=t.z2mBaseTopics.map(Fg).filter(Boolean);return t.enabled||n.length?i.zigbee_topology={enabled:!0===t.enabled,z2m_base_topics:[...new Set(n)].slice(0,8)}:delete i.zigbee_topology,i}const Og={now:()=>performance.now(),requestFrame:e=>requestAnimationFrame(e),cancelFrame:e=>cancelAnimationFrame(e)},Eg=e=>Math.max(0,Math.min(1,e)),Ng=(e,t,i)=>e+(t-e)*i,Hg=(e,t,i)=>{const n=1-e;return 3*n*n*e*t+3*n*e*e*i+e*e*e},Lg=e=>{const t=Eg(e);if(0===t||1===t)return t;let i=0,n=1,r=t;for(let e=0;e<12;e++)r=(i+n)/2,Hg(r,.2,.2)0&&e.w>0?t/e.w:1,viewBox:{...e}}}function qg(e,t,i){const n=Math.max(1e-9,e.pixelsPerUnit),r=Math.max(1e-9,t/n),o=Math.max(1e-9,i/n);return{x:e.centerX-r/2,y:e.centerY-o/2,w:r,h:o}}function jg(e){const t=e.trim(),i=/^rgba?\(\s*([\d.]+)[, ]+([\d.]+)[, ]+([\d.]+)(?:\s*[,/]\s*([\d.]+))?\s*\)$/i.exec(t);if(i)return[Number(i[1]),Number(i[2]),Number(i[3]),null==i[4]?1:Number(i[4])];const n=/^#([0-9a-f]{6}|[0-9a-f]{8})$/i.exec(t)?.[1];return n?[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16),8===n.length?parseInt(n.slice(6,8),16)/255:1]:null}function Wg(e,t,i){const n=jg(e),r=jg(t);if(!n||!r)return i<.5?e:t;const o=Eg(i);return`rgba(${Math.round(Ng(n[0],r[0],o))}, ${Math.round(Ng(n[1],r[1],o))}, ${Math.round(Ng(n[2],r[2],o))}, ${Ng(n[3],r[3],o).toFixed(3)})`}class Ug{constructor(e,t=Og){this._hooks=e,this._clock=t,this._token=0,this._raf=0,this._state=null}get state(){return this._state}get active(){return"running"===this._state?.phase||"preparing"===this._state?.phase}get presented(){return this._state?.presented||null}start(e,t,i,n=220){this.cancel(!1);const r=++this._token,o=this._clock.now();if(this._state={token:r,phase:n<=0?"settling":"running",from:e,to:t,presented:n<=0?t:e,startedAt:o,duration:Math.max(0,n),targetMode:i},n<=0)return this._hooks.frame(this._state),this._hooks.settled(this._state),this._state=null,r;this._hooks.frame(this._state);const s=e=>{const t=this._state;if(!t||t.token!==r)return;const i=Eg((e-t.startedAt)/t.duration);t.presented=i>=1?t.to:function(e,t,i){const n=Lg(i),r=Ng(e.stageWidth,t.stageWidth,n),o=Ng(e.stageHeight,t.stageHeight,n),s=Math.max(1e-9,e.viewport.pixelsPerUnit),a=Math.max(1e-9,t.viewport.pixelsPerUnit),l={centerX:Ng(e.viewport.centerX,t.viewport.centerX,n),centerY:Ng(e.viewport.centerY,t.viewport.centerY,n),pixelsPerUnit:Math.exp(Ng(Math.log(s),Math.log(a),n))};return{presentedMode:n<.5?e.presentedMode:t.presentedMode,editorChromeHeight:Ng(e.editorChromeHeight,t.editorChromeHeight,n),stageWidth:r,stageHeight:o,viewport:{...l,viewBox:qg(l,r,o)},stageColor:Wg(e.stageColor,t.stageColor,n),paperColor:Wg(e.paperColor,t.paperColor,n),sceneBrightness:Ng(e.sceneBrightness,t.sceneBrightness,n),architectureOpacity:Ng(e.architectureOpacity,t.architectureOpacity,n),backdropOpacity:Ng(e.backdropOpacity,t.backdropOpacity,n),viewWeight:Ng(e.viewWeight,t.viewWeight,n),editorWeight:Ng(e.editorWeight,t.editorWeight,n),toolbarContentOpacity:Ng(e.toolbarContentOpacity,t.toolbarContentOpacity,n)}}(t.from,t.to,i),t.phase=i>=1?"settling":"running",this._hooks.frame(t),i<1?this._raf=this._clock.requestFrame(s):(this._raf=0,this._hooks.settled(t),this._state?.token===r&&(this._state=null))};return this._raf=this._clock.requestFrame(s),r}cancel(e=!0){this._raf&&this._clock.cancelFrame(this._raf),this._raf=0;const t=this._state;this._state=null,this._token++,t&&e&&(t.phase="settling",t.presented=t.to,this._hooks.frame(t),this._hooks.settled(t))}dispose(){this.cancel(!1)}}const Gg={now:()=>"undefined"!=typeof performance?performance.now():Date.now(),requestFrame:e=>"function"==typeof requestAnimationFrame?requestAnimationFrame(e):null,cancelFrame:e=>{"function"==typeof cancelAnimationFrame&&cancelAnimationFrame(e)}},Vg=e=>Number.isFinite(e);function Kg(e){return!!e&&Vg(e.zoom)&&e.zoom>0&&Vg(e.viewBox.x)&&Vg(e.viewBox.y)&&Vg(e.viewBox.w)&&e.viewBox.w>0&&Vg(e.viewBox.h)&&e.viewBox.h>0}function Yg(e){return{zoom:e.zoom,viewBox:{...e.viewBox}}}function Xg(e,t){return Math.abs(e.zoom-t.zoom)<1e-9&&Math.abs(e.viewBox.x-t.viewBox.x)<1e-6&&Math.abs(e.viewBox.y-t.viewBox.y)<1e-6&&Math.abs(e.viewBox.w-t.viewBox.w)<1e-6&&Math.abs(e.viewBox.h-t.viewBox.h)<1e-6}const Zg=(e,t,i)=>e+(t-e)*i,Jg=(e,t,i)=>Math.exp(Zg(Math.log(e),Math.log(t),i));class Qg{constructor(e,t=Gg){this._hooks=e,this._clock=t,this._token=0,this._raf=null,this._state=null}get state(){return this._state}get active(){return"running"===this._state?.phase}get presented(){return this._state?.presented||null}get target(){return this._state?.to||null}start(e,t,i,n){this.cancel(!1);const r=++this._token,o=Yg(e),s=Yg(t),a=n>0&&Kg(o)&&Kg(s),l=this._clock.now(),c={token:r,phase:a?"running":"settling",from:o,to:s,presented:Yg(a?o:s),startedAt:l,duration:a?n:0,reason:i};if(this._state=c,this._hooks.frame(c),!a)return this._settle(r),r;const h=e=>{const t=this._state;if(!t||t.token!==r)return;const i=Math.max(0,Math.min(1,(e-t.startedAt)/t.duration));if(t.presented=i>=1?Yg(t.to):function(e,t,i){if(!Kg(e))return Yg(t);if(!Kg(t))return Yg(e);const n=Lg(i);if(n<=0)return Yg(e);if(n>=1)return Yg(t);const r=e.viewBox.x+e.viewBox.w/2,o=e.viewBox.y+e.viewBox.h/2,s=t.viewBox.x+t.viewBox.w/2,a=t.viewBox.y+t.viewBox.h/2,l=Jg(e.viewBox.w,t.viewBox.w,n),c=Jg(e.viewBox.h,t.viewBox.h,n),h=Zg(r,s,n),d=Zg(o,a,n);return{zoom:Jg(e.zoom,t.zoom,n),viewBox:{x:h-l/2,y:d-c/2,w:l,h:c}}}(t.from,t.to,i),t.phase=i>=1?"settling":"running",this._hooks.frame(t),i>=1)return this._raf=null,void this._settle(r);this._raf=this._clock.requestFrame(h),null===this._raf&&this._settle(r)};return this._raf=this._clock.requestFrame(h),null===this._raf&&(c.phase="settling",c.presented=Yg(s),this._hooks.frame(c),this._settle(r)),r}cancel(e=!0){null!==this._raf&&this._clock.cancelFrame(this._raf),this._raf=null;const t=this._state;this._state=null,this._token++,t&&e&&(t.phase="settling",t.presented=Yg(t.to),this._hooks.frame(t),this._hooks.settled(t))}dispose(){this.cancel(!1)}_settle(e){const t=this._state;t&&t.token===e&&(t.phase="settling",t.presented=Yg(t.to),this._hooks.settled(t),this._state?.token===e&&(this._state=null))}}function ef(e,t,i){const n=e.querySelector("ha-card");if(!n)return null;const r=n.getBoundingClientRect(),o=t.getBoundingClientRect().top-r.top,s=i?0:Math.min(Math.max(r.top,0),120),a=Math.round(o+s);return a>=0?a:null}const tf=Object.freeze({rotDeg:0,tiltDeg:20,xyScale:1,zScale:1,origin:Object.freeze([500,500])}),nf=84,rf=10,of=4,sf=4;function af(e){return[e.rotDeg,e.tiltDeg,e.xyScale,e.zScale,e.origin[0],e.origin[1]].every(Number.isFinite)&&Math.abs(e.xyScale)>1e-12&&Math.abs(Math.cos(e.tiltDeg*Math.PI/180))>1e-12}function lf(e,t,i=tf){if(!Number.isFinite(e[0])||!Number.isFinite(e[1]))throw new Error("invalid isometric projection input");return function(e,t){if(!Number.isFinite(e[0])||!Number.isFinite(e[1])||!t.every(Number.isFinite))throw new Error("invalid isometric affine input");const[i,n,r,o,s,a]=t;return[i*e[0]+r*e[1]+s,n*e[0]+o*e[1]+a]}(e,hf(t,i))}function cf(e,t=tf){if(!af(t)||!Number.isFinite(e[0])||!Number.isFinite(e[1]))throw new Error("invalid isometric projection input");const i=t.rotDeg*Math.PI/180,n=t.tiltDeg*Math.PI/180,r=(e[0]-t.origin[0])/t.xyScale,o=(e[1]-t.origin[1])/(t.xyScale*Math.cos(n));return[t.origin[0]+r*Math.cos(i)+o*Math.sin(i),t.origin[1]-r*Math.sin(i)+o*Math.cos(i)]}function hf(e=0,t=tf){if(!af(t)||!Number.isFinite(e))throw new Error("invalid isometric camera");const i=t.rotDeg*Math.PI/180,n=t.tiltDeg*Math.PI/180,r=t.xyScale*Math.cos(i),o=-t.xyScale*Math.sin(i),s=t.xyScale*Math.sin(i)*Math.cos(n),a=t.xyScale*Math.cos(i)*Math.cos(n);return[r,s,o,a,t.origin[0]-r*t.origin[0]-o*t.origin[1],t.origin[1]-s*t.origin[0]-a*t.origin[1]-e*t.zScale*Math.sin(n)]}function df(e=tf){return function(e=0,t=tf){return`matrix(${hf(e,t).map(e=>Number(e.toFixed(12))).join(" ")})`}(0,e)}function uf(e,t=tf){const{rect:i,wallHeight:n}=e,r=e.openingHeight??n,o=e.floorDepth??0,s=e.raisedHeight??n;if(!(i.w>=0)||!(i.h>=0)||!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(o)||!Number.isFinite(s)||n<0||r<0||o<0||s<0)throw new Error("invalid isometric frame");const a=[[i.x,i.y],[i.x+i.w,i.y],[i.x+i.w,i.y+i.h],[i.x,i.y+i.h]],l=Math.max(n,r,s),c=a.flatMap(e=>[lf(e,-o,t),lf(e,l,t)]),h=c.map(e=>e[0]),d=c.map(e=>e[1]),u=Math.min(...h),p=Math.min(...d);return{x:u,y:p,w:Math.max(...h)-u,h:Math.max(...d)-p}}const pf=[".dev",".vacpuck",".oplock",".op-hit",".opening",".rlgo","a","button","input","select","textarea",'[contenteditable]:not([contenteditable="false"])',"[data-room-fit-block]",'[role="link"]','[role="button"]'].join(","),_f=(e,t)=>{try{return"function"==typeof e?.matches&&e.matches(t)}catch{return!1}};function mf(e){for(const t of e){const e=t;if(_f(e,".roomlabel[data-id]")){const t=e.getAttribute?.("data-id");return t?{kind:"room",roomId:t}:{kind:"interactive"}}if(_f(e,pf))return{kind:"interactive"};if(_f(e,'[data-hp="room"][data-id]')){const t=e.getAttribute?.("data-id");return t?{kind:"room",roomId:t}:{kind:"interactive"}}if(_f(e,".stage"))return{kind:"background"}}return{kind:"outside"}}function gf(e){const t=mf(e);return"room"===t.kind?t.roomId:null}class ff{constructor(){this.pointer=null,this.sequence=null}clear(){this.pointer=null,this.sequence=null}clearOutside(e){let t={kind:"outside"};try{t=mf(e.composedPath())}catch{}"outside"===t.kind&&this.clear()}pointerDown(e,t,i){let n={kind:"outside"};try{n=mf(e.composedPath())}catch{}this.pointer=function(e){const t="mouse"===(i=e.pointerType)||"touch"===i||"pen"===i?i:null;var i;return t&&"view"===e.mode&&"background"===e.owner.kind&&!e.blocked&&e.isPrimary&&0===e.button&&Number.isFinite(e.x)&&Number.isFinite(e.y)?{pointerId:e.pointerId,spaceId:e.spaceId,modality:t,x:e.x,y:e.y}:null}({pointerId:e.pointerId,pointerType:e.pointerType,isPrimary:e.isPrimary,button:e.button,spaceId:t,mode:i?"view":"blocked",owner:n,blocked:!i,x:e.clientX,y:e.clientY}),this.pointer||(this.sequence=null)}pointerUp(e,t,i,n,r=Date.now()){let o={kind:"outside"};try{o=mf(e.composedPath())}catch{}const s=function(e,t,i){if(!t||"view"!==i.mode||"background"!==i.owner.kind||i.blocked||t.pointerId!==i.pointerId||t.spaceId!==i.spaceId||!Number.isFinite(i.x)||!Number.isFinite(i.y)||!Number.isFinite(i.now)||Math.abs(i.x-t.x)+Math.abs(i.y-t.y)>=8)return{sequence:null,trigger:!1};const n=e?i.now-e.at:Number.POSITIVE_INFINITY;return e&&e.spaceId===i.spaceId&&e.modality===t.modality&&n>=0&&n<=350?{sequence:null,trigger:!0}:{sequence:{at:i.now,spaceId:i.spaceId,modality:t.modality},trigger:!1}}(this.sequence,this.pointer,{pointerId:e.pointerId,spaceId:t,mode:i?"view":"blocked",owner:o,blocked:n||!i,x:e.clientX,y:e.clientY,now:r});return this.pointer=null,this.sequence=s.sequence,s.trigger}}const vf=e=>e.length>=2&&Number.isFinite(e[0])&&Number.isFinite(e[1]);function yf(e){return!!e&&Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.w)&&e.w>0&&Number.isFinite(e.h)&&e.h>0}function bf(e,t=0){if(!e.length||!Number.isFinite(t)||t<0||!e.every(vf))return null;let i=1/0,n=1/0,r=-1/0,o=-1/0;for(const t of e)i=Math.min(i,t[0]),n=Math.min(n,t[1]),r=Math.max(r,t[0]),o=Math.max(o,t[1]);const s=r-i,a=o-n;return s>0&&a>0?{x:i-t,y:n-t,w:s+2*t,h:a+2*t}:null}function wf(e,t,i){const n="string"!=typeof t||"invalid"!==t&&"no-borders"!==t&&"unverified"!==t&&!/^[a-z0-9]{1,8}$/i.test(t)?"redacted":t;return Object.freeze({kind:e,fingerprint:n,terminal:!!i})}function kf(e,t){return`${e("editor.load_failed")} ${e(t.terminal?"editor.refresh_advice":"editor.retry_advice")}`}class xf extends Error{}class Sf{constructor(e){this.options=e,this._state="idle",this._inFlight=null}get state(){return this._state}ensure(){return"ready"===this._state?Promise.resolve(!0):"failed"===this._state?Promise.resolve(!1):(this._inFlight||(this._setState("loading"),this._inFlight=this._loadWithRetry().finally(()=>{this._inFlight=null})),this._inFlight)}async _loadWithRetry(){let e=new Error("Editor runtime did not load"),t=!1;for(const i of[0,1])try{const e=await this.options.load(i);if(e.fingerprint!==this.options.expectedFingerprint)throw new xf(`Editor runtime fingerprint mismatch: expected ${this.options.expectedFingerprint}, got ${e.fingerprint}`);const t=e.create();return this.options.install(t),this._setState("ready"),!0}catch(i){e=i,i instanceof xf&&(t=!0)}return this._setState(t?"failed":"idle"),this.options.failed?.(e,{terminal:t}),!1}_setState(e){e!==this._state&&(this._state=e,this.options.stateChanged?.(e))}}const $f=(e,t)=>{if(!e.has(t))return{hit:!1};const i=e.get(t);return e.delete(t),e.set(t,i),{hit:!0,value:i}},Mf=(e,t,i,n)=>{for(e.delete(t),e.set(t,i);e.size>n;){const t=e.keys().next().value;if(void 0===t)break;e.delete(t)}},Rf=new Set(["select","draw","column","merge","split","resize","opening","wallthick","delroom"]),Cf=e=>`${window.innerWidth}x${window.innerHeight}|${location.pathname}|${JSON.stringify(e??{})}`,Tf="houseplan_card_alpha_v1",Df=Object.freeze([Object.freeze({id:"iso",issue:89,summary:"Volumetric plan renderer"})]);function Af(e){return/^[a-z][a-z0-9-]*$/.test(e.id)&&Number.isInteger(e.issue)&&e.issue>0&&!!e.summary.trim()}function Pf(e){const t=String(e||"").replace(/^#/,"");return new URLSearchParams(t)}function Ff(e){return Pf(e).get("space")||""}function zf(e,t,i=Df){const n=function(e){const t=new Set;for(const i of e){if(!Af(i)||t.has(i.id))return!1;t.add(i.id)}return!0}(i),r=function(e){let t,i=!1;const n=e=>{for(const n of e.getAll("hp_alpha"))i=!0,"1"===n?t=!0:"0"===n&&(t=!1)};return n(new URLSearchParams(String(e.search||"").replace(/^\?/,""))),n(Pf(e.hash)),{present:i,value:t}}(e),o=void 0!==r.value,s="1"===t,a=o?!0===r.value:!r.present&&s,l=n&&a;return{alpha:l,active:Object.freeze(l?i.map(e=>e.id).sort():[]),space:Ff(e.hash),persist:n&&o?l?"1":"0":void 0,knownUrlOperation:o}}let If={alpha:!1,active:Object.freeze([]),space:""},Of=!1,Ef="";const Nf=new Set;function Hf(){if("undefined"==typeof window)return If;const e=zf(window.location,function(){try{return window.localStorage.getItem(Tf)}catch{return null}}());void 0!==e.persist&&function(e){try{window.localStorage.setItem(Tf,e)}catch{}}(e.persist),If={alpha:e.alpha,active:e.active,space:e.space},window.__hpAlpha=e.alpha,window.__hpLabs=e.active;for(const e of Nf)e(If);return If}function Lf(){Hf()}function Bf(){if("undefined"==typeof window)return If;if(!Of){Of=!0,window.__hpLabsListenerCleanup?.(),window.addEventListener("hashchange",Lf),window.addEventListener("popstate",Lf);const e=()=>{window.removeEventListener("hashchange",Lf),window.removeEventListener("popstate",Lf),window.__hpLabsListenerCleanup===e&&delete window.__hpLabsListenerCleanup};window.__hpLabsListenerCleanup=e}return Hf()}const qf={window:120,door:90,passage:90,gate:300};function jf(e){return qf[e]}function Wf(e,t){return{type:e,lengthCm:jf(e),flipH:!1,flipV:!1,revision:t}}function Uf(e,t){const i=Math.max(0,e.renderedLength)/2,n=Math.max(0,e.target.physicalHalfWidth),r=n+.18*Math.max(0,t),o=e=>({x1:e,y1:-r,x2:e,y2:r});return{rect:{x:-i,y:n?-n:0,width:2*i,height:2*n},boundaries:[o(-i),o(i)]}}function Gf(e,t){const i=[e[0],e[1]],n=[t[0],t[1]];return function(e,t){return e[0]-t[0]||e[1]-t[1]}(i,n)<=0?{a:i,b:n}:{a:n,b:i}}function Vf(e){const t=new Map;return e.forEach((e,i)=>{if(!e.kind||e.open)return;const n=Gf(e.a,e.b);if(Math.hypot(n.b[0]-n.a[0],n.b[1]-n.a[1])<=1e-9)return;const r=function(e,t){const i=e=>(Math.abs(e)<=5e-10?0:Math.round(1e6*e)/1e6).toFixed(6);return`${i(e[0])},${i(e[1])}>${i(t[0])},${i(t[1])}`}(n.a,n.b),o=t.get(r);if(o)return o.physicalHalfWidth=Math.max(o.physicalHalfWidth,e.half||0),o.sourceOrder=Math.min(o.sourceOrder,i),void(e.partitionHost&&(o.partitionHost&&o.partitionHost.id!==e.partitionHost.id?o.ambiguousPartitionHost=!0:o.partitionHost=e.partitionHost));t.set(r,{segmentKey:r,a:n.a,b:n.b,physicalHalfWidth:Math.max(0,e.half||0),sourceOrder:i,...e.partitionHost?{partitionHost:e.partitionHost}:{}})}),[...t.values()]}function Kf(e,t){if(Math.abs(e.distance-t.distance)>1e-9)return e.distance-t.distance;if(Math.abs(e.perpendicular-t.perpendicular)>1e-9)return e.perpendicular-t.perpendicular;return(e.target.segmentKeyt.target.segmentKey?1:0)||e.target.sourceOrder-t.target.sourceOrder}function Yf(e){const t=Vf(e.intervals).map(t=>{const i=function(e,t){const i=t.b[0]-t.a[0],n=t.b[1]-t.a[1],r=Math.hypot(i,n),o=i/r,s=n/r,a=(e[0]-t.a[0])*o+(e[1]-t.a[1])*s,l=Math.max(0,Math.min(r,a)),c=t.a[0]+l*o,h=t.a[1]+l*s;return{along:l,length:r,x:c,y:h,distance:Math.hypot(e[0]-c,e[1]-h),perpendicular:Math.abs((e[0]-t.a[0])*s-(e[1]-t.a[1])*o)}}(e.pointer,t);return{target:t,...i,envelope:Math.max(e.baseTolerance,t.physicalHalfWidth+e.bodyPointerPadding)}}).filter(e=>e.distance<=e.envelope+1e-9).filter(t=>!function(e,t,i,n,r){const o=t.b[0]-t.a[0],s=t.b[1]-t.a[1],a=Math.hypot(o,s);if(!(a>1e-9))return!1;const l=o/a,c=s/a;for(const o of i){if(!o.open&&o.kind)continue;const i=Gf(o.a,o.b),s=i.b[0]-i.a[0],a=i.b[1]-i.a[1],h=Math.hypot(s,a);if(!(h>1e-9))continue;const d=s/h,u=a/h;if(Math.abs(l*u-c*d)>1e-6)continue;if(Math.abs((i.a[0]-t.a[0])*c-(i.a[1]-t.a[1])*l)>r)continue;const p=(e[0]-i.a[0])*d+(e[1]-i.a[1])*u,_=1e-9;if(!(p<=_||p>=h-_)&&Math.abs((e[0]-i.a[0])*u-(e[1]-i.a[1])*d)<=n+1e-9)return!0}return!1}(e.pointer,t.target,e.intervals,t.envelope,Math.max(1e-9,Math.min(e.baseTolerance,.04*e.gridStep)))),i=t.filter(t=>!!t.target.partitionHost&&e.renderedLength+2*t.target.physicalHalfWidth>t.length+1e-9).sort(Kf),n=t.filter(t=>!t.target.partitionHost||e.renderedLength+2*t.target.physicalHalfWidth<=t.length+1e-9).sort(Kf);let r=n[0];if(!r)return{candidate:null,jambBlockedTarget:i[0]?.target||null};const o=n.filter(e=>Math.abs(e.distance-r.distance)<=1e-9&&Math.abs(e.perpendicular-r.perpendicular)<=1e-9),s=o.filter(e=>e.target.partitionHost);if(s.length){if(1!==new Set(s.map(e=>e.target.partitionHost.id)).size||s.some(e=>e.target.ambiguousPartitionHost))return{candidate:null,jambBlockedTarget:null};const e=s[0],t=e.target.b[0]-e.target.a[0],i=e.target.b[1]-e.target.a[1],n=Math.hypot(t,i),a=t/n,l=i/n;if(!o.every(t=>{const i=t.target.b[0]-t.target.a[0],n=t.target.b[1]-t.target.a[1],r=Math.hypot(i,n),o=i/r,s=n/r,c=Math.abs(a*s-l*o)<=1e-6,h=Math.abs((t.target.a[0]-e.target.a[0])*l-(t.target.a[1]-e.target.a[1])*a);return c&&h<=1e-9}))return{candidate:null,jambBlockedTarget:null};r=e}if(r.target.ambiguousPartitionHost)return{candidate:null,jambBlockedTarget:null};const{target:a,length:l}=r,c=a.b[0]-a.a[0],h=a.b[1]-a.a[1],d=c/l,u=h/l,p=a.partitionHost?a.physicalHalfWidth:0,_=Math.min(Math.max(0,e.renderedLength)/2+p,l/2);let m=r.along;const g=Math.max(e.gridStep,1e-9),f=l/2;m=Math.abs(m-f)<=g/2?f:Math.round(m/g)*g,m=Math.max(_,Math.min(l-_,m));const v=a.a[0]+d*m,y=a.a[1]+u*m,b=Math.max(0,e.renderedLength)/2,w=m-b,k=m+b,x=Math.max(0,w),S=Math.max(0,l-k),$=[a.a[0]+d*(w-x/2),a.a[1]+u*(w-x/2)],M=[a.a[0]+d*(k+S/2),a.a[1]+u*(k+S/2)];let R=180*Math.atan2(h,c)/Math.PI;R>=90?R-=180:R<-90&&(R+=180);const C=Math.abs(m-f)<=1e-9;return{candidate:{presetRevision:e.preset.revision,geometryRevision:e.geometryRevision,pointer:[e.pointer[0],e.pointer[1]],type:e.preset.type,lengthCm:e.preset.lengthCm,flipH:e.preset.flipH,flipV:e.preset.flipV,x:v,y:y,angle:R,renderedLength:e.renderedLength,target:a,...a.partitionHost?{host:{...a.partitionHost,t:l>0?m/l:0}}:{},measure:{labels:[{distance:x,midpoint:$},{distance:S,midpoint:M}],guide:C?{x:v,y:y,angle:R}:null}},jambBlockedTarget:null}}function Xf(e,t,i,n,r=1e-6){return e.presetRevision===i&&e.geometryRevision===n&&Math.hypot(e.pointer[0]-t[0],e.pointer[1]-t[1])<=r}function Zf(e){return!(!e.canEdit||e.kiosk||e.fixedFloor)&&("view"!==e.mode&&("mouse"===e.pointerType&&e.spaceCount>1))}class Jf{constructor(e,t,i){this.loader=e,this.host=t,this.adopted=i,this.attachment=null}connect(){if(this.runtime)return void this.runtime.connect();this.attachment?.cancel();const e=this.loader.attach(this.host,e=>this.adopt(e));this.runtime||(this.attachment=e)}disconnect(){this.attachment?.cancel(),this.attachment=null,this.runtime?.disconnect()}adopt(e){this.attachment=null,this.runtime||(this.runtime=e,this.adopted(e))}}const Qf=new class{constructor(e){this.load=e,this.factory=null,this.pending=null}get warm(){return null!==this.factory}create(e){return this.factory?this.factory(e):null}attach(e,t){let i=!0;const n={cancel:()=>{i=!1}},r=this.create(e);return r?(t(r),n):(this.ensure().then(n=>{i&&t(n(e))},()=>{}),n)}ensure(){return this.factory?Promise.resolve(this.factory):(this.pending||(this.pending=this.load().then(e=>(this.factory=e,this.pending=null,e),e=>{throw this.pending=null,e})),this.pending)}reset(){this.factory=null,this.pending=null}}(()=>import("./summary-panel-runtime-loaded-C3VkX0bk.js").then(function(e){return e.e}).then(({LoadedSummaryPanelRuntime:e})=>t=>new e(t)));function ev(e){const t=globalThis.__HP_VERSION_OVERRIDE__;return"string"==typeof t&&t.length>0?t:e}let tv=0;const iv="1.77.0-beta.1",nv="d31b0b1e184ab2863684b758f839bdb6809a33cc742c6e9bb36c5ea034e3d309",rv=1500,ov=new Map;let sv=0,av=1e4;const lv="houseplan_card_layout_v1",cv="houseplan_card_cfg_v1",hv="houseplan_card_zoom_v1",dv="houseplan_card_nav_v1",uv="houseplan_card_view_v1",pv="hp-dialog, hp-help, hp-color-opacity, hp-device-preview",_v=1e3,mv=(e,t)=>{const i=Math.min(e.x,t.x),n=Math.min(e.y,t.y);return{x:i,y:n,w:Math.max(e.x+e.w,t.x+t.w)-i,h:Math.max(e.y+e.h,t.y+t.h)-n}},gv=(e,t,i)=>{const n=new Event(t,{bubbles:!0,composed:!0});n.detail=i??{},e.dispatchEvent(n)},fv=e=>{history.pushState(null,"",e),gv(window,"location-changed",{replace:!1})},vv=(e,t)=>{let i,n=null;const r=(...r)=>{clearTimeout(i),n=r,i=window.setTimeout(()=>{i=void 0;const t=n;n=null,t&&e(...t)},t)};return r.flush=()=>{if(void 0===i)return;clearTimeout(i),i=void 0;const t=n;n=null,t&&e(...t)},r.cancel=()=>{clearTimeout(i),i=void 0,n=null},r.pending=()=>void 0!==i,r},yv=e=>{try{e.target?.setPointerCapture?.(e.pointerId)}catch{}},bv=["edges","corners"];class wv extends he{constructor(){var e;super(...arguments),this._editorRuntime=null,this._liveRt=null,this._onboardingRuntime=null,this._editorRuntimeLoadingVisible=!1,this._backdropGuard=null,this._editorModeRequest=0,this._warmModeRequest=0,this._editorRuntimeLoader=new Sf({expectedFingerprint:nv,load:async e=>{const t=0===e?await import("./houseplan-editor-runtime-DOSm4OKX.js"):await import((()=>{const e=new URL("./houseplan-editor-runtime-DOSm4OKX.js",import.meta.url);return e.searchParams.set("hp_retry",`${iv}-${++tv}`),e.href})());return{fingerprint:t.EDITOR_RUNTIME_FINGERPRINT,create:()=>new t.HouseplanEditorRuntime(this)}},install:e=>{this._editorRuntime=e},stateChanged:e=>this._editorRuntimeStateChanged(e),failed:(e,t)=>{console.error("[houseplan] unable to load editor runtime",e),t.terminal&&this._versionRecovery.hasCurrentMismatchNotice||this._showToast(kf(e=>this._t(e),t))}}),this._onboardingRuntimeLoader=new Sf({expectedFingerprint:nv,load:async e=>{const t=0===e?await import("./houseplan-onboarding-runtime-G7DfDSe_.js"):await import((()=>{const e=new URL("./houseplan-onboarding-runtime-G7DfDSe_.js",import.meta.url);return e.searchParams.set("hp_retry",`${iv}-${++tv}`),e.href})());return{fingerprint:t.ONBOARDING_RUNTIME_FINGERPRINT,create:()=>new t.HouseplanOnboardingRuntime(this)}},install:e=>{this._onboardingRuntime=e},failed:(e,t)=>{console.error("[houseplan] unable to load onboarding runtime",e),t.terminal&&this._versionRecovery.hasCurrentMismatchNotice||this._showToast(kf(e=>this._t(e),t))}}),this._isoSceneRuntime=null,this._isoSceneRuntimeLoader=new Sf({expectedFingerprint:nv,load:async e=>{const t=0===e?await import("./iso-scene-render-CCwC6ZHk.js"):await import((()=>{const e=new URL("./iso-scene-render-CCwC6ZHk.js",import.meta.url);return e.searchParams.set("hp_retry",`${iv}-${++tv}`),e.href})());return{fingerprint:t.ISO_SCENE_RUNTIME_FINGERPRINT,create:()=>t}},install:e=>{const t=this._effectiveProjection();this._isoSceneRuntime=e,this._isoProjectionSnapshot=null;const i=this._effectiveProjection();this._convertProjectionView(t,i),this.isConnected&&this.requestUpdate()},failed:(e,t)=>{console.warn("[houseplan] hidden isometric runtime diagnostic",wf("runtime-load","unverified",t.terminal)),this.isConnected&&this.requestUpdate()}}),this._pdfRuntime=null,this._pdfRuntimeLoader=new Sf({expectedFingerprint:nv,load:async e=>{const t=0===e?await import("./pdf-export-B1B1amDF.js"):await import((()=>{const e=new URL("./pdf-export-B1B1amDF.js",import.meta.url);return e.searchParams.set("hp_retry",`${iv}-${++tv}`),e.href})());return{fingerprint:t.PDF_EXPORT_FINGERPRINT,create:()=>new t.PdfExportRuntime}},install:e=>{this._pdfRuntime=e,this.isConnected&&this.requestUpdate()},failed:(e,t)=>{if(console.error("[houseplan] unable to load PDF export runtime",e),!t.terminal||!this._versionRecovery.hasCurrentMismatchNotice){const e=kf(e=>this._t(e),t),i=this._t("editor.load_failed"),n=e.startsWith(i)?e.slice(i.length).trim():e;this._showToast(`${this._t("pdf.failed")} ${n}`.trim())}}}),this.panelHost=!1,this.narrow=null,this._space="f1",this._adoption=new qu((e,t)=>this.requestUpdate(e,t)),this._serverStorage=!1,this._loadOk=!1,this._serverCanWrite=null,this._loading=!1,this._loadTries=0,this._unsubCfg=null,this._unsubLayout=null,this._unsubVirtual=null,this._liveSyncAttempt=null,this._liveSyncGeneration=0,this._liveSyncConnection=null,this._configReloadAuthority=new Gu,this._virtualLights=Hh(null),this._canOptimizeUndo=!1,this._undoKind=null,this._devices=[],this._regSignature="",this._defPos={},this._newSyncKey="",this._areaRelocationIds=new Set,this._areaSnapshotCleanupCandidates=new Map,this._areaRelocationSyncKey="",this._areaRelocationWrite=Promise.resolve(),this._tip=null,this._hoverRoom=null,this._pointerModality=new sg(this,()=>this._syncPointerHoverTargets()),this._devicePressAnimations=new Map,this._selId=null,this._toast="",this._mode="view",this._pendingNavMode=null,this._decorTool="select",this._decorStyle={...Cr},this._decorStyleSeeded=!1,this._decorDraft=null,this._decorMove=null,this._decorSel=null,this._decorEraseConfirm=null,this._decorTextDialog=null,this._decorShapeDialog=null,this._backdropDialog=null,this._decorTextSelection={start:0,end:0},this._furnPalette=null,this._decorImagePalette=null,this._decorAssetCatalog=[],this._decorAssets=new Map,this._decorAssetBusy=!1,this._furnCategory=null,this._furnPreviewInput=null,this._furnTouchPending=null,this._dtBox=null,this._dtDrag=null,this._bdDrag=null,this._slide="",this._reducedMotion=!1,this._onMotionChange=e=>{this._reducedMotion=e.matches,this._cancelDevicePressFeedback(),e.matches&&this._cancelCameraTransition(!0),e.matches&&this._modeTransitionPreparing?this._modeTransitionForceAtomic=!0:e.matches&&this._modeTransition.active&&this._cancelModeTransition(!0),this._syncVersionRecovery(),this.requestUpdate()},this._editorChromeMode="plan",this._modeTransitionVisual=null,this._modeTransitionPreparing=!1,this._modeTransitionForceAtomic=!1,this._modeTransitionRequest=0,this._modeTransitionTargetZoom=1,this._modeTransitionEditorCamera=null,this._modeTransition=new Ug({frame:e=>this._applyModeTransitionFrame(e),settled:e=>this._settleModeTransition(e)}),this._cameraTransitionFit=null,this._cameraTransition=new Qg({frame:e=>this._applyCameraTransitionFrame(e),settled:e=>this._settleCameraTransition(e)}),this._editorSecondaryCopy={groupActive:(e,t)=>this._t("editor.group_active",{group:e,item:t}),openGroup:e=>this._t("editor.open_group",{group:e}),disabledAction:(e,t)=>this._t("editor.disabled_action",{action:e,reason:t})},this._tool="draw",this._geometryHistory=new gg(50),this._devicePositionHistory=new gg(50),this._devicePositionBusy=!1,this._wallDialog=null,this._drawWallField=null,this._activeWallChainId=null,this._activeWallChainPartitionIds=[],this._wallChainRedo=[],this._physicalSel=null,this._physicalDialog=null,this._partitionDeleteDialog=null,this._roomDeleteDialog=null,this._physicalDrag=null,this._physicalRotate=null,this._physicalLastTap=null,this._physicalPickCycle=null,this._wallUnionCacheValue=null,this._wallUnionPool=new Map,this._isoGeometryCache=new Map,this._renderIsoScene=null,this._isoProjectionSnapshot=null,this._isoStructuralBuildCount=0,this._isoFallback=new Set,this._openingTunnelCache=null,this._openingWallIndexCache=new Map,this._openingPlacementIntervalsCache=null,this._openingDimensionContextCache=null,this._planSnapGeometryCache=null,this._planStructuralGeometryCache=null,this._hiddenWallDiagnosticCache=null,this._physicalBodiesCache=null,this._lightPhysicalBodiesCache=null,this._cleanFloorCache=new Map,this._innerContourCache=new Map,this._glowRuntimeState=bm(),this._glowRuntimeHost={window:()=>this.ownerDocument.defaultView||window,isConnected:()=>this.isConnected,requestUpdate:()=>this.requestUpdate(),reducedMotion:()=>this._reducedMotion},this._lightBarrierCache=null,this._lightBarrierPool=new Map,this._glowScreenBlend=!1,this._duplicateColumnId=null,this._duplicateColumnTimer=0,this._rszLimitViolation=null,this._path=[],this._cursorPt=null,this._planSnapHover=null,this._mergeSel=null,this._openingPreset=null,this._openingRebindId=null,this._openingPresetRevision=0,this._openingHoverCandidate=null,this._openingJambBlockCm=null,this._openingDialog=null,this._openingInfo=null,this._opDrag=null,this._opMeasure=null,this._mergeDialog=null,this._splitSel=null,this._pendingSplit=null,this._wallFaceBatch=null,this._wallRepairDiagnostic=null,this._wallFaceGraphCache=[],this._areaSel="",this._nameSel="",this._roomDialog=!1,this._roomEditId=null,this._roomFill="",this._roomCustomFill=null,this._roomTempMin="",this._roomTempMax="",this._roomTempSrc="",this._roomHumSrc="",this._roomSrcOpen=null,this._roomSrcFilter="",this._roomNameScale=1,this._roomLabelScale=1,this._zoom=1,this._view=null,this._zoomBySpace={},this._viewModeSnap=null,this._roomFocus=null,this._roomPointer=null,this._doubleFit=new ff,this._deviceHits=new wc,this._pointers=new Map,this._panStart=null,this._panLock=null,this._pinchStart=null,this._safeDayCycleOutline=!1,this._suppressClick=!1,this._viewportGestureDirty=!1,this._touchContacts=new Map,this._touchClickGuard=new pc,this._connectedPath="",this._routeDepartureHandled=!1,this._onLocationChanged=()=>{this._connectedPath&&location.pathname!==this._connectedPath?this._leaveCardRoute():location.pathname===this._connectedPath&&(this._routeDepartureHandled=!1)},this._touchGestureGuard={capture:!0,handleEvent:e=>this._guardTouchGesture(e)},this._hdrH=118,this._booting=!0,this._bootFading=!1,this._bootSettling=!1,this._bootSettleRaf=0,this._bootLastH=-1,this._bootStart=0,this._bootLastChange=0,this._bootSoft=!1,this._tapConfirm=null,this._dangerConfirm=null,this._dangerConfirmController=new ze(e=>{this._dangerConfirm=e}),this._confirmDanger=e=>this._config&&this.hass?"warm"===this._syncDangerConfirmLocaleGate()||this._dangerConfirmMissingSpace()?Promise.resolve(!1):this._dangerConfirmController.confirm(e):Promise.resolve(!1),this._cancelDangerConfirm=()=>{this._dangerConfirmController.cancel()},this._onDangerConfirmDecision=e=>{this._dangerConfirmController.resolve(e.detail.token,e.detail.accepted)},this._onboardingShown=!1,this._rulesDialog=null,this._preflightClipboardFallback=null,this._haIntegrationVersion=null,this._versionRecovery=(e=this,new wg({clock:{setTimeout:(e,t)=>window.setTimeout(e,t),clearTimeout:e=>window.clearTimeout(e)},storage:()=>e.ownerDocument.defaultView?.sessionStorage??null,safety:()=>Sg(e),reload:()=>e._reloadDocument(),changed:()=>{e.requestUpdate()}})),this._haSupportApi=null,this._haDecorAssetsApi=null,this._haSummaryPanelApi=null,this._haRadarStage1Api=null,this._radarLive=new Ag(this),this._decorAssetSyncToken=0,this._alignDialog=null,this._settingsDialog=null,this._pdfDialog=!1,this._supportDialog=null,this._backupExportDialog=null,this._backupImportDialog=null,this._sunRaysCache=null,this._dayCycleTimer=0,this._dayCycleClockKey="",this._compassDrag=!1,this._importDialog=null,this._importQueue=[],this._importTotal=0,this._rulesCompiledSrc="",this._infoCard=null,this._nativeMoreInfoEntity=null,this._deviceInbox=null,this._deviceInboxReturn=null,this._deviceInboxMemo=null,this._markerDialog=null,this._spaceDialog=null,this._keyHandler=e=>this._onKey(e),this._warmVp=null,this._warmVpArmed=!1,this._warmLongReturn=!1,this._warmRevivePending=!1,this._warmGen=++sv,this._warmKey=null,this._warmSlot=null,this._hashApplied=!1,this._navApplied=!1,this._labs={alpha:!1,active:Object.freeze([]),space:""},this._viewPreference={},this._renderProjection="flat",this._kioskScale={icon:1,font:1},this._kioskDialog=!1,this._summarySlot=new Jf(Qf,this,e=>{this._summary=e,this._capturedSnapshotSequence=-1,this.isConnected&&(e.connect(),this.hasUpdated&&this.requestUpdate())}),this._activityRt=new Map,this._vacRt=new Map,this._vacViewKey="",this._vacLastView=null,this._vacRaf=0,this._vacSrvTrails={},this._vacJumpOnce=!1,this._continuity=this._newContinuityController(),this._continuityHistory=[],this._continuityEpoch=0,this._continuityDataReady=!0,this._continuityPaintToken=-1,this._continuityDisposed=!1,this._renderSnapshotAt=Date.now(),this._hassSequence=0,this._visibleDeviceSnapshot=null,this._candidateDeviceSnapshot=null,this._stagedDeviceSnapshotToken=-1,this._capturedSnapshotSequence=-1,this._capturedSnapshotDevices=null,this._capturedSnapshotLayout=null,this._capturedSnapshotActivity="",this._capturedSnapshotConfigEpoch=-1,this._capturedSnapshotVirtual="",this._lastValidStageSize=null,this._pendingRefitSize=null,this._refitRaf=0,this._pageVisibility=e=>{if(this._continuity.visibility(e),this._dayCycleVisibility(e),this._summary?.visibility(e.kind),"hidden"===e.kind)return this._radarLive.stop(),this._editorRuntime?._cancelRadarSetup(),this._clearRoomFocus(!0),this._clearTransientHover(!0),this._cancelDevicePressFeedback(),this._cancelCameraTransition(!0),void(this._modeTransitionPreparing?this._modeTransitionForceAtomic=!0:this._cancelModeTransition(!0));if(this._vacJumpOnce=!0,this._syncRadarLive(),!e.long){const e=Date.now();let t=!1;for(const i of this._activityRt.values())!i.flashKind||(i.expiresAt||i.flashTs+tg)>e||(i.flashTs=0,i.flashKind=null,i.expiresAt=0,t=!0);return void(t&&this.requestUpdate())}Date.now()-this._renderSnapshotAt>1e3&&this._continuity.note("device-snapshot-stale"),this._continuityDataReady=!1,this._continuityPaintToken=-1,this._resumeSettling=!0,this._loading?this.requestUpdate():this._loadFromServer()},this._resumeSettling=!1,this._viewportInvalidAt=0,this._vacFit=null,this._vacAllCamerasFor=null,this._vacAllCameraCache=null,this._vacCalConfirm=null,this._kioskDots=!1,this._cyclePausedUntil=0,this._swipeStart=null,this._tabDrag=null,this._tabDragRelease=null,this._tabSuppressClick=!1,this._tabOrderWarned=!1,this._onLabsSnapshot=e=>{const t=this._effectiveProjection();this._labs=e,this._isoProjectionSnapshot=null,this._labsIso&&this._ensureIsoSceneRuntime();const i=this._effectiveProjection();this._convertProjectionView(t,i),this.requestUpdate()},this._onHashChange=()=>{if(this._hasFixedFloor)return;const e=this._hashSpace();if(e&&this._model.find(t=>t.id===e)&&e!==this._space){if(this._wallFaceBatch&&this._roomDialogCancel(),"plan"===this._mode&&"draw"===this._tool&&!this._finishWallChain())return;this._commitSpace(e),this._selId=null,this._path=[],this._clearPlanSnapHover(),this._clearOpeningPlacement(!0),this._tool="draw",this._activeWallChainId=null,this._activeWallChainPartitionIds=[],this._wallChainSegmentCms=[],this._closingWallCm=null,this._restoreZoom(),this.requestUpdate()}},this._drag=null,this._deviceDrag=null,this._rlResize=null,this._holdFired=!1,this._retryContinuity=()=>{this._continuityDataReady=!1,this._continuityPaintToken=-1,this._continuity.retry(this._continuity.recoveryReason||"plan"),this._loading||this._loadFromServer()},this._cfgEpoch=0,this._cfgEpochPreservedConfig=null,this._terminalFrame=0,this._modelCache=null,this._emptySpaceStateActive=!1,this._decorSnapCache=null,this._markerPreviewMemo=null,this._markerPreviewDevicesMemo=null,this._showHidden=!1,this._connHooked=null,this._connectionWasLost=!1,this._haRegistryConnection=null,this._haRegistryRev=-1,this._haBindingCacheKey="",this._planHassMemo=null,this._renderLife=new $g,this._liveEditorPaintCount=0,this._onHaRegistryUpdate=()=>{const e=nd(this.hass);e.revision===this._haRegistryRev&&this._devices.length||(this._haRegistryRev=e.revision,this._renderLife.invalidate(),this._planHassMemo=null,this._regSignature="",this._maybeRebuildDevices(),this.requestUpdate())},this._onConnReady=()=>{if(this._loadTries=0,clearTimeout(this._loadRetryTimer),this._loadRetryTimer=void 0,id(this.hass),this._saveConfigDebounced.pending()&&this._saveConfigDebounced.flush(),this._cfgWriting)return clearTimeout(this._reloadRetry),void(this._reloadRetry=window.setTimeout(this._onConnReady,400));!this._connectionWasLost&&this._continuity.hasCompleteFrame?this._beginContinuityCandidate("connection-ready",!1,"plan"):(this._continuityDataReady=!1,this._continuityPaintToken=-1),this._loading||this._loadFromServer()},this._onConnLost=()=>{this._booting&&!this._continuity.hasCompleteFrame||(this._connectionWasLost=!0,this._continuityDataReady=!1,this._continuityPaintToken=-1,this._continuity.connectionLost())},this._signer=new uc(()=>this.requestUpdate()),this._dirtyPos=new Set,this._sentPos=new Map,this._persistLayout=vv(()=>{if(this._serverStorage){const e=[...this._dirtyPos];this._dirtyPos.clear();for(const t of e){const e=xo(this._layout[t]);e&&(this._layout={...this._layout,[t]:e},this._sentPos.set(t,e),this.hass.callWS({type:"houseplan/layout/update",device_id:t,pos:e}).then(e=>this._noteLayoutRev(e)).catch(e=>this._showToast(this._t("toast.pos_save_failed",{err:this._errText(e)}))).finally(()=>{this._sentPos.get(t)===e&&this._sentPos.delete(t)}))}this._cacheSnapshot()}else this._persistLocalLayout()},600),this._frame=null,this._showFar=!1,this._writesPending=0,this._writeChain=Promise.resolve(),this._pendingPhysicalWrites=new Map,this._undoGeometry=()=>this._editorRuntimeOrThrow()._undoGeometry(),this._redoGeometry=()=>this._editorRuntimeOrThrow()._redoGeometry(),this._saveConfigDebounced=vv(()=>{this._serverCfg&&this._writeConfig().catch(e=>{const t=!0===e?.physicalGeometryRolledBack;"geometry-unsafe"!==e?.code&&("wall_model_client_outdated"===e?.code?this._showToast(this._t("toast.wall_model_client_outdated")):"conflict"===e?.code?(this._showToast(this._t("toast.conflict")),t||(this._cancelPath(),this._reloadConfigOnly(!0))):this._showToast(this._t("toast.cfg_save_failed",{err:this._errText(e)})),t&&this._reloadRejectedPhysicalWrite())})},500),this._wallChainSegmentCms=[],this._closingWallCm=null,this._savePhysicalDialog=()=>this._editorRuntimeOrThrow()._savePhysicalDialog(),this._deletePhysicalSelection=()=>this._editorRuntimeOrThrow()._deletePhysicalSelection(),this._confirmPartitionDelete=()=>this._editorRuntimeOrThrow()._confirmPartitionDelete(),this._confirmRoomDelete=e=>this._editorRuntimeOrThrow()._confirmRoomDelete(e),this._rebindPartitionOpening=()=>this._editorRuntimeOrThrow()._rebindPartitionOpening(),this._keepClosedAsPartitions=()=>this._editorRuntimeOrThrow()._keepClosedAsPartitions(),this._toggleServerPlans=async()=>this._onboardingRuntime&&this._spaceDialogUsesOnboardingRuntime("create")?this._onboardingRuntime._toggleServerPlans():this._editorRuntimeOrThrow()._toggleServerPlans(),this._aspectJob=null,this._dayCycleTick=()=>{if(!this.isConnected||"hidden"===this.ownerDocument.visibilityState)return;const e=this._dayCycleState();if(!e)return this._dayCycleTimer&&(clearInterval(this._dayCycleTimer),this._dayCycleTimer=0),void(this._dayCycleClockKey="");const t=cr(e);t!==this._dayCycleClockKey&&(this._dayCycleClockKey=t,this.requestUpdate())},this._sunShown=!1,this._sunOut=!1,this._sunOutTimer=0,this._openSettingsDialog=()=>{if(this._editorRuntime)return this._editorRuntime._openSettingsDialog();this._ensureEditorRuntime().then(e=>{e&&this._openSettingsDialog()})},this._openSupportDialog=()=>{this._editorRuntime?this._editorRuntime._openSupportDialog():this._ensureEditorRuntime().then(e=>{e&&this._openSupportDialog()})},this._openPdfDialog=()=>{this._pdfRuntimeLoader.ensure().then(e=>{e&&(this._pdfDialog=!0,this.requestUpdate())})},this._reportedPreflightFingerprint=null,this._openAlignDialog=()=>this._editorRuntimeOrThrow()._openAlignDialog(),this._toggleOptimizeLivePositions=()=>this._editorRuntimeOrThrow()._toggleOptimizeLivePositions(),this._optimizeUndoBusy=!1,this._openBackupExport=()=>this._editorRuntimeOrThrow()._openBackupExport(),this._openRulesDialog=()=>this._editorRuntimeOrThrow()._openRulesDialog(),this._climateCache=null,this._gearPtCache=new WeakMap}requestUpdate(e,t,i){if("hass"===e&&this.hass&&this._liveRt){const e=this._visibleDeviceSnapshot||this._candidateDeviceSnapshot;if(!this._liveRt.hass(t,this.hass,e?{entityIds:e.entityIds}:null,()=>Mg(this))&&!this._summary?.observeHassComposition())return}void 0!==e&&(this._terminalFrame=0),this._editorRuntime?._routeLiveEditorUpdate(e,t)||(this._liveRt?.clear(),super.requestUpdate(e,t,i))}_editorRuntimeOrThrow(){if(!this._editorRuntime)throw new Error("Houseplan editor runtime is not loaded");return this._editorRuntime}async _ensureEditorRuntime(){return this._editorRuntimeLoader.ensure()}async _ensureOnboardingRuntime(){return this._onboardingRuntimeLoader.ensure()}async _ensureIsoSceneRuntime(){return this._isoSceneRuntimeLoader.ensure()}_editorRuntimeStateChanged(e){clearTimeout(this._editorRuntimeLoadingTimer),this._editorRuntimeLoadingTimer=void 0,"loading"!==e?(this._editorRuntimeLoadingVisible=!1,this.requestUpdate()):this._editorRuntimeLoadingTimer=window.setTimeout(()=>{this._editorRuntimeLoadingVisible=!0,this.requestUpdate()},150)}async _requestMode(e,t=!0,i=!1){const n=++this._editorModeRequest;if(i&&(this._warmModeRequest=n,this._refitRaf&&(cancelAnimationFrame(this._refitRaf),this._refitRaf=0),this._pendingRefitSize=null),"view"===e||await this._ensureEditorRuntime()){if(n===this._editorModeRequest&&this.isConnected)return i?(this._adoptMode(e),this._warmRevivePending&&(clearTimeout(this._warmReviveTimer),this._warmReviveTimer=void 0,this._warmReviveDialog()),this.requestUpdate(),void this.updateComplete.then(()=>requestAnimationFrame(()=>requestAnimationFrame(()=>{if(this._warmModeRequest!==n||n!==this._editorModeRequest)return;const e=this._stageEl;this._lastValidStageSize=e&&e.clientWidth>0&&e.clientHeight>0?[e.clientWidth,e.clientHeight]:null,this._pendingRefitSize=null,this._warmModeRequest=0})))):void this._setMode(e,t);this._warmModeRequest===n&&(this._warmModeRequest=0)}else this._warmModeRequest===n&&(this._warmModeRequest=0)}get _layout(){return this._adoption.layout}set _layout(e){this._adoption.stageLocalLayout(e)}get _layoutRev(){return this._adoption.layoutRev}set _layoutRev(e){this._adoption.seedIdentity({layoutRev:e})}get _layoutContentFingerprint(){return this._adoption.layoutFingerprint}set _layoutContentFingerprint(e){this._adoption.seedIdentity({layoutFingerprint:e})}get _serverCfg(){return this._adoption.config}set _serverCfg(e){this._adoption.stageLocalConfig(e)}get _cfgRev(){return this._adoption.configRev}set _cfgRev(e){this._adoption.seedIdentity({configRev:e})}get _cfgContentFingerprint(){return this._adoption.configFingerprint}set _cfgContentFingerprint(e){this._adoption.seedIdentity({configFingerprint:e})}_seedDecorStyle(e){var t,i;if(t=Ol,i=this,Fl(e,Bl)&&"pending"===t.state()&&(t.art("",i),t.ensure()),this._decorStyleSeeded||!e)return;this._decorStyleSeeded=!0;const n=e.settings?.decor_default_style;n&&(this._decorStyle=function(e,t){if(!e||"object"!=typeof e)return{...t};const i=e,n="string"==typeof i.color&&i.color?i.color:t.color,r="string"==typeof i.fill_color&&i.fill_color?i.fill_color:t.fillColor,o=Number(i.width_cm);return{color:n,opacity:Tr(i.opacity,t.opacity),widthCm:Number.isFinite(o)&&o>0?Math.max(.1,Math.min(100,o)):t.widthCm,fill:"boolean"==typeof i.fill?i.fill:t.fill,fillColor:r,fillOpacity:Tr(i.fill_opacity,t.fillOpacity)}}(n,Cr))}get _canManageConfiguration(){return null!==this._serverCanWrite?this._serverCanWrite:!0===this.hass?.user?.is_admin}get _canEdit(){return this._norm&&this._canManageConfiguration}get _kiosk(){return!!this._config?.kiosk}_showKioskDots(){this._kioskDots=!0,clearTimeout(this._kioskDotsTimer),this._kioskDotsTimer=window.setTimeout(()=>this._kioskDots=!1,2500)}get _modeTransitionBusy(){return this._modeTransitionPreparing||this._modeTransition.active}get _doubleFitEnabled(){return!("view"!==this._mode||this._vacFit||this._modeTransitionBusy||this._touchSequenceMultitouch||"steady"!==this._continuity.state||this._continuity.overlayBlocksInteraction)}_cameraState(){const e=this._viewOr(this._baseVb());return{zoom:this._zoom,viewBox:{...e}}}_normalizeCameraState(e){const t=this._cameraTransitionFit||Oi(this._baseVb(),this._stageAspect());return{zoom:Math.min(wv.ZOOM_MAX,Math.max(wv.ZOOM_MIN,e.zoom)),viewBox:this._clampView({...e.viewBox},t)}}_applyCameraTransitionFrame(e){const t=this._normalizeCameraState(e.presented);e.presented=t,this._zoom=t.zoom,this._view={...t.viewBox},this._liveVp(!0)}_settleCameraTransition(e){const t=this._normalizeCameraState(e.to);this._zoom=t.zoom,this._view={...t.viewBox},this._cameraTransitionFit=null,"room"!==e.reason&&this._saveZoom(),this.requestUpdate()}_cancelCameraTransition(e=!1,t=!1){const i=this._cameraTransition.state?.reason,n=t&&this._cameraTransition.active?this._cameraTransition.presented?.zoom:void 0;this._cameraTransition.cancel(e),this._cameraTransitionFit=null,void 0!==n&&"room"!==i&&this._saveZoom()}_prepareCameraCommand(){this._bootSoftCancel(),this._modeTransitionBusy&&this._cancelModeTransition(!0),"opening"===this._tool&&(this._cursorPt=null,this._clearOpeningPlacement(!1))}_startCameraTransition(e,t,i,n){const r=this._cameraState(),o=this._cameraTransition.target;return(!o||!Xg(o,e))&&(Xg(r,e)?(this._cancelCameraTransition(!1),!1):(this._activateSafeDayCycleOutline(),this._cameraTransitionFit={...t},this._cameraTransition.start(r,e,i,this._reducedMotion?0:n),!0))}_cssColor(e,t){const i=String(e||"").trim();if(!i)return t;const n=document.createElement("span");n.style.cssText=`position:absolute;visibility:hidden;color:${i}`,this.renderRoot.append(n);const r=getComputedStyle(n).color||t;return n.remove(),r}_currentModeVisual(e=this._mode){const t=this._modeTransition.presented||this._modeTransitionVisual;if(t)return{...t,viewport:{...t.viewport,viewBox:{...t.viewport.viewBox}}};const i=this._stageEl;if(!i||i.clientWidth<=0||i.clientHeight<=0)return null;const n=this.renderRoot.querySelector(".editorchrome"),r=this._viewOr(this._baseVb()),o=this.renderRoot.querySelector(".hp-paper"),s=this.renderRoot.querySelector(".hp-backdrop"),a=this.renderRoot.querySelector(".zoomwrap"),l=a?getComputedStyle(a).filter:"",c=Number(/brightness\(([^)]+)\)/.exec(l)?.[1]);return{presentedMode:e,editorChromeHeight:"view"===e?0:n?.getBoundingClientRect().height||0,stageWidth:i.clientWidth,stageHeight:i.clientHeight,viewport:Bg(r,i.clientWidth),stageColor:getComputedStyle(i).backgroundColor||"rgb(255, 255, 255)",paperColor:o?getComputedStyle(o).fill:"rgb(255, 255, 255)",sceneBrightness:Number.isFinite(c)?c:1,architectureOpacity:"decor"===e?.35:1,backdropOpacity:s&&Number(getComputedStyle(s).opacity)||1,viewWeight:"view"===e?1:0,editorWeight:"view"===e?0:1,toolbarContentOpacity:"view"===e?0:1}}_viewForModeTarget(e,t,i,n,r){const o=Oi(this._baseVb(),n/r),s=Math.min(wv.ZOOM_MAX,Math.max(wv.ZOOM_MIN,e)),a=o.w/s,l=o.h/s,c=t??o.x+o.w/2,h=i??o.y+o.h/2;return this._clampView({x:c-a/2,y:h-l/2,w:a,h:l},o)}_targetStageColor(e){return"view"!==e?"rgb(255, 255, 255)":this._cssColor(this._stageBg(this._spaceDisplayForRender()),this._cssColor("var(--ha-card-background, var(--card-background-color, #111))","rgb(17, 17, 17)"))}_targetPaperColor(e){return"view"===e&&this._spaceModel()?.bg?this._cssColor("var(--ha-card-background, var(--card-background-color, #111))","rgb(17, 17, 17)"):"rgb(255, 255, 255)"}_targetBrightness(e){return 1}_applyModeTransitionFrame(e){e.targetMode===this._mode&&(this._modeTransitionVisual=e.presented,this._view={...e.presented.viewport.viewBox},this.requestUpdate())}_settleModeTransition(e){if(e.targetMode!==this._mode)return;const t=this._modeTransitionRequest;this._view={...e.to.viewport.viewBox},this._zoom=this._modeTransitionTargetZoom,this._modeTransitionVisual=null,this._modeTransitionPreparing=!1,this._lastValidStageSize=[e.to.stageWidth,e.to.stageHeight],"view"===this._mode&&(this._saveZoom(),this._viewModeSnap=null,this._modeTransitionEditorCamera=null),this.requestUpdate(),this.updateComplete.then(()=>{if(!this.isConnected||t!==this._modeTransitionRequest||this._modeTransitionBusy||e.targetMode!==this._mode)return;const i=this._stageEl;if(i&&i.clientWidth>0&&i.clientHeight>0&&(Math.abs(i.clientWidth-e.to.stageWidth)>.5||Math.abs(i.clientHeight-e.to.stageHeight)>.5)){const e=this._view;this._lastValidStageSize=[i.clientWidth,i.clientHeight],this._applyView(this._zoom,e?e.x+e.w/2:void 0,e?e.y+e.h/2:void 0),this.requestUpdate()}const n=this.renderRoot.activeElement;(!n||!n.isConnected||!!n.closest?.(".editorchrome, .stage"))&&this.renderRoot.querySelector(".modetab.active")?.focus?.({preventScroll:!0})})}_cancelModeTransition(e=!0){this._cancelCameraTransition(!1);const t=!!this._modeTransition.state;this._modeTransitionRequest++,this._modeTransitionPreparing=!1,this._modeTransitionForceAtomic=!1,this._modeTransition.cancel(e),e&&t||(this._modeTransitionVisual=null)}_adoptMode(e){e!==this._mode&&(this._clearRoomFocus(!0),this._resetDeviceHitState()),this._cancelModeTransition(!1),this._mode=e,this._isoProjectionSnapshot=null,"view"!==e&&(this._editorChromeMode=e)}_commitViewModeAtomic(e,t,i,n){if(this._modeTransitionPreparing=!1,this._modeTransitionVisual=null,this._modeTransitionForceAtomic=!1,this._zoom=t,e){const r=this._stageEl?.clientWidth||e.stageWidth,o=Math.max(1,e.stageHeight+e.editorChromeHeight);this._view=this._viewForModeTarget(t,i,n,r,o),this._lastValidStageSize=[r,o]}else this._view=null;this._viewModeSnap=null,this._modeTransitionEditorCamera=null,this._saveZoom(),this.requestUpdate()}_prepareModeTransition(e,t,i,n,r,o){this.updateComplete.then(()=>{if(!this.isConnected||e!==this._modeTransitionRequest||this._mode!==i)return void(e===this._modeTransitionRequest&&(this._modeTransitionPreparing=!1,this._modeTransitionVisual=null,this._modeTransitionForceAtomic=!1,this.requestUpdate()));const s=this.renderRoot.querySelector(".editorchrome-inner"),a="view"===i?0:s?.scrollHeight||0,l=Math.max(1,(this.panelHost?this.clientHeight:innerHeight)-ef(this.renderRoot,this._stageEl,this.panelHost)),c=this._stageEl?.clientWidth||t.stageWidth,h=this._viewForModeTarget(n,r,o,c,l),d={presentedMode:i,editorChromeHeight:a,stageWidth:c,stageHeight:l,viewport:Bg(h,c),stageColor:this._targetStageColor(i),paperColor:this._targetPaperColor(i),sceneBrightness:this._targetBrightness(i),architectureOpacity:"decor"===i?.35:1,backdropOpacity:"decor"===i&&"backdrop"!==this._decorTool?.5:1,viewWeight:"view"===i?1:0,editorWeight:"view"===i?0:1,toolbarContentOpacity:"view"===i?0:1};this._modeTransitionPreparing=!1;const u=this._modeTransitionForceAtomic;this._modeTransitionForceAtomic=!1,this._modeTransition.start(t,d,i,this._reducedMotion||u?0:220)})}get _hasFixedFloor(){return!!this._config&&Object.prototype.hasOwnProperty.call(this._config,"floor")}_fixedFloorState(e=this._model,t=this._loadOk){const i=this._config?.floor,n=function(e){if(!e.hasFloor)return{kind:"absent"};const t=e.floor;if("string"==typeof t)return t.length?e.spaceIds.includes(t)?{kind:"valid",id:t,source:"id"}:{kind:"invalid",reason:"unknown-id",value:t}:{kind:"invalid",reason:"empty-id",value:t};if("number"==typeof t){if(!Number.isFinite(t))return{kind:"invalid",reason:"non-finite-index",value:t};if(!Number.isInteger(t))return{kind:"invalid",reason:"fractional-index",value:t};if(t<0)return{kind:"invalid",reason:"negative-index",value:t};const i=e.spaceIds[t];return void 0===i?{kind:"invalid",reason:"out-of-range-index",value:t}:{kind:"valid",id:i,source:"index"}}return{kind:"invalid",reason:"invalid-type",value:t}}({spaceIds:e.map(e=>e.id),hasFloor:this._hasFixedFloor,floor:i});return!this._hasFixedFloor||t?n:"number"==typeof i?"valid"===n.kind||"invalid"===n.kind&&"out-of-range-index"===n.reason?{kind:"pending",value:i}:n:"valid"===n.kind||"invalid"===n.kind&&"unknown-id"!==n.reason?n:{kind:"pending",value:i}}_canCommitSpace(e,t=!1){if(t||!this._hasFixedFloor)return!0;const i=this._fixedFloorState();return"valid"===i.kind&&i.id===e}_commitSpace(e,t=!1){return!!this._canCommitSpace(e,t)&&(e!==this._space&&(this._clearRoomFocus(!0),this._resetDeviceHitState(),this._cancelDangerConfirm(),this._cancelCameraTransition(!1),this._clearTransientHover(!0),this._cancelDevicePressFeedback(),this._editorRuntime?._clearFurniturePreview()),this._space=e,this._isoProjectionSnapshot=null,!0)}_slideTo(e,t){if(e===this._space)return!0;if(!this._canCommitSpace(e))return!1;if(this._wallFaceBatch&&this._roomDialogCancel(),"plan"===this._mode&&"draw"===this._tool&&!this._finishWallChain())return!1;this._cancelModeTransition(!0);const i=window.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches;return this._commitSpace(e),this._path=[],this._clearPlanSnapHover(),this._clearOpeningPlacement(!0),this._tool="draw",this._activeWallChainId=null,this._activeWallChainPartitionIds=[],this._wallChainSegmentCms=[],this._closingWallCm=null,this._selId=null,this._physicalSel=null,this._editorSecondary?.closeForNavigation(),this._physicalDialog=null,this._physicalDrag=null,this._restoreZoom(),i||(this._slide=t,clearTimeout(this._slideTimer),this._slideTimer=window.setTimeout(()=>{this._slideTimer=void 0,this._slide="",this.requestUpdate()},190),this.requestUpdate()),!0}get _canReorderTabs(){return Zf({canEdit:this._canEdit,kiosk:this._kiosk,mode:this._mode,pointerType:"mouse",spaceCount:this._model.length,fixedFloor:this._hasFixedFloor})}_tabPointerDown(e,t){Zf({canEdit:this._canEdit,kiosk:this._kiosk,mode:this._mode,pointerType:e.pointerType,spaceCount:this._model.length,fixedFloor:this._hasFixedFloor})&&(yv(e),this._tabDragRelease=e=>this._tabPointerUp(e),window.addEventListener("pointerup",this._tabDragRelease),window.addEventListener("pointercancel",this._tabDragRelease),this._tabDrag={id:t,pointerId:e.pointerId,x:e.clientX,y:e.clientY,moved:!1,targetId:null,placement:null})}_tabDropTargetAt(e,t,i){const n=this._model.map(e=>e.id),r=n.indexOf(i);if(r<0)return null;const o=this.renderRoot.querySelectorAll('[data-hp="space-tab"]');for(const s of o){const o=s.dataset.id||"";if(!o||o===i)continue;const a=s.getBoundingClientRect();if(ea.right||ta.bottom)continue;const l=n.indexOf(o);return l<0?null:{targetId:o,placement:l=4)))return;var i,n;const r=this._tabDropTargetAt(e.clientX,e.clientY,t.id);t.moved&&t.targetId===r?.targetId&&t.placement===r?.placement||(this._tabDrag={...t,moved:!0,targetId:r?.targetId||null,placement:r?.placement||null})}_tabPointerUp(e){const t=this._tabDrag;if(t&&t.pointerId!==e.pointerId)return;const i="pointerup"===e.type&&t?.moved?this._tabDropTargetAt(e.clientX,e.clientY,t.id):null;"pointerup"===e.type&&t?.moved&&this._suppressNextTabClick(),this._endTabDrag(),t?.moved&&i&&this._commitTabOrder(t.id,i.targetId)}_endTabDrag(){this._tabDrag=null,this._tabDragRelease&&(window.removeEventListener("pointerup",this._tabDragRelease),window.removeEventListener("pointercancel",this._tabDragRelease),this._tabDragRelease=null)}_tabClick(e){if(this._tabSuppressClick)return this._tabSuppressClick=!1,clearTimeout(this._tabSuppressClickTimer),void(this._tabSuppressClickTimer=void 0);this._pickSpace(e)}_suppressNextTabClick(){this._tabSuppressClick=!0,clearTimeout(this._tabSuppressClickTimer),this._tabSuppressClickTimer=window.setTimeout(()=>{this._tabSuppressClick=!1,this._tabSuppressClickTimer=void 0},0)}_commitTabOrder(e,t){const i=this._serverCfg;if(!i||!this._canReorderTabs)return;const n=this._model.map(e=>e.id),r=function(e,t,i){const n=e.indexOf(t),r=e.indexOf(i);if(n<0||r<0||n===r)return e;const o=e.slice();return o.splice(n,1),o.splice(r,0,t),o}(n,e,t);if(r===n)return;const o=new Map(this._devices.map(e=>[String(e.id),String(e.area||"")])),s=function(e,t,i,n=()=>""){if(!i)return[];const r=[];for(const o of e){if(!o||!0===o.removed)continue;const e="string"==typeof o.id?o.id:"";if(!e)continue;if("string"==typeof o.space&&o.space)continue;const s=("string"==typeof o.area?o.area:"")||n(e)||"";s&&t[s]||r.push({id:e,space:i})}return r}(i.markers||[],Object.fromEntries(Object.entries(this._areaToSpace).map(([e,t])=>[e,t.space])),n[0]||"",e=>o.get(e)||"");if(s.length){const e=new Map(s.map(e=>[e.id,e.space]));for(const t of i.markers||[]){const i=e.get(String(t.id));i&&(t.space=i)}}i.spaces=function(e,t){const i=new Map(t.map((e,t)=>[e,t]));return e.map((e,t)=>({space:e,index:t})).sort((e,t)=>(i.get(String(e.space?.id))??Number.MAX_SAFE_INTEGER)-(i.get(String(t.space?.id))??Number.MAX_SAFE_INTEGER)||e.index-t.index).map(e=>e.space)}(i.spaces||[],r),this._saveConfig(),this._tabOrderWarned||(this._tabOrderWarned=!0,this._showToast(this._t("toast.space_order_changed")))}_pickSpace(e){if(this._endTabDrag(),e===this._space)return;const t=this._model.map(e=>e.id),i=t.indexOf(this._space),n=t.indexOf(e);this._navApplied=!0,this._showFar=!1,this._frame=null,this._slideTo(e,i>=0&&n0&&Date.now()>=this._cyclePausedUntil&&this._model.length>1&&this._zoom<=1.001){const e=this._model.map(e=>e.id),t=e.indexOf(this._space);this._slideTo(e[(t+1)%e.length],"left"),this._showKioskDots()}}_syncCycleTimer(){clearInterval(this._cycleTimer),this._cycleTimer=void 0,this.isConnected&&!this._hasFixedFloor&&this._config?.kiosk&&Number(this._config.cycle)>0&&(this._cycleTimer=window.setInterval(()=>this._cycleTick(),1e3*Number(this._config.cycle)))}get _editing(){return"plan"===this._mode||"devices"===this._mode||"decor"===this._mode}get _markup(){return"plan"===this._mode}get _wallUnionCache(){return this._wallUnionCacheValue}set _wallUnionCache(e){this._wallUnionCacheValue=e,null===e&&this._wallUnionPool.clear()}get _glowClipCache(){return this._glowRuntimeState.clipCache}get _glowGeometryWarnings(){return this._glowRuntimeState.geometryWarnings}get _glowFeatherUnits(){return this._glowRuntimeState.featherUnits}set _glowFeatherUnits(e){this._glowRuntimeState.featherUnits=e}get _glowRenderedSources(){return this._glowRuntimeState.renderedSources}get _glowLastAppearance(){return this._glowRuntimeState.lastAppearance}get _glowFeatherSuspendUntil(){return this._glowRuntimeState.featherSuspendUntil}set _glowFeatherSuspendUntil(e){this._glowRuntimeState.featherSuspendUntil=e}get _glowFeatherResumeTimer(){return this._glowRuntimeState.featherResumeTimer}set _glowFeatherResumeTimer(e){this._glowRuntimeState.featherResumeTimer=e}get _glowSourceSeq(){return this._glowRuntimeState.sourceSeq}set _glowSourceSeq(e){this._glowRuntimeState.sourceSeq=e}_activateSafeDayCycleOutline(){this._safeDayCycleOutline=!0,this._stageEl?.classList.add("hp-safe-daycycle-outline")}get _touchSequenceMultitouch(){return this._touchClickGuard.sequenceMultitouch}_syncDangerConfirmLocaleGate(){return this._config&&this.hass?dp(this,gp,kp(this.hass,this._config.language)):"ready"}_dangerConfirmMissingSpace(){const e=this._model;if(!e.length)return!1;const t=this._fixedFloorState(e);return"pending"!==t.kind&&"invalid"!==t.kind&&!this._spaceModel()}_syncVersionRecovery(){this._versionRecovery.update({frontendVersion:ev(iv),backendVersion:this._haIntegrationVersion,kiosk:!0===this._config?.kiosk,reducedMotion:this._reducedMotion})}_newContinuityController(){return new lc(()=>{this._resumeSettling="steady"!==this._continuity.state,this._continuityEpoch++,this.isConnected&&this.requestUpdate()})}get _labsIso(){return this._labs.active.includes("iso")}get _desiredProjection(){return"view"===this._mode&&this._labsIso&&"iso"===this._viewPreference[this._space]?"iso":"flat"}_saveViewPreference(){try{localStorage.setItem(uv,JSON.stringify(this._viewPreference))}catch{}}_logicalViewCenter(e){const t=this._view;if(!t)return null;const i=[t.x+t.w/2,t.y+t.h/2],n="iso"===e?cf(i):i;return{x:n[0],y:n[1]}}_convertProjectionView(e,t){if(e===t)return;this._clearRoomFocus(!0);const i=this._logicalViewCenter(e);this._view=null;const n=i?"iso"===t?lf([i.x,i.y],0):[i.x,i.y]:null;this._applyView(this._zoom,n?.[0],n?.[1]),this._warmPatch({vp:this._warmViewportState()}),this.requestUpdate()}_setProjection(e){if(!this._labsIso||"view"!==this._mode)return;const t=this._effectiveProjection();if(this._viewPreference={...this._viewPreference,[this._space]:e},"iso"===e){this._ensureIsoSceneRuntime();const e=this._isoSceneKey();e&&this._isoFallback.delete(e),this._isoFallback.delete(`${this._space}|no-borders`),this._clearIsoInvalidFallback()}this._saveViewPreference(),this._isoProjectionSnapshot=null;const i=this._effectiveProjection();this._convertProjectionView(t,i)}_hashSpace(){return Ff(window.location.hash||"")}connectedCallback(){this._connectedPath=location.pathname,this._routeDepartureHandled=!1,this._configReloadAuthority.observeContext(Vu(this)),window.addEventListener("location-changed",this._onLocationChanged),window.addEventListener("popstate",this._onLocationChanged),this._continuityDisposed&&(this._continuity=this._newContinuityController(),this._continuityDisposed=!1,this._continuityPaintToken=-1);const e=dg(this.ownerDocument);var t;void 0!==e&&(this._glowScreenBlend=e),this._continuityUnsub?.(),this._continuityUnsub=sc(this.ownerDocument,this._pageVisibility),this._languageFailureUnsub?.(),this._languageFailureUnsub=function(...e){return()=>{for(const t of e)t()}}((t=()=>{this._showToast(this._t("toast.locale_load_failed"))},mp.add(t),()=>mp.delete(t)),function(e){return Il.add(e),()=>{Il.delete(e)}}(()=>this._showToast(this._t("toast.furniture_art_load_failed")))),super.connectedCallback(),this._summarySlot.connect(),this._ensureLiveRuntime().catch(()=>this.requestUpdate()),this._pointerModality.connect(this.ownerDocument.defaultView);const i=this.ownerDocument.defaultView?.MutationObserver;i&&(this._pointerHoverObserver=new i(e=>{let t=!1;for(const i of e){for(const e of i.addedNodes)this._syncPointerHoverSubtree(e);const e=e=>{if(e.nodeType!==Node.ELEMENT_NODE)return!1;const t=e;return t.matches(".devlayer, .devlayer *")||!!t.querySelector?.(".devlayer")};(e(i.target)||[...i.addedNodes,...i.removedNodes].some(e))&&(t=!0)}t&&this._invalidateDeviceHitGeometry()}),this._pointerHoverObserver.observe(this.renderRoot,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style","data-id"]})),this._motionMedia=window.matchMedia?.("(prefers-reduced-motion: reduce)"),this._reducedMotion=!!this._motionMedia?.matches,this._motionMedia?.addEventListener?.("change",this._onMotionChange),this._syncVersionRecovery(),this._versionRecovery.connect(),hg(this.ownerDocument).then(e=>{e!==this._glowScreenBlend&&(this._glowScreenBlend=e,this.isConnected&&this.requestUpdate())}),this.hass&&this._ensureHaRegistryAuthority(),window.addEventListener("keydown",this._keyHandler),this._signer.start(()=>this.hass,()=>this._referencedContentUrls()),this._syncCycleTimer(),window.addEventListener("hashchange",this._onHashChange),this._labsUnsub?.(),this._labsUnsub=function(e){Nf.add(e);const t=Bf();return"undefined"==typeof window&&e(t),()=>{Nf.delete(e)}}(this._onLabsSnapshot),this._labsIso&&this._ensureIsoSceneRuntime(),this._booting?this._bootWatch():this._bootFading&&(clearTimeout(this._bootTimer),this._bootTimer=window.setTimeout(()=>{this._bootFading=!1},220)),this._bootSoft&&(clearTimeout(this._bootSoftTimer),this._bootSoftTimer=window.setTimeout(()=>{this._bootSoft=!1},rv)),!this._loadOk&&this._serverCfg&&this.hass&&this._scheduleLoadRetry(),!this._warmSlot&&this._config&&this._warmAdopt(),this._loadOk&&this._ensureLiveSyncSubscriptions(),this._warmVp&&!this._warmRevivePending&&void 0===this._warmReviveTimer&&(this._warmRevivePending=!0,this._warmReviveTimer=window.setTimeout(()=>this._warmReviveDialog(),0)),this._warmLongReturn&&this._beginResumeSettle(),this._warmLongReturn=!1,this.requestUpdate()}disconnectedCallback(){this._versionRecovery.disconnect(),this._configReloadAuthority.invalidateLifecycle(),this._liveRt?.dispose(),this._radarLive.stop(),this._editorRuntime?._disposeLiveEditor(),this._clearRoomFocus(!0),this._cancelDangerConfirm(),this._connectedPath&&location.pathname!==this._connectedPath&&this._leaveCardRoute(),window.removeEventListener("location-changed",this._onLocationChanged),window.removeEventListener("popstate",this._onLocationChanged),this._continuityUnsub?.(),this._continuityUnsub=void 0,this._languageFailureUnsub?.(),this._languageFailureUnsub=void 0,this._motionMedia?.removeEventListener?.("change",this._onMotionChange),this._motionMedia=void 0,this._vacRaf&&(cancelAnimationFrame(this._vacRaf),this._vacRaf=0),this._refitRaf&&(cancelAnimationFrame(this._refitRaf),this._refitRaf=0),this._warmModeRequest=0,this._dayCycleTimer&&(clearInterval(this._dayCycleTimer),this._dayCycleTimer=0),this._summarySlot.disconnect(),this._dayCycleClockKey="",this._bootSettleRaf&&(cancelAnimationFrame(this._bootSettleRaf),this._bootSettleRaf=0),this._bootSettling=!1;for(const e of this._activityRt.values())clearTimeout(e.timer);window.removeEventListener("keydown",this._keyHandler),this._endTabDrag(),clearTimeout(this._tabSuppressClickTimer),this._tabSuppressClickTimer=void 0,this._tabSuppressClick=!1,clearInterval(this._cycleTimer),clearTimeout(this._kioskDotsTimer),clearTimeout(this._kioskHoldTimer),clearTimeout(this._reloadRetry),clearTimeout(this._loadRetryTimer),this._loadRetryTimer=void 0,this._connHooked?.removeEventListener?.("ready",this._onConnReady),this._connHooked?.removeEventListener?.("disconnected",this._onConnLost),this._connHooked?.removeEventListener?.("reconnect-error",this._onConnLost),this._connHooked=null,this._haRegistryRelease?.(),this._haRegistryRelease=void 0,this._haRegistryConnection=null,this._signer.dispose(),clearTimeout(this._toastTimer),clearTimeout(this._slideTimer),clearTimeout(this._editorRuntimeLoadingTimer),this._editorRuntimeLoadingTimer=void 0,this._editorRuntimeLoadingVisible=!1,this._modeTransition.dispose(),this._cameraTransition.dispose(),this._cameraTransitionFit=null,this._modeTransitionVisual=null,this._modeTransitionPreparing=!1,this._modeTransitionForceAtomic=!1,this._modeTransitionRequest++,this._slideTimer=void 0,this._slide="",clearTimeout(this._bootTimer),this._bootTimer=void 0,clearTimeout(this._bootSoftTimer),this._saveConfigDebounced.flush(),this._cancelDeviceDrag(),window.removeEventListener("hashchange",this._onHashChange),this._labsUnsub?.(),this._labsUnsub=void 0,clearTimeout(this._holdTimer),this._roViewport?.disconnect(),this._roViewport=void 0,this._roHdr?.disconnect(),this._roHdr=void 0,this._onWinResize&&(window.removeEventListener("resize",this._onWinResize),this._onWinResize=void 0),this._unsubCfg&&(this._unsubCfg(),this._unsubCfg=null),this._unsubLayout&&(this._unsubLayout(),this._unsubLayout=null),this._unsubVirtual&&(this._unsubVirtual(),this._unsubVirtual=null),this._unsubTrail&&(this._unsubTrail(),this._unsubTrail=void 0),this._liveSyncGeneration++,this._liveSyncAttempt=null,this._liveSyncConnection=null,clearTimeout(this._layoutSyncTimer),clearTimeout(this._duplicateColumnTimer),Fm(this._glowRuntimeState,this._glowRuntimeHost),this._warmSnapshot(),this._warmRevivePending=!1,clearTimeout(this._warmReviveTimer),this._warmReviveTimer=void 0,this._warmRelease(),this._clearPlanSnapHover(),this._clearOpeningPlacement(!0),this._editorRuntime?._clearFurniturePreview(),this._editorRuntime?._furnShiftDetach(),this._touchContacts.clear(),this._touchClickGuard.reset(),this._resetDeviceHitState(),this._clearTransientHover(!0),this._cancelDevicePressFeedback(),this._pointerHoverObserver?.disconnect(),this._pointerHoverObserver=void 0,this._pointerModality.disconnect(),this._editorSecondary?.reset(),this._resumeSettling=!1,this._continuityHistory=[...this._continuityHistory,...this._continuity.trace].slice(-80),this._continuity.dispose(),this._continuityDisposed=!0,super.disconnectedCallback()}_onKey(e){if("Escape"===e.key&&this._vacFit){if(this._vacFit.busy)return;return this._vacFit=null,this._showToast(this._t("vac.cal_cancelled")),void e.stopPropagation()}if("Escape"===e.key){if(this._tapConfirm)return void(this._tapConfirm=null);if(this._vacCalConfirm)return void(this._vacCalConfirm.busy||(this._vacCalConfirm=null));if(this._decorEraseConfirm)return void(this._decorEraseConfirm=null);if(this._openingInfo)return void(this._openingInfo=null);if(this._infoCard)return void this._closeInfoCard();if(this._rulesDialog)return void(this._rulesDialog=null);if(this._alignDialog)return this._alignDialog=null,void(this._preflightClipboardFallback=null);if(this._backupImportDialog)return void(this._backupImportDialog=null);if(this._backupExportDialog)return void(this._backupExportDialog=null);if(this._pdfDialog)return void(this._pdfDialog=!1);if(this._supportDialog)return void this._editorRuntime?._closeSupportDialog();if(this._settingsDialog)return void(this._settingsDialog=null);if(this._summary?.closeDialogIfIdle())return;if(this._markerDialog)return void this._closeMarkerDialog();if(this._deviceInbox)return void(this._deviceInbox=null);if(this._openingDialog)return void(this._openingDialog=null);if(this._physicalDialog)return void(this._physicalDialog=null);if(this._backdropDialog)return void(this._backdropDialog=null);if(this._decorShapeDialog)return void(this._decorShapeDialog=null);if(this._decorTextDialog)return void(this._decorTextDialog=null);if(this._spaceDialog&&!this._roomDialog)return this._spaceDialog=null,this._importQueue=[],void(this._importTotal=0);if(this._editorSecondary?.hasOpenGroup)return e.preventDefault(),void this._editorSecondary?.closeGroup(!0)}const t=e.composedPath?.()||[e.target],i=t.some(e=>e?.matches?.('input, textarea, select, [contenteditable="true"]')),n=t.some(e=>e?.classList?.contains?.("editor-secondary")),r=e.ctrlKey||e.metaKey,o=e.key.toLowerCase(),s=/^[a-z]$/.test(o),a="z"===o||!s&&"KeyZ"===e.code,l="y"===o||!s&&"KeyY"===e.code,c=r&&(a&&e.shiftKey||l),h=r&&a&&!e.shiftKey;if("decor"===this._mode){if((h||c)&&i)return;if(c)return e.preventDefault(),void this._redoGeometry();if(h)return e.preventDefault(),this._decorDraft?void(this._decorDraft=null):this._decorMove||this._dtDrag||this._bdDrag?void this._cancelDecorGesture():void this._undoGeometry();if(("Delete"===e.key||"Backspace"===e.key)&&this._decorSel&&!i&&!n)return e.preventDefault(),void this._decorDeleteSel();const t="ArrowLeft"===e.key?[-this._gridPitch,0]:"ArrowRight"===e.key?[this._gridPitch,0]:"ArrowUp"===e.key?[0,-this._gridPitch]:"ArrowDown"===e.key?[0,this._gridPitch]:null;return!t||r||e.altKey||"select"!==this._decorTool||!this._decorSel||!this._decorList.some(e=>e.id===this._decorSel)||this._decorDraft||this._decorMove||this._dtDrag||this._bdDrag||i||n||this._editorSecondaryDialogBlocked?void("Escape"===e.key&&(e.preventDefault(),this._decorDraft?this._decorDraft=null:this._decorMove||this._dtDrag||this._bdDrag?this._cancelDecorGesture():"furniture"===this._decorTool?(this._editorRuntime?._clearFurniturePreview(),this._editorRuntime?._furnShiftDetach(),this._furnPalette=null,this._furnCategory=null,this._decorTool="select"):this._decorSel?this._decorSel=null:"select"!==this._decorTool?this._decorTool="select":this._setMode("view"))):(e.preventDefault(),void this._decorNudge(t[0],t[1]))}if("devices"===this._mode){if((h||c)&&i)return;return c?(e.preventDefault(),void this._redoDevicePosition()):h?(e.preventDefault(),void this._undoDevicePosition()):void("Escape"===e.key&&this._deviceDrag&&(e.preventDefault(),this._cancelDeviceDrag()))}if(this._markup&&(!h&&!c||!i)){if(("Delete"===e.key||"Backspace"===e.key)&&this._physicalSel&&!i&&!n)return e.preventDefault(),void this._deletePhysicalSelection();if(c)return e.preventDefault(),void this._redoGeometry();if(h)return e.preventDefault(),this._resize?.dragging?void this._rszCancelDrag():this._wallFaceBatch?(this._roomDialogCancel(),void(this._activeWallChainId&&this._path.length>1?this._undoActiveWallPoint():this._undoPoint())):"draw"===this._tool&&this._path.length?void(this._activeWallChainId&&this._path.length>1?this._undoActiveWallPoint():this._undoPoint()):"split"===this._tool&&this._splitSel?.pts?.length?(this._splitSel={...this._splitSel,pts:this._splitSel.pts.slice(0,-1)},void(this._splitSel.pts.length||(this._cursorPt=null))):void this._undoGeometry();if("Escape"===e.key)return this._physicalDrag||this._physicalRotate?(e.preventDefault(),void this._cancelPhysicalGesture()):this._roomDialog?(e.preventDefault(),void this._roomDialogCancel()):"draw"===this._tool&&this._path.length?(e.preventDefault(),void this._finishWallChain()):this._physicalSel?(e.preventDefault(),void(this._physicalSel=null)):"resize"===this._tool?(e.preventDefault(),this._resize?.dragging?void this._rszCancelDrag():("exit-tool"===this._resize?.escapeIdle()&&(this._tool="draw"),void this.requestUpdate())):"split"===this._tool?(e.preventDefault(),void(this._splitSel?.pts?.length?(this._splitSel={...this._splitSel,pts:this._splitSel.pts.slice(0,-1)},this._splitSel.pts.length||(this._cursorPt=null)):this._splitSel?this._splitSel=null:this._tool="draw")):"merge"===this._tool?(e.preventDefault(),void(this._mergeSel?this._mergeSel=null:this._tool="draw")):this._wallDialog?(e.preventDefault(),void(this._wallDialog=null)):void("opening"!==this._tool&&"wallthick"!==this._tool&&"delroom"!==this._tool&&"column"!==this._tool||(e.preventDefault(),"opening"===this._tool&&this._clearOpeningPlacement(!0),this._tool="draw"))}}_undoPoint(){if(this._path.length)return this._contourClosed?(this._path=this._path.slice(0,-1),void(this._closingWallCm=null)):void(this._activeWallChainPartitionIds.length&&this._path.length>1?this._undoActiveWallPoint():this._path=this._path.slice(0,-1))}_undoActiveWallPoint(){const e=[...this._activeWallChainPartitionIds],t=e[e.length-1],i=this._spaceModel()?.partitions.find(e=>e.id===t),n=this._path[0]?[...this._path[0]]:null,r=this._path.slice(0,-1).map(e=>[...e]),o=this._wallChainSegmentCms.slice(0,-1),s=this._geometryHistory.undo();if(!s)return this._activeWallChainPartitionIds=[],this._wallChainSegmentCms=[],this._wallChainRedo=[],void(this._path=n?[n]:[]);this._applyGeometryState(s.before,!0)?(this._activeWallChainId||=`chain-${Date.now().toString(36)}`,this._activeWallChainPartitionIds=e.slice(0,-1),this._path=r.length?r:n?[n]:[],this._wallChainSegmentCms=o,i&&this._wallChainRedo.push({id:i.id,point:[...i.b],cm:i.cm}),this._clearPlanSnapHover(),this._showToast(this._t("history.undone",{name:s.name}))):this._geometryHistory.clear()}static async getConfigElement(){return await import("./editor-0Mj9gnAf.js"),document.createElement("houseplan-card-editor")}static getStubConfig(){return{type:"custom:houseplan-card"}}static _warmBootReset(e){for(const e of ov.values())for(const t of e)clearTimeout(t.evict);ov.clear(),av=e&&e>0?e:1e4}static _warmBootStats(){let e=0,t=0;const i=[];for(const n of ov.values())for(const r of n)e++,r.dlg&&(t++,i.push(r.dlg.kind));return{keys:ov.size,slots:e,dlgs:t,drafts:i}}setConfig(e){const t=this._config,i=!!t&&Object.prototype.hasOwnProperty.call(t,"floor");this._config={icon_size:2.5,show_temperature:!0,live_states:!0,show_signal:!0,...e};(i!==this._hasFixedFloor||t?.floor!==this._config.floor)&&(this._hashApplied=!1,this._navApplied=!1,this._warmVpArmed=!1),this._config.kiosk&&(this._booting=!1,this._bootFading=!1),!this._hasFixedFloor&&e.default_floor&&this._commitSpace(e.default_floor,!0);try{this._zoomBySpace=JSON.parse(localStorage.getItem(hv)||"{}")||{}}catch{this._zoomBySpace={}}try{const e=JSON.parse(localStorage.getItem(uv)||"{}")||{};this._viewPreference=Object.fromEntries(Object.entries(e).filter(e=>"flat"===e[1]||"iso"===e[1]))}catch{this._viewPreference={}}if(this._labs=Bf(),this.isConnected&&this._labsIso&&this._ensureIsoSceneRuntime(),!this._summary?.applyLocalScaleForCurrentIdentity())try{const e=JSON.parse(localStorage.getItem("houseplan_card_kiosk_v1")||"null");this._kioskScale={icon:jn(e?.icon),font:jn(e?.font)}}catch{}try{const e=JSON.parse(localStorage.getItem(cv)||"null");this._adoption.restoreCached(e)&&(this._seedDecorStyle(this._serverCfg),this._cfgEpoch++,this._virtualLights=Hh(e.virtual_lights,this._cfgRev),this._serverStorage=!0)}catch{}this._adoptInitialSpace(this._model,this._loadOk),"view"!==this._mode||this._view||(this._zoom=this._zoomBySpace[this._space]||1),this.isConnected&&(this._syncCycleTimer(),this._warmAdopt(),this._warmLongReturn&&this._beginResumeSettle(),this._warmLongReturn=!1),this._syncVersionRecovery()}_warmAdopt(){if(this._config?.kiosk)return;const e=Cf(this._config);if(this._warmKey===e&&this._warmSlot)return;this._warmSlot&&this._warmRelease();const t=this.parentNode,i=this._warmIdx(t),n=ov.get(e);if(!n||!n.length)return;const r=n.find(e=>e.owner===this._warmGen);if(r)return this._warmLongReturn=!!r.freed&&Date.now()-r.freed>=nc,clearTimeout(r.evict),r.evict=0,r.freed=0,r.live=!0,this._warmSlot=r,this._warmKey=e,r.frameFingerprint&&this._continuity.adoptCompleteFrame(r.frameFingerprint),void(!this._devices.length&&r.devices?.length&&(this._devices=[...r.devices]));const{slot:o,sure:s}=((e,t,i,n)=>{const r=e=>{const t=!!i&&e.place?.deref()===i;return t&&e.idx===n?4:e.live?0:t?3:2};let o=null,s=0,a=0,l=null;for(const i of e){if(i.owner===t)continue;l=i;const e=r(i);e<=0||(e>s?(o=i,s=e,a=1):e===s&&a++)}return!o||a>1?{slot:o||l,sure:!1}:{slot:o,sure:!0}})(n,this._warmGen,t,i);o&&(this._warmLongReturn=!!o.freed&&Date.now()-o.freed>=nc,this._booting=!1,this._bootFading=!1,this._hdrH=o.hdrH,this._bootSoft=!0,this.isConnected&&(clearTimeout(this._bootSoftTimer),this._bootSoftTimer=window.setTimeout(()=>{this._bootSoft=!1},rv)),this._warmKey=e,s?(clearTimeout(o.evict),o.evict=0,o.owner=this._warmGen,o.place=t?new WeakRef(t):null,o.idx=i,o.live=!0,this._warmSlot=o,this._warmVp=o.vp,o.frameFingerprint&&this._continuity.adoptCompleteFrame(o.frameFingerprint),!this._devices.length&&o.devices?.length&&(this._devices=[...o.devices]),this._warmAdoptViewport(this._config)):(this._warmSlot={owner:this._warmGen,path:location.pathname,place:t?new WeakRef(t):null,idx:i,live:!0,hdrH:o.hdrH,stageH:o.stageH,vp:null,frameFingerprint:"",devices:null,dlg:null,freed:0,evict:0},n.push(this._warmSlot),this._warmTrim(n)))}_warmIdx(e){const t=e?.children;if(!t)return-1;for(let e=0;e4;){const t=e.findIndex(e=>!e.live);if(t<0)break;clearTimeout(e[t].evict),e.splice(t,1)}}_warmScheduleEvict(e,t){if(clearTimeout(e.evict),!(e.dlg||e.vp&&"view"!==e.vp.mode))return;const i=e.freed,n=e.owner;e.evict=window.setTimeout(()=>{if(e.evict=0,e.freed!==i||e.owner!==n)return;var r;e.dlg=null,e.vp=(r=e.vp)&&"view"!==r.mode?{...r,mode:"view",zoom:r.snap?.space===r.space?r.snap.zoom:r.zoom,view:null,snap:null,tool:"draw",decorTool:"select",showHidden:!1,selId:null,rszSel:null,decorSel:null}:r,e.frameFingerprint="";const o=ov.get(t);if(!e.live&&o&&o.length>1){const t=o.indexOf(e);t>=0&&o.splice(t,1)}},av+250)}_warmAdoptViewport(e){const t=this._warmVp;if(!t||this._warmSlot?.path!==location.pathname)return void(this._warmVp=null);const i=this._fixedFloorState();if(this._hashApplied||!this._model.find(e=>e.id===t.space)||"valid"===i.kind&&i.id!==t.space||this._hasFixedFloor&&"valid"!==i.kind)return void(this._warmVp=null);this._commitSpace(t.space,!0),this._navApplied=!0;const n="view"!==t.mode&&this._canEdit&&!e.kiosk?t.mode:"view";this._adoptMode("view"),this._pendingNavMode="view"===t.mode||this._canEdit||e.kiosk?null:t.mode,this._zoom=t.zoom;const r=this._effectiveProjection(),o=r===t.projection&&this._labsIso===t.activeLabsIso;if(this._view=o&&t.view?{...t.view}:null,this._viewModeSnap=o&&t.snap?{...t.snap}:null,!o&&t.logicalCenter){const e="iso"===r?lf([t.logicalCenter.x,t.logicalCenter.y],0):[t.logicalCenter.x,t.logicalCenter.y];this._applyView(t.zoom,e[0],e[1])}var s;this._tool="opening"===(s=function(e){return"partition"===e?"draw":e}(s=t.tool))?"draw":"string"==typeof s&&Rf.has(s)?s:"draw",this._decorTool=t.decorTool,this._showHidden=t.showHidden,this._showFar!==t.showFar&&(this._showFar=t.showFar,this._frame=null),this._selId=t.selId,this._resize?.restoreSelection(t.rszSel),this._decorSel=t.decorSel,this._warmVpArmed=!0,"view"!==n&&this._requestMode(n,!1,!0)}_warmPatch(e,t=!1){if(this._config?.kiosk)return;const i=Cf(this._config);if(!this._warmSlot||this._warmKey===i){if(!this._warmSlot){if(!t)return;const e=this.parentNode;this._warmKey=i,this._warmSlot={owner:this._warmGen,path:location.pathname,place:e?new WeakRef(e):null,idx:this._warmIdx(e),live:!0,hdrH:this._hdrH,stageH:0,vp:null,frameFingerprint:"",devices:null,dlg:null,freed:0,evict:0};const n=ov.get(i)||[];for(n.push(this._warmSlot),ov.set(i,n),this._warmTrim(n);ov.size>8;){const e=ov.keys().next().value;if(void 0===e||e===i)break;for(const t of ov.get(e)||[])clearTimeout(t.evict);ov.delete(e)}}Object.assign(this._warmSlot,e)}}_warmViewportState(){const e=this._effectiveProjection();return{space:this._space,mode:this._mode,projection:e,activeLabsIso:this._labsIso,logicalCenter:this._logicalViewCenter(e),zoom:this._zoom,view:this._view?{...this._view}:null,snap:this._viewModeSnap?{...this._viewModeSnap}:null,tool:this._tool,decorTool:this._decorTool,showHidden:this._showHidden,showFar:this._showFar,selId:this._selId,rszSel:this._resize?.selectedRoomId,decorSel:this._decorSel}}_warmDialogState(){const e=(e,t)=>({kind:e,space:this._space,mode:this._mode,data:t});return this._tapConfirm||this._alignDialog||this._mergeDialog||this._importDialog||this._backupExportDialog||this._backupImportDialog?null:this._openingInfo?e("openingInfo",this._openingInfo.id):this._infoCard?e("info",this._infoCard.id):this._rulesDialog?this._rulesDialog.busy?null:e("rules",this._rulesDialog):this._settingsDialog?this._settingsDialog.busy?null:e("settings",this._settingsDialog):this._markerDialog?this._markerDialog.busy?null:e("marker",this._markerDialog):this._openingDialog?e("opening",this._openingDialog):this._backdropDialog?e("backdrop",this._backdropDialog):this._decorShapeDialog?e("decorShape",this._decorShapeDialog):this._decorTextDialog?e("decorText",this._decorTextDialog):this._roomDialog?e("room",{editId:this._roomEditId,fill:this._roomFill,customFill:this._roomCustomFill,tempMin:this._roomTempMin,tempMax:this._roomTempMax,tempSrc:this._roomTempSrc,humSrc:this._roomHumSrc,srcOpen:this._roomSrcOpen,srcFilter:this._roomSrcFilter,nameScale:this._roomNameScale,labelScale:this._roomLabelScale,areaSel:this._areaSel,nameSel:this._nameSel,pendingSplit:this._pendingSplit,wallFaceBatch:this._wallFaceBatch,path:this._path}):this._spaceDialog?this._spaceDialog.busy?null:e("space",this._spaceDialog):null}_warmSnapshot(){if(this._booting||this._config?.kiosk||"steady"!==this._continuity.state)return;const e={vp:this._warmViewportState(),frameFingerprint:this._continuity.frameFingerprint,devices:this._devices,hdrH:this._hdrH};if(this._warmRevivePending||(e.dlg=this._warmDialogState()),this.isConnected&&this._warmSlot?.owner===this._warmGen){const t=this.parentNode;e.place=t?new WeakRef(t):null,e.idx=this._warmIdx(t)}this._warmPatch(e)}_warmReviveDialog(){const e=this._warmSlot;if(this._warmReviveTimer=void 0,!e||!e.dlg)return void(this._warmRevivePending=!1);const t=e.dlg,i=e.freed;if(t.mode===this._mode||"view"===t.mode||this._warmVp?.mode!==t.mode||this._editorRuntime){if(this._warmRevivePending=!1,e.dlg=null,e.freed=0,clearTimeout(e.evict),e.evict=0,i&&!(Date.now()-i>av)&&t.space===this._space&&t.mode===this._mode){switch(t.kind){case"space":this._spaceDialog={...t.data,busy:!1,savedBusy:!1};break;case"marker":this._markerDialog={...t.data,busy:!1};break;case"settings":this._settingsDialog={...t.data,busy:!1};break;case"rules":this._rulesDialog={...t.data,busy:!1};break;case"opening":this._openingDialog={...t.data};break;case"backdrop":this._backdropDialog={...t.data};break;case"decorShape":this._decorShapeDialog={...t.data};break;case"decorText":{this._decorTextDialog={...t.data};const e=String(this._decorTextDialog?.text??"").length;this._decorTextSelection={start:e,end:e};break}case"room":{const e=t.data;this._roomEditId=e.editId,this._roomFill=e.fill,this._roomCustomFill=e.customFill||null,this._roomTempMin=e.tempMin||"",this._roomTempMax=e.tempMax||"",this._roomTempSrc=e.tempSrc,this._roomHumSrc=e.humSrc,this._roomSrcOpen=e.srcOpen,this._roomSrcFilter=e.srcFilter,this._roomNameScale=e.nameScale,this._roomLabelScale=e.labelScale,this._areaSel=e.areaSel,this._nameSel=e.nameSel,this._pendingSplit=e.pendingSplit,this._wallFaceBatch=e.wallFaceBatch||null,this._path=e.path,this._wallFaceBatch&&(this._activeWallChainId=`chain-${Date.now().toString(36)}`,this._activeWallChainPartitionIds=[...this._wallFaceBatch.activePartitionIds],this._wallChainSegmentCms=[...this._wallFaceBatch.activeCms]),this._roomDialog=!0;break}case"info":{const e=this._devices.find(e=>e.id===t.data);e&&(this._infoCard=e);break}case"openingInfo":{const e=(this._curSpaceCfg?.openings||[]).find(e=>e.id===t.data);e&&(this._openingInfo=e);break}}this.requestUpdate()}}else this._warmRevivePending=!0}_cacheSnapshot(){if(this._serverCfg)try{this._virtualLights=function(e,t,i){if(e.configRev===i)return e;const n=new Set((Array.isArray(t?.markers)?t.markers:[]).filter(qh).map(e=>e.id));return{...e,configRev:i,off:new Set([...e.off].filter(e=>n.has(e)))}}(this._virtualLights,this._serverCfg,this._cfgRev);const e=this._adoption.snapshot(function(e){return{rev:e.rev,config_rev:e.configRev,off:[...e.off].sort()}}(this._virtualLights));e&&localStorage.setItem(cv,JSON.stringify(e))}catch{}}_beginContinuityCandidate(e,t,i="plan"){return this._booting&&!this._continuity.hasCompleteFrame?this._continuity.token:(this._continuityDataReady=t,this._continuityPaintToken=-1,this._stagedDeviceSnapshotToken=-1,this._resumeSettling=!0,this._continuity.beginCandidate(e,i))}_continuityStageValid(){const e=this._stageEl;return!!e&&e.clientWidth>0&&e.clientHeight>0}_versionReloadSafetySnapshot(){return Sg(this)}_continuityAssetsReady(){if(!this._model.length)return!1;const e=this._model.length?this._spaceModel():null;return!e?.bg?.href||this._signer.isReady(this.hass,e.bg.href)}_initialSpaceSelection(e,t=this._loadOk){const i=this._fixedFloorState(e,t);return"valid"===i.kind?{id:i.id,source:"fixed"}:this._hasFixedFloor?{id:null,source:"none"}:function(e){const t=new Set(e.spaceIds.filter(e=>!!e));if(!t.size)return{id:null,source:"none"};const i=[["hash",!1===e.acceptHash?null:e.hashSpace],["current",e.preserveCurrent?e.currentSpace:null],["saved",e.savedSpace],["default",e.defaultSpace],["first",e.spaceIds[0]]];for(const[e,n]of i)if(n&&t.has(n))return{id:n,source:e};return{id:null,source:"none"}}({spaceIds:e.map(e=>e.id),hashSpace:this._hashSpace(),acceptHash:!this._hashApplied,currentSpace:this._space,preserveCurrent:this._hashApplied||this._navApplied||this._warmVpArmed,savedSpace:this._savedNav()?.space,defaultSpace:this._config?.default_floor})}_adoptInitialSpace(e,t=this._loadOk){const i=this._initialSpaceSelection(e,t);return i.id?(this._commitSpace(i.id,!0),"hash"===i.source&&(this._hashApplied=!0),"saved"===i.source&&(this._navApplied=!0),i):i}_candidateBackdrop(e,t=this._space){const i=el(e),n=this._fixedFloorState(i,!0);if(this._hasFixedFloor&&"valid"!==n.kind)return"";const r=this._initialSpaceSelection(i,!0).id||(i.some(e=>e.id===t)?t:i[0]?.id);return i.find(e=>e.id===r)?.bg?.href||""}_visualFrameFingerprint(){const e=this._stageEl,t=e?[e.clientWidth,e.clientHeight]:[0,0];return hc([this._cfgRev,this._adoption.currentConfigFingerprint(),this._layoutRev,this._adoption.currentLayoutFingerprint(),this._space,this._mode,this._view,t,this._glowScreenBlend?"screen":"normal",this.hass?.themes?.darkMode??this.hass?.themes?.default_theme??""])}_settleContinuityFrame(){if(this._booting||!this._continuityStageValid())return;if(!this._continuity.hasCompleteFrame&&"steady"===this._continuity.state)return void(this._continuityAssetsReady()&&(this._renderSnapshotAt=Date.now(),this._continuity.markCompleteFrame(this._visualFrameFingerprint())));if(!this._continuityDataReady)return;if(!["holding","offline-stale","overlay-pending","overlay-visible","candidate-ready"].includes(this._continuity.state))return;const e=this._continuity.token;if(this._candidateDeviceSnapshot&&this._candidateDeviceSnapshot!==this._visibleDeviceSnapshot&&this._stagedDeviceSnapshotToken!==e)return this._stagedDeviceSnapshotToken=e,void this.requestUpdate();this._continuityPaintToken!==e&&(this._continuityPaintToken=e,this._continuity.candidateReady(e)&&this._continuity.commitAfterPaint(e,{updateComplete:()=>this.updateComplete,stageValid:()=>this.isConnected&&this._continuityStageValid(),assetsReady:()=>this._continuityAssetsReady(),frameFingerprint:()=>this._visualFrameFingerprint()}).then(t=>{t&&e===this._continuity.token?(this._resumeSettling=!1,this._renderSnapshotAt=Date.now(),this._candidateDeviceSnapshot&&(this._visibleDeviceSnapshot=this._candidateDeviceSnapshot),this._candidateDeviceSnapshot=null,this._stagedDeviceSnapshotToken=-1,this._warmSnapshot()):e===this._continuity.token&&(this._continuityPaintToken=-1,this._stagedDeviceSnapshotToken=-1,this._candidateDeviceSnapshot=null,this.requestUpdate())}))}_onBackdropLoaded(e,t){this._signer.markLoaded(this.hass,e,t),this._continuity.note("asset-ready"),this._continuityPaintToken=-1,"steady"!==this._continuity.state&&this.requestUpdate()}_renderRecoveryOverlay(){if(!this._continuity.overlayVisible&&"recovery-error"!==this._continuity.state)return G;const e="connection"===this._continuity.recoveryReason;return j`
e.stopPropagation()} @click=${e=>e.stopPropagation()} @@ -363,7 +363,7 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db aria-label=${this._t("editor.loading_aria")}> ${this._t("editor.loading")} -
`:G}houseplanContinuityTrace(){return[...this._continuityHistory,...this._continuity.trace].slice(-80).map(e=>({...e,...e.stage?{stage:[...e.stage]}:{}}))}getCardSize(){return 12}getGridOptions(){return{columns:"full"}}get _norm(){return!(!this._serverCfg||!this._serverCfg.spaces.length)}_cfgFingerprint(){const e=this._serverCfg?.spaces||[];let t=e.length+":";for(const i of e){t+=(i.id||"")+","+(i.plan_aspect||"")+","+(i.plan_url||"").length+","+(i.plan_x??"")+","+(i.plan_y??"")+","+(i.plan_scale??"")+","+(i.plan_scale_x??"")+","+(i.plan_scale_y??"")+","+(i.plan_angle??"")+","+(i.rooms?.length||0)+","+(i.openings?.length||0)+","+(i.decor?.length||0)+";";for(const e of i.rooms||[]){const i=e.poly?.[0],n=e.poly?.[e.poly.length-1];t+=(e.poly?.length||0)+"."+(e.id||"")+"."+(e.open_to||[]).join("+")+"."+(e.area||"")+"."+JSON.stringify(e.settings||0)+"."+(e.x??"")+","+(e.y??"")+","+(e.w??"")+","+(e.h??"")+","+(i?i[0]+"/"+i[1]:"")+","+(n?n[0]+"/"+n[1]:"")+";"}}return t}get _model(){if(!this._serverCfg)return[];const e=this._cfgEpoch+"|"+this._cfgFingerprint();if(this._modelCache&&this._modelCache.key===e)return this._modelCache.model;const t=this._buildModel();return this._modelCache={key:e,model:t},t}_buildModel(){if(!this._serverCfg)return[];const e=this._renderCfg;return el(e).map((t,i)=>{const n=e.spaces[i]?.plan_url;return t.bg&&n?{...t,bg:{...t.bg,href:n}}:t})}_spaceModel(){return this._hasFixedFloor?kc(this._model,this._space):(e=this._model,t=this._space,e.find(e=>e.id===t)??e[0]);var e,t}_spaceModelById(e){return kc(this._model,e)}_syncEmptySpaceState(){if(!!this._serverCfg&&0===this._serverCfg.spaces.length){if(!this._emptySpaceStateActive){this._emptySpaceStateActive=!0,this._clearRoomFocus(!0);for(const e of this._pointers.keys())for(const t of this.renderRoot.querySelectorAll("*"))try{t.hasPointerCapture?.(e)&&t.releasePointerCapture(e)}catch{}this._pointers.clear(),this._panStart=null,this._panLock=null,this._pinchStart=null,this._swipeStart=null,this._drag=null,this._deviceDrag=null,this._resetDeviceHitState(),this._rlResize=null,this._vacFit=null,this._compassDrag=!1,this._cancelModeTransition(!1),this._mode="view",this._clearGeometryGesture(),this._geometryHistory.clear(),this._devicePositionHistory.clear(),this._tip=null,this._hoverRoom=null,this._openingInfo=null,this._closeInfoCard(),this._deviceInbox=null,this._deviceInboxReturn=null,this._markerDialog=null,this._physicalDialog=null,this._backdropDialog=null,this._decorShapeDialog=null,this._decorTextDialog=null,this._roomDialog=!1,"edit"===this._spaceDialog?.mode&&(this._spaceDialog=null),this._editorSecondary?.closeForNavigation(),this._saveConfigDebounced.cancel(),this._frame=null,this._planSnapGeometryCache=null,this._hiddenWallDiagnosticCache=null,this._decorSnapCache=null,this._commitSpace("",!0)}}else this._emptySpaceStateActive=!1}get _areaToSpace(){const e={};for(const t of this._model)for(const i of t.rooms)i.area&&(e[i.area]={space:t.id,room:i});return e}get _settings(){return this._serverCfg?.settings||{}}get _showAll(){return this._showHidden||!this._settings.filter_seeded&&!!this._settings.show_all}_seedHiddenDevices(){if(!(this._loadOk&&this._serverCfg&&this._norm&&this._canEdit))return;const e=this._serverCfg,t=eu({hass:this.hass,registry:this._haRegistry,areaToSpace:Object.fromEntries(Object.entries(this._areaToSpace).map(([e,t])=>[e,t.space])),markers:this._markers,settings:this._settings,excluded:this._excluded,firstSpaceId:this._model[0]?.id||"",iconRules:this._iconRules});if(!t.length&&e.settings?.filter_seeded)return;e.markers=e.markers||[];const i=[];for(const n of t){const t="h"+n.slice(n.indexOf(":")+1);e.markers.push({id:t,binding:n,hidden:!0}),i.push(n.slice(n.indexOf(":")+1))}const n={...e.settings||{},filter_seeded:!0};delete n.show_all,i.length&&Array.isArray(n.new_device_ids)&&(n.new_device_ids=n.new_device_ids.filter(e=>!i.includes(e))),e.settings=n,this._regSignature="",this._maybeRebuildDevices(),this._saveConfig(),this.requestUpdate()}get _iconRules(){const e=this._settings.icon_rules;if(!e||!Array.isArray(e)||!e.length)return;const t=JSON.stringify(e);return t!==this._rulesCompiledSrc&&(this._rulesCompiledSrc=t,this._rulesCompiled=Ee(e)),this._rulesCompiled}get _fillColors(){return vn(this._settings)}get _excluded(){return lu(this._settings)}_setAreaLifecycleConfig(e){this._cfgEpochPreservedConfig=e,this._serverCfg=e}willUpdate(e){if(this._isoProjectionSnapshot=null,this._summary?.willUpdate(),e.has("hass")&&this._configReloadAuthority.observeContext(Vu(this)),e.has("_serverCfg")){const e=this._cfgEpochPreservedConfig===this._serverCfg;this._cfgEpochPreservedConfig=null,e||this._cfgEpoch++,this._renderLife.invalidate()}if(this._syncEmptySpaceState(),this._dangerConfirm&&(this._dangerConfirmMissingSpace()||"warm"===this._syncDangerConfirmLocaleGate())&&this._cancelDangerConfirm(),e.has("hass")&&this.hass){const t=this._visibleDeviceSnapshot||this._candidateDeviceSnapshot;this._renderLife.observe(e.get("hass"),this.hass,t?{entityIds:t.entityIds}:null,()=>Mg(this))}this._continuity.hasCompleteFrame&&"steady"===this._continuity.state&&this._continuity.refreshCompleteFrame(this._visualFrameFingerprint()),this._captureRenderDeviceSnapshot()}updated(){this._summary?.updated(),this._liveRt?.commit(),this._editorRuntime?._commitLiveEditor(),this._pruneDevicePressFeedback(),this._syncDayCycleClock(),this._syncRadarLive(),this._warmSnapshot(),this._editorRuntime&&this._dtMeasure();const e=this._stageEl;e&&!this._roViewport&&(this._roViewport=new ResizeObserver(()=>{this._invalidateDeviceHitGeometry(),this._refitView(),requestAnimationFrame(()=>this._summary?.resized())}),this._roViewport.observe(e)),e&&this._booting&&!this._bootTimer&&this._bootWatch();const t=this.renderRoot.querySelector(".hdr");if(t&&e&&!this._roHdr){const i=()=>{const t=ef(this.renderRoot,e,this.panelHost);null!==t&&(t>=0&&t!==this._hdrH&&(this._hdrH=t),t>=0&&!this._booting&&!this._config?.kiosk&&e.clientHeight>0&&this._warmPatch({hdrH:t,stageH:e.clientHeight}))};this._roHdr=new ResizeObserver(()=>requestAnimationFrame(i)),this._roHdr.observe(t),this._onWinResize=()=>requestAnimationFrame(i),window.addEventListener("resize",this._onWinResize),i()}if(e&&!this._view&&this._refitView(),this._editorSecondary?.afterRender(),this._settleContinuityFrame(),this._serverStorage&&this._loadOk&&this._canManageConfiguration&&0===this._model.length&&!this._spaceDialog&&!this._importDialog&&!this._onboardingShown){this._onboardingShown=!0;const e=function(e){const t=e?.floors;if(!t||"object"!=typeof t)return[];const i=[];for(const e of Object.values(t))e&&e.floor_id&&i.push({id:e.floor_id,name:e.name||e.floor_id,level:e.level??null});return i.sort((e,t)=>{const i=e.level??1e9,n=t.level??1e9;return i!==n?i-n:e.name.localeCompare(t.name)}),i}(this.hass);e.length?this._importDialog={floors:e.map(e=>({...e,checked:!0}))}:this._openSpaceDialog("create")}}_adoptConfigCapabilities(e){xg(this,e)}_syncRadarLive(){const e=this._serverCfg?.settings?.radar,t=(this._serverCfg?.markers||[]).some(e=>Cg(e,this._space));this._radarLive.sync(this._space,1===this._haRadarStage1Api&&"view"===this._mode&&!1!==e?.show_live&&t&&"hidden"!==this.ownerDocument.visibilityState)}async _syncDecorAssets(e){const t=++this._decorAssetSyncToken;if(1!==this._haDecorAssetsApi||!this.hass)return void(this._decorAssets=new Map);const i=await um(this.hass,cm(e),this._cfgRev);t===this._decorAssetSyncToken&&(this._decorAssets=i,this._resign(),this.requestUpdate())}_adoptAuthoritative(e){return ju(this,e)}_rollbackOptimistic(e){const t=this._adoption.rollbackOptimistic(e);return t&&this.requestUpdate(),t}_resumePendingNavMode(){if(!this._pendingNavMode||!this._canEdit||this._config?.kiosk)return!1;const e=this._pendingNavMode;return this._pendingNavMode=null,this._setMode(e,!1),!0}_getAuthoritativeConfig(){return e=this,async function(e,t){const i=await e();return t(i),i}(()=>e.hass.callWS({type:"houseplan/config/get"}),t=>xg(e,t));var e}async _loadFromServer(){this._loading=!0,this._loadTries++;const e=this._space,t=!!this._view;let i=!1;const n=()=>{i=!0,this._regSignature="",this._maybeRebuildDevices()};try{const[i,r]=await Promise.all([this._getAuthoritativeConfig(),this.hass.callWS({type:"houseplan/layout/get"})]);if("adopted"!==(await this._adoptAuthoritative({cfgResp:i,layResp:r,reason:"structural-response",profile:"reload",beforeAdopt:()=>{this._connectionWasLost=!1,this._serverStorage=!0},afterAdopt:()=>{this._warmVpArmed&&this._space===this._warmVp?.space?this._warmVpArmed=!1:t&&this._space===e||this._restoreZoom(),this._loadOk=!0,n()}})).status)return;this.hass.callWS({type:"houseplan/trail/get"}).then(e=>{this._vacSrvTrails=e?.trails||{},this.requestUpdate()}).catch(()=>{}),this._ensureLiveSyncSubscriptions()}catch(e){if(this._serverCfg)this._scheduleLoadRetry(!0);else if(this._loadTries>=8){this._serverStorage=!1;try{this._layout=JSON.parse(localStorage.getItem(lv)||"{}")||{}}catch{this._layout={}}}}finally{this._loading=!1,this._continuityDataReady=!0,i||n(),this.requestUpdate()}}_ensureLiveSyncSubscriptions(){const e=this.hass?.connection;if(!e)return;if(e!==this._liveSyncConnection&&(this._unsubCfg?.(),this._unsubCfg=null,this._unsubLayout?.(),this._unsubLayout=null,this._unsubTrail?.(),this._unsubTrail=void 0,this._unsubVirtual?.(),this._unsubVirtual=null,this._liveSyncGeneration++,this._liveSyncAttempt=null,this._liveSyncConnection=e),this._liveSyncAttempt)return;const t=this._liveSyncGeneration,i=[],n=(n,r,o,s)=>{n()||i.push(async()=>{const i=await e.subscribeEvents(s,o);t===this._liveSyncGeneration&&this.isConnected&&this.hass?.connection===e&&!n()?r(i):i?.()})};if(n(()=>this._unsubCfg,e=>{this._unsubCfg=e},"houseplan_config_updated",e=>{const t=Number(e?.data?.rev??-1);t!==this._cfgRev&&this._reloadConfigOnly(!1,t)}),n(()=>this._unsubTrail,e=>{this._unsubTrail=e},"houseplan_trail_updated",async()=>{try{const e=await this.hass.callWS({type:"houseplan/trail/get"});this._vacSrvTrails=e?.trails||{},this.requestUpdate()}catch{}}),n(()=>this._unsubLayout,e=>{this._unsubLayout=e},"houseplan_layout_updated",e=>this._onLayoutEvent(Number(e?.data?.rev??-1))),n(()=>this._unsubVirtual,e=>{this._unsubVirtual=e},"houseplan_virtual_light_updated",e=>{const t=Wh(this._virtualLights,e?.data);t!==this._virtualLights&&(this._virtualLights=t,this._capturedSnapshotVirtual="",this._cacheSnapshot(),this.requestUpdate())}),!i.length)return;const r=function(e){return Promise.allSettled(e.map(e=>Promise.resolve().then(e)))}(i).then(()=>{});this._liveSyncAttempt=r,r.finally(()=>{this._liveSyncAttempt===r&&(this._liveSyncAttempt=null)})}async _reloadConfigOnly(e=!1,t){return Ku(this,e,t)}_scheduleLoadRetry(e=!1){if(void 0!==this._loadRetryTimer)return;const t=Math.min(8e3,500*2**Math.min(4,Math.max(1,this._loadTries-7)));this._loadRetryTimer=window.setTimeout(()=>{this._loadRetryTimer=void 0,!e&&this._loadOk||this._loading||!this.hass||this._loadFromServer()},t)}async _ensureLiveRuntime(){if(this._liveRt)return;const e=await import("./live-interaction-runtime-C7FQnbBF.js");this._liveRt=new e.LiveRuntime(this),this.isConnected&&this.requestUpdate()}_liveVp(e=!1){this._liveRt?this._liveRt.viewport(e):this.requestUpdate()}_syncLiveHover(){this._liveRt?this._liveRt.hover():this.requestUpdate()}_flushHa(){this._liveRt?.take()&&(this._terminalFrame=2,super.requestUpdate())}_ensureHaRegistryAuthority(){const e=this.hass?.connection||null;e&&e!==this._haRegistryConnection&&(this._haRegistryRelease?.(),this._haRegistryConnection=e,this._haRegistryRev=-1,this._haBindingCacheKey="",this._renderLife.invalidate(),this._areaSnapshotCleanupCandidates.clear(),this._planHassMemo=null,this._haRegistryRelease=td(this.hass,this._onHaRegistryUpdate),this._onHaRegistryUpdate())}get _haRegistry(){return nd(this.hass)}get _planHass(){const e=this._haRegistry,t=od(this.hass,e),i=this._planHassMemo;if(i&&i.hass===this.hass&&i.sig===t)return i.active;const n=ad(this.hass,e),r=ld(this.hass,e);return this._planHassMemo={hass:this.hass,sig:t,active:n,full:r},n}_captureRenderDeviceSnapshot(){if(!this.hass)return;const e=Date.now(),t=[...this._activityRt.entries()].map(([t,i])=>`${t}:${i.gen}:${i.flashTs}:`+(i.flashKind&&(i.expiresAt||i.flashTs+tg)>e?1:0)).join("|"),i=Bh(this._virtualLights);if(this._capturedSnapshotSequence===this._hassSequence&&this._capturedSnapshotDevices===this._devices&&this._capturedSnapshotLayout===this._layout&&this._capturedSnapshotConfigEpoch===this._cfgEpoch&&this._capturedSnapshotVirtual===i&&this._capturedSnapshotActivity===t)return;const n=this._planHass,r=new Map,o=new Map,s=new Set(["sun.sun"]);for(const e of this._summary?.entityIds()||[])s.add(e);this._vacFit?.source&&s.add(this._vacFit.source);const a=new Set,l=new Set,c=e=>{if(!e)return;const t=e.indexOf(":");if(t<0)return void s.add(e);const i=e.slice(0,t),n=e.slice(t+1);"device"===i?a.add(n):"entity"===i&&s.add(n)};for(const e of this._model)for(const t of e.rooms)t.area&&l.add(t.area),c(t.settings?.temp_source),c(t.settings?.hum_source);for(const e of this._serverCfg?.spaces||[])for(const t of e.openings||[])for(const e of ui(t))s.add(e);for(const e of this._serverCfg?.spaces||[])for(const t of e.decor||[])if("text"===t.kind){for(const e of String(t.text||"").matchAll(/\{([^{}\r\n]+)\}/g)){const t=Xi(e[1]);t?.entity&&s.add(t.entity)}t.entity&&s.add(t.entity),o.set(`decor:${e.id}:${t.id}`,tn(t.text,t,n,e=>!!n.entities?.[e]&&!!n.states?.[e]&&!Jd(n,e,Zd(this._markers))))}const h=Ed(n,this._devices,null,this._virtualLights);for(const e of this._devices){for(const t of[!1,!0])r.set(f_(e.id,t),p_(n,e,{liveStates:!1!==this._config?.live_states,showTemperature:!1!==this._config?.show_temperature,showSignal:t,activityRuntime:this._activityRt.get(e.id),sourceDetails:!1,lightDevices:this._devices,lightSources:h,registryHass:this._fullRegistryHass,reducedMotion:this._reducedMotion}));if(this._isVacDev(e)){const t=this._vacSource(e,n),i=t?Wc(n?.states?.[t]?.attributes):null,r=this._vacRt.get(e.id),s=lh(e.id,e.marker?.vacuum??null,e.space,t),a=hh({routes:s,observed:dh(s,[t],t=>this._vacObservedMapId(e,t,n)),spaceIds:new Set(this._model.map(e=>e.id))});o.set(`vacuum:${e.id}`,{source:t,telemetry:i,routes:s,resolution:a,mapId:i?this._vacMapId(e,i,n):null,runtime:r?{trail:r.trail,lastTs:r.lastTs,moving:r.moving,jump:r.jump}:null,server:this._vacSrvTrails[e.id]||null})}}const d=g_({sourceSequence:this._hassSequence,hass:n,devices:this._devices,presentations:r,positions:(u=this._model.length>0,p=this._devices,_=e=>this._livePos(e),u?new Map(p.map(e=>[e.id,_(e)])):new Map),facts:o,entityIds:s,deviceIds:a,areaIds:l});var u,p,_;this._capturedSnapshotSequence=this._hassSequence,this._capturedSnapshotDevices=this._devices,this._capturedSnapshotLayout=this._layout,this._capturedSnapshotActivity=t,this._capturedSnapshotConfigEpoch=this._cfgEpoch,this._capturedSnapshotVirtual=i,this._visibleDeviceSnapshot&&"steady"!==this._continuity.state?this._candidateDeviceSnapshot=d:(this._visibleDeviceSnapshot=d,this._candidateDeviceSnapshot=null)}get _renderDeviceSnapshot(){return this._stagedDeviceSnapshotToken===this._continuity.token?this._candidateDeviceSnapshot||this._visibleDeviceSnapshot:this._visibleDeviceSnapshot||this._candidateDeviceSnapshot}get _renderPlanHass(){return this._renderDeviceSnapshot?.hass||this._planHass}get _renderDevices(){return this._renderDeviceSnapshot?.devices||this._devices}get _renderVacuumDevices(){return this._renderDeviceSnapshot?.vacuumDevices||this._devices}get _fullRegistryHass(){return this._planHass,this._planHassMemo?.full||this.hass}_bindingStatus(e){return dd(this.hass,e,this._haRegistry)}houseplanDiagnostics(){const{registry:e,bindings:t}=this._renderLife.diagnostics(this.hass,this._markers,e=>this._bindingStatus(e));return{registry:{...e,lastSuccessAgeMs:e.lastSuccess?Math.max(0,Date.now()-e.lastSuccess):null},bindings:t}}_openBindingInHa(e){const[t,i]=e.split(":");if(i)if("device"!==t){if("entity"===t){const e=this._fullRegistryHass.entities?.[i];e?.device_id&&fv("/config/devices/device/"+encodeURIComponent(e.device_id))}}else fv("/config/devices/device/"+encodeURIComponent(i))}_bindingHasHaPage(e){const[t,i]=e.split(":");return!!i&&("device"===t||"entity"===t&&!!this._fullRegistryHass.entities?.[i]?.device_id)}_toggleMarkerDialogVisibility(){const e=this._markerDialog;if(!e)return;const t="ha"===e.bindingMode?this._bindingStatus(e.binding):null,i=e.hideFromPlan||"ha_disabled"===t?.kind;i&&"ha_disabled"===t?.kind?this._showToast(this._t("entity"===t.reason?"toast.ha_disabled_show_entity":"toast.ha_disabled_show_device")):i&&"unverified"===t?.kind?this._showToast(this._t("toast.ha_binding_unverified")):this._markerDialog={...e,hideFromPlan:!i}}_hookConnection(){const e=this.hass?.connection;e&&e!==this._connHooked&&(this._connHooked?.removeEventListener?.("ready",this._onConnReady),this._connHooked?.removeEventListener?.("disconnected",this._onConnLost),this._connHooked?.removeEventListener?.("reconnect-error",this._onConnLost),e.addEventListener?.("ready",this._onConnReady),e.addEventListener?.("disconnected",this._onConnLost),e.addEventListener?.("reconnect-error",this._onConnLost),this._connHooked=e)}_display(e){return this._signer.display(this.hass,e)}_referencedContentUrls(){const e=Nn(this._serverCfg);for(const t of this._decorAssets.values())e.add(t.url);return e}_resign(){this._signer.resign(this.hass,this._referencedContentUrls())}_onLayoutEvent(e){e<=this._layoutRev||(clearTimeout(this._layoutSyncTimer),this._layoutSyncTimer=window.setTimeout(()=>{e<=this._layoutRev||this._reloadLayoutOnly()},200))}_noteLayoutRev(e){this._adoption.noteLayoutRevision(e?.rev)}async _reloadLayoutOnly(){if(!this._serverStorage||!this.hass?.callWS)return;this._beginContinuityCandidate("layout-reload",!1);const e=new Map;for(const t of this._dirtyPos)this._layout[t]&&e.set(t,this._layout[t]);this._persistLayout.pending()&&this._persistLayout.flush();for(const[t,i]of this._sentPos)e.set(t,i);try{const t=await this.hass.callWS({type:"houseplan/layout/get"}),i={...t?.layout||{}};for(const[t,n]of e)null===n?delete i[t]:i[t]=n;this._adoption.adoptMergedLayout(i,t,()=>{this._cancelDeviceDrag(),this._devicePositionHistory.clear()}),this._canOptimizeUndo=!!t?.can_optimize_undo,this._undoKind=t?.undo_kind||null,this._cacheSnapshot(),this.requestUpdate()}catch{}finally{this._continuityDataReady=!0,this.requestUpdate()}}_persistLocalLayout(){this._layout=So(lo(this._layout)),localStorage.setItem(lv,JSON.stringify(this._layout))}_maybeRebuildDevices(){const e=this.hass;if(!e?.devices||!e?.entities||!e?.areas)return;const t=this._haRegistry,i=od(e,t)+":"+Object.keys(e.areas).length+":"+(this._norm?"n":"l")+":"+kp(e,this._config?.language);if(i===this._regSignature&&this._devices.length)return;this._regSignature=i;const n=new Map(this._devices.map(e=>[e.id,e.bindingStatus?.kind||"active"]));this._devices=iu({hass:e,registry:t,areaToSpace:Object.fromEntries(Object.entries(this._areaToSpace).map(([e,t])=>[e,t.space])),markers:this._markers,settings:this._settings,excluded:this._excluded,showAll:this._showAll,firstSpaceId:this._model[0]?.id||"",loc:e=>this._t(e),iconRules:this._iconRules});const r=this._markers.filter(e=>!e.removed&&"virtual"!==e.binding).map(e=>e.binding).sort(),o=t.revision+":"+r.join("|");if(t.authoritative&&o!==this._haBindingCacheKey){const i=new Map;for(const n of r)i.set(n,dd(e,n,t));!function(e){if("undefined"==typeof localStorage||!e.size)return;const t=hd(),i=Date.now();for(const[n,r]of e)"active"===r.kind?t[n]={kind:"active",ts:i}:"ha_disabled"===r.kind&&(t[n]={kind:"ha_disabled",reason:r.reason,ts:i});const n=Object.fromEntries(Object.entries(t).sort((e,t)=>t[1].ts-e[1].ts).slice(0,1500));Yh=n;try{localStorage.setItem(Kh,JSON.stringify(n))}catch{}}(i),this._haBindingCacheKey=o}let s=null;if(t.authoritative&&(s=this._resolveAreaRelocations(t),this._areaRelocationIds=new Set(s.relocateIds),this._areaRelocationIds.size)){this._cancelDeviceDrag();const e=this._areaRelocationIds;this._devicePositionHistory.removeWhere(({before:t,after:i})=>e.has(t.deviceId)||e.has(i.deviceId));const t=this._markerDialog;if(t?.devId&&!t.roomTouched&&this._areaRelocationIds.has(t.devId)){const e=this._devices.find(e=>e.id===t.devId);e&&(this._markerDialog={...t,room:e.marker?.room_id?`${e.space}#@${e.marker.room_id}`:e.space&&e.area?`${e.space}#${e.area}`:""})}}this._defPos=this._defaultPositions(),this._syncNewDevices(),this._seedHiddenDevices(),s&&this._syncAreaRelocations(s),this._syncActivityRuntime();const a=new Set(this._devices.filter(e=>!e.hidden).map(e=>e.id));for(const e of this._vacRt.keys())a.has(e)||this._vacRt.delete(e);if(this._infoCard){const e=this._devices.find(e=>e.id===this._infoCard.id);this._infoCard=e&&"ha_disabled"!==e.bindingStatus?.kind?e:null}const l=this._devices.some(e=>"ha_disabled"===e.bindingStatus?.kind&&"ha_disabled"!==n.get(e.id));l&&("ha_disabled"!==this._infoCard?.bindingStatus?.kind&&"ha_disabled"!==this._devices.find(e=>e.id===this._infoCard?.id)?.bindingStatus?.kind||this._closeInfoCard(),this._deviceDrag&&"ha_disabled"===this._devices.find(e=>e.id===this._deviceDrag.id)?.bindingStatus?.kind&&(this._cancelDeviceDrag(),this._devicePositionHistory.clear()),clearTimeout(this._holdTimer),this._holdFired=!1,this._tip=null,this._tapConfirm=null),this._nativeMoreInfoEntity&&!this._planEntityAvailable(this._nativeMoreInfoEntity)&&(gv(this,"hass-more-info",{entityId:null}),this._nativeMoreInfoEntity=null)}_resolveAreaRelocations(e=this._haRegistry){const t=function(e){const t=Q_(e.snapshot),i=new Set(Object.values(t).map(e=>e.binding)),n=new Map;for(const[t,r]of e.previousCandidates||[])J_(t)&&Number.isFinite(r)&&i.has(t)&&n.set(t,r);const r=new Set,o=new Set;for(const t of e.markers||[])t.removed||(Z_(t.id)&&r.add(t.id),J_(t.binding)&&o.add(t.binding));const s=new Set(Object.keys(e.registryDevices||{})),a=new Set(Object.keys(e.registryEntities||{})),l=new Set(Object.keys(e.liveStates||{})),c=new Map;for(const[e,i]of Object.entries(t)){const t=c.get(i.binding)||[];t.push(e),c.set(i.binding,t)}const h=new Set;let d=!1;for(const[t,i]of c){const[c,u]=rm(t);if(o.has(t)||i.some(e=>r.has(e))||("device"===c?s.has(u):a.has(u)||l.has(u))){n.delete(t);continue}const p="device"===c?s.size>0:a.size>0;if(!e.authoritative||!p)continue;const _=n.get(t);if(void 0!==_){if(_!==e.revision)for(const e of i)h.add(e)}else n.set(t,e.revision),d=!0}return{removeIds:h,candidates:n,needsConfirmationRefresh:d}}({snapshot:this._settings.marker_area_snapshot,authoritative:e.authoritative,revision:e.revision,registryDevices:e.devices,registryEntities:e.entities,liveStates:this.hass?.states,markers:this._markers,previousCandidates:this._areaSnapshotCleanupCandidates});return this._areaSnapshotCleanupCandidates=t.candidates,t.needsConfirmationRefresh&&this._canEdit&&id(this.hass),om({devices:this._devices,model:this._model,layout:this._layout,snapshot:this._settings.marker_area_snapshot,authoritative:e.authoritative,cleanupSnapshotIds:t.removeIds,coordinateScale:_v})}_syncNewDevices(){if(!this._norm||!this._loadOk||!this._serverCfg)return;const e=this._devices.filter(e=>!e.marker&&!e.virtual).map(e=>e.id).sort(),t=e.join(",");if(t===this._newSyncKey)return;this._newSyncKey=t;const i=this._settings,{fresh:n,known:r}=function(e,t){if(!Array.isArray(t))return{fresh:[],known:[...e]};const i=new Set(t),n=e.filter(e=>!i.has(e));return{fresh:n,known:n.length?[...t,...n]:t}}(e,i.known_devices);if(!Array.isArray(i.known_devices)||n.length){const e=[...new Set([...i.new_device_ids||[],...n])];this._serverCfg={...this._serverCfg,settings:{...i,known_devices:r,new_device_ids:e}},this._saveConfig()}}_syncAreaRelocations(e){if(!(this._loadOk&&this._serverCfg&&this._norm&&this._canEdit&&this._haRegistry.authoritative))return;const t=e.decisions.filter(e=>e.updateSnapshot||e.removeSnapshot);if(!t.length)return;const i=cc({snapshot:Q_(this._settings.marker_area_snapshot),decisions:t});i!==this._areaRelocationSyncKey&&(this._areaRelocationSyncKey=i,this._areaRelocationWrite=this._areaRelocationWrite.catch(()=>{}).then(async()=>{if(!this._serverCfg||!this._haRegistry.authoritative)return;const e=this._resolveAreaRelocations();this._areaRelocationIds=new Set(e.relocateIds);const t=new Set,i=new Map;let n=!1;for(const r of e.decisions){if(!r.relocate)continue;const e=fg(this._layout,r.id);try{await this._persistDevicePlacement(r.id,null),t.add(r.id),e&&i.set(r.id,e),this._areaRelocationIds.delete(r.id)}catch(t){n=!0,this._layout=vg(this._layout,r.id,e),this._showToast(this._t("toast.pos_save_failed",{err:this._errText(t)}))}}const r=this._settings,o=function(e,t,i=new Set){const n=Q_(e);for(const e of t.decisions)e.removeSnapshot?delete n[e.id]:e.updateSnapshot&&e.binding&&e.area&&(e.relocate&&!i.has(e.id)||(n[e.id]={binding:e.binding,area:e.area}));return n}(r.marker_area_snapshot,e,t),s=[...new Set([...Array.isArray(r.new_device_ids)?r.new_device_ids:[],...t])],a=cc(o)!==cc(Q_(r.marker_area_snapshot)),l=cc(s)!==cc(Array.isArray(r.new_device_ids)?r.new_device_ids:[]);if(a||l){const e=r.marker_area_snapshot,n=r.new_device_ids,a={...this._serverCfg,settings:{...r,marker_area_snapshot:o,...l?{new_device_ids:s}:{}}};this._setAreaLifecycleConfig(a);try{this._saveConfigDebounced.pending()&&this._saveConfigDebounced.cancel(),await this._writeConfig()}catch(r){const a=this._settings;if(cc(a.marker_area_snapshot)===cc(o)&&cc(a.new_device_ids)===cc(l?s:n)){const t={...a};void 0===e?delete t.marker_area_snapshot:t.marker_area_snapshot=e,void 0===n?delete t.new_device_ids:t.new_device_ids=n;const i={...this._serverCfg,settings:t};this._setAreaLifecycleConfig(i),this._adoption.refreshConfigFingerprint()}for(const e of t)this._areaRelocationIds.add(e);const c=new Set;for(const[e,t]of i)try{await this._persistDevicePlacement(e,t)}catch(t){c.add(e),this._showToast(this._t("toast.pos_save_failed",{err:this._errText(t)}))}this._areaRelocationSyncKey="",this._regSignature="";if("conflict"===(r&&"object"==typeof r&&"code"in r?r.code:void 0)?(this._showToast(this._t("toast.conflict")),await this._reloadConfigOnly(!0)):this._showToast(this._t("toast.cfg_save_failed",{err:this._errText(r)})),c.size&&this._serverCfg){const e=this._settings,t=[...new Set([...Array.isArray(e.new_device_ids)?e.new_device_ids:[],...c])],i={...this._serverCfg,settings:{...e,new_device_ids:t}};this._setAreaLifecycleConfig(i);try{await this._writeConfig()}catch(e){this._showToast(this._t("toast.cfg_save_failed",{err:this._errText(e)}))}}}}n&&(this._areaRelocationSyncKey=""),this.requestUpdate()}))}get _newIds(){const e=this._settings.new_device_ids;return new Set([...Array.isArray(e)?e:[],...this._areaRelocationIds])}_ackNewDevice(e){if(!this._newIds.has(e)||!this._serverCfg)return;const t=this._settings;this._serverCfg={...this._serverCfg,settings:{...t,new_device_ids:(t.new_device_ids||[]).filter(t=>t!==e)}},this._saveConfig(),this.requestUpdate()}get _markers(){return this._serverCfg?.markers||[]}_roomLqi(e){if(!e)return null;const t=[];for(const i of this._renderDevices){if(i.area!==e||i.virtual)continue;const n=Ld(this._renderPlanHass,i.entities);null!=n&&t.push(n)}return Ii(t)}_roomBounds(e){if(e.poly&&e.poly.length){const t=e.poly.map(e=>e[0]),i=e.poly.map(e=>e[1]),n=Math.min(...t),r=Math.min(...i);return{x:n,y:r,w:Math.max(...t)-n,h:Math.max(...i)-r}}return{x:e.x??0,y:e.y??0,w:e.w??0,h:e.h??0}}_defaultPositions(){const e={},t=this._config?.icon_size??2.5;for(const i of this._model){const n=t/100*Ml(i)*1.3;for(const t of i.rooms){if(!t.area)continue;const r=this._devices.filter(e=>e.area===t.area&&e.space===i.id);if(!r.length)continue;const o=this._roomBounds(t),s=.1*Math.min(o.w,o.h),a=o.w-2*s,l=o.h-2*s,c=Math.max(1,Math.round(Math.sqrt(r.length*a/Math.max(l,1)))),h=Math.ceil(r.length/c),d=a/c,u=l/Math.max(h,1),p=r.map((e,t)=>({x:o.x+s+d*(t%c+.5),y:o.y+s+u*(Math.floor(t/c)+.5)}));Ei(p,o,n,.5*s),r.forEach((t,i)=>e[t.id]=al(p[i]))}}return e}_pos(e){const t=this._renderDeviceSnapshot?.positions.get(e.id);return t?{x:t.x,y:t.y}:this._livePos(e)}_livePos(e){const t=this._spaceModelById(e.space),i=this._areaRelocationIds.has(e.id)?void 0:this._layout[e.id];if(i)if(this._norm){if(i.s===e.space)return{x:i.x*_v,y:i.y*_v}}else if(void 0===i.s)return{x:i.x,y:i.y};return this._defPos[e.id]?this._defPos[e.id]:t?al($l(t)):{x:500,y:500}}_devicePlacementForCanvas(e,t,i){if(!this._norm)return{x:Math.round(t),y:Math.round(i)};const n=this._gridPitch,r=Math.round(t/n)*n,o=Math.round(i/n)*n;return{s:e.space,x:cl(r/_v),y:cl(o/_v)}}_previewDevicePlacement(e,t){this._layout=vg(this._layout,e,t),this.requestUpdate()}_cancelDeviceDrag(){const e=this._deviceDrag;if(!e)return!1;this._editorRuntime?._cancelPointerMove("device"),this._deviceDrag=null,this._deviceHits.cancel(e.pointerId);try{e.source?.hasPointerCapture?.(e.pointerId)&&e.source.releasePointerCapture(e.pointerId)}catch{}return this._previewDevicePlacement(e.id,e.before),!0}async _persistDevicePlacement(e,t){if(this._layout=vg(this._layout,e,t),this._serverStorage){let i=null,n=!1;try{let r;if(null===t)i=null,this._sentPos.set(e,i),n=!0,r=await this.hass.callWS({type:"houseplan/layout/delete",device_id:e});else{const t=xo(this._layout[e]);cc(t)!==cc(this._layout[e])&&(this._layout={...this._layout,[e]:t}),i=t,this._sentPos.set(e,i),n=!0,r=await this.hass.callWS({type:"houseplan/layout/update",device_id:e,pos:t})}this._noteLayoutRev(r),this._adoption.refreshLayoutFingerprint(),this._cacheSnapshot()}finally{n&&this._sentPos.get(e)===i&&this._sentPos.delete(e)}return}this._persistLocalLayout()}_devicePositionStateValid(e){const t=this._devices.find(t=>t.id===e.deviceId);return!!t&&t.space===e.spaceId&&"ha_disabled"!==t.bindingStatus?.kind&&!!this._spaceModelById(e.spaceId)}async _runDevicePositionHistory(e){if(this._cancelDeviceDrag()||this._devicePositionBusy)return;const t="undo"===e?this._devicePositionHistory.undo():this._devicePositionHistory.redo();if(!t)return;const i="undo"===e?t.before:t.after;if(!this._devicePositionStateValid(i))return this._devicePositionHistory.clear(),this._showToast(this._t("history.device_stale")),void this.requestUpdate();const n=fg(this._layout,i.deviceId);i.spaceId!==this._space&&(this._commitSpace(i.spaceId),this._restoreZoom()),this._devicePositionBusy=!0,this._previewDevicePlacement(i.deviceId,i.placement);try{await this._persistDevicePlacement(i.deviceId,i.placement),this._showToast(this._t("undo"===e?"history.undone":"history.redone",{name:t.name}))}catch(t){this._previewDevicePlacement(i.deviceId,n),"undo"===e?this._devicePositionHistory.redo():this._devicePositionHistory.undo(),this._showToast(this._t("toast.pos_save_failed",{err:this._errText(t)}))}finally{this._devicePositionBusy=!1,this.requestUpdate()}}_undoDevicePosition(){this._runDevicePositionHistory("undo")}_redoDevicePosition(){this._runDevicePositionHistory("redo")}_savePos(e,t,i){this._spaceModelById(e.space)&&(this._layout=vg(this._layout,e.id,this._devicePlacementForCanvas(e,t,i)),this._dirtyPos.add(e.id),this._persistLayout())}_devicePresentation(e,t=!1!==this._config?.show_signal,i=!1){const n=i?null:this._renderDeviceSnapshot?.presentations.get(f_(e.id,t));return n||p_(this._renderPlanHass,e,{liveStates:!1!==this._config?.live_states,showTemperature:!1!==this._config?.show_temperature,showSignal:t,designPreview:i,activityRuntime:this._activityRt.get(e.id),sourceDetails:!1,lightDevices:this._renderDevices,registryHass:this._fullRegistryHass,reducedMotion:this._reducedMotion})}_deviceVisual(e){return this._devicePresentation(e).visual}_stateClass(e,t=this._deviceVisual(e)){const i=this._devicePresentation(e);return i.effectiveHidden?"":("icon_ripple"!==i.display||!1===this._config?.live_states||"alarm"===t.status||t.activity,u_({...i,visual:t}).join(" "))}_liveTemp(e){if(!this._config?.show_temperature)return null;if(!0===e.marker?.use_climate_temp){const t=qd(this._renderPlanHass,e.entities);if(null!=t)return t}return"mdi:thermometer"!==e.icon&&"mdi:air-filter"!==e.icon?null:Bd(this._renderPlanHass,e.entities)}_bindingEntities(e){if("virtual"===e||!e)return[];const t=this._bindingStatus(e);return"active"===t.kind?t.enabledEntityIds:t.allEntityIds}_bindingHasClimate(e){return this._bindingEntities(e).some(e=>e.startsWith("climate."))}_bindingHasAlarm(e){return this._bindingEntities(e).some(e=>{const t=this._planHass?.states?.[e]||this.hass?.states?.[e],i=this._fullRegistryHass.entities[e]||this.hass?.entities?.[e];return Yn(e.split(".")[0],t?.attributes?.device_class||i?.device_class||i?.original_device_class)})}_deviceBindingActive(e,t=!0){if(e.virtual||"virtual"===e.bindingKind)return!0;if(!e.bindingKind||!e.bindingRef)return!1;const i=this._bindingStatus(`${e.bindingKind}:${e.bindingRef}`);return"active"===i.kind||(t&&this._showToast(this._t("ha_disabled"===i.kind?"toast.ha_disabled_action":"toast.ha_binding_unverified")),!1)}_openMoreInfo(e){e?this._planEntityAvailable(e)?(this._kiosk&&(this._cyclePausedUntil=Math.max(this._cyclePausedUntil,Date.now()+6e4)),this._nativeMoreInfoEntity=e,gv(this,"hass-more-info",{entityId:e})):this._showToast(this._t("toast.ha_disabled_action")):this._showToast(this._t("toast.no_entity"))}_interruptViewGesture(e,t){if(clearTimeout(this._holdTimer),clearTimeout(this._kioskHoldTimer),void 0!==e)for(const i of[t,this._stageEl])try{i?.hasPointerCapture?.(e)&&i.releasePointerCapture(e)}catch{}this._pointers.clear(),this._panStart=null,this._panLock=null,this._pinchStart=null,this._swipeStart=null,this._roomPointer=null,this._doubleFit.clear(),this._deviceHits.clearPointers()}_closeInfoCard(){this._interruptViewGesture(),this._holdFired=!1,this._infoCard=null}_invalidateDeviceHitGeometry(){this._deviceHits.invalidate()}_resetDeviceHitState(){this._deviceHits.reset(this.renderRoot)}_deviceHitOwnerAt(e,t){return"view"!==this._mode&&"devices"!==this._mode?null:this._deviceHits.at(this.renderRoot,this._renderDevices,this._space,e,t)}_deviceForPointerEvent(e,t){return this._deviceHits.pointer(this.renderRoot,this._renderDevices,this._space,e,t)}_deviceForClickEvent(e,t){return this._deviceHits.click(this.renderRoot,this._renderDevices,this._space,e,t)}_showDeviceTip(e,t){this._liveRt?this._liveRt.devicePointerTip(e,t):this._ensureLiveRuntime().then(()=>this._liveRt?.devicePointerTip(e,t))}_showDeviceFocusTip(e,t){const i=e.currentTarget;this._liveRt?this._liveRt.deviceFocusTip(i,t):this._ensureLiveRuntime().then(()=>this._liveRt?.deviceFocusTip(i,t))}_hideDeviceFocusTip(e){this._liveRt?.deviceBlur(e)}_clearPointerHover(){this._liveRt?this._liveRt.pointerLeave():this._clearTransientHover()}_ctxDevice(e,t){"view"===this._mode&&(t=this._deviceForPointerEvent(e,t),e.preventDefault(),e.stopPropagation(),this._deviceBindingActive(t)&&(t.primary?this._openMoreInfo(t.primary):this._infoCard=t))}_clickDevice(e,t){if("view"!==this._mode&&"devices"!==this._mode)return;if(e.stopPropagation(),t=this._deviceForClickEvent(e,t),this._deviceDrag?.moved||this._suppressClick||this._holdFired)return;if("devices"===this._mode)return void this._openMarkerDialog(t);const i=this._devices.find(e=>e.id===t.id);if(!i)return;const n=Tu(i.tapAction,i.primary?.split(".")[0]);if("none"===n)return;const r=(e,t)=>{i.marker?.tap_confirm?this._tapConfirm={kind:"run",text:e,exec:t}:t()};if("toggle"===n){const e=this._toggleIntent(i);if(!e)return;if(!Iu(e))return void this._showUnavailableToggleTargets(e);const t=e=>{const t=Iu(e);if(!t)return;if("virtual-light"===t.kind)return this._startDevicePressFeedback(i.id),void this.hass.callWS({type:"houseplan/virtual_light/toggle",marker_id:t.markerId}).then(e=>{const t=Wh(this._virtualLights,e);t!==this._virtualLights&&(this._virtualLights=t,this._capturedSnapshotVirtual="",this._cacheSnapshot(),this.requestUpdate())}).catch(e=>this._showToast(this._t("toast.virtual_light_toggle_failed",{err:this._errText(e)})));const{command:n}=t;this._startDevicePressFeedback(i.id),this.hass.callService(n.domain,n.service,n.data).catch(e=>this._showToast(this._t("toast.error",{err:this._errText(e)})))},n=((o=e).targets.length?o.targets:o.skippedTargets).map(e=>e.name||e.entityId||e.ref).join(", ")||i.name;if(i.marker?.tap_confirm){const r=this._toggleConfirmationLines(e);if(!r.length)return;this._tapConfirm={kind:"toggle",text:this._t("confirm.tap_toggle",{name:n}),lines:r,initialIntent:e,deviceId:i.id,exec:()=>{const n=this._devices.find(e=>e.id===i.id),r=n?this._toggleIntent(n):null;r&&!Iu(r)&&this._showUnavailableToggleTargets(r)||(r&&Eu(e,r)?t(r):this._showToast(this._t("toast.tap_target_changed")))}}}else t(e);return}var o;if("info"===n)return this._interruptViewGesture(),void(this._infoCard=i);if(this._deviceBindingActive(i)){if("run"===n){const e=i.marker?.tap_target||"",t=function(e){const t=String(e||"").split(".")[0];return"automation"===t?{domain:"automation",service:"trigger"}:"script"===t?{domain:"script",service:"turn_on"}:"scene"===t?{domain:"scene",service:"turn_on"}:null}(e),n=this.hass.states[e];if(!t||!n)return void this._showToast(this._t("toast.run_target_missing"));const o=n.attributes?.friendly_name||e;return void r(this._t("confirm.tap_run",{name:o}),()=>{this._deviceBindingActive(i)&&this._planEntityAvailable(e)&&(this._startDevicePressFeedback(i.id),this.hass.callService(t.domain,t.service,{entity_id:e}).then(()=>{this._stampActivity(i.id,"event",this._activitySourceKey(i)),this.requestUpdate(),this._showToast(this._t("toast.run_started",{name:o}))}).catch(e=>this._showToast(this._t("toast.error",{err:this._errText(e)}))))})}"more-info"===n&&i.primary?this._openMoreInfo(i.primary):this._infoCard=i}}_showUnavailableToggleTargets(e){const t=function(e){if(!e||"group"!==e.kind||Iu(e)||"configured-targets-missing"!==e.noneReason)return[];if(!e.skippedTargets.length||e.skippedTargets.some(e=>!Ou.has(e.reason)&&"secure"!==e.reason))return[];const t=[],i=new Set;for(const n of e.skippedTargets){if(!Ou.has(n.reason))continue;const e=String(n.name||n.entityId||n.ref||"").trim();e&&!i.has(e)&&(i.add(e),t.push(e))}return t}(e);return!!t.length&&(this._showToast(1===t.length?this._t("toast.toggle_target_unavailable",{name:t[0]}):this._t("toast.toggle_targets_unavailable",{names:t.join(", ")})),!0)}_keyDevice(e,t){"Enter"!==e.key&&" "!==e.key||"view"!==this._mode&&"devices"!==this._mode||(e.preventDefault(),this._clickDevice(e,t))}_startDevicePressFeedback(e){const t=[...this.renderRoot.querySelectorAll(".dev[data-id]")].find(t=>t.dataset.id===e),i=t?.querySelector(".device-shell");if(!i||"function"!=typeof i.animate)return;const n=Number.parseFloat(this.ownerDocument.defaultView?.getComputedStyle(i).scale||""),r=Number.isFinite(n)?Math.max(.95,Math.min(1,n)):1;this._devicePressAnimations.get(e)?.cancel();const o=this._reducedMotion?[{outlineColor:"transparent",outlineStyle:"solid",outlineWidth:"0px"},{outlineColor:"var(--hp-accent, #3ea6ff)",outlineStyle:"solid",outlineWidth:"2px",outlineOffset:"2px",offset:.5},{outlineColor:"transparent",outlineStyle:"solid",outlineWidth:"0px"}]:[{scale:String(r)},{scale:"0.95",offset:.5},{scale:"1"}],s=i.animate(o,{duration:200,easing:"cubic-bezier(.22,.61,.36,1)"});this._devicePressAnimations.set(e,s);const a=()=>{this._devicePressAnimations.get(e)===s&&this._devicePressAnimations.delete(e)};s.addEventListener("finish",a,{once:!0}),s.addEventListener("cancel",a,{once:!0})}_cancelDevicePressFeedback(){for(const e of this._devicePressAnimations.values())e.cancel();this._devicePressAnimations.clear()}_pruneDevicePressFeedback(){if(!this._devicePressAnimations.size)return;const e=new Set([...this.renderRoot.querySelectorAll(".dev[data-id]")].map(e=>e.dataset.id||""));for(const[t,i]of this._devicePressAnimations)e.has(t)||(i.cancel(),this._devicePressAnimations.delete(t))}_t(e,t){return xp(kp(this.hass,this._config?.language),e,t)}get _colorPickerLabels(){return{title:this._t("color_picker.title"),hue:this._t("color_picker.hue"),saturation:this._t("color_picker.saturation"),value:this._t("color_picker.value"),hex:this._t("color_picker.hex"),invalidHex:this._t("color_picker.invalid_hex"),confirm:this._t("color_picker.confirm")}}_help(e){return this._editorRuntimeOrThrow()._help(e)}get _stageEl(){return this.renderRoot.querySelector(".stage")}_contentItems(e){const t=[];for(const i of this._devices){if(i.space!==e.id||i.hidden)continue;const n=this._pos(i);t.push({minX:n.x,minY:n.y,maxX:n.x,maxY:n.y})}if(e.id===this._space){for(const e of this._openingsR){const i=Number(e.angle)*Math.PI/180,n=Math.cos(i)*e.rlen/2,r=Math.sin(i)*e.rlen/2,o=pl([[e.rx-n,e.ry-r],[e.rx+n,e.ry+r]]);o&&t.push(o)}const i=this._decorH;for(const e of this._decorList){if("image"===e.kind&&!this._decorAssets.has(e.asset_id)&&"decor"!==this._mode)continue;const n=pl("line"===e.kind?[[e.x1*_v,e.y1*i],[e.x2*_v,e.y2*i]]:"text"===e.kind?[[e.x*_v,e.y*i]]:Nr({x:e.x*_v,y:e.y*i,w:e.w*_v,h:e.h*i,angle:e.angle}));n&&t.push(n)}for(const i of this._physicalBodiesR(e)){const e=pl(i);e&&t.push(e)}}return vl(e,t)}_frameOf(){const e=this._spaceModel();if(!e){this._frame=null;const e={x:0,y:0,w:_v,h:_v};return{rect:e,all:e,outliers:0}}const t=this._frame,i="view"!==this._mode;if(t&&t.id===e.id&&this._bdDrag)return t;if(t&&t.id===e.id&&t.model===e&&t.layout===this._layout&&t.devs===this._devices&&t.far===this._showFar&&t.grow===i)return t;const n=kl(this._contentItems(e));let r=n.all||Sl(e),o=this._showFar?r:n.core||Sl(e);return t&&t.id===e.id&&i&&t.grow&&(o=mv(t.rect,o),r=mv(t.all,r)),this._frame={id:e.id,model:e,layout:this._layout,devs:this._devices,far:this._showFar,grow:i,rect:o,all:r,outliers:n.outliers},this._frame}_isoSource(){const e=this._isoSceneRuntime;if(!e)return null;const t=this._spaceModel();if(!t)return null;const i=this._spaceWalls,n=this._openCuts(),r=this._openingsR;return e.createIsoStructuralSource({space:t,walls:i,openCuts:n,openings:r,partitionCuts:()=>this._partitionOpeningCuts(t),roomOpenings:()=>this._roomWallOpeningInputs(r,t),cellCm:this._cellCm,gridPitch:this._gridPitch,wallKeyPitch:this._wallKeyPitch,coordinateScale:_v,onBuild:()=>{this._isoStructuralBuildCount+=1}})}_isoSceneKey(){if(!this._labsIso||"view"!==this._mode)return null;try{return this._isoSource()?.key??null}catch{return this._isoInvalidKey()}}_isoInvalidKey(){return`${this._space}|invalid|${this._cfgEpoch}`}_clearIsoInvalidFallback(e){const t=`${this._space}|invalid|`;for(const i of this._isoFallback)i.startsWith(t)&&i!==e&&this._isoFallback.delete(i)}_isoScene(e=this._isoSource()){const t=this._isoSceneRuntime;if(!t||!e)return null;let i=this._frameOf().rect;const n=this._spaceDisplayForRender(),r=this._spaceModel();if(r&&n.showNames)for(const e of r.rooms)if(e.name){const t=this._labelPos(e,r.id);i=mv(i,{x:t.x,y:t.y,w:0,h:0})}const o=t.resolveIsoScene({source:e,cache:this._isoGeometryCache,cellCm:this._cellCm,liveFrame:i});if(!r||!n.showBorders)return o;const s=this._config?.icon_size??2.5,a=s>8?2.5:s,l=this._stageEl?.getBoundingClientRect?.()??null,c=l?.height?l.width/l.height:o.frame.w/o.frame.h,h=Oi([o.frame.x,o.frame.y,o.frame.w,o.frame.h],c),d=this._isoOverlayScene(r,this._renderDevices.filter(e=>e.space===r.id&&!e.hidden),h,n,t.resolveIsoDecorationLayers(n),o,a,x_(a),n.showLqi??this._config?.show_signal??!0,!1),u=d&&t.resolveIsoOverlayFitEnvelope({baseBounds:o.frame,entries:d.entries,stageSize:l,targetView:e=>Oi([e.x,e.y,e.w,e.h],c)});return u?{...o,frame:u.bounds,overlayFitEntries:d.entries}:o}_latchIsoFallback(e,t){if(this._isoFallback.has(e))return;this._isoFallback.add(e);const i=e.includes("|invalid|")?"invalid":e.split("|").pop()||"invalid";console.warn("HOUSEPLAN ISO FALLBACK: #89/#160",wf("structural",i,!0))}_effectiveProjection(){if(this._isoProjectionSnapshot)return this._isoProjectionSnapshot;const e=e=>this._isoProjectionSnapshot=e,t=()=>("iso"===this._renderProjection&&(this._cancelCameraTransition(!1),this._view=null,this._viewModeSnap=null),e("flat"));if(this._renderIsoScene=null,"iso"!==this._desiredProjection||!this._model.length||!this._isoSceneRuntime)return e("flat");if(!this._spaceDisplayForRender().showBorders)return this._isoFallback.has(`${this._space}|no-borders`)?t():e("iso");let i=this._isoInvalidKey();if(this._clearIsoInvalidFallback(i),this._isoFallback.has(i))return t();try{const n=this._isoSource();if(!n)return e("flat");if(i=n.key,this._isoFallback.has(i))return t();const r=this._isoScene(n);return r?this._isoFallback.has(r.key)?t():(this._renderIsoScene=r,e("iso")):e("flat")}catch(e){return this._latchIsoFallback(i,e),t()}}_scenePoint(e){return"iso"===this._renderProjection?lf(e,0):e}_floorView(e){if("iso"!==this._renderProjection)return e;const t=cf([e.x,e.y]),i=cf([e.x+e.w,e.y+e.h]);return{x:t[0],y:t[1],w:i[0]-t[0],h:i[1]-t[1]}}_isoOverlayScene(e,t,i,n,r,o,s,a,l,c=!0){const h=this._isoSceneRuntime;return h&&r?.structural&&o?h.buildIsoOverlayRenderScene({space:e,devices:t,openings:this._openingsR,view:i,display:n,wallSilhouettes:o.wallSilhouettes,resolveCollisions:c,iconPct:s,deviceBasePct:a,showLqi:l,cellCm:this._cellCm,kioskIconScale:"view"===this._mode?this._kioskScale.icon:1,kioskFontScale:"view"===this._mode?this._kioskScale.font:1,stageSize:this._stageEl?.getBoundingClientRect?.(),positionOf:e=>this._pos(e),presentationOf:(e,t)=>this._devicePresentation(e,t),labelPositionOf:(e,t)=>this._labelPos(e,t),labelScaleOf:e=>this._labelScale(e),openingEntityAvailable:e=>this._renderOpeningEntityAvailable(e),openingWallIndex:()=>this._openingWallIndexFor(e,this._openCuts()).value}):null}_baseVb(e=this._effectiveProjection(),t=this._renderIsoScene){if("iso"===e){if(!this._spaceDisplayForRender().showBorders){const e=uf({rect:this._frameOf().rect,wallHeight:0});return[e.x,e.y,e.w,e.h]}const e=t?.frame??this._frameOf().rect;return[e.x,e.y,e.w,e.h]}const i=this._frameOf().rect;return[i.x,i.y,i.w,i.h]}get _outliers(){return this._showFar?0:this._frameOf().outliers}_fitFar(){this._clearRoomFocus(),this._showFar=!0,this._frame=null,this.requestUpdate(),this._resetZoom()}_clearRoomFocus(e=!1){this._doubleFit.clear(),this._roomFocus=null,e&&(this._roomPointer=null)}_roomFitBounds(e,t){const i=ni(e);if(!i||!e.id)return null;const n=this._spaceWalls,r=this._openCuts(),o=this._wallUnionGeometry(),s=n.length&&this._innerRoomContour(t,e.id,r,o?.roomGeom,o?.multiWallNodes)||i,a=this._spaceDisplayForRender();let l=[];if(a.showBorders&&n.length){const i=Fs(t.rooms,e.id,n,r,this._wallKeyPitch,this._cellCm,this._gridPitch,_v);i&&(l=aa(i.poly,i.offsets,o?.multiWallNodes)||i.poly)}const c=this._effectiveProjection();return function(e){const t=e.floor,i=e.wall||[],n=e.padding??0;if(!t.length||!t.every(vf)||!i.every(vf)||!Number.isFinite(n)||n<0)return null;if("flat"===e.projection)return bf([...t,...i],n);const r=e.wallHeight??0,o=e.floorDepth??0;if(!Number.isFinite(r)||r<0||!Number.isFinite(o)||o<0)return null;try{const e=[];for(const i of t){const t=[i[0],i[1]];e.push(lf(t,0)),o>0&&e.push(lf(t,-o))}for(const t of i){const i=[t[0],t[1]];e.push(lf(i,0)),r>0&&e.push(lf(i,r))}return bf(e,n)}catch{return null}}({floor:s,wall:l,projection:c,wallHeight:"iso"===c&&a.showBorders?Wa(84,this._cellCm):0,floorDepth:"iso"===c&&a.showBorders?Wa(10,this._cellCm):0,padding:a.showBorders?Wa(1.25,this._cellCm):0})}_fitRoom(e,t=!0){if("view"!==this._mode)return!1;this._doubleFit.clear();const i=this._spaceModel(),n=i?.rooms.find(t=>t.id===e);if(!i||!n)return this._clearRoomFocus(),!1;let r=this._roomFitBounds(n,i);if(!r)return this._clearRoomFocus(),!1;this._roomFocus={spaceId:i.id,roomId:e};const o=this._stageEl;if(!o||o.clientWidth<=0||o.clientHeight<=0)return!0;const s=Oi(this._baseVb(),o.clientWidth/o.clientHeight),a=e=>function(e){const t=e.safeFraction??.8,{bounds:i,baseFit:n,stageWidth:r,stageHeight:o,minZoom:s,maxZoom:a}=e;if(!yf(i)||!yf(n)||!Number.isFinite(r)||r<=0||!Number.isFinite(o)||o<=0||!Number.isFinite(s)||s<=0||!Number.isFinite(a)||a1)return null;const l=r/o,c=Math.max(i.w/t,i.h/t*l);if(!Number.isFinite(c)||c<=0)return null;const h=Math.min(a,Math.max(s,n.w/c)),d=n.w/h,u=d/l;return{zoom:h,viewBox:{x:i.x+i.w/2-d/2,y:i.y+i.h/2-u/2,w:d,h:u}}}({bounds:e,baseFit:s,stageWidth:o.clientWidth,stageHeight:o.clientHeight,minZoom:wv.ZOOM_MIN,maxZoom:wv.ZOOM_MAX});let l=a(r);const c=this._isoSceneRuntime,h=this._renderIsoScene?.overlayFitEntries;if(l&&"iso"===this._effectiveProjection()&&c&&h?.length){const e=c.resolveIsoOverlayFitEnvelope({baseBounds:r,entries:h,ownerId:n.id,stageSize:{width:o.clientWidth,height:o.clientHeight},targetView:e=>a(e)?.viewBox??null});e&&(r=e.bounds,l=a(r))}if(!l)return this._clearRoomFocus(),!1;const d=this._cameraState(),u=function(e,t,i,n){const r=[e,t,i,n],o=Math.min(...r.map(e=>e.x)),s=Math.min(...r.map(e=>e.y));return{x:o,y:s,w:Math.max(...r.map(e=>e.x+e.w))-o,h:Math.max(...r.map(e=>e.y+e.h))-s}}(s,d.viewBox,l.viewBox,r);return l.viewBox=this._clampView(l.viewBox,u),t?(this._prepareCameraCommand(),this._startCameraTransition(l,u,"room",220),!0):(this._cancelCameraTransition(!1),Xg(d,l)||(this._zoom=l.zoom,this._view={...l.viewBox},this.requestUpdate()),!0)}_fitAll(e="fit"){this._clearRoomFocus(),this._showFar=!0,this._frame=null,this.requestUpdate(),this._resetZoom(e)}_renderFarHint(){return this._kiosk||"view"!==this._mode||this._booting||!this._outliers?G:j`
+
`:G}houseplanContinuityTrace(){return[...this._continuityHistory,...this._continuity.trace].slice(-80).map(e=>({...e,...e.stage?{stage:[...e.stage]}:{}}))}getCardSize(){return 12}getGridOptions(){return{columns:"full"}}get _norm(){return!(!this._serverCfg||!this._serverCfg.spaces.length)}_cfgFingerprint(){const e=this._serverCfg?.spaces||[];let t=e.length+":";for(const i of e){t+=(i.id||"")+","+(i.plan_aspect||"")+","+(i.plan_url||"").length+","+(i.plan_x??"")+","+(i.plan_y??"")+","+(i.plan_scale??"")+","+(i.plan_scale_x??"")+","+(i.plan_scale_y??"")+","+(i.plan_angle??"")+","+(i.rooms?.length||0)+","+(i.openings?.length||0)+","+(i.decor?.length||0)+";";for(const e of i.rooms||[]){const i=e.poly?.[0],n=e.poly?.[e.poly.length-1];t+=(e.poly?.length||0)+"."+(e.id||"")+"."+(e.open_to||[]).join("+")+"."+(e.area||"")+"."+JSON.stringify(e.settings||0)+"."+(e.x??"")+","+(e.y??"")+","+(e.w??"")+","+(e.h??"")+","+(i?i[0]+"/"+i[1]:"")+","+(n?n[0]+"/"+n[1]:"")+";"}}return t}get _model(){if(!this._serverCfg)return[];const e=this._cfgEpoch+"|"+this._cfgFingerprint();if(this._modelCache&&this._modelCache.key===e)return this._modelCache.model;const t=this._buildModel();return this._modelCache={key:e,model:t},t}_buildModel(){if(!this._serverCfg)return[];const e=this._renderCfg;return el(e).map((t,i)=>{const n=e.spaces[i]?.plan_url;return t.bg&&n?{...t,bg:{...t.bg,href:n}}:t})}_spaceModel(){return this._hasFixedFloor?kc(this._model,this._space):(e=this._model,t=this._space,e.find(e=>e.id===t)??e[0]);var e,t}_spaceModelById(e){return kc(this._model,e)}_syncEmptySpaceState(){if(!!this._serverCfg&&0===this._serverCfg.spaces.length){if(!this._emptySpaceStateActive){this._emptySpaceStateActive=!0,this._clearRoomFocus(!0);for(const e of this._pointers.keys())for(const t of this.renderRoot.querySelectorAll("*"))try{t.hasPointerCapture?.(e)&&t.releasePointerCapture(e)}catch{}this._pointers.clear(),this._panStart=null,this._panLock=null,this._pinchStart=null,this._swipeStart=null,this._drag=null,this._deviceDrag=null,this._resetDeviceHitState(),this._rlResize=null,this._vacFit=null,this._compassDrag=!1,this._cancelModeTransition(!1),this._mode="view",this._clearGeometryGesture(),this._geometryHistory.clear(),this._devicePositionHistory.clear(),this._tip=null,this._hoverRoom=null,this._openingInfo=null,this._closeInfoCard(),this._deviceInbox=null,this._deviceInboxReturn=null,this._markerDialog=null,this._physicalDialog=null,this._backdropDialog=null,this._decorShapeDialog=null,this._decorTextDialog=null,this._roomDialog=!1,"edit"===this._spaceDialog?.mode&&(this._spaceDialog=null),this._editorSecondary?.closeForNavigation(),this._saveConfigDebounced.cancel(),this._frame=null,this._planSnapGeometryCache=null,this._hiddenWallDiagnosticCache=null,this._decorSnapCache=null,this._commitSpace("",!0)}}else this._emptySpaceStateActive=!1}get _areaToSpace(){const e={};for(const t of this._model)for(const i of t.rooms)i.area&&(e[i.area]={space:t.id,room:i});return e}get _settings(){return this._serverCfg?.settings||{}}get _showAll(){return this._showHidden||!this._settings.filter_seeded&&!!this._settings.show_all}_seedHiddenDevices(){if(!(this._loadOk&&this._serverCfg&&this._norm&&this._canEdit))return;const e=this._serverCfg,t=eu({hass:this.hass,registry:this._haRegistry,areaToSpace:Object.fromEntries(Object.entries(this._areaToSpace).map(([e,t])=>[e,t.space])),markers:this._markers,settings:this._settings,excluded:this._excluded,firstSpaceId:this._model[0]?.id||"",iconRules:this._iconRules});if(!t.length&&e.settings?.filter_seeded)return;e.markers=e.markers||[];const i=[];for(const n of t){const t="h"+n.slice(n.indexOf(":")+1);e.markers.push({id:t,binding:n,hidden:!0}),i.push(n.slice(n.indexOf(":")+1))}const n={...e.settings||{},filter_seeded:!0};delete n.show_all,i.length&&Array.isArray(n.new_device_ids)&&(n.new_device_ids=n.new_device_ids.filter(e=>!i.includes(e))),e.settings=n,this._regSignature="",this._maybeRebuildDevices(),this._saveConfig(),this.requestUpdate()}get _iconRules(){const e=this._settings.icon_rules;if(!e||!Array.isArray(e)||!e.length)return;const t=JSON.stringify(e);return t!==this._rulesCompiledSrc&&(this._rulesCompiledSrc=t,this._rulesCompiled=Ee(e)),this._rulesCompiled}get _fillColors(){return vn(this._settings)}get _excluded(){return lu(this._settings)}_setAreaLifecycleConfig(e){this._cfgEpochPreservedConfig=e,this._serverCfg=e}willUpdate(e){if(this._isoProjectionSnapshot=null,this._summary?.willUpdate(),e.has("hass")&&this._configReloadAuthority.observeContext(Vu(this)),e.has("_serverCfg")){const e=this._cfgEpochPreservedConfig===this._serverCfg;this._cfgEpochPreservedConfig=null,e||this._cfgEpoch++,this._renderLife.invalidate()}if(this._syncEmptySpaceState(),this._dangerConfirm&&(this._dangerConfirmMissingSpace()||"warm"===this._syncDangerConfirmLocaleGate())&&this._cancelDangerConfirm(),e.has("hass")&&this.hass){const t=this._visibleDeviceSnapshot||this._candidateDeviceSnapshot;this._renderLife.observe(e.get("hass"),this.hass,t?{entityIds:t.entityIds}:null,()=>Mg(this))}this._continuity.hasCompleteFrame&&"steady"===this._continuity.state&&this._continuity.refreshCompleteFrame(this._visualFrameFingerprint()),this._captureRenderDeviceSnapshot()}updated(){this._summary?.updated(),this._liveRt?.commit(),this._editorRuntime?._commitLiveEditor(),this._pruneDevicePressFeedback(),this._syncDayCycleClock(),this._syncRadarLive(),this._warmSnapshot(),this._editorRuntime&&this._dtMeasure();const e=this._stageEl;e&&!this._roViewport&&(this._roViewport=new ResizeObserver(()=>{this._invalidateDeviceHitGeometry(),this._refitView(),requestAnimationFrame(()=>this._summary?.resized())}),this._roViewport.observe(e)),e&&this._booting&&!this._bootTimer&&this._bootWatch();const t=this.renderRoot.querySelector(".hdr");if(t&&e&&!this._roHdr){const i=()=>{const t=ef(this.renderRoot,e,this.panelHost);null!==t&&(t>=0&&t!==this._hdrH&&(this._hdrH=t),t>=0&&!this._booting&&!this._config?.kiosk&&e.clientHeight>0&&this._warmPatch({hdrH:t,stageH:e.clientHeight}))};this._roHdr=new ResizeObserver(()=>requestAnimationFrame(i)),this._roHdr.observe(t),this._onWinResize=()=>requestAnimationFrame(i),window.addEventListener("resize",this._onWinResize),i()}if(e&&!this._view&&this._refitView(),this._editorSecondary?.afterRender(),this._settleContinuityFrame(),this._serverStorage&&this._loadOk&&this._canManageConfiguration&&0===this._model.length&&!this._spaceDialog&&!this._importDialog&&!this._onboardingShown){this._onboardingShown=!0;const e=function(e){const t=e?.floors;if(!t||"object"!=typeof t)return[];const i=[];for(const e of Object.values(t))e&&e.floor_id&&i.push({id:e.floor_id,name:e.name||e.floor_id,level:e.level??null});return i.sort((e,t)=>{const i=e.level??1e9,n=t.level??1e9;return i!==n?i-n:e.name.localeCompare(t.name)}),i}(this.hass);e.length?this._importDialog={floors:e.map(e=>({...e,checked:!0}))}:this._openSpaceDialog("create")}}_adoptConfigCapabilities(e){xg(this,e)}_syncRadarLive(){const e=this._serverCfg?.settings?.radar,t=(this._serverCfg?.markers||[]).some(e=>Cg(e,this._space));this._radarLive.sync(this._space,1===this._haRadarStage1Api&&"view"===this._mode&&!1!==e?.show_live&&t&&"hidden"!==this.ownerDocument.visibilityState)}async _syncDecorAssets(e){const t=++this._decorAssetSyncToken;if(1!==this._haDecorAssetsApi||!this.hass)return void(this._decorAssets=new Map);const i=await um(this.hass,cm(e),this._cfgRev);t===this._decorAssetSyncToken&&(this._decorAssets=i,this._resign(),this.requestUpdate())}_adoptAuthoritative(e){return ju(this,e)}_rollbackOptimistic(e){const t=this._adoption.rollbackOptimistic(e);return t&&this.requestUpdate(),t}_resumePendingNavMode(){if(!this._pendingNavMode||!this._canEdit||this._config?.kiosk)return!1;const e=this._pendingNavMode;return this._pendingNavMode=null,this._setMode(e,!1),!0}_getAuthoritativeConfig(){return e=this,async function(e,t){const i=await e();return t(i),i}(()=>e.hass.callWS({type:"houseplan/config/get"}),t=>xg(e,t));var e}async _loadFromServer(){this._loading=!0,this._loadTries++;const e=this._space,t=!!this._view;let i=!1;const n=()=>{i=!0,this._regSignature="",this._maybeRebuildDevices()};try{const[i,r]=await Promise.all([this._getAuthoritativeConfig(),this.hass.callWS({type:"houseplan/layout/get"})]);if("adopted"!==(await this._adoptAuthoritative({cfgResp:i,layResp:r,reason:"structural-response",profile:"reload",beforeAdopt:()=>{this._connectionWasLost=!1,this._serverStorage=!0},afterAdopt:()=>{this._warmVpArmed&&this._space===this._warmVp?.space?this._warmVpArmed=!1:t&&this._space===e||this._restoreZoom(),this._loadOk=!0,n()}})).status)return;this.hass.callWS({type:"houseplan/trail/get"}).then(e=>{this._vacSrvTrails=e?.trails||{},this.requestUpdate()}).catch(()=>{}),this._ensureLiveSyncSubscriptions()}catch(e){if(this._serverCfg)this._scheduleLoadRetry(!0);else if(this._loadTries>=8){this._serverStorage=!1;try{this._layout=JSON.parse(localStorage.getItem(lv)||"{}")||{}}catch{this._layout={}}}}finally{this._loading=!1,this._continuityDataReady=!0,i||n(),this.requestUpdate()}}_ensureLiveSyncSubscriptions(){const e=this.hass?.connection;if(!e)return;if(e!==this._liveSyncConnection&&(this._unsubCfg?.(),this._unsubCfg=null,this._unsubLayout?.(),this._unsubLayout=null,this._unsubTrail?.(),this._unsubTrail=void 0,this._unsubVirtual?.(),this._unsubVirtual=null,this._liveSyncGeneration++,this._liveSyncAttempt=null,this._liveSyncConnection=e),this._liveSyncAttempt)return;const t=this._liveSyncGeneration,i=[],n=(n,r,o,s)=>{n()||i.push(async()=>{const i=await e.subscribeEvents(s,o);t===this._liveSyncGeneration&&this.isConnected&&this.hass?.connection===e&&!n()?r(i):i?.()})};if(n(()=>this._unsubCfg,e=>{this._unsubCfg=e},"houseplan_config_updated",e=>{const t=Number(e?.data?.rev??-1);t!==this._cfgRev&&this._reloadConfigOnly(!1,t)}),n(()=>this._unsubTrail,e=>{this._unsubTrail=e},"houseplan_trail_updated",async()=>{try{const e=await this.hass.callWS({type:"houseplan/trail/get"});this._vacSrvTrails=e?.trails||{},this.requestUpdate()}catch{}}),n(()=>this._unsubLayout,e=>{this._unsubLayout=e},"houseplan_layout_updated",e=>this._onLayoutEvent(Number(e?.data?.rev??-1))),n(()=>this._unsubVirtual,e=>{this._unsubVirtual=e},"houseplan_virtual_light_updated",e=>{const t=Wh(this._virtualLights,e?.data);t!==this._virtualLights&&(this._virtualLights=t,this._capturedSnapshotVirtual="",this._cacheSnapshot(),this.requestUpdate())}),!i.length)return;const r=function(e){return Promise.allSettled(e.map(e=>Promise.resolve().then(e)))}(i).then(()=>{});this._liveSyncAttempt=r,r.finally(()=>{this._liveSyncAttempt===r&&(this._liveSyncAttempt=null)})}async _reloadConfigOnly(e=!1,t){return Ku(this,e,t)}_scheduleLoadRetry(e=!1){if(void 0!==this._loadRetryTimer)return;const t=Math.min(8e3,500*2**Math.min(4,Math.max(1,this._loadTries-7)));this._loadRetryTimer=window.setTimeout(()=>{this._loadRetryTimer=void 0,!e&&this._loadOk||this._loading||!this.hass||this._loadFromServer()},t)}async _ensureLiveRuntime(){if(this._liveRt)return;const e=await import("./live-interaction-runtime-DpDkGNJh.js");this._liveRt=new e.LiveRuntime(this),this.isConnected&&this.requestUpdate()}_liveVp(e=!1){this._liveRt?this._liveRt.viewport(e):this.requestUpdate()}_syncLiveHover(){this._liveRt?this._liveRt.hover():this.requestUpdate()}_flushHa(){this._liveRt?.take()&&(this._terminalFrame=2,super.requestUpdate())}_ensureHaRegistryAuthority(){const e=this.hass?.connection||null;e&&e!==this._haRegistryConnection&&(this._haRegistryRelease?.(),this._haRegistryConnection=e,this._haRegistryRev=-1,this._haBindingCacheKey="",this._renderLife.invalidate(),this._areaSnapshotCleanupCandidates.clear(),this._planHassMemo=null,this._haRegistryRelease=td(this.hass,this._onHaRegistryUpdate),this._onHaRegistryUpdate())}get _haRegistry(){return nd(this.hass)}get _planHass(){const e=this._haRegistry,t=od(this.hass,e),i=this._planHassMemo;if(i&&i.hass===this.hass&&i.sig===t)return i.active;const n=ad(this.hass,e),r=ld(this.hass,e);return this._planHassMemo={hass:this.hass,sig:t,active:n,full:r},n}_captureRenderDeviceSnapshot(){if(!this.hass)return;const e=Date.now(),t=[...this._activityRt.entries()].map(([t,i])=>`${t}:${i.gen}:${i.flashTs}:`+(i.flashKind&&(i.expiresAt||i.flashTs+tg)>e?1:0)).join("|"),i=Bh(this._virtualLights);if(this._capturedSnapshotSequence===this._hassSequence&&this._capturedSnapshotDevices===this._devices&&this._capturedSnapshotLayout===this._layout&&this._capturedSnapshotConfigEpoch===this._cfgEpoch&&this._capturedSnapshotVirtual===i&&this._capturedSnapshotActivity===t)return;const n=this._planHass,r=new Map,o=new Map,s=new Set(["sun.sun"]);for(const e of this._summary?.entityIds()||[])s.add(e);this._vacFit?.source&&s.add(this._vacFit.source);const a=new Set,l=new Set,c=e=>{if(!e)return;const t=e.indexOf(":");if(t<0)return void s.add(e);const i=e.slice(0,t),n=e.slice(t+1);"device"===i?a.add(n):"entity"===i&&s.add(n)};for(const e of this._model)for(const t of e.rooms)t.area&&l.add(t.area),c(t.settings?.temp_source),c(t.settings?.hum_source);for(const e of this._serverCfg?.spaces||[])for(const t of e.openings||[])for(const e of ui(t))s.add(e);for(const e of this._serverCfg?.spaces||[])for(const t of e.decor||[])if("text"===t.kind){for(const e of String(t.text||"").matchAll(/\{([^{}\r\n]+)\}/g)){const t=Xi(e[1]);t?.entity&&s.add(t.entity)}t.entity&&s.add(t.entity),o.set(`decor:${e.id}:${t.id}`,tn(t.text,t,n,e=>!!n.entities?.[e]&&!!n.states?.[e]&&!Jd(n,e,Zd(this._markers))))}const h=Ed(n,this._devices,null,this._virtualLights);for(const e of this._devices){for(const t of[!1,!0])r.set(f_(e.id,t),p_(n,e,{liveStates:!1!==this._config?.live_states,showTemperature:!1!==this._config?.show_temperature,showSignal:t,activityRuntime:this._activityRt.get(e.id),sourceDetails:!1,lightDevices:this._devices,lightSources:h,registryHass:this._fullRegistryHass,reducedMotion:this._reducedMotion}));if(this._isVacDev(e)){const t=this._vacSource(e,n),i=t?Wc(n?.states?.[t]?.attributes):null,r=this._vacRt.get(e.id),s=lh(e.id,e.marker?.vacuum??null,e.space,t),a=hh({routes:s,observed:dh(s,[t],t=>this._vacObservedMapId(e,t,n)),spaceIds:new Set(this._model.map(e=>e.id))});o.set(`vacuum:${e.id}`,{source:t,telemetry:i,routes:s,resolution:a,mapId:i?this._vacMapId(e,i,n):null,runtime:r?{trail:r.trail,lastTs:r.lastTs,moving:r.moving,jump:r.jump}:null,server:this._vacSrvTrails[e.id]||null})}}const d=g_({sourceSequence:this._hassSequence,hass:n,devices:this._devices,presentations:r,positions:(u=this._model.length>0,p=this._devices,_=e=>this._livePos(e),u?new Map(p.map(e=>[e.id,_(e)])):new Map),facts:o,entityIds:s,deviceIds:a,areaIds:l});var u,p,_;this._capturedSnapshotSequence=this._hassSequence,this._capturedSnapshotDevices=this._devices,this._capturedSnapshotLayout=this._layout,this._capturedSnapshotActivity=t,this._capturedSnapshotConfigEpoch=this._cfgEpoch,this._capturedSnapshotVirtual=i,this._visibleDeviceSnapshot&&"steady"!==this._continuity.state?this._candidateDeviceSnapshot=d:(this._visibleDeviceSnapshot=d,this._candidateDeviceSnapshot=null)}get _renderDeviceSnapshot(){return this._stagedDeviceSnapshotToken===this._continuity.token?this._candidateDeviceSnapshot||this._visibleDeviceSnapshot:this._visibleDeviceSnapshot||this._candidateDeviceSnapshot}get _renderPlanHass(){return this._renderDeviceSnapshot?.hass||this._planHass}get _renderDevices(){return this._renderDeviceSnapshot?.devices||this._devices}get _renderVacuumDevices(){return this._renderDeviceSnapshot?.vacuumDevices||this._devices}get _fullRegistryHass(){return this._planHass,this._planHassMemo?.full||this.hass}_bindingStatus(e){return dd(this.hass,e,this._haRegistry)}houseplanDiagnostics(){const{registry:e,bindings:t}=this._renderLife.diagnostics(this.hass,this._markers,e=>this._bindingStatus(e));return{registry:{...e,lastSuccessAgeMs:e.lastSuccess?Math.max(0,Date.now()-e.lastSuccess):null},bindings:t}}_openBindingInHa(e){const[t,i]=e.split(":");if(i)if("device"!==t){if("entity"===t){const e=this._fullRegistryHass.entities?.[i];e?.device_id&&fv("/config/devices/device/"+encodeURIComponent(e.device_id))}}else fv("/config/devices/device/"+encodeURIComponent(i))}_bindingHasHaPage(e){const[t,i]=e.split(":");return!!i&&("device"===t||"entity"===t&&!!this._fullRegistryHass.entities?.[i]?.device_id)}_toggleMarkerDialogVisibility(){const e=this._markerDialog;if(!e)return;const t="ha"===e.bindingMode?this._bindingStatus(e.binding):null,i=e.hideFromPlan||"ha_disabled"===t?.kind;i&&"ha_disabled"===t?.kind?this._showToast(this._t("entity"===t.reason?"toast.ha_disabled_show_entity":"toast.ha_disabled_show_device")):i&&"unverified"===t?.kind?this._showToast(this._t("toast.ha_binding_unverified")):this._markerDialog={...e,hideFromPlan:!i}}_hookConnection(){const e=this.hass?.connection;e&&e!==this._connHooked&&(this._connHooked?.removeEventListener?.("ready",this._onConnReady),this._connHooked?.removeEventListener?.("disconnected",this._onConnLost),this._connHooked?.removeEventListener?.("reconnect-error",this._onConnLost),e.addEventListener?.("ready",this._onConnReady),e.addEventListener?.("disconnected",this._onConnLost),e.addEventListener?.("reconnect-error",this._onConnLost),this._connHooked=e)}_display(e){return this._signer.display(this.hass,e)}_referencedContentUrls(){const e=Nn(this._serverCfg);for(const t of this._decorAssets.values())e.add(t.url);return e}_resign(){this._signer.resign(this.hass,this._referencedContentUrls())}_onLayoutEvent(e){e<=this._layoutRev||(clearTimeout(this._layoutSyncTimer),this._layoutSyncTimer=window.setTimeout(()=>{e<=this._layoutRev||this._reloadLayoutOnly()},200))}_noteLayoutRev(e){this._adoption.noteLayoutRevision(e?.rev)}async _reloadLayoutOnly(){if(!this._serverStorage||!this.hass?.callWS)return;this._beginContinuityCandidate("layout-reload",!1);const e=new Map;for(const t of this._dirtyPos)this._layout[t]&&e.set(t,this._layout[t]);this._persistLayout.pending()&&this._persistLayout.flush();for(const[t,i]of this._sentPos)e.set(t,i);try{const t=await this.hass.callWS({type:"houseplan/layout/get"}),i={...t?.layout||{}};for(const[t,n]of e)null===n?delete i[t]:i[t]=n;this._adoption.adoptMergedLayout(i,t,()=>{this._cancelDeviceDrag(),this._devicePositionHistory.clear()}),this._canOptimizeUndo=!!t?.can_optimize_undo,this._undoKind=t?.undo_kind||null,this._cacheSnapshot(),this.requestUpdate()}catch{}finally{this._continuityDataReady=!0,this.requestUpdate()}}_persistLocalLayout(){this._layout=So(lo(this._layout)),localStorage.setItem(lv,JSON.stringify(this._layout))}_maybeRebuildDevices(){const e=this.hass;if(!e?.devices||!e?.entities||!e?.areas)return;const t=this._haRegistry,i=od(e,t)+":"+Object.keys(e.areas).length+":"+(this._norm?"n":"l")+":"+kp(e,this._config?.language);if(i===this._regSignature&&this._devices.length)return;this._regSignature=i;const n=new Map(this._devices.map(e=>[e.id,e.bindingStatus?.kind||"active"]));this._devices=iu({hass:e,registry:t,areaToSpace:Object.fromEntries(Object.entries(this._areaToSpace).map(([e,t])=>[e,t.space])),markers:this._markers,settings:this._settings,excluded:this._excluded,showAll:this._showAll,firstSpaceId:this._model[0]?.id||"",loc:e=>this._t(e),iconRules:this._iconRules});const r=this._markers.filter(e=>!e.removed&&"virtual"!==e.binding).map(e=>e.binding).sort(),o=t.revision+":"+r.join("|");if(t.authoritative&&o!==this._haBindingCacheKey){const i=new Map;for(const n of r)i.set(n,dd(e,n,t));!function(e){if("undefined"==typeof localStorage||!e.size)return;const t=hd(),i=Date.now();for(const[n,r]of e)"active"===r.kind?t[n]={kind:"active",ts:i}:"ha_disabled"===r.kind&&(t[n]={kind:"ha_disabled",reason:r.reason,ts:i});const n=Object.fromEntries(Object.entries(t).sort((e,t)=>t[1].ts-e[1].ts).slice(0,1500));Yh=n;try{localStorage.setItem(Kh,JSON.stringify(n))}catch{}}(i),this._haBindingCacheKey=o}let s=null;if(t.authoritative&&(s=this._resolveAreaRelocations(t),this._areaRelocationIds=new Set(s.relocateIds),this._areaRelocationIds.size)){this._cancelDeviceDrag();const e=this._areaRelocationIds;this._devicePositionHistory.removeWhere(({before:t,after:i})=>e.has(t.deviceId)||e.has(i.deviceId));const t=this._markerDialog;if(t?.devId&&!t.roomTouched&&this._areaRelocationIds.has(t.devId)){const e=this._devices.find(e=>e.id===t.devId);e&&(this._markerDialog={...t,room:e.marker?.room_id?`${e.space}#@${e.marker.room_id}`:e.space&&e.area?`${e.space}#${e.area}`:""})}}this._defPos=this._defaultPositions(),this._syncNewDevices(),this._seedHiddenDevices(),s&&this._syncAreaRelocations(s),this._syncActivityRuntime();const a=new Set(this._devices.filter(e=>!e.hidden).map(e=>e.id));for(const e of this._vacRt.keys())a.has(e)||this._vacRt.delete(e);if(this._infoCard){const e=this._devices.find(e=>e.id===this._infoCard.id);this._infoCard=e&&"ha_disabled"!==e.bindingStatus?.kind?e:null}const l=this._devices.some(e=>"ha_disabled"===e.bindingStatus?.kind&&"ha_disabled"!==n.get(e.id));l&&("ha_disabled"!==this._infoCard?.bindingStatus?.kind&&"ha_disabled"!==this._devices.find(e=>e.id===this._infoCard?.id)?.bindingStatus?.kind||this._closeInfoCard(),this._deviceDrag&&"ha_disabled"===this._devices.find(e=>e.id===this._deviceDrag.id)?.bindingStatus?.kind&&(this._cancelDeviceDrag(),this._devicePositionHistory.clear()),clearTimeout(this._holdTimer),this._holdFired=!1,this._tip=null,this._tapConfirm=null),this._nativeMoreInfoEntity&&!this._planEntityAvailable(this._nativeMoreInfoEntity)&&(gv(this,"hass-more-info",{entityId:null}),this._nativeMoreInfoEntity=null)}_resolveAreaRelocations(e=this._haRegistry){const t=function(e){const t=Q_(e.snapshot),i=new Set(Object.values(t).map(e=>e.binding)),n=new Map;for(const[t,r]of e.previousCandidates||[])J_(t)&&Number.isFinite(r)&&i.has(t)&&n.set(t,r);const r=new Set,o=new Set;for(const t of e.markers||[])t.removed||(Z_(t.id)&&r.add(t.id),J_(t.binding)&&o.add(t.binding));const s=new Set(Object.keys(e.registryDevices||{})),a=new Set(Object.keys(e.registryEntities||{})),l=new Set(Object.keys(e.liveStates||{})),c=new Map;for(const[e,i]of Object.entries(t)){const t=c.get(i.binding)||[];t.push(e),c.set(i.binding,t)}const h=new Set;let d=!1;for(const[t,i]of c){const[c,u]=rm(t);if(o.has(t)||i.some(e=>r.has(e))||("device"===c?s.has(u):a.has(u)||l.has(u))){n.delete(t);continue}const p="device"===c?s.size>0:a.size>0;if(!e.authoritative||!p)continue;const _=n.get(t);if(void 0!==_){if(_!==e.revision)for(const e of i)h.add(e)}else n.set(t,e.revision),d=!0}return{removeIds:h,candidates:n,needsConfirmationRefresh:d}}({snapshot:this._settings.marker_area_snapshot,authoritative:e.authoritative,revision:e.revision,registryDevices:e.devices,registryEntities:e.entities,liveStates:this.hass?.states,markers:this._markers,previousCandidates:this._areaSnapshotCleanupCandidates});return this._areaSnapshotCleanupCandidates=t.candidates,t.needsConfirmationRefresh&&this._canEdit&&id(this.hass),om({devices:this._devices,model:this._model,layout:this._layout,snapshot:this._settings.marker_area_snapshot,authoritative:e.authoritative,cleanupSnapshotIds:t.removeIds,coordinateScale:_v})}_syncNewDevices(){if(!this._norm||!this._loadOk||!this._serverCfg)return;const e=this._devices.filter(e=>!e.marker&&!e.virtual).map(e=>e.id).sort(),t=e.join(",");if(t===this._newSyncKey)return;this._newSyncKey=t;const i=this._settings,{fresh:n,known:r}=function(e,t){if(!Array.isArray(t))return{fresh:[],known:[...e]};const i=new Set(t),n=e.filter(e=>!i.has(e));return{fresh:n,known:n.length?[...t,...n]:t}}(e,i.known_devices);if(!Array.isArray(i.known_devices)||n.length){const e=[...new Set([...i.new_device_ids||[],...n])];this._serverCfg={...this._serverCfg,settings:{...i,known_devices:r,new_device_ids:e}},this._saveConfig()}}_syncAreaRelocations(e){if(!(this._loadOk&&this._serverCfg&&this._norm&&this._canEdit&&this._haRegistry.authoritative))return;const t=e.decisions.filter(e=>e.updateSnapshot||e.removeSnapshot);if(!t.length)return;const i=cc({snapshot:Q_(this._settings.marker_area_snapshot),decisions:t});i!==this._areaRelocationSyncKey&&(this._areaRelocationSyncKey=i,this._areaRelocationWrite=this._areaRelocationWrite.catch(()=>{}).then(async()=>{if(!this._serverCfg||!this._haRegistry.authoritative)return;const e=this._resolveAreaRelocations();this._areaRelocationIds=new Set(e.relocateIds);const t=new Set,i=new Map;let n=!1;for(const r of e.decisions){if(!r.relocate)continue;const e=fg(this._layout,r.id);try{await this._persistDevicePlacement(r.id,null),t.add(r.id),e&&i.set(r.id,e),this._areaRelocationIds.delete(r.id)}catch(t){n=!0,this._layout=vg(this._layout,r.id,e),this._showToast(this._t("toast.pos_save_failed",{err:this._errText(t)}))}}const r=this._settings,o=function(e,t,i=new Set){const n=Q_(e);for(const e of t.decisions)e.removeSnapshot?delete n[e.id]:e.updateSnapshot&&e.binding&&e.area&&(e.relocate&&!i.has(e.id)||(n[e.id]={binding:e.binding,area:e.area}));return n}(r.marker_area_snapshot,e,t),s=[...new Set([...Array.isArray(r.new_device_ids)?r.new_device_ids:[],...t])],a=cc(o)!==cc(Q_(r.marker_area_snapshot)),l=cc(s)!==cc(Array.isArray(r.new_device_ids)?r.new_device_ids:[]);if(a||l){const e=r.marker_area_snapshot,n=r.new_device_ids,a={...this._serverCfg,settings:{...r,marker_area_snapshot:o,...l?{new_device_ids:s}:{}}};this._setAreaLifecycleConfig(a);try{this._saveConfigDebounced.pending()&&this._saveConfigDebounced.cancel(),await this._writeConfig()}catch(r){const a=this._settings;if(cc(a.marker_area_snapshot)===cc(o)&&cc(a.new_device_ids)===cc(l?s:n)){const t={...a};void 0===e?delete t.marker_area_snapshot:t.marker_area_snapshot=e,void 0===n?delete t.new_device_ids:t.new_device_ids=n;const i={...this._serverCfg,settings:t};this._setAreaLifecycleConfig(i),this._adoption.refreshConfigFingerprint()}for(const e of t)this._areaRelocationIds.add(e);const c=new Set;for(const[e,t]of i)try{await this._persistDevicePlacement(e,t)}catch(t){c.add(e),this._showToast(this._t("toast.pos_save_failed",{err:this._errText(t)}))}this._areaRelocationSyncKey="",this._regSignature="";if("conflict"===(r&&"object"==typeof r&&"code"in r?r.code:void 0)?(this._showToast(this._t("toast.conflict")),await this._reloadConfigOnly(!0)):this._showToast(this._t("toast.cfg_save_failed",{err:this._errText(r)})),c.size&&this._serverCfg){const e=this._settings,t=[...new Set([...Array.isArray(e.new_device_ids)?e.new_device_ids:[],...c])],i={...this._serverCfg,settings:{...e,new_device_ids:t}};this._setAreaLifecycleConfig(i);try{await this._writeConfig()}catch(e){this._showToast(this._t("toast.cfg_save_failed",{err:this._errText(e)}))}}}}n&&(this._areaRelocationSyncKey=""),this.requestUpdate()}))}get _newIds(){const e=this._settings.new_device_ids;return new Set([...Array.isArray(e)?e:[],...this._areaRelocationIds])}_ackNewDevice(e){if(!this._newIds.has(e)||!this._serverCfg)return;const t=this._settings;this._serverCfg={...this._serverCfg,settings:{...t,new_device_ids:(t.new_device_ids||[]).filter(t=>t!==e)}},this._saveConfig(),this.requestUpdate()}get _markers(){return this._serverCfg?.markers||[]}_roomLqi(e){if(!e)return null;const t=[];for(const i of this._renderDevices){if(i.area!==e||i.virtual)continue;const n=Ld(this._renderPlanHass,i.entities);null!=n&&t.push(n)}return Ii(t)}_roomBounds(e){if(e.poly&&e.poly.length){const t=e.poly.map(e=>e[0]),i=e.poly.map(e=>e[1]),n=Math.min(...t),r=Math.min(...i);return{x:n,y:r,w:Math.max(...t)-n,h:Math.max(...i)-r}}return{x:e.x??0,y:e.y??0,w:e.w??0,h:e.h??0}}_defaultPositions(){const e={},t=this._config?.icon_size??2.5;for(const i of this._model){const n=t/100*Ml(i)*1.3;for(const t of i.rooms){if(!t.area)continue;const r=this._devices.filter(e=>e.area===t.area&&e.space===i.id);if(!r.length)continue;const o=this._roomBounds(t),s=.1*Math.min(o.w,o.h),a=o.w-2*s,l=o.h-2*s,c=Math.max(1,Math.round(Math.sqrt(r.length*a/Math.max(l,1)))),h=Math.ceil(r.length/c),d=a/c,u=l/Math.max(h,1),p=r.map((e,t)=>({x:o.x+s+d*(t%c+.5),y:o.y+s+u*(Math.floor(t/c)+.5)}));Ei(p,o,n,.5*s),r.forEach((t,i)=>e[t.id]=al(p[i]))}}return e}_pos(e){const t=this._renderDeviceSnapshot?.positions.get(e.id);return t?{x:t.x,y:t.y}:this._livePos(e)}_livePos(e){const t=this._spaceModelById(e.space),i=this._areaRelocationIds.has(e.id)?void 0:this._layout[e.id];if(i)if(this._norm){if(i.s===e.space)return{x:i.x*_v,y:i.y*_v}}else if(void 0===i.s)return{x:i.x,y:i.y};return this._defPos[e.id]?this._defPos[e.id]:t?al($l(t)):{x:500,y:500}}_devicePlacementForCanvas(e,t,i){if(!this._norm)return{x:Math.round(t),y:Math.round(i)};const n=this._gridPitch,r=Math.round(t/n)*n,o=Math.round(i/n)*n;return{s:e.space,x:cl(r/_v),y:cl(o/_v)}}_previewDevicePlacement(e,t){this._layout=vg(this._layout,e,t),this.requestUpdate()}_cancelDeviceDrag(){const e=this._deviceDrag;if(!e)return!1;this._editorRuntime?._cancelPointerMove("device"),this._deviceDrag=null,this._deviceHits.cancel(e.pointerId);try{e.source?.hasPointerCapture?.(e.pointerId)&&e.source.releasePointerCapture(e.pointerId)}catch{}return this._previewDevicePlacement(e.id,e.before),!0}async _persistDevicePlacement(e,t){if(this._layout=vg(this._layout,e,t),this._serverStorage){let i=null,n=!1;try{let r;if(null===t)i=null,this._sentPos.set(e,i),n=!0,r=await this.hass.callWS({type:"houseplan/layout/delete",device_id:e});else{const t=xo(this._layout[e]);cc(t)!==cc(this._layout[e])&&(this._layout={...this._layout,[e]:t}),i=t,this._sentPos.set(e,i),n=!0,r=await this.hass.callWS({type:"houseplan/layout/update",device_id:e,pos:t})}this._noteLayoutRev(r),this._adoption.refreshLayoutFingerprint(),this._cacheSnapshot()}finally{n&&this._sentPos.get(e)===i&&this._sentPos.delete(e)}return}this._persistLocalLayout()}_devicePositionStateValid(e){const t=this._devices.find(t=>t.id===e.deviceId);return!!t&&t.space===e.spaceId&&"ha_disabled"!==t.bindingStatus?.kind&&!!this._spaceModelById(e.spaceId)}async _runDevicePositionHistory(e){if(this._cancelDeviceDrag()||this._devicePositionBusy)return;const t="undo"===e?this._devicePositionHistory.undo():this._devicePositionHistory.redo();if(!t)return;const i="undo"===e?t.before:t.after;if(!this._devicePositionStateValid(i))return this._devicePositionHistory.clear(),this._showToast(this._t("history.device_stale")),void this.requestUpdate();const n=fg(this._layout,i.deviceId);i.spaceId!==this._space&&(this._commitSpace(i.spaceId),this._restoreZoom()),this._devicePositionBusy=!0,this._previewDevicePlacement(i.deviceId,i.placement);try{await this._persistDevicePlacement(i.deviceId,i.placement),this._showToast(this._t("undo"===e?"history.undone":"history.redone",{name:t.name}))}catch(t){this._previewDevicePlacement(i.deviceId,n),"undo"===e?this._devicePositionHistory.redo():this._devicePositionHistory.undo(),this._showToast(this._t("toast.pos_save_failed",{err:this._errText(t)}))}finally{this._devicePositionBusy=!1,this.requestUpdate()}}_undoDevicePosition(){this._runDevicePositionHistory("undo")}_redoDevicePosition(){this._runDevicePositionHistory("redo")}_savePos(e,t,i){this._spaceModelById(e.space)&&(this._layout=vg(this._layout,e.id,this._devicePlacementForCanvas(e,t,i)),this._dirtyPos.add(e.id),this._persistLayout())}_devicePresentation(e,t=!1!==this._config?.show_signal,i=!1){const n=i?null:this._renderDeviceSnapshot?.presentations.get(f_(e.id,t));return n||p_(this._renderPlanHass,e,{liveStates:!1!==this._config?.live_states,showTemperature:!1!==this._config?.show_temperature,showSignal:t,designPreview:i,activityRuntime:this._activityRt.get(e.id),sourceDetails:!1,lightDevices:this._renderDevices,registryHass:this._fullRegistryHass,reducedMotion:this._reducedMotion})}_deviceVisual(e){return this._devicePresentation(e).visual}_stateClass(e,t=this._deviceVisual(e)){const i=this._devicePresentation(e);return i.effectiveHidden?"":("icon_ripple"!==i.display||!1===this._config?.live_states||"alarm"===t.status||t.activity,u_({...i,visual:t}).join(" "))}_liveTemp(e){if(!this._config?.show_temperature)return null;if(!0===e.marker?.use_climate_temp){const t=qd(this._renderPlanHass,e.entities);if(null!=t)return t}return"mdi:thermometer"!==e.icon&&"mdi:air-filter"!==e.icon?null:Bd(this._renderPlanHass,e.entities)}_bindingEntities(e){if("virtual"===e||!e)return[];const t=this._bindingStatus(e);return"active"===t.kind?t.enabledEntityIds:t.allEntityIds}_bindingHasClimate(e){return this._bindingEntities(e).some(e=>e.startsWith("climate."))}_bindingHasAlarm(e){return this._bindingEntities(e).some(e=>{const t=this._planHass?.states?.[e]||this.hass?.states?.[e],i=this._fullRegistryHass.entities[e]||this.hass?.entities?.[e];return Yn(e.split(".")[0],t?.attributes?.device_class||i?.device_class||i?.original_device_class)})}_deviceBindingActive(e,t=!0){if(e.virtual||"virtual"===e.bindingKind)return!0;if(!e.bindingKind||!e.bindingRef)return!1;const i=this._bindingStatus(`${e.bindingKind}:${e.bindingRef}`);return"active"===i.kind||(t&&this._showToast(this._t("ha_disabled"===i.kind?"toast.ha_disabled_action":"toast.ha_binding_unverified")),!1)}_openMoreInfo(e){e?this._planEntityAvailable(e)?(this._kiosk&&(this._cyclePausedUntil=Math.max(this._cyclePausedUntil,Date.now()+6e4)),this._nativeMoreInfoEntity=e,gv(this,"hass-more-info",{entityId:e})):this._showToast(this._t("toast.ha_disabled_action")):this._showToast(this._t("toast.no_entity"))}_interruptViewGesture(e,t){if(clearTimeout(this._holdTimer),clearTimeout(this._kioskHoldTimer),void 0!==e)for(const i of[t,this._stageEl])try{i?.hasPointerCapture?.(e)&&i.releasePointerCapture(e)}catch{}this._pointers.clear(),this._panStart=null,this._panLock=null,this._pinchStart=null,this._swipeStart=null,this._roomPointer=null,this._doubleFit.clear(),this._deviceHits.clearPointers()}_closeInfoCard(){this._interruptViewGesture(),this._holdFired=!1,this._infoCard=null}_invalidateDeviceHitGeometry(){this._deviceHits.invalidate()}_resetDeviceHitState(){this._deviceHits.reset(this.renderRoot)}_deviceHitOwnerAt(e,t){return"view"!==this._mode&&"devices"!==this._mode?null:this._deviceHits.at(this.renderRoot,this._renderDevices,this._space,e,t)}_deviceForPointerEvent(e,t){return this._deviceHits.pointer(this.renderRoot,this._renderDevices,this._space,e,t)}_deviceForClickEvent(e,t){return this._deviceHits.click(this.renderRoot,this._renderDevices,this._space,e,t)}_showDeviceTip(e,t){this._liveRt?this._liveRt.devicePointerTip(e,t):this._ensureLiveRuntime().then(()=>this._liveRt?.devicePointerTip(e,t))}_showDeviceFocusTip(e,t){const i=e.currentTarget;this._liveRt?this._liveRt.deviceFocusTip(i,t):this._ensureLiveRuntime().then(()=>this._liveRt?.deviceFocusTip(i,t))}_hideDeviceFocusTip(e){this._liveRt?.deviceBlur(e)}_clearPointerHover(){this._liveRt?this._liveRt.pointerLeave():this._clearTransientHover()}_ctxDevice(e,t){"view"===this._mode&&(t=this._deviceForPointerEvent(e,t),e.preventDefault(),e.stopPropagation(),this._deviceBindingActive(t)&&(t.primary?this._openMoreInfo(t.primary):this._infoCard=t))}_clickDevice(e,t){if("view"!==this._mode&&"devices"!==this._mode)return;if(e.stopPropagation(),t=this._deviceForClickEvent(e,t),this._deviceDrag?.moved||this._suppressClick||this._holdFired)return;if("devices"===this._mode)return void this._openMarkerDialog(t);const i=this._devices.find(e=>e.id===t.id);if(!i)return;const n=Tu(i.tapAction,i.primary?.split(".")[0]);if("none"===n)return;const r=(e,t)=>{i.marker?.tap_confirm?this._tapConfirm={kind:"run",text:e,exec:t}:t()};if("toggle"===n){const e=this._toggleIntent(i);if(!e)return;if(!Iu(e))return void this._showUnavailableToggleTargets(e);const t=e=>{const t=Iu(e);if(!t)return;if("virtual-light"===t.kind)return this._startDevicePressFeedback(i.id),void this.hass.callWS({type:"houseplan/virtual_light/toggle",marker_id:t.markerId}).then(e=>{const t=Wh(this._virtualLights,e);t!==this._virtualLights&&(this._virtualLights=t,this._capturedSnapshotVirtual="",this._cacheSnapshot(),this.requestUpdate())}).catch(e=>this._showToast(this._t("toast.virtual_light_toggle_failed",{err:this._errText(e)})));const{command:n}=t;this._startDevicePressFeedback(i.id),this.hass.callService(n.domain,n.service,n.data).catch(e=>this._showToast(this._t("toast.error",{err:this._errText(e)})))},n=((o=e).targets.length?o.targets:o.skippedTargets).map(e=>e.name||e.entityId||e.ref).join(", ")||i.name;if(i.marker?.tap_confirm){const r=this._toggleConfirmationLines(e);if(!r.length)return;this._tapConfirm={kind:"toggle",text:this._t("confirm.tap_toggle",{name:n}),lines:r,initialIntent:e,deviceId:i.id,exec:()=>{const n=this._devices.find(e=>e.id===i.id),r=n?this._toggleIntent(n):null;r&&!Iu(r)&&this._showUnavailableToggleTargets(r)||(r&&Eu(e,r)?t(r):this._showToast(this._t("toast.tap_target_changed")))}}}else t(e);return}var o;if("info"===n)return this._interruptViewGesture(),void(this._infoCard=i);if(this._deviceBindingActive(i)){if("run"===n){const e=i.marker?.tap_target||"",t=function(e){const t=String(e||"").split(".")[0];return"automation"===t?{domain:"automation",service:"trigger"}:"script"===t?{domain:"script",service:"turn_on"}:"scene"===t?{domain:"scene",service:"turn_on"}:null}(e),n=this.hass.states[e];if(!t||!n)return void this._showToast(this._t("toast.run_target_missing"));const o=n.attributes?.friendly_name||e;return void r(this._t("confirm.tap_run",{name:o}),()=>{this._deviceBindingActive(i)&&this._planEntityAvailable(e)&&(this._startDevicePressFeedback(i.id),this.hass.callService(t.domain,t.service,{entity_id:e}).then(()=>{this._stampActivity(i.id,"event",this._activitySourceKey(i)),this.requestUpdate(),this._showToast(this._t("toast.run_started",{name:o}))}).catch(e=>this._showToast(this._t("toast.error",{err:this._errText(e)}))))})}"more-info"===n&&i.primary?this._openMoreInfo(i.primary):this._infoCard=i}}_showUnavailableToggleTargets(e){const t=function(e){if(!e||"group"!==e.kind||Iu(e)||"configured-targets-missing"!==e.noneReason)return[];if(!e.skippedTargets.length||e.skippedTargets.some(e=>!Ou.has(e.reason)&&"secure"!==e.reason))return[];const t=[],i=new Set;for(const n of e.skippedTargets){if(!Ou.has(n.reason))continue;const e=String(n.name||n.entityId||n.ref||"").trim();e&&!i.has(e)&&(i.add(e),t.push(e))}return t}(e);return!!t.length&&(this._showToast(1===t.length?this._t("toast.toggle_target_unavailable",{name:t[0]}):this._t("toast.toggle_targets_unavailable",{names:t.join(", ")})),!0)}_keyDevice(e,t){"Enter"!==e.key&&" "!==e.key||"view"!==this._mode&&"devices"!==this._mode||(e.preventDefault(),this._clickDevice(e,t))}_startDevicePressFeedback(e){const t=[...this.renderRoot.querySelectorAll(".dev[data-id]")].find(t=>t.dataset.id===e),i=t?.querySelector(".device-shell");if(!i||"function"!=typeof i.animate)return;const n=Number.parseFloat(this.ownerDocument.defaultView?.getComputedStyle(i).scale||""),r=Number.isFinite(n)?Math.max(.95,Math.min(1,n)):1;this._devicePressAnimations.get(e)?.cancel();const o=this._reducedMotion?[{outlineColor:"transparent",outlineStyle:"solid",outlineWidth:"0px"},{outlineColor:"var(--hp-accent, #3ea6ff)",outlineStyle:"solid",outlineWidth:"2px",outlineOffset:"2px",offset:.5},{outlineColor:"transparent",outlineStyle:"solid",outlineWidth:"0px"}]:[{scale:String(r)},{scale:"0.95",offset:.5},{scale:"1"}],s=i.animate(o,{duration:200,easing:"cubic-bezier(.22,.61,.36,1)"});this._devicePressAnimations.set(e,s);const a=()=>{this._devicePressAnimations.get(e)===s&&this._devicePressAnimations.delete(e)};s.addEventListener("finish",a,{once:!0}),s.addEventListener("cancel",a,{once:!0})}_cancelDevicePressFeedback(){for(const e of this._devicePressAnimations.values())e.cancel();this._devicePressAnimations.clear()}_pruneDevicePressFeedback(){if(!this._devicePressAnimations.size)return;const e=new Set([...this.renderRoot.querySelectorAll(".dev[data-id]")].map(e=>e.dataset.id||""));for(const[t,i]of this._devicePressAnimations)e.has(t)||(i.cancel(),this._devicePressAnimations.delete(t))}_t(e,t){return xp(kp(this.hass,this._config?.language),e,t)}get _colorPickerLabels(){return{title:this._t("color_picker.title"),hue:this._t("color_picker.hue"),saturation:this._t("color_picker.saturation"),value:this._t("color_picker.value"),hex:this._t("color_picker.hex"),invalidHex:this._t("color_picker.invalid_hex"),confirm:this._t("color_picker.confirm")}}_help(e){return this._editorRuntimeOrThrow()._help(e)}get _stageEl(){return this.renderRoot.querySelector(".stage")}_contentItems(e){const t=[];for(const i of this._devices){if(i.space!==e.id||i.hidden)continue;const n=this._pos(i);t.push({minX:n.x,minY:n.y,maxX:n.x,maxY:n.y})}if(e.id===this._space){for(const e of this._openingsR){const i=Number(e.angle)*Math.PI/180,n=Math.cos(i)*e.rlen/2,r=Math.sin(i)*e.rlen/2,o=pl([[e.rx-n,e.ry-r],[e.rx+n,e.ry+r]]);o&&t.push(o)}const i=this._decorH;for(const e of this._decorList){if("image"===e.kind&&!this._decorAssets.has(e.asset_id)&&"decor"!==this._mode)continue;const n=pl("line"===e.kind?[[e.x1*_v,e.y1*i],[e.x2*_v,e.y2*i]]:"text"===e.kind?[[e.x*_v,e.y*i]]:Nr({x:e.x*_v,y:e.y*i,w:e.w*_v,h:e.h*i,angle:e.angle}));n&&t.push(n)}for(const i of this._physicalBodiesR(e)){const e=pl(i);e&&t.push(e)}}return vl(e,t)}_frameOf(){const e=this._spaceModel();if(!e){this._frame=null;const e={x:0,y:0,w:_v,h:_v};return{rect:e,all:e,outliers:0}}const t=this._frame,i="view"!==this._mode;if(t&&t.id===e.id&&this._bdDrag)return t;if(t&&t.id===e.id&&t.model===e&&t.layout===this._layout&&t.devs===this._devices&&t.far===this._showFar&&t.grow===i)return t;const n=kl(this._contentItems(e));let r=n.all||Sl(e),o=this._showFar?r:n.core||Sl(e);return t&&t.id===e.id&&i&&t.grow&&(o=mv(t.rect,o),r=mv(t.all,r)),this._frame={id:e.id,model:e,layout:this._layout,devs:this._devices,far:this._showFar,grow:i,rect:o,all:r,outliers:n.outliers},this._frame}_isoSource(){const e=this._isoSceneRuntime;if(!e)return null;const t=this._spaceModel();if(!t)return null;const i=this._spaceWalls,n=this._openCuts(),r=this._openingsR;return e.createIsoStructuralSource({space:t,walls:i,openCuts:n,openings:r,partitionCuts:()=>this._partitionOpeningCuts(t),roomOpenings:()=>this._roomWallOpeningInputs(r,t),cellCm:this._cellCm,gridPitch:this._gridPitch,wallKeyPitch:this._wallKeyPitch,coordinateScale:_v,onBuild:()=>{this._isoStructuralBuildCount+=1}})}_isoSceneKey(){if(!this._labsIso||"view"!==this._mode)return null;try{return this._isoSource()?.key??null}catch{return this._isoInvalidKey()}}_isoInvalidKey(){return`${this._space}|invalid|${this._cfgEpoch}`}_clearIsoInvalidFallback(e){const t=`${this._space}|invalid|`;for(const i of this._isoFallback)i.startsWith(t)&&i!==e&&this._isoFallback.delete(i)}_isoScene(e=this._isoSource()){const t=this._isoSceneRuntime;if(!t||!e)return null;let i=this._frameOf().rect;const n=this._spaceDisplayForRender(),r=this._spaceModel();if(r&&n.showNames)for(const e of r.rooms)if(e.name){const t=this._labelPos(e,r.id);i=mv(i,{x:t.x,y:t.y,w:0,h:0})}const o=t.resolveIsoScene({source:e,cache:this._isoGeometryCache,cellCm:this._cellCm,liveFrame:i});if(!r||!n.showBorders)return o;const s=this._config?.icon_size??2.5,a=s>8?2.5:s,l=this._stageEl?.getBoundingClientRect?.()??null,c=l?.height?l.width/l.height:o.frame.w/o.frame.h,h=Oi([o.frame.x,o.frame.y,o.frame.w,o.frame.h],c),d=this._isoOverlayScene(r,this._renderDevices.filter(e=>e.space===r.id&&!e.hidden),h,n,t.resolveIsoDecorationLayers(n),o,a,x_(a),n.showLqi??this._config?.show_signal??!0,!1),u=d&&t.resolveIsoOverlayFitEnvelope({baseBounds:o.frame,entries:d.entries,stageSize:l,targetView:e=>Oi([e.x,e.y,e.w,e.h],c)});return u?{...o,frame:u.bounds,overlayFitEntries:d.entries}:o}_latchIsoFallback(e,t){if(this._isoFallback.has(e))return;this._isoFallback.add(e);const i=e.includes("|invalid|")?"invalid":e.split("|").pop()||"invalid";console.warn("HOUSEPLAN ISO FALLBACK: #89/#160",wf("structural",i,!0))}_effectiveProjection(){if(this._isoProjectionSnapshot)return this._isoProjectionSnapshot;const e=e=>this._isoProjectionSnapshot=e,t=()=>("iso"===this._renderProjection&&(this._cancelCameraTransition(!1),this._view=null,this._viewModeSnap=null),e("flat"));if(this._renderIsoScene=null,"iso"!==this._desiredProjection||!this._model.length||!this._isoSceneRuntime)return e("flat");if(!this._spaceDisplayForRender().showBorders)return this._isoFallback.has(`${this._space}|no-borders`)?t():e("iso");let i=this._isoInvalidKey();if(this._clearIsoInvalidFallback(i),this._isoFallback.has(i))return t();try{const n=this._isoSource();if(!n)return e("flat");if(i=n.key,this._isoFallback.has(i))return t();const r=this._isoScene(n);return r?this._isoFallback.has(r.key)?t():(this._renderIsoScene=r,e("iso")):e("flat")}catch(e){return this._latchIsoFallback(i,e),t()}}_scenePoint(e){return"iso"===this._renderProjection?lf(e,0):e}_floorView(e){if("iso"!==this._renderProjection)return e;const t=cf([e.x,e.y]),i=cf([e.x+e.w,e.y+e.h]);return{x:t[0],y:t[1],w:i[0]-t[0],h:i[1]-t[1]}}_isoOverlayScene(e,t,i,n,r,o,s,a,l,c=!0){const h=this._isoSceneRuntime;return h&&r?.structural&&o?h.buildIsoOverlayRenderScene({space:e,devices:t,openings:this._openingsR,view:i,display:n,wallSilhouettes:o.wallSilhouettes,resolveCollisions:c,iconPct:s,deviceBasePct:a,showLqi:l,cellCm:this._cellCm,kioskIconScale:"view"===this._mode?this._kioskScale.icon:1,kioskFontScale:"view"===this._mode?this._kioskScale.font:1,stageSize:this._stageEl?.getBoundingClientRect?.(),positionOf:e=>this._pos(e),presentationOf:(e,t)=>this._devicePresentation(e,t),labelPositionOf:(e,t)=>this._labelPos(e,t),labelScaleOf:e=>this._labelScale(e),openingEntityAvailable:e=>this._renderOpeningEntityAvailable(e),openingWallIndex:()=>this._openingWallIndexFor(e,this._openCuts()).value}):null}_baseVb(e=this._effectiveProjection(),t=this._renderIsoScene){if("iso"===e){if(!this._spaceDisplayForRender().showBorders){const e=uf({rect:this._frameOf().rect,wallHeight:0});return[e.x,e.y,e.w,e.h]}const e=t?.frame??this._frameOf().rect;return[e.x,e.y,e.w,e.h]}const i=this._frameOf().rect;return[i.x,i.y,i.w,i.h]}get _outliers(){return this._showFar?0:this._frameOf().outliers}_fitFar(){this._clearRoomFocus(),this._showFar=!0,this._frame=null,this.requestUpdate(),this._resetZoom()}_clearRoomFocus(e=!1){this._doubleFit.clear(),this._roomFocus=null,e&&(this._roomPointer=null)}_roomFitBounds(e,t){const i=ni(e);if(!i||!e.id)return null;const n=this._spaceWalls,r=this._openCuts(),o=this._wallUnionGeometry(),s=n.length&&this._innerRoomContour(t,e.id,r,o?.roomGeom,o?.multiWallNodes)||i,a=this._spaceDisplayForRender();let l=[];if(a.showBorders&&n.length){const i=Fs(t.rooms,e.id,n,r,this._wallKeyPitch,this._cellCm,this._gridPitch,_v);i&&(l=aa(i.poly,i.offsets,o?.multiWallNodes)||i.poly)}const c=this._effectiveProjection();return function(e){const t=e.floor,i=e.wall||[],n=e.padding??0;if(!t.length||!t.every(vf)||!i.every(vf)||!Number.isFinite(n)||n<0)return null;if("flat"===e.projection)return bf([...t,...i],n);const r=e.wallHeight??0,o=e.floorDepth??0;if(!Number.isFinite(r)||r<0||!Number.isFinite(o)||o<0)return null;try{const e=[];for(const i of t){const t=[i[0],i[1]];e.push(lf(t,0)),o>0&&e.push(lf(t,-o))}for(const t of i){const i=[t[0],t[1]];e.push(lf(i,0)),r>0&&e.push(lf(i,r))}return bf(e,n)}catch{return null}}({floor:s,wall:l,projection:c,wallHeight:"iso"===c&&a.showBorders?Wa(84,this._cellCm):0,floorDepth:"iso"===c&&a.showBorders?Wa(10,this._cellCm):0,padding:a.showBorders?Wa(1.25,this._cellCm):0})}_fitRoom(e,t=!0){if("view"!==this._mode)return!1;this._doubleFit.clear();const i=this._spaceModel(),n=i?.rooms.find(t=>t.id===e);if(!i||!n)return this._clearRoomFocus(),!1;let r=this._roomFitBounds(n,i);if(!r)return this._clearRoomFocus(),!1;this._roomFocus={spaceId:i.id,roomId:e};const o=this._stageEl;if(!o||o.clientWidth<=0||o.clientHeight<=0)return!0;const s=Oi(this._baseVb(),o.clientWidth/o.clientHeight),a=e=>function(e){const t=e.safeFraction??.8,{bounds:i,baseFit:n,stageWidth:r,stageHeight:o,minZoom:s,maxZoom:a}=e;if(!yf(i)||!yf(n)||!Number.isFinite(r)||r<=0||!Number.isFinite(o)||o<=0||!Number.isFinite(s)||s<=0||!Number.isFinite(a)||a1)return null;const l=r/o,c=Math.max(i.w/t,i.h/t*l);if(!Number.isFinite(c)||c<=0)return null;const h=Math.min(a,Math.max(s,n.w/c)),d=n.w/h,u=d/l;return{zoom:h,viewBox:{x:i.x+i.w/2-d/2,y:i.y+i.h/2-u/2,w:d,h:u}}}({bounds:e,baseFit:s,stageWidth:o.clientWidth,stageHeight:o.clientHeight,minZoom:wv.ZOOM_MIN,maxZoom:wv.ZOOM_MAX});let l=a(r);const c=this._isoSceneRuntime,h=this._renderIsoScene?.overlayFitEntries;if(l&&"iso"===this._effectiveProjection()&&c&&h?.length){const e=c.resolveIsoOverlayFitEnvelope({baseBounds:r,entries:h,ownerId:n.id,stageSize:{width:o.clientWidth,height:o.clientHeight},targetView:e=>a(e)?.viewBox??null});e&&(r=e.bounds,l=a(r))}if(!l)return this._clearRoomFocus(),!1;const d=this._cameraState(),u=function(e,t,i,n){const r=[e,t,i,n],o=Math.min(...r.map(e=>e.x)),s=Math.min(...r.map(e=>e.y));return{x:o,y:s,w:Math.max(...r.map(e=>e.x+e.w))-o,h:Math.max(...r.map(e=>e.y+e.h))-s}}(s,d.viewBox,l.viewBox,r);return l.viewBox=this._clampView(l.viewBox,u),t?(this._prepareCameraCommand(),this._startCameraTransition(l,u,"room",220),!0):(this._cancelCameraTransition(!1),Xg(d,l)||(this._zoom=l.zoom,this._view={...l.viewBox},this.requestUpdate()),!0)}_fitAll(e="fit"){this._clearRoomFocus(),this._showFar=!0,this._frame=null,this.requestUpdate(),this._resetZoom(e)}_renderFarHint(){return this._kiosk||"view"!==this._mode||this._booting||!this._outliers?G:j`
${this._t("canvas.far_objects",{n:this._outliers})} @@ -820,7 +820,7 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db ${this._renderOpeningLocks(S,R?.locks)} ${g.showNames||this._markup?a.rooms.map(e=>this._renderRoomLabel(e,a,S,g,R?.rooms.get(e))):G} ${this._markup?a.rooms.map(e=>this._renderRoomGear(e,a,S)):G} - ${q={hass:this.hass,settings:this._settings,devices:this._renderDevices,registry:this._haRegistry,currentSpace:a.id,spaces:this._serverCfg?.spaces,viewKey:S,view:"view"===this._mode,kiosk:this._kiosk},q.view&&!q.kiosk&&!0===q.hass?.user?.is_admin&&zg(q.settings).enabled?(import("./hp-zigbee-topology-overlay-SYVcVGiq.js"),j``):G}
diff --git a/custom_components/houseplan/frontend/houseplan-assets/houseplan-editor-runtime-BG2wMJ7n.js b/custom_components/houseplan/frontend/houseplan-assets/houseplan-editor-runtime-DOSm4OKX.js similarity index 88% rename from custom_components/houseplan/frontend/houseplan-assets/houseplan-editor-runtime-BG2wMJ7n.js rename to custom_components/houseplan/frontend/houseplan-assets/houseplan-editor-runtime-DOSm4OKX.js index 0bf2a6cc..d0ceaa7b 100644 --- a/custom_components/houseplan/frontend/houseplan-assets/houseplan-editor-runtime-BG2wMJ7n.js +++ b/custom_components/houseplan/frontend/houseplan-assets/houseplan-editor-runtime-DOSm4OKX.js @@ -1,4 +1,4 @@ -globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db7c58754eeb4ba03f835b8d7c84c6";import{e as t,i as e,E as s,s as i,a as o,n as a,f as n,b as r,l,o as h,r as c,A as d,c as p,d as u,g as _,h as g,v as m,j as f,k as b,m as v,p as y,q as $,t as w,u as k,w as x,x as M,T as C,y as S,D as P,z as D,B as I,C as L,F as T,G as R,H as z,I as F,J as N,K as A,L as E,M as O,N as H,O as B,P as W,Q as j,R as G,S as q,U,V as K,W as V,X as J,Y as Z,Z as Y,_ as X,$ as Q,a0 as tt,a1 as et,a2 as st,a3 as it,a4 as ot,a5 as at,a6 as nt,a7 as rt,a8 as lt,a9 as ht,aa as ct,ab as dt,ac as pt,ad as ut,ae as _t,af as gt,ag as mt,ah as ft,ai as bt,aj as vt,ak as yt,al as $t,am as wt,an as kt,ao as xt,ap as Mt,aq as Ct,ar as St,as as Pt,at as Dt,au as It,av as Lt,aw as Tt,ax as Rt,ay as zt,az as Ft,aA as Nt,aB as At,aC as Et,aD as Ot,aE as Ht,aF as Bt,aG as Wt,aH as jt,aI as Gt,aJ as qt,aK as Ut,aL as Kt,aM as Vt,aN as Jt,aO as Zt,aP as Yt,aQ as Xt,aR as Qt,aS as te,aT as ee,aU as se,aV as ie,aW as oe,aX as ae,aY as ne,aZ as re,a_ as le,a$ as he,b0 as ce,b1 as de,b2 as pe,b3 as ue,b4 as _e,b5 as ge,b6 as me,b7 as fe,b8 as be,b9 as ve,ba as ye,bb as $e,bc as we,bd as ke,be as xe,bf as Me,bg as Ce,bh as Se,bi as Pe,bj as De,bk as Ie,bl as Le,bm as Te,bn as Re,bo as ze,bp as Fe,bq as Ne,br as Ae,bs as Ee,bt as Oe,bu as He,bv as Be,bw as We,bx as je,by as Ge,bz as qe,bA as Ue,bB as Ke,bC as Ve,bD as Je,bE as Ze,bF as Ye,bG as Xe,bH as Qe,bI as ts,bJ as es,bK as ss,bL as is,bM as os,bN as as,bO as ns,bP as rs,bQ as ls,bR as hs,bS as cs,bT as ds,bU as ps,bV as us,bW as _s,bX as gs,bY as ms,bZ as fs,b_ as bs,b$ as vs,c0 as ys,c1 as $s,c2 as ws,c3 as ks,c4 as xs,c5 as Ms,c6 as Cs,c7 as Ss,c8 as Ps,c9 as Ds,ca as Is,cb as Ls,cc as Ts,cd as Rs,ce as zs,cf as Fs,cg as Ns,ch as As,ci as Es,cj as Os,ck as Hs,cl as Bs,cm as Ws,cn as js,co as Gs,cp as qs,cq as Us,cr as Ks,cs as Vs,ct as Js,cu as Zs,cv as Ys,cw as Xs,cx as Qs,cy as ti,cz as ei,cA as si,cB as ii,cC as oi,cD as ai,cE as ni,cF as ri,cG as li,cH as hi,cI as ci,cJ as di,cK as pi,cL as ui,cM as _i,cN as gi,cO as mi,cP as fi,cQ as bi,cR as vi,cS as yi,cT as $i,cU as wi,cV as ki,cW as xi,cX as Mi,cY as Ci,cZ as Si,c_ as Pi,c$ as Di,d0 as Ii,d1 as Li,d2 as Ti,d3 as Ri,d4 as zi,d5 as Fi,d6 as Ni,d7 as Ai,d8 as Ei,d9 as Oi,da as Hi,db as Bi,dc as Wi,dd as ji,de as Gi,df as qi,dg as Ui,dh as Ki,di as Vi,dj as Ji,dk as Zi,dl as Yi,dm as Xi,dn as Qi,dp as to,dq as eo,dr as so,ds as io,dt as oo,du as ao,dv as no,dw as ro,dx as lo,dy as ho,dz as co,dA as po,dB as uo,dC as _o,dD as go,dE as mo,dF as fo}from"./houseplan-card-BiUNLHFh.js";import{c as bo,f as vo,C as yo}from"./form-kit.styles-BQTkV2m1.js";import{F as $o,f as wo,p as ko,c as xo,e as Mo,r as Co,a as So,s as Po}from"./backdrop-pick-Ev52LRir.js";import{t as Do,h as Io,m as Lo,T as To}from"./zigbee-topology-B31-i8CL.js";import{GENERATED_FURNITURE_ART as Ro,FURNITURE_ART_FINGERPRINT as zo}from"./furniture-plan-art.generated-O7K1vBfu.js";const Fo={},No=t(class extends e{constructor(){super(...arguments),this.ot=Fo}render(t,e){return e()}update(t,[e,i]){if(Array.isArray(e)){if(Array.isArray(this.ot)&&this.ot.length===e.length&&e.every((t,e)=>t===this.ot[e]))return s}else if(this.ot===e)return s;return this.ot=Array.isArray(e)?Array.from(e):e,this.render(e,i)}});var Ao={"gs.show_room_tooltip":"Show the room information window on hover","support.about_group":"About the card","support.guide_group":"Documentation","support.guide":"User guide","support.form_group":"Send a report or suggestion","support.contact":"Contact details (email/tg/WhatsApp), optional.","support.message":"Message","support.attach":"Attach anonymized information from your plan","support.attach_hint":"Includes only allowed plan geometry, settings and bounded runtime facts. Excludes names, Home Assistant IDs, live states, URLs, files, and your message/contact.","support.geometry_warning":"The package contains no names or Home Assistant IDs, but it does contain the exact geometry and dimensions of your home.","support.close_busy_title":"Stop the current operation?","support.close_busy_body":"House Plan is preparing or sending the report. Closing now stops waiting for the result.","support.building":"Preparing anonymized data…","support.preview_summary":"Package v{version} · {spaces} spaces · {size} KiB","support.prepared":"Snapshot prepared {n} min ago","support.show_data":"Show data","support.download":"Download JSON","support.refresh":"Refresh snapshot","support.privacy":"When you send, your message, optional contact and, if selected, exact geometry leave your Home Assistant through the House Plan project relay and are visible to maintainers. The project node keeps the report for up to 30 days. Network infrastructure sees your HA server address, but House Plan does not retain it raw; rate-limit and idempotency metadata is kept for up to 24 hours.","support.error_title":"The report was not sent","support.manual_recovery":"You can keep the message and attachment and continue manually:","support.copy_message":"Copy message","support.success":"Report sent: {id}. Save this number when contacting support.","support.copy_id":"Copy ID","support.sending":"Sending…","support.retry":"Retry","support.send":"Send","support.update_required":"Update the House Plan card and integration to compatible versions to send reports.","support.message_copied":"Message copied","support.id_copied":"Report ID copied","support.copy_failed":"Could not access the clipboard. Select and copy the text manually.","support.validation.message_required":"Enter a message.","support.validation.message_too_long":"The message must contain no more than 10,000 characters.","support.validation.contact_too_long":"Contact details must contain no more than 320 characters.","support.validation.preview_missing":"Wait for the attachment preview or turn the attachment off.","support.validation.preview_expired":"The attachment preview expired. Refresh the snapshot.","support.error.support_invalid_message":"Check the message and try again.","support.error.support_preview_expired":"The attachment preview expired or is no longer available. Refresh the snapshot.","support.error.support_package_too_large":"The anonymized package exceeds the 8 MiB limit.","support.error.support_rate_limited":"Too many reports or previews were requested. Try again later.","support.error.support_unavailable":"The private support service is temporarily unavailable. Your draft remains here.","support.error.support_rejected":"The report did not pass the support service validation.","support.error.unauthorized":"You do not have permission to send this report.","vac.routes_section":"Maps and floors","vac.routes_current_map":"Current map","vac.routes_no_map":"no telemetry","vac.routes_status":"Routing","vac.routes_state_ready":"map assigned and calibrated","vac.routes_state_needs_calibration":"map assigned, calibration needed","vac.routes_state_unmapped":"current map is not assigned to a floor","vac.routes_state_ambiguous":"two maps are indistinguishable — no floor is chosen","vac.routes_state_missing_space":"the map's space was deleted","vac.routes_state_none":"no map data","vac.routes_empty":"No map is assigned to a floor yet.","vac.route_map_default":"no map id","vac.route_active":"Active","vac.route_space":"Space","vac.route_space_none":"not selected","vac.route_status_ready":"ready","vac.route_status_needs_calibration":"needs calibration","vac.route_status_ambiguous":"ambiguous","vac.route_status_missing_space":"space deleted","vac.route_missing_space_group":"Deleted space","vac.route_add_current":"Add current map","vac.route_delete":"Remove map","vac.route_delete_title":"Remove the map from its floor?","vac.route_delete_body":"Calibration and saved paths for this map will be removed. Continue?","vac.route_delete_confirm":"Remove","vac.route_space_title":"Move the map to another space?","vac.route_space_body":"Calibration and saved paths for this map will be removed. Continue?","vac.route_space_confirm":"Move","vac.route_missing_space_hint":"One of the maps points at a deleted space: pick a new one or remove the map. Until then the robot is not drawn for that map.","vac.route_default_hint":"The source reports no stable map id. Several floors cannot be told apart without another source or the robot's own selected map.","vac.route_target_hint":"The dock stays in the “{space}” space regardless of the current map.","vac.route_add_source":"Add a map source","vac.route_add_source_hint":"For integrations that give each map its own camera. The “All cameras” section above widens this list.","vac.route_source_no_map":"no map reported"};const Eo={en:Ao,ru:{"gs.show_room_tooltip":"Показывать окно с информацией при наведении на комнату","support.about_group":"О карточке","support.guide_group":"Документация","support.guide":"Руководство пользователя","support.form_group":"Отправить репорт или предложение","support.contact":"Контакт для связи (email/tg/WhatsApp), необязательно.","support.message":"Сообщение","support.attach":"Прикрепить обезличенную информацию из вашего плана","support.attach_hint":"В пакет входят только разрешённые геометрия, настройки и ограниченные сведения о среде. Не входят имена, HA id, текущие состояния, URL, файлы, сообщение и контакт.","support.geometry_warning":"Пакет не содержит имён и HA id, но содержит точную геометрию и размеры дома.","support.close_busy_title":"Прервать текущую операцию?","support.close_busy_body":"House Plan подготавливает или отправляет репорт. При закрытии ожидание результата прекратится.","support.building":"Подготавливаем обезличенные данные…","support.preview_summary":"Пакет v{version} · пространств: {spaces} · {size} КиБ","support.prepared":"Снимок подготовлен {n} мин назад","support.show_data":"Показать данные","support.download":"Скачать JSON","support.refresh":"Обновить снимок","support.privacy":"При отправке сообщение, необязательный контакт и, если выбран пакет, точная геометрия покидают ваш Home Assistant через relay проекта House Plan и доступны мейнтейнерам. Узел проекта хранит репорт до 30 дней. Сетевая инфраструктура видит адрес сервера HA, но House Plan не сохраняет его в исходном виде; метаданные лимитов и идемпотентности хранятся до 24 часов.","support.error_title":"Репорт не отправлен","support.manual_recovery":"Сообщение и вложение можно сохранить и продолжить вручную:","support.copy_message":"Копировать сообщение","support.success":"Репорт отправлен: {id}. Сохраните номер для связи с поддержкой.","support.copy_id":"Копировать ID","support.sending":"Отправляем…","support.retry":"Повторить","support.send":"Отправить","support.update_required":"Обновите карточку и интеграцию House Plan до совместимых версий, чтобы отправлять репорты.","support.message_copied":"Сообщение скопировано","support.id_copied":"ID репорта скопирован","support.copy_failed":"Не удалось получить доступ к буферу обмена. Выделите и скопируйте текст вручную.","support.validation.message_required":"Введите сообщение.","support.validation.message_too_long":"Сообщение должно содержать не более 10 000 символов.","support.validation.contact_too_long":"Контакт должен содержать не более 320 символов.","support.validation.preview_missing":"Дождитесь предпросмотра вложения или отключите его.","support.validation.preview_expired":"Предпросмотр вложения истёк. Обновите снимок.","support.error.support_invalid_message":"Проверьте сообщение и повторите попытку.","support.error.support_preview_expired":"Предпросмотр вложения истёк или больше недоступен. Обновите снимок.","support.error.support_package_too_large":"Обезличенный пакет превышает лимит 8 МиБ.","support.error.support_rate_limited":"Запрошено слишком много репортов или предпросмотров. Повторите позже.","support.error.support_unavailable":"Закрытая служба поддержки временно недоступна. Черновик сохранён в этом окне.","support.error.support_rejected":"Репорт не прошёл проверку службы поддержки.","support.error.unauthorized":"У вас нет прав на отправку этого репорта.","vac.routes_section":"Карты и этажи","vac.routes_current_map":"Текущая карта","vac.routes_no_map":"источник молчит","vac.routes_status":"Маршрутизация","vac.routes_state_ready":"карта сопоставлена и откалибрована","vac.routes_state_needs_calibration":"карта сопоставлена, нужна калибровка","vac.routes_state_unmapped":"текущая карта не сопоставлена этажу","vac.routes_state_ambiguous":"две карты неразличимы — этаж не выбирается","vac.routes_state_missing_space":"пространство карты удалено","vac.routes_state_none":"нет данных о карте","vac.routes_empty":"Ни одна карта ещё не сопоставлена этажу.","vac.route_map_default":"без идентификатора","vac.route_active":"Текущая","vac.route_space":"Пространство","vac.route_space_none":"не выбрано","vac.route_status_ready":"готова","vac.route_status_needs_calibration":"нужна калибровка","vac.route_status_ambiguous":"неоднозначна","vac.route_status_missing_space":"пространство удалено","vac.route_missing_space_group":"Пространство удалено","vac.route_add_current":"Добавить текущую карту","vac.route_delete":"Удалить карту","vac.route_delete_title":"Удалить карту с этажа?","vac.route_delete_body":"Калибровка и сохранённые пути этой карты будут удалены. Продолжить?","vac.route_delete_confirm":"Удалить","vac.route_space_title":"Перенести карту в другое пространство?","vac.route_space_body":"Калибровка и сохранённые пути этой карты будут удалены. Продолжить?","vac.route_space_confirm":"Перенести","vac.route_missing_space_hint":"Одна из карт ссылается на удалённое пространство: выберите новое или удалите карту. Пока ссылка не исправлена, робот на этой карте не рисуется.","vac.route_default_hint":"Источник не сообщает стабильный идентификатор карты. Несколько этажей нельзя различить без другого источника или собственной карты робота.","vac.route_target_hint":"Док остаётся в пространстве «{space}» независимо от текущей карты.","vac.route_add_source":"Добавить источник карты","vac.route_add_source_hint":"Для интеграций, где у каждой карты своя камера. Список расширяется разделом «Все камеры» выше.","vac.route_source_no_map":"карта не читается"},de:{"gs.show_room_tooltip":"Rauminformationen beim Darüberfahren anzeigen","support.about_group":"Über die Karte","support.guide_group":"Dokumentation","support.guide":"Benutzerhandbuch","support.form_group":"Bericht oder Vorschlag senden","support.contact":"Kontakt (E-Mail/tg/WhatsApp), optional.","support.message":"Nachricht","support.attach":"Anonymisierte Informationen aus dem Plan anhängen","support.attach_hint":"Enthält nur erlaubte Plangeometrie, Einstellungen und begrenzte Laufzeitdaten. Namen, Home-Assistant-IDs, Live-Zustände, URLs, Dateien, Nachricht und Kontakt werden ausgeschlossen.","support.geometry_warning":"Das Paket enthält keine Namen oder Home-Assistant-IDs, aber die exakte Geometrie und die Maße Ihres Hauses.","support.close_busy_title":"Aktuellen Vorgang abbrechen?","support.close_busy_body":"House Plan bereitet den Bericht vor oder sendet ihn. Beim Schließen wird nicht weiter auf das Ergebnis gewartet.","support.building":"Anonymisierte Daten werden vorbereitet…","support.preview_summary":"Paket v{version} · {spaces} Bereiche · {size} KiB","support.prepared":"Schnappschuss vor {n} Min. erstellt","support.show_data":"Daten anzeigen","support.download":"JSON herunterladen","support.refresh":"Schnappschuss aktualisieren","support.privacy":"Beim Senden verlassen Ihre Nachricht, der optionale Kontakt und, falls ausgewählt, die exakte Geometrie Ihren Home Assistant über das House-Plan-Projektrelay und sind für die Maintainer sichtbar. Der Projektserver speichert den Bericht bis zu 30 Tage. Die Netzwerkinfrastruktur sieht die Adresse Ihres HA-Servers, House Plan speichert sie jedoch nicht im Rohformat; Limit- und Idempotenzdaten bleiben bis zu 24 Stunden erhalten.","support.error_title":"Der Bericht wurde nicht gesendet","support.manual_recovery":"Nachricht und Anhang können gespeichert und manuell weitergegeben werden:","support.copy_message":"Nachricht kopieren","support.success":"Bericht gesendet: {id}. Bewahren Sie diese Nummer für den Support auf.","support.copy_id":"ID kopieren","support.sending":"Wird gesendet…","support.retry":"Erneut versuchen","support.send":"Senden","support.update_required":"Aktualisieren Sie House-Plan-Karte und Integration auf kompatible Versionen, um Berichte zu senden.","support.message_copied":"Nachricht kopiert","support.id_copied":"Berichts-ID kopiert","support.copy_failed":"Kein Zugriff auf die Zwischenablage. Markieren und kopieren Sie den Text manuell.","support.validation.message_required":"Geben Sie eine Nachricht ein.","support.validation.message_too_long":"Die Nachricht darf höchstens 10.000 Zeichen enthalten.","support.validation.contact_too_long":"Der Kontakt darf höchstens 320 Zeichen enthalten.","support.validation.preview_missing":"Warten Sie auf die Vorschau oder deaktivieren Sie den Anhang.","support.validation.preview_expired":"Die Anhangsvorschau ist abgelaufen. Aktualisieren Sie den Schnappschuss.","support.error.support_invalid_message":"Prüfen Sie die Nachricht und versuchen Sie es erneut.","support.error.support_preview_expired":"Die Anhangsvorschau ist abgelaufen oder nicht mehr verfügbar. Aktualisieren Sie den Schnappschuss.","support.error.support_package_too_large":"Das anonymisierte Paket überschreitet das Limit von 8 MiB.","support.error.support_rate_limited":"Zu viele Berichte oder Vorschauen wurden angefordert. Versuchen Sie es später erneut.","support.error.support_unavailable":"Der private Supportdienst ist vorübergehend nicht verfügbar. Der Entwurf bleibt in diesem Fenster erhalten.","support.error.support_rejected":"Der Bericht hat die Prüfung des Supportdienstes nicht bestanden.","support.error.unauthorized":"Sie dürfen diesen Bericht nicht senden.","vac.routes_section":"Karten und Etagen","vac.routes_current_map":"Aktuelle Karte","vac.routes_no_map":"keine Telemetrie","vac.routes_status":"Zuordnung","vac.routes_state_ready":"Karte zugeordnet und kalibriert","vac.routes_state_needs_calibration":"Karte zugeordnet, Kalibrierung nötig","vac.routes_state_unmapped":"aktuelle Karte keiner Etage zugeordnet","vac.routes_state_ambiguous":"zwei Karten nicht unterscheidbar — keine Etage gewählt","vac.routes_state_missing_space":"der Raum der Karte wurde gelöscht","vac.routes_state_none":"keine Kartendaten","vac.routes_empty":"Noch keine Karte einer Etage zugeordnet.","vac.route_map_default":"ohne Karten-ID","vac.route_active":"Aktiv","vac.route_space":"Raum","vac.route_space_none":"nicht gewählt","vac.route_status_ready":"bereit","vac.route_status_needs_calibration":"Kalibrierung nötig","vac.route_status_ambiguous":"mehrdeutig","vac.route_status_missing_space":"Raum gelöscht","vac.route_missing_space_group":"Gelöschter Bereich","vac.route_add_current":"Aktuelle Karte hinzufügen","vac.route_delete":"Karte entfernen","vac.route_delete_title":"Karte von der Etage entfernen?","vac.route_delete_body":"Kalibrierung und gespeicherte Pfade dieser Karte werden entfernt. Fortfahren?","vac.route_delete_confirm":"Entfernen","vac.route_space_title":"Karte in einen anderen Raum verschieben?","vac.route_space_body":"Kalibrierung und gespeicherte Pfade dieser Karte werden entfernt. Fortfahren?","vac.route_space_confirm":"Verschieben","vac.route_missing_space_hint":"Eine Karte verweist auf einen gelöschten Raum: neuen wählen oder Karte entfernen. Bis dahin wird der Roboter für diese Karte nicht gezeichnet.","vac.route_default_hint":"Die Quelle meldet keine stabile Karten-ID. Mehrere Etagen lassen sich ohne andere Quelle oder die vom Roboter gewählte Karte nicht unterscheiden.","vac.route_target_hint":"Die Station bleibt unabhängig von der aktuellen Karte im Raum „{space}“.","vac.route_add_source":"Kartenquelle hinzufügen","vac.route_add_source_hint":"Für Integrationen, die jeder Karte eine eigene Kamera geben. Der Abschnitt „Alle Kameras“ oben erweitert diese Liste.","vac.route_source_no_map":"keine Karte gemeldet"},fr:{"gs.show_room_tooltip":"Afficher les informations de la pièce au survol","support.about_group":"À propos de la carte","support.guide_group":"Documentation d’aide","support.guide":"Guide utilisateur","support.form_group":"Envoyer un rapport ou une suggestion","support.contact":"Contact (e-mail/tg/WhatsApp), facultatif.","support.message":"Votre message","support.attach":"Joindre des informations anonymisées de votre plan","support.attach_hint":"Inclut uniquement la géométrie, les réglages autorisés et des données d’exécution limitées. Exclut les noms, identifiants Home Assistant, états en direct, URL, fichiers, message et contact.","support.geometry_warning":"Le paquet ne contient ni noms ni identifiants Home Assistant, mais il contient la géométrie et les dimensions exactes de votre logement.","support.close_busy_title":"Interrompre l’opération en cours ?","support.close_busy_body":"House Plan prépare ou envoie le rapport. Fermer maintenant arrête l’attente du résultat.","support.building":"Préparation des données anonymisées…","support.preview_summary":"Paquet v{version} · {spaces} espaces · {size} Kio","support.prepared":"Instantané préparé il y a {n} min","support.show_data":"Afficher les données","support.download":"Télécharger le JSON","support.refresh":"Actualiser l’instantané","support.privacy":"Lors de l’envoi, votre message, le contact facultatif et, si elle est sélectionnée, la géométrie exacte quittent votre Home Assistant via le relais du projet House Plan et sont visibles par les mainteneurs. Le serveur du projet conserve le rapport jusqu’à 30 jours. L’infrastructure réseau voit l’adresse de votre serveur HA, mais House Plan ne la conserve pas en clair ; les métadonnées de limitation et d’idempotence sont gardées jusqu’à 24 heures.","support.error_title":"Le rapport n’a pas été envoyé","support.manual_recovery":"Vous pouvez conserver le message et la pièce jointe puis continuer manuellement :","support.copy_message":"Copier le message","support.success":"Rapport envoyé : {id}. Conservez ce numéro pour contacter l’assistance.","support.copy_id":"Copier l’ID","support.sending":"Envoi…","support.retry":"Réessayer","support.send":"Envoyer","support.update_required":"Mettez à jour la carte et l’intégration House Plan vers des versions compatibles pour envoyer des rapports.","support.message_copied":"Message copié","support.id_copied":"ID du rapport copié","support.copy_failed":"Impossible d’accéder au presse-papiers. Sélectionnez et copiez le texte manuellement.","support.validation.message_required":"Saisissez un message.","support.validation.message_too_long":"Le message ne doit pas dépasser 10 000 caractères.","support.validation.contact_too_long":"Le contact ne doit pas dépasser 320 caractères.","support.validation.preview_missing":"Attendez l’aperçu de la pièce jointe ou désactivez-la.","support.validation.preview_expired":"L’aperçu de la pièce jointe a expiré. Actualisez l’instantané.","support.error.support_invalid_message":"Vérifiez le message et réessayez.","support.error.support_preview_expired":"L’aperçu de la pièce jointe a expiré ou n’est plus disponible. Actualisez l’instantané.","support.error.support_package_too_large":"Le paquet anonymisé dépasse la limite de 8 Mio.","support.error.support_rate_limited":"Trop de rapports ou d’aperçus ont été demandés. Réessayez plus tard.","support.error.support_unavailable":"Le service d’assistance privé est temporairement indisponible. Le brouillon reste dans cette fenêtre.","support.error.support_rejected":"Le rapport n’a pas passé la validation du service d’assistance.","support.error.unauthorized":"Vous n’êtes pas autorisé à envoyer ce rapport.","vac.routes_section":"Cartes et étages","vac.routes_current_map":"Carte actuelle","vac.routes_no_map":"aucune télémétrie","vac.routes_status":"Routage","vac.routes_state_ready":"carte assignée et calibrée","vac.routes_state_needs_calibration":"carte assignée, calibrage requis","vac.routes_state_unmapped":"carte actuelle non assignée à un étage","vac.routes_state_ambiguous":"deux cartes indiscernables — aucun étage choisi","vac.routes_state_missing_space":"l'espace de la carte a été supprimé","vac.routes_state_none":"aucune donnée de carte","vac.routes_empty":"Aucune carte n'est encore assignée à un étage.","vac.route_map_default":"sans identifiant","vac.route_active":"Active","vac.route_space":"Espace","vac.route_space_none":"non sélectionné","vac.route_status_ready":"prête","vac.route_status_needs_calibration":"calibrage requis","vac.route_status_ambiguous":"ambiguë","vac.route_status_missing_space":"espace supprimé","vac.route_missing_space_group":"Espace supprimé","vac.route_add_current":"Ajouter la carte actuelle","vac.route_delete":"Supprimer la carte","vac.route_delete_title":"Retirer la carte de son étage ?","vac.route_delete_body":"Le calibrage et les trajets enregistrés de cette carte seront supprimés. Continuer ?","vac.route_delete_confirm":"Supprimer","vac.route_space_title":"Déplacer la carte vers un autre espace ?","vac.route_space_body":"Le calibrage et les trajets enregistrés de cette carte seront supprimés. Continuer ?","vac.route_space_confirm":"Déplacer","vac.route_missing_space_hint":"Une carte pointe vers un espace supprimé : choisissez-en un autre ou supprimez la carte. D'ici là, le robot n'est pas dessiné pour cette carte.","vac.route_default_hint":"La source ne fournit pas d'identifiant de carte stable. Plusieurs étages ne peuvent pas être distingués sans une autre source ou la carte sélectionnée du robot.","vac.route_target_hint":"La station reste dans l'espace « {space} » quelle que soit la carte actuelle.","vac.route_add_source":"Ajouter une source de carte","vac.route_add_source_hint":"Pour les intégrations qui donnent à chaque carte sa propre caméra. La section « Toutes les caméras » ci-dessus élargit cette liste.","vac.route_source_no_map":"aucune carte signalée"}};function Oo(t,e,s){return i(Eo[t]?.[e]??Ao[e]??e,s)}function Ho(t,e,s,i,o){return{markerId:t,source:i,mapId:o,space:e.length?"":s}}function Bo(t,e,s){return{...t,space:s.has(e)?e:""}}function Wo(t,e=Math.random){const s=new Set(t);for(let t=0;t<64;t+=1){const t="vr_"+Math.floor(16777215*e()).toString(36).padStart(5,"0");if(!s.has(t))return t}return"vr_"+Date.now().toString(36)}function jo(t,e,s){return t.map(t=>t.id===e?{...t,calibration:s}:t)}const Go=new WeakMap,qo=(t,e)=>{const s=(t._serverCfg?.spaces||[]).find(t=>t?.id===e);return String(s?.name||s?.id||e)};function Uo(t,e,s){const i=t.host,n=l(i.hass,i._config?.language),r=(t,e)=>Oo(n,t,e),u=e.marker?.vacuum||{},_=Array.isArray(u.map_routes),g=i._vacSource(e)||"",m=o(e.id,u,e.space,g),f=(i._serverCfg?.spaces||[]).filter(t=>"string"==typeof t?.id&&!!t.id).map(t=>({id:t.id,name:String(t.name||t.id)})),b=new Set(f.map(t=>t.id)),v=h(m,[g],t=>i._vacObservedMapId(e,t)),y=c({routes:m,observed:v,spaceIds:b}),$="ready"===y.kind||"needs_calibration"===y.kind||"missing_space"===y.kind?y.route.id:"",w=g?v[g]:void 0,k=async s=>{let o=_?u.map_routes??null:null;if(!o&&(o=function(t,e,s,i){if(!s)return null;const o=t?.calibration;if(!o||"object"!=typeof o)return null;const n=new Set,r=[];for(const t of Object.keys(o)){const l=a(o[t]);if(!l)continue;const h=i(n);n.add(h),r.push({id:h,source:s,map_id:t,space:e,calibration:l})}return r.length?r:null}(u,e.space,g,t=>Wo(t))??[],!g&&Object.keys(u.calibration||{}).length))return!1;const n=s(o);return!!n&&(async s=>{const o=i._serverCfg;if(!o)return!1;const a=JSON.parse(JSON.stringify(o));a.markers=a.markers||[];let n=a.markers.find(t=>t.id===e.id);if(!n){if("device"!==e.bindingKind&&"entity"!==e.bindingKind||!e.bindingRef)return!1;n={id:e.id,binding:`${e.bindingKind}:${e.bindingRef}`,space:e.space||null,area:e.area||null,hidden:!!e.hidden},a.markers.push(n)}n.vacuum={...n.vacuum||{},map_routes:s},delete n.vacuum.calibration;const r=i._adoption.beginOptimistic(o,a);i._adoption.stageLocalConfig(a),i._regSignature="",i._maybeRebuildDevices(),i.requestUpdate(),i._saveConfigDebounced.pending()&&i._saveConfigDebounced.cancel();try{return await t._saveConfigNow(),!0}catch(t){return i._rollbackOptimistic(r),i._regSignature="",i._maybeRebuildDevices(),i.requestUpdate(),i._showToast(i._t("toast.cfg_save_failed",{err:i._errText(t)})),!1}})(n)},x=s.candidates.filter(t=>t.entityId!==g&&!m.some(e=>e.source===t.entityId)),M=async(t,e)=>{if(!e||e===t.space)return;await i._confirmDanger({key:"vacuum_route_space",kind:"warning",title:r("vac.route_space_title"),message:r("vac.route_space_body"),objectName:t.map_id||r("vac.route_map_default"),confirmLabel:r("vac.route_space_confirm"),cancelLabel:i._t("btn.cancel")})&&await k(s=>function(t,e,s,i){return t.map(t=>t.id===e?{...t,id:i,space:s,calibration:null}:t)}(s,t.id,e,Wo(new Set(m.map(t=>t.id)))))},C=new Map(f.map((t,e)=>[t.id,e])),S=(t,e)=>t.map_id.localeCompare(e.map_id)||t.source.localeCompare(e.source)||t.id.localeCompare(e.id),P=m.filter(t=>b.has(t.space)).sort((t,e)=>(C.get(t.space)??0)-(C.get(e.space)??0)||S(t,e)),D=m.filter(t=>!b.has(t.space)).sort(S),I=[...P,...D],L=!!g&&void 0!==w&&!m.some(t=>t.source===g&&t.map_id===w);let T=Go.get(t);const R=T?.source||"",z=T?.mapId||"",F=!!T&&m.some(t=>t.source===R&&t.map_id===z);T&&(T.markerId!==e.id||i._vacObservedMapId(e,T.source)!==T.mapId||F&&!T.saving)&&(Go.delete(t),T=void 0),T?.space&&!b.has(T.space)&&(T=Bo(T,"",b),Go.set(t,T));const N=s=>p` +globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="d31b0b1e184ab2863684b758f839bdb6809a33cc742c6e9bb36c5ea034e3d309";import{e as t,i as e,E as s,s as i,a as o,n as a,f as n,b as r,l,o as h,r as c,A as d,c as p,d as u,g as _,h as g,v as m,j as f,k as b,m as v,p as y,q as $,t as w,u as k,w as x,x as M,T as C,y as S,D as P,z as D,B as I,C as L,F as T,G as R,H as z,I as F,J as N,K as A,L as E,M as O,N as H,O as B,P as W,Q as j,R as G,S as q,U,V as K,W as V,X as J,Y as Z,Z as Y,_ as X,$ as Q,a0 as tt,a1 as et,a2 as st,a3 as it,a4 as ot,a5 as at,a6 as nt,a7 as rt,a8 as lt,a9 as ht,aa as ct,ab as dt,ac as pt,ad as ut,ae as _t,af as gt,ag as mt,ah as ft,ai as bt,aj as vt,ak as yt,al as $t,am as wt,an as kt,ao as xt,ap as Mt,aq as Ct,ar as St,as as Pt,at as Dt,au as It,av as Lt,aw as Tt,ax as Rt,ay as zt,az as Ft,aA as Nt,aB as At,aC as Et,aD as Ot,aE as Ht,aF as Bt,aG as Wt,aH as jt,aI as Gt,aJ as qt,aK as Ut,aL as Kt,aM as Vt,aN as Jt,aO as Zt,aP as Yt,aQ as Xt,aR as Qt,aS as te,aT as ee,aU as se,aV as ie,aW as oe,aX as ae,aY as ne,aZ as re,a_ as le,a$ as he,b0 as ce,b1 as de,b2 as pe,b3 as ue,b4 as _e,b5 as ge,b6 as me,b7 as fe,b8 as be,b9 as ve,ba as ye,bb as $e,bc as we,bd as ke,be as xe,bf as Me,bg as Ce,bh as Se,bi as Pe,bj as De,bk as Ie,bl as Le,bm as Te,bn as Re,bo as ze,bp as Fe,bq as Ne,br as Ae,bs as Ee,bt as Oe,bu as He,bv as Be,bw as We,bx as je,by as Ge,bz as qe,bA as Ue,bB as Ke,bC as Ve,bD as Je,bE as Ze,bF as Ye,bG as Xe,bH as Qe,bI as ts,bJ as es,bK as ss,bL as is,bM as os,bN as as,bO as ns,bP as rs,bQ as ls,bR as hs,bS as cs,bT as ds,bU as ps,bV as us,bW as _s,bX as gs,bY as ms,bZ as fs,b_ as bs,b$ as vs,c0 as ys,c1 as $s,c2 as ws,c3 as ks,c4 as xs,c5 as Ms,c6 as Cs,c7 as Ss,c8 as Ps,c9 as Ds,ca as Is,cb as Ls,cc as Ts,cd as Rs,ce as zs,cf as Fs,cg as Ns,ch as As,ci as Es,cj as Os,ck as Hs,cl as Bs,cm as Ws,cn as js,co as Gs,cp as qs,cq as Us,cr as Ks,cs as Vs,ct as Js,cu as Zs,cv as Ys,cw as Xs,cx as Qs,cy as ti,cz as ei,cA as si,cB as ii,cC as oi,cD as ai,cE as ni,cF as ri,cG as li,cH as hi,cI as ci,cJ as di,cK as pi,cL as ui,cM as _i,cN as gi,cO as mi,cP as fi,cQ as bi,cR as vi,cS as yi,cT as $i,cU as wi,cV as ki,cW as xi,cX as Mi,cY as Ci,cZ as Si,c_ as Pi,c$ as Di,d0 as Ii,d1 as Li,d2 as Ti,d3 as Ri,d4 as zi,d5 as Fi,d6 as Ni,d7 as Ai,d8 as Ei,d9 as Oi,da as Hi,db as Bi,dc as Wi,dd as ji,de as Gi,df as qi,dg as Ui,dh as Ki,di as Vi,dj as Ji,dk as Zi,dl as Yi,dm as Xi,dn as Qi,dp as to,dq as eo,dr as so,ds as io,dt as oo,du as ao,dv as no,dw as ro,dx as lo,dy as ho,dz as co,dA as po,dB as uo,dC as _o,dD as go,dE as mo,dF as fo}from"./houseplan-card-W9mG3gab.js";import{c as bo,f as vo,C as yo}from"./form-kit.styles-BSWYQ2Fp.js";import{F as $o,f as wo,p as ko,c as xo,e as Mo,r as Co,a as So,s as Po}from"./backdrop-pick-ToIYfsVt.js";import{t as Do,h as Io,m as Lo,T as To}from"./zigbee-topology-3KJks91U.js";import{GENERATED_FURNITURE_ART as Ro,FURNITURE_ART_FINGERPRINT as zo}from"./furniture-plan-art.generated-B9qZ5DM-.js";const Fo={},No=t(class extends e{constructor(){super(...arguments),this.ot=Fo}render(t,e){return e()}update(t,[e,i]){if(Array.isArray(e)){if(Array.isArray(this.ot)&&this.ot.length===e.length&&e.every((t,e)=>t===this.ot[e]))return s}else if(this.ot===e)return s;return this.ot=Array.isArray(e)?Array.from(e):e,this.render(e,i)}});var Ao={"gs.show_room_tooltip":"Show the room information window on hover","support.about_group":"About the card","support.guide_group":"Documentation","support.guide":"User guide","support.form_group":"Send a report or suggestion","support.contact":"Contact details (email/tg/WhatsApp), optional.","support.message":"Message","support.attach":"Attach anonymized information from your plan","support.attach_hint":"Includes only allowed plan geometry, settings and bounded runtime facts. Excludes names, Home Assistant IDs, live states, URLs, files, and your message/contact.","support.geometry_warning":"The package contains no names or Home Assistant IDs, but it does contain the exact geometry and dimensions of your home.","support.close_busy_title":"Stop the current operation?","support.close_busy_body":"House Plan is preparing or sending the report. Closing now stops waiting for the result.","support.building":"Preparing anonymized data…","support.preview_summary":"Package v{version} · {spaces} spaces · {size} KiB","support.prepared":"Snapshot prepared {n} min ago","support.show_data":"Show data","support.download":"Download JSON","support.refresh":"Refresh snapshot","support.privacy":"When you send, your message, optional contact and, if selected, exact geometry leave your Home Assistant through the House Plan project relay and are visible to maintainers. The project node keeps the report for up to 30 days. Network infrastructure sees your HA server address, but House Plan does not retain it raw; rate-limit and idempotency metadata is kept for up to 24 hours.","support.error_title":"The report was not sent","support.manual_recovery":"You can keep the message and attachment and continue manually:","support.copy_message":"Copy message","support.success":"Report sent: {id}. Save this number when contacting support.","support.copy_id":"Copy ID","support.sending":"Sending…","support.retry":"Retry","support.send":"Send","support.update_required":"Update the House Plan card and integration to compatible versions to send reports.","support.message_copied":"Message copied","support.id_copied":"Report ID copied","support.copy_failed":"Could not access the clipboard. Select and copy the text manually.","support.validation.message_required":"Enter a message.","support.validation.message_too_long":"The message must contain no more than 10,000 characters.","support.validation.contact_too_long":"Contact details must contain no more than 320 characters.","support.validation.preview_missing":"Wait for the attachment preview or turn the attachment off.","support.validation.preview_expired":"The attachment preview expired. Refresh the snapshot.","support.error.support_invalid_message":"Check the message and try again.","support.error.support_preview_expired":"The attachment preview expired or is no longer available. Refresh the snapshot.","support.error.support_package_too_large":"The anonymized package exceeds the 8 MiB limit.","support.error.support_rate_limited":"Too many reports or previews were requested. Try again later.","support.error.support_unavailable":"The private support service is temporarily unavailable. Your draft remains here.","support.error.support_rejected":"The report did not pass the support service validation.","support.error.unauthorized":"You do not have permission to send this report.","vac.routes_section":"Maps and floors","vac.routes_current_map":"Current map","vac.routes_no_map":"no telemetry","vac.routes_status":"Routing","vac.routes_state_ready":"map assigned and calibrated","vac.routes_state_needs_calibration":"map assigned, calibration needed","vac.routes_state_unmapped":"current map is not assigned to a floor","vac.routes_state_ambiguous":"two maps are indistinguishable — no floor is chosen","vac.routes_state_missing_space":"the map's space was deleted","vac.routes_state_none":"no map data","vac.routes_empty":"No map is assigned to a floor yet.","vac.route_map_default":"no map id","vac.route_active":"Active","vac.route_space":"Space","vac.route_space_none":"not selected","vac.route_status_ready":"ready","vac.route_status_needs_calibration":"needs calibration","vac.route_status_ambiguous":"ambiguous","vac.route_status_missing_space":"space deleted","vac.route_missing_space_group":"Deleted space","vac.route_add_current":"Add current map","vac.route_delete":"Remove map","vac.route_delete_title":"Remove the map from its floor?","vac.route_delete_body":"Calibration and saved paths for this map will be removed. Continue?","vac.route_delete_confirm":"Remove","vac.route_space_title":"Move the map to another space?","vac.route_space_body":"Calibration and saved paths for this map will be removed. Continue?","vac.route_space_confirm":"Move","vac.route_missing_space_hint":"One of the maps points at a deleted space: pick a new one or remove the map. Until then the robot is not drawn for that map.","vac.route_default_hint":"The source reports no stable map id. Several floors cannot be told apart without another source or the robot's own selected map.","vac.route_target_hint":"The dock stays in the “{space}” space regardless of the current map.","vac.route_add_source":"Add a map source","vac.route_add_source_hint":"For integrations that give each map its own camera. The “All cameras” section above widens this list.","vac.route_source_no_map":"no map reported"};const Eo={en:Ao,ru:{"gs.show_room_tooltip":"Показывать окно с информацией при наведении на комнату","support.about_group":"О карточке","support.guide_group":"Документация","support.guide":"Руководство пользователя","support.form_group":"Отправить репорт или предложение","support.contact":"Контакт для связи (email/tg/WhatsApp), необязательно.","support.message":"Сообщение","support.attach":"Прикрепить обезличенную информацию из вашего плана","support.attach_hint":"В пакет входят только разрешённые геометрия, настройки и ограниченные сведения о среде. Не входят имена, HA id, текущие состояния, URL, файлы, сообщение и контакт.","support.geometry_warning":"Пакет не содержит имён и HA id, но содержит точную геометрию и размеры дома.","support.close_busy_title":"Прервать текущую операцию?","support.close_busy_body":"House Plan подготавливает или отправляет репорт. При закрытии ожидание результата прекратится.","support.building":"Подготавливаем обезличенные данные…","support.preview_summary":"Пакет v{version} · пространств: {spaces} · {size} КиБ","support.prepared":"Снимок подготовлен {n} мин назад","support.show_data":"Показать данные","support.download":"Скачать JSON","support.refresh":"Обновить снимок","support.privacy":"При отправке сообщение, необязательный контакт и, если выбран пакет, точная геометрия покидают ваш Home Assistant через relay проекта House Plan и доступны мейнтейнерам. Узел проекта хранит репорт до 30 дней. Сетевая инфраструктура видит адрес сервера HA, но House Plan не сохраняет его в исходном виде; метаданные лимитов и идемпотентности хранятся до 24 часов.","support.error_title":"Репорт не отправлен","support.manual_recovery":"Сообщение и вложение можно сохранить и продолжить вручную:","support.copy_message":"Копировать сообщение","support.success":"Репорт отправлен: {id}. Сохраните номер для связи с поддержкой.","support.copy_id":"Копировать ID","support.sending":"Отправляем…","support.retry":"Повторить","support.send":"Отправить","support.update_required":"Обновите карточку и интеграцию House Plan до совместимых версий, чтобы отправлять репорты.","support.message_copied":"Сообщение скопировано","support.id_copied":"ID репорта скопирован","support.copy_failed":"Не удалось получить доступ к буферу обмена. Выделите и скопируйте текст вручную.","support.validation.message_required":"Введите сообщение.","support.validation.message_too_long":"Сообщение должно содержать не более 10 000 символов.","support.validation.contact_too_long":"Контакт должен содержать не более 320 символов.","support.validation.preview_missing":"Дождитесь предпросмотра вложения или отключите его.","support.validation.preview_expired":"Предпросмотр вложения истёк. Обновите снимок.","support.error.support_invalid_message":"Проверьте сообщение и повторите попытку.","support.error.support_preview_expired":"Предпросмотр вложения истёк или больше недоступен. Обновите снимок.","support.error.support_package_too_large":"Обезличенный пакет превышает лимит 8 МиБ.","support.error.support_rate_limited":"Запрошено слишком много репортов или предпросмотров. Повторите позже.","support.error.support_unavailable":"Закрытая служба поддержки временно недоступна. Черновик сохранён в этом окне.","support.error.support_rejected":"Репорт не прошёл проверку службы поддержки.","support.error.unauthorized":"У вас нет прав на отправку этого репорта.","vac.routes_section":"Карты и этажи","vac.routes_current_map":"Текущая карта","vac.routes_no_map":"источник молчит","vac.routes_status":"Маршрутизация","vac.routes_state_ready":"карта сопоставлена и откалибрована","vac.routes_state_needs_calibration":"карта сопоставлена, нужна калибровка","vac.routes_state_unmapped":"текущая карта не сопоставлена этажу","vac.routes_state_ambiguous":"две карты неразличимы — этаж не выбирается","vac.routes_state_missing_space":"пространство карты удалено","vac.routes_state_none":"нет данных о карте","vac.routes_empty":"Ни одна карта ещё не сопоставлена этажу.","vac.route_map_default":"без идентификатора","vac.route_active":"Текущая","vac.route_space":"Пространство","vac.route_space_none":"не выбрано","vac.route_status_ready":"готова","vac.route_status_needs_calibration":"нужна калибровка","vac.route_status_ambiguous":"неоднозначна","vac.route_status_missing_space":"пространство удалено","vac.route_missing_space_group":"Пространство удалено","vac.route_add_current":"Добавить текущую карту","vac.route_delete":"Удалить карту","vac.route_delete_title":"Удалить карту с этажа?","vac.route_delete_body":"Калибровка и сохранённые пути этой карты будут удалены. Продолжить?","vac.route_delete_confirm":"Удалить","vac.route_space_title":"Перенести карту в другое пространство?","vac.route_space_body":"Калибровка и сохранённые пути этой карты будут удалены. Продолжить?","vac.route_space_confirm":"Перенести","vac.route_missing_space_hint":"Одна из карт ссылается на удалённое пространство: выберите новое или удалите карту. Пока ссылка не исправлена, робот на этой карте не рисуется.","vac.route_default_hint":"Источник не сообщает стабильный идентификатор карты. Несколько этажей нельзя различить без другого источника или собственной карты робота.","vac.route_target_hint":"Док остаётся в пространстве «{space}» независимо от текущей карты.","vac.route_add_source":"Добавить источник карты","vac.route_add_source_hint":"Для интеграций, где у каждой карты своя камера. Список расширяется разделом «Все камеры» выше.","vac.route_source_no_map":"карта не читается"},de:{"gs.show_room_tooltip":"Rauminformationen beim Darüberfahren anzeigen","support.about_group":"Über die Karte","support.guide_group":"Dokumentation","support.guide":"Benutzerhandbuch","support.form_group":"Bericht oder Vorschlag senden","support.contact":"Kontakt (E-Mail/tg/WhatsApp), optional.","support.message":"Nachricht","support.attach":"Anonymisierte Informationen aus dem Plan anhängen","support.attach_hint":"Enthält nur erlaubte Plangeometrie, Einstellungen und begrenzte Laufzeitdaten. Namen, Home-Assistant-IDs, Live-Zustände, URLs, Dateien, Nachricht und Kontakt werden ausgeschlossen.","support.geometry_warning":"Das Paket enthält keine Namen oder Home-Assistant-IDs, aber die exakte Geometrie und die Maße Ihres Hauses.","support.close_busy_title":"Aktuellen Vorgang abbrechen?","support.close_busy_body":"House Plan bereitet den Bericht vor oder sendet ihn. Beim Schließen wird nicht weiter auf das Ergebnis gewartet.","support.building":"Anonymisierte Daten werden vorbereitet…","support.preview_summary":"Paket v{version} · {spaces} Bereiche · {size} KiB","support.prepared":"Schnappschuss vor {n} Min. erstellt","support.show_data":"Daten anzeigen","support.download":"JSON herunterladen","support.refresh":"Schnappschuss aktualisieren","support.privacy":"Beim Senden verlassen Ihre Nachricht, der optionale Kontakt und, falls ausgewählt, die exakte Geometrie Ihren Home Assistant über das House-Plan-Projektrelay und sind für die Maintainer sichtbar. Der Projektserver speichert den Bericht bis zu 30 Tage. Die Netzwerkinfrastruktur sieht die Adresse Ihres HA-Servers, House Plan speichert sie jedoch nicht im Rohformat; Limit- und Idempotenzdaten bleiben bis zu 24 Stunden erhalten.","support.error_title":"Der Bericht wurde nicht gesendet","support.manual_recovery":"Nachricht und Anhang können gespeichert und manuell weitergegeben werden:","support.copy_message":"Nachricht kopieren","support.success":"Bericht gesendet: {id}. Bewahren Sie diese Nummer für den Support auf.","support.copy_id":"ID kopieren","support.sending":"Wird gesendet…","support.retry":"Erneut versuchen","support.send":"Senden","support.update_required":"Aktualisieren Sie House-Plan-Karte und Integration auf kompatible Versionen, um Berichte zu senden.","support.message_copied":"Nachricht kopiert","support.id_copied":"Berichts-ID kopiert","support.copy_failed":"Kein Zugriff auf die Zwischenablage. Markieren und kopieren Sie den Text manuell.","support.validation.message_required":"Geben Sie eine Nachricht ein.","support.validation.message_too_long":"Die Nachricht darf höchstens 10.000 Zeichen enthalten.","support.validation.contact_too_long":"Der Kontakt darf höchstens 320 Zeichen enthalten.","support.validation.preview_missing":"Warten Sie auf die Vorschau oder deaktivieren Sie den Anhang.","support.validation.preview_expired":"Die Anhangsvorschau ist abgelaufen. Aktualisieren Sie den Schnappschuss.","support.error.support_invalid_message":"Prüfen Sie die Nachricht und versuchen Sie es erneut.","support.error.support_preview_expired":"Die Anhangsvorschau ist abgelaufen oder nicht mehr verfügbar. Aktualisieren Sie den Schnappschuss.","support.error.support_package_too_large":"Das anonymisierte Paket überschreitet das Limit von 8 MiB.","support.error.support_rate_limited":"Zu viele Berichte oder Vorschauen wurden angefordert. Versuchen Sie es später erneut.","support.error.support_unavailable":"Der private Supportdienst ist vorübergehend nicht verfügbar. Der Entwurf bleibt in diesem Fenster erhalten.","support.error.support_rejected":"Der Bericht hat die Prüfung des Supportdienstes nicht bestanden.","support.error.unauthorized":"Sie dürfen diesen Bericht nicht senden.","vac.routes_section":"Karten und Etagen","vac.routes_current_map":"Aktuelle Karte","vac.routes_no_map":"keine Telemetrie","vac.routes_status":"Zuordnung","vac.routes_state_ready":"Karte zugeordnet und kalibriert","vac.routes_state_needs_calibration":"Karte zugeordnet, Kalibrierung nötig","vac.routes_state_unmapped":"aktuelle Karte keiner Etage zugeordnet","vac.routes_state_ambiguous":"zwei Karten nicht unterscheidbar — keine Etage gewählt","vac.routes_state_missing_space":"der Raum der Karte wurde gelöscht","vac.routes_state_none":"keine Kartendaten","vac.routes_empty":"Noch keine Karte einer Etage zugeordnet.","vac.route_map_default":"ohne Karten-ID","vac.route_active":"Aktiv","vac.route_space":"Raum","vac.route_space_none":"nicht gewählt","vac.route_status_ready":"bereit","vac.route_status_needs_calibration":"Kalibrierung nötig","vac.route_status_ambiguous":"mehrdeutig","vac.route_status_missing_space":"Raum gelöscht","vac.route_missing_space_group":"Gelöschter Bereich","vac.route_add_current":"Aktuelle Karte hinzufügen","vac.route_delete":"Karte entfernen","vac.route_delete_title":"Karte von der Etage entfernen?","vac.route_delete_body":"Kalibrierung und gespeicherte Pfade dieser Karte werden entfernt. Fortfahren?","vac.route_delete_confirm":"Entfernen","vac.route_space_title":"Karte in einen anderen Raum verschieben?","vac.route_space_body":"Kalibrierung und gespeicherte Pfade dieser Karte werden entfernt. Fortfahren?","vac.route_space_confirm":"Verschieben","vac.route_missing_space_hint":"Eine Karte verweist auf einen gelöschten Raum: neuen wählen oder Karte entfernen. Bis dahin wird der Roboter für diese Karte nicht gezeichnet.","vac.route_default_hint":"Die Quelle meldet keine stabile Karten-ID. Mehrere Etagen lassen sich ohne andere Quelle oder die vom Roboter gewählte Karte nicht unterscheiden.","vac.route_target_hint":"Die Station bleibt unabhängig von der aktuellen Karte im Raum „{space}“.","vac.route_add_source":"Kartenquelle hinzufügen","vac.route_add_source_hint":"Für Integrationen, die jeder Karte eine eigene Kamera geben. Der Abschnitt „Alle Kameras“ oben erweitert diese Liste.","vac.route_source_no_map":"keine Karte gemeldet"},fr:{"gs.show_room_tooltip":"Afficher les informations de la pièce au survol","support.about_group":"À propos de la carte","support.guide_group":"Documentation d’aide","support.guide":"Guide utilisateur","support.form_group":"Envoyer un rapport ou une suggestion","support.contact":"Contact (e-mail/tg/WhatsApp), facultatif.","support.message":"Votre message","support.attach":"Joindre des informations anonymisées de votre plan","support.attach_hint":"Inclut uniquement la géométrie, les réglages autorisés et des données d’exécution limitées. Exclut les noms, identifiants Home Assistant, états en direct, URL, fichiers, message et contact.","support.geometry_warning":"Le paquet ne contient ni noms ni identifiants Home Assistant, mais il contient la géométrie et les dimensions exactes de votre logement.","support.close_busy_title":"Interrompre l’opération en cours ?","support.close_busy_body":"House Plan prépare ou envoie le rapport. Fermer maintenant arrête l’attente du résultat.","support.building":"Préparation des données anonymisées…","support.preview_summary":"Paquet v{version} · {spaces} espaces · {size} Kio","support.prepared":"Instantané préparé il y a {n} min","support.show_data":"Afficher les données","support.download":"Télécharger le JSON","support.refresh":"Actualiser l’instantané","support.privacy":"Lors de l’envoi, votre message, le contact facultatif et, si elle est sélectionnée, la géométrie exacte quittent votre Home Assistant via le relais du projet House Plan et sont visibles par les mainteneurs. Le serveur du projet conserve le rapport jusqu’à 30 jours. L’infrastructure réseau voit l’adresse de votre serveur HA, mais House Plan ne la conserve pas en clair ; les métadonnées de limitation et d’idempotence sont gardées jusqu’à 24 heures.","support.error_title":"Le rapport n’a pas été envoyé","support.manual_recovery":"Vous pouvez conserver le message et la pièce jointe puis continuer manuellement :","support.copy_message":"Copier le message","support.success":"Rapport envoyé : {id}. Conservez ce numéro pour contacter l’assistance.","support.copy_id":"Copier l’ID","support.sending":"Envoi…","support.retry":"Réessayer","support.send":"Envoyer","support.update_required":"Mettez à jour la carte et l’intégration House Plan vers des versions compatibles pour envoyer des rapports.","support.message_copied":"Message copié","support.id_copied":"ID du rapport copié","support.copy_failed":"Impossible d’accéder au presse-papiers. Sélectionnez et copiez le texte manuellement.","support.validation.message_required":"Saisissez un message.","support.validation.message_too_long":"Le message ne doit pas dépasser 10 000 caractères.","support.validation.contact_too_long":"Le contact ne doit pas dépasser 320 caractères.","support.validation.preview_missing":"Attendez l’aperçu de la pièce jointe ou désactivez-la.","support.validation.preview_expired":"L’aperçu de la pièce jointe a expiré. Actualisez l’instantané.","support.error.support_invalid_message":"Vérifiez le message et réessayez.","support.error.support_preview_expired":"L’aperçu de la pièce jointe a expiré ou n’est plus disponible. Actualisez l’instantané.","support.error.support_package_too_large":"Le paquet anonymisé dépasse la limite de 8 Mio.","support.error.support_rate_limited":"Trop de rapports ou d’aperçus ont été demandés. Réessayez plus tard.","support.error.support_unavailable":"Le service d’assistance privé est temporairement indisponible. Le brouillon reste dans cette fenêtre.","support.error.support_rejected":"Le rapport n’a pas passé la validation du service d’assistance.","support.error.unauthorized":"Vous n’êtes pas autorisé à envoyer ce rapport.","vac.routes_section":"Cartes et étages","vac.routes_current_map":"Carte actuelle","vac.routes_no_map":"aucune télémétrie","vac.routes_status":"Routage","vac.routes_state_ready":"carte assignée et calibrée","vac.routes_state_needs_calibration":"carte assignée, calibrage requis","vac.routes_state_unmapped":"carte actuelle non assignée à un étage","vac.routes_state_ambiguous":"deux cartes indiscernables — aucun étage choisi","vac.routes_state_missing_space":"l'espace de la carte a été supprimé","vac.routes_state_none":"aucune donnée de carte","vac.routes_empty":"Aucune carte n'est encore assignée à un étage.","vac.route_map_default":"sans identifiant","vac.route_active":"Active","vac.route_space":"Espace","vac.route_space_none":"non sélectionné","vac.route_status_ready":"prête","vac.route_status_needs_calibration":"calibrage requis","vac.route_status_ambiguous":"ambiguë","vac.route_status_missing_space":"espace supprimé","vac.route_missing_space_group":"Espace supprimé","vac.route_add_current":"Ajouter la carte actuelle","vac.route_delete":"Supprimer la carte","vac.route_delete_title":"Retirer la carte de son étage ?","vac.route_delete_body":"Le calibrage et les trajets enregistrés de cette carte seront supprimés. Continuer ?","vac.route_delete_confirm":"Supprimer","vac.route_space_title":"Déplacer la carte vers un autre espace ?","vac.route_space_body":"Le calibrage et les trajets enregistrés de cette carte seront supprimés. Continuer ?","vac.route_space_confirm":"Déplacer","vac.route_missing_space_hint":"Une carte pointe vers un espace supprimé : choisissez-en un autre ou supprimez la carte. D'ici là, le robot n'est pas dessiné pour cette carte.","vac.route_default_hint":"La source ne fournit pas d'identifiant de carte stable. Plusieurs étages ne peuvent pas être distingués sans une autre source ou la carte sélectionnée du robot.","vac.route_target_hint":"La station reste dans l'espace « {space} » quelle que soit la carte actuelle.","vac.route_add_source":"Ajouter une source de carte","vac.route_add_source_hint":"Pour les intégrations qui donnent à chaque carte sa propre caméra. La section « Toutes les caméras » ci-dessus élargit cette liste.","vac.route_source_no_map":"aucune carte signalée"}};function Oo(t,e,s){return i(Eo[t]?.[e]??Ao[e]??e,s)}function Ho(t,e,s,i,o){return{markerId:t,source:i,mapId:o,space:e.length?"":s}}function Bo(t,e,s){return{...t,space:s.has(e)?e:""}}function Wo(t,e=Math.random){const s=new Set(t);for(let t=0;t<64;t+=1){const t="vr_"+Math.floor(16777215*e()).toString(36).padStart(5,"0");if(!s.has(t))return t}return"vr_"+Date.now().toString(36)}function jo(t,e,s){return t.map(t=>t.id===e?{...t,calibration:s}:t)}const Go=new WeakMap,qo=(t,e)=>{const s=(t._serverCfg?.spaces||[]).find(t=>t?.id===e);return String(s?.name||s?.id||e)};function Uo(t,e,s){const i=t.host,n=l(i.hass,i._config?.language),r=(t,e)=>Oo(n,t,e),u=e.marker?.vacuum||{},_=Array.isArray(u.map_routes),g=i._vacSource(e)||"",m=o(e.id,u,e.space,g),f=(i._serverCfg?.spaces||[]).filter(t=>"string"==typeof t?.id&&!!t.id).map(t=>({id:t.id,name:String(t.name||t.id)})),b=new Set(f.map(t=>t.id)),v=h(m,[g],t=>i._vacObservedMapId(e,t)),y=c({routes:m,observed:v,spaceIds:b}),$="ready"===y.kind||"needs_calibration"===y.kind||"missing_space"===y.kind?y.route.id:"",w=g?v[g]:void 0,k=async s=>{let o=_?u.map_routes??null:null;if(!o&&(o=function(t,e,s,i){if(!s)return null;const o=t?.calibration;if(!o||"object"!=typeof o)return null;const n=new Set,r=[];for(const t of Object.keys(o)){const l=a(o[t]);if(!l)continue;const h=i(n);n.add(h),r.push({id:h,source:s,map_id:t,space:e,calibration:l})}return r.length?r:null}(u,e.space,g,t=>Wo(t))??[],!g&&Object.keys(u.calibration||{}).length))return!1;const n=s(o);return!!n&&(async s=>{const o=i._serverCfg;if(!o)return!1;const a=JSON.parse(JSON.stringify(o));a.markers=a.markers||[];let n=a.markers.find(t=>t.id===e.id);if(!n){if("device"!==e.bindingKind&&"entity"!==e.bindingKind||!e.bindingRef)return!1;n={id:e.id,binding:`${e.bindingKind}:${e.bindingRef}`,space:e.space||null,area:e.area||null,hidden:!!e.hidden},a.markers.push(n)}n.vacuum={...n.vacuum||{},map_routes:s},delete n.vacuum.calibration;const r=i._adoption.beginOptimistic(o,a);i._adoption.stageLocalConfig(a),i._regSignature="",i._maybeRebuildDevices(),i.requestUpdate(),i._saveConfigDebounced.pending()&&i._saveConfigDebounced.cancel();try{return await t._saveConfigNow(),!0}catch(t){return i._rollbackOptimistic(r),i._regSignature="",i._maybeRebuildDevices(),i.requestUpdate(),i._showToast(i._t("toast.cfg_save_failed",{err:i._errText(t)})),!1}})(n)},x=s.candidates.filter(t=>t.entityId!==g&&!m.some(e=>e.source===t.entityId)),M=async(t,e)=>{if(!e||e===t.space)return;await i._confirmDanger({key:"vacuum_route_space",kind:"warning",title:r("vac.route_space_title"),message:r("vac.route_space_body"),objectName:t.map_id||r("vac.route_map_default"),confirmLabel:r("vac.route_space_confirm"),cancelLabel:i._t("btn.cancel")})&&await k(s=>function(t,e,s,i){return t.map(t=>t.id===e?{...t,id:i,space:s,calibration:null}:t)}(s,t.id,e,Wo(new Set(m.map(t=>t.id)))))},C=new Map(f.map((t,e)=>[t.id,e])),S=(t,e)=>t.map_id.localeCompare(e.map_id)||t.source.localeCompare(e.source)||t.id.localeCompare(e.id),P=m.filter(t=>b.has(t.space)).sort((t,e)=>(C.get(t.space)??0)-(C.get(e.space)??0)||S(t,e)),D=m.filter(t=>!b.has(t.space)).sort(S),I=[...P,...D],L=!!g&&void 0!==w&&!m.some(t=>t.source===g&&t.map_id===w);let T=Go.get(t);const R=T?.source||"",z=T?.mapId||"",F=!!T&&m.some(t=>t.source===R&&t.map_id===z);T&&(T.markerId!==e.id||i._vacObservedMapId(e,T.source)!==T.mapId||F&&!T.saving)&&(Go.delete(t),T=void 0),T?.space&&!b.has(T.space)&&(T=Bo(T,"",b),Go.set(t,T));const N=s=>p`
  • ${s.map_id||r("vac.route_map_default")} @@ -81,26 +81,26 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db ${m.some(t=>"default"===t.map_id)?p`
    ${r("vac.route_default_hint")}
    `:d} ${I.length?p`
    ${r("vac.route_target_hint",{space:qo(i,e.space)})}
    `:d} -
    `}const Ko=bo+vo(yo,{withSwitch:!1}),Vo=new WeakSet;let Jo=null;function Zo({title:t,help:e,body:s}){return p`
    +
  • `}const Ko=bo+vo(yo,{withSwitch:!1}),Vo=new WeakSet;let Jo=null;function Zo(t){const e=t.renderRoot;if(!e||Vo.has(e))return;const s=e.ownerDocument??globalThis.document,i=s?.defaultView?.CSSStyleSheet;if(i&&"adoptedStyleSheets"in e)return Jo||(Jo=new i,Jo.replaceSync(Ko)),e.adoptedStyleSheets=[...e.adoptedStyleSheets,Jo],void Vo.add(e);if(e.querySelector("style[data-hp-form-kit]"))return void Vo.add(e);const o=s.createElement("style");o.dataset.hpFormKit="true",o.textContent=Ko,e.appendChild(o),Vo.add(e)}function Yo({title:t,help:e,body:s}){return p`
    ${t?p`

    ${t}

    ${e??d}
    `:d} ${s} -
    `}function Yo({label:t,control:e,action:s}){return p`
    + `}function Xo({label:t,control:e,action:s}){return p`
    ${t} ${e}${s??d} -
    `}function Xo({name:t,value:e,options:s,onChange:i,ariaLabel:o}){return p`
    +
    `}function Qo({name:t,value:e,options:s,onChange:i,ariaLabel:o}){return p`
    ${s.map(s=>p``)} -
    `}function Qo({label:t,picker:e,action:s}){return p`
    +
    `}function ta({label:t,picker:e,action:s}){return p`
    ${t} ${e}${s??d} -
    `}const ta=new Set(["ld2450","hlkld2450","hilinkld2450"]),ea=()=>globalThis.crypto?.randomUUID?.()||`radar_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`,sa=(t,e,s)=>{const i=!!t?.original;return{radar:i?t:null,radarEligible:i,radarTouched:i?e:e||!!t,radarRemove:i?s:s||!!t}},ia=(t,e="")=>"number"==typeof t&&Number.isFinite(t)?String(t):e,oa=t=>Array.from(new Set([...t.allEntities||t.entities||[],..."entity"===t.bindingKind&&t.bindingRef?[t.bindingRef]:[]])).filter(t=>/^[a-z0-9_]+\.[a-z0-9_]+$/.test(t)),aa=(t,e,s)=>{const i=t.split(".",2)[1]||"";return new RegExp(`(?:^|_)target_?${s}_${e}(?:_|$)`).test(i)||new RegExp(`(?:^|_)target_${e}_${s}(?:_|$)`).test(i)};function na(t,e){if(t.marker?.radar&&"object"==typeof t.marker.radar)return u(t.marker.radar)?{eligible:!0,profile:t.marker.radar.profile,reason:"saved"}:{eligible:!0,profile:"presence_v1",reason:"saved_unsupported"};const s="entity"===t.bindingKind?e?.entities?.[t.bindingRef||""]:null,i="device"===t.bindingKind?t.bindingRef:s?.device_id,o=i?e?.devices?.[i]:null,a=oa(t);return ta.has((n=o?.model||t.model,String(n||"").toLowerCase().replace(/[^a-z0-9]/g,"")))&&a.some(t=>aa(t,"x",1))&&a.some(t=>aa(t,"y",1))?{eligible:!0,profile:"esphome_ld2450_v1",reason:"ld2450"}:{eligible:!1,profile:"presence_v1",reason:"none"};var n}function ra(t,e){return t.find(t=>e.some(e=>e.test(t)))||""}function la(t,e,s,i,o=!1){const a=na(t,i),n=u(t.marker?.radar)?t.marker.radar:null;if(!n&&!a.eligible&&!o)return null;const r=n?.profile||a.profile,l=o&&!a.eligible||"ld2450"!==a.reason?{xEntities:["","",""],yEntities:["","",""],distanceEntity:"",angleEntity:"",occupancyEntity:"",countEntity:"",zoneEntity:""}:function(t,e,s){const i=oa(t).filter(t=>!!s?.states?.[t]),o=[],a=[];for(let t=1;t<=3;t++)o.push(i.find(e=>aa(e,"x",t))||""),a.push(i.find(e=>aa(e,"y",t))||"");const n=i.filter(t=>t.startsWith("binary_sensor.")),r=i.filter(t=>t.startsWith("sensor.")),l=ra(n,[/(?:occupancy|presence|target)(?:_|$)/]);return{xEntities:o,yEntities:a,distanceEntity:ra(r,[/(?:target_)?distance(?:_|$)/,/distance/]),angleEntity:ra(r,[/(?:target_)?angle(?:_|$)/,/angle/]),occupancyEntity:l,countEntity:ra(r,[/(?:target|people|presence)_count(?:_|$)/,/target_count/]),zoneEntity:"zones_v1"===e?ra(n,[/(?:zone|region).*(?:occupancy|presence)/,/zone/]):""}}(t,r,i),h=n?.sources||{},c=h.slots||[],d=c.filter(t=>"x_entity"in t),p=c.filter(t=>"distance_entity"in t),_=h.ranges||[],g=h.zones?.[0],m="esphome_ld2450_v1"===r?3:"cartesian_v1"===r?Math.max(1,d.length):"polar_v1"===r?Math.max(1,p.length):1,f=n?.room_id||t.marker?.room_id||e.rooms.find(e=>e.area&&e.area===t.area)?.id||"";return{original:n,enabled:!0===n?.enabled,showLive:!1!==n?.show_live,profile:r,roomId:f,installationId:n?.mount?.installation_id||ea(),mountX:ia(null==n?.mount?.x?void 0:1e3*n.mount.x,ia(s[0],"0")),mountY:ia(null==n?.mount?.y?void 0:1e3*n.mount.y,ia(s[1],"0")),heading:ia(n?.mount?.heading_deg,"0"),rangeCm:ia(n?.mount?.range_cm,"esphome_ld2450_v1"===r?"600":""),fovDeg:ia(n?.mount?.fov_deg,"esphome_ld2450_v1"===r?"120":""),mirror:!0===n?.calibration?.mirror,unit:d[0]?.unit||p[0]?.unit||_[0]?.unit||("esphome_ld2450_v1"===r?"mm":"cm"),xEntities:Array.from({length:m},(t,e)=>d[e]?.x_entity||l.xEntities[e]||""),yEntities:Array.from({length:m},(t,e)=>d[e]?.y_entity||l.yEntities[e]||""),distanceEntities:Array.from({length:m},(t,e)=>p[e]?.distance_entity||(0===e?l.distanceEntity:"")),angleEntities:Array.from({length:m},(t,e)=>p[e]?.angle_entity||(0===e?l.angleEntity:"")),rangeEntities:_.length?_.map(t=>t.entity_id):[l.distanceEntity],slotPresenceEntities:Array.from({length:m},(t,e)=>(d[e]||p[e])?.presence_entity||""),rangePresenceEntities:(_.length?_:[{}]).map(t=>"presence_entity"in t&&t.presence_entity||""),swapXY:Array.from({length:m},(t,e)=>!0===d[e]?.swap_xy),xSigns:Array.from({length:m},(t,e)=>-1===d[e]?.x_sign?-1:1),ySigns:Array.from({length:m},(t,e)=>-1===d[e]?.y_sign?-1:1),angleUnit:p[0]?.angle_unit||"degrees",angleZero:p[0]?.angle_zero||"forward",angleClockwise:!1!==p[0]?.angle_clockwise,occupancyEntity:h.occupancy_entity||l.occupancyEntity,countEntity:h.count_entity||l.countEntity,availabilityEntity:h.availability_entity||"",zoneEntity:g?.entity_id||l.zoneEntity,zoneKind:g?.kind||"occupancy"}}const ha=t=>JSON.stringify(t,(t,e)=>e&&"object"==typeof e&&!Array.isArray(e)?Object.fromEntries(Object.entries(e).sort(([t],[e])=>te?1:0)):e),ca=t=>{if(!t.trim())return null;const e=Number(t.replace(",","."));return Number.isFinite(e)?e:null};function da(t,e){const s=ca(t.mountX),i=ca(t.mountY),o=ca(t.heading);if(!t.roomId||null==s||null==i||null==o)return null;const a={...t.original?.sources||{}};if(delete a.slots,delete a.ranges,delete a.zones,delete a.occupancy_entity,delete a.count_entity,"esphome_ld2450_v1"===t.profile||"cartesian_v1"===t.profile){if(a.slots=t.xEntities.flatMap((e,s)=>{const i=t.yEntities[s]||"";return e&&i?[{id:`target_${s+1}`,x_entity:e,y_entity:i,unit:"esphome_ld2450_v1"===t.profile?"mm":t.unit,..."cartesian_v1"===t.profile&&t.swapXY[s]?{swap_xy:!0}:{},..."cartesian_v1"===t.profile&&-1===t.xSigns[s]?{x_sign:-1}:{},..."cartesian_v1"===t.profile&&-1===t.ySigns[s]?{y_sign:-1}:{},...t.slotPresenceEntities[s]?{presence_entity:t.slotPresenceEntities[s]}:{}}]:[]}),!a.slots.length)return null}else if("polar_v1"===t.profile){if(a.slots=t.distanceEntities.flatMap((e,s)=>{const i=t.angleEntities[s]||"";return e&&i?[{id:`target_${s+1}`,distance_entity:e,angle_entity:i,unit:t.unit,angle_unit:t.angleUnit,angle_zero:t.angleZero,angle_clockwise:t.angleClockwise,...t.slotPresenceEntities[s]?{presence_entity:t.slotPresenceEntities[s]}:{}}]:[]}),!a.slots.length)return null}else if("range_v1"===t.profile){if(a.ranges=t.rangeEntities.flatMap((e,s)=>e?[{id:`range_${s+1}`,entity_id:e,unit:t.unit,...t.rangePresenceEntities[s]?{presence_entity:t.rangePresenceEntities[s]}:{}}]:[]),!a.ranges.length)return null}else if("zones_v1"===t.profile){if(!t.zoneEntity)return null;a.zones=[{id:"zone_1",kind:t.zoneKind,entity_id:t.zoneEntity}]}else if("presence_v1"===t.profile&&!t.occupancyEntity)return null;t.occupancyEntity&&(a.occupancy_entity=t.occupancyEntity),t.countEntity&&(a.count_entity=t.countEntity),t.availabilityEntity&&(a.availability_entity=t.availabilityEntity);const n=ca(t.rangeCm),r=ca(t.fovDeg),l=(o%360+360)%360,h={...t.original?.mount||{},installation_id:t.installationId,x:s/1e3,y:i/1e3,heading_deg:l};null!=n&&n>0?h.range_cm=n:delete h.range_cm,null!=r&&r>0?h.fov_deg=r:delete h.fov_deg;const c=t.original,d="two_point"===c?.calibration?.method&&c.profile===t.profile&&ha(c.sources)===ha(a)&&c.mount.installation_id===t.installationId&&Math.abs(c.mount.x-h.x)<1e-12&&Math.abs(c.mount.y-h.y)<1e-12&&Math.abs(c.mount.heading_deg-l)<1e-9&&c.calibration.mirror===t.mirror&&Math.abs(c.calibration.cell_cm-e)<1e-9,p=t.calibrationOverride?{...t.calibrationOverride}:d?{...c.calibration}:{...c?.calibration||{},method:"zones_v1"===t.profile||"presence_v1"===t.profile?"not_required":"manual",mirror:t.mirror,cell_cm:e};t.calibrationOverride||d||(delete p.refs,delete p.rms_cm);const u={...t.original||{},version:1,enabled:t.enabled,profile:t.profile,sources:a,mount:h,room_id:t.roomId,calibration:p};return t.showLive?delete u.show_live:u.show_live=!1,u}const pa={badge:"display.badge",icon_ripple:"display.icon_ripple",value:"display.value",static_icon:"display.static_icon",value_static_icon:"display.value_static_icon"},ua={badge:"marker.display_hint_badge",icon_ripple:"marker.display_hint_icon_ripple",value:"marker.display_hint_value",static_icon:"marker.display_hint_static_icon",value_static_icon:"marker.display_hint_value_static_icon"};function _a(){const t=this.host._markerDialog,e="virtual"===t.bindingMode,s=this._bindingCandidates();this.host._bindingEntities(t.binding);const i=e?null:this.host._bindingStatus(t.binding),o=!e&&this.host._bindingHasHaPage(t.binding),a=this._markerPreviewDevice(t),n=this._effectiveMarkerTapAction(t,a),r=a?_(this.host._serverCfg?.spaces.find(t=>t.id===a.space)):null,l=a?this._markerPreviewDevices(a):this.host._devices,h="toggle"===n&&a?this._toggleIntent(a,l):null,c=this._toggleHintLines(h),u=a?g(this.host._planHass,a,{liveStates:!1!==this.host._config?.live_states,showTemperature:!1!==this.host._config?.show_temperature,showSignal:r?.showLqi??!1!==this.host._config?.show_signal,designPreview:!0,activityRuntime:this.host._activityRt.get(a.id),lightDevices:l,registryHass:this.host._fullRegistryHass,reducedMotion:this.host._reducedMotion}):null,R=a?m(this.host._planHass,a,l):[],z=a?f(this.host._planHass,a,R):null,F=t.valueBadgeTouched?t.valueBadgeEnabled:!!u?.valueBadge,N=t.valueBadgeTouched?t.valueBadgeSource:u?.valueBadge?.source||t.valueBadgeSource,A=t.valueBadgeTouched?t.valueBadgePosition:u?.valueBadge?.position||t.valueBadgePosition,E=b(N),O=!!N&&!R.some(t=>t.key===E),H=R.find(t=>t.key===E),B=b(t.valueSource),W=!(!t.valueSource||B&&R.some(t=>t.key===B)),j=R.find(t=>t.key===B),G=u?.valueSource?.sourceKey||"",q=this._markerAutoHasSpatialSource(t),U=!!a&&v(this.host._planHass,{...a}),K=y(t.lightRole,q,U,t.glowMode),V=!K.sourceExists,J=!K.fromSourceEnabled,Z=K.passive,Y=K.effectiveMode,X="never"===t.lightRole?this.host._t("marker.glow_disabled_never"):"auto"!==t.lightRole||q?Z?this.host._t("marker.glow_passive_hint"):this.host._t("marker.glow_disabled_no_entity"):this.host._t("marker.glow_disabled_auto"),Q=a?$(a):[],tt=a&&w(a)||"",et=!!t.lightEntity&&!Q.includes(t.lightEntity),st=a?k(a):[],it=!!t.toggleEntity&&!st.includes(t.toggleEntity),ot="toggle"===n?this._toggleIntentForDialog({...t,toggleEntity:"",toggleEntityTouched:!0}):null,at=ot?[...ot.targets,...ot.skippedTargets].map(t=>t.entityId||("ref"in t?t.ref:"")).filter(Boolean).join(", "):"",nt=(()=>{if(e)return null;const i=s.find(e=>e.value===t.binding);if(i)return i.label;const[o,a]=t.binding.split(":");return"device"===o?this.host._fullRegistryHass.devices[a]?.name_by_user||this.host._fullRegistryHass.devices[a]?.name||a:this.host._fullRegistryHass.entities[a]?.name||this.host.hass.states[a]?.attributes?.friendly_name||a})();return p``}const ea=new Set(["ld2450","hlkld2450","hilinkld2450"]),sa=()=>globalThis.crypto?.randomUUID?.()||`radar_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`,ia=(t,e,s)=>{const i=!!t?.original;return{radar:i?t:null,radarEligible:i,radarTouched:i?e:e||!!t,radarRemove:i?s:s||!!t}},oa=(t,e="")=>"number"==typeof t&&Number.isFinite(t)?String(t):e,aa=t=>Array.from(new Set([...t.allEntities||t.entities||[],..."entity"===t.bindingKind&&t.bindingRef?[t.bindingRef]:[]])).filter(t=>/^[a-z0-9_]+\.[a-z0-9_]+$/.test(t)),na=(t,e,s)=>{const i=t.split(".",2)[1]||"";return new RegExp(`(?:^|_)target_?${s}_${e}(?:_|$)`).test(i)||new RegExp(`(?:^|_)target_${e}_${s}(?:_|$)`).test(i)};function ra(t,e){if(t.marker?.radar&&"object"==typeof t.marker.radar)return u(t.marker.radar)?{eligible:!0,profile:t.marker.radar.profile,reason:"saved"}:{eligible:!0,profile:"presence_v1",reason:"saved_unsupported"};const s="entity"===t.bindingKind?e?.entities?.[t.bindingRef||""]:null,i="device"===t.bindingKind?t.bindingRef:s?.device_id,o=i?e?.devices?.[i]:null,a=aa(t);return ea.has((n=o?.model||t.model,String(n||"").toLowerCase().replace(/[^a-z0-9]/g,"")))&&a.some(t=>na(t,"x",1))&&a.some(t=>na(t,"y",1))?{eligible:!0,profile:"esphome_ld2450_v1",reason:"ld2450"}:{eligible:!1,profile:"presence_v1",reason:"none"};var n}function la(t,e){return t.find(t=>e.some(e=>e.test(t)))||""}function ha(t,e,s,i,o=!1){const a=ra(t,i),n=u(t.marker?.radar)?t.marker.radar:null;if(!n&&!a.eligible&&!o)return null;const r=n?.profile||a.profile,l=o&&!a.eligible||"ld2450"!==a.reason?{xEntities:["","",""],yEntities:["","",""],distanceEntity:"",angleEntity:"",occupancyEntity:"",countEntity:"",zoneEntity:""}:function(t,e,s){const i=aa(t).filter(t=>!!s?.states?.[t]),o=[],a=[];for(let t=1;t<=3;t++)o.push(i.find(e=>na(e,"x",t))||""),a.push(i.find(e=>na(e,"y",t))||"");const n=i.filter(t=>t.startsWith("binary_sensor.")),r=i.filter(t=>t.startsWith("sensor.")),l=la(n,[/(?:occupancy|presence|target)(?:_|$)/]);return{xEntities:o,yEntities:a,distanceEntity:la(r,[/(?:target_)?distance(?:_|$)/,/distance/]),angleEntity:la(r,[/(?:target_)?angle(?:_|$)/,/angle/]),occupancyEntity:l,countEntity:la(r,[/(?:target|people|presence)_count(?:_|$)/,/target_count/]),zoneEntity:"zones_v1"===e?la(n,[/(?:zone|region).*(?:occupancy|presence)/,/zone/]):""}}(t,r,i),h=n?.sources||{},c=h.slots||[],d=c.filter(t=>"x_entity"in t),p=c.filter(t=>"distance_entity"in t),_=h.ranges||[],g=h.zones?.[0],m="esphome_ld2450_v1"===r?3:"cartesian_v1"===r?Math.max(1,d.length):"polar_v1"===r?Math.max(1,p.length):1,f=n?.room_id||t.marker?.room_id||e.rooms.find(e=>e.area&&e.area===t.area)?.id||"";return{original:n,enabled:!0===n?.enabled,showLive:!1!==n?.show_live,profile:r,roomId:f,installationId:n?.mount?.installation_id||sa(),mountX:oa(null==n?.mount?.x?void 0:1e3*n.mount.x,oa(s[0],"0")),mountY:oa(null==n?.mount?.y?void 0:1e3*n.mount.y,oa(s[1],"0")),heading:oa(n?.mount?.heading_deg,"0"),rangeCm:oa(n?.mount?.range_cm,"esphome_ld2450_v1"===r?"600":""),fovDeg:oa(n?.mount?.fov_deg,"esphome_ld2450_v1"===r?"120":""),mirror:!0===n?.calibration?.mirror,unit:d[0]?.unit||p[0]?.unit||_[0]?.unit||("esphome_ld2450_v1"===r?"mm":"cm"),xEntities:Array.from({length:m},(t,e)=>d[e]?.x_entity||l.xEntities[e]||""),yEntities:Array.from({length:m},(t,e)=>d[e]?.y_entity||l.yEntities[e]||""),distanceEntities:Array.from({length:m},(t,e)=>p[e]?.distance_entity||(0===e?l.distanceEntity:"")),angleEntities:Array.from({length:m},(t,e)=>p[e]?.angle_entity||(0===e?l.angleEntity:"")),rangeEntities:_.length?_.map(t=>t.entity_id):[l.distanceEntity],slotPresenceEntities:Array.from({length:m},(t,e)=>(d[e]||p[e])?.presence_entity||""),rangePresenceEntities:(_.length?_:[{}]).map(t=>"presence_entity"in t&&t.presence_entity||""),swapXY:Array.from({length:m},(t,e)=>!0===d[e]?.swap_xy),xSigns:Array.from({length:m},(t,e)=>-1===d[e]?.x_sign?-1:1),ySigns:Array.from({length:m},(t,e)=>-1===d[e]?.y_sign?-1:1),angleUnit:p[0]?.angle_unit||"degrees",angleZero:p[0]?.angle_zero||"forward",angleClockwise:!1!==p[0]?.angle_clockwise,occupancyEntity:h.occupancy_entity||l.occupancyEntity,countEntity:h.count_entity||l.countEntity,availabilityEntity:h.availability_entity||"",zoneEntity:g?.entity_id||l.zoneEntity,zoneKind:g?.kind||"occupancy"}}const ca=t=>JSON.stringify(t,(t,e)=>e&&"object"==typeof e&&!Array.isArray(e)?Object.fromEntries(Object.entries(e).sort(([t],[e])=>te?1:0)):e),da=t=>{if(!t.trim())return null;const e=Number(t.replace(",","."));return Number.isFinite(e)?e:null};function pa(t,e){const s=da(t.mountX),i=da(t.mountY),o=da(t.heading);if(!t.roomId||null==s||null==i||null==o)return null;const a={...t.original?.sources||{}};if(delete a.slots,delete a.ranges,delete a.zones,delete a.occupancy_entity,delete a.count_entity,"esphome_ld2450_v1"===t.profile||"cartesian_v1"===t.profile){if(a.slots=t.xEntities.flatMap((e,s)=>{const i=t.yEntities[s]||"";return e&&i?[{id:`target_${s+1}`,x_entity:e,y_entity:i,unit:"esphome_ld2450_v1"===t.profile?"mm":t.unit,..."cartesian_v1"===t.profile&&t.swapXY[s]?{swap_xy:!0}:{},..."cartesian_v1"===t.profile&&-1===t.xSigns[s]?{x_sign:-1}:{},..."cartesian_v1"===t.profile&&-1===t.ySigns[s]?{y_sign:-1}:{},...t.slotPresenceEntities[s]?{presence_entity:t.slotPresenceEntities[s]}:{}}]:[]}),!a.slots.length)return null}else if("polar_v1"===t.profile){if(a.slots=t.distanceEntities.flatMap((e,s)=>{const i=t.angleEntities[s]||"";return e&&i?[{id:`target_${s+1}`,distance_entity:e,angle_entity:i,unit:t.unit,angle_unit:t.angleUnit,angle_zero:t.angleZero,angle_clockwise:t.angleClockwise,...t.slotPresenceEntities[s]?{presence_entity:t.slotPresenceEntities[s]}:{}}]:[]}),!a.slots.length)return null}else if("range_v1"===t.profile){if(a.ranges=t.rangeEntities.flatMap((e,s)=>e?[{id:`range_${s+1}`,entity_id:e,unit:t.unit,...t.rangePresenceEntities[s]?{presence_entity:t.rangePresenceEntities[s]}:{}}]:[]),!a.ranges.length)return null}else if("zones_v1"===t.profile){if(!t.zoneEntity)return null;a.zones=[{id:"zone_1",kind:t.zoneKind,entity_id:t.zoneEntity}]}else if("presence_v1"===t.profile&&!t.occupancyEntity)return null;t.occupancyEntity&&(a.occupancy_entity=t.occupancyEntity),t.countEntity&&(a.count_entity=t.countEntity),t.availabilityEntity&&(a.availability_entity=t.availabilityEntity);const n=da(t.rangeCm),r=da(t.fovDeg),l=(o%360+360)%360,h={...t.original?.mount||{},installation_id:t.installationId,x:s/1e3,y:i/1e3,heading_deg:l};null!=n&&n>0?h.range_cm=n:delete h.range_cm,null!=r&&r>0?h.fov_deg=r:delete h.fov_deg;const c=t.original,d="two_point"===c?.calibration?.method&&c.profile===t.profile&&ca(c.sources)===ca(a)&&c.mount.installation_id===t.installationId&&Math.abs(c.mount.x-h.x)<1e-12&&Math.abs(c.mount.y-h.y)<1e-12&&Math.abs(c.mount.heading_deg-l)<1e-9&&c.calibration.mirror===t.mirror&&Math.abs(c.calibration.cell_cm-e)<1e-9,p=t.calibrationOverride?{...t.calibrationOverride}:d?{...c.calibration}:{...c?.calibration||{},method:"zones_v1"===t.profile||"presence_v1"===t.profile?"not_required":"manual",mirror:t.mirror,cell_cm:e};t.calibrationOverride||d||(delete p.refs,delete p.rms_cm);const u={...t.original||{},version:1,enabled:t.enabled,profile:t.profile,sources:a,mount:h,room_id:t.roomId,calibration:p};return t.showLive?delete u.show_live:u.show_live=!1,u}const ua={badge:"display.badge",icon_ripple:"display.icon_ripple",value:"display.value",static_icon:"display.static_icon",value_static_icon:"display.value_static_icon"},_a={badge:"marker.display_hint_badge",icon_ripple:"marker.display_hint_icon_ripple",value:"marker.display_hint_value",static_icon:"marker.display_hint_static_icon",value_static_icon:"marker.display_hint_value_static_icon"};function ga(){Zo(this.host);const t=this.host._markerDialog,e="virtual"===t.bindingMode,s=this._bindingCandidates();this.host._bindingEntities(t.binding);const i=e?null:this.host._bindingStatus(t.binding),o=!e&&this.host._bindingHasHaPage(t.binding),a=this._markerPreviewDevice(t),n=this._effectiveMarkerTapAction(t,a),r=a?_(this.host._serverCfg?.spaces.find(t=>t.id===a.space)):null,l=a?this._markerPreviewDevices(a):this.host._devices,h="toggle"===n&&a?this._toggleIntent(a,l):null,c=this._toggleHintLines(h),u=a?g(this.host._planHass,a,{liveStates:!1!==this.host._config?.live_states,showTemperature:!1!==this.host._config?.show_temperature,showSignal:r?.showLqi??!1!==this.host._config?.show_signal,designPreview:!0,activityRuntime:this.host._activityRt.get(a.id),lightDevices:l,registryHass:this.host._fullRegistryHass,reducedMotion:this.host._reducedMotion}):null,R=a?m(this.host._planHass,a,l):[],z=a?f(this.host._planHass,a,R):null,F=t.valueBadgeTouched?t.valueBadgeEnabled:!!u?.valueBadge,N=t.valueBadgeTouched?t.valueBadgeSource:u?.valueBadge?.source||t.valueBadgeSource,A=t.valueBadgeTouched?t.valueBadgePosition:u?.valueBadge?.position||t.valueBadgePosition,E=b(N),O=!!N&&!R.some(t=>t.key===E),H=R.find(t=>t.key===E),B=b(t.valueSource),W=!(!t.valueSource||B&&R.some(t=>t.key===B)),j=R.find(t=>t.key===B),G=u?.valueSource?.sourceKey||"",q=this._markerAutoHasSpatialSource(t),U=!!a&&v(this.host._planHass,{...a}),K=y(t.lightRole,q,U,t.glowMode),V=!K.sourceExists,J=!K.fromSourceEnabled,Z=K.passive,Y=K.effectiveMode,X="never"===t.lightRole?this.host._t("marker.glow_disabled_never"):"auto"!==t.lightRole||q?Z?this.host._t("marker.glow_passive_hint"):this.host._t("marker.glow_disabled_no_entity"):this.host._t("marker.glow_disabled_auto"),Q=a?$(a):[],tt=a&&w(a)||"",et=!!t.lightEntity&&!Q.includes(t.lightEntity),st=a?k(a):[],it=!!t.toggleEntity&&!st.includes(t.toggleEntity),ot="toggle"===n?this._toggleIntentForDialog({...t,toggleEntity:"",toggleEntityTouched:!0}):null,at=ot?[...ot.targets,...ot.skippedTargets].map(t=>t.entityId||("ref"in t?t.ref:"")).filter(Boolean).join(", "):"",nt=(()=>{if(e)return null;const i=s.find(e=>e.value===t.binding);if(i)return i.label;const[o,a]=t.binding.split(":");return"device"===o?this.host._fullRegistryHass.devices[a]?.name_by_user||this.host._fullRegistryHass.devices[a]?.name||a:this.host._fullRegistryHass.entities[a]?.name||this.host.hass.states[a]?.attributes?.friendly_name||a})();return p`this._closeMarkerDialog()}>
    - ${Zo({title:this.host._t("marker.card_basics"),body:p` + ${Yo({title:this.host._t("marker.card_basics"),body:p` ${"ha_disabled"===i?.kind?p`
    ${this.host._t(`marker.ha_disabled_${i.reason}`)} @@ -120,7 +120,7 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db
    @@ -145,7 +145,7 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db @input=${e=>this.host._markerDialog={...t,bindingFilter:e.target.value}} />
    ${s.map(e=>p`
    {if(e.value===t.binding)return void(this.host._markerDialog={...t,bindingOpen:!1});const s={...t,binding:e.value,bindingOpen:!1,controls:x(e.value,t.controls,this.host._bindingEntities(e.value)),autoIcon:this.host._autoIconForBinding(e.value),...sa(t.radar,t.radarTouched,t.radarRemove)};this.host._markerDialog=this._announceToggleDraft({...s,...this._valueBadgeForBinding(s,e.value),valueSource:null,valueSourceTouched:!0})}}> + @click=${()=>{if(e.value===t.binding)return void(this.host._markerDialog={...t,bindingOpen:!1});const s={...t,binding:e.value,bindingOpen:!1,controls:x(e.value,t.controls,this.host._bindingEntities(e.value)),autoIcon:this.host._autoIconForBinding(e.value),...ia(t.radar,t.radarTouched,t.radarRemove)};this.host._markerDialog=this._announceToggleDraft({...s,...this._valueBadgeForBinding(s,e.value),valueSource:null,valueSourceTouched:!0})}}> ${e.label}${e.sub}
    `)} ${s.length?d:p`
    ${this.host._t("marker.nothing_found")}
    `} @@ -164,7 +164,7 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db ${this._renderRadarSection(t,a)} ${this._renderVacSection(t)}`})} - ${Zo({title:this.host._t("marker.card_tap"),body:p` + ${Yo({title:this.host._t("marker.card_tap"),body:p` -

    ${this.host._t(ua[t.display])}

    +

    ${this.host._t(_a[t.display])}

    ${D(t.display)?p`
    @@ -462,7 +462,7 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db ${this._rangeInput(0,355,5,t.angle,e=>this.host._markerDialog={...t,angle:e})} ${t.angle}°
    `})} - ${Zo({title:this.host._t("marker.card_details"),body:p` + ${Yo({title:this.host._t("marker.card_details"),body:p` {Number.isFinite(t)&&Number.isFinite(e)&&t!==e&&Math.abs(e-t)<=ga&&c++},p=(t,e)=>{d(t[0],e[0]),d(t[1],e[1])},u={};let _=5;for(const t of s){const e=$a(t);null!=t?.id&&(u[String(t.id)]=e),e>_&&(_=e)}const g=(t,e,s,i=!1)=>{if(!(t>ga||i))return;o++,t>n&&(n=t);const a=t*F*e;a>r&&(r=a,l=s)};for(const t of s){const e=$a(t),s=null!=t?.id?String(t.id):"";for(const i of t.rooms||[]){a++;let t=0;if(i.poly?.length)i.poly=i.poly.map(e=>{const s=[fa(e[0]),fa(e[1])];return t=Math.max(t,ba(e[0],e[1],s[0],s[1])),p(e,s),s});else if(null!=i.x&&null!=i.y){const e=i.x,s=i.y,o=i.w||0,a=i.h||0,n=fa(e+o),r=fa(s+a),l=fa(e),h=fa(s),c=Math.max(z,n-l),p=Math.max(z,r-h);t=va(e,s,o,a,l,h,c,p),i.x=l,i.y=h,i.w=c,i.h=p,d(e,l),d(s,h),d(e+o,l+c),d(s+a,h+p)}g(t,e,s)}for(const i of t.partitions||[]){a++;const o=[i.a[0],i.a[1]],n=[i.b[0],i.b[1]],r=[fa(o[0]),fa(o[1])],l=[fa(n[0]),fa(n[1])];let h=Math.max(ba(o[0],o[1],r[0],r[1]),ba(n[0],n[1],l[0],l[1]));const c=ba(r[0],r[1],l[0],l[1]),d=(t.openings||[]).filter(t=>"partition"===t.host?.kind&&t.host.id===i.id).every(t=>{const e=Number(t.length),s=Number(t.host.t),i=s*c;return Number.isFinite(e)&&e>0&&Number.isFinite(s)&&s>=0&&s<=1&&i-e/2>=-ga&&i+e/2<=c+ga});c>ga&&d?(i.a=r,i.b=l,p(o,r),p(n,l)):h=0,g(h,e,s)}for(const i of t.wall_columns||[]){a++;const t=[i.center[0],i.center[1]],o=[fa(t[0]),fa(t[1])],n=ba(t[0],t[1],o[0],o[1]);i.center=o,p(t,o),g(n,e,s)}for(const i of t.decor||[]){if("furniture"===i.kind||"image"===i.kind)continue;a++;let t=0;if("line"===i.kind){const e=[i.x1,i.y1],s=[i.x2,i.y2],o=[fa(e[0]),fa(e[1])],a=[fa(s[0]),fa(s[1])];t=Math.max(ba(e[0],e[1],o[0],o[1]),ba(s[0],s[1],a[0],a[1])),i.x1=o[0],i.y1=o[1],i.x2=a[0],i.y2=a[1],p(e,o),p(s,a)}else{const e=i.x,s=i.y,o=i.w,a=i.h,n=fa(e),r=fa(s);if(null!=i.w&&null!=i.h){const l=fa(e+o),h=fa(s+a),c=Math.max(z,l-n),p=Math.max(z,h-r);t=va(e,s,o,a,n,r,c,p),i.w=c,i.h=p,d(e+o,n+c),d(s+a,r+p)}else t=ba(e,s,n,r);i.x=n,i.y=r,d(e,n),d(s,r)}g(t,e,s)}for(const i of t.openings||[]){if(a++,"partition"===i.host?.kind){const o=(t.partitions||[]).find(t=>t.id===i.host.id),a=Number(i.host.t);if(!o||!Number.isFinite(a)||a<0||a>1)continue;const n=o.b[0]-o.a[0],r=o.b[1]-o.a[1];if(Math.hypot(n,r)<=ga)continue;const l=o.a[0]+n*a,c=o.a[1]+r*a;let d=180*Math.atan2(r,n)/Math.PI;d>=90?d-=180:d<-90&&(d+=180);const p=Number(i.angle),u=!(Number.isFinite(p)&&p===d),_=ya(i.x,i.y,Number.isFinite(p)?p:d,Number(i.length)||0,l,c,d);i.x=l,i.y=c,i.angle=d,u&&h++,g(_,e,s,u);continue}const o=R([i.x,i.y],t.rooms||[],ma,{step:z,length:Number(i.length)||0});if(!o)continue;const n=Number(i.angle),r=!(Number.isFinite(n)&&n===o.angle),l=ya(i.x,i.y,Number.isFinite(n)?n:o.angle,Number(i.length)||0,o.x,o.y,o.angle);i.x=o.x,i.y=o.y,i.angle=o.angle,r&&h++,g(l,e,s,r)}}for(const[t,e]of Object.entries(i)){if(!e||"object"!=typeof e)continue;const s=e;if("number"!=typeof s.x||"number"!=typeof s.y)continue;a++;const o=fa(s.x),n=fa(s.y),r=ba(s.x,s.y,o,n);i[t]={...s,x:o,y:n},d(s.x,o),d(s.y,n);const l="string"==typeof s.s?s.s:"";g(r,u[l]??_,l)}return{spaces:s,layout:i,report:{moved:o,coordsCanonicalized:c,total:a,maxShift:n,maxShiftCm:r,maxSpace:l,rotated:h},changed:o>0||c>0}}function ka(t,e){const s=e.base+t*e.span;return Math.min(1,Math.max(0,s))}const xa=t=>Array.isArray(t)&&t.length>=2&&Number.isFinite(t[0])&&Number.isFinite(t[1]),Ma=(t,e)=>Math.hypot(t[0]-e[0],t[1]-e[1]);function Ca(t,e,s){const i=s[0]-e[0],o=s[1]-e[1],a=i*i+o*o;if(a<=0)return Ma(t,e);let n=((t[0]-e[0])*i+(t[1]-e[1])*o)/a;return n=Math.max(0,Math.min(1,n)),Math.hypot(t[0]-(e[0]+i*n),t[1]-(e[1]+o*n))}function Sa(t,e,s,i,o){for(const i of e)if(i&&!s.has(i.id)&&xa(i.a)&&xa(i.b)&&(Ma(t,i.a)<=o||Ma(t,i.b)<=o))return!0;for(const e of i?.roomPolygons||[])for(let s=0;s0&&r>0))return null;if(Math.abs(o[0]/n*(a[1]/r)-o[1]/n*(a[0]/r))>s)return null;for(const[s,o]of[[t.a,e.a],[t.a,e.b],[t.b,e.a],[t.b,e.b]])if(Ma(s,o)<=i)return[(s[0]+o[0])/2,(s[1]+o[1])/2];return null}function Da(t,e){const s=.05*(Number(e.pitch)>0?Number(e.pitch):1),i=new Map;let o=(t||[]).filter(t=>!!t&&"string"==typeof t.id&&xa(t.a)&&xa(t.b));if(o.length<2)return{partitions:[...t||[]],merged:0,openingMoves:[]};const a=e.seedIds&&e.seedIds.length?new Set(e.seedIds):null;let n=0;for(let t=0;tMa(e,t.at)>s);let c=h[0]??r.a,d=h[h.length-1]??l.b;if(h.length<2&&(c=r.a,d=l.b),d[0]0?(d[0]-c[0])/u:0,g=u>0?(d[1]-c[1])/u:0,m=t=>u>0?((t[0]-c[0])*_+(t[1]-c[1])*g)/u:0;for(const t of[r,l]){const e=m(t.a),s=m(t.b)-e;for(const[o,a]of i)a.toId===t.id&&i.set(o,{fromId:a.fromId,toId:p.id,base:e+a.base*s,span:a.span*s});i.set(t.id,{fromId:t.id,toId:p.id,base:e,span:s})}a&&a.add(p.id),o=o.filter((e,s)=>s!==t.i&&s!==t.j),o.splice(t.i,0,p),n++}return{partitions:o,merged:n,openingMoves:[...i.values()]}}function Ia(t,e,s,i){if(!t?.length||!s.length)return 0;const o=new Map(s.map(t=>[t.fromId,t]));let a=0;for(const s of t){const t=s?.host;if(!t||"partition"!==t.kind)continue;const n=o.get(t.id);if(!n)continue;s.host={...t,id:n.toId,t:ka(t.t,n)},a++;const r=A(s,e,i.coordScale,i.cellCm,i.gridPitch).resolved;r&&Object.assign(s,E(s,r,i.coordScale))}return a}function La(t){return{roomPolygons:(t?.rooms||[]).map(t=>N(t)).filter(t=>!!t),columns:t?.wall_columns||[]}}const Ta=t=>!!t&&t.length>=2&&Number.isFinite(t[0])&&Number.isFinite(t[1]),Ra=(t,e)=>t[0]-e[0]||t[1]-e[1],za=(t,e,s,i)=>[t[0]+e*i,t[1]+s*i],Fa=(t,e,s,i)=>(t[0]-e[0])*s+(t[1]-e[1])*i,Na=(t,e,s,i,o)=>{const a=e[0]-t[0],n=e[1]-t[1],r=Math.hypot(a,n);if(!(r>o))return null;const l=a/r,h=n/r,c=e=>Math.abs((e[0]-t[0])*h-(e[1]-t[1])*l);if(c(s)>o||c(i)>o)return null;const d=Fa(s,t,l,h),p=Fa(i,t,l,h),u=Math.max(0,Math.min(d,p)),_=Math.min(r,Math.max(d,p));return _-u>o?{lo:u,hi:_}:null},Aa=(t,e,s)=>Math.min(t.hi,e.hi)-Math.max(t.lo,e.lo)>s,Ea=t=>{const e=new Set(["id","a","b","cm"]);return Object.keys(t||{}).every(t=>e.has(t))},Oa=(t,e,s,i)=>{const o=t.b[0]-t.a[0],a=t.b[1]-t.a[1],n=Math.hypot(o,a);if(!(n>i))return!0;const r=o/n,l=a/n,h=V(t.cm,s.cellCm,s.gridPitch)/2;return e.some(e=>{const o=e?.center;if(!Ta(o))return!0;const a=Fa(o,t.a,r,l),c=Math.abs((o[0]-t.a[0])*l-(o[1]-t.a[1])*r),d=V(Number(e.cm),s.cellCm,s.gridPitch)*("square"===e.shape?Math.SQRT1_2:.5);return!(Number.isFinite(d)&&d>0)||a>=-d-i&&a<=n+d+i&&c<=h+d+i})},Ha=(t,e,s)=>{if(t.host){const i=A(t,e,s.coordScale,s.cellCm,s.gridPitch).resolved;return i?{center:i.center,angle:i.angle,length:i.length}:null}const i=Number(t.x)*s.coordScale,o=Number(t.y)*s.coordScale,a=Number(t.angle),n=Number(t.length)*s.coordScale;return[i,o,a,n].every(Number.isFinite)&&n>0?{center:[i,o],angle:a,length:n}:null},Ba=(t,e,s)=>{const i=t.angle*Math.PI/180,o=Math.cos(i),a=Math.sin(i),n=e.angle*Math.PI/180,r=Math.cos(n),l=Math.sin(n);if(Math.abs(o*l-a*r)>1e-6)return!1;const h=e.center[0]-t.center[0],c=e.center[1]-t.center[1];if(Math.abs(h*a-c*o)>s)return!1;const d=h*o+c*a;return Math.max(-t.length/2,d-e.length/2)({...t,a:[t.a[0]*e,t.a[1]*e],b:[t.b[0]*e,t.b[1]*e]}),ja=(t,e,s,i)=>{const o=`~r-${(t=>{let e=2166136261;for(let s=0;s>>0;return e.toString(36)})(`${t}|${e[0].toFixed(9)},${e[1].toFixed(9)}|${s[0].toFixed(9)},${s[1].toFixed(9)}`)}`,a=`${t.slice(0,Math.max(1,64-o.length))}${o}`;let n=a;for(let t=2;i.has(n);t++){const e=`-${t}`;n=`${a.slice(0,64-e.length)}${e}`}return i.add(n),n},Ga=(t,e)=>{const s=[];for(const i of t){const t=s[s.length-1];!(t&&Math.abs(t.hi-i.lo)<=e&&t.safe===i.safe)||i.safe&&t.signature!==i.signature?s.push({lo:i.lo,hi:i.hi,a:i.a,b:i.b,safe:i.safe,signature:i.signature,roomIds:i.roomIds,finalCm:i.finalCm}):(t.hi=i.hi,t.b=i.b)}return s};function qa(t,e,s,i,o){const a=s||[],n=Array.isArray(t?.partitions)?t.partitions:[],r=Array.isArray(t?.openings)?t.openings:[],l={walls:a,partitions:n,openings:r,partitionsReconciled:0,openingsRehosted:0};if(!n.length)return l;const h=Math.max(2e-4*o.gridPitch,1e-9);let c=a,d=n,p=r,u=0,_=0;const g=o.partitionIds?new Set(o.partitionIds):null,m=new Map(e.partitions.map(t=>[t.id,t]));for(const t of[...n].sort((t,e)=>t.id.localeCompare(e.id))){if(g&&!g.has(t.id))continue;if(!d.some(e=>e.id===t.id))continue;if(!Ea(t))continue;const s=m.get(t.id);if(!(s&&Ta(s.a)&&Ta(s.b)&&Number.isFinite(s.cm)&&(o.allowCoincidentPartitions?!(s.cm<0):s.cm>0)))continue;const[a,n]=Ra(s.a,s.b)<=0?[[s.a[0],s.a[1]],[s.b[0],s.b[1]]]:[[s.b[0],s.b[1]],[s.a[0],s.a[1]]],r=n[0]-a[0],l=n[1]-a[1],f=Math.hypot(r,l);if(!(f>h))continue;const b=r/f,v=l/f,y=O(e.rooms,c,i,o.pitch,o.cellCm,o.gridPitch,o.coordScale),$=y.flatMap(t=>{if(t.open||"outer"!==t.kind&&"shared"!==t.kind)return[];const e=Na(a,n,t.a,t.b,h);return e?[{interval:t,range:e}]:[]});if(!$.length)continue;const w=p.filter(t=>"partition"===t.host?.kind&&t.host.id===s.id).map(t=>({opening:t,resolved:A(t,e.partitions,o.coordScale,o.cellCm,o.gridPitch).resolved}));if(w.some(t=>!t.resolved))continue;const k=[0,f];for(const{range:t}of $)k.push(t.lo,t.hi);const x=k.slice(),M=new Map;for(const{opening:t,resolved:e}of w){const s=Fa(e.center,a,b,v),i={lo:s-e.length/2,hi:s+e.length/2};M.set(t.id,i),x.push(Math.max(0,i.lo),Math.min(f,i.hi))}const C=[...new Set(x.filter(t=>Number.isFinite(t)&&t>=-h&&t<=f+h).map(t=>Math.max(0,Math.min(f,t)).toFixed(9)))].map(Number).sort((t,e)=>t-e),S=d.map(t=>Wa(t,o.coordScale)).filter(t=>t.id!==s.id),P=[];for(let t=0;t+1h))continue;const r=za(a,b,v,i),l=za(a,b,v,n),c=$.filter(({range:t})=>t.lo<=i+h&&t.hi>=n-h).map(({interval:t})=>t),d=new Map;for(const t of c)d.set(t.roomId,t);const p=[...d.values()],u=new Set(p.map(t=>t.kind)),_=new Set(p.map(t=>o.allowCoincidentPartitions||t.cm>0?t.cm:H)),g=p[0]?.kind,m=[...d.keys()].sort(),f=1===u.size&&1===_.size&&("outer"===g&&1===m.length||"shared"===g&&2===m.length),y={id:s.id,a:r,b:l,cm:s.cm},w=S.some(t=>!!Na(r,l,t.a,t.b,h)),k=f&&(o.allowCoincidentPartitions||!w)&&!Oa(y,e.wall_columns,o,h),x=f?o.allowCoincidentPartitions||p[0].cm>0?p[0].cm:H:0,M=f?Math.max(x,s.cm):s.cm;P.push({lo:i,hi:n,a:r,b:l,safe:k,signature:k?`${g}|${m.join(",")}|${M}`:"",roomIds:m,roomCm:x,finalCm:M})}if(!P.some(t=>t.safe))continue;const D=new Map;for(const{opening:t,resolved:e}of w){const i=M.get(t.id),a=k.some(t=>t>i.lo+h&&tAa(t,i,h)),r=new Set(n.filter(t=>t.safe).map(t=>t.signature));if(!a&&n.length>0&&n.every(t=>t.safe)&&1===r.size&&B(e,y,h)){D.set(t.id,{resolved:e,signature:[...r][0]});continue}const l=W(s,o.cellCm,o.gridPitch),c={lo:i.lo-l,hi:i.hi+l};for(const t of P)Aa(t,c,h)&&(t.safe=!1,t.signature="")}let I=!0;for(;I;){I=!1;for(const[t,e]of[...D.entries()]){const i=M.get(t),a=P.filter(t=>Aa(t,i,h));if(a.length>0&&a.every(t=>t.safe)&&a.every(t=>t.signature===e.signature))continue;D.delete(t);const n=W(s,o.cellCm,o.gridPitch),r={lo:i.lo-n,hi:i.hi+n};for(const t of P)Aa(t,r,h)&&(t.safe=!1,t.signature="");I=!0}}const L=Ga(P,h),T=L.filter(t=>t.safe),R=L.filter(t=>!t.safe);if(!T.length)continue;if(d.length-1+R.length>2e3)continue;let z=c;for(const t of T){const[e,i]=Ra(s.a,s.b)<=0?[t.a,t.b]:[t.b,t.a];z=j(z,e,i,t.finalCm,o.pitch,o.coordScale)}if(z=G(e.rooms,z,i,o.pitch,o.cellCm,o.gridPitch,o.coordScale),z.length>500)continue;const F=new Set(d.map(t=>t.id));F.delete(s.id);const N=R.map((t,e)=>{const i=[t.a[0]/o.coordScale,t.a[1]/o.coordScale],a=[t.b[0]/o.coordScale,t.b[1]/o.coordScale],n=0===e?s.id:ja(s.id,i,a,F);return F.add(n),{id:n,a:i,b:a,cm:s.cm}}),V=d.findIndex(t=>t.id===s.id),J=d.slice();J.splice(V,1,...N);const Z=J.map(t=>Wa(t,o.coordScale)),Y=new Map;let X=!0;for(const{opening:t,resolved:e}of w){const s=D.get(t.id);if(s){const e=E(t,s.resolved,o.coordScale),{host:i,...a}=e;Y.set(t.id,a);continue}const i=M.get(t.id),a=N[R.findIndex(t=>t.lo<=i.lo+h&&t.hi>=i.hi-h)],n=a&&Z.find(t=>t.id===a.id);if(!a||!n){X=!1;break}const r=n.b[0]-n.a[0],l=n.b[1]-n.a[1],c=Math.hypot(r,l),d=Fa(e.center,n.a,r/c,l/c),p={...E(t,e,o.coordScale),host:{kind:"partition",id:a.id,t:d/c}};if(!q(p,Z,o.coordScale,o.cellCm,o.gridPitch).resolved){X=!1;break}Y.set(t.id,p)}if(!X)continue;const Q=p.map(t=>Y.get(t.id)||t),tt=[...D.keys()].map(t=>Y.get(t)),et=tt.map(t=>Ha(t,Z,o));if(et.some(t=>!t))continue;let st=!1;for(let t=0;tt.id));for(const t of Q){if(it.has(t.id))continue;const e=Ha(t,Z,o);e&&et.some(t=>Ba(t,e,h))&&(st=!0)}if(st)continue;const ot=U(e.rooms,z,i,o.pitch,o.cellCm,o.gridPitch,o.coordScale);[...D.entries()].every(([t,e])=>{const s=Y.get(t),i=K(ot,{x:s.x*o.coordScale,y:s.y*o.coordScale,angle:s.angle,length:s.length*o.coordScale},!0),a=[i.negative,i.positive].filter(t=>!!t?.full),n=e.signature.split("|")[1].split(","),r=new Set(a.map(t=>t.roomId));return a.length===n.length&&r.size===n.length&&n.every(t=>r.has(t))})&&(c=z,d=J,p=Q,u+=T.length,_+=D.size)}return{walls:c,partitions:d,openings:p,partitionsReconciled:u,openingsRehosted:_}}const Ua=t=>JSON.parse(JSON.stringify(t)),Ka=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Va=(t,e)=>e.length>0&&e.length<=35&&("space"===t?/^[a-z0-9_-]+$/.test(e):/^[A-Za-z0-9_-]+$/.test(e));function Ja(t,e){let s=String(e??"");const i=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=new RegExp(`^${i}_(.+)_([0-9a-f]{8})$`);let a=0;for(;a<16;a++){const t=o.exec(s);if(!t)return{root:s,layers:a,bounded:!1};s=t[1]}return{root:s,layers:a,bounded:o.test(s)}}const Za=(t,e,s)=>{const i=t.get(e)||[];i.push(s),t.set(e,i)};const Ya=1e-9;class Xa extends Error{constructor(t,e=""){super(e?`${t}: ${e}`:t),this.reason=t,this.name="WallSegmentModelError"}}const Qa=t=>JSON.parse(JSON.stringify(t)),tn=t=>Array.isArray(t)&&t.length>=2&&Number.isFinite(Number(t[0]))&&Number.isFinite(Number(t[1])),en=t=>[Number(t[0]),Number(t[1])],sn=t=>`${Number(t[0]).toFixed(12)},${Number(t[1]).toFixed(12)}`,on=(t,e)=>{const s=sn(t),i=sn(e);return ssn(t)<=sn(e)?[en(t),en(e)]:[en(e),en(t)],nn=(t,e)=>Math.hypot(e[0]-t[0],e[1]-t[1]),rn=(t,e=[])=>{const s=new Set,i=t=>{const e=Number(t);if(!Number.isFinite(e))return;const i=e/z;Math.abs(i-Math.round(i))>=tt&&s.add(e.toFixed(12))};for(const e of Array.isArray(t?.rooms)?t.rooms:[])for(const t of N(e)||[])i(t[0]),i(t[1]);for(const e of[t?.wall_segments,t?.walls])for(const t of Array.isArray(e)?e:[])i(t?.a?.[0]),i(t?.a?.[1]),i(t?.b?.[0]),i(t?.b?.[1]);for(const t of e)i(t?.[0]),i(t?.[1]);return s.size},ln=(t,e,s)=>{const i=s[0]-e[0],o=s[1]-e[1],a=i*i+o*o;return a>1e-18?((t[0]-e[0])*i+(t[1]-e[1])*o)/a:0},hn=(t,e,s)=>{const i=Math.max(0,Math.min(1,ln(t,e,s)));return Math.hypot(t[0]-(e[0]+(s[0]-e[0])*i),t[1]-(e[1]+(s[1]-e[1])*i))},cn=(t,e,s,i,o=1e-9)=>{const a=e[0]-t[0],n=e[1]-t[1],r=Math.hypot(a,n);if(r<=o)return 0;const l=e=>Math.abs((e[0]-t[0])*n-(e[1]-t[1])*a)/r;if(l(s)>o||l(i)>o)return 0;const h=ln(s,t,e),c=ln(i,t,e);return Math.max(0,Math.min(1,Math.max(h,c))-Math.max(0,Math.min(h,c)))*r},dn=t=>{const e=(new TextEncoder).encode(t),s=8*e.length,i=64*Math.ceil((e.length+9)/64),o=new Uint8Array(i);o.set(e),o[e.length]=128;const a=new DataView(o.buffer);a.setUint32(i-8,Math.floor(s/4294967296),!1),a.setUint32(i-4,s>>>0,!1);const n=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),r=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),l=new Uint32Array(64),h=(t,e)=>t>>>e|t<<32-e;for(let t=0;t>>3,o=h(s,17)^h(s,19)^s>>>10;l[t]=l[t-16]+i+l[t-7]+o>>>0}let[e,s,i,o,c,d,p,u]=r;for(let t=0;t<64;t++){const a=u+(h(c,6)^h(c,11)^h(c,25))+(c&d^~c&p)+n[t]+l[t]>>>0,r=e&s^e&i^s&i;u=p,p=d,d=c,c=o+a>>>0,o=i,i=s,s=e,e=a+((h(e,2)^h(e,13)^h(e,22))+r>>>0)>>>0}r[0]=r[0]+e>>>0,r[1]=r[1]+s>>>0,r[2]=r[2]+i>>>0,r[3]=r[3]+o>>>0,r[4]=r[4]+c>>>0,r[5]=r[5]+d>>>0,r[6]=r[6]+p>>>0,r[7]=r[7]+u>>>0}const c=new Uint8Array(32),d=new DataView(c.buffer);for(let t=0;t{const e="abcdefghijklmnopqrstuvwxyz234567";let s=0,i=0,o="";for(const a of t)for(i=i<<8|a,s+=8;s>=5;)o+=e[i>>>s-5&31],s-=5;return s&&(o+=e[i<<5-s&31]),o},un=(t,e,s,i,o="")=>{const[a,n]=an(e,s),r=`${t}|${sn(a)}|${sn(n)}|${[...i].sort().join(",")}${o}`;return`wall-${pn(dn(r)).slice(0,20)}`};let _n=0;const gn=t=>{for(let e=0;e<1e3;e++){const e=globalThis.crypto?.randomUUID?.(),s=`wall-${e||pn(dn(`${Date.now()}|${_n++}|${Math.random()}`)).slice(0,26)}`;if(!t.has(s))return s}throw new Xa("duplicate-id","id factory exhausted")},mn=t=>{const e=new Map;for(const s of Array.isArray(t?.wall_segments)?t.wall_segments:[])if(s&&"string"==typeof s.id&&tn(s.a)&&tn(s.b)){if(e.has(s.id))throw new Xa("duplicate-id",s.id);e.set(s.id,s)}return e},fn=(t,e,s)=>{const i=(s,i)=>{const o=t[0]-s[0],a=t[1]-s[1];return Math.abs(e[0]-i[0]-o)<=Ya&&Math.abs(e[1]-i[1]-a)<=Ya?[o,a]:null};return i(s.a,s.b)||i(s.b,s.a)},bn=(t,e)=>{const s=Array.isArray(t.rooms)?t.rooms:[],i=Y(t.open_spans).map(t=>[t.a[0],t.a[1],t.b[0],t.b[1]]),o=i.length?i:X(s,null,1,.04*z,!0),a=[];for(const t of s){const s=N(t),i=Array.isArray(t?.wall_ids)?t.wall_ids:[];if(s&&i.length===s.length)for(let t=0;t"partition"!==t.host?.kind&&[Number(t.x),Number(t.y)].every(Number.isFinite)&&Number.isFinite(Number(t.angle))&&Number(t.length)>0&&o.some(e=>hn([Number(t.x),Number(t.y)],[e[0],e[1]],[e[2],e[3]])<=.04*z)):[],l=r.map(t=>{const e=Number(t.angle)*Math.PI/180,s=[Math.cos(e),Math.sin(e)],i=Number(t.length)/2,o=[Number(t.x),Number(t.y)];return{a:[o[0]-s[0]*i,o[1]-s[1]*i],b:[o[0]+s[0]*i,o[1]+s[1]*i]}}),h=(t,e)=>r.some(s=>{const i=[Number(s.x),Number(s.y)];if(!et(t,e,Number(s.angle)))return!1;if(hn(i,t,e)>.02*z)return!1;const o=nn(t,e),a=ln(i,t,e)*o,n=Number(s.length)/2;return a+n>=-1e-9&&a-n<=o+Ya}),c=new Map,d=[];for(const i of s){const r=String(i?.id||""),p=N(i);if(!r||!p||p.length<3)throw new Xa("invalid-room",r);const u=Q(s,r,n,z,1,[...t.walls||[],...l]);if(!u||u.poly.length<3)throw new Xa("invalid-room",r);const _=Array.isArray(i.wall_ids)?i.wall_ids:[],g=_.length===p.length;let m=null,f=g;if(f)for(let t=0;tYa||Math.abs(i[1]-m[1])>Ya)){f=!1;break}m=i}const b=[];for(let t=0;t2)throw new Xa("third-owner",n);const d=g?_[u.parent[t]]:void 0;if("string"==typeof d&&d){const o=e.get(d);f||!o||cn(s,i,o.a,o.b)>Ya?l.preferredIds.add(d):l.positionalIds.add(d),l.preferredCarriers.set(d,{a:en(p[u.parent[t]]),b:en(p[(u.parent[t]+1)%p.length])})}const m=u.parent[t];l.parentKeys.add(Z(p[m],p[(m+1)%p.length],z));const v=[(s[0]+i[0])/2,(s[1]+i[1])/2],y=t=>t.some(t=>hn(v,[t[0],t[1]],[t[2],t[3]])<=.04*z);l.zeroWall||=y(a)||y(o)&&!h(s,i),b.push(n)}const v={...i};delete v.wall_ids,d.push({...v,poly:u.poly.map(t=>[t[0],t[1]]),wall_ids:b})}return{atoms:[...c.values()].sort((t,e)=>t.key.localeCompare(e.key)),rooms:d}},vn=(t,e,s,i,o)=>{const a=new Map([...s.values()].map(t=>[on(t.a,t.b),t])),n=(t=>{const e=new Map;for(const s of t)"wall"===s.host?.kind&&e.set(s.host.id,(e.get(s.host.id)||0)+1);return e})(t.openings||[]),r=new Map;for(const t of e){const e=o?.get(t.key);if(e){const i=s.get(e);if(!i)throw new Xa("duplicate-id",e);r.set(t,i);continue}if(t.preferredIds.size>1)throw new Xa("duplicate-id",[...t.preferredIds].sort().join(","));const i=[...t.preferredIds][0],l=i?s.get(i):void 0;if(l){r.set(t,l);continue}const h=i?t.preferredCarriers.get(i):void 0;if(i&&h){r.set(t,{id:i,a:h.a,b:h.b,cm:0});continue}const c=a.get(t.key);if(c){r.set(t,c);continue}const d=[...s.values()].filter(e=>cn(t.a,t.b,e.a,e.b)>Ya),p=[...new Map(d.map(t=>[t.id,t])).values()];if(p.sort((t,e)=>(n.get(e.id)||0)-(n.get(t.id)||0)||nn(e.a,e.b)-nn(t.a,t.b)||t.id.localeCompare(e.id)),p[0])r.set(t,p[0]);else if(1===t.positionalIds.size){const e=s.get([...t.positionalIds][0]);e&&r.set(t,e)}}const l=new Map;for(const[t,e]of r){const s=l.get(e.id)||[];s.push(t),l.set(e.id,s)}for(const[t,e]of l){const i=s.get(t)||r.get(e[0]);if(!i)throw new Xa("duplicate-id",t);const o=[(i.a[0]+i.b[0])/2,(i.a[1]+i.b[1])/2];e.sort((t,e)=>{const s=hn(o,t.a,t.b)<=Ya?0:1,a=hn(o,e.a,e.b)<=Ya?0:1;if(s!==a)return s-a;return(hn(i.a,t.a,t.b)<=Ya?0:1)-(hn(i.a,e.a,e.b)<=Ya?0:1)||t.key.localeCompare(e.key)}),e[0].id=t}const h=(t=>{const e=new Set;for(const s of[t.rooms,t.openings,t.decor,t.room_drafts,t.partitions,t.wall_columns])for(const t of Array.isArray(s)?s:[])"string"==typeof t?.id&&t.id&&e.add(t.id);for(const s of Array.isArray(t.room_drafts)?t.room_drafts:[])for(const t of Array.isArray(s?.segments)?s.segments:[])"string"==typeof t?.id&&t.id&&e.add(t.id);return e})(t);for(const t of e)if(t.id){if(h.has(t.id))throw new Xa("duplicate-id",t.id);h.add(t.id)}const c=e.filter(t=>!t.id);if(i){const e=c.map(e=>{const[s,i]=an(e.a,e.b),o=`${String(t.id||"")}|${sn(s)}|${sn(i)}|${[...e.owners].sort().join(",")}`,a=pn(dn(o));return{atom:e,seed:o,digest:a,base:`wall-${a.slice(0,20)}`}}).sort((t,e)=>t.digest.localeCompare(e.digest)||t.atom.key.localeCompare(e.atom.key)),s=new Map;for(const t of e){const e=s.get(t.digest);if(e&&e!==t.seed)throw new Xa("duplicate-id",t.digest);s.set(t.digest,t.seed);let i=1,o=t.base;for(;h.has(o);)o=`${t.base}-${++i}`;t.atom.id=o,h.add(o)}}else for(const t of c)t.id=gn(h),h.add(t.id)},yn=(t,e)=>{if("partition"===t.host?.kind)return null;const s=[Number(t.x),Number(t.y)];if(!s.every(Number.isFinite))return null;const i=e=>{if(!(Number(e.cm)>0))return!1;const i=ln(s,e.a,e.b),o=nn(e.a,e.b),a=Number(t.length)/2;return i>=-1e-9&&i<=1+Ya&&hn(s,e.a,e.b)<=.02*z&&et(e.a,e.b,Number(t.angle))&&Number.isFinite(a)&&a>=0&&i*o-a>=-1e-9&&i*o+a<=o+Ya},o="wall"===t.host?.kind?e.find(e=>e.id===t.host.id):null,a=o&&i(o)?[o]:e.filter(i);if(1!==a.length)return null;const n=a[0];return{kind:"wall",id:n.id,t:Math.max(0,Math.min(1,ln(s,n.a,n.b)))}},$n=(t,e)=>{const s=[Number(t.x),Number(t.y)];if(!s.every(Number.isFinite))return null;const i=Number(t.length)/2,o=e.filter(e=>{if(!(Number(e.cm)>0))return!1;const o=ln(s,e.a,e.b),a=nn(e.a,e.b);return o>=-1e-9&&o<=1+Ya&&hn(s,e.a,e.b)<=.02*z&&et(e.a,e.b,Number(t.angle))&&Number.isFinite(i)&&i>=0&&o*a-i>=-1e-9&&o*a+i<=a+Ya}),a=(e=>{if(!e.length)return null;const i="wall"===t.host?.kind?e.find(e=>e.id===t.host.id):null;return i||[...e].sort((t,e)=>hn(s,t.a,t.b)-hn(s,e.a,e.b)||Number(e.cm)-Number(t.cm)||(t.ide.id?1:0))[0]})(o);return a?{kind:"wall",id:a.id,t:Math.max(0,Math.min(1,ln(s,a.a,a.b)))}:null},wn=/^[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/,kn=t=>{if("number"!=typeof t&&"string"!=typeof t)return null;if("string"==typeof t&&!wn.test(t.trim()))return null;const e=Number(t);return Number.isFinite(e)?e:null},xn=t=>{if(!Array.isArray(t)||t.length<2)return null;const e=kn(t[0]),s=kn(t[1]);return null==e||null==s?null:[e,s]},Mn=t=>"string"==typeof t?t:"",Cn=t=>{if(!Object.prototype.hasOwnProperty.call(t,"room_drafts"))return{drafts:0,segments:0};const e=Array.isArray(t.room_drafts)?t.room_drafts:[];if(!e.length)return delete t.room_drafts,{drafts:0,segments:0};const s=new Set;for(const e of[t.rooms,t.openings,t.decor,t.partitions,t.wall_columns,t.wall_segments])for(const t of Array.isArray(e)?e:[])"string"==typeof t?.id&&t.id&&s.add(t.id);for(const t of e)"string"==typeof t?.id&&t.id&&s.add(t.id);const i=Array.isArray(t.partitions)?[...t.partitions]:[];let o=0;for(const a of e){const e=Mn(a?.id),n=Array.isArray(a?.points)?a.points:[],r=Array.isArray(a?.segments)?a.segments:[];if(n.length<2||r.length!==n.length-1)throw new Xa("zero-length",e);for(let a=0;a+1100)throw new Xa("thickness-conflict",e);let p="string"==typeof c?.id&&c.id?c.id:"";if(!p||s.has(p)){const i=un(Mn(t.id),l,h,[`draft:${e}:${a}`]);p=i;for(let t=2;s.has(p);t++)p=`${i}-${t}`}s.add(p),i.push({id:p,a:en(l),b:en(h),cm:d}),o++}}return i.length?t.partitions=i:delete t.partitions,delete t.room_drafts,{drafts:e.length,segments:o}},Sn=t=>Cn(t),Pn=(t,e,s)=>{const i=Cn(t),o=mn(t),{atoms:a,rooms:n}=bn(t,o);vn(t,a,o,e,s);const r=a.map(e=>{const s=e.id?o.get(e.id):void 0,i=((t,e,s)=>{if(e.zeroWall)return 0;const i=Array.isArray(t.walls)?t.walls:[],o=Z(e.a,e.b,z),a=i.filter(t=>Number(t.cm)>0&&(!(t.key!==o&&!e.parentKeys.has(t.key))||!(!tn(t.a)||!tn(t.b))&&cn(e.a,e.b,t.a,t.b)>=nn(e.a,e.b)-Ya)).map(t=>Math.max(1,Math.min(100,Number(t.cm))));if(new Set(a.map(t=>t.toFixed(9))).size>1)throw new Xa("thickness-conflict",e.key);if(a.length)return a[0];const n=it(i,e.a,e.b,z,1);return n>0?n:Number(s?.cm)>0?Number(s.cm):0})(t,e,s);return{...s||{},id:e.id,a:[...e.a],b:[...e.b],cm:i}}),l=new Map(a.map(t=>[t.key,t.id]));for(const t of n)t.wall_ids=t.wall_ids.map(t=>l.get(t));t.rooms=n,t.wall_segments=r,t.walls=r.filter(t=>t.cm>0).map(t=>({key:Z(t.a,t.b,z),cm:t.cm,a:[...t.a],b:[...t.b]})),t.walls.length||delete t.walls,delete t.open_spans;for(const e of t.rooms)delete e.open_to;return((t,e,s)=>{const i=Array.isArray(t.openings)?t.openings:[];for(const t of i){if("partition"===t.host?.kind)continue;if(!t.host&&!s){const s=yn(t,e);s&&(t.host=s);continue}const i=yn(t,e)??(s?$n(t,e):null);if(i)t.host=i;else{if(!s)throw new Xa("opening-host",t.id);delete t.host}}})(t,r,e),{wallSegments:r.reduce((t,e)=>t+(o.has(e.id)?0:1),0),drafts:i.drafts,draftSegments:i.segments}};function Dn(t,e={}){const s=JSON.stringify(t),i=Qa(t);J(i);let o=0,a=0,n=0;const r=Number(i?.model_version||0)<10;for(const t of Array.isArray(i?.spaces)?i.spaces:[]){const s=e.lineageSpaceId===String(t?.id||"")?e.lineageHints:void 0,i=Pn(t,r,s);o+=i.wallSegments,a+=i.drafts,n+=i.draftSegments}return i.model_version=10,J(i),{config:i,changed:s!==JSON.stringify(i),migratedSegments:o,migratedDrafts:a,migratedDraftSegments:n}}const In=t=>!!t&&"object"==typeof t&&!Array.isArray(t);function Ln(t,e){const s=(t,e)=>{if(Array.isArray(t)&&Array.isArray(e)){const i=new Map;for(const e of t)In(e)&&"string"==typeof e.id&&e.id&&i.set(e.id,e);const o=e.map((e,o)=>{if(In(e)&&"string"==typeof e.id&&e.id){const t=i.get(e.id);return t?s(t,e):Qa(e)}return o[e,e in t?s(t[e],i):Qa(i)]);for(const e of Object.keys(t))delete t[e];for(const[e,s]of i)t[e]=s;return t}return Qa(e)};return s(t,e)}const Tn=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Rn=(t,e,s)=>Math.min(s,Math.max(e,t)),zn=t=>bt({spaces:[t]})[0],Fn=(t,e,s)=>{const i=s>0?s:1,o=t=>`${(t[0]/i).toFixed(12)},${(t[1]/i).toFixed(12)}`,a=o(t),n=o(e);return a0?n:1,l=Math.max(i*r*.02,1e-9),h=[];for(const e of t||[])for(const t of N(e)||[])h.push([t[0],t[1]]);const c=[];for(const t of s||[])Array.isArray(t)&&t.length>=4&&t.slice(0,4).every(Number.isFinite)&&c.push([t[0],t[1]],[t[2],t[3]]);const d=(t,e)=>e.some(e=>Math.hypot(t[0]-e[0],t[1]-e[1])<=2*l),p=new Map;for(const n of t||[]){if(!n?.id)continue;const u=vt(t,n.id,e,s,i,o,a,r);if(u)for(let t=0;t0&&_>0&&n===g&&_!==n))continue;const m=u.poly[i],f=u.poly[(i+1)%u.poly.length],b=Math.hypot(f[0]-m[0],f[1]-m[1]);if(!(b>l&&b<.5*a-1e-9*a))continue;if(d(m,c)||d(f,c))continue;if(d(m,h)&&d(f,h))continue;const v=Fn(m,f,r),y=p.get(v);y?y.targets.add(n):p.set(v,{a:[m[0],m[1]],b:[f[0],f[1]],targets:new Set([n])})}}}let u=e.slice();const _=(t,e)=>Math.hypot(t[0]-e[0],t[1]-e[1])<=2*l,g=(t,e)=>{if(!Array.isArray(t.a)||!Array.isArray(t.b)||t.a.length<2||t.b.length<2)return!1;const s=[Number(t.a[0])*r,Number(t.a[1])*r],i=[Number(t.b[0])*r,Number(t.b[1])*r];return!![...s,...i].every(Number.isFinite)&&(_(s,e.a)&&_(i,e.b)||_(s,e.b)&&_(i,e.a))};for(const t of[...p.values()].filter(t=>1===t.targets.size).sort((t,e)=>Fn(t.a,t.b,r).localeCompare(Fn(e.a,e.b,r)))){const e=[...t.targets][0],s=u.filter(e=>g(e,t));if(new Set(s.map(t=>t.cm)).size>1)continue;let o=!1;u=u.map(s=>g(s,t)?(o=!0,s.cm===e?s:{...s,cm:e}):s),o||(u=j(u,t.a,t.b,e,i,r))}return u}const An=t=>{const e=[];for(const s of t||[]){const t=N(s);if(t?.length)for(let s=0;s"string"==typeof t?.id?t.id:"").filter(Boolean),c=new Set(h),d=new Map;for(const t of h){const e=Ja("space",t);e.layers>0&&Va("space",e.root)&&Za(d,e.root,t)}const p=new Map,u=new Map,_=new Map,g=new Map;for(const t of r){const e="string"==typeof t?.id?t.id:"";if(!e)continue;const s=new Map;for(const i of Array.isArray(t.rooms)?t.rooms:[]){const t="string"==typeof i?.id?i.id:"";if(!t)continue;const o=Ja("room",t);o.layers>0&&Va("room",o.root)&&Za(s,o.root,t),u.has(t)||u.set(t,e),_.has(t)||_.set(t,String(i.name||""));const a="string"==typeof i.area?i.area:"";if(a){const s=g.get(a)||[];s.push({spaceId:e,roomId:t}),g.set(a,s)}}p.set(e,s)}const m=new Set(u.keys()),f=new Map,b=new Map;for(const t of l)"string"==typeof t?.id&&t.id&&(!0===t.removed?b.set(t.id,t):f.set(t.id,t));const v={spaceRefsRemapped:0,roomRefsRemapped:0,positionsRemapped:0,markersDetached:0,positionsUnresolved:0,nestedRefsUnresolved:0,deadSpaceIds:[],orphanRoomLabelsRemoved:0,orphanDevicePositionsRemoved:0,orphanGroupPositionsRemoved:0,liveMissingPositionsRemoved:0,removedPositions:[],liveMissingPositions:[],unverifiedPositions:[]},y=new Set,$=t=>c.has(t)?null:(()=>{const e=Ja("space",t).root;if(!Va("space",e))return null;const s=d.get(e)||[];return 1===s.length?s[0]:null})(),w=(t,e)=>{const s=Ja("room",t).root;if(!Va("room",s))return null;const i=p.get(e)?.get(s)||[];return 1===i.length?i[0]:null},k=t=>{const e=s.effectiveAreaByMarker?.[t]||"",i=e&&g.get(e)||[];return 1===i.length?i[0]:null},x=(t,e,s)=>{if("string"==typeof t.room_id&&t.room_id&&!m.has(t.room_id)){const i=e?w(t.room_id,e):null;i?(t.room_id=i,v.roomRefsRemapped++):s?(t.room_id=s.roomId,v.roomRefsRemapped++):!0!==t.removed&&delete t.room_id}const i=t.vacuum?.segment_map;if(i&&"object"==typeof i&&!Array.isArray(i))for(const t of Object.keys(i)){const s=i[t];if("string"!=typeof s||!s||m.has(s))continue;const o=e?w(s,e):null;o?(i[t]=o,v.roomRefsRemapped++):v.nestedRefsUnresolved++}};for(const t of l){const e="string"==typeof t?.id?t.id:"";if(!e)continue;const s="string"==typeof t.space?t.space:"",i=s&&!c.has(s),a=o[e],n="string"==typeof a?.s?a.s:"",r=n&&!c.has(n),l=!0===t.removed;let h=s&&c.has(s)?s:null,d=null,p=!1;if(i){const i=$(s);i?(t.space=i,h=i,p=!0,v.spaceRefsRemapped++):l||"virtual"===t.binding?l||(delete t.space,h=null,v.markersDetached++):(d=k(e),d?(t.space=d.spaceId,h=d.spaceId,v.spaceRefsRemapped++):(delete t.space,h=null,v.markersDetached++))}l&&!p||x(t,h,d),r&&p&&n===s&&h&&(o[e]={...a,s:h},v.positionsRemapped++,y.add(e))}for(const t of Object.keys(o)){if(y.has(t))continue;const e=o[t],s="string"==typeof e?.s?e.s:"";if(!s||c.has(s))continue;const i=$(s);if(i){if(t.startsWith("rl_")){const s=t.slice(3),a=w(s,i);if(a){const s=`rl_${a}`;Ka(o,s)||(o[s]={...e,s:i}),delete o[t],v.roomRefsRemapped++,v.positionsRemapped++;continue}}o[t]={...e,s:i},v.positionsRemapped++}}const M=s.ownerRoster,C=!0===M?.authoritative,S=new Set(M?.deviceIds||[]),P=new Set(M?.entityIds||[]),D=new Set(Array.isArray(i.settings?.known_devices)?i.settings.known_devices.filter(t=>"string"==typeof t):[]),I=(t,e="")=>{const s=String(M?.names?.[t]||e||"").trim();return s&&s!==t?s:""},L=(t,e,s,i="",o)=>({id:t,spaceId:e,kind:s,name:I(t,i),...o?{reason:o}:{}}),T=t=>{"room_label"===t?v.orphanRoomLabelsRemoved++:"group"===t?v.orphanGroupPositionsRemoved++:v.orphanDevicePositionsRemoved++},R=new Set;for(const[t,e]of Object.entries(o)){const i="string"==typeof e?.s?e.s:"";if(!i||c.has(i))continue;let a,n;const r=f.get(t),l=b.get(t);if(r)a=L(t,i,"device",String(r.name||"")),n="live";else if(l)a=L(t,i,"device",String(l.name||"")),n="absent";else if(t.startsWith("rl_")){const e=t.slice(3);a=L(t,i,"room_label",_.get(e)||""),n=m.has(e)?"live":"absent"}else if(t.startsWith("lg_")){const e=t.slice(3);a=L(t,i,"group"),n=P.has(e)?"live":C?"absent":"unverified","unverified"===n&&(a.reason="registry_unavailable")}else S.has(t)?(a=L(t,i,"device"),n="live"):D.has(t)?(a=L(t,i,"device"),n=C?"absent":"unverified","unverified"===n&&(a.reason="registry_unavailable")):(a=L(t,i,"unknown","","unknown_owner"),n="unverified");if("absent"!==n){if("live"===n){if(v.liveMissingPositions.push(a),!0===s.removeLiveMissingPositions){delete o[t],v.liveMissingPositionsRemoved++,T(a.kind),v.removedPositions.push(a);continue}}else v.unverifiedPositions.push(a);v.positionsUnresolved++,R.add(i)}else delete o[t],T(a.kind),v.removedPositions.push(a)}return v.deadSpaceIds=[...R].sort((t,e)=>t.localeCompare(e)),{config:i,layout:o,report:v,changed:JSON.stringify(i)!==a||JSON.stringify(o)!==n}}(t,e,s),n=a.config,r=ot(n,a.layout);J(n),at(a.layout);const l=JSON.stringify(t||{}),h=JSON.stringify(e||{}),c=Number.isInteger(Number(n.model_version))?Number(n.model_version):0,d=(t=>{let e=0,s=0,i=0;for(const s of t.markers||[]){if("ripple"===s.display&&(s.display="icon_ripple",e++),Array.isArray(s.controls)){const t="string"==typeof s.binding&&s.binding.startsWith("entity:")?s.binding.slice(7):"",i=t?s.controls.filter(e=>e!==t):s.controls;JSON.stringify(i)!==JSON.stringify(s.controls)&&(s.controls=i.length?i:null,e++)}const t=s.vacuum;t&&Tn(t,"trail")&&(["never","cleaning","always"].includes(t.trail_mode)||(t.trail_mode=!1===t.trail?"never":"cleaning"),delete t.trail,e++)}for(const o of t.spaces||[]){const t=o.settings;"glow"===t?.fill_mode&&("boolean"!=typeof t.glow_enabled&&(t.glow_enabled=!0),t.fill_mode="none",e++,s++);for(const t of o.rooms||[]){const s=t.settings;"glow"===s?.fill_mode&&("boolean"!=typeof s.glow&&(s.glow=!0),delete s.fill_mode,e++,i++)}if(Tn(o,"segments")&&(delete o.segments,e++),Tn(o,"plan_scale")){const t=Number(o.plan_scale);Number.isFinite(t)&&t>=pt&&t<=ut&&(Tn(o,"plan_scale_x")||(o.plan_scale_x=t),Tn(o,"plan_scale_y")||(o.plan_scale_y=t),delete o.plan_scale,e++)}const a=Number(o.cell_cm);Tn(o,"cell_cm")&&(!Number.isFinite(a)||a<.1||a>1e3)&&(o.cell_cm=Number.isFinite(a)&&a>0?Rn(a,.1,1e3):5,e++);const n=Number(o.cell_cm),r=Number.isFinite(n)&&n>0?n:5;for(const t of o.wall_columns||[])if("circle"===t.shape)Tn(t,"angle")&&(delete t.angle,e++);else if("square"===t.shape&&Tn(t,"angle")){const s=((Number(t.angle)||0)%90+90)%90;t.angle!==s&&(t.angle=s,e++)}for(const t of o.decor||[]){if(Tn(t,"width")){const s=Number(t.width);(Tn(t,"width_cm")||Number.isFinite(s))&&(Tn(t,"width_cm")||(t.width_cm=Number(Rn(s/ct*r,.1,100).toFixed(6))),delete t.width,e++)}if("rect"!==t?.kind&&"ellipse"!==t?.kind||!0!==t.fill||(Tn(t,"fill_color")||(t.fill_color=t.color||"#607d8b",e++),Tn(t,"fill_opacity")||(t.fill_opacity=.25,e++)),"text"!==t?.kind)continue;void 0===t.size_cm?(t.size_cm=Number(Rn(_t*gt(t)/ct*r,.1,2e3).toFixed(6)),delete t.scale,delete t.size,e++):(Tn(t,"scale")||Tn(t,"size"))&&(delete t.scale,delete t.size,e++);let s=String(t.text??"");const i=[...s.matchAll(/\{([^{}\r\n]+)\}/g)].some(t=>!!mt(t[1]));if(!(Tn(t,"entity")||Tn(t,"attr")||Tn(t,"unit")))continue;const o=String(t.unit??"").trim(),a="state"===String(t.attr??"").trim().toLowerCase()?null:t.attr,n=i||o?"":ft(t.entity,a);if(i||n){if(n){const e=s.indexOf("{}");s=e>=0?s.slice(0,e)+n+s.slice(e+2):`${s}${s?" ":""}${n}`,t.text=s}delete t.entity,delete t.attr,delete t.unit,e++}}}return{total:e,glowSpaces:s,glowRooms:i}})(n);let p=d.total,u=0,_=0,g=0;if(c<10)for(const t of Array.isArray(n.spaces)?n.spaces:[]){const e=Sn(t);_+=e.drafts,g+=e.segments}const m=(f=n.spaces||[],JSON.parse(JSON.stringify(f)));var f;const b=wa(n.spaces||[],a.layout);let v=0,y=0,$=0,w="";const k=b.spaces.map(t=>{const e=nt(t);v+=e.report.wallsStraightened,y+=e.report.wallsStraightenSkipped;const s=Number(t?.cell_cm)>0?Number(t.cell_cm):5,i=e.report.maxStraightenShift/z*s;return i>$&&($=i,w=String(t?.id||"")),e.space}),x=v?wa(k,b.layout):{...b,spaces:k};n.spaces=x.spaces;const M=v?{...b.report,moved:b.report.moved+x.report.moved,coordsCanonicalized:b.report.coordsCanonicalized+x.report.coordsCanonicalized,maxShift:Math.max(b.report.maxShift,x.report.maxShift),maxShiftCm:Math.max(b.report.maxShiftCm,x.report.maxShiftCm),maxSpace:x.report.maxShiftCm>b.report.maxShiftCm?x.report.maxSpace:b.report.maxSpace,rotated:b.report.rotated+x.report.rotated}:{...b.report};let C=0,S=0,P=0,D=0,I=0,L=0,T=0;for(let t=0;t0===Number(t.cm)),walls:e.walls||[]}),a=zn(e),r=zn(s);if(!a||!r)continue;const l=An(a.rooms),h=An(r.rooms),c=.02*ct,d=(e.wall_segments||[]).filter(t=>0===Number(t.cm)).map(t=>({...t,key:Z(t.a,t.b,z),cm:0})),p=new Set(d.map(t=>t.key)),u=rt(e,a.rooms,lt,c);S+=u.length;for(const t of u){const e=[t[0]/lt,t[1]/lt],s=[t[2]/lt,t[3]/lt],i=Z(e,s,z);p.has(i)||(p.add(i),d.push({key:i,a:e,b:s,cm:0}))}const _=d.length,g=ht(d,l,h,z,lt),f=(t,e,s)=>{const i=s[0]-e[0],o=s[1]-e[1],a=i*i+o*o;if(!(a>0))return Math.hypot(t[0]-e[0],t[1]-e[1]);const n=Math.max(0,Math.min(1,((t[0]-e[0])*i+(t[1]-e[1])*o)/a));return Math.hypot(t[0]-(e[0]+i*n),t[1]-(e[1]+o*n))},b=g.filter(t=>{if(!Array.isArray(t.a)||!Array.isArray(t.b))return!1;const e=t.a.map(t=>t*lt),s=t.b.map(t=>t*lt);return h.some(([t,i])=>f(e,t,i)<=4*c&&f(s,t,i)<=4*c)});P+=Math.max(0,_-b.length);const v=(s.wall_segments||[]).filter(t=>Number(t.cm)>0);s.wall_segments=[...v,...b.map(({key:t,...e})=>e)];const y=b.map(t=>[t.a[0]*lt,t.a[1]*lt,t.b[0]*lt,t.b[1]*lt]),$=Array.isArray(e.walls)?e.walls.length:0;let w=ht(e.walls,l,h,z,lt);w=Nn(r.rooms,w,y,z,Number(s.cell_cm)>0?Number(s.cell_cm):5,ct,lt),w=G(r.rooms,w,y,z,Number(s.cell_cm)>0?Number(s.cell_cm):5,ct,lt),w=dt(w,s.rooms||[],z,1,y.map(t=>[t[0]/lt,t[1]/lt,t[2]/lt,t[3]/lt])),C+=Math.max(0,$-w.length),w.length?s.walls=w:delete s.walls;const k=Da(s.partitions||[],{pitch:z,geometry:La(s)});k.merged&&(D+=k.merged,s.partitions=k.partitions,Ia(s.openings,s.partitions,k.openingMoves,{coordScale:lt,cellCm:Number(s.cell_cm)>0?Number(s.cell_cm):5,gridPitch:ct}));const x=zn(s);if(x){const t=o(s,x,s.walls||[],y,{pitch:z,cellCm:Number(s.cell_cm)>0?Number(s.cell_cm):5,gridPitch:ct,coordScale:lt});t.partitionsReconciled&&(I+=t.partitionsReconciled,L+=t.openingsRehosted,t.partitions.length?s.partitions=t.partitions:delete s.partitions,t.openings.length?s.openings=t.openings:delete s.openings,t.walls.length?s.walls=t.walls:delete s.walls)}JSON.stringify({zero:(s.wall_segments||[]).filter(t=>0===Number(t.cm)),walls:s.walls||[]})!==i&&T++}if(c<=10){const t=function(t){const e=Dn(t);return Ln(t,e.config),{...e,config:t}}(n);u+=t.migratedSegments,_+=t.migratedDrafts,g+=t.migratedDraftSegments}const R=J(n),F=at(x.layout),N=JSON.stringify(R)!==l||JSON.stringify(F)!==h;c<10&&N&&(R.model_version=10);const A=JSON.stringify(R)!==l||JSON.stringify(F)!==h,E=Number.isInteger(Number(R.model_version))?Number(R.model_version):c,O=A?M:{...M,moved:0,coordsCanonicalized:0,maxShift:0,maxShiftCm:0,maxSpace:"",rotated:0},H=A?a.report:{...a.report,spaceRefsRemapped:0,roomRefsRemapped:0,positionsRemapped:0,markersDetached:0,orphanRoomLabelsRemoved:0,orphanDevicePositionsRemoved:0,orphanGroupPositionsRemoved:0,liveMissingPositionsRemoved:0};return{config:R,layout:F,report:{...O,modelFrom:c,modelTo:E,migrated:A?p:0,glowSpacesMigrated:A?d.glowSpaces:0,glowRoomsMigrated:A?d.glowRooms:0,canonicalized:A?T:0,wallSegmentsMigrated:A?u:0,roomDraftsMigrated:A?_:0,roomDraftSegmentsMigrated:A?g:0,legacyZeroWallsMigrated:A?S:0,wallsMerged:A?C:0,spansMerged:A?P:0,partitionsMerged:A?D:0,partitionsReconciled:A?I:0,openingsRehosted:A?L:0,wallsStraightened:A?v:0,wallsStraightenSkipped:y,maxStraightenShiftCm:A?$:0,maxStraightenSpace:A?w:"",latticeCoordinatesCanonicalized:A?r.canonicalized:0,latticeCoordinatesFar:A?r.far:0,latticeMaxShift:A?r.maxShift:0,latticeMaxShiftCm:A?r.maxShiftCm:0,latticeSpaces:A?r.spaces:[],...H},changed:A}}async function On(t,e,s){t._saveConfigDebounced.pending()&&t._saveConfigDebounced.flush(),await t._writeChain;const i=await t.hass.callWS({type:"houseplan/plan/optimize",config:e,layout:s,expected_config_rev:t._cfgRev,expected_layout_rev:t._layoutRev});t._adoption.acceptPairWrite(e,s,i),t._geometryHistory.clear(),t._cancelDeviceDrag(),t._devicePositionHistory.clear(),t._canOptimizeUndo=!0===i.can_undo,t._undoKind=!0===i.can_undo?"optimize":null,t._dirtyPos.clear(),t._sentPos.clear(),t._cfgEpoch++,t._modelCache=null,t._frame=null,t._regSignature="",t._maybeRebuildDevices(),t._cacheSnapshot(),t.requestUpdate()}const Hn=Object.freeze({spaces:50,partitions:2e3,openings:500,decor:1e3,columns:500});class Bn extends Error{constructor(t){super(t),this.code=t,this.name="SpaceCopyError"}}const Wn=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),jn=t=>void 0===t?t:JSON.parse(JSON.stringify(t)),Gn=t=>null===t||"object"!=typeof t||Array.isArray(t)?null:t;function qn(t,e=!1){if(void 0===t&&!e)return[];if(!Array.isArray(t))throw new Bn("source_invalid");return t.map(t=>{const e=Gn(t);if(!e||"string"!=typeof e.id||!e.id)throw new Bn("source_invalid");return e})}const Un=t=>Array.isArray(t)&&2===t.length&&t.every(t=>Number.isFinite(t));function Kn(t,e,s){const i=String(t??"").trim()||s,o=new Set(e.map(t=>{const e=Gn(t);return String(e?.title??"").trim()}));let a=2;for(;o.has(`${i} (${a})`);)a++;return`${i} (${a})`}const Vn=["settings","zero_wall_style","cell_cm","view_box","plan_url","plan_aspect","plan_x","plan_y","plan_scale","plan_scale_x","plan_scale_y","plan_angle"];const Jn={source_missing:"space.copy_error_source_missing",source_invalid:"space.copy_error_source_invalid",spaces_limit:"space.copy_error_spaces_limit",partitions_limit:"space.copy_error_partitions_limit",openings_limit:"space.copy_error_openings_limit",decor_limit:"space.copy_error_decor_limit",columns_limit:"space.copy_error_columns_limit",opening_host_missing:"space.copy_error_opening_host",opening_host_unknown:"space.copy_error_opening_host",geometry_unsafe:"space.copy_error_geometry"};let Zn=0;function Yn(t,e,s){const i=t._spaceDialog;return!(!i?.copy||i.copy.token!==e)&&(t._spaceDialog={...i,busy:s,copy:{...i.copy,busy:s}},!0)}function Xn(t){t._cfgEpoch++,t._modelCache=null,t._frame=null,t._regSignature="",t._maybeRebuildDevices(),t.requestUpdate()}async function Qn(t,e){const s=t._spaceDialog;if(!s?.copy||"edit"!==s.mode||s.busy||s.copy.busy||!s.copy.title.trim()||!s.spaceId||!t._serverCfg)return;const i=++Zn,o=s.spaceId,a=s.copy.title.trim();t._spaceDialog={...s,busy:!0,copy:{...s.copy,title:a,busy:!0,token:i}};let n=!1;try{if(t._saveConfigDebounced.pending()&&t._saveConfigDebounced.flush(),await t._writeChain,!Yn(t,i,!0)||!t._serverCfg)return;const s=t._cfgRev,r=t._layoutRev,l=yt(t._serverCfg),h=yt(t._layout);let c;try{c=(e.optimize??En)(t._serverCfg,t._layout,e.optimizeReferenceContext())}catch(s){return Yn(t,i,!1),void e.showWallModelMigrationBlocked(s)}if(c.changed){const d=t._checkOptimizeGeometry(c.config);if(e.reportPreflightFailure(d,c.config),!d.ok)return Yn(t,i,!1),void t._showToast(t._t("space.copy_error_optimize_geometry"));const p=await t._confirmDanger({key:`copy-space:${o}`,kind:"warning",title:t._t("space.copy_optimize_title"),message:t._t("space.copy_optimize_body",{name:a}),objectName:a,confirmLabel:t._t("space.copy_optimize_confirm"),cancelLabel:t._t("btn.cancel"),icon:"mdi:broom"});if(!Yn(t,i,p))return;if(!p)return;if(t._cfgRev!==s||t._layoutRev!==r||!t._serverCfg||yt(t._serverCfg)!==l||yt(t._layout)!==h)return Yn(t,i,!1),void t._showToast(t._t("space.copy_error_changed"));e.clearGeometryGesture(),await On(t,c.config,c.layout),n=!0}if(!Yn(t,i,!0)||!t._serverCfg)return;const d=t._serverCfg,p=function(t,e,s,i){const o=t.spaces;if(!s.trim())throw new Bn("source_invalid");if(o.length>=Hn.spaces)throw new Bn("spaces_limit");const a=o.findIndex(t=>t.id===e);if(a<0)throw new Bn("source_missing");const n=o[a];if(!Array.isArray(n.view_box))throw new Bn("source_invalid");const r=qn(n.wall_segments,!0),l=qn(n.partitions),h=qn(n.openings),c=qn(n.decor),d=qn(n.wall_columns);if(r.length+l.length>Hn.partitions)throw new Bn("partitions_limit");if(h.length>Hn.openings)throw new Bn("openings_limit");if(c.length>Hn.decor)throw new Bn("decor_limit");if(d.length>Hn.columns)throw new Bn("columns_limit");let p=0;const u=t=>`${t}${i}${(p++).toString(36)}`,_=new Map,g=new Map,m=[];for(const t of r){if(_.has(t.id)||!Un(t.a)||!Un(t.b)||"number"!=typeof t.cm||!Number.isFinite(t.cm))throw new Bn("source_invalid");const e=u("cw");_.set(t.id,e),m.push({id:e,a:jn(t.a),b:jn(t.b),cm:t.cm})}for(const t of l){if(g.has(t.id)||!Un(t.a)||!Un(t.b)||"number"!=typeof t.cm||!Number.isFinite(t.cm))throw new Bn("source_invalid");const e=u("cp");g.set(t.id,e),m.push({id:e,a:jn(t.a),b:jn(t.b),cm:t.cm})}const f=h.map(t=>{const e=Gn(t.host);if(!e||"string"!=typeof e.id||"string"!=typeof e.kind)throw new Bn("opening_host_missing");const s="wall"===e.kind?_.get(e.id):"partition"===e.kind?g.get(e.id):void 0;if(!s)throw new Bn("opening_host_unknown");const i={...jn(t),id:u("co"),host:{...jn(e),kind:"partition",id:s}};return delete i.contact,delete i.lock,i}),b=c.map(t=>({...jn(t),id:u("cd")})),v=d.map(t=>({...jn(t),id:u("cc")})),y=`s${i}`;if(o.some(t=>t.id===y))throw new Bn("source_invalid");const $={id:y,title:s.trim(),rooms:[],wall_segments:[],view_box:jn(n.view_box)};for(const t of Vn)"view_box"!==t&&Wn(n,t)&&($[t]=jn(n[t]));m.length&&($.partitions=m),f.length&&($.openings=f),b.length&&($.decor=b),v.length&&($.wall_columns=v);const w=jn(t);return w.spaces.splice(a+1,0,$),{config:w,space:$,sourceIndex:a}}(d,o,a,e.newSeed?.()??function(t=Date.now(),e=Math.random()){const s=Math.floor(16777216*Math.max(0,Math.min(.999999999,e))).toString(36).padStart(5,"0");return`${Math.max(0,Math.floor(t)).toString(36)}${s}`}());let u=!1;try{u=t._checkSpacePhysicalGeometry(p.config,p.space.id).ok}catch{u=!1}if(!u||t._junctionLimitViolations(p.config,p.space.id).length)throw new Bn("geometry_unsafe");const _=t._adoption.beginOptimistic(d,p.config);t._adoption.stageLocalConfig(p.config),Xn(t);try{await e.saveConfigNow(_)}catch(e){throw t._rollbackOptimistic(_)&&Xn(t),"conflict"!==e?.code&&await t._reloadConfigOnly(!0),e}t._canOptimizeUndo=!1,t._undoKind=null,e.clearGeometryGesture(),t._selId=null,t._physicalSel=null,t._spaceDialog=null,t._commitSpace(p.space.id,!0),e.setMode("plan"),t._tool="draw",t._path=[],t._cursorPt=null,t._activeWallChainId=null,t._activeWallChainPartitionIds=[],t._primeDrawWallField(),t._saveNav(),t.requestUpdate(),t._showToast(t._t("toast.space_copied",{name:a}))}catch(e){"conflict"===e?.code&&await Promise.all([t._reloadConfigOnly(!0),t._reloadLayoutOnly()]),Yn(t,i,!1),function(t,e){if(e instanceof Bn)return void t._showToast(t._t(Jn[e.code]));const s=e?.code;"wall_model_client_outdated"!==s?t._showToast(t._t("toast.error",{err:t._errText(e)})):t._showToast(t._t("toast.wall_model_client_outdated"))}(t,e),n&&t.requestUpdate()}}const tr=1e3;function er(){const t=this.host._spaceDialog;if(t.copy)return function(t,e){const s=t._spaceDialog.copy,i=()=>function(t){const e=t._spaceDialog;!e?.copy||e.busy||e.copy.busy||(t._spaceDialog={...e,copy:void 0})}(t);return p``}const ma=1e-6*z,fa=6*z;function ba(t){return Number.isFinite(t)?Math.round(t/z)*z:t}const va=(t,e,s,i)=>Math.hypot(s-t,i-e),ya=(t,e,s,i,o,a,n,r)=>Math.hypot(Math.max(Math.abs(o-t),Math.abs(o+n-(t+s))),Math.max(Math.abs(a-e),Math.abs(a+r-(e+i)))),$a=(t,e,s,i,o,a,n)=>{const r=Math.max(Number(i)||0,0)/2,l=Math.PI/180,h=Math.cos(s*l)*r,c=Math.sin(s*l)*r,d=Math.cos(n*l)*r,p=Math.sin(n*l)*r,u=Math.max(va(t+h,e+c,o+d,a+p),va(t-h,e-c,o-d,a-p)),_=Math.max(va(t+h,e+c,o-d,a-p),va(t-h,e-c,o+d,a+p));return Math.min(u,_)},wa=t=>{const e=Number(t?.cell_cm);return e>0?e:5};function ka(t,e){const s=JSON.parse(JSON.stringify(t||[])),i=JSON.parse(JSON.stringify(e||{}));let o=0,a=0,n=0,r=0,l="",h=0,c=0;const d=(t,e)=>{Number.isFinite(t)&&Number.isFinite(e)&&t!==e&&Math.abs(e-t)<=ma&&c++},p=(t,e)=>{d(t[0],e[0]),d(t[1],e[1])},u={};let _=5;for(const t of s){const e=wa(t);null!=t?.id&&(u[String(t.id)]=e),e>_&&(_=e)}const g=(t,e,s,i=!1)=>{if(!(t>ma||i))return;o++,t>n&&(n=t);const a=t*F*e;a>r&&(r=a,l=s)};for(const t of s){const e=wa(t),s=null!=t?.id?String(t.id):"";for(const i of t.rooms||[]){a++;let t=0;if(i.poly?.length)i.poly=i.poly.map(e=>{const s=[ba(e[0]),ba(e[1])];return t=Math.max(t,va(e[0],e[1],s[0],s[1])),p(e,s),s});else if(null!=i.x&&null!=i.y){const e=i.x,s=i.y,o=i.w||0,a=i.h||0,n=ba(e+o),r=ba(s+a),l=ba(e),h=ba(s),c=Math.max(z,n-l),p=Math.max(z,r-h);t=ya(e,s,o,a,l,h,c,p),i.x=l,i.y=h,i.w=c,i.h=p,d(e,l),d(s,h),d(e+o,l+c),d(s+a,h+p)}g(t,e,s)}for(const i of t.partitions||[]){a++;const o=[i.a[0],i.a[1]],n=[i.b[0],i.b[1]],r=[ba(o[0]),ba(o[1])],l=[ba(n[0]),ba(n[1])];let h=Math.max(va(o[0],o[1],r[0],r[1]),va(n[0],n[1],l[0],l[1]));const c=va(r[0],r[1],l[0],l[1]),d=(t.openings||[]).filter(t=>"partition"===t.host?.kind&&t.host.id===i.id).every(t=>{const e=Number(t.length),s=Number(t.host.t),i=s*c;return Number.isFinite(e)&&e>0&&Number.isFinite(s)&&s>=0&&s<=1&&i-e/2>=-ma&&i+e/2<=c+ma});c>ma&&d?(i.a=r,i.b=l,p(o,r),p(n,l)):h=0,g(h,e,s)}for(const i of t.wall_columns||[]){a++;const t=[i.center[0],i.center[1]],o=[ba(t[0]),ba(t[1])],n=va(t[0],t[1],o[0],o[1]);i.center=o,p(t,o),g(n,e,s)}for(const i of t.decor||[]){if("furniture"===i.kind||"image"===i.kind)continue;a++;let t=0;if("line"===i.kind){const e=[i.x1,i.y1],s=[i.x2,i.y2],o=[ba(e[0]),ba(e[1])],a=[ba(s[0]),ba(s[1])];t=Math.max(va(e[0],e[1],o[0],o[1]),va(s[0],s[1],a[0],a[1])),i.x1=o[0],i.y1=o[1],i.x2=a[0],i.y2=a[1],p(e,o),p(s,a)}else{const e=i.x,s=i.y,o=i.w,a=i.h,n=ba(e),r=ba(s);if(null!=i.w&&null!=i.h){const l=ba(e+o),h=ba(s+a),c=Math.max(z,l-n),p=Math.max(z,h-r);t=ya(e,s,o,a,n,r,c,p),i.w=c,i.h=p,d(e+o,n+c),d(s+a,r+p)}else t=va(e,s,n,r);i.x=n,i.y=r,d(e,n),d(s,r)}g(t,e,s)}for(const i of t.openings||[]){if(a++,"partition"===i.host?.kind){const o=(t.partitions||[]).find(t=>t.id===i.host.id),a=Number(i.host.t);if(!o||!Number.isFinite(a)||a<0||a>1)continue;const n=o.b[0]-o.a[0],r=o.b[1]-o.a[1];if(Math.hypot(n,r)<=ma)continue;const l=o.a[0]+n*a,c=o.a[1]+r*a;let d=180*Math.atan2(r,n)/Math.PI;d>=90?d-=180:d<-90&&(d+=180);const p=Number(i.angle),u=!(Number.isFinite(p)&&p===d),_=$a(i.x,i.y,Number.isFinite(p)?p:d,Number(i.length)||0,l,c,d);i.x=l,i.y=c,i.angle=d,u&&h++,g(_,e,s,u);continue}const o=R([i.x,i.y],t.rooms||[],fa,{step:z,length:Number(i.length)||0});if(!o)continue;const n=Number(i.angle),r=!(Number.isFinite(n)&&n===o.angle),l=$a(i.x,i.y,Number.isFinite(n)?n:o.angle,Number(i.length)||0,o.x,o.y,o.angle);i.x=o.x,i.y=o.y,i.angle=o.angle,r&&h++,g(l,e,s,r)}}for(const[t,e]of Object.entries(i)){if(!e||"object"!=typeof e)continue;const s=e;if("number"!=typeof s.x||"number"!=typeof s.y)continue;a++;const o=ba(s.x),n=ba(s.y),r=va(s.x,s.y,o,n);i[t]={...s,x:o,y:n},d(s.x,o),d(s.y,n);const l="string"==typeof s.s?s.s:"";g(r,u[l]??_,l)}return{spaces:s,layout:i,report:{moved:o,coordsCanonicalized:c,total:a,maxShift:n,maxShiftCm:r,maxSpace:l,rotated:h},changed:o>0||c>0}}function xa(t,e){const s=e.base+t*e.span;return Math.min(1,Math.max(0,s))}const Ma=t=>Array.isArray(t)&&t.length>=2&&Number.isFinite(t[0])&&Number.isFinite(t[1]),Ca=(t,e)=>Math.hypot(t[0]-e[0],t[1]-e[1]);function Sa(t,e,s){const i=s[0]-e[0],o=s[1]-e[1],a=i*i+o*o;if(a<=0)return Ca(t,e);let n=((t[0]-e[0])*i+(t[1]-e[1])*o)/a;return n=Math.max(0,Math.min(1,n)),Math.hypot(t[0]-(e[0]+i*n),t[1]-(e[1]+o*n))}function Pa(t,e,s,i,o){for(const i of e)if(i&&!s.has(i.id)&&Ma(i.a)&&Ma(i.b)&&(Ca(t,i.a)<=o||Ca(t,i.b)<=o))return!0;for(const e of i?.roomPolygons||[])for(let s=0;s0&&r>0))return null;if(Math.abs(o[0]/n*(a[1]/r)-o[1]/n*(a[0]/r))>s)return null;for(const[s,o]of[[t.a,e.a],[t.a,e.b],[t.b,e.a],[t.b,e.b]])if(Ca(s,o)<=i)return[(s[0]+o[0])/2,(s[1]+o[1])/2];return null}function Ia(t,e){const s=.05*(Number(e.pitch)>0?Number(e.pitch):1),i=new Map;let o=(t||[]).filter(t=>!!t&&"string"==typeof t.id&&Ma(t.a)&&Ma(t.b));if(o.length<2)return{partitions:[...t||[]],merged:0,openingMoves:[]};const a=e.seedIds&&e.seedIds.length?new Set(e.seedIds):null;let n=0;for(let t=0;tCa(e,t.at)>s);let c=h[0]??r.a,d=h[h.length-1]??l.b;if(h.length<2&&(c=r.a,d=l.b),d[0]0?(d[0]-c[0])/u:0,g=u>0?(d[1]-c[1])/u:0,m=t=>u>0?((t[0]-c[0])*_+(t[1]-c[1])*g)/u:0;for(const t of[r,l]){const e=m(t.a),s=m(t.b)-e;for(const[o,a]of i)a.toId===t.id&&i.set(o,{fromId:a.fromId,toId:p.id,base:e+a.base*s,span:a.span*s});i.set(t.id,{fromId:t.id,toId:p.id,base:e,span:s})}a&&a.add(p.id),o=o.filter((e,s)=>s!==t.i&&s!==t.j),o.splice(t.i,0,p),n++}return{partitions:o,merged:n,openingMoves:[...i.values()]}}function La(t,e,s,i){if(!t?.length||!s.length)return 0;const o=new Map(s.map(t=>[t.fromId,t]));let a=0;for(const s of t){const t=s?.host;if(!t||"partition"!==t.kind)continue;const n=o.get(t.id);if(!n)continue;s.host={...t,id:n.toId,t:xa(t.t,n)},a++;const r=A(s,e,i.coordScale,i.cellCm,i.gridPitch).resolved;r&&Object.assign(s,E(s,r,i.coordScale))}return a}function Ta(t){return{roomPolygons:(t?.rooms||[]).map(t=>N(t)).filter(t=>!!t),columns:t?.wall_columns||[]}}const Ra=t=>!!t&&t.length>=2&&Number.isFinite(t[0])&&Number.isFinite(t[1]),za=(t,e)=>t[0]-e[0]||t[1]-e[1],Fa=(t,e,s,i)=>[t[0]+e*i,t[1]+s*i],Na=(t,e,s,i)=>(t[0]-e[0])*s+(t[1]-e[1])*i,Aa=(t,e,s,i,o)=>{const a=e[0]-t[0],n=e[1]-t[1],r=Math.hypot(a,n);if(!(r>o))return null;const l=a/r,h=n/r,c=e=>Math.abs((e[0]-t[0])*h-(e[1]-t[1])*l);if(c(s)>o||c(i)>o)return null;const d=Na(s,t,l,h),p=Na(i,t,l,h),u=Math.max(0,Math.min(d,p)),_=Math.min(r,Math.max(d,p));return _-u>o?{lo:u,hi:_}:null},Ea=(t,e,s)=>Math.min(t.hi,e.hi)-Math.max(t.lo,e.lo)>s,Oa=t=>{const e=new Set(["id","a","b","cm"]);return Object.keys(t||{}).every(t=>e.has(t))},Ha=(t,e,s,i)=>{const o=t.b[0]-t.a[0],a=t.b[1]-t.a[1],n=Math.hypot(o,a);if(!(n>i))return!0;const r=o/n,l=a/n,h=V(t.cm,s.cellCm,s.gridPitch)/2;return e.some(e=>{const o=e?.center;if(!Ra(o))return!0;const a=Na(o,t.a,r,l),c=Math.abs((o[0]-t.a[0])*l-(o[1]-t.a[1])*r),d=V(Number(e.cm),s.cellCm,s.gridPitch)*("square"===e.shape?Math.SQRT1_2:.5);return!(Number.isFinite(d)&&d>0)||a>=-d-i&&a<=n+d+i&&c<=h+d+i})},Ba=(t,e,s)=>{if(t.host){const i=A(t,e,s.coordScale,s.cellCm,s.gridPitch).resolved;return i?{center:i.center,angle:i.angle,length:i.length}:null}const i=Number(t.x)*s.coordScale,o=Number(t.y)*s.coordScale,a=Number(t.angle),n=Number(t.length)*s.coordScale;return[i,o,a,n].every(Number.isFinite)&&n>0?{center:[i,o],angle:a,length:n}:null},Wa=(t,e,s)=>{const i=t.angle*Math.PI/180,o=Math.cos(i),a=Math.sin(i),n=e.angle*Math.PI/180,r=Math.cos(n),l=Math.sin(n);if(Math.abs(o*l-a*r)>1e-6)return!1;const h=e.center[0]-t.center[0],c=e.center[1]-t.center[1];if(Math.abs(h*a-c*o)>s)return!1;const d=h*o+c*a;return Math.max(-t.length/2,d-e.length/2)({...t,a:[t.a[0]*e,t.a[1]*e],b:[t.b[0]*e,t.b[1]*e]}),Ga=(t,e,s,i)=>{const o=`~r-${(t=>{let e=2166136261;for(let s=0;s>>0;return e.toString(36)})(`${t}|${e[0].toFixed(9)},${e[1].toFixed(9)}|${s[0].toFixed(9)},${s[1].toFixed(9)}`)}`,a=`${t.slice(0,Math.max(1,64-o.length))}${o}`;let n=a;for(let t=2;i.has(n);t++){const e=`-${t}`;n=`${a.slice(0,64-e.length)}${e}`}return i.add(n),n},qa=(t,e)=>{const s=[];for(const i of t){const t=s[s.length-1];!(t&&Math.abs(t.hi-i.lo)<=e&&t.safe===i.safe)||i.safe&&t.signature!==i.signature?s.push({lo:i.lo,hi:i.hi,a:i.a,b:i.b,safe:i.safe,signature:i.signature,roomIds:i.roomIds,finalCm:i.finalCm}):(t.hi=i.hi,t.b=i.b)}return s};function Ua(t,e,s,i,o){const a=s||[],n=Array.isArray(t?.partitions)?t.partitions:[],r=Array.isArray(t?.openings)?t.openings:[],l={walls:a,partitions:n,openings:r,partitionsReconciled:0,openingsRehosted:0};if(!n.length)return l;const h=Math.max(2e-4*o.gridPitch,1e-9);let c=a,d=n,p=r,u=0,_=0;const g=o.partitionIds?new Set(o.partitionIds):null,m=new Map(e.partitions.map(t=>[t.id,t]));for(const t of[...n].sort((t,e)=>t.id.localeCompare(e.id))){if(g&&!g.has(t.id))continue;if(!d.some(e=>e.id===t.id))continue;if(!Oa(t))continue;const s=m.get(t.id);if(!(s&&Ra(s.a)&&Ra(s.b)&&Number.isFinite(s.cm)&&(o.allowCoincidentPartitions?!(s.cm<0):s.cm>0)))continue;const[a,n]=za(s.a,s.b)<=0?[[s.a[0],s.a[1]],[s.b[0],s.b[1]]]:[[s.b[0],s.b[1]],[s.a[0],s.a[1]]],r=n[0]-a[0],l=n[1]-a[1],f=Math.hypot(r,l);if(!(f>h))continue;const b=r/f,v=l/f,y=O(e.rooms,c,i,o.pitch,o.cellCm,o.gridPitch,o.coordScale),$=y.flatMap(t=>{if(t.open||"outer"!==t.kind&&"shared"!==t.kind)return[];const e=Aa(a,n,t.a,t.b,h);return e?[{interval:t,range:e}]:[]});if(!$.length)continue;const w=p.filter(t=>"partition"===t.host?.kind&&t.host.id===s.id).map(t=>({opening:t,resolved:A(t,e.partitions,o.coordScale,o.cellCm,o.gridPitch).resolved}));if(w.some(t=>!t.resolved))continue;const k=[0,f];for(const{range:t}of $)k.push(t.lo,t.hi);const x=k.slice(),M=new Map;for(const{opening:t,resolved:e}of w){const s=Na(e.center,a,b,v),i={lo:s-e.length/2,hi:s+e.length/2};M.set(t.id,i),x.push(Math.max(0,i.lo),Math.min(f,i.hi))}const C=[...new Set(x.filter(t=>Number.isFinite(t)&&t>=-h&&t<=f+h).map(t=>Math.max(0,Math.min(f,t)).toFixed(9)))].map(Number).sort((t,e)=>t-e),S=d.map(t=>ja(t,o.coordScale)).filter(t=>t.id!==s.id),P=[];for(let t=0;t+1h))continue;const r=Fa(a,b,v,i),l=Fa(a,b,v,n),c=$.filter(({range:t})=>t.lo<=i+h&&t.hi>=n-h).map(({interval:t})=>t),d=new Map;for(const t of c)d.set(t.roomId,t);const p=[...d.values()],u=new Set(p.map(t=>t.kind)),_=new Set(p.map(t=>o.allowCoincidentPartitions||t.cm>0?t.cm:H)),g=p[0]?.kind,m=[...d.keys()].sort(),f=1===u.size&&1===_.size&&("outer"===g&&1===m.length||"shared"===g&&2===m.length),y={id:s.id,a:r,b:l,cm:s.cm},w=S.some(t=>!!Aa(r,l,t.a,t.b,h)),k=f&&(o.allowCoincidentPartitions||!w)&&!Ha(y,e.wall_columns,o,h),x=f?o.allowCoincidentPartitions||p[0].cm>0?p[0].cm:H:0,M=f?Math.max(x,s.cm):s.cm;P.push({lo:i,hi:n,a:r,b:l,safe:k,signature:k?`${g}|${m.join(",")}|${M}`:"",roomIds:m,roomCm:x,finalCm:M})}if(!P.some(t=>t.safe))continue;const D=new Map;for(const{opening:t,resolved:e}of w){const i=M.get(t.id),a=k.some(t=>t>i.lo+h&&tEa(t,i,h)),r=new Set(n.filter(t=>t.safe).map(t=>t.signature));if(!a&&n.length>0&&n.every(t=>t.safe)&&1===r.size&&B(e,y,h)){D.set(t.id,{resolved:e,signature:[...r][0]});continue}const l=W(s,o.cellCm,o.gridPitch),c={lo:i.lo-l,hi:i.hi+l};for(const t of P)Ea(t,c,h)&&(t.safe=!1,t.signature="")}let I=!0;for(;I;){I=!1;for(const[t,e]of[...D.entries()]){const i=M.get(t),a=P.filter(t=>Ea(t,i,h));if(a.length>0&&a.every(t=>t.safe)&&a.every(t=>t.signature===e.signature))continue;D.delete(t);const n=W(s,o.cellCm,o.gridPitch),r={lo:i.lo-n,hi:i.hi+n};for(const t of P)Ea(t,r,h)&&(t.safe=!1,t.signature="");I=!0}}const L=qa(P,h),T=L.filter(t=>t.safe),R=L.filter(t=>!t.safe);if(!T.length)continue;if(d.length-1+R.length>2e3)continue;let z=c;for(const t of T){const[e,i]=za(s.a,s.b)<=0?[t.a,t.b]:[t.b,t.a];z=j(z,e,i,t.finalCm,o.pitch,o.coordScale)}if(z=G(e.rooms,z,i,o.pitch,o.cellCm,o.gridPitch,o.coordScale),z.length>500)continue;const F=new Set(d.map(t=>t.id));F.delete(s.id);const N=R.map((t,e)=>{const i=[t.a[0]/o.coordScale,t.a[1]/o.coordScale],a=[t.b[0]/o.coordScale,t.b[1]/o.coordScale],n=0===e?s.id:Ga(s.id,i,a,F);return F.add(n),{id:n,a:i,b:a,cm:s.cm}}),V=d.findIndex(t=>t.id===s.id),J=d.slice();J.splice(V,1,...N);const Z=J.map(t=>ja(t,o.coordScale)),Y=new Map;let X=!0;for(const{opening:t,resolved:e}of w){const s=D.get(t.id);if(s){const e=E(t,s.resolved,o.coordScale),{host:i,...a}=e;Y.set(t.id,a);continue}const i=M.get(t.id),a=N[R.findIndex(t=>t.lo<=i.lo+h&&t.hi>=i.hi-h)],n=a&&Z.find(t=>t.id===a.id);if(!a||!n){X=!1;break}const r=n.b[0]-n.a[0],l=n.b[1]-n.a[1],c=Math.hypot(r,l),d=Na(e.center,n.a,r/c,l/c),p={...E(t,e,o.coordScale),host:{kind:"partition",id:a.id,t:d/c}};if(!q(p,Z,o.coordScale,o.cellCm,o.gridPitch).resolved){X=!1;break}Y.set(t.id,p)}if(!X)continue;const Q=p.map(t=>Y.get(t.id)||t),tt=[...D.keys()].map(t=>Y.get(t)),et=tt.map(t=>Ba(t,Z,o));if(et.some(t=>!t))continue;let st=!1;for(let t=0;tt.id));for(const t of Q){if(it.has(t.id))continue;const e=Ba(t,Z,o);e&&et.some(t=>Wa(t,e,h))&&(st=!0)}if(st)continue;const ot=U(e.rooms,z,i,o.pitch,o.cellCm,o.gridPitch,o.coordScale);[...D.entries()].every(([t,e])=>{const s=Y.get(t),i=K(ot,{x:s.x*o.coordScale,y:s.y*o.coordScale,angle:s.angle,length:s.length*o.coordScale},!0),a=[i.negative,i.positive].filter(t=>!!t?.full),n=e.signature.split("|")[1].split(","),r=new Set(a.map(t=>t.roomId));return a.length===n.length&&r.size===n.length&&n.every(t=>r.has(t))})&&(c=z,d=J,p=Q,u+=T.length,_+=D.size)}return{walls:c,partitions:d,openings:p,partitionsReconciled:u,openingsRehosted:_}}const Ka=t=>JSON.parse(JSON.stringify(t)),Va=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Ja=(t,e)=>e.length>0&&e.length<=35&&("space"===t?/^[a-z0-9_-]+$/.test(e):/^[A-Za-z0-9_-]+$/.test(e));function Za(t,e){let s=String(e??"");const i=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=new RegExp(`^${i}_(.+)_([0-9a-f]{8})$`);let a=0;for(;a<16;a++){const t=o.exec(s);if(!t)return{root:s,layers:a,bounded:!1};s=t[1]}return{root:s,layers:a,bounded:o.test(s)}}const Ya=(t,e,s)=>{const i=t.get(e)||[];i.push(s),t.set(e,i)};const Xa=1e-9;class Qa extends Error{constructor(t,e=""){super(e?`${t}: ${e}`:t),this.reason=t,this.name="WallSegmentModelError"}}const tn=t=>JSON.parse(JSON.stringify(t)),en=t=>Array.isArray(t)&&t.length>=2&&Number.isFinite(Number(t[0]))&&Number.isFinite(Number(t[1])),sn=t=>[Number(t[0]),Number(t[1])],on=t=>`${Number(t[0]).toFixed(12)},${Number(t[1]).toFixed(12)}`,an=(t,e)=>{const s=on(t),i=on(e);return son(t)<=on(e)?[sn(t),sn(e)]:[sn(e),sn(t)],rn=(t,e)=>Math.hypot(e[0]-t[0],e[1]-t[1]),ln=(t,e=[])=>{const s=new Set,i=t=>{const e=Number(t);if(!Number.isFinite(e))return;const i=e/z;Math.abs(i-Math.round(i))>=tt&&s.add(e.toFixed(12))};for(const e of Array.isArray(t?.rooms)?t.rooms:[])for(const t of N(e)||[])i(t[0]),i(t[1]);for(const e of[t?.wall_segments,t?.walls])for(const t of Array.isArray(e)?e:[])i(t?.a?.[0]),i(t?.a?.[1]),i(t?.b?.[0]),i(t?.b?.[1]);for(const t of e)i(t?.[0]),i(t?.[1]);return s.size},hn=(t,e,s)=>{const i=s[0]-e[0],o=s[1]-e[1],a=i*i+o*o;return a>1e-18?((t[0]-e[0])*i+(t[1]-e[1])*o)/a:0},cn=(t,e,s)=>{const i=Math.max(0,Math.min(1,hn(t,e,s)));return Math.hypot(t[0]-(e[0]+(s[0]-e[0])*i),t[1]-(e[1]+(s[1]-e[1])*i))},dn=(t,e,s,i,o=1e-9)=>{const a=e[0]-t[0],n=e[1]-t[1],r=Math.hypot(a,n);if(r<=o)return 0;const l=e=>Math.abs((e[0]-t[0])*n-(e[1]-t[1])*a)/r;if(l(s)>o||l(i)>o)return 0;const h=hn(s,t,e),c=hn(i,t,e);return Math.max(0,Math.min(1,Math.max(h,c))-Math.max(0,Math.min(h,c)))*r},pn=t=>{const e=(new TextEncoder).encode(t),s=8*e.length,i=64*Math.ceil((e.length+9)/64),o=new Uint8Array(i);o.set(e),o[e.length]=128;const a=new DataView(o.buffer);a.setUint32(i-8,Math.floor(s/4294967296),!1),a.setUint32(i-4,s>>>0,!1);const n=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),r=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),l=new Uint32Array(64),h=(t,e)=>t>>>e|t<<32-e;for(let t=0;t>>3,o=h(s,17)^h(s,19)^s>>>10;l[t]=l[t-16]+i+l[t-7]+o>>>0}let[e,s,i,o,c,d,p,u]=r;for(let t=0;t<64;t++){const a=u+(h(c,6)^h(c,11)^h(c,25))+(c&d^~c&p)+n[t]+l[t]>>>0,r=e&s^e&i^s&i;u=p,p=d,d=c,c=o+a>>>0,o=i,i=s,s=e,e=a+((h(e,2)^h(e,13)^h(e,22))+r>>>0)>>>0}r[0]=r[0]+e>>>0,r[1]=r[1]+s>>>0,r[2]=r[2]+i>>>0,r[3]=r[3]+o>>>0,r[4]=r[4]+c>>>0,r[5]=r[5]+d>>>0,r[6]=r[6]+p>>>0,r[7]=r[7]+u>>>0}const c=new Uint8Array(32),d=new DataView(c.buffer);for(let t=0;t{const e="abcdefghijklmnopqrstuvwxyz234567";let s=0,i=0,o="";for(const a of t)for(i=i<<8|a,s+=8;s>=5;)o+=e[i>>>s-5&31],s-=5;return s&&(o+=e[i<<5-s&31]),o},_n=(t,e,s,i,o="")=>{const[a,n]=nn(e,s),r=`${t}|${on(a)}|${on(n)}|${[...i].sort().join(",")}${o}`;return`wall-${un(pn(r)).slice(0,20)}`};let gn=0;const mn=t=>{for(let e=0;e<1e3;e++){const e=globalThis.crypto?.randomUUID?.(),s=`wall-${e||un(pn(`${Date.now()}|${gn++}|${Math.random()}`)).slice(0,26)}`;if(!t.has(s))return s}throw new Qa("duplicate-id","id factory exhausted")},fn=t=>{const e=new Map;for(const s of Array.isArray(t?.wall_segments)?t.wall_segments:[])if(s&&"string"==typeof s.id&&en(s.a)&&en(s.b)){if(e.has(s.id))throw new Qa("duplicate-id",s.id);e.set(s.id,s)}return e},bn=(t,e,s)=>{const i=(s,i)=>{const o=t[0]-s[0],a=t[1]-s[1];return Math.abs(e[0]-i[0]-o)<=Xa&&Math.abs(e[1]-i[1]-a)<=Xa?[o,a]:null};return i(s.a,s.b)||i(s.b,s.a)},vn=(t,e)=>{const s=Array.isArray(t.rooms)?t.rooms:[],i=Y(t.open_spans).map(t=>[t.a[0],t.a[1],t.b[0],t.b[1]]),o=i.length?i:X(s,null,1,.04*z,!0),a=[];for(const t of s){const s=N(t),i=Array.isArray(t?.wall_ids)?t.wall_ids:[];if(s&&i.length===s.length)for(let t=0;t"partition"!==t.host?.kind&&[Number(t.x),Number(t.y)].every(Number.isFinite)&&Number.isFinite(Number(t.angle))&&Number(t.length)>0&&o.some(e=>cn([Number(t.x),Number(t.y)],[e[0],e[1]],[e[2],e[3]])<=.04*z)):[],l=r.map(t=>{const e=Number(t.angle)*Math.PI/180,s=[Math.cos(e),Math.sin(e)],i=Number(t.length)/2,o=[Number(t.x),Number(t.y)];return{a:[o[0]-s[0]*i,o[1]-s[1]*i],b:[o[0]+s[0]*i,o[1]+s[1]*i]}}),h=(t,e)=>r.some(s=>{const i=[Number(s.x),Number(s.y)];if(!et(t,e,Number(s.angle)))return!1;if(cn(i,t,e)>.02*z)return!1;const o=rn(t,e),a=hn(i,t,e)*o,n=Number(s.length)/2;return a+n>=-1e-9&&a-n<=o+Xa}),c=new Map,d=[];for(const i of s){const r=String(i?.id||""),p=N(i);if(!r||!p||p.length<3)throw new Qa("invalid-room",r);const u=Q(s,r,n,z,1,[...t.walls||[],...l]);if(!u||u.poly.length<3)throw new Qa("invalid-room",r);const _=Array.isArray(i.wall_ids)?i.wall_ids:[],g=_.length===p.length;let m=null,f=g;if(f)for(let t=0;tXa||Math.abs(i[1]-m[1])>Xa)){f=!1;break}m=i}const b=[];for(let t=0;t2)throw new Qa("third-owner",n);const d=g?_[u.parent[t]]:void 0;if("string"==typeof d&&d){const o=e.get(d);f||!o||dn(s,i,o.a,o.b)>Xa?l.preferredIds.add(d):l.positionalIds.add(d),l.preferredCarriers.set(d,{a:sn(p[u.parent[t]]),b:sn(p[(u.parent[t]+1)%p.length])})}const m=u.parent[t];l.parentKeys.add(Z(p[m],p[(m+1)%p.length],z));const v=[(s[0]+i[0])/2,(s[1]+i[1])/2],y=t=>t.some(t=>cn(v,[t[0],t[1]],[t[2],t[3]])<=.04*z);l.zeroWall||=y(a)||y(o)&&!h(s,i),b.push(n)}const v={...i};delete v.wall_ids,d.push({...v,poly:u.poly.map(t=>[t[0],t[1]]),wall_ids:b})}return{atoms:[...c.values()].sort((t,e)=>t.key.localeCompare(e.key)),rooms:d}},yn=(t,e,s,i,o)=>{const a=new Map([...s.values()].map(t=>[an(t.a,t.b),t])),n=(t=>{const e=new Map;for(const s of t)"wall"===s.host?.kind&&e.set(s.host.id,(e.get(s.host.id)||0)+1);return e})(t.openings||[]),r=new Map;for(const t of e){const e=o?.get(t.key);if(e){const i=s.get(e);if(!i)throw new Qa("duplicate-id",e);r.set(t,i);continue}if(t.preferredIds.size>1)throw new Qa("duplicate-id",[...t.preferredIds].sort().join(","));const i=[...t.preferredIds][0],l=i?s.get(i):void 0;if(l){r.set(t,l);continue}const h=i?t.preferredCarriers.get(i):void 0;if(i&&h){r.set(t,{id:i,a:h.a,b:h.b,cm:0});continue}const c=a.get(t.key);if(c){r.set(t,c);continue}const d=[...s.values()].filter(e=>dn(t.a,t.b,e.a,e.b)>Xa),p=[...new Map(d.map(t=>[t.id,t])).values()];if(p.sort((t,e)=>(n.get(e.id)||0)-(n.get(t.id)||0)||rn(e.a,e.b)-rn(t.a,t.b)||t.id.localeCompare(e.id)),p[0])r.set(t,p[0]);else if(1===t.positionalIds.size){const e=s.get([...t.positionalIds][0]);e&&r.set(t,e)}}const l=new Map;for(const[t,e]of r){const s=l.get(e.id)||[];s.push(t),l.set(e.id,s)}for(const[t,e]of l){const i=s.get(t)||r.get(e[0]);if(!i)throw new Qa("duplicate-id",t);const o=[(i.a[0]+i.b[0])/2,(i.a[1]+i.b[1])/2];e.sort((t,e)=>{const s=cn(o,t.a,t.b)<=Xa?0:1,a=cn(o,e.a,e.b)<=Xa?0:1;if(s!==a)return s-a;return(cn(i.a,t.a,t.b)<=Xa?0:1)-(cn(i.a,e.a,e.b)<=Xa?0:1)||t.key.localeCompare(e.key)}),e[0].id=t}const h=(t=>{const e=new Set;for(const s of[t.rooms,t.openings,t.decor,t.room_drafts,t.partitions,t.wall_columns])for(const t of Array.isArray(s)?s:[])"string"==typeof t?.id&&t.id&&e.add(t.id);for(const s of Array.isArray(t.room_drafts)?t.room_drafts:[])for(const t of Array.isArray(s?.segments)?s.segments:[])"string"==typeof t?.id&&t.id&&e.add(t.id);return e})(t);for(const t of e)if(t.id){if(h.has(t.id))throw new Qa("duplicate-id",t.id);h.add(t.id)}const c=e.filter(t=>!t.id);if(i){const e=c.map(e=>{const[s,i]=nn(e.a,e.b),o=`${String(t.id||"")}|${on(s)}|${on(i)}|${[...e.owners].sort().join(",")}`,a=un(pn(o));return{atom:e,seed:o,digest:a,base:`wall-${a.slice(0,20)}`}}).sort((t,e)=>t.digest.localeCompare(e.digest)||t.atom.key.localeCompare(e.atom.key)),s=new Map;for(const t of e){const e=s.get(t.digest);if(e&&e!==t.seed)throw new Qa("duplicate-id",t.digest);s.set(t.digest,t.seed);let i=1,o=t.base;for(;h.has(o);)o=`${t.base}-${++i}`;t.atom.id=o,h.add(o)}}else for(const t of c)t.id=mn(h),h.add(t.id)},$n=(t,e)=>{if("partition"===t.host?.kind)return null;const s=[Number(t.x),Number(t.y)];if(!s.every(Number.isFinite))return null;const i=e=>{if(!(Number(e.cm)>0))return!1;const i=hn(s,e.a,e.b),o=rn(e.a,e.b),a=Number(t.length)/2;return i>=-1e-9&&i<=1+Xa&&cn(s,e.a,e.b)<=.02*z&&et(e.a,e.b,Number(t.angle))&&Number.isFinite(a)&&a>=0&&i*o-a>=-1e-9&&i*o+a<=o+Xa},o="wall"===t.host?.kind?e.find(e=>e.id===t.host.id):null,a=o&&i(o)?[o]:e.filter(i);if(1!==a.length)return null;const n=a[0];return{kind:"wall",id:n.id,t:Math.max(0,Math.min(1,hn(s,n.a,n.b)))}},wn=(t,e)=>{const s=[Number(t.x),Number(t.y)];if(!s.every(Number.isFinite))return null;const i=Number(t.length)/2,o=e.filter(e=>{if(!(Number(e.cm)>0))return!1;const o=hn(s,e.a,e.b),a=rn(e.a,e.b);return o>=-1e-9&&o<=1+Xa&&cn(s,e.a,e.b)<=.02*z&&et(e.a,e.b,Number(t.angle))&&Number.isFinite(i)&&i>=0&&o*a-i>=-1e-9&&o*a+i<=a+Xa}),a=(e=>{if(!e.length)return null;const i="wall"===t.host?.kind?e.find(e=>e.id===t.host.id):null;return i||[...e].sort((t,e)=>cn(s,t.a,t.b)-cn(s,e.a,e.b)||Number(e.cm)-Number(t.cm)||(t.ide.id?1:0))[0]})(o);return a?{kind:"wall",id:a.id,t:Math.max(0,Math.min(1,hn(s,a.a,a.b)))}:null},kn=/^[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/,xn=t=>{if("number"!=typeof t&&"string"!=typeof t)return null;if("string"==typeof t&&!kn.test(t.trim()))return null;const e=Number(t);return Number.isFinite(e)?e:null},Mn=t=>{if(!Array.isArray(t)||t.length<2)return null;const e=xn(t[0]),s=xn(t[1]);return null==e||null==s?null:[e,s]},Cn=t=>"string"==typeof t?t:"",Sn=t=>{if(!Object.prototype.hasOwnProperty.call(t,"room_drafts"))return{drafts:0,segments:0};const e=Array.isArray(t.room_drafts)?t.room_drafts:[];if(!e.length)return delete t.room_drafts,{drafts:0,segments:0};const s=new Set;for(const e of[t.rooms,t.openings,t.decor,t.partitions,t.wall_columns,t.wall_segments])for(const t of Array.isArray(e)?e:[])"string"==typeof t?.id&&t.id&&s.add(t.id);for(const t of e)"string"==typeof t?.id&&t.id&&s.add(t.id);const i=Array.isArray(t.partitions)?[...t.partitions]:[];let o=0;for(const a of e){const e=Cn(a?.id),n=Array.isArray(a?.points)?a.points:[],r=Array.isArray(a?.segments)?a.segments:[];if(n.length<2||r.length!==n.length-1)throw new Qa("zero-length",e);for(let a=0;a+1100)throw new Qa("thickness-conflict",e);let p="string"==typeof c?.id&&c.id?c.id:"";if(!p||s.has(p)){const i=_n(Cn(t.id),l,h,[`draft:${e}:${a}`]);p=i;for(let t=2;s.has(p);t++)p=`${i}-${t}`}s.add(p),i.push({id:p,a:sn(l),b:sn(h),cm:d}),o++}}return i.length?t.partitions=i:delete t.partitions,delete t.room_drafts,{drafts:e.length,segments:o}},Pn=t=>Sn(t),Dn=(t,e,s)=>{const i=Sn(t),o=fn(t),{atoms:a,rooms:n}=vn(t,o);yn(t,a,o,e,s);const r=a.map(e=>{const s=e.id?o.get(e.id):void 0,i=((t,e,s)=>{if(e.zeroWall)return 0;const i=Array.isArray(t.walls)?t.walls:[],o=Z(e.a,e.b,z),a=i.filter(t=>Number(t.cm)>0&&(!(t.key!==o&&!e.parentKeys.has(t.key))||!(!en(t.a)||!en(t.b))&&dn(e.a,e.b,t.a,t.b)>=rn(e.a,e.b)-Xa)).map(t=>Math.max(1,Math.min(100,Number(t.cm))));if(new Set(a.map(t=>t.toFixed(9))).size>1)throw new Qa("thickness-conflict",e.key);if(a.length)return a[0];const n=it(i,e.a,e.b,z,1);return n>0?n:Number(s?.cm)>0?Number(s.cm):0})(t,e,s);return{...s||{},id:e.id,a:[...e.a],b:[...e.b],cm:i}}),l=new Map(a.map(t=>[t.key,t.id]));for(const t of n)t.wall_ids=t.wall_ids.map(t=>l.get(t));t.rooms=n,t.wall_segments=r,t.walls=r.filter(t=>t.cm>0).map(t=>({key:Z(t.a,t.b,z),cm:t.cm,a:[...t.a],b:[...t.b]})),t.walls.length||delete t.walls,delete t.open_spans;for(const e of t.rooms)delete e.open_to;return((t,e,s)=>{const i=Array.isArray(t.openings)?t.openings:[];for(const t of i){if("partition"===t.host?.kind)continue;if(!t.host&&!s){const s=$n(t,e);s&&(t.host=s);continue}const i=$n(t,e)??(s?wn(t,e):null);if(i)t.host=i;else{if(!s)throw new Qa("opening-host",t.id);delete t.host}}})(t,r,e),{wallSegments:r.reduce((t,e)=>t+(o.has(e.id)?0:1),0),drafts:i.drafts,draftSegments:i.segments}};function In(t,e={}){const s=JSON.stringify(t),i=tn(t);J(i);let o=0,a=0,n=0;const r=Number(i?.model_version||0)<10;for(const t of Array.isArray(i?.spaces)?i.spaces:[]){const s=e.lineageSpaceId===String(t?.id||"")?e.lineageHints:void 0,i=Dn(t,r,s);o+=i.wallSegments,a+=i.drafts,n+=i.draftSegments}return i.model_version=10,J(i),{config:i,changed:s!==JSON.stringify(i),migratedSegments:o,migratedDrafts:a,migratedDraftSegments:n}}const Ln=t=>!!t&&"object"==typeof t&&!Array.isArray(t);function Tn(t,e){const s=(t,e)=>{if(Array.isArray(t)&&Array.isArray(e)){const i=new Map;for(const e of t)Ln(e)&&"string"==typeof e.id&&e.id&&i.set(e.id,e);const o=e.map((e,o)=>{if(Ln(e)&&"string"==typeof e.id&&e.id){const t=i.get(e.id);return t?s(t,e):tn(e)}return o[e,e in t?s(t[e],i):tn(i)]);for(const e of Object.keys(t))delete t[e];for(const[e,s]of i)t[e]=s;return t}return tn(e)};return s(t,e)}const Rn=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),zn=(t,e,s)=>Math.min(s,Math.max(e,t)),Fn=t=>bt({spaces:[t]})[0],Nn=(t,e,s)=>{const i=s>0?s:1,o=t=>`${(t[0]/i).toFixed(12)},${(t[1]/i).toFixed(12)}`,a=o(t),n=o(e);return a0?n:1,l=Math.max(i*r*.02,1e-9),h=[];for(const e of t||[])for(const t of N(e)||[])h.push([t[0],t[1]]);const c=[];for(const t of s||[])Array.isArray(t)&&t.length>=4&&t.slice(0,4).every(Number.isFinite)&&c.push([t[0],t[1]],[t[2],t[3]]);const d=(t,e)=>e.some(e=>Math.hypot(t[0]-e[0],t[1]-e[1])<=2*l),p=new Map;for(const n of t||[]){if(!n?.id)continue;const u=vt(t,n.id,e,s,i,o,a,r);if(u)for(let t=0;t0&&_>0&&n===g&&_!==n))continue;const m=u.poly[i],f=u.poly[(i+1)%u.poly.length],b=Math.hypot(f[0]-m[0],f[1]-m[1]);if(!(b>l&&b<.5*a-1e-9*a))continue;if(d(m,c)||d(f,c))continue;if(d(m,h)&&d(f,h))continue;const v=Nn(m,f,r),y=p.get(v);y?y.targets.add(n):p.set(v,{a:[m[0],m[1]],b:[f[0],f[1]],targets:new Set([n])})}}}let u=e.slice();const _=(t,e)=>Math.hypot(t[0]-e[0],t[1]-e[1])<=2*l,g=(t,e)=>{if(!Array.isArray(t.a)||!Array.isArray(t.b)||t.a.length<2||t.b.length<2)return!1;const s=[Number(t.a[0])*r,Number(t.a[1])*r],i=[Number(t.b[0])*r,Number(t.b[1])*r];return!![...s,...i].every(Number.isFinite)&&(_(s,e.a)&&_(i,e.b)||_(s,e.b)&&_(i,e.a))};for(const t of[...p.values()].filter(t=>1===t.targets.size).sort((t,e)=>Nn(t.a,t.b,r).localeCompare(Nn(e.a,e.b,r)))){const e=[...t.targets][0],s=u.filter(e=>g(e,t));if(new Set(s.map(t=>t.cm)).size>1)continue;let o=!1;u=u.map(s=>g(s,t)?(o=!0,s.cm===e?s:{...s,cm:e}):s),o||(u=j(u,t.a,t.b,e,i,r))}return u}const En=t=>{const e=[];for(const s of t||[]){const t=N(s);if(t?.length)for(let s=0;s"string"==typeof t?.id?t.id:"").filter(Boolean),c=new Set(h),d=new Map;for(const t of h){const e=Za("space",t);e.layers>0&&Ja("space",e.root)&&Ya(d,e.root,t)}const p=new Map,u=new Map,_=new Map,g=new Map;for(const t of r){const e="string"==typeof t?.id?t.id:"";if(!e)continue;const s=new Map;for(const i of Array.isArray(t.rooms)?t.rooms:[]){const t="string"==typeof i?.id?i.id:"";if(!t)continue;const o=Za("room",t);o.layers>0&&Ja("room",o.root)&&Ya(s,o.root,t),u.has(t)||u.set(t,e),_.has(t)||_.set(t,String(i.name||""));const a="string"==typeof i.area?i.area:"";if(a){const s=g.get(a)||[];s.push({spaceId:e,roomId:t}),g.set(a,s)}}p.set(e,s)}const m=new Set(u.keys()),f=new Map,b=new Map;for(const t of l)"string"==typeof t?.id&&t.id&&(!0===t.removed?b.set(t.id,t):f.set(t.id,t));const v={spaceRefsRemapped:0,roomRefsRemapped:0,positionsRemapped:0,markersDetached:0,positionsUnresolved:0,nestedRefsUnresolved:0,deadSpaceIds:[],orphanRoomLabelsRemoved:0,orphanDevicePositionsRemoved:0,orphanGroupPositionsRemoved:0,liveMissingPositionsRemoved:0,removedPositions:[],liveMissingPositions:[],unverifiedPositions:[]},y=new Set,$=t=>c.has(t)?null:(()=>{const e=Za("space",t).root;if(!Ja("space",e))return null;const s=d.get(e)||[];return 1===s.length?s[0]:null})(),w=(t,e)=>{const s=Za("room",t).root;if(!Ja("room",s))return null;const i=p.get(e)?.get(s)||[];return 1===i.length?i[0]:null},k=t=>{const e=s.effectiveAreaByMarker?.[t]||"",i=e&&g.get(e)||[];return 1===i.length?i[0]:null},x=(t,e,s)=>{if("string"==typeof t.room_id&&t.room_id&&!m.has(t.room_id)){const i=e?w(t.room_id,e):null;i?(t.room_id=i,v.roomRefsRemapped++):s?(t.room_id=s.roomId,v.roomRefsRemapped++):!0!==t.removed&&delete t.room_id}const i=t.vacuum?.segment_map;if(i&&"object"==typeof i&&!Array.isArray(i))for(const t of Object.keys(i)){const s=i[t];if("string"!=typeof s||!s||m.has(s))continue;const o=e?w(s,e):null;o?(i[t]=o,v.roomRefsRemapped++):v.nestedRefsUnresolved++}};for(const t of l){const e="string"==typeof t?.id?t.id:"";if(!e)continue;const s="string"==typeof t.space?t.space:"",i=s&&!c.has(s),a=o[e],n="string"==typeof a?.s?a.s:"",r=n&&!c.has(n),l=!0===t.removed;let h=s&&c.has(s)?s:null,d=null,p=!1;if(i){const i=$(s);i?(t.space=i,h=i,p=!0,v.spaceRefsRemapped++):l||"virtual"===t.binding?l||(delete t.space,h=null,v.markersDetached++):(d=k(e),d?(t.space=d.spaceId,h=d.spaceId,v.spaceRefsRemapped++):(delete t.space,h=null,v.markersDetached++))}l&&!p||x(t,h,d),r&&p&&n===s&&h&&(o[e]={...a,s:h},v.positionsRemapped++,y.add(e))}for(const t of Object.keys(o)){if(y.has(t))continue;const e=o[t],s="string"==typeof e?.s?e.s:"";if(!s||c.has(s))continue;const i=$(s);if(i){if(t.startsWith("rl_")){const s=t.slice(3),a=w(s,i);if(a){const s=`rl_${a}`;Va(o,s)||(o[s]={...e,s:i}),delete o[t],v.roomRefsRemapped++,v.positionsRemapped++;continue}}o[t]={...e,s:i},v.positionsRemapped++}}const M=s.ownerRoster,C=!0===M?.authoritative,S=new Set(M?.deviceIds||[]),P=new Set(M?.entityIds||[]),D=new Set(Array.isArray(i.settings?.known_devices)?i.settings.known_devices.filter(t=>"string"==typeof t):[]),I=(t,e="")=>{const s=String(M?.names?.[t]||e||"").trim();return s&&s!==t?s:""},L=(t,e,s,i="",o)=>({id:t,spaceId:e,kind:s,name:I(t,i),...o?{reason:o}:{}}),T=t=>{"room_label"===t?v.orphanRoomLabelsRemoved++:"group"===t?v.orphanGroupPositionsRemoved++:v.orphanDevicePositionsRemoved++},R=new Set;for(const[t,e]of Object.entries(o)){const i="string"==typeof e?.s?e.s:"";if(!i||c.has(i))continue;let a,n;const r=f.get(t),l=b.get(t);if(r)a=L(t,i,"device",String(r.name||"")),n="live";else if(l)a=L(t,i,"device",String(l.name||"")),n="absent";else if(t.startsWith("rl_")){const e=t.slice(3);a=L(t,i,"room_label",_.get(e)||""),n=m.has(e)?"live":"absent"}else if(t.startsWith("lg_")){const e=t.slice(3);a=L(t,i,"group"),n=P.has(e)?"live":C?"absent":"unverified","unverified"===n&&(a.reason="registry_unavailable")}else S.has(t)?(a=L(t,i,"device"),n="live"):D.has(t)?(a=L(t,i,"device"),n=C?"absent":"unverified","unverified"===n&&(a.reason="registry_unavailable")):(a=L(t,i,"unknown","","unknown_owner"),n="unverified");if("absent"!==n){if("live"===n){if(v.liveMissingPositions.push(a),!0===s.removeLiveMissingPositions){delete o[t],v.liveMissingPositionsRemoved++,T(a.kind),v.removedPositions.push(a);continue}}else v.unverifiedPositions.push(a);v.positionsUnresolved++,R.add(i)}else delete o[t],T(a.kind),v.removedPositions.push(a)}return v.deadSpaceIds=[...R].sort((t,e)=>t.localeCompare(e)),{config:i,layout:o,report:v,changed:JSON.stringify(i)!==a||JSON.stringify(o)!==n}}(t,e,s),n=a.config,r=ot(n,a.layout);J(n),at(a.layout);const l=JSON.stringify(t||{}),h=JSON.stringify(e||{}),c=Number.isInteger(Number(n.model_version))?Number(n.model_version):0,d=(t=>{let e=0,s=0,i=0;for(const s of t.markers||[]){if("ripple"===s.display&&(s.display="icon_ripple",e++),Array.isArray(s.controls)){const t="string"==typeof s.binding&&s.binding.startsWith("entity:")?s.binding.slice(7):"",i=t?s.controls.filter(e=>e!==t):s.controls;JSON.stringify(i)!==JSON.stringify(s.controls)&&(s.controls=i.length?i:null,e++)}const t=s.vacuum;t&&Rn(t,"trail")&&(["never","cleaning","always"].includes(t.trail_mode)||(t.trail_mode=!1===t.trail?"never":"cleaning"),delete t.trail,e++)}for(const o of t.spaces||[]){const t=o.settings;"glow"===t?.fill_mode&&("boolean"!=typeof t.glow_enabled&&(t.glow_enabled=!0),t.fill_mode="none",e++,s++);for(const t of o.rooms||[]){const s=t.settings;"glow"===s?.fill_mode&&("boolean"!=typeof s.glow&&(s.glow=!0),delete s.fill_mode,e++,i++)}if(Rn(o,"segments")&&(delete o.segments,e++),Rn(o,"plan_scale")){const t=Number(o.plan_scale);Number.isFinite(t)&&t>=pt&&t<=ut&&(Rn(o,"plan_scale_x")||(o.plan_scale_x=t),Rn(o,"plan_scale_y")||(o.plan_scale_y=t),delete o.plan_scale,e++)}const a=Number(o.cell_cm);Rn(o,"cell_cm")&&(!Number.isFinite(a)||a<.1||a>1e3)&&(o.cell_cm=Number.isFinite(a)&&a>0?zn(a,.1,1e3):5,e++);const n=Number(o.cell_cm),r=Number.isFinite(n)&&n>0?n:5;for(const t of o.wall_columns||[])if("circle"===t.shape)Rn(t,"angle")&&(delete t.angle,e++);else if("square"===t.shape&&Rn(t,"angle")){const s=((Number(t.angle)||0)%90+90)%90;t.angle!==s&&(t.angle=s,e++)}for(const t of o.decor||[]){if(Rn(t,"width")){const s=Number(t.width);(Rn(t,"width_cm")||Number.isFinite(s))&&(Rn(t,"width_cm")||(t.width_cm=Number(zn(s/ct*r,.1,100).toFixed(6))),delete t.width,e++)}if("rect"!==t?.kind&&"ellipse"!==t?.kind||!0!==t.fill||(Rn(t,"fill_color")||(t.fill_color=t.color||"#607d8b",e++),Rn(t,"fill_opacity")||(t.fill_opacity=.25,e++)),"text"!==t?.kind)continue;void 0===t.size_cm?(t.size_cm=Number(zn(_t*gt(t)/ct*r,.1,2e3).toFixed(6)),delete t.scale,delete t.size,e++):(Rn(t,"scale")||Rn(t,"size"))&&(delete t.scale,delete t.size,e++);let s=String(t.text??"");const i=[...s.matchAll(/\{([^{}\r\n]+)\}/g)].some(t=>!!mt(t[1]));if(!(Rn(t,"entity")||Rn(t,"attr")||Rn(t,"unit")))continue;const o=String(t.unit??"").trim(),a="state"===String(t.attr??"").trim().toLowerCase()?null:t.attr,n=i||o?"":ft(t.entity,a);if(i||n){if(n){const e=s.indexOf("{}");s=e>=0?s.slice(0,e)+n+s.slice(e+2):`${s}${s?" ":""}${n}`,t.text=s}delete t.entity,delete t.attr,delete t.unit,e++}}}return{total:e,glowSpaces:s,glowRooms:i}})(n);let p=d.total,u=0,_=0,g=0;if(c<10)for(const t of Array.isArray(n.spaces)?n.spaces:[]){const e=Pn(t);_+=e.drafts,g+=e.segments}const m=(f=n.spaces||[],JSON.parse(JSON.stringify(f)));var f;const b=ka(n.spaces||[],a.layout);let v=0,y=0,$=0,w="";const k=b.spaces.map(t=>{const e=nt(t);v+=e.report.wallsStraightened,y+=e.report.wallsStraightenSkipped;const s=Number(t?.cell_cm)>0?Number(t.cell_cm):5,i=e.report.maxStraightenShift/z*s;return i>$&&($=i,w=String(t?.id||"")),e.space}),x=v?ka(k,b.layout):{...b,spaces:k};n.spaces=x.spaces;const M=v?{...b.report,moved:b.report.moved+x.report.moved,coordsCanonicalized:b.report.coordsCanonicalized+x.report.coordsCanonicalized,maxShift:Math.max(b.report.maxShift,x.report.maxShift),maxShiftCm:Math.max(b.report.maxShiftCm,x.report.maxShiftCm),maxSpace:x.report.maxShiftCm>b.report.maxShiftCm?x.report.maxSpace:b.report.maxSpace,rotated:b.report.rotated+x.report.rotated}:{...b.report};let C=0,S=0,P=0,D=0,I=0,L=0,T=0;for(let t=0;t0===Number(t.cm)),walls:e.walls||[]}),a=Fn(e),r=Fn(s);if(!a||!r)continue;const l=En(a.rooms),h=En(r.rooms),c=.02*ct,d=(e.wall_segments||[]).filter(t=>0===Number(t.cm)).map(t=>({...t,key:Z(t.a,t.b,z),cm:0})),p=new Set(d.map(t=>t.key)),u=rt(e,a.rooms,lt,c);S+=u.length;for(const t of u){const e=[t[0]/lt,t[1]/lt],s=[t[2]/lt,t[3]/lt],i=Z(e,s,z);p.has(i)||(p.add(i),d.push({key:i,a:e,b:s,cm:0}))}const _=d.length,g=ht(d,l,h,z,lt),f=(t,e,s)=>{const i=s[0]-e[0],o=s[1]-e[1],a=i*i+o*o;if(!(a>0))return Math.hypot(t[0]-e[0],t[1]-e[1]);const n=Math.max(0,Math.min(1,((t[0]-e[0])*i+(t[1]-e[1])*o)/a));return Math.hypot(t[0]-(e[0]+i*n),t[1]-(e[1]+o*n))},b=g.filter(t=>{if(!Array.isArray(t.a)||!Array.isArray(t.b))return!1;const e=t.a.map(t=>t*lt),s=t.b.map(t=>t*lt);return h.some(([t,i])=>f(e,t,i)<=4*c&&f(s,t,i)<=4*c)});P+=Math.max(0,_-b.length);const v=(s.wall_segments||[]).filter(t=>Number(t.cm)>0);s.wall_segments=[...v,...b.map(({key:t,...e})=>e)];const y=b.map(t=>[t.a[0]*lt,t.a[1]*lt,t.b[0]*lt,t.b[1]*lt]),$=Array.isArray(e.walls)?e.walls.length:0;let w=ht(e.walls,l,h,z,lt);w=An(r.rooms,w,y,z,Number(s.cell_cm)>0?Number(s.cell_cm):5,ct,lt),w=G(r.rooms,w,y,z,Number(s.cell_cm)>0?Number(s.cell_cm):5,ct,lt),w=dt(w,s.rooms||[],z,1,y.map(t=>[t[0]/lt,t[1]/lt,t[2]/lt,t[3]/lt])),C+=Math.max(0,$-w.length),w.length?s.walls=w:delete s.walls;const k=Ia(s.partitions||[],{pitch:z,geometry:Ta(s)});k.merged&&(D+=k.merged,s.partitions=k.partitions,La(s.openings,s.partitions,k.openingMoves,{coordScale:lt,cellCm:Number(s.cell_cm)>0?Number(s.cell_cm):5,gridPitch:ct}));const x=Fn(s);if(x){const t=o(s,x,s.walls||[],y,{pitch:z,cellCm:Number(s.cell_cm)>0?Number(s.cell_cm):5,gridPitch:ct,coordScale:lt});t.partitionsReconciled&&(I+=t.partitionsReconciled,L+=t.openingsRehosted,t.partitions.length?s.partitions=t.partitions:delete s.partitions,t.openings.length?s.openings=t.openings:delete s.openings,t.walls.length?s.walls=t.walls:delete s.walls)}JSON.stringify({zero:(s.wall_segments||[]).filter(t=>0===Number(t.cm)),walls:s.walls||[]})!==i&&T++}if(c<=10){const t=function(t){const e=In(t);return Tn(t,e.config),{...e,config:t}}(n);u+=t.migratedSegments,_+=t.migratedDrafts,g+=t.migratedDraftSegments}const R=J(n),F=at(x.layout),N=JSON.stringify(R)!==l||JSON.stringify(F)!==h;c<10&&N&&(R.model_version=10);const A=JSON.stringify(R)!==l||JSON.stringify(F)!==h,E=Number.isInteger(Number(R.model_version))?Number(R.model_version):c,O=A?M:{...M,moved:0,coordsCanonicalized:0,maxShift:0,maxShiftCm:0,maxSpace:"",rotated:0},H=A?a.report:{...a.report,spaceRefsRemapped:0,roomRefsRemapped:0,positionsRemapped:0,markersDetached:0,orphanRoomLabelsRemoved:0,orphanDevicePositionsRemoved:0,orphanGroupPositionsRemoved:0,liveMissingPositionsRemoved:0};return{config:R,layout:F,report:{...O,modelFrom:c,modelTo:E,migrated:A?p:0,glowSpacesMigrated:A?d.glowSpaces:0,glowRoomsMigrated:A?d.glowRooms:0,canonicalized:A?T:0,wallSegmentsMigrated:A?u:0,roomDraftsMigrated:A?_:0,roomDraftSegmentsMigrated:A?g:0,legacyZeroWallsMigrated:A?S:0,wallsMerged:A?C:0,spansMerged:A?P:0,partitionsMerged:A?D:0,partitionsReconciled:A?I:0,openingsRehosted:A?L:0,wallsStraightened:A?v:0,wallsStraightenSkipped:y,maxStraightenShiftCm:A?$:0,maxStraightenSpace:A?w:"",latticeCoordinatesCanonicalized:A?r.canonicalized:0,latticeCoordinatesFar:A?r.far:0,latticeMaxShift:A?r.maxShift:0,latticeMaxShiftCm:A?r.maxShiftCm:0,latticeSpaces:A?r.spaces:[],...H},changed:A}}async function Hn(t,e,s){t._saveConfigDebounced.pending()&&t._saveConfigDebounced.flush(),await t._writeChain;const i=await t.hass.callWS({type:"houseplan/plan/optimize",config:e,layout:s,expected_config_rev:t._cfgRev,expected_layout_rev:t._layoutRev});t._adoption.acceptPairWrite(e,s,i),t._geometryHistory.clear(),t._cancelDeviceDrag(),t._devicePositionHistory.clear(),t._canOptimizeUndo=!0===i.can_undo,t._undoKind=!0===i.can_undo?"optimize":null,t._dirtyPos.clear(),t._sentPos.clear(),t._cfgEpoch++,t._modelCache=null,t._frame=null,t._regSignature="",t._maybeRebuildDevices(),t._cacheSnapshot(),t.requestUpdate()}const Bn=Object.freeze({spaces:50,partitions:2e3,openings:500,decor:1e3,columns:500});class Wn extends Error{constructor(t){super(t),this.code=t,this.name="SpaceCopyError"}}const jn=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Gn=t=>void 0===t?t:JSON.parse(JSON.stringify(t)),qn=t=>null===t||"object"!=typeof t||Array.isArray(t)?null:t;function Un(t,e=!1){if(void 0===t&&!e)return[];if(!Array.isArray(t))throw new Wn("source_invalid");return t.map(t=>{const e=qn(t);if(!e||"string"!=typeof e.id||!e.id)throw new Wn("source_invalid");return e})}const Kn=t=>Array.isArray(t)&&2===t.length&&t.every(t=>Number.isFinite(t));function Vn(t,e,s){const i=String(t??"").trim()||s,o=new Set(e.map(t=>{const e=qn(t);return String(e?.title??"").trim()}));let a=2;for(;o.has(`${i} (${a})`);)a++;return`${i} (${a})`}const Jn=["settings","zero_wall_style","cell_cm","view_box","plan_url","plan_aspect","plan_x","plan_y","plan_scale","plan_scale_x","plan_scale_y","plan_angle"];const Zn={source_missing:"space.copy_error_source_missing",source_invalid:"space.copy_error_source_invalid",spaces_limit:"space.copy_error_spaces_limit",partitions_limit:"space.copy_error_partitions_limit",openings_limit:"space.copy_error_openings_limit",decor_limit:"space.copy_error_decor_limit",columns_limit:"space.copy_error_columns_limit",opening_host_missing:"space.copy_error_opening_host",opening_host_unknown:"space.copy_error_opening_host",geometry_unsafe:"space.copy_error_geometry"};let Yn=0;function Xn(t,e,s){const i=t._spaceDialog;return!(!i?.copy||i.copy.token!==e)&&(t._spaceDialog={...i,busy:s,copy:{...i.copy,busy:s}},!0)}function Qn(t){t._cfgEpoch++,t._modelCache=null,t._frame=null,t._regSignature="",t._maybeRebuildDevices(),t.requestUpdate()}async function tr(t,e){const s=t._spaceDialog;if(!s?.copy||"edit"!==s.mode||s.busy||s.copy.busy||!s.copy.title.trim()||!s.spaceId||!t._serverCfg)return;const i=++Yn,o=s.spaceId,a=s.copy.title.trim();t._spaceDialog={...s,busy:!0,copy:{...s.copy,title:a,busy:!0,token:i}};let n=!1;try{if(t._saveConfigDebounced.pending()&&t._saveConfigDebounced.flush(),await t._writeChain,!Xn(t,i,!0)||!t._serverCfg)return;const s=t._cfgRev,r=t._layoutRev,l=yt(t._serverCfg),h=yt(t._layout);let c;try{c=(e.optimize??On)(t._serverCfg,t._layout,e.optimizeReferenceContext())}catch(s){return Xn(t,i,!1),void e.showWallModelMigrationBlocked(s)}if(c.changed){const d=t._checkOptimizeGeometry(c.config);if(e.reportPreflightFailure(d,c.config),!d.ok)return Xn(t,i,!1),void t._showToast(t._t("space.copy_error_optimize_geometry"));const p=await t._confirmDanger({key:`copy-space:${o}`,kind:"warning",title:t._t("space.copy_optimize_title"),message:t._t("space.copy_optimize_body",{name:a}),objectName:a,confirmLabel:t._t("space.copy_optimize_confirm"),cancelLabel:t._t("btn.cancel"),icon:"mdi:broom"});if(!Xn(t,i,p))return;if(!p)return;if(t._cfgRev!==s||t._layoutRev!==r||!t._serverCfg||yt(t._serverCfg)!==l||yt(t._layout)!==h)return Xn(t,i,!1),void t._showToast(t._t("space.copy_error_changed"));e.clearGeometryGesture(),await Hn(t,c.config,c.layout),n=!0}if(!Xn(t,i,!0)||!t._serverCfg)return;const d=t._serverCfg,p=function(t,e,s,i){const o=t.spaces;if(!s.trim())throw new Wn("source_invalid");if(o.length>=Bn.spaces)throw new Wn("spaces_limit");const a=o.findIndex(t=>t.id===e);if(a<0)throw new Wn("source_missing");const n=o[a];if(!Array.isArray(n.view_box))throw new Wn("source_invalid");const r=Un(n.wall_segments,!0),l=Un(n.partitions),h=Un(n.openings),c=Un(n.decor),d=Un(n.wall_columns);if(r.length+l.length>Bn.partitions)throw new Wn("partitions_limit");if(h.length>Bn.openings)throw new Wn("openings_limit");if(c.length>Bn.decor)throw new Wn("decor_limit");if(d.length>Bn.columns)throw new Wn("columns_limit");let p=0;const u=t=>`${t}${i}${(p++).toString(36)}`,_=new Map,g=new Map,m=[];for(const t of r){if(_.has(t.id)||!Kn(t.a)||!Kn(t.b)||"number"!=typeof t.cm||!Number.isFinite(t.cm))throw new Wn("source_invalid");const e=u("cw");_.set(t.id,e),m.push({id:e,a:Gn(t.a),b:Gn(t.b),cm:t.cm})}for(const t of l){if(g.has(t.id)||!Kn(t.a)||!Kn(t.b)||"number"!=typeof t.cm||!Number.isFinite(t.cm))throw new Wn("source_invalid");const e=u("cp");g.set(t.id,e),m.push({id:e,a:Gn(t.a),b:Gn(t.b),cm:t.cm})}const f=h.map(t=>{const e=qn(t.host);if(!e||"string"!=typeof e.id||"string"!=typeof e.kind)throw new Wn("opening_host_missing");const s="wall"===e.kind?_.get(e.id):"partition"===e.kind?g.get(e.id):void 0;if(!s)throw new Wn("opening_host_unknown");const i={...Gn(t),id:u("co"),host:{...Gn(e),kind:"partition",id:s}};return delete i.contact,delete i.lock,i}),b=c.map(t=>({...Gn(t),id:u("cd")})),v=d.map(t=>({...Gn(t),id:u("cc")})),y=`s${i}`;if(o.some(t=>t.id===y))throw new Wn("source_invalid");const $={id:y,title:s.trim(),rooms:[],wall_segments:[],view_box:Gn(n.view_box)};for(const t of Jn)"view_box"!==t&&jn(n,t)&&($[t]=Gn(n[t]));m.length&&($.partitions=m),f.length&&($.openings=f),b.length&&($.decor=b),v.length&&($.wall_columns=v);const w=Gn(t);return w.spaces.splice(a+1,0,$),{config:w,space:$,sourceIndex:a}}(d,o,a,e.newSeed?.()??function(t=Date.now(),e=Math.random()){const s=Math.floor(16777216*Math.max(0,Math.min(.999999999,e))).toString(36).padStart(5,"0");return`${Math.max(0,Math.floor(t)).toString(36)}${s}`}());let u=!1;try{u=t._checkSpacePhysicalGeometry(p.config,p.space.id).ok}catch{u=!1}if(!u||t._junctionLimitViolations(p.config,p.space.id).length)throw new Wn("geometry_unsafe");const _=t._adoption.beginOptimistic(d,p.config);t._adoption.stageLocalConfig(p.config),Qn(t);try{await e.saveConfigNow(_)}catch(e){throw t._rollbackOptimistic(_)&&Qn(t),"conflict"!==e?.code&&await t._reloadConfigOnly(!0),e}t._canOptimizeUndo=!1,t._undoKind=null,e.clearGeometryGesture(),t._selId=null,t._physicalSel=null,t._spaceDialog=null,t._commitSpace(p.space.id,!0),e.setMode("plan"),t._tool="draw",t._path=[],t._cursorPt=null,t._activeWallChainId=null,t._activeWallChainPartitionIds=[],t._primeDrawWallField(),t._saveNav(),t.requestUpdate(),t._showToast(t._t("toast.space_copied",{name:a}))}catch(e){"conflict"===e?.code&&await Promise.all([t._reloadConfigOnly(!0),t._reloadLayoutOnly()]),Xn(t,i,!1),function(t,e){if(e instanceof Wn)return void t._showToast(t._t(Zn[e.code]));const s=e?.code;"wall_model_client_outdated"!==s?t._showToast(t._t("toast.error",{err:t._errText(e)})):t._showToast(t._t("toast.wall_model_client_outdated"))}(t,e),n&&t.requestUpdate()}}const er=1e3;function sr(){Zo(this.host);const t=this.host._spaceDialog;if(t.copy)return function(t,e){const s=t._spaceDialog.copy,i=()=>function(t){const e=t._spaceDialog;!e?.copy||e.busy||e.copy.busy||(t._spaceDialog={...e,copy:void 0})}(t);return p`
    @@ -545,7 +545,7 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db .title=${`${"create"===t.mode?this.host._t("space.new"):this.host._t("space.header")}${e?` · ${e}`:""}`} icon="mdi:floor-plan" wide @hp-close=${s}>
    - ${Zo({title:this.host._t("space.card_basics"),body:p` + ${Yo({title:this.host._t("space.card_basics"),body:p` {const s=e.target.value,i=kt(s),o=null==i?null:xt(i,this.host._imperial);this.host._spaceDialog={...t,cellCmInput:s,cellCmTouched:!0,cellCm:null!=o&&o>0?Math.max(.1,Math.min(tr,o)):t.cellCm}}} /> + @input=${e=>{const s=e.target.value,i=kt(s),o=null==i?null:xt(i,this.host._imperial);this.host._spaceDialog={...t,cellCmInput:s,cellCmTouched:!0,cellCm:null!=o&&o>0?Math.max(.1,Math.min(er,o)):t.cellCm}}} /> ${this.host._t(this.host._imperial?"space.scale_unit_imperial":"space.scale_unit")}
    `})} - ${Zo({title:this.host._t("space.display_section"),body:p` + ${Yo({title:this.host._t("space.display_section"),body:p`
    - + ${Qo({name:"space-zero-wall-style",value:"solid"===t.zeroWallStyle?"solid":"dashed",ariaLabel:this.host._t("space.zero_wall_style"),options:[{value:"dashed",label:this.host._t("space.zero_wall_dashed")},{value:"solid",label:this.host._t("space.zero_wall_solid")}],onChange:e=>{this.host._spaceDialog={...t,zeroWallStyle:"solid"===e?"solid":"dashed"}}})}
    `:d}`)}`})} - ${Zo({title:this.host._t("space.roomcard_section"),body:p` + ${Yo({title:this.host._t("space.roomcard_section"),body:p` ${[["labelTemp","space.label_temp"],["labelHum","space.label_hum"],["labelLqi","space.label_lqi"],["labelLight","space.label_light"]].map(([e,s])=>p`
    ${this.host._renderCardPreview(t.cardFontScale,1,1)}`})} - ${Zo({title:this.host._t("space.card_sun"),body:p` + ${Yo({title:this.host._t("space.card_sun"),body:p`
    ${this._help("space.bg_mode.help")}
    - + ${Qo({name:"space-bg-mode",value:t.bgMode??"",ariaLabel:this.host._t("space.bg_mode"),options:[{value:"",label:this.host._t("space.sun_inherit")},{value:"static",label:this.host._t("gs.bg_static")},{value:"daynight",label:this.host._t("gs.bg_daynight")}],onChange:e=>{this.host._spaceDialog={...t,bgMode:"static"===e||"daynight"===e?e:null}}})} ${"static"===(t.bgMode??Pt(this.host._settings,{}))?p`
    ${"edit"===t.mode?p`
    -
    `:d} @@ -741,10 +728,10 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db
    - `}function sr(){return p``}function ir(){return Zo(this.host),p`this.host._settingsDialog=null}>
    - ${Zo({title:this.host._t("gs.card_display"),body:p` + ${Yo({title:this.host._t("gs.card_display"),body:p` `})} - ${Zo({title:this.host._t("gs.card_zigbee"),body:p`this.host._settingsDialog={...this.host._settingsDialog,zigbeeTopology:t.detail}}>`})} - ${Zo({title:this.host._t("gs.card_fills"),help:this._help("gs.card_fills.help"),body:p` + ${Yo({title:this.host._t("gs.card_zigbee"),body:p`this.host._settingsDialog={...this.host._settingsDialog,zigbeeTopology:t.detail}}>`})} + ${Yo({title:this.host._t("gs.card_fills"),help:this._help("gs.card_fills.help"),body:p` ${this._renderColorRow("light_on","gs.light_on")} ${this._renderColorRow("light_off","gs.light_off")} @@ -767,7 +754,7 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db ${this._renderColorRow("lqi_low","gs.lqi_low")} ${this._renderColorRow("lqi_high","gs.lqi_high")}`})} - ${Zo({title:this.host._t("gs.glow_group"),body:p` + ${Yo({title:this.host._t("gs.glow_group"),body:p` ${this._renderColorRow("glow_base","gs.glow_base")} ${this._renderColorRow("glow_light","gs.glow_light")}
    @@ -778,14 +765,14 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db @input=${t=>{const e=kt(t.target.value);null!=e&&e>0&&(this.host._settingsDialog={...this.host._settingsDialog,glowRadius:e})}} /> ${this.host._imperial?this.host._t("gs.unit_ft"):this.host._t("gs.unit_m")}
    `})} - ${Zo({title:this.host._t("gs.card_plan"),body:p` + ${Yo({title:this.host._t("gs.card_plan"),body:p` ${this._renderColorRow("wall_fill","gs.wall_fill")}
    ${this._help("gs.bg_mode.help")} - ${Xo({name:"gs-bg-mode",value:"daynight"===this.host._settingsDialog.bgMode?"daynight":"static",ariaLabel:this.host._t("gs.bg_mode"),options:[{value:"static",label:this.host._t("gs.bg_static")},{value:"daynight",label:this.host._t("gs.bg_daynight")}],onChange:t=>this.host._settingsDialog={...this.host._settingsDialog,bgMode:"daynight"===t?"daynight":"static"}})} + ${Qo({name:"gs-bg-mode",value:"daynight"===this.host._settingsDialog.bgMode?"daynight":"static",ariaLabel:this.host._t("gs.bg_mode"),options:[{value:"static",label:this.host._t("gs.bg_static")},{value:"daynight",label:this.host._t("gs.bg_daynight")}],onChange:t=>this.host._settingsDialog={...this.host._settingsDialog,bgMode:"daynight"===t?"daynight":"static"}})}
    ${"static"===this.host._settingsDialog.bgMode?p`
    this.host._settingsDialog={...this.host._settingsDialog,bgColor:null}}>${this.host._t("gs.bg_default")}`:p`${this.host._t("gs.bg_theme")}`}
    `:d}`})} - ${Zo({title:this.host._t("gs.sun_group"),body:p` + ${Yo({title:this.host._t("gs.sun_group"),body:p` ${Tt(this.host.hass)?d:p`
    ${this.host._t("gs.sun_missing")}
    `}
    ${this.host._renderCompass()} @@ -825,7 +812,7 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db
    `}`})} - ${Zo({title:this.host._t("gs.card_data"),body:p` + ${Yo({title:this.host._t("gs.card_data"),body:p` ${this.host._canEdit?p`
    @@ -867,7 +854,7 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db ${this.host._settingsDialog.busy?"…":this.host._t("btn.save")}
    - `;var t,e,s}function ir(t,e,s,i,o){const a=zt(t._roomTempMin,t._roomTempMax);if("temp"!==e)return{valid:a.valid,template:d};const n=""!==t._roomTempMin.trim()&&null===kt(t._roomTempMin),r=""!==t._roomTempMax.trim()&&null===kt(t._roomTempMax);return{valid:a.valid,template:p`
    + `;var t,e,s}function or(t,e,s,i,o){const a=zt(t._roomTempMin,t._roomTempMax);if("temp"!==e)return{valid:a.valid,template:d};const n=""!==t._roomTempMin.trim()&&null===kt(t._roomTempMin),r=""!==t._roomTempMax.trim()&&null===kt(t._roomTempMax);return{valid:a.valid,template:p`
    ${o} @@ -887,7 +874,7 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db °C ${t._roomTempMin.trim()||t._roomTempMax.trim()?p``:d}
    -
    `}}const or=[{value:"",key:"fill.inherit"},...Ft.map(t=>({value:t,key:`fill.${t}`}))];function ar(t,e){const s=t.host,i="temp"===e?s._roomTempSrc:s._roomHumSrc,o=t=>{"temp"===e?s._roomTempSrc=t:s._roomHumSrc=t,s.requestUpdate()},a=s._roomSrcOpen===e,n=s._t("temp"===e?"room.temp_src_label":"room.hum_src_label");return p`${Yo({label:n,control:Xo({name:`rsrc-${e}`,value:i?"pick":"avg",ariaLabel:n,options:[{value:"avg",label:s._t("room.src_average")},{value:"pick",label:s._t("room.src_pick")}],onChange:t=>{if("avg"===t)return o(""),void(s._roomSrcOpen=null);s._roomSrcOpen=e,s._roomSrcFilter="",s.requestUpdate()}})})} +
    `}}const ar=[{value:"",key:"fill.inherit"},...Ft.map(t=>({value:t,key:`fill.${t}`}))];function nr(t,e){const s=t.host,i="temp"===e?s._roomTempSrc:s._roomHumSrc,o=t=>{"temp"===e?s._roomTempSrc=t:s._roomHumSrc=t,s.requestUpdate()},a=s._roomSrcOpen===e,n=s._t("temp"===e?"room.temp_src_label":"room.hum_src_label");return p`${Xo({label:n,control:Qo({name:`rsrc-${e}`,value:i?"pick":"avg",ariaLabel:n,options:[{value:"avg",label:s._t("room.src_average")},{value:"pick",label:s._t("room.src_pick")}],onChange:t=>{if("avg"===t)return o(""),void(s._roomSrcOpen=null);s._roomSrcOpen=e,s._roomSrcFilter="",s.requestUpdate()}})})} ${i||a?p`
    `)}
    -
    `:d}`:d}`}function nr(){!function(t){const e=t.renderRoot;if(!e||Vo.has(e))return;const s=e.ownerDocument??globalThis.document,i=s?.defaultView?.CSSStyleSheet;if(i&&"adoptedStyleSheets"in e)return Jo||(Jo=new i,Jo.replaceSync(Ko)),e.adoptedStyleSheets=[...e.adoptedStyleSheets,Jo],void Vo.add(e);if(e.querySelector("style[data-hp-form-kit]"))return void Vo.add(e);const o=s.createElement("style");o.dataset.hpFormKit="true",o.textContent=Ko,e.appendChild(o),Vo.add(e)}(this.host);const t=!!this.host._roomEditId,e=t?null:this.host._wallFaceBatch,s=e&&e.candidates.length>1?this.host._t("room.queue_progress",{current:e.index+1,total:e.candidates.length}):"",i=_(this.host._curSpaceCfg),o=this.host._roomFill||i.fill,a=this.host._roomCustomFill||i.customFill,n=zt(this.host._roomTempMin,this.host._roomTempMax).valid,r=(!!this.host._areaSel||!!this.host._nameSel.trim())&&n,l=[...this.host._freeAreas];if(t&&this.host._areaSel&&!l.some(t=>t.area_id===this.host._areaSel)){const t=this.host.hass.areas[this.host._areaSel];t&&l.unshift(t)}return p``:d}`:d}`}function rr(){Zo(this.host);const t=!!this.host._roomEditId,e=t?null:this.host._wallFaceBatch,s=e&&e.candidates.length>1?this.host._t("room.queue_progress",{current:e.index+1,total:e.candidates.length}):"",i=_(this.host._curSpaceCfg),o=this.host._roomFill||i.fill,a=this.host._roomCustomFill||i.customFill,n=zt(this.host._roomTempMin,this.host._roomTempMax).valid,r=(!!this.host._areaSel||!!this.host._nameSel.trim())&&n,l=[...this.host._freeAreas];if(t&&this.host._areaSel&&!l.some(t=>t.area_id===this.host._areaSel)){const t=this.host.hass.areas[this.host._areaSel];t&&l.unshift(t)}return p`this._roomDialogCancel()}>
    ${s?p`

    ${s}

    `:d} - ${Zo({title:this.host._t("room.group_basics"),help:this._help("room.group_basics.help"),body:p` + ${Yo({title:this.host._t("room.group_basics"),help:this._help("room.group_basics.help"),body:p` ${this.host._t("room.no_area_option")} ${l.map(t=>p``)} `})} - ${Zo({title:this.host._t("room.group_fill"),help:this._help("room.group_fill.help"),body:p` + ${Yo({title:this.host._t("room.group_fill"),help:this._help("room.group_fill.help"),body:p` - ${or.map(({value:t,key:e})=>p`
    @@ -959,7 +946,7 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db ${this.host._t("btn.save")} `}
    -
    `}const rr=new WeakMap;function lr(t,e,s){let i=rr.get(t);i||(i=new Map,rr.set(t,i));const o=i.get(e);if(o)return void(o.run=s);const a={run:s};i.set(e,a),queueMicrotask(()=>{i.get(e)===a&&(i.delete(e),a.run())})}function hr(t,e){const s=rr.get(t),i=s?.get(e);i&&(s.delete(e),i.run())}function cr(t,e){const s=rr.get(t);if(!s)return;const i=e?[...s].filter(([t])=>t===e):[...s];for(const[t]of i)s.delete(t);s.size||rr.delete(t)}const dr=new WeakMap,pr=new Set(["_cursorPt","_opMeasure","_physicalDrag","_physicalRotate","_decorDraft","_dtBox","_dtDrag","_bdDrag","_furnPreviewInput","_layout"]),ur=new Set(["_cursorPt","_opMeasure","_furnPreviewInput"]),_r=new Set(["_physicalDrag","_physicalRotate","_decorDraft","_dtDrag","_bdDrag"]),gr=t=>{let e=dr.get(t);return e||(e={raf:0,requestedRevision:0,paintedRevision:0,waiters:[],hidden:[],transparent:[],dimmed:[]},dr.set(t,e)),e},mr=(t,e)=>{t.paintedRevision=Math.max(t.paintedRevision,e);const s=t.waiters.filter(e=>e.revision<=t.paintedRevision);t.waiters=t.waiters.filter(e=>e.revision>t.paintedRevision);for(const t of s)t.resolve()},fr=t=>!!("view"!==t._mode&&(t._deviceDrag||t._physicalDrag||t._physicalRotate||t._decorDraft||t._decorMove||t._dtDrag||t._bdDrag||t._opDrag||t._resize?.dragging));function br(t,e,s){const i=t;if(!i?.isConnected||"view"===i._mode)return!1;const o=void 0!==e&&pr.has(e);if("_layout"===e&&!i._deviceDrag)return!1;if("_dtBox"===e&&!i._dtDrag)return!1;if(void 0!==e&&_r.has(e)&&null==s&&null!=i[e]&&fr(i))return!1;if(void 0!==e&&_r.has(e)&&null==i[e])return!1;if(void 0!==e&&ur.has(e)&&null==i[e])return!1;return!!(o&&(ur.has(e)||fr(i))||void 0===e&&fr(i))&&(function(t){const e=gr(t);if(e.requestedRevision++,e.raf||"function"!=typeof requestAnimationFrame)return;e.raf=requestAnimationFrame(()=>{e.raf=0;const s=e.requestedRevision;!function(t){const e=t,s=e.renderRoot;if(!s)return;const i=gr(e);$r(i),xr(e,s);const o=s.querySelector("[data-hp-live-editor]");if(!o)return;if(yr(i,s,".hp-editor-only-layer:not(.hp-plan-snap-layer)"),"plan"===e._mode)e._opDrag&&vr(i,s,".wallbodies"),e._resize?.dragging&&(Sr(i,s,".wallbodies"),yr(i,s,".resize-layer"),Cr(i,s,e._resize.plan?.movingOpeningIds||[])),e._opDrag&&yr(i,s,".openinglayer");else if("decor"===e._mode){const t=e._dtDrag?.id||e._decorMove?.id;t&&Mr(i,s,t),yr(i,s,".dtframe, .backdropframe")}Nt(kr(e),o);const a=s.querySelector("[data-hp-live-editor-html]");if(a){const t=e._viewOr(e._baseVb());Nt(e._renderLiveEditorMeasurements(t),a)}e._liveEditorPaintCount=(e._liveEditorPaintCount||0)+1}(t),mr(e,s)})}(i),!0)}const vr=(t,e,s)=>{for(const i of e.querySelectorAll(s))i.closest("[data-hp-live-editor]")||"hidden"!==i.style.visibility&&(i.style.visibility="hidden",t.hidden.push(i))},yr=(t,e,s)=>{for(const i of e.querySelectorAll(s))i.closest("[data-hp-live-editor]")||"0"!==i.style.opacity&&(i.style.opacity="0",t.transparent.push(i))},$r=t=>{for(const e of t.hidden)e.style.removeProperty("visibility");t.hidden.length=0;for(const e of t.transparent)e.style.removeProperty("opacity");t.transparent.length=0;for(const e of t.dimmed)e.style.removeProperty("opacity");t.dimmed.length=0},wr=(t,e,s=[])=>{if("iso"===t._renderProjection)return At``;const i=t._spaceModel();if(!i)return At``;const o=new Set(s),a=(i.rooms||[]).filter(t=>!!t.id&&o.has(t.id)).flatMap(t=>{const e=t.poly||[];return e.map((t,s)=>[t,e[(s+1)%e.length]])}),n=(t,e)=>{const[s,i]=e,o=i[0]-s[0],a=i[1]-s[1],n=o*o+a*a;if(!(n>0))return!1;const r=((t[0]-s[0])*o+(t[1]-s[1])*a)/n,l=Math.max(0,Math.min(1,r));return Math.hypot(t[0]-s[0]-o*l,t[1]-s[1]-a*l)<1e-4},r=[...t._spaceWalls.filter(t=>{const e=(t.a||[]).map(t=>t*lt),s=(t.b||[]).map(t=>t*lt);return a.some(t=>n(e,t)&&n(s,t))}).map((e,s)=>((e,s,i,o)=>{const a=Math.hypot(s[0]-e[0],s[1]-e[1]);if(!(a>1e-9&&i>0))return null;const n=V(i,t._cellCm,t._gridPitch)/2,r=-(s[1]-e[1])/a*n,l=(s[0]-e[0])/a*n;return{key:o,kind:"outer",cm:i,a:e,b:s,depthUnits:2*n,quad:[[e[0]+r,e[1]+l],[s[0]+r,s[1]+l],[s[0]-r,s[1]-l],[e[0]-r,e[1]-l]]}})((e.a||[]).map(t=>t*lt),(e.b||[]).map(t=>t*lt),e.cm,e.key||`wall-${s}`))].filter(t=>!!t),l=t._openingsR.map(t=>({x:t.rx,y:t.ry,angle:t.angle,length:t.rlen})),h=r.map(t=>Et(t,l)).filter(Boolean);if(!h.length)return At``;const c=Math.max(...r.map(t=>t.depthUnits),0),d=t._viewOr(t._baseVb()),p=t._stageEl?.clientWidth&&d.w?t._stageEl.clientWidth/d.w:1,u=Ot(c,p)||Ht(Bt(t._cellCm),p),_=e?.color||"#607d8b",g=t._fillColors.wall_fill,m=h.join(" ");return At``}const lr=new WeakMap;function hr(t,e,s){let i=lr.get(t);i||(i=new Map,lr.set(t,i));const o=i.get(e);if(o)return void(o.run=s);const a={run:s};i.set(e,a),queueMicrotask(()=>{i.get(e)===a&&(i.delete(e),a.run())})}function cr(t,e){const s=lr.get(t),i=s?.get(e);i&&(s.delete(e),i.run())}function dr(t,e){const s=lr.get(t);if(!s)return;const i=e?[...s].filter(([t])=>t===e):[...s];for(const[t]of i)s.delete(t);s.size||lr.delete(t)}const pr=new WeakMap,ur=new Set(["_cursorPt","_opMeasure","_physicalDrag","_physicalRotate","_decorDraft","_dtBox","_dtDrag","_bdDrag","_furnPreviewInput","_layout"]),_r=new Set(["_cursorPt","_opMeasure","_furnPreviewInput"]),gr=new Set(["_physicalDrag","_physicalRotate","_decorDraft","_dtDrag","_bdDrag"]),mr=t=>{let e=pr.get(t);return e||(e={raf:0,requestedRevision:0,paintedRevision:0,waiters:[],hidden:[],transparent:[],dimmed:[]},pr.set(t,e)),e},fr=(t,e)=>{t.paintedRevision=Math.max(t.paintedRevision,e);const s=t.waiters.filter(e=>e.revision<=t.paintedRevision);t.waiters=t.waiters.filter(e=>e.revision>t.paintedRevision);for(const t of s)t.resolve()},br=t=>!!("view"!==t._mode&&(t._deviceDrag||t._physicalDrag||t._physicalRotate||t._decorDraft||t._decorMove||t._dtDrag||t._bdDrag||t._opDrag||t._resize?.dragging));function vr(t,e,s){const i=t;if(!i?.isConnected||"view"===i._mode)return!1;const o=void 0!==e&&ur.has(e);if("_layout"===e&&!i._deviceDrag)return!1;if("_dtBox"===e&&!i._dtDrag)return!1;if(void 0!==e&&gr.has(e)&&null==s&&null!=i[e]&&br(i))return!1;if(void 0!==e&&gr.has(e)&&null==i[e])return!1;if(void 0!==e&&_r.has(e)&&null==i[e])return!1;return!!(o&&(_r.has(e)||br(i))||void 0===e&&br(i))&&(function(t){const e=mr(t);if(e.requestedRevision++,e.raf||"function"!=typeof requestAnimationFrame)return;e.raf=requestAnimationFrame(()=>{e.raf=0;const s=e.requestedRevision;!function(t){const e=t,s=e.renderRoot;if(!s)return;const i=mr(e);wr(i),Mr(e,s);const o=s.querySelector("[data-hp-live-editor]");if(!o)return;if($r(i,s,".hp-editor-only-layer:not(.hp-plan-snap-layer)"),"plan"===e._mode)e._opDrag&&yr(i,s,".wallbodies"),e._resize?.dragging&&(Pr(i,s,".wallbodies"),$r(i,s,".resize-layer"),Sr(i,s,e._resize.plan?.movingOpeningIds||[])),e._opDrag&&$r(i,s,".openinglayer");else if("decor"===e._mode){const t=e._dtDrag?.id||e._decorMove?.id;t&&Cr(i,s,t),$r(i,s,".dtframe, .backdropframe")}Nt(xr(e),o);const a=s.querySelector("[data-hp-live-editor-html]");if(a){const t=e._viewOr(e._baseVb());Nt(e._renderLiveEditorMeasurements(t),a)}e._liveEditorPaintCount=(e._liveEditorPaintCount||0)+1}(t),fr(e,s)})}(i),!0)}const yr=(t,e,s)=>{for(const i of e.querySelectorAll(s))i.closest("[data-hp-live-editor]")||"hidden"!==i.style.visibility&&(i.style.visibility="hidden",t.hidden.push(i))},$r=(t,e,s)=>{for(const i of e.querySelectorAll(s))i.closest("[data-hp-live-editor]")||"0"!==i.style.opacity&&(i.style.opacity="0",t.transparent.push(i))},wr=t=>{for(const e of t.hidden)e.style.removeProperty("visibility");t.hidden.length=0;for(const e of t.transparent)e.style.removeProperty("opacity");t.transparent.length=0;for(const e of t.dimmed)e.style.removeProperty("opacity");t.dimmed.length=0},kr=(t,e,s=[])=>{if("iso"===t._renderProjection)return At``;const i=t._spaceModel();if(!i)return At``;const o=new Set(s),a=(i.rooms||[]).filter(t=>!!t.id&&o.has(t.id)).flatMap(t=>{const e=t.poly||[];return e.map((t,s)=>[t,e[(s+1)%e.length]])}),n=(t,e)=>{const[s,i]=e,o=i[0]-s[0],a=i[1]-s[1],n=o*o+a*a;if(!(n>0))return!1;const r=((t[0]-s[0])*o+(t[1]-s[1])*a)/n,l=Math.max(0,Math.min(1,r));return Math.hypot(t[0]-s[0]-o*l,t[1]-s[1]-a*l)<1e-4},r=[...t._spaceWalls.filter(t=>{const e=(t.a||[]).map(t=>t*lt),s=(t.b||[]).map(t=>t*lt);return a.some(t=>n(e,t)&&n(s,t))}).map((e,s)=>((e,s,i,o)=>{const a=Math.hypot(s[0]-e[0],s[1]-e[1]);if(!(a>1e-9&&i>0))return null;const n=V(i,t._cellCm,t._gridPitch)/2,r=-(s[1]-e[1])/a*n,l=(s[0]-e[0])/a*n;return{key:o,kind:"outer",cm:i,a:e,b:s,depthUnits:2*n,quad:[[e[0]+r,e[1]+l],[s[0]+r,s[1]+l],[s[0]-r,s[1]-l],[e[0]-r,e[1]-l]]}})((e.a||[]).map(t=>t*lt),(e.b||[]).map(t=>t*lt),e.cm,e.key||`wall-${s}`))].filter(t=>!!t),l=t._openingsR.map(t=>({x:t.rx,y:t.ry,angle:t.angle,length:t.rlen})),h=r.map(t=>Et(t,l)).filter(Boolean);if(!h.length)return At``;const c=Math.max(...r.map(t=>t.depthUnits),0),d=t._viewOr(t._baseVb()),p=t._stageEl?.clientWidth&&d.w?t._stageEl.clientWidth/d.w:1,u=Ot(c,p)||Ht(Bt(t._cellCm),p),_=e?.color||"#607d8b",g=t._fillColors.wall_fill,m=h.join(" ");return At` @@ -967,8 +954,8 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db data-id="preview" data-kind="preview" d=${m} fill=${u?"none":"url(#hp-wall-hatch)"} fill-rule="nonzero" stroke=${_} stroke-width=${Wt(.6,t._cellCm)}> - `},kr=t=>{if("plan"===t._mode)return(t=>{const e=t._baseVb(),s=t._viewOr(e),i=t._opMeasureView;if(t._resize?.dragging){const e=t._spaceDisplayForRender(),i=t._resize.plan;return At``},xr=t=>{if("plan"===t._mode)return(t=>{const e=t._baseVb(),s=t._viewOr(e),i=t._opMeasureView;if(t._resize?.dragging){const e=t._spaceDisplayForRender(),i=t._resize.plan;return At``}return At``},xr=(t,e)=>{const s=t._deviceDrag;if(!s)return;const i=t._devices.find(t=>t.id===s.id),o=[...e.querySelectorAll('[data-hp="device"]')].find(t=>t.dataset.id===s.id);if(!i||!o)return;const a=t._livePos(i),n=t._scenePoint([a.x,a.y]),r=t._viewOr(t._baseVb());o.style.left=(n[0]-r.x)/r.w*100+"%",o.style.top=(n[1]-r.y)/r.h*100+"%"},Mr=(t,e,s)=>{for(const i of e.querySelectorAll('.decorlayer [data-hp="decor"]'))i.closest("[data-hp-live-editor]")||i.dataset.id!==s||"0"!==i.style.opacity&&(i.style.opacity="0",t.transparent.push(i))},Cr=(t,e,s)=>{const i=new Set(s);for(const s of e.querySelectorAll('.openinglayer [data-hp="opening"]'))!s.closest("[data-hp-live-editor]")&&i.has(s.dataset.id||"")&&(s.style.opacity="0",t.transparent.push(s))},Sr=(t,e,s)=>{for(const i of e.querySelectorAll(s))i.closest("[data-hp-live-editor]")||(i.style.opacity="0.35",t.dimmed.push(i))};const Pr=(t,e,s)=>Math.min(s,Math.max(e,Number.isFinite(t)?t:e));function Dr(t){return Number.isFinite(t)?(t%360+360)%360:0}function Ir(t){if("string"!=typeof t)return null;const e=t.trim().replace(/^#/,""),s=/^[0-9a-fA-F]{3}$/.test(e)?e.split("").map(t=>`${t}${t}`).join(""):e;return/^[0-9a-fA-F]{6}$/.test(s)?`#${s.toLowerCase()}`:null}function Lr(t){const e=Ir(t);return e?{r:Number.parseInt(e.slice(1,3),16),g:Number.parseInt(e.slice(3,5),16),b:Number.parseInt(e.slice(5,7),16)}:null}function Tr(t){const e=Pr(t.r,0,255)/255,s=Pr(t.g,0,255)/255,i=Pr(t.b,0,255)/255,o=Math.max(e,s,i),a=o-Math.min(e,s,i);let n=0;return a>0&&(n=o===e?(s-i)/a%6*60:o===s?60*((i-e)/a+2):60*((e-s)/a+4)),{h:Dr(n),s:0===o?0:a/o*100,v:100*o}}function Rr(t){return function(t){const e=t=>Math.round(Pr(t,0,255)).toString(16).padStart(2,"0");return`#${e(t.r)}${e(t.g)}${e(t.b)}`}(function(t){const e=Dr(t.h),s=Pr(t.s,0,100)/100,i=Pr(t.v,0,100)/100,o=i*s,a=o*(1-Math.abs(e/60%2-1)),n=i-o;let r;return r=e<60?[o,a,0]:e<120?[a,o,0]:e<180?[0,o,a]:e<240?[0,a,o]:e<300?[a,0,o]:[o,0,a],{r:Math.round(255*(r[0]+n)),g:Math.round(255*(r[1]+n)),b:Math.round(255*(r[2]+n))}}(t))}const zr={title:"Color picker",hue:"Hue",saturation:"Saturation",value:"Brightness",hex:"Hex color",invalidHex:"Enter a 3- or 6-digit hex color",confirm:"OK"};class Fr extends Gt{constructor(){super(...arguments),this.label="",this.opacityLabel="Opacity",this.color="#607d8b",this.opacity=1,this.disabled=!1,this.showOpacity=!0,this.pickerLabels=zr,this._open=!1,this._pickerRaf=0,this._emitRaf=0,this._forceFallback=!1,this._overlayDispose=null,this._hue=0,this._saturation=0,this._value=0,this._hexDraft="#607d8b",this._hexInvalid=!1,this._hexNeedsValidInput=!1,this._lastValidColor="#607d8b",this._activePointerId=null,this._outsidePointerDown=t=>{if(!this._open)return;const e=t.composedPath();this._floating.containsPath(e)||this._closePicker(!1,"outside")},this._keyDown=t=>{this._open&&"Escape"===t.key&&(t.preventDefault(),t.stopImmediatePropagation(),this._closePicker(this._floating.ownsActiveElement(),"escape"))},this._floating=new $o(this,"color-opacity",this._keyDown),this._queuePickerPosition=()=>{if(!this._open)return;this._pickerRaf&&cancelAnimationFrame(this._pickerRaf);const t=this._window();t&&(this._pickerRaf=t.requestAnimationFrame(()=>{this._pickerRaf=0,this._positionPicker()||this._closePicker()}))}}connectedCallback(){super.connectedCallback(),this._syncFromColor(this.color,!1),this.ownerDocument.addEventListener("pointerdown",this._outsidePointerDown,!0),this.ownerDocument.addEventListener("scroll",this._queuePickerPosition,!0);const t=this.ownerDocument.defaultView;t?.addEventListener("resize",this._queuePickerPosition),t?.addEventListener("orientationchange",this._queuePickerPosition),t?.visualViewport?.addEventListener("resize",this._queuePickerPosition),t?.visualViewport?.addEventListener("scroll",this._queuePickerPosition),this.addEventListener("keydown",this._keyDown,!0)}disconnectedCallback(){this.ownerDocument.removeEventListener("pointerdown",this._outsidePointerDown,!0),this.ownerDocument.removeEventListener("scroll",this._queuePickerPosition,!0);const t=this.ownerDocument.defaultView;t?.removeEventListener("resize",this._queuePickerPosition),t?.removeEventListener("orientationchange",this._queuePickerPosition),t?.visualViewport?.removeEventListener("resize",this._queuePickerPosition),t?.visualViewport?.removeEventListener("scroll",this._queuePickerPosition),this.removeEventListener("keydown",this._keyDown,!0),this._pickerRaf&&cancelAnimationFrame(this._pickerRaf),this._emitRaf&&cancelAnimationFrame(this._emitRaf),this._pickerRaf=0,this._emitRaf=0,this._closePicker(!1,"disconnect"),super.disconnectedCallback()}updated(t){if(t.has("color")){const t=Ir(this.color);t&&t!==this._lastValidColor&&this._syncFromColor(t,this._open)}this.disabled&&this._open?this._closePicker():this._open&&(this._supportsPopover()||this._renderFallback(),(t.has("color")||t.has("opacity")||t.has("showOpacity")||t.has("label")||t.has("opacityLabel")||t.has("pickerLabels"))&&this._queuePickerPosition())}_window(){return this._floating.window()}_supportsPopover(){return this._floating.usesPopover(this._forceFallback)}_dialog(){return this._floating.dialog()}async _toggle(){this.disabled||(this._open?this._closePicker():(this._forceFallback=!1,this._syncFromColor(this.color,!1),this._hexInvalid=!1,this._hexNeedsValidInput=!1,this._activePointerId=null,this._open=!0,await this.updateComplete,this._open&&(this._supportsPopover()||this._renderFallback(),this._positionPicker()?this._overlayDispose=this._dialog()?.registerOverlay({owner:this,group:"transient",close:t=>this._closePicker("escape"===t&&this._floating.ownsActiveElement(),t)})||null:this._closePicker())))}_closePicker(t=!1,e="exclusive"){if(!this._open&&!this._floating.hasFallback)return;const s=this._overlayDispose;this._overlayDispose=null,s?.();const i=this.renderRoot.querySelector(".picker");if(i?.hidePopover)try{i.matches(":popover-open")&&i.hidePopover()}catch{}this._open=!1,this._cancelQueuedEmit(),this._activePointerId=null,this._floating.destroy(),t&&this.updateComplete.then(()=>this.renderRoot.querySelector(".trigger")?.focus())}_surface(){return this._floating.surface(".picker",this._supportsPopover())}_renderFallback(){const t=Fr.styles.cssText;this._floating.renderFallback(this._pickerTemplate(!1),t)}_positionPicker(){if(!this._open)return!1;const t=this._window(),e=this.renderRoot.querySelector(".trigger");let s=this._surface();if(!t||!e?.isConnected||!s?.isConnected)return!1;const i=wo(t);if(s.style.maxWidth=`${Math.max(0,i.width-16)}px`,s.style.maxHeight=`${Math.max(0,i.height-16)}px`,s.style.visibility="hidden",this._supportsPopover()&&s.showPopover)try{s.matches(":popover-open")||s.showPopover()}catch{if(this._forceFallback=!0,this._renderFallback(),s=this._surface(),!s?.isConnected)return!1;s.style.maxWidth=`${Math.max(0,i.width-16)}px`,s.style.maxHeight=`${Math.max(0,i.height-16)}px`,s.style.visibility="hidden"}const o=e.getBoundingClientRect(),a=s.getBoundingClientRect();if(!(o.width&&o.height&&a.width&&a.height))return!1;const n=ko(o,a,i);return s.style.left=`${n.left}px`,s.style.top=`${n.top}px`,s.dataset.side=n.side,s.style.visibility="",!0}_labels(){const t=this.pickerLabels||zr;return{title:t.title||zr.title,hue:t.hue||zr.hue,saturation:t.saturation||zr.saturation,value:t.value||zr.value,hex:t.hex||zr.hex,invalidHex:t.invalidHex||zr.invalidHex,confirm:t.confirm||zr.confirm}}_syncFromColor(t,e){const s=Ir(qt(t,"#607d8b"))||"#607d8b",i=Lr(s);if(!i)return;const o=Tr(i);(!e||o.s>1e-4)&&(this._hue=o.h),this._saturation=o.s,this._value=o.v,this._hexDraft=s,this._hexInvalid=!1,this._hexNeedsValidInput=!1,this._lastValidColor=s}_cancelQueuedEmit(t=!1){this._emitRaf&&cancelAnimationFrame(this._emitRaf),this._emitRaf=0,t&&this._syncFromColor(this._lastValidColor,!0)}_queueHsvEmit(){if(this._emitRaf)return;const t=this._window();t?this._emitRaf=t.requestAnimationFrame(()=>{this._emitRaf=0,this._emitHsv()}):this._emitHsv()}_emitHsv(){this._emit(Rr({h:this._hue,s:this._saturation,v:this._value}),this.opacity)}_setHue(t){this._hue=Math.min(359,Math.max(0,Number.isFinite(t)?t:0)),this._emitHsv()}_setSaturation(t){this._saturation=Math.min(100,Math.max(0,Number.isFinite(t)?t:0)),this._emitHsv()}_setValue(t){this._value=Math.min(100,Math.max(0,Number.isFinite(t)?t:0)),this._emitHsv()}_setOpacity(t){this._emit(this._lastValidColor,t)}_shiftRangeKey(t,e,s,i,o){if(!t.shiftKey)return;const a="ArrowRight"===t.key||"ArrowUp"===t.key?10:"ArrowLeft"===t.key||"ArrowDown"===t.key?-10:0;a&&(t.preventDefault(),t.stopPropagation(),o(Math.min(i,Math.max(s,e+a))))}_setSvFromPointer(t,e){const s=t.currentTarget.getBoundingClientRect();s.width&&s.height&&(this._saturation=Math.min(100,Math.max(0,(t.clientX-s.left)/s.width*100)),this._value=Math.min(100,Math.max(0,100*(1-(t.clientY-s.top)/s.height))),e?(this._cancelQueuedEmit(),this._emitHsv()):this._queueHsvEmit())}_svPointerDown(t){if(t.preventDefault(),t.stopPropagation(),null===this._activePointerId){this._activePointerId=t.pointerId;try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}this._setSvFromPointer(t,!0)}}_svPointerMove(t){t.pointerId===this._activePointerId&&(t.preventDefault(),t.stopPropagation(),this._setSvFromPointer(t,!1))}_svPointerUp(t){if(t.pointerId===this._activePointerId){t.preventDefault(),t.stopPropagation(),this._setSvFromPointer(t,!0),this._activePointerId=null;try{t.currentTarget.releasePointerCapture(t.pointerId)}catch{}}}_svPointerCancel(t){t.pointerId===this._activePointerId&&(t.preventDefault(),t.stopPropagation(),this._activePointerId=null,this._cancelQueuedEmit(!0))}_svLostPointerCapture(t){t.pointerId===this._activePointerId&&(this._activePointerId=null,this._cancelQueuedEmit(!0))}_hexInput(t){const e=t.target.value;this._hexDraft=e;const s=Ir(e),i=s?Lr(s):null;if(!s||!i)return void(this._hexInvalid=this._hexNeedsValidInput);this._hexNeedsValidInput=!1,this._hexInvalid=!1;const o=Tr(i);o.s>1e-4&&(this._hue=o.h),this._saturation=o.s,this._value=o.v,this._emit(s,this.opacity,!0)}_commitHex(){const t=Ir(this._hexDraft);if(!t)return this._hexDraft=this._lastValidColor,this._hexInvalid=!0,void(this._hexNeedsValidInput=!0);this._hexDraft=t,this._hexNeedsValidInput?this._hexInvalid=!0:(this._hexInvalid=!1,t!==this._lastValidColor&&this._emit(t,this.opacity))}_confirm(t){t.preventDefault(),t.stopPropagation(),this._commitHex(),this._hexInvalid||this._hexNeedsValidInput?this.updateComplete.then(()=>{this._surface()?.querySelector('input[type="text"]')?.focus()}):this._closePicker(!0)}_hexKeyDown(t){"Enter"===t.key&&(t.preventDefault(),t.stopPropagation(),this._commitHex())}_emit(t,e,s=!1){const i=Ir(t)||this._lastValidColor,o=Number.isFinite(e)?e:Number(this.opacity)||0,a=Math.min(1,Math.max(0,o));this.color=i,this.opacity=a,this._lastValidColor=i,s||(this._hexDraft=i),this._hexInvalid=this._hexNeedsValidInput,this.dispatchEvent(new CustomEvent("hp-color-opacity-change",{detail:{color:i,opacity:a},bubbles:!0,composed:!0}))}_pickerTemplate(t){const e=Math.round(100*Math.min(1,Math.max(0,Number(this.opacity)||0))),s=Rr({h:this._hue,s:this._saturation,v:this._value}),i=Rr({h:this._hue,s:100,v:100}),o=this._labels(),a=Math.round(this._hue),n=Math.round(this._saturation),r=Math.round(this._value);return p` + `},Mr=(t,e)=>{const s=t._deviceDrag;if(!s)return;const i=t._devices.find(t=>t.id===s.id),o=[...e.querySelectorAll('[data-hp="device"]')].find(t=>t.dataset.id===s.id);if(!i||!o)return;const a=t._livePos(i),n=t._scenePoint([a.x,a.y]),r=t._viewOr(t._baseVb());o.style.left=(n[0]-r.x)/r.w*100+"%",o.style.top=(n[1]-r.y)/r.h*100+"%"},Cr=(t,e,s)=>{for(const i of e.querySelectorAll('.decorlayer [data-hp="decor"]'))i.closest("[data-hp-live-editor]")||i.dataset.id!==s||"0"!==i.style.opacity&&(i.style.opacity="0",t.transparent.push(i))},Sr=(t,e,s)=>{const i=new Set(s);for(const s of e.querySelectorAll('.openinglayer [data-hp="opening"]'))!s.closest("[data-hp-live-editor]")&&i.has(s.dataset.id||"")&&(s.style.opacity="0",t.transparent.push(s))},Pr=(t,e,s)=>{for(const i of e.querySelectorAll(s))i.closest("[data-hp-live-editor]")||(i.style.opacity="0.35",t.dimmed.push(i))};const Dr=(t,e,s)=>Math.min(s,Math.max(e,Number.isFinite(t)?t:e));function Ir(t){return Number.isFinite(t)?(t%360+360)%360:0}function Lr(t){if("string"!=typeof t)return null;const e=t.trim().replace(/^#/,""),s=/^[0-9a-fA-F]{3}$/.test(e)?e.split("").map(t=>`${t}${t}`).join(""):e;return/^[0-9a-fA-F]{6}$/.test(s)?`#${s.toLowerCase()}`:null}function Tr(t){const e=Lr(t);return e?{r:Number.parseInt(e.slice(1,3),16),g:Number.parseInt(e.slice(3,5),16),b:Number.parseInt(e.slice(5,7),16)}:null}function Rr(t){const e=Dr(t.r,0,255)/255,s=Dr(t.g,0,255)/255,i=Dr(t.b,0,255)/255,o=Math.max(e,s,i),a=o-Math.min(e,s,i);let n=0;return a>0&&(n=o===e?(s-i)/a%6*60:o===s?60*((i-e)/a+2):60*((e-s)/a+4)),{h:Ir(n),s:0===o?0:a/o*100,v:100*o}}function zr(t){return function(t){const e=t=>Math.round(Dr(t,0,255)).toString(16).padStart(2,"0");return`#${e(t.r)}${e(t.g)}${e(t.b)}`}(function(t){const e=Ir(t.h),s=Dr(t.s,0,100)/100,i=Dr(t.v,0,100)/100,o=i*s,a=o*(1-Math.abs(e/60%2-1)),n=i-o;let r;return r=e<60?[o,a,0]:e<120?[a,o,0]:e<180?[0,o,a]:e<240?[0,a,o]:e<300?[a,0,o]:[o,0,a],{r:Math.round(255*(r[0]+n)),g:Math.round(255*(r[1]+n)),b:Math.round(255*(r[2]+n))}}(t))}const Fr={title:"Color picker",hue:"Hue",saturation:"Saturation",value:"Brightness",hex:"Hex color",invalidHex:"Enter a 3- or 6-digit hex color",confirm:"OK"};class Nr extends Gt{constructor(){super(...arguments),this.label="",this.opacityLabel="Opacity",this.color="#607d8b",this.opacity=1,this.disabled=!1,this.showOpacity=!0,this.pickerLabels=Fr,this._open=!1,this._pickerRaf=0,this._emitRaf=0,this._forceFallback=!1,this._overlayDispose=null,this._hue=0,this._saturation=0,this._value=0,this._hexDraft="#607d8b",this._hexInvalid=!1,this._hexNeedsValidInput=!1,this._lastValidColor="#607d8b",this._activePointerId=null,this._outsidePointerDown=t=>{if(!this._open)return;const e=t.composedPath();this._floating.containsPath(e)||this._closePicker(!1,"outside")},this._keyDown=t=>{this._open&&"Escape"===t.key&&(t.preventDefault(),t.stopImmediatePropagation(),this._closePicker(this._floating.ownsActiveElement(),"escape"))},this._floating=new $o(this,"color-opacity",this._keyDown),this._queuePickerPosition=()=>{if(!this._open)return;this._pickerRaf&&cancelAnimationFrame(this._pickerRaf);const t=this._window();t&&(this._pickerRaf=t.requestAnimationFrame(()=>{this._pickerRaf=0,this._positionPicker()||this._closePicker()}))}}connectedCallback(){super.connectedCallback(),this._syncFromColor(this.color,!1),this.ownerDocument.addEventListener("pointerdown",this._outsidePointerDown,!0),this.ownerDocument.addEventListener("scroll",this._queuePickerPosition,!0);const t=this.ownerDocument.defaultView;t?.addEventListener("resize",this._queuePickerPosition),t?.addEventListener("orientationchange",this._queuePickerPosition),t?.visualViewport?.addEventListener("resize",this._queuePickerPosition),t?.visualViewport?.addEventListener("scroll",this._queuePickerPosition),this.addEventListener("keydown",this._keyDown,!0)}disconnectedCallback(){this.ownerDocument.removeEventListener("pointerdown",this._outsidePointerDown,!0),this.ownerDocument.removeEventListener("scroll",this._queuePickerPosition,!0);const t=this.ownerDocument.defaultView;t?.removeEventListener("resize",this._queuePickerPosition),t?.removeEventListener("orientationchange",this._queuePickerPosition),t?.visualViewport?.removeEventListener("resize",this._queuePickerPosition),t?.visualViewport?.removeEventListener("scroll",this._queuePickerPosition),this.removeEventListener("keydown",this._keyDown,!0),this._pickerRaf&&cancelAnimationFrame(this._pickerRaf),this._emitRaf&&cancelAnimationFrame(this._emitRaf),this._pickerRaf=0,this._emitRaf=0,this._closePicker(!1,"disconnect"),super.disconnectedCallback()}updated(t){if(t.has("color")){const t=Lr(this.color);t&&t!==this._lastValidColor&&this._syncFromColor(t,this._open)}this.disabled&&this._open?this._closePicker():this._open&&(this._supportsPopover()||this._renderFallback(),(t.has("color")||t.has("opacity")||t.has("showOpacity")||t.has("label")||t.has("opacityLabel")||t.has("pickerLabels"))&&this._queuePickerPosition())}_window(){return this._floating.window()}_supportsPopover(){return this._floating.usesPopover(this._forceFallback)}_dialog(){return this._floating.dialog()}async _toggle(){this.disabled||(this._open?this._closePicker():(this._forceFallback=!1,this._syncFromColor(this.color,!1),this._hexInvalid=!1,this._hexNeedsValidInput=!1,this._activePointerId=null,this._open=!0,await this.updateComplete,this._open&&(this._supportsPopover()||this._renderFallback(),this._positionPicker()?this._overlayDispose=this._dialog()?.registerOverlay({owner:this,group:"transient",close:t=>this._closePicker("escape"===t&&this._floating.ownsActiveElement(),t)})||null:this._closePicker())))}_closePicker(t=!1,e="exclusive"){if(!this._open&&!this._floating.hasFallback)return;const s=this._overlayDispose;this._overlayDispose=null,s?.();const i=this.renderRoot.querySelector(".picker");if(i?.hidePopover)try{i.matches(":popover-open")&&i.hidePopover()}catch{}this._open=!1,this._cancelQueuedEmit(),this._activePointerId=null,this._floating.destroy(),t&&this.updateComplete.then(()=>this.renderRoot.querySelector(".trigger")?.focus())}_surface(){return this._floating.surface(".picker",this._supportsPopover())}_renderFallback(){const t=Nr.styles.cssText;this._floating.renderFallback(this._pickerTemplate(!1),t)}_positionPicker(){if(!this._open)return!1;const t=this._window(),e=this.renderRoot.querySelector(".trigger");let s=this._surface();if(!t||!e?.isConnected||!s?.isConnected)return!1;const i=wo(t);if(s.style.maxWidth=`${Math.max(0,i.width-16)}px`,s.style.maxHeight=`${Math.max(0,i.height-16)}px`,s.style.visibility="hidden",this._supportsPopover()&&s.showPopover)try{s.matches(":popover-open")||s.showPopover()}catch{if(this._forceFallback=!0,this._renderFallback(),s=this._surface(),!s?.isConnected)return!1;s.style.maxWidth=`${Math.max(0,i.width-16)}px`,s.style.maxHeight=`${Math.max(0,i.height-16)}px`,s.style.visibility="hidden"}const o=e.getBoundingClientRect(),a=s.getBoundingClientRect();if(!(o.width&&o.height&&a.width&&a.height))return!1;const n=ko(o,a,i);return s.style.left=`${n.left}px`,s.style.top=`${n.top}px`,s.dataset.side=n.side,s.style.visibility="",!0}_labels(){const t=this.pickerLabels||Fr;return{title:t.title||Fr.title,hue:t.hue||Fr.hue,saturation:t.saturation||Fr.saturation,value:t.value||Fr.value,hex:t.hex||Fr.hex,invalidHex:t.invalidHex||Fr.invalidHex,confirm:t.confirm||Fr.confirm}}_syncFromColor(t,e){const s=Lr(qt(t,"#607d8b"))||"#607d8b",i=Tr(s);if(!i)return;const o=Rr(i);(!e||o.s>1e-4)&&(this._hue=o.h),this._saturation=o.s,this._value=o.v,this._hexDraft=s,this._hexInvalid=!1,this._hexNeedsValidInput=!1,this._lastValidColor=s}_cancelQueuedEmit(t=!1){this._emitRaf&&cancelAnimationFrame(this._emitRaf),this._emitRaf=0,t&&this._syncFromColor(this._lastValidColor,!0)}_queueHsvEmit(){if(this._emitRaf)return;const t=this._window();t?this._emitRaf=t.requestAnimationFrame(()=>{this._emitRaf=0,this._emitHsv()}):this._emitHsv()}_emitHsv(){this._emit(zr({h:this._hue,s:this._saturation,v:this._value}),this.opacity)}_setHue(t){this._hue=Math.min(359,Math.max(0,Number.isFinite(t)?t:0)),this._emitHsv()}_setSaturation(t){this._saturation=Math.min(100,Math.max(0,Number.isFinite(t)?t:0)),this._emitHsv()}_setValue(t){this._value=Math.min(100,Math.max(0,Number.isFinite(t)?t:0)),this._emitHsv()}_setOpacity(t){this._emit(this._lastValidColor,t)}_shiftRangeKey(t,e,s,i,o){if(!t.shiftKey)return;const a="ArrowRight"===t.key||"ArrowUp"===t.key?10:"ArrowLeft"===t.key||"ArrowDown"===t.key?-10:0;a&&(t.preventDefault(),t.stopPropagation(),o(Math.min(i,Math.max(s,e+a))))}_setSvFromPointer(t,e){const s=t.currentTarget.getBoundingClientRect();s.width&&s.height&&(this._saturation=Math.min(100,Math.max(0,(t.clientX-s.left)/s.width*100)),this._value=Math.min(100,Math.max(0,100*(1-(t.clientY-s.top)/s.height))),e?(this._cancelQueuedEmit(),this._emitHsv()):this._queueHsvEmit())}_svPointerDown(t){if(t.preventDefault(),t.stopPropagation(),null===this._activePointerId){this._activePointerId=t.pointerId;try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}this._setSvFromPointer(t,!0)}}_svPointerMove(t){t.pointerId===this._activePointerId&&(t.preventDefault(),t.stopPropagation(),this._setSvFromPointer(t,!1))}_svPointerUp(t){if(t.pointerId===this._activePointerId){t.preventDefault(),t.stopPropagation(),this._setSvFromPointer(t,!0),this._activePointerId=null;try{t.currentTarget.releasePointerCapture(t.pointerId)}catch{}}}_svPointerCancel(t){t.pointerId===this._activePointerId&&(t.preventDefault(),t.stopPropagation(),this._activePointerId=null,this._cancelQueuedEmit(!0))}_svLostPointerCapture(t){t.pointerId===this._activePointerId&&(this._activePointerId=null,this._cancelQueuedEmit(!0))}_hexInput(t){const e=t.target.value;this._hexDraft=e;const s=Lr(e),i=s?Tr(s):null;if(!s||!i)return void(this._hexInvalid=this._hexNeedsValidInput);this._hexNeedsValidInput=!1,this._hexInvalid=!1;const o=Rr(i);o.s>1e-4&&(this._hue=o.h),this._saturation=o.s,this._value=o.v,this._emit(s,this.opacity,!0)}_commitHex(){const t=Lr(this._hexDraft);if(!t)return this._hexDraft=this._lastValidColor,this._hexInvalid=!0,void(this._hexNeedsValidInput=!0);this._hexDraft=t,this._hexNeedsValidInput?this._hexInvalid=!0:(this._hexInvalid=!1,t!==this._lastValidColor&&this._emit(t,this.opacity))}_confirm(t){t.preventDefault(),t.stopPropagation(),this._commitHex(),this._hexInvalid||this._hexNeedsValidInput?this.updateComplete.then(()=>{this._surface()?.querySelector('input[type="text"]')?.focus()}):this._closePicker(!0)}_hexKeyDown(t){"Enter"===t.key&&(t.preventDefault(),t.stopPropagation(),this._commitHex())}_emit(t,e,s=!1){const i=Lr(t)||this._lastValidColor,o=Number.isFinite(e)?e:Number(this.opacity)||0,a=Math.min(1,Math.max(0,o));this.color=i,this.opacity=a,this._lastValidColor=i,s||(this._hexDraft=i),this._hexInvalid=this._hexNeedsValidInput,this.dispatchEvent(new CustomEvent("hp-color-opacity-change",{detail:{color:i,opacity:a},bubbles:!0,composed:!0}))}_pickerTemplate(t){const e=Math.round(100*Math.min(1,Math.max(0,Number(this.opacity)||0))),s=zr({h:this._hue,s:this._saturation,v:this._value}),i=zr({h:this._hue,s:100,v:100}),o=this._labels(),a=Math.round(this._hue),n=Math.round(this._saturation),r=Math.round(this._value);return p` `}afterRender(){const t=this.host.root();this._blocked&&(this._openGroupId?this.closeGroup(!1):"palette"===this._currentModel?.kind&&this._currentModel.dismiss?.()),this._syncGlobalDismissListener();const e=t.querySelector(".editor-secondary"),s=this._renderedContext,i=e?.dataset.contextId||"";if(i&&s&&i!==s&&!window.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches&&(this._contentAnimation?.cancel(),this._contentAnimation=e?.querySelector(".editor-secondary-content")?.animate([{opacity:.35,transform:"translateY(-4px)"},{opacity:1,transform:"translateY(0)"}],{duration:100,easing:"ease-out"})),this._renderedContext=i,s&&i!==s&&this._focusOwned){const s=i?e?.querySelector('[tabindex="0"], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])'):t.querySelector(".editbar-tools");s?.focus?.(),this._focusOwned=!!i}if("palette"===this._currentModel?.kind&&this._currentModel.launcherId){const e=[...t.querySelectorAll("[data-editor-palette]")].find(t=>t.dataset.editorPalette===this._currentModel?.launcherId);e&&null!==e.offsetParent||this._currentModel.dismiss?.()}if(!this._openGroupId)return;const o=[...t.querySelectorAll("[data-editor-group]")].find(t=>t.dataset.editorGroup===this._openGroupId);o&&null!==o.offsetParent||this.closeGroup(!0)}handleOutsideDismiss(t){if(Ac(t,t=>t.hasAttribute("data-editor-navigation")))return"pointerdown"===t.type?this.closeForNavigation():"click"===t.type&&this._dismissPointerTarget&&this._clearDismissClick(),!1;if("click"===t.type&&this._dismissPointerTarget){return!!(t.composedPath?.()||[t.target]).includes(this._dismissPointerTarget)&&(this._clearDismissClick(),t.preventDefault(),t.stopImmediatePropagation(),!0)}const e=this._openGroupId||this._blocked||"palette"!==this._currentModel?.kind?null:this._currentModel;if("pointerdown"===t.type&&(this._openGroupId||e)){const s=Ac(t,t=>t.classList.contains("editor-secondary")),i=Ac(t,t=>!!t.dataset.editorGroup),o=Ac(t,t=>!!t.dataset.editorPalette),a=Ac(t,t=>t.classList.contains("stage"));if(!(s||i||o||"stay-open-on-canvas"===e?.dismissPolicy&&a))return t.preventDefault(),t.stopImmediatePropagation(),this._dismissPointerTarget=t.target,clearTimeout(this._dismissTimer),this._dismissTimer=window.setTimeout(()=>{this._clearDismissClick()},800),this._openGroupId?this.closeGroup(!1):e?.dismiss?.(),this._syncGlobalDismissListener(),!0}return!1}_activateGroupItem(t,e,s){if(t.id!==this._openGroupId)return;const i=t.items.find(t=>t.id===e);if(!i||i.disabled)return;const o="toggle"===i.role&&"stay-open"===i.closePolicy,a=0===s.detail;o||(this._openGroupId=null,this.host.requestUpdate(),this._syncGlobalDismissListener()),i.invoke(),!o&&a&&this.host.updateComplete().then(()=>{const e=[...this.host.root().querySelectorAll("[data-editor-group]")].find(e=>e.dataset.editorGroup===t.id&&null!==e.offsetParent);e?.focus()})}_groupKeydown(t){if(!["ArrowLeft","ArrowRight","Home","End"].includes(t.key))return;const e=[...t.currentTarget.querySelectorAll(".editor-group-item:not([disabled])")];if(!e.length)return;t.preventDefault();const s=e.indexOf(this.host.root().activeElement),i="Home"===t.key?0:"End"===t.key?e.length-1:"ArrowLeft"===t.key?s<=0?e.length-1:s-1:(s+1)%e.length;e[i]?.focus()}_clearDismissClick(){this._dismissPointerTarget=null,clearTimeout(this._dismissTimer),this._dismissTimer=void 0,this._syncGlobalDismissListener()}_syncGlobalDismissListener(){const t=!this._blocked&&"palette"===this._currentModel?.kind,e=!!this._openGroupId||t||!!this._dismissPointerTarget;e!==this._globalDismissListening&&(this._globalDismissListening=e,e?(window.addEventListener("pointerdown",this._globalDismissGuard,!0),window.addEventListener("click",this._globalDismissGuard,!0)):(window.removeEventListener("pointerdown",this._globalDismissGuard,!0),window.removeEventListener("click",this._globalDismissGuard,!0)))}}const Oc=t=>t.stopPropagation(),Hc=new WeakSet,Bc=t=>{t._regSignature="",t._maybeRebuildDevices(),t.requestUpdate()};async function Wc(t,e,s,i,o,a=""){const n=t.host,r=n._serverCfg;if(!r)return!1;let l=JSON.parse(JSON.stringify(r));l.markers=l.markers||[];let h=l.markers.find(t=>t.id===e);if(!h){const t=n._devices.find(t=>t.id===e);if(!t||"device"!==t.bindingKind&&"entity"!==t.bindingKind||!t.bindingRef)return!1;h={id:t.id,binding:`${t.bindingKind}:${t.bindingRef}`,space:t.space||null,area:t.area||null,hidden:!!t.hidden},l.markers.push(h)}h.vacuum=function(t,e){const s=e.matrix.map(t=>Number(t.toFixed(6))),i=t?.map_routes;if(Array.isArray(i)&&i.length){const o=i.find(t=>t.id===e.routeId)||i.find(t=>t.source===e.source&&t.map_id===e.mapId);if(o)return{...t,map_routes:jo(i,o.id,s)}}return{...t,source:e.source,calibration:{...t?.calibration||{},[e.mapId]:s}}}(h.vacuum||{},{source:s,mapId:i,routeId:a,matrix:o}),l=t._prepareConfigCandidate(l);const c=n._adoption.beginOptimistic(r,l);n._adoption.stageLocalConfig(l),Bc(n),n._saveConfigDebounced.pending()&&n._saveConfigDebounced.cancel();try{return await t._saveConfigNow(c),!0}catch(t){return n._rollbackOptimistic(c),Bc(n),n._showToast(n._t("toast.cfg_save_failed",{err:n._errText(t)})),!1}}function jc(t){return 1===t}function Gc(t){return`${t}-${globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}`}function qc(t){const e=function(t){return JSON.stringify({message:t.message.trim(),contact:t.contact.trim(),previewToken:t.attach&&t.preview?t.preview.token:""})}(t);return{idempotencyKey:t.submissionFingerprint&&t.submissionFingerprint!==e?Gc("report"):t.idempotencyKey,fingerprint:e}}function Uc(t){return[...t].length}function Kc(t,e=Date.now()){const s=t.message.trim();return s?Uc(s)>1e4?"message_too_long":Uc(t.contact.trim())>320?"contact_too_long":t.attach&&!t.preview?"preview_missing":t.attach&&t.preview.expiresAt<=e?"preview_expired":null:"message_required"}function Vc(t,e=Date.now()){return"building"!==t.status&&"sending"!==t.status&&"success"!==t.status&&null===Kc(t,e)}function Jc(t){const e=function(t){const e=/Firefox\/(\d+)/i.exec(t);if(e)return{family:"firefox",major:Number(e[1])||0};const s=/(?:Chrome|Chromium|Edg)\/(\d+)/i.exec(t);if(s)return{family:"chromium",major:Number(s[1])||0};const i=/Version\/(\d+).+Safari\//i.exec(t);return i?{family:"webkit",major:Number(i[1])||0}:{family:"unknown",major:0}}(t.userAgent??globalThis.navigator?.userAgent??""),s=t.now??Date.now(),i=Number(t.registryLastSuccess||0),o=i<=0?"unknown":s-i<=6e5?"fresh":"stale",a=["en","ru","de","fr"].includes(t.language)?t.language:"en",n=globalThis.matchMedia?.bind(globalThis);return{browser_family:e.family,browser_major:Math.max(0,Math.min(999,e.major)),language:a,coarse_pointer:t.coarsePointer??!!n?.("(pointer: coarse)").matches,hover_capable:t.hoverCapable??!!n?.("(hover: hover)").matches,registry_access:"full"===t.registryAccess?"full":"limited"===t.registryAccess?"partial":"unavailable",registry_age_bucket:o}}function Zc(t){const e=t&&"object"==typeof t&&"code"in t?String(t.code||""):"";return new Set(["support_invalid_message","support_preview_expired","support_package_too_large","support_rate_limited","support_unavailable","support_rejected","unauthorized"]).has(e)?e:"support_unavailable"}const Yc=[{id:"air_conditioner",group:"appliance",art:{d:"M85 71.5 L85 63 M25 71.5 L25 63 M25 71.5 L89.5 71.5 C90.8807 71.5 92 70.3807 92 69 L92 41.5 C92 40.1193 90.8807 39 89.5 39 L20.5 39 C19.1193 39 18 40.1193 18 41.5 L18 69 C18 70.3807 19.1193 71.5 20.5 71.5 L25 71.5 Z M85 63 C85 61.6193 83.8807 60.5 82.5 60.5 L27.5 60.5 C26.1193 60.5 25 61.6193 25 63 M85 63 L85 66.5 L25 66.5 L25 63",viewW:110,viewH:110}},{id:"armchair",group:"furniture",art:{d:"M77.5 48.5 L77.5 39 C77.5 33.4772 73.0228 29 67.5 29 L42.5 29 C36.9772 29 32.5 33.4772 32.5 39 L32.5 48.5205 M77.5 48.5 C80.8137 48.5 83.5 51.1863 83.5 54.5 C83.5 57.1123 81.8302 59.3334 79.5 60.1572 L79.5 71.5 C79.5 73.7091 77.7091 75.5 75.5 75.5 M77.5 48.5 C74.2576 48.5 71.617 51.072 71.5049 54.2871 C71.5012 54.3576 71.5 54.4286 71.5 54.5 L71.5 61.75 M38 61.75 L38 54 C38 53.2396 37.7873 52.5291 37.4189 51.9238 C36.5228 50.0421 34.6765 48.7002 32.5 48.5205 M32.5 48.5205 C32.3351 48.5069 32.1684 48.5 32 48.5 M75.5 75.5 L34 75.5 M75.5 75.5 L72.5 75.5 M34 75.5 C31.7909 75.5 30 73.7091 30 71.5 L30 60.1572 C27.6698 59.3334 26 57.1123 26 54.5 C26 51.1863 28.6863 48.5 32 48.5 M34 75.5 L36.5 75.5 M32 48.5 C34.3914 48.5 36.4549 49.8996 37.4189 51.9238 M38 61.75 C38 64.3734 40.1266 66.5 42.75 66.5 L66.75 66.5 C69.3734 66.5 71.5 64.3734 71.5 61.75 M38 61.75 C38 59.1266 40.1266 57 42.75 57 L66.75 57 C69.3734 57 71.5 59.1266 71.5 61.75 M36.5 75.5 L44.5 75.5 M36.5 75.5 L36.5 80.5 C36.5 81.3284 37.1716 82 38 82 L41.3921 82 C42.0506 82 42.6321 81.5705 42.8258 80.9411 L44.5 75.5 M44.5 75.5 L64.5 75.5 M72.5 75.5 L64.5 75.5 M72.5 75.5 L72.5 80.5 C72.5 81.3284 71.8284 82 71 82 L67.6079 82 C66.9494 82 66.3679 81.5705 66.1742 80.9411 L64.5 75.5",viewW:110,viewH:110}},{id:"bathtub",group:"sanitary",art:{d:"M28 74.8457 L28 80 C28 80.8284 28.6716 81.5 29.5 81.5 L32.8921 81.5 C33.5506 81.5 34.1321 81.0705 34.3258 80.4411 L35.6923 76 M28.0191 74.8558 C28.0127 74.8524 28.0063 74.8491 28 74.8457 C25.4198 73.4833 23.483 71.0169 22.8673 67.9996 M19.5 51.5 L90 51.5 M19.5 51.5 C18.1193 51.5 17 50.3807 17 49 C17 47.6193 18.1193 46.5 19.5 46.5 M19.5 51.5 L22.8673 67.9996 M90 51.5 C91.3807 51.5 92.5 50.3807 92.5 49 C92.5 47.6193 91.3807 46.5 90 46.5 M90 51.5 L86.6327 67.9996 C85.9778 71.2088 83.8285 73.7948 81 75.0922 M90 46.5 L19.5 46.5 M90 46.5 L20 46.5 M19.5 46.5 L20 46.5 M22.8673 67.9996 C23.4846 71.0243 25.4293 73.4954 28.0191 74.8558 M30 36 L30 34 C30 32.6739 29.4732 31.4021 28.5355 30.4645 C27.5979 29.5268 26.3261 29 25 29 C23.6739 29 22.4021 29.5268 21.4645 30.4645 C20.5268 31.4021 20 32.6739 20 34 L20 46.5 M81 75.0922 C79.7247 75.6771 78.3114 76 76.8347 76 L73.3077 76 M81 75.0922 L81 80 C81 80.8284 80.3284 81.5 79.5 81.5 L76.1079 81.5 C75.4494 81.5 74.8679 81.0705 74.6742 80.4411 L73.3077 76 M73.3077 76 L35.6923 76 M35.6923 76 L32.6653 76 C31.1128 76 29.6303 75.643 28.3047 75 C28.2086 74.9534 28.1134 74.9053 28.0191 74.8558",viewW:110,viewH:110}},{id:"bed",group:"furniture",art:{d:"M16 75.5 L24 75.5 M16 75.5 L16 80.5 C16 81.3284 16.6716 82 17.5 82 L20.8921 82 C21.5506 82 22.1321 81.5705 22.3258 80.9411 L24 75.5 M16 75.5 L15 75.5 M24 75.5 L86.5 75.5 M94.5 75.5 L86.5 75.5 M94.5 75.5 L94.5 80.5 C94.5 81.3284 93.8284 82 93 82 L89.6079 82 C88.9494 82 88.3679 81.5705 88.1742 80.9411 L86.5 75.5 M94.5 75.5 L95.5 75.5 M88 50.1296 L88 31.5 C88 30.1193 86.8807 29 85.5 29 L25 29 C23.6193 29 22.5 30.1193 22.5 31.5 L22.5 50.1296 M87.9383 50.1068 C87.9589 50.1143 87.9795 50.1219 88 50.1296 C91.7967 51.5483 94.5 55.2085 94.5 59.5 M22.5617 50.1068 C22.5411 50.1143 22.5205 50.1219 22.5 50.1296 C18.7033 51.5483 16 55.2085 16 59.5 M94.5 65.5 L94.5 59.5 M94.5 65.5 L16 65.5 M94.5 65.5 L95.5 65.5 M16 65.5 L16 59.5 M16 65.5 L15 65.5 M84.5 49.5 L26 49.5 M84.5 49.5 L80 49.5 M94.5 59.5 C94.5 55.1853 91.7674 51.5088 87.9383 50.1068 C86.8662 49.7142 85.7081 49.5 84.5 49.5 M26 49.5 L30.5 49.5 M16 59.5 C16 55.1853 18.7326 51.5088 22.5617 50.1068 C23.6338 49.7142 24.7919 49.5 26 49.5 M15 75.5 L95.5 75.5 M15 75.5 C14.4477 75.5 14 75.0523 14 74.5 L14 66.5 C14 65.9477 14.4477 65.5 15 65.5 M95.5 75.5 C96.0523 75.5 96.5 75.0523 96.5 74.5 L96.5 66.5 C96.5 65.9477 96.0523 65.5 95.5 65.5 M95.5 65.5 L15 65.5 M51.5 49.5 L51.5 45.5 C51.5 42.7386 49.2614 40.5 46.5 40.5 L35.5 40.5 C32.7386 40.5 30.5 42.7386 30.5 45.5 L30.5 49.5 M51.5 49.5 L30.5 49.5 M51.5 49.5 L59 49.5 M80 49.5 L80 45.5 C80 42.7386 77.7614 40.5 75 40.5 L64 40.5 C61.2386 40.5 59 42.7386 59 45.5 L59 49.5 M80 49.5 L59 49.5",viewW:110,viewH:110}},{id:"bidet",group:"sanitary",art:{d:"M46 67.5 L64.5 67.5 M46 67.5 C40.4772 67.5 36 63.0228 36 57.5 L36 53 M46 67.5 C45.4902 67.5 44.9893 67.4618 44.5 67.3882 L44.5 79.5 C44.5 80.0523 44.9477 80.5 45.5 80.5 L65 80.5 C65.5523 80.5 66 80.0523 66 79.5 L66 67.3882 C65.5107 67.4618 65.0098 67.5 64.5 67.5 M64.5 67.5 C70.0229 67.5 74.5 63.0228 74.5 57.5 L74.5 53 M74.5 53 L74.5 47.5 C74.5 46.9477 74.0523 46.5 73.5 46.5 M74.5 53 L36 53 M36 53 L36 47.5 C36 46.9477 36.4477 46.5 37 46.5 M73.5 46.5 L37 46.5 M73.5 46.5 L60 46.5 M37 46.5 L50.5 46.5 M51.5 40 L59 40 M51.5 40 C50.9477 40 50.5 40.4477 50.5 41 L50.5 46.5 M51.5 40 L53 40 M59 40 C59.5523 40 60 40.4477 60 41 L60 46.5 M59 40 L57.5 40 M60 46.5 L50.5 46.5 M57.5 40 L57.5 30 C57.5 29.4477 57.0523 29 56.5 29 L54 29 C53.4477 29 53 29.4477 53 30 M57.5 40 L53 40 M53 40 L53 30 M53 40 L53 36 M53 30 L53 31.5 M53 31.5 L49 31.5 C48.4477 31.5 48 31.9477 48 32.5 L48 35 C48 35.5523 48.4477 36 49 36 L53 36 M53 31.5 L53 36",viewW:110,viewH:110}},{id:"boiler",group:"appliance",art:{d:"M51.5 81.5 L51.5 86 C51.5 86.5523 51.0523 87 50.5 87 L47.5 87 C46.9477 87 46.5 86.5523 46.5 86 L46.5 81.5 M51.5 81.5 L46.5 81.5 M51.5 81.5 L59 81.5 M46.5 81.5 L44 81.5 M64 81.5 L64 86 C64 86.5523 63.5523 87 63 87 L60 87 C59.4477 87 59 86.5523 59 86 L59 81.5 M64 81.5 L59 81.5 M64 81.5 L66.5 81.5 M74.5 73 L74.5 73.5 C74.5 77.9183 70.9183 81.5 66.5 81.5 M44 81.5 C39.5817 81.5 36 77.9183 36 73.5 L36 73 L36 31 C36 26.5817 39.5817 23 44 23 L66.5 23 C70.9183 23 74.5 26.5817 74.5 31 L74.5 73 M74.5 73 L36 73 M66.5 81.5 L44 81.5 M55 42.5 L58.5 39 M62.5 42.5 C62.5 46.366 59.366 49.5 55.5 49.5 C51.634 49.5 48.5 46.366 48.5 42.5 C48.5 38.634 51.634 35.5 55.5 35.5 C59.366 35.5 62.5 38.634 62.5 42.5 Z",viewW:110,viewH:110}},{id:"chair",group:"furniture",art:{d:"M41.25 60.5 L68.75 60.5 M68.75 60.5 C70.5449 60.5 72 59.0449 72 57.25 C72 55.6281 70.8119 54.2836 69.2585 54.0395 C69.0928 54.0135 68.923 54 68.75 54 L41.25 54 C41.077 54 40.9072 54.0135 40.7415 54.0395 C39.1881 54.2836 38 55.6281 38 57.25 C38 59.0449 39.4551 60.5 41.25 60.5 M41.25 60.5 L46 60.5 M68.75 60.5 L64 60.5 M64 60.5 L69.5 60.5 L69.5 82 C69.5 82.8284 68.8284 83.5 68 83.5 L67.3752 83.5 C66.5972 83.5 65.9483 82.9051 65.8809 82.1299 L64 60.5 Z M64 60.5 L46 60.5 M46 60.5 L40.5 60.5 L40.5 82 C40.5 82.8284 41.1716 83.5 42 83.5 L42.6248 83.5 C43.4028 83.5 44.0517 82.9051 44.1191 82.1299 L46 60.5 Z M40.7415 54.0395 C40.5847 53.5546 40.5 53.0372 40.5 52.5 L40.5 39.5 C40.5 32.5964 46.0964 27 53 27 L57 27 C63.9036 27 69.5 32.5964 69.5 39.5 L69.5 52.5 C69.5 53.0372 69.4153 53.5546 69.2585 54.0395",viewW:110,viewH:110}},{id:"coffee_table",group:"furniture",art:{d:"M85.2381 55 L86.5 55 C87.0523 55 87.5 54.5523 87.5 54 L87.5 51 L84.6598 43.4847 C84.2586 42.5818 83.3633 42 82.3753 42 L26.6247 42 C25.6367 42 24.7414 42.5818 24.3402 43.4847 L21.5 51 L21.5 54 C21.5 54.5523 21.9477 55 22.5 55 L25 55 M87.5 51 L21.5 51 M25 55 L25 66.5 C25 67.3284 25.6716 68 26.5 68 L27.2113 68 C27.983 68 28.6288 67.4144 28.7041 66.6464 L29.8459 55 M25 55 L29.8459 55 M29.8459 55 L80.3922 55 M80.3922 55 L81.534 66.6464 C81.6093 67.4144 82.2551 68 83.0268 68 L83.7381 68 C84.5665 68 85.2381 67.3284 85.2381 66.5 L85.2381 55 M80.3922 55 L85.2381 55",viewW:110,viewH:110}},{id:"computer",group:"appliance",art:{d:"M43 65 L48 65 M43 65 L24.5 65 C23.1193 65 22 63.8807 22 62.5 L22 40.5 C22 39.1193 23.1193 38 24.5 38 L64.5 38 C65.8807 38 67 39.1193 67 40.5 L67 62.5 C67 63.8807 65.8807 65 64.5 65 L48 65 M43 65 L43 72 M48 65 L48 72 M37 72 L43 72 M54.0711 72 L48 72 M76 60 L84 60 M76 43 L84 43 M35 53 L35 46 L39.5 46 C40.4283 46 41.3185 46.3687 41.9749 47.0251 C42.6313 47.6815 43 48.5717 43 49.5 C43 50.4283 42.6312 51.3185 41.9749 51.9749 C41.3185 52.6313 40.4283 53 39.5 53 L35 53 Z M35 53 L35 56 M54.5355 54.5355 C53.8363 55.2348 52.9454 55.711 51.9755 55.9039 C51.0055 56.0969 50.0002 55.9978 49.0866 55.6194 C48.173 55.241 47.3921 54.6001 46.8427 53.7779 C46.2932 52.9556 46 51.9889 46 51 C46 50.0111 46.2932 49.0444 46.8427 48.2221 C47.3921 47.3999 48.173 46.759 49.0866 46.3806 C50.0002 46.0022 51.0055 45.9031 51.9755 46.0961 C52.9454 46.289 53.8363 46.7652 54.5355 47.4645 M48 72 L43 72 M74.5 72 L85.5 72 C86.8807 72 88 70.8807 88 69.5 L88 40.5 C88 39.1193 86.8807 38 85.5 38 L74.5 38 C73.1193 38 72 39.1193 72 40.5 L72 69.5 C72 70.8807 73.1193 72 74.5 72 Z",viewW:110,viewH:110}},{id:"cooktop",group:"appliance",art:{d:"M25 31.5 C25 30.1193 26.1193 29 27.5 29 L82.5 29 C83.8807 29 85 30.1193 85 31.5 L85 78.5 C85 79.8807 83.8807 81 82.5 81 L27.5 81 C26.1193 81 25 79.8807 25 78.5 L25 31.5 Z M49.5 66.5 C49.5 70.9183 45.9183 74.5 41.5 74.5 C37.0817 74.5 33.5 70.9183 33.5 66.5 C33.5 62.0817 37.0817 58.5 41.5 58.5 C45.9183 58.5 49.5 62.0817 49.5 66.5 Z M76 43.5 C76 47.9183 72.4183 51.5 68 51.5 C63.5817 51.5 60 47.9183 60 43.5 C60 39.0817 63.5817 35.5 68 35.5 C72.4183 35.5 76 39.0817 76 43.5 Z M73 66.5 C73 69.2614 70.7614 71.5 68 71.5 C65.2386 71.5 63 69.2614 63 66.5 C63 63.7386 65.2386 61.5 68 61.5 C70.7614 61.5 73 63.7386 73 66.5 Z M49.5 43.5 C49.5 47.9183 45.9183 51.5 41.5 51.5 C37.0817 51.5 33.5 47.9183 33.5 43.5 C33.5 39.0817 37.0817 35.5 41.5 35.5 C45.9183 35.5 49.5 39.0817 49.5 43.5 Z",viewW:110,viewH:110}},{id:"dining_table",group:"furniture",art:{d:"M26.875 47 L23.5 47 C22.9477 47 22.5 46.5523 22.5 46 L22.5 43 L24.8802 35.5939 C25.2539 34.633 26.1791 34 27.2102 34 L83.7898 34 C84.8209 34 85.7462 34.633 86.1198 35.5939 L88.5 43 L88.5 46 C88.5 46.5523 88.0523 47 87.5 47 L84.125 47 M22.5 43 L88.5 43 M78.875 47 L84.742 73.8205 C84.8926 74.5092 85.5024 75 86.2073 75 L86.7474 75 C87.6682 75 88.3716 74.1781 88.2294 73.2684 L84.125 47 M78.875 47 L84.125 47 M78.875 47 L32.125 47 M32.125 47 L26.258 73.8205 C26.1074 74.5092 25.4976 75 24.7927 75 L24.2526 75 C23.3318 75 22.6284 74.1781 22.7706 73.2684 L26.875 47 M32.125 47 L26.875 47",viewW:110,viewH:110}},{id:"dishwasher",group:"appliance",art:{d:"M81 82.5 L81 27.5 M81 82.5 C81 83.8807 79.8807 85 78.5 85 L31.5 85 C30.1193 85 29 83.8807 29 82.5 L29 55.5 M81 82.5 L81 40 M81 27.5 C81 26.1193 79.8807 25 78.5 25 L31.5 25 C30.1193 25 29 26.1193 29 27.5 M81 27.5 L81 40 M29 27.5 L29 55.5 M29 27.5 L29 40 M81 40 C81 38.6193 79.8807 37.5 78.5 37.5 L31.5 37.5 C30.1193 37.5 29 38.6193 29 40 M29 40 L29 55.5 M35.75 31 L45.25 31 M55.9943 55 C55.9943 55 54.6654 56.8105 54.5153 58.1429 C54.3169 59.9042 56.1139 60.6968 55.9943 62.4643 C55.8942 63.9429 54.5153 66 54.5153 66 M60.4943 55 C60.4943 55 59.1654 56.8105 59.0153 58.1429 C58.8169 59.9042 60.6139 60.6968 60.4943 62.4643 C60.3942 63.9429 59.0153 66 59.0153 66 M50.9943 55 C50.9943 55 49.6654 56.8105 49.5153 58.1429 C49.3169 59.9042 51.1139 60.6968 50.9943 62.4643 C50.8942 63.9429 49.5153 66 49.5153 66 M72 60.5 C72 69.8888 64.3888 77.5 55 77.5 C45.6112 77.5 38 69.8888 38 60.5 C38 51.1112 45.6112 43.5 55 43.5 C64.3888 43.5 72 51.1112 72 60.5 Z M66.5 60.5 C66.5 66.8513 61.3513 72 55 72 C48.6487 72 43.5 66.8513 43.5 60.5 C43.5 54.1487 48.6487 49 55 49 C61.3513 49 66.5 54.1487 66.5 60.5 Z M69.5 31 C69.5 32.1046 68.6046 33 67.5 33 C66.3954 33 65.5 32.1046 65.5 31 C65.5 29.8954 66.3954 29 67.5 29 C68.6046 29 69.5 29.8954 69.5 31 Z M77 31 C77 32.1046 76.1046 33 75 33 C73.8954 33 73 32.1046 73 31 C73 29.8954 73.8954 29 75 29 C76.1046 29 77 29.8954 77 31 Z",viewW:110,viewH:110}},{id:"dryer",group:"appliance",art:{d:"M81 82.5 L81 27.5 M81 82.5 C81 83.8807 79.8807 85 78.5 85 L31.5 85 C30.1193 85 29 83.8807 29 82.5 L29 55.5 M81 82.5 L81 40 M81 27.5 C81 26.1193 79.8807 25 78.5 25 L31.5 25 C30.1193 25 29 26.1193 29 27.5 M81 27.5 L81 40 M29 27.5 L29 55.5 M29 27.5 L29 40 M81 40 C81 38.6193 79.8807 37.5 78.5 37.5 L31.5 37.5 C30.1193 37.5 29 38.6193 29 40 M29 40 L29 55.5 M35.75 31 L45.25 31 M55.9943 55 C55.9943 55 54.6654 56.8105 54.5153 58.1429 C54.3169 59.9042 56.1139 60.6968 55.9943 62.4643 C55.8942 63.9429 54.5153 66 54.5153 66 M60.4943 55 C60.4943 55 59.1654 56.8105 59.0153 58.1429 C58.8169 59.9042 60.6139 60.6968 60.4943 62.4643 C60.3942 63.9429 59.0153 66 59.0153 66 M50.9943 55 C50.9943 55 49.6654 56.8105 49.5153 58.1429 C49.3169 59.9042 51.1139 60.6968 50.9943 62.4643 C50.8942 63.9429 49.5153 66 49.5153 66 M72 60.5 C72 69.8888 64.3888 77.5 55 77.5 C45.6112 77.5 38 69.8888 38 60.5 C38 51.1112 45.6112 43.5 55 43.5 C64.3888 43.5 72 51.1112 72 60.5 Z M66.5 60.5 C66.5 66.8513 61.3513 72 55 72 C48.6487 72 43.5 66.8513 43.5 60.5 C43.5 54.1487 48.6487 49 55 49 C61.3513 49 66.5 54.1487 66.5 60.5 Z M69.5 31 C69.5 32.1046 68.6046 33 67.5 33 C66.3954 33 65.5 32.1046 65.5 31 C65.5 29.8954 66.3954 29 67.5 29 C68.6046 29 69.5 29.8954 69.5 31 Z M77 31 C77 32.1046 76.1046 33 75 33 C73.8954 33 73 32.1046 73 31 C73 29.8954 73.8954 29 75 29 C76.1046 29 77 29.8954 77 31 Z",viewW:110,viewH:110}},{id:"exercise",group:"other",art:{d:"M55.091 60.072 L65.7741 35.5156 M42.2119 56.2083 L55.091 60.072 L60.8511 61.8001 L66.5032 63.4957 C70.733 64.7646 73.6297 68.6579 73.6297 73.074 L73.6297 76.2635 L29.3385 76.2635 L29.3385 65.7866 C29.3385 60.9371 32.7227 57.0804 37.0256 56.051 C38.5108 55.6956 40.1055 55.6771 41.7081 56.0709 M41.7081 56.0709 C41.876 56.1122 42.044 56.1579 42.2119 56.2083 L60.8511 61.8001 M71.9311 35.5156 L76.4108 35.5156 C78.2451 35.5156 79.9321 34.5112 80.8064 32.8987 L83.8375 27.308 C84.3011 26.4529 83.9993 25.384 83.1569 24.8976 C82.2982 24.4018 81.2002 24.696 80.7045 25.5547 L77.8652 30.4723 C77.3293 31.4005 76.3389 31.9723 75.2671 31.9723 L65.6573 31.9723 C64.6788 31.9723 63.8856 32.7655 63.8856 33.744 C63.8856 34.7224 64.6788 35.5156 65.6573 35.5156 L65.7741 35.5156 M71.9311 35.5156 C71.9603 35.7673 71.9261 36.0298 71.8188 36.2793 L60.8511 61.8001 M71.9311 35.5156 L65.7741 35.5156 M41.7081 56.0709 L38.03 42.6022 M37.0256 56.051 L33.3529 42.6022 M38.03 42.6022 L33.3529 42.6022 L29.7814 42.6022 C28.5583 42.6022 27.5668 41.6107 27.5668 40.3876 C27.5668 39.1646 28.5583 38.1731 29.7814 38.1731 L41.2971 38.1731 C42.5202 38.1731 43.5117 39.1646 43.5117 40.3876 C43.5117 41.6107 42.5202 42.6022 41.2971 42.6022 L38.03 42.6022 Z M25.7952 78.921 C25.7952 77.4533 26.985 76.2635 28.4526 76.2635 L74.5155 76.2636 C75.9832 76.2636 77.173 77.4533 77.173 78.921 C77.173 80.3887 75.9832 81.5785 74.5155 81.5785 L28.4526 81.5785 C26.985 81.5785 25.7952 80.3887 25.7952 78.921 Z M29.3385 81.5785 L29.3385 84.5677 C29.3385 85.3962 30.01 86.0677 30.8385 86.0677 L33.6379 86.0677 C34.2512 86.0677 34.8028 85.6943 35.0306 85.1248 L36.5002 81.5785 L29.3385 81.5785 Z M73.6297 81.5785 L73.6297 84.5677 C73.6297 85.3962 72.9581 86.0677 72.1297 86.0677 L69.3303 86.0677 C68.717 86.0677 68.1654 85.6943 67.9376 85.1248 L66.5002 81.5785 L73.6297 81.5785 Z M45.2833 66.0766 C45.2833 68.7673 43.102 70.9486 40.4113 70.9486 C37.7205 70.9486 35.5392 68.7673 35.5392 66.0766 C35.5392 63.3858 37.7205 61.2045 40.4113 61.2045 C43.102 61.2045 45.2833 63.3858 45.2833 66.0766 Z",viewW:110,viewH:110}},{id:"fireplace",group:"other",art:{d:"M71.1884 73.8943 L71.1884 50.4399 C71.1884 47.6784 68.9498 45.4399 66.1884 45.4399 L43.1445 45.4399 C40.3831 45.4399 38.1445 47.6784 38.1445 50.4399 L38.1445 73.8942 M38.1445 73.8942 L26.7031 73.8942 L26.7031 34.4252 L82.6629 34.4252 L82.6629 73.8942 L71.1884 73.8943 L38.1445 73.8942 Z M62.0101 62.8795 L47.3239 62.8795 C45.8031 62.8795 44.5703 64.1124 44.5703 65.6332 C44.5703 67.154 45.8031 68.3868 47.3239 68.3868 M47.3239 68.3868 C45.8031 68.3868 44.5703 69.6195 44.5703 71.1403 C44.5703 72.6611 45.8031 73.894 47.3239 73.894 M47.3239 68.3868 C48.8447 68.3868 50.0776 69.6195 50.0776 71.1403 C50.0776 72.6611 48.8447 73.894 47.3239 73.894 M47.3239 68.3868 L61.9918 68.3868 M47.3239 73.894 L62.0101 73.894 C63.5309 73.894 64.7637 72.6611 64.7637 71.1403 C64.7637 69.6242 63.5385 68.3945 62.0243 68.3869 M62.0114 68.3869 C62.0049 68.3869 61.9983 68.3869 61.9918 68.3868 M62.0114 68.3869 C62.0157 68.3869 62.02 68.3869 62.0243 68.3869 M62.0114 68.3869 L62.0243 68.3869 M62.0114 68.3869 L61.9918 68.3868 M61.9918 68.3868 C60.48 68.3763 59.2578 67.1475 59.2578 65.6332 C59.2578 64.1124 60.4906 62.8796 62.0114 62.8796 C63.5322 62.8796 64.7651 64.1124 64.7651 65.6332 C64.7651 67.1498 63.5392 68.3799 62.0243 68.3869 M61.9918 68.3868 L62.0101 68.3868 C62.0148 68.3868 62.0195 68.3868 62.0243 68.3869 M24 81.6962 L85.3341 81.6962 C85.8864 81.6962 86.3341 81.2485 86.3341 80.6962 L86.3341 74.8942 C86.3341 74.3419 85.8864 73.8942 85.3341 73.8942 L24 73.8942 C23.4477 73.8942 23 74.3419 23 74.8942 L23 80.6962 C23 81.2485 23.4477 81.6962 24 81.6962 Z M24 34.4252 L85.3341 34.4252 C85.8864 34.4252 86.3341 33.9775 86.3341 33.4252 L86.3341 29 C86.3341 28.4477 85.8864 28 85.3341 28 L24 28 C23.4477 28 23 28.4477 23 29 L23 33.4252 C23 33.9775 23.4477 34.4252 24 34.4252 Z",viewW:110,viewH:110}},{id:"fridge",group:"appliance",art:{d:"M35.5 87 C34.1193 87 33 85.8807 33 84.5 M35.5 87 L74.5 87 M35.5 87 L35.5 90.5 C35.5 91.0523 35.9477 91.5 36.5 91.5 L73.5 91.5 C74.0523 91.5 74.5 91.0523 74.5 90.5 L74.5 87 M33 84.5 L33 20.5 M33 84.5 L33 46.5 M77.5 84.5 L77.5 20.5 M77.5 84.5 C77.5 85.8807 76.3807 87 75 87 L74.5 87 M77.5 84.5 L77.5 46.5 M77.5 20.5 C77.5 19.1193 76.3807 18 75 18 L35.5 18 C34.1193 18 33 19.1193 33 20.5 M77.5 20.5 L77.5 46.5 M33 20.5 L33 46.5 M33 46.5 L77.5 46.5 M38.5 41 L38.5 31.5 M38.5 62 L38.5 52.5",viewW:110,viewH:110}},{id:"hood",group:"appliance",art:{d:"M66 57 L83 69 L83 71.5 C83 72.8807 81.8807 74 80.5 74 L29.5 74 C28.1193 74 27 72.8807 27 71.5 L27 69 L44 57 M44 57 L66 57 M44 57 L44 37.5 C44 36.1193 45.1193 35 46.5 35 L63.5 35 C64.8807 35 66 36.1193 66 37.5 L66 57 M83 69 L27 69",viewW:110,viewH:110}},{id:"kitchen_cabinet",group:"furniture",art:{d:"M72 84.95 L72 88 C72 88.5523 71.5523 89 71 89 L39 89 C38.4477 89 38 88.5523 38 88 L38 84.95 M55 20 L71.5 20 C72.8807 20 74 21.1193 74 22.5 L74 39.5 C74 40.8807 72.8807 42 71.5 42 L55 42 M55 20 L55 42 M55 20 L38.5 20 C37.1193 20 36 21.1193 36 22.5 L36 39.5 C36 40.8807 37.1193 42 38.5 42 L55 42 M59 33 L59 38 M51 33 L51 38 M55 85 L71.5 85 C72.8807 85 74 83.8807 74 82.5 L74 65.5 C74 64.1193 72.8807 63 71.5 63 L55 63 M55 85 L55 63 M55 85 L38.5 85 C37.1193 85 36 83.8807 36 82.5 L36 65.5 C36 64.1193 37.1193 63 38.5 63 L55 63 M67 67 L62 67 M48 67 L43 67",viewW:110,viewH:110}},{id:"kitchen_sink",group:"sanitary",art:{d:"M49 54 L49 59 M51.5 37.5 L44 37.5 M51.5 37.5 C52.0523 37.5 52.5 37.9477 52.5 38.5 L52.5 44 M51.5 37.5 L48 37.5 M44 37.5 C43.4477 37.5 43 37.9477 43 38.5 L43 44 M44 37.5 L48 37.5 M43 44 L21.5 44 C20.1193 44 19 45.1193 19 46.5 L19 81.5 C19 82.8807 20.1193 84 21.5 84 L89.5 84 C90.8807 84 92 82.8807 92 81.5 L92 46.5 C92 45.1193 90.8807 44 89.5 44 L52.5 44 M43 44 L52.5 44 M58 33 L58 31 C58 29.6739 57.4732 28.4021 56.5355 27.4645 C55.5979 26.5268 54.3261 26 53 26 C51.6739 26 50.4021 26.5268 49.4645 27.4645 C48.5268 28.4021 48 29.6739 48 31 L48 37.5 M62 54 L62 59 M26 50 L52.5 50 C53.0523 50 53.5 50.4477 53.5 51 L53.5 77 C53.5 77.5523 53.0523 78 52.5 78 L26 78 C25.4477 78 25 77.5523 25 77 L25 51 C25 50.4477 25.4477 50 26 50 Z M58.5 50 L85 50 C85.5523 50 86 50.4477 86 51 L86 77 C86 77.5523 85.5523 78 85 78 L58.5 78 C57.9477 78 57.5 77.5523 57.5 77 L57.5 51 C57.5 50.4477 57.9477 50 58.5 50 Z",viewW:110,viewH:110}},{id:"nightstand",group:"furniture",art:{d:"M34.5 76 C33.1193 76 32 74.8807 32 73.5 M34.5 76 L41.2308 76 M34.5 76 C34.3288 76 34.1616 75.9828 34 75.95 L34 78.5 C34 79.3284 34.6716 80 35.5 80 L38.8921 80 C39.5506 80 40.1321 79.5705 40.3258 78.9411 L41.2308 76 M32 73.5 L32 33 M32 73.5 L32 57.5 M78 73.5 L78 33 M69.2692 76 L75.5 76 C75.8556 76 76.1938 75.9258 76.5 75.792 C77.383 75.4062 78 74.5252 78 73.5 M78 73.5 L78 57.5 M78 33 C78 31.6193 76.8807 30.5 75.5 30.5 L34.5 30.5 C33.1193 30.5 32 31.6193 32 33 M78 33 L78 39.5 M32 33 L32 39.5 M32 39.5 L78 39.5 M32 39.5 L32 57.5 M78 39.5 L78 57.5 M78 57.5 L32 57.5 M50.5 48.5 L60 48.5 M50.5 66 L60 66 M41.2308 76 L69.2692 76 M69.2692 76 L70.1742 78.9411 C70.3679 79.5705 70.9494 80 71.6079 80 L75 80 C75.8284 80 76.5 79.3284 76.5 78.5 L76.5 75.792",viewW:110,viewH:110}},{id:"oven",group:"appliance",art:{d:"M29 76 C29 77.3807 30.1193 78.5 31.5 78.5 L78.5 78.5 C79.8807 78.5 81 77.3807 81 76 M29 76 L29 40 M29 76 L29 82.5 C29 83.8807 30.1193 85 31.5 85 L78.5 85 C79.8807 85 81 83.8807 81 82.5 L81 76 M81 76 L81 40 M81 40 C81 38.6193 79.8807 37.5 78.5 37.5 L31.5 37.5 C30.1193 37.5 29 38.6193 29 40 M81 40 L81 27.5 C81 26.1193 79.8807 25 78.5 25 L31.5 25 C30.1193 25 29 26.1193 29 27.5 L29 40 M35.75 31 L45.25 31 M43 42 L67 42 M40.5 72 L69.5 72 C70.8807 72 72 70.8807 72 69.5 L72 49.5 C72 48.1193 70.8807 47 69.5 47 L40.5 47 C39.1193 47 38 48.1193 38 49.5 L38 69.5 C38 70.8807 39.1193 72 40.5 72 Z M69.5 31 C69.5 32.1046 68.6046 33 67.5 33 C66.3954 33 65.5 32.1046 65.5 31 C65.5 29.8954 66.3954 29 67.5 29 C68.6046 29 69.5 29.8954 69.5 31 Z M77 31 C77 32.1046 76.1046 33 75 33 C73.8954 33 73 32.1046 73 31 C73 29.8954 73.8954 29 75 29 C76.1046 29 77 29.8954 77 31 Z",viewW:110,viewH:110}},{id:"plant",group:"other",art:{d:"M55.7064 55.8805 L55.7064 52.9357 M55.7064 52.9357 C56.839 47.0461 62.7965 41.9801 68.6182 37.5322 M55.7064 52.9357 C50.7678 48.7899 47.7236 46.7763 41.6621 43.8748 M67.4992 61.3174 L65.9151 75.8488 C65.7779 77.1181 64.7063 78.0801 63.4296 78.0801 L48.4373 78.0801 C47.1606 78.0801 46.089 77.1181 45.9518 75.8488 L44.3593 61.3174 L67.4992 61.3174 Z M60.2363 44.7807 C58.4234 36.1732 66.8047 29.604 76.9989 31.869 C76.9989 40.024 68.3904 48.6318 60.2363 44.7807 Z M50.476 49.9288 C51.9926 41.2641 43.391 34.9863 33.2805 37.5996 C33.5602 45.7498 42.4589 54.0573 50.476 49.9288 Z M43.1152 61.3174 L68.7509 61.3174 C69.3031 61.3174 69.7509 60.8697 69.7509 60.3174 L69.7509 56.8809 C69.7509 56.3286 69.3031 55.8809 68.7509 55.8809 L43.1152 55.8809 C42.5629 55.8809 42.1152 56.3286 42.1152 56.8809 L42.1152 60.3174 C42.1152 60.8697 42.5629 61.3174 43.1152 61.3174 Z",viewW:110,viewH:110}},{id:"rug",group:"other",art:{d:"M90.2693 33.8735 L84.648 33.8735 M25.6208 33.8735 L19.9995 33.8735 M90.2693 39.0264 L84.648 39.0264 M25.6208 39.0264 L19.9995 39.0264 M90.2693 44.1792 L84.648 44.1792 M25.6208 44.1792 L19.9995 44.1792 M90.2693 49.332 L84.648 49.332 M25.6208 49.332 L19.9995 49.332 M90.2693 54.4854 L84.648 54.4854 M25.6208 54.4854 L19.9995 54.4854 M90.2693 59.6382 L84.648 59.6382 M25.6208 59.6382 L19.9995 59.6382 M90.2693 64.791 L84.648 64.791 M25.6208 64.791 L19.9995 64.791 M90.2693 69.9438 L84.648 69.9438 M25.6208 69.9438 L19.9995 69.9438 M90.2693 75.0967 L84.648 75.0967 M25.6208 75.0967 L19.9995 75.0967 M28.121 32 L82.145 32 C83.5257 32 84.645 33.1193 84.645 34.5 L84.645 74.939 C84.645 76.3197 83.5257 77.439 82.145 77.439 L28.121 77.439 C26.7403 77.439 25.621 76.3197 25.621 74.939 L25.621 34.5 C25.621 33.1193 26.7403 32 28.121 32 Z M29.8369 32 L29.8369 77.439 M80.4302 32 L80.4302 77.439 M37.8005 54.4852 L55.6014 46.0532 L73.4022 54.4852 L55.6014 62.9172 L37.8005 54.4852 Z",viewW:110,viewH:110}},{id:"shelving",group:"furniture",art:{d:"M64 58.5 L64 47 C64 46.4477 64.4477 46 65 46 L68 46 C68.5523 46 69 46.4477 69 47 M64 58.5 L69 58.5 M64 58.5 L28 58.5 L28 39 L35.5 39 M69 58.5 L69 47 M69 58.5 L69 44.5 M69 58.5 L76 58.5 M69 47 L69 44.5 M52.5 39 L52.5 27.5 C52.5 26.9477 52.0523 26.5 51.5 26.5 L48.5 26.5 C47.9477 26.5 47.5 26.9477 47.5 27.5 M52.5 39 L47.5 39 M52.5 39 L81 39 L81 58.5 L76 58.5 M47.5 39 L47.5 27.5 M47.5 39 L47.5 25 M47.5 39 L40.5 39 M47.5 27.5 L47.5 25 M40.5 39 L40.5 27.5 M40.5 39 L40.5 25 M40.5 39 L35.5 39 M35.5 39 L35.5 27.5 C35.5 26.9477 35.9477 26.5 36.5 26.5 L39.5 26.5 C40.0523 26.5 40.5 26.9477 40.5 27.5 M40.5 27.5 L40.5 25 M49 72 L36.5 72 M50.5 72 L36.5 72 C35.9477 72 35.5 71.5523 35.5 71 L35.5 68.5 C35.5 67.9477 35.9477 67.5 36.5 67.5 L49 67.5 C49.5523 67.5 50 67.9477 50 68.5 L50 71 C50 71.5523 49.5523 72 49 72 M50.5 78 C51.0523 78 51.5 77.5523 51.5 77 L51.5 73 C51.5 72.4477 51.0523 72 50.5 72 L49 72 M36.5 72 C35.9477 72 35.5 72.4477 35.5 73 L35.5 77 C35.5 77.5523 35.9477 78 36.5 78 M76 58.5 L76 44.5 C76 43.9477 75.5523 43.5 75 43.5 L70 43.5 C69.4477 43.5 69 43.9477 69 44.5 M47.5 25 C47.5 24.4477 47.0523 24 46.5 24 L41.5 24 C40.9477 24 40.5 24.4477 40.5 25 M50.5 78 L36.5 78 M50.5 78 L81 78 L81 85 L28 85 L28 78 L36.5 78 M28 89.5 L28 23 C28 21.6193 29.1193 20.5 30.5 20.5 L78.5 20.5 C79.8807 20.5 81 21.6193 81 23 L81 89.5",viewW:110,viewH:110}},{id:"shower",group:"sanitary",art:{d:"M39 84 L39 31.7143 C39 25.245 44.2564 20 50.75 20 C56.4663 20 61.2394 24.5462 62.1824 29.0091 M51.5 39.25 C51.5 33.5891 56.0891 29 61.75 29 C67.4109 29 72 33.5891 72 39.25 L51.5 39.25 M54.75 44.25 L54.75 46.75 M62 44.25 L62 46.75 M69.25 44.25 L69.25 46.75 M54.75 50.5 L54.75 53 M62 50.5 L62 53 M69.25 50.5 L69.25 53 M54.75 56.75 L54.75 59.25 M62 56.75 L62 59.25 M69.25 56.75 L69.25 59.25 M54.75 63 L54.75 65.5 M62 63 L62 65.5 M69.25 63 L69.25 65.5 M31 84 L80 84 C80.5523 84 81 84.4477 81 85 L81 88 C81 88.5523 80.5523 89 80 89 L31 89 C30.4477 89 30 88.5523 30 88 L30 85 C30 84.4477 30.4477 84 31 84",viewW:110,viewH:110}},{id:"sink",group:"sanitary",art:{d:"M51 41.5 L58.5 41.5 M51 41.5 C50.4477 41.5 50 41.9477 50 42.5 L50 48 M51 41.5 L55 41.5 M58.5 41.5 C59.0523 41.5 59.5 41.9477 59.5 42.5 L59.5 48 M58.5 41.5 L55 41.5 M59.5 48 L77 48 C78.3807 48 79.5 49.1193 79.5 50.5 L79.5 57 C79.5 62.5228 75.0228 67 69.5 67 L40 67 C34.4772 67 30 62.5228 30 57 L30 50.5 C30 49.1193 31.1193 48 32.5 48 L50 48 M59.5 48 L50 48 M45 37 L45 35 C45 33.6739 45.5268 32.4021 46.4645 31.4645 C47.4021 30.5268 48.6739 30 50 30 C51.3261 30 52.5979 30.5268 53.5355 31.4645 C54.4732 32.4021 55 33.6739 55 35 L55 41.5 M45 80 L64.5 80 C65.0523 80 65.5 79.5523 65.5 79 L65.5 67 L44 67 L44 79 C44 79.5523 44.4477 80 45 80 Z",viewW:110,viewH:110}},{id:"sofa",group:"furniture",art:{d:"M88.5 44.6689 L88.5 34 C88.5 31.2386 86.2614 29 83.5 29 L59.5 29 C56.7386 29 54.5 31.2386 54.5 34 M88.5 44.6689 C89.2354 44.2435 90.0893 44 91 44 M88.5 44.6689 C88.3992 44.7272 88.3006 44.7889 88.2045 44.8539 M54.5 61.75 L54.5 34 M54.5 61.75 C54.5 64.3734 52.3734 66.5 49.75 66.5 L25.25 66.5 C22.6266 66.5 20.5 64.3734 20.5 61.75 M54.5 61.75 C54.5 59.1266 52.3734 57 49.75 57 L25.25 57 C24.6761 57 24.1261 57.1018 23.6168 57.2882 M54.5 61.75 C54.5 64.3734 56.6266 66.5 59.25 66.5 L83.75 66.5 C86.3734 66.5 88.5 64.3734 88.5 61.75 M88.5 61.75 C88.5 59.9118 87.4558 58.3175 85.9283 57.5278 C85.8889 57.5075 85.8493 57.4877 85.8093 57.4684 C85.1863 57.1682 84.4878 57 83.75 57 L59.25 57 C56.6266 57 54.5 59.1266 54.5 61.75 M54.5 34 C54.5 31.2386 52.2614 29 49.5 29 L25.5 29 C22.7386 29 20.5 31.2386 20.5 34 L20.5 44.416 M20.5 44.416 C19.8875 44.1484 19.2111 44 18.5 44 M20.5 44.416 C22.2659 45.1876 23.5 46.9497 23.5 49 M18.5 44 C21.2614 44 23.5 46.2386 23.5 49 M18.5 44 L18 44 C15.2386 44 13 46.2386 13 49 L13 70.5 C13 73.2614 15.2386 75.5 18 75.5 M23.5 49 L23.5 57.3328 M23.5 57.3328 C21.7427 58.0295 20.5 59.7446 20.5 61.75 M23.5 57.3328 C23.5387 57.3174 23.5776 57.3026 23.6168 57.2882 M91 44 C89.9645 44 89.0025 44.3148 88.2045 44.8539 C86.8744 45.7525 86 47.2741 86 49 L86 57.5657 M85.9283 57.5278 C85.9523 57.5402 85.9762 57.5528 86 57.5657 C87.4884 58.3677 88.5 59.9407 88.5 61.75 M91 44 L91.5 44 C94.2614 44 96.5 46.2386 96.5 49 L96.5 70.5 C96.5 73.2614 94.2614 75.5 91.5 75.5 M91.5 75.5 L18 75.5 M91.5 75.5 L90.5 75.5 M18 75.5 L18.5 75.5 M20.5 61.75 C20.5 59.7005 21.798 57.9542 23.6168 57.2882 M18.5 75.5 L26.5 75.5 M18.5 75.5 L18.5 80.5 C18.5 81.3284 19.1716 82 20 82 L23.3921 82 C24.0506 82 24.6321 81.5705 24.8258 80.9411 L26.5 75.5 M26.5 75.5 L82.5 75.5 M90.5 75.5 L82.5 75.5 M90.5 75.5 L90.5 80.5 C90.5 81.3284 89.8284 82 89 82 L85.6079 82 C84.9494 82 84.3679 81.5705 84.1742 80.9411 L82.5 75.5",viewW:110,viewH:110}},{id:"stairs",group:"other",art:{d:"M73.4707 46.8057 L73.4707 28.5242 M73.4707 46.8057 L73.1504 46.8057 M73.4707 46.8057 L82.6039 46.8057 M73.4707 28.5242 L73.425 28.5242 M73.4707 28.5242 L75.6731 28.5242 M62.8987 54.2946 L62.8987 36.7397 M61.5762 61.7837 L61.5762 55.2944 C61.5762 54.7421 62.0239 54.2944 62.5762 54.2944 L62.8987 54.2946 L72.1504 54.2945 M52.3262 61.7837 L52.3262 45.1306 M52.3262 61.7837 L52.0039 61.7837 M52.3262 61.7837 L61.5762 61.7837 M62.8987 36.7397 L52.3262 45.1306 L42.1934 53.1725 L31.6211 61.5632 M42.1934 69.2725 L42.1934 53.1725 M42.1934 69.2725 L41.873 69.2725 M83.6035 69.2725 L83.6024 69.2725 L51.0039 69.2725 L42.1934 69.2725 M83.6031 76.7612 L83.6031 83.25 C83.6031 83.8023 83.1554 84.25 82.6031 84.25 L31.6231 84.2499 M41.873 69.2725 L83.6035 69.2725 L83.6031 76.7612 M83.6031 76.7612 L31.6231 76.7612 M31.6231 76.7612 L40.873 76.7613 L83.6031 76.7612 M31.6231 84.2499 L27.7773 84.2499 C27.2251 84.2499 26.7773 83.8021 26.7773 83.2499 L26.7773 57.4971 C26.7773 56.9448 27.2251 56.4971 27.7773 56.4971 L28.9352 56.4971 M31.6231 84.2499 L31.6231 76.7612 M31.6231 76.7612 L31.6211 61.5632 L31.6231 56.4971 M29.0212 56.4971 L31.6231 56.4971 L31.6228 57.2227 M31.6211 61.5632 L62.8987 36.7397 M31.6211 61.5632 L31.6228 57.2227 M73.425 28.5242 L75.6731 28.5242 M73.425 28.5242 C73.3119 28.5242 73.202 28.5624 73.1134 28.6328 L62.8987 36.7397 M75.6731 28.5242 C76.6463 28.5242 77.4352 27.7353 77.4352 26.7621 C77.4352 25.7889 76.6463 25 75.6731 25 L71.9495 25 C71.7935 25 71.6421 25.0532 71.5204 25.1508 L31.6228 57.2227 M41.873 69.2725 C41.3208 69.2725 40.873 69.7202 40.873 70.2725 L40.873 76.7613 M52.0039 61.7837 L83.6024 61.7837 M52.0039 61.7837 C51.4516 61.7837 51.0039 62.2314 51.0039 62.7837 L51.0039 69.2725 M83.6022 54.2944 L83.6024 61.7837 L83.6024 69.2725 M83.6024 61.7837 L61.5762 61.7837 M83.6022 54.2944 L83.6039 47.8057 C83.6039 47.2534 83.1562 46.8057 82.6039 46.8057 M83.6022 54.2944 L72.1504 54.2945 M73.1504 46.8057 L82.6039 46.8057 M73.1504 46.8057 C72.5981 46.8057 72.1504 47.2534 72.1504 47.8057 L72.1504 54.2945 M28.9352 56.4971 C28.9495 56.4973 28.9638 56.4974 28.9782 56.4974 C28.9925 56.4974 29.0069 56.4973 29.0212 56.4971 M28.9352 56.4971 C27.2519 56.4741 25.8945 55.1024 25.8945 53.4137 C25.8945 51.7107 27.2751 50.3301 28.9782 50.3301 C30.6812 50.3301 32.0618 51.7107 32.0618 53.4137 C32.0618 55.1024 30.7044 56.4741 29.0212 56.4971 M28.9352 56.4971 L29.0212 56.4971",viewW:110,viewH:110}},{id:"toilet",group:"sanitary",art:{d:"M64.5372 72.1021 L67.6892 84.7575 C67.847 85.3886 67.3696 86 66.7191 86 L37.6483 86 C37.0414 86 36.5743 85.4636 36.6578 84.8624 L38.9999 68 C40.0716 64 32.5 64.5 32 57 L32 26.5 C32 25.1193 33.1193 24 34.5 24 L45 24 C46.3807 24 47.5 25.1193 47.5 26.5 L47.5 52 M32 57 L47.5 57 M47.5 52 L76.5 52 C77.8807 52 79 53.1193 79 54.5 L79 57 M47.5 52 L47.5 57 M54.9999 71.75 C58.5528 72.6096 61.7379 72.6416 64.5372 72.1021 C73.95 70.2877 79 62.0101 79 57 M79 57 L47.5 57",viewW:110,viewH:110}},{id:"tv",group:"appliance",art:{d:"M23.5 31 L86 31 C87.3807 31 88.5 32.1193 88.5 33.5 L88.5 67.5 C88.5 68.8807 87.3807 70 86 70 L23.5 70 C22.1193 70 21 68.8807 21 67.5 L21 33.5 C21 32.1193 22.1193 31 23.5 31 M50 70 L50 78 M59.5 70 L59.5 78 M40 78 L70 78 M42.5466 45.9951 L52.5466 45.9951 M47.5466 45.9951 L47.5 56.0336 M56.75 45.5 L61.75 55.5 L66.75 45.5",viewW:110,viewH:110}},{id:"wardrobe",group:"furniture",art:{d:"M54.5 20.5 L30.5 20.5 C29.1193 20.5 28 21.6193 28 23 L28 82.5 C28 83.8807 29.1193 85 30.5 85 L54.5 85 M54.5 20.5 L54.5 85 M54.5 20.5 L78.5 20.5 C79.8807 20.5 81 21.6193 81 23 L81 82.5 C81 83.8807 79.8807 85 78.5 85 L54.5 85 M79 84.95 L79 88.5 C79 89.0523 78.5523 89.5 78 89.5 L31 89.5 C30.4477 89.5 30 89.0523 30 88.5 L30 84.95 M50.5 48 L50.5 57.5 M58.5 48 L58.5 57.5",viewW:110,viewH:110}},{id:"washer",group:"appliance",art:{d:"M81 40 C81 38.6193 79.8807 37.5 78.5 37.5 L31.5 37.5 C30.1193 37.5 29 38.6193 29 40 M35.75 31 L45.25 31 M31.5 85 L78.5 85 C79.8807 85 81 83.8807 81 82.5 L81 55.5 L81 27.5 C81 26.1193 79.8807 25 78.5 25 L31.5 25 C30.1193 25 29 26.1193 29 27.5 L29 56 L29 82.5 C29 83.8807 30.1193 85 31.5 85 Z M72 60.5 C72 69.8888 64.3888 77.5 55 77.5 C45.6112 77.5 38 69.8888 38 60.5 C38 51.1112 45.6112 43.5 55 43.5 C64.3888 43.5 72 51.1112 72 60.5 Z M66.5 60.5 C66.5 66.8513 61.3513 72 55 72 C48.6487 72 43.5 66.8513 43.5 60.5 C43.5 54.1487 48.6487 49 55 49 C61.3513 49 66.5 54.1487 66.5 60.5 Z M69.5 31 C69.5 32.1046 68.6046 33 67.5 33 C66.3954 33 65.5 32.1046 65.5 31 C65.5 29.8954 66.3954 29 67.5 29 C68.6046 29 69.5 29.8954 69.5 31 Z M77 31 C77 32.1046 76.1046 33 75 33 C73.8954 33 73 32.1046 73 31 C73 29.8954 73.8954 29 75 29 C76.1046 29 77 29.8954 77 31 Z",viewW:110,viewH:110}},{id:"work_table",group:"furniture",art:{d:"M68.5 61 L68.5 73.5 C68.5 74.3284 69.1716 75 70 75 L87 75 C87.8284 75 88.5 74.3284 88.5 73.5 L88.5 61 L88.4844 47 M26.4844 47 L26.4844 73.5 C26.4844 74.3284 25.8128 75 24.9844 75 L23.9844 75 C23.1559 75 22.4844 74.3284 22.4844 73.5 L22.4844 47 L22.4844 43 L24.866 35.5974 C25.2388 34.6346 26.165 34 27.1974 34 L83.7743 34 C84.8054 34 85.7307 34.633 86.1044 35.5939 L88.4844 43 L88.4844 47 M88.4844 47 L68.5 47 M68.5 47 L68.5 61 M68.5 47 L26.4844 47 M68.5 61 L88.5 61 M76.5 51 L80.5 51 M88.4844 43 L22.4844 43 M22.4844 47 L26.4844 47 M76.5 65 L80.5 65",viewW:110,viewH:110}}];class Xc{constructor(t,e){this.host=t,this.hooks=e}place(t,e="mouse"){const s=this.host._decorImagePalette,i=this.host._curSpaceCfg;if(!s||!i)return;const o=this.hooks.decorSnap(t,e),a=$e(s.width,s.height),n=we(a.w,this.host._cellCm,this.host._gridPitch)/lt,r=we(a.h,this.host._cellCm,this.host._gridPitch)/this.host._decorH,l="di"+Date.now().toString(36)+Math.random().toString(36).slice(2,5),h=this.hooks.geometrySnapshot();i.decor=[...this.host._decorList,{id:l,kind:"image",asset_id:s.asset_id,x:le(o[0]/lt-n/2),y:le(o[1]/this.host._decorH-r/2),w:n,h:r,opacity:1}],this.host._decorSel=l,this.host._decorTool="select",this.host._decorImagePalette=null,this.hooks.clearFurniturePreview(),this.hooks.recordGeometry(this.host._t("history.decor_add"),h),this.hooks.saveConfig(),this.host.requestUpdate()}renderPlacementPreview(){const t=this.host._furnPreviewInput,e=this.host._decorImagePalette;if(!t||!e||"decor"!==this.host._mode||"image"!==this.host._decorTool||!this.host._pointerModality.hoverEnabled)return d;const s=this.hooks.decorSnap(t.raw,"mouse"),i=$e(e.width,e.height),o=we(i.w,this.host._cellCm,this.host._gridPitch)/lt,a=we(i.h,this.host._cellCm,this.host._gridPitch)/this.host._decorH,n=this.host._display(e.url);return n?At``}afterRender(){const t=this.host.root();this._blocked&&(this._openGroupId?this.closeGroup(!1):"palette"===this._currentModel?.kind&&this._currentModel.dismiss?.()),this._syncGlobalDismissListener();const e=t.querySelector(".editor-secondary"),s=this._renderedContext,i=e?.dataset.contextId||"";if(i&&s&&i!==s&&!window.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches&&(this._contentAnimation?.cancel(),this._contentAnimation=e?.querySelector(".editor-secondary-content")?.animate([{opacity:.35,transform:"translateY(-4px)"},{opacity:1,transform:"translateY(0)"}],{duration:100,easing:"ease-out"})),this._renderedContext=i,s&&i!==s&&this._focusOwned){const s=i?e?.querySelector('[tabindex="0"], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])'):t.querySelector(".editbar-tools");s?.focus?.(),this._focusOwned=!!i}if("palette"===this._currentModel?.kind&&this._currentModel.launcherId){const e=[...t.querySelectorAll("[data-editor-palette]")].find(t=>t.dataset.editorPalette===this._currentModel?.launcherId);e&&null!==e.offsetParent||this._currentModel.dismiss?.()}if(!this._openGroupId)return;const o=[...t.querySelectorAll("[data-editor-group]")].find(t=>t.dataset.editorGroup===this._openGroupId);o&&null!==o.offsetParent||this.closeGroup(!0)}handleOutsideDismiss(t){if(Ec(t,t=>t.hasAttribute("data-editor-navigation")))return"pointerdown"===t.type?this.closeForNavigation():"click"===t.type&&this._dismissPointerTarget&&this._clearDismissClick(),!1;if("click"===t.type&&this._dismissPointerTarget){return!!(t.composedPath?.()||[t.target]).includes(this._dismissPointerTarget)&&(this._clearDismissClick(),t.preventDefault(),t.stopImmediatePropagation(),!0)}const e=this._openGroupId||this._blocked||"palette"!==this._currentModel?.kind?null:this._currentModel;if("pointerdown"===t.type&&(this._openGroupId||e)){const s=Ec(t,t=>t.classList.contains("editor-secondary")),i=Ec(t,t=>!!t.dataset.editorGroup),o=Ec(t,t=>!!t.dataset.editorPalette),a=Ec(t,t=>t.classList.contains("stage"));if(!(s||i||o||"stay-open-on-canvas"===e?.dismissPolicy&&a))return t.preventDefault(),t.stopImmediatePropagation(),this._dismissPointerTarget=t.target,clearTimeout(this._dismissTimer),this._dismissTimer=window.setTimeout(()=>{this._clearDismissClick()},800),this._openGroupId?this.closeGroup(!1):e?.dismiss?.(),this._syncGlobalDismissListener(),!0}return!1}_activateGroupItem(t,e,s){if(t.id!==this._openGroupId)return;const i=t.items.find(t=>t.id===e);if(!i||i.disabled)return;const o="toggle"===i.role&&"stay-open"===i.closePolicy,a=0===s.detail;o||(this._openGroupId=null,this.host.requestUpdate(),this._syncGlobalDismissListener()),i.invoke(),!o&&a&&this.host.updateComplete().then(()=>{const e=[...this.host.root().querySelectorAll("[data-editor-group]")].find(e=>e.dataset.editorGroup===t.id&&null!==e.offsetParent);e?.focus()})}_groupKeydown(t){if(!["ArrowLeft","ArrowRight","Home","End"].includes(t.key))return;const e=[...t.currentTarget.querySelectorAll(".editor-group-item:not([disabled])")];if(!e.length)return;t.preventDefault();const s=e.indexOf(this.host.root().activeElement),i="Home"===t.key?0:"End"===t.key?e.length-1:"ArrowLeft"===t.key?s<=0?e.length-1:s-1:(s+1)%e.length;e[i]?.focus()}_clearDismissClick(){this._dismissPointerTarget=null,clearTimeout(this._dismissTimer),this._dismissTimer=void 0,this._syncGlobalDismissListener()}_syncGlobalDismissListener(){const t=!this._blocked&&"palette"===this._currentModel?.kind,e=!!this._openGroupId||t||!!this._dismissPointerTarget;e!==this._globalDismissListening&&(this._globalDismissListening=e,e?(window.addEventListener("pointerdown",this._globalDismissGuard,!0),window.addEventListener("click",this._globalDismissGuard,!0)):(window.removeEventListener("pointerdown",this._globalDismissGuard,!0),window.removeEventListener("click",this._globalDismissGuard,!0)))}}const Hc=t=>t.stopPropagation(),Bc=new WeakSet,Wc=t=>{t._regSignature="",t._maybeRebuildDevices(),t.requestUpdate()};async function jc(t,e,s,i,o,a=""){const n=t.host,r=n._serverCfg;if(!r)return!1;let l=JSON.parse(JSON.stringify(r));l.markers=l.markers||[];let h=l.markers.find(t=>t.id===e);if(!h){const t=n._devices.find(t=>t.id===e);if(!t||"device"!==t.bindingKind&&"entity"!==t.bindingKind||!t.bindingRef)return!1;h={id:t.id,binding:`${t.bindingKind}:${t.bindingRef}`,space:t.space||null,area:t.area||null,hidden:!!t.hidden},l.markers.push(h)}h.vacuum=function(t,e){const s=e.matrix.map(t=>Number(t.toFixed(6))),i=t?.map_routes;if(Array.isArray(i)&&i.length){const o=i.find(t=>t.id===e.routeId)||i.find(t=>t.source===e.source&&t.map_id===e.mapId);if(o)return{...t,map_routes:jo(i,o.id,s)}}return{...t,source:e.source,calibration:{...t?.calibration||{},[e.mapId]:s}}}(h.vacuum||{},{source:s,mapId:i,routeId:a,matrix:o}),l=t._prepareConfigCandidate(l);const c=n._adoption.beginOptimistic(r,l);n._adoption.stageLocalConfig(l),Wc(n),n._saveConfigDebounced.pending()&&n._saveConfigDebounced.cancel();try{return await t._saveConfigNow(c),!0}catch(t){return n._rollbackOptimistic(c),Wc(n),n._showToast(n._t("toast.cfg_save_failed",{err:n._errText(t)})),!1}}function Gc(t){return 1===t}function qc(t){return`${t}-${globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}`}function Uc(t){const e=function(t){return JSON.stringify({message:t.message.trim(),contact:t.contact.trim(),previewToken:t.attach&&t.preview?t.preview.token:""})}(t);return{idempotencyKey:t.submissionFingerprint&&t.submissionFingerprint!==e?qc("report"):t.idempotencyKey,fingerprint:e}}function Kc(t){return[...t].length}function Vc(t,e=Date.now()){const s=t.message.trim();return s?Kc(s)>1e4?"message_too_long":Kc(t.contact.trim())>320?"contact_too_long":t.attach&&!t.preview?"preview_missing":t.attach&&t.preview.expiresAt<=e?"preview_expired":null:"message_required"}function Jc(t,e=Date.now()){return"building"!==t.status&&"sending"!==t.status&&"success"!==t.status&&null===Vc(t,e)}function Zc(t){const e=function(t){const e=/Firefox\/(\d+)/i.exec(t);if(e)return{family:"firefox",major:Number(e[1])||0};const s=/(?:Chrome|Chromium|Edg)\/(\d+)/i.exec(t);if(s)return{family:"chromium",major:Number(s[1])||0};const i=/Version\/(\d+).+Safari\//i.exec(t);return i?{family:"webkit",major:Number(i[1])||0}:{family:"unknown",major:0}}(t.userAgent??globalThis.navigator?.userAgent??""),s=t.now??Date.now(),i=Number(t.registryLastSuccess||0),o=i<=0?"unknown":s-i<=6e5?"fresh":"stale",a=["en","ru","de","fr"].includes(t.language)?t.language:"en",n=globalThis.matchMedia?.bind(globalThis);return{browser_family:e.family,browser_major:Math.max(0,Math.min(999,e.major)),language:a,coarse_pointer:t.coarsePointer??!!n?.("(pointer: coarse)").matches,hover_capable:t.hoverCapable??!!n?.("(hover: hover)").matches,registry_access:"full"===t.registryAccess?"full":"limited"===t.registryAccess?"partial":"unavailable",registry_age_bucket:o}}function Yc(t){const e=t&&"object"==typeof t&&"code"in t?String(t.code||""):"";return new Set(["support_invalid_message","support_preview_expired","support_package_too_large","support_rate_limited","support_unavailable","support_rejected","unauthorized"]).has(e)?e:"support_unavailable"}const Xc=[{id:"air_conditioner",group:"appliance",art:{d:"M85 71.5 L85 63 M25 71.5 L25 63 M25 71.5 L89.5 71.5 C90.8807 71.5 92 70.3807 92 69 L92 41.5 C92 40.1193 90.8807 39 89.5 39 L20.5 39 C19.1193 39 18 40.1193 18 41.5 L18 69 C18 70.3807 19.1193 71.5 20.5 71.5 L25 71.5 Z M85 63 C85 61.6193 83.8807 60.5 82.5 60.5 L27.5 60.5 C26.1193 60.5 25 61.6193 25 63 M85 63 L85 66.5 L25 66.5 L25 63",viewW:110,viewH:110}},{id:"armchair",group:"furniture",art:{d:"M77.5 48.5 L77.5 39 C77.5 33.4772 73.0228 29 67.5 29 L42.5 29 C36.9772 29 32.5 33.4772 32.5 39 L32.5 48.5205 M77.5 48.5 C80.8137 48.5 83.5 51.1863 83.5 54.5 C83.5 57.1123 81.8302 59.3334 79.5 60.1572 L79.5 71.5 C79.5 73.7091 77.7091 75.5 75.5 75.5 M77.5 48.5 C74.2576 48.5 71.617 51.072 71.5049 54.2871 C71.5012 54.3576 71.5 54.4286 71.5 54.5 L71.5 61.75 M38 61.75 L38 54 C38 53.2396 37.7873 52.5291 37.4189 51.9238 C36.5228 50.0421 34.6765 48.7002 32.5 48.5205 M32.5 48.5205 C32.3351 48.5069 32.1684 48.5 32 48.5 M75.5 75.5 L34 75.5 M75.5 75.5 L72.5 75.5 M34 75.5 C31.7909 75.5 30 73.7091 30 71.5 L30 60.1572 C27.6698 59.3334 26 57.1123 26 54.5 C26 51.1863 28.6863 48.5 32 48.5 M34 75.5 L36.5 75.5 M32 48.5 C34.3914 48.5 36.4549 49.8996 37.4189 51.9238 M38 61.75 C38 64.3734 40.1266 66.5 42.75 66.5 L66.75 66.5 C69.3734 66.5 71.5 64.3734 71.5 61.75 M38 61.75 C38 59.1266 40.1266 57 42.75 57 L66.75 57 C69.3734 57 71.5 59.1266 71.5 61.75 M36.5 75.5 L44.5 75.5 M36.5 75.5 L36.5 80.5 C36.5 81.3284 37.1716 82 38 82 L41.3921 82 C42.0506 82 42.6321 81.5705 42.8258 80.9411 L44.5 75.5 M44.5 75.5 L64.5 75.5 M72.5 75.5 L64.5 75.5 M72.5 75.5 L72.5 80.5 C72.5 81.3284 71.8284 82 71 82 L67.6079 82 C66.9494 82 66.3679 81.5705 66.1742 80.9411 L64.5 75.5",viewW:110,viewH:110}},{id:"bathtub",group:"sanitary",art:{d:"M28 74.8457 L28 80 C28 80.8284 28.6716 81.5 29.5 81.5 L32.8921 81.5 C33.5506 81.5 34.1321 81.0705 34.3258 80.4411 L35.6923 76 M28.0191 74.8558 C28.0127 74.8524 28.0063 74.8491 28 74.8457 C25.4198 73.4833 23.483 71.0169 22.8673 67.9996 M19.5 51.5 L90 51.5 M19.5 51.5 C18.1193 51.5 17 50.3807 17 49 C17 47.6193 18.1193 46.5 19.5 46.5 M19.5 51.5 L22.8673 67.9996 M90 51.5 C91.3807 51.5 92.5 50.3807 92.5 49 C92.5 47.6193 91.3807 46.5 90 46.5 M90 51.5 L86.6327 67.9996 C85.9778 71.2088 83.8285 73.7948 81 75.0922 M90 46.5 L19.5 46.5 M90 46.5 L20 46.5 M19.5 46.5 L20 46.5 M22.8673 67.9996 C23.4846 71.0243 25.4293 73.4954 28.0191 74.8558 M30 36 L30 34 C30 32.6739 29.4732 31.4021 28.5355 30.4645 C27.5979 29.5268 26.3261 29 25 29 C23.6739 29 22.4021 29.5268 21.4645 30.4645 C20.5268 31.4021 20 32.6739 20 34 L20 46.5 M81 75.0922 C79.7247 75.6771 78.3114 76 76.8347 76 L73.3077 76 M81 75.0922 L81 80 C81 80.8284 80.3284 81.5 79.5 81.5 L76.1079 81.5 C75.4494 81.5 74.8679 81.0705 74.6742 80.4411 L73.3077 76 M73.3077 76 L35.6923 76 M35.6923 76 L32.6653 76 C31.1128 76 29.6303 75.643 28.3047 75 C28.2086 74.9534 28.1134 74.9053 28.0191 74.8558",viewW:110,viewH:110}},{id:"bed",group:"furniture",art:{d:"M16 75.5 L24 75.5 M16 75.5 L16 80.5 C16 81.3284 16.6716 82 17.5 82 L20.8921 82 C21.5506 82 22.1321 81.5705 22.3258 80.9411 L24 75.5 M16 75.5 L15 75.5 M24 75.5 L86.5 75.5 M94.5 75.5 L86.5 75.5 M94.5 75.5 L94.5 80.5 C94.5 81.3284 93.8284 82 93 82 L89.6079 82 C88.9494 82 88.3679 81.5705 88.1742 80.9411 L86.5 75.5 M94.5 75.5 L95.5 75.5 M88 50.1296 L88 31.5 C88 30.1193 86.8807 29 85.5 29 L25 29 C23.6193 29 22.5 30.1193 22.5 31.5 L22.5 50.1296 M87.9383 50.1068 C87.9589 50.1143 87.9795 50.1219 88 50.1296 C91.7967 51.5483 94.5 55.2085 94.5 59.5 M22.5617 50.1068 C22.5411 50.1143 22.5205 50.1219 22.5 50.1296 C18.7033 51.5483 16 55.2085 16 59.5 M94.5 65.5 L94.5 59.5 M94.5 65.5 L16 65.5 M94.5 65.5 L95.5 65.5 M16 65.5 L16 59.5 M16 65.5 L15 65.5 M84.5 49.5 L26 49.5 M84.5 49.5 L80 49.5 M94.5 59.5 C94.5 55.1853 91.7674 51.5088 87.9383 50.1068 C86.8662 49.7142 85.7081 49.5 84.5 49.5 M26 49.5 L30.5 49.5 M16 59.5 C16 55.1853 18.7326 51.5088 22.5617 50.1068 C23.6338 49.7142 24.7919 49.5 26 49.5 M15 75.5 L95.5 75.5 M15 75.5 C14.4477 75.5 14 75.0523 14 74.5 L14 66.5 C14 65.9477 14.4477 65.5 15 65.5 M95.5 75.5 C96.0523 75.5 96.5 75.0523 96.5 74.5 L96.5 66.5 C96.5 65.9477 96.0523 65.5 95.5 65.5 M95.5 65.5 L15 65.5 M51.5 49.5 L51.5 45.5 C51.5 42.7386 49.2614 40.5 46.5 40.5 L35.5 40.5 C32.7386 40.5 30.5 42.7386 30.5 45.5 L30.5 49.5 M51.5 49.5 L30.5 49.5 M51.5 49.5 L59 49.5 M80 49.5 L80 45.5 C80 42.7386 77.7614 40.5 75 40.5 L64 40.5 C61.2386 40.5 59 42.7386 59 45.5 L59 49.5 M80 49.5 L59 49.5",viewW:110,viewH:110}},{id:"bidet",group:"sanitary",art:{d:"M46 67.5 L64.5 67.5 M46 67.5 C40.4772 67.5 36 63.0228 36 57.5 L36 53 M46 67.5 C45.4902 67.5 44.9893 67.4618 44.5 67.3882 L44.5 79.5 C44.5 80.0523 44.9477 80.5 45.5 80.5 L65 80.5 C65.5523 80.5 66 80.0523 66 79.5 L66 67.3882 C65.5107 67.4618 65.0098 67.5 64.5 67.5 M64.5 67.5 C70.0229 67.5 74.5 63.0228 74.5 57.5 L74.5 53 M74.5 53 L74.5 47.5 C74.5 46.9477 74.0523 46.5 73.5 46.5 M74.5 53 L36 53 M36 53 L36 47.5 C36 46.9477 36.4477 46.5 37 46.5 M73.5 46.5 L37 46.5 M73.5 46.5 L60 46.5 M37 46.5 L50.5 46.5 M51.5 40 L59 40 M51.5 40 C50.9477 40 50.5 40.4477 50.5 41 L50.5 46.5 M51.5 40 L53 40 M59 40 C59.5523 40 60 40.4477 60 41 L60 46.5 M59 40 L57.5 40 M60 46.5 L50.5 46.5 M57.5 40 L57.5 30 C57.5 29.4477 57.0523 29 56.5 29 L54 29 C53.4477 29 53 29.4477 53 30 M57.5 40 L53 40 M53 40 L53 30 M53 40 L53 36 M53 30 L53 31.5 M53 31.5 L49 31.5 C48.4477 31.5 48 31.9477 48 32.5 L48 35 C48 35.5523 48.4477 36 49 36 L53 36 M53 31.5 L53 36",viewW:110,viewH:110}},{id:"boiler",group:"appliance",art:{d:"M51.5 81.5 L51.5 86 C51.5 86.5523 51.0523 87 50.5 87 L47.5 87 C46.9477 87 46.5 86.5523 46.5 86 L46.5 81.5 M51.5 81.5 L46.5 81.5 M51.5 81.5 L59 81.5 M46.5 81.5 L44 81.5 M64 81.5 L64 86 C64 86.5523 63.5523 87 63 87 L60 87 C59.4477 87 59 86.5523 59 86 L59 81.5 M64 81.5 L59 81.5 M64 81.5 L66.5 81.5 M74.5 73 L74.5 73.5 C74.5 77.9183 70.9183 81.5 66.5 81.5 M44 81.5 C39.5817 81.5 36 77.9183 36 73.5 L36 73 L36 31 C36 26.5817 39.5817 23 44 23 L66.5 23 C70.9183 23 74.5 26.5817 74.5 31 L74.5 73 M74.5 73 L36 73 M66.5 81.5 L44 81.5 M55 42.5 L58.5 39 M62.5 42.5 C62.5 46.366 59.366 49.5 55.5 49.5 C51.634 49.5 48.5 46.366 48.5 42.5 C48.5 38.634 51.634 35.5 55.5 35.5 C59.366 35.5 62.5 38.634 62.5 42.5 Z",viewW:110,viewH:110}},{id:"chair",group:"furniture",art:{d:"M41.25 60.5 L68.75 60.5 M68.75 60.5 C70.5449 60.5 72 59.0449 72 57.25 C72 55.6281 70.8119 54.2836 69.2585 54.0395 C69.0928 54.0135 68.923 54 68.75 54 L41.25 54 C41.077 54 40.9072 54.0135 40.7415 54.0395 C39.1881 54.2836 38 55.6281 38 57.25 C38 59.0449 39.4551 60.5 41.25 60.5 M41.25 60.5 L46 60.5 M68.75 60.5 L64 60.5 M64 60.5 L69.5 60.5 L69.5 82 C69.5 82.8284 68.8284 83.5 68 83.5 L67.3752 83.5 C66.5972 83.5 65.9483 82.9051 65.8809 82.1299 L64 60.5 Z M64 60.5 L46 60.5 M46 60.5 L40.5 60.5 L40.5 82 C40.5 82.8284 41.1716 83.5 42 83.5 L42.6248 83.5 C43.4028 83.5 44.0517 82.9051 44.1191 82.1299 L46 60.5 Z M40.7415 54.0395 C40.5847 53.5546 40.5 53.0372 40.5 52.5 L40.5 39.5 C40.5 32.5964 46.0964 27 53 27 L57 27 C63.9036 27 69.5 32.5964 69.5 39.5 L69.5 52.5 C69.5 53.0372 69.4153 53.5546 69.2585 54.0395",viewW:110,viewH:110}},{id:"coffee_table",group:"furniture",art:{d:"M85.2381 55 L86.5 55 C87.0523 55 87.5 54.5523 87.5 54 L87.5 51 L84.6598 43.4847 C84.2586 42.5818 83.3633 42 82.3753 42 L26.6247 42 C25.6367 42 24.7414 42.5818 24.3402 43.4847 L21.5 51 L21.5 54 C21.5 54.5523 21.9477 55 22.5 55 L25 55 M87.5 51 L21.5 51 M25 55 L25 66.5 C25 67.3284 25.6716 68 26.5 68 L27.2113 68 C27.983 68 28.6288 67.4144 28.7041 66.6464 L29.8459 55 M25 55 L29.8459 55 M29.8459 55 L80.3922 55 M80.3922 55 L81.534 66.6464 C81.6093 67.4144 82.2551 68 83.0268 68 L83.7381 68 C84.5665 68 85.2381 67.3284 85.2381 66.5 L85.2381 55 M80.3922 55 L85.2381 55",viewW:110,viewH:110}},{id:"computer",group:"appliance",art:{d:"M43 65 L48 65 M43 65 L24.5 65 C23.1193 65 22 63.8807 22 62.5 L22 40.5 C22 39.1193 23.1193 38 24.5 38 L64.5 38 C65.8807 38 67 39.1193 67 40.5 L67 62.5 C67 63.8807 65.8807 65 64.5 65 L48 65 M43 65 L43 72 M48 65 L48 72 M37 72 L43 72 M54.0711 72 L48 72 M76 60 L84 60 M76 43 L84 43 M35 53 L35 46 L39.5 46 C40.4283 46 41.3185 46.3687 41.9749 47.0251 C42.6313 47.6815 43 48.5717 43 49.5 C43 50.4283 42.6312 51.3185 41.9749 51.9749 C41.3185 52.6313 40.4283 53 39.5 53 L35 53 Z M35 53 L35 56 M54.5355 54.5355 C53.8363 55.2348 52.9454 55.711 51.9755 55.9039 C51.0055 56.0969 50.0002 55.9978 49.0866 55.6194 C48.173 55.241 47.3921 54.6001 46.8427 53.7779 C46.2932 52.9556 46 51.9889 46 51 C46 50.0111 46.2932 49.0444 46.8427 48.2221 C47.3921 47.3999 48.173 46.759 49.0866 46.3806 C50.0002 46.0022 51.0055 45.9031 51.9755 46.0961 C52.9454 46.289 53.8363 46.7652 54.5355 47.4645 M48 72 L43 72 M74.5 72 L85.5 72 C86.8807 72 88 70.8807 88 69.5 L88 40.5 C88 39.1193 86.8807 38 85.5 38 L74.5 38 C73.1193 38 72 39.1193 72 40.5 L72 69.5 C72 70.8807 73.1193 72 74.5 72 Z",viewW:110,viewH:110}},{id:"cooktop",group:"appliance",art:{d:"M25 31.5 C25 30.1193 26.1193 29 27.5 29 L82.5 29 C83.8807 29 85 30.1193 85 31.5 L85 78.5 C85 79.8807 83.8807 81 82.5 81 L27.5 81 C26.1193 81 25 79.8807 25 78.5 L25 31.5 Z M49.5 66.5 C49.5 70.9183 45.9183 74.5 41.5 74.5 C37.0817 74.5 33.5 70.9183 33.5 66.5 C33.5 62.0817 37.0817 58.5 41.5 58.5 C45.9183 58.5 49.5 62.0817 49.5 66.5 Z M76 43.5 C76 47.9183 72.4183 51.5 68 51.5 C63.5817 51.5 60 47.9183 60 43.5 C60 39.0817 63.5817 35.5 68 35.5 C72.4183 35.5 76 39.0817 76 43.5 Z M73 66.5 C73 69.2614 70.7614 71.5 68 71.5 C65.2386 71.5 63 69.2614 63 66.5 C63 63.7386 65.2386 61.5 68 61.5 C70.7614 61.5 73 63.7386 73 66.5 Z M49.5 43.5 C49.5 47.9183 45.9183 51.5 41.5 51.5 C37.0817 51.5 33.5 47.9183 33.5 43.5 C33.5 39.0817 37.0817 35.5 41.5 35.5 C45.9183 35.5 49.5 39.0817 49.5 43.5 Z",viewW:110,viewH:110}},{id:"dining_table",group:"furniture",art:{d:"M26.875 47 L23.5 47 C22.9477 47 22.5 46.5523 22.5 46 L22.5 43 L24.8802 35.5939 C25.2539 34.633 26.1791 34 27.2102 34 L83.7898 34 C84.8209 34 85.7462 34.633 86.1198 35.5939 L88.5 43 L88.5 46 C88.5 46.5523 88.0523 47 87.5 47 L84.125 47 M22.5 43 L88.5 43 M78.875 47 L84.742 73.8205 C84.8926 74.5092 85.5024 75 86.2073 75 L86.7474 75 C87.6682 75 88.3716 74.1781 88.2294 73.2684 L84.125 47 M78.875 47 L84.125 47 M78.875 47 L32.125 47 M32.125 47 L26.258 73.8205 C26.1074 74.5092 25.4976 75 24.7927 75 L24.2526 75 C23.3318 75 22.6284 74.1781 22.7706 73.2684 L26.875 47 M32.125 47 L26.875 47",viewW:110,viewH:110}},{id:"dishwasher",group:"appliance",art:{d:"M81 82.5 L81 27.5 M81 82.5 C81 83.8807 79.8807 85 78.5 85 L31.5 85 C30.1193 85 29 83.8807 29 82.5 L29 55.5 M81 82.5 L81 40 M81 27.5 C81 26.1193 79.8807 25 78.5 25 L31.5 25 C30.1193 25 29 26.1193 29 27.5 M81 27.5 L81 40 M29 27.5 L29 55.5 M29 27.5 L29 40 M81 40 C81 38.6193 79.8807 37.5 78.5 37.5 L31.5 37.5 C30.1193 37.5 29 38.6193 29 40 M29 40 L29 55.5 M35.75 31 L45.25 31 M55.9943 55 C55.9943 55 54.6654 56.8105 54.5153 58.1429 C54.3169 59.9042 56.1139 60.6968 55.9943 62.4643 C55.8942 63.9429 54.5153 66 54.5153 66 M60.4943 55 C60.4943 55 59.1654 56.8105 59.0153 58.1429 C58.8169 59.9042 60.6139 60.6968 60.4943 62.4643 C60.3942 63.9429 59.0153 66 59.0153 66 M50.9943 55 C50.9943 55 49.6654 56.8105 49.5153 58.1429 C49.3169 59.9042 51.1139 60.6968 50.9943 62.4643 C50.8942 63.9429 49.5153 66 49.5153 66 M72 60.5 C72 69.8888 64.3888 77.5 55 77.5 C45.6112 77.5 38 69.8888 38 60.5 C38 51.1112 45.6112 43.5 55 43.5 C64.3888 43.5 72 51.1112 72 60.5 Z M66.5 60.5 C66.5 66.8513 61.3513 72 55 72 C48.6487 72 43.5 66.8513 43.5 60.5 C43.5 54.1487 48.6487 49 55 49 C61.3513 49 66.5 54.1487 66.5 60.5 Z M69.5 31 C69.5 32.1046 68.6046 33 67.5 33 C66.3954 33 65.5 32.1046 65.5 31 C65.5 29.8954 66.3954 29 67.5 29 C68.6046 29 69.5 29.8954 69.5 31 Z M77 31 C77 32.1046 76.1046 33 75 33 C73.8954 33 73 32.1046 73 31 C73 29.8954 73.8954 29 75 29 C76.1046 29 77 29.8954 77 31 Z",viewW:110,viewH:110}},{id:"dryer",group:"appliance",art:{d:"M81 82.5 L81 27.5 M81 82.5 C81 83.8807 79.8807 85 78.5 85 L31.5 85 C30.1193 85 29 83.8807 29 82.5 L29 55.5 M81 82.5 L81 40 M81 27.5 C81 26.1193 79.8807 25 78.5 25 L31.5 25 C30.1193 25 29 26.1193 29 27.5 M81 27.5 L81 40 M29 27.5 L29 55.5 M29 27.5 L29 40 M81 40 C81 38.6193 79.8807 37.5 78.5 37.5 L31.5 37.5 C30.1193 37.5 29 38.6193 29 40 M29 40 L29 55.5 M35.75 31 L45.25 31 M55.9943 55 C55.9943 55 54.6654 56.8105 54.5153 58.1429 C54.3169 59.9042 56.1139 60.6968 55.9943 62.4643 C55.8942 63.9429 54.5153 66 54.5153 66 M60.4943 55 C60.4943 55 59.1654 56.8105 59.0153 58.1429 C58.8169 59.9042 60.6139 60.6968 60.4943 62.4643 C60.3942 63.9429 59.0153 66 59.0153 66 M50.9943 55 C50.9943 55 49.6654 56.8105 49.5153 58.1429 C49.3169 59.9042 51.1139 60.6968 50.9943 62.4643 C50.8942 63.9429 49.5153 66 49.5153 66 M72 60.5 C72 69.8888 64.3888 77.5 55 77.5 C45.6112 77.5 38 69.8888 38 60.5 C38 51.1112 45.6112 43.5 55 43.5 C64.3888 43.5 72 51.1112 72 60.5 Z M66.5 60.5 C66.5 66.8513 61.3513 72 55 72 C48.6487 72 43.5 66.8513 43.5 60.5 C43.5 54.1487 48.6487 49 55 49 C61.3513 49 66.5 54.1487 66.5 60.5 Z M69.5 31 C69.5 32.1046 68.6046 33 67.5 33 C66.3954 33 65.5 32.1046 65.5 31 C65.5 29.8954 66.3954 29 67.5 29 C68.6046 29 69.5 29.8954 69.5 31 Z M77 31 C77 32.1046 76.1046 33 75 33 C73.8954 33 73 32.1046 73 31 C73 29.8954 73.8954 29 75 29 C76.1046 29 77 29.8954 77 31 Z",viewW:110,viewH:110}},{id:"exercise",group:"other",art:{d:"M55.091 60.072 L65.7741 35.5156 M42.2119 56.2083 L55.091 60.072 L60.8511 61.8001 L66.5032 63.4957 C70.733 64.7646 73.6297 68.6579 73.6297 73.074 L73.6297 76.2635 L29.3385 76.2635 L29.3385 65.7866 C29.3385 60.9371 32.7227 57.0804 37.0256 56.051 C38.5108 55.6956 40.1055 55.6771 41.7081 56.0709 M41.7081 56.0709 C41.876 56.1122 42.044 56.1579 42.2119 56.2083 L60.8511 61.8001 M71.9311 35.5156 L76.4108 35.5156 C78.2451 35.5156 79.9321 34.5112 80.8064 32.8987 L83.8375 27.308 C84.3011 26.4529 83.9993 25.384 83.1569 24.8976 C82.2982 24.4018 81.2002 24.696 80.7045 25.5547 L77.8652 30.4723 C77.3293 31.4005 76.3389 31.9723 75.2671 31.9723 L65.6573 31.9723 C64.6788 31.9723 63.8856 32.7655 63.8856 33.744 C63.8856 34.7224 64.6788 35.5156 65.6573 35.5156 L65.7741 35.5156 M71.9311 35.5156 C71.9603 35.7673 71.9261 36.0298 71.8188 36.2793 L60.8511 61.8001 M71.9311 35.5156 L65.7741 35.5156 M41.7081 56.0709 L38.03 42.6022 M37.0256 56.051 L33.3529 42.6022 M38.03 42.6022 L33.3529 42.6022 L29.7814 42.6022 C28.5583 42.6022 27.5668 41.6107 27.5668 40.3876 C27.5668 39.1646 28.5583 38.1731 29.7814 38.1731 L41.2971 38.1731 C42.5202 38.1731 43.5117 39.1646 43.5117 40.3876 C43.5117 41.6107 42.5202 42.6022 41.2971 42.6022 L38.03 42.6022 Z M25.7952 78.921 C25.7952 77.4533 26.985 76.2635 28.4526 76.2635 L74.5155 76.2636 C75.9832 76.2636 77.173 77.4533 77.173 78.921 C77.173 80.3887 75.9832 81.5785 74.5155 81.5785 L28.4526 81.5785 C26.985 81.5785 25.7952 80.3887 25.7952 78.921 Z M29.3385 81.5785 L29.3385 84.5677 C29.3385 85.3962 30.01 86.0677 30.8385 86.0677 L33.6379 86.0677 C34.2512 86.0677 34.8028 85.6943 35.0306 85.1248 L36.5002 81.5785 L29.3385 81.5785 Z M73.6297 81.5785 L73.6297 84.5677 C73.6297 85.3962 72.9581 86.0677 72.1297 86.0677 L69.3303 86.0677 C68.717 86.0677 68.1654 85.6943 67.9376 85.1248 L66.5002 81.5785 L73.6297 81.5785 Z M45.2833 66.0766 C45.2833 68.7673 43.102 70.9486 40.4113 70.9486 C37.7205 70.9486 35.5392 68.7673 35.5392 66.0766 C35.5392 63.3858 37.7205 61.2045 40.4113 61.2045 C43.102 61.2045 45.2833 63.3858 45.2833 66.0766 Z",viewW:110,viewH:110}},{id:"fireplace",group:"other",art:{d:"M71.1884 73.8943 L71.1884 50.4399 C71.1884 47.6784 68.9498 45.4399 66.1884 45.4399 L43.1445 45.4399 C40.3831 45.4399 38.1445 47.6784 38.1445 50.4399 L38.1445 73.8942 M38.1445 73.8942 L26.7031 73.8942 L26.7031 34.4252 L82.6629 34.4252 L82.6629 73.8942 L71.1884 73.8943 L38.1445 73.8942 Z M62.0101 62.8795 L47.3239 62.8795 C45.8031 62.8795 44.5703 64.1124 44.5703 65.6332 C44.5703 67.154 45.8031 68.3868 47.3239 68.3868 M47.3239 68.3868 C45.8031 68.3868 44.5703 69.6195 44.5703 71.1403 C44.5703 72.6611 45.8031 73.894 47.3239 73.894 M47.3239 68.3868 C48.8447 68.3868 50.0776 69.6195 50.0776 71.1403 C50.0776 72.6611 48.8447 73.894 47.3239 73.894 M47.3239 68.3868 L61.9918 68.3868 M47.3239 73.894 L62.0101 73.894 C63.5309 73.894 64.7637 72.6611 64.7637 71.1403 C64.7637 69.6242 63.5385 68.3945 62.0243 68.3869 M62.0114 68.3869 C62.0049 68.3869 61.9983 68.3869 61.9918 68.3868 M62.0114 68.3869 C62.0157 68.3869 62.02 68.3869 62.0243 68.3869 M62.0114 68.3869 L62.0243 68.3869 M62.0114 68.3869 L61.9918 68.3868 M61.9918 68.3868 C60.48 68.3763 59.2578 67.1475 59.2578 65.6332 C59.2578 64.1124 60.4906 62.8796 62.0114 62.8796 C63.5322 62.8796 64.7651 64.1124 64.7651 65.6332 C64.7651 67.1498 63.5392 68.3799 62.0243 68.3869 M61.9918 68.3868 L62.0101 68.3868 C62.0148 68.3868 62.0195 68.3868 62.0243 68.3869 M24 81.6962 L85.3341 81.6962 C85.8864 81.6962 86.3341 81.2485 86.3341 80.6962 L86.3341 74.8942 C86.3341 74.3419 85.8864 73.8942 85.3341 73.8942 L24 73.8942 C23.4477 73.8942 23 74.3419 23 74.8942 L23 80.6962 C23 81.2485 23.4477 81.6962 24 81.6962 Z M24 34.4252 L85.3341 34.4252 C85.8864 34.4252 86.3341 33.9775 86.3341 33.4252 L86.3341 29 C86.3341 28.4477 85.8864 28 85.3341 28 L24 28 C23.4477 28 23 28.4477 23 29 L23 33.4252 C23 33.9775 23.4477 34.4252 24 34.4252 Z",viewW:110,viewH:110}},{id:"fridge",group:"appliance",art:{d:"M35.5 87 C34.1193 87 33 85.8807 33 84.5 M35.5 87 L74.5 87 M35.5 87 L35.5 90.5 C35.5 91.0523 35.9477 91.5 36.5 91.5 L73.5 91.5 C74.0523 91.5 74.5 91.0523 74.5 90.5 L74.5 87 M33 84.5 L33 20.5 M33 84.5 L33 46.5 M77.5 84.5 L77.5 20.5 M77.5 84.5 C77.5 85.8807 76.3807 87 75 87 L74.5 87 M77.5 84.5 L77.5 46.5 M77.5 20.5 C77.5 19.1193 76.3807 18 75 18 L35.5 18 C34.1193 18 33 19.1193 33 20.5 M77.5 20.5 L77.5 46.5 M33 20.5 L33 46.5 M33 46.5 L77.5 46.5 M38.5 41 L38.5 31.5 M38.5 62 L38.5 52.5",viewW:110,viewH:110}},{id:"hood",group:"appliance",art:{d:"M66 57 L83 69 L83 71.5 C83 72.8807 81.8807 74 80.5 74 L29.5 74 C28.1193 74 27 72.8807 27 71.5 L27 69 L44 57 M44 57 L66 57 M44 57 L44 37.5 C44 36.1193 45.1193 35 46.5 35 L63.5 35 C64.8807 35 66 36.1193 66 37.5 L66 57 M83 69 L27 69",viewW:110,viewH:110}},{id:"kitchen_cabinet",group:"furniture",art:{d:"M72 84.95 L72 88 C72 88.5523 71.5523 89 71 89 L39 89 C38.4477 89 38 88.5523 38 88 L38 84.95 M55 20 L71.5 20 C72.8807 20 74 21.1193 74 22.5 L74 39.5 C74 40.8807 72.8807 42 71.5 42 L55 42 M55 20 L55 42 M55 20 L38.5 20 C37.1193 20 36 21.1193 36 22.5 L36 39.5 C36 40.8807 37.1193 42 38.5 42 L55 42 M59 33 L59 38 M51 33 L51 38 M55 85 L71.5 85 C72.8807 85 74 83.8807 74 82.5 L74 65.5 C74 64.1193 72.8807 63 71.5 63 L55 63 M55 85 L55 63 M55 85 L38.5 85 C37.1193 85 36 83.8807 36 82.5 L36 65.5 C36 64.1193 37.1193 63 38.5 63 L55 63 M67 67 L62 67 M48 67 L43 67",viewW:110,viewH:110}},{id:"kitchen_sink",group:"sanitary",art:{d:"M49 54 L49 59 M51.5 37.5 L44 37.5 M51.5 37.5 C52.0523 37.5 52.5 37.9477 52.5 38.5 L52.5 44 M51.5 37.5 L48 37.5 M44 37.5 C43.4477 37.5 43 37.9477 43 38.5 L43 44 M44 37.5 L48 37.5 M43 44 L21.5 44 C20.1193 44 19 45.1193 19 46.5 L19 81.5 C19 82.8807 20.1193 84 21.5 84 L89.5 84 C90.8807 84 92 82.8807 92 81.5 L92 46.5 C92 45.1193 90.8807 44 89.5 44 L52.5 44 M43 44 L52.5 44 M58 33 L58 31 C58 29.6739 57.4732 28.4021 56.5355 27.4645 C55.5979 26.5268 54.3261 26 53 26 C51.6739 26 50.4021 26.5268 49.4645 27.4645 C48.5268 28.4021 48 29.6739 48 31 L48 37.5 M62 54 L62 59 M26 50 L52.5 50 C53.0523 50 53.5 50.4477 53.5 51 L53.5 77 C53.5 77.5523 53.0523 78 52.5 78 L26 78 C25.4477 78 25 77.5523 25 77 L25 51 C25 50.4477 25.4477 50 26 50 Z M58.5 50 L85 50 C85.5523 50 86 50.4477 86 51 L86 77 C86 77.5523 85.5523 78 85 78 L58.5 78 C57.9477 78 57.5 77.5523 57.5 77 L57.5 51 C57.5 50.4477 57.9477 50 58.5 50 Z",viewW:110,viewH:110}},{id:"nightstand",group:"furniture",art:{d:"M34.5 76 C33.1193 76 32 74.8807 32 73.5 M34.5 76 L41.2308 76 M34.5 76 C34.3288 76 34.1616 75.9828 34 75.95 L34 78.5 C34 79.3284 34.6716 80 35.5 80 L38.8921 80 C39.5506 80 40.1321 79.5705 40.3258 78.9411 L41.2308 76 M32 73.5 L32 33 M32 73.5 L32 57.5 M78 73.5 L78 33 M69.2692 76 L75.5 76 C75.8556 76 76.1938 75.9258 76.5 75.792 C77.383 75.4062 78 74.5252 78 73.5 M78 73.5 L78 57.5 M78 33 C78 31.6193 76.8807 30.5 75.5 30.5 L34.5 30.5 C33.1193 30.5 32 31.6193 32 33 M78 33 L78 39.5 M32 33 L32 39.5 M32 39.5 L78 39.5 M32 39.5 L32 57.5 M78 39.5 L78 57.5 M78 57.5 L32 57.5 M50.5 48.5 L60 48.5 M50.5 66 L60 66 M41.2308 76 L69.2692 76 M69.2692 76 L70.1742 78.9411 C70.3679 79.5705 70.9494 80 71.6079 80 L75 80 C75.8284 80 76.5 79.3284 76.5 78.5 L76.5 75.792",viewW:110,viewH:110}},{id:"oven",group:"appliance",art:{d:"M29 76 C29 77.3807 30.1193 78.5 31.5 78.5 L78.5 78.5 C79.8807 78.5 81 77.3807 81 76 M29 76 L29 40 M29 76 L29 82.5 C29 83.8807 30.1193 85 31.5 85 L78.5 85 C79.8807 85 81 83.8807 81 82.5 L81 76 M81 76 L81 40 M81 40 C81 38.6193 79.8807 37.5 78.5 37.5 L31.5 37.5 C30.1193 37.5 29 38.6193 29 40 M81 40 L81 27.5 C81 26.1193 79.8807 25 78.5 25 L31.5 25 C30.1193 25 29 26.1193 29 27.5 L29 40 M35.75 31 L45.25 31 M43 42 L67 42 M40.5 72 L69.5 72 C70.8807 72 72 70.8807 72 69.5 L72 49.5 C72 48.1193 70.8807 47 69.5 47 L40.5 47 C39.1193 47 38 48.1193 38 49.5 L38 69.5 C38 70.8807 39.1193 72 40.5 72 Z M69.5 31 C69.5 32.1046 68.6046 33 67.5 33 C66.3954 33 65.5 32.1046 65.5 31 C65.5 29.8954 66.3954 29 67.5 29 C68.6046 29 69.5 29.8954 69.5 31 Z M77 31 C77 32.1046 76.1046 33 75 33 C73.8954 33 73 32.1046 73 31 C73 29.8954 73.8954 29 75 29 C76.1046 29 77 29.8954 77 31 Z",viewW:110,viewH:110}},{id:"plant",group:"other",art:{d:"M55.7064 55.8805 L55.7064 52.9357 M55.7064 52.9357 C56.839 47.0461 62.7965 41.9801 68.6182 37.5322 M55.7064 52.9357 C50.7678 48.7899 47.7236 46.7763 41.6621 43.8748 M67.4992 61.3174 L65.9151 75.8488 C65.7779 77.1181 64.7063 78.0801 63.4296 78.0801 L48.4373 78.0801 C47.1606 78.0801 46.089 77.1181 45.9518 75.8488 L44.3593 61.3174 L67.4992 61.3174 Z M60.2363 44.7807 C58.4234 36.1732 66.8047 29.604 76.9989 31.869 C76.9989 40.024 68.3904 48.6318 60.2363 44.7807 Z M50.476 49.9288 C51.9926 41.2641 43.391 34.9863 33.2805 37.5996 C33.5602 45.7498 42.4589 54.0573 50.476 49.9288 Z M43.1152 61.3174 L68.7509 61.3174 C69.3031 61.3174 69.7509 60.8697 69.7509 60.3174 L69.7509 56.8809 C69.7509 56.3286 69.3031 55.8809 68.7509 55.8809 L43.1152 55.8809 C42.5629 55.8809 42.1152 56.3286 42.1152 56.8809 L42.1152 60.3174 C42.1152 60.8697 42.5629 61.3174 43.1152 61.3174 Z",viewW:110,viewH:110}},{id:"rug",group:"other",art:{d:"M90.2693 33.8735 L84.648 33.8735 M25.6208 33.8735 L19.9995 33.8735 M90.2693 39.0264 L84.648 39.0264 M25.6208 39.0264 L19.9995 39.0264 M90.2693 44.1792 L84.648 44.1792 M25.6208 44.1792 L19.9995 44.1792 M90.2693 49.332 L84.648 49.332 M25.6208 49.332 L19.9995 49.332 M90.2693 54.4854 L84.648 54.4854 M25.6208 54.4854 L19.9995 54.4854 M90.2693 59.6382 L84.648 59.6382 M25.6208 59.6382 L19.9995 59.6382 M90.2693 64.791 L84.648 64.791 M25.6208 64.791 L19.9995 64.791 M90.2693 69.9438 L84.648 69.9438 M25.6208 69.9438 L19.9995 69.9438 M90.2693 75.0967 L84.648 75.0967 M25.6208 75.0967 L19.9995 75.0967 M28.121 32 L82.145 32 C83.5257 32 84.645 33.1193 84.645 34.5 L84.645 74.939 C84.645 76.3197 83.5257 77.439 82.145 77.439 L28.121 77.439 C26.7403 77.439 25.621 76.3197 25.621 74.939 L25.621 34.5 C25.621 33.1193 26.7403 32 28.121 32 Z M29.8369 32 L29.8369 77.439 M80.4302 32 L80.4302 77.439 M37.8005 54.4852 L55.6014 46.0532 L73.4022 54.4852 L55.6014 62.9172 L37.8005 54.4852 Z",viewW:110,viewH:110}},{id:"shelving",group:"furniture",art:{d:"M64 58.5 L64 47 C64 46.4477 64.4477 46 65 46 L68 46 C68.5523 46 69 46.4477 69 47 M64 58.5 L69 58.5 M64 58.5 L28 58.5 L28 39 L35.5 39 M69 58.5 L69 47 M69 58.5 L69 44.5 M69 58.5 L76 58.5 M69 47 L69 44.5 M52.5 39 L52.5 27.5 C52.5 26.9477 52.0523 26.5 51.5 26.5 L48.5 26.5 C47.9477 26.5 47.5 26.9477 47.5 27.5 M52.5 39 L47.5 39 M52.5 39 L81 39 L81 58.5 L76 58.5 M47.5 39 L47.5 27.5 M47.5 39 L47.5 25 M47.5 39 L40.5 39 M47.5 27.5 L47.5 25 M40.5 39 L40.5 27.5 M40.5 39 L40.5 25 M40.5 39 L35.5 39 M35.5 39 L35.5 27.5 C35.5 26.9477 35.9477 26.5 36.5 26.5 L39.5 26.5 C40.0523 26.5 40.5 26.9477 40.5 27.5 M40.5 27.5 L40.5 25 M49 72 L36.5 72 M50.5 72 L36.5 72 C35.9477 72 35.5 71.5523 35.5 71 L35.5 68.5 C35.5 67.9477 35.9477 67.5 36.5 67.5 L49 67.5 C49.5523 67.5 50 67.9477 50 68.5 L50 71 C50 71.5523 49.5523 72 49 72 M50.5 78 C51.0523 78 51.5 77.5523 51.5 77 L51.5 73 C51.5 72.4477 51.0523 72 50.5 72 L49 72 M36.5 72 C35.9477 72 35.5 72.4477 35.5 73 L35.5 77 C35.5 77.5523 35.9477 78 36.5 78 M76 58.5 L76 44.5 C76 43.9477 75.5523 43.5 75 43.5 L70 43.5 C69.4477 43.5 69 43.9477 69 44.5 M47.5 25 C47.5 24.4477 47.0523 24 46.5 24 L41.5 24 C40.9477 24 40.5 24.4477 40.5 25 M50.5 78 L36.5 78 M50.5 78 L81 78 L81 85 L28 85 L28 78 L36.5 78 M28 89.5 L28 23 C28 21.6193 29.1193 20.5 30.5 20.5 L78.5 20.5 C79.8807 20.5 81 21.6193 81 23 L81 89.5",viewW:110,viewH:110}},{id:"shower",group:"sanitary",art:{d:"M39 84 L39 31.7143 C39 25.245 44.2564 20 50.75 20 C56.4663 20 61.2394 24.5462 62.1824 29.0091 M51.5 39.25 C51.5 33.5891 56.0891 29 61.75 29 C67.4109 29 72 33.5891 72 39.25 L51.5 39.25 M54.75 44.25 L54.75 46.75 M62 44.25 L62 46.75 M69.25 44.25 L69.25 46.75 M54.75 50.5 L54.75 53 M62 50.5 L62 53 M69.25 50.5 L69.25 53 M54.75 56.75 L54.75 59.25 M62 56.75 L62 59.25 M69.25 56.75 L69.25 59.25 M54.75 63 L54.75 65.5 M62 63 L62 65.5 M69.25 63 L69.25 65.5 M31 84 L80 84 C80.5523 84 81 84.4477 81 85 L81 88 C81 88.5523 80.5523 89 80 89 L31 89 C30.4477 89 30 88.5523 30 88 L30 85 C30 84.4477 30.4477 84 31 84",viewW:110,viewH:110}},{id:"sink",group:"sanitary",art:{d:"M51 41.5 L58.5 41.5 M51 41.5 C50.4477 41.5 50 41.9477 50 42.5 L50 48 M51 41.5 L55 41.5 M58.5 41.5 C59.0523 41.5 59.5 41.9477 59.5 42.5 L59.5 48 M58.5 41.5 L55 41.5 M59.5 48 L77 48 C78.3807 48 79.5 49.1193 79.5 50.5 L79.5 57 C79.5 62.5228 75.0228 67 69.5 67 L40 67 C34.4772 67 30 62.5228 30 57 L30 50.5 C30 49.1193 31.1193 48 32.5 48 L50 48 M59.5 48 L50 48 M45 37 L45 35 C45 33.6739 45.5268 32.4021 46.4645 31.4645 C47.4021 30.5268 48.6739 30 50 30 C51.3261 30 52.5979 30.5268 53.5355 31.4645 C54.4732 32.4021 55 33.6739 55 35 L55 41.5 M45 80 L64.5 80 C65.0523 80 65.5 79.5523 65.5 79 L65.5 67 L44 67 L44 79 C44 79.5523 44.4477 80 45 80 Z",viewW:110,viewH:110}},{id:"sofa",group:"furniture",art:{d:"M88.5 44.6689 L88.5 34 C88.5 31.2386 86.2614 29 83.5 29 L59.5 29 C56.7386 29 54.5 31.2386 54.5 34 M88.5 44.6689 C89.2354 44.2435 90.0893 44 91 44 M88.5 44.6689 C88.3992 44.7272 88.3006 44.7889 88.2045 44.8539 M54.5 61.75 L54.5 34 M54.5 61.75 C54.5 64.3734 52.3734 66.5 49.75 66.5 L25.25 66.5 C22.6266 66.5 20.5 64.3734 20.5 61.75 M54.5 61.75 C54.5 59.1266 52.3734 57 49.75 57 L25.25 57 C24.6761 57 24.1261 57.1018 23.6168 57.2882 M54.5 61.75 C54.5 64.3734 56.6266 66.5 59.25 66.5 L83.75 66.5 C86.3734 66.5 88.5 64.3734 88.5 61.75 M88.5 61.75 C88.5 59.9118 87.4558 58.3175 85.9283 57.5278 C85.8889 57.5075 85.8493 57.4877 85.8093 57.4684 C85.1863 57.1682 84.4878 57 83.75 57 L59.25 57 C56.6266 57 54.5 59.1266 54.5 61.75 M54.5 34 C54.5 31.2386 52.2614 29 49.5 29 L25.5 29 C22.7386 29 20.5 31.2386 20.5 34 L20.5 44.416 M20.5 44.416 C19.8875 44.1484 19.2111 44 18.5 44 M20.5 44.416 C22.2659 45.1876 23.5 46.9497 23.5 49 M18.5 44 C21.2614 44 23.5 46.2386 23.5 49 M18.5 44 L18 44 C15.2386 44 13 46.2386 13 49 L13 70.5 C13 73.2614 15.2386 75.5 18 75.5 M23.5 49 L23.5 57.3328 M23.5 57.3328 C21.7427 58.0295 20.5 59.7446 20.5 61.75 M23.5 57.3328 C23.5387 57.3174 23.5776 57.3026 23.6168 57.2882 M91 44 C89.9645 44 89.0025 44.3148 88.2045 44.8539 C86.8744 45.7525 86 47.2741 86 49 L86 57.5657 M85.9283 57.5278 C85.9523 57.5402 85.9762 57.5528 86 57.5657 C87.4884 58.3677 88.5 59.9407 88.5 61.75 M91 44 L91.5 44 C94.2614 44 96.5 46.2386 96.5 49 L96.5 70.5 C96.5 73.2614 94.2614 75.5 91.5 75.5 M91.5 75.5 L18 75.5 M91.5 75.5 L90.5 75.5 M18 75.5 L18.5 75.5 M20.5 61.75 C20.5 59.7005 21.798 57.9542 23.6168 57.2882 M18.5 75.5 L26.5 75.5 M18.5 75.5 L18.5 80.5 C18.5 81.3284 19.1716 82 20 82 L23.3921 82 C24.0506 82 24.6321 81.5705 24.8258 80.9411 L26.5 75.5 M26.5 75.5 L82.5 75.5 M90.5 75.5 L82.5 75.5 M90.5 75.5 L90.5 80.5 C90.5 81.3284 89.8284 82 89 82 L85.6079 82 C84.9494 82 84.3679 81.5705 84.1742 80.9411 L82.5 75.5",viewW:110,viewH:110}},{id:"stairs",group:"other",art:{d:"M73.4707 46.8057 L73.4707 28.5242 M73.4707 46.8057 L73.1504 46.8057 M73.4707 46.8057 L82.6039 46.8057 M73.4707 28.5242 L73.425 28.5242 M73.4707 28.5242 L75.6731 28.5242 M62.8987 54.2946 L62.8987 36.7397 M61.5762 61.7837 L61.5762 55.2944 C61.5762 54.7421 62.0239 54.2944 62.5762 54.2944 L62.8987 54.2946 L72.1504 54.2945 M52.3262 61.7837 L52.3262 45.1306 M52.3262 61.7837 L52.0039 61.7837 M52.3262 61.7837 L61.5762 61.7837 M62.8987 36.7397 L52.3262 45.1306 L42.1934 53.1725 L31.6211 61.5632 M42.1934 69.2725 L42.1934 53.1725 M42.1934 69.2725 L41.873 69.2725 M83.6035 69.2725 L83.6024 69.2725 L51.0039 69.2725 L42.1934 69.2725 M83.6031 76.7612 L83.6031 83.25 C83.6031 83.8023 83.1554 84.25 82.6031 84.25 L31.6231 84.2499 M41.873 69.2725 L83.6035 69.2725 L83.6031 76.7612 M83.6031 76.7612 L31.6231 76.7612 M31.6231 76.7612 L40.873 76.7613 L83.6031 76.7612 M31.6231 84.2499 L27.7773 84.2499 C27.2251 84.2499 26.7773 83.8021 26.7773 83.2499 L26.7773 57.4971 C26.7773 56.9448 27.2251 56.4971 27.7773 56.4971 L28.9352 56.4971 M31.6231 84.2499 L31.6231 76.7612 M31.6231 76.7612 L31.6211 61.5632 L31.6231 56.4971 M29.0212 56.4971 L31.6231 56.4971 L31.6228 57.2227 M31.6211 61.5632 L62.8987 36.7397 M31.6211 61.5632 L31.6228 57.2227 M73.425 28.5242 L75.6731 28.5242 M73.425 28.5242 C73.3119 28.5242 73.202 28.5624 73.1134 28.6328 L62.8987 36.7397 M75.6731 28.5242 C76.6463 28.5242 77.4352 27.7353 77.4352 26.7621 C77.4352 25.7889 76.6463 25 75.6731 25 L71.9495 25 C71.7935 25 71.6421 25.0532 71.5204 25.1508 L31.6228 57.2227 M41.873 69.2725 C41.3208 69.2725 40.873 69.7202 40.873 70.2725 L40.873 76.7613 M52.0039 61.7837 L83.6024 61.7837 M52.0039 61.7837 C51.4516 61.7837 51.0039 62.2314 51.0039 62.7837 L51.0039 69.2725 M83.6022 54.2944 L83.6024 61.7837 L83.6024 69.2725 M83.6024 61.7837 L61.5762 61.7837 M83.6022 54.2944 L83.6039 47.8057 C83.6039 47.2534 83.1562 46.8057 82.6039 46.8057 M83.6022 54.2944 L72.1504 54.2945 M73.1504 46.8057 L82.6039 46.8057 M73.1504 46.8057 C72.5981 46.8057 72.1504 47.2534 72.1504 47.8057 L72.1504 54.2945 M28.9352 56.4971 C28.9495 56.4973 28.9638 56.4974 28.9782 56.4974 C28.9925 56.4974 29.0069 56.4973 29.0212 56.4971 M28.9352 56.4971 C27.2519 56.4741 25.8945 55.1024 25.8945 53.4137 C25.8945 51.7107 27.2751 50.3301 28.9782 50.3301 C30.6812 50.3301 32.0618 51.7107 32.0618 53.4137 C32.0618 55.1024 30.7044 56.4741 29.0212 56.4971 M28.9352 56.4971 L29.0212 56.4971",viewW:110,viewH:110}},{id:"toilet",group:"sanitary",art:{d:"M64.5372 72.1021 L67.6892 84.7575 C67.847 85.3886 67.3696 86 66.7191 86 L37.6483 86 C37.0414 86 36.5743 85.4636 36.6578 84.8624 L38.9999 68 C40.0716 64 32.5 64.5 32 57 L32 26.5 C32 25.1193 33.1193 24 34.5 24 L45 24 C46.3807 24 47.5 25.1193 47.5 26.5 L47.5 52 M32 57 L47.5 57 M47.5 52 L76.5 52 C77.8807 52 79 53.1193 79 54.5 L79 57 M47.5 52 L47.5 57 M54.9999 71.75 C58.5528 72.6096 61.7379 72.6416 64.5372 72.1021 C73.95 70.2877 79 62.0101 79 57 M79 57 L47.5 57",viewW:110,viewH:110}},{id:"tv",group:"appliance",art:{d:"M23.5 31 L86 31 C87.3807 31 88.5 32.1193 88.5 33.5 L88.5 67.5 C88.5 68.8807 87.3807 70 86 70 L23.5 70 C22.1193 70 21 68.8807 21 67.5 L21 33.5 C21 32.1193 22.1193 31 23.5 31 M50 70 L50 78 M59.5 70 L59.5 78 M40 78 L70 78 M42.5466 45.9951 L52.5466 45.9951 M47.5466 45.9951 L47.5 56.0336 M56.75 45.5 L61.75 55.5 L66.75 45.5",viewW:110,viewH:110}},{id:"wardrobe",group:"furniture",art:{d:"M54.5 20.5 L30.5 20.5 C29.1193 20.5 28 21.6193 28 23 L28 82.5 C28 83.8807 29.1193 85 30.5 85 L54.5 85 M54.5 20.5 L54.5 85 M54.5 20.5 L78.5 20.5 C79.8807 20.5 81 21.6193 81 23 L81 82.5 C81 83.8807 79.8807 85 78.5 85 L54.5 85 M79 84.95 L79 88.5 C79 89.0523 78.5523 89.5 78 89.5 L31 89.5 C30.4477 89.5 30 89.0523 30 88.5 L30 84.95 M50.5 48 L50.5 57.5 M58.5 48 L58.5 57.5",viewW:110,viewH:110}},{id:"washer",group:"appliance",art:{d:"M81 40 C81 38.6193 79.8807 37.5 78.5 37.5 L31.5 37.5 C30.1193 37.5 29 38.6193 29 40 M35.75 31 L45.25 31 M31.5 85 L78.5 85 C79.8807 85 81 83.8807 81 82.5 L81 55.5 L81 27.5 C81 26.1193 79.8807 25 78.5 25 L31.5 25 C30.1193 25 29 26.1193 29 27.5 L29 56 L29 82.5 C29 83.8807 30.1193 85 31.5 85 Z M72 60.5 C72 69.8888 64.3888 77.5 55 77.5 C45.6112 77.5 38 69.8888 38 60.5 C38 51.1112 45.6112 43.5 55 43.5 C64.3888 43.5 72 51.1112 72 60.5 Z M66.5 60.5 C66.5 66.8513 61.3513 72 55 72 C48.6487 72 43.5 66.8513 43.5 60.5 C43.5 54.1487 48.6487 49 55 49 C61.3513 49 66.5 54.1487 66.5 60.5 Z M69.5 31 C69.5 32.1046 68.6046 33 67.5 33 C66.3954 33 65.5 32.1046 65.5 31 C65.5 29.8954 66.3954 29 67.5 29 C68.6046 29 69.5 29.8954 69.5 31 Z M77 31 C77 32.1046 76.1046 33 75 33 C73.8954 33 73 32.1046 73 31 C73 29.8954 73.8954 29 75 29 C76.1046 29 77 29.8954 77 31 Z",viewW:110,viewH:110}},{id:"work_table",group:"furniture",art:{d:"M68.5 61 L68.5 73.5 C68.5 74.3284 69.1716 75 70 75 L87 75 C87.8284 75 88.5 74.3284 88.5 73.5 L88.5 61 L88.4844 47 M26.4844 47 L26.4844 73.5 C26.4844 74.3284 25.8128 75 24.9844 75 L23.9844 75 C23.1559 75 22.4844 74.3284 22.4844 73.5 L22.4844 47 L22.4844 43 L24.866 35.5974 C25.2388 34.6346 26.165 34 27.1974 34 L83.7743 34 C84.8054 34 85.7307 34.633 86.1044 35.5939 L88.4844 43 L88.4844 47 M88.4844 47 L68.5 47 M68.5 47 L68.5 61 M68.5 47 L26.4844 47 M68.5 61 L88.5 61 M76.5 51 L80.5 51 M88.4844 43 L22.4844 43 M22.4844 47 L26.4844 47 M76.5 65 L80.5 65",viewW:110,viewH:110}}];class Qc{constructor(t,e){this.host=t,this.hooks=e}place(t,e="mouse"){const s=this.host._decorImagePalette,i=this.host._curSpaceCfg;if(!s||!i)return;const o=this.hooks.decorSnap(t,e),a=$e(s.width,s.height),n=we(a.w,this.host._cellCm,this.host._gridPitch)/lt,r=we(a.h,this.host._cellCm,this.host._gridPitch)/this.host._decorH,l="di"+Date.now().toString(36)+Math.random().toString(36).slice(2,5),h=this.hooks.geometrySnapshot();i.decor=[...this.host._decorList,{id:l,kind:"image",asset_id:s.asset_id,x:le(o[0]/lt-n/2),y:le(o[1]/this.host._decorH-r/2),w:n,h:r,opacity:1}],this.host._decorSel=l,this.host._decorTool="select",this.host._decorImagePalette=null,this.hooks.clearFurniturePreview(),this.hooks.recordGeometry(this.host._t("history.decor_add"),h),this.hooks.saveConfig(),this.host.requestUpdate()}renderPlacementPreview(){const t=this.host._furnPreviewInput,e=this.host._decorImagePalette;if(!t||!e||"decor"!==this.host._mode||"image"!==this.host._decorTool||!this.host._pointerModality.hoverEnabled)return d;const s=this.hooks.decorSnap(t.raw,"mouse"),i=$e(e.width,e.height),o=we(i.w,this.host._cellCm,this.host._gridPitch)/lt,a=we(i.h,this.host._cellCm,this.host._gridPitch)/this.host._decorH,n=this.host._display(e.url);return n?At``:d}renderMissing(t,e,s,i,o,a,n,r,l){const h=i+a/2,c=o+n/2;return At`${this.host._t(t?"decor.image_place_hint":"decor.image_pick_hint")}
    - `}renderFurniturePalette(){const t=this.host._furnPalette,e=this.host._furnCategory,s=xe.flatMap(t=>Me(t)),i=Yc.filter(t=>s.some(e=>e.category===t.id)),o=i.find(t=>t.id===e)||null,a=o?s.filter(t=>t.category===o.id):[],n=this.host._t(this.host._imperial?"gs.unit_ft":"gs.unit_m");return p`
    t.stopPropagation()}> +
    `}renderFurniturePalette(){const t=this.host._furnPalette,e=this.host._furnCategory,s=xe.flatMap(t=>Me(t)),i=Xc.filter(t=>s.some(e=>e.category===t.id)),o=i.find(t=>t.id===e)||null,a=o?s.filter(t=>t.category===o.id):[],n=this.host._t(this.host._imperial?"gs.unit_ft":"gs.unit_m");return p`
    t.stopPropagation()}>
    ${this.host._t("furn.title")} @@ -1524,7 +1511,7 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db this.host._decorTextDialog={...t,sizeCm:this.host._decorTextCm(Number(e.target.value))}} /> ${this.host._t(this.host._imperial?"wallthick.unit_in":"wallthick.unit_cm")}
    @@ -1816,7 +1803,7 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db
    - `}_cssPxToRender(t){const e=this.host._stageEl,s=this.host._viewOr(this.host._baseVb());return e?.clientWidth&&e.clientHeight?Math.max(s.w/e.clientWidth,s.h/e.clientHeight)*t:this.host._gridPitch/8*t}_deleteRoomClick(t){const e=this.host._spaceModel();if(!e)return;const s=[...e.rooms].reverse().find(e=>this._pointInRoom(t,e));s?s.id&&(this.host._roomDeleteDialog={roomId:s.id,name:s.name}):this.host._showToast(this.host._t("toast.delete_room_pick"))}_wallThickHit(t){const e=this.host._spaceModel();if(!e)return null;const s=6*this.host._gridPitch,i=this.host._openCuts();let o=null;const a=(t,e,i)=>{e>s||(!o||e100)return void this._showPhysicalRange(100);if("room"!==e.source.kind){const t=this._geometrySnapshot(),i=(s.partitions||[]).find(t=>t.id===e.source.id);if(!i)return;if(0===n&&Fe(s.openings,{kind:"partition",id:i.id}))return void this.host._showToast(this.host._t("toast.zero_wall_opening_conflict"));i.cm=n,this.host._wallDialog=null;return this._commitPhysicalGeometry(this.host._t("history.wall_thickness"),t)&&this.host._showToast(this.host._t("toast.wallthick_set")),void this.host.requestUpdate()}const r=this._geometrySnapshot(),l=n>0?n:null;if(0===n){const i=.02*this.host._gridPitch,o=[e.a[0],e.a[1],e.b[0],e.b[1]],a=(s.rooms||[]).find(t=>t.id===e.roomId),n=new Set(t&&a&&Array.isArray(a.wall_ids)?a.wall_ids:(s.wall_segments||[]).filter(t=>{const e=[Number(t.a?.[0])*wd,Number(t.a?.[1])*wd],s=[Number(t.b?.[0])*wd,Number(t.b?.[1])*wd];return ye(e,o)<=i&&ye(s,o)<=i}).map(t=>String(t.id))),r=(s.openings||[]).some(t=>{if("partition"===t.host?.kind)return!1;if("wall"===t.host?.kind&&n.has(t.host.id))return!0;if(t.host)return!1;const e=[Number(t.x)*wd,Number(t.y)*wd];return e.every(Number.isFinite)&&ye(e,o)<=i});if(r)return void this.host._showToast(this.host._t("toast.zero_wall_opening_conflict"))}let h,c=this.host._openCuts();if(n>0&&c.length){const o=[];if(t&&e.roomId){const t=(s.rooms||[]).find(t=>t.id===e.roomId),a=new Set(Array.isArray(t?.wall_ids)?t.wall_ids:[]);for(const t of s.wall_segments||[])a.has(t.id)&&o.push([Number(t.a?.[0])*wd,Number(t.a?.[1])*wd,Number(t.b?.[0])*wd,Number(t.b?.[1])*wd]);if(!o.length){const t=i.rooms.find(t=>t.id===e.roomId),s=t?N(t):null;for(let t=0;s&&t!o.some(e=>ye([t[0],t[1]],e)<=a&&ye([t[2],t[3]],e)<=a&&ye([e[0],e[1]],t)<=a&&ye([e[2],e[3]],t)<=a))}h=t&&e.roomId?Os(s.walls,i.rooms,e.roomId,l,this.host._wallKeyPitch,c,wd):j(s.walls,e.a,e.b,l,this.host._wallKeyPitch,wd),h=this.host._normalizeWalls(h,c);for(const t of s.wall_segments||[])t.cm=it(h,t.a,t.b,z,1);h.length?s.walls=h:delete s.walls,this.host._wallDialog=null,this._commitPhysicalGeometry(this.host._t("history.wall_thickness"),r)&&this.host._showToast(this.host._t(0===n?"toast.wallthick_cleared":"toast.wallthick_set")),this.host.requestUpdate()}_wallHatchDefs(t){if(!this.host._spaceWalls.length&&!this.host._physicalBodiesR().length&&!this.host._markup)return At``;const e=Bt(this.host._cellCm);return At` + `}_cssPxToRender(t){const e=this.host._stageEl,s=this.host._viewOr(this.host._baseVb());return e?.clientWidth&&e.clientHeight?Math.max(s.w/e.clientWidth,s.h/e.clientHeight)*t:this.host._gridPitch/8*t}_deleteRoomClick(t){const e=this.host._spaceModel();if(!e)return;const s=[...e.rooms].reverse().find(e=>this._pointInRoom(t,e));s?s.id&&(this.host._roomDeleteDialog={roomId:s.id,name:s.name}):this.host._showToast(this.host._t("toast.delete_room_pick"))}_wallThickHit(t){const e=this.host._spaceModel();if(!e)return null;const s=6*this.host._gridPitch,i=this.host._openCuts();let o=null;const a=(t,e,i)=>{e>s||(!o||e100)return void this._showPhysicalRange(100);if("room"!==e.source.kind){const t=this._geometrySnapshot(),i=(s.partitions||[]).find(t=>t.id===e.source.id);if(!i)return;if(0===n&&Fe(s.openings,{kind:"partition",id:i.id}))return void this.host._showToast(this.host._t("toast.zero_wall_opening_conflict"));i.cm=n,this.host._wallDialog=null;return this._commitPhysicalGeometry(this.host._t("history.wall_thickness"),t)&&this.host._showToast(this.host._t("toast.wallthick_set")),void this.host.requestUpdate()}const r=this._geometrySnapshot(),l=n>0?n:null;if(0===n){const i=.02*this.host._gridPitch,o=[e.a[0],e.a[1],e.b[0],e.b[1]],a=(s.rooms||[]).find(t=>t.id===e.roomId),n=new Set(t&&a&&Array.isArray(a.wall_ids)?a.wall_ids:(s.wall_segments||[]).filter(t=>{const e=[Number(t.a?.[0])*kd,Number(t.a?.[1])*kd],s=[Number(t.b?.[0])*kd,Number(t.b?.[1])*kd];return ye(e,o)<=i&&ye(s,o)<=i}).map(t=>String(t.id))),r=(s.openings||[]).some(t=>{if("partition"===t.host?.kind)return!1;if("wall"===t.host?.kind&&n.has(t.host.id))return!0;if(t.host)return!1;const e=[Number(t.x)*kd,Number(t.y)*kd];return e.every(Number.isFinite)&&ye(e,o)<=i});if(r)return void this.host._showToast(this.host._t("toast.zero_wall_opening_conflict"))}let h,c=this.host._openCuts();if(n>0&&c.length){const o=[];if(t&&e.roomId){const t=(s.rooms||[]).find(t=>t.id===e.roomId),a=new Set(Array.isArray(t?.wall_ids)?t.wall_ids:[]);for(const t of s.wall_segments||[])a.has(t.id)&&o.push([Number(t.a?.[0])*kd,Number(t.a?.[1])*kd,Number(t.b?.[0])*kd,Number(t.b?.[1])*kd]);if(!o.length){const t=i.rooms.find(t=>t.id===e.roomId),s=t?N(t):null;for(let t=0;s&&t!o.some(e=>ye([t[0],t[1]],e)<=a&&ye([t[2],t[3]],e)<=a&&ye([e[0],e[1]],t)<=a&&ye([e[2],e[3]],t)<=a))}h=t&&e.roomId?Os(s.walls,i.rooms,e.roomId,l,this.host._wallKeyPitch,c,kd):j(s.walls,e.a,e.b,l,this.host._wallKeyPitch,kd),h=this.host._normalizeWalls(h,c);for(const t of s.wall_segments||[])t.cm=it(h,t.a,t.b,z,1);h.length?s.walls=h:delete s.walls,this.host._wallDialog=null,this._commitPhysicalGeometry(this.host._t("history.wall_thickness"),r)&&this.host._showToast(this.host._t(0===n?"toast.wallthick_cleared":"toast.wallthick_set")),this.host.requestUpdate()}_wallHatchDefs(t){if(!this.host._spaceWalls.length&&!this.host._physicalBodiesR().length&&!this.host._markup)return At``;const e=Bt(this.host._cellCm);return At` @@ -1841,7 +1828,7 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db - `:p``}_openingAt(t){if(!this.host._openingsR.length)return null;const e=this.host._openingsR.flatMap(e=>{const s=e.angle*Math.PI/180,i=t[0]-e.rx,o=t[1]-e.ry,a=i*Math.cos(s)+o*Math.sin(s);return Math.abs(a)>e.rlen/2+Wt(12,this.host._cellCm)?[]:[{o:e,localY:-i*Math.sin(s)+o*Math.cos(s)}]});if(!e.length)return null;const s=this.host._spaceModel();if(!s)return null;const i=this.host._openCuts(),o=this.host._openingWallIndexFor(s,i).value;return e.find(({o:t,localY:e})=>{const s="gate"===t.type?!t.flip_v:t.flip_v,i=t.partitionHost||this.host._spaceWalls.length||"gate"===t.type?this.host._openingFace(t,o,!!s):{ox:0,oy:0,cm:0,side:-1},a=Hs({type:t.type,length:t.rlen,angle:t.angle,amount:this.host._openingAmt(t),flipH:!!t.flip_h,flipV:!!t.flip_v,cellCm:this.host._cellCm,gridPitch:this.host._gridPitch,face:i});return Math.abs(e)<=a.hitHalf})?.o||null}_resolveOpeningPlacement(t){const e=this.host._openingPreset;if("opening"!==this.host._tool||!e)return null;const s=this.host._spaceModel();if(!s)return null;const i=this.host._openCuts(),o=this.host._openingWallIndexFor(s,i),a=`${o.key}|partitions:${this.host._cfgEpoch}`;this.host._openingPlacementIntervalsCache&&this.host._openingPlacementIntervalsCache.key===a||(this.host._openingPlacementIntervalsCache={key:a,value:[...O(s.rooms,this.host._spaceWalls,i,this.host._wallKeyPitch,this.host._cellCm,this.host._gridPitch,wd),...Bs(s.partitions,this.host._cellCm,this.host._gridPitch)]}),this.host._openingDimensionContextCache&&this.host._openingDimensionContextCache.key===a||(this.host._openingDimensionContextCache={key:a,value:nd({rooms:s.rooms,walls:this.host._spaceWalls,openCuts:i,partitions:s.partitions,roomOpenings:this.host._roomWallOpeningInputs(),partitionCuts:this._partitionOpeningCuts(s),pitch:this.host._wallKeyPitch,cellCm:this.host._cellCm,gridPitch:this.host._gridPitch,coordScale:wd,epsilon:2e-4*this.host._gridPitch})});const n=Ws({pointer:[t[0],t[1]],preset:e,geometryRevision:this.host._cfgEpoch,renderedLength:this.host._cmToUnits(e.lengthCm),intervals:this.host._openingPlacementIntervalsCache.value,baseTolerance:1.5*this.host._gridPitch,bodyPointerPadding:this._cssPxToRender("touch"===this.host._pointerModality.modality||"pen"===this.host._pointerModality.modality?10:6),gridStep:this.host._gridPitch});this.host._openingJambBlockCm=n.jambBlockedTarget?n.jambBlockedTarget.physicalHalfWidth/this.host._gridPitch*this.host._cellCm:null;const r=n.candidate;if(!r)return null;const l="gate"===r.type?!r.flipV:r.flipV;let h;if(r.host){const t=A({id:"preview",type:r.type,x:r.x/wd,y:r.y/wd,angle:r.angle,length:r.renderedLength/wd,host:r.host},s.partitions,wd,this.host._cellCm,this.host._gridPitch).resolved;h=t?js(t,l):{ox:0,oy:0,cm:0,side:-1}}else h=Gs(o.value,{x:r.x,y:r.y,angle:r.angle,length:r.renderedLength,flip_v:l});const c="mi"===this.host.hass?.config?.unit_system?.length,d=ud(r,this.host._openingDimensionContextCache.value).map(t=>({x:t.label[0],y:t.label[1],text:fe(t.distance/this.host._gridPitch*this.host._cellCm,c),dimension:t}));return{...r,face:h,measure:{labels:d,guide:r.measure.guide}}}_activateOpeningPlacement(t){this._activateMarkupTool("opening"),"opening"===this.host._tool&&(this.host._openingPreset=qs(t,++this.host._openingPresetRevision),this.host._openingHoverCandidate=null,this.host._cursorPt=null)}_clearOpeningPlacement(t){this.host._openingHoverCandidate=null,this.host._openingJambBlockCm=null,t&&(this.host._openingPreset=null,this.host._openingRebindId=null)}_openingClick(t){const e=this.host._spaceModel();if(!e)return;const s=this.host._openingRebindId?null:this._openingAt(t);if(s)return void this._editOpening(s);const i=this.host._openingPreset;if(!i)return;const o=this.host._openingHoverCandidate,a=o&&Us(o,[t[0],t[1]],i.revision,this.host._cfgEpoch)?o:this._resolveOpeningPlacement(t);if(!a){if(null!=this.host._openingJambBlockCm)return void this.host._showToast(this.host._t("opening.partition_jamb_margin",{distance:fe(this.host._openingJambBlockCm,this.host._imperial)}));const s=1.5*this.host._gridPitch,i=R(t,e.rooms,s);return i&&Ks(i.x,i.y,i.angle,this.host._openCuts(),s)?void this.host._showToast(this.host._t("toast.opening_on_zero_wall")):void this.host._showToast(this.host._t("toast.opening_no_wall"))}const n=this.host._openingRebindId?this.host._curSpaceCfg?.openings?.find(t=>t.id===this.host._openingRebindId):null;this.host._openingDialog={...n?{id:n.id,type:n.type,lengthCm:Math.round(n.length*wd/this.host._gridPitch*this.host._cellCm),lengthTouched:!1,contact:n.contact||"",lock:n.lock||"",invert:!!n.invert,flipH:!!n.flip_h,flipV:!!n.flip_v}:{type:a.type,lengthCm:a.lengthCm,contact:"",lock:"",invert:!1,flipH:a.flipH,flipV:a.flipV},...a.host?{host:a.host}:{},x:a.x,y:a.y,angle:a.angle},this.host._openingRebindId=null,this.host._openingHoverCandidate=null,this.host._cursorPt=null}_editOpening(t){this.host._openingDialog={id:t.id,type:t.type,lengthCm:Math.round(t.rlen/this.host._gridPitch*this.host._cellCm),lengthTouched:!1,contact:t.contact||"",lock:t.lock||"",invert:!!t.invert,flipH:!!t.flip_h,flipV:!!t.flip_v,..."partition"===t.host?.kind?{host:{...t.host}}:{},x:t.rx,y:t.ry,angle:t.angle}}_opPointerDown(t,e){if("plan"===this.host._mode&&this.host._spaceModel()&&"resize"!==this.host._tool){t.preventDefault(),t.stopPropagation();try{xd(t)}catch{}this.host._opDrag={id:e.id,moved:!1,sx:t.clientX,sy:t.clientY,dirty:!1,before:this._geometrySnapshot()}}}_opPointerMove(t,e){lr(this.host,"opening",()=>this._opPointerMoveNow(t,e))}_opPointerMoveNow(t,e){if(!this.host._opDrag||this.host._opDrag.id!==e.id)return;if(Math.abs(t.clientX-this.host._opDrag.sx)+Math.abs(t.clientY-this.host._opDrag.sy)<=3)return;const s=this.host._spaceModel();if(!s)return;const i=this._svgPoint(t),o=this.host._curSpaceCfg,a=o?.openings?.find(t=>t.id===e.id);if(!a)return;if("partition"===a.host?.kind){const t=s.partitions.find(t=>t.id===a.host.id);if(!t)return;const e=t.b[0]-t.a[0],o=t.b[1]-t.a[1],n=Math.hypot(e,o);if(!(n>1e-9))return;const r=e/n,l=o/n;if(Math.abs((i[0]-t.a[0])*l-(i[1]-t.a[1])*r)>4*this.host._gridPitch)return;const h=a.length*wd/2+W(t,this.host._cellCm,this.host._gridPitch);let c=(i[0]-t.a[0])*r+(i[1]-t.a[1])*l;if(c=Math.round(c/this.host._gridPitch)*this.host._gridPitch,c=Math.max(h,Math.min(n-h,c)),n<2*h-1e-9)return;const d=c/n,p=(t.a[0]+r*c)/wd,u=(t.a[1]+l*c)/this.host._spaceH;let _=180*Math.atan2(o,e)/Math.PI;_>=90?_-=180:_<-90&&(_+=180);const g=a.host.t!==d||a.x!==p||a.y!==u||a.angle!==_;return this.host._opDrag.moved=!0,g&&(this.host._opDrag.dirty=!0),a.host={...a.host,t:d},a.x=p,a.y=u,a.angle=_,this.host._opMeasure=null,g&&this.host._cfgEpoch++,void this.host.requestUpdate()}const n=R(i,s.rooms,4*this.host._gridPitch);if(!n)return;this.host._opDrag.moved=!0;const r=this._opRuler(n,a.length*wd);this.host._opMeasure=r.measure;const l=r.x/wd,h=r.y/this.host._spaceH,c=a.x!==l||a.y!==h||a.angle!==n.angle;if(c&&(this.host._opDrag.dirty=!0),a.x=l,a.y=h,a.angle=n.angle,Number(this.host._serverCfg?.model_version||0)>=9){const t=yn(a,o?.wall_segments||[]);t?a.host=t:delete a.host}c&&this.host._cfgEpoch++,this.host.requestUpdate()}_opRuler(t,e){const s=this.host._spaceModel()?.rooms||[],i=this.host._gridPitch/2;let o=t.x,a=t.y,n=Vs([o,a],t.angle,e,s,i);if(n&&n.centered&&(o!==n.wallCenter[0]||a!==n.wallCenter[1]))[o,a]=n.wallCenter,n=Vs([o,a],t.angle,e,s,i);else if(n){const[r,l]=n.wallA,[h,c]=n.wallB,d=h-r,p=c-l,u=Math.hypot(d,p);if(u>0){const h=this.host._gridPitch,c=Math.min(e/2,u/2);let _=Math.round(((o-r)*d+(a-l)*p)/u/h)*h;_=Math.max(c,Math.min(u-c,_)),o=r+_/u*d,a=l+_/u*p,n=Vs([o,a],t.angle,e,s,i)||n}}if(!n)return{x:o,y:a,angle:t.angle,measure:null};const r="mi"===this.host.hass?.config?.unit_system?.length,l=(t,e)=>({x:e[0],y:e[1],text:fe(t/this.host._gridPitch*this.host._cellCm,r)});return{x:o,y:a,angle:t.angle,measure:{labels:[l(n.sideA,n.midA),l(n.sideB,n.midB)],guide:n.centered?{x:n.wallCenter[0],y:n.wallCenter[1],angle:t.angle}:null}}}_opPointerUp(t,e){if(!this.host._opDrag||this.host._opDrag.id!==e.id)return;hr(this.host,"opening");const s=this.host._opDrag,i=s.moved;this.host._opMeasure=null,i&&s.dirty&&this._commitPhysicalGeometry(this.host._t("history.move_opening"),s.before);const o=()=>{this.host._opDrag=null,this.host.requestUpdate()};i?window.setTimeout(o,0):o()}_opClick(t,e){"plan"===this.host._mode&&"resize"===this.host._tool||(t.stopPropagation(),this.host._opDrag?.moved||"plan"===this.host._mode&&this._editOpening(e))}_saveOpening(){const t=this.host._openingDialog,e=this.host._curSpaceCfg,s=this.host._spaceModel();if(!t||!e||!s)return;const i=this._geometrySnapshot(),o=this.host._spaceH,a=(e.openings||[]).find(e=>e.id===t.id),n={...a||{},id:t.id||"o"+Date.now().toString(36),type:t.type,x:t.x/wd,y:t.y/o,angle:t.angle,length:a&&!t.lengthTouched?a.length:this.host._cmToUnits(Math.max(20,t.lengthCm))/wd,...t.host?{host:{...t.host}}:{}};if("partition"===n.host?.kind){const t=Js(a,n)?q(n,s.partitions,wd,this.host._cellCm,this.host._gridPitch):A(n,s.partitions,wd,this.host._cellCm,this.host._gridPitch);if(!t.resolved){const e=s.partitions.find(t=>t.id===n.host.id);if("does-not-fit-jamb"===t.reason&&e){const t=W(e,this.host._cellCm,this.host._gridPitch);this.host._showToast(this.host._t("opening.partition_jamb_margin",{distance:fe(t/this.host._gridPitch*this.host._cellCm,this.host._imperial)}))}else this.host._showToast(this.host._t("opening.partition_orphan"));return}const i=(e.openings||[]).flatMap(t=>{if(!t.host||t.id===n.id)return[];const e=A(t,s.partitions,wd,this.host._cellCm,this.host._gridPitch).resolved;return e?[e]:[]});if(Zs(t.resolved,i))return void this.host._showToast(this.host._t("toast.opening_no_wall"));Object.assign(n,E(n,t.resolved,wd))}else if(Number(this.host._serverCfg?.model_version||0)>=9){const t=yn(n,e.wall_segments||[]);if(!t)return void this.host._showToast(this.host._t("toast.opening_no_wall"));n.host=t}else delete n.host;"passage"===t.type?(delete n.contact,delete n.lock,delete n.invert,delete n.flip_h,delete n.flip_v):(n.contact=t.contact||null,n.lock=("door"===t.type||"gate"===t.type)&&t.lock||null,n.invert=t.invert||void 0,n.flip_h="gate"!==t.type&&t.flipH||void 0,n.flip_v=t.flipV||void 0),e.openings=e.openings||[];const r=e.openings.findIndex(t=>t.id===n.id);r>=0?e.openings[r]=n:e.openings.push(n),this._commitPhysicalGeometry(this.host._t(t.id?"history.edit_opening":"history.add_opening"),i),this.host._openingDialog=null,this.host.requestUpdate()}_deleteOpening(){const t=this.host._openingDialog,e=this.host._curSpaceCfg;if(!t?.id||!e?.openings)return;const s=this._geometrySnapshot();e.openings=e.openings.filter(e=>e.id!==t.id),this._commitPhysicalGeometry(this.host._t("history.delete_opening"),s),this.host._openingDialog=null,this.host.requestUpdate()}_contactCandidates(){const t=[];for(const e of Object.keys(this.host.hass.states)){if(!this.host._openingEntityAvailable(e))continue;const s=e.split(".")[0];if("binary_sensor"!==s&&"cover"!==s)continue;const i=this.host.hass.states[e],o=["door","window","opening","garage_door","garage"].includes(i?.attributes?.device_class||"");("cover"!==s||o)&&t.push([e,i?.attributes?.friendly_name||e,o?0:1])}return t.sort((t,e)=>t[2]-e[2]||t[1].localeCompare(e[1])).map(([t,e])=>({value:t,label:e}))}_lockCandidates(){return Object.keys(this.host.hass.states).filter(t=>t.startsWith("lock.")&&this.host._openingEntityAvailable(t)).map(t=>({value:t,label:this.host.hass.states[t]?.attributes?.friendly_name||t})).sort((t,e)=>t.label.localeCompare(e.label))}_toggleOpeningEntityPicker(t){const e=this.host._openingDialog;if(!e)return;const s="contact"===t?!e.contactOpen:!e.lockOpen;this.host._openingDialog={...e,contactOpen:"contact"===t&&s,lockOpen:"lock"===t&&s}}_filterOpeningEntities(t,e){const s=this.host._openingDialog;s&&(this.host._openingDialog="contact"===t?{...s,contactFilter:e}:{...s,lockFilter:e})}_selectOpeningEntity(t,e){const s=this.host._openingDialog;s&&(this.host._openingDialog="contact"===t?{...s,contact:e,contactOpen:!1,contactFilter:""}:{...s,lock:e,lockOpen:!1,lockFilter:""})}_mergeClick(t){const e=this.host._spaceModel();if(!e)return;const s=e.rooms,i=[...s].reverse().find(e=>this._pointInRoom(t,e));if(!i?.id)return;const o=i.id;if(!this.host._mergeSel||this.host._mergeSel===o)return void(this.host._mergeSel=this.host._mergeSel===o?null:o);const a=s.find(t=>t.id===this.host._mergeSel),n=a?N(a):null,r=N(i),l=n&&r?Ys(n,r):null;if(!l)return this.host._showToast(this.host._t("toast.merge_not_adjacent")),void(this.host._mergeSel=null);this.host._mergeDialog={aId:this.host._mergeSel,bId:o,poly:l,pick:"a"},this.host._mergeSel=null}_commitMerge(){const t=this.host._mergeDialog,e=this.host._curSpaceCfg;if(!t||!e||!this.host._spaceModel())return;const s=this._geometrySnapshot(),i=this.host._spaceH,o="a"===t.pick?t.aId:t.bId,a="a"===t.pick?t.bId:t.aId,n=bd(this.host._serverCfg?.markers||[],{kind:"merge",dropId:a,keepId:o});s&&n.changed&&(s.roomReferences=n.before);const r=e.rooms.find(t=>t.id===o);if(!r)return void(this.host._mergeDialog=null);r.poly=t.poly.map(t=>[t[0]/wd,t[1]/i]),delete r.x,delete r.y,delete r.w,delete r.h,e.rooms=e.rooms.filter(t=>t.id!==a),n.changed&&this.host._serverCfg&&(this.host._serverCfg.markers=n.markers);const l=this._commitPhysicalGeometry(this.host._t("history.merge_rooms"),s);this.host._mergeDialog=null,this.host._regSignature="",this.host._maybeRebuildDevices(),l&&this.host._showToast(this.host._t("toast.rooms_merged",{name:r.name||""}))}_splitClick(t){const e=this.host._spaceModel();if(!e)return;const s=e.rooms;if(!this.host._splitSel){const e=[...s].reverse().find(e=>this._pointInRoom(t,e));if(!e?.id)return;return void(this.host._splitSel={roomId:e.id,pts:[]})}const i=s.find(t=>t.id===this.host._splitSel.roomId),o=i?N(i):null;if(!i||!o)return void(this.host._splitSel=null);const a=.02*this.host._gridPitch,n=6*this.host._gridPitch,r=Xs(t,o),l=r&&Qs(r,o,this.host._gridPitch)||r,h=r&&l&&Math.hypot(r[0]-t[0],r[1]-t[1])<=n?l:null,c=!!h&&ti(h,o,a),d=this.host._splitSel.pts;if(!d.length)return c?void(this.host._splitSel={...this.host._splitSel,pts:[h]}):void this.host._showToast(this.host._t("toast.split_pick_wall"));if(!c){const e=this._snap(t);return es(e,o,a)?void(this.host._splitSel={...this.host._splitSel,pts:[...d,e]}):void this.host._showToast(this.host._t("toast.split_pick_inside"))}const p=is(o,[...d,h],a);if(!p)return void this.host._showToast(this.host._t("toast.split_bad_cut"));this._resetRoomDialogFields();const[u,_]=p,g=ae(u)>=ae(_)?u:_,m=g===u?_:u;this.host._pendingSplit={roomId:i.id,mainPoly:g,newPoly:m},this.host._cursorPt=null,this.host._nameSel="",this.host._areaSel="",this.host._roomDialog=!0}_markupMove(t){if(!this.host._markup)return;if("column"===this.host._tool)return void(this.host._cursorPt=this._snap(this._svgPoint(t)));if("opening"===this.host._tool||"wallthick"===this.host._tool)return void(this.host._cursorPt=this._svgPoint(t));const e="draw"===this.host._tool&&!this.host._contourClosed,s="split"===this.host._tool&&!!this.host._splitSel?.pts?.length;if(!e&&!s)return;const i=this._svgPoint(t);if(e){const e=this._resolvePlanDrawPoint(i,t.shiftKey);if(this.host._planSnapHover={contextKey:e.contextKey,candidate:e.candidate,conflicts:e.conflicts},this._syncPlanSnapConflictMarkers(e.conflicts),this._syncPlanSnapActiveMarker(e.candidate),!this.host._path.length)return;return void(this.host._cursorPt=e.point)}this.host._cursorPt=this._snap(i)}_saveRoom(){(this.host._areaSel||this.host._nameSel.trim())&&zt(this.host._roomTempMin,this.host._roomTempMax).valid&&(this.host._wallFaceBatch?this._decideWallFace(!0):this._commitRoom())}_decideWallFace(t){const e=this.host._wallFaceBatch;if(!e)return;const s=e.candidates[e.index];if(!s)return;if(!t&&(s.existing||s.repair)&&1===e.candidates.length)return this.host._wallFaceBatch=null,this.host._roomDialog=!1,this.host._nameSel="",this.host._areaSel="",void this.host.requestUpdate();const i=t?{candidate:s,create:!0,name:this.host._nameSel.trim(),area:this.host._areaSel||null,settings:this._roomSettingsFromDialog()?JSON.parse(JSON.stringify(this._roomSettingsFromDialog())):null}:{candidate:s,create:!1},o=[...e.decisions,i],a=e.index+1;if(a"number"==typeof t&&Number.isFinite(t)&&t>=0?t:null,o=.02*this.host._gridPitch,a=this.host._spaceModel();if(!a)return H;for(const e of this._planSnapGeometrySnapshot().value.segments)if(!("room"===e.sourceKind||ye(t,[e.a[0],e.a[1],e.b[0],e.b[1]])>o)&&"partition"===e.sourceKind)return i(a.partitions.find(t=>t.id===e.sourceId)?.cm)??H;const n=sc(Math.max(0,e.length-1),s,this.host._drawWallCm,H);for(let s=0;s+1[...t]);if(!e)return s;const i=this.host._activeWallChainPartitionIds.findIndex((t,s)=>this._activeWallSourceKey(s)===e.sourceKey),o=i>=0?i+("b"===e.endpoint?1:0):-1;return o>=0&&oe.key===t.sourceKey),a=i.find(e=>e.key===t.targetSourceKey);if(!o||!a)return!1;const n="a"===t.endpoint?o.a:o.b;return!(Math.hypot(n[0]-t.from[0],n[1]-t.from[1])>s)&&(!(ye(t.to,[a.a[0],a.a[1],a.b[0],a.b[1]])>s)&&!function(t,e){if(!t.sourceKey.startsWith("static:partition|"))return!1;const s=t.sourceKey.slice(17).split("|")[0];return!!s&&e.some(t=>"partition"===t.host?.kind&&t.host.id===s)}(t,this.host._curSpaceCfg?.openings||[]))}_applyWallRepair(t,e){const s=this.host._curSpaceCfg;if(!s||!this._validateWallRepair(t,e.activePath))return!1;if(!t.sourceKey.startsWith("static:"))return!1;const[i,o]=t.sourceKey.slice(7).split("|");if("partition"===i){const i=(s.partitions||[]).find(t=>t.id===o);if(!i)return!1;const a=[i.a[0]*wd,i.a[1]*wd],n=[i.b[0]*wd,i.b[1]*wd],r=Math.hypot(a[0]-t.from[0],a[1]-t.from[1])<=2e-4*this.host._gridPitch?i.a:Math.hypot(n[0]-t.from[0],n[1]-t.from[1])<=2e-4*this.host._gridPitch?i.b:null;if(!r)return!1;(e=>{e[0]=t.to[0]/wd,e[1]=t.to[1]/wd})(r);const l=e.activePartitionIds.indexOf(o);if(l>=0){const s=l+("b"===t.endpoint?1:0);e.activePath[s]&&(e.activePath[s]=[...t.to])}return!0}return!1}_applyWallFaceBatch(){const t=this.host._wallFaceBatch,e=this.host._curSpaceCfg,s=this.host._spaceModel();if(!t||!e||!s)return;const i=(t,e)=>{this.host._showToast(this.host._t(t,e)),this._roomDialogCancel()},o=t.decisions.filter(t=>t.create),a=o.map(t=>t.candidate.ring),n=s.rooms;for(let t=0;ts.id!==e&&!!N(s)&&ie(a[t],N(s)));if(s)return void i("toast.room_overlap",{name:s.name||""})}if((e.rooms||[]).length+o.length>400)return void i("toast.physical_limit");if(o.some(t=>t.candidate.split&&!e.rooms.some(e=>e.id===t.candidate.split.roomId)))return void i("toast.contour_cannot_close");const r=o.map(t=>t.candidate.repair).filter(t=>!!t);if(r.length>1||r[0]&&!this._validateWallRepair(r[0],t.activePath))return void i("toast.wall_repair_changed");if(this._activePathWithRepair(t.activePath,r[0]),!o.length){if(!this._finalizeWallChainPartitions(t.activePartitionIds))return;return this.host._path=[],this.host._activeWallChainId=null,this.host._activeWallChainPartitionIds=[],this.host._wallChainSegmentCms=[],this.host._wallChainRedo=[],this.host._closingWallCm=null,this.host._wallFaceBatch=null,this.host._roomDialog=!1,this.host._nameSel="",this.host._areaSel="",this.host.requestUpdate(),void this.host._showToast(this.host._t("toast.wall_chain_saved"))}const l=new Set(t.activePartitionIds),h=2e-4*this.host._gridPitch,c=o.map(t=>t.candidate.ring.map((t,e,i)=>{const o=i[(e+1)%i.length],a=s.partitions.filter(e=>{const s=Math.hypot(e.b[0]-e.a[0],e.b[1]-e.a[1]);if(!(s>h))return!1;const i=(e.b[0]-e.a[0])/s,a=(e.b[1]-e.a[1])/s,n=t=>(t[0]-e.a[0])*i+(t[1]-e.a[1])*a;return ye(t,[e.a[0],e.a[1],e.b[0],e.b[1]])<=h&&ye(o,[e.a[0],e.a[1],e.b[0],e.b[1]])<=h&&n(t)>=-h&&n(t)<=s+h&&n(o)>=-h&&n(o)<=s+h});return a.sort((t,e)=>Number(l.has(e.id))-Number(l.has(t.id))||Math.hypot(t.b[0]-t.a[0],t.b[1]-t.a[1])-Math.hypot(e.b[0]-e.a[0],e.b[1]-e.a[1])||t.id.localeCompare(e.id)),a[0]?.id||""})),d=this._geometrySnapshot();if(!d)return void i("toast.geometry_unsafe");const p=()=>{this._restoreGeometryStateLocal(d),i("toast.geometry_unsafe")};if(r[0]&&!this._applyWallRepair(r[0],t))return void i("toast.wall_repair_changed");const u=o.some(t=>!!t.candidate.split),_=u?Ae(s.rooms,e.walls,this.host._openCuts(),this.host._wallKeyPitch,this.host._cellCm,this.host._gridPitch,wd):null,g=u&&Array.isArray(e.walls)?e.walls:null;for(const t of o){const s=t.candidate.split;if(!s)continue;const i=e.rooms.find(t=>t.id===s.roomId);if(!i)return void p();i.poly=s.mainPoly.map(t=>[t[0]/wd,t[1]/this.host._spaceH]),delete i.x,delete i.y,delete i.w,delete i.h}const m=Date.now().toString(36),f=[];if(o.forEach((t,s)=>{const i=t.area?this.host.hass.areas[t.area]?.name:"",o={id:`r${m}-${s}`,name:t.name||i||this.host._t("room.default_name"),area:t.area||null,poly:t.candidate.ring.map(t=>[t[0]/wd,t[1]/this.host._spaceH]),...c[s].some(Boolean)?{wall_ids:c[s]}:{},...t.settings?{settings:JSON.parse(JSON.stringify(t.settings))}:{}};e.rooms.push(o),f.push({room:o,decision:t})}),u){const t=this.host._normalizeWalls(_,this.host._openCuts());t.length?e.walls=t:g?.length?e.walls=g:delete e.walls}if(f.length){this.host._cfgEpoch++;const s=this.host._openCuts(),i=this.host._spaceModel();if(!i)return void p();let o=e.walls;for(const{room:e,decision:a}of f){const n=a.candidate.ring,r=this._wallSourceCmAt(n[0],t.activePath,t.activeCms);o=ei(o,i.rooms,e.id,r,this.host._wallKeyPitch,s,wd);for(const a of O(i.rooms,o,s,this.host._wallKeyPitch,this.host._cellCm,this.host._gridPitch,wd)){if(a.roomId!==e.id||"outer"!==a.kind)continue;const s=[(a.a[0]+a.b[0])/2,(a.a[1]+a.b[1])/2];o=j(o,a.a,a.b,this._wallSourceCmAt(s,t.activePath,t.activeCms),this.host._wallKeyPitch,wd)}}const a=this.host._normalizeWalls(o,s);a.length?e.walls=a:delete e.walls,this.host._cfgEpoch++;const n=this.host._spaceModel();if(!n)return void p();const r=qa(e,n,e.walls,s,{pitch:this.host._wallKeyPitch,cellCm:this.host._cellCm,gridPitch:this.host._gridPitch,coordScale:wd,allowCoincidentPartitions:!0});r.walls.length?e.walls=r.walls:delete e.walls,r.partitions.length?e.partitions=r.partitions:delete e.partitions,r.openings.length?e.openings=r.openings:delete e.openings}if(!this._commitPhysicalGeometry(this.host._t("history.wall_face_batch"),d))return;this.host._path=[],this.host._activeWallChainId=null,this.host._activeWallChainPartitionIds=[],this.host._wallChainSegmentCms=[],this.host._wallChainRedo=[],this.host._closingWallCm=null,this.host._wallFaceBatch=null,this.host._roomDialog=!1,this.host._nameSel="",this.host._areaSel="",this.host._regSignature="",this.host._maybeRebuildDevices();const b=new Set(o.map(t=>t.area).filter(t=>!!t));if(b.size){const t={...this.host._layout};for(const e of this.host._devices){if(!b.has(e.area||"")||e.space!==this.host._space)continue;if(this.host._layout[e.id])continue;const s=this.host._defPos[e.id];s&&(t[e.id]={s:this.host._space,x:s.x/wd,y:s.y/wd},this.host._dirtyPos.add(e.id))}this.host._layout=t,this.host._persistLayout()}this.host._showToast(this.host._t(o.length?"toast.wall_rooms_saved":"toast.wall_chain_saved",{n:o.length}))}_commitRoom(){const t=this.host._curSpaceCfg,e=this.host._spaceModel();if(!t||!e)return;const s=this._geometrySnapshot();if(!s)return;const i=()=>{this._restoreGeometryStateLocal(s),this.host._showToast(this.host._t("toast.geometry_unsafe"))},o=this.host._spaceH,a=!!this.host._pendingSplit,n=a?Ae(e.rooms,t.walls,this.host._openCuts(),this.host._wallKeyPitch,this.host._cellCm,this.host._gridPitch,wd):null,r=a&&Array.isArray(t.walls)?t.walls:null;let l;if(this.host._pendingSplit){const e=t.rooms.find(t=>t.id===this.host._pendingSplit.roomId);if(!e)return this.host._pendingSplit=null,this.host._splitSel=null,void(this.host._roomDialog=!1);e.poly=this.host._pendingSplit.mainPoly.map(t=>[t[0]/wd,t[1]/o]),delete e.x,delete e.y,delete e.w,delete e.h,l=this.host._pendingSplit.newPoly}else{if(!this.host._contourClosed)return;l=this.host._path.slice(0,-1)}const h=this.host._areaSel?this.host.hass.areas[this.host._areaSel]?.name:"",c={id:"r"+Date.now().toString(36),name:this.host._nameSel||h||this.host._t("room.default_name"),area:this.host._areaSel||null,poly:l.map(t=>[t[0]/wd,t[1]/o]),...this._roomSettingsFromDialog()?{settings:this._roomSettingsFromDialog()}:{}};if(t.rooms.push(c),a){const e=this.host._normalizeWalls(n,this.host._openCuts());e.length?t.walls=e:r?.length?t.walls=r:delete t.walls}if(!a){const e=sc(l.length,[...this.host._wallChainSegmentCms,this.host._closingWallCm??void 0],this.host._drawWallCm,H),s=e[0];if(null!=s){this.host._cfgEpoch++;const o=this.host._openCuts(),a=this.host._spaceModel();if(!a)return void i();let n=ei(t.walls,a.rooms,c.id,s,this.host._wallKeyPitch,o,wd);for(const t of O(a.rooms,n,o,this.host._wallKeyPitch,this.host._cellCm,this.host._gridPitch,wd)){if(t.roomId!==c.id||"outer"!==t.kind)continue;const s=[(t.a[0]+t.b[0])/2,(t.a[1]+t.b[1])/2],i=l.findIndex((t,e)=>{const i=l[(e+1)%l.length];return ye(s,[t[0],t[1],i[0],i[1]])<=.02*this.host._gridPitch});i>=0&&(n=j(n,t.a,t.b,e[i],this.host._wallKeyPitch,wd))}n=this.host._normalizeWalls(n,o),n.length?t.walls=n:delete t.walls;const r=this.host._spaceModel();if(!r)return void i();const h=qa(t,r,t.walls,o,{pitch:this.host._wallKeyPitch,cellCm:this.host._cellCm,gridPitch:this.host._gridPitch,coordScale:wd,allowCoincidentPartitions:!0});h.walls.length?t.walls=h.walls:delete t.walls,h.partitions.length?t.partitions=h.partitions:delete t.partitions,h.openings.length?t.openings=h.openings:delete t.openings}}const d=this._commitPhysicalGeometry(this.host._t(a?"history.split_room":"history.add_room"),s);this.host._path=[],this.host._activeWallChainId=null,this.host._activeWallChainPartitionIds=[],this.host._wallChainSegmentCms=[],this.host._wallChainRedo=[],this.host._closingWallCm=null,this.host._pendingSplit=null,this.host._splitSel=null;const p=this.host._areaSel;if(this.host._areaSel="",this.host._nameSel="",this.host._roomDialog=!1,this.host._regSignature="",this.host._maybeRebuildDevices(),!d)return;let u=0;if(p){const t=wd,e={...this.host._layout};for(const s of this.host._devices){if(s.area!==p||s.space!==this.host._space)continue;if(u++,this.host._layout[s.id])continue;const i=this.host._defPos[s.id];i&&(e[s.id]={s:this.host._space,x:i.x/wd,y:i.y/t},this.host._dirtyPos.add(s.id))}this.host._layout=e,this.host._persistLayout()}const _=this.host._model.find(t=>t.id===this.host._space)?.rooms.length||0;this.host._showToast(p?this.host._t("toast.room_saved",{n:_,added:u}):this.host._t("toast.room_saved_no_area",{n:_}))}_cancelPath(){this.host._wallRepairDiagnostic=null,this.host._path=[],this.host._activeWallChainId=null,this.host._activeWallChainPartitionIds=[],this.host._wallChainSegmentCms=[],this.host._wallChainRedo=[],this.host._closingWallCm=null,this._clearPlanSnapHover(),this.host._roomDialog=!1,this.host._pendingSplit=null,this.host._wallFaceBatch=null,this.host._splitSel=null,this.host._mergeSel=null,this.host._mergeDialog=null,this.host._physicalSel=null,this.host._physicalDrag=null,this.host._physicalRotate=null,this._clearOpeningPlacement(!0)}_roomDialogCancel(){if(this.host._roomDialog=!1,this.host._roomEditId)return this.host._roomEditId=null,this.host._nameSel="",void(this.host._areaSel="");if(this.host._wallFaceBatch){const t=this.host._wallFaceBatch;return this.host._wallFaceBatch=null,this.host._path=t.activePath.map(t=>[...t]),this.host._wallChainSegmentCms=[...t.activeCms],this.host._activeWallChainPartitionIds=[...t.activePartitionIds],this.host._activeWallChainId||=`chain-${Date.now().toString(36)}`,this.host._nameSel="",this.host._areaSel="",void this.host.requestUpdate()}if(this.host._pendingSplit)return this.host._pendingSplit=null,void(this.host._splitSel=null);this.host._undoPoint()}_openDeviceInbox(){this.host._deviceInboxReturn=null,this.host._deviceInbox=this.host._deviceInbox||{tab:"on_plan",search:"",showEntities:!1,onlyNew:!1,limit:100}}_closeMarkerDialog(){this._radarSetup.isDirty()?this._closeMarkerDialogGuarded():(this._radarSetup.reset(),function(t){if(t._markerDialog=null,!t._deviceInboxReturn)return;const e={...t._deviceInboxReturn};t._deviceInbox=e,t._deviceInboxReturn=null,e.anchor&&t.updateComplete.then(()=>requestAnimationFrame(()=>{const s=`.device-inbox-row[data-binding="${CSS.escape(e.anchor)}"]`;t.renderRoot.querySelector(s)?.scrollIntoView({block:"nearest"})}))}(this.host))}async _closeMarkerDialogGuarded(){if(!await this._radarSetup.discardIfAllowed())return await this.host.updateComplete,void this.host.renderRoot.querySelector("#marker-dialog")?.rejectClose();this._closeMarkerDialog()}_deviceInboxCandidates(t){return Lh({hass:this.host._planHass,devices:this.host._devices,markers:this.host._markers,showEntities:t,labels:{device:this.host._t("marker.sub_device"),z2mGroup:this.host._t("marker.sub_z2m_group"),group:this.host._t("marker.sub_group"),helper:this.host._t("marker.sub_helper"),entity:this.host._t("marker.sub_entity")}})}_deviceInboxRows(){const t=this.host._deviceInbox||this.host._deviceInboxReturn,e=!!t?.showEntities,s=[this.host._haRegistry.revision,this.host._cfgRev,this.host._cfgEpoch,this.host._regSignature,this.host._newSyncKey,e?1:0,this.host._showAll?1:0,l(this.host.hass,this.host._config?.language)].join("|");if(this.host._deviceInboxMemo?.key===s)return this.host._deviceInboxMemo.rows;const i=this._deviceInboxCandidates(e),o=new Set(i.map(t=>t.value));for(const t of this.host._markers)t.binding&&"virtual"!==t.binding&&o.add(t.binding);for(const t of this.host._devices)t.bindingKind&&"virtual"!==t.bindingKind&&t.bindingRef&&o.add(`${t.bindingKind}:${t.bindingRef}`);const a=new Map;for(const t of o)a.set(t,this.host._bindingStatus(t));const n=this.host._areaToSpace,r={};for(const[t,e]of Object.entries(this.host.hass?.areas||{}))r[t]=n[t]?.room?.name||e?.name||t;for(const[t,e]of Object.entries(n))r[t]=e.room.name||r[t]||t;const h=Object.fromEntries(this.host._model.map(t=>[t.id,t.title])),c=Object.fromEntries(Object.entries(n).map(([t,e])=>[t,e.space])),d={},p=new Map;for(const[t,e]of Object.entries(this.host._fullRegistryHass.entities||{})){const s=String(e?.platform||"").trim();if(s&&(d[`entity:${t}`]=s),s&&e?.device_id){const t=p.get(e.device_id)||new Set;t.add(s),p.set(e.device_id,t)}}for(const[t,e]of p)d[`device:${t}`]=[...e].sort().join(", ");const u={};for(const[t,e]of Object.entries(this.host._fullRegistryHass.devices||{})){const s=`device:${t}`,i=p.get(t)||new Set,o=Array.isArray(e?.identifiers?.[0])?String(e.identifiers[0][0]||""):"";o&&!d[s]&&(d[s]=o);const a=[o,...i].some(t=>this.host._excluded.has(t));"service"===e?.entry_type?u[s]="service_entry":a?u[s]="excluded_integration":"Group"===e?.model?u[s]="grouped_light":/scene/i.test(e?.model||"")?u[s]="excluded_domain":(/bridge/i.test(`${e?.model||""}${e?.name||""}`)||"myheat"===o&&e?.via_device_id)&&(u[s]="represented_by_parent")}const _=function(t){const{devices:e,markers:s,candidates:i,statuses:o,newDeviceIds:a,showHiddenOnPlan:n,areaNames:r={},spaceNames:l={},spaceByArea:h={},integrationByBinding:c={},reasonByBinding:d={}}=t,p=new Map;for(const t of e)!t.virtual&&t.bindingKind&&"virtual"!==t.bindingKind&&t.bindingRef&&p.set(`${t.bindingKind}:${t.bindingRef}`,t);const u=new Map,_=new Map;for(const t of s)t?.binding&&"virtual"!==t.binding&&(t.removed?_.set(t.binding,t):u.set(t.binding,t));const g=new Map(i.map(t=>[t.value,t])),m=new Set([...p.keys(),...u.keys(),...g.keys(),...[..._.keys()].filter(t=>g.has(t))]),f=[];for(const t of m){const e=p.get(t),s=u.get(t),i=s?void 0:_.get(t),m=g.get(t);let b;if(i&&m)b="readd";else if(!0===s?.hidden)b="hidden";else if(e||s)b="on_plan";else{if(!m)continue;b="available"}const v=e?.bindingStatus||o.get(t)||Th,y=s||i,$=Rh(t),w=e?.area||m?.areaId||y?.area||"",k=e?.space||y?.space||h[w]||"",x=e?.name||y?.name||m?.label||t,M=e?.model||y?.model||m?.model||"",C=!!m?.parentDeviceId&&p.has(`device:${m.parentDeviceId}`),S="readd"===b?"removed":"hidden"===b?s&&zh(s)?d[t]||"automatic_hidden":"manual_hidden":"on_plan"===b?s?"visible_explicit":"visible_auto":d[t]||(C?"represented_by_parent":w&&k?"available":"no_bound_room"),P=!!e&&(!e.hidden||n),D="active"===v.kind,I=P&&(D||"ha_disabled"===v.kind&&n),L=[x,M,c[t],r[w],l[k],t,m?.sub].filter(Boolean).join(" ").toLocaleLowerCase();f.push({key:t,binding:t,category:b,status:v,reason:S,deviceId:e?.id,markerId:y?.id,name:x,icon:e?.icon||y?.icon||("entity"===$?"mdi:code-braces":"mdi:devices"),model:M,integration:c[t]||"",areaId:w,areaName:r[w]||"",spaceId:k,spaceName:l[k]||"",kind:$,isNew:!!e&&a.has(e.id),searchText:L,canFind:I,canEdit:!!e||!!s,canHide:"on_plan"===b&&D,canShow:"hidden"===b&&D,canAdd:("available"===b||"readd"===b)&&D})}const b=t=>"active"===t.status.kind?1:0;return f.sort((t,e)=>t.category.localeCompare(e.category)||Number(e.isNew)-Number(t.isNew)||b(t)-b(e)||t.name.localeCompare(e.name)||t.binding.localeCompare(e.binding))}({devices:this.host._devices,markers:this.host._markers,candidates:i,statuses:a,newDeviceIds:this.host._newIds,showHiddenOnPlan:this.host._showAll,areaNames:r,spaceNames:h,spaceByArea:c,integrationByBinding:d,reasonByBinding:u});return this.host._deviceInboxMemo={key:s,rows:_},_}_deviceForInboxRow(t){const e=t.deviceId?this.host._devices.find(e=>e.id===t.deviceId):null;if(e)return e;const s=t.markerId?this.host._markers.find(e=>e.id===t.markerId):null;return!s||s.removed?null:{id:s.id,name:t.name,model:t.model,area:t.areaId,space:t.spaceId||this.host._space,hidden:!0===s.hidden||"ha_disabled"===t.status.kind,userHidden:!0===s.hidden,bindingStatus:t.status,icon:t.icon,entities:"active"===t.status.kind?t.status.enabledEntityIds:[],allEntities:t.status.allEntityIds,primary:"active"===t.status.kind?t.status.enabledEntityIds[0]:void 0,marker:s,bindingKind:t.kind,bindingRef:t.binding.slice(t.binding.indexOf(":")+1),pdfs:s.pdfs||[]}}_openInboxMarker(t,e=!1){const s=this.host._deviceInbox;if(s){if(this.host._deviceInboxReturn={...s,anchor:t.key},this.host._deviceInbox=null,!e){const e=this._deviceForInboxRow(t);return void(e?this._openMarkerDialog(e):this._closeMarkerDialog())}this._openMarkerDialog(),this.host._markerDialog?this.host._markerDialog={...this.host._markerDialog,bindingMode:"ha",binding:t.binding,bindingOpen:!1,showEntities:"entity"===t.kind,name:""}:this._closeMarkerDialog()}}async _setInboxHidden(t,e){const s=this.host._deviceInbox,i=this.host._serverCfg;if(!s||!i||s.busy||"active"!==t.status.kind)return;const o=i.markers||[],a=o.find(e=>!e.removed&&e.binding===t.binding);if(!e&&!a)return;const n=a?.id||si(t.binding,t.markerId,()=>`m_${Date.now().toString(36)}`),r=a?{...a,hidden:e}:{id:n,binding:t.binding,hidden:!0};i.markers=[...o.filter(e=>e.id!==n&&(e.binding!==t.binding||!0===e.removed)),r],this.host._deviceInbox={...s,busy:t.key,anchor:t.key};try{await this._saveConfigNow(),this.host._regSignature="",this.host._deviceInboxMemo=null,this.host._maybeRebuildDevices(),this.host._deviceInbox&&(this.host._deviceInbox={...this.host._deviceInbox,busy:void 0}),this.host._showToast(this.host._t("device_inbox.saved"))}catch(t){this.host._serverCfg===i&&(i.markers=o),this.host._deviceInbox&&(this.host._deviceInbox={...this.host._deviceInbox,busy:void 0}),this.host._showToast(this.host._t("toast.error",{err:this.host._errText(t)}))}}_findInboxDevice(t){if(!t.canFind)return;const e=this._deviceForInboxRow(t);if(!e)return;if(this.host._deviceInbox=null,e.space&&e.space!==this.host._space){if(!this.host._commitSpace(e.space))return;this.host._restoreZoom()}const s=()=>{const t=this.host._devices.find(t=>t.id===e.id)||e,s=this.host._pos(t);this.host._applyView(this.host._zoom,s.x,s.y),this.host._selId=t.id,this.host.requestUpdate(),window.setTimeout(()=>{this.host._selId===t.id&&(this.host._selId=null,this.host.requestUpdate())},1500)};requestAnimationFrame(()=>requestAnimationFrame(s))}_openMarkerDialog(t){if(this.host._vacAllCamerasFor=null,this.host._vacAllCameraCache=null,t&&this.host._ackNewDevice(t.id),this.host._norm)if(t){const e=t.marker,s=Object.prototype.hasOwnProperty.call(e||{},"is_light"),i=Object.prototype.hasOwnProperty.call(e||{},"light_entity"),o=Object.prototype.hasOwnProperty.call(e||{},"glow_color"),a=Object.prototype.hasOwnProperty.call(e||{},"value_badge"),n=Object.prototype.hasOwnProperty.call(e||{},"value_source"),r=Object.prototype.hasOwnProperty.call(e||{},"tap_action"),l=Object.prototype.hasOwnProperty.call(e||{},"toggle_entity"),h=ii(e?.glow_color),c=this.host._devicePresentation(t,!0).valueBadge,d=m(this.host._planHass,t,this.host._devices),p=f(this.host._planHass,t,d),u=na(t,this.host._fullRegistryHass),_=this.host._spaceModelById(t.space)||this.host._spaceModel(),g=this.host._pos(t),b=_?la(t,_,[g.x,g.y],this.host._fullRegistryHass):null;this.host._markerDialog={devId:t.id,name:t.name,binding:"virtual"===t.bindingKind?"virtual":t.bindingKind+":"+t.bindingRef,bindingMode:"virtual"===t.bindingKind?"virtual":"ha",bindingOpen:!1,showEntities:"entity"===t.bindingKind&&!!this.host._fullRegistryHass.entities[t.bindingRef||""]?.device_id,bindingFilter:"",icon:t.marker?.icon||"",autoIcon:t.icon||"",display:S(t.marker?.display),rippleColor:qt(t.marker?.ripple_color,""),rippleSize:Number(t.marker?.ripple_size)>0?Number(t.marker.ripple_size):1.5,size:Number(t.marker?.size)>0?Number(t.marker.size):1,angle:Number(t.marker?.angle)||0,tapAction:oi(t.marker?.tap_action,t.primary?.split(".")[0]),tapActionTouched:!1,originalHasTapAction:r,originalTapAction:t.marker?.tap_action,tapHintAnnouncement:"",toggleEntity:e?.toggle_entity||"",toggleEntityTouched:!1,originalHasToggleEntity:l,originalToggleEntity:e?.toggle_entity,tapTarget:t.marker?.tap_target||"",tapConfirm:!0===t.marker?.tap_confirm,runFilter:"",controls:x(t.marker?.binding,t.marker?.controls,t.entities),controlsFilter:"",lightRole:!0===e?.is_light?"always":!1===e?.is_light?"never":"auto",lightRoleTouched:!1,originalHasIsLight:s,originalIsLight:e?.is_light,lightEntity:e?.light_entity||"",lightEntityTouched:!1,originalHasLightEntity:i,originalLightEntity:e?.light_entity,glowMode:null!=h?.bri?"fixed":h?"color":"auto",glowColor:h?.c||this.host._fillColors.glow_light.c,glowBrightness:Math.max(1,Math.round(100*(h?.bri??1))),glowColorDrafted:!!h,glowBrightnessDrafted:null!=h?.bri,glowTouched:!1,originalHasGlowColor:o&&(!!h||null===e?.glow_color),originalGlowColor:h||(null===e?.glow_color?null:void 0),valueBadgeEnabled:a?!0===e?.value_badge?.enabled:!!c,valueBadgeSource:e?.value_badge?.source||c?.source||p,valueBadgePosition:e?.value_badge?.position||c?.position||"right",valueBadgeTouched:!1,originalHasValueBadge:a,originalValueBadge:e?.value_badge,valueSource:e?.value_source||null,valueSourceTouched:!1,originalHasValueSource:n,originalValueSource:e?.value_source,useClimateTemp:!0===t.marker?.use_climate_temp,glowRadius:Number(t.marker?.glow_radius_cm)>0?String(this.host._imperial?Math.round(Number(t.marker.glow_radius_cm)/30.48*10)/10:Math.round(Number(t.marker.glow_radius_cm))/100):"",model:t.model||"",link:t.link||"",description:t.description||"",pdfs:[...t.pdfs||[]],room:t.marker?.room_id?t.space+"#@"+t.marker.room_id:t.space&&t.area?t.space+"#"+t.area:"",roomTouched:!1,radar:b,radarEligible:u.eligible,radarTouched:!1,radarRemove:!1,hideFromPlan:!0===t.marker?.hidden,busy:!1}}else this.host._markerDialog={name:"",binding:"virtual",bindingMode:"virtual",bindingOpen:!1,showEntities:!1,bindingFilter:"",icon:"",autoIcon:"",display:"badge",rippleColor:"",rippleSize:1.5,size:1,angle:0,tapAction:"info",tapActionTouched:!1,originalHasTapAction:!1,originalTapAction:void 0,tapHintAnnouncement:"",toggleEntity:"",toggleEntityTouched:!1,originalHasToggleEntity:!1,originalToggleEntity:void 0,tapTarget:"",tapConfirm:!1,runFilter:"",controls:[],controlsFilter:"",lightRole:"auto",lightRoleTouched:!1,originalHasIsLight:!1,originalIsLight:void 0,lightEntity:"",lightEntityTouched:!1,originalHasLightEntity:!1,originalLightEntity:void 0,glowMode:"auto",glowColor:this.host._fillColors.glow_light.c,glowBrightness:100,glowColorDrafted:!1,glowBrightnessDrafted:!1,glowTouched:!1,originalHasGlowColor:!1,originalGlowColor:void 0,valueBadgeEnabled:!1,valueBadgeSource:null,valueBadgePosition:"right",valueBadgeTouched:!1,originalHasValueBadge:!1,originalValueBadge:void 0,valueSource:null,valueSourceTouched:!1,originalHasValueSource:!1,originalValueSource:void 0,useClimateTemp:!1,glowRadius:"",model:"",link:"",description:"",pdfs:[],room:"",roomTouched:!1,radar:null,radarEligible:!1,radarTouched:!1,radarRemove:!1,hideFromPlan:!1,busy:!1,uploadId:"up_"+Date.now().toString(36)+Math.random().toString(36).slice(2,6)};else this.host._showToast(this.host._t("toast.marker_needs_server"))}_runCandidates(){const t=[];for(const e of ai)for(const[s,i]of Object.entries(this.host.hass.states))s.startsWith(e+".")&&this.host._planEntityAvailable(s)&&t.push({value:s,label:i?.attributes?.friendly_name||s,sub:this.host._t("run."+e)});return t.sort((t,e)=>t.sub.localeCompare(e.sub)||t.label.localeCompare(e.label))}_bindingCandidates(){const t=Lh({hass:this.host._planHass,devices:this.host._devices,markers:this.host._markers,showEntities:!!this.host._markerDialog?.showEntities,currentBinding:this.host._markerDialog?.binding,currentDeviceId:this.host._markerDialog?.devId,labels:{device:this.host._t("marker.sub_device"),z2mGroup:this.host._t("marker.sub_z2m_group"),group:this.host._t("marker.sub_group"),helper:this.host._t("marker.sub_helper"),entity:this.host._t("marker.sub_entity")}}),e=(this.host._markerDialog?.bindingFilter||"").toLowerCase().trim(),s=e?t.filter(t=>(t.label+" "+t.sub+" "+t.value).toLowerCase().includes(e)):t;return s.sort((t,e)=>t.label.localeCompare(e.label)),s.slice(0,200)}_backupErrorText(t){const e=t?.code??t?.error;if("string"==typeof e){const t=`backup.error.${e}`,s=this.host._t(t);if(s!==t)return s}return this.host._errText(t)}async _pickMarkerFiles(t){const e=t.target,s=e.files?[...e.files]:[];if(e.value="",!s.length||!this.host._markerDialog)return;const i=this.host._markerDialog.uploadId||this.host._markerDialog.devId||"new",o=[];for(const t of s)try{const e=new FormData;e.append("marker_id",i),e.append("file",t,t.name);const s=this.host.hass?.fetchWithAuth?await this.host.hass.fetchWithAuth("/api/houseplan/upload",{method:"POST",body:e}):await fetch("/api/houseplan/upload",{method:"POST",body:e,headers:this.host.hass?.auth?.data?.access_token?{authorization:`Bearer ${this.host.hass.auth.data.access_token}`}:{}}),a=await s.json().catch(()=>({}));if(!s.ok||a.error){const t={too_large:this.host._t("err.too_large",{mb:a.max_mb||50}),bad_ext:this.host._t("err.bad_ext"),unauthorized:this.host._t("err.unauthorized")};throw new Error(t[a.error]||a.error||"HTTP "+s.status)}o.push({name:a.name||t.name,url:a.url})}catch(e){this.host._showToast(this.host._t("toast.file_failed",{name:t.name,err:this.host._errText(e)}))}o.length&&this.host._markerDialog&&(this.host._markerDialog={...this.host._markerDialog,pdfs:[...this.host._markerDialog.pdfs,...o]},this.host._showToast(this.host._t("toast.files_attached",{n:o.length})))}_removeMarkerPdf(t){this.host._markerDialog&&(this.host._markerDialog={...this.host._markerDialog,pdfs:this.host._markerDialog.pdfs.filter(e=>e.url!==t)})}_markerLightFields(t){const e={};if(t.lightRoleTouched?"always"===t.lightRole?e.is_light=!0:"never"===t.lightRole&&(e.is_light=!1):t.originalHasIsLight&&(e.is_light=t.originalIsLight??null),t.lightEntityTouched?t.lightEntity&&(e.light_entity=t.lightEntity):t.originalHasLightEntity&&(e.light_entity=t.originalLightEntity??null),t.glowTouched){if("auto"!==t.glowMode){const s={c:qt(t.glowColor,this.host._fillColors.glow_light.c)};"fixed"===t.glowMode&&(s.bri=Math.max(.01,Math.min(1,Math.round(t.glowBrightness)/100))),e.glow_color=s}}else t.originalHasGlowColor&&(e.glow_color=t.originalGlowColor??null);return e}_markerTapActionFields(t){return t.tapActionTouched?{tap_action:t.tapAction||null}:t.originalHasTapAction?{tap_action:t.originalTapAction??null}:{}}_markerToggleEntityFields(t){return(e={touched:t.toggleEntityTouched,originalHas:t.originalHasToggleEntity,original:t.originalToggleEntity,value:t.toggleEntity}).touched?e.value?{toggle_entity:e.value}:{}:e.originalHas?{toggle_entity:e.original??null}:{};var e}async _saveMarker(){const t=this.host._markerDialog;if(!t||t.busy)return;const e=this._effectiveMarkerTapAction(t);if("ha"===t.bindingMode&&(!t.binding||"virtual"===t.binding))return;if("virtual"===t.binding&&!t.name.trim())return void this.host._showToast(this.host._t("toast.virtual_name_required"));if("run"===e&&!t.tapTarget)return void this.host._showToast(this.host._t("toast.run_target_required"));if(t.valueBadgeTouched&&t.valueBadgeEnabled&&!t.valueBadgeSource)return void this.host._showToast(this.host._t("toast.value_badge_source_required"));if("ha"===t.bindingMode){const e=this.host._bindingStatus(t.binding),s=t.devId?this.host._markers.find(e=>e.id===t.devId):null,i=!s||s.binding!==t.binding;if("active"!==e.kind&&i)return void this.host._showToast(this.host._t("ha_disabled"===e.kind?"toast.ha_disabled_add":"toast.ha_binding_unverified"));if("ha_disabled"===e.kind&&!0===s?.hidden&&!t.hideFromPlan)return this.host._markerDialog={...t,hideFromPlan:!0},void this.host._showToast(this.host._t("entity"===e.reason?"toast.ha_disabled_show_entity":"toast.ha_disabled_show_device"))}const s=this.host._serverCfg;if(!s)return;const i=this.host._cfgRev,o=yt(s);let a=JSON.parse(JSON.stringify(s));const n=a.markers||[],r=si(t.binding,t.devId,()=>"v_"+Date.now().toString(36)),l=t.devId,h=l?this.host._devices.find(t=>t.id===l):null,c=l?n.find(t=>t.id===l):null,d=!!c&&("string"==typeof c.area&&c.area.length>0||null===c.area&&!!c.space&&!!c.room_id),p="virtual"===t.binding||t.roomTouched||d,u="virtual"===t.binding||t.roomTouched?M(t.room):null;let _=d&&!t.roomTouched?c?.space||null:u?.space||null;const g=d&&!t.roomTouched?c?.area||null:u?.area||null,m=d&&!t.roomTouched?c?.room_id||null:u?.roomId||null,f=_||h?.space||null,b=f?this.host._spaceModelById(f):this.host._spaceModel();if(!b)return;const v=b.id;"virtual"!==t.binding||_||(_=v);let y={};if(t.radarTouched){if(t.radarRemove)y={radar:null};else if(t.radar){const e=da(t.radar,b.cellCm||5);if(!e)return void this.host._showToast(this.host._t("radar.invalid"));y={radar:e}}}else c&&Object.prototype.hasOwnProperty.call(c,"radar")&&(y={radar:c.radar});this.host._markerDialog={...t,busy:!0};let $=null,w=!1;try{const c="virtual"===t.binding?[]:n.filter(e=>e.removed&&e.binding===t.binding).map(t=>t.id),d=c.length>0,u=x(t.binding,t.controls,this.host._bindingEntities(t.binding)),f=n.find(t=>t.id===r||t.id===l)?.vacuum||null,k={id:r,vacuum:f,...y,binding:t.binding,name:t.name.trim()||null,icon:t.icon||null,display:"badge"!==t.display?t.display:null,ripple_color:"icon_ripple"===t.display&&t.rippleColor?t.rippleColor:null,ripple_size:"icon_ripple"===t.display&&1.5!==t.rippleSize?t.rippleSize:null,size:1!==t.size?t.size:null,angle:t.angle?t.angle:null,...this._markerTapActionFields(t),...this._markerToggleEntityFields(t),tap_target:"run"===e&&t.tapTarget||null,tap_confirm:!!t.tapConfirm||null,controls:u.length?u:null,...this._markerLightFields(t),...this._markerValueBadgeFields(t),...this._markerValueSourceFields(t),use_climate_temp:!!t.useClimateTemp||null,glow_radius_cm:(()=>{const e=kt(t.glowRadius);return null==e||e<=0?null:Math.round(this.host._imperial?30.48*e:100*e)})(),model:t.model.trim()||null,link:t.link.trim()||null,description:t.description.trim()||null,pdfs:t.pdfs,hidden:!!t.hideFromPlan};p&&(k.space=_,k.area=g,k.room_id=m);const M=h?.marker?.room_id??null,C=t.roomTouched&&null!=h&&(h.space!==_||h.area!==g||M!==m);let S=!1;const P=t.uploadId||l;if(P&&P!==r&&k.pdfs?.length)try{const t=await this.host.hass.callWS({type:"houseplan/files/migrate",from_id:P,to_id:r}),e=t?.mapping||{};k.pdfs=ni(k.pdfs,P,r,e),S=Object.keys(e).length>0}catch(t){this.host._showToast(this.host._t("toast.files_migrate_failed",{err:this.host._errText(t)}))}a.markers=n,l&&l!==r&&(a.markers=ri(a.markers,l,r)),l&&l!==r&&"derived_marker_state"===k.value_badge?.source?.kind&&k.value_badge.source.ref===`marker:${l}`&&(k.value_badge.source={kind:"derived_marker_state",ref:`marker:${r}`}),l&&l!==r&&"derived_marker_state"===k.value_source?.kind&&k.value_source.ref===`marker:${l}`&&(k.value_source={kind:"derived_marker_state",ref:`marker:${r}`}),a.markers=a.markers.filter(t=>t.id!==r&&t.id!==l&&("virtual"===k.binding||t.binding!==k.binding)),a.markers.push(k);const D=new Set(c);l&&l!==r&&D.add(l),D.delete(r),D.size&&a.settings?.marker_area_snapshot&&(a.settings={...a.settings,marker_area_snapshot:li(a.settings.marker_area_snapshot,D)});let I=null;const L=l?this.host._layout[l]:null,T=L?{s:L.s||h?.space||this.host._space,x:L.x,y:L.y}:l&&h&&this.host._defPos[l]?this.host._normPos(h.space,this.host._defPos[l].x,this.host._defPos[l].y):null;if(!d&&T&&T.s===v)r===l&&this.host._layout[r]&&!C||(I={s:T.s,x:T.x,y:T.y});else if(d||!this.host._layout[r]||C){let t=b.vb[0]+b.vb[2]/2,e=b.vb[1]+b.vb[3]/2;const s=m?b.rooms.find(t=>t.id===m):g?b.rooms.find(t=>t.area===g):void 0;s&&([t,e]=this.host._roomCenter(s)),I=this.host._normPos(v,t,e)}if(this.host._serverCfg!==s||this.host._cfgRev!==i||yt(s)!==o)return this.host._markerDialog&&(this.host._markerDialog={...this.host._markerDialog,busy:!1}),void this.host._showToast(this.host._t("toast.conflict"));if(a=this._prepareConfigCandidate(a),$=this.host._adoption.beginOptimistic(s,a),this.host._serverCfg=a,this.host._regSignature="",this.host._maybeRebuildDevices(),this.host.requestUpdate(),this.host._saveConfigDebounced.pending()&&this.host._saveConfigDebounced.cancel(),await this._saveConfigNow($),w=!0,I){const t=hi(I);this.host._layout={...this.host._layout,[r]:t},this.host._noteLayoutRev(await this.host.hass.callWS({type:"houseplan/layout/update",device_id:r,pos:t}))}const R=new Set(c);l&&l!==r&&R.add(l),R.delete(r);for(const t of R)delete this.host._layout[t],await this.host.hass.callWS({type:"houseplan/layout/delete",device_id:t}).then(t=>this.host._noteLayoutRev(t)).catch(()=>{});S&&P&&await this.host.hass.callWS({type:"houseplan/files/cleanup",marker_id:P}).catch(()=>{}),this._closeMarkerDialog(),this.host._cancelDeviceDrag(),this.host._devicePositionHistory.clear(),this.host._regSignature="",this.host._maybeRebuildDevices(),this.host._showToast(this.host._t("toast.marker_saved"))}catch(t){!w&&$&&(this.host._rollbackOptimistic($),this.host._regSignature="",this.host._maybeRebuildDevices(),this.host.requestUpdate()),this.host._markerDialog&&(this.host._markerDialog={...this.host._markerDialog,busy:!1}),this.host._showToast(this.host._t("toast.error",{err:this.host._errText(t)}))}}async _deleteMarker(){const t=this.host._markerDialog;if(!t||t.busy||!t.devId)return;const e=t.devId?this.host._devices.find(e=>e.id===t.devId):null,s=this.host._markers.find(e=>e.id===t.devId);if(!e&&!s)return;const i=e?"virtual"===e.bindingKind?"virtual":e.bindingKind&&e.bindingRef?`${e.bindingKind}:${e.bindingRef}`:"":s.binding;if(!i)return;const o=t.name||this.host._t("device.fallback"),a=t.devId,n=await this.host._confirmDanger({key:"remove-marker",kind:"destructive",title:this.host._t("confirm.remove_marker_title"),message:this.host._t("confirm.remove_marker_body"),objectName:o,confirmLabel:this.host._t("btn.delete"),cancelLabel:this.host._t("btn.cancel")}),r=this.host._markerDialog;if(!n||!r||r.busy||r.devId!==a)return;const l=this.host._devices.find(t=>t.id===a),h=this.host._markers.find(t=>t.id===a);if(!l&&!h)return;const c=this.host._serverCfg;if(!c)return;c.markers=c.markers||[];const d=c.markers,p=l?"virtual"===l.bindingKind?"virtual":l.bindingKind&&l.bindingRef?`${l.bindingKind}:${l.bindingRef}`:"":h.binding;if(!p||p!==i)return;const u=ci(c.markers,a,p,"virtual"===p);c.markers=di(u.markers,u.cleanupIds);const _=u.cleanupIds;_.size&&c.settings?.marker_area_snapshot&&(c.settings={...c.settings,marker_area_snapshot:li(c.settings.marker_area_snapshot,_)}),this.host._markerDialog={...r,busy:!0};try{await this._saveConfigNow();for(const t of _){delete this.host._layout[t],delete this.host._defPos[t],this.host._dirtyPos.delete(t),this.host._sentPos.delete(t);const e=this.host._activityRt.get(t);e&&clearTimeout(e.timer),this.host._activityRt.delete(t),this.host._vacRt.delete(t),delete this.host._vacSrvTrails[t],await this.host.hass.callWS({type:"houseplan/layout/delete",device_id:t}).then(t=>this.host._noteLayoutRev(t)).catch(()=>{}),await this.host.hass.callWS({type:"houseplan/files/cleanup",marker_id:t}).catch(()=>{}),await this.host.hass.callWS({type:"houseplan/trail/delete",marker_id:t}).catch(()=>{})}this.host._deviceInboxReturn&&(this.host._deviceInboxReturn={...this.host._deviceInboxReturn,tab:"readd",anchor:p}),this._closeMarkerDialog(),this.host._cancelDeviceDrag(),this.host._devicePositionHistory.clear(),this.host._infoCard?.id===a&&this.host._closeInfoCard(),this.host._selId===a&&(this.host._selId=null),this.host._drag?.id===a&&(this.host._drag=null),this.host._regSignature="",this.host._maybeRebuildDevices(),this.host._showToast(this.host._t("toast.marker_removed"))}catch(t){this.host._serverCfg===c&&(c.markers=d),this.host._markerDialog&&(this.host._markerDialog={...this.host._markerDialog,busy:!1}),this.host._showToast(this.host._t("toast.error",{err:this.host._errText(t)}))}}_openSpaceDialog(t,e){if(this.host._serverStorage&&this.host._serverCfg)if("edit"===t){const s=this.host._serverCfg.spaces.find(t=>t.id===e);if(!s)return;const i=_(s),o=s.settings?.custom_fill&&"object"==typeof s.settings.custom_fill?pi(s.settings.custom_fill):null,a="none"===i.fill?{...o||St,a:0}:o;this.host._spaceDialog={mode:t,spaceId:e,title:s.title,planUrl:s.plan_url||null,planFile:null,source:s.plan_url?"file":"draw",showBorders:i.showBorders,showNames:i.showNames,zeroWallStyle:ui(s),displayTouched:!0,hideDecor:i.hideDecor,hideOpenings:i.hideOpenings,roomColor:i.color,roomOpacity:i.opacity,fillMode:"none"===i.fill?"custom":i.fill,customFill:a,glowEnabled:i.glow,bgColor:i.bgColor,bgMode:"static"===s.settings?.bg_mode||"daynight"===s.settings?.bg_mode?s.settings.bg_mode:null,northDeg:It({},s.settings),sunRays:"boolean"==typeof s.settings?.sun_rays?s.settings.sun_rays:null,tempMin:i.tempMin,tempMax:i.tempMax,showLqi:i.showLqi??this.host._config?.show_signal??!0,cardFontScale:i.cardFontScale,labelTemp:i.labelTemp,labelHum:i.labelHum,labelLqi:i.labelLqi,labelLight:i.labelLight,cellCm:Number(s.cell_cm)>0?Number(s.cell_cm):5,cellCmInput:wt(Number(s.cell_cm)>0?Number(s.cell_cm):5,this.host._imperial),cellCmTouched:!1,busy:!1}}else this.host._spaceDialog={mode:t,title:"",planUrl:null,planFile:null,...vi(),hideDecor:!1,hideOpenings:!1,zeroWallStyle:"dashed",roomColor:fi,roomOpacity:mi,fillMode:"custom",customFill:{...St,a:0},glowEnabled:!0,bgColor:null,bgMode:"daynight",northDeg:null,sunRays:null,tempMin:gi,tempMax:_i,showLqi:this.host._config?.show_signal??!0,cardFontScale:1,labelTemp:!1,labelHum:!1,labelLqi:!1,labelLight:!1,cellCm:bi(this.host._imperial),cellCmInput:wt(bi(this.host._imperial),this.host._imperial),cellCmTouched:!1,busy:!1};else this.host._showToast(this.host._t("toast.integration_missing"))}async _pickPlanFile(t){const e=t.target,s=e.files?.[0];if(!s||!this.host._spaceDialog)return;e.value="",this._decorAssetGuardReplace=null;const i=await xo(s);if("reject"===i.kind)return void this.host._showToast(this.host._t("toast.plan_formats"));if("guard"===i.kind)return void(this.host._backdropGuard=i.state);const o=await Mo(s,i.ext,s.name);this.host._spaceDialog&&(this.host._spaceDialog={...this.host._spaceDialog,planFile:o})}_renderBackdropGuard(){const t=this._decorAssetGuardReplace;return null!==t?Co(this.host,()=>{},()=>{this.host._backdropGuard=null,this._decorAssetGuardReplace=null},this.host.hass,(e,s)=>this._uploadDecorImage(e,s,t),(this.host._backdropGuard?.file.size||0)<=2097152)??d:Co(this.host,t=>{this.host._spaceDialog&&(this.host._spaceDialog={...this.host._spaceDialog,planFile:t})},()=>{this.host._backdropGuard=null},this.host.hass)??d}_useServerPlan(t){const e=this.host._spaceDialog;e&&(this.host._spaceDialog={...e,planUrl:t,planFile:null,pickSaved:!1,savedAspect:void 0},this.host._aspectJob=this._readPlanAspect(t))}async _readPlanAspect(t){for(let e=0;e<40;e++){const e=this.host._display(t);if(e){const s=await new Promise(t=>{const s=new Image;s.onload=()=>t(s.naturalWidth&&s.naturalHeight?s.naturalWidth/s.naturalHeight:0),s.onerror=()=>t(0),s.src=e}),i=this.host._spaceDialog;return i&&i.planUrl===t&&Number.isFinite(s)&&s>0?(this.host._spaceDialog={...i,savedAspect:s},s):0}if(await new Promise(t=>setTimeout(t,150)),this.host._spaceDialog?.planUrl!==t)return 0}return 0}async _deleteServerPlan(t){const e=this.host._spaceDialog,s=e?.saved?.find(e=>e.name===t);if(!e||!s||s.used_by.length||s.url===e.planUrl)return;const i=await this.host._confirmDanger({key:"delete-plan",kind:"destructive",title:this.host._t("confirm.delete_plan_title"),message:this.host._t("confirm.delete_plan_body"),objectName:t,confirmLabel:this.host._t("btn.delete"),cancelLabel:this.host._t("btn.cancel")}),o=this.host._spaceDialog,a=o?.saved?.find(e=>e.name===t);if(i&&o&&a&&a.url===s.url&&a.modified===s.modified&&!a.used_by.length&&a.url!==o.planUrl)try{await this.host.hass.callWS({type:"houseplan/plans/delete",name:t});const e=this.host._spaceDialog;e?.saved&&(this.host._spaceDialog={...e,saved:e.saved.filter(e=>e.name!==t)})}catch(t){this.host._showToast(this.host._t("toast.plan_delete_failed",{err:this.host._errText(t)}))}}_renderServerPlans(t){if(t.savedBusy)return p`
    ${this.host._t("space.loading")}
    `;const e=t.saved||[];if(!e.length)return p`
    ${this.host._t("space.no_saved")}
    `;return p`
    +
    `:p``}_openingAt(t){if(!this.host._openingsR.length)return null;const e=this.host._openingsR.flatMap(e=>{const s=e.angle*Math.PI/180,i=t[0]-e.rx,o=t[1]-e.ry,a=i*Math.cos(s)+o*Math.sin(s);return Math.abs(a)>e.rlen/2+Wt(12,this.host._cellCm)?[]:[{o:e,localY:-i*Math.sin(s)+o*Math.cos(s)}]});if(!e.length)return null;const s=this.host._spaceModel();if(!s)return null;const i=this.host._openCuts(),o=this.host._openingWallIndexFor(s,i).value;return e.find(({o:t,localY:e})=>{const s="gate"===t.type?!t.flip_v:t.flip_v,i=t.partitionHost||this.host._spaceWalls.length||"gate"===t.type?this.host._openingFace(t,o,!!s):{ox:0,oy:0,cm:0,side:-1},a=Hs({type:t.type,length:t.rlen,angle:t.angle,amount:this.host._openingAmt(t),flipH:!!t.flip_h,flipV:!!t.flip_v,cellCm:this.host._cellCm,gridPitch:this.host._gridPitch,face:i});return Math.abs(e)<=a.hitHalf})?.o||null}_resolveOpeningPlacement(t){const e=this.host._openingPreset;if("opening"!==this.host._tool||!e)return null;const s=this.host._spaceModel();if(!s)return null;const i=this.host._openCuts(),o=this.host._openingWallIndexFor(s,i),a=`${o.key}|partitions:${this.host._cfgEpoch}`;this.host._openingPlacementIntervalsCache&&this.host._openingPlacementIntervalsCache.key===a||(this.host._openingPlacementIntervalsCache={key:a,value:[...O(s.rooms,this.host._spaceWalls,i,this.host._wallKeyPitch,this.host._cellCm,this.host._gridPitch,kd),...Bs(s.partitions,this.host._cellCm,this.host._gridPitch)]}),this.host._openingDimensionContextCache&&this.host._openingDimensionContextCache.key===a||(this.host._openingDimensionContextCache={key:a,value:rd({rooms:s.rooms,walls:this.host._spaceWalls,openCuts:i,partitions:s.partitions,roomOpenings:this.host._roomWallOpeningInputs(),partitionCuts:this._partitionOpeningCuts(s),pitch:this.host._wallKeyPitch,cellCm:this.host._cellCm,gridPitch:this.host._gridPitch,coordScale:kd,epsilon:2e-4*this.host._gridPitch})});const n=Ws({pointer:[t[0],t[1]],preset:e,geometryRevision:this.host._cfgEpoch,renderedLength:this.host._cmToUnits(e.lengthCm),intervals:this.host._openingPlacementIntervalsCache.value,baseTolerance:1.5*this.host._gridPitch,bodyPointerPadding:this._cssPxToRender("touch"===this.host._pointerModality.modality||"pen"===this.host._pointerModality.modality?10:6),gridStep:this.host._gridPitch});this.host._openingJambBlockCm=n.jambBlockedTarget?n.jambBlockedTarget.physicalHalfWidth/this.host._gridPitch*this.host._cellCm:null;const r=n.candidate;if(!r)return null;const l="gate"===r.type?!r.flipV:r.flipV;let h;if(r.host){const t=A({id:"preview",type:r.type,x:r.x/kd,y:r.y/kd,angle:r.angle,length:r.renderedLength/kd,host:r.host},s.partitions,kd,this.host._cellCm,this.host._gridPitch).resolved;h=t?js(t,l):{ox:0,oy:0,cm:0,side:-1}}else h=Gs(o.value,{x:r.x,y:r.y,angle:r.angle,length:r.renderedLength,flip_v:l});const c="mi"===this.host.hass?.config?.unit_system?.length,d=_d(r,this.host._openingDimensionContextCache.value).map(t=>({x:t.label[0],y:t.label[1],text:fe(t.distance/this.host._gridPitch*this.host._cellCm,c),dimension:t}));return{...r,face:h,measure:{labels:d,guide:r.measure.guide}}}_activateOpeningPlacement(t){this._activateMarkupTool("opening"),"opening"===this.host._tool&&(this.host._openingPreset=qs(t,++this.host._openingPresetRevision),this.host._openingHoverCandidate=null,this.host._cursorPt=null)}_clearOpeningPlacement(t){this.host._openingHoverCandidate=null,this.host._openingJambBlockCm=null,t&&(this.host._openingPreset=null,this.host._openingRebindId=null)}_openingClick(t){const e=this.host._spaceModel();if(!e)return;const s=this.host._openingRebindId?null:this._openingAt(t);if(s)return void this._editOpening(s);const i=this.host._openingPreset;if(!i)return;const o=this.host._openingHoverCandidate,a=o&&Us(o,[t[0],t[1]],i.revision,this.host._cfgEpoch)?o:this._resolveOpeningPlacement(t);if(!a){if(null!=this.host._openingJambBlockCm)return void this.host._showToast(this.host._t("opening.partition_jamb_margin",{distance:fe(this.host._openingJambBlockCm,this.host._imperial)}));const s=1.5*this.host._gridPitch,i=R(t,e.rooms,s);return i&&Ks(i.x,i.y,i.angle,this.host._openCuts(),s)?void this.host._showToast(this.host._t("toast.opening_on_zero_wall")):void this.host._showToast(this.host._t("toast.opening_no_wall"))}const n=this.host._openingRebindId?this.host._curSpaceCfg?.openings?.find(t=>t.id===this.host._openingRebindId):null;this.host._openingDialog={...n?{id:n.id,type:n.type,lengthCm:Math.round(n.length*kd/this.host._gridPitch*this.host._cellCm),lengthTouched:!1,contact:n.contact||"",lock:n.lock||"",invert:!!n.invert,flipH:!!n.flip_h,flipV:!!n.flip_v}:{type:a.type,lengthCm:a.lengthCm,contact:"",lock:"",invert:!1,flipH:a.flipH,flipV:a.flipV},...a.host?{host:a.host}:{},x:a.x,y:a.y,angle:a.angle},this.host._openingRebindId=null,this.host._openingHoverCandidate=null,this.host._cursorPt=null}_editOpening(t){this.host._openingDialog={id:t.id,type:t.type,lengthCm:Math.round(t.rlen/this.host._gridPitch*this.host._cellCm),lengthTouched:!1,contact:t.contact||"",lock:t.lock||"",invert:!!t.invert,flipH:!!t.flip_h,flipV:!!t.flip_v,..."partition"===t.host?.kind?{host:{...t.host}}:{},x:t.rx,y:t.ry,angle:t.angle}}_opPointerDown(t,e){if("plan"===this.host._mode&&this.host._spaceModel()&&"resize"!==this.host._tool){t.preventDefault(),t.stopPropagation();try{Md(t)}catch{}this.host._opDrag={id:e.id,moved:!1,sx:t.clientX,sy:t.clientY,dirty:!1,before:this._geometrySnapshot()}}}_opPointerMove(t,e){hr(this.host,"opening",()=>this._opPointerMoveNow(t,e))}_opPointerMoveNow(t,e){if(!this.host._opDrag||this.host._opDrag.id!==e.id)return;if(Math.abs(t.clientX-this.host._opDrag.sx)+Math.abs(t.clientY-this.host._opDrag.sy)<=3)return;const s=this.host._spaceModel();if(!s)return;const i=this._svgPoint(t),o=this.host._curSpaceCfg,a=o?.openings?.find(t=>t.id===e.id);if(!a)return;if("partition"===a.host?.kind){const t=s.partitions.find(t=>t.id===a.host.id);if(!t)return;const e=t.b[0]-t.a[0],o=t.b[1]-t.a[1],n=Math.hypot(e,o);if(!(n>1e-9))return;const r=e/n,l=o/n;if(Math.abs((i[0]-t.a[0])*l-(i[1]-t.a[1])*r)>4*this.host._gridPitch)return;const h=a.length*kd/2+W(t,this.host._cellCm,this.host._gridPitch);let c=(i[0]-t.a[0])*r+(i[1]-t.a[1])*l;if(c=Math.round(c/this.host._gridPitch)*this.host._gridPitch,c=Math.max(h,Math.min(n-h,c)),n<2*h-1e-9)return;const d=c/n,p=(t.a[0]+r*c)/kd,u=(t.a[1]+l*c)/this.host._spaceH;let _=180*Math.atan2(o,e)/Math.PI;_>=90?_-=180:_<-90&&(_+=180);const g=a.host.t!==d||a.x!==p||a.y!==u||a.angle!==_;return this.host._opDrag.moved=!0,g&&(this.host._opDrag.dirty=!0),a.host={...a.host,t:d},a.x=p,a.y=u,a.angle=_,this.host._opMeasure=null,g&&this.host._cfgEpoch++,void this.host.requestUpdate()}const n=R(i,s.rooms,4*this.host._gridPitch);if(!n)return;this.host._opDrag.moved=!0;const r=this._opRuler(n,a.length*kd);this.host._opMeasure=r.measure;const l=r.x/kd,h=r.y/this.host._spaceH,c=a.x!==l||a.y!==h||a.angle!==n.angle;if(c&&(this.host._opDrag.dirty=!0),a.x=l,a.y=h,a.angle=n.angle,Number(this.host._serverCfg?.model_version||0)>=9){const t=$n(a,o?.wall_segments||[]);t?a.host=t:delete a.host}c&&this.host._cfgEpoch++,this.host.requestUpdate()}_opRuler(t,e){const s=this.host._spaceModel()?.rooms||[],i=this.host._gridPitch/2;let o=t.x,a=t.y,n=Vs([o,a],t.angle,e,s,i);if(n&&n.centered&&(o!==n.wallCenter[0]||a!==n.wallCenter[1]))[o,a]=n.wallCenter,n=Vs([o,a],t.angle,e,s,i);else if(n){const[r,l]=n.wallA,[h,c]=n.wallB,d=h-r,p=c-l,u=Math.hypot(d,p);if(u>0){const h=this.host._gridPitch,c=Math.min(e/2,u/2);let _=Math.round(((o-r)*d+(a-l)*p)/u/h)*h;_=Math.max(c,Math.min(u-c,_)),o=r+_/u*d,a=l+_/u*p,n=Vs([o,a],t.angle,e,s,i)||n}}if(!n)return{x:o,y:a,angle:t.angle,measure:null};const r="mi"===this.host.hass?.config?.unit_system?.length,l=(t,e)=>({x:e[0],y:e[1],text:fe(t/this.host._gridPitch*this.host._cellCm,r)});return{x:o,y:a,angle:t.angle,measure:{labels:[l(n.sideA,n.midA),l(n.sideB,n.midB)],guide:n.centered?{x:n.wallCenter[0],y:n.wallCenter[1],angle:t.angle}:null}}}_opPointerUp(t,e){if(!this.host._opDrag||this.host._opDrag.id!==e.id)return;cr(this.host,"opening");const s=this.host._opDrag,i=s.moved;this.host._opMeasure=null,i&&s.dirty&&this._commitPhysicalGeometry(this.host._t("history.move_opening"),s.before);const o=()=>{this.host._opDrag=null,this.host.requestUpdate()};i?window.setTimeout(o,0):o()}_opClick(t,e){"plan"===this.host._mode&&"resize"===this.host._tool||(t.stopPropagation(),this.host._opDrag?.moved||"plan"===this.host._mode&&this._editOpening(e))}_saveOpening(){const t=this.host._openingDialog,e=this.host._curSpaceCfg,s=this.host._spaceModel();if(!t||!e||!s)return;const i=this._geometrySnapshot(),o=this.host._spaceH,a=(e.openings||[]).find(e=>e.id===t.id),n={...a||{},id:t.id||"o"+Date.now().toString(36),type:t.type,x:t.x/kd,y:t.y/o,angle:t.angle,length:a&&!t.lengthTouched?a.length:this.host._cmToUnits(Math.max(20,t.lengthCm))/kd,...t.host?{host:{...t.host}}:{}};if("partition"===n.host?.kind){const t=Js(a,n)?q(n,s.partitions,kd,this.host._cellCm,this.host._gridPitch):A(n,s.partitions,kd,this.host._cellCm,this.host._gridPitch);if(!t.resolved){const e=s.partitions.find(t=>t.id===n.host.id);if("does-not-fit-jamb"===t.reason&&e){const t=W(e,this.host._cellCm,this.host._gridPitch);this.host._showToast(this.host._t("opening.partition_jamb_margin",{distance:fe(t/this.host._gridPitch*this.host._cellCm,this.host._imperial)}))}else this.host._showToast(this.host._t("opening.partition_orphan"));return}const i=(e.openings||[]).flatMap(t=>{if(!t.host||t.id===n.id)return[];const e=A(t,s.partitions,kd,this.host._cellCm,this.host._gridPitch).resolved;return e?[e]:[]});if(Zs(t.resolved,i))return void this.host._showToast(this.host._t("toast.opening_no_wall"));Object.assign(n,E(n,t.resolved,kd))}else if(Number(this.host._serverCfg?.model_version||0)>=9){const t=$n(n,e.wall_segments||[]);if(!t)return void this.host._showToast(this.host._t("toast.opening_no_wall"));n.host=t}else delete n.host;"passage"===t.type?(delete n.contact,delete n.lock,delete n.invert,delete n.flip_h,delete n.flip_v):(n.contact=t.contact||null,n.lock=("door"===t.type||"gate"===t.type)&&t.lock||null,n.invert=t.invert||void 0,n.flip_h="gate"!==t.type&&t.flipH||void 0,n.flip_v=t.flipV||void 0),e.openings=e.openings||[];const r=e.openings.findIndex(t=>t.id===n.id);r>=0?e.openings[r]=n:e.openings.push(n),this._commitPhysicalGeometry(this.host._t(t.id?"history.edit_opening":"history.add_opening"),i),this.host._openingDialog=null,this.host.requestUpdate()}_deleteOpening(){const t=this.host._openingDialog,e=this.host._curSpaceCfg;if(!t?.id||!e?.openings)return;const s=this._geometrySnapshot();e.openings=e.openings.filter(e=>e.id!==t.id),this._commitPhysicalGeometry(this.host._t("history.delete_opening"),s),this.host._openingDialog=null,this.host.requestUpdate()}_contactCandidates(){const t=[];for(const e of Object.keys(this.host.hass.states)){if(!this.host._openingEntityAvailable(e))continue;const s=e.split(".")[0];if("binary_sensor"!==s&&"cover"!==s)continue;const i=this.host.hass.states[e],o=["door","window","opening","garage_door","garage"].includes(i?.attributes?.device_class||"");("cover"!==s||o)&&t.push([e,i?.attributes?.friendly_name||e,o?0:1])}return t.sort((t,e)=>t[2]-e[2]||t[1].localeCompare(e[1])).map(([t,e])=>({value:t,label:e}))}_lockCandidates(){return Object.keys(this.host.hass.states).filter(t=>t.startsWith("lock.")&&this.host._openingEntityAvailable(t)).map(t=>({value:t,label:this.host.hass.states[t]?.attributes?.friendly_name||t})).sort((t,e)=>t.label.localeCompare(e.label))}_toggleOpeningEntityPicker(t){const e=this.host._openingDialog;if(!e)return;const s="contact"===t?!e.contactOpen:!e.lockOpen;this.host._openingDialog={...e,contactOpen:"contact"===t&&s,lockOpen:"lock"===t&&s}}_filterOpeningEntities(t,e){const s=this.host._openingDialog;s&&(this.host._openingDialog="contact"===t?{...s,contactFilter:e}:{...s,lockFilter:e})}_selectOpeningEntity(t,e){const s=this.host._openingDialog;s&&(this.host._openingDialog="contact"===t?{...s,contact:e,contactOpen:!1,contactFilter:""}:{...s,lock:e,lockOpen:!1,lockFilter:""})}_mergeClick(t){const e=this.host._spaceModel();if(!e)return;const s=e.rooms,i=[...s].reverse().find(e=>this._pointInRoom(t,e));if(!i?.id)return;const o=i.id;if(!this.host._mergeSel||this.host._mergeSel===o)return void(this.host._mergeSel=this.host._mergeSel===o?null:o);const a=s.find(t=>t.id===this.host._mergeSel),n=a?N(a):null,r=N(i),l=n&&r?Ys(n,r):null;if(!l)return this.host._showToast(this.host._t("toast.merge_not_adjacent")),void(this.host._mergeSel=null);this.host._mergeDialog={aId:this.host._mergeSel,bId:o,poly:l,pick:"a"},this.host._mergeSel=null}_commitMerge(){const t=this.host._mergeDialog,e=this.host._curSpaceCfg;if(!t||!e||!this.host._spaceModel())return;const s=this._geometrySnapshot(),i=this.host._spaceH,o="a"===t.pick?t.aId:t.bId,a="a"===t.pick?t.bId:t.aId,n=vd(this.host._serverCfg?.markers||[],{kind:"merge",dropId:a,keepId:o});s&&n.changed&&(s.roomReferences=n.before);const r=e.rooms.find(t=>t.id===o);if(!r)return void(this.host._mergeDialog=null);r.poly=t.poly.map(t=>[t[0]/kd,t[1]/i]),delete r.x,delete r.y,delete r.w,delete r.h,e.rooms=e.rooms.filter(t=>t.id!==a),n.changed&&this.host._serverCfg&&(this.host._serverCfg.markers=n.markers);const l=this._commitPhysicalGeometry(this.host._t("history.merge_rooms"),s);this.host._mergeDialog=null,this.host._regSignature="",this.host._maybeRebuildDevices(),l&&this.host._showToast(this.host._t("toast.rooms_merged",{name:r.name||""}))}_splitClick(t){const e=this.host._spaceModel();if(!e)return;const s=e.rooms;if(!this.host._splitSel){const e=[...s].reverse().find(e=>this._pointInRoom(t,e));if(!e?.id)return;return void(this.host._splitSel={roomId:e.id,pts:[]})}const i=s.find(t=>t.id===this.host._splitSel.roomId),o=i?N(i):null;if(!i||!o)return void(this.host._splitSel=null);const a=.02*this.host._gridPitch,n=6*this.host._gridPitch,r=Xs(t,o),l=r&&Qs(r,o,this.host._gridPitch)||r,h=r&&l&&Math.hypot(r[0]-t[0],r[1]-t[1])<=n?l:null,c=!!h&&ti(h,o,a),d=this.host._splitSel.pts;if(!d.length)return c?void(this.host._splitSel={...this.host._splitSel,pts:[h]}):void this.host._showToast(this.host._t("toast.split_pick_wall"));if(!c){const e=this._snap(t);return es(e,o,a)?void(this.host._splitSel={...this.host._splitSel,pts:[...d,e]}):void this.host._showToast(this.host._t("toast.split_pick_inside"))}const p=is(o,[...d,h],a);if(!p)return void this.host._showToast(this.host._t("toast.split_bad_cut"));this._resetRoomDialogFields();const[u,_]=p,g=ae(u)>=ae(_)?u:_,m=g===u?_:u;this.host._pendingSplit={roomId:i.id,mainPoly:g,newPoly:m},this.host._cursorPt=null,this.host._nameSel="",this.host._areaSel="",this.host._roomDialog=!0}_markupMove(t){if(!this.host._markup)return;if("column"===this.host._tool)return void(this.host._cursorPt=this._snap(this._svgPoint(t)));if("opening"===this.host._tool||"wallthick"===this.host._tool)return void(this.host._cursorPt=this._svgPoint(t));const e="draw"===this.host._tool&&!this.host._contourClosed,s="split"===this.host._tool&&!!this.host._splitSel?.pts?.length;if(!e&&!s)return;const i=this._svgPoint(t);if(e){const e=this._resolvePlanDrawPoint(i,t.shiftKey);if(this.host._planSnapHover={contextKey:e.contextKey,candidate:e.candidate,conflicts:e.conflicts},this._syncPlanSnapConflictMarkers(e.conflicts),this._syncPlanSnapActiveMarker(e.candidate),!this.host._path.length)return;return void(this.host._cursorPt=e.point)}this.host._cursorPt=this._snap(i)}_saveRoom(){(this.host._areaSel||this.host._nameSel.trim())&&zt(this.host._roomTempMin,this.host._roomTempMax).valid&&(this.host._wallFaceBatch?this._decideWallFace(!0):this._commitRoom())}_decideWallFace(t){const e=this.host._wallFaceBatch;if(!e)return;const s=e.candidates[e.index];if(!s)return;if(!t&&(s.existing||s.repair)&&1===e.candidates.length)return this.host._wallFaceBatch=null,this.host._roomDialog=!1,this.host._nameSel="",this.host._areaSel="",void this.host.requestUpdate();const i=t?{candidate:s,create:!0,name:this.host._nameSel.trim(),area:this.host._areaSel||null,settings:this._roomSettingsFromDialog()?JSON.parse(JSON.stringify(this._roomSettingsFromDialog())):null}:{candidate:s,create:!1},o=[...e.decisions,i],a=e.index+1;if(a"number"==typeof t&&Number.isFinite(t)&&t>=0?t:null,o=.02*this.host._gridPitch,a=this.host._spaceModel();if(!a)return H;for(const e of this._planSnapGeometrySnapshot().value.segments)if(!("room"===e.sourceKind||ye(t,[e.a[0],e.a[1],e.b[0],e.b[1]])>o)&&"partition"===e.sourceKind)return i(a.partitions.find(t=>t.id===e.sourceId)?.cm)??H;const n=ic(Math.max(0,e.length-1),s,this.host._drawWallCm,H);for(let s=0;s+1[...t]);if(!e)return s;const i=this.host._activeWallChainPartitionIds.findIndex((t,s)=>this._activeWallSourceKey(s)===e.sourceKey),o=i>=0?i+("b"===e.endpoint?1:0):-1;return o>=0&&oe.key===t.sourceKey),a=i.find(e=>e.key===t.targetSourceKey);if(!o||!a)return!1;const n="a"===t.endpoint?o.a:o.b;return!(Math.hypot(n[0]-t.from[0],n[1]-t.from[1])>s)&&(!(ye(t.to,[a.a[0],a.a[1],a.b[0],a.b[1]])>s)&&!function(t,e){if(!t.sourceKey.startsWith("static:partition|"))return!1;const s=t.sourceKey.slice(17).split("|")[0];return!!s&&e.some(t=>"partition"===t.host?.kind&&t.host.id===s)}(t,this.host._curSpaceCfg?.openings||[]))}_applyWallRepair(t,e){const s=this.host._curSpaceCfg;if(!s||!this._validateWallRepair(t,e.activePath))return!1;if(!t.sourceKey.startsWith("static:"))return!1;const[i,o]=t.sourceKey.slice(7).split("|");if("partition"===i){const i=(s.partitions||[]).find(t=>t.id===o);if(!i)return!1;const a=[i.a[0]*kd,i.a[1]*kd],n=[i.b[0]*kd,i.b[1]*kd],r=Math.hypot(a[0]-t.from[0],a[1]-t.from[1])<=2e-4*this.host._gridPitch?i.a:Math.hypot(n[0]-t.from[0],n[1]-t.from[1])<=2e-4*this.host._gridPitch?i.b:null;if(!r)return!1;(e=>{e[0]=t.to[0]/kd,e[1]=t.to[1]/kd})(r);const l=e.activePartitionIds.indexOf(o);if(l>=0){const s=l+("b"===t.endpoint?1:0);e.activePath[s]&&(e.activePath[s]=[...t.to])}return!0}return!1}_applyWallFaceBatch(){const t=this.host._wallFaceBatch,e=this.host._curSpaceCfg,s=this.host._spaceModel();if(!t||!e||!s)return;const i=(t,e)=>{this.host._showToast(this.host._t(t,e)),this._roomDialogCancel()},o=t.decisions.filter(t=>t.create),a=o.map(t=>t.candidate.ring),n=s.rooms;for(let t=0;ts.id!==e&&!!N(s)&&ie(a[t],N(s)));if(s)return void i("toast.room_overlap",{name:s.name||""})}if((e.rooms||[]).length+o.length>400)return void i("toast.physical_limit");if(o.some(t=>t.candidate.split&&!e.rooms.some(e=>e.id===t.candidate.split.roomId)))return void i("toast.contour_cannot_close");const r=o.map(t=>t.candidate.repair).filter(t=>!!t);if(r.length>1||r[0]&&!this._validateWallRepair(r[0],t.activePath))return void i("toast.wall_repair_changed");if(this._activePathWithRepair(t.activePath,r[0]),!o.length){if(!this._finalizeWallChainPartitions(t.activePartitionIds))return;return this.host._path=[],this.host._activeWallChainId=null,this.host._activeWallChainPartitionIds=[],this.host._wallChainSegmentCms=[],this.host._wallChainRedo=[],this.host._closingWallCm=null,this.host._wallFaceBatch=null,this.host._roomDialog=!1,this.host._nameSel="",this.host._areaSel="",this.host.requestUpdate(),void this.host._showToast(this.host._t("toast.wall_chain_saved"))}const l=new Set(t.activePartitionIds),h=2e-4*this.host._gridPitch,c=o.map(t=>t.candidate.ring.map((t,e,i)=>{const o=i[(e+1)%i.length],a=s.partitions.filter(e=>{const s=Math.hypot(e.b[0]-e.a[0],e.b[1]-e.a[1]);if(!(s>h))return!1;const i=(e.b[0]-e.a[0])/s,a=(e.b[1]-e.a[1])/s,n=t=>(t[0]-e.a[0])*i+(t[1]-e.a[1])*a;return ye(t,[e.a[0],e.a[1],e.b[0],e.b[1]])<=h&&ye(o,[e.a[0],e.a[1],e.b[0],e.b[1]])<=h&&n(t)>=-h&&n(t)<=s+h&&n(o)>=-h&&n(o)<=s+h});return a.sort((t,e)=>Number(l.has(e.id))-Number(l.has(t.id))||Math.hypot(t.b[0]-t.a[0],t.b[1]-t.a[1])-Math.hypot(e.b[0]-e.a[0],e.b[1]-e.a[1])||t.id.localeCompare(e.id)),a[0]?.id||""})),d=this._geometrySnapshot();if(!d)return void i("toast.geometry_unsafe");const p=()=>{this._restoreGeometryStateLocal(d),i("toast.geometry_unsafe")};if(r[0]&&!this._applyWallRepair(r[0],t))return void i("toast.wall_repair_changed");const u=o.some(t=>!!t.candidate.split),_=u?Ae(s.rooms,e.walls,this.host._openCuts(),this.host._wallKeyPitch,this.host._cellCm,this.host._gridPitch,kd):null,g=u&&Array.isArray(e.walls)?e.walls:null;for(const t of o){const s=t.candidate.split;if(!s)continue;const i=e.rooms.find(t=>t.id===s.roomId);if(!i)return void p();i.poly=s.mainPoly.map(t=>[t[0]/kd,t[1]/this.host._spaceH]),delete i.x,delete i.y,delete i.w,delete i.h}const m=Date.now().toString(36),f=[];if(o.forEach((t,s)=>{const i=t.area?this.host.hass.areas[t.area]?.name:"",o={id:`r${m}-${s}`,name:t.name||i||this.host._t("room.default_name"),area:t.area||null,poly:t.candidate.ring.map(t=>[t[0]/kd,t[1]/this.host._spaceH]),...c[s].some(Boolean)?{wall_ids:c[s]}:{},...t.settings?{settings:JSON.parse(JSON.stringify(t.settings))}:{}};e.rooms.push(o),f.push({room:o,decision:t})}),u){const t=this.host._normalizeWalls(_,this.host._openCuts());t.length?e.walls=t:g?.length?e.walls=g:delete e.walls}if(f.length){this.host._cfgEpoch++;const s=this.host._openCuts(),i=this.host._spaceModel();if(!i)return void p();let o=e.walls;for(const{room:e,decision:a}of f){const n=a.candidate.ring,r=this._wallSourceCmAt(n[0],t.activePath,t.activeCms);o=ei(o,i.rooms,e.id,r,this.host._wallKeyPitch,s,kd);for(const a of O(i.rooms,o,s,this.host._wallKeyPitch,this.host._cellCm,this.host._gridPitch,kd)){if(a.roomId!==e.id||"outer"!==a.kind)continue;const s=[(a.a[0]+a.b[0])/2,(a.a[1]+a.b[1])/2];o=j(o,a.a,a.b,this._wallSourceCmAt(s,t.activePath,t.activeCms),this.host._wallKeyPitch,kd)}}const a=this.host._normalizeWalls(o,s);a.length?e.walls=a:delete e.walls,this.host._cfgEpoch++;const n=this.host._spaceModel();if(!n)return void p();const r=Ua(e,n,e.walls,s,{pitch:this.host._wallKeyPitch,cellCm:this.host._cellCm,gridPitch:this.host._gridPitch,coordScale:kd,allowCoincidentPartitions:!0});r.walls.length?e.walls=r.walls:delete e.walls,r.partitions.length?e.partitions=r.partitions:delete e.partitions,r.openings.length?e.openings=r.openings:delete e.openings}if(!this._commitPhysicalGeometry(this.host._t("history.wall_face_batch"),d))return;this.host._path=[],this.host._activeWallChainId=null,this.host._activeWallChainPartitionIds=[],this.host._wallChainSegmentCms=[],this.host._wallChainRedo=[],this.host._closingWallCm=null,this.host._wallFaceBatch=null,this.host._roomDialog=!1,this.host._nameSel="",this.host._areaSel="",this.host._regSignature="",this.host._maybeRebuildDevices();const b=new Set(o.map(t=>t.area).filter(t=>!!t));if(b.size){const t={...this.host._layout};for(const e of this.host._devices){if(!b.has(e.area||"")||e.space!==this.host._space)continue;if(this.host._layout[e.id])continue;const s=this.host._defPos[e.id];s&&(t[e.id]={s:this.host._space,x:s.x/kd,y:s.y/kd},this.host._dirtyPos.add(e.id))}this.host._layout=t,this.host._persistLayout()}this.host._showToast(this.host._t(o.length?"toast.wall_rooms_saved":"toast.wall_chain_saved",{n:o.length}))}_commitRoom(){const t=this.host._curSpaceCfg,e=this.host._spaceModel();if(!t||!e)return;const s=this._geometrySnapshot();if(!s)return;const i=()=>{this._restoreGeometryStateLocal(s),this.host._showToast(this.host._t("toast.geometry_unsafe"))},o=this.host._spaceH,a=!!this.host._pendingSplit,n=a?Ae(e.rooms,t.walls,this.host._openCuts(),this.host._wallKeyPitch,this.host._cellCm,this.host._gridPitch,kd):null,r=a&&Array.isArray(t.walls)?t.walls:null;let l;if(this.host._pendingSplit){const e=t.rooms.find(t=>t.id===this.host._pendingSplit.roomId);if(!e)return this.host._pendingSplit=null,this.host._splitSel=null,void(this.host._roomDialog=!1);e.poly=this.host._pendingSplit.mainPoly.map(t=>[t[0]/kd,t[1]/o]),delete e.x,delete e.y,delete e.w,delete e.h,l=this.host._pendingSplit.newPoly}else{if(!this.host._contourClosed)return;l=this.host._path.slice(0,-1)}const h=this.host._areaSel?this.host.hass.areas[this.host._areaSel]?.name:"",c={id:"r"+Date.now().toString(36),name:this.host._nameSel||h||this.host._t("room.default_name"),area:this.host._areaSel||null,poly:l.map(t=>[t[0]/kd,t[1]/o]),...this._roomSettingsFromDialog()?{settings:this._roomSettingsFromDialog()}:{}};if(t.rooms.push(c),a){const e=this.host._normalizeWalls(n,this.host._openCuts());e.length?t.walls=e:r?.length?t.walls=r:delete t.walls}if(!a){const e=ic(l.length,[...this.host._wallChainSegmentCms,this.host._closingWallCm??void 0],this.host._drawWallCm,H),s=e[0];if(null!=s){this.host._cfgEpoch++;const o=this.host._openCuts(),a=this.host._spaceModel();if(!a)return void i();let n=ei(t.walls,a.rooms,c.id,s,this.host._wallKeyPitch,o,kd);for(const t of O(a.rooms,n,o,this.host._wallKeyPitch,this.host._cellCm,this.host._gridPitch,kd)){if(t.roomId!==c.id||"outer"!==t.kind)continue;const s=[(t.a[0]+t.b[0])/2,(t.a[1]+t.b[1])/2],i=l.findIndex((t,e)=>{const i=l[(e+1)%l.length];return ye(s,[t[0],t[1],i[0],i[1]])<=.02*this.host._gridPitch});i>=0&&(n=j(n,t.a,t.b,e[i],this.host._wallKeyPitch,kd))}n=this.host._normalizeWalls(n,o),n.length?t.walls=n:delete t.walls;const r=this.host._spaceModel();if(!r)return void i();const h=Ua(t,r,t.walls,o,{pitch:this.host._wallKeyPitch,cellCm:this.host._cellCm,gridPitch:this.host._gridPitch,coordScale:kd,allowCoincidentPartitions:!0});h.walls.length?t.walls=h.walls:delete t.walls,h.partitions.length?t.partitions=h.partitions:delete t.partitions,h.openings.length?t.openings=h.openings:delete t.openings}}const d=this._commitPhysicalGeometry(this.host._t(a?"history.split_room":"history.add_room"),s);this.host._path=[],this.host._activeWallChainId=null,this.host._activeWallChainPartitionIds=[],this.host._wallChainSegmentCms=[],this.host._wallChainRedo=[],this.host._closingWallCm=null,this.host._pendingSplit=null,this.host._splitSel=null;const p=this.host._areaSel;if(this.host._areaSel="",this.host._nameSel="",this.host._roomDialog=!1,this.host._regSignature="",this.host._maybeRebuildDevices(),!d)return;let u=0;if(p){const t=kd,e={...this.host._layout};for(const s of this.host._devices){if(s.area!==p||s.space!==this.host._space)continue;if(u++,this.host._layout[s.id])continue;const i=this.host._defPos[s.id];i&&(e[s.id]={s:this.host._space,x:i.x/kd,y:i.y/t},this.host._dirtyPos.add(s.id))}this.host._layout=e,this.host._persistLayout()}const _=this.host._model.find(t=>t.id===this.host._space)?.rooms.length||0;this.host._showToast(p?this.host._t("toast.room_saved",{n:_,added:u}):this.host._t("toast.room_saved_no_area",{n:_}))}_cancelPath(){this.host._wallRepairDiagnostic=null,this.host._path=[],this.host._activeWallChainId=null,this.host._activeWallChainPartitionIds=[],this.host._wallChainSegmentCms=[],this.host._wallChainRedo=[],this.host._closingWallCm=null,this._clearPlanSnapHover(),this.host._roomDialog=!1,this.host._pendingSplit=null,this.host._wallFaceBatch=null,this.host._splitSel=null,this.host._mergeSel=null,this.host._mergeDialog=null,this.host._physicalSel=null,this.host._physicalDrag=null,this.host._physicalRotate=null,this._clearOpeningPlacement(!0)}_roomDialogCancel(){if(this.host._roomDialog=!1,this.host._roomEditId)return this.host._roomEditId=null,this.host._nameSel="",void(this.host._areaSel="");if(this.host._wallFaceBatch){const t=this.host._wallFaceBatch;return this.host._wallFaceBatch=null,this.host._path=t.activePath.map(t=>[...t]),this.host._wallChainSegmentCms=[...t.activeCms],this.host._activeWallChainPartitionIds=[...t.activePartitionIds],this.host._activeWallChainId||=`chain-${Date.now().toString(36)}`,this.host._nameSel="",this.host._areaSel="",void this.host.requestUpdate()}if(this.host._pendingSplit)return this.host._pendingSplit=null,void(this.host._splitSel=null);this.host._undoPoint()}_openDeviceInbox(){this.host._deviceInboxReturn=null,this.host._deviceInbox=this.host._deviceInbox||{tab:"on_plan",search:"",showEntities:!1,onlyNew:!1,limit:100}}_closeMarkerDialog(){this._radarSetup.isDirty()?this._closeMarkerDialogGuarded():(this._radarSetup.reset(),function(t){if(t._markerDialog=null,!t._deviceInboxReturn)return;const e={...t._deviceInboxReturn};t._deviceInbox=e,t._deviceInboxReturn=null,e.anchor&&t.updateComplete.then(()=>requestAnimationFrame(()=>{const s=`.device-inbox-row[data-binding="${CSS.escape(e.anchor)}"]`;t.renderRoot.querySelector(s)?.scrollIntoView({block:"nearest"})}))}(this.host))}async _closeMarkerDialogGuarded(){if(!await this._radarSetup.discardIfAllowed())return await this.host.updateComplete,void this.host.renderRoot.querySelector("#marker-dialog")?.rejectClose();this._closeMarkerDialog()}_deviceInboxCandidates(t){return Th({hass:this.host._planHass,devices:this.host._devices,markers:this.host._markers,showEntities:t,labels:{device:this.host._t("marker.sub_device"),z2mGroup:this.host._t("marker.sub_z2m_group"),group:this.host._t("marker.sub_group"),helper:this.host._t("marker.sub_helper"),entity:this.host._t("marker.sub_entity")}})}_deviceInboxRows(){const t=this.host._deviceInbox||this.host._deviceInboxReturn,e=!!t?.showEntities,s=[this.host._haRegistry.revision,this.host._cfgRev,this.host._cfgEpoch,this.host._regSignature,this.host._newSyncKey,e?1:0,this.host._showAll?1:0,l(this.host.hass,this.host._config?.language)].join("|");if(this.host._deviceInboxMemo?.key===s)return this.host._deviceInboxMemo.rows;const i=this._deviceInboxCandidates(e),o=new Set(i.map(t=>t.value));for(const t of this.host._markers)t.binding&&"virtual"!==t.binding&&o.add(t.binding);for(const t of this.host._devices)t.bindingKind&&"virtual"!==t.bindingKind&&t.bindingRef&&o.add(`${t.bindingKind}:${t.bindingRef}`);const a=new Map;for(const t of o)a.set(t,this.host._bindingStatus(t));const n=this.host._areaToSpace,r={};for(const[t,e]of Object.entries(this.host.hass?.areas||{}))r[t]=n[t]?.room?.name||e?.name||t;for(const[t,e]of Object.entries(n))r[t]=e.room.name||r[t]||t;const h=Object.fromEntries(this.host._model.map(t=>[t.id,t.title])),c=Object.fromEntries(Object.entries(n).map(([t,e])=>[t,e.space])),d={},p=new Map;for(const[t,e]of Object.entries(this.host._fullRegistryHass.entities||{})){const s=String(e?.platform||"").trim();if(s&&(d[`entity:${t}`]=s),s&&e?.device_id){const t=p.get(e.device_id)||new Set;t.add(s),p.set(e.device_id,t)}}for(const[t,e]of p)d[`device:${t}`]=[...e].sort().join(", ");const u={};for(const[t,e]of Object.entries(this.host._fullRegistryHass.devices||{})){const s=`device:${t}`,i=p.get(t)||new Set,o=Array.isArray(e?.identifiers?.[0])?String(e.identifiers[0][0]||""):"";o&&!d[s]&&(d[s]=o);const a=[o,...i].some(t=>this.host._excluded.has(t));"service"===e?.entry_type?u[s]="service_entry":a?u[s]="excluded_integration":"Group"===e?.model?u[s]="grouped_light":/scene/i.test(e?.model||"")?u[s]="excluded_domain":(/bridge/i.test(`${e?.model||""}${e?.name||""}`)||"myheat"===o&&e?.via_device_id)&&(u[s]="represented_by_parent")}const _=function(t){const{devices:e,markers:s,candidates:i,statuses:o,newDeviceIds:a,showHiddenOnPlan:n,areaNames:r={},spaceNames:l={},spaceByArea:h={},integrationByBinding:c={},reasonByBinding:d={}}=t,p=new Map;for(const t of e)!t.virtual&&t.bindingKind&&"virtual"!==t.bindingKind&&t.bindingRef&&p.set(`${t.bindingKind}:${t.bindingRef}`,t);const u=new Map,_=new Map;for(const t of s)t?.binding&&"virtual"!==t.binding&&(t.removed?_.set(t.binding,t):u.set(t.binding,t));const g=new Map(i.map(t=>[t.value,t])),m=new Set([...p.keys(),...u.keys(),...g.keys(),...[..._.keys()].filter(t=>g.has(t))]),f=[];for(const t of m){const e=p.get(t),s=u.get(t),i=s?void 0:_.get(t),m=g.get(t);let b;if(i&&m)b="readd";else if(!0===s?.hidden)b="hidden";else if(e||s)b="on_plan";else{if(!m)continue;b="available"}const v=e?.bindingStatus||o.get(t)||Rh,y=s||i,$=zh(t),w=e?.area||m?.areaId||y?.area||"",k=e?.space||y?.space||h[w]||"",x=e?.name||y?.name||m?.label||t,M=e?.model||y?.model||m?.model||"",C=!!m?.parentDeviceId&&p.has(`device:${m.parentDeviceId}`),S="readd"===b?"removed":"hidden"===b?s&&Fh(s)?d[t]||"automatic_hidden":"manual_hidden":"on_plan"===b?s?"visible_explicit":"visible_auto":d[t]||(C?"represented_by_parent":w&&k?"available":"no_bound_room"),P=!!e&&(!e.hidden||n),D="active"===v.kind,I=P&&(D||"ha_disabled"===v.kind&&n),L=[x,M,c[t],r[w],l[k],t,m?.sub].filter(Boolean).join(" ").toLocaleLowerCase();f.push({key:t,binding:t,category:b,status:v,reason:S,deviceId:e?.id,markerId:y?.id,name:x,icon:e?.icon||y?.icon||("entity"===$?"mdi:code-braces":"mdi:devices"),model:M,integration:c[t]||"",areaId:w,areaName:r[w]||"",spaceId:k,spaceName:l[k]||"",kind:$,isNew:!!e&&a.has(e.id),searchText:L,canFind:I,canEdit:!!e||!!s,canHide:"on_plan"===b&&D,canShow:"hidden"===b&&D,canAdd:("available"===b||"readd"===b)&&D})}const b=t=>"active"===t.status.kind?1:0;return f.sort((t,e)=>t.category.localeCompare(e.category)||Number(e.isNew)-Number(t.isNew)||b(t)-b(e)||t.name.localeCompare(e.name)||t.binding.localeCompare(e.binding))}({devices:this.host._devices,markers:this.host._markers,candidates:i,statuses:a,newDeviceIds:this.host._newIds,showHiddenOnPlan:this.host._showAll,areaNames:r,spaceNames:h,spaceByArea:c,integrationByBinding:d,reasonByBinding:u});return this.host._deviceInboxMemo={key:s,rows:_},_}_deviceForInboxRow(t){const e=t.deviceId?this.host._devices.find(e=>e.id===t.deviceId):null;if(e)return e;const s=t.markerId?this.host._markers.find(e=>e.id===t.markerId):null;return!s||s.removed?null:{id:s.id,name:t.name,model:t.model,area:t.areaId,space:t.spaceId||this.host._space,hidden:!0===s.hidden||"ha_disabled"===t.status.kind,userHidden:!0===s.hidden,bindingStatus:t.status,icon:t.icon,entities:"active"===t.status.kind?t.status.enabledEntityIds:[],allEntities:t.status.allEntityIds,primary:"active"===t.status.kind?t.status.enabledEntityIds[0]:void 0,marker:s,bindingKind:t.kind,bindingRef:t.binding.slice(t.binding.indexOf(":")+1),pdfs:s.pdfs||[]}}_openInboxMarker(t,e=!1){const s=this.host._deviceInbox;if(s){if(this.host._deviceInboxReturn={...s,anchor:t.key},this.host._deviceInbox=null,!e){const e=this._deviceForInboxRow(t);return void(e?this._openMarkerDialog(e):this._closeMarkerDialog())}this._openMarkerDialog(),this.host._markerDialog?this.host._markerDialog={...this.host._markerDialog,bindingMode:"ha",binding:t.binding,bindingOpen:!1,showEntities:"entity"===t.kind,name:""}:this._closeMarkerDialog()}}async _setInboxHidden(t,e){const s=this.host._deviceInbox,i=this.host._serverCfg;if(!s||!i||s.busy||"active"!==t.status.kind)return;const o=i.markers||[],a=o.find(e=>!e.removed&&e.binding===t.binding);if(!e&&!a)return;const n=a?.id||si(t.binding,t.markerId,()=>`m_${Date.now().toString(36)}`),r=a?{...a,hidden:e}:{id:n,binding:t.binding,hidden:!0};i.markers=[...o.filter(e=>e.id!==n&&(e.binding!==t.binding||!0===e.removed)),r],this.host._deviceInbox={...s,busy:t.key,anchor:t.key};try{await this._saveConfigNow(),this.host._regSignature="",this.host._deviceInboxMemo=null,this.host._maybeRebuildDevices(),this.host._deviceInbox&&(this.host._deviceInbox={...this.host._deviceInbox,busy:void 0}),this.host._showToast(this.host._t("device_inbox.saved"))}catch(t){this.host._serverCfg===i&&(i.markers=o),this.host._deviceInbox&&(this.host._deviceInbox={...this.host._deviceInbox,busy:void 0}),this.host._showToast(this.host._t("toast.error",{err:this.host._errText(t)}))}}_findInboxDevice(t){if(!t.canFind)return;const e=this._deviceForInboxRow(t);if(!e)return;if(this.host._deviceInbox=null,e.space&&e.space!==this.host._space){if(!this.host._commitSpace(e.space))return;this.host._restoreZoom()}const s=()=>{const t=this.host._devices.find(t=>t.id===e.id)||e,s=this.host._pos(t);this.host._applyView(this.host._zoom,s.x,s.y),this.host._selId=t.id,this.host.requestUpdate(),window.setTimeout(()=>{this.host._selId===t.id&&(this.host._selId=null,this.host.requestUpdate())},1500)};requestAnimationFrame(()=>requestAnimationFrame(s))}_openMarkerDialog(t){if(this.host._vacAllCamerasFor=null,this.host._vacAllCameraCache=null,t&&this.host._ackNewDevice(t.id),this.host._norm)if(t){const e=t.marker,s=Object.prototype.hasOwnProperty.call(e||{},"is_light"),i=Object.prototype.hasOwnProperty.call(e||{},"light_entity"),o=Object.prototype.hasOwnProperty.call(e||{},"glow_color"),a=Object.prototype.hasOwnProperty.call(e||{},"value_badge"),n=Object.prototype.hasOwnProperty.call(e||{},"value_source"),r=Object.prototype.hasOwnProperty.call(e||{},"tap_action"),l=Object.prototype.hasOwnProperty.call(e||{},"toggle_entity"),h=ii(e?.glow_color),c=this.host._devicePresentation(t,!0).valueBadge,d=m(this.host._planHass,t,this.host._devices),p=f(this.host._planHass,t,d),u=ra(t,this.host._fullRegistryHass),_=this.host._spaceModelById(t.space)||this.host._spaceModel(),g=this.host._pos(t),b=_?ha(t,_,[g.x,g.y],this.host._fullRegistryHass):null;this.host._markerDialog={devId:t.id,name:t.name,binding:"virtual"===t.bindingKind?"virtual":t.bindingKind+":"+t.bindingRef,bindingMode:"virtual"===t.bindingKind?"virtual":"ha",bindingOpen:!1,showEntities:"entity"===t.bindingKind&&!!this.host._fullRegistryHass.entities[t.bindingRef||""]?.device_id,bindingFilter:"",icon:t.marker?.icon||"",autoIcon:t.icon||"",display:S(t.marker?.display),rippleColor:qt(t.marker?.ripple_color,""),rippleSize:Number(t.marker?.ripple_size)>0?Number(t.marker.ripple_size):1.5,size:Number(t.marker?.size)>0?Number(t.marker.size):1,angle:Number(t.marker?.angle)||0,tapAction:oi(t.marker?.tap_action,t.primary?.split(".")[0]),tapActionTouched:!1,originalHasTapAction:r,originalTapAction:t.marker?.tap_action,tapHintAnnouncement:"",toggleEntity:e?.toggle_entity||"",toggleEntityTouched:!1,originalHasToggleEntity:l,originalToggleEntity:e?.toggle_entity,tapTarget:t.marker?.tap_target||"",tapConfirm:!0===t.marker?.tap_confirm,runFilter:"",controls:x(t.marker?.binding,t.marker?.controls,t.entities),controlsFilter:"",lightRole:!0===e?.is_light?"always":!1===e?.is_light?"never":"auto",lightRoleTouched:!1,originalHasIsLight:s,originalIsLight:e?.is_light,lightEntity:e?.light_entity||"",lightEntityTouched:!1,originalHasLightEntity:i,originalLightEntity:e?.light_entity,glowMode:null!=h?.bri?"fixed":h?"color":"auto",glowColor:h?.c||this.host._fillColors.glow_light.c,glowBrightness:Math.max(1,Math.round(100*(h?.bri??1))),glowColorDrafted:!!h,glowBrightnessDrafted:null!=h?.bri,glowTouched:!1,originalHasGlowColor:o&&(!!h||null===e?.glow_color),originalGlowColor:h||(null===e?.glow_color?null:void 0),valueBadgeEnabled:a?!0===e?.value_badge?.enabled:!!c,valueBadgeSource:e?.value_badge?.source||c?.source||p,valueBadgePosition:e?.value_badge?.position||c?.position||"right",valueBadgeTouched:!1,originalHasValueBadge:a,originalValueBadge:e?.value_badge,valueSource:e?.value_source||null,valueSourceTouched:!1,originalHasValueSource:n,originalValueSource:e?.value_source,useClimateTemp:!0===t.marker?.use_climate_temp,glowRadius:Number(t.marker?.glow_radius_cm)>0?String(this.host._imperial?Math.round(Number(t.marker.glow_radius_cm)/30.48*10)/10:Math.round(Number(t.marker.glow_radius_cm))/100):"",model:t.model||"",link:t.link||"",description:t.description||"",pdfs:[...t.pdfs||[]],room:t.marker?.room_id?t.space+"#@"+t.marker.room_id:t.space&&t.area?t.space+"#"+t.area:"",roomTouched:!1,radar:b,radarEligible:u.eligible,radarTouched:!1,radarRemove:!1,hideFromPlan:!0===t.marker?.hidden,busy:!1}}else this.host._markerDialog={name:"",binding:"virtual",bindingMode:"virtual",bindingOpen:!1,showEntities:!1,bindingFilter:"",icon:"",autoIcon:"",display:"badge",rippleColor:"",rippleSize:1.5,size:1,angle:0,tapAction:"info",tapActionTouched:!1,originalHasTapAction:!1,originalTapAction:void 0,tapHintAnnouncement:"",toggleEntity:"",toggleEntityTouched:!1,originalHasToggleEntity:!1,originalToggleEntity:void 0,tapTarget:"",tapConfirm:!1,runFilter:"",controls:[],controlsFilter:"",lightRole:"auto",lightRoleTouched:!1,originalHasIsLight:!1,originalIsLight:void 0,lightEntity:"",lightEntityTouched:!1,originalHasLightEntity:!1,originalLightEntity:void 0,glowMode:"auto",glowColor:this.host._fillColors.glow_light.c,glowBrightness:100,glowColorDrafted:!1,glowBrightnessDrafted:!1,glowTouched:!1,originalHasGlowColor:!1,originalGlowColor:void 0,valueBadgeEnabled:!1,valueBadgeSource:null,valueBadgePosition:"right",valueBadgeTouched:!1,originalHasValueBadge:!1,originalValueBadge:void 0,valueSource:null,valueSourceTouched:!1,originalHasValueSource:!1,originalValueSource:void 0,useClimateTemp:!1,glowRadius:"",model:"",link:"",description:"",pdfs:[],room:"",roomTouched:!1,radar:null,radarEligible:!1,radarTouched:!1,radarRemove:!1,hideFromPlan:!1,busy:!1,uploadId:"up_"+Date.now().toString(36)+Math.random().toString(36).slice(2,6)};else this.host._showToast(this.host._t("toast.marker_needs_server"))}_runCandidates(){const t=[];for(const e of ai)for(const[s,i]of Object.entries(this.host.hass.states))s.startsWith(e+".")&&this.host._planEntityAvailable(s)&&t.push({value:s,label:i?.attributes?.friendly_name||s,sub:this.host._t("run."+e)});return t.sort((t,e)=>t.sub.localeCompare(e.sub)||t.label.localeCompare(e.label))}_bindingCandidates(){const t=Th({hass:this.host._planHass,devices:this.host._devices,markers:this.host._markers,showEntities:!!this.host._markerDialog?.showEntities,currentBinding:this.host._markerDialog?.binding,currentDeviceId:this.host._markerDialog?.devId,labels:{device:this.host._t("marker.sub_device"),z2mGroup:this.host._t("marker.sub_z2m_group"),group:this.host._t("marker.sub_group"),helper:this.host._t("marker.sub_helper"),entity:this.host._t("marker.sub_entity")}}),e=(this.host._markerDialog?.bindingFilter||"").toLowerCase().trim(),s=e?t.filter(t=>(t.label+" "+t.sub+" "+t.value).toLowerCase().includes(e)):t;return s.sort((t,e)=>t.label.localeCompare(e.label)),s.slice(0,200)}_backupErrorText(t){const e=t?.code??t?.error;if("string"==typeof e){const t=`backup.error.${e}`,s=this.host._t(t);if(s!==t)return s}return this.host._errText(t)}async _pickMarkerFiles(t){const e=t.target,s=e.files?[...e.files]:[];if(e.value="",!s.length||!this.host._markerDialog)return;const i=this.host._markerDialog.uploadId||this.host._markerDialog.devId||"new",o=[];for(const t of s)try{const e=new FormData;e.append("marker_id",i),e.append("file",t,t.name);const s=this.host.hass?.fetchWithAuth?await this.host.hass.fetchWithAuth("/api/houseplan/upload",{method:"POST",body:e}):await fetch("/api/houseplan/upload",{method:"POST",body:e,headers:this.host.hass?.auth?.data?.access_token?{authorization:`Bearer ${this.host.hass.auth.data.access_token}`}:{}}),a=await s.json().catch(()=>({}));if(!s.ok||a.error){const t={too_large:this.host._t("err.too_large",{mb:a.max_mb||50}),bad_ext:this.host._t("err.bad_ext"),unauthorized:this.host._t("err.unauthorized")};throw new Error(t[a.error]||a.error||"HTTP "+s.status)}o.push({name:a.name||t.name,url:a.url})}catch(e){this.host._showToast(this.host._t("toast.file_failed",{name:t.name,err:this.host._errText(e)}))}o.length&&this.host._markerDialog&&(this.host._markerDialog={...this.host._markerDialog,pdfs:[...this.host._markerDialog.pdfs,...o]},this.host._showToast(this.host._t("toast.files_attached",{n:o.length})))}_removeMarkerPdf(t){this.host._markerDialog&&(this.host._markerDialog={...this.host._markerDialog,pdfs:this.host._markerDialog.pdfs.filter(e=>e.url!==t)})}_markerLightFields(t){const e={};if(t.lightRoleTouched?"always"===t.lightRole?e.is_light=!0:"never"===t.lightRole&&(e.is_light=!1):t.originalHasIsLight&&(e.is_light=t.originalIsLight??null),t.lightEntityTouched?t.lightEntity&&(e.light_entity=t.lightEntity):t.originalHasLightEntity&&(e.light_entity=t.originalLightEntity??null),t.glowTouched){if("auto"!==t.glowMode){const s={c:qt(t.glowColor,this.host._fillColors.glow_light.c)};"fixed"===t.glowMode&&(s.bri=Math.max(.01,Math.min(1,Math.round(t.glowBrightness)/100))),e.glow_color=s}}else t.originalHasGlowColor&&(e.glow_color=t.originalGlowColor??null);return e}_markerTapActionFields(t){return t.tapActionTouched?{tap_action:t.tapAction||null}:t.originalHasTapAction?{tap_action:t.originalTapAction??null}:{}}_markerToggleEntityFields(t){return(e={touched:t.toggleEntityTouched,originalHas:t.originalHasToggleEntity,original:t.originalToggleEntity,value:t.toggleEntity}).touched?e.value?{toggle_entity:e.value}:{}:e.originalHas?{toggle_entity:e.original??null}:{};var e}async _saveMarker(){const t=this.host._markerDialog;if(!t||t.busy)return;const e=this._effectiveMarkerTapAction(t);if("ha"===t.bindingMode&&(!t.binding||"virtual"===t.binding))return;if("virtual"===t.binding&&!t.name.trim())return void this.host._showToast(this.host._t("toast.virtual_name_required"));if("run"===e&&!t.tapTarget)return void this.host._showToast(this.host._t("toast.run_target_required"));if(t.valueBadgeTouched&&t.valueBadgeEnabled&&!t.valueBadgeSource)return void this.host._showToast(this.host._t("toast.value_badge_source_required"));if("ha"===t.bindingMode){const e=this.host._bindingStatus(t.binding),s=t.devId?this.host._markers.find(e=>e.id===t.devId):null,i=!s||s.binding!==t.binding;if("active"!==e.kind&&i)return void this.host._showToast(this.host._t("ha_disabled"===e.kind?"toast.ha_disabled_add":"toast.ha_binding_unverified"));if("ha_disabled"===e.kind&&!0===s?.hidden&&!t.hideFromPlan)return this.host._markerDialog={...t,hideFromPlan:!0},void this.host._showToast(this.host._t("entity"===e.reason?"toast.ha_disabled_show_entity":"toast.ha_disabled_show_device"))}const s=this.host._serverCfg;if(!s)return;const i=this.host._cfgRev,o=yt(s);let a=JSON.parse(JSON.stringify(s));const n=a.markers||[],r=si(t.binding,t.devId,()=>"v_"+Date.now().toString(36)),l=t.devId,h=l?this.host._devices.find(t=>t.id===l):null,c=l?n.find(t=>t.id===l):null,d=!!c&&("string"==typeof c.area&&c.area.length>0||null===c.area&&!!c.space&&!!c.room_id),p="virtual"===t.binding||t.roomTouched||d,u="virtual"===t.binding||t.roomTouched?M(t.room):null;let _=d&&!t.roomTouched?c?.space||null:u?.space||null;const g=d&&!t.roomTouched?c?.area||null:u?.area||null,m=d&&!t.roomTouched?c?.room_id||null:u?.roomId||null,f=_||h?.space||null,b=f?this.host._spaceModelById(f):this.host._spaceModel();if(!b)return;const v=b.id;"virtual"!==t.binding||_||(_=v);let y={};if(t.radarTouched){if(t.radarRemove)y={radar:null};else if(t.radar){const e=pa(t.radar,b.cellCm||5);if(!e)return void this.host._showToast(this.host._t("radar.invalid"));y={radar:e}}}else c&&Object.prototype.hasOwnProperty.call(c,"radar")&&(y={radar:c.radar});this.host._markerDialog={...t,busy:!0};let $=null,w=!1;try{const c="virtual"===t.binding?[]:n.filter(e=>e.removed&&e.binding===t.binding).map(t=>t.id),d=c.length>0,u=x(t.binding,t.controls,this.host._bindingEntities(t.binding)),f=n.find(t=>t.id===r||t.id===l)?.vacuum||null,k={id:r,vacuum:f,...y,binding:t.binding,name:t.name.trim()||null,icon:t.icon||null,display:"badge"!==t.display?t.display:null,ripple_color:"icon_ripple"===t.display&&t.rippleColor?t.rippleColor:null,ripple_size:"icon_ripple"===t.display&&1.5!==t.rippleSize?t.rippleSize:null,size:1!==t.size?t.size:null,angle:t.angle?t.angle:null,...this._markerTapActionFields(t),...this._markerToggleEntityFields(t),tap_target:"run"===e&&t.tapTarget||null,tap_confirm:!!t.tapConfirm||null,controls:u.length?u:null,...this._markerLightFields(t),...this._markerValueBadgeFields(t),...this._markerValueSourceFields(t),use_climate_temp:!!t.useClimateTemp||null,glow_radius_cm:(()=>{const e=kt(t.glowRadius);return null==e||e<=0?null:Math.round(this.host._imperial?30.48*e:100*e)})(),model:t.model.trim()||null,link:t.link.trim()||null,description:t.description.trim()||null,pdfs:t.pdfs,hidden:!!t.hideFromPlan};p&&(k.space=_,k.area=g,k.room_id=m);const M=h?.marker?.room_id??null,C=t.roomTouched&&null!=h&&(h.space!==_||h.area!==g||M!==m);let S=!1;const P=t.uploadId||l;if(P&&P!==r&&k.pdfs?.length)try{const t=await this.host.hass.callWS({type:"houseplan/files/migrate",from_id:P,to_id:r}),e=t?.mapping||{};k.pdfs=ni(k.pdfs,P,r,e),S=Object.keys(e).length>0}catch(t){this.host._showToast(this.host._t("toast.files_migrate_failed",{err:this.host._errText(t)}))}a.markers=n,l&&l!==r&&(a.markers=ri(a.markers,l,r)),l&&l!==r&&"derived_marker_state"===k.value_badge?.source?.kind&&k.value_badge.source.ref===`marker:${l}`&&(k.value_badge.source={kind:"derived_marker_state",ref:`marker:${r}`}),l&&l!==r&&"derived_marker_state"===k.value_source?.kind&&k.value_source.ref===`marker:${l}`&&(k.value_source={kind:"derived_marker_state",ref:`marker:${r}`}),a.markers=a.markers.filter(t=>t.id!==r&&t.id!==l&&("virtual"===k.binding||t.binding!==k.binding)),a.markers.push(k);const D=new Set(c);l&&l!==r&&D.add(l),D.delete(r),D.size&&a.settings?.marker_area_snapshot&&(a.settings={...a.settings,marker_area_snapshot:li(a.settings.marker_area_snapshot,D)});let I=null;const L=l?this.host._layout[l]:null,T=L?{s:L.s||h?.space||this.host._space,x:L.x,y:L.y}:l&&h&&this.host._defPos[l]?this.host._normPos(h.space,this.host._defPos[l].x,this.host._defPos[l].y):null;if(!d&&T&&T.s===v)r===l&&this.host._layout[r]&&!C||(I={s:T.s,x:T.x,y:T.y});else if(d||!this.host._layout[r]||C){let t=b.vb[0]+b.vb[2]/2,e=b.vb[1]+b.vb[3]/2;const s=m?b.rooms.find(t=>t.id===m):g?b.rooms.find(t=>t.area===g):void 0;s&&([t,e]=this.host._roomCenter(s)),I=this.host._normPos(v,t,e)}if(this.host._serverCfg!==s||this.host._cfgRev!==i||yt(s)!==o)return this.host._markerDialog&&(this.host._markerDialog={...this.host._markerDialog,busy:!1}),void this.host._showToast(this.host._t("toast.conflict"));if(a=this._prepareConfigCandidate(a),$=this.host._adoption.beginOptimistic(s,a),this.host._serverCfg=a,this.host._regSignature="",this.host._maybeRebuildDevices(),this.host.requestUpdate(),this.host._saveConfigDebounced.pending()&&this.host._saveConfigDebounced.cancel(),await this._saveConfigNow($),w=!0,I){const t=hi(I);this.host._layout={...this.host._layout,[r]:t},this.host._noteLayoutRev(await this.host.hass.callWS({type:"houseplan/layout/update",device_id:r,pos:t}))}const R=new Set(c);l&&l!==r&&R.add(l),R.delete(r);for(const t of R)delete this.host._layout[t],await this.host.hass.callWS({type:"houseplan/layout/delete",device_id:t}).then(t=>this.host._noteLayoutRev(t)).catch(()=>{});S&&P&&await this.host.hass.callWS({type:"houseplan/files/cleanup",marker_id:P}).catch(()=>{}),this._closeMarkerDialog(),this.host._cancelDeviceDrag(),this.host._devicePositionHistory.clear(),this.host._regSignature="",this.host._maybeRebuildDevices(),this.host._showToast(this.host._t("toast.marker_saved"))}catch(t){!w&&$&&(this.host._rollbackOptimistic($),this.host._regSignature="",this.host._maybeRebuildDevices(),this.host.requestUpdate()),this.host._markerDialog&&(this.host._markerDialog={...this.host._markerDialog,busy:!1}),this.host._showToast(this.host._t("toast.error",{err:this.host._errText(t)}))}}async _deleteMarker(){const t=this.host._markerDialog;if(!t||t.busy||!t.devId)return;const e=t.devId?this.host._devices.find(e=>e.id===t.devId):null,s=this.host._markers.find(e=>e.id===t.devId);if(!e&&!s)return;const i=e?"virtual"===e.bindingKind?"virtual":e.bindingKind&&e.bindingRef?`${e.bindingKind}:${e.bindingRef}`:"":s.binding;if(!i)return;const o=t.name||this.host._t("device.fallback"),a=t.devId,n=await this.host._confirmDanger({key:"remove-marker",kind:"destructive",title:this.host._t("confirm.remove_marker_title"),message:this.host._t("confirm.remove_marker_body"),objectName:o,confirmLabel:this.host._t("btn.delete"),cancelLabel:this.host._t("btn.cancel")}),r=this.host._markerDialog;if(!n||!r||r.busy||r.devId!==a)return;const l=this.host._devices.find(t=>t.id===a),h=this.host._markers.find(t=>t.id===a);if(!l&&!h)return;const c=this.host._serverCfg;if(!c)return;c.markers=c.markers||[];const d=c.markers,p=l?"virtual"===l.bindingKind?"virtual":l.bindingKind&&l.bindingRef?`${l.bindingKind}:${l.bindingRef}`:"":h.binding;if(!p||p!==i)return;const u=ci(c.markers,a,p,"virtual"===p);c.markers=di(u.markers,u.cleanupIds);const _=u.cleanupIds;_.size&&c.settings?.marker_area_snapshot&&(c.settings={...c.settings,marker_area_snapshot:li(c.settings.marker_area_snapshot,_)}),this.host._markerDialog={...r,busy:!0};try{await this._saveConfigNow();for(const t of _){delete this.host._layout[t],delete this.host._defPos[t],this.host._dirtyPos.delete(t),this.host._sentPos.delete(t);const e=this.host._activityRt.get(t);e&&clearTimeout(e.timer),this.host._activityRt.delete(t),this.host._vacRt.delete(t),delete this.host._vacSrvTrails[t],await this.host.hass.callWS({type:"houseplan/layout/delete",device_id:t}).then(t=>this.host._noteLayoutRev(t)).catch(()=>{}),await this.host.hass.callWS({type:"houseplan/files/cleanup",marker_id:t}).catch(()=>{}),await this.host.hass.callWS({type:"houseplan/trail/delete",marker_id:t}).catch(()=>{})}this.host._deviceInboxReturn&&(this.host._deviceInboxReturn={...this.host._deviceInboxReturn,tab:"readd",anchor:p}),this._closeMarkerDialog(),this.host._cancelDeviceDrag(),this.host._devicePositionHistory.clear(),this.host._infoCard?.id===a&&this.host._closeInfoCard(),this.host._selId===a&&(this.host._selId=null),this.host._drag?.id===a&&(this.host._drag=null),this.host._regSignature="",this.host._maybeRebuildDevices(),this.host._showToast(this.host._t("toast.marker_removed"))}catch(t){this.host._serverCfg===c&&(c.markers=d),this.host._markerDialog&&(this.host._markerDialog={...this.host._markerDialog,busy:!1}),this.host._showToast(this.host._t("toast.error",{err:this.host._errText(t)}))}}_openSpaceDialog(t,e){if(this.host._serverStorage&&this.host._serverCfg)if("edit"===t){const s=this.host._serverCfg.spaces.find(t=>t.id===e);if(!s)return;const i=_(s),o=s.settings?.custom_fill&&"object"==typeof s.settings.custom_fill?pi(s.settings.custom_fill):null,a="none"===i.fill?{...o||St,a:0}:o;this.host._spaceDialog={mode:t,spaceId:e,title:s.title,planUrl:s.plan_url||null,planFile:null,source:s.plan_url?"file":"draw",showBorders:i.showBorders,showNames:i.showNames,zeroWallStyle:ui(s),displayTouched:!0,hideDecor:i.hideDecor,hideOpenings:i.hideOpenings,roomColor:i.color,roomOpacity:i.opacity,fillMode:"none"===i.fill?"custom":i.fill,customFill:a,glowEnabled:i.glow,bgColor:i.bgColor,bgMode:"static"===s.settings?.bg_mode||"daynight"===s.settings?.bg_mode?s.settings.bg_mode:null,northDeg:It({},s.settings),sunRays:"boolean"==typeof s.settings?.sun_rays?s.settings.sun_rays:null,tempMin:i.tempMin,tempMax:i.tempMax,showLqi:i.showLqi??this.host._config?.show_signal??!0,cardFontScale:i.cardFontScale,labelTemp:i.labelTemp,labelHum:i.labelHum,labelLqi:i.labelLqi,labelLight:i.labelLight,cellCm:Number(s.cell_cm)>0?Number(s.cell_cm):5,cellCmInput:wt(Number(s.cell_cm)>0?Number(s.cell_cm):5,this.host._imperial),cellCmTouched:!1,busy:!1}}else this.host._spaceDialog={mode:t,title:"",planUrl:null,planFile:null,...vi(),hideDecor:!1,hideOpenings:!1,zeroWallStyle:"dashed",roomColor:fi,roomOpacity:mi,fillMode:"custom",customFill:{...St,a:0},glowEnabled:!0,bgColor:null,bgMode:"daynight",northDeg:null,sunRays:null,tempMin:gi,tempMax:_i,showLqi:this.host._config?.show_signal??!0,cardFontScale:1,labelTemp:!1,labelHum:!1,labelLqi:!1,labelLight:!1,cellCm:bi(this.host._imperial),cellCmInput:wt(bi(this.host._imperial),this.host._imperial),cellCmTouched:!1,busy:!1};else this.host._showToast(this.host._t("toast.integration_missing"))}async _pickPlanFile(t){const e=t.target,s=e.files?.[0];if(!s||!this.host._spaceDialog)return;e.value="",this._decorAssetGuardReplace=null;const i=await xo(s);if("reject"===i.kind)return void this.host._showToast(this.host._t("toast.plan_formats"));if("guard"===i.kind)return void(this.host._backdropGuard=i.state);const o=await Mo(s,i.ext,s.name);this.host._spaceDialog&&(this.host._spaceDialog={...this.host._spaceDialog,planFile:o})}_renderBackdropGuard(){const t=this._decorAssetGuardReplace;return null!==t?Co(this.host,()=>{},()=>{this.host._backdropGuard=null,this._decorAssetGuardReplace=null},this.host.hass,(e,s)=>this._uploadDecorImage(e,s,t),(this.host._backdropGuard?.file.size||0)<=2097152)??d:Co(this.host,t=>{this.host._spaceDialog&&(this.host._spaceDialog={...this.host._spaceDialog,planFile:t})},()=>{this.host._backdropGuard=null},this.host.hass)??d}_useServerPlan(t){const e=this.host._spaceDialog;e&&(this.host._spaceDialog={...e,planUrl:t,planFile:null,pickSaved:!1,savedAspect:void 0},this.host._aspectJob=this._readPlanAspect(t))}async _readPlanAspect(t){for(let e=0;e<40;e++){const e=this.host._display(t);if(e){const s=await new Promise(t=>{const s=new Image;s.onload=()=>t(s.naturalWidth&&s.naturalHeight?s.naturalWidth/s.naturalHeight:0),s.onerror=()=>t(0),s.src=e}),i=this.host._spaceDialog;return i&&i.planUrl===t&&Number.isFinite(s)&&s>0?(this.host._spaceDialog={...i,savedAspect:s},s):0}if(await new Promise(t=>setTimeout(t,150)),this.host._spaceDialog?.planUrl!==t)return 0}return 0}async _deleteServerPlan(t){const e=this.host._spaceDialog,s=e?.saved?.find(e=>e.name===t);if(!e||!s||s.used_by.length||s.url===e.planUrl)return;const i=await this.host._confirmDanger({key:"delete-plan",kind:"destructive",title:this.host._t("confirm.delete_plan_title"),message:this.host._t("confirm.delete_plan_body"),objectName:t,confirmLabel:this.host._t("btn.delete"),cancelLabel:this.host._t("btn.cancel")}),o=this.host._spaceDialog,a=o?.saved?.find(e=>e.name===t);if(i&&o&&a&&a.url===s.url&&a.modified===s.modified&&!a.used_by.length&&a.url!==o.planUrl)try{await this.host.hass.callWS({type:"houseplan/plans/delete",name:t});const e=this.host._spaceDialog;e?.saved&&(this.host._spaceDialog={...e,saved:e.saved.filter(e=>e.name!==t)})}catch(t){this.host._showToast(this.host._t("toast.plan_delete_failed",{err:this.host._errText(t)}))}}_renderServerPlans(t){if(t.savedBusy)return p`
    ${this.host._t("space.loading")}
    `;const e=t.saved||[];if(!e.length)return p`
    ${this.host._t("space.no_saved")}
    `;return p`
    ${e.map(e=>{return p`
    @@ -1858,7 +1845,7 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db
    `;var s})} -
    `}async _saveSpaceDialog(){const t=this.host._spaceDialog;if(!t||t.busy||!t.title.trim())return;if("file"===t.source&&!t.planFile&&!t.planUrl)return void this.host._showToast(this.host._t("toast.plan_required"));const e="create"===t.mode&&0===(this.host._serverCfg?.spaces.length||0);this.host._spaceDialog={...t,busy:!0};try{const s="create"===t.mode?"s"+Date.now().toString(36):t.spaceId;let i=null;if("file"===t.source&&t.planFile){i={url:(await this.host.hass.callWS({type:"houseplan/plan/set",space_id:s,ext:t.planFile.ext,data:t.planFile.b64})).url,aspect:t.planFile.aspect}}let o=t.savedAspect||null;!i&&"file"===t.source&&t.planUrl&&!o&&this.host._aspectJob&&(o=await this.host._aspectJob||null);const a=this.host._serverCfg;let n;if("create"===t.mode)n=yi(s,t.title.trim()),a.spaces.push(n);else{if(n=a.spaces.find(t=>t.id===s),!n)throw new Error("space "+s+" is gone from the config");n.title=t.title.trim()}i?(n.plan_url=i.url,n.plan_aspect=i.aspect):"file"===t.source&&t.planUrl&&t.planUrl!==n.plan_url&&(n.plan_url=t.planUrl,n.plan_aspect=o),"draw"===t.source&&(n.plan_url=null,n.plan_aspect=null,delete n.plan_x,delete n.plan_y,delete n.plan_scale,delete n.plan_scale_x,delete n.plan_scale_y,delete n.plan_angle),n.settings={...n.settings||{},show_borders:t.showBorders,show_names:t.showNames,hide_decor:t.hideDecor||void 0,hide_openings:t.hideOpenings||void 0,room_color:t.roomColor,room_opacity:t.roomOpacity,bg_color:t.bgColor||void 0,bg_mode:t.bgMode||void 0,north_deg:t.northDeg??void 0,sun_rays:t.sunRays??void 0,fill_mode:t.fillMode,custom_fill:t.customFill||void 0,glow_enabled:t.glowEnabled,temp_min:Number.isFinite(t.tempMin)?Math.min(t.tempMin,t.tempMax):gi,temp_max:Number.isFinite(t.tempMax)?Math.max(t.tempMin,t.tempMax):_i,show_lqi:t.showLqi,card_font_scale:1!==t.cardFontScale?t.cardFontScale:void 0,label_temp:t.labelTemp,label_hum:t.labelHum,label_lqi:t.labelLqi,label_light:t.labelLight},n.zero_wall_style=t.zeroWallStyle,n.cell_cm=Number.isFinite(t.cellCm)&&t.cellCm>0?Math.max(.1,Math.min(tr,t.cellCm)):5,await this._saveConfigNow(),this.host._spaceDialog=null,"create"===t.mode&&this.host._commitSpace(n.id),this.host._regSignature="",this.host._maybeRebuildDevices(),this.host._importQueue.length?this._openNextImport():e||this.host._importTotal>0?(this.host._importTotal=0,this.host._commitSpace(this.host._serverCfg.spaces[0]?.id||this.host._space),this._setMode("plan"),this.host._tool="draw",this.host._path=[],this.host._cursorPt=null,this._primeDrawWallField(),this.host._showToast(this.host._t(e&&!this.host._importTotal?"toast.space_added_onboard":"import.done"))):(this.host._showToast("create"===t.mode?this.host._t("toast.space_added"):this.host._t("toast.space_saved")),"create"===t.mode&&("plan"!==this.host._mode?this._setMode("plan"):(this.host._tool="draw",this.host._path=[],this.host._cursorPt=null,this._primeDrawWallField(),this.host._saveNav())))}catch(t){"conflict"!==t?.code&&await this.host._reloadConfigOnly(!0),this.host._spaceDialog&&(this.host._spaceDialog={...this.host._spaceDialog,busy:!1}),this.host._showToast(this.host._t("toast.error",{err:this.host._errText(t)}))}}async _deleteSpace(){const t=this.host._spaceDialog;if(!t||"edit"!==t.mode)return;const e=this.host._serverCfg;if(!e)return;const s=e.spaces.find(e=>e.id===t.spaceId),i=So(e,this.host._layout||{},t.spaceId||""),o=1===e.spaces.length&&e.spaces[0]?.id===t.spaceId;if(i.count&&!o)return void(this.host._spaceDialog={...t,deleteBlockers:i.count});if(!s)return;const a=t.spaceId,n=await this.host._confirmDanger({key:"delete-space",kind:"destructive",title:this.host._t("confirm.delete_space_title"),message:Po(this.host._t("confirm.delete_space_body"),this.host._t("confirm.delete_space_vac_routes"),i.routeCount),objectName:s.title,confirmLabel:this.host._t("btn.delete"),cancelLabel:this.host._t("btn.cancel")}),r=this.host._spaceDialog,l=this.host._serverCfg;if(!n||!r||"edit"!==r.mode||r.busy||r.spaceId!==a||!l)return;if(!l.spaces.find(t=>t.id===a))return;const h=So(l,this.host._layout||{},a),c=1===l.spaces.length&&l.spaces[0]?.id===a;if(!h.count||c){this.host._spaceDialog={...r,deleteBlockers:0,busy:!0};try{this.host._saveConfigDebounced.pending()&&this.host._saveConfigDebounced.flush(),this.host._persistLayout.pending()&&this.host._persistLayout.flush(),await this.host._writeChain,await this.host.hass.callWS({type:"houseplan/space/delete",space_id:a,expected_config_rev:this.host._cfgRev,expected_layout_rev:this.host._layoutRev});const[t,e]=await Promise.all([this.host._getAuthoritativeConfig(),this.host.hass.callWS({type:"houseplan/layout/get"})]);if("adopted"!==(await this.host._adoptAuthoritative({cfgResp:t,layResp:e,reason:"space-delete",profile:"post-write"})).status)return this.host._spaceDialog={...r,busy:!1},void this.host.requestUpdate();this.host._spaceDialog=null,this.host._space===a&&this.host._commitSpace(this.host._serverCfg.spaces[0]?.id||""),this.host._regSignature="",this.host._maybeRebuildDevices(),this.host._showToast(this.host._t("toast.space_deleted"))}catch(t){"conflict"!==t?.code&&"space_in_use"!==t?.code||await Promise.all([this.host._reloadConfigOnly(!0),this.host._reloadLayoutOnly()]);const e=this.host._serverCfg;if(this.host._spaceDialog&&e){const t=So(e,this.host._layout||{},a),s=1===e.spaces.length&&e.spaces[0]?.id===a;this.host._spaceDialog={...this.host._spaceDialog,busy:!1,deleteBlockers:s?0:t.count}}this.host._showToast(this.host._t("toast.delete_failed",{err:this.host._errText(t)}))}}else this.host._spaceDialog={...r,deleteBlockers:h.count}}async _saveConfigNow(t=null){this.host._cfgEpoch++;try{await this._writeConfig(t)}catch(t){throw t?.physicalGeometryRolledBack?await this._reloadRejectedPhysicalWrite():"conflict"===t?.code&&await this.host._reloadConfigOnly(),t}}_saveSpaceCopy(){return Qn(this.host,{clearGeometryGesture:()=>this._clearGeometryGesture(),optimizeReferenceContext:()=>this._optimizeReferenceContext(!1),reportPreflightFailure:(t,e)=>this._reportPreflightFailure(t,e),saveConfigNow:t=>this._saveConfigNow(t),setMode:()=>this._setMode("plan"),showWallModelMigrationBlocked:t=>this._showWallModelMigrationBlocked(t)})}_startImport(){const t=this.host._importDialog;if(!t)return;const e=t.floors.filter(t=>t.checked).map(t=>t.name);this.host._importDialog=null,e.length?(this.host._importQueue=e,this.host._importTotal=e.length,this._openNextImport()):this._openSpaceDialog("create")}_openNextImport(){const t=this.host._importQueue.shift();void 0!==t&&(this.host._spaceDialog={mode:"create",title:t,planUrl:null,planFile:null,...vi(),hideDecor:!1,hideOpenings:!1,zeroWallStyle:"dashed",roomColor:fi,roomOpacity:mi,fillMode:"custom",customFill:null,glowEnabled:!0,bgColor:null,bgMode:"daynight",northDeg:null,sunRays:null,tempMin:gi,tempMax:_i,showLqi:this.host._config?.show_signal??!0,cardFontScale:1,labelTemp:!1,labelHum:!1,labelLqi:!1,labelLight:!1,cellCm:bi(this.host._imperial),cellCmInput:wt(bi(this.host._imperial),this.host._imperial),cellCmTouched:!1,busy:!1})}_skipImport(){this.host._spaceDialog=null,this.host._importQueue.length?this._openNextImport():this.host._importTotal>0&&this.host._model.length&&(this.host._importTotal=0,this.host._commitSpace(this.host._serverCfg.spaces[0]?.id||this.host._space),this._setMode("plan"),this.host._showToast(this.host._t("import.done")))}_renderImportDialog(){const t=this.host._importDialog,e=t.floors.filter(t=>t.checked).length;return p``}async _saveSpaceDialog(){const t=this.host._spaceDialog;if(!t||t.busy||!t.title.trim())return;if("file"===t.source&&!t.planFile&&!t.planUrl)return void this.host._showToast(this.host._t("toast.plan_required"));const e="create"===t.mode&&0===(this.host._serverCfg?.spaces.length||0);this.host._spaceDialog={...t,busy:!0};try{const s="create"===t.mode?"s"+Date.now().toString(36):t.spaceId;let i=null;if("file"===t.source&&t.planFile){i={url:(await this.host.hass.callWS({type:"houseplan/plan/set",space_id:s,ext:t.planFile.ext,data:t.planFile.b64})).url,aspect:t.planFile.aspect}}let o=t.savedAspect||null;!i&&"file"===t.source&&t.planUrl&&!o&&this.host._aspectJob&&(o=await this.host._aspectJob||null);const a=this.host._serverCfg;let n;if("create"===t.mode)n=yi(s,t.title.trim()),a.spaces.push(n);else{if(n=a.spaces.find(t=>t.id===s),!n)throw new Error("space "+s+" is gone from the config");n.title=t.title.trim()}i?(n.plan_url=i.url,n.plan_aspect=i.aspect):"file"===t.source&&t.planUrl&&t.planUrl!==n.plan_url&&(n.plan_url=t.planUrl,n.plan_aspect=o),"draw"===t.source&&(n.plan_url=null,n.plan_aspect=null,delete n.plan_x,delete n.plan_y,delete n.plan_scale,delete n.plan_scale_x,delete n.plan_scale_y,delete n.plan_angle),n.settings={...n.settings||{},show_borders:t.showBorders,show_names:t.showNames,hide_decor:t.hideDecor||void 0,hide_openings:t.hideOpenings||void 0,room_color:t.roomColor,room_opacity:t.roomOpacity,bg_color:t.bgColor||void 0,bg_mode:t.bgMode||void 0,north_deg:t.northDeg??void 0,sun_rays:t.sunRays??void 0,fill_mode:t.fillMode,custom_fill:t.customFill||void 0,glow_enabled:t.glowEnabled,temp_min:Number.isFinite(t.tempMin)?Math.min(t.tempMin,t.tempMax):gi,temp_max:Number.isFinite(t.tempMax)?Math.max(t.tempMin,t.tempMax):_i,show_lqi:t.showLqi,card_font_scale:1!==t.cardFontScale?t.cardFontScale:void 0,label_temp:t.labelTemp,label_hum:t.labelHum,label_lqi:t.labelLqi,label_light:t.labelLight},n.zero_wall_style=t.zeroWallStyle,n.cell_cm=Number.isFinite(t.cellCm)&&t.cellCm>0?Math.max(.1,Math.min(er,t.cellCm)):5,await this._saveConfigNow(),this.host._spaceDialog=null,"create"===t.mode&&this.host._commitSpace(n.id),this.host._regSignature="",this.host._maybeRebuildDevices(),this.host._importQueue.length?this._openNextImport():e||this.host._importTotal>0?(this.host._importTotal=0,this.host._commitSpace(this.host._serverCfg.spaces[0]?.id||this.host._space),this._setMode("plan"),this.host._tool="draw",this.host._path=[],this.host._cursorPt=null,this._primeDrawWallField(),this.host._showToast(this.host._t(e&&!this.host._importTotal?"toast.space_added_onboard":"import.done"))):(this.host._showToast("create"===t.mode?this.host._t("toast.space_added"):this.host._t("toast.space_saved")),"create"===t.mode&&("plan"!==this.host._mode?this._setMode("plan"):(this.host._tool="draw",this.host._path=[],this.host._cursorPt=null,this._primeDrawWallField(),this.host._saveNav())))}catch(t){"conflict"!==t?.code&&await this.host._reloadConfigOnly(!0),this.host._spaceDialog&&(this.host._spaceDialog={...this.host._spaceDialog,busy:!1}),this.host._showToast(this.host._t("toast.error",{err:this.host._errText(t)}))}}async _deleteSpace(){const t=this.host._spaceDialog;if(!t||"edit"!==t.mode)return;const e=this.host._serverCfg;if(!e)return;const s=e.spaces.find(e=>e.id===t.spaceId),i=So(e,this.host._layout||{},t.spaceId||""),o=1===e.spaces.length&&e.spaces[0]?.id===t.spaceId;if(i.count&&!o)return void(this.host._spaceDialog={...t,deleteBlockers:i.count});if(!s)return;const a=t.spaceId,n=await this.host._confirmDanger({key:"delete-space",kind:"destructive",title:this.host._t("confirm.delete_space_title"),message:Po(this.host._t("confirm.delete_space_body"),this.host._t("confirm.delete_space_vac_routes"),i.routeCount),objectName:s.title,confirmLabel:this.host._t("btn.delete"),cancelLabel:this.host._t("btn.cancel")}),r=this.host._spaceDialog,l=this.host._serverCfg;if(!n||!r||"edit"!==r.mode||r.busy||r.spaceId!==a||!l)return;if(!l.spaces.find(t=>t.id===a))return;const h=So(l,this.host._layout||{},a),c=1===l.spaces.length&&l.spaces[0]?.id===a;if(!h.count||c){this.host._spaceDialog={...r,deleteBlockers:0,busy:!0};try{this.host._saveConfigDebounced.pending()&&this.host._saveConfigDebounced.flush(),this.host._persistLayout.pending()&&this.host._persistLayout.flush(),await this.host._writeChain,await this.host.hass.callWS({type:"houseplan/space/delete",space_id:a,expected_config_rev:this.host._cfgRev,expected_layout_rev:this.host._layoutRev});const[t,e]=await Promise.all([this.host._getAuthoritativeConfig(),this.host.hass.callWS({type:"houseplan/layout/get"})]);if("adopted"!==(await this.host._adoptAuthoritative({cfgResp:t,layResp:e,reason:"space-delete",profile:"post-write"})).status)return this.host._spaceDialog={...r,busy:!1},void this.host.requestUpdate();this.host._spaceDialog=null,this.host._space===a&&this.host._commitSpace(this.host._serverCfg.spaces[0]?.id||""),this.host._regSignature="",this.host._maybeRebuildDevices(),this.host._showToast(this.host._t("toast.space_deleted"))}catch(t){"conflict"!==t?.code&&"space_in_use"!==t?.code||await Promise.all([this.host._reloadConfigOnly(!0),this.host._reloadLayoutOnly()]);const e=this.host._serverCfg;if(this.host._spaceDialog&&e){const t=So(e,this.host._layout||{},a),s=1===e.spaces.length&&e.spaces[0]?.id===a;this.host._spaceDialog={...this.host._spaceDialog,busy:!1,deleteBlockers:s?0:t.count}}this.host._showToast(this.host._t("toast.delete_failed",{err:this.host._errText(t)}))}}else this.host._spaceDialog={...r,deleteBlockers:h.count}}async _saveConfigNow(t=null){this.host._cfgEpoch++;try{await this._writeConfig(t)}catch(t){throw t?.physicalGeometryRolledBack?await this._reloadRejectedPhysicalWrite():"conflict"===t?.code&&await this.host._reloadConfigOnly(),t}}_saveSpaceCopy(){return tr(this.host,{clearGeometryGesture:()=>this._clearGeometryGesture(),optimizeReferenceContext:()=>this._optimizeReferenceContext(!1),reportPreflightFailure:(t,e)=>this._reportPreflightFailure(t,e),saveConfigNow:t=>this._saveConfigNow(t),setMode:()=>this._setMode("plan"),showWallModelMigrationBlocked:t=>this._showWallModelMigrationBlocked(t)})}_startImport(){const t=this.host._importDialog;if(!t)return;const e=t.floors.filter(t=>t.checked).map(t=>t.name);this.host._importDialog=null,e.length?(this.host._importQueue=e,this.host._importTotal=e.length,this._openNextImport()):this._openSpaceDialog("create")}_openNextImport(){const t=this.host._importQueue.shift();void 0!==t&&(this.host._spaceDialog={mode:"create",title:t,planUrl:null,planFile:null,...vi(),hideDecor:!1,hideOpenings:!1,zeroWallStyle:"dashed",roomColor:fi,roomOpacity:mi,fillMode:"custom",customFill:null,glowEnabled:!0,bgColor:null,bgMode:"daynight",northDeg:null,sunRays:null,tempMin:gi,tempMax:_i,showLqi:this.host._config?.show_signal??!0,cardFontScale:1,labelTemp:!1,labelHum:!1,labelLqi:!1,labelLight:!1,cellCm:bi(this.host._imperial),cellCmInput:wt(bi(this.host._imperial),this.host._imperial),cellCmTouched:!1,busy:!1})}_skipImport(){this.host._spaceDialog=null,this.host._importQueue.length?this._openNextImport():this.host._importTotal>0&&this.host._model.length&&(this.host._importTotal=0,this.host._commitSpace(this.host._serverCfg.spaces[0]?.id||this.host._space),this._setMode("plan"),this.host._showToast(this.host._t("import.done")))}_renderImportDialog(){const t=this.host._importDialog,e=t.floors.filter(t=>t.checked).length;return p`this.host._importDialog=null}>
    ${this.host._t("import.hint")}
    @@ -1878,13 +1865,13 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db ${this.host._t("import.start",{n:e})}
    -
    `}_supportPatch(t,e){const s=this.host._supportDialog;if(!s||s.draftId!==t)return null;const i={...s,...e};return this.host._supportDialog=i,i}async _focusSupport(t){await this.host.updateComplete,this.host.renderRoot.querySelector(t)?.focus({preventScroll:!0})}_updateSupportDraft(t,e){const s=this.host._supportDialog;if(!s||"building"===s.status||"sending"===s.status||"success"===s.status)return;const i={...s,[t]:e},o=Kc({...i,attach:!1,preview:null});"message_required"===o&&"validation.message_required"===s.errorCode||"message_too_long"===o||"contact_too_long"===o?this._supportPatch(s.draftId,{[t]:e,status:"error",errorCode:`validation.${o}`}):i.attach&&i.preview&&i.preview.expiresAt<=Date.now()?this._supportPatch(s.draftId,{[t]:e,status:"error",errorCode:"support_preview_expired"}):this._supportPatch(s.draftId,{[t]:e,status:i.attach&&i.preview?"ready":"idle",errorCode:""})}async _discardSupportPreview(t){if(t)try{await this.host.hass.callWS({type:"houseplan/support/preview/discard",token:t})}catch{}}async _closeSupportDialog(){const t=this.host._supportDialog;if(t){if("building"===t.status||"sending"===t.status){const t=l(this.host.hass,this.host._config?.language);if(!await this.host._confirmDanger({key:"close-support-busy",kind:"warning",title:Oo(t,"support.close_busy_title"),message:Oo(t,"support.close_busy_body"),confirmLabel:this.host._t("btn.close"),cancelLabel:this.host._t("btn.cancel")}))return await this.host.updateComplete,void this.host.renderRoot.querySelector("#support-dialog")?.rejectClose()}clearTimeout(this._supportExpiryTimer),this._supportExpiryTimer=void 0,this.host._supportDialog=null,t.preview?.token&&"success"!==t.status&&this._discardSupportPreview(t.preview.token)}}_scheduleSupportExpiry(t,e){clearTimeout(this._supportExpiryTimer);const s=Math.max(0,e.expiresAt-Date.now());this._supportExpiryTimer=window.setTimeout(()=>{const s=this.host._supportDialog;s&&s.draftId===t&&s.preview?.token===e.token&&s.attach&&"success"!==s.status&&"sending"!==s.status&&this._supportPatch(t,{status:"error",errorCode:"support_preview_expired"})},Math.min(s+20,2147483647))}_supportFacts(){const t=this.host._haRegistry;return Jc({userAgent:globalThis.navigator?.userAgent||"",language:l(this.host.hass,this.host._config?.language),registryAccess:t.access,registryLastSuccess:t.lastSuccess})}_supportPreviewRequestIsCurrent(t,e){const s=this.host._supportDialog;return e===this._supportPreviewGeneration&&s?.draftId===t&&s.attach}async _buildSupportPreview(t){const e=this.host._supportDialog;if(!e||e.draftId!==t||!e.attach||!jc(this.host._haSupportApi))return;const s=++this._supportPreviewGeneration;this._supportPatch(t,{status:"building",errorCode:""});let i="";try{const e=await this.host.hass.callWS({type:"houseplan/support/preview",card_version:$i(vd),...this._supportFacts(),draft_id:t}),o=e&&"object"==typeof e?e:{},a=Date.now(),n="string"==typeof o.text?o.text:"",r=Number(o.size),l=Number(o.expires_in),h=Number(o.spaces),c=String(o.token||"");/^[0-9a-f]{48}$/.test(c)&&(i=c);const d=String(o.sha256||""),p=Number(o.version),u=String(o.format||""),_=(new TextEncoder).encode(n).byteLength;if(!/^[0-9a-f]{48}$/.test(c)||!/^[0-9a-f]{64}$/.test(d)||"houseplan-support-package"!==u||1!==p||!Number.isInteger(r)||r!==_||!Number.isInteger(h)||h<0||!Number.isFinite(l)||l<=0||l>600||!n.endsWith("\n"))throw{code:"support_rejected"};const g={token:c,expiresAt:a+1e3*l,size:r,sha256:d,spaces:h,format:u,version:p,text:n,preparedAt:a};if(!this._supportPreviewRequestIsCurrent(t,s))return i="",void this._discardSupportPreview(c);if(!this._supportPatch(t,{status:"ready",preview:g,errorCode:"",rawOpen:!1}))return i="",void this._discardSupportPreview(c);i="",this._scheduleSupportExpiry(t,g)}catch(e){if(i){const t=i;i="",this._discardSupportPreview(t)}if(!this._supportPreviewRequestIsCurrent(t,s))return;if(!this._supportPatch(t,{status:"error",errorCode:Zc(e)}))return;this._focusSupport("#support-error")}}async _setSupportAttachment(t){const e=this.host._supportDialog;if(!e||"sending"===e.status||"success"===e.status)return;const s=e.preview?.token||"";if(!t)return this._supportPreviewGeneration+=1,clearTimeout(this._supportExpiryTimer),this._supportExpiryTimer=void 0,this._supportPatch(e.draftId,{attach:!1,status:"idle",preview:null,rawOpen:!1,errorCode:""}),void(s&&this._discardSupportPreview(s));this._supportPatch(e.draftId,{attach:!0,errorCode:""}),await this._buildSupportPreview(e.draftId)}async _refreshSupportPreview(){const t=this.host._supportDialog;t&&t.attach&&"building"!==t.status&&"sending"!==t.status&&await this._buildSupportPreview(t.draftId)}_downloadSupportPreview(){const t=this.host._supportDialog?.preview;if(!t)return;const e=new Blob([t.text],{type:"application/json;charset=utf-8"}),s=URL.createObjectURL(e),i=document.createElement("a");i.href=s,i.download=`houseplan-support-${t.sha256.slice(0,12)}.json`,i.style.display="none",document.body.append(i),i.click(),i.remove(),window.setTimeout(()=>URL.revokeObjectURL(s),0)}async _copySupportText(t,e){const s=l(this.host.hass,this.host._config?.language);try{await navigator.clipboard.writeText(t),this.host._showToast(Oo(s,e))}catch{this.host._showToast(Oo(s,"support.copy_failed"))}}async _submitSupport(){const t=this.host._supportDialog;if(!t||!jc(this.host._haSupportApi))return;const e=Kc(t);if(e)return this._supportPatch(t.draftId,{status:"error",errorCode:`validation.${e}`}),void this._focusSupport("#support-message");if(!Vc(t))return;const s=qc(t),i=this._supportPatch(t.draftId,{status:"sending",errorCode:"",idempotencyKey:s.idempotencyKey,submissionFingerprint:s.fingerprint});if(i)try{const e=await this.host.hass.callWS({type:"houseplan/support/submit",message:i.message.trim(),contact:i.contact.trim(),...i.attach&&i.preview?{preview_token:i.preview.token}:{},idempotency_key:i.idempotencyKey}),s=e&&"object"==typeof e&&"report_id"in e?String(e.report_id||""):"";if(!/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(s))throw{code:"support_unavailable"};if(clearTimeout(this._supportExpiryTimer),this._supportExpiryTimer=void 0,!this._supportPatch(t.draftId,{status:"success",reportId:s,errorCode:""}))return;this._focusSupport("#support-receipt")}catch(e){if(!this._supportPatch(t.draftId,{status:"error",errorCode:Zc(e)}))return;this._focusSupport("#support-error")}}_supportErrorText(t){const e=l(this.host.hass,this.host._config?.language);if(t.errorCode.startsWith("validation.")){return Oo(e,`support.validation.${t.errorCode.slice(11)}`)}return Oo(e,`support.error.${t.errorCode||"support_unavailable"}`)}_supportMessageKeydown(t){"Enter"===t.key&&(t.ctrlKey||t.metaKey)&&(t.preventDefault(),this._submitSupport())}_renderSupportDialog(){const t=this.host._supportDialog,e=l(this.host.hass,this.host._config?.language),s="ru"===e?"https://github.com/Matysh/houseplan-card/blob/main/docs/USER-GUIDE.ru.md":"https://github.com/Matysh/houseplan-card/blob/main/docs/USER-GUIDE.md",i=jc(this.host._haSupportApi),o=(t,s)=>Oo(e,t,s),a="building"===t.status||"sending"===t.status,n=Kc(t),r=t.preview?Math.max(0,Math.floor((Date.now()-t.preview.preparedAt)/6e4)):0,h="error"===t.status&&!t.errorCode.startsWith("validation."),c="validation.contact_too_long"===t.errorCode,u="validation.message_required"===t.errorCode||"validation.message_too_long"===t.errorCode;return p``}_supportPatch(t,e){const s=this.host._supportDialog;if(!s||s.draftId!==t)return null;const i={...s,...e};return this.host._supportDialog=i,i}async _focusSupport(t){await this.host.updateComplete,this.host.renderRoot.querySelector(t)?.focus({preventScroll:!0})}_updateSupportDraft(t,e){const s=this.host._supportDialog;if(!s||"building"===s.status||"sending"===s.status||"success"===s.status)return;const i={...s,[t]:e},o=Vc({...i,attach:!1,preview:null});"message_required"===o&&"validation.message_required"===s.errorCode||"message_too_long"===o||"contact_too_long"===o?this._supportPatch(s.draftId,{[t]:e,status:"error",errorCode:`validation.${o}`}):i.attach&&i.preview&&i.preview.expiresAt<=Date.now()?this._supportPatch(s.draftId,{[t]:e,status:"error",errorCode:"support_preview_expired"}):this._supportPatch(s.draftId,{[t]:e,status:i.attach&&i.preview?"ready":"idle",errorCode:""})}async _discardSupportPreview(t){if(t)try{await this.host.hass.callWS({type:"houseplan/support/preview/discard",token:t})}catch{}}async _closeSupportDialog(){const t=this.host._supportDialog;if(t){if("building"===t.status||"sending"===t.status){const t=l(this.host.hass,this.host._config?.language);if(!await this.host._confirmDanger({key:"close-support-busy",kind:"warning",title:Oo(t,"support.close_busy_title"),message:Oo(t,"support.close_busy_body"),confirmLabel:this.host._t("btn.close"),cancelLabel:this.host._t("btn.cancel")}))return await this.host.updateComplete,void this.host.renderRoot.querySelector("#support-dialog")?.rejectClose()}clearTimeout(this._supportExpiryTimer),this._supportExpiryTimer=void 0,this.host._supportDialog=null,t.preview?.token&&"success"!==t.status&&this._discardSupportPreview(t.preview.token)}}_scheduleSupportExpiry(t,e){clearTimeout(this._supportExpiryTimer);const s=Math.max(0,e.expiresAt-Date.now());this._supportExpiryTimer=window.setTimeout(()=>{const s=this.host._supportDialog;s&&s.draftId===t&&s.preview?.token===e.token&&s.attach&&"success"!==s.status&&"sending"!==s.status&&this._supportPatch(t,{status:"error",errorCode:"support_preview_expired"})},Math.min(s+20,2147483647))}_supportFacts(){const t=this.host._haRegistry;return Zc({userAgent:globalThis.navigator?.userAgent||"",language:l(this.host.hass,this.host._config?.language),registryAccess:t.access,registryLastSuccess:t.lastSuccess})}_supportPreviewRequestIsCurrent(t,e){const s=this.host._supportDialog;return e===this._supportPreviewGeneration&&s?.draftId===t&&s.attach}async _buildSupportPreview(t){const e=this.host._supportDialog;if(!e||e.draftId!==t||!e.attach||!Gc(this.host._haSupportApi))return;const s=++this._supportPreviewGeneration;this._supportPatch(t,{status:"building",errorCode:""});let i="";try{const e=await this.host.hass.callWS({type:"houseplan/support/preview",card_version:$i(yd),...this._supportFacts(),draft_id:t}),o=e&&"object"==typeof e?e:{},a=Date.now(),n="string"==typeof o.text?o.text:"",r=Number(o.size),l=Number(o.expires_in),h=Number(o.spaces),c=String(o.token||"");/^[0-9a-f]{48}$/.test(c)&&(i=c);const d=String(o.sha256||""),p=Number(o.version),u=String(o.format||""),_=(new TextEncoder).encode(n).byteLength;if(!/^[0-9a-f]{48}$/.test(c)||!/^[0-9a-f]{64}$/.test(d)||"houseplan-support-package"!==u||1!==p||!Number.isInteger(r)||r!==_||!Number.isInteger(h)||h<0||!Number.isFinite(l)||l<=0||l>600||!n.endsWith("\n"))throw{code:"support_rejected"};const g={token:c,expiresAt:a+1e3*l,size:r,sha256:d,spaces:h,format:u,version:p,text:n,preparedAt:a};if(!this._supportPreviewRequestIsCurrent(t,s))return i="",void this._discardSupportPreview(c);if(!this._supportPatch(t,{status:"ready",preview:g,errorCode:"",rawOpen:!1}))return i="",void this._discardSupportPreview(c);i="",this._scheduleSupportExpiry(t,g)}catch(e){if(i){const t=i;i="",this._discardSupportPreview(t)}if(!this._supportPreviewRequestIsCurrent(t,s))return;if(!this._supportPatch(t,{status:"error",errorCode:Yc(e)}))return;this._focusSupport("#support-error")}}async _setSupportAttachment(t){const e=this.host._supportDialog;if(!e||"sending"===e.status||"success"===e.status)return;const s=e.preview?.token||"";if(!t)return this._supportPreviewGeneration+=1,clearTimeout(this._supportExpiryTimer),this._supportExpiryTimer=void 0,this._supportPatch(e.draftId,{attach:!1,status:"idle",preview:null,rawOpen:!1,errorCode:""}),void(s&&this._discardSupportPreview(s));this._supportPatch(e.draftId,{attach:!0,errorCode:""}),await this._buildSupportPreview(e.draftId)}async _refreshSupportPreview(){const t=this.host._supportDialog;t&&t.attach&&"building"!==t.status&&"sending"!==t.status&&await this._buildSupportPreview(t.draftId)}_downloadSupportPreview(){const t=this.host._supportDialog?.preview;if(!t)return;const e=new Blob([t.text],{type:"application/json;charset=utf-8"}),s=URL.createObjectURL(e),i=document.createElement("a");i.href=s,i.download=`houseplan-support-${t.sha256.slice(0,12)}.json`,i.style.display="none",document.body.append(i),i.click(),i.remove(),window.setTimeout(()=>URL.revokeObjectURL(s),0)}async _copySupportText(t,e){const s=l(this.host.hass,this.host._config?.language);try{await navigator.clipboard.writeText(t),this.host._showToast(Oo(s,e))}catch{this.host._showToast(Oo(s,"support.copy_failed"))}}async _submitSupport(){const t=this.host._supportDialog;if(!t||!Gc(this.host._haSupportApi))return;const e=Vc(t);if(e)return this._supportPatch(t.draftId,{status:"error",errorCode:`validation.${e}`}),void this._focusSupport("#support-message");if(!Jc(t))return;const s=Uc(t),i=this._supportPatch(t.draftId,{status:"sending",errorCode:"",idempotencyKey:s.idempotencyKey,submissionFingerprint:s.fingerprint});if(i)try{const e=await this.host.hass.callWS({type:"houseplan/support/submit",message:i.message.trim(),contact:i.contact.trim(),...i.attach&&i.preview?{preview_token:i.preview.token}:{},idempotency_key:i.idempotencyKey}),s=e&&"object"==typeof e&&"report_id"in e?String(e.report_id||""):"";if(!/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(s))throw{code:"support_unavailable"};if(clearTimeout(this._supportExpiryTimer),this._supportExpiryTimer=void 0,!this._supportPatch(t.draftId,{status:"success",reportId:s,errorCode:""}))return;this._focusSupport("#support-receipt")}catch(e){if(!this._supportPatch(t.draftId,{status:"error",errorCode:Yc(e)}))return;this._focusSupport("#support-error")}}_supportErrorText(t){const e=l(this.host.hass,this.host._config?.language);if(t.errorCode.startsWith("validation.")){return Oo(e,`support.validation.${t.errorCode.slice(11)}`)}return Oo(e,`support.error.${t.errorCode||"support_unavailable"}`)}_supportMessageKeydown(t){"Enter"===t.key&&(t.ctrlKey||t.metaKey)&&(t.preventDefault(),this._submitSupport())}_renderSupportDialog(){const t=this.host._supportDialog,e=l(this.host.hass,this.host._config?.language),s="ru"===e?"https://github.com/Matysh/houseplan-card/blob/main/docs/USER-GUIDE.ru.md":"https://github.com/Matysh/houseplan-card/blob/main/docs/USER-GUIDE.md",i=Gc(this.host._haSupportApi),o=(t,s)=>Oo(e,t,s),a="building"===t.status||"sending"===t.status,n=Vc(t),r=t.preview?Math.max(0,Math.floor((Date.now()-t.preview.preparedAt)/6e4)):0,h="error"===t.status&&!t.errorCode.startsWith("validation."),c="validation.contact_too_long"===t.errorCode,u="validation.message_required"===t.errorCode||"validation.message_too_long"===t.errorCode;return p`{this._closeSupportDialog()}}>

    ${o("support.about_group")}

    -
    ${this.host._t("gs.about_version",{v:$i(vd)})}
    +
    ${this.host._t("gs.about_version",{v:$i(yd)})}
    - `;var _}_preflightDiagnostics(t,e){const s=new Map((e?.spaces||[]).map(t=>[String(t?.id||""),t]));return{kind:"houseplan-optimize-preflight",origin:"runtime",cardVersion:$i(vd),checkedAt:(new Date).toISOString(),preflightFingerprint:t.fingerprint,failures:t.failures.map(t=>({spaceId:t.spaceId,displayName:t.displayName,reason:t.reason,detail:t.detail??null,spaceGeometryFingerprint:s.has(t.spaceId)?ne(s.get(t.spaceId)):null}))}}_reportPreflightFailure(t,e){t.ok||t.fingerprint===this.host._reportedPreflightFingerprint||(this.host._reportedPreflightFingerprint=t.fingerprint,console.warn("[houseplan] optimize preflight failed",this._preflightDiagnostics(t,e)))}_preflightVersionsDiffer(){const t=this.host._haIntegrationVersion;return"string"==typeof t&&t.length>0&&t!==$i(vd)}async _copyPreflightDiagnostics(){const t=this.host._alignDialog?.preflight;if(!t||t.ok)return;const e=JSON.stringify(this._preflightDiagnostics(t,this.host._alignDialog?.config??null),null,2);try{await navigator.clipboard.writeText(e),this.host._preflightClipboardFallback=null,this.host._showToast(this.host._t("gs.preflight_copied"))}catch{this.host._preflightClipboardFallback=e}}_checkOptimizeGeometryImpl(t){return wi(t,{fallbackSpaceName:t=>this.host._t("gs.align_preflight_space",{n:String(t)})})}_checkSpacePhysicalGeometryImpl(t,e,s){return ki(t,e,{fallbackSpaceName:t=>this.host._t("gs.align_preflight_space",{n:String(t)}),captureWallGeometry:s?(t,e)=>s(e):void 0})}_optimizeReferenceContext(t){const e=this.host._haRegistry,s=this.host._fullRegistryHass,i={},o=(...t)=>{for(const e of t){const t=String(e||"").trim();if(t)return t}return""};for(const[t,s]of Object.entries(e.devices||{}))i[t]=o(s?.name_by_user,s?.name,s?.model);for(const[t,s]of Object.entries(e.entities||{}))i[`lg_${t}`]=o(this.host.hass?.states?.[t]?.attributes?.friendly_name,s?.name,s?.original_name);for(const t of this.host._devices)i[t.id]=o(t.name,i[t.id]);for(const t of this.host._serverCfg?.markers||[]){const e=String(t.binding||"").indexOf(":"),a=e>0?t.binding.slice(0,e):"",n=e>0?t.binding.slice(e+1):"",r="device"===a?s?.devices?.[n]:"entity"===a?s?.entities?.[n]:null;i[t.id]=o(t.name,"device"===a?r?.name_by_user:null,r?.name,"entity"===a?this.host.hass?.states?.[n]?.attributes?.friendly_name:null,i[t.id])}return{effectiveAreaByMarker:Object.fromEntries(this.host._devices.filter(t=>!t.virtual&&!!t.area).map(t=>[t.id,t.area])),ownerRoster:{authoritative:e.authoritative,deviceIds:Object.keys(e.devices||{}),entityIds:[...new Set([...Object.keys(e.entities||{}),...Object.keys(this.host.hass?.states||{})])],names:i},removeLiveMissingPositions:t}}_previewAlignDialog(t){if(!this.host._norm||!this.host._serverCfg)return;const e=this.host._serverCfg.spaces||[];let s;try{s=En(this.host._serverCfg,this.host._layout||{},this._optimizeReferenceContext(t))}catch(t){return void this._showWallModelMigrationBlocked(t)}const i=s.changed?this.host._checkOptimizeGeometry(s.config):null;i&&this._reportPreflightFailure(i,s.config);const o=Math.ceil(10*s.report.maxShiftCm)/10,a=e.find(t=>null!=t?.id&&String(t.id)===s.report.maxSpace),n=e.length>1&&a?String(a.title||a.id):"";this.host._preflightClipboardFallback=null,this.host._alignDialog={report:s.report,config:s.config,layout:s.layout,cm:o,where:n,preflight:i,changed:s.changed,busy:!1,removeLiveMissingPositions:t}}async _runAlignToGrid(){let t=this.host._alignDialog;if(!t||t.busy||!this.host._serverCfg||!t.changed||!t.preflight?.ok)return;const e=yt(t.config);if(t.preflight.fingerprint!==e){const e=this.host._checkOptimizeGeometry(t.config);if(this._reportPreflightFailure(e,t.config),t={...t,preflight:e},this.host._alignDialog=t,!e.ok)return}this._clearGeometryGesture(),this.host._alignDialog={...t,busy:!0};try{await On(this.host,t.config,t.layout),this.host._alignDialog=null,this.host._preflightClipboardFallback=null,this.host._showToast(this.host._t("gs.align_done",{n:String(t.report.moved),m:String(t.report.migrated+t.report.canonicalized+t.report.coordsCanonicalized+t.report.latticeCoordinatesCanonicalized+t.report.wallsMerged+t.report.spansMerged+t.report.partitionsMerged+t.report.partitionsReconciled+t.report.openingsRehosted+t.report.wallsStraightened),r:String(t.report.spaceRefsRemapped+t.report.roomRefsRemapped+t.report.positionsRemapped+t.report.markersDetached+t.report.orphanRoomLabelsRemoved+t.report.orphanDevicePositionsRemoved+t.report.orphanGroupPositionsRemoved)}))}catch(t){if(this.host._alignDialog&&(this.host._alignDialog={...this.host._alignDialog,busy:!1}),"wall_model_client_outdated"===t?.code)return void this.host._showToast(this.host._t("toast.wall_model_client_outdated"));"conflict"===t?.code&&await Promise.all([this.host._reloadConfigOnly(!0),this.host._reloadLayoutOnly()]),this.host._showToast(this.host._t("toast.error",{err:this.host._errText(t)}))}}async _undoPlanOptimization(){if(!this.host._canOptimizeUndo||this.host._optimizeUndoBusy)return;const t=this.host._undoKind;this._clearGeometryGesture(),this.host._optimizeUndoBusy=!0,this.host.requestUpdate();try{await this.host.hass.callWS({type:"houseplan/plan/optimize_undo",expected_config_rev:this.host._cfgRev,expected_layout_rev:this.host._layoutRev});const[e,s]=await Promise.all([this.host._getAuthoritativeConfig(),this.host.hass.callWS({type:"houseplan/layout/get"})]);if("adopted"!==(await this.host._adoptAuthoritative({cfgResp:e,layResp:s,reason:"optimize-undo",profile:"post-write"})).status)return;this.host._geometryHistory.clear(),this.host._cancelDeviceDrag(),this.host._devicePositionHistory.clear(),this.host._canOptimizeUndo=!1,this.host._undoKind=null,this.host._cfgEpoch++,this.host._modelCache=null,this.host._frame=null,this.host._regSignature="",this.host._maybeRebuildDevices(),this.host._cacheSnapshot(),this.host.requestUpdate(),this.host._showToast(this.host._t("import"===t?"backup.import_undone":"gs.optimize_undone"))}catch(t){this.host._canOptimizeUndo=!1,this.host._undoKind=null,this.host._showToast(this.host._t("toast.error",{err:this.host._errText(t)}))}finally{this.host._optimizeUndoBusy=!1,this.host.requestUpdate()}}async _runBackupExport(){const t=this.host._backupExportDialog;if(t&&!t.busy){this.host._backupExportDialog={...t,busy:!0,error:""};try{const e=await this.host.hass.callWS({type:"houseplan/export/create",kind:t.kind,space_id:"space"===t.kind?this.host._space:void 0,..."space"===t.kind&&t.planOnly?{plan_only:!0}:{},card_version:$i(vd)}),s=new Blob([JSON.stringify(e.document,null,2)+"\n"],{type:"application/json;charset=utf-8"}),i=URL.createObjectURL(s),o=document.createElement("a");o.href=i,o.download=e.filename||`houseplan-${t.kind}.json`,o.style.display="none",document.body.append(o),o.click(),o.remove(),window.setTimeout(()=>URL.revokeObjectURL(i),0),this.host._backupExportDialog=null,this.host._showToast(this.host._t("backup.export_done"))}catch(t){this.host._backupExportDialog&&(this.host._backupExportDialog={...this.host._backupExportDialog,busy:!1,error:this._backupErrorText(t)})}}}async _pickBackupImport(t){const e=t.target,s=e.files?.[0];if(e.value="",s){this.host._settingsDialog=null,this.host._backupImportDialog={filename:s.name,size:s.size,token:"",preview:null,expectedConfigRev:this.host._cfgRev,expectedLayoutRev:this.host._layoutRev,duplicatePolicy:"skip",confirmMissing:!1,busy:!0,error:""};try{this.host._saveConfigDebounced.pending()&&this.host._saveConfigDebounced.flush(),await this.host._writeChain,this.host._persistLayout.pending()&&this.host._persistLayout.flush();const t="/api/houseplan/import/preview?duplicate_policy=skip",e={method:"POST",body:s,headers:{"content-type":"application/json"}},i=this.host.hass?.fetchWithAuth?await this.host.hass.fetchWithAuth(t,e):await fetch(t,{...e,headers:{...e.headers,...this.host.hass?.auth?.data?.access_token?{authorization:`Bearer ${this.host.hass.auth.data.access_token}`}:{}}}),o=await i.json().catch(()=>({}));if(!i.ok||o.error)throw Object.assign(new Error(o.message||o.error||`HTTP ${i.status}`),{code:o.error});this.host._backupImportDialog&&(this.host._backupImportDialog={...this.host._backupImportDialog,token:o.token,preview:o.preview,expectedConfigRev:o.expected_config_rev,expectedLayoutRev:o.expected_layout_rev,busy:!1})}catch(t){this.host._backupImportDialog&&(this.host._backupImportDialog={...this.host._backupImportDialog,busy:!1,error:this._backupErrorText(t)})}}}async _setBackupDuplicatePolicy(t){const e=this.host._backupImportDialog;if(e&&!e.busy&&e.token&&t!==e.duplicatePolicy){this.host._backupImportDialog={...e,duplicatePolicy:t,busy:!0,error:""};try{const s=await this.host.hass.callWS({type:"houseplan/import/revalidate",token:e.token,duplicate_policy:t});this.host._backupImportDialog&&(this.host._backupImportDialog={...this.host._backupImportDialog,preview:{...e.preview,...s.preview},expectedConfigRev:s.expected_config_rev,expectedLayoutRev:s.expected_layout_rev,confirmMissing:!1,busy:!1})}catch(t){this.host._backupImportDialog&&(this.host._backupImportDialog={...this.host._backupImportDialog,duplicatePolicy:e.duplicatePolicy,preview:e.preview,confirmMissing:e.confirmMissing,busy:!1,error:this._backupErrorText(t)})}}}async _applyBackupImport(){const t=this.host._backupImportDialog;if(!t||t.busy||!t.token||!t.preview)return;if(t.preview.confirmation_required&&!t.confirmMissing)return;this.host._backupImportDialog={...t,busy:!0,error:""};const e=this.host._space;try{const s=await this.host.hass.callWS({type:"houseplan/import/apply",token:t.token,expected_config_rev:t.expectedConfigRev,expected_layout_rev:t.expectedLayoutRev,duplicate_policy:t.duplicatePolicy,confirm_missing_content:t.confirmMissing}),[i,o]=await Promise.all([this.host._getAuthoritativeConfig(),this.host.hass.callWS({type:"houseplan/layout/get"})]);if("adopted"!==(await this.host._adoptAuthoritative({cfgResp:i,layResp:o,reason:"import-apply",profile:"post-write"})).status)return this.host._backupImportDialog={...t,busy:!1,error:""},void this.host.requestUpdate();this.host._geometryHistory.clear(),this.host._dirtyPos.clear(),this.host._sentPos.clear(),this.host._defPos={},this.host._cfgEpoch++,this.host._modelCache=null,this.host._frame=null,this.host._visibleDeviceSnapshot=null,this.host._candidateDeviceSnapshot=null,this.host._stagedDeviceSnapshotToken=-1,this.host._capturedSnapshotConfigEpoch=-1,this.host._regSignature="",this.host._signer.invalidate(this.host.hass),this.host._resign(),this.host._maybeRebuildDevices();const a=this.host._serverCfg?.spaces||[],n="space"===s.kind&&s.space_id?s.space_id:a.some(t=>t.id===e)?e:a[0]?.id||this.host._space;this.host._hasFixedFloor?this.host._adoptInitialSpace(this.host._model,!0):this.host._commitSpace(n),this.host._backupImportDialog=null,this.host._cacheSnapshot(),this.host.requestUpdate();const r="space"===s.kind?t.preview.counts:s.counts;this.host._showToast(this.host._t("space"===s.kind?"backup.space_done":"backup.full_done",{spaces:String(r?.spaces||0),rooms:String(r?.rooms||0),markers:String(r?.markers||0),refs:String(s.repaired_target_refs||0)}))}catch(t){if("conflict"===t?.code&&this.host._backupImportDialog?.token)try{const t=this.host._backupImportDialog,e=await this.host.hass.callWS({type:"houseplan/import/revalidate",token:t.token,duplicate_policy:t.duplicatePolicy});return void(this.host._backupImportDialog={...t,preview:{...t.preview,...e.preview},expectedConfigRev:e.expected_config_rev,expectedLayoutRev:e.expected_layout_rev,confirmMissing:!1,busy:!1,error:this.host._t("backup.revalidated")})}catch(e){t=e}this.host._backupImportDialog&&(this.host._backupImportDialog={...this.host._backupImportDialog,busy:!1,error:this._backupErrorText(t)})}}_renderBackupExportDialog(){const t=this.host._backupExportDialog,e=(this.host._serverCfg?.spaces||[]).find(t=>t.id===this.host._space);return p``;var _}_preflightDiagnostics(t,e){const s=new Map((e?.spaces||[]).map(t=>[String(t?.id||""),t]));return{kind:"houseplan-optimize-preflight",origin:"runtime",cardVersion:$i(yd),checkedAt:(new Date).toISOString(),preflightFingerprint:t.fingerprint,failures:t.failures.map(t=>({spaceId:t.spaceId,displayName:t.displayName,reason:t.reason,detail:t.detail??null,spaceGeometryFingerprint:s.has(t.spaceId)?ne(s.get(t.spaceId)):null}))}}_reportPreflightFailure(t,e){t.ok||t.fingerprint===this.host._reportedPreflightFingerprint||(this.host._reportedPreflightFingerprint=t.fingerprint,console.warn("[houseplan] optimize preflight failed",this._preflightDiagnostics(t,e)))}_preflightVersionsDiffer(){const t=this.host._haIntegrationVersion;return"string"==typeof t&&t.length>0&&t!==$i(yd)}async _copyPreflightDiagnostics(){const t=this.host._alignDialog?.preflight;if(!t||t.ok)return;const e=JSON.stringify(this._preflightDiagnostics(t,this.host._alignDialog?.config??null),null,2);try{await navigator.clipboard.writeText(e),this.host._preflightClipboardFallback=null,this.host._showToast(this.host._t("gs.preflight_copied"))}catch{this.host._preflightClipboardFallback=e}}_checkOptimizeGeometryImpl(t){return wi(t,{fallbackSpaceName:t=>this.host._t("gs.align_preflight_space",{n:String(t)})})}_checkSpacePhysicalGeometryImpl(t,e,s){return ki(t,e,{fallbackSpaceName:t=>this.host._t("gs.align_preflight_space",{n:String(t)}),captureWallGeometry:s?(t,e)=>s(e):void 0})}_optimizeReferenceContext(t){const e=this.host._haRegistry,s=this.host._fullRegistryHass,i={},o=(...t)=>{for(const e of t){const t=String(e||"").trim();if(t)return t}return""};for(const[t,s]of Object.entries(e.devices||{}))i[t]=o(s?.name_by_user,s?.name,s?.model);for(const[t,s]of Object.entries(e.entities||{}))i[`lg_${t}`]=o(this.host.hass?.states?.[t]?.attributes?.friendly_name,s?.name,s?.original_name);for(const t of this.host._devices)i[t.id]=o(t.name,i[t.id]);for(const t of this.host._serverCfg?.markers||[]){const e=String(t.binding||"").indexOf(":"),a=e>0?t.binding.slice(0,e):"",n=e>0?t.binding.slice(e+1):"",r="device"===a?s?.devices?.[n]:"entity"===a?s?.entities?.[n]:null;i[t.id]=o(t.name,"device"===a?r?.name_by_user:null,r?.name,"entity"===a?this.host.hass?.states?.[n]?.attributes?.friendly_name:null,i[t.id])}return{effectiveAreaByMarker:Object.fromEntries(this.host._devices.filter(t=>!t.virtual&&!!t.area).map(t=>[t.id,t.area])),ownerRoster:{authoritative:e.authoritative,deviceIds:Object.keys(e.devices||{}),entityIds:[...new Set([...Object.keys(e.entities||{}),...Object.keys(this.host.hass?.states||{})])],names:i},removeLiveMissingPositions:t}}_previewAlignDialog(t){if(!this.host._norm||!this.host._serverCfg)return;const e=this.host._serverCfg.spaces||[];let s;try{s=On(this.host._serverCfg,this.host._layout||{},this._optimizeReferenceContext(t))}catch(t){return void this._showWallModelMigrationBlocked(t)}const i=s.changed?this.host._checkOptimizeGeometry(s.config):null;i&&this._reportPreflightFailure(i,s.config);const o=Math.ceil(10*s.report.maxShiftCm)/10,a=e.find(t=>null!=t?.id&&String(t.id)===s.report.maxSpace),n=e.length>1&&a?String(a.title||a.id):"";this.host._preflightClipboardFallback=null,this.host._alignDialog={report:s.report,config:s.config,layout:s.layout,cm:o,where:n,preflight:i,changed:s.changed,busy:!1,removeLiveMissingPositions:t}}async _runAlignToGrid(){let t=this.host._alignDialog;if(!t||t.busy||!this.host._serverCfg||!t.changed||!t.preflight?.ok)return;const e=yt(t.config);if(t.preflight.fingerprint!==e){const e=this.host._checkOptimizeGeometry(t.config);if(this._reportPreflightFailure(e,t.config),t={...t,preflight:e},this.host._alignDialog=t,!e.ok)return}this._clearGeometryGesture(),this.host._alignDialog={...t,busy:!0};try{await Hn(this.host,t.config,t.layout),this.host._alignDialog=null,this.host._preflightClipboardFallback=null,this.host._showToast(this.host._t("gs.align_done",{n:String(t.report.moved),m:String(t.report.migrated+t.report.canonicalized+t.report.coordsCanonicalized+t.report.latticeCoordinatesCanonicalized+t.report.wallsMerged+t.report.spansMerged+t.report.partitionsMerged+t.report.partitionsReconciled+t.report.openingsRehosted+t.report.wallsStraightened),r:String(t.report.spaceRefsRemapped+t.report.roomRefsRemapped+t.report.positionsRemapped+t.report.markersDetached+t.report.orphanRoomLabelsRemoved+t.report.orphanDevicePositionsRemoved+t.report.orphanGroupPositionsRemoved)}))}catch(t){if(this.host._alignDialog&&(this.host._alignDialog={...this.host._alignDialog,busy:!1}),"wall_model_client_outdated"===t?.code)return void this.host._showToast(this.host._t("toast.wall_model_client_outdated"));"conflict"===t?.code&&await Promise.all([this.host._reloadConfigOnly(!0),this.host._reloadLayoutOnly()]),this.host._showToast(this.host._t("toast.error",{err:this.host._errText(t)}))}}async _undoPlanOptimization(){if(!this.host._canOptimizeUndo||this.host._optimizeUndoBusy)return;const t=this.host._undoKind;this._clearGeometryGesture(),this.host._optimizeUndoBusy=!0,this.host.requestUpdate();try{await this.host.hass.callWS({type:"houseplan/plan/optimize_undo",expected_config_rev:this.host._cfgRev,expected_layout_rev:this.host._layoutRev});const[e,s]=await Promise.all([this.host._getAuthoritativeConfig(),this.host.hass.callWS({type:"houseplan/layout/get"})]);if("adopted"!==(await this.host._adoptAuthoritative({cfgResp:e,layResp:s,reason:"optimize-undo",profile:"post-write"})).status)return;this.host._geometryHistory.clear(),this.host._cancelDeviceDrag(),this.host._devicePositionHistory.clear(),this.host._canOptimizeUndo=!1,this.host._undoKind=null,this.host._cfgEpoch++,this.host._modelCache=null,this.host._frame=null,this.host._regSignature="",this.host._maybeRebuildDevices(),this.host._cacheSnapshot(),this.host.requestUpdate(),this.host._showToast(this.host._t("import"===t?"backup.import_undone":"gs.optimize_undone"))}catch(t){this.host._canOptimizeUndo=!1,this.host._undoKind=null,this.host._showToast(this.host._t("toast.error",{err:this.host._errText(t)}))}finally{this.host._optimizeUndoBusy=!1,this.host.requestUpdate()}}async _runBackupExport(){const t=this.host._backupExportDialog;if(t&&!t.busy){this.host._backupExportDialog={...t,busy:!0,error:""};try{const e=await this.host.hass.callWS({type:"houseplan/export/create",kind:t.kind,space_id:"space"===t.kind?this.host._space:void 0,..."space"===t.kind&&t.planOnly?{plan_only:!0}:{},card_version:$i(yd)}),s=new Blob([JSON.stringify(e.document,null,2)+"\n"],{type:"application/json;charset=utf-8"}),i=URL.createObjectURL(s),o=document.createElement("a");o.href=i,o.download=e.filename||`houseplan-${t.kind}.json`,o.style.display="none",document.body.append(o),o.click(),o.remove(),window.setTimeout(()=>URL.revokeObjectURL(i),0),this.host._backupExportDialog=null,this.host._showToast(this.host._t("backup.export_done"))}catch(t){this.host._backupExportDialog&&(this.host._backupExportDialog={...this.host._backupExportDialog,busy:!1,error:this._backupErrorText(t)})}}}async _pickBackupImport(t){const e=t.target,s=e.files?.[0];if(e.value="",s){this.host._settingsDialog=null,this.host._backupImportDialog={filename:s.name,size:s.size,token:"",preview:null,expectedConfigRev:this.host._cfgRev,expectedLayoutRev:this.host._layoutRev,duplicatePolicy:"skip",confirmMissing:!1,busy:!0,error:""};try{this.host._saveConfigDebounced.pending()&&this.host._saveConfigDebounced.flush(),await this.host._writeChain,this.host._persistLayout.pending()&&this.host._persistLayout.flush();const t="/api/houseplan/import/preview?duplicate_policy=skip",e={method:"POST",body:s,headers:{"content-type":"application/json"}},i=this.host.hass?.fetchWithAuth?await this.host.hass.fetchWithAuth(t,e):await fetch(t,{...e,headers:{...e.headers,...this.host.hass?.auth?.data?.access_token?{authorization:`Bearer ${this.host.hass.auth.data.access_token}`}:{}}}),o=await i.json().catch(()=>({}));if(!i.ok||o.error)throw Object.assign(new Error(o.message||o.error||`HTTP ${i.status}`),{code:o.error});this.host._backupImportDialog&&(this.host._backupImportDialog={...this.host._backupImportDialog,token:o.token,preview:o.preview,expectedConfigRev:o.expected_config_rev,expectedLayoutRev:o.expected_layout_rev,busy:!1})}catch(t){this.host._backupImportDialog&&(this.host._backupImportDialog={...this.host._backupImportDialog,busy:!1,error:this._backupErrorText(t)})}}}async _setBackupDuplicatePolicy(t){const e=this.host._backupImportDialog;if(e&&!e.busy&&e.token&&t!==e.duplicatePolicy){this.host._backupImportDialog={...e,duplicatePolicy:t,busy:!0,error:""};try{const s=await this.host.hass.callWS({type:"houseplan/import/revalidate",token:e.token,duplicate_policy:t});this.host._backupImportDialog&&(this.host._backupImportDialog={...this.host._backupImportDialog,preview:{...e.preview,...s.preview},expectedConfigRev:s.expected_config_rev,expectedLayoutRev:s.expected_layout_rev,confirmMissing:!1,busy:!1})}catch(t){this.host._backupImportDialog&&(this.host._backupImportDialog={...this.host._backupImportDialog,duplicatePolicy:e.duplicatePolicy,preview:e.preview,confirmMissing:e.confirmMissing,busy:!1,error:this._backupErrorText(t)})}}}async _applyBackupImport(){const t=this.host._backupImportDialog;if(!t||t.busy||!t.token||!t.preview)return;if(t.preview.confirmation_required&&!t.confirmMissing)return;this.host._backupImportDialog={...t,busy:!0,error:""};const e=this.host._space;try{const s=await this.host.hass.callWS({type:"houseplan/import/apply",token:t.token,expected_config_rev:t.expectedConfigRev,expected_layout_rev:t.expectedLayoutRev,duplicate_policy:t.duplicatePolicy,confirm_missing_content:t.confirmMissing}),[i,o]=await Promise.all([this.host._getAuthoritativeConfig(),this.host.hass.callWS({type:"houseplan/layout/get"})]);if("adopted"!==(await this.host._adoptAuthoritative({cfgResp:i,layResp:o,reason:"import-apply",profile:"post-write"})).status)return this.host._backupImportDialog={...t,busy:!1,error:""},void this.host.requestUpdate();this.host._geometryHistory.clear(),this.host._dirtyPos.clear(),this.host._sentPos.clear(),this.host._defPos={},this.host._cfgEpoch++,this.host._modelCache=null,this.host._frame=null,this.host._visibleDeviceSnapshot=null,this.host._candidateDeviceSnapshot=null,this.host._stagedDeviceSnapshotToken=-1,this.host._capturedSnapshotConfigEpoch=-1,this.host._regSignature="",this.host._signer.invalidate(this.host.hass),this.host._resign(),this.host._maybeRebuildDevices();const a=this.host._serverCfg?.spaces||[],n="space"===s.kind&&s.space_id?s.space_id:a.some(t=>t.id===e)?e:a[0]?.id||this.host._space;this.host._hasFixedFloor?this.host._adoptInitialSpace(this.host._model,!0):this.host._commitSpace(n),this.host._backupImportDialog=null,this.host._cacheSnapshot(),this.host.requestUpdate();const r="space"===s.kind?t.preview.counts:s.counts;this.host._showToast(this.host._t("space"===s.kind?"backup.space_done":"backup.full_done",{spaces:String(r?.spaces||0),rooms:String(r?.rooms||0),markers:String(r?.markers||0),refs:String(s.repaired_target_refs||0)}))}catch(t){if("conflict"===t?.code&&this.host._backupImportDialog?.token)try{const t=this.host._backupImportDialog,e=await this.host.hass.callWS({type:"houseplan/import/revalidate",token:t.token,duplicate_policy:t.duplicatePolicy});return void(this.host._backupImportDialog={...t,preview:{...t.preview,...e.preview},expectedConfigRev:e.expected_config_rev,expectedLayoutRev:e.expected_layout_rev,confirmMissing:!1,busy:!1,error:this.host._t("backup.revalidated")})}catch(e){t=e}this.host._backupImportDialog&&(this.host._backupImportDialog={...this.host._backupImportDialog,busy:!1,error:this._backupErrorText(t)})}}_renderBackupExportDialog(){const t=this.host._backupExportDialog,e=(this.host._serverCfg?.spaces||[]).find(t=>t.id===this.host._space);return p`this.host._backupExportDialog=null}>
    ${this.host._t("backup.export_hint")}
    @@ -2181,7 +2168,7 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db ${t.busy?"…":this.host._t("gs.align_run")} `:d}
    -
    `}_renderSettingsDialog(){return sr.call(this)}_rulesSet(t){this.host._rulesDialog={...this.host._rulesDialog,rules:t}}async _saveRules(){const t=this.host._rulesDialog;if(!t||t.busy)return;const e=t.rules.filter(t=>t.pattern.trim()&&t.icon.trim());this.host._rulesDialog={...t,busy:!0};try{const t=this.host._serverCfg,s=JSON.stringify(e)===JSON.stringify(Be),i={...t.settings};s?delete i.icon_rules:i.icon_rules=e,this.host._serverCfg={...t,settings:i},await this._saveConfigNow(),this.host._rulesDialog=null,this.host._regSignature="",this.host._maybeRebuildDevices(),this.host._showToast(this.host._t("rules.saved"))}catch(t){this.host._rulesDialog&&(this.host._rulesDialog={...this.host._rulesDialog,busy:!1}),this.host._showToast(this.host._t("toast.error",{err:this.host._errText(t)}))}}_renderRulesDialog(){const t=this.host._rulesDialog,e=Si(t.rules),s=t.test.trim()?Pi(t.test,"",e):null,i=(e,s)=>{const i=[...t.rules],o=e+s;o<0||o>=i.length||([i[e],i[o]]=[i[o],i[e]],this._rulesSet(i))};return p``}_renderSettingsDialog(){return ir.call(this)}_rulesSet(t){this.host._rulesDialog={...this.host._rulesDialog,rules:t}}async _saveRules(){const t=this.host._rulesDialog;if(!t||t.busy)return;const e=t.rules.filter(t=>t.pattern.trim()&&t.icon.trim());this.host._rulesDialog={...t,busy:!0};try{const t=this.host._serverCfg,s=JSON.stringify(e)===JSON.stringify(Be),i={...t.settings};s?delete i.icon_rules:i.icon_rules=e,this.host._serverCfg={...t,settings:i},await this._saveConfigNow(),this.host._rulesDialog=null,this.host._regSignature="",this.host._maybeRebuildDevices(),this.host._showToast(this.host._t("rules.saved"))}catch(t){this.host._rulesDialog&&(this.host._rulesDialog={...this.host._rulesDialog,busy:!1}),this.host._showToast(this.host._t("toast.error",{err:this.host._errText(t)}))}}_renderRulesDialog(){const t=this.host._rulesDialog,e=Si(t.rules),s=t.test.trim()?Pi(t.test,"",e):null,i=(e,s)=>{const i=[...t.rules],o=e+s;o<0||o>=i.length||([i[e],i[o]]=[i[o],i[e]],this._rulesSet(i))};return p`this.host._rulesDialog=null}>
    ${this.host._t("rules.hint")}
    @@ -2302,7 +2289,7 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db ${Uo(this,e,a)} `:d} -
    `}_vacMapId(t,e,s=this.host._planHass){return this.host._vacMapId(t,e,s)}_vacSaveMatrix(t,e,s,i,o=""){return Wc(this,t,e,s,i,o)}_vacPlanRoomAnchors(t){return(this.host._spaceModelById(t)?.rooms||[]).map(t=>({room:t,poly:N(t)})).filter(({room:t,poly:e})=>t.name&&e).map(({room:t,poly:e})=>{const s=Ri(e);return s?{name:String(t.name),cx:s[0],cy:s[1]}:null}).filter(Boolean)}async _vacAutoCalibrate(t){if(this.host._markerDialog?.busy)return;const e=this.host._vacSource(t),s=e?Ii(this.host.hass?.states[e]?.attributes):null;if(!e||!s||s.rooms.length<3)return void this.host._showToast(this.host._t("vac.autocal_no_rooms"));const i=this._vacMapId(t,s),a=function(t,e,s,i,a){const n=o(t,e,s,i).find(t=>t.source===i&&t.map_id===a);return{space:n?.space||s,routeId:n?.id||""}}(t.id,t.marker?.vacuum??null,t.space,e,i),n=zi(s.rooms,this._vacPlanRoomAnchors(a.space));if(!n)return void this.host._showToast(this.host._t("vac.autocal_no_match"));const r=this.host._serverCfg?.spaces?.find(t=>t.id===a.space),l=Number(r?.cell_cm),h=Number.isFinite(l)&&l>0?l:5,c=Fi(n.residual,this.host._gridPitch,h);c>Ni?this.host._vacCalConfirm={markerId:t.id,source:e,mapId:i,routeId:a.routeId,space:a.space,matrix:n.matrix,rooms:n.matched.length,error:fe(c,"mi"===this.host.hass?.config?.unit_system?.length)}:await async function(t,e){if(Hc.has(t))return;Hc.add(t);const s=t.host,i=s._markerDialog,o=i?{...i,busy:!0}:null;o&&(s._markerDialog=o,s.requestUpdate());try{await Wc(t,e.markerId,e.source,e.mapId,e.matrix,e.routeId)&&s._showToast(s._t("vac.autocal_done",{rooms:String(e.rooms)}))}finally{Hc.delete(t),o&&s._markerDialog===o&&(s._markerDialog={...o,busy:!1},s.requestUpdate())}}(this,{markerId:t.id,source:e,mapId:i,routeId:a.routeId,space:a.space,matrix:n.matrix,rooms:n.matched.length})}_vacApplyCalibrationProposal(t){return async function(t,e){const s=t.host,i=s._vacCalConfirm;if(!i||i.busy)return;if(e){const t=s._devices.find(t=>t.id===i.markerId),e=n(i.matrix);if(!t||!e)return;const o=i.space||t.space;if(o!==s._space&&!s._commitSpace(o))return;return s._vacCalConfirm=null,s._markerDialog=null,void(s._vacFit={markerId:i.markerId,source:i.source,routeId:i.routeId,mapId:i.mapId,p:e,drag:null})}const o={...i,busy:!0};s._vacCalConfirm=o,s.requestUpdate();const a=await Wc(t,i.markerId,i.source,i.mapId,i.matrix,i.routeId);s._vacCalConfirm===o&&(s._vacCalConfirm=a?null:{...i,busy:!1},s.requestUpdate()),a&&s._showToast(s._t("vac.autocal_done",{rooms:String(i.rooms)}))}(this,t)}_vacStartFit(t,e=""){if(this.host._markerDialog?.busy)return;const s=this.host._vacSource(t),i=s?Ii(this.host.hass?.states[s]?.attributes):null;if(!s||!i)return void this.host._showToast(this.host._t("vac.cal_need_pos"));const l=this._vacMapId(t,i),h=function(t,e,s){const i=o(t,e,s.dockSpace,s.source),l=i.find(t=>t.id===s.routeId)||i.find(t=>t.source===s.source&&t.map_id===s.mapId)||null,h=l?.space||s.dockSpace,c=s.viewBoxOf(h);if(!c)return null;const d=a(l?l.calibration:e?.calibration?.[s.mapId]),p=d&&n(d)||r(s.rooms,c);return{space:h,routeId:l?.id||"",params:p}}(t.id,t.marker?.vacuum??null,{routeId:e,source:s,mapId:l,dockSpace:t.space,rooms:i.rooms,viewBoxOf:t=>this.host._spaceModelById(t)?.vb??null});h&&(this.host._markerDialog=null,(h.space===this.host._space||this.host._commitSpace(h.space))&&(this.host._vacFit={markerId:t.id,source:s,mapId:l,routeId:h.routeId,p:h.params,drag:null}))}_vacFitSave(){return async function(t,e){const s=t.host,i=s._vacFit;if(!i||i.busy)return;const o={...i,busy:!0,drag:null};s._vacFit=o,s.requestUpdate();const a=await Wc(t,i.markerId,i.source,i.mapId,e(i.p),i.routeId);s._vacFit===o&&(s._vacFit=a?null:{...i,busy:!1,drag:null},s.requestUpdate()),a&&s._showToast(s._t("vac.cal_done"))}(this,Ei)}_vacFitTurn(t){const e=this.host._vacFit;if(!e||e.busy)return;const s=Ii(this.host.hass?.states[e.source]?.attributes),i=this._vacGhostCentre(s?.rooms||[]),o={...e.p,...t};this.host._vacFit={...e,p:Ai(o,e.p,i[0],i[1])}}_vacGhostCentre(t){const e=[],s=[];for(const i of t)e.push(i.x0??i.cx,i.x1??i.cx),s.push(i.y0??i.cy,i.y1??i.cy);return e.length?[(Math.min(...e)+Math.max(...e))/2,(Math.min(...s)+Math.max(...s))/2]:[0,0]}_vacDelta(t,e,s){const i=this.host._stageEl,o=i?.clientWidth||1,a=i?.clientHeight||1;return[e/o*t.w,s/a*t.h]}_vacFitPointer(t,e){const s=this.host._vacFit;if(!s)return;if(t.stopPropagation(),s.busy)return;if("pointerdown"===t.type){const e=t.target,i=e.getAttribute?.("data-corner");try{t.currentTarget.setPointerCapture?.(t.pointerId)}catch{}return void(this.host._vacFit={...s,drag:i?{kind:"scale",sx:t.clientX,sy:t.clientY,p0:{...s.p},fx:Number(i.split(",")[0]),fy:Number(i.split(",")[1])}:{kind:"move",sx:t.clientX,sy:t.clientY,p0:{...s.p},fx:0,fy:0}})}const i=s.drag;if(i){if("pointermove"===t.type){const[o,a]=this._vacDelta(e,t.clientX-i.sx,t.clientY-i.sy);if("move"===i.kind)this.host._vacFit={...s,p:{...i.p0,ox:i.p0.ox+o,oy:i.p0.oy+a}};else{const t=Ii(this.host.hass?.states[s.source]?.attributes),e=this._vacGhostCentre(t?.rooms||[]),n=Ei(i.p0),[r,l]=Oi(n,e[0],e[1]),[h,c]=Oi(n,i.fx,i.fy),d=Math.hypot(r-h,l-c)||1,[p,u]=[2*r-h,2*l-c],_=Math.hypot(p+2*o-h,u+2*a-c)/2,g=Math.max(.05,_/d),m={...i.p0,s:i.p0.s*g};this.host._vacFit={...s,p:Ai(m,i.p0,i.fx,i.fy)}}return}"pointerup"!==t.type&&"pointercancel"!==t.type||(this.host._vacFit={...s,drag:null})}}_renderVacFit(t){const e=this.host._vacFit;if(!e)return d;const s=Ii(this.host._renderPlanHass?.states?.[e.source]?.attributes);if(!s)return d;const i=Ei(e.p),o=[],a=[],n=[];for(const t of s.rooms){if(null==t.x0)continue;const e=[[t.x0,t.y0],[t.x1,t.y0],[t.x1,t.y1],[t.x0,t.y1]].map(([t,e])=>Oi(i,t,e));e.forEach(([t,e])=>{a.push(t),n.push(e)});const[s,r]=Oi(i,t.cx,t.cy);o.push(At` +
    `}_vacMapId(t,e,s=this.host._planHass){return this.host._vacMapId(t,e,s)}_vacSaveMatrix(t,e,s,i,o=""){return jc(this,t,e,s,i,o)}_vacPlanRoomAnchors(t){return(this.host._spaceModelById(t)?.rooms||[]).map(t=>({room:t,poly:N(t)})).filter(({room:t,poly:e})=>t.name&&e).map(({room:t,poly:e})=>{const s=Ri(e);return s?{name:String(t.name),cx:s[0],cy:s[1]}:null}).filter(Boolean)}async _vacAutoCalibrate(t){if(this.host._markerDialog?.busy)return;const e=this.host._vacSource(t),s=e?Ii(this.host.hass?.states[e]?.attributes):null;if(!e||!s||s.rooms.length<3)return void this.host._showToast(this.host._t("vac.autocal_no_rooms"));const i=this._vacMapId(t,s),a=function(t,e,s,i,a){const n=o(t,e,s,i).find(t=>t.source===i&&t.map_id===a);return{space:n?.space||s,routeId:n?.id||""}}(t.id,t.marker?.vacuum??null,t.space,e,i),n=zi(s.rooms,this._vacPlanRoomAnchors(a.space));if(!n)return void this.host._showToast(this.host._t("vac.autocal_no_match"));const r=this.host._serverCfg?.spaces?.find(t=>t.id===a.space),l=Number(r?.cell_cm),h=Number.isFinite(l)&&l>0?l:5,c=Fi(n.residual,this.host._gridPitch,h);c>Ni?this.host._vacCalConfirm={markerId:t.id,source:e,mapId:i,routeId:a.routeId,space:a.space,matrix:n.matrix,rooms:n.matched.length,error:fe(c,"mi"===this.host.hass?.config?.unit_system?.length)}:await async function(t,e){if(Bc.has(t))return;Bc.add(t);const s=t.host,i=s._markerDialog,o=i?{...i,busy:!0}:null;o&&(s._markerDialog=o,s.requestUpdate());try{await jc(t,e.markerId,e.source,e.mapId,e.matrix,e.routeId)&&s._showToast(s._t("vac.autocal_done",{rooms:String(e.rooms)}))}finally{Bc.delete(t),o&&s._markerDialog===o&&(s._markerDialog={...o,busy:!1},s.requestUpdate())}}(this,{markerId:t.id,source:e,mapId:i,routeId:a.routeId,space:a.space,matrix:n.matrix,rooms:n.matched.length})}_vacApplyCalibrationProposal(t){return async function(t,e){const s=t.host,i=s._vacCalConfirm;if(!i||i.busy)return;if(e){const t=s._devices.find(t=>t.id===i.markerId),e=n(i.matrix);if(!t||!e)return;const o=i.space||t.space;if(o!==s._space&&!s._commitSpace(o))return;return s._vacCalConfirm=null,s._markerDialog=null,void(s._vacFit={markerId:i.markerId,source:i.source,routeId:i.routeId,mapId:i.mapId,p:e,drag:null})}const o={...i,busy:!0};s._vacCalConfirm=o,s.requestUpdate();const a=await jc(t,i.markerId,i.source,i.mapId,i.matrix,i.routeId);s._vacCalConfirm===o&&(s._vacCalConfirm=a?null:{...i,busy:!1},s.requestUpdate()),a&&s._showToast(s._t("vac.autocal_done",{rooms:String(i.rooms)}))}(this,t)}_vacStartFit(t,e=""){if(this.host._markerDialog?.busy)return;const s=this.host._vacSource(t),i=s?Ii(this.host.hass?.states[s]?.attributes):null;if(!s||!i)return void this.host._showToast(this.host._t("vac.cal_need_pos"));const l=this._vacMapId(t,i),h=function(t,e,s){const i=o(t,e,s.dockSpace,s.source),l=i.find(t=>t.id===s.routeId)||i.find(t=>t.source===s.source&&t.map_id===s.mapId)||null,h=l?.space||s.dockSpace,c=s.viewBoxOf(h);if(!c)return null;const d=a(l?l.calibration:e?.calibration?.[s.mapId]),p=d&&n(d)||r(s.rooms,c);return{space:h,routeId:l?.id||"",params:p}}(t.id,t.marker?.vacuum??null,{routeId:e,source:s,mapId:l,dockSpace:t.space,rooms:i.rooms,viewBoxOf:t=>this.host._spaceModelById(t)?.vb??null});h&&(this.host._markerDialog=null,(h.space===this.host._space||this.host._commitSpace(h.space))&&(this.host._vacFit={markerId:t.id,source:s,mapId:l,routeId:h.routeId,p:h.params,drag:null}))}_vacFitSave(){return async function(t,e){const s=t.host,i=s._vacFit;if(!i||i.busy)return;const o={...i,busy:!0,drag:null};s._vacFit=o,s.requestUpdate();const a=await jc(t,i.markerId,i.source,i.mapId,e(i.p),i.routeId);s._vacFit===o&&(s._vacFit=a?null:{...i,busy:!1,drag:null},s.requestUpdate()),a&&s._showToast(s._t("vac.cal_done"))}(this,Ei)}_vacFitTurn(t){const e=this.host._vacFit;if(!e||e.busy)return;const s=Ii(this.host.hass?.states[e.source]?.attributes),i=this._vacGhostCentre(s?.rooms||[]),o={...e.p,...t};this.host._vacFit={...e,p:Ai(o,e.p,i[0],i[1])}}_vacGhostCentre(t){const e=[],s=[];for(const i of t)e.push(i.x0??i.cx,i.x1??i.cx),s.push(i.y0??i.cy,i.y1??i.cy);return e.length?[(Math.min(...e)+Math.max(...e))/2,(Math.min(...s)+Math.max(...s))/2]:[0,0]}_vacDelta(t,e,s){const i=this.host._stageEl,o=i?.clientWidth||1,a=i?.clientHeight||1;return[e/o*t.w,s/a*t.h]}_vacFitPointer(t,e){const s=this.host._vacFit;if(!s)return;if(t.stopPropagation(),s.busy)return;if("pointerdown"===t.type){const e=t.target,i=e.getAttribute?.("data-corner");try{t.currentTarget.setPointerCapture?.(t.pointerId)}catch{}return void(this.host._vacFit={...s,drag:i?{kind:"scale",sx:t.clientX,sy:t.clientY,p0:{...s.p},fx:Number(i.split(",")[0]),fy:Number(i.split(",")[1])}:{kind:"move",sx:t.clientX,sy:t.clientY,p0:{...s.p},fx:0,fy:0}})}const i=s.drag;if(i){if("pointermove"===t.type){const[o,a]=this._vacDelta(e,t.clientX-i.sx,t.clientY-i.sy);if("move"===i.kind)this.host._vacFit={...s,p:{...i.p0,ox:i.p0.ox+o,oy:i.p0.oy+a}};else{const t=Ii(this.host.hass?.states[s.source]?.attributes),e=this._vacGhostCentre(t?.rooms||[]),n=Ei(i.p0),[r,l]=Oi(n,e[0],e[1]),[h,c]=Oi(n,i.fx,i.fy),d=Math.hypot(r-h,l-c)||1,[p,u]=[2*r-h,2*l-c],_=Math.hypot(p+2*o-h,u+2*a-c)/2,g=Math.max(.05,_/d),m={...i.p0,s:i.p0.s*g};this.host._vacFit={...s,p:Ai(m,i.p0,i.fx,i.fy)}}return}"pointerup"!==t.type&&"pointercancel"!==t.type||(this.host._vacFit={...s,drag:null})}}_renderVacFit(t){const e=this.host._vacFit;if(!e)return d;const s=Ii(this.host._renderPlanHass?.states?.[e.source]?.attributes);if(!s)return d;const i=Ei(e.p),o=[],a=[],n=[];for(const t of s.rooms){if(null==t.x0)continue;const e=[[t.x0,t.y0],[t.x1,t.y0],[t.x1,t.y1],[t.x0,t.y1]].map(([t,e])=>Oi(i,t,e));e.forEach(([t,e])=>{a.push(t),n.push(e)});const[s,r]=Oi(i,t.cx,t.cy);o.push(At` ${t.name}`)}let r=d;if(s.pos){const[e,o]=Oi(i,s.pos.x,s.pos.y);r=At``}const l=[];if(a.length){const e=(()=>{const t=i[0]*i[4]-i[1]*i[3];return(e,s)=>[(i[4]*(e-i[2])-i[1]*(s-i[5]))/t,(-i[3]*(e-i[2])+i[0]*(s-i[5]))/t]})(),s=Math.min(...a),o=Math.max(...a),r=Math.min(...n),h=Math.max(...n),c=.022*t.w,d=c/4;for(const[t,i,a,n]of[[s,r,o,h],[o,r,s,h],[o,h,s,r],[s,h,o,r]]){const s=e(a,n);l.push(At` `)}}return p`t.id===this.host._roomEditId);if(!e)return this.host._roomDialog=!1,void(this.host._roomEditId=null);e.name=this.host._nameSel.trim()||e.name,e.area=this.host._areaSel||null;const s=e.settings||{},i={...s};Wi(i,this.host._roomTempMin,this.host._roomTempMax)&&(this.host._roomFill?i.fill_mode=this.host._roomFill:delete i.fill_mode,"custom"===this.host._roomFill&&this.host._roomCustomFill?i.custom_fill=this.host._roomCustomFill:delete i.custom_fill,"glow"===s.fill_mode&&"boolean"!=typeof s.glow&&(i.glow=!0),this.host._roomTempSrc?i.temp_source=this.host._roomTempSrc:delete i.temp_source,this.host._roomHumSrc?i.hum_source=this.host._roomHumSrc:delete i.hum_source,1!==this.host._roomNameScale?i.name_scale=this.host._roomNameScale:delete i.name_scale,1!==this.host._roomLabelScale?i.label_scale=this.host._roomLabelScale:delete i.label_scale,Object.keys(i).length?e.settings=i:delete e.settings,this._saveConfig(),this.host._roomDialog=!1,this.host._roomEditId=null,this.host._nameSel="",this.host._areaSel="",this.host._regSignature="",this.host._maybeRebuildDevices(),this.host.requestUpdate(),this.host._showToast(this.host._t("toast.room_updated")))}_roomSrcCandidates(){const t=this.host._planHass,e=ge(this.host._markers),s=this.host._roomSrcFilter.trim().toLowerCase(),i=[];for(const o of Object.values(t.devices)){if("service"===o.entry_type)continue;if(e.devices.has(o.id))continue;const t=(o.name_by_user||o.name||o.id).trim();s&&!t.toLowerCase().includes(s)||i.push({value:"device:"+o.id,label:t,sub:o.model||this.host._t("marker.sub_device")})}for(const[o,a]of Object.entries(t.entities)){if(!o.startsWith("sensor.")||a.hidden)continue;if(me(t,o,e))continue;const n=a.name||t.states[o]?.attributes?.friendly_name||o;s&&!(n+" "+o).toLowerCase().includes(s)||i.push({value:"entity:"+o,label:n,sub:o})}return i.sort((t,e)=>t.label.localeCompare(e.label)),i.slice(0,200)}_roomSrcLabel(t){const e=t.indexOf(":"),s=t.slice(0,e),i=t.slice(e+1);return"device"===s?this.host._fullRegistryHass.devices[i]?.name_by_user||this.host._fullRegistryHass.devices[i]?.name||i:this.host._fullRegistryHass.entities[i]?.name||this.host.hass.states[i]?.attributes?.friendly_name||i}_labelPos(t,e){const s=this.host._layout["rl_"+(t.id||"")];if(s&&s.s===e)return{x:s.x*wd,y:s.y*wd};const i=this._snap(this.host._roomCenter(t));return{x:i[0],y:i[1]}}_labelDown(t,e,s){if("plan"!==this.host._mode)return;t.preventDefault(),t.stopPropagation();const i=this._labelPos(e,s);this.host._drag={id:"rl_"+(e.id||""),sx:t.clientX,sy:t.clientY,ox:i.x,oy:i.y,moved:!1},xd(t),this.host._tip=null}_labelMove(t,e,s){const i="rl_"+(e.id||"");if(!this.host._drag||this.host._drag.id!==i)return;const o=this.host._stageEl;if(!o)return;const a=this.host._spaceModelById(s);if(!a)return;const n=a.vb,r=o.getBoundingClientRect(),l=this.host._viewOr(n),h=(t.clientX-this.host._drag.sx)/r.width*l.w,c=(t.clientY-this.host._drag.sy)/r.height*l.h;Math.abs(t.clientX-this.host._drag.sx)+Math.abs(t.clientY-this.host._drag.sy)>3&&(this.host._drag.moved=!0);const d=qe(this.host._drag.ox+h),p=qe(this.host._drag.oy+c);this.host._savePos({id:i,space:s},d,p)}_labelUp(t){const e="rl_"+(t.id||"");if(!this.host._drag||this.host._drag.id!==e)return;const s=this.host._drag.moved;this.host._drag=s?this.host._drag:null,s&&window.setTimeout(()=>this.host._drag=null,0)}_labelScale(t){const e=this.host._layout["rl_"+(t.id||"")]?.k;return"number"==typeof e&&Number.isFinite(e)?Math.min(3,Math.max(.5,e)):1}_rlResizeDown(t,e,s){if("plan"!==this.host._mode)return;t.preventDefault(),t.stopPropagation();const i=t.target.closest(".roomlabel");if(!i)return;const o=i.getBoundingClientRect(),a=o.left+o.width/2,n=o.top+o.height/2,r=Math.max(8,Math.hypot(t.clientX-a,t.clientY-n));this.host._rlResize={id:"rl_"+(e.id||""),space:s,k0:this._labelScale(e),cx:a,cy:n,d0:r},xd(t)}_rlResizeMove(t){const e=this.host._rlResize;if(!e)return;t.stopPropagation();const s=Math.max(8,Math.hypot(t.clientX-e.cx,t.clientY-e.cy)),i=Math.min(3,Math.max(.5,e.k0*(s/e.d0))),o=this.host._layout[e.id];if(o)this.host._layout={...this.host._layout,[e.id]:{...o,k:i}};else{const t=e.id.slice(3),s=this.host._spaceModelById(e.space);if(!s)return;const o=s.rooms.find(e=>e.id===t);if(!o)return;const a=this._labelPos(o,e.space);this.host._layout={...this.host._layout,[e.id]:{s:e.space,x:a.x/wd,y:a.y/wd,k:i}}}this.host._dirtyPos.add(e.id)}_rlResizeUp(){this.host._rlResize&&(this.host._rlResize=null,this.host._persistLayout())}_renderRoomGear(t,e,s){if(!t.id)return d;let i=null;if(t.poly?(i=this.host._gearPtCache.get(t.poly)||null,i||(i=gs(t.poly),this.host._gearPtCache.set(t.poly,i))):null!=t.x&&null!=t.y&&(i=[t.x+(t.w||0)/2,t.y+(t.h||0)/2]),!i)return d;const o=(i[0]-s.x)/s.w*100,a=(i[1]-s.y)/s.h*100;return p``}_resetRoomDialogFields(){this.host._roomEditId=null,this.host._roomFill="",this.host._roomCustomFill=null,this.host._roomTempMin="",this.host._roomTempMax="",this.host._roomTempSrc="",this.host._roomHumSrc="",this.host._roomSrcOpen=null,this.host._roomSrcFilter="",this.host._roomNameScale=1,this.host._roomLabelScale=1}_openRoomEdit(t){if(!t.id)return;this.host._roomEditId=t.id,this.host._nameSel=t.name||"",this.host._areaSel=t.area||"",this.host._roomFill="glow"===t.settings?.fill_mode?"":t.settings?.fill_mode||"";const e="custom"===this.host._roomFill?t.settings?.custom_fill:null;this.host._roomCustomFill=e&&"object"==typeof e?pi(e,_(this.host._curSpaceCfg).customFill):null,[this.host._roomTempMin,this.host._roomTempMax]=Hi(t.settings),this.host._roomTempSrc=t.settings?.temp_source||"",this.host._roomHumSrc=t.settings?.hum_source||"",this.host._roomNameScale=Bi(t.settings?.name_scale),this.host._roomLabelScale=Bi(t.settings?.label_scale),this.host._roomSrcOpen=null,this.host._roomSrcFilter="",this.host._roomDialog=!0}_roomSettingsFromDialog(){const t={};return this.host._roomFill&&(t.fill_mode=this.host._roomFill),"custom"===this.host._roomFill&&this.host._roomCustomFill&&(t.custom_fill=this.host._roomCustomFill),this.host._roomTempSrc&&(t.temp_source=this.host._roomTempSrc),this.host._roomHumSrc&&(t.hum_source=this.host._roomHumSrc),Wi(t,this.host._roomTempMin,this.host._roomTempMax),1!==this.host._roomNameScale&&(t.name_scale=this.host._roomNameScale),1!==this.host._roomLabelScale&&(t.label_scale=this.host._roomLabelScale),Object.keys(t).length?t:null}_saveRoomEdit(){const t=this.host._curSpaceCfg,e=t?.rooms.find(t=>t.id===this.host._roomEditId);if(!e)return this.host._roomDialog=!1,void(this.host._roomEditId=null);e.name=this.host._nameSel.trim()||e.name,e.area=this.host._areaSel||null;const s=e.settings||{},i={...s};Wi(i,this.host._roomTempMin,this.host._roomTempMax)&&(this.host._roomFill?i.fill_mode=this.host._roomFill:delete i.fill_mode,"custom"===this.host._roomFill&&this.host._roomCustomFill?i.custom_fill=this.host._roomCustomFill:delete i.custom_fill,"glow"===s.fill_mode&&"boolean"!=typeof s.glow&&(i.glow=!0),this.host._roomTempSrc?i.temp_source=this.host._roomTempSrc:delete i.temp_source,this.host._roomHumSrc?i.hum_source=this.host._roomHumSrc:delete i.hum_source,1!==this.host._roomNameScale?i.name_scale=this.host._roomNameScale:delete i.name_scale,1!==this.host._roomLabelScale?i.label_scale=this.host._roomLabelScale:delete i.label_scale,Object.keys(i).length?e.settings=i:delete e.settings,this._saveConfig(),this.host._roomDialog=!1,this.host._roomEditId=null,this.host._nameSel="",this.host._areaSel="",this.host._regSignature="",this.host._maybeRebuildDevices(),this.host.requestUpdate(),this.host._showToast(this.host._t("toast.room_updated")))}_roomSrcCandidates(){const t=this.host._planHass,e=ge(this.host._markers),s=this.host._roomSrcFilter.trim().toLowerCase(),i=[];for(const o of Object.values(t.devices)){if("service"===o.entry_type)continue;if(e.devices.has(o.id))continue;const t=(o.name_by_user||o.name||o.id).trim();s&&!t.toLowerCase().includes(s)||i.push({value:"device:"+o.id,label:t,sub:o.model||this.host._t("marker.sub_device")})}for(const[o,a]of Object.entries(t.entities)){if(!o.startsWith("sensor.")||a.hidden)continue;if(me(t,o,e))continue;const n=a.name||t.states[o]?.attributes?.friendly_name||o;s&&!(n+" "+o).toLowerCase().includes(s)||i.push({value:"entity:"+o,label:n,sub:o})}return i.sort((t,e)=>t.label.localeCompare(e.label)),i.slice(0,200)}_roomSrcLabel(t){const e=t.indexOf(":"),s=t.slice(0,e),i=t.slice(e+1);return"device"===s?this.host._fullRegistryHass.devices[i]?.name_by_user||this.host._fullRegistryHass.devices[i]?.name||i:this.host._fullRegistryHass.entities[i]?.name||this.host.hass.states[i]?.attributes?.friendly_name||i}_labelPos(t,e){const s=this.host._layout["rl_"+(t.id||"")];if(s&&s.s===e)return{x:s.x*kd,y:s.y*kd};const i=this._snap(this.host._roomCenter(t));return{x:i[0],y:i[1]}}_labelDown(t,e,s){if("plan"!==this.host._mode)return;t.preventDefault(),t.stopPropagation();const i=this._labelPos(e,s);this.host._drag={id:"rl_"+(e.id||""),sx:t.clientX,sy:t.clientY,ox:i.x,oy:i.y,moved:!1},Md(t),this.host._tip=null}_labelMove(t,e,s){const i="rl_"+(e.id||"");if(!this.host._drag||this.host._drag.id!==i)return;const o=this.host._stageEl;if(!o)return;const a=this.host._spaceModelById(s);if(!a)return;const n=a.vb,r=o.getBoundingClientRect(),l=this.host._viewOr(n),h=(t.clientX-this.host._drag.sx)/r.width*l.w,c=(t.clientY-this.host._drag.sy)/r.height*l.h;Math.abs(t.clientX-this.host._drag.sx)+Math.abs(t.clientY-this.host._drag.sy)>3&&(this.host._drag.moved=!0);const d=qe(this.host._drag.ox+h),p=qe(this.host._drag.oy+c);this.host._savePos({id:i,space:s},d,p)}_labelUp(t){const e="rl_"+(t.id||"");if(!this.host._drag||this.host._drag.id!==e)return;const s=this.host._drag.moved;this.host._drag=s?this.host._drag:null,s&&window.setTimeout(()=>this.host._drag=null,0)}_labelScale(t){const e=this.host._layout["rl_"+(t.id||"")]?.k;return"number"==typeof e&&Number.isFinite(e)?Math.min(3,Math.max(.5,e)):1}_rlResizeDown(t,e,s){if("plan"!==this.host._mode)return;t.preventDefault(),t.stopPropagation();const i=t.target.closest(".roomlabel");if(!i)return;const o=i.getBoundingClientRect(),a=o.left+o.width/2,n=o.top+o.height/2,r=Math.max(8,Math.hypot(t.clientX-a,t.clientY-n));this.host._rlResize={id:"rl_"+(e.id||""),space:s,k0:this._labelScale(e),cx:a,cy:n,d0:r},Md(t)}_rlResizeMove(t){const e=this.host._rlResize;if(!e)return;t.stopPropagation();const s=Math.max(8,Math.hypot(t.clientX-e.cx,t.clientY-e.cy)),i=Math.min(3,Math.max(.5,e.k0*(s/e.d0))),o=this.host._layout[e.id];if(o)this.host._layout={...this.host._layout,[e.id]:{...o,k:i}};else{const t=e.id.slice(3),s=this.host._spaceModelById(e.space);if(!s)return;const o=s.rooms.find(e=>e.id===t);if(!o)return;const a=this._labelPos(o,e.space);this.host._layout={...this.host._layout,[e.id]:{s:e.space,x:a.x/kd,y:a.y/kd,k:i}}}this.host._dirtyPos.add(e.id)}_rlResizeUp(){this.host._rlResize&&(this.host._rlResize=null,this.host._persistLayout())}_renderRoomGear(t,e,s){if(!t.id)return d;let i=null;if(t.poly?(i=this.host._gearPtCache.get(t.poly)||null,i||(i=gs(t.poly),this.host._gearPtCache.set(t.poly,i))):null!=t.x&&null!=t.y&&(i=[t.x+(t.w||0)/2,t.y+(t.h||0)/2]),!i)return d;const o=(i[0]-s.x)/s.w*100,a=(i[1]-s.y)/s.h*100;return p` -
    `}_markerValueBadgeFields(t){return to({touched:t.valueBadgeTouched,originalHas:t.originalHasValueBadge,original:t.originalValueBadge,enabled:t.valueBadgeEnabled,source:t.valueBadgeSource,position:t.valueBadgePosition})}_markerValueSourceFields(t){return eo({touched:t.valueSourceTouched,originalHas:t.originalHasValueSource,original:t.originalValueSource,source:t.valueSource})}_markerDraft(t){if("ha"===t.bindingMode&&(!t.binding||"virtual"===t.binding))return null;const e=M(t.room),s=si(t.binding,t.devId,()=>"__hp_device_preview__"),i=this.host._markers.find(e=>e.id===s||e.id===t.devId),o=x(t.binding,t.controls,this.host._bindingEntities(t.binding)),a=this._effectiveStoredTapAction(t),n={id:s,binding:t.binding,name:t.name.trim()||null,icon:t.icon||null,display:"badge"!==t.display?t.display:null,ripple_color:"icon_ripple"===t.display&&t.rippleColor?t.rippleColor:null,ripple_size:"icon_ripple"===t.display&&1.5!==t.rippleSize?t.rippleSize:null,size:1!==t.size?t.size:null,angle:t.angle||null,...this._markerTapActionFields(t),...this._markerToggleEntityFields(t),tap_target:"run"===a&&t.tapTarget||null,tap_confirm:!!t.tapConfirm||null,controls:o.length?o:null,...this._markerLightFields(t),...this._markerValueBadgeFields(t),...this._markerValueSourceFields(t),use_climate_temp:!!t.useClimateTemp||null,glow_radius_cm:(()=>{const e=kt(t.glowRadius);return null==e||e<=0?null:Math.round(this.host._imperial?30.48*e:100*e)})(),model:t.model.trim()||null,link:t.link.trim()||null,description:t.description.trim()||null,pdfs:t.pdfs,hidden:t.hideFromPlan,vacuum:i?.vacuum||null},r=!!i&&("string"==typeof i.area&&i.area.length>0||null===i.area&&!!i.space&&!!i.room_id);return"virtual"===t.binding||t.roomTouched?(n.space=e?.space||("virtual"===t.binding?this.host._space:null),n.area=e?.area||null,n.room_id=e?.roomId||null):r&&(n.space=i.space,n.area=i.area,n.room_id=i.room_id),n}_markerPreviewDevice(t){const e=this._markerDraft(t);if(!e)return null;const s=`${this.host._haRegistry.revision}\n${yt(this.host._markers)}\n${JSON.stringify(e)}`;if(this.host._markerPreviewMemo?.key===s)return this.host._markerPreviewMemo.device;const i=so({hass:this.host.hass,registry:this.host._haRegistry,areaToSpace:Object.fromEntries(Object.entries(this.host._areaToSpace).map(([t,e])=>[t,e.space])),marker:e,siblingMarkers:this.host._markers,settings:this.host._settings,excluded:this.host._excluded,showAll:this.host._showAll,firstSpaceId:this.host._model[0]?.id||this.host._space,loc:t=>this.host._t(t),iconRules:this.host._iconRules});return this.host._markerPreviewMemo={key:s,device:i},i}_markerPreviewDevices(t){const e=this.host._markerPreviewDevicesMemo;if(e?.base===this.host._devices&&e.preview===t)return e.devices;const s=[...this.host._devices.filter(e=>e.id!==t.id),t];return this.host._markerPreviewDevicesMemo={base:this.host._devices,preview:t,devices:s},s}_toggleIntent(t,e=this.host._devices){return this.host._toggleIntent(t,e)}_toggleIntentForDialog(t){const e=this._markerPreviewDevice(t);if(!e)return null;const s=this._markerPreviewDevices(e);return this._toggleIntent(e,s)}_toggleStateText(t,e){return this.host._toggleStateText(t,e)}_toggleConfirmationStateText(t){return this.host._toggleConfirmationStateText(t)}_toggleConfirmationLines(t){return this.host._toggleConfirmationLines(t)}_toggleHintLines(t){if(!t)return[];const e=t=>this.host._t(`marker.toggle_effect_${t.replace("-","_")}`),s=t=>this.host._t(`marker.toggle_skip_${t.replace("-","_")}`);return io(t,{single:t=>{if("via"in t&&"virtual-light"===t.via)return this.host._t("marker.virtual_light_target",{name:t.name});const e=t.entityId||("ref"in t?t.ref:""),s=t.name||e;return this.host._t("marker.toggle_hint_single",{name:s,id:e})},group:t=>this.host._t("marker.toggle_hint_group",{count:t.length,names:t.map(t=>`${t.name} (${t.entityId})`).join(", ")}),currentNext:(t,s)=>"virtual-light"===t.via?this.host._t("marker.virtual_light_current",{state:this.host._t("on"===t.state?"marker.virtual_light_state_on":"marker.virtual_light_state_off"),effect:e(s)}):this.host._t("marker.toggle_hint_current",{state:this._toggleStateText(t.entityId,t.state),effect:e(s)}),groupCurrentNext:(t,s)=>this.host._t("marker.toggle_hint_group_current",{on:t.filter(t=>"on"===t.state).length,count:t.length,effect:e(s)}),skipped:t=>this.host._t("marker.toggle_hint_skipped",{count:t.length,targets:t.map(t=>{const e=t.entityId||t.ref;return`${t.name||e} (${e}: ${s(t.reason)})`}).join(", ")}),none:t=>this.host._t(`marker.toggle_none_${t.replaceAll("-","_")}`)})}_effectiveStoredTapAction(t,e){return t.tapActionTouched?t.tapAction:oi(t.originalHasTapAction?t.originalTapAction:null,e)}_effectiveMarkerTapAction(t,e=this._markerPreviewDevice(t)){return this._effectiveStoredTapAction(t,e?.primary?.split(".")[0])}_announceToggleDraft(t){const e=this._markerPreviewDevice(t),s=t.tapActionTouched?t:{...t,tapAction:this._effectiveMarkerTapAction(t,e)},i="toggle"===s.tapAction?this._toggleHintLines(this._toggleIntentForDialog(s)).join(" "):"";return{...s,tapHintAnnouncement:i}}_valueBadgeForBinding(t,e){const s={...t,binding:e,valueBadgeEnabled:!1,valueBadgeSource:null,valueBadgeTouched:!0},i=this._markerPreviewDevice(s);if(!i)return{valueBadgeEnabled:!1,valueBadgeSource:null,valueBadgeTouched:!0};const o=[...this.host._devices.filter(t=>t.id!==i.id),i],a=m(this.host._planHass,i,o),n=f(this.host._planHass,i,a);return{valueBadgeEnabled:t.valueBadgeEnabled&&!!n,valueBadgeSource:n,valueBadgeTouched:!0}}_markerSpatialSource(t){const e=this._markerPreviewDevice(t);if(!e)return null;const s={...e,hidden:!1};return oo(ao(this.host._planHass,[...this.host._devices.filter(t=>t.id!==s.id),s],null,this.host._virtualLights).filter(t=>t.device.id===s.id))}_markerAutoHasSpatialSource(t){const e={...t,lightRole:"auto",lightRoleTouched:!0},s=this._markerPreviewDevice(e);return!!s&&no(this.host._planHass,{...s})}_setMarkerLightRole(t){const e=this.host._markerDialog;e&&(this.host._markerDialog={...e,lightRole:t,lightRoleTouched:!0})}_controlRefInfo(t){if(!t.startsWith("marker:"))return{label:this.host.hass.states[t]?.attributes?.friendly_name||t,sub:t,icon:t.startsWith("light.")?"mdi:lightbulb":"mdi:toggle-switch",warning:!this.host._planEntityAvailable(t)};const e=t.slice(7),s=this.host._markers.find(t=>t.id===e),i=this.host._devices.find(t=>t.id===e);if(!s||s.removed||!0!==s.is_light)return{label:this.host._t("marker.control_missing_label"),sub:`${this.host._t("marker.control_broken")} (${t})`,icon:"mdi:alert-outline",warning:!0};const o=this.host._serverCfg?.spaces.find(t=>t.id===(i?.space||s.space)),a=!!i&&$(i).length>0;return{label:s.name||i?.name||e,sub:[o?.title||i?.space||s.space,s.room_id||i?.area,a?"":this.host._t("marker.control_passive")].filter(Boolean).join(" · "),icon:s.icon||i?.icon||"mdi:lightbulb-outline",warning:!0===s.hidden||!0===i?.hidden}}_valueBadgeCandidateLabel(t){const e=t.source;if("derived_lqi"===e.kind)return this.host._t("marker.value_badge_lqi");if("derived_marker_state"===e.kind)return this.host._t("marker.value_badge_marker_state",{name:t.label});if("entity_state"===e.kind)return this.host._t("marker.value_badge_state",{name:t.label});const s=this.host.hass.states[e.entity_id]?.attributes?.friendly_name||this.host._fullRegistryHass.entities[e.entity_id]?.name||e.entity_id;return this.host._t(`marker.value_badge_attr_${e.attribute}`,{name:s})}_controlCandidates(t){const e=this._markerDraft(t)?.id||t.devId||"",s=[],i=new Set;for(const t of this.host._markers){if(t.id===e||t.removed||t.hidden||!0!==t.is_light)continue;if("virtual"!==t.binding&&"active"!==this.host._bindingStatus(t.binding).kind)continue;const o=this.host._devices.find(e=>e.id===t.id);if(!o||o.hidden)continue;const a=this._controlRefInfo(`marker:${t.id}`);for(const t of $(o))i.add(t);s.push({value:`marker:${t.id}`,label:a.label,sub:a.sub,icon:a.icon,search:`${a.label} ${a.sub} ${t.id} ${$(o).join(" ")}`.toLowerCase()})}const o=Object.keys(this.host.hass.states||{}).filter(e=>ro(e)&&!i.has(e)&&lo(t.binding,[e],this.host._bindingEntities(t.binding)).length>0&&this.host._planEntityAvailable(e)).map(t=>{const e=this._controlRefInfo(t);return{value:t,label:e.label,sub:t,icon:e.icon,search:`${e.label} ${t}`.toLowerCase()}}),a=t.controlsFilter.trim().toLowerCase();return[...s,...o].filter(e=>!t.controls.includes(e.value)&&(!a||e.search.includes(a))).slice(0,12).map(({search:t,...e})=>e)}_addControlRef(t,e){if(e.startsWith("marker:")){const s=this._markerDraft(t)?.id||t.devId||"";if(!s)return void this.host._showToast(this.host._t("toast.marker_binding_required"));const i=e.slice(7),o=this._markerDraft(t),a=o?[...this.host._markers.filter(t=>t.id!==s),o]:this.host._markers;if(ho(a,s,i))return void this.host._showToast(this.host._t("toast.marker_control_cycle"))}this.host._markerDialog=this._announceToggleDraft({...t,controls:[...t.controls,e],controlsFilter:""})}_setMarkerGlowMode(t){const e=this.host._markerDialog;if(!e)return;if("auto"===t)return void(this.host._markerDialog={...e,glowMode:t,glowTouched:!0});const s=this._markerSpatialSource(e),i=co(s?this.host._planHass.states[s.eid]:void 0,null,this.host._fillColors.glow_light.c),o=!e.glowColorDrafted,a="fixed"===t&&!e.glowBrightnessDrafted;this.host._markerDialog={...e,glowMode:t,glowColor:o?i.c:e.glowColor,glowBrightness:a?Math.max(1,Math.round(100*i.bri)):e.glowBrightness,glowColorDrafted:!0,glowBrightnessDrafted:e.glowBrightnessDrafted||"fixed"===t,glowTouched:!0}}_renderRadarSection(t,e,s="main"){return Fh({dialog:t,device:e,registryHass:this.host._fullRegistryHass,planHass:this.host._planHass,hass:this.host.hass,spaceModelById:t=>this.host._spaceModelById(t),currentSpace:()=>this.host._spaceModel(),position:t=>this.host._pos(t),updateDialog:t=>{this.host._markerDialog&&(this.host._markerDialog={...this.host._markerDialog,...t})},dialogDeviceId:()=>this.host._markerDialog?.devId,t:(t,e)=>this.host._t(t,e),help:t=>this._help(t),boolInput:(t,e)=>this._boolInput(t,e),toast:t=>this.host._showToast(t),setup:this._radarSetup,configRev:this.host._cfgRev},s)}_renderMarkerDialog(){return _a.call(this)}_renderSpaceDialog(){return er.call(this)}_renderMergeDialog(){const t=this.host._mergeDialog,e=this.host._spaceModel()?.rooms||[],s=(s,i)=>{const o=e.find(t=>t.id===s),a=o?.area?this.host.hass.areas[o.area]?.name:null;return p`
    `}_markerValueBadgeFields(t){return to({touched:t.valueBadgeTouched,originalHas:t.originalHasValueBadge,original:t.originalValueBadge,enabled:t.valueBadgeEnabled,source:t.valueBadgeSource,position:t.valueBadgePosition})}_markerValueSourceFields(t){return eo({touched:t.valueSourceTouched,originalHas:t.originalHasValueSource,original:t.originalValueSource,source:t.valueSource})}_markerDraft(t){if("ha"===t.bindingMode&&(!t.binding||"virtual"===t.binding))return null;const e=M(t.room),s=si(t.binding,t.devId,()=>"__hp_device_preview__"),i=this.host._markers.find(e=>e.id===s||e.id===t.devId),o=x(t.binding,t.controls,this.host._bindingEntities(t.binding)),a=this._effectiveStoredTapAction(t),n={id:s,binding:t.binding,name:t.name.trim()||null,icon:t.icon||null,display:"badge"!==t.display?t.display:null,ripple_color:"icon_ripple"===t.display&&t.rippleColor?t.rippleColor:null,ripple_size:"icon_ripple"===t.display&&1.5!==t.rippleSize?t.rippleSize:null,size:1!==t.size?t.size:null,angle:t.angle||null,...this._markerTapActionFields(t),...this._markerToggleEntityFields(t),tap_target:"run"===a&&t.tapTarget||null,tap_confirm:!!t.tapConfirm||null,controls:o.length?o:null,...this._markerLightFields(t),...this._markerValueBadgeFields(t),...this._markerValueSourceFields(t),use_climate_temp:!!t.useClimateTemp||null,glow_radius_cm:(()=>{const e=kt(t.glowRadius);return null==e||e<=0?null:Math.round(this.host._imperial?30.48*e:100*e)})(),model:t.model.trim()||null,link:t.link.trim()||null,description:t.description.trim()||null,pdfs:t.pdfs,hidden:t.hideFromPlan,vacuum:i?.vacuum||null},r=!!i&&("string"==typeof i.area&&i.area.length>0||null===i.area&&!!i.space&&!!i.room_id);return"virtual"===t.binding||t.roomTouched?(n.space=e?.space||("virtual"===t.binding?this.host._space:null),n.area=e?.area||null,n.room_id=e?.roomId||null):r&&(n.space=i.space,n.area=i.area,n.room_id=i.room_id),n}_markerPreviewDevice(t){const e=this._markerDraft(t);if(!e)return null;const s=`${this.host._haRegistry.revision}\n${yt(this.host._markers)}\n${JSON.stringify(e)}`;if(this.host._markerPreviewMemo?.key===s)return this.host._markerPreviewMemo.device;const i=so({hass:this.host.hass,registry:this.host._haRegistry,areaToSpace:Object.fromEntries(Object.entries(this.host._areaToSpace).map(([t,e])=>[t,e.space])),marker:e,siblingMarkers:this.host._markers,settings:this.host._settings,excluded:this.host._excluded,showAll:this.host._showAll,firstSpaceId:this.host._model[0]?.id||this.host._space,loc:t=>this.host._t(t),iconRules:this.host._iconRules});return this.host._markerPreviewMemo={key:s,device:i},i}_markerPreviewDevices(t){const e=this.host._markerPreviewDevicesMemo;if(e?.base===this.host._devices&&e.preview===t)return e.devices;const s=[...this.host._devices.filter(e=>e.id!==t.id),t];return this.host._markerPreviewDevicesMemo={base:this.host._devices,preview:t,devices:s},s}_toggleIntent(t,e=this.host._devices){return this.host._toggleIntent(t,e)}_toggleIntentForDialog(t){const e=this._markerPreviewDevice(t);if(!e)return null;const s=this._markerPreviewDevices(e);return this._toggleIntent(e,s)}_toggleStateText(t,e){return this.host._toggleStateText(t,e)}_toggleConfirmationStateText(t){return this.host._toggleConfirmationStateText(t)}_toggleConfirmationLines(t){return this.host._toggleConfirmationLines(t)}_toggleHintLines(t){if(!t)return[];const e=t=>this.host._t(`marker.toggle_effect_${t.replace("-","_")}`),s=t=>this.host._t(`marker.toggle_skip_${t.replace("-","_")}`);return io(t,{single:t=>{if("via"in t&&"virtual-light"===t.via)return this.host._t("marker.virtual_light_target",{name:t.name});const e=t.entityId||("ref"in t?t.ref:""),s=t.name||e;return this.host._t("marker.toggle_hint_single",{name:s,id:e})},group:t=>this.host._t("marker.toggle_hint_group",{count:t.length,names:t.map(t=>`${t.name} (${t.entityId})`).join(", ")}),currentNext:(t,s)=>"virtual-light"===t.via?this.host._t("marker.virtual_light_current",{state:this.host._t("on"===t.state?"marker.virtual_light_state_on":"marker.virtual_light_state_off"),effect:e(s)}):this.host._t("marker.toggle_hint_current",{state:this._toggleStateText(t.entityId,t.state),effect:e(s)}),groupCurrentNext:(t,s)=>this.host._t("marker.toggle_hint_group_current",{on:t.filter(t=>"on"===t.state).length,count:t.length,effect:e(s)}),skipped:t=>this.host._t("marker.toggle_hint_skipped",{count:t.length,targets:t.map(t=>{const e=t.entityId||t.ref;return`${t.name||e} (${e}: ${s(t.reason)})`}).join(", ")}),none:t=>this.host._t(`marker.toggle_none_${t.replaceAll("-","_")}`)})}_effectiveStoredTapAction(t,e){return t.tapActionTouched?t.tapAction:oi(t.originalHasTapAction?t.originalTapAction:null,e)}_effectiveMarkerTapAction(t,e=this._markerPreviewDevice(t)){return this._effectiveStoredTapAction(t,e?.primary?.split(".")[0])}_announceToggleDraft(t){const e=this._markerPreviewDevice(t),s=t.tapActionTouched?t:{...t,tapAction:this._effectiveMarkerTapAction(t,e)},i="toggle"===s.tapAction?this._toggleHintLines(this._toggleIntentForDialog(s)).join(" "):"";return{...s,tapHintAnnouncement:i}}_valueBadgeForBinding(t,e){const s={...t,binding:e,valueBadgeEnabled:!1,valueBadgeSource:null,valueBadgeTouched:!0},i=this._markerPreviewDevice(s);if(!i)return{valueBadgeEnabled:!1,valueBadgeSource:null,valueBadgeTouched:!0};const o=[...this.host._devices.filter(t=>t.id!==i.id),i],a=m(this.host._planHass,i,o),n=f(this.host._planHass,i,a);return{valueBadgeEnabled:t.valueBadgeEnabled&&!!n,valueBadgeSource:n,valueBadgeTouched:!0}}_markerSpatialSource(t){const e=this._markerPreviewDevice(t);if(!e)return null;const s={...e,hidden:!1};return oo(ao(this.host._planHass,[...this.host._devices.filter(t=>t.id!==s.id),s],null,this.host._virtualLights).filter(t=>t.device.id===s.id))}_markerAutoHasSpatialSource(t){const e={...t,lightRole:"auto",lightRoleTouched:!0},s=this._markerPreviewDevice(e);return!!s&&no(this.host._planHass,{...s})}_setMarkerLightRole(t){const e=this.host._markerDialog;e&&(this.host._markerDialog={...e,lightRole:t,lightRoleTouched:!0})}_controlRefInfo(t){if(!t.startsWith("marker:"))return{label:this.host.hass.states[t]?.attributes?.friendly_name||t,sub:t,icon:t.startsWith("light.")?"mdi:lightbulb":"mdi:toggle-switch",warning:!this.host._planEntityAvailable(t)};const e=t.slice(7),s=this.host._markers.find(t=>t.id===e),i=this.host._devices.find(t=>t.id===e);if(!s||s.removed||!0!==s.is_light)return{label:this.host._t("marker.control_missing_label"),sub:`${this.host._t("marker.control_broken")} (${t})`,icon:"mdi:alert-outline",warning:!0};const o=this.host._serverCfg?.spaces.find(t=>t.id===(i?.space||s.space)),a=!!i&&$(i).length>0;return{label:s.name||i?.name||e,sub:[o?.title||i?.space||s.space,s.room_id||i?.area,a?"":this.host._t("marker.control_passive")].filter(Boolean).join(" · "),icon:s.icon||i?.icon||"mdi:lightbulb-outline",warning:!0===s.hidden||!0===i?.hidden}}_valueBadgeCandidateLabel(t){const e=t.source;if("derived_lqi"===e.kind)return this.host._t("marker.value_badge_lqi");if("derived_marker_state"===e.kind)return this.host._t("marker.value_badge_marker_state",{name:t.label});if("entity_state"===e.kind)return this.host._t("marker.value_badge_state",{name:t.label});const s=this.host.hass.states[e.entity_id]?.attributes?.friendly_name||this.host._fullRegistryHass.entities[e.entity_id]?.name||e.entity_id;return this.host._t(`marker.value_badge_attr_${e.attribute}`,{name:s})}_controlCandidates(t){const e=this._markerDraft(t)?.id||t.devId||"",s=[],i=new Set;for(const t of this.host._markers){if(t.id===e||t.removed||t.hidden||!0!==t.is_light)continue;if("virtual"!==t.binding&&"active"!==this.host._bindingStatus(t.binding).kind)continue;const o=this.host._devices.find(e=>e.id===t.id);if(!o||o.hidden)continue;const a=this._controlRefInfo(`marker:${t.id}`);for(const t of $(o))i.add(t);s.push({value:`marker:${t.id}`,label:a.label,sub:a.sub,icon:a.icon,search:`${a.label} ${a.sub} ${t.id} ${$(o).join(" ")}`.toLowerCase()})}const o=Object.keys(this.host.hass.states||{}).filter(e=>ro(e)&&!i.has(e)&&lo(t.binding,[e],this.host._bindingEntities(t.binding)).length>0&&this.host._planEntityAvailable(e)).map(t=>{const e=this._controlRefInfo(t);return{value:t,label:e.label,sub:t,icon:e.icon,search:`${e.label} ${t}`.toLowerCase()}}),a=t.controlsFilter.trim().toLowerCase();return[...s,...o].filter(e=>!t.controls.includes(e.value)&&(!a||e.search.includes(a))).slice(0,12).map(({search:t,...e})=>e)}_addControlRef(t,e){if(e.startsWith("marker:")){const s=this._markerDraft(t)?.id||t.devId||"";if(!s)return void this.host._showToast(this.host._t("toast.marker_binding_required"));const i=e.slice(7),o=this._markerDraft(t),a=o?[...this.host._markers.filter(t=>t.id!==s),o]:this.host._markers;if(ho(a,s,i))return void this.host._showToast(this.host._t("toast.marker_control_cycle"))}this.host._markerDialog=this._announceToggleDraft({...t,controls:[...t.controls,e],controlsFilter:""})}_setMarkerGlowMode(t){const e=this.host._markerDialog;if(!e)return;if("auto"===t)return void(this.host._markerDialog={...e,glowMode:t,glowTouched:!0});const s=this._markerSpatialSource(e),i=co(s?this.host._planHass.states[s.eid]:void 0,null,this.host._fillColors.glow_light.c),o=!e.glowColorDrafted,a="fixed"===t&&!e.glowBrightnessDrafted;this.host._markerDialog={...e,glowMode:t,glowColor:o?i.c:e.glowColor,glowBrightness:a?Math.max(1,Math.round(100*i.bri)):e.glowBrightness,glowColorDrafted:!0,glowBrightnessDrafted:e.glowBrightnessDrafted||"fixed"===t,glowTouched:!0}}_renderRadarSection(t,e,s="main"){return Nh({dialog:t,device:e,registryHass:this.host._fullRegistryHass,planHass:this.host._planHass,hass:this.host.hass,spaceModelById:t=>this.host._spaceModelById(t),currentSpace:()=>this.host._spaceModel(),position:t=>this.host._pos(t),updateDialog:t=>{this.host._markerDialog&&(this.host._markerDialog={...this.host._markerDialog,...t})},dialogDeviceId:()=>this.host._markerDialog?.devId,t:(t,e)=>this.host._t(t,e),help:t=>this._help(t),boolInput:(t,e)=>this._boolInput(t,e),toast:t=>this.host._showToast(t),setup:this._radarSetup,configRev:this.host._cfgRev},s)}_renderMarkerDialog(){return ga.call(this)}_renderSpaceDialog(){return sr.call(this)}_renderMergeDialog(){const t=this.host._mergeDialog,e=this.host._spaceModel()?.rooms||[],s=(s,i)=>{const o=e.find(t=>t.id===s),a=o?.area?this.host.hass.areas[o.area]?.name:null;return p`
    `}_renderRoomDialog(){return nr.call(this)}}export{Md as EDITOR_RUNTIME_FINGERPRINT,Cd as HouseplanEditorRuntime}; + `}_renderRoomDialog(){return rr.call(this)}}export{Cd as EDITOR_RUNTIME_FINGERPRINT,Sd as HouseplanEditorRuntime}; diff --git a/custom_components/houseplan/frontend/houseplan-assets/houseplan-onboarding-runtime-BAx8bJB2.js b/custom_components/houseplan/frontend/houseplan-assets/houseplan-onboarding-runtime-G7DfDSe_.js similarity index 98% rename from custom_components/houseplan/frontend/houseplan-assets/houseplan-onboarding-runtime-BAx8bJB2.js rename to custom_components/houseplan/frontend/houseplan-assets/houseplan-onboarding-runtime-G7DfDSe_.js index 114b5534..4965470e 100644 --- a/custom_components/houseplan/frontend/houseplan-assets/houseplan-onboarding-runtime-BAx8bJB2.js +++ b/custom_components/houseplan/frontend/houseplan-assets/houseplan-onboarding-runtime-G7DfDSe_.js @@ -1,4 +1,4 @@ -globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db7c58754eeb4ba03f835b8d7c84c6";import{l as t,bw as s,A as e,aL as a,c as o,g as l,cK as i,ar as h,am as c,au as n,cL as r,cQ as p,cM as d,cN as _,cO as u,cP as g,cR as m,cS as b,al as $,ao as v,ap as f,as as y,at as w,aq as D}from"./houseplan-card-BiUNLHFh.js";import{c as k,e as S,r as C,a as M}from"./backdrop-pick-Ev52LRir.js";const F=1e3,x=t=>{if(!t.trim())return null;const s=Number(t.replace(",","."));return Number.isFinite(s)?s:null},T="ed91b3971428d2b8e7bfceb8025d2be4c0db7c58754eeb4ba03f835b8d7c84c6";class L{constructor(t){this.host=t,this._toggleServerPlans=async()=>{const t=this.host._spaceDialog;if(t)if(t.pickSaved)this.host._spaceDialog={...t,pickSaved:!1};else{this.host._spaceDialog={...t,pickSaved:!0,savedBusy:!0};try{const t=await this.host.hass.callWS({type:"houseplan/plans/list"}),s=this.host._spaceDialog;s&&(this.host._spaceDialog={...s,saved:t?.plans||[],savedBusy:!1})}catch(t){const s=this.host._spaceDialog;s&&(this.host._spaceDialog={...s,saved:[],savedBusy:!1}),this.host._showToast(this.host._t("toast.plans_list_failed",{err:this.host._errText(t)}))}}}}_help(l){const i=`${l}.aria`,h=t(this.host.hass,this.host._config?.language);return s(h,l)&&s(h,i)?o`{if(!t.trim())return null;const s=Number(t.replace(",","."));return Number.isFinite(s)?s:null},T="d31b0b1e184ab2863684b758f839bdb6809a33cc742c6e9bb36c5ea034e3d309";class L{constructor(t){this.host=t,this._toggleServerPlans=async()=>{const t=this.host._spaceDialog;if(t)if(t.pickSaved)this.host._spaceDialog={...t,pickSaved:!1};else{this.host._spaceDialog={...t,pickSaved:!0,savedBusy:!0};try{const t=await this.host.hass.callWS({type:"houseplan/plans/list"}),s=this.host._spaceDialog;s&&(this.host._spaceDialog={...s,saved:t?.plans||[],savedBusy:!1})}catch(t){const s=this.host._spaceDialog;s&&(this.host._spaceDialog={...s,saved:[],savedBusy:!1}),this.host._showToast(this.host._t("toast.plans_list_failed",{err:this.host._errText(t)}))}}}}_help(l){const i=`${l}.aria`,h=t(this.host.hass,this.host._config?.language);return s(h,l)&&s(h,i)?o``:e}_openSpaceDialog(t,s){if(!this.host._serverStorage||!this.host._serverCfg)return void this.host._showToast(this.host._t("toast.integration_missing"));if("edit"===t){const e=this.host._serverCfg.spaces.find(t=>t.id===s);if(!e)return;const a=l(e),o=e.settings?.custom_fill&&"object"==typeof e.settings.custom_fill?i(e.settings.custom_fill):null,p="none"===a.fill?{...o||h,a:0}:o;return void(this.host._spaceDialog={mode:t,spaceId:s,title:e.title,planUrl:e.plan_url||null,planFile:null,source:e.plan_url?"file":"draw",showBorders:a.showBorders,showNames:a.showNames,zeroWallStyle:r(e),displayTouched:!0,hideDecor:a.hideDecor,hideOpenings:a.hideOpenings,roomColor:a.color,roomOpacity:a.opacity,fillMode:"none"===a.fill?"custom":a.fill,customFill:p,glowEnabled:a.glow,bgColor:a.bgColor,bgMode:"static"===e.settings?.bg_mode||"daynight"===e.settings?.bg_mode?e.settings.bg_mode:null,northDeg:n({},e.settings),sunRays:"boolean"==typeof e.settings?.sun_rays?e.settings.sun_rays:null,tempMin:a.tempMin,tempMax:a.tempMax,showLqi:a.showLqi??this.host._config?.show_signal??!0,cardFontScale:a.cardFontScale,labelTemp:a.labelTemp,labelHum:a.labelHum,labelLqi:a.labelLqi,labelLight:a.labelLight,cellCm:Number(e.cell_cm)>0?Number(e.cell_cm):5,cellCmInput:c(Number(e.cell_cm)>0?Number(e.cell_cm):5,this.host._imperial),cellCmTouched:!1,busy:!1})}const e=p(this.host._imperial);this.host._spaceDialog={mode:t,title:"",planUrl:null,planFile:null,...m(),hideDecor:!1,hideOpenings:!1,zeroWallStyle:"dashed",roomColor:g,roomOpacity:u,fillMode:"custom",customFill:{...h,a:0},glowEnabled:!0,bgColor:null,bgMode:"daynight",northDeg:null,sunRays:null,tempMin:_,tempMax:d,showLqi:this.host._config?.show_signal??!0,cardFontScale:1,labelTemp:!1,labelHum:!1,labelLqi:!1,labelLight:!1,cellCm:e,cellCmInput:c(e,this.host._imperial),cellCmTouched:!1,busy:!1}}async _pickPlanFile(t){const s=t.target,e=s.files?.[0];if(!e||!this.host._spaceDialog)return;s.value="";const a=await k(e);if("reject"===a.kind)return void this.host._showToast(this.host._t("toast.plan_formats"));if("guard"===a.kind)return void(this.host._backdropGuard=a.state);const o=await S(e,a.ext,e.name);this.host._spaceDialog&&(this.host._spaceDialog={...this.host._spaceDialog,planFile:o})}_renderBackdropGuard(){return C(this.host,t=>{this.host._spaceDialog&&(this.host._spaceDialog={...this.host._spaceDialog,planFile:t})},()=>{this.host._backdropGuard=null},this.host.hass)??e}_useServerPlan(t){const s=this.host._spaceDialog;s&&(this.host._spaceDialog={...s,planUrl:t,planFile:null,pickSaved:!1,savedAspect:void 0},this.host._aspectJob=this._readPlanAspect(t))}async _readPlanAspect(t){for(let s=0;s<40;s++){const s=this.host._display(t);if(s){const e=await new Promise(t=>{const e=new Image;e.onload=()=>t(e.naturalWidth&&e.naturalHeight?e.naturalWidth/e.naturalHeight:0),e.onerror=()=>t(0),e.src=s}),a=this.host._spaceDialog;return a&&a.planUrl===t&&Number.isFinite(e)&&e>0?(this.host._spaceDialog={...a,savedAspect:e},e):0}if(await new Promise(t=>setTimeout(t,150)),this.host._spaceDialog?.planUrl!==t)return 0}return 0}async _deleteServerPlan(t){const s=this.host._spaceDialog,e=s?.saved?.find(s=>s.name===t);if(!s||!e||e.used_by.length||e.url===s.planUrl)return;const a=await this.host._confirmDanger({key:"delete-plan",kind:"destructive",title:this.host._t("confirm.delete_plan_title"),message:this.host._t("confirm.delete_plan_body"),objectName:t,confirmLabel:this.host._t("btn.delete"),cancelLabel:this.host._t("btn.cancel")}),o=this.host._spaceDialog,l=o?.saved?.find(s=>s.name===t);if(a&&o&&l&&l.url===e.url&&l.modified===e.modified&&!l.used_by.length&&l.url!==o.planUrl)try{await this.host.hass.callWS({type:"houseplan/plans/delete",name:t});const s=this.host._spaceDialog;s?.saved&&(this.host._spaceDialog={...s,saved:s.saved.filter(s=>s.name!==t)})}catch(t){this.host._showToast(this.host._t("toast.plan_delete_failed",{err:this.host._errText(t)}))}}_renderServerPlans(t){if(t.savedBusy)return o`
    ${this.host._t("space.loading")}
    `;const s=t.saved||[];if(!s.length)return o`
    ${this.host._t("space.no_saved")}
    `;return o`
    ${s.map(s=>{return o`
    diff --git a/custom_components/houseplan/frontend/houseplan-assets/hp-zigbee-topology-overlay-SYVcVGiq.js b/custom_components/houseplan/frontend/houseplan-assets/hp-zigbee-topology-overlay-CAehZ6TG.js similarity index 97% rename from custom_components/houseplan/frontend/houseplan-assets/hp-zigbee-topology-overlay-SYVcVGiq.js rename to custom_components/houseplan/frontend/houseplan-assets/hp-zigbee-topology-overlay-CAehZ6TG.js index 1abff8cc..2d9a4cd3 100644 --- a/custom_components/houseplan/frontend/houseplan-assets/hp-zigbee-topology-overlay-SYVcVGiq.js +++ b/custom_components/houseplan/frontend/houseplan-assets/hp-zigbee-topology-overlay-CAehZ6TG.js @@ -1,4 +1,4 @@ -globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db7c58754eeb4ba03f835b8d7c84c6";import{aI as e,l as t,A as i,eb as r,aB as o,c as s,aH as n}from"./houseplan-card-BiUNLHFh.js";import{t as a,a as h,r as d}from"./zigbee-topology-B31-i8CL.js";import{zigbeeTopologyRuntimeSnapshot as p,subscribeZigbeeTopology as l}from"./zigbee-topology-runtime-CuXFHyzq.js";function c(e,t,i,r,o,s=9,n=4.5){const a=t.x-e.x,h=t.y-e.y,d=Math.hypot(a,h),p=d-Math.max(0,i)-Math.max(0,r);if(!Number.isFinite(d)||d<=0||p<4)return null;const l=a/d,c=h/d,_="toward-neighbor"===o,u=_?{x:t.x-l*Math.max(0,r),y:t.y-c*Math.max(0,r)}:{x:e.x+l*Math.max(0,i),y:e.y+c*Math.max(0,i)},b=Math.min(s,Math.max(4,.45*p)),m=Math.min(n,.5*b),v=_?-1:1,g=u.x+l*b*v,y=u.y+c*b*v,x=-c;return{tip:u,points:[u,{x:g+x*m,y:y+l*m},{x:g-x*m,y:y-l*m}]}}const _={revision:0,topologies:[],states:{}},u="data-hp-zigbee-topology-endpoint";class b extends e{constructor(){super(...arguments),this.devices=[],this.currentSpace="",this._runtime=_,this._hovered="",this._desiredEndpointIds=new Set,this._endpointSetDirty=!1,this._endpointElements=new Set,this._pointerOver=e=>{if(!this._mouseAllowed(e))return void this._clear();const t=this._deviceFromEvent(e),i=t?.dataset.id||"";i&&i!==this._hovered&&(this._hovered=i,this.requestUpdate())},this._pointerOut=e=>{const t=this._deviceFromEvent(e);if(!t||t.dataset.id!==this._hovered)return;const i=e.relatedTarget instanceof Element?e.relatedTarget.closest('[data-hp="device"]'):null;i?.dataset.id!==this._hovered&&this._clear()},this._pointerDown=e=>{"mouse"!==e.pointerType&&this._clear()}}connectedCallback(){super.connectedCallback();const e=this.getRootNode();e.host&&"undefined"!=typeof MutationObserver&&(this._hoverGateObserver=new MutationObserver(()=>{e.host.hasAttribute("data-pointer-hover")||this._clear()}),this._hoverGateObserver.observe(e.host,{attributes:!0,attributeFilter:["data-pointer-hover"]})),queueMicrotask(()=>this._connectParent())}disconnectedCallback(){this._release?.(),this._release=void 0,this._disconnectParent(),this._hoverGateObserver?.disconnect(),this._hoverGateObserver=void 0,this._hovered="",this._desiredEndpointIds.clear(),super.disconnectedCallback()}updated(e){e.has("hass")&&(this._release?.(),this._acceptRuntime(p(this.hass)),this._release=l(this.hass,()=>{this._acceptRuntime(p(this.hass))}));const t=e.has("currentSpace")||e.has("devices")||e.has("registry");t&&(this._mappedMemo=void 0,this.devices.some(e=>e.id===this._hovered&&e.space===this.currentSpace)||this._clear()),this._connectParent(),(this._endpointSetDirty||t)&&this._syncEndpointOwnership()}_acceptRuntime(e){e.revision===this._runtime.revision&&e.topologies===this._runtime.topologies&&e.states===this._runtime.states||(this._setDesiredEndpointIds([]),this._clearEndpointOwnership(),this._endpointSetDirty=!1,this._runtime=e,this._mappedMemo=void 0,this.requestUpdate())}_connectParent(){const e=this.parentElement;e&&e!==this._parent&&(this._disconnectParent(),this._parent=e,e.addEventListener("pointerover",this._pointerOver),e.addEventListener("pointerout",this._pointerOut),e.addEventListener("pointerdown",this._pointerDown,!0),"undefined"!=typeof MutationObserver&&(this._markerObserver=new MutationObserver(()=>this._syncEndpointOwnership()),this._markerObserver.observe(e,{childList:!0})),this._syncEndpointOwnership())}_disconnectParent(){this._parent?.removeEventListener("pointerover",this._pointerOver),this._parent?.removeEventListener("pointerout",this._pointerOut),this._parent?.removeEventListener("pointerdown",this._pointerDown,!0),this._markerObserver?.disconnect(),this._markerObserver=void 0,this._clearEndpointOwnership(),this._parent=void 0}_deviceFromEvent(e){for(const t of e.composedPath())if(t instanceof HTMLElement&&"device"===t.dataset.hp)return t;return null}_mouseAllowed(e){const t=this.getRootNode();return"mouse"===e.pointerType&&t.host?.hasAttribute?.("data-pointer-hover")}_clear(){this._setDesiredEndpointIds([]),this._clearEndpointOwnership(),this._endpointSetDirty=!1,this._hovered&&(this._hovered="",this.requestUpdate())}_setDesiredEndpointIds(e){const t=new Set(e);t.size===this._desiredEndpointIds.size&&[...t].every(e=>this._desiredEndpointIds.has(e))||(this._desiredEndpointIds=t,this._endpointSetDirty=!0)}_marker(e){return[...this._parent?.querySelectorAll('.dev[data-hp="device"][data-id]')||[]].find(t=>t.dataset.id===e)||null}_clearEndpointOwnership(){for(const e of this._endpointElements)e.removeAttribute(u);for(const e of this._parent?.querySelectorAll(`[${u}]`)||[])e.removeAttribute(u);this._endpointElements.clear()}_syncEndpointOwnership(){const e=new Set;for(const t of this._desiredEndpointIds){const i=this._marker(t);i&&e.add(i)}for(const t of this._endpointElements)e.has(t)||t.removeAttribute(u);for(const t of this._parent?.querySelectorAll(`[${u}]`)||[])e.has(t)||t.removeAttribute(u);for(const t of e)this._endpointElements.has(t)&&t.hasAttribute(u)||t.setAttribute(u,"");this._endpointElements=e,this._endpointSetDirty=!1}_position(e,t,i){const r=this._marker(e);if(!r)return null;const o=Number.parseFloat(r.style.left),s=Number.parseFloat(r.style.top),n=r.getBoundingClientRect();return Number.isFinite(o)&&Number.isFinite(s)?{x:o*t/100,y:s*i/100,width:n.width,height:n.height}:null}_targetText(e){if("remote-space"===e.kind){const i=this.spaces?.find(t=>t.id===e.spaceId)?.title;return"string"==typeof i&&i.trim()||a(t(this.hass),"route_other_space")}return a(t(this.hass),"unplaced-coordinator"===e.kind?"route_coordinator_not_on_plan":"route_device_not_on_plan")}_markerClearance(e){return.61*Math.max(e.width,e.height)+3}_points(e){return e.map(e=>`${e.x.toFixed(2)},${e.y.toFixed(2)}`).join(" ")}render(){if(!this._hovered||!this.registry||!this._runtime.topologies.length)return this._setDesiredEndpointIds([]),i;const e=this._mappedMemo,n=e&&e.runtime===this._runtime&&e.devices===this.devices&&e.registry===this.registry?e.mapped:h(this._runtime.topologies,this.devices,this.registry);e&&n===e.mapped||(this._mappedMemo={runtime:this._runtime,devices:this.devices,registry:this.registry,mapped:n});const p=d(n,this.currentSpace,this._hovered),l=this.clientWidth||this._parent?.clientWidth||1,_=this.clientHeight||this._parent?.clientHeight||1,u=this._position(this._hovered,l,_);if(!u)return this._setDesiredEndpointIds([]),i;const b=p.lines.map(e=>({...e,point:this._position(e.neighborMarkerId,l,_)})).filter(e=>!!e.point).map(e=>{const t=void 0===e.lqi?"rgba(145,155,165,.85)":r(e.lqi),i=e.routeDirection?c(u,e.point,this._markerClearance(u),this._markerClearance(e.point),e.routeDirection):null;return{...e,color:t,arrow:i}}),m=u.x>l/2,v=this._markerClearance(u)+18,g=p.parentTargets.map((e,t)=>{const i=30*(t-(p.parentTargets.length-1)/2),r={x:u.x+(m?-v:v),y:Math.max(14,Math.min(_-14,u.y+i))};return{target:e,point:r,arrow:c(u,r,this._markerClearance(u),0,"toward-neighbor")}});return this._setDesiredEndpointIds(b.length||g.length||p.remoteCount?[this._hovered,...b.map(e=>e.neighborMarkerId)]:[]),s` +globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="d31b0b1e184ab2863684b758f839bdb6809a33cc742c6e9bb36c5ea034e3d309";import{aI as e,l as t,A as i,eb as r,aB as o,c as s,aH as n}from"./houseplan-card-W9mG3gab.js";import{t as a,a as h,r as d}from"./zigbee-topology-3KJks91U.js";import{zigbeeTopologyRuntimeSnapshot as p,subscribeZigbeeTopology as l}from"./zigbee-topology-runtime-DvCmPEhl.js";function c(e,t,i,r,o,s=9,n=4.5){const a=t.x-e.x,h=t.y-e.y,d=Math.hypot(a,h),p=d-Math.max(0,i)-Math.max(0,r);if(!Number.isFinite(d)||d<=0||p<4)return null;const l=a/d,c=h/d,_="toward-neighbor"===o,u=_?{x:t.x-l*Math.max(0,r),y:t.y-c*Math.max(0,r)}:{x:e.x+l*Math.max(0,i),y:e.y+c*Math.max(0,i)},b=Math.min(s,Math.max(4,.45*p)),m=Math.min(n,.5*b),v=_?-1:1,g=u.x+l*b*v,y=u.y+c*b*v,x=-c;return{tip:u,points:[u,{x:g+x*m,y:y+l*m},{x:g-x*m,y:y-l*m}]}}const _={revision:0,topologies:[],states:{}},u="data-hp-zigbee-topology-endpoint";class b extends e{constructor(){super(...arguments),this.devices=[],this.currentSpace="",this._runtime=_,this._hovered="",this._desiredEndpointIds=new Set,this._endpointSetDirty=!1,this._endpointElements=new Set,this._pointerOver=e=>{if(!this._mouseAllowed(e))return void this._clear();const t=this._deviceFromEvent(e),i=t?.dataset.id||"";i&&i!==this._hovered&&(this._hovered=i,this.requestUpdate())},this._pointerOut=e=>{const t=this._deviceFromEvent(e);if(!t||t.dataset.id!==this._hovered)return;const i=e.relatedTarget instanceof Element?e.relatedTarget.closest('[data-hp="device"]'):null;i?.dataset.id!==this._hovered&&this._clear()},this._pointerDown=e=>{"mouse"!==e.pointerType&&this._clear()}}connectedCallback(){super.connectedCallback();const e=this.getRootNode();e.host&&"undefined"!=typeof MutationObserver&&(this._hoverGateObserver=new MutationObserver(()=>{e.host.hasAttribute("data-pointer-hover")||this._clear()}),this._hoverGateObserver.observe(e.host,{attributes:!0,attributeFilter:["data-pointer-hover"]})),queueMicrotask(()=>this._connectParent())}disconnectedCallback(){this._release?.(),this._release=void 0,this._disconnectParent(),this._hoverGateObserver?.disconnect(),this._hoverGateObserver=void 0,this._hovered="",this._desiredEndpointIds.clear(),super.disconnectedCallback()}updated(e){e.has("hass")&&(this._release?.(),this._acceptRuntime(p(this.hass)),this._release=l(this.hass,()=>{this._acceptRuntime(p(this.hass))}));const t=e.has("currentSpace")||e.has("devices")||e.has("registry");t&&(this._mappedMemo=void 0,this.devices.some(e=>e.id===this._hovered&&e.space===this.currentSpace)||this._clear()),this._connectParent(),(this._endpointSetDirty||t)&&this._syncEndpointOwnership()}_acceptRuntime(e){e.revision===this._runtime.revision&&e.topologies===this._runtime.topologies&&e.states===this._runtime.states||(this._setDesiredEndpointIds([]),this._clearEndpointOwnership(),this._endpointSetDirty=!1,this._runtime=e,this._mappedMemo=void 0,this.requestUpdate())}_connectParent(){const e=this.parentElement;e&&e!==this._parent&&(this._disconnectParent(),this._parent=e,e.addEventListener("pointerover",this._pointerOver),e.addEventListener("pointerout",this._pointerOut),e.addEventListener("pointerdown",this._pointerDown,!0),"undefined"!=typeof MutationObserver&&(this._markerObserver=new MutationObserver(()=>this._syncEndpointOwnership()),this._markerObserver.observe(e,{childList:!0})),this._syncEndpointOwnership())}_disconnectParent(){this._parent?.removeEventListener("pointerover",this._pointerOver),this._parent?.removeEventListener("pointerout",this._pointerOut),this._parent?.removeEventListener("pointerdown",this._pointerDown,!0),this._markerObserver?.disconnect(),this._markerObserver=void 0,this._clearEndpointOwnership(),this._parent=void 0}_deviceFromEvent(e){for(const t of e.composedPath())if(t instanceof HTMLElement&&"device"===t.dataset.hp)return t;return null}_mouseAllowed(e){const t=this.getRootNode();return"mouse"===e.pointerType&&t.host?.hasAttribute?.("data-pointer-hover")}_clear(){this._setDesiredEndpointIds([]),this._clearEndpointOwnership(),this._endpointSetDirty=!1,this._hovered&&(this._hovered="",this.requestUpdate())}_setDesiredEndpointIds(e){const t=new Set(e);t.size===this._desiredEndpointIds.size&&[...t].every(e=>this._desiredEndpointIds.has(e))||(this._desiredEndpointIds=t,this._endpointSetDirty=!0)}_marker(e){return[...this._parent?.querySelectorAll('.dev[data-hp="device"][data-id]')||[]].find(t=>t.dataset.id===e)||null}_clearEndpointOwnership(){for(const e of this._endpointElements)e.removeAttribute(u);for(const e of this._parent?.querySelectorAll(`[${u}]`)||[])e.removeAttribute(u);this._endpointElements.clear()}_syncEndpointOwnership(){const e=new Set;for(const t of this._desiredEndpointIds){const i=this._marker(t);i&&e.add(i)}for(const t of this._endpointElements)e.has(t)||t.removeAttribute(u);for(const t of this._parent?.querySelectorAll(`[${u}]`)||[])e.has(t)||t.removeAttribute(u);for(const t of e)this._endpointElements.has(t)&&t.hasAttribute(u)||t.setAttribute(u,"");this._endpointElements=e,this._endpointSetDirty=!1}_position(e,t,i){const r=this._marker(e);if(!r)return null;const o=Number.parseFloat(r.style.left),s=Number.parseFloat(r.style.top),n=r.getBoundingClientRect();return Number.isFinite(o)&&Number.isFinite(s)?{x:o*t/100,y:s*i/100,width:n.width,height:n.height}:null}_targetText(e){if("remote-space"===e.kind){const i=this.spaces?.find(t=>t.id===e.spaceId)?.title;return"string"==typeof i&&i.trim()||a(t(this.hass),"route_other_space")}return a(t(this.hass),"unplaced-coordinator"===e.kind?"route_coordinator_not_on_plan":"route_device_not_on_plan")}_markerClearance(e){return.61*Math.max(e.width,e.height)+3}_points(e){return e.map(e=>`${e.x.toFixed(2)},${e.y.toFixed(2)}`).join(" ")}render(){if(!this._hovered||!this.registry||!this._runtime.topologies.length)return this._setDesiredEndpointIds([]),i;const e=this._mappedMemo,n=e&&e.runtime===this._runtime&&e.devices===this.devices&&e.registry===this.registry?e.mapped:h(this._runtime.topologies,this.devices,this.registry);e&&n===e.mapped||(this._mappedMemo={runtime:this._runtime,devices:this.devices,registry:this.registry,mapped:n});const p=d(n,this.currentSpace,this._hovered),l=this.clientWidth||this._parent?.clientWidth||1,_=this.clientHeight||this._parent?.clientHeight||1,u=this._position(this._hovered,l,_);if(!u)return this._setDesiredEndpointIds([]),i;const b=p.lines.map(e=>({...e,point:this._position(e.neighborMarkerId,l,_)})).filter(e=>!!e.point).map(e=>{const t=void 0===e.lqi?"rgba(145,155,165,.85)":r(e.lqi),i=e.routeDirection?c(u,e.point,this._markerClearance(u),this._markerClearance(e.point),e.routeDirection):null;return{...e,color:t,arrow:i}}),m=u.x>l/2,v=this._markerClearance(u)+18,g=p.parentTargets.map((e,t)=>{const i=30*(t-(p.parentTargets.length-1)/2),r={x:u.x+(m?-v:v),y:Math.max(14,Math.min(_-14,u.y+i))};return{target:e,point:r,arrow:c(u,r,this._markerClearance(u),0,"toward-neighbor")}});return this._setDesiredEndpointIds(b.length||g.length||p.remoteCount?[this._hovered,...b.map(e=>e.neighborMarkerId)]:[]),s` ${b.length||g.length?o`${E} @@ -21,4 +21,4 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db ${this.context.t(this.busy?"pdf.saving":"pdf.save")}
    - `}}v.properties={context:{attribute:!1}},v.styles=A`:host{display:contents;}.body{display:grid;gap:12px;width:100%;max-width:100%;min-width:0;padding:16px 20px;box-sizing:border-box;}label{display:flex;min-width:0;min-height:44px;align-items:center;gap:12px;cursor:pointer;}label span{min-width:0;overflow-wrap:anywhere;}input{width:20px;height:20px;flex:none;accent-color:var(--hp-accent,#d89300);}.row{display:flex;align-items:center;gap:8px;width:100%;max-width:100%;min-width:0;padding:12px 16px;box-sizing:border-box;}.spacer{flex:1;}button{min-width:0;min-height:44px;max-width:100%;display:inline-flex;align-items:center;justify-content:center;border:1px solid var(--hp-line,rgb(127 127 127/.3));border-radius:12px;padding:0 18px;box-sizing:border-box;overflow-wrap:anywhere;white-space:normal;background:transparent;color:inherit;font:inherit;cursor:pointer;}button.primary{background:var(--hp-accent,#d89300);color:var(--hp-on-accent,#111);border-color:transparent;}button:disabled{opacity:.55;cursor:default;}ha-icon{flex:none;margin-right:6px;}@media (max-width:360px){.row{display:grid;grid-template-columns:minmax(0,1fr);}.spacer{display:none;}button{width:100%;}}`,customElements.get("hp-pdf-dialog")||customElements.define("hp-pdf-dialog",v);const V=(A,B,E)=>Math.hypot(A[0]-B[0],A[1]-B[1])<=E,U=A=>Number.isFinite(A)&&A>=0?A:0;function l(A){const B=Number(A);return Number.isFinite(B)&&B>0?.1/B:0}const a=(A,B)=>[...new Set([...A,...B])].sort((A,B)=>A-B),P=(A,B)=>{const E=A.points.length;if(E<=1||!V(A.points[E-1],A.points[0],B))return!1;const s=E-2;return A.edgeSources[s]=a(A.edgeSources[s],A.edgeSources[E-1]),A.points.splice(E-1,1),A.edgeSources.splice(E-1,1),!0},y=(A,B)=>{for(let E=0;E+1{let E=!1;for(;A.points.length>1;)if(P(A,B))E=!0;else{if(!y(A,B))break;E=!0}return E},N=(A,B,E)=>{const s=B[0]-A[0],w=B[1]-A[1],C=E[0]-B[0],g=E[1]-B[1],I=Math.hypot(s,w),Y=Math.hypot(C,g);if(!(I>0&&Y>0))return!1;const R=s*C+w*g;if(!(R>0))return!1;const M=s*g-w*C;return Math.abs(M)<=R*Q},K=A=>{const B=A.points.length;if(B<3)return!1;for(let E=0;E{const E=U(B),s=[],w=[];for(let B=0;B[A])};for(;Q.points.length>1;){const A=u(Q,E);if(Q.points.length<3)break;if(!K(Q)&&!A)break}return u(Q,E),Q};function J(A,B){const E=Number(A[0]),s=Number(A[1]),w=Number(B[0]),C=Number(B[1]);if(![E,s,w,C].every(Number.isFinite))return null;const g=w-E,I=C-s,Y=Math.abs(g),R=Math.abs(I),M=Math.max(Y,R),F=Math.min(Y,R);if(!(M>0)||F/M>Q)return null;const i=[(E+w)/2,(s+C)/2];if(Y>=R){return{axis:"horizontal",a:[E,i[1]],b:[w,i[1]],mid:i,projectedLength:Y,tangentInterval:[Math.min(E,w),Math.max(E,w)],normalCoordinate:i[1]}}return{axis:"vertical",a:[i[0],s],b:[i[0],C],mid:i,projectedLength:R,tangentInterval:[Math.min(s,C),Math.max(s,C)],normalCoordinate:i[0]}}function Z(A,B){const E=B.map(A=>[Number(A[0]),Number(A[1])]);if(!E.every(A=>A.every(Number.isFinite)))return!1;if(E.length<3||((A,B)=>{const E=1e-12*Math.max(1,Math.abs(A[0]),Math.abs(A[1]),...B.flatMap(A=>[Math.abs(A[0]),Math.abs(A[1])]));for(let s=0;s0))continue;const Y=(A[0]-w[0])*g-(A[1]-w[1])*C;if(Math.abs(Y)>E*I)continue;const R=(A[0]-w[0])*C+(A[1]-w[1])*g;if(R>=-E&&R<=I*I+E)return!0}return!1})(A,E))return!1;let s=!1;for(let B=0,w=E.length-1;BA[1]==C[1]>A[1])continue;const g=(C[0]-Q[0])*(A[1]-Q[1])/(C[1]-Q[1])+Q[0];A[0]Object.is(A,-0)?0:A,I=[g(-Q/C),g(w/C)],Y=[g(-I[0]),g(-I[1])],R=[(B[0]+E[0])/2,(B[1]+E[1])/2],M=Math.max(1,C,Math.abs(R[0]),Math.abs(R[1])),F=Math.max(1e-9*M,.01*U(s));for(const B of[F,4*F,16*F]){const E=Z([R[0]+I[0]*B,R[1]+I[1]*B],A);if(E!==Z([R[0]+Y[0]*B,R[1]+Y[1]*B],A))return E?I:Y}return sA(A)>=0?I:Y}function f(A,B){let E=180*Math.atan2(B[1]-A[1],B[0]-A[0])/Math.PI;return E>90&&(E-=180),E<=-90&&(E+=180),E}function k(A,B,E,s={}){const w=Number(B);if(!(w>0&&Number.isFinite(w)))return[];const Q=void 0===s.epsilon?l(w):U(s.epsilon);return z(d(A,Q),w,E,{...s,epsilon:Q})}const z=(A,B,E,s)=>{if(A.points.length<3)return[];const Q=U(s.epsilon??l(B)),C=Number.isFinite(Number(s.ringIndex))?Number(s.ringIndex):0,g=[];for(let s=0;sQ))continue;const M=[...A.edgeSources[s]||[s]].sort((A,B)=>A-B),F=M[0]??s,i=T(A.points,R.a,R.b,Q),x=("horizontal"===R.axis?i[1]:i[0])<0?-1:1,b=[R.axis,O(R.tangentInterval[0]),String(x),O(C),O(F)].join("|"),L=R.projectedLength*B;g.push({sourceA:[...I],sourceB:[...Y],a:R.a,b:R.b,text:w(L,E),short:L<30,angle:f(R.a,R.b),mid:R.mid,axis:R.axis,projectedLength:R.projectedLength,tangentInterval:R.tangentInterval,normalCoordinate:R.normalCoordinate,inwardNormal:i,normalSign:x,source:{ringIndex:C,edgeIndex:F},sourceEdgeIndices:M,stableKey:b})}return g};function p(A,B,E,s={}){const w=Number(B);if(!(w>0&&Number.isFinite(w)))return[];const Q=void 0===s.epsilon?l(w):U(s.epsilon);let C=d(A,Q);if(sA(C.points)<0&&(C=(A=>{const B=A.points.length;return{points:[...A.points].reverse().map(A=>[...A]),edgeSources:A.points.map((E,s)=>[...A.edgeSources[(B-2-s+B)%B]])}})(C)),C.points.length){let A=0;for(let B=1;B({points:[...A.points.slice(B),...A.points.slice(0,B)],edgeSources:[...A.edgeSources.slice(B),...A.edgeSources.slice(0,B)]}))(C,A)}return z(C,w,E,{...s,epsilon:Q})}function X(A,B){const E=U(B),s=[];for(const B of A){const A=s.find(A=>A.axis===B.axis&&A.normalSign===B.normalSign&&Math.abs(A.normalCoordinate-B.normalCoordinate)<=E);A?A.edges.push(B):s.push({axis:B.axis,normalSign:B.normalSign,normalCoordinate:B.normalCoordinate,edges:[B]})}return s.map(A=>A.edges)}const O=A=>Object.is(A,-0)?"0":String(A),q=A=>"horizontal"===A?0:1;function $(A,B){return q(A.axis)-q(B.axis)||A.tangentInterval[0]-B.tangentInterval[0]||A.normalSign-B.normalSign||A.source.ringIndex-B.source.ringIndex||A.source.edgeIndex-B.source.edgeIndex}function _(A,B,E,s){const w=U(s);if(A.axis!==B.axis)return!1;if(A.source.ringIndex!==B.source.ringIndex)return!1;if(A.inwardNormal[0]*B.inwardNormal[0]+A.inwardNormal[1]*B.inwardNormal[1]>=-.5)return!1;if(!((A,B,E)=>Math.abs(A[0]-B[0])<=E&&Math.abs(A[1]-B[1])<=E)(A.tangentInterval,B.tangentInterval,w))return!1;if(Math.abs(A.projectedLength-B.projectedLength)>w)return!1;return Z([(A.mid[0]+B.mid[0])/2,(A.mid[1]+B.mid[1])/2],E)}const AA=(A,B)=>{const E=B?.(A);return{hardCollisions:Number.isFinite(Number(E?.hardCollisions))?Number(E?.hardCollisions):0,normalClearance:Number.isFinite(Number(E?.normalClearance))?Number(E?.normalClearance):0}},BA=(A,B,E)=>{const s=AA(A,E),w=AA(B,E);return s.hardCollisions-w.hardCollisions||w.normalClearance-s.normalClearance||$(A,B)};function EA(A,B){if(A.length<2)return[...A];const E=U(B.epsilon),s=function(A,B=1e-7){return d(A,B).points.map(A=>[...A])}(B.ring,E),w=[];for(let B=0;B{const E=A.separation-B.separation;if(E)return E;const s=$(A.left,A.right)<=0?A.left:A.right,w=s===A.left?A.right:A.left,Q=$(B.left,B.right)<=0?B.left:B.right,C=Q===B.left?B.right:B.left;return $(s,Q)||$(w,C)});const Q=new Set,C=new Set;for(const A of w){if(Q.has(A.left)||Q.has(A.right))continue;Q.add(A.left),Q.add(A.right);const E=BA(A.left,A.right,B.score)<=0?A.left:A.right;C.add(E===A.left?A.right:A.left)}return A.filter(A=>!C.has(A))}function sA(A){let B=0;for(let E=0;E1){const A=Math.sqrt(G);Y*=A,R*=A}const o=Math.max(0,Y*Y*R*R-Y*Y*D*D-R*R*L*L),t=Y*Y*D*D+R*R*L*L||1,c=(Q===C?-1:1)*Math.sqrt(o/t),W=c*Y*D/R,m=c*-R*L/Y,n=F*W-i*m+(A+g)/2,e=i*W+F*m+(B+I)/2;let h=gA(1,0,(L-W)/Y,(D-m)/R),S=gA((L-W)/Y,(D-m)/R,(-L-W)/Y,(-D-m)/R);!C&&S>0&&(S-=2*Math.PI),C&&S<0&&(S+=2*Math.PI);const j=Math.max(1,Math.ceil(Math.abs(S)/(Math.PI/2))),r=S/j,H=A=>[n+F*Y*Math.cos(A)-i*R*Math.sin(A),e+i*Y*Math.cos(A)+F*R*Math.sin(A)],v=A=>[-F*Y*Math.sin(A)-i*R*Math.cos(A),-i*Y*Math.sin(A)+F*R*Math.cos(A)],V=[];for(let A=0;A[B.a*A+B.c*E+B.e,B.b*A+B.d*E+B.f];return function(A){const B=A.match(/[AaCcHhLlMmQqSsTtVvZz]|[-+]?(?:\d*\.\d+|\d+\.?)(?:e[-+]?\d+)?/gi)||[],E=[];let s=0,w="",Q=0,C=0,g=0,I=0,Y=null,R=null;const M=()=>Number(B[s++]);for(;sB.length||QA.test(B[s]))throw new Error(`Invalid SVG path command ${w}`);const x=Array.from({length:i},M),b=A=>A+(F?Q:0),L=A=>A+(F?C:0);if("M"===A||"L"===A)Q=b(x[0]),C=L(x[1]),E.push({op:"M"===A?"M":"L",x:Q,y:C}),"M"===A&&(g=Q,I=C,w=F?"l":"L"),Y=R=null;else if("H"===A)Q=b(x[0]),E.push({op:"L",x:Q,y:C}),Y=R=null;else if("V"===A)C=L(x[0]),E.push({op:"L",x:Q,y:C}),Y=R=null;else if("C"===A){const A=b(x[0]),B=L(x[1]),s=b(x[2]),w=L(x[3]);Q=b(x[4]),C=L(x[5]),Y=[s,w],R=null,E.push({op:"C",x1:A,y1:B,x2:s,y2:w,x:Q,y:C})}else if("S"===A){const A=Y?2*Q-Y[0]:Q,B=Y?2*C-Y[1]:C,s=b(x[0]),w=L(x[1]);Q=b(x[2]),C=L(x[3]),Y=[s,w],R=null,E.push({op:"C",x1:A,y1:B,x2:s,y2:w,x:Q,y:C})}else if("Q"===A||"T"===A){const B="Q"===A?b(x[0]):R?2*Q-R[0]:Q,s="Q"===A?L(x[1]):R?2*C-R[1]:C,w=b("Q"===A?x[2]:x[0]),g=L("Q"===A?x[3]:x[1]);E.push({op:"C",x1:Q+2/3*(B-Q),y1:C+2/3*(s-C),x2:w+2/3*(B-w),y2:g+2/3*(s-g),x:w,y:g}),Q=w,C=g,R=[B,s],Y=null}else if("A"===A){const A=b(x[5]),B=L(x[6]),s=IA(Q,C,x[0],x[1],x[2],x[3],x[4],A,B);s.length?E.push(...s):E.push({op:"L",x:A,y:B}),Q=A,C=B,Y=R=null}}return E}(A).map(A=>{if("Z"===A.op)return A;if("M"===A.op||"L"===A.op){const[B,s]=E(A.x,A.y);return{op:A.op,x:B,y:s}}if("C"!==A.op)throw new Error("Unsupported PDF vector operation");const[B,s]=E(A.x1,A.y1),[w,Q]=E(A.x2,A.y2),[C,g]=E(A.x,A.y);return{op:"C",x1:B,y1:s,x2:w,y2:Q,x:C,y:g}})}const RA=["M20.82,15.31h0L10.46,9c-.46-.26-1.11.37-.86.84l6.15,10.56,10.56,6.15a.66.66,0,0,0,.84-.86Zm-4,4,3-3,4.55,7.44Z","M18,2A16,16,0,1,0,34,18,16,16,0,0,0,18,2Zm1,29.95V29.53H17v2.42A14,14,0,0,1,4.05,19H6.47V17H4.05A14,14,0,0,1,17,4.05V6.47h2V4.05A14,14,0,0,1,31.95,17H29.53v2h2.42A14,14,0,0,1,19,31.95Z"],MA=A=>Math.abs(A)<1e-12?0:Math.abs(A-1)<1e-12?1:Math.abs(A+1)<1e-12?-1:A;function FA(A){const B=function(A){const{centerX:B,centerY:E,size:s,northDeg:w}=A;if(![B,E,s,w].every(Number.isFinite)||s<=0)throw new RangeError("PDF compass placement must contain finite coordinates and a positive size");const Q=((w%360+360)%360+45)*Math.PI/180,C=s/36,g=MA(Math.cos(Q)),I=MA(Math.sin(Q)),Y=C*g,R=C*I,M=-C*I,F=C*g;return{a:Y,b:R,c:M,d:F,e:B-18*Y-18*M,f:E-18*R-18*F}}(A);return RA.flatMap(A=>YA(A,B))}const iA=1e-8,xA=A=>A.length>=2&&Number.isFinite(A[0])&&Number.isFinite(A[1]),bA=(A,B)=>A[0]>=B.minX-iA&&A[0]<=B.maxX+iA&&A[1]>=B.minY-iA&&A[1]<=B.maxY+iA,LA=A=>[A.minX,A.minY,A.maxX,A.maxY].every(Number.isFinite)&&A.maxX>=A.minX&&A.maxY>=A.minY,DA=A=>[[A.minX,A.minY],[A.maxX,A.minY],[A.maxX,A.maxY],[A.minX,A.maxY]];const GA=(A,B,E)=>(B[0]-A[0])*(E[1]-A[1])-(B[1]-A[1])*(E[0]-A[0]),oA=(A,B,E)=>{const s=E[0]-B[0],w=E[1]-B[1],Q=Math.abs(s)>=Math.abs(w)?s:w;return Math.abs(Q)<=iA?0:(Math.abs(s)>=Math.abs(w)?A[0]-B[0]:A[1]-B[1])/Q},tA=(A,B)=>Math.hypot(B[0]-A[0],B[1]-A[1]);function cA(A,B,E){const s=tA(B,E);if(s<=iA)return tA(A,B)<=iA;if(Math.abs(GA(B,E,A))/s>iA)return!1;const w=oA(A,B,E),Q=iA/s;return w>=-Q&&w<=1+Q}function WA(A,B,E,s){const w=B[0]-A[0],Q=B[1]-A[1],C=s[0]-E[0],g=s[1]-E[1],I=Math.hypot(w,Q),Y=Math.hypot(C,g);if(I<=iA)return cA(A,E,s)?{t:0,endT:0,overlap:!1}:null;if(Y<=iA){if(!cA(E,A,B))return null;const s=Math.max(0,Math.min(1,oA(E,A,B)));return{t:s,endT:s,overlap:!1}}const R=w*g-Q*C,M=E[0]-A[0],F=E[1]-A[1],i=iA*I*Y;if(Math.abs(R)<=i){if(Math.abs(GA(A,B,E))/I>iA||Math.abs(GA(A,B,s))/I>iA)return null;const w=oA(E,A,B),Q=oA(s,A,B),C=Math.max(0,Math.min(w,Q)),g=Math.min(1,Math.max(w,Q));return giA}}const x=(M*g-F*C)/R,b=(M*Q-F*w)/R,L=iA/I,D=iA/Y;if(x<-L||x>1+L||b<-D||b>1+D)return null;const G=Math.max(0,Math.min(1,x));return{t:G,endT:G,overlap:!1}}const mA=A=>A.every(A=>A.length>=2&&A.every(xA));function nA(A,B){for(const E of A){const A=E;for(let E=0;Enull!==WA(A,B,E,s[(w+1)%s.length]))}const hA=2048,SA=2146,jA=[-1825,-555,4188,2163],rA={32:1,33:2,34:3,35:4,36:5,37:6,38:7,39:8,40:9,41:10,42:11,43:12,44:13,45:14,46:15,47:16,48:17,49:18,50:19,51:20,52:21,53:22,54:23,55:24,56:25,57:26,58:27,59:28,60:29,61:30,62:31,63:32,64:33,65:34,66:35,67:36,68:37,69:38,70:39,71:40,72:41,73:42,74:43,75:44,76:45,77:46,78:47,79:48,80:49,81:50,82:51,83:52,84:53,85:54,86:55,87:56,88:57,89:58,90:59,91:60,92:61,93:62,94:63,95:64,96:65,97:66,98:67,99:68,100:69,101:70,102:71,103:72,104:73,105:74,106:75,107:76,108:77,109:78,110:79,111:80,112:81,113:82,114:83,115:84,116:85,117:86,118:87,119:88,120:89,121:90,122:91,123:92,124:93,125:94,126:95,160:596,161:96,162:97,163:98,164:99,165:100,166:101,167:102,168:103,169:104,170:105,171:106,172:107,173:597,174:108,175:109,176:110,177:111,178:112,179:113,180:114,181:115,182:116,183:117,184:118,185:119,186:120,187:121,188:122,189:123,190:124,191:125,192:603,193:604,194:605,195:606,196:607,197:608,198:126,199:609,200:610,201:611,202:612,203:613,204:614,205:615,206:616,207:617,208:599,209:618,210:619,211:620,212:621,213:622,214:623,215:127,216:128,217:624,218:625,219:626,220:627,221:628,222:129,223:130,224:629,225:630,226:631,227:632,228:633,229:634,230:131,231:635,232:636,233:637,234:638,235:639,236:640,237:641,238:642,239:643,240:132,241:644,242:645,243:646,244:647,245:648,246:649,247:133,248:134,249:650,250:651,251:652,252:653,253:654,254:135,255:655,256:656,257:657,258:658,259:659,260:660,261:661,262:662,263:663,264:664,265:665,266:666,267:667,268:668,269:669,270:670,271:671,272:598,273:136,274:672,275:673,276:674,277:675,278:676,279:677,280:678,281:679,282:680,283:681,284:682,285:683,286:684,287:685,288:686,289:687,290:688,291:689,292:690,293:691,294:137,295:600,296:692,297:693,298:694,299:695,300:696,301:697,302:698,303:699,304:700,305:138,306:701,307:702,308:703,309:704,310:705,311:706,312:139,313:707,314:708,315:709,316:710,317:711,318:712,319:713,320:714,321:140,322:141,323:715,324:716,325:717,326:718,327:719,328:720,329:721,330:142,331:143,332:722,333:723,334:724,335:725,336:726,337:727,338:144,339:145,340:728,341:729,342:730,343:731,344:732,345:733,346:734,347:735,348:736,349:737,350:738,351:739,352:742,353:743,354:744,355:745,356:746,357:747,358:601,359:602,360:748,361:749,362:750,363:751,364:752,365:753,366:754,367:755,368:756,369:757,370:758,371:759,372:760,373:761,374:762,375:763,376:764,377:765,378:766,379:767,380:768,381:769,382:770,383:146,1024:897,1025:856,1026:165,1027:857,1028:166,1029:858,1030:859,1031:860,1032:861,1033:167,1034:168,1035:169,1036:863,1037:898,1038:864,1039:170,1040:865,1041:171,1042:866,1043:867,1044:172,1045:868,1046:173,1047:174,1048:175,1049:869,1050:862,1051:176,1052:870,1053:871,1054:872,1055:873,1056:874,1057:875,1058:876,1059:177,1060:178,1061:877,1062:179,1063:180,1064:181,1065:182,1066:183,1067:184,1068:185,1069:186,1070:187,1071:188,1072:878,1073:189,1074:190,1075:191,1076:192,1077:879,1078:193,1079:194,1080:195,1081:880,1082:196,1083:197,1084:198,1085:199,1086:881,1087:200,1088:882,1089:883,1090:201,1091:884,1092:202,1093:885,1094:203,1095:204,1096:205,1097:206,1098:207,1099:208,1100:209,1101:210,1102:211,1103:212,1104:899,1105:886,1106:213,1107:887,1108:214,1109:888,1110:889,1111:890,1112:891,1113:215,1114:216,1115:217,1116:892,1117:900,1118:893,1119:218,1120:219,1121:220,1122:965,1123:221,1124:222,1125:223,1126:224,1127:225,1128:226,1129:227,1130:228,1131:229,1132:230,1133:231,1134:232,1135:233,1136:901,1137:902,1138:234,1139:235,1140:236,1141:237,1142:903,1143:904,1144:906,1145:905,1146:238,1147:239,1148:240,1149:241,1150:242,1151:243,1152:244,1153:245,1154:246,1155:247,1156:248,1157:249,1158:250,1159:251,1160:252,1161:253,1162:254,1163:255,1164:964,1165:256,1166:257,1167:258,1168:259,1169:260,1170:966,1171:967,1172:261,1173:262,1174:263,1175:264,1176:907,1177:908,1178:265,1179:266,1180:267,1181:268,1182:968,1183:969,1184:269,1185:270,1186:271,1187:272,1188:273,1189:274,1190:275,1191:276,1192:277,1193:278,1194:909,1195:910,1196:955,1197:956,1198:911,1199:912,1200:970,1201:971,1202:279,1203:280,1204:281,1205:282,1206:283,1207:284,1208:285,1209:286,1210:287,1211:963,1212:288,1213:289,1214:961,1215:962,1216:913,1217:914,1218:915,1219:290,1220:291,1221:292,1222:293,1223:294,1224:295,1225:296,1226:297,1227:957,1228:958,1229:298,1230:299,1231:916,1232:917,1233:918,1234:919,1235:920,1236:921,1237:922,1238:923,1239:924,1240:300,1241:926,1242:925,1243:927,1244:928,1245:929,1246:930,1247:931,1248:301,1249:302,1250:932,1251:933,1252:934,1253:935,1254:936,1255:937,1256:938,1257:939,1258:940,1259:941,1260:942,1261:943,1262:944,1263:945,1264:946,1265:947,1266:948,1267:949,1268:950,1269:951,1270:959,1271:960,1272:952,1273:953,1274:303,1275:304,1276:305,1277:306,1278:972,1279:973,1280:307,1281:954,1282:308,1283:309,1284:310,1285:311,1286:312,1287:313,1288:314,1289:315,1290:316,1291:317,1292:318,1293:319,1294:320,1295:321,1296:322,1297:974,1298:323,1299:324,1300:325,1301:326,1302:327,1303:328,1304:329,1305:330,1306:982,1307:983,1308:984,1309:985,1310:331,1311:332,1312:333,1313:334,1314:335,1315:336,1316:337,1317:338,1318:339,1319:340,1320:341,1321:342,1322:343,1323:344,1324:345,1325:346,1326:347,1327:348,8192:349,8193:350,8194:351,8195:352,8196:353,8197:354,8198:355,8199:356,8200:357,8201:358,8202:360,8203:361,8204:362,8205:363,8206:364,8207:365,8208:366,8209:367,8210:368,8211:369,8212:370,8213:975,8214:371,8215:372,8216:373,8217:374,8218:375,8219:376,8220:377,8221:378,8222:379,8223:380,8224:381,8225:382,8226:383,8227:384,8228:385,8229:386,8230:387,8231:388,8239:986,8240:389,8241:390,8242:894,8243:895,8244:391,8245:392,8246:393,8247:394,8248:395,8249:396,8250:397,8251:398,8252:896,8253:399,8254:400,8255:401,8256:402,8257:403,8258:404,8259:405,8260:406,8261:407,8262:408,8263:987,8264:988,8265:989,8266:409,8267:410,8268:411,8269:412,8270:413,8271:414,8272:415,8273:416,8274:417,8275:418,8276:419,8277:420,8278:421,8279:422,8280:423,8281:424,8282:425,8283:426,8284:427,8285:428,8286:429,8287:990,8364:430,8381:431,8776:433},HA={1:507,2:527,3:655,4:1261,5:1150,6:1500,7:1273,8:357,9:700,10:712,11:882,12:1161,13:402,14:565,15:539,16:844,17:1150,18:1150,19:1150,20:1150,21:1150,22:1150,23:1150,24:1150,25:1150,26:1150,27:496,28:433,29:1041,30:1124,31:1070,32:967,33:1839,34:1336,35:1275,36:1333,37:1343,38:1164,39:1132,40:1395,41:1460,42:557,43:1130,44:1284,45:1102,46:1788,47:1460,48:1408,49:1292,50:1408,51:1261,52:1215,53:1222,54:1328,55:1303,56:1817,57:1284,58:1230,59:1226,60:543,61:840,62:543,63:856,64:924,65:633,66:1114,67:1149,68:1072,69:1155,70:1085,71:711,72:1149,73:1128,74:497,75:489,76:1038,77:497,78:1795,79:1130,80:1168,81:1149,82:1164,83:693,84:1056,85:669,86:1129,87:992,88:1539,89:1015,90:969,91:1015,92:693,93:499,94:693,95:1393,96:499,97:1120,98:1190,99:1460,100:1075,101:491,102:1256,103:856,104:1609,105:915,106:961,107:1134,108:1610,109:938,110:765,111:1094,112:751,113:751,114:642,115:1160,116:1001,117:534,118:507,119:751,120:931,121:960,122:1500,123:1589,124:1593,125:969,126:1914,127:1092,128:1408,129:1210,130:1218,131:1729,132:1200,133:1169,134:1160,135:1180,136:1223,137:1434,138:506,139:1139,140:1103,141:553,142:1419,143:1160,144:1953,145:1860,146:508,165:1535,166:1380,167:2193,168:2212,169:1666,170:1460,171:1291,172:1540,173:1859,174:1215,175:1460,176:1449,177:1287,178:1580,179:1497,180:1402,181:1927,182:1984,183:1554,184:1771,185:1285,186:1380,187:1831,188:1304,189:1132,190:1170,191:859,192:1236,193:1568,194:1040,195:1182,196:1106,197:1184,198:1519,199:1181,200:1182,201:984,202:1485,203:1213,204:1113,205:1656,206:1694,207:1271,208:1590,209:1112,210:1101,211:1671,212:1124,213:1128,214:1101,215:1737,216:1764,217:1161,218:1182,219:1800,220:1579,221:1110,222:1835,223:1528,224:1234,225:1094,226:1803,227:1547,228:1745,229:1505,230:2308,231:2001,232:1059,233:987,234:1393,235:1163,236:1290,237:1027,238:1393,239:1160,240:1793,241:1572,242:1800,243:1579,244:1330,245:1095,246:1277,247:1024,248:1024,249:1024,250:1024,251:1024,252:1024,253:1024,254:1545,255:1261,256:1110,257:1307,258:1161,259:1123,260:912,261:1243,262:1029,263:1954,264:1633,265:1434,266:1208,267:1289,268:1150,269:1676,270:1411,271:1535,272:1241,273:1999,274:1460,275:2097,276:1780,277:1518,278:1235,279:1304,280:1066,281:1836,282:1372,283:1468,284:1174,285:1391,286:1130,287:1391,288:1583,289:1213,290:1289,291:1114,292:1534,293:1263,294:1458,295:1160,296:1554,297:1260,298:1871,299:1598,300:1415,301:1192,302:1192,303:1207,304:939,305:1326,306:1088,307:1270,308:1684,309:1764,310:1622,311:1323,312:1097,313:1031,314:1985,315:1653,316:2043,317:1697,318:1270,319:1053,320:1453,321:1312,322:1380,323:1538,324:1266,325:1920,326:1549,327:1857,328:1547,329:1926,330:1774,331:1316,332:1106,333:2274,334:1832,335:2300,336:1829,337:1526,338:1242,339:1468,340:1208,341:1539,342:1273,343:2710,344:2238,345:1568,346:1240,347:1515,348:1243,349:1044,350:2089,351:1044,352:2089,353:697,354:522,355:348,356:1151,357:560,358:418,360:209,361:1024,362:1024,363:1024,364:1024,365:1024,366:564,367:564,368:1171,369:1344,370:1599,371:778,372:933,373:409,374:409,375:407,376:409,377:724,378:731,379:705,380:764,381:1129,382:1167,383:690,384:1100,385:511,386:964,387:1370,388:382,389:1962,390:2360,391:1045,392:463,393:757,394:1045,395:803,396:614,397:614,398:1241,399:919,400:952,401:1540,402:1540,403:874,404:1370,405:870,406:931,407:640,408:641,409:907,410:1001,411:1237,412:1237,413:985,414:511,415:1541,416:985,417:931,418:1366,419:1540,420:1172,421:932,422:1333,423:1215,424:1125,425:379,426:1071,427:1162,428:379,429:379,430:1150,431:1359,433:1154,596:507,597:565,598:1373,599:1373,600:1158,601:1222,602:669,603:1336,604:1336,605:1336,606:1336,607:1336,608:1336,609:1333,610:1164,611:1164,612:1164,613:1164,614:557,615:557,616:557,617:557,618:1460,619:1408,620:1408,621:1408,622:1408,623:1408,624:1328,625:1328,626:1328,627:1328,628:1230,629:1114,630:1114,631:1114,632:1114,633:1114,634:1114,635:1072,636:1085,637:1085,638:1085,639:1085,640:506,641:506,642:506,643:506,644:1130,645:1168,646:1168,647:1168,648:1168,649:1168,650:1129,651:1129,652:1129,653:1129,654:969,655:969,656:1336,657:1114,658:1336,659:1114,660:1336,661:1114,662:1333,663:1072,664:1333,665:1072,666:1333,667:1072,668:1333,669:1072,670:1343,671:1305,672:1164,673:1085,674:1164,675:1085,676:1164,677:1085,678:1164,679:1085,680:1164,681:1085,682:1395,683:1149,684:1395,685:1149,686:1395,687:1149,688:1395,689:1149,690:1460,691:1128,692:557,693:506,694:557,695:506,696:557,697:506,698:557,699:497,700:557,701:1687,702:986,703:1130,704:515,705:1284,706:1038,707:1102,708:497,709:1102,710:497,711:1102,712:647,713:1102,714:717,715:1460,716:1130,717:1460,718:1130,719:1460,720:1130,721:1130,722:1408,723:1168,724:1408,725:1168,726:1408,727:1168,728:1261,729:693,730:1261,731:693,732:1261,733:693,734:1215,735:1056,736:1215,737:1056,738:1215,739:1056,742:1215,743:1056,744:1222,745:669,746:1222,747:709,748:1328,749:1129,750:1328,751:1129,752:1328,753:1129,754:1328,755:1129,756:1328,757:1129,758:1328,759:1129,760:1817,761:1539,762:1230,763:969,764:1230,765:1226,766:1015,767:1226,768:1015,769:1226,770:1015,856:1164,857:1139,858:1215,859:557,860:557,861:1130,862:1316,863:1284,864:1287,865:1336,866:1275,867:1139,868:1164,869:1460,870:1788,871:1460,872:1408,873:1461,874:1292,875:1333,876:1222,877:1284,878:1114,879:1085,880:1182,881:1168,882:1149,883:1072,884:969,885:1015,886:1085,887:859,888:1056,889:497,890:506,891:489,892:1106,893:969,894:357,895:655,896:1054,897:1164,898:1460,899:1085,900:1182,901:1417,902:1434,903:1290,904:1027,905:2137,906:2377,907:1215,908:1040,909:1333,910:1072,911:1230,912:1026,913:557,914:1859,915:1568,916:557,917:1336,918:1114,919:1336,920:1114,921:1914,922:1729,923:1164,924:1085,925:1415,926:1079,927:1079,928:1859,929:1568,930:1215,931:1040,932:1460,933:1182,934:1460,935:1182,936:1408,937:1168,938:1393,939:1163,940:1393,941:1163,942:1380,943:1101,944:1287,945:969,946:1287,947:969,948:1287,949:969,950:1402,951:1113,952:1771,953:1590,954:1155,955:1222,956:984,957:1402,958:1113,959:1139,960:859,961:1583,962:1213,963:1128,964:1285,965:1285,966:1139,967:859,968:1336,969:1063,970:1230,971:1026,972:1284,973:1015,974:1104,975:1599,982:1408,983:1164,984:1817,985:1539,986:507,987:1934,988:1494,989:1494,990:507},vA=new TextEncoder,VA=A=>{const B=Math.round(100*A)/100;return Number.isInteger(B)?String(B):B.toFixed(2).replace(/0+$/,"")},UA=A=>{const B=Math.round(1e6*A)/1e6;return Number.isInteger(B)?String(B):B.toFixed(6).replace(/0+$/,"")},lA=A=>A.map(UA).join(" ");function aA(A){let B="",E=0;const s=new Map;for(const w of A){const A=w.codePointAt(0)||0,Q=rA[A]||rA[63];B+=Q.toString(16).padStart(4,"0"),E+=HA[Q]||1024,s.has(Q)||s.set(Q,A||63)}return{hex:B,width:E,unicode:s}}function PA(A,B){return aA(A).width*B/hA}function yA(A,B=PA(A.text,A.size)){const E=A.align||"left",s="center"===E?B/2:"right"===E?B:0,w=(A.angle||0)*Math.PI/180,Q=Math.cos(w),C=Math.sin(w);return{width:B,baselineX:A.x-Q*s,baselineY:A.y+C*s,cos:Q,sin:C}}function uA(A){const B=yA(A),E=-555*A.size/hA,s=SA*A.size/hA,w=[0,B.width].flatMap(A=>[E,s].map(E=>({x:B.baselineX+B.cos*A-B.sin*E,y:B.baselineY-B.sin*A-B.cos*E})));return{minX:Math.min(...w.map(A=>A.x)),minY:Math.min(...w.map(A=>A.y)),maxX:Math.max(...w.map(A=>A.x)),maxY:Math.max(...w.map(A=>A.y))}}function NA(A){const B=A.reduce((A,B)=>A+B.length,0),E=new Uint8Array(B);let s=0;for(const B of A)E.set(B,s),s+=B.length;return E}const KA=A=>vA.encode(A),dA=(A,B)=>NA([KA(`<< ${A} /Length ${B.length} >>\nstream\n`),B,KA("\nendstream")]);function JA(A){const B=function(A){const B=atob(A),E=new Uint8Array(B.length);for(let A=0;A"image"===A.kind&&null!=A.opacity&&A.opacity<1?[Math.max(0,Math.min(1,A.opacity))]:[]))].sort((A,B)=>A-B),s=new Map(E.map((A,B)=>[A,`GS${B+1}`])),w=function(A,B){const E=[],s=new Map,w=B=>A.height-B,Q=(A,...B)=>`${B.map(VA).join(" ")} ${A}`,C=A=>{for(const B of A)if(B.length){E.push(Q("m",B[0][0],w(B[0][1])));for(let A=1;A{let B=!1;for(const s of A)if(!(s.length<2)){B=!0,E.push(Q("m",s[0][0],w(s[0][1])));for(let A=1;A Tj`,"ET")}else{const A=(I.angle||0)*Math.PI/180,s=Math.cos(A),C=Math.sin(A),g=I.x+I.width/2,Y=w(I.y+I.height/2);E.push("q");const R=null==I.opacity?1:Math.max(0,Math.min(1,I.opacity)),M=B.get(R);M&&E.push(`/${M} gs`),E.push(Q("cm",s*I.width,C*I.width,C*I.height,-s*I.height,g-s*I.width/2-C*I.height/2,Y-C*I.width/2+s*I.height/2),`/Im${I.imageId} Do`,"Q")}return{stream:E.join("\n"),unicode:s}}(A,s),Q=Math.max(0,...Object.keys(HA).map(Number)),C=Array.from({length:Q+1},(A,B)=>Math.round(1e3*(HA[B]||1024)/hA)),g=[],I=A=>(g.push("string"==typeof A?KA(A):A),g.length),Y=I(""),R=I(""),M=I(""),F=I(dA(`/Length1 ${B.length}`,B)),i=I(`<< /Type /FontDescriptor /FontName /Roboto /Flags 32 /FontBBox [${jA.join(" ")}] /ItalicAngle 0 /Ascent 2146 /Descent -555 /CapHeight 2146 /StemV 80 /FontFile2 ${F} 0 R >>`),x=I(`<< /Type /Font /Subtype /CIDFontType2 /BaseFont /Roboto /CIDSystemInfo << /Registry (Adobe) /Ordering (Identity) /Supplement 0 >> /FontDescriptor ${i} 0 R /W [0 [${C.join(" ")}]] /CIDToGIDMap /Identity >>`),b=KA(function(A){const B=[...A].sort((A,B)=>A[0]-B[0]),E=B.map(([A,B])=>`<${A.toString(16).padStart(4,"0")}> <${B<=65535?B.toString(16).padStart(4,"0"):(()=>{const A=B-65536;return(55296+(A>>10)).toString(16).padStart(4,"0")+(56320+(1023&A)).toString(16).padStart(4,"0")})()}>`);return`/CIDInit /ProcSet findresource begin\n12 dict begin\nbegincmap\n/CIDSystemInfo << /Registry (Adobe) /Ordering (UCS) /Supplement 0 >> def\n/CMapName /HousePlanUnicode def\n/CMapType 2 def\n1 begincodespacerange\n<0000> \nendcodespacerange\n${B.length} beginbfchar\n${E.join("\n")}\nendbfchar\nendcmap\nCMapName currentdict /CMap defineresource pop\nend\nend`}(w.unicode)),L=I(dA("",b)),D=I(`<< /Type /Font /Subtype /Type0 /BaseFont /Roboto /Encoding /Identity-H /DescendantFonts [${x} 0 R] /ToUnicode ${L} 0 R >>`),G=I(dA("",KA(w.stream))),o=[];for(const B of A.images||[]){const A=I(dA(`/Type /XObject /Subtype /Image /Width ${B.width} /Height ${B.height} /ColorSpace /DeviceRGB /BitsPerComponent 8 /Filter /DCTDecode`,B.bytes));o.push(`/Im${B.id} ${A} 0 R`)}const t=A.now.toISOString().replace(/[-:T]/g,"").slice(0,14),c=I(`<< /CreationDate (D:${t}Z) /ModDate (D:${t}Z) >>`),W=`<< /Font << /F1 ${D} 0 R >>`+(o.length?` /XObject << ${o.join(" ")} >>`:"")+(E.length?` /ExtGState << ${E.map(A=>`/${s.get(A)} << /ca ${VA(A)} /CA ${VA(A)} >>`).join(" ")} >>`:"")+" >>";g[Y-1]=KA(`<< /Type /Catalog /Pages ${R} 0 R >>`),g[R-1]=KA(`<< /Type /Pages /Kids [${M} 0 R] /Count 1 >>`),g[M-1]=KA(`<< /Type /Page /Parent ${R} 0 R /MediaBox [0 0 ${VA(A.width)} ${VA(A.height)}] /Resources ${W} /Contents ${G} 0 R >>`);const m=KA("%PDF-1.4\n%âãÏÓ\n"),n=[m],e=[0];let h=m.length;g.forEach((A,B)=>{const E=KA(`${B+1} 0 obj\n`),s=KA("\nendobj\n");e.push(h),n.push(E,A,s),h+=E.length+A.length+s.length});const S=h,j=["xref",`0 ${g.length+1}`,"0000000000 65535 f "];for(let A=1;A<=g.length;A++)j.push(`${String(e[A]).padStart(10,"0")} 00000 n `);return j.push(`trailer\n<< /Size ${g.length+1} /Root ${Y} 0 R /Info ${c} 0 R >>`,`startxref\n${S}\n%%EOF\n`),n.push(KA(j.join("\n"))),NA(n)}const ZA=A=>[A.minX,A.minY,A.maxX,A.maxY].every(Number.isFinite)&&A.maxX>=A.minX&&A.maxY>=A.minY,TA=A=>A.maxX-A.minX,fA=A=>A.maxY-A.minY;function kA(A,B,E,s=0){Number.isFinite(B)&&Number.isFinite(E)&&(A.minX=Math.min(A.minX,B-s),A.minY=Math.min(A.minY,E-s),A.maxX=Math.max(A.maxX,B+s),A.maxY=Math.max(A.maxY,E+s))}function zA(A,B,E,s,w,Q){const C=Q*Math.PI/180,g=Math.cos(C),I=Math.sin(C),Y=B+s/2,R=E+w/2;for(const[B,E]of[[-s/2,-w/2],[s/2,-w/2],[s/2,w/2],[-s/2,w/2]])kA(A,Y+g*B-I*E,R+I*B+g*E)}function pA(A,B,E){for(const s of B)"M"===s.op||"L"===s.op?kA(A,s.x,s.y,E):"C"===s.op&&(kA(A,s.x1,s.y1,E),kA(A,s.x2,s.y2,E),kA(A,s.x,s.y,E))}function XA(A){const B={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};for(const E of A)if("path"===E.kind){const A=E.stroke?(E.width||.5)/2:0;for(const s of E.rings)for(const[E,w]of s)kA(B,E,w,A)}else if("line"===E.kind)for(const[A,s]of E.points)kA(B,A,s,E.width/2);else if("vector"===E.kind)pA(B,E.ops,E.width/2);else if("text"===E.kind){const A=uA(E);kA(B,A.minX,A.minY),kA(B,A.maxX,A.maxY)}else zA(B,E.x,E.y,E.width,E.height,E.angle||0);return B}function OA(A,B,E){return!!ZA(A)&&(TA(A)<=TA(B)+E&&fA(A)<=fA(B)+E)}function qA(A){return`${A.getFullYear()}-${String(A.getMonth()+1).padStart(2,"0")}-${String(A.getDate()).padStart(2,"0")}`}const $A=72/25.4,_A=5.25,AB=[.08,.08,.08],BB=[127/255,127/255,127/255],EB=[.72,.72,.72],sB=(A,B)=>A.minXB.minX&&A.minYB.minY;function wB(A,B,E,s,w=0,Q="left"){return uA({x:A,y:B,text:E,size:s,angle:w,align:Q})}function QB(A,B,E,s,w){const Q=Math.min(...[[A.minX,A.minY],[A.maxX,A.minY],[A.maxX,A.maxY],[A.minX,A.maxY]].map(([A,w])=>(A-B)*s[0]+(w-E)*s[1]));return Math.max(0,w-Q)}const CB=(A,B)=>`${A.axis}:${B[0]<-.5||B[1]<-.5?-1:1}`,gB=(A,B)=>{A.minX=Math.min(A.minX,B[0]),A.minY=Math.min(A.minY,B[1]),A.maxX=Math.max(A.maxX,B[0]),A.maxY=Math.max(A.maxY,B[1])},IB=A=>{const B={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};for(const E of A)for(const A of E)gB(B,A);return B};function YB(A,B,E,s,w=0){const Q=w*Math.PI/180,C=Math.cos(Q),g=Math.sin(Q),I=A+E/2,Y=B+s/2;return Array.from({length:48},(A,B)=>{const w=B/48*Math.PI*2,Q=Math.cos(w)*E/2,R=Math.sin(w)*s/2;return[I+C*Q-g*R,Y+g*Q+C*R]})}function RB(A,B,E,s,w=0){const Q=w*Math.PI/180,C=Math.cos(Q),g=Math.sin(Q),I=A+E/2,Y=B+s/2;return[[-E/2,-s/2],[E/2,-s/2],[E/2,s/2],[-E/2,s/2]].map(([A,B])=>[I+C*A-g*B,Y+g*A+C*B])}function MB(A,B,E){if("passage"===A.type)return[];const s=A.rlen/2,w=B>0?B/E*Y/2:2,Q=[];if("window"===A.type)Q.push([[-s,-w],[s,-w]],[[-s,w],[s,w]],[[-s,-w],[-s,w]],[[s,-w],[s,w]]);else if("gate"===A.type){const B=10*(A.flip_v?-1:1)*Math.PI/180,E=[[[-s,0],[-s+Math.cos(B)*s,Math.sin(B)*s]],[[s,0],[s-Math.cos(B)*s,Math.sin(-B)*s]]];Q.push(...E);for(const A of E){const B=A[1][0]-A[0][0],E=A[1][1]-A[0][1],s=Math.hypot(B,E)||1,C=-E/s,g=B/s,I=Math.min(.08*s,Math.max(1,.7*w));for(const s of[.3,.5,.7]){const w=A[0][0]+B*s,Y=A[0][1]+E*s;Q.push([[w-C*I,Y-g*I],[w+C*I,Y+g*I]])}}}else{const B=A.flip_v?1:-1,E=A.flip_h?s:-s,w=[E,B*A.rlen];Q.push([[E,0],w]);const C=[];for(let s=0;s<=16;s++){const w=B*s/16*Math.PI/2,Q=A.flip_h?-1:1;C.push([E+Q*Math.cos(w)*A.rlen,Math.sin(w)*A.rlen])}Q.push(C)}const C=A.angle*Math.PI/180,g=Math.cos(C),I=Math.sin(C);return Q.map(B=>B.map(([B,E])=>[A.rx+B*g-E*I,A.ry+B*I+E*g]))}function FB(A,B){const E=IB([A]);return B.filter(A=>{const B=IB([A]);return B.maxX>=E.minX&&B.minX<=E.maxX&&B.maxY>=E.minY&&B.minY<=E.maxY})}function iB(A){const B=function(A){const{rawSpace:B,space:E}=A,s=Number(B.cell_cm)>0?Number(B.cell_cm):5,w=Array.isArray(B.walls)?B.walls:[],Q=c(B,E,I,.02*Y),C=W(B,E,s,Y,I),g=m(C),M=n(E,s,Y,2e-4*Y,g).all,F=e(C,E,w,Q.contour,R,s,Y,I);return{cellCm:s,walls:w,zero:Q,openings:C,extras:M,geometry:A.sharedWallGeometry||h(E.rooms,w,Q.contour,F,R,s,Y,I,M)}}(A),E=new Map;if(A.options.dimensions)for(const s of A.space.rooms){const w=C(s);if(!w)continue;const Q=s.id?A.resolveInnerContour?.(s.id):void 0;E.set(s,s.id&&(void 0===Q?g(A.space.rooms,s.id,B.walls,B.zero.contour,R,B.cellCm,Y,I,B.geometry.roomGeom,B.geometry.multiWallNodes):Q)||w)}const s=new Map;if(A.options.dimensions)for(const w of A.space.rooms){const Q=C(w);if(!Q)continue;const g=E.get(w)||Q,I=w.id?A.resolveRoomArea?.(w.id,g):void 0,Y=Number.isFinite(I)?[]:FB(g,B.extras),R=Y.length?M(g,Y):null,i=Number.isFinite(I)&&I>=0?I:R?F(R):Math.abs(g.reduce((A,B,E)=>{const s=g[(E+1)%g.length];return A+B[0]*s[1]-s[0]*B[1]},0)/2);s.set(w,i)}const w=[..."failed-core"===B.geometry.status?A.space.rooms.map(A=>C(A)||[]).filter(A=>A.length):B.geometry.components.flatMap(A=>i(A.geom)),...B.zero.lines.map(A=>[[A[0],A[1]],[A[2],A[3]]])];A.options.decor&&w.push(...function(A){const B=[];for(const E of A.decor||[])"line"===E.kind?B.push([[E.x1*I,E.y1*I],[E.x2*I,E.y2*I]]):"text"!==E.kind?B.push(L(E).map(([A,B])=>[A*I,B*I])):B.push([[E.x*I,E.y*I]]);return B}(A.rawSpace));for(const B of A.rasters||[])w.push(RB(B.x,B.y,B.drawWidth,B.drawHeight,B.angle));let Q=IB(w);var x;[(x=Q).minX,x.minY,x.maxX,x.maxY].every(Number.isFinite)&&x.maxX>x.minX&&x.maxY>x.minY||(Q={minX:0,minY:0,maxX:I,maxY:I});return{built:B,dimensionContours:E,roomAreas:s,bounds:Q,cmPerUnit:B.cellCm/Y}}function xB(A,B,E,s){const{built:w,dimensionContours:Q,roomAreas:g,bounds:M,cmPerUnit:F}=B,c=(s?297:210)*$A,W=(s?210:297)*$A,m=12*$A,n=18*$A,e=24*$A,h=F*(10*$A)/E,j=(M.maxX-M.minX)*h,H=(M.maxY-M.minY)*h,v=m+n,V=W-v-m-e,U=c-2*m,a=A=>[0+(A[0]-M.minX)*h,0+(A[1]-M.minY)*h],P=(A,B)=>[M.minX+(A-0)/h,M.minY+(B-0)/h],y=A=>{const B=P(A.minX,A.minY),E=P(A.maxX,A.maxY);return{minX:B[0],minY:B[1],maxX:E[0],maxY:E[1]}},u=w.geometry.components.flatMap(A=>i(A.geom)),N=A=>w.geometry.components.some(B=>S([...A],B.geom)),K=A=>function(A,B,E){if(!LA(A)||!mA(B))return!0;const s=DA(A);return!!s.some(E)||!!B.some(B=>B.some(B=>xA(B)&&bA(B,A)))||nA(B,(A,B)=>s.some((E,w)=>null!==WA(A,B,E,s[(w+1)%s.length])))}(y(function(A,B){const E=Number.isFinite(B)&&B>=0?B:0;return{minX:A.minX-E,minY:A.minY-E,maxX:A.maxX+E,maxY:A.maxY+E}}(A,$A-1e-6)),u,N),d=(A,B)=>function(A,B,E){if(!LA(A)||!mA([B]))return!1;const s=DA(A);return!!s.every(E)&&!nA([B],(A,B)=>s.some((E,w)=>null!==WA(A,B,E,s[(w+1)%s.length])))}(y(A),B,A=>Z([...A],B)),J=(A,B,E={})=>function(A,B,E,s,w={}){if(!xA(A)||!xA(B)||!mA(E))return!0;if(w.allowStartExit){const w=tA(A,B);if(w<=iA)return!0;const Q=nA(E,(B,E)=>cA(A,B,E));if(!Q)return!0;const C=[];nA(E,(E,s)=>{const w=WA(A,B,E,s);return w&&C.push(w),!1});const g=iA/w,I=[0,1,...C.flatMap(A=>[A.t,A.endT])].sort((A,B)=>A-B).filter((A,B,E)=>0===B||A-E[B-1]>g),Y=E=>[A[0]+(B[0]-A[0])*E,A[1]+(B[1]-A[1])*E],R=A=>C.some(B=>B.overlap&&A>B.t+g&&AA.t>M+g||A.endT>M+g)}const Q=[(A[0]+B[0])/2,(A[1]+B[1])/2],C=nA(E,(B,E)=>cA(A,B,E));return!((!s(A)||w.allowStartBoundary&&C)&&!s(Q)&&!s(B))||nA(E,(E,s)=>{const Q=WA(A,B,E,s);return!!Q&&(Q.overlap||!w.allowStartBoundary||!C||Q.t*tA(A,B)>iA)})}(P(A[0],A[1]),P(B[0],B[1]),u,N,E),T=(A,B,E)=>{const s=A.x*I,w=A.y*I,Q=A.w*I,C=A.h*I,g=s+Q/2,Y=w+C/2,R=s+(A.flip_h?Q:0),F=w+(A.flip_v?C:0),i=(A.flip_h?-1:1)*Q/B,x=(A.flip_v?-1:1)*C/E,b=(Number(A.angle)||0)*Math.PI/180,L=Math.cos(b),D=Math.sin(b),G=Y+D*(R-g)+L*(F-Y);return{a:h*L*i,b:h*D*i,c:-h*D*x,d:h*L*x,e:0+(g+L*(R-g)-D*(F-Y)-M.minX)*h,f:0+(G-M.minY)*h}};let f=[];const z=[],O=function(A,B){const E=3*$A*Math.SQRT2,s=[];for(let w=-B;w<=A+E;w+=E)s.push([[w,0],[w+B,B]]);return s}(c,W);for(const B of A.rasters||[])f.push({kind:"image",imageId:B.id,...a([B.x,B.y]).reduce((A,B,E)=>({...A,[E?"y":"x"]:B}),{}),width:B.drawWidth*h,height:B.drawHeight*h,angle:B.angle,opacity:B.opacity});for(const A of w.geometry.components)f.push({kind:"path",rings:i(A.geom).map(A=>A.map(a)),fill:BB,stroke:AB,width:.25*$A,hatch:{lines:O,stroke:AB,width:.18*$A}});if("failed-core"===w.geometry.status)for(const B of A.space.rooms){const A=C(B);A&&f.push({kind:"path",rings:[A.map(a)],stroke:AB,width:.25*$A})}for(const A of w.zero.lines)f.push({kind:"line",points:[a([A[0],A[1]]),a([A[2],A[3]])],stroke:AB,width:.35*$A,dash:[3*$A,2*$A]});const q=w.geometry.openingIndex;for(const B of w.openings){const E=B.partitionHost?{cm:B.partitionHost.partition.cm}:q?x(A.space.rooms,B,w.walls,R,w.cellCm,Y,I,w.zero.contour):{cm:0};for(const A of MB(B,E.cm,w.cellCm))f.push({kind:"line",points:A.map(a),stroke:AB,width:.3*$A})}if(A.options.decor)for(const B of A.rawSpace.decor||[])if("image"!==B.kind)if("line"===B.kind)f.push({kind:"line",points:[a([B.x1*I,B.y1*I]),a([B.x2*I,B.y2*I])],stroke:AB,width:Math.max(.2*$A,10*Number(B.width_cm||1)*$A/E),dash:"dashed"===B.line_style?[3*$A,2*$A]:void 0});else if("text"===B.kind)f.push({kind:"text",...(()=>{const[A,E]=a([B.x*I,B.y*I]);return{x:A,y:E}})(),text:B.text,size:Math.max(6,10*Number(B.size_cm||20)*$A/E),angle:Number(B.angle)||0});else if("furniture"===B.kind){const A=r[B.symbol];A?f.push({kind:"vector",ops:YA(A.d,T(B,A.viewW,A.viewH)),stroke:AB,width:Math.max(.2*$A,10*b(B,w.cellCm,Y)*$A/E)}):f.push({kind:"path",rings:[L(B).map(([A,B])=>a([A*I,B*I]))],stroke:AB,width:.25*$A})}else{const A="ellipse"===B.kind?YB(B.x*I,B.y*I,B.w*I,B.h*I,Number(B.angle)||0):L(B).map(([A,B])=>[A*I,B*I]);f.push({kind:"path",rings:[A.map(a)],stroke:AB,width:.25*$A})}if(A.options.dimensions&&w.geometry.roomGeom)for(const[B,E]of D(w.geometry.roomGeom).entries()){const s=l(F),w=(A,B,E)=>{const s=a(A.sourceA),w=a(A.sourceB),Q=a(A.a),C=a(A.b),g=(6+E)*$A,I=[Q[0]+B[0]*g,Q[1]+B[1]*g],Y=[C[0]+B[0]*g,C[1]+B[1]*g],R=[(I[0]+Y[0])/2,(I[1]+Y[1])/2],M=PA(A.text,7)+2*$A>Math.hypot(Y[0]-I[0],Y[1]-I[1]),F=QB(wB(R[0],R[1],A.text,7,A.angle,"center"),R[0],R[1],B,$A),i=[R[0]+B[0]*F,R[1]+B[1]*F];return{edge:A,a:s,b:w,oa:I,ob:Y,middle:R,label:i,box:wB(i[0],i[1],A.text,7,A.angle,"center"),needsShelf:M}},Q=A=>{const B=[{start:A.oa,end:A.ob},{start:A.a,end:A.oa,allowStartExit:!0},{start:A.b,end:A.ob,allowStartExit:!0}];return A.needsShelf&&B.push({start:A.middle,end:A.label,mayEnterOwnLabel:!0}),B},C=A=>K(A.box)||Q(A).some(A=>J(A.start,A.end,{allowStartBoundary:A.allowStartBoundary,allowStartExit:A.allowStartExit})),g=EA(k(E,F,A.imperial,{ringIndex:B,epsilon:s}),{ring:E,epsilon:s,score:A=>{const B=[-A.inwardNormal[0],-A.inwardNormal[1]],E=a(A.mid),s=Array.from({length:21},(A,B)=>4*B).find(E=>!C(w(A,B,E))),Q=E[0]+(U-j)/2,g=E[1]+(V-H)/2;return{hardCollisions:void 0===s?21:s/4,normalClearance:Math.abs(B[0])>.5?B[0]>0?U-Q:Q:B[1]>0?V-g:g}}});for(const A of X(g,s)){const B=A.map(A=>({edge:A,outward:[-A.inwardNormal[0],-A.inwardNormal[1]]})),E=A=>B.map(({edge:B,outward:E})=>w(B,E,A));let s=null;for(let A=0;A<=80&&!s;A+=4){const B=E(A),w=B.some((A,E)=>B.slice(0,E).some(B=>sB(A.box,B.box))),g=B.some(A=>C(A)||z.some(B=>sB(A.box,B))),I=B.some((A,E)=>Q(A).some(A=>z.some(B=>eA(A.start,A.end,B))||B.some((B,s)=>(!A.mayEnterOwnLabel||s!==E)&&eA(A.start,A.end,B.box))));w||g||I||(s=B)}if(s)for(const A of s)f.push({kind:"line",points:[A.oa,A.ob],stroke:AB,width:.2*$A},{kind:"line",points:[A.a,A.oa],stroke:AB,width:.15*$A},{kind:"line",points:[A.b,A.ob],stroke:AB,width:.15*$A}),A.needsShelf&&f.push({kind:"line",points:[A.middle,A.label],stroke:AB,width:.15*$A}),f.push({kind:"text",x:A.label[0],y:A.label[1],text:A.edge.text,size:_A,angle:A.edge.angle,align:"center"}),z.push(A.box)}}const $=[...A.space.rooms].sort((A,B)=>String(A.id||"").localeCompare(String(B.id||"")));for(const[B,E]of $.entries()){const s=C(E);if(!s)continue;const w=Q.get(E)||s,I=g.get(E)||0,Y=G(E,A.space.id,A.layout,A.config),[R,M]=a([Y.x,Y.y]),i=w.map(a),x=IB([i]);let b=!1;if(A.options.roomNames&&E.name){const A=Math.max(0,x.maxX-x.minX-4*$A),B=PA(E.name,6.75)<=A?6.75:PA(E.name,5.25)<=A?5.25:0;B&&(f.push({kind:"text",x:R,y:M-2,text:E.name,size:B,align:"center"}),z.push(wB(R,M-2,E.name,B,0,"center")),b=!0)}if(A.options.dimensions){const B=o(I*F*F/1e4,A.imperial),E=M+(b?8:0);f.push({kind:"text",x:R,y:E,text:B,size:6,align:"center"}),z.push(wB(R,E,B,8,0,"center"))}if(A.options.dimensions){const E=l(F),s=EA(p(w,F,A.imperial,{ringIndex:B,epsilon:E}),{ring:w,epsilon:E,score:A=>{const B=a(A.mid),E=QB(wB(B[0],B[1],A.text,_A,A.angle,"center"),B[0],B[1],A.inwardNormal,$A),s=wB(B[0]+A.inwardNormal[0]*E,B[1]+A.inwardNormal[1]*E,A.text,7,A.angle,"center"),w="horizontal"===A.axis?A.inwardNormal[1]>0?x.maxY-B[1]:B[1]-x.minY:A.inwardNormal[0]>0?x.maxX-B[0]:B[0]-x.minX;return{hardCollisions:Number(K(s))+z.reduce((A,B)=>A+Number(sB(s,B)),0),normalClearance:w}}});for(const A of s.filter(A=>A.short)){const B=A.inwardNormal,E=a(A.a),s=a(A.b),w=(E[0]+s[0])/2,Q=(E[1]+s[1])/2;f.push({kind:"line",points:[[w-1.5*B[0]*$A,Q-1.5*B[1]*$A],[w+1.5*B[0]*$A,Q+1.5*B[1]*$A]],stroke:AB,width:.2*$A})}const Q=new Map;for(const A of s.filter(A=>!A.short)){const B=CB(A,A.inwardNormal),E=Q.get(B)||[];E.push(A),Q.set(B,E)}for(const A of Q.values()){let B=null;for(let E=0;E<=30&&!B;E+=3){const s=A.map(A=>{const B=a(A.mid),s=QB(wB(B[0],B[1],A.text,_A,A.angle,"center"),B[0],B[1],A.inwardNormal,(1+E)*$A),w=B[0]+A.inwardNormal[0]*s,Q=B[1]+A.inwardNormal[1]*s;return{edge:A,x:w,y:Q,box:wB(w,Q,A.text,_A,A.angle,"center")}}),Q=s.some((A,B)=>s.slice(0,B).some(B=>sB(A.box,B.box))),C=s.some(A=>K(A.box)||z.some(B=>sB(A.box,B))),g=s.every(A=>d(A.box,w));Q||C||!g||(B=s)}if(B)for(const A of B)f.push({kind:"text",x:A.x,y:A.y,text:A.edge.text,size:_A,angle:A.edge.angle,align:"center"}),z.push(A.box)}}}const _={minX:m,minY:v,maxX:c-m,maxY:v+V},AA=XA(f),BA=OA(AA,{minX:0,minY:0,maxX:U,maxY:V},.5*$A),sA=function(A,B){const E=XA(A);if(!ZA(E))return{commands:[...A],bounds:E,dx:0,dy:0};const s=(B.minX+B.maxX-E.minX-E.maxX)/2,w=(B.minY+B.maxY-E.minY-E.maxY)/2,Q=function(A,B,E){return A.map(A=>"path"===A.kind?{...A,rings:A.rings.map(A=>A.map(([A,s])=>[A+B,s+E]))}:"line"===A.kind?{...A,points:A.points.map(([A,s])=>[A+B,s+E])}:"vector"===A.kind?{...A,ops:A.ops.map(A=>((A,B,E)=>"M"===A.op||"L"===A.op?{...A,x:A.x+B,y:A.y+E}:"C"===A.op?{...A,x1:A.x1+B,y1:A.y1+E,x2:A.x2+B,y2:A.y2+E,x:A.x+B,y:A.y+E}:A)(A,B,E))}:{...A,x:A.x+B,y:A.y+E})}(A,s,w);return{commands:Q,bounds:{minX:E.minX+s,minY:E.minY+w,maxX:E.maxX+s,maxY:E.maxY+w},dx:s,dy:w}}(f,_);f=sA.commands,f.push({kind:"text",x:m,y:m+10,text:A.space.title,size:14}),A.cardTitle&&f.push({kind:"text",x:c-m,y:m+10,text:A.cardTitle,size:10,align:"right"});const wA=W-m-13*$A;f.push({kind:"line",points:[[m,wA-4*$A],[c-m,wA-4*$A]],stroke:EB,width:.2*$A}),f.push({kind:"text",x:m,y:wA,text:A.t("pdf.scale",{n:E}),size:8});const QA=10*(A.imperial?152.4:100)*$A/E,CA=wA+8;f.push({kind:"line",points:[[m,CA],[m+QA,CA]],stroke:AB,width:.4*$A});for(let A=0;A<=4;A++){const B=m+QA*A/4;f.push({kind:"line",points:[[B,CA-2],[B,CA+2]],stroke:AB,width:.25*$A})}f.push({kind:"text",x:m+QA/2,y:wA+17,text:A.imperial?"5 ft":"1 m",size:7,align:"center"});const gA=t(A.config.settings,A.rawSpace.settings||{});if(null!==gA){const B=c/2,E=wA+5.5*$A;f.push({kind:"vector",ops:FA({centerX:B,centerY:E,size:11*$A,northDeg:gA}),fill:AB,width:0,fillRule:"evenodd"}),f.push({kind:"text",x:B,y:wA,text:A.t("pdf.north"),size:7,align:"center"})}f.push({kind:"text",x:c-m,y:wA+12,text:`${qA(A.now)} · House Plan v${A.version}`,size:7,align:"right"});const IA={width:c,height:W,commands:f,images:(A.rasters||[]).map(({id:A,bytes:B,width:E,height:s})=>({id:A,bytes:B,width:E,height:s})),now:A.now,scale:E,sceneBounds:sA.bounds,planField:_},RA=Math.max(0,TA(AA))*Math.max(0,fA(AA)),MA=U*V;return{page:IA,sceneBounds:sA.bounds,field:_,fits:BA,fillRatio:MA>0?RA/MA:0,landscape:s}}function bB(A,B){return A.fillRatio!==B.fillRatio?A.fillRatio>B.fillRatio?A:B:A.landscape?B:A}function LB(A,B,E){const s=12*$A,w=(E?297:210)*$A-2*s,Q=(E?210:297)*$A-2*s-18*$A-24*$A,C=A.cmPerUnit*(10*$A)/B;return(A.bounds.maxX-A.bounds.minX)*C<=w+.5*$A&&(A.bounds.maxY-A.bounds.minY)*C<=Q+.5*$A}function DB(A){let B=0;for(const E of A)if(B+=Math.max(0,Number(E)||0),B>26214400)throw new Error("pdf.too_large")}const GB="ed91b3971428d2b8e7bfceb8025d2be4c0db7c58754eeb4ba03f835b8d7c84c6";async function oB(A,B){if(!A)throw new Error("pdf.asset_failed");const E=await fetch(A,{credentials:"same-origin"});if(!E.ok)throw new Error("pdf.asset_failed");const s=await E.blob();let w;try{w=await createImageBitmap(s)}catch{throw new Error("pdf.asset_failed")}try{if("image/jpeg"===s.type)return{id:B,bytes:new Uint8Array(await s.arrayBuffer()),width:w.width,height:w.height};const A=document.createElement("canvas");A.width=w.width,A.height=w.height;const E=A.getContext("2d");if(!E)throw new Error("pdf.asset_failed");E.fillStyle="#fff",E.fillRect(0,0,A.width,A.height),E.drawImage(w,0,0);const Q=await new Promise(B=>A.toBlob(B,"image/jpeg",.85));if(!Q)throw new Error("pdf.asset_failed");return{id:B,bytes:new Uint8Array(await Q.arrayBuffer()),width:w.width,height:w.height}}finally{w.close()}}async function tB(A,B,E){const s=await async function(A,B){const E=[];if(B.backdrop&&A.space.bg){const B=await oB(A.backdropUrl,"backdrop");E.push({...B,x:A.space.bg.x,y:A.space.bg.y,drawWidth:A.space.bg.w,drawHeight:A.space.bg.h,angle:A.space.bg.angle,opacity:.6})}if(B.decor){let B=0;for(const s of A.rawSpace.decor||[]){if("image"!==s.kind)continue;const w=A.decorAssets.get(s.asset_id),Q=j(s,I,I);if(!w||!Q)throw new Error("pdf.asset_failed");const C=await oB(w.url,"decor"+B++);E.push({...C,x:Q[0],y:Q[1],drawWidth:Q[2],drawHeight:Q[3],opacity:Q[4],angle:Number(s.angle)||0})}}return DB(E.map(A=>A.bytes.byteLength)),E}(A,B),w=JA(function(A){const B=iB(A);let E=[];for(const s of wA){const w=[!1,!0].filter(A=>LB(B,s,A)).map(E=>xB(A,B,s,E));if(!w.length)continue;const Q=w.filter(A=>A.fits);if(Q.length)return Q.reduce(bB).page;E=w}E.length||(E=[!1,!0].map(E=>xB(A,B,500,E)));const s=E.filter(A=>A.fits);if(s.length)return s.reduce(bB).page;const w=Math.min(...E.map(A=>Math.max(TA(A.sceneBounds)/TA(A.field),fA(A.sceneBounds)/fA(A.field)))),Q=50,C=1e6,g=Number.isFinite(w)?Math.ceil(Math.min(C,500*Math.max(1,w))/Q)*Q:C;let I=500,Y=0,R=[],M=Math.max(550,g);for(;M<=C;){const E=[!1,!0].map(E=>xB(A,B,M,E)).filter(A=>A.fits);if(E.length){Y=M,R=E;break}if(I=M,M===C)break;M=Math.min(C,Math.ceil(2*M/Q)*Q)}if(!Y)throw new Error("pdf.failed");let F=Math.floor(I/Q),i=Math.floor(Y/Q);for(;i-F>1;){const E=Math.floor((F+i)/2),s=[!1,!0].map(s=>xB(A,B,E*Q,s)).filter(A=>A.fits);s.length?(i=E,R=s):F=E}const x=R.reduce(bB).page;if(!OA(x.sceneBounds,x.planField,.5*$A))throw new Error("pdf.failed");return x}({...A,options:B,now:E,rasters:s,t:A.t})),Q=new Blob([w],{type:"application/pdf"}),C=URL.createObjectURL(Q);try{const B=document.createElement("a");B.href=C,B.download=`houseplan-${g=A.space.title,g.normalize("NFKD").replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-|-$/g,"").toLowerCase()||"space"}-${qA(E)}.pdf`,B.style.display="none",document.body.append(B),B.click(),B.remove()}finally{setTimeout(()=>URL.revokeObjectURL(C),0)}var g;return w}class cB{assertRasterBudget(A){DB(A)}render(A){let B;return B={...A,save:async E=>{await tB(A,E,B.now||new Date)}},s``}}export{GB as PDF_EXPORT_FINGERPRINT,cB as PdfExportRuntime,tB as exportSpacePdf}; + `}}v.properties={context:{attribute:!1}},v.styles=A`:host{display:contents;}.body{display:grid;gap:12px;width:100%;max-width:100%;min-width:0;padding:16px 20px;box-sizing:border-box;}label{display:flex;min-width:0;min-height:44px;align-items:center;gap:12px;cursor:pointer;}label span{min-width:0;overflow-wrap:anywhere;}input{width:20px;height:20px;flex:none;accent-color:var(--hp-accent,#d89300);}.row{display:flex;align-items:center;gap:8px;width:100%;max-width:100%;min-width:0;padding:12px 16px;box-sizing:border-box;}.spacer{flex:1;}button{min-width:0;min-height:44px;max-width:100%;display:inline-flex;align-items:center;justify-content:center;border:1px solid var(--hp-line,rgb(127 127 127/.3));border-radius:12px;padding:0 18px;box-sizing:border-box;overflow-wrap:anywhere;white-space:normal;background:transparent;color:inherit;font:inherit;cursor:pointer;}button.primary{background:var(--hp-accent,#d89300);color:var(--hp-on-accent,#111);border-color:transparent;}button:disabled{opacity:.55;cursor:default;}ha-icon{flex:none;margin-right:6px;}@media (max-width:360px){.row{display:grid;grid-template-columns:minmax(0,1fr);}.spacer{display:none;}button{width:100%;}}`,customElements.get("hp-pdf-dialog")||customElements.define("hp-pdf-dialog",v);const V=(A,B,E)=>Math.hypot(A[0]-B[0],A[1]-B[1])<=E,U=A=>Number.isFinite(A)&&A>=0?A:0;function l(A){const B=Number(A);return Number.isFinite(B)&&B>0?.1/B:0}const a=(A,B)=>[...new Set([...A,...B])].sort((A,B)=>A-B),P=(A,B)=>{const E=A.points.length;if(E<=1||!V(A.points[E-1],A.points[0],B))return!1;const s=E-2;return A.edgeSources[s]=a(A.edgeSources[s],A.edgeSources[E-1]),A.points.splice(E-1,1),A.edgeSources.splice(E-1,1),!0},y=(A,B)=>{for(let E=0;E+1{let E=!1;for(;A.points.length>1;)if(P(A,B))E=!0;else{if(!y(A,B))break;E=!0}return E},N=(A,B,E)=>{const s=B[0]-A[0],w=B[1]-A[1],C=E[0]-B[0],g=E[1]-B[1],I=Math.hypot(s,w),Y=Math.hypot(C,g);if(!(I>0&&Y>0))return!1;const R=s*C+w*g;if(!(R>0))return!1;const M=s*g-w*C;return Math.abs(M)<=R*Q},K=A=>{const B=A.points.length;if(B<3)return!1;for(let E=0;E{const E=U(B),s=[],w=[];for(let B=0;B[A])};for(;Q.points.length>1;){const A=u(Q,E);if(Q.points.length<3)break;if(!K(Q)&&!A)break}return u(Q,E),Q};function J(A,B){const E=Number(A[0]),s=Number(A[1]),w=Number(B[0]),C=Number(B[1]);if(![E,s,w,C].every(Number.isFinite))return null;const g=w-E,I=C-s,Y=Math.abs(g),R=Math.abs(I),M=Math.max(Y,R),F=Math.min(Y,R);if(!(M>0)||F/M>Q)return null;const i=[(E+w)/2,(s+C)/2];if(Y>=R){return{axis:"horizontal",a:[E,i[1]],b:[w,i[1]],mid:i,projectedLength:Y,tangentInterval:[Math.min(E,w),Math.max(E,w)],normalCoordinate:i[1]}}return{axis:"vertical",a:[i[0],s],b:[i[0],C],mid:i,projectedLength:R,tangentInterval:[Math.min(s,C),Math.max(s,C)],normalCoordinate:i[0]}}function Z(A,B){const E=B.map(A=>[Number(A[0]),Number(A[1])]);if(!E.every(A=>A.every(Number.isFinite)))return!1;if(E.length<3||((A,B)=>{const E=1e-12*Math.max(1,Math.abs(A[0]),Math.abs(A[1]),...B.flatMap(A=>[Math.abs(A[0]),Math.abs(A[1])]));for(let s=0;s0))continue;const Y=(A[0]-w[0])*g-(A[1]-w[1])*C;if(Math.abs(Y)>E*I)continue;const R=(A[0]-w[0])*C+(A[1]-w[1])*g;if(R>=-E&&R<=I*I+E)return!0}return!1})(A,E))return!1;let s=!1;for(let B=0,w=E.length-1;BA[1]==C[1]>A[1])continue;const g=(C[0]-Q[0])*(A[1]-Q[1])/(C[1]-Q[1])+Q[0];A[0]Object.is(A,-0)?0:A,I=[g(-Q/C),g(w/C)],Y=[g(-I[0]),g(-I[1])],R=[(B[0]+E[0])/2,(B[1]+E[1])/2],M=Math.max(1,C,Math.abs(R[0]),Math.abs(R[1])),F=Math.max(1e-9*M,.01*U(s));for(const B of[F,4*F,16*F]){const E=Z([R[0]+I[0]*B,R[1]+I[1]*B],A);if(E!==Z([R[0]+Y[0]*B,R[1]+Y[1]*B],A))return E?I:Y}return sA(A)>=0?I:Y}function f(A,B){let E=180*Math.atan2(B[1]-A[1],B[0]-A[0])/Math.PI;return E>90&&(E-=180),E<=-90&&(E+=180),E}function k(A,B,E,s={}){const w=Number(B);if(!(w>0&&Number.isFinite(w)))return[];const Q=void 0===s.epsilon?l(w):U(s.epsilon);return z(d(A,Q),w,E,{...s,epsilon:Q})}const z=(A,B,E,s)=>{if(A.points.length<3)return[];const Q=U(s.epsilon??l(B)),C=Number.isFinite(Number(s.ringIndex))?Number(s.ringIndex):0,g=[];for(let s=0;sQ))continue;const M=[...A.edgeSources[s]||[s]].sort((A,B)=>A-B),F=M[0]??s,i=T(A.points,R.a,R.b,Q),x=("horizontal"===R.axis?i[1]:i[0])<0?-1:1,b=[R.axis,O(R.tangentInterval[0]),String(x),O(C),O(F)].join("|"),L=R.projectedLength*B;g.push({sourceA:[...I],sourceB:[...Y],a:R.a,b:R.b,text:w(L,E),short:L<30,angle:f(R.a,R.b),mid:R.mid,axis:R.axis,projectedLength:R.projectedLength,tangentInterval:R.tangentInterval,normalCoordinate:R.normalCoordinate,inwardNormal:i,normalSign:x,source:{ringIndex:C,edgeIndex:F},sourceEdgeIndices:M,stableKey:b})}return g};function p(A,B,E,s={}){const w=Number(B);if(!(w>0&&Number.isFinite(w)))return[];const Q=void 0===s.epsilon?l(w):U(s.epsilon);let C=d(A,Q);if(sA(C.points)<0&&(C=(A=>{const B=A.points.length;return{points:[...A.points].reverse().map(A=>[...A]),edgeSources:A.points.map((E,s)=>[...A.edgeSources[(B-2-s+B)%B]])}})(C)),C.points.length){let A=0;for(let B=1;B({points:[...A.points.slice(B),...A.points.slice(0,B)],edgeSources:[...A.edgeSources.slice(B),...A.edgeSources.slice(0,B)]}))(C,A)}return z(C,w,E,{...s,epsilon:Q})}function X(A,B){const E=U(B),s=[];for(const B of A){const A=s.find(A=>A.axis===B.axis&&A.normalSign===B.normalSign&&Math.abs(A.normalCoordinate-B.normalCoordinate)<=E);A?A.edges.push(B):s.push({axis:B.axis,normalSign:B.normalSign,normalCoordinate:B.normalCoordinate,edges:[B]})}return s.map(A=>A.edges)}const O=A=>Object.is(A,-0)?"0":String(A),q=A=>"horizontal"===A?0:1;function $(A,B){return q(A.axis)-q(B.axis)||A.tangentInterval[0]-B.tangentInterval[0]||A.normalSign-B.normalSign||A.source.ringIndex-B.source.ringIndex||A.source.edgeIndex-B.source.edgeIndex}function _(A,B,E,s){const w=U(s);if(A.axis!==B.axis)return!1;if(A.source.ringIndex!==B.source.ringIndex)return!1;if(A.inwardNormal[0]*B.inwardNormal[0]+A.inwardNormal[1]*B.inwardNormal[1]>=-.5)return!1;if(!((A,B,E)=>Math.abs(A[0]-B[0])<=E&&Math.abs(A[1]-B[1])<=E)(A.tangentInterval,B.tangentInterval,w))return!1;if(Math.abs(A.projectedLength-B.projectedLength)>w)return!1;return Z([(A.mid[0]+B.mid[0])/2,(A.mid[1]+B.mid[1])/2],E)}const AA=(A,B)=>{const E=B?.(A);return{hardCollisions:Number.isFinite(Number(E?.hardCollisions))?Number(E?.hardCollisions):0,normalClearance:Number.isFinite(Number(E?.normalClearance))?Number(E?.normalClearance):0}},BA=(A,B,E)=>{const s=AA(A,E),w=AA(B,E);return s.hardCollisions-w.hardCollisions||w.normalClearance-s.normalClearance||$(A,B)};function EA(A,B){if(A.length<2)return[...A];const E=U(B.epsilon),s=function(A,B=1e-7){return d(A,B).points.map(A=>[...A])}(B.ring,E),w=[];for(let B=0;B{const E=A.separation-B.separation;if(E)return E;const s=$(A.left,A.right)<=0?A.left:A.right,w=s===A.left?A.right:A.left,Q=$(B.left,B.right)<=0?B.left:B.right,C=Q===B.left?B.right:B.left;return $(s,Q)||$(w,C)});const Q=new Set,C=new Set;for(const A of w){if(Q.has(A.left)||Q.has(A.right))continue;Q.add(A.left),Q.add(A.right);const E=BA(A.left,A.right,B.score)<=0?A.left:A.right;C.add(E===A.left?A.right:A.left)}return A.filter(A=>!C.has(A))}function sA(A){let B=0;for(let E=0;E1){const A=Math.sqrt(G);Y*=A,R*=A}const o=Math.max(0,Y*Y*R*R-Y*Y*D*D-R*R*L*L),t=Y*Y*D*D+R*R*L*L||1,c=(Q===C?-1:1)*Math.sqrt(o/t),W=c*Y*D/R,m=c*-R*L/Y,n=F*W-i*m+(A+g)/2,e=i*W+F*m+(B+I)/2;let h=gA(1,0,(L-W)/Y,(D-m)/R),S=gA((L-W)/Y,(D-m)/R,(-L-W)/Y,(-D-m)/R);!C&&S>0&&(S-=2*Math.PI),C&&S<0&&(S+=2*Math.PI);const j=Math.max(1,Math.ceil(Math.abs(S)/(Math.PI/2))),r=S/j,H=A=>[n+F*Y*Math.cos(A)-i*R*Math.sin(A),e+i*Y*Math.cos(A)+F*R*Math.sin(A)],v=A=>[-F*Y*Math.sin(A)-i*R*Math.cos(A),-i*Y*Math.sin(A)+F*R*Math.cos(A)],V=[];for(let A=0;A[B.a*A+B.c*E+B.e,B.b*A+B.d*E+B.f];return function(A){const B=A.match(/[AaCcHhLlMmQqSsTtVvZz]|[-+]?(?:\d*\.\d+|\d+\.?)(?:e[-+]?\d+)?/gi)||[],E=[];let s=0,w="",Q=0,C=0,g=0,I=0,Y=null,R=null;const M=()=>Number(B[s++]);for(;sB.length||QA.test(B[s]))throw new Error(`Invalid SVG path command ${w}`);const x=Array.from({length:i},M),b=A=>A+(F?Q:0),L=A=>A+(F?C:0);if("M"===A||"L"===A)Q=b(x[0]),C=L(x[1]),E.push({op:"M"===A?"M":"L",x:Q,y:C}),"M"===A&&(g=Q,I=C,w=F?"l":"L"),Y=R=null;else if("H"===A)Q=b(x[0]),E.push({op:"L",x:Q,y:C}),Y=R=null;else if("V"===A)C=L(x[0]),E.push({op:"L",x:Q,y:C}),Y=R=null;else if("C"===A){const A=b(x[0]),B=L(x[1]),s=b(x[2]),w=L(x[3]);Q=b(x[4]),C=L(x[5]),Y=[s,w],R=null,E.push({op:"C",x1:A,y1:B,x2:s,y2:w,x:Q,y:C})}else if("S"===A){const A=Y?2*Q-Y[0]:Q,B=Y?2*C-Y[1]:C,s=b(x[0]),w=L(x[1]);Q=b(x[2]),C=L(x[3]),Y=[s,w],R=null,E.push({op:"C",x1:A,y1:B,x2:s,y2:w,x:Q,y:C})}else if("Q"===A||"T"===A){const B="Q"===A?b(x[0]):R?2*Q-R[0]:Q,s="Q"===A?L(x[1]):R?2*C-R[1]:C,w=b("Q"===A?x[2]:x[0]),g=L("Q"===A?x[3]:x[1]);E.push({op:"C",x1:Q+2/3*(B-Q),y1:C+2/3*(s-C),x2:w+2/3*(B-w),y2:g+2/3*(s-g),x:w,y:g}),Q=w,C=g,R=[B,s],Y=null}else if("A"===A){const A=b(x[5]),B=L(x[6]),s=IA(Q,C,x[0],x[1],x[2],x[3],x[4],A,B);s.length?E.push(...s):E.push({op:"L",x:A,y:B}),Q=A,C=B,Y=R=null}}return E}(A).map(A=>{if("Z"===A.op)return A;if("M"===A.op||"L"===A.op){const[B,s]=E(A.x,A.y);return{op:A.op,x:B,y:s}}if("C"!==A.op)throw new Error("Unsupported PDF vector operation");const[B,s]=E(A.x1,A.y1),[w,Q]=E(A.x2,A.y2),[C,g]=E(A.x,A.y);return{op:"C",x1:B,y1:s,x2:w,y2:Q,x:C,y:g}})}const RA=["M20.82,15.31h0L10.46,9c-.46-.26-1.11.37-.86.84l6.15,10.56,10.56,6.15a.66.66,0,0,0,.84-.86Zm-4,4,3-3,4.55,7.44Z","M18,2A16,16,0,1,0,34,18,16,16,0,0,0,18,2Zm1,29.95V29.53H17v2.42A14,14,0,0,1,4.05,19H6.47V17H4.05A14,14,0,0,1,17,4.05V6.47h2V4.05A14,14,0,0,1,31.95,17H29.53v2h2.42A14,14,0,0,1,19,31.95Z"],MA=A=>Math.abs(A)<1e-12?0:Math.abs(A-1)<1e-12?1:Math.abs(A+1)<1e-12?-1:A;function FA(A){const B=function(A){const{centerX:B,centerY:E,size:s,northDeg:w}=A;if(![B,E,s,w].every(Number.isFinite)||s<=0)throw new RangeError("PDF compass placement must contain finite coordinates and a positive size");const Q=((w%360+360)%360+45)*Math.PI/180,C=s/36,g=MA(Math.cos(Q)),I=MA(Math.sin(Q)),Y=C*g,R=C*I,M=-C*I,F=C*g;return{a:Y,b:R,c:M,d:F,e:B-18*Y-18*M,f:E-18*R-18*F}}(A);return RA.flatMap(A=>YA(A,B))}const iA=1e-8,xA=A=>A.length>=2&&Number.isFinite(A[0])&&Number.isFinite(A[1]),bA=(A,B)=>A[0]>=B.minX-iA&&A[0]<=B.maxX+iA&&A[1]>=B.minY-iA&&A[1]<=B.maxY+iA,LA=A=>[A.minX,A.minY,A.maxX,A.maxY].every(Number.isFinite)&&A.maxX>=A.minX&&A.maxY>=A.minY,DA=A=>[[A.minX,A.minY],[A.maxX,A.minY],[A.maxX,A.maxY],[A.minX,A.maxY]];const GA=(A,B,E)=>(B[0]-A[0])*(E[1]-A[1])-(B[1]-A[1])*(E[0]-A[0]),oA=(A,B,E)=>{const s=E[0]-B[0],w=E[1]-B[1],Q=Math.abs(s)>=Math.abs(w)?s:w;return Math.abs(Q)<=iA?0:(Math.abs(s)>=Math.abs(w)?A[0]-B[0]:A[1]-B[1])/Q},tA=(A,B)=>Math.hypot(B[0]-A[0],B[1]-A[1]);function cA(A,B,E){const s=tA(B,E);if(s<=iA)return tA(A,B)<=iA;if(Math.abs(GA(B,E,A))/s>iA)return!1;const w=oA(A,B,E),Q=iA/s;return w>=-Q&&w<=1+Q}function WA(A,B,E,s){const w=B[0]-A[0],Q=B[1]-A[1],C=s[0]-E[0],g=s[1]-E[1],I=Math.hypot(w,Q),Y=Math.hypot(C,g);if(I<=iA)return cA(A,E,s)?{t:0,endT:0,overlap:!1}:null;if(Y<=iA){if(!cA(E,A,B))return null;const s=Math.max(0,Math.min(1,oA(E,A,B)));return{t:s,endT:s,overlap:!1}}const R=w*g-Q*C,M=E[0]-A[0],F=E[1]-A[1],i=iA*I*Y;if(Math.abs(R)<=i){if(Math.abs(GA(A,B,E))/I>iA||Math.abs(GA(A,B,s))/I>iA)return null;const w=oA(E,A,B),Q=oA(s,A,B),C=Math.max(0,Math.min(w,Q)),g=Math.min(1,Math.max(w,Q));return giA}}const x=(M*g-F*C)/R,b=(M*Q-F*w)/R,L=iA/I,D=iA/Y;if(x<-L||x>1+L||b<-D||b>1+D)return null;const G=Math.max(0,Math.min(1,x));return{t:G,endT:G,overlap:!1}}const mA=A=>A.every(A=>A.length>=2&&A.every(xA));function nA(A,B){for(const E of A){const A=E;for(let E=0;Enull!==WA(A,B,E,s[(w+1)%s.length]))}const hA=2048,SA=2146,jA=[-1825,-555,4188,2163],rA={32:1,33:2,34:3,35:4,36:5,37:6,38:7,39:8,40:9,41:10,42:11,43:12,44:13,45:14,46:15,47:16,48:17,49:18,50:19,51:20,52:21,53:22,54:23,55:24,56:25,57:26,58:27,59:28,60:29,61:30,62:31,63:32,64:33,65:34,66:35,67:36,68:37,69:38,70:39,71:40,72:41,73:42,74:43,75:44,76:45,77:46,78:47,79:48,80:49,81:50,82:51,83:52,84:53,85:54,86:55,87:56,88:57,89:58,90:59,91:60,92:61,93:62,94:63,95:64,96:65,97:66,98:67,99:68,100:69,101:70,102:71,103:72,104:73,105:74,106:75,107:76,108:77,109:78,110:79,111:80,112:81,113:82,114:83,115:84,116:85,117:86,118:87,119:88,120:89,121:90,122:91,123:92,124:93,125:94,126:95,160:596,161:96,162:97,163:98,164:99,165:100,166:101,167:102,168:103,169:104,170:105,171:106,172:107,173:597,174:108,175:109,176:110,177:111,178:112,179:113,180:114,181:115,182:116,183:117,184:118,185:119,186:120,187:121,188:122,189:123,190:124,191:125,192:603,193:604,194:605,195:606,196:607,197:608,198:126,199:609,200:610,201:611,202:612,203:613,204:614,205:615,206:616,207:617,208:599,209:618,210:619,211:620,212:621,213:622,214:623,215:127,216:128,217:624,218:625,219:626,220:627,221:628,222:129,223:130,224:629,225:630,226:631,227:632,228:633,229:634,230:131,231:635,232:636,233:637,234:638,235:639,236:640,237:641,238:642,239:643,240:132,241:644,242:645,243:646,244:647,245:648,246:649,247:133,248:134,249:650,250:651,251:652,252:653,253:654,254:135,255:655,256:656,257:657,258:658,259:659,260:660,261:661,262:662,263:663,264:664,265:665,266:666,267:667,268:668,269:669,270:670,271:671,272:598,273:136,274:672,275:673,276:674,277:675,278:676,279:677,280:678,281:679,282:680,283:681,284:682,285:683,286:684,287:685,288:686,289:687,290:688,291:689,292:690,293:691,294:137,295:600,296:692,297:693,298:694,299:695,300:696,301:697,302:698,303:699,304:700,305:138,306:701,307:702,308:703,309:704,310:705,311:706,312:139,313:707,314:708,315:709,316:710,317:711,318:712,319:713,320:714,321:140,322:141,323:715,324:716,325:717,326:718,327:719,328:720,329:721,330:142,331:143,332:722,333:723,334:724,335:725,336:726,337:727,338:144,339:145,340:728,341:729,342:730,343:731,344:732,345:733,346:734,347:735,348:736,349:737,350:738,351:739,352:742,353:743,354:744,355:745,356:746,357:747,358:601,359:602,360:748,361:749,362:750,363:751,364:752,365:753,366:754,367:755,368:756,369:757,370:758,371:759,372:760,373:761,374:762,375:763,376:764,377:765,378:766,379:767,380:768,381:769,382:770,383:146,1024:897,1025:856,1026:165,1027:857,1028:166,1029:858,1030:859,1031:860,1032:861,1033:167,1034:168,1035:169,1036:863,1037:898,1038:864,1039:170,1040:865,1041:171,1042:866,1043:867,1044:172,1045:868,1046:173,1047:174,1048:175,1049:869,1050:862,1051:176,1052:870,1053:871,1054:872,1055:873,1056:874,1057:875,1058:876,1059:177,1060:178,1061:877,1062:179,1063:180,1064:181,1065:182,1066:183,1067:184,1068:185,1069:186,1070:187,1071:188,1072:878,1073:189,1074:190,1075:191,1076:192,1077:879,1078:193,1079:194,1080:195,1081:880,1082:196,1083:197,1084:198,1085:199,1086:881,1087:200,1088:882,1089:883,1090:201,1091:884,1092:202,1093:885,1094:203,1095:204,1096:205,1097:206,1098:207,1099:208,1100:209,1101:210,1102:211,1103:212,1104:899,1105:886,1106:213,1107:887,1108:214,1109:888,1110:889,1111:890,1112:891,1113:215,1114:216,1115:217,1116:892,1117:900,1118:893,1119:218,1120:219,1121:220,1122:965,1123:221,1124:222,1125:223,1126:224,1127:225,1128:226,1129:227,1130:228,1131:229,1132:230,1133:231,1134:232,1135:233,1136:901,1137:902,1138:234,1139:235,1140:236,1141:237,1142:903,1143:904,1144:906,1145:905,1146:238,1147:239,1148:240,1149:241,1150:242,1151:243,1152:244,1153:245,1154:246,1155:247,1156:248,1157:249,1158:250,1159:251,1160:252,1161:253,1162:254,1163:255,1164:964,1165:256,1166:257,1167:258,1168:259,1169:260,1170:966,1171:967,1172:261,1173:262,1174:263,1175:264,1176:907,1177:908,1178:265,1179:266,1180:267,1181:268,1182:968,1183:969,1184:269,1185:270,1186:271,1187:272,1188:273,1189:274,1190:275,1191:276,1192:277,1193:278,1194:909,1195:910,1196:955,1197:956,1198:911,1199:912,1200:970,1201:971,1202:279,1203:280,1204:281,1205:282,1206:283,1207:284,1208:285,1209:286,1210:287,1211:963,1212:288,1213:289,1214:961,1215:962,1216:913,1217:914,1218:915,1219:290,1220:291,1221:292,1222:293,1223:294,1224:295,1225:296,1226:297,1227:957,1228:958,1229:298,1230:299,1231:916,1232:917,1233:918,1234:919,1235:920,1236:921,1237:922,1238:923,1239:924,1240:300,1241:926,1242:925,1243:927,1244:928,1245:929,1246:930,1247:931,1248:301,1249:302,1250:932,1251:933,1252:934,1253:935,1254:936,1255:937,1256:938,1257:939,1258:940,1259:941,1260:942,1261:943,1262:944,1263:945,1264:946,1265:947,1266:948,1267:949,1268:950,1269:951,1270:959,1271:960,1272:952,1273:953,1274:303,1275:304,1276:305,1277:306,1278:972,1279:973,1280:307,1281:954,1282:308,1283:309,1284:310,1285:311,1286:312,1287:313,1288:314,1289:315,1290:316,1291:317,1292:318,1293:319,1294:320,1295:321,1296:322,1297:974,1298:323,1299:324,1300:325,1301:326,1302:327,1303:328,1304:329,1305:330,1306:982,1307:983,1308:984,1309:985,1310:331,1311:332,1312:333,1313:334,1314:335,1315:336,1316:337,1317:338,1318:339,1319:340,1320:341,1321:342,1322:343,1323:344,1324:345,1325:346,1326:347,1327:348,8192:349,8193:350,8194:351,8195:352,8196:353,8197:354,8198:355,8199:356,8200:357,8201:358,8202:360,8203:361,8204:362,8205:363,8206:364,8207:365,8208:366,8209:367,8210:368,8211:369,8212:370,8213:975,8214:371,8215:372,8216:373,8217:374,8218:375,8219:376,8220:377,8221:378,8222:379,8223:380,8224:381,8225:382,8226:383,8227:384,8228:385,8229:386,8230:387,8231:388,8239:986,8240:389,8241:390,8242:894,8243:895,8244:391,8245:392,8246:393,8247:394,8248:395,8249:396,8250:397,8251:398,8252:896,8253:399,8254:400,8255:401,8256:402,8257:403,8258:404,8259:405,8260:406,8261:407,8262:408,8263:987,8264:988,8265:989,8266:409,8267:410,8268:411,8269:412,8270:413,8271:414,8272:415,8273:416,8274:417,8275:418,8276:419,8277:420,8278:421,8279:422,8280:423,8281:424,8282:425,8283:426,8284:427,8285:428,8286:429,8287:990,8364:430,8381:431,8776:433},HA={1:507,2:527,3:655,4:1261,5:1150,6:1500,7:1273,8:357,9:700,10:712,11:882,12:1161,13:402,14:565,15:539,16:844,17:1150,18:1150,19:1150,20:1150,21:1150,22:1150,23:1150,24:1150,25:1150,26:1150,27:496,28:433,29:1041,30:1124,31:1070,32:967,33:1839,34:1336,35:1275,36:1333,37:1343,38:1164,39:1132,40:1395,41:1460,42:557,43:1130,44:1284,45:1102,46:1788,47:1460,48:1408,49:1292,50:1408,51:1261,52:1215,53:1222,54:1328,55:1303,56:1817,57:1284,58:1230,59:1226,60:543,61:840,62:543,63:856,64:924,65:633,66:1114,67:1149,68:1072,69:1155,70:1085,71:711,72:1149,73:1128,74:497,75:489,76:1038,77:497,78:1795,79:1130,80:1168,81:1149,82:1164,83:693,84:1056,85:669,86:1129,87:992,88:1539,89:1015,90:969,91:1015,92:693,93:499,94:693,95:1393,96:499,97:1120,98:1190,99:1460,100:1075,101:491,102:1256,103:856,104:1609,105:915,106:961,107:1134,108:1610,109:938,110:765,111:1094,112:751,113:751,114:642,115:1160,116:1001,117:534,118:507,119:751,120:931,121:960,122:1500,123:1589,124:1593,125:969,126:1914,127:1092,128:1408,129:1210,130:1218,131:1729,132:1200,133:1169,134:1160,135:1180,136:1223,137:1434,138:506,139:1139,140:1103,141:553,142:1419,143:1160,144:1953,145:1860,146:508,165:1535,166:1380,167:2193,168:2212,169:1666,170:1460,171:1291,172:1540,173:1859,174:1215,175:1460,176:1449,177:1287,178:1580,179:1497,180:1402,181:1927,182:1984,183:1554,184:1771,185:1285,186:1380,187:1831,188:1304,189:1132,190:1170,191:859,192:1236,193:1568,194:1040,195:1182,196:1106,197:1184,198:1519,199:1181,200:1182,201:984,202:1485,203:1213,204:1113,205:1656,206:1694,207:1271,208:1590,209:1112,210:1101,211:1671,212:1124,213:1128,214:1101,215:1737,216:1764,217:1161,218:1182,219:1800,220:1579,221:1110,222:1835,223:1528,224:1234,225:1094,226:1803,227:1547,228:1745,229:1505,230:2308,231:2001,232:1059,233:987,234:1393,235:1163,236:1290,237:1027,238:1393,239:1160,240:1793,241:1572,242:1800,243:1579,244:1330,245:1095,246:1277,247:1024,248:1024,249:1024,250:1024,251:1024,252:1024,253:1024,254:1545,255:1261,256:1110,257:1307,258:1161,259:1123,260:912,261:1243,262:1029,263:1954,264:1633,265:1434,266:1208,267:1289,268:1150,269:1676,270:1411,271:1535,272:1241,273:1999,274:1460,275:2097,276:1780,277:1518,278:1235,279:1304,280:1066,281:1836,282:1372,283:1468,284:1174,285:1391,286:1130,287:1391,288:1583,289:1213,290:1289,291:1114,292:1534,293:1263,294:1458,295:1160,296:1554,297:1260,298:1871,299:1598,300:1415,301:1192,302:1192,303:1207,304:939,305:1326,306:1088,307:1270,308:1684,309:1764,310:1622,311:1323,312:1097,313:1031,314:1985,315:1653,316:2043,317:1697,318:1270,319:1053,320:1453,321:1312,322:1380,323:1538,324:1266,325:1920,326:1549,327:1857,328:1547,329:1926,330:1774,331:1316,332:1106,333:2274,334:1832,335:2300,336:1829,337:1526,338:1242,339:1468,340:1208,341:1539,342:1273,343:2710,344:2238,345:1568,346:1240,347:1515,348:1243,349:1044,350:2089,351:1044,352:2089,353:697,354:522,355:348,356:1151,357:560,358:418,360:209,361:1024,362:1024,363:1024,364:1024,365:1024,366:564,367:564,368:1171,369:1344,370:1599,371:778,372:933,373:409,374:409,375:407,376:409,377:724,378:731,379:705,380:764,381:1129,382:1167,383:690,384:1100,385:511,386:964,387:1370,388:382,389:1962,390:2360,391:1045,392:463,393:757,394:1045,395:803,396:614,397:614,398:1241,399:919,400:952,401:1540,402:1540,403:874,404:1370,405:870,406:931,407:640,408:641,409:907,410:1001,411:1237,412:1237,413:985,414:511,415:1541,416:985,417:931,418:1366,419:1540,420:1172,421:932,422:1333,423:1215,424:1125,425:379,426:1071,427:1162,428:379,429:379,430:1150,431:1359,433:1154,596:507,597:565,598:1373,599:1373,600:1158,601:1222,602:669,603:1336,604:1336,605:1336,606:1336,607:1336,608:1336,609:1333,610:1164,611:1164,612:1164,613:1164,614:557,615:557,616:557,617:557,618:1460,619:1408,620:1408,621:1408,622:1408,623:1408,624:1328,625:1328,626:1328,627:1328,628:1230,629:1114,630:1114,631:1114,632:1114,633:1114,634:1114,635:1072,636:1085,637:1085,638:1085,639:1085,640:506,641:506,642:506,643:506,644:1130,645:1168,646:1168,647:1168,648:1168,649:1168,650:1129,651:1129,652:1129,653:1129,654:969,655:969,656:1336,657:1114,658:1336,659:1114,660:1336,661:1114,662:1333,663:1072,664:1333,665:1072,666:1333,667:1072,668:1333,669:1072,670:1343,671:1305,672:1164,673:1085,674:1164,675:1085,676:1164,677:1085,678:1164,679:1085,680:1164,681:1085,682:1395,683:1149,684:1395,685:1149,686:1395,687:1149,688:1395,689:1149,690:1460,691:1128,692:557,693:506,694:557,695:506,696:557,697:506,698:557,699:497,700:557,701:1687,702:986,703:1130,704:515,705:1284,706:1038,707:1102,708:497,709:1102,710:497,711:1102,712:647,713:1102,714:717,715:1460,716:1130,717:1460,718:1130,719:1460,720:1130,721:1130,722:1408,723:1168,724:1408,725:1168,726:1408,727:1168,728:1261,729:693,730:1261,731:693,732:1261,733:693,734:1215,735:1056,736:1215,737:1056,738:1215,739:1056,742:1215,743:1056,744:1222,745:669,746:1222,747:709,748:1328,749:1129,750:1328,751:1129,752:1328,753:1129,754:1328,755:1129,756:1328,757:1129,758:1328,759:1129,760:1817,761:1539,762:1230,763:969,764:1230,765:1226,766:1015,767:1226,768:1015,769:1226,770:1015,856:1164,857:1139,858:1215,859:557,860:557,861:1130,862:1316,863:1284,864:1287,865:1336,866:1275,867:1139,868:1164,869:1460,870:1788,871:1460,872:1408,873:1461,874:1292,875:1333,876:1222,877:1284,878:1114,879:1085,880:1182,881:1168,882:1149,883:1072,884:969,885:1015,886:1085,887:859,888:1056,889:497,890:506,891:489,892:1106,893:969,894:357,895:655,896:1054,897:1164,898:1460,899:1085,900:1182,901:1417,902:1434,903:1290,904:1027,905:2137,906:2377,907:1215,908:1040,909:1333,910:1072,911:1230,912:1026,913:557,914:1859,915:1568,916:557,917:1336,918:1114,919:1336,920:1114,921:1914,922:1729,923:1164,924:1085,925:1415,926:1079,927:1079,928:1859,929:1568,930:1215,931:1040,932:1460,933:1182,934:1460,935:1182,936:1408,937:1168,938:1393,939:1163,940:1393,941:1163,942:1380,943:1101,944:1287,945:969,946:1287,947:969,948:1287,949:969,950:1402,951:1113,952:1771,953:1590,954:1155,955:1222,956:984,957:1402,958:1113,959:1139,960:859,961:1583,962:1213,963:1128,964:1285,965:1285,966:1139,967:859,968:1336,969:1063,970:1230,971:1026,972:1284,973:1015,974:1104,975:1599,982:1408,983:1164,984:1817,985:1539,986:507,987:1934,988:1494,989:1494,990:507},vA=new TextEncoder,VA=A=>{const B=Math.round(100*A)/100;return Number.isInteger(B)?String(B):B.toFixed(2).replace(/0+$/,"")},UA=A=>{const B=Math.round(1e6*A)/1e6;return Number.isInteger(B)?String(B):B.toFixed(6).replace(/0+$/,"")},lA=A=>A.map(UA).join(" ");function aA(A){let B="",E=0;const s=new Map;for(const w of A){const A=w.codePointAt(0)||0,Q=rA[A]||rA[63];B+=Q.toString(16).padStart(4,"0"),E+=HA[Q]||1024,s.has(Q)||s.set(Q,A||63)}return{hex:B,width:E,unicode:s}}function PA(A,B){return aA(A).width*B/hA}function yA(A,B=PA(A.text,A.size)){const E=A.align||"left",s="center"===E?B/2:"right"===E?B:0,w=(A.angle||0)*Math.PI/180,Q=Math.cos(w),C=Math.sin(w);return{width:B,baselineX:A.x-Q*s,baselineY:A.y+C*s,cos:Q,sin:C}}function uA(A){const B=yA(A),E=-555*A.size/hA,s=SA*A.size/hA,w=[0,B.width].flatMap(A=>[E,s].map(E=>({x:B.baselineX+B.cos*A-B.sin*E,y:B.baselineY-B.sin*A-B.cos*E})));return{minX:Math.min(...w.map(A=>A.x)),minY:Math.min(...w.map(A=>A.y)),maxX:Math.max(...w.map(A=>A.x)),maxY:Math.max(...w.map(A=>A.y))}}function NA(A){const B=A.reduce((A,B)=>A+B.length,0),E=new Uint8Array(B);let s=0;for(const B of A)E.set(B,s),s+=B.length;return E}const KA=A=>vA.encode(A),dA=(A,B)=>NA([KA(`<< ${A} /Length ${B.length} >>\nstream\n`),B,KA("\nendstream")]);function JA(A){const B=function(A){const B=atob(A),E=new Uint8Array(B.length);for(let A=0;A"image"===A.kind&&null!=A.opacity&&A.opacity<1?[Math.max(0,Math.min(1,A.opacity))]:[]))].sort((A,B)=>A-B),s=new Map(E.map((A,B)=>[A,`GS${B+1}`])),w=function(A,B){const E=[],s=new Map,w=B=>A.height-B,Q=(A,...B)=>`${B.map(VA).join(" ")} ${A}`,C=A=>{for(const B of A)if(B.length){E.push(Q("m",B[0][0],w(B[0][1])));for(let A=1;A{let B=!1;for(const s of A)if(!(s.length<2)){B=!0,E.push(Q("m",s[0][0],w(s[0][1])));for(let A=1;A Tj`,"ET")}else{const A=(I.angle||0)*Math.PI/180,s=Math.cos(A),C=Math.sin(A),g=I.x+I.width/2,Y=w(I.y+I.height/2);E.push("q");const R=null==I.opacity?1:Math.max(0,Math.min(1,I.opacity)),M=B.get(R);M&&E.push(`/${M} gs`),E.push(Q("cm",s*I.width,C*I.width,C*I.height,-s*I.height,g-s*I.width/2-C*I.height/2,Y-C*I.width/2+s*I.height/2),`/Im${I.imageId} Do`,"Q")}return{stream:E.join("\n"),unicode:s}}(A,s),Q=Math.max(0,...Object.keys(HA).map(Number)),C=Array.from({length:Q+1},(A,B)=>Math.round(1e3*(HA[B]||1024)/hA)),g=[],I=A=>(g.push("string"==typeof A?KA(A):A),g.length),Y=I(""),R=I(""),M=I(""),F=I(dA(`/Length1 ${B.length}`,B)),i=I(`<< /Type /FontDescriptor /FontName /Roboto /Flags 32 /FontBBox [${jA.join(" ")}] /ItalicAngle 0 /Ascent 2146 /Descent -555 /CapHeight 2146 /StemV 80 /FontFile2 ${F} 0 R >>`),x=I(`<< /Type /Font /Subtype /CIDFontType2 /BaseFont /Roboto /CIDSystemInfo << /Registry (Adobe) /Ordering (Identity) /Supplement 0 >> /FontDescriptor ${i} 0 R /W [0 [${C.join(" ")}]] /CIDToGIDMap /Identity >>`),b=KA(function(A){const B=[...A].sort((A,B)=>A[0]-B[0]),E=B.map(([A,B])=>`<${A.toString(16).padStart(4,"0")}> <${B<=65535?B.toString(16).padStart(4,"0"):(()=>{const A=B-65536;return(55296+(A>>10)).toString(16).padStart(4,"0")+(56320+(1023&A)).toString(16).padStart(4,"0")})()}>`);return`/CIDInit /ProcSet findresource begin\n12 dict begin\nbegincmap\n/CIDSystemInfo << /Registry (Adobe) /Ordering (UCS) /Supplement 0 >> def\n/CMapName /HousePlanUnicode def\n/CMapType 2 def\n1 begincodespacerange\n<0000> \nendcodespacerange\n${B.length} beginbfchar\n${E.join("\n")}\nendbfchar\nendcmap\nCMapName currentdict /CMap defineresource pop\nend\nend`}(w.unicode)),L=I(dA("",b)),D=I(`<< /Type /Font /Subtype /Type0 /BaseFont /Roboto /Encoding /Identity-H /DescendantFonts [${x} 0 R] /ToUnicode ${L} 0 R >>`),G=I(dA("",KA(w.stream))),o=[];for(const B of A.images||[]){const A=I(dA(`/Type /XObject /Subtype /Image /Width ${B.width} /Height ${B.height} /ColorSpace /DeviceRGB /BitsPerComponent 8 /Filter /DCTDecode`,B.bytes));o.push(`/Im${B.id} ${A} 0 R`)}const t=A.now.toISOString().replace(/[-:T]/g,"").slice(0,14),c=I(`<< /CreationDate (D:${t}Z) /ModDate (D:${t}Z) >>`),W=`<< /Font << /F1 ${D} 0 R >>`+(o.length?` /XObject << ${o.join(" ")} >>`:"")+(E.length?` /ExtGState << ${E.map(A=>`/${s.get(A)} << /ca ${VA(A)} /CA ${VA(A)} >>`).join(" ")} >>`:"")+" >>";g[Y-1]=KA(`<< /Type /Catalog /Pages ${R} 0 R >>`),g[R-1]=KA(`<< /Type /Pages /Kids [${M} 0 R] /Count 1 >>`),g[M-1]=KA(`<< /Type /Page /Parent ${R} 0 R /MediaBox [0 0 ${VA(A.width)} ${VA(A.height)}] /Resources ${W} /Contents ${G} 0 R >>`);const m=KA("%PDF-1.4\n%âãÏÓ\n"),n=[m],e=[0];let h=m.length;g.forEach((A,B)=>{const E=KA(`${B+1} 0 obj\n`),s=KA("\nendobj\n");e.push(h),n.push(E,A,s),h+=E.length+A.length+s.length});const S=h,j=["xref",`0 ${g.length+1}`,"0000000000 65535 f "];for(let A=1;A<=g.length;A++)j.push(`${String(e[A]).padStart(10,"0")} 00000 n `);return j.push(`trailer\n<< /Size ${g.length+1} /Root ${Y} 0 R /Info ${c} 0 R >>`,`startxref\n${S}\n%%EOF\n`),n.push(KA(j.join("\n"))),NA(n)}const ZA=A=>[A.minX,A.minY,A.maxX,A.maxY].every(Number.isFinite)&&A.maxX>=A.minX&&A.maxY>=A.minY,TA=A=>A.maxX-A.minX,fA=A=>A.maxY-A.minY;function kA(A,B,E,s=0){Number.isFinite(B)&&Number.isFinite(E)&&(A.minX=Math.min(A.minX,B-s),A.minY=Math.min(A.minY,E-s),A.maxX=Math.max(A.maxX,B+s),A.maxY=Math.max(A.maxY,E+s))}function zA(A,B,E,s,w,Q){const C=Q*Math.PI/180,g=Math.cos(C),I=Math.sin(C),Y=B+s/2,R=E+w/2;for(const[B,E]of[[-s/2,-w/2],[s/2,-w/2],[s/2,w/2],[-s/2,w/2]])kA(A,Y+g*B-I*E,R+I*B+g*E)}function pA(A,B,E){for(const s of B)"M"===s.op||"L"===s.op?kA(A,s.x,s.y,E):"C"===s.op&&(kA(A,s.x1,s.y1,E),kA(A,s.x2,s.y2,E),kA(A,s.x,s.y,E))}function XA(A){const B={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};for(const E of A)if("path"===E.kind){const A=E.stroke?(E.width||.5)/2:0;for(const s of E.rings)for(const[E,w]of s)kA(B,E,w,A)}else if("line"===E.kind)for(const[A,s]of E.points)kA(B,A,s,E.width/2);else if("vector"===E.kind)pA(B,E.ops,E.width/2);else if("text"===E.kind){const A=uA(E);kA(B,A.minX,A.minY),kA(B,A.maxX,A.maxY)}else zA(B,E.x,E.y,E.width,E.height,E.angle||0);return B}function OA(A,B,E){return!!ZA(A)&&(TA(A)<=TA(B)+E&&fA(A)<=fA(B)+E)}function qA(A){return`${A.getFullYear()}-${String(A.getMonth()+1).padStart(2,"0")}-${String(A.getDate()).padStart(2,"0")}`}const $A=72/25.4,_A=5.25,AB=[.08,.08,.08],BB=[127/255,127/255,127/255],EB=[.72,.72,.72],sB=(A,B)=>A.minXB.minX&&A.minYB.minY;function wB(A,B,E,s,w=0,Q="left"){return uA({x:A,y:B,text:E,size:s,angle:w,align:Q})}function QB(A,B,E,s,w){const Q=Math.min(...[[A.minX,A.minY],[A.maxX,A.minY],[A.maxX,A.maxY],[A.minX,A.maxY]].map(([A,w])=>(A-B)*s[0]+(w-E)*s[1]));return Math.max(0,w-Q)}const CB=(A,B)=>`${A.axis}:${B[0]<-.5||B[1]<-.5?-1:1}`,gB=(A,B)=>{A.minX=Math.min(A.minX,B[0]),A.minY=Math.min(A.minY,B[1]),A.maxX=Math.max(A.maxX,B[0]),A.maxY=Math.max(A.maxY,B[1])},IB=A=>{const B={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};for(const E of A)for(const A of E)gB(B,A);return B};function YB(A,B,E,s,w=0){const Q=w*Math.PI/180,C=Math.cos(Q),g=Math.sin(Q),I=A+E/2,Y=B+s/2;return Array.from({length:48},(A,B)=>{const w=B/48*Math.PI*2,Q=Math.cos(w)*E/2,R=Math.sin(w)*s/2;return[I+C*Q-g*R,Y+g*Q+C*R]})}function RB(A,B,E,s,w=0){const Q=w*Math.PI/180,C=Math.cos(Q),g=Math.sin(Q),I=A+E/2,Y=B+s/2;return[[-E/2,-s/2],[E/2,-s/2],[E/2,s/2],[-E/2,s/2]].map(([A,B])=>[I+C*A-g*B,Y+g*A+C*B])}function MB(A,B,E){if("passage"===A.type)return[];const s=A.rlen/2,w=B>0?B/E*Y/2:2,Q=[];if("window"===A.type)Q.push([[-s,-w],[s,-w]],[[-s,w],[s,w]],[[-s,-w],[-s,w]],[[s,-w],[s,w]]);else if("gate"===A.type){const B=10*(A.flip_v?-1:1)*Math.PI/180,E=[[[-s,0],[-s+Math.cos(B)*s,Math.sin(B)*s]],[[s,0],[s-Math.cos(B)*s,Math.sin(-B)*s]]];Q.push(...E);for(const A of E){const B=A[1][0]-A[0][0],E=A[1][1]-A[0][1],s=Math.hypot(B,E)||1,C=-E/s,g=B/s,I=Math.min(.08*s,Math.max(1,.7*w));for(const s of[.3,.5,.7]){const w=A[0][0]+B*s,Y=A[0][1]+E*s;Q.push([[w-C*I,Y-g*I],[w+C*I,Y+g*I]])}}}else{const B=A.flip_v?1:-1,E=A.flip_h?s:-s,w=[E,B*A.rlen];Q.push([[E,0],w]);const C=[];for(let s=0;s<=16;s++){const w=B*s/16*Math.PI/2,Q=A.flip_h?-1:1;C.push([E+Q*Math.cos(w)*A.rlen,Math.sin(w)*A.rlen])}Q.push(C)}const C=A.angle*Math.PI/180,g=Math.cos(C),I=Math.sin(C);return Q.map(B=>B.map(([B,E])=>[A.rx+B*g-E*I,A.ry+B*I+E*g]))}function FB(A,B){const E=IB([A]);return B.filter(A=>{const B=IB([A]);return B.maxX>=E.minX&&B.minX<=E.maxX&&B.maxY>=E.minY&&B.minY<=E.maxY})}function iB(A){const B=function(A){const{rawSpace:B,space:E}=A,s=Number(B.cell_cm)>0?Number(B.cell_cm):5,w=Array.isArray(B.walls)?B.walls:[],Q=c(B,E,I,.02*Y),C=W(B,E,s,Y,I),g=m(C),M=n(E,s,Y,2e-4*Y,g).all,F=e(C,E,w,Q.contour,R,s,Y,I);return{cellCm:s,walls:w,zero:Q,openings:C,extras:M,geometry:A.sharedWallGeometry||h(E.rooms,w,Q.contour,F,R,s,Y,I,M)}}(A),E=new Map;if(A.options.dimensions)for(const s of A.space.rooms){const w=C(s);if(!w)continue;const Q=s.id?A.resolveInnerContour?.(s.id):void 0;E.set(s,s.id&&(void 0===Q?g(A.space.rooms,s.id,B.walls,B.zero.contour,R,B.cellCm,Y,I,B.geometry.roomGeom,B.geometry.multiWallNodes):Q)||w)}const s=new Map;if(A.options.dimensions)for(const w of A.space.rooms){const Q=C(w);if(!Q)continue;const g=E.get(w)||Q,I=w.id?A.resolveRoomArea?.(w.id,g):void 0,Y=Number.isFinite(I)?[]:FB(g,B.extras),R=Y.length?M(g,Y):null,i=Number.isFinite(I)&&I>=0?I:R?F(R):Math.abs(g.reduce((A,B,E)=>{const s=g[(E+1)%g.length];return A+B[0]*s[1]-s[0]*B[1]},0)/2);s.set(w,i)}const w=[..."failed-core"===B.geometry.status?A.space.rooms.map(A=>C(A)||[]).filter(A=>A.length):B.geometry.components.flatMap(A=>i(A.geom)),...B.zero.lines.map(A=>[[A[0],A[1]],[A[2],A[3]]])];A.options.decor&&w.push(...function(A){const B=[];for(const E of A.decor||[])"line"===E.kind?B.push([[E.x1*I,E.y1*I],[E.x2*I,E.y2*I]]):"text"!==E.kind?B.push(L(E).map(([A,B])=>[A*I,B*I])):B.push([[E.x*I,E.y*I]]);return B}(A.rawSpace));for(const B of A.rasters||[])w.push(RB(B.x,B.y,B.drawWidth,B.drawHeight,B.angle));let Q=IB(w);var x;[(x=Q).minX,x.minY,x.maxX,x.maxY].every(Number.isFinite)&&x.maxX>x.minX&&x.maxY>x.minY||(Q={minX:0,minY:0,maxX:I,maxY:I});return{built:B,dimensionContours:E,roomAreas:s,bounds:Q,cmPerUnit:B.cellCm/Y}}function xB(A,B,E,s){const{built:w,dimensionContours:Q,roomAreas:g,bounds:M,cmPerUnit:F}=B,c=(s?297:210)*$A,W=(s?210:297)*$A,m=12*$A,n=18*$A,e=24*$A,h=F*(10*$A)/E,j=(M.maxX-M.minX)*h,H=(M.maxY-M.minY)*h,v=m+n,V=W-v-m-e,U=c-2*m,a=A=>[0+(A[0]-M.minX)*h,0+(A[1]-M.minY)*h],P=(A,B)=>[M.minX+(A-0)/h,M.minY+(B-0)/h],y=A=>{const B=P(A.minX,A.minY),E=P(A.maxX,A.maxY);return{minX:B[0],minY:B[1],maxX:E[0],maxY:E[1]}},u=w.geometry.components.flatMap(A=>i(A.geom)),N=A=>w.geometry.components.some(B=>S([...A],B.geom)),K=A=>function(A,B,E){if(!LA(A)||!mA(B))return!0;const s=DA(A);return!!s.some(E)||!!B.some(B=>B.some(B=>xA(B)&&bA(B,A)))||nA(B,(A,B)=>s.some((E,w)=>null!==WA(A,B,E,s[(w+1)%s.length])))}(y(function(A,B){const E=Number.isFinite(B)&&B>=0?B:0;return{minX:A.minX-E,minY:A.minY-E,maxX:A.maxX+E,maxY:A.maxY+E}}(A,$A-1e-6)),u,N),d=(A,B)=>function(A,B,E){if(!LA(A)||!mA([B]))return!1;const s=DA(A);return!!s.every(E)&&!nA([B],(A,B)=>s.some((E,w)=>null!==WA(A,B,E,s[(w+1)%s.length])))}(y(A),B,A=>Z([...A],B)),J=(A,B,E={})=>function(A,B,E,s,w={}){if(!xA(A)||!xA(B)||!mA(E))return!0;if(w.allowStartExit){const w=tA(A,B);if(w<=iA)return!0;const Q=nA(E,(B,E)=>cA(A,B,E));if(!Q)return!0;const C=[];nA(E,(E,s)=>{const w=WA(A,B,E,s);return w&&C.push(w),!1});const g=iA/w,I=[0,1,...C.flatMap(A=>[A.t,A.endT])].sort((A,B)=>A-B).filter((A,B,E)=>0===B||A-E[B-1]>g),Y=E=>[A[0]+(B[0]-A[0])*E,A[1]+(B[1]-A[1])*E],R=A=>C.some(B=>B.overlap&&A>B.t+g&&AA.t>M+g||A.endT>M+g)}const Q=[(A[0]+B[0])/2,(A[1]+B[1])/2],C=nA(E,(B,E)=>cA(A,B,E));return!((!s(A)||w.allowStartBoundary&&C)&&!s(Q)&&!s(B))||nA(E,(E,s)=>{const Q=WA(A,B,E,s);return!!Q&&(Q.overlap||!w.allowStartBoundary||!C||Q.t*tA(A,B)>iA)})}(P(A[0],A[1]),P(B[0],B[1]),u,N,E),T=(A,B,E)=>{const s=A.x*I,w=A.y*I,Q=A.w*I,C=A.h*I,g=s+Q/2,Y=w+C/2,R=s+(A.flip_h?Q:0),F=w+(A.flip_v?C:0),i=(A.flip_h?-1:1)*Q/B,x=(A.flip_v?-1:1)*C/E,b=(Number(A.angle)||0)*Math.PI/180,L=Math.cos(b),D=Math.sin(b),G=Y+D*(R-g)+L*(F-Y);return{a:h*L*i,b:h*D*i,c:-h*D*x,d:h*L*x,e:0+(g+L*(R-g)-D*(F-Y)-M.minX)*h,f:0+(G-M.minY)*h}};let f=[];const z=[],O=function(A,B){const E=3*$A*Math.SQRT2,s=[];for(let w=-B;w<=A+E;w+=E)s.push([[w,0],[w+B,B]]);return s}(c,W);for(const B of A.rasters||[])f.push({kind:"image",imageId:B.id,...a([B.x,B.y]).reduce((A,B,E)=>({...A,[E?"y":"x"]:B}),{}),width:B.drawWidth*h,height:B.drawHeight*h,angle:B.angle,opacity:B.opacity});for(const A of w.geometry.components)f.push({kind:"path",rings:i(A.geom).map(A=>A.map(a)),fill:BB,stroke:AB,width:.25*$A,hatch:{lines:O,stroke:AB,width:.18*$A}});if("failed-core"===w.geometry.status)for(const B of A.space.rooms){const A=C(B);A&&f.push({kind:"path",rings:[A.map(a)],stroke:AB,width:.25*$A})}for(const A of w.zero.lines)f.push({kind:"line",points:[a([A[0],A[1]]),a([A[2],A[3]])],stroke:AB,width:.35*$A,dash:[3*$A,2*$A]});const q=w.geometry.openingIndex;for(const B of w.openings){const E=B.partitionHost?{cm:B.partitionHost.partition.cm}:q?x(A.space.rooms,B,w.walls,R,w.cellCm,Y,I,w.zero.contour):{cm:0};for(const A of MB(B,E.cm,w.cellCm))f.push({kind:"line",points:A.map(a),stroke:AB,width:.3*$A})}if(A.options.decor)for(const B of A.rawSpace.decor||[])if("image"!==B.kind)if("line"===B.kind)f.push({kind:"line",points:[a([B.x1*I,B.y1*I]),a([B.x2*I,B.y2*I])],stroke:AB,width:Math.max(.2*$A,10*Number(B.width_cm||1)*$A/E),dash:"dashed"===B.line_style?[3*$A,2*$A]:void 0});else if("text"===B.kind)f.push({kind:"text",...(()=>{const[A,E]=a([B.x*I,B.y*I]);return{x:A,y:E}})(),text:B.text,size:Math.max(6,10*Number(B.size_cm||20)*$A/E),angle:Number(B.angle)||0});else if("furniture"===B.kind){const A=r[B.symbol];A?f.push({kind:"vector",ops:YA(A.d,T(B,A.viewW,A.viewH)),stroke:AB,width:Math.max(.2*$A,10*b(B,w.cellCm,Y)*$A/E)}):f.push({kind:"path",rings:[L(B).map(([A,B])=>a([A*I,B*I]))],stroke:AB,width:.25*$A})}else{const A="ellipse"===B.kind?YB(B.x*I,B.y*I,B.w*I,B.h*I,Number(B.angle)||0):L(B).map(([A,B])=>[A*I,B*I]);f.push({kind:"path",rings:[A.map(a)],stroke:AB,width:.25*$A})}if(A.options.dimensions&&w.geometry.roomGeom)for(const[B,E]of D(w.geometry.roomGeom).entries()){const s=l(F),w=(A,B,E)=>{const s=a(A.sourceA),w=a(A.sourceB),Q=a(A.a),C=a(A.b),g=(6+E)*$A,I=[Q[0]+B[0]*g,Q[1]+B[1]*g],Y=[C[0]+B[0]*g,C[1]+B[1]*g],R=[(I[0]+Y[0])/2,(I[1]+Y[1])/2],M=PA(A.text,7)+2*$A>Math.hypot(Y[0]-I[0],Y[1]-I[1]),F=QB(wB(R[0],R[1],A.text,7,A.angle,"center"),R[0],R[1],B,$A),i=[R[0]+B[0]*F,R[1]+B[1]*F];return{edge:A,a:s,b:w,oa:I,ob:Y,middle:R,label:i,box:wB(i[0],i[1],A.text,7,A.angle,"center"),needsShelf:M}},Q=A=>{const B=[{start:A.oa,end:A.ob},{start:A.a,end:A.oa,allowStartExit:!0},{start:A.b,end:A.ob,allowStartExit:!0}];return A.needsShelf&&B.push({start:A.middle,end:A.label,mayEnterOwnLabel:!0}),B},C=A=>K(A.box)||Q(A).some(A=>J(A.start,A.end,{allowStartBoundary:A.allowStartBoundary,allowStartExit:A.allowStartExit})),g=EA(k(E,F,A.imperial,{ringIndex:B,epsilon:s}),{ring:E,epsilon:s,score:A=>{const B=[-A.inwardNormal[0],-A.inwardNormal[1]],E=a(A.mid),s=Array.from({length:21},(A,B)=>4*B).find(E=>!C(w(A,B,E))),Q=E[0]+(U-j)/2,g=E[1]+(V-H)/2;return{hardCollisions:void 0===s?21:s/4,normalClearance:Math.abs(B[0])>.5?B[0]>0?U-Q:Q:B[1]>0?V-g:g}}});for(const A of X(g,s)){const B=A.map(A=>({edge:A,outward:[-A.inwardNormal[0],-A.inwardNormal[1]]})),E=A=>B.map(({edge:B,outward:E})=>w(B,E,A));let s=null;for(let A=0;A<=80&&!s;A+=4){const B=E(A),w=B.some((A,E)=>B.slice(0,E).some(B=>sB(A.box,B.box))),g=B.some(A=>C(A)||z.some(B=>sB(A.box,B))),I=B.some((A,E)=>Q(A).some(A=>z.some(B=>eA(A.start,A.end,B))||B.some((B,s)=>(!A.mayEnterOwnLabel||s!==E)&&eA(A.start,A.end,B.box))));w||g||I||(s=B)}if(s)for(const A of s)f.push({kind:"line",points:[A.oa,A.ob],stroke:AB,width:.2*$A},{kind:"line",points:[A.a,A.oa],stroke:AB,width:.15*$A},{kind:"line",points:[A.b,A.ob],stroke:AB,width:.15*$A}),A.needsShelf&&f.push({kind:"line",points:[A.middle,A.label],stroke:AB,width:.15*$A}),f.push({kind:"text",x:A.label[0],y:A.label[1],text:A.edge.text,size:_A,angle:A.edge.angle,align:"center"}),z.push(A.box)}}const $=[...A.space.rooms].sort((A,B)=>String(A.id||"").localeCompare(String(B.id||"")));for(const[B,E]of $.entries()){const s=C(E);if(!s)continue;const w=Q.get(E)||s,I=g.get(E)||0,Y=G(E,A.space.id,A.layout,A.config),[R,M]=a([Y.x,Y.y]),i=w.map(a),x=IB([i]);let b=!1;if(A.options.roomNames&&E.name){const A=Math.max(0,x.maxX-x.minX-4*$A),B=PA(E.name,6.75)<=A?6.75:PA(E.name,5.25)<=A?5.25:0;B&&(f.push({kind:"text",x:R,y:M-2,text:E.name,size:B,align:"center"}),z.push(wB(R,M-2,E.name,B,0,"center")),b=!0)}if(A.options.dimensions){const B=o(I*F*F/1e4,A.imperial),E=M+(b?8:0);f.push({kind:"text",x:R,y:E,text:B,size:6,align:"center"}),z.push(wB(R,E,B,8,0,"center"))}if(A.options.dimensions){const E=l(F),s=EA(p(w,F,A.imperial,{ringIndex:B,epsilon:E}),{ring:w,epsilon:E,score:A=>{const B=a(A.mid),E=QB(wB(B[0],B[1],A.text,_A,A.angle,"center"),B[0],B[1],A.inwardNormal,$A),s=wB(B[0]+A.inwardNormal[0]*E,B[1]+A.inwardNormal[1]*E,A.text,7,A.angle,"center"),w="horizontal"===A.axis?A.inwardNormal[1]>0?x.maxY-B[1]:B[1]-x.minY:A.inwardNormal[0]>0?x.maxX-B[0]:B[0]-x.minX;return{hardCollisions:Number(K(s))+z.reduce((A,B)=>A+Number(sB(s,B)),0),normalClearance:w}}});for(const A of s.filter(A=>A.short)){const B=A.inwardNormal,E=a(A.a),s=a(A.b),w=(E[0]+s[0])/2,Q=(E[1]+s[1])/2;f.push({kind:"line",points:[[w-1.5*B[0]*$A,Q-1.5*B[1]*$A],[w+1.5*B[0]*$A,Q+1.5*B[1]*$A]],stroke:AB,width:.2*$A})}const Q=new Map;for(const A of s.filter(A=>!A.short)){const B=CB(A,A.inwardNormal),E=Q.get(B)||[];E.push(A),Q.set(B,E)}for(const A of Q.values()){let B=null;for(let E=0;E<=30&&!B;E+=3){const s=A.map(A=>{const B=a(A.mid),s=QB(wB(B[0],B[1],A.text,_A,A.angle,"center"),B[0],B[1],A.inwardNormal,(1+E)*$A),w=B[0]+A.inwardNormal[0]*s,Q=B[1]+A.inwardNormal[1]*s;return{edge:A,x:w,y:Q,box:wB(w,Q,A.text,_A,A.angle,"center")}}),Q=s.some((A,B)=>s.slice(0,B).some(B=>sB(A.box,B.box))),C=s.some(A=>K(A.box)||z.some(B=>sB(A.box,B))),g=s.every(A=>d(A.box,w));Q||C||!g||(B=s)}if(B)for(const A of B)f.push({kind:"text",x:A.x,y:A.y,text:A.edge.text,size:_A,angle:A.edge.angle,align:"center"}),z.push(A.box)}}}const _={minX:m,minY:v,maxX:c-m,maxY:v+V},AA=XA(f),BA=OA(AA,{minX:0,minY:0,maxX:U,maxY:V},.5*$A),sA=function(A,B){const E=XA(A);if(!ZA(E))return{commands:[...A],bounds:E,dx:0,dy:0};const s=(B.minX+B.maxX-E.minX-E.maxX)/2,w=(B.minY+B.maxY-E.minY-E.maxY)/2,Q=function(A,B,E){return A.map(A=>"path"===A.kind?{...A,rings:A.rings.map(A=>A.map(([A,s])=>[A+B,s+E]))}:"line"===A.kind?{...A,points:A.points.map(([A,s])=>[A+B,s+E])}:"vector"===A.kind?{...A,ops:A.ops.map(A=>((A,B,E)=>"M"===A.op||"L"===A.op?{...A,x:A.x+B,y:A.y+E}:"C"===A.op?{...A,x1:A.x1+B,y1:A.y1+E,x2:A.x2+B,y2:A.y2+E,x:A.x+B,y:A.y+E}:A)(A,B,E))}:{...A,x:A.x+B,y:A.y+E})}(A,s,w);return{commands:Q,bounds:{minX:E.minX+s,minY:E.minY+w,maxX:E.maxX+s,maxY:E.maxY+w},dx:s,dy:w}}(f,_);f=sA.commands,f.push({kind:"text",x:m,y:m+10,text:A.space.title,size:14}),A.cardTitle&&f.push({kind:"text",x:c-m,y:m+10,text:A.cardTitle,size:10,align:"right"});const wA=W-m-13*$A;f.push({kind:"line",points:[[m,wA-4*$A],[c-m,wA-4*$A]],stroke:EB,width:.2*$A}),f.push({kind:"text",x:m,y:wA,text:A.t("pdf.scale",{n:E}),size:8});const QA=10*(A.imperial?152.4:100)*$A/E,CA=wA+8;f.push({kind:"line",points:[[m,CA],[m+QA,CA]],stroke:AB,width:.4*$A});for(let A=0;A<=4;A++){const B=m+QA*A/4;f.push({kind:"line",points:[[B,CA-2],[B,CA+2]],stroke:AB,width:.25*$A})}f.push({kind:"text",x:m+QA/2,y:wA+17,text:A.imperial?"5 ft":"1 m",size:7,align:"center"});const gA=t(A.config.settings,A.rawSpace.settings||{});if(null!==gA){const B=c/2,E=wA+5.5*$A;f.push({kind:"vector",ops:FA({centerX:B,centerY:E,size:11*$A,northDeg:gA}),fill:AB,width:0,fillRule:"evenodd"}),f.push({kind:"text",x:B,y:wA,text:A.t("pdf.north"),size:7,align:"center"})}f.push({kind:"text",x:c-m,y:wA+12,text:`${qA(A.now)} · House Plan v${A.version}`,size:7,align:"right"});const IA={width:c,height:W,commands:f,images:(A.rasters||[]).map(({id:A,bytes:B,width:E,height:s})=>({id:A,bytes:B,width:E,height:s})),now:A.now,scale:E,sceneBounds:sA.bounds,planField:_},RA=Math.max(0,TA(AA))*Math.max(0,fA(AA)),MA=U*V;return{page:IA,sceneBounds:sA.bounds,field:_,fits:BA,fillRatio:MA>0?RA/MA:0,landscape:s}}function bB(A,B){return A.fillRatio!==B.fillRatio?A.fillRatio>B.fillRatio?A:B:A.landscape?B:A}function LB(A,B,E){const s=12*$A,w=(E?297:210)*$A-2*s,Q=(E?210:297)*$A-2*s-18*$A-24*$A,C=A.cmPerUnit*(10*$A)/B;return(A.bounds.maxX-A.bounds.minX)*C<=w+.5*$A&&(A.bounds.maxY-A.bounds.minY)*C<=Q+.5*$A}function DB(A){let B=0;for(const E of A)if(B+=Math.max(0,Number(E)||0),B>26214400)throw new Error("pdf.too_large")}const GB="d31b0b1e184ab2863684b758f839bdb6809a33cc742c6e9bb36c5ea034e3d309";async function oB(A,B){if(!A)throw new Error("pdf.asset_failed");const E=await fetch(A,{credentials:"same-origin"});if(!E.ok)throw new Error("pdf.asset_failed");const s=await E.blob();let w;try{w=await createImageBitmap(s)}catch{throw new Error("pdf.asset_failed")}try{if("image/jpeg"===s.type)return{id:B,bytes:new Uint8Array(await s.arrayBuffer()),width:w.width,height:w.height};const A=document.createElement("canvas");A.width=w.width,A.height=w.height;const E=A.getContext("2d");if(!E)throw new Error("pdf.asset_failed");E.fillStyle="#fff",E.fillRect(0,0,A.width,A.height),E.drawImage(w,0,0);const Q=await new Promise(B=>A.toBlob(B,"image/jpeg",.85));if(!Q)throw new Error("pdf.asset_failed");return{id:B,bytes:new Uint8Array(await Q.arrayBuffer()),width:w.width,height:w.height}}finally{w.close()}}async function tB(A,B,E){const s=await async function(A,B){const E=[];if(B.backdrop&&A.space.bg){const B=await oB(A.backdropUrl,"backdrop");E.push({...B,x:A.space.bg.x,y:A.space.bg.y,drawWidth:A.space.bg.w,drawHeight:A.space.bg.h,angle:A.space.bg.angle,opacity:.6})}if(B.decor){let B=0;for(const s of A.rawSpace.decor||[]){if("image"!==s.kind)continue;const w=A.decorAssets.get(s.asset_id),Q=j(s,I,I);if(!w||!Q)throw new Error("pdf.asset_failed");const C=await oB(w.url,"decor"+B++);E.push({...C,x:Q[0],y:Q[1],drawWidth:Q[2],drawHeight:Q[3],opacity:Q[4],angle:Number(s.angle)||0})}}return DB(E.map(A=>A.bytes.byteLength)),E}(A,B),w=JA(function(A){const B=iB(A);let E=[];for(const s of wA){const w=[!1,!0].filter(A=>LB(B,s,A)).map(E=>xB(A,B,s,E));if(!w.length)continue;const Q=w.filter(A=>A.fits);if(Q.length)return Q.reduce(bB).page;E=w}E.length||(E=[!1,!0].map(E=>xB(A,B,500,E)));const s=E.filter(A=>A.fits);if(s.length)return s.reduce(bB).page;const w=Math.min(...E.map(A=>Math.max(TA(A.sceneBounds)/TA(A.field),fA(A.sceneBounds)/fA(A.field)))),Q=50,C=1e6,g=Number.isFinite(w)?Math.ceil(Math.min(C,500*Math.max(1,w))/Q)*Q:C;let I=500,Y=0,R=[],M=Math.max(550,g);for(;M<=C;){const E=[!1,!0].map(E=>xB(A,B,M,E)).filter(A=>A.fits);if(E.length){Y=M,R=E;break}if(I=M,M===C)break;M=Math.min(C,Math.ceil(2*M/Q)*Q)}if(!Y)throw new Error("pdf.failed");let F=Math.floor(I/Q),i=Math.floor(Y/Q);for(;i-F>1;){const E=Math.floor((F+i)/2),s=[!1,!0].map(s=>xB(A,B,E*Q,s)).filter(A=>A.fits);s.length?(i=E,R=s):F=E}const x=R.reduce(bB).page;if(!OA(x.sceneBounds,x.planField,.5*$A))throw new Error("pdf.failed");return x}({...A,options:B,now:E,rasters:s,t:A.t})),Q=new Blob([w],{type:"application/pdf"}),C=URL.createObjectURL(Q);try{const B=document.createElement("a");B.href=C,B.download=`houseplan-${g=A.space.title,g.normalize("NFKD").replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-|-$/g,"").toLowerCase()||"space"}-${qA(E)}.pdf`,B.style.display="none",document.body.append(B),B.click(),B.remove()}finally{setTimeout(()=>URL.revokeObjectURL(C),0)}var g;return w}class cB{assertRasterBudget(A){DB(A)}render(A){let B;return B={...A,save:async E=>{await tB(A,E,B.now||new Date)}},s``}}export{GB as PDF_EXPORT_FINGERPRINT,cB as PdfExportRuntime,tB as exportSpacePdf}; diff --git a/dist/houseplan-assets/summary-panel-editor-ClwrL_O4.js b/custom_components/houseplan/frontend/houseplan-assets/summary-panel-editor-Dq397KvS.js similarity index 97% rename from dist/houseplan-assets/summary-panel-editor-ClwrL_O4.js rename to custom_components/houseplan/frontend/houseplan-assets/summary-panel-editor-Dq397KvS.js index b5f1758f..a70cc41d 100644 --- a/dist/houseplan-assets/summary-panel-editor-ClwrL_O4.js +++ b/custom_components/houseplan/frontend/houseplan-assets/summary-panel-editor-Dq397KvS.js @@ -1,4 +1,4 @@ -globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db7c58754eeb4ba03f835b8d7c84c6";import{c as a,A as e}from"./houseplan-card-BiUNLHFh.js";import{s,n as t,a as l,m as r,b as o,c as i,d as u}from"./summary-panel-runtime-loaded-B9-PG-Gw.js";import"./form-kit.styles-BQTkV2m1.js";const m=m=>{const{host:c,dialog:d,problems:n,t:b}=m,y=n.find(a=>"error"===a.kind),$=d.localShow!==d.baseLocalShow||!d.localOnly&&!s(t(d.draft),d.base),p=$&&!d.busy&&!y,v=a=>n.find(e=>e.path===a),h=a=>a?b(`summary.problem.${a.code}`):"",k=()=>m.close(),g=a`
    `}renderDialog(){return this.dialog&&this.editorRenderer?(this.dialog.localOnly||this.refreshEntityIndex(),this.editorRenderer({host:this.host,dialog:this.dialog,local:this.local,storageUnavailable:this.storageUnavailable,problems:this.problems(this.dialog),entityIndex:this.entityIndex||F({},null),setDialog:e=>{this.dialog=e,this.host.requestUpdate()},saveLocal:e=>this.saveLocal(e),mutate:e=>this.mutate(e),deleteBlock:e=>{this.deleteBlock(e)},dragStart:(e,t)=>this.dragStart(e,t),drop:(e,t)=>this.drop(e,t),sourceToken:e=>this.sourceToken(e),openSource:(e,t)=>this.openSource(e,t),closeSource:e=>this.closeSource(e),setSource:(e,t,s)=>this.setSource(e,t,s),save:()=>{this.saveDialog()},reload:()=>{this.reloadDialog()},close:()=>this.closeDialogIfIdle(),t:e=>this.t(e)})):t}t(e){return e.startsWith("summary.")?function(e,t){const s=e.toLowerCase().split("-")[0];return(q[s]||q.en)[t]||q.en[t]||t}(r(this.host.hass,this.host._config?.language),e):this.host._t(e)}ensureStyle(){const e=this.host.renderRoot;if(this.styleSheet&&e.adoptedStyleSheets.includes(this.styleSheet))return;const t=this.host.ownerDocument.defaultView?.CSSStyleSheet;if(t&&"adoptedStyleSheets"in e){const s=new t;return s.replaceSync(R),this.styleSheet=s,void(e.adoptedStyleSheets=[...e.adoptedStyleSheets,s])}if(e.querySelector("style[data-hp-summary]"))return;const s=this.host.ownerDocument.createElement("style");s.dataset.hpSummary="true",s.textContent=R,e.insertBefore(s,e.firstChild)}ensureDialogStyle(){const e=this.host.renderRoot.querySelector('hp-dialog[data-kind="summary"]')?.shadowRoot;if(!e||this.styledDialogRoots.has(e))return;const t=this.host.ownerDocument.defaultView?.CSSStyleSheet;if(t&&"adoptedStyleSheets"in e)this.dialogStyleSheet||(this.dialogStyleSheet=new t,this.dialogStyleSheet.replaceSync(I)),e.adoptedStyleSheets=[...e.adoptedStyleSheets,this.dialogStyleSheet];else{const t=this.host.ownerDocument.createElement("style");t.dataset.hpSummaryShell="true",t.textContent=I,e.appendChild(t)}this.styledDialogRoots.add(e)}placementSlot(){return K(this.host)}preferenceKey(){return function(e){const t=y(e.userId),s=y(e.slot);return t&&s?`houseplan.summary-panel.v1:${[t,y(e.path)||"/",y(e.host)||"card",s].map(e=>encodeURIComponent(e)).join(":")}`:null}({userId:this.host.hass?.user?.id||this.host.hass?.user?.name,path:location.pathname,host:this.host.panelHost?"panel":"lovelace",slot:this.placementSlot()})}identity(){return JSON.stringify({key:this.preferenceKey(),user:this.host.hass?.user?.id||this.host.hass?.user?.name||"",route:location.pathname,host:this.host.panelHost?"panel":"lovelace",slot:this.placementSlot(),kiosk:this.host._kiosk,canManage:this.host._canManageConfiguration})}syncLifecycle(){const e=this.identity();this.lifecycleIdentity&&e!==this.lifecycleIdentity&&this.resetLifecycle(),this.lifecycleIdentity=e}resetLifecycle(){this.presentation.reset(),this.lifecycleGeneration++,this.dialog=null,this.entityIndex=null,this.deviceMemo=null,this.areaMemo=null,this.clockContext="",this.storageKey=null,this.storageUnavailable=!1,this.local={version:1,show:!1,icon_scale:1,font_scale:1},this.clockTimer&&clearTimeout(this.clockTimer),this.clockTimer=0,this.lifecycleIdentity=this.connected?this.identity():"",this.host.requestUpdate()}current(e){return this.connected&&e===this.lifecycleGeneration&&this.lifecycleIdentity===this.identity()}refreshEntityIndex(){this.entityIndex=F(this.host.hass?.states,this.entityIndex)}syncNativeNarrow(){if(this.host.panelHost)return;let e=this.host;for(let t=0;e&&t<12;t++){const t=e.getRootNode();if(e=e.parentNode||(t instanceof ShadowRoot?t.host:null),!e||e===this.host)continue;const s=e.narrow;if("boolean"==typeof s)return void(this.host.narrow!==s&&(this.host.narrow=s))}}loadLocal(){const e=this.preferenceKey();if(!e||e===this.storageKey)return;let t=null,s=null,r=!0;try{t=JSON.parse(localStorage.getItem(e)||"null")}catch{r=!1}try{s=JSON.parse(localStorage.getItem("houseplan_card_kiosk_v1")||"null")}catch{r=!1}this.storageKey=e,this.storageUnavailable=!r,this.local=function(e,t){const s=e&&"object"==typeof e?e:{},r=t&&"object"==typeof t?t:{};return{version:1,show:!0===s.show,icon_scale:M(p(s,"icon_scale")?s.icon_scale:r.icon),font_scale:M(p(s,"font_scale")?s.font_scale:r.font)}}(t,s),this.host._kioskScale={icon:this.local.icon_scale,font:this.local.font_scale}}saveLocal(e){this.local={...this.local,...e,version:1,icon_scale:M(e.icon_scale??this.local.icon_scale),font_scale:M(e.font_scale??this.local.font_scale)},this.host._kioskScale={icon:this.local.icon_scale,font:this.local.font_scale},this.storageKey||=this.preferenceKey();let t=!1;try{this.storageKey&&(localStorage.setItem(this.storageKey,JSON.stringify(this.local)),t=!0)}catch{}this.storageUnavailable=!t,t||this.host._showToast?.(this.t("summary.storage_unavailable")),this.host.requestUpdate()}config(){return function(e,t){const s=e?.summary_panel;return void 0===s?{config:b(t),derived:!0,unsupported:!1}:v(s)?{config:s,derived:!1,unsupported:!1}:{config:null,derived:!1,unsupported:!0}}(this.host._settings,this.translate)}async openDialog(){const e=this.lifecycleGeneration;this.loadLocal();try{this.editorLoad||=import("./summary-panel-editor-ClwrL_O4.js").then(e=>e.renderSummaryPanelEditor),this.editorRenderer=await this.editorLoad}catch(t){if(this.editorLoad=null,!this.current(e))return;return void this.host._showToast?.(`${this.t("summary.load_failed")} ${this.host._errText(t)}`)}if(!this.current(e))return;const t=this.config(),s=t.config||b(this.translate),r=this.host._haSummaryPanelApi!==i,a=t.unsupported?"summary.unsupported_schema":r&&this.host._canManageConfiguration?"summary.backend_required":"summary.local_only";this.dialog={draft:_(s),base:_(s),baseRevision:this.host._cfgRev,localShow:this.local.show,baseLocalShow:this.local.show,localOnly:this.host._kiosk||!this.host._canManageConfiguration||r||t.unsupported,localOnlyHint:a,busy:!1,attempted:!1,entityFilter:"",activeSource:null,error:"",conflict:!1},this.dialog.localOnly||this.refreshEntityIndex(),this.host.requestUpdate()}problems(e=this.dialog){return!e||e.localOnly?[]:k(x(e.draft),e.base,new Set(this.host._model.map(e=>e.id)),new Set(Object.keys(this.host.hass?.states||{})))}mutate(e){if(!this.dialog||this.dialog.busy||this.dialog.localOnly)return;const t=_(this.dialog.draft);e(t);const s=this.dialog.activeSource,r=!s||t.blocks.some(e=>e.id===s.blockId&&e.values.some(e=>e.id===s.valueId));this.dialog={...this.dialog,draft:t,error:"",conflict:!1,activeSource:r?s:null,entityFilter:r?this.dialog.entityFilter:""},this.host.requestUpdate()}async deleteBlock(e){const t=this.dialog?.draft.blocks[e];if(!t)return;const s=this.lifecycleGeneration;if(t.values.length){if(!await this.host._confirmDanger({key:"summary-block",kind:"warning",title:this.t("summary.delete_block_title"),message:this.t("summary.delete_block_body"),objectName:t.title,confirmLabel:this.t("btn.delete"),cancelLabel:this.t("btn.cancel")})||!this.current(s))return}this.mutate(e=>{const s=e.blocks.findIndex(e=>e.id===t.id);s>=0&&e.blocks.splice(s,1)})}sourceToken(e){return"system"===e.type?`system:${e.key}`:`entity:${e.entity_id}`}openSource(e,t){!this.dialog||this.dialog.busy||this.dialog.localOnly||(this.refreshEntityIndex(),this.dialog={...this.dialog,activeSource:{blockId:e,valueId:t},entityFilter:""},this.host.requestUpdate(),this.host.updateComplete.then(()=>{this.dialog?.activeSource?.blockId===e&&this.dialog.activeSource.valueId===t&&this.host.renderRoot.querySelector("[data-summary-picker-search]")?.focus()}))}closeSource(e=!1){const t=this.dialog?.activeSource;this.dialog&&t&&(this.dialog={...this.dialog,activeSource:null,entityFilter:""},this.host.requestUpdate(),e&&this.focusSource(t.blockId,t.valueId))}async focusSource(e,t){await this.host.updateComplete;const s=`${e}\n${t}`,r=this.host.renderRoot.querySelectorAll("[data-summary-source-owner]");[...r].find(e=>e.dataset.summarySourceOwner===s)?.focus()}setSource(e,t,s){this.mutate(r=>{const i=r.blocks.find(t=>t.id===e)?.values.find(e=>e.id===t);if(i)if(s.startsWith("system:")){const e=s.slice(7);(e=>"device_count"===e||"total_area"===e||"datetime"===e)(e)&&(i.source={type:"system",key:e})}else i.source={type:"entity",entity_id:s.startsWith("entity:")?s.slice(7):s}}),this.dialog&&(this.dialog={...this.dialog,activeSource:null,entityFilter:""}),this.host.requestUpdate(),this.focusSource(e,t)}dragStart(e,t){e.dataTransfer?.setData("text/x-houseplan-summary",t),e.dataTransfer&&(e.dataTransfer.effectAllowed="move")}drop(e,t){e.preventDefault(),e.stopPropagation();const s=e.dataTransfer?.getData("text/x-houseplan-summary")||"",r=s.split(":").map(Number),i=t.split(":").map(Number);s.startsWith("block:")&&t.startsWith("block:")?this.mutate(e=>{e.blocks=C(e.blocks,r[1],i[1])}):s.startsWith("value:")&&t.startsWith("value:")&&r[1]===i[1]&&this.mutate(e=>{e.blocks[r[1]].values=C(e.blocks[r[1]].values,r[2],i[2])})}async saveDialog(){const e=this.dialog;if(!e||e.busy)return;const t=this.lifecycleGeneration,s=x(e.draft);if((e.localOnly?[]:k(s,e.base,new Set(this.host._model.map(e=>e.id)),new Set(Object.keys(this.host.hass?.states||{})))).some(e=>"error"===e.kind))return this.dialog={...e,draft:s,attempted:!0},this.host.requestUpdate(),await this.host.updateComplete,void this.host.renderRoot.querySelector('[data-summary-error="true"]')?.focus?.();this.dialog={...e,draft:s,busy:!0,attempted:!1,error:"",conflict:!1},this.host.requestUpdate();try{if(!e.localOnly&&!$(s,e.base)){this.host._writesPending++;const r=a(this.host._writeChain,async()=>{if(!this.current(t))return;if(!this.host._serverCfg)throw new Error(this.t("summary.save_failed"));if(this.host._cfgRev!==e.baseRevision)throw new Error(this.t("summary.conflict"));const r=o({...this.host._serverCfg,settings:{...this.host._serverCfg.settings||{},summary_panel:s}});let i=!1;try{if(await this.host._sendConfigCandidate(r),!this.current(t))return}catch(e){if(!this.current(t))throw e;try{const r=await this.host._getAuthoritativeConfig();if(!this.current(t))throw e;const a=function(e,t){if(!g(e))return null;const s=e.config,r=e.rev;if(!g(s)||!Array.isArray(s.spaces)||"number"!=typeof r||!Number.isSafeInteger(r)||r<0)return null;const i=g(s.settings)?s.settings:null,a=i?.summary_panel;return v(a)&&$(a,t)?{config:s,rev:r}:null}(r,s);if(!a)throw e;const o=await this.host._adoptAuthoritative({cfgResp:r,reason:"summary-recovery",profile:"reload"});if("adopted"!==o.status)throw e;o.spaceChanged&&this.host._restoreZoom(),this.host._regSignature="",this.host._maybeRebuildDevices(),i=!0}catch{throw e}}if(!i){if(!this.current(t))return;this.host._adoption.stageConfigCandidate(r),this.host._cacheSnapshot()}});this.host._writeChain=r,await r.finally(()=>{this.host._writesPending--})}if(!this.current(t))return;this.saveLocal({show:e.localShow}),this.dialog=null}catch(s){if(!this.current(t))return;const r="conflict"===s?.code||this.host._cfgRev!==e.baseRevision;this.dialog={...this.dialog||e,busy:!1,conflict:r,error:r?this.t("summary.conflict"):this.host._errText(s)}}this.current(t)&&this.host.requestUpdate()}async reloadDialog(){const e=this.dialog;if(!e||e.busy)return;const t=this.lifecycleGeneration;this.dialog={...e,busy:!0,error:"",conflict:!1},this.host.requestUpdate();try{if(await this.host._reloadConfigOnly(!0),!this.current(t))return;if(e.conflict&&this.host._cfgRev===e.baseRevision)throw new Error(this.t("summary.load_failed"));const s=this.config().config||b(this.translate);this.dialog={...e,draft:_(s),base:_(s),baseRevision:this.host._cfgRev,busy:!1,attempted:!1,error:"",conflict:!1}}catch(s){if(!this.current(t))return;this.dialog={...e,busy:!1,error:this.host._errText(s),conflict:!0}}this.current(t)&&this.host.requestUpdate()}metricsFresh(){return!!this.deviceMemo&&!!this.areaMemo&&this.deviceMemo.cfgEpoch===this.host._cfgEpoch&&this.deviceMemo.layoutRev===this.host._layoutRev&&this.deviceMemo.registryRev===this.host._haRegistry.revision&&this.areaMemo.cfgEpoch===this.host._cfgEpoch}scheduleMetrics(){if(this.metricsRefresh||!this.metricsModule||this.metricsFresh())return;const e=this.lifecycleGeneration,t="undefined"==typeof window?void 0:window,s=()=>{if(this.metricsRefresh=0,!this.current(e))return;const t=this.advanceMetrics(8);this.host.requestUpdate(),t||this.scheduleMetrics()};this.metricsRefresh=t?.setTimeout(()=>{"function"==typeof t.requestAnimationFrame?t.requestAnimationFrame(()=>t.setTimeout(s,0)):s()},0)||0}advanceMetrics(e=8){const t=this.metricsModule;if(!t)return!0;if(this.computeDeviceCount(),!this.host._serverCfg)return this.areaMemo={cfgEpoch:this.host._cfgEpoch,value:null},!0;if(this.areaMemo&&this.areaMemo.cfgEpoch===this.host._cfgEpoch)return!0;this.areaSteps&&this.areaStepsEpoch===this.host._cfgEpoch||(this.areaSteps=t.cleanFloorAreaSteps(this.host._serverCfg,this.host._model),this.areaStepsEpoch=this.host._cfgEpoch);const s=Date.now();let r=this.areaSteps.next();for(;!r.done&&Date.now()-s[e,t.space])),spaceIds:new Set(this.host._model.map(e=>e.id)),firstSpaceId:this.host._model[0]?.id||"",markers:this.host._markers});this.deviceMemo={cfgEpoch:this.host._cfgEpoch,layoutRev:this.host._layoutRev,registryRev:this.host._haRegistry.revision,value:t?.size??null}}}computeMetrics(){for(;!this.advanceMetrics(Number.POSITIVE_INFINITY););}metrics(){return{deviceCount:this.deviceMemo?this.deviceMemo.value:null,areaM2:this.areaMemo?this.areaMemo.value:null,now:this.clock}}valueState(e){const t=this.metricsModule;if(!t)return{kind:"pending"};if("entity"===e.source.type){const s=t.summaryEntityValue(this.host.hass,e.source.entity_id);return null===s?{kind:"unavailable"}:{kind:"ready",text:s}}const s="device_count"===e.source.key||"total_area"===e.source.key,i="device_count"===e.source.key?this.deviceMemo:this.areaMemo;if(s&&!i)return this.scheduleMetrics(),{kind:"pending"};s&&this.scheduleMetrics();const a=t.summarySystemValue(e.source,this.metrics(),this.host.hass,r(this.host.hass,this.host._config?.language));return null===a?{kind:"unavailable"}:{kind:"ready",text:a}}value(e){const t=this.valueState(e);return"ready"===t.kind?t.text:this.t("summary.unavailable")}ensureMetrics(){if(this.metricsModule||this.metricsLoad)return;const e=this.lifecycleGeneration;this.metricsLoad=import("./summary-panel-metrics-BjFIAkz0.js"),this.metricsLoad.then(t=>{this.metricsModule=t,this.current(e)&&this.host.requestUpdate()}).catch(()=>{}).finally(()=>{this.metricsLoad=null})}layout(){return function(e){const t=Math.max(0,Number(e.width)||0),s=Math.max(0,Number(e.height)||0),r=t>=s?"right":"bottom",i=Math.max(0,e.safeLeft||0)+12,a=Math.max(0,e.safeRight||0)+12,o=Math.max(Math.max(0,e.safeTop||0)+12,e.controlTop||0),n=Math.max(Math.max(0,e.safeBottom||0)+12,e.controlBottom||0),l=Math.max(0,t-i-a),m=Math.max(0,s-o-n),c="bottom"===r?Math.min(.6*s,m):m;return{side:r,fits:t>0&&s>0&&l>=280&&c>=Math.max(0,e.minimumHeight),availableWidth:l,heightCap:c,top:o,bottom:n}}({width:this.stage.width,height:this.stage.height,...this.safeInsets(),controlTop:this.host._kiosk?this.stage.controlTop:0,minimumHeight:this.stage.minimumHeight})}syncPresentation(e=!1){const t=this.config().config,s=this.layout(),r=!!t&&"view"===this.host._mode&&s.fits&&S({view:!0,localShow:!0,showOnMobile:t.show_on_mobile,narrow:this.host.narrow,fits:!0});this.presentation.sync(r&&this.local.show,s.side,e||!r||"hidden"===this.host.ownerDocument.visibilityState)}measureLayout(){const e=this.host._stageEl;if(!e)return;const t=this.host.renderRoot.querySelector(".summary-measure"),s=this.host.renderRoot.querySelector(".summary-control.kiosk"),r=e.getBoundingClientRect(),i=s?.getBoundingClientRect(),a={width:Math.round(e.clientWidth),height:Math.round(e.clientHeight),minimumHeight:Math.max(162,Math.ceil(t?.getBoundingClientRect().height||0)),controlTop:i?Math.max(0,Math.ceil(i.bottom-r.top+12)):0};a.width===this.stage.width&&a.height===this.stage.height&&a.minimumHeight===this.stage.minimumHeight&&a.controlTop===this.stage.controlTop||(this.stage=a,this.host.requestUpdate())}safeInsets(){const e=this.host.renderRoot.querySelector(".summary-safe-probe");if(!e)return{safeLeft:0,safeRight:0,safeTop:0,safeBottom:0};const t=this.host.ownerDocument.defaultView?.getComputedStyle(e);if(!t)return{safeLeft:0,safeRight:0,safeTop:0,safeBottom:0};const s=e=>Number.parseFloat(e)||0;return{safeLeft:s(t.paddingLeft),safeRight:s(t.paddingRight),safeTop:s(t.paddingTop),safeBottom:s(t.paddingBottom)}}hasVisibleClock(){const e=this.config().config;return!("hidden"===this.host.ownerDocument.visibilityState||!e)&&(!!S({view:"view"===this.host._mode,localShow:this.local.show,showOnMobile:e.show_on_mobile,narrow:this.host.narrow,fits:this.layout().fits})&&w(e,this.host._space).some(e=>e.values.some(e=>"system"===e.source.type&&"datetime"===e.source.key)))}syncClock(){const e=`${r(this.host.hass,this.host._config?.language)}\n${this.host.hass?.config?.time_zone||""}`;e!==this.clockContext&&(this.clockContext=e,this.clock=new Date);const t=this.hasVisibleClock();if(t&&!this.clockTimer){this.clock=new Date;const e=()=>{this.clock=new Date,this.clockTimer=0,this.host.requestUpdate(),this.syncClock()};this.clockTimer=window.setTimeout(e,6e4-Date.now()%6e4+25)}else!t&&this.clockTimer&&(clearTimeout(this.clockTimer),this.clockTimer=0)}}});export{A as a,G as b,z as c,D as d,V as e,C as m,x as n,$ as s}; + `}renderDialog(){return this.dialog&&this.editorRenderer?(this.dialog.localOnly||this.refreshEntityIndex(),this.editorRenderer({host:this.host,dialog:this.dialog,local:this.local,storageUnavailable:this.storageUnavailable,problems:this.problems(this.dialog),entityIndex:this.entityIndex||F({},null),setDialog:e=>{this.dialog=e,this.host.requestUpdate()},saveLocal:e=>this.saveLocal(e),mutate:e=>this.mutate(e),deleteBlock:e=>{this.deleteBlock(e)},dragStart:(e,t)=>this.dragStart(e,t),drop:(e,t)=>this.drop(e,t),sourceToken:e=>this.sourceToken(e),openSource:(e,t)=>this.openSource(e,t),closeSource:e=>this.closeSource(e),setSource:(e,t,s)=>this.setSource(e,t,s),save:()=>{this.saveDialog()},reload:()=>{this.reloadDialog()},close:()=>this.closeDialogIfIdle(),t:e=>this.t(e)})):t}t(e){return e.startsWith("summary.")?function(e,t){const s=e.toLowerCase().split("-")[0];return(q[s]||q.en)[t]||q.en[t]||t}(r(this.host.hass,this.host._config?.language),e):this.host._t(e)}ensureStyle(){const e=this.host.renderRoot;if(this.styleSheet&&e.adoptedStyleSheets.includes(this.styleSheet))return;const t=this.host.ownerDocument.defaultView?.CSSStyleSheet;if(t&&"adoptedStyleSheets"in e){const s=new t;return s.replaceSync(R),this.styleSheet=s,void(e.adoptedStyleSheets=[...e.adoptedStyleSheets,s])}if(e.querySelector("style[data-hp-summary]"))return;const s=this.host.ownerDocument.createElement("style");s.dataset.hpSummary="true",s.textContent=R,e.insertBefore(s,e.firstChild)}ensureDialogStyle(){const e=this.host.renderRoot.querySelector('hp-dialog[data-kind="summary"]')?.shadowRoot;if(!e||this.styledDialogRoots.has(e))return;const t=this.host.ownerDocument.defaultView?.CSSStyleSheet;if(t&&"adoptedStyleSheets"in e)this.dialogStyleSheet||(this.dialogStyleSheet=new t,this.dialogStyleSheet.replaceSync(I)),e.adoptedStyleSheets=[...e.adoptedStyleSheets,this.dialogStyleSheet];else{const t=this.host.ownerDocument.createElement("style");t.dataset.hpSummaryShell="true",t.textContent=I,e.appendChild(t)}this.styledDialogRoots.add(e)}placementSlot(){return K(this.host)}preferenceKey(){return function(e){const t=y(e.userId),s=y(e.slot);return t&&s?`houseplan.summary-panel.v1:${[t,y(e.path)||"/",y(e.host)||"card",s].map(e=>encodeURIComponent(e)).join(":")}`:null}({userId:this.host.hass?.user?.id||this.host.hass?.user?.name,path:location.pathname,host:this.host.panelHost?"panel":"lovelace",slot:this.placementSlot()})}identity(){return JSON.stringify({key:this.preferenceKey(),user:this.host.hass?.user?.id||this.host.hass?.user?.name||"",route:location.pathname,host:this.host.panelHost?"panel":"lovelace",slot:this.placementSlot(),kiosk:this.host._kiosk,canManage:this.host._canManageConfiguration})}syncLifecycle(){const e=this.identity();this.lifecycleIdentity&&e!==this.lifecycleIdentity&&this.resetLifecycle(),this.lifecycleIdentity=e}resetLifecycle(){this.presentation.reset(),this.lifecycleGeneration++,this.dialog=null,this.entityIndex=null,this.deviceMemo=null,this.areaMemo=null,this.clockContext="",this.storageKey=null,this.storageUnavailable=!1,this.local={version:1,show:!1,icon_scale:1,font_scale:1},this.clockTimer&&clearTimeout(this.clockTimer),this.clockTimer=0,this.lifecycleIdentity=this.connected?this.identity():"",this.host.requestUpdate()}current(e){return this.connected&&e===this.lifecycleGeneration&&this.lifecycleIdentity===this.identity()}refreshEntityIndex(){this.entityIndex=F(this.host.hass?.states,this.entityIndex)}syncNativeNarrow(){if(this.host.panelHost)return;let e=this.host;for(let t=0;e&&t<12;t++){const t=e.getRootNode();if(e=e.parentNode||(t instanceof ShadowRoot?t.host:null),!e||e===this.host)continue;const s=e.narrow;if("boolean"==typeof s)return void(this.host.narrow!==s&&(this.host.narrow=s))}}loadLocal(){const e=this.preferenceKey();if(!e||e===this.storageKey)return;let t=null,s=null,r=!0;try{t=JSON.parse(localStorage.getItem(e)||"null")}catch{r=!1}try{s=JSON.parse(localStorage.getItem("houseplan_card_kiosk_v1")||"null")}catch{r=!1}this.storageKey=e,this.storageUnavailable=!r,this.local=function(e,t){const s=e&&"object"==typeof e?e:{},r=t&&"object"==typeof t?t:{};return{version:1,show:!0===s.show,icon_scale:M(p(s,"icon_scale")?s.icon_scale:r.icon),font_scale:M(p(s,"font_scale")?s.font_scale:r.font)}}(t,s),this.host._kioskScale={icon:this.local.icon_scale,font:this.local.font_scale}}saveLocal(e){this.local={...this.local,...e,version:1,icon_scale:M(e.icon_scale??this.local.icon_scale),font_scale:M(e.font_scale??this.local.font_scale)},this.host._kioskScale={icon:this.local.icon_scale,font:this.local.font_scale},this.storageKey||=this.preferenceKey();let t=!1;try{this.storageKey&&(localStorage.setItem(this.storageKey,JSON.stringify(this.local)),t=!0)}catch{}this.storageUnavailable=!t,t||this.host._showToast?.(this.t("summary.storage_unavailable")),this.host.requestUpdate()}config(){return function(e,t){const s=e?.summary_panel;return void 0===s?{config:b(t),derived:!0,unsupported:!1}:v(s)?{config:s,derived:!1,unsupported:!1}:{config:null,derived:!1,unsupported:!0}}(this.host._settings,this.translate)}async openDialog(){const e=this.lifecycleGeneration;this.loadLocal();try{this.editorLoad||=import("./summary-panel-editor-Dq397KvS.js").then(e=>e.renderSummaryPanelEditor),this.editorRenderer=await this.editorLoad}catch(t){if(this.editorLoad=null,!this.current(e))return;return void this.host._showToast?.(`${this.t("summary.load_failed")} ${this.host._errText(t)}`)}if(!this.current(e))return;const t=this.config(),s=t.config||b(this.translate),r=this.host._haSummaryPanelApi!==i,a=t.unsupported?"summary.unsupported_schema":r&&this.host._canManageConfiguration?"summary.backend_required":"summary.local_only";this.dialog={draft:_(s),base:_(s),baseRevision:this.host._cfgRev,localShow:this.local.show,baseLocalShow:this.local.show,localOnly:this.host._kiosk||!this.host._canManageConfiguration||r||t.unsupported,localOnlyHint:a,busy:!1,attempted:!1,entityFilter:"",activeSource:null,error:"",conflict:!1},this.dialog.localOnly||this.refreshEntityIndex(),this.host.requestUpdate()}problems(e=this.dialog){return!e||e.localOnly?[]:k(x(e.draft),e.base,new Set(this.host._model.map(e=>e.id)),new Set(Object.keys(this.host.hass?.states||{})))}mutate(e){if(!this.dialog||this.dialog.busy||this.dialog.localOnly)return;const t=_(this.dialog.draft);e(t);const s=this.dialog.activeSource,r=!s||t.blocks.some(e=>e.id===s.blockId&&e.values.some(e=>e.id===s.valueId));this.dialog={...this.dialog,draft:t,error:"",conflict:!1,activeSource:r?s:null,entityFilter:r?this.dialog.entityFilter:""},this.host.requestUpdate()}async deleteBlock(e){const t=this.dialog?.draft.blocks[e];if(!t)return;const s=this.lifecycleGeneration;if(t.values.length){if(!await this.host._confirmDanger({key:"summary-block",kind:"warning",title:this.t("summary.delete_block_title"),message:this.t("summary.delete_block_body"),objectName:t.title,confirmLabel:this.t("btn.delete"),cancelLabel:this.t("btn.cancel")})||!this.current(s))return}this.mutate(e=>{const s=e.blocks.findIndex(e=>e.id===t.id);s>=0&&e.blocks.splice(s,1)})}sourceToken(e){return"system"===e.type?`system:${e.key}`:`entity:${e.entity_id}`}openSource(e,t){!this.dialog||this.dialog.busy||this.dialog.localOnly||(this.refreshEntityIndex(),this.dialog={...this.dialog,activeSource:{blockId:e,valueId:t},entityFilter:""},this.host.requestUpdate(),this.host.updateComplete.then(()=>{this.dialog?.activeSource?.blockId===e&&this.dialog.activeSource.valueId===t&&this.host.renderRoot.querySelector("[data-summary-picker-search]")?.focus()}))}closeSource(e=!1){const t=this.dialog?.activeSource;this.dialog&&t&&(this.dialog={...this.dialog,activeSource:null,entityFilter:""},this.host.requestUpdate(),e&&this.focusSource(t.blockId,t.valueId))}async focusSource(e,t){await this.host.updateComplete;const s=`${e}\n${t}`,r=this.host.renderRoot.querySelectorAll("[data-summary-source-owner]");[...r].find(e=>e.dataset.summarySourceOwner===s)?.focus()}setSource(e,t,s){this.mutate(r=>{const i=r.blocks.find(t=>t.id===e)?.values.find(e=>e.id===t);if(i)if(s.startsWith("system:")){const e=s.slice(7);(e=>"device_count"===e||"total_area"===e||"datetime"===e)(e)&&(i.source={type:"system",key:e})}else i.source={type:"entity",entity_id:s.startsWith("entity:")?s.slice(7):s}}),this.dialog&&(this.dialog={...this.dialog,activeSource:null,entityFilter:""}),this.host.requestUpdate(),this.focusSource(e,t)}dragStart(e,t){e.dataTransfer?.setData("text/x-houseplan-summary",t),e.dataTransfer&&(e.dataTransfer.effectAllowed="move")}drop(e,t){e.preventDefault(),e.stopPropagation();const s=e.dataTransfer?.getData("text/x-houseplan-summary")||"",r=s.split(":").map(Number),i=t.split(":").map(Number);s.startsWith("block:")&&t.startsWith("block:")?this.mutate(e=>{e.blocks=C(e.blocks,r[1],i[1])}):s.startsWith("value:")&&t.startsWith("value:")&&r[1]===i[1]&&this.mutate(e=>{e.blocks[r[1]].values=C(e.blocks[r[1]].values,r[2],i[2])})}async saveDialog(){const e=this.dialog;if(!e||e.busy)return;const t=this.lifecycleGeneration,s=x(e.draft);if((e.localOnly?[]:k(s,e.base,new Set(this.host._model.map(e=>e.id)),new Set(Object.keys(this.host.hass?.states||{})))).some(e=>"error"===e.kind))return this.dialog={...e,draft:s,attempted:!0},this.host.requestUpdate(),await this.host.updateComplete,void this.host.renderRoot.querySelector('[data-summary-error="true"]')?.focus?.();this.dialog={...e,draft:s,busy:!0,attempted:!1,error:"",conflict:!1},this.host.requestUpdate();try{if(!e.localOnly&&!$(s,e.base)){this.host._writesPending++;const r=a(this.host._writeChain,async()=>{if(!this.current(t))return;if(!this.host._serverCfg)throw new Error(this.t("summary.save_failed"));if(this.host._cfgRev!==e.baseRevision)throw new Error(this.t("summary.conflict"));const r=o({...this.host._serverCfg,settings:{...this.host._serverCfg.settings||{},summary_panel:s}});let i=!1;try{if(await this.host._sendConfigCandidate(r),!this.current(t))return}catch(e){if(!this.current(t))throw e;try{const r=await this.host._getAuthoritativeConfig();if(!this.current(t))throw e;const a=function(e,t){if(!g(e))return null;const s=e.config,r=e.rev;if(!g(s)||!Array.isArray(s.spaces)||"number"!=typeof r||!Number.isSafeInteger(r)||r<0)return null;const i=g(s.settings)?s.settings:null,a=i?.summary_panel;return v(a)&&$(a,t)?{config:s,rev:r}:null}(r,s);if(!a)throw e;const o=await this.host._adoptAuthoritative({cfgResp:r,reason:"summary-recovery",profile:"reload"});if("adopted"!==o.status)throw e;o.spaceChanged&&this.host._restoreZoom(),this.host._regSignature="",this.host._maybeRebuildDevices(),i=!0}catch{throw e}}if(!i){if(!this.current(t))return;this.host._adoption.stageConfigCandidate(r),this.host._cacheSnapshot()}});this.host._writeChain=r,await r.finally(()=>{this.host._writesPending--})}if(!this.current(t))return;this.saveLocal({show:e.localShow}),this.dialog=null}catch(s){if(!this.current(t))return;const r="conflict"===s?.code||this.host._cfgRev!==e.baseRevision;this.dialog={...this.dialog||e,busy:!1,conflict:r,error:r?this.t("summary.conflict"):this.host._errText(s)}}this.current(t)&&this.host.requestUpdate()}async reloadDialog(){const e=this.dialog;if(!e||e.busy)return;const t=this.lifecycleGeneration;this.dialog={...e,busy:!0,error:"",conflict:!1},this.host.requestUpdate();try{if(await this.host._reloadConfigOnly(!0),!this.current(t))return;if(e.conflict&&this.host._cfgRev===e.baseRevision)throw new Error(this.t("summary.load_failed"));const s=this.config().config||b(this.translate);this.dialog={...e,draft:_(s),base:_(s),baseRevision:this.host._cfgRev,busy:!1,attempted:!1,error:"",conflict:!1}}catch(s){if(!this.current(t))return;this.dialog={...e,busy:!1,error:this.host._errText(s),conflict:!0}}this.current(t)&&this.host.requestUpdate()}metricsFresh(){return!!this.deviceMemo&&!!this.areaMemo&&this.deviceMemo.cfgEpoch===this.host._cfgEpoch&&this.deviceMemo.layoutRev===this.host._layoutRev&&this.deviceMemo.registryRev===this.host._haRegistry.revision&&this.areaMemo.cfgEpoch===this.host._cfgEpoch}scheduleMetrics(){if(this.metricsRefresh||!this.metricsModule||this.metricsFresh())return;const e=this.lifecycleGeneration,t="undefined"==typeof window?void 0:window,s=()=>{if(this.metricsRefresh=0,!this.current(e))return;const t=this.advanceMetrics(8);this.host.requestUpdate(),t||this.scheduleMetrics()};this.metricsRefresh=t?.setTimeout(()=>{"function"==typeof t.requestAnimationFrame?t.requestAnimationFrame(()=>t.setTimeout(s,0)):s()},0)||0}advanceMetrics(e=8){const t=this.metricsModule;if(!t)return!0;if(this.computeDeviceCount(),!this.host._serverCfg)return this.areaMemo={cfgEpoch:this.host._cfgEpoch,value:null},!0;if(this.areaMemo&&this.areaMemo.cfgEpoch===this.host._cfgEpoch)return!0;this.areaSteps&&this.areaStepsEpoch===this.host._cfgEpoch||(this.areaSteps=t.cleanFloorAreaSteps(this.host._serverCfg,this.host._model),this.areaStepsEpoch=this.host._cfgEpoch);const s=Date.now();let r=this.areaSteps.next();for(;!r.done&&Date.now()-s[e,t.space])),spaceIds:new Set(this.host._model.map(e=>e.id)),firstSpaceId:this.host._model[0]?.id||"",markers:this.host._markers});this.deviceMemo={cfgEpoch:this.host._cfgEpoch,layoutRev:this.host._layoutRev,registryRev:this.host._haRegistry.revision,value:t?.size??null}}}computeMetrics(){for(;!this.advanceMetrics(Number.POSITIVE_INFINITY););}metrics(){return{deviceCount:this.deviceMemo?this.deviceMemo.value:null,areaM2:this.areaMemo?this.areaMemo.value:null,now:this.clock}}valueState(e){const t=this.metricsModule;if(!t)return{kind:"pending"};if("entity"===e.source.type){const s=t.summaryEntityValue(this.host.hass,e.source.entity_id);return null===s?{kind:"unavailable"}:{kind:"ready",text:s}}const s="device_count"===e.source.key||"total_area"===e.source.key,i="device_count"===e.source.key?this.deviceMemo:this.areaMemo;if(s&&!i)return this.scheduleMetrics(),{kind:"pending"};s&&this.scheduleMetrics();const a=t.summarySystemValue(e.source,this.metrics(),this.host.hass,r(this.host.hass,this.host._config?.language));return null===a?{kind:"unavailable"}:{kind:"ready",text:a}}value(e){const t=this.valueState(e);return"ready"===t.kind?t.text:this.t("summary.unavailable")}ensureMetrics(){if(this.metricsModule||this.metricsLoad)return;const e=this.lifecycleGeneration;this.metricsLoad=import("./summary-panel-metrics-Kwu_Jan4.js"),this.metricsLoad.then(t=>{this.metricsModule=t,this.current(e)&&this.host.requestUpdate()}).catch(()=>{}).finally(()=>{this.metricsLoad=null})}layout(){return function(e){const t=Math.max(0,Number(e.width)||0),s=Math.max(0,Number(e.height)||0),r=t>=s?"right":"bottom",i=Math.max(0,e.safeLeft||0)+12,a=Math.max(0,e.safeRight||0)+12,o=Math.max(Math.max(0,e.safeTop||0)+12,e.controlTop||0),n=Math.max(Math.max(0,e.safeBottom||0)+12,e.controlBottom||0),l=Math.max(0,t-i-a),m=Math.max(0,s-o-n),c="bottom"===r?Math.min(.6*s,m):m;return{side:r,fits:t>0&&s>0&&l>=280&&c>=Math.max(0,e.minimumHeight),availableWidth:l,heightCap:c,top:o,bottom:n}}({width:this.stage.width,height:this.stage.height,...this.safeInsets(),controlTop:this.host._kiosk?this.stage.controlTop:0,minimumHeight:this.stage.minimumHeight})}syncPresentation(e=!1){const t=this.config().config,s=this.layout(),r=!!t&&"view"===this.host._mode&&s.fits&&S({view:!0,localShow:!0,showOnMobile:t.show_on_mobile,narrow:this.host.narrow,fits:!0});this.presentation.sync(r&&this.local.show,s.side,e||!r||"hidden"===this.host.ownerDocument.visibilityState)}measureLayout(){const e=this.host._stageEl;if(!e)return;const t=this.host.renderRoot.querySelector(".summary-measure"),s=this.host.renderRoot.querySelector(".summary-control.kiosk"),r=e.getBoundingClientRect(),i=s?.getBoundingClientRect(),a={width:Math.round(e.clientWidth),height:Math.round(e.clientHeight),minimumHeight:Math.max(162,Math.ceil(t?.getBoundingClientRect().height||0)),controlTop:i?Math.max(0,Math.ceil(i.bottom-r.top+12)):0};a.width===this.stage.width&&a.height===this.stage.height&&a.minimumHeight===this.stage.minimumHeight&&a.controlTop===this.stage.controlTop||(this.stage=a,this.host.requestUpdate())}safeInsets(){const e=this.host.renderRoot.querySelector(".summary-safe-probe");if(!e)return{safeLeft:0,safeRight:0,safeTop:0,safeBottom:0};const t=this.host.ownerDocument.defaultView?.getComputedStyle(e);if(!t)return{safeLeft:0,safeRight:0,safeTop:0,safeBottom:0};const s=e=>Number.parseFloat(e)||0;return{safeLeft:s(t.paddingLeft),safeRight:s(t.paddingRight),safeTop:s(t.paddingTop),safeBottom:s(t.paddingBottom)}}hasVisibleClock(){const e=this.config().config;return!("hidden"===this.host.ownerDocument.visibilityState||!e)&&(!!S({view:"view"===this.host._mode,localShow:this.local.show,showOnMobile:e.show_on_mobile,narrow:this.host.narrow,fits:this.layout().fits})&&w(e,this.host._space).some(e=>e.values.some(e=>"system"===e.source.type&&"datetime"===e.source.key)))}syncClock(){const e=`${r(this.host.hass,this.host._config?.language)}\n${this.host.hass?.config?.time_zone||""}`;e!==this.clockContext&&(this.clockContext=e,this.clock=new Date);const t=this.hasVisibleClock();if(t&&!this.clockTimer){this.clock=new Date;const e=()=>{this.clock=new Date,this.clockTimer=0,this.host.requestUpdate(),this.syncClock()};this.clockTimer=window.setTimeout(e,6e4-Date.now()%6e4+25)}else!t&&this.clockTimer&&(clearTimeout(this.clockTimer),this.clockTimer=0)}}});export{A as a,G as b,z as c,D as d,V as e,C as m,x as n,$ as s}; diff --git a/dist/houseplan-assets/zigbee-topology-B31-i8CL.js b/custom_components/houseplan/frontend/houseplan-assets/zigbee-topology-3KJks91U.js similarity index 98% rename from dist/houseplan-assets/zigbee-topology-B31-i8CL.js rename to custom_components/houseplan/frontend/houseplan-assets/zigbee-topology-3KJks91U.js index df15ebc4..d3c8426c 100644 --- a/dist/houseplan-assets/zigbee-topology-B31-i8CL.js +++ b/custom_components/houseplan/frontend/houseplan-assets/zigbee-topology-3KJks91U.js @@ -1 +1 @@ -globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db7c58754eeb4ba03f835b8d7c84c6";import{s as e,aR as n}from"./houseplan-card-BiUNLHFh.js";var t={title:"Zigbee links",toggle:"Show Zigbee links when hovering over a device",hint:"Shows observed direct neighbours only. Nothing is fetched while you hover.",help:"Shows which Zigbee devices each device talks to directly. Line colour is link quality (LQI) on the same scale as the device's LQI reading: red at 40 and below, green at 180 and above. A dashed line means quality was not reported. An arrow points to the next device on the way to the coordinator: one arrow leads out, incoming arrows are the devices that route through this one. A line without an arrow is a spare neighbour. This is the route tree House Plan builds, not the path a packet takes right now: a label at the end of an arrow means its target is not on this plan, and no arrow at all means the route is unknown. Data comes from the last load and goes stale; links are shown with a mouse only.",help_aria:"Help: Zigbee links",admin_only:"Topology data is available to Home Assistant administrators only.",save_first:"Save this setting before loading topology data.",zha:"ZHA",zha_read:"Read ZHA data",zha_hint:"Reads ZHA's cached topology; it does not start a radio scan.",z2m:"Zigbee2MQTT",z2m_topics:"Base topics (one per line)",z2m_update:"Update map",z2m_warning:"A network-map scan can take 10 seconds to 2 minutes and may temporarily reduce Zigbee responsiveness.",status_idle:"Data not loaded",status_loading:"Loading…",status_ready:"Received {time}",status_stale:"Received {time} · stale",status_partial:"Received {time} · some nodes were omitted",status_no_links:"Received {time} · no observed links found",error_permission:"Administrator permission is required.",error_unsupported:"This provider or Home Assistant API is unavailable.",error_timeout:"The provider did not respond in time.",error_invalid_topic:"Check the Zigbee2MQTT base topic.",error_invalid_payload:"The provider returned unsupported topology data.",error_provider:"Topology data could not be loaded.",remote_count:"+{n} in other spaces",route_device_not_on_plan:"device is not on the plan",route_coordinator_not_on_plan:"coordinator is not on the plan",route_other_space:"another space"};const i={en:t,ru:{title:"Связи Zigbee",toggle:"Показывать связи Zigbee при наведении на устройство",hint:"Показываются только наблюдаемые прямые соседи. Наведение ничего не запрашивает.",help:"Показывает, с какими устройствами Zigbee каждое связано напрямую. Цвет линии — качество связи (LQI) по той же шкале, что у показателя LQI устройства: красный при 40 и ниже, зелёный при 180 и выше. Пунктир — качество не сообщено. Стрелка ведёт к следующему устройству по пути к координатору: исходящая одна, входящие — те, кто ходит через это устройство. Линия без стрелки — запасной сосед. Это дерево маршрутов, которое строит House Plan, а не путь пакета в эту секунду: подпись на конце стрелки значит, что цель не на этом плане, а отсутствие стрелки — что путь неизвестен. Данные из последней загрузки и устаревают, связи видны только при работе мышью.",help_aria:"Справка: связи Zigbee",admin_only:"Данные топологии доступны только администраторам Home Assistant.",save_first:"Сохраните настройку перед загрузкой данных топологии.",zha:"ZHA",zha_read:"Прочитать данные ZHA",zha_hint:"Читает сохранённую топологию ZHA и не запускает радио-сканирование.",z2m:"Zigbee2MQTT",z2m_topics:"Базовые топики (по одному в строке)",z2m_update:"Обновить карту",z2m_warning:"Сканирование карты сети занимает от 10 секунд до 2 минут и временно может снизить отзывчивость Zigbee.",status_idle:"Данные не загружены",status_loading:"Загрузка…",status_ready:"Получено: {time}",status_stale:"Получено: {time} · данные устарели",status_partial:"Получено: {time} · часть узлов не показана",status_no_links:"Получено: {time} · наблюдаемые связи не найдены",error_permission:"Нужны права администратора.",error_unsupported:"Провайдер или API Home Assistant недоступен.",error_timeout:"Провайдер не ответил вовремя.",error_invalid_topic:"Проверьте базовый топик Zigbee2MQTT.",error_invalid_payload:"Провайдер вернул неподдерживаемые данные топологии.",error_provider:"Не удалось загрузить данные топологии.",remote_count:"+{n} в других пространствах",route_device_not_on_plan:"устройства нет на плане",route_coordinator_not_on_plan:"координатора нет на плане",route_other_space:"другое пространство"},de:{title:"Zigbee-Verbindungen",toggle:"Zigbee-Verbindungen beim Darüberfahren über ein Gerät anzeigen",hint:"Es werden nur beobachtete direkte Nachbarn angezeigt. Beim Darüberfahren werden keine Daten abgerufen.",help:"Zeigt, mit welchen Zigbee-Geräten jedes Gerät direkt verbunden ist. Die Linienfarbe ist die Verbindungsqualität (LQI) auf derselben Skala wie der LQI-Wert des Geräts: rot bei 40 und darunter, grün bei 180 und darüber. Eine gestrichelte Linie bedeutet, dass die Qualität nicht gemeldet wurde. Ein Pfeil zeigt auf das nächste Gerät auf dem Weg zum Koordinator: ein Pfeil führt hinaus, eingehende Pfeile sind die Geräte, die über dieses Gerät routen. Eine Linie ohne Pfeil ist ein Ersatznachbar. Das ist der Routenbaum, den House Plan bildet, nicht der Weg eines Pakets in diesem Moment: eine Beschriftung am Pfeilende bedeutet, dass das Ziel nicht auf diesem Plan liegt, und ein fehlender Pfeil, dass die Route unbekannt ist. Die Daten stammen aus dem letzten Laden und veralten; Verbindungen sind nur mit der Maus sichtbar.",help_aria:"Hilfe: Zigbee-Verbindungen",admin_only:"Topologiedaten sind nur für Home-Assistant-Administratoren verfügbar.",save_first:"Speichere diese Einstellung, bevor Topologiedaten geladen werden.",zha:"ZHA",zha_read:"ZHA-Daten lesen",zha_hint:"Liest den ZHA-Topologiecache; es wird kein Funkscan gestartet.",z2m:"Zigbee2MQTT",z2m_topics:"Basistopics (eines pro Zeile)",z2m_update:"Karte aktualisieren",z2m_warning:"Ein Netzwerkscan kann 10 Sekunden bis 2 Minuten dauern und Zigbee vorübergehend verlangsamen.",status_idle:"Daten nicht geladen",status_loading:"Wird geladen…",status_ready:"Empfangen: {time}",status_stale:"Empfangen: {time} · veraltet",status_partial:"Empfangen: {time} · einige Knoten fehlen",status_no_links:"Empfangen: {time} · keine beobachteten Verbindungen gefunden",error_permission:"Administratorrechte sind erforderlich.",error_unsupported:"Dieser Anbieter oder die Home-Assistant-API ist nicht verfügbar.",error_timeout:"Der Anbieter hat nicht rechtzeitig geantwortet.",error_invalid_topic:"Prüfe das Zigbee2MQTT-Basistopic.",error_invalid_payload:"Der Anbieter hat nicht unterstützte Topologiedaten geliefert.",error_provider:"Topologiedaten konnten nicht geladen werden.",remote_count:"+{n} in anderen Bereichen",route_device_not_on_plan:"Gerät ist nicht im Plan",route_coordinator_not_on_plan:"Koordinator ist nicht im Plan",route_other_space:"anderer Bereich"},fr:{title:"Liens Zigbee",toggle:"Afficher les liens Zigbee au survol d’un appareil",hint:"Seuls les voisins directs observés sont affichés. Le survol ne lance aucune requête.",help:"Montre avec quels appareils Zigbee chaque appareil communique directement. La couleur de la ligne est la qualité du lien (LQI) sur la même échelle que l'indicateur LQI de l'appareil : rouge à 40 et en dessous, vert à 180 et au-dessus. Une ligne pointillée signifie que la qualité n'a pas été communiquée. Une flèche pointe vers l'appareil suivant sur le chemin du coordinateur : une flèche part, les flèches entrantes sont les appareils qui passent par celui-ci. Une ligne sans flèche est un voisin de secours. C'est l'arbre de routes que construit House Plan, pas le trajet d'un paquet à cet instant : une étiquette au bout d'une flèche signifie que sa cible n'est pas sur ce plan, et l'absence de flèche que la route est inconnue. Les données proviennent du dernier chargement et vieillissent ; les liens ne sont visibles qu'à la souris.",help_aria:"Aide : liens Zigbee",admin_only:"Les données de topologie sont réservées aux administrateurs Home Assistant.",save_first:"Enregistrez ce réglage avant de charger les données de topologie.",zha:"ZHA",zha_read:"Lire les données ZHA",zha_hint:"Lit la topologie en cache de ZHA sans lancer d’analyse radio.",z2m:"Zigbee2MQTT",z2m_topics:"Topics de base (un par ligne)",z2m_update:"Actualiser la carte",z2m_warning:"L’analyse de la carte réseau peut durer de 10 secondes à 2 minutes et réduire temporairement la réactivité de Zigbee.",status_idle:"Données non chargées",status_loading:"Chargement…",status_ready:"Reçu : {time}",status_stale:"Reçu : {time} · obsolète",status_partial:"Reçu : {time} · certains nœuds sont omis",status_no_links:"Reçu : {time} · aucun lien observé trouvé",error_permission:"Les droits administrateur sont requis.",error_unsupported:"Ce fournisseur ou l’API Home Assistant n’est pas disponible.",error_timeout:"Le fournisseur n’a pas répondu à temps.",error_invalid_topic:"Vérifiez le topic de base Zigbee2MQTT.",error_invalid_payload:"Le fournisseur a renvoyé des données de topologie non prises en charge.",error_provider:"Impossible de charger les données de topologie.",remote_count:"+{n} dans d’autres espaces",route_device_not_on_plan:"appareil absent du plan",route_coordinator_not_on_plan:"coordinateur absent du plan",route_other_space:"autre espace"}};function r(e,n){const r=i[e]?.[n]??t[n];return"string"==typeof r&&r.trim().length>0}function o(n,r,o){return e(i[n]?.[r]??t[r]??r,o)}const s=3e5,a=2097152,d=6e3;function l(e){return null!==e&&"object"==typeof e?e:null}function u(e){if("string"!=typeof e&&"number"!=typeof e)return null;let n=String(e).trim().toLowerCase();return n=/^0x[0-9a-f]{16}$/.test(n)?n.slice(2):n.replace(/[:-]/g,""),/^[0-9a-f]{16}$/.test(n)?n:null}function c(e,n,t){return`${e}:${n}:${t}`}function p(e){const n=String(e||"").toLowerCase().replace(/[ _-]/g,"");return n.includes("coordinator")?"coordinator":n.includes("router")?"router":n.includes("enddevice")||"end"===n?"end":"unknown"}const h=["parent","child","sibling","none","previous_child"];function g(e){const n=l(e),t=function(e){const n=Number(e);return Number.isFinite(n)&&n>=0&&n<=255?Math.round(n):void 0}(n?.lqi??n?.linkquality??n?.link_quality),i=function(e){if("number"==typeof e)return h[e];if("string"!=typeof e)return;const n=e.trim().toLowerCase().replace(/[\s_-]+/g,"");return"previouschild"===n?"previous_child":n.slice(0,40)||void 0}(n?.relationship);return{...void 0===t?{}:{lqi:t},...i?{relationship:i}:{}}}function f(e,n){return Array.isArray(e)&&e.length<=n?e:null}function _(e){if("string"==typeof e)return e.length<=a;try{return JSON.stringify(e).length<=a}catch{return!1}}function b(e,n,t,i,r){if(t===i)return void n.push({code:"self_link",nodeKey:t});const o=t=d){t.push({code:"invalid_payload"});break}const n=l(e),i=u(n?.ieee??n?.ieee_address);if(!i){t.push({code:"invalid_payload",nodeKey:s});continue}const a=c("zha","zha",i);r.has(a)||r.set(a,{key:a,ieee:i,role:p(n?.device_type)}),b(o,t,s,a,e)}else null!=n?.neighbors&&t.push({code:"invalid_payload",nodeKey:s})}return{provider:"zha",instanceId:"zha",obtainedAt:n,freshness:"provider-cache",nodes:[...r.values()],links:[...o.values()],warnings:t}}function v(e,n){const t=l(e),i=u(t?.ieeeAddr??t?.ieee_address??t?.ieee??e);if(i)return i;for(const i of[t?.id,t?.networkAddress,t?.network_address,e])if(null!=i){const e=n.get(String(i));if(e)return e}return null}function y(e,t,i=Date.now()){const r=[],o=n(t)||"invalid",s=_(e)?function(e){let n=e;if("string"==typeof n){if(n.length>a)return null;try{n=JSON.parse(n)}catch{return null}}const t=l(n),i=l(t?.data);if(n=i?.value??t?.value??t?.data??n,"string"==typeof n){if(n.length>a)return null;try{n=JSON.parse(n)}catch{return null}}return n}(e):null,h=l(s),g=f(h?.nodes,1e3),m=f(h?.links,d);if(!g||!m)return{provider:"z2m",instanceId:o,obtainedAt:i,freshness:"fresh-scan",nodes:[],links:[],warnings:[{code:"invalid_payload"}]};const y=new Map,k=new Map;for(const e of g){const n=l(e),t=u(n?.ieeeAddr??n?.ieee_address??n?.ieee);if(!t){r.push({code:"invalid_payload"});continue}const i=c("z2m",o,t);y.set(i,{key:i,ieee:t,role:p(n?.type??n?.device_type),..."boolean"==typeof n?.failed?{available:!n.failed}:{}});for(const e of[n?.id,n?.networkAddress,n?.network_address])null!=e&&k.set(String(e),t)}const w=new Map;for(const e of m){const n=l(e),t=u(n?.sourceIeeeAddr)??v(n?.source,k),i=u(n?.targetIeeeAddr)??v(n?.target,k);if(!t||!i){r.push({code:"invalid_payload"});continue}const s=c("z2m",o,t),a=c("z2m",o,i);y.has(s)||y.set(s,{key:s,ieee:t,role:"unknown"}),y.has(a)||y.set(a,{key:a,ieee:i,role:"unknown"}),b(w,r,s,a,e)}return{provider:"z2m",instanceId:o,obtainedAt:i,freshness:"fresh-scan",nodes:[...y.values()],links:[...w.values()],warnings:r}}function k(e){if("string"!=typeof e)return null;const n=u(e);if(n)return n;const t=e.toLowerCase().match(/^zigbee2mqtt(?:_bridge)?_(.+)$/);return t?u(t[1]):null}function w(e,n){if(e.deviceId&&n.devices[e.deviceId])return[e.deviceId];const t=new Set;for(const[i,r]of Object.entries(n.devices)){const n=l(r);(Array.isArray(n?.identifiers)?n.identifiers:[]).some(n=>Array.isArray(n)&&k(n[1])===e.ieee)&&t.add(i)}if(t.size)return[...t];for(const i of Object.values(n.entities)){const n=l(i);"string"==typeof n?.device_id&&"string"==typeof n.unique_id&&(k(n.unique_id)===e.ieee&&t.add(n.device_id))}return[...t]}function z(e){return!e.hidden&&!e.virtual&&"ha_disabled"!==e.bindingStatus?.kind&&"orphaned"!==e.bindingStatus?.kind&&"unverified"!==e.bindingStatus?.kind}function A(e){const n=new Map,t=new Map,i=e.nodes.filter(e=>"coordinator"===e.role).map(e=>e.key).sort();if(1!==i.length)return{distances:n,parents:t};const r=i[0],o=function(e){const n=new Set(e.nodes.map(e=>e.key)),t=new Map;for(const e of[...n].sort())t.set(e,[]);for(const i of[...e.links].sort((e,n)=>`${e.a}\0${e.b}`.localeCompare(`${n.a}\0${n.b}`)))n.has(i.a)&&n.has(i.b)&&(t.get(i.a).push({neighborKey:i.b,observation:i.aToB}),t.get(i.b).push({neighborKey:i.a,observation:i.bToA}));for(const e of t.values())e.sort((e,n)=>e.neighborKey.localeCompare(n.neighborKey));return t}(e);if(!o.has(r))return{distances:n,parents:t};n.set(r,0);const s=[r];for(let e=0;en.get(e)===i-1).sort((e,n)=>{const t="parent"===e.observation?.relationship?1:0,i="parent"===n.observation?.relationship?1:0;if(t!==i)return i-t;const r=e.observation?.lqi??-1;return(n.observation?.lqi??-1)-r||e.neighborKey.localeCompare(n.neighborKey)});r[0]&&t.set(e,r[0].neighborKey)}return{coordinatorKey:r,distances:n,parents:t}}function Z(e,n,t){const i=new Map,r=[];for(const o of e.nodes){if(!1===o.available){r.push({code:"provider_scan_failure",nodeKey:o.key});continue}const e=w(o,t);if(1!==e.length){r.push({code:"unmatched_device",nodeKey:o.key});continue}const s=e[0];let a=n.filter(e=>z(e)&&"device"===e.bindingKind&&e.bindingRef===s);a.length||(a=n.filter(e=>z(e)&&"entity"===e.bindingKind&&!!e.bindingRef&&t.entities[e.bindingRef]?.device_id===s)),1===a.length?i.set(o.key,{markerId:a[0].id,space:a[0].space}):r.push({code:a.length>1?"ambiguous_placement":"unmatched_device",nodeKey:o.key})}return{placements:i,warnings:r}}function T(e,n,t){return e.map(e=>({topology:e,placements:Z(e,n,t).placements,routes:A(e)}))}function q(e,n,t){const i=new Map,r=new Set,o=new Map;let s=0;for(const{topology:a,placements:d,routes:l}of e){const e=new Set([...d].filter(([,e])=>e.markerId===t&&e.space===n).map(([e])=>e));if(e.size){for(const t of e){const e=l.parents.get(t);if(!e)continue;const i=d.get(e);if(i?.space===n)continue;let r;r=i?{kind:"remote-space",spaceId:i.space}:"coordinator"===a.nodes.find(n=>n.key===e)?.role?{kind:"unplaced-coordinator"}:{kind:"unplaced-device"};const s="remote-space"===r.kind?`${r.kind}:${r.spaceId}`:r.kind;o.set(s,r)}for(const o of a.links){const a=e.has(o.a),u=e.has(o.b);if(!a&&!u)continue;const c=a?o.a:o.b,p=a?o.b:o.a,h=d.get(p);if(!h||h.markerId===t){s++;continue}const g=l.parents.get(c)===p;if(h.space!==n){g||r.add(h.markerId);continue}const f=a?o.aToB:o.bToA,_=g?"toward-neighbor":l.parents.get(p)===c?"toward-origin":void 0,b=i.get(h.markerId);b?(void 0===b.line.lqi&&void 0!==f?.lqi&&(b.line.lqi=f.lqi),_&&b.directions.add(_)):i.set(h.markerId,{line:{neighborMarkerId:h.markerId,lqi:f?.lqi},directions:new Set(_?[_]:[])})}}}return{lines:[...i.values()].map(({line:e,directions:n})=>1===n.size?{...e,routeDirection:[...n][0]}:e),remoteCount:r.size,omittedCount:s,parentTargets:[...o.values()]}}export{s as T,T as a,y as b,r as h,Z as m,m as n,q as r,o as t}; +globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="d31b0b1e184ab2863684b758f839bdb6809a33cc742c6e9bb36c5ea034e3d309";import{s as e,aR as n}from"./houseplan-card-W9mG3gab.js";var t={title:"Zigbee links",toggle:"Show Zigbee links when hovering over a device",hint:"Shows observed direct neighbours only. Nothing is fetched while you hover.",help:"Shows which Zigbee devices each device talks to directly. Line colour is link quality (LQI) on the same scale as the device's LQI reading: red at 40 and below, green at 180 and above. A dashed line means quality was not reported. An arrow points to the next device on the way to the coordinator: one arrow leads out, incoming arrows are the devices that route through this one. A line without an arrow is a spare neighbour. This is the route tree House Plan builds, not the path a packet takes right now: a label at the end of an arrow means its target is not on this plan, and no arrow at all means the route is unknown. Data comes from the last load and goes stale; links are shown with a mouse only.",help_aria:"Help: Zigbee links",admin_only:"Topology data is available to Home Assistant administrators only.",save_first:"Save this setting before loading topology data.",zha:"ZHA",zha_read:"Read ZHA data",zha_hint:"Reads ZHA's cached topology; it does not start a radio scan.",z2m:"Zigbee2MQTT",z2m_topics:"Base topics (one per line)",z2m_update:"Update map",z2m_warning:"A network-map scan can take 10 seconds to 2 minutes and may temporarily reduce Zigbee responsiveness.",status_idle:"Data not loaded",status_loading:"Loading…",status_ready:"Received {time}",status_stale:"Received {time} · stale",status_partial:"Received {time} · some nodes were omitted",status_no_links:"Received {time} · no observed links found",error_permission:"Administrator permission is required.",error_unsupported:"This provider or Home Assistant API is unavailable.",error_timeout:"The provider did not respond in time.",error_invalid_topic:"Check the Zigbee2MQTT base topic.",error_invalid_payload:"The provider returned unsupported topology data.",error_provider:"Topology data could not be loaded.",remote_count:"+{n} in other spaces",route_device_not_on_plan:"device is not on the plan",route_coordinator_not_on_plan:"coordinator is not on the plan",route_other_space:"another space"};const i={en:t,ru:{title:"Связи Zigbee",toggle:"Показывать связи Zigbee при наведении на устройство",hint:"Показываются только наблюдаемые прямые соседи. Наведение ничего не запрашивает.",help:"Показывает, с какими устройствами Zigbee каждое связано напрямую. Цвет линии — качество связи (LQI) по той же шкале, что у показателя LQI устройства: красный при 40 и ниже, зелёный при 180 и выше. Пунктир — качество не сообщено. Стрелка ведёт к следующему устройству по пути к координатору: исходящая одна, входящие — те, кто ходит через это устройство. Линия без стрелки — запасной сосед. Это дерево маршрутов, которое строит House Plan, а не путь пакета в эту секунду: подпись на конце стрелки значит, что цель не на этом плане, а отсутствие стрелки — что путь неизвестен. Данные из последней загрузки и устаревают, связи видны только при работе мышью.",help_aria:"Справка: связи Zigbee",admin_only:"Данные топологии доступны только администраторам Home Assistant.",save_first:"Сохраните настройку перед загрузкой данных топологии.",zha:"ZHA",zha_read:"Прочитать данные ZHA",zha_hint:"Читает сохранённую топологию ZHA и не запускает радио-сканирование.",z2m:"Zigbee2MQTT",z2m_topics:"Базовые топики (по одному в строке)",z2m_update:"Обновить карту",z2m_warning:"Сканирование карты сети занимает от 10 секунд до 2 минут и временно может снизить отзывчивость Zigbee.",status_idle:"Данные не загружены",status_loading:"Загрузка…",status_ready:"Получено: {time}",status_stale:"Получено: {time} · данные устарели",status_partial:"Получено: {time} · часть узлов не показана",status_no_links:"Получено: {time} · наблюдаемые связи не найдены",error_permission:"Нужны права администратора.",error_unsupported:"Провайдер или API Home Assistant недоступен.",error_timeout:"Провайдер не ответил вовремя.",error_invalid_topic:"Проверьте базовый топик Zigbee2MQTT.",error_invalid_payload:"Провайдер вернул неподдерживаемые данные топологии.",error_provider:"Не удалось загрузить данные топологии.",remote_count:"+{n} в других пространствах",route_device_not_on_plan:"устройства нет на плане",route_coordinator_not_on_plan:"координатора нет на плане",route_other_space:"другое пространство"},de:{title:"Zigbee-Verbindungen",toggle:"Zigbee-Verbindungen beim Darüberfahren über ein Gerät anzeigen",hint:"Es werden nur beobachtete direkte Nachbarn angezeigt. Beim Darüberfahren werden keine Daten abgerufen.",help:"Zeigt, mit welchen Zigbee-Geräten jedes Gerät direkt verbunden ist. Die Linienfarbe ist die Verbindungsqualität (LQI) auf derselben Skala wie der LQI-Wert des Geräts: rot bei 40 und darunter, grün bei 180 und darüber. Eine gestrichelte Linie bedeutet, dass die Qualität nicht gemeldet wurde. Ein Pfeil zeigt auf das nächste Gerät auf dem Weg zum Koordinator: ein Pfeil führt hinaus, eingehende Pfeile sind die Geräte, die über dieses Gerät routen. Eine Linie ohne Pfeil ist ein Ersatznachbar. Das ist der Routenbaum, den House Plan bildet, nicht der Weg eines Pakets in diesem Moment: eine Beschriftung am Pfeilende bedeutet, dass das Ziel nicht auf diesem Plan liegt, und ein fehlender Pfeil, dass die Route unbekannt ist. Die Daten stammen aus dem letzten Laden und veralten; Verbindungen sind nur mit der Maus sichtbar.",help_aria:"Hilfe: Zigbee-Verbindungen",admin_only:"Topologiedaten sind nur für Home-Assistant-Administratoren verfügbar.",save_first:"Speichere diese Einstellung, bevor Topologiedaten geladen werden.",zha:"ZHA",zha_read:"ZHA-Daten lesen",zha_hint:"Liest den ZHA-Topologiecache; es wird kein Funkscan gestartet.",z2m:"Zigbee2MQTT",z2m_topics:"Basistopics (eines pro Zeile)",z2m_update:"Karte aktualisieren",z2m_warning:"Ein Netzwerkscan kann 10 Sekunden bis 2 Minuten dauern und Zigbee vorübergehend verlangsamen.",status_idle:"Daten nicht geladen",status_loading:"Wird geladen…",status_ready:"Empfangen: {time}",status_stale:"Empfangen: {time} · veraltet",status_partial:"Empfangen: {time} · einige Knoten fehlen",status_no_links:"Empfangen: {time} · keine beobachteten Verbindungen gefunden",error_permission:"Administratorrechte sind erforderlich.",error_unsupported:"Dieser Anbieter oder die Home-Assistant-API ist nicht verfügbar.",error_timeout:"Der Anbieter hat nicht rechtzeitig geantwortet.",error_invalid_topic:"Prüfe das Zigbee2MQTT-Basistopic.",error_invalid_payload:"Der Anbieter hat nicht unterstützte Topologiedaten geliefert.",error_provider:"Topologiedaten konnten nicht geladen werden.",remote_count:"+{n} in anderen Bereichen",route_device_not_on_plan:"Gerät ist nicht im Plan",route_coordinator_not_on_plan:"Koordinator ist nicht im Plan",route_other_space:"anderer Bereich"},fr:{title:"Liens Zigbee",toggle:"Afficher les liens Zigbee au survol d’un appareil",hint:"Seuls les voisins directs observés sont affichés. Le survol ne lance aucune requête.",help:"Montre avec quels appareils Zigbee chaque appareil communique directement. La couleur de la ligne est la qualité du lien (LQI) sur la même échelle que l'indicateur LQI de l'appareil : rouge à 40 et en dessous, vert à 180 et au-dessus. Une ligne pointillée signifie que la qualité n'a pas été communiquée. Une flèche pointe vers l'appareil suivant sur le chemin du coordinateur : une flèche part, les flèches entrantes sont les appareils qui passent par celui-ci. Une ligne sans flèche est un voisin de secours. C'est l'arbre de routes que construit House Plan, pas le trajet d'un paquet à cet instant : une étiquette au bout d'une flèche signifie que sa cible n'est pas sur ce plan, et l'absence de flèche que la route est inconnue. Les données proviennent du dernier chargement et vieillissent ; les liens ne sont visibles qu'à la souris.",help_aria:"Aide : liens Zigbee",admin_only:"Les données de topologie sont réservées aux administrateurs Home Assistant.",save_first:"Enregistrez ce réglage avant de charger les données de topologie.",zha:"ZHA",zha_read:"Lire les données ZHA",zha_hint:"Lit la topologie en cache de ZHA sans lancer d’analyse radio.",z2m:"Zigbee2MQTT",z2m_topics:"Topics de base (un par ligne)",z2m_update:"Actualiser la carte",z2m_warning:"L’analyse de la carte réseau peut durer de 10 secondes à 2 minutes et réduire temporairement la réactivité de Zigbee.",status_idle:"Données non chargées",status_loading:"Chargement…",status_ready:"Reçu : {time}",status_stale:"Reçu : {time} · obsolète",status_partial:"Reçu : {time} · certains nœuds sont omis",status_no_links:"Reçu : {time} · aucun lien observé trouvé",error_permission:"Les droits administrateur sont requis.",error_unsupported:"Ce fournisseur ou l’API Home Assistant n’est pas disponible.",error_timeout:"Le fournisseur n’a pas répondu à temps.",error_invalid_topic:"Vérifiez le topic de base Zigbee2MQTT.",error_invalid_payload:"Le fournisseur a renvoyé des données de topologie non prises en charge.",error_provider:"Impossible de charger les données de topologie.",remote_count:"+{n} dans d’autres espaces",route_device_not_on_plan:"appareil absent du plan",route_coordinator_not_on_plan:"coordinateur absent du plan",route_other_space:"autre espace"}};function r(e,n){const r=i[e]?.[n]??t[n];return"string"==typeof r&&r.trim().length>0}function o(n,r,o){return e(i[n]?.[r]??t[r]??r,o)}const s=3e5,a=2097152,d=6e3;function l(e){return null!==e&&"object"==typeof e?e:null}function u(e){if("string"!=typeof e&&"number"!=typeof e)return null;let n=String(e).trim().toLowerCase();return n=/^0x[0-9a-f]{16}$/.test(n)?n.slice(2):n.replace(/[:-]/g,""),/^[0-9a-f]{16}$/.test(n)?n:null}function c(e,n,t){return`${e}:${n}:${t}`}function p(e){const n=String(e||"").toLowerCase().replace(/[ _-]/g,"");return n.includes("coordinator")?"coordinator":n.includes("router")?"router":n.includes("enddevice")||"end"===n?"end":"unknown"}const h=["parent","child","sibling","none","previous_child"];function g(e){const n=l(e),t=function(e){const n=Number(e);return Number.isFinite(n)&&n>=0&&n<=255?Math.round(n):void 0}(n?.lqi??n?.linkquality??n?.link_quality),i=function(e){if("number"==typeof e)return h[e];if("string"!=typeof e)return;const n=e.trim().toLowerCase().replace(/[\s_-]+/g,"");return"previouschild"===n?"previous_child":n.slice(0,40)||void 0}(n?.relationship);return{...void 0===t?{}:{lqi:t},...i?{relationship:i}:{}}}function f(e,n){return Array.isArray(e)&&e.length<=n?e:null}function _(e){if("string"==typeof e)return e.length<=a;try{return JSON.stringify(e).length<=a}catch{return!1}}function b(e,n,t,i,r){if(t===i)return void n.push({code:"self_link",nodeKey:t});const o=t=d){t.push({code:"invalid_payload"});break}const n=l(e),i=u(n?.ieee??n?.ieee_address);if(!i){t.push({code:"invalid_payload",nodeKey:s});continue}const a=c("zha","zha",i);r.has(a)||r.set(a,{key:a,ieee:i,role:p(n?.device_type)}),b(o,t,s,a,e)}else null!=n?.neighbors&&t.push({code:"invalid_payload",nodeKey:s})}return{provider:"zha",instanceId:"zha",obtainedAt:n,freshness:"provider-cache",nodes:[...r.values()],links:[...o.values()],warnings:t}}function v(e,n){const t=l(e),i=u(t?.ieeeAddr??t?.ieee_address??t?.ieee??e);if(i)return i;for(const i of[t?.id,t?.networkAddress,t?.network_address,e])if(null!=i){const e=n.get(String(i));if(e)return e}return null}function y(e,t,i=Date.now()){const r=[],o=n(t)||"invalid",s=_(e)?function(e){let n=e;if("string"==typeof n){if(n.length>a)return null;try{n=JSON.parse(n)}catch{return null}}const t=l(n),i=l(t?.data);if(n=i?.value??t?.value??t?.data??n,"string"==typeof n){if(n.length>a)return null;try{n=JSON.parse(n)}catch{return null}}return n}(e):null,h=l(s),g=f(h?.nodes,1e3),m=f(h?.links,d);if(!g||!m)return{provider:"z2m",instanceId:o,obtainedAt:i,freshness:"fresh-scan",nodes:[],links:[],warnings:[{code:"invalid_payload"}]};const y=new Map,k=new Map;for(const e of g){const n=l(e),t=u(n?.ieeeAddr??n?.ieee_address??n?.ieee);if(!t){r.push({code:"invalid_payload"});continue}const i=c("z2m",o,t);y.set(i,{key:i,ieee:t,role:p(n?.type??n?.device_type),..."boolean"==typeof n?.failed?{available:!n.failed}:{}});for(const e of[n?.id,n?.networkAddress,n?.network_address])null!=e&&k.set(String(e),t)}const w=new Map;for(const e of m){const n=l(e),t=u(n?.sourceIeeeAddr)??v(n?.source,k),i=u(n?.targetIeeeAddr)??v(n?.target,k);if(!t||!i){r.push({code:"invalid_payload"});continue}const s=c("z2m",o,t),a=c("z2m",o,i);y.has(s)||y.set(s,{key:s,ieee:t,role:"unknown"}),y.has(a)||y.set(a,{key:a,ieee:i,role:"unknown"}),b(w,r,s,a,e)}return{provider:"z2m",instanceId:o,obtainedAt:i,freshness:"fresh-scan",nodes:[...y.values()],links:[...w.values()],warnings:r}}function k(e){if("string"!=typeof e)return null;const n=u(e);if(n)return n;const t=e.toLowerCase().match(/^zigbee2mqtt(?:_bridge)?_(.+)$/);return t?u(t[1]):null}function w(e,n){if(e.deviceId&&n.devices[e.deviceId])return[e.deviceId];const t=new Set;for(const[i,r]of Object.entries(n.devices)){const n=l(r);(Array.isArray(n?.identifiers)?n.identifiers:[]).some(n=>Array.isArray(n)&&k(n[1])===e.ieee)&&t.add(i)}if(t.size)return[...t];for(const i of Object.values(n.entities)){const n=l(i);"string"==typeof n?.device_id&&"string"==typeof n.unique_id&&(k(n.unique_id)===e.ieee&&t.add(n.device_id))}return[...t]}function z(e){return!e.hidden&&!e.virtual&&"ha_disabled"!==e.bindingStatus?.kind&&"orphaned"!==e.bindingStatus?.kind&&"unverified"!==e.bindingStatus?.kind}function A(e){const n=new Map,t=new Map,i=e.nodes.filter(e=>"coordinator"===e.role).map(e=>e.key).sort();if(1!==i.length)return{distances:n,parents:t};const r=i[0],o=function(e){const n=new Set(e.nodes.map(e=>e.key)),t=new Map;for(const e of[...n].sort())t.set(e,[]);for(const i of[...e.links].sort((e,n)=>`${e.a}\0${e.b}`.localeCompare(`${n.a}\0${n.b}`)))n.has(i.a)&&n.has(i.b)&&(t.get(i.a).push({neighborKey:i.b,observation:i.aToB}),t.get(i.b).push({neighborKey:i.a,observation:i.bToA}));for(const e of t.values())e.sort((e,n)=>e.neighborKey.localeCompare(n.neighborKey));return t}(e);if(!o.has(r))return{distances:n,parents:t};n.set(r,0);const s=[r];for(let e=0;en.get(e)===i-1).sort((e,n)=>{const t="parent"===e.observation?.relationship?1:0,i="parent"===n.observation?.relationship?1:0;if(t!==i)return i-t;const r=e.observation?.lqi??-1;return(n.observation?.lqi??-1)-r||e.neighborKey.localeCompare(n.neighborKey)});r[0]&&t.set(e,r[0].neighborKey)}return{coordinatorKey:r,distances:n,parents:t}}function Z(e,n,t){const i=new Map,r=[];for(const o of e.nodes){if(!1===o.available){r.push({code:"provider_scan_failure",nodeKey:o.key});continue}const e=w(o,t);if(1!==e.length){r.push({code:"unmatched_device",nodeKey:o.key});continue}const s=e[0];let a=n.filter(e=>z(e)&&"device"===e.bindingKind&&e.bindingRef===s);a.length||(a=n.filter(e=>z(e)&&"entity"===e.bindingKind&&!!e.bindingRef&&t.entities[e.bindingRef]?.device_id===s)),1===a.length?i.set(o.key,{markerId:a[0].id,space:a[0].space}):r.push({code:a.length>1?"ambiguous_placement":"unmatched_device",nodeKey:o.key})}return{placements:i,warnings:r}}function T(e,n,t){return e.map(e=>({topology:e,placements:Z(e,n,t).placements,routes:A(e)}))}function q(e,n,t){const i=new Map,r=new Set,o=new Map;let s=0;for(const{topology:a,placements:d,routes:l}of e){const e=new Set([...d].filter(([,e])=>e.markerId===t&&e.space===n).map(([e])=>e));if(e.size){for(const t of e){const e=l.parents.get(t);if(!e)continue;const i=d.get(e);if(i?.space===n)continue;let r;r=i?{kind:"remote-space",spaceId:i.space}:"coordinator"===a.nodes.find(n=>n.key===e)?.role?{kind:"unplaced-coordinator"}:{kind:"unplaced-device"};const s="remote-space"===r.kind?`${r.kind}:${r.spaceId}`:r.kind;o.set(s,r)}for(const o of a.links){const a=e.has(o.a),u=e.has(o.b);if(!a&&!u)continue;const c=a?o.a:o.b,p=a?o.b:o.a,h=d.get(p);if(!h||h.markerId===t){s++;continue}const g=l.parents.get(c)===p;if(h.space!==n){g||r.add(h.markerId);continue}const f=a?o.aToB:o.bToA,_=g?"toward-neighbor":l.parents.get(p)===c?"toward-origin":void 0,b=i.get(h.markerId);b?(void 0===b.line.lqi&&void 0!==f?.lqi&&(b.line.lqi=f.lqi),_&&b.directions.add(_)):i.set(h.markerId,{line:{neighborMarkerId:h.markerId,lqi:f?.lqi},directions:new Set(_?[_]:[])})}}}return{lines:[...i.values()].map(({line:e,directions:n})=>1===n.size?{...e,routeDirection:[...n][0]}:e),remoteCount:r.size,omittedCount:s,parentTargets:[...o.values()]}}export{s as T,T as a,y as b,r as h,Z as m,m as n,q as r,o as t}; diff --git a/custom_components/houseplan/frontend/houseplan-assets/zigbee-topology-runtime-CuXFHyzq.js b/custom_components/houseplan/frontend/houseplan-assets/zigbee-topology-runtime-DvCmPEhl.js similarity index 83% rename from custom_components/houseplan/frontend/houseplan-assets/zigbee-topology-runtime-CuXFHyzq.js rename to custom_components/houseplan/frontend/houseplan-assets/zigbee-topology-runtime-DvCmPEhl.js index 893c2c21..88ccfdcd 100644 --- a/custom_components/houseplan/frontend/houseplan-assets/zigbee-topology-runtime-CuXFHyzq.js +++ b/custom_components/houseplan/frontend/houseplan-assets/zigbee-topology-runtime-DvCmPEhl.js @@ -1 +1 @@ -globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db7c58754eeb4ba03f835b8d7c84c6";import{n as t,b as n}from"./zigbee-topology-B31-i8CL.js";import{aR as e}from"./houseplan-card-BiUNLHFh.js";const o=new WeakMap;function i(t){const n=function(t){const n=t?.connection||t;return!n||"object"!=typeof n&&"function"!=typeof n?null:n}(t);if(!n)return null;let e=o.get(n);return e||(e={revision:0,topologies:[],states:{},listeners:new Set,inflight:new Map},o.set(n,e)),e}function r(t,n,e){t.states={...t.states,[n]:e},function(t){t.revision++;for(const n of t.listeners)n()}(t)}function s(t){const n=t?.code;if("permission"===n||"unsupported"===n||"timeout"===n||"invalid_topic"===n||"invalid_payload"===n)return n;const e=String(t?.message||"").toLowerCase();return e.includes("unauthor")||e.includes("permission")?"permission":e.includes("unknown_command")||e.includes("not found")?"unsupported":"provider"}function a(t){return Object.assign(new Error(t),{code:t})}function c(t,n,e){const o=t.inflight.get(n);if(o)return o;r(t,n,{phase:"loading"});const i=e().then(n=>{if(!n.nodes.length&&n.warnings.some(t=>"invalid_payload"===t.code))throw a("invalid_payload");!function(t,n){t.topologies=[...t.topologies.filter(t=>!(t.provider===n.provider&&t.instanceId===n.instanceId)),n],r(t,"zha"===n.provider?"zha":`z2m:${n.instanceId}`,{phase:"ready",obtainedAt:n.obtainedAt,partial:n.warnings.length>0})}(t,n)}).catch(e=>{r(t,n,{phase:"error",error:s(e)})}).finally(()=>t.inflight.delete(n));return t.inflight.set(n,i),i}function l(t){const n=i(t);return n?{revision:n.revision,topologies:n.topologies,states:n.states}:{revision:0,topologies:[],states:{}}}function u(t,n){const e=i(t);return e?(e.listeners.add(n),()=>e.listeners.delete(n)):()=>{}}function p(t){if(!0!==t?.user?.is_admin)throw a("permission")}function f(n){const e=i(n);return e?c(e,"zha",async()=>{if(p(n),"function"!=typeof n?.callWS)throw a("unsupported");return t(await n.callWS({type:"zha/devices"}))}):Promise.resolve()}function d(t){return null!==t&&"object"==typeof t?t:null}function h(t){const n=d(t),e=n?.payload??t;if("string"!=typeof e)return e;try{return JSON.parse(e)}catch{return null}}async function g(t,n){let e;try{return await Promise.race([t,new Promise((t,o)=>{e=globalThis.setTimeout(()=>o(a("timeout")),Math.max(1,n))})])}finally{void 0!==e&&globalThis.clearTimeout(e)}}function m(t,o,r=15e4){const s=i(t);if(!s)return Promise.resolve();const l=e(o);return c(s,`z2m:${l||String(o)}`,async()=>{if(p(t),!l)throw a("invalid_topic");const e=t.connection,o=e?.subscribeMessage;if("function"!=typeof o||"function"!=typeof t?.callService)throw a("unsupported");const i=function(){const t=globalThis.crypto;return"function"==typeof t?.randomUUID?`houseplan-${t.randomUUID()}`:`houseplan-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}(),s=Date.now()+Math.max(1,r);let c=!1,u=null,f=null,m=null;const y=new Promise(t=>{u=t}),b=new Promise((t,n)=>{f=t,m=n}),w=[];try{const r=await o.call(e,t=>{!0===d(t)?.retain&&h(t)&&u?.()},{type:"mqtt/subscribe",topic:`${l}/bridge/info`});"function"==typeof r&&w.push(r);const p=await o.call(e,t=>{if(!0===d(t)?.retain)return;const n=h(t);null!==n?n&&function(t){const n=d(t),e=n?.transaction??d(n?.data)?.transaction;return"string"==typeof e||"number"==typeof e?String(e):null}(n)===i&&f?.(n):c&&m?.(a("invalid_payload"))},{type:"mqtt/subscribe",topic:`${l}/bridge/response/networkmap`});"function"==typeof p&&w.push(p),await g(y,Math.min(4e3,Math.max(1,s-Date.now()))),c=!0,await t.callService("mqtt","publish",{topic:`${l}/bridge/request/networkmap`,payload:JSON.stringify({type:"raw",routes:!1,transaction:i}),qos:0,retain:!1});const v=await g(b,s-Date.now()),_=d(v)?.status;if(_&&"ok"!==_)throw a("provider");return n(v,l)}finally{for(const t of w)try{t()}catch{}}})}export{f as readZhaTopology,m as refreshZ2mTopology,u as subscribeZigbeeTopology,l as zigbeeTopologyRuntimeSnapshot}; +globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="d31b0b1e184ab2863684b758f839bdb6809a33cc742c6e9bb36c5ea034e3d309";import{n as t,b as n}from"./zigbee-topology-3KJks91U.js";import{aR as e}from"./houseplan-card-W9mG3gab.js";const o=new WeakMap;function i(t){const n=function(t){const n=t?.connection||t;return!n||"object"!=typeof n&&"function"!=typeof n?null:n}(t);if(!n)return null;let e=o.get(n);return e||(e={revision:0,topologies:[],states:{},listeners:new Set,inflight:new Map},o.set(n,e)),e}function r(t,n,e){t.states={...t.states,[n]:e},function(t){t.revision++;for(const n of t.listeners)n()}(t)}function s(t){const n=t?.code;if("permission"===n||"unsupported"===n||"timeout"===n||"invalid_topic"===n||"invalid_payload"===n)return n;const e=String(t?.message||"").toLowerCase();return e.includes("unauthor")||e.includes("permission")?"permission":e.includes("unknown_command")||e.includes("not found")?"unsupported":"provider"}function a(t){return Object.assign(new Error(t),{code:t})}function c(t,n,e){const o=t.inflight.get(n);if(o)return o;r(t,n,{phase:"loading"});const i=e().then(n=>{if(!n.nodes.length&&n.warnings.some(t=>"invalid_payload"===t.code))throw a("invalid_payload");!function(t,n){t.topologies=[...t.topologies.filter(t=>!(t.provider===n.provider&&t.instanceId===n.instanceId)),n],r(t,"zha"===n.provider?"zha":`z2m:${n.instanceId}`,{phase:"ready",obtainedAt:n.obtainedAt,partial:n.warnings.length>0})}(t,n)}).catch(e=>{r(t,n,{phase:"error",error:s(e)})}).finally(()=>t.inflight.delete(n));return t.inflight.set(n,i),i}function l(t){const n=i(t);return n?{revision:n.revision,topologies:n.topologies,states:n.states}:{revision:0,topologies:[],states:{}}}function u(t,n){const e=i(t);return e?(e.listeners.add(n),()=>e.listeners.delete(n)):()=>{}}function p(t){if(!0!==t?.user?.is_admin)throw a("permission")}function f(n){const e=i(n);return e?c(e,"zha",async()=>{if(p(n),"function"!=typeof n?.callWS)throw a("unsupported");return t(await n.callWS({type:"zha/devices"}))}):Promise.resolve()}function d(t){return null!==t&&"object"==typeof t?t:null}function h(t){const n=d(t),e=n?.payload??t;if("string"!=typeof e)return e;try{return JSON.parse(e)}catch{return null}}async function g(t,n){let e;try{return await Promise.race([t,new Promise((t,o)=>{e=globalThis.setTimeout(()=>o(a("timeout")),Math.max(1,n))})])}finally{void 0!==e&&globalThis.clearTimeout(e)}}function m(t,o,r=15e4){const s=i(t);if(!s)return Promise.resolve();const l=e(o);return c(s,`z2m:${l||String(o)}`,async()=>{if(p(t),!l)throw a("invalid_topic");const e=t.connection,o=e?.subscribeMessage;if("function"!=typeof o||"function"!=typeof t?.callService)throw a("unsupported");const i=function(){const t=globalThis.crypto;return"function"==typeof t?.randomUUID?`houseplan-${t.randomUUID()}`:`houseplan-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}(),s=Date.now()+Math.max(1,r);let c=!1,u=null,f=null,m=null;const y=new Promise(t=>{u=t}),w=new Promise((t,n)=>{f=t,m=n}),b=[];try{const r=await o.call(e,t=>{!0===d(t)?.retain&&h(t)&&u?.()},{type:"mqtt/subscribe",topic:`${l}/bridge/info`});"function"==typeof r&&b.push(r);const p=await o.call(e,t=>{if(!0===d(t)?.retain)return;const n=h(t);null!==n?n&&function(t){const n=d(t),e=n?.transaction??d(n?.data)?.transaction;return"string"==typeof e||"number"==typeof e?String(e):null}(n)===i&&f?.(n):c&&m?.(a("invalid_payload"))},{type:"mqtt/subscribe",topic:`${l}/bridge/response/networkmap`});"function"==typeof p&&b.push(p),await g(y,Math.min(4e3,Math.max(1,s-Date.now()))),c=!0,await t.callService("mqtt","publish",{topic:`${l}/bridge/request/networkmap`,payload:JSON.stringify({type:"raw",routes:!1,transaction:i}),qos:0,retain:!1});const v=await g(w,s-Date.now()),_=d(v)?.status;if(_&&"ok"!==_)throw a("provider");return n(v,l)}finally{for(const t of b)try{t()}catch{}}})}export{f as readZhaTopology,m as refreshZ2mTopology,u as subscribeZigbeeTopology,l as zigbeeTopologyRuntimeSnapshot}; diff --git a/custom_components/houseplan/frontend/houseplan-card.js b/custom_components/houseplan/frontend/houseplan-card.js index 507fbb06..118f9cb4 100644 --- a/custom_components/houseplan/frontend/houseplan-card.js +++ b/custom_components/houseplan/frontend/houseplan-card.js @@ -1 +1 @@ -globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db7c58754eeb4ba03f835b8d7c84c6";try{await import("./houseplan-assets/houseplan-card-BiUNLHFh.js")}catch(e){if(!customElements.get("houseplan-card")){const l=String(navigator.language||"en").toLowerCase();const m=l.startsWith("ru")?"House Plan обновился — перезагрузите страницу (Ctrl+F5).":l.startsWith("de")?"House Plan wurde aktualisiert — bitte laden Sie die Seite neu (Strg+F5).":l.startsWith("fr")?"House Plan a été mis à jour — veuillez recharger la page (Ctrl+F5).":"House Plan was updated — please reload the page (Ctrl+F5).";customElements.define("houseplan-card",class extends HTMLElement{setConfig(){}getCardSize(){return 1}connectedCallback(){this.style.cssText="display:block;box-sizing:border-box;padding:16px;border:1px solid var(--divider-color,#e0e0e0);border-radius:var(--ha-card-border-radius,12px);background:var(--card-background-color,#fff);color:var(--primary-text-color,#212121);font:14px/1.4 var(--paper-font-body1_-_font-family,sans-serif)";this.textContent=m}})}console.error("[houseplan] stale houseplan-card.js: the implementation chunk is unavailable",e)} +globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="d31b0b1e184ab2863684b758f839bdb6809a33cc742c6e9bb36c5ea034e3d309";try{await import("./houseplan-assets/houseplan-card-W9mG3gab.js")}catch(e){if(!customElements.get("houseplan-card")){const l=String(navigator.language||"en").toLowerCase();const m=l.startsWith("ru")?"House Plan обновился — перезагрузите страницу (Ctrl+F5).":l.startsWith("de")?"House Plan wurde aktualisiert — bitte laden Sie die Seite neu (Strg+F5).":l.startsWith("fr")?"House Plan a été mis à jour — veuillez recharger la page (Ctrl+F5).":"House Plan was updated — please reload the page (Ctrl+F5).";customElements.define("houseplan-card",class extends HTMLElement{setConfig(){}getCardSize(){return 1}connectedCallback(){this.style.cssText="display:block;box-sizing:border-box;padding:16px;border:1px solid var(--divider-color,#e0e0e0);border-radius:var(--ha-card-border-radius,12px);background:var(--card-background-color,#fff);color:var(--primary-text-color,#212121);font:14px/1.4 var(--paper-font-body1_-_font-family,sans-serif)";this.textContent=m}})}console.error("[houseplan] stale houseplan-card.js: the implementation chunk is unavailable",e)} diff --git a/custom_components/houseplan/frontend/houseplan-panel.js b/custom_components/houseplan/frontend/houseplan-panel.js index c4075593..88256dbf 100644 --- a/custom_components/houseplan/frontend/houseplan-panel.js +++ b/custom_components/houseplan/frontend/houseplan-panel.js @@ -1 +1 @@ -globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db7c58754eeb4ba03f835b8d7c84c6";try{await import("./houseplan-assets/houseplan-card-BiUNLHFh.js")}catch(e){if(!customElements.get("houseplan-panel")){const l=String(navigator.language||"en").toLowerCase();const m=l.startsWith("ru")?"House Plan обновился — перезагрузите страницу (Ctrl+F5).":l.startsWith("de")?"House Plan wurde aktualisiert — bitte laden Sie die Seite neu (Strg+F5).":l.startsWith("fr")?"House Plan a été mis à jour — veuillez recharger la page (Ctrl+F5).":"House Plan was updated — please reload the page (Ctrl+F5).";customElements.define("houseplan-panel",class extends HTMLElement{connectedCallback(){this.style.cssText="display:block;box-sizing:border-box;padding:16px;min-height:100%;background:var(--card-background-color,#fff);color:var(--primary-text-color,#212121);font:14px/1.4 var(--paper-font-body1_-_font-family,sans-serif)";this.textContent=m}})}console.error("[houseplan] stale houseplan-panel.js: the card implementation chunk is unavailable",e)}const e=["panel","hass","narrow","route"];class n extends HTMLElement{constructor(){super(),this._narrow=!1,this.attachShadow({mode:"open"}),this._adoptPreUpgradeProperties()}connectedCallback(){this._adoptPreUpgradeProperties(),this._ensureShell()}_adoptPreUpgradeProperties(){for(const n of e){if(!Object.prototype.hasOwnProperty.call(this,n))continue;const e=this[n];delete this[n],this[n]=e}}get hass(){return this._hass}set hass(e){this._hass=e,this._ensureShell(),this._card&&(this._card.hass=e),this._syncMenuLabel()}get narrow(){return this._narrow}set narrow(e){this._narrow=Boolean(e),this.toggleAttribute("narrow",this._narrow),this._card&&(this._card.narrow=this._narrow)}get route(){return this._route}set route(e){this._route=e}get panel(){return this._panel}set panel(e){this._panel=e}_ensureShell(){if(this._card||!this.shadowRoot)return;const e=document.createElement("style");e.textContent="\n :host {\n display: block;\n width: 100%;\n /* HA mounts a custom panel inside , a block with\n * safe-area padding and NO height, so a percentage here resolves to\n * auto and the stage collapses to 0 px (#488). Take the viewport\n * like HA's own iframe panels do, minus the insets HA pads with. */\n height: 100vh;\n height: calc(100dvh - var(--safe-area-inset-top, 0px) - var(--safe-area-inset-bottom, 0px));\n min-width: 0;\n min-height: 0;\n overflow: hidden;\n color: var(--primary-text-color);\n background: var(--primary-background-color);\n }\n .page {\n width: 100%;\n height: 100%;\n min-width: 0;\n min-height: 0;\n display: grid;\n grid-template-rows: auto minmax(0, 1fr);\n overflow: hidden;\n }\n .appbar {\n box-sizing: border-box;\n min-width: 0;\n min-height: var(--header-height, 56px);\n display: flex;\n align-items: center;\n gap: 12px;\n padding: 0 16px;\n background: var(--app-header-background-color, var(--primary-background-color));\n color: var(--app-header-text-color, var(--primary-text-color));\n border-bottom: 1px solid var(--divider-color);\n z-index: 1;\n }\n .toolbar {\n min-width: 0;\n width: 100%;\n display: flex;\n align-items: center;\n gap: 12px;\n }\n .menu {\n box-sizing: border-box;\n width: 44px;\n height: 44px;\n min-width: 44px;\n min-height: 44px;\n margin: 0;\n padding: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n border: 0;\n border-radius: 50%;\n color: inherit;\n background: transparent;\n cursor: pointer;\n }\n .menu:focus-visible {\n outline: 2px solid var(--primary-color);\n outline-offset: 2px;\n }\n @media (hover: hover) {\n .menu:hover { background: var(--secondary-background-color); }\n }\n .menu ha-icon { --mdc-icon-size: 24px; }\n .title {\n min-width: 0;\n display: flex;\n align-items: center;\n gap: 10px;\n font-size: 20px;\n font-weight: 500;\n line-height: 1.2;\n }\n .title ha-icon {\n --mdc-icon-size: 24px;\n color: var(--primary-color);\n }\n .content {\n min-width: 0;\n min-height: 0;\n overflow: hidden;\n }\n houseplan-card {\n width: 100%;\n height: 100%;\n min-width: 0;\n min-height: 0;\n }\n ";const n=document.createElement("div");n.className="page";const t=document.createElement("header");t.className="appbar";const a=document.createElement("div");a.className="toolbar",a.setAttribute("role","toolbar");const o=document.createElement("button");o.className="menu",o.dataset.hp="panel-menu",o.type="button",o.innerHTML='',o.addEventListener("click",()=>{o.dispatchEvent(new CustomEvent("hass-toggle-menu",{bubbles:!0,composed:!0}))}),this._menuButton=o;const i=document.createElement("div");i.className="title",i.dataset.hp="panel-title",i.setAttribute("role","heading"),i.setAttribute("aria-level","1"),i.innerHTML='House Plan',a.append(o,i),t.append(a);const r=document.createElement("main");r.className="content";const s=document.createElement("houseplan-card");s.panelHost=!0,s.narrow=this._narrow,s.setConfig({type:"custom:houseplan-card"}),void 0!==this._hass&&(s.hass=this._hass),r.append(s),n.append(t,r),this.shadowRoot.append(e,n),this._card=s,this._syncMenuLabel()}_syncMenuLabel(){if(!this._menuButton)return;const e=this._hass?.localize?.("ui.common.menu")||this._hass?.localize?.("ui.panel.lovelace.menu")||"Menu";this._menuButton.setAttribute("aria-label",e),this._menuButton.title=e}}customElements.get("houseplan-panel")||customElements.define("houseplan-panel",n);export{n as HouseplanPanel}; +globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="d31b0b1e184ab2863684b758f839bdb6809a33cc742c6e9bb36c5ea034e3d309";try{await import("./houseplan-assets/houseplan-card-W9mG3gab.js")}catch(e){if(!customElements.get("houseplan-panel")){const l=String(navigator.language||"en").toLowerCase();const m=l.startsWith("ru")?"House Plan обновился — перезагрузите страницу (Ctrl+F5).":l.startsWith("de")?"House Plan wurde aktualisiert — bitte laden Sie die Seite neu (Strg+F5).":l.startsWith("fr")?"House Plan a été mis à jour — veuillez recharger la page (Ctrl+F5).":"House Plan was updated — please reload the page (Ctrl+F5).";customElements.define("houseplan-panel",class extends HTMLElement{connectedCallback(){this.style.cssText="display:block;box-sizing:border-box;padding:16px;min-height:100%;background:var(--card-background-color,#fff);color:var(--primary-text-color,#212121);font:14px/1.4 var(--paper-font-body1_-_font-family,sans-serif)";this.textContent=m}})}console.error("[houseplan] stale houseplan-panel.js: the card implementation chunk is unavailable",e)}const e=["panel","hass","narrow","route"];class n extends HTMLElement{constructor(){super(),this._narrow=!1,this.attachShadow({mode:"open"}),this._adoptPreUpgradeProperties()}connectedCallback(){this._adoptPreUpgradeProperties(),this._ensureShell()}_adoptPreUpgradeProperties(){for(const n of e){if(!Object.prototype.hasOwnProperty.call(this,n))continue;const e=this[n];delete this[n],this[n]=e}}get hass(){return this._hass}set hass(e){this._hass=e,this._ensureShell(),this._card&&(this._card.hass=e),this._syncMenuLabel()}get narrow(){return this._narrow}set narrow(e){this._narrow=Boolean(e),this.toggleAttribute("narrow",this._narrow),this._card&&(this._card.narrow=this._narrow)}get route(){return this._route}set route(e){this._route=e}get panel(){return this._panel}set panel(e){this._panel=e}_ensureShell(){if(this._card||!this.shadowRoot)return;const e=document.createElement("style");e.textContent="\n :host {\n display: block;\n width: 100%;\n /* HA mounts a custom panel inside , a block with\n * safe-area padding and NO height, so a percentage here resolves to\n * auto and the stage collapses to 0 px (#488). Take the viewport\n * like HA's own iframe panels do, minus the insets HA pads with. */\n height: 100vh;\n height: calc(100dvh - var(--safe-area-inset-top, 0px) - var(--safe-area-inset-bottom, 0px));\n min-width: 0;\n min-height: 0;\n overflow: hidden;\n color: var(--primary-text-color);\n background: var(--primary-background-color);\n }\n .page {\n width: 100%;\n height: 100%;\n min-width: 0;\n min-height: 0;\n display: grid;\n grid-template-rows: auto minmax(0, 1fr);\n overflow: hidden;\n }\n .appbar {\n box-sizing: border-box;\n min-width: 0;\n min-height: var(--header-height, 56px);\n display: flex;\n align-items: center;\n gap: 12px;\n padding: 0 16px;\n background: var(--app-header-background-color, var(--primary-background-color));\n color: var(--app-header-text-color, var(--primary-text-color));\n border-bottom: 1px solid var(--divider-color);\n z-index: 1;\n }\n .toolbar {\n min-width: 0;\n width: 100%;\n display: flex;\n align-items: center;\n gap: 12px;\n }\n .menu {\n box-sizing: border-box;\n width: 44px;\n height: 44px;\n min-width: 44px;\n min-height: 44px;\n margin: 0;\n padding: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n border: 0;\n border-radius: 50%;\n color: inherit;\n background: transparent;\n cursor: pointer;\n }\n .menu:focus-visible {\n outline: 2px solid var(--primary-color);\n outline-offset: 2px;\n }\n @media (hover: hover) {\n .menu:hover { background: var(--secondary-background-color); }\n }\n .menu ha-icon { --mdc-icon-size: 24px; }\n .title {\n min-width: 0;\n display: flex;\n align-items: center;\n gap: 10px;\n font-size: 20px;\n font-weight: 500;\n line-height: 1.2;\n }\n .title ha-icon {\n --mdc-icon-size: 24px;\n color: var(--primary-color);\n }\n .content {\n min-width: 0;\n min-height: 0;\n overflow: hidden;\n }\n houseplan-card {\n width: 100%;\n height: 100%;\n min-width: 0;\n min-height: 0;\n }\n ";const n=document.createElement("div");n.className="page";const t=document.createElement("header");t.className="appbar";const a=document.createElement("div");a.className="toolbar",a.setAttribute("role","toolbar");const o=document.createElement("button");o.className="menu",o.dataset.hp="panel-menu",o.type="button",o.innerHTML='',o.addEventListener("click",()=>{o.dispatchEvent(new CustomEvent("hass-toggle-menu",{bubbles:!0,composed:!0}))}),this._menuButton=o;const i=document.createElement("div");i.className="title",i.dataset.hp="panel-title",i.setAttribute("role","heading"),i.setAttribute("aria-level","1"),i.innerHTML='House Plan',a.append(o,i),t.append(a);const r=document.createElement("main");r.className="content";const s=document.createElement("houseplan-card");s.panelHost=!0,s.narrow=this._narrow,s.setConfig({type:"custom:houseplan-card"}),void 0!==this._hass&&(s.hass=this._hass),r.append(s),n.append(t,r),this.shadowRoot.append(e,n),this._card=s,this._syncMenuLabel()}_syncMenuLabel(){if(!this._menuButton)return;const e=this._hass?.localize?.("ui.common.menu")||this._hass?.localize?.("ui.panel.lovelace.menu")||"Menu";this._menuButton.setAttribute("aria-label",e),this._menuButton.title=e}}customElements.get("houseplan-panel")||customElements.define("houseplan-panel",n);export{n as HouseplanPanel}; diff --git a/demo/smoke_settings_dialog_cards.mjs b/demo/smoke_settings_dialog_cards.mjs new file mode 100644 index 00000000..8bfe053d --- /dev/null +++ b/demo/smoke_settings_dialog_cards.mjs @@ -0,0 +1,81 @@ +// #598: три диалога настроек собраны в карточки-группы. Свидетель отдельный, а +// не дописанный к существующим: девять смоков с `.srcrow` объявлены в ТЗ +// неприкосновенными (AC2), и правка любого из них стоила бы ревью опоры — +// отличить «свидетель поправлен под новую разметку» от «свидетель ослаблен под +// сломанный код» по диффу такого файла нельзя. +// +// Здесь проверяется то, чего раньше не проверял никто: состав карточек, +// клавиатура новых сегментов, размер цели и — главное — что два сообщения о +// СОСТОЯНИИ остались на виду, а не уехали под «?» заодно с пояснениями (К5). +import { launch, checkAll, finish } from './serve.mjs'; + +const { page, browser } = await launch(); +const out = await page.evaluate(async () => { + const o = {}; + const c = window.__card; + const sr = () => c.shadowRoot || c.renderRoot; + const cards = () => [...sr().querySelectorAll('hp-dialog .hpf-card')]; + const headings = () => cards().map((card) => card.querySelector('.hpf-head h3')?.textContent.trim()); + + // --- «Общие настройки»: карточки, сегмент фона, сообщение о состоянии ---- + c._openSettingsDialog(); await c.updateComplete; + o.generalCardsInOrder = JSON.stringify(headings()) === JSON.stringify([ + c._t('gs.card_display'), c._t('gs.card_zigbee'), c._t('gs.card_fills'), + c._t('gs.glow_group'), c._t('gs.card_plan'), c._t('gs.sun_group'), c._t('gs.card_data'), + ]); + o.everyGeneralCardHasContent = cards().every((card) => card.querySelector('.hpf-head + *')); + + // Сегмент фона: настоящая радиогруппа с доступным именем и целью ≥ 44 px. + const bgSeg = sr().querySelector('hp-dialog .hpf-seg[role="radiogroup"]'); + const bgRadios = bgSeg ? [...bgSeg.querySelectorAll('input[type="radio"]')] : []; + o.bgSegmentIsRadioGroup = !!bgSeg && !!bgSeg.getAttribute('aria-label') && bgRadios.length === 2; + // Цель нажатия ≥ 44 px. Проверка нашла настоящий дефект: лист набора + // подключается вызовом `ensureFormKitStyles`, и без него сегмент рисовался + // высотой 14 px — вся доступность держалась на стиле, которого не было. + o.bgSegmentTargetIsBigEnough = bgRadios.length > 0 && bgRadios.every((radio) => { + const box = radio.closest('label')?.getBoundingClientRect(); + return !!box && box.height >= 44; + }); + // Клавиатура: стрелка переводит выбор на соседний вариант, как в списке, + // который сегмент заменил. Значение черновика обязано поехать следом. + const bgBefore = c._settingsDialog.bgMode; + const other = bgRadios.find((radio) => !radio.checked); + other?.focus(); + o.bgSegmentTakesFocus = !!other && bgSeg.contains(sr().activeElement ?? document.activeElement); + other?.click(); await c.updateComplete; + o.bgSegmentWritesItsOwnKey = c._settingsDialog.bgMode !== bgBefore + && c._settingsDialog.northDeg === null; + + // `gs.sun_missing` — сообщение о состоянии. Убираем sun.sun и требуем, чтобы + // абзац был виден, а не спрятан под «?» (К5). + const states = { ...c.hass.states }; + delete states['sun.sun']; + c.hass = { ...c.hass, states }; + await c.updateComplete; + const sunNote = [...sr().querySelectorAll('hp-dialog .rhint')] + .find((node) => node.textContent.trim() === c._t('gs.sun_missing')); + o.sunMissingStaysVisible = !!sunNote && sunNote.getBoundingClientRect().height > 0 + && !sr().querySelector('hp-dialog hp-help[data-help-key="gs.sun_missing.help"]'); + c._settingsDialog = null; await c.updateComplete; + + // --- «Пространство»: карточки и два сегмента вместо селектов ------------- + c._openSpaceDialog('edit', c._space); await c.updateComplete; + o.spaceCardsInOrder = JSON.stringify(headings()) === JSON.stringify([ + c._t('space.card_basics'), c._t('space.display_section'), + c._t('space.roomcard_section'), c._t('space.card_sun'), + ]); + const spaceSegs = [...sr().querySelectorAll('hp-dialog .hpf-seg[role="radiogroup"]')]; + o.spaceHasTwoSegments = spaceSegs.length === 2 + && spaceSegs.every((seg) => !!seg.getAttribute('aria-label')); + const zeroBefore = c._spaceDialog.zeroWallStyle; + const titleBefore = c._spaceDialog.title; + const zeroOther = [...spaceSegs[0]?.querySelectorAll('input[type="radio"]') ?? []] + .find((radio) => !radio.checked); + zeroOther?.click(); await c.updateComplete; + o.zeroWallSegmentWritesItsOwnKey = c._spaceDialog.zeroWallStyle !== zeroBefore + && c._spaceDialog.title === titleBefore; + c._spaceDialog = null; await c.updateComplete; + + return o; +}); +await finish(browser, checkAll(out)); diff --git a/demo/smoke_tap_run.mjs b/demo/smoke_tap_run.mjs index e0609bb1..83f10b60 100644 --- a/demo/smoke_tap_run.mjs +++ b/demo/smoke_tap_run.mjs @@ -38,27 +38,6 @@ const out = await page.evaluate(async () => { // сохранение без цели блокируется await c._saveMarker(); await c.updateComplete; o.saveBlockedWithoutTarget = !!c._markerDialog; - // #598 К5: пропавшая цель — сообщение о СОСТОЯНИИ, а не пояснение. Оно - // остаётся абзацем на виду и называет идентификатор; под «?» такой текст - // уехать не может — подставить туда `{id}` нечем, и человек не узнает, что - // действие сломано, пока сам не откроет подсказку. - c._markerDialog = { ...c._markerDialog, tapTarget: 'script.no_such_target_598' }; - await c.updateComplete; - const goneNote = [...sr().querySelectorAll('hp-dialog .rhint')] - .find((node) => node.textContent.includes('script.no_such_target_598')); - o.missingRunTargetStaysVisible = !!goneNote - && goneNote.getBoundingClientRect().height > 0 - && !sr().querySelector('hp-dialog hp-help[data-help-key="marker.run_target_gone.help"]'); - // карточки диалога: пять групп в заданном порядке, каждая непустая - const markerCards = [...sr().querySelectorAll('hp-dialog .hpf-card > .hpf-head h3')] - .map((h) => h.textContent.trim()); - o.markerCardsInOrder = JSON.stringify(markerCards) === JSON.stringify([ - c._t('marker.card_basics'), c._t('marker.card_tap'), c._t('marker.card_light'), - c._t('marker.card_appearance'), c._t('marker.card_details'), - ]); - o.everyMarkerCardHasContent = [...sr().querySelectorAll('hp-dialog .hpf-card')] - .every((card) => card.querySelector('.hpf-head + *')); - // выбираем цель + подтверждение, сохраняем c._markerDialog = { ...c._markerDialog, tapTarget: 'script.curtains', tapConfirm: true }; await c.updateComplete; @@ -101,7 +80,6 @@ const out = await page.evaluate(async () => { c._clickDevice({ stopPropagation() {} }, dev2); await c.updateComplete; o.missingTargetSafe = calls.length === 0 && !!c._toast; - // очистка c._serverCfg.markers = c._serverCfg.markers.filter((m) => m.id !== (saved?.id ?? d.id)); c._cfgEpoch++; c._regSignature = ''; c._maybeRebuildDevices(); diff --git a/dist/houseplan-assets.json b/dist/houseplan-assets.json index 887ca531..aaf7b142 100644 --- a/dist/houseplan-assets.json +++ b/dist/houseplan-assets.json @@ -1,309 +1,309 @@ { "schema": 1, - "fingerprint": "ed91b3971428d2b8e7bfceb8025d2be4c0db7c58754eeb4ba03f835b8d7c84c6", + "fingerprint": "d31b0b1e184ab2863684b758f839bdb6809a33cc742c6e9bb36c5ea034e3d309", "entry": "houseplan-card.js", "panelEntry": "houseplan-panel.js", "initialViewFiles": [ - "houseplan-assets/houseplan-card-BiUNLHFh.js", + "houseplan-assets/houseplan-card-W9mG3gab.js", "houseplan-card.js" ], - "initialViewGzipBytes": 291522, + "initialViewGzipBytes": 291530, "initialPanelFiles": [ - "houseplan-assets/houseplan-card-BiUNLHFh.js", + "houseplan-assets/houseplan-card-W9mG3gab.js", "houseplan-panel.js" ], - "initialPanelGzipBytes": 293044, + "initialPanelGzipBytes": 293053, "initialPanelOnlyFiles": [ "houseplan-panel.js" ], - "initialPanelOnlyGzipBytes": 2325, + "initialPanelOnlyGzipBytes": 2326, "lazyFiles": [ - "houseplan-assets/backdrop-pick-Ev52LRir.js", - "houseplan-assets/de-DHIqglxm.js", - "houseplan-assets/editor-Dc4-BCoL.js", - "houseplan-assets/form-kit.styles-BQTkV2m1.js", - "houseplan-assets/fr-BUCrcPpM.js", - "houseplan-assets/furniture-plan-art.generated-O7K1vBfu.js", - "houseplan-assets/houseplan-editor-runtime-BG2wMJ7n.js", - "houseplan-assets/houseplan-onboarding-runtime-BAx8bJB2.js", - "houseplan-assets/hp-zigbee-topology-overlay-SYVcVGiq.js", - "houseplan-assets/iso-scene-render-CR59iy_N.js", - "houseplan-assets/live-interaction-runtime-C7FQnbBF.js", - "houseplan-assets/pdf-export-FjKO_S28.js", - "houseplan-assets/summary-panel-runtime-loaded-B9-PG-Gw.js", - "houseplan-assets/zigbee-topology-B31-i8CL.js", - "houseplan-assets/zigbee-topology-runtime-CuXFHyzq.js" + "houseplan-assets/backdrop-pick-ToIYfsVt.js", + "houseplan-assets/de-lgvVUcKp.js", + "houseplan-assets/editor-0Mj9gnAf.js", + "houseplan-assets/form-kit.styles-BSWYQ2Fp.js", + "houseplan-assets/fr-CHBDMDsG.js", + "houseplan-assets/furniture-plan-art.generated-B9qZ5DM-.js", + "houseplan-assets/houseplan-editor-runtime-DOSm4OKX.js", + "houseplan-assets/houseplan-onboarding-runtime-G7DfDSe_.js", + "houseplan-assets/hp-zigbee-topology-overlay-CAehZ6TG.js", + "houseplan-assets/iso-scene-render-CCwC6ZHk.js", + "houseplan-assets/live-interaction-runtime-DpDkGNJh.js", + "houseplan-assets/pdf-export-B1B1amDF.js", + "houseplan-assets/summary-panel-runtime-loaded-C3VkX0bk.js", + "houseplan-assets/zigbee-topology-3KJks91U.js", + "houseplan-assets/zigbee-topology-runtime-DvCmPEhl.js" ], - "lazyGzipBytes": 439294, + "lazyGzipBytes": 439327, "lazyEditorFiles": [ - "houseplan-assets/backdrop-pick-Ev52LRir.js", - "houseplan-assets/editor-Dc4-BCoL.js", - "houseplan-assets/form-kit.styles-BQTkV2m1.js", - "houseplan-assets/furniture-plan-art.generated-O7K1vBfu.js", - "houseplan-assets/houseplan-editor-runtime-BG2wMJ7n.js", - "houseplan-assets/zigbee-topology-B31-i8CL.js" + "houseplan-assets/backdrop-pick-ToIYfsVt.js", + "houseplan-assets/editor-0Mj9gnAf.js", + "houseplan-assets/form-kit.styles-BSWYQ2Fp.js", + "houseplan-assets/furniture-plan-art.generated-B9qZ5DM-.js", + "houseplan-assets/houseplan-editor-runtime-DOSm4OKX.js", + "houseplan-assets/zigbee-topology-3KJks91U.js" ], - "lazyEditorGzipBytes": 222190, + "lazyEditorGzipBytes": 222198, "lazyOnboardingFiles": [ - "houseplan-assets/backdrop-pick-Ev52LRir.js", - "houseplan-assets/houseplan-onboarding-runtime-BAx8bJB2.js" + "houseplan-assets/backdrop-pick-ToIYfsVt.js", + "houseplan-assets/houseplan-onboarding-runtime-G7DfDSe_.js" ], - "lazyOnboardingGzipBytes": 13916, + "lazyOnboardingGzipBytes": 13921, "lazyLocaleFiles": [ - "houseplan-assets/de-DHIqglxm.js", - "houseplan-assets/fr-BUCrcPpM.js" + "houseplan-assets/de-lgvVUcKp.js", + "houseplan-assets/fr-CHBDMDsG.js" ], - "lazyLocaleGzipBytes": 56354, + "lazyLocaleGzipBytes": 56365, "lazyIsometricFiles": [ - "houseplan-assets/iso-scene-render-CR59iy_N.js" + "houseplan-assets/iso-scene-render-CCwC6ZHk.js" ], - "lazyIsometricGzipBytes": 15013, + "lazyIsometricGzipBytes": 15016, "lazyFurnitureArtFiles": [ - "houseplan-assets/furniture-plan-art.generated-O7K1vBfu.js" + "houseplan-assets/furniture-plan-art.generated-B9qZ5DM-.js" ], - "lazyFurnitureArtGzipBytes": 16943, + "lazyFurnitureArtGzipBytes": 16940, "lazyPdfFiles": [ - "houseplan-assets/furniture-plan-art.generated-O7K1vBfu.js", - "houseplan-assets/pdf-export-FjKO_S28.js" + "houseplan-assets/furniture-plan-art.generated-B9qZ5DM-.js", + "houseplan-assets/pdf-export-B1B1amDF.js" ], - "lazyPdfGzipBytes": 126817, + "lazyPdfGzipBytes": 126813, "files": [ { - "path": "houseplan-assets/backdrop-pick-Ev52LRir.js", - "sha256": "2a15e36abcf8b5df52a6e96f347157949fc51572d177a7b4604f9ba0c2cc0563", + "path": "houseplan-assets/backdrop-pick-ToIYfsVt.js", + "sha256": "467a4c0884298f63173094735389446e86f2b04943d9518f822c9206f7d220ed", "rawBytes": 19959, - "gzipBytes": 6881, + "gzipBytes": 6883, "isEntry": false, "imports": [ - "houseplan-assets/houseplan-card-BiUNLHFh.js" + "houseplan-assets/houseplan-card-W9mG3gab.js" ], "dynamicImports": [] }, { - "path": "houseplan-assets/de-DHIqglxm.js", - "sha256": "336585ab9807040f4ae15d678086d6a681ffc62742b00350b466a2b9d35f7f25", + "path": "houseplan-assets/de-lgvVUcKp.js", + "sha256": "1654ca87abcb74a6e64db4624456cb3d9e9742b96501f0e0f85ac9cd3313717e", "rawBytes": 93989, - "gzipBytes": 28442, + "gzipBytes": 28448, "isEntry": false, "imports": [], "dynamicImports": [] }, { - "path": "houseplan-assets/editor-Dc4-BCoL.js", - "sha256": "06f0d6b2e83bd049f7cde67da7fb484b164ceb10db965662a80b9172cd60a650", + "path": "houseplan-assets/editor-0Mj9gnAf.js", + "sha256": "03ec9fa26b6d517aa05ee39a2ef60f59a3e9be81b6499475ba8184f9fb026235", "rawBytes": 3833, - "gzipBytes": 1581, + "gzipBytes": 1583, "isEntry": false, "imports": [ - "houseplan-assets/houseplan-card-BiUNLHFh.js" + "houseplan-assets/houseplan-card-W9mG3gab.js" ], "dynamicImports": [] }, { - "path": "houseplan-assets/form-kit.styles-BQTkV2m1.js", - "sha256": "20f850ea621e9310a86d26ecd9c2a37bc34ceadca8a7049a4c5cf12963fd24a9", + "path": "houseplan-assets/form-kit.styles-BSWYQ2Fp.js", + "sha256": "6d0965d557fe14691b2842a8f8ed0069ebd6cfed7facab7c02d0995106a908c8", "rawBytes": 3615, - "gzipBytes": 1233, + "gzipBytes": 1234, "isEntry": false, "imports": [], "dynamicImports": [] }, { - "path": "houseplan-assets/fr-BUCrcPpM.js", - "sha256": "cfdba0ac7ae0114c12c8ba8216f3197fc58c2fcb0b020ec839199551faaff1c1", + "path": "houseplan-assets/fr-CHBDMDsG.js", + "sha256": "029c8f373570ea5c5798775d49f0500057dac01b3cbd4c74d2b4c7cad411cf21", "rawBytes": 96460, - "gzipBytes": 27912, + "gzipBytes": 27917, "isEntry": false, "imports": [], "dynamicImports": [] }, { - "path": "houseplan-assets/furniture-plan-art.generated-O7K1vBfu.js", - "sha256": "add6e49eaea5b500246044a0fd3835258efc75e9e70374fd361a0c9011f66fa9", + "path": "houseplan-assets/furniture-plan-art.generated-B9qZ5DM-.js", + "sha256": "0ff4bf848333842e22567d52d5e2591c63cf994f5ab877d1e6f6143a7a6d65d9", "rawBytes": 52033, - "gzipBytes": 16943, + "gzipBytes": 16940, "isEntry": false, "imports": [], "dynamicImports": [] }, { - "path": "houseplan-assets/houseplan-card-BiUNLHFh.js", - "sha256": "26013d506b7b7dc5c7f876ec2ab7204ad69e2a42e0f164cf1c6ff075e9c1f9be", + "path": "houseplan-assets/houseplan-card-W9mG3gab.js", + "sha256": "fd3620fc81c2b5149ebfab53fa49392b6340b17a5d7d300ff70797a777a73d6c", "rawBytes": 1035518, - "gzipBytes": 290719, + "gzipBytes": 290727, "isEntry": false, "imports": [], "dynamicImports": [ - "houseplan-assets/de-DHIqglxm.js", - "houseplan-assets/editor-Dc4-BCoL.js", - "houseplan-assets/fr-BUCrcPpM.js", - "houseplan-assets/furniture-plan-art.generated-O7K1vBfu.js", - "houseplan-assets/houseplan-editor-runtime-BG2wMJ7n.js", - "houseplan-assets/houseplan-onboarding-runtime-BAx8bJB2.js", - "houseplan-assets/hp-zigbee-topology-overlay-SYVcVGiq.js", - "houseplan-assets/iso-scene-render-CR59iy_N.js", - "houseplan-assets/live-interaction-runtime-C7FQnbBF.js", - "houseplan-assets/pdf-export-FjKO_S28.js", - "houseplan-assets/summary-panel-runtime-loaded-B9-PG-Gw.js" + "houseplan-assets/de-lgvVUcKp.js", + "houseplan-assets/editor-0Mj9gnAf.js", + "houseplan-assets/fr-CHBDMDsG.js", + "houseplan-assets/furniture-plan-art.generated-B9qZ5DM-.js", + "houseplan-assets/houseplan-editor-runtime-DOSm4OKX.js", + "houseplan-assets/houseplan-onboarding-runtime-G7DfDSe_.js", + "houseplan-assets/hp-zigbee-topology-overlay-CAehZ6TG.js", + "houseplan-assets/iso-scene-render-CCwC6ZHk.js", + "houseplan-assets/live-interaction-runtime-DpDkGNJh.js", + "houseplan-assets/pdf-export-B1B1amDF.js", + "houseplan-assets/summary-panel-runtime-loaded-C3VkX0bk.js" ] }, { - "path": "houseplan-assets/houseplan-editor-runtime-BG2wMJ7n.js", - "sha256": "b52c53a198b616ef643aa161da2fcd6f92f8d80c08b1b0ab906f8e8357f2bb9d", - "rawBytes": 689960, - "gzipBytes": 188126, + "path": "houseplan-assets/houseplan-editor-runtime-DOSm4OKX.js", + "sha256": "d9564d0a4326d66d0cac3b24dde8c625d4ff64fdee9eaa5093e776992d41f177", + "rawBytes": 689688, + "gzipBytes": 188131, "isEntry": false, "imports": [ - "houseplan-assets/backdrop-pick-Ev52LRir.js", - "houseplan-assets/form-kit.styles-BQTkV2m1.js", - "houseplan-assets/furniture-plan-art.generated-O7K1vBfu.js", - "houseplan-assets/houseplan-card-BiUNLHFh.js", - "houseplan-assets/zigbee-topology-B31-i8CL.js" + "houseplan-assets/backdrop-pick-ToIYfsVt.js", + "houseplan-assets/form-kit.styles-BSWYQ2Fp.js", + "houseplan-assets/furniture-plan-art.generated-B9qZ5DM-.js", + "houseplan-assets/houseplan-card-W9mG3gab.js", + "houseplan-assets/zigbee-topology-3KJks91U.js" ], "dynamicImports": [ - "houseplan-assets/zigbee-topology-runtime-CuXFHyzq.js" + "houseplan-assets/zigbee-topology-runtime-DvCmPEhl.js" ] }, { - "path": "houseplan-assets/houseplan-onboarding-runtime-BAx8bJB2.js", - "sha256": "c3c0544f9a5ed52b84b238e91afb6a9af0eb4a549fee2b400d8b57250d479888", + "path": "houseplan-assets/houseplan-onboarding-runtime-G7DfDSe_.js", + "sha256": "05d9e7466cb5ffa0763f31a7726fdb8ca986b339e7129cbfeb8d16fca3d895d8", "rawBytes": 28289, - "gzipBytes": 7035, + "gzipBytes": 7038, "isEntry": false, "imports": [ - "houseplan-assets/backdrop-pick-Ev52LRir.js", - "houseplan-assets/houseplan-card-BiUNLHFh.js" + "houseplan-assets/backdrop-pick-ToIYfsVt.js", + "houseplan-assets/houseplan-card-W9mG3gab.js" ], "dynamicImports": [] }, { - "path": "houseplan-assets/hp-zigbee-topology-overlay-SYVcVGiq.js", - "sha256": "337c5b2f969e0f5eea68e9ed35c57ee887b22d1258ee74ea472e0697bf002405", + "path": "houseplan-assets/hp-zigbee-topology-overlay-CAehZ6TG.js", + "sha256": "ccec4f13dadb1057da1bb7118c7af575813d5273c4db6b3c5a18ec8440a25c00", "rawBytes": 10759, - "gzipBytes": 3684, + "gzipBytes": 3687, "isEntry": false, "imports": [ - "houseplan-assets/houseplan-card-BiUNLHFh.js", - "houseplan-assets/zigbee-topology-B31-i8CL.js", - "houseplan-assets/zigbee-topology-runtime-CuXFHyzq.js" + "houseplan-assets/houseplan-card-W9mG3gab.js", + "houseplan-assets/zigbee-topology-3KJks91U.js", + "houseplan-assets/zigbee-topology-runtime-DvCmPEhl.js" ], "dynamicImports": [] }, { - "path": "houseplan-assets/iso-scene-render-CR59iy_N.js", - "sha256": "bf6302158fdd208e01f51d4bca57a6442759477513d3bc0e050217f9fa1e1c04", + "path": "houseplan-assets/iso-scene-render-CCwC6ZHk.js", + "sha256": "8a570b1a301b025da5bc9be1bd4732a747bd5215951931fa7f9fe7acea744b33", "rawBytes": 44439, - "gzipBytes": 15013, + "gzipBytes": 15016, "isEntry": false, "imports": [ - "houseplan-assets/houseplan-card-BiUNLHFh.js" + "houseplan-assets/houseplan-card-W9mG3gab.js" ], "dynamicImports": [] }, { - "path": "houseplan-assets/live-interaction-runtime-C7FQnbBF.js", - "sha256": "0e125dd3cdeefbe4e37ded88c24b200ae1adeefd58e094249b68b0ae0a16bb68", + "path": "houseplan-assets/live-interaction-runtime-DpDkGNJh.js", + "sha256": "621740a374701977939421138d4c4da260c30891d4d5e49e054cfcbb23a68815", "rawBytes": 8216, - "gzipBytes": 3208, + "gzipBytes": 3210, "isEntry": false, "imports": [ - "houseplan-assets/houseplan-card-BiUNLHFh.js" + "houseplan-assets/houseplan-card-W9mG3gab.js" ], "dynamicImports": [] }, { - "path": "houseplan-assets/pdf-export-FjKO_S28.js", - "sha256": "b707974196d7ef9dbb7849dd027ec41ba56dc5e43d53909a734adf61422ff8c9", + "path": "houseplan-assets/pdf-export-B1B1amDF.js", + "sha256": "f8d3a8f8d5a00e07ee20b6f4104a0eb3eec644deb08c2785c5212faacccb132f", "rawBytes": 236247, - "gzipBytes": 109874, + "gzipBytes": 109873, "isEntry": false, "imports": [ - "houseplan-assets/furniture-plan-art.generated-O7K1vBfu.js", - "houseplan-assets/houseplan-card-BiUNLHFh.js" + "houseplan-assets/furniture-plan-art.generated-B9qZ5DM-.js", + "houseplan-assets/houseplan-card-W9mG3gab.js" ], "dynamicImports": [] }, { - "path": "houseplan-assets/summary-panel-editor-ClwrL_O4.js", - "sha256": "dfeac4341c2e3ac1d1b4d4b3b826967e3fab5ddfca8552c786249d05440722d7", + "path": "houseplan-assets/summary-panel-editor-Dq397KvS.js", + "sha256": "7798f08816a813b97c0fcce7a2c67eade8722964a0bb18f936d4aacc4bc2693b", "rawBytes": 14862, - "gzipBytes": 3424, + "gzipBytes": 3427, "isEntry": false, "imports": [ - "houseplan-assets/form-kit.styles-BQTkV2m1.js", - "houseplan-assets/houseplan-card-BiUNLHFh.js", - "houseplan-assets/summary-panel-runtime-loaded-B9-PG-Gw.js" + "houseplan-assets/form-kit.styles-BSWYQ2Fp.js", + "houseplan-assets/houseplan-card-W9mG3gab.js", + "houseplan-assets/summary-panel-runtime-loaded-C3VkX0bk.js" ], "dynamicImports": [] }, { - "path": "houseplan-assets/summary-panel-metrics-BjFIAkz0.js", - "sha256": "1b42c42876dcc1f3bdc74a00c7f2fecc37ef977f68fc38fc2e50b9ae910d892e", + "path": "houseplan-assets/summary-panel-metrics-Kwu_Jan4.js", + "sha256": "cca1e153c9eb77397b874df8c1b6d13eb05846dac1d20840375ec1c6115769cd", "rawBytes": 2611, - "gzipBytes": 1306, + "gzipBytes": 1308, "isEntry": false, "imports": [ - "houseplan-assets/houseplan-card-BiUNLHFh.js" + "houseplan-assets/houseplan-card-W9mG3gab.js" ], "dynamicImports": [] }, { - "path": "houseplan-assets/summary-panel-runtime-loaded-B9-PG-Gw.js", - "sha256": "c768f6cd041edce5ccedfd1bc1bd14ab75a5e69db9b05c3ced5a07a3d504e62b", + "path": "houseplan-assets/summary-panel-runtime-loaded-C3VkX0bk.js", + "sha256": "dca2b7848fe8afae7efad07e18a55652681c4ece3153759671f4495fbb556f47", "rawBytes": 72733, - "gzipBytes": 20175, + "gzipBytes": 20176, "isEntry": false, "imports": [ - "houseplan-assets/form-kit.styles-BQTkV2m1.js", - "houseplan-assets/houseplan-card-BiUNLHFh.js" + "houseplan-assets/form-kit.styles-BSWYQ2Fp.js", + "houseplan-assets/houseplan-card-W9mG3gab.js" ], "dynamicImports": [ - "houseplan-assets/summary-panel-editor-ClwrL_O4.js", - "houseplan-assets/summary-panel-metrics-BjFIAkz0.js" + "houseplan-assets/summary-panel-editor-Dq397KvS.js", + "houseplan-assets/summary-panel-metrics-Kwu_Jan4.js" ] }, { - "path": "houseplan-assets/zigbee-topology-B31-i8CL.js", - "sha256": "0758d5e433d1d0c5a6fea70281a8107f47861b7788a62f6604dc299f005843f4", + "path": "houseplan-assets/zigbee-topology-3KJks91U.js", + "sha256": "2431b5564b832bb307e7bb1fd96fa2fbd4af5790fe2c8218fbd2da566203454a", "rawBytes": 18962, - "gzipBytes": 7426, + "gzipBytes": 7427, "isEntry": false, "imports": [ - "houseplan-assets/houseplan-card-BiUNLHFh.js" + "houseplan-assets/houseplan-card-W9mG3gab.js" ], "dynamicImports": [] }, { - "path": "houseplan-assets/zigbee-topology-runtime-CuXFHyzq.js", - "sha256": "387eeadd92923ba31787102edb4382aa9a3f41fa535208ad22de6d96de945c4c", + "path": "houseplan-assets/zigbee-topology-runtime-DvCmPEhl.js", + "sha256": "1c7c46872e354ce04d529d33dcb929788c9bcad045ac0b787f3da38ffc96a861", "rawBytes": 3942, - "gzipBytes": 1761, + "gzipBytes": 1764, "isEntry": false, "imports": [ - "houseplan-assets/houseplan-card-BiUNLHFh.js", - "houseplan-assets/zigbee-topology-B31-i8CL.js" + "houseplan-assets/houseplan-card-W9mG3gab.js", + "houseplan-assets/zigbee-topology-3KJks91U.js" ], "dynamicImports": [] }, { "path": "houseplan-card.js", - "sha256": "62a1b4e12d0cb9b39367af3a13159d35a6589e5e2045e0c362e44a0a1b2815d5", + "sha256": "5aceb492cf13dcfe40d540a80ed83a334f1373ca33415a350fef7516db21783a", "rawBytes": 1205, "gzipBytes": 803, "isEntry": true, "imports": [ - "houseplan-assets/houseplan-card-BiUNLHFh.js" + "houseplan-assets/houseplan-card-W9mG3gab.js" ], "dynamicImports": [] }, { "path": "houseplan-panel.js", - "sha256": "04e67b0cbcf54b60e8373a2683d1a73f2346aa2655fd2ee2fac2cd225dddc56b", + "sha256": "f4d6406322e54766b3ad98ccca7cc877dd307a9c0f0af849a5d5f8be4ced70a3", "rawBytes": 6165, - "gzipBytes": 2325, + "gzipBytes": 2326, "isEntry": true, "imports": [ - "houseplan-assets/houseplan-card-BiUNLHFh.js" + "houseplan-assets/houseplan-card-W9mG3gab.js" ], "dynamicImports": [] } diff --git a/dist/houseplan-assets/backdrop-pick-Ev52LRir.js b/dist/houseplan-assets/backdrop-pick-ToIYfsVt.js similarity index 93% rename from dist/houseplan-assets/backdrop-pick-Ev52LRir.js rename to dist/houseplan-assets/backdrop-pick-ToIYfsVt.js index 1a51c183..e9ea54a0 100644 --- a/dist/houseplan-assets/backdrop-pick-Ev52LRir.js +++ b/dist/houseplan-assets/backdrop-pick-ToIYfsVt.js @@ -1,6 +1,6 @@ -globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db7c58754eeb4ba03f835b8d7c84c6";import{aA as e,c as t,A as i,aH as o,aI as n,dG as r}from"./houseplan-card-BiUNLHFh.js";function s(e){const t=e.visualViewport;return t&&Number.isFinite(t.width)&&Number.isFinite(t.height)?{left:Number(t.offsetLeft)||0,top:Number(t.offsetTop)||0,width:Math.max(0,Number(t.width)||0),height:Math.max(0,Number(t.height)||0)}:{left:0,top:0,width:e.innerWidth,height:e.innerHeight}}function a(e,t,i,o=7,n=8){const r=i.left+n,s=i.top+n,a=Math.max(r,i.left+i.width-n),l=Math.max(s,i.top+i.height-n),h=Math.max(0,a-r),d=Math.max(0,l-s),c=Math.min(Math.max(0,t.width),h),u=Math.min(Math.max(0,t.height),d);let p=e.left;p+c>a&&(p=e.right-c),p=Math.min(Math.max(r,p),Math.max(r,a-c));const g=e.bottom+o,_=e.top-o-u;let m="bottom",f=g;return g+u>l&&_>=s?(m="top",f=Math.min(Math.max(s,_),Math.max(s,l-u))):f=Math.min(Math.max(s,g),Math.max(s,l-u)),{left:Math.round(p),top:Math.round(f),side:m,maxWidth:Math.round(h),maxHeight:Math.round(d)}}class l{constructor(e,t,i){this.owner=e,this.name=t,this.keydown=i,this.host=null,this.root=null}window(){return this.owner.ownerDocument.defaultView}dialog(){return this.owner.closest("hp-dialog")}usesPopover(e=!1){const t=this.window();return!e&&!!t&&function(e){const t=e.HTMLElement?.prototype;return"function"==typeof t?.showPopover&&"function"==typeof t?.hidePopover}(t)}get hasFallback(){return!!this.host}containsPath(e){return e.includes(this.owner)||!!this.host&&e.includes(this.host)}ownsActiveElement(){let e=this.owner.ownerDocument.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;return!(!e||e!==this.owner&&!this.owner.shadowRoot?.contains(e)&&!this.root?.contains(e))}renderFallback(i,o){const n=this.ensureFallback();return n?(e(t`${i}`,n),n):null}surface(e,t){return t?this.owner.shadowRoot?.querySelector(e)||null:this.root?.querySelector(e)||null}destroy(){this.root&&e(i,this.root),this.host?.remove(),this.host=null,this.root=null}ensureFallback(){if(this.root?.isConnected)return this.root;const e=this.dialog()?.overlayPortal()||this.owner.ownerDocument.body;if(!e)return null;const t=this.owner.ownerDocument.createElement("div");return t.dataset.hpOverlay=this.name,t.style.display="contents",this.keydown&&t.addEventListener("keydown",this.keydown,!0),e.append(t),this.host=t,this.root=t.attachShadow({mode:"open"}),this.root}}let h=0;class d extends n{constructor(){super(...arguments),this.text="",this.ariaLabel="",this.pointerHover=!1,this._open=!1,this._openTimer=0,this._closeTimer=0,this._positionRaf=0,this._forceFallback=!1,this._hoverOwned=!1,this._overlayDispose=null,this._scrollDialog=null,this._descriptionId="hp-help-description-"+ ++h,this._surfacePointerEnter=()=>{const e=this._window();this._closeTimer&&e?.clearTimeout(this._closeTimer),this._closeTimer=0},this._surfacePointerLeave=()=>{this._scheduleClose()},this._outsidePointerDown=e=>{if(!this._open)return;const t=e.composedPath();this._floating.containsPath(t)||this._closeHelp(!1,"outside")},this._dialogScroll=e=>{const t=this._floating.containsPath(e.composedPath()),i=e.target,o=this._dialog(),n=i instanceof Node&&(i===o||i instanceof Element&&i.contains(this));var r;this._open&&(r=n,!t&&r)&&this._closeHelp(!1,"scroll")},this._keyDown=e=>{if(!this._open||e.defaultPrevented)return;if("Escape"===e.key)return e.preventDefault(),e.stopImmediatePropagation(),void this._closeHelp(this._floating.ownsActiveElement(),"escape");const t=this.renderRoot.querySelector(".trigger");if(!t||!e.composedPath().includes(t))return;const i=this._surface();if(!i||i.scrollHeight<=i.clientHeight)return;const o=Math.max(40,.8*i.clientHeight),n={ArrowDown:40,ArrowUp:-40,PageDown:o,PageUp:-o};if("Home"===e.key)i.scrollTop=0;else if("End"===e.key)i.scrollTop=i.scrollHeight;else{if(!(e.key in n))return;i.scrollBy({top:n[e.key],behavior:"auto"})}e.preventDefault(),e.stopImmediatePropagation()},this._floating=new l(this,"help",this._keyDown),this._queuePosition=()=>{if(!this._open||this._positionRaf)return;const e=this._window();e&&(this._positionRaf=e.requestAnimationFrame(()=>{this._positionRaf=0,this._position()||this._closeHelp()}))}}connectedCallback(){super.connectedCallback(),this.addEventListener("keydown",this._keyDown,!0)}willUpdate(){this.toggleAttribute("data-has-content",this._hasContent())}disconnectedCallback(){const e=this.ownerDocument.defaultView;this._unsubscribeOpenListeners(),this.removeEventListener("keydown",this._keyDown,!0),this._clearTimers(),this._positionRaf&&e?.cancelAnimationFrame(this._positionRaf),this._positionRaf=0,this._closeHelp(!1,"disconnect"),super.disconnectedCallback()}updated(e){if(e.has("pointerHover")&&!this.pointerHover){const e=this._window();this._openTimer&&e?.clearTimeout(this._openTimer),this._openTimer=0,this._hoverOwned&&this._closeHelp(!1,"outside")}this._hasContent()||!this._open?this._open&&e.has("text")&&(this._usesPopover()||this._renderFallback(),this._queuePosition()):this._closeHelp()}_window(){return this._floating.window()}_dialog(){return this._floating.dialog()}_usesPopover(){return this._floating.usesPopover(this._forceFallback)}_hasContent(){return e=this.text,t=this.ariaLabel,"string"==typeof e&&e.trim().length>0&&"string"==typeof t&&t.trim().length>0;var e,t}_clearTimers(){const e=this._window();this._openTimer&&e?.clearTimeout(this._openTimer),this._closeTimer&&e?.clearTimeout(this._closeTimer),this._openTimer=0,this._closeTimer=0}_scheduleOpen(){const e=this._window();this.pointerHover&&e&&!this._open&&!this._openTimer&&(this._closeTimer&&e.clearTimeout(this._closeTimer),this._closeTimer=0,this._openTimer=e.setTimeout(()=>{this._openTimer=0,this.isConnected&&(this._hoverOwned=!0,this._openHelp())},300))}_scheduleClose(){const e=this._window(),t=this.renderRoot.querySelector(".trigger");e&&!t?.matches(":focus-visible")&&(this._openTimer&&e.clearTimeout(this._openTimer),this._closeTimer&&e.clearTimeout(this._closeTimer),this._openTimer=0,this._closeTimer=e.setTimeout(()=>{this._closeTimer=0,this.isConnected&&this._closeHelp()},150))}_triggerPointerEnter(e){this.pointerHover&&"mouse"===e.pointerType&&this._scheduleOpen()}_triggerPointerLeave(e){"mouse"===e.pointerType&&this._scheduleClose()}_triggerFocus(){queueMicrotask(()=>{const e=this.renderRoot.querySelector(".trigger");e?.matches(":focus-visible")&&(this._hoverOwned=!1,this._openHelp())})}_triggerBlur(){this._scheduleClose()}_triggerClick(){this._open?this._closeHelp():(this._hoverOwned=!1,this._openHelp())}_subscribeOpenListeners(){this.ownerDocument.addEventListener("pointerdown",this._outsidePointerDown,!0),this.ownerDocument.addEventListener("keydown",this._keyDown,!0);const e=this._window();e?.addEventListener("resize",this._queuePosition),e?.addEventListener("orientationchange",this._queuePosition),e?.visualViewport?.addEventListener("resize",this._queuePosition),e?.visualViewport?.addEventListener("scroll",this._queuePosition),this._scrollDialog=this._dialog(),this._scrollDialog?.addEventListener("scroll",this._dialogScroll,!0)}_unsubscribeOpenListeners(){this.ownerDocument.removeEventListener("pointerdown",this._outsidePointerDown,!0),this.ownerDocument.removeEventListener("keydown",this._keyDown,!0);const e=this._window();e?.removeEventListener("resize",this._queuePosition),e?.removeEventListener("orientationchange",this._queuePosition),e?.visualViewport?.removeEventListener("resize",this._queuePosition),e?.visualViewport?.removeEventListener("scroll",this._queuePosition),this._scrollDialog?.removeEventListener("scroll",this._dialogScroll,!0),this._scrollDialog=null}async _openHelp(){!this._open&&this._hasContent()&&(this._clearTimers(),this._forceFallback=!1,this._open=!0,this._subscribeOpenListeners(),await this.updateComplete,this._open&&(this._usesPopover()||this._renderFallback(),this._position()?this._overlayDispose=this._dialog()?.registerOverlay({owner:this,group:"transient",close:e=>this._closeHelp("escape"===e&&this._floating.ownsActiveElement(),e)})||null:this._closeHelp()))}_closeHelp(e=!1,t="exclusive"){if(!this._open&&!this._floating.hasFallback)return;this._clearTimers();const i=this._overlayDispose;this._overlayDispose=null,i?.();const o=this.renderRoot.querySelector(".tooltip");if(o?.hidePopover)try{o.matches(":popover-open")&&o.hidePopover()}catch{}this._open=!1,this._hoverOwned=!1,this._unsubscribeOpenListeners(),this._floating.destroy(),e&&this.updateComplete.then(()=>this.renderRoot.querySelector(".trigger")?.focus())}_tooltipTemplate(e){return t`
    a&&(p=e.right-d),p=Math.min(Math.max(r,p),Math.max(r,a-d));const g=e.bottom+o,_=e.top-o-u;let m="bottom",f=g;return g+u>l&&_>=s?(m="top",f=Math.min(Math.max(s,_),Math.max(s,l-u))):f=Math.min(Math.max(s,g),Math.max(s,l-u)),{left:Math.round(p),top:Math.round(f),side:m,maxWidth:Math.round(h),maxHeight:Math.round(c)}}class l{constructor(e,t,i){this.owner=e,this.name=t,this.keydown=i,this.host=null,this.root=null}window(){return this.owner.ownerDocument.defaultView}dialog(){return this.owner.closest("hp-dialog")}usesPopover(e=!1){const t=this.window();return!e&&!!t&&function(e){const t=e.HTMLElement?.prototype;return"function"==typeof t?.showPopover&&"function"==typeof t?.hidePopover}(t)}get hasFallback(){return!!this.host}containsPath(e){return e.includes(this.owner)||!!this.host&&e.includes(this.host)}ownsActiveElement(){let e=this.owner.ownerDocument.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;return!(!e||e!==this.owner&&!this.owner.shadowRoot?.contains(e)&&!this.root?.contains(e))}renderFallback(i,o){const n=this.ensureFallback();return n?(e(t`${i}`,n),n):null}surface(e,t){return t?this.owner.shadowRoot?.querySelector(e)||null:this.root?.querySelector(e)||null}destroy(){this.root&&e(i,this.root),this.host?.remove(),this.host=null,this.root=null}ensureFallback(){if(this.root?.isConnected)return this.root;const e=this.dialog()?.overlayPortal()||this.owner.ownerDocument.body;if(!e)return null;const t=this.owner.ownerDocument.createElement("div");return t.dataset.hpOverlay=this.name,t.style.display="contents",this.keydown&&t.addEventListener("keydown",this.keydown,!0),e.append(t),this.host=t,this.root=t.attachShadow({mode:"open"}),this.root}}let h=0;class c extends n{constructor(){super(...arguments),this.text="",this.ariaLabel="",this.pointerHover=!1,this._open=!1,this._openTimer=0,this._closeTimer=0,this._positionRaf=0,this._forceFallback=!1,this._hoverOwned=!1,this._overlayDispose=null,this._scrollDialog=null,this._descriptionId="hp-help-description-"+ ++h,this._surfacePointerEnter=()=>{const e=this._window();this._closeTimer&&e?.clearTimeout(this._closeTimer),this._closeTimer=0},this._surfacePointerLeave=()=>{this._scheduleClose()},this._outsidePointerDown=e=>{if(!this._open)return;const t=e.composedPath();this._floating.containsPath(t)||this._closeHelp(!1,"outside")},this._dialogScroll=e=>{const t=this._floating.containsPath(e.composedPath()),i=e.target,o=this._dialog(),n=i instanceof Node&&(i===o||i instanceof Element&&i.contains(this));var r;this._open&&(r=n,!t&&r)&&this._closeHelp(!1,"scroll")},this._keyDown=e=>{if(!this._open||e.defaultPrevented)return;if("Escape"===e.key)return e.preventDefault(),e.stopImmediatePropagation(),void this._closeHelp(this._floating.ownsActiveElement(),"escape");const t=this.renderRoot.querySelector(".trigger");if(!t||!e.composedPath().includes(t))return;const i=this._surface();if(!i||i.scrollHeight<=i.clientHeight)return;const o=Math.max(40,.8*i.clientHeight),n={ArrowDown:40,ArrowUp:-40,PageDown:o,PageUp:-o};if("Home"===e.key)i.scrollTop=0;else if("End"===e.key)i.scrollTop=i.scrollHeight;else{if(!(e.key in n))return;i.scrollBy({top:n[e.key],behavior:"auto"})}e.preventDefault(),e.stopImmediatePropagation()},this._floating=new l(this,"help",this._keyDown),this._queuePosition=()=>{if(!this._open||this._positionRaf)return;const e=this._window();e&&(this._positionRaf=e.requestAnimationFrame(()=>{this._positionRaf=0,this._position()||this._closeHelp()}))}}connectedCallback(){super.connectedCallback(),this.addEventListener("keydown",this._keyDown,!0)}willUpdate(){this.toggleAttribute("data-has-content",this._hasContent())}disconnectedCallback(){const e=this.ownerDocument.defaultView;this._unsubscribeOpenListeners(),this.removeEventListener("keydown",this._keyDown,!0),this._clearTimers(),this._positionRaf&&e?.cancelAnimationFrame(this._positionRaf),this._positionRaf=0,this._closeHelp(!1,"disconnect"),super.disconnectedCallback()}updated(e){if(e.has("pointerHover")&&!this.pointerHover){const e=this._window();this._openTimer&&e?.clearTimeout(this._openTimer),this._openTimer=0,this._hoverOwned&&this._closeHelp(!1,"outside")}this._hasContent()||!this._open?this._open&&e.has("text")&&(this._usesPopover()||this._renderFallback(),this._queuePosition()):this._closeHelp()}_window(){return this._floating.window()}_dialog(){return this._floating.dialog()}_usesPopover(){return this._floating.usesPopover(this._forceFallback)}_hasContent(){return e=this.text,t=this.ariaLabel,"string"==typeof e&&e.trim().length>0&&"string"==typeof t&&t.trim().length>0;var e,t}_clearTimers(){const e=this._window();this._openTimer&&e?.clearTimeout(this._openTimer),this._closeTimer&&e?.clearTimeout(this._closeTimer),this._openTimer=0,this._closeTimer=0}_scheduleOpen(){const e=this._window();this.pointerHover&&e&&!this._open&&!this._openTimer&&(this._closeTimer&&e.clearTimeout(this._closeTimer),this._closeTimer=0,this._openTimer=e.setTimeout(()=>{this._openTimer=0,this.isConnected&&(this._hoverOwned=!0,this._openHelp())},300))}_scheduleClose(){const e=this._window(),t=this.renderRoot.querySelector(".trigger");e&&!t?.matches(":focus-visible")&&(this._openTimer&&e.clearTimeout(this._openTimer),this._closeTimer&&e.clearTimeout(this._closeTimer),this._openTimer=0,this._closeTimer=e.setTimeout(()=>{this._closeTimer=0,this.isConnected&&this._closeHelp()},150))}_triggerPointerEnter(e){this.pointerHover&&"mouse"===e.pointerType&&this._scheduleOpen()}_triggerPointerLeave(e){"mouse"===e.pointerType&&this._scheduleClose()}_triggerFocus(){queueMicrotask(()=>{const e=this.renderRoot.querySelector(".trigger");e?.matches(":focus-visible")&&(this._hoverOwned=!1,this._openHelp())})}_triggerBlur(){this._scheduleClose()}_triggerClick(){this._open?this._closeHelp():(this._hoverOwned=!1,this._openHelp())}_subscribeOpenListeners(){this.ownerDocument.addEventListener("pointerdown",this._outsidePointerDown,!0),this.ownerDocument.addEventListener("keydown",this._keyDown,!0);const e=this._window();e?.addEventListener("resize",this._queuePosition),e?.addEventListener("orientationchange",this._queuePosition),e?.visualViewport?.addEventListener("resize",this._queuePosition),e?.visualViewport?.addEventListener("scroll",this._queuePosition),this._scrollDialog=this._dialog(),this._scrollDialog?.addEventListener("scroll",this._dialogScroll,!0)}_unsubscribeOpenListeners(){this.ownerDocument.removeEventListener("pointerdown",this._outsidePointerDown,!0),this.ownerDocument.removeEventListener("keydown",this._keyDown,!0);const e=this._window();e?.removeEventListener("resize",this._queuePosition),e?.removeEventListener("orientationchange",this._queuePosition),e?.visualViewport?.removeEventListener("resize",this._queuePosition),e?.visualViewport?.removeEventListener("scroll",this._queuePosition),this._scrollDialog?.removeEventListener("scroll",this._dialogScroll,!0),this._scrollDialog=null}async _openHelp(){!this._open&&this._hasContent()&&(this._clearTimers(),this._forceFallback=!1,this._open=!0,this._subscribeOpenListeners(),await this.updateComplete,this._open&&(this._usesPopover()||this._renderFallback(),this._position()?this._overlayDispose=this._dialog()?.registerOverlay({owner:this,group:"transient",close:e=>this._closeHelp("escape"===e&&this._floating.ownsActiveElement(),e)})||null:this._closeHelp()))}_closeHelp(e=!1,t="exclusive"){if(!this._open&&!this._floating.hasFallback)return;this._clearTimers();const i=this._overlayDispose;this._overlayDispose=null,i?.();const o=this.renderRoot.querySelector(".tooltip");if(o?.hidePopover)try{o.matches(":popover-open")&&o.hidePopover()}catch{}this._open=!1,this._hoverOwned=!1,this._unsubscribeOpenListeners(),this._floating.destroy(),e&&this.updateComplete.then(()=>this.renderRoot.querySelector(".trigger")?.focus())}_tooltipTemplate(e){return t``}_renderFallback(){const e=d.styles.cssText;this._floating.renderFallback(this._tooltipTemplate(!1),e)}_surface(){return this._floating.surface(".tooltip",this._usesPopover())}_position(){if(!this._open)return!1;const e=this._window(),t=this.renderRoot.querySelector(".trigger");let i=this._surface();if(!e||!t?.isConnected||!i?.isConnected)return!1;const o=s(e);if(i.style.maxWidth=`${Math.max(0,Math.min(320,o.width-16))}px`,i.style.maxHeight=`${Math.max(0,o.height-16)}px`,i.style.visibility="hidden",this._usesPopover()&&i.showPopover)try{i.matches(":popover-open")||i.showPopover()}catch{if(this._forceFallback=!0,this._renderFallback(),i=this._surface(),!i?.isConnected)return!1;i.style.visibility="hidden"}const n=t.getBoundingClientRect(),r=i.getBoundingClientRect();if(!(n.width&&n.height&&r.width&&r.height))return!1;const l=a(n,r,o);return i.style.left=`${l.left}px`,i.style.top=`${l.top}px`,i.dataset.side=l.side,i.style.visibility="",!0}render(){if(!this._hasContent())return i;const e=this.ariaLabel.trim();return t` + @pointerenter=${this._surfacePointerEnter} @pointerleave=${this._surfacePointerLeave}>${this.text}
    `}_renderFallback(){const e=c.styles.cssText;this._floating.renderFallback(this._tooltipTemplate(!1),e)}_surface(){return this._floating.surface(".tooltip",this._usesPopover())}_position(){if(!this._open)return!1;const e=this._window(),t=this.renderRoot.querySelector(".trigger");let i=this._surface();if(!e||!t?.isConnected||!i?.isConnected)return!1;const o=s(e);if(i.style.maxWidth=`${Math.max(0,Math.min(320,o.width-16))}px`,i.style.maxHeight=`${Math.max(0,o.height-16)}px`,i.style.visibility="hidden",this._usesPopover()&&i.showPopover)try{i.matches(":popover-open")||i.showPopover()}catch{if(this._forceFallback=!0,this._renderFallback(),i=this._surface(),!i?.isConnected)return!1;i.style.visibility="hidden"}const n=t.getBoundingClientRect(),r=i.getBoundingClientRect();if(!(n.width&&n.height&&r.width&&r.height))return!1;const l=a(n,r,o);return i.style.left=`${l.left}px`,i.style.top=`${l.top}px`,i.dataset.side=l.side,i.style.visibility="",!0}render(){if(!this._hasContent())return i;const e=this.ariaLabel.trim();return t` ${this.text} `:G} - `}}_g.properties={hass:{attribute:!1},_config:{state:!0},_snap:{state:!0},_continuityEpoch:{state:!0}},_g.styles=[ap,o`.hp-static-title{font-weight:700;padding:10px 14px 6px;font-size:16px;color:var(--primary-text-color);}.hp-static-body{position:relative;}.hp-static-stage{position:relative;width:100%;container-type:inline-size;overflow:hidden;pointer-events:none;background:var(--ha-card-background,var(--card-background-color,#111));}.hp-static-stage>svg{position:absolute;inset:0;width:100%;height:100%;display:block;z-index:1;}.hp-static-stage>.hp-paper-outline-svg{z-index:0;overflow:visible;}.hp-paper{fill:var(--ha-card-background,var(--card-background-color,#111));stroke:none;}.wallbody-fill{fill:var(--wall-fill,#ffffff);fill-opacity:var(--wall-fill-op,1);fill-rule:evenodd;stroke:none;pointer-events:none;}.wallbody{fill:url(#hp-wall-hatch);fill-rule:evenodd;stroke:var(--room-stroke,var(--hp-muted,#607d8b));stroke-width:calc(0.6px * var(--hp-cell-visual-scale,1));pointer-events:none;}.wallbody.solid{fill:none;}.hp-static-stage .devlayer{position:absolute;inset:0;z-index:2;}.hp-static-foot{padding:8px 12px 12px;pointer-events:auto;}.hp-static-btn{width:100%;padding:9px 14px;border:none;border-radius:10px;background:var(--primary-color,#3ea6ff);color:var(--text-primary-color,#fff);font-size:14px;font-weight:600;cursor:pointer;}:host([data-pointer-hover]) .hp-static-btn:hover{filter:brightness(1.08);}.hp-static-error{padding:24px;text-align:center;color:var(--secondary-text-color,#9aa4ad);}`],customElements.get("houseplan-space-card")||customElements.define("houseplan-space-card",_g),window.customCards=window.customCards||[],window.customCards.find(e=>"houseplan-space-card"===e.type)||window.customCards.push({type:"houseplan-space-card",name:"House Plan — Space (static)",description:"Read-only live schematic of a single houseplan space, with a deep-link button.",preview:!1,documentation:"https://github.com/Matysh/houseplan-card"});const mg=o`:host{--hp-editor-tray-bg-fallback:color-mix(in srgb,var(--card-background-color,var(--hp-bg)) 94%,var(--hp-line));--hp-editor-tray-bg:color-mix(in srgb,var(--card-background-color,var(--hp-bg)) 86%,transparent);--hp-editor-tray-border:color-mix(in srgb,var(--hp-line) 82%,var(--hp-accent));--hp-editor-tray-blur:8px;--hp-editor-tray-shadow:var(--shadow-2);}.editor-secondary-host{position:absolute;inset:var(--sp-2) var(--sp-4) auto;z-index:70;display:flex;justify-content:flex-end;pointer-events:none;}.editor-secondary-host.kind-palette,.editor-secondary-host.kind-group{justify-content:flex-start;}.editor-secondary{pointer-events:none;max-width:100%;display:flex;align-items:center;gap:var(--sp-3);padding:var(--sp-3) var(--sp-4);color:var(--hp-txt);background:var(--card-background-color,var(--hp-bg));background:var(--hp-editor-tray-bg-fallback);border:1px solid var(--hp-line);border-color:var(--hp-editor-tray-border);border-radius:var(--rad-l);box-shadow:var(--hp-editor-tray-shadow);opacity:0;visibility:hidden;transform:translateY(-4px);transition:opacity 0.1s ease,transform 0.1s cubic-bezier(0.2,0.7,0.2,1),visibility 0s linear 0.1s;touch-action:auto;}.editor-secondary-host.open .editor-secondary{pointer-events:auto;opacity:1;visibility:visible;transform:translateY(0);transition-duration:0.14s,0.14s,0s;transition-delay:0s;}.editor-secondary-host.blocked .editor-secondary{pointer-events:none;}@supports ((backdrop-filter:blur(1px)) or (-webkit-backdrop-filter:blur(1px))){.editor-secondary{background:var(--hp-editor-tray-bg);-webkit-backdrop-filter:blur(var(--hp-editor-tray-blur));backdrop-filter:blur(var(--hp-editor-tray-blur));}}.editor-secondary-content,.editor-group-items{display:flex;align-items:center;gap:var(--sp-3);min-width:0;}.editor-context-label{max-width:14rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding-inline-end:var(--sp-4);border-inline-end:1px solid var(--hp-line);color:var(--hp-muted);font-size:var(--fs-s);}.editor-secondary.kind-palette{width:min(760px,100%);align-items:stretch;padding:0;overflow:hidden;}.editor-secondary.kind-palette .editor-secondary-content,.editor-secondary.kind-palette .furnpalette{width:100%;}.editor-secondary.kind-palette .furnpalette{max-height:38vh;border:0;background:transparent;}.editor-group-launcher .group-chevron{--mdc-icon-size:16px;transition:transform 0.14s ease;}.editor-group-launcher[aria-expanded="true"] .group-chevron{transform:rotate(180deg);}.editor-secondary .bdhint{font-size:var(--fs-s);color:var(--hp-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}.editor-secondary .dfill{display:inline-flex;align-items:center;gap:var(--sp-2);font-size:var(--fs-s);cursor:pointer;}.editor-secondary .dfill input[type="checkbox"]{width:16px;height:16px;flex:none;margin:0;padding:0;}.editor-secondary hp-color-opacity{flex:0 0 auto;}.editor-secondary input{width:74px;background:transparent;border:1px solid var(--hp-line);color:var(--hp-txt);border-radius:var(--rad-s);padding:var(--sp-3) var(--sp-4);font-size:var(--fs-m);}.editor-secondary label,.editor-secondary .hint{color:var(--hp-muted);font-size:var(--fs-s);}.editor-secondary .drawwall{display:inline-flex;align-items:center;gap:var(--sp-3);white-space:nowrap;}.editor-secondary .drawwall input{width:4.2em;}.editor-secondary .drawwall .opl{color:var(--hp-muted);font-size:var(--fs-s);}@container (min-width:560px) and (max-width:899px){.editor-secondary-content,.editor-group-items{flex-wrap:wrap;justify-content:flex-end;}}@container (max-width:559px){.editor-secondary-host{inset-inline:var(--sp-4);}.editor-secondary{max-width:100%;}.editor-secondary-content,.editor-group-items{overflow-x:auto;scrollbar-width:thin;}.editor-secondary-content>*,.editor-group-items>*{flex:none;}.editor-context-label{display:none;}}@media (prefers-reduced-motion:reduce){.editor-secondary{transition:none;}.editor-group-launcher .group-chevron{transition:none;}}`;class gg{constructor(e=50){this._undo=[],this._redo=[],this._limit=Math.max(30,Math.floor(e))}get canUndo(){return this._undo.length>0}get canRedo(){return this._redo.length>0}get undoName(){return this._undo[this._undo.length-1]?.name??null}get redoName(){return this._redo[this._redo.length-1]?.name??null}get size(){return this._undo.length}push(e){this._undo.push(e),this._undo.length>this._limit&&this._undo.splice(0,this._undo.length-this._limit),this._redo=[]}undo(){const e=this._undo.pop()??null;return e&&this._redo.push(e),e}redo(){const e=this._redo.pop()??null;return e&&this._undo.push(e),e}removeWhere(e){const t=this._undo.length,i=this._redo.length;return this._undo=this._undo.filter(t=>!e(t)),this._redo=this._redo.filter(t=>!e(t)),t+i-this._undo.length-this._redo.length}clear(){this._undo=[],this._redo=[]}}function fg(e,t){const i=e[t];return i&&Number.isFinite(i.x)&&Number.isFinite(i.y)?{x:i.x,y:i.y,..."string"==typeof i.s?{s:i.s}:{}}:null}function vg(e,t,i){if(null===i){if(!(t in e))return e;const i={...e};return delete i[t],i}const n={...e[t]||{}};delete n.x,delete n.y,delete n.s;const r={...n,x:i.x,y:i.y,...void 0!==i.s?{s:i.s}:{}};return{...e,[t]:r}}const yg="houseplan-card:version-reload-target:v1";function bg(e){if("string"!=typeof e)return null;return e.trim()||null}class wg{constructor(e){this.hooks=e,this._input={frontendVersion:null,backendVersion:null,kiosk:!1,reducedMotion:!1},this._relation={kind:"unknown"},this._banner=null,this._connected=!1,this._attemptTarget=null,this._attemptState=null,this._noticeToken=0}get relation(){return this._relation}get banner(){return this._banner}get hasCurrentMismatchNotice(){return"mismatch"===this._relation.kind&&"visible"===this._banner?.phase}connect(){this._connected||(this._connected=!0,this._attemptTarget=null,this._attemptState=null,this._reconcile())}disconnect(){(this._connected||this._banner)&&(this._connected=!1,this._cancelTimer(),this._banner&&(this._banner=null,this.hooks.changed()))}update(e){const t={frontendVersion:bg(e.frontendVersion),backendVersion:bg(e.backendVersion),kiosk:!0===e.kiosk,reducedMotion:!0===e.reducedMotion},i=function(e,t){const i=bg(e),n=bg(t);return i&&n?i===n?{kind:"equal",frontend:i,backend:n}:{kind:"mismatch",frontend:i,backend:n}:{kind:"unknown"}}(t.frontendVersion,t.backendVersion),n=!((e,t)=>e.frontendVersion===t.frontendVersion&&e.backendVersion===t.backendVersion&&e.kiosk===t.kiosk&&e.reducedMotion===t.reducedMotion)(this._input,t)||!((e,t)=>e.kind===t.kind&&("unknown"===e.kind||"unknown"!==t.kind&&e.frontend===t.frontend&&e.backend===t.backend))(this._relation,i);this._input=t,this._relation=i,n&&this._reconcile()}finishBannerExit(e){this._banner&&"leaving"===this._banner.phase&&this._banner.token===e&&(this._banner=null,this.hooks.changed())}_reconcile(){if(this._cancelTimer(),!this._connected||"mismatch"!==this._relation.kind)return this._attemptTarget=null,this._attemptState=null,void this._hideBanner();if(!this._input.kiosk)return this._attemptTarget=null,this._attemptState=null,void this._showBanner(this._relation.frontend,this._relation.backend);const e=this._relation.backend;if(this._attemptTarget===e&&null!==this._attemptState||(this._attemptTarget=e,this._attemptState=function(e,t){try{const i=e();return i?i.getItem(yg)===t?"attempted":"fresh":"unavailable"}catch{return"unavailable"}}(this.hooks.storage,e)),"fresh"===this._attemptState)return this._hideBanner(),void this._armTimer();this._showBanner(this._relation.frontend,e)}_armTimer(){this._connected&&void 0===this._timer&&"mismatch"===this._relation.kind&&this._input.kiosk&&"fresh"===this._attemptState&&(this._timer=this.hooks.clock.setTimeout(()=>{this._timer=void 0,this._tick()},250))}_cancelTimer(){void 0!==this._timer&&(this.hooks.clock.clearTimeout(this._timer),this._timer=void 0)}_tick(){if(!this._connected||"mismatch"!==this._relation.kind||!this._input.kiosk||"fresh"!==this._attemptState)return;if(!function(e){return e.connected&&e.initialFrameSettled&&e.viewOnly&&e.surfacesIdle&&e.configWritesIdle&&e.physicalWritesIdle&&e.layoutWritesIdle&&e.gesturesIdle&&e.interactionPauseElapsed&&e.baseZoom}(this.hooks.safety()))return void this._armTimer();const e=this._relation.backend,t=function(e,t){try{const i=e();return i?i.getItem(yg)===t?"attempted":(i.setItem(yg,t),"claimed"):"unavailable"}catch{return"unavailable"}}(this.hooks.storage,e);if(this._attemptTarget=e,this._attemptState="claimed"===t?"attempted":t,"claimed"===t){this._showBanner(this._relation.frontend,e);try{this.hooks.reload()}catch{}}else this._showBanner(this._relation.frontend,e)}_showBanner(e,t){"visible"===this._banner?.phase&&this._banner.frontend===e&&this._banner.backend===t||(this._banner={frontend:e,backend:t,phase:"visible",token:++this._noticeToken},this.hooks.changed())}_hideBanner(){if(this._banner)return this._input.reducedMotion?(this._banner=null,void this.hooks.changed()):void("leaving"!==this._banner.phase&&(this._banner={...this._banner,phase:"leaving",token:++this._noticeToken},this.hooks.changed()))}}const kg=1;function xg(e,t){const i=t&&"object"==typeof t?t:{};e._haIntegrationVersion=bg(i.integration_version);const n=i.support_api;e._haSupportApi="number"==typeof n&&Number.isSafeInteger(n)?n:null,e._haDecorAssetsApi=1===i.decor_assets_api?1:null,e._haSummaryPanelApi=1===i.summary_panel_api?1:null,e._haRadarStage1Api=1===i.radar_stage1_api?1:null,e._syncVersionRecovery()}function Sg(e){const t=e._stageEl,i=e._loadOk&&!e._loading&&e._continuityDataReady&&!e._resumeSettling&&!e._connectionWasLost&&!e._booting&&!e._bootFading&&!e._bootSettling&&!e._bootSoft&&e._continuity.hasCompleteFrame&&"steady"===e._continuity.state&&!e._continuity.overlayBlocksInteraction&&!!t&&t.clientWidth>0&&t.clientHeight>0,n=!(0!==e._pointers.size||0!==e._touchContacts.size||e._touchSequenceMultitouch||e._roomPointer||e._panStart||e._panLock||e._pinchStart||e._swipeStart||e._tabDrag||e._tabDragRelease||e._drag||e._deviceDrag||e._rlResize||e._resize?.dragging||e._physicalDrag||e._physicalRotate||e._opDrag||e._decorDraft||e._decorMove||e._dtDrag||e._bdDrag||e._furnTouchPending||e._compassDrag||e._viewportGestureDirty||e._devicePositionBusy||e._modeTransitionBusy||e._cameraTransition.active||e._slide||0!==e._warmModeRequest),r=!(e._editorSecondaryDialogBlocked||e._partitionDeleteDialog||e._roomDeleteDialog||e._backdropGuard||e._vacFit||e._editorSecondary?.hasOpenGroup||e._furnPalette||e._decorImagePalette);return{connected:e.isConnected,initialFrameSettled:i,viewOnly:!0===e._config?.kiosk&&"view"===e._mode&&!e._editing,surfacesIdle:r,configWritesIdle:0===e._writesPending&&!e._saveConfigDebounced.pending(),physicalWritesIdle:0===e._pendingPhysicalWrites.size,layoutWritesIdle:!e._persistLayout.pending()&&0===e._dirtyPos.size&&0===e._sentPos.size&&!e._devicePositionBusy,gesturesIdle:n,interactionPauseElapsed:Date.now()>=e._cyclePausedUntil,baseZoom:e._zoom<=1.001}}class $g{constructor(){this.seen=null,this.diagnosticsCache=null}observe(e,t,i,n){this.invalidateDiagnosticsForHass(e,t,i),this.intake(t,n)}intake(e,t){e&&this.seen!==e&&(this.seen=e,t())}invalidate(){this.diagnosticsCache=null}invalidateDiagnosticsForHass(e,t,i){this.diagnosticsCache&&(e?.entities!==t?.entities||e?.devices!==t?.devices||[...i?.entityIds||[]].some(i=>!!e?.states?.[i]!=!!t?.states?.[i]))&&this.invalidate()}diagnostics(e,t,i){if(this.diagnosticsCache)return this.diagnosticsCache;const n={active:0,ha_disabled:0,orphaned:0,unverified:0};for(const e of t)e.removed||"virtual"===e.binding||n[i(e.binding).kind]++;return this.diagnosticsCache={registry:ud(e),bindings:n},this.diagnosticsCache}}function Mg(e){const t=e;t._hassSequence++,t._renderSnapshotAt=Date.now(),t._continuity.note("hass-snapshot"),t._ensureHaRegistryAuthority(),t._planHassMemo=null,t._hookConnection(),!t._loadOk&&!t._loading&&t._loadTries<8&&t._loadFromServer(),t._maybeRebuildDevices(),t._vacTick(),t._activityTick()}function Rg(e){return!!e&&"object"==typeof e&&1===e.version}function Cg(e,t){const i=e.radar;return e.space===t&&!0!==e.hidden&&!0!==e.removed&&Rg(i)&&!0===i.enabled&&!1!==i.show_live}const Tg={ok:"radar.health_ok",off:"radar.health_off",stale:"radar.health_stale",partial:"radar.health_partial",restricted:"radar.health_restricted",incomplete:"radar.health_incomplete",position_unavailable:"radar.health_position_unavailable",unavailable:"radar.health_unavailable",needs_setup:"radar.health_needs_setup",inconsistent:"radar.health_inconsistent",unknown:"radar.health_unknown"};const Dg=e=>"number"==typeof e&&Number.isFinite(e);class Ag{constructor(e){this.host=e,this.frames=new Map,this.connection=null,this.space="",this.generation=0,this.expiryTimer=0,this.deadlines=new Map}sync(e,t){const i=this.host.hass?.connection;if(!t||!i||!this.host.isConnected)return void this.stop();if(this.unsubscribe&&this.connection===i&&this.space===e)return;this.stop(),this.connection=i,this.space=e;const n=++this.generation,r=i.subscribeMessage?.bind(i);"function"==typeof r&&Promise.resolve(r(e=>{if(n!==this.generation||!this.host.isConnected)return;const t=function(e){if(!e||"object"!=typeof e)return null;const t=e;if("string"!=typeof t.marker_id||"string"!=typeof t.server_session_id||!Number.isSafeInteger(t.seq)||"string"!=typeof t.health)return null;const i=Array.isArray(t.targets)?t.targets.slice(0,256).flatMap(e=>{if(!e||"object"!=typeof e)return[];const t=e;return"string"==typeof t.slot&&Dg(t.x)&&Dg(t.y)&&Dg(t.expires_at)&&Dg(t.reported_at)&&("bounded_latest"===t.pair_quality||"coherent"===t.pair_quality)?[{...t,included:!0===t.included,smooth:!0===t.smooth}]:[]}):[],n=Array.isArray(t.ranges)?t.ranges.slice(0,64).flatMap(e=>{if(!e||"object"!=typeof e)return[];const t=e;if(!("string"==typeof t.id&&Dg(t.x)&&Dg(t.y)&&Dg(t.radius)&&Dg(t.expires_at)&&Dg(t.reported_at)))return[];const i=Array.isArray(t.segments)?t.segments.slice(0,64).flatMap(e=>{if(!Array.isArray(e))return[];const t=e.slice(0,181).flatMap(e=>Array.isArray(e)&&2===e.length&&Dg(e[0])&&Dg(e[1])?[[e[0],e[1]]]:[]);return t.length>=2?[t]:[]}):void 0;return[{...t,...i?{segments:i}:{}}]}):[],r=Array.isArray(t.zones)?t.zones.slice(0,64).flatMap(e=>{if(!e||"object"!=typeof e)return[];const t=e;if("string"!=typeof t.id)return[];const i=t.state;if(null!==i&&"boolean"!=typeof i&&!Dg(i))return[];const n=Array.isArray(t.polygon)?t.polygon.slice(0,64).flatMap(e=>Array.isArray(e)&&2===e.length&&Dg(e[0])&&Dg(e[1])?[[e[0],e[1]]]:[]):[];return[{id:t.id,state:i,...n.length>=3?{polygon:n}:{}}]}):[];return{server_session_id:t.server_session_id,marker_id:t.marker_id,source_generation:"string"==typeof t.source_generation?t.source_generation:void 0,calibration_revision:"string"==typeof t.calibration_revision?t.calibration_revision:void 0,seq:t.seq,reported_at:Dg(t.reported_at)?t.reported_at:void 0,expires_at:Dg(t.expires_at)?t.expires_at:void 0,health:t.health,reported_presence:"boolean"==typeof t.reported_presence?t.reported_presence:null,complete:!0===t.complete,targets:i,ranges:n,zones:r}}(e);if(!t)return;if(!function(e,t){return!e||t.server_session_id!==e.server_session_id||t.source_generation!==e.source_generation||t.calibration_revision!==e.calibration_revision||t.seq>e.seq}(this.frames.get(t.marker_id),t))return;const i=function(e,t=Date.now()){if(!Dg(e.expires_at))return null;if(!Dg(e.reported_at))return Math.max(0,1e3*e.expires_at-t);const i=Math.max(0,1e3*(e.expires_at-e.reported_at)),n=Math.max(0,t-1e3*e.reported_at);return Math.max(0,i-n)}(t);"restricted"===t.health||"disabled"===t.health||0===i?(this.frames.delete(t.marker_id),this.deadlines.delete(t.marker_id)):(this.frames.set(t.marker_id,t),null==i?this.deadlines.delete(t.marker_id):this.deadlines.set(t.marker_id,this.monotonicNow()+i)),this.armExpiry(),this.host.requestUpdate()},{type:"houseplan/radar/subscribe",space_id:e})).then(e=>{n===this.generation&&this.host.isConnected?"function"==typeof e&&(this.unsubscribe=e):"function"==typeof e&&e()}).catch(()=>{n===this.generation&&this.stop()})}stop(){this.generation++,this.unsubscribe?.(),this.unsubscribe=void 0,this.connection=null,this.space="",clearTimeout(this.expiryTimer),this.expiryTimer=0,this.frames.size&&(this.frames.clear(),this.host.isConnected&&this.host.requestUpdate()),this.deadlines.clear()}armExpiry(){clearTimeout(this.expiryTimer);const e=this.monotonicNow(),t=[...this.deadlines.values()].filter(t=>t>e);if(!t.length)return;const i=Math.max(20,Math.min(...t)-e+10);this.expiryTimer=window.setTimeout(()=>{this.expiryTimer=0;let e=!1;const t=this.monotonicNow();for(const[i,n]of this.deadlines)n>t||(this.deadlines.delete(i),this.frames.delete(i),e=!0);this.armExpiry(),e&&this.host.isConnected&&this.host.requestUpdate()},i)}monotonicNow(){return globalThis.performance?.now?.()??Date.now()}}const Pg=Object.freeze({enabled:!1,z2mBaseTopics:Object.freeze([])});function Fg(e){if("string"!=typeof e)return null;const t=e.trim().replace(/^\/+|\/+$/g,"").replace(/\/{2,}/g,"/");return!t||t.length>180||/[#+\u0000-\u001f\u007f]/.test(t)?null:t}function zg(e){const t=e?.zigbee_topology;if(!t||"object"!=typeof t)return Pg;const i=t,n=Array.isArray(i.z2m_base_topics)?i.z2m_base_topics:Array.isArray(i.z2mBaseTopics)?i.z2mBaseTopics:[],r=new Set,o=[];for(const e of n){const t=Fg(e);if(t&&!r.has(t)&&(r.add(t),o.push(t),8===o.length))break}return{enabled:!0===i.enabled,z2mBaseTopics:o}}function Ig(e,t){const i={...e},n=t.z2mBaseTopics.map(Fg).filter(Boolean);return t.enabled||n.length?i.zigbee_topology={enabled:!0===t.enabled,z2m_base_topics:[...new Set(n)].slice(0,8)}:delete i.zigbee_topology,i}const Og={now:()=>performance.now(),requestFrame:e=>requestAnimationFrame(e),cancelFrame:e=>cancelAnimationFrame(e)},Eg=e=>Math.max(0,Math.min(1,e)),Ng=(e,t,i)=>e+(t-e)*i,Hg=(e,t,i)=>{const n=1-e;return 3*n*n*e*t+3*n*e*e*i+e*e*e},Lg=e=>{const t=Eg(e);if(0===t||1===t)return t;let i=0,n=1,r=t;for(let e=0;e<12;e++)r=(i+n)/2,Hg(r,.2,.2)0&&e.w>0?t/e.w:1,viewBox:{...e}}}function qg(e,t,i){const n=Math.max(1e-9,e.pixelsPerUnit),r=Math.max(1e-9,t/n),o=Math.max(1e-9,i/n);return{x:e.centerX-r/2,y:e.centerY-o/2,w:r,h:o}}function jg(e){const t=e.trim(),i=/^rgba?\(\s*([\d.]+)[, ]+([\d.]+)[, ]+([\d.]+)(?:\s*[,/]\s*([\d.]+))?\s*\)$/i.exec(t);if(i)return[Number(i[1]),Number(i[2]),Number(i[3]),null==i[4]?1:Number(i[4])];const n=/^#([0-9a-f]{6}|[0-9a-f]{8})$/i.exec(t)?.[1];return n?[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16),8===n.length?parseInt(n.slice(6,8),16)/255:1]:null}function Wg(e,t,i){const n=jg(e),r=jg(t);if(!n||!r)return i<.5?e:t;const o=Eg(i);return`rgba(${Math.round(Ng(n[0],r[0],o))}, ${Math.round(Ng(n[1],r[1],o))}, ${Math.round(Ng(n[2],r[2],o))}, ${Ng(n[3],r[3],o).toFixed(3)})`}class Ug{constructor(e,t=Og){this._hooks=e,this._clock=t,this._token=0,this._raf=0,this._state=null}get state(){return this._state}get active(){return"running"===this._state?.phase||"preparing"===this._state?.phase}get presented(){return this._state?.presented||null}start(e,t,i,n=220){this.cancel(!1);const r=++this._token,o=this._clock.now();if(this._state={token:r,phase:n<=0?"settling":"running",from:e,to:t,presented:n<=0?t:e,startedAt:o,duration:Math.max(0,n),targetMode:i},n<=0)return this._hooks.frame(this._state),this._hooks.settled(this._state),this._state=null,r;this._hooks.frame(this._state);const s=e=>{const t=this._state;if(!t||t.token!==r)return;const i=Eg((e-t.startedAt)/t.duration);t.presented=i>=1?t.to:function(e,t,i){const n=Lg(i),r=Ng(e.stageWidth,t.stageWidth,n),o=Ng(e.stageHeight,t.stageHeight,n),s=Math.max(1e-9,e.viewport.pixelsPerUnit),a=Math.max(1e-9,t.viewport.pixelsPerUnit),l={centerX:Ng(e.viewport.centerX,t.viewport.centerX,n),centerY:Ng(e.viewport.centerY,t.viewport.centerY,n),pixelsPerUnit:Math.exp(Ng(Math.log(s),Math.log(a),n))};return{presentedMode:n<.5?e.presentedMode:t.presentedMode,editorChromeHeight:Ng(e.editorChromeHeight,t.editorChromeHeight,n),stageWidth:r,stageHeight:o,viewport:{...l,viewBox:qg(l,r,o)},stageColor:Wg(e.stageColor,t.stageColor,n),paperColor:Wg(e.paperColor,t.paperColor,n),sceneBrightness:Ng(e.sceneBrightness,t.sceneBrightness,n),architectureOpacity:Ng(e.architectureOpacity,t.architectureOpacity,n),backdropOpacity:Ng(e.backdropOpacity,t.backdropOpacity,n),viewWeight:Ng(e.viewWeight,t.viewWeight,n),editorWeight:Ng(e.editorWeight,t.editorWeight,n),toolbarContentOpacity:Ng(e.toolbarContentOpacity,t.toolbarContentOpacity,n)}}(t.from,t.to,i),t.phase=i>=1?"settling":"running",this._hooks.frame(t),i<1?this._raf=this._clock.requestFrame(s):(this._raf=0,this._hooks.settled(t),this._state?.token===r&&(this._state=null))};return this._raf=this._clock.requestFrame(s),r}cancel(e=!0){this._raf&&this._clock.cancelFrame(this._raf),this._raf=0;const t=this._state;this._state=null,this._token++,t&&e&&(t.phase="settling",t.presented=t.to,this._hooks.frame(t),this._hooks.settled(t))}dispose(){this.cancel(!1)}}const Gg={now:()=>"undefined"!=typeof performance?performance.now():Date.now(),requestFrame:e=>"function"==typeof requestAnimationFrame?requestAnimationFrame(e):null,cancelFrame:e=>{"function"==typeof cancelAnimationFrame&&cancelAnimationFrame(e)}},Vg=e=>Number.isFinite(e);function Kg(e){return!!e&&Vg(e.zoom)&&e.zoom>0&&Vg(e.viewBox.x)&&Vg(e.viewBox.y)&&Vg(e.viewBox.w)&&e.viewBox.w>0&&Vg(e.viewBox.h)&&e.viewBox.h>0}function Yg(e){return{zoom:e.zoom,viewBox:{...e.viewBox}}}function Xg(e,t){return Math.abs(e.zoom-t.zoom)<1e-9&&Math.abs(e.viewBox.x-t.viewBox.x)<1e-6&&Math.abs(e.viewBox.y-t.viewBox.y)<1e-6&&Math.abs(e.viewBox.w-t.viewBox.w)<1e-6&&Math.abs(e.viewBox.h-t.viewBox.h)<1e-6}const Zg=(e,t,i)=>e+(t-e)*i,Jg=(e,t,i)=>Math.exp(Zg(Math.log(e),Math.log(t),i));class Qg{constructor(e,t=Gg){this._hooks=e,this._clock=t,this._token=0,this._raf=null,this._state=null}get state(){return this._state}get active(){return"running"===this._state?.phase}get presented(){return this._state?.presented||null}get target(){return this._state?.to||null}start(e,t,i,n){this.cancel(!1);const r=++this._token,o=Yg(e),s=Yg(t),a=n>0&&Kg(o)&&Kg(s),l=this._clock.now(),c={token:r,phase:a?"running":"settling",from:o,to:s,presented:Yg(a?o:s),startedAt:l,duration:a?n:0,reason:i};if(this._state=c,this._hooks.frame(c),!a)return this._settle(r),r;const h=e=>{const t=this._state;if(!t||t.token!==r)return;const i=Math.max(0,Math.min(1,(e-t.startedAt)/t.duration));if(t.presented=i>=1?Yg(t.to):function(e,t,i){if(!Kg(e))return Yg(t);if(!Kg(t))return Yg(e);const n=Lg(i);if(n<=0)return Yg(e);if(n>=1)return Yg(t);const r=e.viewBox.x+e.viewBox.w/2,o=e.viewBox.y+e.viewBox.h/2,s=t.viewBox.x+t.viewBox.w/2,a=t.viewBox.y+t.viewBox.h/2,l=Jg(e.viewBox.w,t.viewBox.w,n),c=Jg(e.viewBox.h,t.viewBox.h,n),h=Zg(r,s,n),d=Zg(o,a,n);return{zoom:Jg(e.zoom,t.zoom,n),viewBox:{x:h-l/2,y:d-c/2,w:l,h:c}}}(t.from,t.to,i),t.phase=i>=1?"settling":"running",this._hooks.frame(t),i>=1)return this._raf=null,void this._settle(r);this._raf=this._clock.requestFrame(h),null===this._raf&&this._settle(r)};return this._raf=this._clock.requestFrame(h),null===this._raf&&(c.phase="settling",c.presented=Yg(s),this._hooks.frame(c),this._settle(r)),r}cancel(e=!0){null!==this._raf&&this._clock.cancelFrame(this._raf),this._raf=null;const t=this._state;this._state=null,this._token++,t&&e&&(t.phase="settling",t.presented=Yg(t.to),this._hooks.frame(t),this._hooks.settled(t))}dispose(){this.cancel(!1)}_settle(e){const t=this._state;t&&t.token===e&&(t.phase="settling",t.presented=Yg(t.to),this._hooks.settled(t),this._state?.token===e&&(this._state=null))}}function ef(e,t,i){const n=e.querySelector("ha-card");if(!n)return null;const r=n.getBoundingClientRect(),o=t.getBoundingClientRect().top-r.top,s=i?0:Math.min(Math.max(r.top,0),120),a=Math.round(o+s);return a>=0?a:null}const tf=Object.freeze({rotDeg:0,tiltDeg:20,xyScale:1,zScale:1,origin:Object.freeze([500,500])}),nf=84,rf=10,of=4,sf=4;function af(e){return[e.rotDeg,e.tiltDeg,e.xyScale,e.zScale,e.origin[0],e.origin[1]].every(Number.isFinite)&&Math.abs(e.xyScale)>1e-12&&Math.abs(Math.cos(e.tiltDeg*Math.PI/180))>1e-12}function lf(e,t,i=tf){if(!Number.isFinite(e[0])||!Number.isFinite(e[1]))throw new Error("invalid isometric projection input");return function(e,t){if(!Number.isFinite(e[0])||!Number.isFinite(e[1])||!t.every(Number.isFinite))throw new Error("invalid isometric affine input");const[i,n,r,o,s,a]=t;return[i*e[0]+r*e[1]+s,n*e[0]+o*e[1]+a]}(e,hf(t,i))}function cf(e,t=tf){if(!af(t)||!Number.isFinite(e[0])||!Number.isFinite(e[1]))throw new Error("invalid isometric projection input");const i=t.rotDeg*Math.PI/180,n=t.tiltDeg*Math.PI/180,r=(e[0]-t.origin[0])/t.xyScale,o=(e[1]-t.origin[1])/(t.xyScale*Math.cos(n));return[t.origin[0]+r*Math.cos(i)+o*Math.sin(i),t.origin[1]-r*Math.sin(i)+o*Math.cos(i)]}function hf(e=0,t=tf){if(!af(t)||!Number.isFinite(e))throw new Error("invalid isometric camera");const i=t.rotDeg*Math.PI/180,n=t.tiltDeg*Math.PI/180,r=t.xyScale*Math.cos(i),o=-t.xyScale*Math.sin(i),s=t.xyScale*Math.sin(i)*Math.cos(n),a=t.xyScale*Math.cos(i)*Math.cos(n);return[r,s,o,a,t.origin[0]-r*t.origin[0]-o*t.origin[1],t.origin[1]-s*t.origin[0]-a*t.origin[1]-e*t.zScale*Math.sin(n)]}function df(e=tf){return function(e=0,t=tf){return`matrix(${hf(e,t).map(e=>Number(e.toFixed(12))).join(" ")})`}(0,e)}function uf(e,t=tf){const{rect:i,wallHeight:n}=e,r=e.openingHeight??n,o=e.floorDepth??0,s=e.raisedHeight??n;if(!(i.w>=0)||!(i.h>=0)||!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(o)||!Number.isFinite(s)||n<0||r<0||o<0||s<0)throw new Error("invalid isometric frame");const a=[[i.x,i.y],[i.x+i.w,i.y],[i.x+i.w,i.y+i.h],[i.x,i.y+i.h]],l=Math.max(n,r,s),c=a.flatMap(e=>[lf(e,-o,t),lf(e,l,t)]),h=c.map(e=>e[0]),d=c.map(e=>e[1]),u=Math.min(...h),p=Math.min(...d);return{x:u,y:p,w:Math.max(...h)-u,h:Math.max(...d)-p}}const pf=[".dev",".vacpuck",".oplock",".op-hit",".opening",".rlgo","a","button","input","select","textarea",'[contenteditable]:not([contenteditable="false"])',"[data-room-fit-block]",'[role="link"]','[role="button"]'].join(","),_f=(e,t)=>{try{return"function"==typeof e?.matches&&e.matches(t)}catch{return!1}};function mf(e){for(const t of e){const e=t;if(_f(e,".roomlabel[data-id]")){const t=e.getAttribute?.("data-id");return t?{kind:"room",roomId:t}:{kind:"interactive"}}if(_f(e,pf))return{kind:"interactive"};if(_f(e,'[data-hp="room"][data-id]')){const t=e.getAttribute?.("data-id");return t?{kind:"room",roomId:t}:{kind:"interactive"}}if(_f(e,".stage"))return{kind:"background"}}return{kind:"outside"}}function gf(e){const t=mf(e);return"room"===t.kind?t.roomId:null}class ff{constructor(){this.pointer=null,this.sequence=null}clear(){this.pointer=null,this.sequence=null}clearOutside(e){let t={kind:"outside"};try{t=mf(e.composedPath())}catch{}"outside"===t.kind&&this.clear()}pointerDown(e,t,i){let n={kind:"outside"};try{n=mf(e.composedPath())}catch{}this.pointer=function(e){const t="mouse"===(i=e.pointerType)||"touch"===i||"pen"===i?i:null;var i;return t&&"view"===e.mode&&"background"===e.owner.kind&&!e.blocked&&e.isPrimary&&0===e.button&&Number.isFinite(e.x)&&Number.isFinite(e.y)?{pointerId:e.pointerId,spaceId:e.spaceId,modality:t,x:e.x,y:e.y}:null}({pointerId:e.pointerId,pointerType:e.pointerType,isPrimary:e.isPrimary,button:e.button,spaceId:t,mode:i?"view":"blocked",owner:n,blocked:!i,x:e.clientX,y:e.clientY}),this.pointer||(this.sequence=null)}pointerUp(e,t,i,n,r=Date.now()){let o={kind:"outside"};try{o=mf(e.composedPath())}catch{}const s=function(e,t,i){if(!t||"view"!==i.mode||"background"!==i.owner.kind||i.blocked||t.pointerId!==i.pointerId||t.spaceId!==i.spaceId||!Number.isFinite(i.x)||!Number.isFinite(i.y)||!Number.isFinite(i.now)||Math.abs(i.x-t.x)+Math.abs(i.y-t.y)>=8)return{sequence:null,trigger:!1};const n=e?i.now-e.at:Number.POSITIVE_INFINITY;return e&&e.spaceId===i.spaceId&&e.modality===t.modality&&n>=0&&n<=350?{sequence:null,trigger:!0}:{sequence:{at:i.now,spaceId:i.spaceId,modality:t.modality},trigger:!1}}(this.sequence,this.pointer,{pointerId:e.pointerId,spaceId:t,mode:i?"view":"blocked",owner:o,blocked:n||!i,x:e.clientX,y:e.clientY,now:r});return this.pointer=null,this.sequence=s.sequence,s.trigger}}const vf=e=>e.length>=2&&Number.isFinite(e[0])&&Number.isFinite(e[1]);function yf(e){return!!e&&Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.w)&&e.w>0&&Number.isFinite(e.h)&&e.h>0}function bf(e,t=0){if(!e.length||!Number.isFinite(t)||t<0||!e.every(vf))return null;let i=1/0,n=1/0,r=-1/0,o=-1/0;for(const t of e)i=Math.min(i,t[0]),n=Math.min(n,t[1]),r=Math.max(r,t[0]),o=Math.max(o,t[1]);const s=r-i,a=o-n;return s>0&&a>0?{x:i-t,y:n-t,w:s+2*t,h:a+2*t}:null}function wf(e,t,i){const n="string"!=typeof t||"invalid"!==t&&"no-borders"!==t&&"unverified"!==t&&!/^[a-z0-9]{1,8}$/i.test(t)?"redacted":t;return Object.freeze({kind:e,fingerprint:n,terminal:!!i})}function kf(e,t){return`${e("editor.load_failed")} ${e(t.terminal?"editor.refresh_advice":"editor.retry_advice")}`}class xf extends Error{}class Sf{constructor(e){this.options=e,this._state="idle",this._inFlight=null}get state(){return this._state}ensure(){return"ready"===this._state?Promise.resolve(!0):"failed"===this._state?Promise.resolve(!1):(this._inFlight||(this._setState("loading"),this._inFlight=this._loadWithRetry().finally(()=>{this._inFlight=null})),this._inFlight)}async _loadWithRetry(){let e=new Error("Editor runtime did not load"),t=!1;for(const i of[0,1])try{const e=await this.options.load(i);if(e.fingerprint!==this.options.expectedFingerprint)throw new xf(`Editor runtime fingerprint mismatch: expected ${this.options.expectedFingerprint}, got ${e.fingerprint}`);const t=e.create();return this.options.install(t),this._setState("ready"),!0}catch(i){e=i,i instanceof xf&&(t=!0)}return this._setState(t?"failed":"idle"),this.options.failed?.(e,{terminal:t}),!1}_setState(e){e!==this._state&&(this._state=e,this.options.stateChanged?.(e))}}const $f=(e,t)=>{if(!e.has(t))return{hit:!1};const i=e.get(t);return e.delete(t),e.set(t,i),{hit:!0,value:i}},Mf=(e,t,i,n)=>{for(e.delete(t),e.set(t,i);e.size>n;){const t=e.keys().next().value;if(void 0===t)break;e.delete(t)}},Rf=new Set(["select","draw","column","merge","split","resize","opening","wallthick","delroom"]),Cf=e=>`${window.innerWidth}x${window.innerHeight}|${location.pathname}|${JSON.stringify(e??{})}`,Tf="houseplan_card_alpha_v1",Df=Object.freeze([Object.freeze({id:"iso",issue:89,summary:"Volumetric plan renderer"})]);function Af(e){return/^[a-z][a-z0-9-]*$/.test(e.id)&&Number.isInteger(e.issue)&&e.issue>0&&!!e.summary.trim()}function Pf(e){const t=String(e||"").replace(/^#/,"");return new URLSearchParams(t)}function Ff(e){return Pf(e).get("space")||""}function zf(e,t,i=Df){const n=function(e){const t=new Set;for(const i of e){if(!Af(i)||t.has(i.id))return!1;t.add(i.id)}return!0}(i),r=function(e){let t,i=!1;const n=e=>{for(const n of e.getAll("hp_alpha"))i=!0,"1"===n?t=!0:"0"===n&&(t=!1)};return n(new URLSearchParams(String(e.search||"").replace(/^\?/,""))),n(Pf(e.hash)),{present:i,value:t}}(e),o=void 0!==r.value,s="1"===t,a=o?!0===r.value:!r.present&&s,l=n&&a;return{alpha:l,active:Object.freeze(l?i.map(e=>e.id).sort():[]),space:Ff(e.hash),persist:n&&o?l?"1":"0":void 0,knownUrlOperation:o}}let If={alpha:!1,active:Object.freeze([]),space:""},Of=!1,Ef="";const Nf=new Set;function Hf(){if("undefined"==typeof window)return If;const e=zf(window.location,function(){try{return window.localStorage.getItem(Tf)}catch{return null}}());void 0!==e.persist&&function(e){try{window.localStorage.setItem(Tf,e)}catch{}}(e.persist),If={alpha:e.alpha,active:e.active,space:e.space},window.__hpAlpha=e.alpha,window.__hpLabs=e.active;for(const e of Nf)e(If);return If}function Lf(){Hf()}function Bf(){if("undefined"==typeof window)return If;if(!Of){Of=!0,window.__hpLabsListenerCleanup?.(),window.addEventListener("hashchange",Lf),window.addEventListener("popstate",Lf);const e=()=>{window.removeEventListener("hashchange",Lf),window.removeEventListener("popstate",Lf),window.__hpLabsListenerCleanup===e&&delete window.__hpLabsListenerCleanup};window.__hpLabsListenerCleanup=e}return Hf()}const qf={window:120,door:90,passage:90,gate:300};function jf(e){return qf[e]}function Wf(e,t){return{type:e,lengthCm:jf(e),flipH:!1,flipV:!1,revision:t}}function Uf(e,t){const i=Math.max(0,e.renderedLength)/2,n=Math.max(0,e.target.physicalHalfWidth),r=n+.18*Math.max(0,t),o=e=>({x1:e,y1:-r,x2:e,y2:r});return{rect:{x:-i,y:n?-n:0,width:2*i,height:2*n},boundaries:[o(-i),o(i)]}}function Gf(e,t){const i=[e[0],e[1]],n=[t[0],t[1]];return function(e,t){return e[0]-t[0]||e[1]-t[1]}(i,n)<=0?{a:i,b:n}:{a:n,b:i}}function Vf(e){const t=new Map;return e.forEach((e,i)=>{if(!e.kind||e.open)return;const n=Gf(e.a,e.b);if(Math.hypot(n.b[0]-n.a[0],n.b[1]-n.a[1])<=1e-9)return;const r=function(e,t){const i=e=>(Math.abs(e)<=5e-10?0:Math.round(1e6*e)/1e6).toFixed(6);return`${i(e[0])},${i(e[1])}>${i(t[0])},${i(t[1])}`}(n.a,n.b),o=t.get(r);if(o)return o.physicalHalfWidth=Math.max(o.physicalHalfWidth,e.half||0),o.sourceOrder=Math.min(o.sourceOrder,i),void(e.partitionHost&&(o.partitionHost&&o.partitionHost.id!==e.partitionHost.id?o.ambiguousPartitionHost=!0:o.partitionHost=e.partitionHost));t.set(r,{segmentKey:r,a:n.a,b:n.b,physicalHalfWidth:Math.max(0,e.half||0),sourceOrder:i,...e.partitionHost?{partitionHost:e.partitionHost}:{}})}),[...t.values()]}function Kf(e,t){if(Math.abs(e.distance-t.distance)>1e-9)return e.distance-t.distance;if(Math.abs(e.perpendicular-t.perpendicular)>1e-9)return e.perpendicular-t.perpendicular;return(e.target.segmentKeyt.target.segmentKey?1:0)||e.target.sourceOrder-t.target.sourceOrder}function Yf(e){const t=Vf(e.intervals).map(t=>{const i=function(e,t){const i=t.b[0]-t.a[0],n=t.b[1]-t.a[1],r=Math.hypot(i,n),o=i/r,s=n/r,a=(e[0]-t.a[0])*o+(e[1]-t.a[1])*s,l=Math.max(0,Math.min(r,a)),c=t.a[0]+l*o,h=t.a[1]+l*s;return{along:l,length:r,x:c,y:h,distance:Math.hypot(e[0]-c,e[1]-h),perpendicular:Math.abs((e[0]-t.a[0])*s-(e[1]-t.a[1])*o)}}(e.pointer,t);return{target:t,...i,envelope:Math.max(e.baseTolerance,t.physicalHalfWidth+e.bodyPointerPadding)}}).filter(e=>e.distance<=e.envelope+1e-9).filter(t=>!function(e,t,i,n,r){const o=t.b[0]-t.a[0],s=t.b[1]-t.a[1],a=Math.hypot(o,s);if(!(a>1e-9))return!1;const l=o/a,c=s/a;for(const o of i){if(!o.open&&o.kind)continue;const i=Gf(o.a,o.b),s=i.b[0]-i.a[0],a=i.b[1]-i.a[1],h=Math.hypot(s,a);if(!(h>1e-9))continue;const d=s/h,u=a/h;if(Math.abs(l*u-c*d)>1e-6)continue;if(Math.abs((i.a[0]-t.a[0])*c-(i.a[1]-t.a[1])*l)>r)continue;const p=(e[0]-i.a[0])*d+(e[1]-i.a[1])*u,_=1e-9;if(!(p<=_||p>=h-_)&&Math.abs((e[0]-i.a[0])*u-(e[1]-i.a[1])*d)<=n+1e-9)return!0}return!1}(e.pointer,t.target,e.intervals,t.envelope,Math.max(1e-9,Math.min(e.baseTolerance,.04*e.gridStep)))),i=t.filter(t=>!!t.target.partitionHost&&e.renderedLength+2*t.target.physicalHalfWidth>t.length+1e-9).sort(Kf),n=t.filter(t=>!t.target.partitionHost||e.renderedLength+2*t.target.physicalHalfWidth<=t.length+1e-9).sort(Kf);let r=n[0];if(!r)return{candidate:null,jambBlockedTarget:i[0]?.target||null};const o=n.filter(e=>Math.abs(e.distance-r.distance)<=1e-9&&Math.abs(e.perpendicular-r.perpendicular)<=1e-9),s=o.filter(e=>e.target.partitionHost);if(s.length){if(1!==new Set(s.map(e=>e.target.partitionHost.id)).size||s.some(e=>e.target.ambiguousPartitionHost))return{candidate:null,jambBlockedTarget:null};const e=s[0],t=e.target.b[0]-e.target.a[0],i=e.target.b[1]-e.target.a[1],n=Math.hypot(t,i),a=t/n,l=i/n;if(!o.every(t=>{const i=t.target.b[0]-t.target.a[0],n=t.target.b[1]-t.target.a[1],r=Math.hypot(i,n),o=i/r,s=n/r,c=Math.abs(a*s-l*o)<=1e-6,h=Math.abs((t.target.a[0]-e.target.a[0])*l-(t.target.a[1]-e.target.a[1])*a);return c&&h<=1e-9}))return{candidate:null,jambBlockedTarget:null};r=e}if(r.target.ambiguousPartitionHost)return{candidate:null,jambBlockedTarget:null};const{target:a,length:l}=r,c=a.b[0]-a.a[0],h=a.b[1]-a.a[1],d=c/l,u=h/l,p=a.partitionHost?a.physicalHalfWidth:0,_=Math.min(Math.max(0,e.renderedLength)/2+p,l/2);let m=r.along;const g=Math.max(e.gridStep,1e-9),f=l/2;m=Math.abs(m-f)<=g/2?f:Math.round(m/g)*g,m=Math.max(_,Math.min(l-_,m));const v=a.a[0]+d*m,y=a.a[1]+u*m,b=Math.max(0,e.renderedLength)/2,w=m-b,k=m+b,x=Math.max(0,w),S=Math.max(0,l-k),$=[a.a[0]+d*(w-x/2),a.a[1]+u*(w-x/2)],M=[a.a[0]+d*(k+S/2),a.a[1]+u*(k+S/2)];let R=180*Math.atan2(h,c)/Math.PI;R>=90?R-=180:R<-90&&(R+=180);const C=Math.abs(m-f)<=1e-9;return{candidate:{presetRevision:e.preset.revision,geometryRevision:e.geometryRevision,pointer:[e.pointer[0],e.pointer[1]],type:e.preset.type,lengthCm:e.preset.lengthCm,flipH:e.preset.flipH,flipV:e.preset.flipV,x:v,y:y,angle:R,renderedLength:e.renderedLength,target:a,...a.partitionHost?{host:{...a.partitionHost,t:l>0?m/l:0}}:{},measure:{labels:[{distance:x,midpoint:$},{distance:S,midpoint:M}],guide:C?{x:v,y:y,angle:R}:null}},jambBlockedTarget:null}}function Xf(e,t,i,n,r=1e-6){return e.presetRevision===i&&e.geometryRevision===n&&Math.hypot(e.pointer[0]-t[0],e.pointer[1]-t[1])<=r}function Zf(e){return!(!e.canEdit||e.kiosk||e.fixedFloor)&&("view"!==e.mode&&("mouse"===e.pointerType&&e.spaceCount>1))}class Jf{constructor(e,t,i){this.loader=e,this.host=t,this.adopted=i,this.attachment=null}connect(){if(this.runtime)return void this.runtime.connect();this.attachment?.cancel();const e=this.loader.attach(this.host,e=>this.adopt(e));this.runtime||(this.attachment=e)}disconnect(){this.attachment?.cancel(),this.attachment=null,this.runtime?.disconnect()}adopt(e){this.attachment=null,this.runtime||(this.runtime=e,this.adopted(e))}}const Qf=new class{constructor(e){this.load=e,this.factory=null,this.pending=null}get warm(){return null!==this.factory}create(e){return this.factory?this.factory(e):null}attach(e,t){let i=!0;const n={cancel:()=>{i=!1}},r=this.create(e);return r?(t(r),n):(this.ensure().then(n=>{i&&t(n(e))},()=>{}),n)}ensure(){return this.factory?Promise.resolve(this.factory):(this.pending||(this.pending=this.load().then(e=>(this.factory=e,this.pending=null,e),e=>{throw this.pending=null,e})),this.pending)}reset(){this.factory=null,this.pending=null}}(()=>import("./summary-panel-runtime-loaded-B9-PG-Gw.js").then(function(e){return e.e}).then(({LoadedSummaryPanelRuntime:e})=>t=>new e(t)));function ev(e){const t=globalThis.__HP_VERSION_OVERRIDE__;return"string"==typeof t&&t.length>0?t:e}let tv=0;const iv="1.77.0-beta.1",nv="ed91b3971428d2b8e7bfceb8025d2be4c0db7c58754eeb4ba03f835b8d7c84c6",rv=1500,ov=new Map;let sv=0,av=1e4;const lv="houseplan_card_layout_v1",cv="houseplan_card_cfg_v1",hv="houseplan_card_zoom_v1",dv="houseplan_card_nav_v1",uv="houseplan_card_view_v1",pv="hp-dialog, hp-help, hp-color-opacity, hp-device-preview",_v=1e3,mv=(e,t)=>{const i=Math.min(e.x,t.x),n=Math.min(e.y,t.y);return{x:i,y:n,w:Math.max(e.x+e.w,t.x+t.w)-i,h:Math.max(e.y+e.h,t.y+t.h)-n}},gv=(e,t,i)=>{const n=new Event(t,{bubbles:!0,composed:!0});n.detail=i??{},e.dispatchEvent(n)},fv=e=>{history.pushState(null,"",e),gv(window,"location-changed",{replace:!1})},vv=(e,t)=>{let i,n=null;const r=(...r)=>{clearTimeout(i),n=r,i=window.setTimeout(()=>{i=void 0;const t=n;n=null,t&&e(...t)},t)};return r.flush=()=>{if(void 0===i)return;clearTimeout(i),i=void 0;const t=n;n=null,t&&e(...t)},r.cancel=()=>{clearTimeout(i),i=void 0,n=null},r.pending=()=>void 0!==i,r},yv=e=>{try{e.target?.setPointerCapture?.(e.pointerId)}catch{}},bv=["edges","corners"];class wv extends he{constructor(){var e;super(...arguments),this._editorRuntime=null,this._liveRt=null,this._onboardingRuntime=null,this._editorRuntimeLoadingVisible=!1,this._backdropGuard=null,this._editorModeRequest=0,this._warmModeRequest=0,this._editorRuntimeLoader=new Sf({expectedFingerprint:nv,load:async e=>{const t=0===e?await import("./houseplan-editor-runtime-BG2wMJ7n.js"):await import((()=>{const e=new URL("./houseplan-editor-runtime-BG2wMJ7n.js",import.meta.url);return e.searchParams.set("hp_retry",`${iv}-${++tv}`),e.href})());return{fingerprint:t.EDITOR_RUNTIME_FINGERPRINT,create:()=>new t.HouseplanEditorRuntime(this)}},install:e=>{this._editorRuntime=e},stateChanged:e=>this._editorRuntimeStateChanged(e),failed:(e,t)=>{console.error("[houseplan] unable to load editor runtime",e),t.terminal&&this._versionRecovery.hasCurrentMismatchNotice||this._showToast(kf(e=>this._t(e),t))}}),this._onboardingRuntimeLoader=new Sf({expectedFingerprint:nv,load:async e=>{const t=0===e?await import("./houseplan-onboarding-runtime-BAx8bJB2.js"):await import((()=>{const e=new URL("./houseplan-onboarding-runtime-BAx8bJB2.js",import.meta.url);return e.searchParams.set("hp_retry",`${iv}-${++tv}`),e.href})());return{fingerprint:t.ONBOARDING_RUNTIME_FINGERPRINT,create:()=>new t.HouseplanOnboardingRuntime(this)}},install:e=>{this._onboardingRuntime=e},failed:(e,t)=>{console.error("[houseplan] unable to load onboarding runtime",e),t.terminal&&this._versionRecovery.hasCurrentMismatchNotice||this._showToast(kf(e=>this._t(e),t))}}),this._isoSceneRuntime=null,this._isoSceneRuntimeLoader=new Sf({expectedFingerprint:nv,load:async e=>{const t=0===e?await import("./iso-scene-render-CR59iy_N.js"):await import((()=>{const e=new URL("./iso-scene-render-CR59iy_N.js",import.meta.url);return e.searchParams.set("hp_retry",`${iv}-${++tv}`),e.href})());return{fingerprint:t.ISO_SCENE_RUNTIME_FINGERPRINT,create:()=>t}},install:e=>{const t=this._effectiveProjection();this._isoSceneRuntime=e,this._isoProjectionSnapshot=null;const i=this._effectiveProjection();this._convertProjectionView(t,i),this.isConnected&&this.requestUpdate()},failed:(e,t)=>{console.warn("[houseplan] hidden isometric runtime diagnostic",wf("runtime-load","unverified",t.terminal)),this.isConnected&&this.requestUpdate()}}),this._pdfRuntime=null,this._pdfRuntimeLoader=new Sf({expectedFingerprint:nv,load:async e=>{const t=0===e?await import("./pdf-export-FjKO_S28.js"):await import((()=>{const e=new URL("./pdf-export-FjKO_S28.js",import.meta.url);return e.searchParams.set("hp_retry",`${iv}-${++tv}`),e.href})());return{fingerprint:t.PDF_EXPORT_FINGERPRINT,create:()=>new t.PdfExportRuntime}},install:e=>{this._pdfRuntime=e,this.isConnected&&this.requestUpdate()},failed:(e,t)=>{if(console.error("[houseplan] unable to load PDF export runtime",e),!t.terminal||!this._versionRecovery.hasCurrentMismatchNotice){const e=kf(e=>this._t(e),t),i=this._t("editor.load_failed"),n=e.startsWith(i)?e.slice(i.length).trim():e;this._showToast(`${this._t("pdf.failed")} ${n}`.trim())}}}),this.panelHost=!1,this.narrow=null,this._space="f1",this._adoption=new qu((e,t)=>this.requestUpdate(e,t)),this._serverStorage=!1,this._loadOk=!1,this._serverCanWrite=null,this._loading=!1,this._loadTries=0,this._unsubCfg=null,this._unsubLayout=null,this._unsubVirtual=null,this._liveSyncAttempt=null,this._liveSyncGeneration=0,this._liveSyncConnection=null,this._configReloadAuthority=new Gu,this._virtualLights=Hh(null),this._canOptimizeUndo=!1,this._undoKind=null,this._devices=[],this._regSignature="",this._defPos={},this._newSyncKey="",this._areaRelocationIds=new Set,this._areaSnapshotCleanupCandidates=new Map,this._areaRelocationSyncKey="",this._areaRelocationWrite=Promise.resolve(),this._tip=null,this._hoverRoom=null,this._pointerModality=new sg(this,()=>this._syncPointerHoverTargets()),this._devicePressAnimations=new Map,this._selId=null,this._toast="",this._mode="view",this._pendingNavMode=null,this._decorTool="select",this._decorStyle={...Cr},this._decorStyleSeeded=!1,this._decorDraft=null,this._decorMove=null,this._decorSel=null,this._decorEraseConfirm=null,this._decorTextDialog=null,this._decorShapeDialog=null,this._backdropDialog=null,this._decorTextSelection={start:0,end:0},this._furnPalette=null,this._decorImagePalette=null,this._decorAssetCatalog=[],this._decorAssets=new Map,this._decorAssetBusy=!1,this._furnCategory=null,this._furnPreviewInput=null,this._furnTouchPending=null,this._dtBox=null,this._dtDrag=null,this._bdDrag=null,this._slide="",this._reducedMotion=!1,this._onMotionChange=e=>{this._reducedMotion=e.matches,this._cancelDevicePressFeedback(),e.matches&&this._cancelCameraTransition(!0),e.matches&&this._modeTransitionPreparing?this._modeTransitionForceAtomic=!0:e.matches&&this._modeTransition.active&&this._cancelModeTransition(!0),this._syncVersionRecovery(),this.requestUpdate()},this._editorChromeMode="plan",this._modeTransitionVisual=null,this._modeTransitionPreparing=!1,this._modeTransitionForceAtomic=!1,this._modeTransitionRequest=0,this._modeTransitionTargetZoom=1,this._modeTransitionEditorCamera=null,this._modeTransition=new Ug({frame:e=>this._applyModeTransitionFrame(e),settled:e=>this._settleModeTransition(e)}),this._cameraTransitionFit=null,this._cameraTransition=new Qg({frame:e=>this._applyCameraTransitionFrame(e),settled:e=>this._settleCameraTransition(e)}),this._editorSecondaryCopy={groupActive:(e,t)=>this._t("editor.group_active",{group:e,item:t}),openGroup:e=>this._t("editor.open_group",{group:e}),disabledAction:(e,t)=>this._t("editor.disabled_action",{action:e,reason:t})},this._tool="draw",this._geometryHistory=new gg(50),this._devicePositionHistory=new gg(50),this._devicePositionBusy=!1,this._wallDialog=null,this._drawWallField=null,this._activeWallChainId=null,this._activeWallChainPartitionIds=[],this._wallChainRedo=[],this._physicalSel=null,this._physicalDialog=null,this._partitionDeleteDialog=null,this._roomDeleteDialog=null,this._physicalDrag=null,this._physicalRotate=null,this._physicalLastTap=null,this._physicalPickCycle=null,this._wallUnionCacheValue=null,this._wallUnionPool=new Map,this._isoGeometryCache=new Map,this._renderIsoScene=null,this._isoProjectionSnapshot=null,this._isoStructuralBuildCount=0,this._isoFallback=new Set,this._openingTunnelCache=null,this._openingWallIndexCache=new Map,this._openingPlacementIntervalsCache=null,this._openingDimensionContextCache=null,this._planSnapGeometryCache=null,this._planStructuralGeometryCache=null,this._hiddenWallDiagnosticCache=null,this._physicalBodiesCache=null,this._lightPhysicalBodiesCache=null,this._cleanFloorCache=new Map,this._innerContourCache=new Map,this._glowRuntimeState=bm(),this._glowRuntimeHost={window:()=>this.ownerDocument.defaultView||window,isConnected:()=>this.isConnected,requestUpdate:()=>this.requestUpdate(),reducedMotion:()=>this._reducedMotion},this._lightBarrierCache=null,this._lightBarrierPool=new Map,this._glowScreenBlend=!1,this._duplicateColumnId=null,this._duplicateColumnTimer=0,this._rszLimitViolation=null,this._path=[],this._cursorPt=null,this._planSnapHover=null,this._mergeSel=null,this._openingPreset=null,this._openingRebindId=null,this._openingPresetRevision=0,this._openingHoverCandidate=null,this._openingJambBlockCm=null,this._openingDialog=null,this._openingInfo=null,this._opDrag=null,this._opMeasure=null,this._mergeDialog=null,this._splitSel=null,this._pendingSplit=null,this._wallFaceBatch=null,this._wallRepairDiagnostic=null,this._wallFaceGraphCache=[],this._areaSel="",this._nameSel="",this._roomDialog=!1,this._roomEditId=null,this._roomFill="",this._roomCustomFill=null,this._roomTempMin="",this._roomTempMax="",this._roomTempSrc="",this._roomHumSrc="",this._roomSrcOpen=null,this._roomSrcFilter="",this._roomNameScale=1,this._roomLabelScale=1,this._zoom=1,this._view=null,this._zoomBySpace={},this._viewModeSnap=null,this._roomFocus=null,this._roomPointer=null,this._doubleFit=new ff,this._deviceHits=new wc,this._pointers=new Map,this._panStart=null,this._panLock=null,this._pinchStart=null,this._safeDayCycleOutline=!1,this._suppressClick=!1,this._viewportGestureDirty=!1,this._touchContacts=new Map,this._touchClickGuard=new pc,this._connectedPath="",this._routeDepartureHandled=!1,this._onLocationChanged=()=>{this._connectedPath&&location.pathname!==this._connectedPath?this._leaveCardRoute():location.pathname===this._connectedPath&&(this._routeDepartureHandled=!1)},this._touchGestureGuard={capture:!0,handleEvent:e=>this._guardTouchGesture(e)},this._hdrH=118,this._booting=!0,this._bootFading=!1,this._bootSettling=!1,this._bootSettleRaf=0,this._bootLastH=-1,this._bootStart=0,this._bootLastChange=0,this._bootSoft=!1,this._tapConfirm=null,this._dangerConfirm=null,this._dangerConfirmController=new ze(e=>{this._dangerConfirm=e}),this._confirmDanger=e=>this._config&&this.hass?"warm"===this._syncDangerConfirmLocaleGate()||this._dangerConfirmMissingSpace()?Promise.resolve(!1):this._dangerConfirmController.confirm(e):Promise.resolve(!1),this._cancelDangerConfirm=()=>{this._dangerConfirmController.cancel()},this._onDangerConfirmDecision=e=>{this._dangerConfirmController.resolve(e.detail.token,e.detail.accepted)},this._onboardingShown=!1,this._rulesDialog=null,this._preflightClipboardFallback=null,this._haIntegrationVersion=null,this._versionRecovery=(e=this,new wg({clock:{setTimeout:(e,t)=>window.setTimeout(e,t),clearTimeout:e=>window.clearTimeout(e)},storage:()=>e.ownerDocument.defaultView?.sessionStorage??null,safety:()=>Sg(e),reload:()=>e._reloadDocument(),changed:()=>{e.requestUpdate()}})),this._haSupportApi=null,this._haDecorAssetsApi=null,this._haSummaryPanelApi=null,this._haRadarStage1Api=null,this._radarLive=new Ag(this),this._decorAssetSyncToken=0,this._alignDialog=null,this._settingsDialog=null,this._pdfDialog=!1,this._supportDialog=null,this._backupExportDialog=null,this._backupImportDialog=null,this._sunRaysCache=null,this._dayCycleTimer=0,this._dayCycleClockKey="",this._compassDrag=!1,this._importDialog=null,this._importQueue=[],this._importTotal=0,this._rulesCompiledSrc="",this._infoCard=null,this._nativeMoreInfoEntity=null,this._deviceInbox=null,this._deviceInboxReturn=null,this._deviceInboxMemo=null,this._markerDialog=null,this._spaceDialog=null,this._keyHandler=e=>this._onKey(e),this._warmVp=null,this._warmVpArmed=!1,this._warmLongReturn=!1,this._warmRevivePending=!1,this._warmGen=++sv,this._warmKey=null,this._warmSlot=null,this._hashApplied=!1,this._navApplied=!1,this._labs={alpha:!1,active:Object.freeze([]),space:""},this._viewPreference={},this._renderProjection="flat",this._kioskScale={icon:1,font:1},this._kioskDialog=!1,this._summarySlot=new Jf(Qf,this,e=>{this._summary=e,this._capturedSnapshotSequence=-1,this.isConnected&&(e.connect(),this.hasUpdated&&this.requestUpdate())}),this._activityRt=new Map,this._vacRt=new Map,this._vacViewKey="",this._vacLastView=null,this._vacRaf=0,this._vacSrvTrails={},this._vacJumpOnce=!1,this._continuity=this._newContinuityController(),this._continuityHistory=[],this._continuityEpoch=0,this._continuityDataReady=!0,this._continuityPaintToken=-1,this._continuityDisposed=!1,this._renderSnapshotAt=Date.now(),this._hassSequence=0,this._visibleDeviceSnapshot=null,this._candidateDeviceSnapshot=null,this._stagedDeviceSnapshotToken=-1,this._capturedSnapshotSequence=-1,this._capturedSnapshotDevices=null,this._capturedSnapshotLayout=null,this._capturedSnapshotActivity="",this._capturedSnapshotConfigEpoch=-1,this._capturedSnapshotVirtual="",this._lastValidStageSize=null,this._pendingRefitSize=null,this._refitRaf=0,this._pageVisibility=e=>{if(this._continuity.visibility(e),this._dayCycleVisibility(e),this._summary?.visibility(e.kind),"hidden"===e.kind)return this._radarLive.stop(),this._editorRuntime?._cancelRadarSetup(),this._clearRoomFocus(!0),this._clearTransientHover(!0),this._cancelDevicePressFeedback(),this._cancelCameraTransition(!0),void(this._modeTransitionPreparing?this._modeTransitionForceAtomic=!0:this._cancelModeTransition(!0));if(this._vacJumpOnce=!0,this._syncRadarLive(),!e.long){const e=Date.now();let t=!1;for(const i of this._activityRt.values())!i.flashKind||(i.expiresAt||i.flashTs+tg)>e||(i.flashTs=0,i.flashKind=null,i.expiresAt=0,t=!0);return void(t&&this.requestUpdate())}Date.now()-this._renderSnapshotAt>1e3&&this._continuity.note("device-snapshot-stale"),this._continuityDataReady=!1,this._continuityPaintToken=-1,this._resumeSettling=!0,this._loading?this.requestUpdate():this._loadFromServer()},this._resumeSettling=!1,this._viewportInvalidAt=0,this._vacFit=null,this._vacAllCamerasFor=null,this._vacAllCameraCache=null,this._vacCalConfirm=null,this._kioskDots=!1,this._cyclePausedUntil=0,this._swipeStart=null,this._tabDrag=null,this._tabDragRelease=null,this._tabSuppressClick=!1,this._tabOrderWarned=!1,this._onLabsSnapshot=e=>{const t=this._effectiveProjection();this._labs=e,this._isoProjectionSnapshot=null,this._labsIso&&this._ensureIsoSceneRuntime();const i=this._effectiveProjection();this._convertProjectionView(t,i),this.requestUpdate()},this._onHashChange=()=>{if(this._hasFixedFloor)return;const e=this._hashSpace();if(e&&this._model.find(t=>t.id===e)&&e!==this._space){if(this._wallFaceBatch&&this._roomDialogCancel(),"plan"===this._mode&&"draw"===this._tool&&!this._finishWallChain())return;this._commitSpace(e),this._selId=null,this._path=[],this._clearPlanSnapHover(),this._clearOpeningPlacement(!0),this._tool="draw",this._activeWallChainId=null,this._activeWallChainPartitionIds=[],this._wallChainSegmentCms=[],this._closingWallCm=null,this._restoreZoom(),this.requestUpdate()}},this._drag=null,this._deviceDrag=null,this._rlResize=null,this._holdFired=!1,this._retryContinuity=()=>{this._continuityDataReady=!1,this._continuityPaintToken=-1,this._continuity.retry(this._continuity.recoveryReason||"plan"),this._loading||this._loadFromServer()},this._cfgEpoch=0,this._cfgEpochPreservedConfig=null,this._terminalFrame=0,this._modelCache=null,this._emptySpaceStateActive=!1,this._decorSnapCache=null,this._markerPreviewMemo=null,this._markerPreviewDevicesMemo=null,this._showHidden=!1,this._connHooked=null,this._connectionWasLost=!1,this._haRegistryConnection=null,this._haRegistryRev=-1,this._haBindingCacheKey="",this._planHassMemo=null,this._renderLife=new $g,this._liveEditorPaintCount=0,this._onHaRegistryUpdate=()=>{const e=nd(this.hass);e.revision===this._haRegistryRev&&this._devices.length||(this._haRegistryRev=e.revision,this._renderLife.invalidate(),this._planHassMemo=null,this._regSignature="",this._maybeRebuildDevices(),this.requestUpdate())},this._onConnReady=()=>{if(this._loadTries=0,clearTimeout(this._loadRetryTimer),this._loadRetryTimer=void 0,id(this.hass),this._saveConfigDebounced.pending()&&this._saveConfigDebounced.flush(),this._cfgWriting)return clearTimeout(this._reloadRetry),void(this._reloadRetry=window.setTimeout(this._onConnReady,400));!this._connectionWasLost&&this._continuity.hasCompleteFrame?this._beginContinuityCandidate("connection-ready",!1,"plan"):(this._continuityDataReady=!1,this._continuityPaintToken=-1),this._loading||this._loadFromServer()},this._onConnLost=()=>{this._booting&&!this._continuity.hasCompleteFrame||(this._connectionWasLost=!0,this._continuityDataReady=!1,this._continuityPaintToken=-1,this._continuity.connectionLost())},this._signer=new uc(()=>this.requestUpdate()),this._dirtyPos=new Set,this._sentPos=new Map,this._persistLayout=vv(()=>{if(this._serverStorage){const e=[...this._dirtyPos];this._dirtyPos.clear();for(const t of e){const e=xo(this._layout[t]);e&&(this._layout={...this._layout,[t]:e},this._sentPos.set(t,e),this.hass.callWS({type:"houseplan/layout/update",device_id:t,pos:e}).then(e=>this._noteLayoutRev(e)).catch(e=>this._showToast(this._t("toast.pos_save_failed",{err:this._errText(e)}))).finally(()=>{this._sentPos.get(t)===e&&this._sentPos.delete(t)}))}this._cacheSnapshot()}else this._persistLocalLayout()},600),this._frame=null,this._showFar=!1,this._writesPending=0,this._writeChain=Promise.resolve(),this._pendingPhysicalWrites=new Map,this._undoGeometry=()=>this._editorRuntimeOrThrow()._undoGeometry(),this._redoGeometry=()=>this._editorRuntimeOrThrow()._redoGeometry(),this._saveConfigDebounced=vv(()=>{this._serverCfg&&this._writeConfig().catch(e=>{const t=!0===e?.physicalGeometryRolledBack;"geometry-unsafe"!==e?.code&&("wall_model_client_outdated"===e?.code?this._showToast(this._t("toast.wall_model_client_outdated")):"conflict"===e?.code?(this._showToast(this._t("toast.conflict")),t||(this._cancelPath(),this._reloadConfigOnly(!0))):this._showToast(this._t("toast.cfg_save_failed",{err:this._errText(e)})),t&&this._reloadRejectedPhysicalWrite())})},500),this._wallChainSegmentCms=[],this._closingWallCm=null,this._savePhysicalDialog=()=>this._editorRuntimeOrThrow()._savePhysicalDialog(),this._deletePhysicalSelection=()=>this._editorRuntimeOrThrow()._deletePhysicalSelection(),this._confirmPartitionDelete=()=>this._editorRuntimeOrThrow()._confirmPartitionDelete(),this._confirmRoomDelete=e=>this._editorRuntimeOrThrow()._confirmRoomDelete(e),this._rebindPartitionOpening=()=>this._editorRuntimeOrThrow()._rebindPartitionOpening(),this._keepClosedAsPartitions=()=>this._editorRuntimeOrThrow()._keepClosedAsPartitions(),this._toggleServerPlans=async()=>this._onboardingRuntime&&this._spaceDialogUsesOnboardingRuntime("create")?this._onboardingRuntime._toggleServerPlans():this._editorRuntimeOrThrow()._toggleServerPlans(),this._aspectJob=null,this._dayCycleTick=()=>{if(!this.isConnected||"hidden"===this.ownerDocument.visibilityState)return;const e=this._dayCycleState();if(!e)return this._dayCycleTimer&&(clearInterval(this._dayCycleTimer),this._dayCycleTimer=0),void(this._dayCycleClockKey="");const t=cr(e);t!==this._dayCycleClockKey&&(this._dayCycleClockKey=t,this.requestUpdate())},this._sunShown=!1,this._sunOut=!1,this._sunOutTimer=0,this._openSettingsDialog=()=>{if(this._editorRuntime)return this._editorRuntime._openSettingsDialog();this._ensureEditorRuntime().then(e=>{e&&this._openSettingsDialog()})},this._openSupportDialog=()=>{this._editorRuntime?this._editorRuntime._openSupportDialog():this._ensureEditorRuntime().then(e=>{e&&this._openSupportDialog()})},this._openPdfDialog=()=>{this._pdfRuntimeLoader.ensure().then(e=>{e&&(this._pdfDialog=!0,this.requestUpdate())})},this._reportedPreflightFingerprint=null,this._openAlignDialog=()=>this._editorRuntimeOrThrow()._openAlignDialog(),this._toggleOptimizeLivePositions=()=>this._editorRuntimeOrThrow()._toggleOptimizeLivePositions(),this._optimizeUndoBusy=!1,this._openBackupExport=()=>this._editorRuntimeOrThrow()._openBackupExport(),this._openRulesDialog=()=>this._editorRuntimeOrThrow()._openRulesDialog(),this._climateCache=null,this._gearPtCache=new WeakMap}requestUpdate(e,t,i){if("hass"===e&&this.hass&&this._liveRt){const e=this._visibleDeviceSnapshot||this._candidateDeviceSnapshot;if(!this._liveRt.hass(t,this.hass,e?{entityIds:e.entityIds}:null,()=>Mg(this))&&!this._summary?.observeHassComposition())return}void 0!==e&&(this._terminalFrame=0),this._editorRuntime?._routeLiveEditorUpdate(e,t)||(this._liveRt?.clear(),super.requestUpdate(e,t,i))}_editorRuntimeOrThrow(){if(!this._editorRuntime)throw new Error("Houseplan editor runtime is not loaded");return this._editorRuntime}async _ensureEditorRuntime(){return this._editorRuntimeLoader.ensure()}async _ensureOnboardingRuntime(){return this._onboardingRuntimeLoader.ensure()}async _ensureIsoSceneRuntime(){return this._isoSceneRuntimeLoader.ensure()}_editorRuntimeStateChanged(e){clearTimeout(this._editorRuntimeLoadingTimer),this._editorRuntimeLoadingTimer=void 0,"loading"!==e?(this._editorRuntimeLoadingVisible=!1,this.requestUpdate()):this._editorRuntimeLoadingTimer=window.setTimeout(()=>{this._editorRuntimeLoadingVisible=!0,this.requestUpdate()},150)}async _requestMode(e,t=!0,i=!1){const n=++this._editorModeRequest;if(i&&(this._warmModeRequest=n,this._refitRaf&&(cancelAnimationFrame(this._refitRaf),this._refitRaf=0),this._pendingRefitSize=null),"view"===e||await this._ensureEditorRuntime()){if(n===this._editorModeRequest&&this.isConnected)return i?(this._adoptMode(e),this._warmRevivePending&&(clearTimeout(this._warmReviveTimer),this._warmReviveTimer=void 0,this._warmReviveDialog()),this.requestUpdate(),void this.updateComplete.then(()=>requestAnimationFrame(()=>requestAnimationFrame(()=>{if(this._warmModeRequest!==n||n!==this._editorModeRequest)return;const e=this._stageEl;this._lastValidStageSize=e&&e.clientWidth>0&&e.clientHeight>0?[e.clientWidth,e.clientHeight]:null,this._pendingRefitSize=null,this._warmModeRequest=0})))):void this._setMode(e,t);this._warmModeRequest===n&&(this._warmModeRequest=0)}else this._warmModeRequest===n&&(this._warmModeRequest=0)}get _layout(){return this._adoption.layout}set _layout(e){this._adoption.stageLocalLayout(e)}get _layoutRev(){return this._adoption.layoutRev}set _layoutRev(e){this._adoption.seedIdentity({layoutRev:e})}get _layoutContentFingerprint(){return this._adoption.layoutFingerprint}set _layoutContentFingerprint(e){this._adoption.seedIdentity({layoutFingerprint:e})}get _serverCfg(){return this._adoption.config}set _serverCfg(e){this._adoption.stageLocalConfig(e)}get _cfgRev(){return this._adoption.configRev}set _cfgRev(e){this._adoption.seedIdentity({configRev:e})}get _cfgContentFingerprint(){return this._adoption.configFingerprint}set _cfgContentFingerprint(e){this._adoption.seedIdentity({configFingerprint:e})}_seedDecorStyle(e){var t,i;if(t=Ol,i=this,Fl(e,Bl)&&"pending"===t.state()&&(t.art("",i),t.ensure()),this._decorStyleSeeded||!e)return;this._decorStyleSeeded=!0;const n=e.settings?.decor_default_style;n&&(this._decorStyle=function(e,t){if(!e||"object"!=typeof e)return{...t};const i=e,n="string"==typeof i.color&&i.color?i.color:t.color,r="string"==typeof i.fill_color&&i.fill_color?i.fill_color:t.fillColor,o=Number(i.width_cm);return{color:n,opacity:Tr(i.opacity,t.opacity),widthCm:Number.isFinite(o)&&o>0?Math.max(.1,Math.min(100,o)):t.widthCm,fill:"boolean"==typeof i.fill?i.fill:t.fill,fillColor:r,fillOpacity:Tr(i.fill_opacity,t.fillOpacity)}}(n,Cr))}get _canManageConfiguration(){return null!==this._serverCanWrite?this._serverCanWrite:!0===this.hass?.user?.is_admin}get _canEdit(){return this._norm&&this._canManageConfiguration}get _kiosk(){return!!this._config?.kiosk}_showKioskDots(){this._kioskDots=!0,clearTimeout(this._kioskDotsTimer),this._kioskDotsTimer=window.setTimeout(()=>this._kioskDots=!1,2500)}get _modeTransitionBusy(){return this._modeTransitionPreparing||this._modeTransition.active}get _doubleFitEnabled(){return!("view"!==this._mode||this._vacFit||this._modeTransitionBusy||this._touchSequenceMultitouch||"steady"!==this._continuity.state||this._continuity.overlayBlocksInteraction)}_cameraState(){const e=this._viewOr(this._baseVb());return{zoom:this._zoom,viewBox:{...e}}}_normalizeCameraState(e){const t=this._cameraTransitionFit||Oi(this._baseVb(),this._stageAspect());return{zoom:Math.min(wv.ZOOM_MAX,Math.max(wv.ZOOM_MIN,e.zoom)),viewBox:this._clampView({...e.viewBox},t)}}_applyCameraTransitionFrame(e){const t=this._normalizeCameraState(e.presented);e.presented=t,this._zoom=t.zoom,this._view={...t.viewBox},this._liveVp(!0)}_settleCameraTransition(e){const t=this._normalizeCameraState(e.to);this._zoom=t.zoom,this._view={...t.viewBox},this._cameraTransitionFit=null,"room"!==e.reason&&this._saveZoom(),this.requestUpdate()}_cancelCameraTransition(e=!1,t=!1){const i=this._cameraTransition.state?.reason,n=t&&this._cameraTransition.active?this._cameraTransition.presented?.zoom:void 0;this._cameraTransition.cancel(e),this._cameraTransitionFit=null,void 0!==n&&"room"!==i&&this._saveZoom()}_prepareCameraCommand(){this._bootSoftCancel(),this._modeTransitionBusy&&this._cancelModeTransition(!0),"opening"===this._tool&&(this._cursorPt=null,this._clearOpeningPlacement(!1))}_startCameraTransition(e,t,i,n){const r=this._cameraState(),o=this._cameraTransition.target;return(!o||!Xg(o,e))&&(Xg(r,e)?(this._cancelCameraTransition(!1),!1):(this._activateSafeDayCycleOutline(),this._cameraTransitionFit={...t},this._cameraTransition.start(r,e,i,this._reducedMotion?0:n),!0))}_cssColor(e,t){const i=String(e||"").trim();if(!i)return t;const n=document.createElement("span");n.style.cssText=`position:absolute;visibility:hidden;color:${i}`,this.renderRoot.append(n);const r=getComputedStyle(n).color||t;return n.remove(),r}_currentModeVisual(e=this._mode){const t=this._modeTransition.presented||this._modeTransitionVisual;if(t)return{...t,viewport:{...t.viewport,viewBox:{...t.viewport.viewBox}}};const i=this._stageEl;if(!i||i.clientWidth<=0||i.clientHeight<=0)return null;const n=this.renderRoot.querySelector(".editorchrome"),r=this._viewOr(this._baseVb()),o=this.renderRoot.querySelector(".hp-paper"),s=this.renderRoot.querySelector(".hp-backdrop"),a=this.renderRoot.querySelector(".zoomwrap"),l=a?getComputedStyle(a).filter:"",c=Number(/brightness\(([^)]+)\)/.exec(l)?.[1]);return{presentedMode:e,editorChromeHeight:"view"===e?0:n?.getBoundingClientRect().height||0,stageWidth:i.clientWidth,stageHeight:i.clientHeight,viewport:Bg(r,i.clientWidth),stageColor:getComputedStyle(i).backgroundColor||"rgb(255, 255, 255)",paperColor:o?getComputedStyle(o).fill:"rgb(255, 255, 255)",sceneBrightness:Number.isFinite(c)?c:1,architectureOpacity:"decor"===e?.35:1,backdropOpacity:s&&Number(getComputedStyle(s).opacity)||1,viewWeight:"view"===e?1:0,editorWeight:"view"===e?0:1,toolbarContentOpacity:"view"===e?0:1}}_viewForModeTarget(e,t,i,n,r){const o=Oi(this._baseVb(),n/r),s=Math.min(wv.ZOOM_MAX,Math.max(wv.ZOOM_MIN,e)),a=o.w/s,l=o.h/s,c=t??o.x+o.w/2,h=i??o.y+o.h/2;return this._clampView({x:c-a/2,y:h-l/2,w:a,h:l},o)}_targetStageColor(e){return"view"!==e?"rgb(255, 255, 255)":this._cssColor(this._stageBg(this._spaceDisplayForRender()),this._cssColor("var(--ha-card-background, var(--card-background-color, #111))","rgb(17, 17, 17)"))}_targetPaperColor(e){return"view"===e&&this._spaceModel()?.bg?this._cssColor("var(--ha-card-background, var(--card-background-color, #111))","rgb(17, 17, 17)"):"rgb(255, 255, 255)"}_targetBrightness(e){return 1}_applyModeTransitionFrame(e){e.targetMode===this._mode&&(this._modeTransitionVisual=e.presented,this._view={...e.presented.viewport.viewBox},this.requestUpdate())}_settleModeTransition(e){if(e.targetMode!==this._mode)return;const t=this._modeTransitionRequest;this._view={...e.to.viewport.viewBox},this._zoom=this._modeTransitionTargetZoom,this._modeTransitionVisual=null,this._modeTransitionPreparing=!1,this._lastValidStageSize=[e.to.stageWidth,e.to.stageHeight],"view"===this._mode&&(this._saveZoom(),this._viewModeSnap=null,this._modeTransitionEditorCamera=null),this.requestUpdate(),this.updateComplete.then(()=>{if(!this.isConnected||t!==this._modeTransitionRequest||this._modeTransitionBusy||e.targetMode!==this._mode)return;const i=this._stageEl;if(i&&i.clientWidth>0&&i.clientHeight>0&&(Math.abs(i.clientWidth-e.to.stageWidth)>.5||Math.abs(i.clientHeight-e.to.stageHeight)>.5)){const e=this._view;this._lastValidStageSize=[i.clientWidth,i.clientHeight],this._applyView(this._zoom,e?e.x+e.w/2:void 0,e?e.y+e.h/2:void 0),this.requestUpdate()}const n=this.renderRoot.activeElement;(!n||!n.isConnected||!!n.closest?.(".editorchrome, .stage"))&&this.renderRoot.querySelector(".modetab.active")?.focus?.({preventScroll:!0})})}_cancelModeTransition(e=!0){this._cancelCameraTransition(!1);const t=!!this._modeTransition.state;this._modeTransitionRequest++,this._modeTransitionPreparing=!1,this._modeTransitionForceAtomic=!1,this._modeTransition.cancel(e),e&&t||(this._modeTransitionVisual=null)}_adoptMode(e){e!==this._mode&&(this._clearRoomFocus(!0),this._resetDeviceHitState()),this._cancelModeTransition(!1),this._mode=e,this._isoProjectionSnapshot=null,"view"!==e&&(this._editorChromeMode=e)}_commitViewModeAtomic(e,t,i,n){if(this._modeTransitionPreparing=!1,this._modeTransitionVisual=null,this._modeTransitionForceAtomic=!1,this._zoom=t,e){const r=this._stageEl?.clientWidth||e.stageWidth,o=Math.max(1,e.stageHeight+e.editorChromeHeight);this._view=this._viewForModeTarget(t,i,n,r,o),this._lastValidStageSize=[r,o]}else this._view=null;this._viewModeSnap=null,this._modeTransitionEditorCamera=null,this._saveZoom(),this.requestUpdate()}_prepareModeTransition(e,t,i,n,r,o){this.updateComplete.then(()=>{if(!this.isConnected||e!==this._modeTransitionRequest||this._mode!==i)return void(e===this._modeTransitionRequest&&(this._modeTransitionPreparing=!1,this._modeTransitionVisual=null,this._modeTransitionForceAtomic=!1,this.requestUpdate()));const s=this.renderRoot.querySelector(".editorchrome-inner"),a="view"===i?0:s?.scrollHeight||0,l=Math.max(1,(this.panelHost?this.clientHeight:innerHeight)-ef(this.renderRoot,this._stageEl,this.panelHost)),c=this._stageEl?.clientWidth||t.stageWidth,h=this._viewForModeTarget(n,r,o,c,l),d={presentedMode:i,editorChromeHeight:a,stageWidth:c,stageHeight:l,viewport:Bg(h,c),stageColor:this._targetStageColor(i),paperColor:this._targetPaperColor(i),sceneBrightness:this._targetBrightness(i),architectureOpacity:"decor"===i?.35:1,backdropOpacity:"decor"===i&&"backdrop"!==this._decorTool?.5:1,viewWeight:"view"===i?1:0,editorWeight:"view"===i?0:1,toolbarContentOpacity:"view"===i?0:1};this._modeTransitionPreparing=!1;const u=this._modeTransitionForceAtomic;this._modeTransitionForceAtomic=!1,this._modeTransition.start(t,d,i,this._reducedMotion||u?0:220)})}get _hasFixedFloor(){return!!this._config&&Object.prototype.hasOwnProperty.call(this._config,"floor")}_fixedFloorState(e=this._model,t=this._loadOk){const i=this._config?.floor,n=function(e){if(!e.hasFloor)return{kind:"absent"};const t=e.floor;if("string"==typeof t)return t.length?e.spaceIds.includes(t)?{kind:"valid",id:t,source:"id"}:{kind:"invalid",reason:"unknown-id",value:t}:{kind:"invalid",reason:"empty-id",value:t};if("number"==typeof t){if(!Number.isFinite(t))return{kind:"invalid",reason:"non-finite-index",value:t};if(!Number.isInteger(t))return{kind:"invalid",reason:"fractional-index",value:t};if(t<0)return{kind:"invalid",reason:"negative-index",value:t};const i=e.spaceIds[t];return void 0===i?{kind:"invalid",reason:"out-of-range-index",value:t}:{kind:"valid",id:i,source:"index"}}return{kind:"invalid",reason:"invalid-type",value:t}}({spaceIds:e.map(e=>e.id),hasFloor:this._hasFixedFloor,floor:i});return!this._hasFixedFloor||t?n:"number"==typeof i?"valid"===n.kind||"invalid"===n.kind&&"out-of-range-index"===n.reason?{kind:"pending",value:i}:n:"valid"===n.kind||"invalid"===n.kind&&"unknown-id"!==n.reason?n:{kind:"pending",value:i}}_canCommitSpace(e,t=!1){if(t||!this._hasFixedFloor)return!0;const i=this._fixedFloorState();return"valid"===i.kind&&i.id===e}_commitSpace(e,t=!1){return!!this._canCommitSpace(e,t)&&(e!==this._space&&(this._clearRoomFocus(!0),this._resetDeviceHitState(),this._cancelDangerConfirm(),this._cancelCameraTransition(!1),this._clearTransientHover(!0),this._cancelDevicePressFeedback(),this._editorRuntime?._clearFurniturePreview()),this._space=e,this._isoProjectionSnapshot=null,!0)}_slideTo(e,t){if(e===this._space)return!0;if(!this._canCommitSpace(e))return!1;if(this._wallFaceBatch&&this._roomDialogCancel(),"plan"===this._mode&&"draw"===this._tool&&!this._finishWallChain())return!1;this._cancelModeTransition(!0);const i=window.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches;return this._commitSpace(e),this._path=[],this._clearPlanSnapHover(),this._clearOpeningPlacement(!0),this._tool="draw",this._activeWallChainId=null,this._activeWallChainPartitionIds=[],this._wallChainSegmentCms=[],this._closingWallCm=null,this._selId=null,this._physicalSel=null,this._editorSecondary?.closeForNavigation(),this._physicalDialog=null,this._physicalDrag=null,this._restoreZoom(),i||(this._slide=t,clearTimeout(this._slideTimer),this._slideTimer=window.setTimeout(()=>{this._slideTimer=void 0,this._slide="",this.requestUpdate()},190),this.requestUpdate()),!0}get _canReorderTabs(){return Zf({canEdit:this._canEdit,kiosk:this._kiosk,mode:this._mode,pointerType:"mouse",spaceCount:this._model.length,fixedFloor:this._hasFixedFloor})}_tabPointerDown(e,t){Zf({canEdit:this._canEdit,kiosk:this._kiosk,mode:this._mode,pointerType:e.pointerType,spaceCount:this._model.length,fixedFloor:this._hasFixedFloor})&&(yv(e),this._tabDragRelease=e=>this._tabPointerUp(e),window.addEventListener("pointerup",this._tabDragRelease),window.addEventListener("pointercancel",this._tabDragRelease),this._tabDrag={id:t,pointerId:e.pointerId,x:e.clientX,y:e.clientY,moved:!1,targetId:null,placement:null})}_tabDropTargetAt(e,t,i){const n=this._model.map(e=>e.id),r=n.indexOf(i);if(r<0)return null;const o=this.renderRoot.querySelectorAll('[data-hp="space-tab"]');for(const s of o){const o=s.dataset.id||"";if(!o||o===i)continue;const a=s.getBoundingClientRect();if(ea.right||ta.bottom)continue;const l=n.indexOf(o);return l<0?null:{targetId:o,placement:l=4)))return;var i,n;const r=this._tabDropTargetAt(e.clientX,e.clientY,t.id);t.moved&&t.targetId===r?.targetId&&t.placement===r?.placement||(this._tabDrag={...t,moved:!0,targetId:r?.targetId||null,placement:r?.placement||null})}_tabPointerUp(e){const t=this._tabDrag;if(t&&t.pointerId!==e.pointerId)return;const i="pointerup"===e.type&&t?.moved?this._tabDropTargetAt(e.clientX,e.clientY,t.id):null;"pointerup"===e.type&&t?.moved&&this._suppressNextTabClick(),this._endTabDrag(),t?.moved&&i&&this._commitTabOrder(t.id,i.targetId)}_endTabDrag(){this._tabDrag=null,this._tabDragRelease&&(window.removeEventListener("pointerup",this._tabDragRelease),window.removeEventListener("pointercancel",this._tabDragRelease),this._tabDragRelease=null)}_tabClick(e){if(this._tabSuppressClick)return this._tabSuppressClick=!1,clearTimeout(this._tabSuppressClickTimer),void(this._tabSuppressClickTimer=void 0);this._pickSpace(e)}_suppressNextTabClick(){this._tabSuppressClick=!0,clearTimeout(this._tabSuppressClickTimer),this._tabSuppressClickTimer=window.setTimeout(()=>{this._tabSuppressClick=!1,this._tabSuppressClickTimer=void 0},0)}_commitTabOrder(e,t){const i=this._serverCfg;if(!i||!this._canReorderTabs)return;const n=this._model.map(e=>e.id),r=function(e,t,i){const n=e.indexOf(t),r=e.indexOf(i);if(n<0||r<0||n===r)return e;const o=e.slice();return o.splice(n,1),o.splice(r,0,t),o}(n,e,t);if(r===n)return;const o=new Map(this._devices.map(e=>[String(e.id),String(e.area||"")])),s=function(e,t,i,n=()=>""){if(!i)return[];const r=[];for(const o of e){if(!o||!0===o.removed)continue;const e="string"==typeof o.id?o.id:"";if(!e)continue;if("string"==typeof o.space&&o.space)continue;const s=("string"==typeof o.area?o.area:"")||n(e)||"";s&&t[s]||r.push({id:e,space:i})}return r}(i.markers||[],Object.fromEntries(Object.entries(this._areaToSpace).map(([e,t])=>[e,t.space])),n[0]||"",e=>o.get(e)||"");if(s.length){const e=new Map(s.map(e=>[e.id,e.space]));for(const t of i.markers||[]){const i=e.get(String(t.id));i&&(t.space=i)}}i.spaces=function(e,t){const i=new Map(t.map((e,t)=>[e,t]));return e.map((e,t)=>({space:e,index:t})).sort((e,t)=>(i.get(String(e.space?.id))??Number.MAX_SAFE_INTEGER)-(i.get(String(t.space?.id))??Number.MAX_SAFE_INTEGER)||e.index-t.index).map(e=>e.space)}(i.spaces||[],r),this._saveConfig(),this._tabOrderWarned||(this._tabOrderWarned=!0,this._showToast(this._t("toast.space_order_changed")))}_pickSpace(e){if(this._endTabDrag(),e===this._space)return;const t=this._model.map(e=>e.id),i=t.indexOf(this._space),n=t.indexOf(e);this._navApplied=!0,this._showFar=!1,this._frame=null,this._slideTo(e,i>=0&&n0&&Date.now()>=this._cyclePausedUntil&&this._model.length>1&&this._zoom<=1.001){const e=this._model.map(e=>e.id),t=e.indexOf(this._space);this._slideTo(e[(t+1)%e.length],"left"),this._showKioskDots()}}_syncCycleTimer(){clearInterval(this._cycleTimer),this._cycleTimer=void 0,this.isConnected&&!this._hasFixedFloor&&this._config?.kiosk&&Number(this._config.cycle)>0&&(this._cycleTimer=window.setInterval(()=>this._cycleTick(),1e3*Number(this._config.cycle)))}get _editing(){return"plan"===this._mode||"devices"===this._mode||"decor"===this._mode}get _markup(){return"plan"===this._mode}get _wallUnionCache(){return this._wallUnionCacheValue}set _wallUnionCache(e){this._wallUnionCacheValue=e,null===e&&this._wallUnionPool.clear()}get _glowClipCache(){return this._glowRuntimeState.clipCache}get _glowGeometryWarnings(){return this._glowRuntimeState.geometryWarnings}get _glowFeatherUnits(){return this._glowRuntimeState.featherUnits}set _glowFeatherUnits(e){this._glowRuntimeState.featherUnits=e}get _glowRenderedSources(){return this._glowRuntimeState.renderedSources}get _glowLastAppearance(){return this._glowRuntimeState.lastAppearance}get _glowFeatherSuspendUntil(){return this._glowRuntimeState.featherSuspendUntil}set _glowFeatherSuspendUntil(e){this._glowRuntimeState.featherSuspendUntil=e}get _glowFeatherResumeTimer(){return this._glowRuntimeState.featherResumeTimer}set _glowFeatherResumeTimer(e){this._glowRuntimeState.featherResumeTimer=e}get _glowSourceSeq(){return this._glowRuntimeState.sourceSeq}set _glowSourceSeq(e){this._glowRuntimeState.sourceSeq=e}_activateSafeDayCycleOutline(){this._safeDayCycleOutline=!0,this._stageEl?.classList.add("hp-safe-daycycle-outline")}get _touchSequenceMultitouch(){return this._touchClickGuard.sequenceMultitouch}_syncDangerConfirmLocaleGate(){return this._config&&this.hass?dp(this,gp,kp(this.hass,this._config.language)):"ready"}_dangerConfirmMissingSpace(){const e=this._model;if(!e.length)return!1;const t=this._fixedFloorState(e);return"pending"!==t.kind&&"invalid"!==t.kind&&!this._spaceModel()}_syncVersionRecovery(){this._versionRecovery.update({frontendVersion:ev(iv),backendVersion:this._haIntegrationVersion,kiosk:!0===this._config?.kiosk,reducedMotion:this._reducedMotion})}_newContinuityController(){return new lc(()=>{this._resumeSettling="steady"!==this._continuity.state,this._continuityEpoch++,this.isConnected&&this.requestUpdate()})}get _labsIso(){return this._labs.active.includes("iso")}get _desiredProjection(){return"view"===this._mode&&this._labsIso&&"iso"===this._viewPreference[this._space]?"iso":"flat"}_saveViewPreference(){try{localStorage.setItem(uv,JSON.stringify(this._viewPreference))}catch{}}_logicalViewCenter(e){const t=this._view;if(!t)return null;const i=[t.x+t.w/2,t.y+t.h/2],n="iso"===e?cf(i):i;return{x:n[0],y:n[1]}}_convertProjectionView(e,t){if(e===t)return;this._clearRoomFocus(!0);const i=this._logicalViewCenter(e);this._view=null;const n=i?"iso"===t?lf([i.x,i.y],0):[i.x,i.y]:null;this._applyView(this._zoom,n?.[0],n?.[1]),this._warmPatch({vp:this._warmViewportState()}),this.requestUpdate()}_setProjection(e){if(!this._labsIso||"view"!==this._mode)return;const t=this._effectiveProjection();if(this._viewPreference={...this._viewPreference,[this._space]:e},"iso"===e){this._ensureIsoSceneRuntime();const e=this._isoSceneKey();e&&this._isoFallback.delete(e),this._isoFallback.delete(`${this._space}|no-borders`),this._clearIsoInvalidFallback()}this._saveViewPreference(),this._isoProjectionSnapshot=null;const i=this._effectiveProjection();this._convertProjectionView(t,i)}_hashSpace(){return Ff(window.location.hash||"")}connectedCallback(){this._connectedPath=location.pathname,this._routeDepartureHandled=!1,this._configReloadAuthority.observeContext(Vu(this)),window.addEventListener("location-changed",this._onLocationChanged),window.addEventListener("popstate",this._onLocationChanged),this._continuityDisposed&&(this._continuity=this._newContinuityController(),this._continuityDisposed=!1,this._continuityPaintToken=-1);const e=dg(this.ownerDocument);var t;void 0!==e&&(this._glowScreenBlend=e),this._continuityUnsub?.(),this._continuityUnsub=sc(this.ownerDocument,this._pageVisibility),this._languageFailureUnsub?.(),this._languageFailureUnsub=function(...e){return()=>{for(const t of e)t()}}((t=()=>{this._showToast(this._t("toast.locale_load_failed"))},mp.add(t),()=>mp.delete(t)),function(e){return Il.add(e),()=>{Il.delete(e)}}(()=>this._showToast(this._t("toast.furniture_art_load_failed")))),super.connectedCallback(),this._summarySlot.connect(),this._ensureLiveRuntime().catch(()=>this.requestUpdate()),this._pointerModality.connect(this.ownerDocument.defaultView);const i=this.ownerDocument.defaultView?.MutationObserver;i&&(this._pointerHoverObserver=new i(e=>{let t=!1;for(const i of e){for(const e of i.addedNodes)this._syncPointerHoverSubtree(e);const e=e=>{if(e.nodeType!==Node.ELEMENT_NODE)return!1;const t=e;return t.matches(".devlayer, .devlayer *")||!!t.querySelector?.(".devlayer")};(e(i.target)||[...i.addedNodes,...i.removedNodes].some(e))&&(t=!0)}t&&this._invalidateDeviceHitGeometry()}),this._pointerHoverObserver.observe(this.renderRoot,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style","data-id"]})),this._motionMedia=window.matchMedia?.("(prefers-reduced-motion: reduce)"),this._reducedMotion=!!this._motionMedia?.matches,this._motionMedia?.addEventListener?.("change",this._onMotionChange),this._syncVersionRecovery(),this._versionRecovery.connect(),hg(this.ownerDocument).then(e=>{e!==this._glowScreenBlend&&(this._glowScreenBlend=e,this.isConnected&&this.requestUpdate())}),this.hass&&this._ensureHaRegistryAuthority(),window.addEventListener("keydown",this._keyHandler),this._signer.start(()=>this.hass,()=>this._referencedContentUrls()),this._syncCycleTimer(),window.addEventListener("hashchange",this._onHashChange),this._labsUnsub?.(),this._labsUnsub=function(e){Nf.add(e);const t=Bf();return"undefined"==typeof window&&e(t),()=>{Nf.delete(e)}}(this._onLabsSnapshot),this._labsIso&&this._ensureIsoSceneRuntime(),this._booting?this._bootWatch():this._bootFading&&(clearTimeout(this._bootTimer),this._bootTimer=window.setTimeout(()=>{this._bootFading=!1},220)),this._bootSoft&&(clearTimeout(this._bootSoftTimer),this._bootSoftTimer=window.setTimeout(()=>{this._bootSoft=!1},rv)),!this._loadOk&&this._serverCfg&&this.hass&&this._scheduleLoadRetry(),!this._warmSlot&&this._config&&this._warmAdopt(),this._loadOk&&this._ensureLiveSyncSubscriptions(),this._warmVp&&!this._warmRevivePending&&void 0===this._warmReviveTimer&&(this._warmRevivePending=!0,this._warmReviveTimer=window.setTimeout(()=>this._warmReviveDialog(),0)),this._warmLongReturn&&this._beginResumeSettle(),this._warmLongReturn=!1,this.requestUpdate()}disconnectedCallback(){this._versionRecovery.disconnect(),this._configReloadAuthority.invalidateLifecycle(),this._liveRt?.dispose(),this._radarLive.stop(),this._editorRuntime?._disposeLiveEditor(),this._clearRoomFocus(!0),this._cancelDangerConfirm(),this._connectedPath&&location.pathname!==this._connectedPath&&this._leaveCardRoute(),window.removeEventListener("location-changed",this._onLocationChanged),window.removeEventListener("popstate",this._onLocationChanged),this._continuityUnsub?.(),this._continuityUnsub=void 0,this._languageFailureUnsub?.(),this._languageFailureUnsub=void 0,this._motionMedia?.removeEventListener?.("change",this._onMotionChange),this._motionMedia=void 0,this._vacRaf&&(cancelAnimationFrame(this._vacRaf),this._vacRaf=0),this._refitRaf&&(cancelAnimationFrame(this._refitRaf),this._refitRaf=0),this._warmModeRequest=0,this._dayCycleTimer&&(clearInterval(this._dayCycleTimer),this._dayCycleTimer=0),this._summarySlot.disconnect(),this._dayCycleClockKey="",this._bootSettleRaf&&(cancelAnimationFrame(this._bootSettleRaf),this._bootSettleRaf=0),this._bootSettling=!1;for(const e of this._activityRt.values())clearTimeout(e.timer);window.removeEventListener("keydown",this._keyHandler),this._endTabDrag(),clearTimeout(this._tabSuppressClickTimer),this._tabSuppressClickTimer=void 0,this._tabSuppressClick=!1,clearInterval(this._cycleTimer),clearTimeout(this._kioskDotsTimer),clearTimeout(this._kioskHoldTimer),clearTimeout(this._reloadRetry),clearTimeout(this._loadRetryTimer),this._loadRetryTimer=void 0,this._connHooked?.removeEventListener?.("ready",this._onConnReady),this._connHooked?.removeEventListener?.("disconnected",this._onConnLost),this._connHooked?.removeEventListener?.("reconnect-error",this._onConnLost),this._connHooked=null,this._haRegistryRelease?.(),this._haRegistryRelease=void 0,this._haRegistryConnection=null,this._signer.dispose(),clearTimeout(this._toastTimer),clearTimeout(this._slideTimer),clearTimeout(this._editorRuntimeLoadingTimer),this._editorRuntimeLoadingTimer=void 0,this._editorRuntimeLoadingVisible=!1,this._modeTransition.dispose(),this._cameraTransition.dispose(),this._cameraTransitionFit=null,this._modeTransitionVisual=null,this._modeTransitionPreparing=!1,this._modeTransitionForceAtomic=!1,this._modeTransitionRequest++,this._slideTimer=void 0,this._slide="",clearTimeout(this._bootTimer),this._bootTimer=void 0,clearTimeout(this._bootSoftTimer),this._saveConfigDebounced.flush(),this._cancelDeviceDrag(),window.removeEventListener("hashchange",this._onHashChange),this._labsUnsub?.(),this._labsUnsub=void 0,clearTimeout(this._holdTimer),this._roViewport?.disconnect(),this._roViewport=void 0,this._roHdr?.disconnect(),this._roHdr=void 0,this._onWinResize&&(window.removeEventListener("resize",this._onWinResize),this._onWinResize=void 0),this._unsubCfg&&(this._unsubCfg(),this._unsubCfg=null),this._unsubLayout&&(this._unsubLayout(),this._unsubLayout=null),this._unsubVirtual&&(this._unsubVirtual(),this._unsubVirtual=null),this._unsubTrail&&(this._unsubTrail(),this._unsubTrail=void 0),this._liveSyncGeneration++,this._liveSyncAttempt=null,this._liveSyncConnection=null,clearTimeout(this._layoutSyncTimer),clearTimeout(this._duplicateColumnTimer),Fm(this._glowRuntimeState,this._glowRuntimeHost),this._warmSnapshot(),this._warmRevivePending=!1,clearTimeout(this._warmReviveTimer),this._warmReviveTimer=void 0,this._warmRelease(),this._clearPlanSnapHover(),this._clearOpeningPlacement(!0),this._editorRuntime?._clearFurniturePreview(),this._editorRuntime?._furnShiftDetach(),this._touchContacts.clear(),this._touchClickGuard.reset(),this._resetDeviceHitState(),this._clearTransientHover(!0),this._cancelDevicePressFeedback(),this._pointerHoverObserver?.disconnect(),this._pointerHoverObserver=void 0,this._pointerModality.disconnect(),this._editorSecondary?.reset(),this._resumeSettling=!1,this._continuityHistory=[...this._continuityHistory,...this._continuity.trace].slice(-80),this._continuity.dispose(),this._continuityDisposed=!0,super.disconnectedCallback()}_onKey(e){if("Escape"===e.key&&this._vacFit){if(this._vacFit.busy)return;return this._vacFit=null,this._showToast(this._t("vac.cal_cancelled")),void e.stopPropagation()}if("Escape"===e.key){if(this._tapConfirm)return void(this._tapConfirm=null);if(this._vacCalConfirm)return void(this._vacCalConfirm.busy||(this._vacCalConfirm=null));if(this._decorEraseConfirm)return void(this._decorEraseConfirm=null);if(this._openingInfo)return void(this._openingInfo=null);if(this._infoCard)return void this._closeInfoCard();if(this._rulesDialog)return void(this._rulesDialog=null);if(this._alignDialog)return this._alignDialog=null,void(this._preflightClipboardFallback=null);if(this._backupImportDialog)return void(this._backupImportDialog=null);if(this._backupExportDialog)return void(this._backupExportDialog=null);if(this._pdfDialog)return void(this._pdfDialog=!1);if(this._supportDialog)return void this._editorRuntime?._closeSupportDialog();if(this._settingsDialog)return void(this._settingsDialog=null);if(this._summary?.closeDialogIfIdle())return;if(this._markerDialog)return void this._closeMarkerDialog();if(this._deviceInbox)return void(this._deviceInbox=null);if(this._openingDialog)return void(this._openingDialog=null);if(this._physicalDialog)return void(this._physicalDialog=null);if(this._backdropDialog)return void(this._backdropDialog=null);if(this._decorShapeDialog)return void(this._decorShapeDialog=null);if(this._decorTextDialog)return void(this._decorTextDialog=null);if(this._spaceDialog&&!this._roomDialog)return this._spaceDialog=null,this._importQueue=[],void(this._importTotal=0);if(this._editorSecondary?.hasOpenGroup)return e.preventDefault(),void this._editorSecondary?.closeGroup(!0)}const t=e.composedPath?.()||[e.target],i=t.some(e=>e?.matches?.('input, textarea, select, [contenteditable="true"]')),n=t.some(e=>e?.classList?.contains?.("editor-secondary")),r=e.ctrlKey||e.metaKey,o=e.key.toLowerCase(),s=/^[a-z]$/.test(o),a="z"===o||!s&&"KeyZ"===e.code,l="y"===o||!s&&"KeyY"===e.code,c=r&&(a&&e.shiftKey||l),h=r&&a&&!e.shiftKey;if("decor"===this._mode){if((h||c)&&i)return;if(c)return e.preventDefault(),void this._redoGeometry();if(h)return e.preventDefault(),this._decorDraft?void(this._decorDraft=null):this._decorMove||this._dtDrag||this._bdDrag?void this._cancelDecorGesture():void this._undoGeometry();if(("Delete"===e.key||"Backspace"===e.key)&&this._decorSel&&!i&&!n)return e.preventDefault(),void this._decorDeleteSel();const t="ArrowLeft"===e.key?[-this._gridPitch,0]:"ArrowRight"===e.key?[this._gridPitch,0]:"ArrowUp"===e.key?[0,-this._gridPitch]:"ArrowDown"===e.key?[0,this._gridPitch]:null;return!t||r||e.altKey||"select"!==this._decorTool||!this._decorSel||!this._decorList.some(e=>e.id===this._decorSel)||this._decorDraft||this._decorMove||this._dtDrag||this._bdDrag||i||n||this._editorSecondaryDialogBlocked?void("Escape"===e.key&&(e.preventDefault(),this._decorDraft?this._decorDraft=null:this._decorMove||this._dtDrag||this._bdDrag?this._cancelDecorGesture():"furniture"===this._decorTool?(this._editorRuntime?._clearFurniturePreview(),this._editorRuntime?._furnShiftDetach(),this._furnPalette=null,this._furnCategory=null,this._decorTool="select"):this._decorSel?this._decorSel=null:"select"!==this._decorTool?this._decorTool="select":this._setMode("view"))):(e.preventDefault(),void this._decorNudge(t[0],t[1]))}if("devices"===this._mode){if((h||c)&&i)return;return c?(e.preventDefault(),void this._redoDevicePosition()):h?(e.preventDefault(),void this._undoDevicePosition()):void("Escape"===e.key&&this._deviceDrag&&(e.preventDefault(),this._cancelDeviceDrag()))}if(this._markup&&(!h&&!c||!i)){if(("Delete"===e.key||"Backspace"===e.key)&&this._physicalSel&&!i&&!n)return e.preventDefault(),void this._deletePhysicalSelection();if(c)return e.preventDefault(),void this._redoGeometry();if(h)return e.preventDefault(),this._resize?.dragging?void this._rszCancelDrag():this._wallFaceBatch?(this._roomDialogCancel(),void(this._activeWallChainId&&this._path.length>1?this._undoActiveWallPoint():this._undoPoint())):"draw"===this._tool&&this._path.length?void(this._activeWallChainId&&this._path.length>1?this._undoActiveWallPoint():this._undoPoint()):"split"===this._tool&&this._splitSel?.pts?.length?(this._splitSel={...this._splitSel,pts:this._splitSel.pts.slice(0,-1)},void(this._splitSel.pts.length||(this._cursorPt=null))):void this._undoGeometry();if("Escape"===e.key)return this._physicalDrag||this._physicalRotate?(e.preventDefault(),void this._cancelPhysicalGesture()):this._roomDialog?(e.preventDefault(),void this._roomDialogCancel()):"draw"===this._tool&&this._path.length?(e.preventDefault(),void this._finishWallChain()):this._physicalSel?(e.preventDefault(),void(this._physicalSel=null)):"resize"===this._tool?(e.preventDefault(),this._resize?.dragging?void this._rszCancelDrag():("exit-tool"===this._resize?.escapeIdle()&&(this._tool="draw"),void this.requestUpdate())):"split"===this._tool?(e.preventDefault(),void(this._splitSel?.pts?.length?(this._splitSel={...this._splitSel,pts:this._splitSel.pts.slice(0,-1)},this._splitSel.pts.length||(this._cursorPt=null)):this._splitSel?this._splitSel=null:this._tool="draw")):"merge"===this._tool?(e.preventDefault(),void(this._mergeSel?this._mergeSel=null:this._tool="draw")):this._wallDialog?(e.preventDefault(),void(this._wallDialog=null)):void("opening"!==this._tool&&"wallthick"!==this._tool&&"delroom"!==this._tool&&"column"!==this._tool||(e.preventDefault(),"opening"===this._tool&&this._clearOpeningPlacement(!0),this._tool="draw"))}}_undoPoint(){if(this._path.length)return this._contourClosed?(this._path=this._path.slice(0,-1),void(this._closingWallCm=null)):void(this._activeWallChainPartitionIds.length&&this._path.length>1?this._undoActiveWallPoint():this._path=this._path.slice(0,-1))}_undoActiveWallPoint(){const e=[...this._activeWallChainPartitionIds],t=e[e.length-1],i=this._spaceModel()?.partitions.find(e=>e.id===t),n=this._path[0]?[...this._path[0]]:null,r=this._path.slice(0,-1).map(e=>[...e]),o=this._wallChainSegmentCms.slice(0,-1),s=this._geometryHistory.undo();if(!s)return this._activeWallChainPartitionIds=[],this._wallChainSegmentCms=[],this._wallChainRedo=[],void(this._path=n?[n]:[]);this._applyGeometryState(s.before,!0)?(this._activeWallChainId||=`chain-${Date.now().toString(36)}`,this._activeWallChainPartitionIds=e.slice(0,-1),this._path=r.length?r:n?[n]:[],this._wallChainSegmentCms=o,i&&this._wallChainRedo.push({id:i.id,point:[...i.b],cm:i.cm}),this._clearPlanSnapHover(),this._showToast(this._t("history.undone",{name:s.name}))):this._geometryHistory.clear()}static async getConfigElement(){return await import("./editor-Dc4-BCoL.js"),document.createElement("houseplan-card-editor")}static getStubConfig(){return{type:"custom:houseplan-card"}}static _warmBootReset(e){for(const e of ov.values())for(const t of e)clearTimeout(t.evict);ov.clear(),av=e&&e>0?e:1e4}static _warmBootStats(){let e=0,t=0;const i=[];for(const n of ov.values())for(const r of n)e++,r.dlg&&(t++,i.push(r.dlg.kind));return{keys:ov.size,slots:e,dlgs:t,drafts:i}}setConfig(e){const t=this._config,i=!!t&&Object.prototype.hasOwnProperty.call(t,"floor");this._config={icon_size:2.5,show_temperature:!0,live_states:!0,show_signal:!0,...e};(i!==this._hasFixedFloor||t?.floor!==this._config.floor)&&(this._hashApplied=!1,this._navApplied=!1,this._warmVpArmed=!1),this._config.kiosk&&(this._booting=!1,this._bootFading=!1),!this._hasFixedFloor&&e.default_floor&&this._commitSpace(e.default_floor,!0);try{this._zoomBySpace=JSON.parse(localStorage.getItem(hv)||"{}")||{}}catch{this._zoomBySpace={}}try{const e=JSON.parse(localStorage.getItem(uv)||"{}")||{};this._viewPreference=Object.fromEntries(Object.entries(e).filter(e=>"flat"===e[1]||"iso"===e[1]))}catch{this._viewPreference={}}if(this._labs=Bf(),this.isConnected&&this._labsIso&&this._ensureIsoSceneRuntime(),!this._summary?.applyLocalScaleForCurrentIdentity())try{const e=JSON.parse(localStorage.getItem("houseplan_card_kiosk_v1")||"null");this._kioskScale={icon:jn(e?.icon),font:jn(e?.font)}}catch{}try{const e=JSON.parse(localStorage.getItem(cv)||"null");this._adoption.restoreCached(e)&&(this._seedDecorStyle(this._serverCfg),this._cfgEpoch++,this._virtualLights=Hh(e.virtual_lights,this._cfgRev),this._serverStorage=!0)}catch{}this._adoptInitialSpace(this._model,this._loadOk),"view"!==this._mode||this._view||(this._zoom=this._zoomBySpace[this._space]||1),this.isConnected&&(this._syncCycleTimer(),this._warmAdopt(),this._warmLongReturn&&this._beginResumeSettle(),this._warmLongReturn=!1),this._syncVersionRecovery()}_warmAdopt(){if(this._config?.kiosk)return;const e=Cf(this._config);if(this._warmKey===e&&this._warmSlot)return;this._warmSlot&&this._warmRelease();const t=this.parentNode,i=this._warmIdx(t),n=ov.get(e);if(!n||!n.length)return;const r=n.find(e=>e.owner===this._warmGen);if(r)return this._warmLongReturn=!!r.freed&&Date.now()-r.freed>=nc,clearTimeout(r.evict),r.evict=0,r.freed=0,r.live=!0,this._warmSlot=r,this._warmKey=e,r.frameFingerprint&&this._continuity.adoptCompleteFrame(r.frameFingerprint),void(!this._devices.length&&r.devices?.length&&(this._devices=[...r.devices]));const{slot:o,sure:s}=((e,t,i,n)=>{const r=e=>{const t=!!i&&e.place?.deref()===i;return t&&e.idx===n?4:e.live?0:t?3:2};let o=null,s=0,a=0,l=null;for(const i of e){if(i.owner===t)continue;l=i;const e=r(i);e<=0||(e>s?(o=i,s=e,a=1):e===s&&a++)}return!o||a>1?{slot:o||l,sure:!1}:{slot:o,sure:!0}})(n,this._warmGen,t,i);o&&(this._warmLongReturn=!!o.freed&&Date.now()-o.freed>=nc,this._booting=!1,this._bootFading=!1,this._hdrH=o.hdrH,this._bootSoft=!0,this.isConnected&&(clearTimeout(this._bootSoftTimer),this._bootSoftTimer=window.setTimeout(()=>{this._bootSoft=!1},rv)),this._warmKey=e,s?(clearTimeout(o.evict),o.evict=0,o.owner=this._warmGen,o.place=t?new WeakRef(t):null,o.idx=i,o.live=!0,this._warmSlot=o,this._warmVp=o.vp,o.frameFingerprint&&this._continuity.adoptCompleteFrame(o.frameFingerprint),!this._devices.length&&o.devices?.length&&(this._devices=[...o.devices]),this._warmAdoptViewport(this._config)):(this._warmSlot={owner:this._warmGen,path:location.pathname,place:t?new WeakRef(t):null,idx:i,live:!0,hdrH:o.hdrH,stageH:o.stageH,vp:null,frameFingerprint:"",devices:null,dlg:null,freed:0,evict:0},n.push(this._warmSlot),this._warmTrim(n)))}_warmIdx(e){const t=e?.children;if(!t)return-1;for(let e=0;e4;){const t=e.findIndex(e=>!e.live);if(t<0)break;clearTimeout(e[t].evict),e.splice(t,1)}}_warmScheduleEvict(e,t){if(clearTimeout(e.evict),!(e.dlg||e.vp&&"view"!==e.vp.mode))return;const i=e.freed,n=e.owner;e.evict=window.setTimeout(()=>{if(e.evict=0,e.freed!==i||e.owner!==n)return;var r;e.dlg=null,e.vp=(r=e.vp)&&"view"!==r.mode?{...r,mode:"view",zoom:r.snap?.space===r.space?r.snap.zoom:r.zoom,view:null,snap:null,tool:"draw",decorTool:"select",showHidden:!1,selId:null,rszSel:null,decorSel:null}:r,e.frameFingerprint="";const o=ov.get(t);if(!e.live&&o&&o.length>1){const t=o.indexOf(e);t>=0&&o.splice(t,1)}},av+250)}_warmAdoptViewport(e){const t=this._warmVp;if(!t||this._warmSlot?.path!==location.pathname)return void(this._warmVp=null);const i=this._fixedFloorState();if(this._hashApplied||!this._model.find(e=>e.id===t.space)||"valid"===i.kind&&i.id!==t.space||this._hasFixedFloor&&"valid"!==i.kind)return void(this._warmVp=null);this._commitSpace(t.space,!0),this._navApplied=!0;const n="view"!==t.mode&&this._canEdit&&!e.kiosk?t.mode:"view";this._adoptMode("view"),this._pendingNavMode="view"===t.mode||this._canEdit||e.kiosk?null:t.mode,this._zoom=t.zoom;const r=this._effectiveProjection(),o=r===t.projection&&this._labsIso===t.activeLabsIso;if(this._view=o&&t.view?{...t.view}:null,this._viewModeSnap=o&&t.snap?{...t.snap}:null,!o&&t.logicalCenter){const e="iso"===r?lf([t.logicalCenter.x,t.logicalCenter.y],0):[t.logicalCenter.x,t.logicalCenter.y];this._applyView(t.zoom,e[0],e[1])}var s;this._tool="opening"===(s=function(e){return"partition"===e?"draw":e}(s=t.tool))?"draw":"string"==typeof s&&Rf.has(s)?s:"draw",this._decorTool=t.decorTool,this._showHidden=t.showHidden,this._showFar!==t.showFar&&(this._showFar=t.showFar,this._frame=null),this._selId=t.selId,this._resize?.restoreSelection(t.rszSel),this._decorSel=t.decorSel,this._warmVpArmed=!0,"view"!==n&&this._requestMode(n,!1,!0)}_warmPatch(e,t=!1){if(this._config?.kiosk)return;const i=Cf(this._config);if(!this._warmSlot||this._warmKey===i){if(!this._warmSlot){if(!t)return;const e=this.parentNode;this._warmKey=i,this._warmSlot={owner:this._warmGen,path:location.pathname,place:e?new WeakRef(e):null,idx:this._warmIdx(e),live:!0,hdrH:this._hdrH,stageH:0,vp:null,frameFingerprint:"",devices:null,dlg:null,freed:0,evict:0};const n=ov.get(i)||[];for(n.push(this._warmSlot),ov.set(i,n),this._warmTrim(n);ov.size>8;){const e=ov.keys().next().value;if(void 0===e||e===i)break;for(const t of ov.get(e)||[])clearTimeout(t.evict);ov.delete(e)}}Object.assign(this._warmSlot,e)}}_warmViewportState(){const e=this._effectiveProjection();return{space:this._space,mode:this._mode,projection:e,activeLabsIso:this._labsIso,logicalCenter:this._logicalViewCenter(e),zoom:this._zoom,view:this._view?{...this._view}:null,snap:this._viewModeSnap?{...this._viewModeSnap}:null,tool:this._tool,decorTool:this._decorTool,showHidden:this._showHidden,showFar:this._showFar,selId:this._selId,rszSel:this._resize?.selectedRoomId,decorSel:this._decorSel}}_warmDialogState(){const e=(e,t)=>({kind:e,space:this._space,mode:this._mode,data:t});return this._tapConfirm||this._alignDialog||this._mergeDialog||this._importDialog||this._backupExportDialog||this._backupImportDialog?null:this._openingInfo?e("openingInfo",this._openingInfo.id):this._infoCard?e("info",this._infoCard.id):this._rulesDialog?this._rulesDialog.busy?null:e("rules",this._rulesDialog):this._settingsDialog?this._settingsDialog.busy?null:e("settings",this._settingsDialog):this._markerDialog?this._markerDialog.busy?null:e("marker",this._markerDialog):this._openingDialog?e("opening",this._openingDialog):this._backdropDialog?e("backdrop",this._backdropDialog):this._decorShapeDialog?e("decorShape",this._decorShapeDialog):this._decorTextDialog?e("decorText",this._decorTextDialog):this._roomDialog?e("room",{editId:this._roomEditId,fill:this._roomFill,customFill:this._roomCustomFill,tempMin:this._roomTempMin,tempMax:this._roomTempMax,tempSrc:this._roomTempSrc,humSrc:this._roomHumSrc,srcOpen:this._roomSrcOpen,srcFilter:this._roomSrcFilter,nameScale:this._roomNameScale,labelScale:this._roomLabelScale,areaSel:this._areaSel,nameSel:this._nameSel,pendingSplit:this._pendingSplit,wallFaceBatch:this._wallFaceBatch,path:this._path}):this._spaceDialog?this._spaceDialog.busy?null:e("space",this._spaceDialog):null}_warmSnapshot(){if(this._booting||this._config?.kiosk||"steady"!==this._continuity.state)return;const e={vp:this._warmViewportState(),frameFingerprint:this._continuity.frameFingerprint,devices:this._devices,hdrH:this._hdrH};if(this._warmRevivePending||(e.dlg=this._warmDialogState()),this.isConnected&&this._warmSlot?.owner===this._warmGen){const t=this.parentNode;e.place=t?new WeakRef(t):null,e.idx=this._warmIdx(t)}this._warmPatch(e)}_warmReviveDialog(){const e=this._warmSlot;if(this._warmReviveTimer=void 0,!e||!e.dlg)return void(this._warmRevivePending=!1);const t=e.dlg,i=e.freed;if(t.mode===this._mode||"view"===t.mode||this._warmVp?.mode!==t.mode||this._editorRuntime){if(this._warmRevivePending=!1,e.dlg=null,e.freed=0,clearTimeout(e.evict),e.evict=0,i&&!(Date.now()-i>av)&&t.space===this._space&&t.mode===this._mode){switch(t.kind){case"space":this._spaceDialog={...t.data,busy:!1,savedBusy:!1};break;case"marker":this._markerDialog={...t.data,busy:!1};break;case"settings":this._settingsDialog={...t.data,busy:!1};break;case"rules":this._rulesDialog={...t.data,busy:!1};break;case"opening":this._openingDialog={...t.data};break;case"backdrop":this._backdropDialog={...t.data};break;case"decorShape":this._decorShapeDialog={...t.data};break;case"decorText":{this._decorTextDialog={...t.data};const e=String(this._decorTextDialog?.text??"").length;this._decorTextSelection={start:e,end:e};break}case"room":{const e=t.data;this._roomEditId=e.editId,this._roomFill=e.fill,this._roomCustomFill=e.customFill||null,this._roomTempMin=e.tempMin||"",this._roomTempMax=e.tempMax||"",this._roomTempSrc=e.tempSrc,this._roomHumSrc=e.humSrc,this._roomSrcOpen=e.srcOpen,this._roomSrcFilter=e.srcFilter,this._roomNameScale=e.nameScale,this._roomLabelScale=e.labelScale,this._areaSel=e.areaSel,this._nameSel=e.nameSel,this._pendingSplit=e.pendingSplit,this._wallFaceBatch=e.wallFaceBatch||null,this._path=e.path,this._wallFaceBatch&&(this._activeWallChainId=`chain-${Date.now().toString(36)}`,this._activeWallChainPartitionIds=[...this._wallFaceBatch.activePartitionIds],this._wallChainSegmentCms=[...this._wallFaceBatch.activeCms]),this._roomDialog=!0;break}case"info":{const e=this._devices.find(e=>e.id===t.data);e&&(this._infoCard=e);break}case"openingInfo":{const e=(this._curSpaceCfg?.openings||[]).find(e=>e.id===t.data);e&&(this._openingInfo=e);break}}this.requestUpdate()}}else this._warmRevivePending=!0}_cacheSnapshot(){if(this._serverCfg)try{this._virtualLights=function(e,t,i){if(e.configRev===i)return e;const n=new Set((Array.isArray(t?.markers)?t.markers:[]).filter(qh).map(e=>e.id));return{...e,configRev:i,off:new Set([...e.off].filter(e=>n.has(e)))}}(this._virtualLights,this._serverCfg,this._cfgRev);const e=this._adoption.snapshot(function(e){return{rev:e.rev,config_rev:e.configRev,off:[...e.off].sort()}}(this._virtualLights));e&&localStorage.setItem(cv,JSON.stringify(e))}catch{}}_beginContinuityCandidate(e,t,i="plan"){return this._booting&&!this._continuity.hasCompleteFrame?this._continuity.token:(this._continuityDataReady=t,this._continuityPaintToken=-1,this._stagedDeviceSnapshotToken=-1,this._resumeSettling=!0,this._continuity.beginCandidate(e,i))}_continuityStageValid(){const e=this._stageEl;return!!e&&e.clientWidth>0&&e.clientHeight>0}_versionReloadSafetySnapshot(){return Sg(this)}_continuityAssetsReady(){if(!this._model.length)return!1;const e=this._model.length?this._spaceModel():null;return!e?.bg?.href||this._signer.isReady(this.hass,e.bg.href)}_initialSpaceSelection(e,t=this._loadOk){const i=this._fixedFloorState(e,t);return"valid"===i.kind?{id:i.id,source:"fixed"}:this._hasFixedFloor?{id:null,source:"none"}:function(e){const t=new Set(e.spaceIds.filter(e=>!!e));if(!t.size)return{id:null,source:"none"};const i=[["hash",!1===e.acceptHash?null:e.hashSpace],["current",e.preserveCurrent?e.currentSpace:null],["saved",e.savedSpace],["default",e.defaultSpace],["first",e.spaceIds[0]]];for(const[e,n]of i)if(n&&t.has(n))return{id:n,source:e};return{id:null,source:"none"}}({spaceIds:e.map(e=>e.id),hashSpace:this._hashSpace(),acceptHash:!this._hashApplied,currentSpace:this._space,preserveCurrent:this._hashApplied||this._navApplied||this._warmVpArmed,savedSpace:this._savedNav()?.space,defaultSpace:this._config?.default_floor})}_adoptInitialSpace(e,t=this._loadOk){const i=this._initialSpaceSelection(e,t);return i.id?(this._commitSpace(i.id,!0),"hash"===i.source&&(this._hashApplied=!0),"saved"===i.source&&(this._navApplied=!0),i):i}_candidateBackdrop(e,t=this._space){const i=el(e),n=this._fixedFloorState(i,!0);if(this._hasFixedFloor&&"valid"!==n.kind)return"";const r=this._initialSpaceSelection(i,!0).id||(i.some(e=>e.id===t)?t:i[0]?.id);return i.find(e=>e.id===r)?.bg?.href||""}_visualFrameFingerprint(){const e=this._stageEl,t=e?[e.clientWidth,e.clientHeight]:[0,0];return hc([this._cfgRev,this._adoption.currentConfigFingerprint(),this._layoutRev,this._adoption.currentLayoutFingerprint(),this._space,this._mode,this._view,t,this._glowScreenBlend?"screen":"normal",this.hass?.themes?.darkMode??this.hass?.themes?.default_theme??""])}_settleContinuityFrame(){if(this._booting||!this._continuityStageValid())return;if(!this._continuity.hasCompleteFrame&&"steady"===this._continuity.state)return void(this._continuityAssetsReady()&&(this._renderSnapshotAt=Date.now(),this._continuity.markCompleteFrame(this._visualFrameFingerprint())));if(!this._continuityDataReady)return;if(!["holding","offline-stale","overlay-pending","overlay-visible","candidate-ready"].includes(this._continuity.state))return;const e=this._continuity.token;if(this._candidateDeviceSnapshot&&this._candidateDeviceSnapshot!==this._visibleDeviceSnapshot&&this._stagedDeviceSnapshotToken!==e)return this._stagedDeviceSnapshotToken=e,void this.requestUpdate();this._continuityPaintToken!==e&&(this._continuityPaintToken=e,this._continuity.candidateReady(e)&&this._continuity.commitAfterPaint(e,{updateComplete:()=>this.updateComplete,stageValid:()=>this.isConnected&&this._continuityStageValid(),assetsReady:()=>this._continuityAssetsReady(),frameFingerprint:()=>this._visualFrameFingerprint()}).then(t=>{t&&e===this._continuity.token?(this._resumeSettling=!1,this._renderSnapshotAt=Date.now(),this._candidateDeviceSnapshot&&(this._visibleDeviceSnapshot=this._candidateDeviceSnapshot),this._candidateDeviceSnapshot=null,this._stagedDeviceSnapshotToken=-1,this._warmSnapshot()):e===this._continuity.token&&(this._continuityPaintToken=-1,this._stagedDeviceSnapshotToken=-1,this._candidateDeviceSnapshot=null,this.requestUpdate())}))}_onBackdropLoaded(e,t){this._signer.markLoaded(this.hass,e,t),this._continuity.note("asset-ready"),this._continuityPaintToken=-1,"steady"!==this._continuity.state&&this.requestUpdate()}_renderRecoveryOverlay(){if(!this._continuity.overlayVisible&&"recovery-error"!==this._continuity.state)return G;const e="connection"===this._continuity.recoveryReason;return j`
    svg{position:absolute;inset:0;width:100%;height:100%;display:block;z-index:1;}.hp-static-stage>.hp-paper-outline-svg{z-index:0;overflow:visible;}.hp-paper{fill:var(--ha-card-background,var(--card-background-color,#111));stroke:none;}.wallbody-fill{fill:var(--wall-fill,#ffffff);fill-opacity:var(--wall-fill-op,1);fill-rule:evenodd;stroke:none;pointer-events:none;}.wallbody{fill:url(#hp-wall-hatch);fill-rule:evenodd;stroke:var(--room-stroke,var(--hp-muted,#607d8b));stroke-width:calc(0.6px * var(--hp-cell-visual-scale,1));pointer-events:none;}.wallbody.solid{fill:none;}.hp-static-stage .devlayer{position:absolute;inset:0;z-index:2;}.hp-static-foot{padding:8px 12px 12px;pointer-events:auto;}.hp-static-btn{width:100%;padding:9px 14px;border:none;border-radius:10px;background:var(--primary-color,#3ea6ff);color:var(--text-primary-color,#fff);font-size:14px;font-weight:600;cursor:pointer;}:host([data-pointer-hover]) .hp-static-btn:hover{filter:brightness(1.08);}.hp-static-error{padding:24px;text-align:center;color:var(--secondary-text-color,#9aa4ad);}`],customElements.get("houseplan-space-card")||customElements.define("houseplan-space-card",_g),window.customCards=window.customCards||[],window.customCards.find(e=>"houseplan-space-card"===e.type)||window.customCards.push({type:"houseplan-space-card",name:"House Plan — Space (static)",description:"Read-only live schematic of a single houseplan space, with a deep-link button.",preview:!1,documentation:"https://github.com/Matysh/houseplan-card"});const mg=o`:host{--hp-editor-tray-bg-fallback:color-mix(in srgb,var(--card-background-color,var(--hp-bg)) 94%,var(--hp-line));--hp-editor-tray-bg:color-mix(in srgb,var(--card-background-color,var(--hp-bg)) 86%,transparent);--hp-editor-tray-border:color-mix(in srgb,var(--hp-line) 82%,var(--hp-accent));--hp-editor-tray-blur:8px;--hp-editor-tray-shadow:var(--shadow-2);}.editor-secondary-host{position:absolute;inset:var(--sp-2) var(--sp-4) auto;z-index:70;display:flex;justify-content:flex-end;pointer-events:none;}.editor-secondary-host.kind-palette,.editor-secondary-host.kind-group{justify-content:flex-start;}.editor-secondary{pointer-events:none;max-width:100%;display:flex;align-items:center;gap:var(--sp-3);padding:var(--sp-3) var(--sp-4);color:var(--hp-txt);background:var(--card-background-color,var(--hp-bg));background:var(--hp-editor-tray-bg-fallback);border:1px solid var(--hp-line);border-color:var(--hp-editor-tray-border);border-radius:var(--rad-l);box-shadow:var(--hp-editor-tray-shadow);opacity:0;visibility:hidden;transform:translateY(-4px);transition:opacity 0.1s ease,transform 0.1s cubic-bezier(0.2,0.7,0.2,1),visibility 0s linear 0.1s;touch-action:auto;}.editor-secondary-host.open .editor-secondary{pointer-events:auto;opacity:1;visibility:visible;transform:translateY(0);transition-duration:0.14s,0.14s,0s;transition-delay:0s;}.editor-secondary-host.blocked .editor-secondary{pointer-events:none;}@supports ((backdrop-filter:blur(1px)) or (-webkit-backdrop-filter:blur(1px))){.editor-secondary{background:var(--hp-editor-tray-bg);-webkit-backdrop-filter:blur(var(--hp-editor-tray-blur));backdrop-filter:blur(var(--hp-editor-tray-blur));}}.editor-secondary-content,.editor-group-items{display:flex;align-items:center;gap:var(--sp-3);min-width:0;}.editor-context-label{max-width:14rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding-inline-end:var(--sp-4);border-inline-end:1px solid var(--hp-line);color:var(--hp-muted);font-size:var(--fs-s);}.editor-secondary.kind-palette{width:min(760px,100%);align-items:stretch;padding:0;overflow:hidden;}.editor-secondary.kind-palette .editor-secondary-content,.editor-secondary.kind-palette .furnpalette{width:100%;}.editor-secondary.kind-palette .furnpalette{max-height:38vh;border:0;background:transparent;}.editor-group-launcher .group-chevron{--mdc-icon-size:16px;transition:transform 0.14s ease;}.editor-group-launcher[aria-expanded="true"] .group-chevron{transform:rotate(180deg);}.editor-secondary .bdhint{font-size:var(--fs-s);color:var(--hp-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}.editor-secondary .dfill{display:inline-flex;align-items:center;gap:var(--sp-2);font-size:var(--fs-s);cursor:pointer;}.editor-secondary .dfill input[type="checkbox"]{width:16px;height:16px;flex:none;margin:0;padding:0;}.editor-secondary hp-color-opacity{flex:0 0 auto;}.editor-secondary input{width:74px;background:transparent;border:1px solid var(--hp-line);color:var(--hp-txt);border-radius:var(--rad-s);padding:var(--sp-3) var(--sp-4);font-size:var(--fs-m);}.editor-secondary label,.editor-secondary .hint{color:var(--hp-muted);font-size:var(--fs-s);}.editor-secondary .drawwall{display:inline-flex;align-items:center;gap:var(--sp-3);white-space:nowrap;}.editor-secondary .drawwall input{width:4.2em;}.editor-secondary .drawwall .opl{color:var(--hp-muted);font-size:var(--fs-s);}@container (min-width:560px) and (max-width:899px){.editor-secondary-content,.editor-group-items{flex-wrap:wrap;justify-content:flex-end;}}@container (max-width:559px){.editor-secondary-host{inset-inline:var(--sp-4);}.editor-secondary{max-width:100%;}.editor-secondary-content,.editor-group-items{overflow-x:auto;scrollbar-width:thin;}.editor-secondary-content>*,.editor-group-items>*{flex:none;}.editor-context-label{display:none;}}@media (prefers-reduced-motion:reduce){.editor-secondary{transition:none;}.editor-group-launcher .group-chevron{transition:none;}}`;class gg{constructor(e=50){this._undo=[],this._redo=[],this._limit=Math.max(30,Math.floor(e))}get canUndo(){return this._undo.length>0}get canRedo(){return this._redo.length>0}get undoName(){return this._undo[this._undo.length-1]?.name??null}get redoName(){return this._redo[this._redo.length-1]?.name??null}get size(){return this._undo.length}push(e){this._undo.push(e),this._undo.length>this._limit&&this._undo.splice(0,this._undo.length-this._limit),this._redo=[]}undo(){const e=this._undo.pop()??null;return e&&this._redo.push(e),e}redo(){const e=this._redo.pop()??null;return e&&this._undo.push(e),e}removeWhere(e){const t=this._undo.length,i=this._redo.length;return this._undo=this._undo.filter(t=>!e(t)),this._redo=this._redo.filter(t=>!e(t)),t+i-this._undo.length-this._redo.length}clear(){this._undo=[],this._redo=[]}}function fg(e,t){const i=e[t];return i&&Number.isFinite(i.x)&&Number.isFinite(i.y)?{x:i.x,y:i.y,..."string"==typeof i.s?{s:i.s}:{}}:null}function vg(e,t,i){if(null===i){if(!(t in e))return e;const i={...e};return delete i[t],i}const n={...e[t]||{}};delete n.x,delete n.y,delete n.s;const r={...n,x:i.x,y:i.y,...void 0!==i.s?{s:i.s}:{}};return{...e,[t]:r}}const yg="houseplan-card:version-reload-target:v1";function bg(e){if("string"!=typeof e)return null;return e.trim()||null}class wg{constructor(e){this.hooks=e,this._input={frontendVersion:null,backendVersion:null,kiosk:!1,reducedMotion:!1},this._relation={kind:"unknown"},this._banner=null,this._connected=!1,this._attemptTarget=null,this._attemptState=null,this._noticeToken=0}get relation(){return this._relation}get banner(){return this._banner}get hasCurrentMismatchNotice(){return"mismatch"===this._relation.kind&&"visible"===this._banner?.phase}connect(){this._connected||(this._connected=!0,this._attemptTarget=null,this._attemptState=null,this._reconcile())}disconnect(){(this._connected||this._banner)&&(this._connected=!1,this._cancelTimer(),this._banner&&(this._banner=null,this.hooks.changed()))}update(e){const t={frontendVersion:bg(e.frontendVersion),backendVersion:bg(e.backendVersion),kiosk:!0===e.kiosk,reducedMotion:!0===e.reducedMotion},i=function(e,t){const i=bg(e),n=bg(t);return i&&n?i===n?{kind:"equal",frontend:i,backend:n}:{kind:"mismatch",frontend:i,backend:n}:{kind:"unknown"}}(t.frontendVersion,t.backendVersion),n=!((e,t)=>e.frontendVersion===t.frontendVersion&&e.backendVersion===t.backendVersion&&e.kiosk===t.kiosk&&e.reducedMotion===t.reducedMotion)(this._input,t)||!((e,t)=>e.kind===t.kind&&("unknown"===e.kind||"unknown"!==t.kind&&e.frontend===t.frontend&&e.backend===t.backend))(this._relation,i);this._input=t,this._relation=i,n&&this._reconcile()}finishBannerExit(e){this._banner&&"leaving"===this._banner.phase&&this._banner.token===e&&(this._banner=null,this.hooks.changed())}_reconcile(){if(this._cancelTimer(),!this._connected||"mismatch"!==this._relation.kind)return this._attemptTarget=null,this._attemptState=null,void this._hideBanner();if(!this._input.kiosk)return this._attemptTarget=null,this._attemptState=null,void this._showBanner(this._relation.frontend,this._relation.backend);const e=this._relation.backend;if(this._attemptTarget===e&&null!==this._attemptState||(this._attemptTarget=e,this._attemptState=function(e,t){try{const i=e();return i?i.getItem(yg)===t?"attempted":"fresh":"unavailable"}catch{return"unavailable"}}(this.hooks.storage,e)),"fresh"===this._attemptState)return this._hideBanner(),void this._armTimer();this._showBanner(this._relation.frontend,e)}_armTimer(){this._connected&&void 0===this._timer&&"mismatch"===this._relation.kind&&this._input.kiosk&&"fresh"===this._attemptState&&(this._timer=this.hooks.clock.setTimeout(()=>{this._timer=void 0,this._tick()},250))}_cancelTimer(){void 0!==this._timer&&(this.hooks.clock.clearTimeout(this._timer),this._timer=void 0)}_tick(){if(!this._connected||"mismatch"!==this._relation.kind||!this._input.kiosk||"fresh"!==this._attemptState)return;if(!function(e){return e.connected&&e.initialFrameSettled&&e.viewOnly&&e.surfacesIdle&&e.configWritesIdle&&e.physicalWritesIdle&&e.layoutWritesIdle&&e.gesturesIdle&&e.interactionPauseElapsed&&e.baseZoom}(this.hooks.safety()))return void this._armTimer();const e=this._relation.backend,t=function(e,t){try{const i=e();return i?i.getItem(yg)===t?"attempted":(i.setItem(yg,t),"claimed"):"unavailable"}catch{return"unavailable"}}(this.hooks.storage,e);if(this._attemptTarget=e,this._attemptState="claimed"===t?"attempted":t,"claimed"===t){this._showBanner(this._relation.frontend,e);try{this.hooks.reload()}catch{}}else this._showBanner(this._relation.frontend,e)}_showBanner(e,t){"visible"===this._banner?.phase&&this._banner.frontend===e&&this._banner.backend===t||(this._banner={frontend:e,backend:t,phase:"visible",token:++this._noticeToken},this.hooks.changed())}_hideBanner(){if(this._banner)return this._input.reducedMotion?(this._banner=null,void this.hooks.changed()):void("leaving"!==this._banner.phase&&(this._banner={...this._banner,phase:"leaving",token:++this._noticeToken},this.hooks.changed()))}}const kg=1;function xg(e,t){const i=t&&"object"==typeof t?t:{};e._haIntegrationVersion=bg(i.integration_version);const n=i.support_api;e._haSupportApi="number"==typeof n&&Number.isSafeInteger(n)?n:null,e._haDecorAssetsApi=1===i.decor_assets_api?1:null,e._haSummaryPanelApi=1===i.summary_panel_api?1:null,e._haRadarStage1Api=1===i.radar_stage1_api?1:null,e._syncVersionRecovery()}function Sg(e){const t=e._stageEl,i=e._loadOk&&!e._loading&&e._continuityDataReady&&!e._resumeSettling&&!e._connectionWasLost&&!e._booting&&!e._bootFading&&!e._bootSettling&&!e._bootSoft&&e._continuity.hasCompleteFrame&&"steady"===e._continuity.state&&!e._continuity.overlayBlocksInteraction&&!!t&&t.clientWidth>0&&t.clientHeight>0,n=!(0!==e._pointers.size||0!==e._touchContacts.size||e._touchSequenceMultitouch||e._roomPointer||e._panStart||e._panLock||e._pinchStart||e._swipeStart||e._tabDrag||e._tabDragRelease||e._drag||e._deviceDrag||e._rlResize||e._resize?.dragging||e._physicalDrag||e._physicalRotate||e._opDrag||e._decorDraft||e._decorMove||e._dtDrag||e._bdDrag||e._furnTouchPending||e._compassDrag||e._viewportGestureDirty||e._devicePositionBusy||e._modeTransitionBusy||e._cameraTransition.active||e._slide||0!==e._warmModeRequest),r=!(e._editorSecondaryDialogBlocked||e._partitionDeleteDialog||e._roomDeleteDialog||e._backdropGuard||e._vacFit||e._editorSecondary?.hasOpenGroup||e._furnPalette||e._decorImagePalette);return{connected:e.isConnected,initialFrameSettled:i,viewOnly:!0===e._config?.kiosk&&"view"===e._mode&&!e._editing,surfacesIdle:r,configWritesIdle:0===e._writesPending&&!e._saveConfigDebounced.pending(),physicalWritesIdle:0===e._pendingPhysicalWrites.size,layoutWritesIdle:!e._persistLayout.pending()&&0===e._dirtyPos.size&&0===e._sentPos.size&&!e._devicePositionBusy,gesturesIdle:n,interactionPauseElapsed:Date.now()>=e._cyclePausedUntil,baseZoom:e._zoom<=1.001}}class $g{constructor(){this.seen=null,this.diagnosticsCache=null}observe(e,t,i,n){this.invalidateDiagnosticsForHass(e,t,i),this.intake(t,n)}intake(e,t){e&&this.seen!==e&&(this.seen=e,t())}invalidate(){this.diagnosticsCache=null}invalidateDiagnosticsForHass(e,t,i){this.diagnosticsCache&&(e?.entities!==t?.entities||e?.devices!==t?.devices||[...i?.entityIds||[]].some(i=>!!e?.states?.[i]!=!!t?.states?.[i]))&&this.invalidate()}diagnostics(e,t,i){if(this.diagnosticsCache)return this.diagnosticsCache;const n={active:0,ha_disabled:0,orphaned:0,unverified:0};for(const e of t)e.removed||"virtual"===e.binding||n[i(e.binding).kind]++;return this.diagnosticsCache={registry:ud(e),bindings:n},this.diagnosticsCache}}function Mg(e){const t=e;t._hassSequence++,t._renderSnapshotAt=Date.now(),t._continuity.note("hass-snapshot"),t._ensureHaRegistryAuthority(),t._planHassMemo=null,t._hookConnection(),!t._loadOk&&!t._loading&&t._loadTries<8&&t._loadFromServer(),t._maybeRebuildDevices(),t._vacTick(),t._activityTick()}function Rg(e){return!!e&&"object"==typeof e&&1===e.version}function Cg(e,t){const i=e.radar;return e.space===t&&!0!==e.hidden&&!0!==e.removed&&Rg(i)&&!0===i.enabled&&!1!==i.show_live}const Tg={ok:"radar.health_ok",off:"radar.health_off",stale:"radar.health_stale",partial:"radar.health_partial",restricted:"radar.health_restricted",incomplete:"radar.health_incomplete",position_unavailable:"radar.health_position_unavailable",unavailable:"radar.health_unavailable",needs_setup:"radar.health_needs_setup",inconsistent:"radar.health_inconsistent",unknown:"radar.health_unknown"};const Dg=e=>"number"==typeof e&&Number.isFinite(e);class Ag{constructor(e){this.host=e,this.frames=new Map,this.connection=null,this.space="",this.generation=0,this.expiryTimer=0,this.deadlines=new Map}sync(e,t){const i=this.host.hass?.connection;if(!t||!i||!this.host.isConnected)return void this.stop();if(this.unsubscribe&&this.connection===i&&this.space===e)return;this.stop(),this.connection=i,this.space=e;const n=++this.generation,r=i.subscribeMessage?.bind(i);"function"==typeof r&&Promise.resolve(r(e=>{if(n!==this.generation||!this.host.isConnected)return;const t=function(e){if(!e||"object"!=typeof e)return null;const t=e;if("string"!=typeof t.marker_id||"string"!=typeof t.server_session_id||!Number.isSafeInteger(t.seq)||"string"!=typeof t.health)return null;const i=Array.isArray(t.targets)?t.targets.slice(0,256).flatMap(e=>{if(!e||"object"!=typeof e)return[];const t=e;return"string"==typeof t.slot&&Dg(t.x)&&Dg(t.y)&&Dg(t.expires_at)&&Dg(t.reported_at)&&("bounded_latest"===t.pair_quality||"coherent"===t.pair_quality)?[{...t,included:!0===t.included,smooth:!0===t.smooth}]:[]}):[],n=Array.isArray(t.ranges)?t.ranges.slice(0,64).flatMap(e=>{if(!e||"object"!=typeof e)return[];const t=e;if(!("string"==typeof t.id&&Dg(t.x)&&Dg(t.y)&&Dg(t.radius)&&Dg(t.expires_at)&&Dg(t.reported_at)))return[];const i=Array.isArray(t.segments)?t.segments.slice(0,64).flatMap(e=>{if(!Array.isArray(e))return[];const t=e.slice(0,181).flatMap(e=>Array.isArray(e)&&2===e.length&&Dg(e[0])&&Dg(e[1])?[[e[0],e[1]]]:[]);return t.length>=2?[t]:[]}):void 0;return[{...t,...i?{segments:i}:{}}]}):[],r=Array.isArray(t.zones)?t.zones.slice(0,64).flatMap(e=>{if(!e||"object"!=typeof e)return[];const t=e;if("string"!=typeof t.id)return[];const i=t.state;if(null!==i&&"boolean"!=typeof i&&!Dg(i))return[];const n=Array.isArray(t.polygon)?t.polygon.slice(0,64).flatMap(e=>Array.isArray(e)&&2===e.length&&Dg(e[0])&&Dg(e[1])?[[e[0],e[1]]]:[]):[];return[{id:t.id,state:i,...n.length>=3?{polygon:n}:{}}]}):[];return{server_session_id:t.server_session_id,marker_id:t.marker_id,source_generation:"string"==typeof t.source_generation?t.source_generation:void 0,calibration_revision:"string"==typeof t.calibration_revision?t.calibration_revision:void 0,seq:t.seq,reported_at:Dg(t.reported_at)?t.reported_at:void 0,expires_at:Dg(t.expires_at)?t.expires_at:void 0,health:t.health,reported_presence:"boolean"==typeof t.reported_presence?t.reported_presence:null,complete:!0===t.complete,targets:i,ranges:n,zones:r}}(e);if(!t)return;if(!function(e,t){return!e||t.server_session_id!==e.server_session_id||t.source_generation!==e.source_generation||t.calibration_revision!==e.calibration_revision||t.seq>e.seq}(this.frames.get(t.marker_id),t))return;const i=function(e,t=Date.now()){if(!Dg(e.expires_at))return null;if(!Dg(e.reported_at))return Math.max(0,1e3*e.expires_at-t);const i=Math.max(0,1e3*(e.expires_at-e.reported_at)),n=Math.max(0,t-1e3*e.reported_at);return Math.max(0,i-n)}(t);"restricted"===t.health||"disabled"===t.health||0===i?(this.frames.delete(t.marker_id),this.deadlines.delete(t.marker_id)):(this.frames.set(t.marker_id,t),null==i?this.deadlines.delete(t.marker_id):this.deadlines.set(t.marker_id,this.monotonicNow()+i)),this.armExpiry(),this.host.requestUpdate()},{type:"houseplan/radar/subscribe",space_id:e})).then(e=>{n===this.generation&&this.host.isConnected?"function"==typeof e&&(this.unsubscribe=e):"function"==typeof e&&e()}).catch(()=>{n===this.generation&&this.stop()})}stop(){this.generation++,this.unsubscribe?.(),this.unsubscribe=void 0,this.connection=null,this.space="",clearTimeout(this.expiryTimer),this.expiryTimer=0,this.frames.size&&(this.frames.clear(),this.host.isConnected&&this.host.requestUpdate()),this.deadlines.clear()}armExpiry(){clearTimeout(this.expiryTimer);const e=this.monotonicNow(),t=[...this.deadlines.values()].filter(t=>t>e);if(!t.length)return;const i=Math.max(20,Math.min(...t)-e+10);this.expiryTimer=window.setTimeout(()=>{this.expiryTimer=0;let e=!1;const t=this.monotonicNow();for(const[i,n]of this.deadlines)n>t||(this.deadlines.delete(i),this.frames.delete(i),e=!0);this.armExpiry(),e&&this.host.isConnected&&this.host.requestUpdate()},i)}monotonicNow(){return globalThis.performance?.now?.()??Date.now()}}const Pg=Object.freeze({enabled:!1,z2mBaseTopics:Object.freeze([])});function Fg(e){if("string"!=typeof e)return null;const t=e.trim().replace(/^\/+|\/+$/g,"").replace(/\/{2,}/g,"/");return!t||t.length>180||/[#+\u0000-\u001f\u007f]/.test(t)?null:t}function zg(e){const t=e?.zigbee_topology;if(!t||"object"!=typeof t)return Pg;const i=t,n=Array.isArray(i.z2m_base_topics)?i.z2m_base_topics:Array.isArray(i.z2mBaseTopics)?i.z2mBaseTopics:[],r=new Set,o=[];for(const e of n){const t=Fg(e);if(t&&!r.has(t)&&(r.add(t),o.push(t),8===o.length))break}return{enabled:!0===i.enabled,z2mBaseTopics:o}}function Ig(e,t){const i={...e},n=t.z2mBaseTopics.map(Fg).filter(Boolean);return t.enabled||n.length?i.zigbee_topology={enabled:!0===t.enabled,z2m_base_topics:[...new Set(n)].slice(0,8)}:delete i.zigbee_topology,i}const Og={now:()=>performance.now(),requestFrame:e=>requestAnimationFrame(e),cancelFrame:e=>cancelAnimationFrame(e)},Eg=e=>Math.max(0,Math.min(1,e)),Ng=(e,t,i)=>e+(t-e)*i,Hg=(e,t,i)=>{const n=1-e;return 3*n*n*e*t+3*n*e*e*i+e*e*e},Lg=e=>{const t=Eg(e);if(0===t||1===t)return t;let i=0,n=1,r=t;for(let e=0;e<12;e++)r=(i+n)/2,Hg(r,.2,.2)0&&e.w>0?t/e.w:1,viewBox:{...e}}}function qg(e,t,i){const n=Math.max(1e-9,e.pixelsPerUnit),r=Math.max(1e-9,t/n),o=Math.max(1e-9,i/n);return{x:e.centerX-r/2,y:e.centerY-o/2,w:r,h:o}}function jg(e){const t=e.trim(),i=/^rgba?\(\s*([\d.]+)[, ]+([\d.]+)[, ]+([\d.]+)(?:\s*[,/]\s*([\d.]+))?\s*\)$/i.exec(t);if(i)return[Number(i[1]),Number(i[2]),Number(i[3]),null==i[4]?1:Number(i[4])];const n=/^#([0-9a-f]{6}|[0-9a-f]{8})$/i.exec(t)?.[1];return n?[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16),8===n.length?parseInt(n.slice(6,8),16)/255:1]:null}function Wg(e,t,i){const n=jg(e),r=jg(t);if(!n||!r)return i<.5?e:t;const o=Eg(i);return`rgba(${Math.round(Ng(n[0],r[0],o))}, ${Math.round(Ng(n[1],r[1],o))}, ${Math.round(Ng(n[2],r[2],o))}, ${Ng(n[3],r[3],o).toFixed(3)})`}class Ug{constructor(e,t=Og){this._hooks=e,this._clock=t,this._token=0,this._raf=0,this._state=null}get state(){return this._state}get active(){return"running"===this._state?.phase||"preparing"===this._state?.phase}get presented(){return this._state?.presented||null}start(e,t,i,n=220){this.cancel(!1);const r=++this._token,o=this._clock.now();if(this._state={token:r,phase:n<=0?"settling":"running",from:e,to:t,presented:n<=0?t:e,startedAt:o,duration:Math.max(0,n),targetMode:i},n<=0)return this._hooks.frame(this._state),this._hooks.settled(this._state),this._state=null,r;this._hooks.frame(this._state);const s=e=>{const t=this._state;if(!t||t.token!==r)return;const i=Eg((e-t.startedAt)/t.duration);t.presented=i>=1?t.to:function(e,t,i){const n=Lg(i),r=Ng(e.stageWidth,t.stageWidth,n),o=Ng(e.stageHeight,t.stageHeight,n),s=Math.max(1e-9,e.viewport.pixelsPerUnit),a=Math.max(1e-9,t.viewport.pixelsPerUnit),l={centerX:Ng(e.viewport.centerX,t.viewport.centerX,n),centerY:Ng(e.viewport.centerY,t.viewport.centerY,n),pixelsPerUnit:Math.exp(Ng(Math.log(s),Math.log(a),n))};return{presentedMode:n<.5?e.presentedMode:t.presentedMode,editorChromeHeight:Ng(e.editorChromeHeight,t.editorChromeHeight,n),stageWidth:r,stageHeight:o,viewport:{...l,viewBox:qg(l,r,o)},stageColor:Wg(e.stageColor,t.stageColor,n),paperColor:Wg(e.paperColor,t.paperColor,n),sceneBrightness:Ng(e.sceneBrightness,t.sceneBrightness,n),architectureOpacity:Ng(e.architectureOpacity,t.architectureOpacity,n),backdropOpacity:Ng(e.backdropOpacity,t.backdropOpacity,n),viewWeight:Ng(e.viewWeight,t.viewWeight,n),editorWeight:Ng(e.editorWeight,t.editorWeight,n),toolbarContentOpacity:Ng(e.toolbarContentOpacity,t.toolbarContentOpacity,n)}}(t.from,t.to,i),t.phase=i>=1?"settling":"running",this._hooks.frame(t),i<1?this._raf=this._clock.requestFrame(s):(this._raf=0,this._hooks.settled(t),this._state?.token===r&&(this._state=null))};return this._raf=this._clock.requestFrame(s),r}cancel(e=!0){this._raf&&this._clock.cancelFrame(this._raf),this._raf=0;const t=this._state;this._state=null,this._token++,t&&e&&(t.phase="settling",t.presented=t.to,this._hooks.frame(t),this._hooks.settled(t))}dispose(){this.cancel(!1)}}const Gg={now:()=>"undefined"!=typeof performance?performance.now():Date.now(),requestFrame:e=>"function"==typeof requestAnimationFrame?requestAnimationFrame(e):null,cancelFrame:e=>{"function"==typeof cancelAnimationFrame&&cancelAnimationFrame(e)}},Vg=e=>Number.isFinite(e);function Kg(e){return!!e&&Vg(e.zoom)&&e.zoom>0&&Vg(e.viewBox.x)&&Vg(e.viewBox.y)&&Vg(e.viewBox.w)&&e.viewBox.w>0&&Vg(e.viewBox.h)&&e.viewBox.h>0}function Yg(e){return{zoom:e.zoom,viewBox:{...e.viewBox}}}function Xg(e,t){return Math.abs(e.zoom-t.zoom)<1e-9&&Math.abs(e.viewBox.x-t.viewBox.x)<1e-6&&Math.abs(e.viewBox.y-t.viewBox.y)<1e-6&&Math.abs(e.viewBox.w-t.viewBox.w)<1e-6&&Math.abs(e.viewBox.h-t.viewBox.h)<1e-6}const Zg=(e,t,i)=>e+(t-e)*i,Jg=(e,t,i)=>Math.exp(Zg(Math.log(e),Math.log(t),i));class Qg{constructor(e,t=Gg){this._hooks=e,this._clock=t,this._token=0,this._raf=null,this._state=null}get state(){return this._state}get active(){return"running"===this._state?.phase}get presented(){return this._state?.presented||null}get target(){return this._state?.to||null}start(e,t,i,n){this.cancel(!1);const r=++this._token,o=Yg(e),s=Yg(t),a=n>0&&Kg(o)&&Kg(s),l=this._clock.now(),c={token:r,phase:a?"running":"settling",from:o,to:s,presented:Yg(a?o:s),startedAt:l,duration:a?n:0,reason:i};if(this._state=c,this._hooks.frame(c),!a)return this._settle(r),r;const h=e=>{const t=this._state;if(!t||t.token!==r)return;const i=Math.max(0,Math.min(1,(e-t.startedAt)/t.duration));if(t.presented=i>=1?Yg(t.to):function(e,t,i){if(!Kg(e))return Yg(t);if(!Kg(t))return Yg(e);const n=Lg(i);if(n<=0)return Yg(e);if(n>=1)return Yg(t);const r=e.viewBox.x+e.viewBox.w/2,o=e.viewBox.y+e.viewBox.h/2,s=t.viewBox.x+t.viewBox.w/2,a=t.viewBox.y+t.viewBox.h/2,l=Jg(e.viewBox.w,t.viewBox.w,n),c=Jg(e.viewBox.h,t.viewBox.h,n),h=Zg(r,s,n),d=Zg(o,a,n);return{zoom:Jg(e.zoom,t.zoom,n),viewBox:{x:h-l/2,y:d-c/2,w:l,h:c}}}(t.from,t.to,i),t.phase=i>=1?"settling":"running",this._hooks.frame(t),i>=1)return this._raf=null,void this._settle(r);this._raf=this._clock.requestFrame(h),null===this._raf&&this._settle(r)};return this._raf=this._clock.requestFrame(h),null===this._raf&&(c.phase="settling",c.presented=Yg(s),this._hooks.frame(c),this._settle(r)),r}cancel(e=!0){null!==this._raf&&this._clock.cancelFrame(this._raf),this._raf=null;const t=this._state;this._state=null,this._token++,t&&e&&(t.phase="settling",t.presented=Yg(t.to),this._hooks.frame(t),this._hooks.settled(t))}dispose(){this.cancel(!1)}_settle(e){const t=this._state;t&&t.token===e&&(t.phase="settling",t.presented=Yg(t.to),this._hooks.settled(t),this._state?.token===e&&(this._state=null))}}function ef(e,t,i){const n=e.querySelector("ha-card");if(!n)return null;const r=n.getBoundingClientRect(),o=t.getBoundingClientRect().top-r.top,s=i?0:Math.min(Math.max(r.top,0),120),a=Math.round(o+s);return a>=0?a:null}const tf=Object.freeze({rotDeg:0,tiltDeg:20,xyScale:1,zScale:1,origin:Object.freeze([500,500])}),nf=84,rf=10,of=4,sf=4;function af(e){return[e.rotDeg,e.tiltDeg,e.xyScale,e.zScale,e.origin[0],e.origin[1]].every(Number.isFinite)&&Math.abs(e.xyScale)>1e-12&&Math.abs(Math.cos(e.tiltDeg*Math.PI/180))>1e-12}function lf(e,t,i=tf){if(!Number.isFinite(e[0])||!Number.isFinite(e[1]))throw new Error("invalid isometric projection input");return function(e,t){if(!Number.isFinite(e[0])||!Number.isFinite(e[1])||!t.every(Number.isFinite))throw new Error("invalid isometric affine input");const[i,n,r,o,s,a]=t;return[i*e[0]+r*e[1]+s,n*e[0]+o*e[1]+a]}(e,hf(t,i))}function cf(e,t=tf){if(!af(t)||!Number.isFinite(e[0])||!Number.isFinite(e[1]))throw new Error("invalid isometric projection input");const i=t.rotDeg*Math.PI/180,n=t.tiltDeg*Math.PI/180,r=(e[0]-t.origin[0])/t.xyScale,o=(e[1]-t.origin[1])/(t.xyScale*Math.cos(n));return[t.origin[0]+r*Math.cos(i)+o*Math.sin(i),t.origin[1]-r*Math.sin(i)+o*Math.cos(i)]}function hf(e=0,t=tf){if(!af(t)||!Number.isFinite(e))throw new Error("invalid isometric camera");const i=t.rotDeg*Math.PI/180,n=t.tiltDeg*Math.PI/180,r=t.xyScale*Math.cos(i),o=-t.xyScale*Math.sin(i),s=t.xyScale*Math.sin(i)*Math.cos(n),a=t.xyScale*Math.cos(i)*Math.cos(n);return[r,s,o,a,t.origin[0]-r*t.origin[0]-o*t.origin[1],t.origin[1]-s*t.origin[0]-a*t.origin[1]-e*t.zScale*Math.sin(n)]}function df(e=tf){return function(e=0,t=tf){return`matrix(${hf(e,t).map(e=>Number(e.toFixed(12))).join(" ")})`}(0,e)}function uf(e,t=tf){const{rect:i,wallHeight:n}=e,r=e.openingHeight??n,o=e.floorDepth??0,s=e.raisedHeight??n;if(!(i.w>=0)||!(i.h>=0)||!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(o)||!Number.isFinite(s)||n<0||r<0||o<0||s<0)throw new Error("invalid isometric frame");const a=[[i.x,i.y],[i.x+i.w,i.y],[i.x+i.w,i.y+i.h],[i.x,i.y+i.h]],l=Math.max(n,r,s),c=a.flatMap(e=>[lf(e,-o,t),lf(e,l,t)]),h=c.map(e=>e[0]),d=c.map(e=>e[1]),u=Math.min(...h),p=Math.min(...d);return{x:u,y:p,w:Math.max(...h)-u,h:Math.max(...d)-p}}const pf=[".dev",".vacpuck",".oplock",".op-hit",".opening",".rlgo","a","button","input","select","textarea",'[contenteditable]:not([contenteditable="false"])',"[data-room-fit-block]",'[role="link"]','[role="button"]'].join(","),_f=(e,t)=>{try{return"function"==typeof e?.matches&&e.matches(t)}catch{return!1}};function mf(e){for(const t of e){const e=t;if(_f(e,".roomlabel[data-id]")){const t=e.getAttribute?.("data-id");return t?{kind:"room",roomId:t}:{kind:"interactive"}}if(_f(e,pf))return{kind:"interactive"};if(_f(e,'[data-hp="room"][data-id]')){const t=e.getAttribute?.("data-id");return t?{kind:"room",roomId:t}:{kind:"interactive"}}if(_f(e,".stage"))return{kind:"background"}}return{kind:"outside"}}function gf(e){const t=mf(e);return"room"===t.kind?t.roomId:null}class ff{constructor(){this.pointer=null,this.sequence=null}clear(){this.pointer=null,this.sequence=null}clearOutside(e){let t={kind:"outside"};try{t=mf(e.composedPath())}catch{}"outside"===t.kind&&this.clear()}pointerDown(e,t,i){let n={kind:"outside"};try{n=mf(e.composedPath())}catch{}this.pointer=function(e){const t="mouse"===(i=e.pointerType)||"touch"===i||"pen"===i?i:null;var i;return t&&"view"===e.mode&&"background"===e.owner.kind&&!e.blocked&&e.isPrimary&&0===e.button&&Number.isFinite(e.x)&&Number.isFinite(e.y)?{pointerId:e.pointerId,spaceId:e.spaceId,modality:t,x:e.x,y:e.y}:null}({pointerId:e.pointerId,pointerType:e.pointerType,isPrimary:e.isPrimary,button:e.button,spaceId:t,mode:i?"view":"blocked",owner:n,blocked:!i,x:e.clientX,y:e.clientY}),this.pointer||(this.sequence=null)}pointerUp(e,t,i,n,r=Date.now()){let o={kind:"outside"};try{o=mf(e.composedPath())}catch{}const s=function(e,t,i){if(!t||"view"!==i.mode||"background"!==i.owner.kind||i.blocked||t.pointerId!==i.pointerId||t.spaceId!==i.spaceId||!Number.isFinite(i.x)||!Number.isFinite(i.y)||!Number.isFinite(i.now)||Math.abs(i.x-t.x)+Math.abs(i.y-t.y)>=8)return{sequence:null,trigger:!1};const n=e?i.now-e.at:Number.POSITIVE_INFINITY;return e&&e.spaceId===i.spaceId&&e.modality===t.modality&&n>=0&&n<=350?{sequence:null,trigger:!0}:{sequence:{at:i.now,spaceId:i.spaceId,modality:t.modality},trigger:!1}}(this.sequence,this.pointer,{pointerId:e.pointerId,spaceId:t,mode:i?"view":"blocked",owner:o,blocked:n||!i,x:e.clientX,y:e.clientY,now:r});return this.pointer=null,this.sequence=s.sequence,s.trigger}}const vf=e=>e.length>=2&&Number.isFinite(e[0])&&Number.isFinite(e[1]);function yf(e){return!!e&&Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.w)&&e.w>0&&Number.isFinite(e.h)&&e.h>0}function bf(e,t=0){if(!e.length||!Number.isFinite(t)||t<0||!e.every(vf))return null;let i=1/0,n=1/0,r=-1/0,o=-1/0;for(const t of e)i=Math.min(i,t[0]),n=Math.min(n,t[1]),r=Math.max(r,t[0]),o=Math.max(o,t[1]);const s=r-i,a=o-n;return s>0&&a>0?{x:i-t,y:n-t,w:s+2*t,h:a+2*t}:null}function wf(e,t,i){const n="string"!=typeof t||"invalid"!==t&&"no-borders"!==t&&"unverified"!==t&&!/^[a-z0-9]{1,8}$/i.test(t)?"redacted":t;return Object.freeze({kind:e,fingerprint:n,terminal:!!i})}function kf(e,t){return`${e("editor.load_failed")} ${e(t.terminal?"editor.refresh_advice":"editor.retry_advice")}`}class xf extends Error{}class Sf{constructor(e){this.options=e,this._state="idle",this._inFlight=null}get state(){return this._state}ensure(){return"ready"===this._state?Promise.resolve(!0):"failed"===this._state?Promise.resolve(!1):(this._inFlight||(this._setState("loading"),this._inFlight=this._loadWithRetry().finally(()=>{this._inFlight=null})),this._inFlight)}async _loadWithRetry(){let e=new Error("Editor runtime did not load"),t=!1;for(const i of[0,1])try{const e=await this.options.load(i);if(e.fingerprint!==this.options.expectedFingerprint)throw new xf(`Editor runtime fingerprint mismatch: expected ${this.options.expectedFingerprint}, got ${e.fingerprint}`);const t=e.create();return this.options.install(t),this._setState("ready"),!0}catch(i){e=i,i instanceof xf&&(t=!0)}return this._setState(t?"failed":"idle"),this.options.failed?.(e,{terminal:t}),!1}_setState(e){e!==this._state&&(this._state=e,this.options.stateChanged?.(e))}}const $f=(e,t)=>{if(!e.has(t))return{hit:!1};const i=e.get(t);return e.delete(t),e.set(t,i),{hit:!0,value:i}},Mf=(e,t,i,n)=>{for(e.delete(t),e.set(t,i);e.size>n;){const t=e.keys().next().value;if(void 0===t)break;e.delete(t)}},Rf=new Set(["select","draw","column","merge","split","resize","opening","wallthick","delroom"]),Cf=e=>`${window.innerWidth}x${window.innerHeight}|${location.pathname}|${JSON.stringify(e??{})}`,Tf="houseplan_card_alpha_v1",Df=Object.freeze([Object.freeze({id:"iso",issue:89,summary:"Volumetric plan renderer"})]);function Af(e){return/^[a-z][a-z0-9-]*$/.test(e.id)&&Number.isInteger(e.issue)&&e.issue>0&&!!e.summary.trim()}function Pf(e){const t=String(e||"").replace(/^#/,"");return new URLSearchParams(t)}function Ff(e){return Pf(e).get("space")||""}function zf(e,t,i=Df){const n=function(e){const t=new Set;for(const i of e){if(!Af(i)||t.has(i.id))return!1;t.add(i.id)}return!0}(i),r=function(e){let t,i=!1;const n=e=>{for(const n of e.getAll("hp_alpha"))i=!0,"1"===n?t=!0:"0"===n&&(t=!1)};return n(new URLSearchParams(String(e.search||"").replace(/^\?/,""))),n(Pf(e.hash)),{present:i,value:t}}(e),o=void 0!==r.value,s="1"===t,a=o?!0===r.value:!r.present&&s,l=n&&a;return{alpha:l,active:Object.freeze(l?i.map(e=>e.id).sort():[]),space:Ff(e.hash),persist:n&&o?l?"1":"0":void 0,knownUrlOperation:o}}let If={alpha:!1,active:Object.freeze([]),space:""},Of=!1,Ef="";const Nf=new Set;function Hf(){if("undefined"==typeof window)return If;const e=zf(window.location,function(){try{return window.localStorage.getItem(Tf)}catch{return null}}());void 0!==e.persist&&function(e){try{window.localStorage.setItem(Tf,e)}catch{}}(e.persist),If={alpha:e.alpha,active:e.active,space:e.space},window.__hpAlpha=e.alpha,window.__hpLabs=e.active;for(const e of Nf)e(If);return If}function Lf(){Hf()}function Bf(){if("undefined"==typeof window)return If;if(!Of){Of=!0,window.__hpLabsListenerCleanup?.(),window.addEventListener("hashchange",Lf),window.addEventListener("popstate",Lf);const e=()=>{window.removeEventListener("hashchange",Lf),window.removeEventListener("popstate",Lf),window.__hpLabsListenerCleanup===e&&delete window.__hpLabsListenerCleanup};window.__hpLabsListenerCleanup=e}return Hf()}const qf={window:120,door:90,passage:90,gate:300};function jf(e){return qf[e]}function Wf(e,t){return{type:e,lengthCm:jf(e),flipH:!1,flipV:!1,revision:t}}function Uf(e,t){const i=Math.max(0,e.renderedLength)/2,n=Math.max(0,e.target.physicalHalfWidth),r=n+.18*Math.max(0,t),o=e=>({x1:e,y1:-r,x2:e,y2:r});return{rect:{x:-i,y:n?-n:0,width:2*i,height:2*n},boundaries:[o(-i),o(i)]}}function Gf(e,t){const i=[e[0],e[1]],n=[t[0],t[1]];return function(e,t){return e[0]-t[0]||e[1]-t[1]}(i,n)<=0?{a:i,b:n}:{a:n,b:i}}function Vf(e){const t=new Map;return e.forEach((e,i)=>{if(!e.kind||e.open)return;const n=Gf(e.a,e.b);if(Math.hypot(n.b[0]-n.a[0],n.b[1]-n.a[1])<=1e-9)return;const r=function(e,t){const i=e=>(Math.abs(e)<=5e-10?0:Math.round(1e6*e)/1e6).toFixed(6);return`${i(e[0])},${i(e[1])}>${i(t[0])},${i(t[1])}`}(n.a,n.b),o=t.get(r);if(o)return o.physicalHalfWidth=Math.max(o.physicalHalfWidth,e.half||0),o.sourceOrder=Math.min(o.sourceOrder,i),void(e.partitionHost&&(o.partitionHost&&o.partitionHost.id!==e.partitionHost.id?o.ambiguousPartitionHost=!0:o.partitionHost=e.partitionHost));t.set(r,{segmentKey:r,a:n.a,b:n.b,physicalHalfWidth:Math.max(0,e.half||0),sourceOrder:i,...e.partitionHost?{partitionHost:e.partitionHost}:{}})}),[...t.values()]}function Kf(e,t){if(Math.abs(e.distance-t.distance)>1e-9)return e.distance-t.distance;if(Math.abs(e.perpendicular-t.perpendicular)>1e-9)return e.perpendicular-t.perpendicular;return(e.target.segmentKeyt.target.segmentKey?1:0)||e.target.sourceOrder-t.target.sourceOrder}function Yf(e){const t=Vf(e.intervals).map(t=>{const i=function(e,t){const i=t.b[0]-t.a[0],n=t.b[1]-t.a[1],r=Math.hypot(i,n),o=i/r,s=n/r,a=(e[0]-t.a[0])*o+(e[1]-t.a[1])*s,l=Math.max(0,Math.min(r,a)),c=t.a[0]+l*o,h=t.a[1]+l*s;return{along:l,length:r,x:c,y:h,distance:Math.hypot(e[0]-c,e[1]-h),perpendicular:Math.abs((e[0]-t.a[0])*s-(e[1]-t.a[1])*o)}}(e.pointer,t);return{target:t,...i,envelope:Math.max(e.baseTolerance,t.physicalHalfWidth+e.bodyPointerPadding)}}).filter(e=>e.distance<=e.envelope+1e-9).filter(t=>!function(e,t,i,n,r){const o=t.b[0]-t.a[0],s=t.b[1]-t.a[1],a=Math.hypot(o,s);if(!(a>1e-9))return!1;const l=o/a,c=s/a;for(const o of i){if(!o.open&&o.kind)continue;const i=Gf(o.a,o.b),s=i.b[0]-i.a[0],a=i.b[1]-i.a[1],h=Math.hypot(s,a);if(!(h>1e-9))continue;const d=s/h,u=a/h;if(Math.abs(l*u-c*d)>1e-6)continue;if(Math.abs((i.a[0]-t.a[0])*c-(i.a[1]-t.a[1])*l)>r)continue;const p=(e[0]-i.a[0])*d+(e[1]-i.a[1])*u,_=1e-9;if(!(p<=_||p>=h-_)&&Math.abs((e[0]-i.a[0])*u-(e[1]-i.a[1])*d)<=n+1e-9)return!0}return!1}(e.pointer,t.target,e.intervals,t.envelope,Math.max(1e-9,Math.min(e.baseTolerance,.04*e.gridStep)))),i=t.filter(t=>!!t.target.partitionHost&&e.renderedLength+2*t.target.physicalHalfWidth>t.length+1e-9).sort(Kf),n=t.filter(t=>!t.target.partitionHost||e.renderedLength+2*t.target.physicalHalfWidth<=t.length+1e-9).sort(Kf);let r=n[0];if(!r)return{candidate:null,jambBlockedTarget:i[0]?.target||null};const o=n.filter(e=>Math.abs(e.distance-r.distance)<=1e-9&&Math.abs(e.perpendicular-r.perpendicular)<=1e-9),s=o.filter(e=>e.target.partitionHost);if(s.length){if(1!==new Set(s.map(e=>e.target.partitionHost.id)).size||s.some(e=>e.target.ambiguousPartitionHost))return{candidate:null,jambBlockedTarget:null};const e=s[0],t=e.target.b[0]-e.target.a[0],i=e.target.b[1]-e.target.a[1],n=Math.hypot(t,i),a=t/n,l=i/n;if(!o.every(t=>{const i=t.target.b[0]-t.target.a[0],n=t.target.b[1]-t.target.a[1],r=Math.hypot(i,n),o=i/r,s=n/r,c=Math.abs(a*s-l*o)<=1e-6,h=Math.abs((t.target.a[0]-e.target.a[0])*l-(t.target.a[1]-e.target.a[1])*a);return c&&h<=1e-9}))return{candidate:null,jambBlockedTarget:null};r=e}if(r.target.ambiguousPartitionHost)return{candidate:null,jambBlockedTarget:null};const{target:a,length:l}=r,c=a.b[0]-a.a[0],h=a.b[1]-a.a[1],d=c/l,u=h/l,p=a.partitionHost?a.physicalHalfWidth:0,_=Math.min(Math.max(0,e.renderedLength)/2+p,l/2);let m=r.along;const g=Math.max(e.gridStep,1e-9),f=l/2;m=Math.abs(m-f)<=g/2?f:Math.round(m/g)*g,m=Math.max(_,Math.min(l-_,m));const v=a.a[0]+d*m,y=a.a[1]+u*m,b=Math.max(0,e.renderedLength)/2,w=m-b,k=m+b,x=Math.max(0,w),S=Math.max(0,l-k),$=[a.a[0]+d*(w-x/2),a.a[1]+u*(w-x/2)],M=[a.a[0]+d*(k+S/2),a.a[1]+u*(k+S/2)];let R=180*Math.atan2(h,c)/Math.PI;R>=90?R-=180:R<-90&&(R+=180);const C=Math.abs(m-f)<=1e-9;return{candidate:{presetRevision:e.preset.revision,geometryRevision:e.geometryRevision,pointer:[e.pointer[0],e.pointer[1]],type:e.preset.type,lengthCm:e.preset.lengthCm,flipH:e.preset.flipH,flipV:e.preset.flipV,x:v,y:y,angle:R,renderedLength:e.renderedLength,target:a,...a.partitionHost?{host:{...a.partitionHost,t:l>0?m/l:0}}:{},measure:{labels:[{distance:x,midpoint:$},{distance:S,midpoint:M}],guide:C?{x:v,y:y,angle:R}:null}},jambBlockedTarget:null}}function Xf(e,t,i,n,r=1e-6){return e.presetRevision===i&&e.geometryRevision===n&&Math.hypot(e.pointer[0]-t[0],e.pointer[1]-t[1])<=r}function Zf(e){return!(!e.canEdit||e.kiosk||e.fixedFloor)&&("view"!==e.mode&&("mouse"===e.pointerType&&e.spaceCount>1))}class Jf{constructor(e,t,i){this.loader=e,this.host=t,this.adopted=i,this.attachment=null}connect(){if(this.runtime)return void this.runtime.connect();this.attachment?.cancel();const e=this.loader.attach(this.host,e=>this.adopt(e));this.runtime||(this.attachment=e)}disconnect(){this.attachment?.cancel(),this.attachment=null,this.runtime?.disconnect()}adopt(e){this.attachment=null,this.runtime||(this.runtime=e,this.adopted(e))}}const Qf=new class{constructor(e){this.load=e,this.factory=null,this.pending=null}get warm(){return null!==this.factory}create(e){return this.factory?this.factory(e):null}attach(e,t){let i=!0;const n={cancel:()=>{i=!1}},r=this.create(e);return r?(t(r),n):(this.ensure().then(n=>{i&&t(n(e))},()=>{}),n)}ensure(){return this.factory?Promise.resolve(this.factory):(this.pending||(this.pending=this.load().then(e=>(this.factory=e,this.pending=null,e),e=>{throw this.pending=null,e})),this.pending)}reset(){this.factory=null,this.pending=null}}(()=>import("./summary-panel-runtime-loaded-C3VkX0bk.js").then(function(e){return e.e}).then(({LoadedSummaryPanelRuntime:e})=>t=>new e(t)));function ev(e){const t=globalThis.__HP_VERSION_OVERRIDE__;return"string"==typeof t&&t.length>0?t:e}let tv=0;const iv="1.77.0-beta.1",nv="d31b0b1e184ab2863684b758f839bdb6809a33cc742c6e9bb36c5ea034e3d309",rv=1500,ov=new Map;let sv=0,av=1e4;const lv="houseplan_card_layout_v1",cv="houseplan_card_cfg_v1",hv="houseplan_card_zoom_v1",dv="houseplan_card_nav_v1",uv="houseplan_card_view_v1",pv="hp-dialog, hp-help, hp-color-opacity, hp-device-preview",_v=1e3,mv=(e,t)=>{const i=Math.min(e.x,t.x),n=Math.min(e.y,t.y);return{x:i,y:n,w:Math.max(e.x+e.w,t.x+t.w)-i,h:Math.max(e.y+e.h,t.y+t.h)-n}},gv=(e,t,i)=>{const n=new Event(t,{bubbles:!0,composed:!0});n.detail=i??{},e.dispatchEvent(n)},fv=e=>{history.pushState(null,"",e),gv(window,"location-changed",{replace:!1})},vv=(e,t)=>{let i,n=null;const r=(...r)=>{clearTimeout(i),n=r,i=window.setTimeout(()=>{i=void 0;const t=n;n=null,t&&e(...t)},t)};return r.flush=()=>{if(void 0===i)return;clearTimeout(i),i=void 0;const t=n;n=null,t&&e(...t)},r.cancel=()=>{clearTimeout(i),i=void 0,n=null},r.pending=()=>void 0!==i,r},yv=e=>{try{e.target?.setPointerCapture?.(e.pointerId)}catch{}},bv=["edges","corners"];class wv extends he{constructor(){var e;super(...arguments),this._editorRuntime=null,this._liveRt=null,this._onboardingRuntime=null,this._editorRuntimeLoadingVisible=!1,this._backdropGuard=null,this._editorModeRequest=0,this._warmModeRequest=0,this._editorRuntimeLoader=new Sf({expectedFingerprint:nv,load:async e=>{const t=0===e?await import("./houseplan-editor-runtime-DOSm4OKX.js"):await import((()=>{const e=new URL("./houseplan-editor-runtime-DOSm4OKX.js",import.meta.url);return e.searchParams.set("hp_retry",`${iv}-${++tv}`),e.href})());return{fingerprint:t.EDITOR_RUNTIME_FINGERPRINT,create:()=>new t.HouseplanEditorRuntime(this)}},install:e=>{this._editorRuntime=e},stateChanged:e=>this._editorRuntimeStateChanged(e),failed:(e,t)=>{console.error("[houseplan] unable to load editor runtime",e),t.terminal&&this._versionRecovery.hasCurrentMismatchNotice||this._showToast(kf(e=>this._t(e),t))}}),this._onboardingRuntimeLoader=new Sf({expectedFingerprint:nv,load:async e=>{const t=0===e?await import("./houseplan-onboarding-runtime-G7DfDSe_.js"):await import((()=>{const e=new URL("./houseplan-onboarding-runtime-G7DfDSe_.js",import.meta.url);return e.searchParams.set("hp_retry",`${iv}-${++tv}`),e.href})());return{fingerprint:t.ONBOARDING_RUNTIME_FINGERPRINT,create:()=>new t.HouseplanOnboardingRuntime(this)}},install:e=>{this._onboardingRuntime=e},failed:(e,t)=>{console.error("[houseplan] unable to load onboarding runtime",e),t.terminal&&this._versionRecovery.hasCurrentMismatchNotice||this._showToast(kf(e=>this._t(e),t))}}),this._isoSceneRuntime=null,this._isoSceneRuntimeLoader=new Sf({expectedFingerprint:nv,load:async e=>{const t=0===e?await import("./iso-scene-render-CCwC6ZHk.js"):await import((()=>{const e=new URL("./iso-scene-render-CCwC6ZHk.js",import.meta.url);return e.searchParams.set("hp_retry",`${iv}-${++tv}`),e.href})());return{fingerprint:t.ISO_SCENE_RUNTIME_FINGERPRINT,create:()=>t}},install:e=>{const t=this._effectiveProjection();this._isoSceneRuntime=e,this._isoProjectionSnapshot=null;const i=this._effectiveProjection();this._convertProjectionView(t,i),this.isConnected&&this.requestUpdate()},failed:(e,t)=>{console.warn("[houseplan] hidden isometric runtime diagnostic",wf("runtime-load","unverified",t.terminal)),this.isConnected&&this.requestUpdate()}}),this._pdfRuntime=null,this._pdfRuntimeLoader=new Sf({expectedFingerprint:nv,load:async e=>{const t=0===e?await import("./pdf-export-B1B1amDF.js"):await import((()=>{const e=new URL("./pdf-export-B1B1amDF.js",import.meta.url);return e.searchParams.set("hp_retry",`${iv}-${++tv}`),e.href})());return{fingerprint:t.PDF_EXPORT_FINGERPRINT,create:()=>new t.PdfExportRuntime}},install:e=>{this._pdfRuntime=e,this.isConnected&&this.requestUpdate()},failed:(e,t)=>{if(console.error("[houseplan] unable to load PDF export runtime",e),!t.terminal||!this._versionRecovery.hasCurrentMismatchNotice){const e=kf(e=>this._t(e),t),i=this._t("editor.load_failed"),n=e.startsWith(i)?e.slice(i.length).trim():e;this._showToast(`${this._t("pdf.failed")} ${n}`.trim())}}}),this.panelHost=!1,this.narrow=null,this._space="f1",this._adoption=new qu((e,t)=>this.requestUpdate(e,t)),this._serverStorage=!1,this._loadOk=!1,this._serverCanWrite=null,this._loading=!1,this._loadTries=0,this._unsubCfg=null,this._unsubLayout=null,this._unsubVirtual=null,this._liveSyncAttempt=null,this._liveSyncGeneration=0,this._liveSyncConnection=null,this._configReloadAuthority=new Gu,this._virtualLights=Hh(null),this._canOptimizeUndo=!1,this._undoKind=null,this._devices=[],this._regSignature="",this._defPos={},this._newSyncKey="",this._areaRelocationIds=new Set,this._areaSnapshotCleanupCandidates=new Map,this._areaRelocationSyncKey="",this._areaRelocationWrite=Promise.resolve(),this._tip=null,this._hoverRoom=null,this._pointerModality=new sg(this,()=>this._syncPointerHoverTargets()),this._devicePressAnimations=new Map,this._selId=null,this._toast="",this._mode="view",this._pendingNavMode=null,this._decorTool="select",this._decorStyle={...Cr},this._decorStyleSeeded=!1,this._decorDraft=null,this._decorMove=null,this._decorSel=null,this._decorEraseConfirm=null,this._decorTextDialog=null,this._decorShapeDialog=null,this._backdropDialog=null,this._decorTextSelection={start:0,end:0},this._furnPalette=null,this._decorImagePalette=null,this._decorAssetCatalog=[],this._decorAssets=new Map,this._decorAssetBusy=!1,this._furnCategory=null,this._furnPreviewInput=null,this._furnTouchPending=null,this._dtBox=null,this._dtDrag=null,this._bdDrag=null,this._slide="",this._reducedMotion=!1,this._onMotionChange=e=>{this._reducedMotion=e.matches,this._cancelDevicePressFeedback(),e.matches&&this._cancelCameraTransition(!0),e.matches&&this._modeTransitionPreparing?this._modeTransitionForceAtomic=!0:e.matches&&this._modeTransition.active&&this._cancelModeTransition(!0),this._syncVersionRecovery(),this.requestUpdate()},this._editorChromeMode="plan",this._modeTransitionVisual=null,this._modeTransitionPreparing=!1,this._modeTransitionForceAtomic=!1,this._modeTransitionRequest=0,this._modeTransitionTargetZoom=1,this._modeTransitionEditorCamera=null,this._modeTransition=new Ug({frame:e=>this._applyModeTransitionFrame(e),settled:e=>this._settleModeTransition(e)}),this._cameraTransitionFit=null,this._cameraTransition=new Qg({frame:e=>this._applyCameraTransitionFrame(e),settled:e=>this._settleCameraTransition(e)}),this._editorSecondaryCopy={groupActive:(e,t)=>this._t("editor.group_active",{group:e,item:t}),openGroup:e=>this._t("editor.open_group",{group:e}),disabledAction:(e,t)=>this._t("editor.disabled_action",{action:e,reason:t})},this._tool="draw",this._geometryHistory=new gg(50),this._devicePositionHistory=new gg(50),this._devicePositionBusy=!1,this._wallDialog=null,this._drawWallField=null,this._activeWallChainId=null,this._activeWallChainPartitionIds=[],this._wallChainRedo=[],this._physicalSel=null,this._physicalDialog=null,this._partitionDeleteDialog=null,this._roomDeleteDialog=null,this._physicalDrag=null,this._physicalRotate=null,this._physicalLastTap=null,this._physicalPickCycle=null,this._wallUnionCacheValue=null,this._wallUnionPool=new Map,this._isoGeometryCache=new Map,this._renderIsoScene=null,this._isoProjectionSnapshot=null,this._isoStructuralBuildCount=0,this._isoFallback=new Set,this._openingTunnelCache=null,this._openingWallIndexCache=new Map,this._openingPlacementIntervalsCache=null,this._openingDimensionContextCache=null,this._planSnapGeometryCache=null,this._planStructuralGeometryCache=null,this._hiddenWallDiagnosticCache=null,this._physicalBodiesCache=null,this._lightPhysicalBodiesCache=null,this._cleanFloorCache=new Map,this._innerContourCache=new Map,this._glowRuntimeState=bm(),this._glowRuntimeHost={window:()=>this.ownerDocument.defaultView||window,isConnected:()=>this.isConnected,requestUpdate:()=>this.requestUpdate(),reducedMotion:()=>this._reducedMotion},this._lightBarrierCache=null,this._lightBarrierPool=new Map,this._glowScreenBlend=!1,this._duplicateColumnId=null,this._duplicateColumnTimer=0,this._rszLimitViolation=null,this._path=[],this._cursorPt=null,this._planSnapHover=null,this._mergeSel=null,this._openingPreset=null,this._openingRebindId=null,this._openingPresetRevision=0,this._openingHoverCandidate=null,this._openingJambBlockCm=null,this._openingDialog=null,this._openingInfo=null,this._opDrag=null,this._opMeasure=null,this._mergeDialog=null,this._splitSel=null,this._pendingSplit=null,this._wallFaceBatch=null,this._wallRepairDiagnostic=null,this._wallFaceGraphCache=[],this._areaSel="",this._nameSel="",this._roomDialog=!1,this._roomEditId=null,this._roomFill="",this._roomCustomFill=null,this._roomTempMin="",this._roomTempMax="",this._roomTempSrc="",this._roomHumSrc="",this._roomSrcOpen=null,this._roomSrcFilter="",this._roomNameScale=1,this._roomLabelScale=1,this._zoom=1,this._view=null,this._zoomBySpace={},this._viewModeSnap=null,this._roomFocus=null,this._roomPointer=null,this._doubleFit=new ff,this._deviceHits=new wc,this._pointers=new Map,this._panStart=null,this._panLock=null,this._pinchStart=null,this._safeDayCycleOutline=!1,this._suppressClick=!1,this._viewportGestureDirty=!1,this._touchContacts=new Map,this._touchClickGuard=new pc,this._connectedPath="",this._routeDepartureHandled=!1,this._onLocationChanged=()=>{this._connectedPath&&location.pathname!==this._connectedPath?this._leaveCardRoute():location.pathname===this._connectedPath&&(this._routeDepartureHandled=!1)},this._touchGestureGuard={capture:!0,handleEvent:e=>this._guardTouchGesture(e)},this._hdrH=118,this._booting=!0,this._bootFading=!1,this._bootSettling=!1,this._bootSettleRaf=0,this._bootLastH=-1,this._bootStart=0,this._bootLastChange=0,this._bootSoft=!1,this._tapConfirm=null,this._dangerConfirm=null,this._dangerConfirmController=new ze(e=>{this._dangerConfirm=e}),this._confirmDanger=e=>this._config&&this.hass?"warm"===this._syncDangerConfirmLocaleGate()||this._dangerConfirmMissingSpace()?Promise.resolve(!1):this._dangerConfirmController.confirm(e):Promise.resolve(!1),this._cancelDangerConfirm=()=>{this._dangerConfirmController.cancel()},this._onDangerConfirmDecision=e=>{this._dangerConfirmController.resolve(e.detail.token,e.detail.accepted)},this._onboardingShown=!1,this._rulesDialog=null,this._preflightClipboardFallback=null,this._haIntegrationVersion=null,this._versionRecovery=(e=this,new wg({clock:{setTimeout:(e,t)=>window.setTimeout(e,t),clearTimeout:e=>window.clearTimeout(e)},storage:()=>e.ownerDocument.defaultView?.sessionStorage??null,safety:()=>Sg(e),reload:()=>e._reloadDocument(),changed:()=>{e.requestUpdate()}})),this._haSupportApi=null,this._haDecorAssetsApi=null,this._haSummaryPanelApi=null,this._haRadarStage1Api=null,this._radarLive=new Ag(this),this._decorAssetSyncToken=0,this._alignDialog=null,this._settingsDialog=null,this._pdfDialog=!1,this._supportDialog=null,this._backupExportDialog=null,this._backupImportDialog=null,this._sunRaysCache=null,this._dayCycleTimer=0,this._dayCycleClockKey="",this._compassDrag=!1,this._importDialog=null,this._importQueue=[],this._importTotal=0,this._rulesCompiledSrc="",this._infoCard=null,this._nativeMoreInfoEntity=null,this._deviceInbox=null,this._deviceInboxReturn=null,this._deviceInboxMemo=null,this._markerDialog=null,this._spaceDialog=null,this._keyHandler=e=>this._onKey(e),this._warmVp=null,this._warmVpArmed=!1,this._warmLongReturn=!1,this._warmRevivePending=!1,this._warmGen=++sv,this._warmKey=null,this._warmSlot=null,this._hashApplied=!1,this._navApplied=!1,this._labs={alpha:!1,active:Object.freeze([]),space:""},this._viewPreference={},this._renderProjection="flat",this._kioskScale={icon:1,font:1},this._kioskDialog=!1,this._summarySlot=new Jf(Qf,this,e=>{this._summary=e,this._capturedSnapshotSequence=-1,this.isConnected&&(e.connect(),this.hasUpdated&&this.requestUpdate())}),this._activityRt=new Map,this._vacRt=new Map,this._vacViewKey="",this._vacLastView=null,this._vacRaf=0,this._vacSrvTrails={},this._vacJumpOnce=!1,this._continuity=this._newContinuityController(),this._continuityHistory=[],this._continuityEpoch=0,this._continuityDataReady=!0,this._continuityPaintToken=-1,this._continuityDisposed=!1,this._renderSnapshotAt=Date.now(),this._hassSequence=0,this._visibleDeviceSnapshot=null,this._candidateDeviceSnapshot=null,this._stagedDeviceSnapshotToken=-1,this._capturedSnapshotSequence=-1,this._capturedSnapshotDevices=null,this._capturedSnapshotLayout=null,this._capturedSnapshotActivity="",this._capturedSnapshotConfigEpoch=-1,this._capturedSnapshotVirtual="",this._lastValidStageSize=null,this._pendingRefitSize=null,this._refitRaf=0,this._pageVisibility=e=>{if(this._continuity.visibility(e),this._dayCycleVisibility(e),this._summary?.visibility(e.kind),"hidden"===e.kind)return this._radarLive.stop(),this._editorRuntime?._cancelRadarSetup(),this._clearRoomFocus(!0),this._clearTransientHover(!0),this._cancelDevicePressFeedback(),this._cancelCameraTransition(!0),void(this._modeTransitionPreparing?this._modeTransitionForceAtomic=!0:this._cancelModeTransition(!0));if(this._vacJumpOnce=!0,this._syncRadarLive(),!e.long){const e=Date.now();let t=!1;for(const i of this._activityRt.values())!i.flashKind||(i.expiresAt||i.flashTs+tg)>e||(i.flashTs=0,i.flashKind=null,i.expiresAt=0,t=!0);return void(t&&this.requestUpdate())}Date.now()-this._renderSnapshotAt>1e3&&this._continuity.note("device-snapshot-stale"),this._continuityDataReady=!1,this._continuityPaintToken=-1,this._resumeSettling=!0,this._loading?this.requestUpdate():this._loadFromServer()},this._resumeSettling=!1,this._viewportInvalidAt=0,this._vacFit=null,this._vacAllCamerasFor=null,this._vacAllCameraCache=null,this._vacCalConfirm=null,this._kioskDots=!1,this._cyclePausedUntil=0,this._swipeStart=null,this._tabDrag=null,this._tabDragRelease=null,this._tabSuppressClick=!1,this._tabOrderWarned=!1,this._onLabsSnapshot=e=>{const t=this._effectiveProjection();this._labs=e,this._isoProjectionSnapshot=null,this._labsIso&&this._ensureIsoSceneRuntime();const i=this._effectiveProjection();this._convertProjectionView(t,i),this.requestUpdate()},this._onHashChange=()=>{if(this._hasFixedFloor)return;const e=this._hashSpace();if(e&&this._model.find(t=>t.id===e)&&e!==this._space){if(this._wallFaceBatch&&this._roomDialogCancel(),"plan"===this._mode&&"draw"===this._tool&&!this._finishWallChain())return;this._commitSpace(e),this._selId=null,this._path=[],this._clearPlanSnapHover(),this._clearOpeningPlacement(!0),this._tool="draw",this._activeWallChainId=null,this._activeWallChainPartitionIds=[],this._wallChainSegmentCms=[],this._closingWallCm=null,this._restoreZoom(),this.requestUpdate()}},this._drag=null,this._deviceDrag=null,this._rlResize=null,this._holdFired=!1,this._retryContinuity=()=>{this._continuityDataReady=!1,this._continuityPaintToken=-1,this._continuity.retry(this._continuity.recoveryReason||"plan"),this._loading||this._loadFromServer()},this._cfgEpoch=0,this._cfgEpochPreservedConfig=null,this._terminalFrame=0,this._modelCache=null,this._emptySpaceStateActive=!1,this._decorSnapCache=null,this._markerPreviewMemo=null,this._markerPreviewDevicesMemo=null,this._showHidden=!1,this._connHooked=null,this._connectionWasLost=!1,this._haRegistryConnection=null,this._haRegistryRev=-1,this._haBindingCacheKey="",this._planHassMemo=null,this._renderLife=new $g,this._liveEditorPaintCount=0,this._onHaRegistryUpdate=()=>{const e=nd(this.hass);e.revision===this._haRegistryRev&&this._devices.length||(this._haRegistryRev=e.revision,this._renderLife.invalidate(),this._planHassMemo=null,this._regSignature="",this._maybeRebuildDevices(),this.requestUpdate())},this._onConnReady=()=>{if(this._loadTries=0,clearTimeout(this._loadRetryTimer),this._loadRetryTimer=void 0,id(this.hass),this._saveConfigDebounced.pending()&&this._saveConfigDebounced.flush(),this._cfgWriting)return clearTimeout(this._reloadRetry),void(this._reloadRetry=window.setTimeout(this._onConnReady,400));!this._connectionWasLost&&this._continuity.hasCompleteFrame?this._beginContinuityCandidate("connection-ready",!1,"plan"):(this._continuityDataReady=!1,this._continuityPaintToken=-1),this._loading||this._loadFromServer()},this._onConnLost=()=>{this._booting&&!this._continuity.hasCompleteFrame||(this._connectionWasLost=!0,this._continuityDataReady=!1,this._continuityPaintToken=-1,this._continuity.connectionLost())},this._signer=new uc(()=>this.requestUpdate()),this._dirtyPos=new Set,this._sentPos=new Map,this._persistLayout=vv(()=>{if(this._serverStorage){const e=[...this._dirtyPos];this._dirtyPos.clear();for(const t of e){const e=xo(this._layout[t]);e&&(this._layout={...this._layout,[t]:e},this._sentPos.set(t,e),this.hass.callWS({type:"houseplan/layout/update",device_id:t,pos:e}).then(e=>this._noteLayoutRev(e)).catch(e=>this._showToast(this._t("toast.pos_save_failed",{err:this._errText(e)}))).finally(()=>{this._sentPos.get(t)===e&&this._sentPos.delete(t)}))}this._cacheSnapshot()}else this._persistLocalLayout()},600),this._frame=null,this._showFar=!1,this._writesPending=0,this._writeChain=Promise.resolve(),this._pendingPhysicalWrites=new Map,this._undoGeometry=()=>this._editorRuntimeOrThrow()._undoGeometry(),this._redoGeometry=()=>this._editorRuntimeOrThrow()._redoGeometry(),this._saveConfigDebounced=vv(()=>{this._serverCfg&&this._writeConfig().catch(e=>{const t=!0===e?.physicalGeometryRolledBack;"geometry-unsafe"!==e?.code&&("wall_model_client_outdated"===e?.code?this._showToast(this._t("toast.wall_model_client_outdated")):"conflict"===e?.code?(this._showToast(this._t("toast.conflict")),t||(this._cancelPath(),this._reloadConfigOnly(!0))):this._showToast(this._t("toast.cfg_save_failed",{err:this._errText(e)})),t&&this._reloadRejectedPhysicalWrite())})},500),this._wallChainSegmentCms=[],this._closingWallCm=null,this._savePhysicalDialog=()=>this._editorRuntimeOrThrow()._savePhysicalDialog(),this._deletePhysicalSelection=()=>this._editorRuntimeOrThrow()._deletePhysicalSelection(),this._confirmPartitionDelete=()=>this._editorRuntimeOrThrow()._confirmPartitionDelete(),this._confirmRoomDelete=e=>this._editorRuntimeOrThrow()._confirmRoomDelete(e),this._rebindPartitionOpening=()=>this._editorRuntimeOrThrow()._rebindPartitionOpening(),this._keepClosedAsPartitions=()=>this._editorRuntimeOrThrow()._keepClosedAsPartitions(),this._toggleServerPlans=async()=>this._onboardingRuntime&&this._spaceDialogUsesOnboardingRuntime("create")?this._onboardingRuntime._toggleServerPlans():this._editorRuntimeOrThrow()._toggleServerPlans(),this._aspectJob=null,this._dayCycleTick=()=>{if(!this.isConnected||"hidden"===this.ownerDocument.visibilityState)return;const e=this._dayCycleState();if(!e)return this._dayCycleTimer&&(clearInterval(this._dayCycleTimer),this._dayCycleTimer=0),void(this._dayCycleClockKey="");const t=cr(e);t!==this._dayCycleClockKey&&(this._dayCycleClockKey=t,this.requestUpdate())},this._sunShown=!1,this._sunOut=!1,this._sunOutTimer=0,this._openSettingsDialog=()=>{if(this._editorRuntime)return this._editorRuntime._openSettingsDialog();this._ensureEditorRuntime().then(e=>{e&&this._openSettingsDialog()})},this._openSupportDialog=()=>{this._editorRuntime?this._editorRuntime._openSupportDialog():this._ensureEditorRuntime().then(e=>{e&&this._openSupportDialog()})},this._openPdfDialog=()=>{this._pdfRuntimeLoader.ensure().then(e=>{e&&(this._pdfDialog=!0,this.requestUpdate())})},this._reportedPreflightFingerprint=null,this._openAlignDialog=()=>this._editorRuntimeOrThrow()._openAlignDialog(),this._toggleOptimizeLivePositions=()=>this._editorRuntimeOrThrow()._toggleOptimizeLivePositions(),this._optimizeUndoBusy=!1,this._openBackupExport=()=>this._editorRuntimeOrThrow()._openBackupExport(),this._openRulesDialog=()=>this._editorRuntimeOrThrow()._openRulesDialog(),this._climateCache=null,this._gearPtCache=new WeakMap}requestUpdate(e,t,i){if("hass"===e&&this.hass&&this._liveRt){const e=this._visibleDeviceSnapshot||this._candidateDeviceSnapshot;if(!this._liveRt.hass(t,this.hass,e?{entityIds:e.entityIds}:null,()=>Mg(this))&&!this._summary?.observeHassComposition())return}void 0!==e&&(this._terminalFrame=0),this._editorRuntime?._routeLiveEditorUpdate(e,t)||(this._liveRt?.clear(),super.requestUpdate(e,t,i))}_editorRuntimeOrThrow(){if(!this._editorRuntime)throw new Error("Houseplan editor runtime is not loaded");return this._editorRuntime}async _ensureEditorRuntime(){return this._editorRuntimeLoader.ensure()}async _ensureOnboardingRuntime(){return this._onboardingRuntimeLoader.ensure()}async _ensureIsoSceneRuntime(){return this._isoSceneRuntimeLoader.ensure()}_editorRuntimeStateChanged(e){clearTimeout(this._editorRuntimeLoadingTimer),this._editorRuntimeLoadingTimer=void 0,"loading"!==e?(this._editorRuntimeLoadingVisible=!1,this.requestUpdate()):this._editorRuntimeLoadingTimer=window.setTimeout(()=>{this._editorRuntimeLoadingVisible=!0,this.requestUpdate()},150)}async _requestMode(e,t=!0,i=!1){const n=++this._editorModeRequest;if(i&&(this._warmModeRequest=n,this._refitRaf&&(cancelAnimationFrame(this._refitRaf),this._refitRaf=0),this._pendingRefitSize=null),"view"===e||await this._ensureEditorRuntime()){if(n===this._editorModeRequest&&this.isConnected)return i?(this._adoptMode(e),this._warmRevivePending&&(clearTimeout(this._warmReviveTimer),this._warmReviveTimer=void 0,this._warmReviveDialog()),this.requestUpdate(),void this.updateComplete.then(()=>requestAnimationFrame(()=>requestAnimationFrame(()=>{if(this._warmModeRequest!==n||n!==this._editorModeRequest)return;const e=this._stageEl;this._lastValidStageSize=e&&e.clientWidth>0&&e.clientHeight>0?[e.clientWidth,e.clientHeight]:null,this._pendingRefitSize=null,this._warmModeRequest=0})))):void this._setMode(e,t);this._warmModeRequest===n&&(this._warmModeRequest=0)}else this._warmModeRequest===n&&(this._warmModeRequest=0)}get _layout(){return this._adoption.layout}set _layout(e){this._adoption.stageLocalLayout(e)}get _layoutRev(){return this._adoption.layoutRev}set _layoutRev(e){this._adoption.seedIdentity({layoutRev:e})}get _layoutContentFingerprint(){return this._adoption.layoutFingerprint}set _layoutContentFingerprint(e){this._adoption.seedIdentity({layoutFingerprint:e})}get _serverCfg(){return this._adoption.config}set _serverCfg(e){this._adoption.stageLocalConfig(e)}get _cfgRev(){return this._adoption.configRev}set _cfgRev(e){this._adoption.seedIdentity({configRev:e})}get _cfgContentFingerprint(){return this._adoption.configFingerprint}set _cfgContentFingerprint(e){this._adoption.seedIdentity({configFingerprint:e})}_seedDecorStyle(e){var t,i;if(t=Ol,i=this,Fl(e,Bl)&&"pending"===t.state()&&(t.art("",i),t.ensure()),this._decorStyleSeeded||!e)return;this._decorStyleSeeded=!0;const n=e.settings?.decor_default_style;n&&(this._decorStyle=function(e,t){if(!e||"object"!=typeof e)return{...t};const i=e,n="string"==typeof i.color&&i.color?i.color:t.color,r="string"==typeof i.fill_color&&i.fill_color?i.fill_color:t.fillColor,o=Number(i.width_cm);return{color:n,opacity:Tr(i.opacity,t.opacity),widthCm:Number.isFinite(o)&&o>0?Math.max(.1,Math.min(100,o)):t.widthCm,fill:"boolean"==typeof i.fill?i.fill:t.fill,fillColor:r,fillOpacity:Tr(i.fill_opacity,t.fillOpacity)}}(n,Cr))}get _canManageConfiguration(){return null!==this._serverCanWrite?this._serverCanWrite:!0===this.hass?.user?.is_admin}get _canEdit(){return this._norm&&this._canManageConfiguration}get _kiosk(){return!!this._config?.kiosk}_showKioskDots(){this._kioskDots=!0,clearTimeout(this._kioskDotsTimer),this._kioskDotsTimer=window.setTimeout(()=>this._kioskDots=!1,2500)}get _modeTransitionBusy(){return this._modeTransitionPreparing||this._modeTransition.active}get _doubleFitEnabled(){return!("view"!==this._mode||this._vacFit||this._modeTransitionBusy||this._touchSequenceMultitouch||"steady"!==this._continuity.state||this._continuity.overlayBlocksInteraction)}_cameraState(){const e=this._viewOr(this._baseVb());return{zoom:this._zoom,viewBox:{...e}}}_normalizeCameraState(e){const t=this._cameraTransitionFit||Oi(this._baseVb(),this._stageAspect());return{zoom:Math.min(wv.ZOOM_MAX,Math.max(wv.ZOOM_MIN,e.zoom)),viewBox:this._clampView({...e.viewBox},t)}}_applyCameraTransitionFrame(e){const t=this._normalizeCameraState(e.presented);e.presented=t,this._zoom=t.zoom,this._view={...t.viewBox},this._liveVp(!0)}_settleCameraTransition(e){const t=this._normalizeCameraState(e.to);this._zoom=t.zoom,this._view={...t.viewBox},this._cameraTransitionFit=null,"room"!==e.reason&&this._saveZoom(),this.requestUpdate()}_cancelCameraTransition(e=!1,t=!1){const i=this._cameraTransition.state?.reason,n=t&&this._cameraTransition.active?this._cameraTransition.presented?.zoom:void 0;this._cameraTransition.cancel(e),this._cameraTransitionFit=null,void 0!==n&&"room"!==i&&this._saveZoom()}_prepareCameraCommand(){this._bootSoftCancel(),this._modeTransitionBusy&&this._cancelModeTransition(!0),"opening"===this._tool&&(this._cursorPt=null,this._clearOpeningPlacement(!1))}_startCameraTransition(e,t,i,n){const r=this._cameraState(),o=this._cameraTransition.target;return(!o||!Xg(o,e))&&(Xg(r,e)?(this._cancelCameraTransition(!1),!1):(this._activateSafeDayCycleOutline(),this._cameraTransitionFit={...t},this._cameraTransition.start(r,e,i,this._reducedMotion?0:n),!0))}_cssColor(e,t){const i=String(e||"").trim();if(!i)return t;const n=document.createElement("span");n.style.cssText=`position:absolute;visibility:hidden;color:${i}`,this.renderRoot.append(n);const r=getComputedStyle(n).color||t;return n.remove(),r}_currentModeVisual(e=this._mode){const t=this._modeTransition.presented||this._modeTransitionVisual;if(t)return{...t,viewport:{...t.viewport,viewBox:{...t.viewport.viewBox}}};const i=this._stageEl;if(!i||i.clientWidth<=0||i.clientHeight<=0)return null;const n=this.renderRoot.querySelector(".editorchrome"),r=this._viewOr(this._baseVb()),o=this.renderRoot.querySelector(".hp-paper"),s=this.renderRoot.querySelector(".hp-backdrop"),a=this.renderRoot.querySelector(".zoomwrap"),l=a?getComputedStyle(a).filter:"",c=Number(/brightness\(([^)]+)\)/.exec(l)?.[1]);return{presentedMode:e,editorChromeHeight:"view"===e?0:n?.getBoundingClientRect().height||0,stageWidth:i.clientWidth,stageHeight:i.clientHeight,viewport:Bg(r,i.clientWidth),stageColor:getComputedStyle(i).backgroundColor||"rgb(255, 255, 255)",paperColor:o?getComputedStyle(o).fill:"rgb(255, 255, 255)",sceneBrightness:Number.isFinite(c)?c:1,architectureOpacity:"decor"===e?.35:1,backdropOpacity:s&&Number(getComputedStyle(s).opacity)||1,viewWeight:"view"===e?1:0,editorWeight:"view"===e?0:1,toolbarContentOpacity:"view"===e?0:1}}_viewForModeTarget(e,t,i,n,r){const o=Oi(this._baseVb(),n/r),s=Math.min(wv.ZOOM_MAX,Math.max(wv.ZOOM_MIN,e)),a=o.w/s,l=o.h/s,c=t??o.x+o.w/2,h=i??o.y+o.h/2;return this._clampView({x:c-a/2,y:h-l/2,w:a,h:l},o)}_targetStageColor(e){return"view"!==e?"rgb(255, 255, 255)":this._cssColor(this._stageBg(this._spaceDisplayForRender()),this._cssColor("var(--ha-card-background, var(--card-background-color, #111))","rgb(17, 17, 17)"))}_targetPaperColor(e){return"view"===e&&this._spaceModel()?.bg?this._cssColor("var(--ha-card-background, var(--card-background-color, #111))","rgb(17, 17, 17)"):"rgb(255, 255, 255)"}_targetBrightness(e){return 1}_applyModeTransitionFrame(e){e.targetMode===this._mode&&(this._modeTransitionVisual=e.presented,this._view={...e.presented.viewport.viewBox},this.requestUpdate())}_settleModeTransition(e){if(e.targetMode!==this._mode)return;const t=this._modeTransitionRequest;this._view={...e.to.viewport.viewBox},this._zoom=this._modeTransitionTargetZoom,this._modeTransitionVisual=null,this._modeTransitionPreparing=!1,this._lastValidStageSize=[e.to.stageWidth,e.to.stageHeight],"view"===this._mode&&(this._saveZoom(),this._viewModeSnap=null,this._modeTransitionEditorCamera=null),this.requestUpdate(),this.updateComplete.then(()=>{if(!this.isConnected||t!==this._modeTransitionRequest||this._modeTransitionBusy||e.targetMode!==this._mode)return;const i=this._stageEl;if(i&&i.clientWidth>0&&i.clientHeight>0&&(Math.abs(i.clientWidth-e.to.stageWidth)>.5||Math.abs(i.clientHeight-e.to.stageHeight)>.5)){const e=this._view;this._lastValidStageSize=[i.clientWidth,i.clientHeight],this._applyView(this._zoom,e?e.x+e.w/2:void 0,e?e.y+e.h/2:void 0),this.requestUpdate()}const n=this.renderRoot.activeElement;(!n||!n.isConnected||!!n.closest?.(".editorchrome, .stage"))&&this.renderRoot.querySelector(".modetab.active")?.focus?.({preventScroll:!0})})}_cancelModeTransition(e=!0){this._cancelCameraTransition(!1);const t=!!this._modeTransition.state;this._modeTransitionRequest++,this._modeTransitionPreparing=!1,this._modeTransitionForceAtomic=!1,this._modeTransition.cancel(e),e&&t||(this._modeTransitionVisual=null)}_adoptMode(e){e!==this._mode&&(this._clearRoomFocus(!0),this._resetDeviceHitState()),this._cancelModeTransition(!1),this._mode=e,this._isoProjectionSnapshot=null,"view"!==e&&(this._editorChromeMode=e)}_commitViewModeAtomic(e,t,i,n){if(this._modeTransitionPreparing=!1,this._modeTransitionVisual=null,this._modeTransitionForceAtomic=!1,this._zoom=t,e){const r=this._stageEl?.clientWidth||e.stageWidth,o=Math.max(1,e.stageHeight+e.editorChromeHeight);this._view=this._viewForModeTarget(t,i,n,r,o),this._lastValidStageSize=[r,o]}else this._view=null;this._viewModeSnap=null,this._modeTransitionEditorCamera=null,this._saveZoom(),this.requestUpdate()}_prepareModeTransition(e,t,i,n,r,o){this.updateComplete.then(()=>{if(!this.isConnected||e!==this._modeTransitionRequest||this._mode!==i)return void(e===this._modeTransitionRequest&&(this._modeTransitionPreparing=!1,this._modeTransitionVisual=null,this._modeTransitionForceAtomic=!1,this.requestUpdate()));const s=this.renderRoot.querySelector(".editorchrome-inner"),a="view"===i?0:s?.scrollHeight||0,l=Math.max(1,(this.panelHost?this.clientHeight:innerHeight)-ef(this.renderRoot,this._stageEl,this.panelHost)),c=this._stageEl?.clientWidth||t.stageWidth,h=this._viewForModeTarget(n,r,o,c,l),d={presentedMode:i,editorChromeHeight:a,stageWidth:c,stageHeight:l,viewport:Bg(h,c),stageColor:this._targetStageColor(i),paperColor:this._targetPaperColor(i),sceneBrightness:this._targetBrightness(i),architectureOpacity:"decor"===i?.35:1,backdropOpacity:"decor"===i&&"backdrop"!==this._decorTool?.5:1,viewWeight:"view"===i?1:0,editorWeight:"view"===i?0:1,toolbarContentOpacity:"view"===i?0:1};this._modeTransitionPreparing=!1;const u=this._modeTransitionForceAtomic;this._modeTransitionForceAtomic=!1,this._modeTransition.start(t,d,i,this._reducedMotion||u?0:220)})}get _hasFixedFloor(){return!!this._config&&Object.prototype.hasOwnProperty.call(this._config,"floor")}_fixedFloorState(e=this._model,t=this._loadOk){const i=this._config?.floor,n=function(e){if(!e.hasFloor)return{kind:"absent"};const t=e.floor;if("string"==typeof t)return t.length?e.spaceIds.includes(t)?{kind:"valid",id:t,source:"id"}:{kind:"invalid",reason:"unknown-id",value:t}:{kind:"invalid",reason:"empty-id",value:t};if("number"==typeof t){if(!Number.isFinite(t))return{kind:"invalid",reason:"non-finite-index",value:t};if(!Number.isInteger(t))return{kind:"invalid",reason:"fractional-index",value:t};if(t<0)return{kind:"invalid",reason:"negative-index",value:t};const i=e.spaceIds[t];return void 0===i?{kind:"invalid",reason:"out-of-range-index",value:t}:{kind:"valid",id:i,source:"index"}}return{kind:"invalid",reason:"invalid-type",value:t}}({spaceIds:e.map(e=>e.id),hasFloor:this._hasFixedFloor,floor:i});return!this._hasFixedFloor||t?n:"number"==typeof i?"valid"===n.kind||"invalid"===n.kind&&"out-of-range-index"===n.reason?{kind:"pending",value:i}:n:"valid"===n.kind||"invalid"===n.kind&&"unknown-id"!==n.reason?n:{kind:"pending",value:i}}_canCommitSpace(e,t=!1){if(t||!this._hasFixedFloor)return!0;const i=this._fixedFloorState();return"valid"===i.kind&&i.id===e}_commitSpace(e,t=!1){return!!this._canCommitSpace(e,t)&&(e!==this._space&&(this._clearRoomFocus(!0),this._resetDeviceHitState(),this._cancelDangerConfirm(),this._cancelCameraTransition(!1),this._clearTransientHover(!0),this._cancelDevicePressFeedback(),this._editorRuntime?._clearFurniturePreview()),this._space=e,this._isoProjectionSnapshot=null,!0)}_slideTo(e,t){if(e===this._space)return!0;if(!this._canCommitSpace(e))return!1;if(this._wallFaceBatch&&this._roomDialogCancel(),"plan"===this._mode&&"draw"===this._tool&&!this._finishWallChain())return!1;this._cancelModeTransition(!0);const i=window.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches;return this._commitSpace(e),this._path=[],this._clearPlanSnapHover(),this._clearOpeningPlacement(!0),this._tool="draw",this._activeWallChainId=null,this._activeWallChainPartitionIds=[],this._wallChainSegmentCms=[],this._closingWallCm=null,this._selId=null,this._physicalSel=null,this._editorSecondary?.closeForNavigation(),this._physicalDialog=null,this._physicalDrag=null,this._restoreZoom(),i||(this._slide=t,clearTimeout(this._slideTimer),this._slideTimer=window.setTimeout(()=>{this._slideTimer=void 0,this._slide="",this.requestUpdate()},190),this.requestUpdate()),!0}get _canReorderTabs(){return Zf({canEdit:this._canEdit,kiosk:this._kiosk,mode:this._mode,pointerType:"mouse",spaceCount:this._model.length,fixedFloor:this._hasFixedFloor})}_tabPointerDown(e,t){Zf({canEdit:this._canEdit,kiosk:this._kiosk,mode:this._mode,pointerType:e.pointerType,spaceCount:this._model.length,fixedFloor:this._hasFixedFloor})&&(yv(e),this._tabDragRelease=e=>this._tabPointerUp(e),window.addEventListener("pointerup",this._tabDragRelease),window.addEventListener("pointercancel",this._tabDragRelease),this._tabDrag={id:t,pointerId:e.pointerId,x:e.clientX,y:e.clientY,moved:!1,targetId:null,placement:null})}_tabDropTargetAt(e,t,i){const n=this._model.map(e=>e.id),r=n.indexOf(i);if(r<0)return null;const o=this.renderRoot.querySelectorAll('[data-hp="space-tab"]');for(const s of o){const o=s.dataset.id||"";if(!o||o===i)continue;const a=s.getBoundingClientRect();if(ea.right||ta.bottom)continue;const l=n.indexOf(o);return l<0?null:{targetId:o,placement:l=4)))return;var i,n;const r=this._tabDropTargetAt(e.clientX,e.clientY,t.id);t.moved&&t.targetId===r?.targetId&&t.placement===r?.placement||(this._tabDrag={...t,moved:!0,targetId:r?.targetId||null,placement:r?.placement||null})}_tabPointerUp(e){const t=this._tabDrag;if(t&&t.pointerId!==e.pointerId)return;const i="pointerup"===e.type&&t?.moved?this._tabDropTargetAt(e.clientX,e.clientY,t.id):null;"pointerup"===e.type&&t?.moved&&this._suppressNextTabClick(),this._endTabDrag(),t?.moved&&i&&this._commitTabOrder(t.id,i.targetId)}_endTabDrag(){this._tabDrag=null,this._tabDragRelease&&(window.removeEventListener("pointerup",this._tabDragRelease),window.removeEventListener("pointercancel",this._tabDragRelease),this._tabDragRelease=null)}_tabClick(e){if(this._tabSuppressClick)return this._tabSuppressClick=!1,clearTimeout(this._tabSuppressClickTimer),void(this._tabSuppressClickTimer=void 0);this._pickSpace(e)}_suppressNextTabClick(){this._tabSuppressClick=!0,clearTimeout(this._tabSuppressClickTimer),this._tabSuppressClickTimer=window.setTimeout(()=>{this._tabSuppressClick=!1,this._tabSuppressClickTimer=void 0},0)}_commitTabOrder(e,t){const i=this._serverCfg;if(!i||!this._canReorderTabs)return;const n=this._model.map(e=>e.id),r=function(e,t,i){const n=e.indexOf(t),r=e.indexOf(i);if(n<0||r<0||n===r)return e;const o=e.slice();return o.splice(n,1),o.splice(r,0,t),o}(n,e,t);if(r===n)return;const o=new Map(this._devices.map(e=>[String(e.id),String(e.area||"")])),s=function(e,t,i,n=()=>""){if(!i)return[];const r=[];for(const o of e){if(!o||!0===o.removed)continue;const e="string"==typeof o.id?o.id:"";if(!e)continue;if("string"==typeof o.space&&o.space)continue;const s=("string"==typeof o.area?o.area:"")||n(e)||"";s&&t[s]||r.push({id:e,space:i})}return r}(i.markers||[],Object.fromEntries(Object.entries(this._areaToSpace).map(([e,t])=>[e,t.space])),n[0]||"",e=>o.get(e)||"");if(s.length){const e=new Map(s.map(e=>[e.id,e.space]));for(const t of i.markers||[]){const i=e.get(String(t.id));i&&(t.space=i)}}i.spaces=function(e,t){const i=new Map(t.map((e,t)=>[e,t]));return e.map((e,t)=>({space:e,index:t})).sort((e,t)=>(i.get(String(e.space?.id))??Number.MAX_SAFE_INTEGER)-(i.get(String(t.space?.id))??Number.MAX_SAFE_INTEGER)||e.index-t.index).map(e=>e.space)}(i.spaces||[],r),this._saveConfig(),this._tabOrderWarned||(this._tabOrderWarned=!0,this._showToast(this._t("toast.space_order_changed")))}_pickSpace(e){if(this._endTabDrag(),e===this._space)return;const t=this._model.map(e=>e.id),i=t.indexOf(this._space),n=t.indexOf(e);this._navApplied=!0,this._showFar=!1,this._frame=null,this._slideTo(e,i>=0&&n0&&Date.now()>=this._cyclePausedUntil&&this._model.length>1&&this._zoom<=1.001){const e=this._model.map(e=>e.id),t=e.indexOf(this._space);this._slideTo(e[(t+1)%e.length],"left"),this._showKioskDots()}}_syncCycleTimer(){clearInterval(this._cycleTimer),this._cycleTimer=void 0,this.isConnected&&!this._hasFixedFloor&&this._config?.kiosk&&Number(this._config.cycle)>0&&(this._cycleTimer=window.setInterval(()=>this._cycleTick(),1e3*Number(this._config.cycle)))}get _editing(){return"plan"===this._mode||"devices"===this._mode||"decor"===this._mode}get _markup(){return"plan"===this._mode}get _wallUnionCache(){return this._wallUnionCacheValue}set _wallUnionCache(e){this._wallUnionCacheValue=e,null===e&&this._wallUnionPool.clear()}get _glowClipCache(){return this._glowRuntimeState.clipCache}get _glowGeometryWarnings(){return this._glowRuntimeState.geometryWarnings}get _glowFeatherUnits(){return this._glowRuntimeState.featherUnits}set _glowFeatherUnits(e){this._glowRuntimeState.featherUnits=e}get _glowRenderedSources(){return this._glowRuntimeState.renderedSources}get _glowLastAppearance(){return this._glowRuntimeState.lastAppearance}get _glowFeatherSuspendUntil(){return this._glowRuntimeState.featherSuspendUntil}set _glowFeatherSuspendUntil(e){this._glowRuntimeState.featherSuspendUntil=e}get _glowFeatherResumeTimer(){return this._glowRuntimeState.featherResumeTimer}set _glowFeatherResumeTimer(e){this._glowRuntimeState.featherResumeTimer=e}get _glowSourceSeq(){return this._glowRuntimeState.sourceSeq}set _glowSourceSeq(e){this._glowRuntimeState.sourceSeq=e}_activateSafeDayCycleOutline(){this._safeDayCycleOutline=!0,this._stageEl?.classList.add("hp-safe-daycycle-outline")}get _touchSequenceMultitouch(){return this._touchClickGuard.sequenceMultitouch}_syncDangerConfirmLocaleGate(){return this._config&&this.hass?dp(this,gp,kp(this.hass,this._config.language)):"ready"}_dangerConfirmMissingSpace(){const e=this._model;if(!e.length)return!1;const t=this._fixedFloorState(e);return"pending"!==t.kind&&"invalid"!==t.kind&&!this._spaceModel()}_syncVersionRecovery(){this._versionRecovery.update({frontendVersion:ev(iv),backendVersion:this._haIntegrationVersion,kiosk:!0===this._config?.kiosk,reducedMotion:this._reducedMotion})}_newContinuityController(){return new lc(()=>{this._resumeSettling="steady"!==this._continuity.state,this._continuityEpoch++,this.isConnected&&this.requestUpdate()})}get _labsIso(){return this._labs.active.includes("iso")}get _desiredProjection(){return"view"===this._mode&&this._labsIso&&"iso"===this._viewPreference[this._space]?"iso":"flat"}_saveViewPreference(){try{localStorage.setItem(uv,JSON.stringify(this._viewPreference))}catch{}}_logicalViewCenter(e){const t=this._view;if(!t)return null;const i=[t.x+t.w/2,t.y+t.h/2],n="iso"===e?cf(i):i;return{x:n[0],y:n[1]}}_convertProjectionView(e,t){if(e===t)return;this._clearRoomFocus(!0);const i=this._logicalViewCenter(e);this._view=null;const n=i?"iso"===t?lf([i.x,i.y],0):[i.x,i.y]:null;this._applyView(this._zoom,n?.[0],n?.[1]),this._warmPatch({vp:this._warmViewportState()}),this.requestUpdate()}_setProjection(e){if(!this._labsIso||"view"!==this._mode)return;const t=this._effectiveProjection();if(this._viewPreference={...this._viewPreference,[this._space]:e},"iso"===e){this._ensureIsoSceneRuntime();const e=this._isoSceneKey();e&&this._isoFallback.delete(e),this._isoFallback.delete(`${this._space}|no-borders`),this._clearIsoInvalidFallback()}this._saveViewPreference(),this._isoProjectionSnapshot=null;const i=this._effectiveProjection();this._convertProjectionView(t,i)}_hashSpace(){return Ff(window.location.hash||"")}connectedCallback(){this._connectedPath=location.pathname,this._routeDepartureHandled=!1,this._configReloadAuthority.observeContext(Vu(this)),window.addEventListener("location-changed",this._onLocationChanged),window.addEventListener("popstate",this._onLocationChanged),this._continuityDisposed&&(this._continuity=this._newContinuityController(),this._continuityDisposed=!1,this._continuityPaintToken=-1);const e=dg(this.ownerDocument);var t;void 0!==e&&(this._glowScreenBlend=e),this._continuityUnsub?.(),this._continuityUnsub=sc(this.ownerDocument,this._pageVisibility),this._languageFailureUnsub?.(),this._languageFailureUnsub=function(...e){return()=>{for(const t of e)t()}}((t=()=>{this._showToast(this._t("toast.locale_load_failed"))},mp.add(t),()=>mp.delete(t)),function(e){return Il.add(e),()=>{Il.delete(e)}}(()=>this._showToast(this._t("toast.furniture_art_load_failed")))),super.connectedCallback(),this._summarySlot.connect(),this._ensureLiveRuntime().catch(()=>this.requestUpdate()),this._pointerModality.connect(this.ownerDocument.defaultView);const i=this.ownerDocument.defaultView?.MutationObserver;i&&(this._pointerHoverObserver=new i(e=>{let t=!1;for(const i of e){for(const e of i.addedNodes)this._syncPointerHoverSubtree(e);const e=e=>{if(e.nodeType!==Node.ELEMENT_NODE)return!1;const t=e;return t.matches(".devlayer, .devlayer *")||!!t.querySelector?.(".devlayer")};(e(i.target)||[...i.addedNodes,...i.removedNodes].some(e))&&(t=!0)}t&&this._invalidateDeviceHitGeometry()}),this._pointerHoverObserver.observe(this.renderRoot,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style","data-id"]})),this._motionMedia=window.matchMedia?.("(prefers-reduced-motion: reduce)"),this._reducedMotion=!!this._motionMedia?.matches,this._motionMedia?.addEventListener?.("change",this._onMotionChange),this._syncVersionRecovery(),this._versionRecovery.connect(),hg(this.ownerDocument).then(e=>{e!==this._glowScreenBlend&&(this._glowScreenBlend=e,this.isConnected&&this.requestUpdate())}),this.hass&&this._ensureHaRegistryAuthority(),window.addEventListener("keydown",this._keyHandler),this._signer.start(()=>this.hass,()=>this._referencedContentUrls()),this._syncCycleTimer(),window.addEventListener("hashchange",this._onHashChange),this._labsUnsub?.(),this._labsUnsub=function(e){Nf.add(e);const t=Bf();return"undefined"==typeof window&&e(t),()=>{Nf.delete(e)}}(this._onLabsSnapshot),this._labsIso&&this._ensureIsoSceneRuntime(),this._booting?this._bootWatch():this._bootFading&&(clearTimeout(this._bootTimer),this._bootTimer=window.setTimeout(()=>{this._bootFading=!1},220)),this._bootSoft&&(clearTimeout(this._bootSoftTimer),this._bootSoftTimer=window.setTimeout(()=>{this._bootSoft=!1},rv)),!this._loadOk&&this._serverCfg&&this.hass&&this._scheduleLoadRetry(),!this._warmSlot&&this._config&&this._warmAdopt(),this._loadOk&&this._ensureLiveSyncSubscriptions(),this._warmVp&&!this._warmRevivePending&&void 0===this._warmReviveTimer&&(this._warmRevivePending=!0,this._warmReviveTimer=window.setTimeout(()=>this._warmReviveDialog(),0)),this._warmLongReturn&&this._beginResumeSettle(),this._warmLongReturn=!1,this.requestUpdate()}disconnectedCallback(){this._versionRecovery.disconnect(),this._configReloadAuthority.invalidateLifecycle(),this._liveRt?.dispose(),this._radarLive.stop(),this._editorRuntime?._disposeLiveEditor(),this._clearRoomFocus(!0),this._cancelDangerConfirm(),this._connectedPath&&location.pathname!==this._connectedPath&&this._leaveCardRoute(),window.removeEventListener("location-changed",this._onLocationChanged),window.removeEventListener("popstate",this._onLocationChanged),this._continuityUnsub?.(),this._continuityUnsub=void 0,this._languageFailureUnsub?.(),this._languageFailureUnsub=void 0,this._motionMedia?.removeEventListener?.("change",this._onMotionChange),this._motionMedia=void 0,this._vacRaf&&(cancelAnimationFrame(this._vacRaf),this._vacRaf=0),this._refitRaf&&(cancelAnimationFrame(this._refitRaf),this._refitRaf=0),this._warmModeRequest=0,this._dayCycleTimer&&(clearInterval(this._dayCycleTimer),this._dayCycleTimer=0),this._summarySlot.disconnect(),this._dayCycleClockKey="",this._bootSettleRaf&&(cancelAnimationFrame(this._bootSettleRaf),this._bootSettleRaf=0),this._bootSettling=!1;for(const e of this._activityRt.values())clearTimeout(e.timer);window.removeEventListener("keydown",this._keyHandler),this._endTabDrag(),clearTimeout(this._tabSuppressClickTimer),this._tabSuppressClickTimer=void 0,this._tabSuppressClick=!1,clearInterval(this._cycleTimer),clearTimeout(this._kioskDotsTimer),clearTimeout(this._kioskHoldTimer),clearTimeout(this._reloadRetry),clearTimeout(this._loadRetryTimer),this._loadRetryTimer=void 0,this._connHooked?.removeEventListener?.("ready",this._onConnReady),this._connHooked?.removeEventListener?.("disconnected",this._onConnLost),this._connHooked?.removeEventListener?.("reconnect-error",this._onConnLost),this._connHooked=null,this._haRegistryRelease?.(),this._haRegistryRelease=void 0,this._haRegistryConnection=null,this._signer.dispose(),clearTimeout(this._toastTimer),clearTimeout(this._slideTimer),clearTimeout(this._editorRuntimeLoadingTimer),this._editorRuntimeLoadingTimer=void 0,this._editorRuntimeLoadingVisible=!1,this._modeTransition.dispose(),this._cameraTransition.dispose(),this._cameraTransitionFit=null,this._modeTransitionVisual=null,this._modeTransitionPreparing=!1,this._modeTransitionForceAtomic=!1,this._modeTransitionRequest++,this._slideTimer=void 0,this._slide="",clearTimeout(this._bootTimer),this._bootTimer=void 0,clearTimeout(this._bootSoftTimer),this._saveConfigDebounced.flush(),this._cancelDeviceDrag(),window.removeEventListener("hashchange",this._onHashChange),this._labsUnsub?.(),this._labsUnsub=void 0,clearTimeout(this._holdTimer),this._roViewport?.disconnect(),this._roViewport=void 0,this._roHdr?.disconnect(),this._roHdr=void 0,this._onWinResize&&(window.removeEventListener("resize",this._onWinResize),this._onWinResize=void 0),this._unsubCfg&&(this._unsubCfg(),this._unsubCfg=null),this._unsubLayout&&(this._unsubLayout(),this._unsubLayout=null),this._unsubVirtual&&(this._unsubVirtual(),this._unsubVirtual=null),this._unsubTrail&&(this._unsubTrail(),this._unsubTrail=void 0),this._liveSyncGeneration++,this._liveSyncAttempt=null,this._liveSyncConnection=null,clearTimeout(this._layoutSyncTimer),clearTimeout(this._duplicateColumnTimer),Fm(this._glowRuntimeState,this._glowRuntimeHost),this._warmSnapshot(),this._warmRevivePending=!1,clearTimeout(this._warmReviveTimer),this._warmReviveTimer=void 0,this._warmRelease(),this._clearPlanSnapHover(),this._clearOpeningPlacement(!0),this._editorRuntime?._clearFurniturePreview(),this._editorRuntime?._furnShiftDetach(),this._touchContacts.clear(),this._touchClickGuard.reset(),this._resetDeviceHitState(),this._clearTransientHover(!0),this._cancelDevicePressFeedback(),this._pointerHoverObserver?.disconnect(),this._pointerHoverObserver=void 0,this._pointerModality.disconnect(),this._editorSecondary?.reset(),this._resumeSettling=!1,this._continuityHistory=[...this._continuityHistory,...this._continuity.trace].slice(-80),this._continuity.dispose(),this._continuityDisposed=!0,super.disconnectedCallback()}_onKey(e){if("Escape"===e.key&&this._vacFit){if(this._vacFit.busy)return;return this._vacFit=null,this._showToast(this._t("vac.cal_cancelled")),void e.stopPropagation()}if("Escape"===e.key){if(this._tapConfirm)return void(this._tapConfirm=null);if(this._vacCalConfirm)return void(this._vacCalConfirm.busy||(this._vacCalConfirm=null));if(this._decorEraseConfirm)return void(this._decorEraseConfirm=null);if(this._openingInfo)return void(this._openingInfo=null);if(this._infoCard)return void this._closeInfoCard();if(this._rulesDialog)return void(this._rulesDialog=null);if(this._alignDialog)return this._alignDialog=null,void(this._preflightClipboardFallback=null);if(this._backupImportDialog)return void(this._backupImportDialog=null);if(this._backupExportDialog)return void(this._backupExportDialog=null);if(this._pdfDialog)return void(this._pdfDialog=!1);if(this._supportDialog)return void this._editorRuntime?._closeSupportDialog();if(this._settingsDialog)return void(this._settingsDialog=null);if(this._summary?.closeDialogIfIdle())return;if(this._markerDialog)return void this._closeMarkerDialog();if(this._deviceInbox)return void(this._deviceInbox=null);if(this._openingDialog)return void(this._openingDialog=null);if(this._physicalDialog)return void(this._physicalDialog=null);if(this._backdropDialog)return void(this._backdropDialog=null);if(this._decorShapeDialog)return void(this._decorShapeDialog=null);if(this._decorTextDialog)return void(this._decorTextDialog=null);if(this._spaceDialog&&!this._roomDialog)return this._spaceDialog=null,this._importQueue=[],void(this._importTotal=0);if(this._editorSecondary?.hasOpenGroup)return e.preventDefault(),void this._editorSecondary?.closeGroup(!0)}const t=e.composedPath?.()||[e.target],i=t.some(e=>e?.matches?.('input, textarea, select, [contenteditable="true"]')),n=t.some(e=>e?.classList?.contains?.("editor-secondary")),r=e.ctrlKey||e.metaKey,o=e.key.toLowerCase(),s=/^[a-z]$/.test(o),a="z"===o||!s&&"KeyZ"===e.code,l="y"===o||!s&&"KeyY"===e.code,c=r&&(a&&e.shiftKey||l),h=r&&a&&!e.shiftKey;if("decor"===this._mode){if((h||c)&&i)return;if(c)return e.preventDefault(),void this._redoGeometry();if(h)return e.preventDefault(),this._decorDraft?void(this._decorDraft=null):this._decorMove||this._dtDrag||this._bdDrag?void this._cancelDecorGesture():void this._undoGeometry();if(("Delete"===e.key||"Backspace"===e.key)&&this._decorSel&&!i&&!n)return e.preventDefault(),void this._decorDeleteSel();const t="ArrowLeft"===e.key?[-this._gridPitch,0]:"ArrowRight"===e.key?[this._gridPitch,0]:"ArrowUp"===e.key?[0,-this._gridPitch]:"ArrowDown"===e.key?[0,this._gridPitch]:null;return!t||r||e.altKey||"select"!==this._decorTool||!this._decorSel||!this._decorList.some(e=>e.id===this._decorSel)||this._decorDraft||this._decorMove||this._dtDrag||this._bdDrag||i||n||this._editorSecondaryDialogBlocked?void("Escape"===e.key&&(e.preventDefault(),this._decorDraft?this._decorDraft=null:this._decorMove||this._dtDrag||this._bdDrag?this._cancelDecorGesture():"furniture"===this._decorTool?(this._editorRuntime?._clearFurniturePreview(),this._editorRuntime?._furnShiftDetach(),this._furnPalette=null,this._furnCategory=null,this._decorTool="select"):this._decorSel?this._decorSel=null:"select"!==this._decorTool?this._decorTool="select":this._setMode("view"))):(e.preventDefault(),void this._decorNudge(t[0],t[1]))}if("devices"===this._mode){if((h||c)&&i)return;return c?(e.preventDefault(),void this._redoDevicePosition()):h?(e.preventDefault(),void this._undoDevicePosition()):void("Escape"===e.key&&this._deviceDrag&&(e.preventDefault(),this._cancelDeviceDrag()))}if(this._markup&&(!h&&!c||!i)){if(("Delete"===e.key||"Backspace"===e.key)&&this._physicalSel&&!i&&!n)return e.preventDefault(),void this._deletePhysicalSelection();if(c)return e.preventDefault(),void this._redoGeometry();if(h)return e.preventDefault(),this._resize?.dragging?void this._rszCancelDrag():this._wallFaceBatch?(this._roomDialogCancel(),void(this._activeWallChainId&&this._path.length>1?this._undoActiveWallPoint():this._undoPoint())):"draw"===this._tool&&this._path.length?void(this._activeWallChainId&&this._path.length>1?this._undoActiveWallPoint():this._undoPoint()):"split"===this._tool&&this._splitSel?.pts?.length?(this._splitSel={...this._splitSel,pts:this._splitSel.pts.slice(0,-1)},void(this._splitSel.pts.length||(this._cursorPt=null))):void this._undoGeometry();if("Escape"===e.key)return this._physicalDrag||this._physicalRotate?(e.preventDefault(),void this._cancelPhysicalGesture()):this._roomDialog?(e.preventDefault(),void this._roomDialogCancel()):"draw"===this._tool&&this._path.length?(e.preventDefault(),void this._finishWallChain()):this._physicalSel?(e.preventDefault(),void(this._physicalSel=null)):"resize"===this._tool?(e.preventDefault(),this._resize?.dragging?void this._rszCancelDrag():("exit-tool"===this._resize?.escapeIdle()&&(this._tool="draw"),void this.requestUpdate())):"split"===this._tool?(e.preventDefault(),void(this._splitSel?.pts?.length?(this._splitSel={...this._splitSel,pts:this._splitSel.pts.slice(0,-1)},this._splitSel.pts.length||(this._cursorPt=null)):this._splitSel?this._splitSel=null:this._tool="draw")):"merge"===this._tool?(e.preventDefault(),void(this._mergeSel?this._mergeSel=null:this._tool="draw")):this._wallDialog?(e.preventDefault(),void(this._wallDialog=null)):void("opening"!==this._tool&&"wallthick"!==this._tool&&"delroom"!==this._tool&&"column"!==this._tool||(e.preventDefault(),"opening"===this._tool&&this._clearOpeningPlacement(!0),this._tool="draw"))}}_undoPoint(){if(this._path.length)return this._contourClosed?(this._path=this._path.slice(0,-1),void(this._closingWallCm=null)):void(this._activeWallChainPartitionIds.length&&this._path.length>1?this._undoActiveWallPoint():this._path=this._path.slice(0,-1))}_undoActiveWallPoint(){const e=[...this._activeWallChainPartitionIds],t=e[e.length-1],i=this._spaceModel()?.partitions.find(e=>e.id===t),n=this._path[0]?[...this._path[0]]:null,r=this._path.slice(0,-1).map(e=>[...e]),o=this._wallChainSegmentCms.slice(0,-1),s=this._geometryHistory.undo();if(!s)return this._activeWallChainPartitionIds=[],this._wallChainSegmentCms=[],this._wallChainRedo=[],void(this._path=n?[n]:[]);this._applyGeometryState(s.before,!0)?(this._activeWallChainId||=`chain-${Date.now().toString(36)}`,this._activeWallChainPartitionIds=e.slice(0,-1),this._path=r.length?r:n?[n]:[],this._wallChainSegmentCms=o,i&&this._wallChainRedo.push({id:i.id,point:[...i.b],cm:i.cm}),this._clearPlanSnapHover(),this._showToast(this._t("history.undone",{name:s.name}))):this._geometryHistory.clear()}static async getConfigElement(){return await import("./editor-0Mj9gnAf.js"),document.createElement("houseplan-card-editor")}static getStubConfig(){return{type:"custom:houseplan-card"}}static _warmBootReset(e){for(const e of ov.values())for(const t of e)clearTimeout(t.evict);ov.clear(),av=e&&e>0?e:1e4}static _warmBootStats(){let e=0,t=0;const i=[];for(const n of ov.values())for(const r of n)e++,r.dlg&&(t++,i.push(r.dlg.kind));return{keys:ov.size,slots:e,dlgs:t,drafts:i}}setConfig(e){const t=this._config,i=!!t&&Object.prototype.hasOwnProperty.call(t,"floor");this._config={icon_size:2.5,show_temperature:!0,live_states:!0,show_signal:!0,...e};(i!==this._hasFixedFloor||t?.floor!==this._config.floor)&&(this._hashApplied=!1,this._navApplied=!1,this._warmVpArmed=!1),this._config.kiosk&&(this._booting=!1,this._bootFading=!1),!this._hasFixedFloor&&e.default_floor&&this._commitSpace(e.default_floor,!0);try{this._zoomBySpace=JSON.parse(localStorage.getItem(hv)||"{}")||{}}catch{this._zoomBySpace={}}try{const e=JSON.parse(localStorage.getItem(uv)||"{}")||{};this._viewPreference=Object.fromEntries(Object.entries(e).filter(e=>"flat"===e[1]||"iso"===e[1]))}catch{this._viewPreference={}}if(this._labs=Bf(),this.isConnected&&this._labsIso&&this._ensureIsoSceneRuntime(),!this._summary?.applyLocalScaleForCurrentIdentity())try{const e=JSON.parse(localStorage.getItem("houseplan_card_kiosk_v1")||"null");this._kioskScale={icon:jn(e?.icon),font:jn(e?.font)}}catch{}try{const e=JSON.parse(localStorage.getItem(cv)||"null");this._adoption.restoreCached(e)&&(this._seedDecorStyle(this._serverCfg),this._cfgEpoch++,this._virtualLights=Hh(e.virtual_lights,this._cfgRev),this._serverStorage=!0)}catch{}this._adoptInitialSpace(this._model,this._loadOk),"view"!==this._mode||this._view||(this._zoom=this._zoomBySpace[this._space]||1),this.isConnected&&(this._syncCycleTimer(),this._warmAdopt(),this._warmLongReturn&&this._beginResumeSettle(),this._warmLongReturn=!1),this._syncVersionRecovery()}_warmAdopt(){if(this._config?.kiosk)return;const e=Cf(this._config);if(this._warmKey===e&&this._warmSlot)return;this._warmSlot&&this._warmRelease();const t=this.parentNode,i=this._warmIdx(t),n=ov.get(e);if(!n||!n.length)return;const r=n.find(e=>e.owner===this._warmGen);if(r)return this._warmLongReturn=!!r.freed&&Date.now()-r.freed>=nc,clearTimeout(r.evict),r.evict=0,r.freed=0,r.live=!0,this._warmSlot=r,this._warmKey=e,r.frameFingerprint&&this._continuity.adoptCompleteFrame(r.frameFingerprint),void(!this._devices.length&&r.devices?.length&&(this._devices=[...r.devices]));const{slot:o,sure:s}=((e,t,i,n)=>{const r=e=>{const t=!!i&&e.place?.deref()===i;return t&&e.idx===n?4:e.live?0:t?3:2};let o=null,s=0,a=0,l=null;for(const i of e){if(i.owner===t)continue;l=i;const e=r(i);e<=0||(e>s?(o=i,s=e,a=1):e===s&&a++)}return!o||a>1?{slot:o||l,sure:!1}:{slot:o,sure:!0}})(n,this._warmGen,t,i);o&&(this._warmLongReturn=!!o.freed&&Date.now()-o.freed>=nc,this._booting=!1,this._bootFading=!1,this._hdrH=o.hdrH,this._bootSoft=!0,this.isConnected&&(clearTimeout(this._bootSoftTimer),this._bootSoftTimer=window.setTimeout(()=>{this._bootSoft=!1},rv)),this._warmKey=e,s?(clearTimeout(o.evict),o.evict=0,o.owner=this._warmGen,o.place=t?new WeakRef(t):null,o.idx=i,o.live=!0,this._warmSlot=o,this._warmVp=o.vp,o.frameFingerprint&&this._continuity.adoptCompleteFrame(o.frameFingerprint),!this._devices.length&&o.devices?.length&&(this._devices=[...o.devices]),this._warmAdoptViewport(this._config)):(this._warmSlot={owner:this._warmGen,path:location.pathname,place:t?new WeakRef(t):null,idx:i,live:!0,hdrH:o.hdrH,stageH:o.stageH,vp:null,frameFingerprint:"",devices:null,dlg:null,freed:0,evict:0},n.push(this._warmSlot),this._warmTrim(n)))}_warmIdx(e){const t=e?.children;if(!t)return-1;for(let e=0;e4;){const t=e.findIndex(e=>!e.live);if(t<0)break;clearTimeout(e[t].evict),e.splice(t,1)}}_warmScheduleEvict(e,t){if(clearTimeout(e.evict),!(e.dlg||e.vp&&"view"!==e.vp.mode))return;const i=e.freed,n=e.owner;e.evict=window.setTimeout(()=>{if(e.evict=0,e.freed!==i||e.owner!==n)return;var r;e.dlg=null,e.vp=(r=e.vp)&&"view"!==r.mode?{...r,mode:"view",zoom:r.snap?.space===r.space?r.snap.zoom:r.zoom,view:null,snap:null,tool:"draw",decorTool:"select",showHidden:!1,selId:null,rszSel:null,decorSel:null}:r,e.frameFingerprint="";const o=ov.get(t);if(!e.live&&o&&o.length>1){const t=o.indexOf(e);t>=0&&o.splice(t,1)}},av+250)}_warmAdoptViewport(e){const t=this._warmVp;if(!t||this._warmSlot?.path!==location.pathname)return void(this._warmVp=null);const i=this._fixedFloorState();if(this._hashApplied||!this._model.find(e=>e.id===t.space)||"valid"===i.kind&&i.id!==t.space||this._hasFixedFloor&&"valid"!==i.kind)return void(this._warmVp=null);this._commitSpace(t.space,!0),this._navApplied=!0;const n="view"!==t.mode&&this._canEdit&&!e.kiosk?t.mode:"view";this._adoptMode("view"),this._pendingNavMode="view"===t.mode||this._canEdit||e.kiosk?null:t.mode,this._zoom=t.zoom;const r=this._effectiveProjection(),o=r===t.projection&&this._labsIso===t.activeLabsIso;if(this._view=o&&t.view?{...t.view}:null,this._viewModeSnap=o&&t.snap?{...t.snap}:null,!o&&t.logicalCenter){const e="iso"===r?lf([t.logicalCenter.x,t.logicalCenter.y],0):[t.logicalCenter.x,t.logicalCenter.y];this._applyView(t.zoom,e[0],e[1])}var s;this._tool="opening"===(s=function(e){return"partition"===e?"draw":e}(s=t.tool))?"draw":"string"==typeof s&&Rf.has(s)?s:"draw",this._decorTool=t.decorTool,this._showHidden=t.showHidden,this._showFar!==t.showFar&&(this._showFar=t.showFar,this._frame=null),this._selId=t.selId,this._resize?.restoreSelection(t.rszSel),this._decorSel=t.decorSel,this._warmVpArmed=!0,"view"!==n&&this._requestMode(n,!1,!0)}_warmPatch(e,t=!1){if(this._config?.kiosk)return;const i=Cf(this._config);if(!this._warmSlot||this._warmKey===i){if(!this._warmSlot){if(!t)return;const e=this.parentNode;this._warmKey=i,this._warmSlot={owner:this._warmGen,path:location.pathname,place:e?new WeakRef(e):null,idx:this._warmIdx(e),live:!0,hdrH:this._hdrH,stageH:0,vp:null,frameFingerprint:"",devices:null,dlg:null,freed:0,evict:0};const n=ov.get(i)||[];for(n.push(this._warmSlot),ov.set(i,n),this._warmTrim(n);ov.size>8;){const e=ov.keys().next().value;if(void 0===e||e===i)break;for(const t of ov.get(e)||[])clearTimeout(t.evict);ov.delete(e)}}Object.assign(this._warmSlot,e)}}_warmViewportState(){const e=this._effectiveProjection();return{space:this._space,mode:this._mode,projection:e,activeLabsIso:this._labsIso,logicalCenter:this._logicalViewCenter(e),zoom:this._zoom,view:this._view?{...this._view}:null,snap:this._viewModeSnap?{...this._viewModeSnap}:null,tool:this._tool,decorTool:this._decorTool,showHidden:this._showHidden,showFar:this._showFar,selId:this._selId,rszSel:this._resize?.selectedRoomId,decorSel:this._decorSel}}_warmDialogState(){const e=(e,t)=>({kind:e,space:this._space,mode:this._mode,data:t});return this._tapConfirm||this._alignDialog||this._mergeDialog||this._importDialog||this._backupExportDialog||this._backupImportDialog?null:this._openingInfo?e("openingInfo",this._openingInfo.id):this._infoCard?e("info",this._infoCard.id):this._rulesDialog?this._rulesDialog.busy?null:e("rules",this._rulesDialog):this._settingsDialog?this._settingsDialog.busy?null:e("settings",this._settingsDialog):this._markerDialog?this._markerDialog.busy?null:e("marker",this._markerDialog):this._openingDialog?e("opening",this._openingDialog):this._backdropDialog?e("backdrop",this._backdropDialog):this._decorShapeDialog?e("decorShape",this._decorShapeDialog):this._decorTextDialog?e("decorText",this._decorTextDialog):this._roomDialog?e("room",{editId:this._roomEditId,fill:this._roomFill,customFill:this._roomCustomFill,tempMin:this._roomTempMin,tempMax:this._roomTempMax,tempSrc:this._roomTempSrc,humSrc:this._roomHumSrc,srcOpen:this._roomSrcOpen,srcFilter:this._roomSrcFilter,nameScale:this._roomNameScale,labelScale:this._roomLabelScale,areaSel:this._areaSel,nameSel:this._nameSel,pendingSplit:this._pendingSplit,wallFaceBatch:this._wallFaceBatch,path:this._path}):this._spaceDialog?this._spaceDialog.busy?null:e("space",this._spaceDialog):null}_warmSnapshot(){if(this._booting||this._config?.kiosk||"steady"!==this._continuity.state)return;const e={vp:this._warmViewportState(),frameFingerprint:this._continuity.frameFingerprint,devices:this._devices,hdrH:this._hdrH};if(this._warmRevivePending||(e.dlg=this._warmDialogState()),this.isConnected&&this._warmSlot?.owner===this._warmGen){const t=this.parentNode;e.place=t?new WeakRef(t):null,e.idx=this._warmIdx(t)}this._warmPatch(e)}_warmReviveDialog(){const e=this._warmSlot;if(this._warmReviveTimer=void 0,!e||!e.dlg)return void(this._warmRevivePending=!1);const t=e.dlg,i=e.freed;if(t.mode===this._mode||"view"===t.mode||this._warmVp?.mode!==t.mode||this._editorRuntime){if(this._warmRevivePending=!1,e.dlg=null,e.freed=0,clearTimeout(e.evict),e.evict=0,i&&!(Date.now()-i>av)&&t.space===this._space&&t.mode===this._mode){switch(t.kind){case"space":this._spaceDialog={...t.data,busy:!1,savedBusy:!1};break;case"marker":this._markerDialog={...t.data,busy:!1};break;case"settings":this._settingsDialog={...t.data,busy:!1};break;case"rules":this._rulesDialog={...t.data,busy:!1};break;case"opening":this._openingDialog={...t.data};break;case"backdrop":this._backdropDialog={...t.data};break;case"decorShape":this._decorShapeDialog={...t.data};break;case"decorText":{this._decorTextDialog={...t.data};const e=String(this._decorTextDialog?.text??"").length;this._decorTextSelection={start:e,end:e};break}case"room":{const e=t.data;this._roomEditId=e.editId,this._roomFill=e.fill,this._roomCustomFill=e.customFill||null,this._roomTempMin=e.tempMin||"",this._roomTempMax=e.tempMax||"",this._roomTempSrc=e.tempSrc,this._roomHumSrc=e.humSrc,this._roomSrcOpen=e.srcOpen,this._roomSrcFilter=e.srcFilter,this._roomNameScale=e.nameScale,this._roomLabelScale=e.labelScale,this._areaSel=e.areaSel,this._nameSel=e.nameSel,this._pendingSplit=e.pendingSplit,this._wallFaceBatch=e.wallFaceBatch||null,this._path=e.path,this._wallFaceBatch&&(this._activeWallChainId=`chain-${Date.now().toString(36)}`,this._activeWallChainPartitionIds=[...this._wallFaceBatch.activePartitionIds],this._wallChainSegmentCms=[...this._wallFaceBatch.activeCms]),this._roomDialog=!0;break}case"info":{const e=this._devices.find(e=>e.id===t.data);e&&(this._infoCard=e);break}case"openingInfo":{const e=(this._curSpaceCfg?.openings||[]).find(e=>e.id===t.data);e&&(this._openingInfo=e);break}}this.requestUpdate()}}else this._warmRevivePending=!0}_cacheSnapshot(){if(this._serverCfg)try{this._virtualLights=function(e,t,i){if(e.configRev===i)return e;const n=new Set((Array.isArray(t?.markers)?t.markers:[]).filter(qh).map(e=>e.id));return{...e,configRev:i,off:new Set([...e.off].filter(e=>n.has(e)))}}(this._virtualLights,this._serverCfg,this._cfgRev);const e=this._adoption.snapshot(function(e){return{rev:e.rev,config_rev:e.configRev,off:[...e.off].sort()}}(this._virtualLights));e&&localStorage.setItem(cv,JSON.stringify(e))}catch{}}_beginContinuityCandidate(e,t,i="plan"){return this._booting&&!this._continuity.hasCompleteFrame?this._continuity.token:(this._continuityDataReady=t,this._continuityPaintToken=-1,this._stagedDeviceSnapshotToken=-1,this._resumeSettling=!0,this._continuity.beginCandidate(e,i))}_continuityStageValid(){const e=this._stageEl;return!!e&&e.clientWidth>0&&e.clientHeight>0}_versionReloadSafetySnapshot(){return Sg(this)}_continuityAssetsReady(){if(!this._model.length)return!1;const e=this._model.length?this._spaceModel():null;return!e?.bg?.href||this._signer.isReady(this.hass,e.bg.href)}_initialSpaceSelection(e,t=this._loadOk){const i=this._fixedFloorState(e,t);return"valid"===i.kind?{id:i.id,source:"fixed"}:this._hasFixedFloor?{id:null,source:"none"}:function(e){const t=new Set(e.spaceIds.filter(e=>!!e));if(!t.size)return{id:null,source:"none"};const i=[["hash",!1===e.acceptHash?null:e.hashSpace],["current",e.preserveCurrent?e.currentSpace:null],["saved",e.savedSpace],["default",e.defaultSpace],["first",e.spaceIds[0]]];for(const[e,n]of i)if(n&&t.has(n))return{id:n,source:e};return{id:null,source:"none"}}({spaceIds:e.map(e=>e.id),hashSpace:this._hashSpace(),acceptHash:!this._hashApplied,currentSpace:this._space,preserveCurrent:this._hashApplied||this._navApplied||this._warmVpArmed,savedSpace:this._savedNav()?.space,defaultSpace:this._config?.default_floor})}_adoptInitialSpace(e,t=this._loadOk){const i=this._initialSpaceSelection(e,t);return i.id?(this._commitSpace(i.id,!0),"hash"===i.source&&(this._hashApplied=!0),"saved"===i.source&&(this._navApplied=!0),i):i}_candidateBackdrop(e,t=this._space){const i=el(e),n=this._fixedFloorState(i,!0);if(this._hasFixedFloor&&"valid"!==n.kind)return"";const r=this._initialSpaceSelection(i,!0).id||(i.some(e=>e.id===t)?t:i[0]?.id);return i.find(e=>e.id===r)?.bg?.href||""}_visualFrameFingerprint(){const e=this._stageEl,t=e?[e.clientWidth,e.clientHeight]:[0,0];return hc([this._cfgRev,this._adoption.currentConfigFingerprint(),this._layoutRev,this._adoption.currentLayoutFingerprint(),this._space,this._mode,this._view,t,this._glowScreenBlend?"screen":"normal",this.hass?.themes?.darkMode??this.hass?.themes?.default_theme??""])}_settleContinuityFrame(){if(this._booting||!this._continuityStageValid())return;if(!this._continuity.hasCompleteFrame&&"steady"===this._continuity.state)return void(this._continuityAssetsReady()&&(this._renderSnapshotAt=Date.now(),this._continuity.markCompleteFrame(this._visualFrameFingerprint())));if(!this._continuityDataReady)return;if(!["holding","offline-stale","overlay-pending","overlay-visible","candidate-ready"].includes(this._continuity.state))return;const e=this._continuity.token;if(this._candidateDeviceSnapshot&&this._candidateDeviceSnapshot!==this._visibleDeviceSnapshot&&this._stagedDeviceSnapshotToken!==e)return this._stagedDeviceSnapshotToken=e,void this.requestUpdate();this._continuityPaintToken!==e&&(this._continuityPaintToken=e,this._continuity.candidateReady(e)&&this._continuity.commitAfterPaint(e,{updateComplete:()=>this.updateComplete,stageValid:()=>this.isConnected&&this._continuityStageValid(),assetsReady:()=>this._continuityAssetsReady(),frameFingerprint:()=>this._visualFrameFingerprint()}).then(t=>{t&&e===this._continuity.token?(this._resumeSettling=!1,this._renderSnapshotAt=Date.now(),this._candidateDeviceSnapshot&&(this._visibleDeviceSnapshot=this._candidateDeviceSnapshot),this._candidateDeviceSnapshot=null,this._stagedDeviceSnapshotToken=-1,this._warmSnapshot()):e===this._continuity.token&&(this._continuityPaintToken=-1,this._stagedDeviceSnapshotToken=-1,this._candidateDeviceSnapshot=null,this.requestUpdate())}))}_onBackdropLoaded(e,t){this._signer.markLoaded(this.hass,e,t),this._continuity.note("asset-ready"),this._continuityPaintToken=-1,"steady"!==this._continuity.state&&this.requestUpdate()}_renderRecoveryOverlay(){if(!this._continuity.overlayVisible&&"recovery-error"!==this._continuity.state)return G;const e="connection"===this._continuity.recoveryReason;return j`
    e.stopPropagation()} @click=${e=>e.stopPropagation()} @@ -363,7 +363,7 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db aria-label=${this._t("editor.loading_aria")}> ${this._t("editor.loading")} -
    `:G}houseplanContinuityTrace(){return[...this._continuityHistory,...this._continuity.trace].slice(-80).map(e=>({...e,...e.stage?{stage:[...e.stage]}:{}}))}getCardSize(){return 12}getGridOptions(){return{columns:"full"}}get _norm(){return!(!this._serverCfg||!this._serverCfg.spaces.length)}_cfgFingerprint(){const e=this._serverCfg?.spaces||[];let t=e.length+":";for(const i of e){t+=(i.id||"")+","+(i.plan_aspect||"")+","+(i.plan_url||"").length+","+(i.plan_x??"")+","+(i.plan_y??"")+","+(i.plan_scale??"")+","+(i.plan_scale_x??"")+","+(i.plan_scale_y??"")+","+(i.plan_angle??"")+","+(i.rooms?.length||0)+","+(i.openings?.length||0)+","+(i.decor?.length||0)+";";for(const e of i.rooms||[]){const i=e.poly?.[0],n=e.poly?.[e.poly.length-1];t+=(e.poly?.length||0)+"."+(e.id||"")+"."+(e.open_to||[]).join("+")+"."+(e.area||"")+"."+JSON.stringify(e.settings||0)+"."+(e.x??"")+","+(e.y??"")+","+(e.w??"")+","+(e.h??"")+","+(i?i[0]+"/"+i[1]:"")+","+(n?n[0]+"/"+n[1]:"")+";"}}return t}get _model(){if(!this._serverCfg)return[];const e=this._cfgEpoch+"|"+this._cfgFingerprint();if(this._modelCache&&this._modelCache.key===e)return this._modelCache.model;const t=this._buildModel();return this._modelCache={key:e,model:t},t}_buildModel(){if(!this._serverCfg)return[];const e=this._renderCfg;return el(e).map((t,i)=>{const n=e.spaces[i]?.plan_url;return t.bg&&n?{...t,bg:{...t.bg,href:n}}:t})}_spaceModel(){return this._hasFixedFloor?kc(this._model,this._space):(e=this._model,t=this._space,e.find(e=>e.id===t)??e[0]);var e,t}_spaceModelById(e){return kc(this._model,e)}_syncEmptySpaceState(){if(!!this._serverCfg&&0===this._serverCfg.spaces.length){if(!this._emptySpaceStateActive){this._emptySpaceStateActive=!0,this._clearRoomFocus(!0);for(const e of this._pointers.keys())for(const t of this.renderRoot.querySelectorAll("*"))try{t.hasPointerCapture?.(e)&&t.releasePointerCapture(e)}catch{}this._pointers.clear(),this._panStart=null,this._panLock=null,this._pinchStart=null,this._swipeStart=null,this._drag=null,this._deviceDrag=null,this._resetDeviceHitState(),this._rlResize=null,this._vacFit=null,this._compassDrag=!1,this._cancelModeTransition(!1),this._mode="view",this._clearGeometryGesture(),this._geometryHistory.clear(),this._devicePositionHistory.clear(),this._tip=null,this._hoverRoom=null,this._openingInfo=null,this._closeInfoCard(),this._deviceInbox=null,this._deviceInboxReturn=null,this._markerDialog=null,this._physicalDialog=null,this._backdropDialog=null,this._decorShapeDialog=null,this._decorTextDialog=null,this._roomDialog=!1,"edit"===this._spaceDialog?.mode&&(this._spaceDialog=null),this._editorSecondary?.closeForNavigation(),this._saveConfigDebounced.cancel(),this._frame=null,this._planSnapGeometryCache=null,this._hiddenWallDiagnosticCache=null,this._decorSnapCache=null,this._commitSpace("",!0)}}else this._emptySpaceStateActive=!1}get _areaToSpace(){const e={};for(const t of this._model)for(const i of t.rooms)i.area&&(e[i.area]={space:t.id,room:i});return e}get _settings(){return this._serverCfg?.settings||{}}get _showAll(){return this._showHidden||!this._settings.filter_seeded&&!!this._settings.show_all}_seedHiddenDevices(){if(!(this._loadOk&&this._serverCfg&&this._norm&&this._canEdit))return;const e=this._serverCfg,t=eu({hass:this.hass,registry:this._haRegistry,areaToSpace:Object.fromEntries(Object.entries(this._areaToSpace).map(([e,t])=>[e,t.space])),markers:this._markers,settings:this._settings,excluded:this._excluded,firstSpaceId:this._model[0]?.id||"",iconRules:this._iconRules});if(!t.length&&e.settings?.filter_seeded)return;e.markers=e.markers||[];const i=[];for(const n of t){const t="h"+n.slice(n.indexOf(":")+1);e.markers.push({id:t,binding:n,hidden:!0}),i.push(n.slice(n.indexOf(":")+1))}const n={...e.settings||{},filter_seeded:!0};delete n.show_all,i.length&&Array.isArray(n.new_device_ids)&&(n.new_device_ids=n.new_device_ids.filter(e=>!i.includes(e))),e.settings=n,this._regSignature="",this._maybeRebuildDevices(),this._saveConfig(),this.requestUpdate()}get _iconRules(){const e=this._settings.icon_rules;if(!e||!Array.isArray(e)||!e.length)return;const t=JSON.stringify(e);return t!==this._rulesCompiledSrc&&(this._rulesCompiledSrc=t,this._rulesCompiled=Ee(e)),this._rulesCompiled}get _fillColors(){return vn(this._settings)}get _excluded(){return lu(this._settings)}_setAreaLifecycleConfig(e){this._cfgEpochPreservedConfig=e,this._serverCfg=e}willUpdate(e){if(this._isoProjectionSnapshot=null,this._summary?.willUpdate(),e.has("hass")&&this._configReloadAuthority.observeContext(Vu(this)),e.has("_serverCfg")){const e=this._cfgEpochPreservedConfig===this._serverCfg;this._cfgEpochPreservedConfig=null,e||this._cfgEpoch++,this._renderLife.invalidate()}if(this._syncEmptySpaceState(),this._dangerConfirm&&(this._dangerConfirmMissingSpace()||"warm"===this._syncDangerConfirmLocaleGate())&&this._cancelDangerConfirm(),e.has("hass")&&this.hass){const t=this._visibleDeviceSnapshot||this._candidateDeviceSnapshot;this._renderLife.observe(e.get("hass"),this.hass,t?{entityIds:t.entityIds}:null,()=>Mg(this))}this._continuity.hasCompleteFrame&&"steady"===this._continuity.state&&this._continuity.refreshCompleteFrame(this._visualFrameFingerprint()),this._captureRenderDeviceSnapshot()}updated(){this._summary?.updated(),this._liveRt?.commit(),this._editorRuntime?._commitLiveEditor(),this._pruneDevicePressFeedback(),this._syncDayCycleClock(),this._syncRadarLive(),this._warmSnapshot(),this._editorRuntime&&this._dtMeasure();const e=this._stageEl;e&&!this._roViewport&&(this._roViewport=new ResizeObserver(()=>{this._invalidateDeviceHitGeometry(),this._refitView(),requestAnimationFrame(()=>this._summary?.resized())}),this._roViewport.observe(e)),e&&this._booting&&!this._bootTimer&&this._bootWatch();const t=this.renderRoot.querySelector(".hdr");if(t&&e&&!this._roHdr){const i=()=>{const t=ef(this.renderRoot,e,this.panelHost);null!==t&&(t>=0&&t!==this._hdrH&&(this._hdrH=t),t>=0&&!this._booting&&!this._config?.kiosk&&e.clientHeight>0&&this._warmPatch({hdrH:t,stageH:e.clientHeight}))};this._roHdr=new ResizeObserver(()=>requestAnimationFrame(i)),this._roHdr.observe(t),this._onWinResize=()=>requestAnimationFrame(i),window.addEventListener("resize",this._onWinResize),i()}if(e&&!this._view&&this._refitView(),this._editorSecondary?.afterRender(),this._settleContinuityFrame(),this._serverStorage&&this._loadOk&&this._canManageConfiguration&&0===this._model.length&&!this._spaceDialog&&!this._importDialog&&!this._onboardingShown){this._onboardingShown=!0;const e=function(e){const t=e?.floors;if(!t||"object"!=typeof t)return[];const i=[];for(const e of Object.values(t))e&&e.floor_id&&i.push({id:e.floor_id,name:e.name||e.floor_id,level:e.level??null});return i.sort((e,t)=>{const i=e.level??1e9,n=t.level??1e9;return i!==n?i-n:e.name.localeCompare(t.name)}),i}(this.hass);e.length?this._importDialog={floors:e.map(e=>({...e,checked:!0}))}:this._openSpaceDialog("create")}}_adoptConfigCapabilities(e){xg(this,e)}_syncRadarLive(){const e=this._serverCfg?.settings?.radar,t=(this._serverCfg?.markers||[]).some(e=>Cg(e,this._space));this._radarLive.sync(this._space,1===this._haRadarStage1Api&&"view"===this._mode&&!1!==e?.show_live&&t&&"hidden"!==this.ownerDocument.visibilityState)}async _syncDecorAssets(e){const t=++this._decorAssetSyncToken;if(1!==this._haDecorAssetsApi||!this.hass)return void(this._decorAssets=new Map);const i=await um(this.hass,cm(e),this._cfgRev);t===this._decorAssetSyncToken&&(this._decorAssets=i,this._resign(),this.requestUpdate())}_adoptAuthoritative(e){return ju(this,e)}_rollbackOptimistic(e){const t=this._adoption.rollbackOptimistic(e);return t&&this.requestUpdate(),t}_resumePendingNavMode(){if(!this._pendingNavMode||!this._canEdit||this._config?.kiosk)return!1;const e=this._pendingNavMode;return this._pendingNavMode=null,this._setMode(e,!1),!0}_getAuthoritativeConfig(){return e=this,async function(e,t){const i=await e();return t(i),i}(()=>e.hass.callWS({type:"houseplan/config/get"}),t=>xg(e,t));var e}async _loadFromServer(){this._loading=!0,this._loadTries++;const e=this._space,t=!!this._view;let i=!1;const n=()=>{i=!0,this._regSignature="",this._maybeRebuildDevices()};try{const[i,r]=await Promise.all([this._getAuthoritativeConfig(),this.hass.callWS({type:"houseplan/layout/get"})]);if("adopted"!==(await this._adoptAuthoritative({cfgResp:i,layResp:r,reason:"structural-response",profile:"reload",beforeAdopt:()=>{this._connectionWasLost=!1,this._serverStorage=!0},afterAdopt:()=>{this._warmVpArmed&&this._space===this._warmVp?.space?this._warmVpArmed=!1:t&&this._space===e||this._restoreZoom(),this._loadOk=!0,n()}})).status)return;this.hass.callWS({type:"houseplan/trail/get"}).then(e=>{this._vacSrvTrails=e?.trails||{},this.requestUpdate()}).catch(()=>{}),this._ensureLiveSyncSubscriptions()}catch(e){if(this._serverCfg)this._scheduleLoadRetry(!0);else if(this._loadTries>=8){this._serverStorage=!1;try{this._layout=JSON.parse(localStorage.getItem(lv)||"{}")||{}}catch{this._layout={}}}}finally{this._loading=!1,this._continuityDataReady=!0,i||n(),this.requestUpdate()}}_ensureLiveSyncSubscriptions(){const e=this.hass?.connection;if(!e)return;if(e!==this._liveSyncConnection&&(this._unsubCfg?.(),this._unsubCfg=null,this._unsubLayout?.(),this._unsubLayout=null,this._unsubTrail?.(),this._unsubTrail=void 0,this._unsubVirtual?.(),this._unsubVirtual=null,this._liveSyncGeneration++,this._liveSyncAttempt=null,this._liveSyncConnection=e),this._liveSyncAttempt)return;const t=this._liveSyncGeneration,i=[],n=(n,r,o,s)=>{n()||i.push(async()=>{const i=await e.subscribeEvents(s,o);t===this._liveSyncGeneration&&this.isConnected&&this.hass?.connection===e&&!n()?r(i):i?.()})};if(n(()=>this._unsubCfg,e=>{this._unsubCfg=e},"houseplan_config_updated",e=>{const t=Number(e?.data?.rev??-1);t!==this._cfgRev&&this._reloadConfigOnly(!1,t)}),n(()=>this._unsubTrail,e=>{this._unsubTrail=e},"houseplan_trail_updated",async()=>{try{const e=await this.hass.callWS({type:"houseplan/trail/get"});this._vacSrvTrails=e?.trails||{},this.requestUpdate()}catch{}}),n(()=>this._unsubLayout,e=>{this._unsubLayout=e},"houseplan_layout_updated",e=>this._onLayoutEvent(Number(e?.data?.rev??-1))),n(()=>this._unsubVirtual,e=>{this._unsubVirtual=e},"houseplan_virtual_light_updated",e=>{const t=Wh(this._virtualLights,e?.data);t!==this._virtualLights&&(this._virtualLights=t,this._capturedSnapshotVirtual="",this._cacheSnapshot(),this.requestUpdate())}),!i.length)return;const r=function(e){return Promise.allSettled(e.map(e=>Promise.resolve().then(e)))}(i).then(()=>{});this._liveSyncAttempt=r,r.finally(()=>{this._liveSyncAttempt===r&&(this._liveSyncAttempt=null)})}async _reloadConfigOnly(e=!1,t){return Ku(this,e,t)}_scheduleLoadRetry(e=!1){if(void 0!==this._loadRetryTimer)return;const t=Math.min(8e3,500*2**Math.min(4,Math.max(1,this._loadTries-7)));this._loadRetryTimer=window.setTimeout(()=>{this._loadRetryTimer=void 0,!e&&this._loadOk||this._loading||!this.hass||this._loadFromServer()},t)}async _ensureLiveRuntime(){if(this._liveRt)return;const e=await import("./live-interaction-runtime-C7FQnbBF.js");this._liveRt=new e.LiveRuntime(this),this.isConnected&&this.requestUpdate()}_liveVp(e=!1){this._liveRt?this._liveRt.viewport(e):this.requestUpdate()}_syncLiveHover(){this._liveRt?this._liveRt.hover():this.requestUpdate()}_flushHa(){this._liveRt?.take()&&(this._terminalFrame=2,super.requestUpdate())}_ensureHaRegistryAuthority(){const e=this.hass?.connection||null;e&&e!==this._haRegistryConnection&&(this._haRegistryRelease?.(),this._haRegistryConnection=e,this._haRegistryRev=-1,this._haBindingCacheKey="",this._renderLife.invalidate(),this._areaSnapshotCleanupCandidates.clear(),this._planHassMemo=null,this._haRegistryRelease=td(this.hass,this._onHaRegistryUpdate),this._onHaRegistryUpdate())}get _haRegistry(){return nd(this.hass)}get _planHass(){const e=this._haRegistry,t=od(this.hass,e),i=this._planHassMemo;if(i&&i.hass===this.hass&&i.sig===t)return i.active;const n=ad(this.hass,e),r=ld(this.hass,e);return this._planHassMemo={hass:this.hass,sig:t,active:n,full:r},n}_captureRenderDeviceSnapshot(){if(!this.hass)return;const e=Date.now(),t=[...this._activityRt.entries()].map(([t,i])=>`${t}:${i.gen}:${i.flashTs}:`+(i.flashKind&&(i.expiresAt||i.flashTs+tg)>e?1:0)).join("|"),i=Bh(this._virtualLights);if(this._capturedSnapshotSequence===this._hassSequence&&this._capturedSnapshotDevices===this._devices&&this._capturedSnapshotLayout===this._layout&&this._capturedSnapshotConfigEpoch===this._cfgEpoch&&this._capturedSnapshotVirtual===i&&this._capturedSnapshotActivity===t)return;const n=this._planHass,r=new Map,o=new Map,s=new Set(["sun.sun"]);for(const e of this._summary?.entityIds()||[])s.add(e);this._vacFit?.source&&s.add(this._vacFit.source);const a=new Set,l=new Set,c=e=>{if(!e)return;const t=e.indexOf(":");if(t<0)return void s.add(e);const i=e.slice(0,t),n=e.slice(t+1);"device"===i?a.add(n):"entity"===i&&s.add(n)};for(const e of this._model)for(const t of e.rooms)t.area&&l.add(t.area),c(t.settings?.temp_source),c(t.settings?.hum_source);for(const e of this._serverCfg?.spaces||[])for(const t of e.openings||[])for(const e of ui(t))s.add(e);for(const e of this._serverCfg?.spaces||[])for(const t of e.decor||[])if("text"===t.kind){for(const e of String(t.text||"").matchAll(/\{([^{}\r\n]+)\}/g)){const t=Xi(e[1]);t?.entity&&s.add(t.entity)}t.entity&&s.add(t.entity),o.set(`decor:${e.id}:${t.id}`,tn(t.text,t,n,e=>!!n.entities?.[e]&&!!n.states?.[e]&&!Jd(n,e,Zd(this._markers))))}const h=Ed(n,this._devices,null,this._virtualLights);for(const e of this._devices){for(const t of[!1,!0])r.set(f_(e.id,t),p_(n,e,{liveStates:!1!==this._config?.live_states,showTemperature:!1!==this._config?.show_temperature,showSignal:t,activityRuntime:this._activityRt.get(e.id),sourceDetails:!1,lightDevices:this._devices,lightSources:h,registryHass:this._fullRegistryHass,reducedMotion:this._reducedMotion}));if(this._isVacDev(e)){const t=this._vacSource(e,n),i=t?Wc(n?.states?.[t]?.attributes):null,r=this._vacRt.get(e.id),s=lh(e.id,e.marker?.vacuum??null,e.space,t),a=hh({routes:s,observed:dh(s,[t],t=>this._vacObservedMapId(e,t,n)),spaceIds:new Set(this._model.map(e=>e.id))});o.set(`vacuum:${e.id}`,{source:t,telemetry:i,routes:s,resolution:a,mapId:i?this._vacMapId(e,i,n):null,runtime:r?{trail:r.trail,lastTs:r.lastTs,moving:r.moving,jump:r.jump}:null,server:this._vacSrvTrails[e.id]||null})}}const d=g_({sourceSequence:this._hassSequence,hass:n,devices:this._devices,presentations:r,positions:(u=this._model.length>0,p=this._devices,_=e=>this._livePos(e),u?new Map(p.map(e=>[e.id,_(e)])):new Map),facts:o,entityIds:s,deviceIds:a,areaIds:l});var u,p,_;this._capturedSnapshotSequence=this._hassSequence,this._capturedSnapshotDevices=this._devices,this._capturedSnapshotLayout=this._layout,this._capturedSnapshotActivity=t,this._capturedSnapshotConfigEpoch=this._cfgEpoch,this._capturedSnapshotVirtual=i,this._visibleDeviceSnapshot&&"steady"!==this._continuity.state?this._candidateDeviceSnapshot=d:(this._visibleDeviceSnapshot=d,this._candidateDeviceSnapshot=null)}get _renderDeviceSnapshot(){return this._stagedDeviceSnapshotToken===this._continuity.token?this._candidateDeviceSnapshot||this._visibleDeviceSnapshot:this._visibleDeviceSnapshot||this._candidateDeviceSnapshot}get _renderPlanHass(){return this._renderDeviceSnapshot?.hass||this._planHass}get _renderDevices(){return this._renderDeviceSnapshot?.devices||this._devices}get _renderVacuumDevices(){return this._renderDeviceSnapshot?.vacuumDevices||this._devices}get _fullRegistryHass(){return this._planHass,this._planHassMemo?.full||this.hass}_bindingStatus(e){return dd(this.hass,e,this._haRegistry)}houseplanDiagnostics(){const{registry:e,bindings:t}=this._renderLife.diagnostics(this.hass,this._markers,e=>this._bindingStatus(e));return{registry:{...e,lastSuccessAgeMs:e.lastSuccess?Math.max(0,Date.now()-e.lastSuccess):null},bindings:t}}_openBindingInHa(e){const[t,i]=e.split(":");if(i)if("device"!==t){if("entity"===t){const e=this._fullRegistryHass.entities?.[i];e?.device_id&&fv("/config/devices/device/"+encodeURIComponent(e.device_id))}}else fv("/config/devices/device/"+encodeURIComponent(i))}_bindingHasHaPage(e){const[t,i]=e.split(":");return!!i&&("device"===t||"entity"===t&&!!this._fullRegistryHass.entities?.[i]?.device_id)}_toggleMarkerDialogVisibility(){const e=this._markerDialog;if(!e)return;const t="ha"===e.bindingMode?this._bindingStatus(e.binding):null,i=e.hideFromPlan||"ha_disabled"===t?.kind;i&&"ha_disabled"===t?.kind?this._showToast(this._t("entity"===t.reason?"toast.ha_disabled_show_entity":"toast.ha_disabled_show_device")):i&&"unverified"===t?.kind?this._showToast(this._t("toast.ha_binding_unverified")):this._markerDialog={...e,hideFromPlan:!i}}_hookConnection(){const e=this.hass?.connection;e&&e!==this._connHooked&&(this._connHooked?.removeEventListener?.("ready",this._onConnReady),this._connHooked?.removeEventListener?.("disconnected",this._onConnLost),this._connHooked?.removeEventListener?.("reconnect-error",this._onConnLost),e.addEventListener?.("ready",this._onConnReady),e.addEventListener?.("disconnected",this._onConnLost),e.addEventListener?.("reconnect-error",this._onConnLost),this._connHooked=e)}_display(e){return this._signer.display(this.hass,e)}_referencedContentUrls(){const e=Nn(this._serverCfg);for(const t of this._decorAssets.values())e.add(t.url);return e}_resign(){this._signer.resign(this.hass,this._referencedContentUrls())}_onLayoutEvent(e){e<=this._layoutRev||(clearTimeout(this._layoutSyncTimer),this._layoutSyncTimer=window.setTimeout(()=>{e<=this._layoutRev||this._reloadLayoutOnly()},200))}_noteLayoutRev(e){this._adoption.noteLayoutRevision(e?.rev)}async _reloadLayoutOnly(){if(!this._serverStorage||!this.hass?.callWS)return;this._beginContinuityCandidate("layout-reload",!1);const e=new Map;for(const t of this._dirtyPos)this._layout[t]&&e.set(t,this._layout[t]);this._persistLayout.pending()&&this._persistLayout.flush();for(const[t,i]of this._sentPos)e.set(t,i);try{const t=await this.hass.callWS({type:"houseplan/layout/get"}),i={...t?.layout||{}};for(const[t,n]of e)null===n?delete i[t]:i[t]=n;this._adoption.adoptMergedLayout(i,t,()=>{this._cancelDeviceDrag(),this._devicePositionHistory.clear()}),this._canOptimizeUndo=!!t?.can_optimize_undo,this._undoKind=t?.undo_kind||null,this._cacheSnapshot(),this.requestUpdate()}catch{}finally{this._continuityDataReady=!0,this.requestUpdate()}}_persistLocalLayout(){this._layout=So(lo(this._layout)),localStorage.setItem(lv,JSON.stringify(this._layout))}_maybeRebuildDevices(){const e=this.hass;if(!e?.devices||!e?.entities||!e?.areas)return;const t=this._haRegistry,i=od(e,t)+":"+Object.keys(e.areas).length+":"+(this._norm?"n":"l")+":"+kp(e,this._config?.language);if(i===this._regSignature&&this._devices.length)return;this._regSignature=i;const n=new Map(this._devices.map(e=>[e.id,e.bindingStatus?.kind||"active"]));this._devices=iu({hass:e,registry:t,areaToSpace:Object.fromEntries(Object.entries(this._areaToSpace).map(([e,t])=>[e,t.space])),markers:this._markers,settings:this._settings,excluded:this._excluded,showAll:this._showAll,firstSpaceId:this._model[0]?.id||"",loc:e=>this._t(e),iconRules:this._iconRules});const r=this._markers.filter(e=>!e.removed&&"virtual"!==e.binding).map(e=>e.binding).sort(),o=t.revision+":"+r.join("|");if(t.authoritative&&o!==this._haBindingCacheKey){const i=new Map;for(const n of r)i.set(n,dd(e,n,t));!function(e){if("undefined"==typeof localStorage||!e.size)return;const t=hd(),i=Date.now();for(const[n,r]of e)"active"===r.kind?t[n]={kind:"active",ts:i}:"ha_disabled"===r.kind&&(t[n]={kind:"ha_disabled",reason:r.reason,ts:i});const n=Object.fromEntries(Object.entries(t).sort((e,t)=>t[1].ts-e[1].ts).slice(0,1500));Yh=n;try{localStorage.setItem(Kh,JSON.stringify(n))}catch{}}(i),this._haBindingCacheKey=o}let s=null;if(t.authoritative&&(s=this._resolveAreaRelocations(t),this._areaRelocationIds=new Set(s.relocateIds),this._areaRelocationIds.size)){this._cancelDeviceDrag();const e=this._areaRelocationIds;this._devicePositionHistory.removeWhere(({before:t,after:i})=>e.has(t.deviceId)||e.has(i.deviceId));const t=this._markerDialog;if(t?.devId&&!t.roomTouched&&this._areaRelocationIds.has(t.devId)){const e=this._devices.find(e=>e.id===t.devId);e&&(this._markerDialog={...t,room:e.marker?.room_id?`${e.space}#@${e.marker.room_id}`:e.space&&e.area?`${e.space}#${e.area}`:""})}}this._defPos=this._defaultPositions(),this._syncNewDevices(),this._seedHiddenDevices(),s&&this._syncAreaRelocations(s),this._syncActivityRuntime();const a=new Set(this._devices.filter(e=>!e.hidden).map(e=>e.id));for(const e of this._vacRt.keys())a.has(e)||this._vacRt.delete(e);if(this._infoCard){const e=this._devices.find(e=>e.id===this._infoCard.id);this._infoCard=e&&"ha_disabled"!==e.bindingStatus?.kind?e:null}const l=this._devices.some(e=>"ha_disabled"===e.bindingStatus?.kind&&"ha_disabled"!==n.get(e.id));l&&("ha_disabled"!==this._infoCard?.bindingStatus?.kind&&"ha_disabled"!==this._devices.find(e=>e.id===this._infoCard?.id)?.bindingStatus?.kind||this._closeInfoCard(),this._deviceDrag&&"ha_disabled"===this._devices.find(e=>e.id===this._deviceDrag.id)?.bindingStatus?.kind&&(this._cancelDeviceDrag(),this._devicePositionHistory.clear()),clearTimeout(this._holdTimer),this._holdFired=!1,this._tip=null,this._tapConfirm=null),this._nativeMoreInfoEntity&&!this._planEntityAvailable(this._nativeMoreInfoEntity)&&(gv(this,"hass-more-info",{entityId:null}),this._nativeMoreInfoEntity=null)}_resolveAreaRelocations(e=this._haRegistry){const t=function(e){const t=Q_(e.snapshot),i=new Set(Object.values(t).map(e=>e.binding)),n=new Map;for(const[t,r]of e.previousCandidates||[])J_(t)&&Number.isFinite(r)&&i.has(t)&&n.set(t,r);const r=new Set,o=new Set;for(const t of e.markers||[])t.removed||(Z_(t.id)&&r.add(t.id),J_(t.binding)&&o.add(t.binding));const s=new Set(Object.keys(e.registryDevices||{})),a=new Set(Object.keys(e.registryEntities||{})),l=new Set(Object.keys(e.liveStates||{})),c=new Map;for(const[e,i]of Object.entries(t)){const t=c.get(i.binding)||[];t.push(e),c.set(i.binding,t)}const h=new Set;let d=!1;for(const[t,i]of c){const[c,u]=rm(t);if(o.has(t)||i.some(e=>r.has(e))||("device"===c?s.has(u):a.has(u)||l.has(u))){n.delete(t);continue}const p="device"===c?s.size>0:a.size>0;if(!e.authoritative||!p)continue;const _=n.get(t);if(void 0!==_){if(_!==e.revision)for(const e of i)h.add(e)}else n.set(t,e.revision),d=!0}return{removeIds:h,candidates:n,needsConfirmationRefresh:d}}({snapshot:this._settings.marker_area_snapshot,authoritative:e.authoritative,revision:e.revision,registryDevices:e.devices,registryEntities:e.entities,liveStates:this.hass?.states,markers:this._markers,previousCandidates:this._areaSnapshotCleanupCandidates});return this._areaSnapshotCleanupCandidates=t.candidates,t.needsConfirmationRefresh&&this._canEdit&&id(this.hass),om({devices:this._devices,model:this._model,layout:this._layout,snapshot:this._settings.marker_area_snapshot,authoritative:e.authoritative,cleanupSnapshotIds:t.removeIds,coordinateScale:_v})}_syncNewDevices(){if(!this._norm||!this._loadOk||!this._serverCfg)return;const e=this._devices.filter(e=>!e.marker&&!e.virtual).map(e=>e.id).sort(),t=e.join(",");if(t===this._newSyncKey)return;this._newSyncKey=t;const i=this._settings,{fresh:n,known:r}=function(e,t){if(!Array.isArray(t))return{fresh:[],known:[...e]};const i=new Set(t),n=e.filter(e=>!i.has(e));return{fresh:n,known:n.length?[...t,...n]:t}}(e,i.known_devices);if(!Array.isArray(i.known_devices)||n.length){const e=[...new Set([...i.new_device_ids||[],...n])];this._serverCfg={...this._serverCfg,settings:{...i,known_devices:r,new_device_ids:e}},this._saveConfig()}}_syncAreaRelocations(e){if(!(this._loadOk&&this._serverCfg&&this._norm&&this._canEdit&&this._haRegistry.authoritative))return;const t=e.decisions.filter(e=>e.updateSnapshot||e.removeSnapshot);if(!t.length)return;const i=cc({snapshot:Q_(this._settings.marker_area_snapshot),decisions:t});i!==this._areaRelocationSyncKey&&(this._areaRelocationSyncKey=i,this._areaRelocationWrite=this._areaRelocationWrite.catch(()=>{}).then(async()=>{if(!this._serverCfg||!this._haRegistry.authoritative)return;const e=this._resolveAreaRelocations();this._areaRelocationIds=new Set(e.relocateIds);const t=new Set,i=new Map;let n=!1;for(const r of e.decisions){if(!r.relocate)continue;const e=fg(this._layout,r.id);try{await this._persistDevicePlacement(r.id,null),t.add(r.id),e&&i.set(r.id,e),this._areaRelocationIds.delete(r.id)}catch(t){n=!0,this._layout=vg(this._layout,r.id,e),this._showToast(this._t("toast.pos_save_failed",{err:this._errText(t)}))}}const r=this._settings,o=function(e,t,i=new Set){const n=Q_(e);for(const e of t.decisions)e.removeSnapshot?delete n[e.id]:e.updateSnapshot&&e.binding&&e.area&&(e.relocate&&!i.has(e.id)||(n[e.id]={binding:e.binding,area:e.area}));return n}(r.marker_area_snapshot,e,t),s=[...new Set([...Array.isArray(r.new_device_ids)?r.new_device_ids:[],...t])],a=cc(o)!==cc(Q_(r.marker_area_snapshot)),l=cc(s)!==cc(Array.isArray(r.new_device_ids)?r.new_device_ids:[]);if(a||l){const e=r.marker_area_snapshot,n=r.new_device_ids,a={...this._serverCfg,settings:{...r,marker_area_snapshot:o,...l?{new_device_ids:s}:{}}};this._setAreaLifecycleConfig(a);try{this._saveConfigDebounced.pending()&&this._saveConfigDebounced.cancel(),await this._writeConfig()}catch(r){const a=this._settings;if(cc(a.marker_area_snapshot)===cc(o)&&cc(a.new_device_ids)===cc(l?s:n)){const t={...a};void 0===e?delete t.marker_area_snapshot:t.marker_area_snapshot=e,void 0===n?delete t.new_device_ids:t.new_device_ids=n;const i={...this._serverCfg,settings:t};this._setAreaLifecycleConfig(i),this._adoption.refreshConfigFingerprint()}for(const e of t)this._areaRelocationIds.add(e);const c=new Set;for(const[e,t]of i)try{await this._persistDevicePlacement(e,t)}catch(t){c.add(e),this._showToast(this._t("toast.pos_save_failed",{err:this._errText(t)}))}this._areaRelocationSyncKey="",this._regSignature="";if("conflict"===(r&&"object"==typeof r&&"code"in r?r.code:void 0)?(this._showToast(this._t("toast.conflict")),await this._reloadConfigOnly(!0)):this._showToast(this._t("toast.cfg_save_failed",{err:this._errText(r)})),c.size&&this._serverCfg){const e=this._settings,t=[...new Set([...Array.isArray(e.new_device_ids)?e.new_device_ids:[],...c])],i={...this._serverCfg,settings:{...e,new_device_ids:t}};this._setAreaLifecycleConfig(i);try{await this._writeConfig()}catch(e){this._showToast(this._t("toast.cfg_save_failed",{err:this._errText(e)}))}}}}n&&(this._areaRelocationSyncKey=""),this.requestUpdate()}))}get _newIds(){const e=this._settings.new_device_ids;return new Set([...Array.isArray(e)?e:[],...this._areaRelocationIds])}_ackNewDevice(e){if(!this._newIds.has(e)||!this._serverCfg)return;const t=this._settings;this._serverCfg={...this._serverCfg,settings:{...t,new_device_ids:(t.new_device_ids||[]).filter(t=>t!==e)}},this._saveConfig(),this.requestUpdate()}get _markers(){return this._serverCfg?.markers||[]}_roomLqi(e){if(!e)return null;const t=[];for(const i of this._renderDevices){if(i.area!==e||i.virtual)continue;const n=Ld(this._renderPlanHass,i.entities);null!=n&&t.push(n)}return Ii(t)}_roomBounds(e){if(e.poly&&e.poly.length){const t=e.poly.map(e=>e[0]),i=e.poly.map(e=>e[1]),n=Math.min(...t),r=Math.min(...i);return{x:n,y:r,w:Math.max(...t)-n,h:Math.max(...i)-r}}return{x:e.x??0,y:e.y??0,w:e.w??0,h:e.h??0}}_defaultPositions(){const e={},t=this._config?.icon_size??2.5;for(const i of this._model){const n=t/100*Ml(i)*1.3;for(const t of i.rooms){if(!t.area)continue;const r=this._devices.filter(e=>e.area===t.area&&e.space===i.id);if(!r.length)continue;const o=this._roomBounds(t),s=.1*Math.min(o.w,o.h),a=o.w-2*s,l=o.h-2*s,c=Math.max(1,Math.round(Math.sqrt(r.length*a/Math.max(l,1)))),h=Math.ceil(r.length/c),d=a/c,u=l/Math.max(h,1),p=r.map((e,t)=>({x:o.x+s+d*(t%c+.5),y:o.y+s+u*(Math.floor(t/c)+.5)}));Ei(p,o,n,.5*s),r.forEach((t,i)=>e[t.id]=al(p[i]))}}return e}_pos(e){const t=this._renderDeviceSnapshot?.positions.get(e.id);return t?{x:t.x,y:t.y}:this._livePos(e)}_livePos(e){const t=this._spaceModelById(e.space),i=this._areaRelocationIds.has(e.id)?void 0:this._layout[e.id];if(i)if(this._norm){if(i.s===e.space)return{x:i.x*_v,y:i.y*_v}}else if(void 0===i.s)return{x:i.x,y:i.y};return this._defPos[e.id]?this._defPos[e.id]:t?al($l(t)):{x:500,y:500}}_devicePlacementForCanvas(e,t,i){if(!this._norm)return{x:Math.round(t),y:Math.round(i)};const n=this._gridPitch,r=Math.round(t/n)*n,o=Math.round(i/n)*n;return{s:e.space,x:cl(r/_v),y:cl(o/_v)}}_previewDevicePlacement(e,t){this._layout=vg(this._layout,e,t),this.requestUpdate()}_cancelDeviceDrag(){const e=this._deviceDrag;if(!e)return!1;this._editorRuntime?._cancelPointerMove("device"),this._deviceDrag=null,this._deviceHits.cancel(e.pointerId);try{e.source?.hasPointerCapture?.(e.pointerId)&&e.source.releasePointerCapture(e.pointerId)}catch{}return this._previewDevicePlacement(e.id,e.before),!0}async _persistDevicePlacement(e,t){if(this._layout=vg(this._layout,e,t),this._serverStorage){let i=null,n=!1;try{let r;if(null===t)i=null,this._sentPos.set(e,i),n=!0,r=await this.hass.callWS({type:"houseplan/layout/delete",device_id:e});else{const t=xo(this._layout[e]);cc(t)!==cc(this._layout[e])&&(this._layout={...this._layout,[e]:t}),i=t,this._sentPos.set(e,i),n=!0,r=await this.hass.callWS({type:"houseplan/layout/update",device_id:e,pos:t})}this._noteLayoutRev(r),this._adoption.refreshLayoutFingerprint(),this._cacheSnapshot()}finally{n&&this._sentPos.get(e)===i&&this._sentPos.delete(e)}return}this._persistLocalLayout()}_devicePositionStateValid(e){const t=this._devices.find(t=>t.id===e.deviceId);return!!t&&t.space===e.spaceId&&"ha_disabled"!==t.bindingStatus?.kind&&!!this._spaceModelById(e.spaceId)}async _runDevicePositionHistory(e){if(this._cancelDeviceDrag()||this._devicePositionBusy)return;const t="undo"===e?this._devicePositionHistory.undo():this._devicePositionHistory.redo();if(!t)return;const i="undo"===e?t.before:t.after;if(!this._devicePositionStateValid(i))return this._devicePositionHistory.clear(),this._showToast(this._t("history.device_stale")),void this.requestUpdate();const n=fg(this._layout,i.deviceId);i.spaceId!==this._space&&(this._commitSpace(i.spaceId),this._restoreZoom()),this._devicePositionBusy=!0,this._previewDevicePlacement(i.deviceId,i.placement);try{await this._persistDevicePlacement(i.deviceId,i.placement),this._showToast(this._t("undo"===e?"history.undone":"history.redone",{name:t.name}))}catch(t){this._previewDevicePlacement(i.deviceId,n),"undo"===e?this._devicePositionHistory.redo():this._devicePositionHistory.undo(),this._showToast(this._t("toast.pos_save_failed",{err:this._errText(t)}))}finally{this._devicePositionBusy=!1,this.requestUpdate()}}_undoDevicePosition(){this._runDevicePositionHistory("undo")}_redoDevicePosition(){this._runDevicePositionHistory("redo")}_savePos(e,t,i){this._spaceModelById(e.space)&&(this._layout=vg(this._layout,e.id,this._devicePlacementForCanvas(e,t,i)),this._dirtyPos.add(e.id),this._persistLayout())}_devicePresentation(e,t=!1!==this._config?.show_signal,i=!1){const n=i?null:this._renderDeviceSnapshot?.presentations.get(f_(e.id,t));return n||p_(this._renderPlanHass,e,{liveStates:!1!==this._config?.live_states,showTemperature:!1!==this._config?.show_temperature,showSignal:t,designPreview:i,activityRuntime:this._activityRt.get(e.id),sourceDetails:!1,lightDevices:this._renderDevices,registryHass:this._fullRegistryHass,reducedMotion:this._reducedMotion})}_deviceVisual(e){return this._devicePresentation(e).visual}_stateClass(e,t=this._deviceVisual(e)){const i=this._devicePresentation(e);return i.effectiveHidden?"":("icon_ripple"!==i.display||!1===this._config?.live_states||"alarm"===t.status||t.activity,u_({...i,visual:t}).join(" "))}_liveTemp(e){if(!this._config?.show_temperature)return null;if(!0===e.marker?.use_climate_temp){const t=qd(this._renderPlanHass,e.entities);if(null!=t)return t}return"mdi:thermometer"!==e.icon&&"mdi:air-filter"!==e.icon?null:Bd(this._renderPlanHass,e.entities)}_bindingEntities(e){if("virtual"===e||!e)return[];const t=this._bindingStatus(e);return"active"===t.kind?t.enabledEntityIds:t.allEntityIds}_bindingHasClimate(e){return this._bindingEntities(e).some(e=>e.startsWith("climate."))}_bindingHasAlarm(e){return this._bindingEntities(e).some(e=>{const t=this._planHass?.states?.[e]||this.hass?.states?.[e],i=this._fullRegistryHass.entities[e]||this.hass?.entities?.[e];return Yn(e.split(".")[0],t?.attributes?.device_class||i?.device_class||i?.original_device_class)})}_deviceBindingActive(e,t=!0){if(e.virtual||"virtual"===e.bindingKind)return!0;if(!e.bindingKind||!e.bindingRef)return!1;const i=this._bindingStatus(`${e.bindingKind}:${e.bindingRef}`);return"active"===i.kind||(t&&this._showToast(this._t("ha_disabled"===i.kind?"toast.ha_disabled_action":"toast.ha_binding_unverified")),!1)}_openMoreInfo(e){e?this._planEntityAvailable(e)?(this._kiosk&&(this._cyclePausedUntil=Math.max(this._cyclePausedUntil,Date.now()+6e4)),this._nativeMoreInfoEntity=e,gv(this,"hass-more-info",{entityId:e})):this._showToast(this._t("toast.ha_disabled_action")):this._showToast(this._t("toast.no_entity"))}_interruptViewGesture(e,t){if(clearTimeout(this._holdTimer),clearTimeout(this._kioskHoldTimer),void 0!==e)for(const i of[t,this._stageEl])try{i?.hasPointerCapture?.(e)&&i.releasePointerCapture(e)}catch{}this._pointers.clear(),this._panStart=null,this._panLock=null,this._pinchStart=null,this._swipeStart=null,this._roomPointer=null,this._doubleFit.clear(),this._deviceHits.clearPointers()}_closeInfoCard(){this._interruptViewGesture(),this._holdFired=!1,this._infoCard=null}_invalidateDeviceHitGeometry(){this._deviceHits.invalidate()}_resetDeviceHitState(){this._deviceHits.reset(this.renderRoot)}_deviceHitOwnerAt(e,t){return"view"!==this._mode&&"devices"!==this._mode?null:this._deviceHits.at(this.renderRoot,this._renderDevices,this._space,e,t)}_deviceForPointerEvent(e,t){return this._deviceHits.pointer(this.renderRoot,this._renderDevices,this._space,e,t)}_deviceForClickEvent(e,t){return this._deviceHits.click(this.renderRoot,this._renderDevices,this._space,e,t)}_showDeviceTip(e,t){this._liveRt?this._liveRt.devicePointerTip(e,t):this._ensureLiveRuntime().then(()=>this._liveRt?.devicePointerTip(e,t))}_showDeviceFocusTip(e,t){const i=e.currentTarget;this._liveRt?this._liveRt.deviceFocusTip(i,t):this._ensureLiveRuntime().then(()=>this._liveRt?.deviceFocusTip(i,t))}_hideDeviceFocusTip(e){this._liveRt?.deviceBlur(e)}_clearPointerHover(){this._liveRt?this._liveRt.pointerLeave():this._clearTransientHover()}_ctxDevice(e,t){"view"===this._mode&&(t=this._deviceForPointerEvent(e,t),e.preventDefault(),e.stopPropagation(),this._deviceBindingActive(t)&&(t.primary?this._openMoreInfo(t.primary):this._infoCard=t))}_clickDevice(e,t){if("view"!==this._mode&&"devices"!==this._mode)return;if(e.stopPropagation(),t=this._deviceForClickEvent(e,t),this._deviceDrag?.moved||this._suppressClick||this._holdFired)return;if("devices"===this._mode)return void this._openMarkerDialog(t);const i=this._devices.find(e=>e.id===t.id);if(!i)return;const n=Tu(i.tapAction,i.primary?.split(".")[0]);if("none"===n)return;const r=(e,t)=>{i.marker?.tap_confirm?this._tapConfirm={kind:"run",text:e,exec:t}:t()};if("toggle"===n){const e=this._toggleIntent(i);if(!e)return;if(!Iu(e))return void this._showUnavailableToggleTargets(e);const t=e=>{const t=Iu(e);if(!t)return;if("virtual-light"===t.kind)return this._startDevicePressFeedback(i.id),void this.hass.callWS({type:"houseplan/virtual_light/toggle",marker_id:t.markerId}).then(e=>{const t=Wh(this._virtualLights,e);t!==this._virtualLights&&(this._virtualLights=t,this._capturedSnapshotVirtual="",this._cacheSnapshot(),this.requestUpdate())}).catch(e=>this._showToast(this._t("toast.virtual_light_toggle_failed",{err:this._errText(e)})));const{command:n}=t;this._startDevicePressFeedback(i.id),this.hass.callService(n.domain,n.service,n.data).catch(e=>this._showToast(this._t("toast.error",{err:this._errText(e)})))},n=((o=e).targets.length?o.targets:o.skippedTargets).map(e=>e.name||e.entityId||e.ref).join(", ")||i.name;if(i.marker?.tap_confirm){const r=this._toggleConfirmationLines(e);if(!r.length)return;this._tapConfirm={kind:"toggle",text:this._t("confirm.tap_toggle",{name:n}),lines:r,initialIntent:e,deviceId:i.id,exec:()=>{const n=this._devices.find(e=>e.id===i.id),r=n?this._toggleIntent(n):null;r&&!Iu(r)&&this._showUnavailableToggleTargets(r)||(r&&Eu(e,r)?t(r):this._showToast(this._t("toast.tap_target_changed")))}}}else t(e);return}var o;if("info"===n)return this._interruptViewGesture(),void(this._infoCard=i);if(this._deviceBindingActive(i)){if("run"===n){const e=i.marker?.tap_target||"",t=function(e){const t=String(e||"").split(".")[0];return"automation"===t?{domain:"automation",service:"trigger"}:"script"===t?{domain:"script",service:"turn_on"}:"scene"===t?{domain:"scene",service:"turn_on"}:null}(e),n=this.hass.states[e];if(!t||!n)return void this._showToast(this._t("toast.run_target_missing"));const o=n.attributes?.friendly_name||e;return void r(this._t("confirm.tap_run",{name:o}),()=>{this._deviceBindingActive(i)&&this._planEntityAvailable(e)&&(this._startDevicePressFeedback(i.id),this.hass.callService(t.domain,t.service,{entity_id:e}).then(()=>{this._stampActivity(i.id,"event",this._activitySourceKey(i)),this.requestUpdate(),this._showToast(this._t("toast.run_started",{name:o}))}).catch(e=>this._showToast(this._t("toast.error",{err:this._errText(e)}))))})}"more-info"===n&&i.primary?this._openMoreInfo(i.primary):this._infoCard=i}}_showUnavailableToggleTargets(e){const t=function(e){if(!e||"group"!==e.kind||Iu(e)||"configured-targets-missing"!==e.noneReason)return[];if(!e.skippedTargets.length||e.skippedTargets.some(e=>!Ou.has(e.reason)&&"secure"!==e.reason))return[];const t=[],i=new Set;for(const n of e.skippedTargets){if(!Ou.has(n.reason))continue;const e=String(n.name||n.entityId||n.ref||"").trim();e&&!i.has(e)&&(i.add(e),t.push(e))}return t}(e);return!!t.length&&(this._showToast(1===t.length?this._t("toast.toggle_target_unavailable",{name:t[0]}):this._t("toast.toggle_targets_unavailable",{names:t.join(", ")})),!0)}_keyDevice(e,t){"Enter"!==e.key&&" "!==e.key||"view"!==this._mode&&"devices"!==this._mode||(e.preventDefault(),this._clickDevice(e,t))}_startDevicePressFeedback(e){const t=[...this.renderRoot.querySelectorAll(".dev[data-id]")].find(t=>t.dataset.id===e),i=t?.querySelector(".device-shell");if(!i||"function"!=typeof i.animate)return;const n=Number.parseFloat(this.ownerDocument.defaultView?.getComputedStyle(i).scale||""),r=Number.isFinite(n)?Math.max(.95,Math.min(1,n)):1;this._devicePressAnimations.get(e)?.cancel();const o=this._reducedMotion?[{outlineColor:"transparent",outlineStyle:"solid",outlineWidth:"0px"},{outlineColor:"var(--hp-accent, #3ea6ff)",outlineStyle:"solid",outlineWidth:"2px",outlineOffset:"2px",offset:.5},{outlineColor:"transparent",outlineStyle:"solid",outlineWidth:"0px"}]:[{scale:String(r)},{scale:"0.95",offset:.5},{scale:"1"}],s=i.animate(o,{duration:200,easing:"cubic-bezier(.22,.61,.36,1)"});this._devicePressAnimations.set(e,s);const a=()=>{this._devicePressAnimations.get(e)===s&&this._devicePressAnimations.delete(e)};s.addEventListener("finish",a,{once:!0}),s.addEventListener("cancel",a,{once:!0})}_cancelDevicePressFeedback(){for(const e of this._devicePressAnimations.values())e.cancel();this._devicePressAnimations.clear()}_pruneDevicePressFeedback(){if(!this._devicePressAnimations.size)return;const e=new Set([...this.renderRoot.querySelectorAll(".dev[data-id]")].map(e=>e.dataset.id||""));for(const[t,i]of this._devicePressAnimations)e.has(t)||(i.cancel(),this._devicePressAnimations.delete(t))}_t(e,t){return xp(kp(this.hass,this._config?.language),e,t)}get _colorPickerLabels(){return{title:this._t("color_picker.title"),hue:this._t("color_picker.hue"),saturation:this._t("color_picker.saturation"),value:this._t("color_picker.value"),hex:this._t("color_picker.hex"),invalidHex:this._t("color_picker.invalid_hex"),confirm:this._t("color_picker.confirm")}}_help(e){return this._editorRuntimeOrThrow()._help(e)}get _stageEl(){return this.renderRoot.querySelector(".stage")}_contentItems(e){const t=[];for(const i of this._devices){if(i.space!==e.id||i.hidden)continue;const n=this._pos(i);t.push({minX:n.x,minY:n.y,maxX:n.x,maxY:n.y})}if(e.id===this._space){for(const e of this._openingsR){const i=Number(e.angle)*Math.PI/180,n=Math.cos(i)*e.rlen/2,r=Math.sin(i)*e.rlen/2,o=pl([[e.rx-n,e.ry-r],[e.rx+n,e.ry+r]]);o&&t.push(o)}const i=this._decorH;for(const e of this._decorList){if("image"===e.kind&&!this._decorAssets.has(e.asset_id)&&"decor"!==this._mode)continue;const n=pl("line"===e.kind?[[e.x1*_v,e.y1*i],[e.x2*_v,e.y2*i]]:"text"===e.kind?[[e.x*_v,e.y*i]]:Nr({x:e.x*_v,y:e.y*i,w:e.w*_v,h:e.h*i,angle:e.angle}));n&&t.push(n)}for(const i of this._physicalBodiesR(e)){const e=pl(i);e&&t.push(e)}}return vl(e,t)}_frameOf(){const e=this._spaceModel();if(!e){this._frame=null;const e={x:0,y:0,w:_v,h:_v};return{rect:e,all:e,outliers:0}}const t=this._frame,i="view"!==this._mode;if(t&&t.id===e.id&&this._bdDrag)return t;if(t&&t.id===e.id&&t.model===e&&t.layout===this._layout&&t.devs===this._devices&&t.far===this._showFar&&t.grow===i)return t;const n=kl(this._contentItems(e));let r=n.all||Sl(e),o=this._showFar?r:n.core||Sl(e);return t&&t.id===e.id&&i&&t.grow&&(o=mv(t.rect,o),r=mv(t.all,r)),this._frame={id:e.id,model:e,layout:this._layout,devs:this._devices,far:this._showFar,grow:i,rect:o,all:r,outliers:n.outliers},this._frame}_isoSource(){const e=this._isoSceneRuntime;if(!e)return null;const t=this._spaceModel();if(!t)return null;const i=this._spaceWalls,n=this._openCuts(),r=this._openingsR;return e.createIsoStructuralSource({space:t,walls:i,openCuts:n,openings:r,partitionCuts:()=>this._partitionOpeningCuts(t),roomOpenings:()=>this._roomWallOpeningInputs(r,t),cellCm:this._cellCm,gridPitch:this._gridPitch,wallKeyPitch:this._wallKeyPitch,coordinateScale:_v,onBuild:()=>{this._isoStructuralBuildCount+=1}})}_isoSceneKey(){if(!this._labsIso||"view"!==this._mode)return null;try{return this._isoSource()?.key??null}catch{return this._isoInvalidKey()}}_isoInvalidKey(){return`${this._space}|invalid|${this._cfgEpoch}`}_clearIsoInvalidFallback(e){const t=`${this._space}|invalid|`;for(const i of this._isoFallback)i.startsWith(t)&&i!==e&&this._isoFallback.delete(i)}_isoScene(e=this._isoSource()){const t=this._isoSceneRuntime;if(!t||!e)return null;let i=this._frameOf().rect;const n=this._spaceDisplayForRender(),r=this._spaceModel();if(r&&n.showNames)for(const e of r.rooms)if(e.name){const t=this._labelPos(e,r.id);i=mv(i,{x:t.x,y:t.y,w:0,h:0})}const o=t.resolveIsoScene({source:e,cache:this._isoGeometryCache,cellCm:this._cellCm,liveFrame:i});if(!r||!n.showBorders)return o;const s=this._config?.icon_size??2.5,a=s>8?2.5:s,l=this._stageEl?.getBoundingClientRect?.()??null,c=l?.height?l.width/l.height:o.frame.w/o.frame.h,h=Oi([o.frame.x,o.frame.y,o.frame.w,o.frame.h],c),d=this._isoOverlayScene(r,this._renderDevices.filter(e=>e.space===r.id&&!e.hidden),h,n,t.resolveIsoDecorationLayers(n),o,a,x_(a),n.showLqi??this._config?.show_signal??!0,!1),u=d&&t.resolveIsoOverlayFitEnvelope({baseBounds:o.frame,entries:d.entries,stageSize:l,targetView:e=>Oi([e.x,e.y,e.w,e.h],c)});return u?{...o,frame:u.bounds,overlayFitEntries:d.entries}:o}_latchIsoFallback(e,t){if(this._isoFallback.has(e))return;this._isoFallback.add(e);const i=e.includes("|invalid|")?"invalid":e.split("|").pop()||"invalid";console.warn("HOUSEPLAN ISO FALLBACK: #89/#160",wf("structural",i,!0))}_effectiveProjection(){if(this._isoProjectionSnapshot)return this._isoProjectionSnapshot;const e=e=>this._isoProjectionSnapshot=e,t=()=>("iso"===this._renderProjection&&(this._cancelCameraTransition(!1),this._view=null,this._viewModeSnap=null),e("flat"));if(this._renderIsoScene=null,"iso"!==this._desiredProjection||!this._model.length||!this._isoSceneRuntime)return e("flat");if(!this._spaceDisplayForRender().showBorders)return this._isoFallback.has(`${this._space}|no-borders`)?t():e("iso");let i=this._isoInvalidKey();if(this._clearIsoInvalidFallback(i),this._isoFallback.has(i))return t();try{const n=this._isoSource();if(!n)return e("flat");if(i=n.key,this._isoFallback.has(i))return t();const r=this._isoScene(n);return r?this._isoFallback.has(r.key)?t():(this._renderIsoScene=r,e("iso")):e("flat")}catch(e){return this._latchIsoFallback(i,e),t()}}_scenePoint(e){return"iso"===this._renderProjection?lf(e,0):e}_floorView(e){if("iso"!==this._renderProjection)return e;const t=cf([e.x,e.y]),i=cf([e.x+e.w,e.y+e.h]);return{x:t[0],y:t[1],w:i[0]-t[0],h:i[1]-t[1]}}_isoOverlayScene(e,t,i,n,r,o,s,a,l,c=!0){const h=this._isoSceneRuntime;return h&&r?.structural&&o?h.buildIsoOverlayRenderScene({space:e,devices:t,openings:this._openingsR,view:i,display:n,wallSilhouettes:o.wallSilhouettes,resolveCollisions:c,iconPct:s,deviceBasePct:a,showLqi:l,cellCm:this._cellCm,kioskIconScale:"view"===this._mode?this._kioskScale.icon:1,kioskFontScale:"view"===this._mode?this._kioskScale.font:1,stageSize:this._stageEl?.getBoundingClientRect?.(),positionOf:e=>this._pos(e),presentationOf:(e,t)=>this._devicePresentation(e,t),labelPositionOf:(e,t)=>this._labelPos(e,t),labelScaleOf:e=>this._labelScale(e),openingEntityAvailable:e=>this._renderOpeningEntityAvailable(e),openingWallIndex:()=>this._openingWallIndexFor(e,this._openCuts()).value}):null}_baseVb(e=this._effectiveProjection(),t=this._renderIsoScene){if("iso"===e){if(!this._spaceDisplayForRender().showBorders){const e=uf({rect:this._frameOf().rect,wallHeight:0});return[e.x,e.y,e.w,e.h]}const e=t?.frame??this._frameOf().rect;return[e.x,e.y,e.w,e.h]}const i=this._frameOf().rect;return[i.x,i.y,i.w,i.h]}get _outliers(){return this._showFar?0:this._frameOf().outliers}_fitFar(){this._clearRoomFocus(),this._showFar=!0,this._frame=null,this.requestUpdate(),this._resetZoom()}_clearRoomFocus(e=!1){this._doubleFit.clear(),this._roomFocus=null,e&&(this._roomPointer=null)}_roomFitBounds(e,t){const i=ni(e);if(!i||!e.id)return null;const n=this._spaceWalls,r=this._openCuts(),o=this._wallUnionGeometry(),s=n.length&&this._innerRoomContour(t,e.id,r,o?.roomGeom,o?.multiWallNodes)||i,a=this._spaceDisplayForRender();let l=[];if(a.showBorders&&n.length){const i=Fs(t.rooms,e.id,n,r,this._wallKeyPitch,this._cellCm,this._gridPitch,_v);i&&(l=aa(i.poly,i.offsets,o?.multiWallNodes)||i.poly)}const c=this._effectiveProjection();return function(e){const t=e.floor,i=e.wall||[],n=e.padding??0;if(!t.length||!t.every(vf)||!i.every(vf)||!Number.isFinite(n)||n<0)return null;if("flat"===e.projection)return bf([...t,...i],n);const r=e.wallHeight??0,o=e.floorDepth??0;if(!Number.isFinite(r)||r<0||!Number.isFinite(o)||o<0)return null;try{const e=[];for(const i of t){const t=[i[0],i[1]];e.push(lf(t,0)),o>0&&e.push(lf(t,-o))}for(const t of i){const i=[t[0],t[1]];e.push(lf(i,0)),r>0&&e.push(lf(i,r))}return bf(e,n)}catch{return null}}({floor:s,wall:l,projection:c,wallHeight:"iso"===c&&a.showBorders?Wa(84,this._cellCm):0,floorDepth:"iso"===c&&a.showBorders?Wa(10,this._cellCm):0,padding:a.showBorders?Wa(1.25,this._cellCm):0})}_fitRoom(e,t=!0){if("view"!==this._mode)return!1;this._doubleFit.clear();const i=this._spaceModel(),n=i?.rooms.find(t=>t.id===e);if(!i||!n)return this._clearRoomFocus(),!1;let r=this._roomFitBounds(n,i);if(!r)return this._clearRoomFocus(),!1;this._roomFocus={spaceId:i.id,roomId:e};const o=this._stageEl;if(!o||o.clientWidth<=0||o.clientHeight<=0)return!0;const s=Oi(this._baseVb(),o.clientWidth/o.clientHeight),a=e=>function(e){const t=e.safeFraction??.8,{bounds:i,baseFit:n,stageWidth:r,stageHeight:o,minZoom:s,maxZoom:a}=e;if(!yf(i)||!yf(n)||!Number.isFinite(r)||r<=0||!Number.isFinite(o)||o<=0||!Number.isFinite(s)||s<=0||!Number.isFinite(a)||a1)return null;const l=r/o,c=Math.max(i.w/t,i.h/t*l);if(!Number.isFinite(c)||c<=0)return null;const h=Math.min(a,Math.max(s,n.w/c)),d=n.w/h,u=d/l;return{zoom:h,viewBox:{x:i.x+i.w/2-d/2,y:i.y+i.h/2-u/2,w:d,h:u}}}({bounds:e,baseFit:s,stageWidth:o.clientWidth,stageHeight:o.clientHeight,minZoom:wv.ZOOM_MIN,maxZoom:wv.ZOOM_MAX});let l=a(r);const c=this._isoSceneRuntime,h=this._renderIsoScene?.overlayFitEntries;if(l&&"iso"===this._effectiveProjection()&&c&&h?.length){const e=c.resolveIsoOverlayFitEnvelope({baseBounds:r,entries:h,ownerId:n.id,stageSize:{width:o.clientWidth,height:o.clientHeight},targetView:e=>a(e)?.viewBox??null});e&&(r=e.bounds,l=a(r))}if(!l)return this._clearRoomFocus(),!1;const d=this._cameraState(),u=function(e,t,i,n){const r=[e,t,i,n],o=Math.min(...r.map(e=>e.x)),s=Math.min(...r.map(e=>e.y));return{x:o,y:s,w:Math.max(...r.map(e=>e.x+e.w))-o,h:Math.max(...r.map(e=>e.y+e.h))-s}}(s,d.viewBox,l.viewBox,r);return l.viewBox=this._clampView(l.viewBox,u),t?(this._prepareCameraCommand(),this._startCameraTransition(l,u,"room",220),!0):(this._cancelCameraTransition(!1),Xg(d,l)||(this._zoom=l.zoom,this._view={...l.viewBox},this.requestUpdate()),!0)}_fitAll(e="fit"){this._clearRoomFocus(),this._showFar=!0,this._frame=null,this.requestUpdate(),this._resetZoom(e)}_renderFarHint(){return this._kiosk||"view"!==this._mode||this._booting||!this._outliers?G:j`
    +
    `:G}houseplanContinuityTrace(){return[...this._continuityHistory,...this._continuity.trace].slice(-80).map(e=>({...e,...e.stage?{stage:[...e.stage]}:{}}))}getCardSize(){return 12}getGridOptions(){return{columns:"full"}}get _norm(){return!(!this._serverCfg||!this._serverCfg.spaces.length)}_cfgFingerprint(){const e=this._serverCfg?.spaces||[];let t=e.length+":";for(const i of e){t+=(i.id||"")+","+(i.plan_aspect||"")+","+(i.plan_url||"").length+","+(i.plan_x??"")+","+(i.plan_y??"")+","+(i.plan_scale??"")+","+(i.plan_scale_x??"")+","+(i.plan_scale_y??"")+","+(i.plan_angle??"")+","+(i.rooms?.length||0)+","+(i.openings?.length||0)+","+(i.decor?.length||0)+";";for(const e of i.rooms||[]){const i=e.poly?.[0],n=e.poly?.[e.poly.length-1];t+=(e.poly?.length||0)+"."+(e.id||"")+"."+(e.open_to||[]).join("+")+"."+(e.area||"")+"."+JSON.stringify(e.settings||0)+"."+(e.x??"")+","+(e.y??"")+","+(e.w??"")+","+(e.h??"")+","+(i?i[0]+"/"+i[1]:"")+","+(n?n[0]+"/"+n[1]:"")+";"}}return t}get _model(){if(!this._serverCfg)return[];const e=this._cfgEpoch+"|"+this._cfgFingerprint();if(this._modelCache&&this._modelCache.key===e)return this._modelCache.model;const t=this._buildModel();return this._modelCache={key:e,model:t},t}_buildModel(){if(!this._serverCfg)return[];const e=this._renderCfg;return el(e).map((t,i)=>{const n=e.spaces[i]?.plan_url;return t.bg&&n?{...t,bg:{...t.bg,href:n}}:t})}_spaceModel(){return this._hasFixedFloor?kc(this._model,this._space):(e=this._model,t=this._space,e.find(e=>e.id===t)??e[0]);var e,t}_spaceModelById(e){return kc(this._model,e)}_syncEmptySpaceState(){if(!!this._serverCfg&&0===this._serverCfg.spaces.length){if(!this._emptySpaceStateActive){this._emptySpaceStateActive=!0,this._clearRoomFocus(!0);for(const e of this._pointers.keys())for(const t of this.renderRoot.querySelectorAll("*"))try{t.hasPointerCapture?.(e)&&t.releasePointerCapture(e)}catch{}this._pointers.clear(),this._panStart=null,this._panLock=null,this._pinchStart=null,this._swipeStart=null,this._drag=null,this._deviceDrag=null,this._resetDeviceHitState(),this._rlResize=null,this._vacFit=null,this._compassDrag=!1,this._cancelModeTransition(!1),this._mode="view",this._clearGeometryGesture(),this._geometryHistory.clear(),this._devicePositionHistory.clear(),this._tip=null,this._hoverRoom=null,this._openingInfo=null,this._closeInfoCard(),this._deviceInbox=null,this._deviceInboxReturn=null,this._markerDialog=null,this._physicalDialog=null,this._backdropDialog=null,this._decorShapeDialog=null,this._decorTextDialog=null,this._roomDialog=!1,"edit"===this._spaceDialog?.mode&&(this._spaceDialog=null),this._editorSecondary?.closeForNavigation(),this._saveConfigDebounced.cancel(),this._frame=null,this._planSnapGeometryCache=null,this._hiddenWallDiagnosticCache=null,this._decorSnapCache=null,this._commitSpace("",!0)}}else this._emptySpaceStateActive=!1}get _areaToSpace(){const e={};for(const t of this._model)for(const i of t.rooms)i.area&&(e[i.area]={space:t.id,room:i});return e}get _settings(){return this._serverCfg?.settings||{}}get _showAll(){return this._showHidden||!this._settings.filter_seeded&&!!this._settings.show_all}_seedHiddenDevices(){if(!(this._loadOk&&this._serverCfg&&this._norm&&this._canEdit))return;const e=this._serverCfg,t=eu({hass:this.hass,registry:this._haRegistry,areaToSpace:Object.fromEntries(Object.entries(this._areaToSpace).map(([e,t])=>[e,t.space])),markers:this._markers,settings:this._settings,excluded:this._excluded,firstSpaceId:this._model[0]?.id||"",iconRules:this._iconRules});if(!t.length&&e.settings?.filter_seeded)return;e.markers=e.markers||[];const i=[];for(const n of t){const t="h"+n.slice(n.indexOf(":")+1);e.markers.push({id:t,binding:n,hidden:!0}),i.push(n.slice(n.indexOf(":")+1))}const n={...e.settings||{},filter_seeded:!0};delete n.show_all,i.length&&Array.isArray(n.new_device_ids)&&(n.new_device_ids=n.new_device_ids.filter(e=>!i.includes(e))),e.settings=n,this._regSignature="",this._maybeRebuildDevices(),this._saveConfig(),this.requestUpdate()}get _iconRules(){const e=this._settings.icon_rules;if(!e||!Array.isArray(e)||!e.length)return;const t=JSON.stringify(e);return t!==this._rulesCompiledSrc&&(this._rulesCompiledSrc=t,this._rulesCompiled=Ee(e)),this._rulesCompiled}get _fillColors(){return vn(this._settings)}get _excluded(){return lu(this._settings)}_setAreaLifecycleConfig(e){this._cfgEpochPreservedConfig=e,this._serverCfg=e}willUpdate(e){if(this._isoProjectionSnapshot=null,this._summary?.willUpdate(),e.has("hass")&&this._configReloadAuthority.observeContext(Vu(this)),e.has("_serverCfg")){const e=this._cfgEpochPreservedConfig===this._serverCfg;this._cfgEpochPreservedConfig=null,e||this._cfgEpoch++,this._renderLife.invalidate()}if(this._syncEmptySpaceState(),this._dangerConfirm&&(this._dangerConfirmMissingSpace()||"warm"===this._syncDangerConfirmLocaleGate())&&this._cancelDangerConfirm(),e.has("hass")&&this.hass){const t=this._visibleDeviceSnapshot||this._candidateDeviceSnapshot;this._renderLife.observe(e.get("hass"),this.hass,t?{entityIds:t.entityIds}:null,()=>Mg(this))}this._continuity.hasCompleteFrame&&"steady"===this._continuity.state&&this._continuity.refreshCompleteFrame(this._visualFrameFingerprint()),this._captureRenderDeviceSnapshot()}updated(){this._summary?.updated(),this._liveRt?.commit(),this._editorRuntime?._commitLiveEditor(),this._pruneDevicePressFeedback(),this._syncDayCycleClock(),this._syncRadarLive(),this._warmSnapshot(),this._editorRuntime&&this._dtMeasure();const e=this._stageEl;e&&!this._roViewport&&(this._roViewport=new ResizeObserver(()=>{this._invalidateDeviceHitGeometry(),this._refitView(),requestAnimationFrame(()=>this._summary?.resized())}),this._roViewport.observe(e)),e&&this._booting&&!this._bootTimer&&this._bootWatch();const t=this.renderRoot.querySelector(".hdr");if(t&&e&&!this._roHdr){const i=()=>{const t=ef(this.renderRoot,e,this.panelHost);null!==t&&(t>=0&&t!==this._hdrH&&(this._hdrH=t),t>=0&&!this._booting&&!this._config?.kiosk&&e.clientHeight>0&&this._warmPatch({hdrH:t,stageH:e.clientHeight}))};this._roHdr=new ResizeObserver(()=>requestAnimationFrame(i)),this._roHdr.observe(t),this._onWinResize=()=>requestAnimationFrame(i),window.addEventListener("resize",this._onWinResize),i()}if(e&&!this._view&&this._refitView(),this._editorSecondary?.afterRender(),this._settleContinuityFrame(),this._serverStorage&&this._loadOk&&this._canManageConfiguration&&0===this._model.length&&!this._spaceDialog&&!this._importDialog&&!this._onboardingShown){this._onboardingShown=!0;const e=function(e){const t=e?.floors;if(!t||"object"!=typeof t)return[];const i=[];for(const e of Object.values(t))e&&e.floor_id&&i.push({id:e.floor_id,name:e.name||e.floor_id,level:e.level??null});return i.sort((e,t)=>{const i=e.level??1e9,n=t.level??1e9;return i!==n?i-n:e.name.localeCompare(t.name)}),i}(this.hass);e.length?this._importDialog={floors:e.map(e=>({...e,checked:!0}))}:this._openSpaceDialog("create")}}_adoptConfigCapabilities(e){xg(this,e)}_syncRadarLive(){const e=this._serverCfg?.settings?.radar,t=(this._serverCfg?.markers||[]).some(e=>Cg(e,this._space));this._radarLive.sync(this._space,1===this._haRadarStage1Api&&"view"===this._mode&&!1!==e?.show_live&&t&&"hidden"!==this.ownerDocument.visibilityState)}async _syncDecorAssets(e){const t=++this._decorAssetSyncToken;if(1!==this._haDecorAssetsApi||!this.hass)return void(this._decorAssets=new Map);const i=await um(this.hass,cm(e),this._cfgRev);t===this._decorAssetSyncToken&&(this._decorAssets=i,this._resign(),this.requestUpdate())}_adoptAuthoritative(e){return ju(this,e)}_rollbackOptimistic(e){const t=this._adoption.rollbackOptimistic(e);return t&&this.requestUpdate(),t}_resumePendingNavMode(){if(!this._pendingNavMode||!this._canEdit||this._config?.kiosk)return!1;const e=this._pendingNavMode;return this._pendingNavMode=null,this._setMode(e,!1),!0}_getAuthoritativeConfig(){return e=this,async function(e,t){const i=await e();return t(i),i}(()=>e.hass.callWS({type:"houseplan/config/get"}),t=>xg(e,t));var e}async _loadFromServer(){this._loading=!0,this._loadTries++;const e=this._space,t=!!this._view;let i=!1;const n=()=>{i=!0,this._regSignature="",this._maybeRebuildDevices()};try{const[i,r]=await Promise.all([this._getAuthoritativeConfig(),this.hass.callWS({type:"houseplan/layout/get"})]);if("adopted"!==(await this._adoptAuthoritative({cfgResp:i,layResp:r,reason:"structural-response",profile:"reload",beforeAdopt:()=>{this._connectionWasLost=!1,this._serverStorage=!0},afterAdopt:()=>{this._warmVpArmed&&this._space===this._warmVp?.space?this._warmVpArmed=!1:t&&this._space===e||this._restoreZoom(),this._loadOk=!0,n()}})).status)return;this.hass.callWS({type:"houseplan/trail/get"}).then(e=>{this._vacSrvTrails=e?.trails||{},this.requestUpdate()}).catch(()=>{}),this._ensureLiveSyncSubscriptions()}catch(e){if(this._serverCfg)this._scheduleLoadRetry(!0);else if(this._loadTries>=8){this._serverStorage=!1;try{this._layout=JSON.parse(localStorage.getItem(lv)||"{}")||{}}catch{this._layout={}}}}finally{this._loading=!1,this._continuityDataReady=!0,i||n(),this.requestUpdate()}}_ensureLiveSyncSubscriptions(){const e=this.hass?.connection;if(!e)return;if(e!==this._liveSyncConnection&&(this._unsubCfg?.(),this._unsubCfg=null,this._unsubLayout?.(),this._unsubLayout=null,this._unsubTrail?.(),this._unsubTrail=void 0,this._unsubVirtual?.(),this._unsubVirtual=null,this._liveSyncGeneration++,this._liveSyncAttempt=null,this._liveSyncConnection=e),this._liveSyncAttempt)return;const t=this._liveSyncGeneration,i=[],n=(n,r,o,s)=>{n()||i.push(async()=>{const i=await e.subscribeEvents(s,o);t===this._liveSyncGeneration&&this.isConnected&&this.hass?.connection===e&&!n()?r(i):i?.()})};if(n(()=>this._unsubCfg,e=>{this._unsubCfg=e},"houseplan_config_updated",e=>{const t=Number(e?.data?.rev??-1);t!==this._cfgRev&&this._reloadConfigOnly(!1,t)}),n(()=>this._unsubTrail,e=>{this._unsubTrail=e},"houseplan_trail_updated",async()=>{try{const e=await this.hass.callWS({type:"houseplan/trail/get"});this._vacSrvTrails=e?.trails||{},this.requestUpdate()}catch{}}),n(()=>this._unsubLayout,e=>{this._unsubLayout=e},"houseplan_layout_updated",e=>this._onLayoutEvent(Number(e?.data?.rev??-1))),n(()=>this._unsubVirtual,e=>{this._unsubVirtual=e},"houseplan_virtual_light_updated",e=>{const t=Wh(this._virtualLights,e?.data);t!==this._virtualLights&&(this._virtualLights=t,this._capturedSnapshotVirtual="",this._cacheSnapshot(),this.requestUpdate())}),!i.length)return;const r=function(e){return Promise.allSettled(e.map(e=>Promise.resolve().then(e)))}(i).then(()=>{});this._liveSyncAttempt=r,r.finally(()=>{this._liveSyncAttempt===r&&(this._liveSyncAttempt=null)})}async _reloadConfigOnly(e=!1,t){return Ku(this,e,t)}_scheduleLoadRetry(e=!1){if(void 0!==this._loadRetryTimer)return;const t=Math.min(8e3,500*2**Math.min(4,Math.max(1,this._loadTries-7)));this._loadRetryTimer=window.setTimeout(()=>{this._loadRetryTimer=void 0,!e&&this._loadOk||this._loading||!this.hass||this._loadFromServer()},t)}async _ensureLiveRuntime(){if(this._liveRt)return;const e=await import("./live-interaction-runtime-DpDkGNJh.js");this._liveRt=new e.LiveRuntime(this),this.isConnected&&this.requestUpdate()}_liveVp(e=!1){this._liveRt?this._liveRt.viewport(e):this.requestUpdate()}_syncLiveHover(){this._liveRt?this._liveRt.hover():this.requestUpdate()}_flushHa(){this._liveRt?.take()&&(this._terminalFrame=2,super.requestUpdate())}_ensureHaRegistryAuthority(){const e=this.hass?.connection||null;e&&e!==this._haRegistryConnection&&(this._haRegistryRelease?.(),this._haRegistryConnection=e,this._haRegistryRev=-1,this._haBindingCacheKey="",this._renderLife.invalidate(),this._areaSnapshotCleanupCandidates.clear(),this._planHassMemo=null,this._haRegistryRelease=td(this.hass,this._onHaRegistryUpdate),this._onHaRegistryUpdate())}get _haRegistry(){return nd(this.hass)}get _planHass(){const e=this._haRegistry,t=od(this.hass,e),i=this._planHassMemo;if(i&&i.hass===this.hass&&i.sig===t)return i.active;const n=ad(this.hass,e),r=ld(this.hass,e);return this._planHassMemo={hass:this.hass,sig:t,active:n,full:r},n}_captureRenderDeviceSnapshot(){if(!this.hass)return;const e=Date.now(),t=[...this._activityRt.entries()].map(([t,i])=>`${t}:${i.gen}:${i.flashTs}:`+(i.flashKind&&(i.expiresAt||i.flashTs+tg)>e?1:0)).join("|"),i=Bh(this._virtualLights);if(this._capturedSnapshotSequence===this._hassSequence&&this._capturedSnapshotDevices===this._devices&&this._capturedSnapshotLayout===this._layout&&this._capturedSnapshotConfigEpoch===this._cfgEpoch&&this._capturedSnapshotVirtual===i&&this._capturedSnapshotActivity===t)return;const n=this._planHass,r=new Map,o=new Map,s=new Set(["sun.sun"]);for(const e of this._summary?.entityIds()||[])s.add(e);this._vacFit?.source&&s.add(this._vacFit.source);const a=new Set,l=new Set,c=e=>{if(!e)return;const t=e.indexOf(":");if(t<0)return void s.add(e);const i=e.slice(0,t),n=e.slice(t+1);"device"===i?a.add(n):"entity"===i&&s.add(n)};for(const e of this._model)for(const t of e.rooms)t.area&&l.add(t.area),c(t.settings?.temp_source),c(t.settings?.hum_source);for(const e of this._serverCfg?.spaces||[])for(const t of e.openings||[])for(const e of ui(t))s.add(e);for(const e of this._serverCfg?.spaces||[])for(const t of e.decor||[])if("text"===t.kind){for(const e of String(t.text||"").matchAll(/\{([^{}\r\n]+)\}/g)){const t=Xi(e[1]);t?.entity&&s.add(t.entity)}t.entity&&s.add(t.entity),o.set(`decor:${e.id}:${t.id}`,tn(t.text,t,n,e=>!!n.entities?.[e]&&!!n.states?.[e]&&!Jd(n,e,Zd(this._markers))))}const h=Ed(n,this._devices,null,this._virtualLights);for(const e of this._devices){for(const t of[!1,!0])r.set(f_(e.id,t),p_(n,e,{liveStates:!1!==this._config?.live_states,showTemperature:!1!==this._config?.show_temperature,showSignal:t,activityRuntime:this._activityRt.get(e.id),sourceDetails:!1,lightDevices:this._devices,lightSources:h,registryHass:this._fullRegistryHass,reducedMotion:this._reducedMotion}));if(this._isVacDev(e)){const t=this._vacSource(e,n),i=t?Wc(n?.states?.[t]?.attributes):null,r=this._vacRt.get(e.id),s=lh(e.id,e.marker?.vacuum??null,e.space,t),a=hh({routes:s,observed:dh(s,[t],t=>this._vacObservedMapId(e,t,n)),spaceIds:new Set(this._model.map(e=>e.id))});o.set(`vacuum:${e.id}`,{source:t,telemetry:i,routes:s,resolution:a,mapId:i?this._vacMapId(e,i,n):null,runtime:r?{trail:r.trail,lastTs:r.lastTs,moving:r.moving,jump:r.jump}:null,server:this._vacSrvTrails[e.id]||null})}}const d=g_({sourceSequence:this._hassSequence,hass:n,devices:this._devices,presentations:r,positions:(u=this._model.length>0,p=this._devices,_=e=>this._livePos(e),u?new Map(p.map(e=>[e.id,_(e)])):new Map),facts:o,entityIds:s,deviceIds:a,areaIds:l});var u,p,_;this._capturedSnapshotSequence=this._hassSequence,this._capturedSnapshotDevices=this._devices,this._capturedSnapshotLayout=this._layout,this._capturedSnapshotActivity=t,this._capturedSnapshotConfigEpoch=this._cfgEpoch,this._capturedSnapshotVirtual=i,this._visibleDeviceSnapshot&&"steady"!==this._continuity.state?this._candidateDeviceSnapshot=d:(this._visibleDeviceSnapshot=d,this._candidateDeviceSnapshot=null)}get _renderDeviceSnapshot(){return this._stagedDeviceSnapshotToken===this._continuity.token?this._candidateDeviceSnapshot||this._visibleDeviceSnapshot:this._visibleDeviceSnapshot||this._candidateDeviceSnapshot}get _renderPlanHass(){return this._renderDeviceSnapshot?.hass||this._planHass}get _renderDevices(){return this._renderDeviceSnapshot?.devices||this._devices}get _renderVacuumDevices(){return this._renderDeviceSnapshot?.vacuumDevices||this._devices}get _fullRegistryHass(){return this._planHass,this._planHassMemo?.full||this.hass}_bindingStatus(e){return dd(this.hass,e,this._haRegistry)}houseplanDiagnostics(){const{registry:e,bindings:t}=this._renderLife.diagnostics(this.hass,this._markers,e=>this._bindingStatus(e));return{registry:{...e,lastSuccessAgeMs:e.lastSuccess?Math.max(0,Date.now()-e.lastSuccess):null},bindings:t}}_openBindingInHa(e){const[t,i]=e.split(":");if(i)if("device"!==t){if("entity"===t){const e=this._fullRegistryHass.entities?.[i];e?.device_id&&fv("/config/devices/device/"+encodeURIComponent(e.device_id))}}else fv("/config/devices/device/"+encodeURIComponent(i))}_bindingHasHaPage(e){const[t,i]=e.split(":");return!!i&&("device"===t||"entity"===t&&!!this._fullRegistryHass.entities?.[i]?.device_id)}_toggleMarkerDialogVisibility(){const e=this._markerDialog;if(!e)return;const t="ha"===e.bindingMode?this._bindingStatus(e.binding):null,i=e.hideFromPlan||"ha_disabled"===t?.kind;i&&"ha_disabled"===t?.kind?this._showToast(this._t("entity"===t.reason?"toast.ha_disabled_show_entity":"toast.ha_disabled_show_device")):i&&"unverified"===t?.kind?this._showToast(this._t("toast.ha_binding_unverified")):this._markerDialog={...e,hideFromPlan:!i}}_hookConnection(){const e=this.hass?.connection;e&&e!==this._connHooked&&(this._connHooked?.removeEventListener?.("ready",this._onConnReady),this._connHooked?.removeEventListener?.("disconnected",this._onConnLost),this._connHooked?.removeEventListener?.("reconnect-error",this._onConnLost),e.addEventListener?.("ready",this._onConnReady),e.addEventListener?.("disconnected",this._onConnLost),e.addEventListener?.("reconnect-error",this._onConnLost),this._connHooked=e)}_display(e){return this._signer.display(this.hass,e)}_referencedContentUrls(){const e=Nn(this._serverCfg);for(const t of this._decorAssets.values())e.add(t.url);return e}_resign(){this._signer.resign(this.hass,this._referencedContentUrls())}_onLayoutEvent(e){e<=this._layoutRev||(clearTimeout(this._layoutSyncTimer),this._layoutSyncTimer=window.setTimeout(()=>{e<=this._layoutRev||this._reloadLayoutOnly()},200))}_noteLayoutRev(e){this._adoption.noteLayoutRevision(e?.rev)}async _reloadLayoutOnly(){if(!this._serverStorage||!this.hass?.callWS)return;this._beginContinuityCandidate("layout-reload",!1);const e=new Map;for(const t of this._dirtyPos)this._layout[t]&&e.set(t,this._layout[t]);this._persistLayout.pending()&&this._persistLayout.flush();for(const[t,i]of this._sentPos)e.set(t,i);try{const t=await this.hass.callWS({type:"houseplan/layout/get"}),i={...t?.layout||{}};for(const[t,n]of e)null===n?delete i[t]:i[t]=n;this._adoption.adoptMergedLayout(i,t,()=>{this._cancelDeviceDrag(),this._devicePositionHistory.clear()}),this._canOptimizeUndo=!!t?.can_optimize_undo,this._undoKind=t?.undo_kind||null,this._cacheSnapshot(),this.requestUpdate()}catch{}finally{this._continuityDataReady=!0,this.requestUpdate()}}_persistLocalLayout(){this._layout=So(lo(this._layout)),localStorage.setItem(lv,JSON.stringify(this._layout))}_maybeRebuildDevices(){const e=this.hass;if(!e?.devices||!e?.entities||!e?.areas)return;const t=this._haRegistry,i=od(e,t)+":"+Object.keys(e.areas).length+":"+(this._norm?"n":"l")+":"+kp(e,this._config?.language);if(i===this._regSignature&&this._devices.length)return;this._regSignature=i;const n=new Map(this._devices.map(e=>[e.id,e.bindingStatus?.kind||"active"]));this._devices=iu({hass:e,registry:t,areaToSpace:Object.fromEntries(Object.entries(this._areaToSpace).map(([e,t])=>[e,t.space])),markers:this._markers,settings:this._settings,excluded:this._excluded,showAll:this._showAll,firstSpaceId:this._model[0]?.id||"",loc:e=>this._t(e),iconRules:this._iconRules});const r=this._markers.filter(e=>!e.removed&&"virtual"!==e.binding).map(e=>e.binding).sort(),o=t.revision+":"+r.join("|");if(t.authoritative&&o!==this._haBindingCacheKey){const i=new Map;for(const n of r)i.set(n,dd(e,n,t));!function(e){if("undefined"==typeof localStorage||!e.size)return;const t=hd(),i=Date.now();for(const[n,r]of e)"active"===r.kind?t[n]={kind:"active",ts:i}:"ha_disabled"===r.kind&&(t[n]={kind:"ha_disabled",reason:r.reason,ts:i});const n=Object.fromEntries(Object.entries(t).sort((e,t)=>t[1].ts-e[1].ts).slice(0,1500));Yh=n;try{localStorage.setItem(Kh,JSON.stringify(n))}catch{}}(i),this._haBindingCacheKey=o}let s=null;if(t.authoritative&&(s=this._resolveAreaRelocations(t),this._areaRelocationIds=new Set(s.relocateIds),this._areaRelocationIds.size)){this._cancelDeviceDrag();const e=this._areaRelocationIds;this._devicePositionHistory.removeWhere(({before:t,after:i})=>e.has(t.deviceId)||e.has(i.deviceId));const t=this._markerDialog;if(t?.devId&&!t.roomTouched&&this._areaRelocationIds.has(t.devId)){const e=this._devices.find(e=>e.id===t.devId);e&&(this._markerDialog={...t,room:e.marker?.room_id?`${e.space}#@${e.marker.room_id}`:e.space&&e.area?`${e.space}#${e.area}`:""})}}this._defPos=this._defaultPositions(),this._syncNewDevices(),this._seedHiddenDevices(),s&&this._syncAreaRelocations(s),this._syncActivityRuntime();const a=new Set(this._devices.filter(e=>!e.hidden).map(e=>e.id));for(const e of this._vacRt.keys())a.has(e)||this._vacRt.delete(e);if(this._infoCard){const e=this._devices.find(e=>e.id===this._infoCard.id);this._infoCard=e&&"ha_disabled"!==e.bindingStatus?.kind?e:null}const l=this._devices.some(e=>"ha_disabled"===e.bindingStatus?.kind&&"ha_disabled"!==n.get(e.id));l&&("ha_disabled"!==this._infoCard?.bindingStatus?.kind&&"ha_disabled"!==this._devices.find(e=>e.id===this._infoCard?.id)?.bindingStatus?.kind||this._closeInfoCard(),this._deviceDrag&&"ha_disabled"===this._devices.find(e=>e.id===this._deviceDrag.id)?.bindingStatus?.kind&&(this._cancelDeviceDrag(),this._devicePositionHistory.clear()),clearTimeout(this._holdTimer),this._holdFired=!1,this._tip=null,this._tapConfirm=null),this._nativeMoreInfoEntity&&!this._planEntityAvailable(this._nativeMoreInfoEntity)&&(gv(this,"hass-more-info",{entityId:null}),this._nativeMoreInfoEntity=null)}_resolveAreaRelocations(e=this._haRegistry){const t=function(e){const t=Q_(e.snapshot),i=new Set(Object.values(t).map(e=>e.binding)),n=new Map;for(const[t,r]of e.previousCandidates||[])J_(t)&&Number.isFinite(r)&&i.has(t)&&n.set(t,r);const r=new Set,o=new Set;for(const t of e.markers||[])t.removed||(Z_(t.id)&&r.add(t.id),J_(t.binding)&&o.add(t.binding));const s=new Set(Object.keys(e.registryDevices||{})),a=new Set(Object.keys(e.registryEntities||{})),l=new Set(Object.keys(e.liveStates||{})),c=new Map;for(const[e,i]of Object.entries(t)){const t=c.get(i.binding)||[];t.push(e),c.set(i.binding,t)}const h=new Set;let d=!1;for(const[t,i]of c){const[c,u]=rm(t);if(o.has(t)||i.some(e=>r.has(e))||("device"===c?s.has(u):a.has(u)||l.has(u))){n.delete(t);continue}const p="device"===c?s.size>0:a.size>0;if(!e.authoritative||!p)continue;const _=n.get(t);if(void 0!==_){if(_!==e.revision)for(const e of i)h.add(e)}else n.set(t,e.revision),d=!0}return{removeIds:h,candidates:n,needsConfirmationRefresh:d}}({snapshot:this._settings.marker_area_snapshot,authoritative:e.authoritative,revision:e.revision,registryDevices:e.devices,registryEntities:e.entities,liveStates:this.hass?.states,markers:this._markers,previousCandidates:this._areaSnapshotCleanupCandidates});return this._areaSnapshotCleanupCandidates=t.candidates,t.needsConfirmationRefresh&&this._canEdit&&id(this.hass),om({devices:this._devices,model:this._model,layout:this._layout,snapshot:this._settings.marker_area_snapshot,authoritative:e.authoritative,cleanupSnapshotIds:t.removeIds,coordinateScale:_v})}_syncNewDevices(){if(!this._norm||!this._loadOk||!this._serverCfg)return;const e=this._devices.filter(e=>!e.marker&&!e.virtual).map(e=>e.id).sort(),t=e.join(",");if(t===this._newSyncKey)return;this._newSyncKey=t;const i=this._settings,{fresh:n,known:r}=function(e,t){if(!Array.isArray(t))return{fresh:[],known:[...e]};const i=new Set(t),n=e.filter(e=>!i.has(e));return{fresh:n,known:n.length?[...t,...n]:t}}(e,i.known_devices);if(!Array.isArray(i.known_devices)||n.length){const e=[...new Set([...i.new_device_ids||[],...n])];this._serverCfg={...this._serverCfg,settings:{...i,known_devices:r,new_device_ids:e}},this._saveConfig()}}_syncAreaRelocations(e){if(!(this._loadOk&&this._serverCfg&&this._norm&&this._canEdit&&this._haRegistry.authoritative))return;const t=e.decisions.filter(e=>e.updateSnapshot||e.removeSnapshot);if(!t.length)return;const i=cc({snapshot:Q_(this._settings.marker_area_snapshot),decisions:t});i!==this._areaRelocationSyncKey&&(this._areaRelocationSyncKey=i,this._areaRelocationWrite=this._areaRelocationWrite.catch(()=>{}).then(async()=>{if(!this._serverCfg||!this._haRegistry.authoritative)return;const e=this._resolveAreaRelocations();this._areaRelocationIds=new Set(e.relocateIds);const t=new Set,i=new Map;let n=!1;for(const r of e.decisions){if(!r.relocate)continue;const e=fg(this._layout,r.id);try{await this._persistDevicePlacement(r.id,null),t.add(r.id),e&&i.set(r.id,e),this._areaRelocationIds.delete(r.id)}catch(t){n=!0,this._layout=vg(this._layout,r.id,e),this._showToast(this._t("toast.pos_save_failed",{err:this._errText(t)}))}}const r=this._settings,o=function(e,t,i=new Set){const n=Q_(e);for(const e of t.decisions)e.removeSnapshot?delete n[e.id]:e.updateSnapshot&&e.binding&&e.area&&(e.relocate&&!i.has(e.id)||(n[e.id]={binding:e.binding,area:e.area}));return n}(r.marker_area_snapshot,e,t),s=[...new Set([...Array.isArray(r.new_device_ids)?r.new_device_ids:[],...t])],a=cc(o)!==cc(Q_(r.marker_area_snapshot)),l=cc(s)!==cc(Array.isArray(r.new_device_ids)?r.new_device_ids:[]);if(a||l){const e=r.marker_area_snapshot,n=r.new_device_ids,a={...this._serverCfg,settings:{...r,marker_area_snapshot:o,...l?{new_device_ids:s}:{}}};this._setAreaLifecycleConfig(a);try{this._saveConfigDebounced.pending()&&this._saveConfigDebounced.cancel(),await this._writeConfig()}catch(r){const a=this._settings;if(cc(a.marker_area_snapshot)===cc(o)&&cc(a.new_device_ids)===cc(l?s:n)){const t={...a};void 0===e?delete t.marker_area_snapshot:t.marker_area_snapshot=e,void 0===n?delete t.new_device_ids:t.new_device_ids=n;const i={...this._serverCfg,settings:t};this._setAreaLifecycleConfig(i),this._adoption.refreshConfigFingerprint()}for(const e of t)this._areaRelocationIds.add(e);const c=new Set;for(const[e,t]of i)try{await this._persistDevicePlacement(e,t)}catch(t){c.add(e),this._showToast(this._t("toast.pos_save_failed",{err:this._errText(t)}))}this._areaRelocationSyncKey="",this._regSignature="";if("conflict"===(r&&"object"==typeof r&&"code"in r?r.code:void 0)?(this._showToast(this._t("toast.conflict")),await this._reloadConfigOnly(!0)):this._showToast(this._t("toast.cfg_save_failed",{err:this._errText(r)})),c.size&&this._serverCfg){const e=this._settings,t=[...new Set([...Array.isArray(e.new_device_ids)?e.new_device_ids:[],...c])],i={...this._serverCfg,settings:{...e,new_device_ids:t}};this._setAreaLifecycleConfig(i);try{await this._writeConfig()}catch(e){this._showToast(this._t("toast.cfg_save_failed",{err:this._errText(e)}))}}}}n&&(this._areaRelocationSyncKey=""),this.requestUpdate()}))}get _newIds(){const e=this._settings.new_device_ids;return new Set([...Array.isArray(e)?e:[],...this._areaRelocationIds])}_ackNewDevice(e){if(!this._newIds.has(e)||!this._serverCfg)return;const t=this._settings;this._serverCfg={...this._serverCfg,settings:{...t,new_device_ids:(t.new_device_ids||[]).filter(t=>t!==e)}},this._saveConfig(),this.requestUpdate()}get _markers(){return this._serverCfg?.markers||[]}_roomLqi(e){if(!e)return null;const t=[];for(const i of this._renderDevices){if(i.area!==e||i.virtual)continue;const n=Ld(this._renderPlanHass,i.entities);null!=n&&t.push(n)}return Ii(t)}_roomBounds(e){if(e.poly&&e.poly.length){const t=e.poly.map(e=>e[0]),i=e.poly.map(e=>e[1]),n=Math.min(...t),r=Math.min(...i);return{x:n,y:r,w:Math.max(...t)-n,h:Math.max(...i)-r}}return{x:e.x??0,y:e.y??0,w:e.w??0,h:e.h??0}}_defaultPositions(){const e={},t=this._config?.icon_size??2.5;for(const i of this._model){const n=t/100*Ml(i)*1.3;for(const t of i.rooms){if(!t.area)continue;const r=this._devices.filter(e=>e.area===t.area&&e.space===i.id);if(!r.length)continue;const o=this._roomBounds(t),s=.1*Math.min(o.w,o.h),a=o.w-2*s,l=o.h-2*s,c=Math.max(1,Math.round(Math.sqrt(r.length*a/Math.max(l,1)))),h=Math.ceil(r.length/c),d=a/c,u=l/Math.max(h,1),p=r.map((e,t)=>({x:o.x+s+d*(t%c+.5),y:o.y+s+u*(Math.floor(t/c)+.5)}));Ei(p,o,n,.5*s),r.forEach((t,i)=>e[t.id]=al(p[i]))}}return e}_pos(e){const t=this._renderDeviceSnapshot?.positions.get(e.id);return t?{x:t.x,y:t.y}:this._livePos(e)}_livePos(e){const t=this._spaceModelById(e.space),i=this._areaRelocationIds.has(e.id)?void 0:this._layout[e.id];if(i)if(this._norm){if(i.s===e.space)return{x:i.x*_v,y:i.y*_v}}else if(void 0===i.s)return{x:i.x,y:i.y};return this._defPos[e.id]?this._defPos[e.id]:t?al($l(t)):{x:500,y:500}}_devicePlacementForCanvas(e,t,i){if(!this._norm)return{x:Math.round(t),y:Math.round(i)};const n=this._gridPitch,r=Math.round(t/n)*n,o=Math.round(i/n)*n;return{s:e.space,x:cl(r/_v),y:cl(o/_v)}}_previewDevicePlacement(e,t){this._layout=vg(this._layout,e,t),this.requestUpdate()}_cancelDeviceDrag(){const e=this._deviceDrag;if(!e)return!1;this._editorRuntime?._cancelPointerMove("device"),this._deviceDrag=null,this._deviceHits.cancel(e.pointerId);try{e.source?.hasPointerCapture?.(e.pointerId)&&e.source.releasePointerCapture(e.pointerId)}catch{}return this._previewDevicePlacement(e.id,e.before),!0}async _persistDevicePlacement(e,t){if(this._layout=vg(this._layout,e,t),this._serverStorage){let i=null,n=!1;try{let r;if(null===t)i=null,this._sentPos.set(e,i),n=!0,r=await this.hass.callWS({type:"houseplan/layout/delete",device_id:e});else{const t=xo(this._layout[e]);cc(t)!==cc(this._layout[e])&&(this._layout={...this._layout,[e]:t}),i=t,this._sentPos.set(e,i),n=!0,r=await this.hass.callWS({type:"houseplan/layout/update",device_id:e,pos:t})}this._noteLayoutRev(r),this._adoption.refreshLayoutFingerprint(),this._cacheSnapshot()}finally{n&&this._sentPos.get(e)===i&&this._sentPos.delete(e)}return}this._persistLocalLayout()}_devicePositionStateValid(e){const t=this._devices.find(t=>t.id===e.deviceId);return!!t&&t.space===e.spaceId&&"ha_disabled"!==t.bindingStatus?.kind&&!!this._spaceModelById(e.spaceId)}async _runDevicePositionHistory(e){if(this._cancelDeviceDrag()||this._devicePositionBusy)return;const t="undo"===e?this._devicePositionHistory.undo():this._devicePositionHistory.redo();if(!t)return;const i="undo"===e?t.before:t.after;if(!this._devicePositionStateValid(i))return this._devicePositionHistory.clear(),this._showToast(this._t("history.device_stale")),void this.requestUpdate();const n=fg(this._layout,i.deviceId);i.spaceId!==this._space&&(this._commitSpace(i.spaceId),this._restoreZoom()),this._devicePositionBusy=!0,this._previewDevicePlacement(i.deviceId,i.placement);try{await this._persistDevicePlacement(i.deviceId,i.placement),this._showToast(this._t("undo"===e?"history.undone":"history.redone",{name:t.name}))}catch(t){this._previewDevicePlacement(i.deviceId,n),"undo"===e?this._devicePositionHistory.redo():this._devicePositionHistory.undo(),this._showToast(this._t("toast.pos_save_failed",{err:this._errText(t)}))}finally{this._devicePositionBusy=!1,this.requestUpdate()}}_undoDevicePosition(){this._runDevicePositionHistory("undo")}_redoDevicePosition(){this._runDevicePositionHistory("redo")}_savePos(e,t,i){this._spaceModelById(e.space)&&(this._layout=vg(this._layout,e.id,this._devicePlacementForCanvas(e,t,i)),this._dirtyPos.add(e.id),this._persistLayout())}_devicePresentation(e,t=!1!==this._config?.show_signal,i=!1){const n=i?null:this._renderDeviceSnapshot?.presentations.get(f_(e.id,t));return n||p_(this._renderPlanHass,e,{liveStates:!1!==this._config?.live_states,showTemperature:!1!==this._config?.show_temperature,showSignal:t,designPreview:i,activityRuntime:this._activityRt.get(e.id),sourceDetails:!1,lightDevices:this._renderDevices,registryHass:this._fullRegistryHass,reducedMotion:this._reducedMotion})}_deviceVisual(e){return this._devicePresentation(e).visual}_stateClass(e,t=this._deviceVisual(e)){const i=this._devicePresentation(e);return i.effectiveHidden?"":("icon_ripple"!==i.display||!1===this._config?.live_states||"alarm"===t.status||t.activity,u_({...i,visual:t}).join(" "))}_liveTemp(e){if(!this._config?.show_temperature)return null;if(!0===e.marker?.use_climate_temp){const t=qd(this._renderPlanHass,e.entities);if(null!=t)return t}return"mdi:thermometer"!==e.icon&&"mdi:air-filter"!==e.icon?null:Bd(this._renderPlanHass,e.entities)}_bindingEntities(e){if("virtual"===e||!e)return[];const t=this._bindingStatus(e);return"active"===t.kind?t.enabledEntityIds:t.allEntityIds}_bindingHasClimate(e){return this._bindingEntities(e).some(e=>e.startsWith("climate."))}_bindingHasAlarm(e){return this._bindingEntities(e).some(e=>{const t=this._planHass?.states?.[e]||this.hass?.states?.[e],i=this._fullRegistryHass.entities[e]||this.hass?.entities?.[e];return Yn(e.split(".")[0],t?.attributes?.device_class||i?.device_class||i?.original_device_class)})}_deviceBindingActive(e,t=!0){if(e.virtual||"virtual"===e.bindingKind)return!0;if(!e.bindingKind||!e.bindingRef)return!1;const i=this._bindingStatus(`${e.bindingKind}:${e.bindingRef}`);return"active"===i.kind||(t&&this._showToast(this._t("ha_disabled"===i.kind?"toast.ha_disabled_action":"toast.ha_binding_unverified")),!1)}_openMoreInfo(e){e?this._planEntityAvailable(e)?(this._kiosk&&(this._cyclePausedUntil=Math.max(this._cyclePausedUntil,Date.now()+6e4)),this._nativeMoreInfoEntity=e,gv(this,"hass-more-info",{entityId:e})):this._showToast(this._t("toast.ha_disabled_action")):this._showToast(this._t("toast.no_entity"))}_interruptViewGesture(e,t){if(clearTimeout(this._holdTimer),clearTimeout(this._kioskHoldTimer),void 0!==e)for(const i of[t,this._stageEl])try{i?.hasPointerCapture?.(e)&&i.releasePointerCapture(e)}catch{}this._pointers.clear(),this._panStart=null,this._panLock=null,this._pinchStart=null,this._swipeStart=null,this._roomPointer=null,this._doubleFit.clear(),this._deviceHits.clearPointers()}_closeInfoCard(){this._interruptViewGesture(),this._holdFired=!1,this._infoCard=null}_invalidateDeviceHitGeometry(){this._deviceHits.invalidate()}_resetDeviceHitState(){this._deviceHits.reset(this.renderRoot)}_deviceHitOwnerAt(e,t){return"view"!==this._mode&&"devices"!==this._mode?null:this._deviceHits.at(this.renderRoot,this._renderDevices,this._space,e,t)}_deviceForPointerEvent(e,t){return this._deviceHits.pointer(this.renderRoot,this._renderDevices,this._space,e,t)}_deviceForClickEvent(e,t){return this._deviceHits.click(this.renderRoot,this._renderDevices,this._space,e,t)}_showDeviceTip(e,t){this._liveRt?this._liveRt.devicePointerTip(e,t):this._ensureLiveRuntime().then(()=>this._liveRt?.devicePointerTip(e,t))}_showDeviceFocusTip(e,t){const i=e.currentTarget;this._liveRt?this._liveRt.deviceFocusTip(i,t):this._ensureLiveRuntime().then(()=>this._liveRt?.deviceFocusTip(i,t))}_hideDeviceFocusTip(e){this._liveRt?.deviceBlur(e)}_clearPointerHover(){this._liveRt?this._liveRt.pointerLeave():this._clearTransientHover()}_ctxDevice(e,t){"view"===this._mode&&(t=this._deviceForPointerEvent(e,t),e.preventDefault(),e.stopPropagation(),this._deviceBindingActive(t)&&(t.primary?this._openMoreInfo(t.primary):this._infoCard=t))}_clickDevice(e,t){if("view"!==this._mode&&"devices"!==this._mode)return;if(e.stopPropagation(),t=this._deviceForClickEvent(e,t),this._deviceDrag?.moved||this._suppressClick||this._holdFired)return;if("devices"===this._mode)return void this._openMarkerDialog(t);const i=this._devices.find(e=>e.id===t.id);if(!i)return;const n=Tu(i.tapAction,i.primary?.split(".")[0]);if("none"===n)return;const r=(e,t)=>{i.marker?.tap_confirm?this._tapConfirm={kind:"run",text:e,exec:t}:t()};if("toggle"===n){const e=this._toggleIntent(i);if(!e)return;if(!Iu(e))return void this._showUnavailableToggleTargets(e);const t=e=>{const t=Iu(e);if(!t)return;if("virtual-light"===t.kind)return this._startDevicePressFeedback(i.id),void this.hass.callWS({type:"houseplan/virtual_light/toggle",marker_id:t.markerId}).then(e=>{const t=Wh(this._virtualLights,e);t!==this._virtualLights&&(this._virtualLights=t,this._capturedSnapshotVirtual="",this._cacheSnapshot(),this.requestUpdate())}).catch(e=>this._showToast(this._t("toast.virtual_light_toggle_failed",{err:this._errText(e)})));const{command:n}=t;this._startDevicePressFeedback(i.id),this.hass.callService(n.domain,n.service,n.data).catch(e=>this._showToast(this._t("toast.error",{err:this._errText(e)})))},n=((o=e).targets.length?o.targets:o.skippedTargets).map(e=>e.name||e.entityId||e.ref).join(", ")||i.name;if(i.marker?.tap_confirm){const r=this._toggleConfirmationLines(e);if(!r.length)return;this._tapConfirm={kind:"toggle",text:this._t("confirm.tap_toggle",{name:n}),lines:r,initialIntent:e,deviceId:i.id,exec:()=>{const n=this._devices.find(e=>e.id===i.id),r=n?this._toggleIntent(n):null;r&&!Iu(r)&&this._showUnavailableToggleTargets(r)||(r&&Eu(e,r)?t(r):this._showToast(this._t("toast.tap_target_changed")))}}}else t(e);return}var o;if("info"===n)return this._interruptViewGesture(),void(this._infoCard=i);if(this._deviceBindingActive(i)){if("run"===n){const e=i.marker?.tap_target||"",t=function(e){const t=String(e||"").split(".")[0];return"automation"===t?{domain:"automation",service:"trigger"}:"script"===t?{domain:"script",service:"turn_on"}:"scene"===t?{domain:"scene",service:"turn_on"}:null}(e),n=this.hass.states[e];if(!t||!n)return void this._showToast(this._t("toast.run_target_missing"));const o=n.attributes?.friendly_name||e;return void r(this._t("confirm.tap_run",{name:o}),()=>{this._deviceBindingActive(i)&&this._planEntityAvailable(e)&&(this._startDevicePressFeedback(i.id),this.hass.callService(t.domain,t.service,{entity_id:e}).then(()=>{this._stampActivity(i.id,"event",this._activitySourceKey(i)),this.requestUpdate(),this._showToast(this._t("toast.run_started",{name:o}))}).catch(e=>this._showToast(this._t("toast.error",{err:this._errText(e)}))))})}"more-info"===n&&i.primary?this._openMoreInfo(i.primary):this._infoCard=i}}_showUnavailableToggleTargets(e){const t=function(e){if(!e||"group"!==e.kind||Iu(e)||"configured-targets-missing"!==e.noneReason)return[];if(!e.skippedTargets.length||e.skippedTargets.some(e=>!Ou.has(e.reason)&&"secure"!==e.reason))return[];const t=[],i=new Set;for(const n of e.skippedTargets){if(!Ou.has(n.reason))continue;const e=String(n.name||n.entityId||n.ref||"").trim();e&&!i.has(e)&&(i.add(e),t.push(e))}return t}(e);return!!t.length&&(this._showToast(1===t.length?this._t("toast.toggle_target_unavailable",{name:t[0]}):this._t("toast.toggle_targets_unavailable",{names:t.join(", ")})),!0)}_keyDevice(e,t){"Enter"!==e.key&&" "!==e.key||"view"!==this._mode&&"devices"!==this._mode||(e.preventDefault(),this._clickDevice(e,t))}_startDevicePressFeedback(e){const t=[...this.renderRoot.querySelectorAll(".dev[data-id]")].find(t=>t.dataset.id===e),i=t?.querySelector(".device-shell");if(!i||"function"!=typeof i.animate)return;const n=Number.parseFloat(this.ownerDocument.defaultView?.getComputedStyle(i).scale||""),r=Number.isFinite(n)?Math.max(.95,Math.min(1,n)):1;this._devicePressAnimations.get(e)?.cancel();const o=this._reducedMotion?[{outlineColor:"transparent",outlineStyle:"solid",outlineWidth:"0px"},{outlineColor:"var(--hp-accent, #3ea6ff)",outlineStyle:"solid",outlineWidth:"2px",outlineOffset:"2px",offset:.5},{outlineColor:"transparent",outlineStyle:"solid",outlineWidth:"0px"}]:[{scale:String(r)},{scale:"0.95",offset:.5},{scale:"1"}],s=i.animate(o,{duration:200,easing:"cubic-bezier(.22,.61,.36,1)"});this._devicePressAnimations.set(e,s);const a=()=>{this._devicePressAnimations.get(e)===s&&this._devicePressAnimations.delete(e)};s.addEventListener("finish",a,{once:!0}),s.addEventListener("cancel",a,{once:!0})}_cancelDevicePressFeedback(){for(const e of this._devicePressAnimations.values())e.cancel();this._devicePressAnimations.clear()}_pruneDevicePressFeedback(){if(!this._devicePressAnimations.size)return;const e=new Set([...this.renderRoot.querySelectorAll(".dev[data-id]")].map(e=>e.dataset.id||""));for(const[t,i]of this._devicePressAnimations)e.has(t)||(i.cancel(),this._devicePressAnimations.delete(t))}_t(e,t){return xp(kp(this.hass,this._config?.language),e,t)}get _colorPickerLabels(){return{title:this._t("color_picker.title"),hue:this._t("color_picker.hue"),saturation:this._t("color_picker.saturation"),value:this._t("color_picker.value"),hex:this._t("color_picker.hex"),invalidHex:this._t("color_picker.invalid_hex"),confirm:this._t("color_picker.confirm")}}_help(e){return this._editorRuntimeOrThrow()._help(e)}get _stageEl(){return this.renderRoot.querySelector(".stage")}_contentItems(e){const t=[];for(const i of this._devices){if(i.space!==e.id||i.hidden)continue;const n=this._pos(i);t.push({minX:n.x,minY:n.y,maxX:n.x,maxY:n.y})}if(e.id===this._space){for(const e of this._openingsR){const i=Number(e.angle)*Math.PI/180,n=Math.cos(i)*e.rlen/2,r=Math.sin(i)*e.rlen/2,o=pl([[e.rx-n,e.ry-r],[e.rx+n,e.ry+r]]);o&&t.push(o)}const i=this._decorH;for(const e of this._decorList){if("image"===e.kind&&!this._decorAssets.has(e.asset_id)&&"decor"!==this._mode)continue;const n=pl("line"===e.kind?[[e.x1*_v,e.y1*i],[e.x2*_v,e.y2*i]]:"text"===e.kind?[[e.x*_v,e.y*i]]:Nr({x:e.x*_v,y:e.y*i,w:e.w*_v,h:e.h*i,angle:e.angle}));n&&t.push(n)}for(const i of this._physicalBodiesR(e)){const e=pl(i);e&&t.push(e)}}return vl(e,t)}_frameOf(){const e=this._spaceModel();if(!e){this._frame=null;const e={x:0,y:0,w:_v,h:_v};return{rect:e,all:e,outliers:0}}const t=this._frame,i="view"!==this._mode;if(t&&t.id===e.id&&this._bdDrag)return t;if(t&&t.id===e.id&&t.model===e&&t.layout===this._layout&&t.devs===this._devices&&t.far===this._showFar&&t.grow===i)return t;const n=kl(this._contentItems(e));let r=n.all||Sl(e),o=this._showFar?r:n.core||Sl(e);return t&&t.id===e.id&&i&&t.grow&&(o=mv(t.rect,o),r=mv(t.all,r)),this._frame={id:e.id,model:e,layout:this._layout,devs:this._devices,far:this._showFar,grow:i,rect:o,all:r,outliers:n.outliers},this._frame}_isoSource(){const e=this._isoSceneRuntime;if(!e)return null;const t=this._spaceModel();if(!t)return null;const i=this._spaceWalls,n=this._openCuts(),r=this._openingsR;return e.createIsoStructuralSource({space:t,walls:i,openCuts:n,openings:r,partitionCuts:()=>this._partitionOpeningCuts(t),roomOpenings:()=>this._roomWallOpeningInputs(r,t),cellCm:this._cellCm,gridPitch:this._gridPitch,wallKeyPitch:this._wallKeyPitch,coordinateScale:_v,onBuild:()=>{this._isoStructuralBuildCount+=1}})}_isoSceneKey(){if(!this._labsIso||"view"!==this._mode)return null;try{return this._isoSource()?.key??null}catch{return this._isoInvalidKey()}}_isoInvalidKey(){return`${this._space}|invalid|${this._cfgEpoch}`}_clearIsoInvalidFallback(e){const t=`${this._space}|invalid|`;for(const i of this._isoFallback)i.startsWith(t)&&i!==e&&this._isoFallback.delete(i)}_isoScene(e=this._isoSource()){const t=this._isoSceneRuntime;if(!t||!e)return null;let i=this._frameOf().rect;const n=this._spaceDisplayForRender(),r=this._spaceModel();if(r&&n.showNames)for(const e of r.rooms)if(e.name){const t=this._labelPos(e,r.id);i=mv(i,{x:t.x,y:t.y,w:0,h:0})}const o=t.resolveIsoScene({source:e,cache:this._isoGeometryCache,cellCm:this._cellCm,liveFrame:i});if(!r||!n.showBorders)return o;const s=this._config?.icon_size??2.5,a=s>8?2.5:s,l=this._stageEl?.getBoundingClientRect?.()??null,c=l?.height?l.width/l.height:o.frame.w/o.frame.h,h=Oi([o.frame.x,o.frame.y,o.frame.w,o.frame.h],c),d=this._isoOverlayScene(r,this._renderDevices.filter(e=>e.space===r.id&&!e.hidden),h,n,t.resolveIsoDecorationLayers(n),o,a,x_(a),n.showLqi??this._config?.show_signal??!0,!1),u=d&&t.resolveIsoOverlayFitEnvelope({baseBounds:o.frame,entries:d.entries,stageSize:l,targetView:e=>Oi([e.x,e.y,e.w,e.h],c)});return u?{...o,frame:u.bounds,overlayFitEntries:d.entries}:o}_latchIsoFallback(e,t){if(this._isoFallback.has(e))return;this._isoFallback.add(e);const i=e.includes("|invalid|")?"invalid":e.split("|").pop()||"invalid";console.warn("HOUSEPLAN ISO FALLBACK: #89/#160",wf("structural",i,!0))}_effectiveProjection(){if(this._isoProjectionSnapshot)return this._isoProjectionSnapshot;const e=e=>this._isoProjectionSnapshot=e,t=()=>("iso"===this._renderProjection&&(this._cancelCameraTransition(!1),this._view=null,this._viewModeSnap=null),e("flat"));if(this._renderIsoScene=null,"iso"!==this._desiredProjection||!this._model.length||!this._isoSceneRuntime)return e("flat");if(!this._spaceDisplayForRender().showBorders)return this._isoFallback.has(`${this._space}|no-borders`)?t():e("iso");let i=this._isoInvalidKey();if(this._clearIsoInvalidFallback(i),this._isoFallback.has(i))return t();try{const n=this._isoSource();if(!n)return e("flat");if(i=n.key,this._isoFallback.has(i))return t();const r=this._isoScene(n);return r?this._isoFallback.has(r.key)?t():(this._renderIsoScene=r,e("iso")):e("flat")}catch(e){return this._latchIsoFallback(i,e),t()}}_scenePoint(e){return"iso"===this._renderProjection?lf(e,0):e}_floorView(e){if("iso"!==this._renderProjection)return e;const t=cf([e.x,e.y]),i=cf([e.x+e.w,e.y+e.h]);return{x:t[0],y:t[1],w:i[0]-t[0],h:i[1]-t[1]}}_isoOverlayScene(e,t,i,n,r,o,s,a,l,c=!0){const h=this._isoSceneRuntime;return h&&r?.structural&&o?h.buildIsoOverlayRenderScene({space:e,devices:t,openings:this._openingsR,view:i,display:n,wallSilhouettes:o.wallSilhouettes,resolveCollisions:c,iconPct:s,deviceBasePct:a,showLqi:l,cellCm:this._cellCm,kioskIconScale:"view"===this._mode?this._kioskScale.icon:1,kioskFontScale:"view"===this._mode?this._kioskScale.font:1,stageSize:this._stageEl?.getBoundingClientRect?.(),positionOf:e=>this._pos(e),presentationOf:(e,t)=>this._devicePresentation(e,t),labelPositionOf:(e,t)=>this._labelPos(e,t),labelScaleOf:e=>this._labelScale(e),openingEntityAvailable:e=>this._renderOpeningEntityAvailable(e),openingWallIndex:()=>this._openingWallIndexFor(e,this._openCuts()).value}):null}_baseVb(e=this._effectiveProjection(),t=this._renderIsoScene){if("iso"===e){if(!this._spaceDisplayForRender().showBorders){const e=uf({rect:this._frameOf().rect,wallHeight:0});return[e.x,e.y,e.w,e.h]}const e=t?.frame??this._frameOf().rect;return[e.x,e.y,e.w,e.h]}const i=this._frameOf().rect;return[i.x,i.y,i.w,i.h]}get _outliers(){return this._showFar?0:this._frameOf().outliers}_fitFar(){this._clearRoomFocus(),this._showFar=!0,this._frame=null,this.requestUpdate(),this._resetZoom()}_clearRoomFocus(e=!1){this._doubleFit.clear(),this._roomFocus=null,e&&(this._roomPointer=null)}_roomFitBounds(e,t){const i=ni(e);if(!i||!e.id)return null;const n=this._spaceWalls,r=this._openCuts(),o=this._wallUnionGeometry(),s=n.length&&this._innerRoomContour(t,e.id,r,o?.roomGeom,o?.multiWallNodes)||i,a=this._spaceDisplayForRender();let l=[];if(a.showBorders&&n.length){const i=Fs(t.rooms,e.id,n,r,this._wallKeyPitch,this._cellCm,this._gridPitch,_v);i&&(l=aa(i.poly,i.offsets,o?.multiWallNodes)||i.poly)}const c=this._effectiveProjection();return function(e){const t=e.floor,i=e.wall||[],n=e.padding??0;if(!t.length||!t.every(vf)||!i.every(vf)||!Number.isFinite(n)||n<0)return null;if("flat"===e.projection)return bf([...t,...i],n);const r=e.wallHeight??0,o=e.floorDepth??0;if(!Number.isFinite(r)||r<0||!Number.isFinite(o)||o<0)return null;try{const e=[];for(const i of t){const t=[i[0],i[1]];e.push(lf(t,0)),o>0&&e.push(lf(t,-o))}for(const t of i){const i=[t[0],t[1]];e.push(lf(i,0)),r>0&&e.push(lf(i,r))}return bf(e,n)}catch{return null}}({floor:s,wall:l,projection:c,wallHeight:"iso"===c&&a.showBorders?Wa(84,this._cellCm):0,floorDepth:"iso"===c&&a.showBorders?Wa(10,this._cellCm):0,padding:a.showBorders?Wa(1.25,this._cellCm):0})}_fitRoom(e,t=!0){if("view"!==this._mode)return!1;this._doubleFit.clear();const i=this._spaceModel(),n=i?.rooms.find(t=>t.id===e);if(!i||!n)return this._clearRoomFocus(),!1;let r=this._roomFitBounds(n,i);if(!r)return this._clearRoomFocus(),!1;this._roomFocus={spaceId:i.id,roomId:e};const o=this._stageEl;if(!o||o.clientWidth<=0||o.clientHeight<=0)return!0;const s=Oi(this._baseVb(),o.clientWidth/o.clientHeight),a=e=>function(e){const t=e.safeFraction??.8,{bounds:i,baseFit:n,stageWidth:r,stageHeight:o,minZoom:s,maxZoom:a}=e;if(!yf(i)||!yf(n)||!Number.isFinite(r)||r<=0||!Number.isFinite(o)||o<=0||!Number.isFinite(s)||s<=0||!Number.isFinite(a)||a1)return null;const l=r/o,c=Math.max(i.w/t,i.h/t*l);if(!Number.isFinite(c)||c<=0)return null;const h=Math.min(a,Math.max(s,n.w/c)),d=n.w/h,u=d/l;return{zoom:h,viewBox:{x:i.x+i.w/2-d/2,y:i.y+i.h/2-u/2,w:d,h:u}}}({bounds:e,baseFit:s,stageWidth:o.clientWidth,stageHeight:o.clientHeight,minZoom:wv.ZOOM_MIN,maxZoom:wv.ZOOM_MAX});let l=a(r);const c=this._isoSceneRuntime,h=this._renderIsoScene?.overlayFitEntries;if(l&&"iso"===this._effectiveProjection()&&c&&h?.length){const e=c.resolveIsoOverlayFitEnvelope({baseBounds:r,entries:h,ownerId:n.id,stageSize:{width:o.clientWidth,height:o.clientHeight},targetView:e=>a(e)?.viewBox??null});e&&(r=e.bounds,l=a(r))}if(!l)return this._clearRoomFocus(),!1;const d=this._cameraState(),u=function(e,t,i,n){const r=[e,t,i,n],o=Math.min(...r.map(e=>e.x)),s=Math.min(...r.map(e=>e.y));return{x:o,y:s,w:Math.max(...r.map(e=>e.x+e.w))-o,h:Math.max(...r.map(e=>e.y+e.h))-s}}(s,d.viewBox,l.viewBox,r);return l.viewBox=this._clampView(l.viewBox,u),t?(this._prepareCameraCommand(),this._startCameraTransition(l,u,"room",220),!0):(this._cancelCameraTransition(!1),Xg(d,l)||(this._zoom=l.zoom,this._view={...l.viewBox},this.requestUpdate()),!0)}_fitAll(e="fit"){this._clearRoomFocus(),this._showFar=!0,this._frame=null,this.requestUpdate(),this._resetZoom(e)}_renderFarHint(){return this._kiosk||"view"!==this._mode||this._booting||!this._outliers?G:j`
    ${this._t("canvas.far_objects",{n:this._outliers})} @@ -820,7 +820,7 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db ${this._renderOpeningLocks(S,R?.locks)} ${g.showNames||this._markup?a.rooms.map(e=>this._renderRoomLabel(e,a,S,g,R?.rooms.get(e))):G} ${this._markup?a.rooms.map(e=>this._renderRoomGear(e,a,S)):G} - ${q={hass:this.hass,settings:this._settings,devices:this._renderDevices,registry:this._haRegistry,currentSpace:a.id,spaces:this._serverCfg?.spaces,viewKey:S,view:"view"===this._mode,kiosk:this._kiosk},q.view&&!q.kiosk&&!0===q.hass?.user?.is_admin&&zg(q.settings).enabled?(import("./hp-zigbee-topology-overlay-SYVcVGiq.js"),j``):G}
    diff --git a/dist/houseplan-assets/houseplan-editor-runtime-BG2wMJ7n.js b/dist/houseplan-assets/houseplan-editor-runtime-DOSm4OKX.js similarity index 88% rename from dist/houseplan-assets/houseplan-editor-runtime-BG2wMJ7n.js rename to dist/houseplan-assets/houseplan-editor-runtime-DOSm4OKX.js index 0bf2a6cc..d0ceaa7b 100644 --- a/dist/houseplan-assets/houseplan-editor-runtime-BG2wMJ7n.js +++ b/dist/houseplan-assets/houseplan-editor-runtime-DOSm4OKX.js @@ -1,4 +1,4 @@ -globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db7c58754eeb4ba03f835b8d7c84c6";import{e as t,i as e,E as s,s as i,a as o,n as a,f as n,b as r,l,o as h,r as c,A as d,c as p,d as u,g as _,h as g,v as m,j as f,k as b,m as v,p as y,q as $,t as w,u as k,w as x,x as M,T as C,y as S,D as P,z as D,B as I,C as L,F as T,G as R,H as z,I as F,J as N,K as A,L as E,M as O,N as H,O as B,P as W,Q as j,R as G,S as q,U,V as K,W as V,X as J,Y as Z,Z as Y,_ as X,$ as Q,a0 as tt,a1 as et,a2 as st,a3 as it,a4 as ot,a5 as at,a6 as nt,a7 as rt,a8 as lt,a9 as ht,aa as ct,ab as dt,ac as pt,ad as ut,ae as _t,af as gt,ag as mt,ah as ft,ai as bt,aj as vt,ak as yt,al as $t,am as wt,an as kt,ao as xt,ap as Mt,aq as Ct,ar as St,as as Pt,at as Dt,au as It,av as Lt,aw as Tt,ax as Rt,ay as zt,az as Ft,aA as Nt,aB as At,aC as Et,aD as Ot,aE as Ht,aF as Bt,aG as Wt,aH as jt,aI as Gt,aJ as qt,aK as Ut,aL as Kt,aM as Vt,aN as Jt,aO as Zt,aP as Yt,aQ as Xt,aR as Qt,aS as te,aT as ee,aU as se,aV as ie,aW as oe,aX as ae,aY as ne,aZ as re,a_ as le,a$ as he,b0 as ce,b1 as de,b2 as pe,b3 as ue,b4 as _e,b5 as ge,b6 as me,b7 as fe,b8 as be,b9 as ve,ba as ye,bb as $e,bc as we,bd as ke,be as xe,bf as Me,bg as Ce,bh as Se,bi as Pe,bj as De,bk as Ie,bl as Le,bm as Te,bn as Re,bo as ze,bp as Fe,bq as Ne,br as Ae,bs as Ee,bt as Oe,bu as He,bv as Be,bw as We,bx as je,by as Ge,bz as qe,bA as Ue,bB as Ke,bC as Ve,bD as Je,bE as Ze,bF as Ye,bG as Xe,bH as Qe,bI as ts,bJ as es,bK as ss,bL as is,bM as os,bN as as,bO as ns,bP as rs,bQ as ls,bR as hs,bS as cs,bT as ds,bU as ps,bV as us,bW as _s,bX as gs,bY as ms,bZ as fs,b_ as bs,b$ as vs,c0 as ys,c1 as $s,c2 as ws,c3 as ks,c4 as xs,c5 as Ms,c6 as Cs,c7 as Ss,c8 as Ps,c9 as Ds,ca as Is,cb as Ls,cc as Ts,cd as Rs,ce as zs,cf as Fs,cg as Ns,ch as As,ci as Es,cj as Os,ck as Hs,cl as Bs,cm as Ws,cn as js,co as Gs,cp as qs,cq as Us,cr as Ks,cs as Vs,ct as Js,cu as Zs,cv as Ys,cw as Xs,cx as Qs,cy as ti,cz as ei,cA as si,cB as ii,cC as oi,cD as ai,cE as ni,cF as ri,cG as li,cH as hi,cI as ci,cJ as di,cK as pi,cL as ui,cM as _i,cN as gi,cO as mi,cP as fi,cQ as bi,cR as vi,cS as yi,cT as $i,cU as wi,cV as ki,cW as xi,cX as Mi,cY as Ci,cZ as Si,c_ as Pi,c$ as Di,d0 as Ii,d1 as Li,d2 as Ti,d3 as Ri,d4 as zi,d5 as Fi,d6 as Ni,d7 as Ai,d8 as Ei,d9 as Oi,da as Hi,db as Bi,dc as Wi,dd as ji,de as Gi,df as qi,dg as Ui,dh as Ki,di as Vi,dj as Ji,dk as Zi,dl as Yi,dm as Xi,dn as Qi,dp as to,dq as eo,dr as so,ds as io,dt as oo,du as ao,dv as no,dw as ro,dx as lo,dy as ho,dz as co,dA as po,dB as uo,dC as _o,dD as go,dE as mo,dF as fo}from"./houseplan-card-BiUNLHFh.js";import{c as bo,f as vo,C as yo}from"./form-kit.styles-BQTkV2m1.js";import{F as $o,f as wo,p as ko,c as xo,e as Mo,r as Co,a as So,s as Po}from"./backdrop-pick-Ev52LRir.js";import{t as Do,h as Io,m as Lo,T as To}from"./zigbee-topology-B31-i8CL.js";import{GENERATED_FURNITURE_ART as Ro,FURNITURE_ART_FINGERPRINT as zo}from"./furniture-plan-art.generated-O7K1vBfu.js";const Fo={},No=t(class extends e{constructor(){super(...arguments),this.ot=Fo}render(t,e){return e()}update(t,[e,i]){if(Array.isArray(e)){if(Array.isArray(this.ot)&&this.ot.length===e.length&&e.every((t,e)=>t===this.ot[e]))return s}else if(this.ot===e)return s;return this.ot=Array.isArray(e)?Array.from(e):e,this.render(e,i)}});var Ao={"gs.show_room_tooltip":"Show the room information window on hover","support.about_group":"About the card","support.guide_group":"Documentation","support.guide":"User guide","support.form_group":"Send a report or suggestion","support.contact":"Contact details (email/tg/WhatsApp), optional.","support.message":"Message","support.attach":"Attach anonymized information from your plan","support.attach_hint":"Includes only allowed plan geometry, settings and bounded runtime facts. Excludes names, Home Assistant IDs, live states, URLs, files, and your message/contact.","support.geometry_warning":"The package contains no names or Home Assistant IDs, but it does contain the exact geometry and dimensions of your home.","support.close_busy_title":"Stop the current operation?","support.close_busy_body":"House Plan is preparing or sending the report. Closing now stops waiting for the result.","support.building":"Preparing anonymized data…","support.preview_summary":"Package v{version} · {spaces} spaces · {size} KiB","support.prepared":"Snapshot prepared {n} min ago","support.show_data":"Show data","support.download":"Download JSON","support.refresh":"Refresh snapshot","support.privacy":"When you send, your message, optional contact and, if selected, exact geometry leave your Home Assistant through the House Plan project relay and are visible to maintainers. The project node keeps the report for up to 30 days. Network infrastructure sees your HA server address, but House Plan does not retain it raw; rate-limit and idempotency metadata is kept for up to 24 hours.","support.error_title":"The report was not sent","support.manual_recovery":"You can keep the message and attachment and continue manually:","support.copy_message":"Copy message","support.success":"Report sent: {id}. Save this number when contacting support.","support.copy_id":"Copy ID","support.sending":"Sending…","support.retry":"Retry","support.send":"Send","support.update_required":"Update the House Plan card and integration to compatible versions to send reports.","support.message_copied":"Message copied","support.id_copied":"Report ID copied","support.copy_failed":"Could not access the clipboard. Select and copy the text manually.","support.validation.message_required":"Enter a message.","support.validation.message_too_long":"The message must contain no more than 10,000 characters.","support.validation.contact_too_long":"Contact details must contain no more than 320 characters.","support.validation.preview_missing":"Wait for the attachment preview or turn the attachment off.","support.validation.preview_expired":"The attachment preview expired. Refresh the snapshot.","support.error.support_invalid_message":"Check the message and try again.","support.error.support_preview_expired":"The attachment preview expired or is no longer available. Refresh the snapshot.","support.error.support_package_too_large":"The anonymized package exceeds the 8 MiB limit.","support.error.support_rate_limited":"Too many reports or previews were requested. Try again later.","support.error.support_unavailable":"The private support service is temporarily unavailable. Your draft remains here.","support.error.support_rejected":"The report did not pass the support service validation.","support.error.unauthorized":"You do not have permission to send this report.","vac.routes_section":"Maps and floors","vac.routes_current_map":"Current map","vac.routes_no_map":"no telemetry","vac.routes_status":"Routing","vac.routes_state_ready":"map assigned and calibrated","vac.routes_state_needs_calibration":"map assigned, calibration needed","vac.routes_state_unmapped":"current map is not assigned to a floor","vac.routes_state_ambiguous":"two maps are indistinguishable — no floor is chosen","vac.routes_state_missing_space":"the map's space was deleted","vac.routes_state_none":"no map data","vac.routes_empty":"No map is assigned to a floor yet.","vac.route_map_default":"no map id","vac.route_active":"Active","vac.route_space":"Space","vac.route_space_none":"not selected","vac.route_status_ready":"ready","vac.route_status_needs_calibration":"needs calibration","vac.route_status_ambiguous":"ambiguous","vac.route_status_missing_space":"space deleted","vac.route_missing_space_group":"Deleted space","vac.route_add_current":"Add current map","vac.route_delete":"Remove map","vac.route_delete_title":"Remove the map from its floor?","vac.route_delete_body":"Calibration and saved paths for this map will be removed. Continue?","vac.route_delete_confirm":"Remove","vac.route_space_title":"Move the map to another space?","vac.route_space_body":"Calibration and saved paths for this map will be removed. Continue?","vac.route_space_confirm":"Move","vac.route_missing_space_hint":"One of the maps points at a deleted space: pick a new one or remove the map. Until then the robot is not drawn for that map.","vac.route_default_hint":"The source reports no stable map id. Several floors cannot be told apart without another source or the robot's own selected map.","vac.route_target_hint":"The dock stays in the “{space}” space regardless of the current map.","vac.route_add_source":"Add a map source","vac.route_add_source_hint":"For integrations that give each map its own camera. The “All cameras” section above widens this list.","vac.route_source_no_map":"no map reported"};const Eo={en:Ao,ru:{"gs.show_room_tooltip":"Показывать окно с информацией при наведении на комнату","support.about_group":"О карточке","support.guide_group":"Документация","support.guide":"Руководство пользователя","support.form_group":"Отправить репорт или предложение","support.contact":"Контакт для связи (email/tg/WhatsApp), необязательно.","support.message":"Сообщение","support.attach":"Прикрепить обезличенную информацию из вашего плана","support.attach_hint":"В пакет входят только разрешённые геометрия, настройки и ограниченные сведения о среде. Не входят имена, HA id, текущие состояния, URL, файлы, сообщение и контакт.","support.geometry_warning":"Пакет не содержит имён и HA id, но содержит точную геометрию и размеры дома.","support.close_busy_title":"Прервать текущую операцию?","support.close_busy_body":"House Plan подготавливает или отправляет репорт. При закрытии ожидание результата прекратится.","support.building":"Подготавливаем обезличенные данные…","support.preview_summary":"Пакет v{version} · пространств: {spaces} · {size} КиБ","support.prepared":"Снимок подготовлен {n} мин назад","support.show_data":"Показать данные","support.download":"Скачать JSON","support.refresh":"Обновить снимок","support.privacy":"При отправке сообщение, необязательный контакт и, если выбран пакет, точная геометрия покидают ваш Home Assistant через relay проекта House Plan и доступны мейнтейнерам. Узел проекта хранит репорт до 30 дней. Сетевая инфраструктура видит адрес сервера HA, но House Plan не сохраняет его в исходном виде; метаданные лимитов и идемпотентности хранятся до 24 часов.","support.error_title":"Репорт не отправлен","support.manual_recovery":"Сообщение и вложение можно сохранить и продолжить вручную:","support.copy_message":"Копировать сообщение","support.success":"Репорт отправлен: {id}. Сохраните номер для связи с поддержкой.","support.copy_id":"Копировать ID","support.sending":"Отправляем…","support.retry":"Повторить","support.send":"Отправить","support.update_required":"Обновите карточку и интеграцию House Plan до совместимых версий, чтобы отправлять репорты.","support.message_copied":"Сообщение скопировано","support.id_copied":"ID репорта скопирован","support.copy_failed":"Не удалось получить доступ к буферу обмена. Выделите и скопируйте текст вручную.","support.validation.message_required":"Введите сообщение.","support.validation.message_too_long":"Сообщение должно содержать не более 10 000 символов.","support.validation.contact_too_long":"Контакт должен содержать не более 320 символов.","support.validation.preview_missing":"Дождитесь предпросмотра вложения или отключите его.","support.validation.preview_expired":"Предпросмотр вложения истёк. Обновите снимок.","support.error.support_invalid_message":"Проверьте сообщение и повторите попытку.","support.error.support_preview_expired":"Предпросмотр вложения истёк или больше недоступен. Обновите снимок.","support.error.support_package_too_large":"Обезличенный пакет превышает лимит 8 МиБ.","support.error.support_rate_limited":"Запрошено слишком много репортов или предпросмотров. Повторите позже.","support.error.support_unavailable":"Закрытая служба поддержки временно недоступна. Черновик сохранён в этом окне.","support.error.support_rejected":"Репорт не прошёл проверку службы поддержки.","support.error.unauthorized":"У вас нет прав на отправку этого репорта.","vac.routes_section":"Карты и этажи","vac.routes_current_map":"Текущая карта","vac.routes_no_map":"источник молчит","vac.routes_status":"Маршрутизация","vac.routes_state_ready":"карта сопоставлена и откалибрована","vac.routes_state_needs_calibration":"карта сопоставлена, нужна калибровка","vac.routes_state_unmapped":"текущая карта не сопоставлена этажу","vac.routes_state_ambiguous":"две карты неразличимы — этаж не выбирается","vac.routes_state_missing_space":"пространство карты удалено","vac.routes_state_none":"нет данных о карте","vac.routes_empty":"Ни одна карта ещё не сопоставлена этажу.","vac.route_map_default":"без идентификатора","vac.route_active":"Текущая","vac.route_space":"Пространство","vac.route_space_none":"не выбрано","vac.route_status_ready":"готова","vac.route_status_needs_calibration":"нужна калибровка","vac.route_status_ambiguous":"неоднозначна","vac.route_status_missing_space":"пространство удалено","vac.route_missing_space_group":"Пространство удалено","vac.route_add_current":"Добавить текущую карту","vac.route_delete":"Удалить карту","vac.route_delete_title":"Удалить карту с этажа?","vac.route_delete_body":"Калибровка и сохранённые пути этой карты будут удалены. Продолжить?","vac.route_delete_confirm":"Удалить","vac.route_space_title":"Перенести карту в другое пространство?","vac.route_space_body":"Калибровка и сохранённые пути этой карты будут удалены. Продолжить?","vac.route_space_confirm":"Перенести","vac.route_missing_space_hint":"Одна из карт ссылается на удалённое пространство: выберите новое или удалите карту. Пока ссылка не исправлена, робот на этой карте не рисуется.","vac.route_default_hint":"Источник не сообщает стабильный идентификатор карты. Несколько этажей нельзя различить без другого источника или собственной карты робота.","vac.route_target_hint":"Док остаётся в пространстве «{space}» независимо от текущей карты.","vac.route_add_source":"Добавить источник карты","vac.route_add_source_hint":"Для интеграций, где у каждой карты своя камера. Список расширяется разделом «Все камеры» выше.","vac.route_source_no_map":"карта не читается"},de:{"gs.show_room_tooltip":"Rauminformationen beim Darüberfahren anzeigen","support.about_group":"Über die Karte","support.guide_group":"Dokumentation","support.guide":"Benutzerhandbuch","support.form_group":"Bericht oder Vorschlag senden","support.contact":"Kontakt (E-Mail/tg/WhatsApp), optional.","support.message":"Nachricht","support.attach":"Anonymisierte Informationen aus dem Plan anhängen","support.attach_hint":"Enthält nur erlaubte Plangeometrie, Einstellungen und begrenzte Laufzeitdaten. Namen, Home-Assistant-IDs, Live-Zustände, URLs, Dateien, Nachricht und Kontakt werden ausgeschlossen.","support.geometry_warning":"Das Paket enthält keine Namen oder Home-Assistant-IDs, aber die exakte Geometrie und die Maße Ihres Hauses.","support.close_busy_title":"Aktuellen Vorgang abbrechen?","support.close_busy_body":"House Plan bereitet den Bericht vor oder sendet ihn. Beim Schließen wird nicht weiter auf das Ergebnis gewartet.","support.building":"Anonymisierte Daten werden vorbereitet…","support.preview_summary":"Paket v{version} · {spaces} Bereiche · {size} KiB","support.prepared":"Schnappschuss vor {n} Min. erstellt","support.show_data":"Daten anzeigen","support.download":"JSON herunterladen","support.refresh":"Schnappschuss aktualisieren","support.privacy":"Beim Senden verlassen Ihre Nachricht, der optionale Kontakt und, falls ausgewählt, die exakte Geometrie Ihren Home Assistant über das House-Plan-Projektrelay und sind für die Maintainer sichtbar. Der Projektserver speichert den Bericht bis zu 30 Tage. Die Netzwerkinfrastruktur sieht die Adresse Ihres HA-Servers, House Plan speichert sie jedoch nicht im Rohformat; Limit- und Idempotenzdaten bleiben bis zu 24 Stunden erhalten.","support.error_title":"Der Bericht wurde nicht gesendet","support.manual_recovery":"Nachricht und Anhang können gespeichert und manuell weitergegeben werden:","support.copy_message":"Nachricht kopieren","support.success":"Bericht gesendet: {id}. Bewahren Sie diese Nummer für den Support auf.","support.copy_id":"ID kopieren","support.sending":"Wird gesendet…","support.retry":"Erneut versuchen","support.send":"Senden","support.update_required":"Aktualisieren Sie House-Plan-Karte und Integration auf kompatible Versionen, um Berichte zu senden.","support.message_copied":"Nachricht kopiert","support.id_copied":"Berichts-ID kopiert","support.copy_failed":"Kein Zugriff auf die Zwischenablage. Markieren und kopieren Sie den Text manuell.","support.validation.message_required":"Geben Sie eine Nachricht ein.","support.validation.message_too_long":"Die Nachricht darf höchstens 10.000 Zeichen enthalten.","support.validation.contact_too_long":"Der Kontakt darf höchstens 320 Zeichen enthalten.","support.validation.preview_missing":"Warten Sie auf die Vorschau oder deaktivieren Sie den Anhang.","support.validation.preview_expired":"Die Anhangsvorschau ist abgelaufen. Aktualisieren Sie den Schnappschuss.","support.error.support_invalid_message":"Prüfen Sie die Nachricht und versuchen Sie es erneut.","support.error.support_preview_expired":"Die Anhangsvorschau ist abgelaufen oder nicht mehr verfügbar. Aktualisieren Sie den Schnappschuss.","support.error.support_package_too_large":"Das anonymisierte Paket überschreitet das Limit von 8 MiB.","support.error.support_rate_limited":"Zu viele Berichte oder Vorschauen wurden angefordert. Versuchen Sie es später erneut.","support.error.support_unavailable":"Der private Supportdienst ist vorübergehend nicht verfügbar. Der Entwurf bleibt in diesem Fenster erhalten.","support.error.support_rejected":"Der Bericht hat die Prüfung des Supportdienstes nicht bestanden.","support.error.unauthorized":"Sie dürfen diesen Bericht nicht senden.","vac.routes_section":"Karten und Etagen","vac.routes_current_map":"Aktuelle Karte","vac.routes_no_map":"keine Telemetrie","vac.routes_status":"Zuordnung","vac.routes_state_ready":"Karte zugeordnet und kalibriert","vac.routes_state_needs_calibration":"Karte zugeordnet, Kalibrierung nötig","vac.routes_state_unmapped":"aktuelle Karte keiner Etage zugeordnet","vac.routes_state_ambiguous":"zwei Karten nicht unterscheidbar — keine Etage gewählt","vac.routes_state_missing_space":"der Raum der Karte wurde gelöscht","vac.routes_state_none":"keine Kartendaten","vac.routes_empty":"Noch keine Karte einer Etage zugeordnet.","vac.route_map_default":"ohne Karten-ID","vac.route_active":"Aktiv","vac.route_space":"Raum","vac.route_space_none":"nicht gewählt","vac.route_status_ready":"bereit","vac.route_status_needs_calibration":"Kalibrierung nötig","vac.route_status_ambiguous":"mehrdeutig","vac.route_status_missing_space":"Raum gelöscht","vac.route_missing_space_group":"Gelöschter Bereich","vac.route_add_current":"Aktuelle Karte hinzufügen","vac.route_delete":"Karte entfernen","vac.route_delete_title":"Karte von der Etage entfernen?","vac.route_delete_body":"Kalibrierung und gespeicherte Pfade dieser Karte werden entfernt. Fortfahren?","vac.route_delete_confirm":"Entfernen","vac.route_space_title":"Karte in einen anderen Raum verschieben?","vac.route_space_body":"Kalibrierung und gespeicherte Pfade dieser Karte werden entfernt. Fortfahren?","vac.route_space_confirm":"Verschieben","vac.route_missing_space_hint":"Eine Karte verweist auf einen gelöschten Raum: neuen wählen oder Karte entfernen. Bis dahin wird der Roboter für diese Karte nicht gezeichnet.","vac.route_default_hint":"Die Quelle meldet keine stabile Karten-ID. Mehrere Etagen lassen sich ohne andere Quelle oder die vom Roboter gewählte Karte nicht unterscheiden.","vac.route_target_hint":"Die Station bleibt unabhängig von der aktuellen Karte im Raum „{space}“.","vac.route_add_source":"Kartenquelle hinzufügen","vac.route_add_source_hint":"Für Integrationen, die jeder Karte eine eigene Kamera geben. Der Abschnitt „Alle Kameras“ oben erweitert diese Liste.","vac.route_source_no_map":"keine Karte gemeldet"},fr:{"gs.show_room_tooltip":"Afficher les informations de la pièce au survol","support.about_group":"À propos de la carte","support.guide_group":"Documentation d’aide","support.guide":"Guide utilisateur","support.form_group":"Envoyer un rapport ou une suggestion","support.contact":"Contact (e-mail/tg/WhatsApp), facultatif.","support.message":"Votre message","support.attach":"Joindre des informations anonymisées de votre plan","support.attach_hint":"Inclut uniquement la géométrie, les réglages autorisés et des données d’exécution limitées. Exclut les noms, identifiants Home Assistant, états en direct, URL, fichiers, message et contact.","support.geometry_warning":"Le paquet ne contient ni noms ni identifiants Home Assistant, mais il contient la géométrie et les dimensions exactes de votre logement.","support.close_busy_title":"Interrompre l’opération en cours ?","support.close_busy_body":"House Plan prépare ou envoie le rapport. Fermer maintenant arrête l’attente du résultat.","support.building":"Préparation des données anonymisées…","support.preview_summary":"Paquet v{version} · {spaces} espaces · {size} Kio","support.prepared":"Instantané préparé il y a {n} min","support.show_data":"Afficher les données","support.download":"Télécharger le JSON","support.refresh":"Actualiser l’instantané","support.privacy":"Lors de l’envoi, votre message, le contact facultatif et, si elle est sélectionnée, la géométrie exacte quittent votre Home Assistant via le relais du projet House Plan et sont visibles par les mainteneurs. Le serveur du projet conserve le rapport jusqu’à 30 jours. L’infrastructure réseau voit l’adresse de votre serveur HA, mais House Plan ne la conserve pas en clair ; les métadonnées de limitation et d’idempotence sont gardées jusqu’à 24 heures.","support.error_title":"Le rapport n’a pas été envoyé","support.manual_recovery":"Vous pouvez conserver le message et la pièce jointe puis continuer manuellement :","support.copy_message":"Copier le message","support.success":"Rapport envoyé : {id}. Conservez ce numéro pour contacter l’assistance.","support.copy_id":"Copier l’ID","support.sending":"Envoi…","support.retry":"Réessayer","support.send":"Envoyer","support.update_required":"Mettez à jour la carte et l’intégration House Plan vers des versions compatibles pour envoyer des rapports.","support.message_copied":"Message copié","support.id_copied":"ID du rapport copié","support.copy_failed":"Impossible d’accéder au presse-papiers. Sélectionnez et copiez le texte manuellement.","support.validation.message_required":"Saisissez un message.","support.validation.message_too_long":"Le message ne doit pas dépasser 10 000 caractères.","support.validation.contact_too_long":"Le contact ne doit pas dépasser 320 caractères.","support.validation.preview_missing":"Attendez l’aperçu de la pièce jointe ou désactivez-la.","support.validation.preview_expired":"L’aperçu de la pièce jointe a expiré. Actualisez l’instantané.","support.error.support_invalid_message":"Vérifiez le message et réessayez.","support.error.support_preview_expired":"L’aperçu de la pièce jointe a expiré ou n’est plus disponible. Actualisez l’instantané.","support.error.support_package_too_large":"Le paquet anonymisé dépasse la limite de 8 Mio.","support.error.support_rate_limited":"Trop de rapports ou d’aperçus ont été demandés. Réessayez plus tard.","support.error.support_unavailable":"Le service d’assistance privé est temporairement indisponible. Le brouillon reste dans cette fenêtre.","support.error.support_rejected":"Le rapport n’a pas passé la validation du service d’assistance.","support.error.unauthorized":"Vous n’êtes pas autorisé à envoyer ce rapport.","vac.routes_section":"Cartes et étages","vac.routes_current_map":"Carte actuelle","vac.routes_no_map":"aucune télémétrie","vac.routes_status":"Routage","vac.routes_state_ready":"carte assignée et calibrée","vac.routes_state_needs_calibration":"carte assignée, calibrage requis","vac.routes_state_unmapped":"carte actuelle non assignée à un étage","vac.routes_state_ambiguous":"deux cartes indiscernables — aucun étage choisi","vac.routes_state_missing_space":"l'espace de la carte a été supprimé","vac.routes_state_none":"aucune donnée de carte","vac.routes_empty":"Aucune carte n'est encore assignée à un étage.","vac.route_map_default":"sans identifiant","vac.route_active":"Active","vac.route_space":"Espace","vac.route_space_none":"non sélectionné","vac.route_status_ready":"prête","vac.route_status_needs_calibration":"calibrage requis","vac.route_status_ambiguous":"ambiguë","vac.route_status_missing_space":"espace supprimé","vac.route_missing_space_group":"Espace supprimé","vac.route_add_current":"Ajouter la carte actuelle","vac.route_delete":"Supprimer la carte","vac.route_delete_title":"Retirer la carte de son étage ?","vac.route_delete_body":"Le calibrage et les trajets enregistrés de cette carte seront supprimés. Continuer ?","vac.route_delete_confirm":"Supprimer","vac.route_space_title":"Déplacer la carte vers un autre espace ?","vac.route_space_body":"Le calibrage et les trajets enregistrés de cette carte seront supprimés. Continuer ?","vac.route_space_confirm":"Déplacer","vac.route_missing_space_hint":"Une carte pointe vers un espace supprimé : choisissez-en un autre ou supprimez la carte. D'ici là, le robot n'est pas dessiné pour cette carte.","vac.route_default_hint":"La source ne fournit pas d'identifiant de carte stable. Plusieurs étages ne peuvent pas être distingués sans une autre source ou la carte sélectionnée du robot.","vac.route_target_hint":"La station reste dans l'espace « {space} » quelle que soit la carte actuelle.","vac.route_add_source":"Ajouter une source de carte","vac.route_add_source_hint":"Pour les intégrations qui donnent à chaque carte sa propre caméra. La section « Toutes les caméras » ci-dessus élargit cette liste.","vac.route_source_no_map":"aucune carte signalée"}};function Oo(t,e,s){return i(Eo[t]?.[e]??Ao[e]??e,s)}function Ho(t,e,s,i,o){return{markerId:t,source:i,mapId:o,space:e.length?"":s}}function Bo(t,e,s){return{...t,space:s.has(e)?e:""}}function Wo(t,e=Math.random){const s=new Set(t);for(let t=0;t<64;t+=1){const t="vr_"+Math.floor(16777215*e()).toString(36).padStart(5,"0");if(!s.has(t))return t}return"vr_"+Date.now().toString(36)}function jo(t,e,s){return t.map(t=>t.id===e?{...t,calibration:s}:t)}const Go=new WeakMap,qo=(t,e)=>{const s=(t._serverCfg?.spaces||[]).find(t=>t?.id===e);return String(s?.name||s?.id||e)};function Uo(t,e,s){const i=t.host,n=l(i.hass,i._config?.language),r=(t,e)=>Oo(n,t,e),u=e.marker?.vacuum||{},_=Array.isArray(u.map_routes),g=i._vacSource(e)||"",m=o(e.id,u,e.space,g),f=(i._serverCfg?.spaces||[]).filter(t=>"string"==typeof t?.id&&!!t.id).map(t=>({id:t.id,name:String(t.name||t.id)})),b=new Set(f.map(t=>t.id)),v=h(m,[g],t=>i._vacObservedMapId(e,t)),y=c({routes:m,observed:v,spaceIds:b}),$="ready"===y.kind||"needs_calibration"===y.kind||"missing_space"===y.kind?y.route.id:"",w=g?v[g]:void 0,k=async s=>{let o=_?u.map_routes??null:null;if(!o&&(o=function(t,e,s,i){if(!s)return null;const o=t?.calibration;if(!o||"object"!=typeof o)return null;const n=new Set,r=[];for(const t of Object.keys(o)){const l=a(o[t]);if(!l)continue;const h=i(n);n.add(h),r.push({id:h,source:s,map_id:t,space:e,calibration:l})}return r.length?r:null}(u,e.space,g,t=>Wo(t))??[],!g&&Object.keys(u.calibration||{}).length))return!1;const n=s(o);return!!n&&(async s=>{const o=i._serverCfg;if(!o)return!1;const a=JSON.parse(JSON.stringify(o));a.markers=a.markers||[];let n=a.markers.find(t=>t.id===e.id);if(!n){if("device"!==e.bindingKind&&"entity"!==e.bindingKind||!e.bindingRef)return!1;n={id:e.id,binding:`${e.bindingKind}:${e.bindingRef}`,space:e.space||null,area:e.area||null,hidden:!!e.hidden},a.markers.push(n)}n.vacuum={...n.vacuum||{},map_routes:s},delete n.vacuum.calibration;const r=i._adoption.beginOptimistic(o,a);i._adoption.stageLocalConfig(a),i._regSignature="",i._maybeRebuildDevices(),i.requestUpdate(),i._saveConfigDebounced.pending()&&i._saveConfigDebounced.cancel();try{return await t._saveConfigNow(),!0}catch(t){return i._rollbackOptimistic(r),i._regSignature="",i._maybeRebuildDevices(),i.requestUpdate(),i._showToast(i._t("toast.cfg_save_failed",{err:i._errText(t)})),!1}})(n)},x=s.candidates.filter(t=>t.entityId!==g&&!m.some(e=>e.source===t.entityId)),M=async(t,e)=>{if(!e||e===t.space)return;await i._confirmDanger({key:"vacuum_route_space",kind:"warning",title:r("vac.route_space_title"),message:r("vac.route_space_body"),objectName:t.map_id||r("vac.route_map_default"),confirmLabel:r("vac.route_space_confirm"),cancelLabel:i._t("btn.cancel")})&&await k(s=>function(t,e,s,i){return t.map(t=>t.id===e?{...t,id:i,space:s,calibration:null}:t)}(s,t.id,e,Wo(new Set(m.map(t=>t.id)))))},C=new Map(f.map((t,e)=>[t.id,e])),S=(t,e)=>t.map_id.localeCompare(e.map_id)||t.source.localeCompare(e.source)||t.id.localeCompare(e.id),P=m.filter(t=>b.has(t.space)).sort((t,e)=>(C.get(t.space)??0)-(C.get(e.space)??0)||S(t,e)),D=m.filter(t=>!b.has(t.space)).sort(S),I=[...P,...D],L=!!g&&void 0!==w&&!m.some(t=>t.source===g&&t.map_id===w);let T=Go.get(t);const R=T?.source||"",z=T?.mapId||"",F=!!T&&m.some(t=>t.source===R&&t.map_id===z);T&&(T.markerId!==e.id||i._vacObservedMapId(e,T.source)!==T.mapId||F&&!T.saving)&&(Go.delete(t),T=void 0),T?.space&&!b.has(T.space)&&(T=Bo(T,"",b),Go.set(t,T));const N=s=>p` +globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="d31b0b1e184ab2863684b758f839bdb6809a33cc742c6e9bb36c5ea034e3d309";import{e as t,i as e,E as s,s as i,a as o,n as a,f as n,b as r,l,o as h,r as c,A as d,c as p,d as u,g as _,h as g,v as m,j as f,k as b,m as v,p as y,q as $,t as w,u as k,w as x,x as M,T as C,y as S,D as P,z as D,B as I,C as L,F as T,G as R,H as z,I as F,J as N,K as A,L as E,M as O,N as H,O as B,P as W,Q as j,R as G,S as q,U,V as K,W as V,X as J,Y as Z,Z as Y,_ as X,$ as Q,a0 as tt,a1 as et,a2 as st,a3 as it,a4 as ot,a5 as at,a6 as nt,a7 as rt,a8 as lt,a9 as ht,aa as ct,ab as dt,ac as pt,ad as ut,ae as _t,af as gt,ag as mt,ah as ft,ai as bt,aj as vt,ak as yt,al as $t,am as wt,an as kt,ao as xt,ap as Mt,aq as Ct,ar as St,as as Pt,at as Dt,au as It,av as Lt,aw as Tt,ax as Rt,ay as zt,az as Ft,aA as Nt,aB as At,aC as Et,aD as Ot,aE as Ht,aF as Bt,aG as Wt,aH as jt,aI as Gt,aJ as qt,aK as Ut,aL as Kt,aM as Vt,aN as Jt,aO as Zt,aP as Yt,aQ as Xt,aR as Qt,aS as te,aT as ee,aU as se,aV as ie,aW as oe,aX as ae,aY as ne,aZ as re,a_ as le,a$ as he,b0 as ce,b1 as de,b2 as pe,b3 as ue,b4 as _e,b5 as ge,b6 as me,b7 as fe,b8 as be,b9 as ve,ba as ye,bb as $e,bc as we,bd as ke,be as xe,bf as Me,bg as Ce,bh as Se,bi as Pe,bj as De,bk as Ie,bl as Le,bm as Te,bn as Re,bo as ze,bp as Fe,bq as Ne,br as Ae,bs as Ee,bt as Oe,bu as He,bv as Be,bw as We,bx as je,by as Ge,bz as qe,bA as Ue,bB as Ke,bC as Ve,bD as Je,bE as Ze,bF as Ye,bG as Xe,bH as Qe,bI as ts,bJ as es,bK as ss,bL as is,bM as os,bN as as,bO as ns,bP as rs,bQ as ls,bR as hs,bS as cs,bT as ds,bU as ps,bV as us,bW as _s,bX as gs,bY as ms,bZ as fs,b_ as bs,b$ as vs,c0 as ys,c1 as $s,c2 as ws,c3 as ks,c4 as xs,c5 as Ms,c6 as Cs,c7 as Ss,c8 as Ps,c9 as Ds,ca as Is,cb as Ls,cc as Ts,cd as Rs,ce as zs,cf as Fs,cg as Ns,ch as As,ci as Es,cj as Os,ck as Hs,cl as Bs,cm as Ws,cn as js,co as Gs,cp as qs,cq as Us,cr as Ks,cs as Vs,ct as Js,cu as Zs,cv as Ys,cw as Xs,cx as Qs,cy as ti,cz as ei,cA as si,cB as ii,cC as oi,cD as ai,cE as ni,cF as ri,cG as li,cH as hi,cI as ci,cJ as di,cK as pi,cL as ui,cM as _i,cN as gi,cO as mi,cP as fi,cQ as bi,cR as vi,cS as yi,cT as $i,cU as wi,cV as ki,cW as xi,cX as Mi,cY as Ci,cZ as Si,c_ as Pi,c$ as Di,d0 as Ii,d1 as Li,d2 as Ti,d3 as Ri,d4 as zi,d5 as Fi,d6 as Ni,d7 as Ai,d8 as Ei,d9 as Oi,da as Hi,db as Bi,dc as Wi,dd as ji,de as Gi,df as qi,dg as Ui,dh as Ki,di as Vi,dj as Ji,dk as Zi,dl as Yi,dm as Xi,dn as Qi,dp as to,dq as eo,dr as so,ds as io,dt as oo,du as ao,dv as no,dw as ro,dx as lo,dy as ho,dz as co,dA as po,dB as uo,dC as _o,dD as go,dE as mo,dF as fo}from"./houseplan-card-W9mG3gab.js";import{c as bo,f as vo,C as yo}from"./form-kit.styles-BSWYQ2Fp.js";import{F as $o,f as wo,p as ko,c as xo,e as Mo,r as Co,a as So,s as Po}from"./backdrop-pick-ToIYfsVt.js";import{t as Do,h as Io,m as Lo,T as To}from"./zigbee-topology-3KJks91U.js";import{GENERATED_FURNITURE_ART as Ro,FURNITURE_ART_FINGERPRINT as zo}from"./furniture-plan-art.generated-B9qZ5DM-.js";const Fo={},No=t(class extends e{constructor(){super(...arguments),this.ot=Fo}render(t,e){return e()}update(t,[e,i]){if(Array.isArray(e)){if(Array.isArray(this.ot)&&this.ot.length===e.length&&e.every((t,e)=>t===this.ot[e]))return s}else if(this.ot===e)return s;return this.ot=Array.isArray(e)?Array.from(e):e,this.render(e,i)}});var Ao={"gs.show_room_tooltip":"Show the room information window on hover","support.about_group":"About the card","support.guide_group":"Documentation","support.guide":"User guide","support.form_group":"Send a report or suggestion","support.contact":"Contact details (email/tg/WhatsApp), optional.","support.message":"Message","support.attach":"Attach anonymized information from your plan","support.attach_hint":"Includes only allowed plan geometry, settings and bounded runtime facts. Excludes names, Home Assistant IDs, live states, URLs, files, and your message/contact.","support.geometry_warning":"The package contains no names or Home Assistant IDs, but it does contain the exact geometry and dimensions of your home.","support.close_busy_title":"Stop the current operation?","support.close_busy_body":"House Plan is preparing or sending the report. Closing now stops waiting for the result.","support.building":"Preparing anonymized data…","support.preview_summary":"Package v{version} · {spaces} spaces · {size} KiB","support.prepared":"Snapshot prepared {n} min ago","support.show_data":"Show data","support.download":"Download JSON","support.refresh":"Refresh snapshot","support.privacy":"When you send, your message, optional contact and, if selected, exact geometry leave your Home Assistant through the House Plan project relay and are visible to maintainers. The project node keeps the report for up to 30 days. Network infrastructure sees your HA server address, but House Plan does not retain it raw; rate-limit and idempotency metadata is kept for up to 24 hours.","support.error_title":"The report was not sent","support.manual_recovery":"You can keep the message and attachment and continue manually:","support.copy_message":"Copy message","support.success":"Report sent: {id}. Save this number when contacting support.","support.copy_id":"Copy ID","support.sending":"Sending…","support.retry":"Retry","support.send":"Send","support.update_required":"Update the House Plan card and integration to compatible versions to send reports.","support.message_copied":"Message copied","support.id_copied":"Report ID copied","support.copy_failed":"Could not access the clipboard. Select and copy the text manually.","support.validation.message_required":"Enter a message.","support.validation.message_too_long":"The message must contain no more than 10,000 characters.","support.validation.contact_too_long":"Contact details must contain no more than 320 characters.","support.validation.preview_missing":"Wait for the attachment preview or turn the attachment off.","support.validation.preview_expired":"The attachment preview expired. Refresh the snapshot.","support.error.support_invalid_message":"Check the message and try again.","support.error.support_preview_expired":"The attachment preview expired or is no longer available. Refresh the snapshot.","support.error.support_package_too_large":"The anonymized package exceeds the 8 MiB limit.","support.error.support_rate_limited":"Too many reports or previews were requested. Try again later.","support.error.support_unavailable":"The private support service is temporarily unavailable. Your draft remains here.","support.error.support_rejected":"The report did not pass the support service validation.","support.error.unauthorized":"You do not have permission to send this report.","vac.routes_section":"Maps and floors","vac.routes_current_map":"Current map","vac.routes_no_map":"no telemetry","vac.routes_status":"Routing","vac.routes_state_ready":"map assigned and calibrated","vac.routes_state_needs_calibration":"map assigned, calibration needed","vac.routes_state_unmapped":"current map is not assigned to a floor","vac.routes_state_ambiguous":"two maps are indistinguishable — no floor is chosen","vac.routes_state_missing_space":"the map's space was deleted","vac.routes_state_none":"no map data","vac.routes_empty":"No map is assigned to a floor yet.","vac.route_map_default":"no map id","vac.route_active":"Active","vac.route_space":"Space","vac.route_space_none":"not selected","vac.route_status_ready":"ready","vac.route_status_needs_calibration":"needs calibration","vac.route_status_ambiguous":"ambiguous","vac.route_status_missing_space":"space deleted","vac.route_missing_space_group":"Deleted space","vac.route_add_current":"Add current map","vac.route_delete":"Remove map","vac.route_delete_title":"Remove the map from its floor?","vac.route_delete_body":"Calibration and saved paths for this map will be removed. Continue?","vac.route_delete_confirm":"Remove","vac.route_space_title":"Move the map to another space?","vac.route_space_body":"Calibration and saved paths for this map will be removed. Continue?","vac.route_space_confirm":"Move","vac.route_missing_space_hint":"One of the maps points at a deleted space: pick a new one or remove the map. Until then the robot is not drawn for that map.","vac.route_default_hint":"The source reports no stable map id. Several floors cannot be told apart without another source or the robot's own selected map.","vac.route_target_hint":"The dock stays in the “{space}” space regardless of the current map.","vac.route_add_source":"Add a map source","vac.route_add_source_hint":"For integrations that give each map its own camera. The “All cameras” section above widens this list.","vac.route_source_no_map":"no map reported"};const Eo={en:Ao,ru:{"gs.show_room_tooltip":"Показывать окно с информацией при наведении на комнату","support.about_group":"О карточке","support.guide_group":"Документация","support.guide":"Руководство пользователя","support.form_group":"Отправить репорт или предложение","support.contact":"Контакт для связи (email/tg/WhatsApp), необязательно.","support.message":"Сообщение","support.attach":"Прикрепить обезличенную информацию из вашего плана","support.attach_hint":"В пакет входят только разрешённые геометрия, настройки и ограниченные сведения о среде. Не входят имена, HA id, текущие состояния, URL, файлы, сообщение и контакт.","support.geometry_warning":"Пакет не содержит имён и HA id, но содержит точную геометрию и размеры дома.","support.close_busy_title":"Прервать текущую операцию?","support.close_busy_body":"House Plan подготавливает или отправляет репорт. При закрытии ожидание результата прекратится.","support.building":"Подготавливаем обезличенные данные…","support.preview_summary":"Пакет v{version} · пространств: {spaces} · {size} КиБ","support.prepared":"Снимок подготовлен {n} мин назад","support.show_data":"Показать данные","support.download":"Скачать JSON","support.refresh":"Обновить снимок","support.privacy":"При отправке сообщение, необязательный контакт и, если выбран пакет, точная геометрия покидают ваш Home Assistant через relay проекта House Plan и доступны мейнтейнерам. Узел проекта хранит репорт до 30 дней. Сетевая инфраструктура видит адрес сервера HA, но House Plan не сохраняет его в исходном виде; метаданные лимитов и идемпотентности хранятся до 24 часов.","support.error_title":"Репорт не отправлен","support.manual_recovery":"Сообщение и вложение можно сохранить и продолжить вручную:","support.copy_message":"Копировать сообщение","support.success":"Репорт отправлен: {id}. Сохраните номер для связи с поддержкой.","support.copy_id":"Копировать ID","support.sending":"Отправляем…","support.retry":"Повторить","support.send":"Отправить","support.update_required":"Обновите карточку и интеграцию House Plan до совместимых версий, чтобы отправлять репорты.","support.message_copied":"Сообщение скопировано","support.id_copied":"ID репорта скопирован","support.copy_failed":"Не удалось получить доступ к буферу обмена. Выделите и скопируйте текст вручную.","support.validation.message_required":"Введите сообщение.","support.validation.message_too_long":"Сообщение должно содержать не более 10 000 символов.","support.validation.contact_too_long":"Контакт должен содержать не более 320 символов.","support.validation.preview_missing":"Дождитесь предпросмотра вложения или отключите его.","support.validation.preview_expired":"Предпросмотр вложения истёк. Обновите снимок.","support.error.support_invalid_message":"Проверьте сообщение и повторите попытку.","support.error.support_preview_expired":"Предпросмотр вложения истёк или больше недоступен. Обновите снимок.","support.error.support_package_too_large":"Обезличенный пакет превышает лимит 8 МиБ.","support.error.support_rate_limited":"Запрошено слишком много репортов или предпросмотров. Повторите позже.","support.error.support_unavailable":"Закрытая служба поддержки временно недоступна. Черновик сохранён в этом окне.","support.error.support_rejected":"Репорт не прошёл проверку службы поддержки.","support.error.unauthorized":"У вас нет прав на отправку этого репорта.","vac.routes_section":"Карты и этажи","vac.routes_current_map":"Текущая карта","vac.routes_no_map":"источник молчит","vac.routes_status":"Маршрутизация","vac.routes_state_ready":"карта сопоставлена и откалибрована","vac.routes_state_needs_calibration":"карта сопоставлена, нужна калибровка","vac.routes_state_unmapped":"текущая карта не сопоставлена этажу","vac.routes_state_ambiguous":"две карты неразличимы — этаж не выбирается","vac.routes_state_missing_space":"пространство карты удалено","vac.routes_state_none":"нет данных о карте","vac.routes_empty":"Ни одна карта ещё не сопоставлена этажу.","vac.route_map_default":"без идентификатора","vac.route_active":"Текущая","vac.route_space":"Пространство","vac.route_space_none":"не выбрано","vac.route_status_ready":"готова","vac.route_status_needs_calibration":"нужна калибровка","vac.route_status_ambiguous":"неоднозначна","vac.route_status_missing_space":"пространство удалено","vac.route_missing_space_group":"Пространство удалено","vac.route_add_current":"Добавить текущую карту","vac.route_delete":"Удалить карту","vac.route_delete_title":"Удалить карту с этажа?","vac.route_delete_body":"Калибровка и сохранённые пути этой карты будут удалены. Продолжить?","vac.route_delete_confirm":"Удалить","vac.route_space_title":"Перенести карту в другое пространство?","vac.route_space_body":"Калибровка и сохранённые пути этой карты будут удалены. Продолжить?","vac.route_space_confirm":"Перенести","vac.route_missing_space_hint":"Одна из карт ссылается на удалённое пространство: выберите новое или удалите карту. Пока ссылка не исправлена, робот на этой карте не рисуется.","vac.route_default_hint":"Источник не сообщает стабильный идентификатор карты. Несколько этажей нельзя различить без другого источника или собственной карты робота.","vac.route_target_hint":"Док остаётся в пространстве «{space}» независимо от текущей карты.","vac.route_add_source":"Добавить источник карты","vac.route_add_source_hint":"Для интеграций, где у каждой карты своя камера. Список расширяется разделом «Все камеры» выше.","vac.route_source_no_map":"карта не читается"},de:{"gs.show_room_tooltip":"Rauminformationen beim Darüberfahren anzeigen","support.about_group":"Über die Karte","support.guide_group":"Dokumentation","support.guide":"Benutzerhandbuch","support.form_group":"Bericht oder Vorschlag senden","support.contact":"Kontakt (E-Mail/tg/WhatsApp), optional.","support.message":"Nachricht","support.attach":"Anonymisierte Informationen aus dem Plan anhängen","support.attach_hint":"Enthält nur erlaubte Plangeometrie, Einstellungen und begrenzte Laufzeitdaten. Namen, Home-Assistant-IDs, Live-Zustände, URLs, Dateien, Nachricht und Kontakt werden ausgeschlossen.","support.geometry_warning":"Das Paket enthält keine Namen oder Home-Assistant-IDs, aber die exakte Geometrie und die Maße Ihres Hauses.","support.close_busy_title":"Aktuellen Vorgang abbrechen?","support.close_busy_body":"House Plan bereitet den Bericht vor oder sendet ihn. Beim Schließen wird nicht weiter auf das Ergebnis gewartet.","support.building":"Anonymisierte Daten werden vorbereitet…","support.preview_summary":"Paket v{version} · {spaces} Bereiche · {size} KiB","support.prepared":"Schnappschuss vor {n} Min. erstellt","support.show_data":"Daten anzeigen","support.download":"JSON herunterladen","support.refresh":"Schnappschuss aktualisieren","support.privacy":"Beim Senden verlassen Ihre Nachricht, der optionale Kontakt und, falls ausgewählt, die exakte Geometrie Ihren Home Assistant über das House-Plan-Projektrelay und sind für die Maintainer sichtbar. Der Projektserver speichert den Bericht bis zu 30 Tage. Die Netzwerkinfrastruktur sieht die Adresse Ihres HA-Servers, House Plan speichert sie jedoch nicht im Rohformat; Limit- und Idempotenzdaten bleiben bis zu 24 Stunden erhalten.","support.error_title":"Der Bericht wurde nicht gesendet","support.manual_recovery":"Nachricht und Anhang können gespeichert und manuell weitergegeben werden:","support.copy_message":"Nachricht kopieren","support.success":"Bericht gesendet: {id}. Bewahren Sie diese Nummer für den Support auf.","support.copy_id":"ID kopieren","support.sending":"Wird gesendet…","support.retry":"Erneut versuchen","support.send":"Senden","support.update_required":"Aktualisieren Sie House-Plan-Karte und Integration auf kompatible Versionen, um Berichte zu senden.","support.message_copied":"Nachricht kopiert","support.id_copied":"Berichts-ID kopiert","support.copy_failed":"Kein Zugriff auf die Zwischenablage. Markieren und kopieren Sie den Text manuell.","support.validation.message_required":"Geben Sie eine Nachricht ein.","support.validation.message_too_long":"Die Nachricht darf höchstens 10.000 Zeichen enthalten.","support.validation.contact_too_long":"Der Kontakt darf höchstens 320 Zeichen enthalten.","support.validation.preview_missing":"Warten Sie auf die Vorschau oder deaktivieren Sie den Anhang.","support.validation.preview_expired":"Die Anhangsvorschau ist abgelaufen. Aktualisieren Sie den Schnappschuss.","support.error.support_invalid_message":"Prüfen Sie die Nachricht und versuchen Sie es erneut.","support.error.support_preview_expired":"Die Anhangsvorschau ist abgelaufen oder nicht mehr verfügbar. Aktualisieren Sie den Schnappschuss.","support.error.support_package_too_large":"Das anonymisierte Paket überschreitet das Limit von 8 MiB.","support.error.support_rate_limited":"Zu viele Berichte oder Vorschauen wurden angefordert. Versuchen Sie es später erneut.","support.error.support_unavailable":"Der private Supportdienst ist vorübergehend nicht verfügbar. Der Entwurf bleibt in diesem Fenster erhalten.","support.error.support_rejected":"Der Bericht hat die Prüfung des Supportdienstes nicht bestanden.","support.error.unauthorized":"Sie dürfen diesen Bericht nicht senden.","vac.routes_section":"Karten und Etagen","vac.routes_current_map":"Aktuelle Karte","vac.routes_no_map":"keine Telemetrie","vac.routes_status":"Zuordnung","vac.routes_state_ready":"Karte zugeordnet und kalibriert","vac.routes_state_needs_calibration":"Karte zugeordnet, Kalibrierung nötig","vac.routes_state_unmapped":"aktuelle Karte keiner Etage zugeordnet","vac.routes_state_ambiguous":"zwei Karten nicht unterscheidbar — keine Etage gewählt","vac.routes_state_missing_space":"der Raum der Karte wurde gelöscht","vac.routes_state_none":"keine Kartendaten","vac.routes_empty":"Noch keine Karte einer Etage zugeordnet.","vac.route_map_default":"ohne Karten-ID","vac.route_active":"Aktiv","vac.route_space":"Raum","vac.route_space_none":"nicht gewählt","vac.route_status_ready":"bereit","vac.route_status_needs_calibration":"Kalibrierung nötig","vac.route_status_ambiguous":"mehrdeutig","vac.route_status_missing_space":"Raum gelöscht","vac.route_missing_space_group":"Gelöschter Bereich","vac.route_add_current":"Aktuelle Karte hinzufügen","vac.route_delete":"Karte entfernen","vac.route_delete_title":"Karte von der Etage entfernen?","vac.route_delete_body":"Kalibrierung und gespeicherte Pfade dieser Karte werden entfernt. Fortfahren?","vac.route_delete_confirm":"Entfernen","vac.route_space_title":"Karte in einen anderen Raum verschieben?","vac.route_space_body":"Kalibrierung und gespeicherte Pfade dieser Karte werden entfernt. Fortfahren?","vac.route_space_confirm":"Verschieben","vac.route_missing_space_hint":"Eine Karte verweist auf einen gelöschten Raum: neuen wählen oder Karte entfernen. Bis dahin wird der Roboter für diese Karte nicht gezeichnet.","vac.route_default_hint":"Die Quelle meldet keine stabile Karten-ID. Mehrere Etagen lassen sich ohne andere Quelle oder die vom Roboter gewählte Karte nicht unterscheiden.","vac.route_target_hint":"Die Station bleibt unabhängig von der aktuellen Karte im Raum „{space}“.","vac.route_add_source":"Kartenquelle hinzufügen","vac.route_add_source_hint":"Für Integrationen, die jeder Karte eine eigene Kamera geben. Der Abschnitt „Alle Kameras“ oben erweitert diese Liste.","vac.route_source_no_map":"keine Karte gemeldet"},fr:{"gs.show_room_tooltip":"Afficher les informations de la pièce au survol","support.about_group":"À propos de la carte","support.guide_group":"Documentation d’aide","support.guide":"Guide utilisateur","support.form_group":"Envoyer un rapport ou une suggestion","support.contact":"Contact (e-mail/tg/WhatsApp), facultatif.","support.message":"Votre message","support.attach":"Joindre des informations anonymisées de votre plan","support.attach_hint":"Inclut uniquement la géométrie, les réglages autorisés et des données d’exécution limitées. Exclut les noms, identifiants Home Assistant, états en direct, URL, fichiers, message et contact.","support.geometry_warning":"Le paquet ne contient ni noms ni identifiants Home Assistant, mais il contient la géométrie et les dimensions exactes de votre logement.","support.close_busy_title":"Interrompre l’opération en cours ?","support.close_busy_body":"House Plan prépare ou envoie le rapport. Fermer maintenant arrête l’attente du résultat.","support.building":"Préparation des données anonymisées…","support.preview_summary":"Paquet v{version} · {spaces} espaces · {size} Kio","support.prepared":"Instantané préparé il y a {n} min","support.show_data":"Afficher les données","support.download":"Télécharger le JSON","support.refresh":"Actualiser l’instantané","support.privacy":"Lors de l’envoi, votre message, le contact facultatif et, si elle est sélectionnée, la géométrie exacte quittent votre Home Assistant via le relais du projet House Plan et sont visibles par les mainteneurs. Le serveur du projet conserve le rapport jusqu’à 30 jours. L’infrastructure réseau voit l’adresse de votre serveur HA, mais House Plan ne la conserve pas en clair ; les métadonnées de limitation et d’idempotence sont gardées jusqu’à 24 heures.","support.error_title":"Le rapport n’a pas été envoyé","support.manual_recovery":"Vous pouvez conserver le message et la pièce jointe puis continuer manuellement :","support.copy_message":"Copier le message","support.success":"Rapport envoyé : {id}. Conservez ce numéro pour contacter l’assistance.","support.copy_id":"Copier l’ID","support.sending":"Envoi…","support.retry":"Réessayer","support.send":"Envoyer","support.update_required":"Mettez à jour la carte et l’intégration House Plan vers des versions compatibles pour envoyer des rapports.","support.message_copied":"Message copié","support.id_copied":"ID du rapport copié","support.copy_failed":"Impossible d’accéder au presse-papiers. Sélectionnez et copiez le texte manuellement.","support.validation.message_required":"Saisissez un message.","support.validation.message_too_long":"Le message ne doit pas dépasser 10 000 caractères.","support.validation.contact_too_long":"Le contact ne doit pas dépasser 320 caractères.","support.validation.preview_missing":"Attendez l’aperçu de la pièce jointe ou désactivez-la.","support.validation.preview_expired":"L’aperçu de la pièce jointe a expiré. Actualisez l’instantané.","support.error.support_invalid_message":"Vérifiez le message et réessayez.","support.error.support_preview_expired":"L’aperçu de la pièce jointe a expiré ou n’est plus disponible. Actualisez l’instantané.","support.error.support_package_too_large":"Le paquet anonymisé dépasse la limite de 8 Mio.","support.error.support_rate_limited":"Trop de rapports ou d’aperçus ont été demandés. Réessayez plus tard.","support.error.support_unavailable":"Le service d’assistance privé est temporairement indisponible. Le brouillon reste dans cette fenêtre.","support.error.support_rejected":"Le rapport n’a pas passé la validation du service d’assistance.","support.error.unauthorized":"Vous n’êtes pas autorisé à envoyer ce rapport.","vac.routes_section":"Cartes et étages","vac.routes_current_map":"Carte actuelle","vac.routes_no_map":"aucune télémétrie","vac.routes_status":"Routage","vac.routes_state_ready":"carte assignée et calibrée","vac.routes_state_needs_calibration":"carte assignée, calibrage requis","vac.routes_state_unmapped":"carte actuelle non assignée à un étage","vac.routes_state_ambiguous":"deux cartes indiscernables — aucun étage choisi","vac.routes_state_missing_space":"l'espace de la carte a été supprimé","vac.routes_state_none":"aucune donnée de carte","vac.routes_empty":"Aucune carte n'est encore assignée à un étage.","vac.route_map_default":"sans identifiant","vac.route_active":"Active","vac.route_space":"Espace","vac.route_space_none":"non sélectionné","vac.route_status_ready":"prête","vac.route_status_needs_calibration":"calibrage requis","vac.route_status_ambiguous":"ambiguë","vac.route_status_missing_space":"espace supprimé","vac.route_missing_space_group":"Espace supprimé","vac.route_add_current":"Ajouter la carte actuelle","vac.route_delete":"Supprimer la carte","vac.route_delete_title":"Retirer la carte de son étage ?","vac.route_delete_body":"Le calibrage et les trajets enregistrés de cette carte seront supprimés. Continuer ?","vac.route_delete_confirm":"Supprimer","vac.route_space_title":"Déplacer la carte vers un autre espace ?","vac.route_space_body":"Le calibrage et les trajets enregistrés de cette carte seront supprimés. Continuer ?","vac.route_space_confirm":"Déplacer","vac.route_missing_space_hint":"Une carte pointe vers un espace supprimé : choisissez-en un autre ou supprimez la carte. D'ici là, le robot n'est pas dessiné pour cette carte.","vac.route_default_hint":"La source ne fournit pas d'identifiant de carte stable. Plusieurs étages ne peuvent pas être distingués sans une autre source ou la carte sélectionnée du robot.","vac.route_target_hint":"La station reste dans l'espace « {space} » quelle que soit la carte actuelle.","vac.route_add_source":"Ajouter une source de carte","vac.route_add_source_hint":"Pour les intégrations qui donnent à chaque carte sa propre caméra. La section « Toutes les caméras » ci-dessus élargit cette liste.","vac.route_source_no_map":"aucune carte signalée"}};function Oo(t,e,s){return i(Eo[t]?.[e]??Ao[e]??e,s)}function Ho(t,e,s,i,o){return{markerId:t,source:i,mapId:o,space:e.length?"":s}}function Bo(t,e,s){return{...t,space:s.has(e)?e:""}}function Wo(t,e=Math.random){const s=new Set(t);for(let t=0;t<64;t+=1){const t="vr_"+Math.floor(16777215*e()).toString(36).padStart(5,"0");if(!s.has(t))return t}return"vr_"+Date.now().toString(36)}function jo(t,e,s){return t.map(t=>t.id===e?{...t,calibration:s}:t)}const Go=new WeakMap,qo=(t,e)=>{const s=(t._serverCfg?.spaces||[]).find(t=>t?.id===e);return String(s?.name||s?.id||e)};function Uo(t,e,s){const i=t.host,n=l(i.hass,i._config?.language),r=(t,e)=>Oo(n,t,e),u=e.marker?.vacuum||{},_=Array.isArray(u.map_routes),g=i._vacSource(e)||"",m=o(e.id,u,e.space,g),f=(i._serverCfg?.spaces||[]).filter(t=>"string"==typeof t?.id&&!!t.id).map(t=>({id:t.id,name:String(t.name||t.id)})),b=new Set(f.map(t=>t.id)),v=h(m,[g],t=>i._vacObservedMapId(e,t)),y=c({routes:m,observed:v,spaceIds:b}),$="ready"===y.kind||"needs_calibration"===y.kind||"missing_space"===y.kind?y.route.id:"",w=g?v[g]:void 0,k=async s=>{let o=_?u.map_routes??null:null;if(!o&&(o=function(t,e,s,i){if(!s)return null;const o=t?.calibration;if(!o||"object"!=typeof o)return null;const n=new Set,r=[];for(const t of Object.keys(o)){const l=a(o[t]);if(!l)continue;const h=i(n);n.add(h),r.push({id:h,source:s,map_id:t,space:e,calibration:l})}return r.length?r:null}(u,e.space,g,t=>Wo(t))??[],!g&&Object.keys(u.calibration||{}).length))return!1;const n=s(o);return!!n&&(async s=>{const o=i._serverCfg;if(!o)return!1;const a=JSON.parse(JSON.stringify(o));a.markers=a.markers||[];let n=a.markers.find(t=>t.id===e.id);if(!n){if("device"!==e.bindingKind&&"entity"!==e.bindingKind||!e.bindingRef)return!1;n={id:e.id,binding:`${e.bindingKind}:${e.bindingRef}`,space:e.space||null,area:e.area||null,hidden:!!e.hidden},a.markers.push(n)}n.vacuum={...n.vacuum||{},map_routes:s},delete n.vacuum.calibration;const r=i._adoption.beginOptimistic(o,a);i._adoption.stageLocalConfig(a),i._regSignature="",i._maybeRebuildDevices(),i.requestUpdate(),i._saveConfigDebounced.pending()&&i._saveConfigDebounced.cancel();try{return await t._saveConfigNow(),!0}catch(t){return i._rollbackOptimistic(r),i._regSignature="",i._maybeRebuildDevices(),i.requestUpdate(),i._showToast(i._t("toast.cfg_save_failed",{err:i._errText(t)})),!1}})(n)},x=s.candidates.filter(t=>t.entityId!==g&&!m.some(e=>e.source===t.entityId)),M=async(t,e)=>{if(!e||e===t.space)return;await i._confirmDanger({key:"vacuum_route_space",kind:"warning",title:r("vac.route_space_title"),message:r("vac.route_space_body"),objectName:t.map_id||r("vac.route_map_default"),confirmLabel:r("vac.route_space_confirm"),cancelLabel:i._t("btn.cancel")})&&await k(s=>function(t,e,s,i){return t.map(t=>t.id===e?{...t,id:i,space:s,calibration:null}:t)}(s,t.id,e,Wo(new Set(m.map(t=>t.id)))))},C=new Map(f.map((t,e)=>[t.id,e])),S=(t,e)=>t.map_id.localeCompare(e.map_id)||t.source.localeCompare(e.source)||t.id.localeCompare(e.id),P=m.filter(t=>b.has(t.space)).sort((t,e)=>(C.get(t.space)??0)-(C.get(e.space)??0)||S(t,e)),D=m.filter(t=>!b.has(t.space)).sort(S),I=[...P,...D],L=!!g&&void 0!==w&&!m.some(t=>t.source===g&&t.map_id===w);let T=Go.get(t);const R=T?.source||"",z=T?.mapId||"",F=!!T&&m.some(t=>t.source===R&&t.map_id===z);T&&(T.markerId!==e.id||i._vacObservedMapId(e,T.source)!==T.mapId||F&&!T.saving)&&(Go.delete(t),T=void 0),T?.space&&!b.has(T.space)&&(T=Bo(T,"",b),Go.set(t,T));const N=s=>p`
  • ${s.map_id||r("vac.route_map_default")} @@ -81,26 +81,26 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db ${m.some(t=>"default"===t.map_id)?p`
    ${r("vac.route_default_hint")}
    `:d} ${I.length?p`
    ${r("vac.route_target_hint",{space:qo(i,e.space)})}
    `:d} -
    `}const Ko=bo+vo(yo,{withSwitch:!1}),Vo=new WeakSet;let Jo=null;function Zo({title:t,help:e,body:s}){return p`
    +
  • `}const Ko=bo+vo(yo,{withSwitch:!1}),Vo=new WeakSet;let Jo=null;function Zo(t){const e=t.renderRoot;if(!e||Vo.has(e))return;const s=e.ownerDocument??globalThis.document,i=s?.defaultView?.CSSStyleSheet;if(i&&"adoptedStyleSheets"in e)return Jo||(Jo=new i,Jo.replaceSync(Ko)),e.adoptedStyleSheets=[...e.adoptedStyleSheets,Jo],void Vo.add(e);if(e.querySelector("style[data-hp-form-kit]"))return void Vo.add(e);const o=s.createElement("style");o.dataset.hpFormKit="true",o.textContent=Ko,e.appendChild(o),Vo.add(e)}function Yo({title:t,help:e,body:s}){return p`
    ${t?p`

    ${t}

    ${e??d}
    `:d} ${s} -
    `}function Yo({label:t,control:e,action:s}){return p`
    + `}function Xo({label:t,control:e,action:s}){return p`
    ${t} ${e}${s??d} -
    `}function Xo({name:t,value:e,options:s,onChange:i,ariaLabel:o}){return p`
    +
    `}function Qo({name:t,value:e,options:s,onChange:i,ariaLabel:o}){return p`
    ${s.map(s=>p``)} -
    `}function Qo({label:t,picker:e,action:s}){return p`
    +
    `}function ta({label:t,picker:e,action:s}){return p`
    ${t} ${e}${s??d} -
    `}const ta=new Set(["ld2450","hlkld2450","hilinkld2450"]),ea=()=>globalThis.crypto?.randomUUID?.()||`radar_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`,sa=(t,e,s)=>{const i=!!t?.original;return{radar:i?t:null,radarEligible:i,radarTouched:i?e:e||!!t,radarRemove:i?s:s||!!t}},ia=(t,e="")=>"number"==typeof t&&Number.isFinite(t)?String(t):e,oa=t=>Array.from(new Set([...t.allEntities||t.entities||[],..."entity"===t.bindingKind&&t.bindingRef?[t.bindingRef]:[]])).filter(t=>/^[a-z0-9_]+\.[a-z0-9_]+$/.test(t)),aa=(t,e,s)=>{const i=t.split(".",2)[1]||"";return new RegExp(`(?:^|_)target_?${s}_${e}(?:_|$)`).test(i)||new RegExp(`(?:^|_)target_${e}_${s}(?:_|$)`).test(i)};function na(t,e){if(t.marker?.radar&&"object"==typeof t.marker.radar)return u(t.marker.radar)?{eligible:!0,profile:t.marker.radar.profile,reason:"saved"}:{eligible:!0,profile:"presence_v1",reason:"saved_unsupported"};const s="entity"===t.bindingKind?e?.entities?.[t.bindingRef||""]:null,i="device"===t.bindingKind?t.bindingRef:s?.device_id,o=i?e?.devices?.[i]:null,a=oa(t);return ta.has((n=o?.model||t.model,String(n||"").toLowerCase().replace(/[^a-z0-9]/g,"")))&&a.some(t=>aa(t,"x",1))&&a.some(t=>aa(t,"y",1))?{eligible:!0,profile:"esphome_ld2450_v1",reason:"ld2450"}:{eligible:!1,profile:"presence_v1",reason:"none"};var n}function ra(t,e){return t.find(t=>e.some(e=>e.test(t)))||""}function la(t,e,s,i,o=!1){const a=na(t,i),n=u(t.marker?.radar)?t.marker.radar:null;if(!n&&!a.eligible&&!o)return null;const r=n?.profile||a.profile,l=o&&!a.eligible||"ld2450"!==a.reason?{xEntities:["","",""],yEntities:["","",""],distanceEntity:"",angleEntity:"",occupancyEntity:"",countEntity:"",zoneEntity:""}:function(t,e,s){const i=oa(t).filter(t=>!!s?.states?.[t]),o=[],a=[];for(let t=1;t<=3;t++)o.push(i.find(e=>aa(e,"x",t))||""),a.push(i.find(e=>aa(e,"y",t))||"");const n=i.filter(t=>t.startsWith("binary_sensor.")),r=i.filter(t=>t.startsWith("sensor.")),l=ra(n,[/(?:occupancy|presence|target)(?:_|$)/]);return{xEntities:o,yEntities:a,distanceEntity:ra(r,[/(?:target_)?distance(?:_|$)/,/distance/]),angleEntity:ra(r,[/(?:target_)?angle(?:_|$)/,/angle/]),occupancyEntity:l,countEntity:ra(r,[/(?:target|people|presence)_count(?:_|$)/,/target_count/]),zoneEntity:"zones_v1"===e?ra(n,[/(?:zone|region).*(?:occupancy|presence)/,/zone/]):""}}(t,r,i),h=n?.sources||{},c=h.slots||[],d=c.filter(t=>"x_entity"in t),p=c.filter(t=>"distance_entity"in t),_=h.ranges||[],g=h.zones?.[0],m="esphome_ld2450_v1"===r?3:"cartesian_v1"===r?Math.max(1,d.length):"polar_v1"===r?Math.max(1,p.length):1,f=n?.room_id||t.marker?.room_id||e.rooms.find(e=>e.area&&e.area===t.area)?.id||"";return{original:n,enabled:!0===n?.enabled,showLive:!1!==n?.show_live,profile:r,roomId:f,installationId:n?.mount?.installation_id||ea(),mountX:ia(null==n?.mount?.x?void 0:1e3*n.mount.x,ia(s[0],"0")),mountY:ia(null==n?.mount?.y?void 0:1e3*n.mount.y,ia(s[1],"0")),heading:ia(n?.mount?.heading_deg,"0"),rangeCm:ia(n?.mount?.range_cm,"esphome_ld2450_v1"===r?"600":""),fovDeg:ia(n?.mount?.fov_deg,"esphome_ld2450_v1"===r?"120":""),mirror:!0===n?.calibration?.mirror,unit:d[0]?.unit||p[0]?.unit||_[0]?.unit||("esphome_ld2450_v1"===r?"mm":"cm"),xEntities:Array.from({length:m},(t,e)=>d[e]?.x_entity||l.xEntities[e]||""),yEntities:Array.from({length:m},(t,e)=>d[e]?.y_entity||l.yEntities[e]||""),distanceEntities:Array.from({length:m},(t,e)=>p[e]?.distance_entity||(0===e?l.distanceEntity:"")),angleEntities:Array.from({length:m},(t,e)=>p[e]?.angle_entity||(0===e?l.angleEntity:"")),rangeEntities:_.length?_.map(t=>t.entity_id):[l.distanceEntity],slotPresenceEntities:Array.from({length:m},(t,e)=>(d[e]||p[e])?.presence_entity||""),rangePresenceEntities:(_.length?_:[{}]).map(t=>"presence_entity"in t&&t.presence_entity||""),swapXY:Array.from({length:m},(t,e)=>!0===d[e]?.swap_xy),xSigns:Array.from({length:m},(t,e)=>-1===d[e]?.x_sign?-1:1),ySigns:Array.from({length:m},(t,e)=>-1===d[e]?.y_sign?-1:1),angleUnit:p[0]?.angle_unit||"degrees",angleZero:p[0]?.angle_zero||"forward",angleClockwise:!1!==p[0]?.angle_clockwise,occupancyEntity:h.occupancy_entity||l.occupancyEntity,countEntity:h.count_entity||l.countEntity,availabilityEntity:h.availability_entity||"",zoneEntity:g?.entity_id||l.zoneEntity,zoneKind:g?.kind||"occupancy"}}const ha=t=>JSON.stringify(t,(t,e)=>e&&"object"==typeof e&&!Array.isArray(e)?Object.fromEntries(Object.entries(e).sort(([t],[e])=>te?1:0)):e),ca=t=>{if(!t.trim())return null;const e=Number(t.replace(",","."));return Number.isFinite(e)?e:null};function da(t,e){const s=ca(t.mountX),i=ca(t.mountY),o=ca(t.heading);if(!t.roomId||null==s||null==i||null==o)return null;const a={...t.original?.sources||{}};if(delete a.slots,delete a.ranges,delete a.zones,delete a.occupancy_entity,delete a.count_entity,"esphome_ld2450_v1"===t.profile||"cartesian_v1"===t.profile){if(a.slots=t.xEntities.flatMap((e,s)=>{const i=t.yEntities[s]||"";return e&&i?[{id:`target_${s+1}`,x_entity:e,y_entity:i,unit:"esphome_ld2450_v1"===t.profile?"mm":t.unit,..."cartesian_v1"===t.profile&&t.swapXY[s]?{swap_xy:!0}:{},..."cartesian_v1"===t.profile&&-1===t.xSigns[s]?{x_sign:-1}:{},..."cartesian_v1"===t.profile&&-1===t.ySigns[s]?{y_sign:-1}:{},...t.slotPresenceEntities[s]?{presence_entity:t.slotPresenceEntities[s]}:{}}]:[]}),!a.slots.length)return null}else if("polar_v1"===t.profile){if(a.slots=t.distanceEntities.flatMap((e,s)=>{const i=t.angleEntities[s]||"";return e&&i?[{id:`target_${s+1}`,distance_entity:e,angle_entity:i,unit:t.unit,angle_unit:t.angleUnit,angle_zero:t.angleZero,angle_clockwise:t.angleClockwise,...t.slotPresenceEntities[s]?{presence_entity:t.slotPresenceEntities[s]}:{}}]:[]}),!a.slots.length)return null}else if("range_v1"===t.profile){if(a.ranges=t.rangeEntities.flatMap((e,s)=>e?[{id:`range_${s+1}`,entity_id:e,unit:t.unit,...t.rangePresenceEntities[s]?{presence_entity:t.rangePresenceEntities[s]}:{}}]:[]),!a.ranges.length)return null}else if("zones_v1"===t.profile){if(!t.zoneEntity)return null;a.zones=[{id:"zone_1",kind:t.zoneKind,entity_id:t.zoneEntity}]}else if("presence_v1"===t.profile&&!t.occupancyEntity)return null;t.occupancyEntity&&(a.occupancy_entity=t.occupancyEntity),t.countEntity&&(a.count_entity=t.countEntity),t.availabilityEntity&&(a.availability_entity=t.availabilityEntity);const n=ca(t.rangeCm),r=ca(t.fovDeg),l=(o%360+360)%360,h={...t.original?.mount||{},installation_id:t.installationId,x:s/1e3,y:i/1e3,heading_deg:l};null!=n&&n>0?h.range_cm=n:delete h.range_cm,null!=r&&r>0?h.fov_deg=r:delete h.fov_deg;const c=t.original,d="two_point"===c?.calibration?.method&&c.profile===t.profile&&ha(c.sources)===ha(a)&&c.mount.installation_id===t.installationId&&Math.abs(c.mount.x-h.x)<1e-12&&Math.abs(c.mount.y-h.y)<1e-12&&Math.abs(c.mount.heading_deg-l)<1e-9&&c.calibration.mirror===t.mirror&&Math.abs(c.calibration.cell_cm-e)<1e-9,p=t.calibrationOverride?{...t.calibrationOverride}:d?{...c.calibration}:{...c?.calibration||{},method:"zones_v1"===t.profile||"presence_v1"===t.profile?"not_required":"manual",mirror:t.mirror,cell_cm:e};t.calibrationOverride||d||(delete p.refs,delete p.rms_cm);const u={...t.original||{},version:1,enabled:t.enabled,profile:t.profile,sources:a,mount:h,room_id:t.roomId,calibration:p};return t.showLive?delete u.show_live:u.show_live=!1,u}const pa={badge:"display.badge",icon_ripple:"display.icon_ripple",value:"display.value",static_icon:"display.static_icon",value_static_icon:"display.value_static_icon"},ua={badge:"marker.display_hint_badge",icon_ripple:"marker.display_hint_icon_ripple",value:"marker.display_hint_value",static_icon:"marker.display_hint_static_icon",value_static_icon:"marker.display_hint_value_static_icon"};function _a(){const t=this.host._markerDialog,e="virtual"===t.bindingMode,s=this._bindingCandidates();this.host._bindingEntities(t.binding);const i=e?null:this.host._bindingStatus(t.binding),o=!e&&this.host._bindingHasHaPage(t.binding),a=this._markerPreviewDevice(t),n=this._effectiveMarkerTapAction(t,a),r=a?_(this.host._serverCfg?.spaces.find(t=>t.id===a.space)):null,l=a?this._markerPreviewDevices(a):this.host._devices,h="toggle"===n&&a?this._toggleIntent(a,l):null,c=this._toggleHintLines(h),u=a?g(this.host._planHass,a,{liveStates:!1!==this.host._config?.live_states,showTemperature:!1!==this.host._config?.show_temperature,showSignal:r?.showLqi??!1!==this.host._config?.show_signal,designPreview:!0,activityRuntime:this.host._activityRt.get(a.id),lightDevices:l,registryHass:this.host._fullRegistryHass,reducedMotion:this.host._reducedMotion}):null,R=a?m(this.host._planHass,a,l):[],z=a?f(this.host._planHass,a,R):null,F=t.valueBadgeTouched?t.valueBadgeEnabled:!!u?.valueBadge,N=t.valueBadgeTouched?t.valueBadgeSource:u?.valueBadge?.source||t.valueBadgeSource,A=t.valueBadgeTouched?t.valueBadgePosition:u?.valueBadge?.position||t.valueBadgePosition,E=b(N),O=!!N&&!R.some(t=>t.key===E),H=R.find(t=>t.key===E),B=b(t.valueSource),W=!(!t.valueSource||B&&R.some(t=>t.key===B)),j=R.find(t=>t.key===B),G=u?.valueSource?.sourceKey||"",q=this._markerAutoHasSpatialSource(t),U=!!a&&v(this.host._planHass,{...a}),K=y(t.lightRole,q,U,t.glowMode),V=!K.sourceExists,J=!K.fromSourceEnabled,Z=K.passive,Y=K.effectiveMode,X="never"===t.lightRole?this.host._t("marker.glow_disabled_never"):"auto"!==t.lightRole||q?Z?this.host._t("marker.glow_passive_hint"):this.host._t("marker.glow_disabled_no_entity"):this.host._t("marker.glow_disabled_auto"),Q=a?$(a):[],tt=a&&w(a)||"",et=!!t.lightEntity&&!Q.includes(t.lightEntity),st=a?k(a):[],it=!!t.toggleEntity&&!st.includes(t.toggleEntity),ot="toggle"===n?this._toggleIntentForDialog({...t,toggleEntity:"",toggleEntityTouched:!0}):null,at=ot?[...ot.targets,...ot.skippedTargets].map(t=>t.entityId||("ref"in t?t.ref:"")).filter(Boolean).join(", "):"",nt=(()=>{if(e)return null;const i=s.find(e=>e.value===t.binding);if(i)return i.label;const[o,a]=t.binding.split(":");return"device"===o?this.host._fullRegistryHass.devices[a]?.name_by_user||this.host._fullRegistryHass.devices[a]?.name||a:this.host._fullRegistryHass.entities[a]?.name||this.host.hass.states[a]?.attributes?.friendly_name||a})();return p``}const ea=new Set(["ld2450","hlkld2450","hilinkld2450"]),sa=()=>globalThis.crypto?.randomUUID?.()||`radar_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`,ia=(t,e,s)=>{const i=!!t?.original;return{radar:i?t:null,radarEligible:i,radarTouched:i?e:e||!!t,radarRemove:i?s:s||!!t}},oa=(t,e="")=>"number"==typeof t&&Number.isFinite(t)?String(t):e,aa=t=>Array.from(new Set([...t.allEntities||t.entities||[],..."entity"===t.bindingKind&&t.bindingRef?[t.bindingRef]:[]])).filter(t=>/^[a-z0-9_]+\.[a-z0-9_]+$/.test(t)),na=(t,e,s)=>{const i=t.split(".",2)[1]||"";return new RegExp(`(?:^|_)target_?${s}_${e}(?:_|$)`).test(i)||new RegExp(`(?:^|_)target_${e}_${s}(?:_|$)`).test(i)};function ra(t,e){if(t.marker?.radar&&"object"==typeof t.marker.radar)return u(t.marker.radar)?{eligible:!0,profile:t.marker.radar.profile,reason:"saved"}:{eligible:!0,profile:"presence_v1",reason:"saved_unsupported"};const s="entity"===t.bindingKind?e?.entities?.[t.bindingRef||""]:null,i="device"===t.bindingKind?t.bindingRef:s?.device_id,o=i?e?.devices?.[i]:null,a=aa(t);return ea.has((n=o?.model||t.model,String(n||"").toLowerCase().replace(/[^a-z0-9]/g,"")))&&a.some(t=>na(t,"x",1))&&a.some(t=>na(t,"y",1))?{eligible:!0,profile:"esphome_ld2450_v1",reason:"ld2450"}:{eligible:!1,profile:"presence_v1",reason:"none"};var n}function la(t,e){return t.find(t=>e.some(e=>e.test(t)))||""}function ha(t,e,s,i,o=!1){const a=ra(t,i),n=u(t.marker?.radar)?t.marker.radar:null;if(!n&&!a.eligible&&!o)return null;const r=n?.profile||a.profile,l=o&&!a.eligible||"ld2450"!==a.reason?{xEntities:["","",""],yEntities:["","",""],distanceEntity:"",angleEntity:"",occupancyEntity:"",countEntity:"",zoneEntity:""}:function(t,e,s){const i=aa(t).filter(t=>!!s?.states?.[t]),o=[],a=[];for(let t=1;t<=3;t++)o.push(i.find(e=>na(e,"x",t))||""),a.push(i.find(e=>na(e,"y",t))||"");const n=i.filter(t=>t.startsWith("binary_sensor.")),r=i.filter(t=>t.startsWith("sensor.")),l=la(n,[/(?:occupancy|presence|target)(?:_|$)/]);return{xEntities:o,yEntities:a,distanceEntity:la(r,[/(?:target_)?distance(?:_|$)/,/distance/]),angleEntity:la(r,[/(?:target_)?angle(?:_|$)/,/angle/]),occupancyEntity:l,countEntity:la(r,[/(?:target|people|presence)_count(?:_|$)/,/target_count/]),zoneEntity:"zones_v1"===e?la(n,[/(?:zone|region).*(?:occupancy|presence)/,/zone/]):""}}(t,r,i),h=n?.sources||{},c=h.slots||[],d=c.filter(t=>"x_entity"in t),p=c.filter(t=>"distance_entity"in t),_=h.ranges||[],g=h.zones?.[0],m="esphome_ld2450_v1"===r?3:"cartesian_v1"===r?Math.max(1,d.length):"polar_v1"===r?Math.max(1,p.length):1,f=n?.room_id||t.marker?.room_id||e.rooms.find(e=>e.area&&e.area===t.area)?.id||"";return{original:n,enabled:!0===n?.enabled,showLive:!1!==n?.show_live,profile:r,roomId:f,installationId:n?.mount?.installation_id||sa(),mountX:oa(null==n?.mount?.x?void 0:1e3*n.mount.x,oa(s[0],"0")),mountY:oa(null==n?.mount?.y?void 0:1e3*n.mount.y,oa(s[1],"0")),heading:oa(n?.mount?.heading_deg,"0"),rangeCm:oa(n?.mount?.range_cm,"esphome_ld2450_v1"===r?"600":""),fovDeg:oa(n?.mount?.fov_deg,"esphome_ld2450_v1"===r?"120":""),mirror:!0===n?.calibration?.mirror,unit:d[0]?.unit||p[0]?.unit||_[0]?.unit||("esphome_ld2450_v1"===r?"mm":"cm"),xEntities:Array.from({length:m},(t,e)=>d[e]?.x_entity||l.xEntities[e]||""),yEntities:Array.from({length:m},(t,e)=>d[e]?.y_entity||l.yEntities[e]||""),distanceEntities:Array.from({length:m},(t,e)=>p[e]?.distance_entity||(0===e?l.distanceEntity:"")),angleEntities:Array.from({length:m},(t,e)=>p[e]?.angle_entity||(0===e?l.angleEntity:"")),rangeEntities:_.length?_.map(t=>t.entity_id):[l.distanceEntity],slotPresenceEntities:Array.from({length:m},(t,e)=>(d[e]||p[e])?.presence_entity||""),rangePresenceEntities:(_.length?_:[{}]).map(t=>"presence_entity"in t&&t.presence_entity||""),swapXY:Array.from({length:m},(t,e)=>!0===d[e]?.swap_xy),xSigns:Array.from({length:m},(t,e)=>-1===d[e]?.x_sign?-1:1),ySigns:Array.from({length:m},(t,e)=>-1===d[e]?.y_sign?-1:1),angleUnit:p[0]?.angle_unit||"degrees",angleZero:p[0]?.angle_zero||"forward",angleClockwise:!1!==p[0]?.angle_clockwise,occupancyEntity:h.occupancy_entity||l.occupancyEntity,countEntity:h.count_entity||l.countEntity,availabilityEntity:h.availability_entity||"",zoneEntity:g?.entity_id||l.zoneEntity,zoneKind:g?.kind||"occupancy"}}const ca=t=>JSON.stringify(t,(t,e)=>e&&"object"==typeof e&&!Array.isArray(e)?Object.fromEntries(Object.entries(e).sort(([t],[e])=>te?1:0)):e),da=t=>{if(!t.trim())return null;const e=Number(t.replace(",","."));return Number.isFinite(e)?e:null};function pa(t,e){const s=da(t.mountX),i=da(t.mountY),o=da(t.heading);if(!t.roomId||null==s||null==i||null==o)return null;const a={...t.original?.sources||{}};if(delete a.slots,delete a.ranges,delete a.zones,delete a.occupancy_entity,delete a.count_entity,"esphome_ld2450_v1"===t.profile||"cartesian_v1"===t.profile){if(a.slots=t.xEntities.flatMap((e,s)=>{const i=t.yEntities[s]||"";return e&&i?[{id:`target_${s+1}`,x_entity:e,y_entity:i,unit:"esphome_ld2450_v1"===t.profile?"mm":t.unit,..."cartesian_v1"===t.profile&&t.swapXY[s]?{swap_xy:!0}:{},..."cartesian_v1"===t.profile&&-1===t.xSigns[s]?{x_sign:-1}:{},..."cartesian_v1"===t.profile&&-1===t.ySigns[s]?{y_sign:-1}:{},...t.slotPresenceEntities[s]?{presence_entity:t.slotPresenceEntities[s]}:{}}]:[]}),!a.slots.length)return null}else if("polar_v1"===t.profile){if(a.slots=t.distanceEntities.flatMap((e,s)=>{const i=t.angleEntities[s]||"";return e&&i?[{id:`target_${s+1}`,distance_entity:e,angle_entity:i,unit:t.unit,angle_unit:t.angleUnit,angle_zero:t.angleZero,angle_clockwise:t.angleClockwise,...t.slotPresenceEntities[s]?{presence_entity:t.slotPresenceEntities[s]}:{}}]:[]}),!a.slots.length)return null}else if("range_v1"===t.profile){if(a.ranges=t.rangeEntities.flatMap((e,s)=>e?[{id:`range_${s+1}`,entity_id:e,unit:t.unit,...t.rangePresenceEntities[s]?{presence_entity:t.rangePresenceEntities[s]}:{}}]:[]),!a.ranges.length)return null}else if("zones_v1"===t.profile){if(!t.zoneEntity)return null;a.zones=[{id:"zone_1",kind:t.zoneKind,entity_id:t.zoneEntity}]}else if("presence_v1"===t.profile&&!t.occupancyEntity)return null;t.occupancyEntity&&(a.occupancy_entity=t.occupancyEntity),t.countEntity&&(a.count_entity=t.countEntity),t.availabilityEntity&&(a.availability_entity=t.availabilityEntity);const n=da(t.rangeCm),r=da(t.fovDeg),l=(o%360+360)%360,h={...t.original?.mount||{},installation_id:t.installationId,x:s/1e3,y:i/1e3,heading_deg:l};null!=n&&n>0?h.range_cm=n:delete h.range_cm,null!=r&&r>0?h.fov_deg=r:delete h.fov_deg;const c=t.original,d="two_point"===c?.calibration?.method&&c.profile===t.profile&&ca(c.sources)===ca(a)&&c.mount.installation_id===t.installationId&&Math.abs(c.mount.x-h.x)<1e-12&&Math.abs(c.mount.y-h.y)<1e-12&&Math.abs(c.mount.heading_deg-l)<1e-9&&c.calibration.mirror===t.mirror&&Math.abs(c.calibration.cell_cm-e)<1e-9,p=t.calibrationOverride?{...t.calibrationOverride}:d?{...c.calibration}:{...c?.calibration||{},method:"zones_v1"===t.profile||"presence_v1"===t.profile?"not_required":"manual",mirror:t.mirror,cell_cm:e};t.calibrationOverride||d||(delete p.refs,delete p.rms_cm);const u={...t.original||{},version:1,enabled:t.enabled,profile:t.profile,sources:a,mount:h,room_id:t.roomId,calibration:p};return t.showLive?delete u.show_live:u.show_live=!1,u}const ua={badge:"display.badge",icon_ripple:"display.icon_ripple",value:"display.value",static_icon:"display.static_icon",value_static_icon:"display.value_static_icon"},_a={badge:"marker.display_hint_badge",icon_ripple:"marker.display_hint_icon_ripple",value:"marker.display_hint_value",static_icon:"marker.display_hint_static_icon",value_static_icon:"marker.display_hint_value_static_icon"};function ga(){Zo(this.host);const t=this.host._markerDialog,e="virtual"===t.bindingMode,s=this._bindingCandidates();this.host._bindingEntities(t.binding);const i=e?null:this.host._bindingStatus(t.binding),o=!e&&this.host._bindingHasHaPage(t.binding),a=this._markerPreviewDevice(t),n=this._effectiveMarkerTapAction(t,a),r=a?_(this.host._serverCfg?.spaces.find(t=>t.id===a.space)):null,l=a?this._markerPreviewDevices(a):this.host._devices,h="toggle"===n&&a?this._toggleIntent(a,l):null,c=this._toggleHintLines(h),u=a?g(this.host._planHass,a,{liveStates:!1!==this.host._config?.live_states,showTemperature:!1!==this.host._config?.show_temperature,showSignal:r?.showLqi??!1!==this.host._config?.show_signal,designPreview:!0,activityRuntime:this.host._activityRt.get(a.id),lightDevices:l,registryHass:this.host._fullRegistryHass,reducedMotion:this.host._reducedMotion}):null,R=a?m(this.host._planHass,a,l):[],z=a?f(this.host._planHass,a,R):null,F=t.valueBadgeTouched?t.valueBadgeEnabled:!!u?.valueBadge,N=t.valueBadgeTouched?t.valueBadgeSource:u?.valueBadge?.source||t.valueBadgeSource,A=t.valueBadgeTouched?t.valueBadgePosition:u?.valueBadge?.position||t.valueBadgePosition,E=b(N),O=!!N&&!R.some(t=>t.key===E),H=R.find(t=>t.key===E),B=b(t.valueSource),W=!(!t.valueSource||B&&R.some(t=>t.key===B)),j=R.find(t=>t.key===B),G=u?.valueSource?.sourceKey||"",q=this._markerAutoHasSpatialSource(t),U=!!a&&v(this.host._planHass,{...a}),K=y(t.lightRole,q,U,t.glowMode),V=!K.sourceExists,J=!K.fromSourceEnabled,Z=K.passive,Y=K.effectiveMode,X="never"===t.lightRole?this.host._t("marker.glow_disabled_never"):"auto"!==t.lightRole||q?Z?this.host._t("marker.glow_passive_hint"):this.host._t("marker.glow_disabled_no_entity"):this.host._t("marker.glow_disabled_auto"),Q=a?$(a):[],tt=a&&w(a)||"",et=!!t.lightEntity&&!Q.includes(t.lightEntity),st=a?k(a):[],it=!!t.toggleEntity&&!st.includes(t.toggleEntity),ot="toggle"===n?this._toggleIntentForDialog({...t,toggleEntity:"",toggleEntityTouched:!0}):null,at=ot?[...ot.targets,...ot.skippedTargets].map(t=>t.entityId||("ref"in t?t.ref:"")).filter(Boolean).join(", "):"",nt=(()=>{if(e)return null;const i=s.find(e=>e.value===t.binding);if(i)return i.label;const[o,a]=t.binding.split(":");return"device"===o?this.host._fullRegistryHass.devices[a]?.name_by_user||this.host._fullRegistryHass.devices[a]?.name||a:this.host._fullRegistryHass.entities[a]?.name||this.host.hass.states[a]?.attributes?.friendly_name||a})();return p`this._closeMarkerDialog()}>
    - ${Zo({title:this.host._t("marker.card_basics"),body:p` + ${Yo({title:this.host._t("marker.card_basics"),body:p` ${"ha_disabled"===i?.kind?p`
    ${this.host._t(`marker.ha_disabled_${i.reason}`)} @@ -120,7 +120,7 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db
    @@ -145,7 +145,7 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db @input=${e=>this.host._markerDialog={...t,bindingFilter:e.target.value}} />
    ${s.map(e=>p`
    {if(e.value===t.binding)return void(this.host._markerDialog={...t,bindingOpen:!1});const s={...t,binding:e.value,bindingOpen:!1,controls:x(e.value,t.controls,this.host._bindingEntities(e.value)),autoIcon:this.host._autoIconForBinding(e.value),...sa(t.radar,t.radarTouched,t.radarRemove)};this.host._markerDialog=this._announceToggleDraft({...s,...this._valueBadgeForBinding(s,e.value),valueSource:null,valueSourceTouched:!0})}}> + @click=${()=>{if(e.value===t.binding)return void(this.host._markerDialog={...t,bindingOpen:!1});const s={...t,binding:e.value,bindingOpen:!1,controls:x(e.value,t.controls,this.host._bindingEntities(e.value)),autoIcon:this.host._autoIconForBinding(e.value),...ia(t.radar,t.radarTouched,t.radarRemove)};this.host._markerDialog=this._announceToggleDraft({...s,...this._valueBadgeForBinding(s,e.value),valueSource:null,valueSourceTouched:!0})}}> ${e.label}${e.sub}
    `)} ${s.length?d:p`
    ${this.host._t("marker.nothing_found")}
    `} @@ -164,7 +164,7 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db ${this._renderRadarSection(t,a)} ${this._renderVacSection(t)}`})} - ${Zo({title:this.host._t("marker.card_tap"),body:p` + ${Yo({title:this.host._t("marker.card_tap"),body:p` -

    ${this.host._t(ua[t.display])}

    +

    ${this.host._t(_a[t.display])}

    ${D(t.display)?p`
    @@ -462,7 +462,7 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db ${this._rangeInput(0,355,5,t.angle,e=>this.host._markerDialog={...t,angle:e})} ${t.angle}°
    `})} - ${Zo({title:this.host._t("marker.card_details"),body:p` + ${Yo({title:this.host._t("marker.card_details"),body:p` {Number.isFinite(t)&&Number.isFinite(e)&&t!==e&&Math.abs(e-t)<=ga&&c++},p=(t,e)=>{d(t[0],e[0]),d(t[1],e[1])},u={};let _=5;for(const t of s){const e=$a(t);null!=t?.id&&(u[String(t.id)]=e),e>_&&(_=e)}const g=(t,e,s,i=!1)=>{if(!(t>ga||i))return;o++,t>n&&(n=t);const a=t*F*e;a>r&&(r=a,l=s)};for(const t of s){const e=$a(t),s=null!=t?.id?String(t.id):"";for(const i of t.rooms||[]){a++;let t=0;if(i.poly?.length)i.poly=i.poly.map(e=>{const s=[fa(e[0]),fa(e[1])];return t=Math.max(t,ba(e[0],e[1],s[0],s[1])),p(e,s),s});else if(null!=i.x&&null!=i.y){const e=i.x,s=i.y,o=i.w||0,a=i.h||0,n=fa(e+o),r=fa(s+a),l=fa(e),h=fa(s),c=Math.max(z,n-l),p=Math.max(z,r-h);t=va(e,s,o,a,l,h,c,p),i.x=l,i.y=h,i.w=c,i.h=p,d(e,l),d(s,h),d(e+o,l+c),d(s+a,h+p)}g(t,e,s)}for(const i of t.partitions||[]){a++;const o=[i.a[0],i.a[1]],n=[i.b[0],i.b[1]],r=[fa(o[0]),fa(o[1])],l=[fa(n[0]),fa(n[1])];let h=Math.max(ba(o[0],o[1],r[0],r[1]),ba(n[0],n[1],l[0],l[1]));const c=ba(r[0],r[1],l[0],l[1]),d=(t.openings||[]).filter(t=>"partition"===t.host?.kind&&t.host.id===i.id).every(t=>{const e=Number(t.length),s=Number(t.host.t),i=s*c;return Number.isFinite(e)&&e>0&&Number.isFinite(s)&&s>=0&&s<=1&&i-e/2>=-ga&&i+e/2<=c+ga});c>ga&&d?(i.a=r,i.b=l,p(o,r),p(n,l)):h=0,g(h,e,s)}for(const i of t.wall_columns||[]){a++;const t=[i.center[0],i.center[1]],o=[fa(t[0]),fa(t[1])],n=ba(t[0],t[1],o[0],o[1]);i.center=o,p(t,o),g(n,e,s)}for(const i of t.decor||[]){if("furniture"===i.kind||"image"===i.kind)continue;a++;let t=0;if("line"===i.kind){const e=[i.x1,i.y1],s=[i.x2,i.y2],o=[fa(e[0]),fa(e[1])],a=[fa(s[0]),fa(s[1])];t=Math.max(ba(e[0],e[1],o[0],o[1]),ba(s[0],s[1],a[0],a[1])),i.x1=o[0],i.y1=o[1],i.x2=a[0],i.y2=a[1],p(e,o),p(s,a)}else{const e=i.x,s=i.y,o=i.w,a=i.h,n=fa(e),r=fa(s);if(null!=i.w&&null!=i.h){const l=fa(e+o),h=fa(s+a),c=Math.max(z,l-n),p=Math.max(z,h-r);t=va(e,s,o,a,n,r,c,p),i.w=c,i.h=p,d(e+o,n+c),d(s+a,r+p)}else t=ba(e,s,n,r);i.x=n,i.y=r,d(e,n),d(s,r)}g(t,e,s)}for(const i of t.openings||[]){if(a++,"partition"===i.host?.kind){const o=(t.partitions||[]).find(t=>t.id===i.host.id),a=Number(i.host.t);if(!o||!Number.isFinite(a)||a<0||a>1)continue;const n=o.b[0]-o.a[0],r=o.b[1]-o.a[1];if(Math.hypot(n,r)<=ga)continue;const l=o.a[0]+n*a,c=o.a[1]+r*a;let d=180*Math.atan2(r,n)/Math.PI;d>=90?d-=180:d<-90&&(d+=180);const p=Number(i.angle),u=!(Number.isFinite(p)&&p===d),_=ya(i.x,i.y,Number.isFinite(p)?p:d,Number(i.length)||0,l,c,d);i.x=l,i.y=c,i.angle=d,u&&h++,g(_,e,s,u);continue}const o=R([i.x,i.y],t.rooms||[],ma,{step:z,length:Number(i.length)||0});if(!o)continue;const n=Number(i.angle),r=!(Number.isFinite(n)&&n===o.angle),l=ya(i.x,i.y,Number.isFinite(n)?n:o.angle,Number(i.length)||0,o.x,o.y,o.angle);i.x=o.x,i.y=o.y,i.angle=o.angle,r&&h++,g(l,e,s,r)}}for(const[t,e]of Object.entries(i)){if(!e||"object"!=typeof e)continue;const s=e;if("number"!=typeof s.x||"number"!=typeof s.y)continue;a++;const o=fa(s.x),n=fa(s.y),r=ba(s.x,s.y,o,n);i[t]={...s,x:o,y:n},d(s.x,o),d(s.y,n);const l="string"==typeof s.s?s.s:"";g(r,u[l]??_,l)}return{spaces:s,layout:i,report:{moved:o,coordsCanonicalized:c,total:a,maxShift:n,maxShiftCm:r,maxSpace:l,rotated:h},changed:o>0||c>0}}function ka(t,e){const s=e.base+t*e.span;return Math.min(1,Math.max(0,s))}const xa=t=>Array.isArray(t)&&t.length>=2&&Number.isFinite(t[0])&&Number.isFinite(t[1]),Ma=(t,e)=>Math.hypot(t[0]-e[0],t[1]-e[1]);function Ca(t,e,s){const i=s[0]-e[0],o=s[1]-e[1],a=i*i+o*o;if(a<=0)return Ma(t,e);let n=((t[0]-e[0])*i+(t[1]-e[1])*o)/a;return n=Math.max(0,Math.min(1,n)),Math.hypot(t[0]-(e[0]+i*n),t[1]-(e[1]+o*n))}function Sa(t,e,s,i,o){for(const i of e)if(i&&!s.has(i.id)&&xa(i.a)&&xa(i.b)&&(Ma(t,i.a)<=o||Ma(t,i.b)<=o))return!0;for(const e of i?.roomPolygons||[])for(let s=0;s0&&r>0))return null;if(Math.abs(o[0]/n*(a[1]/r)-o[1]/n*(a[0]/r))>s)return null;for(const[s,o]of[[t.a,e.a],[t.a,e.b],[t.b,e.a],[t.b,e.b]])if(Ma(s,o)<=i)return[(s[0]+o[0])/2,(s[1]+o[1])/2];return null}function Da(t,e){const s=.05*(Number(e.pitch)>0?Number(e.pitch):1),i=new Map;let o=(t||[]).filter(t=>!!t&&"string"==typeof t.id&&xa(t.a)&&xa(t.b));if(o.length<2)return{partitions:[...t||[]],merged:0,openingMoves:[]};const a=e.seedIds&&e.seedIds.length?new Set(e.seedIds):null;let n=0;for(let t=0;tMa(e,t.at)>s);let c=h[0]??r.a,d=h[h.length-1]??l.b;if(h.length<2&&(c=r.a,d=l.b),d[0]0?(d[0]-c[0])/u:0,g=u>0?(d[1]-c[1])/u:0,m=t=>u>0?((t[0]-c[0])*_+(t[1]-c[1])*g)/u:0;for(const t of[r,l]){const e=m(t.a),s=m(t.b)-e;for(const[o,a]of i)a.toId===t.id&&i.set(o,{fromId:a.fromId,toId:p.id,base:e+a.base*s,span:a.span*s});i.set(t.id,{fromId:t.id,toId:p.id,base:e,span:s})}a&&a.add(p.id),o=o.filter((e,s)=>s!==t.i&&s!==t.j),o.splice(t.i,0,p),n++}return{partitions:o,merged:n,openingMoves:[...i.values()]}}function Ia(t,e,s,i){if(!t?.length||!s.length)return 0;const o=new Map(s.map(t=>[t.fromId,t]));let a=0;for(const s of t){const t=s?.host;if(!t||"partition"!==t.kind)continue;const n=o.get(t.id);if(!n)continue;s.host={...t,id:n.toId,t:ka(t.t,n)},a++;const r=A(s,e,i.coordScale,i.cellCm,i.gridPitch).resolved;r&&Object.assign(s,E(s,r,i.coordScale))}return a}function La(t){return{roomPolygons:(t?.rooms||[]).map(t=>N(t)).filter(t=>!!t),columns:t?.wall_columns||[]}}const Ta=t=>!!t&&t.length>=2&&Number.isFinite(t[0])&&Number.isFinite(t[1]),Ra=(t,e)=>t[0]-e[0]||t[1]-e[1],za=(t,e,s,i)=>[t[0]+e*i,t[1]+s*i],Fa=(t,e,s,i)=>(t[0]-e[0])*s+(t[1]-e[1])*i,Na=(t,e,s,i,o)=>{const a=e[0]-t[0],n=e[1]-t[1],r=Math.hypot(a,n);if(!(r>o))return null;const l=a/r,h=n/r,c=e=>Math.abs((e[0]-t[0])*h-(e[1]-t[1])*l);if(c(s)>o||c(i)>o)return null;const d=Fa(s,t,l,h),p=Fa(i,t,l,h),u=Math.max(0,Math.min(d,p)),_=Math.min(r,Math.max(d,p));return _-u>o?{lo:u,hi:_}:null},Aa=(t,e,s)=>Math.min(t.hi,e.hi)-Math.max(t.lo,e.lo)>s,Ea=t=>{const e=new Set(["id","a","b","cm"]);return Object.keys(t||{}).every(t=>e.has(t))},Oa=(t,e,s,i)=>{const o=t.b[0]-t.a[0],a=t.b[1]-t.a[1],n=Math.hypot(o,a);if(!(n>i))return!0;const r=o/n,l=a/n,h=V(t.cm,s.cellCm,s.gridPitch)/2;return e.some(e=>{const o=e?.center;if(!Ta(o))return!0;const a=Fa(o,t.a,r,l),c=Math.abs((o[0]-t.a[0])*l-(o[1]-t.a[1])*r),d=V(Number(e.cm),s.cellCm,s.gridPitch)*("square"===e.shape?Math.SQRT1_2:.5);return!(Number.isFinite(d)&&d>0)||a>=-d-i&&a<=n+d+i&&c<=h+d+i})},Ha=(t,e,s)=>{if(t.host){const i=A(t,e,s.coordScale,s.cellCm,s.gridPitch).resolved;return i?{center:i.center,angle:i.angle,length:i.length}:null}const i=Number(t.x)*s.coordScale,o=Number(t.y)*s.coordScale,a=Number(t.angle),n=Number(t.length)*s.coordScale;return[i,o,a,n].every(Number.isFinite)&&n>0?{center:[i,o],angle:a,length:n}:null},Ba=(t,e,s)=>{const i=t.angle*Math.PI/180,o=Math.cos(i),a=Math.sin(i),n=e.angle*Math.PI/180,r=Math.cos(n),l=Math.sin(n);if(Math.abs(o*l-a*r)>1e-6)return!1;const h=e.center[0]-t.center[0],c=e.center[1]-t.center[1];if(Math.abs(h*a-c*o)>s)return!1;const d=h*o+c*a;return Math.max(-t.length/2,d-e.length/2)({...t,a:[t.a[0]*e,t.a[1]*e],b:[t.b[0]*e,t.b[1]*e]}),ja=(t,e,s,i)=>{const o=`~r-${(t=>{let e=2166136261;for(let s=0;s>>0;return e.toString(36)})(`${t}|${e[0].toFixed(9)},${e[1].toFixed(9)}|${s[0].toFixed(9)},${s[1].toFixed(9)}`)}`,a=`${t.slice(0,Math.max(1,64-o.length))}${o}`;let n=a;for(let t=2;i.has(n);t++){const e=`-${t}`;n=`${a.slice(0,64-e.length)}${e}`}return i.add(n),n},Ga=(t,e)=>{const s=[];for(const i of t){const t=s[s.length-1];!(t&&Math.abs(t.hi-i.lo)<=e&&t.safe===i.safe)||i.safe&&t.signature!==i.signature?s.push({lo:i.lo,hi:i.hi,a:i.a,b:i.b,safe:i.safe,signature:i.signature,roomIds:i.roomIds,finalCm:i.finalCm}):(t.hi=i.hi,t.b=i.b)}return s};function qa(t,e,s,i,o){const a=s||[],n=Array.isArray(t?.partitions)?t.partitions:[],r=Array.isArray(t?.openings)?t.openings:[],l={walls:a,partitions:n,openings:r,partitionsReconciled:0,openingsRehosted:0};if(!n.length)return l;const h=Math.max(2e-4*o.gridPitch,1e-9);let c=a,d=n,p=r,u=0,_=0;const g=o.partitionIds?new Set(o.partitionIds):null,m=new Map(e.partitions.map(t=>[t.id,t]));for(const t of[...n].sort((t,e)=>t.id.localeCompare(e.id))){if(g&&!g.has(t.id))continue;if(!d.some(e=>e.id===t.id))continue;if(!Ea(t))continue;const s=m.get(t.id);if(!(s&&Ta(s.a)&&Ta(s.b)&&Number.isFinite(s.cm)&&(o.allowCoincidentPartitions?!(s.cm<0):s.cm>0)))continue;const[a,n]=Ra(s.a,s.b)<=0?[[s.a[0],s.a[1]],[s.b[0],s.b[1]]]:[[s.b[0],s.b[1]],[s.a[0],s.a[1]]],r=n[0]-a[0],l=n[1]-a[1],f=Math.hypot(r,l);if(!(f>h))continue;const b=r/f,v=l/f,y=O(e.rooms,c,i,o.pitch,o.cellCm,o.gridPitch,o.coordScale),$=y.flatMap(t=>{if(t.open||"outer"!==t.kind&&"shared"!==t.kind)return[];const e=Na(a,n,t.a,t.b,h);return e?[{interval:t,range:e}]:[]});if(!$.length)continue;const w=p.filter(t=>"partition"===t.host?.kind&&t.host.id===s.id).map(t=>({opening:t,resolved:A(t,e.partitions,o.coordScale,o.cellCm,o.gridPitch).resolved}));if(w.some(t=>!t.resolved))continue;const k=[0,f];for(const{range:t}of $)k.push(t.lo,t.hi);const x=k.slice(),M=new Map;for(const{opening:t,resolved:e}of w){const s=Fa(e.center,a,b,v),i={lo:s-e.length/2,hi:s+e.length/2};M.set(t.id,i),x.push(Math.max(0,i.lo),Math.min(f,i.hi))}const C=[...new Set(x.filter(t=>Number.isFinite(t)&&t>=-h&&t<=f+h).map(t=>Math.max(0,Math.min(f,t)).toFixed(9)))].map(Number).sort((t,e)=>t-e),S=d.map(t=>Wa(t,o.coordScale)).filter(t=>t.id!==s.id),P=[];for(let t=0;t+1h))continue;const r=za(a,b,v,i),l=za(a,b,v,n),c=$.filter(({range:t})=>t.lo<=i+h&&t.hi>=n-h).map(({interval:t})=>t),d=new Map;for(const t of c)d.set(t.roomId,t);const p=[...d.values()],u=new Set(p.map(t=>t.kind)),_=new Set(p.map(t=>o.allowCoincidentPartitions||t.cm>0?t.cm:H)),g=p[0]?.kind,m=[...d.keys()].sort(),f=1===u.size&&1===_.size&&("outer"===g&&1===m.length||"shared"===g&&2===m.length),y={id:s.id,a:r,b:l,cm:s.cm},w=S.some(t=>!!Na(r,l,t.a,t.b,h)),k=f&&(o.allowCoincidentPartitions||!w)&&!Oa(y,e.wall_columns,o,h),x=f?o.allowCoincidentPartitions||p[0].cm>0?p[0].cm:H:0,M=f?Math.max(x,s.cm):s.cm;P.push({lo:i,hi:n,a:r,b:l,safe:k,signature:k?`${g}|${m.join(",")}|${M}`:"",roomIds:m,roomCm:x,finalCm:M})}if(!P.some(t=>t.safe))continue;const D=new Map;for(const{opening:t,resolved:e}of w){const i=M.get(t.id),a=k.some(t=>t>i.lo+h&&tAa(t,i,h)),r=new Set(n.filter(t=>t.safe).map(t=>t.signature));if(!a&&n.length>0&&n.every(t=>t.safe)&&1===r.size&&B(e,y,h)){D.set(t.id,{resolved:e,signature:[...r][0]});continue}const l=W(s,o.cellCm,o.gridPitch),c={lo:i.lo-l,hi:i.hi+l};for(const t of P)Aa(t,c,h)&&(t.safe=!1,t.signature="")}let I=!0;for(;I;){I=!1;for(const[t,e]of[...D.entries()]){const i=M.get(t),a=P.filter(t=>Aa(t,i,h));if(a.length>0&&a.every(t=>t.safe)&&a.every(t=>t.signature===e.signature))continue;D.delete(t);const n=W(s,o.cellCm,o.gridPitch),r={lo:i.lo-n,hi:i.hi+n};for(const t of P)Aa(t,r,h)&&(t.safe=!1,t.signature="");I=!0}}const L=Ga(P,h),T=L.filter(t=>t.safe),R=L.filter(t=>!t.safe);if(!T.length)continue;if(d.length-1+R.length>2e3)continue;let z=c;for(const t of T){const[e,i]=Ra(s.a,s.b)<=0?[t.a,t.b]:[t.b,t.a];z=j(z,e,i,t.finalCm,o.pitch,o.coordScale)}if(z=G(e.rooms,z,i,o.pitch,o.cellCm,o.gridPitch,o.coordScale),z.length>500)continue;const F=new Set(d.map(t=>t.id));F.delete(s.id);const N=R.map((t,e)=>{const i=[t.a[0]/o.coordScale,t.a[1]/o.coordScale],a=[t.b[0]/o.coordScale,t.b[1]/o.coordScale],n=0===e?s.id:ja(s.id,i,a,F);return F.add(n),{id:n,a:i,b:a,cm:s.cm}}),V=d.findIndex(t=>t.id===s.id),J=d.slice();J.splice(V,1,...N);const Z=J.map(t=>Wa(t,o.coordScale)),Y=new Map;let X=!0;for(const{opening:t,resolved:e}of w){const s=D.get(t.id);if(s){const e=E(t,s.resolved,o.coordScale),{host:i,...a}=e;Y.set(t.id,a);continue}const i=M.get(t.id),a=N[R.findIndex(t=>t.lo<=i.lo+h&&t.hi>=i.hi-h)],n=a&&Z.find(t=>t.id===a.id);if(!a||!n){X=!1;break}const r=n.b[0]-n.a[0],l=n.b[1]-n.a[1],c=Math.hypot(r,l),d=Fa(e.center,n.a,r/c,l/c),p={...E(t,e,o.coordScale),host:{kind:"partition",id:a.id,t:d/c}};if(!q(p,Z,o.coordScale,o.cellCm,o.gridPitch).resolved){X=!1;break}Y.set(t.id,p)}if(!X)continue;const Q=p.map(t=>Y.get(t.id)||t),tt=[...D.keys()].map(t=>Y.get(t)),et=tt.map(t=>Ha(t,Z,o));if(et.some(t=>!t))continue;let st=!1;for(let t=0;tt.id));for(const t of Q){if(it.has(t.id))continue;const e=Ha(t,Z,o);e&&et.some(t=>Ba(t,e,h))&&(st=!0)}if(st)continue;const ot=U(e.rooms,z,i,o.pitch,o.cellCm,o.gridPitch,o.coordScale);[...D.entries()].every(([t,e])=>{const s=Y.get(t),i=K(ot,{x:s.x*o.coordScale,y:s.y*o.coordScale,angle:s.angle,length:s.length*o.coordScale},!0),a=[i.negative,i.positive].filter(t=>!!t?.full),n=e.signature.split("|")[1].split(","),r=new Set(a.map(t=>t.roomId));return a.length===n.length&&r.size===n.length&&n.every(t=>r.has(t))})&&(c=z,d=J,p=Q,u+=T.length,_+=D.size)}return{walls:c,partitions:d,openings:p,partitionsReconciled:u,openingsRehosted:_}}const Ua=t=>JSON.parse(JSON.stringify(t)),Ka=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Va=(t,e)=>e.length>0&&e.length<=35&&("space"===t?/^[a-z0-9_-]+$/.test(e):/^[A-Za-z0-9_-]+$/.test(e));function Ja(t,e){let s=String(e??"");const i=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=new RegExp(`^${i}_(.+)_([0-9a-f]{8})$`);let a=0;for(;a<16;a++){const t=o.exec(s);if(!t)return{root:s,layers:a,bounded:!1};s=t[1]}return{root:s,layers:a,bounded:o.test(s)}}const Za=(t,e,s)=>{const i=t.get(e)||[];i.push(s),t.set(e,i)};const Ya=1e-9;class Xa extends Error{constructor(t,e=""){super(e?`${t}: ${e}`:t),this.reason=t,this.name="WallSegmentModelError"}}const Qa=t=>JSON.parse(JSON.stringify(t)),tn=t=>Array.isArray(t)&&t.length>=2&&Number.isFinite(Number(t[0]))&&Number.isFinite(Number(t[1])),en=t=>[Number(t[0]),Number(t[1])],sn=t=>`${Number(t[0]).toFixed(12)},${Number(t[1]).toFixed(12)}`,on=(t,e)=>{const s=sn(t),i=sn(e);return ssn(t)<=sn(e)?[en(t),en(e)]:[en(e),en(t)],nn=(t,e)=>Math.hypot(e[0]-t[0],e[1]-t[1]),rn=(t,e=[])=>{const s=new Set,i=t=>{const e=Number(t);if(!Number.isFinite(e))return;const i=e/z;Math.abs(i-Math.round(i))>=tt&&s.add(e.toFixed(12))};for(const e of Array.isArray(t?.rooms)?t.rooms:[])for(const t of N(e)||[])i(t[0]),i(t[1]);for(const e of[t?.wall_segments,t?.walls])for(const t of Array.isArray(e)?e:[])i(t?.a?.[0]),i(t?.a?.[1]),i(t?.b?.[0]),i(t?.b?.[1]);for(const t of e)i(t?.[0]),i(t?.[1]);return s.size},ln=(t,e,s)=>{const i=s[0]-e[0],o=s[1]-e[1],a=i*i+o*o;return a>1e-18?((t[0]-e[0])*i+(t[1]-e[1])*o)/a:0},hn=(t,e,s)=>{const i=Math.max(0,Math.min(1,ln(t,e,s)));return Math.hypot(t[0]-(e[0]+(s[0]-e[0])*i),t[1]-(e[1]+(s[1]-e[1])*i))},cn=(t,e,s,i,o=1e-9)=>{const a=e[0]-t[0],n=e[1]-t[1],r=Math.hypot(a,n);if(r<=o)return 0;const l=e=>Math.abs((e[0]-t[0])*n-(e[1]-t[1])*a)/r;if(l(s)>o||l(i)>o)return 0;const h=ln(s,t,e),c=ln(i,t,e);return Math.max(0,Math.min(1,Math.max(h,c))-Math.max(0,Math.min(h,c)))*r},dn=t=>{const e=(new TextEncoder).encode(t),s=8*e.length,i=64*Math.ceil((e.length+9)/64),o=new Uint8Array(i);o.set(e),o[e.length]=128;const a=new DataView(o.buffer);a.setUint32(i-8,Math.floor(s/4294967296),!1),a.setUint32(i-4,s>>>0,!1);const n=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),r=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),l=new Uint32Array(64),h=(t,e)=>t>>>e|t<<32-e;for(let t=0;t>>3,o=h(s,17)^h(s,19)^s>>>10;l[t]=l[t-16]+i+l[t-7]+o>>>0}let[e,s,i,o,c,d,p,u]=r;for(let t=0;t<64;t++){const a=u+(h(c,6)^h(c,11)^h(c,25))+(c&d^~c&p)+n[t]+l[t]>>>0,r=e&s^e&i^s&i;u=p,p=d,d=c,c=o+a>>>0,o=i,i=s,s=e,e=a+((h(e,2)^h(e,13)^h(e,22))+r>>>0)>>>0}r[0]=r[0]+e>>>0,r[1]=r[1]+s>>>0,r[2]=r[2]+i>>>0,r[3]=r[3]+o>>>0,r[4]=r[4]+c>>>0,r[5]=r[5]+d>>>0,r[6]=r[6]+p>>>0,r[7]=r[7]+u>>>0}const c=new Uint8Array(32),d=new DataView(c.buffer);for(let t=0;t{const e="abcdefghijklmnopqrstuvwxyz234567";let s=0,i=0,o="";for(const a of t)for(i=i<<8|a,s+=8;s>=5;)o+=e[i>>>s-5&31],s-=5;return s&&(o+=e[i<<5-s&31]),o},un=(t,e,s,i,o="")=>{const[a,n]=an(e,s),r=`${t}|${sn(a)}|${sn(n)}|${[...i].sort().join(",")}${o}`;return`wall-${pn(dn(r)).slice(0,20)}`};let _n=0;const gn=t=>{for(let e=0;e<1e3;e++){const e=globalThis.crypto?.randomUUID?.(),s=`wall-${e||pn(dn(`${Date.now()}|${_n++}|${Math.random()}`)).slice(0,26)}`;if(!t.has(s))return s}throw new Xa("duplicate-id","id factory exhausted")},mn=t=>{const e=new Map;for(const s of Array.isArray(t?.wall_segments)?t.wall_segments:[])if(s&&"string"==typeof s.id&&tn(s.a)&&tn(s.b)){if(e.has(s.id))throw new Xa("duplicate-id",s.id);e.set(s.id,s)}return e},fn=(t,e,s)=>{const i=(s,i)=>{const o=t[0]-s[0],a=t[1]-s[1];return Math.abs(e[0]-i[0]-o)<=Ya&&Math.abs(e[1]-i[1]-a)<=Ya?[o,a]:null};return i(s.a,s.b)||i(s.b,s.a)},bn=(t,e)=>{const s=Array.isArray(t.rooms)?t.rooms:[],i=Y(t.open_spans).map(t=>[t.a[0],t.a[1],t.b[0],t.b[1]]),o=i.length?i:X(s,null,1,.04*z,!0),a=[];for(const t of s){const s=N(t),i=Array.isArray(t?.wall_ids)?t.wall_ids:[];if(s&&i.length===s.length)for(let t=0;t"partition"!==t.host?.kind&&[Number(t.x),Number(t.y)].every(Number.isFinite)&&Number.isFinite(Number(t.angle))&&Number(t.length)>0&&o.some(e=>hn([Number(t.x),Number(t.y)],[e[0],e[1]],[e[2],e[3]])<=.04*z)):[],l=r.map(t=>{const e=Number(t.angle)*Math.PI/180,s=[Math.cos(e),Math.sin(e)],i=Number(t.length)/2,o=[Number(t.x),Number(t.y)];return{a:[o[0]-s[0]*i,o[1]-s[1]*i],b:[o[0]+s[0]*i,o[1]+s[1]*i]}}),h=(t,e)=>r.some(s=>{const i=[Number(s.x),Number(s.y)];if(!et(t,e,Number(s.angle)))return!1;if(hn(i,t,e)>.02*z)return!1;const o=nn(t,e),a=ln(i,t,e)*o,n=Number(s.length)/2;return a+n>=-1e-9&&a-n<=o+Ya}),c=new Map,d=[];for(const i of s){const r=String(i?.id||""),p=N(i);if(!r||!p||p.length<3)throw new Xa("invalid-room",r);const u=Q(s,r,n,z,1,[...t.walls||[],...l]);if(!u||u.poly.length<3)throw new Xa("invalid-room",r);const _=Array.isArray(i.wall_ids)?i.wall_ids:[],g=_.length===p.length;let m=null,f=g;if(f)for(let t=0;tYa||Math.abs(i[1]-m[1])>Ya)){f=!1;break}m=i}const b=[];for(let t=0;t2)throw new Xa("third-owner",n);const d=g?_[u.parent[t]]:void 0;if("string"==typeof d&&d){const o=e.get(d);f||!o||cn(s,i,o.a,o.b)>Ya?l.preferredIds.add(d):l.positionalIds.add(d),l.preferredCarriers.set(d,{a:en(p[u.parent[t]]),b:en(p[(u.parent[t]+1)%p.length])})}const m=u.parent[t];l.parentKeys.add(Z(p[m],p[(m+1)%p.length],z));const v=[(s[0]+i[0])/2,(s[1]+i[1])/2],y=t=>t.some(t=>hn(v,[t[0],t[1]],[t[2],t[3]])<=.04*z);l.zeroWall||=y(a)||y(o)&&!h(s,i),b.push(n)}const v={...i};delete v.wall_ids,d.push({...v,poly:u.poly.map(t=>[t[0],t[1]]),wall_ids:b})}return{atoms:[...c.values()].sort((t,e)=>t.key.localeCompare(e.key)),rooms:d}},vn=(t,e,s,i,o)=>{const a=new Map([...s.values()].map(t=>[on(t.a,t.b),t])),n=(t=>{const e=new Map;for(const s of t)"wall"===s.host?.kind&&e.set(s.host.id,(e.get(s.host.id)||0)+1);return e})(t.openings||[]),r=new Map;for(const t of e){const e=o?.get(t.key);if(e){const i=s.get(e);if(!i)throw new Xa("duplicate-id",e);r.set(t,i);continue}if(t.preferredIds.size>1)throw new Xa("duplicate-id",[...t.preferredIds].sort().join(","));const i=[...t.preferredIds][0],l=i?s.get(i):void 0;if(l){r.set(t,l);continue}const h=i?t.preferredCarriers.get(i):void 0;if(i&&h){r.set(t,{id:i,a:h.a,b:h.b,cm:0});continue}const c=a.get(t.key);if(c){r.set(t,c);continue}const d=[...s.values()].filter(e=>cn(t.a,t.b,e.a,e.b)>Ya),p=[...new Map(d.map(t=>[t.id,t])).values()];if(p.sort((t,e)=>(n.get(e.id)||0)-(n.get(t.id)||0)||nn(e.a,e.b)-nn(t.a,t.b)||t.id.localeCompare(e.id)),p[0])r.set(t,p[0]);else if(1===t.positionalIds.size){const e=s.get([...t.positionalIds][0]);e&&r.set(t,e)}}const l=new Map;for(const[t,e]of r){const s=l.get(e.id)||[];s.push(t),l.set(e.id,s)}for(const[t,e]of l){const i=s.get(t)||r.get(e[0]);if(!i)throw new Xa("duplicate-id",t);const o=[(i.a[0]+i.b[0])/2,(i.a[1]+i.b[1])/2];e.sort((t,e)=>{const s=hn(o,t.a,t.b)<=Ya?0:1,a=hn(o,e.a,e.b)<=Ya?0:1;if(s!==a)return s-a;return(hn(i.a,t.a,t.b)<=Ya?0:1)-(hn(i.a,e.a,e.b)<=Ya?0:1)||t.key.localeCompare(e.key)}),e[0].id=t}const h=(t=>{const e=new Set;for(const s of[t.rooms,t.openings,t.decor,t.room_drafts,t.partitions,t.wall_columns])for(const t of Array.isArray(s)?s:[])"string"==typeof t?.id&&t.id&&e.add(t.id);for(const s of Array.isArray(t.room_drafts)?t.room_drafts:[])for(const t of Array.isArray(s?.segments)?s.segments:[])"string"==typeof t?.id&&t.id&&e.add(t.id);return e})(t);for(const t of e)if(t.id){if(h.has(t.id))throw new Xa("duplicate-id",t.id);h.add(t.id)}const c=e.filter(t=>!t.id);if(i){const e=c.map(e=>{const[s,i]=an(e.a,e.b),o=`${String(t.id||"")}|${sn(s)}|${sn(i)}|${[...e.owners].sort().join(",")}`,a=pn(dn(o));return{atom:e,seed:o,digest:a,base:`wall-${a.slice(0,20)}`}}).sort((t,e)=>t.digest.localeCompare(e.digest)||t.atom.key.localeCompare(e.atom.key)),s=new Map;for(const t of e){const e=s.get(t.digest);if(e&&e!==t.seed)throw new Xa("duplicate-id",t.digest);s.set(t.digest,t.seed);let i=1,o=t.base;for(;h.has(o);)o=`${t.base}-${++i}`;t.atom.id=o,h.add(o)}}else for(const t of c)t.id=gn(h),h.add(t.id)},yn=(t,e)=>{if("partition"===t.host?.kind)return null;const s=[Number(t.x),Number(t.y)];if(!s.every(Number.isFinite))return null;const i=e=>{if(!(Number(e.cm)>0))return!1;const i=ln(s,e.a,e.b),o=nn(e.a,e.b),a=Number(t.length)/2;return i>=-1e-9&&i<=1+Ya&&hn(s,e.a,e.b)<=.02*z&&et(e.a,e.b,Number(t.angle))&&Number.isFinite(a)&&a>=0&&i*o-a>=-1e-9&&i*o+a<=o+Ya},o="wall"===t.host?.kind?e.find(e=>e.id===t.host.id):null,a=o&&i(o)?[o]:e.filter(i);if(1!==a.length)return null;const n=a[0];return{kind:"wall",id:n.id,t:Math.max(0,Math.min(1,ln(s,n.a,n.b)))}},$n=(t,e)=>{const s=[Number(t.x),Number(t.y)];if(!s.every(Number.isFinite))return null;const i=Number(t.length)/2,o=e.filter(e=>{if(!(Number(e.cm)>0))return!1;const o=ln(s,e.a,e.b),a=nn(e.a,e.b);return o>=-1e-9&&o<=1+Ya&&hn(s,e.a,e.b)<=.02*z&&et(e.a,e.b,Number(t.angle))&&Number.isFinite(i)&&i>=0&&o*a-i>=-1e-9&&o*a+i<=a+Ya}),a=(e=>{if(!e.length)return null;const i="wall"===t.host?.kind?e.find(e=>e.id===t.host.id):null;return i||[...e].sort((t,e)=>hn(s,t.a,t.b)-hn(s,e.a,e.b)||Number(e.cm)-Number(t.cm)||(t.ide.id?1:0))[0]})(o);return a?{kind:"wall",id:a.id,t:Math.max(0,Math.min(1,ln(s,a.a,a.b)))}:null},wn=/^[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/,kn=t=>{if("number"!=typeof t&&"string"!=typeof t)return null;if("string"==typeof t&&!wn.test(t.trim()))return null;const e=Number(t);return Number.isFinite(e)?e:null},xn=t=>{if(!Array.isArray(t)||t.length<2)return null;const e=kn(t[0]),s=kn(t[1]);return null==e||null==s?null:[e,s]},Mn=t=>"string"==typeof t?t:"",Cn=t=>{if(!Object.prototype.hasOwnProperty.call(t,"room_drafts"))return{drafts:0,segments:0};const e=Array.isArray(t.room_drafts)?t.room_drafts:[];if(!e.length)return delete t.room_drafts,{drafts:0,segments:0};const s=new Set;for(const e of[t.rooms,t.openings,t.decor,t.partitions,t.wall_columns,t.wall_segments])for(const t of Array.isArray(e)?e:[])"string"==typeof t?.id&&t.id&&s.add(t.id);for(const t of e)"string"==typeof t?.id&&t.id&&s.add(t.id);const i=Array.isArray(t.partitions)?[...t.partitions]:[];let o=0;for(const a of e){const e=Mn(a?.id),n=Array.isArray(a?.points)?a.points:[],r=Array.isArray(a?.segments)?a.segments:[];if(n.length<2||r.length!==n.length-1)throw new Xa("zero-length",e);for(let a=0;a+1100)throw new Xa("thickness-conflict",e);let p="string"==typeof c?.id&&c.id?c.id:"";if(!p||s.has(p)){const i=un(Mn(t.id),l,h,[`draft:${e}:${a}`]);p=i;for(let t=2;s.has(p);t++)p=`${i}-${t}`}s.add(p),i.push({id:p,a:en(l),b:en(h),cm:d}),o++}}return i.length?t.partitions=i:delete t.partitions,delete t.room_drafts,{drafts:e.length,segments:o}},Sn=t=>Cn(t),Pn=(t,e,s)=>{const i=Cn(t),o=mn(t),{atoms:a,rooms:n}=bn(t,o);vn(t,a,o,e,s);const r=a.map(e=>{const s=e.id?o.get(e.id):void 0,i=((t,e,s)=>{if(e.zeroWall)return 0;const i=Array.isArray(t.walls)?t.walls:[],o=Z(e.a,e.b,z),a=i.filter(t=>Number(t.cm)>0&&(!(t.key!==o&&!e.parentKeys.has(t.key))||!(!tn(t.a)||!tn(t.b))&&cn(e.a,e.b,t.a,t.b)>=nn(e.a,e.b)-Ya)).map(t=>Math.max(1,Math.min(100,Number(t.cm))));if(new Set(a.map(t=>t.toFixed(9))).size>1)throw new Xa("thickness-conflict",e.key);if(a.length)return a[0];const n=it(i,e.a,e.b,z,1);return n>0?n:Number(s?.cm)>0?Number(s.cm):0})(t,e,s);return{...s||{},id:e.id,a:[...e.a],b:[...e.b],cm:i}}),l=new Map(a.map(t=>[t.key,t.id]));for(const t of n)t.wall_ids=t.wall_ids.map(t=>l.get(t));t.rooms=n,t.wall_segments=r,t.walls=r.filter(t=>t.cm>0).map(t=>({key:Z(t.a,t.b,z),cm:t.cm,a:[...t.a],b:[...t.b]})),t.walls.length||delete t.walls,delete t.open_spans;for(const e of t.rooms)delete e.open_to;return((t,e,s)=>{const i=Array.isArray(t.openings)?t.openings:[];for(const t of i){if("partition"===t.host?.kind)continue;if(!t.host&&!s){const s=yn(t,e);s&&(t.host=s);continue}const i=yn(t,e)??(s?$n(t,e):null);if(i)t.host=i;else{if(!s)throw new Xa("opening-host",t.id);delete t.host}}})(t,r,e),{wallSegments:r.reduce((t,e)=>t+(o.has(e.id)?0:1),0),drafts:i.drafts,draftSegments:i.segments}};function Dn(t,e={}){const s=JSON.stringify(t),i=Qa(t);J(i);let o=0,a=0,n=0;const r=Number(i?.model_version||0)<10;for(const t of Array.isArray(i?.spaces)?i.spaces:[]){const s=e.lineageSpaceId===String(t?.id||"")?e.lineageHints:void 0,i=Pn(t,r,s);o+=i.wallSegments,a+=i.drafts,n+=i.draftSegments}return i.model_version=10,J(i),{config:i,changed:s!==JSON.stringify(i),migratedSegments:o,migratedDrafts:a,migratedDraftSegments:n}}const In=t=>!!t&&"object"==typeof t&&!Array.isArray(t);function Ln(t,e){const s=(t,e)=>{if(Array.isArray(t)&&Array.isArray(e)){const i=new Map;for(const e of t)In(e)&&"string"==typeof e.id&&e.id&&i.set(e.id,e);const o=e.map((e,o)=>{if(In(e)&&"string"==typeof e.id&&e.id){const t=i.get(e.id);return t?s(t,e):Qa(e)}return o[e,e in t?s(t[e],i):Qa(i)]);for(const e of Object.keys(t))delete t[e];for(const[e,s]of i)t[e]=s;return t}return Qa(e)};return s(t,e)}const Tn=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Rn=(t,e,s)=>Math.min(s,Math.max(e,t)),zn=t=>bt({spaces:[t]})[0],Fn=(t,e,s)=>{const i=s>0?s:1,o=t=>`${(t[0]/i).toFixed(12)},${(t[1]/i).toFixed(12)}`,a=o(t),n=o(e);return a0?n:1,l=Math.max(i*r*.02,1e-9),h=[];for(const e of t||[])for(const t of N(e)||[])h.push([t[0],t[1]]);const c=[];for(const t of s||[])Array.isArray(t)&&t.length>=4&&t.slice(0,4).every(Number.isFinite)&&c.push([t[0],t[1]],[t[2],t[3]]);const d=(t,e)=>e.some(e=>Math.hypot(t[0]-e[0],t[1]-e[1])<=2*l),p=new Map;for(const n of t||[]){if(!n?.id)continue;const u=vt(t,n.id,e,s,i,o,a,r);if(u)for(let t=0;t0&&_>0&&n===g&&_!==n))continue;const m=u.poly[i],f=u.poly[(i+1)%u.poly.length],b=Math.hypot(f[0]-m[0],f[1]-m[1]);if(!(b>l&&b<.5*a-1e-9*a))continue;if(d(m,c)||d(f,c))continue;if(d(m,h)&&d(f,h))continue;const v=Fn(m,f,r),y=p.get(v);y?y.targets.add(n):p.set(v,{a:[m[0],m[1]],b:[f[0],f[1]],targets:new Set([n])})}}}let u=e.slice();const _=(t,e)=>Math.hypot(t[0]-e[0],t[1]-e[1])<=2*l,g=(t,e)=>{if(!Array.isArray(t.a)||!Array.isArray(t.b)||t.a.length<2||t.b.length<2)return!1;const s=[Number(t.a[0])*r,Number(t.a[1])*r],i=[Number(t.b[0])*r,Number(t.b[1])*r];return!![...s,...i].every(Number.isFinite)&&(_(s,e.a)&&_(i,e.b)||_(s,e.b)&&_(i,e.a))};for(const t of[...p.values()].filter(t=>1===t.targets.size).sort((t,e)=>Fn(t.a,t.b,r).localeCompare(Fn(e.a,e.b,r)))){const e=[...t.targets][0],s=u.filter(e=>g(e,t));if(new Set(s.map(t=>t.cm)).size>1)continue;let o=!1;u=u.map(s=>g(s,t)?(o=!0,s.cm===e?s:{...s,cm:e}):s),o||(u=j(u,t.a,t.b,e,i,r))}return u}const An=t=>{const e=[];for(const s of t||[]){const t=N(s);if(t?.length)for(let s=0;s"string"==typeof t?.id?t.id:"").filter(Boolean),c=new Set(h),d=new Map;for(const t of h){const e=Ja("space",t);e.layers>0&&Va("space",e.root)&&Za(d,e.root,t)}const p=new Map,u=new Map,_=new Map,g=new Map;for(const t of r){const e="string"==typeof t?.id?t.id:"";if(!e)continue;const s=new Map;for(const i of Array.isArray(t.rooms)?t.rooms:[]){const t="string"==typeof i?.id?i.id:"";if(!t)continue;const o=Ja("room",t);o.layers>0&&Va("room",o.root)&&Za(s,o.root,t),u.has(t)||u.set(t,e),_.has(t)||_.set(t,String(i.name||""));const a="string"==typeof i.area?i.area:"";if(a){const s=g.get(a)||[];s.push({spaceId:e,roomId:t}),g.set(a,s)}}p.set(e,s)}const m=new Set(u.keys()),f=new Map,b=new Map;for(const t of l)"string"==typeof t?.id&&t.id&&(!0===t.removed?b.set(t.id,t):f.set(t.id,t));const v={spaceRefsRemapped:0,roomRefsRemapped:0,positionsRemapped:0,markersDetached:0,positionsUnresolved:0,nestedRefsUnresolved:0,deadSpaceIds:[],orphanRoomLabelsRemoved:0,orphanDevicePositionsRemoved:0,orphanGroupPositionsRemoved:0,liveMissingPositionsRemoved:0,removedPositions:[],liveMissingPositions:[],unverifiedPositions:[]},y=new Set,$=t=>c.has(t)?null:(()=>{const e=Ja("space",t).root;if(!Va("space",e))return null;const s=d.get(e)||[];return 1===s.length?s[0]:null})(),w=(t,e)=>{const s=Ja("room",t).root;if(!Va("room",s))return null;const i=p.get(e)?.get(s)||[];return 1===i.length?i[0]:null},k=t=>{const e=s.effectiveAreaByMarker?.[t]||"",i=e&&g.get(e)||[];return 1===i.length?i[0]:null},x=(t,e,s)=>{if("string"==typeof t.room_id&&t.room_id&&!m.has(t.room_id)){const i=e?w(t.room_id,e):null;i?(t.room_id=i,v.roomRefsRemapped++):s?(t.room_id=s.roomId,v.roomRefsRemapped++):!0!==t.removed&&delete t.room_id}const i=t.vacuum?.segment_map;if(i&&"object"==typeof i&&!Array.isArray(i))for(const t of Object.keys(i)){const s=i[t];if("string"!=typeof s||!s||m.has(s))continue;const o=e?w(s,e):null;o?(i[t]=o,v.roomRefsRemapped++):v.nestedRefsUnresolved++}};for(const t of l){const e="string"==typeof t?.id?t.id:"";if(!e)continue;const s="string"==typeof t.space?t.space:"",i=s&&!c.has(s),a=o[e],n="string"==typeof a?.s?a.s:"",r=n&&!c.has(n),l=!0===t.removed;let h=s&&c.has(s)?s:null,d=null,p=!1;if(i){const i=$(s);i?(t.space=i,h=i,p=!0,v.spaceRefsRemapped++):l||"virtual"===t.binding?l||(delete t.space,h=null,v.markersDetached++):(d=k(e),d?(t.space=d.spaceId,h=d.spaceId,v.spaceRefsRemapped++):(delete t.space,h=null,v.markersDetached++))}l&&!p||x(t,h,d),r&&p&&n===s&&h&&(o[e]={...a,s:h},v.positionsRemapped++,y.add(e))}for(const t of Object.keys(o)){if(y.has(t))continue;const e=o[t],s="string"==typeof e?.s?e.s:"";if(!s||c.has(s))continue;const i=$(s);if(i){if(t.startsWith("rl_")){const s=t.slice(3),a=w(s,i);if(a){const s=`rl_${a}`;Ka(o,s)||(o[s]={...e,s:i}),delete o[t],v.roomRefsRemapped++,v.positionsRemapped++;continue}}o[t]={...e,s:i},v.positionsRemapped++}}const M=s.ownerRoster,C=!0===M?.authoritative,S=new Set(M?.deviceIds||[]),P=new Set(M?.entityIds||[]),D=new Set(Array.isArray(i.settings?.known_devices)?i.settings.known_devices.filter(t=>"string"==typeof t):[]),I=(t,e="")=>{const s=String(M?.names?.[t]||e||"").trim();return s&&s!==t?s:""},L=(t,e,s,i="",o)=>({id:t,spaceId:e,kind:s,name:I(t,i),...o?{reason:o}:{}}),T=t=>{"room_label"===t?v.orphanRoomLabelsRemoved++:"group"===t?v.orphanGroupPositionsRemoved++:v.orphanDevicePositionsRemoved++},R=new Set;for(const[t,e]of Object.entries(o)){const i="string"==typeof e?.s?e.s:"";if(!i||c.has(i))continue;let a,n;const r=f.get(t),l=b.get(t);if(r)a=L(t,i,"device",String(r.name||"")),n="live";else if(l)a=L(t,i,"device",String(l.name||"")),n="absent";else if(t.startsWith("rl_")){const e=t.slice(3);a=L(t,i,"room_label",_.get(e)||""),n=m.has(e)?"live":"absent"}else if(t.startsWith("lg_")){const e=t.slice(3);a=L(t,i,"group"),n=P.has(e)?"live":C?"absent":"unverified","unverified"===n&&(a.reason="registry_unavailable")}else S.has(t)?(a=L(t,i,"device"),n="live"):D.has(t)?(a=L(t,i,"device"),n=C?"absent":"unverified","unverified"===n&&(a.reason="registry_unavailable")):(a=L(t,i,"unknown","","unknown_owner"),n="unverified");if("absent"!==n){if("live"===n){if(v.liveMissingPositions.push(a),!0===s.removeLiveMissingPositions){delete o[t],v.liveMissingPositionsRemoved++,T(a.kind),v.removedPositions.push(a);continue}}else v.unverifiedPositions.push(a);v.positionsUnresolved++,R.add(i)}else delete o[t],T(a.kind),v.removedPositions.push(a)}return v.deadSpaceIds=[...R].sort((t,e)=>t.localeCompare(e)),{config:i,layout:o,report:v,changed:JSON.stringify(i)!==a||JSON.stringify(o)!==n}}(t,e,s),n=a.config,r=ot(n,a.layout);J(n),at(a.layout);const l=JSON.stringify(t||{}),h=JSON.stringify(e||{}),c=Number.isInteger(Number(n.model_version))?Number(n.model_version):0,d=(t=>{let e=0,s=0,i=0;for(const s of t.markers||[]){if("ripple"===s.display&&(s.display="icon_ripple",e++),Array.isArray(s.controls)){const t="string"==typeof s.binding&&s.binding.startsWith("entity:")?s.binding.slice(7):"",i=t?s.controls.filter(e=>e!==t):s.controls;JSON.stringify(i)!==JSON.stringify(s.controls)&&(s.controls=i.length?i:null,e++)}const t=s.vacuum;t&&Tn(t,"trail")&&(["never","cleaning","always"].includes(t.trail_mode)||(t.trail_mode=!1===t.trail?"never":"cleaning"),delete t.trail,e++)}for(const o of t.spaces||[]){const t=o.settings;"glow"===t?.fill_mode&&("boolean"!=typeof t.glow_enabled&&(t.glow_enabled=!0),t.fill_mode="none",e++,s++);for(const t of o.rooms||[]){const s=t.settings;"glow"===s?.fill_mode&&("boolean"!=typeof s.glow&&(s.glow=!0),delete s.fill_mode,e++,i++)}if(Tn(o,"segments")&&(delete o.segments,e++),Tn(o,"plan_scale")){const t=Number(o.plan_scale);Number.isFinite(t)&&t>=pt&&t<=ut&&(Tn(o,"plan_scale_x")||(o.plan_scale_x=t),Tn(o,"plan_scale_y")||(o.plan_scale_y=t),delete o.plan_scale,e++)}const a=Number(o.cell_cm);Tn(o,"cell_cm")&&(!Number.isFinite(a)||a<.1||a>1e3)&&(o.cell_cm=Number.isFinite(a)&&a>0?Rn(a,.1,1e3):5,e++);const n=Number(o.cell_cm),r=Number.isFinite(n)&&n>0?n:5;for(const t of o.wall_columns||[])if("circle"===t.shape)Tn(t,"angle")&&(delete t.angle,e++);else if("square"===t.shape&&Tn(t,"angle")){const s=((Number(t.angle)||0)%90+90)%90;t.angle!==s&&(t.angle=s,e++)}for(const t of o.decor||[]){if(Tn(t,"width")){const s=Number(t.width);(Tn(t,"width_cm")||Number.isFinite(s))&&(Tn(t,"width_cm")||(t.width_cm=Number(Rn(s/ct*r,.1,100).toFixed(6))),delete t.width,e++)}if("rect"!==t?.kind&&"ellipse"!==t?.kind||!0!==t.fill||(Tn(t,"fill_color")||(t.fill_color=t.color||"#607d8b",e++),Tn(t,"fill_opacity")||(t.fill_opacity=.25,e++)),"text"!==t?.kind)continue;void 0===t.size_cm?(t.size_cm=Number(Rn(_t*gt(t)/ct*r,.1,2e3).toFixed(6)),delete t.scale,delete t.size,e++):(Tn(t,"scale")||Tn(t,"size"))&&(delete t.scale,delete t.size,e++);let s=String(t.text??"");const i=[...s.matchAll(/\{([^{}\r\n]+)\}/g)].some(t=>!!mt(t[1]));if(!(Tn(t,"entity")||Tn(t,"attr")||Tn(t,"unit")))continue;const o=String(t.unit??"").trim(),a="state"===String(t.attr??"").trim().toLowerCase()?null:t.attr,n=i||o?"":ft(t.entity,a);if(i||n){if(n){const e=s.indexOf("{}");s=e>=0?s.slice(0,e)+n+s.slice(e+2):`${s}${s?" ":""}${n}`,t.text=s}delete t.entity,delete t.attr,delete t.unit,e++}}}return{total:e,glowSpaces:s,glowRooms:i}})(n);let p=d.total,u=0,_=0,g=0;if(c<10)for(const t of Array.isArray(n.spaces)?n.spaces:[]){const e=Sn(t);_+=e.drafts,g+=e.segments}const m=(f=n.spaces||[],JSON.parse(JSON.stringify(f)));var f;const b=wa(n.spaces||[],a.layout);let v=0,y=0,$=0,w="";const k=b.spaces.map(t=>{const e=nt(t);v+=e.report.wallsStraightened,y+=e.report.wallsStraightenSkipped;const s=Number(t?.cell_cm)>0?Number(t.cell_cm):5,i=e.report.maxStraightenShift/z*s;return i>$&&($=i,w=String(t?.id||"")),e.space}),x=v?wa(k,b.layout):{...b,spaces:k};n.spaces=x.spaces;const M=v?{...b.report,moved:b.report.moved+x.report.moved,coordsCanonicalized:b.report.coordsCanonicalized+x.report.coordsCanonicalized,maxShift:Math.max(b.report.maxShift,x.report.maxShift),maxShiftCm:Math.max(b.report.maxShiftCm,x.report.maxShiftCm),maxSpace:x.report.maxShiftCm>b.report.maxShiftCm?x.report.maxSpace:b.report.maxSpace,rotated:b.report.rotated+x.report.rotated}:{...b.report};let C=0,S=0,P=0,D=0,I=0,L=0,T=0;for(let t=0;t0===Number(t.cm)),walls:e.walls||[]}),a=zn(e),r=zn(s);if(!a||!r)continue;const l=An(a.rooms),h=An(r.rooms),c=.02*ct,d=(e.wall_segments||[]).filter(t=>0===Number(t.cm)).map(t=>({...t,key:Z(t.a,t.b,z),cm:0})),p=new Set(d.map(t=>t.key)),u=rt(e,a.rooms,lt,c);S+=u.length;for(const t of u){const e=[t[0]/lt,t[1]/lt],s=[t[2]/lt,t[3]/lt],i=Z(e,s,z);p.has(i)||(p.add(i),d.push({key:i,a:e,b:s,cm:0}))}const _=d.length,g=ht(d,l,h,z,lt),f=(t,e,s)=>{const i=s[0]-e[0],o=s[1]-e[1],a=i*i+o*o;if(!(a>0))return Math.hypot(t[0]-e[0],t[1]-e[1]);const n=Math.max(0,Math.min(1,((t[0]-e[0])*i+(t[1]-e[1])*o)/a));return Math.hypot(t[0]-(e[0]+i*n),t[1]-(e[1]+o*n))},b=g.filter(t=>{if(!Array.isArray(t.a)||!Array.isArray(t.b))return!1;const e=t.a.map(t=>t*lt),s=t.b.map(t=>t*lt);return h.some(([t,i])=>f(e,t,i)<=4*c&&f(s,t,i)<=4*c)});P+=Math.max(0,_-b.length);const v=(s.wall_segments||[]).filter(t=>Number(t.cm)>0);s.wall_segments=[...v,...b.map(({key:t,...e})=>e)];const y=b.map(t=>[t.a[0]*lt,t.a[1]*lt,t.b[0]*lt,t.b[1]*lt]),$=Array.isArray(e.walls)?e.walls.length:0;let w=ht(e.walls,l,h,z,lt);w=Nn(r.rooms,w,y,z,Number(s.cell_cm)>0?Number(s.cell_cm):5,ct,lt),w=G(r.rooms,w,y,z,Number(s.cell_cm)>0?Number(s.cell_cm):5,ct,lt),w=dt(w,s.rooms||[],z,1,y.map(t=>[t[0]/lt,t[1]/lt,t[2]/lt,t[3]/lt])),C+=Math.max(0,$-w.length),w.length?s.walls=w:delete s.walls;const k=Da(s.partitions||[],{pitch:z,geometry:La(s)});k.merged&&(D+=k.merged,s.partitions=k.partitions,Ia(s.openings,s.partitions,k.openingMoves,{coordScale:lt,cellCm:Number(s.cell_cm)>0?Number(s.cell_cm):5,gridPitch:ct}));const x=zn(s);if(x){const t=o(s,x,s.walls||[],y,{pitch:z,cellCm:Number(s.cell_cm)>0?Number(s.cell_cm):5,gridPitch:ct,coordScale:lt});t.partitionsReconciled&&(I+=t.partitionsReconciled,L+=t.openingsRehosted,t.partitions.length?s.partitions=t.partitions:delete s.partitions,t.openings.length?s.openings=t.openings:delete s.openings,t.walls.length?s.walls=t.walls:delete s.walls)}JSON.stringify({zero:(s.wall_segments||[]).filter(t=>0===Number(t.cm)),walls:s.walls||[]})!==i&&T++}if(c<=10){const t=function(t){const e=Dn(t);return Ln(t,e.config),{...e,config:t}}(n);u+=t.migratedSegments,_+=t.migratedDrafts,g+=t.migratedDraftSegments}const R=J(n),F=at(x.layout),N=JSON.stringify(R)!==l||JSON.stringify(F)!==h;c<10&&N&&(R.model_version=10);const A=JSON.stringify(R)!==l||JSON.stringify(F)!==h,E=Number.isInteger(Number(R.model_version))?Number(R.model_version):c,O=A?M:{...M,moved:0,coordsCanonicalized:0,maxShift:0,maxShiftCm:0,maxSpace:"",rotated:0},H=A?a.report:{...a.report,spaceRefsRemapped:0,roomRefsRemapped:0,positionsRemapped:0,markersDetached:0,orphanRoomLabelsRemoved:0,orphanDevicePositionsRemoved:0,orphanGroupPositionsRemoved:0,liveMissingPositionsRemoved:0};return{config:R,layout:F,report:{...O,modelFrom:c,modelTo:E,migrated:A?p:0,glowSpacesMigrated:A?d.glowSpaces:0,glowRoomsMigrated:A?d.glowRooms:0,canonicalized:A?T:0,wallSegmentsMigrated:A?u:0,roomDraftsMigrated:A?_:0,roomDraftSegmentsMigrated:A?g:0,legacyZeroWallsMigrated:A?S:0,wallsMerged:A?C:0,spansMerged:A?P:0,partitionsMerged:A?D:0,partitionsReconciled:A?I:0,openingsRehosted:A?L:0,wallsStraightened:A?v:0,wallsStraightenSkipped:y,maxStraightenShiftCm:A?$:0,maxStraightenSpace:A?w:"",latticeCoordinatesCanonicalized:A?r.canonicalized:0,latticeCoordinatesFar:A?r.far:0,latticeMaxShift:A?r.maxShift:0,latticeMaxShiftCm:A?r.maxShiftCm:0,latticeSpaces:A?r.spaces:[],...H},changed:A}}async function On(t,e,s){t._saveConfigDebounced.pending()&&t._saveConfigDebounced.flush(),await t._writeChain;const i=await t.hass.callWS({type:"houseplan/plan/optimize",config:e,layout:s,expected_config_rev:t._cfgRev,expected_layout_rev:t._layoutRev});t._adoption.acceptPairWrite(e,s,i),t._geometryHistory.clear(),t._cancelDeviceDrag(),t._devicePositionHistory.clear(),t._canOptimizeUndo=!0===i.can_undo,t._undoKind=!0===i.can_undo?"optimize":null,t._dirtyPos.clear(),t._sentPos.clear(),t._cfgEpoch++,t._modelCache=null,t._frame=null,t._regSignature="",t._maybeRebuildDevices(),t._cacheSnapshot(),t.requestUpdate()}const Hn=Object.freeze({spaces:50,partitions:2e3,openings:500,decor:1e3,columns:500});class Bn extends Error{constructor(t){super(t),this.code=t,this.name="SpaceCopyError"}}const Wn=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),jn=t=>void 0===t?t:JSON.parse(JSON.stringify(t)),Gn=t=>null===t||"object"!=typeof t||Array.isArray(t)?null:t;function qn(t,e=!1){if(void 0===t&&!e)return[];if(!Array.isArray(t))throw new Bn("source_invalid");return t.map(t=>{const e=Gn(t);if(!e||"string"!=typeof e.id||!e.id)throw new Bn("source_invalid");return e})}const Un=t=>Array.isArray(t)&&2===t.length&&t.every(t=>Number.isFinite(t));function Kn(t,e,s){const i=String(t??"").trim()||s,o=new Set(e.map(t=>{const e=Gn(t);return String(e?.title??"").trim()}));let a=2;for(;o.has(`${i} (${a})`);)a++;return`${i} (${a})`}const Vn=["settings","zero_wall_style","cell_cm","view_box","plan_url","plan_aspect","plan_x","plan_y","plan_scale","plan_scale_x","plan_scale_y","plan_angle"];const Jn={source_missing:"space.copy_error_source_missing",source_invalid:"space.copy_error_source_invalid",spaces_limit:"space.copy_error_spaces_limit",partitions_limit:"space.copy_error_partitions_limit",openings_limit:"space.copy_error_openings_limit",decor_limit:"space.copy_error_decor_limit",columns_limit:"space.copy_error_columns_limit",opening_host_missing:"space.copy_error_opening_host",opening_host_unknown:"space.copy_error_opening_host",geometry_unsafe:"space.copy_error_geometry"};let Zn=0;function Yn(t,e,s){const i=t._spaceDialog;return!(!i?.copy||i.copy.token!==e)&&(t._spaceDialog={...i,busy:s,copy:{...i.copy,busy:s}},!0)}function Xn(t){t._cfgEpoch++,t._modelCache=null,t._frame=null,t._regSignature="",t._maybeRebuildDevices(),t.requestUpdate()}async function Qn(t,e){const s=t._spaceDialog;if(!s?.copy||"edit"!==s.mode||s.busy||s.copy.busy||!s.copy.title.trim()||!s.spaceId||!t._serverCfg)return;const i=++Zn,o=s.spaceId,a=s.copy.title.trim();t._spaceDialog={...s,busy:!0,copy:{...s.copy,title:a,busy:!0,token:i}};let n=!1;try{if(t._saveConfigDebounced.pending()&&t._saveConfigDebounced.flush(),await t._writeChain,!Yn(t,i,!0)||!t._serverCfg)return;const s=t._cfgRev,r=t._layoutRev,l=yt(t._serverCfg),h=yt(t._layout);let c;try{c=(e.optimize??En)(t._serverCfg,t._layout,e.optimizeReferenceContext())}catch(s){return Yn(t,i,!1),void e.showWallModelMigrationBlocked(s)}if(c.changed){const d=t._checkOptimizeGeometry(c.config);if(e.reportPreflightFailure(d,c.config),!d.ok)return Yn(t,i,!1),void t._showToast(t._t("space.copy_error_optimize_geometry"));const p=await t._confirmDanger({key:`copy-space:${o}`,kind:"warning",title:t._t("space.copy_optimize_title"),message:t._t("space.copy_optimize_body",{name:a}),objectName:a,confirmLabel:t._t("space.copy_optimize_confirm"),cancelLabel:t._t("btn.cancel"),icon:"mdi:broom"});if(!Yn(t,i,p))return;if(!p)return;if(t._cfgRev!==s||t._layoutRev!==r||!t._serverCfg||yt(t._serverCfg)!==l||yt(t._layout)!==h)return Yn(t,i,!1),void t._showToast(t._t("space.copy_error_changed"));e.clearGeometryGesture(),await On(t,c.config,c.layout),n=!0}if(!Yn(t,i,!0)||!t._serverCfg)return;const d=t._serverCfg,p=function(t,e,s,i){const o=t.spaces;if(!s.trim())throw new Bn("source_invalid");if(o.length>=Hn.spaces)throw new Bn("spaces_limit");const a=o.findIndex(t=>t.id===e);if(a<0)throw new Bn("source_missing");const n=o[a];if(!Array.isArray(n.view_box))throw new Bn("source_invalid");const r=qn(n.wall_segments,!0),l=qn(n.partitions),h=qn(n.openings),c=qn(n.decor),d=qn(n.wall_columns);if(r.length+l.length>Hn.partitions)throw new Bn("partitions_limit");if(h.length>Hn.openings)throw new Bn("openings_limit");if(c.length>Hn.decor)throw new Bn("decor_limit");if(d.length>Hn.columns)throw new Bn("columns_limit");let p=0;const u=t=>`${t}${i}${(p++).toString(36)}`,_=new Map,g=new Map,m=[];for(const t of r){if(_.has(t.id)||!Un(t.a)||!Un(t.b)||"number"!=typeof t.cm||!Number.isFinite(t.cm))throw new Bn("source_invalid");const e=u("cw");_.set(t.id,e),m.push({id:e,a:jn(t.a),b:jn(t.b),cm:t.cm})}for(const t of l){if(g.has(t.id)||!Un(t.a)||!Un(t.b)||"number"!=typeof t.cm||!Number.isFinite(t.cm))throw new Bn("source_invalid");const e=u("cp");g.set(t.id,e),m.push({id:e,a:jn(t.a),b:jn(t.b),cm:t.cm})}const f=h.map(t=>{const e=Gn(t.host);if(!e||"string"!=typeof e.id||"string"!=typeof e.kind)throw new Bn("opening_host_missing");const s="wall"===e.kind?_.get(e.id):"partition"===e.kind?g.get(e.id):void 0;if(!s)throw new Bn("opening_host_unknown");const i={...jn(t),id:u("co"),host:{...jn(e),kind:"partition",id:s}};return delete i.contact,delete i.lock,i}),b=c.map(t=>({...jn(t),id:u("cd")})),v=d.map(t=>({...jn(t),id:u("cc")})),y=`s${i}`;if(o.some(t=>t.id===y))throw new Bn("source_invalid");const $={id:y,title:s.trim(),rooms:[],wall_segments:[],view_box:jn(n.view_box)};for(const t of Vn)"view_box"!==t&&Wn(n,t)&&($[t]=jn(n[t]));m.length&&($.partitions=m),f.length&&($.openings=f),b.length&&($.decor=b),v.length&&($.wall_columns=v);const w=jn(t);return w.spaces.splice(a+1,0,$),{config:w,space:$,sourceIndex:a}}(d,o,a,e.newSeed?.()??function(t=Date.now(),e=Math.random()){const s=Math.floor(16777216*Math.max(0,Math.min(.999999999,e))).toString(36).padStart(5,"0");return`${Math.max(0,Math.floor(t)).toString(36)}${s}`}());let u=!1;try{u=t._checkSpacePhysicalGeometry(p.config,p.space.id).ok}catch{u=!1}if(!u||t._junctionLimitViolations(p.config,p.space.id).length)throw new Bn("geometry_unsafe");const _=t._adoption.beginOptimistic(d,p.config);t._adoption.stageLocalConfig(p.config),Xn(t);try{await e.saveConfigNow(_)}catch(e){throw t._rollbackOptimistic(_)&&Xn(t),"conflict"!==e?.code&&await t._reloadConfigOnly(!0),e}t._canOptimizeUndo=!1,t._undoKind=null,e.clearGeometryGesture(),t._selId=null,t._physicalSel=null,t._spaceDialog=null,t._commitSpace(p.space.id,!0),e.setMode("plan"),t._tool="draw",t._path=[],t._cursorPt=null,t._activeWallChainId=null,t._activeWallChainPartitionIds=[],t._primeDrawWallField(),t._saveNav(),t.requestUpdate(),t._showToast(t._t("toast.space_copied",{name:a}))}catch(e){"conflict"===e?.code&&await Promise.all([t._reloadConfigOnly(!0),t._reloadLayoutOnly()]),Yn(t,i,!1),function(t,e){if(e instanceof Bn)return void t._showToast(t._t(Jn[e.code]));const s=e?.code;"wall_model_client_outdated"!==s?t._showToast(t._t("toast.error",{err:t._errText(e)})):t._showToast(t._t("toast.wall_model_client_outdated"))}(t,e),n&&t.requestUpdate()}}const tr=1e3;function er(){const t=this.host._spaceDialog;if(t.copy)return function(t,e){const s=t._spaceDialog.copy,i=()=>function(t){const e=t._spaceDialog;!e?.copy||e.busy||e.copy.busy||(t._spaceDialog={...e,copy:void 0})}(t);return p``}const ma=1e-6*z,fa=6*z;function ba(t){return Number.isFinite(t)?Math.round(t/z)*z:t}const va=(t,e,s,i)=>Math.hypot(s-t,i-e),ya=(t,e,s,i,o,a,n,r)=>Math.hypot(Math.max(Math.abs(o-t),Math.abs(o+n-(t+s))),Math.max(Math.abs(a-e),Math.abs(a+r-(e+i)))),$a=(t,e,s,i,o,a,n)=>{const r=Math.max(Number(i)||0,0)/2,l=Math.PI/180,h=Math.cos(s*l)*r,c=Math.sin(s*l)*r,d=Math.cos(n*l)*r,p=Math.sin(n*l)*r,u=Math.max(va(t+h,e+c,o+d,a+p),va(t-h,e-c,o-d,a-p)),_=Math.max(va(t+h,e+c,o-d,a-p),va(t-h,e-c,o+d,a+p));return Math.min(u,_)},wa=t=>{const e=Number(t?.cell_cm);return e>0?e:5};function ka(t,e){const s=JSON.parse(JSON.stringify(t||[])),i=JSON.parse(JSON.stringify(e||{}));let o=0,a=0,n=0,r=0,l="",h=0,c=0;const d=(t,e)=>{Number.isFinite(t)&&Number.isFinite(e)&&t!==e&&Math.abs(e-t)<=ma&&c++},p=(t,e)=>{d(t[0],e[0]),d(t[1],e[1])},u={};let _=5;for(const t of s){const e=wa(t);null!=t?.id&&(u[String(t.id)]=e),e>_&&(_=e)}const g=(t,e,s,i=!1)=>{if(!(t>ma||i))return;o++,t>n&&(n=t);const a=t*F*e;a>r&&(r=a,l=s)};for(const t of s){const e=wa(t),s=null!=t?.id?String(t.id):"";for(const i of t.rooms||[]){a++;let t=0;if(i.poly?.length)i.poly=i.poly.map(e=>{const s=[ba(e[0]),ba(e[1])];return t=Math.max(t,va(e[0],e[1],s[0],s[1])),p(e,s),s});else if(null!=i.x&&null!=i.y){const e=i.x,s=i.y,o=i.w||0,a=i.h||0,n=ba(e+o),r=ba(s+a),l=ba(e),h=ba(s),c=Math.max(z,n-l),p=Math.max(z,r-h);t=ya(e,s,o,a,l,h,c,p),i.x=l,i.y=h,i.w=c,i.h=p,d(e,l),d(s,h),d(e+o,l+c),d(s+a,h+p)}g(t,e,s)}for(const i of t.partitions||[]){a++;const o=[i.a[0],i.a[1]],n=[i.b[0],i.b[1]],r=[ba(o[0]),ba(o[1])],l=[ba(n[0]),ba(n[1])];let h=Math.max(va(o[0],o[1],r[0],r[1]),va(n[0],n[1],l[0],l[1]));const c=va(r[0],r[1],l[0],l[1]),d=(t.openings||[]).filter(t=>"partition"===t.host?.kind&&t.host.id===i.id).every(t=>{const e=Number(t.length),s=Number(t.host.t),i=s*c;return Number.isFinite(e)&&e>0&&Number.isFinite(s)&&s>=0&&s<=1&&i-e/2>=-ma&&i+e/2<=c+ma});c>ma&&d?(i.a=r,i.b=l,p(o,r),p(n,l)):h=0,g(h,e,s)}for(const i of t.wall_columns||[]){a++;const t=[i.center[0],i.center[1]],o=[ba(t[0]),ba(t[1])],n=va(t[0],t[1],o[0],o[1]);i.center=o,p(t,o),g(n,e,s)}for(const i of t.decor||[]){if("furniture"===i.kind||"image"===i.kind)continue;a++;let t=0;if("line"===i.kind){const e=[i.x1,i.y1],s=[i.x2,i.y2],o=[ba(e[0]),ba(e[1])],a=[ba(s[0]),ba(s[1])];t=Math.max(va(e[0],e[1],o[0],o[1]),va(s[0],s[1],a[0],a[1])),i.x1=o[0],i.y1=o[1],i.x2=a[0],i.y2=a[1],p(e,o),p(s,a)}else{const e=i.x,s=i.y,o=i.w,a=i.h,n=ba(e),r=ba(s);if(null!=i.w&&null!=i.h){const l=ba(e+o),h=ba(s+a),c=Math.max(z,l-n),p=Math.max(z,h-r);t=ya(e,s,o,a,n,r,c,p),i.w=c,i.h=p,d(e+o,n+c),d(s+a,r+p)}else t=va(e,s,n,r);i.x=n,i.y=r,d(e,n),d(s,r)}g(t,e,s)}for(const i of t.openings||[]){if(a++,"partition"===i.host?.kind){const o=(t.partitions||[]).find(t=>t.id===i.host.id),a=Number(i.host.t);if(!o||!Number.isFinite(a)||a<0||a>1)continue;const n=o.b[0]-o.a[0],r=o.b[1]-o.a[1];if(Math.hypot(n,r)<=ma)continue;const l=o.a[0]+n*a,c=o.a[1]+r*a;let d=180*Math.atan2(r,n)/Math.PI;d>=90?d-=180:d<-90&&(d+=180);const p=Number(i.angle),u=!(Number.isFinite(p)&&p===d),_=$a(i.x,i.y,Number.isFinite(p)?p:d,Number(i.length)||0,l,c,d);i.x=l,i.y=c,i.angle=d,u&&h++,g(_,e,s,u);continue}const o=R([i.x,i.y],t.rooms||[],fa,{step:z,length:Number(i.length)||0});if(!o)continue;const n=Number(i.angle),r=!(Number.isFinite(n)&&n===o.angle),l=$a(i.x,i.y,Number.isFinite(n)?n:o.angle,Number(i.length)||0,o.x,o.y,o.angle);i.x=o.x,i.y=o.y,i.angle=o.angle,r&&h++,g(l,e,s,r)}}for(const[t,e]of Object.entries(i)){if(!e||"object"!=typeof e)continue;const s=e;if("number"!=typeof s.x||"number"!=typeof s.y)continue;a++;const o=ba(s.x),n=ba(s.y),r=va(s.x,s.y,o,n);i[t]={...s,x:o,y:n},d(s.x,o),d(s.y,n);const l="string"==typeof s.s?s.s:"";g(r,u[l]??_,l)}return{spaces:s,layout:i,report:{moved:o,coordsCanonicalized:c,total:a,maxShift:n,maxShiftCm:r,maxSpace:l,rotated:h},changed:o>0||c>0}}function xa(t,e){const s=e.base+t*e.span;return Math.min(1,Math.max(0,s))}const Ma=t=>Array.isArray(t)&&t.length>=2&&Number.isFinite(t[0])&&Number.isFinite(t[1]),Ca=(t,e)=>Math.hypot(t[0]-e[0],t[1]-e[1]);function Sa(t,e,s){const i=s[0]-e[0],o=s[1]-e[1],a=i*i+o*o;if(a<=0)return Ca(t,e);let n=((t[0]-e[0])*i+(t[1]-e[1])*o)/a;return n=Math.max(0,Math.min(1,n)),Math.hypot(t[0]-(e[0]+i*n),t[1]-(e[1]+o*n))}function Pa(t,e,s,i,o){for(const i of e)if(i&&!s.has(i.id)&&Ma(i.a)&&Ma(i.b)&&(Ca(t,i.a)<=o||Ca(t,i.b)<=o))return!0;for(const e of i?.roomPolygons||[])for(let s=0;s0&&r>0))return null;if(Math.abs(o[0]/n*(a[1]/r)-o[1]/n*(a[0]/r))>s)return null;for(const[s,o]of[[t.a,e.a],[t.a,e.b],[t.b,e.a],[t.b,e.b]])if(Ca(s,o)<=i)return[(s[0]+o[0])/2,(s[1]+o[1])/2];return null}function Ia(t,e){const s=.05*(Number(e.pitch)>0?Number(e.pitch):1),i=new Map;let o=(t||[]).filter(t=>!!t&&"string"==typeof t.id&&Ma(t.a)&&Ma(t.b));if(o.length<2)return{partitions:[...t||[]],merged:0,openingMoves:[]};const a=e.seedIds&&e.seedIds.length?new Set(e.seedIds):null;let n=0;for(let t=0;tCa(e,t.at)>s);let c=h[0]??r.a,d=h[h.length-1]??l.b;if(h.length<2&&(c=r.a,d=l.b),d[0]0?(d[0]-c[0])/u:0,g=u>0?(d[1]-c[1])/u:0,m=t=>u>0?((t[0]-c[0])*_+(t[1]-c[1])*g)/u:0;for(const t of[r,l]){const e=m(t.a),s=m(t.b)-e;for(const[o,a]of i)a.toId===t.id&&i.set(o,{fromId:a.fromId,toId:p.id,base:e+a.base*s,span:a.span*s});i.set(t.id,{fromId:t.id,toId:p.id,base:e,span:s})}a&&a.add(p.id),o=o.filter((e,s)=>s!==t.i&&s!==t.j),o.splice(t.i,0,p),n++}return{partitions:o,merged:n,openingMoves:[...i.values()]}}function La(t,e,s,i){if(!t?.length||!s.length)return 0;const o=new Map(s.map(t=>[t.fromId,t]));let a=0;for(const s of t){const t=s?.host;if(!t||"partition"!==t.kind)continue;const n=o.get(t.id);if(!n)continue;s.host={...t,id:n.toId,t:xa(t.t,n)},a++;const r=A(s,e,i.coordScale,i.cellCm,i.gridPitch).resolved;r&&Object.assign(s,E(s,r,i.coordScale))}return a}function Ta(t){return{roomPolygons:(t?.rooms||[]).map(t=>N(t)).filter(t=>!!t),columns:t?.wall_columns||[]}}const Ra=t=>!!t&&t.length>=2&&Number.isFinite(t[0])&&Number.isFinite(t[1]),za=(t,e)=>t[0]-e[0]||t[1]-e[1],Fa=(t,e,s,i)=>[t[0]+e*i,t[1]+s*i],Na=(t,e,s,i)=>(t[0]-e[0])*s+(t[1]-e[1])*i,Aa=(t,e,s,i,o)=>{const a=e[0]-t[0],n=e[1]-t[1],r=Math.hypot(a,n);if(!(r>o))return null;const l=a/r,h=n/r,c=e=>Math.abs((e[0]-t[0])*h-(e[1]-t[1])*l);if(c(s)>o||c(i)>o)return null;const d=Na(s,t,l,h),p=Na(i,t,l,h),u=Math.max(0,Math.min(d,p)),_=Math.min(r,Math.max(d,p));return _-u>o?{lo:u,hi:_}:null},Ea=(t,e,s)=>Math.min(t.hi,e.hi)-Math.max(t.lo,e.lo)>s,Oa=t=>{const e=new Set(["id","a","b","cm"]);return Object.keys(t||{}).every(t=>e.has(t))},Ha=(t,e,s,i)=>{const o=t.b[0]-t.a[0],a=t.b[1]-t.a[1],n=Math.hypot(o,a);if(!(n>i))return!0;const r=o/n,l=a/n,h=V(t.cm,s.cellCm,s.gridPitch)/2;return e.some(e=>{const o=e?.center;if(!Ra(o))return!0;const a=Na(o,t.a,r,l),c=Math.abs((o[0]-t.a[0])*l-(o[1]-t.a[1])*r),d=V(Number(e.cm),s.cellCm,s.gridPitch)*("square"===e.shape?Math.SQRT1_2:.5);return!(Number.isFinite(d)&&d>0)||a>=-d-i&&a<=n+d+i&&c<=h+d+i})},Ba=(t,e,s)=>{if(t.host){const i=A(t,e,s.coordScale,s.cellCm,s.gridPitch).resolved;return i?{center:i.center,angle:i.angle,length:i.length}:null}const i=Number(t.x)*s.coordScale,o=Number(t.y)*s.coordScale,a=Number(t.angle),n=Number(t.length)*s.coordScale;return[i,o,a,n].every(Number.isFinite)&&n>0?{center:[i,o],angle:a,length:n}:null},Wa=(t,e,s)=>{const i=t.angle*Math.PI/180,o=Math.cos(i),a=Math.sin(i),n=e.angle*Math.PI/180,r=Math.cos(n),l=Math.sin(n);if(Math.abs(o*l-a*r)>1e-6)return!1;const h=e.center[0]-t.center[0],c=e.center[1]-t.center[1];if(Math.abs(h*a-c*o)>s)return!1;const d=h*o+c*a;return Math.max(-t.length/2,d-e.length/2)({...t,a:[t.a[0]*e,t.a[1]*e],b:[t.b[0]*e,t.b[1]*e]}),Ga=(t,e,s,i)=>{const o=`~r-${(t=>{let e=2166136261;for(let s=0;s>>0;return e.toString(36)})(`${t}|${e[0].toFixed(9)},${e[1].toFixed(9)}|${s[0].toFixed(9)},${s[1].toFixed(9)}`)}`,a=`${t.slice(0,Math.max(1,64-o.length))}${o}`;let n=a;for(let t=2;i.has(n);t++){const e=`-${t}`;n=`${a.slice(0,64-e.length)}${e}`}return i.add(n),n},qa=(t,e)=>{const s=[];for(const i of t){const t=s[s.length-1];!(t&&Math.abs(t.hi-i.lo)<=e&&t.safe===i.safe)||i.safe&&t.signature!==i.signature?s.push({lo:i.lo,hi:i.hi,a:i.a,b:i.b,safe:i.safe,signature:i.signature,roomIds:i.roomIds,finalCm:i.finalCm}):(t.hi=i.hi,t.b=i.b)}return s};function Ua(t,e,s,i,o){const a=s||[],n=Array.isArray(t?.partitions)?t.partitions:[],r=Array.isArray(t?.openings)?t.openings:[],l={walls:a,partitions:n,openings:r,partitionsReconciled:0,openingsRehosted:0};if(!n.length)return l;const h=Math.max(2e-4*o.gridPitch,1e-9);let c=a,d=n,p=r,u=0,_=0;const g=o.partitionIds?new Set(o.partitionIds):null,m=new Map(e.partitions.map(t=>[t.id,t]));for(const t of[...n].sort((t,e)=>t.id.localeCompare(e.id))){if(g&&!g.has(t.id))continue;if(!d.some(e=>e.id===t.id))continue;if(!Oa(t))continue;const s=m.get(t.id);if(!(s&&Ra(s.a)&&Ra(s.b)&&Number.isFinite(s.cm)&&(o.allowCoincidentPartitions?!(s.cm<0):s.cm>0)))continue;const[a,n]=za(s.a,s.b)<=0?[[s.a[0],s.a[1]],[s.b[0],s.b[1]]]:[[s.b[0],s.b[1]],[s.a[0],s.a[1]]],r=n[0]-a[0],l=n[1]-a[1],f=Math.hypot(r,l);if(!(f>h))continue;const b=r/f,v=l/f,y=O(e.rooms,c,i,o.pitch,o.cellCm,o.gridPitch,o.coordScale),$=y.flatMap(t=>{if(t.open||"outer"!==t.kind&&"shared"!==t.kind)return[];const e=Aa(a,n,t.a,t.b,h);return e?[{interval:t,range:e}]:[]});if(!$.length)continue;const w=p.filter(t=>"partition"===t.host?.kind&&t.host.id===s.id).map(t=>({opening:t,resolved:A(t,e.partitions,o.coordScale,o.cellCm,o.gridPitch).resolved}));if(w.some(t=>!t.resolved))continue;const k=[0,f];for(const{range:t}of $)k.push(t.lo,t.hi);const x=k.slice(),M=new Map;for(const{opening:t,resolved:e}of w){const s=Na(e.center,a,b,v),i={lo:s-e.length/2,hi:s+e.length/2};M.set(t.id,i),x.push(Math.max(0,i.lo),Math.min(f,i.hi))}const C=[...new Set(x.filter(t=>Number.isFinite(t)&&t>=-h&&t<=f+h).map(t=>Math.max(0,Math.min(f,t)).toFixed(9)))].map(Number).sort((t,e)=>t-e),S=d.map(t=>ja(t,o.coordScale)).filter(t=>t.id!==s.id),P=[];for(let t=0;t+1h))continue;const r=Fa(a,b,v,i),l=Fa(a,b,v,n),c=$.filter(({range:t})=>t.lo<=i+h&&t.hi>=n-h).map(({interval:t})=>t),d=new Map;for(const t of c)d.set(t.roomId,t);const p=[...d.values()],u=new Set(p.map(t=>t.kind)),_=new Set(p.map(t=>o.allowCoincidentPartitions||t.cm>0?t.cm:H)),g=p[0]?.kind,m=[...d.keys()].sort(),f=1===u.size&&1===_.size&&("outer"===g&&1===m.length||"shared"===g&&2===m.length),y={id:s.id,a:r,b:l,cm:s.cm},w=S.some(t=>!!Aa(r,l,t.a,t.b,h)),k=f&&(o.allowCoincidentPartitions||!w)&&!Ha(y,e.wall_columns,o,h),x=f?o.allowCoincidentPartitions||p[0].cm>0?p[0].cm:H:0,M=f?Math.max(x,s.cm):s.cm;P.push({lo:i,hi:n,a:r,b:l,safe:k,signature:k?`${g}|${m.join(",")}|${M}`:"",roomIds:m,roomCm:x,finalCm:M})}if(!P.some(t=>t.safe))continue;const D=new Map;for(const{opening:t,resolved:e}of w){const i=M.get(t.id),a=k.some(t=>t>i.lo+h&&tEa(t,i,h)),r=new Set(n.filter(t=>t.safe).map(t=>t.signature));if(!a&&n.length>0&&n.every(t=>t.safe)&&1===r.size&&B(e,y,h)){D.set(t.id,{resolved:e,signature:[...r][0]});continue}const l=W(s,o.cellCm,o.gridPitch),c={lo:i.lo-l,hi:i.hi+l};for(const t of P)Ea(t,c,h)&&(t.safe=!1,t.signature="")}let I=!0;for(;I;){I=!1;for(const[t,e]of[...D.entries()]){const i=M.get(t),a=P.filter(t=>Ea(t,i,h));if(a.length>0&&a.every(t=>t.safe)&&a.every(t=>t.signature===e.signature))continue;D.delete(t);const n=W(s,o.cellCm,o.gridPitch),r={lo:i.lo-n,hi:i.hi+n};for(const t of P)Ea(t,r,h)&&(t.safe=!1,t.signature="");I=!0}}const L=qa(P,h),T=L.filter(t=>t.safe),R=L.filter(t=>!t.safe);if(!T.length)continue;if(d.length-1+R.length>2e3)continue;let z=c;for(const t of T){const[e,i]=za(s.a,s.b)<=0?[t.a,t.b]:[t.b,t.a];z=j(z,e,i,t.finalCm,o.pitch,o.coordScale)}if(z=G(e.rooms,z,i,o.pitch,o.cellCm,o.gridPitch,o.coordScale),z.length>500)continue;const F=new Set(d.map(t=>t.id));F.delete(s.id);const N=R.map((t,e)=>{const i=[t.a[0]/o.coordScale,t.a[1]/o.coordScale],a=[t.b[0]/o.coordScale,t.b[1]/o.coordScale],n=0===e?s.id:Ga(s.id,i,a,F);return F.add(n),{id:n,a:i,b:a,cm:s.cm}}),V=d.findIndex(t=>t.id===s.id),J=d.slice();J.splice(V,1,...N);const Z=J.map(t=>ja(t,o.coordScale)),Y=new Map;let X=!0;for(const{opening:t,resolved:e}of w){const s=D.get(t.id);if(s){const e=E(t,s.resolved,o.coordScale),{host:i,...a}=e;Y.set(t.id,a);continue}const i=M.get(t.id),a=N[R.findIndex(t=>t.lo<=i.lo+h&&t.hi>=i.hi-h)],n=a&&Z.find(t=>t.id===a.id);if(!a||!n){X=!1;break}const r=n.b[0]-n.a[0],l=n.b[1]-n.a[1],c=Math.hypot(r,l),d=Na(e.center,n.a,r/c,l/c),p={...E(t,e,o.coordScale),host:{kind:"partition",id:a.id,t:d/c}};if(!q(p,Z,o.coordScale,o.cellCm,o.gridPitch).resolved){X=!1;break}Y.set(t.id,p)}if(!X)continue;const Q=p.map(t=>Y.get(t.id)||t),tt=[...D.keys()].map(t=>Y.get(t)),et=tt.map(t=>Ba(t,Z,o));if(et.some(t=>!t))continue;let st=!1;for(let t=0;tt.id));for(const t of Q){if(it.has(t.id))continue;const e=Ba(t,Z,o);e&&et.some(t=>Wa(t,e,h))&&(st=!0)}if(st)continue;const ot=U(e.rooms,z,i,o.pitch,o.cellCm,o.gridPitch,o.coordScale);[...D.entries()].every(([t,e])=>{const s=Y.get(t),i=K(ot,{x:s.x*o.coordScale,y:s.y*o.coordScale,angle:s.angle,length:s.length*o.coordScale},!0),a=[i.negative,i.positive].filter(t=>!!t?.full),n=e.signature.split("|")[1].split(","),r=new Set(a.map(t=>t.roomId));return a.length===n.length&&r.size===n.length&&n.every(t=>r.has(t))})&&(c=z,d=J,p=Q,u+=T.length,_+=D.size)}return{walls:c,partitions:d,openings:p,partitionsReconciled:u,openingsRehosted:_}}const Ka=t=>JSON.parse(JSON.stringify(t)),Va=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Ja=(t,e)=>e.length>0&&e.length<=35&&("space"===t?/^[a-z0-9_-]+$/.test(e):/^[A-Za-z0-9_-]+$/.test(e));function Za(t,e){let s=String(e??"");const i=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=new RegExp(`^${i}_(.+)_([0-9a-f]{8})$`);let a=0;for(;a<16;a++){const t=o.exec(s);if(!t)return{root:s,layers:a,bounded:!1};s=t[1]}return{root:s,layers:a,bounded:o.test(s)}}const Ya=(t,e,s)=>{const i=t.get(e)||[];i.push(s),t.set(e,i)};const Xa=1e-9;class Qa extends Error{constructor(t,e=""){super(e?`${t}: ${e}`:t),this.reason=t,this.name="WallSegmentModelError"}}const tn=t=>JSON.parse(JSON.stringify(t)),en=t=>Array.isArray(t)&&t.length>=2&&Number.isFinite(Number(t[0]))&&Number.isFinite(Number(t[1])),sn=t=>[Number(t[0]),Number(t[1])],on=t=>`${Number(t[0]).toFixed(12)},${Number(t[1]).toFixed(12)}`,an=(t,e)=>{const s=on(t),i=on(e);return son(t)<=on(e)?[sn(t),sn(e)]:[sn(e),sn(t)],rn=(t,e)=>Math.hypot(e[0]-t[0],e[1]-t[1]),ln=(t,e=[])=>{const s=new Set,i=t=>{const e=Number(t);if(!Number.isFinite(e))return;const i=e/z;Math.abs(i-Math.round(i))>=tt&&s.add(e.toFixed(12))};for(const e of Array.isArray(t?.rooms)?t.rooms:[])for(const t of N(e)||[])i(t[0]),i(t[1]);for(const e of[t?.wall_segments,t?.walls])for(const t of Array.isArray(e)?e:[])i(t?.a?.[0]),i(t?.a?.[1]),i(t?.b?.[0]),i(t?.b?.[1]);for(const t of e)i(t?.[0]),i(t?.[1]);return s.size},hn=(t,e,s)=>{const i=s[0]-e[0],o=s[1]-e[1],a=i*i+o*o;return a>1e-18?((t[0]-e[0])*i+(t[1]-e[1])*o)/a:0},cn=(t,e,s)=>{const i=Math.max(0,Math.min(1,hn(t,e,s)));return Math.hypot(t[0]-(e[0]+(s[0]-e[0])*i),t[1]-(e[1]+(s[1]-e[1])*i))},dn=(t,e,s,i,o=1e-9)=>{const a=e[0]-t[0],n=e[1]-t[1],r=Math.hypot(a,n);if(r<=o)return 0;const l=e=>Math.abs((e[0]-t[0])*n-(e[1]-t[1])*a)/r;if(l(s)>o||l(i)>o)return 0;const h=hn(s,t,e),c=hn(i,t,e);return Math.max(0,Math.min(1,Math.max(h,c))-Math.max(0,Math.min(h,c)))*r},pn=t=>{const e=(new TextEncoder).encode(t),s=8*e.length,i=64*Math.ceil((e.length+9)/64),o=new Uint8Array(i);o.set(e),o[e.length]=128;const a=new DataView(o.buffer);a.setUint32(i-8,Math.floor(s/4294967296),!1),a.setUint32(i-4,s>>>0,!1);const n=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),r=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),l=new Uint32Array(64),h=(t,e)=>t>>>e|t<<32-e;for(let t=0;t>>3,o=h(s,17)^h(s,19)^s>>>10;l[t]=l[t-16]+i+l[t-7]+o>>>0}let[e,s,i,o,c,d,p,u]=r;for(let t=0;t<64;t++){const a=u+(h(c,6)^h(c,11)^h(c,25))+(c&d^~c&p)+n[t]+l[t]>>>0,r=e&s^e&i^s&i;u=p,p=d,d=c,c=o+a>>>0,o=i,i=s,s=e,e=a+((h(e,2)^h(e,13)^h(e,22))+r>>>0)>>>0}r[0]=r[0]+e>>>0,r[1]=r[1]+s>>>0,r[2]=r[2]+i>>>0,r[3]=r[3]+o>>>0,r[4]=r[4]+c>>>0,r[5]=r[5]+d>>>0,r[6]=r[6]+p>>>0,r[7]=r[7]+u>>>0}const c=new Uint8Array(32),d=new DataView(c.buffer);for(let t=0;t{const e="abcdefghijklmnopqrstuvwxyz234567";let s=0,i=0,o="";for(const a of t)for(i=i<<8|a,s+=8;s>=5;)o+=e[i>>>s-5&31],s-=5;return s&&(o+=e[i<<5-s&31]),o},_n=(t,e,s,i,o="")=>{const[a,n]=nn(e,s),r=`${t}|${on(a)}|${on(n)}|${[...i].sort().join(",")}${o}`;return`wall-${un(pn(r)).slice(0,20)}`};let gn=0;const mn=t=>{for(let e=0;e<1e3;e++){const e=globalThis.crypto?.randomUUID?.(),s=`wall-${e||un(pn(`${Date.now()}|${gn++}|${Math.random()}`)).slice(0,26)}`;if(!t.has(s))return s}throw new Qa("duplicate-id","id factory exhausted")},fn=t=>{const e=new Map;for(const s of Array.isArray(t?.wall_segments)?t.wall_segments:[])if(s&&"string"==typeof s.id&&en(s.a)&&en(s.b)){if(e.has(s.id))throw new Qa("duplicate-id",s.id);e.set(s.id,s)}return e},bn=(t,e,s)=>{const i=(s,i)=>{const o=t[0]-s[0],a=t[1]-s[1];return Math.abs(e[0]-i[0]-o)<=Xa&&Math.abs(e[1]-i[1]-a)<=Xa?[o,a]:null};return i(s.a,s.b)||i(s.b,s.a)},vn=(t,e)=>{const s=Array.isArray(t.rooms)?t.rooms:[],i=Y(t.open_spans).map(t=>[t.a[0],t.a[1],t.b[0],t.b[1]]),o=i.length?i:X(s,null,1,.04*z,!0),a=[];for(const t of s){const s=N(t),i=Array.isArray(t?.wall_ids)?t.wall_ids:[];if(s&&i.length===s.length)for(let t=0;t"partition"!==t.host?.kind&&[Number(t.x),Number(t.y)].every(Number.isFinite)&&Number.isFinite(Number(t.angle))&&Number(t.length)>0&&o.some(e=>cn([Number(t.x),Number(t.y)],[e[0],e[1]],[e[2],e[3]])<=.04*z)):[],l=r.map(t=>{const e=Number(t.angle)*Math.PI/180,s=[Math.cos(e),Math.sin(e)],i=Number(t.length)/2,o=[Number(t.x),Number(t.y)];return{a:[o[0]-s[0]*i,o[1]-s[1]*i],b:[o[0]+s[0]*i,o[1]+s[1]*i]}}),h=(t,e)=>r.some(s=>{const i=[Number(s.x),Number(s.y)];if(!et(t,e,Number(s.angle)))return!1;if(cn(i,t,e)>.02*z)return!1;const o=rn(t,e),a=hn(i,t,e)*o,n=Number(s.length)/2;return a+n>=-1e-9&&a-n<=o+Xa}),c=new Map,d=[];for(const i of s){const r=String(i?.id||""),p=N(i);if(!r||!p||p.length<3)throw new Qa("invalid-room",r);const u=Q(s,r,n,z,1,[...t.walls||[],...l]);if(!u||u.poly.length<3)throw new Qa("invalid-room",r);const _=Array.isArray(i.wall_ids)?i.wall_ids:[],g=_.length===p.length;let m=null,f=g;if(f)for(let t=0;tXa||Math.abs(i[1]-m[1])>Xa)){f=!1;break}m=i}const b=[];for(let t=0;t2)throw new Qa("third-owner",n);const d=g?_[u.parent[t]]:void 0;if("string"==typeof d&&d){const o=e.get(d);f||!o||dn(s,i,o.a,o.b)>Xa?l.preferredIds.add(d):l.positionalIds.add(d),l.preferredCarriers.set(d,{a:sn(p[u.parent[t]]),b:sn(p[(u.parent[t]+1)%p.length])})}const m=u.parent[t];l.parentKeys.add(Z(p[m],p[(m+1)%p.length],z));const v=[(s[0]+i[0])/2,(s[1]+i[1])/2],y=t=>t.some(t=>cn(v,[t[0],t[1]],[t[2],t[3]])<=.04*z);l.zeroWall||=y(a)||y(o)&&!h(s,i),b.push(n)}const v={...i};delete v.wall_ids,d.push({...v,poly:u.poly.map(t=>[t[0],t[1]]),wall_ids:b})}return{atoms:[...c.values()].sort((t,e)=>t.key.localeCompare(e.key)),rooms:d}},yn=(t,e,s,i,o)=>{const a=new Map([...s.values()].map(t=>[an(t.a,t.b),t])),n=(t=>{const e=new Map;for(const s of t)"wall"===s.host?.kind&&e.set(s.host.id,(e.get(s.host.id)||0)+1);return e})(t.openings||[]),r=new Map;for(const t of e){const e=o?.get(t.key);if(e){const i=s.get(e);if(!i)throw new Qa("duplicate-id",e);r.set(t,i);continue}if(t.preferredIds.size>1)throw new Qa("duplicate-id",[...t.preferredIds].sort().join(","));const i=[...t.preferredIds][0],l=i?s.get(i):void 0;if(l){r.set(t,l);continue}const h=i?t.preferredCarriers.get(i):void 0;if(i&&h){r.set(t,{id:i,a:h.a,b:h.b,cm:0});continue}const c=a.get(t.key);if(c){r.set(t,c);continue}const d=[...s.values()].filter(e=>dn(t.a,t.b,e.a,e.b)>Xa),p=[...new Map(d.map(t=>[t.id,t])).values()];if(p.sort((t,e)=>(n.get(e.id)||0)-(n.get(t.id)||0)||rn(e.a,e.b)-rn(t.a,t.b)||t.id.localeCompare(e.id)),p[0])r.set(t,p[0]);else if(1===t.positionalIds.size){const e=s.get([...t.positionalIds][0]);e&&r.set(t,e)}}const l=new Map;for(const[t,e]of r){const s=l.get(e.id)||[];s.push(t),l.set(e.id,s)}for(const[t,e]of l){const i=s.get(t)||r.get(e[0]);if(!i)throw new Qa("duplicate-id",t);const o=[(i.a[0]+i.b[0])/2,(i.a[1]+i.b[1])/2];e.sort((t,e)=>{const s=cn(o,t.a,t.b)<=Xa?0:1,a=cn(o,e.a,e.b)<=Xa?0:1;if(s!==a)return s-a;return(cn(i.a,t.a,t.b)<=Xa?0:1)-(cn(i.a,e.a,e.b)<=Xa?0:1)||t.key.localeCompare(e.key)}),e[0].id=t}const h=(t=>{const e=new Set;for(const s of[t.rooms,t.openings,t.decor,t.room_drafts,t.partitions,t.wall_columns])for(const t of Array.isArray(s)?s:[])"string"==typeof t?.id&&t.id&&e.add(t.id);for(const s of Array.isArray(t.room_drafts)?t.room_drafts:[])for(const t of Array.isArray(s?.segments)?s.segments:[])"string"==typeof t?.id&&t.id&&e.add(t.id);return e})(t);for(const t of e)if(t.id){if(h.has(t.id))throw new Qa("duplicate-id",t.id);h.add(t.id)}const c=e.filter(t=>!t.id);if(i){const e=c.map(e=>{const[s,i]=nn(e.a,e.b),o=`${String(t.id||"")}|${on(s)}|${on(i)}|${[...e.owners].sort().join(",")}`,a=un(pn(o));return{atom:e,seed:o,digest:a,base:`wall-${a.slice(0,20)}`}}).sort((t,e)=>t.digest.localeCompare(e.digest)||t.atom.key.localeCompare(e.atom.key)),s=new Map;for(const t of e){const e=s.get(t.digest);if(e&&e!==t.seed)throw new Qa("duplicate-id",t.digest);s.set(t.digest,t.seed);let i=1,o=t.base;for(;h.has(o);)o=`${t.base}-${++i}`;t.atom.id=o,h.add(o)}}else for(const t of c)t.id=mn(h),h.add(t.id)},$n=(t,e)=>{if("partition"===t.host?.kind)return null;const s=[Number(t.x),Number(t.y)];if(!s.every(Number.isFinite))return null;const i=e=>{if(!(Number(e.cm)>0))return!1;const i=hn(s,e.a,e.b),o=rn(e.a,e.b),a=Number(t.length)/2;return i>=-1e-9&&i<=1+Xa&&cn(s,e.a,e.b)<=.02*z&&et(e.a,e.b,Number(t.angle))&&Number.isFinite(a)&&a>=0&&i*o-a>=-1e-9&&i*o+a<=o+Xa},o="wall"===t.host?.kind?e.find(e=>e.id===t.host.id):null,a=o&&i(o)?[o]:e.filter(i);if(1!==a.length)return null;const n=a[0];return{kind:"wall",id:n.id,t:Math.max(0,Math.min(1,hn(s,n.a,n.b)))}},wn=(t,e)=>{const s=[Number(t.x),Number(t.y)];if(!s.every(Number.isFinite))return null;const i=Number(t.length)/2,o=e.filter(e=>{if(!(Number(e.cm)>0))return!1;const o=hn(s,e.a,e.b),a=rn(e.a,e.b);return o>=-1e-9&&o<=1+Xa&&cn(s,e.a,e.b)<=.02*z&&et(e.a,e.b,Number(t.angle))&&Number.isFinite(i)&&i>=0&&o*a-i>=-1e-9&&o*a+i<=a+Xa}),a=(e=>{if(!e.length)return null;const i="wall"===t.host?.kind?e.find(e=>e.id===t.host.id):null;return i||[...e].sort((t,e)=>cn(s,t.a,t.b)-cn(s,e.a,e.b)||Number(e.cm)-Number(t.cm)||(t.ide.id?1:0))[0]})(o);return a?{kind:"wall",id:a.id,t:Math.max(0,Math.min(1,hn(s,a.a,a.b)))}:null},kn=/^[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/,xn=t=>{if("number"!=typeof t&&"string"!=typeof t)return null;if("string"==typeof t&&!kn.test(t.trim()))return null;const e=Number(t);return Number.isFinite(e)?e:null},Mn=t=>{if(!Array.isArray(t)||t.length<2)return null;const e=xn(t[0]),s=xn(t[1]);return null==e||null==s?null:[e,s]},Cn=t=>"string"==typeof t?t:"",Sn=t=>{if(!Object.prototype.hasOwnProperty.call(t,"room_drafts"))return{drafts:0,segments:0};const e=Array.isArray(t.room_drafts)?t.room_drafts:[];if(!e.length)return delete t.room_drafts,{drafts:0,segments:0};const s=new Set;for(const e of[t.rooms,t.openings,t.decor,t.partitions,t.wall_columns,t.wall_segments])for(const t of Array.isArray(e)?e:[])"string"==typeof t?.id&&t.id&&s.add(t.id);for(const t of e)"string"==typeof t?.id&&t.id&&s.add(t.id);const i=Array.isArray(t.partitions)?[...t.partitions]:[];let o=0;for(const a of e){const e=Cn(a?.id),n=Array.isArray(a?.points)?a.points:[],r=Array.isArray(a?.segments)?a.segments:[];if(n.length<2||r.length!==n.length-1)throw new Qa("zero-length",e);for(let a=0;a+1100)throw new Qa("thickness-conflict",e);let p="string"==typeof c?.id&&c.id?c.id:"";if(!p||s.has(p)){const i=_n(Cn(t.id),l,h,[`draft:${e}:${a}`]);p=i;for(let t=2;s.has(p);t++)p=`${i}-${t}`}s.add(p),i.push({id:p,a:sn(l),b:sn(h),cm:d}),o++}}return i.length?t.partitions=i:delete t.partitions,delete t.room_drafts,{drafts:e.length,segments:o}},Pn=t=>Sn(t),Dn=(t,e,s)=>{const i=Sn(t),o=fn(t),{atoms:a,rooms:n}=vn(t,o);yn(t,a,o,e,s);const r=a.map(e=>{const s=e.id?o.get(e.id):void 0,i=((t,e,s)=>{if(e.zeroWall)return 0;const i=Array.isArray(t.walls)?t.walls:[],o=Z(e.a,e.b,z),a=i.filter(t=>Number(t.cm)>0&&(!(t.key!==o&&!e.parentKeys.has(t.key))||!(!en(t.a)||!en(t.b))&&dn(e.a,e.b,t.a,t.b)>=rn(e.a,e.b)-Xa)).map(t=>Math.max(1,Math.min(100,Number(t.cm))));if(new Set(a.map(t=>t.toFixed(9))).size>1)throw new Qa("thickness-conflict",e.key);if(a.length)return a[0];const n=it(i,e.a,e.b,z,1);return n>0?n:Number(s?.cm)>0?Number(s.cm):0})(t,e,s);return{...s||{},id:e.id,a:[...e.a],b:[...e.b],cm:i}}),l=new Map(a.map(t=>[t.key,t.id]));for(const t of n)t.wall_ids=t.wall_ids.map(t=>l.get(t));t.rooms=n,t.wall_segments=r,t.walls=r.filter(t=>t.cm>0).map(t=>({key:Z(t.a,t.b,z),cm:t.cm,a:[...t.a],b:[...t.b]})),t.walls.length||delete t.walls,delete t.open_spans;for(const e of t.rooms)delete e.open_to;return((t,e,s)=>{const i=Array.isArray(t.openings)?t.openings:[];for(const t of i){if("partition"===t.host?.kind)continue;if(!t.host&&!s){const s=$n(t,e);s&&(t.host=s);continue}const i=$n(t,e)??(s?wn(t,e):null);if(i)t.host=i;else{if(!s)throw new Qa("opening-host",t.id);delete t.host}}})(t,r,e),{wallSegments:r.reduce((t,e)=>t+(o.has(e.id)?0:1),0),drafts:i.drafts,draftSegments:i.segments}};function In(t,e={}){const s=JSON.stringify(t),i=tn(t);J(i);let o=0,a=0,n=0;const r=Number(i?.model_version||0)<10;for(const t of Array.isArray(i?.spaces)?i.spaces:[]){const s=e.lineageSpaceId===String(t?.id||"")?e.lineageHints:void 0,i=Dn(t,r,s);o+=i.wallSegments,a+=i.drafts,n+=i.draftSegments}return i.model_version=10,J(i),{config:i,changed:s!==JSON.stringify(i),migratedSegments:o,migratedDrafts:a,migratedDraftSegments:n}}const Ln=t=>!!t&&"object"==typeof t&&!Array.isArray(t);function Tn(t,e){const s=(t,e)=>{if(Array.isArray(t)&&Array.isArray(e)){const i=new Map;for(const e of t)Ln(e)&&"string"==typeof e.id&&e.id&&i.set(e.id,e);const o=e.map((e,o)=>{if(Ln(e)&&"string"==typeof e.id&&e.id){const t=i.get(e.id);return t?s(t,e):tn(e)}return o[e,e in t?s(t[e],i):tn(i)]);for(const e of Object.keys(t))delete t[e];for(const[e,s]of i)t[e]=s;return t}return tn(e)};return s(t,e)}const Rn=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),zn=(t,e,s)=>Math.min(s,Math.max(e,t)),Fn=t=>bt({spaces:[t]})[0],Nn=(t,e,s)=>{const i=s>0?s:1,o=t=>`${(t[0]/i).toFixed(12)},${(t[1]/i).toFixed(12)}`,a=o(t),n=o(e);return a0?n:1,l=Math.max(i*r*.02,1e-9),h=[];for(const e of t||[])for(const t of N(e)||[])h.push([t[0],t[1]]);const c=[];for(const t of s||[])Array.isArray(t)&&t.length>=4&&t.slice(0,4).every(Number.isFinite)&&c.push([t[0],t[1]],[t[2],t[3]]);const d=(t,e)=>e.some(e=>Math.hypot(t[0]-e[0],t[1]-e[1])<=2*l),p=new Map;for(const n of t||[]){if(!n?.id)continue;const u=vt(t,n.id,e,s,i,o,a,r);if(u)for(let t=0;t0&&_>0&&n===g&&_!==n))continue;const m=u.poly[i],f=u.poly[(i+1)%u.poly.length],b=Math.hypot(f[0]-m[0],f[1]-m[1]);if(!(b>l&&b<.5*a-1e-9*a))continue;if(d(m,c)||d(f,c))continue;if(d(m,h)&&d(f,h))continue;const v=Nn(m,f,r),y=p.get(v);y?y.targets.add(n):p.set(v,{a:[m[0],m[1]],b:[f[0],f[1]],targets:new Set([n])})}}}let u=e.slice();const _=(t,e)=>Math.hypot(t[0]-e[0],t[1]-e[1])<=2*l,g=(t,e)=>{if(!Array.isArray(t.a)||!Array.isArray(t.b)||t.a.length<2||t.b.length<2)return!1;const s=[Number(t.a[0])*r,Number(t.a[1])*r],i=[Number(t.b[0])*r,Number(t.b[1])*r];return!![...s,...i].every(Number.isFinite)&&(_(s,e.a)&&_(i,e.b)||_(s,e.b)&&_(i,e.a))};for(const t of[...p.values()].filter(t=>1===t.targets.size).sort((t,e)=>Nn(t.a,t.b,r).localeCompare(Nn(e.a,e.b,r)))){const e=[...t.targets][0],s=u.filter(e=>g(e,t));if(new Set(s.map(t=>t.cm)).size>1)continue;let o=!1;u=u.map(s=>g(s,t)?(o=!0,s.cm===e?s:{...s,cm:e}):s),o||(u=j(u,t.a,t.b,e,i,r))}return u}const En=t=>{const e=[];for(const s of t||[]){const t=N(s);if(t?.length)for(let s=0;s"string"==typeof t?.id?t.id:"").filter(Boolean),c=new Set(h),d=new Map;for(const t of h){const e=Za("space",t);e.layers>0&&Ja("space",e.root)&&Ya(d,e.root,t)}const p=new Map,u=new Map,_=new Map,g=new Map;for(const t of r){const e="string"==typeof t?.id?t.id:"";if(!e)continue;const s=new Map;for(const i of Array.isArray(t.rooms)?t.rooms:[]){const t="string"==typeof i?.id?i.id:"";if(!t)continue;const o=Za("room",t);o.layers>0&&Ja("room",o.root)&&Ya(s,o.root,t),u.has(t)||u.set(t,e),_.has(t)||_.set(t,String(i.name||""));const a="string"==typeof i.area?i.area:"";if(a){const s=g.get(a)||[];s.push({spaceId:e,roomId:t}),g.set(a,s)}}p.set(e,s)}const m=new Set(u.keys()),f=new Map,b=new Map;for(const t of l)"string"==typeof t?.id&&t.id&&(!0===t.removed?b.set(t.id,t):f.set(t.id,t));const v={spaceRefsRemapped:0,roomRefsRemapped:0,positionsRemapped:0,markersDetached:0,positionsUnresolved:0,nestedRefsUnresolved:0,deadSpaceIds:[],orphanRoomLabelsRemoved:0,orphanDevicePositionsRemoved:0,orphanGroupPositionsRemoved:0,liveMissingPositionsRemoved:0,removedPositions:[],liveMissingPositions:[],unverifiedPositions:[]},y=new Set,$=t=>c.has(t)?null:(()=>{const e=Za("space",t).root;if(!Ja("space",e))return null;const s=d.get(e)||[];return 1===s.length?s[0]:null})(),w=(t,e)=>{const s=Za("room",t).root;if(!Ja("room",s))return null;const i=p.get(e)?.get(s)||[];return 1===i.length?i[0]:null},k=t=>{const e=s.effectiveAreaByMarker?.[t]||"",i=e&&g.get(e)||[];return 1===i.length?i[0]:null},x=(t,e,s)=>{if("string"==typeof t.room_id&&t.room_id&&!m.has(t.room_id)){const i=e?w(t.room_id,e):null;i?(t.room_id=i,v.roomRefsRemapped++):s?(t.room_id=s.roomId,v.roomRefsRemapped++):!0!==t.removed&&delete t.room_id}const i=t.vacuum?.segment_map;if(i&&"object"==typeof i&&!Array.isArray(i))for(const t of Object.keys(i)){const s=i[t];if("string"!=typeof s||!s||m.has(s))continue;const o=e?w(s,e):null;o?(i[t]=o,v.roomRefsRemapped++):v.nestedRefsUnresolved++}};for(const t of l){const e="string"==typeof t?.id?t.id:"";if(!e)continue;const s="string"==typeof t.space?t.space:"",i=s&&!c.has(s),a=o[e],n="string"==typeof a?.s?a.s:"",r=n&&!c.has(n),l=!0===t.removed;let h=s&&c.has(s)?s:null,d=null,p=!1;if(i){const i=$(s);i?(t.space=i,h=i,p=!0,v.spaceRefsRemapped++):l||"virtual"===t.binding?l||(delete t.space,h=null,v.markersDetached++):(d=k(e),d?(t.space=d.spaceId,h=d.spaceId,v.spaceRefsRemapped++):(delete t.space,h=null,v.markersDetached++))}l&&!p||x(t,h,d),r&&p&&n===s&&h&&(o[e]={...a,s:h},v.positionsRemapped++,y.add(e))}for(const t of Object.keys(o)){if(y.has(t))continue;const e=o[t],s="string"==typeof e?.s?e.s:"";if(!s||c.has(s))continue;const i=$(s);if(i){if(t.startsWith("rl_")){const s=t.slice(3),a=w(s,i);if(a){const s=`rl_${a}`;Va(o,s)||(o[s]={...e,s:i}),delete o[t],v.roomRefsRemapped++,v.positionsRemapped++;continue}}o[t]={...e,s:i},v.positionsRemapped++}}const M=s.ownerRoster,C=!0===M?.authoritative,S=new Set(M?.deviceIds||[]),P=new Set(M?.entityIds||[]),D=new Set(Array.isArray(i.settings?.known_devices)?i.settings.known_devices.filter(t=>"string"==typeof t):[]),I=(t,e="")=>{const s=String(M?.names?.[t]||e||"").trim();return s&&s!==t?s:""},L=(t,e,s,i="",o)=>({id:t,spaceId:e,kind:s,name:I(t,i),...o?{reason:o}:{}}),T=t=>{"room_label"===t?v.orphanRoomLabelsRemoved++:"group"===t?v.orphanGroupPositionsRemoved++:v.orphanDevicePositionsRemoved++},R=new Set;for(const[t,e]of Object.entries(o)){const i="string"==typeof e?.s?e.s:"";if(!i||c.has(i))continue;let a,n;const r=f.get(t),l=b.get(t);if(r)a=L(t,i,"device",String(r.name||"")),n="live";else if(l)a=L(t,i,"device",String(l.name||"")),n="absent";else if(t.startsWith("rl_")){const e=t.slice(3);a=L(t,i,"room_label",_.get(e)||""),n=m.has(e)?"live":"absent"}else if(t.startsWith("lg_")){const e=t.slice(3);a=L(t,i,"group"),n=P.has(e)?"live":C?"absent":"unverified","unverified"===n&&(a.reason="registry_unavailable")}else S.has(t)?(a=L(t,i,"device"),n="live"):D.has(t)?(a=L(t,i,"device"),n=C?"absent":"unverified","unverified"===n&&(a.reason="registry_unavailable")):(a=L(t,i,"unknown","","unknown_owner"),n="unverified");if("absent"!==n){if("live"===n){if(v.liveMissingPositions.push(a),!0===s.removeLiveMissingPositions){delete o[t],v.liveMissingPositionsRemoved++,T(a.kind),v.removedPositions.push(a);continue}}else v.unverifiedPositions.push(a);v.positionsUnresolved++,R.add(i)}else delete o[t],T(a.kind),v.removedPositions.push(a)}return v.deadSpaceIds=[...R].sort((t,e)=>t.localeCompare(e)),{config:i,layout:o,report:v,changed:JSON.stringify(i)!==a||JSON.stringify(o)!==n}}(t,e,s),n=a.config,r=ot(n,a.layout);J(n),at(a.layout);const l=JSON.stringify(t||{}),h=JSON.stringify(e||{}),c=Number.isInteger(Number(n.model_version))?Number(n.model_version):0,d=(t=>{let e=0,s=0,i=0;for(const s of t.markers||[]){if("ripple"===s.display&&(s.display="icon_ripple",e++),Array.isArray(s.controls)){const t="string"==typeof s.binding&&s.binding.startsWith("entity:")?s.binding.slice(7):"",i=t?s.controls.filter(e=>e!==t):s.controls;JSON.stringify(i)!==JSON.stringify(s.controls)&&(s.controls=i.length?i:null,e++)}const t=s.vacuum;t&&Rn(t,"trail")&&(["never","cleaning","always"].includes(t.trail_mode)||(t.trail_mode=!1===t.trail?"never":"cleaning"),delete t.trail,e++)}for(const o of t.spaces||[]){const t=o.settings;"glow"===t?.fill_mode&&("boolean"!=typeof t.glow_enabled&&(t.glow_enabled=!0),t.fill_mode="none",e++,s++);for(const t of o.rooms||[]){const s=t.settings;"glow"===s?.fill_mode&&("boolean"!=typeof s.glow&&(s.glow=!0),delete s.fill_mode,e++,i++)}if(Rn(o,"segments")&&(delete o.segments,e++),Rn(o,"plan_scale")){const t=Number(o.plan_scale);Number.isFinite(t)&&t>=pt&&t<=ut&&(Rn(o,"plan_scale_x")||(o.plan_scale_x=t),Rn(o,"plan_scale_y")||(o.plan_scale_y=t),delete o.plan_scale,e++)}const a=Number(o.cell_cm);Rn(o,"cell_cm")&&(!Number.isFinite(a)||a<.1||a>1e3)&&(o.cell_cm=Number.isFinite(a)&&a>0?zn(a,.1,1e3):5,e++);const n=Number(o.cell_cm),r=Number.isFinite(n)&&n>0?n:5;for(const t of o.wall_columns||[])if("circle"===t.shape)Rn(t,"angle")&&(delete t.angle,e++);else if("square"===t.shape&&Rn(t,"angle")){const s=((Number(t.angle)||0)%90+90)%90;t.angle!==s&&(t.angle=s,e++)}for(const t of o.decor||[]){if(Rn(t,"width")){const s=Number(t.width);(Rn(t,"width_cm")||Number.isFinite(s))&&(Rn(t,"width_cm")||(t.width_cm=Number(zn(s/ct*r,.1,100).toFixed(6))),delete t.width,e++)}if("rect"!==t?.kind&&"ellipse"!==t?.kind||!0!==t.fill||(Rn(t,"fill_color")||(t.fill_color=t.color||"#607d8b",e++),Rn(t,"fill_opacity")||(t.fill_opacity=.25,e++)),"text"!==t?.kind)continue;void 0===t.size_cm?(t.size_cm=Number(zn(_t*gt(t)/ct*r,.1,2e3).toFixed(6)),delete t.scale,delete t.size,e++):(Rn(t,"scale")||Rn(t,"size"))&&(delete t.scale,delete t.size,e++);let s=String(t.text??"");const i=[...s.matchAll(/\{([^{}\r\n]+)\}/g)].some(t=>!!mt(t[1]));if(!(Rn(t,"entity")||Rn(t,"attr")||Rn(t,"unit")))continue;const o=String(t.unit??"").trim(),a="state"===String(t.attr??"").trim().toLowerCase()?null:t.attr,n=i||o?"":ft(t.entity,a);if(i||n){if(n){const e=s.indexOf("{}");s=e>=0?s.slice(0,e)+n+s.slice(e+2):`${s}${s?" ":""}${n}`,t.text=s}delete t.entity,delete t.attr,delete t.unit,e++}}}return{total:e,glowSpaces:s,glowRooms:i}})(n);let p=d.total,u=0,_=0,g=0;if(c<10)for(const t of Array.isArray(n.spaces)?n.spaces:[]){const e=Pn(t);_+=e.drafts,g+=e.segments}const m=(f=n.spaces||[],JSON.parse(JSON.stringify(f)));var f;const b=ka(n.spaces||[],a.layout);let v=0,y=0,$=0,w="";const k=b.spaces.map(t=>{const e=nt(t);v+=e.report.wallsStraightened,y+=e.report.wallsStraightenSkipped;const s=Number(t?.cell_cm)>0?Number(t.cell_cm):5,i=e.report.maxStraightenShift/z*s;return i>$&&($=i,w=String(t?.id||"")),e.space}),x=v?ka(k,b.layout):{...b,spaces:k};n.spaces=x.spaces;const M=v?{...b.report,moved:b.report.moved+x.report.moved,coordsCanonicalized:b.report.coordsCanonicalized+x.report.coordsCanonicalized,maxShift:Math.max(b.report.maxShift,x.report.maxShift),maxShiftCm:Math.max(b.report.maxShiftCm,x.report.maxShiftCm),maxSpace:x.report.maxShiftCm>b.report.maxShiftCm?x.report.maxSpace:b.report.maxSpace,rotated:b.report.rotated+x.report.rotated}:{...b.report};let C=0,S=0,P=0,D=0,I=0,L=0,T=0;for(let t=0;t0===Number(t.cm)),walls:e.walls||[]}),a=Fn(e),r=Fn(s);if(!a||!r)continue;const l=En(a.rooms),h=En(r.rooms),c=.02*ct,d=(e.wall_segments||[]).filter(t=>0===Number(t.cm)).map(t=>({...t,key:Z(t.a,t.b,z),cm:0})),p=new Set(d.map(t=>t.key)),u=rt(e,a.rooms,lt,c);S+=u.length;for(const t of u){const e=[t[0]/lt,t[1]/lt],s=[t[2]/lt,t[3]/lt],i=Z(e,s,z);p.has(i)||(p.add(i),d.push({key:i,a:e,b:s,cm:0}))}const _=d.length,g=ht(d,l,h,z,lt),f=(t,e,s)=>{const i=s[0]-e[0],o=s[1]-e[1],a=i*i+o*o;if(!(a>0))return Math.hypot(t[0]-e[0],t[1]-e[1]);const n=Math.max(0,Math.min(1,((t[0]-e[0])*i+(t[1]-e[1])*o)/a));return Math.hypot(t[0]-(e[0]+i*n),t[1]-(e[1]+o*n))},b=g.filter(t=>{if(!Array.isArray(t.a)||!Array.isArray(t.b))return!1;const e=t.a.map(t=>t*lt),s=t.b.map(t=>t*lt);return h.some(([t,i])=>f(e,t,i)<=4*c&&f(s,t,i)<=4*c)});P+=Math.max(0,_-b.length);const v=(s.wall_segments||[]).filter(t=>Number(t.cm)>0);s.wall_segments=[...v,...b.map(({key:t,...e})=>e)];const y=b.map(t=>[t.a[0]*lt,t.a[1]*lt,t.b[0]*lt,t.b[1]*lt]),$=Array.isArray(e.walls)?e.walls.length:0;let w=ht(e.walls,l,h,z,lt);w=An(r.rooms,w,y,z,Number(s.cell_cm)>0?Number(s.cell_cm):5,ct,lt),w=G(r.rooms,w,y,z,Number(s.cell_cm)>0?Number(s.cell_cm):5,ct,lt),w=dt(w,s.rooms||[],z,1,y.map(t=>[t[0]/lt,t[1]/lt,t[2]/lt,t[3]/lt])),C+=Math.max(0,$-w.length),w.length?s.walls=w:delete s.walls;const k=Ia(s.partitions||[],{pitch:z,geometry:Ta(s)});k.merged&&(D+=k.merged,s.partitions=k.partitions,La(s.openings,s.partitions,k.openingMoves,{coordScale:lt,cellCm:Number(s.cell_cm)>0?Number(s.cell_cm):5,gridPitch:ct}));const x=Fn(s);if(x){const t=o(s,x,s.walls||[],y,{pitch:z,cellCm:Number(s.cell_cm)>0?Number(s.cell_cm):5,gridPitch:ct,coordScale:lt});t.partitionsReconciled&&(I+=t.partitionsReconciled,L+=t.openingsRehosted,t.partitions.length?s.partitions=t.partitions:delete s.partitions,t.openings.length?s.openings=t.openings:delete s.openings,t.walls.length?s.walls=t.walls:delete s.walls)}JSON.stringify({zero:(s.wall_segments||[]).filter(t=>0===Number(t.cm)),walls:s.walls||[]})!==i&&T++}if(c<=10){const t=function(t){const e=In(t);return Tn(t,e.config),{...e,config:t}}(n);u+=t.migratedSegments,_+=t.migratedDrafts,g+=t.migratedDraftSegments}const R=J(n),F=at(x.layout),N=JSON.stringify(R)!==l||JSON.stringify(F)!==h;c<10&&N&&(R.model_version=10);const A=JSON.stringify(R)!==l||JSON.stringify(F)!==h,E=Number.isInteger(Number(R.model_version))?Number(R.model_version):c,O=A?M:{...M,moved:0,coordsCanonicalized:0,maxShift:0,maxShiftCm:0,maxSpace:"",rotated:0},H=A?a.report:{...a.report,spaceRefsRemapped:0,roomRefsRemapped:0,positionsRemapped:0,markersDetached:0,orphanRoomLabelsRemoved:0,orphanDevicePositionsRemoved:0,orphanGroupPositionsRemoved:0,liveMissingPositionsRemoved:0};return{config:R,layout:F,report:{...O,modelFrom:c,modelTo:E,migrated:A?p:0,glowSpacesMigrated:A?d.glowSpaces:0,glowRoomsMigrated:A?d.glowRooms:0,canonicalized:A?T:0,wallSegmentsMigrated:A?u:0,roomDraftsMigrated:A?_:0,roomDraftSegmentsMigrated:A?g:0,legacyZeroWallsMigrated:A?S:0,wallsMerged:A?C:0,spansMerged:A?P:0,partitionsMerged:A?D:0,partitionsReconciled:A?I:0,openingsRehosted:A?L:0,wallsStraightened:A?v:0,wallsStraightenSkipped:y,maxStraightenShiftCm:A?$:0,maxStraightenSpace:A?w:"",latticeCoordinatesCanonicalized:A?r.canonicalized:0,latticeCoordinatesFar:A?r.far:0,latticeMaxShift:A?r.maxShift:0,latticeMaxShiftCm:A?r.maxShiftCm:0,latticeSpaces:A?r.spaces:[],...H},changed:A}}async function Hn(t,e,s){t._saveConfigDebounced.pending()&&t._saveConfigDebounced.flush(),await t._writeChain;const i=await t.hass.callWS({type:"houseplan/plan/optimize",config:e,layout:s,expected_config_rev:t._cfgRev,expected_layout_rev:t._layoutRev});t._adoption.acceptPairWrite(e,s,i),t._geometryHistory.clear(),t._cancelDeviceDrag(),t._devicePositionHistory.clear(),t._canOptimizeUndo=!0===i.can_undo,t._undoKind=!0===i.can_undo?"optimize":null,t._dirtyPos.clear(),t._sentPos.clear(),t._cfgEpoch++,t._modelCache=null,t._frame=null,t._regSignature="",t._maybeRebuildDevices(),t._cacheSnapshot(),t.requestUpdate()}const Bn=Object.freeze({spaces:50,partitions:2e3,openings:500,decor:1e3,columns:500});class Wn extends Error{constructor(t){super(t),this.code=t,this.name="SpaceCopyError"}}const jn=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Gn=t=>void 0===t?t:JSON.parse(JSON.stringify(t)),qn=t=>null===t||"object"!=typeof t||Array.isArray(t)?null:t;function Un(t,e=!1){if(void 0===t&&!e)return[];if(!Array.isArray(t))throw new Wn("source_invalid");return t.map(t=>{const e=qn(t);if(!e||"string"!=typeof e.id||!e.id)throw new Wn("source_invalid");return e})}const Kn=t=>Array.isArray(t)&&2===t.length&&t.every(t=>Number.isFinite(t));function Vn(t,e,s){const i=String(t??"").trim()||s,o=new Set(e.map(t=>{const e=qn(t);return String(e?.title??"").trim()}));let a=2;for(;o.has(`${i} (${a})`);)a++;return`${i} (${a})`}const Jn=["settings","zero_wall_style","cell_cm","view_box","plan_url","plan_aspect","plan_x","plan_y","plan_scale","plan_scale_x","plan_scale_y","plan_angle"];const Zn={source_missing:"space.copy_error_source_missing",source_invalid:"space.copy_error_source_invalid",spaces_limit:"space.copy_error_spaces_limit",partitions_limit:"space.copy_error_partitions_limit",openings_limit:"space.copy_error_openings_limit",decor_limit:"space.copy_error_decor_limit",columns_limit:"space.copy_error_columns_limit",opening_host_missing:"space.copy_error_opening_host",opening_host_unknown:"space.copy_error_opening_host",geometry_unsafe:"space.copy_error_geometry"};let Yn=0;function Xn(t,e,s){const i=t._spaceDialog;return!(!i?.copy||i.copy.token!==e)&&(t._spaceDialog={...i,busy:s,copy:{...i.copy,busy:s}},!0)}function Qn(t){t._cfgEpoch++,t._modelCache=null,t._frame=null,t._regSignature="",t._maybeRebuildDevices(),t.requestUpdate()}async function tr(t,e){const s=t._spaceDialog;if(!s?.copy||"edit"!==s.mode||s.busy||s.copy.busy||!s.copy.title.trim()||!s.spaceId||!t._serverCfg)return;const i=++Yn,o=s.spaceId,a=s.copy.title.trim();t._spaceDialog={...s,busy:!0,copy:{...s.copy,title:a,busy:!0,token:i}};let n=!1;try{if(t._saveConfigDebounced.pending()&&t._saveConfigDebounced.flush(),await t._writeChain,!Xn(t,i,!0)||!t._serverCfg)return;const s=t._cfgRev,r=t._layoutRev,l=yt(t._serverCfg),h=yt(t._layout);let c;try{c=(e.optimize??On)(t._serverCfg,t._layout,e.optimizeReferenceContext())}catch(s){return Xn(t,i,!1),void e.showWallModelMigrationBlocked(s)}if(c.changed){const d=t._checkOptimizeGeometry(c.config);if(e.reportPreflightFailure(d,c.config),!d.ok)return Xn(t,i,!1),void t._showToast(t._t("space.copy_error_optimize_geometry"));const p=await t._confirmDanger({key:`copy-space:${o}`,kind:"warning",title:t._t("space.copy_optimize_title"),message:t._t("space.copy_optimize_body",{name:a}),objectName:a,confirmLabel:t._t("space.copy_optimize_confirm"),cancelLabel:t._t("btn.cancel"),icon:"mdi:broom"});if(!Xn(t,i,p))return;if(!p)return;if(t._cfgRev!==s||t._layoutRev!==r||!t._serverCfg||yt(t._serverCfg)!==l||yt(t._layout)!==h)return Xn(t,i,!1),void t._showToast(t._t("space.copy_error_changed"));e.clearGeometryGesture(),await Hn(t,c.config,c.layout),n=!0}if(!Xn(t,i,!0)||!t._serverCfg)return;const d=t._serverCfg,p=function(t,e,s,i){const o=t.spaces;if(!s.trim())throw new Wn("source_invalid");if(o.length>=Bn.spaces)throw new Wn("spaces_limit");const a=o.findIndex(t=>t.id===e);if(a<0)throw new Wn("source_missing");const n=o[a];if(!Array.isArray(n.view_box))throw new Wn("source_invalid");const r=Un(n.wall_segments,!0),l=Un(n.partitions),h=Un(n.openings),c=Un(n.decor),d=Un(n.wall_columns);if(r.length+l.length>Bn.partitions)throw new Wn("partitions_limit");if(h.length>Bn.openings)throw new Wn("openings_limit");if(c.length>Bn.decor)throw new Wn("decor_limit");if(d.length>Bn.columns)throw new Wn("columns_limit");let p=0;const u=t=>`${t}${i}${(p++).toString(36)}`,_=new Map,g=new Map,m=[];for(const t of r){if(_.has(t.id)||!Kn(t.a)||!Kn(t.b)||"number"!=typeof t.cm||!Number.isFinite(t.cm))throw new Wn("source_invalid");const e=u("cw");_.set(t.id,e),m.push({id:e,a:Gn(t.a),b:Gn(t.b),cm:t.cm})}for(const t of l){if(g.has(t.id)||!Kn(t.a)||!Kn(t.b)||"number"!=typeof t.cm||!Number.isFinite(t.cm))throw new Wn("source_invalid");const e=u("cp");g.set(t.id,e),m.push({id:e,a:Gn(t.a),b:Gn(t.b),cm:t.cm})}const f=h.map(t=>{const e=qn(t.host);if(!e||"string"!=typeof e.id||"string"!=typeof e.kind)throw new Wn("opening_host_missing");const s="wall"===e.kind?_.get(e.id):"partition"===e.kind?g.get(e.id):void 0;if(!s)throw new Wn("opening_host_unknown");const i={...Gn(t),id:u("co"),host:{...Gn(e),kind:"partition",id:s}};return delete i.contact,delete i.lock,i}),b=c.map(t=>({...Gn(t),id:u("cd")})),v=d.map(t=>({...Gn(t),id:u("cc")})),y=`s${i}`;if(o.some(t=>t.id===y))throw new Wn("source_invalid");const $={id:y,title:s.trim(),rooms:[],wall_segments:[],view_box:Gn(n.view_box)};for(const t of Jn)"view_box"!==t&&jn(n,t)&&($[t]=Gn(n[t]));m.length&&($.partitions=m),f.length&&($.openings=f),b.length&&($.decor=b),v.length&&($.wall_columns=v);const w=Gn(t);return w.spaces.splice(a+1,0,$),{config:w,space:$,sourceIndex:a}}(d,o,a,e.newSeed?.()??function(t=Date.now(),e=Math.random()){const s=Math.floor(16777216*Math.max(0,Math.min(.999999999,e))).toString(36).padStart(5,"0");return`${Math.max(0,Math.floor(t)).toString(36)}${s}`}());let u=!1;try{u=t._checkSpacePhysicalGeometry(p.config,p.space.id).ok}catch{u=!1}if(!u||t._junctionLimitViolations(p.config,p.space.id).length)throw new Wn("geometry_unsafe");const _=t._adoption.beginOptimistic(d,p.config);t._adoption.stageLocalConfig(p.config),Qn(t);try{await e.saveConfigNow(_)}catch(e){throw t._rollbackOptimistic(_)&&Qn(t),"conflict"!==e?.code&&await t._reloadConfigOnly(!0),e}t._canOptimizeUndo=!1,t._undoKind=null,e.clearGeometryGesture(),t._selId=null,t._physicalSel=null,t._spaceDialog=null,t._commitSpace(p.space.id,!0),e.setMode("plan"),t._tool="draw",t._path=[],t._cursorPt=null,t._activeWallChainId=null,t._activeWallChainPartitionIds=[],t._primeDrawWallField(),t._saveNav(),t.requestUpdate(),t._showToast(t._t("toast.space_copied",{name:a}))}catch(e){"conflict"===e?.code&&await Promise.all([t._reloadConfigOnly(!0),t._reloadLayoutOnly()]),Xn(t,i,!1),function(t,e){if(e instanceof Wn)return void t._showToast(t._t(Zn[e.code]));const s=e?.code;"wall_model_client_outdated"!==s?t._showToast(t._t("toast.error",{err:t._errText(e)})):t._showToast(t._t("toast.wall_model_client_outdated"))}(t,e),n&&t.requestUpdate()}}const er=1e3;function sr(){Zo(this.host);const t=this.host._spaceDialog;if(t.copy)return function(t,e){const s=t._spaceDialog.copy,i=()=>function(t){const e=t._spaceDialog;!e?.copy||e.busy||e.copy.busy||(t._spaceDialog={...e,copy:void 0})}(t);return p`
    @@ -545,7 +545,7 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db .title=${`${"create"===t.mode?this.host._t("space.new"):this.host._t("space.header")}${e?` · ${e}`:""}`} icon="mdi:floor-plan" wide @hp-close=${s}>
    - ${Zo({title:this.host._t("space.card_basics"),body:p` + ${Yo({title:this.host._t("space.card_basics"),body:p` {const s=e.target.value,i=kt(s),o=null==i?null:xt(i,this.host._imperial);this.host._spaceDialog={...t,cellCmInput:s,cellCmTouched:!0,cellCm:null!=o&&o>0?Math.max(.1,Math.min(tr,o)):t.cellCm}}} /> + @input=${e=>{const s=e.target.value,i=kt(s),o=null==i?null:xt(i,this.host._imperial);this.host._spaceDialog={...t,cellCmInput:s,cellCmTouched:!0,cellCm:null!=o&&o>0?Math.max(.1,Math.min(er,o)):t.cellCm}}} /> ${this.host._t(this.host._imperial?"space.scale_unit_imperial":"space.scale_unit")}
    `})} - ${Zo({title:this.host._t("space.display_section"),body:p` + ${Yo({title:this.host._t("space.display_section"),body:p`
    - + ${Qo({name:"space-zero-wall-style",value:"solid"===t.zeroWallStyle?"solid":"dashed",ariaLabel:this.host._t("space.zero_wall_style"),options:[{value:"dashed",label:this.host._t("space.zero_wall_dashed")},{value:"solid",label:this.host._t("space.zero_wall_solid")}],onChange:e=>{this.host._spaceDialog={...t,zeroWallStyle:"solid"===e?"solid":"dashed"}}})}
    `:d}`)}`})} - ${Zo({title:this.host._t("space.roomcard_section"),body:p` + ${Yo({title:this.host._t("space.roomcard_section"),body:p` ${[["labelTemp","space.label_temp"],["labelHum","space.label_hum"],["labelLqi","space.label_lqi"],["labelLight","space.label_light"]].map(([e,s])=>p`
    ${this.host._renderCardPreview(t.cardFontScale,1,1)}`})} - ${Zo({title:this.host._t("space.card_sun"),body:p` + ${Yo({title:this.host._t("space.card_sun"),body:p`
    ${this._help("space.bg_mode.help")}
    - + ${Qo({name:"space-bg-mode",value:t.bgMode??"",ariaLabel:this.host._t("space.bg_mode"),options:[{value:"",label:this.host._t("space.sun_inherit")},{value:"static",label:this.host._t("gs.bg_static")},{value:"daynight",label:this.host._t("gs.bg_daynight")}],onChange:e=>{this.host._spaceDialog={...t,bgMode:"static"===e||"daynight"===e?e:null}}})} ${"static"===(t.bgMode??Pt(this.host._settings,{}))?p`
    ${"edit"===t.mode?p`
    -
    `:d} @@ -741,10 +728,10 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db
    - `}function sr(){return p``}function ir(){return Zo(this.host),p`this.host._settingsDialog=null}>
    - ${Zo({title:this.host._t("gs.card_display"),body:p` + ${Yo({title:this.host._t("gs.card_display"),body:p` `})} - ${Zo({title:this.host._t("gs.card_zigbee"),body:p`this.host._settingsDialog={...this.host._settingsDialog,zigbeeTopology:t.detail}}>`})} - ${Zo({title:this.host._t("gs.card_fills"),help:this._help("gs.card_fills.help"),body:p` + ${Yo({title:this.host._t("gs.card_zigbee"),body:p`this.host._settingsDialog={...this.host._settingsDialog,zigbeeTopology:t.detail}}>`})} + ${Yo({title:this.host._t("gs.card_fills"),help:this._help("gs.card_fills.help"),body:p` ${this._renderColorRow("light_on","gs.light_on")} ${this._renderColorRow("light_off","gs.light_off")} @@ -767,7 +754,7 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db ${this._renderColorRow("lqi_low","gs.lqi_low")} ${this._renderColorRow("lqi_high","gs.lqi_high")}`})} - ${Zo({title:this.host._t("gs.glow_group"),body:p` + ${Yo({title:this.host._t("gs.glow_group"),body:p` ${this._renderColorRow("glow_base","gs.glow_base")} ${this._renderColorRow("glow_light","gs.glow_light")}
    @@ -778,14 +765,14 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db @input=${t=>{const e=kt(t.target.value);null!=e&&e>0&&(this.host._settingsDialog={...this.host._settingsDialog,glowRadius:e})}} /> ${this.host._imperial?this.host._t("gs.unit_ft"):this.host._t("gs.unit_m")}
    `})} - ${Zo({title:this.host._t("gs.card_plan"),body:p` + ${Yo({title:this.host._t("gs.card_plan"),body:p` ${this._renderColorRow("wall_fill","gs.wall_fill")}
    ${this._help("gs.bg_mode.help")} - ${Xo({name:"gs-bg-mode",value:"daynight"===this.host._settingsDialog.bgMode?"daynight":"static",ariaLabel:this.host._t("gs.bg_mode"),options:[{value:"static",label:this.host._t("gs.bg_static")},{value:"daynight",label:this.host._t("gs.bg_daynight")}],onChange:t=>this.host._settingsDialog={...this.host._settingsDialog,bgMode:"daynight"===t?"daynight":"static"}})} + ${Qo({name:"gs-bg-mode",value:"daynight"===this.host._settingsDialog.bgMode?"daynight":"static",ariaLabel:this.host._t("gs.bg_mode"),options:[{value:"static",label:this.host._t("gs.bg_static")},{value:"daynight",label:this.host._t("gs.bg_daynight")}],onChange:t=>this.host._settingsDialog={...this.host._settingsDialog,bgMode:"daynight"===t?"daynight":"static"}})}
    ${"static"===this.host._settingsDialog.bgMode?p`
    this.host._settingsDialog={...this.host._settingsDialog,bgColor:null}}>${this.host._t("gs.bg_default")}`:p`${this.host._t("gs.bg_theme")}`}
    `:d}`})} - ${Zo({title:this.host._t("gs.sun_group"),body:p` + ${Yo({title:this.host._t("gs.sun_group"),body:p` ${Tt(this.host.hass)?d:p`
    ${this.host._t("gs.sun_missing")}
    `}
    ${this.host._renderCompass()} @@ -825,7 +812,7 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db
    `}`})} - ${Zo({title:this.host._t("gs.card_data"),body:p` + ${Yo({title:this.host._t("gs.card_data"),body:p` ${this.host._canEdit?p`
    @@ -867,7 +854,7 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db ${this.host._settingsDialog.busy?"…":this.host._t("btn.save")}
    - `;var t,e,s}function ir(t,e,s,i,o){const a=zt(t._roomTempMin,t._roomTempMax);if("temp"!==e)return{valid:a.valid,template:d};const n=""!==t._roomTempMin.trim()&&null===kt(t._roomTempMin),r=""!==t._roomTempMax.trim()&&null===kt(t._roomTempMax);return{valid:a.valid,template:p`
    + `;var t,e,s}function or(t,e,s,i,o){const a=zt(t._roomTempMin,t._roomTempMax);if("temp"!==e)return{valid:a.valid,template:d};const n=""!==t._roomTempMin.trim()&&null===kt(t._roomTempMin),r=""!==t._roomTempMax.trim()&&null===kt(t._roomTempMax);return{valid:a.valid,template:p`
    ${o} @@ -887,7 +874,7 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db °C ${t._roomTempMin.trim()||t._roomTempMax.trim()?p``:d}
    -
    `}}const or=[{value:"",key:"fill.inherit"},...Ft.map(t=>({value:t,key:`fill.${t}`}))];function ar(t,e){const s=t.host,i="temp"===e?s._roomTempSrc:s._roomHumSrc,o=t=>{"temp"===e?s._roomTempSrc=t:s._roomHumSrc=t,s.requestUpdate()},a=s._roomSrcOpen===e,n=s._t("temp"===e?"room.temp_src_label":"room.hum_src_label");return p`${Yo({label:n,control:Xo({name:`rsrc-${e}`,value:i?"pick":"avg",ariaLabel:n,options:[{value:"avg",label:s._t("room.src_average")},{value:"pick",label:s._t("room.src_pick")}],onChange:t=>{if("avg"===t)return o(""),void(s._roomSrcOpen=null);s._roomSrcOpen=e,s._roomSrcFilter="",s.requestUpdate()}})})} +
    `}}const ar=[{value:"",key:"fill.inherit"},...Ft.map(t=>({value:t,key:`fill.${t}`}))];function nr(t,e){const s=t.host,i="temp"===e?s._roomTempSrc:s._roomHumSrc,o=t=>{"temp"===e?s._roomTempSrc=t:s._roomHumSrc=t,s.requestUpdate()},a=s._roomSrcOpen===e,n=s._t("temp"===e?"room.temp_src_label":"room.hum_src_label");return p`${Xo({label:n,control:Qo({name:`rsrc-${e}`,value:i?"pick":"avg",ariaLabel:n,options:[{value:"avg",label:s._t("room.src_average")},{value:"pick",label:s._t("room.src_pick")}],onChange:t=>{if("avg"===t)return o(""),void(s._roomSrcOpen=null);s._roomSrcOpen=e,s._roomSrcFilter="",s.requestUpdate()}})})} ${i||a?p`
    `)}
    -
    `:d}`:d}`}function nr(){!function(t){const e=t.renderRoot;if(!e||Vo.has(e))return;const s=e.ownerDocument??globalThis.document,i=s?.defaultView?.CSSStyleSheet;if(i&&"adoptedStyleSheets"in e)return Jo||(Jo=new i,Jo.replaceSync(Ko)),e.adoptedStyleSheets=[...e.adoptedStyleSheets,Jo],void Vo.add(e);if(e.querySelector("style[data-hp-form-kit]"))return void Vo.add(e);const o=s.createElement("style");o.dataset.hpFormKit="true",o.textContent=Ko,e.appendChild(o),Vo.add(e)}(this.host);const t=!!this.host._roomEditId,e=t?null:this.host._wallFaceBatch,s=e&&e.candidates.length>1?this.host._t("room.queue_progress",{current:e.index+1,total:e.candidates.length}):"",i=_(this.host._curSpaceCfg),o=this.host._roomFill||i.fill,a=this.host._roomCustomFill||i.customFill,n=zt(this.host._roomTempMin,this.host._roomTempMax).valid,r=(!!this.host._areaSel||!!this.host._nameSel.trim())&&n,l=[...this.host._freeAreas];if(t&&this.host._areaSel&&!l.some(t=>t.area_id===this.host._areaSel)){const t=this.host.hass.areas[this.host._areaSel];t&&l.unshift(t)}return p``:d}`:d}`}function rr(){Zo(this.host);const t=!!this.host._roomEditId,e=t?null:this.host._wallFaceBatch,s=e&&e.candidates.length>1?this.host._t("room.queue_progress",{current:e.index+1,total:e.candidates.length}):"",i=_(this.host._curSpaceCfg),o=this.host._roomFill||i.fill,a=this.host._roomCustomFill||i.customFill,n=zt(this.host._roomTempMin,this.host._roomTempMax).valid,r=(!!this.host._areaSel||!!this.host._nameSel.trim())&&n,l=[...this.host._freeAreas];if(t&&this.host._areaSel&&!l.some(t=>t.area_id===this.host._areaSel)){const t=this.host.hass.areas[this.host._areaSel];t&&l.unshift(t)}return p`this._roomDialogCancel()}>
    ${s?p`

    ${s}

    `:d} - ${Zo({title:this.host._t("room.group_basics"),help:this._help("room.group_basics.help"),body:p` + ${Yo({title:this.host._t("room.group_basics"),help:this._help("room.group_basics.help"),body:p` ${this.host._t("room.no_area_option")} ${l.map(t=>p``)} `})} - ${Zo({title:this.host._t("room.group_fill"),help:this._help("room.group_fill.help"),body:p` + ${Yo({title:this.host._t("room.group_fill"),help:this._help("room.group_fill.help"),body:p` - ${or.map(({value:t,key:e})=>p`
    @@ -959,7 +946,7 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db ${this.host._t("btn.save")} `}
    -
    `}const rr=new WeakMap;function lr(t,e,s){let i=rr.get(t);i||(i=new Map,rr.set(t,i));const o=i.get(e);if(o)return void(o.run=s);const a={run:s};i.set(e,a),queueMicrotask(()=>{i.get(e)===a&&(i.delete(e),a.run())})}function hr(t,e){const s=rr.get(t),i=s?.get(e);i&&(s.delete(e),i.run())}function cr(t,e){const s=rr.get(t);if(!s)return;const i=e?[...s].filter(([t])=>t===e):[...s];for(const[t]of i)s.delete(t);s.size||rr.delete(t)}const dr=new WeakMap,pr=new Set(["_cursorPt","_opMeasure","_physicalDrag","_physicalRotate","_decorDraft","_dtBox","_dtDrag","_bdDrag","_furnPreviewInput","_layout"]),ur=new Set(["_cursorPt","_opMeasure","_furnPreviewInput"]),_r=new Set(["_physicalDrag","_physicalRotate","_decorDraft","_dtDrag","_bdDrag"]),gr=t=>{let e=dr.get(t);return e||(e={raf:0,requestedRevision:0,paintedRevision:0,waiters:[],hidden:[],transparent:[],dimmed:[]},dr.set(t,e)),e},mr=(t,e)=>{t.paintedRevision=Math.max(t.paintedRevision,e);const s=t.waiters.filter(e=>e.revision<=t.paintedRevision);t.waiters=t.waiters.filter(e=>e.revision>t.paintedRevision);for(const t of s)t.resolve()},fr=t=>!!("view"!==t._mode&&(t._deviceDrag||t._physicalDrag||t._physicalRotate||t._decorDraft||t._decorMove||t._dtDrag||t._bdDrag||t._opDrag||t._resize?.dragging));function br(t,e,s){const i=t;if(!i?.isConnected||"view"===i._mode)return!1;const o=void 0!==e&&pr.has(e);if("_layout"===e&&!i._deviceDrag)return!1;if("_dtBox"===e&&!i._dtDrag)return!1;if(void 0!==e&&_r.has(e)&&null==s&&null!=i[e]&&fr(i))return!1;if(void 0!==e&&_r.has(e)&&null==i[e])return!1;if(void 0!==e&&ur.has(e)&&null==i[e])return!1;return!!(o&&(ur.has(e)||fr(i))||void 0===e&&fr(i))&&(function(t){const e=gr(t);if(e.requestedRevision++,e.raf||"function"!=typeof requestAnimationFrame)return;e.raf=requestAnimationFrame(()=>{e.raf=0;const s=e.requestedRevision;!function(t){const e=t,s=e.renderRoot;if(!s)return;const i=gr(e);$r(i),xr(e,s);const o=s.querySelector("[data-hp-live-editor]");if(!o)return;if(yr(i,s,".hp-editor-only-layer:not(.hp-plan-snap-layer)"),"plan"===e._mode)e._opDrag&&vr(i,s,".wallbodies"),e._resize?.dragging&&(Sr(i,s,".wallbodies"),yr(i,s,".resize-layer"),Cr(i,s,e._resize.plan?.movingOpeningIds||[])),e._opDrag&&yr(i,s,".openinglayer");else if("decor"===e._mode){const t=e._dtDrag?.id||e._decorMove?.id;t&&Mr(i,s,t),yr(i,s,".dtframe, .backdropframe")}Nt(kr(e),o);const a=s.querySelector("[data-hp-live-editor-html]");if(a){const t=e._viewOr(e._baseVb());Nt(e._renderLiveEditorMeasurements(t),a)}e._liveEditorPaintCount=(e._liveEditorPaintCount||0)+1}(t),mr(e,s)})}(i),!0)}const vr=(t,e,s)=>{for(const i of e.querySelectorAll(s))i.closest("[data-hp-live-editor]")||"hidden"!==i.style.visibility&&(i.style.visibility="hidden",t.hidden.push(i))},yr=(t,e,s)=>{for(const i of e.querySelectorAll(s))i.closest("[data-hp-live-editor]")||"0"!==i.style.opacity&&(i.style.opacity="0",t.transparent.push(i))},$r=t=>{for(const e of t.hidden)e.style.removeProperty("visibility");t.hidden.length=0;for(const e of t.transparent)e.style.removeProperty("opacity");t.transparent.length=0;for(const e of t.dimmed)e.style.removeProperty("opacity");t.dimmed.length=0},wr=(t,e,s=[])=>{if("iso"===t._renderProjection)return At``;const i=t._spaceModel();if(!i)return At``;const o=new Set(s),a=(i.rooms||[]).filter(t=>!!t.id&&o.has(t.id)).flatMap(t=>{const e=t.poly||[];return e.map((t,s)=>[t,e[(s+1)%e.length]])}),n=(t,e)=>{const[s,i]=e,o=i[0]-s[0],a=i[1]-s[1],n=o*o+a*a;if(!(n>0))return!1;const r=((t[0]-s[0])*o+(t[1]-s[1])*a)/n,l=Math.max(0,Math.min(1,r));return Math.hypot(t[0]-s[0]-o*l,t[1]-s[1]-a*l)<1e-4},r=[...t._spaceWalls.filter(t=>{const e=(t.a||[]).map(t=>t*lt),s=(t.b||[]).map(t=>t*lt);return a.some(t=>n(e,t)&&n(s,t))}).map((e,s)=>((e,s,i,o)=>{const a=Math.hypot(s[0]-e[0],s[1]-e[1]);if(!(a>1e-9&&i>0))return null;const n=V(i,t._cellCm,t._gridPitch)/2,r=-(s[1]-e[1])/a*n,l=(s[0]-e[0])/a*n;return{key:o,kind:"outer",cm:i,a:e,b:s,depthUnits:2*n,quad:[[e[0]+r,e[1]+l],[s[0]+r,s[1]+l],[s[0]-r,s[1]-l],[e[0]-r,e[1]-l]]}})((e.a||[]).map(t=>t*lt),(e.b||[]).map(t=>t*lt),e.cm,e.key||`wall-${s}`))].filter(t=>!!t),l=t._openingsR.map(t=>({x:t.rx,y:t.ry,angle:t.angle,length:t.rlen})),h=r.map(t=>Et(t,l)).filter(Boolean);if(!h.length)return At``;const c=Math.max(...r.map(t=>t.depthUnits),0),d=t._viewOr(t._baseVb()),p=t._stageEl?.clientWidth&&d.w?t._stageEl.clientWidth/d.w:1,u=Ot(c,p)||Ht(Bt(t._cellCm),p),_=e?.color||"#607d8b",g=t._fillColors.wall_fill,m=h.join(" ");return At``}const lr=new WeakMap;function hr(t,e,s){let i=lr.get(t);i||(i=new Map,lr.set(t,i));const o=i.get(e);if(o)return void(o.run=s);const a={run:s};i.set(e,a),queueMicrotask(()=>{i.get(e)===a&&(i.delete(e),a.run())})}function cr(t,e){const s=lr.get(t),i=s?.get(e);i&&(s.delete(e),i.run())}function dr(t,e){const s=lr.get(t);if(!s)return;const i=e?[...s].filter(([t])=>t===e):[...s];for(const[t]of i)s.delete(t);s.size||lr.delete(t)}const pr=new WeakMap,ur=new Set(["_cursorPt","_opMeasure","_physicalDrag","_physicalRotate","_decorDraft","_dtBox","_dtDrag","_bdDrag","_furnPreviewInput","_layout"]),_r=new Set(["_cursorPt","_opMeasure","_furnPreviewInput"]),gr=new Set(["_physicalDrag","_physicalRotate","_decorDraft","_dtDrag","_bdDrag"]),mr=t=>{let e=pr.get(t);return e||(e={raf:0,requestedRevision:0,paintedRevision:0,waiters:[],hidden:[],transparent:[],dimmed:[]},pr.set(t,e)),e},fr=(t,e)=>{t.paintedRevision=Math.max(t.paintedRevision,e);const s=t.waiters.filter(e=>e.revision<=t.paintedRevision);t.waiters=t.waiters.filter(e=>e.revision>t.paintedRevision);for(const t of s)t.resolve()},br=t=>!!("view"!==t._mode&&(t._deviceDrag||t._physicalDrag||t._physicalRotate||t._decorDraft||t._decorMove||t._dtDrag||t._bdDrag||t._opDrag||t._resize?.dragging));function vr(t,e,s){const i=t;if(!i?.isConnected||"view"===i._mode)return!1;const o=void 0!==e&&ur.has(e);if("_layout"===e&&!i._deviceDrag)return!1;if("_dtBox"===e&&!i._dtDrag)return!1;if(void 0!==e&&gr.has(e)&&null==s&&null!=i[e]&&br(i))return!1;if(void 0!==e&&gr.has(e)&&null==i[e])return!1;if(void 0!==e&&_r.has(e)&&null==i[e])return!1;return!!(o&&(_r.has(e)||br(i))||void 0===e&&br(i))&&(function(t){const e=mr(t);if(e.requestedRevision++,e.raf||"function"!=typeof requestAnimationFrame)return;e.raf=requestAnimationFrame(()=>{e.raf=0;const s=e.requestedRevision;!function(t){const e=t,s=e.renderRoot;if(!s)return;const i=mr(e);wr(i),Mr(e,s);const o=s.querySelector("[data-hp-live-editor]");if(!o)return;if($r(i,s,".hp-editor-only-layer:not(.hp-plan-snap-layer)"),"plan"===e._mode)e._opDrag&&yr(i,s,".wallbodies"),e._resize?.dragging&&(Pr(i,s,".wallbodies"),$r(i,s,".resize-layer"),Sr(i,s,e._resize.plan?.movingOpeningIds||[])),e._opDrag&&$r(i,s,".openinglayer");else if("decor"===e._mode){const t=e._dtDrag?.id||e._decorMove?.id;t&&Cr(i,s,t),$r(i,s,".dtframe, .backdropframe")}Nt(xr(e),o);const a=s.querySelector("[data-hp-live-editor-html]");if(a){const t=e._viewOr(e._baseVb());Nt(e._renderLiveEditorMeasurements(t),a)}e._liveEditorPaintCount=(e._liveEditorPaintCount||0)+1}(t),fr(e,s)})}(i),!0)}const yr=(t,e,s)=>{for(const i of e.querySelectorAll(s))i.closest("[data-hp-live-editor]")||"hidden"!==i.style.visibility&&(i.style.visibility="hidden",t.hidden.push(i))},$r=(t,e,s)=>{for(const i of e.querySelectorAll(s))i.closest("[data-hp-live-editor]")||"0"!==i.style.opacity&&(i.style.opacity="0",t.transparent.push(i))},wr=t=>{for(const e of t.hidden)e.style.removeProperty("visibility");t.hidden.length=0;for(const e of t.transparent)e.style.removeProperty("opacity");t.transparent.length=0;for(const e of t.dimmed)e.style.removeProperty("opacity");t.dimmed.length=0},kr=(t,e,s=[])=>{if("iso"===t._renderProjection)return At``;const i=t._spaceModel();if(!i)return At``;const o=new Set(s),a=(i.rooms||[]).filter(t=>!!t.id&&o.has(t.id)).flatMap(t=>{const e=t.poly||[];return e.map((t,s)=>[t,e[(s+1)%e.length]])}),n=(t,e)=>{const[s,i]=e,o=i[0]-s[0],a=i[1]-s[1],n=o*o+a*a;if(!(n>0))return!1;const r=((t[0]-s[0])*o+(t[1]-s[1])*a)/n,l=Math.max(0,Math.min(1,r));return Math.hypot(t[0]-s[0]-o*l,t[1]-s[1]-a*l)<1e-4},r=[...t._spaceWalls.filter(t=>{const e=(t.a||[]).map(t=>t*lt),s=(t.b||[]).map(t=>t*lt);return a.some(t=>n(e,t)&&n(s,t))}).map((e,s)=>((e,s,i,o)=>{const a=Math.hypot(s[0]-e[0],s[1]-e[1]);if(!(a>1e-9&&i>0))return null;const n=V(i,t._cellCm,t._gridPitch)/2,r=-(s[1]-e[1])/a*n,l=(s[0]-e[0])/a*n;return{key:o,kind:"outer",cm:i,a:e,b:s,depthUnits:2*n,quad:[[e[0]+r,e[1]+l],[s[0]+r,s[1]+l],[s[0]-r,s[1]-l],[e[0]-r,e[1]-l]]}})((e.a||[]).map(t=>t*lt),(e.b||[]).map(t=>t*lt),e.cm,e.key||`wall-${s}`))].filter(t=>!!t),l=t._openingsR.map(t=>({x:t.rx,y:t.ry,angle:t.angle,length:t.rlen})),h=r.map(t=>Et(t,l)).filter(Boolean);if(!h.length)return At``;const c=Math.max(...r.map(t=>t.depthUnits),0),d=t._viewOr(t._baseVb()),p=t._stageEl?.clientWidth&&d.w?t._stageEl.clientWidth/d.w:1,u=Ot(c,p)||Ht(Bt(t._cellCm),p),_=e?.color||"#607d8b",g=t._fillColors.wall_fill,m=h.join(" ");return At` @@ -967,8 +954,8 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db data-id="preview" data-kind="preview" d=${m} fill=${u?"none":"url(#hp-wall-hatch)"} fill-rule="nonzero" stroke=${_} stroke-width=${Wt(.6,t._cellCm)}> - `},kr=t=>{if("plan"===t._mode)return(t=>{const e=t._baseVb(),s=t._viewOr(e),i=t._opMeasureView;if(t._resize?.dragging){const e=t._spaceDisplayForRender(),i=t._resize.plan;return At``},xr=t=>{if("plan"===t._mode)return(t=>{const e=t._baseVb(),s=t._viewOr(e),i=t._opMeasureView;if(t._resize?.dragging){const e=t._spaceDisplayForRender(),i=t._resize.plan;return At``}return At``},xr=(t,e)=>{const s=t._deviceDrag;if(!s)return;const i=t._devices.find(t=>t.id===s.id),o=[...e.querySelectorAll('[data-hp="device"]')].find(t=>t.dataset.id===s.id);if(!i||!o)return;const a=t._livePos(i),n=t._scenePoint([a.x,a.y]),r=t._viewOr(t._baseVb());o.style.left=(n[0]-r.x)/r.w*100+"%",o.style.top=(n[1]-r.y)/r.h*100+"%"},Mr=(t,e,s)=>{for(const i of e.querySelectorAll('.decorlayer [data-hp="decor"]'))i.closest("[data-hp-live-editor]")||i.dataset.id!==s||"0"!==i.style.opacity&&(i.style.opacity="0",t.transparent.push(i))},Cr=(t,e,s)=>{const i=new Set(s);for(const s of e.querySelectorAll('.openinglayer [data-hp="opening"]'))!s.closest("[data-hp-live-editor]")&&i.has(s.dataset.id||"")&&(s.style.opacity="0",t.transparent.push(s))},Sr=(t,e,s)=>{for(const i of e.querySelectorAll(s))i.closest("[data-hp-live-editor]")||(i.style.opacity="0.35",t.dimmed.push(i))};const Pr=(t,e,s)=>Math.min(s,Math.max(e,Number.isFinite(t)?t:e));function Dr(t){return Number.isFinite(t)?(t%360+360)%360:0}function Ir(t){if("string"!=typeof t)return null;const e=t.trim().replace(/^#/,""),s=/^[0-9a-fA-F]{3}$/.test(e)?e.split("").map(t=>`${t}${t}`).join(""):e;return/^[0-9a-fA-F]{6}$/.test(s)?`#${s.toLowerCase()}`:null}function Lr(t){const e=Ir(t);return e?{r:Number.parseInt(e.slice(1,3),16),g:Number.parseInt(e.slice(3,5),16),b:Number.parseInt(e.slice(5,7),16)}:null}function Tr(t){const e=Pr(t.r,0,255)/255,s=Pr(t.g,0,255)/255,i=Pr(t.b,0,255)/255,o=Math.max(e,s,i),a=o-Math.min(e,s,i);let n=0;return a>0&&(n=o===e?(s-i)/a%6*60:o===s?60*((i-e)/a+2):60*((e-s)/a+4)),{h:Dr(n),s:0===o?0:a/o*100,v:100*o}}function Rr(t){return function(t){const e=t=>Math.round(Pr(t,0,255)).toString(16).padStart(2,"0");return`#${e(t.r)}${e(t.g)}${e(t.b)}`}(function(t){const e=Dr(t.h),s=Pr(t.s,0,100)/100,i=Pr(t.v,0,100)/100,o=i*s,a=o*(1-Math.abs(e/60%2-1)),n=i-o;let r;return r=e<60?[o,a,0]:e<120?[a,o,0]:e<180?[0,o,a]:e<240?[0,a,o]:e<300?[a,0,o]:[o,0,a],{r:Math.round(255*(r[0]+n)),g:Math.round(255*(r[1]+n)),b:Math.round(255*(r[2]+n))}}(t))}const zr={title:"Color picker",hue:"Hue",saturation:"Saturation",value:"Brightness",hex:"Hex color",invalidHex:"Enter a 3- or 6-digit hex color",confirm:"OK"};class Fr extends Gt{constructor(){super(...arguments),this.label="",this.opacityLabel="Opacity",this.color="#607d8b",this.opacity=1,this.disabled=!1,this.showOpacity=!0,this.pickerLabels=zr,this._open=!1,this._pickerRaf=0,this._emitRaf=0,this._forceFallback=!1,this._overlayDispose=null,this._hue=0,this._saturation=0,this._value=0,this._hexDraft="#607d8b",this._hexInvalid=!1,this._hexNeedsValidInput=!1,this._lastValidColor="#607d8b",this._activePointerId=null,this._outsidePointerDown=t=>{if(!this._open)return;const e=t.composedPath();this._floating.containsPath(e)||this._closePicker(!1,"outside")},this._keyDown=t=>{this._open&&"Escape"===t.key&&(t.preventDefault(),t.stopImmediatePropagation(),this._closePicker(this._floating.ownsActiveElement(),"escape"))},this._floating=new $o(this,"color-opacity",this._keyDown),this._queuePickerPosition=()=>{if(!this._open)return;this._pickerRaf&&cancelAnimationFrame(this._pickerRaf);const t=this._window();t&&(this._pickerRaf=t.requestAnimationFrame(()=>{this._pickerRaf=0,this._positionPicker()||this._closePicker()}))}}connectedCallback(){super.connectedCallback(),this._syncFromColor(this.color,!1),this.ownerDocument.addEventListener("pointerdown",this._outsidePointerDown,!0),this.ownerDocument.addEventListener("scroll",this._queuePickerPosition,!0);const t=this.ownerDocument.defaultView;t?.addEventListener("resize",this._queuePickerPosition),t?.addEventListener("orientationchange",this._queuePickerPosition),t?.visualViewport?.addEventListener("resize",this._queuePickerPosition),t?.visualViewport?.addEventListener("scroll",this._queuePickerPosition),this.addEventListener("keydown",this._keyDown,!0)}disconnectedCallback(){this.ownerDocument.removeEventListener("pointerdown",this._outsidePointerDown,!0),this.ownerDocument.removeEventListener("scroll",this._queuePickerPosition,!0);const t=this.ownerDocument.defaultView;t?.removeEventListener("resize",this._queuePickerPosition),t?.removeEventListener("orientationchange",this._queuePickerPosition),t?.visualViewport?.removeEventListener("resize",this._queuePickerPosition),t?.visualViewport?.removeEventListener("scroll",this._queuePickerPosition),this.removeEventListener("keydown",this._keyDown,!0),this._pickerRaf&&cancelAnimationFrame(this._pickerRaf),this._emitRaf&&cancelAnimationFrame(this._emitRaf),this._pickerRaf=0,this._emitRaf=0,this._closePicker(!1,"disconnect"),super.disconnectedCallback()}updated(t){if(t.has("color")){const t=Ir(this.color);t&&t!==this._lastValidColor&&this._syncFromColor(t,this._open)}this.disabled&&this._open?this._closePicker():this._open&&(this._supportsPopover()||this._renderFallback(),(t.has("color")||t.has("opacity")||t.has("showOpacity")||t.has("label")||t.has("opacityLabel")||t.has("pickerLabels"))&&this._queuePickerPosition())}_window(){return this._floating.window()}_supportsPopover(){return this._floating.usesPopover(this._forceFallback)}_dialog(){return this._floating.dialog()}async _toggle(){this.disabled||(this._open?this._closePicker():(this._forceFallback=!1,this._syncFromColor(this.color,!1),this._hexInvalid=!1,this._hexNeedsValidInput=!1,this._activePointerId=null,this._open=!0,await this.updateComplete,this._open&&(this._supportsPopover()||this._renderFallback(),this._positionPicker()?this._overlayDispose=this._dialog()?.registerOverlay({owner:this,group:"transient",close:t=>this._closePicker("escape"===t&&this._floating.ownsActiveElement(),t)})||null:this._closePicker())))}_closePicker(t=!1,e="exclusive"){if(!this._open&&!this._floating.hasFallback)return;const s=this._overlayDispose;this._overlayDispose=null,s?.();const i=this.renderRoot.querySelector(".picker");if(i?.hidePopover)try{i.matches(":popover-open")&&i.hidePopover()}catch{}this._open=!1,this._cancelQueuedEmit(),this._activePointerId=null,this._floating.destroy(),t&&this.updateComplete.then(()=>this.renderRoot.querySelector(".trigger")?.focus())}_surface(){return this._floating.surface(".picker",this._supportsPopover())}_renderFallback(){const t=Fr.styles.cssText;this._floating.renderFallback(this._pickerTemplate(!1),t)}_positionPicker(){if(!this._open)return!1;const t=this._window(),e=this.renderRoot.querySelector(".trigger");let s=this._surface();if(!t||!e?.isConnected||!s?.isConnected)return!1;const i=wo(t);if(s.style.maxWidth=`${Math.max(0,i.width-16)}px`,s.style.maxHeight=`${Math.max(0,i.height-16)}px`,s.style.visibility="hidden",this._supportsPopover()&&s.showPopover)try{s.matches(":popover-open")||s.showPopover()}catch{if(this._forceFallback=!0,this._renderFallback(),s=this._surface(),!s?.isConnected)return!1;s.style.maxWidth=`${Math.max(0,i.width-16)}px`,s.style.maxHeight=`${Math.max(0,i.height-16)}px`,s.style.visibility="hidden"}const o=e.getBoundingClientRect(),a=s.getBoundingClientRect();if(!(o.width&&o.height&&a.width&&a.height))return!1;const n=ko(o,a,i);return s.style.left=`${n.left}px`,s.style.top=`${n.top}px`,s.dataset.side=n.side,s.style.visibility="",!0}_labels(){const t=this.pickerLabels||zr;return{title:t.title||zr.title,hue:t.hue||zr.hue,saturation:t.saturation||zr.saturation,value:t.value||zr.value,hex:t.hex||zr.hex,invalidHex:t.invalidHex||zr.invalidHex,confirm:t.confirm||zr.confirm}}_syncFromColor(t,e){const s=Ir(qt(t,"#607d8b"))||"#607d8b",i=Lr(s);if(!i)return;const o=Tr(i);(!e||o.s>1e-4)&&(this._hue=o.h),this._saturation=o.s,this._value=o.v,this._hexDraft=s,this._hexInvalid=!1,this._hexNeedsValidInput=!1,this._lastValidColor=s}_cancelQueuedEmit(t=!1){this._emitRaf&&cancelAnimationFrame(this._emitRaf),this._emitRaf=0,t&&this._syncFromColor(this._lastValidColor,!0)}_queueHsvEmit(){if(this._emitRaf)return;const t=this._window();t?this._emitRaf=t.requestAnimationFrame(()=>{this._emitRaf=0,this._emitHsv()}):this._emitHsv()}_emitHsv(){this._emit(Rr({h:this._hue,s:this._saturation,v:this._value}),this.opacity)}_setHue(t){this._hue=Math.min(359,Math.max(0,Number.isFinite(t)?t:0)),this._emitHsv()}_setSaturation(t){this._saturation=Math.min(100,Math.max(0,Number.isFinite(t)?t:0)),this._emitHsv()}_setValue(t){this._value=Math.min(100,Math.max(0,Number.isFinite(t)?t:0)),this._emitHsv()}_setOpacity(t){this._emit(this._lastValidColor,t)}_shiftRangeKey(t,e,s,i,o){if(!t.shiftKey)return;const a="ArrowRight"===t.key||"ArrowUp"===t.key?10:"ArrowLeft"===t.key||"ArrowDown"===t.key?-10:0;a&&(t.preventDefault(),t.stopPropagation(),o(Math.min(i,Math.max(s,e+a))))}_setSvFromPointer(t,e){const s=t.currentTarget.getBoundingClientRect();s.width&&s.height&&(this._saturation=Math.min(100,Math.max(0,(t.clientX-s.left)/s.width*100)),this._value=Math.min(100,Math.max(0,100*(1-(t.clientY-s.top)/s.height))),e?(this._cancelQueuedEmit(),this._emitHsv()):this._queueHsvEmit())}_svPointerDown(t){if(t.preventDefault(),t.stopPropagation(),null===this._activePointerId){this._activePointerId=t.pointerId;try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}this._setSvFromPointer(t,!0)}}_svPointerMove(t){t.pointerId===this._activePointerId&&(t.preventDefault(),t.stopPropagation(),this._setSvFromPointer(t,!1))}_svPointerUp(t){if(t.pointerId===this._activePointerId){t.preventDefault(),t.stopPropagation(),this._setSvFromPointer(t,!0),this._activePointerId=null;try{t.currentTarget.releasePointerCapture(t.pointerId)}catch{}}}_svPointerCancel(t){t.pointerId===this._activePointerId&&(t.preventDefault(),t.stopPropagation(),this._activePointerId=null,this._cancelQueuedEmit(!0))}_svLostPointerCapture(t){t.pointerId===this._activePointerId&&(this._activePointerId=null,this._cancelQueuedEmit(!0))}_hexInput(t){const e=t.target.value;this._hexDraft=e;const s=Ir(e),i=s?Lr(s):null;if(!s||!i)return void(this._hexInvalid=this._hexNeedsValidInput);this._hexNeedsValidInput=!1,this._hexInvalid=!1;const o=Tr(i);o.s>1e-4&&(this._hue=o.h),this._saturation=o.s,this._value=o.v,this._emit(s,this.opacity,!0)}_commitHex(){const t=Ir(this._hexDraft);if(!t)return this._hexDraft=this._lastValidColor,this._hexInvalid=!0,void(this._hexNeedsValidInput=!0);this._hexDraft=t,this._hexNeedsValidInput?this._hexInvalid=!0:(this._hexInvalid=!1,t!==this._lastValidColor&&this._emit(t,this.opacity))}_confirm(t){t.preventDefault(),t.stopPropagation(),this._commitHex(),this._hexInvalid||this._hexNeedsValidInput?this.updateComplete.then(()=>{this._surface()?.querySelector('input[type="text"]')?.focus()}):this._closePicker(!0)}_hexKeyDown(t){"Enter"===t.key&&(t.preventDefault(),t.stopPropagation(),this._commitHex())}_emit(t,e,s=!1){const i=Ir(t)||this._lastValidColor,o=Number.isFinite(e)?e:Number(this.opacity)||0,a=Math.min(1,Math.max(0,o));this.color=i,this.opacity=a,this._lastValidColor=i,s||(this._hexDraft=i),this._hexInvalid=this._hexNeedsValidInput,this.dispatchEvent(new CustomEvent("hp-color-opacity-change",{detail:{color:i,opacity:a},bubbles:!0,composed:!0}))}_pickerTemplate(t){const e=Math.round(100*Math.min(1,Math.max(0,Number(this.opacity)||0))),s=Rr({h:this._hue,s:this._saturation,v:this._value}),i=Rr({h:this._hue,s:100,v:100}),o=this._labels(),a=Math.round(this._hue),n=Math.round(this._saturation),r=Math.round(this._value);return p` + `},Mr=(t,e)=>{const s=t._deviceDrag;if(!s)return;const i=t._devices.find(t=>t.id===s.id),o=[...e.querySelectorAll('[data-hp="device"]')].find(t=>t.dataset.id===s.id);if(!i||!o)return;const a=t._livePos(i),n=t._scenePoint([a.x,a.y]),r=t._viewOr(t._baseVb());o.style.left=(n[0]-r.x)/r.w*100+"%",o.style.top=(n[1]-r.y)/r.h*100+"%"},Cr=(t,e,s)=>{for(const i of e.querySelectorAll('.decorlayer [data-hp="decor"]'))i.closest("[data-hp-live-editor]")||i.dataset.id!==s||"0"!==i.style.opacity&&(i.style.opacity="0",t.transparent.push(i))},Sr=(t,e,s)=>{const i=new Set(s);for(const s of e.querySelectorAll('.openinglayer [data-hp="opening"]'))!s.closest("[data-hp-live-editor]")&&i.has(s.dataset.id||"")&&(s.style.opacity="0",t.transparent.push(s))},Pr=(t,e,s)=>{for(const i of e.querySelectorAll(s))i.closest("[data-hp-live-editor]")||(i.style.opacity="0.35",t.dimmed.push(i))};const Dr=(t,e,s)=>Math.min(s,Math.max(e,Number.isFinite(t)?t:e));function Ir(t){return Number.isFinite(t)?(t%360+360)%360:0}function Lr(t){if("string"!=typeof t)return null;const e=t.trim().replace(/^#/,""),s=/^[0-9a-fA-F]{3}$/.test(e)?e.split("").map(t=>`${t}${t}`).join(""):e;return/^[0-9a-fA-F]{6}$/.test(s)?`#${s.toLowerCase()}`:null}function Tr(t){const e=Lr(t);return e?{r:Number.parseInt(e.slice(1,3),16),g:Number.parseInt(e.slice(3,5),16),b:Number.parseInt(e.slice(5,7),16)}:null}function Rr(t){const e=Dr(t.r,0,255)/255,s=Dr(t.g,0,255)/255,i=Dr(t.b,0,255)/255,o=Math.max(e,s,i),a=o-Math.min(e,s,i);let n=0;return a>0&&(n=o===e?(s-i)/a%6*60:o===s?60*((i-e)/a+2):60*((e-s)/a+4)),{h:Ir(n),s:0===o?0:a/o*100,v:100*o}}function zr(t){return function(t){const e=t=>Math.round(Dr(t,0,255)).toString(16).padStart(2,"0");return`#${e(t.r)}${e(t.g)}${e(t.b)}`}(function(t){const e=Ir(t.h),s=Dr(t.s,0,100)/100,i=Dr(t.v,0,100)/100,o=i*s,a=o*(1-Math.abs(e/60%2-1)),n=i-o;let r;return r=e<60?[o,a,0]:e<120?[a,o,0]:e<180?[0,o,a]:e<240?[0,a,o]:e<300?[a,0,o]:[o,0,a],{r:Math.round(255*(r[0]+n)),g:Math.round(255*(r[1]+n)),b:Math.round(255*(r[2]+n))}}(t))}const Fr={title:"Color picker",hue:"Hue",saturation:"Saturation",value:"Brightness",hex:"Hex color",invalidHex:"Enter a 3- or 6-digit hex color",confirm:"OK"};class Nr extends Gt{constructor(){super(...arguments),this.label="",this.opacityLabel="Opacity",this.color="#607d8b",this.opacity=1,this.disabled=!1,this.showOpacity=!0,this.pickerLabels=Fr,this._open=!1,this._pickerRaf=0,this._emitRaf=0,this._forceFallback=!1,this._overlayDispose=null,this._hue=0,this._saturation=0,this._value=0,this._hexDraft="#607d8b",this._hexInvalid=!1,this._hexNeedsValidInput=!1,this._lastValidColor="#607d8b",this._activePointerId=null,this._outsidePointerDown=t=>{if(!this._open)return;const e=t.composedPath();this._floating.containsPath(e)||this._closePicker(!1,"outside")},this._keyDown=t=>{this._open&&"Escape"===t.key&&(t.preventDefault(),t.stopImmediatePropagation(),this._closePicker(this._floating.ownsActiveElement(),"escape"))},this._floating=new $o(this,"color-opacity",this._keyDown),this._queuePickerPosition=()=>{if(!this._open)return;this._pickerRaf&&cancelAnimationFrame(this._pickerRaf);const t=this._window();t&&(this._pickerRaf=t.requestAnimationFrame(()=>{this._pickerRaf=0,this._positionPicker()||this._closePicker()}))}}connectedCallback(){super.connectedCallback(),this._syncFromColor(this.color,!1),this.ownerDocument.addEventListener("pointerdown",this._outsidePointerDown,!0),this.ownerDocument.addEventListener("scroll",this._queuePickerPosition,!0);const t=this.ownerDocument.defaultView;t?.addEventListener("resize",this._queuePickerPosition),t?.addEventListener("orientationchange",this._queuePickerPosition),t?.visualViewport?.addEventListener("resize",this._queuePickerPosition),t?.visualViewport?.addEventListener("scroll",this._queuePickerPosition),this.addEventListener("keydown",this._keyDown,!0)}disconnectedCallback(){this.ownerDocument.removeEventListener("pointerdown",this._outsidePointerDown,!0),this.ownerDocument.removeEventListener("scroll",this._queuePickerPosition,!0);const t=this.ownerDocument.defaultView;t?.removeEventListener("resize",this._queuePickerPosition),t?.removeEventListener("orientationchange",this._queuePickerPosition),t?.visualViewport?.removeEventListener("resize",this._queuePickerPosition),t?.visualViewport?.removeEventListener("scroll",this._queuePickerPosition),this.removeEventListener("keydown",this._keyDown,!0),this._pickerRaf&&cancelAnimationFrame(this._pickerRaf),this._emitRaf&&cancelAnimationFrame(this._emitRaf),this._pickerRaf=0,this._emitRaf=0,this._closePicker(!1,"disconnect"),super.disconnectedCallback()}updated(t){if(t.has("color")){const t=Lr(this.color);t&&t!==this._lastValidColor&&this._syncFromColor(t,this._open)}this.disabled&&this._open?this._closePicker():this._open&&(this._supportsPopover()||this._renderFallback(),(t.has("color")||t.has("opacity")||t.has("showOpacity")||t.has("label")||t.has("opacityLabel")||t.has("pickerLabels"))&&this._queuePickerPosition())}_window(){return this._floating.window()}_supportsPopover(){return this._floating.usesPopover(this._forceFallback)}_dialog(){return this._floating.dialog()}async _toggle(){this.disabled||(this._open?this._closePicker():(this._forceFallback=!1,this._syncFromColor(this.color,!1),this._hexInvalid=!1,this._hexNeedsValidInput=!1,this._activePointerId=null,this._open=!0,await this.updateComplete,this._open&&(this._supportsPopover()||this._renderFallback(),this._positionPicker()?this._overlayDispose=this._dialog()?.registerOverlay({owner:this,group:"transient",close:t=>this._closePicker("escape"===t&&this._floating.ownsActiveElement(),t)})||null:this._closePicker())))}_closePicker(t=!1,e="exclusive"){if(!this._open&&!this._floating.hasFallback)return;const s=this._overlayDispose;this._overlayDispose=null,s?.();const i=this.renderRoot.querySelector(".picker");if(i?.hidePopover)try{i.matches(":popover-open")&&i.hidePopover()}catch{}this._open=!1,this._cancelQueuedEmit(),this._activePointerId=null,this._floating.destroy(),t&&this.updateComplete.then(()=>this.renderRoot.querySelector(".trigger")?.focus())}_surface(){return this._floating.surface(".picker",this._supportsPopover())}_renderFallback(){const t=Nr.styles.cssText;this._floating.renderFallback(this._pickerTemplate(!1),t)}_positionPicker(){if(!this._open)return!1;const t=this._window(),e=this.renderRoot.querySelector(".trigger");let s=this._surface();if(!t||!e?.isConnected||!s?.isConnected)return!1;const i=wo(t);if(s.style.maxWidth=`${Math.max(0,i.width-16)}px`,s.style.maxHeight=`${Math.max(0,i.height-16)}px`,s.style.visibility="hidden",this._supportsPopover()&&s.showPopover)try{s.matches(":popover-open")||s.showPopover()}catch{if(this._forceFallback=!0,this._renderFallback(),s=this._surface(),!s?.isConnected)return!1;s.style.maxWidth=`${Math.max(0,i.width-16)}px`,s.style.maxHeight=`${Math.max(0,i.height-16)}px`,s.style.visibility="hidden"}const o=e.getBoundingClientRect(),a=s.getBoundingClientRect();if(!(o.width&&o.height&&a.width&&a.height))return!1;const n=ko(o,a,i);return s.style.left=`${n.left}px`,s.style.top=`${n.top}px`,s.dataset.side=n.side,s.style.visibility="",!0}_labels(){const t=this.pickerLabels||Fr;return{title:t.title||Fr.title,hue:t.hue||Fr.hue,saturation:t.saturation||Fr.saturation,value:t.value||Fr.value,hex:t.hex||Fr.hex,invalidHex:t.invalidHex||Fr.invalidHex,confirm:t.confirm||Fr.confirm}}_syncFromColor(t,e){const s=Lr(qt(t,"#607d8b"))||"#607d8b",i=Tr(s);if(!i)return;const o=Rr(i);(!e||o.s>1e-4)&&(this._hue=o.h),this._saturation=o.s,this._value=o.v,this._hexDraft=s,this._hexInvalid=!1,this._hexNeedsValidInput=!1,this._lastValidColor=s}_cancelQueuedEmit(t=!1){this._emitRaf&&cancelAnimationFrame(this._emitRaf),this._emitRaf=0,t&&this._syncFromColor(this._lastValidColor,!0)}_queueHsvEmit(){if(this._emitRaf)return;const t=this._window();t?this._emitRaf=t.requestAnimationFrame(()=>{this._emitRaf=0,this._emitHsv()}):this._emitHsv()}_emitHsv(){this._emit(zr({h:this._hue,s:this._saturation,v:this._value}),this.opacity)}_setHue(t){this._hue=Math.min(359,Math.max(0,Number.isFinite(t)?t:0)),this._emitHsv()}_setSaturation(t){this._saturation=Math.min(100,Math.max(0,Number.isFinite(t)?t:0)),this._emitHsv()}_setValue(t){this._value=Math.min(100,Math.max(0,Number.isFinite(t)?t:0)),this._emitHsv()}_setOpacity(t){this._emit(this._lastValidColor,t)}_shiftRangeKey(t,e,s,i,o){if(!t.shiftKey)return;const a="ArrowRight"===t.key||"ArrowUp"===t.key?10:"ArrowLeft"===t.key||"ArrowDown"===t.key?-10:0;a&&(t.preventDefault(),t.stopPropagation(),o(Math.min(i,Math.max(s,e+a))))}_setSvFromPointer(t,e){const s=t.currentTarget.getBoundingClientRect();s.width&&s.height&&(this._saturation=Math.min(100,Math.max(0,(t.clientX-s.left)/s.width*100)),this._value=Math.min(100,Math.max(0,100*(1-(t.clientY-s.top)/s.height))),e?(this._cancelQueuedEmit(),this._emitHsv()):this._queueHsvEmit())}_svPointerDown(t){if(t.preventDefault(),t.stopPropagation(),null===this._activePointerId){this._activePointerId=t.pointerId;try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}this._setSvFromPointer(t,!0)}}_svPointerMove(t){t.pointerId===this._activePointerId&&(t.preventDefault(),t.stopPropagation(),this._setSvFromPointer(t,!1))}_svPointerUp(t){if(t.pointerId===this._activePointerId){t.preventDefault(),t.stopPropagation(),this._setSvFromPointer(t,!0),this._activePointerId=null;try{t.currentTarget.releasePointerCapture(t.pointerId)}catch{}}}_svPointerCancel(t){t.pointerId===this._activePointerId&&(t.preventDefault(),t.stopPropagation(),this._activePointerId=null,this._cancelQueuedEmit(!0))}_svLostPointerCapture(t){t.pointerId===this._activePointerId&&(this._activePointerId=null,this._cancelQueuedEmit(!0))}_hexInput(t){const e=t.target.value;this._hexDraft=e;const s=Lr(e),i=s?Tr(s):null;if(!s||!i)return void(this._hexInvalid=this._hexNeedsValidInput);this._hexNeedsValidInput=!1,this._hexInvalid=!1;const o=Rr(i);o.s>1e-4&&(this._hue=o.h),this._saturation=o.s,this._value=o.v,this._emit(s,this.opacity,!0)}_commitHex(){const t=Lr(this._hexDraft);if(!t)return this._hexDraft=this._lastValidColor,this._hexInvalid=!0,void(this._hexNeedsValidInput=!0);this._hexDraft=t,this._hexNeedsValidInput?this._hexInvalid=!0:(this._hexInvalid=!1,t!==this._lastValidColor&&this._emit(t,this.opacity))}_confirm(t){t.preventDefault(),t.stopPropagation(),this._commitHex(),this._hexInvalid||this._hexNeedsValidInput?this.updateComplete.then(()=>{this._surface()?.querySelector('input[type="text"]')?.focus()}):this._closePicker(!0)}_hexKeyDown(t){"Enter"===t.key&&(t.preventDefault(),t.stopPropagation(),this._commitHex())}_emit(t,e,s=!1){const i=Lr(t)||this._lastValidColor,o=Number.isFinite(e)?e:Number(this.opacity)||0,a=Math.min(1,Math.max(0,o));this.color=i,this.opacity=a,this._lastValidColor=i,s||(this._hexDraft=i),this._hexInvalid=this._hexNeedsValidInput,this.dispatchEvent(new CustomEvent("hp-color-opacity-change",{detail:{color:i,opacity:a},bubbles:!0,composed:!0}))}_pickerTemplate(t){const e=Math.round(100*Math.min(1,Math.max(0,Number(this.opacity)||0))),s=zr({h:this._hue,s:this._saturation,v:this._value}),i=zr({h:this._hue,s:100,v:100}),o=this._labels(),a=Math.round(this._hue),n=Math.round(this._saturation),r=Math.round(this._value);return p` `}afterRender(){const t=this.host.root();this._blocked&&(this._openGroupId?this.closeGroup(!1):"palette"===this._currentModel?.kind&&this._currentModel.dismiss?.()),this._syncGlobalDismissListener();const e=t.querySelector(".editor-secondary"),s=this._renderedContext,i=e?.dataset.contextId||"";if(i&&s&&i!==s&&!window.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches&&(this._contentAnimation?.cancel(),this._contentAnimation=e?.querySelector(".editor-secondary-content")?.animate([{opacity:.35,transform:"translateY(-4px)"},{opacity:1,transform:"translateY(0)"}],{duration:100,easing:"ease-out"})),this._renderedContext=i,s&&i!==s&&this._focusOwned){const s=i?e?.querySelector('[tabindex="0"], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])'):t.querySelector(".editbar-tools");s?.focus?.(),this._focusOwned=!!i}if("palette"===this._currentModel?.kind&&this._currentModel.launcherId){const e=[...t.querySelectorAll("[data-editor-palette]")].find(t=>t.dataset.editorPalette===this._currentModel?.launcherId);e&&null!==e.offsetParent||this._currentModel.dismiss?.()}if(!this._openGroupId)return;const o=[...t.querySelectorAll("[data-editor-group]")].find(t=>t.dataset.editorGroup===this._openGroupId);o&&null!==o.offsetParent||this.closeGroup(!0)}handleOutsideDismiss(t){if(Ac(t,t=>t.hasAttribute("data-editor-navigation")))return"pointerdown"===t.type?this.closeForNavigation():"click"===t.type&&this._dismissPointerTarget&&this._clearDismissClick(),!1;if("click"===t.type&&this._dismissPointerTarget){return!!(t.composedPath?.()||[t.target]).includes(this._dismissPointerTarget)&&(this._clearDismissClick(),t.preventDefault(),t.stopImmediatePropagation(),!0)}const e=this._openGroupId||this._blocked||"palette"!==this._currentModel?.kind?null:this._currentModel;if("pointerdown"===t.type&&(this._openGroupId||e)){const s=Ac(t,t=>t.classList.contains("editor-secondary")),i=Ac(t,t=>!!t.dataset.editorGroup),o=Ac(t,t=>!!t.dataset.editorPalette),a=Ac(t,t=>t.classList.contains("stage"));if(!(s||i||o||"stay-open-on-canvas"===e?.dismissPolicy&&a))return t.preventDefault(),t.stopImmediatePropagation(),this._dismissPointerTarget=t.target,clearTimeout(this._dismissTimer),this._dismissTimer=window.setTimeout(()=>{this._clearDismissClick()},800),this._openGroupId?this.closeGroup(!1):e?.dismiss?.(),this._syncGlobalDismissListener(),!0}return!1}_activateGroupItem(t,e,s){if(t.id!==this._openGroupId)return;const i=t.items.find(t=>t.id===e);if(!i||i.disabled)return;const o="toggle"===i.role&&"stay-open"===i.closePolicy,a=0===s.detail;o||(this._openGroupId=null,this.host.requestUpdate(),this._syncGlobalDismissListener()),i.invoke(),!o&&a&&this.host.updateComplete().then(()=>{const e=[...this.host.root().querySelectorAll("[data-editor-group]")].find(e=>e.dataset.editorGroup===t.id&&null!==e.offsetParent);e?.focus()})}_groupKeydown(t){if(!["ArrowLeft","ArrowRight","Home","End"].includes(t.key))return;const e=[...t.currentTarget.querySelectorAll(".editor-group-item:not([disabled])")];if(!e.length)return;t.preventDefault();const s=e.indexOf(this.host.root().activeElement),i="Home"===t.key?0:"End"===t.key?e.length-1:"ArrowLeft"===t.key?s<=0?e.length-1:s-1:(s+1)%e.length;e[i]?.focus()}_clearDismissClick(){this._dismissPointerTarget=null,clearTimeout(this._dismissTimer),this._dismissTimer=void 0,this._syncGlobalDismissListener()}_syncGlobalDismissListener(){const t=!this._blocked&&"palette"===this._currentModel?.kind,e=!!this._openGroupId||t||!!this._dismissPointerTarget;e!==this._globalDismissListening&&(this._globalDismissListening=e,e?(window.addEventListener("pointerdown",this._globalDismissGuard,!0),window.addEventListener("click",this._globalDismissGuard,!0)):(window.removeEventListener("pointerdown",this._globalDismissGuard,!0),window.removeEventListener("click",this._globalDismissGuard,!0)))}}const Oc=t=>t.stopPropagation(),Hc=new WeakSet,Bc=t=>{t._regSignature="",t._maybeRebuildDevices(),t.requestUpdate()};async function Wc(t,e,s,i,o,a=""){const n=t.host,r=n._serverCfg;if(!r)return!1;let l=JSON.parse(JSON.stringify(r));l.markers=l.markers||[];let h=l.markers.find(t=>t.id===e);if(!h){const t=n._devices.find(t=>t.id===e);if(!t||"device"!==t.bindingKind&&"entity"!==t.bindingKind||!t.bindingRef)return!1;h={id:t.id,binding:`${t.bindingKind}:${t.bindingRef}`,space:t.space||null,area:t.area||null,hidden:!!t.hidden},l.markers.push(h)}h.vacuum=function(t,e){const s=e.matrix.map(t=>Number(t.toFixed(6))),i=t?.map_routes;if(Array.isArray(i)&&i.length){const o=i.find(t=>t.id===e.routeId)||i.find(t=>t.source===e.source&&t.map_id===e.mapId);if(o)return{...t,map_routes:jo(i,o.id,s)}}return{...t,source:e.source,calibration:{...t?.calibration||{},[e.mapId]:s}}}(h.vacuum||{},{source:s,mapId:i,routeId:a,matrix:o}),l=t._prepareConfigCandidate(l);const c=n._adoption.beginOptimistic(r,l);n._adoption.stageLocalConfig(l),Bc(n),n._saveConfigDebounced.pending()&&n._saveConfigDebounced.cancel();try{return await t._saveConfigNow(c),!0}catch(t){return n._rollbackOptimistic(c),Bc(n),n._showToast(n._t("toast.cfg_save_failed",{err:n._errText(t)})),!1}}function jc(t){return 1===t}function Gc(t){return`${t}-${globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}`}function qc(t){const e=function(t){return JSON.stringify({message:t.message.trim(),contact:t.contact.trim(),previewToken:t.attach&&t.preview?t.preview.token:""})}(t);return{idempotencyKey:t.submissionFingerprint&&t.submissionFingerprint!==e?Gc("report"):t.idempotencyKey,fingerprint:e}}function Uc(t){return[...t].length}function Kc(t,e=Date.now()){const s=t.message.trim();return s?Uc(s)>1e4?"message_too_long":Uc(t.contact.trim())>320?"contact_too_long":t.attach&&!t.preview?"preview_missing":t.attach&&t.preview.expiresAt<=e?"preview_expired":null:"message_required"}function Vc(t,e=Date.now()){return"building"!==t.status&&"sending"!==t.status&&"success"!==t.status&&null===Kc(t,e)}function Jc(t){const e=function(t){const e=/Firefox\/(\d+)/i.exec(t);if(e)return{family:"firefox",major:Number(e[1])||0};const s=/(?:Chrome|Chromium|Edg)\/(\d+)/i.exec(t);if(s)return{family:"chromium",major:Number(s[1])||0};const i=/Version\/(\d+).+Safari\//i.exec(t);return i?{family:"webkit",major:Number(i[1])||0}:{family:"unknown",major:0}}(t.userAgent??globalThis.navigator?.userAgent??""),s=t.now??Date.now(),i=Number(t.registryLastSuccess||0),o=i<=0?"unknown":s-i<=6e5?"fresh":"stale",a=["en","ru","de","fr"].includes(t.language)?t.language:"en",n=globalThis.matchMedia?.bind(globalThis);return{browser_family:e.family,browser_major:Math.max(0,Math.min(999,e.major)),language:a,coarse_pointer:t.coarsePointer??!!n?.("(pointer: coarse)").matches,hover_capable:t.hoverCapable??!!n?.("(hover: hover)").matches,registry_access:"full"===t.registryAccess?"full":"limited"===t.registryAccess?"partial":"unavailable",registry_age_bucket:o}}function Zc(t){const e=t&&"object"==typeof t&&"code"in t?String(t.code||""):"";return new Set(["support_invalid_message","support_preview_expired","support_package_too_large","support_rate_limited","support_unavailable","support_rejected","unauthorized"]).has(e)?e:"support_unavailable"}const Yc=[{id:"air_conditioner",group:"appliance",art:{d:"M85 71.5 L85 63 M25 71.5 L25 63 M25 71.5 L89.5 71.5 C90.8807 71.5 92 70.3807 92 69 L92 41.5 C92 40.1193 90.8807 39 89.5 39 L20.5 39 C19.1193 39 18 40.1193 18 41.5 L18 69 C18 70.3807 19.1193 71.5 20.5 71.5 L25 71.5 Z M85 63 C85 61.6193 83.8807 60.5 82.5 60.5 L27.5 60.5 C26.1193 60.5 25 61.6193 25 63 M85 63 L85 66.5 L25 66.5 L25 63",viewW:110,viewH:110}},{id:"armchair",group:"furniture",art:{d:"M77.5 48.5 L77.5 39 C77.5 33.4772 73.0228 29 67.5 29 L42.5 29 C36.9772 29 32.5 33.4772 32.5 39 L32.5 48.5205 M77.5 48.5 C80.8137 48.5 83.5 51.1863 83.5 54.5 C83.5 57.1123 81.8302 59.3334 79.5 60.1572 L79.5 71.5 C79.5 73.7091 77.7091 75.5 75.5 75.5 M77.5 48.5 C74.2576 48.5 71.617 51.072 71.5049 54.2871 C71.5012 54.3576 71.5 54.4286 71.5 54.5 L71.5 61.75 M38 61.75 L38 54 C38 53.2396 37.7873 52.5291 37.4189 51.9238 C36.5228 50.0421 34.6765 48.7002 32.5 48.5205 M32.5 48.5205 C32.3351 48.5069 32.1684 48.5 32 48.5 M75.5 75.5 L34 75.5 M75.5 75.5 L72.5 75.5 M34 75.5 C31.7909 75.5 30 73.7091 30 71.5 L30 60.1572 C27.6698 59.3334 26 57.1123 26 54.5 C26 51.1863 28.6863 48.5 32 48.5 M34 75.5 L36.5 75.5 M32 48.5 C34.3914 48.5 36.4549 49.8996 37.4189 51.9238 M38 61.75 C38 64.3734 40.1266 66.5 42.75 66.5 L66.75 66.5 C69.3734 66.5 71.5 64.3734 71.5 61.75 M38 61.75 C38 59.1266 40.1266 57 42.75 57 L66.75 57 C69.3734 57 71.5 59.1266 71.5 61.75 M36.5 75.5 L44.5 75.5 M36.5 75.5 L36.5 80.5 C36.5 81.3284 37.1716 82 38 82 L41.3921 82 C42.0506 82 42.6321 81.5705 42.8258 80.9411 L44.5 75.5 M44.5 75.5 L64.5 75.5 M72.5 75.5 L64.5 75.5 M72.5 75.5 L72.5 80.5 C72.5 81.3284 71.8284 82 71 82 L67.6079 82 C66.9494 82 66.3679 81.5705 66.1742 80.9411 L64.5 75.5",viewW:110,viewH:110}},{id:"bathtub",group:"sanitary",art:{d:"M28 74.8457 L28 80 C28 80.8284 28.6716 81.5 29.5 81.5 L32.8921 81.5 C33.5506 81.5 34.1321 81.0705 34.3258 80.4411 L35.6923 76 M28.0191 74.8558 C28.0127 74.8524 28.0063 74.8491 28 74.8457 C25.4198 73.4833 23.483 71.0169 22.8673 67.9996 M19.5 51.5 L90 51.5 M19.5 51.5 C18.1193 51.5 17 50.3807 17 49 C17 47.6193 18.1193 46.5 19.5 46.5 M19.5 51.5 L22.8673 67.9996 M90 51.5 C91.3807 51.5 92.5 50.3807 92.5 49 C92.5 47.6193 91.3807 46.5 90 46.5 M90 51.5 L86.6327 67.9996 C85.9778 71.2088 83.8285 73.7948 81 75.0922 M90 46.5 L19.5 46.5 M90 46.5 L20 46.5 M19.5 46.5 L20 46.5 M22.8673 67.9996 C23.4846 71.0243 25.4293 73.4954 28.0191 74.8558 M30 36 L30 34 C30 32.6739 29.4732 31.4021 28.5355 30.4645 C27.5979 29.5268 26.3261 29 25 29 C23.6739 29 22.4021 29.5268 21.4645 30.4645 C20.5268 31.4021 20 32.6739 20 34 L20 46.5 M81 75.0922 C79.7247 75.6771 78.3114 76 76.8347 76 L73.3077 76 M81 75.0922 L81 80 C81 80.8284 80.3284 81.5 79.5 81.5 L76.1079 81.5 C75.4494 81.5 74.8679 81.0705 74.6742 80.4411 L73.3077 76 M73.3077 76 L35.6923 76 M35.6923 76 L32.6653 76 C31.1128 76 29.6303 75.643 28.3047 75 C28.2086 74.9534 28.1134 74.9053 28.0191 74.8558",viewW:110,viewH:110}},{id:"bed",group:"furniture",art:{d:"M16 75.5 L24 75.5 M16 75.5 L16 80.5 C16 81.3284 16.6716 82 17.5 82 L20.8921 82 C21.5506 82 22.1321 81.5705 22.3258 80.9411 L24 75.5 M16 75.5 L15 75.5 M24 75.5 L86.5 75.5 M94.5 75.5 L86.5 75.5 M94.5 75.5 L94.5 80.5 C94.5 81.3284 93.8284 82 93 82 L89.6079 82 C88.9494 82 88.3679 81.5705 88.1742 80.9411 L86.5 75.5 M94.5 75.5 L95.5 75.5 M88 50.1296 L88 31.5 C88 30.1193 86.8807 29 85.5 29 L25 29 C23.6193 29 22.5 30.1193 22.5 31.5 L22.5 50.1296 M87.9383 50.1068 C87.9589 50.1143 87.9795 50.1219 88 50.1296 C91.7967 51.5483 94.5 55.2085 94.5 59.5 M22.5617 50.1068 C22.5411 50.1143 22.5205 50.1219 22.5 50.1296 C18.7033 51.5483 16 55.2085 16 59.5 M94.5 65.5 L94.5 59.5 M94.5 65.5 L16 65.5 M94.5 65.5 L95.5 65.5 M16 65.5 L16 59.5 M16 65.5 L15 65.5 M84.5 49.5 L26 49.5 M84.5 49.5 L80 49.5 M94.5 59.5 C94.5 55.1853 91.7674 51.5088 87.9383 50.1068 C86.8662 49.7142 85.7081 49.5 84.5 49.5 M26 49.5 L30.5 49.5 M16 59.5 C16 55.1853 18.7326 51.5088 22.5617 50.1068 C23.6338 49.7142 24.7919 49.5 26 49.5 M15 75.5 L95.5 75.5 M15 75.5 C14.4477 75.5 14 75.0523 14 74.5 L14 66.5 C14 65.9477 14.4477 65.5 15 65.5 M95.5 75.5 C96.0523 75.5 96.5 75.0523 96.5 74.5 L96.5 66.5 C96.5 65.9477 96.0523 65.5 95.5 65.5 M95.5 65.5 L15 65.5 M51.5 49.5 L51.5 45.5 C51.5 42.7386 49.2614 40.5 46.5 40.5 L35.5 40.5 C32.7386 40.5 30.5 42.7386 30.5 45.5 L30.5 49.5 M51.5 49.5 L30.5 49.5 M51.5 49.5 L59 49.5 M80 49.5 L80 45.5 C80 42.7386 77.7614 40.5 75 40.5 L64 40.5 C61.2386 40.5 59 42.7386 59 45.5 L59 49.5 M80 49.5 L59 49.5",viewW:110,viewH:110}},{id:"bidet",group:"sanitary",art:{d:"M46 67.5 L64.5 67.5 M46 67.5 C40.4772 67.5 36 63.0228 36 57.5 L36 53 M46 67.5 C45.4902 67.5 44.9893 67.4618 44.5 67.3882 L44.5 79.5 C44.5 80.0523 44.9477 80.5 45.5 80.5 L65 80.5 C65.5523 80.5 66 80.0523 66 79.5 L66 67.3882 C65.5107 67.4618 65.0098 67.5 64.5 67.5 M64.5 67.5 C70.0229 67.5 74.5 63.0228 74.5 57.5 L74.5 53 M74.5 53 L74.5 47.5 C74.5 46.9477 74.0523 46.5 73.5 46.5 M74.5 53 L36 53 M36 53 L36 47.5 C36 46.9477 36.4477 46.5 37 46.5 M73.5 46.5 L37 46.5 M73.5 46.5 L60 46.5 M37 46.5 L50.5 46.5 M51.5 40 L59 40 M51.5 40 C50.9477 40 50.5 40.4477 50.5 41 L50.5 46.5 M51.5 40 L53 40 M59 40 C59.5523 40 60 40.4477 60 41 L60 46.5 M59 40 L57.5 40 M60 46.5 L50.5 46.5 M57.5 40 L57.5 30 C57.5 29.4477 57.0523 29 56.5 29 L54 29 C53.4477 29 53 29.4477 53 30 M57.5 40 L53 40 M53 40 L53 30 M53 40 L53 36 M53 30 L53 31.5 M53 31.5 L49 31.5 C48.4477 31.5 48 31.9477 48 32.5 L48 35 C48 35.5523 48.4477 36 49 36 L53 36 M53 31.5 L53 36",viewW:110,viewH:110}},{id:"boiler",group:"appliance",art:{d:"M51.5 81.5 L51.5 86 C51.5 86.5523 51.0523 87 50.5 87 L47.5 87 C46.9477 87 46.5 86.5523 46.5 86 L46.5 81.5 M51.5 81.5 L46.5 81.5 M51.5 81.5 L59 81.5 M46.5 81.5 L44 81.5 M64 81.5 L64 86 C64 86.5523 63.5523 87 63 87 L60 87 C59.4477 87 59 86.5523 59 86 L59 81.5 M64 81.5 L59 81.5 M64 81.5 L66.5 81.5 M74.5 73 L74.5 73.5 C74.5 77.9183 70.9183 81.5 66.5 81.5 M44 81.5 C39.5817 81.5 36 77.9183 36 73.5 L36 73 L36 31 C36 26.5817 39.5817 23 44 23 L66.5 23 C70.9183 23 74.5 26.5817 74.5 31 L74.5 73 M74.5 73 L36 73 M66.5 81.5 L44 81.5 M55 42.5 L58.5 39 M62.5 42.5 C62.5 46.366 59.366 49.5 55.5 49.5 C51.634 49.5 48.5 46.366 48.5 42.5 C48.5 38.634 51.634 35.5 55.5 35.5 C59.366 35.5 62.5 38.634 62.5 42.5 Z",viewW:110,viewH:110}},{id:"chair",group:"furniture",art:{d:"M41.25 60.5 L68.75 60.5 M68.75 60.5 C70.5449 60.5 72 59.0449 72 57.25 C72 55.6281 70.8119 54.2836 69.2585 54.0395 C69.0928 54.0135 68.923 54 68.75 54 L41.25 54 C41.077 54 40.9072 54.0135 40.7415 54.0395 C39.1881 54.2836 38 55.6281 38 57.25 C38 59.0449 39.4551 60.5 41.25 60.5 M41.25 60.5 L46 60.5 M68.75 60.5 L64 60.5 M64 60.5 L69.5 60.5 L69.5 82 C69.5 82.8284 68.8284 83.5 68 83.5 L67.3752 83.5 C66.5972 83.5 65.9483 82.9051 65.8809 82.1299 L64 60.5 Z M64 60.5 L46 60.5 M46 60.5 L40.5 60.5 L40.5 82 C40.5 82.8284 41.1716 83.5 42 83.5 L42.6248 83.5 C43.4028 83.5 44.0517 82.9051 44.1191 82.1299 L46 60.5 Z M40.7415 54.0395 C40.5847 53.5546 40.5 53.0372 40.5 52.5 L40.5 39.5 C40.5 32.5964 46.0964 27 53 27 L57 27 C63.9036 27 69.5 32.5964 69.5 39.5 L69.5 52.5 C69.5 53.0372 69.4153 53.5546 69.2585 54.0395",viewW:110,viewH:110}},{id:"coffee_table",group:"furniture",art:{d:"M85.2381 55 L86.5 55 C87.0523 55 87.5 54.5523 87.5 54 L87.5 51 L84.6598 43.4847 C84.2586 42.5818 83.3633 42 82.3753 42 L26.6247 42 C25.6367 42 24.7414 42.5818 24.3402 43.4847 L21.5 51 L21.5 54 C21.5 54.5523 21.9477 55 22.5 55 L25 55 M87.5 51 L21.5 51 M25 55 L25 66.5 C25 67.3284 25.6716 68 26.5 68 L27.2113 68 C27.983 68 28.6288 67.4144 28.7041 66.6464 L29.8459 55 M25 55 L29.8459 55 M29.8459 55 L80.3922 55 M80.3922 55 L81.534 66.6464 C81.6093 67.4144 82.2551 68 83.0268 68 L83.7381 68 C84.5665 68 85.2381 67.3284 85.2381 66.5 L85.2381 55 M80.3922 55 L85.2381 55",viewW:110,viewH:110}},{id:"computer",group:"appliance",art:{d:"M43 65 L48 65 M43 65 L24.5 65 C23.1193 65 22 63.8807 22 62.5 L22 40.5 C22 39.1193 23.1193 38 24.5 38 L64.5 38 C65.8807 38 67 39.1193 67 40.5 L67 62.5 C67 63.8807 65.8807 65 64.5 65 L48 65 M43 65 L43 72 M48 65 L48 72 M37 72 L43 72 M54.0711 72 L48 72 M76 60 L84 60 M76 43 L84 43 M35 53 L35 46 L39.5 46 C40.4283 46 41.3185 46.3687 41.9749 47.0251 C42.6313 47.6815 43 48.5717 43 49.5 C43 50.4283 42.6312 51.3185 41.9749 51.9749 C41.3185 52.6313 40.4283 53 39.5 53 L35 53 Z M35 53 L35 56 M54.5355 54.5355 C53.8363 55.2348 52.9454 55.711 51.9755 55.9039 C51.0055 56.0969 50.0002 55.9978 49.0866 55.6194 C48.173 55.241 47.3921 54.6001 46.8427 53.7779 C46.2932 52.9556 46 51.9889 46 51 C46 50.0111 46.2932 49.0444 46.8427 48.2221 C47.3921 47.3999 48.173 46.759 49.0866 46.3806 C50.0002 46.0022 51.0055 45.9031 51.9755 46.0961 C52.9454 46.289 53.8363 46.7652 54.5355 47.4645 M48 72 L43 72 M74.5 72 L85.5 72 C86.8807 72 88 70.8807 88 69.5 L88 40.5 C88 39.1193 86.8807 38 85.5 38 L74.5 38 C73.1193 38 72 39.1193 72 40.5 L72 69.5 C72 70.8807 73.1193 72 74.5 72 Z",viewW:110,viewH:110}},{id:"cooktop",group:"appliance",art:{d:"M25 31.5 C25 30.1193 26.1193 29 27.5 29 L82.5 29 C83.8807 29 85 30.1193 85 31.5 L85 78.5 C85 79.8807 83.8807 81 82.5 81 L27.5 81 C26.1193 81 25 79.8807 25 78.5 L25 31.5 Z M49.5 66.5 C49.5 70.9183 45.9183 74.5 41.5 74.5 C37.0817 74.5 33.5 70.9183 33.5 66.5 C33.5 62.0817 37.0817 58.5 41.5 58.5 C45.9183 58.5 49.5 62.0817 49.5 66.5 Z M76 43.5 C76 47.9183 72.4183 51.5 68 51.5 C63.5817 51.5 60 47.9183 60 43.5 C60 39.0817 63.5817 35.5 68 35.5 C72.4183 35.5 76 39.0817 76 43.5 Z M73 66.5 C73 69.2614 70.7614 71.5 68 71.5 C65.2386 71.5 63 69.2614 63 66.5 C63 63.7386 65.2386 61.5 68 61.5 C70.7614 61.5 73 63.7386 73 66.5 Z M49.5 43.5 C49.5 47.9183 45.9183 51.5 41.5 51.5 C37.0817 51.5 33.5 47.9183 33.5 43.5 C33.5 39.0817 37.0817 35.5 41.5 35.5 C45.9183 35.5 49.5 39.0817 49.5 43.5 Z",viewW:110,viewH:110}},{id:"dining_table",group:"furniture",art:{d:"M26.875 47 L23.5 47 C22.9477 47 22.5 46.5523 22.5 46 L22.5 43 L24.8802 35.5939 C25.2539 34.633 26.1791 34 27.2102 34 L83.7898 34 C84.8209 34 85.7462 34.633 86.1198 35.5939 L88.5 43 L88.5 46 C88.5 46.5523 88.0523 47 87.5 47 L84.125 47 M22.5 43 L88.5 43 M78.875 47 L84.742 73.8205 C84.8926 74.5092 85.5024 75 86.2073 75 L86.7474 75 C87.6682 75 88.3716 74.1781 88.2294 73.2684 L84.125 47 M78.875 47 L84.125 47 M78.875 47 L32.125 47 M32.125 47 L26.258 73.8205 C26.1074 74.5092 25.4976 75 24.7927 75 L24.2526 75 C23.3318 75 22.6284 74.1781 22.7706 73.2684 L26.875 47 M32.125 47 L26.875 47",viewW:110,viewH:110}},{id:"dishwasher",group:"appliance",art:{d:"M81 82.5 L81 27.5 M81 82.5 C81 83.8807 79.8807 85 78.5 85 L31.5 85 C30.1193 85 29 83.8807 29 82.5 L29 55.5 M81 82.5 L81 40 M81 27.5 C81 26.1193 79.8807 25 78.5 25 L31.5 25 C30.1193 25 29 26.1193 29 27.5 M81 27.5 L81 40 M29 27.5 L29 55.5 M29 27.5 L29 40 M81 40 C81 38.6193 79.8807 37.5 78.5 37.5 L31.5 37.5 C30.1193 37.5 29 38.6193 29 40 M29 40 L29 55.5 M35.75 31 L45.25 31 M55.9943 55 C55.9943 55 54.6654 56.8105 54.5153 58.1429 C54.3169 59.9042 56.1139 60.6968 55.9943 62.4643 C55.8942 63.9429 54.5153 66 54.5153 66 M60.4943 55 C60.4943 55 59.1654 56.8105 59.0153 58.1429 C58.8169 59.9042 60.6139 60.6968 60.4943 62.4643 C60.3942 63.9429 59.0153 66 59.0153 66 M50.9943 55 C50.9943 55 49.6654 56.8105 49.5153 58.1429 C49.3169 59.9042 51.1139 60.6968 50.9943 62.4643 C50.8942 63.9429 49.5153 66 49.5153 66 M72 60.5 C72 69.8888 64.3888 77.5 55 77.5 C45.6112 77.5 38 69.8888 38 60.5 C38 51.1112 45.6112 43.5 55 43.5 C64.3888 43.5 72 51.1112 72 60.5 Z M66.5 60.5 C66.5 66.8513 61.3513 72 55 72 C48.6487 72 43.5 66.8513 43.5 60.5 C43.5 54.1487 48.6487 49 55 49 C61.3513 49 66.5 54.1487 66.5 60.5 Z M69.5 31 C69.5 32.1046 68.6046 33 67.5 33 C66.3954 33 65.5 32.1046 65.5 31 C65.5 29.8954 66.3954 29 67.5 29 C68.6046 29 69.5 29.8954 69.5 31 Z M77 31 C77 32.1046 76.1046 33 75 33 C73.8954 33 73 32.1046 73 31 C73 29.8954 73.8954 29 75 29 C76.1046 29 77 29.8954 77 31 Z",viewW:110,viewH:110}},{id:"dryer",group:"appliance",art:{d:"M81 82.5 L81 27.5 M81 82.5 C81 83.8807 79.8807 85 78.5 85 L31.5 85 C30.1193 85 29 83.8807 29 82.5 L29 55.5 M81 82.5 L81 40 M81 27.5 C81 26.1193 79.8807 25 78.5 25 L31.5 25 C30.1193 25 29 26.1193 29 27.5 M81 27.5 L81 40 M29 27.5 L29 55.5 M29 27.5 L29 40 M81 40 C81 38.6193 79.8807 37.5 78.5 37.5 L31.5 37.5 C30.1193 37.5 29 38.6193 29 40 M29 40 L29 55.5 M35.75 31 L45.25 31 M55.9943 55 C55.9943 55 54.6654 56.8105 54.5153 58.1429 C54.3169 59.9042 56.1139 60.6968 55.9943 62.4643 C55.8942 63.9429 54.5153 66 54.5153 66 M60.4943 55 C60.4943 55 59.1654 56.8105 59.0153 58.1429 C58.8169 59.9042 60.6139 60.6968 60.4943 62.4643 C60.3942 63.9429 59.0153 66 59.0153 66 M50.9943 55 C50.9943 55 49.6654 56.8105 49.5153 58.1429 C49.3169 59.9042 51.1139 60.6968 50.9943 62.4643 C50.8942 63.9429 49.5153 66 49.5153 66 M72 60.5 C72 69.8888 64.3888 77.5 55 77.5 C45.6112 77.5 38 69.8888 38 60.5 C38 51.1112 45.6112 43.5 55 43.5 C64.3888 43.5 72 51.1112 72 60.5 Z M66.5 60.5 C66.5 66.8513 61.3513 72 55 72 C48.6487 72 43.5 66.8513 43.5 60.5 C43.5 54.1487 48.6487 49 55 49 C61.3513 49 66.5 54.1487 66.5 60.5 Z M69.5 31 C69.5 32.1046 68.6046 33 67.5 33 C66.3954 33 65.5 32.1046 65.5 31 C65.5 29.8954 66.3954 29 67.5 29 C68.6046 29 69.5 29.8954 69.5 31 Z M77 31 C77 32.1046 76.1046 33 75 33 C73.8954 33 73 32.1046 73 31 C73 29.8954 73.8954 29 75 29 C76.1046 29 77 29.8954 77 31 Z",viewW:110,viewH:110}},{id:"exercise",group:"other",art:{d:"M55.091 60.072 L65.7741 35.5156 M42.2119 56.2083 L55.091 60.072 L60.8511 61.8001 L66.5032 63.4957 C70.733 64.7646 73.6297 68.6579 73.6297 73.074 L73.6297 76.2635 L29.3385 76.2635 L29.3385 65.7866 C29.3385 60.9371 32.7227 57.0804 37.0256 56.051 C38.5108 55.6956 40.1055 55.6771 41.7081 56.0709 M41.7081 56.0709 C41.876 56.1122 42.044 56.1579 42.2119 56.2083 L60.8511 61.8001 M71.9311 35.5156 L76.4108 35.5156 C78.2451 35.5156 79.9321 34.5112 80.8064 32.8987 L83.8375 27.308 C84.3011 26.4529 83.9993 25.384 83.1569 24.8976 C82.2982 24.4018 81.2002 24.696 80.7045 25.5547 L77.8652 30.4723 C77.3293 31.4005 76.3389 31.9723 75.2671 31.9723 L65.6573 31.9723 C64.6788 31.9723 63.8856 32.7655 63.8856 33.744 C63.8856 34.7224 64.6788 35.5156 65.6573 35.5156 L65.7741 35.5156 M71.9311 35.5156 C71.9603 35.7673 71.9261 36.0298 71.8188 36.2793 L60.8511 61.8001 M71.9311 35.5156 L65.7741 35.5156 M41.7081 56.0709 L38.03 42.6022 M37.0256 56.051 L33.3529 42.6022 M38.03 42.6022 L33.3529 42.6022 L29.7814 42.6022 C28.5583 42.6022 27.5668 41.6107 27.5668 40.3876 C27.5668 39.1646 28.5583 38.1731 29.7814 38.1731 L41.2971 38.1731 C42.5202 38.1731 43.5117 39.1646 43.5117 40.3876 C43.5117 41.6107 42.5202 42.6022 41.2971 42.6022 L38.03 42.6022 Z M25.7952 78.921 C25.7952 77.4533 26.985 76.2635 28.4526 76.2635 L74.5155 76.2636 C75.9832 76.2636 77.173 77.4533 77.173 78.921 C77.173 80.3887 75.9832 81.5785 74.5155 81.5785 L28.4526 81.5785 C26.985 81.5785 25.7952 80.3887 25.7952 78.921 Z M29.3385 81.5785 L29.3385 84.5677 C29.3385 85.3962 30.01 86.0677 30.8385 86.0677 L33.6379 86.0677 C34.2512 86.0677 34.8028 85.6943 35.0306 85.1248 L36.5002 81.5785 L29.3385 81.5785 Z M73.6297 81.5785 L73.6297 84.5677 C73.6297 85.3962 72.9581 86.0677 72.1297 86.0677 L69.3303 86.0677 C68.717 86.0677 68.1654 85.6943 67.9376 85.1248 L66.5002 81.5785 L73.6297 81.5785 Z M45.2833 66.0766 C45.2833 68.7673 43.102 70.9486 40.4113 70.9486 C37.7205 70.9486 35.5392 68.7673 35.5392 66.0766 C35.5392 63.3858 37.7205 61.2045 40.4113 61.2045 C43.102 61.2045 45.2833 63.3858 45.2833 66.0766 Z",viewW:110,viewH:110}},{id:"fireplace",group:"other",art:{d:"M71.1884 73.8943 L71.1884 50.4399 C71.1884 47.6784 68.9498 45.4399 66.1884 45.4399 L43.1445 45.4399 C40.3831 45.4399 38.1445 47.6784 38.1445 50.4399 L38.1445 73.8942 M38.1445 73.8942 L26.7031 73.8942 L26.7031 34.4252 L82.6629 34.4252 L82.6629 73.8942 L71.1884 73.8943 L38.1445 73.8942 Z M62.0101 62.8795 L47.3239 62.8795 C45.8031 62.8795 44.5703 64.1124 44.5703 65.6332 C44.5703 67.154 45.8031 68.3868 47.3239 68.3868 M47.3239 68.3868 C45.8031 68.3868 44.5703 69.6195 44.5703 71.1403 C44.5703 72.6611 45.8031 73.894 47.3239 73.894 M47.3239 68.3868 C48.8447 68.3868 50.0776 69.6195 50.0776 71.1403 C50.0776 72.6611 48.8447 73.894 47.3239 73.894 M47.3239 68.3868 L61.9918 68.3868 M47.3239 73.894 L62.0101 73.894 C63.5309 73.894 64.7637 72.6611 64.7637 71.1403 C64.7637 69.6242 63.5385 68.3945 62.0243 68.3869 M62.0114 68.3869 C62.0049 68.3869 61.9983 68.3869 61.9918 68.3868 M62.0114 68.3869 C62.0157 68.3869 62.02 68.3869 62.0243 68.3869 M62.0114 68.3869 L62.0243 68.3869 M62.0114 68.3869 L61.9918 68.3868 M61.9918 68.3868 C60.48 68.3763 59.2578 67.1475 59.2578 65.6332 C59.2578 64.1124 60.4906 62.8796 62.0114 62.8796 C63.5322 62.8796 64.7651 64.1124 64.7651 65.6332 C64.7651 67.1498 63.5392 68.3799 62.0243 68.3869 M61.9918 68.3868 L62.0101 68.3868 C62.0148 68.3868 62.0195 68.3868 62.0243 68.3869 M24 81.6962 L85.3341 81.6962 C85.8864 81.6962 86.3341 81.2485 86.3341 80.6962 L86.3341 74.8942 C86.3341 74.3419 85.8864 73.8942 85.3341 73.8942 L24 73.8942 C23.4477 73.8942 23 74.3419 23 74.8942 L23 80.6962 C23 81.2485 23.4477 81.6962 24 81.6962 Z M24 34.4252 L85.3341 34.4252 C85.8864 34.4252 86.3341 33.9775 86.3341 33.4252 L86.3341 29 C86.3341 28.4477 85.8864 28 85.3341 28 L24 28 C23.4477 28 23 28.4477 23 29 L23 33.4252 C23 33.9775 23.4477 34.4252 24 34.4252 Z",viewW:110,viewH:110}},{id:"fridge",group:"appliance",art:{d:"M35.5 87 C34.1193 87 33 85.8807 33 84.5 M35.5 87 L74.5 87 M35.5 87 L35.5 90.5 C35.5 91.0523 35.9477 91.5 36.5 91.5 L73.5 91.5 C74.0523 91.5 74.5 91.0523 74.5 90.5 L74.5 87 M33 84.5 L33 20.5 M33 84.5 L33 46.5 M77.5 84.5 L77.5 20.5 M77.5 84.5 C77.5 85.8807 76.3807 87 75 87 L74.5 87 M77.5 84.5 L77.5 46.5 M77.5 20.5 C77.5 19.1193 76.3807 18 75 18 L35.5 18 C34.1193 18 33 19.1193 33 20.5 M77.5 20.5 L77.5 46.5 M33 20.5 L33 46.5 M33 46.5 L77.5 46.5 M38.5 41 L38.5 31.5 M38.5 62 L38.5 52.5",viewW:110,viewH:110}},{id:"hood",group:"appliance",art:{d:"M66 57 L83 69 L83 71.5 C83 72.8807 81.8807 74 80.5 74 L29.5 74 C28.1193 74 27 72.8807 27 71.5 L27 69 L44 57 M44 57 L66 57 M44 57 L44 37.5 C44 36.1193 45.1193 35 46.5 35 L63.5 35 C64.8807 35 66 36.1193 66 37.5 L66 57 M83 69 L27 69",viewW:110,viewH:110}},{id:"kitchen_cabinet",group:"furniture",art:{d:"M72 84.95 L72 88 C72 88.5523 71.5523 89 71 89 L39 89 C38.4477 89 38 88.5523 38 88 L38 84.95 M55 20 L71.5 20 C72.8807 20 74 21.1193 74 22.5 L74 39.5 C74 40.8807 72.8807 42 71.5 42 L55 42 M55 20 L55 42 M55 20 L38.5 20 C37.1193 20 36 21.1193 36 22.5 L36 39.5 C36 40.8807 37.1193 42 38.5 42 L55 42 M59 33 L59 38 M51 33 L51 38 M55 85 L71.5 85 C72.8807 85 74 83.8807 74 82.5 L74 65.5 C74 64.1193 72.8807 63 71.5 63 L55 63 M55 85 L55 63 M55 85 L38.5 85 C37.1193 85 36 83.8807 36 82.5 L36 65.5 C36 64.1193 37.1193 63 38.5 63 L55 63 M67 67 L62 67 M48 67 L43 67",viewW:110,viewH:110}},{id:"kitchen_sink",group:"sanitary",art:{d:"M49 54 L49 59 M51.5 37.5 L44 37.5 M51.5 37.5 C52.0523 37.5 52.5 37.9477 52.5 38.5 L52.5 44 M51.5 37.5 L48 37.5 M44 37.5 C43.4477 37.5 43 37.9477 43 38.5 L43 44 M44 37.5 L48 37.5 M43 44 L21.5 44 C20.1193 44 19 45.1193 19 46.5 L19 81.5 C19 82.8807 20.1193 84 21.5 84 L89.5 84 C90.8807 84 92 82.8807 92 81.5 L92 46.5 C92 45.1193 90.8807 44 89.5 44 L52.5 44 M43 44 L52.5 44 M58 33 L58 31 C58 29.6739 57.4732 28.4021 56.5355 27.4645 C55.5979 26.5268 54.3261 26 53 26 C51.6739 26 50.4021 26.5268 49.4645 27.4645 C48.5268 28.4021 48 29.6739 48 31 L48 37.5 M62 54 L62 59 M26 50 L52.5 50 C53.0523 50 53.5 50.4477 53.5 51 L53.5 77 C53.5 77.5523 53.0523 78 52.5 78 L26 78 C25.4477 78 25 77.5523 25 77 L25 51 C25 50.4477 25.4477 50 26 50 Z M58.5 50 L85 50 C85.5523 50 86 50.4477 86 51 L86 77 C86 77.5523 85.5523 78 85 78 L58.5 78 C57.9477 78 57.5 77.5523 57.5 77 L57.5 51 C57.5 50.4477 57.9477 50 58.5 50 Z",viewW:110,viewH:110}},{id:"nightstand",group:"furniture",art:{d:"M34.5 76 C33.1193 76 32 74.8807 32 73.5 M34.5 76 L41.2308 76 M34.5 76 C34.3288 76 34.1616 75.9828 34 75.95 L34 78.5 C34 79.3284 34.6716 80 35.5 80 L38.8921 80 C39.5506 80 40.1321 79.5705 40.3258 78.9411 L41.2308 76 M32 73.5 L32 33 M32 73.5 L32 57.5 M78 73.5 L78 33 M69.2692 76 L75.5 76 C75.8556 76 76.1938 75.9258 76.5 75.792 C77.383 75.4062 78 74.5252 78 73.5 M78 73.5 L78 57.5 M78 33 C78 31.6193 76.8807 30.5 75.5 30.5 L34.5 30.5 C33.1193 30.5 32 31.6193 32 33 M78 33 L78 39.5 M32 33 L32 39.5 M32 39.5 L78 39.5 M32 39.5 L32 57.5 M78 39.5 L78 57.5 M78 57.5 L32 57.5 M50.5 48.5 L60 48.5 M50.5 66 L60 66 M41.2308 76 L69.2692 76 M69.2692 76 L70.1742 78.9411 C70.3679 79.5705 70.9494 80 71.6079 80 L75 80 C75.8284 80 76.5 79.3284 76.5 78.5 L76.5 75.792",viewW:110,viewH:110}},{id:"oven",group:"appliance",art:{d:"M29 76 C29 77.3807 30.1193 78.5 31.5 78.5 L78.5 78.5 C79.8807 78.5 81 77.3807 81 76 M29 76 L29 40 M29 76 L29 82.5 C29 83.8807 30.1193 85 31.5 85 L78.5 85 C79.8807 85 81 83.8807 81 82.5 L81 76 M81 76 L81 40 M81 40 C81 38.6193 79.8807 37.5 78.5 37.5 L31.5 37.5 C30.1193 37.5 29 38.6193 29 40 M81 40 L81 27.5 C81 26.1193 79.8807 25 78.5 25 L31.5 25 C30.1193 25 29 26.1193 29 27.5 L29 40 M35.75 31 L45.25 31 M43 42 L67 42 M40.5 72 L69.5 72 C70.8807 72 72 70.8807 72 69.5 L72 49.5 C72 48.1193 70.8807 47 69.5 47 L40.5 47 C39.1193 47 38 48.1193 38 49.5 L38 69.5 C38 70.8807 39.1193 72 40.5 72 Z M69.5 31 C69.5 32.1046 68.6046 33 67.5 33 C66.3954 33 65.5 32.1046 65.5 31 C65.5 29.8954 66.3954 29 67.5 29 C68.6046 29 69.5 29.8954 69.5 31 Z M77 31 C77 32.1046 76.1046 33 75 33 C73.8954 33 73 32.1046 73 31 C73 29.8954 73.8954 29 75 29 C76.1046 29 77 29.8954 77 31 Z",viewW:110,viewH:110}},{id:"plant",group:"other",art:{d:"M55.7064 55.8805 L55.7064 52.9357 M55.7064 52.9357 C56.839 47.0461 62.7965 41.9801 68.6182 37.5322 M55.7064 52.9357 C50.7678 48.7899 47.7236 46.7763 41.6621 43.8748 M67.4992 61.3174 L65.9151 75.8488 C65.7779 77.1181 64.7063 78.0801 63.4296 78.0801 L48.4373 78.0801 C47.1606 78.0801 46.089 77.1181 45.9518 75.8488 L44.3593 61.3174 L67.4992 61.3174 Z M60.2363 44.7807 C58.4234 36.1732 66.8047 29.604 76.9989 31.869 C76.9989 40.024 68.3904 48.6318 60.2363 44.7807 Z M50.476 49.9288 C51.9926 41.2641 43.391 34.9863 33.2805 37.5996 C33.5602 45.7498 42.4589 54.0573 50.476 49.9288 Z M43.1152 61.3174 L68.7509 61.3174 C69.3031 61.3174 69.7509 60.8697 69.7509 60.3174 L69.7509 56.8809 C69.7509 56.3286 69.3031 55.8809 68.7509 55.8809 L43.1152 55.8809 C42.5629 55.8809 42.1152 56.3286 42.1152 56.8809 L42.1152 60.3174 C42.1152 60.8697 42.5629 61.3174 43.1152 61.3174 Z",viewW:110,viewH:110}},{id:"rug",group:"other",art:{d:"M90.2693 33.8735 L84.648 33.8735 M25.6208 33.8735 L19.9995 33.8735 M90.2693 39.0264 L84.648 39.0264 M25.6208 39.0264 L19.9995 39.0264 M90.2693 44.1792 L84.648 44.1792 M25.6208 44.1792 L19.9995 44.1792 M90.2693 49.332 L84.648 49.332 M25.6208 49.332 L19.9995 49.332 M90.2693 54.4854 L84.648 54.4854 M25.6208 54.4854 L19.9995 54.4854 M90.2693 59.6382 L84.648 59.6382 M25.6208 59.6382 L19.9995 59.6382 M90.2693 64.791 L84.648 64.791 M25.6208 64.791 L19.9995 64.791 M90.2693 69.9438 L84.648 69.9438 M25.6208 69.9438 L19.9995 69.9438 M90.2693 75.0967 L84.648 75.0967 M25.6208 75.0967 L19.9995 75.0967 M28.121 32 L82.145 32 C83.5257 32 84.645 33.1193 84.645 34.5 L84.645 74.939 C84.645 76.3197 83.5257 77.439 82.145 77.439 L28.121 77.439 C26.7403 77.439 25.621 76.3197 25.621 74.939 L25.621 34.5 C25.621 33.1193 26.7403 32 28.121 32 Z M29.8369 32 L29.8369 77.439 M80.4302 32 L80.4302 77.439 M37.8005 54.4852 L55.6014 46.0532 L73.4022 54.4852 L55.6014 62.9172 L37.8005 54.4852 Z",viewW:110,viewH:110}},{id:"shelving",group:"furniture",art:{d:"M64 58.5 L64 47 C64 46.4477 64.4477 46 65 46 L68 46 C68.5523 46 69 46.4477 69 47 M64 58.5 L69 58.5 M64 58.5 L28 58.5 L28 39 L35.5 39 M69 58.5 L69 47 M69 58.5 L69 44.5 M69 58.5 L76 58.5 M69 47 L69 44.5 M52.5 39 L52.5 27.5 C52.5 26.9477 52.0523 26.5 51.5 26.5 L48.5 26.5 C47.9477 26.5 47.5 26.9477 47.5 27.5 M52.5 39 L47.5 39 M52.5 39 L81 39 L81 58.5 L76 58.5 M47.5 39 L47.5 27.5 M47.5 39 L47.5 25 M47.5 39 L40.5 39 M47.5 27.5 L47.5 25 M40.5 39 L40.5 27.5 M40.5 39 L40.5 25 M40.5 39 L35.5 39 M35.5 39 L35.5 27.5 C35.5 26.9477 35.9477 26.5 36.5 26.5 L39.5 26.5 C40.0523 26.5 40.5 26.9477 40.5 27.5 M40.5 27.5 L40.5 25 M49 72 L36.5 72 M50.5 72 L36.5 72 C35.9477 72 35.5 71.5523 35.5 71 L35.5 68.5 C35.5 67.9477 35.9477 67.5 36.5 67.5 L49 67.5 C49.5523 67.5 50 67.9477 50 68.5 L50 71 C50 71.5523 49.5523 72 49 72 M50.5 78 C51.0523 78 51.5 77.5523 51.5 77 L51.5 73 C51.5 72.4477 51.0523 72 50.5 72 L49 72 M36.5 72 C35.9477 72 35.5 72.4477 35.5 73 L35.5 77 C35.5 77.5523 35.9477 78 36.5 78 M76 58.5 L76 44.5 C76 43.9477 75.5523 43.5 75 43.5 L70 43.5 C69.4477 43.5 69 43.9477 69 44.5 M47.5 25 C47.5 24.4477 47.0523 24 46.5 24 L41.5 24 C40.9477 24 40.5 24.4477 40.5 25 M50.5 78 L36.5 78 M50.5 78 L81 78 L81 85 L28 85 L28 78 L36.5 78 M28 89.5 L28 23 C28 21.6193 29.1193 20.5 30.5 20.5 L78.5 20.5 C79.8807 20.5 81 21.6193 81 23 L81 89.5",viewW:110,viewH:110}},{id:"shower",group:"sanitary",art:{d:"M39 84 L39 31.7143 C39 25.245 44.2564 20 50.75 20 C56.4663 20 61.2394 24.5462 62.1824 29.0091 M51.5 39.25 C51.5 33.5891 56.0891 29 61.75 29 C67.4109 29 72 33.5891 72 39.25 L51.5 39.25 M54.75 44.25 L54.75 46.75 M62 44.25 L62 46.75 M69.25 44.25 L69.25 46.75 M54.75 50.5 L54.75 53 M62 50.5 L62 53 M69.25 50.5 L69.25 53 M54.75 56.75 L54.75 59.25 M62 56.75 L62 59.25 M69.25 56.75 L69.25 59.25 M54.75 63 L54.75 65.5 M62 63 L62 65.5 M69.25 63 L69.25 65.5 M31 84 L80 84 C80.5523 84 81 84.4477 81 85 L81 88 C81 88.5523 80.5523 89 80 89 L31 89 C30.4477 89 30 88.5523 30 88 L30 85 C30 84.4477 30.4477 84 31 84",viewW:110,viewH:110}},{id:"sink",group:"sanitary",art:{d:"M51 41.5 L58.5 41.5 M51 41.5 C50.4477 41.5 50 41.9477 50 42.5 L50 48 M51 41.5 L55 41.5 M58.5 41.5 C59.0523 41.5 59.5 41.9477 59.5 42.5 L59.5 48 M58.5 41.5 L55 41.5 M59.5 48 L77 48 C78.3807 48 79.5 49.1193 79.5 50.5 L79.5 57 C79.5 62.5228 75.0228 67 69.5 67 L40 67 C34.4772 67 30 62.5228 30 57 L30 50.5 C30 49.1193 31.1193 48 32.5 48 L50 48 M59.5 48 L50 48 M45 37 L45 35 C45 33.6739 45.5268 32.4021 46.4645 31.4645 C47.4021 30.5268 48.6739 30 50 30 C51.3261 30 52.5979 30.5268 53.5355 31.4645 C54.4732 32.4021 55 33.6739 55 35 L55 41.5 M45 80 L64.5 80 C65.0523 80 65.5 79.5523 65.5 79 L65.5 67 L44 67 L44 79 C44 79.5523 44.4477 80 45 80 Z",viewW:110,viewH:110}},{id:"sofa",group:"furniture",art:{d:"M88.5 44.6689 L88.5 34 C88.5 31.2386 86.2614 29 83.5 29 L59.5 29 C56.7386 29 54.5 31.2386 54.5 34 M88.5 44.6689 C89.2354 44.2435 90.0893 44 91 44 M88.5 44.6689 C88.3992 44.7272 88.3006 44.7889 88.2045 44.8539 M54.5 61.75 L54.5 34 M54.5 61.75 C54.5 64.3734 52.3734 66.5 49.75 66.5 L25.25 66.5 C22.6266 66.5 20.5 64.3734 20.5 61.75 M54.5 61.75 C54.5 59.1266 52.3734 57 49.75 57 L25.25 57 C24.6761 57 24.1261 57.1018 23.6168 57.2882 M54.5 61.75 C54.5 64.3734 56.6266 66.5 59.25 66.5 L83.75 66.5 C86.3734 66.5 88.5 64.3734 88.5 61.75 M88.5 61.75 C88.5 59.9118 87.4558 58.3175 85.9283 57.5278 C85.8889 57.5075 85.8493 57.4877 85.8093 57.4684 C85.1863 57.1682 84.4878 57 83.75 57 L59.25 57 C56.6266 57 54.5 59.1266 54.5 61.75 M54.5 34 C54.5 31.2386 52.2614 29 49.5 29 L25.5 29 C22.7386 29 20.5 31.2386 20.5 34 L20.5 44.416 M20.5 44.416 C19.8875 44.1484 19.2111 44 18.5 44 M20.5 44.416 C22.2659 45.1876 23.5 46.9497 23.5 49 M18.5 44 C21.2614 44 23.5 46.2386 23.5 49 M18.5 44 L18 44 C15.2386 44 13 46.2386 13 49 L13 70.5 C13 73.2614 15.2386 75.5 18 75.5 M23.5 49 L23.5 57.3328 M23.5 57.3328 C21.7427 58.0295 20.5 59.7446 20.5 61.75 M23.5 57.3328 C23.5387 57.3174 23.5776 57.3026 23.6168 57.2882 M91 44 C89.9645 44 89.0025 44.3148 88.2045 44.8539 C86.8744 45.7525 86 47.2741 86 49 L86 57.5657 M85.9283 57.5278 C85.9523 57.5402 85.9762 57.5528 86 57.5657 C87.4884 58.3677 88.5 59.9407 88.5 61.75 M91 44 L91.5 44 C94.2614 44 96.5 46.2386 96.5 49 L96.5 70.5 C96.5 73.2614 94.2614 75.5 91.5 75.5 M91.5 75.5 L18 75.5 M91.5 75.5 L90.5 75.5 M18 75.5 L18.5 75.5 M20.5 61.75 C20.5 59.7005 21.798 57.9542 23.6168 57.2882 M18.5 75.5 L26.5 75.5 M18.5 75.5 L18.5 80.5 C18.5 81.3284 19.1716 82 20 82 L23.3921 82 C24.0506 82 24.6321 81.5705 24.8258 80.9411 L26.5 75.5 M26.5 75.5 L82.5 75.5 M90.5 75.5 L82.5 75.5 M90.5 75.5 L90.5 80.5 C90.5 81.3284 89.8284 82 89 82 L85.6079 82 C84.9494 82 84.3679 81.5705 84.1742 80.9411 L82.5 75.5",viewW:110,viewH:110}},{id:"stairs",group:"other",art:{d:"M73.4707 46.8057 L73.4707 28.5242 M73.4707 46.8057 L73.1504 46.8057 M73.4707 46.8057 L82.6039 46.8057 M73.4707 28.5242 L73.425 28.5242 M73.4707 28.5242 L75.6731 28.5242 M62.8987 54.2946 L62.8987 36.7397 M61.5762 61.7837 L61.5762 55.2944 C61.5762 54.7421 62.0239 54.2944 62.5762 54.2944 L62.8987 54.2946 L72.1504 54.2945 M52.3262 61.7837 L52.3262 45.1306 M52.3262 61.7837 L52.0039 61.7837 M52.3262 61.7837 L61.5762 61.7837 M62.8987 36.7397 L52.3262 45.1306 L42.1934 53.1725 L31.6211 61.5632 M42.1934 69.2725 L42.1934 53.1725 M42.1934 69.2725 L41.873 69.2725 M83.6035 69.2725 L83.6024 69.2725 L51.0039 69.2725 L42.1934 69.2725 M83.6031 76.7612 L83.6031 83.25 C83.6031 83.8023 83.1554 84.25 82.6031 84.25 L31.6231 84.2499 M41.873 69.2725 L83.6035 69.2725 L83.6031 76.7612 M83.6031 76.7612 L31.6231 76.7612 M31.6231 76.7612 L40.873 76.7613 L83.6031 76.7612 M31.6231 84.2499 L27.7773 84.2499 C27.2251 84.2499 26.7773 83.8021 26.7773 83.2499 L26.7773 57.4971 C26.7773 56.9448 27.2251 56.4971 27.7773 56.4971 L28.9352 56.4971 M31.6231 84.2499 L31.6231 76.7612 M31.6231 76.7612 L31.6211 61.5632 L31.6231 56.4971 M29.0212 56.4971 L31.6231 56.4971 L31.6228 57.2227 M31.6211 61.5632 L62.8987 36.7397 M31.6211 61.5632 L31.6228 57.2227 M73.425 28.5242 L75.6731 28.5242 M73.425 28.5242 C73.3119 28.5242 73.202 28.5624 73.1134 28.6328 L62.8987 36.7397 M75.6731 28.5242 C76.6463 28.5242 77.4352 27.7353 77.4352 26.7621 C77.4352 25.7889 76.6463 25 75.6731 25 L71.9495 25 C71.7935 25 71.6421 25.0532 71.5204 25.1508 L31.6228 57.2227 M41.873 69.2725 C41.3208 69.2725 40.873 69.7202 40.873 70.2725 L40.873 76.7613 M52.0039 61.7837 L83.6024 61.7837 M52.0039 61.7837 C51.4516 61.7837 51.0039 62.2314 51.0039 62.7837 L51.0039 69.2725 M83.6022 54.2944 L83.6024 61.7837 L83.6024 69.2725 M83.6024 61.7837 L61.5762 61.7837 M83.6022 54.2944 L83.6039 47.8057 C83.6039 47.2534 83.1562 46.8057 82.6039 46.8057 M83.6022 54.2944 L72.1504 54.2945 M73.1504 46.8057 L82.6039 46.8057 M73.1504 46.8057 C72.5981 46.8057 72.1504 47.2534 72.1504 47.8057 L72.1504 54.2945 M28.9352 56.4971 C28.9495 56.4973 28.9638 56.4974 28.9782 56.4974 C28.9925 56.4974 29.0069 56.4973 29.0212 56.4971 M28.9352 56.4971 C27.2519 56.4741 25.8945 55.1024 25.8945 53.4137 C25.8945 51.7107 27.2751 50.3301 28.9782 50.3301 C30.6812 50.3301 32.0618 51.7107 32.0618 53.4137 C32.0618 55.1024 30.7044 56.4741 29.0212 56.4971 M28.9352 56.4971 L29.0212 56.4971",viewW:110,viewH:110}},{id:"toilet",group:"sanitary",art:{d:"M64.5372 72.1021 L67.6892 84.7575 C67.847 85.3886 67.3696 86 66.7191 86 L37.6483 86 C37.0414 86 36.5743 85.4636 36.6578 84.8624 L38.9999 68 C40.0716 64 32.5 64.5 32 57 L32 26.5 C32 25.1193 33.1193 24 34.5 24 L45 24 C46.3807 24 47.5 25.1193 47.5 26.5 L47.5 52 M32 57 L47.5 57 M47.5 52 L76.5 52 C77.8807 52 79 53.1193 79 54.5 L79 57 M47.5 52 L47.5 57 M54.9999 71.75 C58.5528 72.6096 61.7379 72.6416 64.5372 72.1021 C73.95 70.2877 79 62.0101 79 57 M79 57 L47.5 57",viewW:110,viewH:110}},{id:"tv",group:"appliance",art:{d:"M23.5 31 L86 31 C87.3807 31 88.5 32.1193 88.5 33.5 L88.5 67.5 C88.5 68.8807 87.3807 70 86 70 L23.5 70 C22.1193 70 21 68.8807 21 67.5 L21 33.5 C21 32.1193 22.1193 31 23.5 31 M50 70 L50 78 M59.5 70 L59.5 78 M40 78 L70 78 M42.5466 45.9951 L52.5466 45.9951 M47.5466 45.9951 L47.5 56.0336 M56.75 45.5 L61.75 55.5 L66.75 45.5",viewW:110,viewH:110}},{id:"wardrobe",group:"furniture",art:{d:"M54.5 20.5 L30.5 20.5 C29.1193 20.5 28 21.6193 28 23 L28 82.5 C28 83.8807 29.1193 85 30.5 85 L54.5 85 M54.5 20.5 L54.5 85 M54.5 20.5 L78.5 20.5 C79.8807 20.5 81 21.6193 81 23 L81 82.5 C81 83.8807 79.8807 85 78.5 85 L54.5 85 M79 84.95 L79 88.5 C79 89.0523 78.5523 89.5 78 89.5 L31 89.5 C30.4477 89.5 30 89.0523 30 88.5 L30 84.95 M50.5 48 L50.5 57.5 M58.5 48 L58.5 57.5",viewW:110,viewH:110}},{id:"washer",group:"appliance",art:{d:"M81 40 C81 38.6193 79.8807 37.5 78.5 37.5 L31.5 37.5 C30.1193 37.5 29 38.6193 29 40 M35.75 31 L45.25 31 M31.5 85 L78.5 85 C79.8807 85 81 83.8807 81 82.5 L81 55.5 L81 27.5 C81 26.1193 79.8807 25 78.5 25 L31.5 25 C30.1193 25 29 26.1193 29 27.5 L29 56 L29 82.5 C29 83.8807 30.1193 85 31.5 85 Z M72 60.5 C72 69.8888 64.3888 77.5 55 77.5 C45.6112 77.5 38 69.8888 38 60.5 C38 51.1112 45.6112 43.5 55 43.5 C64.3888 43.5 72 51.1112 72 60.5 Z M66.5 60.5 C66.5 66.8513 61.3513 72 55 72 C48.6487 72 43.5 66.8513 43.5 60.5 C43.5 54.1487 48.6487 49 55 49 C61.3513 49 66.5 54.1487 66.5 60.5 Z M69.5 31 C69.5 32.1046 68.6046 33 67.5 33 C66.3954 33 65.5 32.1046 65.5 31 C65.5 29.8954 66.3954 29 67.5 29 C68.6046 29 69.5 29.8954 69.5 31 Z M77 31 C77 32.1046 76.1046 33 75 33 C73.8954 33 73 32.1046 73 31 C73 29.8954 73.8954 29 75 29 C76.1046 29 77 29.8954 77 31 Z",viewW:110,viewH:110}},{id:"work_table",group:"furniture",art:{d:"M68.5 61 L68.5 73.5 C68.5 74.3284 69.1716 75 70 75 L87 75 C87.8284 75 88.5 74.3284 88.5 73.5 L88.5 61 L88.4844 47 M26.4844 47 L26.4844 73.5 C26.4844 74.3284 25.8128 75 24.9844 75 L23.9844 75 C23.1559 75 22.4844 74.3284 22.4844 73.5 L22.4844 47 L22.4844 43 L24.866 35.5974 C25.2388 34.6346 26.165 34 27.1974 34 L83.7743 34 C84.8054 34 85.7307 34.633 86.1044 35.5939 L88.4844 43 L88.4844 47 M88.4844 47 L68.5 47 M68.5 47 L68.5 61 M68.5 47 L26.4844 47 M68.5 61 L88.5 61 M76.5 51 L80.5 51 M88.4844 43 L22.4844 43 M22.4844 47 L26.4844 47 M76.5 65 L80.5 65",viewW:110,viewH:110}}];class Xc{constructor(t,e){this.host=t,this.hooks=e}place(t,e="mouse"){const s=this.host._decorImagePalette,i=this.host._curSpaceCfg;if(!s||!i)return;const o=this.hooks.decorSnap(t,e),a=$e(s.width,s.height),n=we(a.w,this.host._cellCm,this.host._gridPitch)/lt,r=we(a.h,this.host._cellCm,this.host._gridPitch)/this.host._decorH,l="di"+Date.now().toString(36)+Math.random().toString(36).slice(2,5),h=this.hooks.geometrySnapshot();i.decor=[...this.host._decorList,{id:l,kind:"image",asset_id:s.asset_id,x:le(o[0]/lt-n/2),y:le(o[1]/this.host._decorH-r/2),w:n,h:r,opacity:1}],this.host._decorSel=l,this.host._decorTool="select",this.host._decorImagePalette=null,this.hooks.clearFurniturePreview(),this.hooks.recordGeometry(this.host._t("history.decor_add"),h),this.hooks.saveConfig(),this.host.requestUpdate()}renderPlacementPreview(){const t=this.host._furnPreviewInput,e=this.host._decorImagePalette;if(!t||!e||"decor"!==this.host._mode||"image"!==this.host._decorTool||!this.host._pointerModality.hoverEnabled)return d;const s=this.hooks.decorSnap(t.raw,"mouse"),i=$e(e.width,e.height),o=we(i.w,this.host._cellCm,this.host._gridPitch)/lt,a=we(i.h,this.host._cellCm,this.host._gridPitch)/this.host._decorH,n=this.host._display(e.url);return n?At``}afterRender(){const t=this.host.root();this._blocked&&(this._openGroupId?this.closeGroup(!1):"palette"===this._currentModel?.kind&&this._currentModel.dismiss?.()),this._syncGlobalDismissListener();const e=t.querySelector(".editor-secondary"),s=this._renderedContext,i=e?.dataset.contextId||"";if(i&&s&&i!==s&&!window.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches&&(this._contentAnimation?.cancel(),this._contentAnimation=e?.querySelector(".editor-secondary-content")?.animate([{opacity:.35,transform:"translateY(-4px)"},{opacity:1,transform:"translateY(0)"}],{duration:100,easing:"ease-out"})),this._renderedContext=i,s&&i!==s&&this._focusOwned){const s=i?e?.querySelector('[tabindex="0"], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])'):t.querySelector(".editbar-tools");s?.focus?.(),this._focusOwned=!!i}if("palette"===this._currentModel?.kind&&this._currentModel.launcherId){const e=[...t.querySelectorAll("[data-editor-palette]")].find(t=>t.dataset.editorPalette===this._currentModel?.launcherId);e&&null!==e.offsetParent||this._currentModel.dismiss?.()}if(!this._openGroupId)return;const o=[...t.querySelectorAll("[data-editor-group]")].find(t=>t.dataset.editorGroup===this._openGroupId);o&&null!==o.offsetParent||this.closeGroup(!0)}handleOutsideDismiss(t){if(Ec(t,t=>t.hasAttribute("data-editor-navigation")))return"pointerdown"===t.type?this.closeForNavigation():"click"===t.type&&this._dismissPointerTarget&&this._clearDismissClick(),!1;if("click"===t.type&&this._dismissPointerTarget){return!!(t.composedPath?.()||[t.target]).includes(this._dismissPointerTarget)&&(this._clearDismissClick(),t.preventDefault(),t.stopImmediatePropagation(),!0)}const e=this._openGroupId||this._blocked||"palette"!==this._currentModel?.kind?null:this._currentModel;if("pointerdown"===t.type&&(this._openGroupId||e)){const s=Ec(t,t=>t.classList.contains("editor-secondary")),i=Ec(t,t=>!!t.dataset.editorGroup),o=Ec(t,t=>!!t.dataset.editorPalette),a=Ec(t,t=>t.classList.contains("stage"));if(!(s||i||o||"stay-open-on-canvas"===e?.dismissPolicy&&a))return t.preventDefault(),t.stopImmediatePropagation(),this._dismissPointerTarget=t.target,clearTimeout(this._dismissTimer),this._dismissTimer=window.setTimeout(()=>{this._clearDismissClick()},800),this._openGroupId?this.closeGroup(!1):e?.dismiss?.(),this._syncGlobalDismissListener(),!0}return!1}_activateGroupItem(t,e,s){if(t.id!==this._openGroupId)return;const i=t.items.find(t=>t.id===e);if(!i||i.disabled)return;const o="toggle"===i.role&&"stay-open"===i.closePolicy,a=0===s.detail;o||(this._openGroupId=null,this.host.requestUpdate(),this._syncGlobalDismissListener()),i.invoke(),!o&&a&&this.host.updateComplete().then(()=>{const e=[...this.host.root().querySelectorAll("[data-editor-group]")].find(e=>e.dataset.editorGroup===t.id&&null!==e.offsetParent);e?.focus()})}_groupKeydown(t){if(!["ArrowLeft","ArrowRight","Home","End"].includes(t.key))return;const e=[...t.currentTarget.querySelectorAll(".editor-group-item:not([disabled])")];if(!e.length)return;t.preventDefault();const s=e.indexOf(this.host.root().activeElement),i="Home"===t.key?0:"End"===t.key?e.length-1:"ArrowLeft"===t.key?s<=0?e.length-1:s-1:(s+1)%e.length;e[i]?.focus()}_clearDismissClick(){this._dismissPointerTarget=null,clearTimeout(this._dismissTimer),this._dismissTimer=void 0,this._syncGlobalDismissListener()}_syncGlobalDismissListener(){const t=!this._blocked&&"palette"===this._currentModel?.kind,e=!!this._openGroupId||t||!!this._dismissPointerTarget;e!==this._globalDismissListening&&(this._globalDismissListening=e,e?(window.addEventListener("pointerdown",this._globalDismissGuard,!0),window.addEventListener("click",this._globalDismissGuard,!0)):(window.removeEventListener("pointerdown",this._globalDismissGuard,!0),window.removeEventListener("click",this._globalDismissGuard,!0)))}}const Hc=t=>t.stopPropagation(),Bc=new WeakSet,Wc=t=>{t._regSignature="",t._maybeRebuildDevices(),t.requestUpdate()};async function jc(t,e,s,i,o,a=""){const n=t.host,r=n._serverCfg;if(!r)return!1;let l=JSON.parse(JSON.stringify(r));l.markers=l.markers||[];let h=l.markers.find(t=>t.id===e);if(!h){const t=n._devices.find(t=>t.id===e);if(!t||"device"!==t.bindingKind&&"entity"!==t.bindingKind||!t.bindingRef)return!1;h={id:t.id,binding:`${t.bindingKind}:${t.bindingRef}`,space:t.space||null,area:t.area||null,hidden:!!t.hidden},l.markers.push(h)}h.vacuum=function(t,e){const s=e.matrix.map(t=>Number(t.toFixed(6))),i=t?.map_routes;if(Array.isArray(i)&&i.length){const o=i.find(t=>t.id===e.routeId)||i.find(t=>t.source===e.source&&t.map_id===e.mapId);if(o)return{...t,map_routes:jo(i,o.id,s)}}return{...t,source:e.source,calibration:{...t?.calibration||{},[e.mapId]:s}}}(h.vacuum||{},{source:s,mapId:i,routeId:a,matrix:o}),l=t._prepareConfigCandidate(l);const c=n._adoption.beginOptimistic(r,l);n._adoption.stageLocalConfig(l),Wc(n),n._saveConfigDebounced.pending()&&n._saveConfigDebounced.cancel();try{return await t._saveConfigNow(c),!0}catch(t){return n._rollbackOptimistic(c),Wc(n),n._showToast(n._t("toast.cfg_save_failed",{err:n._errText(t)})),!1}}function Gc(t){return 1===t}function qc(t){return`${t}-${globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}`}function Uc(t){const e=function(t){return JSON.stringify({message:t.message.trim(),contact:t.contact.trim(),previewToken:t.attach&&t.preview?t.preview.token:""})}(t);return{idempotencyKey:t.submissionFingerprint&&t.submissionFingerprint!==e?qc("report"):t.idempotencyKey,fingerprint:e}}function Kc(t){return[...t].length}function Vc(t,e=Date.now()){const s=t.message.trim();return s?Kc(s)>1e4?"message_too_long":Kc(t.contact.trim())>320?"contact_too_long":t.attach&&!t.preview?"preview_missing":t.attach&&t.preview.expiresAt<=e?"preview_expired":null:"message_required"}function Jc(t,e=Date.now()){return"building"!==t.status&&"sending"!==t.status&&"success"!==t.status&&null===Vc(t,e)}function Zc(t){const e=function(t){const e=/Firefox\/(\d+)/i.exec(t);if(e)return{family:"firefox",major:Number(e[1])||0};const s=/(?:Chrome|Chromium|Edg)\/(\d+)/i.exec(t);if(s)return{family:"chromium",major:Number(s[1])||0};const i=/Version\/(\d+).+Safari\//i.exec(t);return i?{family:"webkit",major:Number(i[1])||0}:{family:"unknown",major:0}}(t.userAgent??globalThis.navigator?.userAgent??""),s=t.now??Date.now(),i=Number(t.registryLastSuccess||0),o=i<=0?"unknown":s-i<=6e5?"fresh":"stale",a=["en","ru","de","fr"].includes(t.language)?t.language:"en",n=globalThis.matchMedia?.bind(globalThis);return{browser_family:e.family,browser_major:Math.max(0,Math.min(999,e.major)),language:a,coarse_pointer:t.coarsePointer??!!n?.("(pointer: coarse)").matches,hover_capable:t.hoverCapable??!!n?.("(hover: hover)").matches,registry_access:"full"===t.registryAccess?"full":"limited"===t.registryAccess?"partial":"unavailable",registry_age_bucket:o}}function Yc(t){const e=t&&"object"==typeof t&&"code"in t?String(t.code||""):"";return new Set(["support_invalid_message","support_preview_expired","support_package_too_large","support_rate_limited","support_unavailable","support_rejected","unauthorized"]).has(e)?e:"support_unavailable"}const Xc=[{id:"air_conditioner",group:"appliance",art:{d:"M85 71.5 L85 63 M25 71.5 L25 63 M25 71.5 L89.5 71.5 C90.8807 71.5 92 70.3807 92 69 L92 41.5 C92 40.1193 90.8807 39 89.5 39 L20.5 39 C19.1193 39 18 40.1193 18 41.5 L18 69 C18 70.3807 19.1193 71.5 20.5 71.5 L25 71.5 Z M85 63 C85 61.6193 83.8807 60.5 82.5 60.5 L27.5 60.5 C26.1193 60.5 25 61.6193 25 63 M85 63 L85 66.5 L25 66.5 L25 63",viewW:110,viewH:110}},{id:"armchair",group:"furniture",art:{d:"M77.5 48.5 L77.5 39 C77.5 33.4772 73.0228 29 67.5 29 L42.5 29 C36.9772 29 32.5 33.4772 32.5 39 L32.5 48.5205 M77.5 48.5 C80.8137 48.5 83.5 51.1863 83.5 54.5 C83.5 57.1123 81.8302 59.3334 79.5 60.1572 L79.5 71.5 C79.5 73.7091 77.7091 75.5 75.5 75.5 M77.5 48.5 C74.2576 48.5 71.617 51.072 71.5049 54.2871 C71.5012 54.3576 71.5 54.4286 71.5 54.5 L71.5 61.75 M38 61.75 L38 54 C38 53.2396 37.7873 52.5291 37.4189 51.9238 C36.5228 50.0421 34.6765 48.7002 32.5 48.5205 M32.5 48.5205 C32.3351 48.5069 32.1684 48.5 32 48.5 M75.5 75.5 L34 75.5 M75.5 75.5 L72.5 75.5 M34 75.5 C31.7909 75.5 30 73.7091 30 71.5 L30 60.1572 C27.6698 59.3334 26 57.1123 26 54.5 C26 51.1863 28.6863 48.5 32 48.5 M34 75.5 L36.5 75.5 M32 48.5 C34.3914 48.5 36.4549 49.8996 37.4189 51.9238 M38 61.75 C38 64.3734 40.1266 66.5 42.75 66.5 L66.75 66.5 C69.3734 66.5 71.5 64.3734 71.5 61.75 M38 61.75 C38 59.1266 40.1266 57 42.75 57 L66.75 57 C69.3734 57 71.5 59.1266 71.5 61.75 M36.5 75.5 L44.5 75.5 M36.5 75.5 L36.5 80.5 C36.5 81.3284 37.1716 82 38 82 L41.3921 82 C42.0506 82 42.6321 81.5705 42.8258 80.9411 L44.5 75.5 M44.5 75.5 L64.5 75.5 M72.5 75.5 L64.5 75.5 M72.5 75.5 L72.5 80.5 C72.5 81.3284 71.8284 82 71 82 L67.6079 82 C66.9494 82 66.3679 81.5705 66.1742 80.9411 L64.5 75.5",viewW:110,viewH:110}},{id:"bathtub",group:"sanitary",art:{d:"M28 74.8457 L28 80 C28 80.8284 28.6716 81.5 29.5 81.5 L32.8921 81.5 C33.5506 81.5 34.1321 81.0705 34.3258 80.4411 L35.6923 76 M28.0191 74.8558 C28.0127 74.8524 28.0063 74.8491 28 74.8457 C25.4198 73.4833 23.483 71.0169 22.8673 67.9996 M19.5 51.5 L90 51.5 M19.5 51.5 C18.1193 51.5 17 50.3807 17 49 C17 47.6193 18.1193 46.5 19.5 46.5 M19.5 51.5 L22.8673 67.9996 M90 51.5 C91.3807 51.5 92.5 50.3807 92.5 49 C92.5 47.6193 91.3807 46.5 90 46.5 M90 51.5 L86.6327 67.9996 C85.9778 71.2088 83.8285 73.7948 81 75.0922 M90 46.5 L19.5 46.5 M90 46.5 L20 46.5 M19.5 46.5 L20 46.5 M22.8673 67.9996 C23.4846 71.0243 25.4293 73.4954 28.0191 74.8558 M30 36 L30 34 C30 32.6739 29.4732 31.4021 28.5355 30.4645 C27.5979 29.5268 26.3261 29 25 29 C23.6739 29 22.4021 29.5268 21.4645 30.4645 C20.5268 31.4021 20 32.6739 20 34 L20 46.5 M81 75.0922 C79.7247 75.6771 78.3114 76 76.8347 76 L73.3077 76 M81 75.0922 L81 80 C81 80.8284 80.3284 81.5 79.5 81.5 L76.1079 81.5 C75.4494 81.5 74.8679 81.0705 74.6742 80.4411 L73.3077 76 M73.3077 76 L35.6923 76 M35.6923 76 L32.6653 76 C31.1128 76 29.6303 75.643 28.3047 75 C28.2086 74.9534 28.1134 74.9053 28.0191 74.8558",viewW:110,viewH:110}},{id:"bed",group:"furniture",art:{d:"M16 75.5 L24 75.5 M16 75.5 L16 80.5 C16 81.3284 16.6716 82 17.5 82 L20.8921 82 C21.5506 82 22.1321 81.5705 22.3258 80.9411 L24 75.5 M16 75.5 L15 75.5 M24 75.5 L86.5 75.5 M94.5 75.5 L86.5 75.5 M94.5 75.5 L94.5 80.5 C94.5 81.3284 93.8284 82 93 82 L89.6079 82 C88.9494 82 88.3679 81.5705 88.1742 80.9411 L86.5 75.5 M94.5 75.5 L95.5 75.5 M88 50.1296 L88 31.5 C88 30.1193 86.8807 29 85.5 29 L25 29 C23.6193 29 22.5 30.1193 22.5 31.5 L22.5 50.1296 M87.9383 50.1068 C87.9589 50.1143 87.9795 50.1219 88 50.1296 C91.7967 51.5483 94.5 55.2085 94.5 59.5 M22.5617 50.1068 C22.5411 50.1143 22.5205 50.1219 22.5 50.1296 C18.7033 51.5483 16 55.2085 16 59.5 M94.5 65.5 L94.5 59.5 M94.5 65.5 L16 65.5 M94.5 65.5 L95.5 65.5 M16 65.5 L16 59.5 M16 65.5 L15 65.5 M84.5 49.5 L26 49.5 M84.5 49.5 L80 49.5 M94.5 59.5 C94.5 55.1853 91.7674 51.5088 87.9383 50.1068 C86.8662 49.7142 85.7081 49.5 84.5 49.5 M26 49.5 L30.5 49.5 M16 59.5 C16 55.1853 18.7326 51.5088 22.5617 50.1068 C23.6338 49.7142 24.7919 49.5 26 49.5 M15 75.5 L95.5 75.5 M15 75.5 C14.4477 75.5 14 75.0523 14 74.5 L14 66.5 C14 65.9477 14.4477 65.5 15 65.5 M95.5 75.5 C96.0523 75.5 96.5 75.0523 96.5 74.5 L96.5 66.5 C96.5 65.9477 96.0523 65.5 95.5 65.5 M95.5 65.5 L15 65.5 M51.5 49.5 L51.5 45.5 C51.5 42.7386 49.2614 40.5 46.5 40.5 L35.5 40.5 C32.7386 40.5 30.5 42.7386 30.5 45.5 L30.5 49.5 M51.5 49.5 L30.5 49.5 M51.5 49.5 L59 49.5 M80 49.5 L80 45.5 C80 42.7386 77.7614 40.5 75 40.5 L64 40.5 C61.2386 40.5 59 42.7386 59 45.5 L59 49.5 M80 49.5 L59 49.5",viewW:110,viewH:110}},{id:"bidet",group:"sanitary",art:{d:"M46 67.5 L64.5 67.5 M46 67.5 C40.4772 67.5 36 63.0228 36 57.5 L36 53 M46 67.5 C45.4902 67.5 44.9893 67.4618 44.5 67.3882 L44.5 79.5 C44.5 80.0523 44.9477 80.5 45.5 80.5 L65 80.5 C65.5523 80.5 66 80.0523 66 79.5 L66 67.3882 C65.5107 67.4618 65.0098 67.5 64.5 67.5 M64.5 67.5 C70.0229 67.5 74.5 63.0228 74.5 57.5 L74.5 53 M74.5 53 L74.5 47.5 C74.5 46.9477 74.0523 46.5 73.5 46.5 M74.5 53 L36 53 M36 53 L36 47.5 C36 46.9477 36.4477 46.5 37 46.5 M73.5 46.5 L37 46.5 M73.5 46.5 L60 46.5 M37 46.5 L50.5 46.5 M51.5 40 L59 40 M51.5 40 C50.9477 40 50.5 40.4477 50.5 41 L50.5 46.5 M51.5 40 L53 40 M59 40 C59.5523 40 60 40.4477 60 41 L60 46.5 M59 40 L57.5 40 M60 46.5 L50.5 46.5 M57.5 40 L57.5 30 C57.5 29.4477 57.0523 29 56.5 29 L54 29 C53.4477 29 53 29.4477 53 30 M57.5 40 L53 40 M53 40 L53 30 M53 40 L53 36 M53 30 L53 31.5 M53 31.5 L49 31.5 C48.4477 31.5 48 31.9477 48 32.5 L48 35 C48 35.5523 48.4477 36 49 36 L53 36 M53 31.5 L53 36",viewW:110,viewH:110}},{id:"boiler",group:"appliance",art:{d:"M51.5 81.5 L51.5 86 C51.5 86.5523 51.0523 87 50.5 87 L47.5 87 C46.9477 87 46.5 86.5523 46.5 86 L46.5 81.5 M51.5 81.5 L46.5 81.5 M51.5 81.5 L59 81.5 M46.5 81.5 L44 81.5 M64 81.5 L64 86 C64 86.5523 63.5523 87 63 87 L60 87 C59.4477 87 59 86.5523 59 86 L59 81.5 M64 81.5 L59 81.5 M64 81.5 L66.5 81.5 M74.5 73 L74.5 73.5 C74.5 77.9183 70.9183 81.5 66.5 81.5 M44 81.5 C39.5817 81.5 36 77.9183 36 73.5 L36 73 L36 31 C36 26.5817 39.5817 23 44 23 L66.5 23 C70.9183 23 74.5 26.5817 74.5 31 L74.5 73 M74.5 73 L36 73 M66.5 81.5 L44 81.5 M55 42.5 L58.5 39 M62.5 42.5 C62.5 46.366 59.366 49.5 55.5 49.5 C51.634 49.5 48.5 46.366 48.5 42.5 C48.5 38.634 51.634 35.5 55.5 35.5 C59.366 35.5 62.5 38.634 62.5 42.5 Z",viewW:110,viewH:110}},{id:"chair",group:"furniture",art:{d:"M41.25 60.5 L68.75 60.5 M68.75 60.5 C70.5449 60.5 72 59.0449 72 57.25 C72 55.6281 70.8119 54.2836 69.2585 54.0395 C69.0928 54.0135 68.923 54 68.75 54 L41.25 54 C41.077 54 40.9072 54.0135 40.7415 54.0395 C39.1881 54.2836 38 55.6281 38 57.25 C38 59.0449 39.4551 60.5 41.25 60.5 M41.25 60.5 L46 60.5 M68.75 60.5 L64 60.5 M64 60.5 L69.5 60.5 L69.5 82 C69.5 82.8284 68.8284 83.5 68 83.5 L67.3752 83.5 C66.5972 83.5 65.9483 82.9051 65.8809 82.1299 L64 60.5 Z M64 60.5 L46 60.5 M46 60.5 L40.5 60.5 L40.5 82 C40.5 82.8284 41.1716 83.5 42 83.5 L42.6248 83.5 C43.4028 83.5 44.0517 82.9051 44.1191 82.1299 L46 60.5 Z M40.7415 54.0395 C40.5847 53.5546 40.5 53.0372 40.5 52.5 L40.5 39.5 C40.5 32.5964 46.0964 27 53 27 L57 27 C63.9036 27 69.5 32.5964 69.5 39.5 L69.5 52.5 C69.5 53.0372 69.4153 53.5546 69.2585 54.0395",viewW:110,viewH:110}},{id:"coffee_table",group:"furniture",art:{d:"M85.2381 55 L86.5 55 C87.0523 55 87.5 54.5523 87.5 54 L87.5 51 L84.6598 43.4847 C84.2586 42.5818 83.3633 42 82.3753 42 L26.6247 42 C25.6367 42 24.7414 42.5818 24.3402 43.4847 L21.5 51 L21.5 54 C21.5 54.5523 21.9477 55 22.5 55 L25 55 M87.5 51 L21.5 51 M25 55 L25 66.5 C25 67.3284 25.6716 68 26.5 68 L27.2113 68 C27.983 68 28.6288 67.4144 28.7041 66.6464 L29.8459 55 M25 55 L29.8459 55 M29.8459 55 L80.3922 55 M80.3922 55 L81.534 66.6464 C81.6093 67.4144 82.2551 68 83.0268 68 L83.7381 68 C84.5665 68 85.2381 67.3284 85.2381 66.5 L85.2381 55 M80.3922 55 L85.2381 55",viewW:110,viewH:110}},{id:"computer",group:"appliance",art:{d:"M43 65 L48 65 M43 65 L24.5 65 C23.1193 65 22 63.8807 22 62.5 L22 40.5 C22 39.1193 23.1193 38 24.5 38 L64.5 38 C65.8807 38 67 39.1193 67 40.5 L67 62.5 C67 63.8807 65.8807 65 64.5 65 L48 65 M43 65 L43 72 M48 65 L48 72 M37 72 L43 72 M54.0711 72 L48 72 M76 60 L84 60 M76 43 L84 43 M35 53 L35 46 L39.5 46 C40.4283 46 41.3185 46.3687 41.9749 47.0251 C42.6313 47.6815 43 48.5717 43 49.5 C43 50.4283 42.6312 51.3185 41.9749 51.9749 C41.3185 52.6313 40.4283 53 39.5 53 L35 53 Z M35 53 L35 56 M54.5355 54.5355 C53.8363 55.2348 52.9454 55.711 51.9755 55.9039 C51.0055 56.0969 50.0002 55.9978 49.0866 55.6194 C48.173 55.241 47.3921 54.6001 46.8427 53.7779 C46.2932 52.9556 46 51.9889 46 51 C46 50.0111 46.2932 49.0444 46.8427 48.2221 C47.3921 47.3999 48.173 46.759 49.0866 46.3806 C50.0002 46.0022 51.0055 45.9031 51.9755 46.0961 C52.9454 46.289 53.8363 46.7652 54.5355 47.4645 M48 72 L43 72 M74.5 72 L85.5 72 C86.8807 72 88 70.8807 88 69.5 L88 40.5 C88 39.1193 86.8807 38 85.5 38 L74.5 38 C73.1193 38 72 39.1193 72 40.5 L72 69.5 C72 70.8807 73.1193 72 74.5 72 Z",viewW:110,viewH:110}},{id:"cooktop",group:"appliance",art:{d:"M25 31.5 C25 30.1193 26.1193 29 27.5 29 L82.5 29 C83.8807 29 85 30.1193 85 31.5 L85 78.5 C85 79.8807 83.8807 81 82.5 81 L27.5 81 C26.1193 81 25 79.8807 25 78.5 L25 31.5 Z M49.5 66.5 C49.5 70.9183 45.9183 74.5 41.5 74.5 C37.0817 74.5 33.5 70.9183 33.5 66.5 C33.5 62.0817 37.0817 58.5 41.5 58.5 C45.9183 58.5 49.5 62.0817 49.5 66.5 Z M76 43.5 C76 47.9183 72.4183 51.5 68 51.5 C63.5817 51.5 60 47.9183 60 43.5 C60 39.0817 63.5817 35.5 68 35.5 C72.4183 35.5 76 39.0817 76 43.5 Z M73 66.5 C73 69.2614 70.7614 71.5 68 71.5 C65.2386 71.5 63 69.2614 63 66.5 C63 63.7386 65.2386 61.5 68 61.5 C70.7614 61.5 73 63.7386 73 66.5 Z M49.5 43.5 C49.5 47.9183 45.9183 51.5 41.5 51.5 C37.0817 51.5 33.5 47.9183 33.5 43.5 C33.5 39.0817 37.0817 35.5 41.5 35.5 C45.9183 35.5 49.5 39.0817 49.5 43.5 Z",viewW:110,viewH:110}},{id:"dining_table",group:"furniture",art:{d:"M26.875 47 L23.5 47 C22.9477 47 22.5 46.5523 22.5 46 L22.5 43 L24.8802 35.5939 C25.2539 34.633 26.1791 34 27.2102 34 L83.7898 34 C84.8209 34 85.7462 34.633 86.1198 35.5939 L88.5 43 L88.5 46 C88.5 46.5523 88.0523 47 87.5 47 L84.125 47 M22.5 43 L88.5 43 M78.875 47 L84.742 73.8205 C84.8926 74.5092 85.5024 75 86.2073 75 L86.7474 75 C87.6682 75 88.3716 74.1781 88.2294 73.2684 L84.125 47 M78.875 47 L84.125 47 M78.875 47 L32.125 47 M32.125 47 L26.258 73.8205 C26.1074 74.5092 25.4976 75 24.7927 75 L24.2526 75 C23.3318 75 22.6284 74.1781 22.7706 73.2684 L26.875 47 M32.125 47 L26.875 47",viewW:110,viewH:110}},{id:"dishwasher",group:"appliance",art:{d:"M81 82.5 L81 27.5 M81 82.5 C81 83.8807 79.8807 85 78.5 85 L31.5 85 C30.1193 85 29 83.8807 29 82.5 L29 55.5 M81 82.5 L81 40 M81 27.5 C81 26.1193 79.8807 25 78.5 25 L31.5 25 C30.1193 25 29 26.1193 29 27.5 M81 27.5 L81 40 M29 27.5 L29 55.5 M29 27.5 L29 40 M81 40 C81 38.6193 79.8807 37.5 78.5 37.5 L31.5 37.5 C30.1193 37.5 29 38.6193 29 40 M29 40 L29 55.5 M35.75 31 L45.25 31 M55.9943 55 C55.9943 55 54.6654 56.8105 54.5153 58.1429 C54.3169 59.9042 56.1139 60.6968 55.9943 62.4643 C55.8942 63.9429 54.5153 66 54.5153 66 M60.4943 55 C60.4943 55 59.1654 56.8105 59.0153 58.1429 C58.8169 59.9042 60.6139 60.6968 60.4943 62.4643 C60.3942 63.9429 59.0153 66 59.0153 66 M50.9943 55 C50.9943 55 49.6654 56.8105 49.5153 58.1429 C49.3169 59.9042 51.1139 60.6968 50.9943 62.4643 C50.8942 63.9429 49.5153 66 49.5153 66 M72 60.5 C72 69.8888 64.3888 77.5 55 77.5 C45.6112 77.5 38 69.8888 38 60.5 C38 51.1112 45.6112 43.5 55 43.5 C64.3888 43.5 72 51.1112 72 60.5 Z M66.5 60.5 C66.5 66.8513 61.3513 72 55 72 C48.6487 72 43.5 66.8513 43.5 60.5 C43.5 54.1487 48.6487 49 55 49 C61.3513 49 66.5 54.1487 66.5 60.5 Z M69.5 31 C69.5 32.1046 68.6046 33 67.5 33 C66.3954 33 65.5 32.1046 65.5 31 C65.5 29.8954 66.3954 29 67.5 29 C68.6046 29 69.5 29.8954 69.5 31 Z M77 31 C77 32.1046 76.1046 33 75 33 C73.8954 33 73 32.1046 73 31 C73 29.8954 73.8954 29 75 29 C76.1046 29 77 29.8954 77 31 Z",viewW:110,viewH:110}},{id:"dryer",group:"appliance",art:{d:"M81 82.5 L81 27.5 M81 82.5 C81 83.8807 79.8807 85 78.5 85 L31.5 85 C30.1193 85 29 83.8807 29 82.5 L29 55.5 M81 82.5 L81 40 M81 27.5 C81 26.1193 79.8807 25 78.5 25 L31.5 25 C30.1193 25 29 26.1193 29 27.5 M81 27.5 L81 40 M29 27.5 L29 55.5 M29 27.5 L29 40 M81 40 C81 38.6193 79.8807 37.5 78.5 37.5 L31.5 37.5 C30.1193 37.5 29 38.6193 29 40 M29 40 L29 55.5 M35.75 31 L45.25 31 M55.9943 55 C55.9943 55 54.6654 56.8105 54.5153 58.1429 C54.3169 59.9042 56.1139 60.6968 55.9943 62.4643 C55.8942 63.9429 54.5153 66 54.5153 66 M60.4943 55 C60.4943 55 59.1654 56.8105 59.0153 58.1429 C58.8169 59.9042 60.6139 60.6968 60.4943 62.4643 C60.3942 63.9429 59.0153 66 59.0153 66 M50.9943 55 C50.9943 55 49.6654 56.8105 49.5153 58.1429 C49.3169 59.9042 51.1139 60.6968 50.9943 62.4643 C50.8942 63.9429 49.5153 66 49.5153 66 M72 60.5 C72 69.8888 64.3888 77.5 55 77.5 C45.6112 77.5 38 69.8888 38 60.5 C38 51.1112 45.6112 43.5 55 43.5 C64.3888 43.5 72 51.1112 72 60.5 Z M66.5 60.5 C66.5 66.8513 61.3513 72 55 72 C48.6487 72 43.5 66.8513 43.5 60.5 C43.5 54.1487 48.6487 49 55 49 C61.3513 49 66.5 54.1487 66.5 60.5 Z M69.5 31 C69.5 32.1046 68.6046 33 67.5 33 C66.3954 33 65.5 32.1046 65.5 31 C65.5 29.8954 66.3954 29 67.5 29 C68.6046 29 69.5 29.8954 69.5 31 Z M77 31 C77 32.1046 76.1046 33 75 33 C73.8954 33 73 32.1046 73 31 C73 29.8954 73.8954 29 75 29 C76.1046 29 77 29.8954 77 31 Z",viewW:110,viewH:110}},{id:"exercise",group:"other",art:{d:"M55.091 60.072 L65.7741 35.5156 M42.2119 56.2083 L55.091 60.072 L60.8511 61.8001 L66.5032 63.4957 C70.733 64.7646 73.6297 68.6579 73.6297 73.074 L73.6297 76.2635 L29.3385 76.2635 L29.3385 65.7866 C29.3385 60.9371 32.7227 57.0804 37.0256 56.051 C38.5108 55.6956 40.1055 55.6771 41.7081 56.0709 M41.7081 56.0709 C41.876 56.1122 42.044 56.1579 42.2119 56.2083 L60.8511 61.8001 M71.9311 35.5156 L76.4108 35.5156 C78.2451 35.5156 79.9321 34.5112 80.8064 32.8987 L83.8375 27.308 C84.3011 26.4529 83.9993 25.384 83.1569 24.8976 C82.2982 24.4018 81.2002 24.696 80.7045 25.5547 L77.8652 30.4723 C77.3293 31.4005 76.3389 31.9723 75.2671 31.9723 L65.6573 31.9723 C64.6788 31.9723 63.8856 32.7655 63.8856 33.744 C63.8856 34.7224 64.6788 35.5156 65.6573 35.5156 L65.7741 35.5156 M71.9311 35.5156 C71.9603 35.7673 71.9261 36.0298 71.8188 36.2793 L60.8511 61.8001 M71.9311 35.5156 L65.7741 35.5156 M41.7081 56.0709 L38.03 42.6022 M37.0256 56.051 L33.3529 42.6022 M38.03 42.6022 L33.3529 42.6022 L29.7814 42.6022 C28.5583 42.6022 27.5668 41.6107 27.5668 40.3876 C27.5668 39.1646 28.5583 38.1731 29.7814 38.1731 L41.2971 38.1731 C42.5202 38.1731 43.5117 39.1646 43.5117 40.3876 C43.5117 41.6107 42.5202 42.6022 41.2971 42.6022 L38.03 42.6022 Z M25.7952 78.921 C25.7952 77.4533 26.985 76.2635 28.4526 76.2635 L74.5155 76.2636 C75.9832 76.2636 77.173 77.4533 77.173 78.921 C77.173 80.3887 75.9832 81.5785 74.5155 81.5785 L28.4526 81.5785 C26.985 81.5785 25.7952 80.3887 25.7952 78.921 Z M29.3385 81.5785 L29.3385 84.5677 C29.3385 85.3962 30.01 86.0677 30.8385 86.0677 L33.6379 86.0677 C34.2512 86.0677 34.8028 85.6943 35.0306 85.1248 L36.5002 81.5785 L29.3385 81.5785 Z M73.6297 81.5785 L73.6297 84.5677 C73.6297 85.3962 72.9581 86.0677 72.1297 86.0677 L69.3303 86.0677 C68.717 86.0677 68.1654 85.6943 67.9376 85.1248 L66.5002 81.5785 L73.6297 81.5785 Z M45.2833 66.0766 C45.2833 68.7673 43.102 70.9486 40.4113 70.9486 C37.7205 70.9486 35.5392 68.7673 35.5392 66.0766 C35.5392 63.3858 37.7205 61.2045 40.4113 61.2045 C43.102 61.2045 45.2833 63.3858 45.2833 66.0766 Z",viewW:110,viewH:110}},{id:"fireplace",group:"other",art:{d:"M71.1884 73.8943 L71.1884 50.4399 C71.1884 47.6784 68.9498 45.4399 66.1884 45.4399 L43.1445 45.4399 C40.3831 45.4399 38.1445 47.6784 38.1445 50.4399 L38.1445 73.8942 M38.1445 73.8942 L26.7031 73.8942 L26.7031 34.4252 L82.6629 34.4252 L82.6629 73.8942 L71.1884 73.8943 L38.1445 73.8942 Z M62.0101 62.8795 L47.3239 62.8795 C45.8031 62.8795 44.5703 64.1124 44.5703 65.6332 C44.5703 67.154 45.8031 68.3868 47.3239 68.3868 M47.3239 68.3868 C45.8031 68.3868 44.5703 69.6195 44.5703 71.1403 C44.5703 72.6611 45.8031 73.894 47.3239 73.894 M47.3239 68.3868 C48.8447 68.3868 50.0776 69.6195 50.0776 71.1403 C50.0776 72.6611 48.8447 73.894 47.3239 73.894 M47.3239 68.3868 L61.9918 68.3868 M47.3239 73.894 L62.0101 73.894 C63.5309 73.894 64.7637 72.6611 64.7637 71.1403 C64.7637 69.6242 63.5385 68.3945 62.0243 68.3869 M62.0114 68.3869 C62.0049 68.3869 61.9983 68.3869 61.9918 68.3868 M62.0114 68.3869 C62.0157 68.3869 62.02 68.3869 62.0243 68.3869 M62.0114 68.3869 L62.0243 68.3869 M62.0114 68.3869 L61.9918 68.3868 M61.9918 68.3868 C60.48 68.3763 59.2578 67.1475 59.2578 65.6332 C59.2578 64.1124 60.4906 62.8796 62.0114 62.8796 C63.5322 62.8796 64.7651 64.1124 64.7651 65.6332 C64.7651 67.1498 63.5392 68.3799 62.0243 68.3869 M61.9918 68.3868 L62.0101 68.3868 C62.0148 68.3868 62.0195 68.3868 62.0243 68.3869 M24 81.6962 L85.3341 81.6962 C85.8864 81.6962 86.3341 81.2485 86.3341 80.6962 L86.3341 74.8942 C86.3341 74.3419 85.8864 73.8942 85.3341 73.8942 L24 73.8942 C23.4477 73.8942 23 74.3419 23 74.8942 L23 80.6962 C23 81.2485 23.4477 81.6962 24 81.6962 Z M24 34.4252 L85.3341 34.4252 C85.8864 34.4252 86.3341 33.9775 86.3341 33.4252 L86.3341 29 C86.3341 28.4477 85.8864 28 85.3341 28 L24 28 C23.4477 28 23 28.4477 23 29 L23 33.4252 C23 33.9775 23.4477 34.4252 24 34.4252 Z",viewW:110,viewH:110}},{id:"fridge",group:"appliance",art:{d:"M35.5 87 C34.1193 87 33 85.8807 33 84.5 M35.5 87 L74.5 87 M35.5 87 L35.5 90.5 C35.5 91.0523 35.9477 91.5 36.5 91.5 L73.5 91.5 C74.0523 91.5 74.5 91.0523 74.5 90.5 L74.5 87 M33 84.5 L33 20.5 M33 84.5 L33 46.5 M77.5 84.5 L77.5 20.5 M77.5 84.5 C77.5 85.8807 76.3807 87 75 87 L74.5 87 M77.5 84.5 L77.5 46.5 M77.5 20.5 C77.5 19.1193 76.3807 18 75 18 L35.5 18 C34.1193 18 33 19.1193 33 20.5 M77.5 20.5 L77.5 46.5 M33 20.5 L33 46.5 M33 46.5 L77.5 46.5 M38.5 41 L38.5 31.5 M38.5 62 L38.5 52.5",viewW:110,viewH:110}},{id:"hood",group:"appliance",art:{d:"M66 57 L83 69 L83 71.5 C83 72.8807 81.8807 74 80.5 74 L29.5 74 C28.1193 74 27 72.8807 27 71.5 L27 69 L44 57 M44 57 L66 57 M44 57 L44 37.5 C44 36.1193 45.1193 35 46.5 35 L63.5 35 C64.8807 35 66 36.1193 66 37.5 L66 57 M83 69 L27 69",viewW:110,viewH:110}},{id:"kitchen_cabinet",group:"furniture",art:{d:"M72 84.95 L72 88 C72 88.5523 71.5523 89 71 89 L39 89 C38.4477 89 38 88.5523 38 88 L38 84.95 M55 20 L71.5 20 C72.8807 20 74 21.1193 74 22.5 L74 39.5 C74 40.8807 72.8807 42 71.5 42 L55 42 M55 20 L55 42 M55 20 L38.5 20 C37.1193 20 36 21.1193 36 22.5 L36 39.5 C36 40.8807 37.1193 42 38.5 42 L55 42 M59 33 L59 38 M51 33 L51 38 M55 85 L71.5 85 C72.8807 85 74 83.8807 74 82.5 L74 65.5 C74 64.1193 72.8807 63 71.5 63 L55 63 M55 85 L55 63 M55 85 L38.5 85 C37.1193 85 36 83.8807 36 82.5 L36 65.5 C36 64.1193 37.1193 63 38.5 63 L55 63 M67 67 L62 67 M48 67 L43 67",viewW:110,viewH:110}},{id:"kitchen_sink",group:"sanitary",art:{d:"M49 54 L49 59 M51.5 37.5 L44 37.5 M51.5 37.5 C52.0523 37.5 52.5 37.9477 52.5 38.5 L52.5 44 M51.5 37.5 L48 37.5 M44 37.5 C43.4477 37.5 43 37.9477 43 38.5 L43 44 M44 37.5 L48 37.5 M43 44 L21.5 44 C20.1193 44 19 45.1193 19 46.5 L19 81.5 C19 82.8807 20.1193 84 21.5 84 L89.5 84 C90.8807 84 92 82.8807 92 81.5 L92 46.5 C92 45.1193 90.8807 44 89.5 44 L52.5 44 M43 44 L52.5 44 M58 33 L58 31 C58 29.6739 57.4732 28.4021 56.5355 27.4645 C55.5979 26.5268 54.3261 26 53 26 C51.6739 26 50.4021 26.5268 49.4645 27.4645 C48.5268 28.4021 48 29.6739 48 31 L48 37.5 M62 54 L62 59 M26 50 L52.5 50 C53.0523 50 53.5 50.4477 53.5 51 L53.5 77 C53.5 77.5523 53.0523 78 52.5 78 L26 78 C25.4477 78 25 77.5523 25 77 L25 51 C25 50.4477 25.4477 50 26 50 Z M58.5 50 L85 50 C85.5523 50 86 50.4477 86 51 L86 77 C86 77.5523 85.5523 78 85 78 L58.5 78 C57.9477 78 57.5 77.5523 57.5 77 L57.5 51 C57.5 50.4477 57.9477 50 58.5 50 Z",viewW:110,viewH:110}},{id:"nightstand",group:"furniture",art:{d:"M34.5 76 C33.1193 76 32 74.8807 32 73.5 M34.5 76 L41.2308 76 M34.5 76 C34.3288 76 34.1616 75.9828 34 75.95 L34 78.5 C34 79.3284 34.6716 80 35.5 80 L38.8921 80 C39.5506 80 40.1321 79.5705 40.3258 78.9411 L41.2308 76 M32 73.5 L32 33 M32 73.5 L32 57.5 M78 73.5 L78 33 M69.2692 76 L75.5 76 C75.8556 76 76.1938 75.9258 76.5 75.792 C77.383 75.4062 78 74.5252 78 73.5 M78 73.5 L78 57.5 M78 33 C78 31.6193 76.8807 30.5 75.5 30.5 L34.5 30.5 C33.1193 30.5 32 31.6193 32 33 M78 33 L78 39.5 M32 33 L32 39.5 M32 39.5 L78 39.5 M32 39.5 L32 57.5 M78 39.5 L78 57.5 M78 57.5 L32 57.5 M50.5 48.5 L60 48.5 M50.5 66 L60 66 M41.2308 76 L69.2692 76 M69.2692 76 L70.1742 78.9411 C70.3679 79.5705 70.9494 80 71.6079 80 L75 80 C75.8284 80 76.5 79.3284 76.5 78.5 L76.5 75.792",viewW:110,viewH:110}},{id:"oven",group:"appliance",art:{d:"M29 76 C29 77.3807 30.1193 78.5 31.5 78.5 L78.5 78.5 C79.8807 78.5 81 77.3807 81 76 M29 76 L29 40 M29 76 L29 82.5 C29 83.8807 30.1193 85 31.5 85 L78.5 85 C79.8807 85 81 83.8807 81 82.5 L81 76 M81 76 L81 40 M81 40 C81 38.6193 79.8807 37.5 78.5 37.5 L31.5 37.5 C30.1193 37.5 29 38.6193 29 40 M81 40 L81 27.5 C81 26.1193 79.8807 25 78.5 25 L31.5 25 C30.1193 25 29 26.1193 29 27.5 L29 40 M35.75 31 L45.25 31 M43 42 L67 42 M40.5 72 L69.5 72 C70.8807 72 72 70.8807 72 69.5 L72 49.5 C72 48.1193 70.8807 47 69.5 47 L40.5 47 C39.1193 47 38 48.1193 38 49.5 L38 69.5 C38 70.8807 39.1193 72 40.5 72 Z M69.5 31 C69.5 32.1046 68.6046 33 67.5 33 C66.3954 33 65.5 32.1046 65.5 31 C65.5 29.8954 66.3954 29 67.5 29 C68.6046 29 69.5 29.8954 69.5 31 Z M77 31 C77 32.1046 76.1046 33 75 33 C73.8954 33 73 32.1046 73 31 C73 29.8954 73.8954 29 75 29 C76.1046 29 77 29.8954 77 31 Z",viewW:110,viewH:110}},{id:"plant",group:"other",art:{d:"M55.7064 55.8805 L55.7064 52.9357 M55.7064 52.9357 C56.839 47.0461 62.7965 41.9801 68.6182 37.5322 M55.7064 52.9357 C50.7678 48.7899 47.7236 46.7763 41.6621 43.8748 M67.4992 61.3174 L65.9151 75.8488 C65.7779 77.1181 64.7063 78.0801 63.4296 78.0801 L48.4373 78.0801 C47.1606 78.0801 46.089 77.1181 45.9518 75.8488 L44.3593 61.3174 L67.4992 61.3174 Z M60.2363 44.7807 C58.4234 36.1732 66.8047 29.604 76.9989 31.869 C76.9989 40.024 68.3904 48.6318 60.2363 44.7807 Z M50.476 49.9288 C51.9926 41.2641 43.391 34.9863 33.2805 37.5996 C33.5602 45.7498 42.4589 54.0573 50.476 49.9288 Z M43.1152 61.3174 L68.7509 61.3174 C69.3031 61.3174 69.7509 60.8697 69.7509 60.3174 L69.7509 56.8809 C69.7509 56.3286 69.3031 55.8809 68.7509 55.8809 L43.1152 55.8809 C42.5629 55.8809 42.1152 56.3286 42.1152 56.8809 L42.1152 60.3174 C42.1152 60.8697 42.5629 61.3174 43.1152 61.3174 Z",viewW:110,viewH:110}},{id:"rug",group:"other",art:{d:"M90.2693 33.8735 L84.648 33.8735 M25.6208 33.8735 L19.9995 33.8735 M90.2693 39.0264 L84.648 39.0264 M25.6208 39.0264 L19.9995 39.0264 M90.2693 44.1792 L84.648 44.1792 M25.6208 44.1792 L19.9995 44.1792 M90.2693 49.332 L84.648 49.332 M25.6208 49.332 L19.9995 49.332 M90.2693 54.4854 L84.648 54.4854 M25.6208 54.4854 L19.9995 54.4854 M90.2693 59.6382 L84.648 59.6382 M25.6208 59.6382 L19.9995 59.6382 M90.2693 64.791 L84.648 64.791 M25.6208 64.791 L19.9995 64.791 M90.2693 69.9438 L84.648 69.9438 M25.6208 69.9438 L19.9995 69.9438 M90.2693 75.0967 L84.648 75.0967 M25.6208 75.0967 L19.9995 75.0967 M28.121 32 L82.145 32 C83.5257 32 84.645 33.1193 84.645 34.5 L84.645 74.939 C84.645 76.3197 83.5257 77.439 82.145 77.439 L28.121 77.439 C26.7403 77.439 25.621 76.3197 25.621 74.939 L25.621 34.5 C25.621 33.1193 26.7403 32 28.121 32 Z M29.8369 32 L29.8369 77.439 M80.4302 32 L80.4302 77.439 M37.8005 54.4852 L55.6014 46.0532 L73.4022 54.4852 L55.6014 62.9172 L37.8005 54.4852 Z",viewW:110,viewH:110}},{id:"shelving",group:"furniture",art:{d:"M64 58.5 L64 47 C64 46.4477 64.4477 46 65 46 L68 46 C68.5523 46 69 46.4477 69 47 M64 58.5 L69 58.5 M64 58.5 L28 58.5 L28 39 L35.5 39 M69 58.5 L69 47 M69 58.5 L69 44.5 M69 58.5 L76 58.5 M69 47 L69 44.5 M52.5 39 L52.5 27.5 C52.5 26.9477 52.0523 26.5 51.5 26.5 L48.5 26.5 C47.9477 26.5 47.5 26.9477 47.5 27.5 M52.5 39 L47.5 39 M52.5 39 L81 39 L81 58.5 L76 58.5 M47.5 39 L47.5 27.5 M47.5 39 L47.5 25 M47.5 39 L40.5 39 M47.5 27.5 L47.5 25 M40.5 39 L40.5 27.5 M40.5 39 L40.5 25 M40.5 39 L35.5 39 M35.5 39 L35.5 27.5 C35.5 26.9477 35.9477 26.5 36.5 26.5 L39.5 26.5 C40.0523 26.5 40.5 26.9477 40.5 27.5 M40.5 27.5 L40.5 25 M49 72 L36.5 72 M50.5 72 L36.5 72 C35.9477 72 35.5 71.5523 35.5 71 L35.5 68.5 C35.5 67.9477 35.9477 67.5 36.5 67.5 L49 67.5 C49.5523 67.5 50 67.9477 50 68.5 L50 71 C50 71.5523 49.5523 72 49 72 M50.5 78 C51.0523 78 51.5 77.5523 51.5 77 L51.5 73 C51.5 72.4477 51.0523 72 50.5 72 L49 72 M36.5 72 C35.9477 72 35.5 72.4477 35.5 73 L35.5 77 C35.5 77.5523 35.9477 78 36.5 78 M76 58.5 L76 44.5 C76 43.9477 75.5523 43.5 75 43.5 L70 43.5 C69.4477 43.5 69 43.9477 69 44.5 M47.5 25 C47.5 24.4477 47.0523 24 46.5 24 L41.5 24 C40.9477 24 40.5 24.4477 40.5 25 M50.5 78 L36.5 78 M50.5 78 L81 78 L81 85 L28 85 L28 78 L36.5 78 M28 89.5 L28 23 C28 21.6193 29.1193 20.5 30.5 20.5 L78.5 20.5 C79.8807 20.5 81 21.6193 81 23 L81 89.5",viewW:110,viewH:110}},{id:"shower",group:"sanitary",art:{d:"M39 84 L39 31.7143 C39 25.245 44.2564 20 50.75 20 C56.4663 20 61.2394 24.5462 62.1824 29.0091 M51.5 39.25 C51.5 33.5891 56.0891 29 61.75 29 C67.4109 29 72 33.5891 72 39.25 L51.5 39.25 M54.75 44.25 L54.75 46.75 M62 44.25 L62 46.75 M69.25 44.25 L69.25 46.75 M54.75 50.5 L54.75 53 M62 50.5 L62 53 M69.25 50.5 L69.25 53 M54.75 56.75 L54.75 59.25 M62 56.75 L62 59.25 M69.25 56.75 L69.25 59.25 M54.75 63 L54.75 65.5 M62 63 L62 65.5 M69.25 63 L69.25 65.5 M31 84 L80 84 C80.5523 84 81 84.4477 81 85 L81 88 C81 88.5523 80.5523 89 80 89 L31 89 C30.4477 89 30 88.5523 30 88 L30 85 C30 84.4477 30.4477 84 31 84",viewW:110,viewH:110}},{id:"sink",group:"sanitary",art:{d:"M51 41.5 L58.5 41.5 M51 41.5 C50.4477 41.5 50 41.9477 50 42.5 L50 48 M51 41.5 L55 41.5 M58.5 41.5 C59.0523 41.5 59.5 41.9477 59.5 42.5 L59.5 48 M58.5 41.5 L55 41.5 M59.5 48 L77 48 C78.3807 48 79.5 49.1193 79.5 50.5 L79.5 57 C79.5 62.5228 75.0228 67 69.5 67 L40 67 C34.4772 67 30 62.5228 30 57 L30 50.5 C30 49.1193 31.1193 48 32.5 48 L50 48 M59.5 48 L50 48 M45 37 L45 35 C45 33.6739 45.5268 32.4021 46.4645 31.4645 C47.4021 30.5268 48.6739 30 50 30 C51.3261 30 52.5979 30.5268 53.5355 31.4645 C54.4732 32.4021 55 33.6739 55 35 L55 41.5 M45 80 L64.5 80 C65.0523 80 65.5 79.5523 65.5 79 L65.5 67 L44 67 L44 79 C44 79.5523 44.4477 80 45 80 Z",viewW:110,viewH:110}},{id:"sofa",group:"furniture",art:{d:"M88.5 44.6689 L88.5 34 C88.5 31.2386 86.2614 29 83.5 29 L59.5 29 C56.7386 29 54.5 31.2386 54.5 34 M88.5 44.6689 C89.2354 44.2435 90.0893 44 91 44 M88.5 44.6689 C88.3992 44.7272 88.3006 44.7889 88.2045 44.8539 M54.5 61.75 L54.5 34 M54.5 61.75 C54.5 64.3734 52.3734 66.5 49.75 66.5 L25.25 66.5 C22.6266 66.5 20.5 64.3734 20.5 61.75 M54.5 61.75 C54.5 59.1266 52.3734 57 49.75 57 L25.25 57 C24.6761 57 24.1261 57.1018 23.6168 57.2882 M54.5 61.75 C54.5 64.3734 56.6266 66.5 59.25 66.5 L83.75 66.5 C86.3734 66.5 88.5 64.3734 88.5 61.75 M88.5 61.75 C88.5 59.9118 87.4558 58.3175 85.9283 57.5278 C85.8889 57.5075 85.8493 57.4877 85.8093 57.4684 C85.1863 57.1682 84.4878 57 83.75 57 L59.25 57 C56.6266 57 54.5 59.1266 54.5 61.75 M54.5 34 C54.5 31.2386 52.2614 29 49.5 29 L25.5 29 C22.7386 29 20.5 31.2386 20.5 34 L20.5 44.416 M20.5 44.416 C19.8875 44.1484 19.2111 44 18.5 44 M20.5 44.416 C22.2659 45.1876 23.5 46.9497 23.5 49 M18.5 44 C21.2614 44 23.5 46.2386 23.5 49 M18.5 44 L18 44 C15.2386 44 13 46.2386 13 49 L13 70.5 C13 73.2614 15.2386 75.5 18 75.5 M23.5 49 L23.5 57.3328 M23.5 57.3328 C21.7427 58.0295 20.5 59.7446 20.5 61.75 M23.5 57.3328 C23.5387 57.3174 23.5776 57.3026 23.6168 57.2882 M91 44 C89.9645 44 89.0025 44.3148 88.2045 44.8539 C86.8744 45.7525 86 47.2741 86 49 L86 57.5657 M85.9283 57.5278 C85.9523 57.5402 85.9762 57.5528 86 57.5657 C87.4884 58.3677 88.5 59.9407 88.5 61.75 M91 44 L91.5 44 C94.2614 44 96.5 46.2386 96.5 49 L96.5 70.5 C96.5 73.2614 94.2614 75.5 91.5 75.5 M91.5 75.5 L18 75.5 M91.5 75.5 L90.5 75.5 M18 75.5 L18.5 75.5 M20.5 61.75 C20.5 59.7005 21.798 57.9542 23.6168 57.2882 M18.5 75.5 L26.5 75.5 M18.5 75.5 L18.5 80.5 C18.5 81.3284 19.1716 82 20 82 L23.3921 82 C24.0506 82 24.6321 81.5705 24.8258 80.9411 L26.5 75.5 M26.5 75.5 L82.5 75.5 M90.5 75.5 L82.5 75.5 M90.5 75.5 L90.5 80.5 C90.5 81.3284 89.8284 82 89 82 L85.6079 82 C84.9494 82 84.3679 81.5705 84.1742 80.9411 L82.5 75.5",viewW:110,viewH:110}},{id:"stairs",group:"other",art:{d:"M73.4707 46.8057 L73.4707 28.5242 M73.4707 46.8057 L73.1504 46.8057 M73.4707 46.8057 L82.6039 46.8057 M73.4707 28.5242 L73.425 28.5242 M73.4707 28.5242 L75.6731 28.5242 M62.8987 54.2946 L62.8987 36.7397 M61.5762 61.7837 L61.5762 55.2944 C61.5762 54.7421 62.0239 54.2944 62.5762 54.2944 L62.8987 54.2946 L72.1504 54.2945 M52.3262 61.7837 L52.3262 45.1306 M52.3262 61.7837 L52.0039 61.7837 M52.3262 61.7837 L61.5762 61.7837 M62.8987 36.7397 L52.3262 45.1306 L42.1934 53.1725 L31.6211 61.5632 M42.1934 69.2725 L42.1934 53.1725 M42.1934 69.2725 L41.873 69.2725 M83.6035 69.2725 L83.6024 69.2725 L51.0039 69.2725 L42.1934 69.2725 M83.6031 76.7612 L83.6031 83.25 C83.6031 83.8023 83.1554 84.25 82.6031 84.25 L31.6231 84.2499 M41.873 69.2725 L83.6035 69.2725 L83.6031 76.7612 M83.6031 76.7612 L31.6231 76.7612 M31.6231 76.7612 L40.873 76.7613 L83.6031 76.7612 M31.6231 84.2499 L27.7773 84.2499 C27.2251 84.2499 26.7773 83.8021 26.7773 83.2499 L26.7773 57.4971 C26.7773 56.9448 27.2251 56.4971 27.7773 56.4971 L28.9352 56.4971 M31.6231 84.2499 L31.6231 76.7612 M31.6231 76.7612 L31.6211 61.5632 L31.6231 56.4971 M29.0212 56.4971 L31.6231 56.4971 L31.6228 57.2227 M31.6211 61.5632 L62.8987 36.7397 M31.6211 61.5632 L31.6228 57.2227 M73.425 28.5242 L75.6731 28.5242 M73.425 28.5242 C73.3119 28.5242 73.202 28.5624 73.1134 28.6328 L62.8987 36.7397 M75.6731 28.5242 C76.6463 28.5242 77.4352 27.7353 77.4352 26.7621 C77.4352 25.7889 76.6463 25 75.6731 25 L71.9495 25 C71.7935 25 71.6421 25.0532 71.5204 25.1508 L31.6228 57.2227 M41.873 69.2725 C41.3208 69.2725 40.873 69.7202 40.873 70.2725 L40.873 76.7613 M52.0039 61.7837 L83.6024 61.7837 M52.0039 61.7837 C51.4516 61.7837 51.0039 62.2314 51.0039 62.7837 L51.0039 69.2725 M83.6022 54.2944 L83.6024 61.7837 L83.6024 69.2725 M83.6024 61.7837 L61.5762 61.7837 M83.6022 54.2944 L83.6039 47.8057 C83.6039 47.2534 83.1562 46.8057 82.6039 46.8057 M83.6022 54.2944 L72.1504 54.2945 M73.1504 46.8057 L82.6039 46.8057 M73.1504 46.8057 C72.5981 46.8057 72.1504 47.2534 72.1504 47.8057 L72.1504 54.2945 M28.9352 56.4971 C28.9495 56.4973 28.9638 56.4974 28.9782 56.4974 C28.9925 56.4974 29.0069 56.4973 29.0212 56.4971 M28.9352 56.4971 C27.2519 56.4741 25.8945 55.1024 25.8945 53.4137 C25.8945 51.7107 27.2751 50.3301 28.9782 50.3301 C30.6812 50.3301 32.0618 51.7107 32.0618 53.4137 C32.0618 55.1024 30.7044 56.4741 29.0212 56.4971 M28.9352 56.4971 L29.0212 56.4971",viewW:110,viewH:110}},{id:"toilet",group:"sanitary",art:{d:"M64.5372 72.1021 L67.6892 84.7575 C67.847 85.3886 67.3696 86 66.7191 86 L37.6483 86 C37.0414 86 36.5743 85.4636 36.6578 84.8624 L38.9999 68 C40.0716 64 32.5 64.5 32 57 L32 26.5 C32 25.1193 33.1193 24 34.5 24 L45 24 C46.3807 24 47.5 25.1193 47.5 26.5 L47.5 52 M32 57 L47.5 57 M47.5 52 L76.5 52 C77.8807 52 79 53.1193 79 54.5 L79 57 M47.5 52 L47.5 57 M54.9999 71.75 C58.5528 72.6096 61.7379 72.6416 64.5372 72.1021 C73.95 70.2877 79 62.0101 79 57 M79 57 L47.5 57",viewW:110,viewH:110}},{id:"tv",group:"appliance",art:{d:"M23.5 31 L86 31 C87.3807 31 88.5 32.1193 88.5 33.5 L88.5 67.5 C88.5 68.8807 87.3807 70 86 70 L23.5 70 C22.1193 70 21 68.8807 21 67.5 L21 33.5 C21 32.1193 22.1193 31 23.5 31 M50 70 L50 78 M59.5 70 L59.5 78 M40 78 L70 78 M42.5466 45.9951 L52.5466 45.9951 M47.5466 45.9951 L47.5 56.0336 M56.75 45.5 L61.75 55.5 L66.75 45.5",viewW:110,viewH:110}},{id:"wardrobe",group:"furniture",art:{d:"M54.5 20.5 L30.5 20.5 C29.1193 20.5 28 21.6193 28 23 L28 82.5 C28 83.8807 29.1193 85 30.5 85 L54.5 85 M54.5 20.5 L54.5 85 M54.5 20.5 L78.5 20.5 C79.8807 20.5 81 21.6193 81 23 L81 82.5 C81 83.8807 79.8807 85 78.5 85 L54.5 85 M79 84.95 L79 88.5 C79 89.0523 78.5523 89.5 78 89.5 L31 89.5 C30.4477 89.5 30 89.0523 30 88.5 L30 84.95 M50.5 48 L50.5 57.5 M58.5 48 L58.5 57.5",viewW:110,viewH:110}},{id:"washer",group:"appliance",art:{d:"M81 40 C81 38.6193 79.8807 37.5 78.5 37.5 L31.5 37.5 C30.1193 37.5 29 38.6193 29 40 M35.75 31 L45.25 31 M31.5 85 L78.5 85 C79.8807 85 81 83.8807 81 82.5 L81 55.5 L81 27.5 C81 26.1193 79.8807 25 78.5 25 L31.5 25 C30.1193 25 29 26.1193 29 27.5 L29 56 L29 82.5 C29 83.8807 30.1193 85 31.5 85 Z M72 60.5 C72 69.8888 64.3888 77.5 55 77.5 C45.6112 77.5 38 69.8888 38 60.5 C38 51.1112 45.6112 43.5 55 43.5 C64.3888 43.5 72 51.1112 72 60.5 Z M66.5 60.5 C66.5 66.8513 61.3513 72 55 72 C48.6487 72 43.5 66.8513 43.5 60.5 C43.5 54.1487 48.6487 49 55 49 C61.3513 49 66.5 54.1487 66.5 60.5 Z M69.5 31 C69.5 32.1046 68.6046 33 67.5 33 C66.3954 33 65.5 32.1046 65.5 31 C65.5 29.8954 66.3954 29 67.5 29 C68.6046 29 69.5 29.8954 69.5 31 Z M77 31 C77 32.1046 76.1046 33 75 33 C73.8954 33 73 32.1046 73 31 C73 29.8954 73.8954 29 75 29 C76.1046 29 77 29.8954 77 31 Z",viewW:110,viewH:110}},{id:"work_table",group:"furniture",art:{d:"M68.5 61 L68.5 73.5 C68.5 74.3284 69.1716 75 70 75 L87 75 C87.8284 75 88.5 74.3284 88.5 73.5 L88.5 61 L88.4844 47 M26.4844 47 L26.4844 73.5 C26.4844 74.3284 25.8128 75 24.9844 75 L23.9844 75 C23.1559 75 22.4844 74.3284 22.4844 73.5 L22.4844 47 L22.4844 43 L24.866 35.5974 C25.2388 34.6346 26.165 34 27.1974 34 L83.7743 34 C84.8054 34 85.7307 34.633 86.1044 35.5939 L88.4844 43 L88.4844 47 M88.4844 47 L68.5 47 M68.5 47 L68.5 61 M68.5 47 L26.4844 47 M68.5 61 L88.5 61 M76.5 51 L80.5 51 M88.4844 43 L22.4844 43 M22.4844 47 L26.4844 47 M76.5 65 L80.5 65",viewW:110,viewH:110}}];class Qc{constructor(t,e){this.host=t,this.hooks=e}place(t,e="mouse"){const s=this.host._decorImagePalette,i=this.host._curSpaceCfg;if(!s||!i)return;const o=this.hooks.decorSnap(t,e),a=$e(s.width,s.height),n=we(a.w,this.host._cellCm,this.host._gridPitch)/lt,r=we(a.h,this.host._cellCm,this.host._gridPitch)/this.host._decorH,l="di"+Date.now().toString(36)+Math.random().toString(36).slice(2,5),h=this.hooks.geometrySnapshot();i.decor=[...this.host._decorList,{id:l,kind:"image",asset_id:s.asset_id,x:le(o[0]/lt-n/2),y:le(o[1]/this.host._decorH-r/2),w:n,h:r,opacity:1}],this.host._decorSel=l,this.host._decorTool="select",this.host._decorImagePalette=null,this.hooks.clearFurniturePreview(),this.hooks.recordGeometry(this.host._t("history.decor_add"),h),this.hooks.saveConfig(),this.host.requestUpdate()}renderPlacementPreview(){const t=this.host._furnPreviewInput,e=this.host._decorImagePalette;if(!t||!e||"decor"!==this.host._mode||"image"!==this.host._decorTool||!this.host._pointerModality.hoverEnabled)return d;const s=this.hooks.decorSnap(t.raw,"mouse"),i=$e(e.width,e.height),o=we(i.w,this.host._cellCm,this.host._gridPitch)/lt,a=we(i.h,this.host._cellCm,this.host._gridPitch)/this.host._decorH,n=this.host._display(e.url);return n?At``:d}renderMissing(t,e,s,i,o,a,n,r,l){const h=i+a/2,c=o+n/2;return At`${this.host._t(t?"decor.image_place_hint":"decor.image_pick_hint")}
    - `}renderFurniturePalette(){const t=this.host._furnPalette,e=this.host._furnCategory,s=xe.flatMap(t=>Me(t)),i=Yc.filter(t=>s.some(e=>e.category===t.id)),o=i.find(t=>t.id===e)||null,a=o?s.filter(t=>t.category===o.id):[],n=this.host._t(this.host._imperial?"gs.unit_ft":"gs.unit_m");return p`
    t.stopPropagation()}> +
    `}renderFurniturePalette(){const t=this.host._furnPalette,e=this.host._furnCategory,s=xe.flatMap(t=>Me(t)),i=Xc.filter(t=>s.some(e=>e.category===t.id)),o=i.find(t=>t.id===e)||null,a=o?s.filter(t=>t.category===o.id):[],n=this.host._t(this.host._imperial?"gs.unit_ft":"gs.unit_m");return p`
    t.stopPropagation()}>
    ${this.host._t("furn.title")} @@ -1524,7 +1511,7 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db this.host._decorTextDialog={...t,sizeCm:this.host._decorTextCm(Number(e.target.value))}} /> ${this.host._t(this.host._imperial?"wallthick.unit_in":"wallthick.unit_cm")}
    @@ -1816,7 +1803,7 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db
    - `}_cssPxToRender(t){const e=this.host._stageEl,s=this.host._viewOr(this.host._baseVb());return e?.clientWidth&&e.clientHeight?Math.max(s.w/e.clientWidth,s.h/e.clientHeight)*t:this.host._gridPitch/8*t}_deleteRoomClick(t){const e=this.host._spaceModel();if(!e)return;const s=[...e.rooms].reverse().find(e=>this._pointInRoom(t,e));s?s.id&&(this.host._roomDeleteDialog={roomId:s.id,name:s.name}):this.host._showToast(this.host._t("toast.delete_room_pick"))}_wallThickHit(t){const e=this.host._spaceModel();if(!e)return null;const s=6*this.host._gridPitch,i=this.host._openCuts();let o=null;const a=(t,e,i)=>{e>s||(!o||e100)return void this._showPhysicalRange(100);if("room"!==e.source.kind){const t=this._geometrySnapshot(),i=(s.partitions||[]).find(t=>t.id===e.source.id);if(!i)return;if(0===n&&Fe(s.openings,{kind:"partition",id:i.id}))return void this.host._showToast(this.host._t("toast.zero_wall_opening_conflict"));i.cm=n,this.host._wallDialog=null;return this._commitPhysicalGeometry(this.host._t("history.wall_thickness"),t)&&this.host._showToast(this.host._t("toast.wallthick_set")),void this.host.requestUpdate()}const r=this._geometrySnapshot(),l=n>0?n:null;if(0===n){const i=.02*this.host._gridPitch,o=[e.a[0],e.a[1],e.b[0],e.b[1]],a=(s.rooms||[]).find(t=>t.id===e.roomId),n=new Set(t&&a&&Array.isArray(a.wall_ids)?a.wall_ids:(s.wall_segments||[]).filter(t=>{const e=[Number(t.a?.[0])*wd,Number(t.a?.[1])*wd],s=[Number(t.b?.[0])*wd,Number(t.b?.[1])*wd];return ye(e,o)<=i&&ye(s,o)<=i}).map(t=>String(t.id))),r=(s.openings||[]).some(t=>{if("partition"===t.host?.kind)return!1;if("wall"===t.host?.kind&&n.has(t.host.id))return!0;if(t.host)return!1;const e=[Number(t.x)*wd,Number(t.y)*wd];return e.every(Number.isFinite)&&ye(e,o)<=i});if(r)return void this.host._showToast(this.host._t("toast.zero_wall_opening_conflict"))}let h,c=this.host._openCuts();if(n>0&&c.length){const o=[];if(t&&e.roomId){const t=(s.rooms||[]).find(t=>t.id===e.roomId),a=new Set(Array.isArray(t?.wall_ids)?t.wall_ids:[]);for(const t of s.wall_segments||[])a.has(t.id)&&o.push([Number(t.a?.[0])*wd,Number(t.a?.[1])*wd,Number(t.b?.[0])*wd,Number(t.b?.[1])*wd]);if(!o.length){const t=i.rooms.find(t=>t.id===e.roomId),s=t?N(t):null;for(let t=0;s&&t!o.some(e=>ye([t[0],t[1]],e)<=a&&ye([t[2],t[3]],e)<=a&&ye([e[0],e[1]],t)<=a&&ye([e[2],e[3]],t)<=a))}h=t&&e.roomId?Os(s.walls,i.rooms,e.roomId,l,this.host._wallKeyPitch,c,wd):j(s.walls,e.a,e.b,l,this.host._wallKeyPitch,wd),h=this.host._normalizeWalls(h,c);for(const t of s.wall_segments||[])t.cm=it(h,t.a,t.b,z,1);h.length?s.walls=h:delete s.walls,this.host._wallDialog=null,this._commitPhysicalGeometry(this.host._t("history.wall_thickness"),r)&&this.host._showToast(this.host._t(0===n?"toast.wallthick_cleared":"toast.wallthick_set")),this.host.requestUpdate()}_wallHatchDefs(t){if(!this.host._spaceWalls.length&&!this.host._physicalBodiesR().length&&!this.host._markup)return At``;const e=Bt(this.host._cellCm);return At` + `}_cssPxToRender(t){const e=this.host._stageEl,s=this.host._viewOr(this.host._baseVb());return e?.clientWidth&&e.clientHeight?Math.max(s.w/e.clientWidth,s.h/e.clientHeight)*t:this.host._gridPitch/8*t}_deleteRoomClick(t){const e=this.host._spaceModel();if(!e)return;const s=[...e.rooms].reverse().find(e=>this._pointInRoom(t,e));s?s.id&&(this.host._roomDeleteDialog={roomId:s.id,name:s.name}):this.host._showToast(this.host._t("toast.delete_room_pick"))}_wallThickHit(t){const e=this.host._spaceModel();if(!e)return null;const s=6*this.host._gridPitch,i=this.host._openCuts();let o=null;const a=(t,e,i)=>{e>s||(!o||e100)return void this._showPhysicalRange(100);if("room"!==e.source.kind){const t=this._geometrySnapshot(),i=(s.partitions||[]).find(t=>t.id===e.source.id);if(!i)return;if(0===n&&Fe(s.openings,{kind:"partition",id:i.id}))return void this.host._showToast(this.host._t("toast.zero_wall_opening_conflict"));i.cm=n,this.host._wallDialog=null;return this._commitPhysicalGeometry(this.host._t("history.wall_thickness"),t)&&this.host._showToast(this.host._t("toast.wallthick_set")),void this.host.requestUpdate()}const r=this._geometrySnapshot(),l=n>0?n:null;if(0===n){const i=.02*this.host._gridPitch,o=[e.a[0],e.a[1],e.b[0],e.b[1]],a=(s.rooms||[]).find(t=>t.id===e.roomId),n=new Set(t&&a&&Array.isArray(a.wall_ids)?a.wall_ids:(s.wall_segments||[]).filter(t=>{const e=[Number(t.a?.[0])*kd,Number(t.a?.[1])*kd],s=[Number(t.b?.[0])*kd,Number(t.b?.[1])*kd];return ye(e,o)<=i&&ye(s,o)<=i}).map(t=>String(t.id))),r=(s.openings||[]).some(t=>{if("partition"===t.host?.kind)return!1;if("wall"===t.host?.kind&&n.has(t.host.id))return!0;if(t.host)return!1;const e=[Number(t.x)*kd,Number(t.y)*kd];return e.every(Number.isFinite)&&ye(e,o)<=i});if(r)return void this.host._showToast(this.host._t("toast.zero_wall_opening_conflict"))}let h,c=this.host._openCuts();if(n>0&&c.length){const o=[];if(t&&e.roomId){const t=(s.rooms||[]).find(t=>t.id===e.roomId),a=new Set(Array.isArray(t?.wall_ids)?t.wall_ids:[]);for(const t of s.wall_segments||[])a.has(t.id)&&o.push([Number(t.a?.[0])*kd,Number(t.a?.[1])*kd,Number(t.b?.[0])*kd,Number(t.b?.[1])*kd]);if(!o.length){const t=i.rooms.find(t=>t.id===e.roomId),s=t?N(t):null;for(let t=0;s&&t!o.some(e=>ye([t[0],t[1]],e)<=a&&ye([t[2],t[3]],e)<=a&&ye([e[0],e[1]],t)<=a&&ye([e[2],e[3]],t)<=a))}h=t&&e.roomId?Os(s.walls,i.rooms,e.roomId,l,this.host._wallKeyPitch,c,kd):j(s.walls,e.a,e.b,l,this.host._wallKeyPitch,kd),h=this.host._normalizeWalls(h,c);for(const t of s.wall_segments||[])t.cm=it(h,t.a,t.b,z,1);h.length?s.walls=h:delete s.walls,this.host._wallDialog=null,this._commitPhysicalGeometry(this.host._t("history.wall_thickness"),r)&&this.host._showToast(this.host._t(0===n?"toast.wallthick_cleared":"toast.wallthick_set")),this.host.requestUpdate()}_wallHatchDefs(t){if(!this.host._spaceWalls.length&&!this.host._physicalBodiesR().length&&!this.host._markup)return At``;const e=Bt(this.host._cellCm);return At` @@ -1841,7 +1828,7 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db - `:p``}_openingAt(t){if(!this.host._openingsR.length)return null;const e=this.host._openingsR.flatMap(e=>{const s=e.angle*Math.PI/180,i=t[0]-e.rx,o=t[1]-e.ry,a=i*Math.cos(s)+o*Math.sin(s);return Math.abs(a)>e.rlen/2+Wt(12,this.host._cellCm)?[]:[{o:e,localY:-i*Math.sin(s)+o*Math.cos(s)}]});if(!e.length)return null;const s=this.host._spaceModel();if(!s)return null;const i=this.host._openCuts(),o=this.host._openingWallIndexFor(s,i).value;return e.find(({o:t,localY:e})=>{const s="gate"===t.type?!t.flip_v:t.flip_v,i=t.partitionHost||this.host._spaceWalls.length||"gate"===t.type?this.host._openingFace(t,o,!!s):{ox:0,oy:0,cm:0,side:-1},a=Hs({type:t.type,length:t.rlen,angle:t.angle,amount:this.host._openingAmt(t),flipH:!!t.flip_h,flipV:!!t.flip_v,cellCm:this.host._cellCm,gridPitch:this.host._gridPitch,face:i});return Math.abs(e)<=a.hitHalf})?.o||null}_resolveOpeningPlacement(t){const e=this.host._openingPreset;if("opening"!==this.host._tool||!e)return null;const s=this.host._spaceModel();if(!s)return null;const i=this.host._openCuts(),o=this.host._openingWallIndexFor(s,i),a=`${o.key}|partitions:${this.host._cfgEpoch}`;this.host._openingPlacementIntervalsCache&&this.host._openingPlacementIntervalsCache.key===a||(this.host._openingPlacementIntervalsCache={key:a,value:[...O(s.rooms,this.host._spaceWalls,i,this.host._wallKeyPitch,this.host._cellCm,this.host._gridPitch,wd),...Bs(s.partitions,this.host._cellCm,this.host._gridPitch)]}),this.host._openingDimensionContextCache&&this.host._openingDimensionContextCache.key===a||(this.host._openingDimensionContextCache={key:a,value:nd({rooms:s.rooms,walls:this.host._spaceWalls,openCuts:i,partitions:s.partitions,roomOpenings:this.host._roomWallOpeningInputs(),partitionCuts:this._partitionOpeningCuts(s),pitch:this.host._wallKeyPitch,cellCm:this.host._cellCm,gridPitch:this.host._gridPitch,coordScale:wd,epsilon:2e-4*this.host._gridPitch})});const n=Ws({pointer:[t[0],t[1]],preset:e,geometryRevision:this.host._cfgEpoch,renderedLength:this.host._cmToUnits(e.lengthCm),intervals:this.host._openingPlacementIntervalsCache.value,baseTolerance:1.5*this.host._gridPitch,bodyPointerPadding:this._cssPxToRender("touch"===this.host._pointerModality.modality||"pen"===this.host._pointerModality.modality?10:6),gridStep:this.host._gridPitch});this.host._openingJambBlockCm=n.jambBlockedTarget?n.jambBlockedTarget.physicalHalfWidth/this.host._gridPitch*this.host._cellCm:null;const r=n.candidate;if(!r)return null;const l="gate"===r.type?!r.flipV:r.flipV;let h;if(r.host){const t=A({id:"preview",type:r.type,x:r.x/wd,y:r.y/wd,angle:r.angle,length:r.renderedLength/wd,host:r.host},s.partitions,wd,this.host._cellCm,this.host._gridPitch).resolved;h=t?js(t,l):{ox:0,oy:0,cm:0,side:-1}}else h=Gs(o.value,{x:r.x,y:r.y,angle:r.angle,length:r.renderedLength,flip_v:l});const c="mi"===this.host.hass?.config?.unit_system?.length,d=ud(r,this.host._openingDimensionContextCache.value).map(t=>({x:t.label[0],y:t.label[1],text:fe(t.distance/this.host._gridPitch*this.host._cellCm,c),dimension:t}));return{...r,face:h,measure:{labels:d,guide:r.measure.guide}}}_activateOpeningPlacement(t){this._activateMarkupTool("opening"),"opening"===this.host._tool&&(this.host._openingPreset=qs(t,++this.host._openingPresetRevision),this.host._openingHoverCandidate=null,this.host._cursorPt=null)}_clearOpeningPlacement(t){this.host._openingHoverCandidate=null,this.host._openingJambBlockCm=null,t&&(this.host._openingPreset=null,this.host._openingRebindId=null)}_openingClick(t){const e=this.host._spaceModel();if(!e)return;const s=this.host._openingRebindId?null:this._openingAt(t);if(s)return void this._editOpening(s);const i=this.host._openingPreset;if(!i)return;const o=this.host._openingHoverCandidate,a=o&&Us(o,[t[0],t[1]],i.revision,this.host._cfgEpoch)?o:this._resolveOpeningPlacement(t);if(!a){if(null!=this.host._openingJambBlockCm)return void this.host._showToast(this.host._t("opening.partition_jamb_margin",{distance:fe(this.host._openingJambBlockCm,this.host._imperial)}));const s=1.5*this.host._gridPitch,i=R(t,e.rooms,s);return i&&Ks(i.x,i.y,i.angle,this.host._openCuts(),s)?void this.host._showToast(this.host._t("toast.opening_on_zero_wall")):void this.host._showToast(this.host._t("toast.opening_no_wall"))}const n=this.host._openingRebindId?this.host._curSpaceCfg?.openings?.find(t=>t.id===this.host._openingRebindId):null;this.host._openingDialog={...n?{id:n.id,type:n.type,lengthCm:Math.round(n.length*wd/this.host._gridPitch*this.host._cellCm),lengthTouched:!1,contact:n.contact||"",lock:n.lock||"",invert:!!n.invert,flipH:!!n.flip_h,flipV:!!n.flip_v}:{type:a.type,lengthCm:a.lengthCm,contact:"",lock:"",invert:!1,flipH:a.flipH,flipV:a.flipV},...a.host?{host:a.host}:{},x:a.x,y:a.y,angle:a.angle},this.host._openingRebindId=null,this.host._openingHoverCandidate=null,this.host._cursorPt=null}_editOpening(t){this.host._openingDialog={id:t.id,type:t.type,lengthCm:Math.round(t.rlen/this.host._gridPitch*this.host._cellCm),lengthTouched:!1,contact:t.contact||"",lock:t.lock||"",invert:!!t.invert,flipH:!!t.flip_h,flipV:!!t.flip_v,..."partition"===t.host?.kind?{host:{...t.host}}:{},x:t.rx,y:t.ry,angle:t.angle}}_opPointerDown(t,e){if("plan"===this.host._mode&&this.host._spaceModel()&&"resize"!==this.host._tool){t.preventDefault(),t.stopPropagation();try{xd(t)}catch{}this.host._opDrag={id:e.id,moved:!1,sx:t.clientX,sy:t.clientY,dirty:!1,before:this._geometrySnapshot()}}}_opPointerMove(t,e){lr(this.host,"opening",()=>this._opPointerMoveNow(t,e))}_opPointerMoveNow(t,e){if(!this.host._opDrag||this.host._opDrag.id!==e.id)return;if(Math.abs(t.clientX-this.host._opDrag.sx)+Math.abs(t.clientY-this.host._opDrag.sy)<=3)return;const s=this.host._spaceModel();if(!s)return;const i=this._svgPoint(t),o=this.host._curSpaceCfg,a=o?.openings?.find(t=>t.id===e.id);if(!a)return;if("partition"===a.host?.kind){const t=s.partitions.find(t=>t.id===a.host.id);if(!t)return;const e=t.b[0]-t.a[0],o=t.b[1]-t.a[1],n=Math.hypot(e,o);if(!(n>1e-9))return;const r=e/n,l=o/n;if(Math.abs((i[0]-t.a[0])*l-(i[1]-t.a[1])*r)>4*this.host._gridPitch)return;const h=a.length*wd/2+W(t,this.host._cellCm,this.host._gridPitch);let c=(i[0]-t.a[0])*r+(i[1]-t.a[1])*l;if(c=Math.round(c/this.host._gridPitch)*this.host._gridPitch,c=Math.max(h,Math.min(n-h,c)),n<2*h-1e-9)return;const d=c/n,p=(t.a[0]+r*c)/wd,u=(t.a[1]+l*c)/this.host._spaceH;let _=180*Math.atan2(o,e)/Math.PI;_>=90?_-=180:_<-90&&(_+=180);const g=a.host.t!==d||a.x!==p||a.y!==u||a.angle!==_;return this.host._opDrag.moved=!0,g&&(this.host._opDrag.dirty=!0),a.host={...a.host,t:d},a.x=p,a.y=u,a.angle=_,this.host._opMeasure=null,g&&this.host._cfgEpoch++,void this.host.requestUpdate()}const n=R(i,s.rooms,4*this.host._gridPitch);if(!n)return;this.host._opDrag.moved=!0;const r=this._opRuler(n,a.length*wd);this.host._opMeasure=r.measure;const l=r.x/wd,h=r.y/this.host._spaceH,c=a.x!==l||a.y!==h||a.angle!==n.angle;if(c&&(this.host._opDrag.dirty=!0),a.x=l,a.y=h,a.angle=n.angle,Number(this.host._serverCfg?.model_version||0)>=9){const t=yn(a,o?.wall_segments||[]);t?a.host=t:delete a.host}c&&this.host._cfgEpoch++,this.host.requestUpdate()}_opRuler(t,e){const s=this.host._spaceModel()?.rooms||[],i=this.host._gridPitch/2;let o=t.x,a=t.y,n=Vs([o,a],t.angle,e,s,i);if(n&&n.centered&&(o!==n.wallCenter[0]||a!==n.wallCenter[1]))[o,a]=n.wallCenter,n=Vs([o,a],t.angle,e,s,i);else if(n){const[r,l]=n.wallA,[h,c]=n.wallB,d=h-r,p=c-l,u=Math.hypot(d,p);if(u>0){const h=this.host._gridPitch,c=Math.min(e/2,u/2);let _=Math.round(((o-r)*d+(a-l)*p)/u/h)*h;_=Math.max(c,Math.min(u-c,_)),o=r+_/u*d,a=l+_/u*p,n=Vs([o,a],t.angle,e,s,i)||n}}if(!n)return{x:o,y:a,angle:t.angle,measure:null};const r="mi"===this.host.hass?.config?.unit_system?.length,l=(t,e)=>({x:e[0],y:e[1],text:fe(t/this.host._gridPitch*this.host._cellCm,r)});return{x:o,y:a,angle:t.angle,measure:{labels:[l(n.sideA,n.midA),l(n.sideB,n.midB)],guide:n.centered?{x:n.wallCenter[0],y:n.wallCenter[1],angle:t.angle}:null}}}_opPointerUp(t,e){if(!this.host._opDrag||this.host._opDrag.id!==e.id)return;hr(this.host,"opening");const s=this.host._opDrag,i=s.moved;this.host._opMeasure=null,i&&s.dirty&&this._commitPhysicalGeometry(this.host._t("history.move_opening"),s.before);const o=()=>{this.host._opDrag=null,this.host.requestUpdate()};i?window.setTimeout(o,0):o()}_opClick(t,e){"plan"===this.host._mode&&"resize"===this.host._tool||(t.stopPropagation(),this.host._opDrag?.moved||"plan"===this.host._mode&&this._editOpening(e))}_saveOpening(){const t=this.host._openingDialog,e=this.host._curSpaceCfg,s=this.host._spaceModel();if(!t||!e||!s)return;const i=this._geometrySnapshot(),o=this.host._spaceH,a=(e.openings||[]).find(e=>e.id===t.id),n={...a||{},id:t.id||"o"+Date.now().toString(36),type:t.type,x:t.x/wd,y:t.y/o,angle:t.angle,length:a&&!t.lengthTouched?a.length:this.host._cmToUnits(Math.max(20,t.lengthCm))/wd,...t.host?{host:{...t.host}}:{}};if("partition"===n.host?.kind){const t=Js(a,n)?q(n,s.partitions,wd,this.host._cellCm,this.host._gridPitch):A(n,s.partitions,wd,this.host._cellCm,this.host._gridPitch);if(!t.resolved){const e=s.partitions.find(t=>t.id===n.host.id);if("does-not-fit-jamb"===t.reason&&e){const t=W(e,this.host._cellCm,this.host._gridPitch);this.host._showToast(this.host._t("opening.partition_jamb_margin",{distance:fe(t/this.host._gridPitch*this.host._cellCm,this.host._imperial)}))}else this.host._showToast(this.host._t("opening.partition_orphan"));return}const i=(e.openings||[]).flatMap(t=>{if(!t.host||t.id===n.id)return[];const e=A(t,s.partitions,wd,this.host._cellCm,this.host._gridPitch).resolved;return e?[e]:[]});if(Zs(t.resolved,i))return void this.host._showToast(this.host._t("toast.opening_no_wall"));Object.assign(n,E(n,t.resolved,wd))}else if(Number(this.host._serverCfg?.model_version||0)>=9){const t=yn(n,e.wall_segments||[]);if(!t)return void this.host._showToast(this.host._t("toast.opening_no_wall"));n.host=t}else delete n.host;"passage"===t.type?(delete n.contact,delete n.lock,delete n.invert,delete n.flip_h,delete n.flip_v):(n.contact=t.contact||null,n.lock=("door"===t.type||"gate"===t.type)&&t.lock||null,n.invert=t.invert||void 0,n.flip_h="gate"!==t.type&&t.flipH||void 0,n.flip_v=t.flipV||void 0),e.openings=e.openings||[];const r=e.openings.findIndex(t=>t.id===n.id);r>=0?e.openings[r]=n:e.openings.push(n),this._commitPhysicalGeometry(this.host._t(t.id?"history.edit_opening":"history.add_opening"),i),this.host._openingDialog=null,this.host.requestUpdate()}_deleteOpening(){const t=this.host._openingDialog,e=this.host._curSpaceCfg;if(!t?.id||!e?.openings)return;const s=this._geometrySnapshot();e.openings=e.openings.filter(e=>e.id!==t.id),this._commitPhysicalGeometry(this.host._t("history.delete_opening"),s),this.host._openingDialog=null,this.host.requestUpdate()}_contactCandidates(){const t=[];for(const e of Object.keys(this.host.hass.states)){if(!this.host._openingEntityAvailable(e))continue;const s=e.split(".")[0];if("binary_sensor"!==s&&"cover"!==s)continue;const i=this.host.hass.states[e],o=["door","window","opening","garage_door","garage"].includes(i?.attributes?.device_class||"");("cover"!==s||o)&&t.push([e,i?.attributes?.friendly_name||e,o?0:1])}return t.sort((t,e)=>t[2]-e[2]||t[1].localeCompare(e[1])).map(([t,e])=>({value:t,label:e}))}_lockCandidates(){return Object.keys(this.host.hass.states).filter(t=>t.startsWith("lock.")&&this.host._openingEntityAvailable(t)).map(t=>({value:t,label:this.host.hass.states[t]?.attributes?.friendly_name||t})).sort((t,e)=>t.label.localeCompare(e.label))}_toggleOpeningEntityPicker(t){const e=this.host._openingDialog;if(!e)return;const s="contact"===t?!e.contactOpen:!e.lockOpen;this.host._openingDialog={...e,contactOpen:"contact"===t&&s,lockOpen:"lock"===t&&s}}_filterOpeningEntities(t,e){const s=this.host._openingDialog;s&&(this.host._openingDialog="contact"===t?{...s,contactFilter:e}:{...s,lockFilter:e})}_selectOpeningEntity(t,e){const s=this.host._openingDialog;s&&(this.host._openingDialog="contact"===t?{...s,contact:e,contactOpen:!1,contactFilter:""}:{...s,lock:e,lockOpen:!1,lockFilter:""})}_mergeClick(t){const e=this.host._spaceModel();if(!e)return;const s=e.rooms,i=[...s].reverse().find(e=>this._pointInRoom(t,e));if(!i?.id)return;const o=i.id;if(!this.host._mergeSel||this.host._mergeSel===o)return void(this.host._mergeSel=this.host._mergeSel===o?null:o);const a=s.find(t=>t.id===this.host._mergeSel),n=a?N(a):null,r=N(i),l=n&&r?Ys(n,r):null;if(!l)return this.host._showToast(this.host._t("toast.merge_not_adjacent")),void(this.host._mergeSel=null);this.host._mergeDialog={aId:this.host._mergeSel,bId:o,poly:l,pick:"a"},this.host._mergeSel=null}_commitMerge(){const t=this.host._mergeDialog,e=this.host._curSpaceCfg;if(!t||!e||!this.host._spaceModel())return;const s=this._geometrySnapshot(),i=this.host._spaceH,o="a"===t.pick?t.aId:t.bId,a="a"===t.pick?t.bId:t.aId,n=bd(this.host._serverCfg?.markers||[],{kind:"merge",dropId:a,keepId:o});s&&n.changed&&(s.roomReferences=n.before);const r=e.rooms.find(t=>t.id===o);if(!r)return void(this.host._mergeDialog=null);r.poly=t.poly.map(t=>[t[0]/wd,t[1]/i]),delete r.x,delete r.y,delete r.w,delete r.h,e.rooms=e.rooms.filter(t=>t.id!==a),n.changed&&this.host._serverCfg&&(this.host._serverCfg.markers=n.markers);const l=this._commitPhysicalGeometry(this.host._t("history.merge_rooms"),s);this.host._mergeDialog=null,this.host._regSignature="",this.host._maybeRebuildDevices(),l&&this.host._showToast(this.host._t("toast.rooms_merged",{name:r.name||""}))}_splitClick(t){const e=this.host._spaceModel();if(!e)return;const s=e.rooms;if(!this.host._splitSel){const e=[...s].reverse().find(e=>this._pointInRoom(t,e));if(!e?.id)return;return void(this.host._splitSel={roomId:e.id,pts:[]})}const i=s.find(t=>t.id===this.host._splitSel.roomId),o=i?N(i):null;if(!i||!o)return void(this.host._splitSel=null);const a=.02*this.host._gridPitch,n=6*this.host._gridPitch,r=Xs(t,o),l=r&&Qs(r,o,this.host._gridPitch)||r,h=r&&l&&Math.hypot(r[0]-t[0],r[1]-t[1])<=n?l:null,c=!!h&&ti(h,o,a),d=this.host._splitSel.pts;if(!d.length)return c?void(this.host._splitSel={...this.host._splitSel,pts:[h]}):void this.host._showToast(this.host._t("toast.split_pick_wall"));if(!c){const e=this._snap(t);return es(e,o,a)?void(this.host._splitSel={...this.host._splitSel,pts:[...d,e]}):void this.host._showToast(this.host._t("toast.split_pick_inside"))}const p=is(o,[...d,h],a);if(!p)return void this.host._showToast(this.host._t("toast.split_bad_cut"));this._resetRoomDialogFields();const[u,_]=p,g=ae(u)>=ae(_)?u:_,m=g===u?_:u;this.host._pendingSplit={roomId:i.id,mainPoly:g,newPoly:m},this.host._cursorPt=null,this.host._nameSel="",this.host._areaSel="",this.host._roomDialog=!0}_markupMove(t){if(!this.host._markup)return;if("column"===this.host._tool)return void(this.host._cursorPt=this._snap(this._svgPoint(t)));if("opening"===this.host._tool||"wallthick"===this.host._tool)return void(this.host._cursorPt=this._svgPoint(t));const e="draw"===this.host._tool&&!this.host._contourClosed,s="split"===this.host._tool&&!!this.host._splitSel?.pts?.length;if(!e&&!s)return;const i=this._svgPoint(t);if(e){const e=this._resolvePlanDrawPoint(i,t.shiftKey);if(this.host._planSnapHover={contextKey:e.contextKey,candidate:e.candidate,conflicts:e.conflicts},this._syncPlanSnapConflictMarkers(e.conflicts),this._syncPlanSnapActiveMarker(e.candidate),!this.host._path.length)return;return void(this.host._cursorPt=e.point)}this.host._cursorPt=this._snap(i)}_saveRoom(){(this.host._areaSel||this.host._nameSel.trim())&&zt(this.host._roomTempMin,this.host._roomTempMax).valid&&(this.host._wallFaceBatch?this._decideWallFace(!0):this._commitRoom())}_decideWallFace(t){const e=this.host._wallFaceBatch;if(!e)return;const s=e.candidates[e.index];if(!s)return;if(!t&&(s.existing||s.repair)&&1===e.candidates.length)return this.host._wallFaceBatch=null,this.host._roomDialog=!1,this.host._nameSel="",this.host._areaSel="",void this.host.requestUpdate();const i=t?{candidate:s,create:!0,name:this.host._nameSel.trim(),area:this.host._areaSel||null,settings:this._roomSettingsFromDialog()?JSON.parse(JSON.stringify(this._roomSettingsFromDialog())):null}:{candidate:s,create:!1},o=[...e.decisions,i],a=e.index+1;if(a"number"==typeof t&&Number.isFinite(t)&&t>=0?t:null,o=.02*this.host._gridPitch,a=this.host._spaceModel();if(!a)return H;for(const e of this._planSnapGeometrySnapshot().value.segments)if(!("room"===e.sourceKind||ye(t,[e.a[0],e.a[1],e.b[0],e.b[1]])>o)&&"partition"===e.sourceKind)return i(a.partitions.find(t=>t.id===e.sourceId)?.cm)??H;const n=sc(Math.max(0,e.length-1),s,this.host._drawWallCm,H);for(let s=0;s+1[...t]);if(!e)return s;const i=this.host._activeWallChainPartitionIds.findIndex((t,s)=>this._activeWallSourceKey(s)===e.sourceKey),o=i>=0?i+("b"===e.endpoint?1:0):-1;return o>=0&&oe.key===t.sourceKey),a=i.find(e=>e.key===t.targetSourceKey);if(!o||!a)return!1;const n="a"===t.endpoint?o.a:o.b;return!(Math.hypot(n[0]-t.from[0],n[1]-t.from[1])>s)&&(!(ye(t.to,[a.a[0],a.a[1],a.b[0],a.b[1]])>s)&&!function(t,e){if(!t.sourceKey.startsWith("static:partition|"))return!1;const s=t.sourceKey.slice(17).split("|")[0];return!!s&&e.some(t=>"partition"===t.host?.kind&&t.host.id===s)}(t,this.host._curSpaceCfg?.openings||[]))}_applyWallRepair(t,e){const s=this.host._curSpaceCfg;if(!s||!this._validateWallRepair(t,e.activePath))return!1;if(!t.sourceKey.startsWith("static:"))return!1;const[i,o]=t.sourceKey.slice(7).split("|");if("partition"===i){const i=(s.partitions||[]).find(t=>t.id===o);if(!i)return!1;const a=[i.a[0]*wd,i.a[1]*wd],n=[i.b[0]*wd,i.b[1]*wd],r=Math.hypot(a[0]-t.from[0],a[1]-t.from[1])<=2e-4*this.host._gridPitch?i.a:Math.hypot(n[0]-t.from[0],n[1]-t.from[1])<=2e-4*this.host._gridPitch?i.b:null;if(!r)return!1;(e=>{e[0]=t.to[0]/wd,e[1]=t.to[1]/wd})(r);const l=e.activePartitionIds.indexOf(o);if(l>=0){const s=l+("b"===t.endpoint?1:0);e.activePath[s]&&(e.activePath[s]=[...t.to])}return!0}return!1}_applyWallFaceBatch(){const t=this.host._wallFaceBatch,e=this.host._curSpaceCfg,s=this.host._spaceModel();if(!t||!e||!s)return;const i=(t,e)=>{this.host._showToast(this.host._t(t,e)),this._roomDialogCancel()},o=t.decisions.filter(t=>t.create),a=o.map(t=>t.candidate.ring),n=s.rooms;for(let t=0;ts.id!==e&&!!N(s)&&ie(a[t],N(s)));if(s)return void i("toast.room_overlap",{name:s.name||""})}if((e.rooms||[]).length+o.length>400)return void i("toast.physical_limit");if(o.some(t=>t.candidate.split&&!e.rooms.some(e=>e.id===t.candidate.split.roomId)))return void i("toast.contour_cannot_close");const r=o.map(t=>t.candidate.repair).filter(t=>!!t);if(r.length>1||r[0]&&!this._validateWallRepair(r[0],t.activePath))return void i("toast.wall_repair_changed");if(this._activePathWithRepair(t.activePath,r[0]),!o.length){if(!this._finalizeWallChainPartitions(t.activePartitionIds))return;return this.host._path=[],this.host._activeWallChainId=null,this.host._activeWallChainPartitionIds=[],this.host._wallChainSegmentCms=[],this.host._wallChainRedo=[],this.host._closingWallCm=null,this.host._wallFaceBatch=null,this.host._roomDialog=!1,this.host._nameSel="",this.host._areaSel="",this.host.requestUpdate(),void this.host._showToast(this.host._t("toast.wall_chain_saved"))}const l=new Set(t.activePartitionIds),h=2e-4*this.host._gridPitch,c=o.map(t=>t.candidate.ring.map((t,e,i)=>{const o=i[(e+1)%i.length],a=s.partitions.filter(e=>{const s=Math.hypot(e.b[0]-e.a[0],e.b[1]-e.a[1]);if(!(s>h))return!1;const i=(e.b[0]-e.a[0])/s,a=(e.b[1]-e.a[1])/s,n=t=>(t[0]-e.a[0])*i+(t[1]-e.a[1])*a;return ye(t,[e.a[0],e.a[1],e.b[0],e.b[1]])<=h&&ye(o,[e.a[0],e.a[1],e.b[0],e.b[1]])<=h&&n(t)>=-h&&n(t)<=s+h&&n(o)>=-h&&n(o)<=s+h});return a.sort((t,e)=>Number(l.has(e.id))-Number(l.has(t.id))||Math.hypot(t.b[0]-t.a[0],t.b[1]-t.a[1])-Math.hypot(e.b[0]-e.a[0],e.b[1]-e.a[1])||t.id.localeCompare(e.id)),a[0]?.id||""})),d=this._geometrySnapshot();if(!d)return void i("toast.geometry_unsafe");const p=()=>{this._restoreGeometryStateLocal(d),i("toast.geometry_unsafe")};if(r[0]&&!this._applyWallRepair(r[0],t))return void i("toast.wall_repair_changed");const u=o.some(t=>!!t.candidate.split),_=u?Ae(s.rooms,e.walls,this.host._openCuts(),this.host._wallKeyPitch,this.host._cellCm,this.host._gridPitch,wd):null,g=u&&Array.isArray(e.walls)?e.walls:null;for(const t of o){const s=t.candidate.split;if(!s)continue;const i=e.rooms.find(t=>t.id===s.roomId);if(!i)return void p();i.poly=s.mainPoly.map(t=>[t[0]/wd,t[1]/this.host._spaceH]),delete i.x,delete i.y,delete i.w,delete i.h}const m=Date.now().toString(36),f=[];if(o.forEach((t,s)=>{const i=t.area?this.host.hass.areas[t.area]?.name:"",o={id:`r${m}-${s}`,name:t.name||i||this.host._t("room.default_name"),area:t.area||null,poly:t.candidate.ring.map(t=>[t[0]/wd,t[1]/this.host._spaceH]),...c[s].some(Boolean)?{wall_ids:c[s]}:{},...t.settings?{settings:JSON.parse(JSON.stringify(t.settings))}:{}};e.rooms.push(o),f.push({room:o,decision:t})}),u){const t=this.host._normalizeWalls(_,this.host._openCuts());t.length?e.walls=t:g?.length?e.walls=g:delete e.walls}if(f.length){this.host._cfgEpoch++;const s=this.host._openCuts(),i=this.host._spaceModel();if(!i)return void p();let o=e.walls;for(const{room:e,decision:a}of f){const n=a.candidate.ring,r=this._wallSourceCmAt(n[0],t.activePath,t.activeCms);o=ei(o,i.rooms,e.id,r,this.host._wallKeyPitch,s,wd);for(const a of O(i.rooms,o,s,this.host._wallKeyPitch,this.host._cellCm,this.host._gridPitch,wd)){if(a.roomId!==e.id||"outer"!==a.kind)continue;const s=[(a.a[0]+a.b[0])/2,(a.a[1]+a.b[1])/2];o=j(o,a.a,a.b,this._wallSourceCmAt(s,t.activePath,t.activeCms),this.host._wallKeyPitch,wd)}}const a=this.host._normalizeWalls(o,s);a.length?e.walls=a:delete e.walls,this.host._cfgEpoch++;const n=this.host._spaceModel();if(!n)return void p();const r=qa(e,n,e.walls,s,{pitch:this.host._wallKeyPitch,cellCm:this.host._cellCm,gridPitch:this.host._gridPitch,coordScale:wd,allowCoincidentPartitions:!0});r.walls.length?e.walls=r.walls:delete e.walls,r.partitions.length?e.partitions=r.partitions:delete e.partitions,r.openings.length?e.openings=r.openings:delete e.openings}if(!this._commitPhysicalGeometry(this.host._t("history.wall_face_batch"),d))return;this.host._path=[],this.host._activeWallChainId=null,this.host._activeWallChainPartitionIds=[],this.host._wallChainSegmentCms=[],this.host._wallChainRedo=[],this.host._closingWallCm=null,this.host._wallFaceBatch=null,this.host._roomDialog=!1,this.host._nameSel="",this.host._areaSel="",this.host._regSignature="",this.host._maybeRebuildDevices();const b=new Set(o.map(t=>t.area).filter(t=>!!t));if(b.size){const t={...this.host._layout};for(const e of this.host._devices){if(!b.has(e.area||"")||e.space!==this.host._space)continue;if(this.host._layout[e.id])continue;const s=this.host._defPos[e.id];s&&(t[e.id]={s:this.host._space,x:s.x/wd,y:s.y/wd},this.host._dirtyPos.add(e.id))}this.host._layout=t,this.host._persistLayout()}this.host._showToast(this.host._t(o.length?"toast.wall_rooms_saved":"toast.wall_chain_saved",{n:o.length}))}_commitRoom(){const t=this.host._curSpaceCfg,e=this.host._spaceModel();if(!t||!e)return;const s=this._geometrySnapshot();if(!s)return;const i=()=>{this._restoreGeometryStateLocal(s),this.host._showToast(this.host._t("toast.geometry_unsafe"))},o=this.host._spaceH,a=!!this.host._pendingSplit,n=a?Ae(e.rooms,t.walls,this.host._openCuts(),this.host._wallKeyPitch,this.host._cellCm,this.host._gridPitch,wd):null,r=a&&Array.isArray(t.walls)?t.walls:null;let l;if(this.host._pendingSplit){const e=t.rooms.find(t=>t.id===this.host._pendingSplit.roomId);if(!e)return this.host._pendingSplit=null,this.host._splitSel=null,void(this.host._roomDialog=!1);e.poly=this.host._pendingSplit.mainPoly.map(t=>[t[0]/wd,t[1]/o]),delete e.x,delete e.y,delete e.w,delete e.h,l=this.host._pendingSplit.newPoly}else{if(!this.host._contourClosed)return;l=this.host._path.slice(0,-1)}const h=this.host._areaSel?this.host.hass.areas[this.host._areaSel]?.name:"",c={id:"r"+Date.now().toString(36),name:this.host._nameSel||h||this.host._t("room.default_name"),area:this.host._areaSel||null,poly:l.map(t=>[t[0]/wd,t[1]/o]),...this._roomSettingsFromDialog()?{settings:this._roomSettingsFromDialog()}:{}};if(t.rooms.push(c),a){const e=this.host._normalizeWalls(n,this.host._openCuts());e.length?t.walls=e:r?.length?t.walls=r:delete t.walls}if(!a){const e=sc(l.length,[...this.host._wallChainSegmentCms,this.host._closingWallCm??void 0],this.host._drawWallCm,H),s=e[0];if(null!=s){this.host._cfgEpoch++;const o=this.host._openCuts(),a=this.host._spaceModel();if(!a)return void i();let n=ei(t.walls,a.rooms,c.id,s,this.host._wallKeyPitch,o,wd);for(const t of O(a.rooms,n,o,this.host._wallKeyPitch,this.host._cellCm,this.host._gridPitch,wd)){if(t.roomId!==c.id||"outer"!==t.kind)continue;const s=[(t.a[0]+t.b[0])/2,(t.a[1]+t.b[1])/2],i=l.findIndex((t,e)=>{const i=l[(e+1)%l.length];return ye(s,[t[0],t[1],i[0],i[1]])<=.02*this.host._gridPitch});i>=0&&(n=j(n,t.a,t.b,e[i],this.host._wallKeyPitch,wd))}n=this.host._normalizeWalls(n,o),n.length?t.walls=n:delete t.walls;const r=this.host._spaceModel();if(!r)return void i();const h=qa(t,r,t.walls,o,{pitch:this.host._wallKeyPitch,cellCm:this.host._cellCm,gridPitch:this.host._gridPitch,coordScale:wd,allowCoincidentPartitions:!0});h.walls.length?t.walls=h.walls:delete t.walls,h.partitions.length?t.partitions=h.partitions:delete t.partitions,h.openings.length?t.openings=h.openings:delete t.openings}}const d=this._commitPhysicalGeometry(this.host._t(a?"history.split_room":"history.add_room"),s);this.host._path=[],this.host._activeWallChainId=null,this.host._activeWallChainPartitionIds=[],this.host._wallChainSegmentCms=[],this.host._wallChainRedo=[],this.host._closingWallCm=null,this.host._pendingSplit=null,this.host._splitSel=null;const p=this.host._areaSel;if(this.host._areaSel="",this.host._nameSel="",this.host._roomDialog=!1,this.host._regSignature="",this.host._maybeRebuildDevices(),!d)return;let u=0;if(p){const t=wd,e={...this.host._layout};for(const s of this.host._devices){if(s.area!==p||s.space!==this.host._space)continue;if(u++,this.host._layout[s.id])continue;const i=this.host._defPos[s.id];i&&(e[s.id]={s:this.host._space,x:i.x/wd,y:i.y/t},this.host._dirtyPos.add(s.id))}this.host._layout=e,this.host._persistLayout()}const _=this.host._model.find(t=>t.id===this.host._space)?.rooms.length||0;this.host._showToast(p?this.host._t("toast.room_saved",{n:_,added:u}):this.host._t("toast.room_saved_no_area",{n:_}))}_cancelPath(){this.host._wallRepairDiagnostic=null,this.host._path=[],this.host._activeWallChainId=null,this.host._activeWallChainPartitionIds=[],this.host._wallChainSegmentCms=[],this.host._wallChainRedo=[],this.host._closingWallCm=null,this._clearPlanSnapHover(),this.host._roomDialog=!1,this.host._pendingSplit=null,this.host._wallFaceBatch=null,this.host._splitSel=null,this.host._mergeSel=null,this.host._mergeDialog=null,this.host._physicalSel=null,this.host._physicalDrag=null,this.host._physicalRotate=null,this._clearOpeningPlacement(!0)}_roomDialogCancel(){if(this.host._roomDialog=!1,this.host._roomEditId)return this.host._roomEditId=null,this.host._nameSel="",void(this.host._areaSel="");if(this.host._wallFaceBatch){const t=this.host._wallFaceBatch;return this.host._wallFaceBatch=null,this.host._path=t.activePath.map(t=>[...t]),this.host._wallChainSegmentCms=[...t.activeCms],this.host._activeWallChainPartitionIds=[...t.activePartitionIds],this.host._activeWallChainId||=`chain-${Date.now().toString(36)}`,this.host._nameSel="",this.host._areaSel="",void this.host.requestUpdate()}if(this.host._pendingSplit)return this.host._pendingSplit=null,void(this.host._splitSel=null);this.host._undoPoint()}_openDeviceInbox(){this.host._deviceInboxReturn=null,this.host._deviceInbox=this.host._deviceInbox||{tab:"on_plan",search:"",showEntities:!1,onlyNew:!1,limit:100}}_closeMarkerDialog(){this._radarSetup.isDirty()?this._closeMarkerDialogGuarded():(this._radarSetup.reset(),function(t){if(t._markerDialog=null,!t._deviceInboxReturn)return;const e={...t._deviceInboxReturn};t._deviceInbox=e,t._deviceInboxReturn=null,e.anchor&&t.updateComplete.then(()=>requestAnimationFrame(()=>{const s=`.device-inbox-row[data-binding="${CSS.escape(e.anchor)}"]`;t.renderRoot.querySelector(s)?.scrollIntoView({block:"nearest"})}))}(this.host))}async _closeMarkerDialogGuarded(){if(!await this._radarSetup.discardIfAllowed())return await this.host.updateComplete,void this.host.renderRoot.querySelector("#marker-dialog")?.rejectClose();this._closeMarkerDialog()}_deviceInboxCandidates(t){return Lh({hass:this.host._planHass,devices:this.host._devices,markers:this.host._markers,showEntities:t,labels:{device:this.host._t("marker.sub_device"),z2mGroup:this.host._t("marker.sub_z2m_group"),group:this.host._t("marker.sub_group"),helper:this.host._t("marker.sub_helper"),entity:this.host._t("marker.sub_entity")}})}_deviceInboxRows(){const t=this.host._deviceInbox||this.host._deviceInboxReturn,e=!!t?.showEntities,s=[this.host._haRegistry.revision,this.host._cfgRev,this.host._cfgEpoch,this.host._regSignature,this.host._newSyncKey,e?1:0,this.host._showAll?1:0,l(this.host.hass,this.host._config?.language)].join("|");if(this.host._deviceInboxMemo?.key===s)return this.host._deviceInboxMemo.rows;const i=this._deviceInboxCandidates(e),o=new Set(i.map(t=>t.value));for(const t of this.host._markers)t.binding&&"virtual"!==t.binding&&o.add(t.binding);for(const t of this.host._devices)t.bindingKind&&"virtual"!==t.bindingKind&&t.bindingRef&&o.add(`${t.bindingKind}:${t.bindingRef}`);const a=new Map;for(const t of o)a.set(t,this.host._bindingStatus(t));const n=this.host._areaToSpace,r={};for(const[t,e]of Object.entries(this.host.hass?.areas||{}))r[t]=n[t]?.room?.name||e?.name||t;for(const[t,e]of Object.entries(n))r[t]=e.room.name||r[t]||t;const h=Object.fromEntries(this.host._model.map(t=>[t.id,t.title])),c=Object.fromEntries(Object.entries(n).map(([t,e])=>[t,e.space])),d={},p=new Map;for(const[t,e]of Object.entries(this.host._fullRegistryHass.entities||{})){const s=String(e?.platform||"").trim();if(s&&(d[`entity:${t}`]=s),s&&e?.device_id){const t=p.get(e.device_id)||new Set;t.add(s),p.set(e.device_id,t)}}for(const[t,e]of p)d[`device:${t}`]=[...e].sort().join(", ");const u={};for(const[t,e]of Object.entries(this.host._fullRegistryHass.devices||{})){const s=`device:${t}`,i=p.get(t)||new Set,o=Array.isArray(e?.identifiers?.[0])?String(e.identifiers[0][0]||""):"";o&&!d[s]&&(d[s]=o);const a=[o,...i].some(t=>this.host._excluded.has(t));"service"===e?.entry_type?u[s]="service_entry":a?u[s]="excluded_integration":"Group"===e?.model?u[s]="grouped_light":/scene/i.test(e?.model||"")?u[s]="excluded_domain":(/bridge/i.test(`${e?.model||""}${e?.name||""}`)||"myheat"===o&&e?.via_device_id)&&(u[s]="represented_by_parent")}const _=function(t){const{devices:e,markers:s,candidates:i,statuses:o,newDeviceIds:a,showHiddenOnPlan:n,areaNames:r={},spaceNames:l={},spaceByArea:h={},integrationByBinding:c={},reasonByBinding:d={}}=t,p=new Map;for(const t of e)!t.virtual&&t.bindingKind&&"virtual"!==t.bindingKind&&t.bindingRef&&p.set(`${t.bindingKind}:${t.bindingRef}`,t);const u=new Map,_=new Map;for(const t of s)t?.binding&&"virtual"!==t.binding&&(t.removed?_.set(t.binding,t):u.set(t.binding,t));const g=new Map(i.map(t=>[t.value,t])),m=new Set([...p.keys(),...u.keys(),...g.keys(),...[..._.keys()].filter(t=>g.has(t))]),f=[];for(const t of m){const e=p.get(t),s=u.get(t),i=s?void 0:_.get(t),m=g.get(t);let b;if(i&&m)b="readd";else if(!0===s?.hidden)b="hidden";else if(e||s)b="on_plan";else{if(!m)continue;b="available"}const v=e?.bindingStatus||o.get(t)||Th,y=s||i,$=Rh(t),w=e?.area||m?.areaId||y?.area||"",k=e?.space||y?.space||h[w]||"",x=e?.name||y?.name||m?.label||t,M=e?.model||y?.model||m?.model||"",C=!!m?.parentDeviceId&&p.has(`device:${m.parentDeviceId}`),S="readd"===b?"removed":"hidden"===b?s&&zh(s)?d[t]||"automatic_hidden":"manual_hidden":"on_plan"===b?s?"visible_explicit":"visible_auto":d[t]||(C?"represented_by_parent":w&&k?"available":"no_bound_room"),P=!!e&&(!e.hidden||n),D="active"===v.kind,I=P&&(D||"ha_disabled"===v.kind&&n),L=[x,M,c[t],r[w],l[k],t,m?.sub].filter(Boolean).join(" ").toLocaleLowerCase();f.push({key:t,binding:t,category:b,status:v,reason:S,deviceId:e?.id,markerId:y?.id,name:x,icon:e?.icon||y?.icon||("entity"===$?"mdi:code-braces":"mdi:devices"),model:M,integration:c[t]||"",areaId:w,areaName:r[w]||"",spaceId:k,spaceName:l[k]||"",kind:$,isNew:!!e&&a.has(e.id),searchText:L,canFind:I,canEdit:!!e||!!s,canHide:"on_plan"===b&&D,canShow:"hidden"===b&&D,canAdd:("available"===b||"readd"===b)&&D})}const b=t=>"active"===t.status.kind?1:0;return f.sort((t,e)=>t.category.localeCompare(e.category)||Number(e.isNew)-Number(t.isNew)||b(t)-b(e)||t.name.localeCompare(e.name)||t.binding.localeCompare(e.binding))}({devices:this.host._devices,markers:this.host._markers,candidates:i,statuses:a,newDeviceIds:this.host._newIds,showHiddenOnPlan:this.host._showAll,areaNames:r,spaceNames:h,spaceByArea:c,integrationByBinding:d,reasonByBinding:u});return this.host._deviceInboxMemo={key:s,rows:_},_}_deviceForInboxRow(t){const e=t.deviceId?this.host._devices.find(e=>e.id===t.deviceId):null;if(e)return e;const s=t.markerId?this.host._markers.find(e=>e.id===t.markerId):null;return!s||s.removed?null:{id:s.id,name:t.name,model:t.model,area:t.areaId,space:t.spaceId||this.host._space,hidden:!0===s.hidden||"ha_disabled"===t.status.kind,userHidden:!0===s.hidden,bindingStatus:t.status,icon:t.icon,entities:"active"===t.status.kind?t.status.enabledEntityIds:[],allEntities:t.status.allEntityIds,primary:"active"===t.status.kind?t.status.enabledEntityIds[0]:void 0,marker:s,bindingKind:t.kind,bindingRef:t.binding.slice(t.binding.indexOf(":")+1),pdfs:s.pdfs||[]}}_openInboxMarker(t,e=!1){const s=this.host._deviceInbox;if(s){if(this.host._deviceInboxReturn={...s,anchor:t.key},this.host._deviceInbox=null,!e){const e=this._deviceForInboxRow(t);return void(e?this._openMarkerDialog(e):this._closeMarkerDialog())}this._openMarkerDialog(),this.host._markerDialog?this.host._markerDialog={...this.host._markerDialog,bindingMode:"ha",binding:t.binding,bindingOpen:!1,showEntities:"entity"===t.kind,name:""}:this._closeMarkerDialog()}}async _setInboxHidden(t,e){const s=this.host._deviceInbox,i=this.host._serverCfg;if(!s||!i||s.busy||"active"!==t.status.kind)return;const o=i.markers||[],a=o.find(e=>!e.removed&&e.binding===t.binding);if(!e&&!a)return;const n=a?.id||si(t.binding,t.markerId,()=>`m_${Date.now().toString(36)}`),r=a?{...a,hidden:e}:{id:n,binding:t.binding,hidden:!0};i.markers=[...o.filter(e=>e.id!==n&&(e.binding!==t.binding||!0===e.removed)),r],this.host._deviceInbox={...s,busy:t.key,anchor:t.key};try{await this._saveConfigNow(),this.host._regSignature="",this.host._deviceInboxMemo=null,this.host._maybeRebuildDevices(),this.host._deviceInbox&&(this.host._deviceInbox={...this.host._deviceInbox,busy:void 0}),this.host._showToast(this.host._t("device_inbox.saved"))}catch(t){this.host._serverCfg===i&&(i.markers=o),this.host._deviceInbox&&(this.host._deviceInbox={...this.host._deviceInbox,busy:void 0}),this.host._showToast(this.host._t("toast.error",{err:this.host._errText(t)}))}}_findInboxDevice(t){if(!t.canFind)return;const e=this._deviceForInboxRow(t);if(!e)return;if(this.host._deviceInbox=null,e.space&&e.space!==this.host._space){if(!this.host._commitSpace(e.space))return;this.host._restoreZoom()}const s=()=>{const t=this.host._devices.find(t=>t.id===e.id)||e,s=this.host._pos(t);this.host._applyView(this.host._zoom,s.x,s.y),this.host._selId=t.id,this.host.requestUpdate(),window.setTimeout(()=>{this.host._selId===t.id&&(this.host._selId=null,this.host.requestUpdate())},1500)};requestAnimationFrame(()=>requestAnimationFrame(s))}_openMarkerDialog(t){if(this.host._vacAllCamerasFor=null,this.host._vacAllCameraCache=null,t&&this.host._ackNewDevice(t.id),this.host._norm)if(t){const e=t.marker,s=Object.prototype.hasOwnProperty.call(e||{},"is_light"),i=Object.prototype.hasOwnProperty.call(e||{},"light_entity"),o=Object.prototype.hasOwnProperty.call(e||{},"glow_color"),a=Object.prototype.hasOwnProperty.call(e||{},"value_badge"),n=Object.prototype.hasOwnProperty.call(e||{},"value_source"),r=Object.prototype.hasOwnProperty.call(e||{},"tap_action"),l=Object.prototype.hasOwnProperty.call(e||{},"toggle_entity"),h=ii(e?.glow_color),c=this.host._devicePresentation(t,!0).valueBadge,d=m(this.host._planHass,t,this.host._devices),p=f(this.host._planHass,t,d),u=na(t,this.host._fullRegistryHass),_=this.host._spaceModelById(t.space)||this.host._spaceModel(),g=this.host._pos(t),b=_?la(t,_,[g.x,g.y],this.host._fullRegistryHass):null;this.host._markerDialog={devId:t.id,name:t.name,binding:"virtual"===t.bindingKind?"virtual":t.bindingKind+":"+t.bindingRef,bindingMode:"virtual"===t.bindingKind?"virtual":"ha",bindingOpen:!1,showEntities:"entity"===t.bindingKind&&!!this.host._fullRegistryHass.entities[t.bindingRef||""]?.device_id,bindingFilter:"",icon:t.marker?.icon||"",autoIcon:t.icon||"",display:S(t.marker?.display),rippleColor:qt(t.marker?.ripple_color,""),rippleSize:Number(t.marker?.ripple_size)>0?Number(t.marker.ripple_size):1.5,size:Number(t.marker?.size)>0?Number(t.marker.size):1,angle:Number(t.marker?.angle)||0,tapAction:oi(t.marker?.tap_action,t.primary?.split(".")[0]),tapActionTouched:!1,originalHasTapAction:r,originalTapAction:t.marker?.tap_action,tapHintAnnouncement:"",toggleEntity:e?.toggle_entity||"",toggleEntityTouched:!1,originalHasToggleEntity:l,originalToggleEntity:e?.toggle_entity,tapTarget:t.marker?.tap_target||"",tapConfirm:!0===t.marker?.tap_confirm,runFilter:"",controls:x(t.marker?.binding,t.marker?.controls,t.entities),controlsFilter:"",lightRole:!0===e?.is_light?"always":!1===e?.is_light?"never":"auto",lightRoleTouched:!1,originalHasIsLight:s,originalIsLight:e?.is_light,lightEntity:e?.light_entity||"",lightEntityTouched:!1,originalHasLightEntity:i,originalLightEntity:e?.light_entity,glowMode:null!=h?.bri?"fixed":h?"color":"auto",glowColor:h?.c||this.host._fillColors.glow_light.c,glowBrightness:Math.max(1,Math.round(100*(h?.bri??1))),glowColorDrafted:!!h,glowBrightnessDrafted:null!=h?.bri,glowTouched:!1,originalHasGlowColor:o&&(!!h||null===e?.glow_color),originalGlowColor:h||(null===e?.glow_color?null:void 0),valueBadgeEnabled:a?!0===e?.value_badge?.enabled:!!c,valueBadgeSource:e?.value_badge?.source||c?.source||p,valueBadgePosition:e?.value_badge?.position||c?.position||"right",valueBadgeTouched:!1,originalHasValueBadge:a,originalValueBadge:e?.value_badge,valueSource:e?.value_source||null,valueSourceTouched:!1,originalHasValueSource:n,originalValueSource:e?.value_source,useClimateTemp:!0===t.marker?.use_climate_temp,glowRadius:Number(t.marker?.glow_radius_cm)>0?String(this.host._imperial?Math.round(Number(t.marker.glow_radius_cm)/30.48*10)/10:Math.round(Number(t.marker.glow_radius_cm))/100):"",model:t.model||"",link:t.link||"",description:t.description||"",pdfs:[...t.pdfs||[]],room:t.marker?.room_id?t.space+"#@"+t.marker.room_id:t.space&&t.area?t.space+"#"+t.area:"",roomTouched:!1,radar:b,radarEligible:u.eligible,radarTouched:!1,radarRemove:!1,hideFromPlan:!0===t.marker?.hidden,busy:!1}}else this.host._markerDialog={name:"",binding:"virtual",bindingMode:"virtual",bindingOpen:!1,showEntities:!1,bindingFilter:"",icon:"",autoIcon:"",display:"badge",rippleColor:"",rippleSize:1.5,size:1,angle:0,tapAction:"info",tapActionTouched:!1,originalHasTapAction:!1,originalTapAction:void 0,tapHintAnnouncement:"",toggleEntity:"",toggleEntityTouched:!1,originalHasToggleEntity:!1,originalToggleEntity:void 0,tapTarget:"",tapConfirm:!1,runFilter:"",controls:[],controlsFilter:"",lightRole:"auto",lightRoleTouched:!1,originalHasIsLight:!1,originalIsLight:void 0,lightEntity:"",lightEntityTouched:!1,originalHasLightEntity:!1,originalLightEntity:void 0,glowMode:"auto",glowColor:this.host._fillColors.glow_light.c,glowBrightness:100,glowColorDrafted:!1,glowBrightnessDrafted:!1,glowTouched:!1,originalHasGlowColor:!1,originalGlowColor:void 0,valueBadgeEnabled:!1,valueBadgeSource:null,valueBadgePosition:"right",valueBadgeTouched:!1,originalHasValueBadge:!1,originalValueBadge:void 0,valueSource:null,valueSourceTouched:!1,originalHasValueSource:!1,originalValueSource:void 0,useClimateTemp:!1,glowRadius:"",model:"",link:"",description:"",pdfs:[],room:"",roomTouched:!1,radar:null,radarEligible:!1,radarTouched:!1,radarRemove:!1,hideFromPlan:!1,busy:!1,uploadId:"up_"+Date.now().toString(36)+Math.random().toString(36).slice(2,6)};else this.host._showToast(this.host._t("toast.marker_needs_server"))}_runCandidates(){const t=[];for(const e of ai)for(const[s,i]of Object.entries(this.host.hass.states))s.startsWith(e+".")&&this.host._planEntityAvailable(s)&&t.push({value:s,label:i?.attributes?.friendly_name||s,sub:this.host._t("run."+e)});return t.sort((t,e)=>t.sub.localeCompare(e.sub)||t.label.localeCompare(e.label))}_bindingCandidates(){const t=Lh({hass:this.host._planHass,devices:this.host._devices,markers:this.host._markers,showEntities:!!this.host._markerDialog?.showEntities,currentBinding:this.host._markerDialog?.binding,currentDeviceId:this.host._markerDialog?.devId,labels:{device:this.host._t("marker.sub_device"),z2mGroup:this.host._t("marker.sub_z2m_group"),group:this.host._t("marker.sub_group"),helper:this.host._t("marker.sub_helper"),entity:this.host._t("marker.sub_entity")}}),e=(this.host._markerDialog?.bindingFilter||"").toLowerCase().trim(),s=e?t.filter(t=>(t.label+" "+t.sub+" "+t.value).toLowerCase().includes(e)):t;return s.sort((t,e)=>t.label.localeCompare(e.label)),s.slice(0,200)}_backupErrorText(t){const e=t?.code??t?.error;if("string"==typeof e){const t=`backup.error.${e}`,s=this.host._t(t);if(s!==t)return s}return this.host._errText(t)}async _pickMarkerFiles(t){const e=t.target,s=e.files?[...e.files]:[];if(e.value="",!s.length||!this.host._markerDialog)return;const i=this.host._markerDialog.uploadId||this.host._markerDialog.devId||"new",o=[];for(const t of s)try{const e=new FormData;e.append("marker_id",i),e.append("file",t,t.name);const s=this.host.hass?.fetchWithAuth?await this.host.hass.fetchWithAuth("/api/houseplan/upload",{method:"POST",body:e}):await fetch("/api/houseplan/upload",{method:"POST",body:e,headers:this.host.hass?.auth?.data?.access_token?{authorization:`Bearer ${this.host.hass.auth.data.access_token}`}:{}}),a=await s.json().catch(()=>({}));if(!s.ok||a.error){const t={too_large:this.host._t("err.too_large",{mb:a.max_mb||50}),bad_ext:this.host._t("err.bad_ext"),unauthorized:this.host._t("err.unauthorized")};throw new Error(t[a.error]||a.error||"HTTP "+s.status)}o.push({name:a.name||t.name,url:a.url})}catch(e){this.host._showToast(this.host._t("toast.file_failed",{name:t.name,err:this.host._errText(e)}))}o.length&&this.host._markerDialog&&(this.host._markerDialog={...this.host._markerDialog,pdfs:[...this.host._markerDialog.pdfs,...o]},this.host._showToast(this.host._t("toast.files_attached",{n:o.length})))}_removeMarkerPdf(t){this.host._markerDialog&&(this.host._markerDialog={...this.host._markerDialog,pdfs:this.host._markerDialog.pdfs.filter(e=>e.url!==t)})}_markerLightFields(t){const e={};if(t.lightRoleTouched?"always"===t.lightRole?e.is_light=!0:"never"===t.lightRole&&(e.is_light=!1):t.originalHasIsLight&&(e.is_light=t.originalIsLight??null),t.lightEntityTouched?t.lightEntity&&(e.light_entity=t.lightEntity):t.originalHasLightEntity&&(e.light_entity=t.originalLightEntity??null),t.glowTouched){if("auto"!==t.glowMode){const s={c:qt(t.glowColor,this.host._fillColors.glow_light.c)};"fixed"===t.glowMode&&(s.bri=Math.max(.01,Math.min(1,Math.round(t.glowBrightness)/100))),e.glow_color=s}}else t.originalHasGlowColor&&(e.glow_color=t.originalGlowColor??null);return e}_markerTapActionFields(t){return t.tapActionTouched?{tap_action:t.tapAction||null}:t.originalHasTapAction?{tap_action:t.originalTapAction??null}:{}}_markerToggleEntityFields(t){return(e={touched:t.toggleEntityTouched,originalHas:t.originalHasToggleEntity,original:t.originalToggleEntity,value:t.toggleEntity}).touched?e.value?{toggle_entity:e.value}:{}:e.originalHas?{toggle_entity:e.original??null}:{};var e}async _saveMarker(){const t=this.host._markerDialog;if(!t||t.busy)return;const e=this._effectiveMarkerTapAction(t);if("ha"===t.bindingMode&&(!t.binding||"virtual"===t.binding))return;if("virtual"===t.binding&&!t.name.trim())return void this.host._showToast(this.host._t("toast.virtual_name_required"));if("run"===e&&!t.tapTarget)return void this.host._showToast(this.host._t("toast.run_target_required"));if(t.valueBadgeTouched&&t.valueBadgeEnabled&&!t.valueBadgeSource)return void this.host._showToast(this.host._t("toast.value_badge_source_required"));if("ha"===t.bindingMode){const e=this.host._bindingStatus(t.binding),s=t.devId?this.host._markers.find(e=>e.id===t.devId):null,i=!s||s.binding!==t.binding;if("active"!==e.kind&&i)return void this.host._showToast(this.host._t("ha_disabled"===e.kind?"toast.ha_disabled_add":"toast.ha_binding_unverified"));if("ha_disabled"===e.kind&&!0===s?.hidden&&!t.hideFromPlan)return this.host._markerDialog={...t,hideFromPlan:!0},void this.host._showToast(this.host._t("entity"===e.reason?"toast.ha_disabled_show_entity":"toast.ha_disabled_show_device"))}const s=this.host._serverCfg;if(!s)return;const i=this.host._cfgRev,o=yt(s);let a=JSON.parse(JSON.stringify(s));const n=a.markers||[],r=si(t.binding,t.devId,()=>"v_"+Date.now().toString(36)),l=t.devId,h=l?this.host._devices.find(t=>t.id===l):null,c=l?n.find(t=>t.id===l):null,d=!!c&&("string"==typeof c.area&&c.area.length>0||null===c.area&&!!c.space&&!!c.room_id),p="virtual"===t.binding||t.roomTouched||d,u="virtual"===t.binding||t.roomTouched?M(t.room):null;let _=d&&!t.roomTouched?c?.space||null:u?.space||null;const g=d&&!t.roomTouched?c?.area||null:u?.area||null,m=d&&!t.roomTouched?c?.room_id||null:u?.roomId||null,f=_||h?.space||null,b=f?this.host._spaceModelById(f):this.host._spaceModel();if(!b)return;const v=b.id;"virtual"!==t.binding||_||(_=v);let y={};if(t.radarTouched){if(t.radarRemove)y={radar:null};else if(t.radar){const e=da(t.radar,b.cellCm||5);if(!e)return void this.host._showToast(this.host._t("radar.invalid"));y={radar:e}}}else c&&Object.prototype.hasOwnProperty.call(c,"radar")&&(y={radar:c.radar});this.host._markerDialog={...t,busy:!0};let $=null,w=!1;try{const c="virtual"===t.binding?[]:n.filter(e=>e.removed&&e.binding===t.binding).map(t=>t.id),d=c.length>0,u=x(t.binding,t.controls,this.host._bindingEntities(t.binding)),f=n.find(t=>t.id===r||t.id===l)?.vacuum||null,k={id:r,vacuum:f,...y,binding:t.binding,name:t.name.trim()||null,icon:t.icon||null,display:"badge"!==t.display?t.display:null,ripple_color:"icon_ripple"===t.display&&t.rippleColor?t.rippleColor:null,ripple_size:"icon_ripple"===t.display&&1.5!==t.rippleSize?t.rippleSize:null,size:1!==t.size?t.size:null,angle:t.angle?t.angle:null,...this._markerTapActionFields(t),...this._markerToggleEntityFields(t),tap_target:"run"===e&&t.tapTarget||null,tap_confirm:!!t.tapConfirm||null,controls:u.length?u:null,...this._markerLightFields(t),...this._markerValueBadgeFields(t),...this._markerValueSourceFields(t),use_climate_temp:!!t.useClimateTemp||null,glow_radius_cm:(()=>{const e=kt(t.glowRadius);return null==e||e<=0?null:Math.round(this.host._imperial?30.48*e:100*e)})(),model:t.model.trim()||null,link:t.link.trim()||null,description:t.description.trim()||null,pdfs:t.pdfs,hidden:!!t.hideFromPlan};p&&(k.space=_,k.area=g,k.room_id=m);const M=h?.marker?.room_id??null,C=t.roomTouched&&null!=h&&(h.space!==_||h.area!==g||M!==m);let S=!1;const P=t.uploadId||l;if(P&&P!==r&&k.pdfs?.length)try{const t=await this.host.hass.callWS({type:"houseplan/files/migrate",from_id:P,to_id:r}),e=t?.mapping||{};k.pdfs=ni(k.pdfs,P,r,e),S=Object.keys(e).length>0}catch(t){this.host._showToast(this.host._t("toast.files_migrate_failed",{err:this.host._errText(t)}))}a.markers=n,l&&l!==r&&(a.markers=ri(a.markers,l,r)),l&&l!==r&&"derived_marker_state"===k.value_badge?.source?.kind&&k.value_badge.source.ref===`marker:${l}`&&(k.value_badge.source={kind:"derived_marker_state",ref:`marker:${r}`}),l&&l!==r&&"derived_marker_state"===k.value_source?.kind&&k.value_source.ref===`marker:${l}`&&(k.value_source={kind:"derived_marker_state",ref:`marker:${r}`}),a.markers=a.markers.filter(t=>t.id!==r&&t.id!==l&&("virtual"===k.binding||t.binding!==k.binding)),a.markers.push(k);const D=new Set(c);l&&l!==r&&D.add(l),D.delete(r),D.size&&a.settings?.marker_area_snapshot&&(a.settings={...a.settings,marker_area_snapshot:li(a.settings.marker_area_snapshot,D)});let I=null;const L=l?this.host._layout[l]:null,T=L?{s:L.s||h?.space||this.host._space,x:L.x,y:L.y}:l&&h&&this.host._defPos[l]?this.host._normPos(h.space,this.host._defPos[l].x,this.host._defPos[l].y):null;if(!d&&T&&T.s===v)r===l&&this.host._layout[r]&&!C||(I={s:T.s,x:T.x,y:T.y});else if(d||!this.host._layout[r]||C){let t=b.vb[0]+b.vb[2]/2,e=b.vb[1]+b.vb[3]/2;const s=m?b.rooms.find(t=>t.id===m):g?b.rooms.find(t=>t.area===g):void 0;s&&([t,e]=this.host._roomCenter(s)),I=this.host._normPos(v,t,e)}if(this.host._serverCfg!==s||this.host._cfgRev!==i||yt(s)!==o)return this.host._markerDialog&&(this.host._markerDialog={...this.host._markerDialog,busy:!1}),void this.host._showToast(this.host._t("toast.conflict"));if(a=this._prepareConfigCandidate(a),$=this.host._adoption.beginOptimistic(s,a),this.host._serverCfg=a,this.host._regSignature="",this.host._maybeRebuildDevices(),this.host.requestUpdate(),this.host._saveConfigDebounced.pending()&&this.host._saveConfigDebounced.cancel(),await this._saveConfigNow($),w=!0,I){const t=hi(I);this.host._layout={...this.host._layout,[r]:t},this.host._noteLayoutRev(await this.host.hass.callWS({type:"houseplan/layout/update",device_id:r,pos:t}))}const R=new Set(c);l&&l!==r&&R.add(l),R.delete(r);for(const t of R)delete this.host._layout[t],await this.host.hass.callWS({type:"houseplan/layout/delete",device_id:t}).then(t=>this.host._noteLayoutRev(t)).catch(()=>{});S&&P&&await this.host.hass.callWS({type:"houseplan/files/cleanup",marker_id:P}).catch(()=>{}),this._closeMarkerDialog(),this.host._cancelDeviceDrag(),this.host._devicePositionHistory.clear(),this.host._regSignature="",this.host._maybeRebuildDevices(),this.host._showToast(this.host._t("toast.marker_saved"))}catch(t){!w&&$&&(this.host._rollbackOptimistic($),this.host._regSignature="",this.host._maybeRebuildDevices(),this.host.requestUpdate()),this.host._markerDialog&&(this.host._markerDialog={...this.host._markerDialog,busy:!1}),this.host._showToast(this.host._t("toast.error",{err:this.host._errText(t)}))}}async _deleteMarker(){const t=this.host._markerDialog;if(!t||t.busy||!t.devId)return;const e=t.devId?this.host._devices.find(e=>e.id===t.devId):null,s=this.host._markers.find(e=>e.id===t.devId);if(!e&&!s)return;const i=e?"virtual"===e.bindingKind?"virtual":e.bindingKind&&e.bindingRef?`${e.bindingKind}:${e.bindingRef}`:"":s.binding;if(!i)return;const o=t.name||this.host._t("device.fallback"),a=t.devId,n=await this.host._confirmDanger({key:"remove-marker",kind:"destructive",title:this.host._t("confirm.remove_marker_title"),message:this.host._t("confirm.remove_marker_body"),objectName:o,confirmLabel:this.host._t("btn.delete"),cancelLabel:this.host._t("btn.cancel")}),r=this.host._markerDialog;if(!n||!r||r.busy||r.devId!==a)return;const l=this.host._devices.find(t=>t.id===a),h=this.host._markers.find(t=>t.id===a);if(!l&&!h)return;const c=this.host._serverCfg;if(!c)return;c.markers=c.markers||[];const d=c.markers,p=l?"virtual"===l.bindingKind?"virtual":l.bindingKind&&l.bindingRef?`${l.bindingKind}:${l.bindingRef}`:"":h.binding;if(!p||p!==i)return;const u=ci(c.markers,a,p,"virtual"===p);c.markers=di(u.markers,u.cleanupIds);const _=u.cleanupIds;_.size&&c.settings?.marker_area_snapshot&&(c.settings={...c.settings,marker_area_snapshot:li(c.settings.marker_area_snapshot,_)}),this.host._markerDialog={...r,busy:!0};try{await this._saveConfigNow();for(const t of _){delete this.host._layout[t],delete this.host._defPos[t],this.host._dirtyPos.delete(t),this.host._sentPos.delete(t);const e=this.host._activityRt.get(t);e&&clearTimeout(e.timer),this.host._activityRt.delete(t),this.host._vacRt.delete(t),delete this.host._vacSrvTrails[t],await this.host.hass.callWS({type:"houseplan/layout/delete",device_id:t}).then(t=>this.host._noteLayoutRev(t)).catch(()=>{}),await this.host.hass.callWS({type:"houseplan/files/cleanup",marker_id:t}).catch(()=>{}),await this.host.hass.callWS({type:"houseplan/trail/delete",marker_id:t}).catch(()=>{})}this.host._deviceInboxReturn&&(this.host._deviceInboxReturn={...this.host._deviceInboxReturn,tab:"readd",anchor:p}),this._closeMarkerDialog(),this.host._cancelDeviceDrag(),this.host._devicePositionHistory.clear(),this.host._infoCard?.id===a&&this.host._closeInfoCard(),this.host._selId===a&&(this.host._selId=null),this.host._drag?.id===a&&(this.host._drag=null),this.host._regSignature="",this.host._maybeRebuildDevices(),this.host._showToast(this.host._t("toast.marker_removed"))}catch(t){this.host._serverCfg===c&&(c.markers=d),this.host._markerDialog&&(this.host._markerDialog={...this.host._markerDialog,busy:!1}),this.host._showToast(this.host._t("toast.error",{err:this.host._errText(t)}))}}_openSpaceDialog(t,e){if(this.host._serverStorage&&this.host._serverCfg)if("edit"===t){const s=this.host._serverCfg.spaces.find(t=>t.id===e);if(!s)return;const i=_(s),o=s.settings?.custom_fill&&"object"==typeof s.settings.custom_fill?pi(s.settings.custom_fill):null,a="none"===i.fill?{...o||St,a:0}:o;this.host._spaceDialog={mode:t,spaceId:e,title:s.title,planUrl:s.plan_url||null,planFile:null,source:s.plan_url?"file":"draw",showBorders:i.showBorders,showNames:i.showNames,zeroWallStyle:ui(s),displayTouched:!0,hideDecor:i.hideDecor,hideOpenings:i.hideOpenings,roomColor:i.color,roomOpacity:i.opacity,fillMode:"none"===i.fill?"custom":i.fill,customFill:a,glowEnabled:i.glow,bgColor:i.bgColor,bgMode:"static"===s.settings?.bg_mode||"daynight"===s.settings?.bg_mode?s.settings.bg_mode:null,northDeg:It({},s.settings),sunRays:"boolean"==typeof s.settings?.sun_rays?s.settings.sun_rays:null,tempMin:i.tempMin,tempMax:i.tempMax,showLqi:i.showLqi??this.host._config?.show_signal??!0,cardFontScale:i.cardFontScale,labelTemp:i.labelTemp,labelHum:i.labelHum,labelLqi:i.labelLqi,labelLight:i.labelLight,cellCm:Number(s.cell_cm)>0?Number(s.cell_cm):5,cellCmInput:wt(Number(s.cell_cm)>0?Number(s.cell_cm):5,this.host._imperial),cellCmTouched:!1,busy:!1}}else this.host._spaceDialog={mode:t,title:"",planUrl:null,planFile:null,...vi(),hideDecor:!1,hideOpenings:!1,zeroWallStyle:"dashed",roomColor:fi,roomOpacity:mi,fillMode:"custom",customFill:{...St,a:0},glowEnabled:!0,bgColor:null,bgMode:"daynight",northDeg:null,sunRays:null,tempMin:gi,tempMax:_i,showLqi:this.host._config?.show_signal??!0,cardFontScale:1,labelTemp:!1,labelHum:!1,labelLqi:!1,labelLight:!1,cellCm:bi(this.host._imperial),cellCmInput:wt(bi(this.host._imperial),this.host._imperial),cellCmTouched:!1,busy:!1};else this.host._showToast(this.host._t("toast.integration_missing"))}async _pickPlanFile(t){const e=t.target,s=e.files?.[0];if(!s||!this.host._spaceDialog)return;e.value="",this._decorAssetGuardReplace=null;const i=await xo(s);if("reject"===i.kind)return void this.host._showToast(this.host._t("toast.plan_formats"));if("guard"===i.kind)return void(this.host._backdropGuard=i.state);const o=await Mo(s,i.ext,s.name);this.host._spaceDialog&&(this.host._spaceDialog={...this.host._spaceDialog,planFile:o})}_renderBackdropGuard(){const t=this._decorAssetGuardReplace;return null!==t?Co(this.host,()=>{},()=>{this.host._backdropGuard=null,this._decorAssetGuardReplace=null},this.host.hass,(e,s)=>this._uploadDecorImage(e,s,t),(this.host._backdropGuard?.file.size||0)<=2097152)??d:Co(this.host,t=>{this.host._spaceDialog&&(this.host._spaceDialog={...this.host._spaceDialog,planFile:t})},()=>{this.host._backdropGuard=null},this.host.hass)??d}_useServerPlan(t){const e=this.host._spaceDialog;e&&(this.host._spaceDialog={...e,planUrl:t,planFile:null,pickSaved:!1,savedAspect:void 0},this.host._aspectJob=this._readPlanAspect(t))}async _readPlanAspect(t){for(let e=0;e<40;e++){const e=this.host._display(t);if(e){const s=await new Promise(t=>{const s=new Image;s.onload=()=>t(s.naturalWidth&&s.naturalHeight?s.naturalWidth/s.naturalHeight:0),s.onerror=()=>t(0),s.src=e}),i=this.host._spaceDialog;return i&&i.planUrl===t&&Number.isFinite(s)&&s>0?(this.host._spaceDialog={...i,savedAspect:s},s):0}if(await new Promise(t=>setTimeout(t,150)),this.host._spaceDialog?.planUrl!==t)return 0}return 0}async _deleteServerPlan(t){const e=this.host._spaceDialog,s=e?.saved?.find(e=>e.name===t);if(!e||!s||s.used_by.length||s.url===e.planUrl)return;const i=await this.host._confirmDanger({key:"delete-plan",kind:"destructive",title:this.host._t("confirm.delete_plan_title"),message:this.host._t("confirm.delete_plan_body"),objectName:t,confirmLabel:this.host._t("btn.delete"),cancelLabel:this.host._t("btn.cancel")}),o=this.host._spaceDialog,a=o?.saved?.find(e=>e.name===t);if(i&&o&&a&&a.url===s.url&&a.modified===s.modified&&!a.used_by.length&&a.url!==o.planUrl)try{await this.host.hass.callWS({type:"houseplan/plans/delete",name:t});const e=this.host._spaceDialog;e?.saved&&(this.host._spaceDialog={...e,saved:e.saved.filter(e=>e.name!==t)})}catch(t){this.host._showToast(this.host._t("toast.plan_delete_failed",{err:this.host._errText(t)}))}}_renderServerPlans(t){if(t.savedBusy)return p`
    ${this.host._t("space.loading")}
    `;const e=t.saved||[];if(!e.length)return p`
    ${this.host._t("space.no_saved")}
    `;return p`
    +
    `:p``}_openingAt(t){if(!this.host._openingsR.length)return null;const e=this.host._openingsR.flatMap(e=>{const s=e.angle*Math.PI/180,i=t[0]-e.rx,o=t[1]-e.ry,a=i*Math.cos(s)+o*Math.sin(s);return Math.abs(a)>e.rlen/2+Wt(12,this.host._cellCm)?[]:[{o:e,localY:-i*Math.sin(s)+o*Math.cos(s)}]});if(!e.length)return null;const s=this.host._spaceModel();if(!s)return null;const i=this.host._openCuts(),o=this.host._openingWallIndexFor(s,i).value;return e.find(({o:t,localY:e})=>{const s="gate"===t.type?!t.flip_v:t.flip_v,i=t.partitionHost||this.host._spaceWalls.length||"gate"===t.type?this.host._openingFace(t,o,!!s):{ox:0,oy:0,cm:0,side:-1},a=Hs({type:t.type,length:t.rlen,angle:t.angle,amount:this.host._openingAmt(t),flipH:!!t.flip_h,flipV:!!t.flip_v,cellCm:this.host._cellCm,gridPitch:this.host._gridPitch,face:i});return Math.abs(e)<=a.hitHalf})?.o||null}_resolveOpeningPlacement(t){const e=this.host._openingPreset;if("opening"!==this.host._tool||!e)return null;const s=this.host._spaceModel();if(!s)return null;const i=this.host._openCuts(),o=this.host._openingWallIndexFor(s,i),a=`${o.key}|partitions:${this.host._cfgEpoch}`;this.host._openingPlacementIntervalsCache&&this.host._openingPlacementIntervalsCache.key===a||(this.host._openingPlacementIntervalsCache={key:a,value:[...O(s.rooms,this.host._spaceWalls,i,this.host._wallKeyPitch,this.host._cellCm,this.host._gridPitch,kd),...Bs(s.partitions,this.host._cellCm,this.host._gridPitch)]}),this.host._openingDimensionContextCache&&this.host._openingDimensionContextCache.key===a||(this.host._openingDimensionContextCache={key:a,value:rd({rooms:s.rooms,walls:this.host._spaceWalls,openCuts:i,partitions:s.partitions,roomOpenings:this.host._roomWallOpeningInputs(),partitionCuts:this._partitionOpeningCuts(s),pitch:this.host._wallKeyPitch,cellCm:this.host._cellCm,gridPitch:this.host._gridPitch,coordScale:kd,epsilon:2e-4*this.host._gridPitch})});const n=Ws({pointer:[t[0],t[1]],preset:e,geometryRevision:this.host._cfgEpoch,renderedLength:this.host._cmToUnits(e.lengthCm),intervals:this.host._openingPlacementIntervalsCache.value,baseTolerance:1.5*this.host._gridPitch,bodyPointerPadding:this._cssPxToRender("touch"===this.host._pointerModality.modality||"pen"===this.host._pointerModality.modality?10:6),gridStep:this.host._gridPitch});this.host._openingJambBlockCm=n.jambBlockedTarget?n.jambBlockedTarget.physicalHalfWidth/this.host._gridPitch*this.host._cellCm:null;const r=n.candidate;if(!r)return null;const l="gate"===r.type?!r.flipV:r.flipV;let h;if(r.host){const t=A({id:"preview",type:r.type,x:r.x/kd,y:r.y/kd,angle:r.angle,length:r.renderedLength/kd,host:r.host},s.partitions,kd,this.host._cellCm,this.host._gridPitch).resolved;h=t?js(t,l):{ox:0,oy:0,cm:0,side:-1}}else h=Gs(o.value,{x:r.x,y:r.y,angle:r.angle,length:r.renderedLength,flip_v:l});const c="mi"===this.host.hass?.config?.unit_system?.length,d=_d(r,this.host._openingDimensionContextCache.value).map(t=>({x:t.label[0],y:t.label[1],text:fe(t.distance/this.host._gridPitch*this.host._cellCm,c),dimension:t}));return{...r,face:h,measure:{labels:d,guide:r.measure.guide}}}_activateOpeningPlacement(t){this._activateMarkupTool("opening"),"opening"===this.host._tool&&(this.host._openingPreset=qs(t,++this.host._openingPresetRevision),this.host._openingHoverCandidate=null,this.host._cursorPt=null)}_clearOpeningPlacement(t){this.host._openingHoverCandidate=null,this.host._openingJambBlockCm=null,t&&(this.host._openingPreset=null,this.host._openingRebindId=null)}_openingClick(t){const e=this.host._spaceModel();if(!e)return;const s=this.host._openingRebindId?null:this._openingAt(t);if(s)return void this._editOpening(s);const i=this.host._openingPreset;if(!i)return;const o=this.host._openingHoverCandidate,a=o&&Us(o,[t[0],t[1]],i.revision,this.host._cfgEpoch)?o:this._resolveOpeningPlacement(t);if(!a){if(null!=this.host._openingJambBlockCm)return void this.host._showToast(this.host._t("opening.partition_jamb_margin",{distance:fe(this.host._openingJambBlockCm,this.host._imperial)}));const s=1.5*this.host._gridPitch,i=R(t,e.rooms,s);return i&&Ks(i.x,i.y,i.angle,this.host._openCuts(),s)?void this.host._showToast(this.host._t("toast.opening_on_zero_wall")):void this.host._showToast(this.host._t("toast.opening_no_wall"))}const n=this.host._openingRebindId?this.host._curSpaceCfg?.openings?.find(t=>t.id===this.host._openingRebindId):null;this.host._openingDialog={...n?{id:n.id,type:n.type,lengthCm:Math.round(n.length*kd/this.host._gridPitch*this.host._cellCm),lengthTouched:!1,contact:n.contact||"",lock:n.lock||"",invert:!!n.invert,flipH:!!n.flip_h,flipV:!!n.flip_v}:{type:a.type,lengthCm:a.lengthCm,contact:"",lock:"",invert:!1,flipH:a.flipH,flipV:a.flipV},...a.host?{host:a.host}:{},x:a.x,y:a.y,angle:a.angle},this.host._openingRebindId=null,this.host._openingHoverCandidate=null,this.host._cursorPt=null}_editOpening(t){this.host._openingDialog={id:t.id,type:t.type,lengthCm:Math.round(t.rlen/this.host._gridPitch*this.host._cellCm),lengthTouched:!1,contact:t.contact||"",lock:t.lock||"",invert:!!t.invert,flipH:!!t.flip_h,flipV:!!t.flip_v,..."partition"===t.host?.kind?{host:{...t.host}}:{},x:t.rx,y:t.ry,angle:t.angle}}_opPointerDown(t,e){if("plan"===this.host._mode&&this.host._spaceModel()&&"resize"!==this.host._tool){t.preventDefault(),t.stopPropagation();try{Md(t)}catch{}this.host._opDrag={id:e.id,moved:!1,sx:t.clientX,sy:t.clientY,dirty:!1,before:this._geometrySnapshot()}}}_opPointerMove(t,e){hr(this.host,"opening",()=>this._opPointerMoveNow(t,e))}_opPointerMoveNow(t,e){if(!this.host._opDrag||this.host._opDrag.id!==e.id)return;if(Math.abs(t.clientX-this.host._opDrag.sx)+Math.abs(t.clientY-this.host._opDrag.sy)<=3)return;const s=this.host._spaceModel();if(!s)return;const i=this._svgPoint(t),o=this.host._curSpaceCfg,a=o?.openings?.find(t=>t.id===e.id);if(!a)return;if("partition"===a.host?.kind){const t=s.partitions.find(t=>t.id===a.host.id);if(!t)return;const e=t.b[0]-t.a[0],o=t.b[1]-t.a[1],n=Math.hypot(e,o);if(!(n>1e-9))return;const r=e/n,l=o/n;if(Math.abs((i[0]-t.a[0])*l-(i[1]-t.a[1])*r)>4*this.host._gridPitch)return;const h=a.length*kd/2+W(t,this.host._cellCm,this.host._gridPitch);let c=(i[0]-t.a[0])*r+(i[1]-t.a[1])*l;if(c=Math.round(c/this.host._gridPitch)*this.host._gridPitch,c=Math.max(h,Math.min(n-h,c)),n<2*h-1e-9)return;const d=c/n,p=(t.a[0]+r*c)/kd,u=(t.a[1]+l*c)/this.host._spaceH;let _=180*Math.atan2(o,e)/Math.PI;_>=90?_-=180:_<-90&&(_+=180);const g=a.host.t!==d||a.x!==p||a.y!==u||a.angle!==_;return this.host._opDrag.moved=!0,g&&(this.host._opDrag.dirty=!0),a.host={...a.host,t:d},a.x=p,a.y=u,a.angle=_,this.host._opMeasure=null,g&&this.host._cfgEpoch++,void this.host.requestUpdate()}const n=R(i,s.rooms,4*this.host._gridPitch);if(!n)return;this.host._opDrag.moved=!0;const r=this._opRuler(n,a.length*kd);this.host._opMeasure=r.measure;const l=r.x/kd,h=r.y/this.host._spaceH,c=a.x!==l||a.y!==h||a.angle!==n.angle;if(c&&(this.host._opDrag.dirty=!0),a.x=l,a.y=h,a.angle=n.angle,Number(this.host._serverCfg?.model_version||0)>=9){const t=$n(a,o?.wall_segments||[]);t?a.host=t:delete a.host}c&&this.host._cfgEpoch++,this.host.requestUpdate()}_opRuler(t,e){const s=this.host._spaceModel()?.rooms||[],i=this.host._gridPitch/2;let o=t.x,a=t.y,n=Vs([o,a],t.angle,e,s,i);if(n&&n.centered&&(o!==n.wallCenter[0]||a!==n.wallCenter[1]))[o,a]=n.wallCenter,n=Vs([o,a],t.angle,e,s,i);else if(n){const[r,l]=n.wallA,[h,c]=n.wallB,d=h-r,p=c-l,u=Math.hypot(d,p);if(u>0){const h=this.host._gridPitch,c=Math.min(e/2,u/2);let _=Math.round(((o-r)*d+(a-l)*p)/u/h)*h;_=Math.max(c,Math.min(u-c,_)),o=r+_/u*d,a=l+_/u*p,n=Vs([o,a],t.angle,e,s,i)||n}}if(!n)return{x:o,y:a,angle:t.angle,measure:null};const r="mi"===this.host.hass?.config?.unit_system?.length,l=(t,e)=>({x:e[0],y:e[1],text:fe(t/this.host._gridPitch*this.host._cellCm,r)});return{x:o,y:a,angle:t.angle,measure:{labels:[l(n.sideA,n.midA),l(n.sideB,n.midB)],guide:n.centered?{x:n.wallCenter[0],y:n.wallCenter[1],angle:t.angle}:null}}}_opPointerUp(t,e){if(!this.host._opDrag||this.host._opDrag.id!==e.id)return;cr(this.host,"opening");const s=this.host._opDrag,i=s.moved;this.host._opMeasure=null,i&&s.dirty&&this._commitPhysicalGeometry(this.host._t("history.move_opening"),s.before);const o=()=>{this.host._opDrag=null,this.host.requestUpdate()};i?window.setTimeout(o,0):o()}_opClick(t,e){"plan"===this.host._mode&&"resize"===this.host._tool||(t.stopPropagation(),this.host._opDrag?.moved||"plan"===this.host._mode&&this._editOpening(e))}_saveOpening(){const t=this.host._openingDialog,e=this.host._curSpaceCfg,s=this.host._spaceModel();if(!t||!e||!s)return;const i=this._geometrySnapshot(),o=this.host._spaceH,a=(e.openings||[]).find(e=>e.id===t.id),n={...a||{},id:t.id||"o"+Date.now().toString(36),type:t.type,x:t.x/kd,y:t.y/o,angle:t.angle,length:a&&!t.lengthTouched?a.length:this.host._cmToUnits(Math.max(20,t.lengthCm))/kd,...t.host?{host:{...t.host}}:{}};if("partition"===n.host?.kind){const t=Js(a,n)?q(n,s.partitions,kd,this.host._cellCm,this.host._gridPitch):A(n,s.partitions,kd,this.host._cellCm,this.host._gridPitch);if(!t.resolved){const e=s.partitions.find(t=>t.id===n.host.id);if("does-not-fit-jamb"===t.reason&&e){const t=W(e,this.host._cellCm,this.host._gridPitch);this.host._showToast(this.host._t("opening.partition_jamb_margin",{distance:fe(t/this.host._gridPitch*this.host._cellCm,this.host._imperial)}))}else this.host._showToast(this.host._t("opening.partition_orphan"));return}const i=(e.openings||[]).flatMap(t=>{if(!t.host||t.id===n.id)return[];const e=A(t,s.partitions,kd,this.host._cellCm,this.host._gridPitch).resolved;return e?[e]:[]});if(Zs(t.resolved,i))return void this.host._showToast(this.host._t("toast.opening_no_wall"));Object.assign(n,E(n,t.resolved,kd))}else if(Number(this.host._serverCfg?.model_version||0)>=9){const t=$n(n,e.wall_segments||[]);if(!t)return void this.host._showToast(this.host._t("toast.opening_no_wall"));n.host=t}else delete n.host;"passage"===t.type?(delete n.contact,delete n.lock,delete n.invert,delete n.flip_h,delete n.flip_v):(n.contact=t.contact||null,n.lock=("door"===t.type||"gate"===t.type)&&t.lock||null,n.invert=t.invert||void 0,n.flip_h="gate"!==t.type&&t.flipH||void 0,n.flip_v=t.flipV||void 0),e.openings=e.openings||[];const r=e.openings.findIndex(t=>t.id===n.id);r>=0?e.openings[r]=n:e.openings.push(n),this._commitPhysicalGeometry(this.host._t(t.id?"history.edit_opening":"history.add_opening"),i),this.host._openingDialog=null,this.host.requestUpdate()}_deleteOpening(){const t=this.host._openingDialog,e=this.host._curSpaceCfg;if(!t?.id||!e?.openings)return;const s=this._geometrySnapshot();e.openings=e.openings.filter(e=>e.id!==t.id),this._commitPhysicalGeometry(this.host._t("history.delete_opening"),s),this.host._openingDialog=null,this.host.requestUpdate()}_contactCandidates(){const t=[];for(const e of Object.keys(this.host.hass.states)){if(!this.host._openingEntityAvailable(e))continue;const s=e.split(".")[0];if("binary_sensor"!==s&&"cover"!==s)continue;const i=this.host.hass.states[e],o=["door","window","opening","garage_door","garage"].includes(i?.attributes?.device_class||"");("cover"!==s||o)&&t.push([e,i?.attributes?.friendly_name||e,o?0:1])}return t.sort((t,e)=>t[2]-e[2]||t[1].localeCompare(e[1])).map(([t,e])=>({value:t,label:e}))}_lockCandidates(){return Object.keys(this.host.hass.states).filter(t=>t.startsWith("lock.")&&this.host._openingEntityAvailable(t)).map(t=>({value:t,label:this.host.hass.states[t]?.attributes?.friendly_name||t})).sort((t,e)=>t.label.localeCompare(e.label))}_toggleOpeningEntityPicker(t){const e=this.host._openingDialog;if(!e)return;const s="contact"===t?!e.contactOpen:!e.lockOpen;this.host._openingDialog={...e,contactOpen:"contact"===t&&s,lockOpen:"lock"===t&&s}}_filterOpeningEntities(t,e){const s=this.host._openingDialog;s&&(this.host._openingDialog="contact"===t?{...s,contactFilter:e}:{...s,lockFilter:e})}_selectOpeningEntity(t,e){const s=this.host._openingDialog;s&&(this.host._openingDialog="contact"===t?{...s,contact:e,contactOpen:!1,contactFilter:""}:{...s,lock:e,lockOpen:!1,lockFilter:""})}_mergeClick(t){const e=this.host._spaceModel();if(!e)return;const s=e.rooms,i=[...s].reverse().find(e=>this._pointInRoom(t,e));if(!i?.id)return;const o=i.id;if(!this.host._mergeSel||this.host._mergeSel===o)return void(this.host._mergeSel=this.host._mergeSel===o?null:o);const a=s.find(t=>t.id===this.host._mergeSel),n=a?N(a):null,r=N(i),l=n&&r?Ys(n,r):null;if(!l)return this.host._showToast(this.host._t("toast.merge_not_adjacent")),void(this.host._mergeSel=null);this.host._mergeDialog={aId:this.host._mergeSel,bId:o,poly:l,pick:"a"},this.host._mergeSel=null}_commitMerge(){const t=this.host._mergeDialog,e=this.host._curSpaceCfg;if(!t||!e||!this.host._spaceModel())return;const s=this._geometrySnapshot(),i=this.host._spaceH,o="a"===t.pick?t.aId:t.bId,a="a"===t.pick?t.bId:t.aId,n=vd(this.host._serverCfg?.markers||[],{kind:"merge",dropId:a,keepId:o});s&&n.changed&&(s.roomReferences=n.before);const r=e.rooms.find(t=>t.id===o);if(!r)return void(this.host._mergeDialog=null);r.poly=t.poly.map(t=>[t[0]/kd,t[1]/i]),delete r.x,delete r.y,delete r.w,delete r.h,e.rooms=e.rooms.filter(t=>t.id!==a),n.changed&&this.host._serverCfg&&(this.host._serverCfg.markers=n.markers);const l=this._commitPhysicalGeometry(this.host._t("history.merge_rooms"),s);this.host._mergeDialog=null,this.host._regSignature="",this.host._maybeRebuildDevices(),l&&this.host._showToast(this.host._t("toast.rooms_merged",{name:r.name||""}))}_splitClick(t){const e=this.host._spaceModel();if(!e)return;const s=e.rooms;if(!this.host._splitSel){const e=[...s].reverse().find(e=>this._pointInRoom(t,e));if(!e?.id)return;return void(this.host._splitSel={roomId:e.id,pts:[]})}const i=s.find(t=>t.id===this.host._splitSel.roomId),o=i?N(i):null;if(!i||!o)return void(this.host._splitSel=null);const a=.02*this.host._gridPitch,n=6*this.host._gridPitch,r=Xs(t,o),l=r&&Qs(r,o,this.host._gridPitch)||r,h=r&&l&&Math.hypot(r[0]-t[0],r[1]-t[1])<=n?l:null,c=!!h&&ti(h,o,a),d=this.host._splitSel.pts;if(!d.length)return c?void(this.host._splitSel={...this.host._splitSel,pts:[h]}):void this.host._showToast(this.host._t("toast.split_pick_wall"));if(!c){const e=this._snap(t);return es(e,o,a)?void(this.host._splitSel={...this.host._splitSel,pts:[...d,e]}):void this.host._showToast(this.host._t("toast.split_pick_inside"))}const p=is(o,[...d,h],a);if(!p)return void this.host._showToast(this.host._t("toast.split_bad_cut"));this._resetRoomDialogFields();const[u,_]=p,g=ae(u)>=ae(_)?u:_,m=g===u?_:u;this.host._pendingSplit={roomId:i.id,mainPoly:g,newPoly:m},this.host._cursorPt=null,this.host._nameSel="",this.host._areaSel="",this.host._roomDialog=!0}_markupMove(t){if(!this.host._markup)return;if("column"===this.host._tool)return void(this.host._cursorPt=this._snap(this._svgPoint(t)));if("opening"===this.host._tool||"wallthick"===this.host._tool)return void(this.host._cursorPt=this._svgPoint(t));const e="draw"===this.host._tool&&!this.host._contourClosed,s="split"===this.host._tool&&!!this.host._splitSel?.pts?.length;if(!e&&!s)return;const i=this._svgPoint(t);if(e){const e=this._resolvePlanDrawPoint(i,t.shiftKey);if(this.host._planSnapHover={contextKey:e.contextKey,candidate:e.candidate,conflicts:e.conflicts},this._syncPlanSnapConflictMarkers(e.conflicts),this._syncPlanSnapActiveMarker(e.candidate),!this.host._path.length)return;return void(this.host._cursorPt=e.point)}this.host._cursorPt=this._snap(i)}_saveRoom(){(this.host._areaSel||this.host._nameSel.trim())&&zt(this.host._roomTempMin,this.host._roomTempMax).valid&&(this.host._wallFaceBatch?this._decideWallFace(!0):this._commitRoom())}_decideWallFace(t){const e=this.host._wallFaceBatch;if(!e)return;const s=e.candidates[e.index];if(!s)return;if(!t&&(s.existing||s.repair)&&1===e.candidates.length)return this.host._wallFaceBatch=null,this.host._roomDialog=!1,this.host._nameSel="",this.host._areaSel="",void this.host.requestUpdate();const i=t?{candidate:s,create:!0,name:this.host._nameSel.trim(),area:this.host._areaSel||null,settings:this._roomSettingsFromDialog()?JSON.parse(JSON.stringify(this._roomSettingsFromDialog())):null}:{candidate:s,create:!1},o=[...e.decisions,i],a=e.index+1;if(a"number"==typeof t&&Number.isFinite(t)&&t>=0?t:null,o=.02*this.host._gridPitch,a=this.host._spaceModel();if(!a)return H;for(const e of this._planSnapGeometrySnapshot().value.segments)if(!("room"===e.sourceKind||ye(t,[e.a[0],e.a[1],e.b[0],e.b[1]])>o)&&"partition"===e.sourceKind)return i(a.partitions.find(t=>t.id===e.sourceId)?.cm)??H;const n=ic(Math.max(0,e.length-1),s,this.host._drawWallCm,H);for(let s=0;s+1[...t]);if(!e)return s;const i=this.host._activeWallChainPartitionIds.findIndex((t,s)=>this._activeWallSourceKey(s)===e.sourceKey),o=i>=0?i+("b"===e.endpoint?1:0):-1;return o>=0&&oe.key===t.sourceKey),a=i.find(e=>e.key===t.targetSourceKey);if(!o||!a)return!1;const n="a"===t.endpoint?o.a:o.b;return!(Math.hypot(n[0]-t.from[0],n[1]-t.from[1])>s)&&(!(ye(t.to,[a.a[0],a.a[1],a.b[0],a.b[1]])>s)&&!function(t,e){if(!t.sourceKey.startsWith("static:partition|"))return!1;const s=t.sourceKey.slice(17).split("|")[0];return!!s&&e.some(t=>"partition"===t.host?.kind&&t.host.id===s)}(t,this.host._curSpaceCfg?.openings||[]))}_applyWallRepair(t,e){const s=this.host._curSpaceCfg;if(!s||!this._validateWallRepair(t,e.activePath))return!1;if(!t.sourceKey.startsWith("static:"))return!1;const[i,o]=t.sourceKey.slice(7).split("|");if("partition"===i){const i=(s.partitions||[]).find(t=>t.id===o);if(!i)return!1;const a=[i.a[0]*kd,i.a[1]*kd],n=[i.b[0]*kd,i.b[1]*kd],r=Math.hypot(a[0]-t.from[0],a[1]-t.from[1])<=2e-4*this.host._gridPitch?i.a:Math.hypot(n[0]-t.from[0],n[1]-t.from[1])<=2e-4*this.host._gridPitch?i.b:null;if(!r)return!1;(e=>{e[0]=t.to[0]/kd,e[1]=t.to[1]/kd})(r);const l=e.activePartitionIds.indexOf(o);if(l>=0){const s=l+("b"===t.endpoint?1:0);e.activePath[s]&&(e.activePath[s]=[...t.to])}return!0}return!1}_applyWallFaceBatch(){const t=this.host._wallFaceBatch,e=this.host._curSpaceCfg,s=this.host._spaceModel();if(!t||!e||!s)return;const i=(t,e)=>{this.host._showToast(this.host._t(t,e)),this._roomDialogCancel()},o=t.decisions.filter(t=>t.create),a=o.map(t=>t.candidate.ring),n=s.rooms;for(let t=0;ts.id!==e&&!!N(s)&&ie(a[t],N(s)));if(s)return void i("toast.room_overlap",{name:s.name||""})}if((e.rooms||[]).length+o.length>400)return void i("toast.physical_limit");if(o.some(t=>t.candidate.split&&!e.rooms.some(e=>e.id===t.candidate.split.roomId)))return void i("toast.contour_cannot_close");const r=o.map(t=>t.candidate.repair).filter(t=>!!t);if(r.length>1||r[0]&&!this._validateWallRepair(r[0],t.activePath))return void i("toast.wall_repair_changed");if(this._activePathWithRepair(t.activePath,r[0]),!o.length){if(!this._finalizeWallChainPartitions(t.activePartitionIds))return;return this.host._path=[],this.host._activeWallChainId=null,this.host._activeWallChainPartitionIds=[],this.host._wallChainSegmentCms=[],this.host._wallChainRedo=[],this.host._closingWallCm=null,this.host._wallFaceBatch=null,this.host._roomDialog=!1,this.host._nameSel="",this.host._areaSel="",this.host.requestUpdate(),void this.host._showToast(this.host._t("toast.wall_chain_saved"))}const l=new Set(t.activePartitionIds),h=2e-4*this.host._gridPitch,c=o.map(t=>t.candidate.ring.map((t,e,i)=>{const o=i[(e+1)%i.length],a=s.partitions.filter(e=>{const s=Math.hypot(e.b[0]-e.a[0],e.b[1]-e.a[1]);if(!(s>h))return!1;const i=(e.b[0]-e.a[0])/s,a=(e.b[1]-e.a[1])/s,n=t=>(t[0]-e.a[0])*i+(t[1]-e.a[1])*a;return ye(t,[e.a[0],e.a[1],e.b[0],e.b[1]])<=h&&ye(o,[e.a[0],e.a[1],e.b[0],e.b[1]])<=h&&n(t)>=-h&&n(t)<=s+h&&n(o)>=-h&&n(o)<=s+h});return a.sort((t,e)=>Number(l.has(e.id))-Number(l.has(t.id))||Math.hypot(t.b[0]-t.a[0],t.b[1]-t.a[1])-Math.hypot(e.b[0]-e.a[0],e.b[1]-e.a[1])||t.id.localeCompare(e.id)),a[0]?.id||""})),d=this._geometrySnapshot();if(!d)return void i("toast.geometry_unsafe");const p=()=>{this._restoreGeometryStateLocal(d),i("toast.geometry_unsafe")};if(r[0]&&!this._applyWallRepair(r[0],t))return void i("toast.wall_repair_changed");const u=o.some(t=>!!t.candidate.split),_=u?Ae(s.rooms,e.walls,this.host._openCuts(),this.host._wallKeyPitch,this.host._cellCm,this.host._gridPitch,kd):null,g=u&&Array.isArray(e.walls)?e.walls:null;for(const t of o){const s=t.candidate.split;if(!s)continue;const i=e.rooms.find(t=>t.id===s.roomId);if(!i)return void p();i.poly=s.mainPoly.map(t=>[t[0]/kd,t[1]/this.host._spaceH]),delete i.x,delete i.y,delete i.w,delete i.h}const m=Date.now().toString(36),f=[];if(o.forEach((t,s)=>{const i=t.area?this.host.hass.areas[t.area]?.name:"",o={id:`r${m}-${s}`,name:t.name||i||this.host._t("room.default_name"),area:t.area||null,poly:t.candidate.ring.map(t=>[t[0]/kd,t[1]/this.host._spaceH]),...c[s].some(Boolean)?{wall_ids:c[s]}:{},...t.settings?{settings:JSON.parse(JSON.stringify(t.settings))}:{}};e.rooms.push(o),f.push({room:o,decision:t})}),u){const t=this.host._normalizeWalls(_,this.host._openCuts());t.length?e.walls=t:g?.length?e.walls=g:delete e.walls}if(f.length){this.host._cfgEpoch++;const s=this.host._openCuts(),i=this.host._spaceModel();if(!i)return void p();let o=e.walls;for(const{room:e,decision:a}of f){const n=a.candidate.ring,r=this._wallSourceCmAt(n[0],t.activePath,t.activeCms);o=ei(o,i.rooms,e.id,r,this.host._wallKeyPitch,s,kd);for(const a of O(i.rooms,o,s,this.host._wallKeyPitch,this.host._cellCm,this.host._gridPitch,kd)){if(a.roomId!==e.id||"outer"!==a.kind)continue;const s=[(a.a[0]+a.b[0])/2,(a.a[1]+a.b[1])/2];o=j(o,a.a,a.b,this._wallSourceCmAt(s,t.activePath,t.activeCms),this.host._wallKeyPitch,kd)}}const a=this.host._normalizeWalls(o,s);a.length?e.walls=a:delete e.walls,this.host._cfgEpoch++;const n=this.host._spaceModel();if(!n)return void p();const r=Ua(e,n,e.walls,s,{pitch:this.host._wallKeyPitch,cellCm:this.host._cellCm,gridPitch:this.host._gridPitch,coordScale:kd,allowCoincidentPartitions:!0});r.walls.length?e.walls=r.walls:delete e.walls,r.partitions.length?e.partitions=r.partitions:delete e.partitions,r.openings.length?e.openings=r.openings:delete e.openings}if(!this._commitPhysicalGeometry(this.host._t("history.wall_face_batch"),d))return;this.host._path=[],this.host._activeWallChainId=null,this.host._activeWallChainPartitionIds=[],this.host._wallChainSegmentCms=[],this.host._wallChainRedo=[],this.host._closingWallCm=null,this.host._wallFaceBatch=null,this.host._roomDialog=!1,this.host._nameSel="",this.host._areaSel="",this.host._regSignature="",this.host._maybeRebuildDevices();const b=new Set(o.map(t=>t.area).filter(t=>!!t));if(b.size){const t={...this.host._layout};for(const e of this.host._devices){if(!b.has(e.area||"")||e.space!==this.host._space)continue;if(this.host._layout[e.id])continue;const s=this.host._defPos[e.id];s&&(t[e.id]={s:this.host._space,x:s.x/kd,y:s.y/kd},this.host._dirtyPos.add(e.id))}this.host._layout=t,this.host._persistLayout()}this.host._showToast(this.host._t(o.length?"toast.wall_rooms_saved":"toast.wall_chain_saved",{n:o.length}))}_commitRoom(){const t=this.host._curSpaceCfg,e=this.host._spaceModel();if(!t||!e)return;const s=this._geometrySnapshot();if(!s)return;const i=()=>{this._restoreGeometryStateLocal(s),this.host._showToast(this.host._t("toast.geometry_unsafe"))},o=this.host._spaceH,a=!!this.host._pendingSplit,n=a?Ae(e.rooms,t.walls,this.host._openCuts(),this.host._wallKeyPitch,this.host._cellCm,this.host._gridPitch,kd):null,r=a&&Array.isArray(t.walls)?t.walls:null;let l;if(this.host._pendingSplit){const e=t.rooms.find(t=>t.id===this.host._pendingSplit.roomId);if(!e)return this.host._pendingSplit=null,this.host._splitSel=null,void(this.host._roomDialog=!1);e.poly=this.host._pendingSplit.mainPoly.map(t=>[t[0]/kd,t[1]/o]),delete e.x,delete e.y,delete e.w,delete e.h,l=this.host._pendingSplit.newPoly}else{if(!this.host._contourClosed)return;l=this.host._path.slice(0,-1)}const h=this.host._areaSel?this.host.hass.areas[this.host._areaSel]?.name:"",c={id:"r"+Date.now().toString(36),name:this.host._nameSel||h||this.host._t("room.default_name"),area:this.host._areaSel||null,poly:l.map(t=>[t[0]/kd,t[1]/o]),...this._roomSettingsFromDialog()?{settings:this._roomSettingsFromDialog()}:{}};if(t.rooms.push(c),a){const e=this.host._normalizeWalls(n,this.host._openCuts());e.length?t.walls=e:r?.length?t.walls=r:delete t.walls}if(!a){const e=ic(l.length,[...this.host._wallChainSegmentCms,this.host._closingWallCm??void 0],this.host._drawWallCm,H),s=e[0];if(null!=s){this.host._cfgEpoch++;const o=this.host._openCuts(),a=this.host._spaceModel();if(!a)return void i();let n=ei(t.walls,a.rooms,c.id,s,this.host._wallKeyPitch,o,kd);for(const t of O(a.rooms,n,o,this.host._wallKeyPitch,this.host._cellCm,this.host._gridPitch,kd)){if(t.roomId!==c.id||"outer"!==t.kind)continue;const s=[(t.a[0]+t.b[0])/2,(t.a[1]+t.b[1])/2],i=l.findIndex((t,e)=>{const i=l[(e+1)%l.length];return ye(s,[t[0],t[1],i[0],i[1]])<=.02*this.host._gridPitch});i>=0&&(n=j(n,t.a,t.b,e[i],this.host._wallKeyPitch,kd))}n=this.host._normalizeWalls(n,o),n.length?t.walls=n:delete t.walls;const r=this.host._spaceModel();if(!r)return void i();const h=Ua(t,r,t.walls,o,{pitch:this.host._wallKeyPitch,cellCm:this.host._cellCm,gridPitch:this.host._gridPitch,coordScale:kd,allowCoincidentPartitions:!0});h.walls.length?t.walls=h.walls:delete t.walls,h.partitions.length?t.partitions=h.partitions:delete t.partitions,h.openings.length?t.openings=h.openings:delete t.openings}}const d=this._commitPhysicalGeometry(this.host._t(a?"history.split_room":"history.add_room"),s);this.host._path=[],this.host._activeWallChainId=null,this.host._activeWallChainPartitionIds=[],this.host._wallChainSegmentCms=[],this.host._wallChainRedo=[],this.host._closingWallCm=null,this.host._pendingSplit=null,this.host._splitSel=null;const p=this.host._areaSel;if(this.host._areaSel="",this.host._nameSel="",this.host._roomDialog=!1,this.host._regSignature="",this.host._maybeRebuildDevices(),!d)return;let u=0;if(p){const t=kd,e={...this.host._layout};for(const s of this.host._devices){if(s.area!==p||s.space!==this.host._space)continue;if(u++,this.host._layout[s.id])continue;const i=this.host._defPos[s.id];i&&(e[s.id]={s:this.host._space,x:i.x/kd,y:i.y/t},this.host._dirtyPos.add(s.id))}this.host._layout=e,this.host._persistLayout()}const _=this.host._model.find(t=>t.id===this.host._space)?.rooms.length||0;this.host._showToast(p?this.host._t("toast.room_saved",{n:_,added:u}):this.host._t("toast.room_saved_no_area",{n:_}))}_cancelPath(){this.host._wallRepairDiagnostic=null,this.host._path=[],this.host._activeWallChainId=null,this.host._activeWallChainPartitionIds=[],this.host._wallChainSegmentCms=[],this.host._wallChainRedo=[],this.host._closingWallCm=null,this._clearPlanSnapHover(),this.host._roomDialog=!1,this.host._pendingSplit=null,this.host._wallFaceBatch=null,this.host._splitSel=null,this.host._mergeSel=null,this.host._mergeDialog=null,this.host._physicalSel=null,this.host._physicalDrag=null,this.host._physicalRotate=null,this._clearOpeningPlacement(!0)}_roomDialogCancel(){if(this.host._roomDialog=!1,this.host._roomEditId)return this.host._roomEditId=null,this.host._nameSel="",void(this.host._areaSel="");if(this.host._wallFaceBatch){const t=this.host._wallFaceBatch;return this.host._wallFaceBatch=null,this.host._path=t.activePath.map(t=>[...t]),this.host._wallChainSegmentCms=[...t.activeCms],this.host._activeWallChainPartitionIds=[...t.activePartitionIds],this.host._activeWallChainId||=`chain-${Date.now().toString(36)}`,this.host._nameSel="",this.host._areaSel="",void this.host.requestUpdate()}if(this.host._pendingSplit)return this.host._pendingSplit=null,void(this.host._splitSel=null);this.host._undoPoint()}_openDeviceInbox(){this.host._deviceInboxReturn=null,this.host._deviceInbox=this.host._deviceInbox||{tab:"on_plan",search:"",showEntities:!1,onlyNew:!1,limit:100}}_closeMarkerDialog(){this._radarSetup.isDirty()?this._closeMarkerDialogGuarded():(this._radarSetup.reset(),function(t){if(t._markerDialog=null,!t._deviceInboxReturn)return;const e={...t._deviceInboxReturn};t._deviceInbox=e,t._deviceInboxReturn=null,e.anchor&&t.updateComplete.then(()=>requestAnimationFrame(()=>{const s=`.device-inbox-row[data-binding="${CSS.escape(e.anchor)}"]`;t.renderRoot.querySelector(s)?.scrollIntoView({block:"nearest"})}))}(this.host))}async _closeMarkerDialogGuarded(){if(!await this._radarSetup.discardIfAllowed())return await this.host.updateComplete,void this.host.renderRoot.querySelector("#marker-dialog")?.rejectClose();this._closeMarkerDialog()}_deviceInboxCandidates(t){return Th({hass:this.host._planHass,devices:this.host._devices,markers:this.host._markers,showEntities:t,labels:{device:this.host._t("marker.sub_device"),z2mGroup:this.host._t("marker.sub_z2m_group"),group:this.host._t("marker.sub_group"),helper:this.host._t("marker.sub_helper"),entity:this.host._t("marker.sub_entity")}})}_deviceInboxRows(){const t=this.host._deviceInbox||this.host._deviceInboxReturn,e=!!t?.showEntities,s=[this.host._haRegistry.revision,this.host._cfgRev,this.host._cfgEpoch,this.host._regSignature,this.host._newSyncKey,e?1:0,this.host._showAll?1:0,l(this.host.hass,this.host._config?.language)].join("|");if(this.host._deviceInboxMemo?.key===s)return this.host._deviceInboxMemo.rows;const i=this._deviceInboxCandidates(e),o=new Set(i.map(t=>t.value));for(const t of this.host._markers)t.binding&&"virtual"!==t.binding&&o.add(t.binding);for(const t of this.host._devices)t.bindingKind&&"virtual"!==t.bindingKind&&t.bindingRef&&o.add(`${t.bindingKind}:${t.bindingRef}`);const a=new Map;for(const t of o)a.set(t,this.host._bindingStatus(t));const n=this.host._areaToSpace,r={};for(const[t,e]of Object.entries(this.host.hass?.areas||{}))r[t]=n[t]?.room?.name||e?.name||t;for(const[t,e]of Object.entries(n))r[t]=e.room.name||r[t]||t;const h=Object.fromEntries(this.host._model.map(t=>[t.id,t.title])),c=Object.fromEntries(Object.entries(n).map(([t,e])=>[t,e.space])),d={},p=new Map;for(const[t,e]of Object.entries(this.host._fullRegistryHass.entities||{})){const s=String(e?.platform||"").trim();if(s&&(d[`entity:${t}`]=s),s&&e?.device_id){const t=p.get(e.device_id)||new Set;t.add(s),p.set(e.device_id,t)}}for(const[t,e]of p)d[`device:${t}`]=[...e].sort().join(", ");const u={};for(const[t,e]of Object.entries(this.host._fullRegistryHass.devices||{})){const s=`device:${t}`,i=p.get(t)||new Set,o=Array.isArray(e?.identifiers?.[0])?String(e.identifiers[0][0]||""):"";o&&!d[s]&&(d[s]=o);const a=[o,...i].some(t=>this.host._excluded.has(t));"service"===e?.entry_type?u[s]="service_entry":a?u[s]="excluded_integration":"Group"===e?.model?u[s]="grouped_light":/scene/i.test(e?.model||"")?u[s]="excluded_domain":(/bridge/i.test(`${e?.model||""}${e?.name||""}`)||"myheat"===o&&e?.via_device_id)&&(u[s]="represented_by_parent")}const _=function(t){const{devices:e,markers:s,candidates:i,statuses:o,newDeviceIds:a,showHiddenOnPlan:n,areaNames:r={},spaceNames:l={},spaceByArea:h={},integrationByBinding:c={},reasonByBinding:d={}}=t,p=new Map;for(const t of e)!t.virtual&&t.bindingKind&&"virtual"!==t.bindingKind&&t.bindingRef&&p.set(`${t.bindingKind}:${t.bindingRef}`,t);const u=new Map,_=new Map;for(const t of s)t?.binding&&"virtual"!==t.binding&&(t.removed?_.set(t.binding,t):u.set(t.binding,t));const g=new Map(i.map(t=>[t.value,t])),m=new Set([...p.keys(),...u.keys(),...g.keys(),...[..._.keys()].filter(t=>g.has(t))]),f=[];for(const t of m){const e=p.get(t),s=u.get(t),i=s?void 0:_.get(t),m=g.get(t);let b;if(i&&m)b="readd";else if(!0===s?.hidden)b="hidden";else if(e||s)b="on_plan";else{if(!m)continue;b="available"}const v=e?.bindingStatus||o.get(t)||Rh,y=s||i,$=zh(t),w=e?.area||m?.areaId||y?.area||"",k=e?.space||y?.space||h[w]||"",x=e?.name||y?.name||m?.label||t,M=e?.model||y?.model||m?.model||"",C=!!m?.parentDeviceId&&p.has(`device:${m.parentDeviceId}`),S="readd"===b?"removed":"hidden"===b?s&&Fh(s)?d[t]||"automatic_hidden":"manual_hidden":"on_plan"===b?s?"visible_explicit":"visible_auto":d[t]||(C?"represented_by_parent":w&&k?"available":"no_bound_room"),P=!!e&&(!e.hidden||n),D="active"===v.kind,I=P&&(D||"ha_disabled"===v.kind&&n),L=[x,M,c[t],r[w],l[k],t,m?.sub].filter(Boolean).join(" ").toLocaleLowerCase();f.push({key:t,binding:t,category:b,status:v,reason:S,deviceId:e?.id,markerId:y?.id,name:x,icon:e?.icon||y?.icon||("entity"===$?"mdi:code-braces":"mdi:devices"),model:M,integration:c[t]||"",areaId:w,areaName:r[w]||"",spaceId:k,spaceName:l[k]||"",kind:$,isNew:!!e&&a.has(e.id),searchText:L,canFind:I,canEdit:!!e||!!s,canHide:"on_plan"===b&&D,canShow:"hidden"===b&&D,canAdd:("available"===b||"readd"===b)&&D})}const b=t=>"active"===t.status.kind?1:0;return f.sort((t,e)=>t.category.localeCompare(e.category)||Number(e.isNew)-Number(t.isNew)||b(t)-b(e)||t.name.localeCompare(e.name)||t.binding.localeCompare(e.binding))}({devices:this.host._devices,markers:this.host._markers,candidates:i,statuses:a,newDeviceIds:this.host._newIds,showHiddenOnPlan:this.host._showAll,areaNames:r,spaceNames:h,spaceByArea:c,integrationByBinding:d,reasonByBinding:u});return this.host._deviceInboxMemo={key:s,rows:_},_}_deviceForInboxRow(t){const e=t.deviceId?this.host._devices.find(e=>e.id===t.deviceId):null;if(e)return e;const s=t.markerId?this.host._markers.find(e=>e.id===t.markerId):null;return!s||s.removed?null:{id:s.id,name:t.name,model:t.model,area:t.areaId,space:t.spaceId||this.host._space,hidden:!0===s.hidden||"ha_disabled"===t.status.kind,userHidden:!0===s.hidden,bindingStatus:t.status,icon:t.icon,entities:"active"===t.status.kind?t.status.enabledEntityIds:[],allEntities:t.status.allEntityIds,primary:"active"===t.status.kind?t.status.enabledEntityIds[0]:void 0,marker:s,bindingKind:t.kind,bindingRef:t.binding.slice(t.binding.indexOf(":")+1),pdfs:s.pdfs||[]}}_openInboxMarker(t,e=!1){const s=this.host._deviceInbox;if(s){if(this.host._deviceInboxReturn={...s,anchor:t.key},this.host._deviceInbox=null,!e){const e=this._deviceForInboxRow(t);return void(e?this._openMarkerDialog(e):this._closeMarkerDialog())}this._openMarkerDialog(),this.host._markerDialog?this.host._markerDialog={...this.host._markerDialog,bindingMode:"ha",binding:t.binding,bindingOpen:!1,showEntities:"entity"===t.kind,name:""}:this._closeMarkerDialog()}}async _setInboxHidden(t,e){const s=this.host._deviceInbox,i=this.host._serverCfg;if(!s||!i||s.busy||"active"!==t.status.kind)return;const o=i.markers||[],a=o.find(e=>!e.removed&&e.binding===t.binding);if(!e&&!a)return;const n=a?.id||si(t.binding,t.markerId,()=>`m_${Date.now().toString(36)}`),r=a?{...a,hidden:e}:{id:n,binding:t.binding,hidden:!0};i.markers=[...o.filter(e=>e.id!==n&&(e.binding!==t.binding||!0===e.removed)),r],this.host._deviceInbox={...s,busy:t.key,anchor:t.key};try{await this._saveConfigNow(),this.host._regSignature="",this.host._deviceInboxMemo=null,this.host._maybeRebuildDevices(),this.host._deviceInbox&&(this.host._deviceInbox={...this.host._deviceInbox,busy:void 0}),this.host._showToast(this.host._t("device_inbox.saved"))}catch(t){this.host._serverCfg===i&&(i.markers=o),this.host._deviceInbox&&(this.host._deviceInbox={...this.host._deviceInbox,busy:void 0}),this.host._showToast(this.host._t("toast.error",{err:this.host._errText(t)}))}}_findInboxDevice(t){if(!t.canFind)return;const e=this._deviceForInboxRow(t);if(!e)return;if(this.host._deviceInbox=null,e.space&&e.space!==this.host._space){if(!this.host._commitSpace(e.space))return;this.host._restoreZoom()}const s=()=>{const t=this.host._devices.find(t=>t.id===e.id)||e,s=this.host._pos(t);this.host._applyView(this.host._zoom,s.x,s.y),this.host._selId=t.id,this.host.requestUpdate(),window.setTimeout(()=>{this.host._selId===t.id&&(this.host._selId=null,this.host.requestUpdate())},1500)};requestAnimationFrame(()=>requestAnimationFrame(s))}_openMarkerDialog(t){if(this.host._vacAllCamerasFor=null,this.host._vacAllCameraCache=null,t&&this.host._ackNewDevice(t.id),this.host._norm)if(t){const e=t.marker,s=Object.prototype.hasOwnProperty.call(e||{},"is_light"),i=Object.prototype.hasOwnProperty.call(e||{},"light_entity"),o=Object.prototype.hasOwnProperty.call(e||{},"glow_color"),a=Object.prototype.hasOwnProperty.call(e||{},"value_badge"),n=Object.prototype.hasOwnProperty.call(e||{},"value_source"),r=Object.prototype.hasOwnProperty.call(e||{},"tap_action"),l=Object.prototype.hasOwnProperty.call(e||{},"toggle_entity"),h=ii(e?.glow_color),c=this.host._devicePresentation(t,!0).valueBadge,d=m(this.host._planHass,t,this.host._devices),p=f(this.host._planHass,t,d),u=ra(t,this.host._fullRegistryHass),_=this.host._spaceModelById(t.space)||this.host._spaceModel(),g=this.host._pos(t),b=_?ha(t,_,[g.x,g.y],this.host._fullRegistryHass):null;this.host._markerDialog={devId:t.id,name:t.name,binding:"virtual"===t.bindingKind?"virtual":t.bindingKind+":"+t.bindingRef,bindingMode:"virtual"===t.bindingKind?"virtual":"ha",bindingOpen:!1,showEntities:"entity"===t.bindingKind&&!!this.host._fullRegistryHass.entities[t.bindingRef||""]?.device_id,bindingFilter:"",icon:t.marker?.icon||"",autoIcon:t.icon||"",display:S(t.marker?.display),rippleColor:qt(t.marker?.ripple_color,""),rippleSize:Number(t.marker?.ripple_size)>0?Number(t.marker.ripple_size):1.5,size:Number(t.marker?.size)>0?Number(t.marker.size):1,angle:Number(t.marker?.angle)||0,tapAction:oi(t.marker?.tap_action,t.primary?.split(".")[0]),tapActionTouched:!1,originalHasTapAction:r,originalTapAction:t.marker?.tap_action,tapHintAnnouncement:"",toggleEntity:e?.toggle_entity||"",toggleEntityTouched:!1,originalHasToggleEntity:l,originalToggleEntity:e?.toggle_entity,tapTarget:t.marker?.tap_target||"",tapConfirm:!0===t.marker?.tap_confirm,runFilter:"",controls:x(t.marker?.binding,t.marker?.controls,t.entities),controlsFilter:"",lightRole:!0===e?.is_light?"always":!1===e?.is_light?"never":"auto",lightRoleTouched:!1,originalHasIsLight:s,originalIsLight:e?.is_light,lightEntity:e?.light_entity||"",lightEntityTouched:!1,originalHasLightEntity:i,originalLightEntity:e?.light_entity,glowMode:null!=h?.bri?"fixed":h?"color":"auto",glowColor:h?.c||this.host._fillColors.glow_light.c,glowBrightness:Math.max(1,Math.round(100*(h?.bri??1))),glowColorDrafted:!!h,glowBrightnessDrafted:null!=h?.bri,glowTouched:!1,originalHasGlowColor:o&&(!!h||null===e?.glow_color),originalGlowColor:h||(null===e?.glow_color?null:void 0),valueBadgeEnabled:a?!0===e?.value_badge?.enabled:!!c,valueBadgeSource:e?.value_badge?.source||c?.source||p,valueBadgePosition:e?.value_badge?.position||c?.position||"right",valueBadgeTouched:!1,originalHasValueBadge:a,originalValueBadge:e?.value_badge,valueSource:e?.value_source||null,valueSourceTouched:!1,originalHasValueSource:n,originalValueSource:e?.value_source,useClimateTemp:!0===t.marker?.use_climate_temp,glowRadius:Number(t.marker?.glow_radius_cm)>0?String(this.host._imperial?Math.round(Number(t.marker.glow_radius_cm)/30.48*10)/10:Math.round(Number(t.marker.glow_radius_cm))/100):"",model:t.model||"",link:t.link||"",description:t.description||"",pdfs:[...t.pdfs||[]],room:t.marker?.room_id?t.space+"#@"+t.marker.room_id:t.space&&t.area?t.space+"#"+t.area:"",roomTouched:!1,radar:b,radarEligible:u.eligible,radarTouched:!1,radarRemove:!1,hideFromPlan:!0===t.marker?.hidden,busy:!1}}else this.host._markerDialog={name:"",binding:"virtual",bindingMode:"virtual",bindingOpen:!1,showEntities:!1,bindingFilter:"",icon:"",autoIcon:"",display:"badge",rippleColor:"",rippleSize:1.5,size:1,angle:0,tapAction:"info",tapActionTouched:!1,originalHasTapAction:!1,originalTapAction:void 0,tapHintAnnouncement:"",toggleEntity:"",toggleEntityTouched:!1,originalHasToggleEntity:!1,originalToggleEntity:void 0,tapTarget:"",tapConfirm:!1,runFilter:"",controls:[],controlsFilter:"",lightRole:"auto",lightRoleTouched:!1,originalHasIsLight:!1,originalIsLight:void 0,lightEntity:"",lightEntityTouched:!1,originalHasLightEntity:!1,originalLightEntity:void 0,glowMode:"auto",glowColor:this.host._fillColors.glow_light.c,glowBrightness:100,glowColorDrafted:!1,glowBrightnessDrafted:!1,glowTouched:!1,originalHasGlowColor:!1,originalGlowColor:void 0,valueBadgeEnabled:!1,valueBadgeSource:null,valueBadgePosition:"right",valueBadgeTouched:!1,originalHasValueBadge:!1,originalValueBadge:void 0,valueSource:null,valueSourceTouched:!1,originalHasValueSource:!1,originalValueSource:void 0,useClimateTemp:!1,glowRadius:"",model:"",link:"",description:"",pdfs:[],room:"",roomTouched:!1,radar:null,radarEligible:!1,radarTouched:!1,radarRemove:!1,hideFromPlan:!1,busy:!1,uploadId:"up_"+Date.now().toString(36)+Math.random().toString(36).slice(2,6)};else this.host._showToast(this.host._t("toast.marker_needs_server"))}_runCandidates(){const t=[];for(const e of ai)for(const[s,i]of Object.entries(this.host.hass.states))s.startsWith(e+".")&&this.host._planEntityAvailable(s)&&t.push({value:s,label:i?.attributes?.friendly_name||s,sub:this.host._t("run."+e)});return t.sort((t,e)=>t.sub.localeCompare(e.sub)||t.label.localeCompare(e.label))}_bindingCandidates(){const t=Th({hass:this.host._planHass,devices:this.host._devices,markers:this.host._markers,showEntities:!!this.host._markerDialog?.showEntities,currentBinding:this.host._markerDialog?.binding,currentDeviceId:this.host._markerDialog?.devId,labels:{device:this.host._t("marker.sub_device"),z2mGroup:this.host._t("marker.sub_z2m_group"),group:this.host._t("marker.sub_group"),helper:this.host._t("marker.sub_helper"),entity:this.host._t("marker.sub_entity")}}),e=(this.host._markerDialog?.bindingFilter||"").toLowerCase().trim(),s=e?t.filter(t=>(t.label+" "+t.sub+" "+t.value).toLowerCase().includes(e)):t;return s.sort((t,e)=>t.label.localeCompare(e.label)),s.slice(0,200)}_backupErrorText(t){const e=t?.code??t?.error;if("string"==typeof e){const t=`backup.error.${e}`,s=this.host._t(t);if(s!==t)return s}return this.host._errText(t)}async _pickMarkerFiles(t){const e=t.target,s=e.files?[...e.files]:[];if(e.value="",!s.length||!this.host._markerDialog)return;const i=this.host._markerDialog.uploadId||this.host._markerDialog.devId||"new",o=[];for(const t of s)try{const e=new FormData;e.append("marker_id",i),e.append("file",t,t.name);const s=this.host.hass?.fetchWithAuth?await this.host.hass.fetchWithAuth("/api/houseplan/upload",{method:"POST",body:e}):await fetch("/api/houseplan/upload",{method:"POST",body:e,headers:this.host.hass?.auth?.data?.access_token?{authorization:`Bearer ${this.host.hass.auth.data.access_token}`}:{}}),a=await s.json().catch(()=>({}));if(!s.ok||a.error){const t={too_large:this.host._t("err.too_large",{mb:a.max_mb||50}),bad_ext:this.host._t("err.bad_ext"),unauthorized:this.host._t("err.unauthorized")};throw new Error(t[a.error]||a.error||"HTTP "+s.status)}o.push({name:a.name||t.name,url:a.url})}catch(e){this.host._showToast(this.host._t("toast.file_failed",{name:t.name,err:this.host._errText(e)}))}o.length&&this.host._markerDialog&&(this.host._markerDialog={...this.host._markerDialog,pdfs:[...this.host._markerDialog.pdfs,...o]},this.host._showToast(this.host._t("toast.files_attached",{n:o.length})))}_removeMarkerPdf(t){this.host._markerDialog&&(this.host._markerDialog={...this.host._markerDialog,pdfs:this.host._markerDialog.pdfs.filter(e=>e.url!==t)})}_markerLightFields(t){const e={};if(t.lightRoleTouched?"always"===t.lightRole?e.is_light=!0:"never"===t.lightRole&&(e.is_light=!1):t.originalHasIsLight&&(e.is_light=t.originalIsLight??null),t.lightEntityTouched?t.lightEntity&&(e.light_entity=t.lightEntity):t.originalHasLightEntity&&(e.light_entity=t.originalLightEntity??null),t.glowTouched){if("auto"!==t.glowMode){const s={c:qt(t.glowColor,this.host._fillColors.glow_light.c)};"fixed"===t.glowMode&&(s.bri=Math.max(.01,Math.min(1,Math.round(t.glowBrightness)/100))),e.glow_color=s}}else t.originalHasGlowColor&&(e.glow_color=t.originalGlowColor??null);return e}_markerTapActionFields(t){return t.tapActionTouched?{tap_action:t.tapAction||null}:t.originalHasTapAction?{tap_action:t.originalTapAction??null}:{}}_markerToggleEntityFields(t){return(e={touched:t.toggleEntityTouched,originalHas:t.originalHasToggleEntity,original:t.originalToggleEntity,value:t.toggleEntity}).touched?e.value?{toggle_entity:e.value}:{}:e.originalHas?{toggle_entity:e.original??null}:{};var e}async _saveMarker(){const t=this.host._markerDialog;if(!t||t.busy)return;const e=this._effectiveMarkerTapAction(t);if("ha"===t.bindingMode&&(!t.binding||"virtual"===t.binding))return;if("virtual"===t.binding&&!t.name.trim())return void this.host._showToast(this.host._t("toast.virtual_name_required"));if("run"===e&&!t.tapTarget)return void this.host._showToast(this.host._t("toast.run_target_required"));if(t.valueBadgeTouched&&t.valueBadgeEnabled&&!t.valueBadgeSource)return void this.host._showToast(this.host._t("toast.value_badge_source_required"));if("ha"===t.bindingMode){const e=this.host._bindingStatus(t.binding),s=t.devId?this.host._markers.find(e=>e.id===t.devId):null,i=!s||s.binding!==t.binding;if("active"!==e.kind&&i)return void this.host._showToast(this.host._t("ha_disabled"===e.kind?"toast.ha_disabled_add":"toast.ha_binding_unverified"));if("ha_disabled"===e.kind&&!0===s?.hidden&&!t.hideFromPlan)return this.host._markerDialog={...t,hideFromPlan:!0},void this.host._showToast(this.host._t("entity"===e.reason?"toast.ha_disabled_show_entity":"toast.ha_disabled_show_device"))}const s=this.host._serverCfg;if(!s)return;const i=this.host._cfgRev,o=yt(s);let a=JSON.parse(JSON.stringify(s));const n=a.markers||[],r=si(t.binding,t.devId,()=>"v_"+Date.now().toString(36)),l=t.devId,h=l?this.host._devices.find(t=>t.id===l):null,c=l?n.find(t=>t.id===l):null,d=!!c&&("string"==typeof c.area&&c.area.length>0||null===c.area&&!!c.space&&!!c.room_id),p="virtual"===t.binding||t.roomTouched||d,u="virtual"===t.binding||t.roomTouched?M(t.room):null;let _=d&&!t.roomTouched?c?.space||null:u?.space||null;const g=d&&!t.roomTouched?c?.area||null:u?.area||null,m=d&&!t.roomTouched?c?.room_id||null:u?.roomId||null,f=_||h?.space||null,b=f?this.host._spaceModelById(f):this.host._spaceModel();if(!b)return;const v=b.id;"virtual"!==t.binding||_||(_=v);let y={};if(t.radarTouched){if(t.radarRemove)y={radar:null};else if(t.radar){const e=pa(t.radar,b.cellCm||5);if(!e)return void this.host._showToast(this.host._t("radar.invalid"));y={radar:e}}}else c&&Object.prototype.hasOwnProperty.call(c,"radar")&&(y={radar:c.radar});this.host._markerDialog={...t,busy:!0};let $=null,w=!1;try{const c="virtual"===t.binding?[]:n.filter(e=>e.removed&&e.binding===t.binding).map(t=>t.id),d=c.length>0,u=x(t.binding,t.controls,this.host._bindingEntities(t.binding)),f=n.find(t=>t.id===r||t.id===l)?.vacuum||null,k={id:r,vacuum:f,...y,binding:t.binding,name:t.name.trim()||null,icon:t.icon||null,display:"badge"!==t.display?t.display:null,ripple_color:"icon_ripple"===t.display&&t.rippleColor?t.rippleColor:null,ripple_size:"icon_ripple"===t.display&&1.5!==t.rippleSize?t.rippleSize:null,size:1!==t.size?t.size:null,angle:t.angle?t.angle:null,...this._markerTapActionFields(t),...this._markerToggleEntityFields(t),tap_target:"run"===e&&t.tapTarget||null,tap_confirm:!!t.tapConfirm||null,controls:u.length?u:null,...this._markerLightFields(t),...this._markerValueBadgeFields(t),...this._markerValueSourceFields(t),use_climate_temp:!!t.useClimateTemp||null,glow_radius_cm:(()=>{const e=kt(t.glowRadius);return null==e||e<=0?null:Math.round(this.host._imperial?30.48*e:100*e)})(),model:t.model.trim()||null,link:t.link.trim()||null,description:t.description.trim()||null,pdfs:t.pdfs,hidden:!!t.hideFromPlan};p&&(k.space=_,k.area=g,k.room_id=m);const M=h?.marker?.room_id??null,C=t.roomTouched&&null!=h&&(h.space!==_||h.area!==g||M!==m);let S=!1;const P=t.uploadId||l;if(P&&P!==r&&k.pdfs?.length)try{const t=await this.host.hass.callWS({type:"houseplan/files/migrate",from_id:P,to_id:r}),e=t?.mapping||{};k.pdfs=ni(k.pdfs,P,r,e),S=Object.keys(e).length>0}catch(t){this.host._showToast(this.host._t("toast.files_migrate_failed",{err:this.host._errText(t)}))}a.markers=n,l&&l!==r&&(a.markers=ri(a.markers,l,r)),l&&l!==r&&"derived_marker_state"===k.value_badge?.source?.kind&&k.value_badge.source.ref===`marker:${l}`&&(k.value_badge.source={kind:"derived_marker_state",ref:`marker:${r}`}),l&&l!==r&&"derived_marker_state"===k.value_source?.kind&&k.value_source.ref===`marker:${l}`&&(k.value_source={kind:"derived_marker_state",ref:`marker:${r}`}),a.markers=a.markers.filter(t=>t.id!==r&&t.id!==l&&("virtual"===k.binding||t.binding!==k.binding)),a.markers.push(k);const D=new Set(c);l&&l!==r&&D.add(l),D.delete(r),D.size&&a.settings?.marker_area_snapshot&&(a.settings={...a.settings,marker_area_snapshot:li(a.settings.marker_area_snapshot,D)});let I=null;const L=l?this.host._layout[l]:null,T=L?{s:L.s||h?.space||this.host._space,x:L.x,y:L.y}:l&&h&&this.host._defPos[l]?this.host._normPos(h.space,this.host._defPos[l].x,this.host._defPos[l].y):null;if(!d&&T&&T.s===v)r===l&&this.host._layout[r]&&!C||(I={s:T.s,x:T.x,y:T.y});else if(d||!this.host._layout[r]||C){let t=b.vb[0]+b.vb[2]/2,e=b.vb[1]+b.vb[3]/2;const s=m?b.rooms.find(t=>t.id===m):g?b.rooms.find(t=>t.area===g):void 0;s&&([t,e]=this.host._roomCenter(s)),I=this.host._normPos(v,t,e)}if(this.host._serverCfg!==s||this.host._cfgRev!==i||yt(s)!==o)return this.host._markerDialog&&(this.host._markerDialog={...this.host._markerDialog,busy:!1}),void this.host._showToast(this.host._t("toast.conflict"));if(a=this._prepareConfigCandidate(a),$=this.host._adoption.beginOptimistic(s,a),this.host._serverCfg=a,this.host._regSignature="",this.host._maybeRebuildDevices(),this.host.requestUpdate(),this.host._saveConfigDebounced.pending()&&this.host._saveConfigDebounced.cancel(),await this._saveConfigNow($),w=!0,I){const t=hi(I);this.host._layout={...this.host._layout,[r]:t},this.host._noteLayoutRev(await this.host.hass.callWS({type:"houseplan/layout/update",device_id:r,pos:t}))}const R=new Set(c);l&&l!==r&&R.add(l),R.delete(r);for(const t of R)delete this.host._layout[t],await this.host.hass.callWS({type:"houseplan/layout/delete",device_id:t}).then(t=>this.host._noteLayoutRev(t)).catch(()=>{});S&&P&&await this.host.hass.callWS({type:"houseplan/files/cleanup",marker_id:P}).catch(()=>{}),this._closeMarkerDialog(),this.host._cancelDeviceDrag(),this.host._devicePositionHistory.clear(),this.host._regSignature="",this.host._maybeRebuildDevices(),this.host._showToast(this.host._t("toast.marker_saved"))}catch(t){!w&&$&&(this.host._rollbackOptimistic($),this.host._regSignature="",this.host._maybeRebuildDevices(),this.host.requestUpdate()),this.host._markerDialog&&(this.host._markerDialog={...this.host._markerDialog,busy:!1}),this.host._showToast(this.host._t("toast.error",{err:this.host._errText(t)}))}}async _deleteMarker(){const t=this.host._markerDialog;if(!t||t.busy||!t.devId)return;const e=t.devId?this.host._devices.find(e=>e.id===t.devId):null,s=this.host._markers.find(e=>e.id===t.devId);if(!e&&!s)return;const i=e?"virtual"===e.bindingKind?"virtual":e.bindingKind&&e.bindingRef?`${e.bindingKind}:${e.bindingRef}`:"":s.binding;if(!i)return;const o=t.name||this.host._t("device.fallback"),a=t.devId,n=await this.host._confirmDanger({key:"remove-marker",kind:"destructive",title:this.host._t("confirm.remove_marker_title"),message:this.host._t("confirm.remove_marker_body"),objectName:o,confirmLabel:this.host._t("btn.delete"),cancelLabel:this.host._t("btn.cancel")}),r=this.host._markerDialog;if(!n||!r||r.busy||r.devId!==a)return;const l=this.host._devices.find(t=>t.id===a),h=this.host._markers.find(t=>t.id===a);if(!l&&!h)return;const c=this.host._serverCfg;if(!c)return;c.markers=c.markers||[];const d=c.markers,p=l?"virtual"===l.bindingKind?"virtual":l.bindingKind&&l.bindingRef?`${l.bindingKind}:${l.bindingRef}`:"":h.binding;if(!p||p!==i)return;const u=ci(c.markers,a,p,"virtual"===p);c.markers=di(u.markers,u.cleanupIds);const _=u.cleanupIds;_.size&&c.settings?.marker_area_snapshot&&(c.settings={...c.settings,marker_area_snapshot:li(c.settings.marker_area_snapshot,_)}),this.host._markerDialog={...r,busy:!0};try{await this._saveConfigNow();for(const t of _){delete this.host._layout[t],delete this.host._defPos[t],this.host._dirtyPos.delete(t),this.host._sentPos.delete(t);const e=this.host._activityRt.get(t);e&&clearTimeout(e.timer),this.host._activityRt.delete(t),this.host._vacRt.delete(t),delete this.host._vacSrvTrails[t],await this.host.hass.callWS({type:"houseplan/layout/delete",device_id:t}).then(t=>this.host._noteLayoutRev(t)).catch(()=>{}),await this.host.hass.callWS({type:"houseplan/files/cleanup",marker_id:t}).catch(()=>{}),await this.host.hass.callWS({type:"houseplan/trail/delete",marker_id:t}).catch(()=>{})}this.host._deviceInboxReturn&&(this.host._deviceInboxReturn={...this.host._deviceInboxReturn,tab:"readd",anchor:p}),this._closeMarkerDialog(),this.host._cancelDeviceDrag(),this.host._devicePositionHistory.clear(),this.host._infoCard?.id===a&&this.host._closeInfoCard(),this.host._selId===a&&(this.host._selId=null),this.host._drag?.id===a&&(this.host._drag=null),this.host._regSignature="",this.host._maybeRebuildDevices(),this.host._showToast(this.host._t("toast.marker_removed"))}catch(t){this.host._serverCfg===c&&(c.markers=d),this.host._markerDialog&&(this.host._markerDialog={...this.host._markerDialog,busy:!1}),this.host._showToast(this.host._t("toast.error",{err:this.host._errText(t)}))}}_openSpaceDialog(t,e){if(this.host._serverStorage&&this.host._serverCfg)if("edit"===t){const s=this.host._serverCfg.spaces.find(t=>t.id===e);if(!s)return;const i=_(s),o=s.settings?.custom_fill&&"object"==typeof s.settings.custom_fill?pi(s.settings.custom_fill):null,a="none"===i.fill?{...o||St,a:0}:o;this.host._spaceDialog={mode:t,spaceId:e,title:s.title,planUrl:s.plan_url||null,planFile:null,source:s.plan_url?"file":"draw",showBorders:i.showBorders,showNames:i.showNames,zeroWallStyle:ui(s),displayTouched:!0,hideDecor:i.hideDecor,hideOpenings:i.hideOpenings,roomColor:i.color,roomOpacity:i.opacity,fillMode:"none"===i.fill?"custom":i.fill,customFill:a,glowEnabled:i.glow,bgColor:i.bgColor,bgMode:"static"===s.settings?.bg_mode||"daynight"===s.settings?.bg_mode?s.settings.bg_mode:null,northDeg:It({},s.settings),sunRays:"boolean"==typeof s.settings?.sun_rays?s.settings.sun_rays:null,tempMin:i.tempMin,tempMax:i.tempMax,showLqi:i.showLqi??this.host._config?.show_signal??!0,cardFontScale:i.cardFontScale,labelTemp:i.labelTemp,labelHum:i.labelHum,labelLqi:i.labelLqi,labelLight:i.labelLight,cellCm:Number(s.cell_cm)>0?Number(s.cell_cm):5,cellCmInput:wt(Number(s.cell_cm)>0?Number(s.cell_cm):5,this.host._imperial),cellCmTouched:!1,busy:!1}}else this.host._spaceDialog={mode:t,title:"",planUrl:null,planFile:null,...vi(),hideDecor:!1,hideOpenings:!1,zeroWallStyle:"dashed",roomColor:fi,roomOpacity:mi,fillMode:"custom",customFill:{...St,a:0},glowEnabled:!0,bgColor:null,bgMode:"daynight",northDeg:null,sunRays:null,tempMin:gi,tempMax:_i,showLqi:this.host._config?.show_signal??!0,cardFontScale:1,labelTemp:!1,labelHum:!1,labelLqi:!1,labelLight:!1,cellCm:bi(this.host._imperial),cellCmInput:wt(bi(this.host._imperial),this.host._imperial),cellCmTouched:!1,busy:!1};else this.host._showToast(this.host._t("toast.integration_missing"))}async _pickPlanFile(t){const e=t.target,s=e.files?.[0];if(!s||!this.host._spaceDialog)return;e.value="",this._decorAssetGuardReplace=null;const i=await xo(s);if("reject"===i.kind)return void this.host._showToast(this.host._t("toast.plan_formats"));if("guard"===i.kind)return void(this.host._backdropGuard=i.state);const o=await Mo(s,i.ext,s.name);this.host._spaceDialog&&(this.host._spaceDialog={...this.host._spaceDialog,planFile:o})}_renderBackdropGuard(){const t=this._decorAssetGuardReplace;return null!==t?Co(this.host,()=>{},()=>{this.host._backdropGuard=null,this._decorAssetGuardReplace=null},this.host.hass,(e,s)=>this._uploadDecorImage(e,s,t),(this.host._backdropGuard?.file.size||0)<=2097152)??d:Co(this.host,t=>{this.host._spaceDialog&&(this.host._spaceDialog={...this.host._spaceDialog,planFile:t})},()=>{this.host._backdropGuard=null},this.host.hass)??d}_useServerPlan(t){const e=this.host._spaceDialog;e&&(this.host._spaceDialog={...e,planUrl:t,planFile:null,pickSaved:!1,savedAspect:void 0},this.host._aspectJob=this._readPlanAspect(t))}async _readPlanAspect(t){for(let e=0;e<40;e++){const e=this.host._display(t);if(e){const s=await new Promise(t=>{const s=new Image;s.onload=()=>t(s.naturalWidth&&s.naturalHeight?s.naturalWidth/s.naturalHeight:0),s.onerror=()=>t(0),s.src=e}),i=this.host._spaceDialog;return i&&i.planUrl===t&&Number.isFinite(s)&&s>0?(this.host._spaceDialog={...i,savedAspect:s},s):0}if(await new Promise(t=>setTimeout(t,150)),this.host._spaceDialog?.planUrl!==t)return 0}return 0}async _deleteServerPlan(t){const e=this.host._spaceDialog,s=e?.saved?.find(e=>e.name===t);if(!e||!s||s.used_by.length||s.url===e.planUrl)return;const i=await this.host._confirmDanger({key:"delete-plan",kind:"destructive",title:this.host._t("confirm.delete_plan_title"),message:this.host._t("confirm.delete_plan_body"),objectName:t,confirmLabel:this.host._t("btn.delete"),cancelLabel:this.host._t("btn.cancel")}),o=this.host._spaceDialog,a=o?.saved?.find(e=>e.name===t);if(i&&o&&a&&a.url===s.url&&a.modified===s.modified&&!a.used_by.length&&a.url!==o.planUrl)try{await this.host.hass.callWS({type:"houseplan/plans/delete",name:t});const e=this.host._spaceDialog;e?.saved&&(this.host._spaceDialog={...e,saved:e.saved.filter(e=>e.name!==t)})}catch(t){this.host._showToast(this.host._t("toast.plan_delete_failed",{err:this.host._errText(t)}))}}_renderServerPlans(t){if(t.savedBusy)return p`
    ${this.host._t("space.loading")}
    `;const e=t.saved||[];if(!e.length)return p`
    ${this.host._t("space.no_saved")}
    `;return p`
    ${e.map(e=>{return p`
    @@ -1858,7 +1845,7 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db
    `;var s})} -
    `}async _saveSpaceDialog(){const t=this.host._spaceDialog;if(!t||t.busy||!t.title.trim())return;if("file"===t.source&&!t.planFile&&!t.planUrl)return void this.host._showToast(this.host._t("toast.plan_required"));const e="create"===t.mode&&0===(this.host._serverCfg?.spaces.length||0);this.host._spaceDialog={...t,busy:!0};try{const s="create"===t.mode?"s"+Date.now().toString(36):t.spaceId;let i=null;if("file"===t.source&&t.planFile){i={url:(await this.host.hass.callWS({type:"houseplan/plan/set",space_id:s,ext:t.planFile.ext,data:t.planFile.b64})).url,aspect:t.planFile.aspect}}let o=t.savedAspect||null;!i&&"file"===t.source&&t.planUrl&&!o&&this.host._aspectJob&&(o=await this.host._aspectJob||null);const a=this.host._serverCfg;let n;if("create"===t.mode)n=yi(s,t.title.trim()),a.spaces.push(n);else{if(n=a.spaces.find(t=>t.id===s),!n)throw new Error("space "+s+" is gone from the config");n.title=t.title.trim()}i?(n.plan_url=i.url,n.plan_aspect=i.aspect):"file"===t.source&&t.planUrl&&t.planUrl!==n.plan_url&&(n.plan_url=t.planUrl,n.plan_aspect=o),"draw"===t.source&&(n.plan_url=null,n.plan_aspect=null,delete n.plan_x,delete n.plan_y,delete n.plan_scale,delete n.plan_scale_x,delete n.plan_scale_y,delete n.plan_angle),n.settings={...n.settings||{},show_borders:t.showBorders,show_names:t.showNames,hide_decor:t.hideDecor||void 0,hide_openings:t.hideOpenings||void 0,room_color:t.roomColor,room_opacity:t.roomOpacity,bg_color:t.bgColor||void 0,bg_mode:t.bgMode||void 0,north_deg:t.northDeg??void 0,sun_rays:t.sunRays??void 0,fill_mode:t.fillMode,custom_fill:t.customFill||void 0,glow_enabled:t.glowEnabled,temp_min:Number.isFinite(t.tempMin)?Math.min(t.tempMin,t.tempMax):gi,temp_max:Number.isFinite(t.tempMax)?Math.max(t.tempMin,t.tempMax):_i,show_lqi:t.showLqi,card_font_scale:1!==t.cardFontScale?t.cardFontScale:void 0,label_temp:t.labelTemp,label_hum:t.labelHum,label_lqi:t.labelLqi,label_light:t.labelLight},n.zero_wall_style=t.zeroWallStyle,n.cell_cm=Number.isFinite(t.cellCm)&&t.cellCm>0?Math.max(.1,Math.min(tr,t.cellCm)):5,await this._saveConfigNow(),this.host._spaceDialog=null,"create"===t.mode&&this.host._commitSpace(n.id),this.host._regSignature="",this.host._maybeRebuildDevices(),this.host._importQueue.length?this._openNextImport():e||this.host._importTotal>0?(this.host._importTotal=0,this.host._commitSpace(this.host._serverCfg.spaces[0]?.id||this.host._space),this._setMode("plan"),this.host._tool="draw",this.host._path=[],this.host._cursorPt=null,this._primeDrawWallField(),this.host._showToast(this.host._t(e&&!this.host._importTotal?"toast.space_added_onboard":"import.done"))):(this.host._showToast("create"===t.mode?this.host._t("toast.space_added"):this.host._t("toast.space_saved")),"create"===t.mode&&("plan"!==this.host._mode?this._setMode("plan"):(this.host._tool="draw",this.host._path=[],this.host._cursorPt=null,this._primeDrawWallField(),this.host._saveNav())))}catch(t){"conflict"!==t?.code&&await this.host._reloadConfigOnly(!0),this.host._spaceDialog&&(this.host._spaceDialog={...this.host._spaceDialog,busy:!1}),this.host._showToast(this.host._t("toast.error",{err:this.host._errText(t)}))}}async _deleteSpace(){const t=this.host._spaceDialog;if(!t||"edit"!==t.mode)return;const e=this.host._serverCfg;if(!e)return;const s=e.spaces.find(e=>e.id===t.spaceId),i=So(e,this.host._layout||{},t.spaceId||""),o=1===e.spaces.length&&e.spaces[0]?.id===t.spaceId;if(i.count&&!o)return void(this.host._spaceDialog={...t,deleteBlockers:i.count});if(!s)return;const a=t.spaceId,n=await this.host._confirmDanger({key:"delete-space",kind:"destructive",title:this.host._t("confirm.delete_space_title"),message:Po(this.host._t("confirm.delete_space_body"),this.host._t("confirm.delete_space_vac_routes"),i.routeCount),objectName:s.title,confirmLabel:this.host._t("btn.delete"),cancelLabel:this.host._t("btn.cancel")}),r=this.host._spaceDialog,l=this.host._serverCfg;if(!n||!r||"edit"!==r.mode||r.busy||r.spaceId!==a||!l)return;if(!l.spaces.find(t=>t.id===a))return;const h=So(l,this.host._layout||{},a),c=1===l.spaces.length&&l.spaces[0]?.id===a;if(!h.count||c){this.host._spaceDialog={...r,deleteBlockers:0,busy:!0};try{this.host._saveConfigDebounced.pending()&&this.host._saveConfigDebounced.flush(),this.host._persistLayout.pending()&&this.host._persistLayout.flush(),await this.host._writeChain,await this.host.hass.callWS({type:"houseplan/space/delete",space_id:a,expected_config_rev:this.host._cfgRev,expected_layout_rev:this.host._layoutRev});const[t,e]=await Promise.all([this.host._getAuthoritativeConfig(),this.host.hass.callWS({type:"houseplan/layout/get"})]);if("adopted"!==(await this.host._adoptAuthoritative({cfgResp:t,layResp:e,reason:"space-delete",profile:"post-write"})).status)return this.host._spaceDialog={...r,busy:!1},void this.host.requestUpdate();this.host._spaceDialog=null,this.host._space===a&&this.host._commitSpace(this.host._serverCfg.spaces[0]?.id||""),this.host._regSignature="",this.host._maybeRebuildDevices(),this.host._showToast(this.host._t("toast.space_deleted"))}catch(t){"conflict"!==t?.code&&"space_in_use"!==t?.code||await Promise.all([this.host._reloadConfigOnly(!0),this.host._reloadLayoutOnly()]);const e=this.host._serverCfg;if(this.host._spaceDialog&&e){const t=So(e,this.host._layout||{},a),s=1===e.spaces.length&&e.spaces[0]?.id===a;this.host._spaceDialog={...this.host._spaceDialog,busy:!1,deleteBlockers:s?0:t.count}}this.host._showToast(this.host._t("toast.delete_failed",{err:this.host._errText(t)}))}}else this.host._spaceDialog={...r,deleteBlockers:h.count}}async _saveConfigNow(t=null){this.host._cfgEpoch++;try{await this._writeConfig(t)}catch(t){throw t?.physicalGeometryRolledBack?await this._reloadRejectedPhysicalWrite():"conflict"===t?.code&&await this.host._reloadConfigOnly(),t}}_saveSpaceCopy(){return Qn(this.host,{clearGeometryGesture:()=>this._clearGeometryGesture(),optimizeReferenceContext:()=>this._optimizeReferenceContext(!1),reportPreflightFailure:(t,e)=>this._reportPreflightFailure(t,e),saveConfigNow:t=>this._saveConfigNow(t),setMode:()=>this._setMode("plan"),showWallModelMigrationBlocked:t=>this._showWallModelMigrationBlocked(t)})}_startImport(){const t=this.host._importDialog;if(!t)return;const e=t.floors.filter(t=>t.checked).map(t=>t.name);this.host._importDialog=null,e.length?(this.host._importQueue=e,this.host._importTotal=e.length,this._openNextImport()):this._openSpaceDialog("create")}_openNextImport(){const t=this.host._importQueue.shift();void 0!==t&&(this.host._spaceDialog={mode:"create",title:t,planUrl:null,planFile:null,...vi(),hideDecor:!1,hideOpenings:!1,zeroWallStyle:"dashed",roomColor:fi,roomOpacity:mi,fillMode:"custom",customFill:null,glowEnabled:!0,bgColor:null,bgMode:"daynight",northDeg:null,sunRays:null,tempMin:gi,tempMax:_i,showLqi:this.host._config?.show_signal??!0,cardFontScale:1,labelTemp:!1,labelHum:!1,labelLqi:!1,labelLight:!1,cellCm:bi(this.host._imperial),cellCmInput:wt(bi(this.host._imperial),this.host._imperial),cellCmTouched:!1,busy:!1})}_skipImport(){this.host._spaceDialog=null,this.host._importQueue.length?this._openNextImport():this.host._importTotal>0&&this.host._model.length&&(this.host._importTotal=0,this.host._commitSpace(this.host._serverCfg.spaces[0]?.id||this.host._space),this._setMode("plan"),this.host._showToast(this.host._t("import.done")))}_renderImportDialog(){const t=this.host._importDialog,e=t.floors.filter(t=>t.checked).length;return p``}async _saveSpaceDialog(){const t=this.host._spaceDialog;if(!t||t.busy||!t.title.trim())return;if("file"===t.source&&!t.planFile&&!t.planUrl)return void this.host._showToast(this.host._t("toast.plan_required"));const e="create"===t.mode&&0===(this.host._serverCfg?.spaces.length||0);this.host._spaceDialog={...t,busy:!0};try{const s="create"===t.mode?"s"+Date.now().toString(36):t.spaceId;let i=null;if("file"===t.source&&t.planFile){i={url:(await this.host.hass.callWS({type:"houseplan/plan/set",space_id:s,ext:t.planFile.ext,data:t.planFile.b64})).url,aspect:t.planFile.aspect}}let o=t.savedAspect||null;!i&&"file"===t.source&&t.planUrl&&!o&&this.host._aspectJob&&(o=await this.host._aspectJob||null);const a=this.host._serverCfg;let n;if("create"===t.mode)n=yi(s,t.title.trim()),a.spaces.push(n);else{if(n=a.spaces.find(t=>t.id===s),!n)throw new Error("space "+s+" is gone from the config");n.title=t.title.trim()}i?(n.plan_url=i.url,n.plan_aspect=i.aspect):"file"===t.source&&t.planUrl&&t.planUrl!==n.plan_url&&(n.plan_url=t.planUrl,n.plan_aspect=o),"draw"===t.source&&(n.plan_url=null,n.plan_aspect=null,delete n.plan_x,delete n.plan_y,delete n.plan_scale,delete n.plan_scale_x,delete n.plan_scale_y,delete n.plan_angle),n.settings={...n.settings||{},show_borders:t.showBorders,show_names:t.showNames,hide_decor:t.hideDecor||void 0,hide_openings:t.hideOpenings||void 0,room_color:t.roomColor,room_opacity:t.roomOpacity,bg_color:t.bgColor||void 0,bg_mode:t.bgMode||void 0,north_deg:t.northDeg??void 0,sun_rays:t.sunRays??void 0,fill_mode:t.fillMode,custom_fill:t.customFill||void 0,glow_enabled:t.glowEnabled,temp_min:Number.isFinite(t.tempMin)?Math.min(t.tempMin,t.tempMax):gi,temp_max:Number.isFinite(t.tempMax)?Math.max(t.tempMin,t.tempMax):_i,show_lqi:t.showLqi,card_font_scale:1!==t.cardFontScale?t.cardFontScale:void 0,label_temp:t.labelTemp,label_hum:t.labelHum,label_lqi:t.labelLqi,label_light:t.labelLight},n.zero_wall_style=t.zeroWallStyle,n.cell_cm=Number.isFinite(t.cellCm)&&t.cellCm>0?Math.max(.1,Math.min(er,t.cellCm)):5,await this._saveConfigNow(),this.host._spaceDialog=null,"create"===t.mode&&this.host._commitSpace(n.id),this.host._regSignature="",this.host._maybeRebuildDevices(),this.host._importQueue.length?this._openNextImport():e||this.host._importTotal>0?(this.host._importTotal=0,this.host._commitSpace(this.host._serverCfg.spaces[0]?.id||this.host._space),this._setMode("plan"),this.host._tool="draw",this.host._path=[],this.host._cursorPt=null,this._primeDrawWallField(),this.host._showToast(this.host._t(e&&!this.host._importTotal?"toast.space_added_onboard":"import.done"))):(this.host._showToast("create"===t.mode?this.host._t("toast.space_added"):this.host._t("toast.space_saved")),"create"===t.mode&&("plan"!==this.host._mode?this._setMode("plan"):(this.host._tool="draw",this.host._path=[],this.host._cursorPt=null,this._primeDrawWallField(),this.host._saveNav())))}catch(t){"conflict"!==t?.code&&await this.host._reloadConfigOnly(!0),this.host._spaceDialog&&(this.host._spaceDialog={...this.host._spaceDialog,busy:!1}),this.host._showToast(this.host._t("toast.error",{err:this.host._errText(t)}))}}async _deleteSpace(){const t=this.host._spaceDialog;if(!t||"edit"!==t.mode)return;const e=this.host._serverCfg;if(!e)return;const s=e.spaces.find(e=>e.id===t.spaceId),i=So(e,this.host._layout||{},t.spaceId||""),o=1===e.spaces.length&&e.spaces[0]?.id===t.spaceId;if(i.count&&!o)return void(this.host._spaceDialog={...t,deleteBlockers:i.count});if(!s)return;const a=t.spaceId,n=await this.host._confirmDanger({key:"delete-space",kind:"destructive",title:this.host._t("confirm.delete_space_title"),message:Po(this.host._t("confirm.delete_space_body"),this.host._t("confirm.delete_space_vac_routes"),i.routeCount),objectName:s.title,confirmLabel:this.host._t("btn.delete"),cancelLabel:this.host._t("btn.cancel")}),r=this.host._spaceDialog,l=this.host._serverCfg;if(!n||!r||"edit"!==r.mode||r.busy||r.spaceId!==a||!l)return;if(!l.spaces.find(t=>t.id===a))return;const h=So(l,this.host._layout||{},a),c=1===l.spaces.length&&l.spaces[0]?.id===a;if(!h.count||c){this.host._spaceDialog={...r,deleteBlockers:0,busy:!0};try{this.host._saveConfigDebounced.pending()&&this.host._saveConfigDebounced.flush(),this.host._persistLayout.pending()&&this.host._persistLayout.flush(),await this.host._writeChain,await this.host.hass.callWS({type:"houseplan/space/delete",space_id:a,expected_config_rev:this.host._cfgRev,expected_layout_rev:this.host._layoutRev});const[t,e]=await Promise.all([this.host._getAuthoritativeConfig(),this.host.hass.callWS({type:"houseplan/layout/get"})]);if("adopted"!==(await this.host._adoptAuthoritative({cfgResp:t,layResp:e,reason:"space-delete",profile:"post-write"})).status)return this.host._spaceDialog={...r,busy:!1},void this.host.requestUpdate();this.host._spaceDialog=null,this.host._space===a&&this.host._commitSpace(this.host._serverCfg.spaces[0]?.id||""),this.host._regSignature="",this.host._maybeRebuildDevices(),this.host._showToast(this.host._t("toast.space_deleted"))}catch(t){"conflict"!==t?.code&&"space_in_use"!==t?.code||await Promise.all([this.host._reloadConfigOnly(!0),this.host._reloadLayoutOnly()]);const e=this.host._serverCfg;if(this.host._spaceDialog&&e){const t=So(e,this.host._layout||{},a),s=1===e.spaces.length&&e.spaces[0]?.id===a;this.host._spaceDialog={...this.host._spaceDialog,busy:!1,deleteBlockers:s?0:t.count}}this.host._showToast(this.host._t("toast.delete_failed",{err:this.host._errText(t)}))}}else this.host._spaceDialog={...r,deleteBlockers:h.count}}async _saveConfigNow(t=null){this.host._cfgEpoch++;try{await this._writeConfig(t)}catch(t){throw t?.physicalGeometryRolledBack?await this._reloadRejectedPhysicalWrite():"conflict"===t?.code&&await this.host._reloadConfigOnly(),t}}_saveSpaceCopy(){return tr(this.host,{clearGeometryGesture:()=>this._clearGeometryGesture(),optimizeReferenceContext:()=>this._optimizeReferenceContext(!1),reportPreflightFailure:(t,e)=>this._reportPreflightFailure(t,e),saveConfigNow:t=>this._saveConfigNow(t),setMode:()=>this._setMode("plan"),showWallModelMigrationBlocked:t=>this._showWallModelMigrationBlocked(t)})}_startImport(){const t=this.host._importDialog;if(!t)return;const e=t.floors.filter(t=>t.checked).map(t=>t.name);this.host._importDialog=null,e.length?(this.host._importQueue=e,this.host._importTotal=e.length,this._openNextImport()):this._openSpaceDialog("create")}_openNextImport(){const t=this.host._importQueue.shift();void 0!==t&&(this.host._spaceDialog={mode:"create",title:t,planUrl:null,planFile:null,...vi(),hideDecor:!1,hideOpenings:!1,zeroWallStyle:"dashed",roomColor:fi,roomOpacity:mi,fillMode:"custom",customFill:null,glowEnabled:!0,bgColor:null,bgMode:"daynight",northDeg:null,sunRays:null,tempMin:gi,tempMax:_i,showLqi:this.host._config?.show_signal??!0,cardFontScale:1,labelTemp:!1,labelHum:!1,labelLqi:!1,labelLight:!1,cellCm:bi(this.host._imperial),cellCmInput:wt(bi(this.host._imperial),this.host._imperial),cellCmTouched:!1,busy:!1})}_skipImport(){this.host._spaceDialog=null,this.host._importQueue.length?this._openNextImport():this.host._importTotal>0&&this.host._model.length&&(this.host._importTotal=0,this.host._commitSpace(this.host._serverCfg.spaces[0]?.id||this.host._space),this._setMode("plan"),this.host._showToast(this.host._t("import.done")))}_renderImportDialog(){const t=this.host._importDialog,e=t.floors.filter(t=>t.checked).length;return p`this.host._importDialog=null}>
    ${this.host._t("import.hint")}
    @@ -1878,13 +1865,13 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db ${this.host._t("import.start",{n:e})}
    -
    `}_supportPatch(t,e){const s=this.host._supportDialog;if(!s||s.draftId!==t)return null;const i={...s,...e};return this.host._supportDialog=i,i}async _focusSupport(t){await this.host.updateComplete,this.host.renderRoot.querySelector(t)?.focus({preventScroll:!0})}_updateSupportDraft(t,e){const s=this.host._supportDialog;if(!s||"building"===s.status||"sending"===s.status||"success"===s.status)return;const i={...s,[t]:e},o=Kc({...i,attach:!1,preview:null});"message_required"===o&&"validation.message_required"===s.errorCode||"message_too_long"===o||"contact_too_long"===o?this._supportPatch(s.draftId,{[t]:e,status:"error",errorCode:`validation.${o}`}):i.attach&&i.preview&&i.preview.expiresAt<=Date.now()?this._supportPatch(s.draftId,{[t]:e,status:"error",errorCode:"support_preview_expired"}):this._supportPatch(s.draftId,{[t]:e,status:i.attach&&i.preview?"ready":"idle",errorCode:""})}async _discardSupportPreview(t){if(t)try{await this.host.hass.callWS({type:"houseplan/support/preview/discard",token:t})}catch{}}async _closeSupportDialog(){const t=this.host._supportDialog;if(t){if("building"===t.status||"sending"===t.status){const t=l(this.host.hass,this.host._config?.language);if(!await this.host._confirmDanger({key:"close-support-busy",kind:"warning",title:Oo(t,"support.close_busy_title"),message:Oo(t,"support.close_busy_body"),confirmLabel:this.host._t("btn.close"),cancelLabel:this.host._t("btn.cancel")}))return await this.host.updateComplete,void this.host.renderRoot.querySelector("#support-dialog")?.rejectClose()}clearTimeout(this._supportExpiryTimer),this._supportExpiryTimer=void 0,this.host._supportDialog=null,t.preview?.token&&"success"!==t.status&&this._discardSupportPreview(t.preview.token)}}_scheduleSupportExpiry(t,e){clearTimeout(this._supportExpiryTimer);const s=Math.max(0,e.expiresAt-Date.now());this._supportExpiryTimer=window.setTimeout(()=>{const s=this.host._supportDialog;s&&s.draftId===t&&s.preview?.token===e.token&&s.attach&&"success"!==s.status&&"sending"!==s.status&&this._supportPatch(t,{status:"error",errorCode:"support_preview_expired"})},Math.min(s+20,2147483647))}_supportFacts(){const t=this.host._haRegistry;return Jc({userAgent:globalThis.navigator?.userAgent||"",language:l(this.host.hass,this.host._config?.language),registryAccess:t.access,registryLastSuccess:t.lastSuccess})}_supportPreviewRequestIsCurrent(t,e){const s=this.host._supportDialog;return e===this._supportPreviewGeneration&&s?.draftId===t&&s.attach}async _buildSupportPreview(t){const e=this.host._supportDialog;if(!e||e.draftId!==t||!e.attach||!jc(this.host._haSupportApi))return;const s=++this._supportPreviewGeneration;this._supportPatch(t,{status:"building",errorCode:""});let i="";try{const e=await this.host.hass.callWS({type:"houseplan/support/preview",card_version:$i(vd),...this._supportFacts(),draft_id:t}),o=e&&"object"==typeof e?e:{},a=Date.now(),n="string"==typeof o.text?o.text:"",r=Number(o.size),l=Number(o.expires_in),h=Number(o.spaces),c=String(o.token||"");/^[0-9a-f]{48}$/.test(c)&&(i=c);const d=String(o.sha256||""),p=Number(o.version),u=String(o.format||""),_=(new TextEncoder).encode(n).byteLength;if(!/^[0-9a-f]{48}$/.test(c)||!/^[0-9a-f]{64}$/.test(d)||"houseplan-support-package"!==u||1!==p||!Number.isInteger(r)||r!==_||!Number.isInteger(h)||h<0||!Number.isFinite(l)||l<=0||l>600||!n.endsWith("\n"))throw{code:"support_rejected"};const g={token:c,expiresAt:a+1e3*l,size:r,sha256:d,spaces:h,format:u,version:p,text:n,preparedAt:a};if(!this._supportPreviewRequestIsCurrent(t,s))return i="",void this._discardSupportPreview(c);if(!this._supportPatch(t,{status:"ready",preview:g,errorCode:"",rawOpen:!1}))return i="",void this._discardSupportPreview(c);i="",this._scheduleSupportExpiry(t,g)}catch(e){if(i){const t=i;i="",this._discardSupportPreview(t)}if(!this._supportPreviewRequestIsCurrent(t,s))return;if(!this._supportPatch(t,{status:"error",errorCode:Zc(e)}))return;this._focusSupport("#support-error")}}async _setSupportAttachment(t){const e=this.host._supportDialog;if(!e||"sending"===e.status||"success"===e.status)return;const s=e.preview?.token||"";if(!t)return this._supportPreviewGeneration+=1,clearTimeout(this._supportExpiryTimer),this._supportExpiryTimer=void 0,this._supportPatch(e.draftId,{attach:!1,status:"idle",preview:null,rawOpen:!1,errorCode:""}),void(s&&this._discardSupportPreview(s));this._supportPatch(e.draftId,{attach:!0,errorCode:""}),await this._buildSupportPreview(e.draftId)}async _refreshSupportPreview(){const t=this.host._supportDialog;t&&t.attach&&"building"!==t.status&&"sending"!==t.status&&await this._buildSupportPreview(t.draftId)}_downloadSupportPreview(){const t=this.host._supportDialog?.preview;if(!t)return;const e=new Blob([t.text],{type:"application/json;charset=utf-8"}),s=URL.createObjectURL(e),i=document.createElement("a");i.href=s,i.download=`houseplan-support-${t.sha256.slice(0,12)}.json`,i.style.display="none",document.body.append(i),i.click(),i.remove(),window.setTimeout(()=>URL.revokeObjectURL(s),0)}async _copySupportText(t,e){const s=l(this.host.hass,this.host._config?.language);try{await navigator.clipboard.writeText(t),this.host._showToast(Oo(s,e))}catch{this.host._showToast(Oo(s,"support.copy_failed"))}}async _submitSupport(){const t=this.host._supportDialog;if(!t||!jc(this.host._haSupportApi))return;const e=Kc(t);if(e)return this._supportPatch(t.draftId,{status:"error",errorCode:`validation.${e}`}),void this._focusSupport("#support-message");if(!Vc(t))return;const s=qc(t),i=this._supportPatch(t.draftId,{status:"sending",errorCode:"",idempotencyKey:s.idempotencyKey,submissionFingerprint:s.fingerprint});if(i)try{const e=await this.host.hass.callWS({type:"houseplan/support/submit",message:i.message.trim(),contact:i.contact.trim(),...i.attach&&i.preview?{preview_token:i.preview.token}:{},idempotency_key:i.idempotencyKey}),s=e&&"object"==typeof e&&"report_id"in e?String(e.report_id||""):"";if(!/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(s))throw{code:"support_unavailable"};if(clearTimeout(this._supportExpiryTimer),this._supportExpiryTimer=void 0,!this._supportPatch(t.draftId,{status:"success",reportId:s,errorCode:""}))return;this._focusSupport("#support-receipt")}catch(e){if(!this._supportPatch(t.draftId,{status:"error",errorCode:Zc(e)}))return;this._focusSupport("#support-error")}}_supportErrorText(t){const e=l(this.host.hass,this.host._config?.language);if(t.errorCode.startsWith("validation.")){return Oo(e,`support.validation.${t.errorCode.slice(11)}`)}return Oo(e,`support.error.${t.errorCode||"support_unavailable"}`)}_supportMessageKeydown(t){"Enter"===t.key&&(t.ctrlKey||t.metaKey)&&(t.preventDefault(),this._submitSupport())}_renderSupportDialog(){const t=this.host._supportDialog,e=l(this.host.hass,this.host._config?.language),s="ru"===e?"https://github.com/Matysh/houseplan-card/blob/main/docs/USER-GUIDE.ru.md":"https://github.com/Matysh/houseplan-card/blob/main/docs/USER-GUIDE.md",i=jc(this.host._haSupportApi),o=(t,s)=>Oo(e,t,s),a="building"===t.status||"sending"===t.status,n=Kc(t),r=t.preview?Math.max(0,Math.floor((Date.now()-t.preview.preparedAt)/6e4)):0,h="error"===t.status&&!t.errorCode.startsWith("validation."),c="validation.contact_too_long"===t.errorCode,u="validation.message_required"===t.errorCode||"validation.message_too_long"===t.errorCode;return p``}_supportPatch(t,e){const s=this.host._supportDialog;if(!s||s.draftId!==t)return null;const i={...s,...e};return this.host._supportDialog=i,i}async _focusSupport(t){await this.host.updateComplete,this.host.renderRoot.querySelector(t)?.focus({preventScroll:!0})}_updateSupportDraft(t,e){const s=this.host._supportDialog;if(!s||"building"===s.status||"sending"===s.status||"success"===s.status)return;const i={...s,[t]:e},o=Vc({...i,attach:!1,preview:null});"message_required"===o&&"validation.message_required"===s.errorCode||"message_too_long"===o||"contact_too_long"===o?this._supportPatch(s.draftId,{[t]:e,status:"error",errorCode:`validation.${o}`}):i.attach&&i.preview&&i.preview.expiresAt<=Date.now()?this._supportPatch(s.draftId,{[t]:e,status:"error",errorCode:"support_preview_expired"}):this._supportPatch(s.draftId,{[t]:e,status:i.attach&&i.preview?"ready":"idle",errorCode:""})}async _discardSupportPreview(t){if(t)try{await this.host.hass.callWS({type:"houseplan/support/preview/discard",token:t})}catch{}}async _closeSupportDialog(){const t=this.host._supportDialog;if(t){if("building"===t.status||"sending"===t.status){const t=l(this.host.hass,this.host._config?.language);if(!await this.host._confirmDanger({key:"close-support-busy",kind:"warning",title:Oo(t,"support.close_busy_title"),message:Oo(t,"support.close_busy_body"),confirmLabel:this.host._t("btn.close"),cancelLabel:this.host._t("btn.cancel")}))return await this.host.updateComplete,void this.host.renderRoot.querySelector("#support-dialog")?.rejectClose()}clearTimeout(this._supportExpiryTimer),this._supportExpiryTimer=void 0,this.host._supportDialog=null,t.preview?.token&&"success"!==t.status&&this._discardSupportPreview(t.preview.token)}}_scheduleSupportExpiry(t,e){clearTimeout(this._supportExpiryTimer);const s=Math.max(0,e.expiresAt-Date.now());this._supportExpiryTimer=window.setTimeout(()=>{const s=this.host._supportDialog;s&&s.draftId===t&&s.preview?.token===e.token&&s.attach&&"success"!==s.status&&"sending"!==s.status&&this._supportPatch(t,{status:"error",errorCode:"support_preview_expired"})},Math.min(s+20,2147483647))}_supportFacts(){const t=this.host._haRegistry;return Zc({userAgent:globalThis.navigator?.userAgent||"",language:l(this.host.hass,this.host._config?.language),registryAccess:t.access,registryLastSuccess:t.lastSuccess})}_supportPreviewRequestIsCurrent(t,e){const s=this.host._supportDialog;return e===this._supportPreviewGeneration&&s?.draftId===t&&s.attach}async _buildSupportPreview(t){const e=this.host._supportDialog;if(!e||e.draftId!==t||!e.attach||!Gc(this.host._haSupportApi))return;const s=++this._supportPreviewGeneration;this._supportPatch(t,{status:"building",errorCode:""});let i="";try{const e=await this.host.hass.callWS({type:"houseplan/support/preview",card_version:$i(yd),...this._supportFacts(),draft_id:t}),o=e&&"object"==typeof e?e:{},a=Date.now(),n="string"==typeof o.text?o.text:"",r=Number(o.size),l=Number(o.expires_in),h=Number(o.spaces),c=String(o.token||"");/^[0-9a-f]{48}$/.test(c)&&(i=c);const d=String(o.sha256||""),p=Number(o.version),u=String(o.format||""),_=(new TextEncoder).encode(n).byteLength;if(!/^[0-9a-f]{48}$/.test(c)||!/^[0-9a-f]{64}$/.test(d)||"houseplan-support-package"!==u||1!==p||!Number.isInteger(r)||r!==_||!Number.isInteger(h)||h<0||!Number.isFinite(l)||l<=0||l>600||!n.endsWith("\n"))throw{code:"support_rejected"};const g={token:c,expiresAt:a+1e3*l,size:r,sha256:d,spaces:h,format:u,version:p,text:n,preparedAt:a};if(!this._supportPreviewRequestIsCurrent(t,s))return i="",void this._discardSupportPreview(c);if(!this._supportPatch(t,{status:"ready",preview:g,errorCode:"",rawOpen:!1}))return i="",void this._discardSupportPreview(c);i="",this._scheduleSupportExpiry(t,g)}catch(e){if(i){const t=i;i="",this._discardSupportPreview(t)}if(!this._supportPreviewRequestIsCurrent(t,s))return;if(!this._supportPatch(t,{status:"error",errorCode:Yc(e)}))return;this._focusSupport("#support-error")}}async _setSupportAttachment(t){const e=this.host._supportDialog;if(!e||"sending"===e.status||"success"===e.status)return;const s=e.preview?.token||"";if(!t)return this._supportPreviewGeneration+=1,clearTimeout(this._supportExpiryTimer),this._supportExpiryTimer=void 0,this._supportPatch(e.draftId,{attach:!1,status:"idle",preview:null,rawOpen:!1,errorCode:""}),void(s&&this._discardSupportPreview(s));this._supportPatch(e.draftId,{attach:!0,errorCode:""}),await this._buildSupportPreview(e.draftId)}async _refreshSupportPreview(){const t=this.host._supportDialog;t&&t.attach&&"building"!==t.status&&"sending"!==t.status&&await this._buildSupportPreview(t.draftId)}_downloadSupportPreview(){const t=this.host._supportDialog?.preview;if(!t)return;const e=new Blob([t.text],{type:"application/json;charset=utf-8"}),s=URL.createObjectURL(e),i=document.createElement("a");i.href=s,i.download=`houseplan-support-${t.sha256.slice(0,12)}.json`,i.style.display="none",document.body.append(i),i.click(),i.remove(),window.setTimeout(()=>URL.revokeObjectURL(s),0)}async _copySupportText(t,e){const s=l(this.host.hass,this.host._config?.language);try{await navigator.clipboard.writeText(t),this.host._showToast(Oo(s,e))}catch{this.host._showToast(Oo(s,"support.copy_failed"))}}async _submitSupport(){const t=this.host._supportDialog;if(!t||!Gc(this.host._haSupportApi))return;const e=Vc(t);if(e)return this._supportPatch(t.draftId,{status:"error",errorCode:`validation.${e}`}),void this._focusSupport("#support-message");if(!Jc(t))return;const s=Uc(t),i=this._supportPatch(t.draftId,{status:"sending",errorCode:"",idempotencyKey:s.idempotencyKey,submissionFingerprint:s.fingerprint});if(i)try{const e=await this.host.hass.callWS({type:"houseplan/support/submit",message:i.message.trim(),contact:i.contact.trim(),...i.attach&&i.preview?{preview_token:i.preview.token}:{},idempotency_key:i.idempotencyKey}),s=e&&"object"==typeof e&&"report_id"in e?String(e.report_id||""):"";if(!/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(s))throw{code:"support_unavailable"};if(clearTimeout(this._supportExpiryTimer),this._supportExpiryTimer=void 0,!this._supportPatch(t.draftId,{status:"success",reportId:s,errorCode:""}))return;this._focusSupport("#support-receipt")}catch(e){if(!this._supportPatch(t.draftId,{status:"error",errorCode:Yc(e)}))return;this._focusSupport("#support-error")}}_supportErrorText(t){const e=l(this.host.hass,this.host._config?.language);if(t.errorCode.startsWith("validation.")){return Oo(e,`support.validation.${t.errorCode.slice(11)}`)}return Oo(e,`support.error.${t.errorCode||"support_unavailable"}`)}_supportMessageKeydown(t){"Enter"===t.key&&(t.ctrlKey||t.metaKey)&&(t.preventDefault(),this._submitSupport())}_renderSupportDialog(){const t=this.host._supportDialog,e=l(this.host.hass,this.host._config?.language),s="ru"===e?"https://github.com/Matysh/houseplan-card/blob/main/docs/USER-GUIDE.ru.md":"https://github.com/Matysh/houseplan-card/blob/main/docs/USER-GUIDE.md",i=Gc(this.host._haSupportApi),o=(t,s)=>Oo(e,t,s),a="building"===t.status||"sending"===t.status,n=Vc(t),r=t.preview?Math.max(0,Math.floor((Date.now()-t.preview.preparedAt)/6e4)):0,h="error"===t.status&&!t.errorCode.startsWith("validation."),c="validation.contact_too_long"===t.errorCode,u="validation.message_required"===t.errorCode||"validation.message_too_long"===t.errorCode;return p`{this._closeSupportDialog()}}>

    ${o("support.about_group")}

    -
    ${this.host._t("gs.about_version",{v:$i(vd)})}
    +
    ${this.host._t("gs.about_version",{v:$i(yd)})}
    - `;var _}_preflightDiagnostics(t,e){const s=new Map((e?.spaces||[]).map(t=>[String(t?.id||""),t]));return{kind:"houseplan-optimize-preflight",origin:"runtime",cardVersion:$i(vd),checkedAt:(new Date).toISOString(),preflightFingerprint:t.fingerprint,failures:t.failures.map(t=>({spaceId:t.spaceId,displayName:t.displayName,reason:t.reason,detail:t.detail??null,spaceGeometryFingerprint:s.has(t.spaceId)?ne(s.get(t.spaceId)):null}))}}_reportPreflightFailure(t,e){t.ok||t.fingerprint===this.host._reportedPreflightFingerprint||(this.host._reportedPreflightFingerprint=t.fingerprint,console.warn("[houseplan] optimize preflight failed",this._preflightDiagnostics(t,e)))}_preflightVersionsDiffer(){const t=this.host._haIntegrationVersion;return"string"==typeof t&&t.length>0&&t!==$i(vd)}async _copyPreflightDiagnostics(){const t=this.host._alignDialog?.preflight;if(!t||t.ok)return;const e=JSON.stringify(this._preflightDiagnostics(t,this.host._alignDialog?.config??null),null,2);try{await navigator.clipboard.writeText(e),this.host._preflightClipboardFallback=null,this.host._showToast(this.host._t("gs.preflight_copied"))}catch{this.host._preflightClipboardFallback=e}}_checkOptimizeGeometryImpl(t){return wi(t,{fallbackSpaceName:t=>this.host._t("gs.align_preflight_space",{n:String(t)})})}_checkSpacePhysicalGeometryImpl(t,e,s){return ki(t,e,{fallbackSpaceName:t=>this.host._t("gs.align_preflight_space",{n:String(t)}),captureWallGeometry:s?(t,e)=>s(e):void 0})}_optimizeReferenceContext(t){const e=this.host._haRegistry,s=this.host._fullRegistryHass,i={},o=(...t)=>{for(const e of t){const t=String(e||"").trim();if(t)return t}return""};for(const[t,s]of Object.entries(e.devices||{}))i[t]=o(s?.name_by_user,s?.name,s?.model);for(const[t,s]of Object.entries(e.entities||{}))i[`lg_${t}`]=o(this.host.hass?.states?.[t]?.attributes?.friendly_name,s?.name,s?.original_name);for(const t of this.host._devices)i[t.id]=o(t.name,i[t.id]);for(const t of this.host._serverCfg?.markers||[]){const e=String(t.binding||"").indexOf(":"),a=e>0?t.binding.slice(0,e):"",n=e>0?t.binding.slice(e+1):"",r="device"===a?s?.devices?.[n]:"entity"===a?s?.entities?.[n]:null;i[t.id]=o(t.name,"device"===a?r?.name_by_user:null,r?.name,"entity"===a?this.host.hass?.states?.[n]?.attributes?.friendly_name:null,i[t.id])}return{effectiveAreaByMarker:Object.fromEntries(this.host._devices.filter(t=>!t.virtual&&!!t.area).map(t=>[t.id,t.area])),ownerRoster:{authoritative:e.authoritative,deviceIds:Object.keys(e.devices||{}),entityIds:[...new Set([...Object.keys(e.entities||{}),...Object.keys(this.host.hass?.states||{})])],names:i},removeLiveMissingPositions:t}}_previewAlignDialog(t){if(!this.host._norm||!this.host._serverCfg)return;const e=this.host._serverCfg.spaces||[];let s;try{s=En(this.host._serverCfg,this.host._layout||{},this._optimizeReferenceContext(t))}catch(t){return void this._showWallModelMigrationBlocked(t)}const i=s.changed?this.host._checkOptimizeGeometry(s.config):null;i&&this._reportPreflightFailure(i,s.config);const o=Math.ceil(10*s.report.maxShiftCm)/10,a=e.find(t=>null!=t?.id&&String(t.id)===s.report.maxSpace),n=e.length>1&&a?String(a.title||a.id):"";this.host._preflightClipboardFallback=null,this.host._alignDialog={report:s.report,config:s.config,layout:s.layout,cm:o,where:n,preflight:i,changed:s.changed,busy:!1,removeLiveMissingPositions:t}}async _runAlignToGrid(){let t=this.host._alignDialog;if(!t||t.busy||!this.host._serverCfg||!t.changed||!t.preflight?.ok)return;const e=yt(t.config);if(t.preflight.fingerprint!==e){const e=this.host._checkOptimizeGeometry(t.config);if(this._reportPreflightFailure(e,t.config),t={...t,preflight:e},this.host._alignDialog=t,!e.ok)return}this._clearGeometryGesture(),this.host._alignDialog={...t,busy:!0};try{await On(this.host,t.config,t.layout),this.host._alignDialog=null,this.host._preflightClipboardFallback=null,this.host._showToast(this.host._t("gs.align_done",{n:String(t.report.moved),m:String(t.report.migrated+t.report.canonicalized+t.report.coordsCanonicalized+t.report.latticeCoordinatesCanonicalized+t.report.wallsMerged+t.report.spansMerged+t.report.partitionsMerged+t.report.partitionsReconciled+t.report.openingsRehosted+t.report.wallsStraightened),r:String(t.report.spaceRefsRemapped+t.report.roomRefsRemapped+t.report.positionsRemapped+t.report.markersDetached+t.report.orphanRoomLabelsRemoved+t.report.orphanDevicePositionsRemoved+t.report.orphanGroupPositionsRemoved)}))}catch(t){if(this.host._alignDialog&&(this.host._alignDialog={...this.host._alignDialog,busy:!1}),"wall_model_client_outdated"===t?.code)return void this.host._showToast(this.host._t("toast.wall_model_client_outdated"));"conflict"===t?.code&&await Promise.all([this.host._reloadConfigOnly(!0),this.host._reloadLayoutOnly()]),this.host._showToast(this.host._t("toast.error",{err:this.host._errText(t)}))}}async _undoPlanOptimization(){if(!this.host._canOptimizeUndo||this.host._optimizeUndoBusy)return;const t=this.host._undoKind;this._clearGeometryGesture(),this.host._optimizeUndoBusy=!0,this.host.requestUpdate();try{await this.host.hass.callWS({type:"houseplan/plan/optimize_undo",expected_config_rev:this.host._cfgRev,expected_layout_rev:this.host._layoutRev});const[e,s]=await Promise.all([this.host._getAuthoritativeConfig(),this.host.hass.callWS({type:"houseplan/layout/get"})]);if("adopted"!==(await this.host._adoptAuthoritative({cfgResp:e,layResp:s,reason:"optimize-undo",profile:"post-write"})).status)return;this.host._geometryHistory.clear(),this.host._cancelDeviceDrag(),this.host._devicePositionHistory.clear(),this.host._canOptimizeUndo=!1,this.host._undoKind=null,this.host._cfgEpoch++,this.host._modelCache=null,this.host._frame=null,this.host._regSignature="",this.host._maybeRebuildDevices(),this.host._cacheSnapshot(),this.host.requestUpdate(),this.host._showToast(this.host._t("import"===t?"backup.import_undone":"gs.optimize_undone"))}catch(t){this.host._canOptimizeUndo=!1,this.host._undoKind=null,this.host._showToast(this.host._t("toast.error",{err:this.host._errText(t)}))}finally{this.host._optimizeUndoBusy=!1,this.host.requestUpdate()}}async _runBackupExport(){const t=this.host._backupExportDialog;if(t&&!t.busy){this.host._backupExportDialog={...t,busy:!0,error:""};try{const e=await this.host.hass.callWS({type:"houseplan/export/create",kind:t.kind,space_id:"space"===t.kind?this.host._space:void 0,..."space"===t.kind&&t.planOnly?{plan_only:!0}:{},card_version:$i(vd)}),s=new Blob([JSON.stringify(e.document,null,2)+"\n"],{type:"application/json;charset=utf-8"}),i=URL.createObjectURL(s),o=document.createElement("a");o.href=i,o.download=e.filename||`houseplan-${t.kind}.json`,o.style.display="none",document.body.append(o),o.click(),o.remove(),window.setTimeout(()=>URL.revokeObjectURL(i),0),this.host._backupExportDialog=null,this.host._showToast(this.host._t("backup.export_done"))}catch(t){this.host._backupExportDialog&&(this.host._backupExportDialog={...this.host._backupExportDialog,busy:!1,error:this._backupErrorText(t)})}}}async _pickBackupImport(t){const e=t.target,s=e.files?.[0];if(e.value="",s){this.host._settingsDialog=null,this.host._backupImportDialog={filename:s.name,size:s.size,token:"",preview:null,expectedConfigRev:this.host._cfgRev,expectedLayoutRev:this.host._layoutRev,duplicatePolicy:"skip",confirmMissing:!1,busy:!0,error:""};try{this.host._saveConfigDebounced.pending()&&this.host._saveConfigDebounced.flush(),await this.host._writeChain,this.host._persistLayout.pending()&&this.host._persistLayout.flush();const t="/api/houseplan/import/preview?duplicate_policy=skip",e={method:"POST",body:s,headers:{"content-type":"application/json"}},i=this.host.hass?.fetchWithAuth?await this.host.hass.fetchWithAuth(t,e):await fetch(t,{...e,headers:{...e.headers,...this.host.hass?.auth?.data?.access_token?{authorization:`Bearer ${this.host.hass.auth.data.access_token}`}:{}}}),o=await i.json().catch(()=>({}));if(!i.ok||o.error)throw Object.assign(new Error(o.message||o.error||`HTTP ${i.status}`),{code:o.error});this.host._backupImportDialog&&(this.host._backupImportDialog={...this.host._backupImportDialog,token:o.token,preview:o.preview,expectedConfigRev:o.expected_config_rev,expectedLayoutRev:o.expected_layout_rev,busy:!1})}catch(t){this.host._backupImportDialog&&(this.host._backupImportDialog={...this.host._backupImportDialog,busy:!1,error:this._backupErrorText(t)})}}}async _setBackupDuplicatePolicy(t){const e=this.host._backupImportDialog;if(e&&!e.busy&&e.token&&t!==e.duplicatePolicy){this.host._backupImportDialog={...e,duplicatePolicy:t,busy:!0,error:""};try{const s=await this.host.hass.callWS({type:"houseplan/import/revalidate",token:e.token,duplicate_policy:t});this.host._backupImportDialog&&(this.host._backupImportDialog={...this.host._backupImportDialog,preview:{...e.preview,...s.preview},expectedConfigRev:s.expected_config_rev,expectedLayoutRev:s.expected_layout_rev,confirmMissing:!1,busy:!1})}catch(t){this.host._backupImportDialog&&(this.host._backupImportDialog={...this.host._backupImportDialog,duplicatePolicy:e.duplicatePolicy,preview:e.preview,confirmMissing:e.confirmMissing,busy:!1,error:this._backupErrorText(t)})}}}async _applyBackupImport(){const t=this.host._backupImportDialog;if(!t||t.busy||!t.token||!t.preview)return;if(t.preview.confirmation_required&&!t.confirmMissing)return;this.host._backupImportDialog={...t,busy:!0,error:""};const e=this.host._space;try{const s=await this.host.hass.callWS({type:"houseplan/import/apply",token:t.token,expected_config_rev:t.expectedConfigRev,expected_layout_rev:t.expectedLayoutRev,duplicate_policy:t.duplicatePolicy,confirm_missing_content:t.confirmMissing}),[i,o]=await Promise.all([this.host._getAuthoritativeConfig(),this.host.hass.callWS({type:"houseplan/layout/get"})]);if("adopted"!==(await this.host._adoptAuthoritative({cfgResp:i,layResp:o,reason:"import-apply",profile:"post-write"})).status)return this.host._backupImportDialog={...t,busy:!1,error:""},void this.host.requestUpdate();this.host._geometryHistory.clear(),this.host._dirtyPos.clear(),this.host._sentPos.clear(),this.host._defPos={},this.host._cfgEpoch++,this.host._modelCache=null,this.host._frame=null,this.host._visibleDeviceSnapshot=null,this.host._candidateDeviceSnapshot=null,this.host._stagedDeviceSnapshotToken=-1,this.host._capturedSnapshotConfigEpoch=-1,this.host._regSignature="",this.host._signer.invalidate(this.host.hass),this.host._resign(),this.host._maybeRebuildDevices();const a=this.host._serverCfg?.spaces||[],n="space"===s.kind&&s.space_id?s.space_id:a.some(t=>t.id===e)?e:a[0]?.id||this.host._space;this.host._hasFixedFloor?this.host._adoptInitialSpace(this.host._model,!0):this.host._commitSpace(n),this.host._backupImportDialog=null,this.host._cacheSnapshot(),this.host.requestUpdate();const r="space"===s.kind?t.preview.counts:s.counts;this.host._showToast(this.host._t("space"===s.kind?"backup.space_done":"backup.full_done",{spaces:String(r?.spaces||0),rooms:String(r?.rooms||0),markers:String(r?.markers||0),refs:String(s.repaired_target_refs||0)}))}catch(t){if("conflict"===t?.code&&this.host._backupImportDialog?.token)try{const t=this.host._backupImportDialog,e=await this.host.hass.callWS({type:"houseplan/import/revalidate",token:t.token,duplicate_policy:t.duplicatePolicy});return void(this.host._backupImportDialog={...t,preview:{...t.preview,...e.preview},expectedConfigRev:e.expected_config_rev,expectedLayoutRev:e.expected_layout_rev,confirmMissing:!1,busy:!1,error:this.host._t("backup.revalidated")})}catch(e){t=e}this.host._backupImportDialog&&(this.host._backupImportDialog={...this.host._backupImportDialog,busy:!1,error:this._backupErrorText(t)})}}_renderBackupExportDialog(){const t=this.host._backupExportDialog,e=(this.host._serverCfg?.spaces||[]).find(t=>t.id===this.host._space);return p``;var _}_preflightDiagnostics(t,e){const s=new Map((e?.spaces||[]).map(t=>[String(t?.id||""),t]));return{kind:"houseplan-optimize-preflight",origin:"runtime",cardVersion:$i(yd),checkedAt:(new Date).toISOString(),preflightFingerprint:t.fingerprint,failures:t.failures.map(t=>({spaceId:t.spaceId,displayName:t.displayName,reason:t.reason,detail:t.detail??null,spaceGeometryFingerprint:s.has(t.spaceId)?ne(s.get(t.spaceId)):null}))}}_reportPreflightFailure(t,e){t.ok||t.fingerprint===this.host._reportedPreflightFingerprint||(this.host._reportedPreflightFingerprint=t.fingerprint,console.warn("[houseplan] optimize preflight failed",this._preflightDiagnostics(t,e)))}_preflightVersionsDiffer(){const t=this.host._haIntegrationVersion;return"string"==typeof t&&t.length>0&&t!==$i(yd)}async _copyPreflightDiagnostics(){const t=this.host._alignDialog?.preflight;if(!t||t.ok)return;const e=JSON.stringify(this._preflightDiagnostics(t,this.host._alignDialog?.config??null),null,2);try{await navigator.clipboard.writeText(e),this.host._preflightClipboardFallback=null,this.host._showToast(this.host._t("gs.preflight_copied"))}catch{this.host._preflightClipboardFallback=e}}_checkOptimizeGeometryImpl(t){return wi(t,{fallbackSpaceName:t=>this.host._t("gs.align_preflight_space",{n:String(t)})})}_checkSpacePhysicalGeometryImpl(t,e,s){return ki(t,e,{fallbackSpaceName:t=>this.host._t("gs.align_preflight_space",{n:String(t)}),captureWallGeometry:s?(t,e)=>s(e):void 0})}_optimizeReferenceContext(t){const e=this.host._haRegistry,s=this.host._fullRegistryHass,i={},o=(...t)=>{for(const e of t){const t=String(e||"").trim();if(t)return t}return""};for(const[t,s]of Object.entries(e.devices||{}))i[t]=o(s?.name_by_user,s?.name,s?.model);for(const[t,s]of Object.entries(e.entities||{}))i[`lg_${t}`]=o(this.host.hass?.states?.[t]?.attributes?.friendly_name,s?.name,s?.original_name);for(const t of this.host._devices)i[t.id]=o(t.name,i[t.id]);for(const t of this.host._serverCfg?.markers||[]){const e=String(t.binding||"").indexOf(":"),a=e>0?t.binding.slice(0,e):"",n=e>0?t.binding.slice(e+1):"",r="device"===a?s?.devices?.[n]:"entity"===a?s?.entities?.[n]:null;i[t.id]=o(t.name,"device"===a?r?.name_by_user:null,r?.name,"entity"===a?this.host.hass?.states?.[n]?.attributes?.friendly_name:null,i[t.id])}return{effectiveAreaByMarker:Object.fromEntries(this.host._devices.filter(t=>!t.virtual&&!!t.area).map(t=>[t.id,t.area])),ownerRoster:{authoritative:e.authoritative,deviceIds:Object.keys(e.devices||{}),entityIds:[...new Set([...Object.keys(e.entities||{}),...Object.keys(this.host.hass?.states||{})])],names:i},removeLiveMissingPositions:t}}_previewAlignDialog(t){if(!this.host._norm||!this.host._serverCfg)return;const e=this.host._serverCfg.spaces||[];let s;try{s=On(this.host._serverCfg,this.host._layout||{},this._optimizeReferenceContext(t))}catch(t){return void this._showWallModelMigrationBlocked(t)}const i=s.changed?this.host._checkOptimizeGeometry(s.config):null;i&&this._reportPreflightFailure(i,s.config);const o=Math.ceil(10*s.report.maxShiftCm)/10,a=e.find(t=>null!=t?.id&&String(t.id)===s.report.maxSpace),n=e.length>1&&a?String(a.title||a.id):"";this.host._preflightClipboardFallback=null,this.host._alignDialog={report:s.report,config:s.config,layout:s.layout,cm:o,where:n,preflight:i,changed:s.changed,busy:!1,removeLiveMissingPositions:t}}async _runAlignToGrid(){let t=this.host._alignDialog;if(!t||t.busy||!this.host._serverCfg||!t.changed||!t.preflight?.ok)return;const e=yt(t.config);if(t.preflight.fingerprint!==e){const e=this.host._checkOptimizeGeometry(t.config);if(this._reportPreflightFailure(e,t.config),t={...t,preflight:e},this.host._alignDialog=t,!e.ok)return}this._clearGeometryGesture(),this.host._alignDialog={...t,busy:!0};try{await Hn(this.host,t.config,t.layout),this.host._alignDialog=null,this.host._preflightClipboardFallback=null,this.host._showToast(this.host._t("gs.align_done",{n:String(t.report.moved),m:String(t.report.migrated+t.report.canonicalized+t.report.coordsCanonicalized+t.report.latticeCoordinatesCanonicalized+t.report.wallsMerged+t.report.spansMerged+t.report.partitionsMerged+t.report.partitionsReconciled+t.report.openingsRehosted+t.report.wallsStraightened),r:String(t.report.spaceRefsRemapped+t.report.roomRefsRemapped+t.report.positionsRemapped+t.report.markersDetached+t.report.orphanRoomLabelsRemoved+t.report.orphanDevicePositionsRemoved+t.report.orphanGroupPositionsRemoved)}))}catch(t){if(this.host._alignDialog&&(this.host._alignDialog={...this.host._alignDialog,busy:!1}),"wall_model_client_outdated"===t?.code)return void this.host._showToast(this.host._t("toast.wall_model_client_outdated"));"conflict"===t?.code&&await Promise.all([this.host._reloadConfigOnly(!0),this.host._reloadLayoutOnly()]),this.host._showToast(this.host._t("toast.error",{err:this.host._errText(t)}))}}async _undoPlanOptimization(){if(!this.host._canOptimizeUndo||this.host._optimizeUndoBusy)return;const t=this.host._undoKind;this._clearGeometryGesture(),this.host._optimizeUndoBusy=!0,this.host.requestUpdate();try{await this.host.hass.callWS({type:"houseplan/plan/optimize_undo",expected_config_rev:this.host._cfgRev,expected_layout_rev:this.host._layoutRev});const[e,s]=await Promise.all([this.host._getAuthoritativeConfig(),this.host.hass.callWS({type:"houseplan/layout/get"})]);if("adopted"!==(await this.host._adoptAuthoritative({cfgResp:e,layResp:s,reason:"optimize-undo",profile:"post-write"})).status)return;this.host._geometryHistory.clear(),this.host._cancelDeviceDrag(),this.host._devicePositionHistory.clear(),this.host._canOptimizeUndo=!1,this.host._undoKind=null,this.host._cfgEpoch++,this.host._modelCache=null,this.host._frame=null,this.host._regSignature="",this.host._maybeRebuildDevices(),this.host._cacheSnapshot(),this.host.requestUpdate(),this.host._showToast(this.host._t("import"===t?"backup.import_undone":"gs.optimize_undone"))}catch(t){this.host._canOptimizeUndo=!1,this.host._undoKind=null,this.host._showToast(this.host._t("toast.error",{err:this.host._errText(t)}))}finally{this.host._optimizeUndoBusy=!1,this.host.requestUpdate()}}async _runBackupExport(){const t=this.host._backupExportDialog;if(t&&!t.busy){this.host._backupExportDialog={...t,busy:!0,error:""};try{const e=await this.host.hass.callWS({type:"houseplan/export/create",kind:t.kind,space_id:"space"===t.kind?this.host._space:void 0,..."space"===t.kind&&t.planOnly?{plan_only:!0}:{},card_version:$i(yd)}),s=new Blob([JSON.stringify(e.document,null,2)+"\n"],{type:"application/json;charset=utf-8"}),i=URL.createObjectURL(s),o=document.createElement("a");o.href=i,o.download=e.filename||`houseplan-${t.kind}.json`,o.style.display="none",document.body.append(o),o.click(),o.remove(),window.setTimeout(()=>URL.revokeObjectURL(i),0),this.host._backupExportDialog=null,this.host._showToast(this.host._t("backup.export_done"))}catch(t){this.host._backupExportDialog&&(this.host._backupExportDialog={...this.host._backupExportDialog,busy:!1,error:this._backupErrorText(t)})}}}async _pickBackupImport(t){const e=t.target,s=e.files?.[0];if(e.value="",s){this.host._settingsDialog=null,this.host._backupImportDialog={filename:s.name,size:s.size,token:"",preview:null,expectedConfigRev:this.host._cfgRev,expectedLayoutRev:this.host._layoutRev,duplicatePolicy:"skip",confirmMissing:!1,busy:!0,error:""};try{this.host._saveConfigDebounced.pending()&&this.host._saveConfigDebounced.flush(),await this.host._writeChain,this.host._persistLayout.pending()&&this.host._persistLayout.flush();const t="/api/houseplan/import/preview?duplicate_policy=skip",e={method:"POST",body:s,headers:{"content-type":"application/json"}},i=this.host.hass?.fetchWithAuth?await this.host.hass.fetchWithAuth(t,e):await fetch(t,{...e,headers:{...e.headers,...this.host.hass?.auth?.data?.access_token?{authorization:`Bearer ${this.host.hass.auth.data.access_token}`}:{}}}),o=await i.json().catch(()=>({}));if(!i.ok||o.error)throw Object.assign(new Error(o.message||o.error||`HTTP ${i.status}`),{code:o.error});this.host._backupImportDialog&&(this.host._backupImportDialog={...this.host._backupImportDialog,token:o.token,preview:o.preview,expectedConfigRev:o.expected_config_rev,expectedLayoutRev:o.expected_layout_rev,busy:!1})}catch(t){this.host._backupImportDialog&&(this.host._backupImportDialog={...this.host._backupImportDialog,busy:!1,error:this._backupErrorText(t)})}}}async _setBackupDuplicatePolicy(t){const e=this.host._backupImportDialog;if(e&&!e.busy&&e.token&&t!==e.duplicatePolicy){this.host._backupImportDialog={...e,duplicatePolicy:t,busy:!0,error:""};try{const s=await this.host.hass.callWS({type:"houseplan/import/revalidate",token:e.token,duplicate_policy:t});this.host._backupImportDialog&&(this.host._backupImportDialog={...this.host._backupImportDialog,preview:{...e.preview,...s.preview},expectedConfigRev:s.expected_config_rev,expectedLayoutRev:s.expected_layout_rev,confirmMissing:!1,busy:!1})}catch(t){this.host._backupImportDialog&&(this.host._backupImportDialog={...this.host._backupImportDialog,duplicatePolicy:e.duplicatePolicy,preview:e.preview,confirmMissing:e.confirmMissing,busy:!1,error:this._backupErrorText(t)})}}}async _applyBackupImport(){const t=this.host._backupImportDialog;if(!t||t.busy||!t.token||!t.preview)return;if(t.preview.confirmation_required&&!t.confirmMissing)return;this.host._backupImportDialog={...t,busy:!0,error:""};const e=this.host._space;try{const s=await this.host.hass.callWS({type:"houseplan/import/apply",token:t.token,expected_config_rev:t.expectedConfigRev,expected_layout_rev:t.expectedLayoutRev,duplicate_policy:t.duplicatePolicy,confirm_missing_content:t.confirmMissing}),[i,o]=await Promise.all([this.host._getAuthoritativeConfig(),this.host.hass.callWS({type:"houseplan/layout/get"})]);if("adopted"!==(await this.host._adoptAuthoritative({cfgResp:i,layResp:o,reason:"import-apply",profile:"post-write"})).status)return this.host._backupImportDialog={...t,busy:!1,error:""},void this.host.requestUpdate();this.host._geometryHistory.clear(),this.host._dirtyPos.clear(),this.host._sentPos.clear(),this.host._defPos={},this.host._cfgEpoch++,this.host._modelCache=null,this.host._frame=null,this.host._visibleDeviceSnapshot=null,this.host._candidateDeviceSnapshot=null,this.host._stagedDeviceSnapshotToken=-1,this.host._capturedSnapshotConfigEpoch=-1,this.host._regSignature="",this.host._signer.invalidate(this.host.hass),this.host._resign(),this.host._maybeRebuildDevices();const a=this.host._serverCfg?.spaces||[],n="space"===s.kind&&s.space_id?s.space_id:a.some(t=>t.id===e)?e:a[0]?.id||this.host._space;this.host._hasFixedFloor?this.host._adoptInitialSpace(this.host._model,!0):this.host._commitSpace(n),this.host._backupImportDialog=null,this.host._cacheSnapshot(),this.host.requestUpdate();const r="space"===s.kind?t.preview.counts:s.counts;this.host._showToast(this.host._t("space"===s.kind?"backup.space_done":"backup.full_done",{spaces:String(r?.spaces||0),rooms:String(r?.rooms||0),markers:String(r?.markers||0),refs:String(s.repaired_target_refs||0)}))}catch(t){if("conflict"===t?.code&&this.host._backupImportDialog?.token)try{const t=this.host._backupImportDialog,e=await this.host.hass.callWS({type:"houseplan/import/revalidate",token:t.token,duplicate_policy:t.duplicatePolicy});return void(this.host._backupImportDialog={...t,preview:{...t.preview,...e.preview},expectedConfigRev:e.expected_config_rev,expectedLayoutRev:e.expected_layout_rev,confirmMissing:!1,busy:!1,error:this.host._t("backup.revalidated")})}catch(e){t=e}this.host._backupImportDialog&&(this.host._backupImportDialog={...this.host._backupImportDialog,busy:!1,error:this._backupErrorText(t)})}}_renderBackupExportDialog(){const t=this.host._backupExportDialog,e=(this.host._serverCfg?.spaces||[]).find(t=>t.id===this.host._space);return p`this.host._backupExportDialog=null}>
    ${this.host._t("backup.export_hint")}
    @@ -2181,7 +2168,7 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db ${t.busy?"…":this.host._t("gs.align_run")} `:d}
    -
    `}_renderSettingsDialog(){return sr.call(this)}_rulesSet(t){this.host._rulesDialog={...this.host._rulesDialog,rules:t}}async _saveRules(){const t=this.host._rulesDialog;if(!t||t.busy)return;const e=t.rules.filter(t=>t.pattern.trim()&&t.icon.trim());this.host._rulesDialog={...t,busy:!0};try{const t=this.host._serverCfg,s=JSON.stringify(e)===JSON.stringify(Be),i={...t.settings};s?delete i.icon_rules:i.icon_rules=e,this.host._serverCfg={...t,settings:i},await this._saveConfigNow(),this.host._rulesDialog=null,this.host._regSignature="",this.host._maybeRebuildDevices(),this.host._showToast(this.host._t("rules.saved"))}catch(t){this.host._rulesDialog&&(this.host._rulesDialog={...this.host._rulesDialog,busy:!1}),this.host._showToast(this.host._t("toast.error",{err:this.host._errText(t)}))}}_renderRulesDialog(){const t=this.host._rulesDialog,e=Si(t.rules),s=t.test.trim()?Pi(t.test,"",e):null,i=(e,s)=>{const i=[...t.rules],o=e+s;o<0||o>=i.length||([i[e],i[o]]=[i[o],i[e]],this._rulesSet(i))};return p``}_renderSettingsDialog(){return ir.call(this)}_rulesSet(t){this.host._rulesDialog={...this.host._rulesDialog,rules:t}}async _saveRules(){const t=this.host._rulesDialog;if(!t||t.busy)return;const e=t.rules.filter(t=>t.pattern.trim()&&t.icon.trim());this.host._rulesDialog={...t,busy:!0};try{const t=this.host._serverCfg,s=JSON.stringify(e)===JSON.stringify(Be),i={...t.settings};s?delete i.icon_rules:i.icon_rules=e,this.host._serverCfg={...t,settings:i},await this._saveConfigNow(),this.host._rulesDialog=null,this.host._regSignature="",this.host._maybeRebuildDevices(),this.host._showToast(this.host._t("rules.saved"))}catch(t){this.host._rulesDialog&&(this.host._rulesDialog={...this.host._rulesDialog,busy:!1}),this.host._showToast(this.host._t("toast.error",{err:this.host._errText(t)}))}}_renderRulesDialog(){const t=this.host._rulesDialog,e=Si(t.rules),s=t.test.trim()?Pi(t.test,"",e):null,i=(e,s)=>{const i=[...t.rules],o=e+s;o<0||o>=i.length||([i[e],i[o]]=[i[o],i[e]],this._rulesSet(i))};return p`this.host._rulesDialog=null}>
    ${this.host._t("rules.hint")}
    @@ -2302,7 +2289,7 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db ${Uo(this,e,a)} `:d} -
    `}_vacMapId(t,e,s=this.host._planHass){return this.host._vacMapId(t,e,s)}_vacSaveMatrix(t,e,s,i,o=""){return Wc(this,t,e,s,i,o)}_vacPlanRoomAnchors(t){return(this.host._spaceModelById(t)?.rooms||[]).map(t=>({room:t,poly:N(t)})).filter(({room:t,poly:e})=>t.name&&e).map(({room:t,poly:e})=>{const s=Ri(e);return s?{name:String(t.name),cx:s[0],cy:s[1]}:null}).filter(Boolean)}async _vacAutoCalibrate(t){if(this.host._markerDialog?.busy)return;const e=this.host._vacSource(t),s=e?Ii(this.host.hass?.states[e]?.attributes):null;if(!e||!s||s.rooms.length<3)return void this.host._showToast(this.host._t("vac.autocal_no_rooms"));const i=this._vacMapId(t,s),a=function(t,e,s,i,a){const n=o(t,e,s,i).find(t=>t.source===i&&t.map_id===a);return{space:n?.space||s,routeId:n?.id||""}}(t.id,t.marker?.vacuum??null,t.space,e,i),n=zi(s.rooms,this._vacPlanRoomAnchors(a.space));if(!n)return void this.host._showToast(this.host._t("vac.autocal_no_match"));const r=this.host._serverCfg?.spaces?.find(t=>t.id===a.space),l=Number(r?.cell_cm),h=Number.isFinite(l)&&l>0?l:5,c=Fi(n.residual,this.host._gridPitch,h);c>Ni?this.host._vacCalConfirm={markerId:t.id,source:e,mapId:i,routeId:a.routeId,space:a.space,matrix:n.matrix,rooms:n.matched.length,error:fe(c,"mi"===this.host.hass?.config?.unit_system?.length)}:await async function(t,e){if(Hc.has(t))return;Hc.add(t);const s=t.host,i=s._markerDialog,o=i?{...i,busy:!0}:null;o&&(s._markerDialog=o,s.requestUpdate());try{await Wc(t,e.markerId,e.source,e.mapId,e.matrix,e.routeId)&&s._showToast(s._t("vac.autocal_done",{rooms:String(e.rooms)}))}finally{Hc.delete(t),o&&s._markerDialog===o&&(s._markerDialog={...o,busy:!1},s.requestUpdate())}}(this,{markerId:t.id,source:e,mapId:i,routeId:a.routeId,space:a.space,matrix:n.matrix,rooms:n.matched.length})}_vacApplyCalibrationProposal(t){return async function(t,e){const s=t.host,i=s._vacCalConfirm;if(!i||i.busy)return;if(e){const t=s._devices.find(t=>t.id===i.markerId),e=n(i.matrix);if(!t||!e)return;const o=i.space||t.space;if(o!==s._space&&!s._commitSpace(o))return;return s._vacCalConfirm=null,s._markerDialog=null,void(s._vacFit={markerId:i.markerId,source:i.source,routeId:i.routeId,mapId:i.mapId,p:e,drag:null})}const o={...i,busy:!0};s._vacCalConfirm=o,s.requestUpdate();const a=await Wc(t,i.markerId,i.source,i.mapId,i.matrix,i.routeId);s._vacCalConfirm===o&&(s._vacCalConfirm=a?null:{...i,busy:!1},s.requestUpdate()),a&&s._showToast(s._t("vac.autocal_done",{rooms:String(i.rooms)}))}(this,t)}_vacStartFit(t,e=""){if(this.host._markerDialog?.busy)return;const s=this.host._vacSource(t),i=s?Ii(this.host.hass?.states[s]?.attributes):null;if(!s||!i)return void this.host._showToast(this.host._t("vac.cal_need_pos"));const l=this._vacMapId(t,i),h=function(t,e,s){const i=o(t,e,s.dockSpace,s.source),l=i.find(t=>t.id===s.routeId)||i.find(t=>t.source===s.source&&t.map_id===s.mapId)||null,h=l?.space||s.dockSpace,c=s.viewBoxOf(h);if(!c)return null;const d=a(l?l.calibration:e?.calibration?.[s.mapId]),p=d&&n(d)||r(s.rooms,c);return{space:h,routeId:l?.id||"",params:p}}(t.id,t.marker?.vacuum??null,{routeId:e,source:s,mapId:l,dockSpace:t.space,rooms:i.rooms,viewBoxOf:t=>this.host._spaceModelById(t)?.vb??null});h&&(this.host._markerDialog=null,(h.space===this.host._space||this.host._commitSpace(h.space))&&(this.host._vacFit={markerId:t.id,source:s,mapId:l,routeId:h.routeId,p:h.params,drag:null}))}_vacFitSave(){return async function(t,e){const s=t.host,i=s._vacFit;if(!i||i.busy)return;const o={...i,busy:!0,drag:null};s._vacFit=o,s.requestUpdate();const a=await Wc(t,i.markerId,i.source,i.mapId,e(i.p),i.routeId);s._vacFit===o&&(s._vacFit=a?null:{...i,busy:!1,drag:null},s.requestUpdate()),a&&s._showToast(s._t("vac.cal_done"))}(this,Ei)}_vacFitTurn(t){const e=this.host._vacFit;if(!e||e.busy)return;const s=Ii(this.host.hass?.states[e.source]?.attributes),i=this._vacGhostCentre(s?.rooms||[]),o={...e.p,...t};this.host._vacFit={...e,p:Ai(o,e.p,i[0],i[1])}}_vacGhostCentre(t){const e=[],s=[];for(const i of t)e.push(i.x0??i.cx,i.x1??i.cx),s.push(i.y0??i.cy,i.y1??i.cy);return e.length?[(Math.min(...e)+Math.max(...e))/2,(Math.min(...s)+Math.max(...s))/2]:[0,0]}_vacDelta(t,e,s){const i=this.host._stageEl,o=i?.clientWidth||1,a=i?.clientHeight||1;return[e/o*t.w,s/a*t.h]}_vacFitPointer(t,e){const s=this.host._vacFit;if(!s)return;if(t.stopPropagation(),s.busy)return;if("pointerdown"===t.type){const e=t.target,i=e.getAttribute?.("data-corner");try{t.currentTarget.setPointerCapture?.(t.pointerId)}catch{}return void(this.host._vacFit={...s,drag:i?{kind:"scale",sx:t.clientX,sy:t.clientY,p0:{...s.p},fx:Number(i.split(",")[0]),fy:Number(i.split(",")[1])}:{kind:"move",sx:t.clientX,sy:t.clientY,p0:{...s.p},fx:0,fy:0}})}const i=s.drag;if(i){if("pointermove"===t.type){const[o,a]=this._vacDelta(e,t.clientX-i.sx,t.clientY-i.sy);if("move"===i.kind)this.host._vacFit={...s,p:{...i.p0,ox:i.p0.ox+o,oy:i.p0.oy+a}};else{const t=Ii(this.host.hass?.states[s.source]?.attributes),e=this._vacGhostCentre(t?.rooms||[]),n=Ei(i.p0),[r,l]=Oi(n,e[0],e[1]),[h,c]=Oi(n,i.fx,i.fy),d=Math.hypot(r-h,l-c)||1,[p,u]=[2*r-h,2*l-c],_=Math.hypot(p+2*o-h,u+2*a-c)/2,g=Math.max(.05,_/d),m={...i.p0,s:i.p0.s*g};this.host._vacFit={...s,p:Ai(m,i.p0,i.fx,i.fy)}}return}"pointerup"!==t.type&&"pointercancel"!==t.type||(this.host._vacFit={...s,drag:null})}}_renderVacFit(t){const e=this.host._vacFit;if(!e)return d;const s=Ii(this.host._renderPlanHass?.states?.[e.source]?.attributes);if(!s)return d;const i=Ei(e.p),o=[],a=[],n=[];for(const t of s.rooms){if(null==t.x0)continue;const e=[[t.x0,t.y0],[t.x1,t.y0],[t.x1,t.y1],[t.x0,t.y1]].map(([t,e])=>Oi(i,t,e));e.forEach(([t,e])=>{a.push(t),n.push(e)});const[s,r]=Oi(i,t.cx,t.cy);o.push(At` +
    `}_vacMapId(t,e,s=this.host._planHass){return this.host._vacMapId(t,e,s)}_vacSaveMatrix(t,e,s,i,o=""){return jc(this,t,e,s,i,o)}_vacPlanRoomAnchors(t){return(this.host._spaceModelById(t)?.rooms||[]).map(t=>({room:t,poly:N(t)})).filter(({room:t,poly:e})=>t.name&&e).map(({room:t,poly:e})=>{const s=Ri(e);return s?{name:String(t.name),cx:s[0],cy:s[1]}:null}).filter(Boolean)}async _vacAutoCalibrate(t){if(this.host._markerDialog?.busy)return;const e=this.host._vacSource(t),s=e?Ii(this.host.hass?.states[e]?.attributes):null;if(!e||!s||s.rooms.length<3)return void this.host._showToast(this.host._t("vac.autocal_no_rooms"));const i=this._vacMapId(t,s),a=function(t,e,s,i,a){const n=o(t,e,s,i).find(t=>t.source===i&&t.map_id===a);return{space:n?.space||s,routeId:n?.id||""}}(t.id,t.marker?.vacuum??null,t.space,e,i),n=zi(s.rooms,this._vacPlanRoomAnchors(a.space));if(!n)return void this.host._showToast(this.host._t("vac.autocal_no_match"));const r=this.host._serverCfg?.spaces?.find(t=>t.id===a.space),l=Number(r?.cell_cm),h=Number.isFinite(l)&&l>0?l:5,c=Fi(n.residual,this.host._gridPitch,h);c>Ni?this.host._vacCalConfirm={markerId:t.id,source:e,mapId:i,routeId:a.routeId,space:a.space,matrix:n.matrix,rooms:n.matched.length,error:fe(c,"mi"===this.host.hass?.config?.unit_system?.length)}:await async function(t,e){if(Bc.has(t))return;Bc.add(t);const s=t.host,i=s._markerDialog,o=i?{...i,busy:!0}:null;o&&(s._markerDialog=o,s.requestUpdate());try{await jc(t,e.markerId,e.source,e.mapId,e.matrix,e.routeId)&&s._showToast(s._t("vac.autocal_done",{rooms:String(e.rooms)}))}finally{Bc.delete(t),o&&s._markerDialog===o&&(s._markerDialog={...o,busy:!1},s.requestUpdate())}}(this,{markerId:t.id,source:e,mapId:i,routeId:a.routeId,space:a.space,matrix:n.matrix,rooms:n.matched.length})}_vacApplyCalibrationProposal(t){return async function(t,e){const s=t.host,i=s._vacCalConfirm;if(!i||i.busy)return;if(e){const t=s._devices.find(t=>t.id===i.markerId),e=n(i.matrix);if(!t||!e)return;const o=i.space||t.space;if(o!==s._space&&!s._commitSpace(o))return;return s._vacCalConfirm=null,s._markerDialog=null,void(s._vacFit={markerId:i.markerId,source:i.source,routeId:i.routeId,mapId:i.mapId,p:e,drag:null})}const o={...i,busy:!0};s._vacCalConfirm=o,s.requestUpdate();const a=await jc(t,i.markerId,i.source,i.mapId,i.matrix,i.routeId);s._vacCalConfirm===o&&(s._vacCalConfirm=a?null:{...i,busy:!1},s.requestUpdate()),a&&s._showToast(s._t("vac.autocal_done",{rooms:String(i.rooms)}))}(this,t)}_vacStartFit(t,e=""){if(this.host._markerDialog?.busy)return;const s=this.host._vacSource(t),i=s?Ii(this.host.hass?.states[s]?.attributes):null;if(!s||!i)return void this.host._showToast(this.host._t("vac.cal_need_pos"));const l=this._vacMapId(t,i),h=function(t,e,s){const i=o(t,e,s.dockSpace,s.source),l=i.find(t=>t.id===s.routeId)||i.find(t=>t.source===s.source&&t.map_id===s.mapId)||null,h=l?.space||s.dockSpace,c=s.viewBoxOf(h);if(!c)return null;const d=a(l?l.calibration:e?.calibration?.[s.mapId]),p=d&&n(d)||r(s.rooms,c);return{space:h,routeId:l?.id||"",params:p}}(t.id,t.marker?.vacuum??null,{routeId:e,source:s,mapId:l,dockSpace:t.space,rooms:i.rooms,viewBoxOf:t=>this.host._spaceModelById(t)?.vb??null});h&&(this.host._markerDialog=null,(h.space===this.host._space||this.host._commitSpace(h.space))&&(this.host._vacFit={markerId:t.id,source:s,mapId:l,routeId:h.routeId,p:h.params,drag:null}))}_vacFitSave(){return async function(t,e){const s=t.host,i=s._vacFit;if(!i||i.busy)return;const o={...i,busy:!0,drag:null};s._vacFit=o,s.requestUpdate();const a=await jc(t,i.markerId,i.source,i.mapId,e(i.p),i.routeId);s._vacFit===o&&(s._vacFit=a?null:{...i,busy:!1,drag:null},s.requestUpdate()),a&&s._showToast(s._t("vac.cal_done"))}(this,Ei)}_vacFitTurn(t){const e=this.host._vacFit;if(!e||e.busy)return;const s=Ii(this.host.hass?.states[e.source]?.attributes),i=this._vacGhostCentre(s?.rooms||[]),o={...e.p,...t};this.host._vacFit={...e,p:Ai(o,e.p,i[0],i[1])}}_vacGhostCentre(t){const e=[],s=[];for(const i of t)e.push(i.x0??i.cx,i.x1??i.cx),s.push(i.y0??i.cy,i.y1??i.cy);return e.length?[(Math.min(...e)+Math.max(...e))/2,(Math.min(...s)+Math.max(...s))/2]:[0,0]}_vacDelta(t,e,s){const i=this.host._stageEl,o=i?.clientWidth||1,a=i?.clientHeight||1;return[e/o*t.w,s/a*t.h]}_vacFitPointer(t,e){const s=this.host._vacFit;if(!s)return;if(t.stopPropagation(),s.busy)return;if("pointerdown"===t.type){const e=t.target,i=e.getAttribute?.("data-corner");try{t.currentTarget.setPointerCapture?.(t.pointerId)}catch{}return void(this.host._vacFit={...s,drag:i?{kind:"scale",sx:t.clientX,sy:t.clientY,p0:{...s.p},fx:Number(i.split(",")[0]),fy:Number(i.split(",")[1])}:{kind:"move",sx:t.clientX,sy:t.clientY,p0:{...s.p},fx:0,fy:0}})}const i=s.drag;if(i){if("pointermove"===t.type){const[o,a]=this._vacDelta(e,t.clientX-i.sx,t.clientY-i.sy);if("move"===i.kind)this.host._vacFit={...s,p:{...i.p0,ox:i.p0.ox+o,oy:i.p0.oy+a}};else{const t=Ii(this.host.hass?.states[s.source]?.attributes),e=this._vacGhostCentre(t?.rooms||[]),n=Ei(i.p0),[r,l]=Oi(n,e[0],e[1]),[h,c]=Oi(n,i.fx,i.fy),d=Math.hypot(r-h,l-c)||1,[p,u]=[2*r-h,2*l-c],_=Math.hypot(p+2*o-h,u+2*a-c)/2,g=Math.max(.05,_/d),m={...i.p0,s:i.p0.s*g};this.host._vacFit={...s,p:Ai(m,i.p0,i.fx,i.fy)}}return}"pointerup"!==t.type&&"pointercancel"!==t.type||(this.host._vacFit={...s,drag:null})}}_renderVacFit(t){const e=this.host._vacFit;if(!e)return d;const s=Ii(this.host._renderPlanHass?.states?.[e.source]?.attributes);if(!s)return d;const i=Ei(e.p),o=[],a=[],n=[];for(const t of s.rooms){if(null==t.x0)continue;const e=[[t.x0,t.y0],[t.x1,t.y0],[t.x1,t.y1],[t.x0,t.y1]].map(([t,e])=>Oi(i,t,e));e.forEach(([t,e])=>{a.push(t),n.push(e)});const[s,r]=Oi(i,t.cx,t.cy);o.push(At` ${t.name}`)}let r=d;if(s.pos){const[e,o]=Oi(i,s.pos.x,s.pos.y);r=At``}const l=[];if(a.length){const e=(()=>{const t=i[0]*i[4]-i[1]*i[3];return(e,s)=>[(i[4]*(e-i[2])-i[1]*(s-i[5]))/t,(-i[3]*(e-i[2])+i[0]*(s-i[5]))/t]})(),s=Math.min(...a),o=Math.max(...a),r=Math.min(...n),h=Math.max(...n),c=.022*t.w,d=c/4;for(const[t,i,a,n]of[[s,r,o,h],[o,r,s,h],[o,h,s,r],[s,h,o,r]]){const s=e(a,n);l.push(At` `)}}return p`t.id===this.host._roomEditId);if(!e)return this.host._roomDialog=!1,void(this.host._roomEditId=null);e.name=this.host._nameSel.trim()||e.name,e.area=this.host._areaSel||null;const s=e.settings||{},i={...s};Wi(i,this.host._roomTempMin,this.host._roomTempMax)&&(this.host._roomFill?i.fill_mode=this.host._roomFill:delete i.fill_mode,"custom"===this.host._roomFill&&this.host._roomCustomFill?i.custom_fill=this.host._roomCustomFill:delete i.custom_fill,"glow"===s.fill_mode&&"boolean"!=typeof s.glow&&(i.glow=!0),this.host._roomTempSrc?i.temp_source=this.host._roomTempSrc:delete i.temp_source,this.host._roomHumSrc?i.hum_source=this.host._roomHumSrc:delete i.hum_source,1!==this.host._roomNameScale?i.name_scale=this.host._roomNameScale:delete i.name_scale,1!==this.host._roomLabelScale?i.label_scale=this.host._roomLabelScale:delete i.label_scale,Object.keys(i).length?e.settings=i:delete e.settings,this._saveConfig(),this.host._roomDialog=!1,this.host._roomEditId=null,this.host._nameSel="",this.host._areaSel="",this.host._regSignature="",this.host._maybeRebuildDevices(),this.host.requestUpdate(),this.host._showToast(this.host._t("toast.room_updated")))}_roomSrcCandidates(){const t=this.host._planHass,e=ge(this.host._markers),s=this.host._roomSrcFilter.trim().toLowerCase(),i=[];for(const o of Object.values(t.devices)){if("service"===o.entry_type)continue;if(e.devices.has(o.id))continue;const t=(o.name_by_user||o.name||o.id).trim();s&&!t.toLowerCase().includes(s)||i.push({value:"device:"+o.id,label:t,sub:o.model||this.host._t("marker.sub_device")})}for(const[o,a]of Object.entries(t.entities)){if(!o.startsWith("sensor.")||a.hidden)continue;if(me(t,o,e))continue;const n=a.name||t.states[o]?.attributes?.friendly_name||o;s&&!(n+" "+o).toLowerCase().includes(s)||i.push({value:"entity:"+o,label:n,sub:o})}return i.sort((t,e)=>t.label.localeCompare(e.label)),i.slice(0,200)}_roomSrcLabel(t){const e=t.indexOf(":"),s=t.slice(0,e),i=t.slice(e+1);return"device"===s?this.host._fullRegistryHass.devices[i]?.name_by_user||this.host._fullRegistryHass.devices[i]?.name||i:this.host._fullRegistryHass.entities[i]?.name||this.host.hass.states[i]?.attributes?.friendly_name||i}_labelPos(t,e){const s=this.host._layout["rl_"+(t.id||"")];if(s&&s.s===e)return{x:s.x*wd,y:s.y*wd};const i=this._snap(this.host._roomCenter(t));return{x:i[0],y:i[1]}}_labelDown(t,e,s){if("plan"!==this.host._mode)return;t.preventDefault(),t.stopPropagation();const i=this._labelPos(e,s);this.host._drag={id:"rl_"+(e.id||""),sx:t.clientX,sy:t.clientY,ox:i.x,oy:i.y,moved:!1},xd(t),this.host._tip=null}_labelMove(t,e,s){const i="rl_"+(e.id||"");if(!this.host._drag||this.host._drag.id!==i)return;const o=this.host._stageEl;if(!o)return;const a=this.host._spaceModelById(s);if(!a)return;const n=a.vb,r=o.getBoundingClientRect(),l=this.host._viewOr(n),h=(t.clientX-this.host._drag.sx)/r.width*l.w,c=(t.clientY-this.host._drag.sy)/r.height*l.h;Math.abs(t.clientX-this.host._drag.sx)+Math.abs(t.clientY-this.host._drag.sy)>3&&(this.host._drag.moved=!0);const d=qe(this.host._drag.ox+h),p=qe(this.host._drag.oy+c);this.host._savePos({id:i,space:s},d,p)}_labelUp(t){const e="rl_"+(t.id||"");if(!this.host._drag||this.host._drag.id!==e)return;const s=this.host._drag.moved;this.host._drag=s?this.host._drag:null,s&&window.setTimeout(()=>this.host._drag=null,0)}_labelScale(t){const e=this.host._layout["rl_"+(t.id||"")]?.k;return"number"==typeof e&&Number.isFinite(e)?Math.min(3,Math.max(.5,e)):1}_rlResizeDown(t,e,s){if("plan"!==this.host._mode)return;t.preventDefault(),t.stopPropagation();const i=t.target.closest(".roomlabel");if(!i)return;const o=i.getBoundingClientRect(),a=o.left+o.width/2,n=o.top+o.height/2,r=Math.max(8,Math.hypot(t.clientX-a,t.clientY-n));this.host._rlResize={id:"rl_"+(e.id||""),space:s,k0:this._labelScale(e),cx:a,cy:n,d0:r},xd(t)}_rlResizeMove(t){const e=this.host._rlResize;if(!e)return;t.stopPropagation();const s=Math.max(8,Math.hypot(t.clientX-e.cx,t.clientY-e.cy)),i=Math.min(3,Math.max(.5,e.k0*(s/e.d0))),o=this.host._layout[e.id];if(o)this.host._layout={...this.host._layout,[e.id]:{...o,k:i}};else{const t=e.id.slice(3),s=this.host._spaceModelById(e.space);if(!s)return;const o=s.rooms.find(e=>e.id===t);if(!o)return;const a=this._labelPos(o,e.space);this.host._layout={...this.host._layout,[e.id]:{s:e.space,x:a.x/wd,y:a.y/wd,k:i}}}this.host._dirtyPos.add(e.id)}_rlResizeUp(){this.host._rlResize&&(this.host._rlResize=null,this.host._persistLayout())}_renderRoomGear(t,e,s){if(!t.id)return d;let i=null;if(t.poly?(i=this.host._gearPtCache.get(t.poly)||null,i||(i=gs(t.poly),this.host._gearPtCache.set(t.poly,i))):null!=t.x&&null!=t.y&&(i=[t.x+(t.w||0)/2,t.y+(t.h||0)/2]),!i)return d;const o=(i[0]-s.x)/s.w*100,a=(i[1]-s.y)/s.h*100;return p``}_resetRoomDialogFields(){this.host._roomEditId=null,this.host._roomFill="",this.host._roomCustomFill=null,this.host._roomTempMin="",this.host._roomTempMax="",this.host._roomTempSrc="",this.host._roomHumSrc="",this.host._roomSrcOpen=null,this.host._roomSrcFilter="",this.host._roomNameScale=1,this.host._roomLabelScale=1}_openRoomEdit(t){if(!t.id)return;this.host._roomEditId=t.id,this.host._nameSel=t.name||"",this.host._areaSel=t.area||"",this.host._roomFill="glow"===t.settings?.fill_mode?"":t.settings?.fill_mode||"";const e="custom"===this.host._roomFill?t.settings?.custom_fill:null;this.host._roomCustomFill=e&&"object"==typeof e?pi(e,_(this.host._curSpaceCfg).customFill):null,[this.host._roomTempMin,this.host._roomTempMax]=Hi(t.settings),this.host._roomTempSrc=t.settings?.temp_source||"",this.host._roomHumSrc=t.settings?.hum_source||"",this.host._roomNameScale=Bi(t.settings?.name_scale),this.host._roomLabelScale=Bi(t.settings?.label_scale),this.host._roomSrcOpen=null,this.host._roomSrcFilter="",this.host._roomDialog=!0}_roomSettingsFromDialog(){const t={};return this.host._roomFill&&(t.fill_mode=this.host._roomFill),"custom"===this.host._roomFill&&this.host._roomCustomFill&&(t.custom_fill=this.host._roomCustomFill),this.host._roomTempSrc&&(t.temp_source=this.host._roomTempSrc),this.host._roomHumSrc&&(t.hum_source=this.host._roomHumSrc),Wi(t,this.host._roomTempMin,this.host._roomTempMax),1!==this.host._roomNameScale&&(t.name_scale=this.host._roomNameScale),1!==this.host._roomLabelScale&&(t.label_scale=this.host._roomLabelScale),Object.keys(t).length?t:null}_saveRoomEdit(){const t=this.host._curSpaceCfg,e=t?.rooms.find(t=>t.id===this.host._roomEditId);if(!e)return this.host._roomDialog=!1,void(this.host._roomEditId=null);e.name=this.host._nameSel.trim()||e.name,e.area=this.host._areaSel||null;const s=e.settings||{},i={...s};Wi(i,this.host._roomTempMin,this.host._roomTempMax)&&(this.host._roomFill?i.fill_mode=this.host._roomFill:delete i.fill_mode,"custom"===this.host._roomFill&&this.host._roomCustomFill?i.custom_fill=this.host._roomCustomFill:delete i.custom_fill,"glow"===s.fill_mode&&"boolean"!=typeof s.glow&&(i.glow=!0),this.host._roomTempSrc?i.temp_source=this.host._roomTempSrc:delete i.temp_source,this.host._roomHumSrc?i.hum_source=this.host._roomHumSrc:delete i.hum_source,1!==this.host._roomNameScale?i.name_scale=this.host._roomNameScale:delete i.name_scale,1!==this.host._roomLabelScale?i.label_scale=this.host._roomLabelScale:delete i.label_scale,Object.keys(i).length?e.settings=i:delete e.settings,this._saveConfig(),this.host._roomDialog=!1,this.host._roomEditId=null,this.host._nameSel="",this.host._areaSel="",this.host._regSignature="",this.host._maybeRebuildDevices(),this.host.requestUpdate(),this.host._showToast(this.host._t("toast.room_updated")))}_roomSrcCandidates(){const t=this.host._planHass,e=ge(this.host._markers),s=this.host._roomSrcFilter.trim().toLowerCase(),i=[];for(const o of Object.values(t.devices)){if("service"===o.entry_type)continue;if(e.devices.has(o.id))continue;const t=(o.name_by_user||o.name||o.id).trim();s&&!t.toLowerCase().includes(s)||i.push({value:"device:"+o.id,label:t,sub:o.model||this.host._t("marker.sub_device")})}for(const[o,a]of Object.entries(t.entities)){if(!o.startsWith("sensor.")||a.hidden)continue;if(me(t,o,e))continue;const n=a.name||t.states[o]?.attributes?.friendly_name||o;s&&!(n+" "+o).toLowerCase().includes(s)||i.push({value:"entity:"+o,label:n,sub:o})}return i.sort((t,e)=>t.label.localeCompare(e.label)),i.slice(0,200)}_roomSrcLabel(t){const e=t.indexOf(":"),s=t.slice(0,e),i=t.slice(e+1);return"device"===s?this.host._fullRegistryHass.devices[i]?.name_by_user||this.host._fullRegistryHass.devices[i]?.name||i:this.host._fullRegistryHass.entities[i]?.name||this.host.hass.states[i]?.attributes?.friendly_name||i}_labelPos(t,e){const s=this.host._layout["rl_"+(t.id||"")];if(s&&s.s===e)return{x:s.x*kd,y:s.y*kd};const i=this._snap(this.host._roomCenter(t));return{x:i[0],y:i[1]}}_labelDown(t,e,s){if("plan"!==this.host._mode)return;t.preventDefault(),t.stopPropagation();const i=this._labelPos(e,s);this.host._drag={id:"rl_"+(e.id||""),sx:t.clientX,sy:t.clientY,ox:i.x,oy:i.y,moved:!1},Md(t),this.host._tip=null}_labelMove(t,e,s){const i="rl_"+(e.id||"");if(!this.host._drag||this.host._drag.id!==i)return;const o=this.host._stageEl;if(!o)return;const a=this.host._spaceModelById(s);if(!a)return;const n=a.vb,r=o.getBoundingClientRect(),l=this.host._viewOr(n),h=(t.clientX-this.host._drag.sx)/r.width*l.w,c=(t.clientY-this.host._drag.sy)/r.height*l.h;Math.abs(t.clientX-this.host._drag.sx)+Math.abs(t.clientY-this.host._drag.sy)>3&&(this.host._drag.moved=!0);const d=qe(this.host._drag.ox+h),p=qe(this.host._drag.oy+c);this.host._savePos({id:i,space:s},d,p)}_labelUp(t){const e="rl_"+(t.id||"");if(!this.host._drag||this.host._drag.id!==e)return;const s=this.host._drag.moved;this.host._drag=s?this.host._drag:null,s&&window.setTimeout(()=>this.host._drag=null,0)}_labelScale(t){const e=this.host._layout["rl_"+(t.id||"")]?.k;return"number"==typeof e&&Number.isFinite(e)?Math.min(3,Math.max(.5,e)):1}_rlResizeDown(t,e,s){if("plan"!==this.host._mode)return;t.preventDefault(),t.stopPropagation();const i=t.target.closest(".roomlabel");if(!i)return;const o=i.getBoundingClientRect(),a=o.left+o.width/2,n=o.top+o.height/2,r=Math.max(8,Math.hypot(t.clientX-a,t.clientY-n));this.host._rlResize={id:"rl_"+(e.id||""),space:s,k0:this._labelScale(e),cx:a,cy:n,d0:r},Md(t)}_rlResizeMove(t){const e=this.host._rlResize;if(!e)return;t.stopPropagation();const s=Math.max(8,Math.hypot(t.clientX-e.cx,t.clientY-e.cy)),i=Math.min(3,Math.max(.5,e.k0*(s/e.d0))),o=this.host._layout[e.id];if(o)this.host._layout={...this.host._layout,[e.id]:{...o,k:i}};else{const t=e.id.slice(3),s=this.host._spaceModelById(e.space);if(!s)return;const o=s.rooms.find(e=>e.id===t);if(!o)return;const a=this._labelPos(o,e.space);this.host._layout={...this.host._layout,[e.id]:{s:e.space,x:a.x/kd,y:a.y/kd,k:i}}}this.host._dirtyPos.add(e.id)}_rlResizeUp(){this.host._rlResize&&(this.host._rlResize=null,this.host._persistLayout())}_renderRoomGear(t,e,s){if(!t.id)return d;let i=null;if(t.poly?(i=this.host._gearPtCache.get(t.poly)||null,i||(i=gs(t.poly),this.host._gearPtCache.set(t.poly,i))):null!=t.x&&null!=t.y&&(i=[t.x+(t.w||0)/2,t.y+(t.h||0)/2]),!i)return d;const o=(i[0]-s.x)/s.w*100,a=(i[1]-s.y)/s.h*100;return p` -
    `}_markerValueBadgeFields(t){return to({touched:t.valueBadgeTouched,originalHas:t.originalHasValueBadge,original:t.originalValueBadge,enabled:t.valueBadgeEnabled,source:t.valueBadgeSource,position:t.valueBadgePosition})}_markerValueSourceFields(t){return eo({touched:t.valueSourceTouched,originalHas:t.originalHasValueSource,original:t.originalValueSource,source:t.valueSource})}_markerDraft(t){if("ha"===t.bindingMode&&(!t.binding||"virtual"===t.binding))return null;const e=M(t.room),s=si(t.binding,t.devId,()=>"__hp_device_preview__"),i=this.host._markers.find(e=>e.id===s||e.id===t.devId),o=x(t.binding,t.controls,this.host._bindingEntities(t.binding)),a=this._effectiveStoredTapAction(t),n={id:s,binding:t.binding,name:t.name.trim()||null,icon:t.icon||null,display:"badge"!==t.display?t.display:null,ripple_color:"icon_ripple"===t.display&&t.rippleColor?t.rippleColor:null,ripple_size:"icon_ripple"===t.display&&1.5!==t.rippleSize?t.rippleSize:null,size:1!==t.size?t.size:null,angle:t.angle||null,...this._markerTapActionFields(t),...this._markerToggleEntityFields(t),tap_target:"run"===a&&t.tapTarget||null,tap_confirm:!!t.tapConfirm||null,controls:o.length?o:null,...this._markerLightFields(t),...this._markerValueBadgeFields(t),...this._markerValueSourceFields(t),use_climate_temp:!!t.useClimateTemp||null,glow_radius_cm:(()=>{const e=kt(t.glowRadius);return null==e||e<=0?null:Math.round(this.host._imperial?30.48*e:100*e)})(),model:t.model.trim()||null,link:t.link.trim()||null,description:t.description.trim()||null,pdfs:t.pdfs,hidden:t.hideFromPlan,vacuum:i?.vacuum||null},r=!!i&&("string"==typeof i.area&&i.area.length>0||null===i.area&&!!i.space&&!!i.room_id);return"virtual"===t.binding||t.roomTouched?(n.space=e?.space||("virtual"===t.binding?this.host._space:null),n.area=e?.area||null,n.room_id=e?.roomId||null):r&&(n.space=i.space,n.area=i.area,n.room_id=i.room_id),n}_markerPreviewDevice(t){const e=this._markerDraft(t);if(!e)return null;const s=`${this.host._haRegistry.revision}\n${yt(this.host._markers)}\n${JSON.stringify(e)}`;if(this.host._markerPreviewMemo?.key===s)return this.host._markerPreviewMemo.device;const i=so({hass:this.host.hass,registry:this.host._haRegistry,areaToSpace:Object.fromEntries(Object.entries(this.host._areaToSpace).map(([t,e])=>[t,e.space])),marker:e,siblingMarkers:this.host._markers,settings:this.host._settings,excluded:this.host._excluded,showAll:this.host._showAll,firstSpaceId:this.host._model[0]?.id||this.host._space,loc:t=>this.host._t(t),iconRules:this.host._iconRules});return this.host._markerPreviewMemo={key:s,device:i},i}_markerPreviewDevices(t){const e=this.host._markerPreviewDevicesMemo;if(e?.base===this.host._devices&&e.preview===t)return e.devices;const s=[...this.host._devices.filter(e=>e.id!==t.id),t];return this.host._markerPreviewDevicesMemo={base:this.host._devices,preview:t,devices:s},s}_toggleIntent(t,e=this.host._devices){return this.host._toggleIntent(t,e)}_toggleIntentForDialog(t){const e=this._markerPreviewDevice(t);if(!e)return null;const s=this._markerPreviewDevices(e);return this._toggleIntent(e,s)}_toggleStateText(t,e){return this.host._toggleStateText(t,e)}_toggleConfirmationStateText(t){return this.host._toggleConfirmationStateText(t)}_toggleConfirmationLines(t){return this.host._toggleConfirmationLines(t)}_toggleHintLines(t){if(!t)return[];const e=t=>this.host._t(`marker.toggle_effect_${t.replace("-","_")}`),s=t=>this.host._t(`marker.toggle_skip_${t.replace("-","_")}`);return io(t,{single:t=>{if("via"in t&&"virtual-light"===t.via)return this.host._t("marker.virtual_light_target",{name:t.name});const e=t.entityId||("ref"in t?t.ref:""),s=t.name||e;return this.host._t("marker.toggle_hint_single",{name:s,id:e})},group:t=>this.host._t("marker.toggle_hint_group",{count:t.length,names:t.map(t=>`${t.name} (${t.entityId})`).join(", ")}),currentNext:(t,s)=>"virtual-light"===t.via?this.host._t("marker.virtual_light_current",{state:this.host._t("on"===t.state?"marker.virtual_light_state_on":"marker.virtual_light_state_off"),effect:e(s)}):this.host._t("marker.toggle_hint_current",{state:this._toggleStateText(t.entityId,t.state),effect:e(s)}),groupCurrentNext:(t,s)=>this.host._t("marker.toggle_hint_group_current",{on:t.filter(t=>"on"===t.state).length,count:t.length,effect:e(s)}),skipped:t=>this.host._t("marker.toggle_hint_skipped",{count:t.length,targets:t.map(t=>{const e=t.entityId||t.ref;return`${t.name||e} (${e}: ${s(t.reason)})`}).join(", ")}),none:t=>this.host._t(`marker.toggle_none_${t.replaceAll("-","_")}`)})}_effectiveStoredTapAction(t,e){return t.tapActionTouched?t.tapAction:oi(t.originalHasTapAction?t.originalTapAction:null,e)}_effectiveMarkerTapAction(t,e=this._markerPreviewDevice(t)){return this._effectiveStoredTapAction(t,e?.primary?.split(".")[0])}_announceToggleDraft(t){const e=this._markerPreviewDevice(t),s=t.tapActionTouched?t:{...t,tapAction:this._effectiveMarkerTapAction(t,e)},i="toggle"===s.tapAction?this._toggleHintLines(this._toggleIntentForDialog(s)).join(" "):"";return{...s,tapHintAnnouncement:i}}_valueBadgeForBinding(t,e){const s={...t,binding:e,valueBadgeEnabled:!1,valueBadgeSource:null,valueBadgeTouched:!0},i=this._markerPreviewDevice(s);if(!i)return{valueBadgeEnabled:!1,valueBadgeSource:null,valueBadgeTouched:!0};const o=[...this.host._devices.filter(t=>t.id!==i.id),i],a=m(this.host._planHass,i,o),n=f(this.host._planHass,i,a);return{valueBadgeEnabled:t.valueBadgeEnabled&&!!n,valueBadgeSource:n,valueBadgeTouched:!0}}_markerSpatialSource(t){const e=this._markerPreviewDevice(t);if(!e)return null;const s={...e,hidden:!1};return oo(ao(this.host._planHass,[...this.host._devices.filter(t=>t.id!==s.id),s],null,this.host._virtualLights).filter(t=>t.device.id===s.id))}_markerAutoHasSpatialSource(t){const e={...t,lightRole:"auto",lightRoleTouched:!0},s=this._markerPreviewDevice(e);return!!s&&no(this.host._planHass,{...s})}_setMarkerLightRole(t){const e=this.host._markerDialog;e&&(this.host._markerDialog={...e,lightRole:t,lightRoleTouched:!0})}_controlRefInfo(t){if(!t.startsWith("marker:"))return{label:this.host.hass.states[t]?.attributes?.friendly_name||t,sub:t,icon:t.startsWith("light.")?"mdi:lightbulb":"mdi:toggle-switch",warning:!this.host._planEntityAvailable(t)};const e=t.slice(7),s=this.host._markers.find(t=>t.id===e),i=this.host._devices.find(t=>t.id===e);if(!s||s.removed||!0!==s.is_light)return{label:this.host._t("marker.control_missing_label"),sub:`${this.host._t("marker.control_broken")} (${t})`,icon:"mdi:alert-outline",warning:!0};const o=this.host._serverCfg?.spaces.find(t=>t.id===(i?.space||s.space)),a=!!i&&$(i).length>0;return{label:s.name||i?.name||e,sub:[o?.title||i?.space||s.space,s.room_id||i?.area,a?"":this.host._t("marker.control_passive")].filter(Boolean).join(" · "),icon:s.icon||i?.icon||"mdi:lightbulb-outline",warning:!0===s.hidden||!0===i?.hidden}}_valueBadgeCandidateLabel(t){const e=t.source;if("derived_lqi"===e.kind)return this.host._t("marker.value_badge_lqi");if("derived_marker_state"===e.kind)return this.host._t("marker.value_badge_marker_state",{name:t.label});if("entity_state"===e.kind)return this.host._t("marker.value_badge_state",{name:t.label});const s=this.host.hass.states[e.entity_id]?.attributes?.friendly_name||this.host._fullRegistryHass.entities[e.entity_id]?.name||e.entity_id;return this.host._t(`marker.value_badge_attr_${e.attribute}`,{name:s})}_controlCandidates(t){const e=this._markerDraft(t)?.id||t.devId||"",s=[],i=new Set;for(const t of this.host._markers){if(t.id===e||t.removed||t.hidden||!0!==t.is_light)continue;if("virtual"!==t.binding&&"active"!==this.host._bindingStatus(t.binding).kind)continue;const o=this.host._devices.find(e=>e.id===t.id);if(!o||o.hidden)continue;const a=this._controlRefInfo(`marker:${t.id}`);for(const t of $(o))i.add(t);s.push({value:`marker:${t.id}`,label:a.label,sub:a.sub,icon:a.icon,search:`${a.label} ${a.sub} ${t.id} ${$(o).join(" ")}`.toLowerCase()})}const o=Object.keys(this.host.hass.states||{}).filter(e=>ro(e)&&!i.has(e)&&lo(t.binding,[e],this.host._bindingEntities(t.binding)).length>0&&this.host._planEntityAvailable(e)).map(t=>{const e=this._controlRefInfo(t);return{value:t,label:e.label,sub:t,icon:e.icon,search:`${e.label} ${t}`.toLowerCase()}}),a=t.controlsFilter.trim().toLowerCase();return[...s,...o].filter(e=>!t.controls.includes(e.value)&&(!a||e.search.includes(a))).slice(0,12).map(({search:t,...e})=>e)}_addControlRef(t,e){if(e.startsWith("marker:")){const s=this._markerDraft(t)?.id||t.devId||"";if(!s)return void this.host._showToast(this.host._t("toast.marker_binding_required"));const i=e.slice(7),o=this._markerDraft(t),a=o?[...this.host._markers.filter(t=>t.id!==s),o]:this.host._markers;if(ho(a,s,i))return void this.host._showToast(this.host._t("toast.marker_control_cycle"))}this.host._markerDialog=this._announceToggleDraft({...t,controls:[...t.controls,e],controlsFilter:""})}_setMarkerGlowMode(t){const e=this.host._markerDialog;if(!e)return;if("auto"===t)return void(this.host._markerDialog={...e,glowMode:t,glowTouched:!0});const s=this._markerSpatialSource(e),i=co(s?this.host._planHass.states[s.eid]:void 0,null,this.host._fillColors.glow_light.c),o=!e.glowColorDrafted,a="fixed"===t&&!e.glowBrightnessDrafted;this.host._markerDialog={...e,glowMode:t,glowColor:o?i.c:e.glowColor,glowBrightness:a?Math.max(1,Math.round(100*i.bri)):e.glowBrightness,glowColorDrafted:!0,glowBrightnessDrafted:e.glowBrightnessDrafted||"fixed"===t,glowTouched:!0}}_renderRadarSection(t,e,s="main"){return Fh({dialog:t,device:e,registryHass:this.host._fullRegistryHass,planHass:this.host._planHass,hass:this.host.hass,spaceModelById:t=>this.host._spaceModelById(t),currentSpace:()=>this.host._spaceModel(),position:t=>this.host._pos(t),updateDialog:t=>{this.host._markerDialog&&(this.host._markerDialog={...this.host._markerDialog,...t})},dialogDeviceId:()=>this.host._markerDialog?.devId,t:(t,e)=>this.host._t(t,e),help:t=>this._help(t),boolInput:(t,e)=>this._boolInput(t,e),toast:t=>this.host._showToast(t),setup:this._radarSetup,configRev:this.host._cfgRev},s)}_renderMarkerDialog(){return _a.call(this)}_renderSpaceDialog(){return er.call(this)}_renderMergeDialog(){const t=this.host._mergeDialog,e=this.host._spaceModel()?.rooms||[],s=(s,i)=>{const o=e.find(t=>t.id===s),a=o?.area?this.host.hass.areas[o.area]?.name:null;return p`
    `}_markerValueBadgeFields(t){return to({touched:t.valueBadgeTouched,originalHas:t.originalHasValueBadge,original:t.originalValueBadge,enabled:t.valueBadgeEnabled,source:t.valueBadgeSource,position:t.valueBadgePosition})}_markerValueSourceFields(t){return eo({touched:t.valueSourceTouched,originalHas:t.originalHasValueSource,original:t.originalValueSource,source:t.valueSource})}_markerDraft(t){if("ha"===t.bindingMode&&(!t.binding||"virtual"===t.binding))return null;const e=M(t.room),s=si(t.binding,t.devId,()=>"__hp_device_preview__"),i=this.host._markers.find(e=>e.id===s||e.id===t.devId),o=x(t.binding,t.controls,this.host._bindingEntities(t.binding)),a=this._effectiveStoredTapAction(t),n={id:s,binding:t.binding,name:t.name.trim()||null,icon:t.icon||null,display:"badge"!==t.display?t.display:null,ripple_color:"icon_ripple"===t.display&&t.rippleColor?t.rippleColor:null,ripple_size:"icon_ripple"===t.display&&1.5!==t.rippleSize?t.rippleSize:null,size:1!==t.size?t.size:null,angle:t.angle||null,...this._markerTapActionFields(t),...this._markerToggleEntityFields(t),tap_target:"run"===a&&t.tapTarget||null,tap_confirm:!!t.tapConfirm||null,controls:o.length?o:null,...this._markerLightFields(t),...this._markerValueBadgeFields(t),...this._markerValueSourceFields(t),use_climate_temp:!!t.useClimateTemp||null,glow_radius_cm:(()=>{const e=kt(t.glowRadius);return null==e||e<=0?null:Math.round(this.host._imperial?30.48*e:100*e)})(),model:t.model.trim()||null,link:t.link.trim()||null,description:t.description.trim()||null,pdfs:t.pdfs,hidden:t.hideFromPlan,vacuum:i?.vacuum||null},r=!!i&&("string"==typeof i.area&&i.area.length>0||null===i.area&&!!i.space&&!!i.room_id);return"virtual"===t.binding||t.roomTouched?(n.space=e?.space||("virtual"===t.binding?this.host._space:null),n.area=e?.area||null,n.room_id=e?.roomId||null):r&&(n.space=i.space,n.area=i.area,n.room_id=i.room_id),n}_markerPreviewDevice(t){const e=this._markerDraft(t);if(!e)return null;const s=`${this.host._haRegistry.revision}\n${yt(this.host._markers)}\n${JSON.stringify(e)}`;if(this.host._markerPreviewMemo?.key===s)return this.host._markerPreviewMemo.device;const i=so({hass:this.host.hass,registry:this.host._haRegistry,areaToSpace:Object.fromEntries(Object.entries(this.host._areaToSpace).map(([t,e])=>[t,e.space])),marker:e,siblingMarkers:this.host._markers,settings:this.host._settings,excluded:this.host._excluded,showAll:this.host._showAll,firstSpaceId:this.host._model[0]?.id||this.host._space,loc:t=>this.host._t(t),iconRules:this.host._iconRules});return this.host._markerPreviewMemo={key:s,device:i},i}_markerPreviewDevices(t){const e=this.host._markerPreviewDevicesMemo;if(e?.base===this.host._devices&&e.preview===t)return e.devices;const s=[...this.host._devices.filter(e=>e.id!==t.id),t];return this.host._markerPreviewDevicesMemo={base:this.host._devices,preview:t,devices:s},s}_toggleIntent(t,e=this.host._devices){return this.host._toggleIntent(t,e)}_toggleIntentForDialog(t){const e=this._markerPreviewDevice(t);if(!e)return null;const s=this._markerPreviewDevices(e);return this._toggleIntent(e,s)}_toggleStateText(t,e){return this.host._toggleStateText(t,e)}_toggleConfirmationStateText(t){return this.host._toggleConfirmationStateText(t)}_toggleConfirmationLines(t){return this.host._toggleConfirmationLines(t)}_toggleHintLines(t){if(!t)return[];const e=t=>this.host._t(`marker.toggle_effect_${t.replace("-","_")}`),s=t=>this.host._t(`marker.toggle_skip_${t.replace("-","_")}`);return io(t,{single:t=>{if("via"in t&&"virtual-light"===t.via)return this.host._t("marker.virtual_light_target",{name:t.name});const e=t.entityId||("ref"in t?t.ref:""),s=t.name||e;return this.host._t("marker.toggle_hint_single",{name:s,id:e})},group:t=>this.host._t("marker.toggle_hint_group",{count:t.length,names:t.map(t=>`${t.name} (${t.entityId})`).join(", ")}),currentNext:(t,s)=>"virtual-light"===t.via?this.host._t("marker.virtual_light_current",{state:this.host._t("on"===t.state?"marker.virtual_light_state_on":"marker.virtual_light_state_off"),effect:e(s)}):this.host._t("marker.toggle_hint_current",{state:this._toggleStateText(t.entityId,t.state),effect:e(s)}),groupCurrentNext:(t,s)=>this.host._t("marker.toggle_hint_group_current",{on:t.filter(t=>"on"===t.state).length,count:t.length,effect:e(s)}),skipped:t=>this.host._t("marker.toggle_hint_skipped",{count:t.length,targets:t.map(t=>{const e=t.entityId||t.ref;return`${t.name||e} (${e}: ${s(t.reason)})`}).join(", ")}),none:t=>this.host._t(`marker.toggle_none_${t.replaceAll("-","_")}`)})}_effectiveStoredTapAction(t,e){return t.tapActionTouched?t.tapAction:oi(t.originalHasTapAction?t.originalTapAction:null,e)}_effectiveMarkerTapAction(t,e=this._markerPreviewDevice(t)){return this._effectiveStoredTapAction(t,e?.primary?.split(".")[0])}_announceToggleDraft(t){const e=this._markerPreviewDevice(t),s=t.tapActionTouched?t:{...t,tapAction:this._effectiveMarkerTapAction(t,e)},i="toggle"===s.tapAction?this._toggleHintLines(this._toggleIntentForDialog(s)).join(" "):"";return{...s,tapHintAnnouncement:i}}_valueBadgeForBinding(t,e){const s={...t,binding:e,valueBadgeEnabled:!1,valueBadgeSource:null,valueBadgeTouched:!0},i=this._markerPreviewDevice(s);if(!i)return{valueBadgeEnabled:!1,valueBadgeSource:null,valueBadgeTouched:!0};const o=[...this.host._devices.filter(t=>t.id!==i.id),i],a=m(this.host._planHass,i,o),n=f(this.host._planHass,i,a);return{valueBadgeEnabled:t.valueBadgeEnabled&&!!n,valueBadgeSource:n,valueBadgeTouched:!0}}_markerSpatialSource(t){const e=this._markerPreviewDevice(t);if(!e)return null;const s={...e,hidden:!1};return oo(ao(this.host._planHass,[...this.host._devices.filter(t=>t.id!==s.id),s],null,this.host._virtualLights).filter(t=>t.device.id===s.id))}_markerAutoHasSpatialSource(t){const e={...t,lightRole:"auto",lightRoleTouched:!0},s=this._markerPreviewDevice(e);return!!s&&no(this.host._planHass,{...s})}_setMarkerLightRole(t){const e=this.host._markerDialog;e&&(this.host._markerDialog={...e,lightRole:t,lightRoleTouched:!0})}_controlRefInfo(t){if(!t.startsWith("marker:"))return{label:this.host.hass.states[t]?.attributes?.friendly_name||t,sub:t,icon:t.startsWith("light.")?"mdi:lightbulb":"mdi:toggle-switch",warning:!this.host._planEntityAvailable(t)};const e=t.slice(7),s=this.host._markers.find(t=>t.id===e),i=this.host._devices.find(t=>t.id===e);if(!s||s.removed||!0!==s.is_light)return{label:this.host._t("marker.control_missing_label"),sub:`${this.host._t("marker.control_broken")} (${t})`,icon:"mdi:alert-outline",warning:!0};const o=this.host._serverCfg?.spaces.find(t=>t.id===(i?.space||s.space)),a=!!i&&$(i).length>0;return{label:s.name||i?.name||e,sub:[o?.title||i?.space||s.space,s.room_id||i?.area,a?"":this.host._t("marker.control_passive")].filter(Boolean).join(" · "),icon:s.icon||i?.icon||"mdi:lightbulb-outline",warning:!0===s.hidden||!0===i?.hidden}}_valueBadgeCandidateLabel(t){const e=t.source;if("derived_lqi"===e.kind)return this.host._t("marker.value_badge_lqi");if("derived_marker_state"===e.kind)return this.host._t("marker.value_badge_marker_state",{name:t.label});if("entity_state"===e.kind)return this.host._t("marker.value_badge_state",{name:t.label});const s=this.host.hass.states[e.entity_id]?.attributes?.friendly_name||this.host._fullRegistryHass.entities[e.entity_id]?.name||e.entity_id;return this.host._t(`marker.value_badge_attr_${e.attribute}`,{name:s})}_controlCandidates(t){const e=this._markerDraft(t)?.id||t.devId||"",s=[],i=new Set;for(const t of this.host._markers){if(t.id===e||t.removed||t.hidden||!0!==t.is_light)continue;if("virtual"!==t.binding&&"active"!==this.host._bindingStatus(t.binding).kind)continue;const o=this.host._devices.find(e=>e.id===t.id);if(!o||o.hidden)continue;const a=this._controlRefInfo(`marker:${t.id}`);for(const t of $(o))i.add(t);s.push({value:`marker:${t.id}`,label:a.label,sub:a.sub,icon:a.icon,search:`${a.label} ${a.sub} ${t.id} ${$(o).join(" ")}`.toLowerCase()})}const o=Object.keys(this.host.hass.states||{}).filter(e=>ro(e)&&!i.has(e)&&lo(t.binding,[e],this.host._bindingEntities(t.binding)).length>0&&this.host._planEntityAvailable(e)).map(t=>{const e=this._controlRefInfo(t);return{value:t,label:e.label,sub:t,icon:e.icon,search:`${e.label} ${t}`.toLowerCase()}}),a=t.controlsFilter.trim().toLowerCase();return[...s,...o].filter(e=>!t.controls.includes(e.value)&&(!a||e.search.includes(a))).slice(0,12).map(({search:t,...e})=>e)}_addControlRef(t,e){if(e.startsWith("marker:")){const s=this._markerDraft(t)?.id||t.devId||"";if(!s)return void this.host._showToast(this.host._t("toast.marker_binding_required"));const i=e.slice(7),o=this._markerDraft(t),a=o?[...this.host._markers.filter(t=>t.id!==s),o]:this.host._markers;if(ho(a,s,i))return void this.host._showToast(this.host._t("toast.marker_control_cycle"))}this.host._markerDialog=this._announceToggleDraft({...t,controls:[...t.controls,e],controlsFilter:""})}_setMarkerGlowMode(t){const e=this.host._markerDialog;if(!e)return;if("auto"===t)return void(this.host._markerDialog={...e,glowMode:t,glowTouched:!0});const s=this._markerSpatialSource(e),i=co(s?this.host._planHass.states[s.eid]:void 0,null,this.host._fillColors.glow_light.c),o=!e.glowColorDrafted,a="fixed"===t&&!e.glowBrightnessDrafted;this.host._markerDialog={...e,glowMode:t,glowColor:o?i.c:e.glowColor,glowBrightness:a?Math.max(1,Math.round(100*i.bri)):e.glowBrightness,glowColorDrafted:!0,glowBrightnessDrafted:e.glowBrightnessDrafted||"fixed"===t,glowTouched:!0}}_renderRadarSection(t,e,s="main"){return Nh({dialog:t,device:e,registryHass:this.host._fullRegistryHass,planHass:this.host._planHass,hass:this.host.hass,spaceModelById:t=>this.host._spaceModelById(t),currentSpace:()=>this.host._spaceModel(),position:t=>this.host._pos(t),updateDialog:t=>{this.host._markerDialog&&(this.host._markerDialog={...this.host._markerDialog,...t})},dialogDeviceId:()=>this.host._markerDialog?.devId,t:(t,e)=>this.host._t(t,e),help:t=>this._help(t),boolInput:(t,e)=>this._boolInput(t,e),toast:t=>this.host._showToast(t),setup:this._radarSetup,configRev:this.host._cfgRev},s)}_renderMarkerDialog(){return ga.call(this)}_renderSpaceDialog(){return sr.call(this)}_renderMergeDialog(){const t=this.host._mergeDialog,e=this.host._spaceModel()?.rooms||[],s=(s,i)=>{const o=e.find(t=>t.id===s),a=o?.area?this.host.hass.areas[o.area]?.name:null;return p`
    `}_renderRoomDialog(){return nr.call(this)}}export{Md as EDITOR_RUNTIME_FINGERPRINT,Cd as HouseplanEditorRuntime}; + `}_renderRoomDialog(){return rr.call(this)}}export{Cd as EDITOR_RUNTIME_FINGERPRINT,Sd as HouseplanEditorRuntime}; diff --git a/dist/houseplan-assets/houseplan-onboarding-runtime-BAx8bJB2.js b/dist/houseplan-assets/houseplan-onboarding-runtime-G7DfDSe_.js similarity index 98% rename from dist/houseplan-assets/houseplan-onboarding-runtime-BAx8bJB2.js rename to dist/houseplan-assets/houseplan-onboarding-runtime-G7DfDSe_.js index 114b5534..4965470e 100644 --- a/dist/houseplan-assets/houseplan-onboarding-runtime-BAx8bJB2.js +++ b/dist/houseplan-assets/houseplan-onboarding-runtime-G7DfDSe_.js @@ -1,4 +1,4 @@ -globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db7c58754eeb4ba03f835b8d7c84c6";import{l as t,bw as s,A as e,aL as a,c as o,g as l,cK as i,ar as h,am as c,au as n,cL as r,cQ as p,cM as d,cN as _,cO as u,cP as g,cR as m,cS as b,al as $,ao as v,ap as f,as as y,at as w,aq as D}from"./houseplan-card-BiUNLHFh.js";import{c as k,e as S,r as C,a as M}from"./backdrop-pick-Ev52LRir.js";const F=1e3,x=t=>{if(!t.trim())return null;const s=Number(t.replace(",","."));return Number.isFinite(s)?s:null},T="ed91b3971428d2b8e7bfceb8025d2be4c0db7c58754eeb4ba03f835b8d7c84c6";class L{constructor(t){this.host=t,this._toggleServerPlans=async()=>{const t=this.host._spaceDialog;if(t)if(t.pickSaved)this.host._spaceDialog={...t,pickSaved:!1};else{this.host._spaceDialog={...t,pickSaved:!0,savedBusy:!0};try{const t=await this.host.hass.callWS({type:"houseplan/plans/list"}),s=this.host._spaceDialog;s&&(this.host._spaceDialog={...s,saved:t?.plans||[],savedBusy:!1})}catch(t){const s=this.host._spaceDialog;s&&(this.host._spaceDialog={...s,saved:[],savedBusy:!1}),this.host._showToast(this.host._t("toast.plans_list_failed",{err:this.host._errText(t)}))}}}}_help(l){const i=`${l}.aria`,h=t(this.host.hass,this.host._config?.language);return s(h,l)&&s(h,i)?o`{if(!t.trim())return null;const s=Number(t.replace(",","."));return Number.isFinite(s)?s:null},T="d31b0b1e184ab2863684b758f839bdb6809a33cc742c6e9bb36c5ea034e3d309";class L{constructor(t){this.host=t,this._toggleServerPlans=async()=>{const t=this.host._spaceDialog;if(t)if(t.pickSaved)this.host._spaceDialog={...t,pickSaved:!1};else{this.host._spaceDialog={...t,pickSaved:!0,savedBusy:!0};try{const t=await this.host.hass.callWS({type:"houseplan/plans/list"}),s=this.host._spaceDialog;s&&(this.host._spaceDialog={...s,saved:t?.plans||[],savedBusy:!1})}catch(t){const s=this.host._spaceDialog;s&&(this.host._spaceDialog={...s,saved:[],savedBusy:!1}),this.host._showToast(this.host._t("toast.plans_list_failed",{err:this.host._errText(t)}))}}}}_help(l){const i=`${l}.aria`,h=t(this.host.hass,this.host._config?.language);return s(h,l)&&s(h,i)?o``:e}_openSpaceDialog(t,s){if(!this.host._serverStorage||!this.host._serverCfg)return void this.host._showToast(this.host._t("toast.integration_missing"));if("edit"===t){const e=this.host._serverCfg.spaces.find(t=>t.id===s);if(!e)return;const a=l(e),o=e.settings?.custom_fill&&"object"==typeof e.settings.custom_fill?i(e.settings.custom_fill):null,p="none"===a.fill?{...o||h,a:0}:o;return void(this.host._spaceDialog={mode:t,spaceId:s,title:e.title,planUrl:e.plan_url||null,planFile:null,source:e.plan_url?"file":"draw",showBorders:a.showBorders,showNames:a.showNames,zeroWallStyle:r(e),displayTouched:!0,hideDecor:a.hideDecor,hideOpenings:a.hideOpenings,roomColor:a.color,roomOpacity:a.opacity,fillMode:"none"===a.fill?"custom":a.fill,customFill:p,glowEnabled:a.glow,bgColor:a.bgColor,bgMode:"static"===e.settings?.bg_mode||"daynight"===e.settings?.bg_mode?e.settings.bg_mode:null,northDeg:n({},e.settings),sunRays:"boolean"==typeof e.settings?.sun_rays?e.settings.sun_rays:null,tempMin:a.tempMin,tempMax:a.tempMax,showLqi:a.showLqi??this.host._config?.show_signal??!0,cardFontScale:a.cardFontScale,labelTemp:a.labelTemp,labelHum:a.labelHum,labelLqi:a.labelLqi,labelLight:a.labelLight,cellCm:Number(e.cell_cm)>0?Number(e.cell_cm):5,cellCmInput:c(Number(e.cell_cm)>0?Number(e.cell_cm):5,this.host._imperial),cellCmTouched:!1,busy:!1})}const e=p(this.host._imperial);this.host._spaceDialog={mode:t,title:"",planUrl:null,planFile:null,...m(),hideDecor:!1,hideOpenings:!1,zeroWallStyle:"dashed",roomColor:g,roomOpacity:u,fillMode:"custom",customFill:{...h,a:0},glowEnabled:!0,bgColor:null,bgMode:"daynight",northDeg:null,sunRays:null,tempMin:_,tempMax:d,showLqi:this.host._config?.show_signal??!0,cardFontScale:1,labelTemp:!1,labelHum:!1,labelLqi:!1,labelLight:!1,cellCm:e,cellCmInput:c(e,this.host._imperial),cellCmTouched:!1,busy:!1}}async _pickPlanFile(t){const s=t.target,e=s.files?.[0];if(!e||!this.host._spaceDialog)return;s.value="";const a=await k(e);if("reject"===a.kind)return void this.host._showToast(this.host._t("toast.plan_formats"));if("guard"===a.kind)return void(this.host._backdropGuard=a.state);const o=await S(e,a.ext,e.name);this.host._spaceDialog&&(this.host._spaceDialog={...this.host._spaceDialog,planFile:o})}_renderBackdropGuard(){return C(this.host,t=>{this.host._spaceDialog&&(this.host._spaceDialog={...this.host._spaceDialog,planFile:t})},()=>{this.host._backdropGuard=null},this.host.hass)??e}_useServerPlan(t){const s=this.host._spaceDialog;s&&(this.host._spaceDialog={...s,planUrl:t,planFile:null,pickSaved:!1,savedAspect:void 0},this.host._aspectJob=this._readPlanAspect(t))}async _readPlanAspect(t){for(let s=0;s<40;s++){const s=this.host._display(t);if(s){const e=await new Promise(t=>{const e=new Image;e.onload=()=>t(e.naturalWidth&&e.naturalHeight?e.naturalWidth/e.naturalHeight:0),e.onerror=()=>t(0),e.src=s}),a=this.host._spaceDialog;return a&&a.planUrl===t&&Number.isFinite(e)&&e>0?(this.host._spaceDialog={...a,savedAspect:e},e):0}if(await new Promise(t=>setTimeout(t,150)),this.host._spaceDialog?.planUrl!==t)return 0}return 0}async _deleteServerPlan(t){const s=this.host._spaceDialog,e=s?.saved?.find(s=>s.name===t);if(!s||!e||e.used_by.length||e.url===s.planUrl)return;const a=await this.host._confirmDanger({key:"delete-plan",kind:"destructive",title:this.host._t("confirm.delete_plan_title"),message:this.host._t("confirm.delete_plan_body"),objectName:t,confirmLabel:this.host._t("btn.delete"),cancelLabel:this.host._t("btn.cancel")}),o=this.host._spaceDialog,l=o?.saved?.find(s=>s.name===t);if(a&&o&&l&&l.url===e.url&&l.modified===e.modified&&!l.used_by.length&&l.url!==o.planUrl)try{await this.host.hass.callWS({type:"houseplan/plans/delete",name:t});const s=this.host._spaceDialog;s?.saved&&(this.host._spaceDialog={...s,saved:s.saved.filter(s=>s.name!==t)})}catch(t){this.host._showToast(this.host._t("toast.plan_delete_failed",{err:this.host._errText(t)}))}}_renderServerPlans(t){if(t.savedBusy)return o`
    ${this.host._t("space.loading")}
    `;const s=t.saved||[];if(!s.length)return o`
    ${this.host._t("space.no_saved")}
    `;return o`
    ${s.map(s=>{return o`
    diff --git a/dist/houseplan-assets/hp-zigbee-topology-overlay-SYVcVGiq.js b/dist/houseplan-assets/hp-zigbee-topology-overlay-CAehZ6TG.js similarity index 97% rename from dist/houseplan-assets/hp-zigbee-topology-overlay-SYVcVGiq.js rename to dist/houseplan-assets/hp-zigbee-topology-overlay-CAehZ6TG.js index 1abff8cc..2d9a4cd3 100644 --- a/dist/houseplan-assets/hp-zigbee-topology-overlay-SYVcVGiq.js +++ b/dist/houseplan-assets/hp-zigbee-topology-overlay-CAehZ6TG.js @@ -1,4 +1,4 @@ -globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db7c58754eeb4ba03f835b8d7c84c6";import{aI as e,l as t,A as i,eb as r,aB as o,c as s,aH as n}from"./houseplan-card-BiUNLHFh.js";import{t as a,a as h,r as d}from"./zigbee-topology-B31-i8CL.js";import{zigbeeTopologyRuntimeSnapshot as p,subscribeZigbeeTopology as l}from"./zigbee-topology-runtime-CuXFHyzq.js";function c(e,t,i,r,o,s=9,n=4.5){const a=t.x-e.x,h=t.y-e.y,d=Math.hypot(a,h),p=d-Math.max(0,i)-Math.max(0,r);if(!Number.isFinite(d)||d<=0||p<4)return null;const l=a/d,c=h/d,_="toward-neighbor"===o,u=_?{x:t.x-l*Math.max(0,r),y:t.y-c*Math.max(0,r)}:{x:e.x+l*Math.max(0,i),y:e.y+c*Math.max(0,i)},b=Math.min(s,Math.max(4,.45*p)),m=Math.min(n,.5*b),v=_?-1:1,g=u.x+l*b*v,y=u.y+c*b*v,x=-c;return{tip:u,points:[u,{x:g+x*m,y:y+l*m},{x:g-x*m,y:y-l*m}]}}const _={revision:0,topologies:[],states:{}},u="data-hp-zigbee-topology-endpoint";class b extends e{constructor(){super(...arguments),this.devices=[],this.currentSpace="",this._runtime=_,this._hovered="",this._desiredEndpointIds=new Set,this._endpointSetDirty=!1,this._endpointElements=new Set,this._pointerOver=e=>{if(!this._mouseAllowed(e))return void this._clear();const t=this._deviceFromEvent(e),i=t?.dataset.id||"";i&&i!==this._hovered&&(this._hovered=i,this.requestUpdate())},this._pointerOut=e=>{const t=this._deviceFromEvent(e);if(!t||t.dataset.id!==this._hovered)return;const i=e.relatedTarget instanceof Element?e.relatedTarget.closest('[data-hp="device"]'):null;i?.dataset.id!==this._hovered&&this._clear()},this._pointerDown=e=>{"mouse"!==e.pointerType&&this._clear()}}connectedCallback(){super.connectedCallback();const e=this.getRootNode();e.host&&"undefined"!=typeof MutationObserver&&(this._hoverGateObserver=new MutationObserver(()=>{e.host.hasAttribute("data-pointer-hover")||this._clear()}),this._hoverGateObserver.observe(e.host,{attributes:!0,attributeFilter:["data-pointer-hover"]})),queueMicrotask(()=>this._connectParent())}disconnectedCallback(){this._release?.(),this._release=void 0,this._disconnectParent(),this._hoverGateObserver?.disconnect(),this._hoverGateObserver=void 0,this._hovered="",this._desiredEndpointIds.clear(),super.disconnectedCallback()}updated(e){e.has("hass")&&(this._release?.(),this._acceptRuntime(p(this.hass)),this._release=l(this.hass,()=>{this._acceptRuntime(p(this.hass))}));const t=e.has("currentSpace")||e.has("devices")||e.has("registry");t&&(this._mappedMemo=void 0,this.devices.some(e=>e.id===this._hovered&&e.space===this.currentSpace)||this._clear()),this._connectParent(),(this._endpointSetDirty||t)&&this._syncEndpointOwnership()}_acceptRuntime(e){e.revision===this._runtime.revision&&e.topologies===this._runtime.topologies&&e.states===this._runtime.states||(this._setDesiredEndpointIds([]),this._clearEndpointOwnership(),this._endpointSetDirty=!1,this._runtime=e,this._mappedMemo=void 0,this.requestUpdate())}_connectParent(){const e=this.parentElement;e&&e!==this._parent&&(this._disconnectParent(),this._parent=e,e.addEventListener("pointerover",this._pointerOver),e.addEventListener("pointerout",this._pointerOut),e.addEventListener("pointerdown",this._pointerDown,!0),"undefined"!=typeof MutationObserver&&(this._markerObserver=new MutationObserver(()=>this._syncEndpointOwnership()),this._markerObserver.observe(e,{childList:!0})),this._syncEndpointOwnership())}_disconnectParent(){this._parent?.removeEventListener("pointerover",this._pointerOver),this._parent?.removeEventListener("pointerout",this._pointerOut),this._parent?.removeEventListener("pointerdown",this._pointerDown,!0),this._markerObserver?.disconnect(),this._markerObserver=void 0,this._clearEndpointOwnership(),this._parent=void 0}_deviceFromEvent(e){for(const t of e.composedPath())if(t instanceof HTMLElement&&"device"===t.dataset.hp)return t;return null}_mouseAllowed(e){const t=this.getRootNode();return"mouse"===e.pointerType&&t.host?.hasAttribute?.("data-pointer-hover")}_clear(){this._setDesiredEndpointIds([]),this._clearEndpointOwnership(),this._endpointSetDirty=!1,this._hovered&&(this._hovered="",this.requestUpdate())}_setDesiredEndpointIds(e){const t=new Set(e);t.size===this._desiredEndpointIds.size&&[...t].every(e=>this._desiredEndpointIds.has(e))||(this._desiredEndpointIds=t,this._endpointSetDirty=!0)}_marker(e){return[...this._parent?.querySelectorAll('.dev[data-hp="device"][data-id]')||[]].find(t=>t.dataset.id===e)||null}_clearEndpointOwnership(){for(const e of this._endpointElements)e.removeAttribute(u);for(const e of this._parent?.querySelectorAll(`[${u}]`)||[])e.removeAttribute(u);this._endpointElements.clear()}_syncEndpointOwnership(){const e=new Set;for(const t of this._desiredEndpointIds){const i=this._marker(t);i&&e.add(i)}for(const t of this._endpointElements)e.has(t)||t.removeAttribute(u);for(const t of this._parent?.querySelectorAll(`[${u}]`)||[])e.has(t)||t.removeAttribute(u);for(const t of e)this._endpointElements.has(t)&&t.hasAttribute(u)||t.setAttribute(u,"");this._endpointElements=e,this._endpointSetDirty=!1}_position(e,t,i){const r=this._marker(e);if(!r)return null;const o=Number.parseFloat(r.style.left),s=Number.parseFloat(r.style.top),n=r.getBoundingClientRect();return Number.isFinite(o)&&Number.isFinite(s)?{x:o*t/100,y:s*i/100,width:n.width,height:n.height}:null}_targetText(e){if("remote-space"===e.kind){const i=this.spaces?.find(t=>t.id===e.spaceId)?.title;return"string"==typeof i&&i.trim()||a(t(this.hass),"route_other_space")}return a(t(this.hass),"unplaced-coordinator"===e.kind?"route_coordinator_not_on_plan":"route_device_not_on_plan")}_markerClearance(e){return.61*Math.max(e.width,e.height)+3}_points(e){return e.map(e=>`${e.x.toFixed(2)},${e.y.toFixed(2)}`).join(" ")}render(){if(!this._hovered||!this.registry||!this._runtime.topologies.length)return this._setDesiredEndpointIds([]),i;const e=this._mappedMemo,n=e&&e.runtime===this._runtime&&e.devices===this.devices&&e.registry===this.registry?e.mapped:h(this._runtime.topologies,this.devices,this.registry);e&&n===e.mapped||(this._mappedMemo={runtime:this._runtime,devices:this.devices,registry:this.registry,mapped:n});const p=d(n,this.currentSpace,this._hovered),l=this.clientWidth||this._parent?.clientWidth||1,_=this.clientHeight||this._parent?.clientHeight||1,u=this._position(this._hovered,l,_);if(!u)return this._setDesiredEndpointIds([]),i;const b=p.lines.map(e=>({...e,point:this._position(e.neighborMarkerId,l,_)})).filter(e=>!!e.point).map(e=>{const t=void 0===e.lqi?"rgba(145,155,165,.85)":r(e.lqi),i=e.routeDirection?c(u,e.point,this._markerClearance(u),this._markerClearance(e.point),e.routeDirection):null;return{...e,color:t,arrow:i}}),m=u.x>l/2,v=this._markerClearance(u)+18,g=p.parentTargets.map((e,t)=>{const i=30*(t-(p.parentTargets.length-1)/2),r={x:u.x+(m?-v:v),y:Math.max(14,Math.min(_-14,u.y+i))};return{target:e,point:r,arrow:c(u,r,this._markerClearance(u),0,"toward-neighbor")}});return this._setDesiredEndpointIds(b.length||g.length||p.remoteCount?[this._hovered,...b.map(e=>e.neighborMarkerId)]:[]),s` +globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="d31b0b1e184ab2863684b758f839bdb6809a33cc742c6e9bb36c5ea034e3d309";import{aI as e,l as t,A as i,eb as r,aB as o,c as s,aH as n}from"./houseplan-card-W9mG3gab.js";import{t as a,a as h,r as d}from"./zigbee-topology-3KJks91U.js";import{zigbeeTopologyRuntimeSnapshot as p,subscribeZigbeeTopology as l}from"./zigbee-topology-runtime-DvCmPEhl.js";function c(e,t,i,r,o,s=9,n=4.5){const a=t.x-e.x,h=t.y-e.y,d=Math.hypot(a,h),p=d-Math.max(0,i)-Math.max(0,r);if(!Number.isFinite(d)||d<=0||p<4)return null;const l=a/d,c=h/d,_="toward-neighbor"===o,u=_?{x:t.x-l*Math.max(0,r),y:t.y-c*Math.max(0,r)}:{x:e.x+l*Math.max(0,i),y:e.y+c*Math.max(0,i)},b=Math.min(s,Math.max(4,.45*p)),m=Math.min(n,.5*b),v=_?-1:1,g=u.x+l*b*v,y=u.y+c*b*v,x=-c;return{tip:u,points:[u,{x:g+x*m,y:y+l*m},{x:g-x*m,y:y-l*m}]}}const _={revision:0,topologies:[],states:{}},u="data-hp-zigbee-topology-endpoint";class b extends e{constructor(){super(...arguments),this.devices=[],this.currentSpace="",this._runtime=_,this._hovered="",this._desiredEndpointIds=new Set,this._endpointSetDirty=!1,this._endpointElements=new Set,this._pointerOver=e=>{if(!this._mouseAllowed(e))return void this._clear();const t=this._deviceFromEvent(e),i=t?.dataset.id||"";i&&i!==this._hovered&&(this._hovered=i,this.requestUpdate())},this._pointerOut=e=>{const t=this._deviceFromEvent(e);if(!t||t.dataset.id!==this._hovered)return;const i=e.relatedTarget instanceof Element?e.relatedTarget.closest('[data-hp="device"]'):null;i?.dataset.id!==this._hovered&&this._clear()},this._pointerDown=e=>{"mouse"!==e.pointerType&&this._clear()}}connectedCallback(){super.connectedCallback();const e=this.getRootNode();e.host&&"undefined"!=typeof MutationObserver&&(this._hoverGateObserver=new MutationObserver(()=>{e.host.hasAttribute("data-pointer-hover")||this._clear()}),this._hoverGateObserver.observe(e.host,{attributes:!0,attributeFilter:["data-pointer-hover"]})),queueMicrotask(()=>this._connectParent())}disconnectedCallback(){this._release?.(),this._release=void 0,this._disconnectParent(),this._hoverGateObserver?.disconnect(),this._hoverGateObserver=void 0,this._hovered="",this._desiredEndpointIds.clear(),super.disconnectedCallback()}updated(e){e.has("hass")&&(this._release?.(),this._acceptRuntime(p(this.hass)),this._release=l(this.hass,()=>{this._acceptRuntime(p(this.hass))}));const t=e.has("currentSpace")||e.has("devices")||e.has("registry");t&&(this._mappedMemo=void 0,this.devices.some(e=>e.id===this._hovered&&e.space===this.currentSpace)||this._clear()),this._connectParent(),(this._endpointSetDirty||t)&&this._syncEndpointOwnership()}_acceptRuntime(e){e.revision===this._runtime.revision&&e.topologies===this._runtime.topologies&&e.states===this._runtime.states||(this._setDesiredEndpointIds([]),this._clearEndpointOwnership(),this._endpointSetDirty=!1,this._runtime=e,this._mappedMemo=void 0,this.requestUpdate())}_connectParent(){const e=this.parentElement;e&&e!==this._parent&&(this._disconnectParent(),this._parent=e,e.addEventListener("pointerover",this._pointerOver),e.addEventListener("pointerout",this._pointerOut),e.addEventListener("pointerdown",this._pointerDown,!0),"undefined"!=typeof MutationObserver&&(this._markerObserver=new MutationObserver(()=>this._syncEndpointOwnership()),this._markerObserver.observe(e,{childList:!0})),this._syncEndpointOwnership())}_disconnectParent(){this._parent?.removeEventListener("pointerover",this._pointerOver),this._parent?.removeEventListener("pointerout",this._pointerOut),this._parent?.removeEventListener("pointerdown",this._pointerDown,!0),this._markerObserver?.disconnect(),this._markerObserver=void 0,this._clearEndpointOwnership(),this._parent=void 0}_deviceFromEvent(e){for(const t of e.composedPath())if(t instanceof HTMLElement&&"device"===t.dataset.hp)return t;return null}_mouseAllowed(e){const t=this.getRootNode();return"mouse"===e.pointerType&&t.host?.hasAttribute?.("data-pointer-hover")}_clear(){this._setDesiredEndpointIds([]),this._clearEndpointOwnership(),this._endpointSetDirty=!1,this._hovered&&(this._hovered="",this.requestUpdate())}_setDesiredEndpointIds(e){const t=new Set(e);t.size===this._desiredEndpointIds.size&&[...t].every(e=>this._desiredEndpointIds.has(e))||(this._desiredEndpointIds=t,this._endpointSetDirty=!0)}_marker(e){return[...this._parent?.querySelectorAll('.dev[data-hp="device"][data-id]')||[]].find(t=>t.dataset.id===e)||null}_clearEndpointOwnership(){for(const e of this._endpointElements)e.removeAttribute(u);for(const e of this._parent?.querySelectorAll(`[${u}]`)||[])e.removeAttribute(u);this._endpointElements.clear()}_syncEndpointOwnership(){const e=new Set;for(const t of this._desiredEndpointIds){const i=this._marker(t);i&&e.add(i)}for(const t of this._endpointElements)e.has(t)||t.removeAttribute(u);for(const t of this._parent?.querySelectorAll(`[${u}]`)||[])e.has(t)||t.removeAttribute(u);for(const t of e)this._endpointElements.has(t)&&t.hasAttribute(u)||t.setAttribute(u,"");this._endpointElements=e,this._endpointSetDirty=!1}_position(e,t,i){const r=this._marker(e);if(!r)return null;const o=Number.parseFloat(r.style.left),s=Number.parseFloat(r.style.top),n=r.getBoundingClientRect();return Number.isFinite(o)&&Number.isFinite(s)?{x:o*t/100,y:s*i/100,width:n.width,height:n.height}:null}_targetText(e){if("remote-space"===e.kind){const i=this.spaces?.find(t=>t.id===e.spaceId)?.title;return"string"==typeof i&&i.trim()||a(t(this.hass),"route_other_space")}return a(t(this.hass),"unplaced-coordinator"===e.kind?"route_coordinator_not_on_plan":"route_device_not_on_plan")}_markerClearance(e){return.61*Math.max(e.width,e.height)+3}_points(e){return e.map(e=>`${e.x.toFixed(2)},${e.y.toFixed(2)}`).join(" ")}render(){if(!this._hovered||!this.registry||!this._runtime.topologies.length)return this._setDesiredEndpointIds([]),i;const e=this._mappedMemo,n=e&&e.runtime===this._runtime&&e.devices===this.devices&&e.registry===this.registry?e.mapped:h(this._runtime.topologies,this.devices,this.registry);e&&n===e.mapped||(this._mappedMemo={runtime:this._runtime,devices:this.devices,registry:this.registry,mapped:n});const p=d(n,this.currentSpace,this._hovered),l=this.clientWidth||this._parent?.clientWidth||1,_=this.clientHeight||this._parent?.clientHeight||1,u=this._position(this._hovered,l,_);if(!u)return this._setDesiredEndpointIds([]),i;const b=p.lines.map(e=>({...e,point:this._position(e.neighborMarkerId,l,_)})).filter(e=>!!e.point).map(e=>{const t=void 0===e.lqi?"rgba(145,155,165,.85)":r(e.lqi),i=e.routeDirection?c(u,e.point,this._markerClearance(u),this._markerClearance(e.point),e.routeDirection):null;return{...e,color:t,arrow:i}}),m=u.x>l/2,v=this._markerClearance(u)+18,g=p.parentTargets.map((e,t)=>{const i=30*(t-(p.parentTargets.length-1)/2),r={x:u.x+(m?-v:v),y:Math.max(14,Math.min(_-14,u.y+i))};return{target:e,point:r,arrow:c(u,r,this._markerClearance(u),0,"toward-neighbor")}});return this._setDesiredEndpointIds(b.length||g.length||p.remoteCount?[this._hovered,...b.map(e=>e.neighborMarkerId)]:[]),s` ${b.length||g.length?o`${E} @@ -21,4 +21,4 @@ globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db ${this.context.t(this.busy?"pdf.saving":"pdf.save")}
    - `}}v.properties={context:{attribute:!1}},v.styles=A`:host{display:contents;}.body{display:grid;gap:12px;width:100%;max-width:100%;min-width:0;padding:16px 20px;box-sizing:border-box;}label{display:flex;min-width:0;min-height:44px;align-items:center;gap:12px;cursor:pointer;}label span{min-width:0;overflow-wrap:anywhere;}input{width:20px;height:20px;flex:none;accent-color:var(--hp-accent,#d89300);}.row{display:flex;align-items:center;gap:8px;width:100%;max-width:100%;min-width:0;padding:12px 16px;box-sizing:border-box;}.spacer{flex:1;}button{min-width:0;min-height:44px;max-width:100%;display:inline-flex;align-items:center;justify-content:center;border:1px solid var(--hp-line,rgb(127 127 127/.3));border-radius:12px;padding:0 18px;box-sizing:border-box;overflow-wrap:anywhere;white-space:normal;background:transparent;color:inherit;font:inherit;cursor:pointer;}button.primary{background:var(--hp-accent,#d89300);color:var(--hp-on-accent,#111);border-color:transparent;}button:disabled{opacity:.55;cursor:default;}ha-icon{flex:none;margin-right:6px;}@media (max-width:360px){.row{display:grid;grid-template-columns:minmax(0,1fr);}.spacer{display:none;}button{width:100%;}}`,customElements.get("hp-pdf-dialog")||customElements.define("hp-pdf-dialog",v);const V=(A,B,E)=>Math.hypot(A[0]-B[0],A[1]-B[1])<=E,U=A=>Number.isFinite(A)&&A>=0?A:0;function l(A){const B=Number(A);return Number.isFinite(B)&&B>0?.1/B:0}const a=(A,B)=>[...new Set([...A,...B])].sort((A,B)=>A-B),P=(A,B)=>{const E=A.points.length;if(E<=1||!V(A.points[E-1],A.points[0],B))return!1;const s=E-2;return A.edgeSources[s]=a(A.edgeSources[s],A.edgeSources[E-1]),A.points.splice(E-1,1),A.edgeSources.splice(E-1,1),!0},y=(A,B)=>{for(let E=0;E+1{let E=!1;for(;A.points.length>1;)if(P(A,B))E=!0;else{if(!y(A,B))break;E=!0}return E},N=(A,B,E)=>{const s=B[0]-A[0],w=B[1]-A[1],C=E[0]-B[0],g=E[1]-B[1],I=Math.hypot(s,w),Y=Math.hypot(C,g);if(!(I>0&&Y>0))return!1;const R=s*C+w*g;if(!(R>0))return!1;const M=s*g-w*C;return Math.abs(M)<=R*Q},K=A=>{const B=A.points.length;if(B<3)return!1;for(let E=0;E{const E=U(B),s=[],w=[];for(let B=0;B[A])};for(;Q.points.length>1;){const A=u(Q,E);if(Q.points.length<3)break;if(!K(Q)&&!A)break}return u(Q,E),Q};function J(A,B){const E=Number(A[0]),s=Number(A[1]),w=Number(B[0]),C=Number(B[1]);if(![E,s,w,C].every(Number.isFinite))return null;const g=w-E,I=C-s,Y=Math.abs(g),R=Math.abs(I),M=Math.max(Y,R),F=Math.min(Y,R);if(!(M>0)||F/M>Q)return null;const i=[(E+w)/2,(s+C)/2];if(Y>=R){return{axis:"horizontal",a:[E,i[1]],b:[w,i[1]],mid:i,projectedLength:Y,tangentInterval:[Math.min(E,w),Math.max(E,w)],normalCoordinate:i[1]}}return{axis:"vertical",a:[i[0],s],b:[i[0],C],mid:i,projectedLength:R,tangentInterval:[Math.min(s,C),Math.max(s,C)],normalCoordinate:i[0]}}function Z(A,B){const E=B.map(A=>[Number(A[0]),Number(A[1])]);if(!E.every(A=>A.every(Number.isFinite)))return!1;if(E.length<3||((A,B)=>{const E=1e-12*Math.max(1,Math.abs(A[0]),Math.abs(A[1]),...B.flatMap(A=>[Math.abs(A[0]),Math.abs(A[1])]));for(let s=0;s0))continue;const Y=(A[0]-w[0])*g-(A[1]-w[1])*C;if(Math.abs(Y)>E*I)continue;const R=(A[0]-w[0])*C+(A[1]-w[1])*g;if(R>=-E&&R<=I*I+E)return!0}return!1})(A,E))return!1;let s=!1;for(let B=0,w=E.length-1;BA[1]==C[1]>A[1])continue;const g=(C[0]-Q[0])*(A[1]-Q[1])/(C[1]-Q[1])+Q[0];A[0]Object.is(A,-0)?0:A,I=[g(-Q/C),g(w/C)],Y=[g(-I[0]),g(-I[1])],R=[(B[0]+E[0])/2,(B[1]+E[1])/2],M=Math.max(1,C,Math.abs(R[0]),Math.abs(R[1])),F=Math.max(1e-9*M,.01*U(s));for(const B of[F,4*F,16*F]){const E=Z([R[0]+I[0]*B,R[1]+I[1]*B],A);if(E!==Z([R[0]+Y[0]*B,R[1]+Y[1]*B],A))return E?I:Y}return sA(A)>=0?I:Y}function f(A,B){let E=180*Math.atan2(B[1]-A[1],B[0]-A[0])/Math.PI;return E>90&&(E-=180),E<=-90&&(E+=180),E}function k(A,B,E,s={}){const w=Number(B);if(!(w>0&&Number.isFinite(w)))return[];const Q=void 0===s.epsilon?l(w):U(s.epsilon);return z(d(A,Q),w,E,{...s,epsilon:Q})}const z=(A,B,E,s)=>{if(A.points.length<3)return[];const Q=U(s.epsilon??l(B)),C=Number.isFinite(Number(s.ringIndex))?Number(s.ringIndex):0,g=[];for(let s=0;sQ))continue;const M=[...A.edgeSources[s]||[s]].sort((A,B)=>A-B),F=M[0]??s,i=T(A.points,R.a,R.b,Q),x=("horizontal"===R.axis?i[1]:i[0])<0?-1:1,b=[R.axis,O(R.tangentInterval[0]),String(x),O(C),O(F)].join("|"),L=R.projectedLength*B;g.push({sourceA:[...I],sourceB:[...Y],a:R.a,b:R.b,text:w(L,E),short:L<30,angle:f(R.a,R.b),mid:R.mid,axis:R.axis,projectedLength:R.projectedLength,tangentInterval:R.tangentInterval,normalCoordinate:R.normalCoordinate,inwardNormal:i,normalSign:x,source:{ringIndex:C,edgeIndex:F},sourceEdgeIndices:M,stableKey:b})}return g};function p(A,B,E,s={}){const w=Number(B);if(!(w>0&&Number.isFinite(w)))return[];const Q=void 0===s.epsilon?l(w):U(s.epsilon);let C=d(A,Q);if(sA(C.points)<0&&(C=(A=>{const B=A.points.length;return{points:[...A.points].reverse().map(A=>[...A]),edgeSources:A.points.map((E,s)=>[...A.edgeSources[(B-2-s+B)%B]])}})(C)),C.points.length){let A=0;for(let B=1;B({points:[...A.points.slice(B),...A.points.slice(0,B)],edgeSources:[...A.edgeSources.slice(B),...A.edgeSources.slice(0,B)]}))(C,A)}return z(C,w,E,{...s,epsilon:Q})}function X(A,B){const E=U(B),s=[];for(const B of A){const A=s.find(A=>A.axis===B.axis&&A.normalSign===B.normalSign&&Math.abs(A.normalCoordinate-B.normalCoordinate)<=E);A?A.edges.push(B):s.push({axis:B.axis,normalSign:B.normalSign,normalCoordinate:B.normalCoordinate,edges:[B]})}return s.map(A=>A.edges)}const O=A=>Object.is(A,-0)?"0":String(A),q=A=>"horizontal"===A?0:1;function $(A,B){return q(A.axis)-q(B.axis)||A.tangentInterval[0]-B.tangentInterval[0]||A.normalSign-B.normalSign||A.source.ringIndex-B.source.ringIndex||A.source.edgeIndex-B.source.edgeIndex}function _(A,B,E,s){const w=U(s);if(A.axis!==B.axis)return!1;if(A.source.ringIndex!==B.source.ringIndex)return!1;if(A.inwardNormal[0]*B.inwardNormal[0]+A.inwardNormal[1]*B.inwardNormal[1]>=-.5)return!1;if(!((A,B,E)=>Math.abs(A[0]-B[0])<=E&&Math.abs(A[1]-B[1])<=E)(A.tangentInterval,B.tangentInterval,w))return!1;if(Math.abs(A.projectedLength-B.projectedLength)>w)return!1;return Z([(A.mid[0]+B.mid[0])/2,(A.mid[1]+B.mid[1])/2],E)}const AA=(A,B)=>{const E=B?.(A);return{hardCollisions:Number.isFinite(Number(E?.hardCollisions))?Number(E?.hardCollisions):0,normalClearance:Number.isFinite(Number(E?.normalClearance))?Number(E?.normalClearance):0}},BA=(A,B,E)=>{const s=AA(A,E),w=AA(B,E);return s.hardCollisions-w.hardCollisions||w.normalClearance-s.normalClearance||$(A,B)};function EA(A,B){if(A.length<2)return[...A];const E=U(B.epsilon),s=function(A,B=1e-7){return d(A,B).points.map(A=>[...A])}(B.ring,E),w=[];for(let B=0;B{const E=A.separation-B.separation;if(E)return E;const s=$(A.left,A.right)<=0?A.left:A.right,w=s===A.left?A.right:A.left,Q=$(B.left,B.right)<=0?B.left:B.right,C=Q===B.left?B.right:B.left;return $(s,Q)||$(w,C)});const Q=new Set,C=new Set;for(const A of w){if(Q.has(A.left)||Q.has(A.right))continue;Q.add(A.left),Q.add(A.right);const E=BA(A.left,A.right,B.score)<=0?A.left:A.right;C.add(E===A.left?A.right:A.left)}return A.filter(A=>!C.has(A))}function sA(A){let B=0;for(let E=0;E1){const A=Math.sqrt(G);Y*=A,R*=A}const o=Math.max(0,Y*Y*R*R-Y*Y*D*D-R*R*L*L),t=Y*Y*D*D+R*R*L*L||1,c=(Q===C?-1:1)*Math.sqrt(o/t),W=c*Y*D/R,m=c*-R*L/Y,n=F*W-i*m+(A+g)/2,e=i*W+F*m+(B+I)/2;let h=gA(1,0,(L-W)/Y,(D-m)/R),S=gA((L-W)/Y,(D-m)/R,(-L-W)/Y,(-D-m)/R);!C&&S>0&&(S-=2*Math.PI),C&&S<0&&(S+=2*Math.PI);const j=Math.max(1,Math.ceil(Math.abs(S)/(Math.PI/2))),r=S/j,H=A=>[n+F*Y*Math.cos(A)-i*R*Math.sin(A),e+i*Y*Math.cos(A)+F*R*Math.sin(A)],v=A=>[-F*Y*Math.sin(A)-i*R*Math.cos(A),-i*Y*Math.sin(A)+F*R*Math.cos(A)],V=[];for(let A=0;A[B.a*A+B.c*E+B.e,B.b*A+B.d*E+B.f];return function(A){const B=A.match(/[AaCcHhLlMmQqSsTtVvZz]|[-+]?(?:\d*\.\d+|\d+\.?)(?:e[-+]?\d+)?/gi)||[],E=[];let s=0,w="",Q=0,C=0,g=0,I=0,Y=null,R=null;const M=()=>Number(B[s++]);for(;sB.length||QA.test(B[s]))throw new Error(`Invalid SVG path command ${w}`);const x=Array.from({length:i},M),b=A=>A+(F?Q:0),L=A=>A+(F?C:0);if("M"===A||"L"===A)Q=b(x[0]),C=L(x[1]),E.push({op:"M"===A?"M":"L",x:Q,y:C}),"M"===A&&(g=Q,I=C,w=F?"l":"L"),Y=R=null;else if("H"===A)Q=b(x[0]),E.push({op:"L",x:Q,y:C}),Y=R=null;else if("V"===A)C=L(x[0]),E.push({op:"L",x:Q,y:C}),Y=R=null;else if("C"===A){const A=b(x[0]),B=L(x[1]),s=b(x[2]),w=L(x[3]);Q=b(x[4]),C=L(x[5]),Y=[s,w],R=null,E.push({op:"C",x1:A,y1:B,x2:s,y2:w,x:Q,y:C})}else if("S"===A){const A=Y?2*Q-Y[0]:Q,B=Y?2*C-Y[1]:C,s=b(x[0]),w=L(x[1]);Q=b(x[2]),C=L(x[3]),Y=[s,w],R=null,E.push({op:"C",x1:A,y1:B,x2:s,y2:w,x:Q,y:C})}else if("Q"===A||"T"===A){const B="Q"===A?b(x[0]):R?2*Q-R[0]:Q,s="Q"===A?L(x[1]):R?2*C-R[1]:C,w=b("Q"===A?x[2]:x[0]),g=L("Q"===A?x[3]:x[1]);E.push({op:"C",x1:Q+2/3*(B-Q),y1:C+2/3*(s-C),x2:w+2/3*(B-w),y2:g+2/3*(s-g),x:w,y:g}),Q=w,C=g,R=[B,s],Y=null}else if("A"===A){const A=b(x[5]),B=L(x[6]),s=IA(Q,C,x[0],x[1],x[2],x[3],x[4],A,B);s.length?E.push(...s):E.push({op:"L",x:A,y:B}),Q=A,C=B,Y=R=null}}return E}(A).map(A=>{if("Z"===A.op)return A;if("M"===A.op||"L"===A.op){const[B,s]=E(A.x,A.y);return{op:A.op,x:B,y:s}}if("C"!==A.op)throw new Error("Unsupported PDF vector operation");const[B,s]=E(A.x1,A.y1),[w,Q]=E(A.x2,A.y2),[C,g]=E(A.x,A.y);return{op:"C",x1:B,y1:s,x2:w,y2:Q,x:C,y:g}})}const RA=["M20.82,15.31h0L10.46,9c-.46-.26-1.11.37-.86.84l6.15,10.56,10.56,6.15a.66.66,0,0,0,.84-.86Zm-4,4,3-3,4.55,7.44Z","M18,2A16,16,0,1,0,34,18,16,16,0,0,0,18,2Zm1,29.95V29.53H17v2.42A14,14,0,0,1,4.05,19H6.47V17H4.05A14,14,0,0,1,17,4.05V6.47h2V4.05A14,14,0,0,1,31.95,17H29.53v2h2.42A14,14,0,0,1,19,31.95Z"],MA=A=>Math.abs(A)<1e-12?0:Math.abs(A-1)<1e-12?1:Math.abs(A+1)<1e-12?-1:A;function FA(A){const B=function(A){const{centerX:B,centerY:E,size:s,northDeg:w}=A;if(![B,E,s,w].every(Number.isFinite)||s<=0)throw new RangeError("PDF compass placement must contain finite coordinates and a positive size");const Q=((w%360+360)%360+45)*Math.PI/180,C=s/36,g=MA(Math.cos(Q)),I=MA(Math.sin(Q)),Y=C*g,R=C*I,M=-C*I,F=C*g;return{a:Y,b:R,c:M,d:F,e:B-18*Y-18*M,f:E-18*R-18*F}}(A);return RA.flatMap(A=>YA(A,B))}const iA=1e-8,xA=A=>A.length>=2&&Number.isFinite(A[0])&&Number.isFinite(A[1]),bA=(A,B)=>A[0]>=B.minX-iA&&A[0]<=B.maxX+iA&&A[1]>=B.minY-iA&&A[1]<=B.maxY+iA,LA=A=>[A.minX,A.minY,A.maxX,A.maxY].every(Number.isFinite)&&A.maxX>=A.minX&&A.maxY>=A.minY,DA=A=>[[A.minX,A.minY],[A.maxX,A.minY],[A.maxX,A.maxY],[A.minX,A.maxY]];const GA=(A,B,E)=>(B[0]-A[0])*(E[1]-A[1])-(B[1]-A[1])*(E[0]-A[0]),oA=(A,B,E)=>{const s=E[0]-B[0],w=E[1]-B[1],Q=Math.abs(s)>=Math.abs(w)?s:w;return Math.abs(Q)<=iA?0:(Math.abs(s)>=Math.abs(w)?A[0]-B[0]:A[1]-B[1])/Q},tA=(A,B)=>Math.hypot(B[0]-A[0],B[1]-A[1]);function cA(A,B,E){const s=tA(B,E);if(s<=iA)return tA(A,B)<=iA;if(Math.abs(GA(B,E,A))/s>iA)return!1;const w=oA(A,B,E),Q=iA/s;return w>=-Q&&w<=1+Q}function WA(A,B,E,s){const w=B[0]-A[0],Q=B[1]-A[1],C=s[0]-E[0],g=s[1]-E[1],I=Math.hypot(w,Q),Y=Math.hypot(C,g);if(I<=iA)return cA(A,E,s)?{t:0,endT:0,overlap:!1}:null;if(Y<=iA){if(!cA(E,A,B))return null;const s=Math.max(0,Math.min(1,oA(E,A,B)));return{t:s,endT:s,overlap:!1}}const R=w*g-Q*C,M=E[0]-A[0],F=E[1]-A[1],i=iA*I*Y;if(Math.abs(R)<=i){if(Math.abs(GA(A,B,E))/I>iA||Math.abs(GA(A,B,s))/I>iA)return null;const w=oA(E,A,B),Q=oA(s,A,B),C=Math.max(0,Math.min(w,Q)),g=Math.min(1,Math.max(w,Q));return giA}}const x=(M*g-F*C)/R,b=(M*Q-F*w)/R,L=iA/I,D=iA/Y;if(x<-L||x>1+L||b<-D||b>1+D)return null;const G=Math.max(0,Math.min(1,x));return{t:G,endT:G,overlap:!1}}const mA=A=>A.every(A=>A.length>=2&&A.every(xA));function nA(A,B){for(const E of A){const A=E;for(let E=0;Enull!==WA(A,B,E,s[(w+1)%s.length]))}const hA=2048,SA=2146,jA=[-1825,-555,4188,2163],rA={32:1,33:2,34:3,35:4,36:5,37:6,38:7,39:8,40:9,41:10,42:11,43:12,44:13,45:14,46:15,47:16,48:17,49:18,50:19,51:20,52:21,53:22,54:23,55:24,56:25,57:26,58:27,59:28,60:29,61:30,62:31,63:32,64:33,65:34,66:35,67:36,68:37,69:38,70:39,71:40,72:41,73:42,74:43,75:44,76:45,77:46,78:47,79:48,80:49,81:50,82:51,83:52,84:53,85:54,86:55,87:56,88:57,89:58,90:59,91:60,92:61,93:62,94:63,95:64,96:65,97:66,98:67,99:68,100:69,101:70,102:71,103:72,104:73,105:74,106:75,107:76,108:77,109:78,110:79,111:80,112:81,113:82,114:83,115:84,116:85,117:86,118:87,119:88,120:89,121:90,122:91,123:92,124:93,125:94,126:95,160:596,161:96,162:97,163:98,164:99,165:100,166:101,167:102,168:103,169:104,170:105,171:106,172:107,173:597,174:108,175:109,176:110,177:111,178:112,179:113,180:114,181:115,182:116,183:117,184:118,185:119,186:120,187:121,188:122,189:123,190:124,191:125,192:603,193:604,194:605,195:606,196:607,197:608,198:126,199:609,200:610,201:611,202:612,203:613,204:614,205:615,206:616,207:617,208:599,209:618,210:619,211:620,212:621,213:622,214:623,215:127,216:128,217:624,218:625,219:626,220:627,221:628,222:129,223:130,224:629,225:630,226:631,227:632,228:633,229:634,230:131,231:635,232:636,233:637,234:638,235:639,236:640,237:641,238:642,239:643,240:132,241:644,242:645,243:646,244:647,245:648,246:649,247:133,248:134,249:650,250:651,251:652,252:653,253:654,254:135,255:655,256:656,257:657,258:658,259:659,260:660,261:661,262:662,263:663,264:664,265:665,266:666,267:667,268:668,269:669,270:670,271:671,272:598,273:136,274:672,275:673,276:674,277:675,278:676,279:677,280:678,281:679,282:680,283:681,284:682,285:683,286:684,287:685,288:686,289:687,290:688,291:689,292:690,293:691,294:137,295:600,296:692,297:693,298:694,299:695,300:696,301:697,302:698,303:699,304:700,305:138,306:701,307:702,308:703,309:704,310:705,311:706,312:139,313:707,314:708,315:709,316:710,317:711,318:712,319:713,320:714,321:140,322:141,323:715,324:716,325:717,326:718,327:719,328:720,329:721,330:142,331:143,332:722,333:723,334:724,335:725,336:726,337:727,338:144,339:145,340:728,341:729,342:730,343:731,344:732,345:733,346:734,347:735,348:736,349:737,350:738,351:739,352:742,353:743,354:744,355:745,356:746,357:747,358:601,359:602,360:748,361:749,362:750,363:751,364:752,365:753,366:754,367:755,368:756,369:757,370:758,371:759,372:760,373:761,374:762,375:763,376:764,377:765,378:766,379:767,380:768,381:769,382:770,383:146,1024:897,1025:856,1026:165,1027:857,1028:166,1029:858,1030:859,1031:860,1032:861,1033:167,1034:168,1035:169,1036:863,1037:898,1038:864,1039:170,1040:865,1041:171,1042:866,1043:867,1044:172,1045:868,1046:173,1047:174,1048:175,1049:869,1050:862,1051:176,1052:870,1053:871,1054:872,1055:873,1056:874,1057:875,1058:876,1059:177,1060:178,1061:877,1062:179,1063:180,1064:181,1065:182,1066:183,1067:184,1068:185,1069:186,1070:187,1071:188,1072:878,1073:189,1074:190,1075:191,1076:192,1077:879,1078:193,1079:194,1080:195,1081:880,1082:196,1083:197,1084:198,1085:199,1086:881,1087:200,1088:882,1089:883,1090:201,1091:884,1092:202,1093:885,1094:203,1095:204,1096:205,1097:206,1098:207,1099:208,1100:209,1101:210,1102:211,1103:212,1104:899,1105:886,1106:213,1107:887,1108:214,1109:888,1110:889,1111:890,1112:891,1113:215,1114:216,1115:217,1116:892,1117:900,1118:893,1119:218,1120:219,1121:220,1122:965,1123:221,1124:222,1125:223,1126:224,1127:225,1128:226,1129:227,1130:228,1131:229,1132:230,1133:231,1134:232,1135:233,1136:901,1137:902,1138:234,1139:235,1140:236,1141:237,1142:903,1143:904,1144:906,1145:905,1146:238,1147:239,1148:240,1149:241,1150:242,1151:243,1152:244,1153:245,1154:246,1155:247,1156:248,1157:249,1158:250,1159:251,1160:252,1161:253,1162:254,1163:255,1164:964,1165:256,1166:257,1167:258,1168:259,1169:260,1170:966,1171:967,1172:261,1173:262,1174:263,1175:264,1176:907,1177:908,1178:265,1179:266,1180:267,1181:268,1182:968,1183:969,1184:269,1185:270,1186:271,1187:272,1188:273,1189:274,1190:275,1191:276,1192:277,1193:278,1194:909,1195:910,1196:955,1197:956,1198:911,1199:912,1200:970,1201:971,1202:279,1203:280,1204:281,1205:282,1206:283,1207:284,1208:285,1209:286,1210:287,1211:963,1212:288,1213:289,1214:961,1215:962,1216:913,1217:914,1218:915,1219:290,1220:291,1221:292,1222:293,1223:294,1224:295,1225:296,1226:297,1227:957,1228:958,1229:298,1230:299,1231:916,1232:917,1233:918,1234:919,1235:920,1236:921,1237:922,1238:923,1239:924,1240:300,1241:926,1242:925,1243:927,1244:928,1245:929,1246:930,1247:931,1248:301,1249:302,1250:932,1251:933,1252:934,1253:935,1254:936,1255:937,1256:938,1257:939,1258:940,1259:941,1260:942,1261:943,1262:944,1263:945,1264:946,1265:947,1266:948,1267:949,1268:950,1269:951,1270:959,1271:960,1272:952,1273:953,1274:303,1275:304,1276:305,1277:306,1278:972,1279:973,1280:307,1281:954,1282:308,1283:309,1284:310,1285:311,1286:312,1287:313,1288:314,1289:315,1290:316,1291:317,1292:318,1293:319,1294:320,1295:321,1296:322,1297:974,1298:323,1299:324,1300:325,1301:326,1302:327,1303:328,1304:329,1305:330,1306:982,1307:983,1308:984,1309:985,1310:331,1311:332,1312:333,1313:334,1314:335,1315:336,1316:337,1317:338,1318:339,1319:340,1320:341,1321:342,1322:343,1323:344,1324:345,1325:346,1326:347,1327:348,8192:349,8193:350,8194:351,8195:352,8196:353,8197:354,8198:355,8199:356,8200:357,8201:358,8202:360,8203:361,8204:362,8205:363,8206:364,8207:365,8208:366,8209:367,8210:368,8211:369,8212:370,8213:975,8214:371,8215:372,8216:373,8217:374,8218:375,8219:376,8220:377,8221:378,8222:379,8223:380,8224:381,8225:382,8226:383,8227:384,8228:385,8229:386,8230:387,8231:388,8239:986,8240:389,8241:390,8242:894,8243:895,8244:391,8245:392,8246:393,8247:394,8248:395,8249:396,8250:397,8251:398,8252:896,8253:399,8254:400,8255:401,8256:402,8257:403,8258:404,8259:405,8260:406,8261:407,8262:408,8263:987,8264:988,8265:989,8266:409,8267:410,8268:411,8269:412,8270:413,8271:414,8272:415,8273:416,8274:417,8275:418,8276:419,8277:420,8278:421,8279:422,8280:423,8281:424,8282:425,8283:426,8284:427,8285:428,8286:429,8287:990,8364:430,8381:431,8776:433},HA={1:507,2:527,3:655,4:1261,5:1150,6:1500,7:1273,8:357,9:700,10:712,11:882,12:1161,13:402,14:565,15:539,16:844,17:1150,18:1150,19:1150,20:1150,21:1150,22:1150,23:1150,24:1150,25:1150,26:1150,27:496,28:433,29:1041,30:1124,31:1070,32:967,33:1839,34:1336,35:1275,36:1333,37:1343,38:1164,39:1132,40:1395,41:1460,42:557,43:1130,44:1284,45:1102,46:1788,47:1460,48:1408,49:1292,50:1408,51:1261,52:1215,53:1222,54:1328,55:1303,56:1817,57:1284,58:1230,59:1226,60:543,61:840,62:543,63:856,64:924,65:633,66:1114,67:1149,68:1072,69:1155,70:1085,71:711,72:1149,73:1128,74:497,75:489,76:1038,77:497,78:1795,79:1130,80:1168,81:1149,82:1164,83:693,84:1056,85:669,86:1129,87:992,88:1539,89:1015,90:969,91:1015,92:693,93:499,94:693,95:1393,96:499,97:1120,98:1190,99:1460,100:1075,101:491,102:1256,103:856,104:1609,105:915,106:961,107:1134,108:1610,109:938,110:765,111:1094,112:751,113:751,114:642,115:1160,116:1001,117:534,118:507,119:751,120:931,121:960,122:1500,123:1589,124:1593,125:969,126:1914,127:1092,128:1408,129:1210,130:1218,131:1729,132:1200,133:1169,134:1160,135:1180,136:1223,137:1434,138:506,139:1139,140:1103,141:553,142:1419,143:1160,144:1953,145:1860,146:508,165:1535,166:1380,167:2193,168:2212,169:1666,170:1460,171:1291,172:1540,173:1859,174:1215,175:1460,176:1449,177:1287,178:1580,179:1497,180:1402,181:1927,182:1984,183:1554,184:1771,185:1285,186:1380,187:1831,188:1304,189:1132,190:1170,191:859,192:1236,193:1568,194:1040,195:1182,196:1106,197:1184,198:1519,199:1181,200:1182,201:984,202:1485,203:1213,204:1113,205:1656,206:1694,207:1271,208:1590,209:1112,210:1101,211:1671,212:1124,213:1128,214:1101,215:1737,216:1764,217:1161,218:1182,219:1800,220:1579,221:1110,222:1835,223:1528,224:1234,225:1094,226:1803,227:1547,228:1745,229:1505,230:2308,231:2001,232:1059,233:987,234:1393,235:1163,236:1290,237:1027,238:1393,239:1160,240:1793,241:1572,242:1800,243:1579,244:1330,245:1095,246:1277,247:1024,248:1024,249:1024,250:1024,251:1024,252:1024,253:1024,254:1545,255:1261,256:1110,257:1307,258:1161,259:1123,260:912,261:1243,262:1029,263:1954,264:1633,265:1434,266:1208,267:1289,268:1150,269:1676,270:1411,271:1535,272:1241,273:1999,274:1460,275:2097,276:1780,277:1518,278:1235,279:1304,280:1066,281:1836,282:1372,283:1468,284:1174,285:1391,286:1130,287:1391,288:1583,289:1213,290:1289,291:1114,292:1534,293:1263,294:1458,295:1160,296:1554,297:1260,298:1871,299:1598,300:1415,301:1192,302:1192,303:1207,304:939,305:1326,306:1088,307:1270,308:1684,309:1764,310:1622,311:1323,312:1097,313:1031,314:1985,315:1653,316:2043,317:1697,318:1270,319:1053,320:1453,321:1312,322:1380,323:1538,324:1266,325:1920,326:1549,327:1857,328:1547,329:1926,330:1774,331:1316,332:1106,333:2274,334:1832,335:2300,336:1829,337:1526,338:1242,339:1468,340:1208,341:1539,342:1273,343:2710,344:2238,345:1568,346:1240,347:1515,348:1243,349:1044,350:2089,351:1044,352:2089,353:697,354:522,355:348,356:1151,357:560,358:418,360:209,361:1024,362:1024,363:1024,364:1024,365:1024,366:564,367:564,368:1171,369:1344,370:1599,371:778,372:933,373:409,374:409,375:407,376:409,377:724,378:731,379:705,380:764,381:1129,382:1167,383:690,384:1100,385:511,386:964,387:1370,388:382,389:1962,390:2360,391:1045,392:463,393:757,394:1045,395:803,396:614,397:614,398:1241,399:919,400:952,401:1540,402:1540,403:874,404:1370,405:870,406:931,407:640,408:641,409:907,410:1001,411:1237,412:1237,413:985,414:511,415:1541,416:985,417:931,418:1366,419:1540,420:1172,421:932,422:1333,423:1215,424:1125,425:379,426:1071,427:1162,428:379,429:379,430:1150,431:1359,433:1154,596:507,597:565,598:1373,599:1373,600:1158,601:1222,602:669,603:1336,604:1336,605:1336,606:1336,607:1336,608:1336,609:1333,610:1164,611:1164,612:1164,613:1164,614:557,615:557,616:557,617:557,618:1460,619:1408,620:1408,621:1408,622:1408,623:1408,624:1328,625:1328,626:1328,627:1328,628:1230,629:1114,630:1114,631:1114,632:1114,633:1114,634:1114,635:1072,636:1085,637:1085,638:1085,639:1085,640:506,641:506,642:506,643:506,644:1130,645:1168,646:1168,647:1168,648:1168,649:1168,650:1129,651:1129,652:1129,653:1129,654:969,655:969,656:1336,657:1114,658:1336,659:1114,660:1336,661:1114,662:1333,663:1072,664:1333,665:1072,666:1333,667:1072,668:1333,669:1072,670:1343,671:1305,672:1164,673:1085,674:1164,675:1085,676:1164,677:1085,678:1164,679:1085,680:1164,681:1085,682:1395,683:1149,684:1395,685:1149,686:1395,687:1149,688:1395,689:1149,690:1460,691:1128,692:557,693:506,694:557,695:506,696:557,697:506,698:557,699:497,700:557,701:1687,702:986,703:1130,704:515,705:1284,706:1038,707:1102,708:497,709:1102,710:497,711:1102,712:647,713:1102,714:717,715:1460,716:1130,717:1460,718:1130,719:1460,720:1130,721:1130,722:1408,723:1168,724:1408,725:1168,726:1408,727:1168,728:1261,729:693,730:1261,731:693,732:1261,733:693,734:1215,735:1056,736:1215,737:1056,738:1215,739:1056,742:1215,743:1056,744:1222,745:669,746:1222,747:709,748:1328,749:1129,750:1328,751:1129,752:1328,753:1129,754:1328,755:1129,756:1328,757:1129,758:1328,759:1129,760:1817,761:1539,762:1230,763:969,764:1230,765:1226,766:1015,767:1226,768:1015,769:1226,770:1015,856:1164,857:1139,858:1215,859:557,860:557,861:1130,862:1316,863:1284,864:1287,865:1336,866:1275,867:1139,868:1164,869:1460,870:1788,871:1460,872:1408,873:1461,874:1292,875:1333,876:1222,877:1284,878:1114,879:1085,880:1182,881:1168,882:1149,883:1072,884:969,885:1015,886:1085,887:859,888:1056,889:497,890:506,891:489,892:1106,893:969,894:357,895:655,896:1054,897:1164,898:1460,899:1085,900:1182,901:1417,902:1434,903:1290,904:1027,905:2137,906:2377,907:1215,908:1040,909:1333,910:1072,911:1230,912:1026,913:557,914:1859,915:1568,916:557,917:1336,918:1114,919:1336,920:1114,921:1914,922:1729,923:1164,924:1085,925:1415,926:1079,927:1079,928:1859,929:1568,930:1215,931:1040,932:1460,933:1182,934:1460,935:1182,936:1408,937:1168,938:1393,939:1163,940:1393,941:1163,942:1380,943:1101,944:1287,945:969,946:1287,947:969,948:1287,949:969,950:1402,951:1113,952:1771,953:1590,954:1155,955:1222,956:984,957:1402,958:1113,959:1139,960:859,961:1583,962:1213,963:1128,964:1285,965:1285,966:1139,967:859,968:1336,969:1063,970:1230,971:1026,972:1284,973:1015,974:1104,975:1599,982:1408,983:1164,984:1817,985:1539,986:507,987:1934,988:1494,989:1494,990:507},vA=new TextEncoder,VA=A=>{const B=Math.round(100*A)/100;return Number.isInteger(B)?String(B):B.toFixed(2).replace(/0+$/,"")},UA=A=>{const B=Math.round(1e6*A)/1e6;return Number.isInteger(B)?String(B):B.toFixed(6).replace(/0+$/,"")},lA=A=>A.map(UA).join(" ");function aA(A){let B="",E=0;const s=new Map;for(const w of A){const A=w.codePointAt(0)||0,Q=rA[A]||rA[63];B+=Q.toString(16).padStart(4,"0"),E+=HA[Q]||1024,s.has(Q)||s.set(Q,A||63)}return{hex:B,width:E,unicode:s}}function PA(A,B){return aA(A).width*B/hA}function yA(A,B=PA(A.text,A.size)){const E=A.align||"left",s="center"===E?B/2:"right"===E?B:0,w=(A.angle||0)*Math.PI/180,Q=Math.cos(w),C=Math.sin(w);return{width:B,baselineX:A.x-Q*s,baselineY:A.y+C*s,cos:Q,sin:C}}function uA(A){const B=yA(A),E=-555*A.size/hA,s=SA*A.size/hA,w=[0,B.width].flatMap(A=>[E,s].map(E=>({x:B.baselineX+B.cos*A-B.sin*E,y:B.baselineY-B.sin*A-B.cos*E})));return{minX:Math.min(...w.map(A=>A.x)),minY:Math.min(...w.map(A=>A.y)),maxX:Math.max(...w.map(A=>A.x)),maxY:Math.max(...w.map(A=>A.y))}}function NA(A){const B=A.reduce((A,B)=>A+B.length,0),E=new Uint8Array(B);let s=0;for(const B of A)E.set(B,s),s+=B.length;return E}const KA=A=>vA.encode(A),dA=(A,B)=>NA([KA(`<< ${A} /Length ${B.length} >>\nstream\n`),B,KA("\nendstream")]);function JA(A){const B=function(A){const B=atob(A),E=new Uint8Array(B.length);for(let A=0;A"image"===A.kind&&null!=A.opacity&&A.opacity<1?[Math.max(0,Math.min(1,A.opacity))]:[]))].sort((A,B)=>A-B),s=new Map(E.map((A,B)=>[A,`GS${B+1}`])),w=function(A,B){const E=[],s=new Map,w=B=>A.height-B,Q=(A,...B)=>`${B.map(VA).join(" ")} ${A}`,C=A=>{for(const B of A)if(B.length){E.push(Q("m",B[0][0],w(B[0][1])));for(let A=1;A{let B=!1;for(const s of A)if(!(s.length<2)){B=!0,E.push(Q("m",s[0][0],w(s[0][1])));for(let A=1;A Tj`,"ET")}else{const A=(I.angle||0)*Math.PI/180,s=Math.cos(A),C=Math.sin(A),g=I.x+I.width/2,Y=w(I.y+I.height/2);E.push("q");const R=null==I.opacity?1:Math.max(0,Math.min(1,I.opacity)),M=B.get(R);M&&E.push(`/${M} gs`),E.push(Q("cm",s*I.width,C*I.width,C*I.height,-s*I.height,g-s*I.width/2-C*I.height/2,Y-C*I.width/2+s*I.height/2),`/Im${I.imageId} Do`,"Q")}return{stream:E.join("\n"),unicode:s}}(A,s),Q=Math.max(0,...Object.keys(HA).map(Number)),C=Array.from({length:Q+1},(A,B)=>Math.round(1e3*(HA[B]||1024)/hA)),g=[],I=A=>(g.push("string"==typeof A?KA(A):A),g.length),Y=I(""),R=I(""),M=I(""),F=I(dA(`/Length1 ${B.length}`,B)),i=I(`<< /Type /FontDescriptor /FontName /Roboto /Flags 32 /FontBBox [${jA.join(" ")}] /ItalicAngle 0 /Ascent 2146 /Descent -555 /CapHeight 2146 /StemV 80 /FontFile2 ${F} 0 R >>`),x=I(`<< /Type /Font /Subtype /CIDFontType2 /BaseFont /Roboto /CIDSystemInfo << /Registry (Adobe) /Ordering (Identity) /Supplement 0 >> /FontDescriptor ${i} 0 R /W [0 [${C.join(" ")}]] /CIDToGIDMap /Identity >>`),b=KA(function(A){const B=[...A].sort((A,B)=>A[0]-B[0]),E=B.map(([A,B])=>`<${A.toString(16).padStart(4,"0")}> <${B<=65535?B.toString(16).padStart(4,"0"):(()=>{const A=B-65536;return(55296+(A>>10)).toString(16).padStart(4,"0")+(56320+(1023&A)).toString(16).padStart(4,"0")})()}>`);return`/CIDInit /ProcSet findresource begin\n12 dict begin\nbegincmap\n/CIDSystemInfo << /Registry (Adobe) /Ordering (UCS) /Supplement 0 >> def\n/CMapName /HousePlanUnicode def\n/CMapType 2 def\n1 begincodespacerange\n<0000> \nendcodespacerange\n${B.length} beginbfchar\n${E.join("\n")}\nendbfchar\nendcmap\nCMapName currentdict /CMap defineresource pop\nend\nend`}(w.unicode)),L=I(dA("",b)),D=I(`<< /Type /Font /Subtype /Type0 /BaseFont /Roboto /Encoding /Identity-H /DescendantFonts [${x} 0 R] /ToUnicode ${L} 0 R >>`),G=I(dA("",KA(w.stream))),o=[];for(const B of A.images||[]){const A=I(dA(`/Type /XObject /Subtype /Image /Width ${B.width} /Height ${B.height} /ColorSpace /DeviceRGB /BitsPerComponent 8 /Filter /DCTDecode`,B.bytes));o.push(`/Im${B.id} ${A} 0 R`)}const t=A.now.toISOString().replace(/[-:T]/g,"").slice(0,14),c=I(`<< /CreationDate (D:${t}Z) /ModDate (D:${t}Z) >>`),W=`<< /Font << /F1 ${D} 0 R >>`+(o.length?` /XObject << ${o.join(" ")} >>`:"")+(E.length?` /ExtGState << ${E.map(A=>`/${s.get(A)} << /ca ${VA(A)} /CA ${VA(A)} >>`).join(" ")} >>`:"")+" >>";g[Y-1]=KA(`<< /Type /Catalog /Pages ${R} 0 R >>`),g[R-1]=KA(`<< /Type /Pages /Kids [${M} 0 R] /Count 1 >>`),g[M-1]=KA(`<< /Type /Page /Parent ${R} 0 R /MediaBox [0 0 ${VA(A.width)} ${VA(A.height)}] /Resources ${W} /Contents ${G} 0 R >>`);const m=KA("%PDF-1.4\n%âãÏÓ\n"),n=[m],e=[0];let h=m.length;g.forEach((A,B)=>{const E=KA(`${B+1} 0 obj\n`),s=KA("\nendobj\n");e.push(h),n.push(E,A,s),h+=E.length+A.length+s.length});const S=h,j=["xref",`0 ${g.length+1}`,"0000000000 65535 f "];for(let A=1;A<=g.length;A++)j.push(`${String(e[A]).padStart(10,"0")} 00000 n `);return j.push(`trailer\n<< /Size ${g.length+1} /Root ${Y} 0 R /Info ${c} 0 R >>`,`startxref\n${S}\n%%EOF\n`),n.push(KA(j.join("\n"))),NA(n)}const ZA=A=>[A.minX,A.minY,A.maxX,A.maxY].every(Number.isFinite)&&A.maxX>=A.minX&&A.maxY>=A.minY,TA=A=>A.maxX-A.minX,fA=A=>A.maxY-A.minY;function kA(A,B,E,s=0){Number.isFinite(B)&&Number.isFinite(E)&&(A.minX=Math.min(A.minX,B-s),A.minY=Math.min(A.minY,E-s),A.maxX=Math.max(A.maxX,B+s),A.maxY=Math.max(A.maxY,E+s))}function zA(A,B,E,s,w,Q){const C=Q*Math.PI/180,g=Math.cos(C),I=Math.sin(C),Y=B+s/2,R=E+w/2;for(const[B,E]of[[-s/2,-w/2],[s/2,-w/2],[s/2,w/2],[-s/2,w/2]])kA(A,Y+g*B-I*E,R+I*B+g*E)}function pA(A,B,E){for(const s of B)"M"===s.op||"L"===s.op?kA(A,s.x,s.y,E):"C"===s.op&&(kA(A,s.x1,s.y1,E),kA(A,s.x2,s.y2,E),kA(A,s.x,s.y,E))}function XA(A){const B={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};for(const E of A)if("path"===E.kind){const A=E.stroke?(E.width||.5)/2:0;for(const s of E.rings)for(const[E,w]of s)kA(B,E,w,A)}else if("line"===E.kind)for(const[A,s]of E.points)kA(B,A,s,E.width/2);else if("vector"===E.kind)pA(B,E.ops,E.width/2);else if("text"===E.kind){const A=uA(E);kA(B,A.minX,A.minY),kA(B,A.maxX,A.maxY)}else zA(B,E.x,E.y,E.width,E.height,E.angle||0);return B}function OA(A,B,E){return!!ZA(A)&&(TA(A)<=TA(B)+E&&fA(A)<=fA(B)+E)}function qA(A){return`${A.getFullYear()}-${String(A.getMonth()+1).padStart(2,"0")}-${String(A.getDate()).padStart(2,"0")}`}const $A=72/25.4,_A=5.25,AB=[.08,.08,.08],BB=[127/255,127/255,127/255],EB=[.72,.72,.72],sB=(A,B)=>A.minXB.minX&&A.minYB.minY;function wB(A,B,E,s,w=0,Q="left"){return uA({x:A,y:B,text:E,size:s,angle:w,align:Q})}function QB(A,B,E,s,w){const Q=Math.min(...[[A.minX,A.minY],[A.maxX,A.minY],[A.maxX,A.maxY],[A.minX,A.maxY]].map(([A,w])=>(A-B)*s[0]+(w-E)*s[1]));return Math.max(0,w-Q)}const CB=(A,B)=>`${A.axis}:${B[0]<-.5||B[1]<-.5?-1:1}`,gB=(A,B)=>{A.minX=Math.min(A.minX,B[0]),A.minY=Math.min(A.minY,B[1]),A.maxX=Math.max(A.maxX,B[0]),A.maxY=Math.max(A.maxY,B[1])},IB=A=>{const B={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};for(const E of A)for(const A of E)gB(B,A);return B};function YB(A,B,E,s,w=0){const Q=w*Math.PI/180,C=Math.cos(Q),g=Math.sin(Q),I=A+E/2,Y=B+s/2;return Array.from({length:48},(A,B)=>{const w=B/48*Math.PI*2,Q=Math.cos(w)*E/2,R=Math.sin(w)*s/2;return[I+C*Q-g*R,Y+g*Q+C*R]})}function RB(A,B,E,s,w=0){const Q=w*Math.PI/180,C=Math.cos(Q),g=Math.sin(Q),I=A+E/2,Y=B+s/2;return[[-E/2,-s/2],[E/2,-s/2],[E/2,s/2],[-E/2,s/2]].map(([A,B])=>[I+C*A-g*B,Y+g*A+C*B])}function MB(A,B,E){if("passage"===A.type)return[];const s=A.rlen/2,w=B>0?B/E*Y/2:2,Q=[];if("window"===A.type)Q.push([[-s,-w],[s,-w]],[[-s,w],[s,w]],[[-s,-w],[-s,w]],[[s,-w],[s,w]]);else if("gate"===A.type){const B=10*(A.flip_v?-1:1)*Math.PI/180,E=[[[-s,0],[-s+Math.cos(B)*s,Math.sin(B)*s]],[[s,0],[s-Math.cos(B)*s,Math.sin(-B)*s]]];Q.push(...E);for(const A of E){const B=A[1][0]-A[0][0],E=A[1][1]-A[0][1],s=Math.hypot(B,E)||1,C=-E/s,g=B/s,I=Math.min(.08*s,Math.max(1,.7*w));for(const s of[.3,.5,.7]){const w=A[0][0]+B*s,Y=A[0][1]+E*s;Q.push([[w-C*I,Y-g*I],[w+C*I,Y+g*I]])}}}else{const B=A.flip_v?1:-1,E=A.flip_h?s:-s,w=[E,B*A.rlen];Q.push([[E,0],w]);const C=[];for(let s=0;s<=16;s++){const w=B*s/16*Math.PI/2,Q=A.flip_h?-1:1;C.push([E+Q*Math.cos(w)*A.rlen,Math.sin(w)*A.rlen])}Q.push(C)}const C=A.angle*Math.PI/180,g=Math.cos(C),I=Math.sin(C);return Q.map(B=>B.map(([B,E])=>[A.rx+B*g-E*I,A.ry+B*I+E*g]))}function FB(A,B){const E=IB([A]);return B.filter(A=>{const B=IB([A]);return B.maxX>=E.minX&&B.minX<=E.maxX&&B.maxY>=E.minY&&B.minY<=E.maxY})}function iB(A){const B=function(A){const{rawSpace:B,space:E}=A,s=Number(B.cell_cm)>0?Number(B.cell_cm):5,w=Array.isArray(B.walls)?B.walls:[],Q=c(B,E,I,.02*Y),C=W(B,E,s,Y,I),g=m(C),M=n(E,s,Y,2e-4*Y,g).all,F=e(C,E,w,Q.contour,R,s,Y,I);return{cellCm:s,walls:w,zero:Q,openings:C,extras:M,geometry:A.sharedWallGeometry||h(E.rooms,w,Q.contour,F,R,s,Y,I,M)}}(A),E=new Map;if(A.options.dimensions)for(const s of A.space.rooms){const w=C(s);if(!w)continue;const Q=s.id?A.resolveInnerContour?.(s.id):void 0;E.set(s,s.id&&(void 0===Q?g(A.space.rooms,s.id,B.walls,B.zero.contour,R,B.cellCm,Y,I,B.geometry.roomGeom,B.geometry.multiWallNodes):Q)||w)}const s=new Map;if(A.options.dimensions)for(const w of A.space.rooms){const Q=C(w);if(!Q)continue;const g=E.get(w)||Q,I=w.id?A.resolveRoomArea?.(w.id,g):void 0,Y=Number.isFinite(I)?[]:FB(g,B.extras),R=Y.length?M(g,Y):null,i=Number.isFinite(I)&&I>=0?I:R?F(R):Math.abs(g.reduce((A,B,E)=>{const s=g[(E+1)%g.length];return A+B[0]*s[1]-s[0]*B[1]},0)/2);s.set(w,i)}const w=[..."failed-core"===B.geometry.status?A.space.rooms.map(A=>C(A)||[]).filter(A=>A.length):B.geometry.components.flatMap(A=>i(A.geom)),...B.zero.lines.map(A=>[[A[0],A[1]],[A[2],A[3]]])];A.options.decor&&w.push(...function(A){const B=[];for(const E of A.decor||[])"line"===E.kind?B.push([[E.x1*I,E.y1*I],[E.x2*I,E.y2*I]]):"text"!==E.kind?B.push(L(E).map(([A,B])=>[A*I,B*I])):B.push([[E.x*I,E.y*I]]);return B}(A.rawSpace));for(const B of A.rasters||[])w.push(RB(B.x,B.y,B.drawWidth,B.drawHeight,B.angle));let Q=IB(w);var x;[(x=Q).minX,x.minY,x.maxX,x.maxY].every(Number.isFinite)&&x.maxX>x.minX&&x.maxY>x.minY||(Q={minX:0,minY:0,maxX:I,maxY:I});return{built:B,dimensionContours:E,roomAreas:s,bounds:Q,cmPerUnit:B.cellCm/Y}}function xB(A,B,E,s){const{built:w,dimensionContours:Q,roomAreas:g,bounds:M,cmPerUnit:F}=B,c=(s?297:210)*$A,W=(s?210:297)*$A,m=12*$A,n=18*$A,e=24*$A,h=F*(10*$A)/E,j=(M.maxX-M.minX)*h,H=(M.maxY-M.minY)*h,v=m+n,V=W-v-m-e,U=c-2*m,a=A=>[0+(A[0]-M.minX)*h,0+(A[1]-M.minY)*h],P=(A,B)=>[M.minX+(A-0)/h,M.minY+(B-0)/h],y=A=>{const B=P(A.minX,A.minY),E=P(A.maxX,A.maxY);return{minX:B[0],minY:B[1],maxX:E[0],maxY:E[1]}},u=w.geometry.components.flatMap(A=>i(A.geom)),N=A=>w.geometry.components.some(B=>S([...A],B.geom)),K=A=>function(A,B,E){if(!LA(A)||!mA(B))return!0;const s=DA(A);return!!s.some(E)||!!B.some(B=>B.some(B=>xA(B)&&bA(B,A)))||nA(B,(A,B)=>s.some((E,w)=>null!==WA(A,B,E,s[(w+1)%s.length])))}(y(function(A,B){const E=Number.isFinite(B)&&B>=0?B:0;return{minX:A.minX-E,minY:A.minY-E,maxX:A.maxX+E,maxY:A.maxY+E}}(A,$A-1e-6)),u,N),d=(A,B)=>function(A,B,E){if(!LA(A)||!mA([B]))return!1;const s=DA(A);return!!s.every(E)&&!nA([B],(A,B)=>s.some((E,w)=>null!==WA(A,B,E,s[(w+1)%s.length])))}(y(A),B,A=>Z([...A],B)),J=(A,B,E={})=>function(A,B,E,s,w={}){if(!xA(A)||!xA(B)||!mA(E))return!0;if(w.allowStartExit){const w=tA(A,B);if(w<=iA)return!0;const Q=nA(E,(B,E)=>cA(A,B,E));if(!Q)return!0;const C=[];nA(E,(E,s)=>{const w=WA(A,B,E,s);return w&&C.push(w),!1});const g=iA/w,I=[0,1,...C.flatMap(A=>[A.t,A.endT])].sort((A,B)=>A-B).filter((A,B,E)=>0===B||A-E[B-1]>g),Y=E=>[A[0]+(B[0]-A[0])*E,A[1]+(B[1]-A[1])*E],R=A=>C.some(B=>B.overlap&&A>B.t+g&&AA.t>M+g||A.endT>M+g)}const Q=[(A[0]+B[0])/2,(A[1]+B[1])/2],C=nA(E,(B,E)=>cA(A,B,E));return!((!s(A)||w.allowStartBoundary&&C)&&!s(Q)&&!s(B))||nA(E,(E,s)=>{const Q=WA(A,B,E,s);return!!Q&&(Q.overlap||!w.allowStartBoundary||!C||Q.t*tA(A,B)>iA)})}(P(A[0],A[1]),P(B[0],B[1]),u,N,E),T=(A,B,E)=>{const s=A.x*I,w=A.y*I,Q=A.w*I,C=A.h*I,g=s+Q/2,Y=w+C/2,R=s+(A.flip_h?Q:0),F=w+(A.flip_v?C:0),i=(A.flip_h?-1:1)*Q/B,x=(A.flip_v?-1:1)*C/E,b=(Number(A.angle)||0)*Math.PI/180,L=Math.cos(b),D=Math.sin(b),G=Y+D*(R-g)+L*(F-Y);return{a:h*L*i,b:h*D*i,c:-h*D*x,d:h*L*x,e:0+(g+L*(R-g)-D*(F-Y)-M.minX)*h,f:0+(G-M.minY)*h}};let f=[];const z=[],O=function(A,B){const E=3*$A*Math.SQRT2,s=[];for(let w=-B;w<=A+E;w+=E)s.push([[w,0],[w+B,B]]);return s}(c,W);for(const B of A.rasters||[])f.push({kind:"image",imageId:B.id,...a([B.x,B.y]).reduce((A,B,E)=>({...A,[E?"y":"x"]:B}),{}),width:B.drawWidth*h,height:B.drawHeight*h,angle:B.angle,opacity:B.opacity});for(const A of w.geometry.components)f.push({kind:"path",rings:i(A.geom).map(A=>A.map(a)),fill:BB,stroke:AB,width:.25*$A,hatch:{lines:O,stroke:AB,width:.18*$A}});if("failed-core"===w.geometry.status)for(const B of A.space.rooms){const A=C(B);A&&f.push({kind:"path",rings:[A.map(a)],stroke:AB,width:.25*$A})}for(const A of w.zero.lines)f.push({kind:"line",points:[a([A[0],A[1]]),a([A[2],A[3]])],stroke:AB,width:.35*$A,dash:[3*$A,2*$A]});const q=w.geometry.openingIndex;for(const B of w.openings){const E=B.partitionHost?{cm:B.partitionHost.partition.cm}:q?x(A.space.rooms,B,w.walls,R,w.cellCm,Y,I,w.zero.contour):{cm:0};for(const A of MB(B,E.cm,w.cellCm))f.push({kind:"line",points:A.map(a),stroke:AB,width:.3*$A})}if(A.options.decor)for(const B of A.rawSpace.decor||[])if("image"!==B.kind)if("line"===B.kind)f.push({kind:"line",points:[a([B.x1*I,B.y1*I]),a([B.x2*I,B.y2*I])],stroke:AB,width:Math.max(.2*$A,10*Number(B.width_cm||1)*$A/E),dash:"dashed"===B.line_style?[3*$A,2*$A]:void 0});else if("text"===B.kind)f.push({kind:"text",...(()=>{const[A,E]=a([B.x*I,B.y*I]);return{x:A,y:E}})(),text:B.text,size:Math.max(6,10*Number(B.size_cm||20)*$A/E),angle:Number(B.angle)||0});else if("furniture"===B.kind){const A=r[B.symbol];A?f.push({kind:"vector",ops:YA(A.d,T(B,A.viewW,A.viewH)),stroke:AB,width:Math.max(.2*$A,10*b(B,w.cellCm,Y)*$A/E)}):f.push({kind:"path",rings:[L(B).map(([A,B])=>a([A*I,B*I]))],stroke:AB,width:.25*$A})}else{const A="ellipse"===B.kind?YB(B.x*I,B.y*I,B.w*I,B.h*I,Number(B.angle)||0):L(B).map(([A,B])=>[A*I,B*I]);f.push({kind:"path",rings:[A.map(a)],stroke:AB,width:.25*$A})}if(A.options.dimensions&&w.geometry.roomGeom)for(const[B,E]of D(w.geometry.roomGeom).entries()){const s=l(F),w=(A,B,E)=>{const s=a(A.sourceA),w=a(A.sourceB),Q=a(A.a),C=a(A.b),g=(6+E)*$A,I=[Q[0]+B[0]*g,Q[1]+B[1]*g],Y=[C[0]+B[0]*g,C[1]+B[1]*g],R=[(I[0]+Y[0])/2,(I[1]+Y[1])/2],M=PA(A.text,7)+2*$A>Math.hypot(Y[0]-I[0],Y[1]-I[1]),F=QB(wB(R[0],R[1],A.text,7,A.angle,"center"),R[0],R[1],B,$A),i=[R[0]+B[0]*F,R[1]+B[1]*F];return{edge:A,a:s,b:w,oa:I,ob:Y,middle:R,label:i,box:wB(i[0],i[1],A.text,7,A.angle,"center"),needsShelf:M}},Q=A=>{const B=[{start:A.oa,end:A.ob},{start:A.a,end:A.oa,allowStartExit:!0},{start:A.b,end:A.ob,allowStartExit:!0}];return A.needsShelf&&B.push({start:A.middle,end:A.label,mayEnterOwnLabel:!0}),B},C=A=>K(A.box)||Q(A).some(A=>J(A.start,A.end,{allowStartBoundary:A.allowStartBoundary,allowStartExit:A.allowStartExit})),g=EA(k(E,F,A.imperial,{ringIndex:B,epsilon:s}),{ring:E,epsilon:s,score:A=>{const B=[-A.inwardNormal[0],-A.inwardNormal[1]],E=a(A.mid),s=Array.from({length:21},(A,B)=>4*B).find(E=>!C(w(A,B,E))),Q=E[0]+(U-j)/2,g=E[1]+(V-H)/2;return{hardCollisions:void 0===s?21:s/4,normalClearance:Math.abs(B[0])>.5?B[0]>0?U-Q:Q:B[1]>0?V-g:g}}});for(const A of X(g,s)){const B=A.map(A=>({edge:A,outward:[-A.inwardNormal[0],-A.inwardNormal[1]]})),E=A=>B.map(({edge:B,outward:E})=>w(B,E,A));let s=null;for(let A=0;A<=80&&!s;A+=4){const B=E(A),w=B.some((A,E)=>B.slice(0,E).some(B=>sB(A.box,B.box))),g=B.some(A=>C(A)||z.some(B=>sB(A.box,B))),I=B.some((A,E)=>Q(A).some(A=>z.some(B=>eA(A.start,A.end,B))||B.some((B,s)=>(!A.mayEnterOwnLabel||s!==E)&&eA(A.start,A.end,B.box))));w||g||I||(s=B)}if(s)for(const A of s)f.push({kind:"line",points:[A.oa,A.ob],stroke:AB,width:.2*$A},{kind:"line",points:[A.a,A.oa],stroke:AB,width:.15*$A},{kind:"line",points:[A.b,A.ob],stroke:AB,width:.15*$A}),A.needsShelf&&f.push({kind:"line",points:[A.middle,A.label],stroke:AB,width:.15*$A}),f.push({kind:"text",x:A.label[0],y:A.label[1],text:A.edge.text,size:_A,angle:A.edge.angle,align:"center"}),z.push(A.box)}}const $=[...A.space.rooms].sort((A,B)=>String(A.id||"").localeCompare(String(B.id||"")));for(const[B,E]of $.entries()){const s=C(E);if(!s)continue;const w=Q.get(E)||s,I=g.get(E)||0,Y=G(E,A.space.id,A.layout,A.config),[R,M]=a([Y.x,Y.y]),i=w.map(a),x=IB([i]);let b=!1;if(A.options.roomNames&&E.name){const A=Math.max(0,x.maxX-x.minX-4*$A),B=PA(E.name,6.75)<=A?6.75:PA(E.name,5.25)<=A?5.25:0;B&&(f.push({kind:"text",x:R,y:M-2,text:E.name,size:B,align:"center"}),z.push(wB(R,M-2,E.name,B,0,"center")),b=!0)}if(A.options.dimensions){const B=o(I*F*F/1e4,A.imperial),E=M+(b?8:0);f.push({kind:"text",x:R,y:E,text:B,size:6,align:"center"}),z.push(wB(R,E,B,8,0,"center"))}if(A.options.dimensions){const E=l(F),s=EA(p(w,F,A.imperial,{ringIndex:B,epsilon:E}),{ring:w,epsilon:E,score:A=>{const B=a(A.mid),E=QB(wB(B[0],B[1],A.text,_A,A.angle,"center"),B[0],B[1],A.inwardNormal,$A),s=wB(B[0]+A.inwardNormal[0]*E,B[1]+A.inwardNormal[1]*E,A.text,7,A.angle,"center"),w="horizontal"===A.axis?A.inwardNormal[1]>0?x.maxY-B[1]:B[1]-x.minY:A.inwardNormal[0]>0?x.maxX-B[0]:B[0]-x.minX;return{hardCollisions:Number(K(s))+z.reduce((A,B)=>A+Number(sB(s,B)),0),normalClearance:w}}});for(const A of s.filter(A=>A.short)){const B=A.inwardNormal,E=a(A.a),s=a(A.b),w=(E[0]+s[0])/2,Q=(E[1]+s[1])/2;f.push({kind:"line",points:[[w-1.5*B[0]*$A,Q-1.5*B[1]*$A],[w+1.5*B[0]*$A,Q+1.5*B[1]*$A]],stroke:AB,width:.2*$A})}const Q=new Map;for(const A of s.filter(A=>!A.short)){const B=CB(A,A.inwardNormal),E=Q.get(B)||[];E.push(A),Q.set(B,E)}for(const A of Q.values()){let B=null;for(let E=0;E<=30&&!B;E+=3){const s=A.map(A=>{const B=a(A.mid),s=QB(wB(B[0],B[1],A.text,_A,A.angle,"center"),B[0],B[1],A.inwardNormal,(1+E)*$A),w=B[0]+A.inwardNormal[0]*s,Q=B[1]+A.inwardNormal[1]*s;return{edge:A,x:w,y:Q,box:wB(w,Q,A.text,_A,A.angle,"center")}}),Q=s.some((A,B)=>s.slice(0,B).some(B=>sB(A.box,B.box))),C=s.some(A=>K(A.box)||z.some(B=>sB(A.box,B))),g=s.every(A=>d(A.box,w));Q||C||!g||(B=s)}if(B)for(const A of B)f.push({kind:"text",x:A.x,y:A.y,text:A.edge.text,size:_A,angle:A.edge.angle,align:"center"}),z.push(A.box)}}}const _={minX:m,minY:v,maxX:c-m,maxY:v+V},AA=XA(f),BA=OA(AA,{minX:0,minY:0,maxX:U,maxY:V},.5*$A),sA=function(A,B){const E=XA(A);if(!ZA(E))return{commands:[...A],bounds:E,dx:0,dy:0};const s=(B.minX+B.maxX-E.minX-E.maxX)/2,w=(B.minY+B.maxY-E.minY-E.maxY)/2,Q=function(A,B,E){return A.map(A=>"path"===A.kind?{...A,rings:A.rings.map(A=>A.map(([A,s])=>[A+B,s+E]))}:"line"===A.kind?{...A,points:A.points.map(([A,s])=>[A+B,s+E])}:"vector"===A.kind?{...A,ops:A.ops.map(A=>((A,B,E)=>"M"===A.op||"L"===A.op?{...A,x:A.x+B,y:A.y+E}:"C"===A.op?{...A,x1:A.x1+B,y1:A.y1+E,x2:A.x2+B,y2:A.y2+E,x:A.x+B,y:A.y+E}:A)(A,B,E))}:{...A,x:A.x+B,y:A.y+E})}(A,s,w);return{commands:Q,bounds:{minX:E.minX+s,minY:E.minY+w,maxX:E.maxX+s,maxY:E.maxY+w},dx:s,dy:w}}(f,_);f=sA.commands,f.push({kind:"text",x:m,y:m+10,text:A.space.title,size:14}),A.cardTitle&&f.push({kind:"text",x:c-m,y:m+10,text:A.cardTitle,size:10,align:"right"});const wA=W-m-13*$A;f.push({kind:"line",points:[[m,wA-4*$A],[c-m,wA-4*$A]],stroke:EB,width:.2*$A}),f.push({kind:"text",x:m,y:wA,text:A.t("pdf.scale",{n:E}),size:8});const QA=10*(A.imperial?152.4:100)*$A/E,CA=wA+8;f.push({kind:"line",points:[[m,CA],[m+QA,CA]],stroke:AB,width:.4*$A});for(let A=0;A<=4;A++){const B=m+QA*A/4;f.push({kind:"line",points:[[B,CA-2],[B,CA+2]],stroke:AB,width:.25*$A})}f.push({kind:"text",x:m+QA/2,y:wA+17,text:A.imperial?"5 ft":"1 m",size:7,align:"center"});const gA=t(A.config.settings,A.rawSpace.settings||{});if(null!==gA){const B=c/2,E=wA+5.5*$A;f.push({kind:"vector",ops:FA({centerX:B,centerY:E,size:11*$A,northDeg:gA}),fill:AB,width:0,fillRule:"evenodd"}),f.push({kind:"text",x:B,y:wA,text:A.t("pdf.north"),size:7,align:"center"})}f.push({kind:"text",x:c-m,y:wA+12,text:`${qA(A.now)} · House Plan v${A.version}`,size:7,align:"right"});const IA={width:c,height:W,commands:f,images:(A.rasters||[]).map(({id:A,bytes:B,width:E,height:s})=>({id:A,bytes:B,width:E,height:s})),now:A.now,scale:E,sceneBounds:sA.bounds,planField:_},RA=Math.max(0,TA(AA))*Math.max(0,fA(AA)),MA=U*V;return{page:IA,sceneBounds:sA.bounds,field:_,fits:BA,fillRatio:MA>0?RA/MA:0,landscape:s}}function bB(A,B){return A.fillRatio!==B.fillRatio?A.fillRatio>B.fillRatio?A:B:A.landscape?B:A}function LB(A,B,E){const s=12*$A,w=(E?297:210)*$A-2*s,Q=(E?210:297)*$A-2*s-18*$A-24*$A,C=A.cmPerUnit*(10*$A)/B;return(A.bounds.maxX-A.bounds.minX)*C<=w+.5*$A&&(A.bounds.maxY-A.bounds.minY)*C<=Q+.5*$A}function DB(A){let B=0;for(const E of A)if(B+=Math.max(0,Number(E)||0),B>26214400)throw new Error("pdf.too_large")}const GB="ed91b3971428d2b8e7bfceb8025d2be4c0db7c58754eeb4ba03f835b8d7c84c6";async function oB(A,B){if(!A)throw new Error("pdf.asset_failed");const E=await fetch(A,{credentials:"same-origin"});if(!E.ok)throw new Error("pdf.asset_failed");const s=await E.blob();let w;try{w=await createImageBitmap(s)}catch{throw new Error("pdf.asset_failed")}try{if("image/jpeg"===s.type)return{id:B,bytes:new Uint8Array(await s.arrayBuffer()),width:w.width,height:w.height};const A=document.createElement("canvas");A.width=w.width,A.height=w.height;const E=A.getContext("2d");if(!E)throw new Error("pdf.asset_failed");E.fillStyle="#fff",E.fillRect(0,0,A.width,A.height),E.drawImage(w,0,0);const Q=await new Promise(B=>A.toBlob(B,"image/jpeg",.85));if(!Q)throw new Error("pdf.asset_failed");return{id:B,bytes:new Uint8Array(await Q.arrayBuffer()),width:w.width,height:w.height}}finally{w.close()}}async function tB(A,B,E){const s=await async function(A,B){const E=[];if(B.backdrop&&A.space.bg){const B=await oB(A.backdropUrl,"backdrop");E.push({...B,x:A.space.bg.x,y:A.space.bg.y,drawWidth:A.space.bg.w,drawHeight:A.space.bg.h,angle:A.space.bg.angle,opacity:.6})}if(B.decor){let B=0;for(const s of A.rawSpace.decor||[]){if("image"!==s.kind)continue;const w=A.decorAssets.get(s.asset_id),Q=j(s,I,I);if(!w||!Q)throw new Error("pdf.asset_failed");const C=await oB(w.url,"decor"+B++);E.push({...C,x:Q[0],y:Q[1],drawWidth:Q[2],drawHeight:Q[3],opacity:Q[4],angle:Number(s.angle)||0})}}return DB(E.map(A=>A.bytes.byteLength)),E}(A,B),w=JA(function(A){const B=iB(A);let E=[];for(const s of wA){const w=[!1,!0].filter(A=>LB(B,s,A)).map(E=>xB(A,B,s,E));if(!w.length)continue;const Q=w.filter(A=>A.fits);if(Q.length)return Q.reduce(bB).page;E=w}E.length||(E=[!1,!0].map(E=>xB(A,B,500,E)));const s=E.filter(A=>A.fits);if(s.length)return s.reduce(bB).page;const w=Math.min(...E.map(A=>Math.max(TA(A.sceneBounds)/TA(A.field),fA(A.sceneBounds)/fA(A.field)))),Q=50,C=1e6,g=Number.isFinite(w)?Math.ceil(Math.min(C,500*Math.max(1,w))/Q)*Q:C;let I=500,Y=0,R=[],M=Math.max(550,g);for(;M<=C;){const E=[!1,!0].map(E=>xB(A,B,M,E)).filter(A=>A.fits);if(E.length){Y=M,R=E;break}if(I=M,M===C)break;M=Math.min(C,Math.ceil(2*M/Q)*Q)}if(!Y)throw new Error("pdf.failed");let F=Math.floor(I/Q),i=Math.floor(Y/Q);for(;i-F>1;){const E=Math.floor((F+i)/2),s=[!1,!0].map(s=>xB(A,B,E*Q,s)).filter(A=>A.fits);s.length?(i=E,R=s):F=E}const x=R.reduce(bB).page;if(!OA(x.sceneBounds,x.planField,.5*$A))throw new Error("pdf.failed");return x}({...A,options:B,now:E,rasters:s,t:A.t})),Q=new Blob([w],{type:"application/pdf"}),C=URL.createObjectURL(Q);try{const B=document.createElement("a");B.href=C,B.download=`houseplan-${g=A.space.title,g.normalize("NFKD").replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-|-$/g,"").toLowerCase()||"space"}-${qA(E)}.pdf`,B.style.display="none",document.body.append(B),B.click(),B.remove()}finally{setTimeout(()=>URL.revokeObjectURL(C),0)}var g;return w}class cB{assertRasterBudget(A){DB(A)}render(A){let B;return B={...A,save:async E=>{await tB(A,E,B.now||new Date)}},s``}}export{GB as PDF_EXPORT_FINGERPRINT,cB as PdfExportRuntime,tB as exportSpacePdf}; + `}}v.properties={context:{attribute:!1}},v.styles=A`:host{display:contents;}.body{display:grid;gap:12px;width:100%;max-width:100%;min-width:0;padding:16px 20px;box-sizing:border-box;}label{display:flex;min-width:0;min-height:44px;align-items:center;gap:12px;cursor:pointer;}label span{min-width:0;overflow-wrap:anywhere;}input{width:20px;height:20px;flex:none;accent-color:var(--hp-accent,#d89300);}.row{display:flex;align-items:center;gap:8px;width:100%;max-width:100%;min-width:0;padding:12px 16px;box-sizing:border-box;}.spacer{flex:1;}button{min-width:0;min-height:44px;max-width:100%;display:inline-flex;align-items:center;justify-content:center;border:1px solid var(--hp-line,rgb(127 127 127/.3));border-radius:12px;padding:0 18px;box-sizing:border-box;overflow-wrap:anywhere;white-space:normal;background:transparent;color:inherit;font:inherit;cursor:pointer;}button.primary{background:var(--hp-accent,#d89300);color:var(--hp-on-accent,#111);border-color:transparent;}button:disabled{opacity:.55;cursor:default;}ha-icon{flex:none;margin-right:6px;}@media (max-width:360px){.row{display:grid;grid-template-columns:minmax(0,1fr);}.spacer{display:none;}button{width:100%;}}`,customElements.get("hp-pdf-dialog")||customElements.define("hp-pdf-dialog",v);const V=(A,B,E)=>Math.hypot(A[0]-B[0],A[1]-B[1])<=E,U=A=>Number.isFinite(A)&&A>=0?A:0;function l(A){const B=Number(A);return Number.isFinite(B)&&B>0?.1/B:0}const a=(A,B)=>[...new Set([...A,...B])].sort((A,B)=>A-B),P=(A,B)=>{const E=A.points.length;if(E<=1||!V(A.points[E-1],A.points[0],B))return!1;const s=E-2;return A.edgeSources[s]=a(A.edgeSources[s],A.edgeSources[E-1]),A.points.splice(E-1,1),A.edgeSources.splice(E-1,1),!0},y=(A,B)=>{for(let E=0;E+1{let E=!1;for(;A.points.length>1;)if(P(A,B))E=!0;else{if(!y(A,B))break;E=!0}return E},N=(A,B,E)=>{const s=B[0]-A[0],w=B[1]-A[1],C=E[0]-B[0],g=E[1]-B[1],I=Math.hypot(s,w),Y=Math.hypot(C,g);if(!(I>0&&Y>0))return!1;const R=s*C+w*g;if(!(R>0))return!1;const M=s*g-w*C;return Math.abs(M)<=R*Q},K=A=>{const B=A.points.length;if(B<3)return!1;for(let E=0;E{const E=U(B),s=[],w=[];for(let B=0;B[A])};for(;Q.points.length>1;){const A=u(Q,E);if(Q.points.length<3)break;if(!K(Q)&&!A)break}return u(Q,E),Q};function J(A,B){const E=Number(A[0]),s=Number(A[1]),w=Number(B[0]),C=Number(B[1]);if(![E,s,w,C].every(Number.isFinite))return null;const g=w-E,I=C-s,Y=Math.abs(g),R=Math.abs(I),M=Math.max(Y,R),F=Math.min(Y,R);if(!(M>0)||F/M>Q)return null;const i=[(E+w)/2,(s+C)/2];if(Y>=R){return{axis:"horizontal",a:[E,i[1]],b:[w,i[1]],mid:i,projectedLength:Y,tangentInterval:[Math.min(E,w),Math.max(E,w)],normalCoordinate:i[1]}}return{axis:"vertical",a:[i[0],s],b:[i[0],C],mid:i,projectedLength:R,tangentInterval:[Math.min(s,C),Math.max(s,C)],normalCoordinate:i[0]}}function Z(A,B){const E=B.map(A=>[Number(A[0]),Number(A[1])]);if(!E.every(A=>A.every(Number.isFinite)))return!1;if(E.length<3||((A,B)=>{const E=1e-12*Math.max(1,Math.abs(A[0]),Math.abs(A[1]),...B.flatMap(A=>[Math.abs(A[0]),Math.abs(A[1])]));for(let s=0;s0))continue;const Y=(A[0]-w[0])*g-(A[1]-w[1])*C;if(Math.abs(Y)>E*I)continue;const R=(A[0]-w[0])*C+(A[1]-w[1])*g;if(R>=-E&&R<=I*I+E)return!0}return!1})(A,E))return!1;let s=!1;for(let B=0,w=E.length-1;BA[1]==C[1]>A[1])continue;const g=(C[0]-Q[0])*(A[1]-Q[1])/(C[1]-Q[1])+Q[0];A[0]Object.is(A,-0)?0:A,I=[g(-Q/C),g(w/C)],Y=[g(-I[0]),g(-I[1])],R=[(B[0]+E[0])/2,(B[1]+E[1])/2],M=Math.max(1,C,Math.abs(R[0]),Math.abs(R[1])),F=Math.max(1e-9*M,.01*U(s));for(const B of[F,4*F,16*F]){const E=Z([R[0]+I[0]*B,R[1]+I[1]*B],A);if(E!==Z([R[0]+Y[0]*B,R[1]+Y[1]*B],A))return E?I:Y}return sA(A)>=0?I:Y}function f(A,B){let E=180*Math.atan2(B[1]-A[1],B[0]-A[0])/Math.PI;return E>90&&(E-=180),E<=-90&&(E+=180),E}function k(A,B,E,s={}){const w=Number(B);if(!(w>0&&Number.isFinite(w)))return[];const Q=void 0===s.epsilon?l(w):U(s.epsilon);return z(d(A,Q),w,E,{...s,epsilon:Q})}const z=(A,B,E,s)=>{if(A.points.length<3)return[];const Q=U(s.epsilon??l(B)),C=Number.isFinite(Number(s.ringIndex))?Number(s.ringIndex):0,g=[];for(let s=0;sQ))continue;const M=[...A.edgeSources[s]||[s]].sort((A,B)=>A-B),F=M[0]??s,i=T(A.points,R.a,R.b,Q),x=("horizontal"===R.axis?i[1]:i[0])<0?-1:1,b=[R.axis,O(R.tangentInterval[0]),String(x),O(C),O(F)].join("|"),L=R.projectedLength*B;g.push({sourceA:[...I],sourceB:[...Y],a:R.a,b:R.b,text:w(L,E),short:L<30,angle:f(R.a,R.b),mid:R.mid,axis:R.axis,projectedLength:R.projectedLength,tangentInterval:R.tangentInterval,normalCoordinate:R.normalCoordinate,inwardNormal:i,normalSign:x,source:{ringIndex:C,edgeIndex:F},sourceEdgeIndices:M,stableKey:b})}return g};function p(A,B,E,s={}){const w=Number(B);if(!(w>0&&Number.isFinite(w)))return[];const Q=void 0===s.epsilon?l(w):U(s.epsilon);let C=d(A,Q);if(sA(C.points)<0&&(C=(A=>{const B=A.points.length;return{points:[...A.points].reverse().map(A=>[...A]),edgeSources:A.points.map((E,s)=>[...A.edgeSources[(B-2-s+B)%B]])}})(C)),C.points.length){let A=0;for(let B=1;B({points:[...A.points.slice(B),...A.points.slice(0,B)],edgeSources:[...A.edgeSources.slice(B),...A.edgeSources.slice(0,B)]}))(C,A)}return z(C,w,E,{...s,epsilon:Q})}function X(A,B){const E=U(B),s=[];for(const B of A){const A=s.find(A=>A.axis===B.axis&&A.normalSign===B.normalSign&&Math.abs(A.normalCoordinate-B.normalCoordinate)<=E);A?A.edges.push(B):s.push({axis:B.axis,normalSign:B.normalSign,normalCoordinate:B.normalCoordinate,edges:[B]})}return s.map(A=>A.edges)}const O=A=>Object.is(A,-0)?"0":String(A),q=A=>"horizontal"===A?0:1;function $(A,B){return q(A.axis)-q(B.axis)||A.tangentInterval[0]-B.tangentInterval[0]||A.normalSign-B.normalSign||A.source.ringIndex-B.source.ringIndex||A.source.edgeIndex-B.source.edgeIndex}function _(A,B,E,s){const w=U(s);if(A.axis!==B.axis)return!1;if(A.source.ringIndex!==B.source.ringIndex)return!1;if(A.inwardNormal[0]*B.inwardNormal[0]+A.inwardNormal[1]*B.inwardNormal[1]>=-.5)return!1;if(!((A,B,E)=>Math.abs(A[0]-B[0])<=E&&Math.abs(A[1]-B[1])<=E)(A.tangentInterval,B.tangentInterval,w))return!1;if(Math.abs(A.projectedLength-B.projectedLength)>w)return!1;return Z([(A.mid[0]+B.mid[0])/2,(A.mid[1]+B.mid[1])/2],E)}const AA=(A,B)=>{const E=B?.(A);return{hardCollisions:Number.isFinite(Number(E?.hardCollisions))?Number(E?.hardCollisions):0,normalClearance:Number.isFinite(Number(E?.normalClearance))?Number(E?.normalClearance):0}},BA=(A,B,E)=>{const s=AA(A,E),w=AA(B,E);return s.hardCollisions-w.hardCollisions||w.normalClearance-s.normalClearance||$(A,B)};function EA(A,B){if(A.length<2)return[...A];const E=U(B.epsilon),s=function(A,B=1e-7){return d(A,B).points.map(A=>[...A])}(B.ring,E),w=[];for(let B=0;B{const E=A.separation-B.separation;if(E)return E;const s=$(A.left,A.right)<=0?A.left:A.right,w=s===A.left?A.right:A.left,Q=$(B.left,B.right)<=0?B.left:B.right,C=Q===B.left?B.right:B.left;return $(s,Q)||$(w,C)});const Q=new Set,C=new Set;for(const A of w){if(Q.has(A.left)||Q.has(A.right))continue;Q.add(A.left),Q.add(A.right);const E=BA(A.left,A.right,B.score)<=0?A.left:A.right;C.add(E===A.left?A.right:A.left)}return A.filter(A=>!C.has(A))}function sA(A){let B=0;for(let E=0;E1){const A=Math.sqrt(G);Y*=A,R*=A}const o=Math.max(0,Y*Y*R*R-Y*Y*D*D-R*R*L*L),t=Y*Y*D*D+R*R*L*L||1,c=(Q===C?-1:1)*Math.sqrt(o/t),W=c*Y*D/R,m=c*-R*L/Y,n=F*W-i*m+(A+g)/2,e=i*W+F*m+(B+I)/2;let h=gA(1,0,(L-W)/Y,(D-m)/R),S=gA((L-W)/Y,(D-m)/R,(-L-W)/Y,(-D-m)/R);!C&&S>0&&(S-=2*Math.PI),C&&S<0&&(S+=2*Math.PI);const j=Math.max(1,Math.ceil(Math.abs(S)/(Math.PI/2))),r=S/j,H=A=>[n+F*Y*Math.cos(A)-i*R*Math.sin(A),e+i*Y*Math.cos(A)+F*R*Math.sin(A)],v=A=>[-F*Y*Math.sin(A)-i*R*Math.cos(A),-i*Y*Math.sin(A)+F*R*Math.cos(A)],V=[];for(let A=0;A[B.a*A+B.c*E+B.e,B.b*A+B.d*E+B.f];return function(A){const B=A.match(/[AaCcHhLlMmQqSsTtVvZz]|[-+]?(?:\d*\.\d+|\d+\.?)(?:e[-+]?\d+)?/gi)||[],E=[];let s=0,w="",Q=0,C=0,g=0,I=0,Y=null,R=null;const M=()=>Number(B[s++]);for(;sB.length||QA.test(B[s]))throw new Error(`Invalid SVG path command ${w}`);const x=Array.from({length:i},M),b=A=>A+(F?Q:0),L=A=>A+(F?C:0);if("M"===A||"L"===A)Q=b(x[0]),C=L(x[1]),E.push({op:"M"===A?"M":"L",x:Q,y:C}),"M"===A&&(g=Q,I=C,w=F?"l":"L"),Y=R=null;else if("H"===A)Q=b(x[0]),E.push({op:"L",x:Q,y:C}),Y=R=null;else if("V"===A)C=L(x[0]),E.push({op:"L",x:Q,y:C}),Y=R=null;else if("C"===A){const A=b(x[0]),B=L(x[1]),s=b(x[2]),w=L(x[3]);Q=b(x[4]),C=L(x[5]),Y=[s,w],R=null,E.push({op:"C",x1:A,y1:B,x2:s,y2:w,x:Q,y:C})}else if("S"===A){const A=Y?2*Q-Y[0]:Q,B=Y?2*C-Y[1]:C,s=b(x[0]),w=L(x[1]);Q=b(x[2]),C=L(x[3]),Y=[s,w],R=null,E.push({op:"C",x1:A,y1:B,x2:s,y2:w,x:Q,y:C})}else if("Q"===A||"T"===A){const B="Q"===A?b(x[0]):R?2*Q-R[0]:Q,s="Q"===A?L(x[1]):R?2*C-R[1]:C,w=b("Q"===A?x[2]:x[0]),g=L("Q"===A?x[3]:x[1]);E.push({op:"C",x1:Q+2/3*(B-Q),y1:C+2/3*(s-C),x2:w+2/3*(B-w),y2:g+2/3*(s-g),x:w,y:g}),Q=w,C=g,R=[B,s],Y=null}else if("A"===A){const A=b(x[5]),B=L(x[6]),s=IA(Q,C,x[0],x[1],x[2],x[3],x[4],A,B);s.length?E.push(...s):E.push({op:"L",x:A,y:B}),Q=A,C=B,Y=R=null}}return E}(A).map(A=>{if("Z"===A.op)return A;if("M"===A.op||"L"===A.op){const[B,s]=E(A.x,A.y);return{op:A.op,x:B,y:s}}if("C"!==A.op)throw new Error("Unsupported PDF vector operation");const[B,s]=E(A.x1,A.y1),[w,Q]=E(A.x2,A.y2),[C,g]=E(A.x,A.y);return{op:"C",x1:B,y1:s,x2:w,y2:Q,x:C,y:g}})}const RA=["M20.82,15.31h0L10.46,9c-.46-.26-1.11.37-.86.84l6.15,10.56,10.56,6.15a.66.66,0,0,0,.84-.86Zm-4,4,3-3,4.55,7.44Z","M18,2A16,16,0,1,0,34,18,16,16,0,0,0,18,2Zm1,29.95V29.53H17v2.42A14,14,0,0,1,4.05,19H6.47V17H4.05A14,14,0,0,1,17,4.05V6.47h2V4.05A14,14,0,0,1,31.95,17H29.53v2h2.42A14,14,0,0,1,19,31.95Z"],MA=A=>Math.abs(A)<1e-12?0:Math.abs(A-1)<1e-12?1:Math.abs(A+1)<1e-12?-1:A;function FA(A){const B=function(A){const{centerX:B,centerY:E,size:s,northDeg:w}=A;if(![B,E,s,w].every(Number.isFinite)||s<=0)throw new RangeError("PDF compass placement must contain finite coordinates and a positive size");const Q=((w%360+360)%360+45)*Math.PI/180,C=s/36,g=MA(Math.cos(Q)),I=MA(Math.sin(Q)),Y=C*g,R=C*I,M=-C*I,F=C*g;return{a:Y,b:R,c:M,d:F,e:B-18*Y-18*M,f:E-18*R-18*F}}(A);return RA.flatMap(A=>YA(A,B))}const iA=1e-8,xA=A=>A.length>=2&&Number.isFinite(A[0])&&Number.isFinite(A[1]),bA=(A,B)=>A[0]>=B.minX-iA&&A[0]<=B.maxX+iA&&A[1]>=B.minY-iA&&A[1]<=B.maxY+iA,LA=A=>[A.minX,A.minY,A.maxX,A.maxY].every(Number.isFinite)&&A.maxX>=A.minX&&A.maxY>=A.minY,DA=A=>[[A.minX,A.minY],[A.maxX,A.minY],[A.maxX,A.maxY],[A.minX,A.maxY]];const GA=(A,B,E)=>(B[0]-A[0])*(E[1]-A[1])-(B[1]-A[1])*(E[0]-A[0]),oA=(A,B,E)=>{const s=E[0]-B[0],w=E[1]-B[1],Q=Math.abs(s)>=Math.abs(w)?s:w;return Math.abs(Q)<=iA?0:(Math.abs(s)>=Math.abs(w)?A[0]-B[0]:A[1]-B[1])/Q},tA=(A,B)=>Math.hypot(B[0]-A[0],B[1]-A[1]);function cA(A,B,E){const s=tA(B,E);if(s<=iA)return tA(A,B)<=iA;if(Math.abs(GA(B,E,A))/s>iA)return!1;const w=oA(A,B,E),Q=iA/s;return w>=-Q&&w<=1+Q}function WA(A,B,E,s){const w=B[0]-A[0],Q=B[1]-A[1],C=s[0]-E[0],g=s[1]-E[1],I=Math.hypot(w,Q),Y=Math.hypot(C,g);if(I<=iA)return cA(A,E,s)?{t:0,endT:0,overlap:!1}:null;if(Y<=iA){if(!cA(E,A,B))return null;const s=Math.max(0,Math.min(1,oA(E,A,B)));return{t:s,endT:s,overlap:!1}}const R=w*g-Q*C,M=E[0]-A[0],F=E[1]-A[1],i=iA*I*Y;if(Math.abs(R)<=i){if(Math.abs(GA(A,B,E))/I>iA||Math.abs(GA(A,B,s))/I>iA)return null;const w=oA(E,A,B),Q=oA(s,A,B),C=Math.max(0,Math.min(w,Q)),g=Math.min(1,Math.max(w,Q));return giA}}const x=(M*g-F*C)/R,b=(M*Q-F*w)/R,L=iA/I,D=iA/Y;if(x<-L||x>1+L||b<-D||b>1+D)return null;const G=Math.max(0,Math.min(1,x));return{t:G,endT:G,overlap:!1}}const mA=A=>A.every(A=>A.length>=2&&A.every(xA));function nA(A,B){for(const E of A){const A=E;for(let E=0;Enull!==WA(A,B,E,s[(w+1)%s.length]))}const hA=2048,SA=2146,jA=[-1825,-555,4188,2163],rA={32:1,33:2,34:3,35:4,36:5,37:6,38:7,39:8,40:9,41:10,42:11,43:12,44:13,45:14,46:15,47:16,48:17,49:18,50:19,51:20,52:21,53:22,54:23,55:24,56:25,57:26,58:27,59:28,60:29,61:30,62:31,63:32,64:33,65:34,66:35,67:36,68:37,69:38,70:39,71:40,72:41,73:42,74:43,75:44,76:45,77:46,78:47,79:48,80:49,81:50,82:51,83:52,84:53,85:54,86:55,87:56,88:57,89:58,90:59,91:60,92:61,93:62,94:63,95:64,96:65,97:66,98:67,99:68,100:69,101:70,102:71,103:72,104:73,105:74,106:75,107:76,108:77,109:78,110:79,111:80,112:81,113:82,114:83,115:84,116:85,117:86,118:87,119:88,120:89,121:90,122:91,123:92,124:93,125:94,126:95,160:596,161:96,162:97,163:98,164:99,165:100,166:101,167:102,168:103,169:104,170:105,171:106,172:107,173:597,174:108,175:109,176:110,177:111,178:112,179:113,180:114,181:115,182:116,183:117,184:118,185:119,186:120,187:121,188:122,189:123,190:124,191:125,192:603,193:604,194:605,195:606,196:607,197:608,198:126,199:609,200:610,201:611,202:612,203:613,204:614,205:615,206:616,207:617,208:599,209:618,210:619,211:620,212:621,213:622,214:623,215:127,216:128,217:624,218:625,219:626,220:627,221:628,222:129,223:130,224:629,225:630,226:631,227:632,228:633,229:634,230:131,231:635,232:636,233:637,234:638,235:639,236:640,237:641,238:642,239:643,240:132,241:644,242:645,243:646,244:647,245:648,246:649,247:133,248:134,249:650,250:651,251:652,252:653,253:654,254:135,255:655,256:656,257:657,258:658,259:659,260:660,261:661,262:662,263:663,264:664,265:665,266:666,267:667,268:668,269:669,270:670,271:671,272:598,273:136,274:672,275:673,276:674,277:675,278:676,279:677,280:678,281:679,282:680,283:681,284:682,285:683,286:684,287:685,288:686,289:687,290:688,291:689,292:690,293:691,294:137,295:600,296:692,297:693,298:694,299:695,300:696,301:697,302:698,303:699,304:700,305:138,306:701,307:702,308:703,309:704,310:705,311:706,312:139,313:707,314:708,315:709,316:710,317:711,318:712,319:713,320:714,321:140,322:141,323:715,324:716,325:717,326:718,327:719,328:720,329:721,330:142,331:143,332:722,333:723,334:724,335:725,336:726,337:727,338:144,339:145,340:728,341:729,342:730,343:731,344:732,345:733,346:734,347:735,348:736,349:737,350:738,351:739,352:742,353:743,354:744,355:745,356:746,357:747,358:601,359:602,360:748,361:749,362:750,363:751,364:752,365:753,366:754,367:755,368:756,369:757,370:758,371:759,372:760,373:761,374:762,375:763,376:764,377:765,378:766,379:767,380:768,381:769,382:770,383:146,1024:897,1025:856,1026:165,1027:857,1028:166,1029:858,1030:859,1031:860,1032:861,1033:167,1034:168,1035:169,1036:863,1037:898,1038:864,1039:170,1040:865,1041:171,1042:866,1043:867,1044:172,1045:868,1046:173,1047:174,1048:175,1049:869,1050:862,1051:176,1052:870,1053:871,1054:872,1055:873,1056:874,1057:875,1058:876,1059:177,1060:178,1061:877,1062:179,1063:180,1064:181,1065:182,1066:183,1067:184,1068:185,1069:186,1070:187,1071:188,1072:878,1073:189,1074:190,1075:191,1076:192,1077:879,1078:193,1079:194,1080:195,1081:880,1082:196,1083:197,1084:198,1085:199,1086:881,1087:200,1088:882,1089:883,1090:201,1091:884,1092:202,1093:885,1094:203,1095:204,1096:205,1097:206,1098:207,1099:208,1100:209,1101:210,1102:211,1103:212,1104:899,1105:886,1106:213,1107:887,1108:214,1109:888,1110:889,1111:890,1112:891,1113:215,1114:216,1115:217,1116:892,1117:900,1118:893,1119:218,1120:219,1121:220,1122:965,1123:221,1124:222,1125:223,1126:224,1127:225,1128:226,1129:227,1130:228,1131:229,1132:230,1133:231,1134:232,1135:233,1136:901,1137:902,1138:234,1139:235,1140:236,1141:237,1142:903,1143:904,1144:906,1145:905,1146:238,1147:239,1148:240,1149:241,1150:242,1151:243,1152:244,1153:245,1154:246,1155:247,1156:248,1157:249,1158:250,1159:251,1160:252,1161:253,1162:254,1163:255,1164:964,1165:256,1166:257,1167:258,1168:259,1169:260,1170:966,1171:967,1172:261,1173:262,1174:263,1175:264,1176:907,1177:908,1178:265,1179:266,1180:267,1181:268,1182:968,1183:969,1184:269,1185:270,1186:271,1187:272,1188:273,1189:274,1190:275,1191:276,1192:277,1193:278,1194:909,1195:910,1196:955,1197:956,1198:911,1199:912,1200:970,1201:971,1202:279,1203:280,1204:281,1205:282,1206:283,1207:284,1208:285,1209:286,1210:287,1211:963,1212:288,1213:289,1214:961,1215:962,1216:913,1217:914,1218:915,1219:290,1220:291,1221:292,1222:293,1223:294,1224:295,1225:296,1226:297,1227:957,1228:958,1229:298,1230:299,1231:916,1232:917,1233:918,1234:919,1235:920,1236:921,1237:922,1238:923,1239:924,1240:300,1241:926,1242:925,1243:927,1244:928,1245:929,1246:930,1247:931,1248:301,1249:302,1250:932,1251:933,1252:934,1253:935,1254:936,1255:937,1256:938,1257:939,1258:940,1259:941,1260:942,1261:943,1262:944,1263:945,1264:946,1265:947,1266:948,1267:949,1268:950,1269:951,1270:959,1271:960,1272:952,1273:953,1274:303,1275:304,1276:305,1277:306,1278:972,1279:973,1280:307,1281:954,1282:308,1283:309,1284:310,1285:311,1286:312,1287:313,1288:314,1289:315,1290:316,1291:317,1292:318,1293:319,1294:320,1295:321,1296:322,1297:974,1298:323,1299:324,1300:325,1301:326,1302:327,1303:328,1304:329,1305:330,1306:982,1307:983,1308:984,1309:985,1310:331,1311:332,1312:333,1313:334,1314:335,1315:336,1316:337,1317:338,1318:339,1319:340,1320:341,1321:342,1322:343,1323:344,1324:345,1325:346,1326:347,1327:348,8192:349,8193:350,8194:351,8195:352,8196:353,8197:354,8198:355,8199:356,8200:357,8201:358,8202:360,8203:361,8204:362,8205:363,8206:364,8207:365,8208:366,8209:367,8210:368,8211:369,8212:370,8213:975,8214:371,8215:372,8216:373,8217:374,8218:375,8219:376,8220:377,8221:378,8222:379,8223:380,8224:381,8225:382,8226:383,8227:384,8228:385,8229:386,8230:387,8231:388,8239:986,8240:389,8241:390,8242:894,8243:895,8244:391,8245:392,8246:393,8247:394,8248:395,8249:396,8250:397,8251:398,8252:896,8253:399,8254:400,8255:401,8256:402,8257:403,8258:404,8259:405,8260:406,8261:407,8262:408,8263:987,8264:988,8265:989,8266:409,8267:410,8268:411,8269:412,8270:413,8271:414,8272:415,8273:416,8274:417,8275:418,8276:419,8277:420,8278:421,8279:422,8280:423,8281:424,8282:425,8283:426,8284:427,8285:428,8286:429,8287:990,8364:430,8381:431,8776:433},HA={1:507,2:527,3:655,4:1261,5:1150,6:1500,7:1273,8:357,9:700,10:712,11:882,12:1161,13:402,14:565,15:539,16:844,17:1150,18:1150,19:1150,20:1150,21:1150,22:1150,23:1150,24:1150,25:1150,26:1150,27:496,28:433,29:1041,30:1124,31:1070,32:967,33:1839,34:1336,35:1275,36:1333,37:1343,38:1164,39:1132,40:1395,41:1460,42:557,43:1130,44:1284,45:1102,46:1788,47:1460,48:1408,49:1292,50:1408,51:1261,52:1215,53:1222,54:1328,55:1303,56:1817,57:1284,58:1230,59:1226,60:543,61:840,62:543,63:856,64:924,65:633,66:1114,67:1149,68:1072,69:1155,70:1085,71:711,72:1149,73:1128,74:497,75:489,76:1038,77:497,78:1795,79:1130,80:1168,81:1149,82:1164,83:693,84:1056,85:669,86:1129,87:992,88:1539,89:1015,90:969,91:1015,92:693,93:499,94:693,95:1393,96:499,97:1120,98:1190,99:1460,100:1075,101:491,102:1256,103:856,104:1609,105:915,106:961,107:1134,108:1610,109:938,110:765,111:1094,112:751,113:751,114:642,115:1160,116:1001,117:534,118:507,119:751,120:931,121:960,122:1500,123:1589,124:1593,125:969,126:1914,127:1092,128:1408,129:1210,130:1218,131:1729,132:1200,133:1169,134:1160,135:1180,136:1223,137:1434,138:506,139:1139,140:1103,141:553,142:1419,143:1160,144:1953,145:1860,146:508,165:1535,166:1380,167:2193,168:2212,169:1666,170:1460,171:1291,172:1540,173:1859,174:1215,175:1460,176:1449,177:1287,178:1580,179:1497,180:1402,181:1927,182:1984,183:1554,184:1771,185:1285,186:1380,187:1831,188:1304,189:1132,190:1170,191:859,192:1236,193:1568,194:1040,195:1182,196:1106,197:1184,198:1519,199:1181,200:1182,201:984,202:1485,203:1213,204:1113,205:1656,206:1694,207:1271,208:1590,209:1112,210:1101,211:1671,212:1124,213:1128,214:1101,215:1737,216:1764,217:1161,218:1182,219:1800,220:1579,221:1110,222:1835,223:1528,224:1234,225:1094,226:1803,227:1547,228:1745,229:1505,230:2308,231:2001,232:1059,233:987,234:1393,235:1163,236:1290,237:1027,238:1393,239:1160,240:1793,241:1572,242:1800,243:1579,244:1330,245:1095,246:1277,247:1024,248:1024,249:1024,250:1024,251:1024,252:1024,253:1024,254:1545,255:1261,256:1110,257:1307,258:1161,259:1123,260:912,261:1243,262:1029,263:1954,264:1633,265:1434,266:1208,267:1289,268:1150,269:1676,270:1411,271:1535,272:1241,273:1999,274:1460,275:2097,276:1780,277:1518,278:1235,279:1304,280:1066,281:1836,282:1372,283:1468,284:1174,285:1391,286:1130,287:1391,288:1583,289:1213,290:1289,291:1114,292:1534,293:1263,294:1458,295:1160,296:1554,297:1260,298:1871,299:1598,300:1415,301:1192,302:1192,303:1207,304:939,305:1326,306:1088,307:1270,308:1684,309:1764,310:1622,311:1323,312:1097,313:1031,314:1985,315:1653,316:2043,317:1697,318:1270,319:1053,320:1453,321:1312,322:1380,323:1538,324:1266,325:1920,326:1549,327:1857,328:1547,329:1926,330:1774,331:1316,332:1106,333:2274,334:1832,335:2300,336:1829,337:1526,338:1242,339:1468,340:1208,341:1539,342:1273,343:2710,344:2238,345:1568,346:1240,347:1515,348:1243,349:1044,350:2089,351:1044,352:2089,353:697,354:522,355:348,356:1151,357:560,358:418,360:209,361:1024,362:1024,363:1024,364:1024,365:1024,366:564,367:564,368:1171,369:1344,370:1599,371:778,372:933,373:409,374:409,375:407,376:409,377:724,378:731,379:705,380:764,381:1129,382:1167,383:690,384:1100,385:511,386:964,387:1370,388:382,389:1962,390:2360,391:1045,392:463,393:757,394:1045,395:803,396:614,397:614,398:1241,399:919,400:952,401:1540,402:1540,403:874,404:1370,405:870,406:931,407:640,408:641,409:907,410:1001,411:1237,412:1237,413:985,414:511,415:1541,416:985,417:931,418:1366,419:1540,420:1172,421:932,422:1333,423:1215,424:1125,425:379,426:1071,427:1162,428:379,429:379,430:1150,431:1359,433:1154,596:507,597:565,598:1373,599:1373,600:1158,601:1222,602:669,603:1336,604:1336,605:1336,606:1336,607:1336,608:1336,609:1333,610:1164,611:1164,612:1164,613:1164,614:557,615:557,616:557,617:557,618:1460,619:1408,620:1408,621:1408,622:1408,623:1408,624:1328,625:1328,626:1328,627:1328,628:1230,629:1114,630:1114,631:1114,632:1114,633:1114,634:1114,635:1072,636:1085,637:1085,638:1085,639:1085,640:506,641:506,642:506,643:506,644:1130,645:1168,646:1168,647:1168,648:1168,649:1168,650:1129,651:1129,652:1129,653:1129,654:969,655:969,656:1336,657:1114,658:1336,659:1114,660:1336,661:1114,662:1333,663:1072,664:1333,665:1072,666:1333,667:1072,668:1333,669:1072,670:1343,671:1305,672:1164,673:1085,674:1164,675:1085,676:1164,677:1085,678:1164,679:1085,680:1164,681:1085,682:1395,683:1149,684:1395,685:1149,686:1395,687:1149,688:1395,689:1149,690:1460,691:1128,692:557,693:506,694:557,695:506,696:557,697:506,698:557,699:497,700:557,701:1687,702:986,703:1130,704:515,705:1284,706:1038,707:1102,708:497,709:1102,710:497,711:1102,712:647,713:1102,714:717,715:1460,716:1130,717:1460,718:1130,719:1460,720:1130,721:1130,722:1408,723:1168,724:1408,725:1168,726:1408,727:1168,728:1261,729:693,730:1261,731:693,732:1261,733:693,734:1215,735:1056,736:1215,737:1056,738:1215,739:1056,742:1215,743:1056,744:1222,745:669,746:1222,747:709,748:1328,749:1129,750:1328,751:1129,752:1328,753:1129,754:1328,755:1129,756:1328,757:1129,758:1328,759:1129,760:1817,761:1539,762:1230,763:969,764:1230,765:1226,766:1015,767:1226,768:1015,769:1226,770:1015,856:1164,857:1139,858:1215,859:557,860:557,861:1130,862:1316,863:1284,864:1287,865:1336,866:1275,867:1139,868:1164,869:1460,870:1788,871:1460,872:1408,873:1461,874:1292,875:1333,876:1222,877:1284,878:1114,879:1085,880:1182,881:1168,882:1149,883:1072,884:969,885:1015,886:1085,887:859,888:1056,889:497,890:506,891:489,892:1106,893:969,894:357,895:655,896:1054,897:1164,898:1460,899:1085,900:1182,901:1417,902:1434,903:1290,904:1027,905:2137,906:2377,907:1215,908:1040,909:1333,910:1072,911:1230,912:1026,913:557,914:1859,915:1568,916:557,917:1336,918:1114,919:1336,920:1114,921:1914,922:1729,923:1164,924:1085,925:1415,926:1079,927:1079,928:1859,929:1568,930:1215,931:1040,932:1460,933:1182,934:1460,935:1182,936:1408,937:1168,938:1393,939:1163,940:1393,941:1163,942:1380,943:1101,944:1287,945:969,946:1287,947:969,948:1287,949:969,950:1402,951:1113,952:1771,953:1590,954:1155,955:1222,956:984,957:1402,958:1113,959:1139,960:859,961:1583,962:1213,963:1128,964:1285,965:1285,966:1139,967:859,968:1336,969:1063,970:1230,971:1026,972:1284,973:1015,974:1104,975:1599,982:1408,983:1164,984:1817,985:1539,986:507,987:1934,988:1494,989:1494,990:507},vA=new TextEncoder,VA=A=>{const B=Math.round(100*A)/100;return Number.isInteger(B)?String(B):B.toFixed(2).replace(/0+$/,"")},UA=A=>{const B=Math.round(1e6*A)/1e6;return Number.isInteger(B)?String(B):B.toFixed(6).replace(/0+$/,"")},lA=A=>A.map(UA).join(" ");function aA(A){let B="",E=0;const s=new Map;for(const w of A){const A=w.codePointAt(0)||0,Q=rA[A]||rA[63];B+=Q.toString(16).padStart(4,"0"),E+=HA[Q]||1024,s.has(Q)||s.set(Q,A||63)}return{hex:B,width:E,unicode:s}}function PA(A,B){return aA(A).width*B/hA}function yA(A,B=PA(A.text,A.size)){const E=A.align||"left",s="center"===E?B/2:"right"===E?B:0,w=(A.angle||0)*Math.PI/180,Q=Math.cos(w),C=Math.sin(w);return{width:B,baselineX:A.x-Q*s,baselineY:A.y+C*s,cos:Q,sin:C}}function uA(A){const B=yA(A),E=-555*A.size/hA,s=SA*A.size/hA,w=[0,B.width].flatMap(A=>[E,s].map(E=>({x:B.baselineX+B.cos*A-B.sin*E,y:B.baselineY-B.sin*A-B.cos*E})));return{minX:Math.min(...w.map(A=>A.x)),minY:Math.min(...w.map(A=>A.y)),maxX:Math.max(...w.map(A=>A.x)),maxY:Math.max(...w.map(A=>A.y))}}function NA(A){const B=A.reduce((A,B)=>A+B.length,0),E=new Uint8Array(B);let s=0;for(const B of A)E.set(B,s),s+=B.length;return E}const KA=A=>vA.encode(A),dA=(A,B)=>NA([KA(`<< ${A} /Length ${B.length} >>\nstream\n`),B,KA("\nendstream")]);function JA(A){const B=function(A){const B=atob(A),E=new Uint8Array(B.length);for(let A=0;A"image"===A.kind&&null!=A.opacity&&A.opacity<1?[Math.max(0,Math.min(1,A.opacity))]:[]))].sort((A,B)=>A-B),s=new Map(E.map((A,B)=>[A,`GS${B+1}`])),w=function(A,B){const E=[],s=new Map,w=B=>A.height-B,Q=(A,...B)=>`${B.map(VA).join(" ")} ${A}`,C=A=>{for(const B of A)if(B.length){E.push(Q("m",B[0][0],w(B[0][1])));for(let A=1;A{let B=!1;for(const s of A)if(!(s.length<2)){B=!0,E.push(Q("m",s[0][0],w(s[0][1])));for(let A=1;A Tj`,"ET")}else{const A=(I.angle||0)*Math.PI/180,s=Math.cos(A),C=Math.sin(A),g=I.x+I.width/2,Y=w(I.y+I.height/2);E.push("q");const R=null==I.opacity?1:Math.max(0,Math.min(1,I.opacity)),M=B.get(R);M&&E.push(`/${M} gs`),E.push(Q("cm",s*I.width,C*I.width,C*I.height,-s*I.height,g-s*I.width/2-C*I.height/2,Y-C*I.width/2+s*I.height/2),`/Im${I.imageId} Do`,"Q")}return{stream:E.join("\n"),unicode:s}}(A,s),Q=Math.max(0,...Object.keys(HA).map(Number)),C=Array.from({length:Q+1},(A,B)=>Math.round(1e3*(HA[B]||1024)/hA)),g=[],I=A=>(g.push("string"==typeof A?KA(A):A),g.length),Y=I(""),R=I(""),M=I(""),F=I(dA(`/Length1 ${B.length}`,B)),i=I(`<< /Type /FontDescriptor /FontName /Roboto /Flags 32 /FontBBox [${jA.join(" ")}] /ItalicAngle 0 /Ascent 2146 /Descent -555 /CapHeight 2146 /StemV 80 /FontFile2 ${F} 0 R >>`),x=I(`<< /Type /Font /Subtype /CIDFontType2 /BaseFont /Roboto /CIDSystemInfo << /Registry (Adobe) /Ordering (Identity) /Supplement 0 >> /FontDescriptor ${i} 0 R /W [0 [${C.join(" ")}]] /CIDToGIDMap /Identity >>`),b=KA(function(A){const B=[...A].sort((A,B)=>A[0]-B[0]),E=B.map(([A,B])=>`<${A.toString(16).padStart(4,"0")}> <${B<=65535?B.toString(16).padStart(4,"0"):(()=>{const A=B-65536;return(55296+(A>>10)).toString(16).padStart(4,"0")+(56320+(1023&A)).toString(16).padStart(4,"0")})()}>`);return`/CIDInit /ProcSet findresource begin\n12 dict begin\nbegincmap\n/CIDSystemInfo << /Registry (Adobe) /Ordering (UCS) /Supplement 0 >> def\n/CMapName /HousePlanUnicode def\n/CMapType 2 def\n1 begincodespacerange\n<0000> \nendcodespacerange\n${B.length} beginbfchar\n${E.join("\n")}\nendbfchar\nendcmap\nCMapName currentdict /CMap defineresource pop\nend\nend`}(w.unicode)),L=I(dA("",b)),D=I(`<< /Type /Font /Subtype /Type0 /BaseFont /Roboto /Encoding /Identity-H /DescendantFonts [${x} 0 R] /ToUnicode ${L} 0 R >>`),G=I(dA("",KA(w.stream))),o=[];for(const B of A.images||[]){const A=I(dA(`/Type /XObject /Subtype /Image /Width ${B.width} /Height ${B.height} /ColorSpace /DeviceRGB /BitsPerComponent 8 /Filter /DCTDecode`,B.bytes));o.push(`/Im${B.id} ${A} 0 R`)}const t=A.now.toISOString().replace(/[-:T]/g,"").slice(0,14),c=I(`<< /CreationDate (D:${t}Z) /ModDate (D:${t}Z) >>`),W=`<< /Font << /F1 ${D} 0 R >>`+(o.length?` /XObject << ${o.join(" ")} >>`:"")+(E.length?` /ExtGState << ${E.map(A=>`/${s.get(A)} << /ca ${VA(A)} /CA ${VA(A)} >>`).join(" ")} >>`:"")+" >>";g[Y-1]=KA(`<< /Type /Catalog /Pages ${R} 0 R >>`),g[R-1]=KA(`<< /Type /Pages /Kids [${M} 0 R] /Count 1 >>`),g[M-1]=KA(`<< /Type /Page /Parent ${R} 0 R /MediaBox [0 0 ${VA(A.width)} ${VA(A.height)}] /Resources ${W} /Contents ${G} 0 R >>`);const m=KA("%PDF-1.4\n%âãÏÓ\n"),n=[m],e=[0];let h=m.length;g.forEach((A,B)=>{const E=KA(`${B+1} 0 obj\n`),s=KA("\nendobj\n");e.push(h),n.push(E,A,s),h+=E.length+A.length+s.length});const S=h,j=["xref",`0 ${g.length+1}`,"0000000000 65535 f "];for(let A=1;A<=g.length;A++)j.push(`${String(e[A]).padStart(10,"0")} 00000 n `);return j.push(`trailer\n<< /Size ${g.length+1} /Root ${Y} 0 R /Info ${c} 0 R >>`,`startxref\n${S}\n%%EOF\n`),n.push(KA(j.join("\n"))),NA(n)}const ZA=A=>[A.minX,A.minY,A.maxX,A.maxY].every(Number.isFinite)&&A.maxX>=A.minX&&A.maxY>=A.minY,TA=A=>A.maxX-A.minX,fA=A=>A.maxY-A.minY;function kA(A,B,E,s=0){Number.isFinite(B)&&Number.isFinite(E)&&(A.minX=Math.min(A.minX,B-s),A.minY=Math.min(A.minY,E-s),A.maxX=Math.max(A.maxX,B+s),A.maxY=Math.max(A.maxY,E+s))}function zA(A,B,E,s,w,Q){const C=Q*Math.PI/180,g=Math.cos(C),I=Math.sin(C),Y=B+s/2,R=E+w/2;for(const[B,E]of[[-s/2,-w/2],[s/2,-w/2],[s/2,w/2],[-s/2,w/2]])kA(A,Y+g*B-I*E,R+I*B+g*E)}function pA(A,B,E){for(const s of B)"M"===s.op||"L"===s.op?kA(A,s.x,s.y,E):"C"===s.op&&(kA(A,s.x1,s.y1,E),kA(A,s.x2,s.y2,E),kA(A,s.x,s.y,E))}function XA(A){const B={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};for(const E of A)if("path"===E.kind){const A=E.stroke?(E.width||.5)/2:0;for(const s of E.rings)for(const[E,w]of s)kA(B,E,w,A)}else if("line"===E.kind)for(const[A,s]of E.points)kA(B,A,s,E.width/2);else if("vector"===E.kind)pA(B,E.ops,E.width/2);else if("text"===E.kind){const A=uA(E);kA(B,A.minX,A.minY),kA(B,A.maxX,A.maxY)}else zA(B,E.x,E.y,E.width,E.height,E.angle||0);return B}function OA(A,B,E){return!!ZA(A)&&(TA(A)<=TA(B)+E&&fA(A)<=fA(B)+E)}function qA(A){return`${A.getFullYear()}-${String(A.getMonth()+1).padStart(2,"0")}-${String(A.getDate()).padStart(2,"0")}`}const $A=72/25.4,_A=5.25,AB=[.08,.08,.08],BB=[127/255,127/255,127/255],EB=[.72,.72,.72],sB=(A,B)=>A.minXB.minX&&A.minYB.minY;function wB(A,B,E,s,w=0,Q="left"){return uA({x:A,y:B,text:E,size:s,angle:w,align:Q})}function QB(A,B,E,s,w){const Q=Math.min(...[[A.minX,A.minY],[A.maxX,A.minY],[A.maxX,A.maxY],[A.minX,A.maxY]].map(([A,w])=>(A-B)*s[0]+(w-E)*s[1]));return Math.max(0,w-Q)}const CB=(A,B)=>`${A.axis}:${B[0]<-.5||B[1]<-.5?-1:1}`,gB=(A,B)=>{A.minX=Math.min(A.minX,B[0]),A.minY=Math.min(A.minY,B[1]),A.maxX=Math.max(A.maxX,B[0]),A.maxY=Math.max(A.maxY,B[1])},IB=A=>{const B={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};for(const E of A)for(const A of E)gB(B,A);return B};function YB(A,B,E,s,w=0){const Q=w*Math.PI/180,C=Math.cos(Q),g=Math.sin(Q),I=A+E/2,Y=B+s/2;return Array.from({length:48},(A,B)=>{const w=B/48*Math.PI*2,Q=Math.cos(w)*E/2,R=Math.sin(w)*s/2;return[I+C*Q-g*R,Y+g*Q+C*R]})}function RB(A,B,E,s,w=0){const Q=w*Math.PI/180,C=Math.cos(Q),g=Math.sin(Q),I=A+E/2,Y=B+s/2;return[[-E/2,-s/2],[E/2,-s/2],[E/2,s/2],[-E/2,s/2]].map(([A,B])=>[I+C*A-g*B,Y+g*A+C*B])}function MB(A,B,E){if("passage"===A.type)return[];const s=A.rlen/2,w=B>0?B/E*Y/2:2,Q=[];if("window"===A.type)Q.push([[-s,-w],[s,-w]],[[-s,w],[s,w]],[[-s,-w],[-s,w]],[[s,-w],[s,w]]);else if("gate"===A.type){const B=10*(A.flip_v?-1:1)*Math.PI/180,E=[[[-s,0],[-s+Math.cos(B)*s,Math.sin(B)*s]],[[s,0],[s-Math.cos(B)*s,Math.sin(-B)*s]]];Q.push(...E);for(const A of E){const B=A[1][0]-A[0][0],E=A[1][1]-A[0][1],s=Math.hypot(B,E)||1,C=-E/s,g=B/s,I=Math.min(.08*s,Math.max(1,.7*w));for(const s of[.3,.5,.7]){const w=A[0][0]+B*s,Y=A[0][1]+E*s;Q.push([[w-C*I,Y-g*I],[w+C*I,Y+g*I]])}}}else{const B=A.flip_v?1:-1,E=A.flip_h?s:-s,w=[E,B*A.rlen];Q.push([[E,0],w]);const C=[];for(let s=0;s<=16;s++){const w=B*s/16*Math.PI/2,Q=A.flip_h?-1:1;C.push([E+Q*Math.cos(w)*A.rlen,Math.sin(w)*A.rlen])}Q.push(C)}const C=A.angle*Math.PI/180,g=Math.cos(C),I=Math.sin(C);return Q.map(B=>B.map(([B,E])=>[A.rx+B*g-E*I,A.ry+B*I+E*g]))}function FB(A,B){const E=IB([A]);return B.filter(A=>{const B=IB([A]);return B.maxX>=E.minX&&B.minX<=E.maxX&&B.maxY>=E.minY&&B.minY<=E.maxY})}function iB(A){const B=function(A){const{rawSpace:B,space:E}=A,s=Number(B.cell_cm)>0?Number(B.cell_cm):5,w=Array.isArray(B.walls)?B.walls:[],Q=c(B,E,I,.02*Y),C=W(B,E,s,Y,I),g=m(C),M=n(E,s,Y,2e-4*Y,g).all,F=e(C,E,w,Q.contour,R,s,Y,I);return{cellCm:s,walls:w,zero:Q,openings:C,extras:M,geometry:A.sharedWallGeometry||h(E.rooms,w,Q.contour,F,R,s,Y,I,M)}}(A),E=new Map;if(A.options.dimensions)for(const s of A.space.rooms){const w=C(s);if(!w)continue;const Q=s.id?A.resolveInnerContour?.(s.id):void 0;E.set(s,s.id&&(void 0===Q?g(A.space.rooms,s.id,B.walls,B.zero.contour,R,B.cellCm,Y,I,B.geometry.roomGeom,B.geometry.multiWallNodes):Q)||w)}const s=new Map;if(A.options.dimensions)for(const w of A.space.rooms){const Q=C(w);if(!Q)continue;const g=E.get(w)||Q,I=w.id?A.resolveRoomArea?.(w.id,g):void 0,Y=Number.isFinite(I)?[]:FB(g,B.extras),R=Y.length?M(g,Y):null,i=Number.isFinite(I)&&I>=0?I:R?F(R):Math.abs(g.reduce((A,B,E)=>{const s=g[(E+1)%g.length];return A+B[0]*s[1]-s[0]*B[1]},0)/2);s.set(w,i)}const w=[..."failed-core"===B.geometry.status?A.space.rooms.map(A=>C(A)||[]).filter(A=>A.length):B.geometry.components.flatMap(A=>i(A.geom)),...B.zero.lines.map(A=>[[A[0],A[1]],[A[2],A[3]]])];A.options.decor&&w.push(...function(A){const B=[];for(const E of A.decor||[])"line"===E.kind?B.push([[E.x1*I,E.y1*I],[E.x2*I,E.y2*I]]):"text"!==E.kind?B.push(L(E).map(([A,B])=>[A*I,B*I])):B.push([[E.x*I,E.y*I]]);return B}(A.rawSpace));for(const B of A.rasters||[])w.push(RB(B.x,B.y,B.drawWidth,B.drawHeight,B.angle));let Q=IB(w);var x;[(x=Q).minX,x.minY,x.maxX,x.maxY].every(Number.isFinite)&&x.maxX>x.minX&&x.maxY>x.minY||(Q={minX:0,minY:0,maxX:I,maxY:I});return{built:B,dimensionContours:E,roomAreas:s,bounds:Q,cmPerUnit:B.cellCm/Y}}function xB(A,B,E,s){const{built:w,dimensionContours:Q,roomAreas:g,bounds:M,cmPerUnit:F}=B,c=(s?297:210)*$A,W=(s?210:297)*$A,m=12*$A,n=18*$A,e=24*$A,h=F*(10*$A)/E,j=(M.maxX-M.minX)*h,H=(M.maxY-M.minY)*h,v=m+n,V=W-v-m-e,U=c-2*m,a=A=>[0+(A[0]-M.minX)*h,0+(A[1]-M.minY)*h],P=(A,B)=>[M.minX+(A-0)/h,M.minY+(B-0)/h],y=A=>{const B=P(A.minX,A.minY),E=P(A.maxX,A.maxY);return{minX:B[0],minY:B[1],maxX:E[0],maxY:E[1]}},u=w.geometry.components.flatMap(A=>i(A.geom)),N=A=>w.geometry.components.some(B=>S([...A],B.geom)),K=A=>function(A,B,E){if(!LA(A)||!mA(B))return!0;const s=DA(A);return!!s.some(E)||!!B.some(B=>B.some(B=>xA(B)&&bA(B,A)))||nA(B,(A,B)=>s.some((E,w)=>null!==WA(A,B,E,s[(w+1)%s.length])))}(y(function(A,B){const E=Number.isFinite(B)&&B>=0?B:0;return{minX:A.minX-E,minY:A.minY-E,maxX:A.maxX+E,maxY:A.maxY+E}}(A,$A-1e-6)),u,N),d=(A,B)=>function(A,B,E){if(!LA(A)||!mA([B]))return!1;const s=DA(A);return!!s.every(E)&&!nA([B],(A,B)=>s.some((E,w)=>null!==WA(A,B,E,s[(w+1)%s.length])))}(y(A),B,A=>Z([...A],B)),J=(A,B,E={})=>function(A,B,E,s,w={}){if(!xA(A)||!xA(B)||!mA(E))return!0;if(w.allowStartExit){const w=tA(A,B);if(w<=iA)return!0;const Q=nA(E,(B,E)=>cA(A,B,E));if(!Q)return!0;const C=[];nA(E,(E,s)=>{const w=WA(A,B,E,s);return w&&C.push(w),!1});const g=iA/w,I=[0,1,...C.flatMap(A=>[A.t,A.endT])].sort((A,B)=>A-B).filter((A,B,E)=>0===B||A-E[B-1]>g),Y=E=>[A[0]+(B[0]-A[0])*E,A[1]+(B[1]-A[1])*E],R=A=>C.some(B=>B.overlap&&A>B.t+g&&AA.t>M+g||A.endT>M+g)}const Q=[(A[0]+B[0])/2,(A[1]+B[1])/2],C=nA(E,(B,E)=>cA(A,B,E));return!((!s(A)||w.allowStartBoundary&&C)&&!s(Q)&&!s(B))||nA(E,(E,s)=>{const Q=WA(A,B,E,s);return!!Q&&(Q.overlap||!w.allowStartBoundary||!C||Q.t*tA(A,B)>iA)})}(P(A[0],A[1]),P(B[0],B[1]),u,N,E),T=(A,B,E)=>{const s=A.x*I,w=A.y*I,Q=A.w*I,C=A.h*I,g=s+Q/2,Y=w+C/2,R=s+(A.flip_h?Q:0),F=w+(A.flip_v?C:0),i=(A.flip_h?-1:1)*Q/B,x=(A.flip_v?-1:1)*C/E,b=(Number(A.angle)||0)*Math.PI/180,L=Math.cos(b),D=Math.sin(b),G=Y+D*(R-g)+L*(F-Y);return{a:h*L*i,b:h*D*i,c:-h*D*x,d:h*L*x,e:0+(g+L*(R-g)-D*(F-Y)-M.minX)*h,f:0+(G-M.minY)*h}};let f=[];const z=[],O=function(A,B){const E=3*$A*Math.SQRT2,s=[];for(let w=-B;w<=A+E;w+=E)s.push([[w,0],[w+B,B]]);return s}(c,W);for(const B of A.rasters||[])f.push({kind:"image",imageId:B.id,...a([B.x,B.y]).reduce((A,B,E)=>({...A,[E?"y":"x"]:B}),{}),width:B.drawWidth*h,height:B.drawHeight*h,angle:B.angle,opacity:B.opacity});for(const A of w.geometry.components)f.push({kind:"path",rings:i(A.geom).map(A=>A.map(a)),fill:BB,stroke:AB,width:.25*$A,hatch:{lines:O,stroke:AB,width:.18*$A}});if("failed-core"===w.geometry.status)for(const B of A.space.rooms){const A=C(B);A&&f.push({kind:"path",rings:[A.map(a)],stroke:AB,width:.25*$A})}for(const A of w.zero.lines)f.push({kind:"line",points:[a([A[0],A[1]]),a([A[2],A[3]])],stroke:AB,width:.35*$A,dash:[3*$A,2*$A]});const q=w.geometry.openingIndex;for(const B of w.openings){const E=B.partitionHost?{cm:B.partitionHost.partition.cm}:q?x(A.space.rooms,B,w.walls,R,w.cellCm,Y,I,w.zero.contour):{cm:0};for(const A of MB(B,E.cm,w.cellCm))f.push({kind:"line",points:A.map(a),stroke:AB,width:.3*$A})}if(A.options.decor)for(const B of A.rawSpace.decor||[])if("image"!==B.kind)if("line"===B.kind)f.push({kind:"line",points:[a([B.x1*I,B.y1*I]),a([B.x2*I,B.y2*I])],stroke:AB,width:Math.max(.2*$A,10*Number(B.width_cm||1)*$A/E),dash:"dashed"===B.line_style?[3*$A,2*$A]:void 0});else if("text"===B.kind)f.push({kind:"text",...(()=>{const[A,E]=a([B.x*I,B.y*I]);return{x:A,y:E}})(),text:B.text,size:Math.max(6,10*Number(B.size_cm||20)*$A/E),angle:Number(B.angle)||0});else if("furniture"===B.kind){const A=r[B.symbol];A?f.push({kind:"vector",ops:YA(A.d,T(B,A.viewW,A.viewH)),stroke:AB,width:Math.max(.2*$A,10*b(B,w.cellCm,Y)*$A/E)}):f.push({kind:"path",rings:[L(B).map(([A,B])=>a([A*I,B*I]))],stroke:AB,width:.25*$A})}else{const A="ellipse"===B.kind?YB(B.x*I,B.y*I,B.w*I,B.h*I,Number(B.angle)||0):L(B).map(([A,B])=>[A*I,B*I]);f.push({kind:"path",rings:[A.map(a)],stroke:AB,width:.25*$A})}if(A.options.dimensions&&w.geometry.roomGeom)for(const[B,E]of D(w.geometry.roomGeom).entries()){const s=l(F),w=(A,B,E)=>{const s=a(A.sourceA),w=a(A.sourceB),Q=a(A.a),C=a(A.b),g=(6+E)*$A,I=[Q[0]+B[0]*g,Q[1]+B[1]*g],Y=[C[0]+B[0]*g,C[1]+B[1]*g],R=[(I[0]+Y[0])/2,(I[1]+Y[1])/2],M=PA(A.text,7)+2*$A>Math.hypot(Y[0]-I[0],Y[1]-I[1]),F=QB(wB(R[0],R[1],A.text,7,A.angle,"center"),R[0],R[1],B,$A),i=[R[0]+B[0]*F,R[1]+B[1]*F];return{edge:A,a:s,b:w,oa:I,ob:Y,middle:R,label:i,box:wB(i[0],i[1],A.text,7,A.angle,"center"),needsShelf:M}},Q=A=>{const B=[{start:A.oa,end:A.ob},{start:A.a,end:A.oa,allowStartExit:!0},{start:A.b,end:A.ob,allowStartExit:!0}];return A.needsShelf&&B.push({start:A.middle,end:A.label,mayEnterOwnLabel:!0}),B},C=A=>K(A.box)||Q(A).some(A=>J(A.start,A.end,{allowStartBoundary:A.allowStartBoundary,allowStartExit:A.allowStartExit})),g=EA(k(E,F,A.imperial,{ringIndex:B,epsilon:s}),{ring:E,epsilon:s,score:A=>{const B=[-A.inwardNormal[0],-A.inwardNormal[1]],E=a(A.mid),s=Array.from({length:21},(A,B)=>4*B).find(E=>!C(w(A,B,E))),Q=E[0]+(U-j)/2,g=E[1]+(V-H)/2;return{hardCollisions:void 0===s?21:s/4,normalClearance:Math.abs(B[0])>.5?B[0]>0?U-Q:Q:B[1]>0?V-g:g}}});for(const A of X(g,s)){const B=A.map(A=>({edge:A,outward:[-A.inwardNormal[0],-A.inwardNormal[1]]})),E=A=>B.map(({edge:B,outward:E})=>w(B,E,A));let s=null;for(let A=0;A<=80&&!s;A+=4){const B=E(A),w=B.some((A,E)=>B.slice(0,E).some(B=>sB(A.box,B.box))),g=B.some(A=>C(A)||z.some(B=>sB(A.box,B))),I=B.some((A,E)=>Q(A).some(A=>z.some(B=>eA(A.start,A.end,B))||B.some((B,s)=>(!A.mayEnterOwnLabel||s!==E)&&eA(A.start,A.end,B.box))));w||g||I||(s=B)}if(s)for(const A of s)f.push({kind:"line",points:[A.oa,A.ob],stroke:AB,width:.2*$A},{kind:"line",points:[A.a,A.oa],stroke:AB,width:.15*$A},{kind:"line",points:[A.b,A.ob],stroke:AB,width:.15*$A}),A.needsShelf&&f.push({kind:"line",points:[A.middle,A.label],stroke:AB,width:.15*$A}),f.push({kind:"text",x:A.label[0],y:A.label[1],text:A.edge.text,size:_A,angle:A.edge.angle,align:"center"}),z.push(A.box)}}const $=[...A.space.rooms].sort((A,B)=>String(A.id||"").localeCompare(String(B.id||"")));for(const[B,E]of $.entries()){const s=C(E);if(!s)continue;const w=Q.get(E)||s,I=g.get(E)||0,Y=G(E,A.space.id,A.layout,A.config),[R,M]=a([Y.x,Y.y]),i=w.map(a),x=IB([i]);let b=!1;if(A.options.roomNames&&E.name){const A=Math.max(0,x.maxX-x.minX-4*$A),B=PA(E.name,6.75)<=A?6.75:PA(E.name,5.25)<=A?5.25:0;B&&(f.push({kind:"text",x:R,y:M-2,text:E.name,size:B,align:"center"}),z.push(wB(R,M-2,E.name,B,0,"center")),b=!0)}if(A.options.dimensions){const B=o(I*F*F/1e4,A.imperial),E=M+(b?8:0);f.push({kind:"text",x:R,y:E,text:B,size:6,align:"center"}),z.push(wB(R,E,B,8,0,"center"))}if(A.options.dimensions){const E=l(F),s=EA(p(w,F,A.imperial,{ringIndex:B,epsilon:E}),{ring:w,epsilon:E,score:A=>{const B=a(A.mid),E=QB(wB(B[0],B[1],A.text,_A,A.angle,"center"),B[0],B[1],A.inwardNormal,$A),s=wB(B[0]+A.inwardNormal[0]*E,B[1]+A.inwardNormal[1]*E,A.text,7,A.angle,"center"),w="horizontal"===A.axis?A.inwardNormal[1]>0?x.maxY-B[1]:B[1]-x.minY:A.inwardNormal[0]>0?x.maxX-B[0]:B[0]-x.minX;return{hardCollisions:Number(K(s))+z.reduce((A,B)=>A+Number(sB(s,B)),0),normalClearance:w}}});for(const A of s.filter(A=>A.short)){const B=A.inwardNormal,E=a(A.a),s=a(A.b),w=(E[0]+s[0])/2,Q=(E[1]+s[1])/2;f.push({kind:"line",points:[[w-1.5*B[0]*$A,Q-1.5*B[1]*$A],[w+1.5*B[0]*$A,Q+1.5*B[1]*$A]],stroke:AB,width:.2*$A})}const Q=new Map;for(const A of s.filter(A=>!A.short)){const B=CB(A,A.inwardNormal),E=Q.get(B)||[];E.push(A),Q.set(B,E)}for(const A of Q.values()){let B=null;for(let E=0;E<=30&&!B;E+=3){const s=A.map(A=>{const B=a(A.mid),s=QB(wB(B[0],B[1],A.text,_A,A.angle,"center"),B[0],B[1],A.inwardNormal,(1+E)*$A),w=B[0]+A.inwardNormal[0]*s,Q=B[1]+A.inwardNormal[1]*s;return{edge:A,x:w,y:Q,box:wB(w,Q,A.text,_A,A.angle,"center")}}),Q=s.some((A,B)=>s.slice(0,B).some(B=>sB(A.box,B.box))),C=s.some(A=>K(A.box)||z.some(B=>sB(A.box,B))),g=s.every(A=>d(A.box,w));Q||C||!g||(B=s)}if(B)for(const A of B)f.push({kind:"text",x:A.x,y:A.y,text:A.edge.text,size:_A,angle:A.edge.angle,align:"center"}),z.push(A.box)}}}const _={minX:m,minY:v,maxX:c-m,maxY:v+V},AA=XA(f),BA=OA(AA,{minX:0,minY:0,maxX:U,maxY:V},.5*$A),sA=function(A,B){const E=XA(A);if(!ZA(E))return{commands:[...A],bounds:E,dx:0,dy:0};const s=(B.minX+B.maxX-E.minX-E.maxX)/2,w=(B.minY+B.maxY-E.minY-E.maxY)/2,Q=function(A,B,E){return A.map(A=>"path"===A.kind?{...A,rings:A.rings.map(A=>A.map(([A,s])=>[A+B,s+E]))}:"line"===A.kind?{...A,points:A.points.map(([A,s])=>[A+B,s+E])}:"vector"===A.kind?{...A,ops:A.ops.map(A=>((A,B,E)=>"M"===A.op||"L"===A.op?{...A,x:A.x+B,y:A.y+E}:"C"===A.op?{...A,x1:A.x1+B,y1:A.y1+E,x2:A.x2+B,y2:A.y2+E,x:A.x+B,y:A.y+E}:A)(A,B,E))}:{...A,x:A.x+B,y:A.y+E})}(A,s,w);return{commands:Q,bounds:{minX:E.minX+s,minY:E.minY+w,maxX:E.maxX+s,maxY:E.maxY+w},dx:s,dy:w}}(f,_);f=sA.commands,f.push({kind:"text",x:m,y:m+10,text:A.space.title,size:14}),A.cardTitle&&f.push({kind:"text",x:c-m,y:m+10,text:A.cardTitle,size:10,align:"right"});const wA=W-m-13*$A;f.push({kind:"line",points:[[m,wA-4*$A],[c-m,wA-4*$A]],stroke:EB,width:.2*$A}),f.push({kind:"text",x:m,y:wA,text:A.t("pdf.scale",{n:E}),size:8});const QA=10*(A.imperial?152.4:100)*$A/E,CA=wA+8;f.push({kind:"line",points:[[m,CA],[m+QA,CA]],stroke:AB,width:.4*$A});for(let A=0;A<=4;A++){const B=m+QA*A/4;f.push({kind:"line",points:[[B,CA-2],[B,CA+2]],stroke:AB,width:.25*$A})}f.push({kind:"text",x:m+QA/2,y:wA+17,text:A.imperial?"5 ft":"1 m",size:7,align:"center"});const gA=t(A.config.settings,A.rawSpace.settings||{});if(null!==gA){const B=c/2,E=wA+5.5*$A;f.push({kind:"vector",ops:FA({centerX:B,centerY:E,size:11*$A,northDeg:gA}),fill:AB,width:0,fillRule:"evenodd"}),f.push({kind:"text",x:B,y:wA,text:A.t("pdf.north"),size:7,align:"center"})}f.push({kind:"text",x:c-m,y:wA+12,text:`${qA(A.now)} · House Plan v${A.version}`,size:7,align:"right"});const IA={width:c,height:W,commands:f,images:(A.rasters||[]).map(({id:A,bytes:B,width:E,height:s})=>({id:A,bytes:B,width:E,height:s})),now:A.now,scale:E,sceneBounds:sA.bounds,planField:_},RA=Math.max(0,TA(AA))*Math.max(0,fA(AA)),MA=U*V;return{page:IA,sceneBounds:sA.bounds,field:_,fits:BA,fillRatio:MA>0?RA/MA:0,landscape:s}}function bB(A,B){return A.fillRatio!==B.fillRatio?A.fillRatio>B.fillRatio?A:B:A.landscape?B:A}function LB(A,B,E){const s=12*$A,w=(E?297:210)*$A-2*s,Q=(E?210:297)*$A-2*s-18*$A-24*$A,C=A.cmPerUnit*(10*$A)/B;return(A.bounds.maxX-A.bounds.minX)*C<=w+.5*$A&&(A.bounds.maxY-A.bounds.minY)*C<=Q+.5*$A}function DB(A){let B=0;for(const E of A)if(B+=Math.max(0,Number(E)||0),B>26214400)throw new Error("pdf.too_large")}const GB="d31b0b1e184ab2863684b758f839bdb6809a33cc742c6e9bb36c5ea034e3d309";async function oB(A,B){if(!A)throw new Error("pdf.asset_failed");const E=await fetch(A,{credentials:"same-origin"});if(!E.ok)throw new Error("pdf.asset_failed");const s=await E.blob();let w;try{w=await createImageBitmap(s)}catch{throw new Error("pdf.asset_failed")}try{if("image/jpeg"===s.type)return{id:B,bytes:new Uint8Array(await s.arrayBuffer()),width:w.width,height:w.height};const A=document.createElement("canvas");A.width=w.width,A.height=w.height;const E=A.getContext("2d");if(!E)throw new Error("pdf.asset_failed");E.fillStyle="#fff",E.fillRect(0,0,A.width,A.height),E.drawImage(w,0,0);const Q=await new Promise(B=>A.toBlob(B,"image/jpeg",.85));if(!Q)throw new Error("pdf.asset_failed");return{id:B,bytes:new Uint8Array(await Q.arrayBuffer()),width:w.width,height:w.height}}finally{w.close()}}async function tB(A,B,E){const s=await async function(A,B){const E=[];if(B.backdrop&&A.space.bg){const B=await oB(A.backdropUrl,"backdrop");E.push({...B,x:A.space.bg.x,y:A.space.bg.y,drawWidth:A.space.bg.w,drawHeight:A.space.bg.h,angle:A.space.bg.angle,opacity:.6})}if(B.decor){let B=0;for(const s of A.rawSpace.decor||[]){if("image"!==s.kind)continue;const w=A.decorAssets.get(s.asset_id),Q=j(s,I,I);if(!w||!Q)throw new Error("pdf.asset_failed");const C=await oB(w.url,"decor"+B++);E.push({...C,x:Q[0],y:Q[1],drawWidth:Q[2],drawHeight:Q[3],opacity:Q[4],angle:Number(s.angle)||0})}}return DB(E.map(A=>A.bytes.byteLength)),E}(A,B),w=JA(function(A){const B=iB(A);let E=[];for(const s of wA){const w=[!1,!0].filter(A=>LB(B,s,A)).map(E=>xB(A,B,s,E));if(!w.length)continue;const Q=w.filter(A=>A.fits);if(Q.length)return Q.reduce(bB).page;E=w}E.length||(E=[!1,!0].map(E=>xB(A,B,500,E)));const s=E.filter(A=>A.fits);if(s.length)return s.reduce(bB).page;const w=Math.min(...E.map(A=>Math.max(TA(A.sceneBounds)/TA(A.field),fA(A.sceneBounds)/fA(A.field)))),Q=50,C=1e6,g=Number.isFinite(w)?Math.ceil(Math.min(C,500*Math.max(1,w))/Q)*Q:C;let I=500,Y=0,R=[],M=Math.max(550,g);for(;M<=C;){const E=[!1,!0].map(E=>xB(A,B,M,E)).filter(A=>A.fits);if(E.length){Y=M,R=E;break}if(I=M,M===C)break;M=Math.min(C,Math.ceil(2*M/Q)*Q)}if(!Y)throw new Error("pdf.failed");let F=Math.floor(I/Q),i=Math.floor(Y/Q);for(;i-F>1;){const E=Math.floor((F+i)/2),s=[!1,!0].map(s=>xB(A,B,E*Q,s)).filter(A=>A.fits);s.length?(i=E,R=s):F=E}const x=R.reduce(bB).page;if(!OA(x.sceneBounds,x.planField,.5*$A))throw new Error("pdf.failed");return x}({...A,options:B,now:E,rasters:s,t:A.t})),Q=new Blob([w],{type:"application/pdf"}),C=URL.createObjectURL(Q);try{const B=document.createElement("a");B.href=C,B.download=`houseplan-${g=A.space.title,g.normalize("NFKD").replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-|-$/g,"").toLowerCase()||"space"}-${qA(E)}.pdf`,B.style.display="none",document.body.append(B),B.click(),B.remove()}finally{setTimeout(()=>URL.revokeObjectURL(C),0)}var g;return w}class cB{assertRasterBudget(A){DB(A)}render(A){let B;return B={...A,save:async E=>{await tB(A,E,B.now||new Date)}},s``}}export{GB as PDF_EXPORT_FINGERPRINT,cB as PdfExportRuntime,tB as exportSpacePdf}; diff --git a/custom_components/houseplan/frontend/houseplan-assets/summary-panel-editor-ClwrL_O4.js b/dist/houseplan-assets/summary-panel-editor-Dq397KvS.js similarity index 97% rename from custom_components/houseplan/frontend/houseplan-assets/summary-panel-editor-ClwrL_O4.js rename to dist/houseplan-assets/summary-panel-editor-Dq397KvS.js index b5f1758f..a70cc41d 100644 --- a/custom_components/houseplan/frontend/houseplan-assets/summary-panel-editor-ClwrL_O4.js +++ b/dist/houseplan-assets/summary-panel-editor-Dq397KvS.js @@ -1,4 +1,4 @@ -globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db7c58754eeb4ba03f835b8d7c84c6";import{c as a,A as e}from"./houseplan-card-BiUNLHFh.js";import{s,n as t,a as l,m as r,b as o,c as i,d as u}from"./summary-panel-runtime-loaded-B9-PG-Gw.js";import"./form-kit.styles-BQTkV2m1.js";const m=m=>{const{host:c,dialog:d,problems:n,t:b}=m,y=n.find(a=>"error"===a.kind),$=d.localShow!==d.baseLocalShow||!d.localOnly&&!s(t(d.draft),d.base),p=$&&!d.busy&&!y,v=a=>n.find(e=>e.path===a),h=a=>a?b(`summary.problem.${a.code}`):"",k=()=>m.close(),g=a`
    `}renderDialog(){return this.dialog&&this.editorRenderer?(this.dialog.localOnly||this.refreshEntityIndex(),this.editorRenderer({host:this.host,dialog:this.dialog,local:this.local,storageUnavailable:this.storageUnavailable,problems:this.problems(this.dialog),entityIndex:this.entityIndex||F({},null),setDialog:e=>{this.dialog=e,this.host.requestUpdate()},saveLocal:e=>this.saveLocal(e),mutate:e=>this.mutate(e),deleteBlock:e=>{this.deleteBlock(e)},dragStart:(e,t)=>this.dragStart(e,t),drop:(e,t)=>this.drop(e,t),sourceToken:e=>this.sourceToken(e),openSource:(e,t)=>this.openSource(e,t),closeSource:e=>this.closeSource(e),setSource:(e,t,s)=>this.setSource(e,t,s),save:()=>{this.saveDialog()},reload:()=>{this.reloadDialog()},close:()=>this.closeDialogIfIdle(),t:e=>this.t(e)})):t}t(e){return e.startsWith("summary.")?function(e,t){const s=e.toLowerCase().split("-")[0];return(q[s]||q.en)[t]||q.en[t]||t}(r(this.host.hass,this.host._config?.language),e):this.host._t(e)}ensureStyle(){const e=this.host.renderRoot;if(this.styleSheet&&e.adoptedStyleSheets.includes(this.styleSheet))return;const t=this.host.ownerDocument.defaultView?.CSSStyleSheet;if(t&&"adoptedStyleSheets"in e){const s=new t;return s.replaceSync(R),this.styleSheet=s,void(e.adoptedStyleSheets=[...e.adoptedStyleSheets,s])}if(e.querySelector("style[data-hp-summary]"))return;const s=this.host.ownerDocument.createElement("style");s.dataset.hpSummary="true",s.textContent=R,e.insertBefore(s,e.firstChild)}ensureDialogStyle(){const e=this.host.renderRoot.querySelector('hp-dialog[data-kind="summary"]')?.shadowRoot;if(!e||this.styledDialogRoots.has(e))return;const t=this.host.ownerDocument.defaultView?.CSSStyleSheet;if(t&&"adoptedStyleSheets"in e)this.dialogStyleSheet||(this.dialogStyleSheet=new t,this.dialogStyleSheet.replaceSync(I)),e.adoptedStyleSheets=[...e.adoptedStyleSheets,this.dialogStyleSheet];else{const t=this.host.ownerDocument.createElement("style");t.dataset.hpSummaryShell="true",t.textContent=I,e.appendChild(t)}this.styledDialogRoots.add(e)}placementSlot(){return K(this.host)}preferenceKey(){return function(e){const t=y(e.userId),s=y(e.slot);return t&&s?`houseplan.summary-panel.v1:${[t,y(e.path)||"/",y(e.host)||"card",s].map(e=>encodeURIComponent(e)).join(":")}`:null}({userId:this.host.hass?.user?.id||this.host.hass?.user?.name,path:location.pathname,host:this.host.panelHost?"panel":"lovelace",slot:this.placementSlot()})}identity(){return JSON.stringify({key:this.preferenceKey(),user:this.host.hass?.user?.id||this.host.hass?.user?.name||"",route:location.pathname,host:this.host.panelHost?"panel":"lovelace",slot:this.placementSlot(),kiosk:this.host._kiosk,canManage:this.host._canManageConfiguration})}syncLifecycle(){const e=this.identity();this.lifecycleIdentity&&e!==this.lifecycleIdentity&&this.resetLifecycle(),this.lifecycleIdentity=e}resetLifecycle(){this.presentation.reset(),this.lifecycleGeneration++,this.dialog=null,this.entityIndex=null,this.deviceMemo=null,this.areaMemo=null,this.clockContext="",this.storageKey=null,this.storageUnavailable=!1,this.local={version:1,show:!1,icon_scale:1,font_scale:1},this.clockTimer&&clearTimeout(this.clockTimer),this.clockTimer=0,this.lifecycleIdentity=this.connected?this.identity():"",this.host.requestUpdate()}current(e){return this.connected&&e===this.lifecycleGeneration&&this.lifecycleIdentity===this.identity()}refreshEntityIndex(){this.entityIndex=F(this.host.hass?.states,this.entityIndex)}syncNativeNarrow(){if(this.host.panelHost)return;let e=this.host;for(let t=0;e&&t<12;t++){const t=e.getRootNode();if(e=e.parentNode||(t instanceof ShadowRoot?t.host:null),!e||e===this.host)continue;const s=e.narrow;if("boolean"==typeof s)return void(this.host.narrow!==s&&(this.host.narrow=s))}}loadLocal(){const e=this.preferenceKey();if(!e||e===this.storageKey)return;let t=null,s=null,r=!0;try{t=JSON.parse(localStorage.getItem(e)||"null")}catch{r=!1}try{s=JSON.parse(localStorage.getItem("houseplan_card_kiosk_v1")||"null")}catch{r=!1}this.storageKey=e,this.storageUnavailable=!r,this.local=function(e,t){const s=e&&"object"==typeof e?e:{},r=t&&"object"==typeof t?t:{};return{version:1,show:!0===s.show,icon_scale:M(p(s,"icon_scale")?s.icon_scale:r.icon),font_scale:M(p(s,"font_scale")?s.font_scale:r.font)}}(t,s),this.host._kioskScale={icon:this.local.icon_scale,font:this.local.font_scale}}saveLocal(e){this.local={...this.local,...e,version:1,icon_scale:M(e.icon_scale??this.local.icon_scale),font_scale:M(e.font_scale??this.local.font_scale)},this.host._kioskScale={icon:this.local.icon_scale,font:this.local.font_scale},this.storageKey||=this.preferenceKey();let t=!1;try{this.storageKey&&(localStorage.setItem(this.storageKey,JSON.stringify(this.local)),t=!0)}catch{}this.storageUnavailable=!t,t||this.host._showToast?.(this.t("summary.storage_unavailable")),this.host.requestUpdate()}config(){return function(e,t){const s=e?.summary_panel;return void 0===s?{config:b(t),derived:!0,unsupported:!1}:v(s)?{config:s,derived:!1,unsupported:!1}:{config:null,derived:!1,unsupported:!0}}(this.host._settings,this.translate)}async openDialog(){const e=this.lifecycleGeneration;this.loadLocal();try{this.editorLoad||=import("./summary-panel-editor-ClwrL_O4.js").then(e=>e.renderSummaryPanelEditor),this.editorRenderer=await this.editorLoad}catch(t){if(this.editorLoad=null,!this.current(e))return;return void this.host._showToast?.(`${this.t("summary.load_failed")} ${this.host._errText(t)}`)}if(!this.current(e))return;const t=this.config(),s=t.config||b(this.translate),r=this.host._haSummaryPanelApi!==i,a=t.unsupported?"summary.unsupported_schema":r&&this.host._canManageConfiguration?"summary.backend_required":"summary.local_only";this.dialog={draft:_(s),base:_(s),baseRevision:this.host._cfgRev,localShow:this.local.show,baseLocalShow:this.local.show,localOnly:this.host._kiosk||!this.host._canManageConfiguration||r||t.unsupported,localOnlyHint:a,busy:!1,attempted:!1,entityFilter:"",activeSource:null,error:"",conflict:!1},this.dialog.localOnly||this.refreshEntityIndex(),this.host.requestUpdate()}problems(e=this.dialog){return!e||e.localOnly?[]:k(x(e.draft),e.base,new Set(this.host._model.map(e=>e.id)),new Set(Object.keys(this.host.hass?.states||{})))}mutate(e){if(!this.dialog||this.dialog.busy||this.dialog.localOnly)return;const t=_(this.dialog.draft);e(t);const s=this.dialog.activeSource,r=!s||t.blocks.some(e=>e.id===s.blockId&&e.values.some(e=>e.id===s.valueId));this.dialog={...this.dialog,draft:t,error:"",conflict:!1,activeSource:r?s:null,entityFilter:r?this.dialog.entityFilter:""},this.host.requestUpdate()}async deleteBlock(e){const t=this.dialog?.draft.blocks[e];if(!t)return;const s=this.lifecycleGeneration;if(t.values.length){if(!await this.host._confirmDanger({key:"summary-block",kind:"warning",title:this.t("summary.delete_block_title"),message:this.t("summary.delete_block_body"),objectName:t.title,confirmLabel:this.t("btn.delete"),cancelLabel:this.t("btn.cancel")})||!this.current(s))return}this.mutate(e=>{const s=e.blocks.findIndex(e=>e.id===t.id);s>=0&&e.blocks.splice(s,1)})}sourceToken(e){return"system"===e.type?`system:${e.key}`:`entity:${e.entity_id}`}openSource(e,t){!this.dialog||this.dialog.busy||this.dialog.localOnly||(this.refreshEntityIndex(),this.dialog={...this.dialog,activeSource:{blockId:e,valueId:t},entityFilter:""},this.host.requestUpdate(),this.host.updateComplete.then(()=>{this.dialog?.activeSource?.blockId===e&&this.dialog.activeSource.valueId===t&&this.host.renderRoot.querySelector("[data-summary-picker-search]")?.focus()}))}closeSource(e=!1){const t=this.dialog?.activeSource;this.dialog&&t&&(this.dialog={...this.dialog,activeSource:null,entityFilter:""},this.host.requestUpdate(),e&&this.focusSource(t.blockId,t.valueId))}async focusSource(e,t){await this.host.updateComplete;const s=`${e}\n${t}`,r=this.host.renderRoot.querySelectorAll("[data-summary-source-owner]");[...r].find(e=>e.dataset.summarySourceOwner===s)?.focus()}setSource(e,t,s){this.mutate(r=>{const i=r.blocks.find(t=>t.id===e)?.values.find(e=>e.id===t);if(i)if(s.startsWith("system:")){const e=s.slice(7);(e=>"device_count"===e||"total_area"===e||"datetime"===e)(e)&&(i.source={type:"system",key:e})}else i.source={type:"entity",entity_id:s.startsWith("entity:")?s.slice(7):s}}),this.dialog&&(this.dialog={...this.dialog,activeSource:null,entityFilter:""}),this.host.requestUpdate(),this.focusSource(e,t)}dragStart(e,t){e.dataTransfer?.setData("text/x-houseplan-summary",t),e.dataTransfer&&(e.dataTransfer.effectAllowed="move")}drop(e,t){e.preventDefault(),e.stopPropagation();const s=e.dataTransfer?.getData("text/x-houseplan-summary")||"",r=s.split(":").map(Number),i=t.split(":").map(Number);s.startsWith("block:")&&t.startsWith("block:")?this.mutate(e=>{e.blocks=C(e.blocks,r[1],i[1])}):s.startsWith("value:")&&t.startsWith("value:")&&r[1]===i[1]&&this.mutate(e=>{e.blocks[r[1]].values=C(e.blocks[r[1]].values,r[2],i[2])})}async saveDialog(){const e=this.dialog;if(!e||e.busy)return;const t=this.lifecycleGeneration,s=x(e.draft);if((e.localOnly?[]:k(s,e.base,new Set(this.host._model.map(e=>e.id)),new Set(Object.keys(this.host.hass?.states||{})))).some(e=>"error"===e.kind))return this.dialog={...e,draft:s,attempted:!0},this.host.requestUpdate(),await this.host.updateComplete,void this.host.renderRoot.querySelector('[data-summary-error="true"]')?.focus?.();this.dialog={...e,draft:s,busy:!0,attempted:!1,error:"",conflict:!1},this.host.requestUpdate();try{if(!e.localOnly&&!$(s,e.base)){this.host._writesPending++;const r=a(this.host._writeChain,async()=>{if(!this.current(t))return;if(!this.host._serverCfg)throw new Error(this.t("summary.save_failed"));if(this.host._cfgRev!==e.baseRevision)throw new Error(this.t("summary.conflict"));const r=o({...this.host._serverCfg,settings:{...this.host._serverCfg.settings||{},summary_panel:s}});let i=!1;try{if(await this.host._sendConfigCandidate(r),!this.current(t))return}catch(e){if(!this.current(t))throw e;try{const r=await this.host._getAuthoritativeConfig();if(!this.current(t))throw e;const a=function(e,t){if(!g(e))return null;const s=e.config,r=e.rev;if(!g(s)||!Array.isArray(s.spaces)||"number"!=typeof r||!Number.isSafeInteger(r)||r<0)return null;const i=g(s.settings)?s.settings:null,a=i?.summary_panel;return v(a)&&$(a,t)?{config:s,rev:r}:null}(r,s);if(!a)throw e;const o=await this.host._adoptAuthoritative({cfgResp:r,reason:"summary-recovery",profile:"reload"});if("adopted"!==o.status)throw e;o.spaceChanged&&this.host._restoreZoom(),this.host._regSignature="",this.host._maybeRebuildDevices(),i=!0}catch{throw e}}if(!i){if(!this.current(t))return;this.host._adoption.stageConfigCandidate(r),this.host._cacheSnapshot()}});this.host._writeChain=r,await r.finally(()=>{this.host._writesPending--})}if(!this.current(t))return;this.saveLocal({show:e.localShow}),this.dialog=null}catch(s){if(!this.current(t))return;const r="conflict"===s?.code||this.host._cfgRev!==e.baseRevision;this.dialog={...this.dialog||e,busy:!1,conflict:r,error:r?this.t("summary.conflict"):this.host._errText(s)}}this.current(t)&&this.host.requestUpdate()}async reloadDialog(){const e=this.dialog;if(!e||e.busy)return;const t=this.lifecycleGeneration;this.dialog={...e,busy:!0,error:"",conflict:!1},this.host.requestUpdate();try{if(await this.host._reloadConfigOnly(!0),!this.current(t))return;if(e.conflict&&this.host._cfgRev===e.baseRevision)throw new Error(this.t("summary.load_failed"));const s=this.config().config||b(this.translate);this.dialog={...e,draft:_(s),base:_(s),baseRevision:this.host._cfgRev,busy:!1,attempted:!1,error:"",conflict:!1}}catch(s){if(!this.current(t))return;this.dialog={...e,busy:!1,error:this.host._errText(s),conflict:!0}}this.current(t)&&this.host.requestUpdate()}metricsFresh(){return!!this.deviceMemo&&!!this.areaMemo&&this.deviceMemo.cfgEpoch===this.host._cfgEpoch&&this.deviceMemo.layoutRev===this.host._layoutRev&&this.deviceMemo.registryRev===this.host._haRegistry.revision&&this.areaMemo.cfgEpoch===this.host._cfgEpoch}scheduleMetrics(){if(this.metricsRefresh||!this.metricsModule||this.metricsFresh())return;const e=this.lifecycleGeneration,t="undefined"==typeof window?void 0:window,s=()=>{if(this.metricsRefresh=0,!this.current(e))return;const t=this.advanceMetrics(8);this.host.requestUpdate(),t||this.scheduleMetrics()};this.metricsRefresh=t?.setTimeout(()=>{"function"==typeof t.requestAnimationFrame?t.requestAnimationFrame(()=>t.setTimeout(s,0)):s()},0)||0}advanceMetrics(e=8){const t=this.metricsModule;if(!t)return!0;if(this.computeDeviceCount(),!this.host._serverCfg)return this.areaMemo={cfgEpoch:this.host._cfgEpoch,value:null},!0;if(this.areaMemo&&this.areaMemo.cfgEpoch===this.host._cfgEpoch)return!0;this.areaSteps&&this.areaStepsEpoch===this.host._cfgEpoch||(this.areaSteps=t.cleanFloorAreaSteps(this.host._serverCfg,this.host._model),this.areaStepsEpoch=this.host._cfgEpoch);const s=Date.now();let r=this.areaSteps.next();for(;!r.done&&Date.now()-s[e,t.space])),spaceIds:new Set(this.host._model.map(e=>e.id)),firstSpaceId:this.host._model[0]?.id||"",markers:this.host._markers});this.deviceMemo={cfgEpoch:this.host._cfgEpoch,layoutRev:this.host._layoutRev,registryRev:this.host._haRegistry.revision,value:t?.size??null}}}computeMetrics(){for(;!this.advanceMetrics(Number.POSITIVE_INFINITY););}metrics(){return{deviceCount:this.deviceMemo?this.deviceMemo.value:null,areaM2:this.areaMemo?this.areaMemo.value:null,now:this.clock}}valueState(e){const t=this.metricsModule;if(!t)return{kind:"pending"};if("entity"===e.source.type){const s=t.summaryEntityValue(this.host.hass,e.source.entity_id);return null===s?{kind:"unavailable"}:{kind:"ready",text:s}}const s="device_count"===e.source.key||"total_area"===e.source.key,i="device_count"===e.source.key?this.deviceMemo:this.areaMemo;if(s&&!i)return this.scheduleMetrics(),{kind:"pending"};s&&this.scheduleMetrics();const a=t.summarySystemValue(e.source,this.metrics(),this.host.hass,r(this.host.hass,this.host._config?.language));return null===a?{kind:"unavailable"}:{kind:"ready",text:a}}value(e){const t=this.valueState(e);return"ready"===t.kind?t.text:this.t("summary.unavailable")}ensureMetrics(){if(this.metricsModule||this.metricsLoad)return;const e=this.lifecycleGeneration;this.metricsLoad=import("./summary-panel-metrics-BjFIAkz0.js"),this.metricsLoad.then(t=>{this.metricsModule=t,this.current(e)&&this.host.requestUpdate()}).catch(()=>{}).finally(()=>{this.metricsLoad=null})}layout(){return function(e){const t=Math.max(0,Number(e.width)||0),s=Math.max(0,Number(e.height)||0),r=t>=s?"right":"bottom",i=Math.max(0,e.safeLeft||0)+12,a=Math.max(0,e.safeRight||0)+12,o=Math.max(Math.max(0,e.safeTop||0)+12,e.controlTop||0),n=Math.max(Math.max(0,e.safeBottom||0)+12,e.controlBottom||0),l=Math.max(0,t-i-a),m=Math.max(0,s-o-n),c="bottom"===r?Math.min(.6*s,m):m;return{side:r,fits:t>0&&s>0&&l>=280&&c>=Math.max(0,e.minimumHeight),availableWidth:l,heightCap:c,top:o,bottom:n}}({width:this.stage.width,height:this.stage.height,...this.safeInsets(),controlTop:this.host._kiosk?this.stage.controlTop:0,minimumHeight:this.stage.minimumHeight})}syncPresentation(e=!1){const t=this.config().config,s=this.layout(),r=!!t&&"view"===this.host._mode&&s.fits&&S({view:!0,localShow:!0,showOnMobile:t.show_on_mobile,narrow:this.host.narrow,fits:!0});this.presentation.sync(r&&this.local.show,s.side,e||!r||"hidden"===this.host.ownerDocument.visibilityState)}measureLayout(){const e=this.host._stageEl;if(!e)return;const t=this.host.renderRoot.querySelector(".summary-measure"),s=this.host.renderRoot.querySelector(".summary-control.kiosk"),r=e.getBoundingClientRect(),i=s?.getBoundingClientRect(),a={width:Math.round(e.clientWidth),height:Math.round(e.clientHeight),minimumHeight:Math.max(162,Math.ceil(t?.getBoundingClientRect().height||0)),controlTop:i?Math.max(0,Math.ceil(i.bottom-r.top+12)):0};a.width===this.stage.width&&a.height===this.stage.height&&a.minimumHeight===this.stage.minimumHeight&&a.controlTop===this.stage.controlTop||(this.stage=a,this.host.requestUpdate())}safeInsets(){const e=this.host.renderRoot.querySelector(".summary-safe-probe");if(!e)return{safeLeft:0,safeRight:0,safeTop:0,safeBottom:0};const t=this.host.ownerDocument.defaultView?.getComputedStyle(e);if(!t)return{safeLeft:0,safeRight:0,safeTop:0,safeBottom:0};const s=e=>Number.parseFloat(e)||0;return{safeLeft:s(t.paddingLeft),safeRight:s(t.paddingRight),safeTop:s(t.paddingTop),safeBottom:s(t.paddingBottom)}}hasVisibleClock(){const e=this.config().config;return!("hidden"===this.host.ownerDocument.visibilityState||!e)&&(!!S({view:"view"===this.host._mode,localShow:this.local.show,showOnMobile:e.show_on_mobile,narrow:this.host.narrow,fits:this.layout().fits})&&w(e,this.host._space).some(e=>e.values.some(e=>"system"===e.source.type&&"datetime"===e.source.key)))}syncClock(){const e=`${r(this.host.hass,this.host._config?.language)}\n${this.host.hass?.config?.time_zone||""}`;e!==this.clockContext&&(this.clockContext=e,this.clock=new Date);const t=this.hasVisibleClock();if(t&&!this.clockTimer){this.clock=new Date;const e=()=>{this.clock=new Date,this.clockTimer=0,this.host.requestUpdate(),this.syncClock()};this.clockTimer=window.setTimeout(e,6e4-Date.now()%6e4+25)}else!t&&this.clockTimer&&(clearTimeout(this.clockTimer),this.clockTimer=0)}}});export{A as a,G as b,z as c,D as d,V as e,C as m,x as n,$ as s}; + `}renderDialog(){return this.dialog&&this.editorRenderer?(this.dialog.localOnly||this.refreshEntityIndex(),this.editorRenderer({host:this.host,dialog:this.dialog,local:this.local,storageUnavailable:this.storageUnavailable,problems:this.problems(this.dialog),entityIndex:this.entityIndex||F({},null),setDialog:e=>{this.dialog=e,this.host.requestUpdate()},saveLocal:e=>this.saveLocal(e),mutate:e=>this.mutate(e),deleteBlock:e=>{this.deleteBlock(e)},dragStart:(e,t)=>this.dragStart(e,t),drop:(e,t)=>this.drop(e,t),sourceToken:e=>this.sourceToken(e),openSource:(e,t)=>this.openSource(e,t),closeSource:e=>this.closeSource(e),setSource:(e,t,s)=>this.setSource(e,t,s),save:()=>{this.saveDialog()},reload:()=>{this.reloadDialog()},close:()=>this.closeDialogIfIdle(),t:e=>this.t(e)})):t}t(e){return e.startsWith("summary.")?function(e,t){const s=e.toLowerCase().split("-")[0];return(q[s]||q.en)[t]||q.en[t]||t}(r(this.host.hass,this.host._config?.language),e):this.host._t(e)}ensureStyle(){const e=this.host.renderRoot;if(this.styleSheet&&e.adoptedStyleSheets.includes(this.styleSheet))return;const t=this.host.ownerDocument.defaultView?.CSSStyleSheet;if(t&&"adoptedStyleSheets"in e){const s=new t;return s.replaceSync(R),this.styleSheet=s,void(e.adoptedStyleSheets=[...e.adoptedStyleSheets,s])}if(e.querySelector("style[data-hp-summary]"))return;const s=this.host.ownerDocument.createElement("style");s.dataset.hpSummary="true",s.textContent=R,e.insertBefore(s,e.firstChild)}ensureDialogStyle(){const e=this.host.renderRoot.querySelector('hp-dialog[data-kind="summary"]')?.shadowRoot;if(!e||this.styledDialogRoots.has(e))return;const t=this.host.ownerDocument.defaultView?.CSSStyleSheet;if(t&&"adoptedStyleSheets"in e)this.dialogStyleSheet||(this.dialogStyleSheet=new t,this.dialogStyleSheet.replaceSync(I)),e.adoptedStyleSheets=[...e.adoptedStyleSheets,this.dialogStyleSheet];else{const t=this.host.ownerDocument.createElement("style");t.dataset.hpSummaryShell="true",t.textContent=I,e.appendChild(t)}this.styledDialogRoots.add(e)}placementSlot(){return K(this.host)}preferenceKey(){return function(e){const t=y(e.userId),s=y(e.slot);return t&&s?`houseplan.summary-panel.v1:${[t,y(e.path)||"/",y(e.host)||"card",s].map(e=>encodeURIComponent(e)).join(":")}`:null}({userId:this.host.hass?.user?.id||this.host.hass?.user?.name,path:location.pathname,host:this.host.panelHost?"panel":"lovelace",slot:this.placementSlot()})}identity(){return JSON.stringify({key:this.preferenceKey(),user:this.host.hass?.user?.id||this.host.hass?.user?.name||"",route:location.pathname,host:this.host.panelHost?"panel":"lovelace",slot:this.placementSlot(),kiosk:this.host._kiosk,canManage:this.host._canManageConfiguration})}syncLifecycle(){const e=this.identity();this.lifecycleIdentity&&e!==this.lifecycleIdentity&&this.resetLifecycle(),this.lifecycleIdentity=e}resetLifecycle(){this.presentation.reset(),this.lifecycleGeneration++,this.dialog=null,this.entityIndex=null,this.deviceMemo=null,this.areaMemo=null,this.clockContext="",this.storageKey=null,this.storageUnavailable=!1,this.local={version:1,show:!1,icon_scale:1,font_scale:1},this.clockTimer&&clearTimeout(this.clockTimer),this.clockTimer=0,this.lifecycleIdentity=this.connected?this.identity():"",this.host.requestUpdate()}current(e){return this.connected&&e===this.lifecycleGeneration&&this.lifecycleIdentity===this.identity()}refreshEntityIndex(){this.entityIndex=F(this.host.hass?.states,this.entityIndex)}syncNativeNarrow(){if(this.host.panelHost)return;let e=this.host;for(let t=0;e&&t<12;t++){const t=e.getRootNode();if(e=e.parentNode||(t instanceof ShadowRoot?t.host:null),!e||e===this.host)continue;const s=e.narrow;if("boolean"==typeof s)return void(this.host.narrow!==s&&(this.host.narrow=s))}}loadLocal(){const e=this.preferenceKey();if(!e||e===this.storageKey)return;let t=null,s=null,r=!0;try{t=JSON.parse(localStorage.getItem(e)||"null")}catch{r=!1}try{s=JSON.parse(localStorage.getItem("houseplan_card_kiosk_v1")||"null")}catch{r=!1}this.storageKey=e,this.storageUnavailable=!r,this.local=function(e,t){const s=e&&"object"==typeof e?e:{},r=t&&"object"==typeof t?t:{};return{version:1,show:!0===s.show,icon_scale:M(p(s,"icon_scale")?s.icon_scale:r.icon),font_scale:M(p(s,"font_scale")?s.font_scale:r.font)}}(t,s),this.host._kioskScale={icon:this.local.icon_scale,font:this.local.font_scale}}saveLocal(e){this.local={...this.local,...e,version:1,icon_scale:M(e.icon_scale??this.local.icon_scale),font_scale:M(e.font_scale??this.local.font_scale)},this.host._kioskScale={icon:this.local.icon_scale,font:this.local.font_scale},this.storageKey||=this.preferenceKey();let t=!1;try{this.storageKey&&(localStorage.setItem(this.storageKey,JSON.stringify(this.local)),t=!0)}catch{}this.storageUnavailable=!t,t||this.host._showToast?.(this.t("summary.storage_unavailable")),this.host.requestUpdate()}config(){return function(e,t){const s=e?.summary_panel;return void 0===s?{config:b(t),derived:!0,unsupported:!1}:v(s)?{config:s,derived:!1,unsupported:!1}:{config:null,derived:!1,unsupported:!0}}(this.host._settings,this.translate)}async openDialog(){const e=this.lifecycleGeneration;this.loadLocal();try{this.editorLoad||=import("./summary-panel-editor-Dq397KvS.js").then(e=>e.renderSummaryPanelEditor),this.editorRenderer=await this.editorLoad}catch(t){if(this.editorLoad=null,!this.current(e))return;return void this.host._showToast?.(`${this.t("summary.load_failed")} ${this.host._errText(t)}`)}if(!this.current(e))return;const t=this.config(),s=t.config||b(this.translate),r=this.host._haSummaryPanelApi!==i,a=t.unsupported?"summary.unsupported_schema":r&&this.host._canManageConfiguration?"summary.backend_required":"summary.local_only";this.dialog={draft:_(s),base:_(s),baseRevision:this.host._cfgRev,localShow:this.local.show,baseLocalShow:this.local.show,localOnly:this.host._kiosk||!this.host._canManageConfiguration||r||t.unsupported,localOnlyHint:a,busy:!1,attempted:!1,entityFilter:"",activeSource:null,error:"",conflict:!1},this.dialog.localOnly||this.refreshEntityIndex(),this.host.requestUpdate()}problems(e=this.dialog){return!e||e.localOnly?[]:k(x(e.draft),e.base,new Set(this.host._model.map(e=>e.id)),new Set(Object.keys(this.host.hass?.states||{})))}mutate(e){if(!this.dialog||this.dialog.busy||this.dialog.localOnly)return;const t=_(this.dialog.draft);e(t);const s=this.dialog.activeSource,r=!s||t.blocks.some(e=>e.id===s.blockId&&e.values.some(e=>e.id===s.valueId));this.dialog={...this.dialog,draft:t,error:"",conflict:!1,activeSource:r?s:null,entityFilter:r?this.dialog.entityFilter:""},this.host.requestUpdate()}async deleteBlock(e){const t=this.dialog?.draft.blocks[e];if(!t)return;const s=this.lifecycleGeneration;if(t.values.length){if(!await this.host._confirmDanger({key:"summary-block",kind:"warning",title:this.t("summary.delete_block_title"),message:this.t("summary.delete_block_body"),objectName:t.title,confirmLabel:this.t("btn.delete"),cancelLabel:this.t("btn.cancel")})||!this.current(s))return}this.mutate(e=>{const s=e.blocks.findIndex(e=>e.id===t.id);s>=0&&e.blocks.splice(s,1)})}sourceToken(e){return"system"===e.type?`system:${e.key}`:`entity:${e.entity_id}`}openSource(e,t){!this.dialog||this.dialog.busy||this.dialog.localOnly||(this.refreshEntityIndex(),this.dialog={...this.dialog,activeSource:{blockId:e,valueId:t},entityFilter:""},this.host.requestUpdate(),this.host.updateComplete.then(()=>{this.dialog?.activeSource?.blockId===e&&this.dialog.activeSource.valueId===t&&this.host.renderRoot.querySelector("[data-summary-picker-search]")?.focus()}))}closeSource(e=!1){const t=this.dialog?.activeSource;this.dialog&&t&&(this.dialog={...this.dialog,activeSource:null,entityFilter:""},this.host.requestUpdate(),e&&this.focusSource(t.blockId,t.valueId))}async focusSource(e,t){await this.host.updateComplete;const s=`${e}\n${t}`,r=this.host.renderRoot.querySelectorAll("[data-summary-source-owner]");[...r].find(e=>e.dataset.summarySourceOwner===s)?.focus()}setSource(e,t,s){this.mutate(r=>{const i=r.blocks.find(t=>t.id===e)?.values.find(e=>e.id===t);if(i)if(s.startsWith("system:")){const e=s.slice(7);(e=>"device_count"===e||"total_area"===e||"datetime"===e)(e)&&(i.source={type:"system",key:e})}else i.source={type:"entity",entity_id:s.startsWith("entity:")?s.slice(7):s}}),this.dialog&&(this.dialog={...this.dialog,activeSource:null,entityFilter:""}),this.host.requestUpdate(),this.focusSource(e,t)}dragStart(e,t){e.dataTransfer?.setData("text/x-houseplan-summary",t),e.dataTransfer&&(e.dataTransfer.effectAllowed="move")}drop(e,t){e.preventDefault(),e.stopPropagation();const s=e.dataTransfer?.getData("text/x-houseplan-summary")||"",r=s.split(":").map(Number),i=t.split(":").map(Number);s.startsWith("block:")&&t.startsWith("block:")?this.mutate(e=>{e.blocks=C(e.blocks,r[1],i[1])}):s.startsWith("value:")&&t.startsWith("value:")&&r[1]===i[1]&&this.mutate(e=>{e.blocks[r[1]].values=C(e.blocks[r[1]].values,r[2],i[2])})}async saveDialog(){const e=this.dialog;if(!e||e.busy)return;const t=this.lifecycleGeneration,s=x(e.draft);if((e.localOnly?[]:k(s,e.base,new Set(this.host._model.map(e=>e.id)),new Set(Object.keys(this.host.hass?.states||{})))).some(e=>"error"===e.kind))return this.dialog={...e,draft:s,attempted:!0},this.host.requestUpdate(),await this.host.updateComplete,void this.host.renderRoot.querySelector('[data-summary-error="true"]')?.focus?.();this.dialog={...e,draft:s,busy:!0,attempted:!1,error:"",conflict:!1},this.host.requestUpdate();try{if(!e.localOnly&&!$(s,e.base)){this.host._writesPending++;const r=a(this.host._writeChain,async()=>{if(!this.current(t))return;if(!this.host._serverCfg)throw new Error(this.t("summary.save_failed"));if(this.host._cfgRev!==e.baseRevision)throw new Error(this.t("summary.conflict"));const r=o({...this.host._serverCfg,settings:{...this.host._serverCfg.settings||{},summary_panel:s}});let i=!1;try{if(await this.host._sendConfigCandidate(r),!this.current(t))return}catch(e){if(!this.current(t))throw e;try{const r=await this.host._getAuthoritativeConfig();if(!this.current(t))throw e;const a=function(e,t){if(!g(e))return null;const s=e.config,r=e.rev;if(!g(s)||!Array.isArray(s.spaces)||"number"!=typeof r||!Number.isSafeInteger(r)||r<0)return null;const i=g(s.settings)?s.settings:null,a=i?.summary_panel;return v(a)&&$(a,t)?{config:s,rev:r}:null}(r,s);if(!a)throw e;const o=await this.host._adoptAuthoritative({cfgResp:r,reason:"summary-recovery",profile:"reload"});if("adopted"!==o.status)throw e;o.spaceChanged&&this.host._restoreZoom(),this.host._regSignature="",this.host._maybeRebuildDevices(),i=!0}catch{throw e}}if(!i){if(!this.current(t))return;this.host._adoption.stageConfigCandidate(r),this.host._cacheSnapshot()}});this.host._writeChain=r,await r.finally(()=>{this.host._writesPending--})}if(!this.current(t))return;this.saveLocal({show:e.localShow}),this.dialog=null}catch(s){if(!this.current(t))return;const r="conflict"===s?.code||this.host._cfgRev!==e.baseRevision;this.dialog={...this.dialog||e,busy:!1,conflict:r,error:r?this.t("summary.conflict"):this.host._errText(s)}}this.current(t)&&this.host.requestUpdate()}async reloadDialog(){const e=this.dialog;if(!e||e.busy)return;const t=this.lifecycleGeneration;this.dialog={...e,busy:!0,error:"",conflict:!1},this.host.requestUpdate();try{if(await this.host._reloadConfigOnly(!0),!this.current(t))return;if(e.conflict&&this.host._cfgRev===e.baseRevision)throw new Error(this.t("summary.load_failed"));const s=this.config().config||b(this.translate);this.dialog={...e,draft:_(s),base:_(s),baseRevision:this.host._cfgRev,busy:!1,attempted:!1,error:"",conflict:!1}}catch(s){if(!this.current(t))return;this.dialog={...e,busy:!1,error:this.host._errText(s),conflict:!0}}this.current(t)&&this.host.requestUpdate()}metricsFresh(){return!!this.deviceMemo&&!!this.areaMemo&&this.deviceMemo.cfgEpoch===this.host._cfgEpoch&&this.deviceMemo.layoutRev===this.host._layoutRev&&this.deviceMemo.registryRev===this.host._haRegistry.revision&&this.areaMemo.cfgEpoch===this.host._cfgEpoch}scheduleMetrics(){if(this.metricsRefresh||!this.metricsModule||this.metricsFresh())return;const e=this.lifecycleGeneration,t="undefined"==typeof window?void 0:window,s=()=>{if(this.metricsRefresh=0,!this.current(e))return;const t=this.advanceMetrics(8);this.host.requestUpdate(),t||this.scheduleMetrics()};this.metricsRefresh=t?.setTimeout(()=>{"function"==typeof t.requestAnimationFrame?t.requestAnimationFrame(()=>t.setTimeout(s,0)):s()},0)||0}advanceMetrics(e=8){const t=this.metricsModule;if(!t)return!0;if(this.computeDeviceCount(),!this.host._serverCfg)return this.areaMemo={cfgEpoch:this.host._cfgEpoch,value:null},!0;if(this.areaMemo&&this.areaMemo.cfgEpoch===this.host._cfgEpoch)return!0;this.areaSteps&&this.areaStepsEpoch===this.host._cfgEpoch||(this.areaSteps=t.cleanFloorAreaSteps(this.host._serverCfg,this.host._model),this.areaStepsEpoch=this.host._cfgEpoch);const s=Date.now();let r=this.areaSteps.next();for(;!r.done&&Date.now()-s[e,t.space])),spaceIds:new Set(this.host._model.map(e=>e.id)),firstSpaceId:this.host._model[0]?.id||"",markers:this.host._markers});this.deviceMemo={cfgEpoch:this.host._cfgEpoch,layoutRev:this.host._layoutRev,registryRev:this.host._haRegistry.revision,value:t?.size??null}}}computeMetrics(){for(;!this.advanceMetrics(Number.POSITIVE_INFINITY););}metrics(){return{deviceCount:this.deviceMemo?this.deviceMemo.value:null,areaM2:this.areaMemo?this.areaMemo.value:null,now:this.clock}}valueState(e){const t=this.metricsModule;if(!t)return{kind:"pending"};if("entity"===e.source.type){const s=t.summaryEntityValue(this.host.hass,e.source.entity_id);return null===s?{kind:"unavailable"}:{kind:"ready",text:s}}const s="device_count"===e.source.key||"total_area"===e.source.key,i="device_count"===e.source.key?this.deviceMemo:this.areaMemo;if(s&&!i)return this.scheduleMetrics(),{kind:"pending"};s&&this.scheduleMetrics();const a=t.summarySystemValue(e.source,this.metrics(),this.host.hass,r(this.host.hass,this.host._config?.language));return null===a?{kind:"unavailable"}:{kind:"ready",text:a}}value(e){const t=this.valueState(e);return"ready"===t.kind?t.text:this.t("summary.unavailable")}ensureMetrics(){if(this.metricsModule||this.metricsLoad)return;const e=this.lifecycleGeneration;this.metricsLoad=import("./summary-panel-metrics-Kwu_Jan4.js"),this.metricsLoad.then(t=>{this.metricsModule=t,this.current(e)&&this.host.requestUpdate()}).catch(()=>{}).finally(()=>{this.metricsLoad=null})}layout(){return function(e){const t=Math.max(0,Number(e.width)||0),s=Math.max(0,Number(e.height)||0),r=t>=s?"right":"bottom",i=Math.max(0,e.safeLeft||0)+12,a=Math.max(0,e.safeRight||0)+12,o=Math.max(Math.max(0,e.safeTop||0)+12,e.controlTop||0),n=Math.max(Math.max(0,e.safeBottom||0)+12,e.controlBottom||0),l=Math.max(0,t-i-a),m=Math.max(0,s-o-n),c="bottom"===r?Math.min(.6*s,m):m;return{side:r,fits:t>0&&s>0&&l>=280&&c>=Math.max(0,e.minimumHeight),availableWidth:l,heightCap:c,top:o,bottom:n}}({width:this.stage.width,height:this.stage.height,...this.safeInsets(),controlTop:this.host._kiosk?this.stage.controlTop:0,minimumHeight:this.stage.minimumHeight})}syncPresentation(e=!1){const t=this.config().config,s=this.layout(),r=!!t&&"view"===this.host._mode&&s.fits&&S({view:!0,localShow:!0,showOnMobile:t.show_on_mobile,narrow:this.host.narrow,fits:!0});this.presentation.sync(r&&this.local.show,s.side,e||!r||"hidden"===this.host.ownerDocument.visibilityState)}measureLayout(){const e=this.host._stageEl;if(!e)return;const t=this.host.renderRoot.querySelector(".summary-measure"),s=this.host.renderRoot.querySelector(".summary-control.kiosk"),r=e.getBoundingClientRect(),i=s?.getBoundingClientRect(),a={width:Math.round(e.clientWidth),height:Math.round(e.clientHeight),minimumHeight:Math.max(162,Math.ceil(t?.getBoundingClientRect().height||0)),controlTop:i?Math.max(0,Math.ceil(i.bottom-r.top+12)):0};a.width===this.stage.width&&a.height===this.stage.height&&a.minimumHeight===this.stage.minimumHeight&&a.controlTop===this.stage.controlTop||(this.stage=a,this.host.requestUpdate())}safeInsets(){const e=this.host.renderRoot.querySelector(".summary-safe-probe");if(!e)return{safeLeft:0,safeRight:0,safeTop:0,safeBottom:0};const t=this.host.ownerDocument.defaultView?.getComputedStyle(e);if(!t)return{safeLeft:0,safeRight:0,safeTop:0,safeBottom:0};const s=e=>Number.parseFloat(e)||0;return{safeLeft:s(t.paddingLeft),safeRight:s(t.paddingRight),safeTop:s(t.paddingTop),safeBottom:s(t.paddingBottom)}}hasVisibleClock(){const e=this.config().config;return!("hidden"===this.host.ownerDocument.visibilityState||!e)&&(!!S({view:"view"===this.host._mode,localShow:this.local.show,showOnMobile:e.show_on_mobile,narrow:this.host.narrow,fits:this.layout().fits})&&w(e,this.host._space).some(e=>e.values.some(e=>"system"===e.source.type&&"datetime"===e.source.key)))}syncClock(){const e=`${r(this.host.hass,this.host._config?.language)}\n${this.host.hass?.config?.time_zone||""}`;e!==this.clockContext&&(this.clockContext=e,this.clock=new Date);const t=this.hasVisibleClock();if(t&&!this.clockTimer){this.clock=new Date;const e=()=>{this.clock=new Date,this.clockTimer=0,this.host.requestUpdate(),this.syncClock()};this.clockTimer=window.setTimeout(e,6e4-Date.now()%6e4+25)}else!t&&this.clockTimer&&(clearTimeout(this.clockTimer),this.clockTimer=0)}}});export{A as a,G as b,z as c,D as d,V as e,C as m,x as n,$ as s}; diff --git a/custom_components/houseplan/frontend/houseplan-assets/zigbee-topology-B31-i8CL.js b/dist/houseplan-assets/zigbee-topology-3KJks91U.js similarity index 98% rename from custom_components/houseplan/frontend/houseplan-assets/zigbee-topology-B31-i8CL.js rename to dist/houseplan-assets/zigbee-topology-3KJks91U.js index df15ebc4..d3c8426c 100644 --- a/custom_components/houseplan/frontend/houseplan-assets/zigbee-topology-B31-i8CL.js +++ b/dist/houseplan-assets/zigbee-topology-3KJks91U.js @@ -1 +1 @@ -globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db7c58754eeb4ba03f835b8d7c84c6";import{s as e,aR as n}from"./houseplan-card-BiUNLHFh.js";var t={title:"Zigbee links",toggle:"Show Zigbee links when hovering over a device",hint:"Shows observed direct neighbours only. Nothing is fetched while you hover.",help:"Shows which Zigbee devices each device talks to directly. Line colour is link quality (LQI) on the same scale as the device's LQI reading: red at 40 and below, green at 180 and above. A dashed line means quality was not reported. An arrow points to the next device on the way to the coordinator: one arrow leads out, incoming arrows are the devices that route through this one. A line without an arrow is a spare neighbour. This is the route tree House Plan builds, not the path a packet takes right now: a label at the end of an arrow means its target is not on this plan, and no arrow at all means the route is unknown. Data comes from the last load and goes stale; links are shown with a mouse only.",help_aria:"Help: Zigbee links",admin_only:"Topology data is available to Home Assistant administrators only.",save_first:"Save this setting before loading topology data.",zha:"ZHA",zha_read:"Read ZHA data",zha_hint:"Reads ZHA's cached topology; it does not start a radio scan.",z2m:"Zigbee2MQTT",z2m_topics:"Base topics (one per line)",z2m_update:"Update map",z2m_warning:"A network-map scan can take 10 seconds to 2 minutes and may temporarily reduce Zigbee responsiveness.",status_idle:"Data not loaded",status_loading:"Loading…",status_ready:"Received {time}",status_stale:"Received {time} · stale",status_partial:"Received {time} · some nodes were omitted",status_no_links:"Received {time} · no observed links found",error_permission:"Administrator permission is required.",error_unsupported:"This provider or Home Assistant API is unavailable.",error_timeout:"The provider did not respond in time.",error_invalid_topic:"Check the Zigbee2MQTT base topic.",error_invalid_payload:"The provider returned unsupported topology data.",error_provider:"Topology data could not be loaded.",remote_count:"+{n} in other spaces",route_device_not_on_plan:"device is not on the plan",route_coordinator_not_on_plan:"coordinator is not on the plan",route_other_space:"another space"};const i={en:t,ru:{title:"Связи Zigbee",toggle:"Показывать связи Zigbee при наведении на устройство",hint:"Показываются только наблюдаемые прямые соседи. Наведение ничего не запрашивает.",help:"Показывает, с какими устройствами Zigbee каждое связано напрямую. Цвет линии — качество связи (LQI) по той же шкале, что у показателя LQI устройства: красный при 40 и ниже, зелёный при 180 и выше. Пунктир — качество не сообщено. Стрелка ведёт к следующему устройству по пути к координатору: исходящая одна, входящие — те, кто ходит через это устройство. Линия без стрелки — запасной сосед. Это дерево маршрутов, которое строит House Plan, а не путь пакета в эту секунду: подпись на конце стрелки значит, что цель не на этом плане, а отсутствие стрелки — что путь неизвестен. Данные из последней загрузки и устаревают, связи видны только при работе мышью.",help_aria:"Справка: связи Zigbee",admin_only:"Данные топологии доступны только администраторам Home Assistant.",save_first:"Сохраните настройку перед загрузкой данных топологии.",zha:"ZHA",zha_read:"Прочитать данные ZHA",zha_hint:"Читает сохранённую топологию ZHA и не запускает радио-сканирование.",z2m:"Zigbee2MQTT",z2m_topics:"Базовые топики (по одному в строке)",z2m_update:"Обновить карту",z2m_warning:"Сканирование карты сети занимает от 10 секунд до 2 минут и временно может снизить отзывчивость Zigbee.",status_idle:"Данные не загружены",status_loading:"Загрузка…",status_ready:"Получено: {time}",status_stale:"Получено: {time} · данные устарели",status_partial:"Получено: {time} · часть узлов не показана",status_no_links:"Получено: {time} · наблюдаемые связи не найдены",error_permission:"Нужны права администратора.",error_unsupported:"Провайдер или API Home Assistant недоступен.",error_timeout:"Провайдер не ответил вовремя.",error_invalid_topic:"Проверьте базовый топик Zigbee2MQTT.",error_invalid_payload:"Провайдер вернул неподдерживаемые данные топологии.",error_provider:"Не удалось загрузить данные топологии.",remote_count:"+{n} в других пространствах",route_device_not_on_plan:"устройства нет на плане",route_coordinator_not_on_plan:"координатора нет на плане",route_other_space:"другое пространство"},de:{title:"Zigbee-Verbindungen",toggle:"Zigbee-Verbindungen beim Darüberfahren über ein Gerät anzeigen",hint:"Es werden nur beobachtete direkte Nachbarn angezeigt. Beim Darüberfahren werden keine Daten abgerufen.",help:"Zeigt, mit welchen Zigbee-Geräten jedes Gerät direkt verbunden ist. Die Linienfarbe ist die Verbindungsqualität (LQI) auf derselben Skala wie der LQI-Wert des Geräts: rot bei 40 und darunter, grün bei 180 und darüber. Eine gestrichelte Linie bedeutet, dass die Qualität nicht gemeldet wurde. Ein Pfeil zeigt auf das nächste Gerät auf dem Weg zum Koordinator: ein Pfeil führt hinaus, eingehende Pfeile sind die Geräte, die über dieses Gerät routen. Eine Linie ohne Pfeil ist ein Ersatznachbar. Das ist der Routenbaum, den House Plan bildet, nicht der Weg eines Pakets in diesem Moment: eine Beschriftung am Pfeilende bedeutet, dass das Ziel nicht auf diesem Plan liegt, und ein fehlender Pfeil, dass die Route unbekannt ist. Die Daten stammen aus dem letzten Laden und veralten; Verbindungen sind nur mit der Maus sichtbar.",help_aria:"Hilfe: Zigbee-Verbindungen",admin_only:"Topologiedaten sind nur für Home-Assistant-Administratoren verfügbar.",save_first:"Speichere diese Einstellung, bevor Topologiedaten geladen werden.",zha:"ZHA",zha_read:"ZHA-Daten lesen",zha_hint:"Liest den ZHA-Topologiecache; es wird kein Funkscan gestartet.",z2m:"Zigbee2MQTT",z2m_topics:"Basistopics (eines pro Zeile)",z2m_update:"Karte aktualisieren",z2m_warning:"Ein Netzwerkscan kann 10 Sekunden bis 2 Minuten dauern und Zigbee vorübergehend verlangsamen.",status_idle:"Daten nicht geladen",status_loading:"Wird geladen…",status_ready:"Empfangen: {time}",status_stale:"Empfangen: {time} · veraltet",status_partial:"Empfangen: {time} · einige Knoten fehlen",status_no_links:"Empfangen: {time} · keine beobachteten Verbindungen gefunden",error_permission:"Administratorrechte sind erforderlich.",error_unsupported:"Dieser Anbieter oder die Home-Assistant-API ist nicht verfügbar.",error_timeout:"Der Anbieter hat nicht rechtzeitig geantwortet.",error_invalid_topic:"Prüfe das Zigbee2MQTT-Basistopic.",error_invalid_payload:"Der Anbieter hat nicht unterstützte Topologiedaten geliefert.",error_provider:"Topologiedaten konnten nicht geladen werden.",remote_count:"+{n} in anderen Bereichen",route_device_not_on_plan:"Gerät ist nicht im Plan",route_coordinator_not_on_plan:"Koordinator ist nicht im Plan",route_other_space:"anderer Bereich"},fr:{title:"Liens Zigbee",toggle:"Afficher les liens Zigbee au survol d’un appareil",hint:"Seuls les voisins directs observés sont affichés. Le survol ne lance aucune requête.",help:"Montre avec quels appareils Zigbee chaque appareil communique directement. La couleur de la ligne est la qualité du lien (LQI) sur la même échelle que l'indicateur LQI de l'appareil : rouge à 40 et en dessous, vert à 180 et au-dessus. Une ligne pointillée signifie que la qualité n'a pas été communiquée. Une flèche pointe vers l'appareil suivant sur le chemin du coordinateur : une flèche part, les flèches entrantes sont les appareils qui passent par celui-ci. Une ligne sans flèche est un voisin de secours. C'est l'arbre de routes que construit House Plan, pas le trajet d'un paquet à cet instant : une étiquette au bout d'une flèche signifie que sa cible n'est pas sur ce plan, et l'absence de flèche que la route est inconnue. Les données proviennent du dernier chargement et vieillissent ; les liens ne sont visibles qu'à la souris.",help_aria:"Aide : liens Zigbee",admin_only:"Les données de topologie sont réservées aux administrateurs Home Assistant.",save_first:"Enregistrez ce réglage avant de charger les données de topologie.",zha:"ZHA",zha_read:"Lire les données ZHA",zha_hint:"Lit la topologie en cache de ZHA sans lancer d’analyse radio.",z2m:"Zigbee2MQTT",z2m_topics:"Topics de base (un par ligne)",z2m_update:"Actualiser la carte",z2m_warning:"L’analyse de la carte réseau peut durer de 10 secondes à 2 minutes et réduire temporairement la réactivité de Zigbee.",status_idle:"Données non chargées",status_loading:"Chargement…",status_ready:"Reçu : {time}",status_stale:"Reçu : {time} · obsolète",status_partial:"Reçu : {time} · certains nœuds sont omis",status_no_links:"Reçu : {time} · aucun lien observé trouvé",error_permission:"Les droits administrateur sont requis.",error_unsupported:"Ce fournisseur ou l’API Home Assistant n’est pas disponible.",error_timeout:"Le fournisseur n’a pas répondu à temps.",error_invalid_topic:"Vérifiez le topic de base Zigbee2MQTT.",error_invalid_payload:"Le fournisseur a renvoyé des données de topologie non prises en charge.",error_provider:"Impossible de charger les données de topologie.",remote_count:"+{n} dans d’autres espaces",route_device_not_on_plan:"appareil absent du plan",route_coordinator_not_on_plan:"coordinateur absent du plan",route_other_space:"autre espace"}};function r(e,n){const r=i[e]?.[n]??t[n];return"string"==typeof r&&r.trim().length>0}function o(n,r,o){return e(i[n]?.[r]??t[r]??r,o)}const s=3e5,a=2097152,d=6e3;function l(e){return null!==e&&"object"==typeof e?e:null}function u(e){if("string"!=typeof e&&"number"!=typeof e)return null;let n=String(e).trim().toLowerCase();return n=/^0x[0-9a-f]{16}$/.test(n)?n.slice(2):n.replace(/[:-]/g,""),/^[0-9a-f]{16}$/.test(n)?n:null}function c(e,n,t){return`${e}:${n}:${t}`}function p(e){const n=String(e||"").toLowerCase().replace(/[ _-]/g,"");return n.includes("coordinator")?"coordinator":n.includes("router")?"router":n.includes("enddevice")||"end"===n?"end":"unknown"}const h=["parent","child","sibling","none","previous_child"];function g(e){const n=l(e),t=function(e){const n=Number(e);return Number.isFinite(n)&&n>=0&&n<=255?Math.round(n):void 0}(n?.lqi??n?.linkquality??n?.link_quality),i=function(e){if("number"==typeof e)return h[e];if("string"!=typeof e)return;const n=e.trim().toLowerCase().replace(/[\s_-]+/g,"");return"previouschild"===n?"previous_child":n.slice(0,40)||void 0}(n?.relationship);return{...void 0===t?{}:{lqi:t},...i?{relationship:i}:{}}}function f(e,n){return Array.isArray(e)&&e.length<=n?e:null}function _(e){if("string"==typeof e)return e.length<=a;try{return JSON.stringify(e).length<=a}catch{return!1}}function b(e,n,t,i,r){if(t===i)return void n.push({code:"self_link",nodeKey:t});const o=t=d){t.push({code:"invalid_payload"});break}const n=l(e),i=u(n?.ieee??n?.ieee_address);if(!i){t.push({code:"invalid_payload",nodeKey:s});continue}const a=c("zha","zha",i);r.has(a)||r.set(a,{key:a,ieee:i,role:p(n?.device_type)}),b(o,t,s,a,e)}else null!=n?.neighbors&&t.push({code:"invalid_payload",nodeKey:s})}return{provider:"zha",instanceId:"zha",obtainedAt:n,freshness:"provider-cache",nodes:[...r.values()],links:[...o.values()],warnings:t}}function v(e,n){const t=l(e),i=u(t?.ieeeAddr??t?.ieee_address??t?.ieee??e);if(i)return i;for(const i of[t?.id,t?.networkAddress,t?.network_address,e])if(null!=i){const e=n.get(String(i));if(e)return e}return null}function y(e,t,i=Date.now()){const r=[],o=n(t)||"invalid",s=_(e)?function(e){let n=e;if("string"==typeof n){if(n.length>a)return null;try{n=JSON.parse(n)}catch{return null}}const t=l(n),i=l(t?.data);if(n=i?.value??t?.value??t?.data??n,"string"==typeof n){if(n.length>a)return null;try{n=JSON.parse(n)}catch{return null}}return n}(e):null,h=l(s),g=f(h?.nodes,1e3),m=f(h?.links,d);if(!g||!m)return{provider:"z2m",instanceId:o,obtainedAt:i,freshness:"fresh-scan",nodes:[],links:[],warnings:[{code:"invalid_payload"}]};const y=new Map,k=new Map;for(const e of g){const n=l(e),t=u(n?.ieeeAddr??n?.ieee_address??n?.ieee);if(!t){r.push({code:"invalid_payload"});continue}const i=c("z2m",o,t);y.set(i,{key:i,ieee:t,role:p(n?.type??n?.device_type),..."boolean"==typeof n?.failed?{available:!n.failed}:{}});for(const e of[n?.id,n?.networkAddress,n?.network_address])null!=e&&k.set(String(e),t)}const w=new Map;for(const e of m){const n=l(e),t=u(n?.sourceIeeeAddr)??v(n?.source,k),i=u(n?.targetIeeeAddr)??v(n?.target,k);if(!t||!i){r.push({code:"invalid_payload"});continue}const s=c("z2m",o,t),a=c("z2m",o,i);y.has(s)||y.set(s,{key:s,ieee:t,role:"unknown"}),y.has(a)||y.set(a,{key:a,ieee:i,role:"unknown"}),b(w,r,s,a,e)}return{provider:"z2m",instanceId:o,obtainedAt:i,freshness:"fresh-scan",nodes:[...y.values()],links:[...w.values()],warnings:r}}function k(e){if("string"!=typeof e)return null;const n=u(e);if(n)return n;const t=e.toLowerCase().match(/^zigbee2mqtt(?:_bridge)?_(.+)$/);return t?u(t[1]):null}function w(e,n){if(e.deviceId&&n.devices[e.deviceId])return[e.deviceId];const t=new Set;for(const[i,r]of Object.entries(n.devices)){const n=l(r);(Array.isArray(n?.identifiers)?n.identifiers:[]).some(n=>Array.isArray(n)&&k(n[1])===e.ieee)&&t.add(i)}if(t.size)return[...t];for(const i of Object.values(n.entities)){const n=l(i);"string"==typeof n?.device_id&&"string"==typeof n.unique_id&&(k(n.unique_id)===e.ieee&&t.add(n.device_id))}return[...t]}function z(e){return!e.hidden&&!e.virtual&&"ha_disabled"!==e.bindingStatus?.kind&&"orphaned"!==e.bindingStatus?.kind&&"unverified"!==e.bindingStatus?.kind}function A(e){const n=new Map,t=new Map,i=e.nodes.filter(e=>"coordinator"===e.role).map(e=>e.key).sort();if(1!==i.length)return{distances:n,parents:t};const r=i[0],o=function(e){const n=new Set(e.nodes.map(e=>e.key)),t=new Map;for(const e of[...n].sort())t.set(e,[]);for(const i of[...e.links].sort((e,n)=>`${e.a}\0${e.b}`.localeCompare(`${n.a}\0${n.b}`)))n.has(i.a)&&n.has(i.b)&&(t.get(i.a).push({neighborKey:i.b,observation:i.aToB}),t.get(i.b).push({neighborKey:i.a,observation:i.bToA}));for(const e of t.values())e.sort((e,n)=>e.neighborKey.localeCompare(n.neighborKey));return t}(e);if(!o.has(r))return{distances:n,parents:t};n.set(r,0);const s=[r];for(let e=0;en.get(e)===i-1).sort((e,n)=>{const t="parent"===e.observation?.relationship?1:0,i="parent"===n.observation?.relationship?1:0;if(t!==i)return i-t;const r=e.observation?.lqi??-1;return(n.observation?.lqi??-1)-r||e.neighborKey.localeCompare(n.neighborKey)});r[0]&&t.set(e,r[0].neighborKey)}return{coordinatorKey:r,distances:n,parents:t}}function Z(e,n,t){const i=new Map,r=[];for(const o of e.nodes){if(!1===o.available){r.push({code:"provider_scan_failure",nodeKey:o.key});continue}const e=w(o,t);if(1!==e.length){r.push({code:"unmatched_device",nodeKey:o.key});continue}const s=e[0];let a=n.filter(e=>z(e)&&"device"===e.bindingKind&&e.bindingRef===s);a.length||(a=n.filter(e=>z(e)&&"entity"===e.bindingKind&&!!e.bindingRef&&t.entities[e.bindingRef]?.device_id===s)),1===a.length?i.set(o.key,{markerId:a[0].id,space:a[0].space}):r.push({code:a.length>1?"ambiguous_placement":"unmatched_device",nodeKey:o.key})}return{placements:i,warnings:r}}function T(e,n,t){return e.map(e=>({topology:e,placements:Z(e,n,t).placements,routes:A(e)}))}function q(e,n,t){const i=new Map,r=new Set,o=new Map;let s=0;for(const{topology:a,placements:d,routes:l}of e){const e=new Set([...d].filter(([,e])=>e.markerId===t&&e.space===n).map(([e])=>e));if(e.size){for(const t of e){const e=l.parents.get(t);if(!e)continue;const i=d.get(e);if(i?.space===n)continue;let r;r=i?{kind:"remote-space",spaceId:i.space}:"coordinator"===a.nodes.find(n=>n.key===e)?.role?{kind:"unplaced-coordinator"}:{kind:"unplaced-device"};const s="remote-space"===r.kind?`${r.kind}:${r.spaceId}`:r.kind;o.set(s,r)}for(const o of a.links){const a=e.has(o.a),u=e.has(o.b);if(!a&&!u)continue;const c=a?o.a:o.b,p=a?o.b:o.a,h=d.get(p);if(!h||h.markerId===t){s++;continue}const g=l.parents.get(c)===p;if(h.space!==n){g||r.add(h.markerId);continue}const f=a?o.aToB:o.bToA,_=g?"toward-neighbor":l.parents.get(p)===c?"toward-origin":void 0,b=i.get(h.markerId);b?(void 0===b.line.lqi&&void 0!==f?.lqi&&(b.line.lqi=f.lqi),_&&b.directions.add(_)):i.set(h.markerId,{line:{neighborMarkerId:h.markerId,lqi:f?.lqi},directions:new Set(_?[_]:[])})}}}return{lines:[...i.values()].map(({line:e,directions:n})=>1===n.size?{...e,routeDirection:[...n][0]}:e),remoteCount:r.size,omittedCount:s,parentTargets:[...o.values()]}}export{s as T,T as a,y as b,r as h,Z as m,m as n,q as r,o as t}; +globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="d31b0b1e184ab2863684b758f839bdb6809a33cc742c6e9bb36c5ea034e3d309";import{s as e,aR as n}from"./houseplan-card-W9mG3gab.js";var t={title:"Zigbee links",toggle:"Show Zigbee links when hovering over a device",hint:"Shows observed direct neighbours only. Nothing is fetched while you hover.",help:"Shows which Zigbee devices each device talks to directly. Line colour is link quality (LQI) on the same scale as the device's LQI reading: red at 40 and below, green at 180 and above. A dashed line means quality was not reported. An arrow points to the next device on the way to the coordinator: one arrow leads out, incoming arrows are the devices that route through this one. A line without an arrow is a spare neighbour. This is the route tree House Plan builds, not the path a packet takes right now: a label at the end of an arrow means its target is not on this plan, and no arrow at all means the route is unknown. Data comes from the last load and goes stale; links are shown with a mouse only.",help_aria:"Help: Zigbee links",admin_only:"Topology data is available to Home Assistant administrators only.",save_first:"Save this setting before loading topology data.",zha:"ZHA",zha_read:"Read ZHA data",zha_hint:"Reads ZHA's cached topology; it does not start a radio scan.",z2m:"Zigbee2MQTT",z2m_topics:"Base topics (one per line)",z2m_update:"Update map",z2m_warning:"A network-map scan can take 10 seconds to 2 minutes and may temporarily reduce Zigbee responsiveness.",status_idle:"Data not loaded",status_loading:"Loading…",status_ready:"Received {time}",status_stale:"Received {time} · stale",status_partial:"Received {time} · some nodes were omitted",status_no_links:"Received {time} · no observed links found",error_permission:"Administrator permission is required.",error_unsupported:"This provider or Home Assistant API is unavailable.",error_timeout:"The provider did not respond in time.",error_invalid_topic:"Check the Zigbee2MQTT base topic.",error_invalid_payload:"The provider returned unsupported topology data.",error_provider:"Topology data could not be loaded.",remote_count:"+{n} in other spaces",route_device_not_on_plan:"device is not on the plan",route_coordinator_not_on_plan:"coordinator is not on the plan",route_other_space:"another space"};const i={en:t,ru:{title:"Связи Zigbee",toggle:"Показывать связи Zigbee при наведении на устройство",hint:"Показываются только наблюдаемые прямые соседи. Наведение ничего не запрашивает.",help:"Показывает, с какими устройствами Zigbee каждое связано напрямую. Цвет линии — качество связи (LQI) по той же шкале, что у показателя LQI устройства: красный при 40 и ниже, зелёный при 180 и выше. Пунктир — качество не сообщено. Стрелка ведёт к следующему устройству по пути к координатору: исходящая одна, входящие — те, кто ходит через это устройство. Линия без стрелки — запасной сосед. Это дерево маршрутов, которое строит House Plan, а не путь пакета в эту секунду: подпись на конце стрелки значит, что цель не на этом плане, а отсутствие стрелки — что путь неизвестен. Данные из последней загрузки и устаревают, связи видны только при работе мышью.",help_aria:"Справка: связи Zigbee",admin_only:"Данные топологии доступны только администраторам Home Assistant.",save_first:"Сохраните настройку перед загрузкой данных топологии.",zha:"ZHA",zha_read:"Прочитать данные ZHA",zha_hint:"Читает сохранённую топологию ZHA и не запускает радио-сканирование.",z2m:"Zigbee2MQTT",z2m_topics:"Базовые топики (по одному в строке)",z2m_update:"Обновить карту",z2m_warning:"Сканирование карты сети занимает от 10 секунд до 2 минут и временно может снизить отзывчивость Zigbee.",status_idle:"Данные не загружены",status_loading:"Загрузка…",status_ready:"Получено: {time}",status_stale:"Получено: {time} · данные устарели",status_partial:"Получено: {time} · часть узлов не показана",status_no_links:"Получено: {time} · наблюдаемые связи не найдены",error_permission:"Нужны права администратора.",error_unsupported:"Провайдер или API Home Assistant недоступен.",error_timeout:"Провайдер не ответил вовремя.",error_invalid_topic:"Проверьте базовый топик Zigbee2MQTT.",error_invalid_payload:"Провайдер вернул неподдерживаемые данные топологии.",error_provider:"Не удалось загрузить данные топологии.",remote_count:"+{n} в других пространствах",route_device_not_on_plan:"устройства нет на плане",route_coordinator_not_on_plan:"координатора нет на плане",route_other_space:"другое пространство"},de:{title:"Zigbee-Verbindungen",toggle:"Zigbee-Verbindungen beim Darüberfahren über ein Gerät anzeigen",hint:"Es werden nur beobachtete direkte Nachbarn angezeigt. Beim Darüberfahren werden keine Daten abgerufen.",help:"Zeigt, mit welchen Zigbee-Geräten jedes Gerät direkt verbunden ist. Die Linienfarbe ist die Verbindungsqualität (LQI) auf derselben Skala wie der LQI-Wert des Geräts: rot bei 40 und darunter, grün bei 180 und darüber. Eine gestrichelte Linie bedeutet, dass die Qualität nicht gemeldet wurde. Ein Pfeil zeigt auf das nächste Gerät auf dem Weg zum Koordinator: ein Pfeil führt hinaus, eingehende Pfeile sind die Geräte, die über dieses Gerät routen. Eine Linie ohne Pfeil ist ein Ersatznachbar. Das ist der Routenbaum, den House Plan bildet, nicht der Weg eines Pakets in diesem Moment: eine Beschriftung am Pfeilende bedeutet, dass das Ziel nicht auf diesem Plan liegt, und ein fehlender Pfeil, dass die Route unbekannt ist. Die Daten stammen aus dem letzten Laden und veralten; Verbindungen sind nur mit der Maus sichtbar.",help_aria:"Hilfe: Zigbee-Verbindungen",admin_only:"Topologiedaten sind nur für Home-Assistant-Administratoren verfügbar.",save_first:"Speichere diese Einstellung, bevor Topologiedaten geladen werden.",zha:"ZHA",zha_read:"ZHA-Daten lesen",zha_hint:"Liest den ZHA-Topologiecache; es wird kein Funkscan gestartet.",z2m:"Zigbee2MQTT",z2m_topics:"Basistopics (eines pro Zeile)",z2m_update:"Karte aktualisieren",z2m_warning:"Ein Netzwerkscan kann 10 Sekunden bis 2 Minuten dauern und Zigbee vorübergehend verlangsamen.",status_idle:"Daten nicht geladen",status_loading:"Wird geladen…",status_ready:"Empfangen: {time}",status_stale:"Empfangen: {time} · veraltet",status_partial:"Empfangen: {time} · einige Knoten fehlen",status_no_links:"Empfangen: {time} · keine beobachteten Verbindungen gefunden",error_permission:"Administratorrechte sind erforderlich.",error_unsupported:"Dieser Anbieter oder die Home-Assistant-API ist nicht verfügbar.",error_timeout:"Der Anbieter hat nicht rechtzeitig geantwortet.",error_invalid_topic:"Prüfe das Zigbee2MQTT-Basistopic.",error_invalid_payload:"Der Anbieter hat nicht unterstützte Topologiedaten geliefert.",error_provider:"Topologiedaten konnten nicht geladen werden.",remote_count:"+{n} in anderen Bereichen",route_device_not_on_plan:"Gerät ist nicht im Plan",route_coordinator_not_on_plan:"Koordinator ist nicht im Plan",route_other_space:"anderer Bereich"},fr:{title:"Liens Zigbee",toggle:"Afficher les liens Zigbee au survol d’un appareil",hint:"Seuls les voisins directs observés sont affichés. Le survol ne lance aucune requête.",help:"Montre avec quels appareils Zigbee chaque appareil communique directement. La couleur de la ligne est la qualité du lien (LQI) sur la même échelle que l'indicateur LQI de l'appareil : rouge à 40 et en dessous, vert à 180 et au-dessus. Une ligne pointillée signifie que la qualité n'a pas été communiquée. Une flèche pointe vers l'appareil suivant sur le chemin du coordinateur : une flèche part, les flèches entrantes sont les appareils qui passent par celui-ci. Une ligne sans flèche est un voisin de secours. C'est l'arbre de routes que construit House Plan, pas le trajet d'un paquet à cet instant : une étiquette au bout d'une flèche signifie que sa cible n'est pas sur ce plan, et l'absence de flèche que la route est inconnue. Les données proviennent du dernier chargement et vieillissent ; les liens ne sont visibles qu'à la souris.",help_aria:"Aide : liens Zigbee",admin_only:"Les données de topologie sont réservées aux administrateurs Home Assistant.",save_first:"Enregistrez ce réglage avant de charger les données de topologie.",zha:"ZHA",zha_read:"Lire les données ZHA",zha_hint:"Lit la topologie en cache de ZHA sans lancer d’analyse radio.",z2m:"Zigbee2MQTT",z2m_topics:"Topics de base (un par ligne)",z2m_update:"Actualiser la carte",z2m_warning:"L’analyse de la carte réseau peut durer de 10 secondes à 2 minutes et réduire temporairement la réactivité de Zigbee.",status_idle:"Données non chargées",status_loading:"Chargement…",status_ready:"Reçu : {time}",status_stale:"Reçu : {time} · obsolète",status_partial:"Reçu : {time} · certains nœuds sont omis",status_no_links:"Reçu : {time} · aucun lien observé trouvé",error_permission:"Les droits administrateur sont requis.",error_unsupported:"Ce fournisseur ou l’API Home Assistant n’est pas disponible.",error_timeout:"Le fournisseur n’a pas répondu à temps.",error_invalid_topic:"Vérifiez le topic de base Zigbee2MQTT.",error_invalid_payload:"Le fournisseur a renvoyé des données de topologie non prises en charge.",error_provider:"Impossible de charger les données de topologie.",remote_count:"+{n} dans d’autres espaces",route_device_not_on_plan:"appareil absent du plan",route_coordinator_not_on_plan:"coordinateur absent du plan",route_other_space:"autre espace"}};function r(e,n){const r=i[e]?.[n]??t[n];return"string"==typeof r&&r.trim().length>0}function o(n,r,o){return e(i[n]?.[r]??t[r]??r,o)}const s=3e5,a=2097152,d=6e3;function l(e){return null!==e&&"object"==typeof e?e:null}function u(e){if("string"!=typeof e&&"number"!=typeof e)return null;let n=String(e).trim().toLowerCase();return n=/^0x[0-9a-f]{16}$/.test(n)?n.slice(2):n.replace(/[:-]/g,""),/^[0-9a-f]{16}$/.test(n)?n:null}function c(e,n,t){return`${e}:${n}:${t}`}function p(e){const n=String(e||"").toLowerCase().replace(/[ _-]/g,"");return n.includes("coordinator")?"coordinator":n.includes("router")?"router":n.includes("enddevice")||"end"===n?"end":"unknown"}const h=["parent","child","sibling","none","previous_child"];function g(e){const n=l(e),t=function(e){const n=Number(e);return Number.isFinite(n)&&n>=0&&n<=255?Math.round(n):void 0}(n?.lqi??n?.linkquality??n?.link_quality),i=function(e){if("number"==typeof e)return h[e];if("string"!=typeof e)return;const n=e.trim().toLowerCase().replace(/[\s_-]+/g,"");return"previouschild"===n?"previous_child":n.slice(0,40)||void 0}(n?.relationship);return{...void 0===t?{}:{lqi:t},...i?{relationship:i}:{}}}function f(e,n){return Array.isArray(e)&&e.length<=n?e:null}function _(e){if("string"==typeof e)return e.length<=a;try{return JSON.stringify(e).length<=a}catch{return!1}}function b(e,n,t,i,r){if(t===i)return void n.push({code:"self_link",nodeKey:t});const o=t=d){t.push({code:"invalid_payload"});break}const n=l(e),i=u(n?.ieee??n?.ieee_address);if(!i){t.push({code:"invalid_payload",nodeKey:s});continue}const a=c("zha","zha",i);r.has(a)||r.set(a,{key:a,ieee:i,role:p(n?.device_type)}),b(o,t,s,a,e)}else null!=n?.neighbors&&t.push({code:"invalid_payload",nodeKey:s})}return{provider:"zha",instanceId:"zha",obtainedAt:n,freshness:"provider-cache",nodes:[...r.values()],links:[...o.values()],warnings:t}}function v(e,n){const t=l(e),i=u(t?.ieeeAddr??t?.ieee_address??t?.ieee??e);if(i)return i;for(const i of[t?.id,t?.networkAddress,t?.network_address,e])if(null!=i){const e=n.get(String(i));if(e)return e}return null}function y(e,t,i=Date.now()){const r=[],o=n(t)||"invalid",s=_(e)?function(e){let n=e;if("string"==typeof n){if(n.length>a)return null;try{n=JSON.parse(n)}catch{return null}}const t=l(n),i=l(t?.data);if(n=i?.value??t?.value??t?.data??n,"string"==typeof n){if(n.length>a)return null;try{n=JSON.parse(n)}catch{return null}}return n}(e):null,h=l(s),g=f(h?.nodes,1e3),m=f(h?.links,d);if(!g||!m)return{provider:"z2m",instanceId:o,obtainedAt:i,freshness:"fresh-scan",nodes:[],links:[],warnings:[{code:"invalid_payload"}]};const y=new Map,k=new Map;for(const e of g){const n=l(e),t=u(n?.ieeeAddr??n?.ieee_address??n?.ieee);if(!t){r.push({code:"invalid_payload"});continue}const i=c("z2m",o,t);y.set(i,{key:i,ieee:t,role:p(n?.type??n?.device_type),..."boolean"==typeof n?.failed?{available:!n.failed}:{}});for(const e of[n?.id,n?.networkAddress,n?.network_address])null!=e&&k.set(String(e),t)}const w=new Map;for(const e of m){const n=l(e),t=u(n?.sourceIeeeAddr)??v(n?.source,k),i=u(n?.targetIeeeAddr)??v(n?.target,k);if(!t||!i){r.push({code:"invalid_payload"});continue}const s=c("z2m",o,t),a=c("z2m",o,i);y.has(s)||y.set(s,{key:s,ieee:t,role:"unknown"}),y.has(a)||y.set(a,{key:a,ieee:i,role:"unknown"}),b(w,r,s,a,e)}return{provider:"z2m",instanceId:o,obtainedAt:i,freshness:"fresh-scan",nodes:[...y.values()],links:[...w.values()],warnings:r}}function k(e){if("string"!=typeof e)return null;const n=u(e);if(n)return n;const t=e.toLowerCase().match(/^zigbee2mqtt(?:_bridge)?_(.+)$/);return t?u(t[1]):null}function w(e,n){if(e.deviceId&&n.devices[e.deviceId])return[e.deviceId];const t=new Set;for(const[i,r]of Object.entries(n.devices)){const n=l(r);(Array.isArray(n?.identifiers)?n.identifiers:[]).some(n=>Array.isArray(n)&&k(n[1])===e.ieee)&&t.add(i)}if(t.size)return[...t];for(const i of Object.values(n.entities)){const n=l(i);"string"==typeof n?.device_id&&"string"==typeof n.unique_id&&(k(n.unique_id)===e.ieee&&t.add(n.device_id))}return[...t]}function z(e){return!e.hidden&&!e.virtual&&"ha_disabled"!==e.bindingStatus?.kind&&"orphaned"!==e.bindingStatus?.kind&&"unverified"!==e.bindingStatus?.kind}function A(e){const n=new Map,t=new Map,i=e.nodes.filter(e=>"coordinator"===e.role).map(e=>e.key).sort();if(1!==i.length)return{distances:n,parents:t};const r=i[0],o=function(e){const n=new Set(e.nodes.map(e=>e.key)),t=new Map;for(const e of[...n].sort())t.set(e,[]);for(const i of[...e.links].sort((e,n)=>`${e.a}\0${e.b}`.localeCompare(`${n.a}\0${n.b}`)))n.has(i.a)&&n.has(i.b)&&(t.get(i.a).push({neighborKey:i.b,observation:i.aToB}),t.get(i.b).push({neighborKey:i.a,observation:i.bToA}));for(const e of t.values())e.sort((e,n)=>e.neighborKey.localeCompare(n.neighborKey));return t}(e);if(!o.has(r))return{distances:n,parents:t};n.set(r,0);const s=[r];for(let e=0;en.get(e)===i-1).sort((e,n)=>{const t="parent"===e.observation?.relationship?1:0,i="parent"===n.observation?.relationship?1:0;if(t!==i)return i-t;const r=e.observation?.lqi??-1;return(n.observation?.lqi??-1)-r||e.neighborKey.localeCompare(n.neighborKey)});r[0]&&t.set(e,r[0].neighborKey)}return{coordinatorKey:r,distances:n,parents:t}}function Z(e,n,t){const i=new Map,r=[];for(const o of e.nodes){if(!1===o.available){r.push({code:"provider_scan_failure",nodeKey:o.key});continue}const e=w(o,t);if(1!==e.length){r.push({code:"unmatched_device",nodeKey:o.key});continue}const s=e[0];let a=n.filter(e=>z(e)&&"device"===e.bindingKind&&e.bindingRef===s);a.length||(a=n.filter(e=>z(e)&&"entity"===e.bindingKind&&!!e.bindingRef&&t.entities[e.bindingRef]?.device_id===s)),1===a.length?i.set(o.key,{markerId:a[0].id,space:a[0].space}):r.push({code:a.length>1?"ambiguous_placement":"unmatched_device",nodeKey:o.key})}return{placements:i,warnings:r}}function T(e,n,t){return e.map(e=>({topology:e,placements:Z(e,n,t).placements,routes:A(e)}))}function q(e,n,t){const i=new Map,r=new Set,o=new Map;let s=0;for(const{topology:a,placements:d,routes:l}of e){const e=new Set([...d].filter(([,e])=>e.markerId===t&&e.space===n).map(([e])=>e));if(e.size){for(const t of e){const e=l.parents.get(t);if(!e)continue;const i=d.get(e);if(i?.space===n)continue;let r;r=i?{kind:"remote-space",spaceId:i.space}:"coordinator"===a.nodes.find(n=>n.key===e)?.role?{kind:"unplaced-coordinator"}:{kind:"unplaced-device"};const s="remote-space"===r.kind?`${r.kind}:${r.spaceId}`:r.kind;o.set(s,r)}for(const o of a.links){const a=e.has(o.a),u=e.has(o.b);if(!a&&!u)continue;const c=a?o.a:o.b,p=a?o.b:o.a,h=d.get(p);if(!h||h.markerId===t){s++;continue}const g=l.parents.get(c)===p;if(h.space!==n){g||r.add(h.markerId);continue}const f=a?o.aToB:o.bToA,_=g?"toward-neighbor":l.parents.get(p)===c?"toward-origin":void 0,b=i.get(h.markerId);b?(void 0===b.line.lqi&&void 0!==f?.lqi&&(b.line.lqi=f.lqi),_&&b.directions.add(_)):i.set(h.markerId,{line:{neighborMarkerId:h.markerId,lqi:f?.lqi},directions:new Set(_?[_]:[])})}}}return{lines:[...i.values()].map(({line:e,directions:n})=>1===n.size?{...e,routeDirection:[...n][0]}:e),remoteCount:r.size,omittedCount:s,parentTargets:[...o.values()]}}export{s as T,T as a,y as b,r as h,Z as m,m as n,q as r,o as t}; diff --git a/dist/houseplan-assets/zigbee-topology-runtime-CuXFHyzq.js b/dist/houseplan-assets/zigbee-topology-runtime-DvCmPEhl.js similarity index 83% rename from dist/houseplan-assets/zigbee-topology-runtime-CuXFHyzq.js rename to dist/houseplan-assets/zigbee-topology-runtime-DvCmPEhl.js index 893c2c21..88ccfdcd 100644 --- a/dist/houseplan-assets/zigbee-topology-runtime-CuXFHyzq.js +++ b/dist/houseplan-assets/zigbee-topology-runtime-DvCmPEhl.js @@ -1 +1 @@ -globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db7c58754eeb4ba03f835b8d7c84c6";import{n as t,b as n}from"./zigbee-topology-B31-i8CL.js";import{aR as e}from"./houseplan-card-BiUNLHFh.js";const o=new WeakMap;function i(t){const n=function(t){const n=t?.connection||t;return!n||"object"!=typeof n&&"function"!=typeof n?null:n}(t);if(!n)return null;let e=o.get(n);return e||(e={revision:0,topologies:[],states:{},listeners:new Set,inflight:new Map},o.set(n,e)),e}function r(t,n,e){t.states={...t.states,[n]:e},function(t){t.revision++;for(const n of t.listeners)n()}(t)}function s(t){const n=t?.code;if("permission"===n||"unsupported"===n||"timeout"===n||"invalid_topic"===n||"invalid_payload"===n)return n;const e=String(t?.message||"").toLowerCase();return e.includes("unauthor")||e.includes("permission")?"permission":e.includes("unknown_command")||e.includes("not found")?"unsupported":"provider"}function a(t){return Object.assign(new Error(t),{code:t})}function c(t,n,e){const o=t.inflight.get(n);if(o)return o;r(t,n,{phase:"loading"});const i=e().then(n=>{if(!n.nodes.length&&n.warnings.some(t=>"invalid_payload"===t.code))throw a("invalid_payload");!function(t,n){t.topologies=[...t.topologies.filter(t=>!(t.provider===n.provider&&t.instanceId===n.instanceId)),n],r(t,"zha"===n.provider?"zha":`z2m:${n.instanceId}`,{phase:"ready",obtainedAt:n.obtainedAt,partial:n.warnings.length>0})}(t,n)}).catch(e=>{r(t,n,{phase:"error",error:s(e)})}).finally(()=>t.inflight.delete(n));return t.inflight.set(n,i),i}function l(t){const n=i(t);return n?{revision:n.revision,topologies:n.topologies,states:n.states}:{revision:0,topologies:[],states:{}}}function u(t,n){const e=i(t);return e?(e.listeners.add(n),()=>e.listeners.delete(n)):()=>{}}function p(t){if(!0!==t?.user?.is_admin)throw a("permission")}function f(n){const e=i(n);return e?c(e,"zha",async()=>{if(p(n),"function"!=typeof n?.callWS)throw a("unsupported");return t(await n.callWS({type:"zha/devices"}))}):Promise.resolve()}function d(t){return null!==t&&"object"==typeof t?t:null}function h(t){const n=d(t),e=n?.payload??t;if("string"!=typeof e)return e;try{return JSON.parse(e)}catch{return null}}async function g(t,n){let e;try{return await Promise.race([t,new Promise((t,o)=>{e=globalThis.setTimeout(()=>o(a("timeout")),Math.max(1,n))})])}finally{void 0!==e&&globalThis.clearTimeout(e)}}function m(t,o,r=15e4){const s=i(t);if(!s)return Promise.resolve();const l=e(o);return c(s,`z2m:${l||String(o)}`,async()=>{if(p(t),!l)throw a("invalid_topic");const e=t.connection,o=e?.subscribeMessage;if("function"!=typeof o||"function"!=typeof t?.callService)throw a("unsupported");const i=function(){const t=globalThis.crypto;return"function"==typeof t?.randomUUID?`houseplan-${t.randomUUID()}`:`houseplan-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}(),s=Date.now()+Math.max(1,r);let c=!1,u=null,f=null,m=null;const y=new Promise(t=>{u=t}),b=new Promise((t,n)=>{f=t,m=n}),w=[];try{const r=await o.call(e,t=>{!0===d(t)?.retain&&h(t)&&u?.()},{type:"mqtt/subscribe",topic:`${l}/bridge/info`});"function"==typeof r&&w.push(r);const p=await o.call(e,t=>{if(!0===d(t)?.retain)return;const n=h(t);null!==n?n&&function(t){const n=d(t),e=n?.transaction??d(n?.data)?.transaction;return"string"==typeof e||"number"==typeof e?String(e):null}(n)===i&&f?.(n):c&&m?.(a("invalid_payload"))},{type:"mqtt/subscribe",topic:`${l}/bridge/response/networkmap`});"function"==typeof p&&w.push(p),await g(y,Math.min(4e3,Math.max(1,s-Date.now()))),c=!0,await t.callService("mqtt","publish",{topic:`${l}/bridge/request/networkmap`,payload:JSON.stringify({type:"raw",routes:!1,transaction:i}),qos:0,retain:!1});const v=await g(b,s-Date.now()),_=d(v)?.status;if(_&&"ok"!==_)throw a("provider");return n(v,l)}finally{for(const t of w)try{t()}catch{}}})}export{f as readZhaTopology,m as refreshZ2mTopology,u as subscribeZigbeeTopology,l as zigbeeTopologyRuntimeSnapshot}; +globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="d31b0b1e184ab2863684b758f839bdb6809a33cc742c6e9bb36c5ea034e3d309";import{n as t,b as n}from"./zigbee-topology-3KJks91U.js";import{aR as e}from"./houseplan-card-W9mG3gab.js";const o=new WeakMap;function i(t){const n=function(t){const n=t?.connection||t;return!n||"object"!=typeof n&&"function"!=typeof n?null:n}(t);if(!n)return null;let e=o.get(n);return e||(e={revision:0,topologies:[],states:{},listeners:new Set,inflight:new Map},o.set(n,e)),e}function r(t,n,e){t.states={...t.states,[n]:e},function(t){t.revision++;for(const n of t.listeners)n()}(t)}function s(t){const n=t?.code;if("permission"===n||"unsupported"===n||"timeout"===n||"invalid_topic"===n||"invalid_payload"===n)return n;const e=String(t?.message||"").toLowerCase();return e.includes("unauthor")||e.includes("permission")?"permission":e.includes("unknown_command")||e.includes("not found")?"unsupported":"provider"}function a(t){return Object.assign(new Error(t),{code:t})}function c(t,n,e){const o=t.inflight.get(n);if(o)return o;r(t,n,{phase:"loading"});const i=e().then(n=>{if(!n.nodes.length&&n.warnings.some(t=>"invalid_payload"===t.code))throw a("invalid_payload");!function(t,n){t.topologies=[...t.topologies.filter(t=>!(t.provider===n.provider&&t.instanceId===n.instanceId)),n],r(t,"zha"===n.provider?"zha":`z2m:${n.instanceId}`,{phase:"ready",obtainedAt:n.obtainedAt,partial:n.warnings.length>0})}(t,n)}).catch(e=>{r(t,n,{phase:"error",error:s(e)})}).finally(()=>t.inflight.delete(n));return t.inflight.set(n,i),i}function l(t){const n=i(t);return n?{revision:n.revision,topologies:n.topologies,states:n.states}:{revision:0,topologies:[],states:{}}}function u(t,n){const e=i(t);return e?(e.listeners.add(n),()=>e.listeners.delete(n)):()=>{}}function p(t){if(!0!==t?.user?.is_admin)throw a("permission")}function f(n){const e=i(n);return e?c(e,"zha",async()=>{if(p(n),"function"!=typeof n?.callWS)throw a("unsupported");return t(await n.callWS({type:"zha/devices"}))}):Promise.resolve()}function d(t){return null!==t&&"object"==typeof t?t:null}function h(t){const n=d(t),e=n?.payload??t;if("string"!=typeof e)return e;try{return JSON.parse(e)}catch{return null}}async function g(t,n){let e;try{return await Promise.race([t,new Promise((t,o)=>{e=globalThis.setTimeout(()=>o(a("timeout")),Math.max(1,n))})])}finally{void 0!==e&&globalThis.clearTimeout(e)}}function m(t,o,r=15e4){const s=i(t);if(!s)return Promise.resolve();const l=e(o);return c(s,`z2m:${l||String(o)}`,async()=>{if(p(t),!l)throw a("invalid_topic");const e=t.connection,o=e?.subscribeMessage;if("function"!=typeof o||"function"!=typeof t?.callService)throw a("unsupported");const i=function(){const t=globalThis.crypto;return"function"==typeof t?.randomUUID?`houseplan-${t.randomUUID()}`:`houseplan-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}(),s=Date.now()+Math.max(1,r);let c=!1,u=null,f=null,m=null;const y=new Promise(t=>{u=t}),w=new Promise((t,n)=>{f=t,m=n}),b=[];try{const r=await o.call(e,t=>{!0===d(t)?.retain&&h(t)&&u?.()},{type:"mqtt/subscribe",topic:`${l}/bridge/info`});"function"==typeof r&&b.push(r);const p=await o.call(e,t=>{if(!0===d(t)?.retain)return;const n=h(t);null!==n?n&&function(t){const n=d(t),e=n?.transaction??d(n?.data)?.transaction;return"string"==typeof e||"number"==typeof e?String(e):null}(n)===i&&f?.(n):c&&m?.(a("invalid_payload"))},{type:"mqtt/subscribe",topic:`${l}/bridge/response/networkmap`});"function"==typeof p&&b.push(p),await g(y,Math.min(4e3,Math.max(1,s-Date.now()))),c=!0,await t.callService("mqtt","publish",{topic:`${l}/bridge/request/networkmap`,payload:JSON.stringify({type:"raw",routes:!1,transaction:i}),qos:0,retain:!1});const v=await g(w,s-Date.now()),_=d(v)?.status;if(_&&"ok"!==_)throw a("provider");return n(v,l)}finally{for(const t of b)try{t()}catch{}}})}export{f as readZhaTopology,m as refreshZ2mTopology,u as subscribeZigbeeTopology,l as zigbeeTopologyRuntimeSnapshot}; diff --git a/dist/houseplan-card.js b/dist/houseplan-card.js index 507fbb06..118f9cb4 100644 --- a/dist/houseplan-card.js +++ b/dist/houseplan-card.js @@ -1 +1 @@ -globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db7c58754eeb4ba03f835b8d7c84c6";try{await import("./houseplan-assets/houseplan-card-BiUNLHFh.js")}catch(e){if(!customElements.get("houseplan-card")){const l=String(navigator.language||"en").toLowerCase();const m=l.startsWith("ru")?"House Plan обновился — перезагрузите страницу (Ctrl+F5).":l.startsWith("de")?"House Plan wurde aktualisiert — bitte laden Sie die Seite neu (Strg+F5).":l.startsWith("fr")?"House Plan a été mis à jour — veuillez recharger la page (Ctrl+F5).":"House Plan was updated — please reload the page (Ctrl+F5).";customElements.define("houseplan-card",class extends HTMLElement{setConfig(){}getCardSize(){return 1}connectedCallback(){this.style.cssText="display:block;box-sizing:border-box;padding:16px;border:1px solid var(--divider-color,#e0e0e0);border-radius:var(--ha-card-border-radius,12px);background:var(--card-background-color,#fff);color:var(--primary-text-color,#212121);font:14px/1.4 var(--paper-font-body1_-_font-family,sans-serif)";this.textContent=m}})}console.error("[houseplan] stale houseplan-card.js: the implementation chunk is unavailable",e)} +globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="d31b0b1e184ab2863684b758f839bdb6809a33cc742c6e9bb36c5ea034e3d309";try{await import("./houseplan-assets/houseplan-card-W9mG3gab.js")}catch(e){if(!customElements.get("houseplan-card")){const l=String(navigator.language||"en").toLowerCase();const m=l.startsWith("ru")?"House Plan обновился — перезагрузите страницу (Ctrl+F5).":l.startsWith("de")?"House Plan wurde aktualisiert — bitte laden Sie die Seite neu (Strg+F5).":l.startsWith("fr")?"House Plan a été mis à jour — veuillez recharger la page (Ctrl+F5).":"House Plan was updated — please reload the page (Ctrl+F5).";customElements.define("houseplan-card",class extends HTMLElement{setConfig(){}getCardSize(){return 1}connectedCallback(){this.style.cssText="display:block;box-sizing:border-box;padding:16px;border:1px solid var(--divider-color,#e0e0e0);border-radius:var(--ha-card-border-radius,12px);background:var(--card-background-color,#fff);color:var(--primary-text-color,#212121);font:14px/1.4 var(--paper-font-body1_-_font-family,sans-serif)";this.textContent=m}})}console.error("[houseplan] stale houseplan-card.js: the implementation chunk is unavailable",e)} diff --git a/dist/houseplan-panel.js b/dist/houseplan-panel.js index c4075593..88256dbf 100644 --- a/dist/houseplan-panel.js +++ b/dist/houseplan-panel.js @@ -1 +1 @@ -globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="ed91b3971428d2b8e7bfceb8025d2be4c0db7c58754eeb4ba03f835b8d7c84c6";try{await import("./houseplan-assets/houseplan-card-BiUNLHFh.js")}catch(e){if(!customElements.get("houseplan-panel")){const l=String(navigator.language||"en").toLowerCase();const m=l.startsWith("ru")?"House Plan обновился — перезагрузите страницу (Ctrl+F5).":l.startsWith("de")?"House Plan wurde aktualisiert — bitte laden Sie die Seite neu (Strg+F5).":l.startsWith("fr")?"House Plan a été mis à jour — veuillez recharger la page (Ctrl+F5).":"House Plan was updated — please reload the page (Ctrl+F5).";customElements.define("houseplan-panel",class extends HTMLElement{connectedCallback(){this.style.cssText="display:block;box-sizing:border-box;padding:16px;min-height:100%;background:var(--card-background-color,#fff);color:var(--primary-text-color,#212121);font:14px/1.4 var(--paper-font-body1_-_font-family,sans-serif)";this.textContent=m}})}console.error("[houseplan] stale houseplan-panel.js: the card implementation chunk is unavailable",e)}const e=["panel","hass","narrow","route"];class n extends HTMLElement{constructor(){super(),this._narrow=!1,this.attachShadow({mode:"open"}),this._adoptPreUpgradeProperties()}connectedCallback(){this._adoptPreUpgradeProperties(),this._ensureShell()}_adoptPreUpgradeProperties(){for(const n of e){if(!Object.prototype.hasOwnProperty.call(this,n))continue;const e=this[n];delete this[n],this[n]=e}}get hass(){return this._hass}set hass(e){this._hass=e,this._ensureShell(),this._card&&(this._card.hass=e),this._syncMenuLabel()}get narrow(){return this._narrow}set narrow(e){this._narrow=Boolean(e),this.toggleAttribute("narrow",this._narrow),this._card&&(this._card.narrow=this._narrow)}get route(){return this._route}set route(e){this._route=e}get panel(){return this._panel}set panel(e){this._panel=e}_ensureShell(){if(this._card||!this.shadowRoot)return;const e=document.createElement("style");e.textContent="\n :host {\n display: block;\n width: 100%;\n /* HA mounts a custom panel inside , a block with\n * safe-area padding and NO height, so a percentage here resolves to\n * auto and the stage collapses to 0 px (#488). Take the viewport\n * like HA's own iframe panels do, minus the insets HA pads with. */\n height: 100vh;\n height: calc(100dvh - var(--safe-area-inset-top, 0px) - var(--safe-area-inset-bottom, 0px));\n min-width: 0;\n min-height: 0;\n overflow: hidden;\n color: var(--primary-text-color);\n background: var(--primary-background-color);\n }\n .page {\n width: 100%;\n height: 100%;\n min-width: 0;\n min-height: 0;\n display: grid;\n grid-template-rows: auto minmax(0, 1fr);\n overflow: hidden;\n }\n .appbar {\n box-sizing: border-box;\n min-width: 0;\n min-height: var(--header-height, 56px);\n display: flex;\n align-items: center;\n gap: 12px;\n padding: 0 16px;\n background: var(--app-header-background-color, var(--primary-background-color));\n color: var(--app-header-text-color, var(--primary-text-color));\n border-bottom: 1px solid var(--divider-color);\n z-index: 1;\n }\n .toolbar {\n min-width: 0;\n width: 100%;\n display: flex;\n align-items: center;\n gap: 12px;\n }\n .menu {\n box-sizing: border-box;\n width: 44px;\n height: 44px;\n min-width: 44px;\n min-height: 44px;\n margin: 0;\n padding: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n border: 0;\n border-radius: 50%;\n color: inherit;\n background: transparent;\n cursor: pointer;\n }\n .menu:focus-visible {\n outline: 2px solid var(--primary-color);\n outline-offset: 2px;\n }\n @media (hover: hover) {\n .menu:hover { background: var(--secondary-background-color); }\n }\n .menu ha-icon { --mdc-icon-size: 24px; }\n .title {\n min-width: 0;\n display: flex;\n align-items: center;\n gap: 10px;\n font-size: 20px;\n font-weight: 500;\n line-height: 1.2;\n }\n .title ha-icon {\n --mdc-icon-size: 24px;\n color: var(--primary-color);\n }\n .content {\n min-width: 0;\n min-height: 0;\n overflow: hidden;\n }\n houseplan-card {\n width: 100%;\n height: 100%;\n min-width: 0;\n min-height: 0;\n }\n ";const n=document.createElement("div");n.className="page";const t=document.createElement("header");t.className="appbar";const a=document.createElement("div");a.className="toolbar",a.setAttribute("role","toolbar");const o=document.createElement("button");o.className="menu",o.dataset.hp="panel-menu",o.type="button",o.innerHTML='',o.addEventListener("click",()=>{o.dispatchEvent(new CustomEvent("hass-toggle-menu",{bubbles:!0,composed:!0}))}),this._menuButton=o;const i=document.createElement("div");i.className="title",i.dataset.hp="panel-title",i.setAttribute("role","heading"),i.setAttribute("aria-level","1"),i.innerHTML='House Plan',a.append(o,i),t.append(a);const r=document.createElement("main");r.className="content";const s=document.createElement("houseplan-card");s.panelHost=!0,s.narrow=this._narrow,s.setConfig({type:"custom:houseplan-card"}),void 0!==this._hass&&(s.hass=this._hass),r.append(s),n.append(t,r),this.shadowRoot.append(e,n),this._card=s,this._syncMenuLabel()}_syncMenuLabel(){if(!this._menuButton)return;const e=this._hass?.localize?.("ui.common.menu")||this._hass?.localize?.("ui.panel.lovelace.menu")||"Menu";this._menuButton.setAttribute("aria-label",e),this._menuButton.title=e}}customElements.get("houseplan-panel")||customElements.define("houseplan-panel",n);export{n as HouseplanPanel}; +globalThis.__HOUSEPLAN_BUILD_FINGERPRINT__="d31b0b1e184ab2863684b758f839bdb6809a33cc742c6e9bb36c5ea034e3d309";try{await import("./houseplan-assets/houseplan-card-W9mG3gab.js")}catch(e){if(!customElements.get("houseplan-panel")){const l=String(navigator.language||"en").toLowerCase();const m=l.startsWith("ru")?"House Plan обновился — перезагрузите страницу (Ctrl+F5).":l.startsWith("de")?"House Plan wurde aktualisiert — bitte laden Sie die Seite neu (Strg+F5).":l.startsWith("fr")?"House Plan a été mis à jour — veuillez recharger la page (Ctrl+F5).":"House Plan was updated — please reload the page (Ctrl+F5).";customElements.define("houseplan-panel",class extends HTMLElement{connectedCallback(){this.style.cssText="display:block;box-sizing:border-box;padding:16px;min-height:100%;background:var(--card-background-color,#fff);color:var(--primary-text-color,#212121);font:14px/1.4 var(--paper-font-body1_-_font-family,sans-serif)";this.textContent=m}})}console.error("[houseplan] stale houseplan-panel.js: the card implementation chunk is unavailable",e)}const e=["panel","hass","narrow","route"];class n extends HTMLElement{constructor(){super(),this._narrow=!1,this.attachShadow({mode:"open"}),this._adoptPreUpgradeProperties()}connectedCallback(){this._adoptPreUpgradeProperties(),this._ensureShell()}_adoptPreUpgradeProperties(){for(const n of e){if(!Object.prototype.hasOwnProperty.call(this,n))continue;const e=this[n];delete this[n],this[n]=e}}get hass(){return this._hass}set hass(e){this._hass=e,this._ensureShell(),this._card&&(this._card.hass=e),this._syncMenuLabel()}get narrow(){return this._narrow}set narrow(e){this._narrow=Boolean(e),this.toggleAttribute("narrow",this._narrow),this._card&&(this._card.narrow=this._narrow)}get route(){return this._route}set route(e){this._route=e}get panel(){return this._panel}set panel(e){this._panel=e}_ensureShell(){if(this._card||!this.shadowRoot)return;const e=document.createElement("style");e.textContent="\n :host {\n display: block;\n width: 100%;\n /* HA mounts a custom panel inside , a block with\n * safe-area padding and NO height, so a percentage here resolves to\n * auto and the stage collapses to 0 px (#488). Take the viewport\n * like HA's own iframe panels do, minus the insets HA pads with. */\n height: 100vh;\n height: calc(100dvh - var(--safe-area-inset-top, 0px) - var(--safe-area-inset-bottom, 0px));\n min-width: 0;\n min-height: 0;\n overflow: hidden;\n color: var(--primary-text-color);\n background: var(--primary-background-color);\n }\n .page {\n width: 100%;\n height: 100%;\n min-width: 0;\n min-height: 0;\n display: grid;\n grid-template-rows: auto minmax(0, 1fr);\n overflow: hidden;\n }\n .appbar {\n box-sizing: border-box;\n min-width: 0;\n min-height: var(--header-height, 56px);\n display: flex;\n align-items: center;\n gap: 12px;\n padding: 0 16px;\n background: var(--app-header-background-color, var(--primary-background-color));\n color: var(--app-header-text-color, var(--primary-text-color));\n border-bottom: 1px solid var(--divider-color);\n z-index: 1;\n }\n .toolbar {\n min-width: 0;\n width: 100%;\n display: flex;\n align-items: center;\n gap: 12px;\n }\n .menu {\n box-sizing: border-box;\n width: 44px;\n height: 44px;\n min-width: 44px;\n min-height: 44px;\n margin: 0;\n padding: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n border: 0;\n border-radius: 50%;\n color: inherit;\n background: transparent;\n cursor: pointer;\n }\n .menu:focus-visible {\n outline: 2px solid var(--primary-color);\n outline-offset: 2px;\n }\n @media (hover: hover) {\n .menu:hover { background: var(--secondary-background-color); }\n }\n .menu ha-icon { --mdc-icon-size: 24px; }\n .title {\n min-width: 0;\n display: flex;\n align-items: center;\n gap: 10px;\n font-size: 20px;\n font-weight: 500;\n line-height: 1.2;\n }\n .title ha-icon {\n --mdc-icon-size: 24px;\n color: var(--primary-color);\n }\n .content {\n min-width: 0;\n min-height: 0;\n overflow: hidden;\n }\n houseplan-card {\n width: 100%;\n height: 100%;\n min-width: 0;\n min-height: 0;\n }\n ";const n=document.createElement("div");n.className="page";const t=document.createElement("header");t.className="appbar";const a=document.createElement("div");a.className="toolbar",a.setAttribute("role","toolbar");const o=document.createElement("button");o.className="menu",o.dataset.hp="panel-menu",o.type="button",o.innerHTML='',o.addEventListener("click",()=>{o.dispatchEvent(new CustomEvent("hass-toggle-menu",{bubbles:!0,composed:!0}))}),this._menuButton=o;const i=document.createElement("div");i.className="title",i.dataset.hp="panel-title",i.setAttribute("role","heading"),i.setAttribute("aria-level","1"),i.innerHTML='House Plan',a.append(o,i),t.append(a);const r=document.createElement("main");r.className="content";const s=document.createElement("houseplan-card");s.panelHost=!0,s.narrow=this._narrow,s.setConfig({type:"custom:houseplan-card"}),void 0!==this._hass&&(s.hass=this._hass),r.append(s),n.append(t,r),this.shadowRoot.append(e,n),this._card=s,this._syncMenuLabel()}_syncMenuLabel(){if(!this._menuButton)return;const e=this._hass?.localize?.("ui.common.menu")||this._hass?.localize?.("ui.panel.lovelace.menu")||"Menu";this._menuButton.setAttribute("aria-label",e),this._menuButton.title=e}}customElements.get("houseplan-panel")||customElements.define("houseplan-panel",n);export{n as HouseplanPanel}; diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 0184febd..d26caf94 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -7,7 +7,10 @@ mixed with rows and paragraphs in General, and no grouping at all across the 760-line Device form. Explanations that sat as paragraphs between fields now open from a «?» next to their own heading or row. The plan background choice - became a segmented control instead of a dropdown. Values, units, field order + became a segmented control, and so did the background and zero-wall style in + Space: three short lists whose options are now visible at once instead of + hiding behind a dropdown. The remaining dropdowns in these dialogs are long + or list entities and stay dropdowns. Values, units, field order and every action are unchanged; warnings about broken settings — a missing `sun.sun` entity, or a tap target that disappeared — stay visible instead of hiding under «?» diff --git a/docs/CHANGELOG.ru.md b/docs/CHANGELOG.ru.md index 45dd972d..fd43119e 100755 --- a/docs/CHANGELOG.ru.md +++ b/docs/CHANGELOG.ru.md @@ -13,8 +13,12 @@ столбцы: в «Общих» девять подписей вперемешку с рядами и абзацами, в «Устройстве» вообще ни одного деления на 760 строк формы. Пояснения, которые лежали абзацами между полями, теперь открываются кнопкой «?» у своего - заголовка или строки. Выбор фона плана стал переключателем вместо - выпадающего списка. Значения, единицы, порядок полей и все действия прежние; + заголовка или строки. Три выбора из коротких списков — фон плана в «Общих», + фон и вид нулевой стены в «Пространстве» — стали сегментированными + переключателями вместо выпадающих списков: варианты видны сразу, попадание + пальцем не требует раскрытия. Остальные списки в этих диалогах длинные или + перечисляют сущности и остались списками. Значения, единицы, порядок полей и + все действия прежние; предупреждения о сломанных настройках — что нет сущности `sun.sun` или что выбранная цель нажатия исчезла — остались на виду, а не уехали под «?» ([#598](https://github.com/Matysh/houseplan-card/issues/598)). diff --git a/scripts/mutation-registry.mjs b/scripts/mutation-registry.mjs index 40cf919c..db434cee 100644 --- a/scripts/mutation-registry.mjs +++ b/scripts/mutation-registry.mjs @@ -10257,7 +10257,7 @@ const MUTANT_DEFINITIONS = [ }, { id: 'state-callout-hidden-under-help', - guard: 'node demo/smoke_tap_run.mjs', + guard: 'node demo/smoke_settings_dialog_cards.mjs', because: '#598 К5: «Цель {id} не найдена» — сообщение о СОСТОЯНИИ, а не пояснение. ' + 'Спрятать его под «?» заодно с шестью настоящими подсказками легко, и тогда человек ' + 'узнает о сломанном действии, только если сам откроет подсказку — а подставить туда ' @@ -10266,6 +10266,12 @@ const MUTANT_DEFINITIONS = [ file: 'src/editors/marker-dialog.ts', find: " ? html`
    ${this.host._t('marker.run_target_gone', { id: d.tapTarget })}
    `", replace: " ? html``", + }, { + // Оба сообщения о состоянии — один контракт (К5), поэтому и мутант один: + // спрятать под «?» можно каждое, и «поймано» обязано означать оба. + file: 'src/editors/general-settings-dialog.ts', + find: " ? html`
    ${this.host._t('gs.sun_missing')}
    `", + replace: " ? html``", }], }, { diff --git a/src/editors/general-settings-dialog.ts b/src/editors/general-settings-dialog.ts index 29c7b45d..2692df6b 100644 --- a/src/editors/general-settings-dialog.ts +++ b/src/editors/general-settings-dialog.ts @@ -11,7 +11,7 @@ */ import { html, nothing, type TemplateResult } from 'lit'; -import { formCard, segmented } from './form-kit'; +import { ensureFormKitStyles, formCard, segmented } from './form-kit'; import { langOf } from '../i18n'; import { supportT } from '../i18n/support'; import { DEFAULT_FILL_COLORS } from '../logic'; @@ -23,6 +23,7 @@ import type { ZigbeeTopologySettings } from '../zigbee-topology-settings'; import type { HouseplanEditorRuntime } from '../houseplan-editor-runtime'; export function renderGeneralSettingsDialog(this: HouseplanEditorRuntime): TemplateResult { + ensureFormKitStyles(this.host); return html` (this.host._settingsDialog = null)}>
    diff --git a/src/editors/marker-dialog.ts b/src/editors/marker-dialog.ts index daf6eb0c..8b92901b 100644 --- a/src/editors/marker-dialog.ts +++ b/src/editors/marker-dialog.ts @@ -7,7 +7,7 @@ */ import { html, nothing, type TemplateResult } from 'lit'; -import { formCard } from './form-kit'; +import { ensureFormKitStyles, formCard } from './form-kit'; import { resolveDevicePresentation } from '../device-presentation'; import { toggleEntityCandidates } from '../device-toggle'; @@ -35,6 +35,7 @@ const DISPLAY_HINT_KEYS: Record = { export function renderMarkerDialog(this: HouseplanEditorRuntime): TemplateResult { + ensureFormKitStyles(this.host); const d = this.host._markerDialog!; const isVirtual = d.bindingMode === 'virtual'; const cands = this._bindingCandidates(); diff --git a/src/editors/space-settings-dialog.ts b/src/editors/space-settings-dialog.ts index 2278c947..e2cfcf8c 100644 --- a/src/editors/space-settings-dialog.ts +++ b/src/editors/space-settings-dialog.ts @@ -7,7 +7,7 @@ */ import { html, nothing, type TemplateResult } from 'lit'; -import { formCard, segmented } from './form-kit'; +import { ensureFormKitStyles, formCard, segmented } from './form-kit'; import { gridCellFieldToCm, gridCellFieldValue } from '../grid-scale'; import { DEFAULT_CUSTOM_FILL, SPACE_FILL_UI_MODES, stageBgOf } from '../logic'; @@ -23,6 +23,7 @@ export const CELL_CM_MAX = 1000; export function renderSpaceSettingsDialog(this: HouseplanEditorRuntime): TemplateResult { + ensureFormKitStyles(this.host); const d = this.host._spaceDialog!; if (d.copy) return renderSpaceCopyDialog(this.host, () => { void this._saveSpaceCopy(); }); const progress = this.host._importTotal > 0 && d.mode === 'create' @@ -118,20 +119,20 @@ export function renderSpaceSettingsDialog(this: HouseplanEditorRuntime): Templat ${this._help('space.zero_wall_style.help')}
    - + }, + })}