draw-libre 0.4.0 → 0.4.1

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,2 +1,2 @@
1
- .undo{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='lucide lucide-undo-icon lucide-undo'%3E%3Cpath d='M3 7v6h6'/%3E%3Cpath d='M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13'/%3E%3C/svg%3E")}.redo{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='lucide lucide-redo-icon lucide-redo'%3E%3Cpath d='M21 7v6h-6'/%3E%3Cpath d='M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7'/%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;background-color:#fff;border-radius:4px}.dashboard-container{position:absolute;z-index:1000000;pointer-events:auto}.dashboard-container.hidden{opacity:0;pointer-events:none}.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:disabled{opacity:.25;cursor:not-allowed}.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}.hide-panel{visibility:hidden}.popup-container{display:block;position:absolute;z-index:1000;pointer-events:none;top:0;left:0}.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{transform:rotate(44deg);background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:svg='http://www.w3.org/2000/svg' xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns%23' xmlns:cc='http://creativecommons.org/ns%23' xmlns:dc='http://purl.org/dc/elements/1.1/' fill='%23000000' width='10' height='16' viewBox='-3 0 0.22850401 0.63333199' version='1.1' id='svg1' xml:space='preserve'%3E%3Cdefs id='defs1'/%3E%3Ctitle id='title1'%3Eline-chart%3C/title%3E%3Cmetadata id='metadata1'%3E%3Crdf:RDF%3E%3Ccc:Work rdf:about=''%3E%3Cdc:title%3Eline-chart%3C/dc:title%3E%3C/cc:Work%3E%3C/rdf:RDF%3E%3C/metadata%3E%3Cg style='fill:none' id='g1' transform='matrix(0.04,0,0,0.04,-3.48332,-0.48336)'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='m 14.9997,12.084 c -1.6109,0 -2.9167,1.3058 -2.9167,2.9167 0,1.3212 0.8786,2.4373 2.0833,2.7958 v 4.4083 c -1.2047,0.3585 -2.0833,1.4746 -2.0833,2.7959 0,1.6108 1.3058,2.9166 2.9167,2.9166 1.3212,0 2.4373,-0.8785 2.7959,-2.0833 V 14.1673 C 17.437,12.9625 16.3209,12.084 14.9997,12.084 Z m -1.25,2.9167 c 0,-0.6904 0.5596,-1.25 1.25,-1.25 0.6903,0 1.25,0.5596 1.25,1.25 0,0.6903 -0.5597,1.25 -1.25,1.25 -0.6904,0 -1.25,-0.5597 -1.25,-1.25 z m 2.0833,7.2041 c 0.9407,0.2799 1.6826,1.0218 1.9626,1.9625 V 15.834 c -0.28,0.9407 -1.0219,1.6826 -1.9626,1.9625 z m -0.8333,1.5459 c -0.6904,0 -1.25,0.5596 -1.25,1.25 0,0.6903 0.5596,1.25 1.25,1.25 0.6903,0 1.25,-0.5597 1.25,-1.25 0,-0.6904 -0.5597,-1.25 -1.25,-1.25 z' fill='%2315181a' id='path1'/%3E%3C/g%3E%3C/svg%3E")}.polygon{background-image:url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M4.99967 2.08398C3.38884 2.08398 2.08301 3.38982 2.08301 5.00065C2.08301 6.32191 2.96155 7.43797 4.16634 7.79654L4.16634 12.2048C2.96155 12.5633 2.08301 13.6794 2.08301 15.0007C2.08301 16.6115 3.38884 17.9173 4.99967 17.9173C6.32093 17.9173 7.437 17.0388 7.79556 15.834H12.2038C12.5624 17.0388 13.6784 17.9173 14.9997 17.9173C16.6105 17.9173 17.9163 16.6115 17.9163 15.0007C17.9163 13.6794 17.0378 12.5633 15.833 12.2048V7.79653C17.0378 7.43797 17.9163 6.32191 17.9163 5.00065C17.9163 3.38982 16.6105 2.08398 14.9997 2.08398C13.6784 2.08398 12.5624 2.96253 12.2038 4.16732L7.79556 4.16732C7.437 2.96253 6.32093 2.08398 4.99967 2.08398ZM3.74967 5.00065C3.74967 4.31029 4.30932 3.75065 4.99967 3.75065C5.69003 3.75065 6.24967 4.31029 6.24967 5.00065C6.24967 5.69101 5.69003 6.25065 4.99967 6.25065C4.30932 6.25065 3.74967 5.69101 3.74967 5.00065ZM5.83301 12.2048C6.77375 12.4847 7.51558 13.2266 7.79556 14.1673L12.2038 14.1673C12.4838 13.2266 13.2256 12.4847 14.1663 12.2048L14.1663 7.79654C13.2256 7.51656 12.4838 6.77473 12.2038 5.83398L7.79556 5.83398C7.51558 6.77472 6.77375 7.51656 5.83301 7.79653L5.83301 12.2048ZM13.7497 5.00065C13.7497 4.31029 14.3093 3.75065 14.9997 3.75065C15.69 3.75065 16.2497 4.31029 16.2497 5.00065C16.2497 5.69101 15.69 6.25065 14.9997 6.25065C14.3093 6.25065 13.7497 5.69101 13.7497 5.00065ZM4.99967 13.7507C4.30932 13.7507 3.74967 14.3103 3.74967 15.0007C3.74967 15.691 4.30932 16.2507 4.99967 16.2507C5.69003 16.2507 6.24967 15.691 6.24967 15.0007C6.24967 14.3103 5.69003 13.7507 4.99967 13.7507ZM13.7497 15.0007C13.7497 14.3103 14.3093 13.7507 14.9997 13.7507C15.69 13.7507 16.2497 14.3103 16.2497 15.0007C16.2497 15.691 15.69 16.2507 14.9997 16.2507C14.3093 16.2507 13.7497 15.691 13.7497 15.0007Z' fill='%2315181A'/%3E%3C/svg%3E%0A")}.break{background-image:url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4.16667 1.66602C4.6269 1.66602 5 2.03911 5 2.49935V5.83268H15V2.49935C15 2.03911 15.3731 1.66602 15.8333 1.66602C16.2936 1.66602 16.6667 2.03911 16.6667 2.49935V5.83268C16.6667 6.75316 15.9205 7.49935 15 7.49935H5C4.07953 7.49935 3.33333 6.75316 3.33333 5.83268V2.49935C3.33333 2.03911 3.70643 1.66602 4.16667 1.66602Z' fill='%2315181A'/%3E%3Cpath d='M4.16667 18.3327C4.6269 18.3327 5 17.9596 5 17.4993V14.166H15V17.4993C15 17.9596 15.3731 18.3327 15.8333 18.3327C16.2936 18.3327 16.6667 17.9596 16.6667 17.4993V14.166C16.6667 13.2455 15.9205 12.4993 15 12.4993H5C4.07953 12.4993 3.33333 13.2455 3.33333 14.166V17.4993C3.33333 17.9596 3.70643 18.3327 4.16667 18.3327Z' fill='%2315181A'/%3E%3Cpath d='M13.3333 9.16602H11.4583C10.9981 9.16602 10.625 9.53911 10.625 9.99935C10.625 10.4596 10.9981 10.8327 11.4583 10.8327H13.3333C13.7936 10.8327 14.1667 10.4596 14.1667 9.99935C14.1667 9.53911 13.7936 9.16602 13.3333 9.16602Z' fill='%2315181A'/%3E%3Cpath d='M8.54167 9.16602H6.66667C6.20643 9.16602 5.83333 9.53911 5.83333 9.99935C5.83333 10.4596 6.20643 10.8327 6.66667 10.8327H8.54167C9.0019 10.8327 9.375 10.4596 9.375 9.99935C9.375 9.53911 9.0019 9.16602 8.54167 9.16602Z' fill='%2315181A'/%3E%3Cpath d='M3.75 9.16601H2.08333C1.6231 9.16601 1.25 9.53911 1.25 9.99935C1.25 10.4596 1.6231 10.8327 2.08333 10.8327H3.75C4.21024 10.8327 4.58333 10.4596 4.58333 9.99935C4.58333 9.53911 4.21024 9.16601 3.75 9.16601Z' fill='%2315181A'/%3E%3Cpath d='M17.9167 9.16601H16.25C15.7898 9.16601 15.4167 9.53911 15.4167 9.99935C15.4167 10.4596 15.7898 10.8327 16.25 10.8327H17.9167C18.3769 10.8327 18.75 10.4596 18.75 9.99935C18.75 9.53911 18.3769 9.16601 17.9167 9.16601Z' fill='%2315181A'/%3E%3C/svg%3E%0A")}.control-button:first-child{border-top-left-radius:4px;border-top-right-radius:4px}.maplibregl-ctrl-group button.control-button-active{background-color:#edeaea}.control-button:disabled{opacity:.25}.maplibregl-popup-tip,.mapboxgl-popup-tip{display:none!important}.maplibregl-popup-content,.mapboxgl-popup-content{padding:0!important}
1
+ .popup-container{display:block;position:absolute;z-index:1000;pointer-events:none;top:0;left:0}.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}.undo{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='lucide lucide-undo-icon lucide-undo'%3E%3Cpath d='M3 7v6h6'/%3E%3Cpath d='M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13'/%3E%3C/svg%3E")}.redo{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='lucide lucide-redo-icon lucide-redo'%3E%3Cpath d='M21 7v6h-6'/%3E%3Cpath d='M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7'/%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;background-color:#fff;border-radius:4px}.dashboard-container{position:absolute;z-index:1000000;pointer-events:auto}.dashboard-container.hidden{opacity:0;pointer-events:none}.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:disabled{opacity:.25;cursor:not-allowed}.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}.hide-panel{visibility:hidden}.line{transform:rotate(44deg);background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:svg='http://www.w3.org/2000/svg' xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns%23' xmlns:cc='http://creativecommons.org/ns%23' xmlns:dc='http://purl.org/dc/elements/1.1/' fill='%23000000' width='10' height='16' viewBox='-3 0 0.22850401 0.63333199' version='1.1' id='svg1' xml:space='preserve'%3E%3Cdefs id='defs1'/%3E%3Ctitle id='title1'%3Eline-chart%3C/title%3E%3Cmetadata id='metadata1'%3E%3Crdf:RDF%3E%3Ccc:Work rdf:about=''%3E%3Cdc:title%3Eline-chart%3C/dc:title%3E%3C/cc:Work%3E%3C/rdf:RDF%3E%3C/metadata%3E%3Cg style='fill:none' id='g1' transform='matrix(0.04,0,0,0.04,-3.48332,-0.48336)'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='m 14.9997,12.084 c -1.6109,0 -2.9167,1.3058 -2.9167,2.9167 0,1.3212 0.8786,2.4373 2.0833,2.7958 v 4.4083 c -1.2047,0.3585 -2.0833,1.4746 -2.0833,2.7959 0,1.6108 1.3058,2.9166 2.9167,2.9166 1.3212,0 2.4373,-0.8785 2.7959,-2.0833 V 14.1673 C 17.437,12.9625 16.3209,12.084 14.9997,12.084 Z m -1.25,2.9167 c 0,-0.6904 0.5596,-1.25 1.25,-1.25 0.6903,0 1.25,0.5596 1.25,1.25 0,0.6903 -0.5597,1.25 -1.25,1.25 -0.6904,0 -1.25,-0.5597 -1.25,-1.25 z m 2.0833,7.2041 c 0.9407,0.2799 1.6826,1.0218 1.9626,1.9625 V 15.834 c -0.28,0.9407 -1.0219,1.6826 -1.9626,1.9625 z m -0.8333,1.5459 c -0.6904,0 -1.25,0.5596 -1.25,1.25 0,0.6903 0.5596,1.25 1.25,1.25 0.6903,0 1.25,-0.5597 1.25,-1.25 0,-0.6904 -0.5597,-1.25 -1.25,-1.25 z' fill='%2315181a' id='path1'/%3E%3C/g%3E%3C/svg%3E")}.polygon{background-image:url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M4.99967 2.08398C3.38884 2.08398 2.08301 3.38982 2.08301 5.00065C2.08301 6.32191 2.96155 7.43797 4.16634 7.79654L4.16634 12.2048C2.96155 12.5633 2.08301 13.6794 2.08301 15.0007C2.08301 16.6115 3.38884 17.9173 4.99967 17.9173C6.32093 17.9173 7.437 17.0388 7.79556 15.834H12.2038C12.5624 17.0388 13.6784 17.9173 14.9997 17.9173C16.6105 17.9173 17.9163 16.6115 17.9163 15.0007C17.9163 13.6794 17.0378 12.5633 15.833 12.2048V7.79653C17.0378 7.43797 17.9163 6.32191 17.9163 5.00065C17.9163 3.38982 16.6105 2.08398 14.9997 2.08398C13.6784 2.08398 12.5624 2.96253 12.2038 4.16732L7.79556 4.16732C7.437 2.96253 6.32093 2.08398 4.99967 2.08398ZM3.74967 5.00065C3.74967 4.31029 4.30932 3.75065 4.99967 3.75065C5.69003 3.75065 6.24967 4.31029 6.24967 5.00065C6.24967 5.69101 5.69003 6.25065 4.99967 6.25065C4.30932 6.25065 3.74967 5.69101 3.74967 5.00065ZM5.83301 12.2048C6.77375 12.4847 7.51558 13.2266 7.79556 14.1673L12.2038 14.1673C12.4838 13.2266 13.2256 12.4847 14.1663 12.2048L14.1663 7.79654C13.2256 7.51656 12.4838 6.77473 12.2038 5.83398L7.79556 5.83398C7.51558 6.77472 6.77375 7.51656 5.83301 7.79653L5.83301 12.2048ZM13.7497 5.00065C13.7497 4.31029 14.3093 3.75065 14.9997 3.75065C15.69 3.75065 16.2497 4.31029 16.2497 5.00065C16.2497 5.69101 15.69 6.25065 14.9997 6.25065C14.3093 6.25065 13.7497 5.69101 13.7497 5.00065ZM4.99967 13.7507C4.30932 13.7507 3.74967 14.3103 3.74967 15.0007C3.74967 15.691 4.30932 16.2507 4.99967 16.2507C5.69003 16.2507 6.24967 15.691 6.24967 15.0007C6.24967 14.3103 5.69003 13.7507 4.99967 13.7507ZM13.7497 15.0007C13.7497 14.3103 14.3093 13.7507 14.9997 13.7507C15.69 13.7507 16.2497 14.3103 16.2497 15.0007C16.2497 15.691 15.69 16.2507 14.9997 16.2507C14.3093 16.2507 13.7497 15.691 13.7497 15.0007Z' fill='%2315181A'/%3E%3C/svg%3E%0A")}.break{background-image:url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4.16667 1.66602C4.6269 1.66602 5 2.03911 5 2.49935V5.83268H15V2.49935C15 2.03911 15.3731 1.66602 15.8333 1.66602C16.2936 1.66602 16.6667 2.03911 16.6667 2.49935V5.83268C16.6667 6.75316 15.9205 7.49935 15 7.49935H5C4.07953 7.49935 3.33333 6.75316 3.33333 5.83268V2.49935C3.33333 2.03911 3.70643 1.66602 4.16667 1.66602Z' fill='%2315181A'/%3E%3Cpath d='M4.16667 18.3327C4.6269 18.3327 5 17.9596 5 17.4993V14.166H15V17.4993C15 17.9596 15.3731 18.3327 15.8333 18.3327C16.2936 18.3327 16.6667 17.9596 16.6667 17.4993V14.166C16.6667 13.2455 15.9205 12.4993 15 12.4993H5C4.07953 12.4993 3.33333 13.2455 3.33333 14.166V17.4993C3.33333 17.9596 3.70643 18.3327 4.16667 18.3327Z' fill='%2315181A'/%3E%3Cpath d='M13.3333 9.16602H11.4583C10.9981 9.16602 10.625 9.53911 10.625 9.99935C10.625 10.4596 10.9981 10.8327 11.4583 10.8327H13.3333C13.7936 10.8327 14.1667 10.4596 14.1667 9.99935C14.1667 9.53911 13.7936 9.16602 13.3333 9.16602Z' fill='%2315181A'/%3E%3Cpath d='M8.54167 9.16602H6.66667C6.20643 9.16602 5.83333 9.53911 5.83333 9.99935C5.83333 10.4596 6.20643 10.8327 6.66667 10.8327H8.54167C9.0019 10.8327 9.375 10.4596 9.375 9.99935C9.375 9.53911 9.0019 9.16602 8.54167 9.16602Z' fill='%2315181A'/%3E%3Cpath d='M3.75 9.16601H2.08333C1.6231 9.16601 1.25 9.53911 1.25 9.99935C1.25 10.4596 1.6231 10.8327 2.08333 10.8327H3.75C4.21024 10.8327 4.58333 10.4596 4.58333 9.99935C4.58333 9.53911 4.21024 9.16601 3.75 9.16601Z' fill='%2315181A'/%3E%3Cpath d='M17.9167 9.16601H16.25C15.7898 9.16601 15.4167 9.53911 15.4167 9.99935C15.4167 10.4596 15.7898 10.8327 16.25 10.8327H17.9167C18.3769 10.8327 18.75 10.4596 18.75 9.99935C18.75 9.53911 18.3769 9.16601 17.9167 9.16601Z' fill='%2315181A'/%3E%3C/svg%3E%0A")}.control-button:first-child{border-top-left-radius:4px;border-top-right-radius:4px}.maplibregl-ctrl-group button.control-button-active{background-color:#edeaea}.control-button:disabled{opacity:.25}.maplibregl-popup-tip,.mapboxgl-popup-tip{display:none!important}.maplibregl-popup-content,.mapboxgl-popup-content{padding:0!important}
2
2
  /*# sourceMappingURL=index.css.map */
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/panel/panel.css","../src/components/tooltip/tooltip.css","../src/components/side-control/control.css","../src/draw.css"],"sourcesContent":[".undo {\n background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='lucide lucide-undo-icon lucide-undo'%3E%3Cpath d='M3 7v6h6'/%3E%3Cpath d='M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13'/%3E%3C/svg%3E\");\n}\n\n.redo {\n background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='lucide lucide-redo-icon lucide-redo'%3E%3Cpath d='M21 7v6h-6'/%3E%3Cpath d='M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7'/%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 background-color: white;\n border-radius: 4px;\n}\n\n.dashboard-container {\n position: absolute;\n z-index: 1000000;\n pointer-events: auto;\n}\n\n.dashboard-container.hidden {\n opacity: 0;\n pointer-events: none;\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:disabled {\n opacity: 0.25;\n cursor: not-allowed;\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\n.hide-panel {\n visibility: hidden;\n}\n",".popup-container {\n display: block;\n position: absolute;\n z-index: 1000;\n pointer-events: none;\n top: 0;\n left: 0;\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 transform: rotate(44deg);\n background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:svg='http://www.w3.org/2000/svg' xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns%23' xmlns:cc='http://creativecommons.org/ns%23' xmlns:dc='http://purl.org/dc/elements/1.1/' fill='%23000000' width='10' height='16' viewBox='-3 0 0.22850401 0.63333199' version='1.1' id='svg1' xml:space='preserve'%3E%3Cdefs id='defs1'/%3E%3Ctitle id='title1'%3Eline-chart%3C/title%3E%3Cmetadata id='metadata1'%3E%3Crdf:RDF%3E%3Ccc:Work rdf:about=''%3E%3Cdc:title%3Eline-chart%3C/dc:title%3E%3C/cc:Work%3E%3C/rdf:RDF%3E%3C/metadata%3E%3Cg style='fill:none' id='g1' transform='matrix(0.04,0,0,0.04,-3.48332,-0.48336)'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='m 14.9997,12.084 c -1.6109,0 -2.9167,1.3058 -2.9167,2.9167 0,1.3212 0.8786,2.4373 2.0833,2.7958 v 4.4083 c -1.2047,0.3585 -2.0833,1.4746 -2.0833,2.7959 0,1.6108 1.3058,2.9166 2.9167,2.9166 1.3212,0 2.4373,-0.8785 2.7959,-2.0833 V 14.1673 C 17.437,12.9625 16.3209,12.084 14.9997,12.084 Z m -1.25,2.9167 c 0,-0.6904 0.5596,-1.25 1.25,-1.25 0.6903,0 1.25,0.5596 1.25,1.25 0,0.6903 -0.5597,1.25 -1.25,1.25 -0.6904,0 -1.25,-0.5597 -1.25,-1.25 z m 2.0833,7.2041 c 0.9407,0.2799 1.6826,1.0218 1.9626,1.9625 V 15.834 c -0.28,0.9407 -1.0219,1.6826 -1.9626,1.9625 z m -0.8333,1.5459 c -0.6904,0 -1.25,0.5596 -1.25,1.25 0,0.6903 0.5596,1.25 1.25,1.25 0.6903,0 1.25,-0.5597 1.25,-1.25 0,-0.6904 -0.5597,-1.25 -1.25,-1.25 z' fill='%2315181a' id='path1'/%3E%3C/g%3E%3C/svg%3E\");\n}\n\n.polygon {\n background-image: url(\"data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M4.99967 2.08398C3.38884 2.08398 2.08301 3.38982 2.08301 5.00065C2.08301 6.32191 2.96155 7.43797 4.16634 7.79654L4.16634 12.2048C2.96155 12.5633 2.08301 13.6794 2.08301 15.0007C2.08301 16.6115 3.38884 17.9173 4.99967 17.9173C6.32093 17.9173 7.437 17.0388 7.79556 15.834H12.2038C12.5624 17.0388 13.6784 17.9173 14.9997 17.9173C16.6105 17.9173 17.9163 16.6115 17.9163 15.0007C17.9163 13.6794 17.0378 12.5633 15.833 12.2048V7.79653C17.0378 7.43797 17.9163 6.32191 17.9163 5.00065C17.9163 3.38982 16.6105 2.08398 14.9997 2.08398C13.6784 2.08398 12.5624 2.96253 12.2038 4.16732L7.79556 4.16732C7.437 2.96253 6.32093 2.08398 4.99967 2.08398ZM3.74967 5.00065C3.74967 4.31029 4.30932 3.75065 4.99967 3.75065C5.69003 3.75065 6.24967 4.31029 6.24967 5.00065C6.24967 5.69101 5.69003 6.25065 4.99967 6.25065C4.30932 6.25065 3.74967 5.69101 3.74967 5.00065ZM5.83301 12.2048C6.77375 12.4847 7.51558 13.2266 7.79556 14.1673L12.2038 14.1673C12.4838 13.2266 13.2256 12.4847 14.1663 12.2048L14.1663 7.79654C13.2256 7.51656 12.4838 6.77473 12.2038 5.83398L7.79556 5.83398C7.51558 6.77472 6.77375 7.51656 5.83301 7.79653L5.83301 12.2048ZM13.7497 5.00065C13.7497 4.31029 14.3093 3.75065 14.9997 3.75065C15.69 3.75065 16.2497 4.31029 16.2497 5.00065C16.2497 5.69101 15.69 6.25065 14.9997 6.25065C14.3093 6.25065 13.7497 5.69101 13.7497 5.00065ZM4.99967 13.7507C4.30932 13.7507 3.74967 14.3103 3.74967 15.0007C3.74967 15.691 4.30932 16.2507 4.99967 16.2507C5.69003 16.2507 6.24967 15.691 6.24967 15.0007C6.24967 14.3103 5.69003 13.7507 4.99967 13.7507ZM13.7497 15.0007C13.7497 14.3103 14.3093 13.7507 14.9997 13.7507C15.69 13.7507 16.2497 14.3103 16.2497 15.0007C16.2497 15.691 15.69 16.2507 14.9997 16.2507C14.3093 16.2507 13.7497 15.691 13.7497 15.0007Z' fill='%2315181A'/%3E%3C/svg%3E%0A\");\n}\n\n.break {\n background-image: url(\"data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4.16667 1.66602C4.6269 1.66602 5 2.03911 5 2.49935V5.83268H15V2.49935C15 2.03911 15.3731 1.66602 15.8333 1.66602C16.2936 1.66602 16.6667 2.03911 16.6667 2.49935V5.83268C16.6667 6.75316 15.9205 7.49935 15 7.49935H5C4.07953 7.49935 3.33333 6.75316 3.33333 5.83268V2.49935C3.33333 2.03911 3.70643 1.66602 4.16667 1.66602Z' fill='%2315181A'/%3E%3Cpath d='M4.16667 18.3327C4.6269 18.3327 5 17.9596 5 17.4993V14.166H15V17.4993C15 17.9596 15.3731 18.3327 15.8333 18.3327C16.2936 18.3327 16.6667 17.9596 16.6667 17.4993V14.166C16.6667 13.2455 15.9205 12.4993 15 12.4993H5C4.07953 12.4993 3.33333 13.2455 3.33333 14.166V17.4993C3.33333 17.9596 3.70643 18.3327 4.16667 18.3327Z' fill='%2315181A'/%3E%3Cpath d='M13.3333 9.16602H11.4583C10.9981 9.16602 10.625 9.53911 10.625 9.99935C10.625 10.4596 10.9981 10.8327 11.4583 10.8327H13.3333C13.7936 10.8327 14.1667 10.4596 14.1667 9.99935C14.1667 9.53911 13.7936 9.16602 13.3333 9.16602Z' fill='%2315181A'/%3E%3Cpath d='M8.54167 9.16602H6.66667C6.20643 9.16602 5.83333 9.53911 5.83333 9.99935C5.83333 10.4596 6.20643 10.8327 6.66667 10.8327H8.54167C9.0019 10.8327 9.375 10.4596 9.375 9.99935C9.375 9.53911 9.0019 9.16602 8.54167 9.16602Z' fill='%2315181A'/%3E%3Cpath d='M3.75 9.16601H2.08333C1.6231 9.16601 1.25 9.53911 1.25 9.99935C1.25 10.4596 1.6231 10.8327 2.08333 10.8327H3.75C4.21024 10.8327 4.58333 10.4596 4.58333 9.99935C4.58333 9.53911 4.21024 9.16601 3.75 9.16601Z' fill='%2315181A'/%3E%3Cpath d='M17.9167 9.16601H16.25C15.7898 9.16601 15.4167 9.53911 15.4167 9.99935C15.4167 10.4596 15.7898 10.8327 16.25 10.8327H17.9167C18.3769 10.8327 18.75 10.4596 18.75 9.99935C18.75 9.53911 18.3769 9.16601 17.9167 9.16601Z' fill='%2315181A'/%3E%3C/svg%3E%0A\");\n}\n\n.control-button:first-child {\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n}\n\n/* otherwise if we just .control-button-active, then maplibre will have higher importance */\n.maplibregl-ctrl-group button.control-button-active {\n background-color: #edeaea;\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,KACC,iBAAkB,mUACpB,CAEA,CAAC,KACC,iBAAkB,qUACpB,CAEA,CAAC,OACC,iBAAkB,iiBACpB,CAEA,CAAC,KACC,iBAAkB,qYACpB,CAEA,CAAC,UACC,QAAS,KACT,YAAa,OACb,iBAAkB,KAnBpB,cAoBiB,GACjB,CAEA,CAAC,oBACC,SAAU,SACV,QAAS,QACT,eAAgB,IAClB,CAEA,CANC,mBAMmB,CAAC,OACnB,QAAS,EACT,eAAgB,IAClB,CAEA,CAAC,aACC,iBAAkB,YAClB,OAAQ,EACR,WAAY,WACZ,OAAQ,QACR,QAAS,MACT,OAAQ,KACR,QAAS,KAzCX,QA0CW,EACT,MAAO,IACT,CAEA,CAZC,YAYY,UACX,QAAS,IACT,OAAQ,WACV,CAEA,CAjBC,YAiBY,OACX,iBAAkB,SACpB,CAEA,CAAC,KACC,oBAAqB,IACrB,kBAAmB,UACnB,QAAS,MACT,OAAQ,IACV,CAEA,CA5BC,YA4BY,KAAK,aAAa,CAP9B,KAQC,aAAc,IAAI,MAAM,IAC1B,CAEA,CAAC,mBACC,MAAO,KACP,OAAQ,IACV,CAEA,CAAC,oBACC,MAAO,KACP,OAAQ,IACV,CACA,CAAC,mBACC,MAAO,KACP,OAAQ,IACV,CAEA,CAAC,WACC,OAAQ,IACV,CAEA,CAAC,YACC,OAAQ,IACV,CAEA,CAAC,WACC,OAAQ,IACV,CAEA,CAAC,WACC,WAAY,MACd,CC9FA,CAAC,gBACC,QAAS,MACT,SAAU,SACV,QAAS,KACT,eAAgB,KAChB,IAAK,EACL,KAAM,CACR,CAEA,CAAC,WACC,QAAS,aAVX,QAWW,IAAI,KACb,iBAAkB,QAZpB,cAaiB,KACf,MAAO,KACP,UAAW,IACb,CAEA,CAAC,kBACC,QAAS,EACT,UAAW,WAAW,MACtB,WAAY,IAAI,IAAK,SACrB,iBAAkB,IACpB,CAEA,CAAC,gBACC,QAAS,EACT,UAAW,UAAW,MACtB,WAAY,IAAI,IAAK,QACvB,CAEA,CAAC,kBACC,UAAW,UAAU,GACrB,QAAS,CACX,CClCA,CAAC,KACC,UAAW,OAAO,OAClB,iBAAkB,m9CACpB,CAEA,CAAC,QACC,iBAAkB,u5DACpB,CAEA,CAAC,MACC,iBAAkB,syDACpB,CAEA,CAAC,cAAc,aACb,uBAAwB,IACxB,wBAAyB,GAC3B,CAGA,CAAC,sBAAsB,MAAM,CAAC,sBAC5B,iBAAkB,OACpB,CAEA,CAVC,cAUc,UACb,QAAS,GACX,CCzBA,CAAC,qBACD,CAAC,mBACC,QAAS,cACX,CAEA,CAAC,yBACD,CAAC,uBAND,QAOW,WACX","names":[]}
1
+ {"version":3,"sources":["../src/components/tooltip/tooltip.css","../src/components/panel/panel.css","../src/components/side-control/control.css","../src/draw.css"],"sourcesContent":[".popup-container {\n display: block;\n position: absolute;\n z-index: 1000;\n pointer-events: none;\n top: 0;\n left: 0;\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",".undo {\n background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='lucide lucide-undo-icon lucide-undo'%3E%3Cpath d='M3 7v6h6'/%3E%3Cpath d='M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13'/%3E%3C/svg%3E\");\n}\n\n.redo {\n background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='lucide lucide-redo-icon lucide-redo'%3E%3Cpath d='M21 7v6h-6'/%3E%3Cpath d='M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7'/%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 background-color: white;\n border-radius: 4px;\n}\n\n.dashboard-container {\n position: absolute;\n z-index: 1000000;\n pointer-events: auto;\n}\n\n.dashboard-container.hidden {\n opacity: 0;\n pointer-events: none;\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:disabled {\n opacity: 0.25;\n cursor: not-allowed;\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\n.hide-panel {\n visibility: hidden;\n}\n",".line {\n transform: rotate(44deg);\n background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:svg='http://www.w3.org/2000/svg' xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns%23' xmlns:cc='http://creativecommons.org/ns%23' xmlns:dc='http://purl.org/dc/elements/1.1/' fill='%23000000' width='10' height='16' viewBox='-3 0 0.22850401 0.63333199' version='1.1' id='svg1' xml:space='preserve'%3E%3Cdefs id='defs1'/%3E%3Ctitle id='title1'%3Eline-chart%3C/title%3E%3Cmetadata id='metadata1'%3E%3Crdf:RDF%3E%3Ccc:Work rdf:about=''%3E%3Cdc:title%3Eline-chart%3C/dc:title%3E%3C/cc:Work%3E%3C/rdf:RDF%3E%3C/metadata%3E%3Cg style='fill:none' id='g1' transform='matrix(0.04,0,0,0.04,-3.48332,-0.48336)'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='m 14.9997,12.084 c -1.6109,0 -2.9167,1.3058 -2.9167,2.9167 0,1.3212 0.8786,2.4373 2.0833,2.7958 v 4.4083 c -1.2047,0.3585 -2.0833,1.4746 -2.0833,2.7959 0,1.6108 1.3058,2.9166 2.9167,2.9166 1.3212,0 2.4373,-0.8785 2.7959,-2.0833 V 14.1673 C 17.437,12.9625 16.3209,12.084 14.9997,12.084 Z m -1.25,2.9167 c 0,-0.6904 0.5596,-1.25 1.25,-1.25 0.6903,0 1.25,0.5596 1.25,1.25 0,0.6903 -0.5597,1.25 -1.25,1.25 -0.6904,0 -1.25,-0.5597 -1.25,-1.25 z m 2.0833,7.2041 c 0.9407,0.2799 1.6826,1.0218 1.9626,1.9625 V 15.834 c -0.28,0.9407 -1.0219,1.6826 -1.9626,1.9625 z m -0.8333,1.5459 c -0.6904,0 -1.25,0.5596 -1.25,1.25 0,0.6903 0.5596,1.25 1.25,1.25 0.6903,0 1.25,-0.5597 1.25,-1.25 0,-0.6904 -0.5597,-1.25 -1.25,-1.25 z' fill='%2315181a' id='path1'/%3E%3C/g%3E%3C/svg%3E\");\n}\n\n.polygon {\n background-image: url(\"data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M4.99967 2.08398C3.38884 2.08398 2.08301 3.38982 2.08301 5.00065C2.08301 6.32191 2.96155 7.43797 4.16634 7.79654L4.16634 12.2048C2.96155 12.5633 2.08301 13.6794 2.08301 15.0007C2.08301 16.6115 3.38884 17.9173 4.99967 17.9173C6.32093 17.9173 7.437 17.0388 7.79556 15.834H12.2038C12.5624 17.0388 13.6784 17.9173 14.9997 17.9173C16.6105 17.9173 17.9163 16.6115 17.9163 15.0007C17.9163 13.6794 17.0378 12.5633 15.833 12.2048V7.79653C17.0378 7.43797 17.9163 6.32191 17.9163 5.00065C17.9163 3.38982 16.6105 2.08398 14.9997 2.08398C13.6784 2.08398 12.5624 2.96253 12.2038 4.16732L7.79556 4.16732C7.437 2.96253 6.32093 2.08398 4.99967 2.08398ZM3.74967 5.00065C3.74967 4.31029 4.30932 3.75065 4.99967 3.75065C5.69003 3.75065 6.24967 4.31029 6.24967 5.00065C6.24967 5.69101 5.69003 6.25065 4.99967 6.25065C4.30932 6.25065 3.74967 5.69101 3.74967 5.00065ZM5.83301 12.2048C6.77375 12.4847 7.51558 13.2266 7.79556 14.1673L12.2038 14.1673C12.4838 13.2266 13.2256 12.4847 14.1663 12.2048L14.1663 7.79654C13.2256 7.51656 12.4838 6.77473 12.2038 5.83398L7.79556 5.83398C7.51558 6.77472 6.77375 7.51656 5.83301 7.79653L5.83301 12.2048ZM13.7497 5.00065C13.7497 4.31029 14.3093 3.75065 14.9997 3.75065C15.69 3.75065 16.2497 4.31029 16.2497 5.00065C16.2497 5.69101 15.69 6.25065 14.9997 6.25065C14.3093 6.25065 13.7497 5.69101 13.7497 5.00065ZM4.99967 13.7507C4.30932 13.7507 3.74967 14.3103 3.74967 15.0007C3.74967 15.691 4.30932 16.2507 4.99967 16.2507C5.69003 16.2507 6.24967 15.691 6.24967 15.0007C6.24967 14.3103 5.69003 13.7507 4.99967 13.7507ZM13.7497 15.0007C13.7497 14.3103 14.3093 13.7507 14.9997 13.7507C15.69 13.7507 16.2497 14.3103 16.2497 15.0007C16.2497 15.691 15.69 16.2507 14.9997 16.2507C14.3093 16.2507 13.7497 15.691 13.7497 15.0007Z' fill='%2315181A'/%3E%3C/svg%3E%0A\");\n}\n\n.break {\n background-image: url(\"data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4.16667 1.66602C4.6269 1.66602 5 2.03911 5 2.49935V5.83268H15V2.49935C15 2.03911 15.3731 1.66602 15.8333 1.66602C16.2936 1.66602 16.6667 2.03911 16.6667 2.49935V5.83268C16.6667 6.75316 15.9205 7.49935 15 7.49935H5C4.07953 7.49935 3.33333 6.75316 3.33333 5.83268V2.49935C3.33333 2.03911 3.70643 1.66602 4.16667 1.66602Z' fill='%2315181A'/%3E%3Cpath d='M4.16667 18.3327C4.6269 18.3327 5 17.9596 5 17.4993V14.166H15V17.4993C15 17.9596 15.3731 18.3327 15.8333 18.3327C16.2936 18.3327 16.6667 17.9596 16.6667 17.4993V14.166C16.6667 13.2455 15.9205 12.4993 15 12.4993H5C4.07953 12.4993 3.33333 13.2455 3.33333 14.166V17.4993C3.33333 17.9596 3.70643 18.3327 4.16667 18.3327Z' fill='%2315181A'/%3E%3Cpath d='M13.3333 9.16602H11.4583C10.9981 9.16602 10.625 9.53911 10.625 9.99935C10.625 10.4596 10.9981 10.8327 11.4583 10.8327H13.3333C13.7936 10.8327 14.1667 10.4596 14.1667 9.99935C14.1667 9.53911 13.7936 9.16602 13.3333 9.16602Z' fill='%2315181A'/%3E%3Cpath d='M8.54167 9.16602H6.66667C6.20643 9.16602 5.83333 9.53911 5.83333 9.99935C5.83333 10.4596 6.20643 10.8327 6.66667 10.8327H8.54167C9.0019 10.8327 9.375 10.4596 9.375 9.99935C9.375 9.53911 9.0019 9.16602 8.54167 9.16602Z' fill='%2315181A'/%3E%3Cpath d='M3.75 9.16601H2.08333C1.6231 9.16601 1.25 9.53911 1.25 9.99935C1.25 10.4596 1.6231 10.8327 2.08333 10.8327H3.75C4.21024 10.8327 4.58333 10.4596 4.58333 9.99935C4.58333 9.53911 4.21024 9.16601 3.75 9.16601Z' fill='%2315181A'/%3E%3Cpath d='M17.9167 9.16601H16.25C15.7898 9.16601 15.4167 9.53911 15.4167 9.99935C15.4167 10.4596 15.7898 10.8327 16.25 10.8327H17.9167C18.3769 10.8327 18.75 10.4596 18.75 9.99935C18.75 9.53911 18.3769 9.16601 17.9167 9.16601Z' fill='%2315181A'/%3E%3C/svg%3E%0A\");\n}\n\n.control-button:first-child {\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n}\n\n/* otherwise if we just .control-button-active, then maplibre will have higher importance */\n.maplibregl-ctrl-group button.control-button-active {\n background-color: #edeaea;\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,gBACC,QAAS,MACT,SAAU,SACV,QAAS,KACT,eAAgB,KAChB,IAAK,EACL,KAAM,CACR,CAEA,CAAC,WACC,QAAS,aAVX,QAWW,IAAI,KACb,iBAAkB,QAZpB,cAaiB,KACf,MAAO,KACP,UAAW,IACb,CAEA,CAAC,kBACC,QAAS,EACT,UAAW,WAAW,MACtB,WAAY,IAAI,IAAK,SACrB,iBAAkB,IACpB,CAEA,CAAC,gBACC,QAAS,EACT,UAAW,UAAW,MACtB,WAAY,IAAI,IAAK,QACvB,CAEA,CAAC,kBACC,UAAW,UAAU,GACrB,QAAS,CACX,CClCA,CAAC,KACC,iBAAkB,mUACpB,CAEA,CAAC,KACC,iBAAkB,qUACpB,CAEA,CAAC,OACC,iBAAkB,iiBACpB,CAEA,CAAC,KACC,iBAAkB,qYACpB,CAEA,CAAC,UACC,QAAS,KACT,YAAa,OACb,iBAAkB,KAnBpB,cAoBiB,GACjB,CAEA,CAAC,oBACC,SAAU,SACV,QAAS,QACT,eAAgB,IAClB,CAEA,CANC,mBAMmB,CAAC,OACnB,QAAS,EACT,eAAgB,IAClB,CAEA,CAAC,aACC,iBAAkB,YAClB,OAAQ,EACR,WAAY,WACZ,OAAQ,QACR,QAAS,MACT,OAAQ,KACR,QAAS,KAzCX,QA0CW,EACT,MAAO,IACT,CAEA,CAZC,YAYY,UACX,QAAS,IACT,OAAQ,WACV,CAEA,CAjBC,YAiBY,OACX,iBAAkB,SACpB,CAEA,CAAC,KACC,oBAAqB,IACrB,kBAAmB,UACnB,QAAS,MACT,OAAQ,IACV,CAEA,CA5BC,YA4BY,KAAK,aAAa,CAP9B,KAQC,aAAc,IAAI,MAAM,IAC1B,CAEA,CAAC,mBACC,MAAO,KACP,OAAQ,IACV,CAEA,CAAC,oBACC,MAAO,KACP,OAAQ,IACV,CACA,CAAC,mBACC,MAAO,KACP,OAAQ,IACV,CAEA,CAAC,WACC,OAAQ,IACV,CAEA,CAAC,YACC,OAAQ,IACV,CAEA,CAAC,WACC,OAAQ,IACV,CAEA,CAAC,WACC,WAAY,MACd,CC9FA,CAAC,KACC,UAAW,OAAO,OAClB,iBAAkB,m9CACpB,CAEA,CAAC,QACC,iBAAkB,u5DACpB,CAEA,CAAC,MACC,iBAAkB,syDACpB,CAEA,CAAC,cAAc,aACb,uBAAwB,IACxB,wBAAyB,GAC3B,CAGA,CAAC,sBAAsB,MAAM,CAAC,sBAC5B,iBAAkB,OACpB,CAEA,CAVC,cAUc,UACb,QAAS,GACX,CCzBA,CAAC,qBACD,CAAC,mBACC,QAAS,cACX,CAEA,CAAC,yBACD,CAAC,uBAND,QAOW,WACX","names":[]}
package/dist/index.d.ts CHANGED
@@ -177,7 +177,18 @@ interface ModeChangeEvent {
177
177
  }
178
178
 
179
179
  declare class DrawLibre implements IControl {
180
- #private;
180
+ private container;
181
+ private store;
182
+ private mode;
183
+ private defaultOptions;
184
+ private mapEvents;
185
+ private tiles;
186
+ private panel;
187
+ private control;
188
+ private cursor;
189
+ private mouseEvents;
190
+ private renderer;
191
+ static instance: DrawLibre | null;
181
192
  private constructor();
182
193
  static getInstance(options?: DrawOptions): DrawLibre;
183
194
  /**
@@ -185,7 +196,7 @@ declare class DrawLibre implements IControl {
185
196
  *
186
197
  * @example ```ts
187
198
  * const map = new Map();
188
- * const draw = new DrawLibre();
199
+ * const draw = DrawLibre.getInstance();
189
200
  * map.addControl(draw)
190
201
  * ```
191
202
  *
@@ -203,7 +214,7 @@ declare class DrawLibre implements IControl {
203
214
  *
204
215
  * @example ```ts
205
216
  * const map = new Map();
206
- * const draw = new DrawLibre();
217
+ * const draw = DrawLibre.getInstance();
207
218
  * map.removeControl(draw)
208
219
  * ```
209
220
  *
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- var K=class{_isHidden=!0;_anchor={dx:0,dy:0};_pendingCoord=null;_rafId=0;_listenersActive=!1;get isHidden(){return this._isHidden}set isHidden(e){this._isHidden=e;}get anchor(){return {...this._anchor}}set anchor(e){this._anchor={...e};}get pendingCoord(){return this._pendingCoord}set pendingCoord(e){this._pendingCoord=e;}get rafId(){return this._rafId}set rafId(e){this._rafId=e;}get listenersActive(){return this._listenersActive}set listenersActive(e){this._listenersActive=e;}reset(){this._isHidden=!0,this._anchor={dx:0,dy:0},this._pendingCoord=null,this._rafId=0,this._listenersActive=!1;}};var l=class{static create(e,t,i){let o=window.document.createElement(e);return t!==void 0&&(o.className=t),i&&i.appendChild(o),o}static remove(e){e.parentNode&&e.parentNode.removeChild(e);}static addEventListener(e,t,i,o={}){e&&e.addEventListener(t,i,o);}static removeEventListener(e,t,i,o={}){e&&e.removeEventListener(t,i,o);}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 ke={type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[]}}]};var 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",AuxiliaryPointLayer:"mdl-auxiliary-point-layer"},d={UnifiedSource:"mdl-unified-source",LineDynamicSource:"mdl-line-dynamic-source",LineSourceBreak:"mdl-line-source-break",SinglePointSource:"mdl-single-point-source"},A={large:6.5,default:5.5},Y={large:"#FF6464",default:"#666666"},N={"circle-radius":A.default,"circle-color":"#FEFFFE","circle-stroke-color":Y.default,"circle-stroke-width":3},U={"circle-radius":A.default-1.5,"circle-color":"#FEFFFE","circle-stroke-color":"#666666","circle-stroke-width":2},k={"circle-radius":A.large,"circle-color":"#FEFFFE","circle-stroke-color":"#666666","circle-stroke-width":3},H={"fill-color":"grey","fill-opacity":.4},D={"line-width":3,"line-color":"grey","line-opacity":.7},R={"circle-radius":A.default,"circle-color":"#FEFFFE","circle-stroke-color":"#666666","circle-stroke-width":3},I={"line-width":3,"line-color":"#FF6464","line-dasharray":[3,3]},j=n=>[{id:r.SinglePointLayer,source:d.SinglePointSource,type:"circle",paint:n.layersPaint.onLinePoint,layout:{visibility:"none"}},{id:r.PolygonLayer,source:d.UnifiedSource,type:"fill",paint:n.layersPaint.polygon,layout:{visibility:"none"},filter:["==","$type","Polygon"]},{id:r.LineDynamicLayer,source:d.LineDynamicSource,type:"line",paint:n.layersPaint.line,layout:{visibility:"none"}},{id:r.LineLayer,source:d.UnifiedSource,type:"line",paint:n.layersPaint.line,layout:{visibility:"visible"},filter:["==","$type","LineString"]},{id:r.LineLayerTransparent,source:d.UnifiedSource,type:"line",paint:{"line-width":4,"line-color":"transparent"},filter:["==","$type","LineString"]},{id:r.LineLayerBreak,source:d.LineSourceBreak,type:"line",paint:n.layersPaint.breakLine,layout:{visibility:"none"}},{id:r.PointsLayer,source:d.UnifiedSource,type:"circle",paint:n.layersPaint.points,filter:["all",["==","$type","Point"],["==","isFirst",!1],["==","isAuxiliary",!1]]},{id:r.FirstPointLayer,source:d.UnifiedSource,type:"circle",paint:n.layersPaint.firstPoint,filter:["==",["get","isFirst"],!0],layout:{visibility:"none"}},{id:r.AuxiliaryPointLayer,source:d.UnifiedSource,type:"circle",paint:n.layersPaint.auxiliaryPoint,filter:["==",["get","isAuxiliary"],!0]}];var m=class{static isFeatureTriggered(e,t){return e.target.queryRenderedFeatures(e.point,{layers:t}).some(o=>t.includes(o.layer.id))}static getPixelCoordinates=(e,t)=>{let{lat:i,lng:o}=t;return e.project([o,i])};static queryPointId=(e,t)=>e.queryRenderedFeatures(t,{layers:[r.PointsLayer,r.FirstPointLayer,r.AuxiliaryPointLayer,r.SinglePointLayer]})?.[0]?.properties.id;static queryPoint=(e,t)=>e.queryRenderedFeatures(t,{layers:[r.PointsLayer,r.FirstPointLayer,r.AuxiliaryPointLayer,r.SinglePointLayer]})?.[0]},S=class{static#t(e){let t=[],i=e.head,o=new Set;for(;i!==null;){if(o.has(i.val?.id)){e.head&&e.head.val&&t.push([e.head.val.lng,e.head.val.lat]);break}o.add(i.val?.id),i.val&&t.push([i.val.lng,i.val.lat]),i=i.next;}return t}static getLine(e,t){return {type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[e,t]}}]}}static getAllLines(e){return {type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:e}}]}}static getPolygon(e){return {type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[e]}}]}}static getPoints(e){let t=e.head,i=[],o=new Set;for(;t!==null&&!o.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,isAuxiliary:s.isAuxiliary},geometry:{type:"Point",coordinates:[s.lng,s.lat]}});}o.add(t.val?.id),t=t.next;}return {type:"FeatureCollection",features:i}}static getUnifiedFeatures(e){let t=this.getPoints(e).features,i=this.#t(e),o=this.getAllLines(i).features,s=this.getPolygon(i).features;return {type:"FeatureCollection",features:[...t,...o,...s]}}},b=class{static getGeometryIndex=(e,t)=>{let i=e.head,o=0,s=new Set;for(;i!==null&&!s.has(i.val?.id);){if(i.val?.id===t)return o;s.add(i.val?.id),o++,i=i.next;}return -1};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,t)=>t.pointGeneration==="auto"?e.tail?.next?.val?.id===e.head?.val?.id&&e.tail?.next!==null:e.tail?.next===e.head;static breakGeometry=(e,t,i)=>{e.head&&(t.pointGeneration==="auto"?(i.val?.isAuxiliary?(e.head=i.next,e.head.prev=null,e.tail=i.prev,e.tail.next=null):(e.head=i.next?.next,e.head.prev=null,e.tail=i,e.tail.next=null),e.size=e.size-1):(e.head=i.next,e.head.prev=null,e.tail=i,e.tail.next=null));};static closeGeometry=(e,t)=>{e.tail&&e.head&&(e.tail.next=e.head,e.head.prev=e.tail),t.setClosedGeometry(!0);};static canCloseGeometry=(e,t)=>(t.pointGeneration==="auto"?e.size>3:e.size>2)&&!this.isClosedGeometry(e,t);static canBreakClosedGeometry=(e,t)=>t.pointGeneration==="auto"?e.size<=3:e.size<=2},g=()=>{if("crypto"in window&&"randomUUID"in window.crypto)return window.crypto.randomUUID();function n(){return "0123456789abcdef"[Math.floor(Math.random()*16)]}function e(o){let s="";for(let a=0;a<o;a++)s+=n();return s}function t(o){let s=o===0,a=o===4;return s?8:a?12:4}let i=[];for(let o=0;o<5;o++)i.push(e(t(o)));return i.join("-")},w=(n,e)=>{let t,i=!0;function o(){i&&t&&(n(...t),t=null,i=!1,setTimeout(()=>{i=!0,o();},e));}return function(...s){t=s,o();}},B=(n,e)=>{let t;return function(...i){clearTimeout(t),t=window.setTimeout(()=>{n(...i);},e);}},P=n=>{n&&(n.setAttribute("disabled","true"),n.setAttribute("aria-disabled","true"));},O=n=>{n&&(n.removeAttribute("disabled"),n.removeAttribute("aria-disabled"));};var J=class{constructor(e){this.ctx=e;this.root=l.create("div","dashboard-container"),this.buttonContainer=l.create("div","dashboard",this.root),this.renderButtons(),e.map.getContainer().appendChild(this.root);}root;buttonContainer;buttons={};createButton(e,t,i,o){let s=l.create("button",`panel-button panel-button-${i}`,o);return s.setAttribute("data-type",e),s.setAttribute("aria-label",t),l.create("span",`icon ${e} icon-${i}`,s),s}renderButtons(){let{panel:e,locale:t}=this.ctx.options,{buttons:i,size:o}=e;Object.keys(i).forEach(s=>{if(!i[s].visible)return;let a=this.createButton(s,t[s],o,this.buttonContainer);(s==="undo"||s==="redo")&&P(a),this.buttons[s]=a;});}getButton(e){return this.buttons[e]}getRoot(){return this.root}show(){this.root.classList.remove("hidden");}hide(){this.root.classList.add("hidden");}setTransform(e,t){this.root.style.transform=`translate(${e}px, ${t}px)`;}observeResize(e){let t=new ResizeObserver(e);return t.observe(this.root),t}destroy(){this.root.remove();}};var ze=20,$=class{constructor(e){this.ctx=e;this.view=new J(e),this.init();}view;state=new K;resizeObserver;onMapMove=()=>this.schedulePositionUpdate();init(){let{store:e}=this.ctx;this.resizeObserver=this.view.observeResize(this.measureAnchor),this.measureAnchor(),e.tail?.val&&this.setPanelLocation(e.tail.val);}destroy(){this.state.listenersActive&&this.disableListeners(),this.resizeObserver.disconnect(),cancelAnimationFrame(this.state.rafId),this.view.destroy();}enableListeners(){if(this.state.listenersActive)return;let e=this.ctx.map;e.on("move",this.onMapMove),e.on("zoom",this.onMapMove),this.state.listenersActive=!0;}disableListeners(){if(!this.state.listenersActive)return;let e=this.ctx.map;e.off("move",this.onMapMove),e.off("zoom",this.onMapMove),this.state.listenersActive=!1;}setPanelLocation=e=>{this.state.pendingCoord=e,this.enableListeners(),this.schedulePositionUpdate(),this.show();};measureAnchor=()=>{let{width:e,height:t}=this.view.getRoot().getBoundingClientRect();this.state.anchor={dx:-e/2,dy:-t-ze},this.schedulePositionUpdate();};schedulePositionUpdate=()=>{this.state.rafId||(this.state.rafId=requestAnimationFrame(()=>{if(this.state.rafId=0,this.state.pendingCoord){let e=this.ctx.map.project(this.state.pendingCoord),{dx:t,dy:i}=this.state.anchor;this.view.setTransform(e.x+t,e.y+i);}}));};setVisible(e){this.state.isHidden=!e,e?this.view.show():this.view.hide();}show=()=>this.setVisible(!0);hide=()=>this.setVisible(!1);get undoButton(){return this.view.getButton("undo")}get redoButton(){return this.view.getButton("redo")}get deleteButton(){return this.view.getButton("delete")}get saveButton(){return this.view.getButton("save")}};var _=class{constructor(e){this.ctx=e;this.unifiedGeoJSON=S.getUnifiedFeatures(this.ctx.store),this.execute();}unifiedGeoJSON;updateLine(e,t){let{mode:i}=this.ctx,o=this.unifiedGeoJSON.features.at(-2)?.geometry.coordinates;o&&(o[e]=[t.lng,t.lat],i.getClosedGeometry()&&e===0&&(o[o.length-1]=[t.lng,t.lat]));}updatePolygon(e,t){let{mode:i}=this.ctx,o=this.unifiedGeoJSON.features.at(-1)?.geometry.coordinates[0];o&&(o[e]=[t.lng,t.lat],i.getClosedGeometry()&&e===0&&(o[o.length-1]=[t.lng,t.lat]));}updatePoint(e,t){let i=this.unifiedGeoJSON?.features?.[e];i?.geometry?.coordinates&&(i.geometry.coordinates=[t.lng,t.lat]);}executeOnMouseMove=(e,t,i)=>{let{mode:o,options:s,store:a}=this.ctx,p=e===0?a.size-1:e-1;this.updatePoint(e,t),i&&i.prev&&this.updatePoint(p,i.prev),i&&i.next&&this.updatePoint(e+1,i.next),this.updateLine(e,t),i&&i.prev&&this.updateLine(p,i.prev),i&&i.next&&this.updateLine(e+1,i.next),s.modes.polygon.visible&&o.isPolygon()&&(this.updatePolygon(e,t),i&&i.prev&&this.updatePolygon(p,i.prev),i&&i.next&&this.updatePolygon(e+1,i.next));let L=this.ctx.map.getSource(d.UnifiedSource);L&&L.setData(this.unifiedGeoJSON);};execute(){this.unifiedGeoJSON=S.getUnifiedFeatures(this.ctx.store);let e=this.ctx.map.getSource(d.UnifiedSource);e&&e.setData(this.unifiedGeoJSON);}resetGeometries=()=>{let e=this.ctx.map.getSource(d.UnifiedSource);e&&e.setData({type:"FeatureCollection",features:[]});}};var qe=8,Ve=8,T=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};#t=()=>{!this.label?.classList.value.includes("popup-text-active")&&this.label?.classList.add("popup-text-active");};#e=()=>this.label?{width:this.label.clientWidth,height:this.label.clientHeight}:{width:0,height:0};#o=e=>{let{bottom:t,left:i}=e.target.getBoundingClientRect(),{width:o,height:s}=this.#e();return {x:i-Ve-o,y:t-s-2}};#i=e=>{let{bottom:t,left:i,right:o}=e.target.getBoundingClientRect(),{width:s}=this.#e();return {x:(o-i)/2+i-s/2,y:t+qe}};getPosition=(e,t)=>t==="left"?this.#o(e):this.#i(e);setPosition=e=>{let{x:t,y:i}=e;this.container&&(this.container.style.left=`${t}px`,this.container.style.top=`${i}px`),this.#t();};remove=()=>{this.container&&l.remove(this.container);}};var E={AUTO:"auto",DEFAULT:"default",POINTER:"pointer",CROSSHAIR:"crosshair",MOVE:"move",HELP:"help",GRAB:"grab",GRABBING:"grabbing"};var Re=(n,e)=>{let t=e.locale.line,i=e.locale.polygon,o=e.locale.break;return {line:t,polygon:i,break:o}[n]};var v={RIGHTCLICKREMOVE:"mdl:rightclickremove",POINTENTER:"mdl:pointenter",POINTLEAVE:"mdl:pointleave",MOVEEND:"mdl:moveend",ADD:"mdl:add",UNDO:"mdl:undo",REDO:"mdl:redo",REMOVEALL:"mdl:removeall",SAVE:"mdl:save",BREAK:"mdl:break",MODECHANGED:"mdl:modechanged"},Be=768,u={pointGeneration:"manual",panel:{size:"medium",buttons:{undo:{visible:!0},redo:{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:k,firstPoint:N,points:R,line:D,polygon:H,breakLine:I},initial:null,dynamicLine:!0,locale:{save:"Save",delete:"Delete all",undo:"Undo",redo:"Redo",line:"Line",polygon:"Polygon",break:"Split",closeLine:"Close the line",createPolygon:"Create a polygon"}};var c=class{static addPoint(e,t,i){t.fire(v.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(v.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 pointRemoveRightClick(e,t){t.fire(v.RIGHTCLICKREMOVE,{id:e.id,coordinates:{lat:e.lat,lng:e.lng},total:e.total,timestamp:Date.now()});}static enterPoint(e,t){t.fire(v.POINTENTER,{id:e.id,coordinates:{lat:e.lat,lng:e.lng},total:e.total,timestamp:Date.now()});}static leavePoint(e,t){t.fire(v.POINTLEAVE,{id:e.id,coordinates:{lat:e.lat,lng:e.lng},total:e.total,timestamp:Date.now()});}static undo(e,t,i){t.fire(v.UNDO,{originalEvent:i,id:e.id,coordinates:{lat:e.lat,lng:e.lng},total:e.total,timestamp:Date.now()});}static redo(e,t,i){t.fire(v.REDO,{originalEvent:i,id:e.id,coordinates:{lat:e.lat,lng:e.lng},total:e.total,timestamp:Date.now()});}static modeChanged(e,t){e.fire(v.MODECHANGED,{mode:t});}static removeAllPoints(e,t){e.fire(v.REMOVEALL,{originalEvent:t});}static onSaveClick(e,t,i){let{map:o,mode:s}=e;o.fire(v.SAVE,{originalEvent:i,timestamp:Date.now(),steps:t,mode:{geometry:s.getMode(),closedGeometry:s.getClosedGeometry()}});}static onLineBreak(e){e.fire(v.BREAK);}};var W=class{constructor(e){this.props=e;this.initConsumers();}initConsumers=()=>{this.props.mode.addObserver(this.mapModeConsumer);};removeConsumers=()=>{this.props.mode.removeObserver(this.mapModeConsumer);};resetAllState=()=>{let{lineButton:e,polygonButton:t,breakButton:i}=this.props.control;e?.classList.remove("control-button-active"),t?.classList.remove("control-button-active"),i?.classList.remove("control-button-active");};checkActive=e=>{this.resetAllState(),e.classList.add("control-button-active");};observeModeChange=e=>{let{data:t}=e,{lineButton:i,polygonButton:o,breakButton:s}=this.props.control,{mode:a}=this.props;if(c.modeChanged(this.props.map,t),!(!i||!o||!s)){switch(t){case"line":this.checkActive(i);break;case"polygon":this.checkActive(o);break;}t?a.getClosedGeometry()&&O(s):P(s);}};observeGeometryChange=e=>{let{data:t}=e,{breakButton:i,lineButton:o,polygonButton:s}=this.props.control,{mode:a}=this.props;t?(i&&O(i),a.getMode()==="polygon"&&o&&P(o),a.getMode()==="line"&&s&&P(s)):(i&&P(i),a.getMode()==="polygon"&&o&&O(o),a.getMode()==="line"&&s&&O(s));};mapModeConsumer=e=>{let{type:t,data:i}=e;if(t==="MODE_CHANGED"&&this.observeModeChange(e),t==="CLOSED_GEOMETRY_CHANGED"&&this.observeGeometryChange(e),t==="BREAK_CHANGED"&&i){let{breakButton:o}=this.props.control;this.checkActive(o),c.modeChanged(this.props.map,"break");}}};var Z=class{constructor(e){this.ctx=e;this.#e=new W(e),this.#t=new T,this.#o();}#t;#e;#o(){let{control:e}=this.ctx;if(e){let{breakButton:t,lineButton:i,polygonButton:o}=e;i&&(l.addEventListener(i,"click",this.onLineClick),l.addEventListener(i,"mouseenter",this.onButtonEnter),l.addEventListener(i,"mouseleave",this.onButtonLeave)),o&&(l.addEventListener(o,"click",this.onPolygonClick),l.addEventListener(o,"mouseenter",this.onButtonEnter),l.addEventListener(o,"mouseleave",this.onButtonLeave)),t&&(l.addEventListener(t,"click",this.onBreakClick),l.addEventListener(t,"mouseenter",this.onButtonEnter),l.addEventListener(t,"mouseleave",this.onButtonLeave));}}#i(){let{control:e}=this.ctx;if(e){let{breakButton:t,lineButton:i,polygonButton:o}=e;i&&(l.removeEventListener(i,"click",this.onLineClick),l.removeEventListener(i,"mouseenter",this.onButtonEnter),l.removeEventListener(i,"mouseleave",this.onButtonLeave)),o&&(l.removeEventListener(o,"click",this.onPolygonClick),l.removeEventListener(o,"mouseenter",this.onButtonEnter),l.removeEventListener(o,"mouseleave",this.onButtonLeave)),t&&(l.removeEventListener(t,"click",this.onBreakClick),l.removeEventListener(t,"mouseenter",this.onButtonEnter),l.removeEventListener(t,"mouseleave",this.onButtonLeave));}}remove(){this.#e.removeConsumers(),this.#i(),this.#t.remove();}onButtonEnter=e=>{let{options:t}=this.ctx,i=e.target.getAttribute("data-type");if(i){let o=Re(i,t),s="left";this.#t.create({label:o,placement:s}).setPosition(this.#t.getPosition(e,s));}};onButtonLeave=()=>{this.#t.remove();};#n=()=>{let{control:e}=this.ctx;e.lineButton?.classList.remove("control-button-active"),e.polygonButton?.classList.remove("control-button-active"),e.breakButton?.classList.remove("control-button-active");};#s=()=>{let{map:e,mode:t}=this.ctx;t.getMode()||e.fire("mode:initialize");};onLineClick=()=>{let{map:e,mode:t,renderer:i,control:o}=this.ctx;this.#s(),this.#n(),t.getMode()==="line"&&!t.getBreak()?(t.setMode(null),e.fire("mode:remove"),i.resetGeometries()):(o.lineButton?.classList.add("control-button-active"),t.setMode("line"),i.execute());};onPolygonClick=()=>{let{map:e,mode:t,renderer:i,control:o}=this.ctx;this.#s(),this.#n(),t.getMode()==="polygon"&&!t.getBreak()?(t.setMode(null),e.fire("mode:remove"),i.resetGeometries()):(o.polygonButton?.classList.add("control-button-active"),t.setMode("polygon"),i.execute());};onBreakClick=()=>{let{map:e,mode:t,control:i}=this.ctx;t.getBreak()&&(t.setMode(null),e.fire("mode:remove")),this.#n(),i.breakButton?.classList.add("control-button-active"),t.setBreak(!0),e.getCanvasContainer().style.cursor=E.POINTER;}};var f={getMidpoint(n,e){return {lat:(n.lat+e.lat)/2,lng:(n.lng+e.lng)/2}},createAuxiliaryPoint(n,e){let t=f.getMidpoint(n,e);return {lat:t.lat,lng:t.lng,isAuxiliary:!0,id:g()}}},x={setFirstPointVisible(n){n.setLayoutProperty(r.FirstPointLayer,"visibility","visible");},setFirstPointHidden(n){n.setLayoutProperty(r.FirstPointLayer,"visibility","none");},setSinglePointVisible(n){n.target.setLayoutProperty(r.SinglePointLayer,"visibility","visible");},setSinglePointHidden(n){let e=n.target;setTimeout(()=>{e.setLayoutProperty(r.SinglePointLayer,"visibility","none");},33);}},Se={default(n){n.setFilter(r.PointsLayer,["all",["==","$type","Point"],["==","isFirst",!1],["==","isAuxiliary",!1]]);},closedGeometry(n){n.setFilter(r.PointsLayer,["all",["==","$type","Point"],["==","isAuxiliary",!1]]);}};var C=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 X=class{constructor(e,t){this.store=e;this.options=t;this.store=e;}isCircular=()=>{let{head:e,tail:t}=this.store;return !e||!t?!1:e===t.next&&t===e.prev};canBreak=()=>{let{size:e}=this.store,t=this.options?.pointGeneration==="auto"?3:2;return e<=t};canClose=()=>{let{size:e}=this.store;return (this.options?.pointGeneration==="auto"?e>3:e>2)&&!this.isCircular()};break=e=>{if(this.store.head)if(this.options?.pointGeneration==="auto")if(e.val?.isAuxiliary){let t=e.val?.id;this.store.head=e.next,this.store.tail=e.prev,this.store.removeNodeById(t),this.store.head.prev=null,this.store.tail.next=null;}else {let t=e.next?.val?.id;this.store.head=e.next?.next,this.store.tail=e,this.store.removeNodeById(t),this.store.head.prev=null,this.store.tail.next=null;}else this.store.head=e.next,this.store.head.prev=null,this.store.tail=e,this.store.tail.next=null;};close=()=>{let{head:e,tail:t}=this.store;!e||!t||(t.next=e,e.prev=t);}};var z=class{val;prev;next;constructor(e=null,t=null,i=null){this.val=e,this.prev=i,this.next=t;}},q=class extends C{constructor(t){super();this.options=t;let i=M.initStore(t);this.circular=new X(this,t),this.map=i?i.map:new Map,this.head=i?i.head:null,this.tail=i?i.tail:null,this.size=i?i.size:0;}head;tail;size;map;circular;push=t=>{let i=new z(t);return this.head?this.tail&&(i.prev=this.tail,this.tail.next=i,this.tail=i):this.head=this.tail=i,this.map.set(t.id,i),this.size++,this.pingConsumers(),i};unshift=t=>{let i=new z(t);i.next=this.head,this.head=i,this.circular.isCircular()&&this.tail&&(this.tail.next=i,i.prev=this.tail),this.map.set(t.id,i),this.size++,this.pingConsumers();};insertAfter=(t,i)=>{if(!t)return null;let o=new z(i);return o.prev=t,o.next=t.next,this.tail===t&&this.head===t.next&&(this.tail=o,this.head.prev=o),t.next&&(t.next.prev=o),t.next=o,this.map.set(i.id,o),this.size++,this.pingConsumers(),o};removeNodeById(t){let i=this.map.get(t);return i?(this.size===1?(this.head=null,this.tail=null):(i.prev&&(i.prev.next=i.next),i.next&&(i.next.prev=i.prev),i===this.head&&(this.head=i.next,this.head?.prev&&this.tail&&(this.tail.next=this.head)),i===this.tail&&(this.tail=i.prev,this.head&&this.tail?.next&&(this.head.prev=this.tail))),this.map.delete(t),this.size--,this.pingConsumers(),i):null}findStepById(t){let i=this.map.get(t);return i?i.val:null}findNodeById(t){let i=this.map.get(t);return i||null}reset=()=>{this.head=null,this.tail=null,this.size=0,this.map.clear(),this.notify({type:"STORE_CLEARED"});};pingConsumers=()=>{this.notify({type:"STORE_MUTATED",data:{head:this.head,tail:this.tail,size:this.size}});}},M=class n{static isLastPoint=(e,t,i)=>t.pointGeneration==="auto"&&e.tail?.next===e.head?e.tail?.prev?.val?.id===i:e.tail?.val?.id===i;static initStore(e){if(!e?.initial)return null;if(e&&e.initial&&!e.initial.steps.length)throw new Error(G.EMPTY_INITIAL_STATE);return e&&e.initial.steps?n.fromArray(e.initial,e.pointGeneration):null}static generateIdForSteps=e=>e.map((t,i)=>({...t,isAuxiliary:!1,isFirst:i===0,id:g()}));static buildStepSequence(e,t,i){let o=new q,s=t?e.slice(0,-1):e;return s.forEach((a,p)=>{if(o.push(a),i==="auto"){if(s[p+1]){let L=f.createAuxiliaryPoint(a,s[p+1]);o.push(L);}else if(t){let L=f.createAuxiliaryPoint(a,s[0]);o.push(L);}}}),o}static fromArray(e,t){let{steps:i,closeGeometry:o,generateId:s}=e,a=s?this.generateIdForSteps(i):i,p=this.buildStepSequence(a,o,t);return o&&p.tail&&p.head&&(p.tail.next=p.head,p.head.prev=p.tail),p}static toArray(e){if(!e)return [];let t=new Set,i=[],o=e;for(;o!==null&&!t.has(o);)t.add(o),i.push(o.val),o=o.next;return i}};var we=class{constructor(e,t,i=[]){this.type=e;this.payload=t;this.commands=i;}add(e){this.commands.push(e);}execute(){if(this.commands)for(let e of this.commands)e.execute();}undo(){if(this.commands)for(let e=this.commands.length-1;e>=0;e--)this.commands[e]?.undo();}},Oe=class n extends C{transaction=null;undoStack=[];redoStack=[];static instance=null;static getInstance(){return n.instance||(n.instance=new n),n.instance}commit=e=>{e.execute(),this.transaction?this.transaction.add(e):this.undoStack.push(e),this.redoStack.length=0,this.pingConsumers();};undo=()=>{let e=this.undoStack.pop();if(e)return e.undo(),this.redoStack.push(e),this.pingConsumers(),e};redo=()=>{let e=this.redoStack.pop();return e?(e.execute(),this.undoStack.push(e),this.pingConsumers(),e):null};beginTransaction=(e="compound",t=null)=>{this.transaction||(this.transaction=new we(e,t));};commitTransaction=()=>{if(!this.transaction)return;let e=this.transaction;this.transaction=null,this.undoStack.push(e),this.pingConsumers();};getRedoStackLength=()=>this.redoStack.length;getUndoStackLength=()=>this.undoStack;resetStacks=()=>{this.undoStack=[],this.redoStack=[],this.notify({type:"REDO_STACK_CHANGED",data:0});};pingConsumers=()=>{this.notify({type:"REDO_STACK_CHANGED",data:this.redoStack.length}),this.notify({type:"UNDO_STACK_CHANGED",data:this.undoStack.length});}},h=Oe.getInstance();var Q=class{constructor(e){this.ctx=e;this.tooltip=new T;}tooltip;initConsumers(){this.ctx.store.addObserver(this.onStoreChangeConsumer),this.ctx.mode?.addObserver(this.onMapModeConsumer),h.addObserver(this.timelineConsumer);}removeConsumers(){this.ctx.store.removeObserver(this.onStoreChangeConsumer),this.ctx.mode?.removeObserver(this.onMapModeConsumer),h.removeObserver(this.timelineConsumer);}timelineConsumer=e=>{let{type:t,data:i}=e;t==="REDO_STACK_CHANGED"&&(i?O(this.ctx.panel.redoButton):P(this.ctx.panel.redoButton)),t==="UNDO_STACK_CHANGED"&&(i?O(this.ctx.panel.undoButton):P(this.ctx.panel.undoButton));};onStoreChangeConsumer=e=>{if(e.type==="STORE_MUTATED"){let{data:t}=e;if(t?.size===0)this.ctx.panel.hide();else {let i=Object.assign({},t);for(;i.tail;)if(i.tail?.val?.isAuxiliary)i.tail=i.tail?.prev;else {i.tail?.val&&this.ctx.panel.setPanelLocation({lat:i.tail.val.lat,lng:i.tail.val.lng});break}}}};onMapModeConsumer=e=>{let{store:t}=this.ctx,{type:i,data:o}=e;i==="MODE_CHANGED"&&!o&&this.ctx.panel.hide(),i==="MODE_CHANGED"&&o&&t.tail?.val&&this.ctx.panel.setPanelLocation({lat:t.tail?.val?.lat,lng:t.tail?.val?.lng});};initEvents(){let{panel:e}=this.ctx;e.undoButton&&(l.addEventListener(e.undoButton,"click",this.onUndoClick),l.addEventListener(e.undoButton,"mouseenter",this.onMouseEnter),l.addEventListener(e.undoButton,"mouseleave",this.onMouseLeave)),e.redoButton&&(l.addEventListener(e.redoButton,"click",this.onRedoClick),l.addEventListener(e.redoButton,"mouseenter",this.onMouseEnter),l.addEventListener(e.redoButton,"mouseleave",this.onMouseLeave)),e.deleteButton&&(l.addEventListener(e.deleteButton,"click",this.onRemoveAll),l.addEventListener(e.deleteButton,"mouseenter",this.onMouseEnter),l.addEventListener(e.deleteButton,"mouseleave",this.onMouseLeave)),e.saveButton&&(l.addEventListener(e.saveButton,"click",this.onSaveClick),l.addEventListener(e.saveButton,"mouseenter",this.onMouseEnter),l.addEventListener(e.saveButton,"mouseleave",this.onMouseLeave));}removeEvents(){let{panel:e}=this.ctx;e.undoButton&&(l.removeEventListener(e.undoButton,"click",this.onUndoClick),l.removeEventListener(e.undoButton,"mouseenter",this.onMouseEnter),l.removeEventListener(e.undoButton,"mouseleave",this.onMouseLeave)),e.deleteButton&&(l.removeEventListener(e.deleteButton,"click",this.onRemoveAll),l.removeEventListener(e.deleteButton,"mouseenter",this.onMouseEnter),l.removeEventListener(e.deleteButton,"mouseleave",this.onMouseLeave)),e.redoButton&&(l.removeEventListener(e.redoButton,"click",this.onRedoClick),l.removeEventListener(e.redoButton,"mouseenter",this.onMouseEnter),l.removeEventListener(e.redoButton,"mouseleave",this.onMouseLeave)),e.saveButton&&(l.removeEventListener(e.saveButton,"click",this.onSaveClick),l.removeEventListener(e.saveButton,"mouseenter",this.onMouseEnter),l.removeEventListener(e.saveButton,"mouseleave",this.onMouseLeave));}getButtonLabel=e=>{let{options:t}=this.ctx;return {undo:t.locale.undo,redo:t.locale.redo,delete:t.locale.delete,save:t.locale.save}[e]};onMouseEnter=e=>{let t=e.target.getAttribute("data-type");if(t){let i=this.getButtonLabel(t);this.tooltip.create({label:i,placement:"bottom"}).setPosition(this.tooltip.getPosition(e,"bottom"));}};onMouseLeave=()=>{this.tooltip.remove();};onRemoveAll=e=>{let{renderer:t,mode:i,panel:o,store:s,map:a}=this.ctx;s.reset(),o.hide(),i.reset(),this.tooltip.remove(),h.resetStacks(),t.resetGeometries(),c.removeAllPoints(a,e);};onUndoClick=e=>{let{store:t,map:i,renderer:o}=this.ctx,s=h.getRedoStackLength();t.size===1&&s?(t.reset(),this.ctx.panel.hide()):h.undo(),this.tooltip.remove(),c.undo({...t.tail?.val,total:t.size},i,e),o.execute();};onRedoClick=e=>{let{store:t,map:i,renderer:o}=this.ctx;h.redo(),c.redo({...t.tail?.val,total:t.size},i,e),o.execute();};onSaveClick=e=>{let{store:t,options:i}=this.ctx;c.onSaveClick(this.ctx,M.toArray(t.head),e),this.tooltip.remove(),i.panel.buttons.save.clearOnSave&&this.onRemoveAll(e);}};var ee=class{constructor(e,t,i){this.store=e;this.segmentStart=i;this.step={id:g(),isAuxiliary:!1,...t},this.payload={node:this.step};}type="STORE_POINT_INSERTED";payload;step;snapshot={insertedNode:null};restoreInsertedNode=e=>{let t=e.prev,i=e.next;t?t.next=e:this.store.head=e,i?i.prev=e:this.store.tail=e,this.store.tail===t&&this.store.head===i&&(this.store.tail=e,this.store.head&&(this.store.head.prev=e)),e.val&&!this.store.map.has(e.val.id)&&(this.store.map.set(e.val.id,e),this.store.size++,this.store.pingConsumers());};execute=()=>{this.snapshot.insertedNode?this.restoreInsertedNode(this.snapshot.insertedNode):this.snapshot.insertedNode=this.store.insertAfter(this.segmentStart,this.step),this.store.notify({type:"STORE_POINT_INSERTED"});};undo=()=>{this.store.removeNodeById(this.step.id);}};var Te=(n,e)=>{let t=e.head,i=new Set;for(;t!==null&&!i.has(t);){if(t?.next?.val&&t?.val){let o=n.target,s=m.getPixelCoordinates(o,t.val),a=m.getPixelCoordinates(o,t.next.val),p=m.getPixelCoordinates(o,n.lngLat);if(b.checkIfPointIsOnLine(s,a,p))return t}i.add(t),t=t.next;}return null},De=(n,e)=>{let t=Te(n,e);if(t){let i={...n.lngLat,isAuxiliary:!1,id:g()};return h.commit(new ee(e,i,t)),i}return null},Ie=(n,e)=>{let{store:t,renderer:i}=e;t.tail?.val&&(x.setSinglePointHidden(n),i.execute());},_e=n=>m.isFeatureTriggered(n,[r.PointsLayer,r.FirstPointLayer,r.AuxiliaryPointLayer]);var te=class{constructor(e,t,i,o,s){this.store=e;this.options=t;this.mode=i;this.current=o;this.clickCoords=s;}type="STORE_BREAK_GEOMETRY";snapshot={originalHead:null,originalTail:null,newHead:null,newTail:null,newAuxBetweenHeadTail:null};makeSnapshot=()=>{this.snapshot.originalHead=this.store.head,this.snapshot.originalTail=this.store.tail,this.snapshot.newAuxBetweenHeadTail=this.current.val?.isAuxiliary?this.current:this.current.next;};execute=()=>{this.makeSnapshot(),this.store.circular.break(this.current),this.mode.setClosedGeometry(!1),this.snapshot.newHead=this.store.head,this.snapshot.newTail=this.store.tail,this.store.notify({type:"STORE_BREAK_GEOMETRY",data:{coords:this.clickCoords}});};restoreOriginalHeadTail=()=>{let{originalHead:e,originalTail:t}=this.snapshot;this.store.head=e,this.store.tail=t,this.store.head&&(this.store.head.prev=this.store.tail),this.store.tail&&(this.store.tail.next=this.store.head);};restoreAuxBetweenNewHeadTail=()=>{let{newHead:e,newTail:t,newAuxBetweenHeadTail:i}=this.snapshot;e&&t&&(t.next=i,i.prev=t,i.next=e,e.prev=i,i?.val&&(this.store.map.set(i?.val.id,i),this.store.size+=1));};undo=()=>{this.restoreOriginalHeadTail(),this.store.circular.close(),this.store.notify({type:"STORE_CLOSE_GEOMETRY"});let{newHead:e,newTail:t,newAuxBetweenHeadTail:i}=this.snapshot;e&&t&&(this.options.pointGeneration==="auto"?this.restoreAuxBetweenNewHeadTail():(t.next=e,e.prev=t)),this.mode.setClosedGeometry(!0),this.store.pingConsumers();}};var Ge=15,ie=class{constructor(e){this.ctx=e;this.current=null,this.throttledOnLineEnter=w(this.onLineEnterBreak,Ge);}current;throttledOnLineEnter;initBreakEvents=()=>{this.ctx.map.on("click",r.LineLayer,this.geometryBreakOnClick),this.ctx.map.on("mouseenter",r.LineLayer,this.throttledOnLineEnter),this.ctx.map.on("mousemove",r.LineLayer,this.throttledOnLineEnter),this.ctx.map.on("mouseleave",r.LineLayer,this.onLineLeave);};removeBreakEvents=()=>{this.ctx.map.off("click",r.LineLayer,this.geometryBreakOnClick),this.ctx.map.off("mouseenter",r.LineLayer,this.throttledOnLineEnter),this.ctx.map.off("mousemove",r.LineLayer,this.throttledOnLineEnter),this.ctx.map.off("mouseleave",r.LineLayer,this.onLineLeave);};hideBreakLine=()=>{this.ctx.map.getLayoutProperty(r.LineLayerBreak,"visibility")!=="none"&&this.ctx.map.setLayoutProperty(r.LineLayerBreak,"visibility","none");};showBreakLine=()=>{this.ctx.map.getLayoutProperty(r.LineLayerBreak,"visibility")!=="visible"&&this.ctx.map.setLayoutProperty(r.LineLayerBreak,"visibility","visible");};geometryBreakOnClick=e=>{let{store:t,mode:i,map:o,renderer:s,options:a}=this.ctx;this.current&&(h.commit(new te(t,a,i,this.current,e.lngLat)),this.onLineLeave(),i.reset(),s.execute(),c.onLineBreak(o));};getAutoGenerationPoints=e=>{let t=null,i=null;return e?.val?.isAuxiliary?(t=[e?.prev?.val?.lng,e?.prev?.val?.lat],i=[e?.next?.val?.lng,e?.next?.val?.lat]):(t=[e?.val?.lng,e?.val?.lat],i=[e?.next?.next?.val?.lng,e?.next?.next?.val?.lat]),{current:t,next:i}};getLinePoints=e=>{if(this.ctx.options.pointGeneration==="manual"){let t=[e?.val?.lng,e?.val?.lat],i=[e?.next?.val?.lng,e?.next?.val?.lat];return {current:t,next:i}}return this.getAutoGenerationPoints(e)};onLineEnterBreak=e=>{let{map:t,store:i}=this.ctx,o=Te(e,i);o?.val?.id!==this.current?.val?.id&&(this.current=o);let s=t.getSource(d.LineSourceBreak),{current:a,next:p}=this.getLinePoints(this.current),y=S.getLine(a,p);y&&(s.setData(y),this.showBreakLine());};onLineLeave=()=>{setTimeout(()=>{this.hideBreakLine();},Ge+10);}};var Ke=17,oe=class{constructor(e){this.ctx=e;this.visible=!0,this.onMouseMoveThrottled=w(this.onLineMove,Ke),this.onStoreEventsDebounced=B(this.onStoreEventsConsumer,10),this.initConsumers(),this.initDynamicEvents();}visible;firstPoint=null;secondPoint=null;lineFeature;onMouseMoveThrottled;onStoreEventsDebounced;initConsumers(){this.ctx.store.addObserver(this.onStoreEventsDebounced),this.ctx.mouseEvents.addObserver(this.onMouseEventsConsumer);}removeConsumers=()=>{this.ctx.store.removeObserver(this.onStoreEventsDebounced),this.ctx.mouseEvents.removeObserver(this.onMouseEventsConsumer);};onMouseEventsConsumer=e=>{let{store:t}=this.ctx;if(t.circular.isCircular()){this.hide();return}if(e.type==="lastPointMouseClick"&&e.data&&(this.hide(),this.visible=!1),!this.visible)return;if(["pointMouseEnter","lineMouseEnter","pointMouseDown"].includes(e.type)&&e.data&&this.hide(),e.type==="pointMouseLeave"||e.type==="lineMouseLeave"){let{store:o}=this.ctx;if(o.circular.isCircular())return;e.data&&(this.firstPoint=o.tail?.val,this.secondPoint=o.tail?.val,this.show());}};onStoreEventsConsumer=e=>{let{store:t}=this.ctx;if(t.circular.isCircular()){this.hide();return}e.type==="STORE_CLOSE_GEOMETRY"||e.type==="STORE_CLEARED"?this.hide():e.type==="STORE_BREAK_GEOMETRY"?(this.firstPoint=t.tail?.val,this.secondPoint=e.data?.coords,this.show(),this.visible=!0):e.type==="STORE_POINT_ADD"&&t.size>0&&(this.firstPoint=t.tail?.val,this.secondPoint=t.tail?.val,this.show(),this.visible=!0);};initDynamicEvents=()=>{let{map:e}=this.ctx;e.on("click",this.onMapClick),e.on("mousemove",this.onMouseMoveThrottled),e.on(v.REMOVEALL,this.hide),e.on(v.UNDO,this.onUndoRedoClick),e.on(v.REDO,this.onUndoRedoClick),e.on(v.RIGHTCLICKREMOVE,this.onRightClickRemove);};removeEvents=()=>{let{map:e}=this.ctx;e.off("click",this.onMapClick),e.off("mousemove",this.onMouseMoveThrottled),e.off(v.REMOVEALL,this.hide),e.off(v.UNDO,this.onUndoRedoClick),e.off(v.REDO,this.onUndoRedoClick),e.off(v.RIGHTCLICKREMOVE,this.onRightClickRemove);};hide=()=>{let{map:e}=this.ctx;this.firstPoint=null,this.secondPoint=null,this.lineFeature=null,e.off("mousemove",this.onMouseMoveThrottled);let t=e.getSource(d.LineDynamicSource);t&&t.setData(ke),e.getLayer(r.LineDynamicLayer)&&e.setLayoutProperty(r.LineDynamicLayer,"visibility","none");};show=()=>{let{map:e,store:t}=this.ctx;if(t.size&&this.firstPoint?.lat&&this.firstPoint.lng&&this.secondPoint?.lng&&this.secondPoint?.lat){let i=[this.firstPoint.lng,this.firstPoint.lat],o=[this.secondPoint.lng,this.secondPoint.lat];this.lineFeature=S.getLine(i,o),e.setLayoutProperty(r.LineDynamicLayer,"visibility","visible"),this.secondPoint&&this.renderLineOnMouseMove({lng:this.secondPoint?.lng,lat:this.secondPoint?.lat});}e.on("mousemove",this.onMouseMoveThrottled);};renderLineOnMouseMove=e=>{if(!this.lineFeature)return;let{map:t}=this.ctx;this.lineFeature.features[0].geometry.coordinates[1]=[e.lng,e.lat];let i=t.getSource(d.LineDynamicSource);i&&i.setData(this.lineFeature);};onLineMove=e=>{this.renderLineOnMouseMove(e.lngLat);};onMapClick=e=>{let{mode:t}=this.ctx,i=m.isFeatureTriggered(e,[r.LineLayerTransparent,r.LineLayer]);i&&t.getBreak()&&(this.secondPoint={lng:e.lngLat.lng,lat:e.lngLat.lat}),!i&&this.hide();};onUndoRedoClick=e=>{let{store:t}=this.ctx;if(!t.circular.isCircular()){let i=e.target.unproject({x:e.originalEvent.x,y:e.originalEvent.y});this.secondPoint={lng:i.lng,lat:i.lat},this.firstPoint=t.tail?.val,this.show();}t.size===0&&this.hide();};onRightClickRemove=e=>{let{store:t}=this.ctx;t.circular.isCircular()||(this.secondPoint={lng:e.coordinates.lng,lat:e.coordinates.lat},this.firstPoint=t.tail?.val,this.show()),t.size===0&&this.hide();}};var Ye=22,ne=class{constructor(e){this.ctx=e;this.isThrottled=!1,this.lastEvent=null;}isThrottled;lastEvent;initEvents(){this.ctx.map.on("click",r.LineLayerTransparent,this.onLineClick),this.ctx.map.on("mousemove",r.LineLayerTransparent,this.onLineMove),this.ctx.map.on("mouseenter",r.LineLayerTransparent,this.onLineEnter),this.ctx.map.on("mouseleave",r.LineLayerTransparent,this.onLineLeave);}removeEvents(){this.ctx.map.off("click",r.LineLayerTransparent,this.onLineClick),this.ctx.map.off("mousemove",r.LineLayerTransparent,this.onLineMove),this.ctx.map.off("mouseenter",r.LineLayerTransparent,this.onLineEnter),this.ctx.map.off("mouseleave",r.LineLayerTransparent,this.onLineLeave);}onLineClick=e=>{let{store:t,map:i,mode:o}=this.ctx;if(_e(e))return;let s=De(e,t);s&&(Ie(e,this.ctx),c.addPoint({...s,total:t.size},i,o));};processMouseMove=e=>{if(x.setSinglePointVisible(e),e.target.getLayer(r.SinglePointLayer)){let i=e.target.getSource(d.SinglePointSource);i&&i.setData({type:"Feature",geometry:{type:"Point",coordinates:[e.lngLat.lng,e.lngLat.lat]},properties:{}});}};onLineMove=w(e=>{m.isFeatureTriggered(e,[r.PointsLayer,r.FirstPointLayer])||this.ctx.mouseEvents.pointMouseDown||this.ctx.mouseEvents.pointMouseEnter||(this.lastEvent=e,!this.isThrottled&&(this.isThrottled=!0,requestAnimationFrame(()=>{this.lastEvent&&(this.processMouseMove(this.lastEvent),this.isThrottled=!1);})));},Ye);onLineEnter=e=>{this.ctx.mouseEvents.pointMouseDown||this.ctx.mouseEvents.pointMouseEnter||m.isFeatureTriggered(e,[r.PointsLayer,r.FirstPointLayer])||(this.ctx.mouseEvents.lineMouseEnter=!0,x.setSinglePointVisible(e));};onLineLeave=e=>{this.ctx.mouseEvents.pointMouseDown||this.ctx.mouseEvents.pointMouseEnter||(this.ctx.mouseEvents.lineMouseLeave=!0,x.setSinglePointHidden(e));}};var se=class{constructor(e){this.ctx=e;this.break=new ie(e),this.transparent=e.options.pointGeneration==="manual"?new ne(e):null,this.dynamic=null,this.type="default";}break;transparent;dynamic;type;init(){this.initDynamicLine(),this.initEvents(),this.initConsumers();}initDynamicLine=()=>{window.innerWidth<=Be||this.ctx.options.dynamicLine&&(this.dynamic=new oe(this.ctx));};initEvents(){!this.ctx.mode.getBreak()&&this.transparent?.initEvents();}initConsumers(){this.ctx.mode.addObserver(this.mapModeConsumer),this.ctx.mouseEvents.addObserver(this.mouseEventsConsumer);}remove(){this.removeConsumers(),this.removeEvents();}removeConsumers(){this.ctx.mode.removeObserver(this.mapModeConsumer),this.ctx.mouseEvents.removeObserver(this.mouseEventsConsumer),this.ctx.options.dynamicLine&&this.dynamic?.removeConsumers();}removeEvents(){this.break.removeBreakEvents(),this.transparent?.removeEvents(),this.ctx.options.dynamicLine&&(this.dynamic?.removeEvents(),this.dynamic?.hide());}mouseEventsConsumer=e=>{let{type:t,data:i}=e,{mode:o}=this.ctx;if(!(!i||!o.getBreak()))switch(t){case"pointMouseDown":this.break.removeBreakEvents(),this.break.hideBreakLine();break;case"pointMouseUp":this.break.initBreakEvents();break;}};mapModeConsumer=e=>{let{type:t,data:i}=e;t==="MODE_CHANGED"&&this.type==="break"&&(this.break.removeBreakEvents(),this.transparent?.initEvents(),this.type="default"),t==="BREAK_CHANGED"&&i&&this.type==="default"&&(this.transparent?.removeEvents(),this.break.initBreakEvents(),this.type="break");}};var je=n=>{n.setPaintProperty(r.FirstPointLayer,"circle-radius",A.large),n.setPaintProperty(r.FirstPointLayer,"circle-stroke-color",Y.large);},Je=n=>{n.setPaintProperty(r.FirstPointLayer,"circle-radius",A.default),n.setPaintProperty(r.FirstPointLayer,"circle-stroke-color",Y.default);},Ae=(n,e)=>{e==="large"?je(n):Je(n);},Fe=n=>{n.getLayer(r.LineLayerTransparent)&&n.removeLayer(r.LineLayerTransparent);},re=(n,e)=>{if(n.getLayer(r.LineLayerTransparent))return;let i=j(e).find(o=>o.id===r.LineLayerTransparent);i&&n.addLayer(i);};var ae=class{constructor(e,t,i){this.store=e;this.mode=t;this.options=i;this.type="STORE_CLOSE_GEOMETRY";}type="STORE_CLOSE_GEOMETRY";auxPointSnapshot=null;restoreAuxPoint=()=>{this.auxPointSnapshot?.val&&(this.store.head.prev=this.auxPointSnapshot,this.store.tail.next=this.auxPointSnapshot,this.auxPointSnapshot.prev=this.store.tail,this.auxPointSnapshot.next=this.store.head,this.store.tail=this.auxPointSnapshot,this.store.map.set(this.auxPointSnapshot.val.id,this.auxPointSnapshot),this.store.size++,this.store.pingConsumers());};execute=()=>{if(this.options.pointGeneration==="auto"&&this.store.tail?.val)if(this.auxPointSnapshot)this.restoreAuxPoint();else {let e=f.createAuxiliaryPoint(this.store.tail?.val,this.store.head?.val);this.auxPointSnapshot=this.store.push(e);}this.store.circular.close(),this.mode.setClosedGeometry(!0),this.store.notify({type:this.type});};undo=()=>{this.options.pointGeneration==="auto"&&this.store.removeNodeById(this.store.tail?.val?.id),this.store.tail?.val&&this.store.head?.val&&(this.store.tail.next=null,this.store.head.prev=null),this.mode.setClosedGeometry(!1),this.store.notify({type:"STORE_BREAK_GEOMETRY"});}};var le=class{constructor(e,t){this.props=e;this.baseEvents=t;this.#t=!1,this.#e=new T,this.initLayer(),this.initEvents();}#t;#e;initConsumers=()=>{let{mode:e,store:t}=this.props;e.addObserver(this.onMapModeChanggeConsumer),t.addObserver(this.onStoreChangeConsumer);};removeConsumers=()=>{let{mode:e,store:t}=this.props;e.removeObserver(this.onMapModeChanggeConsumer),t.removeObserver(this.onStoreChangeConsumer);};initLayer(){let{map:e}=this.props;e.setLayoutProperty(r.FirstPointLayer,"visibility","visible");}initBaseEvents=()=>{let{map:e}=this.props;e.on("mouseenter",r.FirstPointLayer,this.baseEvents.onPointMouseEnter),e.on("mouseleave",r.FirstPointLayer,this.baseEvents.onPointMouseLeave),e.on("mousedown",r.FirstPointLayer,this.baseEvents.onPointMouseDown),e.on("mouseup",r.FirstPointLayer,this.baseEvents.onPointMouseUp),e.on("touchend",r.FirstPointLayer,this.baseEvents.onPointMouseUp),e.on("touchstart",r.FirstPointLayer,this.baseEvents.onPointMouseDown);};initEvents(){let{map:e}=this.props;e.on("click",r.FirstPointLayer,this.onFirstPointClick),e.on("mouseenter",r.FirstPointLayer,this.onFirstPointMouseEnter),e.on("mouseleave",r.FirstPointLayer,this.onFirstPointMouseLeave),e.on("mouseup",r.FirstPointLayer,this.onFirstPointMouseUp),e.on("mousedown",r.FirstPointLayer,this.onFirstPointMouseDown),this.initBaseEvents(),this.initConsumers();}removeBaseEvents=()=>{let{map:e}=this.props;e.off("mouseenter",r.FirstPointLayer,this.baseEvents.onPointMouseEnter),e.off("mouseleave",r.FirstPointLayer,this.baseEvents.onPointMouseLeave),e.off("mousedown",r.FirstPointLayer,this.baseEvents.onPointMouseDown),e.off("mouseup",r.FirstPointLayer,this.baseEvents.onPointMouseUp),e.off("touchend",r.FirstPointLayer,this.baseEvents.onPointMouseUp),e.off("touchstart",r.FirstPointLayer,this.baseEvents.onPointMouseDown);};removeEvents(){let{map:e}=this.props;e.off("click",r.FirstPointLayer,this.onFirstPointClick),e.off("mouseenter",r.FirstPointLayer,this.onFirstPointMouseEnter),e.off("mouseleave",r.FirstPointLayer,this.onFirstPointMouseLeave),e.off("mouseup",r.FirstPointLayer,this.onFirstPointMouseUp),this.removeBaseEvents(),this.removeConsumers();}onMapModeChanggeConsumer=e=>{let{map:t,options:i}=this.props,{type:o,data:s}=e;o==="MODE_CHANGED"&&(s==="line"&&!i.modes.line.closeGeometry?(x.setFirstPointHidden(t),Se.closedGeometry(t)):(x.setFirstPointVisible(t),Se.default(t)));};onStoreChangeConsumer=e=>{let{map:t,store:i}=this.props,{type:o}=e;["STORE_MUTATED","STORE_POINT_INSERTED","STORE_CLOSE_GEOMETRY","STORE_BREAK_GEOMETRY","STORE_CLEARED"].includes(o)&&(i.circular.canClose()?Ae(t,"large"):Ae(t,"default"));};onFirstPointClick=()=>{let{store:e,mode:t,renderer:i,options:o}=this.props;e.circular.canClose()&&(h.commit(new ae(e,t,o)),i.execute());};onFirstPointMouseDown=()=>{this.#t=!0,this.#e.remove();};onFirstPointMouseUp=()=>{this.#t=!1;};onFirstPointMouseLeave=()=>{let{mouseEvents:e}=this.props;this.#t||(e.firstPointMouseLeave=!0,this.#e.remove());};getTitle=()=>{let{mode:e,options:t}=this.props;return e.getMode()==="line"&&t.modes.line.closeGeometry?t.locale.closeLine:e.getMode()==="polygon"?t.locale.createPolygon:""};onFirstPointMouseEnter=e=>{let{mode:t,mouseEvents:i,store:o,options:s}=this.props;if(i.firstPointMouseEnter=!0,!(t.getClosedGeometry()||this.#t)&&b.canCloseGeometry(o,s)){let{x:a,y:p}=e.originalEvent;if(a&&p){this.#e.create({label:this.getTitle(),placement:"bottom"});let L=this.#e.label?this.#e.label.clientWidth/2:0;this.#e.setPosition({x:a-L,y:p+14});}}}};var pe=class{constructor(e,t){this.store=e;this.clickedNode=t;this.snapshot=this.makeSnapshot(this.clickedNode);}type="STORE_AUX_TO_PRIMARY";snapshot=null;makeSnapshot(e){let t=e.prev,i=e.next;return {clickedNode:e,prevPrimaryNode:t,nextPrimaryNode:i,prevAuxNode:null,nextAuxNode:null}}restorePreviousAux=e=>{if(!this.snapshot)return;let{prevPrimaryNode:t,prevAuxNode:i}=this.snapshot;t&&(t.next=i),i&&(i.prev=t),e.prev=i,i&&(i.next=e),i?.val?.id&&!this.store.map.has(i.val.id)&&(this.store.map.set(i?.val?.id,i),this.store.size++);};restoreNextAux=e=>{if(!this.snapshot)return;let{nextPrimaryNode:t,nextAuxNode:i}=this.snapshot;if(e.next=i,i&&(i.prev=e,i.next=t),t&&(t.prev=i),e.next?.next===this.store.head){let s=e.next;this.store.tail=s,this.store.head&&(this.store.head.prev=s),this.store.tail&&(this.store.tail.next=this.store.head);}i?.val?.id&&(this.store.map.set(i.val?.id,i),this.store.size++);};addTwoAuxiliaryPoints=e=>{if(!this.snapshot)return;let{nextPrimaryNode:t,prevPrimaryNode:i}=this.snapshot;if(i)if(this.snapshot.prevAuxNode)this.restorePreviousAux(e);else {let o=f.createAuxiliaryPoint(i.val,e.val);this.snapshot.prevAuxNode=this.store.insertAfter(i,o);}if(t)if(this.snapshot.nextAuxNode)this.restoreNextAux(e);else {let o=f.createAuxiliaryPoint(e.val,t.val);this.snapshot.nextAuxNode=this.store.insertAfter(e,o);}};execute=()=>{if(!this.snapshot)return;let{clickedNode:e}=this.snapshot;e&&e.val&&(e.val.isAuxiliary=!1,this.addTwoAuxiliaryPoints(e));};removeTwoAuxiliaryPoints=e=>{if(!e||!this.snapshot)return;let{prevAuxNode:t,nextAuxNode:i}=this.snapshot;t?.val?.isAuxiliary&&this.store.removeNodeById(t.val?.id),i?.val?.isAuxiliary&&this.store.removeNodeById(i?.val.id);};undo=()=>{if(!this.snapshot)return;let{clickedNode:e}=this.snapshot;e&&e.val&&(e.val.isAuxiliary=!0,this.removeTwoAuxiliaryPoints(e));}};var F=class{constructor(e,t,i,o){this.store=e;this.selectedNode=t;this.start=i;this.map=o;this.end={lat:t.val.lat,lng:t.val.lng};}type="STORE_POINT_MOVED";end;updateNeighbors=e=>{let t=e.prev,i=e.next;if(!t?.val?.isAuxiliary&&!i?.val?.isAuxiliary)return;let o=e.prev?.prev,s=e.next?.next;if(o?.val&&this.selectedNode?.val&&t){let a=f.getMidpoint(this.selectedNode?.val,o?.val);t.val&&(t.val.lat=a.lat,t.val.lng=a.lng);}if(s?.val&&this.selectedNode?.val&&i){let a=f.getMidpoint(this.selectedNode?.val,s?.val);i.val&&(i.val.lat=a.lat,i.val.lng=a.lng);}};execute=()=>{if(!this.selectedNode.val)return;let e=this.store.findStepById(this.selectedNode.val?.id);e&&(e.lat=this.end.lat,e.lng=this.end.lng,this.updateNeighbors(this.selectedNode),this.store.notify({type:"STORE_MUTATED",data:this.store}),c.movePoint({id:this.selectedNode.val.id,total:this.store.size,end:{lat:this.selectedNode.val.lat,lng:this.selectedNode.val.lng},start:this.start},this.map));};undo=()=>{if(!this.selectedNode.val)return;let e=this.store.findStepById(this.selectedNode.val?.id);e&&(e.lat=this.start.lat,e.lng=this.start.lng,this.updateNeighbors(this.selectedNode),this.store.notify({type:"STORE_MUTATED",data:this.store}),c.movePoint({id:this.selectedNode.val.id,total:this.store.size,end:this.start,start:this.end},this.map));}};var ue=class{constructor(e,t,i,o){this.ctx=e;this.baseEvents=t;this.pointState=i;this.topologyManager=o;this.initEvents();}initBaseEvents=()=>{let{map:e}=this.ctx;e.on("mouseenter",r.AuxiliaryPointLayer,this.baseEvents.onPointMouseEnter),e.on("mouseleave",r.AuxiliaryPointLayer,this.baseEvents.onPointMouseLeave),e.on("mousedown",r.AuxiliaryPointLayer,this.baseEvents.onPointMouseDown),e.on("mouseup",r.PointsLayer,this.onMouseUp),e.on("touchend",r.PointsLayer,this.onMouseUp),e.on("touchstart",r.AuxiliaryPointLayer,this.baseEvents.onPointMouseDown);};removeBaseEvents=()=>{let{map:e}=this.ctx;e.off("mouseenter",r.AuxiliaryPointLayer,this.baseEvents.onPointMouseEnter),e.off("mouseleave",r.AuxiliaryPointLayer,this.baseEvents.onPointMouseLeave),e.off("mousedown",r.AuxiliaryPointLayer,this.baseEvents.onPointMouseDown),e.off("mouseup",r.PointsLayer,this.onMouseUp),e.off("touchend",r.PointsLayer,this.onMouseUp),e.off("touchstart",r.AuxiliaryPointLayer,this.baseEvents.onPointMouseDown);};initEvents(){let{map:e}=this.ctx;e.on("mousedown",r.AuxiliaryPointLayer,this.onMouseDown),e.on("touchstart",r.AuxiliaryPointLayer,this.onMouseDown),this.initBaseEvents();}removeEvents(){let{map:e}=this.ctx;e.off("mousedown",r.AuxiliaryPointLayer,this.onMouseDown),e.off("touchstart",r.AuxiliaryPointLayer,this.onMouseDown),this.removeBaseEvents();}onMouseDown=e=>{let{store:t,renderer:i,map:o}=this.ctx;if(e.originalEvent.button===2)return;let s=m.queryPointId(o,e.point),a=t.findNodeById(s);a&&(h.beginTransaction("PointCompound"),h.commit(new pe(t,a)),i.execute());};onMouseUp=()=>{let{mouseEvents:e,store:t,panel:i,map:o,options:s}=this.ctx;e.pointMouseUp=!0;let a=this.pointState.getSelectedNode(),p=this.pointState.getLastEvent(),y=this.pointState.getStartCoordinates();a&&a.val&&(p&&(this.topologyManager.updateStore(),this.pointState.clearLastEvent()),i?.show(),this.pointState.isMoved()&&(h.commit(new F(t,a,y,o)),h.commitTransaction()),this.pointState.partialReset()),e&&(e.pointMouseDown=!1),re(o,s);}};var ce=class{selectedNode=null;selectedIdx=null;startCoordinates=null;enteredStep=null;lastEvent=null;moved=!1;getSelectedNode(){return this.selectedNode}isMoved(){return this.moved}getSelectedIdx(){return this.selectedIdx}getStartCoordinates(){return this.startCoordinates}getEnteredStep(){return this.enteredStep}getLastEvent(){return this.lastEvent}setSelectedNode(e){this.selectedNode=e;}setSelectedIdx(e){this.selectedIdx=e;}setStartCoordinates(e){this.startCoordinates=e;}setEnteredStep(e){this.enteredStep=e;}setLastEvent(e){this.lastEvent=e;}setMoved(e){this.moved=e;}clearLastEvent(){this.lastEvent=null;}reset(){this.selectedNode=null,this.selectedIdx=null,this.startCoordinates=null,this.enteredStep=null,this.lastEvent=null;}partialReset(){this.selectedNode=null,this.selectedIdx=null,this.startCoordinates=null,this.lastEvent=null,this.moved=!1;}};var de=class{constructor(e,t,i){this.store=e;this.options=t;this.step={id:g(),isAuxiliary:!1,...i};}type="STORE_MUTATED";snapshot={addedNode:null,auxNode:null};step;restoreAddedNode=e=>{e.prev?e.prev.next=e:this.store.head=e,e.next?e.next.prev=e:this.store.tail=e,this.snapshot.addedNode=e,e.val&&(this.store.map.set(e.val.id,e),this.store.size++,this.store.pingConsumers());};restoreAuxNode=e=>{e.prev?e.prev.next=e:this.store.head=e,e.next?e.next.prev=e:this.store.tail=e,this.snapshot.auxNode=e,e.val&&(this.store.map.set(e.val.id,e),this.store.size++,this.store.pingConsumers());};execute=()=>{if(this.snapshot.addedNode?this.restoreAddedNode(this.snapshot.addedNode):this.snapshot.addedNode=this.store.push(this.step),this.options.pointGeneration==="auto"&&this.store.tail?.prev?.val)if(this.snapshot?.auxNode?.val)this.restoreAuxNode(this.snapshot.auxNode);else {let e=f.createAuxiliaryPoint(this.store.tail?.val,this.store.tail?.prev?.val);this.snapshot.auxNode=this.store.insertAfter(this.store.tail.prev,e);}this.store.notify({type:"STORE_POINT_ADD"});};undo=()=>{this.store.removeNodeById(this.step.id),this.options.pointGeneration==="auto"&&this?.snapshot.auxNode?.val&&this.store.removeNodeById(this?.snapshot.auxNode.val.id);};getStep=()=>this.step};var he=class{constructor(e){this.ctx=e;}type="STORE_INBETWEEN_POINT_REMOVED";snapshot=null;makeSnapshot(e){let{store:t,nodeId:i}=this.ctx,o=t.circular.isCircular(),s=t.head?.val?.id===i,p=(o?t.tail?.prev:t.tail)?.val?.id===i,y=e.prev,L=e.next,Ue=e.prev?.prev??null,He=e.next?.next??null;return {removedNode:e,wasCircular:o,wasRemovedHead:s,wasRemovedTail:p,beforePrimary:Ue,afterPrimary:He,beforeAux:y,afterAux:L,newAux:null}}restoreNodeAfter=(e,t)=>{!e||!t||!t.val||(t.prev=e,t.next=e.next,e.next&&(e.next.prev=t),e.next=t,this.ctx.store.map.has(t.val.id)||(this.ctx.store.map.set(t.val.id,t),this.ctx.store.size++,this.ctx.store.pingConsumers()));};recalculateInBetweenRemoved(e){if(!e||!this.snapshot)return;let{store:t}=this.ctx,i=e.prev,o=e.next,s=i?.prev,a=o?.next;i?.val?.isAuxiliary&&t.removeNodeById(i.val.id),o?.val?.isAuxiliary&&t.removeNodeById(o.val.id);let p=t.circular.isCircular()?t.size>=5:t.size>=3;if(s?.val&&a?.val&&p)if(this.snapshot.newAux)this.restoreNodeAfter(s,this.snapshot.newAux);else {let y=f.createAuxiliaryPoint(s.val,a.val);this.snapshot.newAux=t.insertAfter(s,y);}}breakGeometryIfNeeded=e=>{let{store:t}=e;if(t.circular.canBreak()&&t.circular.isCircular()){if(t.tail?.val?.isAuxiliary){let i=t.tail;t.removeNodeById(t.tail.val.id),t.tail=i?.prev;let o=f.createAuxiliaryPoint(t.tail?.val,t.head?.val);this.snapshot&&(this.snapshot.newAux=t.insertAfter(t.head,o));}return t.head&&(t.head.prev=null),t.tail&&(t.tail.next=null),!0}return !1};execute=()=>{let e=this.ctx.store.findNodeById(this.ctx.nodeId),t=e?.val?.isAuxiliary;if(!e||t)return;this.snapshot=this.makeSnapshot(e),this.recalculateInBetweenRemoved(e),this.ctx.store.removeNodeById(this.ctx.nodeId),this.breakGeometryIfNeeded(this.ctx)&&this.ctx.mode.reset(),c.pointRemoveRightClick({...e?.val,total:this.ctx.store.size},this.ctx.map),this.ctx.store.pingConsumers();};restoreRemovedMiddleNode=e=>{if(!this.snapshot||!e.val)return;let{beforePrimary:t,afterPrimary:i,wasCircular:o}=this.snapshot,{store:s,mode:a}=this.ctx;if(t&&(t.next=e,e.prev=t),i&&(e.next=i,i.prev=e),o&&!this.ctx.store.circular.isCircular()){let p=f.createAuxiliaryPoint(s.tail?.val,s.head?.val);s.push(p),s.circular.close(),a.setClosedGeometry(!0);}};restoreRemovedHeadNode=e=>{if(!this.snapshot||!e?.val)return;let{wasCircular:t}=this.snapshot,{store:i,mode:o}=this.ctx,s=this.ctx.store.head;s&&(e.next=s,s.prev=e),i.head=e;let a=!i.circular.isCircular();t&&a&&(i.circular.close(),o.setClosedGeometry(!0));};restoreRemovedTailNode=e=>{let{store:t,mode:i}=this.ctx;if(!this.snapshot)return;let{wasCircular:o}=this.snapshot,s=t.tail;s&&(s.next=e,e.prev=s,t.tail=e);let a=!t.circular.isCircular();o&&a&&(t.circular.close(),i.setClosedGeometry(!0));};restoreAuxiliaryPoints(e){this.snapshot&&(e.prev?.val&&e.val&&this.snapshot?.beforeAux&&(this.restoreNodeAfter(e.prev,this.snapshot?.beforeAux),this.snapshot.wasRemovedHead&&this.snapshot.wasCircular&&(this.ctx.store.tail=this.snapshot.beforeAux)),e.next?.val&&e.val&&this.snapshot?.afterAux&&(this.restoreNodeAfter(e,this.snapshot?.afterAux),this.snapshot.wasRemovedTail&&this.snapshot.wasCircular&&(this.ctx.store.tail=this.snapshot.afterAux)),this.snapshot.wasCircular&&this.ctx.store.circular.close());}undo=()=>{let{store:e}=this.ctx;if(!this.snapshot)return;let{removedNode:t,wasRemovedHead:i,wasRemovedTail:o,wasCircular:s}=this.snapshot;t?.val&&(i?(e.removeNodeById(e.head?.prev?.val?.id),this.restoreRemovedHeadNode(t)):o?(this.restoreRemovedTailNode(t),s&&e.tail?.prev?.val?.isAuxiliary&&e.removeNodeById(e.tail?.prev?.val?.id)):(this.snapshot.newAux?.val?.id&&e.removeNodeById(this.snapshot.newAux?.val?.id),this.restoreRemovedMiddleNode(t)),e.map.has(this.ctx.nodeId)||(e.map.set(this.ctx.nodeId,t),e.size++),this.restoreAuxiliaryPoints(t),e.pingConsumers());}};var me=class{constructor(e){this.ctx=e;}type="STORE_INBETWEEN_POINT_REMOVED";snapshot=null;makeSnapshot(e){let t=this.ctx.store.head?.val?.id===this.ctx.nodeId,i=this.ctx.store.tail?.val?.id===this.ctx.nodeId,o=this.ctx.store.circular.isCircular();return {removedNode:e,wasCircular:o,wasRemovedHead:t,wasRemovedTail:i}}breakGeometryIfNeeded=e=>{let{store:t}=e;return t.circular.canBreak()&&t.circular.isCircular()?(t.head&&(t.head.prev=null),t.tail&&(t.tail.next=null),!0):!1};execute=()=>{let e=this.ctx.store.findNodeById(this.ctx.nodeId);if(!e?.val)return;this.snapshot=this.makeSnapshot(e),this.ctx.store.removeNodeById(this.ctx.nodeId),this.breakGeometryIfNeeded(this.ctx)&&this.ctx.mode.reset(),c.pointRemoveRightClick({...e?.val,total:this.ctx.store.size},this.ctx.map),this.ctx.store.pingConsumers();};closeGeometryIfNeeded=()=>{let{store:e,mode:t}=this.ctx,i=!this.ctx.store.circular.isCircular();this.snapshot?.wasCircular&&i&&(e.circular.close(),t.setClosedGeometry(!0));};restoreRemovedMiddleNode=e=>{if(!e?.val)return;let{prev:t,next:i}=e;t?(t.next=e,e.prev=t):this.ctx.store.head=e,i?(i.prev=e,e.next=i):this.ctx.store.tail=e;};restoreRemovedHeadNode=e=>{let t=this.ctx.store.head;e?.val&&(t&&(e.next=t,t.prev=e),this.ctx.store.head=e);};restoreRemovedTailNode=e=>{let t=this.ctx.store.tail;t&&(t.next=e,e.prev=t),this.ctx.store.tail=e;};undo=()=>{if(!this.snapshot)return;let{removedNode:e,wasRemovedHead:t,wasRemovedTail:i}=this.snapshot;t?this.restoreRemovedHeadNode(e):i?this.restoreRemovedTailNode(e):this.restoreRemovedMiddleNode(e),this.closeGeometryIfNeeded(),this.ctx.store.map.has(this.ctx.nodeId)||(this.ctx.store.map.set(this.ctx.nodeId,e),this.ctx.store.size++),this.ctx.store.pingConsumers();}};var ve=class{constructor(e){this.ctx=e;this.manualPointRemove=new me(this.ctx),this.autoPointRemove=new he(this.ctx);}type="STORE_INBETWEEN_POINT_REMOVED";manualPointRemove=null;autoPointRemove=null;execute=()=>{this.ctx.options.pointGeneration==="auto"?this.autoPointRemove?.execute():this.manualPointRemove?.execute();};undo=()=>{this.ctx.options.pointGeneration==="auto"?this.autoPointRemove?.undo():this.manualPointRemove?.undo();}};var fe=class{constructor(e,t){this.ctx=e;this.state=t;}updateMainPoint(e,t){e.val&&(e.val.lat=t.lngLat.lat,e.val.lng=t.lngLat.lng);}updateAuxiliaryPoints(e,t){let i=this.getAuxPointsLatLng(t);i&&(this.updatePrevAuxPoint(e,i.prev),this.updateNextAuxPoint(e,i.next));}updatePrevAuxPoint(e,t){e.prev?.val&&t&&(e.prev.val.lat=t.lat,e.prev.val.lng=t.lng);}updateNextAuxPoint(e,t){e.next?.val&&t&&(e.next.val.lat=t.lat,e.next.val.lng=t.lng);}updateStore=()=>{let e=this.state.getLastEvent(),t=this.state.getSelectedNode();!e||!t?.val||(this.updateMainPoint(t,e),this.updateAuxiliaryPoints(t,e));};getAuxPointsLatLng=e=>{let t=this.state.getSelectedNode();if(!t)return null;let{options:i}=this.ctx,o=t?.prev?.prev,s=t?.next?.next;return i.pointGeneration==="auto"?{next:s?.val?f.getMidpoint(s.val,e.lngLat):null,prev:o?.val?f.getMidpoint(e.lngLat,o.val):null}:null};addPoint(e){let{store:t,options:i}=this.ctx,o=new de(t,i,e.lngLat);return h.commit(o),o.getStep()}removePoint(e){let{store:t,options:i,mode:o,map:s}=this.ctx;t.size===1?t.reset():h.commit(new ve({store:t,options:i,mode:o,map:s,nodeId:e}));}};var ye=class{constructor(e){this.ctx=e;this.pointState=new ce,this.topologyManager=new fe(e,this.pointState),this.events={onPointMouseEnter:this.onPointMouseEnter,onPointMouseLeave:this.onPointMouseLeave,onPointMouseDown:this.onPointMouseDown,onPointMouseUp:this.onPointMouseUp,onMapMouseMove:this.onMapMouseMove},this.firstPoint=new le(this.ctx,this.events),this.auxPoints=new ue(this.ctx,this.events,this.pointState,this.topologyManager);}events;firstPoint;auxPoints;pointState;topologyManager;initConsumers=()=>{this.ctx.mode.addObserver(this.mapModeConsumer),this.ctx.store.addObserver(this.storeEventsConsumer);};removeConsumers=()=>{this.ctx.mode.removeObserver(this.mapModeConsumer),this.ctx.store.removeObserver(this.storeEventsConsumer);};initEvents=()=>{let{map:e}=this.ctx;e.on("click",this.onMapClick),e.on("dblclick",this.onMapDblClick),e.on("mouseenter",r.PointsLayer,this.onPointMouseEnter),e.on("mouseleave",r.PointsLayer,this.onPointMouseLeave),e.on("mousedown",r.PointsLayer,this.onPointMouseDown),e.on("click",r.PointsLayer,this.onPointClick),e.on("mouseup",r.PointsLayer,this.onPointMouseUp),e.on("touchend",r.PointsLayer,this.onPointMouseUp),e.on("touchstart",r.PointsLayer,this.onPointMouseDown),this.initConsumers();};removeEvents=()=>{let{map:e}=this.ctx;e.off("click",this.onMapClick),e.off("dblclick",this.onMapDblClick),e.off("mousemove",this.onMapMouseMove),e.off("mouseenter",r.PointsLayer,this.onPointMouseEnter),e.off("mouseleave",r.PointsLayer,this.onPointMouseLeave),e.off("mousedown",r.PointsLayer,this.onPointMouseDown),e.off("click",r.PointsLayer,this.onPointClick),e.off("mouseup",r.PointsLayer,this.onPointMouseUp),e.off("touchend",r.PointsLayer,this.onPointMouseUp),e.off("touchstart",r.PointsLayer,this.onPointMouseDown),this.firstPoint?.removeEvents(),this.auxPoints?.removeEvents(),this.removeConsumers();};onPointClick=e=>{let{mouseEvents:t,store:i,map:o,options:s}=this.ctx,a=m.queryPointId(o,e.point);M.isLastPoint(i,s,a)&&(t.lastPointMouseClick=!0,t.lastPointMouseUp=!1);};onMapDblClick=e=>{e.preventDefault();};onPointRemove=e=>{let{store:t,renderer:i}=this.ctx;if(t.size===1)t.reset(),this.ctx.panel.hide();else {let o=m.queryPointId(this.ctx.map,e.point),s=t.findNodeById(o);if(!s?.val)return;this.topologyManager.removePoint(s.val.id);}i.execute();};onOwnGeometryLayersClick=e=>m.isFeatureTriggered(e,[r.PointsLayer,r.FirstPointLayer,r.LineLayerTransparent,r.LineLayerBreak]);onMapClick=e=>{let{mode:t,mouseEvents:i,map:o,store:s,renderer:a}=this.ctx;if(t.getClosedGeometry()||this.onOwnGeometryLayersClick(e))return;i.lastPointMouseClick&&(i.lastPointMouseClick=!1),o.getCanvasContainer().style.cursor="grab";let p=this.topologyManager.addPoint(e);c.addPoint({...p,total:s.size},o,t),x.setSinglePointHidden(e),a.execute();};onMoveLeftClickUp=e=>{e.originalEvent.buttons===0&&this.onPointMouseUp();};onMapMouseMove=w(e=>{let{mouseEvents:t}=this.ctx;if(t.pointMouseDown){if(this.pointState.setLastEvent(e),!this.pointState.getSelectedNode())return;let{renderer:i}=this.ctx;this.onMoveLeftClickUp(this.pointState.getLastEvent());let o=this.topologyManager.getAuxPointsLatLng(this.pointState.getLastEvent());i.executeOnMouseMove(this.pointState.getSelectedIdx(),e.lngLat,o),this.pointState.setMoved(!0);}},17);onPointMouseEnter=e=>{let{mouseEvents:t,map:i,store:o,options:s}=this.ctx;if(t&&(t.pointMouseEnter=!0,t.pointMouseDown))return;x.setSinglePointHidden(e);let a=m.queryPointId(i,e.point);M.isLastPoint(o,s,a)&&(t.lastPointMouseEnter=!0,t.lastPointMouseLeave=!1);let p=o.findStepById(a);p&&(this.pointState.setEnteredStep(p),c.enterPoint(Object.assign({},p,{total:o.size}),i));};onPointMouseLeave=e=>{let{mouseEvents:t,store:i,map:o,options:s}=this.ctx;if(t&&(t.pointMouseEnter=!1,e.originalEvent.buttons===0&&(t.pointMouseLeave=!0),t.pointMouseDown))return;let a=m.queryPointId(o,e.point);M.isLastPoint(i,s,a)&&(t.lastPointMouseEnter=!1,t.lastPointMouseLeave=!0),c.leavePoint(Object.assign({},this.pointState.getEnteredStep(),{total:i.size}),o);};storeEventsConsumer=e=>{e.type==="STORE_MUTATED"&&e.data?.size===0&&this.pointState.reset();};mapModeConsumer=e=>{(e.type==="BREAK_CHANGED"||e.type==="MODE_CHANGED")&&this.pointState.reset();};hideLastPointPanel=()=>{let{store:e,panel:t,options:i}=this.ctx,o=this.pointState.getSelectedNode();o?.val&&M.isLastPoint(e,i,o.val.id)&&t.hide();};setSelectedNode=e=>{let{store:t,map:i}=this.ctx,o=m.queryPointId(i,e.point),s=t.findNodeById(o);s&&this.pointState.setSelectedNode(s);};onPointMouseDown=e=>{e.preventDefault(),this.pointState.clearLastEvent();let{mouseEvents:t,map:i,store:o}=this.ctx;if(e.originalEvent.button===2){this.onPointRemove(e);return}this.setSelectedNode(e),Fe(i),this.hideLastPointPanel();let s=m.queryPoint(i,e.point),a=b.getGeometryIndex(o,s?.properties.id);this.pointState.setSelectedIdx(a),t&&(t.pointMouseDown=!0),this.pointState.setStartCoordinates(e.lngLat),i.on("mousemove",this.onMapMouseMove),i.on("touchmove",this.onMapMouseMove);};onPointMouseUp=()=>{let{mouseEvents:e,store:t,panel:i,map:o,options:s,renderer:a}=this.ctx;o.off("mousemove",this.onMapMouseMove),o.off("touchmove",this.onMapMouseMove),e.pointMouseUp=!0;let p=this.pointState.getSelectedNode(),y=this.pointState.getLastEvent(),L=this.pointState.getStartCoordinates();p&&!p.val?.isAuxiliary&&(y&&(this.topologyManager.updateStore(),this.pointState.clearLastEvent()),i?.show(),this.pointState.isMoved()&&(h.commit(new F(t,p,L,o)),this.pointState.setMoved(!1)),this.pointState.partialReset()),e&&(e.pointMouseDown=!1),re(o,s),a.execute();}};var Ee=class extends _{constructor(t){super({...t});this.events=t;this.panelEvents=new Q(t),this.controlEvents=new Z(t),this.pointEvents=new ye(t),this.lineEvents=new se(t),t.map.on("mode:initialize",this.initEvents),t.map.on("mode:remove",this.removeDrawEvents);}panelEvents;controlEvents;pointEvents;lineEvents;initEvents=()=>{this.lineEvents.init(),this.panelEvents?.initEvents(),this.panelEvents?.initConsumers(),this.pointEvents?.initEvents();};removeDrawEvents=()=>{this.panelEvents?.removeEvents(),this.panelEvents?.removeConsumers(),this.pointEvents?.removeEvents(),this.lineEvents?.remove();};removeMapEventsAndConsumers=()=>{this.panelEvents?.removeEvents(),this.pointEvents?.removeEvents(),this.controlEvents?.remove(),this.lineEvents?.remove(),this.events.map.off("mode:initialize",this.initEvents),this.events.map.off("mode:remove",this.removeDrawEvents);}};var Le=class{constructor(e){this.props=e;this.lineButton=void 0,this.polygonButton=void 0,this.breakButton=void 0,this.container=l.create("div","mapboxgl-ctrl mapboxgl-ctrl-group maplibregl-ctrl maplibregl-ctrl-group"),this.createControl();}lineButton;polygonButton;breakButton;container;createControlButton=(e,t,i,o)=>{let s=this.props.options.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"),o&&(a.setAttribute("disabled","true"),a.setAttribute("aria-disabled","true")),l.create("span",`icon ${e} icon-medium`,a),a};createLineButton=()=>{let{mode:e,options:t}=this.props,i=this.props.options.modes.line.visible,o=t.locale.line;i&&(this.lineButton=this.createControlButton("line",o,e.getMode()==="line"));};createPolygonButton=()=>{let{mode:e,options:t}=this.props,i=this.props.options.modes.polygon.visible,o=t.locale.polygon;i&&(this.polygonButton=this.createControlButton("polygon",o,e.getMode()==="polygon"));};createBreakButton=()=>{let{mode:e,options:t}=this.props,i=this.props.options.modes.breakGeometry.visible,o=t.locale.break;if(i){let a=!this.props.options.initial?.closeGeometry,p=e.getBreak();this.breakButton=this.createControlButton("break",o,p,a);}};createControl=()=>{this.createLineButton(),this.createPolygonButton(),this.createBreakButton();};getContainer=()=>this.container};function $e(n){return n.initial?.geometry?n.initial?.geometry:n.modes.initial?n.modes.initial:null}var ge=class extends C{mode;break;closedGeometry;constructor(e){super(),this.mode=$e(e),this.break=!1,this.closedGeometry=e.initial?.closeGeometry??!1;}getMode=()=>this.mode;setMode=e=>{this.mode=e,this.setBreak(!1),this.notify({type:"MODE_CHANGED",data:e});};getBreak=()=>this.break;setBreak=e=>{this.break=e,this.notify({type:"BREAK_CHANGED",data:e});};getClosedGeometry=()=>this.closedGeometry;setClosedGeometry=e=>{this.closedGeometry=e,this.notify({type:"CLOSED_GEOMETRY_CHANGED",data:this.closedGeometry});};isPolygon=()=>this.mode==="polygon"&&this.getClosedGeometry();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 xe=class{#t;#e;constructor(e){this.#t=e,this.#e=this.#t.map.getCanvasContainer(),this.#e.style.cursor=e.mode.getMode()?E.CROSSHAIR:E.AUTO,this.#o();}set=e=>{this.#e.style.cursor=e;};get=()=>this.#e.style.cursor;handleMouseLeave=B(()=>{let{mouseEvents:e,mode:t}=this.#t;if(!e.pointMouseDown){if(!t.getMode()){this.set(E.AUTO);return}t.getClosedGeometry()?this.set(E.AUTO):this.set(E.CROSSHAIR);}},10);handleFirstPointMouseEnter=B(()=>{let{store:e,options:t}=this.#t;b.canCloseGeometry(e,t)&&this.set(E.POINTER);},10);#o(){let{mouseEvents:e}=this.#t;e.addObserver(this.#i);}removeConsumers(){let{mouseEvents:e}=this.#t;e.removeObserver(this.#i);}#i=e=>{let{mode:t,mouseEvents:i,store:o,options:s}=this.#t;if(t.getBreak())return;let{type:a,data:p}=e;if(p)switch(a){case"pointMouseDown":this.set(E.GRABBING);break;case"pointMouseUp":this.set(E.GRAB);break;case"pointMouseEnter":if(i.pointMouseDown)return;this.set(E.GRAB);break;case"pointMouseLeave":this.handleMouseLeave();break;case"lineMouseEnter":if(i.pointMouseDown)return;this.set(E.POINTER);break;case"lineMouseLeave":this.handleMouseLeave();break;case"firstPointMouseEnter":this.handleFirstPointMouseEnter();break;case"firstPointMouseLeave":this.handleMouseLeave();break;case"lastPointMouseEnter":b.isClosedGeometry(o,s)||this.set(E.POINTER);break;case"lastPointMouseLeave":this.handleMouseLeave();break;}}};var Me=class extends C{#t;#e;#o;#i;#n;#s;#r;#a;#p;#l;#u;#c;constructor(){super(),this.#t=!1,this.#e=!1,this.#o=!1,this.#i=!1,this.#n=!1,this.#s=!1,this.#r=!1,this.#a=!1,this.#p=!1,this.#l=!1,this.#u=!1,this.#c=!1;}get firstPointMouseEnter(){return this.#t}set firstPointMouseEnter(e){this.#t=e,this.notify({type:"firstPointMouseEnter",data:e});}get firstPointMouseLeave(){return this.#e}set firstPointMouseLeave(e){this.#e=e,this.notify({type:"firstPointMouseLeave",data:e});}get lastPointMouseClick(){return this.#o}set lastPointMouseClick(e){this.#o=e,this.notify({type:"lastPointMouseClick",data:e});}get lastPointMouseUp(){return this.#i}set lastPointMouseUp(e){this.#i=e,this.notify({type:"lastPointMouseUp",data:e});}get lastPointMouseEnter(){return this.#n}set lastPointMouseEnter(e){this.#n=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.#p}set pointMouseEnter(e){this.#p=e,this.notify({type:"pointMouseEnter",data:e});}get pointMouseLeave(){return this.#l}set pointMouseLeave(e){this.#l=e,this.notify({type:"pointMouseLeave",data:e});}get lineMouseEnter(){return this.#u}set lineMouseEnter(e){this.#u=e,this.notify({type:"lineMouseEnter",data:e});}get lineMouseLeave(){return this.#c}set lineMouseLeave(e){this.#c=e,this.notify({type:"lineMouseLeave",data:e});}};var V=class{static allStepsHaveIds(e){return e.every(t=>"id"in t&&t.id!==void 0)}static checkIfMissingIds(e,t){let i=!t,o=!this.allStepsHaveIds(e);if(i&&o)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 o=i[0]?.lng,s=i[i.length-1]?.lng,a=i[0]?.lat,p=i[i.length-1]?.lat;if((o!==s||a!==p)&&t)throw new Error(G.FIRST_LAST_POINT_NOT_EQUAL)}}static checkInitialStepsOption(e){let{closeGeometry:t,generateId:i,steps:o}=e;this.checkIfMissingIds(o,i),this.checkIfEnoughPointsToClose(o,t),this.checkIfPolygonIsClosed(e);}static init(e){return e?{pointGeneration:e.pointGeneration??u.pointGeneration,panel:We(e),modes:Ze(e),layersPaint:Xe(e),initial:e.initial||u.initial,locale:Qe(e),dynamicLine:e.dynamicLine??u.dynamicLine}:u}};function We(n){return {size:n.panel?.size||u.panel.size,buttons:{undo:{visible:n.panel?.buttons?.undo?.visible??u.panel.buttons.undo.visible},redo:{visible:n.panel?.buttons?.redo?.visible??u.panel.buttons.redo.visible},delete:{visible:n.panel?.buttons?.delete?.visible??u.panel.buttons.delete.visible},save:{visible:n.panel?.buttons?.save?.visible??u.panel.buttons.save.visible,clearOnSave:n.panel?.buttons?.save?.clearOnSave??u.panel.buttons.save.clearOnSave}}}}function Ze(n){return {initial:n.modes?.initial||u.modes.initial,line:{visible:n?.modes?.line?.visible!==void 0?n.modes.line.visible:n?.initial?.geometry==="line"||u.modes.line.visible,closeGeometry:n?.modes?.line?.closeGeometry??u.modes.line.closeGeometry},polygon:{visible:n?.modes?.polygon?.visible!==void 0?n.modes.polygon.visible:n?.initial?.geometry==="polygon"||u.modes.polygon.visible},breakGeometry:{visible:n?.modes?.breakGeometry?.visible??u.modes.breakGeometry.visible}}}function Xe(n){return {onLinePoint:{"circle-radius":n.layersPaint?.onLinePoint?.["circle-radius"]||k["circle-radius"],"circle-color":n.layersPaint?.onLinePoint?.["circle-color"]||k["circle-color"],"circle-stroke-color":n.layersPaint?.onLinePoint?.["circle-stroke-color"]||k["circle-stroke-color"],"circle-stroke-width":n.layersPaint?.onLinePoint?.["circle-stroke-width"]||k["circle-stroke-width"],...n.layersPaint?.onLinePoint},firstPoint:{"circle-radius":n.layersPaint?.firstPoint?.["circle-radius"]||N["circle-radius"],"circle-color":n.layersPaint?.firstPoint?.["circle-color"]||N["circle-color"],"circle-stroke-color":n.layersPaint?.firstPoint?.["circle-stroke-color"]||N["circle-stroke-color"],"circle-stroke-width":n.layersPaint?.firstPoint?.["circle-stroke-width"]||N["circle-stroke-width"],...n.layersPaint?.firstPoint},points:{"circle-radius":n.layersPaint?.points?.["circle-radius"]||R["circle-radius"],"circle-color":n.layersPaint?.points?.["circle-color"]||R["circle-color"],"circle-stroke-color":n.layersPaint?.points?.["circle-stroke-color"]||R["circle-stroke-color"],"circle-stroke-width":n.layersPaint?.points?.["circle-stroke-width"]||R["circle-stroke-width"],...n.layersPaint?.points},auxiliaryPoint:{"circle-radius":n.layersPaint?.auxiliaryPoint?.["circle-radius"]||U["circle-radius"],"circle-color":n.layersPaint?.auxiliaryPoint?.["circle-color"]||U["circle-color"],"circle-stroke-color":n.layersPaint?.auxiliaryPoint?.["circle-stroke-color"]||U["circle-stroke-color"],"circle-stroke-width":n.layersPaint?.auxiliaryPoint?.["circle-stroke-width"]||U["circle-stroke-width"],...n.layersPaint?.auxiliaryPoint},line:{"line-width":n.layersPaint?.line?.["line-width"]||D["line-width"],"line-color":n.layersPaint?.line?.["line-color"]||D["line-color"],"line-opacity":n.layersPaint?.line?.["line-opacity"]||D["line-opacity"],...n.layersPaint?.line},polygon:{"fill-color":n.layersPaint?.polygon?.["fill-color"]||H["fill-color"],"fill-opacity":n.layersPaint?.polygon?.["fill-opacity"]||H["fill-opacity"],...n.layersPaint?.polygon},breakLine:{"line-width":n.layersPaint?.breakLine?.["line-width"]||I["line-width"],"line-color":n.layersPaint?.breakLine?.["line-color"]||I["line-color"],"line-dasharray":n.layersPaint?.breakLine?.["line-dasharray"]||I["line-dasharray"],...n.layersPaint?.breakLine}}}function Qe(n){return {save:n.locale?.save??u.locale.save,delete:n.locale?.delete??u.locale.delete,undo:n.locale?.undo??u.locale.undo,redo:n.locale?.redo??u.locale.redo,line:n.locale?.line??u.locale.line,polygon:n.locale?.polygon??u.locale.polygon,break:n.locale?.break??u.locale.break,closeLine:n.locale?.closeLine??u.locale.closeLine,createPolygon:n.locale?.createPolygon??u.locale.createPolygon}}var be=class{constructor(e){this.ctx=e;}init(){this.add(),this.swap(r.LineLayer,r.SinglePointLayer),this.swap(r.LineLayerTransparent,r.SinglePointLayer),this.swap(r.LineLayerTransparent,r.FirstPointLayer),this.swap(r.LineLayerTransparent,r.PointsLayer),this.swap(r.PolygonLayer,r.LineLayer),this.initConsumers();}initConsumers=()=>{this.ctx.store.addObserver(this.onStoreChange);};removeConsumers=()=>{this.ctx.store.removeObserver(this.onStoreChange);};onStoreChange=B(e=>{if(["STORE_MUTATED","STORE_CLOSE_GEOMETRY","STORE_BREAK_GEOMETRY","STORE_CLEARED"].includes(e.type)){let{map:i,store:o,mode:s}=this.ctx;s.getMode()==="polygon"&&o.circular.isCircular()?i.setLayoutProperty(r.PolygonLayer,"visibility","visible"):i.setLayoutProperty(r.PolygonLayer,"visibility","none");}},10);add=()=>{let e=j(this.ctx.options);for(let t of e)this.ctx.map.getLayer(t.id)||this.ctx.map.addLayer(t);};swap=(e,t)=>{let i=this.ctx.map.getLayer(e),o=this.ctx.map.getLayer(t);i&&o&&this.ctx.map.moveLayer(e,t);};removeLayers=()=>{for(let e of Object.values(r))this.ctx.map.getLayer(e)&&this.ctx.map.removeLayer(e);};remove=()=>{this.removeConsumers(),this.removeLayers();}};var Pe=class{constructor(e){this.ctx=e;}init(){for(let e of Object.values(d))this.ctx.map.getSource(e)||this.ctx.map.addSource(e,{type:"geojson",data:{type:"FeatureCollection",features:[]},promoteId:"id"});}remove(){for(let e of Object.values(d))this.ctx.map.getSource(e)&&this.ctx.map.removeSource(e);}};var Ce=class{constructor(e){this.ctx=e;this.sources=new Pe(this.ctx),this.layers=new be(this.ctx),this.init();}sources;layers;init=()=>{this.sources.init(),this.layers.init();};remove=()=>{this.layers.remove(),this.sources.remove();}};var Ne=class n{#t;#e;#o;#i;#n;#s;#r;#a;#p;#l;static#u=null;static#c=!1;constructor(e){if(this.#i=V.init(e),this.#i.initial&&V.checkInitialStepsOption(this.#i.initial),n.#c)throw new Error("Use 'DrawLibre.getInstance()' instead of 'new DrawLibre()'.");n.#c=!0,this.#e=void 0,this.#o=void 0,this.#n=void 0,this.#s=void 0,this.#a=void 0,this.#r=void 0,this.#l=void 0,this.#p=void 0;}static getInstance(e){return n.#u||(n.#u=new n(e)),n.#u}onAdd=e=>{this.#e=new q(this.#i),this.#o=new ge(this.#i),this.#r=new $({map:e,mode:this.#o,options:this.#i,store:this.#e}),this.#s=new Ce({map:e,store:this.#e,mode:this.#o,options:this.#i}),this.#a=new _({map:e,store:this.#e,options:this.#i,mode:this.#o});let t=new Le({options:this.#i,mode:this.#o});return this.#l=new Me,this.#p=new xe({map:e,mode:this.#o,mouseEvents:this.#l,store:this.#e,options:this.#i}),this.#n=new Ee({map:e,store:this.#e,options:this.#i,panel:this.#r,control:t,mode:this.#o,renderer:this.#a,mouseEvents:this.#l}),this.#o.getMode()&&e.fire("mode:initialize"),this.#o.pingConsumers(),this.#e.pingConsumers(),this.#t=t.getContainer(),this.#t};onRemove=()=>{this.#p?.removeConsumers(),this.#s?.remove(),this.#n?.removeMapEventsAndConsumers(),this.#r?.destroy(),this.#e?.reset(),this.#o?.unsubscribe(),this.#t&&l.remove(this.#t);};setSteps=e=>{if(Array.isArray(e))for(let t of e){let i={...t,id:t.id||g()};this.#e?.push(i);}else throw new Error("Invalid argument. Expected an array of steps.");this.#a?.execute();};findStepById=e=>this.#e?.findStepById(e);findNodeById=e=>this.#e?.findNodeById(e);getAllSteps=(e="array")=>{if(e==="array"&&this.#e)return M.toArray(this.#e.head);if(e==="linkedlist")return {head:this.#e?.head,tail:this.#e?.tail,size:this.#e?.size};throw new Error("Invalid type specified. Use 'array' or 'linkedlist'.")};setOptions=e=>{this.#i=e(this.#i);};removeAllSteps=()=>{this.#e?.reset(),this.#r?.destroy(),this.#a?.execute();}};
1
+ var Y=class{_isHidden=!0;_anchor={dx:0,dy:0};_pendingCoord=null;_rafId=0;_listenersActive=!1;get isHidden(){return this._isHidden}set isHidden(e){this._isHidden=e;}get anchor(){return {...this._anchor}}set anchor(e){this._anchor={...e};}get pendingCoord(){return this._pendingCoord}set pendingCoord(e){this._pendingCoord=e;}get rafId(){return this._rafId}set rafId(e){this._rafId=e;}get listenersActive(){return this._listenersActive}set listenersActive(e){this._listenersActive=e;}reset(){this._isHidden=!0,this._anchor={dx:0,dy:0},this._pendingCoord=null,this._rafId=0,this._listenersActive=!1;}};var l=class{static create(e,t,i){let o=window.document.createElement(e);return t!==void 0&&(o.className=t),i&&i.appendChild(o),o}static remove(e){e.parentNode&&e.parentNode.removeChild(e);}static addEventListener(e,t,i,o={}){e&&e.addEventListener(t,i,o);}static removeEventListener(e,t,i,o={}){e&&e.removeEventListener(t,i,o);}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 Be={type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[]}}]};var s={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",AuxiliaryPointLayer:"mdl-auxiliary-point-layer"},h={UnifiedSource:"mdl-unified-source",LineDynamicSource:"mdl-line-dynamic-source",LineSourceBreak:"mdl-line-source-break",SinglePointSource:"mdl-single-point-source"},N={large:6.5,default:5.5},j={large:"#FF6464",default:"#666666"},k={"circle-radius":N.default,"circle-color":"#FEFFFE","circle-stroke-color":j.default,"circle-stroke-width":3},U={"circle-radius":N.default-1.5,"circle-color":"#FEFFFE","circle-stroke-color":"#666666","circle-stroke-width":2},R={"circle-radius":N.large,"circle-color":"#FEFFFE","circle-stroke-color":"#666666","circle-stroke-width":3},H={"fill-color":"grey","fill-opacity":.4},B={"line-width":3,"line-color":"grey","line-opacity":.7},D={"circle-radius":N.default,"circle-color":"#FEFFFE","circle-stroke-color":"#666666","circle-stroke-width":3},_={"line-width":3,"line-color":"#FF6464","line-dasharray":[3,3]},J=n=>[{id:s.SinglePointLayer,source:h.SinglePointSource,type:"circle",paint:n.layersPaint.onLinePoint,layout:{visibility:"none"}},{id:s.PolygonLayer,source:h.UnifiedSource,type:"fill",paint:n.layersPaint.polygon,layout:{visibility:"none"},filter:["==","$type","Polygon"]},{id:s.LineDynamicLayer,source:h.LineDynamicSource,type:"line",paint:n.layersPaint.line,layout:{visibility:"none"}},{id:s.LineLayer,source:h.UnifiedSource,type:"line",paint:n.layersPaint.line,layout:{visibility:"visible"},filter:["==","$type","LineString"]},{id:s.LineLayerTransparent,source:h.UnifiedSource,type:"line",paint:{"line-width":4,"line-color":"transparent"},filter:["==","$type","LineString"]},{id:s.LineLayerBreak,source:h.LineSourceBreak,type:"line",paint:n.layersPaint.breakLine,layout:{visibility:"none"}},{id:s.PointsLayer,source:h.UnifiedSource,type:"circle",paint:n.layersPaint.points,filter:["all",["==","$type","Point"],["==","isFirst",!1],["==","isAuxiliary",!1]]},{id:s.FirstPointLayer,source:h.UnifiedSource,type:"circle",paint:n.layersPaint.firstPoint,filter:["==",["get","isFirst"],!0],layout:{visibility:"none"}},{id:s.AuxiliaryPointLayer,source:h.UnifiedSource,type:"circle",paint:n.layersPaint.auxiliaryPoint,filter:["==",["get","isAuxiliary"],!0]}];var m=class{static isFeatureTriggered(e,t){return e.target.queryRenderedFeatures(e.point,{layers:t}).some(o=>t.includes(o.layer.id))}static getPixelCoordinates=(e,t)=>{let{lat:i,lng:o}=t;return e.project([o,i])};static queryPointId=(e,t)=>e.queryRenderedFeatures(t,{layers:[s.PointsLayer,s.FirstPointLayer,s.AuxiliaryPointLayer,s.SinglePointLayer]})?.[0]?.properties.id;static queryPoint=(e,t)=>e.queryRenderedFeatures(t,{layers:[s.PointsLayer,s.FirstPointLayer,s.AuxiliaryPointLayer,s.SinglePointLayer]})?.[0]},S=class{static#e(e){let t=[],i=e.head,o=new Set;for(;i!==null;){if(o.has(i.val?.id)){e.head&&e.head.val&&t.push([e.head.val.lng,e.head.val.lat]);break}o.add(i.val?.id),i.val&&t.push([i.val.lng,i.val.lat]),i=i.next;}return t}static getLine(e,t){return {type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[e,t]}}]}}static getAllLines(e){return {type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:e}}]}}static getPolygon(e){return {type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[e]}}]}}static getPoints(e){let t=e.head,i=[],o=new Set;for(;t!==null&&!o.has(t.val?.id);){if(t.val){let r=t.val,a=t.val.id===e.head?.val?.id;i.push({type:"Feature",properties:{id:r.id,lat:r.lat,lng:r.lng,isFirst:a,isAuxiliary:r.isAuxiliary},geometry:{type:"Point",coordinates:[r.lng,r.lat]}});}o.add(t.val?.id),t=t.next;}return {type:"FeatureCollection",features:i}}static getUnifiedFeatures(e){let t=this.getPoints(e).features,i=this.#e(e),o=this.getAllLines(i).features,r=this.getPolygon(i).features;return {type:"FeatureCollection",features:[...t,...o,...r]}}},P=class{static getGeometryIndex=(e,t)=>{let i=e.head,o=0,r=new Set;for(;i!==null&&!r.has(i.val?.id);){if(i.val?.id===t)return o;r.add(i.val?.id),o++,i=i.next;}return -1};static distance=(e,t)=>Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2);static checkIfPointIsOnLine=(e,t,i)=>{let r=this.distance(e,t),a=this.distance(e,i),p=this.distance(i,t);return Math.abs(a+p-r)<.1};static isClosedGeometry=(e,t)=>t.pointGeneration==="auto"?e.tail?.next?.val?.id===e.head?.val?.id&&e.tail?.next!==null:e.tail?.next===e.head;static breakGeometry=(e,t,i)=>{e.head&&(t.pointGeneration==="auto"?(i.val?.isAuxiliary?(e.head=i.next,e.head.prev=null,e.tail=i.prev,e.tail.next=null):(e.head=i.next?.next,e.head.prev=null,e.tail=i,e.tail.next=null),e.size=e.size-1):(e.head=i.next,e.head.prev=null,e.tail=i,e.tail.next=null));};static closeGeometry=(e,t)=>{e.tail&&e.head&&(e.tail.next=e.head,e.head.prev=e.tail),t.setClosedGeometry(!0);};static canCloseGeometry=(e,t)=>(t.pointGeneration==="auto"?e.size>3:e.size>2)&&!this.isClosedGeometry(e,t);static canBreakClosedGeometry=(e,t)=>t.pointGeneration==="auto"?e.size<=3:e.size<=2},g=()=>{if("crypto"in window&&"randomUUID"in window.crypto)return window.crypto.randomUUID();function n(){return "0123456789abcdef"[Math.floor(Math.random()*16)]}function e(o){let r="";for(let a=0;a<o;a++)r+=n();return r}function t(o){let r=o===0,a=o===4;return r?8:a?12:4}let i=[];for(let o=0;o<5;o++)i.push(e(t(o)));return i.join("-")},O=(n,e)=>{let t,i=!0;function o(){i&&t&&(n(...t),t=null,i=!1,setTimeout(()=>{i=!0,o();},e));}return function(...r){t=r,o();}},I=(n,e)=>{let t;return function(...i){clearTimeout(t),t=window.setTimeout(()=>{n(...i);},e);}},x=n=>{n&&(n.setAttribute("disabled","true"),n.setAttribute("aria-disabled","true"));},T=n=>{n&&(n.removeAttribute("disabled"),n.removeAttribute("aria-disabled"));};var $=class{constructor(e){this.ctx=e;this.root=l.create("div","dashboard-container"),this.buttonContainer=l.create("div","dashboard",this.root),this.renderButtons(),e.map.getContainer().appendChild(this.root);}root;buttonContainer;buttons={};createButton(e,t,i,o){let r=l.create("button",`panel-button panel-button-${i}`,o);return r.setAttribute("data-type",e),r.setAttribute("aria-label",t),l.create("span",`icon ${e} icon-${i}`,r),r}renderButtons(){let{panel:e,locale:t}=this.ctx.options,{buttons:i,size:o}=e;Object.keys(i).forEach(r=>{if(!i[r].visible)return;let a=this.createButton(r,t[r],o,this.buttonContainer);(r==="undo"||r==="redo")&&x(a),this.buttons[r]=a;});}getButton=e=>{let t=this?.buttons?.[e];return t||console.warn(`[PanelView] Button "${e}" not initialized`),t??null};getRoot=()=>this.root;show=()=>{this.root.classList.remove("hidden");};hide=()=>{this.root.classList.add("hidden");};setTransform=(e,t)=>{this.root.style.transform=`translate(${e}px, ${t}px)`;};observeResize=e=>{let t=new ResizeObserver(e);return t.observe(this.root),t};destroy=()=>{this.root.remove();}};var v={getMidpoint(n,e){return {lat:(n.lat+e.lat)/2,lng:(n.lng+e.lng)/2}},createAuxiliaryPoint(n,e){let t=v.getMidpoint(n,e);return {lat:t.lat,lng:t.lng,isAuxiliary:!0,id:g()}}},M={setFirstPointVisible(n){n.setLayoutProperty(s.FirstPointLayer,"visibility","visible");},setFirstPointHidden(n){n.setLayoutProperty(s.FirstPointLayer,"visibility","none");},setSinglePointVisible(n){n.target.setLayoutProperty(s.SinglePointLayer,"visibility","visible");},setSinglePointHidden(n){let e=n.target;setTimeout(()=>{e.setLayoutProperty(s.SinglePointLayer,"visibility","none");},33);}},Te={default(n){n.setFilter(s.PointsLayer,["all",["==","$type","Point"],["==","isFirst",!1],["==","isAuxiliary",!1]]);},closedGeometry(n){n.setFilter(s.PointsLayer,["all",["==","$type","Point"],["==","isAuxiliary",!1]]);}};var C=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 W=class{constructor(e,t){this.store=e;this.options=t;this.store=e;}isCircular=()=>{let{head:e,tail:t}=this.store;return !e||!t?!1:e===t.next&&t===e.prev};canBreak=()=>{let{size:e}=this.store,t=this.options?.pointGeneration==="auto"?3:2;return e<=t};canClose=()=>{let{size:e}=this.store;return (this.options?.pointGeneration==="auto"?e>3:e>2)&&!this.isCircular()};break=e=>{if(this.store.head)if(this.options?.pointGeneration==="auto")if(e.val?.isAuxiliary){let t=e.val?.id;this.store.head=e.next,this.store.tail=e.prev,this.store.removeNodeById(t),this.store.head.prev=null,this.store.tail.next=null;}else {let t=e.next?.val?.id;this.store.head=e.next?.next,this.store.tail=e,this.store.removeNodeById(t),this.store.head.prev=null,this.store.tail.next=null;}else this.store.head=e.next,this.store.head.prev=null,this.store.tail=e,this.store.tail.next=null;};close=()=>{let{head:e,tail:t}=this.store;!e||!t||(t.next=e,e.prev=t);}};var z=class{val;prev;next;constructor(e=null,t=null,i=null){this.val=e,this.prev=i,this.next=t;}},q=class extends C{constructor(t){super();this.options=t;let i=b.initStore(t);this.circular=new W(this,t),this.map=i?i.map:new Map,this.head=i?i.head:null,this.tail=i?i.tail:null,this.size=i?i.size:0;}head;tail;size;map;circular;push=t=>{let i=new z(t);return this.head?this.tail&&(i.prev=this.tail,this.tail.next=i,this.tail=i):this.head=this.tail=i,this.map.set(t.id,i),this.size++,this.pingConsumers(),i};unshift=t=>{let i=new z(t);i.next=this.head,this.head=i,this.circular.isCircular()&&this.tail&&(this.tail.next=i,i.prev=this.tail),this.map.set(t.id,i),this.size++,this.pingConsumers();};insertAfter=(t,i)=>{if(!t)return null;let o=new z(i);return o.prev=t,o.next=t.next,this.tail===t&&this.head===t.next&&(this.tail=o,this.head.prev=o),t.next&&(t.next.prev=o),t.next=o,this.map.set(i.id,o),this.size++,this.pingConsumers(),o};removeNodeById(t){let i=this.map.get(t);return i?(this.size===1?(this.head=null,this.tail=null):(i.prev&&(i.prev.next=i.next),i.next&&(i.next.prev=i.prev),i===this.head&&(this.head=i.next,this.head?.prev&&this.tail&&(this.tail.next=this.head)),i===this.tail&&(this.tail=i.prev,this.head&&this.tail?.next&&(this.head.prev=this.tail))),this.map.delete(t),this.size--,this.pingConsumers(),i):null}findStepById(t){let i=this.map.get(t);return i?i.val:null}findNodeById(t){let i=this.map.get(t);return i||null}reset=()=>{this.head=null,this.tail=null,this.size=0,this.map.clear(),this.notify({type:"STORE_CLEARED"});};pingConsumers=()=>{this.notify({type:"STORE_MUTATED",data:{head:this.head,tail:this.tail,size:this.size}});}},b=class n{static isLastPoint=(e,t,i)=>t.pointGeneration==="auto"&&e.tail?.next===e.head?e.tail?.prev?.val?.id===i:e.tail?.val?.id===i;static initStore(e){if(!e?.initial)return null;if(e&&e.initial&&!e.initial.steps.length)throw new Error(G.EMPTY_INITIAL_STATE);return e&&e.initial.steps?n.fromArray(e.initial,e.pointGeneration):null}static generateIdForSteps=e=>e.map((t,i)=>({...t,isAuxiliary:!1,isFirst:i===0,id:g()}));static buildStepSequence(e,t,i){let o=new q,r=t?e.slice(0,-1):e;return r.forEach((a,p)=>{if(o.push(a),i==="auto"){if(r[p+1]){let w=v.createAuxiliaryPoint(a,r[p+1]);o.push(w);}else if(t){let w=v.createAuxiliaryPoint(a,r[0]);o.push(w);}}}),o}static fromArray(e,t){let{steps:i,closeGeometry:o,generateId:r}=e,a=r?this.generateIdForSteps(i):i,p=this.buildStepSequence(a,o,t);return o&&p.tail&&p.head&&(p.tail.next=p.head,p.head.prev=p.tail),p}static toArray(e){if(!e)return [];let t=new Set,i=[],o=e;for(;o!==null&&!t.has(o);)t.add(o),i.push(o.val),o=o.next;return i}};var Ke=8,Ye=8,A=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:o,height:r}=this.#t();return {x:i-Ye-o,y:t-r-2}};#o=e=>{let{bottom:t,left:i,right:o}=e.target.getBoundingClientRect(),{width:r}=this.#t();return {x:(o-i)/2+i-r/2,y:t+Ke}};getPosition=(e,t)=>t==="left"?this.#i(e):this.#o(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 y={RIGHTCLICKREMOVE:"mdl:rightclickremove",POINTENTER:"mdl:pointenter",POINTLEAVE:"mdl:pointleave",MOVEEND:"mdl:moveend",ADD:"mdl:add",UNDO:"mdl:undo",REDO:"mdl:redo",REMOVEALL:"mdl:removeall",SAVE:"mdl:save",BREAK:"mdl:break",MODECHANGED:"mdl:modechanged"},_e=768,c={pointGeneration:"manual",panel:{size:"medium",buttons:{undo:{visible:!0},redo:{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:R,firstPoint:k,points:D,line:B,polygon:H,breakLine:_},initial:null,dynamicLine:!0,locale:{save:"Save",delete:"Delete all",undo:"Undo",redo:"Redo",line:"Line",polygon:"Polygon",break:"Split",closeLine:"Close the line",createPolygon:"Create a polygon"}};var u=class{static addPoint(e,t,i){t.fire(y.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(y.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 pointRemoveRightClick(e,t){t.fire(y.RIGHTCLICKREMOVE,{id:e.id,coordinates:{lat:e.lat,lng:e.lng},total:e.total,timestamp:Date.now()});}static enterPoint(e,t){t.fire(y.POINTENTER,{id:e.id,coordinates:{lat:e.lat,lng:e.lng},total:e.total,timestamp:Date.now()});}static leavePoint(e,t){t.fire(y.POINTLEAVE,{id:e.id,coordinates:{lat:e.lat,lng:e.lng},total:e.total,timestamp:Date.now()});}static undo(e,t,i){t.fire(y.UNDO,{originalEvent:i,id:e.id,coordinates:{lat:e.lat,lng:e.lng},total:e.total,timestamp:Date.now()});}static redo(e,t,i){t.fire(y.REDO,{originalEvent:i,id:e.id,coordinates:{lat:e.lat,lng:e.lng},total:e.total,timestamp:Date.now()});}static modeChanged(e,t){e.fire(y.MODECHANGED,{mode:t});}static removeAllPoints(e,t){e.fire(y.REMOVEALL,{originalEvent:t});}static onSaveClick(e,t,i){let{map:o,mode:r}=e;o.fire(y.SAVE,{originalEvent:i,timestamp:Date.now(),steps:t,mode:{geometry:r.getMode(),closedGeometry:r.getClosedGeometry()}});}static onLineBreak(e){e.fire(y.BREAK);}};var Ae=class{constructor(e,t,i=[]){this.type=e;this.payload=t;this.commands=i;}add(e){this.commands.push(e);}execute(){if(this.commands)for(let e of this.commands)e.execute();}undo(){if(this.commands)for(let e=this.commands.length-1;e>=0;e--)this.commands[e]?.undo();}},Ne=class n extends C{transaction=null;undoStack=[];redoStack=[];static instance=null;static getInstance(){return n.instance||(n.instance=new n),n.instance}commit=e=>{e.execute(),this.transaction?this.transaction.add(e):this.undoStack.push(e),this.redoStack.length=0,this.pingConsumers();};undo=()=>{let e=this.undoStack.pop();if(e)return e.undo(),this.redoStack.push(e),this.pingConsumers(),e};redo=()=>{let e=this.redoStack.pop();return e?(e.execute(),this.undoStack.push(e),this.pingConsumers(),e):null};beginTransaction=(e="compound",t=null)=>{this.transaction||(this.transaction=new Ae(e,t));};commitTransaction=()=>{if(!this.transaction)return;let e=this.transaction;this.transaction=null,this.undoStack.push(e),this.pingConsumers();};getRedoStackLength=()=>this.redoStack.length;getUndoStackLength=()=>this.undoStack;resetStacks=()=>{this.undoStack=[],this.redoStack=[],this.notify({type:"REDO_STACK_CHANGED",data:0});};pingConsumers=()=>{this.notify({type:"REDO_STACK_CHANGED",data:this.redoStack.length}),this.notify({type:"UNDO_STACK_CHANGED",data:this.undoStack.length});}},d=Ne.getInstance();var ke=class n{static instance=null;ctx=null;unifiedGeoJSON;constructor(){this.unifiedGeoJSON={type:"FeatureCollection",features:[]};}initialize(e){return this.ctx=e,this.unifiedGeoJSON=S.getUnifiedFeatures(this.ctx.store),this.execute(),n.instance}static getInstance(){return n.instance||(n.instance=new n),n.instance}getContext(){if(!this.ctx)throw new Error("Somehow trolled with Renderer.getContext, check the Renderer.initialize");return this.ctx}updateLine(e,t){let{mode:i}=this.getContext(),o=this.unifiedGeoJSON.features.at(-2)?.geometry.coordinates;o&&(o[e]=[t.lng,t.lat],i.getClosedGeometry()&&e===0&&(o[o.length-1]=[t.lng,t.lat]));}updatePolygon(e,t){let{mode:i}=this.getContext(),o=this.unifiedGeoJSON.features.at(-1)?.geometry.coordinates[0];o&&(o[e]=[t.lng,t.lat],i.getClosedGeometry()&&e===0&&(o[o.length-1]=[t.lng,t.lat]));}updatePoint(e,t){let i=this.unifiedGeoJSON?.features?.[e];i?.geometry?.coordinates&&(i.geometry.coordinates=[t.lng,t.lat]);}executeOnMouseMove=(e,t,i)=>{let{map:o,mode:r,options:a,store:p}=this.getContext(),L=e===0?p.size-1:e-1;this.updatePoint(e,t),i&&i.prev&&this.updatePoint(L,i.prev),i&&i.next&&this.updatePoint(e+1,i.next),this.updateLine(e,t),i&&i.prev&&this.updateLine(L,i.prev),i&&i.next&&this.updateLine(e+1,i.next),a.modes.polygon.visible&&r.isPolygon()&&(this.updatePolygon(e,t),i&&i.prev&&this.updatePolygon(L,i.prev),i&&i.next&&this.updatePolygon(e+1,i.next));let K=o.getSource(h.UnifiedSource);K&&K.setData(this.unifiedGeoJSON);};execute(){let{map:e,store:t}=this.getContext();this.unifiedGeoJSON=S.getUnifiedFeatures(t);let i=e.getSource(h.UnifiedSource);i&&i.setData(this.unifiedGeoJSON);}resetGeometries=()=>{let{map:e}=this.getContext(),t=e.getSource(h.UnifiedSource);t&&t.setData({type:"FeatureCollection",features:[]});}},f=ke.getInstance();var Z=class{constructor(e){this.ctx=e;this.tooltip=new A;}tooltip;initEvents(){let e=this.ctx.view.getButton("undo");e&&(l.addEventListener(e,"click",this.onUndoClick),l.addEventListener(e,"mouseenter",this.onMouseEnter),l.addEventListener(e,"mouseleave",this.onMouseLeave));let t=this.ctx.view.getButton("redo");t&&(l.addEventListener(t,"click",this.onRedoClick),l.addEventListener(t,"mouseenter",this.onMouseEnter),l.addEventListener(t,"mouseleave",this.onMouseLeave));let i=this.ctx.view.getButton("delete");i&&(l.addEventListener(i,"click",this.onRemoveAll),l.addEventListener(i,"mouseenter",this.onMouseEnter),l.addEventListener(i,"mouseleave",this.onMouseLeave));let o=this.ctx.view.getButton("save");o&&(l.addEventListener(o,"click",this.onSaveClick),l.addEventListener(o,"mouseenter",this.onMouseEnter),l.addEventListener(o,"mouseleave",this.onMouseLeave));}removeEvents(){let e=this.ctx.view.getButton("undo");e&&(l.removeEventListener(e,"click",this.onUndoClick),l.removeEventListener(e,"mouseenter",this.onMouseEnter),l.removeEventListener(e,"mouseleave",this.onMouseLeave));let t=this.ctx.view.getButton("redo");t&&(l.removeEventListener(t,"click",this.onRedoClick),l.removeEventListener(t,"mouseenter",this.onMouseEnter),l.removeEventListener(t,"mouseleave",this.onMouseLeave));let i=this.ctx.view.getButton("delete");i&&(l.removeEventListener(i,"click",this.onRemoveAll),l.removeEventListener(i,"mouseenter",this.onMouseEnter),l.removeEventListener(i,"mouseleave",this.onMouseLeave));let o=this.ctx.view.getButton("save");o&&(l.removeEventListener(o,"click",this.onSaveClick),l.removeEventListener(o,"mouseenter",this.onMouseEnter),l.removeEventListener(o,"mouseleave",this.onMouseLeave));}getButtonLabel=e=>{let{options:t}=this.ctx;return {undo:t.locale.undo,redo:t.locale.redo,delete:t.locale.delete,save:t.locale.save}[e]};onMouseEnter=e=>{let t=e.target.getAttribute("data-type");if(t){let i=this.getButtonLabel(t);this.tooltip.create({label:i,placement:"bottom"}).setPosition(this.tooltip.getPosition(e,"bottom"));}};onMouseLeave=()=>{this.tooltip.remove();};onRemoveAll=e=>{let{mode:t,view:i,store:o,map:r}=this.ctx;o.reset(),i.hide(),t.reset(),this.tooltip.remove(),d.resetStacks(),f.resetGeometries(),u.removeAllPoints(r,e);};onUndoClick=e=>{let{store:t,map:i,view:o}=this.ctx,r=d.getRedoStackLength();t.size===1&&r?(t.reset(),this.ctx.view.hide()):d.undo(),this.tooltip.remove(),u.undo({...t.tail?.val,total:t.size},i,e),f.execute();};onRedoClick=e=>{let{store:t,map:i}=this.ctx;d.redo(),u.redo({...t.tail?.val,total:t.size},i,e),f.execute();};onSaveClick=e=>{let{store:t,options:i}=this.ctx;u.onSaveClick(this.ctx,b.toArray(t.head),e),this.tooltip.remove(),i.panel.buttons.save.clearOnSave&&this.onRemoveAll(e);}};var X=class{constructor(e){this.ctx=e;}initConsumers(){this.ctx.store.addObserver(this.onStoreChangeConsumer),this.ctx.mode?.addObserver(this.onMapModeConsumer),d.addObserver(this.onTimelineChangeConsumer);}removeConsumers(){this.ctx.store.removeObserver(this.onStoreChangeConsumer),this.ctx.mode?.removeObserver(this.onMapModeConsumer),d.removeObserver(this.onTimelineChangeConsumer);}onTimelineChangeConsumer=e=>{let{type:t,data:i}=e;t==="REDO_STACK_CHANGED"&&(i?T(this.ctx.view.getButton("redo")):x(this.ctx.view.getButton("redo"))),t==="UNDO_STACK_CHANGED"&&(i?T(this.ctx.view.getButton("undo")):x(this.ctx.view.getButton("undo")));};onStoreChangeConsumer=e=>{if(e.type==="STORE_MUTATED"){let{data:t}=e;if(t?.size===0)this.ctx.view.hide();else {let i=Object.assign({},t);for(;i.tail;)if(i.tail?.val?.isAuxiliary)i.tail=i.tail?.prev;else {i.tail?.val&&this.ctx.setPanelLocation({lat:i.tail.val.lat,lng:i.tail.val.lng});break}}}};onMapModeConsumer=e=>{let{store:t}=this.ctx,{type:i,data:o}=e;i==="MODE_CHANGED"&&!o&&this.ctx.view.hide(),i==="MODE_CHANGED"&&o&&t.tail?.val&&this.ctx.setPanelLocation({lat:t.tail?.val?.lat,lng:t.tail?.val?.lng});}};var je=20,Q=class{constructor(e){this.ctx=e;this.view=new $(e),this.events=new Z({...e,view:this.view}),this.observer=new X({...e,view:this.view,setPanelLocation:this.setPanelLocation}),this.init();}view;state=new Y;events;observer;resizeObserver;onMapMove=()=>this.schedulePositionUpdate();init(){let{store:e}=this.ctx;this.resizeObserver=this.view.observeResize(this.measureAnchor),this.measureAnchor(),e.tail?.val&&this.setPanelLocation(e.tail.val),this.events.initEvents(),this.observer.initConsumers();}destroy(){this.observer.removeConsumers(),this.events.removeEvents(),this.state.listenersActive&&this.disableListeners(),this.resizeObserver.disconnect(),cancelAnimationFrame(this.state.rafId),this.view.destroy();}enableListeners(){if(this.state.listenersActive)return;let e=this.ctx.map;e.on("move",this.onMapMove),e.on("zoom",this.onMapMove),this.state.listenersActive=!0;}disableListeners(){if(!this.state.listenersActive)return;let e=this.ctx.map;e.off("move",this.onMapMove),e.off("zoom",this.onMapMove),this.state.listenersActive=!1;}setPanelLocation=e=>{this.state.pendingCoord=e,this.enableListeners(),this.schedulePositionUpdate(),this.show();};measureAnchor=()=>{let{width:e,height:t}=this.view.getRoot().getBoundingClientRect();this.state.anchor={dx:-e/2,dy:-t-je},this.schedulePositionUpdate();};schedulePositionUpdate=()=>{this.state.rafId||(this.state.rafId=requestAnimationFrame(()=>{if(this.state.rafId=0,this.state.pendingCoord){let e=this.ctx.map.project(this.state.pendingCoord),{dx:t,dy:i}=this.state.anchor;this.view.setTransform(e.x+t,e.y+i);}}));};setVisible(e){this.state.isHidden=!e,e?this.view.show():this.view.hide();}show=()=>this.setVisible(!0);hide=()=>this.setVisible(!1)};var ee=class{constructor(e,t,i){this.store=e;this.segmentStart=i;this.step={id:g(),isAuxiliary:!1,...t},this.payload={node:this.step};}type="STORE_POINT_INSERTED";payload;step;snapshot={insertedNode:null};restoreInsertedNode=e=>{let t=e.prev,i=e.next;t?t.next=e:this.store.head=e,i?i.prev=e:this.store.tail=e,this.store.tail===t&&this.store.head===i&&(this.store.tail=e,this.store.head&&(this.store.head.prev=e)),e.val&&!this.store.map.has(e.val.id)&&(this.store.map.set(e.val.id,e),this.store.size++,this.store.pingConsumers());};execute=()=>{this.snapshot.insertedNode?this.restoreInsertedNode(this.snapshot.insertedNode):this.snapshot.insertedNode=this.store.insertAfter(this.segmentStart,this.step),this.store.notify({type:"STORE_POINT_INSERTED"});};undo=()=>{this.store.removeNodeById(this.step.id);}};var Re=(n,e)=>{let t=e.head,i=new Set;for(;t!==null&&!i.has(t);){if(t?.next?.val&&t?.val){let o=n.target,r=m.getPixelCoordinates(o,t.val),a=m.getPixelCoordinates(o,t.next.val),p=m.getPixelCoordinates(o,n.lngLat);if(P.checkIfPointIsOnLine(r,a,p))return t}i.add(t),t=t.next;}return null},Ge=(n,e)=>{let t=Re(n,e);if(t){let i={...n.lngLat,isAuxiliary:!1,id:g()};return d.commit(new ee(e,i,t)),i}return null},Fe=(n,e)=>{let{store:t}=e;t.tail?.val&&(M.setSinglePointHidden(n),f.execute());},Ue=n=>m.isFeatureTriggered(n,[s.PointsLayer,s.FirstPointLayer,s.AuxiliaryPointLayer]);var te=class{constructor(e,t,i,o,r){this.store=e;this.options=t;this.mode=i;this.current=o;this.clickCoords=r;}type="STORE_BREAK_GEOMETRY";snapshot={originalHead:null,originalTail:null,newHead:null,newTail:null,newAuxBetweenHeadTail:null};makeSnapshot=()=>{this.snapshot.originalHead=this.store.head,this.snapshot.originalTail=this.store.tail,this.snapshot.newAuxBetweenHeadTail=this.current.val?.isAuxiliary?this.current:this.current.next;};execute=()=>{this.makeSnapshot(),this.store.circular.break(this.current),this.mode.setClosedGeometry(!1),this.snapshot.newHead=this.store.head,this.snapshot.newTail=this.store.tail,this.store.notify({type:"STORE_BREAK_GEOMETRY",data:{coords:this.clickCoords}});};restoreOriginalHeadTail=()=>{let{originalHead:e,originalTail:t}=this.snapshot;this.store.head=e,this.store.tail=t,this.store.head&&(this.store.head.prev=this.store.tail),this.store.tail&&(this.store.tail.next=this.store.head);};restoreAuxBetweenNewHeadTail=()=>{let{newHead:e,newTail:t,newAuxBetweenHeadTail:i}=this.snapshot;e&&t&&(t.next=i,i.prev=t,i.next=e,e.prev=i,i?.val&&(this.store.map.set(i?.val.id,i),this.store.size+=1));};undo=()=>{this.restoreOriginalHeadTail(),this.store.circular.close(),this.store.notify({type:"STORE_CLOSE_GEOMETRY"});let{newHead:e,newTail:t,newAuxBetweenHeadTail:i}=this.snapshot;e&&t&&(this.options.pointGeneration==="auto"?this.restoreAuxBetweenNewHeadTail():(t.next=e,e.prev=t)),this.mode.setClosedGeometry(!0),this.store.pingConsumers();}};var He=15,ie=class{constructor(e){this.ctx=e;this.current=null,this.throttledOnLineEnter=O(this.onLineEnterBreak,He);}current;throttledOnLineEnter;initBreakEvents=()=>{this.ctx.map.on("click",s.LineLayer,this.geometryBreakOnClick),this.ctx.map.on("mouseenter",s.LineLayer,this.throttledOnLineEnter),this.ctx.map.on("mousemove",s.LineLayer,this.throttledOnLineEnter),this.ctx.map.on("mouseleave",s.LineLayer,this.onLineLeave);};removeBreakEvents=()=>{this.ctx.map.off("click",s.LineLayer,this.geometryBreakOnClick),this.ctx.map.off("mouseenter",s.LineLayer,this.throttledOnLineEnter),this.ctx.map.off("mousemove",s.LineLayer,this.throttledOnLineEnter),this.ctx.map.off("mouseleave",s.LineLayer,this.onLineLeave);};hideBreakLine=()=>{this.ctx.map.getLayoutProperty(s.LineLayerBreak,"visibility")!=="none"&&this.ctx.map.setLayoutProperty(s.LineLayerBreak,"visibility","none");};showBreakLine=()=>{this.ctx.map.getLayoutProperty(s.LineLayerBreak,"visibility")!=="visible"&&this.ctx.map.setLayoutProperty(s.LineLayerBreak,"visibility","visible");};geometryBreakOnClick=e=>{let{store:t,mode:i,map:o,options:r}=this.ctx;this.current&&(d.commit(new te(t,r,i,this.current,e.lngLat)),this.onLineLeave(),i.reset(),f.execute(),u.onLineBreak(o));};getAutoGenerationPoints=e=>{let t=null,i=null;return e?.val?.isAuxiliary?(t=[e?.prev?.val?.lng,e?.prev?.val?.lat],i=[e?.next?.val?.lng,e?.next?.val?.lat]):(t=[e?.val?.lng,e?.val?.lat],i=[e?.next?.next?.val?.lng,e?.next?.next?.val?.lat]),{current:t,next:i}};getLinePoints=e=>{if(this.ctx.options.pointGeneration==="manual"){let t=[e?.val?.lng,e?.val?.lat],i=[e?.next?.val?.lng,e?.next?.val?.lat];return {current:t,next:i}}return this.getAutoGenerationPoints(e)};onLineEnterBreak=e=>{let{map:t,store:i}=this.ctx,o=Re(e,i);o?.val?.id!==this.current?.val?.id&&(this.current=o);let r=t.getSource(h.LineSourceBreak),{current:a,next:p}=this.getLinePoints(this.current),L=S.getLine(a,p);L&&(r.setData(L),this.showBreakLine());};onLineLeave=()=>{setTimeout(()=>{this.hideBreakLine();},He+10);}};var Je=17,oe=class{constructor(e){this.ctx=e;this.visible=!0,this.onMouseMoveThrottled=O(this.onLineMove,Je),this.onStoreEventsDebounced=I(this.onStoreEventsConsumer,10),this.initConsumers(),this.initDynamicEvents();}visible;firstPoint=null;secondPoint=null;lineFeature;onMouseMoveThrottled;onStoreEventsDebounced;initConsumers(){this.ctx.store.addObserver(this.onStoreEventsDebounced),this.ctx.mouseEvents.addObserver(this.onMouseEventsConsumer);}removeConsumers=()=>{this.ctx.store.removeObserver(this.onStoreEventsDebounced),this.ctx.mouseEvents.removeObserver(this.onMouseEventsConsumer);};onMouseEventsConsumer=e=>{let{store:t}=this.ctx;if(t.circular.isCircular()){this.hide();return}if(e.type==="lastPointMouseClick"&&e.data&&(this.hide(),this.visible=!1),!this.visible)return;if(["pointMouseEnter","lineMouseEnter","pointMouseDown"].includes(e.type)&&e.data&&this.hide(),e.type==="pointMouseLeave"||e.type==="lineMouseLeave"){let{store:o}=this.ctx;if(o.circular.isCircular())return;e.data&&(this.firstPoint=o.tail?.val,this.secondPoint=o.tail?.val,this.show());}};onStoreEventsConsumer=e=>{let{store:t}=this.ctx;if(t.circular.isCircular()){this.hide();return}e.type==="STORE_CLOSE_GEOMETRY"||e.type==="STORE_CLEARED"?this.hide():e.type==="STORE_BREAK_GEOMETRY"?(this.firstPoint=t.tail?.val,this.secondPoint=e.data?.coords,this.show(),this.visible=!0):e.type==="STORE_POINT_ADD"&&t.size>0&&(this.firstPoint=t.tail?.val,this.secondPoint=t.tail?.val,this.show(),this.visible=!0);};initDynamicEvents=()=>{let{map:e}=this.ctx;e.on("click",this.onMapClick),e.on("mousemove",this.onMouseMoveThrottled),e.on(y.REMOVEALL,this.hide),e.on(y.UNDO,this.onUndoRedoClick),e.on(y.REDO,this.onUndoRedoClick),e.on(y.RIGHTCLICKREMOVE,this.onRightClickRemove);};removeEvents=()=>{let{map:e}=this.ctx;e.off("click",this.onMapClick),e.off("mousemove",this.onMouseMoveThrottled),e.off(y.REMOVEALL,this.hide),e.off(y.UNDO,this.onUndoRedoClick),e.off(y.REDO,this.onUndoRedoClick),e.off(y.RIGHTCLICKREMOVE,this.onRightClickRemove);};hide=()=>{let{map:e}=this.ctx;this.firstPoint=null,this.secondPoint=null,this.lineFeature=null,e.off("mousemove",this.onMouseMoveThrottled);let t=e.getSource(h.LineDynamicSource);t&&t.setData(Be),e.getLayer(s.LineDynamicLayer)&&e.setLayoutProperty(s.LineDynamicLayer,"visibility","none");};show=()=>{let{map:e,store:t}=this.ctx;if(t.size&&this.firstPoint?.lat&&this.firstPoint.lng&&this.secondPoint?.lng&&this.secondPoint?.lat){let i=[this.firstPoint.lng,this.firstPoint.lat],o=[this.secondPoint.lng,this.secondPoint.lat];this.lineFeature=S.getLine(i,o),e.setLayoutProperty(s.LineDynamicLayer,"visibility","visible"),this.secondPoint&&this.renderLineOnMouseMove({lng:this.secondPoint?.lng,lat:this.secondPoint?.lat});}e.on("mousemove",this.onMouseMoveThrottled);};renderLineOnMouseMove=e=>{if(!this.lineFeature)return;let{map:t}=this.ctx;this.lineFeature.features[0].geometry.coordinates[1]=[e.lng,e.lat];let i=t.getSource(h.LineDynamicSource);i&&i.setData(this.lineFeature);};onLineMove=e=>{this.renderLineOnMouseMove(e.lngLat);};onMapClick=e=>{let{mode:t}=this.ctx,i=m.isFeatureTriggered(e,[s.LineLayerTransparent,s.LineLayer]);i&&t.getBreak()&&(this.secondPoint={lng:e.lngLat.lng,lat:e.lngLat.lat}),!i&&this.hide();};onUndoRedoClick=e=>{let{store:t}=this.ctx;if(!t.circular.isCircular()){let i=e.target.unproject({x:e.originalEvent.x,y:e.originalEvent.y});this.secondPoint={lng:i.lng,lat:i.lat},this.firstPoint=t.tail?.val,this.show();}t.size===0&&this.hide();};onRightClickRemove=e=>{let{store:t}=this.ctx;t.circular.isCircular()||(this.secondPoint={lng:e.coordinates.lng,lat:e.coordinates.lat},this.firstPoint=t.tail?.val,this.show()),t.size===0&&this.hide();}};var $e=22,ne=class{constructor(e){this.ctx=e;this.isThrottled=!1,this.lastEvent=null;}isThrottled;lastEvent;initEvents(){this.ctx.map.on("click",s.LineLayerTransparent,this.onLineClick),this.ctx.map.on("mousemove",s.LineLayerTransparent,this.onLineMove),this.ctx.map.on("mouseenter",s.LineLayerTransparent,this.onLineEnter),this.ctx.map.on("mouseleave",s.LineLayerTransparent,this.onLineLeave);}removeEvents(){this.ctx.map.off("click",s.LineLayerTransparent,this.onLineClick),this.ctx.map.off("mousemove",s.LineLayerTransparent,this.onLineMove),this.ctx.map.off("mouseenter",s.LineLayerTransparent,this.onLineEnter),this.ctx.map.off("mouseleave",s.LineLayerTransparent,this.onLineLeave);}onLineClick=e=>{let{store:t,map:i,mode:o}=this.ctx;if(Ue(e))return;let r=Ge(e,t);r&&(Fe(e,this.ctx),u.addPoint({...r,total:t.size},i,o));};processMouseMove=e=>{if(M.setSinglePointVisible(e),e.target.getLayer(s.SinglePointLayer)){let i=e.target.getSource(h.SinglePointSource);i&&i.setData({type:"Feature",geometry:{type:"Point",coordinates:[e.lngLat.lng,e.lngLat.lat]},properties:{}});}};onLineMove=O(e=>{m.isFeatureTriggered(e,[s.PointsLayer,s.FirstPointLayer])||this.ctx.mouseEvents.pointMouseDown||this.ctx.mouseEvents.pointMouseEnter||(this.lastEvent=e,!this.isThrottled&&(this.isThrottled=!0,requestAnimationFrame(()=>{this.lastEvent&&(this.processMouseMove(this.lastEvent),this.isThrottled=!1);})));},$e);onLineEnter=e=>{this.ctx.mouseEvents.pointMouseDown||this.ctx.mouseEvents.pointMouseEnter||m.isFeatureTriggered(e,[s.PointsLayer,s.FirstPointLayer])||(this.ctx.mouseEvents.lineMouseEnter=!0,M.setSinglePointVisible(e));};onLineLeave=e=>{this.ctx.mouseEvents.pointMouseDown||this.ctx.mouseEvents.pointMouseEnter||(this.ctx.mouseEvents.lineMouseLeave=!0,M.setSinglePointHidden(e));}};var se=class{constructor(e){this.ctx=e;this.break=new ie(e),this.transparent=e.options.pointGeneration==="manual"?new ne(e):null,this.dynamic=null,this.type="default";}break;transparent;dynamic;type;init(){this.initDynamicLine(),this.initEvents(),this.initConsumers();}initDynamicLine=()=>{window.innerWidth<=_e||this.ctx.options.dynamicLine&&(this.dynamic=new oe(this.ctx));};initEvents(){!this.ctx.mode.getBreak()&&this.transparent?.initEvents();}initConsumers(){this.ctx.mode.addObserver(this.mapModeConsumer),this.ctx.mouseEvents.addObserver(this.mouseEventsConsumer);}remove(){this.removeConsumers(),this.removeEvents();}removeConsumers(){this.ctx.mode.removeObserver(this.mapModeConsumer),this.ctx.mouseEvents.removeObserver(this.mouseEventsConsumer),this.ctx.options.dynamicLine&&this.dynamic?.removeConsumers();}removeEvents(){this.break.removeBreakEvents(),this.transparent?.removeEvents(),this.ctx.options.dynamicLine&&(this.dynamic?.removeEvents(),this.dynamic?.hide());}mouseEventsConsumer=e=>{let{type:t,data:i}=e,{mode:o}=this.ctx;if(!(!i||!o.getBreak()))switch(t){case"pointMouseDown":this.break.removeBreakEvents(),this.break.hideBreakLine();break;case"pointMouseUp":this.break.initBreakEvents();break;}};mapModeConsumer=e=>{let{type:t,data:i}=e;t==="MODE_CHANGED"&&this.type==="break"&&(this.break.removeBreakEvents(),this.transparent?.initEvents(),this.type="default"),t==="BREAK_CHANGED"&&i&&this.type==="default"&&(this.transparent?.removeEvents(),this.break.initBreakEvents(),this.type="break");}};var We=n=>{n.setPaintProperty(s.FirstPointLayer,"circle-radius",N.large),n.setPaintProperty(s.FirstPointLayer,"circle-stroke-color",j.large);},Ze=n=>{n.setPaintProperty(s.FirstPointLayer,"circle-radius",N.default),n.setPaintProperty(s.FirstPointLayer,"circle-stroke-color",j.default);},De=(n,e)=>{e==="large"?We(n):Ze(n);},ze=n=>{n.getLayer(s.LineLayerTransparent)&&n.removeLayer(s.LineLayerTransparent);},re=(n,e)=>{if(n.getLayer(s.LineLayerTransparent))return;let i=J(e).find(o=>o.id===s.LineLayerTransparent);i&&n.addLayer(i);};var ae=class{constructor(e,t,i){this.store=e;this.mode=t;this.options=i;this.type="STORE_CLOSE_GEOMETRY";}type="STORE_CLOSE_GEOMETRY";auxPointSnapshot=null;restoreAuxPoint=()=>{this.auxPointSnapshot?.val&&(this.store.head.prev=this.auxPointSnapshot,this.store.tail.next=this.auxPointSnapshot,this.auxPointSnapshot.prev=this.store.tail,this.auxPointSnapshot.next=this.store.head,this.store.tail=this.auxPointSnapshot,this.store.map.set(this.auxPointSnapshot.val.id,this.auxPointSnapshot),this.store.size++,this.store.pingConsumers());};execute=()=>{if(this.options.pointGeneration==="auto"&&this.store.tail?.val)if(this.auxPointSnapshot)this.restoreAuxPoint();else {let e=v.createAuxiliaryPoint(this.store.tail?.val,this.store.head?.val);this.auxPointSnapshot=this.store.push(e);}this.store.circular.close(),this.mode.setClosedGeometry(!0),this.store.notify({type:this.type});};undo=()=>{this.options.pointGeneration==="auto"&&this.store.removeNodeById(this.store.tail?.val?.id),this.store.tail?.val&&this.store.head?.val&&(this.store.tail.next=null,this.store.head.prev=null),this.mode.setClosedGeometry(!1),this.store.notify({type:"STORE_BREAK_GEOMETRY"});}};var le=class{constructor(e,t){this.ctx=e;this.baseEvents=t;this.#e=!1,this.#t=new A,this.initLayer(),this.initEvents();}#e;#t;initConsumers=()=>{let{mode:e,store:t}=this.ctx;e.addObserver(this.onMapModeChanggeConsumer),t.addObserver(this.onStoreChangeConsumer);};removeConsumers=()=>{let{mode:e,store:t}=this.ctx;e.removeObserver(this.onMapModeChanggeConsumer),t.removeObserver(this.onStoreChangeConsumer);};initLayer(){let{map:e}=this.ctx;e.setLayoutProperty(s.FirstPointLayer,"visibility","visible");}initBaseEvents=()=>{let{map:e}=this.ctx;e.on("mouseenter",s.FirstPointLayer,this.baseEvents.onPointMouseEnter),e.on("mouseleave",s.FirstPointLayer,this.baseEvents.onPointMouseLeave),e.on("mousedown",s.FirstPointLayer,this.baseEvents.onPointMouseDown),e.on("mouseup",s.FirstPointLayer,this.baseEvents.onPointMouseUp),e.on("touchend",s.FirstPointLayer,this.baseEvents.onPointMouseUp),e.on("touchstart",s.FirstPointLayer,this.baseEvents.onPointMouseDown);};initEvents(){let{map:e}=this.ctx;e.on("click",s.FirstPointLayer,this.onFirstPointClick),e.on("mouseenter",s.FirstPointLayer,this.onFirstPointMouseEnter),e.on("mouseleave",s.FirstPointLayer,this.onFirstPointMouseLeave),e.on("mouseup",s.FirstPointLayer,this.onFirstPointMouseUp),e.on("mousedown",s.FirstPointLayer,this.onFirstPointMouseDown),this.initBaseEvents(),this.initConsumers();}removeBaseEvents=()=>{let{map:e}=this.ctx;e.off("mouseenter",s.FirstPointLayer,this.baseEvents.onPointMouseEnter),e.off("mouseleave",s.FirstPointLayer,this.baseEvents.onPointMouseLeave),e.off("mousedown",s.FirstPointLayer,this.baseEvents.onPointMouseDown),e.off("mouseup",s.FirstPointLayer,this.baseEvents.onPointMouseUp),e.off("touchend",s.FirstPointLayer,this.baseEvents.onPointMouseUp),e.off("touchstart",s.FirstPointLayer,this.baseEvents.onPointMouseDown);};removeEvents(){let{map:e}=this.ctx;e.off("click",s.FirstPointLayer,this.onFirstPointClick),e.off("mouseenter",s.FirstPointLayer,this.onFirstPointMouseEnter),e.off("mouseleave",s.FirstPointLayer,this.onFirstPointMouseLeave),e.off("mouseup",s.FirstPointLayer,this.onFirstPointMouseUp),this.removeBaseEvents(),this.removeConsumers();}onMapModeChanggeConsumer=e=>{let{map:t,options:i}=this.ctx,{type:o,data:r}=e;o==="MODE_CHANGED"&&(r==="line"&&!i.modes.line.closeGeometry?(M.setFirstPointHidden(t),Te.closedGeometry(t)):(M.setFirstPointVisible(t),Te.default(t)));};onStoreChangeConsumer=e=>{let{map:t,store:i}=this.ctx,{type:o}=e;["STORE_MUTATED","STORE_POINT_INSERTED","STORE_CLOSE_GEOMETRY","STORE_BREAK_GEOMETRY","STORE_CLEARED"].includes(o)&&(i.circular.canClose()?De(t,"large"):De(t,"default"));};onFirstPointClick=()=>{let{store:e,mode:t,options:i}=this.ctx;e.circular.canClose()&&(d.commit(new ae(e,t,i)),f.execute());};onFirstPointMouseDown=()=>{this.#e=!0,this.#t.remove();};onFirstPointMouseUp=()=>{this.#e=!1;};onFirstPointMouseLeave=()=>{let{mouseEvents:e}=this.ctx;this.#e||(e.firstPointMouseLeave=!0,this.#t.remove());};getTitle=()=>{let{mode:e,options:t}=this.ctx;return e.getMode()==="line"&&t.modes.line.closeGeometry?t.locale.closeLine:e.getMode()==="polygon"?t.locale.createPolygon:""};onFirstPointMouseEnter=e=>{let{mode:t,mouseEvents:i,store:o,options:r}=this.ctx;if(i.firstPointMouseEnter=!0,!(t.getClosedGeometry()||this.#e)&&P.canCloseGeometry(o,r)){let{x:a,y:p}=e.originalEvent;if(a&&p){this.#t.create({label:this.getTitle(),placement:"bottom"});let w=this.#t.label?this.#t.label.clientWidth/2:0;this.#t.setPosition({x:a-w,y:p+14});}}}};var pe=class{constructor(e,t){this.store=e;this.clickedNode=t;this.snapshot=this.makeSnapshot(this.clickedNode);}type="STORE_AUX_TO_PRIMARY";snapshot=null;makeSnapshot(e){let t=e.prev,i=e.next;return {clickedNode:e,prevPrimaryNode:t,nextPrimaryNode:i,prevAuxNode:null,nextAuxNode:null}}restorePreviousAux=e=>{if(!this.snapshot)return;let{prevPrimaryNode:t,prevAuxNode:i}=this.snapshot;t&&(t.next=i),i&&(i.prev=t),e.prev=i,i&&(i.next=e),i?.val?.id&&!this.store.map.has(i.val.id)&&(this.store.map.set(i?.val?.id,i),this.store.size++);};restoreNextAux=e=>{if(!this.snapshot)return;let{nextPrimaryNode:t,nextAuxNode:i}=this.snapshot;if(e.next=i,i&&(i.prev=e,i.next=t),t&&(t.prev=i),e.next?.next===this.store.head){let r=e.next;this.store.tail=r,this.store.head&&(this.store.head.prev=r),this.store.tail&&(this.store.tail.next=this.store.head);}i?.val?.id&&(this.store.map.set(i.val?.id,i),this.store.size++);};addTwoAuxiliaryPoints=e=>{if(!this.snapshot)return;let{nextPrimaryNode:t,prevPrimaryNode:i}=this.snapshot;if(i)if(this.snapshot.prevAuxNode)this.restorePreviousAux(e);else {let o=v.createAuxiliaryPoint(i.val,e.val);this.snapshot.prevAuxNode=this.store.insertAfter(i,o);}if(t)if(this.snapshot.nextAuxNode)this.restoreNextAux(e);else {let o=v.createAuxiliaryPoint(e.val,t.val);this.snapshot.nextAuxNode=this.store.insertAfter(e,o);}};execute=()=>{if(!this.snapshot)return;let{clickedNode:e}=this.snapshot;e&&e.val&&(e.val.isAuxiliary=!1,this.addTwoAuxiliaryPoints(e));};removeTwoAuxiliaryPoints=e=>{if(!e||!this.snapshot)return;let{prevAuxNode:t,nextAuxNode:i}=this.snapshot;t?.val?.isAuxiliary&&this.store.removeNodeById(t.val?.id),i?.val?.isAuxiliary&&this.store.removeNodeById(i?.val.id);};undo=()=>{if(!this.snapshot)return;let{clickedNode:e}=this.snapshot;e&&e.val&&(e.val.isAuxiliary=!0,this.removeTwoAuxiliaryPoints(e));}};var F=class{constructor(e,t,i,o){this.store=e;this.selectedNode=t;this.start=i;this.map=o;this.end={lat:t.val.lat,lng:t.val.lng};}type="STORE_POINT_MOVED";end;updateNeighbors=e=>{let t=e.prev,i=e.next;if(!t?.val?.isAuxiliary&&!i?.val?.isAuxiliary)return;let o=e.prev?.prev,r=e.next?.next;if(o?.val&&this.selectedNode?.val&&t){let a=v.getMidpoint(this.selectedNode?.val,o?.val);t.val&&(t.val.lat=a.lat,t.val.lng=a.lng);}if(r?.val&&this.selectedNode?.val&&i){let a=v.getMidpoint(this.selectedNode?.val,r?.val);i.val&&(i.val.lat=a.lat,i.val.lng=a.lng);}};execute=()=>{if(!this.selectedNode.val)return;let e=this.store.findStepById(this.selectedNode.val?.id);e&&(e.lat=this.end.lat,e.lng=this.end.lng,this.updateNeighbors(this.selectedNode),this.store.notify({type:"STORE_MUTATED",data:this.store}),u.movePoint({id:this.selectedNode.val.id,total:this.store.size,end:{lat:this.selectedNode.val.lat,lng:this.selectedNode.val.lng},start:this.start},this.map));};undo=()=>{if(!this.selectedNode.val)return;let e=this.store.findStepById(this.selectedNode.val?.id);e&&(e.lat=this.start.lat,e.lng=this.start.lng,this.updateNeighbors(this.selectedNode),this.store.notify({type:"STORE_MUTATED",data:this.store}),u.movePoint({id:this.selectedNode.val.id,total:this.store.size,end:this.start,start:this.end},this.map));}};var ce=class{constructor(e,t,i,o){this.ctx=e;this.baseEvents=t;this.pointState=i;this.topologyManager=o;this.initEvents();}initBaseEvents=()=>{let{map:e}=this.ctx;e.on("mouseenter",s.AuxiliaryPointLayer,this.baseEvents.onPointMouseEnter),e.on("mouseleave",s.AuxiliaryPointLayer,this.baseEvents.onPointMouseLeave),e.on("mousedown",s.AuxiliaryPointLayer,this.baseEvents.onPointMouseDown),e.on("mouseup",s.PointsLayer,this.onMouseUp),e.on("touchend",s.PointsLayer,this.onMouseUp),e.on("touchstart",s.AuxiliaryPointLayer,this.baseEvents.onPointMouseDown);};removeBaseEvents=()=>{let{map:e}=this.ctx;e.off("mouseenter",s.AuxiliaryPointLayer,this.baseEvents.onPointMouseEnter),e.off("mouseleave",s.AuxiliaryPointLayer,this.baseEvents.onPointMouseLeave),e.off("mousedown",s.AuxiliaryPointLayer,this.baseEvents.onPointMouseDown),e.off("mouseup",s.PointsLayer,this.onMouseUp),e.off("touchend",s.PointsLayer,this.onMouseUp),e.off("touchstart",s.AuxiliaryPointLayer,this.baseEvents.onPointMouseDown);};initEvents(){let{map:e}=this.ctx;e.on("mousedown",s.AuxiliaryPointLayer,this.onMouseDown),e.on("touchstart",s.AuxiliaryPointLayer,this.onMouseDown),this.initBaseEvents();}removeEvents(){let{map:e}=this.ctx;e.off("mousedown",s.AuxiliaryPointLayer,this.onMouseDown),e.off("touchstart",s.AuxiliaryPointLayer,this.onMouseDown),this.removeBaseEvents();}onMouseDown=e=>{let{store:t,map:i}=this.ctx;if(e.originalEvent.button===2)return;let o=m.queryPointId(i,e.point),r=t.findNodeById(o);r&&(d.beginTransaction("PointCompound"),d.commit(new pe(t,r)),f.execute());};onMouseUp=()=>{let{mouseEvents:e,store:t,panel:i,map:o,options:r}=this.ctx;e.pointMouseUp=!0;let a=this.pointState.getSelectedNode(),p=this.pointState.getLastEvent(),L=this.pointState.getStartCoordinates();a&&a.val&&(p&&(this.topologyManager.updateStore(),this.pointState.clearLastEvent()),i?.show(),this.pointState.isMoved()&&(d.commit(new F(t,a,L,o)),d.commitTransaction()),this.pointState.partialReset()),e&&(e.pointMouseDown=!1),re(o,r);}};var ue=class{selectedNode=null;selectedIdx=null;startCoordinates=null;enteredStep=null;lastEvent=null;moved=!1;getSelectedNode(){return this.selectedNode}isMoved(){return this.moved}getSelectedIdx(){return this.selectedIdx}getStartCoordinates(){return this.startCoordinates}getEnteredStep(){return this.enteredStep}getLastEvent(){return this.lastEvent}setSelectedNode(e){this.selectedNode=e;}setSelectedIdx(e){this.selectedIdx=e;}setStartCoordinates(e){this.startCoordinates=e;}setEnteredStep(e){this.enteredStep=e;}setLastEvent(e){this.lastEvent=e;}setMoved(e){this.moved=e;}clearLastEvent(){this.lastEvent=null;}reset(){this.selectedNode=null,this.selectedIdx=null,this.startCoordinates=null,this.enteredStep=null,this.lastEvent=null;}partialReset(){this.selectedNode=null,this.selectedIdx=null,this.startCoordinates=null,this.lastEvent=null,this.moved=!1;}};var de=class{constructor(e,t,i){this.store=e;this.options=t;this.step={id:g(),isAuxiliary:!1,...i};}type="STORE_MUTATED";snapshot={addedNode:null,auxNode:null};step;restoreAddedNode=e=>{e.prev?e.prev.next=e:this.store.head=e,e.next?e.next.prev=e:this.store.tail=e,this.snapshot.addedNode=e,e.val&&(this.store.map.set(e.val.id,e),this.store.size++,this.store.pingConsumers());};restoreAuxNode=e=>{e.prev?e.prev.next=e:this.store.head=e,e.next?e.next.prev=e:this.store.tail=e,this.snapshot.auxNode=e,e.val&&(this.store.map.set(e.val.id,e),this.store.size++,this.store.pingConsumers());};execute=()=>{if(this.snapshot.addedNode?this.restoreAddedNode(this.snapshot.addedNode):this.snapshot.addedNode=this.store.push(this.step),this.options.pointGeneration==="auto"&&this.store.tail?.prev?.val)if(this.snapshot?.auxNode?.val)this.restoreAuxNode(this.snapshot.auxNode);else {let e=v.createAuxiliaryPoint(this.store.tail?.val,this.store.tail?.prev?.val);this.snapshot.auxNode=this.store.insertAfter(this.store.tail.prev,e);}this.store.notify({type:"STORE_POINT_ADD"});};undo=()=>{this.store.removeNodeById(this.step.id),this.options.pointGeneration==="auto"&&this?.snapshot.auxNode?.val&&this.store.removeNodeById(this?.snapshot.auxNode.val.id);};getStep=()=>this.step};var he=class{constructor(e){this.ctx=e;}type="STORE_INBETWEEN_POINT_REMOVED";snapshot=null;makeSnapshot(e){let{store:t,nodeId:i}=this.ctx,o=t.circular.isCircular(),r=t.head?.val?.id===i,p=(o?t.tail?.prev:t.tail)?.val?.id===i,L=e.prev,w=e.next,K=e.prev?.prev??null,Ve=e.next?.next??null;return {removedNode:e,wasCircular:o,wasRemovedHead:r,wasRemovedTail:p,beforePrimary:K,afterPrimary:Ve,beforeAux:L,afterAux:w,newAux:null}}restoreNodeAfter=(e,t)=>{!e||!t||!t.val||(t.prev=e,t.next=e.next,e.next&&(e.next.prev=t),e.next=t,this.ctx.store.map.has(t.val.id)||(this.ctx.store.map.set(t.val.id,t),this.ctx.store.size++,this.ctx.store.pingConsumers()));};recalculateInBetweenRemoved(e){if(!e||!this.snapshot)return;let{store:t}=this.ctx,i=e.prev,o=e.next,r=i?.prev,a=o?.next;i?.val?.isAuxiliary&&t.removeNodeById(i.val.id),o?.val?.isAuxiliary&&t.removeNodeById(o.val.id);let p=t.circular.isCircular()?t.size>=5:t.size>=3;if(r?.val&&a?.val&&p)if(this.snapshot.newAux)this.restoreNodeAfter(r,this.snapshot.newAux);else {let L=v.createAuxiliaryPoint(r.val,a.val);this.snapshot.newAux=t.insertAfter(r,L);}}breakGeometryIfNeeded=e=>{let{store:t}=e;if(t.circular.canBreak()&&t.circular.isCircular()){if(t.tail?.val?.isAuxiliary){let i=t.tail;t.removeNodeById(t.tail.val.id),t.tail=i?.prev;let o=v.createAuxiliaryPoint(t.tail?.val,t.head?.val);this.snapshot&&(this.snapshot.newAux=t.insertAfter(t.head,o));}return t.head&&(t.head.prev=null),t.tail&&(t.tail.next=null),!0}return !1};execute=()=>{let e=this.ctx.store.findNodeById(this.ctx.nodeId),t=e?.val?.isAuxiliary;if(!e||t)return;this.snapshot=this.makeSnapshot(e),this.recalculateInBetweenRemoved(e),this.ctx.store.removeNodeById(this.ctx.nodeId),this.breakGeometryIfNeeded(this.ctx)&&this.ctx.mode.reset(),u.pointRemoveRightClick({...e?.val,total:this.ctx.store.size},this.ctx.map),this.ctx.store.pingConsumers();};restoreRemovedMiddleNode=e=>{if(!this.snapshot||!e.val)return;let{beforePrimary:t,afterPrimary:i,wasCircular:o}=this.snapshot,{store:r,mode:a}=this.ctx;if(t&&(t.next=e,e.prev=t),i&&(e.next=i,i.prev=e),o&&!this.ctx.store.circular.isCircular()){let p=v.createAuxiliaryPoint(r.tail?.val,r.head?.val);r.push(p),r.circular.close(),a.setClosedGeometry(!0);}};restoreRemovedHeadNode=e=>{if(!this.snapshot||!e?.val)return;let{wasCircular:t}=this.snapshot,{store:i,mode:o}=this.ctx,r=this.ctx.store.head;r&&(e.next=r,r.prev=e),i.head=e;let a=!i.circular.isCircular();t&&a&&(i.circular.close(),o.setClosedGeometry(!0));};restoreRemovedTailNode=e=>{let{store:t,mode:i}=this.ctx;if(!this.snapshot)return;let{wasCircular:o}=this.snapshot,r=t.tail;r&&(r.next=e,e.prev=r,t.tail=e);let a=!t.circular.isCircular();o&&a&&(t.circular.close(),i.setClosedGeometry(!0));};restoreAuxiliaryPoints(e){this.snapshot&&(e.prev?.val&&e.val&&this.snapshot?.beforeAux&&(this.restoreNodeAfter(e.prev,this.snapshot?.beforeAux),this.snapshot.wasRemovedHead&&this.snapshot.wasCircular&&(this.ctx.store.tail=this.snapshot.beforeAux)),e.next?.val&&e.val&&this.snapshot?.afterAux&&(this.restoreNodeAfter(e,this.snapshot?.afterAux),this.snapshot.wasRemovedTail&&this.snapshot.wasCircular&&(this.ctx.store.tail=this.snapshot.afterAux)),this.snapshot.wasCircular&&this.ctx.store.circular.close());}undo=()=>{let{store:e}=this.ctx;if(!this.snapshot)return;let{removedNode:t,wasRemovedHead:i,wasRemovedTail:o,wasCircular:r}=this.snapshot;t?.val&&(i?(e.removeNodeById(e.head?.prev?.val?.id),this.restoreRemovedHeadNode(t)):o?(this.restoreRemovedTailNode(t),r&&e.tail?.prev?.val?.isAuxiliary&&e.removeNodeById(e.tail?.prev?.val?.id)):(this.snapshot.newAux?.val?.id&&e.removeNodeById(this.snapshot.newAux?.val?.id),this.restoreRemovedMiddleNode(t)),e.map.has(this.ctx.nodeId)||(e.map.set(this.ctx.nodeId,t),e.size++),this.restoreAuxiliaryPoints(t),e.pingConsumers());}};var me=class{constructor(e){this.ctx=e;}type="STORE_INBETWEEN_POINT_REMOVED";snapshot=null;makeSnapshot(e){let t=this.ctx.store.head?.val?.id===this.ctx.nodeId,i=this.ctx.store.tail?.val?.id===this.ctx.nodeId,o=this.ctx.store.circular.isCircular();return {removedNode:e,wasCircular:o,wasRemovedHead:t,wasRemovedTail:i}}breakGeometryIfNeeded=e=>{let{store:t}=e;return t.circular.canBreak()&&t.circular.isCircular()?(t.head&&(t.head.prev=null),t.tail&&(t.tail.next=null),!0):!1};execute=()=>{let e=this.ctx.store.findNodeById(this.ctx.nodeId);if(!e?.val)return;this.snapshot=this.makeSnapshot(e),this.ctx.store.removeNodeById(this.ctx.nodeId),this.breakGeometryIfNeeded(this.ctx)&&this.ctx.mode.reset(),u.pointRemoveRightClick({...e?.val,total:this.ctx.store.size},this.ctx.map),this.ctx.store.pingConsumers();};closeGeometryIfNeeded=()=>{let{store:e,mode:t}=this.ctx,i=!this.ctx.store.circular.isCircular();this.snapshot?.wasCircular&&i&&(e.circular.close(),t.setClosedGeometry(!0));};restoreRemovedMiddleNode=e=>{if(!e?.val)return;let{prev:t,next:i}=e;t?(t.next=e,e.prev=t):this.ctx.store.head=e,i?(i.prev=e,e.next=i):this.ctx.store.tail=e;};restoreRemovedHeadNode=e=>{let t=this.ctx.store.head;e?.val&&(t&&(e.next=t,t.prev=e),this.ctx.store.head=e);};restoreRemovedTailNode=e=>{let t=this.ctx.store.tail;t&&(t.next=e,e.prev=t),this.ctx.store.tail=e;};undo=()=>{if(!this.snapshot)return;let{removedNode:e,wasRemovedHead:t,wasRemovedTail:i}=this.snapshot;t?this.restoreRemovedHeadNode(e):i?this.restoreRemovedTailNode(e):this.restoreRemovedMiddleNode(e),this.closeGeometryIfNeeded(),this.ctx.store.map.has(this.ctx.nodeId)||(this.ctx.store.map.set(this.ctx.nodeId,e),this.ctx.store.size++),this.ctx.store.pingConsumers();}};var ve=class{constructor(e){this.ctx=e;this.manualPointRemove=new me(this.ctx),this.autoPointRemove=new he(this.ctx);}type="STORE_INBETWEEN_POINT_REMOVED";manualPointRemove=null;autoPointRemove=null;execute=()=>{this.ctx.options.pointGeneration==="auto"?this.autoPointRemove?.execute():this.manualPointRemove?.execute();};undo=()=>{this.ctx.options.pointGeneration==="auto"?this.autoPointRemove?.undo():this.manualPointRemove?.undo();}};var ye=class{constructor(e,t){this.ctx=e;this.state=t;}updateMainPoint(e,t){e.val&&(e.val.lat=t.lngLat.lat,e.val.lng=t.lngLat.lng);}updateAuxiliaryPoints(e,t){let i=this.getAuxPointsLatLng(t);i&&(this.updatePrevAuxPoint(e,i.prev),this.updateNextAuxPoint(e,i.next));}updatePrevAuxPoint(e,t){e.prev?.val&&t&&(e.prev.val.lat=t.lat,e.prev.val.lng=t.lng);}updateNextAuxPoint(e,t){e.next?.val&&t&&(e.next.val.lat=t.lat,e.next.val.lng=t.lng);}updateStore=()=>{let e=this.state.getLastEvent(),t=this.state.getSelectedNode();!e||!t?.val||(this.updateMainPoint(t,e),this.updateAuxiliaryPoints(t,e));};getAuxPointsLatLng=e=>{let t=this.state.getSelectedNode();if(!t)return null;let{options:i}=this.ctx,o=t?.prev?.prev,r=t?.next?.next;return i.pointGeneration==="auto"?{next:r?.val?v.getMidpoint(r.val,e.lngLat):null,prev:o?.val?v.getMidpoint(e.lngLat,o.val):null}:null};addPoint(e){let{store:t,options:i}=this.ctx,o=new de(t,i,e.lngLat);return d.commit(o),o.getStep()}removePoint(e){let{store:t,options:i,mode:o,map:r}=this.ctx;t.size===1?t.reset():d.commit(new ve({store:t,options:i,mode:o,map:r,nodeId:e}));}};var fe=class{constructor(e){this.ctx=e;this.pointState=new ue,this.topologyManager=new ye(e,this.pointState),this.events={onPointMouseEnter:this.onPointMouseEnter,onPointMouseLeave:this.onPointMouseLeave,onPointMouseDown:this.onPointMouseDown,onPointMouseUp:this.onPointMouseUp,onMapMouseMove:this.onMapMouseMove},this.firstPoint=new le(this.ctx,this.events),this.auxPoints=new ce(this.ctx,this.events,this.pointState,this.topologyManager);}events;firstPoint;auxPoints;pointState;topologyManager;initConsumers=()=>{this.ctx.mode.addObserver(this.mapModeConsumer),this.ctx.store.addObserver(this.storeEventsConsumer);};removeConsumers=()=>{this.ctx.mode.removeObserver(this.mapModeConsumer),this.ctx.store.removeObserver(this.storeEventsConsumer);};init=()=>{let{map:e}=this.ctx;e.on("click",this.onMapClick),e.on("dblclick",this.onMapDblClick),e.on("mouseenter",s.PointsLayer,this.onPointMouseEnter),e.on("mouseleave",s.PointsLayer,this.onPointMouseLeave),e.on("mousedown",s.PointsLayer,this.onPointMouseDown),e.on("click",s.PointsLayer,this.onPointClick),e.on("mouseup",s.PointsLayer,this.onPointMouseUp),e.on("touchend",s.PointsLayer,this.onPointMouseUp),e.on("touchstart",s.PointsLayer,this.onPointMouseDown),this.initConsumers();};remove=()=>{let{map:e}=this.ctx;e.off("click",this.onMapClick),e.off("dblclick",this.onMapDblClick),e.off("mousemove",this.onMapMouseMove),e.off("mouseenter",s.PointsLayer,this.onPointMouseEnter),e.off("mouseleave",s.PointsLayer,this.onPointMouseLeave),e.off("mousedown",s.PointsLayer,this.onPointMouseDown),e.off("click",s.PointsLayer,this.onPointClick),e.off("mouseup",s.PointsLayer,this.onPointMouseUp),e.off("touchend",s.PointsLayer,this.onPointMouseUp),e.off("touchstart",s.PointsLayer,this.onPointMouseDown),this.firstPoint?.removeEvents(),this.auxPoints?.removeEvents(),this.removeConsumers();};onPointClick=e=>{let{mouseEvents:t,store:i,map:o,options:r}=this.ctx,a=m.queryPointId(o,e.point);b.isLastPoint(i,r,a)&&(t.lastPointMouseClick=!0,t.lastPointMouseUp=!1);};onMapDblClick=e=>{e.preventDefault();};onPointRemove=e=>{let{store:t}=this.ctx;if(t.size===1)t.reset(),this.ctx.panel.hide();else {let i=m.queryPointId(this.ctx.map,e.point),o=t.findNodeById(i);if(!o?.val)return;this.topologyManager.removePoint(o.val.id);}f.execute();};onOwnGeometryLayersClick=e=>m.isFeatureTriggered(e,[s.PointsLayer,s.FirstPointLayer,s.LineLayerTransparent,s.LineLayerBreak]);onMapClick=e=>{let{mode:t,mouseEvents:i,map:o,store:r}=this.ctx;if(t.getClosedGeometry()||this.onOwnGeometryLayersClick(e))return;i.lastPointMouseClick&&(i.lastPointMouseClick=!1),o.getCanvasContainer().style.cursor="grab";let a=this.topologyManager.addPoint(e);u.addPoint({...a,total:r.size},o,t),M.setSinglePointHidden(e),f.execute();};onMoveLeftClickUp=e=>{e.originalEvent.buttons===0&&this.onPointMouseUp();};onMapMouseMove=O(e=>{let{mouseEvents:t}=this.ctx;if(t.pointMouseDown){if(this.pointState.setLastEvent(e),!this.pointState.getSelectedNode())return;this.onMoveLeftClickUp(this.pointState.getLastEvent());let i=this.topologyManager.getAuxPointsLatLng(this.pointState.getLastEvent());f.executeOnMouseMove(this.pointState.getSelectedIdx(),e.lngLat,i),this.pointState.setMoved(!0);}},17);onPointMouseEnter=e=>{let{mouseEvents:t,map:i,store:o,options:r}=this.ctx;if(t&&(t.pointMouseEnter=!0,t.pointMouseDown))return;M.setSinglePointHidden(e);let a=m.queryPointId(i,e.point);b.isLastPoint(o,r,a)&&(t.lastPointMouseEnter=!0,t.lastPointMouseLeave=!1);let p=o.findStepById(a);p&&(this.pointState.setEnteredStep(p),u.enterPoint(Object.assign({},p,{total:o.size}),i));};onPointMouseLeave=e=>{let{mouseEvents:t,store:i,map:o,options:r}=this.ctx;if(t&&(t.pointMouseEnter=!1,e.originalEvent.buttons===0&&(t.pointMouseLeave=!0),t.pointMouseDown))return;let a=m.queryPointId(o,e.point);b.isLastPoint(i,r,a)&&(t.lastPointMouseEnter=!1,t.lastPointMouseLeave=!0),u.leavePoint(Object.assign({},this.pointState.getEnteredStep(),{total:i.size}),o);};storeEventsConsumer=e=>{e.type==="STORE_MUTATED"&&e.data?.size===0&&this.pointState.reset();};mapModeConsumer=e=>{(e.type==="BREAK_CHANGED"||e.type==="MODE_CHANGED")&&this.pointState.reset();};hideLastPointPanel=()=>{let{store:e,panel:t,options:i}=this.ctx,o=this.pointState.getSelectedNode();o?.val&&b.isLastPoint(e,i,o.val.id)&&t.hide();};setSelectedNode=e=>{let{store:t,map:i}=this.ctx,o=m.queryPointId(i,e.point),r=t.findNodeById(o);r&&this.pointState.setSelectedNode(r);};onPointMouseDown=e=>{e.preventDefault(),this.pointState.clearLastEvent();let{mouseEvents:t,map:i,store:o}=this.ctx;if(e.originalEvent.button===2){this.onPointRemove(e);return}this.setSelectedNode(e),ze(i),this.hideLastPointPanel();let r=m.queryPoint(i,e.point),a=P.getGeometryIndex(o,r?.properties.id);this.pointState.setSelectedIdx(a),t&&(t.pointMouseDown=!0),this.pointState.setStartCoordinates(e.lngLat),i.on("mousemove",this.onMapMouseMove),i.on("touchmove",this.onMapMouseMove);};onPointMouseUp=()=>{let{mouseEvents:e,store:t,panel:i,map:o,options:r}=this.ctx;o.off("mousemove",this.onMapMouseMove),o.off("touchmove",this.onMapMouseMove),e.pointMouseUp=!0;let a=this.pointState.getSelectedNode(),p=this.pointState.getLastEvent(),L=this.pointState.getStartCoordinates();a&&!a.val?.isAuxiliary&&(p&&(this.topologyManager.updateStore(),this.pointState.clearLastEvent()),i?.show(),this.pointState.isMoved()&&(d.commit(new F(t,a,L,o)),this.pointState.setMoved(!1)),this.pointState.partialReset()),e&&(e.pointMouseDown=!1),re(o,r),f.execute();}};var Le=class{constructor(e){this.ctx=e;this.pointEvents=new fe(e),this.lineEvents=new se(e),this.initEvents();}pointEvents;lineEvents;initEvents=()=>{this.lineEvents.init(),this.pointEvents?.init();};remove=()=>{this.pointEvents?.remove(),this.lineEvents?.remove();}};var E={AUTO:"auto",DEFAULT:"default",POINTER:"pointer",CROSSHAIR:"crosshair",MOVE:"move",HELP:"help",GRAB:"grab",GRABBING:"grabbing"};var qe=(n,e)=>{let t=e.locale.line,i=e.locale.polygon,o=e.locale.break;return {line:t,polygon:i,break:o}[n]};var Ee=class{constructor(e){this.ctx=e;this.tooltip=new A,this.initEvents();}tooltip;initEvents(){let{lineButton:e,breakButton:t,polygonButton:i}=this.ctx.view;e&&(l.addEventListener(e,"click",this.onLineClick),l.addEventListener(e,"mouseenter",this.onButtonEnter),l.addEventListener(e,"mouseleave",this.onButtonLeave)),i&&(l.addEventListener(i,"click",this.onPolygonClick),l.addEventListener(i,"mouseenter",this.onButtonEnter),l.addEventListener(i,"mouseleave",this.onButtonLeave)),t&&(l.addEventListener(t,"click",this.onBreakClick),l.addEventListener(t,"mouseenter",this.onButtonEnter),l.addEventListener(t,"mouseleave",this.onButtonLeave));}removeEvents(){let{lineButton:e,breakButton:t,polygonButton:i}=this.ctx.view;e&&(l.removeEventListener(e,"click",this.onLineClick),l.removeEventListener(e,"mouseenter",this.onButtonEnter),l.removeEventListener(e,"mouseleave",this.onButtonLeave)),i&&(l.removeEventListener(i,"click",this.onPolygonClick),l.removeEventListener(i,"mouseenter",this.onButtonEnter),l.removeEventListener(i,"mouseleave",this.onButtonLeave)),t&&(l.removeEventListener(t,"click",this.onBreakClick),l.removeEventListener(t,"mouseenter",this.onButtonEnter),l.removeEventListener(t,"mouseleave",this.onButtonLeave));}remove(){this.removeEvents(),this.tooltip.remove();}onButtonEnter=e=>{let{options:t}=this.ctx,i=e.target.getAttribute("data-type");if(i){let o=qe(i,t),r="left";this.tooltip.create({label:o,placement:r}).setPosition(this.tooltip.getPosition(e,r));}};onButtonLeave=()=>{this.tooltip.remove();};removeActiveClass=()=>{let{lineButton:e,breakButton:t,polygonButton:i}=this.ctx.view;e?.classList.remove("control-button-active"),i?.classList.remove("control-button-active"),t?.classList.remove("control-button-active");};onLineClick=()=>{let{mode:e}=this.ctx,{lineButton:t}=this.ctx.view;e.getMode()!=="line"&&(this.removeActiveClass(),t?.classList.add("control-button-active"),e.setMode("line"));};onPolygonClick=()=>{let{mode:e}=this.ctx,{polygonButton:t}=this.ctx.view;e.getMode()!=="polygon"&&(this.removeActiveClass(),t?.classList.add("control-button-active"),e.setMode("polygon"));};onBreakClick=()=>{let{map:e,mode:t}=this.ctx,{breakButton:i}=this.ctx.view;this.removeActiveClass(),i?.classList.add("control-button-active"),t.setBreak(!0),e.getCanvasContainer().style.cursor=E.POINTER;}};var ge=class{constructor(e){this.ctx=e;this.initConsumers();}initConsumers=()=>{this.ctx.mode.addObserver(this.mapModeConsumer);};remove=()=>{this.ctx.mode.removeObserver(this.mapModeConsumer);};resetAllState=()=>{let{lineButton:e,breakButton:t,polygonButton:i}=this.ctx.view;e?.classList.remove("control-button-active"),i?.classList.remove("control-button-active"),t?.classList.remove("control-button-active");};checkActive=e=>{this.resetAllState(),e.classList.add("control-button-active");};observeModeChange=e=>{let{data:t}=e,{lineButton:i,breakButton:o,polygonButton:r}=this.ctx.view,{mode:a}=this.ctx;if(u.modeChanged(this.ctx.map,t),!(!i||!r||!o)){switch(t){case"line":this.checkActive(i);break;case"polygon":this.checkActive(r);break;}t?a.getClosedGeometry()&&T(o):x(o);}};observeGeometryChange=e=>{let{data:t}=e,{lineButton:i,breakButton:o,polygonButton:r}=this.ctx.view,{mode:a}=this.ctx;t?(o&&T(o),a.getMode()==="polygon"&&i&&x(i),a.getMode()==="line"&&r&&x(r)):(o&&x(o),a.getMode()==="polygon"&&i&&T(i),a.getMode()==="line"&&r&&T(r));};mapModeConsumer=e=>{let{type:t,data:i}=e;if(t==="MODE_CHANGED"&&this.observeModeChange(e),t==="CLOSED_GEOMETRY_CHANGED"&&this.observeGeometryChange(e),t==="BREAK_CHANGED"&&i){let{breakButton:o}=this.ctx.view;this.checkActive(o),u.modeChanged(this.ctx.map,"break");}}};var xe=class{constructor(e){this.ctx=e;this.root=l.create("div","mapboxgl-ctrl mapboxgl-ctrl-group maplibregl-ctrl maplibregl-ctrl-group"),this.createControl();}root;lineButton;polygonButton;breakButton;createControlButton=(e,t,i,o)=>{let r=this.ctx.options.panel.size,a=l.create("button",`control-button control-button-${r}`,this.root);return a.setAttribute("aria-label",t),a.setAttribute("data-type",e),i&&a.classList.add("control-button-active"),o&&x(a),l.create("span",`icon ${e} icon-medium`,a),a};createLineButton=()=>{let{mode:e,options:t}=this.ctx,i=this.ctx.options.modes.line.visible,o=t.locale.line;i&&(this.lineButton=this.createControlButton("line",o,e.getMode()==="line"));};createPolygonButton=()=>{let{mode:e,options:t}=this.ctx,i=this.ctx.options.modes.polygon.visible,o=t.locale.polygon;i&&(this.polygonButton=this.createControlButton("polygon",o,e.getMode()==="polygon"));};createBreakButton=()=>{let{mode:e,options:t}=this.ctx,i=this.ctx.options.modes.breakGeometry.visible,o=t.locale.break;if(i){let a=!this.ctx.options.initial?.closeGeometry,p=e.getBreak();this.breakButton=this.createControlButton("break",o,p,a);}};createControl=()=>{this.createLineButton(),this.createPolygonButton(),this.createBreakButton();};getContainer=()=>this.root;destroy=()=>{this.root.remove();}};var Me=class{constructor(e){this.ctx=e;this.view=new xe(e);let t={...e,view:this.view};this.events=new Ee(t),this.observer=new ge(t),this.init();}view;events;observer;init(){let e=this.view.getContainer();this.ctx.map.getContainer().appendChild(e);}getContainer(){return this.view.getContainer()}destroy(){this.events.remove(),this.observer.remove(),this.view.destroy();}};function Xe(n){return n.initial?.geometry?n.initial?.geometry:n.modes.initial?n.modes.initial:null}var be=class extends C{mode;break;closedGeometry;constructor(e){super(),this.mode=Xe(e),this.break=!1,this.closedGeometry=e.initial?.closeGeometry??!1;}getMode=()=>this.mode;setMode=e=>{this.mode=e,this.setBreak(!1),this.notify({type:"MODE_CHANGED",data:e});};getBreak=()=>this.break;setBreak=e=>{this.break=e,this.notify({type:"BREAK_CHANGED",data:e});};getClosedGeometry=()=>this.closedGeometry;setClosedGeometry=e=>{this.closedGeometry=e,this.notify({type:"CLOSED_GEOMETRY_CHANGED",data:this.closedGeometry});};isPolygon=()=>this.mode==="polygon"&&this.getClosedGeometry();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 Pe=class{constructor(e){this.ctx=e;this.#e=this.ctx.map.getCanvasContainer(),this.#e.style.cursor=e.mode.getMode()?E.CROSSHAIR:E.AUTO,this.#t();}#e;set=e=>{this.#e.style.cursor=e;};get=()=>this.#e.style.cursor;handleMouseLeave=I(()=>{let{mouseEvents:e,mode:t}=this.ctx;if(!e.pointMouseDown){if(!t.getMode()){this.set(E.AUTO);return}t.getClosedGeometry()?this.set(E.AUTO):this.set(E.CROSSHAIR);}},10);handleFirstPointMouseEnter=I(()=>{let{store:e,options:t}=this.ctx;P.canCloseGeometry(e,t)&&this.set(E.POINTER);},10);#t(){let{mouseEvents:e}=this.ctx;e.addObserver(this.#i);}remove(){let{mouseEvents:e}=this.ctx;e.removeObserver(this.#i);}#i=e=>{let{mode:t,mouseEvents:i,store:o,options:r}=this.ctx;if(t.getBreak())return;let{type:a,data:p}=e;if(p)switch(a){case"pointMouseDown":this.set(E.GRABBING);break;case"pointMouseUp":this.set(E.GRAB);break;case"pointMouseEnter":if(i.pointMouseDown)return;this.set(E.GRAB);break;case"pointMouseLeave":this.handleMouseLeave();break;case"lineMouseEnter":if(i.pointMouseDown)return;this.set(E.POINTER);break;case"lineMouseLeave":this.handleMouseLeave();break;case"firstPointMouseEnter":this.handleFirstPointMouseEnter();break;case"firstPointMouseLeave":this.handleMouseLeave();break;case"lastPointMouseEnter":P.isClosedGeometry(o,r)||this.set(E.POINTER);break;case"lastPointMouseLeave":this.handleMouseLeave();break;}}};var Ce=class extends C{#e;#t;#i;#o;#n;#s;#r;#a;#l;#p;#c;#u;constructor(){super(),this.#e=!1,this.#t=!1,this.#i=!1,this.#o=!1,this.#n=!1,this.#s=!1,this.#r=!1,this.#a=!1,this.#l=!1,this.#p=!1,this.#c=!1,this.#u=!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.#o}set lastPointMouseUp(e){this.#o=e,this.notify({type:"lastPointMouseUp",data:e});}get lastPointMouseEnter(){return this.#n}set lastPointMouseEnter(e){this.#n=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.#p}set pointMouseLeave(e){this.#p=e,this.notify({type:"pointMouseLeave",data:e});}get lineMouseEnter(){return this.#c}set lineMouseEnter(e){this.#c=e,this.notify({type:"lineMouseEnter",data:e});}get lineMouseLeave(){return this.#u}set lineMouseLeave(e){this.#u=e,this.notify({type:"lineMouseLeave",data:e});}};var V=class{static allStepsHaveIds(e){return e.every(t=>"id"in t&&t.id!==void 0)}static checkIfMissingIds(e,t){let i=!t,o=!this.allStepsHaveIds(e);if(i&&o)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 o=i[0]?.lng,r=i[i.length-1]?.lng,a=i[0]?.lat,p=i[i.length-1]?.lat;if((o!==r||a!==p)&&t)throw new Error(G.FIRST_LAST_POINT_NOT_EQUAL)}}static checkInitialStepsOption(e){let{closeGeometry:t,generateId:i,steps:o}=e;this.checkIfMissingIds(o,i),this.checkIfEnoughPointsToClose(o,t),this.checkIfPolygonIsClosed(e);}static init(e){return e?{pointGeneration:e.pointGeneration??c.pointGeneration,panel:Qe(e),modes:et(e),layersPaint:tt(e),initial:e.initial||c.initial,locale:it(e),dynamicLine:e.dynamicLine??c.dynamicLine}:c}};function Qe(n){return {size:n.panel?.size||c.panel.size,buttons:{undo:{visible:n.panel?.buttons?.undo?.visible??c.panel.buttons.undo.visible},redo:{visible:n.panel?.buttons?.redo?.visible??c.panel.buttons.redo.visible},delete:{visible:n.panel?.buttons?.delete?.visible??c.panel.buttons.delete.visible},save:{visible:n.panel?.buttons?.save?.visible??c.panel.buttons.save.visible,clearOnSave:n.panel?.buttons?.save?.clearOnSave??c.panel.buttons.save.clearOnSave}}}}function et(n){return {initial:n.modes?.initial||c.modes.initial,line:{visible:n?.modes?.line?.visible!==void 0?n.modes.line.visible:n?.initial?.geometry==="line"||c.modes.line.visible,closeGeometry:n?.modes?.line?.closeGeometry??c.modes.line.closeGeometry},polygon:{visible:n?.modes?.polygon?.visible!==void 0?n.modes.polygon.visible:n?.initial?.geometry==="polygon"||c.modes.polygon.visible},breakGeometry:{visible:n?.modes?.breakGeometry?.visible??c.modes.breakGeometry.visible}}}function tt(n){return {onLinePoint:{"circle-radius":n.layersPaint?.onLinePoint?.["circle-radius"]||R["circle-radius"],"circle-color":n.layersPaint?.onLinePoint?.["circle-color"]||R["circle-color"],"circle-stroke-color":n.layersPaint?.onLinePoint?.["circle-stroke-color"]||R["circle-stroke-color"],"circle-stroke-width":n.layersPaint?.onLinePoint?.["circle-stroke-width"]||R["circle-stroke-width"],...n.layersPaint?.onLinePoint},firstPoint:{"circle-radius":n.layersPaint?.firstPoint?.["circle-radius"]||k["circle-radius"],"circle-color":n.layersPaint?.firstPoint?.["circle-color"]||k["circle-color"],"circle-stroke-color":n.layersPaint?.firstPoint?.["circle-stroke-color"]||k["circle-stroke-color"],"circle-stroke-width":n.layersPaint?.firstPoint?.["circle-stroke-width"]||k["circle-stroke-width"],...n.layersPaint?.firstPoint},points:{"circle-radius":n.layersPaint?.points?.["circle-radius"]||D["circle-radius"],"circle-color":n.layersPaint?.points?.["circle-color"]||D["circle-color"],"circle-stroke-color":n.layersPaint?.points?.["circle-stroke-color"]||D["circle-stroke-color"],"circle-stroke-width":n.layersPaint?.points?.["circle-stroke-width"]||D["circle-stroke-width"],...n.layersPaint?.points},auxiliaryPoint:{"circle-radius":n.layersPaint?.auxiliaryPoint?.["circle-radius"]||U["circle-radius"],"circle-color":n.layersPaint?.auxiliaryPoint?.["circle-color"]||U["circle-color"],"circle-stroke-color":n.layersPaint?.auxiliaryPoint?.["circle-stroke-color"]||U["circle-stroke-color"],"circle-stroke-width":n.layersPaint?.auxiliaryPoint?.["circle-stroke-width"]||U["circle-stroke-width"],...n.layersPaint?.auxiliaryPoint},line:{"line-width":n.layersPaint?.line?.["line-width"]||B["line-width"],"line-color":n.layersPaint?.line?.["line-color"]||B["line-color"],"line-opacity":n.layersPaint?.line?.["line-opacity"]||B["line-opacity"],...n.layersPaint?.line},polygon:{"fill-color":n.layersPaint?.polygon?.["fill-color"]||H["fill-color"],"fill-opacity":n.layersPaint?.polygon?.["fill-opacity"]||H["fill-opacity"],...n.layersPaint?.polygon},breakLine:{"line-width":n.layersPaint?.breakLine?.["line-width"]||_["line-width"],"line-color":n.layersPaint?.breakLine?.["line-color"]||_["line-color"],"line-dasharray":n.layersPaint?.breakLine?.["line-dasharray"]||_["line-dasharray"],...n.layersPaint?.breakLine}}}function it(n){return {save:n.locale?.save??c.locale.save,delete:n.locale?.delete??c.locale.delete,undo:n.locale?.undo??c.locale.undo,redo:n.locale?.redo??c.locale.redo,line:n.locale?.line??c.locale.line,polygon:n.locale?.polygon??c.locale.polygon,break:n.locale?.break??c.locale.break,closeLine:n.locale?.closeLine??c.locale.closeLine,createPolygon:n.locale?.createPolygon??c.locale.createPolygon}}var Se=class{constructor(e){this.ctx=e;}init(){this.add(),this.swap(s.LineLayer,s.SinglePointLayer),this.swap(s.LineLayerTransparent,s.SinglePointLayer),this.swap(s.LineLayerTransparent,s.FirstPointLayer),this.swap(s.LineLayerTransparent,s.PointsLayer),this.swap(s.PolygonLayer,s.LineLayer),this.initConsumers();}initConsumers=()=>{this.ctx.store.addObserver(this.onStoreChange);};removeConsumers=()=>{this.ctx.store.removeObserver(this.onStoreChange);};onStoreChange=I(e=>{if(["STORE_MUTATED","STORE_CLOSE_GEOMETRY","STORE_BREAK_GEOMETRY","STORE_CLEARED"].includes(e.type)){let{map:i,store:o,mode:r}=this.ctx;r.getMode()==="polygon"&&o.circular.isCircular()?i.setLayoutProperty(s.PolygonLayer,"visibility","visible"):i.setLayoutProperty(s.PolygonLayer,"visibility","none");}},10);add=()=>{let e=J(this.ctx.options);for(let t of e)this.ctx.map.getLayer(t.id)||this.ctx.map.addLayer(t);};swap=(e,t)=>{let i=this.ctx.map.getLayer(e),o=this.ctx.map.getLayer(t);i&&o&&this.ctx.map.moveLayer(e,t);};removeLayers=()=>{for(let e of Object.values(s))this.ctx.map.getLayer(e)&&this.ctx.map.removeLayer(e);};remove=()=>{this.removeConsumers(),this.removeLayers();}};var we=class{constructor(e){this.ctx=e;}init(){for(let e of Object.values(h))this.ctx.map.getSource(e)||this.ctx.map.addSource(e,{type:"geojson",data:{type:"FeatureCollection",features:[]},promoteId:"id"});}remove(){for(let e of Object.values(h))this.ctx.map.getSource(e)&&this.ctx.map.removeSource(e);}};var Oe=class{constructor(e){this.ctx=e;this.sources=new we(this.ctx),this.layers=new Se(this.ctx),this.init();}sources;layers;init=()=>{this.sources.init(),this.layers.init();};remove=()=>{this.layers.remove(),this.sources.remove();}};var Ie=class n{container;store;mode;defaultOptions;mapEvents;tiles;panel;control;cursor;mouseEvents;renderer=null;static instance=null;constructor(e){this.defaultOptions=V.init(e),this.defaultOptions.initial&&V.checkInitialStepsOption(this.defaultOptions.initial);}static getInstance(e){return n.instance||(n.instance=new n(e)),n.instance}onAdd=e=>(this.store=new q(this.defaultOptions),this.mode=new be(this.defaultOptions),this.tiles=new Oe({map:e,store:this.store,mode:this.mode,options:this.defaultOptions}),this.renderer=f.initialize({map:e,store:this.store,options:this.defaultOptions,mode:this.mode}),this.control=new Me({options:this.defaultOptions,map:e,mode:this.mode}),this.mouseEvents=new Ce,this.cursor=new Pe({map:e,mode:this.mode,mouseEvents:this.mouseEvents,store:this.store,options:this.defaultOptions}),this.panel=new Q({map:e,mode:this.mode,options:this.defaultOptions,store:this.store}),this.mapEvents=new Le({map:e,store:this.store,options:this.defaultOptions,panel:this.panel,control:this.control,mode:this.mode,mouseEvents:this.mouseEvents}),this.mode.pingConsumers(),this.store.pingConsumers(),this.container=this.control.getContainer(),this.container);onRemove=()=>{this.cursor?.remove(),this.tiles?.remove(),this.mapEvents?.remove(),this.panel?.destroy(),this.store?.reset(),this.mode?.unsubscribe(),this.control?.destroy(),this.container&&l.remove(this.container);};setSteps=e=>{if(Array.isArray(e))for(let t of e){let i={...t,id:t.id||g()};this.store?.push(i);}else throw new Error("Invalid argument. Expected an array of steps.");this.renderer?.execute();};findStepById=e=>this.store?.findStepById(e);findNodeById=e=>this.store?.findNodeById(e);getAllSteps=(e="array")=>{if(e==="array"&&this.store)return b.toArray(this.store.head);if(e==="linkedlist")return {head:this.store?.head,tail:this.store?.tail,size:this.store?.size};throw new Error("Invalid type specified. Use 'array' or 'linkedlist'.")};setOptions=e=>{this.defaultOptions=e(this.defaultOptions);};removeAllSteps=()=>{this.store?.reset(),this.panel?.destroy(),this.renderer?.execute();}};
2
2
 
3
- export { Ne as default };
3
+ export { Ie as default };
4
4
  //# sourceMappingURL=index.js.map
5
5
  //# sourceMappingURL=index.js.map