draw-libre 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.css CHANGED
@@ -1 +1,2 @@
1
1
  .hide-panel{visibility:hidden}.undo{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='64 64 896 896' focusable='false' data-icon='undo' fill='currentColor' aria-hidden='true'%3E%3Cpath d='M511.4 124C290.5 124.3 112 303 112 523.9c0 128 60.2 242 153.8 315.2l-37.5 48c-4.1 5.3-.3 13 6.3 12.9l167-.8c5.2 0 9-4.9 7.7-9.9L369.8 727a8 8 0 00-14.1-3L315 776.1c-10.2-8-20-16.7-29.3-26a318.64 318.64 0 01-68.6-101.7C200.4 609 192 567.1 192 523.9s8.4-85.1 25.1-124.5c16.1-38.1 39.2-72.3 68.6-101.7 29.4-29.4 63.6-52.5 101.7-68.6C426.9 212.4 468.8 204 512 204s85.1 8.4 124.5 25.1c38.1 16.1 72.3 39.2 101.7 68.6 29.4 29.4 52.5 63.6 68.6 101.7 16.7 39.4 25.1 81.3 25.1 124.5s-8.4 85.1-25.1 124.5a318.64 318.64 0 01-68.6 101.7c-7.5 7.5-15.3 14.5-23.4 21.2a7.93 7.93 0 00-1.2 11.1l39.4 50.5c2.8 3.5 7.9 4.1 11.4 1.3C854.5 760.8 912 649.1 912 523.9c0-221.1-179.4-400.2-400.6-399.9z'%3E%3C/path%3E%3C/svg%3E")}.delete{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='64 64 896 896' focusable='false' data-icon='delete' fill='currentColor' aria-hidden='true'%3E%3Cpath d='M360 184h-8c4.4 0 8-3.6 8-8v8h304v-8c0 4.4 3.6 8 8 8h-8v72h72v-80c0-35.3-28.7-64-64-64H352c-35.3 0-64 28.7-64 64v80h72v-72zm504 72H160c-17.7 0-32 14.3-32 32v32c0 4.4 3.6 8 8 8h60.4l24.7 523c1.6 34.1 29.8 61 63.9 61h454c34.2 0 62.3-26.8 63.9-61l24.7-523H888c4.4 0 8-3.6 8-8v-32c0-17.7-14.3-32-32-32zM731.3 840H292.7l-24.2-512h487l-24.2 512z'%3E%3C/path%3E%3C/svg%3E")}.save{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='64 64 896 896' focusable='false' data-icon='check' fill='currentColor' aria-hidden='true'%3E%3Cpath d='M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5 207 474a32 32 0 00-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1.4-12.8-6.3-12.8z'%3E%3C/path%3E%3C/svg%3E")}.dashboard{display:flex;align-items:center}.panel-button{background-color:transparent;border:0;box-sizing:border-box;cursor:pointer;display:block;height:28px;outline:none;padding:0;width:28px}.panel-button:hover{background-color:#0000000d}.icon{background-position:50%;background-repeat:no-repeat;display:block;height:18px}.panel-button:not(:last-child) .icon{border-right:1px solid #ddd}.panel-button-small{width:20px;height:20px}.panel-button-medium{width:24px;height:24px}.panel-button-large{width:28px;height:28px}.icon-small{height:14px}.icon-medium{height:16px}.icon-large{height:18px}.popup-container{display:block;position:absolute;z-index:1000;top:0;left:0;height:50px}.popup-text{display:inline-block;padding:4px 16px;background-color:#4d4d4d;border-radius:18px;color:#fff;font-size:14px}.popup-text-bottom{opacity:0;transform:translateY(16px);transition:all .2s ease-out;transition-delay:.25s}.popup-text-left{opacity:0;transform:translate(16px);transition:all .3s ease-out}.popup-text-active{transform:translate(0);opacity:1}.line{background-image:url("data:image/svg+xml,%3Csvg fill='%23000000' viewBox='-3 0 32 32' version='1.1' xmlns='http://www.w3.org/2000/svg'%3E%3Ctitle%3Eline-chart%3C/title%3E%3Cpath d='M23.36 9.32c-1.32 0-2.36 1.080-2.36 2.36 0 0.28 0.040 0.56 0.12 0.8l-4.8 4.080c-0.32-0.2-0.72-0.28-1.16-0.28s-0.88 0.12-1.24 0.36l-2.72-2.2c0.080-0.24 0.12-0.44 0.12-0.72 0-1.32-1.080-2.36-2.36-2.36-1.32 0-2.36 1.080-2.36 2.36 0 0.36 0.080 0.68 0.2 0.96l-3.44 3.44c-0.28-0.12-0.64-0.2-0.96-0.2-1.32 0-2.36 1.080-2.36 2.36 0 1.32 1.080 2.36 2.36 2.36s2.36-1.080 2.36-2.36c0-0.36-0.080-0.68-0.2-0.96l3.44-3.44c0.28 0.12 0.64 0.2 0.96 0.2 0.44 0 0.88-0.12 1.24-0.36l2.76 2.12c-0.080 0.24-0.080 0.44-0.080 0.72 0 1.32 1.080 2.36 2.36 2.36s2.36-1.080 2.36-2.36c0-0.28-0.040-0.56-0.12-0.8l4.8-4.080c0.32 0.2 0.72 0.28 1.16 0.28 1.32 0 2.36-1.080 2.36-2.36-0.040-1.2-1.16-2.28-2.44-2.28zM2.36 21c-0.36 0-0.68-0.32-0.68-0.68 0-0.4 0.32-0.68 0.68-0.68s0.68 0.32 0.68 0.68c0 0.36-0.28 0.68-0.68 0.68zM8.24 13.76c0-0.4 0.32-0.68 0.68-0.68s0.68 0.32 0.68 0.68-0.32 0.68-0.68 0.68c-0.36 0-0.68-0.32-0.68-0.68zM15.2 19.28c-0.4 0-0.68-0.32-0.68-0.68s0.32-0.68 0.68-0.68 0.68 0.32 0.68 0.68c-0.040 0.4-0.28 0.68-0.68 0.68zM23.36 12.36c-0.36 0-0.68-0.32-0.68-0.68 0-0.4 0.32-0.68 0.68-0.68 0.4 0 0.68 0.32 0.68 0.68 0 0.4-0.32 0.68-0.68 0.68z'%3E%3C/path%3E%3C/svg%3E")}.polygon{background-image:url("data:image/svg+xml,%3Csvg fill='%23000000' viewBox='0 0 256 256' id='Flat' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M233.46,97.46a36,36,0,0,0-50.92-50.92h0a36.18,36.18,0,0,0-4.12,5l-22.54-6.14A36,36,0,0,0,94.54,22.54h0a36.07,36.07,0,0,0-7.79,39.24L57.2,88.38a36.06,36.06,0,0,0-42.66,6.16h0a36,36,0,0,0,45.73,55.2l65.27,47.87a36,36,0,1,0,59.92-15.07,37.69,37.69,0,0,0-2.85-2.55L208,108A35.87,35.87,0,0,0,233.46,97.46Zm-93.73,80.8L74.46,130.39a36.19,36.19,0,0,0-1.21-24.17l29.55-26.6a35.92,35.92,0,0,0,46.78-11.11l22.54,6.14a35.88,35.88,0,0,0,10.42,22.81,37.69,37.69,0,0,0,2.85,2.55L160,172A35.89,35.89,0,0,0,139.73,178.26ZM216.49,63.51a12,12,0,1,1-17,0h0A12,12,0,0,1,216.49,63.51Zm-105-24a12,12,0,1,1,0,17,12,12,0,0,1,0-17Zm-80,89a12,12,0,0,1,0-17h0a12,12,0,1,1,0,17Zm137,88a12,12,0,0,1-17-17h0a12,12,0,0,1,17,17Z'/%3E%3C/svg%3E")}.break{background-image:url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M7.68377 0.0513439C8.20771 -0.123304 8.77403 0.159856 8.94868 0.683799L9.94868 3.6838C10.1233 4.20774 9.84017 4.77406 9.31622 4.94871C8.79228 5.12336 8.22596 4.8402 8.05131 4.31625L7.05131 1.31625C6.87667 0.792312 7.15983 0.225992 7.68377 0.0513439Z' fill='%230F0F0F'/%3E%3Cpath d='M20.8596 9.54591L16.9706 13.435C16.58 13.8255 15.9469 13.8255 15.5563 13.435C15.1658 13.0445 15.1658 12.4113 15.5563 12.0208L19.4454 8.1317C20.4217 7.15539 20.4217 5.57247 19.4454 4.59616C18.4691 3.61985 16.8862 3.61985 15.9099 4.59616L12.0208 8.48525C11.6303 8.87578 10.9971 8.87578 10.6066 8.48525C10.2161 8.09473 10.2161 7.46156 10.6066 7.07104L14.4957 3.18195C16.253 1.42459 19.1023 1.42459 20.8596 3.18195C22.617 4.93931 22.617 7.78855 20.8596 9.54591Z' fill='%230F0F0F'/%3E%3Cpath d='M3.18198 14.4957L7.07106 10.6066C7.46159 10.216 8.09475 10.216 8.48528 10.6066C8.8758 10.9971 8.8758 11.6303 8.48528 12.0208L4.59619 15.9099C3.61988 16.8862 3.61988 18.4691 4.59619 19.4454C5.5725 20.4217 7.15541 20.4217 8.13172 19.4454L12.0208 15.5563C12.4113 15.1658 13.0445 15.1658 13.435 15.5563C13.8256 15.9468 13.8256 16.58 13.435 16.9705L9.54594 20.8596C7.78858 22.617 4.93934 22.617 3.18198 20.8596C1.42462 19.1023 1.42462 16.253 3.18198 14.4957Z' fill='%230F0F0F'/%3E%3Cpath d='M2.29289 2.29292C2.68341 1.9024 3.31658 1.9024 3.7071 2.29292L6.7071 5.29292C7.09763 5.68344 7.09763 6.31661 6.7071 6.70713C6.31658 7.09766 5.68341 7.09766 5.29289 6.70713L2.29289 3.70713C1.90237 3.31661 1.90237 2.68344 2.29289 2.29292Z' fill='%230F0F0F'/%3E%3Cpath d='M20.2929 21.7071C20.6834 22.0977 21.3166 22.0977 21.7071 21.7071C22.0976 21.3166 22.0976 20.6834 21.7071 20.2929L18.7071 17.2929C18.3166 16.9024 17.6834 16.9024 17.2929 17.2929C16.9024 17.6834 16.9024 18.3166 17.2929 18.7071L20.2929 21.7071Z' fill='%230F0F0F'/%3E%3Cpath d='M15.0513 23.3163C15.226 23.8402 15.7923 24.1234 16.3162 23.9487C16.8402 23.7741 17.1233 23.2077 16.9487 22.6838L15.9487 19.6838C15.774 19.1599 15.2077 18.8767 14.6838 19.0513C14.1598 19.226 13.8767 19.7923 14.0513 20.3163L15.0513 23.3163Z' fill='%230F0F0F'/%3E%3Cpath d='M0.0513134 7.6838C-0.123334 8.20774 0.159826 8.77406 0.683769 8.94871L3.68377 9.94871C4.20771 10.1234 4.77403 9.8402 4.94868 9.31625C5.12333 8.79231 4.84017 8.22599 4.31622 8.05134L1.31622 7.05134C0.792281 6.8767 0.225961 7.15986 0.0513134 7.6838Z' fill='%230F0F0F'/%3E%3Cpath d='M23.3162 15.0513C23.8402 15.226 24.1233 15.7923 23.9487 16.3163C23.774 16.8402 23.2077 17.1234 22.6838 16.9487L19.6838 15.9487C19.1598 15.7741 18.8767 15.2077 19.0513 14.6838C19.226 14.1599 19.7923 13.8767 20.3162 14.0513L23.3162 15.0513Z' fill='%230F0F0F'/%3E%3C/svg%3E")}.control-button:first-child{border-top-left-radius:4px;border-top-right-radius:4px}.control-button-active{background-color:#f0f0f0!important}.control-button:disabled{opacity:.25}.maplibregl-popup-tip,.mapboxgl-popup-tip{display:none!important}.maplibregl-popup-content,.mapboxgl-popup-content{padding:0!important}
2
+ /*# sourceMappingURL=index.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/last-point-panel/panel.css","../src/components/tooltip/tooltip.css","../src/components/side-control/control.css","../src/draw.css"],"sourcesContent":[".hide-panel {\n visibility: hidden;\n}\n\n.undo {\n background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='64 64 896 896' focusable='false' data-icon='undo' fill='currentColor' aria-hidden='true'%3E%3Cpath d='M511.4 124C290.5 124.3 112 303 112 523.9c0 128 60.2 242 153.8 315.2l-37.5 48c-4.1 5.3-.3 13 6.3 12.9l167-.8c5.2 0 9-4.9 7.7-9.9L369.8 727a8 8 0 00-14.1-3L315 776.1c-10.2-8-20-16.7-29.3-26a318.64 318.64 0 01-68.6-101.7C200.4 609 192 567.1 192 523.9s8.4-85.1 25.1-124.5c16.1-38.1 39.2-72.3 68.6-101.7 29.4-29.4 63.6-52.5 101.7-68.6C426.9 212.4 468.8 204 512 204s85.1 8.4 124.5 25.1c38.1 16.1 72.3 39.2 101.7 68.6 29.4 29.4 52.5 63.6 68.6 101.7 16.7 39.4 25.1 81.3 25.1 124.5s-8.4 85.1-25.1 124.5a318.64 318.64 0 01-68.6 101.7c-7.5 7.5-15.3 14.5-23.4 21.2a7.93 7.93 0 00-1.2 11.1l39.4 50.5c2.8 3.5 7.9 4.1 11.4 1.3C854.5 760.8 912 649.1 912 523.9c0-221.1-179.4-400.2-400.6-399.9z'%3E%3C/path%3E%3C/svg%3E\");\n}\n\n.delete {\n background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='64 64 896 896' focusable='false' data-icon='delete' fill='currentColor' aria-hidden='true'%3E%3Cpath d='M360 184h-8c4.4 0 8-3.6 8-8v8h304v-8c0 4.4 3.6 8 8 8h-8v72h72v-80c0-35.3-28.7-64-64-64H352c-35.3 0-64 28.7-64 64v80h72v-72zm504 72H160c-17.7 0-32 14.3-32 32v32c0 4.4 3.6 8 8 8h60.4l24.7 523c1.6 34.1 29.8 61 63.9 61h454c34.2 0 62.3-26.8 63.9-61l24.7-523H888c4.4 0 8-3.6 8-8v-32c0-17.7-14.3-32-32-32zM731.3 840H292.7l-24.2-512h487l-24.2 512z'%3E%3C/path%3E%3C/svg%3E\");\n}\n\n.save {\n background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='64 64 896 896' focusable='false' data-icon='check' fill='currentColor' aria-hidden='true'%3E%3Cpath d='M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5 207 474a32 32 0 00-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1.4-12.8-6.3-12.8z'%3E%3C/path%3E%3C/svg%3E\");\n}\n\n.dashboard {\n display: flex;\n align-items: center;\n}\n\n.panel-button {\n background-color: transparent;\n border: 0;\n box-sizing: border-box;\n cursor: pointer;\n display: block;\n height: 28px;\n outline: none;\n padding: 0;\n width: 28px;\n}\n\n.panel-button:hover {\n background-color: #0000000d;\n}\n\n.icon {\n background-position: 50%;\n background-repeat: no-repeat;\n display: block;\n height: 18px;\n}\n\n.panel-button:not(:last-child) .icon {\n border-right: 1px solid #ddd;\n}\n\n.panel-button-small {\n width: 20px;\n height: 20px;\n}\n\n.panel-button-medium {\n width: 24px;\n height: 24px;\n}\n.panel-button-large {\n width: 28px;\n height: 28px;\n}\n\n.icon-small {\n height: 14px;\n}\n\n.icon-medium {\n height: 16px;\n}\n\n.icon-large {\n height: 18px;\n}\n",".popup-container {\n display: block;\n position: absolute;\n z-index: 1000;\n top: 0;\n left: 0;\n height: 50px;\n}\n\n.popup-text {\n display: inline-block;\n padding: 4px 16px;\n background-color: #4d4d4d;\n border-radius: 18px;\n color: #fff;\n font-size: 14px;\n}\n\n.popup-text-bottom {\n opacity: 0;\n transform: translateY(16px);\n transition: all 0.2s ease-out;\n transition-delay: 0.25s;\n}\n\n.popup-text-left {\n opacity: 0;\n transform: translateX(16px);\n transition: all 0.3s ease-out;\n}\n\n.popup-text-active {\n transform: translate(0px);\n opacity: 1;\n}\n",".line {\n background-image: url(\"data:image/svg+xml,%3Csvg fill='%23000000' viewBox='-3 0 32 32' version='1.1' xmlns='http://www.w3.org/2000/svg'%3E%3Ctitle%3Eline-chart%3C/title%3E%3Cpath d='M23.36 9.32c-1.32 0-2.36 1.080-2.36 2.36 0 0.28 0.040 0.56 0.12 0.8l-4.8 4.080c-0.32-0.2-0.72-0.28-1.16-0.28s-0.88 0.12-1.24 0.36l-2.72-2.2c0.080-0.24 0.12-0.44 0.12-0.72 0-1.32-1.080-2.36-2.36-2.36-1.32 0-2.36 1.080-2.36 2.36 0 0.36 0.080 0.68 0.2 0.96l-3.44 3.44c-0.28-0.12-0.64-0.2-0.96-0.2-1.32 0-2.36 1.080-2.36 2.36 0 1.32 1.080 2.36 2.36 2.36s2.36-1.080 2.36-2.36c0-0.36-0.080-0.68-0.2-0.96l3.44-3.44c0.28 0.12 0.64 0.2 0.96 0.2 0.44 0 0.88-0.12 1.24-0.36l2.76 2.12c-0.080 0.24-0.080 0.44-0.080 0.72 0 1.32 1.080 2.36 2.36 2.36s2.36-1.080 2.36-2.36c0-0.28-0.040-0.56-0.12-0.8l4.8-4.080c0.32 0.2 0.72 0.28 1.16 0.28 1.32 0 2.36-1.080 2.36-2.36-0.040-1.2-1.16-2.28-2.44-2.28zM2.36 21c-0.36 0-0.68-0.32-0.68-0.68 0-0.4 0.32-0.68 0.68-0.68s0.68 0.32 0.68 0.68c0 0.36-0.28 0.68-0.68 0.68zM8.24 13.76c0-0.4 0.32-0.68 0.68-0.68s0.68 0.32 0.68 0.68-0.32 0.68-0.68 0.68c-0.36 0-0.68-0.32-0.68-0.68zM15.2 19.28c-0.4 0-0.68-0.32-0.68-0.68s0.32-0.68 0.68-0.68 0.68 0.32 0.68 0.68c-0.040 0.4-0.28 0.68-0.68 0.68zM23.36 12.36c-0.36 0-0.68-0.32-0.68-0.68 0-0.4 0.32-0.68 0.68-0.68 0.4 0 0.68 0.32 0.68 0.68 0 0.4-0.32 0.68-0.68 0.68z'%3E%3C/path%3E%3C/svg%3E\");\n}\n\n.polygon {\n background-image: url(\"data:image/svg+xml,%3Csvg fill='%23000000' viewBox='0 0 256 256' id='Flat' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M233.46,97.46a36,36,0,0,0-50.92-50.92h0a36.18,36.18,0,0,0-4.12,5l-22.54-6.14A36,36,0,0,0,94.54,22.54h0a36.07,36.07,0,0,0-7.79,39.24L57.2,88.38a36.06,36.06,0,0,0-42.66,6.16h0a36,36,0,0,0,45.73,55.2l65.27,47.87a36,36,0,1,0,59.92-15.07,37.69,37.69,0,0,0-2.85-2.55L208,108A35.87,35.87,0,0,0,233.46,97.46Zm-93.73,80.8L74.46,130.39a36.19,36.19,0,0,0-1.21-24.17l29.55-26.6a35.92,35.92,0,0,0,46.78-11.11l22.54,6.14a35.88,35.88,0,0,0,10.42,22.81,37.69,37.69,0,0,0,2.85,2.55L160,172A35.89,35.89,0,0,0,139.73,178.26ZM216.49,63.51a12,12,0,1,1-17,0h0A12,12,0,0,1,216.49,63.51Zm-105-24a12,12,0,1,1,0,17,12,12,0,0,1,0-17Zm-80,89a12,12,0,0,1,0-17h0a12,12,0,1,1,0,17Zm137,88a12,12,0,0,1-17-17h0a12,12,0,0,1,17,17Z'/%3E%3C/svg%3E\");\n}\n\n.break {\n background-image: url(\"data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M7.68377 0.0513439C8.20771 -0.123304 8.77403 0.159856 8.94868 0.683799L9.94868 3.6838C10.1233 4.20774 9.84017 4.77406 9.31622 4.94871C8.79228 5.12336 8.22596 4.8402 8.05131 4.31625L7.05131 1.31625C6.87667 0.792312 7.15983 0.225992 7.68377 0.0513439Z' fill='%230F0F0F'/%3E%3Cpath d='M20.8596 9.54591L16.9706 13.435C16.58 13.8255 15.9469 13.8255 15.5563 13.435C15.1658 13.0445 15.1658 12.4113 15.5563 12.0208L19.4454 8.1317C20.4217 7.15539 20.4217 5.57247 19.4454 4.59616C18.4691 3.61985 16.8862 3.61985 15.9099 4.59616L12.0208 8.48525C11.6303 8.87578 10.9971 8.87578 10.6066 8.48525C10.2161 8.09473 10.2161 7.46156 10.6066 7.07104L14.4957 3.18195C16.253 1.42459 19.1023 1.42459 20.8596 3.18195C22.617 4.93931 22.617 7.78855 20.8596 9.54591Z' fill='%230F0F0F'/%3E%3Cpath d='M3.18198 14.4957L7.07106 10.6066C7.46159 10.216 8.09475 10.216 8.48528 10.6066C8.8758 10.9971 8.8758 11.6303 8.48528 12.0208L4.59619 15.9099C3.61988 16.8862 3.61988 18.4691 4.59619 19.4454C5.5725 20.4217 7.15541 20.4217 8.13172 19.4454L12.0208 15.5563C12.4113 15.1658 13.0445 15.1658 13.435 15.5563C13.8256 15.9468 13.8256 16.58 13.435 16.9705L9.54594 20.8596C7.78858 22.617 4.93934 22.617 3.18198 20.8596C1.42462 19.1023 1.42462 16.253 3.18198 14.4957Z' fill='%230F0F0F'/%3E%3Cpath d='M2.29289 2.29292C2.68341 1.9024 3.31658 1.9024 3.7071 2.29292L6.7071 5.29292C7.09763 5.68344 7.09763 6.31661 6.7071 6.70713C6.31658 7.09766 5.68341 7.09766 5.29289 6.70713L2.29289 3.70713C1.90237 3.31661 1.90237 2.68344 2.29289 2.29292Z' fill='%230F0F0F'/%3E%3Cpath d='M20.2929 21.7071C20.6834 22.0977 21.3166 22.0977 21.7071 21.7071C22.0976 21.3166 22.0976 20.6834 21.7071 20.2929L18.7071 17.2929C18.3166 16.9024 17.6834 16.9024 17.2929 17.2929C16.9024 17.6834 16.9024 18.3166 17.2929 18.7071L20.2929 21.7071Z' fill='%230F0F0F'/%3E%3Cpath d='M15.0513 23.3163C15.226 23.8402 15.7923 24.1234 16.3162 23.9487C16.8402 23.7741 17.1233 23.2077 16.9487 22.6838L15.9487 19.6838C15.774 19.1599 15.2077 18.8767 14.6838 19.0513C14.1598 19.226 13.8767 19.7923 14.0513 20.3163L15.0513 23.3163Z' fill='%230F0F0F'/%3E%3Cpath d='M0.0513134 7.6838C-0.123334 8.20774 0.159826 8.77406 0.683769 8.94871L3.68377 9.94871C4.20771 10.1234 4.77403 9.8402 4.94868 9.31625C5.12333 8.79231 4.84017 8.22599 4.31622 8.05134L1.31622 7.05134C0.792281 6.8767 0.225961 7.15986 0.0513134 7.6838Z' fill='%230F0F0F'/%3E%3Cpath d='M23.3162 15.0513C23.8402 15.226 24.1233 15.7923 23.9487 16.3163C23.774 16.8402 23.2077 17.1234 22.6838 16.9487L19.6838 15.9487C19.1598 15.7741 18.8767 15.2077 19.0513 14.6838C19.226 14.1599 19.7923 13.8767 20.3162 14.0513L23.3162 15.0513Z' fill='%230F0F0F'/%3E%3C/svg%3E\");\n}\n\n.control-button:first-child {\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n}\n\n.control-button-active {\n background-color: #f0f0f0 !important;\n}\n\n.control-button:disabled {\n opacity: 0.25;\n}\n",".maplibregl-popup-tip,\n.mapboxgl-popup-tip {\n display: none !important;\n}\n\n.maplibregl-popup-content,\n.mapboxgl-popup-content {\n padding: 0 !important;\n}\n"],"mappings":"AAAA,CAAC,WACC,WAAY,MACd,CAEA,CAAC,KACC,iBAAkB,g3BACpB,CAEA,CAAC,OACC,i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AS,cACX,CAEA,CAAC,yBACD,CAAC,uBAND,QAOW,WACX","names":[]}
package/dist/index.js CHANGED
@@ -1,3 +1,5 @@
1
- var l=class o{static docStyle=typeof window<"u"&&window.document&&window.document.documentElement.style;static transformProp=o.testProp(["transform","WebkitTransform"]);static testProp(e){if(!o.docStyle)return e[0];for(let t=0;t<e.length;t++)if(e[t]in o.docStyle)return e[t];return e[0]}static create(e,t,i){let n=window.document.createElement(e);return t!==void 0&&(n.className=t),i&&i.appendChild(n),n}static remove(e){e.parentNode&&e.parentNode.removeChild(e);}static setTransform(e,t){o.transformProp&&e.style&&(e.style[o.transformProp]=t);}static manageEventListener(e,t,i,n,s={}){if(!t)return;let a=e==="add"?"addEventListener":"removeEventListener";"passive"in s?t[a](i,n,s):t[a](i,n,s.capture);}static mouseButton(e){return e.button}static addClassName(e,t){e.classList.contains(t)||e.classList.add(t);}static removeClassName(e,t){e.classList.contains(t)&&e.classList.remove(t);}};var S=class o{lng;lat;constructor(e,t){if(isNaN(e)||isNaN(t))throw new Error(`Invalid LngLat object: (${e}, ${t})`);if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}static convert(e){if(e instanceof o)return e;if(Array.isArray(e)&&(e.length===2||e.length===3))return new o(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null)return new o(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}};function H(o,...e){for(let t of e)for(let i in t)o[i]=t[i];return o}function Le(o,e,t){let i=new S(o.lng,o.lat);if(o=new S(o.lng,o.lat),e){let n=new S(o.lng-360,o.lat),s=new S(o.lng+360,o.lat),a=t.locationPoint(o).distSqr(e);t.locationPoint(n).distSqr(e)<a?o=n:t.locationPoint(s).distSqr(e)<a&&(o=s);}for(;Math.abs(o.lng-t.center.lng)>180;){let n=t.locationPoint(o);if(n.x>=0&&n.y>=0&&n.x<=t.width&&n.y<=t.height)break;o.lng>t.center.lng?o.lng-=360:o.lng+=360;}return o.lng!==i.lng&&t.locationPoint(o).y>t.height/2-t.getHorizon()?o:i}var me={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function ge(o,e,t){let i=o.classList;for(let n in me)i.remove(`maplibregl-${t}-anchor-${n}`);i.add(`maplibregl-${t}-anchor-${e}`);}function Ee(o,e,t){t[o]&&t[o].indexOf(e)!==-1||(t[o]=t[o]||[],t[o].push(e));}function ye(o,e,t){if(t&&t[o]){let i=t[o].indexOf(e);i!==-1&&t[o].splice(i,1);}}var Y=class{_listeners;_oneTimeListeners;_eventedParent;_eventedParentData;on(e,t){return this._listeners=this._listeners||{},Ee(e,t,this._listeners),this}off(e,t){return ye(e,t,this._listeners),ye(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},Ee(e,t,this._oneTimeListeners),this):new Promise(i=>this.once(e,i))}fire(e,t){typeof e=="string"&&(e=new I(e,t||{}));let i=e.type;if(this.listens(i)){e.target=this;let n=this._listeners&&this._listeners[i]?this._listeners[i].slice():[];for(let p of n)p.call(this,e);let s=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(let p of s)ye(i,p,this._oneTimeListeners),p.call(this,e);let a=this._eventedParent;a&&(H(e,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),a.fire(e));}else e instanceof ErrorEvent&&console.error(e.error);return this}listens(e){return this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e)}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}},I=class{type;constructor(e,t={}){H(this,t),this.type=e;}};var u=class o{x;y;constructor(e,t){this.x=e,this.y=t;}mag(){return Math.sqrt(this.x*this.x+this.y*this.y)}equals(e){return this.x===e.x&&this.y===e.y}dist(e){return Math.sqrt(this.distSqr(e))}distSqr(e){let t=e.x-this.x,i=e.y-this.y;return t*t+i*i}angle(){return Math.atan2(this.y,this.x)}angleTo(e){return Math.atan2(this.y-e.y,this.x-e.x)}angleWith(e){return this.angleWithSep(e.x,e.y)}angleWithSep(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)}_matMult(e){let t=e[0]*this.x+e[1]*this.y,i=e[2]*this.x+e[3]*this.y;return this.x=t,this.y=i,this}_add(e){return this.x+=e.x,this.y+=e.y,this}_sub(e){return this.x-=e.x,this.y-=e.y,this}_mult(e){return this.x*=e,this.y*=e,this}_div(e){return this.x/=e,this.y/=e,this}_multByPoint(e){return this.x*=e.x,this.y*=e.y,this}_divByPoint(e){return this.x/=e.x,this.y/=e.y,this}_unit(){return this._div(this.mag()),this}_perp(){let e=this.y;return this.y=this.x,this.x=-e,this}_rotate(e){let t=Math.cos(e),i=Math.sin(e),n=t*this.x-i*this.y,s=i*this.x+t*this.y;return this.x=n,this.y=s,this}_rotateAround(e,t){let i=Math.cos(e),n=Math.sin(e),s=t.x+i*(this.x-t.x)-n*(this.y-t.y),a=t.y+n*(this.x-t.x)+i*(this.y-t.y);return this.x=s,this.y=a,this}_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}static convert(e){if(e instanceof o)return e;if(Array.isArray(e))return new o(+e[0],+e[1]);if(e.x!==void 0&&e.y!==void 0)return new o(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")}};var ke={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1},xe=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", "),j=class extends Y{_map;options;_content;_container;_closeButton;_tip;_lngLat;_trackPointer;_pos;_flatPos;constructor(e){super(),this.options=H(Object.create(ke),e);}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new I("open")),this}isOpen(){return !!this._map}remove=()=>(this._content&&l.remove(this._content),this._container&&(l.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new I("close"))),this);getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=S.convert(e),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){let t=document.createDocumentFragment(),i=document.createElement("body"),n;for(i.innerHTML=e;n=i.firstChild,!!n;)t.appendChild(n);return this.setDOMContent(t)}getMaxWidth(){return this._container?.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=l.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(e),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(e){return this._container&&this._container.classList.add(e),this}removeClassName(e){return this._container&&this._container.classList.remove(e),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){if(this._container)return this._container.classList.toggle(e)}setSubpixelPositioning(e){this.options.subpixelPositioning=e;}_createCloseButton(){this.options.closeButton&&(this._closeButton=l.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="&#215;",this._closeButton.addEventListener("click",this._onClose));}_onMouseUp=e=>{this._update(e.point);};_onMouseMove=e=>{this._update(e.point);};_onDrag=e=>{this._update(e.point);};_update=e=>{let t=this._lngLat||this._trackPointer;if(!this._map||!t||!this._content)return;if(!this._container){if(this._container=l.create("div","maplibregl-popup",this._map.getContainer()),this._tip=l.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(let p of this.options.className.split(" "))this._container.classList.add(p);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer");}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._map.transform.renderWorldCopies&&!this._trackPointer?this._lngLat=Le(this._lngLat,this._flatPos,this._map.transform):this._lngLat=this._lngLat?.wrap(),this._trackPointer&&!e)return;let i=this._flatPos=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&e?e:this._map.transform.locationPoint(this._lngLat));let n=this.options.anchor,s=Pe(this.options.offset);if(!n){let p=this._container.offsetWidth,g=this._container.offsetHeight,T;i.y+s.bottom.y<g?T=["top"]:i.y>this._map.transform.height-g?T=["bottom"]:T=[],i.x<p/2?T.push("left"):i.x>this._map.transform.width-p/2&&T.push("right"),T.length===0?n="bottom":n=T.join("-");}let a=i.add(s[n]);this.options.subpixelPositioning||(a=a.round()),l.setTransform(this._container,`${me[n]} translate(${a.x}px,${a.y}px)`),ge(this._container,n,"popup");};_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;let e=this._container.querySelector(xe);e&&e.focus();}_onClose=()=>{this.remove();}};function Pe(o){if(o)if(typeof o=="number"){let e=Math.round(Math.abs(o)/Math.SQRT2);return {center:new u(0,0),top:new u(0,o),"top-left":new u(e,e),"top-right":new u(-e,e),bottom:new u(0,-o),"bottom-left":new u(e,-e),"bottom-right":new u(-e,-e),left:new u(o,0),right:new u(-o,0)}}else if(o instanceof u||Array.isArray(o)){let e=u.convert(o);return {center:e,top:e,"top-left":e,"top-right":e,bottom:e,"bottom-left":e,"bottom-right":e,left:e,right:e}}else return {center:u.convert(o.center||[0,0]),top:u.convert(o.top||[0,0]),"top-left":u.convert(o["top-left"]||[0,0]),"top-right":u.convert(o["top-right"]||[0,0]),bottom:u.convert(o.bottom||[0,0]),"bottom-left":u.convert(o["bottom-left"]||[0,0]),"bottom-right":u.convert(o["bottom-right"]||[0,0]),left:u.convert(o.left||[0,0]),right:u.convert(o.right||[0,0])};else return Pe(new u(0,0))}var W=class{#e;#t;#i;_undoButton;_deleteButton;_saveButton;_container;constructor(e){this.#e=e,this._container=void 0,this.#i=!1,this.#s().then(()=>{this.#r(),this.#n();});}#n(){this.#e.mode?.addObserver(this.#o);}#o=e=>{let{store:t}=this.#e,{type:i,data:n}=e;i==="MODE_CHANGED"&&!n&&this.hidePanel(),i==="MODE_CHANGED"&&n&&t.tail?.val&&this.setPanelLocation({lat:t.tail?.val?.lat,lng:t.tail?.val?.lng});};#s=async()=>{try{this.#t=new j({offset:16,closeButton:!1,closeOnClick:!1,closeOnMove:!1,anchor:"bottom"});}catch(e){console.error("POPUP LOAD ERROR",e);}};#r=()=>{let{store:e}=this.#e;this.createPanel(),e.tail?.val&&this.setPanelLocation({lat:e.tail?.val?.lat,lng:e.tail?.val?.lng});};setPanelLocation=e=>{let{map:t}=this.#e;this.#i&&(this.#i=!1,this.showPanel()),this._container&&this.#t&&this.#t.setLngLat(e).setDOMContent(this._container).addTo(t);};hidePanel=()=>{!this.#i&&(this.#t?.addClassName("hide-panel"),this.#i=!0);};showPanel=()=>{this.#t?.removeClassName("hide-panel"),this.#i=!1;};onPointRemove=e=>{e?this.setPanelLocation(e):this.hidePanel();};removePanel=()=>{this._container&&l.remove(this._container),this.#t?.remove();};createButton=(e,t,i,n)=>{let s=l.create("button",`panel-button panel-button-${i}`,n);return s.setAttribute("data-type",e),s.setAttribute("aria-label",t),l.create("span",`icon ${e} icon-${i}`,s),s};createPanel=()=>{let{options:e}=this.#e,{locale:t}=e,{undo:i,delete:n,save:s}=e.panel.buttons,a=e.panel.size,p=document.querySelector(".maplibregl-popup-content"),g=l.create("div","dashboard",p);i.visible&&(this._undoButton=this.createButton("undo",t.undo,a,g)),n.visible&&(this._deleteButton=this.createButton("delete",t.delete,a,g)),s.visible&&(this._saveButton=this.createButton("save",t.save,a,g)),this._container=g;}};var V={type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[]}}]},K={type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[]}}]},Me={type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"Point",coordinates:[]}}]},r={LineDynamicLayer:"mdl-line-dynamic-layer",LineLayer:"mdl-line-layer",LineLayerTransparent:"mdl-line-layer-transparent",LineLayerBreak:"mdl-line-break-layer",PolygonLayer:"mdl-polygon-layer",PointsLayer:"mdl-points-layer",SinglePointLayer:"mdl-single-point-layer",FirstPointLayer:"mdl-first-point-layer"},d={LineDynamicSource:"mdl-line-dynamic-source",LineSourceBreak:"mdl-line-source-break",LineSource:"mdl-line-source",PolygonSource:"mdl-polygon-source",PointsSource:"mdl-points-source",SinglePointSource:"mdl-single-point-source"},B={large:6.5,default:5.5},$={large:"#FF6464",default:"#666666"},w={"circle-radius":B.default,"circle-color":"#FEFFFE","circle-stroke-color":$.default,"circle-stroke-width":3},D={"circle-radius":B.large,"circle-color":"#FEFFFE","circle-stroke-color":"#666666","circle-stroke-width":3},U={"fill-color":"grey","fill-opacity":.4},N={"line-width":3,"line-color":"grey","line-opacity":.7},A={"circle-radius":B.default,"circle-color":"#FEFFFE","circle-stroke-color":"#666666","circle-stroke-width":3},F={"line-width":3,"line-color":"#FF6464","line-dasharray":[3,3]},Z=o=>[{id:r.SinglePointLayer,source:d.SinglePointSource,type:"circle",paint:o.layersPaint.onLinePoint,layout:{visibility:"none"}},{id:r.PolygonLayer,source:d.PolygonSource,type:"fill",paint:o.layersPaint.polygon,layout:{visibility:"none"}},{id:r.LineDynamicLayer,source:d.LineDynamicSource,type:"line",paint:o.layersPaint.line,layout:{visibility:"none"}},{id:r.LineLayer,source:d.LineSource,type:"line",paint:o.layersPaint.line,layout:{visibility:"visible"}},{id:r.LineLayerTransparent,source:d.LineSource,type:"line",paint:{"line-width":4,"line-color":"transparent"}},{id:r.LineLayerBreak,source:d.LineSourceBreak,type:"line",paint:o.layersPaint.breakLine,layout:{visibility:"none"}},{id:r.PointsLayer,source:d.PointsSource,type:"circle",paint:o.layersPaint.points,filter:["==",["get","isFirst"],!1]},{id:r.FirstPointLayer,source:d.PointsSource,type:"circle",paint:o.layersPaint.firstPoint,filter:["==",["get","isFirst"],!0]}];var E=class{static#e=0;static#t=e=>{e.setPaintProperty(r.FirstPointLayer,"circle-radius",B.large),e.setPaintProperty(r.FirstPointLayer,"circle-stroke-color",$.large);};static#i=e=>{e.setPaintProperty(r.FirstPointLayer,"circle-radius",B.default),e.setPaintProperty(r.FirstPointLayer,"circle-stroke-color",$.default);};static togglePointCircleRadius=(e,t)=>{t==="large"?this.#t(e):this.#i(e);};static removeTransparentLine=e=>{e.removeLayer(r.LineLayerTransparent);};static addTransparentLine=(e,t)=>{if(e.getLayer(r.LineLayerTransparent))return;let n=Z(t).find(s=>s.id===r.LineLayerTransparent);n&&e.addLayer(n);};static isDoubleClick(){let t=Date.now();return t-this.#e<=400?(this.#e=t,!0):(this.#e=t,!1)}};var v=class{static isFeatureTriggered(e,t){return e.target.queryRenderedFeatures(e.point,{layers:t}).some(n=>t.includes(n.layer.id))}static getPixelCoordinates=(e,t)=>{let{lat:i,lng:n}=t;return e.project([n,i])};static queryPointId=(e,t)=>e.queryRenderedFeatures(t,{layers:[r.PointsLayer,r.FirstPointLayer]})?.[0]?.properties.id},_=class{static#e(e){let t=[],i=e.head,n=new Set;for(;i!==null;){if(n.has(i.val?.id)){e.head&&e.head.val&&t.push([e.head.val.lng,e.head.val.lat]);break}n.add(i.val?.id),i.val&&t.push([i.val.lng,i.val.lat]),i=i.next;}return t}static getAllLines(e){let t=this.#e(e);return {type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:t}}]}}static getLine(e,t){return {type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[e,t]}}]}}static getPolygon(e){let t=this.#e(e);return {type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[t]}}]}}static getPoints(e){let t=e.head,i=[],n=new Set;for(;t!==null&&!n.has(t.val?.id);){if(t.val){let s=t.val,a=t.val.id===e.head?.val?.id;i.push({type:"Feature",properties:{id:s.id,lat:s.lat,lng:s.lng,isFirst:a},geometry:{type:"Point",coordinates:[s.lng,s.lat]}});}n.add(t.val?.id),t=t.next;}return {type:"FeatureCollection",features:i}}},m=class o{static getGeometryIndex=(e,t)=>{let i=e.head,n=0;for(;i!==null;){if(i.val?.id===t)return n;n++,i=i.next;}return -1};static isFirstPoint(e){let t=e.target,i=e.point;return !!t.queryRenderedFeatures(i,{layers:[r.FirstPointLayer]}).length}static distance=(e,t)=>Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2);static checkIfPointIsOnLine=(e,t,i)=>{let s=this.distance(e,t),a=this.distance(e,i),p=this.distance(i,t);return Math.abs(a+p-s)<.1};static isClosedGeometry=e=>e.tail?.next===e.head;static breakGeometry=(e,t)=>{if(!e.head)return;let i=e.head,n=e.tail;do{if(i?.val?.id===t){i!==e.head&&(n.next=i.next,e.head=i,e.tail=n),e.tail.next=null;return}n=i,i=i.next;}while(i!==e.head)};static closeGeometry=(e,t)=>{e.tail&&(e.tail.next=e.head),t.setClosedGeometry(!0);};static canCloseGeometry=e=>e.size>2&&!this.isClosedGeometry(e);static canBreakClosedGeometry=e=>e.size<=2;static switchToLineModeIfCan=e=>{let{mode:t,store:i,tiles:n,map:s}=e;o.canBreakClosedGeometry(i)&&(i.tail&&i.tail.val&&(i.tail.next=null),t.reset(),E.togglePointCircleRadius(s,"default"),n.renderPolygon(V));}},C=()=>{if("crypto"in window&&"randomUUID"in window.crypto)return window.crypto.randomUUID();function o(){return "0123456789abcdef"[Math.floor(Math.random()*16)]}function e(n){let s="";for(let a=0;a<n;a++)s+=o();return s}function t(n){let s=n===0,a=n===4;return s?8:a?12:4}let i=[];for(let n=0;n<5;n++)i.push(e(t(n)));return i.join("-")},O=(o,e)=>{let t,i=!0;function n(){i&&t&&(o(...t),t=null,i=!1,setTimeout(()=>{i=!0,n();},e));}return function(...s){t=s,n();}};var R=class{#e;#t;#i;#n;constructor(e){this.#e=e,this.#o(),this.render();}#o(){this.#s(),this.#r(),this.#a(r.LineLayer,r.SinglePointLayer),this.#a(r.LineLayerTransparent,r.SinglePointLayer),this.#a(r.LineLayerTransparent,r.FirstPointLayer),this.#a(r.LineLayerTransparent,r.PointsLayer),this.#a(r.PolygonLayer,r.LineLayer);}#s=()=>{let{map:e}=this.#e;Object.values(d).forEach(t=>{e.getSource(t)||e.addSource(t,{type:"geojson",data:{type:"FeatureCollection",features:[]},promoteId:"id"});});};#r=()=>{let{map:e,mode:t,options:i}=this.#e;Z(i).forEach(a=>{e.getLayer(a.id)||e.addLayer(a);});let s=e.getLayoutProperty(r.PolygonLayer,"visibility")==="none";t.getMode()==="polygon"&&s&&e.setLayoutProperty(r.PolygonLayer,"visibility","visible");};#a=(e,t)=>{let{map:i}=this.#e,n=i.getLayer(e),s=i.getLayer(t);n&&s&&i.moveLayer(e,t);};#l=()=>{let{map:e}=this.#e;Object.values(d).forEach(t=>{e.getSource(t)&&e.removeSource(t);});};#c=()=>{let{map:e}=this.#e;Object.values(r).forEach(t=>{e.getLayer(t)&&e.removeLayer(t);});};removeTiles=()=>{this.#c(),this.#l();};renderPoints=e=>{let{map:t}=this.#e,i=t.getSource(d.PointsSource);i&&i.setData(e);};renderLines=(e,t)=>{let{map:i}=this.#e,n=i.getSource(t);n&&n.setData(e);};renderPolygon=e=>{let{map:t}=this.#e,i=t.getSource(d.PolygonSource);i&&i.setData(e);};render=()=>{let{mode:e,options:t,store:i}=this.#e,n=_.getPoints(i),s=_.getAllLines(i);if(this.#t=n,this.#i=s,this.renderPoints(n),this.renderLines(s,d.LineSource),t.modes.polygon.visible&&e.isPolygon()){let p=_.getPolygon(i);this.#n=p,this.renderPolygon(p);}};#h=(e,t)=>{if(this.#n.features[0].geometry.coordinates[0][e]=[t.lng,t.lat],e===0){let n=this.#n.features[0].geometry.coordinates[0]?.length-1;this.#n.features[0].geometry.coordinates[0][n]=[t.lng,t.lat];}this.renderPolygon(this.#n);};#p=(e,t)=>{let{mode:i}=this.#e;this.#i.features[0].geometry.coordinates[e]=[t.lng,t.lat];let n=e===0;if(this.#i&&i.getClosedGeometry()&&n){let a=this.#i.features[0].geometry.coordinates?.length-1;this.#i.features[0].geometry.coordinates[a]=[t.lng,t.lat];}this.renderLines(this.#i,d.LineSource);};renderOnMouseMove=(e,t)=>{let{mode:i,options:n}=this.#e;this.#t.features[e].geometry.coordinates=[t.lng,t.lat],this.renderPoints(this.#t),this.#p(e,t),n.modes.polygon.visible&&i.isPolygon()&&this.#h(e,t);};resetGeometries=()=>{this.renderPoints(Me),this.renderLines(K,d.LineSource),this.renderPolygon(V);}};var Te=8,we=8,k=class{_container;_label;constructor(){this._container=void 0;}create=e=>{let t=l.create("div","popup-container",document.body),i=l.create("span",`popup-text popup-text-${e.placement}`,t);return i.textContent=e.label,this._container=t,this._label=i,this};#e=()=>{!this._label?.classList.value.includes("popup-text-active")&&this._label?.classList.add("popup-text-active");};#t=()=>this._label?{width:this._label.clientWidth,height:this._label.clientHeight}:{width:0,height:0};#i=e=>{let{bottom:t,left:i}=e.target.getBoundingClientRect(),{width:n,height:s}=this.#t();return {x:i-we-n,y:t-s-2}};#n=e=>{let{bottom:t,left:i,right:n}=e.target.getBoundingClientRect(),{width:s}=this.#t();return {x:(n-i)/2+i-s/2,y:t+Te}};getPosition=(e,t)=>t==="left"?this.#i(e):this.#n(e);setPosition=e=>{let{x:t,y:i}=e;this._container&&(this._container.style.left=`${t}px`,this._container.style.top=`${i}px`),this.#e();};remove=()=>{this._container&&l.remove(this._container);}};var P={AUTO:"auto",DEFAULT:"default",POINTER:"pointer",CROSSHAIR:"crosshair",MOVE:"move",HELP:"help",GRAB:"grab",GRABBING:"grabbing"};var J=(o,e)=>{for(let[t,i]of Object.entries(e))l.manageEventListener("add",o,t,i);},X=(o,e)=>{for(let[t,i]of Object.entries(e))l.manageEventListener("remove",o,t,i);},be=(o,e)=>{let t=e.locale.line,i=e.locale.polygon,n=e.locale.break;return {line:t,polygon:i,break:n}[o]};var L={DOUBLECLICK:"mdl:doubleclick",POINTENTER:"mdl:pointenter",POINTLEAVE:"mdl:pointleave",MOVEEND:"mdl:moveend",ADD:"mdl:add",UNDO:"mdl:undo",REMOVEALL:"mdl:removeall",SAVE:"mdl:save",BREAK:"mdl:break",MODECHANGED:"mdl:modechanged"};var y={panel:{size:"medium",buttons:{undo:{visible:!0},delete:{visible:!0},save:{visible:!0,clearOnSave:!0}}},modes:{initial:null,line:{visible:!0,closeGeometry:!0},polygon:{visible:!0},breakGeometry:{visible:!0}},layersPaint:{onLinePoint:D,firstPoint:w,points:A,line:N,polygon:U,breakLine:F},initial:null,dynamicLine:!0,locale:{save:"Save",delete:"Delete all",undo:"Undo",line:"Line",polygon:"Polygon",break:"Split",closeLine:"Close line",createPolygon:"Create polygon"}};var f=class{static addPoint(e,t,i){t.fire(L.ADD,{id:e.id,coordinates:{lat:e.lat,lng:e.lng},total:e.total,timestamp:Date.now(),mode:{geometry:i.getMode(),closedGeometry:i.getClosedGeometry()}});}static movePoint(e,t){t.fire(L.MOVEEND,{id:e.id,start_coordinates:{lat:e.start.lat,lng:e.start.lng},end_coordinates:{lat:e.end.lat,lng:e.end.lng},total:e.total,timestamp:Date.now()});}static pointDoubleClick(e,t){t.fire(L.DOUBLECLICK,{id:e.id,coordinates:{lat:e.lat,lng:e.lng},total:e.total,timestamp:Date.now()});}static enterPoint(e,t){t.fire(L.POINTENTER,{id:e.id,coordinates:{lat:e.lat,lng:e.lng},total:e.total,timestamp:Date.now()});}static leavePoint(e,t){t.fire(L.POINTLEAVE,{id:e.id,coordinates:{lat:e.lat,lng:e.lng},total:e.total,timestamp:Date.now()});}static undoPoint(e,t,i){t.fire(L.UNDO,{originalEvent:i,id:e.id,coordinates:{lat:e.lat,lng:e.lng},total:e.total,timestamp:Date.now()});}static modeChanged(e,t){e.fire(L.MODECHANGED,{mode:t});}static removeAllPoints(e,t){e.fire(L.REMOVEALL,{originalEvent:t});}static onSaveClick(e,t,i){let{map:n,mode:s}=e;n.fire(L.SAVE,{originalEvent:i,timestamp:Date.now(),steps:t,mode:{geometry:s.getMode(),closedGeometry:s.getClosedGeometry()}});}static onLineBreak(e){e.fire(L.BREAK);}};var Q=class{#e;constructor(e){this.#e=e,this.#t();}#t=()=>{this.#e.mode.addObserver(this.#l);};removeConsumers=()=>{this.#e.mode.removeObserver(this.#l);};#i=()=>{let{_line:e,_polygon:t,_break:i}=this.#e.control;e?.classList.remove("control-button-active"),t?.classList.remove("control-button-active"),i?.classList.remove("control-button-active");};#n=e=>{this.#i(),e.classList.add("control-button-active");};#o=e=>{let{data:t}=e,{_line:i,_polygon:n,_break:s}=this.#e.control,{mode:a}=this.#e;if(f.modeChanged(this.#e.map,t),!(!i||!n||!s)){switch(t){case"line":this.#n(i);break;case"polygon":this.#n(n);break;}t?a.getClosedGeometry()&&this.#r(s):this.#s(s);}};#s=e=>{e.setAttribute("disabled","true"),e.setAttribute("aria-disabled","true");};#r=e=>{e.removeAttribute("disabled"),e.removeAttribute("aria-disabled");};#a=e=>{let{data:t}=e,{_break:i,_line:n,_polygon:s}=this.#e.control,{mode:a}=this.#e;t?(i&&this.#r(i),a.getMode()==="polygon"&&n&&this.#s(n),a.getMode()==="line"&&s&&this.#s(s)):(i&&this.#s(i),a.getMode()==="polygon"&&n&&this.#r(n),a.getMode()==="line"&&s&&this.#r(s));};#l=e=>{let{type:t,data:i}=e;if(t==="MODE_CHANGED"&&this.#o(e),t==="CLOSED_GEOMETRY_CHANGED"&&this.#a(e),t==="BREAK_CHANGED"&&i){let{_break:n}=this.#e.control;this.#n(n),f.modeChanged(this.#e.map,"break");}}};var ee=class{#e;#t;#i;constructor(e){this.#e=e,this.#i=new Q(e),this.#t=new k,this.#n();}#n(){let{control:e}=this.#e;if(e){let t={mouseenter:this.onButtonEnter,mouseleave:this.onButtonLeave};e._line&&J(e._line,{...t,click:this.onLineClick}),e._polygon&&J(e._polygon,{...t,click:this.onPolygonClick}),e._break&&J(e._break,{...t,click:this.onBreakClick});}}#o(){let{control:e}=this.#e;if(e){let t={mouseenter:this.onButtonEnter,mouseleave:this.onButtonLeave};e._line&&X(e._line,{...t,click:this.onLineClick}),e._polygon&&X(e._polygon,{...t,click:this.onPolygonClick}),e._break&&X(e._break,{...t,click:this.onBreakClick});}}remove(){this.#i.removeConsumers(),this.#o(),this.#t.remove();}onButtonEnter=e=>{let{options:t}=this.#e,i=e.target.getAttribute("data-type");if(i){let n=be(i,t),s="left";this.#t.create({label:n,placement:s}).setPosition(this.#t.getPosition(e,s));}};onButtonLeave=()=>{this.#t.remove();};#s=()=>{let{control:e}=this.#e;e._line?.classList.remove("control-button-active"),e._polygon?.classList.remove("control-button-active"),e._break?.classList.remove("control-button-active");};#r=()=>{let{map:e,mode:t}=this.#e;t.getMode()||e.fire("mode:initialize");};onLineClick=()=>{let{map:e,mode:t,tiles:i,control:n}=this.#e;this.#r(),this.#s(),t.getMode()==="line"&&!t.getBreak()?(t.setMode(null),e.fire("mode:remove"),i.resetGeometries()):(n._line?.classList.add("control-button-active"),t.setMode("line"),i.render());};onPolygonClick=()=>{let{map:e,mode:t,tiles:i,control:n}=this.#e;this.#r(),this.#s(),t.getMode()==="polygon"&&!t.getBreak()?(t.setMode(null),e.fire("mode:remove"),e.setLayoutProperty(r.PolygonLayer,"visibility","visible"),i.resetGeometries()):(n._polygon?.classList.add("control-button-active"),t.setMode("polygon"),i.render());};onBreakClick=()=>{let{map:e,mode:t,control:i}=this.#e;t.getBreak()&&(t.setMode(null),e.fire("mode:remove")),this.#s(),i._break?.classList.add("control-button-active"),t.setBreak(!0),e.getCanvasContainer().style.cursor=P.POINTER;}};var x=class{observers;constructor(){this.observers=new Set;}addObserver(e){this.observers.add(e);}removeObserver(e){this.observers.delete(e);}unsubscribe(){this.observers.clear();}notify(e){this.observers.forEach(t=>t(e));}};var G={EMPTY_INITIAL_STATE:"You passed an empty initial array in the options. Please either remove the 'initial' property or include at least one element in the array.",MISSING_IDS:"You set 'generateId' to false but did not provide IDs for all steps. Please ensure all steps have IDs or set 'generateId' to true.",NOT_ENOUGH_POINTS_TO_CLOSE:"At least three points are required to close a polygon or a line. Please add more points or set 'closeGeometry' to false.",FIRST_LAST_POINT_NOT_EQUAL:"The first and last points of a polygon or a closed linestring must be the same. Please ensure the first and last points are equal or set 'closeGeometry' to false."};var te=class{val;next;constructor(e=null,t=null){this.val=e,this.next=t;}},q=class extends x{head;tail;size;constructor(e){super();let t=b.initStore(e);this.head=t?t.head:null,this.tail=t?t.tail:null,this.size=t?t.size:0;}push(e){let t=new te(e);this.head?this.tail&&(this.tail.next=t,this.tail=t):this.head=this.tail=t,this.size++,this.pingConsumers();}insert(e,t){let i=new te(e,t.next);this.tail===t&&this.head===t.next&&(this.tail=i),t.next=i,this.size++;}findStepById(e){let t=this.head,i=new Set;for(;t!==null&&!i.has(t);){if(t.val&&t.val.id===e)return t.val;i.add(t),t=t.next;}return null}removeStepById(e){if(!this.head)return null;let t=this.head,i=null;for(;t!==null;){if(t?.val?.id===e)return t===this.head?(this.head=t.next,this.tail&&(this.tail.next=t.next)):i.next=t.next,t===this.tail&&(this.tail=i),this.size--,this.pingConsumers(),t;i=t,t.next&&(t=t.next);}return null}reset(){this.head=null,this.tail=null,this.size=0,this.pingConsumers();}pingConsumers=()=>{this.notify({type:"STORE_CHANGED",data:{head:this.head,tail:this.tail,size:this.size}});}},b=class o{static isLastPoint=(e,t)=>e.tail?.val?.id===t;static initStore(e){if(!e?.initial)return null;if(e&&e.initial&&!e.initial.steps.length)throw new Error(G.EMPTY_INITIAL_STATE);if(e&&e.initial.steps){let{steps:n,closeGeometry:s,generateId:a}=e.initial;return o.fromArray(n,s,a)}return null}static#e=e=>e.map(t=>({...t,id:C()}));static buildStepSequence(e){let t=new q;return e.forEach(i=>{t.push(i);}),t}static fromArray(e,t,i){let n=i?this.#e(e):e,s=this.buildStepSequence(n);return t&&s.tail&&(s.tail.next=s.head),s}static toArray(e){if(!e)return [];let t=new Set,i=[],n=e;for(;n!==null&&!t.has(n);)t.add(n),i.push(n.val),n=n.next;return i}};var ie=class{#e;#t;constructor(e){this.#e=e,this.#t=new k;}initEvents(){let{panel:e}=this.#e;e&&(l.manageEventListener("add",e?._undoButton,"click",this.#o),l.manageEventListener("add",e?._undoButton,"mouseenter",this.onMouseEnter),l.manageEventListener("add",e?._undoButton,"mouseleave",this.onMouseLeave)),e&&(l.manageEventListener("add",e?._deleteButton,"click",this.#n),l.manageEventListener("add",e?._deleteButton,"mouseenter",this.onMouseEnter),l.manageEventListener("add",e?._deleteButton,"mouseleave",this.onMouseLeave)),e&&(l.manageEventListener("add",e?._saveButton,"click",this.onSaveClick),l.manageEventListener("add",e?._saveButton,"mouseenter",this.onMouseEnter),l.manageEventListener("add",e?._saveButton,"mouseleave",this.onMouseLeave));}removeEvents(){let{panel:e}=this.#e;e&&e._undoButton&&(l.manageEventListener("remove",e._undoButton,"click",this.#o),l.manageEventListener("remove",e._undoButton,"mouseenter",this.onMouseEnter),l.manageEventListener("remove",e._undoButton,"mouseleave",this.onMouseLeave)),e&&e._deleteButton&&(l.manageEventListener("remove",e._deleteButton,"click",this.#n),l.manageEventListener("remove",e._deleteButton,"mouseenter",this.onMouseEnter),l.manageEventListener("remove",e._deleteButton,"mouseleave",this.onMouseLeave)),e&&e._saveButton&&(l.manageEventListener("remove",e._saveButton,"click",this.onSaveClick),l.manageEventListener("remove",e._saveButton,"mouseenter",this.onMouseEnter),l.manageEventListener("remove",e._saveButton,"mouseleave",this.onMouseLeave));}#i=e=>{let{options:t}=this.#e;return {undo:t.locale.undo,delete:t.locale.delete,save:t.locale.save}[e]};onMouseEnter=e=>{let t=e.target.getAttribute("data-type");if(t){let i=this.#i(t);this.#t.create({label:i,placement:"bottom"}).setPosition(this.#t.getPosition(e,"bottom"));}};onMouseLeave=()=>{this.#t.remove();};#n=e=>{let{tiles:t,mode:i,panel:n,store:s,map:a}=this.#e;s.reset(),n.hidePanel(),i.reset(),E.togglePointCircleRadius(a,"default"),this.#t.remove(),t.resetGeometries(),f.removeAllPoints(a,e);};#o=e=>{let{store:t,panel:i,map:n,tiles:s}=this.#e,a=t.tail?.val;t.removeStepById(a.id);let p={...a,total:t.size};f.undoPoint(p,n,e),m.switchToLineModeIfCan(this.#e),i?.onPointRemove(t.tail?.val),this.#t.remove(),requestAnimationFrame(s.render);};onSaveClick=e=>{let{store:t,options:i}=this.#e;f.onSaveClick(this.#e,b.toArray(t.head),e),this.#t.remove(),i.panel.buttons.save.clearOnSave&&this.#n(e);}};var M=class{static updatePointsData(e){let i=e.target.getSource(d.SinglePointSource);i&&i.setData({type:"Feature",geometry:{type:"Point",coordinates:[e.lngLat.lng,e.lngLat.lat]},properties:{}});}static setSinglePointVisible(e){e.target.setLayoutProperty(r.SinglePointLayer,"visibility","visible");}static setSinglePointHidden(e){let t=e.target;setTimeout(()=>{t.setLayoutProperty(r.SinglePointLayer,"visibility","none");},33);}static triggerPostPointAddition(e,t){let{panel:i,tiles:n,store:s,map:a}=t;m.canCloseGeometry(s)&&E.togglePointCircleRadius(a,"large"),i?.setPanelLocation(e.lngLat),n.render();}static addPointToMap=(e,t)=>{let{store:i,map:n,mode:s}=t,a={...e.lngLat,id:C()};i.push(a),f.addPoint({...a,total:i.size},n,s),this.triggerPostPointAddition(e,t);};static updateSelectedStepLatLng=(e,t)=>{t.lat=e.lngLat.lat,t.lng=e.lngLat.lng;}};var fe=(o,e)=>{let t=e.head,i=new Set;for(;t!==null&&!i.has(t);){if(t.next&&t.next.val&&t.val){let n=o.target,s=v.getPixelCoordinates(n,t.val),a=v.getPixelCoordinates(n,t.next.val),p=v.getPixelCoordinates(n,o.lngLat);if(m.checkIfPointIsOnLine(s,a,p))return t}i.add(t),t=t.next;}return null},_e=(o,e)=>{let t=fe(o,e);if(t){let i={...o.lngLat,id:C()};return e.insert(i,t),i}return null},Ce=(o,e)=>{let{store:t,tiles:i,panel:n}=e;t.tail?.val&&(n?.setPanelLocation(t.tail.val),M.setSinglePointHidden(o),i.render());},Se=o=>v.isFeatureTriggered(o,[r.PointsLayer,r.FirstPointLayer]);var Oe=15,ne=class{props;#e;#t;constructor(e){this.props=e,this.#e=null,this.#t=O(this.#n,Oe);}initBreakEvents=()=>{let{map:e}=this.props;e.on("click",r.LineLayerTransparent,this.#i),e.on("mouseenter",r.LineLayerTransparent,this.#t),e.on("mousemove",r.LineLayerTransparent,this.#t),e.on("mouseleave",r.LineLayerTransparent,this.#o);};removeBreakEvents=()=>{let{map:e}=this.props;e.off("click",r.LineLayerTransparent,this.#i),e.off("mouseenter",r.LineLayerTransparent,this.#t),e.off("mousemove",r.LineLayerTransparent,this.#t),e.off("mouseleave",r.LineLayerTransparent,this.#o);};hideBreakLine=()=>{let{map:e}=this.props;e.getLayoutProperty(r.LineLayerBreak,"visibility")!=="none"&&e.setLayoutProperty(r.LineLayerBreak,"visibility","none");};showBreakLine=()=>{let{map:e}=this.props;e.getLayoutProperty(r.LineLayerBreak,"visibility")!=="visible"&&e.setLayoutProperty(r.LineLayerBreak,"visibility","visible");};#i=()=>{let{store:e,mode:t,panel:i,map:n,tiles:s}=this.props,a=this.#e?.next?.val?.id;m.breakGeometry(e,a),e.tail?.val&&i.setPanelLocation({lat:e.tail?.val?.lat,lng:e.tail?.val?.lng}),this.#o(),n.setLayoutProperty(r.PolygonLayer,"visibility","none"),t.reset(),s.render(),f.onLineBreak(n);};#n=e=>{let{map:t,store:i}=this.props,n=fe(e,i);n?.val?.id!==this.#e?.val?.id&&(this.#e=n);let s=t.getSource(d.LineSourceBreak),a=[n?.val?.lng,n?.val?.lat],p=[n?.next?.val?.lng,n?.next?.val?.lat],g=_.getLine(a,p);g&&(s.setData(g),this.showBreakLine());};#o=()=>{setTimeout(()=>{this.hideBreakLine();},Oe+10);}};var De=10,oe=class{#e;#t;#i;#n;#o;#s;constructor(e){this.#e=e,this.#t=e.options.dynamicLine,this.#i=null,this.#n=null,this.#r(),this.#s=O(this.#p,De);}#r(){this.#e.store.addObserver(this.#l),this.#e.mode.addObserver(this.#c),this.#e.mouseEvents.addObserver(this.#a);}removeLine=()=>{this.hideDynamicLine();};removeConsumers=()=>{this.#e.store.removeObserver(this.#l),this.#e.mode.removeObserver(this.#c),this.#e.mouseEvents.removeObserver(this.#a);};#a=e=>{let{mode:t}=this.#e;if(!t.getClosedGeometry()&&(e.type==="lastPointMouseClick"&&e.data?(this.hideDynamicLine(),this.#t=!1):e.type==="lastPointMouseClick"&&!e.data&&(this.#t=!0),!!this.#t&&((e.type==="pointMouseEnter"||e.type==="lineMouseEnter")&&e.data&&this.hideDynamicLine(),(e.type==="pointMouseLeave"||e.type==="lineMouseLeave")&&e.data))){let{store:i}=this.#e;this.#i=i.tail?.val,this.#n=i.tail?.val,this.showDynamicLine();}};#l=e=>{let{store:t}=this.#e;switch(e.type){case"STORE_CHANGED":e.data.tail?.val&&!m.isClosedGeometry(t)&&(this.#i=e.data.tail?.val,this.showDynamicLine());break;}};#c=e=>{let{store:t}=this.#e;e.type==="CLOSED_GEOMETRY_CHANGED"&&(e.data&&this.hideDynamicLine(),!e.data&&t?.tail?.val&&(this.#i=t?.tail?.val,this.showDynamicLine()));};initDynamicEvents=()=>{let{map:e}=this.#e;e.on("click",this.#f),e.on("mousemove",this.#s),e.on(L.REMOVEALL,this.hideDynamicLine),e.on(L.UNDO,this.#m),e.on(L.DOUBLECLICK,this.#v);};removeEvents=()=>{let{map:e}=this.#e;e.off("click",this.#f),e.off("mousemove",this.#s),e.off(L.REMOVEALL,this.hideDynamicLine),e.off(L.UNDO,this.#m),e.off(L.DOUBLECLICK,this.#v);};hideDynamicLine=()=>{let{map:e,tiles:t}=this.#e;this.#i=null,this.#n=null,this.#o=null,e.off("mousemove",this.#s),t.renderLines(K,d.LineDynamicSource),e.setLayoutProperty(r.LineDynamicLayer,"visibility","none");};showDynamicLine=()=>{let{map:e}=this.#e,t=[this.#i?.lng,this.#i?.lat],i=[this.#n?.lng,this.#n?.lat];this.#o=_.getLine(t,i),e.setLayoutProperty(r.LineDynamicLayer,"visibility","visible"),this.#n&&this.#h({lng:this.#n?.lng,lat:this.#n?.lat}),e.on("mousemove",this.#s);};#h=e=>{if(!this.#o)return;let{tiles:t}=this.#e;this.#o.features[0].geometry.coordinates[1]=[e.lng,e.lat],t.renderLines(this.#o,d.LineDynamicSource);};#p=e=>{this.#h(e.lngLat);};#f=e=>{let{mode:t}=this.#e,i=v.isFeatureTriggered(e,[r.LineLayerTransparent,r.LineLayer]);i&&t.getBreak()&&(this.#n={lng:e.lngLat.lng,lat:e.lngLat.lat}),!i&&this.hideDynamicLine();};#m=e=>{let{store:t,mode:i}=this.#e;if(!i.getClosedGeometry()){let n=e.target.unproject({x:e.originalEvent.x,y:e.originalEvent.y});this.#n={lng:n.lng,lat:n.lat},this.#i=t.tail?.val,this.showDynamicLine();}};#v=e=>{let{store:t,mode:i}=this.#e;i.getClosedGeometry()||(this.#n={lng:e.coordinates.lng,lat:e.coordinates.lat},this.#i=t.tail?.val,this.showDynamicLine());}};var Ae=22,se=class{props;#e;#t;constructor(e){this.props=e,this.#e=!1,this.#t=null;}initEvents(){let{map:e}=this.props;e.on("click",r.LineLayerTransparent,this.#i),e.on("mousemove",r.LineLayerTransparent,this.#o),e.on("mouseenter",r.LineLayerTransparent,this.#s),e.on("mouseleave",r.LineLayerTransparent,this.#r);}removeEvents(){let{map:e}=this.props;e.off("click",r.LineLayerTransparent,this.#i),e.off("mousemove",r.LineLayerTransparent,this.#o),e.off("mouseenter",r.LineLayerTransparent,this.#s),e.off("mouseleave",r.LineLayerTransparent,this.#r);}#i=e=>{let{store:t,map:i,mode:n}=this.props;if(Se(e))return;let s=_e(e,t);s&&(f.addPoint({...s,total:t.size},i,n),Ce(e,this.props));};#n=e=>{M.setSinglePointVisible(e),e.target.getLayer(r.SinglePointLayer)&&M.updatePointsData(e);};#o=O(e=>{if(v.isFeatureTriggered(e,[r.PointsLayer,r.FirstPointLayer]))return;let{mouseEvents:t}=this.props;t.pointMouseDown||t.pointMouseEnter||(this.#t=e,!this.#e&&(this.#e=!0,requestAnimationFrame(()=>{this.#t&&(this.#n(this.#t),this.#e=!1);})));},Ae);#s=e=>{let{mouseEvents:t}=this.props;t.pointMouseDown||t.pointMouseEnter||v.isFeatureTriggered(e,[r.PointsLayer,r.FirstPointLayer])||(t.lineMouseEnter=!0,M.setSinglePointVisible(e));};#r=e=>{let{mouseEvents:t}=this.props;t.pointMouseDown||t.pointMouseEnter||(t.lineMouseLeave=!0,M.setSinglePointHidden(e));}};var re=class{props;#e;#t;#i;#n;constructor(e){this.props=e,this.#e=new ne(e),this.#t=new se(e),this.#i=null,this.#n="default";}init(){this.#o(),this.#s(),this.#r();}#o=()=>{window.innerWidth<=768||this.props.options.dynamicLine&&(this.#i=new oe(this.props));};#s(){!this.props.mode.getBreak()&&(this.#t.initEvents(),this.props.options.dynamicLine&&this.#i?.initDynamicEvents());}#r(){this.props.mode.addObserver(this.#h),this.props.mouseEvents.addObserver(this.#c);}remove(){this.#a(),this.#l();}#a(){this.props.mode.removeObserver(this.#h),this.props.mouseEvents.removeObserver(this.#c),this.props.options.dynamicLine&&this.#i?.removeConsumers();}#l(){this.#e.removeBreakEvents(),this.#t.removeEvents(),this.props.options.dynamicLine&&(this.#i?.removeEvents(),this.#i?.removeLine());}#c=e=>{let{type:t,data:i}=e,{mode:n}=this.props;if(!(!i||!n.getBreak()))switch(t){case"pointMouseDown":this.#e.removeBreakEvents(),this.#e.hideBreakLine();break;case"pointMouseUp":this.#e.initBreakEvents();break;}};#h=e=>{let{type:t,data:i}=e;t==="MODE_CHANGED"&&this.#n==="break"&&(this.#e.removeBreakEvents(),this.#t.initEvents(),this.#n="default"),t==="BREAK_CHANGED"&&i&&this.#n==="default"&&(this.#t.removeEvents(),this.#e.initBreakEvents(),this.#n="break");}};var ae=class{#e;#t;#i;constructor(e){this.#t=e,this.#e=!1,this.#i=new k,e.mode.addObserver(this.#n);}initEvents(){let{map:e}=this.#t;e.on("click",r.FirstPointLayer,this.#o),e.on("mouseenter",r.FirstPointLayer,this.#c),e.on("mouseleave",r.FirstPointLayer,this.#a),e.on("mouseup",r.FirstPointLayer,this.#r),e.on("mousedown",r.FirstPointLayer,this.#s);}removeEvents(){let{map:e}=this.#t;e.off("click",r.FirstPointLayer,this.#o),e.off("mouseenter",r.FirstPointLayer,this.#c),e.off("mouseleave",r.FirstPointLayer,this.#a),e.off("mouseup",r.FirstPointLayer,this.#r);}#n=e=>{let{map:t,store:i}=this.#t,{type:n,data:s}=e;n==="MODE_CHANGED"&&(s==="line"||s==="polygon"?t.on("click",r.FirstPointLayer,this.#o):t.off("click",r.FirstPointLayer,this.#o),m.canCloseGeometry(i)&&E.togglePointCircleRadius(t,"large"));};#o=()=>{let{store:e,map:t,mode:i,tiles:n}=this.#t;if(i.getMode()==="polygon"&&t.setLayoutProperty(r.PolygonLayer,"visibility","visible"),m.canCloseGeometry(e)){m.closeGeometry(e,i);let s=Object.assign({},e.head?.val,{id:C(),total:e.size});f.addPoint(s,t,i),E.togglePointCircleRadius(t,"default"),n.render();}};#s=()=>{this.#e=!0,this.#i.remove();};#r=()=>{this.#e=!1;};#a=()=>{let{mouseEvents:e}=this.#t;this.#e||(e.firstPointMouseLeave=!0,this.#i.remove());};#l=()=>{let{mode:e,options:t}=this.#t;return e.getMode()==="line"&&t.modes.line.closeGeometry?t.locale.closeLine:e.getMode()==="polygon"?t.locale.createPolygon:""};#c=e=>{let{mode:t,mouseEvents:i,store:n}=this.#t;if(!(t.getClosedGeometry()||this.#e)&&(i.firstPointMouseEnter=!0,m.canCloseGeometry(n))){let{x:s,y:a}=e.originalEvent;if(s&&a){this.#i.create({label:this.#l(),placement:"bottom"});let g=this.#i._label?this.#i._label.clientWidth/2:0;this.#i.setPosition({x:s-g,y:a+14});}}}};var le=class{#e;#t;#i;#n;#o;#s;#r;#a;constructor(e){this.#e=e,this.#t=void 0,this.#i=null,this.#n=null,this.#o=null,this.#s=new ae(e),this.#r=!1,this.#a=null;}#l=()=>{let{map:e}=this.#e;e.on("click",r.FirstPointLayer,this.#p),e.on("mouseenter",r.FirstPointLayer,this.#L),e.on("mouseleave",r.FirstPointLayer,this.#g),e.on("mousedown",r.FirstPointLayer,this.#d),e.on("mouseup",r.FirstPointLayer,this.#u),e.on("touchend",r.FirstPointLayer,this.#u),e.on("touchstart",r.FirstPointLayer,this.#d),this.#s.initEvents();};initEvents=()=>{let{map:e}=this.#e;e.on("click",this.#m),e.on("dblclick",this.#h),e.on("click",r.PointsLayer,this.#p),e.on("mouseenter",r.PointsLayer,this.#L),e.on("mouseleave",r.PointsLayer,this.#g),e.on("mousedown",r.PointsLayer,this.#d),e.on("mouseup",r.PointsLayer,this.#u),e.on("touchend",r.PointsLayer,this.#u),e.on("touchstart",r.PointsLayer,this.#d),this.#l();};#c=()=>{let{map:e}=this.#e;e.off("click",r.FirstPointLayer,this.#p),e.off("mouseenter",r.FirstPointLayer,this.#L),e.off("mouseleave",r.FirstPointLayer,this.#g),e.off("mousedown",r.FirstPointLayer,this.#d),e.off("mouseup",r.FirstPointLayer,this.#u),e.off("touchend",r.PointsLayer,this.#u),e.off("touchstart",r.PointsLayer,this.#d),this.#s.removeEvents();};removeEvents=()=>{let{map:e}=this.#e;e.off("click",this.#m),e.off("dblclick",this.#h),e.off("mousemove",this.#y),e.off("click",r.PointsLayer,this.#p),e.off("mouseenter",r.PointsLayer,this.#L),e.off("mouseleave",r.PointsLayer,this.#g),e.off("mousedown",r.PointsLayer,this.#d),e.off("mouseup",r.PointsLayer,this.#u),this.#c();};#h=e=>{e.preventDefault();};#p=e=>{let{store:t,tiles:i,panel:n,map:s,mouseEvents:a}=this.#e;E.isDoubleClick()&&this.#n&&(t.removeStepById(this.#n.id),n.onPointRemove(t.tail?.val),f.pointDoubleClick({...this.#n,total:t.size},this.#e.map),m.switchToLineModeIfCan(this.#e));let p=v.queryPointId(s,e.point);b.isLastPoint(t,p)&&(a.lastPointMouseClick=!0,a.lastPointMouseUp=!1),i.render();};#f=e=>v.isFeatureTriggered(e,[r.PointsLayer,r.FirstPointLayer,r.LineLayerTransparent,r.LineLayerBreak]);#m=e=>{let{mode:t,mouseEvents:i,map:n}=this.#e;t.getClosedGeometry()||this.#f(e)||(i.lastPointMouseClick&&(i.lastPointMouseClick=!1),n.getCanvasContainer().style.cursor="grab",M.addPointToMap(e,this.#e),M.setSinglePointHidden(e));};#v=e=>{e.originalEvent.buttons===0&&this.#u();};#E=e=>{let{tiles:t}=this.#e;t.renderOnMouseMove(this.#o,e.lngLat);};#y=O(e=>{this.#a=e,this.#r||(this.#r=!0,requestAnimationFrame(()=>{!this.#n||!this.#a||(M.updateSelectedStepLatLng(this.#a,this.#n),this.#v(this.#a),this.#E(this.#a),this.#r=!1);}));},15);#L=e=>{let{mouseEvents:t,map:i,store:n}=this.#e;if(t&&(t.pointMouseEnter=!0,t.pointMouseDown))return;M.setSinglePointHidden(e);let s=v.queryPointId(i,e.point);b.isLastPoint(n,s)&&(t.lastPointMouseEnter=!0,t.lastPointMouseLeave=!1);let a=n.findStepById(s);a&&(this.#i=a,f.enterPoint(Object.assign({},a,{total:n.size}),i));};#g=e=>{let{mouseEvents:t,store:i,map:n}=this.#e;if(t&&(t.pointMouseEnter=!1,e.originalEvent.buttons===0&&(t.pointMouseLeave=!0),t.pointMouseDown))return;let s=v.queryPointId(n,e.point);b.isLastPoint(i,s)&&(t.lastPointMouseEnter=!1,t.lastPointMouseLeave=!0),f.leavePoint(Object.assign({},this.#i,{total:i.size}),n);};#P=()=>{let{store:e,panel:t}=this.#e;this.#n&&b.isLastPoint(e,this.#n.id)&&t.hidePanel();};#M=e=>{let{store:t,map:i}=this.#e,n=v.queryPointId(i,e.point),s=t.findStepById(n);s&&(this.#n=s);};#d=e=>{e.preventDefault();let{mouseEvents:t,map:i,store:n}=this.#e;E.removeTransparentLine(i),this.#M(e),this.#P();let s=v.queryPointId(i,e.point);this.#o=m.getGeometryIndex(n,s),t&&(t.pointMouseDown=!0),this.#t=e.lngLat,i.on("mousemove",this.#y),i.on("touchmove",this.#y);};#u=()=>{let{mouseEvents:e,store:t,panel:i,map:n,options:s}=this.#e;e.pointMouseUp=!0,this.#n&&(b.isLastPoint(t,this.#n.id)&&t.tail?.val&&i?.setPanelLocation(t.tail.val),i?.showPanel(),f.movePoint({id:this.#n.id,total:t.size,end:{lat:this.#n.lat,lng:this.#n.lng},start:this.#t},n)),e&&(e.pointMouseDown=!1),E.addTransparentLine(n,s),n.off("mousemove",this.#y),n.off("touchmove",this.#y);}};var ce=class extends R{#e;#t;#i;#n;#o;constructor(e){super({...e}),this.#e=e,this.#t=new ie(e),this.#i=new ee(e),this.#n=new le(e),this.#o=new re(e),e.map.on("mode:initialize",this.#s),e.map.on("mode:remove",this.#r);}#s=()=>{this.#o.init(),this.#t?.initEvents(),this.#n?.initEvents();};#r=()=>{this.#t?.removeEvents(),this.#n?.removeEvents(),this.#o?.remove();};removeMapEventsAndConsumers=()=>{this.#t?.removeEvents(),this.#n?.removeEvents(),this.#i?.remove(),this.#o?.remove(),this.#e.map.off("mode:initialize",this.#s);}};var he=class{#e;_line;_polygon;_break;_container;constructor(e){this.#e=e.options,this._line=void 0,this._polygon=void 0,this._break=void 0,this._container=l.create("div","mapboxgl-ctrl mapboxgl-ctrl-group maplibregl-ctrl maplibregl-ctrl-group"),this.createControl(e);}createControlButton=(e,t,i,n)=>{let s=this.#e.panel.size,a=l.create("button",`control-button control-button-${s}`,this._container);return a.setAttribute("aria-label",t),a.setAttribute("data-type",e),i&&a.classList.add("control-button-active"),n&&(a.setAttribute("disabled","true"),a.setAttribute("aria-disabled","true")),l.create("span",`icon ${e} icon-${s}`,a),a};#t=e=>{let{mode:t,options:i}=e,n=this.#e.modes.line.visible,s=i.locale.line;n&&(this._line=this.createControlButton("line",s,t.getMode()==="line"));};#i=e=>{let{mode:t,options:i}=e,n=this.#e.modes.polygon.visible,s=i.locale.polygon;n&&(this._polygon=this.createControlButton("polygon",s,t.getMode()==="polygon"));};#n=e=>{let{mode:t,options:i}=e,n=this.#e.modes.breakGeometry.visible,s=i.locale.break;if(n){let p=!this.#e?.initial?.closeGeometry,g=t.getBreak();this._break=this.createControlButton("break",s,g,p);}};createControl=e=>{this.#t(e),this.#i(e),this.#n(e);};getContainer=()=>this._container};function Ie(o){return o.initial?.geometry?o.initial?.geometry:o.modes.initial?o.modes.initial:null}var pe=class extends x{#e;#t;#i;constructor(e){super(),this.#e=Ie(e),this.#t=!1,this.#i=e.initial?.closeGeometry??!1;}getMode=()=>this.#e;setMode=e=>{this.#e=e,this.setBreak(!1),this.notify({type:"MODE_CHANGED",data:e});};getBreak=()=>this.#t;setBreak=e=>{this.#t=e,this.notify({type:"BREAK_CHANGED",data:e});};getClosedGeometry=()=>this.#i;setClosedGeometry=e=>{this.#i=e,this.notify({type:"CLOSED_GEOMETRY_CHANGED",data:this.#i});};isPolygon=()=>this.#e==="polygon"&&this.#i;reset=()=>{this.setMode(this.getMode()),this.setClosedGeometry(!1);};pingConsumers=()=>{this.notify({type:"MODE_CHANGED",data:this.getMode()}),this.notify({type:"CLOSED_GEOMETRY_CHANGED",data:this.getClosedGeometry()});}};var ue=class{#e;#t;constructor(e){this.#e=e,this.#t=this.#e.map.getCanvasContainer(),this.#t.style.cursor=e.mode.getMode()?P.CROSSHAIR:P.AUTO,this.#i();}set=e=>{this.#t.style.cursor=e;};get=()=>this.#t.style.cursor;handleMouseLeave=()=>{let{mouseEvents:e,mode:t}=this.#e;if(!e.pointMouseDown){if(!t.getMode()){this.set(P.AUTO);return}t.getClosedGeometry()?this.set(P.AUTO):this.set(P.CROSSHAIR);}};handleFirstPointMouseEnter=()=>{let{mode:e,store:t}=this.#e;e.getClosedGeometry()&&this.set(P.MOVE),m.canCloseGeometry(t)&&this.set(P.POINTER);};#i(){let{mouseEvents:e}=this.#e;e.addObserver(this.#n);}removeConsumers(){let{mouseEvents:e}=this.#e;e.removeObserver(this.#n);}#n=e=>{let{mode:t,mouseEvents:i}=this.#e;if(t.getBreak())return;let{type:n,data:s}=e;if(s)switch(n){case"pointMouseDown":this.set(P.GRABBING);break;case"pointMouseUp":this.set(P.GRAB);break;case"pointMouseEnter":if(i.pointMouseDown)return;this.set(P.GRAB);break;case"pointMouseLeave":this.handleMouseLeave();break;case"lineMouseEnter":if(i.pointMouseDown)return;this.set(P.POINTER);break;case"lineMouseLeave":this.handleMouseLeave();break;case"firstPointMouseEnter":this.handleFirstPointMouseEnter();break;case"firstPointMouseLeave":this.handleMouseLeave();break;case"lastPointMouseEnter":this.set(P.POINTER);break;case"lastPointMouseLeave":this.handleMouseLeave();break;}}};var de=class extends x{#e;#t;#i;#n;#o;#s;#r;#a;#l;#c;#h;#p;constructor(){super(),this.#e=!1,this.#t=!1,this.#i=!1,this.#n=!1,this.#o=!1,this.#s=!1,this.#r=!1,this.#a=!1,this.#l=!1,this.#c=!1,this.#h=!1,this.#p=!1;}get firstPointMouseEnter(){return this.#e}set firstPointMouseEnter(e){this.#e=e,this.notify({type:"firstPointMouseEnter",data:e});}get firstPointMouseLeave(){return this.#t}set firstPointMouseLeave(e){this.#t=e,this.notify({type:"firstPointMouseLeave",data:e});}get lastPointMouseClick(){return this.#i}set lastPointMouseClick(e){this.#i=e,this.notify({type:"lastPointMouseClick",data:e});}get lastPointMouseUp(){return this.#n}set lastPointMouseUp(e){this.#n=e,this.notify({type:"lastPointMouseUp",data:e});}get lastPointMouseEnter(){return this.#o}set lastPointMouseEnter(e){this.#o=e,this.notify({type:"lastPointMouseEnter",data:e});}get lastPointMouseLeave(){return this.#s}set lastPointMouseLeave(e){this.#s=e,this.notify({type:"lastPointMouseLeave",data:e});}get pointMouseDown(){return this.#r}set pointMouseDown(e){this.#r=e,this.notify({type:"pointMouseDown",data:e});}get pointMouseUp(){return this.#a}set pointMouseUp(e){this.#a=e,this.notify({type:"pointMouseUp",data:e});}get pointMouseEnter(){return this.#l}set pointMouseEnter(e){this.#l=e,this.notify({type:"pointMouseEnter",data:e});}get pointMouseLeave(){return this.#c}set pointMouseLeave(e){this.#c=e,this.notify({type:"pointMouseLeave",data:e});}get lineMouseEnter(){return this.#h}set lineMouseEnter(e){this.#h=e,this.notify({type:"lineMouseEnter",data:e});}get lineMouseLeave(){return this.#p}set lineMouseLeave(e){this.#p=e,this.notify({type:"lineMouseLeave",data:e});}};var z=class{static allStepsHaveIds(e){return e.every(t=>"id"in t&&t.id!==void 0)}static checkIfMissingIds(e,t){let i=!t,n=!this.allStepsHaveIds(e);if(i&&n)throw new Error(G.MISSING_IDS)}static checkIfEnoughPointsToClose(e,t){if(t&&e.length<3)throw new Error(G.NOT_ENOUGH_POINTS_TO_CLOSE)}static checkIfPolygonIsClosed(e){let{closeGeometry:t,steps:i}=e;if(i){let n=i[0]?.lng,s=i[i.length-1]?.lng,a=i[0]?.lat,p=i[i.length-1]?.lat;if((n!==s||a!==p)&&t)throw new Error(G.FIRST_LAST_POINT_NOT_EQUAL)}}static checkInitialStepsOption(e){let{closeGeometry:t,generateId:i,steps:n}=e;this.checkIfMissingIds(n,i),this.checkIfEnoughPointsToClose(n,t),this.checkIfPolygonIsClosed(e);}static init(e){return e?{panel:Be(e),modes:Ne(e),layersPaint:Fe(e),initial:e.initial||y.initial,locale:Re(e),dynamicLine:e.dynamicLine??y.dynamicLine}:y}};function Be(o){return {size:o.panel?.size||y.panel.size,buttons:{undo:{visible:o.panel?.buttons?.undo?.visible??y.panel.buttons.undo.visible},delete:{visible:o.panel?.buttons?.delete?.visible??y.panel.buttons.delete.visible},save:{visible:o.panel?.buttons?.save?.visible??y.panel.buttons.save.visible,clearOnSave:o.panel?.buttons?.save?.clearOnSave??y.panel.buttons.save.clearOnSave}}}}function Ne(o){return {initial:o.modes?.initial||y.modes.initial,line:{visible:o?.modes?.line?.visible!==void 0?o.modes.line.visible:o?.initial?.geometry==="line"||y.modes.line.visible,closeGeometry:o?.modes?.line?.closeGeometry??o?.initial?.closeGeometry??y.modes.line.closeGeometry},polygon:{visible:o?.modes?.polygon?.visible!==void 0?o.modes.polygon.visible:o?.initial?.geometry==="polygon"||y.modes.polygon.visible},breakGeometry:{visible:o?.modes?.breakGeometry?.visible??y.modes.breakGeometry.visible}}}function Fe(o){return {onLinePoint:{"circle-radius":o.layersPaint?.onLinePoint?.["circle-radius"]||D["circle-radius"],"circle-color":o.layersPaint?.onLinePoint?.["circle-color"]||D["circle-color"],"circle-stroke-color":o.layersPaint?.onLinePoint?.["circle-stroke-color"]||D["circle-stroke-color"],"circle-stroke-width":o.layersPaint?.onLinePoint?.["circle-stroke-width"]||D["circle-stroke-width"],...o.layersPaint?.onLinePoint},firstPoint:{"circle-radius":o.layersPaint?.firstPoint?.["circle-radius"]||w["circle-radius"],"circle-color":o.layersPaint?.firstPoint?.["circle-color"]||w["circle-color"],"circle-stroke-color":o.layersPaint?.firstPoint?.["circle-stroke-color"]||w["circle-stroke-color"],"circle-stroke-width":o.layersPaint?.firstPoint?.["circle-stroke-width"]||w["circle-stroke-width"],...o.layersPaint?.firstPoint},points:{"circle-radius":o.layersPaint?.points?.["circle-radius"]||A["circle-radius"],"circle-color":o.layersPaint?.points?.["circle-color"]||A["circle-color"],"circle-stroke-color":o.layersPaint?.points?.["circle-stroke-color"]||A["circle-stroke-color"],"circle-stroke-width":o.layersPaint?.points?.["circle-stroke-width"]||A["circle-stroke-width"],...o.layersPaint?.points},line:{"line-width":o.layersPaint?.line?.["line-width"]||N["line-width"],"line-color":o.layersPaint?.line?.["line-color"]||N["line-color"],"line-opacity":o.layersPaint?.line?.["line-opacity"]||N["line-opacity"],...o.layersPaint?.line},polygon:{"fill-color":o.layersPaint?.polygon?.["fill-color"]||U["fill-color"],"fill-opacity":o.layersPaint?.polygon?.["fill-opacity"]||U["fill-opacity"],...o.layersPaint?.polygon},breakLine:{"line-width":o.layersPaint?.breakLine?.["line-width"]||F["line-width"],"line-color":o.layersPaint?.breakLine?.["line-color"]||F["line-color"],"line-dasharray":o.layersPaint?.breakLine?.["line-dasharray"]||F["line-dasharray"],...o.layersPaint?.breakLine}}}function Re(o){return {save:o.locale?.save??y.locale.save,delete:o.locale?.delete??y.locale.delete,undo:o.locale?.undo??y.locale.undo,line:o.locale?.line??y.locale.line,polygon:o.locale?.polygon??y.locale.polygon,break:o.locale?.break??y.locale.break,closeLine:o.locale?.closeLine??y.locale.closeLine,createPolygon:o.locale?.createPolygon??y.locale.createPolygon}}var ve=class o{#e;#t;#i;#n;#o;#s;#r;#a;#l;static#c=null;static#h=!1;constructor(e){if(this.#n=z.init(e),this.#n.initial&&z.checkInitialStepsOption(this.#n.initial),o.#h)throw new Error("Use 'DrawLibre.getInstance()' instead of 'new DrawLibre()'.");o.#h=!0,this.#t=void 0,this.#i=void 0,this.#o=void 0,this.#s=void 0,this.#r=void 0,this.#l=void 0,this.#a=void 0;}static getInstance(e){return o.#c||(o.#c=new o(e)),o.#c}onAdd(e){this.#t=new q(this.#n),this.#i=new pe(this.#n),this.#r=new W({map:e,mode:this.#i,options:this.#n,store:this.#t}),this.#s=new R({map:e,store:this.#t,options:this.#n,mode:this.#i});let t=new he({options:this.#n,mode:this.#i});return this.#l=new de,this.#a=new ue({map:e,mode:this.#i,mouseEvents:this.#l,store:this.#t}),this.#o=new ce({map:e,store:this.#t,options:this.#n,panel:this.#r,control:t,mode:this.#i,tiles:this.#s,mouseEvents:this.#l}),this.#i.getMode()&&e.fire("mode:initialize"),this.#i.pingConsumers(),this.#e=t.getContainer(),this.#e}onRemove(){this.#a?.removeConsumers(),this.#s?.removeTiles(),this.#o?.removeMapEventsAndConsumers(),this.#r?.removePanel(),this.#t?.reset(),this.#i?.unsubscribe(),this.#e&&l.remove(this.#e);}setSteps=e=>{if(Array.isArray(e))e.forEach(t=>{let i={...t,id:t.id||C()};this.#t?.push(i);});else throw new Error("Invalid argument. Expected an array of steps.");this.#s?.render();};findStepById=e=>this.#t?.findStepById(e);getAllSteps=(e="array")=>{if(e==="array"&&this.#t)return b.toArray(this.#t.head);if(e==="linkedlist")return this.#t;throw new Error("Invalid type specified. Use 'array' or 'linkedlist'.")};setOptions=e=>{this.#n=e(this.#n);};removeAllSteps=()=>{this.#t?.reset(),this.#r?.removePanel(),this.#s?.render();}};
1
+ var l=class o{static docStyle=typeof window<"u"&&window.document&&window.document.documentElement.style;static transformProp=o.testProp(["transform","WebkitTransform"]);static testProp(e){if(!o.docStyle)return e[0];for(let t=0;t<e.length;t++)if(e[t]in o.docStyle)return e[t];return e[0]}static create(e,t,i){let n=window.document.createElement(e);return t!==void 0&&(n.className=t),i&&i.appendChild(n),n}static remove(e){e.parentNode&&e.parentNode.removeChild(e);}static setTransform(e,t){o.transformProp&&e.style&&(e.style[o.transformProp]=t);}static manageEventListener(e,t,i,n,s={}){if(!t)return;let a=e==="add"?"addEventListener":"removeEventListener";"passive"in s?t[a](i,n,s):t[a](i,n,s.capture);}static mouseButton(e){return e.button}static addClassName(e,t){e.classList.contains(t)||e.classList.add(t);}static removeClassName(e,t){e.classList.contains(t)&&e.classList.remove(t);}};var _=class o{lng;lat;constructor(e,t){if(isNaN(e)||isNaN(t))throw new Error(`Invalid LngLat object: (${e}, ${t})`);if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}static convert(e){if(e instanceof o)return e;if(Array.isArray(e)&&(e.length===2||e.length===3))return new o(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null)return new o(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}};function R(o,...e){for(let t of e)for(let i in t)o[i]=t[i];return o}function fe(o,e,t){let i=new _(o.lng,o.lat);if(o=new _(o.lng,o.lat),e){let n=new _(o.lng-360,o.lat),s=new _(o.lng+360,o.lat),a=t.locationPoint(o).distSqr(e);t.locationPoint(n).distSqr(e)<a?o=n:t.locationPoint(s).distSqr(e)<a&&(o=s);}for(;Math.abs(o.lng-t.center.lng)>180;){let n=t.locationPoint(o);if(n.x>=0&&n.y>=0&&n.x<=t.width&&n.y<=t.height)break;o.lng>t.center.lng?o.lng-=360:o.lng+=360;}return o.lng!==i.lng&&t.locationPoint(o).y>t.height/2-t.getHorizon()?o:i}var ue={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function ve(o,e,t){let i=o.classList;for(let n in ue)i.remove(`maplibregl-${t}-anchor-${n}`);i.add(`maplibregl-${t}-anchor-${e}`);}function Le(o,e,t){t[o]&&t[o].indexOf(e)!==-1||(t[o]=t[o]||[],t[o].push(e));}function de(o,e,t){if(t&&t[o]){let i=t[o].indexOf(e);i!==-1&&t[o].splice(i,1);}}var q=class{_listeners;_oneTimeListeners;_eventedParent;_eventedParentData;on(e,t){return this._listeners=this._listeners||{},Le(e,t,this._listeners),this}off(e,t){return de(e,t,this._listeners),de(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},Le(e,t,this._oneTimeListeners),this):new Promise(i=>this.once(e,i))}fire(e,t){typeof e=="string"&&(e=new D(e,t||{}));let i=e.type;if(this.listens(i)){e.target=this;let n=this._listeners&&this._listeners[i]?this._listeners[i].slice():[];for(let c of n)c.call(this,e);let s=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(let c of s)de(i,c,this._oneTimeListeners),c.call(this,e);let a=this._eventedParent;a&&(R(e,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),a.fire(e));}else e instanceof ErrorEvent&&console.error(e.error);return this}listens(e){return this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e)}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}},D=class{type;constructor(e,t={}){R(this,t),this.type=e;}};var h=class o{x;y;constructor(e,t){this.x=e,this.y=t;}mag(){return Math.sqrt(this.x*this.x+this.y*this.y)}equals(e){return this.x===e.x&&this.y===e.y}dist(e){return Math.sqrt(this.distSqr(e))}distSqr(e){let t=e.x-this.x,i=e.y-this.y;return t*t+i*i}angle(){return Math.atan2(this.y,this.x)}angleTo(e){return Math.atan2(this.y-e.y,this.x-e.x)}angleWith(e){return this.angleWithSep(e.x,e.y)}angleWithSep(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)}_matMult(e){let t=e[0]*this.x+e[1]*this.y,i=e[2]*this.x+e[3]*this.y;return this.x=t,this.y=i,this}_add(e){return this.x+=e.x,this.y+=e.y,this}_sub(e){return this.x-=e.x,this.y-=e.y,this}_mult(e){return this.x*=e,this.y*=e,this}_div(e){return this.x/=e,this.y/=e,this}_multByPoint(e){return this.x*=e.x,this.y*=e.y,this}_divByPoint(e){return this.x/=e.x,this.y/=e.y,this}_unit(){return this._div(this.mag()),this}_perp(){let e=this.y;return this.y=this.x,this.x=-e,this}_rotate(e){let t=Math.cos(e),i=Math.sin(e),n=t*this.x-i*this.y,s=i*this.x+t*this.y;return this.x=n,this.y=s,this}_rotateAround(e,t){let i=Math.cos(e),n=Math.sin(e),s=t.x+i*(this.x-t.x)-n*(this.y-t.y),a=t.y+n*(this.x-t.x)+i*(this.y-t.y);return this.x=s,this.y=a,this}_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}static convert(e){if(e instanceof o)return e;if(Array.isArray(e))return new o(+e[0],+e[1]);if(e.x!==void 0&&e.y!==void 0)return new o(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")}};var Se={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1},Oe=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", "),z=class extends q{_map;options;_content;_container;_closeButton;_tip;_lngLat;_trackPointer;_pos;_flatPos;constructor(e){super(),this.options=R(Object.create(Se),e);}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new D("open")),this}isOpen(){return !!this._map}remove=()=>(this._content&&l.remove(this._content),this._container&&(l.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new D("close"))),this);getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=_.convert(e),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){let t=document.createDocumentFragment(),i=document.createElement("body"),n;for(i.innerHTML=e;n=i.firstChild,!!n;)t.appendChild(n);return this.setDOMContent(t)}getMaxWidth(){return this._container?.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=l.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(e),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(e){return this._container&&this._container.classList.add(e),this}removeClassName(e){return this._container&&this._container.classList.remove(e),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){if(this._container)return this._container.classList.toggle(e)}setSubpixelPositioning(e){this.options.subpixelPositioning=e;}_createCloseButton(){this.options.closeButton&&(this._closeButton=l.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="&#215;",this._closeButton.addEventListener("click",this._onClose));}_onMouseUp=e=>{this._update(e.point);};_onMouseMove=e=>{this._update(e.point);};_onDrag=e=>{this._update(e.point);};_update=e=>{let t=this._lngLat||this._trackPointer;if(!this._map||!t||!this._content)return;if(!this._container){if(this._container=l.create("div","maplibregl-popup",this._map.getContainer()),this._tip=l.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(let c of this.options.className.split(" "))this._container.classList.add(c);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer");}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._map.transform.renderWorldCopies&&!this._trackPointer?this._lngLat=fe(this._lngLat,this._flatPos,this._map.transform):this._lngLat=this._lngLat?.wrap(),this._trackPointer&&!e)return;let i=this._flatPos=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&e?e:this._map.transform.locationPoint(this._lngLat));let n=this.options.anchor,s=ge(this.options.offset);if(!n){let c=this._container.offsetWidth,v=this._container.offsetHeight,k;i.y+s.bottom.y<v?k=["top"]:i.y>this._map.transform.height-v?k=["bottom"]:k=[],i.x<c/2?k.push("left"):i.x>this._map.transform.width-c/2&&k.push("right"),k.length===0?n="bottom":n=k.join("-");}let a=i.add(s[n]);this.options.subpixelPositioning||(a=a.round()),l.setTransform(this._container,`${ue[n]} translate(${a.x}px,${a.y}px)`),ve(this._container,n,"popup");};_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;let e=this._container.querySelector(Oe);e&&e.focus();}_onClose=()=>{this.remove();}};function ge(o){if(o)if(typeof o=="number"){let e=Math.round(Math.abs(o)/Math.SQRT2);return {center:new h(0,0),top:new h(0,o),"top-left":new h(e,e),"top-right":new h(-e,e),bottom:new h(0,-o),"bottom-left":new h(e,-e),"bottom-right":new h(-e,-e),left:new h(o,0),right:new h(-o,0)}}else if(o instanceof h||Array.isArray(o)){let e=h.convert(o);return {center:e,top:e,"top-left":e,"top-right":e,bottom:e,"bottom-left":e,"bottom-right":e,left:e,right:e}}else return {center:h.convert(o.center||[0,0]),top:h.convert(o.top||[0,0]),"top-left":h.convert(o["top-left"]||[0,0]),"top-right":h.convert(o["top-right"]||[0,0]),bottom:h.convert(o.bottom||[0,0]),"bottom-left":h.convert(o["bottom-left"]||[0,0]),"bottom-right":h.convert(o["bottom-right"]||[0,0]),left:h.convert(o.left||[0,0]),right:h.convert(o.right||[0,0])};else return ge(new h(0,0))}var Y=class{#e;#t;#i;_undoButton;_deleteButton;_saveButton;_container;constructor(e){this.#e=e,this._container=void 0,this.#i=!1,this.#s().then(()=>{this.#r(),this.#n();});}#n(){this.#e.mode?.addObserver(this.#o);}#o=e=>{let{store:t}=this.#e,{type:i,data:n}=e;i==="MODE_CHANGED"&&!n&&this.hidePanel(),i==="MODE_CHANGED"&&n&&t.tail?.val&&this.setPanelLocation({lat:t.tail?.val?.lat,lng:t.tail?.val?.lng});};#s=async()=>{try{this.#t=new z({offset:16,closeButton:!1,closeOnClick:!1,closeOnMove:!1,anchor:"bottom"});}catch(e){console.error("POPUP LOAD ERROR",e);}};#r=()=>{let{store:e}=this.#e;this.createPanel(),e.tail?.val&&this.setPanelLocation({lat:e.tail?.val?.lat,lng:e.tail?.val?.lng});};setPanelLocation=e=>{let{map:t}=this.#e;this.#i&&(this.#i=!1,this.showPanel()),this._container&&this.#t&&this.#t.setLngLat(e).setDOMContent(this._container).addTo(t);};hidePanel=()=>{!this.#i&&(this.#t?.addClassName("hide-panel"),this.#i=!0);};showPanel=()=>{this.#t?.removeClassName("hide-panel"),this.#i=!1;};onPointRemove=e=>{e?this.setPanelLocation(e):this.hidePanel();};removePanel=()=>{this._container&&l.remove(this._container),this.#t?.remove();};createButton=(e,t,i,n)=>{let s=l.create("button",`panel-button panel-button-${i}`,n);return s.setAttribute("data-type",e),s.setAttribute("aria-label",t),l.create("span",`icon ${e} icon-${i}`,s),s};createPanel=()=>{let{options:e}=this.#e,{locale:t}=e,{undo:i,delete:n,save:s}=e.panel.buttons,a=e.panel.size,c=document.querySelector(".maplibregl-popup-content"),v=l.create("div","dashboard",c);i.visible&&(this._undoButton=this.createButton("undo",t.undo,a,v)),n.visible&&(this._deleteButton=this.createButton("delete",t.delete,a,v)),s.visible&&(this._saveButton=this.createButton("save",t.save,a,v)),this._container=v;}};var j={type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[]}}]},W={type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[]}}]},Ee={type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"Point",coordinates:[]}}]},r={LineDynamicLayer:"mdl-line-dynamic-layer",LineLayer:"mdl-line-layer",LineLayerTransparent:"mdl-line-layer-transparent",LineLayerBreak:"mdl-line-break-layer",PolygonLayer:"mdl-polygon-layer",PointsLayer:"mdl-points-layer",SinglePointLayer:"mdl-single-point-layer",FirstPointLayer:"mdl-first-point-layer"},p={LineDynamicSource:"mdl-line-dynamic-source",LineSourceBreak:"mdl-line-source-break",LineSource:"mdl-line-source",PolygonSource:"mdl-polygon-source",PointsSource:"mdl-points-source",SinglePointSource:"mdl-single-point-source"},A={large:6.5,default:5.5},V={large:"#FF6464",default:"#666666"},x={"circle-radius":A.default,"circle-color":"#FEFFFE","circle-stroke-color":V.default,"circle-stroke-width":3},T={"circle-radius":A.large,"circle-color":"#FEFFFE","circle-stroke-color":"#666666","circle-stroke-width":3},G={"fill-color":"grey","fill-opacity":.4},I={"line-width":3,"line-color":"grey","line-opacity":.7},w={"circle-radius":A.default,"circle-color":"#FEFFFE","circle-stroke-color":"#666666","circle-stroke-width":3},B={"line-width":3,"line-color":"#FF6464","line-dasharray":[3,3]},K=o=>[{id:r.SinglePointLayer,source:p.SinglePointSource,type:"circle",paint:o.layersPaint.onLinePoint,layout:{visibility:"none"}},{id:r.PolygonLayer,source:p.PolygonSource,type:"fill",paint:o.layersPaint.polygon,layout:{visibility:"none"}},{id:r.LineDynamicLayer,source:p.LineDynamicSource,type:"line",paint:o.layersPaint.line,layout:{visibility:"none"}},{id:r.LineLayer,source:p.LineSource,type:"line",paint:o.layersPaint.line,layout:{visibility:"visible"}},{id:r.LineLayerTransparent,source:p.LineSource,type:"line",paint:{"line-width":4,"line-color":"transparent"}},{id:r.LineLayerBreak,source:p.LineSourceBreak,type:"line",paint:o.layersPaint.breakLine,layout:{visibility:"none"}},{id:r.PointsLayer,source:p.PointsSource,type:"circle",paint:o.layersPaint.points,filter:["==",["get","isFirst"],!1]},{id:r.FirstPointLayer,source:p.PointsSource,type:"circle",paint:o.layersPaint.firstPoint,filter:["==",["get","isFirst"],!0]}];var L=class{static#e=0;static#t=e=>{e.setPaintProperty(r.FirstPointLayer,"circle-radius",A.large),e.setPaintProperty(r.FirstPointLayer,"circle-stroke-color",V.large);};static#i=e=>{e.setPaintProperty(r.FirstPointLayer,"circle-radius",A.default),e.setPaintProperty(r.FirstPointLayer,"circle-stroke-color",V.default);};static togglePointCircleRadius=(e,t)=>{t==="large"?this.#t(e):this.#i(e);};static removeTransparentLine=e=>{e.removeLayer(r.LineLayerTransparent);};static addTransparentLine=(e,t)=>{if(e.getLayer(r.LineLayerTransparent))return;let n=K(t).find(s=>s.id===r.LineLayerTransparent);n&&e.addLayer(n);};static isDoubleClick(){let t=Date.now();return t-this.#e<=400?(this.#e=t,!0):(this.#e=t,!1)}};var y=class{static isFeatureTriggered(e,t){return e.target.queryRenderedFeatures(e.point,{layers:t}).some(n=>t.includes(n.layer.id))}static getPixelCoordinates=(e,t)=>{let{lat:i,lng:n}=t;return e.project([n,i])};static queryPointId=(e,t)=>e.queryRenderedFeatures(t,{layers:[r.PointsLayer,r.FirstPointLayer]})?.[0]?.properties.id},M=class{static#e(e){let t=[],i=e.head,n=new Set;for(;i!==null;){if(n.has(i.val?.id)){e.head&&e.head.val&&t.push([e.head.val.lng,e.head.val.lat]);break}n.add(i.val?.id),i.val&&t.push([i.val.lng,i.val.lat]),i=i.next;}return t}static getAllLines(e){let t=this.#e(e);return {type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:t}}]}}static getLine(e,t){return {type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[e,t]}}]}}static getPolygon(e){let t=this.#e(e);return {type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[t]}}]}}static getPoints(e){let t=e.head,i=[],n=new Set;for(;t!==null&&!n.has(t.val?.id);){if(t.val){let s=t.val,a=t.val.id===e.head?.val?.id;i.push({type:"Feature",properties:{id:s.id,lat:s.lat,lng:s.lng,isFirst:a},geometry:{type:"Point",coordinates:[s.lng,s.lat]}});}n.add(t.val?.id),t=t.next;}return {type:"FeatureCollection",features:i}}},u=class o{static getGeometryIndex=(e,t)=>{let i=e.head,n=0;for(;i!==null;){if(i.val?.id===t)return n;n++,i=i.next;}return -1};static isFirstPoint(e){let t=e.target,i=e.point;return !!t.queryRenderedFeatures(i,{layers:[r.FirstPointLayer]}).length}static distance=(e,t)=>Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2);static checkIfPointIsOnLine=(e,t,i)=>{let s=this.distance(e,t),a=this.distance(e,i),c=this.distance(i,t);return Math.abs(a+c-s)<.1};static isClosedGeometry=e=>e.tail?.next===e.head;static breakGeometry=(e,t)=>{if(!e.head)return;let i=e.head,n=e.tail;do{if(i?.val?.id===t){i!==e.head&&(n.next=i.next,e.head=i,e.tail=n),e.tail.next=null;return}n=i,i=i.next;}while(i!==e.head)};static closeGeometry=(e,t)=>{e.tail&&(e.tail.next=e.head),t.setClosedGeometry(!0);};static canCloseGeometry=e=>e.size>2&&!this.isClosedGeometry(e);static canBreakClosedGeometry=e=>e.size<=2;static switchToLineModeIfCan=e=>{let{mode:t,store:i,tiles:n,map:s}=e;o.canBreakClosedGeometry(i)&&(i.tail&&i.tail.val&&(i.tail.next=null),t.reset(),L.togglePointCircleRadius(s,"default"),n.renderPolygon(j));}},b=()=>{if("crypto"in window&&"randomUUID"in window.crypto)return window.crypto.randomUUID();function o(){return "0123456789abcdef"[Math.floor(Math.random()*16)]}function e(n){let s="";for(let a=0;a<n;a++)s+=o();return s}function t(n){let s=n===0,a=n===4;return s?8:a?12:4}let i=[];for(let n=0;n<5;n++)i.push(e(t(n)));return i.join("-")},C=(o,e)=>{let t,i=!0;function n(){i&&t&&(o(...t),t=null,i=!1,setTimeout(()=>{i=!0,n();},e));}return function(...s){t=s,n();}};var N=class{#e;#t;#i;#n;constructor(e){this.#e=e,this.#o(),this.render();}#o(){this.#s(),this.#r(),this.#a(r.LineLayer,r.SinglePointLayer),this.#a(r.LineLayerTransparent,r.SinglePointLayer),this.#a(r.LineLayerTransparent,r.FirstPointLayer),this.#a(r.LineLayerTransparent,r.PointsLayer),this.#a(r.PolygonLayer,r.LineLayer);}#s=()=>{let{map:e}=this.#e;Object.values(p).forEach(t=>{e.getSource(t)||e.addSource(t,{type:"geojson",data:{type:"FeatureCollection",features:[]},promoteId:"id"});});};#r=()=>{let{map:e,mode:t,options:i}=this.#e;K(i).forEach(a=>{e.getLayer(a.id)||e.addLayer(a);});let s=e.getLayoutProperty(r.PolygonLayer,"visibility")==="none";t.getMode()==="polygon"&&s&&e.setLayoutProperty(r.PolygonLayer,"visibility","visible");};#a=(e,t)=>{let{map:i}=this.#e,n=i.getLayer(e),s=i.getLayer(t);n&&s&&i.moveLayer(e,t);};#l=()=>{let{map:e}=this.#e;Object.values(p).forEach(t=>{e.getSource(t)&&e.removeSource(t);});};#c=()=>{let{map:e}=this.#e;Object.values(r).forEach(t=>{e.getLayer(t)&&e.removeLayer(t);});};removeTiles=()=>{this.#c(),this.#l();};renderPoints=e=>{let{map:t}=this.#e,i=t.getSource(p.PointsSource);i&&i.setData(e);};renderLines=(e,t)=>{let{map:i}=this.#e,n=i.getSource(t);n&&n.setData(e);};renderPolygon=e=>{let{map:t}=this.#e,i=t.getSource(p.PolygonSource);i&&i.setData(e);};render=()=>{let{mode:e,options:t,store:i}=this.#e,n=M.getPoints(i),s=M.getAllLines(i);if(this.#t=n,this.#i=s,this.renderPoints(n),this.renderLines(s,p.LineSource),t.modes.polygon.visible&&e.isPolygon()){let c=M.getPolygon(i);this.#n=c,this.renderPolygon(c);}};#h=(e,t)=>{if(this.#n.features[0].geometry.coordinates[0][e]=[t.lng,t.lat],e===0){let n=this.#n.features[0].geometry.coordinates[0]?.length-1;this.#n.features[0].geometry.coordinates[0][n]=[t.lng,t.lat];}this.renderPolygon(this.#n);};#p=(e,t)=>{let{mode:i}=this.#e;this.#i.features[0].geometry.coordinates[e]=[t.lng,t.lat];let n=e===0;if(this.#i&&i.getClosedGeometry()&&n){let a=this.#i.features[0].geometry.coordinates?.length-1;this.#i.features[0].geometry.coordinates[a]=[t.lng,t.lat];}this.renderLines(this.#i,p.LineSource);};renderOnMouseMove=(e,t)=>{let{mode:i,options:n}=this.#e;this.#t.features[e].geometry.coordinates=[t.lng,t.lat],this.renderPoints(this.#t),this.#p(e,t),n.modes.polygon.visible&&i.isPolygon()&&this.#h(e,t);};resetGeometries=()=>{this.renderPoints(Ee),this.renderLines(W,p.LineSource),this.renderPolygon(j);}};var ke=8,xe=8,S=class{_container;_label;constructor(){this._container=void 0;}create=e=>{let t=l.create("div","popup-container",document.body),i=l.create("span",`popup-text popup-text-${e.placement}`,t);return i.textContent=e.label,this._container=t,this._label=i,this};#e=()=>{!this._label?.classList.value.includes("popup-text-active")&&this._label?.classList.add("popup-text-active");};#t=()=>this._label?{width:this._label.clientWidth,height:this._label.clientHeight}:{width:0,height:0};#i=e=>{let{bottom:t,left:i}=e.target.getBoundingClientRect(),{width:n,height:s}=this.#t();return {x:i-xe-n,y:t-s-2}};#n=e=>{let{bottom:t,left:i,right:n}=e.target.getBoundingClientRect(),{width:s}=this.#t();return {x:(n-i)/2+i-s/2,y:t+ke}};getPosition=(e,t)=>t==="left"?this.#i(e):this.#n(e);setPosition=e=>{let{x:t,y:i}=e;this._container&&(this._container.style.left=`${t}px`,this._container.style.top=`${i}px`),this.#e();};remove=()=>{this._container&&l.remove(this._container);}};var g={AUTO:"auto",DEFAULT:"default",POINTER:"pointer",CROSSHAIR:"crosshair",MOVE:"move",HELP:"help",GRAB:"grab",GRABBING:"grabbing"};var $=(o,e)=>{for(let[t,i]of Object.entries(e))l.manageEventListener("add",o,t,i);},Z=(o,e)=>{for(let[t,i]of Object.entries(e))l.manageEventListener("remove",o,t,i);},Pe=(o,e)=>{let t=e.locale.line,i=e.locale.polygon,n=e.locale.break;return {line:t,polygon:i,break:n}[o]};var f={DOUBLECLICK:"mdl:doubleclick",POINTENTER:"mdl:pointenter",POINTLEAVE:"mdl:pointleave",MOVEEND:"mdl:moveend",ADD:"mdl:add",UNDO:"mdl:undo",REMOVEALL:"mdl:removeall",SAVE:"mdl:save",BREAK:"mdl:break",MODECHANGED:"mdl:modechanged"};var d={panel:{size:"medium",buttons:{undo:{visible:!0},delete:{visible:!0},save:{visible:!0,clearOnSave:!0}}},modes:{initial:null,line:{visible:!0,closeGeometry:!0},polygon:{visible:!0},breakGeometry:{visible:!0}},layersPaint:{onLinePoint:T,firstPoint:x,points:w,line:I,polygon:G,breakLine:B},initial:null,dynamicLine:!0,locale:{save:"Save",delete:"Delete all",undo:"Undo",line:"Line",polygon:"Polygon",break:"Split",closeLine:"Close line",createPolygon:"Create polygon"}};var m=class{static addPoint(e,t,i){t.fire(f.ADD,{id:e.id,coordinates:{lat:e.lat,lng:e.lng},total:e.total,timestamp:Date.now(),mode:{geometry:i.getMode(),closedGeometry:i.getClosedGeometry()}});}static movePoint(e,t){t.fire(f.MOVEEND,{id:e.id,start_coordinates:{lat:e.start.lat,lng:e.start.lng},end_coordinates:{lat:e.end.lat,lng:e.end.lng},total:e.total,timestamp:Date.now()});}static pointDoubleClick(e,t){t.fire(f.DOUBLECLICK,{id:e.id,coordinates:{lat:e.lat,lng:e.lng},total:e.total,timestamp:Date.now()});}static enterPoint(e,t){t.fire(f.POINTENTER,{id:e.id,coordinates:{lat:e.lat,lng:e.lng},total:e.total,timestamp:Date.now()});}static leavePoint(e,t){t.fire(f.POINTLEAVE,{id:e.id,coordinates:{lat:e.lat,lng:e.lng},total:e.total,timestamp:Date.now()});}static undoPoint(e,t,i){t.fire(f.UNDO,{originalEvent:i,id:e.id,coordinates:{lat:e.lat,lng:e.lng},total:e.total,timestamp:Date.now()});}static modeChanged(e,t){e.fire(f.MODECHANGED,{mode:t});}static removeAllPoints(e,t){e.fire(f.REMOVEALL,{originalEvent:t});}static onSaveClick(e,t,i){let{map:n,mode:s}=e;n.fire(f.SAVE,{originalEvent:i,timestamp:Date.now(),steps:t,mode:{geometry:s.getMode(),closedGeometry:s.getClosedGeometry()}});}static onLineBreak(e){e.fire(f.BREAK);}};var J=class{#e;constructor(e){this.#e=e,this.#t();}#t=()=>{this.#e.mode.addObserver(this.#l);};removeConsumers=()=>{this.#e.mode.removeObserver(this.#l);};#i=()=>{let{_line:e,_polygon:t,_break:i}=this.#e.control;e?.classList.remove("control-button-active"),t?.classList.remove("control-button-active"),i?.classList.remove("control-button-active");};#n=e=>{this.#i(),e.classList.add("control-button-active");};#o=e=>{let{data:t}=e,{_line:i,_polygon:n,_break:s}=this.#e.control,{mode:a}=this.#e;if(m.modeChanged(this.#e.map,t),!(!i||!n||!s)){switch(t){case"line":this.#n(i);break;case"polygon":this.#n(n);break;}t?a.getClosedGeometry()&&this.#r(s):this.#s(s);}};#s=e=>{e.setAttribute("disabled","true"),e.setAttribute("aria-disabled","true");};#r=e=>{e.removeAttribute("disabled"),e.removeAttribute("aria-disabled");};#a=e=>{let{data:t}=e,{_break:i,_line:n,_polygon:s}=this.#e.control,{mode:a}=this.#e;t?(i&&this.#r(i),a.getMode()==="polygon"&&n&&this.#s(n),a.getMode()==="line"&&s&&this.#s(s)):(i&&this.#s(i),a.getMode()==="polygon"&&n&&this.#r(n),a.getMode()==="line"&&s&&this.#r(s));};#l=e=>{let{type:t,data:i}=e;if(t==="MODE_CHANGED"&&this.#o(e),t==="CLOSED_GEOMETRY_CHANGED"&&this.#a(e),t==="BREAK_CHANGED"&&i){let{_break:n}=this.#e.control;this.#n(n),m.modeChanged(this.#e.map,"break");}}};var X=class{#e;#t;#i;constructor(e){this.#e=e,this.#i=new J(e),this.#t=new S,this.#n();}#n(){let{control:e}=this.#e;if(e){let t={mouseenter:this.onButtonEnter,mouseleave:this.onButtonLeave};e._line&&$(e._line,{...t,click:this.onLineClick}),e._polygon&&$(e._polygon,{...t,click:this.onPolygonClick}),e._break&&$(e._break,{...t,click:this.onBreakClick});}}#o(){let{control:e}=this.#e;if(e){let t={mouseenter:this.onButtonEnter,mouseleave:this.onButtonLeave};e._line&&Z(e._line,{...t,click:this.onLineClick}),e._polygon&&Z(e._polygon,{...t,click:this.onPolygonClick}),e._break&&Z(e._break,{...t,click:this.onBreakClick});}}remove(){this.#i.removeConsumers(),this.#o(),this.#t.remove();}onButtonEnter=e=>{let{options:t}=this.#e,i=e.target.getAttribute("data-type");if(i){let n=Pe(i,t),s="left";this.#t.create({label:n,placement:s}).setPosition(this.#t.getPosition(e,s));}};onButtonLeave=()=>{this.#t.remove();};#s=()=>{let{control:e}=this.#e;e._line?.classList.remove("control-button-active"),e._polygon?.classList.remove("control-button-active"),e._break?.classList.remove("control-button-active");};#r=()=>{let{map:e,mode:t}=this.#e;t.getMode()||e.fire("mode:initialize");};onLineClick=()=>{let{map:e,mode:t,tiles:i,control:n}=this.#e;this.#r(),this.#s(),t.getMode()==="line"&&!t.getBreak()?(t.setMode(null),e.fire("mode:remove"),i.resetGeometries()):(n._line?.classList.add("control-button-active"),t.setMode("line"),i.render());};onPolygonClick=()=>{let{map:e,mode:t,tiles:i,control:n}=this.#e;this.#r(),this.#s(),t.getMode()==="polygon"&&!t.getBreak()?(t.setMode(null),e.fire("mode:remove"),e.setLayoutProperty(r.PolygonLayer,"visibility","visible"),i.resetGeometries()):(n._polygon?.classList.add("control-button-active"),t.setMode("polygon"),i.render());};onBreakClick=()=>{let{map:e,mode:t,control:i}=this.#e;t.getBreak()&&(t.setMode(null),e.fire("mode:remove")),this.#s(),i._break?.classList.add("control-button-active"),t.setBreak(!0),e.getCanvasContainer().style.cursor=g.POINTER;}};var O=class{observers;constructor(){this.observers=new Set;}addObserver(e){this.observers.add(e);}removeObserver(e){this.observers.delete(e);}unsubscribe(){this.observers.clear();}notify(e){this.observers.forEach(t=>t(e));}};var F={EMPTY_INITIAL_STATE:"You passed an empty initial array in the options. Please either remove the 'initial' property or include at least one element in the array.",MISSING_IDS:"You set 'generateId' to false but did not provide IDs for all steps. Please ensure all steps have IDs or set 'generateId' to true.",NOT_ENOUGH_POINTS_TO_CLOSE:"At least three points are required to close a polygon or a line. Please add more points or set 'closeGeometry' to false.",FIRST_LAST_POINT_NOT_EQUAL:"The first and last points of a polygon or a closed linestring must be the same. Please ensure the first and last points are equal or set 'closeGeometry' to false."};var Q=class{val;next;constructor(e=null,t=null){this.val=e,this.next=t;}},H=class extends O{head;tail;size;constructor(e){super();let t=P.initStore(e);this.head=t?t.head:null,this.tail=t?t.tail:null,this.size=t?t.size:0;}push(e){let t=new Q(e);this.head?this.tail&&(this.tail.next=t,this.tail=t):this.head=this.tail=t,this.size++,this.pingConsumers();}insert(e,t){let i=new Q(e,t.next);this.tail===t&&this.head===t.next&&(this.tail=i),t.next=i,this.size++;}findStepById(e){let t=this.head,i=new Set;for(;t!==null&&!i.has(t);){if(t.val&&t.val.id===e)return t.val;i.add(t),t=t.next;}return null}removeStepById(e){if(!this.head)return null;let t=this.head,i=null;for(;t!==null;){if(t?.val?.id===e)return t===this.head?(this.head=t.next,this.tail&&(this.tail.next=t.next)):i.next=t.next,t===this.tail&&(this.tail=i),this.size--,this.pingConsumers(),t;i=t,t.next&&(t=t.next);}return null}reset(){this.head=null,this.tail=null,this.size=0,this.pingConsumers();}pingConsumers=()=>{this.notify({type:"STORE_CHANGED",data:{head:this.head,tail:this.tail,size:this.size}});}},P=class o{static isLastPoint=(e,t)=>e.tail?.val?.id===t;static initStore(e){if(!e?.initial)return null;if(e&&e.initial&&!e.initial.steps.length)throw new Error(F.EMPTY_INITIAL_STATE);if(e&&e.initial.steps){let{steps:n,closeGeometry:s,generateId:a}=e.initial;return o.fromArray(n,s,a)}return null}static#e=e=>e.map(t=>({...t,id:b()}));static buildStepSequence(e){let t=new H;return e.forEach(i=>{t.push(i);}),t}static fromArray(e,t,i){let n=i?this.#e(e):e,s=this.buildStepSequence(n);return t&&s.tail&&(s.tail.next=s.head),s}static toArray(e){if(!e)return [];let t=new Set,i=[],n=e;for(;n!==null&&!t.has(n);)t.add(n),i.push(n.val),n=n.next;return i}};var ee=class{#e;#t;constructor(e){this.#e=e,this.#t=new S;}initEvents(){let{panel:e}=this.#e;e&&(l.manageEventListener("add",e?._undoButton,"click",this.#o),l.manageEventListener("add",e?._undoButton,"mouseenter",this.onMouseEnter),l.manageEventListener("add",e?._undoButton,"mouseleave",this.onMouseLeave)),e&&(l.manageEventListener("add",e?._deleteButton,"click",this.#n),l.manageEventListener("add",e?._deleteButton,"mouseenter",this.onMouseEnter),l.manageEventListener("add",e?._deleteButton,"mouseleave",this.onMouseLeave)),e&&(l.manageEventListener("add",e?._saveButton,"click",this.onSaveClick),l.manageEventListener("add",e?._saveButton,"mouseenter",this.onMouseEnter),l.manageEventListener("add",e?._saveButton,"mouseleave",this.onMouseLeave));}removeEvents(){let{panel:e}=this.#e;e&&e._undoButton&&(l.manageEventListener("remove",e._undoButton,"click",this.#o),l.manageEventListener("remove",e._undoButton,"mouseenter",this.onMouseEnter),l.manageEventListener("remove",e._undoButton,"mouseleave",this.onMouseLeave)),e&&e._deleteButton&&(l.manageEventListener("remove",e._deleteButton,"click",this.#n),l.manageEventListener("remove",e._deleteButton,"mouseenter",this.onMouseEnter),l.manageEventListener("remove",e._deleteButton,"mouseleave",this.onMouseLeave)),e&&e._saveButton&&(l.manageEventListener("remove",e._saveButton,"click",this.onSaveClick),l.manageEventListener("remove",e._saveButton,"mouseenter",this.onMouseEnter),l.manageEventListener("remove",e._saveButton,"mouseleave",this.onMouseLeave));}#i=e=>{let{options:t}=this.#e;return {undo:t.locale.undo,delete:t.locale.delete,save:t.locale.save}[e]};onMouseEnter=e=>{let t=e.target.getAttribute("data-type");if(t){let i=this.#i(t);this.#t.create({label:i,placement:"bottom"}).setPosition(this.#t.getPosition(e,"bottom"));}};onMouseLeave=()=>{this.#t.remove();};#n=e=>{let{tiles:t,mode:i,panel:n,store:s,map:a}=this.#e;s.reset(),n.hidePanel(),i.reset(),L.togglePointCircleRadius(a,"default"),this.#t.remove(),t.resetGeometries(),m.removeAllPoints(a,e);};#o=e=>{let{store:t,panel:i,map:n,tiles:s}=this.#e,a=t.tail?.val;t.removeStepById(a.id);let c={...a,total:t.size};m.undoPoint(c,n,e),u.switchToLineModeIfCan(this.#e),i?.onPointRemove(t.tail?.val),this.#t.remove(),requestAnimationFrame(s.render);};onSaveClick=e=>{let{store:t,options:i}=this.#e;m.onSaveClick(this.#e,P.toArray(t.head),e),this.#t.remove(),i.panel.buttons.save.clearOnSave&&this.#n(e);}};var E=class{static updatePointsData(e){let i=e.target.getSource(p.SinglePointSource);i&&i.setData({type:"Feature",geometry:{type:"Point",coordinates:[e.lngLat.lng,e.lngLat.lat]},properties:{}});}static setSinglePointVisible(e){e.target.setLayoutProperty(r.SinglePointLayer,"visibility","visible");}static setSinglePointHidden(e){let t=e.target;setTimeout(()=>{t.setLayoutProperty(r.SinglePointLayer,"visibility","none");},33);}static triggerPostPointAddition(e,t){let{panel:i,tiles:n,store:s,map:a}=t;u.canCloseGeometry(s)&&L.togglePointCircleRadius(a,"large"),i?.setPanelLocation(e.lngLat),n.render();}static addPointToMap=(e,t)=>{let{store:i,map:n,mode:s}=t,a={...e.lngLat,id:b()};i.push(a),m.addPoint({...a,total:i.size},n,s),this.triggerPostPointAddition(e,t);};static updateSelectedStepLatLng=(e,t)=>{t.lat=e.lngLat.lat,t.lng=e.lngLat.lng;}};var me=(o,e)=>{let t=e.head,i=new Set;for(;t!==null&&!i.has(t);){if(t.next&&t.next.val&&t.val){let n=o.target,s=y.getPixelCoordinates(n,t.val),a=y.getPixelCoordinates(n,t.next.val),c=y.getPixelCoordinates(n,o.lngLat);if(u.checkIfPointIsOnLine(s,a,c))return t}i.add(t),t=t.next;}return null},Me=(o,e)=>{let t=me(o,e);if(t){let i={...o.lngLat,id:b()};return e.insert(i,t),i}return null},be=(o,e)=>{let{store:t,tiles:i,panel:n}=e;t.tail?.val&&(n?.setPanelLocation(t.tail.val),E.setSinglePointHidden(o),i.render());},_e=o=>y.isFeatureTriggered(o,[r.PointsLayer,r.FirstPointLayer]);var Ce=15,te=class{props;#e;#t;constructor(e){this.props=e,this.#e=null,this.#t=C(this.#n,Ce);}initBreakEvents=()=>{let{map:e}=this.props;e.on("click",r.LineLayerTransparent,this.#i),e.on("mouseenter",r.LineLayerTransparent,this.#t),e.on("mousemove",r.LineLayerTransparent,this.#t),e.on("mouseleave",r.LineLayerTransparent,this.#o);};removeBreakEvents=()=>{let{map:e}=this.props;e.off("click",r.LineLayerTransparent,this.#i),e.off("mouseenter",r.LineLayerTransparent,this.#t),e.off("mousemove",r.LineLayerTransparent,this.#t),e.off("mouseleave",r.LineLayerTransparent,this.#o);};hideBreakLine=()=>{let{map:e}=this.props;e.getLayoutProperty(r.LineLayerBreak,"visibility")!=="none"&&e.setLayoutProperty(r.LineLayerBreak,"visibility","none");};showBreakLine=()=>{let{map:e}=this.props;e.getLayoutProperty(r.LineLayerBreak,"visibility")!=="visible"&&e.setLayoutProperty(r.LineLayerBreak,"visibility","visible");};#i=()=>{let{store:e,mode:t,panel:i,map:n,tiles:s}=this.props,a=this.#e?.next?.val?.id;u.breakGeometry(e,a),e.tail?.val&&i.setPanelLocation({lat:e.tail?.val?.lat,lng:e.tail?.val?.lng}),this.#o(),n.setLayoutProperty(r.PolygonLayer,"visibility","none"),t.reset(),s.render(),m.onLineBreak(n);};#n=e=>{let{map:t,store:i}=this.props,n=me(e,i);n?.val?.id!==this.#e?.val?.id&&(this.#e=n);let s=t.getSource(p.LineSourceBreak),a=[n?.val?.lng,n?.val?.lat],c=[n?.next?.val?.lng,n?.next?.val?.lat],v=M.getLine(a,c);v&&(s.setData(v),this.showBreakLine());};#o=()=>{setTimeout(()=>{this.hideBreakLine();},Ce+10);}};var Te=10,ie=class{#e;#t;#i;#n;#o;#s;constructor(e){this.#e=e,this.#t=e.options.dynamicLine,this.#i=null,this.#n=null,this.#r(),this.#s=C(this.#p,Te);}#r(){this.#e.store.addObserver(this.#l),this.#e.mode.addObserver(this.#c),this.#e.mouseEvents.addObserver(this.#a);}removeLine=()=>{this.hideDynamicLine();};removeConsumers=()=>{this.#e.store.removeObserver(this.#l),this.#e.mode.removeObserver(this.#c),this.#e.mouseEvents.removeObserver(this.#a);};#a=e=>{let{mode:t}=this.#e;if(!t.getClosedGeometry()&&(e.type==="lastPointMouseClick"&&e.data?(this.hideDynamicLine(),this.#t=!1):e.type==="lastPointMouseClick"&&!e.data&&(this.#t=!0),!!this.#t&&((e.type==="pointMouseEnter"||e.type==="lineMouseEnter")&&e.data&&this.hideDynamicLine(),(e.type==="pointMouseLeave"||e.type==="lineMouseLeave")&&e.data))){let{store:i}=this.#e;this.#i=i.tail?.val,this.#n=i.tail?.val,this.showDynamicLine();}};#l=e=>{let{store:t}=this.#e;switch(e.type){case"STORE_CHANGED":e.data.tail?.val&&!u.isClosedGeometry(t)&&(this.#i=e.data.tail?.val,this.showDynamicLine());break;}};#c=e=>{let{store:t}=this.#e;e.type==="CLOSED_GEOMETRY_CHANGED"&&(e.data&&this.hideDynamicLine(),!e.data&&t?.tail?.val&&(this.#i=t?.tail?.val,this.showDynamicLine()));};initDynamicEvents=()=>{let{map:e}=this.#e;e.on("click",this.#f),e.on("mousemove",this.#s),e.on(f.REMOVEALL,this.hideDynamicLine),e.on(f.UNDO,this.#m),e.on(f.DOUBLECLICK,this.#v);};removeEvents=()=>{let{map:e}=this.#e;e.off("click",this.#f),e.off("mousemove",this.#s),e.off(f.REMOVEALL,this.hideDynamicLine),e.off(f.UNDO,this.#m),e.off(f.DOUBLECLICK,this.#v);};hideDynamicLine=()=>{let{map:e,tiles:t}=this.#e;this.#i=null,this.#n=null,this.#o=null,e.off("mousemove",this.#s),t.renderLines(W,p.LineDynamicSource),e.setLayoutProperty(r.LineDynamicLayer,"visibility","none");};showDynamicLine=()=>{let{map:e}=this.#e,t=[this.#i?.lng,this.#i?.lat],i=[this.#n?.lng,this.#n?.lat];this.#o=M.getLine(t,i),e.setLayoutProperty(r.LineDynamicLayer,"visibility","visible"),this.#n&&this.#h({lng:this.#n?.lng,lat:this.#n?.lat}),e.on("mousemove",this.#s);};#h=e=>{if(!this.#o)return;let{tiles:t}=this.#e;this.#o.features[0].geometry.coordinates[1]=[e.lng,e.lat],t.renderLines(this.#o,p.LineDynamicSource);};#p=e=>{this.#h(e.lngLat);};#f=e=>{let{mode:t}=this.#e,i=y.isFeatureTriggered(e,[r.LineLayerTransparent,r.LineLayer]);i&&t.getBreak()&&(this.#n={lng:e.lngLat.lng,lat:e.lngLat.lat}),!i&&this.hideDynamicLine();};#m=e=>{let{store:t,mode:i}=this.#e;if(!i.getClosedGeometry()){let n=e.target.unproject({x:e.originalEvent.x,y:e.originalEvent.y});this.#n={lng:n.lng,lat:n.lat},this.#i=t.tail?.val,this.showDynamicLine();}};#v=e=>{let{store:t,mode:i}=this.#e;i.getClosedGeometry()||(this.#n={lng:e.coordinates.lng,lat:e.coordinates.lat},this.#i=t.tail?.val,this.showDynamicLine());}};var we=22,ne=class{props;#e;#t;constructor(e){this.props=e,this.#e=!1,this.#t=null;}initEvents(){let{map:e}=this.props;e.on("click",r.LineLayerTransparent,this.#i),e.on("mousemove",r.LineLayerTransparent,this.#o),e.on("mouseenter",r.LineLayerTransparent,this.#s),e.on("mouseleave",r.LineLayerTransparent,this.#r);}removeEvents(){let{map:e}=this.props;e.off("click",r.LineLayerTransparent,this.#i),e.off("mousemove",r.LineLayerTransparent,this.#o),e.off("mouseenter",r.LineLayerTransparent,this.#s),e.off("mouseleave",r.LineLayerTransparent,this.#r);}#i=e=>{let{store:t,map:i,mode:n}=this.props;if(_e(e))return;let s=Me(e,t);s&&(m.addPoint({...s,total:t.size},i,n),be(e,this.props));};#n=e=>{E.setSinglePointVisible(e),e.target.getLayer(r.SinglePointLayer)&&E.updatePointsData(e);};#o=C(e=>{if(y.isFeatureTriggered(e,[r.PointsLayer,r.FirstPointLayer]))return;let{mouseEvents:t}=this.props;t.pointMouseDown||t.pointMouseEnter||(this.#t=e,!this.#e&&(this.#e=!0,requestAnimationFrame(()=>{this.#t&&(this.#n(this.#t),this.#e=!1);})));},we);#s=e=>{let{mouseEvents:t}=this.props;t.pointMouseDown||t.pointMouseEnter||y.isFeatureTriggered(e,[r.PointsLayer,r.FirstPointLayer])||(t.lineMouseEnter=!0,E.setSinglePointVisible(e));};#r=e=>{let{mouseEvents:t}=this.props;t.pointMouseDown||t.pointMouseEnter||(t.lineMouseLeave=!0,E.setSinglePointHidden(e));}};var oe=class{props;#e;#t;#i;#n;constructor(e){this.props=e,this.#e=new te(e),this.#t=new ne(e),this.#i=null,this.#n="default";}init(){this.#o(),this.#s(),this.#r();}#o=()=>{window.innerWidth<=768||this.props.options.dynamicLine&&(this.#i=new ie(this.props));};#s(){!this.props.mode.getBreak()&&(this.#t.initEvents(),this.props.options.dynamicLine&&this.#i?.initDynamicEvents());}#r(){this.props.mode.addObserver(this.#h),this.props.mouseEvents.addObserver(this.#c);}remove(){this.#a(),this.#l();}#a(){this.props.mode.removeObserver(this.#h),this.props.mouseEvents.removeObserver(this.#c),this.props.options.dynamicLine&&this.#i?.removeConsumers();}#l(){this.#e.removeBreakEvents(),this.#t.removeEvents(),this.props.options.dynamicLine&&(this.#i?.removeEvents(),this.#i?.removeLine());}#c=e=>{let{type:t,data:i}=e,{mode:n}=this.props;if(!(!i||!n.getBreak()))switch(t){case"pointMouseDown":this.#e.removeBreakEvents(),this.#e.hideBreakLine();break;case"pointMouseUp":this.#e.initBreakEvents();break;}};#h=e=>{let{type:t,data:i}=e;t==="MODE_CHANGED"&&this.#n==="break"&&(this.#e.removeBreakEvents(),this.#t.initEvents(),this.#n="default"),t==="BREAK_CHANGED"&&i&&this.#n==="default"&&(this.#t.removeEvents(),this.#e.initBreakEvents(),this.#n="break");}};var se=class{#e;#t;#i;constructor(e){this.#t=e,this.#e=!1,this.#i=new S,e.mode.addObserver(this.#n);}initEvents(){let{map:e}=this.#t;e.on("click",r.FirstPointLayer,this.#o),e.on("mouseenter",r.FirstPointLayer,this.#c),e.on("mouseleave",r.FirstPointLayer,this.#a),e.on("mouseup",r.FirstPointLayer,this.#r),e.on("mousedown",r.FirstPointLayer,this.#s);}removeEvents(){let{map:e}=this.#t;e.off("click",r.FirstPointLayer,this.#o),e.off("mouseenter",r.FirstPointLayer,this.#c),e.off("mouseleave",r.FirstPointLayer,this.#a),e.off("mouseup",r.FirstPointLayer,this.#r);}#n=e=>{let{map:t,store:i}=this.#t,{type:n,data:s}=e;n==="MODE_CHANGED"&&(s==="line"||s==="polygon"?t.on("click",r.FirstPointLayer,this.#o):t.off("click",r.FirstPointLayer,this.#o),u.canCloseGeometry(i)&&L.togglePointCircleRadius(t,"large"));};#o=()=>{let{store:e,map:t,mode:i,tiles:n}=this.#t;if(i.getMode()==="polygon"&&t.setLayoutProperty(r.PolygonLayer,"visibility","visible"),u.canCloseGeometry(e)){u.closeGeometry(e,i);let s=Object.assign({},e.head?.val,{id:b(),total:e.size});m.addPoint(s,t,i),L.togglePointCircleRadius(t,"default"),n.render();}};#s=()=>{this.#e=!0,this.#i.remove();};#r=()=>{this.#e=!1;};#a=()=>{let{mouseEvents:e}=this.#t;this.#e||(e.firstPointMouseLeave=!0,this.#i.remove());};#l=()=>{let{mode:e,options:t}=this.#t;return e.getMode()==="line"&&t.modes.line.closeGeometry?t.locale.closeLine:e.getMode()==="polygon"?t.locale.createPolygon:""};#c=e=>{let{mode:t,mouseEvents:i,store:n}=this.#t;if(!(t.getClosedGeometry()||this.#e)&&(i.firstPointMouseEnter=!0,u.canCloseGeometry(n))){let{x:s,y:a}=e.originalEvent;if(s&&a){this.#i.create({label:this.#l(),placement:"bottom"});let v=this.#i._label?this.#i._label.clientWidth/2:0;this.#i.setPosition({x:s-v,y:a+14});}}}};var re=class{#e;#t;#i;#n;#o;#s;#r;#a;constructor(e){this.#e=e,this.#t=void 0,this.#i=null,this.#n=null,this.#o=null,this.#s=new se(e),this.#r=!1,this.#a=null;}#l=()=>{let{map:e}=this.#e;e.on("click",r.FirstPointLayer,this.#p),e.on("mouseenter",r.FirstPointLayer,this.#L),e.on("mouseleave",r.FirstPointLayer,this.#g),e.on("mousedown",r.FirstPointLayer,this.#d),e.on("mouseup",r.FirstPointLayer,this.#u),e.on("touchend",r.FirstPointLayer,this.#u),e.on("touchstart",r.FirstPointLayer,this.#d),this.#s.initEvents();};initEvents=()=>{let{map:e}=this.#e;e.on("click",this.#m),e.on("dblclick",this.#h),e.on("click",r.PointsLayer,this.#p),e.on("mouseenter",r.PointsLayer,this.#L),e.on("mouseleave",r.PointsLayer,this.#g),e.on("mousedown",r.PointsLayer,this.#d),e.on("mouseup",r.PointsLayer,this.#u),e.on("touchend",r.PointsLayer,this.#u),e.on("touchstart",r.PointsLayer,this.#d),this.#l();};#c=()=>{let{map:e}=this.#e;e.off("click",r.FirstPointLayer,this.#p),e.off("mouseenter",r.FirstPointLayer,this.#L),e.off("mouseleave",r.FirstPointLayer,this.#g),e.off("mousedown",r.FirstPointLayer,this.#d),e.off("mouseup",r.FirstPointLayer,this.#u),e.off("touchend",r.PointsLayer,this.#u),e.off("touchstart",r.PointsLayer,this.#d),this.#s.removeEvents();};removeEvents=()=>{let{map:e}=this.#e;e.off("click",this.#m),e.off("dblclick",this.#h),e.off("mousemove",this.#y),e.off("click",r.PointsLayer,this.#p),e.off("mouseenter",r.PointsLayer,this.#L),e.off("mouseleave",r.PointsLayer,this.#g),e.off("mousedown",r.PointsLayer,this.#d),e.off("mouseup",r.PointsLayer,this.#u),this.#c();};#h=e=>{e.preventDefault();};#p=e=>{let{store:t,tiles:i,panel:n,map:s,mouseEvents:a}=this.#e;L.isDoubleClick()&&this.#n&&(t.removeStepById(this.#n.id),n.onPointRemove(t.tail?.val),m.pointDoubleClick({...this.#n,total:t.size},this.#e.map),u.switchToLineModeIfCan(this.#e));let c=y.queryPointId(s,e.point);P.isLastPoint(t,c)&&(a.lastPointMouseClick=!0,a.lastPointMouseUp=!1),i.render();};#f=e=>y.isFeatureTriggered(e,[r.PointsLayer,r.FirstPointLayer,r.LineLayerTransparent,r.LineLayerBreak]);#m=e=>{let{mode:t,mouseEvents:i,map:n}=this.#e;t.getClosedGeometry()||this.#f(e)||(i.lastPointMouseClick&&(i.lastPointMouseClick=!1),n.getCanvasContainer().style.cursor="grab",E.addPointToMap(e,this.#e),E.setSinglePointHidden(e));};#v=e=>{e.originalEvent.buttons===0&&this.#u();};#E=e=>{let{tiles:t}=this.#e;t.renderOnMouseMove(this.#o,e.lngLat);};#y=C(e=>{this.#a=e,this.#r||(this.#r=!0,requestAnimationFrame(()=>{!this.#n||!this.#a||(E.updateSelectedStepLatLng(this.#a,this.#n),this.#v(this.#a),this.#E(this.#a),this.#r=!1);}));},15);#L=e=>{let{mouseEvents:t,map:i,store:n}=this.#e;if(t&&(t.pointMouseEnter=!0,t.pointMouseDown))return;E.setSinglePointHidden(e);let s=y.queryPointId(i,e.point);P.isLastPoint(n,s)&&(t.lastPointMouseEnter=!0,t.lastPointMouseLeave=!1);let a=n.findStepById(s);a&&(this.#i=a,m.enterPoint(Object.assign({},a,{total:n.size}),i));};#g=e=>{let{mouseEvents:t,store:i,map:n}=this.#e;if(t&&(t.pointMouseEnter=!1,e.originalEvent.buttons===0&&(t.pointMouseLeave=!0),t.pointMouseDown))return;let s=y.queryPointId(n,e.point);P.isLastPoint(i,s)&&(t.lastPointMouseEnter=!1,t.lastPointMouseLeave=!0),m.leavePoint(Object.assign({},this.#i,{total:i.size}),n);};#P=()=>{let{store:e,panel:t}=this.#e;this.#n&&P.isLastPoint(e,this.#n.id)&&t.hidePanel();};#M=e=>{let{store:t,map:i}=this.#e,n=y.queryPointId(i,e.point),s=t.findStepById(n);s&&(this.#n=s);};#d=e=>{e.preventDefault();let{mouseEvents:t,map:i,store:n}=this.#e;L.removeTransparentLine(i),this.#M(e),this.#P();let s=y.queryPointId(i,e.point);this.#o=u.getGeometryIndex(n,s),t&&(t.pointMouseDown=!0),this.#t=e.lngLat,i.on("mousemove",this.#y),i.on("touchmove",this.#y);};#u=()=>{let{mouseEvents:e,store:t,panel:i,map:n,options:s}=this.#e;e.pointMouseUp=!0,this.#n&&(P.isLastPoint(t,this.#n.id)&&t.tail?.val&&i?.setPanelLocation(t.tail.val),i?.showPanel(),m.movePoint({id:this.#n.id,total:t.size,end:{lat:this.#n.lat,lng:this.#n.lng},start:this.#t},n)),e&&(e.pointMouseDown=!1),L.addTransparentLine(n,s),n.off("mousemove",this.#y),n.off("touchmove",this.#y);}};var ae=class extends N{#e;#t;#i;#n;#o;constructor(e){super({...e}),this.#e=e,this.#t=new ee(e),this.#i=new X(e),this.#n=new re(e),this.#o=new oe(e),e.map.on("mode:initialize",this.#s),e.map.on("mode:remove",this.#r);}#s=()=>{this.#o.init(),this.#t?.initEvents(),this.#n?.initEvents();};#r=()=>{this.#t?.removeEvents(),this.#n?.removeEvents(),this.#o?.remove();};removeMapEventsAndConsumers=()=>{this.#t?.removeEvents(),this.#n?.removeEvents(),this.#i?.remove(),this.#o?.remove(),this.#e.map.off("mode:initialize",this.#s);}};var le=class{#e;_line;_polygon;_break;_container;constructor(e){this.#e=e.options,this._line=void 0,this._polygon=void 0,this._break=void 0,this._container=l.create("div","mapboxgl-ctrl mapboxgl-ctrl-group maplibregl-ctrl maplibregl-ctrl-group"),this.createControl(e);}createControlButton=(e,t,i,n)=>{let s=this.#e.panel.size,a=l.create("button",`control-button control-button-${s}`,this._container);return a.setAttribute("aria-label",t),a.setAttribute("data-type",e),i&&a.classList.add("control-button-active"),n&&(a.setAttribute("disabled","true"),a.setAttribute("aria-disabled","true")),l.create("span",`icon ${e} icon-${s}`,a),a};#t=e=>{let{mode:t,options:i}=e,n=this.#e.modes.line.visible,s=i.locale.line;n&&(this._line=this.createControlButton("line",s,t.getMode()==="line"));};#i=e=>{let{mode:t,options:i}=e,n=this.#e.modes.polygon.visible,s=i.locale.polygon;n&&(this._polygon=this.createControlButton("polygon",s,t.getMode()==="polygon"));};#n=e=>{let{mode:t,options:i}=e,n=this.#e.modes.breakGeometry.visible,s=i.locale.break;if(n){let c=!this.#e?.initial?.closeGeometry,v=t.getBreak();this._break=this.createControlButton("break",s,v,c);}};createControl=e=>{this.#t(e),this.#i(e),this.#n(e);};getContainer=()=>this._container};function De(o){return o.initial?.geometry?o.initial?.geometry:o.modes.initial?o.modes.initial:null}var ce=class extends O{#e;#t;#i;constructor(e){super(),this.#e=De(e),this.#t=!1,this.#i=e.initial?.closeGeometry??!1;}getMode=()=>this.#e;setMode=e=>{this.#e=e,this.setBreak(!1),this.notify({type:"MODE_CHANGED",data:e});};getBreak=()=>this.#t;setBreak=e=>{this.#t=e,this.notify({type:"BREAK_CHANGED",data:e});};getClosedGeometry=()=>this.#i;setClosedGeometry=e=>{this.#i=e,this.notify({type:"CLOSED_GEOMETRY_CHANGED",data:this.#i});};isPolygon=()=>this.#e==="polygon"&&this.#i;reset=()=>{this.setMode(this.getMode()),this.setClosedGeometry(!1);};pingConsumers=()=>{this.notify({type:"MODE_CHANGED",data:this.getMode()}),this.notify({type:"CLOSED_GEOMETRY_CHANGED",data:this.getClosedGeometry()});}};var he=class{#e;#t;constructor(e){this.#e=e,this.#t=this.#e.map.getCanvasContainer(),this.#t.style.cursor=e.mode.getMode()?g.CROSSHAIR:g.AUTO,this.#i();}set=e=>{this.#t.style.cursor=e;};get=()=>this.#t.style.cursor;handleMouseLeave=()=>{let{mouseEvents:e,mode:t}=this.#e;if(!e.pointMouseDown){if(!t.getMode()){this.set(g.AUTO);return}t.getClosedGeometry()?this.set(g.AUTO):this.set(g.CROSSHAIR);}};handleFirstPointMouseEnter=()=>{let{mode:e,store:t}=this.#e;e.getClosedGeometry()&&this.set(g.MOVE),u.canCloseGeometry(t)&&this.set(g.POINTER);};#i(){let{mouseEvents:e}=this.#e;e.addObserver(this.#n);}removeConsumers(){let{mouseEvents:e}=this.#e;e.removeObserver(this.#n);}#n=e=>{let{mode:t,mouseEvents:i}=this.#e;if(t.getBreak())return;let{type:n,data:s}=e;if(s)switch(n){case"pointMouseDown":this.set(g.GRABBING);break;case"pointMouseUp":this.set(g.GRAB);break;case"pointMouseEnter":if(i.pointMouseDown)return;this.set(g.GRAB);break;case"pointMouseLeave":this.handleMouseLeave();break;case"lineMouseEnter":if(i.pointMouseDown)return;this.set(g.POINTER);break;case"lineMouseLeave":this.handleMouseLeave();break;case"firstPointMouseEnter":this.handleFirstPointMouseEnter();break;case"firstPointMouseLeave":this.handleMouseLeave();break;case"lastPointMouseEnter":this.set(g.POINTER);break;case"lastPointMouseLeave":this.handleMouseLeave();break;}}};var pe=class extends O{#e;#t;#i;#n;#o;#s;#r;#a;#l;#c;#h;#p;constructor(){super(),this.#e=!1,this.#t=!1,this.#i=!1,this.#n=!1,this.#o=!1,this.#s=!1,this.#r=!1,this.#a=!1,this.#l=!1,this.#c=!1,this.#h=!1,this.#p=!1;}get firstPointMouseEnter(){return this.#e}set firstPointMouseEnter(e){this.#e=e,this.notify({type:"firstPointMouseEnter",data:e});}get firstPointMouseLeave(){return this.#t}set firstPointMouseLeave(e){this.#t=e,this.notify({type:"firstPointMouseLeave",data:e});}get lastPointMouseClick(){return this.#i}set lastPointMouseClick(e){this.#i=e,this.notify({type:"lastPointMouseClick",data:e});}get lastPointMouseUp(){return this.#n}set lastPointMouseUp(e){this.#n=e,this.notify({type:"lastPointMouseUp",data:e});}get lastPointMouseEnter(){return this.#o}set lastPointMouseEnter(e){this.#o=e,this.notify({type:"lastPointMouseEnter",data:e});}get lastPointMouseLeave(){return this.#s}set lastPointMouseLeave(e){this.#s=e,this.notify({type:"lastPointMouseLeave",data:e});}get pointMouseDown(){return this.#r}set pointMouseDown(e){this.#r=e,this.notify({type:"pointMouseDown",data:e});}get pointMouseUp(){return this.#a}set pointMouseUp(e){this.#a=e,this.notify({type:"pointMouseUp",data:e});}get pointMouseEnter(){return this.#l}set pointMouseEnter(e){this.#l=e,this.notify({type:"pointMouseEnter",data:e});}get pointMouseLeave(){return this.#c}set pointMouseLeave(e){this.#c=e,this.notify({type:"pointMouseLeave",data:e});}get lineMouseEnter(){return this.#h}set lineMouseEnter(e){this.#h=e,this.notify({type:"lineMouseEnter",data:e});}get lineMouseLeave(){return this.#p}set lineMouseLeave(e){this.#p=e,this.notify({type:"lineMouseLeave",data:e});}};var U=class{static allStepsHaveIds(e){return e.every(t=>"id"in t&&t.id!==void 0)}static checkIfMissingIds(e,t){let i=!t,n=!this.allStepsHaveIds(e);if(i&&n)throw new Error(F.MISSING_IDS)}static checkIfEnoughPointsToClose(e,t){if(t&&e.length<3)throw new Error(F.NOT_ENOUGH_POINTS_TO_CLOSE)}static checkIfPolygonIsClosed(e){let{closeGeometry:t,steps:i}=e;if(i){let n=i[0]?.lng,s=i[i.length-1]?.lng,a=i[0]?.lat,c=i[i.length-1]?.lat;if((n!==s||a!==c)&&t)throw new Error(F.FIRST_LAST_POINT_NOT_EQUAL)}}static checkInitialStepsOption(e){let{closeGeometry:t,generateId:i,steps:n}=e;this.checkIfMissingIds(n,i),this.checkIfEnoughPointsToClose(n,t),this.checkIfPolygonIsClosed(e);}static init(e){return e?{panel:Ae(e),modes:Ie(e),layersPaint:Be(e),initial:e.initial||d.initial,locale:Ne(e),dynamicLine:e.dynamicLine??d.dynamicLine}:d}};function Ae(o){return {size:o.panel?.size||d.panel.size,buttons:{undo:{visible:o.panel?.buttons?.undo?.visible??d.panel.buttons.undo.visible},delete:{visible:o.panel?.buttons?.delete?.visible??d.panel.buttons.delete.visible},save:{visible:o.panel?.buttons?.save?.visible??d.panel.buttons.save.visible,clearOnSave:o.panel?.buttons?.save?.clearOnSave??d.panel.buttons.save.clearOnSave}}}}function Ie(o){return {initial:o.modes?.initial||d.modes.initial,line:{visible:o?.modes?.line?.visible!==void 0?o.modes.line.visible:o?.initial?.geometry==="line"||d.modes.line.visible,closeGeometry:o?.modes?.line?.closeGeometry??o?.initial?.closeGeometry??d.modes.line.closeGeometry},polygon:{visible:o?.modes?.polygon?.visible!==void 0?o.modes.polygon.visible:o?.initial?.geometry==="polygon"||d.modes.polygon.visible},breakGeometry:{visible:o?.modes?.breakGeometry?.visible??d.modes.breakGeometry.visible}}}function Be(o){return {onLinePoint:{"circle-radius":o.layersPaint?.onLinePoint?.["circle-radius"]||T["circle-radius"],"circle-color":o.layersPaint?.onLinePoint?.["circle-color"]||T["circle-color"],"circle-stroke-color":o.layersPaint?.onLinePoint?.["circle-stroke-color"]||T["circle-stroke-color"],"circle-stroke-width":o.layersPaint?.onLinePoint?.["circle-stroke-width"]||T["circle-stroke-width"],...o.layersPaint?.onLinePoint},firstPoint:{"circle-radius":o.layersPaint?.firstPoint?.["circle-radius"]||x["circle-radius"],"circle-color":o.layersPaint?.firstPoint?.["circle-color"]||x["circle-color"],"circle-stroke-color":o.layersPaint?.firstPoint?.["circle-stroke-color"]||x["circle-stroke-color"],"circle-stroke-width":o.layersPaint?.firstPoint?.["circle-stroke-width"]||x["circle-stroke-width"],...o.layersPaint?.firstPoint},points:{"circle-radius":o.layersPaint?.points?.["circle-radius"]||w["circle-radius"],"circle-color":o.layersPaint?.points?.["circle-color"]||w["circle-color"],"circle-stroke-color":o.layersPaint?.points?.["circle-stroke-color"]||w["circle-stroke-color"],"circle-stroke-width":o.layersPaint?.points?.["circle-stroke-width"]||w["circle-stroke-width"],...o.layersPaint?.points},line:{"line-width":o.layersPaint?.line?.["line-width"]||I["line-width"],"line-color":o.layersPaint?.line?.["line-color"]||I["line-color"],"line-opacity":o.layersPaint?.line?.["line-opacity"]||I["line-opacity"],...o.layersPaint?.line},polygon:{"fill-color":o.layersPaint?.polygon?.["fill-color"]||G["fill-color"],"fill-opacity":o.layersPaint?.polygon?.["fill-opacity"]||G["fill-opacity"],...o.layersPaint?.polygon},breakLine:{"line-width":o.layersPaint?.breakLine?.["line-width"]||B["line-width"],"line-color":o.layersPaint?.breakLine?.["line-color"]||B["line-color"],"line-dasharray":o.layersPaint?.breakLine?.["line-dasharray"]||B["line-dasharray"],...o.layersPaint?.breakLine}}}function Ne(o){return {save:o.locale?.save??d.locale.save,delete:o.locale?.delete??d.locale.delete,undo:o.locale?.undo??d.locale.undo,line:o.locale?.line??d.locale.line,polygon:o.locale?.polygon??d.locale.polygon,break:o.locale?.break??d.locale.break,closeLine:o.locale?.closeLine??d.locale.closeLine,createPolygon:o.locale?.createPolygon??d.locale.createPolygon}}var ye=class o{#e;#t;#i;#n;#o;#s;#r;#a;#l;static#c=null;static#h=!1;constructor(e){if(this.#n=U.init(e),this.#n.initial&&U.checkInitialStepsOption(this.#n.initial),o.#h)throw new Error("Use 'DrawLibre.getInstance()' instead of 'new DrawLibre()'.");o.#h=!0,this.#t=void 0,this.#i=void 0,this.#o=void 0,this.#s=void 0,this.#r=void 0,this.#l=void 0,this.#a=void 0;}static getInstance(e){return o.#c||(o.#c=new o(e)),o.#c}onAdd(e){this.#t=new H(this.#n),this.#i=new ce(this.#n),this.#r=new Y({map:e,mode:this.#i,options:this.#n,store:this.#t}),this.#s=new N({map:e,store:this.#t,options:this.#n,mode:this.#i});let t=new le({options:this.#n,mode:this.#i});return this.#l=new pe,this.#a=new he({map:e,mode:this.#i,mouseEvents:this.#l,store:this.#t}),this.#o=new ae({map:e,store:this.#t,options:this.#n,panel:this.#r,control:t,mode:this.#i,tiles:this.#s,mouseEvents:this.#l}),this.#i.getMode()&&e.fire("mode:initialize"),this.#i.pingConsumers(),this.#e=t.getContainer(),this.#e}onRemove(){this.#a?.removeConsumers(),this.#s?.removeTiles(),this.#o?.removeMapEventsAndConsumers(),this.#r?.removePanel(),this.#t?.reset(),this.#i?.unsubscribe(),this.#e&&l.remove(this.#e);}setSteps=e=>{if(Array.isArray(e))e.forEach(t=>{let i={...t,id:t.id||b()};this.#t?.push(i);});else throw new Error("Invalid argument. Expected an array of steps.");this.#s?.render();};findStepById=e=>this.#t?.findStepById(e);getAllSteps=(e="array")=>{if(e==="array"&&this.#t)return P.toArray(this.#t.head);if(e==="linkedlist")return this.#t;throw new Error("Invalid type specified. Use 'array' or 'linkedlist'.")};setOptions=e=>{this.#n=e(this.#n);};removeAllSteps=()=>{this.#t?.reset(),this.#r?.removePanel(),this.#s?.render();}};
2
2
 
3
- export { ve as default };
3
+ export { ye as default };
4
+ //# sourceMappingURL=index.js.map
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/dom.ts","../src/components/map/popup/util/lnglat.ts","../src/components/map/popup/util/index.ts","../src/components/map/popup/util/evented.ts","../src/components/map/popup/util/point.ts","../src/components/map/popup/index.ts","../src/components/last-point-panel/index.ts","../src/utils/geo_constants.ts","../src/components/map/tiles/helpers.ts","../src/utils/helpers.ts","../src/components/map/tiles/index.ts","../src/components/tooltip/index.ts","../src/components/map/cursor/constants.ts","../src/components/side-control/helpers.ts","../src/utils/constants.ts","../src/components/map/helpers.ts","../src/components/side-control/observer.ts","../src/components/side-control/events.ts","../src/utils/observable.ts","../src/store/errors.ts","../src/store/index.ts","../src/components/last-point-panel/events.ts","../src/components/map/points/helpers.ts","../src/components/map/line/utils.ts","../src/components/map/line/break-line.ts","../src/components/map/line/dynamic-line.ts","../src/components/map/line/transparent-line.ts","../src/components/map/line/index.ts","../src/components/map/points/first-point.ts","../src/components/map/points/index.ts","../src/components/map/index.ts","../src/components/side-control/index.ts","../src/components/map/mode/index.ts","../src/components/map/cursor/index.ts","../src/components/map/mouse-events/index.ts","../src/utils/options.ts","../src/index.ts"],"names":["DOM","_DOM","props","i","tagName","className","container","element","node","el","value","action","target","type","callback","options","actionFn","LngLat","_LngLat","lng","lat","input","extend","dest","sources","src","k","smartWrap","lngLat","priorPos","transform","originalLngLat","left","right","delta","pos","anchorTranslate","applyAnchorClass","anchor","prefix","classList","key","_addEventListener","listener","listenerList","_removeEventListener","index","Evented","resolve","event","properties","Event","listeners","oneTimeListeners","parent","data","Point","_Point","x","y","other","p","dx","dy","b","m","angle","cos","sin","defaultOptions","focusQuerySelector","Popup","map","lnglat","text","html","frag","temp","child","maxWidth","htmlNode","offset","cursor","hasPosition","name","normalizeOffset","width","height","anchorComponents","offsetedPos","firstFocusable","cornerOffset","convertedOffset","Panel","#props","#panelPopup","#isHidden","#importPopup","#initPopup","#initConsumers","#mapModeConsumer","store","error","coordinates","head","title","size","button","locale","undo","deleteButton","save","panelSize","popupContent","POLYGON_BASE","LINE_BASE","POINT_BASE","ELAYERS","ESOURCES","FIRST_POINT_RADIUS","FIRST_POINT_COLOR","FIRST_POINT_PAINT_BASE","ON_LINE_POINT_PAINT_BASE","POLYGON_PAINT_BASE","LINE_PAINT_BASE","POINTS_PAINT_BASE","BREAK_PAINT_BASE","generateLayersToRender","TilesHelpers","#lastClickTime","#firstPointCircleRadius","#defaultPointCircleRadius","transparentLayer","layer","now","MapUtils","layerIds","coords","point","GeometryFactory","#collectGeometryCoordinates","current","visitedNodes","next","pointFeatures","val","Spatial","_Spatial","id","idx","point1","point2","A","B","P","distanceAB","distanceAP","distancePB","prev","mode","context","tiles","uuidv4","getRandomHexChar","getUuidSection","length","section","getUuidSectionSize","firstElement","lastElement","parts","throttle","fn","delay","lastArgs","shouldCall","execute","args","Tiles","#pointsFeature","#linesFeature","#polygonFeature","#init","#addSources","#addLayers","#swapLayers","source","polygonInvisible","beneathLayerId","aboveLayerId","beneath","above","#removeSources","#removeLayers","points","pointSource","lines","lineSource","polygon","polygoneSource","#renderPolygonOnMouseMove","featureIdx","newCoord","lastIdx","#renderLineOnMouseMove","BASE_Y_OFFSET_FROM_ELEMENT","BASE_X_OFFSET_FROM_ELEMENT","Tooltip","span","#activateAnimation","#getLabelDimensions","#getLeftPosition","bottom","labelWidth","labelHeight","#getBottomPosition","position","CURSORS","addControlListeners","events","removeControlListeners","getButtonLabel","lineTitle","polygonTitle","breakTitle","EVENTS","DEFAULT_OPTIONS","FireEvents","step","originalEvent","steps","ControlObserver","#resetAllState","_line","_polygon","_break","#checkActive","#observeModeChange","#enableButton","#disableButton","#observeGeometryChange","ControlEvents","#tooltip","#observer","#initEvents","control","#removeEvents","label","placement","#removeActiveClass","#initialize","Observable","observer","ERRORS","ListNode","Store","list","StoreHelpers","newNode","_StoreHelpers","closeGeometry","generateId","#generateIdForSteps","stepsWithoutIds","initialSteps","result","PanelEvents","panel","#onUndoClick","#onRemoveAll","#getButtonLabel","tailVal","PointHelpers","selectedStep","isOnLine","visited","aPixel","bPixel","eventPixel","insertStepIfOnLine","currentStep","updateUIAfterInsert","checkIfPointClicked","LINE_BREAK_THROTTLE_TIME","LineBreakEvents","#current","#throttledOnLineEnter","#onLineEnterBreak","#geometryBreakOnClick","#onLineLeave","nextPointId","line","lineBreakData","LINE_DYNAMIC_THROTTLE_TIME","DynamicLineEvents","#visible","#firstPoint","#secondPoint","#lineFeature","#throttledOnLineMove","#onLineMove","#storeEventsConsumer","#mouseEventsConsumer","#onMapClick","#onDoubleClick","lineClick","latLng","LINE_TRANSPARENT_THROTTLE_TIME","TransparentLineEvents","#isThrottled","#lastEvent","#onLineAdd","#onLineEnter","#processMouseMove","mouseEvents","LineEvents","#break","#transparent","#dynamic","#type","#initDynamicLine","#removeConsumers","FirstPoint","#mouseDown","#onFirstPointClick","#onFirstPointMouseEnter","#onFirstPointMouseLeave","#onFirstPointMouseUp","#onFirstPointMouseDown","#getTitle","X_OFFSET","PointEvents","#startCoordinates","#enteredStep","#selectedStep","#selectedIdx","#initFirstPointEvents","#onPointClick","#onPointMouseEnter","#onPointMouseLeave","#onPointMouseDown","#onPointMouseUp","#onMapDblClick","#removeFirstPointEvents","#onMapMouseMove","#onOwnGeometryLayersClick","#onMoveLeftClickUp","#hideLastPointPanel","#setSelectedStep","Events","#panelEvents","#controlEvents","#pointEvents","#lineEvents","#removeDrawEvents","Control","#defaultOptions","active","disabled","#createLineButton","lineVisible","#createPolygonButton","polygonVisible","#createBreakButton","breakVisible","isBreak","getInitialMode","DrawingMode","#mode","#closedGeometry","newMode","Cursor","#canvas","#mouseEventsObserver","MouseEvents","#firstPointMouseEnter","#firstPointMouseLeave","#lastPointMouseClick","#lastPointMouseUp","#lastPointMouseEnter","#lastPointMouseLeave","#pointMouseDown","#pointMouseUp","#pointMouseEnter","#pointMouseLeave","#lineMouseEnter","#lineMouseLeave","Options","idGenerationIsOff","idsNotProvided","firstLng","lastLng","firstLat","lastLat","generatePanelOptions","generateModeOptions","generateLayersOptions","generateLocaleOptions","DrawLibre","_DrawLibre","#container","#store","#events","#tiles","#panel","#cursor","#mouseEvents","#instance","#instanceCreated","newStep"],"mappings":"AAAO,IAAMA,EAAN,MAAMC,CAAI,CACf,OAAwB,QAAA,CACtB,OAAO,MAAW,CAAA,GAAA,EAAe,OAAO,QAAY,EAAA,MAAA,CAAO,SAAS,eAAgB,CAAA,KAAA,CACtF,OAAe,aAAgBA,CAAAA,CAAAA,CAAI,SAAS,CAAC,WAAA,CAAa,iBAAiB,CAAC,CAAA,CAE5E,OAAe,QAASC,CAAAA,CAAAA,CAAqC,CAC3D,GAAI,CAACD,EAAI,QAAU,CAAA,OAAOC,EAAM,CAAC,CAAA,CACjC,QAASC,CAAI,CAAA,CAAA,CAAGA,EAAID,CAAM,CAAA,MAAA,CAAQC,IAChC,GAAKD,CAAAA,CAAcC,CAAC,CAAKF,GAAAA,CAAAA,CAAI,SAC3B,OAAOC,CAAAA,CAAMC,CAAC,CAGlB,CAAA,OAAOD,EAAM,CAAC,CAChB,CAEA,OAAO,MAAA,CACLE,EACAC,CACAC,CAAAA,CAAAA,CAC0B,CAC1B,IAAMC,CAAAA,CAAU,OAAO,QAAS,CAAA,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AAa7P,CAAAA,CAAE,EAWrC,WAAc,CAAA,CAACvI,EAA+B,OAAY,GAAA,CACxD,GAAIA,CAAS,GAAA,OAAA,EAAW,KAAKoY,EAC3B,CAAA,OAAOhJ,EAAa,OAAQ,CAAA,IAAA,CAAKgJ,GAAO,IAAI,CAAA,CAE9C,GAAIpY,CAAS,GAAA,YAAA,CACX,OAAO,IAAKoY,CAAAA,EAAAA,CAEd,MAAM,IAAI,KAAA,CAAM,sDAAsD,CACxE,CAAA,CAEA,WAAcrO,CAA8D,EAAA,CAC1E,KAAKwL,EAAkBxL,CAAAA,CAAAA,CAAG,KAAKwL,EAAe,EAChD,EAKA,cAAiB,CAAA,IAAM,CACrB,IAAK6C,CAAAA,EAAAA,EAAQ,OACb,CAAA,IAAA,CAAKG,IAAQ,WAAY,EAAA,CACzB,KAAKD,EAAQ,EAAA,MAAA,GACf,CACF","file":"index.js","sourcesContent":["export class DOM {\n private static readonly docStyle =\n typeof window !== \"undefined\" && window.document && window.document.documentElement.style;\n private static transformProp = DOM.testProp([\"transform\", \"WebkitTransform\"]);\n\n private static testProp(props: string[]): string | undefined {\n if (!DOM.docStyle) return props[0];\n for (let i = 0; i < props.length; i++) {\n if ((props as any)[i] in DOM.docStyle) {\n return props[i];\n }\n }\n return props[0];\n }\n\n static create<K extends keyof HTMLElementTagNameMap>(\n tagName: K,\n className?: string,\n container?: HTMLElement,\n ): HTMLElementTagNameMap[K] {\n const element = window.document.createElement(tagName);\n if (className !== undefined) element.className = className;\n if (container) container.appendChild(element);\n return element;\n }\n\n static remove(node: HTMLElement) {\n if (node.parentNode) {\n node.parentNode.removeChild(node);\n }\n }\n\n public static setTransform(el: HTMLElement, value: string) {\n if (DOM.transformProp && el.style) {\n // @ts-ignore\n el.style[DOM.transformProp] = value;\n }\n }\n\n static manageEventListener(\n action: \"add\" | \"remove\",\n target: HTMLElement | Window | Document | undefined,\n type: string,\n callback: EventListenerOrEventListenerObject,\n options: {\n capture?: boolean;\n passive?: boolean;\n } = {},\n ) {\n if (!target) return;\n\n const actionFn = action === \"add\" ? \"addEventListener\" : \"removeEventListener\";\n if (\"passive\" in options) {\n target[actionFn](type, callback, options);\n } else {\n target[actionFn](type, callback, options.capture);\n }\n }\n\n static mouseButton(e: MouseEvent) {\n return e.button;\n }\n\n static addClassName(node: HTMLElement, className: string) {\n if (!node.classList.contains(className)) {\n node.classList.add(className);\n }\n }\n\n static removeClassName(node: HTMLElement, className: string) {\n if (node.classList.contains(className)) {\n node.classList.remove(className);\n }\n }\n}\n","export class LngLat {\n lng: number;\n lat: number;\n\n /**\n * @param lng - Longitude, measured in degrees.\n * @param lat - Latitude, measured in degrees.\n */\n constructor(lng: number, lat: number) {\n if (isNaN(lng) || isNaN(lat)) {\n throw new Error(`Invalid LngLat object: (${lng}, ${lat})`);\n }\n this.lng = +lng;\n this.lat = +lat;\n if (this.lat > 90 || this.lat < -90) {\n throw new Error(\"Invalid LngLat latitude value: must be between -90 and 90\");\n }\n }\n\n static convert(input: any): LngLat {\n if (input instanceof LngLat) {\n return input;\n }\n if (Array.isArray(input) && (input.length === 2 || input.length === 3)) {\n return new LngLat(Number(input[0]), Number(input[1]));\n }\n if (!Array.isArray(input) && typeof input === \"object\" && input !== null) {\n return new LngLat(\n // flow can't refine this to have one of lng or lat, so we have to cast to any\n Number(\"lng\" in input ? (input as any).lng : (input as any).lon),\n Number(input.lat),\n );\n }\n throw new Error(\n \"`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]\",\n );\n }\n}\n","import { LngLat } from \"./lnglat\";\n\nexport function extend(dest: any, ...sources: any) {\n for (const src of sources) {\n for (const k in src) {\n dest[k] = src[k];\n }\n }\n return dest;\n}\n\nexport function wrap(n: any, min: any, max: any) {\n const d = max - min;\n const w = ((((n - min) % d) + d) % d) + min;\n return w === min ? max : w;\n}\n\nexport function smartWrap(lngLat: any, priorPos: any, transform: any) {\n const originalLngLat = new LngLat(lngLat.lng, lngLat.lat);\n lngLat = new LngLat(lngLat.lng, lngLat.lat);\n\n // First, try shifting one world in either direction, and see if either is closer to the\n // prior position. This preserves object constancy when the map center is auto-wrapped\n // during animations.\n if (priorPos) {\n const left = new LngLat(lngLat.lng - 360, lngLat.lat);\n const right = new LngLat(lngLat.lng + 360, lngLat.lat);\n const delta = transform.locationPoint(lngLat).distSqr(priorPos);\n if (transform.locationPoint(left).distSqr(priorPos) < delta) {\n lngLat = left;\n } else if (transform.locationPoint(right).distSqr(priorPos) < delta) {\n lngLat = right;\n }\n }\n\n // Second, wrap toward the center until the new position is on screen, or we can't get\n // any closer.\n while (Math.abs(lngLat.lng - transform.center.lng) > 180) {\n const pos = transform.locationPoint(lngLat);\n if (pos.x >= 0 && pos.y >= 0 && pos.x <= transform.width && pos.y <= transform.height) {\n break;\n }\n if (lngLat.lng > transform.center.lng) {\n lngLat.lng -= 360;\n } else {\n lngLat.lng += 360;\n }\n }\n\n if (\n lngLat.lng !== originalLngLat.lng &&\n transform.locationPoint(lngLat).y > transform.height / 2 - transform.getHorizon()\n ) {\n return lngLat;\n }\n\n return originalLngLat;\n}\n\nexport const anchorTranslate = {\n center: \"translate(-50%,-50%)\",\n top: \"translate(-50%,0)\",\n \"top-left\": \"translate(0,0)\",\n \"top-right\": \"translate(-100%,0)\",\n bottom: \"translate(-50%,-100%)\",\n \"bottom-left\": \"translate(0,-100%)\",\n \"bottom-right\": \"translate(-100%,-100%)\",\n left: \"translate(0,-50%)\",\n right: \"translate(-100%,-50%)\",\n};\n\nexport function applyAnchorClass(element: any, anchor: any, prefix: any) {\n const classList = element.classList;\n for (const key in anchorTranslate) {\n classList.remove(`maplibregl-${prefix}-anchor-${key}`);\n }\n classList.add(`maplibregl-${prefix}-anchor-${anchor}`);\n}\n","import { extend } from \"./index\";\n\nfunction _addEventListener(type: string, listener: any, listenerList: any) {\n const listenerExists = listenerList[type] && listenerList[type].indexOf(listener) !== -1;\n if (!listenerExists) {\n listenerList[type] = listenerList[type] || [];\n listenerList[type].push(listener);\n }\n}\n\nfunction _removeEventListener(type: string, listener: any, listenerList: any) {\n if (listenerList && listenerList[type]) {\n const index = listenerList[type].indexOf(listener);\n if (index !== -1) {\n listenerList[type].splice(index, 1);\n }\n }\n}\n\nexport class Evented {\n _listeners: any;\n _oneTimeListeners: any;\n _eventedParent: any;\n _eventedParentData: any | (() => any);\n\n /**\n * Adds a listener to a specified event type.\n *\n * @param type - The event type to add a listen for.\n * @param listener - The function to be called when the event is fired.\n * The listener function is called with the data object passed to `fire`,\n * extended with `target` and `type` properties.\n */\n on(type: string, listener: any): this {\n this._listeners = this._listeners || {};\n _addEventListener(type, listener, this._listeners);\n\n return this;\n }\n\n /**\n * Removes a previously registered event listener.\n *\n * @param type - The event type to remove listeners for.\n * @param listener - The listener function to remove.\n */\n off(type: string, listener: any) {\n _removeEventListener(type, listener, this._listeners);\n _removeEventListener(type, listener, this._oneTimeListeners);\n\n return this;\n }\n\n /**\n * Adds a listener that will be called only once to a specified event type.\n *\n * The listener will be called first time the event fires after the listener is registered.\n *\n * @param type - The event type to listen for.\n * @param listener - The function to be called when the event is fired the first time.\n * @returns `this` or a promise if a listener is not provided\n */\n once(type: string, listener?: any): this | Promise<any> {\n if (!listener) {\n return new Promise((resolve) => this.once(type, resolve));\n }\n this._oneTimeListeners = this._oneTimeListeners || {};\n _addEventListener(type, listener, this._oneTimeListeners);\n\n return this;\n }\n\n fire(event: Event | string, properties?: any) {\n // Compatibility with (type: string, properties: Object) signature from previous versions.\n // See https://github.com/mapbox/mapbox-gl-js/issues/6522,\n // https://github.com/mapbox/mapbox-gl-draw/issues/766\n if (typeof event === \"string\") {\n event = new Event(event, properties || {});\n }\n\n const type = (event as any).type;\n\n if (this.listens(type)) {\n (event as any).target = this;\n\n // make sure adding or removing listeners inside other listeners won't cause an infinite loop\n const listeners = this._listeners && this._listeners[type] ? this._listeners[type].slice() : [];\n for (const listener of listeners) {\n listener.call(this, event);\n }\n\n const oneTimeListeners =\n this._oneTimeListeners && this._oneTimeListeners[type] ? this._oneTimeListeners[type].slice() : [];\n for (const listener of oneTimeListeners) {\n _removeEventListener(type, listener, this._oneTimeListeners);\n listener.call(this, event);\n }\n\n const parent = this._eventedParent;\n if (parent) {\n extend(\n event,\n typeof this._eventedParentData === \"function\" ? this._eventedParentData() : this._eventedParentData,\n );\n parent.fire(event);\n }\n\n // To ensure that no error events are dropped, print them to the\n // console if they have no listeners.\n } else if (event instanceof ErrorEvent) {\n console.error(event.error);\n }\n\n return this;\n }\n\n /**\n * Returns a true if this instance of Evented or any forwardeed instances of Evented have a listener for the specified type.\n *\n * @param type - The event type\n * @returns `true` if there is at least one registered listener for specified event type, `false` otherwise\n */\n listens(type: string): boolean {\n return (\n (this._listeners && this._listeners[type] && this._listeners[type].length > 0) ||\n (this._oneTimeListeners && this._oneTimeListeners[type] && this._oneTimeListeners[type].length > 0) ||\n (this._eventedParent && this._eventedParent.listens(type))\n );\n }\n\n /**\n * Bubble all events fired by this instance of Evented to this parent instance of Evented.\n */\n setEventedParent(parent?: Evented | null, data?: any | (() => any)) {\n this._eventedParent = parent;\n this._eventedParentData = data;\n\n return this;\n }\n}\n\nexport class Event {\n readonly type: string;\n\n constructor(type: string, data: any = {}) {\n extend(this, data);\n this.type = type;\n }\n}\n","export class Point {\n x: any;\n y: any;\n\n constructor(x: any, y: any) {\n this.x = x;\n this.y = y;\n }\n\n mag() {\n return Math.sqrt(this.x * this.x + this.y * this.y);\n }\n\n equals(other: any) {\n return this.x === other.x && this.y === other.y;\n }\n\n dist(p: any) {\n return Math.sqrt(this.distSqr(p));\n }\n\n distSqr(p: any) {\n const dx = p.x - this.x,\n dy = p.y - this.y;\n return dx * dx + dy * dy;\n }\n\n angle() {\n return Math.atan2(this.y, this.x);\n }\n\n angleTo(b: any) {\n return Math.atan2(this.y - b.y, this.x - b.x);\n }\n\n angleWith(b: any) {\n return this.angleWithSep(b.x, b.y);\n }\n\n angleWithSep(x: any, y: any) {\n return Math.atan2(this.x * y - this.y * x, this.x * x + this.y * y);\n }\n\n _matMult(m: any) {\n const x = m[0] * this.x + m[1] * this.y,\n y = m[2] * this.x + m[3] * this.y;\n this.x = x;\n this.y = y;\n return this;\n }\n\n _add(p: any) {\n this.x += p.x;\n this.y += p.y;\n return this;\n }\n _sub(p: any) {\n this.x -= p.x;\n this.y -= p.y;\n return this;\n }\n\n _mult(k: any) {\n this.x *= k;\n this.y *= k;\n return this;\n }\n\n _div(k: any) {\n this.x /= k;\n this.y /= k;\n return this;\n }\n\n _multByPoint(p: any) {\n this.x *= p.x;\n this.y *= p.y;\n return this;\n }\n\n _divByPoint(p: any) {\n this.x /= p.x;\n this.y /= p.y;\n return this;\n }\n\n _unit() {\n this._div(this.mag());\n return this;\n }\n\n _perp() {\n const y = this.y;\n this.y = this.x;\n this.x = -y;\n return this;\n }\n\n _rotate(angle: any) {\n const cos = Math.cos(angle),\n sin = Math.sin(angle),\n x = cos * this.x - sin * this.y,\n y = sin * this.x + cos * this.y;\n this.x = x;\n this.y = y;\n return this;\n }\n\n _rotateAround(angle: any, p: any) {\n const cos = Math.cos(angle),\n sin = Math.sin(angle),\n x = p.x + cos * (this.x - p.x) - sin * (this.y - p.y),\n y = p.y + sin * (this.x - p.x) + cos * (this.y - p.y);\n this.x = x;\n this.y = y;\n return this;\n }\n\n _round() {\n this.x = Math.round(this.x);\n this.y = Math.round(this.y);\n return this;\n }\n\n static convert(p: any) {\n if (p instanceof Point) {\n return /** @type {Point} */ p;\n }\n if (Array.isArray(p)) {\n return new Point(+p[0], +p[1]);\n }\n if (p.x !== undefined && p.y !== undefined) {\n return new Point(+p.x, +p.y);\n }\n throw new Error(\"Expected [x, y] or {x, y} point format\");\n }\n}\n","import { extend } from \"./util/index\";\nimport { Event, Evented } from \"./util/evented\";\nimport { DOM } from \"#utils/dom\";\nimport { LngLat } from \"./util/lnglat\";\nimport { Point } from \"./util/point\";\nimport { smartWrap } from \"./util/index\";\nimport { anchorTranslate, applyAnchorClass } from \"./util/index\";\n\nconst defaultOptions = {\n closeButton: true,\n closeOnClick: true,\n focusAfterOpen: true,\n className: \"\",\n maxWidth: \"240px\",\n subpixelPositioning: false,\n};\nexport type Offset = any;\n\nexport type PopupOptions = {\n closeButton?: boolean;\n closeOnClick?: boolean;\n closeOnMove?: boolean;\n focusAfterOpen?: boolean;\n anchor?: any;\n offset?: Offset;\n className?: string;\n maxWidth?: string;\n subpixelPositioning?: boolean;\n};\n\nconst focusQuerySelector = [\n \"a[href]\",\n \"[tabindex]:not([tabindex='-1'])\",\n \"[contenteditable]:not([contenteditable='false'])\",\n \"button:not([disabled])\",\n \"input:not([disabled])\",\n \"select:not([disabled])\",\n \"textarea:not([disabled])\",\n].join(\", \");\n\nexport class Popup extends Evented {\n _map: any;\n options: any;\n _content: any;\n _container: any;\n _closeButton: any;\n _tip: any;\n _lngLat: any;\n _trackPointer: any;\n _pos: any;\n _flatPos: any;\n\n constructor(options?: PopupOptions) {\n super();\n this.options = extend(Object.create(defaultOptions), options);\n }\n\n addTo(map: any): this {\n if (this._map) this.remove();\n\n this._map = map;\n if (this.options.closeOnClick) {\n this._map.on(\"click\", this._onClose);\n }\n\n if (this.options.closeOnMove) {\n this._map.on(\"move\", this._onClose);\n }\n\n this._map.on(\"remove\", this.remove);\n this._update();\n this._focusFirstElement();\n\n if (this._trackPointer) {\n this._map.on(\"mousemove\", this._onMouseMove);\n this._map.on(\"mouseup\", this._onMouseUp);\n if (this._container) {\n this._container.classList.add(\"maplibregl-popup-track-pointer\");\n }\n this._map._canvasContainer.classList.add(\"maplibregl-track-pointer\");\n } else {\n this._map.on(\"move\", this._update);\n }\n\n (this as any).fire(new Event(\"open\"));\n\n return this;\n }\n isOpen() {\n return !!this._map;\n }\n remove = (): this => {\n if (this._content) {\n DOM.remove(this._content);\n }\n\n if (this._container) {\n DOM.remove(this._container);\n delete this._container;\n }\n\n if (this._map) {\n this._map.off(\"move\", this._update);\n this._map.off(\"move\", this._onClose);\n this._map.off(\"click\", this._onClose);\n this._map.off(\"remove\", this.remove);\n this._map.off(\"mousemove\", this._onMouseMove);\n this._map.off(\"mouseup\", this._onMouseUp);\n this._map.off(\"drag\", this._onDrag);\n this._map._canvasContainer.classList.remove(\"maplibregl-track-pointer\");\n delete this._map;\n (this as any).fire(new Event(\"close\"));\n }\n\n return this;\n };\n\n getLngLat(): LngLat {\n return this._lngLat;\n }\n\n setLngLat(lnglat: any): this {\n this._lngLat = LngLat.convert(lnglat);\n this._pos = null;\n this._flatPos = null;\n\n this._trackPointer = false;\n\n this._update();\n\n if (this._map) {\n this._map.on(\"move\", this._update);\n this._map.off(\"mousemove\", this._onMouseMove);\n if (this._container) {\n this._container.classList.remove(\"maplibregl-popup-track-pointer\");\n }\n this._map._canvasContainer.classList.remove(\"maplibregl-track-pointer\");\n }\n\n return this;\n }\n\n trackPointer(): this {\n this._trackPointer = true;\n this._pos = null;\n this._flatPos = null;\n this._update();\n if (this._map) {\n this._map.off(\"move\", this._update);\n this._map.on(\"mousemove\", this._onMouseMove);\n this._map.on(\"drag\", this._onDrag);\n if (this._container) {\n this._container.classList.add(\"maplibregl-popup-track-pointer\");\n }\n this._map._canvasContainer.classList.add(\"maplibregl-track-pointer\");\n }\n\n return this;\n }\n\n getElement(): HTMLElement {\n return this._container;\n }\n\n setText(text: string): this {\n return this.setDOMContent(document.createTextNode(text));\n }\n\n setHTML(html: string): this {\n const frag = document.createDocumentFragment();\n const temp = document.createElement(\"body\");\n let child;\n temp.innerHTML = html;\n while (true) {\n child = temp.firstChild;\n if (!child) break;\n frag.appendChild(child);\n }\n\n return this.setDOMContent(frag);\n }\n\n getMaxWidth(): string {\n return this._container?.style.maxWidth;\n }\n\n setMaxWidth(maxWidth: string): this {\n this.options.maxWidth = maxWidth;\n this._update();\n return this;\n }\n\n setDOMContent(htmlNode: Node): this {\n if (this._content) {\n while (this._content.hasChildNodes()) {\n if (this._content.firstChild) {\n this._content.removeChild(this._content.firstChild);\n }\n }\n } else {\n this._content = DOM.create(\"div\", \"maplibregl-popup-content\", this._container);\n }\n\n this._content.appendChild(htmlNode);\n this._createCloseButton();\n this._update();\n this._focusFirstElement();\n return this;\n }\n\n addClassName(className: string) {\n if (this._container) {\n this._container.classList.add(className);\n }\n return this;\n }\n\n removeClassName(className: string) {\n if (this._container) {\n this._container.classList.remove(className);\n }\n return this;\n }\n\n setOffset(offset?: Offset): this {\n this.options.offset = offset;\n this._update();\n return this;\n }\n\n toggleClassName(className: string): boolean | undefined {\n if (this._container) {\n return this._container.classList.toggle(className);\n }\n }\n\n setSubpixelPositioning(value: boolean) {\n this.options.subpixelPositioning = value;\n }\n\n _createCloseButton() {\n if (this.options.closeButton) {\n this._closeButton = DOM.create(\"button\", \"maplibregl-popup-close-button\", this._content);\n this._closeButton.type = \"button\";\n this._closeButton.innerHTML = \"&#215;\";\n this._closeButton.addEventListener(\"click\", this._onClose);\n }\n }\n\n _onMouseUp = (event: any) => {\n this._update(event.point);\n };\n\n _onMouseMove = (event: any) => {\n this._update(event.point);\n };\n\n _onDrag = (event: any) => {\n this._update(event.point);\n };\n\n _update = (cursor?: any) => {\n const hasPosition = this._lngLat || this._trackPointer;\n\n if (!this._map || !hasPosition || !this._content) {\n return;\n }\n\n if (!this._container) {\n this._container = DOM.create(\"div\", \"maplibregl-popup\", this._map.getContainer());\n this._tip = DOM.create(\"div\", \"maplibregl-popup-tip\", this._container);\n this._container.appendChild(this._content);\n if (this.options.className) {\n for (const name of this.options.className.split(\" \")) {\n this._container.classList.add(name);\n }\n }\n\n if (this._closeButton) {\n this._closeButton.setAttribute(\"aria-label\", this._map._getUIString(\"Popup.Close\"));\n }\n\n if (this._trackPointer) {\n this._container.classList.add(\"maplibregl-popup-track-pointer\");\n }\n }\n\n if (this.options.maxWidth && this._container.style.maxWidth !== this.options.maxWidth) {\n this._container.style.maxWidth = this.options.maxWidth;\n }\n\n if (this._map.transform.renderWorldCopies && !this._trackPointer) {\n this._lngLat = smartWrap(this._lngLat, this._flatPos, this._map.transform);\n } else {\n this._lngLat = this._lngLat?.wrap();\n }\n\n if (this._trackPointer && !cursor) return;\n\n const pos = (this._flatPos = this._pos = this._trackPointer && cursor ? cursor : this._map.project(this._lngLat));\n if (this._map.terrain) {\n // flat position is saved because smartWrap needs non-elevated points\n this._flatPos = this._trackPointer && cursor ? cursor : this._map.transform.locationPoint(this._lngLat);\n }\n\n let anchor = this.options.anchor;\n const offset = normalizeOffset(this.options.offset);\n\n if (!anchor) {\n const width = this._container.offsetWidth;\n const height = this._container.offsetHeight;\n let anchorComponents: any;\n\n if (pos.y + offset.bottom.y < height) {\n anchorComponents = [\"top\"];\n } else if (pos.y > this._map.transform.height - height) {\n anchorComponents = [\"bottom\"];\n } else {\n anchorComponents = [];\n }\n\n if (pos.x < width / 2) {\n anchorComponents.push(\"left\");\n } else if (pos.x > this._map.transform.width - width / 2) {\n anchorComponents.push(\"right\");\n }\n\n if (anchorComponents.length === 0) {\n anchor = \"bottom\";\n } else {\n anchor = anchorComponents.join(\"-\") as any;\n }\n }\n\n let offsetedPos = pos.add((offset as any)[anchor]);\n\n if (!this.options.subpixelPositioning) {\n offsetedPos = offsetedPos.round();\n }\n\n DOM.setTransform(\n this._container,\n `${(anchorTranslate as any)[anchor]} translate(${offsetedPos.x}px,${offsetedPos.y}px)`,\n );\n applyAnchorClass(this._container, anchor, \"popup\");\n };\n\n _focusFirstElement() {\n if (!this.options.focusAfterOpen || !this._container) return;\n\n const firstFocusable = this._container.querySelector(focusQuerySelector) as HTMLElement;\n\n if (firstFocusable) firstFocusable.focus();\n }\n\n _onClose = () => {\n this.remove();\n };\n}\n\nfunction normalizeOffset(offset?: Offset | null) {\n if (!offset) {\n return normalizeOffset(new Point(0, 0));\n } else if (typeof offset === \"number\") {\n // input specifies a radius from which to calculate offsets at all positions\n const cornerOffset = Math.round(Math.abs(offset) / Math.SQRT2);\n return {\n center: new Point(0, 0),\n top: new Point(0, offset),\n \"top-left\": new Point(cornerOffset, cornerOffset),\n \"top-right\": new Point(-cornerOffset, cornerOffset),\n bottom: new Point(0, -offset),\n \"bottom-left\": new Point(cornerOffset, -cornerOffset),\n \"bottom-right\": new Point(-cornerOffset, -cornerOffset),\n left: new Point(offset, 0),\n right: new Point(-offset, 0),\n };\n } else if (offset instanceof Point || Array.isArray(offset)) {\n const convertedOffset = Point.convert(offset);\n return {\n center: convertedOffset,\n top: convertedOffset,\n \"top-left\": convertedOffset,\n \"top-right\": convertedOffset,\n bottom: convertedOffset,\n \"bottom-left\": convertedOffset,\n \"bottom-right\": convertedOffset,\n left: convertedOffset,\n right: convertedOffset,\n };\n } else {\n return {\n center: Point.convert(offset[\"center\"] || [0, 0]),\n top: Point.convert(offset[\"top\"] || [0, 0]),\n \"top-left\": Point.convert(offset[\"top-left\"] || [0, 0]),\n \"top-right\": Point.convert(offset[\"top-right\"] || [0, 0]),\n bottom: Point.convert(offset[\"bottom\"] || [0, 0]),\n \"bottom-left\": Point.convert(offset[\"bottom-left\"] || [0, 0]),\n \"bottom-right\": Point.convert(offset[\"bottom-right\"] || [0, 0]),\n left: Point.convert(offset[\"left\"] || [0, 0]),\n right: Point.convert(offset[\"right\"] || [0, 0]),\n };\n }\n}\n","import type { Map } from \"#types/map\";\nimport type { LatLng, PanelImpl, RequiredDrawOptions, Step } from \"#types/index\";\nimport { DOM } from \"#utils/dom\";\nimport { Store } from \"#store/index\";\nimport { Popup } from \"#components/map/popup/index\";\nimport \"./panel.css\";\nimport { DrawingMode } from \"#components/map/mode\";\nimport { DrawingModeChangeEvent } from \"#components/map/mode/types\";\n\ninterface IProps {\n map: Map;\n mode: DrawingMode;\n options: RequiredDrawOptions;\n store: Store;\n}\n\nexport class Panel {\n #props: IProps;\n #panelPopup: Popup | undefined;\n #isHidden: boolean;\n _undoButton: HTMLElement | undefined;\n // used outside in events\n _deleteButton: HTMLElement | undefined;\n _saveButton: HTMLElement | undefined;\n _container: HTMLElement | undefined;\n\n constructor(props: IProps) {\n this.#props = props;\n this._container = undefined;\n this.#isHidden = false;\n this.#importPopup().then(() => {\n this.#initPopup();\n this.#initConsumers();\n });\n }\n\n #initConsumers() {\n this.#props.mode?.addObserver(this.#mapModeConsumer);\n }\n\n #mapModeConsumer = (event: DrawingModeChangeEvent) => {\n const { store } = this.#props;\n const { type, data } = event;\n if (type === \"MODE_CHANGED\" && !data) {\n this.hidePanel();\n }\n if (type === \"MODE_CHANGED\" && data) {\n if (store.tail?.val) {\n this.setPanelLocation({\n lat: store.tail?.val?.lat,\n lng: store.tail?.val?.lng,\n });\n }\n }\n };\n\n #importPopup = async () => {\n try {\n this.#panelPopup = new Popup({\n offset: 16,\n closeButton: false,\n closeOnClick: false,\n closeOnMove: false,\n anchor: \"bottom\",\n });\n } catch (error) {\n console.error(\"POPUP LOAD ERROR\", error);\n }\n };\n\n #initPopup = () => {\n const { store } = this.#props;\n\n this.createPanel();\n if (store.tail?.val) {\n this.setPanelLocation({\n lat: store.tail?.val?.lat,\n lng: store.tail?.val?.lng,\n });\n }\n };\n\n setPanelLocation = (coordinates: LatLng) => {\n const { map } = this.#props;\n\n if (this.#isHidden) {\n this.#isHidden = false;\n this.showPanel();\n }\n if (this._container && this.#panelPopup) {\n this.#panelPopup.setLngLat(coordinates).setDOMContent(this._container).addTo(map);\n }\n };\n\n hidePanel = () => {\n const notHidden = !this.#isHidden;\n if (notHidden) {\n this.#panelPopup?.addClassName(\"hide-panel\");\n this.#isHidden = true;\n }\n };\n\n showPanel = () => {\n this.#panelPopup?.removeClassName(\"hide-panel\");\n this.#isHidden = false;\n };\n\n onPointRemove = (head: Step) => {\n if (head) {\n this.setPanelLocation(head);\n } else {\n this.hidePanel();\n }\n };\n\n removePanel = () => {\n if (this._container) {\n DOM.remove(this._container);\n }\n this.#panelPopup?.remove();\n };\n\n createButton = (type: \"undo\" | \"save\" | \"delete\", title: string, size: PanelImpl[\"size\"], container: HTMLElement) => {\n const button = DOM.create(\"button\", `panel-button panel-button-${size}`, container);\n button.setAttribute(\"data-type\", type);\n button.setAttribute(\"aria-label\", title);\n DOM.create(\"span\", `icon ${type} icon-${size}`, button);\n return button;\n };\n\n createPanel = () => {\n const { options } = this.#props;\n const { locale } = options;\n const { undo, delete: deleteButton, save } = options.panel.buttons;\n const panelSize = options.panel.size;\n\n const popupContent = document.querySelector(\".maplibregl-popup-content\") as HTMLElement;\n const container = DOM.create(\"div\", \"dashboard\", popupContent);\n\n if (undo.visible) {\n this._undoButton = this.createButton(\"undo\", locale.undo, panelSize, container);\n }\n if (deleteButton.visible) {\n this._deleteButton = this.createButton(\"delete\", locale.delete, panelSize, container);\n }\n if (save.visible) {\n this._saveButton = this.createButton(\"save\", locale.save, panelSize, container);\n }\n this._container = container;\n };\n}\n","import type { RequiredDrawOptions } from \"#types/index\";\nimport type { AddLayerObject } from \"maplibre-gl\";\n\nexport const POLYGON_BASE = {\n type: \"FeatureCollection\",\n features: [\n {\n type: \"Feature\",\n properties: {},\n geometry: {\n type: \"Polygon\",\n coordinates: [],\n },\n },\n ],\n};\n\nexport const LINE_BASE = {\n type: \"FeatureCollection\",\n features: [\n {\n type: \"Feature\",\n properties: {},\n geometry: {\n type: \"LineString\",\n coordinates: [],\n },\n },\n ],\n};\n\nexport const POINT_BASE = {\n type: \"FeatureCollection\",\n features: [\n {\n type: \"Feature\",\n properties: {},\n geometry: {\n type: \"Point\",\n coordinates: [],\n },\n },\n ],\n};\n\nexport const ELAYERS = {\n LineDynamicLayer: \"mdl-line-dynamic-layer\",\n LineLayer: \"mdl-line-layer\",\n LineLayerTransparent: \"mdl-line-layer-transparent\",\n LineLayerBreak: \"mdl-line-break-layer\",\n PolygonLayer: \"mdl-polygon-layer\",\n PointsLayer: \"mdl-points-layer\",\n SinglePointLayer: \"mdl-single-point-layer\",\n FirstPointLayer: \"mdl-first-point-layer\",\n} as const;\n\nexport const ESOURCES = {\n LineDynamicSource: \"mdl-line-dynamic-source\",\n LineSourceBreak: \"mdl-line-source-break\",\n LineSource: \"mdl-line-source\",\n PolygonSource: \"mdl-polygon-source\",\n PointsSource: \"mdl-points-source\",\n SinglePointSource: \"mdl-single-point-source\",\n} as const;\n\nexport const FIRST_POINT_RADIUS = {\n large: 6.5,\n default: 5.5,\n};\n\nexport const FIRST_POINT_COLOR = {\n large: \"#FF6464\",\n default: \"#666666\",\n};\n\nexport const FIRST_POINT_PAINT_BASE = {\n \"circle-radius\": FIRST_POINT_RADIUS[\"default\"],\n \"circle-color\": \"#FEFFFE\",\n \"circle-stroke-color\": FIRST_POINT_COLOR[\"default\"],\n \"circle-stroke-width\": 3,\n};\n\nexport const ON_LINE_POINT_PAINT_BASE = {\n \"circle-radius\": FIRST_POINT_RADIUS[\"large\"],\n \"circle-color\": \"#FEFFFE\",\n \"circle-stroke-color\": \"#666666\",\n \"circle-stroke-width\": 3,\n};\n\nexport const POLYGON_PAINT_BASE = {\n \"fill-color\": \"grey\",\n \"fill-opacity\": 0.4,\n};\n\nexport const LINE_PAINT_BASE = {\n \"line-width\": 3,\n \"line-color\": \"grey\",\n \"line-opacity\": 0.7,\n};\n\nexport const POINTS_PAINT_BASE = {\n \"circle-radius\": FIRST_POINT_RADIUS[\"default\"],\n \"circle-color\": \"#FEFFFE\",\n \"circle-stroke-color\": \"#666666\",\n \"circle-stroke-width\": 3,\n};\n\nexport const BREAK_PAINT_BASE = {\n \"line-width\": 3,\n \"line-color\": \"#FF6464\",\n \"line-dasharray\": [3, 3],\n};\n\nexport const generateLayersToRender = (options: RequiredDrawOptions) => {\n return [\n {\n id: ELAYERS.SinglePointLayer,\n source: ESOURCES.SinglePointSource,\n type: \"circle\",\n paint: options.layersPaint.onLinePoint,\n layout: {\n visibility: \"none\",\n },\n },\n {\n id: ELAYERS.PolygonLayer,\n source: ESOURCES.PolygonSource,\n type: \"fill\",\n paint: options.layersPaint.polygon,\n layout: {\n visibility: \"none\",\n },\n },\n {\n id: ELAYERS.LineDynamicLayer,\n source: ESOURCES.LineDynamicSource,\n type: \"line\",\n paint: options.layersPaint.line,\n layout: {\n visibility: \"none\",\n },\n },\n {\n id: ELAYERS.LineLayer,\n source: ESOURCES.LineSource,\n type: \"line\",\n paint: options.layersPaint.line,\n layout: {\n visibility: \"visible\",\n },\n },\n {\n id: ELAYERS.LineLayerTransparent,\n source: ESOURCES.LineSource,\n type: \"line\",\n paint: {\n \"line-width\": 4,\n \"line-color\": \"transparent\",\n },\n },\n {\n id: ELAYERS.LineLayerBreak,\n source: ESOURCES.LineSourceBreak,\n type: \"line\",\n paint: options.layersPaint.breakLine,\n layout: {\n visibility: \"none\",\n },\n },\n {\n id: ELAYERS.PointsLayer,\n source: ESOURCES.PointsSource,\n type: \"circle\",\n paint: options.layersPaint.points,\n filter: [\"==\", [\"get\", \"isFirst\"], false],\n },\n {\n id: ELAYERS.FirstPointLayer,\n source: ESOURCES.PointsSource,\n type: \"circle\",\n paint: options.layersPaint.firstPoint,\n filter: [\"==\", [\"get\", \"isFirst\"], true],\n },\n ] satisfies AddLayerObject[];\n};\n","import type { Map } from \"#types/map\";\n\nimport { ELAYERS, FIRST_POINT_COLOR, generateLayersToRender, FIRST_POINT_RADIUS } from \"#utils/geo_constants\";\nimport { RequiredDrawOptions } from \"#types/index\";\n\nexport class TilesHelpers {\n static #lastClickTime = 0;\n\n static #firstPointCircleRadius = (map: Map) => {\n map.setPaintProperty(ELAYERS.FirstPointLayer, \"circle-radius\", FIRST_POINT_RADIUS[\"large\"]);\n map.setPaintProperty(ELAYERS.FirstPointLayer, \"circle-stroke-color\", FIRST_POINT_COLOR[\"large\"]);\n };\n\n static #defaultPointCircleRadius = (map: Map) => {\n map.setPaintProperty(ELAYERS.FirstPointLayer, \"circle-radius\", FIRST_POINT_RADIUS[\"default\"]);\n map.setPaintProperty(ELAYERS.FirstPointLayer, \"circle-stroke-color\", FIRST_POINT_COLOR[\"default\"]);\n };\n\n static togglePointCircleRadius = (map: Map, type: keyof typeof FIRST_POINT_RADIUS) => {\n if (type === \"large\") {\n this.#firstPointCircleRadius(map);\n } else {\n this.#defaultPointCircleRadius(map);\n }\n };\n\n static removeTransparentLine = (map: Map) => {\n map.removeLayer(ELAYERS.LineLayerTransparent);\n };\n\n static addTransparentLine = (map: Map, options: RequiredDrawOptions) => {\n if (map.getLayer(ELAYERS.LineLayerTransparent)) return;\n const LAYERS_TO_RENDER = generateLayersToRender(options);\n const transparentLayer = LAYERS_TO_RENDER.find((layer) => layer.id === ELAYERS.LineLayerTransparent);\n if (transparentLayer) {\n map.addLayer(transparentLayer);\n }\n };\n\n static isDoubleClick() {\n const DOUBLE_CLICK_THRESHOLD = 400;\n const now = Date.now();\n\n if (now - this.#lastClickTime <= DOUBLE_CLICK_THRESHOLD) {\n this.#lastClickTime = now;\n return true;\n }\n\n this.#lastClickTime = now;\n return false;\n }\n}\n","import type { MapLayerMouseEvent, MapMouseEvent } from \"maplibre-gl\";\nimport type { LatLng, Point, Uuid, EventsProps } from \"#types/index\";\nimport type { Map } from \"#types/map\";\n\nimport { ListNode, Store } from \"#store/index\";\nimport { TilesHelpers } from \"#components/map/tiles/helpers\";\n\nimport { DrawingMode } from \"#components/map/mode\";\nimport { ELAYERS, POLYGON_BASE } from \"./geo_constants\";\n\nexport class MapUtils {\n static isFeatureTriggered(event: MapLayerMouseEvent, layerIds: string[]) {\n const layers = event.target.queryRenderedFeatures(event.point, {\n layers: layerIds,\n });\n return layers.some((layer) => layerIds.includes(layer.layer.id));\n }\n\n static getPixelCoordinates = (map: Map, coords: LatLng) => {\n const { lat, lng } = coords;\n return map.project([lng, lat]);\n };\n\n static queryPointId = (map: Map, point: MapMouseEvent[\"point\"]) => {\n const query = map.queryRenderedFeatures(point, {\n layers: [ELAYERS.PointsLayer, ELAYERS.FirstPointLayer],\n });\n const id = query?.[0]?.properties.id;\n return id;\n };\n}\n\nexport class GeometryFactory {\n static #collectGeometryCoordinates(store: Store): number[][] {\n const coordinates = [];\n let current = store.head;\n const visitedNodes = new Set();\n\n while (current !== null) {\n if (visitedNodes.has(current.val?.id)) {\n if (store.head && store.head.val) {\n coordinates.push([store.head.val.lng, store.head.val.lat]);\n }\n break;\n }\n visitedNodes.add(current.val?.id);\n\n if (current.val) {\n coordinates.push([current.val.lng, current.val.lat]);\n }\n current = current.next;\n }\n\n return coordinates;\n }\n\n static getAllLines(store: Store) {\n const coordinates = this.#collectGeometryCoordinates(store);\n return {\n type: \"FeatureCollection\",\n features: [\n {\n type: \"Feature\",\n properties: {},\n geometry: {\n type: \"LineString\",\n coordinates: coordinates,\n },\n },\n ],\n };\n }\n\n static getLine(current: [number, number], next: [number, number]) {\n return {\n type: \"FeatureCollection\",\n features: [\n {\n type: \"Feature\",\n properties: {},\n geometry: {\n type: \"LineString\",\n coordinates: [current, next],\n },\n },\n ],\n };\n }\n\n static getPolygon(store: Store) {\n const coordinates = this.#collectGeometryCoordinates(store);\n return {\n type: \"FeatureCollection\",\n features: [\n {\n type: \"Feature\",\n properties: {},\n geometry: {\n type: \"Polygon\",\n coordinates: [coordinates],\n },\n },\n ],\n };\n }\n\n static getPoints(store: Store) {\n let current = store.head;\n const pointFeatures = [];\n const visitedNodes = new Set();\n\n while (current !== null) {\n if (visitedNodes.has(current.val?.id)) {\n break;\n }\n if (current.val) {\n const val = current.val;\n const head = current.val.id === store.head?.val?.id;\n pointFeatures.push({\n type: \"Feature\",\n properties: { id: val.id, lat: val.lat, lng: val.lng, isFirst: head },\n geometry: {\n type: \"Point\",\n coordinates: [val.lng, val.lat],\n },\n });\n }\n visitedNodes.add(current.val?.id);\n current = current.next;\n }\n\n return {\n type: \"FeatureCollection\",\n features: pointFeatures,\n };\n }\n}\n\nexport class Spatial {\n static getGeometryIndex = (store: Store, id: Uuid) => {\n let current = store.head;\n let idx = 0;\n while (current !== null) {\n if (current.val?.id === id) {\n return idx;\n }\n idx++;\n current = current.next;\n }\n return -1;\n };\n\n static isFirstPoint(event: MapLayerMouseEvent): boolean {\n const map = event.target;\n const point = event.point;\n const points = map.queryRenderedFeatures(point, {\n layers: [ELAYERS.FirstPointLayer],\n });\n return Boolean(points.length);\n }\n\n // √(x2​−x1​)²+(y2​−y1​)²​\n static distance = (point1: Point, point2: Point) =>\n Math.sqrt((point1.x - point2.x) ** 2 + (point1.y - point2.y) ** 2);\n\n static checkIfPointIsOnLine = (A: Point, B: Point, P: Point): boolean => {\n const EPSILON = 0.1;\n\n const distanceAB = this.distance(A, B);\n const distanceAP = this.distance(A, P);\n const distancePB = this.distance(P, B);\n\n if (Math.abs(distanceAP + distancePB - distanceAB) < EPSILON) {\n return true;\n }\n\n return false;\n };\n\n static isClosedGeometry = (store: Store) => {\n return store.tail?.next === store.head;\n };\n\n static breakGeometry = (store: Store, id: Uuid) => {\n if (!store.head) return;\n\n let current = store.head;\n let prev = store.tail as ListNode; // we know that tail is not null because the geometry is closed\n\n do {\n if (current?.val?.id === id) {\n if (current !== store.head) {\n prev.next = current.next;\n store.head = current;\n store.tail = prev;\n }\n (store.tail as ListNode).next = null;\n return;\n }\n prev = current;\n current = current.next as ListNode;\n } while (current !== store.head);\n };\n\n static closeGeometry = (store: Store, mode: DrawingMode) => {\n if (store.tail) {\n store.tail.next = store.head;\n }\n mode.setClosedGeometry(true);\n };\n\n static canCloseGeometry = (store: Store) => {\n return store.size > 2 && !this.isClosedGeometry(store);\n };\n\n static canBreakClosedGeometry = (store: Store) => {\n return store.size <= 2;\n };\n\n static switchToLineModeIfCan = (context: EventsProps) => {\n const { mode, store, tiles, map } = context;\n\n if (Spatial.canBreakClosedGeometry(store)) {\n if (store.tail && store.tail.val) {\n store.tail.next = null;\n }\n mode.reset();\n TilesHelpers.togglePointCircleRadius(map, \"default\");\n tiles.renderPolygon(POLYGON_BASE);\n }\n };\n}\n\nexport const uuidv4 = (): Uuid => {\n if (\"crypto\" in window && \"randomUUID\" in window.crypto) {\n return window.crypto.randomUUID();\n }\n\n function getRandomHexChar() {\n const hexChars = \"0123456789abcdef\";\n return hexChars[Math.floor(Math.random() * 16)];\n }\n\n function getUuidSection(length: number) {\n let section = \"\";\n for (let i = 0; i < length; i++) {\n section += getRandomHexChar();\n }\n return section;\n }\n\n function getUuidSectionSize(idx: number) {\n const firstElement = idx === 0;\n const lastElement = idx === 4;\n\n if (firstElement) {\n return 8;\n }\n if (lastElement) {\n return 12;\n }\n\n return 4;\n }\n\n const parts = [];\n for (let i = 0; i < 5; i++) {\n parts.push(getUuidSection(getUuidSectionSize(i)));\n }\n\n return parts.join(\"-\") as Uuid;\n};\n\nexport const throttle = (fn: (...args: any) => void, delay: number) => {\n let lastArgs: any;\n let shouldCall = true;\n\n function execute() {\n if (shouldCall && lastArgs) {\n fn(...lastArgs);\n lastArgs = null;\n shouldCall = false;\n setTimeout(() => {\n shouldCall = true;\n execute();\n }, delay);\n }\n }\n\n return function (...args: any) {\n lastArgs = args;\n execute();\n };\n};\n","import type { GeoJSONSource } from \"maplibre-gl\";\n\nimport type { LatLng, RequiredDrawOptions } from \"#types/index\";\nimport type { Map } from \"#types/map\";\nimport { Store } from \"#store/index\";\nimport { ELAYERS, ESOURCES, generateLayersToRender } from \"#utils/geo_constants\";\nimport { POINT_BASE, LINE_BASE, POLYGON_BASE } from \"#utils/geo_constants\";\nimport { GeometryFactory } from \"#utils/helpers\";\nimport { DrawingMode } from \"#components/map/mode\";\n\ninterface IProps {\n map: Map;\n store: Store;\n options: RequiredDrawOptions;\n mode: DrawingMode;\n}\n\nexport class Tiles {\n #props: IProps;\n #pointsFeature: any;\n #linesFeature: any;\n #polygonFeature: any;\n\n constructor(props: IProps) {\n this.#props = props;\n this.#init();\n this.render();\n }\n\n #init() {\n this.#addSources();\n this.#addLayers();\n this.#swapLayers(ELAYERS.LineLayer, ELAYERS.SinglePointLayer);\n this.#swapLayers(ELAYERS.LineLayerTransparent, ELAYERS.SinglePointLayer);\n this.#swapLayers(ELAYERS.LineLayerTransparent, ELAYERS.FirstPointLayer);\n this.#swapLayers(ELAYERS.LineLayerTransparent, ELAYERS.PointsLayer);\n this.#swapLayers(ELAYERS.PolygonLayer, ELAYERS.LineLayer);\n }\n\n #addSources = () => {\n const { map } = this.#props;\n Object.values(ESOURCES).forEach((source) => {\n if (!map.getSource(source)) {\n map.addSource(source, {\n type: \"geojson\",\n data: {\n type: \"FeatureCollection\",\n features: [],\n },\n promoteId: \"id\",\n });\n }\n });\n };\n\n #addLayers = () => {\n const { map, mode, options } = this.#props;\n\n const LAYERS_TO_RENDER = generateLayersToRender(options);\n\n LAYERS_TO_RENDER.forEach((layer) => {\n if (!map.getLayer(layer.id)) {\n map.addLayer(layer);\n }\n });\n\n const polygonInvisible = map.getLayoutProperty(ELAYERS.PolygonLayer, \"visibility\") === \"none\";\n if (mode.getMode() === \"polygon\" && polygonInvisible) {\n map.setLayoutProperty(ELAYERS.PolygonLayer, \"visibility\", \"visible\");\n }\n };\n\n #swapLayers = (beneathLayerId: string, aboveLayerId: string) => {\n const { map } = this.#props;\n\n const beneath = map.getLayer(beneathLayerId);\n const above = map.getLayer(aboveLayerId);\n\n if (beneath && above) {\n map.moveLayer(beneathLayerId, aboveLayerId);\n }\n };\n\n #removeSources = () => {\n const { map } = this.#props;\n\n Object.values(ESOURCES).forEach((source) => {\n if (map.getSource(source)) {\n map.removeSource(source);\n }\n });\n };\n\n #removeLayers = () => {\n const { map } = this.#props;\n\n Object.values(ELAYERS).forEach((layer) => {\n if (map.getLayer(layer)) {\n map.removeLayer(layer);\n }\n });\n };\n\n removeTiles = () => {\n // first remove the layers then all the sources\n this.#removeLayers();\n this.#removeSources();\n };\n\n renderPoints = (points: any) => {\n const { map } = this.#props;\n\n const pointSource = map.getSource(ESOURCES.PointsSource) as GeoJSONSource;\n if (pointSource) {\n pointSource.setData(points);\n }\n };\n\n renderLines = (lines: any, source: string) => {\n const { map } = this.#props;\n\n const lineSource = map.getSource(source) as GeoJSONSource;\n\n if (lineSource) {\n lineSource.setData(lines);\n }\n };\n\n renderPolygon = (polygon: any) => {\n const { map } = this.#props;\n\n const polygoneSource = map.getSource(ESOURCES.PolygonSource) as GeoJSONSource;\n\n if (polygoneSource) {\n polygoneSource.setData(polygon);\n }\n };\n\n render = () => {\n const { mode, options, store } = this.#props;\n\n const points = GeometryFactory.getPoints(store);\n const lines = GeometryFactory.getAllLines(store);\n this.#pointsFeature = points;\n this.#linesFeature = lines;\n\n this.renderPoints(points);\n this.renderLines(lines, ESOURCES.LineSource);\n\n const polygonOptionChecked = options.modes.polygon.visible;\n if (polygonOptionChecked && mode.isPolygon()) {\n const polygon = GeometryFactory.getPolygon(store);\n this.#polygonFeature = polygon;\n this.renderPolygon(polygon);\n }\n };\n\n #renderPolygonOnMouseMove = (featureIdx: number, newCoord: LatLng) => {\n this.#polygonFeature.features[0].geometry.coordinates[0][featureIdx] = [newCoord.lng, newCoord.lat];\n const firstElement = featureIdx === 0;\n if (firstElement) {\n const lastIdx = this.#polygonFeature.features[0].geometry.coordinates[0]?.length - 1;\n this.#polygonFeature.features[0].geometry.coordinates[0][lastIdx] = [newCoord.lng, newCoord.lat];\n }\n this.renderPolygon(this.#polygonFeature);\n };\n\n #renderLineOnMouseMove = (featureIdx: number, newCoord: LatLng) => {\n const { mode } = this.#props;\n\n this.#linesFeature.features[0].geometry.coordinates[featureIdx] = [newCoord.lng, newCoord.lat];\n\n const firstElement = featureIdx === 0;\n const selectedFirstPointInClosedLine = this.#linesFeature && mode.getClosedGeometry() && firstElement;\n if (selectedFirstPointInClosedLine) {\n const lastIdx = this.#linesFeature.features[0].geometry.coordinates?.length - 1;\n this.#linesFeature.features[0].geometry.coordinates[lastIdx] = [newCoord.lng, newCoord.lat];\n }\n this.renderLines(this.#linesFeature, ESOURCES.LineSource);\n };\n\n renderOnMouseMove = (featureIdx: number, newCoord: LatLng) => {\n const { mode, options } = this.#props;\n\n this.#pointsFeature.features[featureIdx].geometry.coordinates = [newCoord.lng, newCoord.lat];\n this.renderPoints(this.#pointsFeature);\n this.#renderLineOnMouseMove(featureIdx, newCoord);\n\n const polygonOptionChecked = options.modes.polygon.visible;\n if (polygonOptionChecked && mode.isPolygon()) {\n this.#renderPolygonOnMouseMove(featureIdx, newCoord);\n }\n };\n\n resetGeometries = () => {\n this.renderPoints(POINT_BASE);\n this.renderLines(LINE_BASE, ESOURCES.LineSource);\n this.renderPolygon(POLYGON_BASE);\n };\n}\n","import { HTMLEvent } from \"#types/helpers\";\nimport { DOM } from \"#utils/dom\";\nimport \"./tooltip.css\";\n\ninterface CreateOptions {\n label: string;\n placement: \"left\" | \"bottom\";\n}\n\nconst BASE_Y_OFFSET_FROM_ELEMENT = 8;\nconst BASE_X_OFFSET_FROM_ELEMENT = 8;\n\ntype Position = {\n x: number;\n y: number;\n};\n\nexport class Tooltip {\n _container: HTMLElement | undefined;\n _label: HTMLElement | undefined;\n\n constructor() {\n this._container = undefined;\n }\n\n create = (options: CreateOptions) => {\n const container = DOM.create(\"div\", \"popup-container\", document.body);\n const span = DOM.create(\"span\", `popup-text popup-text-${options.placement}`, container);\n span.textContent = options.label;\n this._container = container;\n this._label = span;\n return this;\n };\n\n #activateAnimation = () => {\n const notActive = !this._label?.classList.value.includes(\"popup-text-active\");\n if (notActive) {\n this._label?.classList.add(\"popup-text-active\");\n }\n };\n\n #getLabelDimensions = () => {\n if (!this._label) return { width: 0, height: 0 };\n\n return {\n width: this._label.clientWidth,\n height: this._label.clientHeight,\n };\n };\n\n #getLeftPosition = (event: HTMLEvent<HTMLElement>): Position => {\n const { bottom, left } = event.target.getBoundingClientRect();\n const { width: labelWidth, height: labelHeight } = this.#getLabelDimensions();\n\n return {\n x: left - BASE_X_OFFSET_FROM_ELEMENT - labelWidth,\n y: bottom - labelHeight - 2,\n };\n };\n\n #getBottomPosition = (event: HTMLEvent<HTMLElement>): Position => {\n const { bottom, left, right } = event.target.getBoundingClientRect();\n const { width: labelWidth } = this.#getLabelDimensions();\n\n const elementCenterX = (right - left) / 2 + left;\n return {\n x: elementCenterX - labelWidth / 2,\n y: bottom + BASE_Y_OFFSET_FROM_ELEMENT,\n };\n };\n\n getPosition = (event: HTMLEvent<HTMLElement>, position: \"left\" | \"bottom\"): Position => {\n if (position === \"left\") {\n return this.#getLeftPosition(event);\n }\n\n return this.#getBottomPosition(event);\n };\n\n setPosition = (pos: Position) => {\n const { x, y } = pos;\n if (this._container) {\n this._container.style.left = `${x}px`;\n this._container.style.top = `${y}px`;\n }\n this.#activateAnimation();\n };\n\n remove = () => {\n if (this._container) {\n DOM.remove(this._container);\n }\n };\n}\n","export const CURSORS = {\n AUTO: \"auto\",\n DEFAULT: \"default\",\n POINTER: \"pointer\",\n CROSSHAIR: \"crosshair\",\n MOVE: \"move\",\n HELP: \"help\",\n GRAB: \"grab\",\n GRABBING: \"grabbing\",\n} as const;\n\nexport type TCursor = (typeof CURSORS)[keyof typeof CURSORS];\n","import { ControlType, RequiredDrawOptions } from \"#types/index\";\nimport { DOM } from \"#utils/dom\";\n\nexport const addControlListeners = (\n element: HTMLElement,\n events: { [key: string]: EventListenerOrEventListenerObject },\n) => {\n for (const [event, listener] of Object.entries(events)) {\n DOM.manageEventListener(\"add\", element, event, listener);\n }\n};\n\nexport const removeControlListeners = (\n element: HTMLElement,\n events: { [key: string]: EventListenerOrEventListenerObject },\n) => {\n for (const [event, listener] of Object.entries(events)) {\n DOM.manageEventListener(\"remove\", element, event, listener);\n }\n};\n\nexport const getButtonLabel = (type: ControlType, options: RequiredDrawOptions) => {\n const lineTitle = options.locale.line;\n const polygonTitle = options.locale.polygon;\n const breakTitle = options.locale.break;\n\n const LABELS = {\n line: lineTitle,\n polygon: polygonTitle,\n break: breakTitle,\n };\n\n return LABELS[type];\n};\n","import { RequiredDrawOptions } from \"../types\";\nimport {\n BREAK_PAINT_BASE,\n FIRST_POINT_PAINT_BASE,\n LINE_PAINT_BASE,\n ON_LINE_POINT_PAINT_BASE,\n POINTS_PAINT_BASE,\n POLYGON_PAINT_BASE,\n} from \"./geo_constants\";\n\nexport const EVENTS = {\n DOUBLECLICK: \"mdl:doubleclick\",\n POINTENTER: \"mdl:pointenter\",\n POINTLEAVE: \"mdl:pointleave\",\n MOVEEND: \"mdl:moveend\",\n ADD: \"mdl:add\",\n UNDO: \"mdl:undo\",\n REMOVEALL: \"mdl:removeall\",\n SAVE: \"mdl:save\",\n BREAK: \"mdl:break\",\n MODECHANGED: \"mdl:modechanged\",\n} as const;\n\nexport const MOBILE_WIDTH = 768;\n\nexport const DEFAULT_OPTIONS: RequiredDrawOptions = {\n panel: {\n size: \"medium\",\n buttons: {\n undo: { visible: true },\n delete: { visible: true },\n save: { visible: true, clearOnSave: true },\n },\n },\n modes: {\n initial: null,\n line: {\n visible: true,\n closeGeometry: true,\n },\n polygon: {\n visible: true,\n },\n breakGeometry: {\n visible: true,\n },\n },\n layersPaint: {\n onLinePoint: ON_LINE_POINT_PAINT_BASE,\n firstPoint: FIRST_POINT_PAINT_BASE,\n points: POINTS_PAINT_BASE,\n line: LINE_PAINT_BASE,\n polygon: POLYGON_PAINT_BASE,\n breakLine: BREAK_PAINT_BASE,\n },\n initial: null,\n dynamicLine: true,\n locale: {\n save: \"Save\",\n delete: \"Delete all\",\n undo: \"Undo\",\n line: \"Line\",\n polygon: \"Polygon\",\n break: \"Split\",\n closeLine: \"Close line\",\n createPolygon: \"Create polygon\",\n },\n};\n","import type { Map } from \"#types/map\";\nimport type { LatLng, StepId, Step, EventsProps } from \"#types/index\";\nimport { EVENTS } from \"#utils/constants\";\nimport { DrawingMode } from \"./mode\";\nimport { Mode } from \"./mode/types\";\n\nexport class FireEvents {\n static addPoint(step: Step & { total: number }, map: Map, mode: DrawingMode) {\n map.fire(EVENTS.ADD, {\n id: step.id,\n coordinates: {\n lat: step.lat,\n lng: step.lng,\n },\n total: step.total,\n timestamp: Date.now(),\n mode: {\n geometry: mode.getMode(),\n closedGeometry: mode.getClosedGeometry(),\n },\n });\n }\n static movePoint(step: { end: LatLng; id: StepId; start: LatLng; total: number }, map: Map) {\n map.fire(EVENTS.MOVEEND, {\n id: step.id,\n start_coordinates: {\n lat: step.start.lat,\n lng: step.start.lng,\n },\n end_coordinates: {\n lat: step.end.lat,\n lng: step.end.lng,\n },\n total: step.total,\n timestamp: Date.now(),\n });\n }\n static pointDoubleClick(step: Step & { total: number }, map: Map) {\n map.fire(EVENTS.DOUBLECLICK, {\n id: step.id,\n coordinates: {\n lat: step.lat,\n lng: step.lng,\n },\n total: step.total,\n timestamp: Date.now(),\n });\n }\n static enterPoint(step: Step & { total: number }, map: Map) {\n map.fire(EVENTS.POINTENTER, {\n id: step.id,\n coordinates: {\n lat: step.lat,\n lng: step.lng,\n },\n total: step.total,\n timestamp: Date.now(),\n });\n }\n static leavePoint(step: Step & { total: number }, map: Map) {\n map.fire(EVENTS.POINTLEAVE, {\n id: step.id,\n coordinates: {\n lat: step.lat,\n lng: step.lng,\n },\n total: step.total,\n timestamp: Date.now(),\n });\n }\n static undoPoint(step: Step & { total: number }, map: Map, originalEvent?: Event) {\n map.fire(EVENTS.UNDO, {\n originalEvent,\n id: step.id,\n coordinates: {\n lat: step.lat,\n lng: step.lng,\n },\n total: step.total,\n timestamp: Date.now(),\n });\n }\n static modeChanged(map: Map, mode: Mode | \"break\") {\n map.fire(EVENTS.MODECHANGED, {\n mode,\n });\n }\n static removeAllPoints(map: Map, originalEvent: Event) {\n map.fire(EVENTS.REMOVEALL, { originalEvent });\n }\n static onSaveClick(context: Pick<EventsProps, \"map\" | \"mode\">, steps: Step[], originalEvent: Event) {\n const { map, mode } = context;\n\n map.fire(EVENTS.SAVE, {\n originalEvent,\n timestamp: Date.now(),\n steps,\n mode: {\n geometry: mode.getMode(),\n closedGeometry: mode.getClosedGeometry(),\n },\n });\n }\n static onLineBreak(map: Map) {\n map.fire(EVENTS.BREAK);\n }\n}\n","import { FireEvents } from \"#components/map/helpers\";\nimport { DrawingModeChangeEvent, Mode } from \"#components/map/mode/types\";\nimport { EventsProps } from \"#types/index\";\n\nexport class ControlObserver {\n #props: EventsProps;\n constructor(props: EventsProps) {\n this.#props = props;\n this.#initConsumers();\n }\n\n #initConsumers = () => {\n this.#props.mode.addObserver(this.#mapModeConsumer);\n };\n\n removeConsumers = () => {\n this.#props.mode.removeObserver(this.#mapModeConsumer);\n };\n\n #resetAllState = () => {\n const { _line, _polygon, _break } = this.#props.control;\n\n _line?.classList.remove(\"control-button-active\");\n _polygon?.classList.remove(\"control-button-active\");\n _break?.classList.remove(\"control-button-active\");\n };\n\n #checkActive = (button: HTMLElement) => {\n this.#resetAllState();\n button.classList.add(\"control-button-active\");\n };\n\n #observeModeChange = (event: DrawingModeChangeEvent) => {\n const { data } = event;\n const { _line, _polygon, _break } = this.#props.control;\n const { mode } = this.#props;\n FireEvents.modeChanged(this.#props.map, data as Mode);\n\n if (!_line || !_polygon || !_break) return;\n\n switch (data) {\n case \"line\":\n this.#checkActive(_line);\n break;\n case \"polygon\":\n this.#checkActive(_polygon);\n break;\n default:\n break;\n }\n\n if (!data) {\n this.#disableButton(_break);\n } else {\n if (mode.getClosedGeometry()) {\n this.#enableButton(_break);\n }\n }\n };\n\n #disableButton = (button: HTMLButtonElement) => {\n button.setAttribute(\"disabled\", \"true\");\n button.setAttribute(\"aria-disabled\", \"true\");\n };\n\n #enableButton = (button: HTMLButtonElement) => {\n button.removeAttribute(\"disabled\");\n button.removeAttribute(\"aria-disabled\");\n };\n\n #observeGeometryChange = (event: DrawingModeChangeEvent) => {\n const { data } = event;\n const { _break, _line, _polygon } = this.#props.control;\n const { mode } = this.#props;\n\n if (data) {\n if (_break) {\n this.#enableButton(_break);\n }\n if (mode.getMode() === \"polygon\") {\n if (_line) {\n this.#disableButton(_line);\n }\n }\n if (mode.getMode() === \"line\") {\n if (_polygon) {\n this.#disableButton(_polygon);\n }\n }\n } else {\n if (_break) {\n this.#disableButton(_break);\n }\n if (mode.getMode() === \"polygon\") {\n if (_line) {\n this.#enableButton(_line);\n }\n }\n if (mode.getMode() === \"line\") {\n if (_polygon) {\n this.#enableButton(_polygon);\n }\n }\n }\n };\n\n #mapModeConsumer = (event: DrawingModeChangeEvent) => {\n const { type, data } = event;\n\n if (type === \"MODE_CHANGED\") {\n this.#observeModeChange(event);\n }\n if (type === \"CLOSED_GEOMETRY_CHANGED\") {\n this.#observeGeometryChange(event);\n }\n if (type === \"BREAK_CHANGED\" && data) {\n const { _break } = this.#props.control;\n this.#checkActive(_break as HTMLElement);\n FireEvents.modeChanged(this.#props.map, \"break\");\n }\n };\n}\n","import type { EventsProps, ControlType } from \"#types/index\";\nimport { HTMLEvent } from \"#types/helpers\";\nimport { Tooltip } from \"#components/tooltip\";\nimport { CURSORS } from \"#components/map/cursor/constants\";\n\nimport { addControlListeners, getButtonLabel, removeControlListeners } from \"./helpers\";\nimport { ELAYERS } from \"#utils/geo_constants\";\nimport { ControlObserver } from \"./observer\";\n\nexport class ControlEvents {\n #props: EventsProps;\n #tooltip: Tooltip;\n #observer: ControlObserver;\n\n constructor(props: EventsProps) {\n this.#props = props;\n this.#observer = new ControlObserver(props);\n this.#tooltip = new Tooltip();\n this.#initEvents();\n }\n\n #initEvents() {\n const { control } = this.#props;\n if (control) {\n const events = {\n mouseenter: this.onButtonEnter as EventListenerOrEventListenerObject,\n mouseleave: this.onButtonLeave,\n };\n\n if (control._line) {\n addControlListeners(control._line, {\n ...events,\n click: this.onLineClick,\n });\n }\n if (control._polygon) {\n addControlListeners(control._polygon, {\n ...events,\n click: this.onPolygonClick,\n });\n }\n if (control._break) {\n addControlListeners(control._break, {\n ...events,\n click: this.onBreakClick,\n });\n }\n }\n }\n\n #removeEvents() {\n const { control } = this.#props;\n if (control) {\n const events = {\n mouseenter: this.onButtonEnter as EventListenerOrEventListenerObject,\n mouseleave: this.onButtonLeave,\n };\n\n if (control._line) {\n removeControlListeners(control._line, {\n ...events,\n click: this.onLineClick,\n });\n }\n if (control._polygon) {\n removeControlListeners(control._polygon, {\n ...events,\n click: this.onPolygonClick,\n });\n }\n if (control._break) {\n removeControlListeners(control._break, {\n ...events,\n click: this.onBreakClick,\n });\n }\n }\n }\n\n remove() {\n this.#observer.removeConsumers();\n this.#removeEvents();\n this.#tooltip.remove();\n }\n\n onButtonEnter = (event: HTMLEvent<HTMLButtonElement>) => {\n const { options } = this.#props;\n\n const type = event.target.getAttribute(\"data-type\") as ControlType;\n if (type) {\n const label = getButtonLabel(type, options);\n const placement = \"left\";\n this.#tooltip\n .create({\n label,\n placement,\n })\n .setPosition(this.#tooltip.getPosition(event, placement));\n }\n };\n\n onButtonLeave = () => {\n this.#tooltip.remove();\n };\n\n #removeActiveClass = () => {\n const { control } = this.#props;\n\n control._line?.classList.remove(\"control-button-active\");\n control._polygon?.classList.remove(\"control-button-active\");\n control._break?.classList.remove(\"control-button-active\");\n };\n\n #initialize = () => {\n const { map, mode } = this.#props;\n if (!mode.getMode()) {\n map.fire(\"mode:initialize\");\n }\n };\n\n onLineClick = () => {\n const { map, mode, tiles, control } = this.#props;\n this.#initialize();\n this.#removeActiveClass();\n if (mode.getMode() === \"line\" && !mode.getBreak()) {\n mode.setMode(null);\n map.fire(\"mode:remove\");\n tiles.resetGeometries();\n } else {\n control._line?.classList.add(\"control-button-active\");\n mode.setMode(\"line\");\n tiles.render();\n }\n };\n\n onPolygonClick = () => {\n const { map, mode, tiles, control } = this.#props;\n this.#initialize();\n this.#removeActiveClass();\n if (mode.getMode() === \"polygon\" && !mode.getBreak()) {\n mode.setMode(null);\n map.fire(\"mode:remove\");\n map.setLayoutProperty(ELAYERS.PolygonLayer, \"visibility\", \"visible\");\n tiles.resetGeometries();\n } else {\n control._polygon?.classList.add(\"control-button-active\");\n mode.setMode(\"polygon\");\n tiles.render();\n }\n };\n\n onBreakClick = () => {\n const { map, mode, control } = this.#props;\n if (mode.getBreak()) {\n mode.setMode(null);\n map.fire(\"mode:remove\");\n }\n this.#removeActiveClass();\n control._break?.classList.add(\"control-button-active\");\n mode.setBreak(true);\n map.getCanvasContainer().style.cursor = CURSORS.POINTER;\n };\n}\n","type Func<T> = (event: T) => any;\n\nexport type ChangeEvent<T> = {\n [K in keyof T]: {\n type: K;\n data: T[K];\n };\n}[keyof T];\n\nexport class Observable<T> {\n observers: Set<Func<T>>;\n\n constructor() {\n this.observers = new Set<Func<T>>();\n }\n\n addObserver(observer: Func<T>) {\n this.observers.add(observer);\n }\n\n removeObserver(observer: Func<T>) {\n this.observers.delete(observer);\n }\n\n unsubscribe() {\n this.observers.clear();\n }\n\n notify(args: T) {\n this.observers.forEach((observer) => observer(args));\n }\n}\n","export const ERRORS = {\n EMPTY_INITIAL_STATE:\n \"You passed an empty initial array in the options. Please either remove the 'initial' property or include at least one element in the array.\",\n MISSING_IDS:\n \"You set 'generateId' to false but did not provide IDs for all steps. Please ensure all steps have IDs or set 'generateId' to true.\",\n NOT_ENOUGH_POINTS_TO_CLOSE:\n \"At least three points are required to close a polygon or a line. Please add more points or set 'closeGeometry' to false.\",\n FIRST_LAST_POINT_NOT_EQUAL:\n \"The first and last points of a polygon or a closed linestring must be the same. Please ensure the first and last points are equal or set 'closeGeometry' to false.\",\n};\n","import type { Initial, LatLng, RequiredDrawOptions, Step, StepId } from \"#types/index\";\nimport { uuidv4 } from \"#utils/helpers\";\nimport { Observable } from \"#utils/observable\";\n\nimport { ERRORS } from \"./errors\";\nimport { StoreChangeEvent } from \"./types\";\n\nexport class ListNode {\n val: Step | null;\n next: ListNode | null;\n constructor(val: Step | null = null, next: ListNode | null = null) {\n this.val = val;\n this.next = next;\n }\n}\n\nexport class Store extends Observable<StoreChangeEvent> {\n head: ListNode | null;\n tail: ListNode | null;\n size: number;\n\n constructor(options?: RequiredDrawOptions) {\n super();\n let list = StoreHelpers.initStore(options);\n\n this.head = list ? list.head : null;\n this.tail = list ? list.tail : null;\n this.size = list ? list.size : 0;\n }\n\n push(step: Step) {\n const newNode = new ListNode(step);\n if (!this.head) {\n this.head = this.tail = newNode;\n } else if (this.tail) {\n this.tail.next = newNode;\n this.tail = newNode;\n }\n this.size++;\n this.pingConsumers();\n }\n\n insert(step: Step, current: ListNode) {\n const newNode = new ListNode(step, current.next);\n const betweenHeadAndTail = this.tail === current && this.head === current.next;\n // If the point is inserted between head and tail, update the tail\n if (betweenHeadAndTail) {\n this.tail = newNode;\n }\n current.next = newNode;\n this.size++;\n }\n\n findStepById(id: StepId): ListNode[\"val\"] | null {\n let current = this.head;\n const visitedNodes = new Set();\n while (current !== null) {\n if (visitedNodes.has(current)) {\n break;\n }\n if (current.val && current.val.id === id) {\n return current.val;\n }\n visitedNodes.add(current);\n current = current.next;\n }\n return null;\n }\n\n removeStepById(id: string): ListNode | null {\n if (!this.head) return null;\n let current = this.head;\n let prev: ListNode | null = null;\n while (current !== null) {\n if (current?.val?.id === id) {\n if (current === this.head) {\n this.head = current.next;\n if (this.tail) {\n this.tail.next = current.next;\n }\n } else {\n (prev as ListNode).next = current.next;\n }\n if (current === this.tail) {\n this.tail = prev;\n }\n this.size--;\n this.pingConsumers();\n\n return current;\n }\n\n prev = current;\n if (current.next) {\n current = current.next;\n }\n }\n\n return null;\n }\n\n reset() {\n this.head = null;\n this.tail = null;\n this.size = 0;\n this.pingConsumers();\n }\n\n pingConsumers = () => {\n this.notify({\n type: \"STORE_CHANGED\",\n data: {\n head: this.head,\n tail: this.tail,\n size: this.size,\n },\n });\n };\n}\n\nexport class StoreHelpers {\n static isLastPoint = (store: Store, id: StepId): boolean => {\n return store.tail?.val?.id === id;\n };\n\n static initStore(options?: RequiredDrawOptions): Store | null {\n if (!options?.initial) return null;\n\n const emptyInitialOptions = options && options.initial && !options.initial.steps.length;\n if (emptyInitialOptions) {\n throw new Error(ERRORS[\"EMPTY_INITIAL_STATE\"]);\n }\n\n const initialOptionsProvided = options && options.initial.steps;\n if (initialOptionsProvided) {\n const { steps, closeGeometry, generateId } = options.initial;\n return StoreHelpers.fromArray(steps, closeGeometry, generateId);\n }\n\n return null;\n }\n\n static #generateIdForSteps = (stepsWithoutIds: LatLng[]): Step[] => {\n return stepsWithoutIds.map((step) => {\n return { ...step, id: uuidv4() };\n });\n };\n\n static buildStepSequence(steps: Step[]): Store {\n const list = new Store();\n steps.forEach((step) => {\n list.push(step);\n });\n return list;\n }\n\n static fromArray(\n initialSteps: Initial[\"steps\"],\n closeGeometry: Initial[\"closeGeometry\"],\n generateId: Initial[\"generateId\"],\n ): Store | null {\n let steps = generateId ? this.#generateIdForSteps(initialSteps) : initialSteps;\n\n const list = this.buildStepSequence(steps as Step[]);\n\n if (closeGeometry && list.tail) {\n list.tail.next = list.head;\n }\n return list;\n }\n\n static toArray(head: ListNode | null): Step[] {\n if (!head) return [];\n\n const visitedNodes = new Set<ListNode>();\n const result: Step[] = [];\n\n let current: ListNode | null = head;\n while (current !== null) {\n if (visitedNodes.has(current)) break;\n\n visitedNodes.add(current);\n result.push(current.val as Step);\n current = current.next;\n }\n\n return result;\n }\n}\n","import { StoreHelpers } from \"#store/index\";\nimport type { ButtonType, EventsProps, Step } from \"#types/index\";\nimport { HTMLEvent } from \"#types/helpers\";\nimport { DOM } from \"#utils/dom\";\nimport { Tooltip } from \"#components/tooltip\";\nimport { FireEvents } from \"#components/map/helpers\";\nimport { Spatial } from \"#utils/helpers\";\nimport { TilesHelpers } from \"#components/map/tiles/helpers\";\n\nexport class PanelEvents {\n #props: EventsProps;\n #tooltip: Tooltip;\n\n constructor(props: EventsProps) {\n this.#props = props;\n this.#tooltip = new Tooltip();\n }\n\n initEvents() {\n const { panel } = this.#props;\n if (panel) {\n DOM.manageEventListener(\"add\", panel?._undoButton, \"click\", this.#onUndoClick);\n DOM.manageEventListener(\n \"add\",\n panel?._undoButton,\n \"mouseenter\",\n this.onMouseEnter as EventListenerOrEventListenerObject,\n );\n DOM.manageEventListener(\"add\", panel?._undoButton, \"mouseleave\", this.onMouseLeave);\n }\n if (panel) {\n DOM.manageEventListener(\"add\", panel?._deleteButton, \"click\", this.#onRemoveAll);\n DOM.manageEventListener(\n \"add\",\n panel?._deleteButton,\n \"mouseenter\",\n this.onMouseEnter as EventListenerOrEventListenerObject,\n );\n DOM.manageEventListener(\"add\", panel?._deleteButton, \"mouseleave\", this.onMouseLeave);\n }\n\n if (panel) {\n DOM.manageEventListener(\"add\", panel?._saveButton, \"click\", this.onSaveClick);\n DOM.manageEventListener(\n \"add\",\n panel?._saveButton,\n \"mouseenter\",\n this.onMouseEnter as EventListenerOrEventListenerObject,\n );\n DOM.manageEventListener(\"add\", panel?._saveButton, \"mouseleave\", this.onMouseLeave);\n }\n }\n\n removeEvents() {\n const { panel } = this.#props;\n\n if (panel && panel._undoButton) {\n DOM.manageEventListener(\"remove\", panel._undoButton, \"click\", this.#onUndoClick);\n DOM.manageEventListener(\n \"remove\",\n panel._undoButton,\n \"mouseenter\",\n this.onMouseEnter as EventListenerOrEventListenerObject,\n );\n DOM.manageEventListener(\"remove\", panel._undoButton, \"mouseleave\", this.onMouseLeave);\n }\n if (panel && panel._deleteButton) {\n DOM.manageEventListener(\"remove\", panel._deleteButton, \"click\", this.#onRemoveAll);\n DOM.manageEventListener(\n \"remove\",\n panel._deleteButton,\n \"mouseenter\",\n this.onMouseEnter as EventListenerOrEventListenerObject,\n );\n DOM.manageEventListener(\"remove\", panel._deleteButton, \"mouseleave\", this.onMouseLeave);\n }\n if (panel && panel._saveButton) {\n DOM.manageEventListener(\"remove\", panel._saveButton, \"click\", this.onSaveClick);\n DOM.manageEventListener(\n \"remove\",\n panel._saveButton,\n \"mouseenter\",\n this.onMouseEnter as EventListenerOrEventListenerObject,\n );\n DOM.manageEventListener(\"remove\", panel._saveButton, \"mouseleave\", this.onMouseLeave);\n }\n }\n\n #getButtonLabel = (type: ButtonType) => {\n const { options } = this.#props;\n\n const LABELS = {\n undo: options.locale.undo,\n delete: options.locale.delete,\n save: options.locale.save,\n };\n\n return LABELS[type];\n };\n\n onMouseEnter = (event: HTMLEvent<HTMLButtonElement>) => {\n const type = event.target.getAttribute(\"data-type\") as ButtonType;\n if (type) {\n const label = this.#getButtonLabel(type);\n\n this.#tooltip\n .create({\n label: label,\n placement: \"bottom\",\n })\n .setPosition(this.#tooltip.getPosition(event, \"bottom\"));\n }\n };\n\n onMouseLeave = () => {\n this.#tooltip.remove();\n };\n\n #onRemoveAll = (event: Event) => {\n const { tiles, mode, panel, store, map } = this.#props;\n store.reset();\n panel.hidePanel();\n mode.reset();\n TilesHelpers.togglePointCircleRadius(map, \"default\");\n this.#tooltip.remove();\n tiles.resetGeometries();\n FireEvents.removeAllPoints(map, event);\n };\n\n #onUndoClick = (event: Event) => {\n const { store, panel, map, tiles } = this.#props;\n\n const tailVal = store.tail?.val as Step;\n store.removeStepById(tailVal.id);\n\n const step = { ...tailVal, total: store.size };\n FireEvents.undoPoint(step, map, event);\n\n // if we have only 2 points left, we need to switch to line mode and update the tail.next to null\n Spatial.switchToLineModeIfCan(this.#props);\n\n // after removing the last point, we need to set the panel coordinates to the new last point\n panel?.onPointRemove(store.tail?.val as Step);\n this.#tooltip.remove();\n\n requestAnimationFrame(tiles.render);\n };\n\n onSaveClick = (event: Event) => {\n const { store, options } = this.#props;\n\n FireEvents.onSaveClick(this.#props, StoreHelpers.toArray(store.head), event);\n this.#tooltip.remove();\n if (options.panel.buttons.save.clearOnSave) {\n this.#onRemoveAll(event);\n }\n };\n}\n","import type { MapLayerMouseEvent, GeoJSONSource } from \"maplibre-gl\";\nimport type { EventsProps, Step } from \"#types/index\";\n\nimport { ESOURCES, ELAYERS } from \"#utils/geo_constants\";\nimport { Spatial, uuidv4 } from \"#utils/helpers\";\nimport { TilesHelpers } from \"#components/map/tiles/helpers\";\n\nimport { FireEvents } from \"../helpers\";\n\nexport class PointHelpers {\n static updatePointsData(event: MapLayerMouseEvent) {\n const map = event.target;\n const pointSource = map.getSource(ESOURCES.SinglePointSource) as GeoJSONSource;\n if (pointSource) {\n pointSource.setData({\n type: \"Feature\",\n geometry: {\n type: \"Point\",\n coordinates: [event.lngLat.lng, event.lngLat.lat],\n },\n properties: {},\n });\n }\n }\n\n static setSinglePointVisible(event: MapLayerMouseEvent) {\n const map = event.target;\n map.setLayoutProperty(ELAYERS.SinglePointLayer, \"visibility\", \"visible\");\n }\n\n static setSinglePointHidden(event: MapLayerMouseEvent) {\n const map = event.target;\n setTimeout(() => {\n map.setLayoutProperty(ELAYERS.SinglePointLayer, \"visibility\", \"none\");\n }, 33);\n }\n\n static triggerPostPointAddition(event: MapLayerMouseEvent, props: EventsProps) {\n const { panel, tiles, store, map } = props;\n\n if (Spatial.canCloseGeometry(store)) {\n TilesHelpers.togglePointCircleRadius(map, \"large\");\n }\n panel?.setPanelLocation(event.lngLat);\n tiles.render();\n }\n\n static addPointToMap = (event: MapLayerMouseEvent, props: EventsProps) => {\n const { store, map, mode } = props;\n\n const step = { ...event.lngLat, id: uuidv4() };\n store.push(step);\n FireEvents.addPoint({ ...step, total: store.size }, map, mode);\n this.triggerPostPointAddition(event, props);\n };\n\n static updateSelectedStepLatLng = (event: MapLayerMouseEvent, selectedStep: Step) => {\n selectedStep.lat = event.lngLat.lat;\n selectedStep.lng = event.lngLat.lng;\n };\n}\n","import type { MapLayerMouseEvent } from \"maplibre-gl\";\nimport type { EventsProps, Step } from \"#types/index\";\nimport type { Map } from \"#types/map\";\n\nimport { Store } from \"#store/index\";\nimport { ELAYERS } from \"#utils/geo_constants\";\nimport { MapUtils, Spatial, uuidv4 } from \"#utils/helpers\";\nimport { PointHelpers } from \"../points/helpers\";\n\nexport const isOnLine = (event: MapLayerMouseEvent, store: Store) => {\n let current = store.head;\n const visited = new Set();\n\n while (current !== null) {\n if (visited.has(current)) break;\n if (current.next && current.next.val && current.val) {\n const map = event.target as Map;\n const aPixel = MapUtils.getPixelCoordinates(map, current.val);\n const bPixel = MapUtils.getPixelCoordinates(map, current.next.val);\n const eventPixel = MapUtils.getPixelCoordinates(map, event.lngLat);\n if (Spatial.checkIfPointIsOnLine(aPixel, bPixel, eventPixel)) {\n return current;\n }\n }\n visited.add(current);\n current = current.next;\n }\n return null;\n};\n\nexport const insertStepIfOnLine = (event: MapLayerMouseEvent, store: Store): Step | null => {\n const currentStep = isOnLine(event, store);\n\n if (currentStep) {\n const step = { ...event.lngLat, id: uuidv4() };\n store.insert(step, currentStep);\n return step;\n }\n return null;\n};\n\nexport const updateUIAfterInsert = (event: MapLayerMouseEvent, context: EventsProps) => {\n const { store, tiles, panel } = context;\n if (store.tail?.val) {\n panel?.setPanelLocation(store.tail.val);\n PointHelpers.setSinglePointHidden(event);\n tiles.render();\n }\n};\n\nexport const checkIfPointClicked = (event: MapLayerMouseEvent) => {\n return MapUtils.isFeatureTriggered(event, [ELAYERS.PointsLayer, ELAYERS.FirstPointLayer]);\n};\n","import { GeoJSONSource, MapLayerMouseEvent } from \"maplibre-gl\";\n\nimport { ListNode } from \"#store/index\";\nimport type { EventsProps, Uuid } from \"#types/index\";\nimport { ELAYERS, ESOURCES } from \"#utils/geo_constants\";\nimport { GeometryFactory, Spatial, throttle } from \"#utils/helpers\";\n\nimport { isOnLine } from \"./utils\";\nimport { FireEvents } from \"../helpers\";\n\nconst LINE_BREAK_THROTTLE_TIME = 15;\n\nexport class LineBreakEvents {\n props: EventsProps;\n #current: ListNode | null;\n #throttledOnLineEnter: (event: MapLayerMouseEvent) => void;\n\n constructor(props: EventsProps) {\n this.props = props;\n this.#current = null;\n this.#throttledOnLineEnter = throttle(this.#onLineEnterBreak, LINE_BREAK_THROTTLE_TIME);\n }\n\n initBreakEvents = () => {\n const { map } = this.props;\n\n map.on(\"click\", ELAYERS.LineLayerTransparent, this.#geometryBreakOnClick);\n map.on(\"mouseenter\", ELAYERS.LineLayerTransparent, this.#throttledOnLineEnter);\n map.on(\"mousemove\", ELAYERS.LineLayerTransparent, this.#throttledOnLineEnter);\n map.on(\"mouseleave\", ELAYERS.LineLayerTransparent, this.#onLineLeave);\n };\n\n removeBreakEvents = () => {\n const { map } = this.props;\n\n map.off(\"click\", ELAYERS.LineLayerTransparent, this.#geometryBreakOnClick);\n map.off(\"mouseenter\", ELAYERS.LineLayerTransparent, this.#throttledOnLineEnter);\n map.off(\"mousemove\", ELAYERS.LineLayerTransparent, this.#throttledOnLineEnter);\n map.off(\"mouseleave\", ELAYERS.LineLayerTransparent, this.#onLineLeave);\n };\n\n hideBreakLine = () => {\n const { map } = this.props;\n\n if (map.getLayoutProperty(ELAYERS.LineLayerBreak, \"visibility\") !== \"none\") {\n map.setLayoutProperty(ELAYERS.LineLayerBreak, \"visibility\", \"none\");\n }\n };\n\n showBreakLine = () => {\n const { map } = this.props;\n\n if (map.getLayoutProperty(ELAYERS.LineLayerBreak, \"visibility\") !== \"visible\") {\n map.setLayoutProperty(ELAYERS.LineLayerBreak, \"visibility\", \"visible\");\n }\n };\n\n // TODO\n #geometryBreakOnClick = () => {\n const { store, mode, panel, map, tiles } = this.props;\n\n const nextPointId = this.#current?.next?.val?.id as Uuid;\n Spatial.breakGeometry(store, nextPointId);\n if (store.tail?.val) {\n panel.setPanelLocation({\n lat: store.tail?.val?.lat,\n lng: store.tail?.val?.lng,\n });\n }\n this.#onLineLeave();\n\n map.setLayoutProperty(ELAYERS.PolygonLayer, \"visibility\", \"none\");\n mode.reset();\n tiles.render();\n FireEvents.onLineBreak(map);\n };\n\n // TODO\n #onLineEnterBreak = (event: MapLayerMouseEvent) => {\n const { map, store } = this.props;\n\n const line = isOnLine(event, store);\n if (line?.val?.id !== this.#current?.val?.id) {\n this.#current = line;\n }\n\n const lineSource = map.getSource(ESOURCES.LineSourceBreak) as GeoJSONSource;\n\n const current = [line?.val?.lng, line?.val?.lat] as [number, number];\n const next = [line?.next?.val?.lng, line?.next?.val?.lat] as [number, number];\n const lineBreakData = GeometryFactory.getLine(current, next);\n if (!lineBreakData) return;\n\n lineSource.setData(lineBreakData as any);\n this.showBreakLine();\n };\n\n #onLineLeave = () => {\n setTimeout(() => {\n this.hideBreakLine();\n }, LINE_BREAK_THROTTLE_TIME + 10);\n };\n}\n","import type { MapLayerMouseEvent, PointLike } from \"maplibre-gl\";\n\nimport type { EventsProps, LatLng } from \"#types/index\";\nimport { ELAYERS, ESOURCES, LINE_BASE } from \"#utils/geo_constants\";\nimport { StoreChangeEvent } from \"#store/types\";\nimport { GeometryFactory, MapUtils, Spatial, throttle } from \"#utils/helpers\";\nimport { EVENTS } from \"#utils/constants\";\n\nimport { DrawingModeChangeEvent } from \"../mode/types\";\nimport { MouseEventsChangeEvent } from \"../mouse-events/types\";\nimport { PointDoubleClickEvent, UndoEvent } from \"../types\";\n\nconst LINE_DYNAMIC_THROTTLE_TIME = 10;\n\nexport class DynamicLineEvents {\n #props: EventsProps;\n #visible: boolean;\n #firstPoint: LatLng | null;\n #secondPoint: LatLng | null;\n #lineFeature: any;\n #throttledOnLineMove: (event: MapLayerMouseEvent) => void;\n\n constructor(props: EventsProps) {\n this.#props = props;\n this.#visible = props.options.dynamicLine;\n this.#firstPoint = null;\n this.#secondPoint = null;\n this.#initConsumers();\n this.#throttledOnLineMove = throttle(this.#onLineMove, LINE_DYNAMIC_THROTTLE_TIME);\n }\n\n #initConsumers() {\n this.#props.store.addObserver(this.#storeEventsConsumer);\n this.#props.mode.addObserver(this.#mapModeConsumer);\n this.#props.mouseEvents.addObserver(this.#mouseEventsConsumer);\n }\n\n removeLine = () => {\n this.hideDynamicLine();\n };\n\n removeConsumers = () => {\n this.#props.store.removeObserver(this.#storeEventsConsumer);\n this.#props.mode.removeObserver(this.#mapModeConsumer);\n this.#props.mouseEvents.removeObserver(this.#mouseEventsConsumer);\n };\n\n #mouseEventsConsumer = (event: MouseEventsChangeEvent) => {\n const { mode } = this.#props;\n if (mode.getClosedGeometry()) return;\n\n if (event.type === \"lastPointMouseClick\" && event.data) {\n this.hideDynamicLine();\n this.#visible = false;\n } else if (event.type === \"lastPointMouseClick\" && !event.data) {\n this.#visible = true;\n }\n if (!this.#visible) return;\n // hide the line if a point or a line is hovered\n if ((event.type === \"pointMouseEnter\" || event.type === \"lineMouseEnter\") && event.data) {\n this.hideDynamicLine();\n }\n if ((event.type === \"pointMouseLeave\" || event.type === \"lineMouseLeave\") && event.data) {\n const { store } = this.#props;\n this.#firstPoint = store.tail?.val as LatLng;\n this.#secondPoint = store.tail?.val as LatLng;\n this.showDynamicLine();\n }\n };\n\n #storeEventsConsumer = (event: StoreChangeEvent) => {\n const { store } = this.#props;\n switch (event.type) {\n case \"STORE_CHANGED\":\n if (event.data.tail?.val && !Spatial.isClosedGeometry(store)) {\n this.#firstPoint = event.data.tail?.val;\n this.showDynamicLine();\n }\n break;\n default:\n break;\n }\n };\n\n #mapModeConsumer = (event: DrawingModeChangeEvent) => {\n const { store } = this.#props;\n if (event.type === \"CLOSED_GEOMETRY_CHANGED\") {\n if (event.data) {\n this.hideDynamicLine();\n }\n\n if (!event.data && store?.tail?.val) {\n this.#firstPoint = store?.tail?.val;\n this.showDynamicLine();\n }\n }\n };\n\n initDynamicEvents = () => {\n const { map } = this.#props;\n\n map.on(\"click\", this.#onMapClick);\n map.on(\"mousemove\", this.#throttledOnLineMove);\n map.on(EVENTS.REMOVEALL, this.hideDynamicLine);\n map.on(EVENTS.UNDO, this.#onUndoClick);\n map.on(EVENTS.DOUBLECLICK, this.#onDoubleClick);\n };\n\n removeEvents = () => {\n const { map } = this.#props;\n\n map.off(\"click\", this.#onMapClick);\n map.off(\"mousemove\", this.#throttledOnLineMove);\n map.off(EVENTS.REMOVEALL, this.hideDynamicLine);\n map.off(EVENTS.UNDO, this.#onUndoClick);\n map.off(EVENTS.DOUBLECLICK, this.#onDoubleClick);\n };\n\n hideDynamicLine = () => {\n const { map, tiles } = this.#props;\n\n this.#firstPoint = null;\n this.#secondPoint = null;\n this.#lineFeature = null;\n map.off(\"mousemove\", this.#throttledOnLineMove);\n tiles.renderLines(LINE_BASE, ESOURCES.LineDynamicSource);\n map.setLayoutProperty(ELAYERS.LineDynamicLayer, \"visibility\", \"none\");\n };\n\n showDynamicLine = () => {\n const { map } = this.#props;\n\n const current = [this.#firstPoint?.lng, this.#firstPoint?.lat] as [number, number];\n const next = [this.#secondPoint?.lng, this.#secondPoint?.lat] as [number, number];\n\n this.#lineFeature = GeometryFactory.getLine(current, next);\n\n map.setLayoutProperty(ELAYERS.LineDynamicLayer, \"visibility\", \"visible\");\n if (this.#secondPoint) {\n this.#renderLineOnMouseMove({ lng: this.#secondPoint?.lng, lat: this.#secondPoint?.lat });\n }\n map.on(\"mousemove\", this.#throttledOnLineMove);\n };\n\n #renderLineOnMouseMove = (newCoord: LatLng) => {\n if (!this.#lineFeature) return;\n\n const { tiles } = this.#props;\n this.#lineFeature.features[0].geometry.coordinates[1] = [newCoord.lng, newCoord.lat];\n\n tiles.renderLines(this.#lineFeature, ESOURCES.LineDynamicSource);\n };\n\n #onLineMove = (event: MapLayerMouseEvent) => {\n this.#renderLineOnMouseMove(event.lngLat);\n };\n\n #onMapClick = (event: MapLayerMouseEvent) => {\n const { mode } = this.#props;\n const lineClick = MapUtils.isFeatureTriggered(event, [ELAYERS.LineLayerTransparent, ELAYERS.LineLayer]);\n if (lineClick && mode.getBreak()) {\n this.#secondPoint = { lng: event.lngLat.lng, lat: event.lngLat.lat };\n }\n\n if (lineClick) return;\n\n this.hideDynamicLine();\n };\n\n #onUndoClick = (event: UndoEvent) => {\n const { store, mode } = this.#props;\n if (!mode.getClosedGeometry()) {\n const latLng = event.target.unproject({ x: event.originalEvent.x, y: event.originalEvent.y } as PointLike);\n this.#secondPoint = { lng: latLng.lng, lat: latLng.lat };\n this.#firstPoint = store.tail?.val as LatLng;\n this.showDynamicLine();\n }\n };\n\n #onDoubleClick = (event: PointDoubleClickEvent) => {\n const { store, mode } = this.#props;\n if (!mode.getClosedGeometry()) {\n this.#secondPoint = { lng: event.coordinates.lng, lat: event.coordinates.lat };\n this.#firstPoint = store.tail?.val as LatLng;\n this.showDynamicLine();\n }\n };\n}\n","import type { MapLayerMouseEvent } from \"maplibre-gl\";\n\nimport type { EventsProps } from \"#types/index\";\nimport { ELAYERS } from \"#utils/geo_constants\";\nimport { MapUtils, throttle } from \"#utils/helpers\";\nimport { FireEvents } from \"../helpers\";\nimport { PointHelpers } from \"../points/helpers\";\nimport { checkIfPointClicked, insertStepIfOnLine, updateUIAfterInsert } from \"./utils\";\n\nexport const LINE_TRANSPARENT_THROTTLE_TIME = 22;\n\nexport class TransparentLineEvents {\n props: EventsProps;\n #isThrottled: boolean;\n #lastEvent: MapLayerMouseEvent | null;\n\n constructor(props: EventsProps) {\n this.props = props;\n this.#isThrottled = false;\n this.#lastEvent = null;\n }\n\n initEvents() {\n const { map } = this.props;\n\n map.on(\"click\", ELAYERS.LineLayerTransparent, this.#onLineAdd);\n map.on(\"mousemove\", ELAYERS.LineLayerTransparent, this.#onLineMove);\n map.on(\"mouseenter\", ELAYERS.LineLayerTransparent, this.#onLineEnter);\n map.on(\"mouseleave\", ELAYERS.LineLayerTransparent, this.#onLineLeave);\n }\n\n removeEvents() {\n const { map } = this.props;\n map.off(\"click\", ELAYERS.LineLayerTransparent, this.#onLineAdd);\n map.off(\"mousemove\", ELAYERS.LineLayerTransparent, this.#onLineMove);\n map.off(\"mouseenter\", ELAYERS.LineLayerTransparent, this.#onLineEnter);\n map.off(\"mouseleave\", ELAYERS.LineLayerTransparent, this.#onLineLeave);\n }\n\n #onLineAdd = (event: MapLayerMouseEvent) => {\n const { store, map, mode } = this.props;\n if (checkIfPointClicked(event)) return;\n const step = insertStepIfOnLine(event, store);\n if (step) {\n FireEvents.addPoint({ ...step, total: store.size }, map, mode);\n updateUIAfterInsert(event, this.props);\n }\n };\n\n #processMouseMove = (event: MapLayerMouseEvent) => {\n PointHelpers.setSinglePointVisible(event);\n if (event.target.getLayer(ELAYERS.SinglePointLayer)) {\n PointHelpers.updatePointsData(event);\n }\n };\n\n // TODO\n #onLineMove = throttle((event: MapLayerMouseEvent) => {\n if (MapUtils.isFeatureTriggered(event, [ELAYERS.PointsLayer, ELAYERS.FirstPointLayer])) return;\n\n const { mouseEvents } = this.props;\n if (mouseEvents.pointMouseDown || mouseEvents.pointMouseEnter) return;\n\n this.#lastEvent = event;\n\n if (this.#isThrottled) return;\n\n this.#isThrottled = true;\n requestAnimationFrame(() => {\n if (!this.#lastEvent) return;\n this.#processMouseMove(this.#lastEvent);\n this.#isThrottled = false;\n });\n }, LINE_TRANSPARENT_THROTTLE_TIME);\n\n #onLineEnter = (event: MapLayerMouseEvent) => {\n const { mouseEvents } = this.props;\n if (mouseEvents.pointMouseDown || mouseEvents.pointMouseEnter) return;\n if (MapUtils.isFeatureTriggered(event, [ELAYERS.PointsLayer, ELAYERS.FirstPointLayer])) return;\n\n mouseEvents.lineMouseEnter = true;\n PointHelpers.setSinglePointVisible(event);\n };\n\n #onLineLeave = (event: MapLayerMouseEvent) => {\n const { mouseEvents } = this.props;\n if (mouseEvents.pointMouseDown || mouseEvents.pointMouseEnter) return;\n\n mouseEvents.lineMouseLeave = true;\n PointHelpers.setSinglePointHidden(event);\n };\n}\n","import type { EventsProps } from \"#types/index\";\nimport { DrawingModeChangeEvent } from \"../mode/types\";\nimport { MouseEventsChangeEvent } from \"../mouse-events/types\";\nimport { LineBreakEvents } from \"./break-line\";\nimport { DynamicLineEvents } from \"./dynamic-line\";\nimport { TransparentLineEvents } from \"./transparent-line\";\n\nexport class LineEvents {\n props: EventsProps;\n #break: LineBreakEvents;\n #transparent: TransparentLineEvents;\n #dynamic: DynamicLineEvents | null;\n #type: \"default\" | \"break\";\n\n constructor(props: EventsProps) {\n this.props = props;\n this.#break = new LineBreakEvents(props);\n this.#transparent = new TransparentLineEvents(props);\n this.#dynamic = null;\n this.#type = \"default\";\n }\n\n init() {\n this.#initDynamicLine();\n this.#initEvents();\n this.#initConsumers();\n }\n\n #initDynamicLine = () => {\n if (window.innerWidth <= 768) return;\n if (this.props.options.dynamicLine) {\n this.#dynamic = new DynamicLineEvents(this.props);\n }\n };\n\n #initEvents() {\n const notBreakMode = !this.props.mode.getBreak();\n if (notBreakMode) {\n this.#transparent.initEvents();\n if (this.props.options.dynamicLine) {\n this.#dynamic?.initDynamicEvents();\n }\n }\n }\n\n #initConsumers() {\n this.props.mode.addObserver(this.#mapModeConsumer);\n this.props.mouseEvents.addObserver(this.#mouseEventsConsumer);\n }\n\n remove() {\n this.#removeConsumers();\n this.#removeEvents();\n }\n\n #removeConsumers() {\n this.props.mode.removeObserver(this.#mapModeConsumer);\n this.props.mouseEvents.removeObserver(this.#mouseEventsConsumer);\n if (this.props.options.dynamicLine) {\n this.#dynamic?.removeConsumers();\n }\n }\n\n #removeEvents() {\n this.#break.removeBreakEvents();\n this.#transparent.removeEvents();\n if (this.props.options.dynamicLine) {\n this.#dynamic?.removeEvents();\n this.#dynamic?.removeLine();\n }\n }\n\n #mouseEventsConsumer = (event: MouseEventsChangeEvent) => {\n const { type, data } = event;\n const { mode } = this.props;\n if (!data || !mode.getBreak()) return;\n\n switch (type) {\n case \"pointMouseDown\":\n this.#break.removeBreakEvents();\n this.#break.hideBreakLine();\n break;\n case \"pointMouseUp\":\n this.#break.initBreakEvents();\n break;\n default:\n break;\n }\n };\n\n #mapModeConsumer = (event: DrawingModeChangeEvent) => {\n const { type, data } = event;\n\n if (type === \"MODE_CHANGED\") {\n if (this.#type === \"break\") {\n this.#break.removeBreakEvents();\n this.#transparent.initEvents();\n this.#type = \"default\";\n }\n }\n\n if (type === \"BREAK_CHANGED\" && data) {\n if (this.#type === \"default\") {\n this.#transparent.removeEvents();\n this.#break.initBreakEvents();\n this.#type = \"break\";\n }\n }\n };\n}\n","import type { MapLayerMouseEvent } from \"maplibre-gl\";\nimport type { EventsProps } from \"#types/index\";\n\nimport { uuidv4, Spatial } from \"#utils/helpers\";\nimport { ELAYERS } from \"#utils/geo_constants\";\nimport { Tooltip } from \"#components/tooltip\";\nimport { TilesHelpers } from \"#components/map/tiles/helpers\";\n\nimport { FireEvents } from \"../helpers\";\nimport { DrawingModeChangeEvent } from \"../mode/types\";\n\nexport class FirstPoint {\n #mouseDown: boolean;\n #props: EventsProps;\n #tooltip: Tooltip;\n\n constructor(props: EventsProps) {\n this.#props = props;\n this.#mouseDown = false;\n this.#tooltip = new Tooltip();\n props.mode.addObserver(this.#mapModeConsumer);\n }\n\n initEvents() {\n const { map } = this.#props;\n\n map.on(\"click\", ELAYERS.FirstPointLayer, this.#onFirstPointClick);\n map.on(\"mouseenter\", ELAYERS.FirstPointLayer, this.#onFirstPointMouseEnter);\n map.on(\"mouseleave\", ELAYERS.FirstPointLayer, this.#onFirstPointMouseLeave);\n map.on(\"mouseup\", ELAYERS.FirstPointLayer, this.#onFirstPointMouseUp);\n map.on(\"mousedown\", ELAYERS.FirstPointLayer, this.#onFirstPointMouseDown);\n }\n\n removeEvents() {\n const { map } = this.#props;\n\n map.off(\"click\", ELAYERS.FirstPointLayer, this.#onFirstPointClick);\n map.off(\"mouseenter\", ELAYERS.FirstPointLayer, this.#onFirstPointMouseEnter);\n map.off(\"mouseleave\", ELAYERS.FirstPointLayer, this.#onFirstPointMouseLeave);\n map.off(\"mouseup\", ELAYERS.FirstPointLayer, this.#onFirstPointMouseUp);\n }\n\n #mapModeConsumer = (event: DrawingModeChangeEvent) => {\n const { map, store } = this.#props;\n const { type, data } = event;\n\n if (type === \"MODE_CHANGED\") {\n if (data === \"line\" || data === \"polygon\") {\n map.on(\"click\", ELAYERS.FirstPointLayer, this.#onFirstPointClick);\n } else {\n map.off(\"click\", ELAYERS.FirstPointLayer, this.#onFirstPointClick);\n }\n if (Spatial.canCloseGeometry(store)) {\n TilesHelpers.togglePointCircleRadius(map, \"large\");\n }\n }\n };\n\n #onFirstPointClick = () => {\n const { store, map, mode, tiles } = this.#props;\n\n if (mode.getMode() === \"polygon\") {\n map.setLayoutProperty(ELAYERS.PolygonLayer, \"visibility\", \"visible\");\n }\n\n if (Spatial.canCloseGeometry(store)) {\n Spatial.closeGeometry(store, mode);\n const step = Object.assign({}, store.head?.val, {\n id: uuidv4(),\n total: store.size,\n });\n FireEvents.addPoint(step, map, mode);\n TilesHelpers.togglePointCircleRadius(map, \"default\");\n tiles.render();\n }\n };\n\n #onFirstPointMouseDown = () => {\n this.#mouseDown = true;\n this.#tooltip.remove();\n };\n\n #onFirstPointMouseUp = () => {\n this.#mouseDown = false;\n };\n\n #onFirstPointMouseLeave = () => {\n const { mouseEvents } = this.#props;\n\n if (this.#mouseDown) return;\n\n mouseEvents.firstPointMouseLeave = true;\n this.#tooltip.remove();\n };\n\n #getTitle = () => {\n const { mode, options } = this.#props;\n\n if (mode.getMode() === \"line\" && options.modes.line.closeGeometry) {\n return options.locale.closeLine;\n }\n\n if (mode.getMode() === \"polygon\") {\n return options.locale.createPolygon;\n }\n\n return \"\";\n };\n\n #onFirstPointMouseEnter = (event: MapLayerMouseEvent) => {\n const { mode, mouseEvents, store } = this.#props;\n if (mode.getClosedGeometry() || this.#mouseDown) return;\n mouseEvents.firstPointMouseEnter = true;\n if (Spatial.canCloseGeometry(store)) {\n const { x, y } = event.originalEvent;\n if (x && y) {\n const Y_OFFSET = 14;\n\n this.#tooltip.create({ label: this.#getTitle(), placement: \"bottom\" });\n\n const X_OFFSET = this.#tooltip._label ? this.#tooltip._label.clientWidth / 2 : 0;\n this.#tooltip.setPosition({ x: x - X_OFFSET, y: y + Y_OFFSET });\n }\n }\n };\n}\n","import { TilesHelpers } from \"#components/map/tiles/helpers\";\nimport type { MapLayerMouseEvent, MapTouchEvent } from \"maplibre-gl\";\nimport type { EventsProps, LatLng, Step } from \"#types/index\";\n\nimport { MapUtils, Spatial, throttle } from \"#utils/helpers\";\nimport { ELAYERS } from \"#utils/geo_constants\";\nimport { StoreHelpers } from \"#store/index\";\n\nimport { FireEvents } from \"../helpers\";\nimport { PointHelpers } from \"./helpers\";\nimport { FirstPoint } from \"./first-point\";\n\nexport class PointEvents {\n #props: EventsProps;\n #startCoordinates: LatLng | undefined;\n #enteredStep: Step | null;\n #selectedStep: Step | null;\n #selectedIdx: number | null;\n #firstPoint: FirstPoint;\n #isThrottled: boolean;\n #lastEvent: MapLayerMouseEvent | null;\n\n constructor(props: EventsProps) {\n this.#props = props;\n this.#startCoordinates = undefined;\n this.#enteredStep = null;\n this.#selectedStep = null;\n this.#selectedIdx = null;\n this.#firstPoint = new FirstPoint(props);\n this.#isThrottled = false;\n this.#lastEvent = null;\n }\n\n #initFirstPointEvents = () => {\n const { map } = this.#props;\n\n map.on(\"click\", ELAYERS.FirstPointLayer, this.#onPointClick);\n map.on(\"mouseenter\", ELAYERS.FirstPointLayer, this.#onPointMouseEnter);\n map.on(\"mouseleave\", ELAYERS.FirstPointLayer, this.#onPointMouseLeave);\n map.on(\"mousedown\", ELAYERS.FirstPointLayer, this.#onPointMouseDown);\n map.on(\"mouseup\", ELAYERS.FirstPointLayer, this.#onPointMouseUp);\n map.on(\"touchend\", ELAYERS.FirstPointLayer, this.#onPointMouseUp);\n map.on(\"touchstart\", ELAYERS.FirstPointLayer, this.#onPointMouseDown);\n\n this.#firstPoint.initEvents();\n };\n\n initEvents = () => {\n const { map } = this.#props;\n map.on(\"click\", this.#onMapClick);\n map.on(\"dblclick\", this.#onMapDblClick);\n\n map.on(\"click\", ELAYERS.PointsLayer, this.#onPointClick);\n map.on(\"mouseenter\", ELAYERS.PointsLayer, this.#onPointMouseEnter);\n map.on(\"mouseleave\", ELAYERS.PointsLayer, this.#onPointMouseLeave);\n map.on(\"mousedown\", ELAYERS.PointsLayer, this.#onPointMouseDown);\n map.on(\"mouseup\", ELAYERS.PointsLayer, this.#onPointMouseUp);\n map.on(\"touchend\", ELAYERS.PointsLayer, this.#onPointMouseUp);\n map.on(\"touchstart\", ELAYERS.PointsLayer, this.#onPointMouseDown);\n\n this.#initFirstPointEvents();\n };\n\n #removeFirstPointEvents = () => {\n const { map } = this.#props;\n\n map.off(\"click\", ELAYERS.FirstPointLayer, this.#onPointClick);\n map.off(\"mouseenter\", ELAYERS.FirstPointLayer, this.#onPointMouseEnter);\n map.off(\"mouseleave\", ELAYERS.FirstPointLayer, this.#onPointMouseLeave);\n map.off(\"mousedown\", ELAYERS.FirstPointLayer, this.#onPointMouseDown);\n map.off(\"mouseup\", ELAYERS.FirstPointLayer, this.#onPointMouseUp);\n map.off(\"touchend\", ELAYERS.PointsLayer, this.#onPointMouseUp);\n map.off(\"touchstart\", ELAYERS.PointsLayer, this.#onPointMouseDown);\n this.#firstPoint.removeEvents();\n };\n\n removeEvents = () => {\n const { map } = this.#props;\n map.off(\"click\", this.#onMapClick);\n map.off(\"dblclick\", this.#onMapDblClick);\n map.off(\"mousemove\", this.#onMapMouseMove);\n\n map.off(\"click\", ELAYERS.PointsLayer, this.#onPointClick);\n map.off(\"mouseenter\", ELAYERS.PointsLayer, this.#onPointMouseEnter);\n map.off(\"mouseleave\", ELAYERS.PointsLayer, this.#onPointMouseLeave);\n map.off(\"mousedown\", ELAYERS.PointsLayer, this.#onPointMouseDown);\n map.off(\"mouseup\", ELAYERS.PointsLayer, this.#onPointMouseUp);\n\n this.#removeFirstPointEvents();\n };\n\n #onMapDblClick = (event: MapLayerMouseEvent) => {\n event.preventDefault();\n };\n\n #onPointClick = (event: MapLayerMouseEvent) => {\n const { store, tiles, panel, map, mouseEvents } = this.#props;\n\n // not using dblclick event because it's not working properly(fires if we add point and then move it fast)\n if (TilesHelpers.isDoubleClick() && this.#selectedStep) {\n store.removeStepById(this.#selectedStep.id);\n panel.onPointRemove(store.tail?.val as Step);\n FireEvents.pointDoubleClick({ ...this.#selectedStep, total: store.size }, this.#props.map);\n Spatial.switchToLineModeIfCan(this.#props);\n }\n\n const id = MapUtils.queryPointId(map, event.point);\n if (StoreHelpers.isLastPoint(store, id)) {\n mouseEvents.lastPointMouseClick = true;\n mouseEvents.lastPointMouseUp = false;\n }\n\n tiles.render();\n };\n\n #onOwnGeometryLayersClick = (event: MapLayerMouseEvent) => {\n return MapUtils.isFeatureTriggered(event, [\n ELAYERS.PointsLayer,\n ELAYERS.FirstPointLayer,\n ELAYERS.LineLayerTransparent,\n ELAYERS.LineLayerBreak,\n ]);\n };\n\n #onMapClick = (event: MapLayerMouseEvent) => {\n const { mode, mouseEvents, map } = this.#props;\n\n if (mode.getClosedGeometry()) return;\n if (this.#onOwnGeometryLayersClick(event)) return;\n if (mouseEvents.lastPointMouseClick) {\n mouseEvents.lastPointMouseClick = false;\n }\n map.getCanvasContainer().style.cursor = \"grab\";\n PointHelpers.addPointToMap(event, this.#props);\n PointHelpers.setSinglePointHidden(event);\n };\n\n #onMoveLeftClickUp = (event: MapLayerMouseEvent) => {\n const mouseLeftClickUp = event.originalEvent.buttons === 0;\n if (mouseLeftClickUp) {\n this.#onPointMouseUp();\n }\n };\n\n #processMouseMove = (event: MapLayerMouseEvent) => {\n const { tiles } = this.#props;\n tiles.renderOnMouseMove(this.#selectedIdx as number, event.lngLat);\n };\n\n #onMapMouseMove = throttle((event: MapLayerMouseEvent) => {\n this.#lastEvent = event;\n\n if (!this.#isThrottled) {\n this.#isThrottled = true;\n\n requestAnimationFrame(() => {\n if (!this.#selectedStep || !this.#lastEvent) return;\n PointHelpers.updateSelectedStepLatLng(this.#lastEvent, this.#selectedStep);\n this.#onMoveLeftClickUp(this.#lastEvent);\n this.#processMouseMove(this.#lastEvent);\n this.#isThrottled = false;\n });\n }\n }, 15);\n\n #onPointMouseEnter = (event: MapLayerMouseEvent) => {\n const { mouseEvents, map, store } = this.#props;\n if (mouseEvents) {\n mouseEvents.pointMouseEnter = true;\n if (mouseEvents.pointMouseDown) return;\n }\n PointHelpers.setSinglePointHidden(event);\n const id = MapUtils.queryPointId(map, event.point);\n if (StoreHelpers.isLastPoint(store, id)) {\n mouseEvents.lastPointMouseEnter = true;\n mouseEvents.lastPointMouseLeave = false;\n }\n const step = store.findStepById(id);\n if (step) {\n this.#enteredStep = step;\n FireEvents.enterPoint(Object.assign({}, step, { total: store.size }), map);\n }\n };\n\n #onPointMouseLeave = (event: MapLayerMouseEvent) => {\n const { mouseEvents, store, map } = this.#props;\n\n if (mouseEvents) {\n mouseEvents.pointMouseEnter = false;\n if (event.originalEvent.buttons === 0) {\n mouseEvents.pointMouseLeave = true;\n }\n if (mouseEvents.pointMouseDown) return;\n }\n const id = MapUtils.queryPointId(map, event.point);\n if (StoreHelpers.isLastPoint(store, id)) {\n mouseEvents.lastPointMouseEnter = false;\n mouseEvents.lastPointMouseLeave = true;\n }\n FireEvents.leavePoint(\n Object.assign({}, this.#enteredStep, {\n total: store.size,\n }),\n map,\n );\n };\n\n #hideLastPointPanel = () => {\n const { store, panel } = this.#props;\n if (!this.#selectedStep) return;\n\n if (StoreHelpers.isLastPoint(store, this.#selectedStep.id)) {\n panel.hidePanel();\n }\n };\n\n #setSelectedStep = (event: MapLayerMouseEvent | MapTouchEvent) => {\n const { store, map } = this.#props;\n\n const id = MapUtils.queryPointId(map, event.point);\n const step = store.findStepById(id);\n if (step) {\n this.#selectedStep = step;\n }\n };\n\n #onPointMouseDown = (event: MapLayerMouseEvent | MapTouchEvent) => {\n event.preventDefault();\n\n const { mouseEvents, map, store } = this.#props;\n TilesHelpers.removeTransparentLine(map);\n this.#setSelectedStep(event);\n this.#hideLastPointPanel();\n const id = MapUtils.queryPointId(map, event.point);\n this.#selectedIdx = Spatial.getGeometryIndex(store, id);\n if (mouseEvents) {\n mouseEvents.pointMouseDown = true;\n }\n this.#startCoordinates = event.lngLat;\n map.on(\"mousemove\", this.#onMapMouseMove);\n map.on(\"touchmove\", this.#onMapMouseMove);\n };\n\n #onPointMouseUp = () => {\n const { mouseEvents, store, panel, map, options } = this.#props;\n mouseEvents.pointMouseUp = true;\n if (this.#selectedStep) {\n if (StoreHelpers.isLastPoint(store, this.#selectedStep.id) && store.tail?.val) {\n // mouseEvents.lastPointMouseClick = false;\n // mouseEvents.lastPointMouseUp = true;\n panel?.setPanelLocation(store.tail.val);\n }\n panel?.showPanel();\n\n FireEvents.movePoint(\n {\n id: this.#selectedStep.id,\n total: store.size,\n end: { lat: this.#selectedStep.lat, lng: this.#selectedStep.lng },\n start: this.#startCoordinates as LatLng,\n },\n map,\n );\n }\n if (mouseEvents) {\n mouseEvents.pointMouseDown = false;\n }\n TilesHelpers.addTransparentLine(map, options);\n // if the event.originalEvent.buttons === 0 in mousemove didn't work, let's try on mouse up\n // but this is a fail safe, it should work on event.originalEvent.buttons\n map.off(\"mousemove\", this.#onMapMouseMove);\n map.off(\"touchmove\", this.#onMapMouseMove);\n };\n}\n","import type { EventsProps } from \"#types/index\";\nimport { Tiles } from \"#components/map/tiles\";\nimport { ControlEvents } from \"#components/side-control/events\";\nimport { PanelEvents } from \"#components/last-point-panel/events\";\nimport { LineEvents } from \"./line\";\nimport { PointEvents } from \"./points\";\n\nexport class Events extends Tiles {\n #props: EventsProps;\n #panelEvents: PanelEvents;\n #controlEvents: ControlEvents;\n #pointEvents: PointEvents;\n #lineEvents: LineEvents;\n\n constructor(props: EventsProps) {\n super({ ...props });\n this.#props = props;\n this.#panelEvents = new PanelEvents(props);\n this.#controlEvents = new ControlEvents(props);\n this.#pointEvents = new PointEvents(props);\n this.#lineEvents = new LineEvents(props);\n props.map.on(\"mode:initialize\", this.#initEvents);\n props.map.on(\"mode:remove\", this.#removeDrawEvents);\n }\n\n #initEvents = () => {\n this.#lineEvents.init();\n this.#panelEvents?.initEvents();\n this.#pointEvents?.initEvents();\n };\n\n #removeDrawEvents = () => {\n this.#panelEvents?.removeEvents();\n this.#pointEvents?.removeEvents();\n this.#lineEvents?.remove();\n };\n\n removeMapEventsAndConsumers = () => {\n this.#panelEvents?.removeEvents();\n this.#pointEvents?.removeEvents();\n this.#controlEvents?.remove();\n this.#lineEvents?.remove();\n this.#props.map.off(\"mode:initialize\", this.#initEvents);\n };\n}\n","import type { RequiredDrawOptions } from \"#types/index\";\nimport { DOM } from \"#utils/dom\";\nimport { DrawingMode } from \"#components/map/mode\";\nimport \"./control.css\";\n\ninterface ControlProps {\n options: RequiredDrawOptions;\n mode: DrawingMode;\n}\n\nexport class Control {\n #defaultOptions: RequiredDrawOptions;\n _line: HTMLButtonElement | undefined;\n _polygon: HTMLButtonElement | undefined;\n _break: HTMLButtonElement | undefined;\n _container: HTMLElement;\n constructor(props: ControlProps) {\n this.#defaultOptions = props.options;\n this._line = undefined;\n this._polygon = undefined;\n this._break = undefined;\n this._container = DOM.create(\"div\", \"mapboxgl-ctrl mapboxgl-ctrl-group maplibregl-ctrl maplibregl-ctrl-group\");\n this.createControl(props);\n }\n\n createControlButton = (\n type: \"line\" | \"polygon\" | \"break\",\n title: string,\n active: boolean,\n disabled?: boolean,\n ): HTMLButtonElement => {\n const size = this.#defaultOptions.panel.size;\n const button = DOM.create(\"button\", `control-button control-button-${size}`, this._container);\n button.setAttribute(\"aria-label\", title);\n button.setAttribute(\"data-type\", type);\n if (active) {\n button.classList.add(\"control-button-active\");\n }\n if (disabled) {\n button.setAttribute(\"disabled\", \"true\");\n button.setAttribute(\"aria-disabled\", \"true\");\n }\n DOM.create(\"span\", `icon ${type} icon-${size}`, button);\n return button;\n };\n\n #createLineButton = (context: ControlProps) => {\n const { mode, options } = context;\n const lineVisible = this.#defaultOptions.modes.line.visible;\n const lineTitle = options.locale.line;\n if (lineVisible) {\n this._line = this.createControlButton(\"line\", lineTitle, mode.getMode() === \"line\");\n }\n };\n\n #createPolygonButton = (context: ControlProps) => {\n const { mode, options } = context;\n\n const polygonVisible = this.#defaultOptions.modes.polygon.visible;\n const polygonTitle = options.locale.polygon;\n if (polygonVisible) {\n this._polygon = this.createControlButton(\"polygon\", polygonTitle, mode.getMode() === \"polygon\");\n }\n };\n\n #createBreakButton = (context: ControlProps) => {\n const { mode, options } = context;\n\n const breakVisible = this.#defaultOptions.modes.breakGeometry.visible;\n const breakTitle = options.locale.break;\n if (breakVisible) {\n const closedGeometry = this.#defaultOptions?.initial?.closeGeometry;\n const disabled = !closedGeometry;\n const isBreak = mode.getBreak();\n this._break = this.createControlButton(\"break\", breakTitle, isBreak, disabled);\n }\n };\n\n createControl = (context: ControlProps) => {\n this.#createLineButton(context);\n this.#createPolygonButton(context);\n this.#createBreakButton(context);\n };\n\n getContainer = () => {\n return this._container;\n };\n}\n","import type { RequiredDrawOptions } from \"#types/index\";\nimport { Observable } from \"#utils/observable\";\n\nimport type { DrawingModeChangeEvent, Mode } from \"./types\";\n\nfunction getInitialMode(options: RequiredDrawOptions): Mode {\n if (options.initial?.geometry) {\n return options.initial?.geometry;\n }\n\n if (options.modes.initial) {\n return options.modes.initial;\n }\n\n return null;\n}\n\nexport class DrawingMode extends Observable<DrawingModeChangeEvent> {\n #mode: Mode;\n #break: boolean;\n #closedGeometry: boolean;\n\n constructor(options: RequiredDrawOptions) {\n super();\n this.#mode = getInitialMode(options);\n this.#break = false;\n this.#closedGeometry = options.initial?.closeGeometry ?? false;\n }\n\n getMode = (): Mode => {\n return this.#mode;\n };\n\n setMode = (newMode: Mode) => {\n this.#mode = newMode;\n this.setBreak(false);\n this.notify({\n type: \"MODE_CHANGED\",\n data: newMode,\n });\n };\n\n getBreak = (): boolean => {\n return this.#break;\n };\n\n setBreak = (value: boolean) => {\n this.#break = value;\n this.notify({\n type: \"BREAK_CHANGED\",\n data: value,\n });\n };\n\n getClosedGeometry = (): boolean => {\n return this.#closedGeometry;\n };\n\n setClosedGeometry = (value: boolean) => {\n this.#closedGeometry = value;\n this.notify({\n type: \"CLOSED_GEOMETRY_CHANGED\",\n data: this.#closedGeometry,\n });\n };\n\n isPolygon = () => {\n return this.#mode === \"polygon\" && this.#closedGeometry;\n };\n\n reset = () => {\n this.setMode(this.getMode());\n this.setClosedGeometry(false);\n };\n\n pingConsumers = () => {\n this.notify({\n type: \"MODE_CHANGED\",\n data: this.getMode(),\n });\n this.notify({\n type: \"CLOSED_GEOMETRY_CHANGED\",\n data: this.getClosedGeometry(),\n });\n };\n}\n","import type { Map } from \"#types/map\";\n\nimport { Spatial } from \"#utils/helpers\";\nimport { DrawingMode } from \"#components/map/mode\";\nimport { Store } from \"#store/index\";\n\nimport { MouseEvents } from \"../mouse-events\";\nimport { MouseEventsChangeEvent } from \"../mouse-events/types\";\nimport { CURSORS, TCursor } from \"./constants\";\n\ninterface CursorProps {\n map: Map;\n mode: DrawingMode;\n mouseEvents: MouseEvents;\n store: Store;\n}\n\nexport class Cursor {\n #props: CursorProps;\n #canvas: HTMLElement;\n\n // map: Map, mode: DrawingMode, mouseEvents: MouseEvents, store: Store\n constructor(props: CursorProps) {\n this.#props = props;\n this.#canvas = this.#props.map.getCanvasContainer();\n this.#canvas.style.cursor = props.mode.getMode() ? CURSORS.CROSSHAIR : CURSORS.AUTO;\n this.#initConsumers();\n }\n\n set = (cursor: TCursor) => {\n this.#canvas.style.cursor = cursor;\n };\n\n get = () => this.#canvas.style.cursor;\n\n handleMouseLeave = () => {\n const { mouseEvents, mode } = this.#props;\n if (mouseEvents.pointMouseDown) return;\n if (!mode.getMode()) {\n this.set(CURSORS.AUTO);\n return;\n }\n if (mode.getClosedGeometry()) {\n this.set(CURSORS.AUTO);\n } else {\n this.set(CURSORS.CROSSHAIR);\n }\n };\n\n handleFirstPointMouseEnter = () => {\n const { mode, store } = this.#props;\n\n if (mode.getClosedGeometry()) {\n this.set(CURSORS.MOVE);\n }\n if (Spatial.canCloseGeometry(store)) {\n this.set(CURSORS.POINTER);\n }\n };\n\n #initConsumers() {\n const { mouseEvents } = this.#props;\n\n mouseEvents.addObserver(this.#mouseEventsObserver);\n }\n\n removeConsumers() {\n const { mouseEvents } = this.#props;\n\n mouseEvents.removeObserver(this.#mouseEventsObserver);\n }\n\n #mouseEventsObserver = (event: MouseEventsChangeEvent) => {\n const { mode, mouseEvents } = this.#props;\n if (mode.getBreak()) return;\n\n const { type, data } = event;\n\n if (!data) return;\n\n switch (type) {\n case \"pointMouseDown\":\n this.set(CURSORS.GRABBING);\n break;\n case \"pointMouseUp\":\n this.set(CURSORS.GRAB);\n break;\n case \"pointMouseEnter\":\n if (mouseEvents.pointMouseDown) return;\n this.set(CURSORS.GRAB);\n break;\n case \"pointMouseLeave\":\n this.handleMouseLeave();\n break;\n case \"lineMouseEnter\":\n if (mouseEvents.pointMouseDown) return;\n this.set(CURSORS.POINTER);\n break;\n case \"lineMouseLeave\":\n this.handleMouseLeave();\n break;\n case \"firstPointMouseEnter\":\n this.handleFirstPointMouseEnter();\n break;\n case \"firstPointMouseLeave\":\n this.handleMouseLeave();\n break;\n case \"lastPointMouseEnter\":\n this.set(CURSORS.POINTER);\n break;\n case \"lastPointMouseLeave\":\n this.handleMouseLeave();\n break;\n default:\n break;\n }\n };\n}\n","import { Observable } from \"#utils/observable\";\nimport { MouseEventsChangeEvent } from \"./types\";\n\nexport class MouseEvents extends Observable<MouseEventsChangeEvent> {\n #firstPointMouseEnter: boolean;\n #firstPointMouseLeave: boolean;\n #lastPointMouseClick: boolean;\n #lastPointMouseUp: boolean;\n #lastPointMouseEnter: boolean;\n #lastPointMouseLeave: boolean;\n #pointMouseDown: boolean;\n #pointMouseUp: boolean;\n #pointMouseEnter: boolean;\n #pointMouseLeave: boolean;\n #lineMouseEnter: boolean;\n #lineMouseLeave: boolean;\n\n constructor() {\n super();\n this.#firstPointMouseEnter = false;\n this.#firstPointMouseLeave = false;\n this.#lastPointMouseClick = false;\n this.#lastPointMouseUp = false;\n this.#lastPointMouseEnter = false;\n this.#lastPointMouseLeave = false;\n this.#pointMouseDown = false;\n this.#pointMouseUp = false;\n this.#pointMouseEnter = false;\n this.#pointMouseLeave = false;\n this.#lineMouseEnter = false;\n this.#lineMouseLeave = false;\n }\n\n get firstPointMouseEnter() {\n return this.#firstPointMouseEnter;\n }\n set firstPointMouseEnter(value) {\n this.#firstPointMouseEnter = value;\n this.notify({\n type: \"firstPointMouseEnter\",\n data: value,\n });\n }\n\n get firstPointMouseLeave() {\n return this.#firstPointMouseLeave;\n }\n set firstPointMouseLeave(value) {\n this.#firstPointMouseLeave = value;\n this.notify({\n type: \"firstPointMouseLeave\",\n data: value,\n });\n }\n\n get lastPointMouseClick() {\n return this.#lastPointMouseClick;\n }\n set lastPointMouseClick(value) {\n this.#lastPointMouseClick = value;\n this.notify({\n type: \"lastPointMouseClick\",\n data: value,\n });\n }\n\n get lastPointMouseUp() {\n return this.#lastPointMouseUp;\n }\n set lastPointMouseUp(value) {\n this.#lastPointMouseUp = value;\n this.notify({\n type: \"lastPointMouseUp\",\n data: value,\n });\n }\n\n get lastPointMouseEnter() {\n return this.#lastPointMouseEnter;\n }\n set lastPointMouseEnter(value) {\n this.#lastPointMouseEnter = value;\n this.notify({\n type: \"lastPointMouseEnter\",\n data: value,\n });\n }\n\n get lastPointMouseLeave() {\n return this.#lastPointMouseLeave;\n }\n set lastPointMouseLeave(value) {\n this.#lastPointMouseLeave = value;\n this.notify({\n type: \"lastPointMouseLeave\",\n data: value,\n });\n }\n\n get pointMouseDown() {\n return this.#pointMouseDown;\n }\n set pointMouseDown(value) {\n this.#pointMouseDown = value;\n this.notify({\n type: \"pointMouseDown\",\n data: value,\n });\n }\n\n get pointMouseUp() {\n return this.#pointMouseUp;\n }\n set pointMouseUp(value) {\n this.#pointMouseUp = value;\n this.notify({\n type: \"pointMouseUp\",\n data: value,\n });\n }\n\n get pointMouseEnter() {\n return this.#pointMouseEnter;\n }\n set pointMouseEnter(value) {\n this.#pointMouseEnter = value;\n this.notify({\n type: \"pointMouseEnter\",\n data: value,\n });\n }\n\n get pointMouseLeave() {\n return this.#pointMouseLeave;\n }\n set pointMouseLeave(value) {\n this.#pointMouseLeave = value;\n this.notify({\n type: \"pointMouseLeave\",\n data: value,\n });\n }\n\n get lineMouseEnter() {\n return this.#lineMouseEnter;\n }\n set lineMouseEnter(value) {\n this.#lineMouseEnter = value;\n this.notify({\n type: \"lineMouseEnter\",\n data: value,\n });\n }\n\n get lineMouseLeave() {\n return this.#lineMouseLeave;\n }\n set lineMouseLeave(value) {\n this.#lineMouseLeave = value;\n this.notify({\n type: \"lineMouseLeave\",\n data: value,\n });\n }\n}\n","import { ERRORS } from \"#store/errors\";\nimport { Initial, DrawOptions, RequiredDrawOptions } from \"#types/index\";\nimport { DEFAULT_OPTIONS } from \"./constants\";\nimport {\n ON_LINE_POINT_PAINT_BASE,\n FIRST_POINT_PAINT_BASE,\n POINTS_PAINT_BASE,\n LINE_PAINT_BASE,\n POLYGON_PAINT_BASE,\n BREAK_PAINT_BASE,\n} from \"./geo_constants\";\n\nexport class Options {\n static allStepsHaveIds(steps: Initial[\"steps\"]): boolean {\n return steps.every((step) => \"id\" in step && step.id !== undefined);\n }\n\n static checkIfMissingIds(steps: Initial[\"steps\"], generateId: Initial[\"generateId\"]) {\n const idGenerationIsOff = !generateId;\n const idsNotProvided = !this.allStepsHaveIds(steps);\n if (idGenerationIsOff && idsNotProvided) {\n throw new Error(ERRORS[\"MISSING_IDS\"]);\n }\n }\n\n static checkIfEnoughPointsToClose(steps: Initial[\"steps\"], closeGeometry: Initial[\"closeGeometry\"]) {\n const minLengthToCloseGeometry = 3;\n if (closeGeometry && steps.length < minLengthToCloseGeometry) {\n throw new Error(ERRORS[\"NOT_ENOUGH_POINTS_TO_CLOSE\"]);\n }\n }\n\n static checkIfPolygonIsClosed(options: Initial) {\n const { closeGeometry, steps } = options;\n if (steps) {\n const firstLng = steps[0]?.lng;\n const lastLng = steps[steps.length - 1]?.lng;\n const firstLat = steps[0]?.lat;\n const lastLat = steps[steps.length - 1]?.lat;\n const firstAndLastNotEqual = firstLng !== lastLng || firstLat !== lastLat;\n if (firstAndLastNotEqual && closeGeometry) {\n throw new Error(ERRORS[\"FIRST_LAST_POINT_NOT_EQUAL\"]);\n }\n }\n }\n\n static checkInitialStepsOption(options: Initial): void {\n const { closeGeometry, generateId, steps } = options;\n // if we have ids for all steps if id generation is off\n this.checkIfMissingIds(steps, generateId);\n // If we want to close the geometry, we need at least 3 points\n this.checkIfEnoughPointsToClose(steps, closeGeometry);\n // If the geometry is a polygon, closeGeometry must be true.\n this.checkIfPolygonIsClosed(options);\n }\n\n static init(options?: DrawOptions): RequiredDrawOptions {\n if (!options) {\n return DEFAULT_OPTIONS;\n }\n\n return {\n panel: generatePanelOptions(options),\n modes: generateModeOptions(options),\n layersPaint: generateLayersOptions(options),\n initial: options.initial || DEFAULT_OPTIONS[\"initial\"],\n locale: generateLocaleOptions(options),\n dynamicLine: options.dynamicLine ?? DEFAULT_OPTIONS.dynamicLine,\n } as RequiredDrawOptions;\n }\n}\n\nfunction generatePanelOptions(options: DrawOptions): RequiredDrawOptions[\"panel\"] {\n return {\n size: options.panel?.size || DEFAULT_OPTIONS.panel.size,\n buttons: {\n undo: {\n visible: options.panel?.buttons?.undo?.visible ?? DEFAULT_OPTIONS.panel.buttons.undo.visible,\n },\n delete: {\n visible: options.panel?.buttons?.delete?.visible ?? DEFAULT_OPTIONS.panel.buttons.delete.visible,\n },\n save: {\n visible: options.panel?.buttons?.save?.visible ?? DEFAULT_OPTIONS.panel.buttons.save.visible,\n clearOnSave: options.panel?.buttons?.save?.clearOnSave ?? DEFAULT_OPTIONS.panel.buttons.save.clearOnSave,\n },\n },\n };\n}\n\nfunction generateModeOptions(options: DrawOptions): RequiredDrawOptions[\"modes\"] {\n return {\n initial: options.modes?.initial || DEFAULT_OPTIONS.modes.initial,\n line: {\n visible:\n options?.modes?.line?.visible !== undefined\n ? options.modes.line.visible\n : options?.initial?.geometry === \"line\" || DEFAULT_OPTIONS.modes.line.visible,\n closeGeometry:\n options?.modes?.line?.closeGeometry ??\n options?.initial?.closeGeometry ??\n DEFAULT_OPTIONS.modes.line.closeGeometry,\n },\n polygon: {\n visible:\n options?.modes?.polygon?.visible !== undefined\n ? options.modes.polygon.visible\n : options?.initial?.geometry === \"polygon\" || DEFAULT_OPTIONS.modes.polygon.visible,\n },\n breakGeometry: {\n visible: options?.modes?.breakGeometry?.visible ?? DEFAULT_OPTIONS.modes.breakGeometry.visible,\n },\n };\n}\n\nfunction generateLayersOptions(options: DrawOptions): RequiredDrawOptions[\"layersPaint\"] {\n return {\n onLinePoint: {\n \"circle-radius\": options.layersPaint?.onLinePoint?.[\"circle-radius\"] || ON_LINE_POINT_PAINT_BASE[\"circle-radius\"],\n \"circle-color\": options.layersPaint?.onLinePoint?.[\"circle-color\"] || ON_LINE_POINT_PAINT_BASE[\"circle-color\"],\n \"circle-stroke-color\":\n options.layersPaint?.onLinePoint?.[\"circle-stroke-color\"] || ON_LINE_POINT_PAINT_BASE[\"circle-stroke-color\"],\n \"circle-stroke-width\":\n options.layersPaint?.onLinePoint?.[\"circle-stroke-width\"] || ON_LINE_POINT_PAINT_BASE[\"circle-stroke-width\"],\n ...options.layersPaint?.onLinePoint,\n },\n firstPoint: {\n \"circle-radius\": options.layersPaint?.firstPoint?.[\"circle-radius\"] || FIRST_POINT_PAINT_BASE[\"circle-radius\"],\n \"circle-color\": options.layersPaint?.firstPoint?.[\"circle-color\"] || FIRST_POINT_PAINT_BASE[\"circle-color\"],\n \"circle-stroke-color\":\n options.layersPaint?.firstPoint?.[\"circle-stroke-color\"] || FIRST_POINT_PAINT_BASE[\"circle-stroke-color\"],\n \"circle-stroke-width\":\n options.layersPaint?.firstPoint?.[\"circle-stroke-width\"] || FIRST_POINT_PAINT_BASE[\"circle-stroke-width\"],\n ...options.layersPaint?.firstPoint,\n },\n points: {\n \"circle-radius\": options.layersPaint?.points?.[\"circle-radius\"] || POINTS_PAINT_BASE[\"circle-radius\"],\n \"circle-color\": options.layersPaint?.points?.[\"circle-color\"] || POINTS_PAINT_BASE[\"circle-color\"],\n \"circle-stroke-color\":\n options.layersPaint?.points?.[\"circle-stroke-color\"] || POINTS_PAINT_BASE[\"circle-stroke-color\"],\n \"circle-stroke-width\":\n options.layersPaint?.points?.[\"circle-stroke-width\"] || POINTS_PAINT_BASE[\"circle-stroke-width\"],\n ...options.layersPaint?.points,\n },\n line: {\n \"line-width\": options.layersPaint?.line?.[\"line-width\"] || LINE_PAINT_BASE[\"line-width\"],\n \"line-color\": options.layersPaint?.line?.[\"line-color\"] || LINE_PAINT_BASE[\"line-color\"],\n \"line-opacity\": options.layersPaint?.line?.[\"line-opacity\"] || LINE_PAINT_BASE[\"line-opacity\"],\n ...options.layersPaint?.line,\n },\n polygon: {\n \"fill-color\": options.layersPaint?.polygon?.[\"fill-color\"] || POLYGON_PAINT_BASE[\"fill-color\"],\n \"fill-opacity\": options.layersPaint?.polygon?.[\"fill-opacity\"] || POLYGON_PAINT_BASE[\"fill-opacity\"],\n ...options.layersPaint?.polygon,\n },\n breakLine: {\n \"line-width\": options.layersPaint?.breakLine?.[\"line-width\"] || BREAK_PAINT_BASE[\"line-width\"],\n \"line-color\": options.layersPaint?.breakLine?.[\"line-color\"] || BREAK_PAINT_BASE[\"line-color\"],\n \"line-dasharray\": options.layersPaint?.breakLine?.[\"line-dasharray\"] || BREAK_PAINT_BASE[\"line-dasharray\"],\n ...options.layersPaint?.breakLine,\n },\n };\n}\n\nfunction generateLocaleOptions(options: DrawOptions): RequiredDrawOptions[\"locale\"] {\n return {\n save: options.locale?.save ?? DEFAULT_OPTIONS.locale.save,\n delete: options.locale?.delete ?? DEFAULT_OPTIONS.locale.delete,\n undo: options.locale?.undo ?? DEFAULT_OPTIONS.locale.undo,\n line: options.locale?.line ?? DEFAULT_OPTIONS.locale.line,\n polygon: options.locale?.polygon ?? DEFAULT_OPTIONS.locale.polygon,\n break: options.locale?.break ?? DEFAULT_OPTIONS.locale.break,\n closeLine: options.locale?.closeLine ?? DEFAULT_OPTIONS.locale.closeLine,\n createPolygon: options.locale?.createPolygon ?? DEFAULT_OPTIONS.locale.createPolygon,\n };\n}\n","import type { IControl, Map } from \"#types/map\";\n\nimport type { DrawOptions, LatLng, RequiredDrawOptions, Step, StepId } from \"#types/index\";\nimport { Panel } from \"#components/last-point-panel\";\nimport { Tiles } from \"#components/map/tiles\";\nimport { Events } from \"#components/map\";\nimport { Control } from \"#components/side-control\";\nimport { DrawingMode } from \"#components/map/mode\";\nimport { Cursor } from \"#components/map/cursor\";\nimport { MouseEvents } from \"#components/map/mouse-events/index\";\nimport { uuidv4 } from \"#utils/helpers\";\nimport { DOM } from \"#utils/dom\";\nimport { Store, StoreHelpers } from \"#store/index\";\nimport { Options } from \"#utils/options\";\n\nimport type {\n UndoEvent,\n PointAddEvent,\n PointDoubleClickEvent,\n PointEnterEvent,\n PointLeaveEvent,\n PointMoveEvent,\n RemoveAllEvent,\n SaveEvent,\n ModeChangeEvent,\n} from \"#components/map/types\";\n\nimport \"./draw.css\";\n\nexport default class DrawLibre implements IControl {\n #container: HTMLElement | undefined;\n #store: Store | undefined;\n #mode: DrawingMode | undefined;\n #defaultOptions: RequiredDrawOptions;\n #events: Events | undefined;\n #tiles: Tiles | undefined;\n #panel: Panel | undefined;\n #cursor: Cursor | undefined;\n #mouseEvents: MouseEvents | undefined;\n\n static #instance: DrawLibre | null = null;\n static #instanceCreated = false;\n\n private constructor(options?: DrawOptions) {\n this.#defaultOptions = Options.init(options);\n if (this.#defaultOptions.initial) {\n Options.checkInitialStepsOption(this.#defaultOptions.initial);\n }\n\n if (DrawLibre.#instanceCreated) {\n throw new Error(\"Use 'DrawLibre.getInstance()' instead of 'new DrawLibre()'.\");\n }\n\n DrawLibre.#instanceCreated = true;\n this.#store = undefined;\n this.#mode = undefined;\n this.#events = undefined;\n this.#tiles = undefined;\n this.#panel = undefined;\n this.#mouseEvents = undefined;\n this.#cursor = undefined;\n }\n\n public static getInstance(options?: DrawOptions) {\n if (!DrawLibre.#instance) {\n DrawLibre.#instance = new DrawLibre(options);\n }\n return DrawLibre.#instance;\n }\n\n /**\n * DO NOT USE IMPLICITLY. PASS TO map.addControl().\n *\n * @example ```ts\n * const map = new Map();\n * const draw = new DrawLibre();\n * map.addControl(draw)\n * ```\n *\n * Register a control on the map and give it a chance to register event listeners\n *\n * @param map - the Map this control will be added to\n * @returns The control's container element. This should\n * be created by the control and returned by onAdd without being attached\n * to the DOM: the map will insert the control's element into the DOM\n * as necessary.\n */\n onAdd(map: Map) {\n this.#store = new Store(this.#defaultOptions);\n this.#mode = new DrawingMode(this.#defaultOptions);\n this.#panel = new Panel({ map, mode: this.#mode, options: this.#defaultOptions, store: this.#store });\n this.#tiles = new Tiles({ map, store: this.#store, options: this.#defaultOptions, mode: this.#mode });\n const control = new Control({ options: this.#defaultOptions, mode: this.#mode });\n this.#mouseEvents = new MouseEvents();\n this.#cursor = new Cursor({ map, mode: this.#mode, mouseEvents: this.#mouseEvents, store: this.#store });\n this.#events = new Events({\n map,\n store: this.#store,\n options: this.#defaultOptions,\n panel: this.#panel,\n control,\n mode: this.#mode,\n tiles: this.#tiles,\n mouseEvents: this.#mouseEvents,\n });\n if (this.#mode.getMode()) {\n map.fire(\"mode:initialize\");\n }\n this.#mode.pingConsumers();\n this.#container = control.getContainer();\n\n return this.#container;\n }\n\n /**\n * DO NOT USE IMPLICITLY. PASS TO map.removeControl().\n *\n * @example ```ts\n * const map = new Map();\n * const draw = new DrawLibre();\n * map.removeControl(draw)\n * ```\n *\n * Unregister a control on the map and give it a chance to detach event listeners.\n *\n * @param map - the Map this control will be removed from\n */\n onRemove() {\n this.#cursor?.removeConsumers();\n this.#tiles?.removeTiles();\n this.#events?.removeMapEventsAndConsumers();\n this.#panel?.removePanel();\n this.#store?.reset();\n this.#mode?.unsubscribe();\n\n if (this.#container) {\n DOM.remove(this.#container);\n }\n }\n\n /**\n * Adds a series of steps to the store. If a step ID is not provided, it will be automatically generated.\n *\n * @param step - The step to add to the store, which can be of type Step or LatLng.\n */\n setSteps = (value: Step[] | LatLng[]) => {\n if (Array.isArray(value)) {\n value.forEach((step) => {\n const newStep = { ...step, id: (step as Step)[\"id\"] || uuidv4() };\n this.#store?.push(newStep);\n });\n } else {\n throw new Error(\"Invalid argument. Expected an array of steps.\");\n }\n this.#tiles?.render();\n };\n\n /**\n * Retrieves a step from the store by its ID. This method is called by {@link map.findStepById}\n * internally.\n *\n * @param id - The ID of the step to retrieve.\n * @returns The step with the specified ID, or undefined if not found.\n */\n findStepById = (id: StepId) => {\n return this.#store?.findStepById(id);\n };\n\n /**\n * Retrieves all steps from the store, either as an array or as a linked list, based on the type specified.\n * This method is called by {@link map.getAllSteps}\n * internally.\n *\n * @param type - The type of collection to return, either \"array\" or \"ll\" (linked list).\n * @returns An array of all steps or the linked list of steps.\n */\n getAllSteps = (type: \"array\" | \"linkedlist\" = \"array\") => {\n if (type === \"array\" && this.#store) {\n return StoreHelpers.toArray(this.#store.head);\n }\n if (type === \"linkedlist\") {\n return this.#store;\n }\n throw new Error(\"Invalid type specified. Use 'array' or 'linkedlist'.\");\n };\n\n setOptions = (fn: (options: RequiredDrawOptions) => RequiredDrawOptions) => {\n this.#defaultOptions = fn(this.#defaultOptions);\n };\n\n /**\n * Removes all steps.\n */\n removeAllSteps = () => {\n this.#store?.reset();\n this.#panel?.removePanel();\n this.#tiles?.render();\n };\n}\n\nexport type {\n RequiredDrawOptions,\n PointAddEvent,\n PointDoubleClickEvent,\n PointEnterEvent,\n PointLeaveEvent,\n PointMoveEvent,\n RemoveAllEvent,\n SaveEvent,\n UndoEvent,\n ModeChangeEvent,\n};\n"]}
package/package.json CHANGED
@@ -1,11 +1,8 @@
1
1
  {
2
2
  "name": "draw-libre",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Draw a line/polygon on a maplibre or mapbox map",
5
5
  "private": false,
6
- "main": "./dist/index.js",
7
- "module": "./dist/index.mjs",
8
- "types": "./dist/index.d.ts",
9
6
  "type": "module",
10
7
  "scripts": {
11
8
  "build": "tsup",
@@ -46,5 +43,14 @@
46
43
  "prettier": "3.2.5",
47
44
  "tsup": "8.2.2",
48
45
  "typescript": "5.4.5"
49
- }
46
+ },
47
+ "exports": {
48
+ ".": {
49
+ "types": "./dist/index.d.ts",
50
+ "import": "./dist/index.js",
51
+ "default": "./dist/index.js"
52
+ }
53
+ },
54
+ "sideEffects": false,
55
+ "browser": "./dist/index.js"
50
56
  }
@@ -1,8 +0,0 @@
1
- var DrawLibre = (function () {
2
- 'use strict';
3
-
4
- var l=class o{static docStyle=typeof window<"u"&&window.document&&window.document.documentElement.style;static transformProp=o.testProp(["transform","WebkitTransform"]);static testProp(e){if(!o.docStyle)return e[0];for(let t=0;t<e.length;t++)if(e[t]in o.docStyle)return e[t];return e[0]}static create(e,t,i){let n=window.document.createElement(e);return t!==void 0&&(n.className=t),i&&i.appendChild(n),n}static remove(e){e.parentNode&&e.parentNode.removeChild(e);}static setTransform(e,t){o.transformProp&&e.style&&(e.style[o.transformProp]=t);}static manageEventListener(e,t,i,n,s={}){if(!t)return;let a=e==="add"?"addEventListener":"removeEventListener";"passive"in s?t[a](i,n,s):t[a](i,n,s.capture);}static mouseButton(e){return e.button}static addClassName(e,t){e.classList.contains(t)||e.classList.add(t);}static removeClassName(e,t){e.classList.contains(t)&&e.classList.remove(t);}};var _=class o{lng;lat;constructor(e,t){if(isNaN(e)||isNaN(t))throw new Error(`Invalid LngLat object: (${e}, ${t})`);if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}static convert(e){if(e instanceof o)return e;if(Array.isArray(e)&&(e.length===2||e.length===3))return new o(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null)return new o(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}};function R(o,...e){for(let t of e)for(let i in t)o[i]=t[i];return o}function fe(o,e,t){let i=new _(o.lng,o.lat);if(o=new _(o.lng,o.lat),e){let n=new _(o.lng-360,o.lat),s=new _(o.lng+360,o.lat),a=t.locationPoint(o).distSqr(e);t.locationPoint(n).distSqr(e)<a?o=n:t.locationPoint(s).distSqr(e)<a&&(o=s);}for(;Math.abs(o.lng-t.center.lng)>180;){let n=t.locationPoint(o);if(n.x>=0&&n.y>=0&&n.x<=t.width&&n.y<=t.height)break;o.lng>t.center.lng?o.lng-=360:o.lng+=360;}return o.lng!==i.lng&&t.locationPoint(o).y>t.height/2-t.getHorizon()?o:i}var ue={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function ve(o,e,t){let i=o.classList;for(let n in ue)i.remove(`maplibregl-${t}-anchor-${n}`);i.add(`maplibregl-${t}-anchor-${e}`);}function Le(o,e,t){t[o]&&t[o].indexOf(e)!==-1||(t[o]=t[o]||[],t[o].push(e));}function de(o,e,t){if(t&&t[o]){let i=t[o].indexOf(e);i!==-1&&t[o].splice(i,1);}}var q=class{_listeners;_oneTimeListeners;_eventedParent;_eventedParentData;on(e,t){return this._listeners=this._listeners||{},Le(e,t,this._listeners),this}off(e,t){return de(e,t,this._listeners),de(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},Le(e,t,this._oneTimeListeners),this):new Promise(i=>this.once(e,i))}fire(e,t){typeof e=="string"&&(e=new D(e,t||{}));let i=e.type;if(this.listens(i)){e.target=this;let n=this._listeners&&this._listeners[i]?this._listeners[i].slice():[];for(let c of n)c.call(this,e);let s=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(let c of s)de(i,c,this._oneTimeListeners),c.call(this,e);let a=this._eventedParent;a&&(R(e,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),a.fire(e));}else e instanceof ErrorEvent&&console.error(e.error);return this}listens(e){return this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e)}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}},D=class{type;constructor(e,t={}){R(this,t),this.type=e;}};var h=class o{x;y;constructor(e,t){this.x=e,this.y=t;}mag(){return Math.sqrt(this.x*this.x+this.y*this.y)}equals(e){return this.x===e.x&&this.y===e.y}dist(e){return Math.sqrt(this.distSqr(e))}distSqr(e){let t=e.x-this.x,i=e.y-this.y;return t*t+i*i}angle(){return Math.atan2(this.y,this.x)}angleTo(e){return Math.atan2(this.y-e.y,this.x-e.x)}angleWith(e){return this.angleWithSep(e.x,e.y)}angleWithSep(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)}_matMult(e){let t=e[0]*this.x+e[1]*this.y,i=e[2]*this.x+e[3]*this.y;return this.x=t,this.y=i,this}_add(e){return this.x+=e.x,this.y+=e.y,this}_sub(e){return this.x-=e.x,this.y-=e.y,this}_mult(e){return this.x*=e,this.y*=e,this}_div(e){return this.x/=e,this.y/=e,this}_multByPoint(e){return this.x*=e.x,this.y*=e.y,this}_divByPoint(e){return this.x/=e.x,this.y/=e.y,this}_unit(){return this._div(this.mag()),this}_perp(){let e=this.y;return this.y=this.x,this.x=-e,this}_rotate(e){let t=Math.cos(e),i=Math.sin(e),n=t*this.x-i*this.y,s=i*this.x+t*this.y;return this.x=n,this.y=s,this}_rotateAround(e,t){let i=Math.cos(e),n=Math.sin(e),s=t.x+i*(this.x-t.x)-n*(this.y-t.y),a=t.y+n*(this.x-t.x)+i*(this.y-t.y);return this.x=s,this.y=a,this}_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}static convert(e){if(e instanceof o)return e;if(Array.isArray(e))return new o(+e[0],+e[1]);if(e.x!==void 0&&e.y!==void 0)return new o(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")}};var Se={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1},Oe=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", "),z=class extends q{_map;options;_content;_container;_closeButton;_tip;_lngLat;_trackPointer;_pos;_flatPos;constructor(e){super(),this.options=R(Object.create(Se),e);}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new D("open")),this}isOpen(){return !!this._map}remove=()=>(this._content&&l.remove(this._content),this._container&&(l.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new D("close"))),this);getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=_.convert(e),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){let t=document.createDocumentFragment(),i=document.createElement("body"),n;for(i.innerHTML=e;n=i.firstChild,!!n;)t.appendChild(n);return this.setDOMContent(t)}getMaxWidth(){return this._container?.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=l.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(e),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(e){return this._container&&this._container.classList.add(e),this}removeClassName(e){return this._container&&this._container.classList.remove(e),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){if(this._container)return this._container.classList.toggle(e)}setSubpixelPositioning(e){this.options.subpixelPositioning=e;}_createCloseButton(){this.options.closeButton&&(this._closeButton=l.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="&#215;",this._closeButton.addEventListener("click",this._onClose));}_onMouseUp=e=>{this._update(e.point);};_onMouseMove=e=>{this._update(e.point);};_onDrag=e=>{this._update(e.point);};_update=e=>{let t=this._lngLat||this._trackPointer;if(!this._map||!t||!this._content)return;if(!this._container){if(this._container=l.create("div","maplibregl-popup",this._map.getContainer()),this._tip=l.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(let c of this.options.className.split(" "))this._container.classList.add(c);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer");}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._map.transform.renderWorldCopies&&!this._trackPointer?this._lngLat=fe(this._lngLat,this._flatPos,this._map.transform):this._lngLat=this._lngLat?.wrap(),this._trackPointer&&!e)return;let i=this._flatPos=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&e?e:this._map.transform.locationPoint(this._lngLat));let n=this.options.anchor,s=ge(this.options.offset);if(!n){let c=this._container.offsetWidth,v=this._container.offsetHeight,k;i.y+s.bottom.y<v?k=["top"]:i.y>this._map.transform.height-v?k=["bottom"]:k=[],i.x<c/2?k.push("left"):i.x>this._map.transform.width-c/2&&k.push("right"),k.length===0?n="bottom":n=k.join("-");}let a=i.add(s[n]);this.options.subpixelPositioning||(a=a.round()),l.setTransform(this._container,`${ue[n]} translate(${a.x}px,${a.y}px)`),ve(this._container,n,"popup");};_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;let e=this._container.querySelector(Oe);e&&e.focus();}_onClose=()=>{this.remove();}};function ge(o){if(o)if(typeof o=="number"){let e=Math.round(Math.abs(o)/Math.SQRT2);return {center:new h(0,0),top:new h(0,o),"top-left":new h(e,e),"top-right":new h(-e,e),bottom:new h(0,-o),"bottom-left":new h(e,-e),"bottom-right":new h(-e,-e),left:new h(o,0),right:new h(-o,0)}}else if(o instanceof h||Array.isArray(o)){let e=h.convert(o);return {center:e,top:e,"top-left":e,"top-right":e,bottom:e,"bottom-left":e,"bottom-right":e,left:e,right:e}}else return {center:h.convert(o.center||[0,0]),top:h.convert(o.top||[0,0]),"top-left":h.convert(o["top-left"]||[0,0]),"top-right":h.convert(o["top-right"]||[0,0]),bottom:h.convert(o.bottom||[0,0]),"bottom-left":h.convert(o["bottom-left"]||[0,0]),"bottom-right":h.convert(o["bottom-right"]||[0,0]),left:h.convert(o.left||[0,0]),right:h.convert(o.right||[0,0])};else return ge(new h(0,0))}var Y=class{#e;#t;#i;_undoButton;_deleteButton;_saveButton;_container;constructor(e){this.#e=e,this._container=void 0,this.#i=!1,this.#s().then(()=>{this.#r(),this.#n();});}#n(){this.#e.mode?.addObserver(this.#o);}#o=e=>{let{store:t}=this.#e,{type:i,data:n}=e;i==="MODE_CHANGED"&&!n&&this.hidePanel(),i==="MODE_CHANGED"&&n&&t.tail?.val&&this.setPanelLocation({lat:t.tail?.val?.lat,lng:t.tail?.val?.lng});};#s=async()=>{try{this.#t=new z({offset:16,closeButton:!1,closeOnClick:!1,closeOnMove:!1,anchor:"bottom"});}catch(e){console.error("POPUP LOAD ERROR",e);}};#r=()=>{let{store:e}=this.#e;this.createPanel(),e.tail?.val&&this.setPanelLocation({lat:e.tail?.val?.lat,lng:e.tail?.val?.lng});};setPanelLocation=e=>{let{map:t}=this.#e;this.#i&&(this.#i=!1,this.showPanel()),this._container&&this.#t&&this.#t.setLngLat(e).setDOMContent(this._container).addTo(t);};hidePanel=()=>{!this.#i&&(this.#t?.addClassName("hide-panel"),this.#i=!0);};showPanel=()=>{this.#t?.removeClassName("hide-panel"),this.#i=!1;};onPointRemove=e=>{e?this.setPanelLocation(e):this.hidePanel();};removePanel=()=>{this._container&&l.remove(this._container),this.#t?.remove();};createButton=(e,t,i,n)=>{let s=l.create("button",`panel-button panel-button-${i}`,n);return s.setAttribute("data-type",e),s.setAttribute("aria-label",t),l.create("span",`icon ${e} icon-${i}`,s),s};createPanel=()=>{let{options:e}=this.#e,{locale:t}=e,{undo:i,delete:n,save:s}=e.panel.buttons,a=e.panel.size,c=document.querySelector(".maplibregl-popup-content"),v=l.create("div","dashboard",c);i.visible&&(this._undoButton=this.createButton("undo",t.undo,a,v)),n.visible&&(this._deleteButton=this.createButton("delete",t.delete,a,v)),s.visible&&(this._saveButton=this.createButton("save",t.save,a,v)),this._container=v;}};var j={type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[]}}]},W={type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[]}}]},Ee={type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"Point",coordinates:[]}}]},r={LineDynamicLayer:"mdl-line-dynamic-layer",LineLayer:"mdl-line-layer",LineLayerTransparent:"mdl-line-layer-transparent",LineLayerBreak:"mdl-line-break-layer",PolygonLayer:"mdl-polygon-layer",PointsLayer:"mdl-points-layer",SinglePointLayer:"mdl-single-point-layer",FirstPointLayer:"mdl-first-point-layer"},p={LineDynamicSource:"mdl-line-dynamic-source",LineSourceBreak:"mdl-line-source-break",LineSource:"mdl-line-source",PolygonSource:"mdl-polygon-source",PointsSource:"mdl-points-source",SinglePointSource:"mdl-single-point-source"},A={large:6.5,default:5.5},V={large:"#FF6464",default:"#666666"},x={"circle-radius":A.default,"circle-color":"#FEFFFE","circle-stroke-color":V.default,"circle-stroke-width":3},T={"circle-radius":A.large,"circle-color":"#FEFFFE","circle-stroke-color":"#666666","circle-stroke-width":3},G={"fill-color":"grey","fill-opacity":.4},I={"line-width":3,"line-color":"grey","line-opacity":.7},w={"circle-radius":A.default,"circle-color":"#FEFFFE","circle-stroke-color":"#666666","circle-stroke-width":3},B={"line-width":3,"line-color":"#FF6464","line-dasharray":[3,3]},K=o=>[{id:r.SinglePointLayer,source:p.SinglePointSource,type:"circle",paint:o.layersPaint.onLinePoint,layout:{visibility:"none"}},{id:r.PolygonLayer,source:p.PolygonSource,type:"fill",paint:o.layersPaint.polygon,layout:{visibility:"none"}},{id:r.LineDynamicLayer,source:p.LineDynamicSource,type:"line",paint:o.layersPaint.line,layout:{visibility:"none"}},{id:r.LineLayer,source:p.LineSource,type:"line",paint:o.layersPaint.line,layout:{visibility:"visible"}},{id:r.LineLayerTransparent,source:p.LineSource,type:"line",paint:{"line-width":4,"line-color":"transparent"}},{id:r.LineLayerBreak,source:p.LineSourceBreak,type:"line",paint:o.layersPaint.breakLine,layout:{visibility:"none"}},{id:r.PointsLayer,source:p.PointsSource,type:"circle",paint:o.layersPaint.points,filter:["==",["get","isFirst"],!1]},{id:r.FirstPointLayer,source:p.PointsSource,type:"circle",paint:o.layersPaint.firstPoint,filter:["==",["get","isFirst"],!0]}];var L=class{static#e=0;static#t=e=>{e.setPaintProperty(r.FirstPointLayer,"circle-radius",A.large),e.setPaintProperty(r.FirstPointLayer,"circle-stroke-color",V.large);};static#i=e=>{e.setPaintProperty(r.FirstPointLayer,"circle-radius",A.default),e.setPaintProperty(r.FirstPointLayer,"circle-stroke-color",V.default);};static togglePointCircleRadius=(e,t)=>{t==="large"?this.#t(e):this.#i(e);};static removeTransparentLine=e=>{e.removeLayer(r.LineLayerTransparent);};static addTransparentLine=(e,t)=>{if(e.getLayer(r.LineLayerTransparent))return;let n=K(t).find(s=>s.id===r.LineLayerTransparent);n&&e.addLayer(n);};static isDoubleClick(){let t=Date.now();return t-this.#e<=400?(this.#e=t,!0):(this.#e=t,!1)}};var y=class{static isFeatureTriggered(e,t){return e.target.queryRenderedFeatures(e.point,{layers:t}).some(n=>t.includes(n.layer.id))}static getPixelCoordinates=(e,t)=>{let{lat:i,lng:n}=t;return e.project([n,i])};static queryPointId=(e,t)=>e.queryRenderedFeatures(t,{layers:[r.PointsLayer,r.FirstPointLayer]})?.[0]?.properties.id},M=class{static#e(e){let t=[],i=e.head,n=new Set;for(;i!==null;){if(n.has(i.val?.id)){e.head&&e.head.val&&t.push([e.head.val.lng,e.head.val.lat]);break}n.add(i.val?.id),i.val&&t.push([i.val.lng,i.val.lat]),i=i.next;}return t}static getAllLines(e){let t=this.#e(e);return {type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:t}}]}}static getLine(e,t){return {type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[e,t]}}]}}static getPolygon(e){let t=this.#e(e);return {type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[t]}}]}}static getPoints(e){let t=e.head,i=[],n=new Set;for(;t!==null&&!n.has(t.val?.id);){if(t.val){let s=t.val,a=t.val.id===e.head?.val?.id;i.push({type:"Feature",properties:{id:s.id,lat:s.lat,lng:s.lng,isFirst:a},geometry:{type:"Point",coordinates:[s.lng,s.lat]}});}n.add(t.val?.id),t=t.next;}return {type:"FeatureCollection",features:i}}},u=class o{static getGeometryIndex=(e,t)=>{let i=e.head,n=0;for(;i!==null;){if(i.val?.id===t)return n;n++,i=i.next;}return -1};static isFirstPoint(e){let t=e.target,i=e.point;return !!t.queryRenderedFeatures(i,{layers:[r.FirstPointLayer]}).length}static distance=(e,t)=>Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2);static checkIfPointIsOnLine=(e,t,i)=>{let s=this.distance(e,t),a=this.distance(e,i),c=this.distance(i,t);return Math.abs(a+c-s)<.1};static isClosedGeometry=e=>e.tail?.next===e.head;static breakGeometry=(e,t)=>{if(!e.head)return;let i=e.head,n=e.tail;do{if(i?.val?.id===t){i!==e.head&&(n.next=i.next,e.head=i,e.tail=n),e.tail.next=null;return}n=i,i=i.next;}while(i!==e.head)};static closeGeometry=(e,t)=>{e.tail&&(e.tail.next=e.head),t.setClosedGeometry(!0);};static canCloseGeometry=e=>e.size>2&&!this.isClosedGeometry(e);static canBreakClosedGeometry=e=>e.size<=2;static switchToLineModeIfCan=e=>{let{mode:t,store:i,tiles:n,map:s}=e;o.canBreakClosedGeometry(i)&&(i.tail&&i.tail.val&&(i.tail.next=null),t.reset(),L.togglePointCircleRadius(s,"default"),n.renderPolygon(j));}},b=()=>{if("crypto"in window&&"randomUUID"in window.crypto)return window.crypto.randomUUID();function o(){return "0123456789abcdef"[Math.floor(Math.random()*16)]}function e(n){let s="";for(let a=0;a<n;a++)s+=o();return s}function t(n){let s=n===0,a=n===4;return s?8:a?12:4}let i=[];for(let n=0;n<5;n++)i.push(e(t(n)));return i.join("-")},C=(o,e)=>{let t,i=!0;function n(){i&&t&&(o(...t),t=null,i=!1,setTimeout(()=>{i=!0,n();},e));}return function(...s){t=s,n();}};var N=class{#e;#t;#i;#n;constructor(e){this.#e=e,this.#o(),this.render();}#o(){this.#s(),this.#r(),this.#a(r.LineLayer,r.SinglePointLayer),this.#a(r.LineLayerTransparent,r.SinglePointLayer),this.#a(r.LineLayerTransparent,r.FirstPointLayer),this.#a(r.LineLayerTransparent,r.PointsLayer),this.#a(r.PolygonLayer,r.LineLayer);}#s=()=>{let{map:e}=this.#e;Object.values(p).forEach(t=>{e.getSource(t)||e.addSource(t,{type:"geojson",data:{type:"FeatureCollection",features:[]},promoteId:"id"});});};#r=()=>{let{map:e,mode:t,options:i}=this.#e;K(i).forEach(a=>{e.getLayer(a.id)||e.addLayer(a);});let s=e.getLayoutProperty(r.PolygonLayer,"visibility")==="none";t.getMode()==="polygon"&&s&&e.setLayoutProperty(r.PolygonLayer,"visibility","visible");};#a=(e,t)=>{let{map:i}=this.#e,n=i.getLayer(e),s=i.getLayer(t);n&&s&&i.moveLayer(e,t);};#l=()=>{let{map:e}=this.#e;Object.values(p).forEach(t=>{e.getSource(t)&&e.removeSource(t);});};#c=()=>{let{map:e}=this.#e;Object.values(r).forEach(t=>{e.getLayer(t)&&e.removeLayer(t);});};removeTiles=()=>{this.#c(),this.#l();};renderPoints=e=>{let{map:t}=this.#e,i=t.getSource(p.PointsSource);i&&i.setData(e);};renderLines=(e,t)=>{let{map:i}=this.#e,n=i.getSource(t);n&&n.setData(e);};renderPolygon=e=>{let{map:t}=this.#e,i=t.getSource(p.PolygonSource);i&&i.setData(e);};render=()=>{let{mode:e,options:t,store:i}=this.#e,n=M.getPoints(i),s=M.getAllLines(i);if(this.#t=n,this.#i=s,this.renderPoints(n),this.renderLines(s,p.LineSource),t.modes.polygon.visible&&e.isPolygon()){let c=M.getPolygon(i);this.#n=c,this.renderPolygon(c);}};#h=(e,t)=>{if(this.#n.features[0].geometry.coordinates[0][e]=[t.lng,t.lat],e===0){let n=this.#n.features[0].geometry.coordinates[0]?.length-1;this.#n.features[0].geometry.coordinates[0][n]=[t.lng,t.lat];}this.renderPolygon(this.#n);};#p=(e,t)=>{let{mode:i}=this.#e;this.#i.features[0].geometry.coordinates[e]=[t.lng,t.lat];let n=e===0;if(this.#i&&i.getClosedGeometry()&&n){let a=this.#i.features[0].geometry.coordinates?.length-1;this.#i.features[0].geometry.coordinates[a]=[t.lng,t.lat];}this.renderLines(this.#i,p.LineSource);};renderOnMouseMove=(e,t)=>{let{mode:i,options:n}=this.#e;this.#t.features[e].geometry.coordinates=[t.lng,t.lat],this.renderPoints(this.#t),this.#p(e,t),n.modes.polygon.visible&&i.isPolygon()&&this.#h(e,t);};resetGeometries=()=>{this.renderPoints(Ee),this.renderLines(W,p.LineSource),this.renderPolygon(j);}};var ke=8,xe=8,S=class{_container;_label;constructor(){this._container=void 0;}create=e=>{let t=l.create("div","popup-container",document.body),i=l.create("span",`popup-text popup-text-${e.placement}`,t);return i.textContent=e.label,this._container=t,this._label=i,this};#e=()=>{!this._label?.classList.value.includes("popup-text-active")&&this._label?.classList.add("popup-text-active");};#t=()=>this._label?{width:this._label.clientWidth,height:this._label.clientHeight}:{width:0,height:0};#i=e=>{let{bottom:t,left:i}=e.target.getBoundingClientRect(),{width:n,height:s}=this.#t();return {x:i-xe-n,y:t-s-2}};#n=e=>{let{bottom:t,left:i,right:n}=e.target.getBoundingClientRect(),{width:s}=this.#t();return {x:(n-i)/2+i-s/2,y:t+ke}};getPosition=(e,t)=>t==="left"?this.#i(e):this.#n(e);setPosition=e=>{let{x:t,y:i}=e;this._container&&(this._container.style.left=`${t}px`,this._container.style.top=`${i}px`),this.#e();};remove=()=>{this._container&&l.remove(this._container);}};var g={AUTO:"auto",DEFAULT:"default",POINTER:"pointer",CROSSHAIR:"crosshair",MOVE:"move",HELP:"help",GRAB:"grab",GRABBING:"grabbing"};var $=(o,e)=>{for(let[t,i]of Object.entries(e))l.manageEventListener("add",o,t,i);},Z=(o,e)=>{for(let[t,i]of Object.entries(e))l.manageEventListener("remove",o,t,i);},Pe=(o,e)=>{let t=e.locale.line,i=e.locale.polygon,n=e.locale.break;return {line:t,polygon:i,break:n}[o]};var f={DOUBLECLICK:"mdl:doubleclick",POINTENTER:"mdl:pointenter",POINTLEAVE:"mdl:pointleave",MOVEEND:"mdl:moveend",ADD:"mdl:add",UNDO:"mdl:undo",REMOVEALL:"mdl:removeall",SAVE:"mdl:save",BREAK:"mdl:break",MODECHANGED:"mdl:modechanged"};var d={panel:{size:"medium",buttons:{undo:{visible:!0},delete:{visible:!0},save:{visible:!0,clearOnSave:!0}}},modes:{initial:null,line:{visible:!0,closeGeometry:!0},polygon:{visible:!0},breakGeometry:{visible:!0}},layersPaint:{onLinePoint:T,firstPoint:x,points:w,line:I,polygon:G,breakLine:B},initial:null,dynamicLine:!0,locale:{save:"Save",delete:"Delete all",undo:"Undo",line:"Line",polygon:"Polygon",break:"Split",closeLine:"Close line",createPolygon:"Create polygon"}};var m=class{static addPoint(e,t,i){t.fire(f.ADD,{id:e.id,coordinates:{lat:e.lat,lng:e.lng},total:e.total,timestamp:Date.now(),mode:{geometry:i.getMode(),closedGeometry:i.getClosedGeometry()}});}static movePoint(e,t){t.fire(f.MOVEEND,{id:e.id,start_coordinates:{lat:e.start.lat,lng:e.start.lng},end_coordinates:{lat:e.end.lat,lng:e.end.lng},total:e.total,timestamp:Date.now()});}static pointDoubleClick(e,t){t.fire(f.DOUBLECLICK,{id:e.id,coordinates:{lat:e.lat,lng:e.lng},total:e.total,timestamp:Date.now()});}static enterPoint(e,t){t.fire(f.POINTENTER,{id:e.id,coordinates:{lat:e.lat,lng:e.lng},total:e.total,timestamp:Date.now()});}static leavePoint(e,t){t.fire(f.POINTLEAVE,{id:e.id,coordinates:{lat:e.lat,lng:e.lng},total:e.total,timestamp:Date.now()});}static undoPoint(e,t,i){t.fire(f.UNDO,{originalEvent:i,id:e.id,coordinates:{lat:e.lat,lng:e.lng},total:e.total,timestamp:Date.now()});}static modeChanged(e,t){e.fire(f.MODECHANGED,{mode:t});}static removeAllPoints(e,t){e.fire(f.REMOVEALL,{originalEvent:t});}static onSaveClick(e,t,i){let{map:n,mode:s}=e;n.fire(f.SAVE,{originalEvent:i,timestamp:Date.now(),steps:t,mode:{geometry:s.getMode(),closedGeometry:s.getClosedGeometry()}});}static onLineBreak(e){e.fire(f.BREAK);}};var J=class{#e;constructor(e){this.#e=e,this.#t();}#t=()=>{this.#e.mode.addObserver(this.#l);};removeConsumers=()=>{this.#e.mode.removeObserver(this.#l);};#i=()=>{let{_line:e,_polygon:t,_break:i}=this.#e.control;e?.classList.remove("control-button-active"),t?.classList.remove("control-button-active"),i?.classList.remove("control-button-active");};#n=e=>{this.#i(),e.classList.add("control-button-active");};#o=e=>{let{data:t}=e,{_line:i,_polygon:n,_break:s}=this.#e.control,{mode:a}=this.#e;if(m.modeChanged(this.#e.map,t),!(!i||!n||!s)){switch(t){case"line":this.#n(i);break;case"polygon":this.#n(n);break;}t?a.getClosedGeometry()&&this.#r(s):this.#s(s);}};#s=e=>{e.setAttribute("disabled","true"),e.setAttribute("aria-disabled","true");};#r=e=>{e.removeAttribute("disabled"),e.removeAttribute("aria-disabled");};#a=e=>{let{data:t}=e,{_break:i,_line:n,_polygon:s}=this.#e.control,{mode:a}=this.#e;t?(i&&this.#r(i),a.getMode()==="polygon"&&n&&this.#s(n),a.getMode()==="line"&&s&&this.#s(s)):(i&&this.#s(i),a.getMode()==="polygon"&&n&&this.#r(n),a.getMode()==="line"&&s&&this.#r(s));};#l=e=>{let{type:t,data:i}=e;if(t==="MODE_CHANGED"&&this.#o(e),t==="CLOSED_GEOMETRY_CHANGED"&&this.#a(e),t==="BREAK_CHANGED"&&i){let{_break:n}=this.#e.control;this.#n(n),m.modeChanged(this.#e.map,"break");}}};var X=class{#e;#t;#i;constructor(e){this.#e=e,this.#i=new J(e),this.#t=new S,this.#n();}#n(){let{control:e}=this.#e;if(e){let t={mouseenter:this.onButtonEnter,mouseleave:this.onButtonLeave};e._line&&$(e._line,{...t,click:this.onLineClick}),e._polygon&&$(e._polygon,{...t,click:this.onPolygonClick}),e._break&&$(e._break,{...t,click:this.onBreakClick});}}#o(){let{control:e}=this.#e;if(e){let t={mouseenter:this.onButtonEnter,mouseleave:this.onButtonLeave};e._line&&Z(e._line,{...t,click:this.onLineClick}),e._polygon&&Z(e._polygon,{...t,click:this.onPolygonClick}),e._break&&Z(e._break,{...t,click:this.onBreakClick});}}remove(){this.#i.removeConsumers(),this.#o(),this.#t.remove();}onButtonEnter=e=>{let{options:t}=this.#e,i=e.target.getAttribute("data-type");if(i){let n=Pe(i,t),s="left";this.#t.create({label:n,placement:s}).setPosition(this.#t.getPosition(e,s));}};onButtonLeave=()=>{this.#t.remove();};#s=()=>{let{control:e}=this.#e;e._line?.classList.remove("control-button-active"),e._polygon?.classList.remove("control-button-active"),e._break?.classList.remove("control-button-active");};#r=()=>{let{map:e,mode:t}=this.#e;t.getMode()||e.fire("mode:initialize");};onLineClick=()=>{let{map:e,mode:t,tiles:i,control:n}=this.#e;this.#r(),this.#s(),t.getMode()==="line"&&!t.getBreak()?(t.setMode(null),e.fire("mode:remove"),i.resetGeometries()):(n._line?.classList.add("control-button-active"),t.setMode("line"),i.render());};onPolygonClick=()=>{let{map:e,mode:t,tiles:i,control:n}=this.#e;this.#r(),this.#s(),t.getMode()==="polygon"&&!t.getBreak()?(t.setMode(null),e.fire("mode:remove"),e.setLayoutProperty(r.PolygonLayer,"visibility","visible"),i.resetGeometries()):(n._polygon?.classList.add("control-button-active"),t.setMode("polygon"),i.render());};onBreakClick=()=>{let{map:e,mode:t,control:i}=this.#e;t.getBreak()&&(t.setMode(null),e.fire("mode:remove")),this.#s(),i._break?.classList.add("control-button-active"),t.setBreak(!0),e.getCanvasContainer().style.cursor=g.POINTER;}};var O=class{observers;constructor(){this.observers=new Set;}addObserver(e){this.observers.add(e);}removeObserver(e){this.observers.delete(e);}unsubscribe(){this.observers.clear();}notify(e){this.observers.forEach(t=>t(e));}};var F={EMPTY_INITIAL_STATE:"You passed an empty initial array in the options. Please either remove the 'initial' property or include at least one element in the array.",MISSING_IDS:"You set 'generateId' to false but did not provide IDs for all steps. Please ensure all steps have IDs or set 'generateId' to true.",NOT_ENOUGH_POINTS_TO_CLOSE:"At least three points are required to close a polygon or a line. Please add more points or set 'closeGeometry' to false.",FIRST_LAST_POINT_NOT_EQUAL:"The first and last points of a polygon or a closed linestring must be the same. Please ensure the first and last points are equal or set 'closeGeometry' to false."};var Q=class{val;next;constructor(e=null,t=null){this.val=e,this.next=t;}},H=class extends O{head;tail;size;constructor(e){super();let t=P.initStore(e);this.head=t?t.head:null,this.tail=t?t.tail:null,this.size=t?t.size:0;}push(e){let t=new Q(e);this.head?this.tail&&(this.tail.next=t,this.tail=t):this.head=this.tail=t,this.size++,this.pingConsumers();}insert(e,t){let i=new Q(e,t.next);this.tail===t&&this.head===t.next&&(this.tail=i),t.next=i,this.size++;}findStepById(e){let t=this.head,i=new Set;for(;t!==null&&!i.has(t);){if(t.val&&t.val.id===e)return t.val;i.add(t),t=t.next;}return null}removeStepById(e){if(!this.head)return null;let t=this.head,i=null;for(;t!==null;){if(t?.val?.id===e)return t===this.head?(this.head=t.next,this.tail&&(this.tail.next=t.next)):i.next=t.next,t===this.tail&&(this.tail=i),this.size--,this.pingConsumers(),t;i=t,t.next&&(t=t.next);}return null}reset(){this.head=null,this.tail=null,this.size=0,this.pingConsumers();}pingConsumers=()=>{this.notify({type:"STORE_CHANGED",data:{head:this.head,tail:this.tail,size:this.size}});}},P=class o{static isLastPoint=(e,t)=>e.tail?.val?.id===t;static initStore(e){if(!e?.initial)return null;if(e&&e.initial&&!e.initial.steps.length)throw new Error(F.EMPTY_INITIAL_STATE);if(e&&e.initial.steps){let{steps:n,closeGeometry:s,generateId:a}=e.initial;return o.fromArray(n,s,a)}return null}static#e=e=>e.map(t=>({...t,id:b()}));static buildStepSequence(e){let t=new H;return e.forEach(i=>{t.push(i);}),t}static fromArray(e,t,i){let n=i?this.#e(e):e,s=this.buildStepSequence(n);return t&&s.tail&&(s.tail.next=s.head),s}static toArray(e){if(!e)return [];let t=new Set,i=[],n=e;for(;n!==null&&!t.has(n);)t.add(n),i.push(n.val),n=n.next;return i}};var ee=class{#e;#t;constructor(e){this.#e=e,this.#t=new S;}initEvents(){let{panel:e}=this.#e;e&&(l.manageEventListener("add",e?._undoButton,"click",this.#o),l.manageEventListener("add",e?._undoButton,"mouseenter",this.onMouseEnter),l.manageEventListener("add",e?._undoButton,"mouseleave",this.onMouseLeave)),e&&(l.manageEventListener("add",e?._deleteButton,"click",this.#n),l.manageEventListener("add",e?._deleteButton,"mouseenter",this.onMouseEnter),l.manageEventListener("add",e?._deleteButton,"mouseleave",this.onMouseLeave)),e&&(l.manageEventListener("add",e?._saveButton,"click",this.onSaveClick),l.manageEventListener("add",e?._saveButton,"mouseenter",this.onMouseEnter),l.manageEventListener("add",e?._saveButton,"mouseleave",this.onMouseLeave));}removeEvents(){let{panel:e}=this.#e;e&&e._undoButton&&(l.manageEventListener("remove",e._undoButton,"click",this.#o),l.manageEventListener("remove",e._undoButton,"mouseenter",this.onMouseEnter),l.manageEventListener("remove",e._undoButton,"mouseleave",this.onMouseLeave)),e&&e._deleteButton&&(l.manageEventListener("remove",e._deleteButton,"click",this.#n),l.manageEventListener("remove",e._deleteButton,"mouseenter",this.onMouseEnter),l.manageEventListener("remove",e._deleteButton,"mouseleave",this.onMouseLeave)),e&&e._saveButton&&(l.manageEventListener("remove",e._saveButton,"click",this.onSaveClick),l.manageEventListener("remove",e._saveButton,"mouseenter",this.onMouseEnter),l.manageEventListener("remove",e._saveButton,"mouseleave",this.onMouseLeave));}#i=e=>{let{options:t}=this.#e;return {undo:t.locale.undo,delete:t.locale.delete,save:t.locale.save}[e]};onMouseEnter=e=>{let t=e.target.getAttribute("data-type");if(t){let i=this.#i(t);this.#t.create({label:i,placement:"bottom"}).setPosition(this.#t.getPosition(e,"bottom"));}};onMouseLeave=()=>{this.#t.remove();};#n=e=>{let{tiles:t,mode:i,panel:n,store:s,map:a}=this.#e;s.reset(),n.hidePanel(),i.reset(),L.togglePointCircleRadius(a,"default"),this.#t.remove(),t.resetGeometries(),m.removeAllPoints(a,e);};#o=e=>{let{store:t,panel:i,map:n,tiles:s}=this.#e,a=t.tail?.val;t.removeStepById(a.id);let c={...a,total:t.size};m.undoPoint(c,n,e),u.switchToLineModeIfCan(this.#e),i?.onPointRemove(t.tail?.val),this.#t.remove(),requestAnimationFrame(s.render);};onSaveClick=e=>{let{store:t,options:i}=this.#e;m.onSaveClick(this.#e,P.toArray(t.head),e),this.#t.remove(),i.panel.buttons.save.clearOnSave&&this.#n(e);}};var E=class{static updatePointsData(e){let i=e.target.getSource(p.SinglePointSource);i&&i.setData({type:"Feature",geometry:{type:"Point",coordinates:[e.lngLat.lng,e.lngLat.lat]},properties:{}});}static setSinglePointVisible(e){e.target.setLayoutProperty(r.SinglePointLayer,"visibility","visible");}static setSinglePointHidden(e){let t=e.target;setTimeout(()=>{t.setLayoutProperty(r.SinglePointLayer,"visibility","none");},33);}static triggerPostPointAddition(e,t){let{panel:i,tiles:n,store:s,map:a}=t;u.canCloseGeometry(s)&&L.togglePointCircleRadius(a,"large"),i?.setPanelLocation(e.lngLat),n.render();}static addPointToMap=(e,t)=>{let{store:i,map:n,mode:s}=t,a={...e.lngLat,id:b()};i.push(a),m.addPoint({...a,total:i.size},n,s),this.triggerPostPointAddition(e,t);};static updateSelectedStepLatLng=(e,t)=>{t.lat=e.lngLat.lat,t.lng=e.lngLat.lng;}};var me=(o,e)=>{let t=e.head,i=new Set;for(;t!==null&&!i.has(t);){if(t.next&&t.next.val&&t.val){let n=o.target,s=y.getPixelCoordinates(n,t.val),a=y.getPixelCoordinates(n,t.next.val),c=y.getPixelCoordinates(n,o.lngLat);if(u.checkIfPointIsOnLine(s,a,c))return t}i.add(t),t=t.next;}return null},Me=(o,e)=>{let t=me(o,e);if(t){let i={...o.lngLat,id:b()};return e.insert(i,t),i}return null},be=(o,e)=>{let{store:t,tiles:i,panel:n}=e;t.tail?.val&&(n?.setPanelLocation(t.tail.val),E.setSinglePointHidden(o),i.render());},_e=o=>y.isFeatureTriggered(o,[r.PointsLayer,r.FirstPointLayer]);var Ce=15,te=class{props;#e;#t;constructor(e){this.props=e,this.#e=null,this.#t=C(this.#n,Ce);}initBreakEvents=()=>{let{map:e}=this.props;e.on("click",r.LineLayerTransparent,this.#i),e.on("mouseenter",r.LineLayerTransparent,this.#t),e.on("mousemove",r.LineLayerTransparent,this.#t),e.on("mouseleave",r.LineLayerTransparent,this.#o);};removeBreakEvents=()=>{let{map:e}=this.props;e.off("click",r.LineLayerTransparent,this.#i),e.off("mouseenter",r.LineLayerTransparent,this.#t),e.off("mousemove",r.LineLayerTransparent,this.#t),e.off("mouseleave",r.LineLayerTransparent,this.#o);};hideBreakLine=()=>{let{map:e}=this.props;e.getLayoutProperty(r.LineLayerBreak,"visibility")!=="none"&&e.setLayoutProperty(r.LineLayerBreak,"visibility","none");};showBreakLine=()=>{let{map:e}=this.props;e.getLayoutProperty(r.LineLayerBreak,"visibility")!=="visible"&&e.setLayoutProperty(r.LineLayerBreak,"visibility","visible");};#i=()=>{let{store:e,mode:t,panel:i,map:n,tiles:s}=this.props,a=this.#e?.next?.val?.id;u.breakGeometry(e,a),e.tail?.val&&i.setPanelLocation({lat:e.tail?.val?.lat,lng:e.tail?.val?.lng}),this.#o(),n.setLayoutProperty(r.PolygonLayer,"visibility","none"),t.reset(),s.render(),m.onLineBreak(n);};#n=e=>{let{map:t,store:i}=this.props,n=me(e,i);n?.val?.id!==this.#e?.val?.id&&(this.#e=n);let s=t.getSource(p.LineSourceBreak),a=[n?.val?.lng,n?.val?.lat],c=[n?.next?.val?.lng,n?.next?.val?.lat],v=M.getLine(a,c);v&&(s.setData(v),this.showBreakLine());};#o=()=>{setTimeout(()=>{this.hideBreakLine();},Ce+10);}};var Te=10,ie=class{#e;#t;#i;#n;#o;#s;constructor(e){this.#e=e,this.#t=e.options.dynamicLine,this.#i=null,this.#n=null,this.#r(),this.#s=C(this.#p,Te);}#r(){this.#e.store.addObserver(this.#l),this.#e.mode.addObserver(this.#c),this.#e.mouseEvents.addObserver(this.#a);}removeLine=()=>{this.hideDynamicLine();};removeConsumers=()=>{this.#e.store.removeObserver(this.#l),this.#e.mode.removeObserver(this.#c),this.#e.mouseEvents.removeObserver(this.#a);};#a=e=>{let{mode:t}=this.#e;if(!t.getClosedGeometry()&&(e.type==="lastPointMouseClick"&&e.data?(this.hideDynamicLine(),this.#t=!1):e.type==="lastPointMouseClick"&&!e.data&&(this.#t=!0),!!this.#t&&((e.type==="pointMouseEnter"||e.type==="lineMouseEnter")&&e.data&&this.hideDynamicLine(),(e.type==="pointMouseLeave"||e.type==="lineMouseLeave")&&e.data))){let{store:i}=this.#e;this.#i=i.tail?.val,this.#n=i.tail?.val,this.showDynamicLine();}};#l=e=>{let{store:t}=this.#e;switch(e.type){case"STORE_CHANGED":e.data.tail?.val&&!u.isClosedGeometry(t)&&(this.#i=e.data.tail?.val,this.showDynamicLine());break;}};#c=e=>{let{store:t}=this.#e;e.type==="CLOSED_GEOMETRY_CHANGED"&&(e.data&&this.hideDynamicLine(),!e.data&&t?.tail?.val&&(this.#i=t?.tail?.val,this.showDynamicLine()));};initDynamicEvents=()=>{let{map:e}=this.#e;e.on("click",this.#f),e.on("mousemove",this.#s),e.on(f.REMOVEALL,this.hideDynamicLine),e.on(f.UNDO,this.#m),e.on(f.DOUBLECLICK,this.#v);};removeEvents=()=>{let{map:e}=this.#e;e.off("click",this.#f),e.off("mousemove",this.#s),e.off(f.REMOVEALL,this.hideDynamicLine),e.off(f.UNDO,this.#m),e.off(f.DOUBLECLICK,this.#v);};hideDynamicLine=()=>{let{map:e,tiles:t}=this.#e;this.#i=null,this.#n=null,this.#o=null,e.off("mousemove",this.#s),t.renderLines(W,p.LineDynamicSource),e.setLayoutProperty(r.LineDynamicLayer,"visibility","none");};showDynamicLine=()=>{let{map:e}=this.#e,t=[this.#i?.lng,this.#i?.lat],i=[this.#n?.lng,this.#n?.lat];this.#o=M.getLine(t,i),e.setLayoutProperty(r.LineDynamicLayer,"visibility","visible"),this.#n&&this.#h({lng:this.#n?.lng,lat:this.#n?.lat}),e.on("mousemove",this.#s);};#h=e=>{if(!this.#o)return;let{tiles:t}=this.#e;this.#o.features[0].geometry.coordinates[1]=[e.lng,e.lat],t.renderLines(this.#o,p.LineDynamicSource);};#p=e=>{this.#h(e.lngLat);};#f=e=>{let{mode:t}=this.#e,i=y.isFeatureTriggered(e,[r.LineLayerTransparent,r.LineLayer]);i&&t.getBreak()&&(this.#n={lng:e.lngLat.lng,lat:e.lngLat.lat}),!i&&this.hideDynamicLine();};#m=e=>{let{store:t,mode:i}=this.#e;if(!i.getClosedGeometry()){let n=e.target.unproject({x:e.originalEvent.x,y:e.originalEvent.y});this.#n={lng:n.lng,lat:n.lat},this.#i=t.tail?.val,this.showDynamicLine();}};#v=e=>{let{store:t,mode:i}=this.#e;i.getClosedGeometry()||(this.#n={lng:e.coordinates.lng,lat:e.coordinates.lat},this.#i=t.tail?.val,this.showDynamicLine());}};var we=22,ne=class{props;#e;#t;constructor(e){this.props=e,this.#e=!1,this.#t=null;}initEvents(){let{map:e}=this.props;e.on("click",r.LineLayerTransparent,this.#i),e.on("mousemove",r.LineLayerTransparent,this.#o),e.on("mouseenter",r.LineLayerTransparent,this.#s),e.on("mouseleave",r.LineLayerTransparent,this.#r);}removeEvents(){let{map:e}=this.props;e.off("click",r.LineLayerTransparent,this.#i),e.off("mousemove",r.LineLayerTransparent,this.#o),e.off("mouseenter",r.LineLayerTransparent,this.#s),e.off("mouseleave",r.LineLayerTransparent,this.#r);}#i=e=>{let{store:t,map:i,mode:n}=this.props;if(_e(e))return;let s=Me(e,t);s&&(m.addPoint({...s,total:t.size},i,n),be(e,this.props));};#n=e=>{E.setSinglePointVisible(e),e.target.getLayer(r.SinglePointLayer)&&E.updatePointsData(e);};#o=C(e=>{if(y.isFeatureTriggered(e,[r.PointsLayer,r.FirstPointLayer]))return;let{mouseEvents:t}=this.props;t.pointMouseDown||t.pointMouseEnter||(this.#t=e,!this.#e&&(this.#e=!0,requestAnimationFrame(()=>{this.#t&&(this.#n(this.#t),this.#e=!1);})));},we);#s=e=>{let{mouseEvents:t}=this.props;t.pointMouseDown||t.pointMouseEnter||y.isFeatureTriggered(e,[r.PointsLayer,r.FirstPointLayer])||(t.lineMouseEnter=!0,E.setSinglePointVisible(e));};#r=e=>{let{mouseEvents:t}=this.props;t.pointMouseDown||t.pointMouseEnter||(t.lineMouseLeave=!0,E.setSinglePointHidden(e));}};var oe=class{props;#e;#t;#i;#n;constructor(e){this.props=e,this.#e=new te(e),this.#t=new ne(e),this.#i=null,this.#n="default";}init(){this.#o(),this.#s(),this.#r();}#o=()=>{window.innerWidth<=768||this.props.options.dynamicLine&&(this.#i=new ie(this.props));};#s(){!this.props.mode.getBreak()&&(this.#t.initEvents(),this.props.options.dynamicLine&&this.#i?.initDynamicEvents());}#r(){this.props.mode.addObserver(this.#h),this.props.mouseEvents.addObserver(this.#c);}remove(){this.#a(),this.#l();}#a(){this.props.mode.removeObserver(this.#h),this.props.mouseEvents.removeObserver(this.#c),this.props.options.dynamicLine&&this.#i?.removeConsumers();}#l(){this.#e.removeBreakEvents(),this.#t.removeEvents(),this.props.options.dynamicLine&&(this.#i?.removeEvents(),this.#i?.removeLine());}#c=e=>{let{type:t,data:i}=e,{mode:n}=this.props;if(!(!i||!n.getBreak()))switch(t){case"pointMouseDown":this.#e.removeBreakEvents(),this.#e.hideBreakLine();break;case"pointMouseUp":this.#e.initBreakEvents();break;}};#h=e=>{let{type:t,data:i}=e;t==="MODE_CHANGED"&&this.#n==="break"&&(this.#e.removeBreakEvents(),this.#t.initEvents(),this.#n="default"),t==="BREAK_CHANGED"&&i&&this.#n==="default"&&(this.#t.removeEvents(),this.#e.initBreakEvents(),this.#n="break");}};var se=class{#e;#t;#i;constructor(e){this.#t=e,this.#e=!1,this.#i=new S,e.mode.addObserver(this.#n);}initEvents(){let{map:e}=this.#t;e.on("click",r.FirstPointLayer,this.#o),e.on("mouseenter",r.FirstPointLayer,this.#c),e.on("mouseleave",r.FirstPointLayer,this.#a),e.on("mouseup",r.FirstPointLayer,this.#r),e.on("mousedown",r.FirstPointLayer,this.#s);}removeEvents(){let{map:e}=this.#t;e.off("click",r.FirstPointLayer,this.#o),e.off("mouseenter",r.FirstPointLayer,this.#c),e.off("mouseleave",r.FirstPointLayer,this.#a),e.off("mouseup",r.FirstPointLayer,this.#r);}#n=e=>{let{map:t,store:i}=this.#t,{type:n,data:s}=e;n==="MODE_CHANGED"&&(s==="line"||s==="polygon"?t.on("click",r.FirstPointLayer,this.#o):t.off("click",r.FirstPointLayer,this.#o),u.canCloseGeometry(i)&&L.togglePointCircleRadius(t,"large"));};#o=()=>{let{store:e,map:t,mode:i,tiles:n}=this.#t;if(i.getMode()==="polygon"&&t.setLayoutProperty(r.PolygonLayer,"visibility","visible"),u.canCloseGeometry(e)){u.closeGeometry(e,i);let s=Object.assign({},e.head?.val,{id:b(),total:e.size});m.addPoint(s,t,i),L.togglePointCircleRadius(t,"default"),n.render();}};#s=()=>{this.#e=!0,this.#i.remove();};#r=()=>{this.#e=!1;};#a=()=>{let{mouseEvents:e}=this.#t;this.#e||(e.firstPointMouseLeave=!0,this.#i.remove());};#l=()=>{let{mode:e,options:t}=this.#t;return e.getMode()==="line"&&t.modes.line.closeGeometry?t.locale.closeLine:e.getMode()==="polygon"?t.locale.createPolygon:""};#c=e=>{let{mode:t,mouseEvents:i,store:n}=this.#t;if(!(t.getClosedGeometry()||this.#e)&&(i.firstPointMouseEnter=!0,u.canCloseGeometry(n))){let{x:s,y:a}=e.originalEvent;if(s&&a){this.#i.create({label:this.#l(),placement:"bottom"});let v=this.#i._label?this.#i._label.clientWidth/2:0;this.#i.setPosition({x:s-v,y:a+14});}}}};var re=class{#e;#t;#i;#n;#o;#s;#r;#a;constructor(e){this.#e=e,this.#t=void 0,this.#i=null,this.#n=null,this.#o=null,this.#s=new se(e),this.#r=!1,this.#a=null;}#l=()=>{let{map:e}=this.#e;e.on("click",r.FirstPointLayer,this.#p),e.on("mouseenter",r.FirstPointLayer,this.#L),e.on("mouseleave",r.FirstPointLayer,this.#g),e.on("mousedown",r.FirstPointLayer,this.#d),e.on("mouseup",r.FirstPointLayer,this.#u),e.on("touchend",r.FirstPointLayer,this.#u),e.on("touchstart",r.FirstPointLayer,this.#d),this.#s.initEvents();};initEvents=()=>{let{map:e}=this.#e;e.on("click",this.#m),e.on("dblclick",this.#h),e.on("click",r.PointsLayer,this.#p),e.on("mouseenter",r.PointsLayer,this.#L),e.on("mouseleave",r.PointsLayer,this.#g),e.on("mousedown",r.PointsLayer,this.#d),e.on("mouseup",r.PointsLayer,this.#u),e.on("touchend",r.PointsLayer,this.#u),e.on("touchstart",r.PointsLayer,this.#d),this.#l();};#c=()=>{let{map:e}=this.#e;e.off("click",r.FirstPointLayer,this.#p),e.off("mouseenter",r.FirstPointLayer,this.#L),e.off("mouseleave",r.FirstPointLayer,this.#g),e.off("mousedown",r.FirstPointLayer,this.#d),e.off("mouseup",r.FirstPointLayer,this.#u),e.off("touchend",r.PointsLayer,this.#u),e.off("touchstart",r.PointsLayer,this.#d),this.#s.removeEvents();};removeEvents=()=>{let{map:e}=this.#e;e.off("click",this.#m),e.off("dblclick",this.#h),e.off("mousemove",this.#y),e.off("click",r.PointsLayer,this.#p),e.off("mouseenter",r.PointsLayer,this.#L),e.off("mouseleave",r.PointsLayer,this.#g),e.off("mousedown",r.PointsLayer,this.#d),e.off("mouseup",r.PointsLayer,this.#u),this.#c();};#h=e=>{e.preventDefault();};#p=e=>{let{store:t,tiles:i,panel:n,map:s,mouseEvents:a}=this.#e;L.isDoubleClick()&&this.#n&&(t.removeStepById(this.#n.id),n.onPointRemove(t.tail?.val),m.pointDoubleClick({...this.#n,total:t.size},this.#e.map),u.switchToLineModeIfCan(this.#e));let c=y.queryPointId(s,e.point);P.isLastPoint(t,c)&&(a.lastPointMouseClick=!0,a.lastPointMouseUp=!1),i.render();};#f=e=>y.isFeatureTriggered(e,[r.PointsLayer,r.FirstPointLayer,r.LineLayerTransparent,r.LineLayerBreak]);#m=e=>{let{mode:t,mouseEvents:i,map:n}=this.#e;t.getClosedGeometry()||this.#f(e)||(i.lastPointMouseClick&&(i.lastPointMouseClick=!1),n.getCanvasContainer().style.cursor="grab",E.addPointToMap(e,this.#e),E.setSinglePointHidden(e));};#v=e=>{e.originalEvent.buttons===0&&this.#u();};#E=e=>{let{tiles:t}=this.#e;t.renderOnMouseMove(this.#o,e.lngLat);};#y=C(e=>{this.#a=e,this.#r||(this.#r=!0,requestAnimationFrame(()=>{!this.#n||!this.#a||(E.updateSelectedStepLatLng(this.#a,this.#n),this.#v(this.#a),this.#E(this.#a),this.#r=!1);}));},15);#L=e=>{let{mouseEvents:t,map:i,store:n}=this.#e;if(t&&(t.pointMouseEnter=!0,t.pointMouseDown))return;E.setSinglePointHidden(e);let s=y.queryPointId(i,e.point);P.isLastPoint(n,s)&&(t.lastPointMouseEnter=!0,t.lastPointMouseLeave=!1);let a=n.findStepById(s);a&&(this.#i=a,m.enterPoint(Object.assign({},a,{total:n.size}),i));};#g=e=>{let{mouseEvents:t,store:i,map:n}=this.#e;if(t&&(t.pointMouseEnter=!1,e.originalEvent.buttons===0&&(t.pointMouseLeave=!0),t.pointMouseDown))return;let s=y.queryPointId(n,e.point);P.isLastPoint(i,s)&&(t.lastPointMouseEnter=!1,t.lastPointMouseLeave=!0),m.leavePoint(Object.assign({},this.#i,{total:i.size}),n);};#P=()=>{let{store:e,panel:t}=this.#e;this.#n&&P.isLastPoint(e,this.#n.id)&&t.hidePanel();};#M=e=>{let{store:t,map:i}=this.#e,n=y.queryPointId(i,e.point),s=t.findStepById(n);s&&(this.#n=s);};#d=e=>{e.preventDefault();let{mouseEvents:t,map:i,store:n}=this.#e;L.removeTransparentLine(i),this.#M(e),this.#P();let s=y.queryPointId(i,e.point);this.#o=u.getGeometryIndex(n,s),t&&(t.pointMouseDown=!0),this.#t=e.lngLat,i.on("mousemove",this.#y),i.on("touchmove",this.#y);};#u=()=>{let{mouseEvents:e,store:t,panel:i,map:n,options:s}=this.#e;e.pointMouseUp=!0,this.#n&&(P.isLastPoint(t,this.#n.id)&&t.tail?.val&&i?.setPanelLocation(t.tail.val),i?.showPanel(),m.movePoint({id:this.#n.id,total:t.size,end:{lat:this.#n.lat,lng:this.#n.lng},start:this.#t},n)),e&&(e.pointMouseDown=!1),L.addTransparentLine(n,s),n.off("mousemove",this.#y),n.off("touchmove",this.#y);}};var ae=class extends N{#e;#t;#i;#n;#o;constructor(e){super({...e}),this.#e=e,this.#t=new ee(e),this.#i=new X(e),this.#n=new re(e),this.#o=new oe(e),e.map.on("mode:initialize",this.#s),e.map.on("mode:remove",this.#r);}#s=()=>{this.#o.init(),this.#t?.initEvents(),this.#n?.initEvents();};#r=()=>{this.#t?.removeEvents(),this.#n?.removeEvents(),this.#o?.remove();};removeMapEventsAndConsumers=()=>{this.#t?.removeEvents(),this.#n?.removeEvents(),this.#i?.remove(),this.#o?.remove(),this.#e.map.off("mode:initialize",this.#s);}};var le=class{#e;_line;_polygon;_break;_container;constructor(e){this.#e=e.options,this._line=void 0,this._polygon=void 0,this._break=void 0,this._container=l.create("div","mapboxgl-ctrl mapboxgl-ctrl-group maplibregl-ctrl maplibregl-ctrl-group"),this.createControl(e);}createControlButton=(e,t,i,n)=>{let s=this.#e.panel.size,a=l.create("button",`control-button control-button-${s}`,this._container);return a.setAttribute("aria-label",t),a.setAttribute("data-type",e),i&&a.classList.add("control-button-active"),n&&(a.setAttribute("disabled","true"),a.setAttribute("aria-disabled","true")),l.create("span",`icon ${e} icon-${s}`,a),a};#t=e=>{let{mode:t,options:i}=e,n=this.#e.modes.line.visible,s=i.locale.line;n&&(this._line=this.createControlButton("line",s,t.getMode()==="line"));};#i=e=>{let{mode:t,options:i}=e,n=this.#e.modes.polygon.visible,s=i.locale.polygon;n&&(this._polygon=this.createControlButton("polygon",s,t.getMode()==="polygon"));};#n=e=>{let{mode:t,options:i}=e,n=this.#e.modes.breakGeometry.visible,s=i.locale.break;if(n){let c=!this.#e?.initial?.closeGeometry,v=t.getBreak();this._break=this.createControlButton("break",s,v,c);}};createControl=e=>{this.#t(e),this.#i(e),this.#n(e);};getContainer=()=>this._container};function De(o){return o.initial?.geometry?o.initial?.geometry:o.modes.initial?o.modes.initial:null}var ce=class extends O{#e;#t;#i;constructor(e){super(),this.#e=De(e),this.#t=!1,this.#i=e.initial?.closeGeometry??!1;}getMode=()=>this.#e;setMode=e=>{this.#e=e,this.setBreak(!1),this.notify({type:"MODE_CHANGED",data:e});};getBreak=()=>this.#t;setBreak=e=>{this.#t=e,this.notify({type:"BREAK_CHANGED",data:e});};getClosedGeometry=()=>this.#i;setClosedGeometry=e=>{this.#i=e,this.notify({type:"CLOSED_GEOMETRY_CHANGED",data:this.#i});};isPolygon=()=>this.#e==="polygon"&&this.#i;reset=()=>{this.setMode(this.getMode()),this.setClosedGeometry(!1);};pingConsumers=()=>{this.notify({type:"MODE_CHANGED",data:this.getMode()}),this.notify({type:"CLOSED_GEOMETRY_CHANGED",data:this.getClosedGeometry()});}};var he=class{#e;#t;constructor(e){this.#e=e,this.#t=this.#e.map.getCanvasContainer(),this.#t.style.cursor=e.mode.getMode()?g.CROSSHAIR:g.AUTO,this.#i();}set=e=>{this.#t.style.cursor=e;};get=()=>this.#t.style.cursor;handleMouseLeave=()=>{let{mouseEvents:e,mode:t}=this.#e;if(!e.pointMouseDown){if(!t.getMode()){this.set(g.AUTO);return}t.getClosedGeometry()?this.set(g.AUTO):this.set(g.CROSSHAIR);}};handleFirstPointMouseEnter=()=>{let{mode:e,store:t}=this.#e;e.getClosedGeometry()&&this.set(g.MOVE),u.canCloseGeometry(t)&&this.set(g.POINTER);};#i(){let{mouseEvents:e}=this.#e;e.addObserver(this.#n);}removeConsumers(){let{mouseEvents:e}=this.#e;e.removeObserver(this.#n);}#n=e=>{let{mode:t,mouseEvents:i}=this.#e;if(t.getBreak())return;let{type:n,data:s}=e;if(s)switch(n){case"pointMouseDown":this.set(g.GRABBING);break;case"pointMouseUp":this.set(g.GRAB);break;case"pointMouseEnter":if(i.pointMouseDown)return;this.set(g.GRAB);break;case"pointMouseLeave":this.handleMouseLeave();break;case"lineMouseEnter":if(i.pointMouseDown)return;this.set(g.POINTER);break;case"lineMouseLeave":this.handleMouseLeave();break;case"firstPointMouseEnter":this.handleFirstPointMouseEnter();break;case"firstPointMouseLeave":this.handleMouseLeave();break;case"lastPointMouseEnter":this.set(g.POINTER);break;case"lastPointMouseLeave":this.handleMouseLeave();break;}}};var pe=class extends O{#e;#t;#i;#n;#o;#s;#r;#a;#l;#c;#h;#p;constructor(){super(),this.#e=!1,this.#t=!1,this.#i=!1,this.#n=!1,this.#o=!1,this.#s=!1,this.#r=!1,this.#a=!1,this.#l=!1,this.#c=!1,this.#h=!1,this.#p=!1;}get firstPointMouseEnter(){return this.#e}set firstPointMouseEnter(e){this.#e=e,this.notify({type:"firstPointMouseEnter",data:e});}get firstPointMouseLeave(){return this.#t}set firstPointMouseLeave(e){this.#t=e,this.notify({type:"firstPointMouseLeave",data:e});}get lastPointMouseClick(){return this.#i}set lastPointMouseClick(e){this.#i=e,this.notify({type:"lastPointMouseClick",data:e});}get lastPointMouseUp(){return this.#n}set lastPointMouseUp(e){this.#n=e,this.notify({type:"lastPointMouseUp",data:e});}get lastPointMouseEnter(){return this.#o}set lastPointMouseEnter(e){this.#o=e,this.notify({type:"lastPointMouseEnter",data:e});}get lastPointMouseLeave(){return this.#s}set lastPointMouseLeave(e){this.#s=e,this.notify({type:"lastPointMouseLeave",data:e});}get pointMouseDown(){return this.#r}set pointMouseDown(e){this.#r=e,this.notify({type:"pointMouseDown",data:e});}get pointMouseUp(){return this.#a}set pointMouseUp(e){this.#a=e,this.notify({type:"pointMouseUp",data:e});}get pointMouseEnter(){return this.#l}set pointMouseEnter(e){this.#l=e,this.notify({type:"pointMouseEnter",data:e});}get pointMouseLeave(){return this.#c}set pointMouseLeave(e){this.#c=e,this.notify({type:"pointMouseLeave",data:e});}get lineMouseEnter(){return this.#h}set lineMouseEnter(e){this.#h=e,this.notify({type:"lineMouseEnter",data:e});}get lineMouseLeave(){return this.#p}set lineMouseLeave(e){this.#p=e,this.notify({type:"lineMouseLeave",data:e});}};var U=class{static allStepsHaveIds(e){return e.every(t=>"id"in t&&t.id!==void 0)}static checkIfMissingIds(e,t){let i=!t,n=!this.allStepsHaveIds(e);if(i&&n)throw new Error(F.MISSING_IDS)}static checkIfEnoughPointsToClose(e,t){if(t&&e.length<3)throw new Error(F.NOT_ENOUGH_POINTS_TO_CLOSE)}static checkIfPolygonIsClosed(e){let{closeGeometry:t,steps:i}=e;if(i){let n=i[0]?.lng,s=i[i.length-1]?.lng,a=i[0]?.lat,c=i[i.length-1]?.lat;if((n!==s||a!==c)&&t)throw new Error(F.FIRST_LAST_POINT_NOT_EQUAL)}}static checkInitialStepsOption(e){let{closeGeometry:t,generateId:i,steps:n}=e;this.checkIfMissingIds(n,i),this.checkIfEnoughPointsToClose(n,t),this.checkIfPolygonIsClosed(e);}static init(e){return e?{panel:Ae(e),modes:Ie(e),layersPaint:Be(e),initial:e.initial||d.initial,locale:Ne(e),dynamicLine:e.dynamicLine??d.dynamicLine}:d}};function Ae(o){return {size:o.panel?.size||d.panel.size,buttons:{undo:{visible:o.panel?.buttons?.undo?.visible??d.panel.buttons.undo.visible},delete:{visible:o.panel?.buttons?.delete?.visible??d.panel.buttons.delete.visible},save:{visible:o.panel?.buttons?.save?.visible??d.panel.buttons.save.visible,clearOnSave:o.panel?.buttons?.save?.clearOnSave??d.panel.buttons.save.clearOnSave}}}}function Ie(o){return {initial:o.modes?.initial||d.modes.initial,line:{visible:o?.modes?.line?.visible!==void 0?o.modes.line.visible:o?.initial?.geometry==="line"||d.modes.line.visible,closeGeometry:o?.modes?.line?.closeGeometry??o?.initial?.closeGeometry??d.modes.line.closeGeometry},polygon:{visible:o?.modes?.polygon?.visible!==void 0?o.modes.polygon.visible:o?.initial?.geometry==="polygon"||d.modes.polygon.visible},breakGeometry:{visible:o?.modes?.breakGeometry?.visible??d.modes.breakGeometry.visible}}}function Be(o){return {onLinePoint:{"circle-radius":o.layersPaint?.onLinePoint?.["circle-radius"]||T["circle-radius"],"circle-color":o.layersPaint?.onLinePoint?.["circle-color"]||T["circle-color"],"circle-stroke-color":o.layersPaint?.onLinePoint?.["circle-stroke-color"]||T["circle-stroke-color"],"circle-stroke-width":o.layersPaint?.onLinePoint?.["circle-stroke-width"]||T["circle-stroke-width"],...o.layersPaint?.onLinePoint},firstPoint:{"circle-radius":o.layersPaint?.firstPoint?.["circle-radius"]||x["circle-radius"],"circle-color":o.layersPaint?.firstPoint?.["circle-color"]||x["circle-color"],"circle-stroke-color":o.layersPaint?.firstPoint?.["circle-stroke-color"]||x["circle-stroke-color"],"circle-stroke-width":o.layersPaint?.firstPoint?.["circle-stroke-width"]||x["circle-stroke-width"],...o.layersPaint?.firstPoint},points:{"circle-radius":o.layersPaint?.points?.["circle-radius"]||w["circle-radius"],"circle-color":o.layersPaint?.points?.["circle-color"]||w["circle-color"],"circle-stroke-color":o.layersPaint?.points?.["circle-stroke-color"]||w["circle-stroke-color"],"circle-stroke-width":o.layersPaint?.points?.["circle-stroke-width"]||w["circle-stroke-width"],...o.layersPaint?.points},line:{"line-width":o.layersPaint?.line?.["line-width"]||I["line-width"],"line-color":o.layersPaint?.line?.["line-color"]||I["line-color"],"line-opacity":o.layersPaint?.line?.["line-opacity"]||I["line-opacity"],...o.layersPaint?.line},polygon:{"fill-color":o.layersPaint?.polygon?.["fill-color"]||G["fill-color"],"fill-opacity":o.layersPaint?.polygon?.["fill-opacity"]||G["fill-opacity"],...o.layersPaint?.polygon},breakLine:{"line-width":o.layersPaint?.breakLine?.["line-width"]||B["line-width"],"line-color":o.layersPaint?.breakLine?.["line-color"]||B["line-color"],"line-dasharray":o.layersPaint?.breakLine?.["line-dasharray"]||B["line-dasharray"],...o.layersPaint?.breakLine}}}function Ne(o){return {save:o.locale?.save??d.locale.save,delete:o.locale?.delete??d.locale.delete,undo:o.locale?.undo??d.locale.undo,line:o.locale?.line??d.locale.line,polygon:o.locale?.polygon??d.locale.polygon,break:o.locale?.break??d.locale.break,closeLine:o.locale?.closeLine??d.locale.closeLine,createPolygon:o.locale?.createPolygon??d.locale.createPolygon}}var ye=class o{#e;#t;#i;#n;#o;#s;#r;#a;#l;static#c=null;static#h=!1;constructor(e){if(this.#n=U.init(e),this.#n.initial&&U.checkInitialStepsOption(this.#n.initial),o.#h)throw new Error("Use 'DrawLibre.getInstance()' instead of 'new DrawLibre()'.");o.#h=!0,this.#t=void 0,this.#i=void 0,this.#o=void 0,this.#s=void 0,this.#r=void 0,this.#l=void 0,this.#a=void 0;}static getInstance(e){return o.#c||(o.#c=new o(e)),o.#c}onAdd(e){this.#t=new H(this.#n),this.#i=new ce(this.#n),this.#r=new Y({map:e,mode:this.#i,options:this.#n,store:this.#t}),this.#s=new N({map:e,store:this.#t,options:this.#n,mode:this.#i});let t=new le({options:this.#n,mode:this.#i});return this.#l=new pe,this.#a=new he({map:e,mode:this.#i,mouseEvents:this.#l,store:this.#t}),this.#o=new ae({map:e,store:this.#t,options:this.#n,panel:this.#r,control:t,mode:this.#i,tiles:this.#s,mouseEvents:this.#l}),this.#i.getMode()&&e.fire("mode:initialize"),this.#i.pingConsumers(),this.#e=t.getContainer(),this.#e}onRemove(){this.#a?.removeConsumers(),this.#s?.removeTiles(),this.#o?.removeMapEventsAndConsumers(),this.#r?.removePanel(),this.#t?.reset(),this.#i?.unsubscribe(),this.#e&&l.remove(this.#e);}setSteps=e=>{if(Array.isArray(e))e.forEach(t=>{let i={...t,id:t.id||b()};this.#t?.push(i);});else throw new Error("Invalid argument. Expected an array of steps.");this.#s?.render();};findStepById=e=>this.#t?.findStepById(e);getAllSteps=(e="array")=>{if(e==="array"&&this.#t)return P.toArray(this.#t.head);if(e==="linkedlist")return this.#t;throw new Error("Invalid type specified. Use 'array' or 'linkedlist'.")};setOptions=e=>{this.#n=e(this.#n);};removeAllSteps=()=>{this.#t?.reset(),this.#r?.removePanel(),this.#s?.render();}};
5
-
6
- return ye;
7
-
8
- })();