Файловый менеджер - Редактировать - /home/atelierpru/provence/52177/vendor.tar
Назад
maplibre-gl.css 0000666 00000210610 15244655454 0007473 0 ustar 00 .maplibregl-map{font:12px/20px Helvetica Neue,Arial,Helvetica,sans-serif;overflow:hidden;position:relative;-webkit-tap-highlight-color:rgb(0 0 0/0)}.maplibregl-canvas{left:0;position:absolute;top:0}.maplibregl-map:fullscreen{height:100%;width:100%}.maplibregl-ctrl-group button.maplibregl-ctrl-compass{touch-action:none}.maplibregl-canvas-container.maplibregl-interactive,.maplibregl-ctrl-group button.maplibregl-ctrl-compass{cursor:grab;-webkit-user-select:none;-moz-user-select:none;user-select:none}.maplibregl-canvas-container.maplibregl-interactive.maplibregl-track-pointer{cursor:pointer}.maplibregl-canvas-container.maplibregl-interactive:active,.maplibregl-ctrl-group button.maplibregl-ctrl-compass:active{cursor:grabbing}.maplibregl-canvas-container.maplibregl-touch-zoom-rotate,.maplibregl-canvas-container.maplibregl-touch-zoom-rotate .maplibregl-canvas{touch-action:pan-x pan-y}.maplibregl-canvas-container.maplibregl-touch-drag-pan,.maplibregl-canvas-container.maplibregl-touch-drag-pan .maplibregl-canvas{touch-action:pinch-zoom}.maplibregl-canvas-container.maplibregl-touch-zoom-rotate.maplibregl-touch-drag-pan,.maplibregl-canvas-container.maplibregl-touch-zoom-rotate.maplibregl-touch-drag-pan .maplibregl-canvas{touch-action:none}.maplibregl-canvas-container.maplibregl-touch-drag-pan.maplibregl-cooperative-gestures,.maplibregl-canvas-container.maplibregl-touch-drag-pan.maplibregl-cooperative-gestures .maplibregl-canvas{touch-action:pan-x pan-y}.maplibregl-ctrl-bottom-left,.maplibregl-ctrl-bottom-right,.maplibregl-ctrl-top-left,.maplibregl-ctrl-top-right{pointer-events:none;position:absolute;z-index:2}.maplibregl-ctrl-top-left{left:0;top:0}.maplibregl-ctrl-top-right{right:0;top:0}.maplibregl-ctrl-bottom-left{bottom:0;left:0}.maplibregl-ctrl-bottom-right{bottom:0;right:0}.maplibregl-ctrl{clear:both;pointer-events:auto;transform:translate(0)}.maplibregl-ctrl-top-left .maplibregl-ctrl{float:left;margin:10px 0 0 10px}.maplibregl-ctrl-top-right .maplibregl-ctrl{float:right;margin:10px 10px 0 0}.maplibregl-ctrl-bottom-left .maplibregl-ctrl{float:left;margin:0 0 10px 10px}.maplibregl-ctrl-bottom-right .maplibregl-ctrl{float:right;margin:0 10px 10px 0}.maplibregl-ctrl-group{background:#fff;border-radius:4px}.maplibregl-ctrl-group:not(:empty){box-shadow:0 0 0 2px rgba(0,0,0,.1)}@media (forced-colors:active){.maplibregl-ctrl-group:not(:empty){box-shadow:0 0 0 2px ButtonText}}.maplibregl-ctrl-group button{background-color:transparent;border:0;box-sizing:border-box;cursor:pointer;display:block;height:29px;outline:none;padding:0;width:29px}.maplibregl-ctrl-group button+button{border-top:1px solid #ddd}.maplibregl-ctrl button .maplibregl-ctrl-icon{background-position:50%;background-repeat:no-repeat;display:block;height:100%;width:100%}@media (forced-colors:active){.maplibregl-ctrl-icon{background-color:transparent}.maplibregl-ctrl-group button+button{border-top:1px solid ButtonText}}.maplibregl-ctrl button::-moz-focus-inner{border:0;padding:0}.maplibregl-ctrl-attrib-button:focus,.maplibregl-ctrl-group button:focus{box-shadow:0 0 2px 2px #0096ff}.maplibregl-ctrl button:disabled{cursor:not-allowed}.maplibregl-ctrl button:disabled .maplibregl-ctrl-icon{opacity:.25}@media (hover:hover){.maplibregl-ctrl button:not(:disabled):hover{background-color:rgba(0,0,0,.05)}}.maplibregl-ctrl button:not(:disabled):active{background-color:rgba(0,0,0,.05)}.maplibregl-ctrl-group button:focus:focus-visible{box-shadow:0 0 2px 2px #0096ff}.maplibregl-ctrl-group button:focus:not(:focus-visible){box-shadow:none}.maplibregl-ctrl-group button:focus:first-child{border-radius:4px 4px 0 0}.maplibregl-ctrl-group button:focus:last-child{border-radius:0 0 4px 4px}.maplibregl-ctrl-group button:focus:only-child{border-radius:inherit}.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-globe .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='none' stroke='%23333' viewBox='0 0 22 22'%3E%3Ccircle cx='11' cy='11' r='8.5'/%3E%3Cpath d='M17.5 11c0 4.819-3.02 8.5-6.5 8.5S4.5 15.819 4.5 11 7.52 2.5 11 2.5s6.5 3.681 6.5 8.5Z'/%3E%3Cpath d='M13.5 11c0 2.447-.331 4.64-.853 6.206-.262.785-.562 1.384-.872 1.777-.314.399-.58.517-.775.517s-.461-.118-.775-.517c-.31-.393-.61-.992-.872-1.777C8.831 15.64 8.5 13.446 8.5 11s.331-4.64.853-6.206c.262-.785.562-1.384.872-1.777.314-.399.58-.517.775-.517s.461.118.775.517c.31.393.61.992.872 1.777.522 1.565.853 3.76.853 6.206Z'/%3E%3Cpath d='M11 7.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138q.07-.058.224-.138c.299-.151.763-.302 1.379-.434C7.378 5.666 9.091 5.5 11 5.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138q-.07.058-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428ZM4.486 6.436ZM11 16.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138 1.3 1.3 0 0 1 .224-.138c.299-.151.763-.302 1.379-.434C7.378 14.666 9.091 14.5 11 14.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138a1.3 1.3 0 0 1-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428Zm-6.514-1.064ZM11 12.5c-2.46 0-4.672-.222-6.255-.574-.796-.177-1.406-.38-1.805-.59a1.5 1.5 0 0 1-.39-.272.3.3 0 0 1-.047-.064.3.3 0 0 1 .048-.064c.066-.073.189-.167.389-.272.399-.21 1.009-.413 1.805-.59C6.328 9.722 8.54 9.5 11 9.5s4.672.222 6.256.574c.795.177 1.405.38 1.804.59.2.105.323.2.39.272a.3.3 0 0 1 .047.064.3.3 0 0 1-.048.064 1.4 1.4 0 0 1-.389.272c-.399.21-1.009.413-1.804.59-1.584.352-3.796.574-6.256.574Zm-8.501-1.51v.002zm0 .018v.002zm17.002.002v-.002zm0-.018v-.002z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-globe-enabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='none' stroke='%2333b5e5' viewBox='0 0 22 22'%3E%3Ccircle cx='11' cy='11' r='8.5'/%3E%3Cpath d='M17.5 11c0 4.819-3.02 8.5-6.5 8.5S4.5 15.819 4.5 11 7.52 2.5 11 2.5s6.5 3.681 6.5 8.5Z'/%3E%3Cpath d='M13.5 11c0 2.447-.331 4.64-.853 6.206-.262.785-.562 1.384-.872 1.777-.314.399-.58.517-.775.517s-.461-.118-.775-.517c-.31-.393-.61-.992-.872-1.777C8.831 15.64 8.5 13.446 8.5 11s.331-4.64.853-6.206c.262-.785.562-1.384.872-1.777.314-.399.58-.517.775-.517s.461.118.775.517c.31.393.61.992.872 1.777.522 1.565.853 3.76.853 6.206Z'/%3E%3Cpath d='M11 7.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138q.07-.058.224-.138c.299-.151.763-.302 1.379-.434C7.378 5.666 9.091 5.5 11 5.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138q-.07.058-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428ZM4.486 6.436ZM11 16.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138 1.3 1.3 0 0 1 .224-.138c.299-.151.763-.302 1.379-.434C7.378 14.666 9.091 14.5 11 14.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138a1.3 1.3 0 0 1-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428Zm-6.514-1.064ZM11 12.5c-2.46 0-4.672-.222-6.255-.574-.796-.177-1.406-.38-1.805-.59a1.5 1.5 0 0 1-.39-.272.3.3 0 0 1-.047-.064.3.3 0 0 1 .048-.064c.066-.073.189-.167.389-.272.399-.21 1.009-.413 1.805-.59C6.328 9.722 8.54 9.5 11 9.5s4.672.222 6.256.574c.795.177 1.405.38 1.804.59.2.105.323.2.39.272a.3.3 0 0 1 .047.064.3.3 0 0 1-.048.064 1.4 1.4 0 0 1-.389.272c-.399.21-1.009.413-1.804.59-1.584.352-3.796.574-6.256.574Zm-8.501-1.51v.002zm0 .018v.002zm17.002.002v-.002zm0-.018v-.002z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-terrain .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='%23333' viewBox='0 0 22 22'%3E%3Cpath d='m1.754 13.406 4.453-4.851 3.09 3.09 3.281 3.277.969-.969-3.309-3.312 3.844-4.121 6.148 6.886h1.082v-.855l-7.207-8.07-4.84 5.187L6.169 6.57l-5.48 5.965v.871ZM.688 16.844h20.625v1.375H.688Zm0 0'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-terrain-enabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='%2333b5e5' viewBox='0 0 22 22'%3E%3Cpath d='m1.754 13.406 4.453-4.851 3.09 3.09 3.281 3.277.969-.969-3.309-3.312 3.844-4.121 6.148 6.886h1.082v-.855l-7.207-8.07-4.84 5.187L6.169 6.57l-5.48 5.965v.871ZM.688 16.844h20.625v1.375H.688Zm0 0'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23aaa' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e58978' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e54e33' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-waiting .maplibregl-ctrl-icon{animation:maplibregl-spin 2s linear infinite}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23999' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e58978' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e54e33' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23666' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}}@keyframes maplibregl-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}a.maplibregl-ctrl-logo{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E");background-repeat:no-repeat;cursor:pointer;display:block;height:23px;margin:0 0 -4px -4px;overflow:hidden;width:88px}a.maplibregl-ctrl-logo.maplibregl-compact{width:14px}@media (forced-colors:active){a.maplibregl-ctrl-logo{background-color:transparent;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){a.maplibregl-ctrl-logo{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E")}}.maplibregl-ctrl.maplibregl-ctrl-attrib{background-color:hsla(0,0%,100%,.5);margin:0;padding:0 5px}@media screen{.maplibregl-ctrl-attrib.maplibregl-compact{background-color:#fff;border-radius:12px;box-sizing:content-box;color:#000;margin:10px;min-height:20px;padding:2px 24px 2px 0;position:relative}.maplibregl-ctrl-attrib.maplibregl-compact-show{padding:2px 28px 2px 8px;visibility:visible}.maplibregl-ctrl-bottom-left>.maplibregl-ctrl-attrib.maplibregl-compact-show,.maplibregl-ctrl-top-left>.maplibregl-ctrl-attrib.maplibregl-compact-show{border-radius:12px;padding:2px 8px 2px 28px}.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-inner{display:none}.maplibregl-ctrl-attrib-button{background-color:hsla(0,0%,100%,.5);background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E");border:0;border-radius:12px;box-sizing:border-box;cursor:pointer;display:none;height:24px;outline:none;position:absolute;right:0;top:0;width:24px}.maplibregl-ctrl-attrib summary.maplibregl-ctrl-attrib-button{-webkit-appearance:none;-moz-appearance:none;appearance:none;list-style:none}.maplibregl-ctrl-attrib summary.maplibregl-ctrl-attrib-button::-webkit-details-marker{display:none}.maplibregl-ctrl-bottom-left .maplibregl-ctrl-attrib-button,.maplibregl-ctrl-top-left .maplibregl-ctrl-attrib-button{left:0}.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-button,.maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-inner{display:block}.maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-button{background-color:rgba(0,0,0,.05)}.maplibregl-ctrl-bottom-right>.maplibregl-ctrl-attrib.maplibregl-compact:after{bottom:0;right:0}.maplibregl-ctrl-top-right>.maplibregl-ctrl-attrib.maplibregl-compact:after{right:0;top:0}.maplibregl-ctrl-top-left>.maplibregl-ctrl-attrib.maplibregl-compact:after{left:0;top:0}.maplibregl-ctrl-bottom-left>.maplibregl-ctrl-attrib.maplibregl-compact:after{bottom:0;left:0}}@media screen and (forced-colors:active){.maplibregl-ctrl-attrib.maplibregl-compact:after{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='%23fff' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E")}}@media screen and (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl-attrib.maplibregl-compact:after{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E")}}.maplibregl-ctrl-attrib a{color:rgba(0,0,0,.75);text-decoration:none}.maplibregl-ctrl-attrib a:hover{color:inherit;text-decoration:underline}.maplibregl-attrib-empty{display:none}.maplibregl-ctrl-scale{background-color:hsla(0,0%,100%,.75);border:2px solid #333;border-top:#333;box-sizing:border-box;color:#333;font-size:10px;padding:0 5px;white-space:nowrap}.maplibregl-popup{display:flex;left:0;pointer-events:none;position:absolute;top:0;will-change:transform}.maplibregl-popup-anchor-top,.maplibregl-popup-anchor-top-left,.maplibregl-popup-anchor-top-right{flex-direction:column}.maplibregl-popup-anchor-bottom,.maplibregl-popup-anchor-bottom-left,.maplibregl-popup-anchor-bottom-right{flex-direction:column-reverse}.maplibregl-popup-anchor-left{flex-direction:row}.maplibregl-popup-anchor-right{flex-direction:row-reverse}.maplibregl-popup-tip{border:10px solid transparent;height:0;width:0;z-index:1}.maplibregl-popup-anchor-top .maplibregl-popup-tip{align-self:center;border-bottom-color:#fff;border-top:none}.maplibregl-popup-anchor-top-left .maplibregl-popup-tip{align-self:flex-start;border-bottom-color:#fff;border-left:none;border-top:none}.maplibregl-popup-anchor-top-right .maplibregl-popup-tip{align-self:flex-end;border-bottom-color:#fff;border-right:none;border-top:none}.maplibregl-popup-anchor-bottom .maplibregl-popup-tip{align-self:center;border-bottom:none;border-top-color:#fff}.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip{align-self:flex-start;border-bottom:none;border-left:none;border-top-color:#fff}.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip{align-self:flex-end;border-bottom:none;border-right:none;border-top-color:#fff}.maplibregl-popup-anchor-left .maplibregl-popup-tip{align-self:center;border-left:none;border-right-color:#fff}.maplibregl-popup-anchor-right .maplibregl-popup-tip{align-self:center;border-left-color:#fff;border-right:none}[dir=rtl] .maplibregl-popup-anchor-left{flex-direction:row-reverse}[dir=rtl] .maplibregl-popup-anchor-right{flex-direction:row}[dir=rtl] .maplibregl-popup-anchor-top-left .maplibregl-popup-tip{align-self:flex-end}[dir=rtl] .maplibregl-popup-anchor-top-right .maplibregl-popup-tip{align-self:flex-start}[dir=rtl] .maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip{align-self:flex-end}[dir=rtl] .maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip{align-self:flex-start}.maplibregl-popup-close-button{background-color:transparent;border:0;border-radius:0 3px 0 0;cursor:pointer;position:absolute;right:0;top:0}.maplibregl-popup-close-button:hover{background-color:rgba(0,0,0,.05)}.maplibregl-popup-content{background:#fff;border-radius:3px;box-shadow:0 1px 2px rgba(0,0,0,.1);padding:15px 10px;pointer-events:auto;position:relative}.maplibregl-popup-anchor-top-left .maplibregl-popup-content{border-top-left-radius:0}.maplibregl-popup-anchor-top-right .maplibregl-popup-content{border-top-right-radius:0}.maplibregl-popup-anchor-bottom-left .maplibregl-popup-content{border-bottom-left-radius:0}.maplibregl-popup-anchor-bottom-right .maplibregl-popup-content{border-bottom-right-radius:0}.maplibregl-popup-track-pointer{display:none}.maplibregl-popup-track-pointer *{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.maplibregl-map:hover .maplibregl-popup-track-pointer{display:flex}.maplibregl-map:active .maplibregl-popup-track-pointer{display:none}.maplibregl-marker{left:0;position:absolute;top:0;transition:opacity .2s;will-change:transform}.maplibregl-user-location-dot,.maplibregl-user-location-dot:before{background-color:#1da1f2;border-radius:50%;height:15px;width:15px}.maplibregl-user-location-dot:before{animation:maplibregl-user-location-dot-pulse 2s infinite;content:"";position:absolute}.maplibregl-user-location-dot:after{border:2px solid #fff;border-radius:50%;box-shadow:0 0 3px rgba(0,0,0,.35);box-sizing:border-box;content:"";height:19px;left:-2px;position:absolute;top:-2px;width:19px}@media (prefers-reduced-motion:reduce){.maplibregl-user-location-dot:before{animation:none}}@keyframes maplibregl-user-location-dot-pulse{0%{opacity:1;transform:scale(1)}70%{opacity:0;transform:scale(3)}to{opacity:0;transform:scale(1)}}.maplibregl-user-location-dot-stale{background-color:#aaa}.maplibregl-user-location-dot-stale:after{display:none}.maplibregl-user-location-accuracy-circle{background-color:#1da1f233;border-radius:100%;height:1px;width:1px}.maplibregl-crosshair,.maplibregl-crosshair .maplibregl-interactive,.maplibregl-crosshair .maplibregl-interactive:active{cursor:crosshair}.maplibregl-boxzoom{background:#fff;border:2px dotted #202020;height:0;left:0;opacity:.5;position:absolute;top:0;width:0}.maplibregl-cooperative-gesture-screen{align-items:center;background:rgba(0,0,0,.4);color:#fff;display:flex;font-size:1.4em;inset:0;justify-content:center;line-height:1.2;opacity:0;padding:1rem;pointer-events:none;position:absolute;transition:opacity 1s ease 1s;z-index:99999}.maplibregl-cooperative-gesture-screen.maplibregl-show{opacity:1;transition:opacity .05s}.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:none}@media (hover:none),(pointer:coarse){.maplibregl-cooperative-gesture-screen .maplibregl-desktop-message{display:none}.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:block}}.maplibregl-pseudo-fullscreen{height:100%!important;left:0!important;position:fixed!important;top:0!important;width:100%!important;z-index:99999} deck.gl.min.js 0000666 00006220402 15244655454 0007223 0 ustar 00 /* deck.gl v9.3.7 — https://deck.gl — MIT License (bundle scripting officiel) */ (function webpackUniversalModuleDefinition(root, factory) { if (typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if (typeof define === 'function' && define.amd) define([], factory); else if (typeof exports === 'object') exports['deck'] = factory(); else root['deck'] = factory();})(globalThis, function () { "use strict";var __exports__=(()=>{var c5=Object.create;var Hl=Object.defineProperty;var l5=Object.getOwnPropertyDescriptor;var f5=Object.getOwnPropertyNames;var u5=Object.getPrototypeOf,d5=Object.prototype.hasOwnProperty;var h5=(t,e,r)=>e in t?Hl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var qw=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var L=(t,e)=>()=>(t&&(e=t(t=0)),e);var jl=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ze=(t,e)=>{for(var r in e)Hl(t,r,{get:e[r],enumerable:!0})},Zw=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of f5(e))!d5.call(t,n)&&n!==r&&Hl(t,n,{get:()=>e[n],enumerable:!(o=l5(e,n))||o.enumerable});return t};var kn=(t,e,r)=>(r=t!=null?c5(u5(t)):{},Zw(e||!t||!t.__esModule?Hl(r,"default",{value:t,enumerable:!0}):r,t)),p5=t=>Zw(Hl({},"__esModule",{value:!0}),t);var k=(t,e,r)=>(h5(t,typeof e!="symbol"?e+"":e,r),r);var Op,b5,Fp,A5,Qw,_b=L(()=>{Op=globalThis,b5=globalThis.document||{},Fp=globalThis.process||{},A5=globalThis.console,Qw=globalThis.navigator||{}});function Np(t){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&Boolean(process.versions?.electron))return!0;let e=typeof navigator<"u"&&navigator.userAgent,r=t||e;return Boolean(r&&r.indexOf("Electron")>=0)}var yb=L(()=>{});function Ot(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||Np()}var xb=L(()=>{yb()});function bb(t){return!t&&!Ot()?"Node":Np(t)?"Electron":(t||Qw.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown"}var eP=L(()=>{xb();yb();_b()});var Ab,Vn=L(()=>{_b();xb();eP();Ab="4.1.1"});function _a(t,e){if(!t)throw new Error(e||"Assertion failed")}var Tb=L(()=>{});function vb(t){if(!t)return 0;let e;switch(typeof t){case"number":e=t;break;case"object":e=t.logLevel||t.priority||0;break;default:return 0}return _a(Number.isFinite(e)&&e>=0),e}function tP(t){let{logLevel:e,message:r}=t;t.logLevel=vb(e);let o=t.args?Array.from(t.args):[];for(;o.length&&o.shift()!==r;);switch(typeof e){case"string":case"function":r!==void 0&&o.unshift(r),t.message=e;break;case"object":Object.assign(t,e);break;default:}typeof t.message=="function"&&(t.message=t.message());let n=typeof t.message;return _a(n==="string"||n==="object"),Object.assign(t,{args:o},t.opts)}var rP=L(()=>{Tb()});var Hi,Dp,oP=L(()=>{rP();Hi=()=>{},Dp=class{constructor({level:e=0}={}){this.userData={},this._onceCache=new Set,this._level=e}set level(e){this.setLevel(e)}get level(){return this.getLevel()}setLevel(e){return this._level=e,this}getLevel(){return this._level}warn(e,...r){return this._log("warn",0,e,r,{once:!0})}error(e,...r){return this._log("error",0,e,r)}log(e,r,...o){return this._log("log",e,r,o)}info(e,r,...o){return this._log("info",e,r,o)}once(e,r,...o){return this._log("once",e,r,o,{once:!0})}_log(e,r,o,n,i={}){let s=tP({logLevel:r,message:o,args:this._buildArgs(r,o,n),opts:i});return this._createLogFunction(e,s,i)}_buildArgs(e,r,o){return[e,r,...o]}_createLogFunction(e,r,o){if(!this._shouldLog(r.logLevel))return Hi;let n=this._getOnceTag(o.tag??r.tag??r.message);if((o.once||r.once)&&n!==void 0){if(this._onceCache.has(n))return Hi;this._onceCache.add(n)}return this._emit(e,r)}_shouldLog(e){return this.getLevel()>=vb(e)}_getOnceTag(e){if(e!==void 0)try{return typeof e=="string"?e:String(e)}catch{return}}}});function v5(t){try{let e=window[t],r="__storage_test__";return e.setItem(r,r),e.removeItem(r),e}catch{return null}}var Up,nP=L(()=>{Up=class{constructor(e,r,o="sessionStorage"){this.storage=v5(o),this.id=e,this.config=r,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let r=JSON.stringify(this.config);this.storage.setItem(this.id,r)}}_loadConfiguration(){let e={};if(this.storage){let r=this.storage.getItem(this.id);e=r?JSON.parse(r):{}}return Object.assign(this.config,e),this}}});function iP(t){let e;return t<10?e=`${t.toFixed(2)}ms`:t<100?e=`${t.toFixed(1)}ms`:t<1e3?e=`${t.toFixed(0)}ms`:e=`${(t/1e3).toFixed(2)}s`,e}function sP(t,e=8){let r=Math.max(e-t.length,0);return`${" ".repeat(r)}${t}`}var aP=L(()=>{});function cP(t){return typeof t!="string"?t:(t=t.toUpperCase(),kp[t]||kp.WHITE)}function lP(t,e,r){return!Ot&&typeof t=="string"&&(e&&(t=`\x1B[${cP(e)}m${t}\x1B[39m`),r&&(t=`\x1B[${cP(r)+S5}m${t}\x1B[49m`)),t}var kp,S5,fP=L(()=>{Vn();(function(t){t[t.BLACK=30]="BLACK",t[t.RED=31]="RED",t[t.GREEN=32]="GREEN",t[t.YELLOW=33]="YELLOW",t[t.BLUE=34]="BLUE",t[t.MAGENTA=35]="MAGENTA",t[t.CYAN=36]="CYAN",t[t.WHITE=37]="WHITE",t[t.BRIGHT_BLACK=90]="BRIGHT_BLACK",t[t.BRIGHT_RED=91]="BRIGHT_RED",t[t.BRIGHT_GREEN=92]="BRIGHT_GREEN",t[t.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",t[t.BRIGHT_BLUE=94]="BRIGHT_BLUE",t[t.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",t[t.BRIGHT_CYAN=96]="BRIGHT_CYAN",t[t.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(kp||(kp={}));S5=10});function uP(t,e=["constructor"]){let r=Object.getPrototypeOf(t),o=Object.getOwnPropertyNames(r),n=t;for(let i of o){let s=n[i];typeof s=="function"&&(e.find(a=>i===a)||(n[i]=s.bind(t)))}}var dP=L(()=>{});function ya(){let t;if(Ot()&&Op.performance)t=Op?.performance?.now?.();else if("hrtime"in Fp){let e=Fp?.hrtime?.();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var hP=L(()=>{Vn()});function C5(t,e,r){if(typeof e=="string"){let o=r.time?sP(iP(r.total)):"";e=r.time?`${t}: ${o} ${e}`:`${t}: ${e}`,e=lP(e,r.color,r.background)}return e}function E5(t){for(let e in t)for(let r in t[e])return r||"untitled";return"empty"}var xa,Sb,ct,Cb=L(()=>{Vn();oP();nP();aP();fP();dP();Tb();hP();xa={debug:Ot()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},Sb={enabled:!0,level:0},ct=class extends Dp{constructor({id:e}={id:""}){super({level:0}),this.VERSION=Ab,this._startTs=ya(),this._deltaTs=ya(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new Up(`__probe-${this.id}__`,{[this.id]:Sb}),this.timeStamp(`${this.id} started`),uP(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((ya()-this._startTs).toPrecision(10))}getDelta(){return Number((ya()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._updateConfiguration({enabled:e}),this}setLevel(e){return this._updateConfiguration({level:e}),this}get(e){return this._getConfiguration()[e]}set(e,r){this._updateConfiguration({[e]:r})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,r){if(!e)throw new Error(r||"Assertion failed")}warn(e,...r){return this._log("warn",0,e,r,{method:xa.warn,once:!0})}error(e,...r){return this._log("error",0,e,r,{method:xa.error})}deprecated(e,r){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${r}\` instead`)}removed(e,r){return this.error(`\`${e}\` has been removed. Use \`${r}\` instead`)}probe(e,r,...o){return this._log("log",e,r,o,{method:xa.log,time:!0,once:!0})}log(e,r,...o){return this._log("log",e,r,o,{method:xa.debug})}info(e,r,...o){return this._log("info",e,r,o,{method:console.info})}once(e,r,...o){return this._log("once",e,r,o,{method:xa.debug||xa.info,once:!0})}table(e,r,o){return r?this._log("table",e,r,o&&[o]||[],{method:console.table||Hi,tag:E5(r)}):Hi}time(e,r){return this._log("time",e,r,[],{method:console.time?console.time:console.info})}timeEnd(e,r){return this._log("time",e,r,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(e,r){return this._log("time",e,r,[],{method:console.timeStamp||Hi})}group(e,r,o={collapsed:!1}){let n=(o.collapsed?console.groupCollapsed:console.group)||console.info;return this._log("group",e,r,[],{method:n})}groupCollapsed(e,r,o={}){return this.group(e,r,Object.assign({},o,{collapsed:!0}))}groupEnd(e){return this._log("groupEnd",e,"",[],{method:console.groupEnd||Hi})}withGroup(e,r,o){this.group(e,r)();try{o()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&super._shouldLog(e)}_emit(e,r){let o=r.method;_a(o),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=ya();let n=C5(this.id,r.message,r);return o.bind(console,n,...r.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(Sb),this._storage.config[this.id]}_updateConfiguration(e){let r=this._storage.config[this.id]||{...Sb};this._storage.setConfiguration({[this.id]:{...r,...e}})}};ct.VERSION=Ab});var pP=L(()=>{globalThis.probe={}});var Eb,zn=L(()=>{Cb();Cb();pP();Eb=new ct({id:"@probe.gl/log"})});function Zl(){let t;if(typeof window<"u"&&window.performance)t=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var Gb=L(()=>{});var $i,$b=L(()=>{Gb();$i=class{constructor(e,r){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=r,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=Zl(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(Zl()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}}});var Et,MP=L(()=>{$b();Et=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,r="count"){return this._getOrCreate({name:e,type:r})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let r of Object.values(this.stats))e(r)}getTable(){let e={};return this.forEach(r=>{e[r.name]={time:r.time||0,count:r.count||0,average:r.getAverageTime()||0,hz:r.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(r=>this._getOrCreate(r))}_getOrCreate(e){let{name:r,type:o}=e,n=this.stats[r];return n||(e instanceof $i?n=e:n=new $i(r,o),this.stats[r]=n),n}}});var Xi=L(()=>{MP();$b();Gb()});function iX(t,e){let r=t.stats,o=!1;for(let c of e)r[c]||(t.get(c),o=!0);let n=Object.keys(r).length,i=s2.get(t);if(!o&&i?.orderedStatNames===e&&i.statCount===n)return;let s={},a=a2.get(e);a||(a=new Set(e),a2.set(e,a));for(let c of e)r[c]&&(s[c]=r[c]);for(let[c,l]of Object.entries(r))a.has(c)||(s[c]=l);for(let c of Object.keys(r))delete r[c];Object.assign(r,s),s2.set(t,{orderedStatNames:e,statCount:n})}var oX,nX,s2,a2,yT,Sm,xT=L(()=>{Xi();oX="GPU Time and Memory",nX=["Adapter","GPU","GPU Type","GPU Backend","Frame Rate","CPU Time","GPU Time","GPU Memory","Buffer Memory","Texture Memory","Referenced Buffer Memory","Referenced Texture Memory","Swap Chain Texture"],s2=new WeakMap,a2=new WeakMap,yT=class{stats=new Map;getStats(e){return this.get(e)}get(e){this.stats.has(e)||this.stats.set(e,new Et({id:e}));let r=this.stats.get(e);return e===oX&&iX(r,nX),r}},Sm=new yT});var P,Er=L(()=>{zn();P=new ct({id:"luma.gl"})});function vo(t="id"){bT[t]=bT[t]||1;let e=bT[t]++;return`${t}-${e}`}var bT,Fa=L(()=>{bT={}});function uX(t,e){let r={...e};for(let o in t)t[o]!==void 0&&(r[o]=t[o]);return r}function h2(t,e){let r=t.stats,o=!1;for(let c of e)r[c]||(t.get(c),o=!0);let n=Object.keys(r).length,i=u2.get(t);if(!o&&i?.orderedStatNames===e&&i.statCount===n)return;let s={},a=d2.get(e);a||(a=new Set(e),d2.set(e,a));for(let c of e)r[c]&&(s[c]=r[c]);for(let[c,l]of Object.entries(r))a.has(c)||(s[c]=l);for(let c of Object.keys(r))delete r[c];Object.assign(r,s),u2.set(t,{orderedStatNames:e,statCount:n})}function p2(t){return t.type==="webgl"?fX:lX}function Tf(t){let e=t.userData[sX];return e?.enabled?e:null}function ti(){return globalThis.performance?.now?.()??Date.now()}function dX(t,e){let r=Tf(t);if(!(!r||!r.activeDefaultFramebufferAcquireDepth))switch(r.transientCanvasResourceCreates=(r.transientCanvasResourceCreates||0)+1,e){case"Texture":r.transientCanvasTextureCreates=(r.transientCanvasTextureCreates||0)+1;break;case"TextureView":r.transientCanvasTextureViewCreates=(r.transientCanvasTextureViewCreates||0)+1;break;case"Sampler":r.transientCanvasSamplerCreates=(r.transientCanvasSamplerCreates||0)+1;break;case"Framebuffer":r.transientCanvasFramebufferCreates=(r.transientCanvasFramebufferCreates||0)+1;break;default:break}}function hX(t){let e=Object.getPrototypeOf(t);for(;e;){let r=Object.getPrototypeOf(e);if(!r||r===J.prototype)return pX(e)||t[Symbol.toStringTag]||t.constructor.name;e=r}return t[Symbol.toStringTag]||t.constructor.name}function pX(t){let e=Object.getOwnPropertyDescriptor(t,Symbol.toStringTag);return typeof e?.get=="function"?e.get.call(t):typeof e?.value=="string"?e.value:null}var sX,c2,l2,f2,aX,cX,lX,fX,u2,d2,J,xt=L(()=>{Fa();sX="cpu-hotspot-profiler",c2="GPU Resource Counts",l2="Resource Counts",f2="GPU Time and Memory",aX=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","ComputePasss","CommandEncoders","CommandBuffers"],cX=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","SharedRenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","ComputePasss","CommandEncoders","CommandBuffers"],lX=aX.flatMap(t=>[`${t} Created`,`${t} Active`]),fX=cX.flatMap(t=>[`${t} Created`,`${t} Active`]),u2=new WeakMap,d2=new WeakMap,J=class{toString(){return`${this[Symbol.toStringTag]||this.constructor.name}:"${this.id}"`}id;props;userData={};_device;destroyed=!1;allocatedBytes=0;allocatedBytesName=null;_attachedResources=new Set;constructor(e,r,o){if(!e)throw new Error("no device");this._device=e,this.props=uX(r,o);let n=this.props.id!=="undefined"?this.props.id:vo(this[Symbol.toStringTag]);this.props.id=n,this.id=n,this.userData=this.props.userData||{},this.addStats()}destroy(){this.destroyed||this.destroyResource()}delete(){return this.destroy(),this}getProps(){return this.props}attachResource(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(let e of this._attachedResources)e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyed||(this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0)}removeStats(){let e=Tf(this._device),r=e?ti():0,o=[this._device.statsManager.getStats(c2),this._device.statsManager.getStats(l2)],n=p2(this._device);for(let s of o)h2(s,n);let i=this.getStatsName();for(let s of o)s.get("Resources Active").decrementCount(),s.get(`${i}s Active`).decrementCount();e&&(e.statsBookkeepingCalls=(e.statsBookkeepingCalls||0)+1,e.statsBookkeepingTimeMs=(e.statsBookkeepingTimeMs||0)+(ti()-r))}trackAllocatedMemory(e,r=this.getStatsName()){let o=Tf(this._device),n=o?ti():0,i=this._device.statsManager.getStats(f2);this.allocatedBytes>0&&this.allocatedBytesName&&(i.get("GPU Memory").subtractCount(this.allocatedBytes),i.get(`${this.allocatedBytesName} Memory`).subtractCount(this.allocatedBytes)),i.get("GPU Memory").addCount(e),i.get(`${r} Memory`).addCount(e),o&&(o.statsBookkeepingCalls=(o.statsBookkeepingCalls||0)+1,o.statsBookkeepingTimeMs=(o.statsBookkeepingTimeMs||0)+(ti()-n)),this.allocatedBytes=e,this.allocatedBytesName=r}trackReferencedMemory(e,r=this.getStatsName()){this.trackAllocatedMemory(e,`Referenced ${r}`)}trackDeallocatedMemory(e=this.getStatsName()){if(this.allocatedBytes===0){this.allocatedBytesName=null;return}let r=Tf(this._device),o=r?ti():0,n=this._device.statsManager.getStats(f2);n.get("GPU Memory").subtractCount(this.allocatedBytes),n.get(`${this.allocatedBytesName||e} Memory`).subtractCount(this.allocatedBytes),r&&(r.statsBookkeepingCalls=(r.statsBookkeepingCalls||0)+1,r.statsBookkeepingTimeMs=(r.statsBookkeepingTimeMs||0)+(ti()-o)),this.allocatedBytes=0,this.allocatedBytesName=null}trackDeallocatedReferencedMemory(e=this.getStatsName()){this.trackDeallocatedMemory(`Referenced ${e}`)}addStats(){let e=this.getStatsName(),r=Tf(this._device),o=r?ti():0,n=[this._device.statsManager.getStats(c2),this._device.statsManager.getStats(l2)],i=p2(this._device);for(let s of n)h2(s,i);for(let s of n)s.get("Resources Created").incrementCount(),s.get("Resources Active").incrementCount(),s.get(`${e}s Created`).incrementCount(),s.get(`${e}s Active`).incrementCount();r&&(r.statsBookkeepingCalls=(r.statsBookkeepingCalls||0)+1,r.statsBookkeepingTimeMs=(r.statsBookkeepingTimeMs||0)+(ti()-o)),dX(this._device,e)}getStatsName(){return hX(this)}};k(J,"defaultProps",{id:"undefined",handle:void 0,userData:void 0})});var vf,K,Cm=L(()=>{xt();vf=class extends J{get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(e,r){let o={...r};(r.usage||0)&vf.INDEX&&!r.indexType&&(r.data instanceof Uint32Array?o.indexType="uint32":r.data instanceof Uint16Array?o.indexType="uint16":r.data instanceof Uint8Array&&(o.indexType="uint8")),delete o.data,super(e,o,vf.defaultProps),this.usage=o.usage||0,this.indexType=o.indexType,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createBuffer({...this.props,...e})}debugData=new ArrayBuffer(0);_setDebugData(e,r,o){let n=null,i;ArrayBuffer.isView(e)?(n=e,i=e.buffer):i=e;let s=Math.min(e?e.byteLength:o,vf.DEBUG_DATA_MAX_LENGTH);if(i===null)this.debugData=new ArrayBuffer(s);else{let a=Math.min(n?.byteOffset||0,i.byteLength),c=Math.max(0,i.byteLength-a),l=Math.min(s,c);this.debugData=new Uint8Array(i,a,l).slice().buffer}}},K=vf;k(K,"INDEX",16),k(K,"VERTEX",32),k(K,"UNIFORM",64),k(K,"STORAGE",128),k(K,"INDIRECT",256),k(K,"QUERY_RESOLVE",512),k(K,"MAP_READ",1),k(K,"MAP_WRITE",2),k(K,"COPY_SRC",4),k(K,"COPY_DST",8),k(K,"DEBUG_DATA_MAX_LENGTH",32),k(K,"defaultProps",{...J.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",onMapped:void 0})});var TT,Dt,AT,Em=L(()=>{TT=class{getDataTypeInfo(e){let[r,o,n]=AT[e],i=e.includes("norm"),s=!i&&!e.startsWith("float"),a=e.startsWith("s");return{signedType:r,primitiveType:o,byteLength:n,normalized:i,integer:s,signed:a}}getNormalizedDataType(e){let r=e;switch(r){case"uint8":return"unorm8";case"sint8":return"snorm8";case"uint16":return"unorm16";case"sint16":return"snorm16";default:return r}}alignTo(e,r){switch(r){case 1:return e;case 2:return e+e%2;default:return e+(4-e%4)%4}}getDataType(e){let r=ArrayBuffer.isView(e)?e.constructor:e;if(r===Uint8ClampedArray)return"uint8";let o=Object.values(AT).find(n=>r===n[4]);if(!o)throw new Error(r.name);return o[0]}getTypedArrayConstructor(e){let[,,,,r]=AT[e];return r}},Dt=new TT,AT={uint8:["uint8","u32",1,!1,Uint8Array],sint8:["sint8","i32",1,!1,Int8Array],unorm8:["uint8","f32",1,!0,Uint8Array],snorm8:["sint8","f32",1,!0,Int8Array],uint16:["uint16","u32",2,!1,Uint16Array],sint16:["sint16","i32",2,!1,Int16Array],unorm16:["uint16","u32",2,!0,Uint16Array],snorm16:["sint16","i32",2,!0,Int16Array],float16:["float16","f16",2,!1,Uint16Array],float32:["float32","f32",4,!1,Float32Array],uint32:["uint32","u32",4,!1,Uint32Array],sint32:["sint32","i32",4,!1,Int32Array]}});var vT,tn,wm=L(()=>{Em();vT=class{getVertexFormatInfo(e){let r;e.endsWith("-webgl")&&(e.replace("-webgl",""),r=!0);let[o,n]=e.split("x"),i=o,s=n?parseInt(n):1,a=Dt.getDataTypeInfo(i),c={type:i,components:s,byteLength:a.byteLength*s,integer:a.integer,signed:a.signed,normalized:a.normalized};return r&&(c.webglOnly=!0),c}makeVertexFormat(e,r,o){let n=o?Dt.getNormalizedDataType(e):e;switch(n){case"unorm8":return r===1?"unorm8":r===3?"unorm8x3-webgl":`${n}x${r}`;case"snorm8":return r===1?"snorm8":r===3?"snorm8x3-webgl":`${n}x${r}`;case"uint8":case"sint8":if(r===1||r===3)throw new Error(`size: ${r}`);return`${n}x${r}`;case"uint16":return r===1?"uint16":r===3?"uint16x3-webgl":`${n}x${r}`;case"sint16":return r===1?"sint16":r===3?"sint16x3-webgl":`${n}x${r}`;case"unorm16":return r===1?"unorm16":r===3?"unorm16x3-webgl":`${n}x${r}`;case"snorm16":return r===1?"snorm16":r===3?"snorm16x3-webgl":`${n}x${r}`;case"float16":if(r===1||r===3)throw new Error(`size: ${r}`);return`${n}x${r}`;default:return r===1?n:`${n}x${r}`}}getVertexFormatFromAttribute(e,r,o){if(!r||r>4)throw new Error(`size ${r}`);let n=r,i=Dt.getDataType(e);return this.makeVertexFormat(i,n,o)}getCompatibleVertexFormat(e){let r;switch(e.primitiveType){case"f32":r="float32";break;case"i32":r="sint32";break;case"u32":r="uint32";break;case"f16":return e.components<=2?"float16x2":"float16x4"}return e.components===1?r:`${r}x${e.components}`}},tn=new vT});function MT(t){let e=_2[t];if(!e)throw new Error(`Unsupported texture format ${t}`);return e}function g2(){return _2}var wt,we,So,mX,Pm,ST,Mm,CT,gX,ET,ri,wT,PT,Rm,m2,_X,yX,_2,RT=L(()=>{wt="texture-compression-bc",we="texture-compression-astc",So="texture-compression-etc2",mX="texture-compression-etc1-webgl",Pm="texture-compression-pvrtc-webgl",ST="texture-compression-atc-webgl",Mm="float32-renderable-webgl",CT="float16-renderable-webgl",gX="rgb9e5ufloat-renderable-webgl",ET="snorm8-renderable-webgl",ri="norm16-webgl",wT="norm16-renderable-webgl",PT="snorm16-renderable-webgl",Rm="float32-filterable",m2="float16-filterable-webgl";_X={r8unorm:{},rg8unorm:{},"rgb8unorm-webgl":{},rgba8unorm:{},"rgba8unorm-srgb":{},r8snorm:{render:ET},rg8snorm:{render:ET},"rgb8snorm-webgl":{},rgba8snorm:{render:ET},r8uint:{},rg8uint:{},rgba8uint:{},r8sint:{},rg8sint:{},rgba8sint:{},bgra8unorm:{},"bgra8unorm-srgb":{},r16unorm:{f:ri,render:wT},rg16unorm:{f:ri,render:wT},"rgb16unorm-webgl":{f:ri,render:!1},rgba16unorm:{f:ri,render:wT},r16snorm:{f:ri,render:PT},rg16snorm:{f:ri,render:PT},"rgb16snorm-webgl":{f:ri,render:!1},rgba16snorm:{f:ri,render:PT},r16uint:{},rg16uint:{},rgba16uint:{},r16sint:{},rg16sint:{},rgba16sint:{},r16float:{render:CT,filter:"float16-filterable-webgl"},rg16float:{render:CT,filter:m2},rgba16float:{render:CT,filter:m2},r32uint:{},rg32uint:{},rgba32uint:{},r32sint:{},rg32sint:{},rgba32sint:{},r32float:{render:Mm,filter:Rm},rg32float:{render:!1,filter:Rm},"rgb32float-webgl":{render:Mm,filter:Rm},rgba32float:{render:Mm,filter:Rm},"rgba4unorm-webgl":{channels:"rgba",bitsPerChannel:[4,4,4,4],packed:!0},"rgb565unorm-webgl":{channels:"rgb",bitsPerChannel:[5,6,5,0],packed:!0},"rgb5a1unorm-webgl":{channels:"rgba",bitsPerChannel:[5,5,5,1],packed:!0},rgb9e5ufloat:{channels:"rgb",packed:!0,render:gX},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:Mm},rgb10a2unorm:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1},rgb10a2uint:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1},stencil8:{attachment:"stencil",bitsPerChannel:[8,0,0,0],dataType:"uint8"},depth16unorm:{attachment:"depth",bitsPerChannel:[16,0,0,0],dataType:"uint16"},depth24plus:{attachment:"depth",bitsPerChannel:[24,0,0,0],dataType:"uint32"},depth32float:{attachment:"depth",bitsPerChannel:[32,0,0,0],dataType:"float32"},"depth24plus-stencil8":{attachment:"depth-stencil",bitsPerChannel:[24,8,0,0],packed:!0},"depth32float-stencil8":{attachment:"depth-stencil",bitsPerChannel:[32,8,0,0],packed:!0}},yX={"bc1-rgb-unorm-webgl":{f:wt},"bc1-rgb-unorm-srgb-webgl":{f:wt},"bc1-rgba-unorm":{f:wt},"bc1-rgba-unorm-srgb":{f:wt},"bc2-rgba-unorm":{f:wt},"bc2-rgba-unorm-srgb":{f:wt},"bc3-rgba-unorm":{f:wt},"bc3-rgba-unorm-srgb":{f:wt},"bc4-r-unorm":{f:wt},"bc4-r-snorm":{f:wt},"bc5-rg-unorm":{f:wt},"bc5-rg-snorm":{f:wt},"bc6h-rgb-ufloat":{f:wt},"bc6h-rgb-float":{f:wt},"bc7-rgba-unorm":{f:wt},"bc7-rgba-unorm-srgb":{f:wt},"etc2-rgb8unorm":{f:So},"etc2-rgb8unorm-srgb":{f:So},"etc2-rgb8a1unorm":{f:So},"etc2-rgb8a1unorm-srgb":{f:So},"etc2-rgba8unorm":{f:So},"etc2-rgba8unorm-srgb":{f:So},"eac-r11unorm":{f:So},"eac-r11snorm":{f:So},"eac-rg11unorm":{f:So},"eac-rg11snorm":{f:So},"astc-4x4-unorm":{f:we},"astc-4x4-unorm-srgb":{f:we},"astc-5x4-unorm":{f:we},"astc-5x4-unorm-srgb":{f:we},"astc-5x5-unorm":{f:we},"astc-5x5-unorm-srgb":{f:we},"astc-6x5-unorm":{f:we},"astc-6x5-unorm-srgb":{f:we},"astc-6x6-unorm":{f:we},"astc-6x6-unorm-srgb":{f:we},"astc-8x5-unorm":{f:we},"astc-8x5-unorm-srgb":{f:we},"astc-8x6-unorm":{f:we},"astc-8x6-unorm-srgb":{f:we},"astc-8x8-unorm":{f:we},"astc-8x8-unorm-srgb":{f:we},"astc-10x5-unorm":{f:we},"astc-10x5-unorm-srgb":{f:we},"astc-10x6-unorm":{f:we},"astc-10x6-unorm-srgb":{f:we},"astc-10x8-unorm":{f:we},"astc-10x8-unorm-srgb":{f:we},"astc-10x10-unorm":{f:we},"astc-10x10-unorm-srgb":{f:we},"astc-12x10-unorm":{f:we},"astc-12x10-unorm-srgb":{f:we},"astc-12x12-unorm":{f:we},"astc-12x12-unorm-srgb":{f:we},"pvrtc-rgb4unorm-webgl":{f:Pm},"pvrtc-rgba4unorm-webgl":{f:Pm},"pvrtc-rgb2unorm-webgl":{f:Pm},"pvrtc-rgba2unorm-webgl":{f:Pm},"etc1-rbg-unorm-webgl":{f:mX},"atc-rgb-unorm-webgl":{f:ST},"atc-rgba-unorm-webgl":{f:ST},"atc-rgbai-unorm-webgl":{f:ST}},_2={..._X,...yX}});function vX({format:t,width:e,height:r,depth:o,byteAlignment:n}){let i=bt.getInfo(t),{bytesPerPixel:s,bytesPerBlock:a=s,blockWidth:c=1,blockHeight:l=1,compressed:f=!1}=i,u=f?Math.ceil(e/c):e,d=f?Math.ceil(r/l):r,h=u*a,p=Math.ceil(h/n)*n,m=d,g=p*m*o;return{bytesPerPixel:s,bytesPerRow:p,rowsPerImage:m,depthOrArrayLayers:o,bytesPerImage:p*m,byteLength:g}}function SX(t){let e=MT(t),r={format:t,create:e.f??!0,render:e.render??!0,filter:e.filter??!0,blend:e.blend??!0,store:e.store??!0},o=y2(t),n=t.startsWith("depth")||t.startsWith("stencil"),i=o?.signed,s=o?.integer,a=o?.webgl,c=Boolean(o?.compressed);return r.render&&=!n&&!c,r.filter&&=!n&&!i&&!s&&!a,r}function y2(t){let e=CX(t);if(bt.isCompressed(t)){e.channels="rgb",e.components=3,e.bytesPerPixel=1,e.srgb=!1,e.compressed=!0,e.bytesPerBlock=wX(t);let o=EX(t);o&&(e.blockWidth=o.blockWidth,e.blockHeight=o.blockHeight)}let r=e.packed?null:xX.exec(t);if(r){let[,o,n,i,s,a]=r,c=`${i}${n}`,l=Dt.getDataTypeInfo(c),f=l.byteLength*8,u=o?.length??1,d=[f,u>=2?f:0,u>=3?f:0,u>=4?f:0];e={format:t,attachment:e.attachment,dataType:l.signedType,components:u,channels:o,integer:l.integer,signed:l.signed,normalized:l.normalized,bitsPerChannel:d,bytesPerPixel:l.byteLength*u,packed:e.packed,srgb:e.srgb},a==="-webgl"&&(e.webgl=!0),s==="-srgb"&&(e.srgb=!0)}return t.endsWith("-webgl")&&(e.webgl=!0),t.endsWith("-srgb")&&(e.srgb=!0),e}function CX(t){let e=MT(t),r=e.bytesPerPixel||1,o=e.bitsPerChannel||[8,8,8,8];return delete e.bitsPerChannel,delete e.bytesPerPixel,delete e.f,delete e.render,delete e.filter,delete e.blend,delete e.store,{...e,format:t,attachment:e.attachment||"color",channels:e.channels||"r",components:e.components||e.channels?.length||1,bytesPerPixel:r,bitsPerChannel:o,dataType:e.dataType||"uint8",srgb:e.srgb??!1,packed:e.packed??!1,webgl:e.webgl??!1,integer:e.integer??!1,signed:e.signed??!1,normalized:e.normalized??!1,compressed:e.compressed??!1}}function EX(t){let r=/.*-(\d+)x(\d+)-.*/.exec(t);if(r){let[,o,n]=r;return{blockWidth:Number(o),blockHeight:Number(n)}}return t.startsWith("bc")||t.startsWith("etc1")||t.startsWith("etc2")||t.startsWith("eac")||t.startsWith("atc")?{blockWidth:4,blockHeight:4}:t.startsWith("pvrtc-rgb4")||t.startsWith("pvrtc-rgba4")?{blockWidth:4,blockHeight:4}:t.startsWith("pvrtc-rgb2")||t.startsWith("pvrtc-rgba2")?{blockWidth:8,blockHeight:4}:null}function wX(t){return t.startsWith("bc1")||t.startsWith("bc4")||t.startsWith("etc1")||t.startsWith("etc2-rgb8")||t.startsWith("etc2-rgb8a1")||t.startsWith("eac-r11")||t==="atc-rgb-unorm-webgl"?8:t.startsWith("bc2")||t.startsWith("bc3")||t.startsWith("bc5")||t.startsWith("bc6h")||t.startsWith("bc7")||t.startsWith("etc2-rgba8")||t.startsWith("eac-rg11")||t.startsWith("astc")||t==="atc-rgba-unorm-webgl"||t==="atc-rgbai-unorm-webgl"?16:t.startsWith("pvrtc")?8:16}var xX,bX,AX,TX,IT,bt,Im=L(()=>{Em();RT();xX=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/,bX=["rgb","rgba","bgra"],AX=["depth","stencil"],TX=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],IT=class{isColor(e){return bX.some(r=>e.startsWith(r))}isDepthStencil(e){return AX.some(r=>e.startsWith(r))}isCompressed(e){return TX.some(r=>e.startsWith(r))}getInfo(e){return y2(e)}getCapabilities(e){return SX(e)}computeMemoryLayout(e){return vX(e)}},bt=new IT});function Na(t){return typeof ImageData<"u"&&t instanceof ImageData||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement||typeof VideoFrame<"u"&&t instanceof VideoFrame||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas}function Sf(t){if(typeof ImageData<"u"&&t instanceof ImageData||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas)return{width:t.width,height:t.height};if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement)return{width:t.naturalWidth,height:t.naturalHeight};if(typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement)return{width:t.videoWidth,height:t.videoHeight};if(typeof VideoFrame<"u"&&t instanceof VideoFrame)return{width:t.displayWidth,height:t.displayHeight};throw new Error("Unknown image type")}var LT=L(()=>{});function PX(t,e){let r=BT(t),o=e.map(BT).filter(n=>n!==void 0);return[r,...o].filter(n=>n!==void 0)}function BT(t){if(t!==void 0){if(t===null||typeof t=="string"||typeof t=="number"||typeof t=="boolean")return t;if(t instanceof Error)return t.message;if(Array.isArray(t))return t.map(BT);if(typeof t=="object"){if(MX(t)){let e=String(t);if(e!=="[object Object]")return e}return RX(t)?IX(t):t.constructor?.name||"Object"}return String(t)}}function MX(t){return"toString"in t&&typeof t.toString=="function"&&t.toString!==Object.prototype.toString}function RX(t){return"message"in t&&"type"in t}function IX(t){let e=typeof t.type=="string"?t.type:"message",r=typeof t.message=="string"?t.message:"",o=typeof t.lineNum=="number"?t.lineNum:null,n=typeof t.linePos=="number"?t.linePos:null,i=o!==null&&n!==null?` @ ${o}:${n}`:o!==null?` @ ${o}`:"";return`${e}${i}: ${r}`.trim()}function LX(t,e){return t!=null?Boolean(t):e!==void 0?e!=="production":!1}function BX(){return LX(P.get("debug"),OX())}function OX(){let t=globalThis.process;if(t?.env)return t.env.NODE_ENV}var Cf,Ef,OT,Xt,FT=L(()=>{xT();Er();Fa();Cm();wm();Im();LT();RT();Cf=class{};Ef=class{features;disabledFeatures;constructor(e=[],r){this.features=new Set(e),this.disabledFeatures=r||{}}*[Symbol.iterator](){yield*this.features}has(e){return!this.disabledFeatures?.[e]&&this.features.has(e)}},OT=class{get[Symbol.toStringTag](){return"Device"}toString(){return`Device(${this.id})`}id;props;userData={};statsManager=Sm;_factories={};timestamp=0;_reused=!1;_moduleData={};_textureCaps={};_debugGPUTimeQuery=null;constructor(e){this.props={...OT.defaultProps,...e},this.id=this.props.id||vo(this[Symbol.toStringTag].toLowerCase())}getVertexFormatInfo(e){return tn.getVertexFormatInfo(e)}isVertexFormatSupported(e){return!0}getTextureFormatInfo(e){return bt.getInfo(e)}getTextureFormatCapabilities(e){let r=this._textureCaps[e];if(!r){let o=this._getDeviceTextureFormatCapabilities(e);r=this._getDeviceSpecificTextureFormatCapabilities(o),this._textureCaps[e]=r}return r}getMipLevelCount(e,r,o=1){let n=Math.max(e,r,o);return 1+Math.floor(Math.log2(n))}isExternalImage(e){return Na(e)}getExternalImageSize(e){return Sf(e)}isTextureFormatSupported(e){return this.getTextureFormatCapabilities(e).create}isTextureFormatFilterable(e){return this.getTextureFormatCapabilities(e).filter}isTextureFormatRenderable(e){return this.getTextureFormatCapabilities(e).render}isTextureFormatCompressed(e){return bt.isCompressed(e)}getSupportedCompressedTextureFormats(){let e=[];for(let r of Object.keys(g2()))this.isTextureFormatCompressed(r)&&this.isTextureFormatSupported(r)&&e.push(r);return e}pushDebugGroup(e){this.commandEncoder.pushDebugGroup(e)}popDebugGroup(){this.commandEncoder?.popDebugGroup()}insertDebugMarker(e){this.commandEncoder?.insertDebugMarker(e)}loseDevice(){return!1}incrementTimestamp(){return this.timestamp++}reportError(e,r,...o){if(!this.props.onError(e,r)){let i=PX(r,o);return P.error(this.type==="webgl"?"%cWebGL":"%cWebGPU","color: white; background: red; padding: 2px 6px; border-radius: 3px;",e.message,...i)}return()=>{}}debug(){if(this.props.debug)debugger;else{let e=`'Type luma.log.set({debug: true}) in console to enable debug breakpoints', or create a device with the 'debug: true' prop.`;P.once(0,e)()}}getDefaultCanvasContext(){if(!this.canvasContext)throw new Error("Device has no default CanvasContext. See props.createCanvasContext");return this.canvasContext}createFence(){throw new Error("createFence() not implemented")}beginRenderPass(e){return this.commandEncoder.beginRenderPass(e)}beginComputePass(e){return this.commandEncoder.beginComputePass(e)}generateMipmapsWebGPU(e){throw new Error("not implemented")}_createSharedRenderPipelineWebGL(e){throw new Error("_createSharedRenderPipelineWebGL() not implemented")}_createBindGroupLayoutWebGPU(e,r){throw new Error("_createBindGroupLayoutWebGPU() not implemented")}_createBindGroupWebGPU(e,r,o,n,i){throw new Error("_createBindGroupWebGPU() not implemented")}_supportsDebugGPUTime(){return this.features.has("timestamp-query")&&Boolean(this.props.debug||this.props.debugGPUTime)}_enableDebugGPUTime(e=256){if(!this._supportsDebugGPUTime())return null;if(this._debugGPUTimeQuery)return this._debugGPUTimeQuery;try{this._debugGPUTimeQuery=this.createQuerySet({type:"timestamp",count:e}),this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id,timeProfilingQuerySet:this._debugGPUTimeQuery})}catch{this._debugGPUTimeQuery=null}return this._debugGPUTimeQuery}_disableDebugGPUTime(){this._debugGPUTimeQuery&&(this.commandEncoder.getTimeProfilingQuerySet()===this._debugGPUTimeQuery&&(this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id})),this._debugGPUTimeQuery.destroy(),this._debugGPUTimeQuery=null)}_isDebugGPUTimeEnabled(){return this._debugGPUTimeQuery!==null}getCanvasContext(){return this.getDefaultCanvasContext()}readPixelsToArrayWebGL(e,r){throw new Error("not implemented")}readPixelsToBufferWebGL(e,r){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,r){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}getModuleData(e){return this._moduleData[e]||={},this._moduleData[e]}static _getCanvasContextProps(e){return e.createCanvasContext===!0?{}:e.createCanvasContext}_getDeviceTextureFormatCapabilities(e){let r=bt.getCapabilities(e),o=i=>(typeof i=="string"?this.features.has(i):i)??!0,n=o(r.create);return{format:e,create:n,render:n&&o(r.render),filter:n&&o(r.filter),blend:n&&o(r.blend),store:n&&o(r.store)}}_normalizeBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});let r={...e};if((e.usage||0)&K.INDEX&&(e.indexType||(e.data instanceof Uint32Array?r.indexType="uint32":e.data instanceof Uint16Array?r.indexType="uint16":e.data instanceof Uint8Array&&(r.data=new Uint16Array(e.data),r.indexType="uint16")),!r.indexType))throw new Error("indices buffer content must be of type uint16 or uint32");return r}},Xt=OT;k(Xt,"defaultProps",{id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,createCanvasContext:void 0,webgl:{},onError:(e,r)=>{},onResize:(e,r)=>{let[o,n]=e.getDevicePixelSize();P.log(1,`${e} resized => ${o}x${n}px`)()},onPositionChange:(e,r)=>{let[o,n]=e.getPosition();P.log(1,`${e} repositioned => ${o},${n}`)()},onVisibilityChange:e=>P.log(1,`${e} Visibility changed ${e.isVisible}`)(),onDevicePixelRatioChange:(e,r)=>P.log(1,`${e} DPR changed ${r.oldRatio} => ${e.devicePixelRatio}`)(),debug:BX(),debugGPUTime:!1,debugShaders:P.get("debug-shaders")||void 0,debugFramebuffers:Boolean(P.get("debug-framebuffers")),debugFactories:Boolean(P.get("debug-factories")),debugWebGL:Boolean(P.get("debug-webgl")),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_reuseDevices:!1,_requestMaxLimits:!0,_cacheShaders:!0,_destroyShaders:!1,_cachePipelines:!0,_sharePipelines:!0,_destroyPipelines:!1,_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_handle:void 0})});var FX,x2,Bm,Lm,Co,b2=L(()=>{FT();xT();Er();FX="set luma.log.level=1 (or higher) to trace rendering",x2="No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.",Bm=class{stats=Sm;log=P;VERSION="9.3.3";spector;preregisteredAdapters=new Map;constructor(){if(globalThis.luma){if(globalThis.luma.VERSION!==this.VERSION)throw P.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)(),P.error("'yarn why @luma.gl/core' can help identify the source of the conflict")(),new Error("luma.gl - multiple versions detected: see console log");P.error("This version of luma.gl has already been initialized")()}P.log(1,`${this.VERSION} - ${FX}`)(),globalThis.luma=this}async createDevice(e={}){let r={...Bm.defaultProps,...e},o=this.selectAdapter(r.type,r.adapters);if(!o)throw new Error(x2);return r.waitForPageLoad&&await o.pageLoaded,await o.create(r)}async attachDevice(e,r){let o=this._getTypeFromHandle(e,r.adapters),n=o&&this.selectAdapter(o,r.adapters);if(!n)throw new Error(x2);return await n?.attach?.(e,r)}registerAdapters(e){for(let r of e)this.preregisteredAdapters.set(r.type,r)}getSupportedAdapters(e=[]){let r=this._getAdapterMap(e);return Array.from(r).map(([,o])=>o).filter(o=>o.isSupported?.()).map(o=>o.type)}getBestAvailableAdapterType(e=[]){let r=["webgpu","webgl","null"],o=this._getAdapterMap(e);for(let n of r)if(o.get(n)?.isSupported?.())return n;return null}selectAdapter(e,r=[]){let o=e;e==="best-available"&&(o=this.getBestAvailableAdapterType(r));let n=this._getAdapterMap(r);return o&&n.get(o)||null}enforceWebGL2(e=!0,r=[]){let n=this._getAdapterMap(r).get("webgl");n||P.warn("enforceWebGL2: webgl adapter not found")(),n?.enforceWebGL2?.(e)}setDefaultDeviceProps(e){Object.assign(Bm.defaultProps,e)}_getAdapterMap(e=[]){let r=new Map(this.preregisteredAdapters);for(let o of e)r.set(o.type,o);return r}_getTypeFromHandle(e,r=[]){return e instanceof WebGL2RenderingContext?"webgl":typeof GPUDevice<"u"&&e instanceof GPUDevice||e?.queue?"webgpu":e===null?"null":(e instanceof WebGLRenderingContext?P.warn("WebGL1 is not supported",e)():P.warn("Unknown handle type",e)(),null)}},Lm=Bm;k(Lm,"defaultProps",{...Xt.defaultProps,type:"best-available",adapters:void 0,waitForPageLoad:!0});Co=new Lm});function UX(){return Om||(DX()||typeof window>"u"?Om=Promise.resolve():Om=new Promise(t=>window.addEventListener("load",()=>t()))),Om}var wf,NX,DX,Om,A2=L(()=>{Vn();wf=class{get pageLoaded(){return UX()}},NX=Ot()&&typeof document<"u",DX=()=>NX&&document.readyState==="complete",Om=null});var Fm,T2=L(()=>{Fm=class{props;_resizeObserver;_intersectionObserver;_observeDevicePixelRatioTimeout=null;_observeDevicePixelRatioMediaQuery=null;_handleDevicePixelRatioChange=()=>this._refreshDevicePixelRatio();_trackPositionInterval=null;_started=!1;get started(){return this._started}constructor(e){this.props=e}start(){if(!(this._started||!this.props.canvas)){this._started=!0,this._intersectionObserver||=new IntersectionObserver(e=>this.props.onIntersection(e)),this._resizeObserver||=new ResizeObserver(e=>this.props.onResize(e)),this._intersectionObserver.observe(this.props.canvas);try{this._resizeObserver.observe(this.props.canvas,{box:"device-pixel-content-box"})}catch{this._resizeObserver.observe(this.props.canvas,{box:"content-box"})}this._observeDevicePixelRatioTimeout=setTimeout(()=>this._refreshDevicePixelRatio(),0),this.props.trackPosition&&this._trackPosition()}}stop(){this._started&&(this._started=!1,this._observeDevicePixelRatioTimeout&&(clearTimeout(this._observeDevicePixelRatioTimeout),this._observeDevicePixelRatioTimeout=null),this._observeDevicePixelRatioMediaQuery&&(this._observeDevicePixelRatioMediaQuery.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=null),this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null),this._resizeObserver?.disconnect(),this._intersectionObserver?.disconnect())}_refreshDevicePixelRatio(){this._started&&(this.props.onDevicePixelRatioChange(),this._observeDevicePixelRatioMediaQuery?.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),this._observeDevicePixelRatioMediaQuery.addEventListener("change",this._handleDevicePixelRatioChange,{once:!0}))}_trackPosition(e=100){this._trackPositionInterval||(this._trackPositionInterval=setInterval(()=>{this._started?this.props.onPositionChange():this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null)},e))}}});function v2(){let t,e;return{promise:new Promise((o,n)=>{t=o,e=n}),resolve:t,reject:e}}var S2=L(()=>{});function NT(t,e){if(!t){let r=new Error(e??"luma.gl assertion failed.");throw Error.captureStackTrace?.(r,NT),r}}function os(t,e){return NT(t,e),t}var DT=L(()=>{});function kX(t){if(typeof t=="string"){let e=document.getElementById(t);if(!e)throw new Error(`${t} is not an HTML element`);return e}return t||document.body}function VX(t){let e=document.getElementById(t);if(!rn.isHTMLCanvas(e))throw new Error("Object is not a canvas element");return e}function zX(t){let{width:e,height:r}=t,o=document.createElement("canvas");o.id=vo("lumagl-auto-created-canvas"),o.width=e||1,o.height=r||1,o.style.width=Number.isFinite(e)?`${e}px`:"100%",o.style.height=Number.isFinite(r)?`${r}px`:"100%",t?.visible||(o.style.visibility="hidden");let n=kX(t?.container||null);return n.insertBefore(o,n.firstChild),o}function HX(t,e,r,o,n){let i=t,s=C2(i[0],e,r),a=E2(i[1],e,o,n),c=C2(i[0]+1,e,r),l=c===r-1?c:c-1;c=E2(i[1]+1,e,o,n);let f;return n?(c=c===0?c:c+1,f=a,a=c):f=c===o-1?c:c-1,{x:s,y:a,width:Math.max(l-s+1,1),height:Math.max(f-a+1,1)}}function C2(t,e,r){return Math.min(Math.round(t*e),r-1)}function E2(t,e,r,o){return o?Math.max(0,r-1-Math.round(t*e)):Math.min(Math.round(t*e),r-1)}var Pf,rn,UT=L(()=>{Vn();T2();Fa();S2();DT();Pf=class{static isHTMLCanvas(e){return typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement}static isOffscreenCanvas(e){return typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas}id;props;canvas;htmlCanvas;offscreenCanvas;type;initialized;isInitialized=!1;isVisible=!0;cssWidth;cssHeight;devicePixelRatio;devicePixelWidth;devicePixelHeight;drawingBufferWidth;drawingBufferHeight;_initializedResolvers=v2();_canvasObserver;_position=[0,0];destroyed=!1;_needsDrawingBufferResize=!0;toString(){return`${this[Symbol.toStringTag]}(${this.id})`}constructor(e){this.props={...Pf.defaultProps,...e},e=this.props,this.initialized=this._initializedResolvers.promise,Ot()?e.canvas?typeof e.canvas=="string"?this.canvas=VX(e.canvas):this.canvas=e.canvas:this.canvas=zX(e):this.canvas={width:e.width||1,height:e.height||1},Pf.isHTMLCanvas(this.canvas)?(this.id=e.id||this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):Pf.isOffscreenCanvas(this.canvas)?(this.id=e.id||"offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas):(this.id=e.id||"node-canvas-context",this.type="node"),this.cssWidth=this.htmlCanvas?.clientWidth||this.canvas.width,this.cssHeight=this.htmlCanvas?.clientHeight||this.canvas.height,this.devicePixelWidth=this.canvas.width,this.devicePixelHeight=this.canvas.height,this.drawingBufferWidth=this.canvas.width,this.drawingBufferHeight=this.canvas.height,this.devicePixelRatio=globalThis.devicePixelRatio||1,this._position=[0,0],this._canvasObserver=new Fm({canvas:this.htmlCanvas,trackPosition:this.props.trackPosition,onResize:r=>this._handleResize(r),onIntersection:r=>this._handleIntersection(r),onDevicePixelRatioChange:()=>this._observeDevicePixelRatio(),onPositionChange:()=>this.updatePosition()})}destroy(){this.destroyed||(this.destroyed=!0,this._stopObservers(),this.device=null)}setProps(e){return"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1,this._updateDrawingBufferSize()),this}getCurrentFramebuffer(e){return this._resizeDrawingBufferIfNeeded(),this._getCurrentFramebuffer(e)}getCSSSize(){return[this.cssWidth,this.cssHeight]}getPosition(){return this._position}getDevicePixelSize(){return[this.devicePixelWidth,this.devicePixelHeight]}getDrawingBufferSize(){return[this.drawingBufferWidth,this.drawingBufferHeight]}getMaxDrawingBufferSize(){let e=this.device.limits.maxTextureDimension2D;return[e,e]}setDrawingBufferSize(e,r){e=Math.floor(e),r=Math.floor(r),!(this.drawingBufferWidth===e&&this.drawingBufferHeight===r)&&(this.drawingBufferWidth=e,this.drawingBufferHeight=r,this._needsDrawingBufferResize=!0)}getDevicePixelRatio(){return typeof window<"u"&&window.devicePixelRatio||1}cssToDevicePixels(e,r=!0){let o=this.cssToDeviceRatio(),[n,i]=this.getDrawingBufferSize();return HX(e,o,n,i,r)}getPixelSize(){return this.getDevicePixelSize()}getAspect(){let[e,r]=this.getDrawingBufferSize();return e>0&&r>0?e/r:1}cssToDeviceRatio(){try{let[e]=this.getDrawingBufferSize(),[r]=this.getCSSSize();return r?e/r:1}catch{return 1}}resize(e){this.setDrawingBufferSize(e.width,e.height)}_setAutoCreatedCanvasId(e){this.htmlCanvas?.id==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=e)}_startObservers(){this.destroyed||this._canvasObserver.start()}_stopObservers(){this._canvasObserver.stop()}_handleIntersection(e){if(this.destroyed)return;let r=e.find(n=>n.target===this.canvas);if(!r)return;let o=r.isIntersecting;this.isVisible!==o&&(this.isVisible=o,this.device.props.onVisibilityChange(this))}_handleResize(e){if(this.destroyed)return;let r=e.find(l=>l.target===this.canvas);if(!r)return;let o=os(r.contentBoxSize?.[0]);this.cssWidth=o.inlineSize,this.cssHeight=o.blockSize;let n=this.getDevicePixelSize(),i=r.devicePixelContentBoxSize?.[0]?.inlineSize||o.inlineSize*devicePixelRatio,s=r.devicePixelContentBoxSize?.[0]?.blockSize||o.blockSize*devicePixelRatio,[a,c]=this.getMaxDrawingBufferSize();this.devicePixelWidth=Math.max(1,Math.min(i,a)),this.devicePixelHeight=Math.max(1,Math.min(s,c)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:n})}_updateDrawingBufferSize(){if(this.props.autoResize)if(typeof this.props.useDevicePixels=="number"){let e=this.props.useDevicePixels;this.setDrawingBufferSize(this.cssWidth*e,this.cssHeight*e)}else this.props.useDevicePixels?this.setDrawingBufferSize(this.devicePixelWidth,this.devicePixelHeight):this.setDrawingBufferSize(this.cssWidth,this.cssHeight);this._initializedResolvers.resolve(),this.isInitialized=!0,this.updatePosition()}_resizeDrawingBufferIfNeeded(){this._needsDrawingBufferResize&&(this._needsDrawingBufferResize=!1,(this.drawingBufferWidth!==this.canvas.width||this.drawingBufferHeight!==this.canvas.height)&&(this.canvas.width=this.drawingBufferWidth,this.canvas.height=this.drawingBufferHeight,this._configureDevice()))}_observeDevicePixelRatio(){if(this.destroyed||!this._canvasObserver.started)return;let e=this.devicePixelRatio;this.devicePixelRatio=window.devicePixelRatio,this.updatePosition(),this.device.props.onDevicePixelRatioChange?.(this,{oldRatio:e})}updatePosition(){if(this.destroyed)return;let e=this.htmlCanvas?.getBoundingClientRect();if(e){let r=[e.left,e.top];if(this._position??=r,r[0]!==this._position[0]||r[1]!==this._position[1]){let n=this._position;this._position=r,this.device.props.onPositionChange?.(this,{oldPosition:n})}}}},rn=Pf;k(rn,"defaultProps",{id:void 0,canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,alphaMode:"opaque",colorSpace:"srgb",trackPosition:!1})});var Da,w2=L(()=>{UT();Da=class extends rn{};k(Da,"defaultProps",rn.defaultProps)});var Mf,P2=L(()=>{UT();Mf=class extends rn{}});var Nm,Pt,kT=L(()=>{xt();Nm=class extends J{get[Symbol.toStringTag](){return"Sampler"}constructor(e,r){r=Nm.normalizeProps(e,r),super(e,r,Nm.defaultProps)}static normalizeProps(e,r){return r}},Pt=Nm;k(Pt,"defaultProps",{...J.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"none",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1})});var jX,lr,Y,VT=L(()=>{xt();kT();Er();Im();jX={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},lr=class extends J{dimension;baseDimension;format;width;height;depth;mipLevels;samples;byteAlignment;ready=Promise.resolve(this);isReady=!0;updateTimestamp;get[Symbol.toStringTag](){return"Texture"}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}constructor(e,r,o){if(r=lr.normalizeProps(e,r),super(e,r,lr.defaultProps),this.dimension=this.props.dimension,this.baseDimension=jX[this.dimension],this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.mipLevels=this.props.mipLevels,this.samples=this.props.samples||1,this.dimension==="cube"&&(this.depth=6),this.props.width===void 0||this.props.height===void 0)if(e.isExternalImage(r.data)){let n=e.getExternalImageSize(r.data);this.width=n?.width||1,this.height=n?.height||1}else this.width=1,this.height=1,(this.props.width===void 0||this.props.height===void 0)&&P.warn(`${this} created with undefined width or height. This is deprecated. Use DynamicTexture instead.`)();this.byteAlignment=o?.byteAlignment||1,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createTexture({...this.props,...e})}setSampler(e){this.sampler=e instanceof Pt?e:this.device.createSampler(e)}copyImageData(e){let{data:r,depth:o,...n}=e;this.writeData(r,{...n,depthOrArrayLayers:n.depthOrArrayLayers??o})}computeMemoryLayout(e={}){let r=this._normalizeTextureReadOptions(e),{width:o=this.width,height:n=this.height,depthOrArrayLayers:i=this.depth}=r,{format:s,byteAlignment:a}=this;return bt.computeMemoryLayout({format:s,width:o,height:n,depth:i,byteAlignment:a})}readBuffer(e,r){throw new Error("readBuffer not implemented")}readDataAsync(e){throw new Error("readBuffer not implemented")}writeBuffer(e,r){throw new Error("readBuffer not implemented")}writeData(e,r){throw new Error("readBuffer not implemented")}readDataSyncWebGL(e){throw new Error("readDataSyncWebGL not available")}generateMipmapsWebGL(){throw new Error("generateMipmapsWebGL not available")}static normalizeProps(e,r){let o={...r},{width:n,height:i}=o;return typeof n=="number"&&(o.width=Math.max(1,Math.ceil(n))),typeof i=="number"&&(o.height=Math.max(1,Math.ceil(i))),o}_initializeData(e){this.device.isExternalImage(e)?this.copyExternalImage({image:e,width:this.width,height:this.height,depth:this.depth,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1}):e&&this.copyImageData({data:e,mipLevel:0,x:0,y:0,z:0,aspect:"all"})}_normalizeCopyImageDataOptions(e){let{data:r,depth:o,...n}=e,i=this._normalizeTextureWriteOptions({...n,depthOrArrayLayers:n.depthOrArrayLayers??o});return{data:r,depth:i.depthOrArrayLayers,...i}}_normalizeCopyExternalImageOptions(e){let r=lr._omitUndefined(e),o=r.mipLevel??0,n=this._getMipLevelSize(o),i=this.device.getExternalImageSize(e.image),s={...lr.defaultCopyExternalImageOptions,...n,...i,...r};return s.width=Math.min(s.width,n.width-s.x),s.height=Math.min(s.height,n.height-s.y),s.depth=Math.min(s.depth,n.depthOrArrayLayers-s.z),s}_normalizeTextureReadOptions(e){let r=lr._omitUndefined(e),o=r.mipLevel??0,n=this._getMipLevelSize(o),i={...lr.defaultTextureReadOptions,...n,...r};return i.width=Math.min(i.width,n.width-i.x),i.height=Math.min(i.height,n.height-i.y),i.depthOrArrayLayers=Math.min(i.depthOrArrayLayers,n.depthOrArrayLayers-i.z),i}_getSupportedColorReadOptions(e){let r=this._normalizeTextureReadOptions(e),o=bt.getInfo(this.format);switch(this._validateColorReadAspect(r),this._validateColorReadFormat(o),this.dimension){case"2d":case"cube":case"cube-array":case"2d-array":case"3d":return r;default:throw new Error(`${this} color readback does not support ${this.dimension} textures`)}}_validateColorReadAspect(e){if(e.aspect!=="all")throw new Error(`${this} color readback only supports aspect 'all'`)}_validateColorReadFormat(e){if(e.compressed)throw new Error(`${this} color readback does not support compressed formats (${this.format})`);switch(e.attachment){case"color":return;case"depth":throw new Error(`${this} color readback does not support depth formats (${this.format})`);case"stencil":throw new Error(`${this} color readback does not support stencil formats (${this.format})`);case"depth-stencil":throw new Error(`${this} color readback does not support depth-stencil formats (${this.format})`);default:throw new Error(`${this} color readback does not support format ${this.format}`)}}_normalizeTextureWriteOptions(e){let r=lr._omitUndefined(e),o=r.mipLevel??0,n=this._getMipLevelSize(o),i={...lr.defaultTextureWriteOptions,...n,...r};i.width=Math.min(i.width,n.width-i.x),i.height=Math.min(i.height,n.height-i.y),i.depthOrArrayLayers=Math.min(i.depthOrArrayLayers,n.depthOrArrayLayers-i.z);let s=bt.computeMemoryLayout({format:this.format,width:i.width,height:i.height,depth:i.depthOrArrayLayers,byteAlignment:this.byteAlignment}),a=s.bytesPerPixel*i.width;if(i.bytesPerRow=r.bytesPerRow??s.bytesPerRow,i.rowsPerImage=r.rowsPerImage??i.height,i.bytesPerRow<a)throw new Error(`bytesPerRow (${i.bytesPerRow}) must be at least ${a} for ${this.format}`);if(i.rowsPerImage<i.height)throw new Error(`rowsPerImage (${i.rowsPerImage}) must be at least ${i.height} for ${this.format}`);let c=this.device.getTextureFormatInfo(this.format).bytesPerPixel;if(c&&i.bytesPerRow%c!==0)throw new Error(`bytesPerRow (${i.bytesPerRow}) must be a multiple of bytesPerPixel (${c}) for ${this.format}`);return i}_getMipLevelSize(e){let r=Math.max(1,this.width>>e),o=this.baseDimension==="1d"?1:Math.max(1,this.height>>e),n=this.dimension==="3d"?Math.max(1,this.depth>>e):this.depth;return{width:r,height:o,depthOrArrayLayers:n}}getAllocatedByteLength(){let e=0;for(let r=0;r<this.mipLevels;r++){let{width:o,height:n,depthOrArrayLayers:i}=this._getMipLevelSize(r);e+=bt.computeMemoryLayout({format:this.format,width:o,height:n,depth:i,byteAlignment:1}).byteLength}return e*this.samples}static _omitUndefined(e){return Object.fromEntries(Object.entries(e).filter(([,r])=>r!==void 0))}},Y=lr;k(Y,"SAMPLE",4),k(Y,"STORAGE",8),k(Y,"RENDER",16),k(Y,"COPY_SRC",1),k(Y,"COPY_DST",2),k(Y,"TEXTURE",4),k(Y,"RENDER_ATTACHMENT",16),k(Y,"defaultProps",{...J.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",usage:lr.SAMPLE|lr.RENDER|lr.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0}),k(Y,"defaultCopyDataOptions",{data:void 0,byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,width:void 0,height:void 0,depthOrArrayLayers:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all"}),k(Y,"defaultCopyExternalImageOptions",{image:void 0,sourceX:0,sourceY:0,width:void 0,height:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1}),k(Y,"defaultTextureReadOptions",{x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"}),k(Y,"defaultTextureWriteOptions",{byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"})});var zT,wr,M2=L(()=>{xt();zT=class extends J{get[Symbol.toStringTag](){return"TextureView"}constructor(e,r){super(e,r,zT.defaultProps)}},wr=zT;k(wr,"defaultProps",{...J.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0})});function R2(t,e,r){let o="",n=e.split(/\r?\n/),i=t.slice().sort((s,a)=>s.lineNum-a.lineNum);switch(r?.showSourceCode||"no"){case"all":let s=0;for(let a=1;a<=n.length;a++){let c=n[a-1],l=i[s];for(c&&l&&(o+=I2(c,a,r));i.length>s&&l.lineNum===a;){let f=i[s++];f&&(o+=HT(f,n,f.lineNum,{...r,inlineSource:!1}))}}for(;i.length>s;){let a=i[s++];a&&(o+=HT(a,[],0,{...r,inlineSource:!1}))}return o;case"issues":case"no":for(let a of t)o+=HT(a,n,a.lineNum,{inlineSource:r?.showSourceCode!=="no"});return o}}function HT(t,e,r,o){if(o?.inlineSource){let i=WX(e,r),s=t.linePos>0?`${" ".repeat(t.linePos+5)}^^^ `:"";return` ${i}${s}${t.type.toUpperCase()}: ${t.message} `}let n=t.type==="error"?"red":"orange";return o?.html?`<div class='luma-compiler-log-${t.type}' style="color:${n};"><b> ${t.type.toUpperCase()}: ${t.message}</b></div>`:`${t.type.toUpperCase()}: ${t.message}`}function WX(t,e,r){let o="";for(let n=e-2;n<=e;n++){let i=t[n-1];i!==void 0&&(o+=I2(i,e,r))}return o}function I2(t,e,r){let o=r?.html?$X(t):t;return`${GX(String(e),4)}: ${o}${r?.html?"<br/>":` `}`}function GX(t,e){let r="";for(let o=t.length;o<e;++o)r+=" ";return r+t}function $X(t){return t.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}var L2=L(()=>{});function XX(t){return YX(t.source)||t.id||vo(`unnamed ${t.stage}-shader`)}function YX(t,e="unnamed"){return/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(t)?.[1]??e}var jT,oi,WT=L(()=>{xt();Fa();L2();jT=class extends J{get[Symbol.toStringTag](){return"Shader"}stage;source;compilationStatus="pending";constructor(e,r){r={...r,debugShaders:r.debugShaders||e.props.debugShaders||"errors"},super(e,{id:XX(r),...r},jT.defaultProps),this.stage=this.props.stage,this.source=this.props.source}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(){let e=this.props.debugShaders;switch(e){case"never":return;case"errors":if(this.compilationStatus==="success")return;break;case"warnings":case"always":break}let r=await this.getCompilationInfo();e==="warnings"&&r?.length===0||this._displayShaderLog(r,this.id)}_displayShaderLog(e,r){if(typeof document>"u"||!document?.createElement)return;let o=r,n=`${this.stage} shader "${o}"`,i=R2(e,this.source,{showSourceCode:"all",html:!0}),s=this.getTranslatedSource(),a=document.createElement("div");a.innerHTML=`<h1>Compilation error in ${n}</h1> <div style="display:flex;position:fixed;top:10px;right:20px;gap:2px;"> <button id="copy">Copy source</button><br/> <button id="close">Close</button> </div> <code><pre>${i}</pre></code>`,s&&(a.innerHTML+=`<br /><h1>Translated Source</h1><br /><br /><code><pre>${s}</pre></code>`),a.style.top="0",a.style.left="0",a.style.background="white",a.style.position="fixed",a.style.zIndex="9999",a.style.maxWidth="100vw",a.style.maxHeight="100vh",a.style.overflowY="auto",document.body.appendChild(a),a.querySelector(".luma-compiler-log-error")?.scrollIntoView(),a.querySelector("button#close").onclick=()=>{a.remove()},a.querySelector("button#copy").onclick=()=>{navigator.clipboard.writeText(this.source)}}},oi=jT;k(oi,"defaultProps",{...J.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0})});var GT,Eo,B2=L(()=>{xt();VT();Er();GT=class extends J{get[Symbol.toStringTag](){return"Framebuffer"}width;height;constructor(e,r={}){super(e,r,GT.defaultProps),this.width=this.props.width,this.height=this.props.height}clone(e){let r=this.colorAttachments.map(n=>n.texture.clone(e)),o=this.depthStencilAttachment&&this.depthStencilAttachment.texture.clone(e);return this.device.createFramebuffer({...this.props,...e,colorAttachments:r,depthStencilAttachment:o})}resize(e){let r=!e;if(e){let[o,n]=Array.isArray(e)?e:[e.width,e.height];r=r||n!==this.height||o!==this.width,this.width=o,this.height=n}r&&(P.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(this.props.colorAttachments.length===0&&!this.props.depthStencilAttachment)throw new Error("Framebuffer has noattachments");this.colorAttachments=this.props.colorAttachments.map((r,o)=>{if(typeof r=="string"){let n=this.createColorTexture(r,o);return this.attachResource(n),n.view}return r instanceof Y?r.view:r});let e=this.props.depthStencilAttachment;if(e)if(typeof e=="string"){let r=this.createDepthStencilTexture(e);this.attachResource(r),this.depthStencilAttachment=r.view}else e instanceof Y?this.depthStencilAttachment=e.view:this.depthStencilAttachment=e}createColorTexture(e,r){return this.device.createTexture({id:`${this.id}-color-attachment-${r}`,usage:Y.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height,sampler:{magFilter:"linear",minFilter:"linear"}})}createDepthStencilTexture(e){return this.device.createTexture({id:`${this.id}-depth-stencil-attachment`,usage:Y.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}resizeAttachments(e,r){if(this.colorAttachments.forEach((o,n)=>{let i=o.texture.clone({width:e,height:r});this.destroyAttachedResource(o),this.colorAttachments[n]=i.view,this.attachResource(i.view)}),this.depthStencilAttachment){let o=this.depthStencilAttachment.texture.clone({width:e,height:r});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=o.view,this.attachResource(o)}this.updateAttachments()}},Eo=GT;k(Eo,"defaultProps",{...J.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null})});var $T,fr,XT=L(()=>{xt();$T=class extends J{get[Symbol.toStringTag](){return"RenderPipeline"}shaderLayout;bufferLayout;linkStatus="pending";hash="";sharedRenderPipeline=null;get isPending(){return this.linkStatus==="pending"||this.vs.compilationStatus==="pending"||this.fs?.compilationStatus==="pending"}get isErrored(){return this.linkStatus==="error"||this.vs.compilationStatus==="error"||this.fs?.compilationStatus==="error"}constructor(e,r){super(e,r,$T.defaultProps),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[],this.sharedRenderPipeline=this.props._sharedRenderPipeline||null}},fr=$T;k(fr,"defaultProps",{...J.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",colorAttachmentFormats:void 0,depthStencilAttachmentFormat:void 0,parameters:{},varyings:void 0,bufferMode:void 0,disableWarnings:!1,_sharedRenderPipeline:void 0,bindings:void 0,bindGroups:void 0})});var Rf,O2=L(()=>{xt();Rf=class extends J{get[Symbol.toStringTag](){return"SharedRenderPipeline"}constructor(e,r){super(e,r,{...J.defaultProps,handle:void 0,vs:void 0,fs:void 0,varyings:void 0,bufferMode:void 0})}}});var YT,Ua,F2=L(()=>{xt();YT=class extends J{get[Symbol.toStringTag](){return"ComputePipeline"}hash="";shaderLayout;constructor(e,r){super(e,r,YT.defaultProps),this.shaderLayout=r.shaderLayout}},Ua=YT;k(Ua,"defaultProps",{...J.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0})});var KT,ka,N2=L(()=>{F2();XT();Er();Fa();KT=class{static getDefaultPipelineFactory(e){let r=e.getModuleData("@luma.gl/core");return r.defaultPipelineFactory||=new KT(e),r.defaultPipelineFactory}device;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};_sharedRenderPipelineCache={};get[Symbol.toStringTag](){return"PipelineFactory"}toString(){return`PipelineFactory(${this.device.id})`}constructor(e){this.device=e}createRenderPipeline(e){if(!this.device.props._cachePipelines)return this.device.createRenderPipeline(e);let r={...fr.defaultProps,...e},o=this._renderPipelineCache,n=this._hashRenderPipeline(r),i=o[n]?.resource;if(i)o[n].useCount++,this.device.props.debugFactories&&P.log(3,`${this}: ${o[n].resource} reused, count=${o[n].useCount}, (id=${e.id})`)();else{let s=this.device.type==="webgl"&&this.device.props._sharePipelines?this.createSharedRenderPipeline(r):void 0;i=this.device.createRenderPipeline({...r,id:r.id?`${r.id}-cached`:vo("unnamed-cached"),_sharedRenderPipeline:s}),i.hash=n,o[n]={resource:i,useCount:1},this.device.props.debugFactories&&P.log(3,`${this}: ${i} created, count=${o[n].useCount}`)()}return i}createComputePipeline(e){if(!this.device.props._cachePipelines)return this.device.createComputePipeline(e);let r={...Ua.defaultProps,...e},o=this._computePipelineCache,n=this._hashComputePipeline(r),i=o[n]?.resource;return i?(o[n].useCount++,this.device.props.debugFactories&&P.log(3,`${this}: ${o[n].resource} reused, count=${o[n].useCount}, (id=${e.id})`)()):(i=this.device.createComputePipeline({...r,id:r.id?`${r.id}-cached`:void 0}),i.hash=n,o[n]={resource:i,useCount:1},this.device.props.debugFactories&&P.log(3,`${this}: ${i} created, count=${o[n].useCount}`)()),i}release(e){if(!this.device.props._cachePipelines){e.destroy();return}let r=this._getCache(e),o=e.hash;r[o].useCount--,r[o].useCount===0?(this._destroyPipeline(e),this.device.props.debugFactories&&P.log(3,`${this}: ${e} released and destroyed`)()):r[o].useCount<0?(P.error(`${this}: ${e} released, useCount < 0, resetting`)(),r[o].useCount=0):this.device.props.debugFactories&&P.log(3,`${this}: ${e} released, count=${r[o].useCount}`)()}createSharedRenderPipeline(e){let r=this._hashSharedRenderPipeline(e),o=this._sharedRenderPipelineCache[r];return o||(o={resource:this.device._createSharedRenderPipelineWebGL(e),useCount:0},this._sharedRenderPipelineCache[r]=o),o.useCount++,o.resource}releaseSharedRenderPipeline(e){if(!e.sharedRenderPipeline)return;let r=this._hashSharedRenderPipeline(e.sharedRenderPipeline.props),o=this._sharedRenderPipelineCache[r];o&&(o.useCount--,o.useCount===0&&(o.resource.destroy(),delete this._sharedRenderPipelineCache[r]))}_destroyPipeline(e){let r=this._getCache(e);return this.device.props._destroyPipelines?(delete r[e.hash],e.destroy(),e instanceof fr&&this.releaseSharedRenderPipeline(e),!0):!1}_getCache(e){let r;if(e instanceof Ua&&(r=this._computePipelineCache),e instanceof fr&&(r=this._renderPipelineCache),!r)throw new Error(`${this}`);if(!r[e.hash])throw new Error(`${this}: ${e} matched incorrect entry`);return r}_hashComputePipeline(e){let{type:r}=this.device,o=this._getHash(e.shader.source),n=this._getHash(JSON.stringify(e.shaderLayout));return`${r}/C/${o}SL${n}`}_hashRenderPipeline(e){let r=e.vs?this._getHash(e.vs.source):0,o=e.fs?this._getHash(e.fs.source):0,n=this._getWebGLVaryingHash(e),i=this._getHash(JSON.stringify(e.shaderLayout)),s=this._getHash(JSON.stringify(e.bufferLayout)),{type:a}=this.device;switch(a){case"webgl":let c=this._getHash(JSON.stringify(e.parameters));return`${a}/R/${r}/${o}V${n}T${e.topology}P${c}SL${i}BL${s}`;case"webgpu":default:let l=this._getHash(JSON.stringify({vertexEntryPoint:e.vertexEntryPoint,fragmentEntryPoint:e.fragmentEntryPoint})),f=this._getHash(JSON.stringify(e.parameters)),u=this._getWebGPUAttachmentHash(e);return`${a}/R/${r}/${o}V${n}T${e.topology}EP${l}P${f}SL${i}BL${s}A${u}`}}_hashSharedRenderPipeline(e){let r=e.vs?this._getHash(e.vs.source):0,o=e.fs?this._getHash(e.fs.source):0,n=this._getWebGLVaryingHash(e);return`webgl/S/${r}/${o}V${n}`}_getHash(e){return this._hashes[e]===void 0&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}_getWebGLVaryingHash(e){let{varyings:r=[],bufferMode:o=null}=e;return this._getHash(JSON.stringify({varyings:r,bufferMode:o}))}_getWebGPUAttachmentHash(e){let r=e.colorAttachmentFormats??[this.device.preferredColorFormat],o=e.parameters?.depthWriteEnabled?e.depthStencilAttachmentFormat||this.device.preferredDepthFormat:null;return this._getHash(JSON.stringify({colorAttachmentFormats:r,depthStencilAttachmentFormat:o}))}},ka=KT;k(ka,"defaultProps",{...fr.defaultProps})});var qT,Va,D2=L(()=>{WT();Er();qT=class{static getDefaultShaderFactory(e){let r=e.getModuleData("@luma.gl/core");return r.defaultShaderFactory||=new qT(e),r.defaultShaderFactory}device;_cache={};get[Symbol.toStringTag](){return"ShaderFactory"}toString(){return`${this[Symbol.toStringTag]}(${this.device.id})`}constructor(e){this.device=e}createShader(e){if(!this.device.props._cacheShaders)return this.device.createShader(e);let r=this._hashShader(e),o=this._cache[r];if(o)o.useCount++,this.device.props.debugFactories&&P.log(3,`${this}: Reusing shader ${o.resource.id} count=${o.useCount}`)();else{let n=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[r]=o={resource:n,useCount:1},this.device.props.debugFactories&&P.log(3,`${this}: Created new shader ${n.id}`)()}return o.resource}release(e){if(!this.device.props._cacheShaders){e.destroy();return}let r=this._hashShader(e),o=this._cache[r];if(o)if(o.useCount--,o.useCount===0)this.device.props._destroyShaders&&(delete this._cache[r],o.resource.destroy(),this.device.props.debugFactories&&P.log(3,`${this}: Releasing shader ${e.id}, destroyed`)());else{if(o.useCount<0)throw new Error(`ShaderFactory: Shader ${e.id} released too many times`);this.device.props.debugFactories&&P.log(3,`${this}: Releasing shader ${e.id} count=${o.useCount}`)()}}_hashShader(e){return`${e.stage}:${e.source}`}},Va=qT;k(Va,"defaultProps",{...oi.defaultProps})});function U2(t,e,r){let o=t.bindings.find(n=>n.name===e||`${n.name.toLocaleLowerCase()}uniforms`===e.toLocaleLowerCase());return!o&&!r?.ignoreWarnings&&P.warn(`Binding ${e} not set: Not found in shader layout.`)(),o||null}function If(t,e){if(!e)return{};if(KX(e))return Object.fromEntries(Object.entries(e).map(([n,i])=>[Number(n),{...i}]));let r={};for(let[o,n]of Object.entries(e)){let s=U2(t,o)?.group??0;r[s]||={},r[s][o]=n}return r}function Dm(t){let e={};for(let r of Object.values(t))Object.assign(e,r);return e}function KX(t){let e=Object.keys(t);return e.length>0&&e.every(r=>/^\d+$/.test(r))}var k2=L(()=>{Er()});var ns,on,V2=L(()=>{xt();ns=class extends J{get[Symbol.toStringTag](){return"RenderPass"}constructor(e,r){r=ns.normalizeProps(e,r),super(e,r,ns.defaultProps)}static normalizeProps(e,r){return r}},on=ns;k(on,"defaultClearColor",[0,0,0,1]),k(on,"defaultClearDepth",1),k(on,"defaultClearStencil",0),k(on,"defaultProps",{...J.defaultProps,framebuffer:null,parameters:void 0,clearColor:ns.defaultClearColor,clearColors:void 0,clearDepth:ns.defaultClearDepth,clearStencil:ns.defaultClearStencil,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0})});var ZT,za,z2=L(()=>{xt();ZT=class extends J{get[Symbol.toStringTag](){return"CommandEncoder"}_timeProfilingQuerySet=null;_timeProfilingSlotCount=0;_gpuTimeMs;constructor(e,r){super(e,r,ZT.defaultProps),this._timeProfilingQuerySet=r.timeProfilingQuerySet??null,this._timeProfilingSlotCount=0,this._gpuTimeMs=void 0}async resolveTimeProfilingQuerySet(){if(this._gpuTimeMs=void 0,!this._timeProfilingQuerySet)return;let e=Math.floor(this._timeProfilingSlotCount/2);if(e<=0)return;let r=e*2,o=await this._timeProfilingQuerySet.readResults({firstQuery:0,queryCount:r}),n=0n;for(let i=0;i<r;i+=2)n+=o[i+1]-o[i];this._gpuTimeMs=Number(n)/1e6}getTimeProfilingSlotCount(){return this._timeProfilingSlotCount}getTimeProfilingQuerySet(){return this._timeProfilingQuerySet}_applyTimeProfilingToPassProps(e){let r=e||{};if(!this._supportsTimestampQueries()||!this._timeProfilingQuerySet||r.timestampQuerySet!==void 0||r.beginTimestampIndex!==void 0||r.endTimestampIndex!==void 0)return r;let o=this._timeProfilingSlotCount;return o+1>=this._timeProfilingQuerySet.props.count?r:(this._timeProfilingSlotCount+=2,{...r,timestampQuerySet:this._timeProfilingQuerySet,beginTimestampIndex:o,endTimestampIndex:o+1})}_supportsTimestampQueries(){return this.device.features.has("timestamp-query")}},za=ZT;k(za,"defaultProps",{...J.defaultProps,measureExecutionTime:void 0,timeProfilingQuerySet:void 0})});var JT,Ha,H2=L(()=>{xt();JT=class extends J{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(e,r){super(e,r,JT.defaultProps)}},Ha=JT;k(Ha,"defaultProps",{...J.defaultProps})});function ja(t){let e=Um(t),r=QX[e];if(!r)throw new Error(`Unsupported variable shader type: ${t}`);return r}function j2(t){let e=W2(t),r=JX[e];if(!r)throw new Error(`Unsupported attribute shader type: ${t}`);let[o,n]=r,i=o==="i32"||o==="u32",s=o!=="u32",a=ZX[o]*n;return{primitiveType:o,components:n,byteLength:a,integer:i,signed:s}}function qX(t,e){return e===1?t:`vec${e}<${t}>`}function W2(t){return e7[t]||t}function Um(t){return t7[t]||t}var QT,ev,ZX,JX,QX,e7,t7,km=L(()=>{QT=class{getVariableShaderTypeInfo(e){return ja(e)}getAttributeShaderTypeInfo(e){return j2(e)}makeShaderAttributeType(e,r){return qX(e,r)}resolveAttributeShaderTypeAlias(e){return W2(e)}resolveVariableShaderTypeAlias(e){return Um(e)}};ev=new QT,ZX={f32:4,f16:2,i32:4,u32:4},JX={f32:["f32",1],"vec2<f32>":["f32",2],"vec3<f32>":["f32",3],"vec4<f32>":["f32",4],f16:["f16",1],"vec2<f16>":["f16",2],"vec3<f16>":["f16",3],"vec4<f16>":["f16",4],i32:["i32",1],"vec2<i32>":["i32",2],"vec3<i32>":["i32",3],"vec4<i32>":["i32",4],u32:["u32",1],"vec2<u32>":["u32",2],"vec3<u32>":["u32",3],"vec4<u32>":["u32",4]},QX={f32:{type:"f32",components:1},f16:{type:"f16",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2<f32>":{type:"f32",components:2},"vec3<f32>":{type:"f32",components:3},"vec4<f32>":{type:"f32",components:4},"vec2<f16>":{type:"f16",components:2},"vec3<f16>":{type:"f16",components:3},"vec4<f16>":{type:"f16",components:4},"vec2<i32>":{type:"i32",components:2},"vec3<i32>":{type:"i32",components:3},"vec4<i32>":{type:"i32",components:4},"vec2<u32>":{type:"u32",components:2},"vec3<u32>":{type:"u32",components:3},"vec4<u32>":{type:"u32",components:4},"mat2x2<f32>":{type:"f32",components:4},"mat2x3<f32>":{type:"f32",components:6},"mat2x4<f32>":{type:"f32",components:8},"mat3x2<f32>":{type:"f32",components:6},"mat3x3<f32>":{type:"f32",components:9},"mat3x4<f32>":{type:"f32",components:12},"mat4x2<f32>":{type:"f32",components:8},"mat4x3<f32>":{type:"f32",components:12},"mat4x4<f32>":{type:"f32",components:16},"mat2x2<f16>":{type:"f16",components:4},"mat2x3<f16>":{type:"f16",components:6},"mat2x4<f16>":{type:"f16",components:8},"mat3x2<f16>":{type:"f16",components:6},"mat3x3<f16>":{type:"f16",components:9},"mat3x4<f16>":{type:"f16",components:12},"mat4x2<f16>":{type:"f16",components:8},"mat4x3<f16>":{type:"f16",components:12},"mat4x4<f16>":{type:"f16",components:16},"mat2x2<i32>":{type:"i32",components:4},"mat2x3<i32>":{type:"i32",components:6},"mat2x4<i32>":{type:"i32",components:8},"mat3x2<i32>":{type:"i32",components:6},"mat3x3<i32>":{type:"i32",components:9},"mat3x4<i32>":{type:"i32",components:12},"mat4x2<i32>":{type:"i32",components:8},"mat4x3<i32>":{type:"i32",components:12},"mat4x4<i32>":{type:"i32",components:16},"mat2x2<u32>":{type:"u32",components:4},"mat2x3<u32>":{type:"u32",components:6},"mat2x4<u32>":{type:"u32",components:8},"mat3x2<u32>":{type:"u32",components:6},"mat3x3<u32>":{type:"u32",components:9},"mat3x4<u32>":{type:"u32",components:12},"mat4x2<u32>":{type:"u32",components:8},"mat4x3<u32>":{type:"u32",components:12},"mat4x4<u32>":{type:"u32",components:16}},e7={vec2i:"vec2<i32>",vec3i:"vec3<i32>",vec4i:"vec4<i32>",vec2u:"vec2<u32>",vec3u:"vec3<u32>",vec4u:"vec4<u32>",vec2f:"vec2<f32>",vec3f:"vec3<f32>",vec4f:"vec4<f32>",vec2h:"vec2<f16>",vec3h:"vec3<f16>",vec4h:"vec4<f16>"},t7={vec2i:"vec2<i32>",vec3i:"vec3<i32>",vec4i:"vec4<i32>",vec2u:"vec2<u32>",vec3u:"vec3<u32>",vec4u:"vec4<u32>",vec2f:"vec2<f32>",vec3f:"vec3<f32>",vec4f:"vec4<f32>",vec2h:"vec2<f16>",vec3h:"vec3<f16>",vec4h:"vec4<f16>",mat2x2f:"mat2x2<f32>",mat2x3f:"mat2x3<f32>",mat2x4f:"mat2x4<f32>",mat3x2f:"mat3x2<f32>",mat3x3f:"mat3x3<f32>",mat3x4f:"mat3x4<f32>",mat4x2f:"mat4x2<f32>",mat4x3f:"mat4x3<f32>",mat4x4f:"mat4x4<f32>",mat2x2i:"mat2x2<i32>",mat2x3i:"mat2x3<i32>",mat2x4i:"mat2x4<i32>",mat3x2i:"mat3x2<i32>",mat3x3i:"mat3x3<i32>",mat3x4i:"mat3x4<i32>",mat4x2i:"mat4x2<i32>",mat4x3i:"mat4x3<i32>",mat4x4i:"mat4x4<i32>",mat2x2u:"mat2x2<u32>",mat2x3u:"mat2x3<u32>",mat2x4u:"mat2x4<u32>",mat3x2u:"mat3x2<u32>",mat3x3u:"mat3x3<u32>",mat3x4u:"mat3x4<u32>",mat4x2u:"mat4x2<u32>",mat4x3u:"mat4x3<u32>",mat4x4u:"mat4x4<u32>",mat2x2h:"mat2x2<f16>",mat2x3h:"mat2x3<f16>",mat2x4h:"mat2x4<f16>",mat3x2h:"mat3x2<f16>",mat3x3h:"mat3x3<f16>",mat3x4h:"mat3x4<f16>",mat4x2h:"mat4x2<f16>",mat4x3h:"mat4x3<f16>",mat4x4h:"mat4x4<f16>"}});function Vm(t,e){let r={};for(let o of t.attributes){let n=r7(t,e,o.name);n&&(r[o.name]=n)}return r}function G2(t,e,r=16){let o=Vm(t,e),n=new Array(r).fill(null);for(let i of Object.values(o))n[i.location]=i;return n}function r7(t,e,r){let o=o7(t,r),n=n7(e,r);if(!o)return null;let i=ev.getAttributeShaderTypeInfo(o.type),s=tn.getCompatibleVertexFormat(i),a=n?.vertexFormat||s,c=tn.getVertexFormatInfo(a);return{attributeName:n?.attributeName||o.name,bufferName:n?.bufferName||o.name,location:o.location,shaderType:o.type,primitiveType:i.primitiveType,shaderComponents:i.components,vertexFormat:a,bufferDataType:c.type,bufferComponents:c.components,normalized:c.normalized,integer:i.integer,stepMode:n?.stepMode||o.stepMode||"vertex",byteOffset:n?.byteOffset||0,byteStride:n?.byteStride||0}}function o7(t,e){let r=t.attributes.find(o=>o.name===e);return r||P.warn(`shader layout attribute "${e}" not present in shader`),r||null}function n7(t,e){i7(t);let r=s7(t,e);return r||(r=a7(t,e),r)?r:(P.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function i7(t){for(let e of t)(e.attributes&&e.format||!e.attributes&&!e.format)&&P.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function s7(t,e){for(let r of t)if(r.format&&r.name===e)return{attributeName:r.name,bufferName:e,stepMode:r.stepMode,vertexFormat:r.format,byteOffset:0,byteStride:r.byteStride||0};return null}function a7(t,e){for(let r of t){let o=r.byteStride;if(typeof r.byteStride!="number")for(let i of r.attributes||[]){let s=tn.getVertexFormatInfo(i.format);o+=s.byteLength}let n=r.attributes?.find(i=>i.attribute===e);if(n)return{attributeName:n.attribute,bufferName:r.name,stepMode:r.stepMode,vertexFormat:n.format,byteOffset:n.byteOffset,byteStride:o}}return null}var tv=L(()=>{Er();km();wm()});var rv,Wa,$2=L(()=>{tv();xt();rv=class extends J{get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;attributeInfos;indexBuffer=null;attributes;constructor(e,r){super(e,r,rv.defaultProps),this.maxVertexAttributes=e.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null),this.attributeInfos=G2(r.shaderLayout,r.bufferLayout,this.maxVertexAttributes)}setConstantWebGL(e,r){this.device.reportError(new Error("constant attributes not supported"),this)()}},Wa=rv;k(Wa,"defaultProps",{...J.defaultProps,shaderLayout:void 0,bufferLayout:[]})});var ov,Ga,X2=L(()=>{xt();ov=class extends J{get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,r){super(e,r,ov.defaultProps)}},Ga=ov;k(Ga,"defaultProps",{...J.defaultProps,layout:void 0,buffers:{}})});var nv,$a,Y2=L(()=>{xt();nv=class extends J{get[Symbol.toStringTag](){return"QuerySet"}constructor(e,r){super(e,r,nv.defaultProps)}},$a=nv;k($a,"defaultProps",{...J.defaultProps,type:void 0,count:void 0})});var iv,Xa,K2=L(()=>{xt();iv=class extends J{get[Symbol.toStringTag](){return"Fence"}constructor(e,r={}){super(e,r,iv.defaultProps)}},Xa=iv;k(Xa,"defaultProps",{...J.defaultProps})});function wo(t,e){switch(e){case 1:return t;case 2:return t+t%2;default:return t+(4-t%4)%4}}function Lf(t){let[,,,,e]=c7[t];return e}var c7,sv=L(()=>{c7={uint8:["uint8","u32",1,!1,Uint8Array],sint8:["sint8","i32",1,!1,Int8Array],unorm8:["uint8","f32",1,!0,Uint8Array],snorm8:["sint8","f32",1,!0,Int8Array],uint16:["uint16","u32",2,!1,Uint16Array],sint16:["sint16","i32",2,!1,Int16Array],unorm16:["uint16","u32",2,!0,Uint16Array],snorm16:["sint16","i32",2,!0,Int16Array],float16:["float16","f16",2,!1,Uint16Array],float32:["float32","f32",4,!1,Float32Array],uint32:["uint32","u32",4,!1,Uint32Array],sint32:["sint32","i32",4,!1,Int32Array]}});function Z2(t,e={}){let r={...t},o=e.layout??"std140",n={},i=0;for(let[s,a]of Object.entries(r))i=av(n,s,a,i,o);return i=wo(i,ni(r,o)),{layout:o,byteLength:i*4,uniformTypes:r,fields:n}}function Bf(t,e){let r=Um(t),o=ja(r),n=/^mat(\d)x(\d)<.+>$/.exec(r);if(n){let s=Number(n[1]),a=Number(n[2]),c=q2(a,r,o.type,e),l=f7(c.size,c.alignment,e);return{alignment:c.alignment,size:s*l,components:s*a,columns:s,rows:a,columnStride:l,shaderType:r,type:o.type}}let i=/^vec(\d)<.+>$/.exec(r);return i?q2(Number(i[1]),r,o.type,e):{alignment:1,size:1,components:1,columns:1,rows:1,columnStride:1,shaderType:r,type:o.type}}function cv(t){return Boolean(t)&&typeof t=="object"&&!Array.isArray(t)}function av(t,e,r,o,n){if(typeof r=="string"){let i=Bf(r,n),s=wo(o,i.alignment);return t[e]={offset:s,...i},s+i.size}if(Array.isArray(r)){if(Array.isArray(r[0]))throw new Error(`Nested arrays are not supported for ${e}`);let i=r[0],s=r[1],a=Q2(i,n),c=wo(o,ni(r,n));for(let l=0;l<s;l++)av(t,`${e}[${l}]`,i,c+l*a,n);return c+a*s}if(cv(r)){let i=ni(r,n),s=wo(o,i);for(let[a,c]of Object.entries(r))s=av(t,`${e}.${a}`,c,s,n);return wo(s,i)}throw new Error(`Unsupported CompositeShaderType for ${e}`)}function J2(t,e){if(typeof t=="string")return Bf(t,e).size;if(Array.isArray(t)){let o=t[0],n=t[1];if(Array.isArray(o))throw new Error("Nested arrays are not supported");return Q2(o,e)*n}let r=0;for(let o of Object.values(t)){let n=o;r=wo(r,ni(n,e)),r+=J2(n,e)}return wo(r,ni(t,e))}function ni(t,e){if(typeof t=="string")return Bf(t,e).alignment;if(Array.isArray(t)){let o=t[0],n=ni(o,e);return eI(e)?Math.max(n,4):n}let r=1;for(let o of Object.values(t)){let n=ni(o,e);r=Math.max(r,n)}return u7(e)?Math.max(r,4):r}function q2(t,e,r,o){return{alignment:t===2?2:4,size:t===3?3:t,components:t,columns:1,rows:t,columnStride:t===3?3:t,shaderType:e,type:r}}function Q2(t,e){let r=J2(t,e),o=ni(t,e);return l7(r,o,e)}function l7(t,e,r){return wo(t,eI(r)?4:e)}function f7(t,e,r){return r==="std140"?4:wo(t,e)}function eI(t){return t==="std140"||t==="wgsl-uniform"}function u7(t){return t==="std140"||t==="wgsl-uniform"}var lv=L(()=>{sv();km()});function fv(t){return(!zm||zm.byteLength<t)&&(zm=new ArrayBuffer(t)),zm}function uv(t,e){let r=fv(t.BYTES_PER_ELEMENT*e);return new t(r,0,e)}var zm,dv=L(()=>{});function d7(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Ya(t){return Array.isArray(t)?t.length===0||typeof t[0]=="number":d7(t)}var hv=L(()=>{});function h7(t){return Boolean(t)&&typeof t=="object"&&!Array.isArray(t)&&!ArrayBuffer.isView(t)}function p7(t,e,r){return Array.prototype.slice.call(t,e,r)}var Hm,tI=L(()=>{dv();hv();Er();lv();Hm=class{layout;constructor(e){this.layout=e}has(e){return Boolean(this.layout.fields[e])}get(e){let r=this.layout.fields[e];return r?{offset:r.offset,size:r.size}:void 0}getFlatUniformValues(e){let r={};for(let[o,n]of Object.entries(e)){let i=this.layout.uniformTypes[o];i?this._flattenCompositeValue(r,o,i,n):this.layout.fields[o]&&(r[o]=n)}return r}getData(e){let r=fv(this.layout.byteLength);new Uint8Array(r,0,this.layout.byteLength).fill(0);let o={i32:new Int32Array(r),u32:new Uint32Array(r),f32:new Float32Array(r),f16:new Uint16Array(r)},n=this.getFlatUniformValues(e);for(let[i,s]of Object.entries(n))this._writeLeafValue(o,i,s);return new Uint8Array(r,0,this.layout.byteLength)}_flattenCompositeValue(e,r,o,n){if(n!==void 0){if(typeof o=="string"||this.layout.fields[r]){e[r]=n;return}if(Array.isArray(o)){let i=o[0],s=o[1];if(Array.isArray(i))throw new Error(`Nested arrays are not supported for ${r}`);if(typeof i=="string"&&Ya(n)){this._flattenPackedArray(e,r,i,s,n);return}if(!Array.isArray(n)){P.warn(`Unsupported uniform array value for ${r}:`,n)();return}for(let a=0;a<Math.min(n.length,s);a++){let c=n[a];c!==void 0&&this._flattenCompositeValue(e,`${r}[${a}]`,i,c)}return}if(cv(o)&&h7(n)){for(let[i,s]of Object.entries(n)){if(s===void 0)continue;let a=`${r}.${i}`;this._flattenCompositeValue(e,a,o[i],s)}return}P.warn(`Unsupported uniform value for ${r}:`,n)()}}_flattenPackedArray(e,r,o,n,i){let s=i,c=Bf(o,this.layout.layout).components;for(let l=0;l<n;l++){let f=l*c;if(f>=s.length)break;c===1?e[`${r}[${l}]`]=Number(s[f]):e[`${r}[${l}]`]=p7(i,f,f+c)}}_writeLeafValue(e,r,o){let n=this.layout.fields[r];if(!n){P.warn(`Uniform ${r} not found in layout`)();return}let{type:i,components:s,columns:a,rows:c,offset:l,columnStride:f}=n,u=e[i];if(s===1){u[l]=Number(o);return}let d=o;if(a===1){for(let p=0;p<s;p++)u[l+p]=Number(d[p]??0);return}let h=0;for(let p=0;p<a;p++){let m=l+p*f;for(let g=0;g<c;g++)u[m+g]=Number(d[h++]??0)}}}});function rI(t,e,r=16){if(t===e)return!0;let o=t,n=e;if(!Ya(o)||!Ya(n)||o.length!==n.length)return!1;let i=Math.min(r,m7);if(o.length>i)return!1;for(let s=0;s<o.length;++s)if(n[s]!==o[s])return!1;return!0}function oI(t){return Ya(t)?t.slice():t}var m7,nI=L(()=>{hv();m7=128});var jm,iI=L(()=>{nI();jm=class{name;uniforms={};modifiedUniforms={};modified=!0;bindingLayout={};needsRedraw="initialized";constructor(e){if(this.name=e?.name||"unnamed",e?.name&&e?.shaderLayout){let r=e?.shaderLayout.bindings?.find(n=>n.type==="uniform"&&n.name===e?.name);if(!r)throw new Error(e?.name);let o=r;for(let n of o.uniforms||[])this.bindingLayout[n.name]=n}}setUniforms(e){for(let[r,o]of Object.entries(e))this._setUniform(r,o),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${r}=${o}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,r){rI(this.uniforms[e],r)||(this.uniforms[e]=oI(r),this.modifiedUniforms[e]=!0,this.modified=!0)}}});function _7(t){return t.type==="webgpu"?"wgsl-uniform":"std140"}var g7,is,sI=L(()=>{Cm();Er();lv();iI();tI();g7=1024,is=class{device;uniformBlocks=new Map;shaderBlockLayouts=new Map;shaderBlockWriters=new Map;uniformBuffers=new Map;constructor(e,r){this.device=e;for(let[o,n]of Object.entries(r)){let i=o,s=Z2(n.uniformTypes??{},{layout:n.layout??_7(e)}),a=new Hm(s);this.shaderBlockLayouts.set(i,s),this.shaderBlockWriters.set(i,a);let c=new jm({name:o});c.setUniforms(a.getFlatUniformValues(n.defaultUniforms||{})),this.uniformBlocks.set(i,c)}}destroy(){for(let e of this.uniformBuffers.values())e.destroy()}setUniforms(e){for(let[r,o]of Object.entries(e)){let n=r,s=this.shaderBlockWriters.get(n)?.getFlatUniformValues(o||{});this.uniformBlocks.get(n)?.setUniforms(s||{})}this.updateUniformBuffers()}getUniformBufferByteLength(e){let r=this.shaderBlockLayouts.get(e)?.byteLength||0;return Math.max(r,g7)}getUniformBufferData(e){let r=this.uniformBlocks.get(e)?.getAllUniforms()||{};return this.shaderBlockWriters.get(e)?.getData(r)||new Uint8Array(0)}createUniformBuffer(e,r){r&&this.setUniforms(r);let o=this.getUniformBufferByteLength(e),n=this.device.createBuffer({usage:K.UNIFORM|K.COPY_DST,byteLength:o}),i=this.getUniformBufferData(e);return n.write(i),n}getManagedUniformBuffer(e){if(!this.uniformBuffers.get(e)){let r=this.getUniformBufferByteLength(e),o=this.device.createBuffer({usage:K.UNIFORM|K.COPY_DST,byteLength:r});this.uniformBuffers.set(e,o)}return this.uniformBuffers.get(e)}updateUniformBuffers(){let e=!1;for(let r of this.uniformBlocks.keys()){let o=this.updateUniformBuffer(r);e||=o}return e&&P.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){let r=this.uniformBlocks.get(e),o=this.uniformBuffers.get(e),n=!1;if(o&&r?.needsRedraw){n||=r.needsRedraw;let i=this.getUniformBufferData(e);o=this.uniformBuffers.get(e),o?.write(i);let s=this.uniformBlocks.get(e)?.getAllUniforms();P.log(4,`Writing to uniform buffer ${String(e)}`,i,s)()}return n}}});var q=L(()=>{b2();A2();FT();w2();P2();Cm();VT();M2();WT();kT();B2();XT();O2();N2();D2();V2();z2();H2();$2();X2();Y2();K2();sI();Em();sv();km();wm();Im();LT();Er();k2();DT();dv();tv()});var hi,U3=L(()=>{(function(t){t[t.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",t[t.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",t[t.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",t[t.POINTS=0]="POINTS",t[t.LINES=1]="LINES",t[t.LINE_LOOP=2]="LINE_LOOP",t[t.LINE_STRIP=3]="LINE_STRIP",t[t.TRIANGLES=4]="TRIANGLES",t[t.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",t[t.TRIANGLE_FAN=6]="TRIANGLE_FAN",t[t.ZERO=0]="ZERO",t[t.ONE=1]="ONE",t[t.SRC_COLOR=768]="SRC_COLOR",t[t.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",t[t.SRC_ALPHA=770]="SRC_ALPHA",t[t.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",t[t.DST_ALPHA=772]="DST_ALPHA",t[t.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",t[t.DST_COLOR=774]="DST_COLOR",t[t.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",t[t.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",t[t.CONSTANT_COLOR=32769]="CONSTANT_COLOR",t[t.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",t[t.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",t[t.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",t[t.FUNC_ADD=32774]="FUNC_ADD",t[t.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",t[t.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",t[t.BLEND_EQUATION=32777]="BLEND_EQUATION",t[t.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",t[t.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",t[t.BLEND_DST_RGB=32968]="BLEND_DST_RGB",t[t.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",t[t.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",t[t.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",t[t.BLEND_COLOR=32773]="BLEND_COLOR",t[t.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",t[t.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",t[t.LINE_WIDTH=2849]="LINE_WIDTH",t[t.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",t[t.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",t[t.CULL_FACE_MODE=2885]="CULL_FACE_MODE",t[t.FRONT_FACE=2886]="FRONT_FACE",t[t.DEPTH_RANGE=2928]="DEPTH_RANGE",t[t.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",t[t.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",t[t.DEPTH_FUNC=2932]="DEPTH_FUNC",t[t.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",t[t.STENCIL_FUNC=2962]="STENCIL_FUNC",t[t.STENCIL_FAIL=2964]="STENCIL_FAIL",t[t.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",t[t.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",t[t.STENCIL_REF=2967]="STENCIL_REF",t[t.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",t[t.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",t[t.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",t[t.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",t[t.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",t[t.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",t[t.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",t[t.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",t[t.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",t[t.VIEWPORT=2978]="VIEWPORT",t[t.SCISSOR_BOX=3088]="SCISSOR_BOX",t[t.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",t[t.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",t[t.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",t[t.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",t[t.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",t[t.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",t[t.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",t[t.RED_BITS=3410]="RED_BITS",t[t.GREEN_BITS=3411]="GREEN_BITS",t[t.BLUE_BITS=3412]="BLUE_BITS",t[t.ALPHA_BITS=3413]="ALPHA_BITS",t[t.DEPTH_BITS=3414]="DEPTH_BITS",t[t.STENCIL_BITS=3415]="STENCIL_BITS",t[t.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",t[t.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",t[t.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",t[t.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",t[t.SAMPLES=32937]="SAMPLES",t[t.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",t[t.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",t[t.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",t[t.VENDOR=7936]="VENDOR",t[t.RENDERER=7937]="RENDERER",t[t.VERSION=7938]="VERSION",t[t.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",t[t.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",t[t.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",t[t.STATIC_DRAW=35044]="STATIC_DRAW",t[t.STREAM_DRAW=35040]="STREAM_DRAW",t[t.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.BUFFER_SIZE=34660]="BUFFER_SIZE",t[t.BUFFER_USAGE=34661]="BUFFER_USAGE",t[t.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",t[t.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",t[t.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",t[t.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",t[t.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",t[t.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",t[t.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",t[t.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",t[t.CULL_FACE=2884]="CULL_FACE",t[t.FRONT=1028]="FRONT",t[t.BACK=1029]="BACK",t[t.FRONT_AND_BACK=1032]="FRONT_AND_BACK",t[t.BLEND=3042]="BLEND",t[t.DEPTH_TEST=2929]="DEPTH_TEST",t[t.DITHER=3024]="DITHER",t[t.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",t[t.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",t[t.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",t[t.SCISSOR_TEST=3089]="SCISSOR_TEST",t[t.STENCIL_TEST=2960]="STENCIL_TEST",t[t.NO_ERROR=0]="NO_ERROR",t[t.INVALID_ENUM=1280]="INVALID_ENUM",t[t.INVALID_VALUE=1281]="INVALID_VALUE",t[t.INVALID_OPERATION=1282]="INVALID_OPERATION",t[t.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",t[t.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",t[t.CW=2304]="CW",t[t.CCW=2305]="CCW",t[t.DONT_CARE=4352]="DONT_CARE",t[t.FASTEST=4353]="FASTEST",t[t.NICEST=4354]="NICEST",t[t.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",t[t.BYTE=5120]="BYTE",t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.SHORT=5122]="SHORT",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.INT=5124]="INT",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.FLOAT=5126]="FLOAT",t[t.DOUBLE=5130]="DOUBLE",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.ALPHA=6406]="ALPHA",t[t.RGB=6407]="RGB",t[t.RGBA=6408]="RGBA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",t[t.VERTEX_SHADER=35633]="VERTEX_SHADER",t[t.COMPILE_STATUS=35713]="COMPILE_STATUS",t[t.DELETE_STATUS=35712]="DELETE_STATUS",t[t.LINK_STATUS=35714]="LINK_STATUS",t[t.VALIDATE_STATUS=35715]="VALIDATE_STATUS",t[t.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",t[t.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",t[t.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",t[t.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",t[t.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",t[t.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",t[t.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",t[t.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",t[t.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",t[t.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",t[t.SHADER_TYPE=35663]="SHADER_TYPE",t[t.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",t[t.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",t[t.NEVER=512]="NEVER",t[t.LESS=513]="LESS",t[t.EQUAL=514]="EQUAL",t[t.LEQUAL=515]="LEQUAL",t[t.GREATER=516]="GREATER",t[t.NOTEQUAL=517]="NOTEQUAL",t[t.GEQUAL=518]="GEQUAL",t[t.ALWAYS=519]="ALWAYS",t[t.KEEP=7680]="KEEP",t[t.REPLACE=7681]="REPLACE",t[t.INCR=7682]="INCR",t[t.DECR=7683]="DECR",t[t.INVERT=5386]="INVERT",t[t.INCR_WRAP=34055]="INCR_WRAP",t[t.DECR_WRAP=34056]="DECR_WRAP",t[t.NEAREST=9728]="NEAREST",t[t.LINEAR=9729]="LINEAR",t[t.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",t[t.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",t[t.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",t[t.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",t[t.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",t[t.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",t[t.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",t[t.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE=5890]="TEXTURE",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",t[t.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",t[t.TEXTURE0=33984]="TEXTURE0",t[t.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",t[t.REPEAT=10497]="REPEAT",t[t.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",t[t.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",t[t.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",t[t.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",t[t.FLOAT_VEC2=35664]="FLOAT_VEC2",t[t.FLOAT_VEC3=35665]="FLOAT_VEC3",t[t.FLOAT_VEC4=35666]="FLOAT_VEC4",t[t.INT_VEC2=35667]="INT_VEC2",t[t.INT_VEC3=35668]="INT_VEC3",t[t.INT_VEC4=35669]="INT_VEC4",t[t.BOOL=35670]="BOOL",t[t.BOOL_VEC2=35671]="BOOL_VEC2",t[t.BOOL_VEC3=35672]="BOOL_VEC3",t[t.BOOL_VEC4=35673]="BOOL_VEC4",t[t.FLOAT_MAT2=35674]="FLOAT_MAT2",t[t.FLOAT_MAT3=35675]="FLOAT_MAT3",t[t.FLOAT_MAT4=35676]="FLOAT_MAT4",t[t.SAMPLER_2D=35678]="SAMPLER_2D",t[t.SAMPLER_CUBE=35680]="SAMPLER_CUBE",t[t.LOW_FLOAT=36336]="LOW_FLOAT",t[t.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",t[t.HIGH_FLOAT=36338]="HIGH_FLOAT",t[t.LOW_INT=36339]="LOW_INT",t[t.MEDIUM_INT=36340]="MEDIUM_INT",t[t.HIGH_INT=36341]="HIGH_INT",t[t.FRAMEBUFFER=36160]="FRAMEBUFFER",t[t.RENDERBUFFER=36161]="RENDERBUFFER",t[t.RGBA4=32854]="RGBA4",t[t.RGB5_A1=32855]="RGB5_A1",t[t.RGB565=36194]="RGB565",t[t.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",t[t.STENCIL_INDEX=6401]="STENCIL_INDEX",t[t.STENCIL_INDEX8=36168]="STENCIL_INDEX8",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL",t[t.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",t[t.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",t[t.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",t[t.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",t[t.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",t[t.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",t[t.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",t[t.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",t[t.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",t[t.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",t[t.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",t[t.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",t[t.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",t[t.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",t[t.NONE=0]="NONE",t[t.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",t[t.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",t[t.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",t[t.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",t[t.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",t[t.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",t[t.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",t[t.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",t[t.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",t[t.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",t[t.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",t[t.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",t[t.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",t[t.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",t[t.READ_BUFFER=3074]="READ_BUFFER",t[t.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",t[t.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",t[t.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",t[t.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",t[t.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",t[t.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",t[t.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",t[t.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",t[t.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",t[t.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",t[t.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",t[t.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",t[t.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",t[t.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",t[t.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",t[t.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",t[t.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",t[t.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",t[t.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",t[t.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",t[t.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",t[t.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",t[t.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",t[t.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",t[t.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",t[t.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",t[t.RED=6403]="RED",t[t.RGB8=32849]="RGB8",t[t.RGBA8=32856]="RGBA8",t[t.RGB10_A2=32857]="RGB10_A2",t[t.TEXTURE_3D=32879]="TEXTURE_3D",t[t.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",t[t.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",t[t.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",t[t.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",t[t.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",t[t.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",t[t.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",t[t.SRGB=35904]="SRGB",t[t.SRGB8=35905]="SRGB8",t[t.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",t[t.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",t[t.RGBA32F=34836]="RGBA32F",t[t.RGB32F=34837]="RGB32F",t[t.RGBA16F=34842]="RGBA16F",t[t.RGB16F=34843]="RGB16F",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",t[t.R11F_G11F_B10F=35898]="R11F_G11F_B10F",t[t.RGB9_E5=35901]="RGB9_E5",t[t.RGBA32UI=36208]="RGBA32UI",t[t.RGB32UI=36209]="RGB32UI",t[t.RGBA16UI=36214]="RGBA16UI",t[t.RGB16UI=36215]="RGB16UI",t[t.RGBA8UI=36220]="RGBA8UI",t[t.RGB8UI=36221]="RGB8UI",t[t.RGBA32I=36226]="RGBA32I",t[t.RGB32I=36227]="RGB32I",t[t.RGBA16I=36232]="RGBA16I",t[t.RGB16I=36233]="RGB16I",t[t.RGBA8I=36238]="RGBA8I",t[t.RGB8I=36239]="RGB8I",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.R8=33321]="R8",t[t.RG8=33323]="RG8",t[t.R16F=33325]="R16F",t[t.R32F=33326]="R32F",t[t.RG16F=33327]="RG16F",t[t.RG32F=33328]="RG32F",t[t.R8I=33329]="R8I",t[t.R8UI=33330]="R8UI",t[t.R16I=33331]="R16I",t[t.R16UI=33332]="R16UI",t[t.R32I=33333]="R32I",t[t.R32UI=33334]="R32UI",t[t.RG8I=33335]="RG8I",t[t.RG8UI=33336]="RG8UI",t[t.RG16I=33337]="RG16I",t[t.RG16UI=33338]="RG16UI",t[t.RG32I=33339]="RG32I",t[t.RG32UI=33340]="RG32UI",t[t.R8_SNORM=36756]="R8_SNORM",t[t.RG8_SNORM=36757]="RG8_SNORM",t[t.RGB8_SNORM=36758]="RGB8_SNORM",t[t.RGBA8_SNORM=36759]="RGBA8_SNORM",t[t.RGB10_A2UI=36975]="RGB10_A2UI",t[t.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",t[t.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.HALF_FLOAT=5131]="HALF_FLOAT",t[t.RG=33319]="RG",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",t[t.CURRENT_QUERY=34917]="CURRENT_QUERY",t[t.QUERY_RESULT=34918]="QUERY_RESULT",t[t.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",t[t.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",t[t.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",t[t.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",t[t.DRAW_BUFFER0=34853]="DRAW_BUFFER0",t[t.DRAW_BUFFER1=34854]="DRAW_BUFFER1",t[t.DRAW_BUFFER2=34855]="DRAW_BUFFER2",t[t.DRAW_BUFFER3=34856]="DRAW_BUFFER3",t[t.DRAW_BUFFER4=34857]="DRAW_BUFFER4",t[t.DRAW_BUFFER5=34858]="DRAW_BUFFER5",t[t.DRAW_BUFFER6=34859]="DRAW_BUFFER6",t[t.DRAW_BUFFER7=34860]="DRAW_BUFFER7",t[t.DRAW_BUFFER8=34861]="DRAW_BUFFER8",t[t.DRAW_BUFFER9=34862]="DRAW_BUFFER9",t[t.DRAW_BUFFER10=34863]="DRAW_BUFFER10",t[t.DRAW_BUFFER11=34864]="DRAW_BUFFER11",t[t.DRAW_BUFFER12=34865]="DRAW_BUFFER12",t[t.DRAW_BUFFER13=34866]="DRAW_BUFFER13",t[t.DRAW_BUFFER14=34867]="DRAW_BUFFER14",t[t.DRAW_BUFFER15=34868]="DRAW_BUFFER15",t[t.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",t[t.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",t[t.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",t[t.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",t[t.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",t[t.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",t[t.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",t[t.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",t[t.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",t[t.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",t[t.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",t[t.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",t[t.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",t[t.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",t[t.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",t[t.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",t[t.SAMPLER_3D=35679]="SAMPLER_3D",t[t.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",t[t.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",t[t.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",t[t.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",t[t.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",t[t.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",t[t.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",t[t.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",t[t.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",t[t.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",t[t.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",t[t.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",t[t.MAX_SAMPLES=36183]="MAX_SAMPLES",t[t.SAMPLER_BINDING=35097]="SAMPLER_BINDING",t[t.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",t[t.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",t[t.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",t[t.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",t[t.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",t[t.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",t[t.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",t[t.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",t[t.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",t[t.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",t[t.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",t[t.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",t[t.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",t[t.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",t[t.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",t[t.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",t[t.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",t[t.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",t[t.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",t[t.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",t[t.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",t[t.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",t[t.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",t[t.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",t[t.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",t[t.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",t[t.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",t[t.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",t[t.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",t[t.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",t[t.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",t[t.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",t[t.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",t[t.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",t[t.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",t[t.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",t[t.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",t[t.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",t[t.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",t[t.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",t[t.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",t[t.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",t[t.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",t[t.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",t[t.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",t[t.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",t[t.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",t[t.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",t[t.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",t[t.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",t[t.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",t[t.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",t[t.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",t[t.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",t[t.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",t[t.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",t[t.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",t[t.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",t[t.UNIFORM_TYPE=35383]="UNIFORM_TYPE",t[t.UNIFORM_SIZE=35384]="UNIFORM_SIZE",t[t.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",t[t.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",t[t.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",t[t.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",t[t.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",t[t.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",t[t.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",t[t.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",t[t.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",t[t.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",t[t.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",t[t.OBJECT_TYPE=37138]="OBJECT_TYPE",t[t.SYNC_CONDITION=37139]="SYNC_CONDITION",t[t.SYNC_STATUS=37140]="SYNC_STATUS",t[t.SYNC_FLAGS=37141]="SYNC_FLAGS",t[t.SYNC_FENCE=37142]="SYNC_FENCE",t[t.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",t[t.UNSIGNALED=37144]="UNSIGNALED",t[t.SIGNALED=37145]="SIGNALED",t[t.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",t[t.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",t[t.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",t[t.WAIT_FAILED=37149]="WAIT_FAILED",t[t.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",t[t.COLOR=6144]="COLOR",t[t.DEPTH=6145]="DEPTH",t[t.STENCIL=6146]="STENCIL",t[t.MIN=32775]="MIN",t[t.MAX=32776]="MAX",t[t.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",t[t.STREAM_READ=35041]="STREAM_READ",t[t.STREAM_COPY=35042]="STREAM_COPY",t[t.STATIC_READ=35045]="STATIC_READ",t[t.STATIC_COPY=35046]="STATIC_COPY",t[t.DYNAMIC_READ=35049]="DYNAMIC_READ",t[t.DYNAMIC_COPY=35050]="DYNAMIC_COPY",t[t.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",t[t.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",t[t.INVALID_INDEX=4294967295]="INVALID_INDEX",t[t.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",t[t.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",t[t.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",t[t.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",t[t.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",t[t.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",t[t.R16_EXT=33322]="R16_EXT",t[t.RG16_EXT=33324]="RG16_EXT",t[t.RGB16_EXT=32852]="RGB16_EXT",t[t.RGBA16_EXT=32859]="RGBA16_EXT",t[t.R16_SNORM_EXT=36760]="R16_SNORM_EXT",t[t.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",t[t.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",t[t.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",t[t.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",t[t.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",t[t.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",t[t.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",t[t.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",t[t.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",t[t.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",t[t.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",t[t.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",t[t.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",t[t.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",t[t.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",t[t.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",t[t.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",t[t.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",t[t.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",t[t.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",t[t.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",t[t.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",t[t.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",t[t.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",t[t.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",t[t.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",t[t.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",t[t.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",t[t.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",t[t.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",t[t.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",t[t.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",t[t.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",t[t.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",t[t.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",t[t.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",t[t.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",t[t.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",t[t.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",t[t.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",t[t.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",t[t.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",t[t.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",t[t.LINE_WEBGL=6913]="LINE_WEBGL",t[t.FILL_WEBGL=6914]="FILL_WEBGL",t[t.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",t[t.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",t[t.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",t[t.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",t[t.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",t[t.CLIP_DISTANCE2_WEBGL=12290]="CLIP_DISTANCE2_WEBGL",t[t.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",t[t.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",t[t.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",t[t.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",t[t.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",t[t.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",t[t.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",t[t.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",t[t.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",t[t.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",t[t.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",t[t.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",t[t.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",t[t.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",t[t.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",t[t.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",t[t.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",t[t.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT"})(hi||(hi={}))});var k3=L(()=>{U3()});function V3(t=!0){let e=HTMLCanvasElement.prototype;if(!t&&e.originalGetContext){e.getContext=e.originalGetContext,e.originalGetContext=void 0;return}e.originalGetContext=e.getContext,e.getContext=function(r,o){if(r==="webgl"||r==="experimental-webgl"){let n=this.originalGetContext("webgl2",o);return n instanceof HTMLElement&&$q(n),n}return this.originalGetContext(r,o)}}function $q(t){t.getExtension("EXT_color_buffer_float");let e={...Hq,WEBGL_disjoint_timer_query:t.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:jq(t),OES_vertex_array_object:Wq(t),ANGLE_instanced_arrays:Gq(t)},r=t.getExtension;t.getExtension=function(n){let i=r.call(t,n);return i||(n in e?e[n]:null)};let o=t.getSupportedExtensions;t.getSupportedExtensions=function(){return(o.apply(t)||[])?.concat(Object.keys(e))}}var Hq,jq,Wq,Gq,z3=L(()=>{Hq={WEBGL_depth_texture:{UNSIGNED_INT_24_8_WEBGL:34042},OES_element_index_uint:{},OES_texture_float:{},OES_texture_half_float:{HALF_FLOAT_OES:5131},EXT_color_buffer_float:{},OES_standard_derivatives:{FRAGMENT_SHADER_DERIVATIVE_HINT_OES:35723},EXT_frag_depth:{},EXT_blend_minmax:{MIN_EXT:32775,MAX_EXT:32776},EXT_shader_texture_lod:{}},jq=t=>({drawBuffersWEBGL(e){return t.drawBuffers(e)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),Wq=t=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES(){return t.createVertexArray()},deleteVertexArrayOES(e){return t.deleteVertexArray(e)},isVertexArrayOES(e){return t.isVertexArray(e)},bindVertexArrayOES(e){return t.bindVertexArray(e)}}),Gq=t=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE(...e){return t.drawArraysInstanced(...e)},drawElementsInstancedANGLE(...e){return t.drawElementsInstanced(...e)},vertexAttribDivisorANGLE(...e){return t.vertexAttribDivisor(...e)}})});async function Ng(t,e){let r=document.getElementsByTagName("head")[0];if(!r)throw new Error("loadScript");let o=document.createElement("script");return o.setAttribute("type","text/javascript"),o.setAttribute("src",t),e&&(o.id=e),new Promise((n,i)=>{o.onload=n,o.onerror=s=>i(new Error(`Unable to load script '${t}': ${s}`)),r.appendChild(o)})}var o1=L(()=>{});function bs(t){let e=t.luma||{_polyfilled:!1,extensions:{},softwareRenderer:!1};return e._polyfilled??=!1,e.extensions||={},t.luma=e,e}var Dg=L(()=>{});async function j3(t){if(!globalThis.SPECTOR)try{await Ng(t.debugSpectorJSUrl||Ug.debugSpectorJSUrl)}catch(e){P.warn(String(e))}}function W3(t){if(t={...Ug,...t},!t.debugSpectorJS)return null;if(!dr&&globalThis.SPECTOR&&!globalThis.luma?.spector){P.probe(Xq,"SPECTOR found and initialized. Start with `luma.spector.displayUI()`")();let{Spector:e}=globalThis.SPECTOR;dr=new e,globalThis.luma&&(globalThis.luma.spector=dr)}if(!dr)return null;if(H3||(H3=!0,dr.spyCanvases(),dr?.onCaptureStarted.add(e=>P.info("Spector capture started:",e)()),dr?.onCapture.add(e=>{P.info("Spector capture complete:",e)(),dr?.getResultUI(),dr?.resultView.display(),dr?.resultView.addCapture(e)})),t.gl){let e=t.gl,r=bs(e),o=r.device;dr?.startCapture(t.gl,500),r.device=o,new Promise(n=>setTimeout(n,2e3)).then(n=>{P.info("Spector capture stopped after 2 seconds")(),dr?.stopCapture()})}return dr}var Xq,dr,H3,Ug,n1=L(()=>{q();o1();Dg();Xq=1,dr=null,H3=!1,Ug={debugSpectorJS:P.get("debug-spectorjs"),debugSpectorJSUrl:"https://cdn.jsdelivr.net/npm/spectorjs@0.9.30/dist/spector.bundle.js",gl:void 0}});function $3(t){return t.luma=t.luma||{},t.luma}async function X3(){Ot()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await Ng(Yq))}function Y3(t,e={}){return e.debugWebGL||e.traceWebGL?qq(t,e):Kq(t)}function Kq(t){let e=$3(t);return e.realContext?e.realContext:t}function qq(t,e){if(!globalThis.WebGLDebugUtils)return P.warn("webgl-debug not loaded")(),t;let r=$3(t);if(r.debugContext)return r.debugContext;globalThis.WebGLDebugUtils.init({...hi,...t});let o=globalThis.WebGLDebugUtils.makeDebugContext(t,Zq.bind(null,e),Jq.bind(null,e));for(let s in hi)!(s in o)&&typeof hi[s]=="number"&&(o[s]=hi[s]);class n{}Object.setPrototypeOf(o,Object.getPrototypeOf(t)),Object.setPrototypeOf(n,o);let i=Object.create(n);return r.realContext=t,r.debugContext=i,i.luma=r,i.debug=!0,i}function G3(t,e){e=Array.from(e).map(o=>o===void 0?"undefined":o);let r=globalThis.WebGLDebugUtils.glFunctionArgsToString(t,e);return r=`${r.slice(0,100)}${r.length>100?"...":""}`,`gl.${t}(${r})`}function Zq(t,e,r,o){o=Array.from(o).map(a=>a===void 0?"undefined":a);let n=globalThis.WebGLDebugUtils.glEnumToString(e),i=globalThis.WebGLDebugUtils.glFunctionArgsToString(r,o),s=`${n} in gl.${r}(${i})`;P.error("%cWebGL","color: white; background: red; padding: 2px 6px; border-radius: 3px;",s)();debugger;throw new Error(s)}function Jq(t,e,r){let o="";t.traceWebGL&&P.level>=1&&(o=G3(e,r),P.info(1,"%cWebGL","color: white; background: blue; padding: 2px 6px; border-radius: 3px;",o)());for(let n of r)if(n===void 0){o=o||G3(e,r);debugger}}var Yq,i1=L(()=>{q();k3();Vn();o1();Yq="https://unpkg.com/webgl-debug@2.0.1/index.js"});function s1(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Ge(t,e,r){return e[t]!==void 0?e[t]:r[t]}var gu,it,K3,hr,q3,mu,Z3,J3,a1,Fo,c1,Q3,l1=L(()=>{gu={[3042]:!1,[32773]:new Float32Array([0,0,0,0]),[32777]:32774,[34877]:32774,[32969]:1,[32968]:0,[32971]:1,[32970]:0,[3106]:new Float32Array([0,0,0,0]),[3107]:[!0,!0,!0,!0],[2884]:!1,[2885]:1029,[2929]:!1,[2931]:1,[2932]:513,[2928]:new Float32Array([0,1]),[2930]:!0,[3024]:!0,[35725]:null,[36006]:null,[36007]:null,[34229]:null,[34964]:null,[2886]:2305,[33170]:4352,[2849]:1,[32823]:!1,[32824]:0,[10752]:0,[32926]:!1,[32928]:!1,[32938]:1,[32939]:!1,[3089]:!1,[3088]:new Int32Array([0,0,1024,1024]),[2960]:!1,[2961]:0,[2968]:4294967295,[36005]:4294967295,[2962]:519,[2967]:0,[2963]:4294967295,[34816]:519,[36003]:0,[36004]:4294967295,[2964]:7680,[2965]:7680,[2966]:7680,[34817]:7680,[34818]:7680,[34819]:7680,[2978]:[0,0,1024,1024],[36389]:null,[36662]:null,[36663]:null,[35053]:null,[35055]:null,[35723]:4352,[36010]:null,[35977]:!1,[3333]:4,[3317]:4,[37440]:!1,[37441]:!1,[37443]:37444,[3330]:0,[3332]:0,[3331]:0,[3314]:0,[32878]:0,[3316]:0,[3315]:0,[32877]:0},it=(t,e,r)=>e?t.enable(r):t.disable(r),K3=(t,e,r)=>t.hint(r,e),hr=(t,e,r)=>t.pixelStorei(r,e),q3=(t,e,r)=>{let o=r===36006?36009:36008;return t.bindFramebuffer(o,e)},mu=(t,e,r)=>{let n={[34964]:34962,[36662]:36662,[36663]:36663,[35053]:35051,[35055]:35052}[r];t.bindBuffer(n,e)};Z3={[3042]:it,[32773]:(t,e)=>t.blendColor(...e),[32777]:"blendEquation",[34877]:"blendEquation",[32969]:"blendFunc",[32968]:"blendFunc",[32971]:"blendFunc",[32970]:"blendFunc",[3106]:(t,e)=>t.clearColor(...e),[3107]:(t,e)=>t.colorMask(...e),[2884]:it,[2885]:(t,e)=>t.cullFace(e),[2929]:it,[2931]:(t,e)=>t.clearDepth(e),[2932]:(t,e)=>t.depthFunc(e),[2928]:(t,e)=>t.depthRange(...e),[2930]:(t,e)=>t.depthMask(e),[3024]:it,[35723]:K3,[35725]:(t,e)=>t.useProgram(e),[36007]:(t,e)=>t.bindRenderbuffer(36161,e),[36389]:(t,e)=>t.bindTransformFeedback?.(36386,e),[34229]:(t,e)=>t.bindVertexArray(e),[36006]:q3,[36010]:q3,[34964]:mu,[36662]:mu,[36663]:mu,[35053]:mu,[35055]:mu,[2886]:(t,e)=>t.frontFace(e),[33170]:K3,[2849]:(t,e)=>t.lineWidth(e),[32823]:it,[32824]:"polygonOffset",[10752]:"polygonOffset",[35977]:it,[32926]:it,[32928]:it,[32938]:"sampleCoverage",[32939]:"sampleCoverage",[3089]:it,[3088]:(t,e)=>t.scissor(...e),[2960]:it,[2961]:(t,e)=>t.clearStencil(e),[2968]:(t,e)=>t.stencilMaskSeparate(1028,e),[36005]:(t,e)=>t.stencilMaskSeparate(1029,e),[2962]:"stencilFuncFront",[2967]:"stencilFuncFront",[2963]:"stencilFuncFront",[34816]:"stencilFuncBack",[36003]:"stencilFuncBack",[36004]:"stencilFuncBack",[2964]:"stencilOpFront",[2965]:"stencilOpFront",[2966]:"stencilOpFront",[34817]:"stencilOpBack",[34818]:"stencilOpBack",[34819]:"stencilOpBack",[2978]:(t,e)=>t.viewport(...e),[34383]:it,[10754]:it,[12288]:it,[12289]:it,[12290]:it,[12291]:it,[12292]:it,[12293]:it,[12294]:it,[12295]:it,[3333]:hr,[3317]:hr,[37440]:hr,[37441]:hr,[37443]:hr,[3330]:hr,[3332]:hr,[3331]:hr,[3314]:hr,[32878]:hr,[3316]:hr,[3315]:hr,[32877]:hr,framebuffer:(t,e)=>{let r=e&&"handle"in e?e.handle:e;return t.bindFramebuffer(36160,r)},blend:(t,e)=>e?t.enable(3042):t.disable(3042),blendColor:(t,e)=>t.blendColor(...e),blendEquation:(t,e)=>{let r=typeof e=="number"?[e,e]:e;t.blendEquationSeparate(...r)},blendFunc:(t,e)=>{let r=e?.length===2?[...e,...e]:e;t.blendFuncSeparate(...r)},clearColor:(t,e)=>t.clearColor(...e),clearDepth:(t,e)=>t.clearDepth(e),clearStencil:(t,e)=>t.clearStencil(e),colorMask:(t,e)=>t.colorMask(...e),cull:(t,e)=>e?t.enable(2884):t.disable(2884),cullFace:(t,e)=>t.cullFace(e),depthTest:(t,e)=>e?t.enable(2929):t.disable(2929),depthFunc:(t,e)=>t.depthFunc(e),depthMask:(t,e)=>t.depthMask(e),depthRange:(t,e)=>t.depthRange(...e),dither:(t,e)=>e?t.enable(3024):t.disable(3024),derivativeHint:(t,e)=>{t.hint(35723,e)},frontFace:(t,e)=>t.frontFace(e),mipmapHint:(t,e)=>t.hint(33170,e),lineWidth:(t,e)=>t.lineWidth(e),polygonOffsetFill:(t,e)=>e?t.enable(32823):t.disable(32823),polygonOffset:(t,e)=>t.polygonOffset(...e),sampleCoverage:(t,e)=>t.sampleCoverage(e[0],e[1]||!1),scissorTest:(t,e)=>e?t.enable(3089):t.disable(3089),scissor:(t,e)=>t.scissor(...e),stencilTest:(t,e)=>e?t.enable(2960):t.disable(2960),stencilMask:(t,e)=>{e=s1(e)?e:[e,e];let[r,o]=e;t.stencilMaskSeparate(1028,r),t.stencilMaskSeparate(1029,o)},stencilFunc:(t,e)=>{e=s1(e)&&e.length===3?[...e,...e]:e;let[r,o,n,i,s,a]=e;t.stencilFuncSeparate(1028,r,o,n),t.stencilFuncSeparate(1029,i,s,a)},stencilOp:(t,e)=>{e=s1(e)&&e.length===3?[...e,...e]:e;let[r,o,n,i,s,a]=e;t.stencilOpSeparate(1028,r,o,n),t.stencilOpSeparate(1029,i,s,a)},viewport:(t,e)=>t.viewport(...e)};J3={blendEquation:(t,e,r)=>t.blendEquationSeparate(Ge(32777,e,r),Ge(34877,e,r)),blendFunc:(t,e,r)=>t.blendFuncSeparate(Ge(32969,e,r),Ge(32968,e,r),Ge(32971,e,r),Ge(32970,e,r)),polygonOffset:(t,e,r)=>t.polygonOffset(Ge(32824,e,r),Ge(10752,e,r)),sampleCoverage:(t,e,r)=>t.sampleCoverage(Ge(32938,e,r),Ge(32939,e,r)),stencilFuncFront:(t,e,r)=>t.stencilFuncSeparate(1028,Ge(2962,e,r),Ge(2967,e,r),Ge(2963,e,r)),stencilFuncBack:(t,e,r)=>t.stencilFuncSeparate(1029,Ge(34816,e,r),Ge(36003,e,r),Ge(36004,e,r)),stencilOpFront:(t,e,r)=>t.stencilOpSeparate(1028,Ge(2964,e,r),Ge(2965,e,r),Ge(2966,e,r)),stencilOpBack:(t,e,r)=>t.stencilOpSeparate(1029,Ge(34817,e,r),Ge(34818,e,r),Ge(34819,e,r))},a1={enable:(t,e)=>t({[e]:!0}),disable:(t,e)=>t({[e]:!1}),pixelStorei:(t,e,r)=>t({[e]:r}),hint:(t,e,r)=>t({[e]:r}),useProgram:(t,e)=>t({[35725]:e}),bindRenderbuffer:(t,e,r)=>t({[36007]:r}),bindTransformFeedback:(t,e,r)=>t({[36389]:r}),bindVertexArray:(t,e)=>t({[34229]:e}),bindFramebuffer:(t,e,r)=>{switch(e){case 36160:return t({[36006]:r,[36010]:r});case 36009:return t({[36006]:r});case 36008:return t({[36010]:r});default:return null}},bindBuffer:(t,e,r)=>{let o={[34962]:[34964],[36662]:[36662],[36663]:[36663],[35051]:[35053],[35052]:[35055]}[e];return o?t({[o]:r}):{valueChanged:!0}},blendColor:(t,e,r,o,n)=>t({[32773]:new Float32Array([e,r,o,n])}),blendEquation:(t,e)=>t({[32777]:e,[34877]:e}),blendEquationSeparate:(t,e,r)=>t({[32777]:e,[34877]:r}),blendFunc:(t,e,r)=>t({[32969]:e,[32968]:r,[32971]:e,[32970]:r}),blendFuncSeparate:(t,e,r,o,n)=>t({[32969]:e,[32968]:r,[32971]:o,[32970]:n}),clearColor:(t,e,r,o,n)=>t({[3106]:new Float32Array([e,r,o,n])}),clearDepth:(t,e)=>t({[2931]:e}),clearStencil:(t,e)=>t({[2961]:e}),colorMask:(t,e,r,o,n)=>t({[3107]:[e,r,o,n]}),cullFace:(t,e)=>t({[2885]:e}),depthFunc:(t,e)=>t({[2932]:e}),depthRange:(t,e,r)=>t({[2928]:new Float32Array([e,r])}),depthMask:(t,e)=>t({[2930]:e}),frontFace:(t,e)=>t({[2886]:e}),lineWidth:(t,e)=>t({[2849]:e}),polygonOffset:(t,e,r)=>t({[32824]:e,[10752]:r}),sampleCoverage:(t,e,r)=>t({[32938]:e,[32939]:r}),scissor:(t,e,r,o,n)=>t({[3088]:new Int32Array([e,r,o,n])}),stencilMask:(t,e)=>t({[2968]:e,[36005]:e}),stencilMaskSeparate:(t,e,r)=>t({[e===1028?2968:36005]:r}),stencilFunc:(t,e,r,o)=>t({[2962]:e,[2967]:r,[2963]:o,[34816]:e,[36003]:r,[36004]:o}),stencilFuncSeparate:(t,e,r,o,n)=>t({[e===1028?2962:34816]:r,[e===1028?2967:36003]:o,[e===1028?2963:36004]:n}),stencilOp:(t,e,r,o)=>t({[2964]:e,[2965]:r,[2966]:o,[34817]:e,[34818]:r,[34819]:o}),stencilOpSeparate:(t,e,r,o,n)=>t({[e===1028?2964:34817]:r,[e===1028?2965:34818]:o,[e===1028?2966:34819]:n}),viewport:(t,e,r,o,n)=>t({[2978]:[e,r,o,n]})},Fo=(t,e)=>t.isEnabled(e),c1={[3042]:Fo,[2884]:Fo,[2929]:Fo,[3024]:Fo,[32823]:Fo,[32926]:Fo,[32928]:Fo,[3089]:Fo,[2960]:Fo,[35977]:Fo},Q3=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068])});function ro(t,e){if(Qq(e))return;let r={};for(let n in e){let i=Number(n),s=Z3[n];s&&(typeof s=="string"?r[s]=!0:s(t,e[n],i))}let o=t.lumaState?.cache;if(o)for(let n in r){let i=J3[n];i(t,e,o)}}function kg(t,e=gu){if(typeof e=="number"){let n=e,i=c1[n];return i?i(t,n):t.getParameter(n)}let r=Array.isArray(e)?e:Object.keys(e),o={};for(let n of r){let i=c1[n];o[n]=i?i(t,Number(n)):t.getParameter(Number(n))}return o}function eL(t){ro(t,gu)}function Qq(t){for(let e in t)return!1;return!0}var hc=L(()=>{l1()});function rL(t,e){if(t===e)return!0;if(tL(t)&&tL(e)&&t.length===e.length){for(let r=0;r<t.length;++r)if(t[r]!==e[r])return!1;return!0}return!1}function tL(t){return Array.isArray(t)||ArrayBuffer.isView(t)}var oL=L(()=>{});function nL(t,e){let r=t[e].bind(t);t[e]=function(n){if(n===void 0||Q3.has(n))return r(n);let i=oo.get(t);return n in i.cache||(i.cache[n]=r(n)),i.enable?i.cache[n]:r(n)},Object.defineProperty(t[e],"name",{value:`${e}-from-cache`,configurable:!1})}function eZ(t,e,r){if(!t[e])return;let o=t[e].bind(t);t[e]=function(...i){let s=oo.get(t),{valueChanged:a,oldValue:c}=r(s._updateCache,...i);return a&&o(...i),c},Object.defineProperty(t[e],"name",{value:`${e}-to-cache`,configurable:!1})}function tZ(t){let e=t.useProgram.bind(t);t.useProgram=function(o){let n=oo.get(t);n.program!==o&&(e(o),n.program=o)}}var oo,f1=L(()=>{hc();oL();l1();oo=class{static get(e){return e.lumaState}gl;program=null;stateStack=[];enable=!0;cache=null;log;initialized=!1;constructor(e,r){this.gl=e,this.log=r?.log||(()=>{}),this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(e={}){this.stateStack.push({})}pop(){let e=this.stateStack[this.stateStack.length-1];ro(this.gl,e),this.stateStack.pop()}trackState(e,r){if(this.cache=r?.copyState?kg(e):Object.assign({},gu),this.initialized)throw new Error("WebGLStateTracker");this.initialized=!0,this.gl.lumaState=this,tZ(e);for(let o in a1){let n=a1[o];eZ(e,o,n)}nL(e,"getParameter"),nL(e,"isEnabled")}_updateCache(e){let r=!1,o,n=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let i in e){let s=e[i],a=this.cache[i];rL(s,a)||(r=!0,o=a,n&&!(i in n)&&(n[i]=a),this.cache[i]=s)}return{valueChanged:r,oldValue:o}}}});function iL(t,e,r){let o="",n=c=>{let l=c.statusMessage;l&&(o||=l)};t.addEventListener("webglcontextcreationerror",n,!1);let i=r.failIfMajorPerformanceCaveat!==!0,s={preserveDrawingBuffer:!0,...r,failIfMajorPerformanceCaveat:!0},a=null;try{a||=t.getContext("webgl2",s),!a&&s.failIfMajorPerformanceCaveat&&(o||="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.");let c=!1;if(!a&&i&&(s.failIfMajorPerformanceCaveat=!1,a=t.getContext("webgl2",s),c=!0),a||(a=t.getContext("webgl",{}),a&&(a=null,o||="Your browser only supports WebGL1")),!a)throw o||="Your browser does not support WebGL",new Error(`Failed to create WebGL context: ${o}`);let l=bs(a);l.softwareRenderer=c;let{onContextLost:f,onContextRestored:u}=e;return t.addEventListener("webglcontextlost",d=>f(d),!1),t.addEventListener("webglcontextrestored",d=>u(d),!1),a}finally{t.removeEventListener("webglcontextcreationerror",n,!1)}}var sL=L(()=>{Dg()});function no(t,e,r){return r[e]===void 0&&(r[e]=t.getExtension(e)||null),r[e]}var _u=L(()=>{});function aL(t,e){let r=t.getParameter(7936),o=t.getParameter(7937);no(t,"WEBGL_debug_renderer_info",e);let n=e.WEBGL_debug_renderer_info,i=t.getParameter(n?n.UNMASKED_VENDOR_WEBGL:7936),s=t.getParameter(n?n.UNMASKED_RENDERER_WEBGL:7937),a=i||r,c=s||o,l=t.getParameter(7938),f=cL(a,c),u=rZ(a,c),d=oZ(a,c);return{type:"webgl",gpu:f,gpuType:d,gpuBackend:u,vendor:a,renderer:c,version:l,shadingLanguage:"glsl",shadingLanguageVersion:300}}function cL(t,e){return/NVIDIA/i.exec(t)||/NVIDIA/i.exec(e)?"nvidia":/INTEL/i.exec(t)||/INTEL/i.exec(e)?"intel":/Apple/i.exec(t)||/Apple/i.exec(e)?"apple":/AMD/i.exec(t)||/AMD/i.exec(e)||/ATI/i.exec(t)||/ATI/i.exec(e)?"amd":/SwiftShader/i.exec(t)||/SwiftShader/i.exec(e)?"software":"unknown"}function rZ(t,e){return/Metal/i.exec(t)||/Metal/i.exec(e)?"metal":/ANGLE/i.exec(t)||/ANGLE/i.exec(e)?"opengl":"unknown"}function oZ(t,e){if(/SwiftShader/i.exec(t)||/SwiftShader/i.exec(e))return"cpu";switch(cL(t,e)){case"apple":return nZ(t,e)?"integrated":"unknown";case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function nZ(t,e){return/Apple (M\d|A\d|GPU)/i.test(`${t} ${e}`)}var lL=L(()=>{_u()});function Vg(t){switch(t){case"uint8":return 5121;case"sint8":return 5120;case"unorm8":return 5121;case"snorm8":return 5120;case"uint16":return 5123;case"sint16":return 5122;case"unorm16":return 5123;case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(t))}var u1=L(()=>{});function dL(t){return t in Hg}function g1(t,e,r){return hL(t,e,r,new Set)}function hL(t,e,r,o){let n=Hg[e];if(!n||o.has(e))return!1;o.add(e);let i=(n.features||[]).every(s=>hL(t,s,r,o));return o.delete(e),i?(n.extensions||[]).every(s=>Boolean(no(t,s,r))):!1}function pL(t,e,r){let o=e.create,n=jg[e.format];n?.gl===void 0&&(o=!1),n?.x&&(o=o&&Boolean(no(t,n.x,r))),e.format==="stencil8"&&(o=!1);let i=n?.r===!1?!1:n?.r===void 0||g1(t,n.r,r),s=o&&e.render&&i&&dZ(t,e.format,r);return{format:e.format,create:o&&e.create,render:s,filter:o&&e.filter,blend:o&&e.blend,store:o&&e.store}}function dZ(t,e,r){let o=jg[e],n=o?.gl;if(n===void 0||o?.x&&!no(t,o.x,r))return!1;let i=t.getParameter(32873),s=t.getParameter(36006),a=t.createTexture(),c=t.createFramebuffer();if(!a||!c)return!1;let l=Number(0),f=Number(t.getError());for(;f!==l;)f=t.getError();let u=!1;try{if(t.bindTexture(3553,a),t.texStorage2D(3553,1,n,1,1),Number(t.getError())!==l)return!1;t.bindFramebuffer(36160,c),t.framebufferTexture2D(36160,36064,3553,a,0),u=Number(t.checkFramebufferStatus(36160))===Number(36053)&&Number(t.getError())===l}finally{t.bindFramebuffer(36160,s),t.deleteFramebuffer(c),t.bindTexture(3553,i),t.deleteTexture(a)}return u}function Wg(t){let e=jg[t],r=pZ(t),o=bt.getInfo(t);return o.compressed&&(e.dataFormat=r),{internalFormat:r,format:e?.dataFormat||hZ(o.channels,o.integer,o.normalized,r),type:o.dataType?Vg(o.dataType):e?.types?.[0]||5121,compressed:o.compressed||!1}}function mL(t){switch(bt.getInfo(t).attachment){case"depth":return 36096;case"stencil":return 36128;case"depth-stencil":return 33306;default:throw new Error(`Not a depth stencil format: ${t}`)}}function hZ(t,e,r,o){if(o===6408||o===6407)return o;switch(t){case"r":return e&&!r?36244:6403;case"rg":return e&&!r?33320:33319;case"rgb":return e&&!r?36248:6407;case"rgba":return e&&!r?36249:6408;case"bgra":throw new Error("bgra pixels not supported by WebGL");default:return 6408}}function pZ(t){let r=jg[t]?.gl;if(r===void 0)throw new Error(`Unsupported texture format ${t}`);return r}var yu,xu,pc,mc,iZ,sZ,aZ,cZ,lZ,fZ,fL,uL,d1,h1,p1,m1,zg,uZ,Hg,jg,gc=L(()=>{q();_u();u1();yu="WEBGL_compressed_texture_s3tc",xu="WEBGL_compressed_texture_s3tc_srgb",pc="EXT_texture_compression_rgtc",mc="EXT_texture_compression_bptc",iZ="WEBGL_compressed_texture_etc",sZ="WEBGL_compressed_texture_astc",aZ="WEBGL_compressed_texture_etc1",cZ="WEBGL_compressed_texture_pvrtc",lZ="WEBGL_compressed_texture_atc",fZ="EXT_texture_norm16",fL="EXT_render_snorm",uL="EXT_color_buffer_float",d1="snorm8-renderable-webgl",h1="norm16-renderable-webgl",p1="snorm16-renderable-webgl",m1="float16-renderable-webgl",zg="float32-renderable-webgl",uZ="rgb9e5ufloat-renderable-webgl",Hg={"float32-renderable-webgl":{extensions:[uL]},"float16-renderable-webgl":{extensions:["EXT_color_buffer_half_float"]},"rgb9e5ufloat-renderable-webgl":{extensions:["WEBGL_render_shared_exponent"]},"snorm8-renderable-webgl":{extensions:[fL]},"norm16-webgl":{extensions:[fZ]},"norm16-renderable-webgl":{features:["norm16-webgl"]},"snorm16-renderable-webgl":{features:["norm16-webgl"],extensions:[fL]},"float32-filterable":{extensions:["OES_texture_float_linear"]},"float16-filterable-webgl":{extensions:["OES_texture_half_float_linear"]},"texture-filterable-anisotropic-webgl":{extensions:["EXT_texture_filter_anisotropic"]},"texture-blend-float-webgl":{extensions:["EXT_float_blend"]},"texture-compression-bc":{extensions:[yu,xu,pc,mc]},"texture-compression-bc5-webgl":{extensions:[pc]},"texture-compression-bc7-webgl":{extensions:[mc]},"texture-compression-etc2":{extensions:[iZ]},"texture-compression-astc":{extensions:[sZ]},"texture-compression-etc1-webgl":{extensions:[aZ]},"texture-compression-pvrtc-webgl":{extensions:[cZ]},"texture-compression-atc-webgl":{extensions:[lZ]}};jg={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756,r:d1},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757,r:d1},rg8uint:{gl:33336,rb:!0},rg8sint:{gl:33335,rb:!0},r16uint:{gl:33332,rb:!0},r16sint:{gl:33331,rb:!0},r16float:{gl:33325,rb:!0,r:m1},r16unorm:{gl:33322,rb:!0,r:h1},r16snorm:{gl:36760,r:p1},"rgba4unorm-webgl":{gl:32854,rb:!0},"rgb565unorm-webgl":{gl:36194,rb:!0},"rgb5a1unorm-webgl":{gl:32855,rb:!0},"rgb8unorm-webgl":{gl:32849},"rgb8snorm-webgl":{gl:36758},rgba8unorm:{gl:32856},"rgba8unorm-srgb":{gl:35907},rgba8snorm:{gl:36759,r:d1},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0,r:m1},rg16unorm:{gl:33324,r:h1},rg16snorm:{gl:36761,r:p1},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326,r:zg},rgb9e5ufloat:{gl:35901,r:uZ},rg11b10ufloat:{gl:35898,rb:!0},rgb10a2unorm:{gl:32857,rb:!0},rgb10a2uint:{gl:36975,rb:!0},"rgb16unorm-webgl":{gl:32852,r:!1},"rgb16snorm-webgl":{gl:36762,r:!1},rg32uint:{gl:33340,rb:!0},rg32sint:{gl:33339,rb:!0},rg32float:{gl:33328,rb:!0,r:zg},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842,r:m1},rgba16unorm:{gl:32859,rb:!0,r:h1},rgba16snorm:{gl:36763,r:p1},"rgb32float-webgl":{gl:34837,x:uL,r:zg,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0,r:zg},stencil8:{gl:36168,rb:!0},depth16unorm:{gl:33189,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,dataFormat:6402,types:[5125]},depth32float:{gl:36012,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth32float-stencil8":{gl:36013,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:yu},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:xu},"bc1-rgba-unorm":{gl:33777,x:yu},"bc1-rgba-unorm-srgb":{gl:35916,x:xu},"bc2-rgba-unorm":{gl:33778,x:yu},"bc2-rgba-unorm-srgb":{gl:35918,x:xu},"bc3-rgba-unorm":{gl:33779,x:yu},"bc3-rgba-unorm-srgb":{gl:35919,x:xu},"bc4-r-unorm":{gl:36283,x:pc},"bc4-r-snorm":{gl:36284,x:pc},"bc5-rg-unorm":{gl:36285,x:pc},"bc5-rg-snorm":{gl:36286,x:pc},"bc6h-rgb-ufloat":{gl:36495,x:mc},"bc6h-rgb-float":{gl:36494,x:mc},"bc7-rgba-unorm":{gl:36492,x:mc},"bc7-rgba-unorm-srgb":{gl:36493,x:mc},"etc2-rgb8unorm":{gl:37492},"etc2-rgb8unorm-srgb":{gl:37494},"etc2-rgb8a1unorm":{gl:37496},"etc2-rgb8a1unorm-srgb":{gl:37497},"etc2-rgba8unorm":{gl:37493},"etc2-rgba8unorm-srgb":{gl:37495},"eac-r11unorm":{gl:37488},"eac-r11snorm":{gl:37489},"eac-rg11unorm":{gl:37490},"eac-rg11snorm":{gl:37491},"astc-4x4-unorm":{gl:37808},"astc-4x4-unorm-srgb":{gl:37840},"astc-5x4-unorm":{gl:37809},"astc-5x4-unorm-srgb":{gl:37841},"astc-5x5-unorm":{gl:37810},"astc-5x5-unorm-srgb":{gl:37842},"astc-6x5-unorm":{gl:37811},"astc-6x5-unorm-srgb":{gl:37843},"astc-6x6-unorm":{gl:37812},"astc-6x6-unorm-srgb":{gl:37844},"astc-8x5-unorm":{gl:37813},"astc-8x5-unorm-srgb":{gl:37845},"astc-8x6-unorm":{gl:37814},"astc-8x6-unorm-srgb":{gl:37846},"astc-8x8-unorm":{gl:37815},"astc-8x8-unorm-srgb":{gl:37847},"astc-10x5-unorm":{gl:37816},"astc-10x5-unorm-srgb":{gl:37848},"astc-10x6-unorm":{gl:37817},"astc-10x6-unorm-srgb":{gl:37849},"astc-10x8-unorm":{gl:37818},"astc-10x8-unorm-srgb":{gl:37850},"astc-10x10-unorm":{gl:37819},"astc-10x10-unorm-srgb":{gl:37851},"astc-12x10-unorm":{gl:37820},"astc-12x10-unorm-srgb":{gl:37852},"astc-12x12-unorm":{gl:37821},"astc-12x12-unorm-srgb":{gl:37853},"pvrtc-rgb4unorm-webgl":{gl:35840},"pvrtc-rgba4unorm-webgl":{gl:35842},"pvrtc-rgb2unorm-webgl":{gl:35841},"pvrtc-rgba2unorm-webgl":{gl:35843},"etc1-rbg-unorm-webgl":{gl:36196},"atc-rgb-unorm-webgl":{gl:35986},"atc-rgba-unorm-webgl":{gl:35986},"atc-rgbai-unorm-webgl":{gl:34798}}});var gL,Gg,_L=L(()=>{q();_u();gc();gL={"depth-clip-control":"EXT_depth_clamp","timestamp-query":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"},Gg=class extends Ef{gl;extensions;testedFeatures=new Set;constructor(e,r,o){super([],o),this.gl=e,this.extensions=r,no(e,"EXT_color_buffer_float",r)}*[Symbol.iterator](){let e=this.getFeatures();for(let r of e)this.has(r)&&(yield r);return[]}has(e){return this.disabledFeatures?.[e]?!1:(this.testedFeatures.has(e)||(this.testedFeatures.add(e),dL(e)&&g1(this.gl,e,this.extensions)&&this.features.add(e),this.getWebGLFeature(e)&&this.features.add(e)),this.features.has(e))}initializeFeatures(){let e=this.getFeatures().filter(r=>r!=="polygon-mode-webgl");for(let r of e)this.has(r)}getFeatures(){return[...Object.keys(gL),...Object.keys(Hg)]}getWebGLFeature(e){let r=gL[e];return Boolean(typeof r=="string"?no(this.gl,r,this.extensions):r)}}});var $g,yL=L(()=>{q();$g=class extends Cf{get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderVariables(){return this.getParameter(35659)}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}gl;limits={};constructor(e){super(),this.gl=e}getParameter(e){return this.limits[e]===void 0&&(this.limits[e]=this.gl.getParameter(e)),this.limits[e]||0}}});function mZ(t){return t<34069?t+34069:t}function gZ(t){switch(t){case 36053:return"success";case 36054:return"Mismatched attachments";case 36055:return"No attachments";case 36057:return"Height/width mismatch";case 36061:return"Unsupported or split attachments";case 36182:return"Samples mismatch";default:return`${t}`}}var No,Xg=L(()=>{q();gc();No=class extends Eo{device;gl;handle;colorAttachments=[];depthStencilAttachment=null;constructor(e,r){super(e,r);let o=r.handle===null;this.device=e,this.gl=e.gl,this.handle=this.props.handle||o?this.props.handle:this.gl.createFramebuffer(),o||(e._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),r.handle||(this.autoCreateAttachmentTextures(),this.updateAttachments()))}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&!this.props.handle&&this.gl.deleteFramebuffer(this.handle)}updateAttachments(){let e=this.gl.bindFramebuffer(36160,this.handle);for(let r=0;r<this.colorAttachments.length;++r){let o=this.colorAttachments[r];if(o){let n=36064+r;this._attachTextureView(n,o)}}if(this.depthStencilAttachment){let r=mL(this.depthStencilAttachment.props.format);this._attachTextureView(r,this.depthStencilAttachment)}if(this.device.props.debug){let r=this.gl.checkFramebufferStatus(36160);if(r!==36053)throw new Error(`Framebuffer ${gZ(r)}`)}this.gl.bindFramebuffer(36160,e)}_attachTextureView(e,r){let{gl:o}=this.device,{texture:n}=r,i=r.props.baseMipLevel,s=r.props.baseArrayLayer;switch(o.bindTexture(n.glTarget,n.handle),n.glTarget){case 35866:case 32879:o.framebufferTextureLayer(36160,e,n.handle,i,s);break;case 34067:let a=mZ(s);o.framebufferTexture2D(36160,e,a,n.handle,i);break;case 3553:o.framebufferTexture2D(36160,e,3553,n.handle,i);break;default:throw new Error("Illegal texture type")}o.bindTexture(n.glTarget,null)}resizeAttachments(e,r){if(this.handle===null){this.width=e,this.height=r;return}super.resizeAttachments(e,r)}}});var Yg,xL=L(()=>{q();Xg();Yg=class extends Da{device;handle=null;_framebuffer=null;get[Symbol.toStringTag](){return"WebGLCanvasContext"}constructor(e,r){super(r),this.device=e,this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this._configureDevice()}_configureDevice(){(this.drawingBufferWidth!==this._framebuffer?.width||this.drawingBufferHeight!==this._framebuffer?.height)&&this._framebuffer?.resize([this.drawingBufferWidth,this.drawingBufferHeight])}_getCurrentFramebuffer(){return this._framebuffer||=new No(this.device,{id:"canvas-context-framebuffer",handle:null,width:this.drawingBufferWidth,height:this.drawingBufferHeight}),this._framebuffer}}});var Kg,bL=L(()=>{q();Kg=class extends Mf{device;handle=null;context2d;get[Symbol.toStringTag](){return"WebGLPresentationContext"}constructor(e,r={}){super(r),this.device=e;let o=`${this[Symbol.toStringTag]}(${this.id})`;if(!this.device.getDefaultCanvasContext().offscreenCanvas)throw new Error(`${o}: WebGL PresentationContext requires the default CanvasContext canvas to be an OffscreenCanvas`);let i=this.canvas.getContext("2d");if(!i)throw new Error(`${o}: Failed to create 2d presentation context`);this.context2d=i,this._setAutoCreatedCanvasId(`${this.device.id}-presentation-canvas`),this._configureDevice(),this._startObservers()}present(){this._resizeDrawingBufferIfNeeded(),this.device.submit();let e=this.device.getDefaultCanvasContext(),[r,o]=e.getDrawingBufferSize();if(!(this.drawingBufferWidth===0||this.drawingBufferHeight===0||r===0||o===0||e.canvas.width===0||e.canvas.height===0)){if(r!==this.drawingBufferWidth||o!==this.drawingBufferHeight||e.canvas.width!==this.drawingBufferWidth||e.canvas.height!==this.drawingBufferHeight)throw new Error(`${this[Symbol.toStringTag]}(${this.id}): Default canvas context size ${r}x${o} does not match presentation size ${this.drawingBufferWidth}x${this.drawingBufferHeight}`);this.context2d.clearRect(0,0,this.drawingBufferWidth,this.drawingBufferHeight),this.context2d.drawImage(e.canvas,0,0)}}_configureDevice(){}_getCurrentFramebuffer(e){let r=this.device.getDefaultCanvasContext();return r.setDrawingBufferSize(this.drawingBufferWidth,this.drawingBufferHeight),r.getCurrentFramebuffer(e)}}});function AL(t="id"){_1[t]=_1[t]||1;let e=_1[t]++;return`${t}-${e}`}var _1,TL=L(()=>{_1={}});function _Z(t){return t&K.INDEX?34963:t&K.VERTEX?34962:t&K.UNIFORM?35345:34962}function yZ(t){return t&K.INDEX||t&K.VERTEX?35044:t&K.UNIFORM?35048:35044}var io,qg=L(()=>{q();io=class extends K{device;gl;handle;glTarget;glUsage;glIndexType=5123;byteLength=0;bytesUsed=0;constructor(e,r={}){super(e,r),this.device=e,this.gl=this.device.gl;let o=typeof r=="object"?r.handle:void 0;this.handle=o||this.gl.createBuffer(),e._setWebGLDebugMetadata(this.handle,this,{spector:{...this.props,data:typeof this.props.data}}),this.glTarget=_Z(this.props.usage),this.glUsage=yZ(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?5125:5123,r.data?this._initWithData(r.data,r.byteOffset,r.byteLength):this._initWithByteLength(r.byteLength||0)}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.props.handle?this.trackDeallocatedReferencedMemory("Buffer"):(this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle)),this.destroyed=!0,this.handle=null)}_initWithData(e,r=0,o=e.byteLength+r){let n=this.glTarget;this.gl.bindBuffer(n,this.handle),this.gl.bufferData(n,o,this.glUsage),this.gl.bufferSubData(n,r,e),this.gl.bindBuffer(n,null),this.bytesUsed=o,this.byteLength=o,this._setDebugData(e,r,o),this.props.handle?this.trackReferencedMemory(o,"Buffer"):this.trackAllocatedMemory(o)}_initWithByteLength(e){let r=e;e===0&&(r=new Float32Array(0));let o=this.glTarget;return this.gl.bindBuffer(o,this.handle),this.gl.bufferData(o,r,this.glUsage),this.gl.bindBuffer(o,null),this.bytesUsed=e,this.byteLength=e,this._setDebugData(null,0,e),this.props.handle?this.trackReferencedMemory(e,"Buffer"):this.trackAllocatedMemory(e),this}write(e,r=0){let o=ArrayBuffer.isView(e)?e:new Uint8Array(e),n=0,i=void 0,s=36663;this.gl.bindBuffer(s,this.handle),n!==0||i!==void 0?this.gl.bufferSubData(s,r,o,n,i):this.gl.bufferSubData(s,r,o),this.gl.bindBuffer(s,null),this._setDebugData(e,r,e.byteLength)}async mapAndWriteAsync(e,r=0,o=this.byteLength-r){let n=new ArrayBuffer(o);await e(n,"copied"),this.write(n,r)}async readAsync(e=0,r){return this.readSyncWebGL(e,r)}async mapAndReadAsync(e,r=0,o){let n=await this.readAsync(r,o);return await e(n.buffer,"copied")}readSyncWebGL(e=0,r){r=r??this.byteLength-e;let o=new Uint8Array(r),n=0;return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,e,o,n,r),this.gl.bindBuffer(36662,null),this._setDebugData(o,e,r),o}}});function vL(t){let e=t.split(/\r?\n/),r=[];for(let o of e){if(o.length<=1)continue;let n=o.trim(),i=o.split(":"),s=i[0]?.trim();if(i.length===2){let[h,p]=i;if(!h||!p){r.push({message:n,type:Zg(s||"info"),lineNum:0,linePos:0});continue}r.push({message:p.trim(),type:Zg(h),lineNum:0,linePos:0});continue}let[a,c,l,...f]=i;if(!a||!c||!l){r.push({message:i.slice(1).join(":").trim()||n,type:Zg(s||"info"),lineNum:0,linePos:0});continue}let u=parseInt(l,10);Number.isNaN(u)&&(u=0);let d=parseInt(c,10);Number.isNaN(d)&&(d=0),r.push({message:f.join(":").trim(),type:Zg(a),lineNum:u,linePos:d})}return r}function Zg(t){let e=["warning","error","info"],r=t.toLowerCase();return e.includes(r)?r:"info"}var SL=L(()=>{});var Jg,CL=L(()=>{q();SL();Jg=class extends oi{device;handle;constructor(e,r){switch(super(e,r),this.device=e,this.props.stage){case"vertex":this.handle=this.props.handle||this.device.gl.createShader(35633);break;case"fragment":this.handle=this.props.handle||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}e._setWebGLDebugMetadata(this.handle,this,{spector:this.props});let o=this._compile(this.source);o&&typeof o.catch=="function"&&o.catch(()=>{this.compilationStatus="error"})}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0,this.handle.destroyed=!0)}get asyncCompilationStatus(){return this._waitForCompilationComplete().then(()=>(this._getCompilationStatus(),this.compilationStatus))}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){let e=this.device.gl.getShaderInfoLog(this.handle);return e?vL(e):[]}getTranslatedSource(){return this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders?.getTranslatedShaderSource(this.handle)||null}_compile(e){e=e.startsWith("#version ")?e:`#version 300 es ${e}`;let{gl:r}=this.device;if(r.shaderSource(this.handle,e),r.compileShader(this.handle),!this.device.props.debug){this.compilationStatus="pending";return}if(!this.device.features.has("compilation-status-async-webgl")){if(this._getCompilationStatus(),this.debugShader(),this.compilationStatus==="error")throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`);return}return P.once(1,"Shader compilation is asynchronous")(),this._waitForCompilationComplete().then(()=>{P.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()})}async _waitForCompilationComplete(){let e=async n=>await new Promise(i=>setTimeout(i,n));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:o}=this.device;for(;;){if(o.getShaderParameter(this.handle,37297))return;await e(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error"}}});function wL(t,e,r,o){if(TZ(e))return o(t);let n=t;n.pushState();try{return xZ(t,e),ro(n.gl,r),o(t)}finally{n.popState()}}function xZ(t,e){let r=t,{gl:o}=r;if(e.cullMode)switch(e.cullMode){case"none":o.disable(2884);break;case"front":o.enable(2884),o.cullFace(1028);break;case"back":o.enable(2884),o.cullFace(1029);break}if(e.frontFace&&o.frontFace(As("frontFace",e.frontFace,{ccw:2305,cw:2304})),e.unclippedDepth&&t.features.has("depth-clip-control")&&o.enable(34383),e.depthBias!==void 0&&(o.enable(32823),o.polygonOffset(e.depthBias,e.depthBiasSlopeScale||0)),e.provokingVertex&&t.features.has("provoking-vertex-webgl")){let i=r.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,s=As("provokingVertex",e.provokingVertex,{first:36429,last:36430});i?.provokingVertexWEBGL(s)}if((e.polygonMode||e.polygonOffsetLine)&&t.features.has("polygon-mode-webgl")){if(e.polygonMode){let i=r.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,s=As("polygonMode",e.polygonMode,{fill:6914,line:6913});i?.polygonModeWEBGL(1028,s),i?.polygonModeWEBGL(1029,s)}e.polygonOffsetLine&&o.enable(10754)}if(t.features.has("shader-clip-cull-distance-webgl")&&(e.clipDistance0&&o.enable(12288),e.clipDistance1&&o.enable(12289),e.clipDistance2&&o.enable(12290),e.clipDistance3&&o.enable(12291),e.clipDistance4&&o.enable(12292),e.clipDistance5&&o.enable(12293),e.clipDistance6&&o.enable(12294),e.clipDistance7&&o.enable(12295)),e.depthWriteEnabled!==void 0&&o.depthMask(AZ("depthWriteEnabled",e.depthWriteEnabled)),e.depthCompare&&(e.depthCompare!=="always"?o.enable(2929):o.disable(2929),o.depthFunc(e_("depthCompare",e.depthCompare))),e.clearDepth!==void 0&&o.clearDepth(e.clearDepth),e.stencilWriteMask){let n=e.stencilWriteMask;o.stencilMaskSeparate(1028,n),o.stencilMaskSeparate(1029,n)}if(e.stencilReadMask&&P.warn("stencilReadMask not supported under WebGL"),e.stencilCompare){let n=e.stencilReadMask||4294967295,i=e_("depthCompare",e.stencilCompare);e.stencilCompare!=="always"?o.enable(2960):o.disable(2960),o.stencilFuncSeparate(1028,i,0,n),o.stencilFuncSeparate(1029,i,0,n)}if(e.stencilPassOperation&&e.stencilFailOperation&&e.stencilDepthFailOperation){let n=y1("stencilPassOperation",e.stencilPassOperation),i=y1("stencilFailOperation",e.stencilFailOperation),s=y1("stencilDepthFailOperation",e.stencilDepthFailOperation);o.stencilOpSeparate(1028,i,s,n),o.stencilOpSeparate(1029,i,s,n)}switch(e.blend){case!0:o.enable(3042);break;case!1:o.disable(3042);break;default:}if(e.blendColorOperation||e.blendAlphaOperation){let n=EL("blendColorOperation",e.blendColorOperation||"add"),i=EL("blendAlphaOperation",e.blendAlphaOperation||"add");o.blendEquationSeparate(n,i);let s=Qg("blendColorSrcFactor",e.blendColorSrcFactor||"one"),a=Qg("blendColorDstFactor",e.blendColorDstFactor||"zero"),c=Qg("blendAlphaSrcFactor",e.blendAlphaSrcFactor||"one"),l=Qg("blendAlphaDstFactor",e.blendAlphaDstFactor||"zero");o.blendFuncSeparate(s,a,c,l)}}function e_(t,e){return As(t,e,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function y1(t,e){return As(t,e,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function EL(t,e){return As(t,e,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function Qg(t,e,r="color"){return As(t,e,{one:1,zero:0,src:768,"one-minus-src":769,dst:774,"one-minus-dst":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,constant:r==="color"?32769:32771,"one-minus-constant":r==="color"?32770:32772,src1:768,"one-minus-src1":769,"src1-alpha":770,"one-minus-src1-alpha":771})}function bZ(t,e){return`Illegal parameter ${e} for ${t}`}function As(t,e,r){if(!(e in r))throw new Error(bZ(t,e));return r[e]}function AZ(t,e){return e}function TZ(t){let e=!0;for(let r in t){e=!1;break}return e}var x1=L(()=>{q();hc()});function t_(t){let e={};return t.addressModeU&&(e[10242]=b1(t.addressModeU)),t.addressModeV&&(e[10243]=b1(t.addressModeV)),t.addressModeW&&(e[32882]=b1(t.addressModeW)),t.magFilter&&(e[10240]=A1(t.magFilter)),(t.minFilter||t.mipmapFilter)&&(e[10241]=vZ(t.minFilter||"linear",t.mipmapFilter)),t.lodMinClamp!==void 0&&(e[33082]=t.lodMinClamp),t.lodMaxClamp!==void 0&&(e[33083]=t.lodMaxClamp),t.type==="comparison-sampler"&&(e[34892]=34894),t.compare&&(e[34893]=e_("compare",t.compare)),t.maxAnisotropy&&(e[34046]=t.maxAnisotropy),e}function b1(t){switch(t){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function A1(t){switch(t){case"nearest":return 9728;case"linear":return 9729}}function vZ(t,e="none"){if(!e)return A1(t);switch(e){case"none":return A1(t);case"nearest":switch(t){case"nearest":return 9984;case"linear":return 9985}break;case"linear":switch(t){case"nearest":return 9986;case"linear":return 9987}}}var T1=L(()=>{x1()});var r_,PL=L(()=>{q();T1();r_=class extends Pt{device;handle;parameters;constructor(e,r){super(e,r),this.device=e,this.parameters=t_(r),this.handle=r.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(e){for(let[r,o]of Object.entries(e)){let n=Number(r);switch(n){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,n,o);break;default:this.device.gl.samplerParameteri(this.handle,n,o);break}}}}});function Do(t,e,r){if(SZ(e))return r(t);let{nocatch:o=!0}=e,n=oo.get(t);n.push(),ro(t,e);let i;if(o)i=r(t),n.pop();else try{i=r(t)}finally{n.pop()}return i}function SZ(t){for(let e in t)return!1;return!0}var o_=L(()=>{hc();f1()});var Uo,v1=L(()=>{q();Uo=class extends wr{device;gl;handle;texture;constructor(e,r){super(e,{...Y.defaultProps,...r}),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=r.texture}}});function n_(t){return CZ[t]}var CZ,S1=L(()=>{CZ={[5124]:"sint32",[5125]:"uint32",[5122]:"sint16",[5123]:"uint16",[5120]:"sint8",[5121]:"uint8",[5126]:"float32",[5131]:"float16",[33635]:"uint16",[32819]:"uint16",[32820]:"uint16",[33640]:"uint32",[35899]:"uint32",[35902]:"uint32",[34042]:"uint32",[36269]:"uint32"}});function EZ(t,e=0){return e?new t.constructor(t.buffer,t.byteOffset+e,(t.byteLength-e)/t.BYTES_PER_ELEMENT):t}function wZ(t,e){if(e%t.BYTES_PER_ELEMENT!==0)throw new Error(`Texture byteOffset ${e} must align to typed array element size ${t.BYTES_PER_ELEMENT}`);return e/t.BYTES_PER_ELEMENT}function PZ(t){switch(t){case"1d":break;case"2d":return 3553;case"3d":return 32879;case"cube":return 34067;case"2d-array":return 35866;case"cube-array":break}throw new Error(t)}function i_(t,e,r){return e==="cube"?34069+r:t}var ko,s_=L(()=>{q();gc();T1();o_();v1();S1();ko=class extends Y{device;gl;handle;sampler=void 0;view;glTarget;glFormat;glType;glInternalFormat;compressed;_textureUnit=0;_framebuffer=null;_framebufferAttachmentKey=null;constructor(e,r){super(e,r,{byteAlignment:1}),this.device=e,this.gl=this.device.gl;let o=Wg(this.props.format);this.glTarget=PZ(this.props.dimension),this.glInternalFormat=o.internalFormat,this.glFormat=o.format,this.glType=o.type,this.compressed=o.compressed,this.handle=this.props.handle||this.gl.createTexture(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),this.gl.bindTexture(this.glTarget,this.handle);let{dimension:n,width:i,height:s,depth:a,mipLevels:c,glTarget:l,glInternalFormat:f}=this;if(!this.compressed)switch(n){case"2d":case"cube":this.gl.texStorage2D(l,c,f,i,s);break;case"2d-array":case"3d":this.gl.texStorage3D(l,c,f,i,s,a);break;default:throw new Error(n)}this.gl.bindTexture(this.glTarget,null),this._initializeData(r.data),this.props.handle?this.trackReferencedMemory(this.getAllocatedByteLength(),"Texture"):this.trackAllocatedMemory(this.getAllocatedByteLength(),"Texture"),this.setSampler(this.props.sampler),this.view=new Uo(this.device,{...this.props,texture:this}),Object.seal(this)}destroy(){this.handle&&(this._framebuffer?.destroy(),this._framebuffer=null,this._framebufferAttachmentKey=null,this.removeStats(),this.props.handle?this.trackDeallocatedReferencedMemory("Texture"):(this.gl.deleteTexture(this.handle),this.trackDeallocatedMemory("Texture")),this.destroyed=!0)}createView(e){return new Uo(this.device,{...e,texture:this})}setSampler(e={}){super.setSampler(e);let r=t_(this.sampler.props);this._setSamplerParameters(r)}copyExternalImage(e){let r=this._normalizeCopyExternalImageOptions(e);if(r.sourceX||r.sourceY)throw new Error("WebGL does not support sourceX/sourceY)");let{glFormat:o,glType:n}=this,{image:i,depth:s,mipLevel:a,x:c,y:l,z:f,width:u,height:d}=r,h=i_(this.glTarget,this.dimension,f),p=r.flipY?{[37440]:!0}:{};return this.gl.bindTexture(this.glTarget,this.handle),Do(this.gl,p,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(h,a,c,l,u,d,o,n,i);break;case"2d-array":case"3d":this.gl.texSubImage3D(h,a,c,l,f,u,d,s,o,n,i);break;default:}}),this.gl.bindTexture(this.glTarget,null),{width:r.width,height:r.height}}copyImageData(e){super.copyImageData(e)}readBuffer(e={},r){if(!r)throw new Error(`${this} readBuffer requires a destination buffer`);let o=this._getSupportedColorReadOptions(e),n=e.byteOffset??0,i=this.computeMemoryLayout(o);if(r.byteLength<n+i.byteLength)throw new Error(`${this} readBuffer target is too small (${r.byteLength} < ${n+i.byteLength})`);let s=r;this.gl.bindBuffer(35051,s.handle);try{this._readColorTextureLayers(o,i,a=>{this.gl.readPixels(o.x,o.y,o.width,o.height,this.glFormat,this.glType,n+a)})}finally{this.gl.bindBuffer(35051,null)}return r}async readDataAsync(e={}){throw new Error(`${this} readDataAsync is deprecated; use readBuffer() with an explicit destination buffer or DynamicTexture.readAsync()`)}writeBuffer(e,r={}){let o=this._normalizeTextureWriteOptions(r),{width:n,height:i,depthOrArrayLayers:s,mipLevel:a,byteOffset:c,x:l,y:f,z:u}=o,{glFormat:d,glType:h,compressed:p}=this,m=i_(this.glTarget,this.dimension,u);if(p)throw new Error("writeBuffer for compressed textures is not implemented in WebGL");let{bytesPerPixel:g}=this.device.getTextureFormatInfo(this.format),_=g?o.bytesPerRow/g:void 0,x={[3317]:this.byteAlignment,..._!==void 0?{[3314]:_}:{},[32878]:o.rowsPerImage};this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,e.handle),Do(this.gl,x,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(m,a,l,f,n,i,d,h,c);break;case"2d-array":case"3d":this.gl.texSubImage3D(m,a,l,f,u,n,i,s,d,h,c);break;default:}}),this.gl.bindBuffer(35052,null),this.gl.bindTexture(this.glTarget,null)}writeData(e,r={}){let o=this._normalizeTextureWriteOptions(r),n=ArrayBuffer.isView(e)?e:new Uint8Array(e),{width:i,height:s,depthOrArrayLayers:a,mipLevel:c,x:l,y:f,z:u,byteOffset:d}=o,{glFormat:h,glType:p,compressed:m}=this,g=i_(this.glTarget,this.dimension,u),_;if(!m){let{bytesPerPixel:w}=this.device.getTextureFormatInfo(this.format);w&&(_=o.bytesPerRow/w)}let x=this.compressed?{}:{[3317]:this.byteAlignment,..._!==void 0?{[3314]:_}:{},[32878]:o.rowsPerImage},y=wZ(n,d),b=m?EZ(n,d):n,T=this._getMipLevelSize(c),v=l===0&&f===0&&u===0&&i===T.width&&s===T.height&&a===T.depthOrArrayLayers;this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,null),Do(this.gl,x,()=>{switch(this.dimension){case"2d":case"cube":m?v?this.gl.compressedTexImage2D(g,c,h,i,s,0,b):this.gl.compressedTexSubImage2D(g,c,l,f,i,s,h,b):this.gl.texSubImage2D(g,c,l,f,i,s,h,p,n,y);break;case"2d-array":case"3d":m?v?this.gl.compressedTexImage3D(g,c,h,i,s,a,0,b):this.gl.compressedTexSubImage3D(g,c,l,f,u,i,s,a,h,b):this.gl.texSubImage3D(g,c,l,f,u,i,s,a,h,p,n,y);break;default:}}),this.gl.bindTexture(this.glTarget,null)}_getRowByteAlignment(e,r){return 1}_getFramebuffer(){return this._framebuffer||=this.device.createFramebuffer({id:`framebuffer-for-${this.id}`,width:this.width,height:this.height,colorAttachments:[this]}),this._framebuffer}readDataSyncWebGL(e={}){let r=this._getSupportedColorReadOptions(e),o=this.computeMemoryLayout(r),n=n_(this.glType),i=Lf(n),s=new i(o.byteLength/i.BYTES_PER_ELEMENT);return this._readColorTextureLayers(r,o,a=>{let c=new i(s.buffer,s.byteOffset+a,o.bytesPerImage/i.BYTES_PER_ELEMENT);this.gl.readPixels(r.x,r.y,r.width,r.height,this.glFormat,this.glType,c)}),s.buffer}_readColorTextureLayers(e,r,o){let n=this._getFramebuffer(),i=r.bytesPerRow/r.bytesPerPixel,s={[3333]:this.byteAlignment,...i!==e.width?{[3330]:i}:{}},a=this.gl.getParameter(3074),c=this.gl.bindFramebuffer(36160,n.handle);try{this.gl.readBuffer(36064),Do(this.gl,s,()=>{for(let l=0;l<e.depthOrArrayLayers;l++)this._attachReadSubresource(n,e.mipLevel,e.z+l),o(l*r.bytesPerImage)})}finally{this.gl.bindFramebuffer(36160,c||null),this.gl.readBuffer(a)}}_attachReadSubresource(e,r,o){let n=`${r}:${o}`;if(this._framebufferAttachmentKey!==n){switch(this.dimension){case"2d":this.gl.framebufferTexture2D(36160,36064,3553,this.handle,r);break;case"cube":this.gl.framebufferTexture2D(36160,36064,i_(this.glTarget,this.dimension,o),this.handle,r);break;case"2d-array":case"3d":this.gl.framebufferTextureLayer(36160,36064,this.handle,r,o);break;default:throw new Error(`${this} color readback does not support ${this.dimension} textures`)}if(this.device.props.debug){let i=Number(this.gl.checkFramebufferStatus(36160));if(i!==Number(36053))throw new Error(`${e} incomplete for ${this} readback (${i})`)}this._framebufferAttachmentKey=n}}generateMipmapsWebGL(e){if(!(!(this.device.isTextureFormatRenderable(this.props.format)&&this.device.isTextureFormatFilterable(this.props.format))&&(P.warn(`${this} is not renderable or filterable, may not be able to generate mipmaps`)(),!e?.force)))try{this.gl.bindTexture(this.glTarget,this.handle),this.gl.generateMipmap(this.glTarget)}catch(o){P.warn(`Error generating mipmap for ${this}: ${o.message}`)()}finally{this.gl.bindTexture(this.glTarget,null)}}_setSamplerParameters(e){P.log(2,`${this.id} sampler parameters`,this.device.getGLKeys(e))(),this.gl.bindTexture(this.glTarget,this.handle);for(let[r,o]of Object.entries(e)){let n=Number(r),i=o;switch(n){case 33082:case 33083:this.gl.texParameterf(this.glTarget,n,i);break;case 10240:case 10241:this.gl.texParameteri(this.glTarget,n,i);break;case 10242:case 10243:case 32882:this.gl.texParameteri(this.glTarget,n,i);break;case 34046:this.device.features.has("texture-filterable-anisotropic-webgl")&&this.gl.texParameteri(this.glTarget,n,i);break;case 34892:case 34893:this.gl.texParameteri(this.glTarget,n,i);break}}this.gl.bindTexture(this.glTarget,null)}_getActiveUnit(){return this.gl.getParameter(34016)-33984}_bind(e){let{gl:r}=this;return e!==void 0&&(this._textureUnit=e,r.activeTexture(33984+e)),r.bindTexture(this.glTarget,this.handle),e}_unbind(e){let{gl:r}=this;return e!==void 0&&(this._textureUnit=e,r.activeTexture(33984+e)),r.bindTexture(this.glTarget,null),e}}});function ML(t,e,r,o){let n=t,i=o;i===!0&&(i=1),i===!1&&(i=0);let s=typeof i=="number"?[i]:i;switch(r){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if(typeof o!="number")throw new Error("samplers must be set to integers");return t.uniform1i(e,o);case 5126:return t.uniform1fv(e,s);case 35664:return t.uniform2fv(e,s);case 35665:return t.uniform3fv(e,s);case 35666:return t.uniform4fv(e,s);case 5124:return t.uniform1iv(e,s);case 35667:return t.uniform2iv(e,s);case 35668:return t.uniform3iv(e,s);case 35669:return t.uniform4iv(e,s);case 35670:return t.uniform1iv(e,s);case 35671:return t.uniform2iv(e,s);case 35672:return t.uniform3iv(e,s);case 35673:return t.uniform4iv(e,s);case 5125:return n.uniform1uiv(e,s,1);case 36294:return n.uniform2uiv(e,s,2);case 36295:return n.uniform3uiv(e,s,3);case 36296:return n.uniform4uiv(e,s,4);case 35674:return t.uniformMatrix2fv(e,!1,s);case 35675:return t.uniformMatrix3fv(e,!1,s);case 35676:return t.uniformMatrix4fv(e,!1,s);case 35685:return n.uniformMatrix2x3fv(e,!1,s);case 35686:return n.uniformMatrix2x4fv(e,!1,s);case 35687:return n.uniformMatrix3x2fv(e,!1,s);case 35688:return n.uniformMatrix3x4fv(e,!1,s);case 35689:return n.uniformMatrix4x2fv(e,!1,s);case 35690:return n.uniformMatrix4x3fv(e,!1,s)}throw new Error("Illegal uniform")}var RL=L(()=>{});function IL(t){switch(t){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 3;case"triangle-list":return 4;case"triangle-strip":return 5;default:throw new Error(t)}}function LL(t){switch(t){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 1;case"triangle-list":return 4;case"triangle-strip":return 4;default:throw new Error(t)}}var C1=L(()=>{});function MZ(t,e){let r={...t,attributes:t.attributes.map(o=>({...o})),bindings:t.bindings.map(o=>({...o}))};for(let o of e?.attributes||[]){let n=r.attributes.find(i=>i.name===o.name);n?(n.type=o.type||n.type,n.stepMode=o.stepMode||n.stepMode):P.warn(`shader layout attribute ${o.name} not present in shader`)}for(let o of e?.bindings||[]){let n=OL(r,o.name);if(!n){P.warn(`shader layout binding ${o.name} not present in shader`);continue}Object.assign(n,o)}return r}function OL(t,e){return t.bindings.find(r=>r.name===e||r.name===`${e}Uniforms`||`${r.name}Uniforms`===e)}function BL(t,e){return t[e]||t[`${e}Uniforms`]||t[e.replace(/Uniforms$/,"")]}var a_,FL=L(()=>{q();x1();RL();qg();Xg();s_();v1();C1();a_=class extends fr{device;handle;vs;fs;introspectedLayout;bindings={};uniforms={};varyings=null;_uniformCount=0;_uniformSetters={};get[Symbol.toStringTag](){return"WEBGLRenderPipeline"}constructor(e,r){super(e,r),this.device=e;let o=this.sharedRenderPipeline||this.device._createSharedRenderPipelineWebGL(r);this.sharedRenderPipeline=o,this.handle=o.handle,this.vs=o.vs,this.fs=o.fs,this.linkStatus=o.linkStatus,this.introspectedLayout=o.introspectedLayout,this.device._setWebGLDebugMetadata(this.handle,this,{spector:{id:this.props.id}}),this.shaderLayout=r.shaderLayout?MZ(this.introspectedLayout,r.shaderLayout):this.introspectedLayout}destroy(){this.destroyed||(this.sharedRenderPipeline&&!this.props._sharedRenderPipeline&&this.sharedRenderPipeline.destroy(),this.destroyResource())}setBindings(e,r){let o=Dm(If(this.shaderLayout,e));for(let[n,i]of Object.entries(o)){let s=OL(this.shaderLayout,n);if(s){switch(i||P.warn(`Unsetting binding "${n}" in render pipeline "${this.id}"`)(),s.type){case"uniform":if(!(i instanceof io)&&!(i.buffer instanceof io))throw new Error("buffer value");break;case"texture":if(!(i instanceof Uo||i instanceof ko||i instanceof No))throw new Error(`${this} Bad texture binding for ${n}`);break;case"sampler":P.warn(`Ignoring sampler ${n}`)();break;default:throw new Error(s.type)}this.bindings[n]=i}else{let a=this.shaderLayout.bindings.map(c=>`"${c.name}"`).join(", ");r?.disableWarnings||P.warn(`No binding "${n}" in render pipeline "${this.id}", expected one of ${a}`,i)()}}}draw(e){this._syncLinkStatus();let r=e.bindGroups?Dm(e.bindGroups):e.bindings||this.bindings,{renderPass:o,parameters:n=this.props.parameters,topology:i=this.props.topology,vertexArray:s,vertexCount:a,instanceCount:c,isInstanced:l=!1,firstVertex:f=0,transformFeedback:u,uniforms:d=this.uniforms}=e,h=IL(i),p=Boolean(s.indexBuffer),m=s.indexBuffer?.glIndexType;if(this.linkStatus!=="success")return P.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable(r))return P.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;this.device.gl.useProgram(this.handle),s.bindBeforeRender(o),u&&u.begin(this.props.topology),this._applyBindings(r,{disableWarnings:this.props.disableWarnings}),this._applyUniforms(d);let g=o;return wL(this.device,n,g.glParameters,()=>{p&&l?this.device.gl.drawElementsInstanced(h,a||0,m,f,c||0):p?this.device.gl.drawElements(h,a||0,m,f):l?this.device.gl.drawArraysInstanced(h,f,a||0,c||0):this.device.gl.drawArrays(h,f,a||0),u&&u.end()}),s.unbindAfterRender(o),!0}_areTexturesRenderable(e){let r=!0;for(let o of this.shaderLayout.bindings)BL(e,o.name)||(P.warn(`Binding ${o.name} not found in ${this.id}`)(),r=!1);return r}_applyBindings(e,r){if(this._syncLinkStatus(),this.linkStatus!=="success")return;let{gl:o}=this.device;o.useProgram(this.handle);let n=0,i=0;for(let s of this.shaderLayout.bindings){let a=BL(e,s.name);if(!a)throw new Error(`No value for binding ${s.name} in ${this.id}`);switch(s.type){case"uniform":let{name:c}=s,l=o.getUniformBlockIndex(this.handle,c);if(l===4294967295)throw new Error(`Invalid uniform block name ${c}`);if(o.uniformBlockBinding(this.handle,l,i),a instanceof io)o.bindBufferBase(35345,i,a.handle);else{let u=a;o.bindBufferRange(35345,i,u.buffer.handle,u.offset||0,u.size||u.buffer.byteLength-(u.offset||0))}i+=1;break;case"texture":if(!(a instanceof Uo||a instanceof ko||a instanceof No))throw new Error("texture");let f;if(a instanceof Uo)f=a.texture;else if(a instanceof ko)f=a;else if(a instanceof No&&a.colorAttachments[0]instanceof Uo)P.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),f=a.colorAttachments[0].texture;else throw new Error("No texture");o.activeTexture(33984+n),o.bindTexture(f.glTarget,f.handle),n+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${s.type}' not supported in WebGL`)}}}_applyUniforms(e){for(let r of this.shaderLayout.uniforms||[]){let{name:o,location:n,type:i,textureUnit:s}=r,a=e[o]??s;a!==void 0&&ML(this.device.gl,n,i,a)}}_syncLinkStatus(){this.linkStatus=this.sharedRenderPipeline.linkStatus}}});function NL(t){return IZ[t]}function c_(t){return RZ[t]}function l_(t){return Boolean(UL[t])}function DL(t){return UL[t]}var RZ,UL,IZ,f_=L(()=>{RZ={[5126]:"f32",[35664]:"vec2<f32>",[35665]:"vec3<f32>",[35666]:"vec4<f32>",[5124]:"i32",[35667]:"vec2<i32>",[35668]:"vec3<i32>",[35669]:"vec4<i32>",[5125]:"u32",[36294]:"vec2<u32>",[36295]:"vec3<u32>",[36296]:"vec4<u32>",[35670]:"f32",[35671]:"vec2<f32>",[35672]:"vec3<f32>",[35673]:"vec4<f32>",[35674]:"mat2x2<f32>",[35685]:"mat2x3<f32>",[35686]:"mat2x4<f32>",[35687]:"mat3x2<f32>",[35675]:"mat3x3<f32>",[35688]:"mat3x4<f32>",[35689]:"mat4x2<f32>",[35690]:"mat4x3<f32>",[35676]:"mat4x4<f32>"},UL={[35678]:{viewDimension:"2d",sampleType:"float"},[35680]:{viewDimension:"cube",sampleType:"float"},[35679]:{viewDimension:"3d",sampleType:"float"},[35682]:{viewDimension:"3d",sampleType:"depth"},[36289]:{viewDimension:"2d-array",sampleType:"float"},[36292]:{viewDimension:"2d-array",sampleType:"depth"},[36293]:{viewDimension:"cube",sampleType:"float"},[36298]:{viewDimension:"2d",sampleType:"sint"},[36299]:{viewDimension:"3d",sampleType:"sint"},[36300]:{viewDimension:"cube",sampleType:"sint"},[36303]:{viewDimension:"2d-array",sampleType:"uint"},[36306]:{viewDimension:"2d",sampleType:"uint"},[36307]:{viewDimension:"3d",sampleType:"uint"},[36308]:{viewDimension:"cube",sampleType:"uint"},[36311]:{viewDimension:"2d-array",sampleType:"uint"}},IZ={uint8:5121,sint8:5120,unorm8:5121,snorm8:5120,uint16:5123,sint16:5122,unorm16:5123,snorm16:5122,uint32:5125,sint32:5124,float16:5131,float32:5126}});function kL(t,e){let r={attributes:[],bindings:[]};r.attributes=LZ(t,e);let o=FZ(t,e);for(let a of o){let c=a.uniforms.map(l=>({name:l.name,format:l.format,byteOffset:l.byteOffset,byteStride:l.byteStride,arrayLength:l.arrayLength}));r.bindings.push({type:"uniform",name:a.name,group:0,location:a.location,visibility:(a.vertex?1:0)&(a.fragment?2:0),minBindingSize:a.byteLength,uniforms:c})}let n=OZ(t,e),i=0;for(let a of n)if(l_(a.type)){let{viewDimension:c,sampleType:l}=DL(a.type);r.bindings.push({type:"texture",name:a.name,group:0,location:i,viewDimension:c,sampleType:l}),a.textureUnit=i,i+=1}n.length&&(r.uniforms=n);let s=BZ(t,e);return s?.length&&(r.varyings=s),r}function LZ(t,e){let r=[],o=t.getProgramParameter(e,35721);for(let n=0;n<o;n++){let i=t.getActiveAttrib(e,n);if(!i)throw new Error("activeInfo");let{name:s,type:a}=i,c=t.getAttribLocation(e,s);if(c>=0){let l=c_(a),f=/instance/i.test(s)?"instance":"vertex";r.push({name:s,location:c,stepMode:f,type:l})}}return r.sort((n,i)=>n.location-i.location),r}function BZ(t,e){let r=[],o=t.getProgramParameter(e,35971);for(let n=0;n<o;n++){let i=t.getTransformFeedbackVarying(e,n);if(!i)throw new Error("activeInfo");let{name:s,type:a,size:c}=i,l=c_(a),{type:f,components:u}=ja(l);r.push({location:n,name:s,type:f,size:c*u})}return r.sort((n,i)=>n.location-i.location),r}function OZ(t,e){let r=[],o=t.getProgramParameter(e,35718);for(let n=0;n<o;n++){let i=t.getActiveUniform(e,n);if(!i)throw new Error("activeInfo");let{name:s,size:a,type:c}=i,{name:l,isArray:f}=NZ(s),u=t.getUniformLocation(e,l),d={location:u,name:l,size:a,type:c,isArray:f};if(r.push(d),d.size>1)for(let h=0;h<d.size;h++){let p=`${l}[${h}]`;u=t.getUniformLocation(e,p);let m={...d,name:p,location:u};r.push(m)}}return r}function FZ(t,e){let r=(i,s)=>t.getActiveUniformBlockParameter(e,i,s),o=[],n=t.getProgramParameter(e,35382);for(let i=0;i<n;i++){let s={name:t.getActiveUniformBlockName(e,i)||"",location:r(i,35391),byteLength:r(i,35392),vertex:r(i,35396),fragment:r(i,35398),uniformCount:r(i,35394),uniforms:[]},a=r(i,35395)||[],c=t.getActiveUniforms(e,a,35383),l=t.getActiveUniforms(e,a,35384),f=t.getActiveUniforms(e,a,35387),u=t.getActiveUniforms(e,a,35388);for(let p=0;p<s.uniformCount;++p){let m=a[p];if(m!==void 0){let g=t.getActiveUniform(e,m);if(!g)throw new Error("activeInfo");let _=c_(c[p]);s.uniforms.push({name:g.name,format:_,type:c[p],arrayLength:l[p],byteOffset:f[p],byteStride:u[p]})}}let d=new Set(s.uniforms.map(p=>p.name.split(".")[0]).filter(p=>Boolean(p))),h=s.name.replace(/Uniforms$/,"");if(d.size===1&&!d.has(s.name)&&!d.has(h)){let[p]=d;P.warn(`Uniform block "${s.name}" uses GLSL instance "${p}". luma.gl binds uniform buffers by block name ("${s.name}") and alias ("${h}"). Prefer matching the instance name to one of those to avoid confusing silent mismatches.`)()}o.push(s)}return o.sort((i,s)=>i.location-s.location),o}function NZ(t){if(t[t.length-1]!=="]")return{name:t,length:1,isArray:!1};let r=/([^[]*)(\[[0-9]+\])?/.exec(t);return{name:os(r?.[1],`Failed to parse GLSL uniform name ${t}`),length:r?.[2]?1:0,isArray:Boolean(r?.[2])}}var VL=L(()=>{q();f_()});var zL,u_,HL=L(()=>{q();VL();f_();zL=4,u_=class extends Rf{device;handle;vs;fs;introspectedLayout={attributes:[],bindings:[],uniforms:[]};linkStatus="pending";constructor(e,r){super(e,r),this.device=e,this.handle=r.handle||this.device.gl.createProgram(),this.vs=r.vs,this.fs=r.fs,r.varyings&&r.varyings.length>0&&this.device.gl.transformFeedbackVaryings(this.handle,r.varyings,r.bufferMode||35981),this._linkShaders(),P.time(3,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=kL(this.device.gl,this.handle),P.timeEnd(3,`RenderPipeline ${this.id} - shaderLayout introspection`)()}destroy(){this.destroyed||(this.device.gl.useProgram(null),this.device.gl.deleteProgram(this.handle),this.handle.destroyed=!0,this.destroyResource())}async _linkShaders(){let{gl:e}=this.device;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),P.time(zL,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),P.timeEnd(zL,`linkProgram for ${this.id}`)(),!this.device.features.has("compilation-status-async-webgl")){let o=this._getLinkStatus();this._reportLinkStatus(o);return}P.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),P.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();let r=this._getLinkStatus();this._reportLinkStatus(r)}async _reportLinkStatus(e){switch(e){case"success":return;default:let r=e==="link-error"?"Link error":"Validation error";switch(this.vs.compilationStatus){case"error":throw this.vs.debugShader(),new Error(`${this} ${r} during compilation of ${this.vs}`);case"pending":await this.vs.asyncCompilationStatus,this.vs.debugShader();break;case"success":break}switch(this.fs?.compilationStatus){case"error":throw this.fs.debugShader(),new Error(`${this} ${r} during compilation of ${this.fs}`);case"pending":await this.fs.asyncCompilationStatus,this.fs.debugShader();break;case"success":break}let o=this.device.gl.getProgramInfoLog(this.handle);this.device.reportError(new Error(`${r} during ${e}: ${o}`),this)(),this.device.debug()}}_getLinkStatus(){let{gl:e}=this.device;return e.getProgramParameter(this.handle,35714)?(this._initializeSamplerUniforms(),e.validateProgram(this.handle),e.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation-error")):(this.linkStatus="error","link-error")}_initializeSamplerUniforms(){let{gl:e}=this.device;e.useProgram(this.handle);let r=0,o=e.getProgramParameter(this.handle,35718);for(let n=0;n<o;n++){let i=e.getActiveUniform(this.handle,n);if(i&&l_(i.type)){let s=i.name.endsWith("[0]"),a=s?i.name.slice(0,-3):i.name,c=e.getUniformLocation(this.handle,a);c!==null&&(r=this._assignSamplerUniform(c,i,s,r))}}}_assignSamplerUniform(e,r,o,n){let{gl:i}=this.device;if(o&&r.size>1){let s=Int32Array.from({length:r.size},(a,c)=>n+c);return i.uniform1iv(e,s),n+r.size}return i.uniform1i(e,n),n+1}async _waitForLinkComplete(){let e=async n=>await new Promise(i=>setTimeout(i,n));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:o}=this.device;for(;;){if(o.getProgramParameter(this.handle,37297))return;await e(10)}}}});function DZ(t,e){let r=e.sourceBuffer,o=e.destinationBuffer;t.gl.bindBuffer(36662,r.handle),t.gl.bindBuffer(36663,o.handle),t.gl.copyBufferSubData(36662,36663,e.sourceOffset??0,e.destinationOffset??0,e.size),t.gl.bindBuffer(36662,null),t.gl.bindBuffer(36663,null)}function UZ(t,e){throw new Error("copyBufferToTexture is not supported in WebGL")}function kZ(t,e){let{sourceTexture:r,mipLevel:o=0,aspect:n="all",width:i=e.sourceTexture.width,height:s=e.sourceTexture.height,depthOrArrayLayers:a,origin:c=[0,0,0],destinationBuffer:l,byteOffset:f=0,bytesPerRow:u,rowsPerImage:d}=e;if(r instanceof Y){r.readBuffer({x:c[0]??0,y:c[1]??0,z:c[2]??0,width:i,height:s,depthOrArrayLayers:a,mipLevel:o,aspect:n,byteOffset:f},l);return}if(n!=="all")throw new Error("aspect not supported in WebGL");if(o!==0||a!==void 0||u||d)throw new Error("not implemented");let{framebuffer:h,destroyFramebuffer:p}=jL(r),m;try{let g=l,_=i||h.width,x=s||h.height,y=os(h.colorAttachments[0]),b=Wg(y.texture.props.format),T=b.format,v=b.type;t.gl.bindBuffer(35051,g.handle),m=t.gl.bindFramebuffer(36160,h.handle),t.gl.readPixels(c[0],c[1],_,x,T,v,f)}finally{t.gl.bindBuffer(35051,null),m!==void 0&&t.gl.bindFramebuffer(36160,m),p&&h.destroy()}}function VZ(t,e){let{sourceTexture:r,destinationMipLevel:o=0,origin:n=[0,0],destinationOrigin:i=[0,0,0],destinationTexture:s}=e,{width:a=e.destinationTexture.width,height:c=e.destinationTexture.height}=e,{framebuffer:l,destroyFramebuffer:f}=jL(r),[u=0,d=0]=n,[h,p,m]=i,g=t.gl.bindFramebuffer(36160,l.handle),_,x;if(s instanceof ko)_=s,a=Number.isFinite(a)?a:_.width,c=Number.isFinite(c)?c:_.height,_._bind(0),x=_.glTarget;else throw new Error("invalid destination");switch(x){case 3553:case 34067:t.gl.copyTexSubImage2D(x,o,h,p,u,d,a,c);break;case 35866:case 32879:t.gl.copyTexSubImage3D(x,o,h,p,m,u,d,a,c);break;default:}_&&_._unbind(),t.gl.bindFramebuffer(36160,g),f&&l.destroy()}function jL(t){if(t instanceof Y){let{width:e,height:r,id:o}=t;return{framebuffer:t.device.createFramebuffer({id:`framebuffer-for-${o}`,width:e,height:r,colorAttachments:[t]}),destroyFramebuffer:!0}}return{framebuffer:t,destroyFramebuffer:!1}}var d_,WL=L(()=>{q();gc();s_();d_=class extends Ha{device;handle=null;commands=[];constructor(e,r={}){super(e,r),this.device=e}_executeCommands(e=this.commands){for(let r of e)switch(r.name){case"copy-buffer-to-buffer":DZ(this.device,r.options);break;case"copy-buffer-to-texture":UZ(this.device,r.options);break;case"copy-texture-to-buffer":kZ(this.device,r.options);break;case"copy-texture-to-texture":VZ(this.device,r.options);break;default:throw new Error(r.name)}}}});var zZ,h_,$L=L(()=>{q();o_();hc();zZ=[1,2,4,8],h_=class extends on{device;handle=null;glParameters={};constructor(e,r){super(e,r),this.device=e;let o=this.props.framebuffer,n=!o||o.handle===null;n&&e.getDefaultCanvasContext()._resizeDrawingBufferIfNeeded();let i;if(!r?.parameters?.viewport)if(!n&&o){let{width:s,height:a}=o;i=[0,0,s,a]}else{let[s,a]=e.getDefaultCanvasContext().getDrawingBufferSize();i=[0,0,s,a]}if(this.device.pushState(),this.setParameters({viewport:i,...this.props.parameters}),!n&&o?.colorAttachments.length){let s=o.colorAttachments.map((a,c)=>36064+c);this.device.gl.drawBuffers(s)}else n&&this.device.gl.drawBuffers([1029]);this.clear(),this.props.timestampQuerySet&&this.props.beginTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.beginTimestampIndex)}end(){this.destroyed||(this.props.timestampQuerySet&&this.props.endTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.endTimestampIndex),this.device.popState(),this.destroy())}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}setParameters(e={}){let r={...this.glParameters};r.framebuffer=this.props.framebuffer||null,this.props.depthReadOnly&&(r.depthMask=!this.props.depthReadOnly),r.stencilMask=this.props.stencilReadOnly?0:1,r[35977]=this.props.discard,e.viewport&&(e.viewport.length>=6?(r.viewport=e.viewport.slice(0,4),r.depthRange=[e.viewport[4],e.viewport[5]]):r.viewport=e.viewport),e.scissorRect&&(r.scissorTest=!0,r.scissor=e.scissorRect),e.blendConstant&&(r.blendColor=e.blendConstant),e.stencilReference!==void 0&&(r[2967]=e.stencilReference,r[36003]=e.stencilReference),"colorMask"in e&&(r.colorMask=zZ.map(o=>Boolean(o&e.colorMask))),this.glParameters=r,ro(this.device.gl,r)}beginOcclusionQuery(e){this.props.occlusionQuerySet?.beginOcclusionQuery()}endOcclusionQuery(){this.props.occlusionQuerySet?.endOcclusionQuery()}clear(){let e={...this.glParameters},r=0;this.props.clearColors&&this.props.clearColors.forEach((o,n)=>{o&&this.clearColorBuffer(n,o)}),this.props.clearColor!==!1&&this.props.clearColors===void 0&&(r|=16384,e.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(r|=256,e.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(r|=1024,e.clearStencil=this.props.clearStencil),r!==0&&Do(this.device.gl,e,()=>{this.device.gl.clear(r)})}clearColorBuffer(e=0,r=[0,0,0,0]){Do(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(r.constructor){case Int8Array:case Int16Array:case Int32Array:this.device.gl.clearBufferiv(6144,e,r);break;case Uint8Array:case Uint8ClampedArray:case Uint16Array:case Uint32Array:this.device.gl.clearBufferuiv(6144,e,r);break;case Float32Array:this.device.gl.clearBufferfv(6144,e,r);break;default:throw new Error("clearColorBuffer: color must be typed array")}})}}});var bu,XL=L(()=>{q();WL();$L();bu=class extends za{device;handle=null;commandBuffer;constructor(e,r){super(e,r),this.device=e,this.commandBuffer=new d_(e,{id:`${this.props.id}-command-buffer`})}destroy(){this.destroyResource()}finish(e){return e?.id&&this.commandBuffer.id!==e.id&&(this.commandBuffer.id=e.id,this.commandBuffer.props.id=e.id),this.destroy(),this.commandBuffer}beginRenderPass(e={}){return new h_(this.device,this._applyTimeProfilingToPassProps(e))}beginComputePass(e={}){throw new Error("ComputePass not supported in WebGL")}copyBufferToBuffer(e){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:e})}copyBufferToTexture(e){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:e})}copyTextureToBuffer(e){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:e})}copyTextureToTexture(e){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:e})}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}resolveQuerySet(e,r,o){throw new Error("resolveQuerySet is not supported in WebGL")}writeTimestamp(e,r){e.writeTimestamp(r)}}});function YL(t){let{target:e,source:r,start:o=0,count:n=1}=t,i=r.length,s=n*i,a=0;for(let c=o;a<i;a++)e[c++]=r[a]??0;for(;a<s;)a<s-a?(e.copyWithin(o+a,o,o+a),a*=2):(e.copyWithin(o+a,o,o+s-a),a=s);return t.target}var KL=L(()=>{});function HZ(t){return Array.isArray(t)?new Float32Array(t):t}function jZ(t,e){if(!t||!e||t.length!==e.length||t.constructor!==e.constructor)return!1;for(let r=0;r<t.length;++r)if(t[r]!==e[r])return!1;return!0}var _c,qL=L(()=>{q();Vn();u1();KL();_c=class extends Wa{get[Symbol.toStringTag](){return"VertexArray"}device;handle;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(e){return bb()==="Chrome"}constructor(e,r){super(e,r),this.device=e,this.handle=this.device.gl.createVertexArray()}destroy(){super.destroy(),this.buffer&&this.buffer?.destroy(),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(e){let r=e;if(r&&r.glTarget!==34963)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,r?r.handle:null),this.indexBuffer=r,this.device.gl.bindVertexArray(null)}setBuffer(e,r){let o=r;if(o.glTarget===34963)throw new Error("Use .setIndexBuffer()");let{size:n,type:i,stride:s,offset:a,normalized:c,integer:l,divisor:f}=this._getAccessor(e);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,o.handle),l?this.device.gl.vertexAttribIPointer(e,n,i,s,a):this.device.gl.vertexAttribPointer(e,n,i,c,s,a),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(e),this.device.gl.vertexAttribDivisor(e,f||0),this.attributes[e]=o,this.device.gl.bindVertexArray(null)}setConstantWebGL(e,r){this._enable(e,!1),this.attributes[e]=r}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let e=0;e<this.maxVertexAttributes;++e){let r=this.attributes[e];ArrayBuffer.isView(r)&&this.device.setConstantAttributeWebGL(e,r)}}_getAccessor(e){let r=this.attributeInfos[e];if(!r)throw new Error(`Unknown attribute location ${e}`);let o=Vg(r.bufferDataType);return{size:r.bufferComponents,type:o,stride:r.byteStride,offset:r.byteOffset,normalized:r.normalized,integer:r.integer,divisor:r.stepMode==="instance"?1:0}}_enable(e,r=!0){let n=_c.isConstantAttributeZeroSupported(this.device)||e!==0;(r||n)&&(e=Number(e),this.device.gl.bindVertexArray(this.handle),r?this.device.gl.enableVertexAttribArray(e):this.device.gl.disableVertexAttribArray(e),this.device.gl.bindVertexArray(null))}getConstantBuffer(e,r){let o=HZ(r),n=o.byteLength*e,i=o.length*e;if(this.buffer&&n!==this.buffer.byteLength)throw new Error(`Buffer size is immutable, byte length ${n} !== ${this.buffer.byteLength}.`);let s=!this.buffer;if(this.buffer=this.buffer||this.device.createBuffer({byteLength:n}),s||=!jZ(o,this.bufferValue),s){let a=uv(r.constructor,i);YL({target:a,source:o,start:0,count:i}),this.buffer.write(a),this.bufferValue=r}return this.buffer}}});function ZL(t){return typeof t=="number"?Number.isInteger(t):/^\d+$/.test(t)}var p_,JL=L(()=>{q();Au();C1();p_=class extends Ga{device;gl;handle;layout;buffers={};unusedBuffers={};bindOnUse=!0;_bound=!1;constructor(e,r){super(e,r),this.device=e,this.gl=e.gl,this.handle=this.props.handle||this.gl.createTransformFeedback(),this.layout=this.props.layout,r.buffers&&this.setBuffers(r.buffers),Object.seal(this)}destroy(){this.gl.deleteTransformFeedback(this.handle),super.destroy()}begin(e="point-list"){this.gl.bindTransformFeedback(36386,this.handle),this.bindOnUse&&this._bindBuffers(),this.gl.beginTransformFeedback(LL(e))}end(){this.gl.endTransformFeedback(),this.bindOnUse&&this._unbindBuffers(),this.gl.bindTransformFeedback(36386,null)}setBuffers(e){this.buffers={},this.unusedBuffers={},this.bind(()=>{for(let[r,o]of Object.entries(e))this.setBuffer(r,o)})}setBuffer(e,r){let o=this._getVaryingIndex(e),{buffer:n,byteLength:i,byteOffset:s}=this._getBufferRange(r);if(o<0){this.unusedBuffers[e]=n,P.warn(`${this.id} unusedBuffers varying buffer ${e}`)();return}this.buffers[o]={buffer:n,byteLength:i,byteOffset:s},this.bindOnUse||this._bindBuffer(o,n,s,i)}getBuffer(e){if(ZL(e))return this.buffers[e]||null;let r=this._getVaryingIndex(e);return this.buffers[r]??null}bind(e=this.handle){if(typeof e!="function")return this.gl.bindTransformFeedback(36386,e),this;let r;return this._bound?r=e():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,r=e(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),r}unbind(){this.bind(null)}_getBufferRange(e){if(e instanceof io)return{buffer:e,byteOffset:0,byteLength:e.byteLength};let{buffer:r,byteOffset:o=0,byteLength:n=e.buffer.byteLength}=e;return{buffer:r,byteOffset:o,byteLength:n}}_getVaryingIndex(e){if(ZL(e))return Number(e);for(let r of this.layout.varyings||[])if(e===r.name)return r.location;return-1}_bindBuffers(){for(let[e,r]of Object.entries(this.buffers)){let{buffer:o,byteLength:n,byteOffset:i}=this._getBufferRange(r);this._bindBuffer(Number(e),o,i,n)}}_unbindBuffers(){for(let e in this.buffers)this.gl.bindBufferBase(35982,Number(e),null)}_bindBuffer(e,r,o=0,n){let i=r&&r.handle;!i||n===void 0?this.gl.bindBufferBase(35982,e,i):this.gl.bindBufferRange(35982,e,i,o,n)}}});var m_,QL=L(()=>{q();m_=class extends $a{device;handle;_timestampPairs=[];_pendingReads=new Set;_occlusionQuery=null;_occlusionActive=!1;get[Symbol.toStringTag](){return"QuerySet"}constructor(e,r){if(super(e,r),this.device=e,r.type==="timestamp"){if(r.count<2)throw new Error("Timestamp QuerySet requires at least two query slots");this._timestampPairs=new Array(Math.ceil(r.count/2)).fill(null).map(()=>({activeQuery:null,completedQueries:[]})),this.handle=null}else{if(r.count>1)throw new Error("WebGL occlusion QuerySet can only have one value");let o=this.device.gl.createQuery();if(!o)throw new Error("WebGL query not supported");this.handle=o}Object.seal(this)}destroy(){if(!this.destroyed){this.handle&&this.device.gl.deleteQuery(this.handle);for(let e of this._timestampPairs){e.activeQuery&&(this._cancelPendingQuery(e.activeQuery),this.device.gl.deleteQuery(e.activeQuery.handle));for(let r of e.completedQueries)this._cancelPendingQuery(r),this.device.gl.deleteQuery(r.handle)}this._occlusionQuery&&(this._cancelPendingQuery(this._occlusionQuery),this.device.gl.deleteQuery(this._occlusionQuery.handle));for(let e of Array.from(this._pendingReads))this._cancelPendingQuery(e);this.destroyResource()}}isResultAvailable(e){return this.props.type==="timestamp"?e===void 0?this._timestampPairs.some((r,o)=>this._isTimestampPairAvailable(o)):this._isTimestampPairAvailable(this._getTimestampPairIndex(e)):this._occlusionQuery?this._pollQueryAvailability(this._occlusionQuery):!1}async readResults(e){let r=e?.firstQuery||0,o=e?.queryCount||this.props.count-r;if(this._validateRange(r,o),this.props.type==="timestamp"){let n=new Array(o).fill(0n),i=Math.floor(r/2),s=Math.floor((r+o-1)/2);for(let a=i;a<=s;a++){let c=await this._consumeTimestampPairResult(a),l=a*2,f=l+1;l>=r&&l<r+o&&(n[l-r]=0n),f>=r&&f<r+o&&(n[f-r]=c)}return n}if(!this._occlusionQuery)throw new Error("Occlusion query has not been started");return[await this._consumeQueryResult(this._occlusionQuery)]}async readTimestampDuration(e,r){if(this.props.type!=="timestamp")throw new Error("Timestamp durations require a timestamp QuerySet");if(e<0||r>=this.props.count||r<=e)throw new Error("Timestamp duration range is out of bounds");if(e%2!==0||r!==e+1)throw new Error("WebGL timestamp durations require adjacent even/odd query indices");let o=await this._consumeTimestampPairResult(this._getTimestampPairIndex(e));return Number(o)/1e6}beginOcclusionQuery(){if(this.props.type!=="occlusion")throw new Error("Occlusion queries require an occlusion QuerySet");if(!this.handle)throw new Error("WebGL occlusion query is not available");if(this._occlusionActive)throw new Error("Occlusion query is already active");this.device.gl.beginQuery(35887,this.handle),this._occlusionQuery={handle:this.handle,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null},this._occlusionActive=!0}endOcclusionQuery(){if(!this._occlusionActive)throw new Error("Occlusion query is not active");this.device.gl.endQuery(35887),this._occlusionActive=!1}writeTimestamp(e){if(this.props.type!=="timestamp")throw new Error("Timestamp writes require a timestamp QuerySet");let r=this._getTimestampPairIndex(e),o=this._timestampPairs[r];if(e%2===0){if(o.activeQuery)throw new Error("Timestamp query pair is already active");let n=this.device.gl.createQuery();if(!n)throw new Error("WebGL query not supported");let i={handle:n,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null};this.device.gl.beginQuery(35007,n),o.activeQuery=i;return}if(!o.activeQuery)throw new Error("Timestamp query pair was ended before it was started");this.device.gl.endQuery(35007),o.completedQueries.push(o.activeQuery),o.activeQuery=null}_validateRange(e,r){if(e<0||r<0||e+r>this.props.count)throw new Error("Query read range is out of bounds")}_getTimestampPairIndex(e){if(e<0||e>=this.props.count)throw new Error("Query index is out of bounds");return Math.floor(e/2)}_isTimestampPairAvailable(e){let r=this._timestampPairs[e];return!r||r.completedQueries.length===0?!1:this._pollQueryAvailability(r.completedQueries[0])}_pollQueryAvailability(e){if(e.cancelled||this.destroyed)return e.result=0n,!0;if(e.result!==null||e.disjoint)return!0;if(!this.device.gl.getQueryParameter(e.handle,34919))return!1;let o=Boolean(this.device.gl.getParameter(36795));return e.disjoint=o,e.result=o?0n:BigInt(this.device.gl.getQueryParameter(e.handle,34918)),!0}async _consumeTimestampPairResult(e){let r=this._timestampPairs[e];if(!r||r.completedQueries.length===0)throw new Error("Timestamp query pair has no completed result");let o=r.completedQueries.shift();try{return await this._consumeQueryResult(o)}finally{this.device.gl.deleteQuery(o.handle)}}_consumeQueryResult(e){return e.promise||(this._pendingReads.add(e),e.promise=new Promise((r,o)=>{e.resolve=r,e.reject=o;let n=()=>{if(e.pollRequestId=null,e.cancelled||this.destroyed){this._pendingReads.delete(e),e.promise=null,e.resolve=null,e.reject=null,r(0n);return}if(!this._pollQueryAvailability(e)){e.pollRequestId=this._requestAnimationFrame(n);return}this._pendingReads.delete(e),e.promise=null,e.resolve=null,e.reject=null,e.disjoint?o(new Error("GPU timestamp query was invalidated by a disjoint event")):r(e.result||0n)};n()})),e.promise}_cancelPendingQuery(e){if(this._pendingReads.delete(e),e.cancelled=!0,e.pollRequestId!==null&&(this._cancelAnimationFrame(e.pollRequestId),e.pollRequestId=null),e.resolve){let r=e.resolve;e.promise=null,e.resolve=null,e.reject=null,r(0n)}}_requestAnimationFrame(e){return requestAnimationFrame(e)}_cancelAnimationFrame(e){cancelAnimationFrame(e)}}});var g_,eB=L(()=>{q();g_=class extends Xa{device;gl;handle;signaled;_signaled=!1;constructor(e,r={}){super(e,{}),this.device=e,this.gl=e.gl;let o=this.props.handle||this.gl.fenceSync(this.gl.SYNC_GPU_COMMANDS_COMPLETE,0);if(!o)throw new Error("Failed to create WebGL fence");this.handle=o,this.signaled=new Promise(n=>{let i=()=>{let s=this.gl.clientWaitSync(this.handle,0,0);s===this.gl.ALREADY_SIGNALED||s===this.gl.CONDITION_SATISFIED?(this._signaled=!0,n()):setTimeout(i,1)};i()})}isSignaled(){if(this._signaled)return!0;let e=this.gl.getSyncParameter(this.handle,this.gl.SYNC_STATUS);return this._signaled=e===this.gl.SIGNALED,this._signaled}destroy(){this.destroyed||this.gl.deleteSync(this.handle)}}});function E1(t){switch(t){case 6406:case 33326:case 6403:case 36244:return 1;case 33339:case 33340:case 33328:case 33320:case 33319:return 2;case 6407:case 36248:case 34837:return 3;case 6408:case 36249:case 34836:return 4;default:return 0}}function tB(t){switch(t){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return 0}}var rB=L(()=>{});function oB(t,e){let{sourceX:r=0,sourceY:o=0,sourceAttachment:n=0}=e||{},{target:i=null,sourceWidth:s,sourceHeight:a,sourceDepth:c,sourceFormat:l,sourceType:f}=e||{},{framebuffer:u,deleteFramebuffer:d}=iB(t),{gl:h,handle:p}=u;s||=u.width,a||=u.height;let m=u.colorAttachments[n]?.texture;if(!m)throw new Error(`Invalid framebuffer attachment ${n}`);c=m?.depth||1,l||=m?.glFormat||6408,f||=m?.glType||5121,i=GZ(i,f,l,s,a,c);let g=Dt.getDataType(i);f=f||NL(g);let _=h.bindFramebuffer(36160,p);return h.readBuffer(36064+n),h.readPixels(r,o,s,a,l,f,i),h.readBuffer(36064),h.bindFramebuffer(36160,_||null),d&&u.destroy(),i}function nB(t,e){let{target:r,sourceX:o=0,sourceY:n=0,sourceFormat:i=6408,targetByteOffset:s=0}=e||{},{sourceWidth:a,sourceHeight:c,sourceType:l}=e||{},{framebuffer:f,deleteFramebuffer:u}=iB(t);a=a||f.width,c=c||f.height;let d=f;l=l||5121;let h=r;if(!h){let m=E1(i),g=tB(l),_=s+a*c*m*g;h=d.device.createBuffer({byteLength:_})}let p=t.device.createCommandEncoder();return p.copyTextureToBuffer({sourceTexture:t,width:a,height:c,origin:[o,n],destinationBuffer:h,byteOffset:s}),p.destroy(),u&&f.destroy(),h}function iB(t){return t instanceof Eo?{framebuffer:t,deleteFramebuffer:!1}:{framebuffer:WZ(t),deleteFramebuffer:!0}}function WZ(t,e){let{device:r,width:o,height:n,id:i}=t;return r.createFramebuffer({...e,id:`framebuffer-for-${i}`,width:o,height:n,colorAttachments:[t]})}function GZ(t,e,r,o,n,i){if(t)return t;e||=5121;let s=n_(e),a=Dt.getTypedArrayConstructor(s),c=E1(r);return new a(o*n*c)}var sB=L(()=>{q();f_();rB();S1()});var w1={};ze(w1,{WebGLDevice:()=>Zt});function $Z(t,e,r){switch(r.length){case 1:t.gl.vertexAttrib1fv(e,r);break;case 2:t.gl.vertexAttrib2fv(e,r);break;case 3:t.gl.vertexAttrib3fv(e,r);break;case 4:t.gl.vertexAttrib4fv(e,r);break;default:}}function XZ(t,e,r){t.gl.vertexAttribI4iv(e,r)}function YZ(t,e,r){t.gl.vertexAttribI4uiv(e,r)}function KZ(t,e){if(!t||!e||t.length!==e.length||t.constructor!==e.constructor)return!1;for(let r=0;r<t.length;++r)if(t[r]!==e[r])return!1;return!0}var Zt,__=L(()=>{q();f1();sL();Dg();lL();_L();yL();xL();bL();n1();i1();gc();TL();qg();CL();PL();s_();Xg();FL();HL();XL();qL();JL();QL();eB();sB();hc();o_();_u();Zt=class extends Xt{static getDeviceFromContext(e){return e?e.luma?.device??null:null}type="webgl";handle;features;limits;info;canvasContext;preferredColorFormat="rgba8unorm";preferredDepthFormat="depth24plus";commandEncoder;lost;_resolveContextLost;gl;_constants;extensions;_polyfilled=!1;spectorJS;get[Symbol.toStringTag](){return"WebGLDevice"}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}isVertexFormatSupported(e){switch(e){case"unorm8x4-bgra":return!1;default:return!0}}constructor(e){super({...e,id:e.id||AL("webgl-device")});let r=Xt._getCanvasContextProps(e);if(!r)throw new Error("WebGLDevice requires props.createCanvasContext to be set");let o=r.canvas?.gl??null,n=Zt.getDeviceFromContext(o);if(n)throw new Error(`WebGL context already attached to device ${n.id}`);this.canvasContext=new Yg(this,r),this.lost=new Promise(f=>{this._resolveContextLost=f});let i={...e.webgl};r.alphaMode==="premultiplied"&&(i.premultipliedAlpha=!0),e.powerPreference!==void 0&&(i.powerPreference=e.powerPreference),e.failIfMajorPerformanceCaveat!==void 0&&(i.failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat);let a=this.props._handle||iL(this.canvasContext.canvas,{onContextLost:f=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."}),onContextRestored:f=>console.log("WebGL context restored")},i);if(!a)throw new Error("WebGL context creation failed");if(n=Zt.getDeviceFromContext(a),n){if(e._reuseDevices)return P.log(1,`Not creating a new Device, instead returning a reference to Device ${n.id} already attached to WebGL context`,n)(),this.canvasContext.destroy(),n._reused=!0,n;throw new Error(`WebGL context already attached to device ${n.id}`)}this.handle=a,this.gl=a,this.spectorJS=W3({...this.props,gl:this.handle});let c=bs(this.handle);c.device=this,c.extensions||(c.extensions={}),this.extensions=c.extensions,this.info=aL(this.gl,this.extensions),this.limits=new $g(this.gl),this.features=new Gg(this.gl,this.extensions,this.props._disabledFeatures),this.props._initializeFeatures&&this.features.initializeFeatures(),new oo(this.gl,{log:(...f)=>P.log(1,...f)()}).trackState(this.gl,{copyState:!1}),(e.debug||e.debugWebGL)&&(this.gl=Y3(this.gl,{debugWebGL:!0,traceWebGL:e.debugWebGL}),P.warn("WebGL debug mode activated. Performance reduced.")()),e.debugWebGL&&(P.level=Math.max(P.level,1)),this.commandEncoder=new bu(this,{id:`${this}-command-encoder`}),this.canvasContext._startObservers()}destroy(){if(this.commandEncoder?.destroy(),!this.props._reuseDevices&&!this._reused){let e=bs(this.handle);e.device=null}}get isLost(){return this.gl.isContextLost()}createCanvasContext(e){throw new Error("WebGL only supports a single canvas")}createPresentationContext(e){return new Kg(this,e||{})}createBuffer(e){let r=this._normalizeBufferProps(e);return new io(this,r)}createTexture(e){return new ko(this,e)}createExternalTexture(e){throw new Error("createExternalTexture() not implemented")}createSampler(e){return new r_(this,e)}createShader(e){return new Jg(this,e)}createFramebuffer(e){return new No(this,e)}createVertexArray(e){return new _c(this,e)}createTransformFeedback(e){return new p_(this,e)}createQuerySet(e){return new m_(this,e)}createFence(){return new g_(this)}createRenderPipeline(e){return new a_(this,e)}_createSharedRenderPipelineWebGL(e){return new u_(this,e)}createComputePipeline(e){throw new Error("ComputePipeline not supported in WebGL")}createCommandEncoder(e={}){return new bu(this,e)}submit(e){let r=null;e||({submittedCommandEncoder:r,commandBuffer:e}=this._finalizeDefaultCommandEncoderForSubmit());try{e._executeCommands(),r&&r.resolveTimeProfilingQuerySet().then(()=>{this.commandEncoder._gpuTimeMs=r._gpuTimeMs}).catch(()=>{})}finally{e.destroy()}}_finalizeDefaultCommandEncoderForSubmit(){let e=this.commandEncoder,r=e.finish();return this.commandEncoder.destroy(),this.commandEncoder=this.createCommandEncoder({id:e.props.id,timeProfilingQuerySet:e.getTimeProfilingQuerySet()}),{submittedCommandEncoder:e,commandBuffer:r}}readPixelsToArrayWebGL(e,r){return oB(e,r)}readPixelsToBufferWebGL(e,r){return nB(e,r)}setParametersWebGL(e){ro(this.gl,e)}getParametersWebGL(e){return kg(this.gl,e)}withParametersWebGL(e,r){return Do(this.gl,e,r)}resetWebGL(){P.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),eL(this.gl)}_getDeviceSpecificTextureFormatCapabilities(e){return pL(this.gl,e,this.extensions)}loseDevice(){let e=!1,o=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return o&&(e=!0,o.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),e}pushState(){oo.get(this.gl).push()}popState(){oo.get(this.gl).pop()}getGLKey(e,r){let o=Number(e);for(let n in this.gl)if(this.gl[n]===o)return`GL.${n}`;return r?.emptyIfUnknown?"":String(e)}getGLKeys(e){let r={emptyIfUnknown:!0};return Object.entries(e).reduce((o,[n,i])=>(o[`${n}:${this.getGLKey(n,r)}`]=`${i}:${this.getGLKey(i,r)}`,o),{})}setConstantAttributeWebGL(e,r){let o=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(o).fill(null);let n=this._constants[e];switch(n&&KZ(n,r)&&P.info(1,`setConstantAttributeWebGL(${e}) could have been skipped, value unchanged`)(),this._constants[e]=r,r.constructor){case Float32Array:$Z(this,e,r);break;case Int32Array:XZ(this,e,r);break;case Uint32Array:YZ(this,e,r);break;default:throw new Error("constant")}}getExtension(e){return no(this.gl,e,this.extensions),this.extensions}_setWebGLDebugMetadata(e,r,o){e.luma=r;let n={props:o.spector,id:o.spector.id};e.__SPECTOR_Metadata=n}}});function qZ(t){return typeof WebGL2RenderingContext<"u"&&t instanceof WebGL2RenderingContext?!0:Boolean(t&&typeof t.createVertexArray=="function")}var Tu,P1,vu,aB=L(()=>{q();z3();n1();i1();Tu=1,P1=class extends wf{type="webgl";constructor(){super(),Xt.defaultProps={...Xt.defaultProps,...Ug}}enforceWebGL2(e){V3(e)}isSupported(){return typeof WebGL2RenderingContext<"u"}isDeviceHandle(e){return typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext?!0:(typeof WebGLRenderingContext<"u"&&e instanceof WebGLRenderingContext&&P.warn("WebGL1 is not supported",e)(),!1)}async attach(e,r={}){let{WebGLDevice:o}=await Promise.resolve().then(()=>(__(),w1));if(e instanceof o)return e;let n=o.getDeviceFromContext(e);if(n)return n;if(!qZ(e))throw new Error("Invalid WebGL2RenderingContext");let i=r.createCanvasContext===!0?{}:r.createCanvasContext;return new o({...r,_handle:e,createCanvasContext:{canvas:e.canvas,autoResize:!1,...i}})}async create(e={}){let{WebGLDevice:r}=await Promise.resolve().then(()=>(__(),w1)),o=[];(e.debugWebGL||e.debug)&&o.push(X3()),e.debugSpectorJS&&o.push(j3(e));let n=await Promise.allSettled(o);for(let i of n)i.status==="rejected"&&P.error(`Failed to initialize debug libraries ${i.reason}`)();try{let i=new r(e);P.groupCollapsed(Tu,`WebGLDevice ${i.id} created`)();let s=`${i._reused?"Reusing":"Created"} device with WebGL2 ${i.props.debug?"debug ":""}context: ${i.info.vendor}, ${i.info.renderer} for canvas: ${i.canvasContext.id}`;return P.probe(Tu,s)(),P.table(Tu,i.info)(),i}finally{P.groupEnd(Tu)(),P.info(Tu,"%cWebGL call tracing: luma.log.set('debug-webgl') ","color: white; background: blue; padding: 2px 6px; border-radius: 3px;")()}}};vu=new P1});var Au=L(()=>{aB();__();qg()});var DF=jl((Vje,PS)=>{"use strict";PS.exports=f0;PS.exports.default=f0;function f0(t,e,r){r=r||2;var o=e&&e.length,n=o?e[0]*r:t.length,i=OF(t,0,n,r,!0),s=[];if(!i||i.next===i.prev)return s;var a,c,l,f,u,d,h;if(o&&(i=ite(t,e,i,r)),t.length>80*r){a=l=t[0],c=f=t[1];for(var p=r;p<n;p+=r)u=t[p],d=t[p+1],u<a&&(a=u),d<c&&(c=d),u>l&&(l=u),d>f&&(f=d);h=Math.max(l-a,f-c),h=h!==0?32767/h:0}return yd(i,s,r,a,c,h,0),s}function OF(t,e,r,o,n){var i,s;if(n===wS(t,e,r,o)>0)for(i=e;i<r;i+=o)s=BF(i,t[i],t[i+1],s);else for(i=r-o;i>=e;i-=o)s=BF(i,t[i],t[i+1],s);return s&&u0(s,s.next)&&(bd(s),s=s.next),s}function Ls(t,e){if(!t)return t;e||(e=t);var r=t,o;do if(o=!1,!r.steiner&&(u0(r,r.next)||Ve(r.prev,r,r.next)===0)){if(bd(r),r=e=r.prev,r===r.next)break;o=!0}else r=r.next;while(o||r!==e);return e}function yd(t,e,r,o,n,i,s){if(t){!s&&i&&fte(t,o,n,i);for(var a=t,c,l;t.prev!==t.next;){if(c=t.prev,l=t.next,i?rte(t,o,n,i):tte(t)){e.push(c.i/r|0),e.push(t.i/r|0),e.push(l.i/r|0),bd(t),t=l.next,a=l.next;continue}if(t=l,t===a){s?s===1?(t=ote(Ls(t),e,r),yd(t,e,r,o,n,i,2)):s===2&&nte(t,e,r,o,n,i):yd(Ls(t),e,r,o,n,i,1);break}}}}function tte(t){var e=t.prev,r=t,o=t.next;if(Ve(e,r,o)>=0)return!1;for(var n=e.x,i=r.x,s=o.x,a=e.y,c=r.y,l=o.y,f=n<i?n<s?n:s:i<s?i:s,u=a<c?a<l?a:l:c<l?c:l,d=n>i?n>s?n:s:i>s?i:s,h=a>c?a>l?a:l:c>l?c:l,p=o.next;p!==e;){if(p.x>=f&&p.x<=d&&p.y>=u&&p.y<=h&&Mc(n,a,i,c,s,l,p.x,p.y)&&Ve(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function rte(t,e,r,o){var n=t.prev,i=t,s=t.next;if(Ve(n,i,s)>=0)return!1;for(var a=n.x,c=i.x,l=s.x,f=n.y,u=i.y,d=s.y,h=a<c?a<l?a:l:c<l?c:l,p=f<u?f<d?f:d:u<d?u:d,m=a>c?a>l?a:l:c>l?c:l,g=f>u?f>d?f:d:u>d?u:d,_=CS(h,p,e,r,o),x=CS(m,g,e,r,o),y=t.prevZ,b=t.nextZ;y&&y.z>=_&&b&&b.z<=x;){if(y.x>=h&&y.x<=m&&y.y>=p&&y.y<=g&&y!==n&&y!==s&&Mc(a,f,c,u,l,d,y.x,y.y)&&Ve(y.prev,y,y.next)>=0||(y=y.prevZ,b.x>=h&&b.x<=m&&b.y>=p&&b.y<=g&&b!==n&&b!==s&&Mc(a,f,c,u,l,d,b.x,b.y)&&Ve(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;y&&y.z>=_;){if(y.x>=h&&y.x<=m&&y.y>=p&&y.y<=g&&y!==n&&y!==s&&Mc(a,f,c,u,l,d,y.x,y.y)&&Ve(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;b&&b.z<=x;){if(b.x>=h&&b.x<=m&&b.y>=p&&b.y<=g&&b!==n&&b!==s&&Mc(a,f,c,u,l,d,b.x,b.y)&&Ve(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function ote(t,e,r){var o=t;do{var n=o.prev,i=o.next.next;!u0(n,i)&&FF(n,o,o.next,i)&&xd(n,i)&&xd(i,n)&&(e.push(n.i/r|0),e.push(o.i/r|0),e.push(i.i/r|0),bd(o),bd(o.next),o=t=i),o=o.next}while(o!==t);return Ls(o)}function nte(t,e,r,o,n,i){var s=t;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&hte(s,a)){var c=NF(s,a);s=Ls(s,s.next),c=Ls(c,c.next),yd(s,e,r,o,n,i,0),yd(c,e,r,o,n,i,0);return}a=a.next}s=s.next}while(s!==t)}function ite(t,e,r,o){var n=[],i,s,a,c,l;for(i=0,s=e.length;i<s;i++)a=e[i]*o,c=i<s-1?e[i+1]*o:t.length,l=OF(t,a,c,o,!1),l===l.next&&(l.steiner=!0),n.push(dte(l));for(n.sort(ste),i=0;i<n.length;i++)r=ate(n[i],r);return r}function ste(t,e){return t.x-e.x}function ate(t,e){var r=cte(t,e);if(!r)return e;var o=NF(r,t);return Ls(o,o.next),Ls(r,r.next)}function cte(t,e){var r=e,o=t.x,n=t.y,i=-1/0,s;do{if(n<=r.y&&n>=r.next.y&&r.next.y!==r.y){var a=r.x+(n-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=o&&a>i&&(i=a,s=r.x<r.next.x?r:r.next,a===o))return s}r=r.next}while(r!==e);if(!s)return null;var c=s,l=s.x,f=s.y,u=1/0,d;r=s;do o>=r.x&&r.x>=l&&o!==r.x&&Mc(n<f?o:i,n,l,f,n<f?i:o,n,r.x,r.y)&&(d=Math.abs(n-r.y)/(o-r.x),xd(r,t)&&(d<u||d===u&&(r.x>s.x||r.x===s.x&<e(s,r)))&&(s=r,u=d)),r=r.next;while(r!==c);return s}function lte(t,e){return Ve(t.prev,t,e.prev)<0&&Ve(e.next,t,t.next)<0}function fte(t,e,r,o){var n=t;do n.z===0&&(n.z=CS(n.x,n.y,e,r,o)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==t);n.prevZ.nextZ=null,n.prevZ=null,ute(n)}function ute(t){var e,r,o,n,i,s,a,c,l=1;do{for(r=t,t=null,i=null,s=0;r;){for(s++,o=r,a=0,e=0;e<l&&(a++,o=o.nextZ,!!o);e++);for(c=l;a>0||c>0&&o;)a!==0&&(c===0||!o||r.z<=o.z)?(n=r,r=r.nextZ,a--):(n=o,o=o.nextZ,c--),i?i.nextZ=n:t=n,n.prevZ=i,i=n;r=o}i.nextZ=null,l*=2}while(s>1);return t}function CS(t,e,r,o,n){return t=(t-r)*n|0,e=(e-o)*n|0,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t|e<<1}function dte(t){var e=t,r=t;do(e.x<r.x||e.x===r.x&&e.y<r.y)&&(r=e),e=e.next;while(e!==t);return r}function Mc(t,e,r,o,n,i,s,a){return(n-s)*(e-a)>=(t-s)*(i-a)&&(t-s)*(o-a)>=(r-s)*(e-a)&&(r-s)*(i-a)>=(n-s)*(o-a)}function hte(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!pte(t,e)&&(xd(t,e)&&xd(e,t)&&mte(t,e)&&(Ve(t.prev,t,e.prev)||Ve(t,e.prev,e))||u0(t,e)&&Ve(t.prev,t,t.next)>0&&Ve(e.prev,e,e.next)>0)}function Ve(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function u0(t,e){return t.x===e.x&&t.y===e.y}function FF(t,e,r,o){var n=l0(Ve(t,e,r)),i=l0(Ve(t,e,o)),s=l0(Ve(r,o,t)),a=l0(Ve(r,o,e));return!!(n!==i&&s!==a||n===0&&c0(t,r,e)||i===0&&c0(t,o,e)||s===0&&c0(r,t,o)||a===0&&c0(r,e,o))}function c0(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function l0(t){return t>0?1:t<0?-1:0}function pte(t,e){var r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&FF(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}function xd(t,e){return Ve(t.prev,t,t.next)<0?Ve(t,e,t.next)>=0&&Ve(t,t.prev,e)>=0:Ve(t,e,t.prev)<0||Ve(t,t.next,e)<0}function mte(t,e){var r=t,o=!1,n=(t.x+e.x)/2,i=(t.y+e.y)/2;do r.y>i!=r.next.y>i&&r.next.y!==r.y&&n<(r.next.x-r.x)*(i-r.y)/(r.next.y-r.y)+r.x&&(o=!o),r=r.next;while(r!==t);return o}function NF(t,e){var r=new ES(t.i,t.x,t.y),o=new ES(e.i,e.x,e.y),n=t.next,i=e.prev;return t.next=e,e.prev=t,r.next=n,n.prev=r,o.next=r,r.prev=o,i.next=o,o.prev=i,o}function BF(t,e,r,o){var n=new ES(t,e,r);return o?(n.next=o.next,n.prev=o,o.next.prev=n,o.next=n):(n.prev=n,n.next=n),n}function bd(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function ES(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}f0.deviation=function(t,e,r,o){var n=e&&e.length,i=n?e[0]*r:t.length,s=Math.abs(wS(t,0,i,r));if(n)for(var a=0,c=e.length;a<c;a++){var l=e[a]*r,f=a<c-1?e[a+1]*r:t.length;s-=Math.abs(wS(t,l,f,r))}var u=0;for(a=0;a<o.length;a+=3){var d=o[a]*r,h=o[a+1]*r,p=o[a+2]*r;u+=Math.abs((t[d]-t[p])*(t[h+1]-t[d+1])-(t[d]-t[h])*(t[p+1]-t[d+1]))}return s===0&&u===0?0:Math.abs((u-s)/s)};function wS(t,e,r,o){for(var n=0,i=e,s=r-o;i<r;i+=o)n+=(t[s]-t[i])*(t[i+1]+t[s+1]),s=i;return n}f0.flatten=function(t){for(var e=t[0][0].length,r={vertices:[],holes:[],dimensions:e},o=0,n=0;n<t.length;n++){for(var i=0;i<t[n].length;i++)for(var s=0;s<e;s++)r.vertices.push(t[n][i][s]);n>0&&(o+=t[n-1].length,r.holes.push(o))}return r}});var kd=jl((qGe,GD)=>{GD.exports=globalThis.h3||{}});var uC=jl((pU,Zd)=>{(function(t,e){typeof define=="function"&&define.amd?define([],e):typeof qw=="function"&&typeof Zd=="object"&&Zd&&Zd.exports?Zd.exports=e():(t.dcodeIO=t.dcodeIO||{}).Long=e()})(pU,function(){"use strict";function t(S,A,M){this.low=S|0,this.high=A|0,this.unsigned=!!M}t.prototype.__isLong__,Object.defineProperty(t.prototype,"__isLong__",{value:!0,enumerable:!1,configurable:!1});function e(S){return(S&&S.__isLong__)===!0}t.isLong=e;var r={},o={};function n(S,A){var M,B,O;return A?(S>>>=0,(O=0<=S&&S<256)&&(B=o[S],B)?B:(M=s(S,(S|0)<0?-1:0,!0),O&&(o[S]=M),M)):(S|=0,(O=-128<=S&&S<128)&&(B=r[S],B)?B:(M=s(S,S<0?-1:0,!1),O&&(r[S]=M),M))}t.fromInt=n;function i(S,A){if(isNaN(S)||!isFinite(S))return A?_:g;if(A){if(S<0)return _;if(S>=h)return v}else{if(S<=-p)return w;if(S+1>=p)return T}return S<0?i(-S,A).neg():s(S%d|0,S/d|0,A)}t.fromNumber=i;function s(S,A,M){return new t(S,A,M)}t.fromBits=s;var a=Math.pow;function c(S,A,M){if(S.length===0)throw Error("empty string");if(S==="NaN"||S==="Infinity"||S==="+Infinity"||S==="-Infinity")return g;if(typeof A=="number"?(M=A,A=!1):A=!!A,M=M||10,M<2||36<M)throw RangeError("radix");var B;if((B=S.indexOf("-"))>0)throw Error("interior hyphen");if(B===0)return c(S.substring(1),A,M).neg();for(var O=i(a(M,8)),F=g,X=0;X<S.length;X+=8){var G=Math.min(8,S.length-X),j=parseInt(S.substring(X,X+G),M);if(G<8){var se=i(a(M,G));F=F.mul(se).add(i(j))}else F=F.mul(O),F=F.add(i(j))}return F.unsigned=A,F}t.fromString=c;function l(S){return S instanceof t?S:typeof S=="number"?i(S):typeof S=="string"?c(S):s(S.low,S.high,S.unsigned)}t.fromValue=l;var f=1<<16,u=1<<24,d=f*f,h=d*d,p=h/2,m=n(u),g=n(0);t.ZERO=g;var _=n(0,!0);t.UZERO=_;var x=n(1);t.ONE=x;var y=n(1,!0);t.UONE=y;var b=n(-1);t.NEG_ONE=b;var T=s(-1,2147483647,!1);t.MAX_VALUE=T;var v=s(-1,-1,!0);t.MAX_UNSIGNED_VALUE=v;var w=s(0,-2147483648,!1);t.MIN_VALUE=w;var C=t.prototype;return C.toInt=function(){return this.unsigned?this.low>>>0:this.low},C.toNumber=function(){return this.unsigned?(this.high>>>0)*d+(this.low>>>0):this.high*d+(this.low>>>0)},C.toString=function(A){if(A=A||10,A<2||36<A)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(w)){var M=i(A),B=this.div(M),O=B.mul(M).sub(this);return B.toString(A)+O.toInt().toString(A)}else return"-"+this.neg().toString(A);for(var F=i(a(A,6),this.unsigned),X=this,G="";;){var j=X.div(F),se=X.sub(j.mul(F)).toInt()>>>0,ne=se.toString(A);if(X=j,X.isZero())return ne+G;for(;ne.length<6;)ne="0"+ne;G=""+ne+G}},C.getHighBits=function(){return this.high},C.getHighBitsUnsigned=function(){return this.high>>>0},C.getLowBits=function(){return this.low},C.getLowBitsUnsigned=function(){return this.low>>>0},C.getNumBitsAbs=function(){if(this.isNegative())return this.eq(w)?64:this.neg().getNumBitsAbs();for(var A=this.high!=0?this.high:this.low,M=31;M>0&&!(A&1<<M);M--);return this.high!=0?M+33:M+1},C.isZero=function(){return this.high===0&&this.low===0},C.isNegative=function(){return!this.unsigned&&this.high<0},C.isPositive=function(){return this.unsigned||this.high>=0},C.isOdd=function(){return(this.low&1)===1},C.isEven=function(){return(this.low&1)===0},C.equals=function(A){return e(A)||(A=l(A)),this.unsigned!==A.unsigned&&this.high>>>31===1&&A.high>>>31===1?!1:this.high===A.high&&this.low===A.low},C.eq=C.equals,C.notEquals=function(A){return!this.eq(A)},C.neq=C.notEquals,C.lessThan=function(A){return this.comp(A)<0},C.lt=C.lessThan,C.lessThanOrEqual=function(A){return this.comp(A)<=0},C.lte=C.lessThanOrEqual,C.greaterThan=function(A){return this.comp(A)>0},C.gt=C.greaterThan,C.greaterThanOrEqual=function(A){return this.comp(A)>=0},C.gte=C.greaterThanOrEqual,C.compare=function(A){if(e(A)||(A=l(A)),this.eq(A))return 0;var M=this.isNegative(),B=A.isNegative();return M&&!B?-1:!M&&B?1:this.unsigned?A.high>>>0>this.high>>>0||A.high===this.high&&A.low>>>0>this.low>>>0?-1:1:this.sub(A).isNegative()?-1:1},C.comp=C.compare,C.negate=function(){return!this.unsigned&&this.eq(w)?w:this.not().add(x)},C.neg=C.negate,C.add=function(A){e(A)||(A=l(A));var M=this.high>>>16,B=this.high&65535,O=this.low>>>16,F=this.low&65535,X=A.high>>>16,G=A.high&65535,j=A.low>>>16,se=A.low&65535,ne=0,pe=0,U=0,re=0;return re+=F+se,U+=re>>>16,re&=65535,U+=O+j,pe+=U>>>16,U&=65535,pe+=B+G,ne+=pe>>>16,pe&=65535,ne+=M+X,ne&=65535,s(U<<16|re,ne<<16|pe,this.unsigned)},C.subtract=function(A){return e(A)||(A=l(A)),this.add(A.neg())},C.sub=C.subtract,C.multiply=function(A){if(this.isZero()||(e(A)||(A=l(A)),A.isZero()))return g;if(this.eq(w))return A.isOdd()?w:g;if(A.eq(w))return this.isOdd()?w:g;if(this.isNegative())return A.isNegative()?this.neg().mul(A.neg()):this.neg().mul(A).neg();if(A.isNegative())return this.mul(A.neg()).neg();if(this.lt(m)&&A.lt(m))return i(this.toNumber()*A.toNumber(),this.unsigned);var M=this.high>>>16,B=this.high&65535,O=this.low>>>16,F=this.low&65535,X=A.high>>>16,G=A.high&65535,j=A.low>>>16,se=A.low&65535,ne=0,pe=0,U=0,re=0;return re+=F*se,U+=re>>>16,re&=65535,U+=O*se,pe+=U>>>16,U&=65535,U+=F*j,pe+=U>>>16,U&=65535,pe+=B*se,ne+=pe>>>16,pe&=65535,pe+=O*j,ne+=pe>>>16,pe&=65535,pe+=F*G,ne+=pe>>>16,pe&=65535,ne+=M*se+B*j+O*G+F*X,ne&=65535,s(U<<16|re,ne<<16|pe,this.unsigned)},C.mul=C.multiply,C.divide=function(A){if(e(A)||(A=l(A)),A.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?_:g;var M,B,O;if(this.unsigned){if(A.unsigned||(A=A.toUnsigned()),A.gt(this))return _;if(A.gt(this.shru(1)))return y;O=_}else{if(this.eq(w)){if(A.eq(x)||A.eq(b))return w;if(A.eq(w))return x;var F=this.shr(1);return M=F.div(A).shl(1),M.eq(g)?A.isNegative()?x:b:(B=this.sub(A.mul(M)),O=M.add(B.div(A)),O)}else if(A.eq(w))return this.unsigned?_:g;if(this.isNegative())return A.isNegative()?this.neg().div(A.neg()):this.neg().div(A).neg();if(A.isNegative())return this.div(A.neg()).neg();O=g}for(B=this;B.gte(A);){M=Math.max(1,Math.floor(B.toNumber()/A.toNumber()));for(var X=Math.ceil(Math.log(M)/Math.LN2),G=X<=48?1:a(2,X-48),j=i(M),se=j.mul(A);se.isNegative()||se.gt(B);)M-=G,j=i(M,this.unsigned),se=j.mul(A);j.isZero()&&(j=x),O=O.add(j),B=B.sub(se)}return O},C.div=C.divide,C.modulo=function(A){return e(A)||(A=l(A)),this.sub(this.div(A).mul(A))},C.mod=C.modulo,C.not=function(){return s(~this.low,~this.high,this.unsigned)},C.and=function(A){return e(A)||(A=l(A)),s(this.low&A.low,this.high&A.high,this.unsigned)},C.or=function(A){return e(A)||(A=l(A)),s(this.low|A.low,this.high|A.high,this.unsigned)},C.xor=function(A){return e(A)||(A=l(A)),s(this.low^A.low,this.high^A.high,this.unsigned)},C.shiftLeft=function(A){return e(A)&&(A=A.toInt()),(A&=63)===0?this:A<32?s(this.low<<A,this.high<<A|this.low>>>32-A,this.unsigned):s(0,this.low<<A-32,this.unsigned)},C.shl=C.shiftLeft,C.shiftRight=function(A){return e(A)&&(A=A.toInt()),(A&=63)===0?this:A<32?s(this.low>>>A|this.high<<32-A,this.high>>A,this.unsigned):s(this.high>>A-32,this.high>=0?0:-1,this.unsigned)},C.shr=C.shiftRight,C.shiftRightUnsigned=function(A){if(e(A)&&(A=A.toInt()),A&=63,A===0)return this;var M=this.high;if(A<32){var B=this.low;return s(B>>>A|M<<32-A,M>>>A,this.unsigned)}else return A===32?s(M,0,this.unsigned):s(M>>>A-32,0,this.unsigned)},C.shru=C.shiftRightUnsigned,C.toSigned=function(){return this.unsigned?s(this.low,this.high,!1):this},C.toUnsigned=function(){return this.unsigned?this:s(this.low,this.high,!0)},C.toBytes=function(S){return S?this.toBytesLE():this.toBytesBE()},C.toBytesLE=function(){var S=this.high,A=this.low;return[A&255,A>>>8&255,A>>>16&255,A>>>24&255,S&255,S>>>8&255,S>>>16&255,S>>>24&255]},C.toBytesBE=function(){var S=this.high,A=this.low;return[S>>>24&255,S>>>16&255,S>>>8&255,S&255,A>>>24&255,A>>>16&255,A>>>8&255,A&255]},t})});var kV=jl(tw=>{tw.read=function(t,e,r,o,n){var i,s,a=n*8-o-1,c=(1<<a)-1,l=c>>1,f=-7,u=r?n-1:0,d=r?-1:1,h=t[e+u];for(u+=d,i=h&(1<<-f)-1,h>>=-f,f+=a;f>0;i=i*256+t[e+u],u+=d,f-=8);for(s=i&(1<<-f)-1,i>>=-f,f+=o;f>0;s=s*256+t[e+u],u+=d,f-=8);if(i===0)i=1-l;else{if(i===c)return s?NaN:(h?-1:1)*(1/0);s=s+Math.pow(2,o),i=i-l}return(h?-1:1)*s*Math.pow(2,i-o)};tw.write=function(t,e,r,o,n,i){var s,a,c,l=i*8-n-1,f=(1<<l)-1,u=f>>1,d=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,h=o?0:i-1,p=o?1:-1,m=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),s+u>=1?e+=d/c:e+=d*Math.pow(2,1-u),e*c>=2&&(s++,c/=2),s+u>=f?(a=0,s=f):s+u>=1?(a=(e*c-1)*Math.pow(2,n),s=s+u):(a=e*Math.pow(2,u-1)*Math.pow(2,n),s=0));n>=8;t[r+h]=a&255,h+=p,a/=256,n-=8);for(s=s<<n|a,l+=n;l>0;t[r+h]=s&255,h+=p,s/=256,l-=8);t[r+h-p]|=m*128}});var GV=jl((sit,WV)=>{"use strict";WV.exports=Ae;var mx=kV();function Ae(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}Ae.Varint=0;Ae.Fixed64=1;Ae.Bytes=2;Ae.Fixed32=5;var rw=(1<<16)*(1<<16),VV=1/rw,Wpe=12,jV=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");Ae.prototype={destroy:function(){this.buf=null},readFields:function(t,e,r){for(r=r||this.length;this.pos<r;){var o=this.readVarint(),n=o>>3,i=this.pos;this.type=o&7,t(n,e,this),this.pos===i&&this.skip(o)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=gx(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=HV(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=gx(this.buf,this.pos)+gx(this.buf,this.pos+4)*rw;return this.pos+=8,t},readSFixed64:function(){var t=gx(this.buf,this.pos)+HV(this.buf,this.pos+4)*rw;return this.pos+=8,t},readFloat:function(){var t=mx.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=mx.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e=this.buf,r,o;return o=e[this.pos++],r=o&127,o<128||(o=e[this.pos++],r|=(o&127)<<7,o<128)||(o=e[this.pos++],r|=(o&127)<<14,o<128)||(o=e[this.pos++],r|=(o&127)<<21,o<128)?r:(o=e[this.pos],r|=(o&15)<<28,Gpe(r,t,this))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2===1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=Wpe&&jV?ime(this.buf,e,t):nme(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==Ae.Bytes)return t.push(this.readVarint(e));var r=Bn(this);for(t=t||[];this.pos<r;)t.push(this.readVarint(e));return t},readPackedSVarint:function(t){if(this.type!==Ae.Bytes)return t.push(this.readSVarint());var e=Bn(this);for(t=t||[];this.pos<e;)t.push(this.readSVarint());return t},readPackedBoolean:function(t){if(this.type!==Ae.Bytes)return t.push(this.readBoolean());var e=Bn(this);for(t=t||[];this.pos<e;)t.push(this.readBoolean());return t},readPackedFloat:function(t){if(this.type!==Ae.Bytes)return t.push(this.readFloat());var e=Bn(this);for(t=t||[];this.pos<e;)t.push(this.readFloat());return t},readPackedDouble:function(t){if(this.type!==Ae.Bytes)return t.push(this.readDouble());var e=Bn(this);for(t=t||[];this.pos<e;)t.push(this.readDouble());return t},readPackedFixed32:function(t){if(this.type!==Ae.Bytes)return t.push(this.readFixed32());var e=Bn(this);for(t=t||[];this.pos<e;)t.push(this.readFixed32());return t},readPackedSFixed32:function(t){if(this.type!==Ae.Bytes)return t.push(this.readSFixed32());var e=Bn(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed32());return t},readPackedFixed64:function(t){if(this.type!==Ae.Bytes)return t.push(this.readFixed64());var e=Bn(this);for(t=t||[];this.pos<e;)t.push(this.readFixed64());return t},readPackedSFixed64:function(t){if(this.type!==Ae.Bytes)return t.push(this.readSFixed64());var e=Bn(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed64());return t},skip:function(t){var e=t&7;if(e===Ae.Varint)for(;this.buf[this.pos++]>127;);else if(e===Ae.Bytes)this.pos=this.readVarint()+this.pos;else if(e===Ae.Fixed32)this.pos+=4;else if(e===Ae.Fixed64)this.pos+=8;else throw new Error("Unimplemented type: "+e)},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e<this.pos+t;)e*=2;if(e!==this.length){var r=new Uint8Array(e);r.set(this.buf),this.buf=r,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),_l(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),_l(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),_l(this.buf,t&-1,this.pos),_l(this.buf,Math.floor(t*VV),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),_l(this.buf,t&-1,this.pos),_l(this.buf,Math.floor(t*VV),this.pos+4),this.pos+=8},writeVarint:function(t){if(t=+t||0,t>268435455||t<0){$pe(t,this);return}this.realloc(4),this.buf[this.pos++]=t&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=t>>>7&127)))},writeSVarint:function(t){this.writeVarint(t<0?-t*2-1:t*2)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(t.length*4),this.pos++;var e=this.pos;this.pos=sme(this.buf,t,this.pos);var r=this.pos-e;r>=128&&zV(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(t){this.realloc(4),mx.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),mx.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var r=0;r<e;r++)this.buf[this.pos++]=t[r]},writeRawMessage:function(t,e){this.pos++;var r=this.pos;t(e,this);var o=this.pos-r;o>=128&&zV(r,o,this),this.pos=r-1,this.writeVarint(o),this.pos+=o},writeMessage:function(t,e,r){this.writeTag(t,Ae.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,Kpe,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,qpe,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,Qpe,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,Zpe,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,Jpe,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,eme,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,tme,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,rme,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,ome,e)},writeBytesField:function(t,e){this.writeTag(t,Ae.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,Ae.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,Ae.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,Ae.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,Ae.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,Ae.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,Ae.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,Ae.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,Ae.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,Ae.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};function Gpe(t,e,r){var o=r.buf,n,i;if(i=o[r.pos++],n=(i&112)>>4,i<128||(i=o[r.pos++],n|=(i&127)<<3,i<128)||(i=o[r.pos++],n|=(i&127)<<10,i<128)||(i=o[r.pos++],n|=(i&127)<<17,i<128)||(i=o[r.pos++],n|=(i&127)<<24,i<128)||(i=o[r.pos++],n|=(i&1)<<31,i<128))return gl(t,n,e);throw new Error("Expected varint not more than 10 bytes")}function Bn(t){return t.type===Ae.Bytes?t.readVarint()+t.pos:t.pos+1}function gl(t,e,r){return r?e*4294967296+(t>>>0):(e>>>0)*4294967296+(t>>>0)}function $pe(t,e){var r,o;if(t>=0?(r=t%4294967296|0,o=t/4294967296|0):(r=~(-t%4294967296),o=~(-t/4294967296),r^4294967295?r=r+1|0:(r=0,o=o+1|0)),t>=18446744073709552e3||t<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),Xpe(r,o,e),Ype(o,e)}function Xpe(t,e,r){r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos]=t&127}function Ype(t,e){var r=(t&7)<<4;e.buf[e.pos++]|=r|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127)))))}function zV(t,e,r){var o=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(Math.LN2*7));r.realloc(o);for(var n=r.pos-1;n>=t;n--)r.buf[n+o]=r.buf[n]}function Kpe(t,e){for(var r=0;r<t.length;r++)e.writeVarint(t[r])}function qpe(t,e){for(var r=0;r<t.length;r++)e.writeSVarint(t[r])}function Zpe(t,e){for(var r=0;r<t.length;r++)e.writeFloat(t[r])}function Jpe(t,e){for(var r=0;r<t.length;r++)e.writeDouble(t[r])}function Qpe(t,e){for(var r=0;r<t.length;r++)e.writeBoolean(t[r])}function eme(t,e){for(var r=0;r<t.length;r++)e.writeFixed32(t[r])}function tme(t,e){for(var r=0;r<t.length;r++)e.writeSFixed32(t[r])}function rme(t,e){for(var r=0;r<t.length;r++)e.writeFixed64(t[r])}function ome(t,e){for(var r=0;r<t.length;r++)e.writeSFixed64(t[r])}function gx(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+t[e+3]*16777216}function _l(t,e,r){t[r]=e,t[r+1]=e>>>8,t[r+2]=e>>>16,t[r+3]=e>>>24}function HV(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}function nme(t,e,r){for(var o="",n=e;n<r;){var i=t[n],s=null,a=i>239?4:i>223?3:i>191?2:1;if(n+a>r)break;var c,l,f;a===1?i<128&&(s=i):a===2?(c=t[n+1],(c&192)===128&&(s=(i&31)<<6|c&63,s<=127&&(s=null))):a===3?(c=t[n+1],l=t[n+2],(c&192)===128&&(l&192)===128&&(s=(i&15)<<12|(c&63)<<6|l&63,(s<=2047||s>=55296&&s<=57343)&&(s=null))):a===4&&(c=t[n+1],l=t[n+2],f=t[n+3],(c&192)===128&&(l&192)===128&&(f&192)===128&&(s=(i&15)<<18|(c&63)<<12|(l&63)<<6|f&63,(s<=65535||s>=1114112)&&(s=null))),s===null?(s=65533,a=1):s>65535&&(s-=65536,o+=String.fromCharCode(s>>>10&1023|55296),s=56320|s&1023),o+=String.fromCharCode(s),n+=a}return o}function ime(t,e,r){return jV.decode(t.subarray(e,r))}function sme(t,e,r){for(var o=0,n,i;o<e.length;o++){if(n=e.charCodeAt(o),n>55295&&n<57344)if(i)if(n<56320){t[r++]=239,t[r++]=191,t[r++]=189,i=n;continue}else n=i-55296<<10|n-56320|65536,i=null;else{n>56319||o+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):i=n;continue}else i&&(t[r++]=239,t[r++]=191,t[r++]=189,i=null);n<128?t[r++]=n:(n<2048?t[r++]=n>>6|192:(n<65536?t[r++]=n>>12|224:(t[r++]=n>>18|240,t[r++]=n>>12&63|128),t[r++]=n>>6&63|128),t[r++]=n&63|128)}return r}});var F_e={};ze(F_e,{A5Layer:()=>XD,AmbientLight:()=>oc,ArcLayer:()=>z_,Attribute:()=>Tn,AttributeManager:()=>pr,BitmapLayer:()=>H_,BrushingExtension:()=>rV,COORDINATE_SYSTEM:()=>Be,CPUAggregator:()=>$t,ClipExtension:()=>ax,CollisionFilterExtension:()=>PV,ColumnLayer:()=>Wo,CompassWidget:()=>lp,CompositeLayer:()=>Ne,ContextMenuWidget:()=>Tp,ContourLayer:()=>yH,Controller:()=>zt,DarkGlassTheme:()=>gb,DarkTheme:()=>n5,DataFilterExtension:()=>mV,Deck:()=>An,DeckGL:()=>Gh,DeckRenderer:()=>ys,DirectionalLight:()=>fn,FillStyleExtension:()=>CV,FirstPersonController:()=>Ss,FirstPersonView:()=>FB,FirstPersonViewport:()=>B_,FlyToInterpolator:()=>so,Fp64Extension:()=>_V,FullscreenWidget:()=>dp,GeoJsonLayer:()=>Os,GeohashLayer:()=>uz,GimbalWidget:()=>cp,GoogleMapsOverlay:()=>ep,GreatCircleLayer:()=>hU,GridCellLayer:()=>CF,GridLayer:()=>vH,H3ClusterLayer:()=>YU,H3HexagonLayer:()=>$c,HeatmapLayer:()=>zH,HexagonLayer:()=>kz,IconLayer:()=>Ec,IconWidget:()=>Cp,InfoWidget:()=>bp,Layer:()=>_e,LayerExtension:()=>st,LayerManager:()=>gs,LightGlassTheme:()=>mb,LightTheme:()=>o5,LightingEffect:()=>ai,LineLayer:()=>ZO,LinearInterpolator:()=>Ue,LoadingWidget:()=>Ip,MVTLayer:()=>az,MapController:()=>xn,MapView:()=>di,MapboxOverlay:()=>op,MaskExtension:()=>IV,OPERATION:()=>NI,OrbitController:()=>Cs,OrbitView:()=>NB,OrbitViewport:()=>R_,OrthographicController:()=>Es,OrthographicView:()=>D_,OrthographicViewport:()=>Ac,PathLayer:()=>Go,PathStyleExtension:()=>TV,PointCloudLayer:()=>e0,PointLight:()=>cc,PolygonLayer:()=>vi,PopupWidget:()=>Ap,PostProcessEffect:()=>nu,QuadkeyLayer:()=>wU,ResetViewWidget:()=>ap,S2Layer:()=>CU,ScatterplotLayer:()=>t0,ScenegraphLayer:()=>My,ScreenGridLayer:()=>Pz,ScreenshotWidget:()=>Mp,ScrollbarWidget:()=>da,SelectorWidget:()=>wp,SimpleMeshLayer:()=>Gs,SolidPolygonLayer:()=>Ti,TRANSITION_EVENTS:()=>cu,TerrainController:()=>ku,TerrainLayer:()=>Q6,Tesselator:()=>vn,TextLayer:()=>T0,ThemeWidget:()=>Rp,Tile3DLayer:()=>$6,TileLayer:()=>Ws,ToggleWidget:()=>Ep,TransitionInterpolator:()=>gn,TripsLayer:()=>$U,UNIT:()=>Pe,VERSION:()=>em,View:()=>Vt,Viewport:()=>ot,WebGLAggregator:()=>Qe,WebMercatorViewport:()=>Mt,Widget:()=>$,ZoomWidget:()=>sp,_AggregationLayer:()=>Zo,_ButtonGroup:()=>Yx,_CameraLight:()=>Kf,_Component:()=>bc,_ComponentState:()=>Ts,_CoordinatesGeocoder:()=>Ol,_CurrentLocationGeocoder:()=>nb,_DropdownMenu:()=>Qx,_GeoCellLayer:()=>Or,_GeocoderWidget:()=>up,_GlobeController:()=>ws,_GlobeView:()=>k_,_GlobeViewport:()=>Oo,_GoogleGeocoder:()=>tb,_IconButton:()=>Me,_LayersPass:()=>At,_MapboxGeocoder:()=>rb,_MultiIconLayer:()=>x0,_OpenCageGeocoder:()=>ob,_PickLayersPass:()=>Jr,_RangeInput:()=>Vl,_ScaleWidget:()=>fp,_SimpleMenu:()=>sa,_SplitterWidget:()=>hp,_StatsWidget:()=>Lp,_SunLight:()=>qf,_TerrainExtension:()=>FV,_TextBackgroundLayer:()=>A0,_Tile2DHeader:()=>Hs,_Tileset2D:()=>js,_TimelineWidget:()=>Pp,_WMSLayer:()=>Wc,_applyStyles:()=>xs,_compareProps:()=>xc,_count:()=>E_,_deepEqual:()=>ie,_fillArray:()=>Cg,_flatten:()=>kt,_getURLFromTemplate:()=>Yo,_memoize:()=>Yt,_mergeShaders:()=>mi,_registerLoggers:()=>Qp,_removeStyles:()=>Fg,assert:()=>ge,color:()=>Yr,createIterable:()=>Fe,fp64LowPart:()=>sc,getShaderAssembler:()=>hg,gouraudMaterial:()=>Xr,log:()=>N,phongMaterial:()=>nn,picking:()=>Se,project:()=>We,project32:()=>fe,project64:()=>ix,shadow:()=>rc});async function nr(t,e,r,o){return o._parse(t,e,r,o)}function le(t,e){if(!t)throw new Error(e||"loader assertion failed.")}var _o={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},m5=_o.self||_o.window||_o.global||{},g5=_o.window||_o.self||_o.global||{},_5=_o.global||_o.self||_o.window||{},y5=_o.document||{};var Qo=Boolean(typeof process!="object"||String(process)!=="[object process]"||process.browser);var Jw=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),x5=Jw&&parseFloat(Jw[1])||0;zn();var wb="4.4.3",w5=wb[0]>="0"&&wb[0]<="9"?`v${wb}`:"";function P5(){let t=new ct({id:"loaders.gl"});return globalThis.loaders||={},globalThis.loaders.log=t,globalThis.loaders.version=w5,globalThis.probe||={},globalThis.probe.loaders=t,t}var Wl=P5();var M5=t=>typeof t=="boolean",yo=t=>typeof t=="function",xo=t=>t!==null&&typeof t=="object",Vp=t=>xo(t)&&t.constructor==={}.constructor;var Pb=t=>typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer,ba=t=>xo(t)&&typeof t.byteLength=="number"&&typeof t.slice=="function";var Mb=t=>Boolean(t)&&yo(t[Symbol.iterator]),Rb=t=>Boolean(t)&&yo(t[Symbol.asyncIterator]);var ir=t=>typeof Response<"u"&&t instanceof Response||xo(t)&&yo(t.arrayBuffer)&&yo(t.text)&&yo(t.json);var sr=t=>typeof Blob<"u"&&t instanceof Blob;var mP=t=>typeof ReadableStream<"u"&&t instanceof ReadableStream||xo(t)&&yo(t.tee)&&yo(t.cancel)&&yo(t.getReader);var gP=t=>xo(t)&&yo(t.read)&&yo(t.pipe)&&M5(t.readable),Gl=t=>mP(t)||gP(t);function ji(t,e){return _P(t||{},e)}function _P(t,e,r=0){if(r>3)return e;let o={...t};for(let[n,i]of Object.entries(e))i&&typeof i=="object"&&!Array.isArray(i)?o[n]=_P(o[n]||{},e[n],r+1):o[n]=e[n];return o}function zp(t){globalThis.loaders||={},globalThis.loaders.modules||={},Object.assign(globalThis.loaders.modules,t)}function Ib(t){return globalThis.loaders?.modules?.[t]||null}var yP="latest";function R5(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.4.3"),globalThis._loadersgl_.version}var Hp=R5();function yt(t,e){if(!t)throw new Error(e||"loaders.gl assertion failed.")}var bo={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},L0e=bo.self||bo.window||bo.global||{},B0e=bo.window||bo.self||bo.global||{},O0e=bo.global||bo.self||bo.window||{},F0e=bo.document||{};var tt=typeof process!="object"||String(process)!=="[object process]"||process.browser,$l=typeof importScripts=="function",bP=typeof window<"u"&&typeof window.orientation<"u",xP=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),N0e=xP&&parseFloat(xP[1])||0;var Xl=class{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(e,r){this.name=e,this.workerThread=r,this.result=new Promise((o,n)=>{this._resolve=o,this._reject=n})}postMessage(e,r){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:r})}done(e){yt(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){yt(this.isRunning),this.isRunning=!1,this._reject(e)}};var Aa=class{terminate(){}};var Lb=new Map;function AP(t){yt(t.source&&!t.url||!t.source&&t.url);let e=Lb.get(t.source||t.url);return e||(t.url&&(e=I5(t.url),Lb.set(t.url,e)),t.source&&(e=TP(t.source),Lb.set(t.source,e))),yt(e),e}function I5(t){if(!t.startsWith("http"))return t;let e=L5(t);return TP(e)}function TP(t){let e=new Blob([t],{type:"application/javascript"});return URL.createObjectURL(e)}function L5(t){return`try { importScripts('${t}'); } catch (error) { console.error(error); throw error; }`}function Bb(t,e=!0,r){let o=r||new Set;if(t){if(vP(t))o.add(t);else if(vP(t.buffer))o.add(t.buffer);else if(!ArrayBuffer.isView(t)){if(e&&typeof t=="object")for(let n in t)Bb(t[n],e,o)}}return r===void 0?Array.from(o):[]}function vP(t){return t?t instanceof ArrayBuffer||typeof MessagePort<"u"&&t instanceof MessagePort||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas:!1}var Ob=()=>{},Hn=class{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return typeof Worker<"u"&&tt||typeof Aa<"u"&&!tt}constructor(e){let{name:r,source:o,url:n}=e;yt(o||n),this.name=r,this.source=o,this.url=n,this.onMessage=Ob,this.onError=i=>console.log(i),this.worker=tt?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=Ob,this.onError=Ob,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(e,r){r=r||Bb(e),this.worker.postMessage(e,r)}_getErrorFromErrorEvent(e){let r="Failed to load ";return r+=`worker ${this.name} from ${this.url}. `,e.message&&(r+=`${e.message} in `),e.lineno&&(r+=`:${e.lineno}:${e.colno}`),new Error(r)}_createBrowserWorker(){this._loadableURL=AP({source:this.source,url:this.url});let e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=r=>{r.data?this.onMessage(r.data):this.onError(new Error("No data received"))},e.onerror=r=>{this.onError(this._getErrorFromErrorEvent(r)),this.terminated=!0},e.onmessageerror=r=>console.error(r),e}_createNodeWorker(){let e;if(this.url){let o=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`,n=this.url.endsWith(".ts")||this.url.endsWith(".mjs")?"module":"commonjs";e=new Aa(o,{eval:!1,type:n})}else if(this.source)e=new Aa(this.source,{eval:!0});else throw new Error("no worker");return e.on("message",r=>{this.onMessage(r)}),e.on("error",r=>{this.onError(r)}),e.on("exit",r=>{}),e}};var Yl=class{name="unnamed";source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return Hn.isSupported()}constructor(e){this.source=e.source,this.url=e.url,this.setProps(e)}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},e.name!==void 0&&(this.name=e.name),e.maxConcurrency!==void 0&&(this.maxConcurrency=e.maxConcurrency),e.maxMobileConcurrency!==void 0&&(this.maxMobileConcurrency=e.maxMobileConcurrency),e.reuseWorkers!==void 0&&(this.reuseWorkers=e.reuseWorkers),e.onDebug!==void 0&&(this.onDebug=e.onDebug)}async startJob(e,r=(n,i,s)=>n.done(s),o=(n,i)=>n.error(i)){let n=new Promise(i=>(this.jobQueue.push({name:e,onMessage:r,onError:o,onStart:i}),this));return this._startQueuedJob(),await n}async _startQueuedJob(){if(!this.jobQueue.length)return;let e=this._getAvailableWorker();if(!e)return;let r=this.jobQueue.shift();if(r){this.onDebug({message:"Starting job",name:r.name,workerThread:e,backlog:this.jobQueue.length});let o=new Xl(r.name,e);e.onMessage=n=>r.onMessage(o,n.type,n.payload),e.onError=n=>r.onError(o,n),r.onStart(o);try{await o.result}catch(n){console.error(`Worker exception: ${n}`)}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){!tt||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count<this._getMaxConcurrency()){this.count++;let e=`${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;return new Hn({name:e,source:this.source,url:this.url})}return null}_getMaxConcurrency(){return bP?this.maxMobileConcurrency:this.maxConcurrency}};var B5={maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:!0,onDebug:()=>{}},Wi=class{props;workerPools=new Map;static isSupported(){return Hn.isSupported()}static getWorkerFarm(e={}){return Wi._workerFarm=Wi._workerFarm||new Wi({}),Wi._workerFarm.setProps(e),Wi._workerFarm}constructor(e){this.props={...B5},this.setProps(e),this.workerPools=new Map}destroy(){for(let e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(let r of this.workerPools.values())r.setProps(this._getWorkerPoolProps())}getWorkerPool(e){let{name:r,source:o,url:n}=e,i=this.workerPools.get(r);return i||(i=new Yl({name:r,source:o,url:n}),i.setProps(this._getWorkerPoolProps()),this.workerPools.set(r,i)),i}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}},jn=Wi;k(jn,"_workerFarm");function Fb(t,e={}){let r=e[t.id]||{},o=tt?`${t.id}-worker.js`:`${t.id}-worker-node.js`,n=r.workerUrl;if(!n&&t.id==="compression"&&(n=e.workerUrl),(e._workerType||e?.core?._workerType)==="test"&&(tt?n=`modules/${t.module}/dist/${o}`:n=`modules/${t.module}/src/workers/${t.id}-worker-node.ts`),!n){let s=t.version;s==="latest"&&(s=yP);let a=s?`@${s}`:"";n=`https://unpkg.com/@loaders.gl/${t.module}${a}/dist/${o}`}return yt(n),n}function Nb(t,e=Hp){yt(t,"no worker provided");let r=t.version;return!(!e||!r)}var Db={};function Kl(t={}){let e=t.useLocalLibraries??t.core?.useLocalLibraries,r=t.CDN??t.core?.CDN,o=t.modules;return{...e!==void 0?{useLocalLibraries:e}:{},...r!==void 0?{CDN:r}:{},...o!==void 0?{modules:o}:{}}}async function br(t,e=null,r={},o=null){return e&&(t=SP(t,e,r,o)),Db[t]=Db[t]||O5(t),await Db[t]}function SP(t,e,r={},o=null){if(r?.core)throw new Error("loadLibrary: options.core must be pre-normalized");if(!r.useLocalLibraries&&t.startsWith("http"))return t;o=o||t;let n=r.modules||{};return n[o]?n[o]:tt?r.CDN?(yt(r.CDN.startsWith("http")),`${r.CDN}/${e}@${Hp}/dist/libs/${o}`):$l?`../src/libs/${o}`:`modules/${e}/src/libs/${o}`:`modules/${e}/dist/libs/${o}`}async function O5(t){if(t.endsWith("wasm"))return await N5(t);if(!tt){let{requireFromFile:r}=globalThis.loaders||{};try{let o=await r?.(t);return o||!t.includes("/dist/libs/")?o:await r?.(t.replace("/dist/libs/","/src/libs/"))}catch(o){if(t.includes("/dist/libs/"))try{return await r?.(t.replace("/dist/libs/","/src/libs/"))}catch{}return console.error(o),null}}if($l)return importScripts(t);let e=await D5(t);return F5(e,t)}function F5(t,e){if(!tt){let{requireFromString:o}=globalThis.loaders||{};return o?.(t,e)}if($l)return eval.call(globalThis,t),null;let r=document.createElement("script");r.id=e;try{r.appendChild(document.createTextNode(t))}catch{r.text=t}return document.body.appendChild(r),null}async function N5(t){let{readFileAsArrayBuffer:e}=globalThis.loaders||{};if(tt||!e||t.startsWith("http"))return await(await fetch(t)).arrayBuffer();try{return await e(t)}catch{if(t.includes("/dist/libs/"))return await e(t.replace("/dist/libs/","/src/libs/"));throw new Error(`Failed to load ArrayBuffer from ${t}`)}}async function D5(t){let{readFileAsText:e}=globalThis.loaders||{};if(tt||!e||t.startsWith("http"))return await(await fetch(t)).text();try{return await e(t)}catch{if(t.includes("/dist/libs/"))return await e(t.replace("/dist/libs/","/src/libs/"));throw new Error(`Failed to load text from ${t}`)}}function Ub(t,e){if(!jn.isSupported())return!1;let r=e?._nodeWorkers??e?.core?._nodeWorkers;if(!tt&&!r)return!1;let o=e?.worker??e?.core?.worker;return Boolean(t.worker&&o)}async function kb(t,e,r,o,n){let i=t.id,s=Fb(t,r),c=jn.getWorkerFarm(r?.core).getWorkerPool({name:i,url:s});r=JSON.parse(JSON.stringify(r)),o=JSON.parse(JSON.stringify(o||{}));let l=await c.startJob("process-on-worker",U5.bind(null,n));return l.postMessage("process",{input:e,options:r,context:o}),await(await l.result).result}async function U5(t,e,r,o){switch(r){case"done":e.done(o);break;case"error":e.error(new Error(o.error));break;case"process":let{id:n,input:i,options:s}=o;try{let a=await t(i,s);e.postMessage("done",{id:n,result:a})}catch(a){let c=a instanceof Error?a.message:"unknown error";e.postMessage("error",{id:n,error:c})}break;default:console.warn(`parse-with-worker unknown message ${r}`)}}function EP(t,e=5){return typeof t=="string"?t.slice(0,e):ArrayBuffer.isView(t)?CP(t.buffer,t.byteOffset,e):t instanceof ArrayBuffer?CP(t,0,e):""}function CP(t,e,r){if(t.byteLength<=e+r)return"";let o=new DataView(t),n="";for(let i=0;i<r;i++)n+=String.fromCharCode(o.getUint8(e+i));return n}function Vb(t){try{return JSON.parse(t)}catch{throw new Error(`Failed to parse JSON from data starting with "${EP(t)}"`)}}function zb(t,e,r){if(r=r||t.byteLength,t.byteLength<r||e.byteLength<r)return!1;let o=new Uint8Array(t),n=new Uint8Array(e);for(let i=0;i<o.length;++i)if(o[i]!==n[i])return!1;return!0}function Hb(...t){return wP(t)}function wP(t){let e=t.map(i=>i instanceof ArrayBuffer?new Uint8Array(i):i),r=e.reduce((i,s)=>i+s.byteLength,0),o=new Uint8Array(r),n=0;for(let i of e)o.set(i,n),n+=i.byteLength;return o.buffer}function ql(...t){let e=t,r=e&&e.length>1&&e[0].constructor||null;if(!r)throw new Error('"concatenateTypedArrays" - incorrect quantity of arguments or arguments have incompatible data types');let o=e.reduce((s,a)=>s+a.length,0),n=new r(o),i=0;for(let s of e)n.set(s,i),i+=s.length;return n}function Gi(t,e,r){let o=r!==void 0?new Uint8Array(t).subarray(e,e+r):new Uint8Array(t).subarray(e);return new Uint8Array(o).buffer}function Wn(t,e){return le(t>=0),le(e>0),t+(e-1)&~(e-1)}function jb(t,e,r){let o;if(t instanceof ArrayBuffer)o=new Uint8Array(t);else{let n=t.byteOffset,i=t.byteLength;o=new Uint8Array(t.buffer||t.arrayBuffer,n,i)}return e.set(o,r),r+Wn(o.byteLength,4)}async function Wb(t){let e=[];for await(let r of t)e.push(k5(r));return Hb(...e)}function k5(t){if(t instanceof ArrayBuffer)return t;if(ArrayBuffer.isView(t)){let{buffer:e,byteOffset:r,byteLength:o}=t;return PP(e,r,o)}return PP(t)}function PP(t,e=0,r=t.byteLength-e){let o=new Uint8Array(t,e,r),n=new Uint8Array(o.length);return n.set(o),n.buffer}Xi();var V5="Queued Requests",z5="Active Requests",H5="Cancelled Requests",j5="Queued Requests Ever",W5="Active Requests Ever",G5={id:"request-scheduler",throttleRequests:!0,maxRequests:6,debounceTime:0},Gn=class{props;stats;activeRequestCount=0;requestQueue=[];requestMap=new Map;updateTimer=null;constructor(e={}){this.props={...G5,...e},this.stats=new Et({id:this.props.id}),this.stats.get(V5),this.stats.get(z5),this.stats.get(H5),this.stats.get(j5),this.stats.get(W5)}setProps(e){e.throttleRequests!==void 0&&(this.props.throttleRequests=e.throttleRequests),e.maxRequests!==void 0&&(this.props.maxRequests=e.maxRequests),e.debounceTime!==void 0&&(this.props.debounceTime=e.debounceTime)}scheduleRequest(e,r=()=>0){if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(e))return this.requestMap.get(e);let o={handle:e,priority:0,getPriority:r},n=new Promise(i=>(o.resolve=i,o));return this.requestQueue.push(o),this.requestMap.set(e,n),this._issueNewRequests(),n}_issueRequest(e){let{handle:r,resolve:o}=e,n=!1,i=()=>{n||(n=!0,this.requestMap.delete(r),this.activeRequestCount--,this._issueNewRequests())};return this.activeRequestCount++,o?o({done:i}):Promise.resolve({done:i})}_issueNewRequests(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>this._issueNewRequestsAsync(),this.props.debounceTime)}_issueNewRequestsAsync(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=null;let e=Math.max(this.props.maxRequests-this.activeRequestCount,0);if(e!==0){this._updateAllRequests();for(let r=0;r<e;++r){let o=this.requestQueue.shift();o&&this._issueRequest(o)}}}_updateAllRequests(){let e=this.requestQueue;for(let r=0;r<e.length;++r){let o=e[r];this._updateRequest(o)||(e.splice(r,1),this.requestMap.delete(o.handle),r--)}e.sort((r,o)=>r.priority-o.priority)}_updateRequest(e){return e.priority=e.getPriority(e.handle),e.priority<0?(e.resolve(null),!1):!0}};var $5="",RP={};function Jl(t){for(let e in RP)if(t.startsWith(e)){let r=RP[e];t=t.replace(e,r)}return!t.startsWith("http://")&&!t.startsWith("https://")&&(t=`${$5}${t}`),t}function jp(t){return t&&typeof t=="object"&&t.isBuffer}function va(t){if(jp(t))return t;if(t instanceof ArrayBuffer)return t;if(Pb(t))return Ta(t);if(ArrayBuffer.isView(t)){let e=t.buffer;return t.byteOffset===0&&t.byteLength===t.buffer.byteLength?e:e.slice(t.byteOffset,t.byteOffset+t.byteLength)}if(typeof t=="string"){let e=t;return new TextEncoder().encode(e).buffer}if(t&&typeof t=="object"&&t._toArrayBuffer)return t._toArrayBuffer();throw new Error("toArrayBuffer")}function Ar(t){if(t instanceof ArrayBuffer)return t;if(Pb(t))return Ta(t);let{buffer:e,byteOffset:r,byteLength:o}=t;return e instanceof ArrayBuffer&&r===0&&o===e.byteLength?e:Ta(e,r,o)}function Ta(t,e=0,r=t.byteLength-e){let o=new Uint8Array(t,e,r),n=new Uint8Array(o.length);return n.set(o),n.buffer}function Xb(t){return ArrayBuffer.isView(t)?t:new Uint8Array(t)}var Ft={};ze(Ft,{dirname:()=>Y5,filename:()=>X5,join:()=>K5,resolve:()=>q5});function IP(){if(typeof process<"u"&&typeof process.cwd<"u")return process.cwd();let t=window.location?.pathname;return t?.slice(0,t.lastIndexOf("/")+1)||""}function X5(t){let e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(e+1):t}function Y5(t){let e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(0,e):""}function K5(...t){let e="/";return t=t.map((r,o)=>(o&&(r=r.replace(new RegExp(`^${e}`),"")),o!==t.length-1&&(r=r.replace(new RegExp(`${e}$`),"")),r)),t.join(e)}function q5(...t){let e=[];for(let i=0;i<t.length;i++)e[i]=t[i];let r="",o=!1,n;for(let i=e.length-1;i>=-1&&!o;i--){let s;i>=0?s=e[i]:(n===void 0&&(n=IP()),s=n),s.length!==0&&(r=`${s}/${r}`,o=s.charCodeAt(0)===Ql)}return r=Z5(r,!o),o?`/${r}`:r.length>0?r:"."}var Ql=47,Yb=46;function Z5(t,e){let r="",o=-1,n=0,i,s=!1;for(let a=0;a<=t.length;++a){if(a<t.length)i=t.charCodeAt(a);else{if(i===Ql)break;i=Ql}if(i===Ql){if(!(o===a-1||n===1))if(o!==a-1&&n===2){if(r.length<2||!s||r.charCodeAt(r.length-1)!==Yb||r.charCodeAt(r.length-2)!==Yb){if(r.length>2){let c=r.length-1,l=c;for(;l>=0&&r.charCodeAt(l)!==Ql;--l);if(l!==c){r=l===-1?"":r.slice(0,l),o=a,n=0,s=!1;continue}}else if(r.length===2||r.length===1){r="",o=a,n=0,s=!1;continue}}e&&(r.length>0?r+="/..":r="..",s=!0)}else{let c=t.slice(o+1,a);r.length>0?r+=`/${c}`:r=c,s=!1}o=a,n=0}else i===Yb&&n!==-1?++n:n=-1}return r}var Kb=class{optionsType;options;data;url;loadOptions;fetch;_needsRefresh=!0;constructor(e,r,o){o?this.options=ji({...o,core:Kb.defaultOptions},r):this.options={...r},this.data=e,this.url=typeof e=="string"?Jl(e):"",this.loadOptions=Q5(this.options.core?.loadOptions),this.fetch=J5(this.loadOptions)}setProps(e){this.options=Object.assign(this.options,e),this.setNeedsRefresh()}setNeedsRefresh(){this._needsRefresh=!0}getNeedsRefresh(e=!0){let r=this._needsRefresh;return e&&(this._needsRefresh=!1),r}},Sa=Kb;k(Sa,"defaultOptions",{core:{type:"auto",attributions:[],loadOptions:{},loaders:[]}});function J5(t){let e=t?.core?.fetch;if(e&&typeof e=="function")return(o,n)=>e(o,n);let r=t?.fetch;return r&&typeof r!="function"?o=>fetch(o,r):o=>fetch(o)}function Q5(t){let e={...t};t?.core&&(e.core={...t.core});let r=typeof e.baseUri=="string"?e.baseUri:void 0,o=typeof e.baseUrl=="string"?e.baseUrl:void 0;return(r!==void 0||o!==void 0)&&(e.core||={},e.core.baseUrl===void 0&&(e.core.baseUrl=o??r),delete e.baseUri,delete e.baseUrl),e}var $n=class{};k($n,"type","template"),k($n,"testURL",e=>!1);var Wp=class extends Error{constructor(e,r){super(e),this.reason=r.reason,this.url=r.url,this.response=r.response}reason;url;response};var rj=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,oj=/^([-\w.]+\/[-\w.+]+)/;function qb(t,e){return t.toLowerCase()===e.toLowerCase()}function LP(t){let e=oj.exec(t);return e?e[1]:t}function Zb(t){let e=rj.exec(t);return e?e[1]:""}var BP=/\?.*/;function OP(t){let e=t.match(BP);return e&&e[0]}function Xn(t){return t.replace(BP,"")}function FP(t){if(t.length<50)return t;let e=t.slice(t.length-15);return`${t.substr(0,32)}...${e}`}function Yi(t){return ir(t)?t.url:sr(t)?("name"in t?t.name:"")||"":typeof t=="string"?t:""}function Ca(t){if(ir(t)){let e=t.headers.get("content-type")||"",r=Xn(t.url);return LP(e)||Zb(r)}return sr(t)?t.type||"":typeof t=="string"?Zb(t):""}function NP(t){return ir(t)?t.headers["content-length"]||-1:sr(t)?t.size:typeof t=="string"?t.length:t instanceof ArrayBuffer||ArrayBuffer.isView(t)?t.byteLength:-1}async function Gp(t){if(ir(t))return t;let e={},r=NP(t);r>=0&&(e["content-length"]=String(r));let o=Yi(t),n=Ca(t);n&&(e["content-type"]=n);let i=await ij(t);i&&(e["x-first-bytes"]=i),typeof t=="string"&&(t=new TextEncoder().encode(t));let s=new Response(t,{headers:e});return Object.defineProperty(s,"url",{value:o}),s}async function DP(t){if(!t.ok)throw await nj(t)}async function nj(t){let e=FP(t.url),r=`Failed to fetch resource (${t.status}) ${t.statusText}: ${e}`;r=r.length>100?`${r.slice(0,100)}...`:r;let o={reason:t.statusText,url:t.url,response:t};try{let n=t.headers.get("Content-Type");o.reason=!t.bodyUsed&&n?.includes("application/json")?await t.json():await t.text()}catch{}return new Wp(r,o)}async function ij(t){if(typeof t=="string")return`data:,${t.slice(0,5)}`;if(t instanceof Blob){let r=t.slice(0,5);return await new Promise(o=>{let n=new FileReader;n.onload=i=>o(i?.target?.result),n.readAsDataURL(r)})}if(t instanceof ArrayBuffer){let r=t.slice(0,5);return`data:base64,${sj(r)}`}return null}function sj(t){let e="",r=new Uint8Array(t);for(let o=0;o<r.byteLength;o++)e+=String.fromCharCode(r[o]);return btoa(e)}function aj(t){return!cj(t)&&!lj(t)}function cj(t){return t.startsWith("http:")||t.startsWith("https:")}function lj(t){return t.startsWith("data:")}async function Ea(t,e){if(typeof t=="string"){let r=Jl(t);return aj(r)&&globalThis.loaders?.fetchNode?globalThis.loaders?.fetchNode(r,e):await fetch(r,e)}return await Gp(t)}zn();var ef=new ct({id:"loaders.gl"}),$p=class{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}},Xp=class{console;constructor(){this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}};var Yp={core:{baseUrl:void 0,fetch:null,mimeType:void 0,fallbackMimeType:void 0,ignoreRegisteredLoaders:void 0,nothrow:!1,log:new Xp,useLocalLibraries:!1,CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:Qo,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]}},UP={baseUri:"core.baseUrl",fetch:"core.fetch",mimeType:"core.mimeType",fallbackMimeType:"core.fallbackMimeType",ignoreRegisteredLoaders:"core.ignoreRegisteredLoaders",nothrow:"core.nothrow",log:"core.log",useLocalLibraries:"core.useLocalLibraries",CDN:"core.CDN",worker:"core.worker",maxConcurrency:"core.maxConcurrency",maxMobileConcurrency:"core.maxMobileConcurrency",reuseWorkers:"core.reuseWorkers",_nodeWorkers:"core.nodeWorkers",_workerType:"core._workerType",_worker:"core._workerType",limit:"core.limit",_limitMB:"core._limitMB",batchSize:"core.batchSize",batchDebounceMs:"core.batchDebounceMs",metadata:"core.metadata",transforms:"core.transforms",throws:"nothrow",dataType:"(no longer used)",uri:"core.baseUrl",method:"core.fetch.method",headers:"core.fetch.headers",body:"core.fetch.body",mode:"core.fetch.mode",credentials:"core.fetch.credentials",cache:"core.fetch.cache",redirect:"core.fetch.redirect",referrer:"core.fetch.referrer",referrerPolicy:"core.fetch.referrerPolicy",integrity:"core.fetch.integrity",keepalive:"core.fetch.keepalive",signal:"core.fetch.signal"};var Jb=["baseUrl","fetch","mimeType","fallbackMimeType","ignoreRegisteredLoaders","nothrow","log","useLocalLibraries","CDN","worker","maxConcurrency","maxMobileConcurrency","reuseWorkers","_nodeWorkers","_workerType","limit","_limitMB","batchSize","batchDebounceMs","metadata","transforms"];function Qb(){globalThis.loaders=globalThis.loaders||{};let{loaders:t}=globalThis;return t._state||(t._state={}),t._state}function eA(){let t=Qb();return t.globalOptions=t.globalOptions||{...Yp,core:{...Yp.core}},en(t.globalOptions)}function zP(t,e,r,o){return r=r||[],r=Array.isArray(r)?r:[r],fj(t,r),en(dj(e,t,o))}function en(t){let e=pj(t);HP(e);for(let r of Jb)e.core&&e.core[r]!==void 0&&delete e[r];return e.core&&e.core._workerType!==void 0&&delete e._worker,e}function fj(t,e){kP(t,null,Yp,UP,e);for(let r of e){let o=t&&t[r.id]||{},n=r.options&&r.options[r.id]||{},i=r.deprecatedOptions&&r.deprecatedOptions[r.id]||{};kP(o,r.id,n,i,e)}}function kP(t,e,r,o,n){let i=e||"Top level",s=e?`${e}.`:"";for(let a in t){let c=!e&&xo(t[a]),l=a==="baseUri"&&!e,f=a==="workerUrl"&&e;if(!(a in r)&&!l&&!f){if(a in o)ef.level>0&&ef.warn(`${i} loader option '${s}${a}' no longer supported, use '${o[a]}'`)();else if(!c&&ef.level>0){let u=uj(a,n);ef.warn(`${i} loader option '${s}${a}' not recognized. ${u}`)()}}}}function uj(t,e){let r=t.toLowerCase(),o="";for(let n of e)for(let i in n.options){if(t===i)return`Did you mean '${n.id}.${i}'?`;let s=i.toLowerCase();(r.startsWith(s)||s.startsWith(r))&&(o=o||`Did you mean '${n.id}.${i}'?`)}return o}function dj(t,e,r){let o=t.options||{},n={...o};o.core&&(n.core={...o.core}),HP(n),n.core?.log===null&&(n.core={...n.core,log:new $p}),VP(n,en(eA()));let i=en(e);return VP(n,i),hj(n,r),mj(n),n}function VP(t,e){for(let r in e)if(r in e){let o=e[r];Vp(o)&&Vp(t[r])?t[r]={...t[r],...e[r]}:t[r]=e[r]}}function hj(t,e){if(!e)return;t.core?.baseUrl!==void 0||(t.core||={},t.core.baseUrl=Ft.dirname(Xn(e)))}function pj(t){let e={...t};return t.core&&(e.core={...t.core}),e}function HP(t){t.baseUri!==void 0&&(t.core||={},t.core.baseUrl===void 0&&(t.core.baseUrl=t.baseUri));for(let r of Jb)if(t[r]!==void 0){let n=t.core=t.core||{};n[r]===void 0&&(n[r]=t[r])}let e=t._worker;e!==void 0&&(t.core||={},t.core._workerType===void 0&&(t.core._workerType=e))}function mj(t){let e=t.core;if(e)for(let r of Jb)e[r]!==void 0&&(t[r]=e[r])}function tf(t){return t?(Array.isArray(t)&&(t=t[0]),Array.isArray(t?.extensions)):!1}function rf(t){le(t,"null loader"),le(tf(t),"invalid loader");let e;return Array.isArray(t)&&(e=t[1],t=t[0],t={...t,options:{...t.options,...e}}),(t?.parseTextSync||t?.parseText)&&(t.text=!0),t.text||(t.binary=!0),t}var jP=()=>{let t=Qb();return t.loaderRegistry=t.loaderRegistry||[],t.loaderRegistry};function of(t){let e=jP();t=Array.isArray(t)?t:[t];for(let r of t){let o=rf(r);e.find(n=>o===n)||e.unshift(o)}}function WP(){return jP()}var gj=/\.([^.]+)$/;async function XP(t,e=[],r,o){if(!YP(t))return null;let n=en(r||{});if(n.core||={},t instanceof Response&&GP(t)){let s=await t.clone().text(),a=Kp(s,e,{...n,core:{...n.core,nothrow:!0}},o);if(a)return a}let i=Kp(t,e,{...n,core:{...n.core,nothrow:!0}},o);if(i)return i;if(sr(t)&&(t=await t.slice(0,10).arrayBuffer(),i=Kp(t,e,n,o)),!i&&t instanceof Response&&GP(t)){let s=await t.clone().text();i=Kp(s,e,n,o)}if(!i&&!n.core.nothrow)throw new Error(KP(t));return i}function GP(t){let e=Ca(t);return Boolean(e&&(e.startsWith("text/")||e==="application/json"||e.endsWith("+json")))}function Kp(t,e=[],r,o){if(!YP(t))return null;let n=en(r||{});if(n.core||={},e&&!Array.isArray(e))return rf(e);let i=[];e&&(i=i.concat(e)),n.core.ignoreRegisteredLoaders||i.push(...WP()),yj(i);let s=_j(t,i,n,o);if(!s&&!n.core.nothrow)throw new Error(KP(t));return s}function _j(t,e,r,o){let n=Yi(t),i=Ca(t),s=Xn(n)||o?.url,a=null,c="";return r?.core?.mimeType&&(a=tA(e,r?.core?.mimeType),c=`match forced by supplied MIME type ${r?.core?.mimeType}`),a=a||xj(e,s),c=c||(a?`matched url ${s}`:""),a=a||tA(e,i),c=c||(a?`matched MIME type ${i}`:""),a=a||Aj(e,t),c=c||(a?`matched initial data ${qP(t)}`:""),r?.core?.fallbackMimeType&&(a=a||tA(e,r?.core?.fallbackMimeType),c=c||(a?`matched fallback MIME type ${i}`:"")),c&&Wl.log(1,`selectLoader selected ${a?.name}: ${c}.`),a}function YP(t){return!(t instanceof Response&&t.status===204)}function KP(t){let e=Yi(t),r=Ca(t),o="No valid loader found (";o+=e?`${Ft.filename(e)}, `:"no url provided, ",o+=`MIME type: ${r?`"${r}"`:"not provided"}, `;let n=t?qP(t):"";return o+=n?` first bytes: "${n}"`:"first bytes: not available",o+=")",o}function yj(t){for(let e of t)rf(e)}function xj(t,e){let r=e&&gj.exec(e),o=r&&r[1];return o?bj(t,o):null}function bj(t,e){e=e.toLowerCase();for(let r of t)for(let o of r.extensions)if(o.toLowerCase()===e)return r;return null}function tA(t,e){for(let r of t)if(r.mimeTypes?.some(o=>qb(e,o))||qb(e,`application/x.${r.id}`))return r;return null}function Aj(t,e){if(!e)return null;for(let r of t)if(typeof e=="string"){if(Tj(e,r))return r}else if(ArrayBuffer.isView(e)){if($P(e.buffer,e.byteOffset,r))return r}else if(e instanceof ArrayBuffer&&$P(e,0,r))return r;return null}function Tj(t,e){return e.testText?e.testText(t):(Array.isArray(e.tests)?e.tests:[e.tests]).some(o=>t.startsWith(o))}function $P(t,e,r){return(Array.isArray(r.tests)?r.tests:[r.tests]).some(n=>vj(t,e,r,n))}function vj(t,e,r,o){if(ba(o))return zb(o,t,o.byteLength);switch(typeof o){case"function":return o(Ar(t));case"string":let n=rA(t,e,o.length);return o===n;default:return!1}}function qP(t,e=5){return typeof t=="string"?t.slice(0,e):ArrayBuffer.isView(t)?rA(t.buffer,t.byteOffset,e):t instanceof ArrayBuffer?rA(t,0,e):""}function rA(t,e,r){if(t.byteLength<e+r)return"";let o=new DataView(t),n="";for(let i=0;i<r;i++)n+=String.fromCharCode(o.getUint8(e+i));return n}var Sj=256*1024;function*ZP(t,e){let r=e?.chunkSize||Sj,o=0,n=new TextEncoder;for(;o<t.length;){let i=Math.min(t.length-o,r),s=t.slice(o,o+i);o+=i,yield Ar(n.encode(s))}}function*JP(t,e={}){let{chunkSize:r=262144}=e,o=0;for(;o<t.byteLength;){let n=Math.min(t.byteLength-o,r),i=new ArrayBuffer(n),s=new Uint8Array(t,o,n);new Uint8Array(i).set(s),o+=n,yield i}}async function*QP(t,e){let r=e?.chunkSize||1048576,o=0;for(;o<t.size;){let n=o+r,i=await t.slice(o,n).arrayBuffer();o=n,yield i}}function oA(t,e){return Qo?Cj(t,e):Ej(t,e)}async function*Cj(t,e){let r=t.getReader(),o;try{for(;;){let n=o||r.read();e?._streamReadAhead&&(o=r.read());let{done:i,value:s}=await n;if(i)return;yield va(s)}}catch{r.releaseLock()}}async function*Ej(t,e){for await(let r of t)yield va(r)}function eM(t,e){if(typeof t=="string")return ZP(t,e);if(t instanceof ArrayBuffer)return JP(t,e);if(sr(t))return QP(t,e);if(Gl(t))return oA(t,e);if(ir(t)){let r=t.body;if(!r)throw new Error("Readable stream not available on Response");return oA(r,e)}throw new Error("makeIterator")}var tM="Cannot convert supplied data type";function wj(t,e,r){if(e.text&&typeof t=="string")return t;if(jp(t)&&(t=t.buffer),ba(t)){let o=Xb(t);return e.text&&!e.binary?new TextDecoder("utf8").decode(o):va(o)}throw new Error(tM)}async function rM(t,e,r){if(typeof t=="string"||ba(t))return wj(t,e,r);if(sr(t)&&(t=await Gp(t)),ir(t))return await DP(t),e.binary?await t.arrayBuffer():await t.text();if(Gl(t)&&(t=eM(t,r)),Mb(t)||Rb(t))return Wb(t);throw new Error(tM)}function qp(t,e){let r=eA(),o=t||r,n=o.fetch??o.core?.fetch;return typeof n=="function"?n:xo(n)?i=>Ea(i,n):e?.fetch?e?.fetch:Ea}function oM(t,e,r){if(r)return r;let o={fetch:qp(e,t),...t};if(o.url){let n=Xn(o.url);o.baseUrl=n,o.queryString=OP(o.url),o.filename=Ft.filename(n),o.baseUrl=Ft.dirname(n)}return Array.isArray(o.loaders)||(o.loaders=null),o}function nM(t,e){if(t&&!Array.isArray(t))return t;let r;if(t&&(r=Array.isArray(t)?t:[t]),e&&e.loaders){let o=Array.isArray(e.loaders)?e.loaders:[e.loaders];r=r?[...r,...o]:o}return r&&r.length?r:void 0}async function Yn(t,e,r,o){e&&!Array.isArray(e)&&!tf(e)&&(o=void 0,r=e,e=void 0),t=await t,r=r||{};let n=Yi(t),s=nM(e,o),a=await XP(t,s,r);if(!a)return null;let c=zP(r,a,s,n);return o=oM({url:n,_parse:Yn,loaders:s},c,o||null),await Pj(a,t,c,o)}async function Pj(t,e,r,o){if(Nb(t),r=ji(t.options,r),ir(e)){let{ok:i,redirected:s,status:a,statusText:c,type:l,url:f}=e,u=Object.fromEntries(e.headers.entries());o.response={headers:u,ok:i,redirected:s,status:a,statusText:c,type:l,url:f}}e=await rM(e,t,r);let n=t;if(n.parseTextSync&&typeof e=="string")return n.parseTextSync(e,r,o);if(Ub(t,r))return await kb(t,e,r,o,Yn);if(n.parseText&&typeof e=="string")return await n.parseText(e,r,o);if(n.parse)return await n.parse(e,r,o);throw yt(!n.parseSync),new Error(`${t.id} loader - no parser found and worker is disabled`)}function iM(t){switch(t.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}function sM(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function aM(t){return Array.isArray(t)?t.length===0||typeof t[0]=="number":!1}function nA(t){return sM(t)||aM(t)}function Ki(t){let e=1/0,r=1/0,o=1/0,n=-1/0,i=-1/0,s=-1/0,a=t.POSITION?t.POSITION.value:[],c=a&&a.length;for(let l=0;l<c;l+=3){let f=a[l],u=a[l+1],d=a[l+2];e=f<e?f:e,r=u<r?u:r,o=d<o?d:o,n=f>n?f:n,i=u>i?u:i,s=d>s?d:s}return[[e,r,o],[n,i,s]]}function iA(t,e,r){let o=iM(e.value),n=r||cM(e);return{name:t,type:{type:"fixed-size-list",listSize:e.size,children:[{name:"value",type:o}]},nullable:!1,metadata:n}}function cM(t){let e={};return"byteOffset"in t&&(e.byteOffset=t.byteOffset.toString(10)),"byteStride"in t&&(e.byteStride=t.byteStride.toString(10)),"normalized"in t&&(e.normalized=t.normalized.toString()),e}async function Kn(t,e,r,o){let n,i;!Array.isArray(e)&&!tf(e)?(n=[],i=e,o=void 0):(n=e,i=r);let s=qp(i),a=t;return typeof t=="string"&&(a=await s(t)),sr(t)&&(a=await s(t)),typeof t=="string"&&(en(i||{}).core?.baseUrl||(i={...i,core:{...i?.core,baseUrl:t}})),Array.isArray(n)?await Yn(a,n,i):await Yn(a,n,i)}var lM="4.4.3";var Mj=globalThis.loaders?.parseImageNode,sA=typeof Image<"u",aA=typeof ImageBitmap<"u",Rj=Boolean(Mj),cA=Qo?!0:Rj;function fM(t){switch(t){case"auto":return aA||sA||cA;case"imagebitmap":return aA;case"image":return sA;case"data":return cA;default:throw new Error(`@loaders.gl/images: image ${t} not supported in this environment`)}}function uM(){if(aA)return"imagebitmap";if(sA)return"image";if(cA)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function dM(t){let e=Ij(t);if(!e)throw new Error("Not an image");return e}function nf(t){switch(dM(t)){case"data":return t;case"image":case"imagebitmap":let e=document.createElement("canvas"),r=e.getContext("2d");if(!r)throw new Error("getImageData");return e.width=t.width,e.height=t.height,r.drawImage(t,0,0),r.getImageData(0,0,t.width,t.height);default:throw new Error("getImageData")}}function Ij(t){return typeof ImageBitmap<"u"&&t instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&t instanceof Image?"image":t&&typeof t=="object"&&t.data&&t.width&&t.height?"data":null}var Lj=/^data:image\/svg\+xml/,Bj=/\.svg((\?|#).*)?$/;function Zp(t){return t&&(Lj.test(t)||Bj.test(t))}function hM(t,e){if(Zp(e)){let o=new TextDecoder().decode(t);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(o=unescape(encodeURIComponent(o)))}catch(i){throw new Error(i.message)}return`data:image/svg+xml;base64,${btoa(o)}`}return lA(t,e)}function lA(t,e){if(Zp(e))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(t)])}async function Jp(t,e,r){let o=hM(t,r),n=self.URL||self.webkitURL,i=typeof o!="string"&&n.createObjectURL(o);try{return await Oj(i||o,e)}finally{i&&n.revokeObjectURL(i)}}async function Oj(t,e){let r=new Image;return r.src=t,e.image&&e.image.decode&&r.decode?(await r.decode(),r):await new Promise((o,n)=>{try{r.onload=()=>o(r),r.onerror=i=>{let s=i instanceof Error?i.message:"error";n(new Error(s))}}catch(i){n(i)}})}var pM=!0;async function mM(t,e,r){let o;Zp(r)?o=await Jp(t,e,r):o=lA(t,r);let n=e&&e.imagebitmap;return await Fj(o,n)}async function Fj(t,e=null){if((Nj(e)||!pM)&&(e=null),e)try{return await createImageBitmap(t,e)}catch(r){console.warn(r),pM=!1}return await createImageBitmap(t)}function Nj(t){if(!t)return!0;for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function gM(t){return!Vj(t,"ftyp",4)||!(t[8]&96)?null:Dj(t)}function Dj(t){switch(Uj(t,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function Uj(t,e,r){return String.fromCharCode(...t.slice(e,r))}function kj(t){return[...t].map(e=>e.charCodeAt(0))}function Vj(t,e,r=0){let o=kj(e);for(let n=0;n<o.length;++n)if(o[n]!==t[n+r])return!1;return!0}var Ao=!1,sf=!0;function qi(t){let e=af(t);return Hj(e)||Gj(e)||jj(e)||Wj(e)||zj(e)}function zj(t){let e=new Uint8Array(t instanceof DataView?t.buffer:t),r=gM(e);return r?{mimeType:r.mimeType,width:0,height:0}:null}function Hj(t){let e=af(t);return e.byteLength>=24&&e.getUint32(0,Ao)===2303741511?{mimeType:"image/png",width:e.getUint32(16,Ao),height:e.getUint32(20,Ao)}:null}function jj(t){let e=af(t);return e.byteLength>=10&&e.getUint32(0,Ao)===1195984440?{mimeType:"image/gif",width:e.getUint16(6,sf),height:e.getUint16(8,sf)}:null}function Wj(t){let e=af(t);return e.byteLength>=14&&e.getUint16(0,Ao)===16973&&e.getUint32(2,sf)===e.byteLength?{mimeType:"image/bmp",width:e.getUint32(18,sf),height:e.getUint32(22,sf)}:null}function Gj(t){let e=af(t);if(!(e.byteLength>=3&&e.getUint16(0,Ao)===65496&&e.getUint8(2)===255))return null;let{tableMarkers:o,sofMarkers:n}=$j(),i=2;for(;i+9<e.byteLength;){let s=e.getUint16(i,Ao);if(n.has(s))return{mimeType:"image/jpeg",height:e.getUint16(i+5,Ao),width:e.getUint16(i+7,Ao)};if(!o.has(s))return null;i+=2,i+=e.getUint16(i,Ao)}return null}function $j(){let t=new Set([65499,65476,65484,65501,65534]);for(let r=65504;r<65520;++r)t.add(r);return{tableMarkers:t,sofMarkers:new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502])}}function af(t){if(t instanceof DataView)return t;if(ArrayBuffer.isView(t))return new DataView(t.buffer);if(t instanceof ArrayBuffer)return new DataView(t);throw new Error("toDataView")}async function _M(t,e){let{mimeType:r}=qi(t)||{},o=globalThis.loaders?.parseImageNode;return le(o),await o(t,r)}async function yM(t,e,r){e=e||{};let n=(e.image||{}).type||"auto",{url:i}=r||{},s=Xj(n),a;switch(s){case"imagebitmap":a=await mM(t,e,i);break;case"image":a=await Jp(t,e,i);break;case"data":a=await _M(t,e);break;default:le(!1)}return n==="data"&&(a=nf(a)),a}function Xj(t){switch(t){case"auto":case"data":return uM();default:return fM(t),t}}var Yj=["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],Kj=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],qj={image:{type:"auto",decode:!0}},qn={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:lM,mimeTypes:Kj,extensions:Yj,parse:yM,tests:[t=>Boolean(qi(new DataView(t)))],options:qj};var fA={};function uA(t){if(fA[t]===void 0){let e=Qo?Jj(t):Zj(t);fA[t]=e}return fA[t]}function Zj(t){let e=["image/png","image/jpeg","image/gif"],r=globalThis.loaders?.imageFormatsNode||e,o=globalThis.loaders?.parseImageNode;return Boolean(o)&&r.includes(t)}function Jj(t){switch(t){case"image/avif":case"image/webp":return Qj(t);default:return!0}}function Qj(t){try{return document.createElement("canvas").toDataURL(t).indexOf(`data:${t}`)===0}catch{return!1}}zn();var eW=new ct({id:"deck"}),N=eW;var dA={};function Qp(t){dA=t}function He(t,e,r,o){N.level>0&&dA[t]&&dA[t].call(null,e,r,o)}function tW(t){let e=t[0],r=t[t.length-1];return e==="{"&&r==="}"||e==="["&&r==="]"}var xM={dataType:null,batchType:null,id:"JSON",name:"JSON",module:"",version:"",options:{},extensions:["json","geojson"],mimeTypes:["application/json","application/geo+json"],testText:tW,parseTextSync:JSON.parse};function rW(){let t="9.3.7",e=globalThis.deck&&globalThis.deck.VERSION;if(e&&e!==t)throw new Error(`deck.gl - multiple versions detected: ${e} vs ${t}`);return e||(N.log(1,`deck.gl ${t}`)(),globalThis.deck={...globalThis.deck,VERSION:t,version:t,log:N,_registerLoggers:Qp},of([xM,[qn,{imagebitmap:{premultiplyAlpha:"none"}}]])),t}var em=rW();function Zi(t,e){if(!t){let r=new Error(e||"shadertools: assertion failed.");throw Error.captureStackTrace?.(r,Zi),r}}var hA={number:{type:"number",validate(t,e){return Number.isFinite(t)&&typeof e=="object"&&(e.max===void 0||t<=e.max)&&(e.min===void 0||t>=e.min)}},array:{type:"array",validate(t,e){return Array.isArray(t)||ArrayBuffer.isView(t)}}};function AM(t){let e={};for(let[r,o]of Object.entries(t))e[r]=oW(o);return e}function oW(t){let e=bM(t);if(e!=="object")return{value:t,...hA[e],type:e};if(typeof t=="object")return t?t.type!==void 0?{...t,...hA[t.type],type:t.type}:t.value===void 0?{type:"object",value:t}:(e=bM(t.value),{...t,...hA[e],type:e}):{type:"object",value:null};throw new Error("props")}function bM(t){return Array.isArray(t)||ArrayBuffer.isView(t)?"array":typeof t}var TM=`#ifdef MODULE_LOGDEPTH logdepth_adjustPosition(gl_Position); #endif `,vM=`#ifdef MODULE_MATERIAL fragColor = material_filterColor(fragColor); #endif #ifdef MODULE_LIGHTING fragColor = lighting_filterColor(fragColor); #endif #ifdef MODULE_FOG fragColor = fog_filterColor(fragColor); #endif #ifdef MODULE_PICKING fragColor = picking_filterHighlightColor(fragColor); fragColor = picking_filterPickingColor(fragColor); #endif #ifdef MODULE_LOGDEPTH logdepth_setFragDepth(); #endif `;var nW={vertex:TM,fragment:vM},SM=/void\s+main\s*\([^)]*\)\s*\{\n?/,CM=/}\n?[^{}]*$/,pA=[],cf="__LUMA_INJECT_DECLARATIONS__";function EM(t){let e={vertex:{},fragment:{}};for(let r in t){let o=t[r],n=iW(r);typeof o=="string"&&(o={order:0,injection:o}),e[n][r]=o}return e}function iW(t){let e=t.slice(0,2);switch(e){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(e)}}function lf(t,e,r,o=!1){let n=e==="vertex";for(let i in r){let s=r[i];s.sort((c,l)=>c.order-l.order),pA.length=s.length;for(let c=0,l=s.length;c<l;++c)pA[c]=s[c].injection;let a=`${pA.join(` `)} `;switch(i){case"vs:#decl":n&&(t=t.replace(cf,a));break;case"vs:#main-start":n&&(t=t.replace(SM,c=>c+a));break;case"vs:#main-end":n&&(t=t.replace(CM,c=>a+c));break;case"fs:#decl":n||(t=t.replace(cf,a));break;case"fs:#main-start":n||(t=t.replace(SM,c=>c+a));break;case"fs:#main-end":n||(t=t.replace(CM,c=>a+c));break;default:t=t.replace(i,c=>c+a)}}return t=t.replace(cf,""),o&&(t=t.replace(/\}\s*$/,i=>i+nW[e])),t}function Ji(t){t.map(e=>tm(e))}function tm(t){if(t.instance)return;Ji(t.dependencies||[]);let{propTypes:e={},deprecations:r=[],inject:o={}}=t,n={normalizedInjections:EM(o),parsedDeprecations:sW(r)};e&&(n.propValidators=AM(e)),t.instance=n;let i={};e&&(i=Object.entries(e).reduce((s,[a,c])=>{let l=c?.value;return l&&(s[a]=l),s},{})),t.defaultUniforms={...t.defaultUniforms,...i}}function mA(t,e,r){t.deprecations?.forEach(o=>{o.regex?.test(e)&&(o.deprecated?r.deprecated(o.old,o.new)():r.removed(o.old,o.new)())})}function sW(t){return t.forEach(e=>{switch(e.type){case"function":e.regex=new RegExp(`\\b${e.old}\\(`);break;default:e.regex=new RegExp(`${e.type} ${e.old};`)}}),t}function wa(t){Ji(t);let e={},r={};wM({modules:t,level:0,moduleMap:e,moduleDepth:r});let o=Object.keys(r).sort((n,i)=>r[i]-r[n]).map(n=>e[n]);return Ji(o),o}function wM(t){let{modules:e,level:r,moduleMap:o,moduleDepth:n}=t;if(r>=5)throw new Error("Possible loop in shader dependency graph");for(let i of e)o[i.name]=i,(n[i.name]===void 0||n[i.name]<r)&&(n[i.name]=r);for(let i of e)i.dependencies&&wM({modules:i.dependencies,level:r+1,moduleMap:o,moduleDepth:n})}var aW=/^(?:uniform\s+)?(?:(?:lowp|mediump|highp)\s+)?[A-Za-z0-9_]+(?:<[^>]+>)?\s+([A-Za-z0-9_]+)(?:\s*\[[^\]]+\])?\s*;/,cW=/((?:layout\s*\([^)]*\)\s*)*)uniform\s+([A-Za-z_][A-Za-z0-9_]*)\s*\{([\s\S]*?)\}\s*([A-Za-z_][A-Za-z0-9_]*)?\s*;/g;function MM(t){return`${t.name}Uniforms`}function lW(t,e){let r=e==="wgsl"?t.source:e==="vertex"?t.vs:t.fs;if(!r)return null;let o=MM(t);return uW(r,e==="wgsl"?"wgsl":"glsl",o)}function fW(t,e){let r=Object.keys(t.uniformTypes||{});if(!r.length)return null;let o=lW(t,e);return o?{moduleName:t.name,uniformBlockName:MM(t),stage:e,expectedUniformNames:r,actualUniformNames:o,matches:pW(r,o)}:null}function RM(t,e,r={}){let o=fW(t,e);if(!o||o.matches)return o;let n=mW(o);return r.log?.error?.(n,o)(),r.throwOnError!==!1&&Zi(!1,n),o}function IM(t){let e=[],r=gW(t);for(let o of r.matchAll(cW)){let n=o[1]?.trim()||null;e.push({blockName:o[2],body:o[3],instanceName:o[4]||null,layoutQualifier:n,hasLayoutQualifier:Boolean(n),isStd140:Boolean(n&&/\blayout\s*\([^)]*\bstd140\b[^)]*\)/.exec(n))})}return e}function LM(t,e,r,o){let n=IM(t).filter(s=>!s.isStd140),i=new Set;for(let s of n){if(i.has(s.blockName))continue;i.add(s.blockName);let a=o?.label?`${o.label} `:"",c=s.hasLayoutQualifier?`declares ${_W(s.layoutQualifier)} instead of layout(std140)`:"does not declare layout(std140)",l=`${a}${e} shader uniform block ${s.blockName} ${c}. luma.gl host-side shader block packing assumes explicit layout(std140) for GLSL uniform blocks. Add \`layout(std140)\` to the block declaration.`;r?.warn?.(l,s)()}return n}function uW(t,e,r){let o=e==="wgsl"?dW(t,r):hW(t,r);if(!o)return null;let n=[];for(let i of o.split(` `)){let s=i.replace(/\/\/.*$/,"").trim();if(!s||s.startsWith("#"))continue;let a=e==="wgsl"?s.match(/^([A-Za-z0-9_]+)\s*:/):s.match(aW);a&&n.push(a[1])}return n}function dW(t,e){let r=new RegExp(`\\bstruct\\s+${e}\\b`,"m").exec(t);if(!r)return null;let o=t.indexOf("{",r.index);if(o<0)return null;let n=0;for(let i=o;i<t.length;i++){let s=t[i];if(s==="{"){n++;continue}if(s==="}"&&(n--,n===0))return t.slice(o+1,i)}return null}function hW(t,e){return IM(t).find(o=>o.blockName===e)?.body||null}function pW(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}function mW(t){let{expectedUniformNames:e,actualUniformNames:r}=t,o=e.filter(a=>!r.includes(a)),n=r.filter(a=>!e.includes(a)),i=[`Expected ${e.length} fields, found ${r.length}.`],s=yW(e,r);return s&&i.push(s),o.length&&i.push(`Missing from shader block (${o.length}): ${PM(o)}.`),n.length&&i.push(`Unexpected in shader block (${n.length}): ${PM(n)}.`),e.length<=12&&r.length<=12&&(o.length||n.length)&&(i.push(`Expected: ${e.join(", ")}.`),i.push(`Actual: ${r.join(", ")}.`)),`${t.moduleName}: ${t.stage} shader uniform block ${t.uniformBlockName} does not match module.uniformTypes. ${i.join(" ")}`}function gW(t){return t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"")}function _W(t){return t.replace(/\s+/g," ").trim()}function yW(t,e){let r=Math.min(t.length,e.length);for(let o=0;o<r;o++)if(t[o]!==e[o])return`First mismatch at field ${o+1}: expected ${t[o]}, found ${e[o]}.`;return t.length>e.length?`Shader block ends after field ${e.length}; expected next field ${t[e.length]}.`:e.length>t.length?`Shader block has extra field ${e.length}: ${e[t.length]}.`:null}function PM(t,e=8){if(t.length<=e)return t.join(", ");let r=t.length-e;return`${t.slice(0,e).join(", ")}, ... (${r} more)`}function BM(t){switch(t?.gpu.toLowerCase()){case"apple":return`#define APPLE_GPU // Apple optimizes away the calculation necessary for emulated fp64 #define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1 #define LUMA_FP32_TAN_PRECISION_WORKAROUND 1 // Intel GPU doesn't have full 32 bits precision in same cases, causes overflow #define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1 `;case"nvidia":return`#define NVIDIA_GPU // Nvidia optimizes away the calculation necessary for emulated fp64 #define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1 `;case"intel":return`#define INTEL_GPU // Intel optimizes away the calculation necessary for emulated fp64 #define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1 // Intel's built-in 'tan' function doesn't have acceptable precision #define LUMA_FP32_TAN_PRECISION_WORKAROUND 1 // Intel GPU doesn't have full 32 bits precision in same cases, causes overflow #define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1 `;case"amd":return`#define AMD_GPU `;default:return`#define DEFAULT_GPU // Prevent driver from optimizing away the calculation necessary for emulated fp64 #define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1 // Headless Chrome's software shader 'tan' function doesn't have acceptable precision #define LUMA_FP32_TAN_PRECISION_WORKAROUND 1 // If the GPU doesn't have full 32 bits precision, will causes overflow #define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1 `}}function FM(t,e){if(Number(t.match(/^#version[ \t]+(\d+)/m)?.[1]||100)!==300)throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");switch(e){case"vertex":return t=OM(t,xW),t;case"fragment":return t=OM(t,bW),t;default:throw new Error(e)}}var NM=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,`#version 300 es `],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],xW=[...NM,[gA("attribute"),"in $1"],[gA("varying"),"out $1"]],bW=[...NM,[gA("varying"),"in $1"]];function OM(t,e){for(let[r,o]of e)t=t.replace(r,o);return t}function gA(t){return new RegExp(`\\b${t}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}function _A(t,e){let r="";for(let o in t){let n=t[o];if(r+=`void ${n.signature} { `,n.header&&(r+=` ${n.header}`),e[o]){let i=e[o];i.sort((s,a)=>s.order-a.order);for(let s of i)r+=` ${s.injection} `}n.footer&&(r+=` ${n.footer}`),r+=`} `}return r}function yA(t){let e={vertex:{},fragment:{}};for(let r of t){let o,n;typeof r!="string"?(o=r,n=o.hook):(o={},n=r),n=n.trim();let[i,s]=n.split(":"),a=n.replace(/\(.+/,""),c=Object.assign(o,{signature:s});switch(i){case"vs":e.vertex[a]=c;break;case"fs":e.fragment[a]=c;break;default:throw new Error(i)}}return e}function DM(t,e){return{name:AW(t,e),language:"glsl",version:TW(t)}}function AW(t,e="unnamed"){let o=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(t);return o?o[1]:e}function TW(t){let e=100,r=t.match(/[^\s]+/g);if(r&&r.length>=2&&r[0]==="#version"){let o=parseInt(r[1],10);Number.isFinite(o)&&(e=o)}if(e!==100&&e!==300)throw new Error(`Invalid GLSL version ${e}`);return e}var ar="(?:var<\\s*(uniform|storage(?:\\s*,\\s*[A-Za-z_][A-Za-z0-9_]*)?)\\s*>|var)\\s+([A-Za-z_][A-Za-z0-9_]*)",Tr="\\s*",Pa=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${Tr}@group\\(\\s*(\\d+)\\s*\\)${Tr}${ar}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${Tr}@binding\\(\\s*(auto|\\d+)\\s*\\)${Tr}${ar}`,"g")],rm=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${Tr}@group\\(\\s*(\\d+)\\s*\\)${Tr}${ar}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${Tr}@binding\\(\\s*(auto|\\d+)\\s*\\)${Tr}${ar}`,"g")],UM=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)${Tr}@group\\(\\s*(\\d+)\\s*\\)${Tr}${ar}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${Tr}@binding\\(\\s*(\\d+)\\s*\\)${Tr}${ar}`,"g")],vW=[new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${ar}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)\\s*${ar}`,"g"),new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${ar}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${ar}`,"g")];function om(t){let e=t.split(""),r=0,o=0,n=!1,i=!1,s=!1;for(;r<t.length;){let a=t[r],c=t[r+1];if(i){s?s=!1:a==="\\"?s=!0:a==='"'&&(i=!1),r++;continue}if(n){a===` `||a==="\r"?n=!1:e[r]=" ",r++;continue}if(o>0){if(a==="/"&&c==="*"){e[r]=" ",e[r+1]=" ",o++,r+=2;continue}if(a==="*"&&c==="/"){e[r]=" ",e[r+1]=" ",o--,r+=2;continue}a!==` `&&a!=="\r"&&(e[r]=" "),r++;continue}if(a==='"'){i=!0,r++;continue}if(a==="/"&&c==="/"){e[r]=" ",e[r+1]=" ",n=!0,r+=2;continue}if(a==="/"&&c==="*"){e[r]=" ",e[r+1]=" ",o=1,r+=2;continue}r++}return e.join("")}function Qi(t,e){let r=om(t),o=[];for(let n of e){n.lastIndex=0;let i;for(i=n.exec(r);i;){let s=n===e[0],a=i.index,c=i[0].length;o.push({match:t.slice(a,a+c),index:a,length:c,bindingToken:i[s?1:2],groupToken:i[s?2:1],accessDeclaration:i[3]?.trim(),name:i[4]}),i=n.exec(r)}}return o.sort((n,i)=>n.index-i.index)}function xA(t,e,r){let o=Qi(t,e);if(!o.length)return t;let n="",i=0;for(let s of o)n+=t.slice(i,s.index),n+=r(s),i=s.index+s.length;return n+=t.slice(i),n}function bA(t){return/@binding\(\s*auto\s*\)/.test(om(t))}function kM(t,e){return Qi(t,e===Pa||e===rm?vW:e).find(o=>o.bindingToken==="auto")}var VM=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${ar}\\s*:\\s*([^;]+);`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(\\d+)\\s*\\)\\s*${ar}\\s*:\\s*([^;]+);`,"g")];function nm(t,e=[]){let r=om(t),o=new Map;for(let i of e)o.set(zM(i.name,i.group,i.location),i.moduleName);let n=[];for(let i of VM){i.lastIndex=0;let s;for(s=i.exec(r);s;){let a=i===VM[0],c=Number(s[a?1:2]),l=Number(s[a?2:1]),f=s[3]?.trim(),u=s[4],d=s[5].trim(),h=o.get(zM(u,l,c));n.push(SW({name:u,group:l,binding:c,owner:h?"module":"application",moduleName:h,accessDeclaration:f,resourceType:d})),s=i.exec(r)}}return n.sort((i,s)=>i.group!==s.group?i.group-s.group:i.binding!==s.binding?i.binding-s.binding:i.name.localeCompare(s.name))}function SW(t){let e={name:t.name,group:t.group,binding:t.binding,owner:t.owner,kind:"unknown",moduleName:t.moduleName,resourceType:t.resourceType};if(t.accessDeclaration){let r=t.accessDeclaration.split(",").map(o=>o.trim());if(r[0]==="uniform")return{...e,kind:"uniform",access:"uniform"};if(r[0]==="storage"){let o=r[1]||"read_write";return{...e,kind:o==="read"?"read-only-storage":"storage",access:o}}}return t.resourceType==="sampler"||t.resourceType==="sampler_comparison"?{...e,kind:"sampler",samplerKind:t.resourceType==="sampler_comparison"?"comparison":"filtering"}:t.resourceType.startsWith("texture_storage_")?{...e,kind:"storage-texture",access:EW(t.resourceType),viewDimension:HM(t.resourceType)}:t.resourceType.startsWith("texture_")?{...e,kind:"texture",viewDimension:HM(t.resourceType),sampleType:CW(t.resourceType),multisampled:t.resourceType.startsWith("texture_multisampled_")}:e}function zM(t,e,r){return`${e}:${r}:${t}`}function HM(t){if(t.includes("cube_array"))return"cube-array";if(t.includes("2d_array"))return"2d-array";if(t.includes("cube"))return"cube";if(t.includes("3d"))return"3d";if(t.includes("2d"))return"2d";if(t.includes("1d"))return"1d"}function CW(t){if(t.startsWith("texture_depth_"))return"depth";if(t.includes("<i32>"))return"sint";if(t.includes("<u32>"))return"uint";if(t.includes("<f32>"))return"float"}function EW(t){return/,\s*([A-Za-z_][A-Za-z0-9_]*)\s*>$/.exec(t)?.[1]}var AA=` ${cf} `,ff=100,wW=`precision highp float; `;function $M(t){let e=wa(t.modules||[]),{source:r,bindingAssignments:o}=PW(t.platformInfo,{...t,source:t.source,stage:"vertex",modules:e});return{source:r,getUniforms:YM(e),bindingAssignments:o,bindingTable:nm(r,o)}}function XM(t){let{vs:e,fs:r}=t,o=wa(t.modules||[]);return{vs:jM(t.platformInfo,{...t,source:e,stage:"vertex",modules:o}),fs:jM(t.platformInfo,{...t,source:r,stage:"fragment",modules:o}),getUniforms:YM(o)}}function PW(t,e){let{source:r,stage:o,modules:n,hookFunctions:i=[],inject:s={},log:a}=e;Zi(typeof r=="string","shader source must be a string");let c=r,l="",f=yA(i),u={},d={},h={};for(let y in s){let b=typeof s[y]=="string"?{injection:s[y],order:0}:s[y],T=/^(v|f)s:(#)?([\w-]+)$/.exec(y);if(T){let v=T[2],w=T[3];v?w==="decl"?d[y]=[b]:h[y]=[b]:u[y]=[b]}else h[y]=[b]}let p=n,m=IW(c),g=RW(m.source),_=FW(p,e._bindingRegistry,g),x=[];for(let y of p){a&&mA(y,c,a);let b=LW(KM(y,"wgsl",a),y,{usedBindingsByGroup:g,bindingRegistry:e._bindingRegistry,reservedBindingKeysByGroup:_});x.push(...b.bindingAssignments);let T=b.source;l+=T;let v=y.injections?.[o]||{};for(let w in v){let C=/^(v|f)s:#([\w-]+)$/.exec(w);if(C){let A=C[2]==="decl"?d:h;A[w]=A[w]||[],A[w].push(v[w])}else u[w]=u[w]||[],u[w].push(v[w])}}return l+=AA,l=lf(l,o,d),l+=_A(f[o],u),l+=VW(x),l+=m.source,l=lf(l,o,h),kW(l),{source:l,bindingAssignments:x}}function jM(t,e){let{source:r,stage:o,language:n="glsl",modules:i,defines:s={},hookFunctions:a=[],inject:c={},prologue:l=!0,log:f}=e;Zi(typeof r=="string","shader source must be a string");let u=n==="glsl"?DM(r).version:-1,d=t.shaderLanguageVersion,h=u===100?"#version 100":"#version 300 es",m=r.split(` `).slice(1).join(` `),g={};i.forEach(v=>{Object.assign(g,v.defines)}),Object.assign(g,s);let _="";switch(n){case"wgsl":break;case"glsl":_=l?`${h} // ----- PROLOGUE ------------------------- ${`#define SHADER_TYPE_${o.toUpperCase()}`} ${BM(t)} ${o==="fragment"?wW:""} // ----- APPLICATION DEFINES ------------------------- ${MW(g)} `:`${h} `;break}let x=yA(a),y={},b={},T={};for(let v in c){let w=typeof c[v]=="string"?{injection:c[v],order:0}:c[v],C=/^(v|f)s:(#)?([\w-]+)$/.exec(v);if(C){let S=C[2],A=C[3];S?A==="decl"?b[v]=[w]:T[v]=[w]:y[v]=[w]}else T[v]=[w]}for(let v of i){f&&mA(v,m,f);let w=KM(v,o,f);_+=w;let C=v.instance?.normalizedInjections[o]||{};for(let S in C){let A=/^(v|f)s:#([\w-]+)$/.exec(S);if(A){let B=A[2]==="decl"?b:T;B[S]=B[S]||[],B[S].push(C[S])}else y[S]=y[S]||[],y[S].push(C[S])}}return _+="// ----- MAIN SHADER SOURCE -------------------------",_+=AA,_=lf(_,o,b),_+=_A(x[o],y),_+=m,_=lf(_,o,T),n==="glsl"&&u!==d&&(_=FM(_,o)),n==="glsl"&&LM(_,o,f),_.trim()}function YM(t){return function(r){let o={};for(let n of t){let i=n.getUniforms?.(r,o);Object.assign(o,i)}return o}}function MW(t={}){let e="";for(let r in t){let o=t[r];(o||Number.isFinite(o))&&(e+=`#define ${r.toUpperCase()} ${t[r]} `)}return e}function KM(t,e,r){let o;switch(e){case"vertex":o=t.vs||"";break;case"fragment":o=t.fs||"";break;case"wgsl":o=t.source||"";break;default:Zi(!1)}if(!t.name)throw new Error("Shader module must have a name");RM(t,e,{log:r});let n=t.name.toUpperCase().replace(/[^0-9a-z]/gi,"_"),i=`// ----- MODULE ${t.name} --------------- `;return e!=="wgsl"&&(i+=`#define MODULE_${n} `),i+=`${o} `,i}function RW(t){let e=new Map;for(let r of Qi(t,UM)){let o=Number(r.bindingToken),n=Number(r.groupToken);TA(n,o,r.name),Ma(e,n,o,`application binding "${r.name}"`)}return e}function IW(t){let e=Qi(t,rm),r=new Map;for(let i of e){if(i.bindingToken==="auto")continue;let s=Number(i.bindingToken),a=Number(i.groupToken);TA(a,s,i.name),Ma(r,a,s,`application binding "${i.name}"`)}let o={sawSupportedBindingDeclaration:e.length>0},n=xA(t,rm,i=>OW(i,r,o));if(bA(t)&&!o.sawSupportedBindingDeclaration)throw new Error('Unsupported @binding(auto) declaration form in application WGSL. Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.');return{source:n}}function LW(t,e,r){let o=[],i={sawSupportedBindingDeclaration:Qi(t,Pa).length>0,nextHintedBindingLocation:typeof e.firstBindingSlot=="number"?e.firstBindingSlot:null},s=xA(t,Pa,a=>BW(a,{module:e,context:r,bindingAssignments:o,relocationState:i}));if(bA(t)&&!i.sawSupportedBindingDeclaration)throw new Error(`Unsupported @binding(auto) declaration form in module "${e.name}". Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.`);return{source:s,bindingAssignments:o}}function BW(t,e){let{module:r,context:o,bindingAssignments:n,relocationState:i}=e,{match:s,bindingToken:a,groupToken:c,name:l}=t,f=Number(c);if(a==="auto"){let d=qM(f,r.name,l),h=o.bindingRegistry?.get(d),p=h!==void 0?h:i.nextHintedBindingLocation===null?GM(f,o.usedBindingsByGroup):GM(f,o.usedBindingsByGroup,i.nextHintedBindingLocation);return WM(r.name,f,p,l),h!==void 0&&NW(o.reservedBindingKeysByGroup,f,p,d)?(n.push({moduleName:r.name,name:l,group:f,location:p}),s.replace(/@binding\(\s*auto\s*\)/,`@binding(${p})`)):(Ma(o.usedBindingsByGroup,f,p,`module "${r.name}" binding "${l}"`),o.bindingRegistry?.set(d,p),n.push({moduleName:r.name,name:l,group:f,location:p}),i.nextHintedBindingLocation!==null&&h===void 0&&(i.nextHintedBindingLocation=p+1),s.replace(/@binding\(\s*auto\s*\)/,`@binding(${p})`))}let u=Number(a);return WM(r.name,f,u,l),Ma(o.usedBindingsByGroup,f,u,`module "${r.name}" binding "${l}"`),n.push({moduleName:r.name,name:l,group:f,location:u}),s}function OW(t,e,r){let{match:o,bindingToken:n,groupToken:i,name:s}=t,a=Number(i);if(n==="auto"){let c=UW(a,e);return TA(a,c,s),Ma(e,a,c,`application binding "${s}"`),o.replace(/@binding\(\s*auto\s*\)/,`@binding(${c})`)}return r.sawSupportedBindingDeclaration=!0,o}function FW(t,e,r){let o=new Map;if(!e)return o;for(let n of t)for(let i of DW(n)){let s=qM(i.group,n.name,i.name),a=e.get(s);if(a!==void 0){let c=o.get(i.group)||new Map,l=c.get(a);if(l&&l!==s)throw new Error(`Duplicate WGSL binding reservation for modules "${l}" and "${s}": group ${i.group}, binding ${a}.`);Ma(r,i.group,a,`registered module binding "${s}"`),c.set(a,s),o.set(i.group,c)}}return o}function NW(t,e,r,o){let n=t.get(e);if(!n)return!1;let i=n.get(r);if(!i)return!1;if(i!==o)throw new Error(`Registered module binding "${o}" collided with "${i}": group ${e}, binding ${r}.`);return!0}function DW(t){let e=[],r=t.source||"";for(let o of Qi(r,Pa))e.push({name:o.name,group:Number(o.groupToken)});return e}function TA(t,e,r){if(t===0&&e>=ff)throw new Error(`Application binding "${r}" in group 0 uses reserved binding ${e}. Application-owned explicit group-0 bindings must stay below ${ff}.`)}function WM(t,e,r,o){if(e===0&&r<ff)throw new Error(`Module "${t}" binding "${o}" in group 0 uses reserved application binding ${r}. Module-owned explicit group-0 bindings must be ${ff} or higher.`)}function Ma(t,e,r,o){let n=t.get(e)||new Set;if(n.has(r))throw new Error(`Duplicate WGSL binding assignment for ${o}: group ${e}, binding ${r}.`);n.add(r),t.set(e,n)}function GM(t,e,r){let o=e.get(t)||new Set,n=r??(t===0?ff:o.size>0?Math.max(...o)+1:0);for(;o.has(n);)n++;return n}function UW(t,e){let r=e.get(t)||new Set,o=0;for(;r.has(o);)o++;return o}function kW(t){let e=kM(t,Pa);if(!e)return;let r=zW(t,e.index);throw r?new Error(`Unresolved @binding(auto) for module "${r}" binding "${e.name}" remained in assembled WGSL source.`):HW(t,e.index)?new Error(`Unresolved @binding(auto) for application binding "${e.name}" remained in assembled WGSL source.`):new Error(`Unresolved @binding(auto) remained in assembled WGSL source near "${jW(e.match)}".`)}function VW(t){if(t.length===0)return"";let e=`// ----- MODULE WGSL BINDING ASSIGNMENTS --------------- `;for(let r of t)e+=`// ${r.moduleName}.${r.name} -> @group(${r.group}) @binding(${r.location}) `;return e+=` `,e}function qM(t,e,r){return`${t}:${e}:${r}`}function zW(t,e){let r=/^\/\/ ----- MODULE ([^\n]+) ---------------$/gm,o,n;for(n=r.exec(t);n&&n.index<=e;)o=n[1],n=r.exec(t);return o}function HW(t,e){let r=t.indexOf(AA);return r>=0?e>r:!0}function jW(t){return t.replace(/\s+/g," ").trim()}var vA="([a-zA-Z_][a-zA-Z0-9_]*)",WW=new RegExp(`^\\s*\\#\\s*ifdef\\s*${vA}\\s*$`),GW=new RegExp(`^\\s*\\#\\s*ifndef\\s*${vA}\\s*(?:\\/\\/.*)?$`),$W=/^\s*\#\s*else\s*(?:\/\/.*)?$/,XW=/^\s*\#\s*endif\s*$/,YW=new RegExp(`^\\s*\\#\\s*ifdef\\s*${vA}\\s*(?:\\/\\/.*)?$`),KW=/^\s*\#\s*endif\s*(?:\/\/.*)?$/;function ZM(t,e){let r=t.split(` `),o=[],n=[],i=!0;for(let s of r){let a=s.match(YW)||s.match(WW),c=s.match(GW),l=s.match($W),f=s.match(KW)||s.match(XW);if(a||c){let u=(a||c)?.[1],d=Boolean(e?.defines?.[u]),h=a?d:!d,p=i&&h;n.push({parentActive:i,branchTaken:h,active:p}),i=p}else if(l){let u=n[n.length-1];if(!u)throw new Error("Encountered #else without matching #ifdef or #ifndef");u.active=u.parentActive&&!u.branchTaken,u.branchTaken=!0,i=u.active}else f?(n.pop(),i=n.length?n[n.length-1].active:!0):i&&o.push(s)}if(n.length>0)throw new Error("Unterminated conditional block in shader source");return o.join(` `)}var Ra=class{_hookFunctions=[];_defaultModules=[];_wgslBindingRegistry=new Map;static getDefaultShaderAssembler(){return Ra.defaultShaderAssembler=Ra.defaultShaderAssembler||new Ra,Ra.defaultShaderAssembler}addDefaultModule(e){this._defaultModules.find(r=>r.name===(typeof e=="string"?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){let r=typeof e=="string"?e:e.name;this._defaultModules=this._defaultModules.filter(o=>o.name!==r)}addShaderHook(e,r){r&&(e=Object.assign(r,{hook:e})),this._hookFunctions.push(e)}assembleWGSLShader(e){let r=this._getModuleList(e.modules),o=this._hookFunctions,{source:n,getUniforms:i,bindingAssignments:s}=$M({...e,source:e.source,_bindingRegistry:this._wgslBindingRegistry,modules:r,hookFunctions:o}),a={...r.reduce((l,f)=>(Object.assign(l,f.defines),l),{}),...e.defines},c=e.platformInfo.shaderLanguage==="wgsl"?ZM(n,{defines:a}):n;return{source:c,getUniforms:i,modules:r,bindingAssignments:s,bindingTable:nm(c,s)}}assembleGLSLShaderPair(e){let r=this._getModuleList(e.modules),o=this._hookFunctions;return{...XM({...e,vs:e.vs,fs:e.fs,modules:r,hookFunctions:o}),modules:r}}_getModuleList(e=[]){let r=new Array(this._defaultModules.length+e.length),o={},n=0;for(let i=0,s=this._defaultModules.length;i<s;++i){let a=this._defaultModules[i],c=a.name;r[n++]=a,o[c]=!0}for(let i=0,s=e.length;i<s;++i){let a=e[i],c=a.name;o[c]||(r[n++]=a,o[c]=!0)}return r.length=n,Ji(r),r}},Zn=Ra;k(Zn,"defaultShaderAssembler");var qW=`out vec4 transform_output; void main() { transform_output = vec4(0); }`,ZW=`#version 300 es ${qW}`;function uf(t){let{input:e,inputChannels:r,output:o}=t||{};if(!e)return ZW;if(!r)throw new Error("inputChannels");let n=JW(r),i=JM(e,r);return`#version 300 es in ${n} ${e}; out vec4 ${o}; void main() { ${o} = ${i}; }`}function JW(t){switch(t){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`invalid channels: ${t}`)}}function JM(t,e){switch(e){case 1:return`vec4(${t}, 0.0, 0.0, 1.0)`;case 2:return`vec4(${t}, 0.0, 1.0)`;case 3:return`vec4(${t}, 1.0)`;case 4:return t;default:throw new Error(`invalid channels: ${e}`)}}var QW=1/Math.PI*180,eG=1/180*Math.PI,tG={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...tG}};var ve=globalThis.mathgl.config;function df(t,{precision:e=ve.precision}={}){return t=rG(t),`${parseFloat(t.toPrecision(e))}`}function cr(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function SA(t){return es(t)}function CA(t){return rt(t)}function es(t,e){return EA(t,r=>r*eG,e)}function rt(t,e){return EA(t,r=>r*QW,e)}function ee(t,e,r){return EA(t,o=>Math.max(e,Math.min(r,o)))}function lt(t,e,r){return cr(t)?t.map((o,n)=>lt(o,e[n],r)):r*e+(1-r)*t}function Ce(t,e,r){let o=ve.EPSILON;r&&(ve.EPSILON=r);try{if(t===e)return!0;if(cr(t)&&cr(e)){if(t.length!==e.length)return!1;for(let n=0;n<t.length;++n)if(!Ce(t[n],e[n]))return!1;return!0}return t&&t.equals?t.equals(e):e&&e.equals?e.equals(t):typeof t=="number"&&typeof e=="number"?Math.abs(t-e)<=ve.EPSILON*Math.max(1,Math.abs(t),Math.abs(e)):!1}finally{ve.EPSILON=o}}function rG(t){return Math.round(t/ve.EPSILON)*ve.EPSILON}function oG(t){return t.clone?t.clone():new Array(t.length)}function EA(t,e,r){if(cr(t)){let o=t;r=r||oG(o);for(let n=0;n<r.length&&n<o.length;++n){let i=typeof t=="number"?t:t[n];r[n]=e(i,n,r)}return r}return e(t)}var Jn=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,r=0){for(let o=0;o<this.ELEMENTS;++o)this[o]=e[o+r];return this.check()}toArray(e=[],r=0){for(let o=0;o<this.ELEMENTS;++o)e[r+o]=this[o];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:cr(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(ve)}formatString(e){let r="";for(let o=0;o<this.ELEMENTS;++o)r+=(o>0?", ":"")+df(this[o],e);return`${e.printTypes?this.constructor.name:""}[${r}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(!Ce(this[r],e[r]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(this[r]!==e[r])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,r,o){if(o===void 0)return this.lerp(this,e,r);for(let n=0;n<this.ELEMENTS;++n){let i=e[n],s=typeof r=="number"?r:r[n];this[n]=i+o*(s-i)}return this.check()}min(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(e[r],this[r]);return this.check()}max(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.max(e[r],this[r]);return this.check()}clamp(e,r){for(let o=0;o<this.ELEMENTS;++o)this[o]=Math.min(Math.max(this[o],e[o]),r[o]);return this.check()}add(...e){for(let r of e)for(let o=0;o<this.ELEMENTS;++o)this[o]+=r[o];return this.check()}subtract(...e){for(let r of e)for(let o=0;o<this.ELEMENTS;++o)this[o]-=r[o];return this.check()}scale(e){if(typeof e=="number")for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;else for(let r=0;r<this.ELEMENTS&&r<e.length;++r)this[r]*=e[r];return this.check()}multiplyByScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;return this.check()}check(){if(ve.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let e=this.length===this.ELEMENTS;for(let r=0;r<this.ELEMENTS;++r)e=e&&Number.isFinite(this[r]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=e;return this.check()}addScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,r){for(let o=0;o<this.ELEMENTS;++o)this[o]=Math.min(Math.max(this[o],e),r);return this.check()}get elements(){return this}};function nG(t,e){if(t.length!==e)return!1;for(let r=0;r<t.length;++r)if(!Number.isFinite(t[r]))return!1;return!0}function he(t){if(!Number.isFinite(t))throw new Error(`Invalid number ${JSON.stringify(t)}`);return t}function Qn(t,e,r=""){if(ve.debug&&!nG(t,e))throw new Error(`math.gl: ${r} some fields set to invalid numbers'`);return t}function ht(t,e){if(!t)throw new Error(`math.gl assertion ${e}`)}var ei=class extends Jn{get x(){return this[0]}set x(e){this[0]=he(e)}get y(){return this[1]}set y(e){this[1]=he(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let r=0;r<this.ELEMENTS;++r)e+=this[r]*this[r];return e}magnitudeSquared(){return this.lengthSquared()}distance(e){return Math.sqrt(this.distanceSquared(e))}distanceSquared(e){let r=0;for(let o=0;o<this.ELEMENTS;++o){let n=this[o]-e[o];r+=n*n}return he(r)}dot(e){let r=0;for(let o=0;o<this.ELEMENTS;++o)r+=this[o]*e[o];return he(r)}normalize(){let e=this.magnitude();if(e!==0)for(let r=0;r<this.ELEMENTS;++r)this[r]/=e;return this.check()}multiply(...e){for(let r of e)for(let o=0;o<this.ELEMENTS;++o)this[o]*=r[o];return this.check()}divide(...e){for(let r of e)for(let o=0;o<this.ELEMENTS;++o)this[o]/=r[o];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(e){return this.distance(e)}distanceToSquared(e){return this.distanceSquared(e)}getComponent(e){return ht(e>=0&&e<this.ELEMENTS,"index is out of range"),he(this[e])}setComponent(e,r){return ht(e>=0&&e<this.ELEMENTS,"index is out of range"),this[e]=r,this.check()}addVectors(e,r){return this.copy(e).add(r)}subVectors(e,r){return this.copy(e).subtract(r)}multiplyVectors(e,r){return this.copy(e).multiply(r)}addScaledVector(e,r){return this.add(new this.constructor(e).multiplyScalar(r))}};var Ye={};ze(Ye,{add:()=>lG,angle:()=>CG,ceil:()=>fG,clone:()=>iG,copy:()=>aG,create:()=>QM,cross:()=>AG,dist:()=>OG,distance:()=>oR,div:()=>BG,divide:()=>rR,dot:()=>bG,equals:()=>MG,exactEquals:()=>PG,floor:()=>uG,forEach:()=>DG,fromValues:()=>sG,inverse:()=>yG,len:()=>RG,length:()=>iR,lerp:()=>TG,max:()=>hG,min:()=>dG,mul:()=>LG,multiply:()=>tR,negate:()=>_G,normalize:()=>xG,random:()=>vG,rotate:()=>SG,round:()=>pG,scale:()=>mG,scaleAndAdd:()=>gG,set:()=>cG,sqrDist:()=>FG,sqrLen:()=>NG,squaredDistance:()=>nR,squaredLength:()=>sR,str:()=>wG,sub:()=>IG,subtract:()=>eR,transformMat2:()=>wA,transformMat2d:()=>PA,transformMat3:()=>hf,transformMat4:()=>pf,zero:()=>EG});var Ee=typeof Float32Array<"u"?Float32Array:Array,To=Math.random;function vr(t){return t>=0?Math.round(t):t%.5===0?Math.floor(t):Math.round(t)}var uve=Math.PI/180;function QM(){let t=new Ee(2);return Ee!=Float32Array&&(t[0]=0,t[1]=0),t}function iG(t){let e=new Ee(2);return e[0]=t[0],e[1]=t[1],e}function sG(t,e){let r=new Ee(2);return r[0]=t,r[1]=e,r}function aG(t,e){return t[0]=e[0],t[1]=e[1],t}function cG(t,e,r){return t[0]=e,t[1]=r,t}function lG(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t}function eR(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t}function tR(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t}function rR(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t}function fG(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t}function uG(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t}function dG(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t}function hG(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t}function pG(t,e){return t[0]=vr(e[0]),t[1]=vr(e[1]),t}function mG(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t}function gG(t,e,r,o){return t[0]=e[0]+r[0]*o,t[1]=e[1]+r[1]*o,t}function oR(t,e){let r=e[0]-t[0],o=e[1]-t[1];return Math.sqrt(r*r+o*o)}function nR(t,e){let r=e[0]-t[0],o=e[1]-t[1];return r*r+o*o}function iR(t){let e=t[0],r=t[1];return Math.sqrt(e*e+r*r)}function sR(t){let e=t[0],r=t[1];return e*e+r*r}function _G(t,e){return t[0]=-e[0],t[1]=-e[1],t}function yG(t,e){return t[0]=1/e[0],t[1]=1/e[1],t}function xG(t,e){let r=e[0],o=e[1],n=r*r+o*o;return n>0&&(n=1/Math.sqrt(n)),t[0]=e[0]*n,t[1]=e[1]*n,t}function bG(t,e){return t[0]*e[0]+t[1]*e[1]}function AG(t,e,r){let o=e[0]*r[1]-e[1]*r[0];return t[0]=t[1]=0,t[2]=o,t}function TG(t,e,r,o){let n=e[0],i=e[1];return t[0]=n+o*(r[0]-n),t[1]=i+o*(r[1]-i),t}function vG(t,e){e=e===void 0?1:e;let r=To()*2*Math.PI;return t[0]=Math.cos(r)*e,t[1]=Math.sin(r)*e,t}function wA(t,e,r){let o=e[0],n=e[1];return t[0]=r[0]*o+r[2]*n,t[1]=r[1]*o+r[3]*n,t}function PA(t,e,r){let o=e[0],n=e[1];return t[0]=r[0]*o+r[2]*n+r[4],t[1]=r[1]*o+r[3]*n+r[5],t}function hf(t,e,r){let o=e[0],n=e[1];return t[0]=r[0]*o+r[3]*n+r[6],t[1]=r[1]*o+r[4]*n+r[7],t}function pf(t,e,r){let o=e[0],n=e[1];return t[0]=r[0]*o+r[4]*n+r[12],t[1]=r[1]*o+r[5]*n+r[13],t}function SG(t,e,r,o){let n=e[0]-r[0],i=e[1]-r[1],s=Math.sin(o),a=Math.cos(o);return t[0]=n*a-i*s+r[0],t[1]=n*s+i*a+r[1],t}function CG(t,e){let r=t[0],o=t[1],n=e[0],i=e[1],s=Math.sqrt((r*r+o*o)*(n*n+i*i)),a=s&&(r*n+o*i)/s;return Math.acos(Math.min(Math.max(a,-1),1))}function EG(t){return t[0]=0,t[1]=0,t}function wG(t){return`vec2(${t[0]}, ${t[1]})`}function PG(t,e){return t[0]===e[0]&&t[1]===e[1]}function MG(t,e){let r=t[0],o=t[1],n=e[0],i=e[1];return Math.abs(r-n)<=1e-6*Math.max(1,Math.abs(r),Math.abs(n))&&Math.abs(o-i)<=1e-6*Math.max(1,Math.abs(o),Math.abs(i))}var RG=iR,IG=eR,LG=tR,BG=rR,OG=oR,FG=nR,NG=sR,DG=function(){let t=QM();return function(e,r,o,n,i,s){let a,c;for(r||(r=2),o||(o=0),n?c=Math.min(n*r+o,e.length):c=e.length,a=o;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],i(t,t,s),e[a]=t[0],e[a+1]=t[1];return e}}();function im(t,e,r){let o=e[0],n=e[1],i=r[3]*o+r[7]*n||1;return t[0]=(r[0]*o+r[4]*n)/i,t[1]=(r[1]*o+r[5]*n)/i,t}function sm(t,e,r){let o=e[0],n=e[1],i=e[2],s=r[3]*o+r[7]*n+r[11]*i||1;return t[0]=(r[0]*o+r[4]*n+r[8]*i)/s,t[1]=(r[1]*o+r[5]*n+r[9]*i)/s,t[2]=(r[2]*o+r[6]*n+r[10]*i)/s,t}function aR(t,e,r){let o=e[0],n=e[1];return t[0]=r[0]*o+r[2]*n,t[1]=r[1]*o+r[3]*n,t[2]=e[2],t}function cR(t,e,r){let o=e[0],n=e[1];return t[0]=r[0]*o+r[2]*n,t[1]=r[1]*o+r[3]*n,t[2]=e[2],t[3]=e[3],t}function am(t,e,r){let o=e[0],n=e[1],i=e[2];return t[0]=r[0]*o+r[3]*n+r[6]*i,t[1]=r[1]*o+r[4]*n+r[7]*i,t[2]=r[2]*o+r[5]*n+r[8]*i,t[3]=e[3],t}var Gr=class extends ei{constructor(e=0,r=0){super(2),cr(e)&&arguments.length===1?this.copy(e):(ve.debug&&(he(e),he(r)),this[0]=e,this[1]=r)}set(e,r){return this[0]=e,this[1]=r,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this.check()}fromObject(e){return ve.debug&&(he(e.x),he(e.y)),this[0]=e.x,this[1]=e.y,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e}get ELEMENTS(){return 2}horizontalAngle(){return Math.atan2(this.y,this.x)}verticalAngle(){return Math.atan2(this.x,this.y)}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return pf(this,this,e),this.check()}transformAsVector(e){return im(this,this,e),this.check()}transformByMatrix3(e){return hf(this,this,e),this.check()}transformByMatrix2x3(e){return PA(this,this,e),this.check()}transformByMatrix2(e){return wA(this,this,e),this.check()}};var Ke={};ze(Ke,{add:()=>zG,angle:()=>BA,bezier:()=>e9,ceil:()=>HG,clone:()=>UG,copy:()=>kG,create:()=>cm,cross:()=>ts,dist:()=>l9,distance:()=>dR,div:()=>c9,divide:()=>uR,dot:()=>mf,equals:()=>i9,exactEquals:()=>n9,floor:()=>jG,forEach:()=>d9,fromValues:()=>fm,hermite:()=>QG,inverse:()=>qG,len:()=>OA,length:()=>lm,lerp:()=>ZG,max:()=>GG,min:()=>WG,mul:()=>a9,multiply:()=>fR,negate:()=>KG,normalize:()=>MA,random:()=>t9,rotateX:()=>RA,rotateY:()=>IA,rotateZ:()=>LA,round:()=>$G,scale:()=>XG,scaleAndAdd:()=>YG,set:()=>VG,slerp:()=>JG,sqrDist:()=>f9,sqrLen:()=>u9,squaredDistance:()=>hR,squaredLength:()=>pR,str:()=>o9,sub:()=>s9,subtract:()=>lR,transformMat3:()=>gf,transformMat4:()=>rs,transformQuat:()=>_f,zero:()=>r9});function cm(){let t=new Ee(3);return Ee!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function UG(t){let e=new Ee(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function lm(t){let e=t[0],r=t[1],o=t[2];return Math.sqrt(e*e+r*r+o*o)}function fm(t,e,r){let o=new Ee(3);return o[0]=t,o[1]=e,o[2]=r,o}function kG(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function VG(t,e,r,o){return t[0]=e,t[1]=r,t[2]=o,t}function zG(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function lR(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function fR(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function uR(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}function HG(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t}function jG(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t}function WG(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t}function GG(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t}function $G(t,e){return t[0]=vr(e[0]),t[1]=vr(e[1]),t[2]=vr(e[2]),t}function XG(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function YG(t,e,r,o){return t[0]=e[0]+r[0]*o,t[1]=e[1]+r[1]*o,t[2]=e[2]+r[2]*o,t}function dR(t,e){let r=e[0]-t[0],o=e[1]-t[1],n=e[2]-t[2];return Math.sqrt(r*r+o*o+n*n)}function hR(t,e){let r=e[0]-t[0],o=e[1]-t[1],n=e[2]-t[2];return r*r+o*o+n*n}function pR(t){let e=t[0],r=t[1],o=t[2];return e*e+r*r+o*o}function KG(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}function qG(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t}function MA(t,e){let r=e[0],o=e[1],n=e[2],i=r*r+o*o+n*n;return i>0&&(i=1/Math.sqrt(i)),t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t}function mf(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function ts(t,e,r){let o=e[0],n=e[1],i=e[2],s=r[0],a=r[1],c=r[2];return t[0]=n*c-i*a,t[1]=i*s-o*c,t[2]=o*a-n*s,t}function ZG(t,e,r,o){let n=e[0],i=e[1],s=e[2];return t[0]=n+o*(r[0]-n),t[1]=i+o*(r[1]-i),t[2]=s+o*(r[2]-s),t}function JG(t,e,r,o){let n=Math.acos(Math.min(Math.max(mf(e,r),-1),1)),i=Math.sin(n),s=Math.sin((1-o)*n)/i,a=Math.sin(o*n)/i;return t[0]=s*e[0]+a*r[0],t[1]=s*e[1]+a*r[1],t[2]=s*e[2]+a*r[2],t}function QG(t,e,r,o,n,i){let s=i*i,a=s*(2*i-3)+1,c=s*(i-2)+i,l=s*(i-1),f=s*(3-2*i);return t[0]=e[0]*a+r[0]*c+o[0]*l+n[0]*f,t[1]=e[1]*a+r[1]*c+o[1]*l+n[1]*f,t[2]=e[2]*a+r[2]*c+o[2]*l+n[2]*f,t}function e9(t,e,r,o,n,i){let s=1-i,a=s*s,c=i*i,l=a*s,f=3*i*a,u=3*c*s,d=c*i;return t[0]=e[0]*l+r[0]*f+o[0]*u+n[0]*d,t[1]=e[1]*l+r[1]*f+o[1]*u+n[1]*d,t[2]=e[2]*l+r[2]*f+o[2]*u+n[2]*d,t}function t9(t,e){e=e===void 0?1:e;let r=To()*2*Math.PI,o=To()*2-1,n=Math.sqrt(1-o*o)*e;return t[0]=Math.cos(r)*n,t[1]=Math.sin(r)*n,t[2]=o*e,t}function rs(t,e,r){let o=e[0],n=e[1],i=e[2],s=r[3]*o+r[7]*n+r[11]*i+r[15];return s=s||1,t[0]=(r[0]*o+r[4]*n+r[8]*i+r[12])/s,t[1]=(r[1]*o+r[5]*n+r[9]*i+r[13])/s,t[2]=(r[2]*o+r[6]*n+r[10]*i+r[14])/s,t}function gf(t,e,r){let o=e[0],n=e[1],i=e[2];return t[0]=o*r[0]+n*r[3]+i*r[6],t[1]=o*r[1]+n*r[4]+i*r[7],t[2]=o*r[2]+n*r[5]+i*r[8],t}function _f(t,e,r){let o=r[0],n=r[1],i=r[2],s=r[3],a=e[0],c=e[1],l=e[2],f=n*l-i*c,u=i*a-o*l,d=o*c-n*a,h=n*d-i*u,p=i*f-o*d,m=o*u-n*f,g=s*2;return f*=g,u*=g,d*=g,h*=2,p*=2,m*=2,t[0]=a+f+h,t[1]=c+u+p,t[2]=l+d+m,t}function RA(t,e,r,o){let n=[],i=[];return n[0]=e[0]-r[0],n[1]=e[1]-r[1],n[2]=e[2]-r[2],i[0]=n[0],i[1]=n[1]*Math.cos(o)-n[2]*Math.sin(o),i[2]=n[1]*Math.sin(o)+n[2]*Math.cos(o),t[0]=i[0]+r[0],t[1]=i[1]+r[1],t[2]=i[2]+r[2],t}function IA(t,e,r,o){let n=[],i=[];return n[0]=e[0]-r[0],n[1]=e[1]-r[1],n[2]=e[2]-r[2],i[0]=n[2]*Math.sin(o)+n[0]*Math.cos(o),i[1]=n[1],i[2]=n[2]*Math.cos(o)-n[0]*Math.sin(o),t[0]=i[0]+r[0],t[1]=i[1]+r[1],t[2]=i[2]+r[2],t}function LA(t,e,r,o){let n=[],i=[];return n[0]=e[0]-r[0],n[1]=e[1]-r[1],n[2]=e[2]-r[2],i[0]=n[0]*Math.cos(o)-n[1]*Math.sin(o),i[1]=n[0]*Math.sin(o)+n[1]*Math.cos(o),i[2]=n[2],t[0]=i[0]+r[0],t[1]=i[1]+r[1],t[2]=i[2]+r[2],t}function BA(t,e){let r=t[0],o=t[1],n=t[2],i=e[0],s=e[1],a=e[2],c=Math.sqrt((r*r+o*o+n*n)*(i*i+s*s+a*a)),l=c&&mf(t,e)/c;return Math.acos(Math.min(Math.max(l,-1),1))}function r9(t){return t[0]=0,t[1]=0,t[2]=0,t}function o9(t){return`vec3(${t[0]}, ${t[1]}, ${t[2]})`}function n9(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}function i9(t,e){let r=t[0],o=t[1],n=t[2],i=e[0],s=e[1],a=e[2];return Math.abs(r-i)<=1e-6*Math.max(1,Math.abs(r),Math.abs(i))&&Math.abs(o-s)<=1e-6*Math.max(1,Math.abs(o),Math.abs(s))&&Math.abs(n-a)<=1e-6*Math.max(1,Math.abs(n),Math.abs(a))}var s9=lR,a9=fR,c9=uR,l9=dR,f9=hR,OA=lm,u9=pR,d9=function(){let t=cm();return function(e,r,o,n,i,s){let a,c;for(r||(r=3),o||(o=0),n?c=Math.min(n*r+o,e.length):c=e.length,a=o;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],i(t,t,s),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2];return e}}();var FA=[0,0,0],um,E=class extends ei{static get ZERO(){return um||(um=new E(0,0,0),Object.freeze(um)),um}constructor(e=0,r=0,o=0){super(-0,-0,-0),arguments.length===1&&cr(e)?this.copy(e):(ve.debug&&(he(e),he(r),he(o)),this[0]=e,this[1]=r,this[2]=o)}set(e,r,o){return this[0]=e,this[1]=r,this[2]=o,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return ve.debug&&(he(e.x),he(e.y),he(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}get ELEMENTS(){return 3}get z(){return this[2]}set z(e){this[2]=he(e)}angle(e){return BA(this,e)}cross(e){return ts(this,this,e),this.check()}rotateX({radians:e,origin:r=FA}){return RA(this,this,r,e),this.check()}rotateY({radians:e,origin:r=FA}){return IA(this,this,r,e),this.check()}rotateZ({radians:e,origin:r=FA}){return LA(this,this,r,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return rs(this,this,e),this.check()}transformAsVector(e){return sm(this,this,e),this.check()}transformByMatrix3(e){return gf(this,this,e),this.check()}transformByMatrix2(e){return aR(this,this,e),this.check()}transformByQuaternion(e){return _f(this,this,e),this.check()}};var dm,La=class extends ei{static get ZERO(){return dm||(dm=new La(0,0,0,0),Object.freeze(dm)),dm}constructor(e=0,r=0,o=0,n=0){super(-0,-0,-0,-0),cr(e)&&arguments.length===1?this.copy(e):(ve.debug&&(he(e),he(r),he(o),he(n)),this[0]=e,this[1]=r,this[2]=o,this[3]=n)}set(e,r,o,n){return this[0]=e,this[1]=r,this[2]=o,this[3]=n,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}fromObject(e){return ve.debug&&(he(e.x),he(e.y),he(e.z),he(e.w)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e.w=this[3],e}get ELEMENTS(){return 4}get z(){return this[2]}set z(e){this[2]=he(e)}get w(){return this[3]}set w(e){this[3]=he(e)}transform(e){return rs(this,this,e),this.check()}transformByMatrix3(e){return am(this,this,e),this.check()}transformByMatrix2(e){return cR(this,this,e),this.check()}transformByQuaternion(e){return _f(this,this,e),this.check()}applyMatrix4(e){return e.transform(this,this),this}};var Ba=class extends Jn{toString(){let e="[";if(ve.printRowMajor){e+="row-major:";for(let r=0;r<this.RANK;++r)for(let o=0;o<this.RANK;++o)e+=` ${this[o*this.RANK+r]}`}else{e+="column-major:";for(let r=0;r<this.ELEMENTS;++r)e+=` ${this[r]}`}return e+="]",e}getElementIndex(e,r){return r*this.RANK+e}getElement(e,r){return this[r*this.RANK+e]}setElement(e,r,o){return this[r*this.RANK+e]=he(o),this}getColumn(e,r=new Array(this.RANK).fill(-0)){let o=e*this.RANK;for(let n=0;n<this.RANK;++n)r[n]=this[o+n];return r}setColumn(e,r){let o=e*this.RANK;for(let n=0;n<this.RANK;++n)this[o+n]=r[n];return this}};function mR(){let t=new Ee(9);return Ee!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function gR(t,e){if(t===e){let r=e[1],o=e[2],n=e[5];t[1]=e[3],t[2]=e[6],t[3]=r,t[5]=e[7],t[6]=o,t[7]=n}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t}function _R(t,e){let r=e[0],o=e[1],n=e[2],i=e[3],s=e[4],a=e[5],c=e[6],l=e[7],f=e[8],u=f*s-a*l,d=-f*i+a*c,h=l*i-s*c,p=r*u+o*d+n*h;return p?(p=1/p,t[0]=u*p,t[1]=(-f*o+n*l)*p,t[2]=(a*o-n*s)*p,t[3]=d*p,t[4]=(f*r-n*c)*p,t[5]=(-a*r+n*i)*p,t[6]=h*p,t[7]=(-l*r+o*c)*p,t[8]=(s*r-o*i)*p,t):null}function yR(t){let e=t[0],r=t[1],o=t[2],n=t[3],i=t[4],s=t[5],a=t[6],c=t[7],l=t[8];return e*(l*i-s*c)+r*(-l*n+s*a)+o*(c*n-i*a)}function NA(t,e,r){let o=e[0],n=e[1],i=e[2],s=e[3],a=e[4],c=e[5],l=e[6],f=e[7],u=e[8],d=r[0],h=r[1],p=r[2],m=r[3],g=r[4],_=r[5],x=r[6],y=r[7],b=r[8];return t[0]=d*o+h*s+p*l,t[1]=d*n+h*a+p*f,t[2]=d*i+h*c+p*u,t[3]=m*o+g*s+_*l,t[4]=m*n+g*a+_*f,t[5]=m*i+g*c+_*u,t[6]=x*o+y*s+b*l,t[7]=x*n+y*a+b*f,t[8]=x*i+y*c+b*u,t}function xR(t,e,r){let o=e[0],n=e[1],i=e[2],s=e[3],a=e[4],c=e[5],l=e[6],f=e[7],u=e[8],d=r[0],h=r[1];return t[0]=o,t[1]=n,t[2]=i,t[3]=s,t[4]=a,t[5]=c,t[6]=d*o+h*s+l,t[7]=d*n+h*a+f,t[8]=d*i+h*c+u,t}function bR(t,e,r){let o=e[0],n=e[1],i=e[2],s=e[3],a=e[4],c=e[5],l=e[6],f=e[7],u=e[8],d=Math.sin(r),h=Math.cos(r);return t[0]=h*o+d*s,t[1]=h*n+d*a,t[2]=h*i+d*c,t[3]=h*s-d*o,t[4]=h*a-d*n,t[5]=h*c-d*i,t[6]=l,t[7]=f,t[8]=u,t}function DA(t,e,r){let o=r[0],n=r[1];return t[0]=o*e[0],t[1]=o*e[1],t[2]=o*e[2],t[3]=n*e[3],t[4]=n*e[4],t[5]=n*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t}function AR(t,e){let r=e[0],o=e[1],n=e[2],i=e[3],s=r+r,a=o+o,c=n+n,l=r*s,f=o*s,u=o*a,d=n*s,h=n*a,p=n*c,m=i*s,g=i*a,_=i*c;return t[0]=1-u-p,t[3]=f-_,t[6]=d+g,t[1]=f+_,t[4]=1-l-p,t[7]=h-m,t[2]=d-g,t[5]=h+m,t[8]=1-l-u,t}var UA;(function(t){t[t.COL0ROW0=0]="COL0ROW0",t[t.COL0ROW1=1]="COL0ROW1",t[t.COL0ROW2=2]="COL0ROW2",t[t.COL1ROW0=3]="COL1ROW0",t[t.COL1ROW1=4]="COL1ROW1",t[t.COL1ROW2=5]="COL1ROW2",t[t.COL2ROW0=6]="COL2ROW0",t[t.COL2ROW1=7]="COL2ROW1",t[t.COL2ROW2=8]="COL2ROW2"})(UA||(UA={}));var p9=Object.freeze([1,0,0,0,1,0,0,0,1]),ue=class extends Ba{static get IDENTITY(){return g9()}static get ZERO(){return m9()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return UA}constructor(e,...r){super(-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):r.length>0?this.copy([e,...r]):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this.check()}identity(){return this.copy(p9)}fromObject(e){return this.check()}fromQuaternion(e){return AR(this,e),this.check()}set(e,r,o,n,i,s,a,c,l){return this[0]=e,this[1]=r,this[2]=o,this[3]=n,this[4]=i,this[5]=s,this[6]=a,this[7]=c,this[8]=l,this.check()}setRowMajor(e,r,o,n,i,s,a,c,l){return this[0]=e,this[1]=n,this[2]=a,this[3]=r,this[4]=i,this[5]=c,this[6]=o,this[7]=s,this[8]=l,this.check()}determinant(){return yR(this)}transpose(){return gR(this,this),this.check()}invert(){return _R(this,this),this.check()}multiplyLeft(e){return NA(this,e,this),this.check()}multiplyRight(e){return NA(this,this,e),this.check()}rotate(e){return bR(this,this,e),this.check()}scale(e){return Array.isArray(e)?DA(this,this,e):DA(this,this,[e,e]),this.check()}translate(e){return xR(this,this,e),this.check()}transform(e,r){let o;switch(e.length){case 2:o=hf(r||[-0,-0],e,this);break;case 3:o=gf(r||[-0,-0,-0],e,this);break;case 4:o=am(r||[-0,-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Qn(o,e.length),o}transformVector(e,r){return this.transform(e,r)}transformVector2(e,r){return this.transform(e,r)}transformVector3(e,r){return this.transform(e,r)}},hm,pm=null;function m9(){return hm||(hm=new ue([0,0,0,0,0,0,0,0,0]),Object.freeze(hm)),hm}function g9(){return pm||(pm=new ue,Object.freeze(pm)),pm}var je={};ze(je,{add:()=>z9,adjoint:()=>T9,clone:()=>y9,copy:()=>x9,create:()=>_9,decompose:()=>L9,determinant:()=>zA,equals:()=>G9,exactEquals:()=>W9,frob:()=>V9,fromQuat:()=>YA,fromQuat2:()=>M9,fromRotation:()=>C9,fromRotationTranslation:()=>vR,fromRotationTranslationScale:()=>B9,fromRotationTranslationScaleOrigin:()=>O9,fromScaling:()=>S9,fromTranslation:()=>v9,fromValues:()=>b9,fromXRotation:()=>E9,fromYRotation:()=>w9,fromZRotation:()=>P9,frustum:()=>KA,getRotation:()=>I9,getScaling:()=>SR,getTranslation:()=>R9,identity:()=>TR,invert:()=>VA,lookAt:()=>JA,mul:()=>$9,multiply:()=>yf,multiplyScalar:()=>H9,multiplyScalarAndAdd:()=>j9,ortho:()=>ZA,orthoNO:()=>ER,orthoZO:()=>D9,perspective:()=>qA,perspectiveFromFieldOfView:()=>N9,perspectiveNO:()=>CR,perspectiveZO:()=>F9,rotate:()=>WA,rotateX:()=>GA,rotateY:()=>$A,rotateZ:()=>XA,scale:()=>jA,set:()=>A9,str:()=>k9,sub:()=>X9,subtract:()=>wR,targetTo:()=>U9,translate:()=>HA,transpose:()=>kA});function _9(){let t=new Ee(16);return Ee!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function y9(t){let e=new Ee(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function x9(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function b9(t,e,r,o,n,i,s,a,c,l,f,u,d,h,p,m){let g=new Ee(16);return g[0]=t,g[1]=e,g[2]=r,g[3]=o,g[4]=n,g[5]=i,g[6]=s,g[7]=a,g[8]=c,g[9]=l,g[10]=f,g[11]=u,g[12]=d,g[13]=h,g[14]=p,g[15]=m,g}function A9(t,e,r,o,n,i,s,a,c,l,f,u,d,h,p,m,g){return t[0]=e,t[1]=r,t[2]=o,t[3]=n,t[4]=i,t[5]=s,t[6]=a,t[7]=c,t[8]=l,t[9]=f,t[10]=u,t[11]=d,t[12]=h,t[13]=p,t[14]=m,t[15]=g,t}function TR(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function kA(t,e){if(t===e){let r=e[1],o=e[2],n=e[3],i=e[6],s=e[7],a=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=o,t[9]=i,t[11]=e[14],t[12]=n,t[13]=s,t[14]=a}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function VA(t,e){let r=e[0],o=e[1],n=e[2],i=e[3],s=e[4],a=e[5],c=e[6],l=e[7],f=e[8],u=e[9],d=e[10],h=e[11],p=e[12],m=e[13],g=e[14],_=e[15],x=r*a-o*s,y=r*c-n*s,b=r*l-i*s,T=o*c-n*a,v=o*l-i*a,w=n*l-i*c,C=f*m-u*p,S=f*g-d*p,A=f*_-h*p,M=u*g-d*m,B=u*_-h*m,O=d*_-h*g,F=x*O-y*B+b*M+T*A-v*S+w*C;return F?(F=1/F,t[0]=(a*O-c*B+l*M)*F,t[1]=(n*B-o*O-i*M)*F,t[2]=(m*w-g*v+_*T)*F,t[3]=(d*v-u*w-h*T)*F,t[4]=(c*A-s*O-l*S)*F,t[5]=(r*O-n*A+i*S)*F,t[6]=(g*b-p*w-_*y)*F,t[7]=(f*w-d*b+h*y)*F,t[8]=(s*B-a*A+l*C)*F,t[9]=(o*A-r*B-i*C)*F,t[10]=(p*v-m*b+_*x)*F,t[11]=(u*b-f*v-h*x)*F,t[12]=(a*S-s*M-c*C)*F,t[13]=(r*M-o*S+n*C)*F,t[14]=(m*y-p*T-g*x)*F,t[15]=(f*T-u*y+d*x)*F,t):null}function T9(t,e){let r=e[0],o=e[1],n=e[2],i=e[3],s=e[4],a=e[5],c=e[6],l=e[7],f=e[8],u=e[9],d=e[10],h=e[11],p=e[12],m=e[13],g=e[14],_=e[15],x=r*a-o*s,y=r*c-n*s,b=r*l-i*s,T=o*c-n*a,v=o*l-i*a,w=n*l-i*c,C=f*m-u*p,S=f*g-d*p,A=f*_-h*p,M=u*g-d*m,B=u*_-h*m,O=d*_-h*g;return t[0]=a*O-c*B+l*M,t[1]=n*B-o*O-i*M,t[2]=m*w-g*v+_*T,t[3]=d*v-u*w-h*T,t[4]=c*A-s*O-l*S,t[5]=r*O-n*A+i*S,t[6]=g*b-p*w-_*y,t[7]=f*w-d*b+h*y,t[8]=s*B-a*A+l*C,t[9]=o*A-r*B-i*C,t[10]=p*v-m*b+_*x,t[11]=u*b-f*v-h*x,t[12]=a*S-s*M-c*C,t[13]=r*M-o*S+n*C,t[14]=m*y-p*T-g*x,t[15]=f*T-u*y+d*x,t}function zA(t){let e=t[0],r=t[1],o=t[2],n=t[3],i=t[4],s=t[5],a=t[6],c=t[7],l=t[8],f=t[9],u=t[10],d=t[11],h=t[12],p=t[13],m=t[14],g=t[15],_=e*s-r*i,x=e*a-o*i,y=r*a-o*s,b=l*p-f*h,T=l*m-u*h,v=f*m-u*p,w=e*v-r*T+o*b,C=i*v-s*T+a*b,S=l*y-f*x+u*_,A=h*y-p*x+m*_;return c*w-n*C+g*S-d*A}function yf(t,e,r){let o=e[0],n=e[1],i=e[2],s=e[3],a=e[4],c=e[5],l=e[6],f=e[7],u=e[8],d=e[9],h=e[10],p=e[11],m=e[12],g=e[13],_=e[14],x=e[15],y=r[0],b=r[1],T=r[2],v=r[3];return t[0]=y*o+b*a+T*u+v*m,t[1]=y*n+b*c+T*d+v*g,t[2]=y*i+b*l+T*h+v*_,t[3]=y*s+b*f+T*p+v*x,y=r[4],b=r[5],T=r[6],v=r[7],t[4]=y*o+b*a+T*u+v*m,t[5]=y*n+b*c+T*d+v*g,t[6]=y*i+b*l+T*h+v*_,t[7]=y*s+b*f+T*p+v*x,y=r[8],b=r[9],T=r[10],v=r[11],t[8]=y*o+b*a+T*u+v*m,t[9]=y*n+b*c+T*d+v*g,t[10]=y*i+b*l+T*h+v*_,t[11]=y*s+b*f+T*p+v*x,y=r[12],b=r[13],T=r[14],v=r[15],t[12]=y*o+b*a+T*u+v*m,t[13]=y*n+b*c+T*d+v*g,t[14]=y*i+b*l+T*h+v*_,t[15]=y*s+b*f+T*p+v*x,t}function HA(t,e,r){let o=r[0],n=r[1],i=r[2],s,a,c,l,f,u,d,h,p,m,g,_;return e===t?(t[12]=e[0]*o+e[4]*n+e[8]*i+e[12],t[13]=e[1]*o+e[5]*n+e[9]*i+e[13],t[14]=e[2]*o+e[6]*n+e[10]*i+e[14],t[15]=e[3]*o+e[7]*n+e[11]*i+e[15]):(s=e[0],a=e[1],c=e[2],l=e[3],f=e[4],u=e[5],d=e[6],h=e[7],p=e[8],m=e[9],g=e[10],_=e[11],t[0]=s,t[1]=a,t[2]=c,t[3]=l,t[4]=f,t[5]=u,t[6]=d,t[7]=h,t[8]=p,t[9]=m,t[10]=g,t[11]=_,t[12]=s*o+f*n+p*i+e[12],t[13]=a*o+u*n+m*i+e[13],t[14]=c*o+d*n+g*i+e[14],t[15]=l*o+h*n+_*i+e[15]),t}function jA(t,e,r){let o=r[0],n=r[1],i=r[2];return t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t[3]=e[3]*o,t[4]=e[4]*n,t[5]=e[5]*n,t[6]=e[6]*n,t[7]=e[7]*n,t[8]=e[8]*i,t[9]=e[9]*i,t[10]=e[10]*i,t[11]=e[11]*i,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function WA(t,e,r,o){let n=o[0],i=o[1],s=o[2],a=Math.sqrt(n*n+i*i+s*s),c,l,f,u,d,h,p,m,g,_,x,y,b,T,v,w,C,S,A,M,B,O,F,X;return a<1e-6?null:(a=1/a,n*=a,i*=a,s*=a,l=Math.sin(r),c=Math.cos(r),f=1-c,u=e[0],d=e[1],h=e[2],p=e[3],m=e[4],g=e[5],_=e[6],x=e[7],y=e[8],b=e[9],T=e[10],v=e[11],w=n*n*f+c,C=i*n*f+s*l,S=s*n*f-i*l,A=n*i*f-s*l,M=i*i*f+c,B=s*i*f+n*l,O=n*s*f+i*l,F=i*s*f-n*l,X=s*s*f+c,t[0]=u*w+m*C+y*S,t[1]=d*w+g*C+b*S,t[2]=h*w+_*C+T*S,t[3]=p*w+x*C+v*S,t[4]=u*A+m*M+y*B,t[5]=d*A+g*M+b*B,t[6]=h*A+_*M+T*B,t[7]=p*A+x*M+v*B,t[8]=u*O+m*F+y*X,t[9]=d*O+g*F+b*X,t[10]=h*O+_*F+T*X,t[11]=p*O+x*F+v*X,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}function GA(t,e,r){let o=Math.sin(r),n=Math.cos(r),i=e[4],s=e[5],a=e[6],c=e[7],l=e[8],f=e[9],u=e[10],d=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=i*n+l*o,t[5]=s*n+f*o,t[6]=a*n+u*o,t[7]=c*n+d*o,t[8]=l*n-i*o,t[9]=f*n-s*o,t[10]=u*n-a*o,t[11]=d*n-c*o,t}function $A(t,e,r){let o=Math.sin(r),n=Math.cos(r),i=e[0],s=e[1],a=e[2],c=e[3],l=e[8],f=e[9],u=e[10],d=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=i*n-l*o,t[1]=s*n-f*o,t[2]=a*n-u*o,t[3]=c*n-d*o,t[8]=i*o+l*n,t[9]=s*o+f*n,t[10]=a*o+u*n,t[11]=c*o+d*n,t}function XA(t,e,r){let o=Math.sin(r),n=Math.cos(r),i=e[0],s=e[1],a=e[2],c=e[3],l=e[4],f=e[5],u=e[6],d=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=i*n+l*o,t[1]=s*n+f*o,t[2]=a*n+u*o,t[3]=c*n+d*o,t[4]=l*n-i*o,t[5]=f*n-s*o,t[6]=u*n-a*o,t[7]=d*n-c*o,t}function v9(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}function S9(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function C9(t,e,r){let o=r[0],n=r[1],i=r[2],s=Math.sqrt(o*o+n*n+i*i),a,c,l;return s<1e-6?null:(s=1/s,o*=s,n*=s,i*=s,c=Math.sin(e),a=Math.cos(e),l=1-a,t[0]=o*o*l+a,t[1]=n*o*l+i*c,t[2]=i*o*l-n*c,t[3]=0,t[4]=o*n*l-i*c,t[5]=n*n*l+a,t[6]=i*n*l+o*c,t[7]=0,t[8]=o*i*l+n*c,t[9]=n*i*l-o*c,t[10]=i*i*l+a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)}function E9(t,e){let r=Math.sin(e),o=Math.cos(e);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o,t[6]=r,t[7]=0,t[8]=0,t[9]=-r,t[10]=o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function w9(t,e){let r=Math.sin(e),o=Math.cos(e);return t[0]=o,t[1]=0,t[2]=-r,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=r,t[9]=0,t[10]=o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function P9(t,e){let r=Math.sin(e),o=Math.cos(e);return t[0]=o,t[1]=r,t[2]=0,t[3]=0,t[4]=-r,t[5]=o,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function vR(t,e,r){let o=e[0],n=e[1],i=e[2],s=e[3],a=o+o,c=n+n,l=i+i,f=o*a,u=o*c,d=o*l,h=n*c,p=n*l,m=i*l,g=s*a,_=s*c,x=s*l;return t[0]=1-(h+m),t[1]=u+x,t[2]=d-_,t[3]=0,t[4]=u-x,t[5]=1-(f+m),t[6]=p+g,t[7]=0,t[8]=d+_,t[9]=p-g,t[10]=1-(f+h),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function M9(t,e){let r=new Ee(3),o=-e[0],n=-e[1],i=-e[2],s=e[3],a=e[4],c=e[5],l=e[6],f=e[7],u=o*o+n*n+i*i+s*s;return u>0?(r[0]=(a*s+f*o+c*i-l*n)*2/u,r[1]=(c*s+f*n+l*o-a*i)*2/u,r[2]=(l*s+f*i+a*n-c*o)*2/u):(r[0]=(a*s+f*o+c*i-l*n)*2,r[1]=(c*s+f*n+l*o-a*i)*2,r[2]=(l*s+f*i+a*n-c*o)*2),vR(t,e,r),t}function R9(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}function SR(t,e){let r=e[0],o=e[1],n=e[2],i=e[4],s=e[5],a=e[6],c=e[8],l=e[9],f=e[10];return t[0]=Math.sqrt(r*r+o*o+n*n),t[1]=Math.sqrt(i*i+s*s+a*a),t[2]=Math.sqrt(c*c+l*l+f*f),t}function I9(t,e){let r=new Ee(3);SR(r,e);let o=1/r[0],n=1/r[1],i=1/r[2],s=e[0]*o,a=e[1]*n,c=e[2]*i,l=e[4]*o,f=e[5]*n,u=e[6]*i,d=e[8]*o,h=e[9]*n,p=e[10]*i,m=s+f+p,g=0;return m>0?(g=Math.sqrt(m+1)*2,t[3]=.25*g,t[0]=(u-h)/g,t[1]=(d-c)/g,t[2]=(a-l)/g):s>f&&s>p?(g=Math.sqrt(1+s-f-p)*2,t[3]=(u-h)/g,t[0]=.25*g,t[1]=(a+l)/g,t[2]=(d+c)/g):f>p?(g=Math.sqrt(1+f-s-p)*2,t[3]=(d-c)/g,t[0]=(a+l)/g,t[1]=.25*g,t[2]=(u+h)/g):(g=Math.sqrt(1+p-s-f)*2,t[3]=(a-l)/g,t[0]=(d+c)/g,t[1]=(u+h)/g,t[2]=.25*g),t}function L9(t,e,r,o){e[0]=o[12],e[1]=o[13],e[2]=o[14];let n=o[0],i=o[1],s=o[2],a=o[4],c=o[5],l=o[6],f=o[8],u=o[9],d=o[10];r[0]=Math.sqrt(n*n+i*i+s*s),r[1]=Math.sqrt(a*a+c*c+l*l),r[2]=Math.sqrt(f*f+u*u+d*d);let h=1/r[0],p=1/r[1],m=1/r[2],g=n*h,_=i*p,x=s*m,y=a*h,b=c*p,T=l*m,v=f*h,w=u*p,C=d*m,S=g+b+C,A=0;return S>0?(A=Math.sqrt(S+1)*2,t[3]=.25*A,t[0]=(T-w)/A,t[1]=(v-x)/A,t[2]=(_-y)/A):g>b&&g>C?(A=Math.sqrt(1+g-b-C)*2,t[3]=(T-w)/A,t[0]=.25*A,t[1]=(_+y)/A,t[2]=(v+x)/A):b>C?(A=Math.sqrt(1+b-g-C)*2,t[3]=(v-x)/A,t[0]=(_+y)/A,t[1]=.25*A,t[2]=(T+w)/A):(A=Math.sqrt(1+C-g-b)*2,t[3]=(_-y)/A,t[0]=(v+x)/A,t[1]=(T+w)/A,t[2]=.25*A),t}function B9(t,e,r,o){let n=e[0],i=e[1],s=e[2],a=e[3],c=n+n,l=i+i,f=s+s,u=n*c,d=n*l,h=n*f,p=i*l,m=i*f,g=s*f,_=a*c,x=a*l,y=a*f,b=o[0],T=o[1],v=o[2];return t[0]=(1-(p+g))*b,t[1]=(d+y)*b,t[2]=(h-x)*b,t[3]=0,t[4]=(d-y)*T,t[5]=(1-(u+g))*T,t[6]=(m+_)*T,t[7]=0,t[8]=(h+x)*v,t[9]=(m-_)*v,t[10]=(1-(u+p))*v,t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function O9(t,e,r,o,n){let i=e[0],s=e[1],a=e[2],c=e[3],l=i+i,f=s+s,u=a+a,d=i*l,h=i*f,p=i*u,m=s*f,g=s*u,_=a*u,x=c*l,y=c*f,b=c*u,T=o[0],v=o[1],w=o[2],C=n[0],S=n[1],A=n[2],M=(1-(m+_))*T,B=(h+b)*T,O=(p-y)*T,F=(h-b)*v,X=(1-(d+_))*v,G=(g+x)*v,j=(p+y)*w,se=(g-x)*w,ne=(1-(d+m))*w;return t[0]=M,t[1]=B,t[2]=O,t[3]=0,t[4]=F,t[5]=X,t[6]=G,t[7]=0,t[8]=j,t[9]=se,t[10]=ne,t[11]=0,t[12]=r[0]+C-(M*C+F*S+j*A),t[13]=r[1]+S-(B*C+X*S+se*A),t[14]=r[2]+A-(O*C+G*S+ne*A),t[15]=1,t}function YA(t,e){let r=e[0],o=e[1],n=e[2],i=e[3],s=r+r,a=o+o,c=n+n,l=r*s,f=o*s,u=o*a,d=n*s,h=n*a,p=n*c,m=i*s,g=i*a,_=i*c;return t[0]=1-u-p,t[1]=f+_,t[2]=d-g,t[3]=0,t[4]=f-_,t[5]=1-l-p,t[6]=h+m,t[7]=0,t[8]=d+g,t[9]=h-m,t[10]=1-l-u,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function KA(t,e,r,o,n,i,s){let a=1/(r-e),c=1/(n-o),l=1/(i-s);return t[0]=i*2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=i*2*c,t[6]=0,t[7]=0,t[8]=(r+e)*a,t[9]=(n+o)*c,t[10]=(s+i)*l,t[11]=-1,t[12]=0,t[13]=0,t[14]=s*i*2*l,t[15]=0,t}function CR(t,e,r,o,n){let i=1/Math.tan(e/2);if(t[0]=i/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=i,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,n!=null&&n!==1/0){let s=1/(o-n);t[10]=(n+o)*s,t[14]=2*n*o*s}else t[10]=-1,t[14]=-2*o;return t}var qA=CR;function F9(t,e,r,o,n){let i=1/Math.tan(e/2);if(t[0]=i/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=i,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,n!=null&&n!==1/0){let s=1/(o-n);t[10]=n*s,t[14]=n*o*s}else t[10]=-1,t[14]=-o;return t}function N9(t,e,r,o){let n=Math.tan(e.upDegrees*Math.PI/180),i=Math.tan(e.downDegrees*Math.PI/180),s=Math.tan(e.leftDegrees*Math.PI/180),a=Math.tan(e.rightDegrees*Math.PI/180),c=2/(s+a),l=2/(n+i);return t[0]=c,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=l,t[6]=0,t[7]=0,t[8]=-((s-a)*c*.5),t[9]=(n-i)*l*.5,t[10]=o/(r-o),t[11]=-1,t[12]=0,t[13]=0,t[14]=o*r/(r-o),t[15]=0,t}function ER(t,e,r,o,n,i,s){let a=1/(e-r),c=1/(o-n),l=1/(i-s);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*l,t[11]=0,t[12]=(e+r)*a,t[13]=(n+o)*c,t[14]=(s+i)*l,t[15]=1,t}var ZA=ER;function D9(t,e,r,o,n,i,s){let a=1/(e-r),c=1/(o-n),l=1/(i-s);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=l,t[11]=0,t[12]=(e+r)*a,t[13]=(n+o)*c,t[14]=i*l,t[15]=1,t}function JA(t,e,r,o){let n,i,s,a,c,l,f,u,d,h,p=e[0],m=e[1],g=e[2],_=o[0],x=o[1],y=o[2],b=r[0],T=r[1],v=r[2];return Math.abs(p-b)<1e-6&&Math.abs(m-T)<1e-6&&Math.abs(g-v)<1e-6?TR(t):(u=p-b,d=m-T,h=g-v,n=1/Math.sqrt(u*u+d*d+h*h),u*=n,d*=n,h*=n,i=x*h-y*d,s=y*u-_*h,a=_*d-x*u,n=Math.sqrt(i*i+s*s+a*a),n?(n=1/n,i*=n,s*=n,a*=n):(i=0,s=0,a=0),c=d*a-h*s,l=h*i-u*a,f=u*s-d*i,n=Math.sqrt(c*c+l*l+f*f),n?(n=1/n,c*=n,l*=n,f*=n):(c=0,l=0,f=0),t[0]=i,t[1]=c,t[2]=u,t[3]=0,t[4]=s,t[5]=l,t[6]=d,t[7]=0,t[8]=a,t[9]=f,t[10]=h,t[11]=0,t[12]=-(i*p+s*m+a*g),t[13]=-(c*p+l*m+f*g),t[14]=-(u*p+d*m+h*g),t[15]=1,t)}function U9(t,e,r,o){let n=e[0],i=e[1],s=e[2],a=o[0],c=o[1],l=o[2],f=n-r[0],u=i-r[1],d=s-r[2],h=f*f+u*u+d*d;h>0&&(h=1/Math.sqrt(h),f*=h,u*=h,d*=h);let p=c*d-l*u,m=l*f-a*d,g=a*u-c*f;return h=p*p+m*m+g*g,h>0&&(h=1/Math.sqrt(h),p*=h,m*=h,g*=h),t[0]=p,t[1]=m,t[2]=g,t[3]=0,t[4]=u*g-d*m,t[5]=d*p-f*g,t[6]=f*m-u*p,t[7]=0,t[8]=f,t[9]=u,t[10]=d,t[11]=0,t[12]=n,t[13]=i,t[14]=s,t[15]=1,t}function k9(t){return`mat4(${t[0]}, ${t[1]}, ${t[2]}, ${t[3]}, ${t[4]}, ${t[5]}, ${t[6]}, ${t[7]}, ${t[8]}, ${t[9]}, ${t[10]}, ${t[11]}, ${t[12]}, ${t[13]}, ${t[14]}, ${t[15]})`}function V9(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]+t[3]*t[3]+t[4]*t[4]+t[5]*t[5]+t[6]*t[6]+t[7]*t[7]+t[8]*t[8]+t[9]*t[9]+t[10]*t[10]+t[11]*t[11]+t[12]*t[12]+t[13]*t[13]+t[14]*t[14]+t[15]*t[15])}function z9(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t[8]=e[8]+r[8],t[9]=e[9]+r[9],t[10]=e[10]+r[10],t[11]=e[11]+r[11],t[12]=e[12]+r[12],t[13]=e[13]+r[13],t[14]=e[14]+r[14],t[15]=e[15]+r[15],t}function wR(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t[6]=e[6]-r[6],t[7]=e[7]-r[7],t[8]=e[8]-r[8],t[9]=e[9]-r[9],t[10]=e[10]-r[10],t[11]=e[11]-r[11],t[12]=e[12]-r[12],t[13]=e[13]-r[13],t[14]=e[14]-r[14],t[15]=e[15]-r[15],t}function H9(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*r,t[9]=e[9]*r,t[10]=e[10]*r,t[11]=e[11]*r,t[12]=e[12]*r,t[13]=e[13]*r,t[14]=e[14]*r,t[15]=e[15]*r,t}function j9(t,e,r,o){return t[0]=e[0]+r[0]*o,t[1]=e[1]+r[1]*o,t[2]=e[2]+r[2]*o,t[3]=e[3]+r[3]*o,t[4]=e[4]+r[4]*o,t[5]=e[5]+r[5]*o,t[6]=e[6]+r[6]*o,t[7]=e[7]+r[7]*o,t[8]=e[8]+r[8]*o,t[9]=e[9]+r[9]*o,t[10]=e[10]+r[10]*o,t[11]=e[11]+r[11]*o,t[12]=e[12]+r[12]*o,t[13]=e[13]+r[13]*o,t[14]=e[14]+r[14]*o,t[15]=e[15]+r[15]*o,t}function W9(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]}function G9(t,e){let r=t[0],o=t[1],n=t[2],i=t[3],s=t[4],a=t[5],c=t[6],l=t[7],f=t[8],u=t[9],d=t[10],h=t[11],p=t[12],m=t[13],g=t[14],_=t[15],x=e[0],y=e[1],b=e[2],T=e[3],v=e[4],w=e[5],C=e[6],S=e[7],A=e[8],M=e[9],B=e[10],O=e[11],F=e[12],X=e[13],G=e[14],j=e[15];return Math.abs(r-x)<=1e-6*Math.max(1,Math.abs(r),Math.abs(x))&&Math.abs(o-y)<=1e-6*Math.max(1,Math.abs(o),Math.abs(y))&&Math.abs(n-b)<=1e-6*Math.max(1,Math.abs(n),Math.abs(b))&&Math.abs(i-T)<=1e-6*Math.max(1,Math.abs(i),Math.abs(T))&&Math.abs(s-v)<=1e-6*Math.max(1,Math.abs(s),Math.abs(v))&&Math.abs(a-w)<=1e-6*Math.max(1,Math.abs(a),Math.abs(w))&&Math.abs(c-C)<=1e-6*Math.max(1,Math.abs(c),Math.abs(C))&&Math.abs(l-S)<=1e-6*Math.max(1,Math.abs(l),Math.abs(S))&&Math.abs(f-A)<=1e-6*Math.max(1,Math.abs(f),Math.abs(A))&&Math.abs(u-M)<=1e-6*Math.max(1,Math.abs(u),Math.abs(M))&&Math.abs(d-B)<=1e-6*Math.max(1,Math.abs(d),Math.abs(B))&&Math.abs(h-O)<=1e-6*Math.max(1,Math.abs(h),Math.abs(O))&&Math.abs(p-F)<=1e-6*Math.max(1,Math.abs(p),Math.abs(F))&&Math.abs(m-X)<=1e-6*Math.max(1,Math.abs(m),Math.abs(X))&&Math.abs(g-G)<=1e-6*Math.max(1,Math.abs(g),Math.abs(G))&&Math.abs(_-j)<=1e-6*Math.max(1,Math.abs(_),Math.abs(j))}var $9=yf,X9=wR;var Nt={};ze(Nt,{add:()=>QA,ceil:()=>Y9,clone:()=>MR,copy:()=>IR,create:()=>PR,cross:()=>r$,dist:()=>f$,distance:()=>NR,div:()=>l$,divide:()=>FR,dot:()=>rT,equals:()=>s$,exactEquals:()=>UR,floor:()=>K9,forEach:()=>p$,fromValues:()=>RR,inverse:()=>t$,len:()=>d$,length:()=>mm,lerp:()=>oT,max:()=>Z9,min:()=>q9,mul:()=>c$,multiply:()=>OR,negate:()=>e$,normalize:()=>tT,random:()=>o$,round:()=>J9,scale:()=>eT,scaleAndAdd:()=>Q9,set:()=>LR,sqrDist:()=>u$,sqrLen:()=>h$,squaredDistance:()=>DR,squaredLength:()=>gm,str:()=>i$,sub:()=>a$,subtract:()=>BR,transformMat4:()=>nT,transformQuat:()=>iT,zero:()=>n$});function PR(){let t=new Ee(4);return Ee!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function MR(t){let e=new Ee(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function RR(t,e,r,o){let n=new Ee(4);return n[0]=t,n[1]=e,n[2]=r,n[3]=o,n}function IR(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function LR(t,e,r,o,n){return t[0]=e,t[1]=r,t[2]=o,t[3]=n,t}function QA(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}function BR(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}function OR(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t}function FR(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t[3]=e[3]/r[3],t}function Y9(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t[3]=Math.ceil(e[3]),t}function K9(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t[3]=Math.floor(e[3]),t}function q9(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t[3]=Math.min(e[3],r[3]),t}function Z9(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t[3]=Math.max(e[3],r[3]),t}function J9(t,e){return t[0]=vr(e[0]),t[1]=vr(e[1]),t[2]=vr(e[2]),t[3]=vr(e[3]),t}function eT(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}function Q9(t,e,r,o){return t[0]=e[0]+r[0]*o,t[1]=e[1]+r[1]*o,t[2]=e[2]+r[2]*o,t[3]=e[3]+r[3]*o,t}function NR(t,e){let r=e[0]-t[0],o=e[1]-t[1],n=e[2]-t[2],i=e[3]-t[3];return Math.sqrt(r*r+o*o+n*n+i*i)}function DR(t,e){let r=e[0]-t[0],o=e[1]-t[1],n=e[2]-t[2],i=e[3]-t[3];return r*r+o*o+n*n+i*i}function mm(t){let e=t[0],r=t[1],o=t[2],n=t[3];return Math.sqrt(e*e+r*r+o*o+n*n)}function gm(t){let e=t[0],r=t[1],o=t[2],n=t[3];return e*e+r*r+o*o+n*n}function e$(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t}function t$(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t[3]=1/e[3],t}function tT(t,e){let r=e[0],o=e[1],n=e[2],i=e[3],s=r*r+o*o+n*n+i*i;return s>0&&(s=1/Math.sqrt(s)),t[0]=r*s,t[1]=o*s,t[2]=n*s,t[3]=i*s,t}function rT(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function r$(t,e,r,o){let n=r[0]*o[1]-r[1]*o[0],i=r[0]*o[2]-r[2]*o[0],s=r[0]*o[3]-r[3]*o[0],a=r[1]*o[2]-r[2]*o[1],c=r[1]*o[3]-r[3]*o[1],l=r[2]*o[3]-r[3]*o[2],f=e[0],u=e[1],d=e[2],h=e[3];return t[0]=u*l-d*c+h*a,t[1]=-(f*l)+d*s-h*i,t[2]=f*c-u*s+h*n,t[3]=-(f*a)+u*i-d*n,t}function oT(t,e,r,o){let n=e[0],i=e[1],s=e[2],a=e[3];return t[0]=n+o*(r[0]-n),t[1]=i+o*(r[1]-i),t[2]=s+o*(r[2]-s),t[3]=a+o*(r[3]-a),t}function o$(t,e){e=e===void 0?1:e;let r,o,n,i,s,a;do r=To()*2-1,o=To()*2-1,s=r*r+o*o;while(s>=1);do n=To()*2-1,i=To()*2-1,a=n*n+i*i;while(a>=1);let c=Math.sqrt((1-s)/a);return t[0]=e*r,t[1]=e*o,t[2]=e*n*c,t[3]=e*i*c,t}function nT(t,e,r){let o=e[0],n=e[1],i=e[2],s=e[3];return t[0]=r[0]*o+r[4]*n+r[8]*i+r[12]*s,t[1]=r[1]*o+r[5]*n+r[9]*i+r[13]*s,t[2]=r[2]*o+r[6]*n+r[10]*i+r[14]*s,t[3]=r[3]*o+r[7]*n+r[11]*i+r[15]*s,t}function iT(t,e,r){let o=e[0],n=e[1],i=e[2],s=r[0],a=r[1],c=r[2],l=r[3],f=l*o+a*i-c*n,u=l*n+c*o-s*i,d=l*i+s*n-a*o,h=-s*o-a*n-c*i;return t[0]=f*l+h*-s+u*-c-d*-a,t[1]=u*l+h*-a+d*-s-f*-c,t[2]=d*l+h*-c+f*-a-u*-s,t[3]=e[3],t}function n$(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t}function i$(t){return`vec4(${t[0]}, ${t[1]}, ${t[2]}, ${t[3]})`}function UR(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]}function s$(t,e){let r=t[0],o=t[1],n=t[2],i=t[3],s=e[0],a=e[1],c=e[2],l=e[3];return Math.abs(r-s)<=1e-6*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(o-a)<=1e-6*Math.max(1,Math.abs(o),Math.abs(a))&&Math.abs(n-c)<=1e-6*Math.max(1,Math.abs(n),Math.abs(c))&&Math.abs(i-l)<=1e-6*Math.max(1,Math.abs(i),Math.abs(l))}var a$=BR,c$=OR,l$=FR,f$=NR,u$=DR,d$=mm,h$=gm,p$=function(){let t=PR();return function(e,r,o,n,i,s){let a,c;for(r||(r=4),o||(o=0),n?c=Math.min(n*r+o,e.length):c=e.length,a=o;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],t[3]=e[a+3],i(t,t,s),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2],e[a+3]=t[3];return e}}();var cT;(function(t){t[t.COL0ROW0=0]="COL0ROW0",t[t.COL0ROW1=1]="COL0ROW1",t[t.COL0ROW2=2]="COL0ROW2",t[t.COL0ROW3=3]="COL0ROW3",t[t.COL1ROW0=4]="COL1ROW0",t[t.COL1ROW1=5]="COL1ROW1",t[t.COL1ROW2=6]="COL1ROW2",t[t.COL1ROW3=7]="COL1ROW3",t[t.COL2ROW0=8]="COL2ROW0",t[t.COL2ROW1=9]="COL2ROW1",t[t.COL2ROW2=10]="COL2ROW2",t[t.COL2ROW3=11]="COL2ROW3",t[t.COL3ROW0=12]="COL3ROW0",t[t.COL3ROW1=13]="COL3ROW1",t[t.COL3ROW2=14]="COL3ROW2",t[t.COL3ROW3=15]="COL3ROW3"})(cT||(cT={}));var m$=45*Math.PI/180,g$=1,sT=.1,aT=500,_$=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),V=class extends Ba{static get IDENTITY(){return x$()}static get ZERO(){return y$()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return cT}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,r,o,n,i,s,a,c,l,f,u,d,h,p,m,g){return this[0]=e,this[1]=r,this[2]=o,this[3]=n,this[4]=i,this[5]=s,this[6]=a,this[7]=c,this[8]=l,this[9]=f,this[10]=u,this[11]=d,this[12]=h,this[13]=p,this[14]=m,this[15]=g,this.check()}setRowMajor(e,r,o,n,i,s,a,c,l,f,u,d,h,p,m,g){return this[0]=e,this[1]=i,this[2]=l,this[3]=h,this[4]=r,this[5]=s,this[6]=f,this[7]=p,this[8]=o,this[9]=a,this[10]=u,this[11]=m,this[12]=n,this[13]=c,this[14]=d,this[15]=g,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(_$)}fromObject(e){return this.check()}fromQuaternion(e){return YA(this,e),this.check()}frustum(e){let{left:r,right:o,bottom:n,top:i,near:s=sT,far:a=aT}=e;return a===1/0?b$(this,r,o,n,i,s):KA(this,r,o,n,i,s,a),this.check()}lookAt(e){let{eye:r,center:o=[0,0,0],up:n=[0,1,0]}=e;return JA(this,r,o,n),this.check()}ortho(e){let{left:r,right:o,bottom:n,top:i,near:s=sT,far:a=aT}=e;return ZA(this,r,o,n,i,s,a),this.check()}orthographic(e){let{fovy:r=m$,aspect:o=g$,focalDistance:n=1,near:i=sT,far:s=aT}=e;kR(r);let a=r/2,c=n*Math.tan(a),l=c*o;return this.ortho({left:-l,right:l,bottom:-c,top:c,near:i,far:s})}perspective(e){let{fovy:r=45*Math.PI/180,aspect:o=1,near:n=.1,far:i=500}=e;return kR(r),qA(this,r,o,n,i),this.check()}determinant(){return zA(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,r){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let o=this.getScale(r),n=1/o[0],i=1/o[1],s=1/o[2];return e[0]=this[0]*n,e[1]=this[1]*i,e[2]=this[2]*s,e[3]=0,e[4]=this[4]*n,e[5]=this[5]*i,e[6]=this[6]*s,e[7]=0,e[8]=this[8]*n,e[9]=this[9]*i,e[10]=this[10]*s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,r){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let o=this.getScale(r),n=1/o[0],i=1/o[1],s=1/o[2];return e[0]=this[0]*n,e[1]=this[1]*i,e[2]=this[2]*s,e[3]=this[4]*n,e[4]=this[5]*i,e[5]=this[6]*s,e[6]=this[8]*n,e[7]=this[9]*i,e[8]=this[10]*s,e}transpose(){return kA(this,this),this.check()}invert(){return VA(this,this),this.check()}multiplyLeft(e){return yf(this,e,this),this.check()}multiplyRight(e){return yf(this,this,e),this.check()}rotateX(e){return GA(this,this,e),this.check()}rotateY(e){return $A(this,this,e),this.check()}rotateZ(e){return XA(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,r){return WA(this,this,e,r),this.check()}scale(e){return jA(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return HA(this,this,e),this.check()}transform(e,r){return e.length===4?(r=nT(r||[-0,-0,-0,-0],e,this),Qn(r,4),r):this.transformAsPoint(e,r)}transformAsPoint(e,r){let{length:o}=e,n;switch(o){case 2:n=pf(r||[-0,-0],e,this);break;case 3:n=rs(r||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Qn(n,e.length),n}transformAsVector(e,r){let o;switch(e.length){case 2:o=im(r||[-0,-0],e,this);break;case 3:o=sm(r||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Qn(o,e.length),o}transformPoint(e,r){return this.transformAsPoint(e,r)}transformVector(e,r){return this.transformAsPoint(e,r)}transformDirection(e,r){return this.transformAsVector(e,r)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,r,o){return this.identity().translate([e,r,o])}},_m,ym;function y$(){return _m||(_m=new V([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(_m)),_m}function x$(){return ym||(ym=new V,Object.freeze(ym)),ym}function kR(t){if(t>Math.PI*2)throw Error("expected radians")}function b$(t,e,r,o,n,i){let s=2*i/(r-e),a=2*i/(n-o),c=(r+e)/(r-e),l=(n+o)/(n-o),f=-1,u=-1,d=-2*i;return t[0]=s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=c,t[9]=l,t[10]=f,t[11]=u,t[12]=0,t[13]=0,t[14]=d,t[15]=0,t}function VR(){let t=new Ee(4);return Ee!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function zR(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function lT(t,e,r){r=r*.5;let o=Math.sin(r);return t[0]=o*e[0],t[1]=o*e[1],t[2]=o*e[2],t[3]=Math.cos(r),t}function fT(t,e,r){let o=e[0],n=e[1],i=e[2],s=e[3],a=r[0],c=r[1],l=r[2],f=r[3];return t[0]=o*f+s*a+n*l-i*c,t[1]=n*f+s*c+i*a-o*l,t[2]=i*f+s*l+o*c-n*a,t[3]=s*f-o*a-n*c-i*l,t}function HR(t,e,r){r*=.5;let o=e[0],n=e[1],i=e[2],s=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=o*c+s*a,t[1]=n*c+i*a,t[2]=i*c-n*a,t[3]=s*c-o*a,t}function jR(t,e,r){r*=.5;let o=e[0],n=e[1],i=e[2],s=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=o*c-i*a,t[1]=n*c+s*a,t[2]=i*c+o*a,t[3]=s*c-n*a,t}function WR(t,e,r){r*=.5;let o=e[0],n=e[1],i=e[2],s=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=o*c+n*a,t[1]=n*c-o*a,t[2]=i*c+s*a,t[3]=s*c-i*a,t}function GR(t,e){let r=e[0],o=e[1],n=e[2];return t[0]=r,t[1]=o,t[2]=n,t[3]=Math.sqrt(Math.abs(1-r*r-o*o-n*n)),t}function xf(t,e,r,o){let n=e[0],i=e[1],s=e[2],a=e[3],c=r[0],l=r[1],f=r[2],u=r[3],d,h,p,m,g;return d=n*c+i*l+s*f+a*u,d<0&&(d=-d,c=-c,l=-l,f=-f,u=-u),1-d>1e-6?(h=Math.acos(d),g=Math.sin(h),p=Math.sin((1-o)*h)/g,m=Math.sin(o*h)/g):(p=1-o,m=o),t[0]=p*n+m*c,t[1]=p*i+m*l,t[2]=p*s+m*f,t[3]=p*a+m*u,t}function $R(t,e){let r=e[0],o=e[1],n=e[2],i=e[3],s=r*r+o*o+n*n+i*i,a=s?1/s:0;return t[0]=-r*a,t[1]=-o*a,t[2]=-n*a,t[3]=i*a,t}function XR(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t}function uT(t,e){let r=e[0]+e[4]+e[8],o;if(r>0)o=Math.sqrt(r+1),t[3]=.5*o,o=.5/o,t[0]=(e[5]-e[7])*o,t[1]=(e[6]-e[2])*o,t[2]=(e[1]-e[3])*o;else{let n=0;e[4]>e[0]&&(n=1),e[8]>e[n*3+n]&&(n=2);let i=(n+1)%3,s=(n+2)%3;o=Math.sqrt(e[n*3+n]-e[i*3+i]-e[s*3+s]+1),t[n]=.5*o,o=.5/o,t[3]=(e[i*3+s]-e[s*3+i])*o,t[i]=(e[i*3+n]+e[n*3+i])*o,t[s]=(e[s*3+n]+e[n*3+s])*o}return t}var YR=QA;var KR=eT,qR=rT,ZR=oT,JR=mm;var QR=gm;var e2=tT;var t2=function(){let t=cm(),e=fm(1,0,0),r=fm(0,1,0);return function(o,n,i){let s=mf(n,i);return s<-.999999?(ts(t,e,n),OA(t)<1e-6&&ts(t,r,n),MA(t,t),lT(o,t,Math.PI),o):s>.999999?(o[0]=0,o[1]=0,o[2]=0,o[3]=1,o):(ts(t,n,i),o[0]=t[0],o[1]=t[1],o[2]=t[2],o[3]=1+s,e2(o,o))}}(),qve=function(){let t=VR(),e=VR();return function(r,o,n,i,s,a){return xf(t,o,s,a),xf(e,n,i,a),xf(r,t,e,2*a*(1-a)),r}}(),Zve=function(){let t=mR();return function(e,r,o,n){return t[0]=o[0],t[3]=o[1],t[6]=o[2],t[1]=n[0],t[4]=n[1],t[7]=n[2],t[2]=-r[0],t[5]=-r[1],t[8]=-r[2],e2(e,uT(e,t))}}();var A$=[0,0,0,1],Sr=class extends Jn{constructor(e=0,r=0,o=0,n=1){super(-0,-0,-0,-0),Array.isArray(e)&&arguments.length===1?this.copy(e):this.set(e,r,o,n)}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}set(e,r,o,n){return this[0]=e,this[1]=r,this[2]=o,this[3]=n,this.check()}fromObject(e){return this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this.check()}fromMatrix3(e){return uT(this,e),this.check()}fromAxisRotation(e,r){return lT(this,e,r),this.check()}identity(){return zR(this),this.check()}setAxisAngle(e,r){return this.fromAxisRotation(e,r)}get ELEMENTS(){return 4}get x(){return this[0]}set x(e){this[0]=he(e)}get y(){return this[1]}set y(e){this[1]=he(e)}get z(){return this[2]}set z(e){this[2]=he(e)}get w(){return this[3]}set w(e){this[3]=he(e)}len(){return JR(this)}lengthSquared(){return QR(this)}dot(e){return qR(this,e)}rotationTo(e,r){return t2(this,e,r),this.check()}add(e){return YR(this,this,e),this.check()}calculateW(){return GR(this,this),this.check()}conjugate(){return XR(this,this),this.check()}invert(){return $R(this,this),this.check()}lerp(e,r,o){return o===void 0?this.lerp(this,e,r):(ZR(this,e,r,o),this.check())}multiplyRight(e){return fT(this,this,e),this.check()}multiplyLeft(e){return fT(this,e,this),this.check()}normalize(){let e=this.len(),r=e>0?1/e:0;return this[0]=this[0]*r,this[1]=this[1]*r,this[2]=this[2]*r,this[3]=this[3]*r,e===0&&(this[3]=1),this.check()}rotateX(e){return HR(this,this,e),this.check()}rotateY(e){return jR(this,this,e),this.check()}rotateZ(e){return WR(this,this,e),this.check()}scale(e){return KR(this,this,e),this.check()}slerp(e,r,o){let n,i,s;switch(arguments.length){case 1:({start:n=A$,target:i,ratio:s}=e);break;case 2:n=this,i=e,s=r;break;default:n=e,i=r,s=o}return xf(this,n,i,s),this.check()}transformVector4(e,r=new La){return iT(r,e,this),Qn(r,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(e,r){return this.setAxisAngle(e,r)}premultiply(e){return this.multiplyLeft(e)}multiply(e){return this.multiplyRight(e)}};var r2=1e-6,T$=6371e3,$r=class{constructor({phi:e=0,theta:r=0,radius:o=1,bearing:n,pitch:i,altitude:s,radiusScale:a=T$}={}){this.phi=e,this.theta=r,this.radius=o||s||1,this.radiusScale=a||1,n!==void 0&&(this.bearing=n),i!==void 0&&(this.pitch=i),this.check()}toString(){return this.formatString(ve)}formatString({printTypes:e=!1}){let r=df;return`${e?"Spherical":""}[rho:${r(this.radius)},theta:${r(this.theta)},phi:${r(this.phi)}]`}equals(e){return Ce(this.radius,e.radius)&&Ce(this.theta,e.theta)&&Ce(this.phi,e.phi)}exactEquals(e){return this.radius===e.radius&&this.theta===e.theta&&this.phi===e.phi}get bearing(){return 180-rt(this.phi)}set bearing(e){this.phi=Math.PI-es(e)}get pitch(){return rt(this.theta)}set pitch(e){this.theta=es(e)}get longitude(){return rt(this.phi)}get latitude(){return rt(this.theta)}get lng(){return rt(this.phi)}get lat(){return rt(this.theta)}get z(){return(this.radius-1)*this.radiusScale}set(e,r,o){return this.radius=e,this.phi=r,this.theta=o,this.check()}clone(){return new $r().copy(this)}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this.check()}fromLngLatZ([e,r,o]){return this.radius=1+o/this.radiusScale,this.phi=es(r),this.theta=es(e),this.check()}fromVector3(e){return this.radius=lm(e),this.radius>0&&(this.theta=Math.atan2(e[0],e[1]),this.phi=Math.acos(ee(e[2]/this.radius,-1,1))),this.check()}toVector3(){return new E(0,0,this.radius).rotateX({radians:this.theta}).rotateZ({radians:this.phi})}makeSafe(){return this.phi=Math.max(r2,Math.min(Math.PI-r2,this.phi)),this}check(){if(!Number.isFinite(this.phi)||!Number.isFinite(this.theta)||!(this.radius>0))throw new Error("SphericalCoordinates: some fields set to invalid numbers");return this}};var Cr={};ze(Cr,{EPSILON1:()=>v$,EPSILON10:()=>L$,EPSILON11:()=>B$,EPSILON12:()=>O$,EPSILON13:()=>F$,EPSILON14:()=>N$,EPSILON15:()=>D$,EPSILON16:()=>U$,EPSILON17:()=>k$,EPSILON18:()=>V$,EPSILON19:()=>z$,EPSILON2:()=>S$,EPSILON20:()=>H$,EPSILON3:()=>C$,EPSILON4:()=>E$,EPSILON5:()=>w$,EPSILON6:()=>P$,EPSILON7:()=>M$,EPSILON8:()=>R$,EPSILON9:()=>I$,PI_OVER_FOUR:()=>W$,PI_OVER_SIX:()=>G$,PI_OVER_TWO:()=>j$,TWO_PI:()=>$$});var v$=.1,S$=.01,C$=.001,E$=1e-4,w$=1e-5,P$=1e-6,M$=1e-7,R$=1e-8,I$=1e-9,L$=1e-10,B$=1e-11,O$=1e-12,F$=1e-13,N$=1e-14,D$=1e-15,U$=1e-16,k$=1e-17,V$=1e-18,z$=1e-19,H$=1e-20,j$=Math.PI/2,W$=Math.PI/4,G$=Math.PI/6,$$=Math.PI*2;function xm(t,e=[],r=0){let o=Math.fround(t),n=t-o;return e[r]=o,e[r+1]=n,e}function dT(t){return t-Math.fround(t)}function hT(t){let e=new Float32Array(32);for(let r=0;r<4;++r)for(let o=0;o<4;++o){let n=r*4+o;xm(t[o*4+r],e,n*2)}return e}function bf(t,e=!0){return t??e}function Oa(t=[0,0,0],e=!0){return e?t.map(r=>r/255):[...t]}function pT(t,e=!0){let r=Oa(t.slice(0,3),e),o=Number.isFinite(t[3]),n=o?t[3]:1;return[r[0],r[1],r[2],e&&o?n/255:n]}var X$=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND // All these functions are for substituting tan() function from Intel GPU only const float TWO_PI = 6.2831854820251465; const float PI_2 = 1.5707963705062866; const float PI_16 = 0.1963495463132858; const float SIN_TABLE_0 = 0.19509032368659973; const float SIN_TABLE_1 = 0.3826834261417389; const float SIN_TABLE_2 = 0.5555702447891235; const float SIN_TABLE_3 = 0.7071067690849304; const float COS_TABLE_0 = 0.9807852506637573; const float COS_TABLE_1 = 0.9238795042037964; const float COS_TABLE_2 = 0.8314695954322815; const float COS_TABLE_3 = 0.7071067690849304; const float INVERSE_FACTORIAL_3 = 1.666666716337204e-01; // 1/3! const float INVERSE_FACTORIAL_5 = 8.333333767950535e-03; // 1/5! const float INVERSE_FACTORIAL_7 = 1.9841270113829523e-04; // 1/7! const float INVERSE_FACTORIAL_9 = 2.75573188446287533e-06; // 1/9! float sin_taylor_fp32(float a) { float r, s, t, x; if (a == 0.0) { return 0.0; } x = -a * a; s = a; r = a; r = r * x; t = r * INVERSE_FACTORIAL_3; s = s + t; r = r * x; t = r * INVERSE_FACTORIAL_5; s = s + t; r = r * x; t = r * INVERSE_FACTORIAL_7; s = s + t; r = r * x; t = r * INVERSE_FACTORIAL_9; s = s + t; return s; } void sincos_taylor_fp32(float a, out float sin_t, out float cos_t) { if (a == 0.0) { sin_t = 0.0; cos_t = 1.0; } sin_t = sin_taylor_fp32(a); cos_t = sqrt(1.0 - sin_t * sin_t); } float tan_taylor_fp32(float a) { float sin_a; float cos_a; if (a == 0.0) { return 0.0; } // 2pi range reduction float z = floor(a / TWO_PI); float r = a - TWO_PI * z; float t; float q = floor(r / PI_2 + 0.5); int j = int(q); if (j < -2 || j > 2) { return 1.0 / 0.0; } t = r - PI_2 * q; q = floor(t / PI_16 + 0.5); int k = int(q); int abs_k = int(abs(float(k))); if (abs_k > 4) { return 1.0 / 0.0; } else { t = t - PI_16 * q; } float u = 0.0; float v = 0.0; float sin_t, cos_t; float s, c; sincos_taylor_fp32(t, sin_t, cos_t); if (k == 0) { s = sin_t; c = cos_t; } else { if (abs(float(abs_k) - 1.0) < 0.5) { u = COS_TABLE_0; v = SIN_TABLE_0; } else if (abs(float(abs_k) - 2.0) < 0.5) { u = COS_TABLE_1; v = SIN_TABLE_1; } else if (abs(float(abs_k) - 3.0) < 0.5) { u = COS_TABLE_2; v = SIN_TABLE_2; } else if (abs(float(abs_k) - 4.0) < 0.5) { u = COS_TABLE_3; v = SIN_TABLE_3; } if (k > 0) { s = u * sin_t + v * cos_t; c = u * cos_t - v * sin_t; } else { s = u * sin_t - v * cos_t; c = u * cos_t + v * sin_t; } } if (j == 0) { sin_a = s; cos_a = c; } else if (j == 1) { sin_a = c; cos_a = -s; } else if (j == -1) { sin_a = -c; cos_a = s; } else { sin_a = -s; cos_a = -c; } return sin_a / cos_a; } #endif float tan_fp32(float a) { #ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND return tan_taylor_fp32(a); #else return tan(a); #endif } `,mT={name:"fp32",vs:X$};var gT=` layout(std140) uniform fp64arithmeticUniforms { uniform float ONE; uniform float SPLIT; } fp64; /* About LUMA_FP64_CODE_ELIMINATION_WORKAROUND The purpose of this workaround is to prevent shader compilers from optimizing away necessary arithmetic operations by swapping their sequences or transform the equation to some 'equivalent' form. These helpers implement Dekker/Veltkamp-style error tracking. If the compiler folds constants or reassociates the arithmetic, the high/low split can stop tracking the rounding error correctly. That failure mode tends to look fine in simple coordinate setup, but then breaks down inside iterative arithmetic such as fp64 Mandelbrot loops. The method is to multiply an artifical variable, ONE, which will be known to the compiler to be 1 only at runtime. The whole expression is then represented as a polynomial with respective to ONE. In the coefficients of all terms, only one a and one b should appear err = (a + b) * ONE^6 - a * ONE^5 - (a + b) * ONE^4 + a * ONE^3 - b - (a + b) * ONE^2 + a * ONE */ float prevent_fp64_optimization(float value) { #if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) return value + fp64.ONE * 0.0; #else return value; #endif } // Divide float number to high and low floats to extend fraction bits vec2 split(float a) { // Keep SPLIT as a runtime uniform so the compiler cannot fold the Dekker // split into a constant expression and reassociate the recovery steps. float split = prevent_fp64_optimization(fp64.SPLIT); float t = prevent_fp64_optimization(a * split); float temp = t - a; float a_hi = t - temp; float a_lo = a - a_hi; return vec2(a_hi, a_lo); } // Divide float number again when high float uses too many fraction bits vec2 split2(vec2 a) { vec2 b = split(a.x); b.y += a.y; return b; } // Special sum operation when a > b vec2 quickTwoSum(float a, float b) { #if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) float sum = (a + b) * fp64.ONE; float err = b - (sum - a) * fp64.ONE; #else float sum = a + b; float err = b - (sum - a); #endif return vec2(sum, err); } // General sum operation vec2 twoSum(float a, float b) { float s = (a + b); #if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) float v = (s * fp64.ONE - a) * fp64.ONE; float err = (a - (s - v) * fp64.ONE) * fp64.ONE * fp64.ONE * fp64.ONE + (b - v); #else float v = s - a; float err = (a - (s - v)) + (b - v); #endif return vec2(s, err); } vec2 twoSub(float a, float b) { float s = (a - b); #if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) float v = (s * fp64.ONE - a) * fp64.ONE; float err = (a - (s - v) * fp64.ONE) * fp64.ONE * fp64.ONE * fp64.ONE - (b + v); #else float v = s - a; float err = (a - (s - v)) - (b + v); #endif return vec2(s, err); } vec2 twoSqr(float a) { float prod = a * a; vec2 a_fp64 = split(a); #if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) float err = ((a_fp64.x * a_fp64.x - prod) * fp64.ONE + 2.0 * a_fp64.x * a_fp64.y * fp64.ONE * fp64.ONE) + a_fp64.y * a_fp64.y * fp64.ONE * fp64.ONE * fp64.ONE; #else float err = ((a_fp64.x * a_fp64.x - prod) + 2.0 * a_fp64.x * a_fp64.y) + a_fp64.y * a_fp64.y; #endif return vec2(prod, err); } vec2 twoProd(float a, float b) { float prod = a * b; vec2 a_fp64 = split(a); vec2 b_fp64 = split(b); // twoProd is especially sensitive because mul_fp64 and div_fp64 both depend // on the split terms and cross terms staying in the original evaluation // order. If the compiler folds or reassociates them, the low part tends to // collapse to zero or NaN on some drivers. float highProduct = prevent_fp64_optimization(a_fp64.x * b_fp64.x); float crossProduct1 = prevent_fp64_optimization(a_fp64.x * b_fp64.y); float crossProduct2 = prevent_fp64_optimization(a_fp64.y * b_fp64.x); float lowProduct = prevent_fp64_optimization(a_fp64.y * b_fp64.y); #if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) float err1 = (highProduct - prod) * fp64.ONE; float err2 = crossProduct1 * fp64.ONE * fp64.ONE; float err3 = crossProduct2 * fp64.ONE * fp64.ONE * fp64.ONE; float err4 = lowProduct * fp64.ONE * fp64.ONE * fp64.ONE * fp64.ONE; #else float err1 = highProduct - prod; float err2 = crossProduct1; float err3 = crossProduct2; float err4 = lowProduct; #endif float err = ((err1 + err2) + err3) + err4; return vec2(prod, err); } vec2 sum_fp64(vec2 a, vec2 b) { vec2 s, t; s = twoSum(a.x, b.x); t = twoSum(a.y, b.y); s.y += t.x; s = quickTwoSum(s.x, s.y); s.y += t.y; s = quickTwoSum(s.x, s.y); return s; } vec2 sub_fp64(vec2 a, vec2 b) { vec2 s, t; s = twoSub(a.x, b.x); t = twoSub(a.y, b.y); s.y += t.x; s = quickTwoSum(s.x, s.y); s.y += t.y; s = quickTwoSum(s.x, s.y); return s; } vec2 mul_fp64(vec2 a, vec2 b) { vec2 prod = twoProd(a.x, b.x); // y component is for the error prod.y += a.x * b.y; #if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND) prod = split2(prod); #endif prod = quickTwoSum(prod.x, prod.y); prod.y += a.y * b.x; #if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND) prod = split2(prod); #endif prod = quickTwoSum(prod.x, prod.y); return prod; } vec2 div_fp64(vec2 a, vec2 b) { float xn = 1.0 / b.x; #if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND) vec2 yn = mul_fp64(a, vec2(xn, 0)); #else vec2 yn = a * xn; #endif float diff = (sub_fp64(a, mul_fp64(b, yn))).x; vec2 prod = twoProd(xn, diff); return sum_fp64(yn, prod); } vec2 sqrt_fp64(vec2 a) { if (a.x == 0.0 && a.y == 0.0) return vec2(0.0, 0.0); if (a.x < 0.0) return vec2(0.0 / 0.0, 0.0 / 0.0); float x = 1.0 / sqrt(a.x); float yn = a.x * x; #if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) vec2 yn_sqr = twoSqr(yn) * fp64.ONE; #else vec2 yn_sqr = twoSqr(yn); #endif float diff = sub_fp64(a, yn_sqr).x; vec2 prod = twoProd(x * 0.5, diff); #if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND) return sum_fp64(split(yn), prod); #else return sum_fp64(vec2(yn, 0.0), prod); #endif } `;var o2=`struct Fp64ArithmeticUniforms { ONE: f32, SPLIT: f32, }; @group(0) @binding(auto) var<uniform> fp64arithmetic : Fp64ArithmeticUniforms; fn fp64_nan(seed: f32) -> f32 { let nanBits = 0x7fc00000u | select(0u, 1u, seed < 0.0); return bitcast<f32>(nanBits); } fn fp64_runtime_zero() -> f32 { return fp64arithmetic.ONE * 0.0; } fn prevent_fp64_optimization(value: f32) -> f32 { #ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND return value + fp64_runtime_zero(); #else return value; #endif } fn split(a: f32) -> vec2f { let splitValue = prevent_fp64_optimization(fp64arithmetic.SPLIT + fp64_runtime_zero()); let t = prevent_fp64_optimization(a * splitValue); let temp = prevent_fp64_optimization(t - a); let aHi = prevent_fp64_optimization(t - temp); let aLo = prevent_fp64_optimization(a - aHi); return vec2f(aHi, aLo); } fn split2(a: vec2f) -> vec2f { var b = split(a.x); b.y = b.y + a.y; return b; } fn quickTwoSum(a: f32, b: f32) -> vec2f { #ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND let sum = prevent_fp64_optimization((a + b) * fp64arithmetic.ONE); let err = prevent_fp64_optimization(b - (sum - a) * fp64arithmetic.ONE); #else let sum = prevent_fp64_optimization(a + b); let err = prevent_fp64_optimization(b - (sum - a)); #endif return vec2f(sum, err); } fn twoSum(a: f32, b: f32) -> vec2f { let s = prevent_fp64_optimization(a + b); #ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND let v = prevent_fp64_optimization((s * fp64arithmetic.ONE - a) * fp64arithmetic.ONE); let err = prevent_fp64_optimization((a - (s - v) * fp64arithmetic.ONE) * fp64arithmetic.ONE * fp64arithmetic.ONE * fp64arithmetic.ONE) + prevent_fp64_optimization(b - v); #else let v = prevent_fp64_optimization(s - a); let err = prevent_fp64_optimization(a - (s - v)) + prevent_fp64_optimization(b - v); #endif return vec2f(s, err); } fn twoSub(a: f32, b: f32) -> vec2f { let s = prevent_fp64_optimization(a - b); #ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND let v = prevent_fp64_optimization((s * fp64arithmetic.ONE - a) * fp64arithmetic.ONE); let err = prevent_fp64_optimization((a - (s - v) * fp64arithmetic.ONE) * fp64arithmetic.ONE * fp64arithmetic.ONE * fp64arithmetic.ONE) - prevent_fp64_optimization(b + v); #else let v = prevent_fp64_optimization(s - a); let err = prevent_fp64_optimization(a - (s - v)) - prevent_fp64_optimization(b + v); #endif return vec2f(s, err); } fn twoSqr(a: f32) -> vec2f { let prod = prevent_fp64_optimization(a * a); let aFp64 = split(a); let highProduct = prevent_fp64_optimization(aFp64.x * aFp64.x); let crossProduct = prevent_fp64_optimization(2.0 * aFp64.x * aFp64.y); let lowProduct = prevent_fp64_optimization(aFp64.y * aFp64.y); #ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND let err = (prevent_fp64_optimization(highProduct - prod) * fp64arithmetic.ONE + crossProduct * fp64arithmetic.ONE * fp64arithmetic.ONE) + lowProduct * fp64arithmetic.ONE * fp64arithmetic.ONE * fp64arithmetic.ONE; #else let err = ((prevent_fp64_optimization(highProduct - prod) + crossProduct) + lowProduct); #endif return vec2f(prod, err); } fn twoProd(a: f32, b: f32) -> vec2f { let prod = prevent_fp64_optimization(a * b); let aFp64 = split(a); let bFp64 = split(b); let highProduct = prevent_fp64_optimization(aFp64.x * bFp64.x); let crossProduct1 = prevent_fp64_optimization(aFp64.x * bFp64.y); let crossProduct2 = prevent_fp64_optimization(aFp64.y * bFp64.x); let lowProduct = prevent_fp64_optimization(aFp64.y * bFp64.y); #ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND let err1 = (highProduct - prod) * fp64arithmetic.ONE; let err2 = crossProduct1 * fp64arithmetic.ONE * fp64arithmetic.ONE; let err3 = crossProduct2 * fp64arithmetic.ONE * fp64arithmetic.ONE * fp64arithmetic.ONE; let err4 = lowProduct * fp64arithmetic.ONE * fp64arithmetic.ONE * fp64arithmetic.ONE * fp64arithmetic.ONE; #else let err1 = highProduct - prod; let err2 = crossProduct1; let err3 = crossProduct2; let err4 = lowProduct; #endif let err12InputA = prevent_fp64_optimization(err1); let err12InputB = prevent_fp64_optimization(err2); let err12 = prevent_fp64_optimization(err12InputA + err12InputB); let err123InputA = prevent_fp64_optimization(err12); let err123InputB = prevent_fp64_optimization(err3); let err123 = prevent_fp64_optimization(err123InputA + err123InputB); let err1234InputA = prevent_fp64_optimization(err123); let err1234InputB = prevent_fp64_optimization(err4); let err = prevent_fp64_optimization(err1234InputA + err1234InputB); return vec2f(prod, err); } fn sum_fp64(a: vec2f, b: vec2f) -> vec2f { var s = twoSum(a.x, b.x); let t = twoSum(a.y, b.y); s.y = prevent_fp64_optimization(s.y + t.x); s = quickTwoSum(s.x, s.y); s.y = prevent_fp64_optimization(s.y + t.y); s = quickTwoSum(s.x, s.y); return s; } fn sub_fp64(a: vec2f, b: vec2f) -> vec2f { var s = twoSub(a.x, b.x); let t = twoSub(a.y, b.y); s.y = prevent_fp64_optimization(s.y + t.x); s = quickTwoSum(s.x, s.y); s.y = prevent_fp64_optimization(s.y + t.y); s = quickTwoSum(s.x, s.y); return s; } fn mul_fp64(a: vec2f, b: vec2f) -> vec2f { var prod = twoProd(a.x, b.x); let crossProduct1 = prevent_fp64_optimization(a.x * b.y); prod.y = prevent_fp64_optimization(prod.y + crossProduct1); #ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND prod = split2(prod); #endif prod = quickTwoSum(prod.x, prod.y); let crossProduct2 = prevent_fp64_optimization(a.y * b.x); prod.y = prevent_fp64_optimization(prod.y + crossProduct2); #ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND prod = split2(prod); #endif prod = quickTwoSum(prod.x, prod.y); return prod; } fn div_fp64(a: vec2f, b: vec2f) -> vec2f { let xn = prevent_fp64_optimization(1.0 / b.x); let yn = mul_fp64(a, vec2f(xn, fp64_runtime_zero())); let diff = prevent_fp64_optimization(sub_fp64(a, mul_fp64(b, yn)).x); let prod = twoProd(xn, diff); return sum_fp64(yn, prod); } fn sqrt_fp64(a: vec2f) -> vec2f { if (a.x == 0.0 && a.y == 0.0) { return vec2f(0.0, 0.0); } if (a.x < 0.0) { let nanValue = fp64_nan(a.x); return vec2f(nanValue, nanValue); } let x = prevent_fp64_optimization(1.0 / sqrt(a.x)); let yn = prevent_fp64_optimization(a.x * x); #ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND let ynSqr = twoSqr(yn) * fp64arithmetic.ONE; #else let ynSqr = twoSqr(yn); #endif let diff = prevent_fp64_optimization(sub_fp64(a, ynSqr).x); let prod = twoProd(prevent_fp64_optimization(x * 0.5), diff); #ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND return sum_fp64(split(yn), prod); #else return sum_fp64(vec2f(yn, 0.0), prod); #endif } `;var n2=`const vec2 E_FP64 = vec2(2.7182817459106445e+00, 8.254840366817007e-08); const vec2 LOG2_FP64 = vec2(0.6931471824645996e+00, -1.9046542121259336e-09); const vec2 PI_FP64 = vec2(3.1415927410125732, -8.742278012618954e-8); const vec2 TWO_PI_FP64 = vec2(6.2831854820251465, -1.7484556025237907e-7); const vec2 PI_2_FP64 = vec2(1.5707963705062866, -4.371139006309477e-8); const vec2 PI_4_FP64 = vec2(0.7853981852531433, -2.1855695031547384e-8); const vec2 PI_16_FP64 = vec2(0.19634954631328583, -5.463923757886846e-9); const vec2 PI_16_2_FP64 = vec2(0.39269909262657166, -1.0927847515773692e-8); const vec2 PI_16_3_FP64 = vec2(0.5890486240386963, -1.4906100798128818e-9); const vec2 PI_180_FP64 = vec2(0.01745329238474369, 1.3519960498364902e-10); const vec2 SIN_TABLE_0_FP64 = vec2(0.19509032368659973, -1.6704714833615242e-9); const vec2 SIN_TABLE_1_FP64 = vec2(0.3826834261417389, 6.22335089017767e-9); const vec2 SIN_TABLE_2_FP64 = vec2(0.5555702447891235, -1.1769521357507529e-8); const vec2 SIN_TABLE_3_FP64 = vec2(0.7071067690849304, 1.2101617041793133e-8); const vec2 COS_TABLE_0_FP64 = vec2(0.9807852506637573, 2.9739473106360492e-8); const vec2 COS_TABLE_1_FP64 = vec2(0.9238795042037964, 2.8307490351764386e-8); const vec2 COS_TABLE_2_FP64 = vec2(0.8314695954322815, 1.6870263741530778e-8); const vec2 COS_TABLE_3_FP64 = vec2(0.7071067690849304, 1.2101617152815436e-8); const vec2 INVERSE_FACTORIAL_3_FP64 = vec2(1.666666716337204e-01, -4.967053879312289e-09); // 1/3! const vec2 INVERSE_FACTORIAL_4_FP64 = vec2(4.16666679084301e-02, -1.2417634698280722e-09); // 1/4! const vec2 INVERSE_FACTORIAL_5_FP64 = vec2(8.333333767950535e-03, -4.34617203337595e-10); // 1/5! const vec2 INVERSE_FACTORIAL_6_FP64 = vec2(1.3888889225199819e-03, -3.3631094437103215e-11); // 1/6! const vec2 INVERSE_FACTORIAL_7_FP64 = vec2(1.9841270113829523e-04, -2.725596874933456e-12); // 1/7! const vec2 INVERSE_FACTORIAL_8_FP64 = vec2(2.4801587642286904e-05, -3.406996025904184e-13); // 1/8! const vec2 INVERSE_FACTORIAL_9_FP64 = vec2(2.75573188446287533e-06, 3.7935713937038186e-14); // 1/9! const vec2 INVERSE_FACTORIAL_10_FP64 = vec2(2.755731998149713e-07, -7.575112367869873e-15); // 1/10! float nint(float d) { if (d == floor(d)) return d; return floor(d + 0.5); } vec2 nint_fp64(vec2 a) { float hi = nint(a.x); float lo; vec2 tmp; if (hi == a.x) { lo = nint(a.y); tmp = quickTwoSum(hi, lo); } else { lo = 0.0; if (abs(hi - a.x) == 0.5 && a.y < 0.0) { hi -= 1.0; } tmp = vec2(hi, lo); } return tmp; } /* k_power controls how much range reduction we would like to have Range reduction uses the following method: assume a = k_power * r + m * log(2), k and m being integers. Set k_power = 4 (we can choose other k to trade accuracy with performance. we only need to calculate exp(r) and using exp(a) = 2^m * exp(r)^k_power; */ vec2 exp_fp64(vec2 a) { // We need to make sure these two numbers match // as bit-wise shift is not available in GLSL 1.0 const int k_power = 4; const float k = 16.0; const float inv_k = 1.0 / k; if (a.x <= -88.0) return vec2(0.0, 0.0); if (a.x >= 88.0) return vec2(1.0 / 0.0, 1.0 / 0.0); if (a.x == 0.0 && a.y == 0.0) return vec2(1.0, 0.0); if (a.x == 1.0 && a.y == 0.0) return E_FP64; float m = floor(a.x / LOG2_FP64.x + 0.5); vec2 r = sub_fp64(a, mul_fp64(LOG2_FP64, vec2(m, 0.0))) * inv_k; vec2 s, t, p; p = mul_fp64(r, r); s = sum_fp64(r, p * 0.5); p = mul_fp64(p, r); t = mul_fp64(p, INVERSE_FACTORIAL_3_FP64); s = sum_fp64(s, t); p = mul_fp64(p, r); t = mul_fp64(p, INVERSE_FACTORIAL_4_FP64); s = sum_fp64(s, t); p = mul_fp64(p, r); t = mul_fp64(p, INVERSE_FACTORIAL_5_FP64); // s = sum_fp64(s, t); // p = mul_fp64(p, r); // t = mul_fp64(p, INVERSE_FACTORIAL_6_FP64); // s = sum_fp64(s, t); // p = mul_fp64(p, r); // t = mul_fp64(p, INVERSE_FACTORIAL_7_FP64); s = sum_fp64(s, t); // At this point, s = exp(r) - 1; but after following 4 recursions, we will get exp(r) ^ 512 - 1. for (int i = 0; i < k_power; i++) { s = sum_fp64(s * 2.0, mul_fp64(s, s)); } #if defined(NVIDIA_FP64_WORKAROUND) || defined(INTEL_FP64_WORKAROUND) s = sum_fp64(s, vec2(fp64.ONE, 0.0)); #else s = sum_fp64(s, vec2(1.0, 0.0)); #endif return s * pow(2.0, m); // return r; } vec2 log_fp64(vec2 a) { if (a.x == 1.0 && a.y == 0.0) return vec2(0.0, 0.0); if (a.x <= 0.0) return vec2(0.0 / 0.0, 0.0 / 0.0); vec2 x = vec2(log(a.x), 0.0); vec2 s; #if defined(NVIDIA_FP64_WORKAROUND) || defined(INTEL_FP64_WORKAROUND) s = vec2(fp64.ONE, 0.0); #else s = vec2(1.0, 0.0); #endif x = sub_fp64(sum_fp64(x, mul_fp64(a, exp_fp64(-x))), s); return x; } vec2 sin_taylor_fp64(vec2 a) { vec2 r, s, t, x; if (a.x == 0.0 && a.y == 0.0) { return vec2(0.0, 0.0); } x = -mul_fp64(a, a); s = a; r = a; r = mul_fp64(r, x); t = mul_fp64(r, INVERSE_FACTORIAL_3_FP64); s = sum_fp64(s, t); r = mul_fp64(r, x); t = mul_fp64(r, INVERSE_FACTORIAL_5_FP64); s = sum_fp64(s, t); /* keep the following commented code in case we need them for extra accuracy from the Taylor expansion*/ // r = mul_fp64(r, x); // t = mul_fp64(r, INVERSE_FACTORIAL_7_FP64); // s = sum_fp64(s, t); // r = mul_fp64(r, x); // t = mul_fp64(r, INVERSE_FACTORIAL_9_FP64); // s = sum_fp64(s, t); return s; } vec2 cos_taylor_fp64(vec2 a) { vec2 r, s, t, x; if (a.x == 0.0 && a.y == 0.0) { return vec2(1.0, 0.0); } x = -mul_fp64(a, a); r = x; s = sum_fp64(vec2(1.0, 0.0), r * 0.5); r = mul_fp64(r, x); t = mul_fp64(r, INVERSE_FACTORIAL_4_FP64); s = sum_fp64(s, t); r = mul_fp64(r, x); t = mul_fp64(r, INVERSE_FACTORIAL_6_FP64); s = sum_fp64(s, t); /* keep the following commented code in case we need them for extra accuracy from the Taylor expansion*/ // r = mul_fp64(r, x); // t = mul_fp64(r, INVERSE_FACTORIAL_8_FP64); // s = sum_fp64(s, t); // r = mul_fp64(r, x); // t = mul_fp64(r, INVERSE_FACTORIAL_10_FP64); // s = sum_fp64(s, t); return s; } void sincos_taylor_fp64(vec2 a, out vec2 sin_t, out vec2 cos_t) { if (a.x == 0.0 && a.y == 0.0) { sin_t = vec2(0.0, 0.0); cos_t = vec2(1.0, 0.0); } sin_t = sin_taylor_fp64(a); cos_t = sqrt_fp64(sub_fp64(vec2(1.0, 0.0), mul_fp64(sin_t, sin_t))); } vec2 sin_fp64(vec2 a) { if (a.x == 0.0 && a.y == 0.0) { return vec2(0.0, 0.0); } // 2pi range reduction vec2 z = nint_fp64(div_fp64(a, TWO_PI_FP64)); vec2 r = sub_fp64(a, mul_fp64(TWO_PI_FP64, z)); vec2 t; float q = floor(r.x / PI_2_FP64.x + 0.5); int j = int(q); if (j < -2 || j > 2) { return vec2(0.0 / 0.0, 0.0 / 0.0); } t = sub_fp64(r, mul_fp64(PI_2_FP64, vec2(q, 0.0))); q = floor(t.x / PI_16_FP64.x + 0.5); int k = int(q); if (k == 0) { if (j == 0) { return sin_taylor_fp64(t); } else if (j == 1) { return cos_taylor_fp64(t); } else if (j == -1) { return -cos_taylor_fp64(t); } else { return -sin_taylor_fp64(t); } } int abs_k = int(abs(float(k))); if (abs_k > 4) { return vec2(0.0 / 0.0, 0.0 / 0.0); } else { t = sub_fp64(t, mul_fp64(PI_16_FP64, vec2(q, 0.0))); } vec2 u = vec2(0.0, 0.0); vec2 v = vec2(0.0, 0.0); #if defined(NVIDIA_FP64_WORKAROUND) || defined(INTEL_FP64_WORKAROUND) if (abs(float(abs_k) - 1.0) < 0.5) { u = COS_TABLE_0_FP64; v = SIN_TABLE_0_FP64; } else if (abs(float(abs_k) - 2.0) < 0.5) { u = COS_TABLE_1_FP64; v = SIN_TABLE_1_FP64; } else if (abs(float(abs_k) - 3.0) < 0.5) { u = COS_TABLE_2_FP64; v = SIN_TABLE_2_FP64; } else if (abs(float(abs_k) - 4.0) < 0.5) { u = COS_TABLE_3_FP64; v = SIN_TABLE_3_FP64; } #else if (abs_k == 1) { u = COS_TABLE_0_FP64; v = SIN_TABLE_0_FP64; } else if (abs_k == 2) { u = COS_TABLE_1_FP64; v = SIN_TABLE_1_FP64; } else if (abs_k == 3) { u = COS_TABLE_2_FP64; v = SIN_TABLE_2_FP64; } else if (abs_k == 4) { u = COS_TABLE_3_FP64; v = SIN_TABLE_3_FP64; } #endif vec2 sin_t, cos_t; sincos_taylor_fp64(t, sin_t, cos_t); vec2 result = vec2(0.0, 0.0); if (j == 0) { if (k > 0) { result = sum_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t)); } else { result = sub_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t)); } } else if (j == 1) { if (k > 0) { result = sub_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t)); } else { result = sum_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t)); } } else if (j == -1) { if (k > 0) { result = sub_fp64(mul_fp64(v, sin_t), mul_fp64(u, cos_t)); } else { result = -sum_fp64(mul_fp64(v, sin_t), mul_fp64(u, cos_t)); } } else { if (k > 0) { result = -sum_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t)); } else { result = sub_fp64(mul_fp64(v, cos_t), mul_fp64(u, sin_t)); } } return result; } vec2 cos_fp64(vec2 a) { if (a.x == 0.0 && a.y == 0.0) { return vec2(1.0, 0.0); } // 2pi range reduction vec2 z = nint_fp64(div_fp64(a, TWO_PI_FP64)); vec2 r = sub_fp64(a, mul_fp64(TWO_PI_FP64, z)); vec2 t; float q = floor(r.x / PI_2_FP64.x + 0.5); int j = int(q); if (j < -2 || j > 2) { return vec2(0.0 / 0.0, 0.0 / 0.0); } t = sub_fp64(r, mul_fp64(PI_2_FP64, vec2(q, 0.0))); q = floor(t.x / PI_16_FP64.x + 0.5); int k = int(q); if (k == 0) { if (j == 0) { return cos_taylor_fp64(t); } else if (j == 1) { return -sin_taylor_fp64(t); } else if (j == -1) { return sin_taylor_fp64(t); } else { return -cos_taylor_fp64(t); } } int abs_k = int(abs(float(k))); if (abs_k > 4) { return vec2(0.0 / 0.0, 0.0 / 0.0); } else { t = sub_fp64(t, mul_fp64(PI_16_FP64, vec2(q, 0.0))); } vec2 u = vec2(0.0, 0.0); vec2 v = vec2(0.0, 0.0); #if defined(NVIDIA_FP64_WORKAROUND) || defined(INTEL_FP64_WORKAROUND) if (abs(float(abs_k) - 1.0) < 0.5) { u = COS_TABLE_0_FP64; v = SIN_TABLE_0_FP64; } else if (abs(float(abs_k) - 2.0) < 0.5) { u = COS_TABLE_1_FP64; v = SIN_TABLE_1_FP64; } else if (abs(float(abs_k) - 3.0) < 0.5) { u = COS_TABLE_2_FP64; v = SIN_TABLE_2_FP64; } else if (abs(float(abs_k) - 4.0) < 0.5) { u = COS_TABLE_3_FP64; v = SIN_TABLE_3_FP64; } #else if (abs_k == 1) { u = COS_TABLE_0_FP64; v = SIN_TABLE_0_FP64; } else if (abs_k == 2) { u = COS_TABLE_1_FP64; v = SIN_TABLE_1_FP64; } else if (abs_k == 3) { u = COS_TABLE_2_FP64; v = SIN_TABLE_2_FP64; } else if (abs_k == 4) { u = COS_TABLE_3_FP64; v = SIN_TABLE_3_FP64; } #endif vec2 sin_t, cos_t; sincos_taylor_fp64(t, sin_t, cos_t); vec2 result = vec2(0.0, 0.0); if (j == 0) { if (k > 0) { result = sub_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t)); } else { result = sum_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t)); } } else if (j == 1) { if (k > 0) { result = -sum_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t)); } else { result = sub_fp64(mul_fp64(v, cos_t), mul_fp64(u, sin_t)); } } else if (j == -1) { if (k > 0) { result = sum_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t)); } else { result = sub_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t)); } } else { if (k > 0) { result = sub_fp64(mul_fp64(v, sin_t), mul_fp64(u, cos_t)); } else { result = -sum_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t)); } } return result; } vec2 tan_fp64(vec2 a) { vec2 sin_a; vec2 cos_a; if (a.x == 0.0 && a.y == 0.0) { return vec2(0.0, 0.0); } // 2pi range reduction vec2 z = nint_fp64(div_fp64(a, TWO_PI_FP64)); vec2 r = sub_fp64(a, mul_fp64(TWO_PI_FP64, z)); vec2 t; float q = floor(r.x / PI_2_FP64.x + 0.5); int j = int(q); if (j < -2 || j > 2) { return vec2(0.0 / 0.0, 0.0 / 0.0); } t = sub_fp64(r, mul_fp64(PI_2_FP64, vec2(q, 0.0))); q = floor(t.x / PI_16_FP64.x + 0.5); int k = int(q); int abs_k = int(abs(float(k))); // We just can't get PI/16 * 3.0 very accurately. // so let's just store it if (abs_k > 4) { return vec2(0.0 / 0.0, 0.0 / 0.0); } else { t = sub_fp64(t, mul_fp64(PI_16_FP64, vec2(q, 0.0))); } vec2 u = vec2(0.0, 0.0); vec2 v = vec2(0.0, 0.0); vec2 sin_t, cos_t; vec2 s, c; sincos_taylor_fp64(t, sin_t, cos_t); if (k == 0) { s = sin_t; c = cos_t; } else { #if defined(NVIDIA_FP64_WORKAROUND) || defined(INTEL_FP64_WORKAROUND) if (abs(float(abs_k) - 1.0) < 0.5) { u = COS_TABLE_0_FP64; v = SIN_TABLE_0_FP64; } else if (abs(float(abs_k) - 2.0) < 0.5) { u = COS_TABLE_1_FP64; v = SIN_TABLE_1_FP64; } else if (abs(float(abs_k) - 3.0) < 0.5) { u = COS_TABLE_2_FP64; v = SIN_TABLE_2_FP64; } else if (abs(float(abs_k) - 4.0) < 0.5) { u = COS_TABLE_3_FP64; v = SIN_TABLE_3_FP64; } #else if (abs_k == 1) { u = COS_TABLE_0_FP64; v = SIN_TABLE_0_FP64; } else if (abs_k == 2) { u = COS_TABLE_1_FP64; v = SIN_TABLE_1_FP64; } else if (abs_k == 3) { u = COS_TABLE_2_FP64; v = SIN_TABLE_2_FP64; } else if (abs_k == 4) { u = COS_TABLE_3_FP64; v = SIN_TABLE_3_FP64; } #endif if (k > 0) { s = sum_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t)); c = sub_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t)); } else { s = sub_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t)); c = sum_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t)); } } if (j == 0) { sin_a = s; cos_a = c; } else if (j == 1) { sin_a = c; cos_a = -s; } else if (j == -1) { sin_a = -c; cos_a = s; } else { sin_a = -s; cos_a = -c; } return div_fp64(sin_a, cos_a); } vec2 radians_fp64(vec2 degree) { return mul_fp64(degree, PI_180_FP64); } vec2 mix_fp64(vec2 a, vec2 b, float x) { vec2 range = sub_fp64(b, a); return sum_fp64(a, mul_fp64(range, vec2(x, 0.0))); } // Vector functions // vec2 functions void vec2_sum_fp64(vec2 a[2], vec2 b[2], out vec2 out_val[2]) { out_val[0] = sum_fp64(a[0], b[0]); out_val[1] = sum_fp64(a[1], b[1]); } void vec2_sub_fp64(vec2 a[2], vec2 b[2], out vec2 out_val[2]) { out_val[0] = sub_fp64(a[0], b[0]); out_val[1] = sub_fp64(a[1], b[1]); } void vec2_mul_fp64(vec2 a[2], vec2 b[2], out vec2 out_val[2]) { out_val[0] = mul_fp64(a[0], b[0]); out_val[1] = mul_fp64(a[1], b[1]); } void vec2_div_fp64(vec2 a[2], vec2 b[2], out vec2 out_val[2]) { out_val[0] = div_fp64(a[0], b[0]); out_val[1] = div_fp64(a[1], b[1]); } void vec2_mix_fp64(vec2 x[2], vec2 y[2], float a, out vec2 out_val[2]) { vec2 range[2]; vec2_sub_fp64(y, x, range); vec2 portion[2]; portion[0] = range[0] * a; portion[1] = range[1] * a; vec2_sum_fp64(x, portion, out_val); } vec2 vec2_length_fp64(vec2 x[2]) { return sqrt_fp64(sum_fp64(mul_fp64(x[0], x[0]), mul_fp64(x[1], x[1]))); } void vec2_normalize_fp64(vec2 x[2], out vec2 out_val[2]) { vec2 length = vec2_length_fp64(x); vec2 length_vec2[2]; length_vec2[0] = length; length_vec2[1] = length; vec2_div_fp64(x, length_vec2, out_val); } vec2 vec2_distance_fp64(vec2 x[2], vec2 y[2]) { vec2 diff[2]; vec2_sub_fp64(x, y, diff); return vec2_length_fp64(diff); } vec2 vec2_dot_fp64(vec2 a[2], vec2 b[2]) { vec2 v[2]; v[0] = mul_fp64(a[0], b[0]); v[1] = mul_fp64(a[1], b[1]); return sum_fp64(v[0], v[1]); } // vec3 functions void vec3_sub_fp64(vec2 a[3], vec2 b[3], out vec2 out_val[3]) { for (int i = 0; i < 3; i++) { out_val[i] = sum_fp64(a[i], b[i]); } } void vec3_sum_fp64(vec2 a[3], vec2 b[3], out vec2 out_val[3]) { for (int i = 0; i < 3; i++) { out_val[i] = sum_fp64(a[i], b[i]); } } vec2 vec3_length_fp64(vec2 x[3]) { return sqrt_fp64(sum_fp64(sum_fp64(mul_fp64(x[0], x[0]), mul_fp64(x[1], x[1])), mul_fp64(x[2], x[2]))); } vec2 vec3_distance_fp64(vec2 x[3], vec2 y[3]) { vec2 diff[3]; vec3_sub_fp64(x, y, diff); return vec3_length_fp64(diff); } // vec4 functions void vec4_fp64(vec4 a, out vec2 out_val[4]) { out_val[0].x = a[0]; out_val[0].y = 0.0; out_val[1].x = a[1]; out_val[1].y = 0.0; out_val[2].x = a[2]; out_val[2].y = 0.0; out_val[3].x = a[3]; out_val[3].y = 0.0; } void vec4_scalar_mul_fp64(vec2 a[4], vec2 b, out vec2 out_val[4]) { out_val[0] = mul_fp64(a[0], b); out_val[1] = mul_fp64(a[1], b); out_val[2] = mul_fp64(a[2], b); out_val[3] = mul_fp64(a[3], b); } void vec4_sum_fp64(vec2 a[4], vec2 b[4], out vec2 out_val[4]) { for (int i = 0; i < 4; i++) { out_val[i] = sum_fp64(a[i], b[i]); } } void vec4_dot_fp64(vec2 a[4], vec2 b[4], out vec2 out_val) { vec2 v[4]; v[0] = mul_fp64(a[0], b[0]); v[1] = mul_fp64(a[1], b[1]); v[2] = mul_fp64(a[2], b[2]); v[3] = mul_fp64(a[3], b[3]); out_val = sum_fp64(sum_fp64(v[0], v[1]), sum_fp64(v[2], v[3])); } void mat4_vec4_mul_fp64(vec2 b[16], vec2 a[4], out vec2 out_val[4]) { vec2 tmp[4]; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { tmp[j] = b[j + i * 4]; } vec4_dot_fp64(a, tmp, out_val[i]); } } `;var Y$={ONE:1,SPLIT:4097},bm={name:"fp64arithmetic",source:o2,fs:gT,vs:gT,defaultUniforms:Y$,uniformTypes:{ONE:"f32",SPLIT:"f32"},fp64ify:xm,fp64LowPart:dT,fp64ifyMatrix4:hT},Am={name:"fp64",vs:n2,dependencies:[bm],fp64ify:xm,fp64LowPart:dT,fp64ifyMatrix4:hT};var i2=`layout(std140) uniform floatColorsUniforms { float useByteColors; } floatColors; vec3 floatColors_normalize(vec3 inputColor) { return floatColors.useByteColors > 0.5 ? inputColor / 255.0 : inputColor; } vec4 floatColors_normalize(vec4 inputColor) { return floatColors.useByteColors > 0.5 ? inputColor / 255.0 : inputColor; } vec4 floatColors_premultiplyAlpha(vec4 inputColor) { return vec4(inputColor.rgb * inputColor.a, inputColor.a); } vec4 floatColors_unpremultiplyAlpha(vec4 inputColor) { return inputColor.a > 0.0 ? vec4(inputColor.rgb / inputColor.a, inputColor.a) : vec4(0.0); } vec4 floatColors_premultiply_alpha(vec4 inputColor) { return floatColors_premultiplyAlpha(inputColor); } vec4 floatColors_unpremultiply_alpha(vec4 inputColor) { return floatColors_unpremultiplyAlpha(inputColor); } `,K$=`struct floatColorsUniforms { useByteColors: f32 }; @group(0) @binding(auto) var<uniform> floatColors : floatColorsUniforms; fn floatColors_normalize(inputColor: vec3<f32>) -> vec3<f32> { return select(inputColor, inputColor / 255.0, floatColors.useByteColors > 0.5); } fn floatColors_normalize4(inputColor: vec4<f32>) -> vec4<f32> { return select(inputColor, inputColor / 255.0, floatColors.useByteColors > 0.5); } fn floatColors_premultiplyAlpha(inputColor: vec4<f32>) -> vec4<f32> { return vec4<f32>(inputColor.rgb * inputColor.a, inputColor.a); } fn floatColors_unpremultiplyAlpha(inputColor: vec4<f32>) -> vec4<f32> { return select( vec4<f32>(0.0), vec4<f32>(inputColor.rgb / inputColor.a, inputColor.a), inputColor.a > 0.0 ); } fn floatColors_premultiply_alpha(inputColor: vec4<f32>) -> vec4<f32> { return floatColors_premultiplyAlpha(inputColor); } fn floatColors_unpremultiply_alpha(inputColor: vec4<f32>) -> vec4<f32> { return floatColors_unpremultiplyAlpha(inputColor); } `,Tm={name:"floatColors",props:{},uniforms:{},vs:i2,fs:i2,source:K$,uniformTypes:{useByteColors:"f32"},defaultUniforms:{useByteColors:!0}};var q$=[0,1,1,1],Z$=`layout(std140) uniform pickingUniforms { float isActive; float isAttribute; float isHighlightActive; float useByteColors; vec3 highlightedObjectColor; vec4 highlightColor; } picking; out vec4 picking_vRGBcolor_Avalid; // Normalize unsigned byte color to 0-1 range vec3 picking_normalizeColor(vec3 color) { return picking.useByteColors > 0.5 ? color / 255.0 : color; } // Normalize unsigned byte color to 0-1 range vec4 picking_normalizeColor(vec4 color) { return picking.useByteColors > 0.5 ? color / 255.0 : color; } bool picking_isColorZero(vec3 color) { return dot(color, vec3(1.0)) < 0.00001; } bool picking_isColorValid(vec3 color) { return dot(color, vec3(1.0)) > 0.00001; } // Check if this vertex is highlighted bool isVertexHighlighted(vec3 vertexColor) { vec3 highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor); return bool(picking.isHighlightActive) && picking_isColorZero(abs(vertexColor - highlightedObjectColor)); } // Set the current picking color void picking_setPickingColor(vec3 pickingColor) { pickingColor = picking_normalizeColor(pickingColor); if (bool(picking.isActive)) { // Use alpha as the validity flag. If pickingColor is [0, 0, 0] fragment is non-pickable picking_vRGBcolor_Avalid.a = float(picking_isColorValid(pickingColor)); if (!bool(picking.isAttribute)) { // Stores the picking color so that the fragment shader can render it during picking picking_vRGBcolor_Avalid.rgb = pickingColor; } } else { // Do the comparison with selected item color in vertex shader as it should mean fewer compares picking_vRGBcolor_Avalid.a = float(isVertexHighlighted(pickingColor)); } } void picking_setPickingAttribute(float value) { if (bool(picking.isAttribute)) { picking_vRGBcolor_Avalid.r = value; } } void picking_setPickingAttribute(vec2 value) { if (bool(picking.isAttribute)) { picking_vRGBcolor_Avalid.rg = value; } } void picking_setPickingAttribute(vec3 value) { if (bool(picking.isAttribute)) { picking_vRGBcolor_Avalid.rgb = value; } } `,J$=`layout(std140) uniform pickingUniforms { float isActive; float isAttribute; float isHighlightActive; float useByteColors; vec3 highlightedObjectColor; vec4 highlightColor; } picking; in vec4 picking_vRGBcolor_Avalid; /* * Returns highlight color if this item is selected. */ vec4 picking_filterHighlightColor(vec4 color) { // If we are still picking, we don't highlight if (picking.isActive > 0.5) { return color; } bool selected = bool(picking_vRGBcolor_Avalid.a); if (selected) { // Blend in highlight color based on its alpha value float highLightAlpha = picking.highlightColor.a; float blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha); float highLightRatio = highLightAlpha / blendedAlpha; vec3 blendedRGB = mix(color.rgb, picking.highlightColor.rgb, highLightRatio); return vec4(blendedRGB, blendedAlpha); } else { return color; } } /* * Returns picking color if picking enabled else unmodified argument. */ vec4 picking_filterPickingColor(vec4 color) { if (bool(picking.isActive)) { if (picking_vRGBcolor_Avalid.a == 0.0) { discard; } return picking_vRGBcolor_Avalid; } return color; } /* * Returns picking color if picking is enabled if not * highlight color if this item is selected, otherwise unmodified argument. */ vec4 picking_filterColor(vec4 color) { vec4 highlightColor = picking_filterHighlightColor(color); return picking_filterPickingColor(highlightColor); } `,vm={props:{},uniforms:{},name:"picking",uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useByteColors:"f32",highlightedObjectColor:"vec3<f32>",highlightColor:"vec4<f32>"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useByteColors:!0,highlightedObjectColor:[0,0,0],highlightColor:q$},vs:Z$,fs:J$,getUniforms:Q$};function Q$(t={},e){let r={},o=bf(t.useByteColors,!0);if(t.highlightedObjectColor!==void 0)if(t.highlightedObjectColor===null)r.isHighlightActive=!1;else{r.isHighlightActive=!0;let n=t.highlightedObjectColor.slice(0,3);r.highlightedObjectColor=n}return t.highlightColor&&(r.highlightColor=pT(t.highlightColor,o)),t.isActive!==void 0&&(r.isActive=Boolean(t.isActive),r.isAttribute=Boolean(t.isAttribute)),t.useByteColors!==void 0&&(r.useByteColors=Boolean(t.useByteColors)),r}var Af=20,eX=` struct skinUniforms { jointMatrix: array<mat4x4<f32>, ${Af}>, }; @group(0) @binding(auto) var<uniform> skin: skinUniforms; fn getSkinMatrix(weights: vec4f, joints: vec4u) -> mat4x4<f32> { return (weights.x * skin.jointMatrix[joints.x]) + (weights.y * skin.jointMatrix[joints.y]) + (weights.z * skin.jointMatrix[joints.z]) + (weights.w * skin.jointMatrix[joints.w]); } `,tX=` layout(std140) uniform skinUniforms { mat4 jointMatrix[SKIN_MAX_JOINTS]; } skin; mat4 getSkinMatrix(vec4 weights, uvec4 joints) { return (weights.x * skin.jointMatrix[joints.x]) + (weights.y * skin.jointMatrix[joints.y]) + (weights.z * skin.jointMatrix[joints.z]) + (weights.w * skin.jointMatrix[joints.w]); } `,rX="",_T={props:{},uniforms:{},name:"skin",bindingLayout:[{name:"skin",group:0}],dependencies:[],source:eX,vs:tX,fs:rX,defines:{SKIN_MAX_JOINTS:Af},getUniforms:(t={},e)=>{let{scenegraphsFromGLTF:r}=t;if(!r?.gltf?.skins?.[0])return{jointMatrix:[]};let{inverseBindMatrices:o,joints:n,skeleton:i}=r.gltf.skins[0],s=[],a=o.value.length/16;for(let u=0;u<a;u++){let d=o.value.subarray(u*16,u*16+16);s.push(new V(Array.from(d)))}let c=r.gltfNodeIndexToNodeMap.get(i),l={};c.preorderTraversal((u,{worldMatrix:d})=>{l[u.id]=d});let f=new Float32Array(Af*16);for(let u=0;u<Af;++u){let d=n[u];if(d===void 0)break;let h=l[r.gltfNodeIndexToNodeMap.get(d).id],p=s[u],m=new V().copy(h).multiplyRight(p),g=u*16;for(let _=0;_<16;_++)f[g+_]=m[_]}return{jointMatrix:f}},uniformTypes:{jointMatrix:["mat4x4<f32>",Af]}};q();var pv=`precision highp int; // #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX)) struct AmbientLight { vec3 color; }; struct PointLight { vec3 color; vec3 position; vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential }; struct SpotLight { vec3 color; vec3 position; vec3 direction; vec3 attenuation; vec2 coneCos; }; struct DirectionalLight { vec3 color; vec3 direction; }; struct UniformLight { vec3 color; vec3 position; vec3 direction; vec3 attenuation; vec2 coneCos; }; layout(std140) uniform lightingUniforms { int enabled; int directionalLightCount; int pointLightCount; int spotLightCount; vec3 ambientColor; UniformLight lights[5]; } lighting; PointLight lighting_getPointLight(int index) { UniformLight light = lighting.lights[index]; return PointLight(light.color, light.position, light.attenuation); } SpotLight lighting_getSpotLight(int index) { UniformLight light = lighting.lights[lighting.pointLightCount + index]; return SpotLight(light.color, light.position, light.direction, light.attenuation, light.coneCos); } DirectionalLight lighting_getDirectionalLight(int index) { UniformLight light = lighting.lights[lighting.pointLightCount + lighting.spotLightCount + index]; return DirectionalLight(light.color, light.direction); } float getPointLightAttenuation(PointLight pointLight, float distance) { return pointLight.attenuation.x + pointLight.attenuation.y * distance + pointLight.attenuation.z * distance * distance; } float getSpotLightAttenuation(SpotLight spotLight, vec3 positionWorldspace) { vec3 light_direction = normalize(positionWorldspace - spotLight.position); float coneFactor = smoothstep( spotLight.coneCos.y, spotLight.coneCos.x, dot(normalize(spotLight.direction), light_direction) ); float distanceAttenuation = getPointLightAttenuation( PointLight(spotLight.color, spotLight.position, spotLight.attenuation), distance(spotLight.position, positionWorldspace) ); return distanceAttenuation / max(coneFactor, 0.0001); } // #endif `;var aI=`// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX)) const MAX_LIGHTS: i32 = 5; struct AmbientLight { color: vec3<f32>, }; struct PointLight { color: vec3<f32>, position: vec3<f32>, attenuation: vec3<f32>, // 2nd order x:Constant-y:Linear-z:Exponential }; struct SpotLight { color: vec3<f32>, position: vec3<f32>, direction: vec3<f32>, attenuation: vec3<f32>, coneCos: vec2<f32>, }; struct DirectionalLight { color: vec3<f32>, direction: vec3<f32>, }; struct UniformLight { color: vec3<f32>, position: vec3<f32>, direction: vec3<f32>, attenuation: vec3<f32>, coneCos: vec2<f32>, }; struct lightingUniforms { enabled: i32, directionalLightCount: i32, pointLightCount: i32, spotLightCount: i32, ambientColor: vec3<f32>, lights: array<UniformLight, 5>, }; @group(2) @binding(auto) var<uniform> lighting : lightingUniforms; fn lighting_getPointLight(index: i32) -> PointLight { let light = lighting.lights[index]; return PointLight(light.color, light.position, light.attenuation); } fn lighting_getSpotLight(index: i32) -> SpotLight { let light = lighting.lights[lighting.pointLightCount + index]; return SpotLight(light.color, light.position, light.direction, light.attenuation, light.coneCos); } fn lighting_getDirectionalLight(index: i32) -> DirectionalLight { let light = lighting.lights[lighting.pointLightCount + lighting.spotLightCount + index]; return DirectionalLight(light.color, light.direction); } fn getPointLightAttenuation(pointLight: PointLight, distance: f32) -> f32 { return pointLight.attenuation.x + pointLight.attenuation.y * distance + pointLight.attenuation.z * distance * distance; } fn getSpotLightAttenuation(spotLight: SpotLight, positionWorldspace: vec3<f32>) -> f32 { let lightDirection = normalize(positionWorldspace - spotLight.position); let coneFactor = smoothstep( spotLight.coneCos.y, spotLight.coneCos.x, dot(normalize(spotLight.direction), lightDirection) ); let distanceAttenuation = getPointLightAttenuation( PointLight(spotLight.color, spotLight.position, spotLight.attenuation), distance(spotLight.position, positionWorldspace) ); return distanceAttenuation / max(coneFactor, 0.0001); } `;var ss=5,y7={color:"vec3<f32>",position:"vec3<f32>",direction:"vec3<f32>",attenuation:"vec3<f32>",coneCos:"vec2<f32>"},Ka={props:{},uniforms:{},name:"lighting",defines:{},uniformTypes:{enabled:"i32",directionalLightCount:"i32",pointLightCount:"i32",spotLightCount:"i32",ambientColor:"vec3<f32>",lights:[y7,ss]},defaultUniforms:Gm(),bindingLayout:[{name:"lighting",group:2}],firstBindingSlot:0,source:aI,vs:pv,fs:pv,getUniforms:x7};function x7(t,e={}){if(t=t&&{...t},!t)return Gm();t.lights&&(t={...t,...A7(t.lights),lights:void 0});let{useByteColors:r,ambientLight:o,pointLights:n,spotLights:i,directionalLights:s}=t||{};if(!(o||n&&n.length>0||i&&i.length>0||s&&s.length>0))return{...Gm(),enabled:0};let c={...Gm(),...b7({useByteColors:r,ambientLight:o,pointLights:n,spotLights:i,directionalLights:s})};return t.enabled!==void 0&&(c.enabled=t.enabled?1:0),c}function b7({useByteColors:t,ambientLight:e,pointLights:r=[],spotLights:o=[],directionalLights:n=[]}){let i=cI(),s=0,a=0,c=0,l=0;for(let f of r){if(s>=ss)break;i[s]={...i[s],color:Wm(f,t),position:f.position,attenuation:f.attenuation||[1,0,0]},s++,a++}for(let f of o){if(s>=ss)break;i[s]={...i[s],color:Wm(f,t),position:f.position,direction:f.direction,attenuation:f.attenuation||[1,0,0],coneCos:v7(f)},s++,c++}for(let f of n){if(s>=ss)break;i[s]={...i[s],color:Wm(f,t),direction:f.direction},s++,l++}return r.length+o.length+n.length>ss&&P.warn(`MAX_LIGHTS exceeded, truncating to ${ss}`)(),{ambientColor:Wm(e,t),directionalLightCount:l,pointLightCount:a,spotLightCount:c,lights:i}}function A7(t){let e={pointLights:[],spotLights:[],directionalLights:[]};for(let r of t||[])switch(r.type){case"ambient":e.ambientLight=r;break;case"directional":e.directionalLights?.push(r);break;case"point":e.pointLights?.push(r);break;case"spot":e.spotLights?.push(r);break;default:}return e}function Wm(t={},e){let{color:r=[0,0,0],intensity:o=1}=t;return Oa(r,bf(e,!0)).map(i=>i*o)}function Gm(){return{enabled:1,directionalLightCount:0,pointLightCount:0,spotLightCount:0,ambientColor:[.1,.1,.1],lights:cI()}}function cI(){return Array.from({length:ss},()=>T7())}function T7(){return{color:[1,1,1],position:[1,1,2],direction:[1,1,1],attenuation:[1,0,0],coneCos:[1,0]}}function v7(t){let e=t.innerConeAngle??0,r=t.outerConeAngle??Math.PI/4;return[Math.cos(e),Math.cos(r)]}var S7=`#ifdef USE_IBL @group(2) @binding(auto) var pbr_diffuseEnvSampler: texture_cube<f32>; @group(2) @binding(auto) var pbr_diffuseEnvSamplerSampler: sampler; @group(2) @binding(auto) var pbr_specularEnvSampler: texture_cube<f32>; @group(2) @binding(auto) var pbr_specularEnvSamplerSampler: sampler; @group(2) @binding(auto) var pbr_brdfLUT: texture_2d<f32>; @group(2) @binding(auto) var pbr_brdfLUTSampler: sampler; #endif `,lI=`#ifdef USE_IBL uniform samplerCube pbr_diffuseEnvSampler; uniform samplerCube pbr_specularEnvSampler; uniform sampler2D pbr_brdfLUT; #endif `,fI={name:"ibl",firstBindingSlot:32,bindingLayout:[{name:"pbr_diffuseEnvSampler",group:2},{name:"pbr_specularEnvSampler",group:2},{name:"pbr_brdfLUT",group:2}],source:S7,vs:lI,fs:lI};var $m=`layout(std140) uniform phongMaterialUniforms { uniform bool unlit; uniform float ambient; uniform float diffuse; uniform float shininess; uniform vec3 specularColor; } material; `,Xm=`layout(std140) uniform phongMaterialUniforms { uniform bool unlit; uniform float ambient; uniform float diffuse; uniform float shininess; uniform vec3 specularColor; } material; vec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) { vec3 halfway_direction = normalize(light_direction + view_direction); float lambertian = dot(light_direction, normal_worldspace); float specular = 0.0; if (lambertian > 0.0) { float specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0); specular = pow(specular_angle, material.shininess); } lambertian = max(lambertian, 0.0); return (lambertian * material.diffuse * surfaceColor + specular * floatColors_normalize(material.specularColor)) * color; } vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) { vec3 lightColor = surfaceColor; if (material.unlit) { return surfaceColor; } if (lighting.enabled == 0) { return lightColor; } vec3 view_direction = normalize(cameraPosition - position_worldspace); lightColor = material.ambient * surfaceColor * lighting.ambientColor; for (int i = 0; i < lighting.pointLightCount; i++) { PointLight pointLight = lighting_getPointLight(i); vec3 light_position_worldspace = pointLight.position; vec3 light_direction = normalize(light_position_worldspace - position_worldspace); float light_attenuation = getPointLightAttenuation(pointLight, distance(light_position_worldspace, position_worldspace)); lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color / light_attenuation); } for (int i = 0; i < lighting.spotLightCount; i++) { SpotLight spotLight = lighting_getSpotLight(i); vec3 light_position_worldspace = spotLight.position; vec3 light_direction = normalize(light_position_worldspace - position_worldspace); float light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace); lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, spotLight.color / light_attenuation); } for (int i = 0; i < lighting.directionalLightCount; i++) { DirectionalLight directionalLight = lighting_getDirectionalLight(i); lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color); } return lightColor; } `;var Ym=`struct phongMaterialUniforms { unlit: u32, ambient: f32, diffuse: f32, shininess: f32, specularColor: vec3<f32>, }; @group(3) @binding(auto) var<uniform> phongMaterial : phongMaterialUniforms; fn lighting_getLightColor(surfaceColor: vec3<f32>, light_direction: vec3<f32>, view_direction: vec3<f32>, normal_worldspace: vec3<f32>, color: vec3<f32>) -> vec3<f32> { let halfway_direction: vec3<f32> = normalize(light_direction + view_direction); var lambertian: f32 = dot(light_direction, normal_worldspace); var specular: f32 = 0.0; if (lambertian > 0.0) { let specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0); specular = pow(specular_angle, phongMaterial.shininess); } lambertian = max(lambertian, 0.0); return ( lambertian * phongMaterial.diffuse * surfaceColor + specular * floatColors_normalize(phongMaterial.specularColor) ) * color; } fn lighting_getLightColor2(surfaceColor: vec3<f32>, cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32> { var lightColor: vec3<f32> = surfaceColor; if (phongMaterial.unlit != 0u) { return surfaceColor; } if (lighting.enabled == 0) { return lightColor; } let view_direction: vec3<f32> = normalize(cameraPosition - position_worldspace); lightColor = phongMaterial.ambient * surfaceColor * lighting.ambientColor; for (var i: i32 = 0; i < lighting.pointLightCount; i++) { let pointLight: PointLight = lighting_getPointLight(i); let light_position_worldspace: vec3<f32> = pointLight.position; let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace); let light_attenuation = getPointLightAttenuation( pointLight, distance(light_position_worldspace, position_worldspace) ); lightColor += lighting_getLightColor( surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color / light_attenuation ); } for (var i: i32 = 0; i < lighting.spotLightCount; i++) { let spotLight: SpotLight = lighting_getSpotLight(i); let light_position_worldspace: vec3<f32> = spotLight.position; let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace); let light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace); lightColor += lighting_getLightColor( surfaceColor, light_direction, view_direction, normal_worldspace, spotLight.color / light_attenuation ); } for (var i: i32 = 0; i < lighting.directionalLightCount; i++) { let directionalLight: DirectionalLight = lighting_getDirectionalLight(i); lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color); } return lightColor; } fn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32>{ var lightColor = vec3<f32>(0, 0, 0); let surfaceColor = vec3<f32>(0, 0, 0); if (lighting.enabled != 0) { let view_direction = normalize(cameraPosition - position_worldspace); for (var i: i32 = 0; i < lighting.pointLightCount; i++) { let pointLight: PointLight = lighting_getPointLight(i); let light_position_worldspace: vec3<f32> = pointLight.position; let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace); let light_attenuation = getPointLightAttenuation( pointLight, distance(light_position_worldspace, position_worldspace) ); lightColor += lighting_getLightColor( surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color / light_attenuation ); } for (var i: i32 = 0; i < lighting.spotLightCount; i++) { let spotLight: SpotLight = lighting_getSpotLight(i); let light_position_worldspace: vec3<f32> = spotLight.position; let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace); let light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace); lightColor += lighting_getLightColor( surfaceColor, light_direction, view_direction, normal_worldspace, spotLight.color / light_attenuation ); } for (var i: i32 = 0; i < lighting.directionalLightCount; i++) { let directionalLight: DirectionalLight = lighting_getDirectionalLight(i); lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color); } } return lightColor; } `;var C7=[38.25,38.25,38.25],Xr={props:{},name:"gouraudMaterial",bindingLayout:[{name:"gouraudMaterial",group:3}],vs:Xm.replace("phongMaterial","gouraudMaterial"),fs:$m.replace("phongMaterial","gouraudMaterial"),source:Ym.replaceAll("phongMaterial","gouraudMaterial"),defines:{LIGHTING_VERTEX:!0},dependencies:[Ka,Tm],uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6,shininess:32,specularColor:C7},getUniforms(t){return{...Xr.defaultUniforms,...t}}};var E7=[38.25,38.25,38.25],nn={name:"phongMaterial",firstBindingSlot:0,bindingLayout:[{name:"phongMaterial",group:3}],dependencies:[Ka,Tm],source:Ym,vs:$m,fs:Xm,defines:{LIGHTING_FRAGMENT:!0},uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6,shininess:32,specularColor:E7},getUniforms(t){return{...nn.defaultUniforms,...t}}};var uI=`out vec3 pbr_vPosition; out vec2 pbr_vUV0; out vec2 pbr_vUV1; #ifdef HAS_NORMALS # ifdef HAS_TANGENTS out mat3 pbr_vTBN; # else out vec3 pbr_vNormal; # endif #endif void pbr_setPositionNormalTangentUV( vec4 position, vec4 normal, vec4 tangent, vec2 uv0, vec2 uv1 ) { vec4 pos = pbrProjection.modelMatrix * position; pbr_vPosition = vec3(pos.xyz) / pos.w; #ifdef HAS_NORMALS #ifdef HAS_TANGENTS vec3 normalW = normalize(vec3(pbrProjection.normalMatrix * vec4(normal.xyz, 0.0))); vec3 tangentW = normalize(vec3(pbrProjection.modelMatrix * vec4(tangent.xyz, 0.0))); vec3 bitangentW = cross(normalW, tangentW) * tangent.w; pbr_vTBN = mat3(tangentW, bitangentW, normalW); #else // HAS_TANGENTS != 1 pbr_vNormal = normalize(vec3(pbrProjection.modelMatrix * vec4(normal.xyz, 0.0))); #endif #endif #ifdef HAS_UV pbr_vUV0 = uv0; #else pbr_vUV0 = vec2(0.,0.); #endif pbr_vUV1 = uv1; } `,dI=`precision highp float; layout(std140) uniform pbrMaterialUniforms { // Material is unlit bool unlit; // Base color map bool baseColorMapEnabled; vec4 baseColorFactor; bool normalMapEnabled; float normalScale; // #ifdef HAS_NORMALMAP bool emissiveMapEnabled; vec3 emissiveFactor; // #ifdef HAS_EMISSIVEMAP vec2 metallicRoughnessValues; bool metallicRoughnessMapEnabled; bool occlusionMapEnabled; float occlusionStrength; // #ifdef HAS_OCCLUSIONMAP bool alphaCutoffEnabled; float alphaCutoff; // #ifdef ALPHA_CUTOFF vec3 specularColorFactor; float specularIntensityFactor; bool specularColorMapEnabled; bool specularIntensityMapEnabled; float ior; float transmissionFactor; bool transmissionMapEnabled; float thicknessFactor; float attenuationDistance; vec3 attenuationColor; float clearcoatFactor; float clearcoatRoughnessFactor; bool clearcoatMapEnabled; bool clearcoatRoughnessMapEnabled; vec3 sheenColorFactor; float sheenRoughnessFactor; bool sheenColorMapEnabled; bool sheenRoughnessMapEnabled; float iridescenceFactor; float iridescenceIor; vec2 iridescenceThicknessRange; bool iridescenceMapEnabled; float anisotropyStrength; float anisotropyRotation; vec2 anisotropyDirection; bool anisotropyMapEnabled; float emissiveStrength; // IBL bool IBLenabled; vec2 scaleIBLAmbient; // #ifdef USE_IBL // debugging flags used for shader output of intermediate PBR variables // #ifdef PBR_DEBUG vec4 scaleDiffBaseMR; vec4 scaleFGDSpec; // #endif int baseColorUVSet; mat3 baseColorUVTransform; int metallicRoughnessUVSet; mat3 metallicRoughnessUVTransform; int normalUVSet; mat3 normalUVTransform; int occlusionUVSet; mat3 occlusionUVTransform; int emissiveUVSet; mat3 emissiveUVTransform; int specularColorUVSet; mat3 specularColorUVTransform; int specularIntensityUVSet; mat3 specularIntensityUVTransform; int transmissionUVSet; mat3 transmissionUVTransform; int thicknessUVSet; mat3 thicknessUVTransform; int clearcoatUVSet; mat3 clearcoatUVTransform; int clearcoatRoughnessUVSet; mat3 clearcoatRoughnessUVTransform; int clearcoatNormalUVSet; mat3 clearcoatNormalUVTransform; int sheenColorUVSet; mat3 sheenColorUVTransform; int sheenRoughnessUVSet; mat3 sheenRoughnessUVTransform; int iridescenceUVSet; mat3 iridescenceUVTransform; int iridescenceThicknessUVSet; mat3 iridescenceThicknessUVTransform; int anisotropyUVSet; mat3 anisotropyUVTransform; } pbrMaterial; // Samplers #ifdef HAS_BASECOLORMAP uniform sampler2D pbr_baseColorSampler; #endif #ifdef HAS_NORMALMAP uniform sampler2D pbr_normalSampler; #endif #ifdef HAS_EMISSIVEMAP uniform sampler2D pbr_emissiveSampler; #endif #ifdef HAS_METALROUGHNESSMAP uniform sampler2D pbr_metallicRoughnessSampler; #endif #ifdef HAS_OCCLUSIONMAP uniform sampler2D pbr_occlusionSampler; #endif #ifdef HAS_SPECULARCOLORMAP uniform sampler2D pbr_specularColorSampler; #endif #ifdef HAS_SPECULARINTENSITYMAP uniform sampler2D pbr_specularIntensitySampler; #endif #ifdef HAS_TRANSMISSIONMAP uniform sampler2D pbr_transmissionSampler; #endif #ifdef HAS_THICKNESSMAP uniform sampler2D pbr_thicknessSampler; #endif #ifdef HAS_CLEARCOATMAP uniform sampler2D pbr_clearcoatSampler; #endif #ifdef HAS_CLEARCOATROUGHNESSMAP uniform sampler2D pbr_clearcoatRoughnessSampler; #endif #ifdef HAS_CLEARCOATNORMALMAP uniform sampler2D pbr_clearcoatNormalSampler; #endif #ifdef HAS_SHEENCOLORMAP uniform sampler2D pbr_sheenColorSampler; #endif #ifdef HAS_SHEENROUGHNESSMAP uniform sampler2D pbr_sheenRoughnessSampler; #endif #ifdef HAS_IRIDESCENCEMAP uniform sampler2D pbr_iridescenceSampler; #endif #ifdef HAS_IRIDESCENCETHICKNESSMAP uniform sampler2D pbr_iridescenceThicknessSampler; #endif #ifdef HAS_ANISOTROPYMAP uniform sampler2D pbr_anisotropySampler; #endif // Inputs from vertex shader in vec3 pbr_vPosition; in vec2 pbr_vUV0; in vec2 pbr_vUV1; #ifdef HAS_NORMALS #ifdef HAS_TANGENTS in mat3 pbr_vTBN; #else in vec3 pbr_vNormal; #endif #endif // Encapsulate the various inputs used by the various functions in the shading equation // We store values in this struct to simplify the integration of alternative implementations // of the shading terms, outlined in the Readme.MD Appendix. struct PBRInfo { float NdotL; // cos angle between normal and light direction float NdotV; // cos angle between normal and view direction float NdotH; // cos angle between normal and half vector float LdotH; // cos angle between light direction and half vector float VdotH; // cos angle between view direction and half vector float perceptualRoughness; // roughness value, as authored by the model creator (input to shader) float metalness; // metallic value at the surface vec3 reflectance0; // full reflectance color (normal incidence angle) vec3 reflectance90; // reflectance color at grazing angle float alphaRoughness; // roughness mapped to a more linear change in the roughness (proposed by [2]) vec3 diffuseColor; // color contribution from diffuse lighting vec3 specularColor; // color contribution from specular lighting vec3 n; // normal at surface point vec3 v; // vector from surface point to camera }; const float M_PI = 3.141592653589793; const float c_MinRoughness = 0.04; vec3 calculateFinalColor(PBRInfo pbrInfo, vec3 lightColor); vec4 SRGBtoLINEAR(vec4 srgbIn) { #ifdef MANUAL_SRGB #ifdef SRGB_FAST_APPROXIMATION vec3 linOut = pow(srgbIn.xyz,vec3(2.2)); #else // SRGB_FAST_APPROXIMATION vec3 bLess = step(vec3(0.04045),srgbIn.xyz); vec3 linOut = mix( srgbIn.xyz/vec3(12.92), pow((srgbIn.xyz+vec3(0.055))/vec3(1.055),vec3(2.4)), bLess ); #endif //SRGB_FAST_APPROXIMATION return vec4(linOut,srgbIn.w);; #else //MANUAL_SRGB return srgbIn; #endif //MANUAL_SRGB } vec2 getMaterialUV(int uvSet, mat3 uvTransform) { vec2 baseUV = uvSet == 1 ? pbr_vUV1 : pbr_vUV0; return (uvTransform * vec3(baseUV, 1.0)).xy; } // Build the tangent basis from interpolated attributes or screen-space derivatives. mat3 getTBN(vec2 uv) { #ifndef HAS_TANGENTS vec3 pos_dx = dFdx(pbr_vPosition); vec3 pos_dy = dFdy(pbr_vPosition); vec3 tex_dx = dFdx(vec3(uv, 0.0)); vec3 tex_dy = dFdy(vec3(uv, 0.0)); vec3 t = (tex_dy.t * pos_dx - tex_dx.t * pos_dy) / (tex_dx.s * tex_dy.t - tex_dy.s * tex_dx.t); #ifdef HAS_NORMALS vec3 ng = normalize(pbr_vNormal); #else vec3 ng = cross(pos_dx, pos_dy); #endif t = normalize(t - ng * dot(ng, t)); vec3 b = normalize(cross(ng, t)); mat3 tbn = mat3(t, b, ng); #else // HAS_TANGENTS mat3 tbn = pbr_vTBN; #endif return tbn; } // Find the normal for this fragment, pulling either from a predefined normal map // or from the interpolated mesh normal and tangent attributes. vec3 getMappedNormal(sampler2D normalSampler, mat3 tbn, float normalScale, vec2 uv) { vec3 n = texture(normalSampler, uv).rgb; return normalize(tbn * ((2.0 * n - 1.0) * vec3(normalScale, normalScale, 1.0))); } vec3 getNormal(mat3 tbn, vec2 uv) { #ifdef HAS_NORMALMAP vec3 n = getMappedNormal(pbr_normalSampler, tbn, pbrMaterial.normalScale, uv); #else // The tbn matrix is linearly interpolated, so we need to re-normalize vec3 n = normalize(tbn[2].xyz); #endif return n; } vec3 getClearcoatNormal(mat3 tbn, vec3 baseNormal, vec2 uv) { #ifdef HAS_CLEARCOATNORMALMAP return getMappedNormal(pbr_clearcoatNormalSampler, tbn, 1.0, uv); #else return baseNormal; #endif } // Calculation of the lighting contribution from an optional Image Based Light source. // Precomputed Environment Maps are required uniform inputs and are computed as outlined in [1]. // See our README.md on Environment Maps [3] for additional discussion. #ifdef USE_IBL vec3 getIBLContribution(PBRInfo pbrInfo, vec3 n, vec3 reflection) { float mipCount = 9.0; // resolution of 512x512 float lod = (pbrInfo.perceptualRoughness * mipCount); // retrieve a scale and bias to F0. See [1], Figure 3 vec3 brdf = SRGBtoLINEAR(texture(pbr_brdfLUT, vec2(pbrInfo.NdotV, 1.0 - pbrInfo.perceptualRoughness))).rgb; vec3 diffuseLight = SRGBtoLINEAR(texture(pbr_diffuseEnvSampler, n)).rgb; #ifdef USE_TEX_LOD vec3 specularLight = SRGBtoLINEAR(texture(pbr_specularEnvSampler, reflection, lod)).rgb; #else vec3 specularLight = SRGBtoLINEAR(texture(pbr_specularEnvSampler, reflection)).rgb; #endif vec3 diffuse = diffuseLight * pbrInfo.diffuseColor; vec3 specular = specularLight * (pbrInfo.specularColor * brdf.x + brdf.y); // For presentation, this allows us to disable IBL terms diffuse *= pbrMaterial.scaleIBLAmbient.x; specular *= pbrMaterial.scaleIBLAmbient.y; return diffuse + specular; } #endif // Basic Lambertian diffuse // Implementation from Lambert's Photometria https://archive.org/details/lambertsphotome00lambgoog // See also [1], Equation 1 vec3 diffuse(PBRInfo pbrInfo) { return pbrInfo.diffuseColor / M_PI; } // The following equation models the Fresnel reflectance term of the spec equation (aka F()) // Implementation of fresnel from [4], Equation 15 vec3 specularReflection(PBRInfo pbrInfo) { return pbrInfo.reflectance0 + (pbrInfo.reflectance90 - pbrInfo.reflectance0) * pow(clamp(1.0 - pbrInfo.VdotH, 0.0, 1.0), 5.0); } // This calculates the specular geometric attenuation (aka G()), // where rougher material will reflect less light back to the viewer. // This implementation is based on [1] Equation 4, and we adopt their modifications to // alphaRoughness as input as originally proposed in [2]. float geometricOcclusion(PBRInfo pbrInfo) { float NdotL = pbrInfo.NdotL; float NdotV = pbrInfo.NdotV; float r = pbrInfo.alphaRoughness; float attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL))); float attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV))); return attenuationL * attenuationV; } // The following equation(s) model the distribution of microfacet normals across // the area being drawn (aka D()) // Implementation from "Average Irregularity Representation of a Roughened Surface // for Ray Reflection" by T. S. Trowbridge, and K. P. Reitz // Follows the distribution function recommended in the SIGGRAPH 2013 course notes // from EPIC Games [1], Equation 3. float microfacetDistribution(PBRInfo pbrInfo) { float roughnessSq = pbrInfo.alphaRoughness * pbrInfo.alphaRoughness; float f = (pbrInfo.NdotH * roughnessSq - pbrInfo.NdotH) * pbrInfo.NdotH + 1.0; return roughnessSq / (M_PI * f * f); } float maxComponent(vec3 value) { return max(max(value.r, value.g), value.b); } float getDielectricF0(float ior) { float clampedIor = max(ior, 1.0); float ratio = (clampedIor - 1.0) / (clampedIor + 1.0); return ratio * ratio; } vec2 normalizeDirection(vec2 direction) { float directionLength = length(direction); return directionLength > 0.0001 ? direction / directionLength : vec2(1.0, 0.0); } vec2 rotateDirection(vec2 direction, float rotation) { float s = sin(rotation); float c = cos(rotation); return vec2(direction.x * c - direction.y * s, direction.x * s + direction.y * c); } vec3 getIridescenceTint(float iridescence, float thickness, float NdotV) { if (iridescence <= 0.0) { return vec3(1.0); } float phase = 0.015 * thickness * pbrMaterial.iridescenceIor + (1.0 - NdotV) * 6.0; vec3 thinFilmTint = 0.5 + 0.5 * cos(vec3(phase, phase + 2.0943951, phase + 4.1887902)); return mix(vec3(1.0), thinFilmTint, iridescence); } vec3 getVolumeAttenuation(float thickness) { if (thickness <= 0.0) { return vec3(1.0); } vec3 attenuationCoefficient = -log(max(pbrMaterial.attenuationColor, vec3(0.0001))) / max(pbrMaterial.attenuationDistance, 0.0001); return exp(-attenuationCoefficient * thickness); } PBRInfo createClearcoatPBRInfo(PBRInfo basePBRInfo, vec3 clearcoatNormal, float clearcoatRoughness) { float perceptualRoughness = clamp(clearcoatRoughness, c_MinRoughness, 1.0); float alphaRoughness = perceptualRoughness * perceptualRoughness; float NdotV = clamp(abs(dot(clearcoatNormal, basePBRInfo.v)), 0.001, 1.0); return PBRInfo( basePBRInfo.NdotL, NdotV, basePBRInfo.NdotH, basePBRInfo.LdotH, basePBRInfo.VdotH, perceptualRoughness, 0.0, vec3(0.04), vec3(1.0), alphaRoughness, vec3(0.0), vec3(0.04), clearcoatNormal, basePBRInfo.v ); } vec3 calculateClearcoatContribution( PBRInfo pbrInfo, vec3 lightColor, vec3 clearcoatNormal, float clearcoatFactor, float clearcoatRoughness ) { if (clearcoatFactor <= 0.0) { return vec3(0.0); } PBRInfo clearcoatPBRInfo = createClearcoatPBRInfo(pbrInfo, clearcoatNormal, clearcoatRoughness); return calculateFinalColor(clearcoatPBRInfo, lightColor) * clearcoatFactor; } #ifdef USE_IBL vec3 calculateClearcoatIBLContribution( PBRInfo pbrInfo, vec3 clearcoatNormal, vec3 reflection, float clearcoatFactor, float clearcoatRoughness ) { if (clearcoatFactor <= 0.0) { return vec3(0.0); } PBRInfo clearcoatPBRInfo = createClearcoatPBRInfo(pbrInfo, clearcoatNormal, clearcoatRoughness); return getIBLContribution(clearcoatPBRInfo, clearcoatNormal, reflection) * clearcoatFactor; } #endif vec3 calculateSheenContribution( PBRInfo pbrInfo, vec3 lightColor, vec3 sheenColor, float sheenRoughness ) { if (maxComponent(sheenColor) <= 0.0) { return vec3(0.0); } float sheenFresnel = pow(clamp(1.0 - pbrInfo.VdotH, 0.0, 1.0), 5.0); float sheenVisibility = mix(1.0, pbrInfo.NdotL * pbrInfo.NdotV, sheenRoughness); return pbrInfo.NdotL * lightColor * sheenColor * (0.25 + 0.75 * sheenFresnel) * sheenVisibility * (1.0 - pbrInfo.metalness); } float calculateAnisotropyBoost( PBRInfo pbrInfo, vec3 anisotropyTangent, float anisotropyStrength ) { if (anisotropyStrength <= 0.0) { return 1.0; } vec3 anisotropyBitangent = normalize(cross(pbrInfo.n, anisotropyTangent)); float bitangentViewAlignment = abs(dot(pbrInfo.v, anisotropyBitangent)); return mix(1.0, 0.65 + 0.7 * bitangentViewAlignment, anisotropyStrength); } vec3 calculateMaterialLightColor( PBRInfo pbrInfo, vec3 lightColor, vec3 clearcoatNormal, float clearcoatFactor, float clearcoatRoughness, vec3 sheenColor, float sheenRoughness, vec3 anisotropyTangent, float anisotropyStrength ) { float anisotropyBoost = calculateAnisotropyBoost(pbrInfo, anisotropyTangent, anisotropyStrength); vec3 color = calculateFinalColor(pbrInfo, lightColor) * anisotropyBoost; color += calculateClearcoatContribution( pbrInfo, lightColor, clearcoatNormal, clearcoatFactor, clearcoatRoughness ); color += calculateSheenContribution(pbrInfo, lightColor, sheenColor, sheenRoughness); return color; } void PBRInfo_setAmbientLight(inout PBRInfo pbrInfo) { pbrInfo.NdotL = 1.0; pbrInfo.NdotH = 0.0; pbrInfo.LdotH = 0.0; pbrInfo.VdotH = 1.0; } void PBRInfo_setDirectionalLight(inout PBRInfo pbrInfo, vec3 lightDirection) { vec3 n = pbrInfo.n; vec3 v = pbrInfo.v; vec3 l = normalize(lightDirection); // Vector from surface point to light vec3 h = normalize(l+v); // Half vector between both l and v pbrInfo.NdotL = clamp(dot(n, l), 0.001, 1.0); pbrInfo.NdotH = clamp(dot(n, h), 0.0, 1.0); pbrInfo.LdotH = clamp(dot(l, h), 0.0, 1.0); pbrInfo.VdotH = clamp(dot(v, h), 0.0, 1.0); } void PBRInfo_setPointLight(inout PBRInfo pbrInfo, PointLight pointLight) { vec3 light_direction = normalize(pointLight.position - pbr_vPosition); PBRInfo_setDirectionalLight(pbrInfo, light_direction); } void PBRInfo_setSpotLight(inout PBRInfo pbrInfo, SpotLight spotLight) { vec3 light_direction = normalize(spotLight.position - pbr_vPosition); PBRInfo_setDirectionalLight(pbrInfo, light_direction); } vec3 calculateFinalColor(PBRInfo pbrInfo, vec3 lightColor) { // Calculate the shading terms for the microfacet specular shading model vec3 F = specularReflection(pbrInfo); float G = geometricOcclusion(pbrInfo); float D = microfacetDistribution(pbrInfo); // Calculation of analytical lighting contribution vec3 diffuseContrib = (1.0 - F) * diffuse(pbrInfo); vec3 specContrib = F * G * D / (4.0 * pbrInfo.NdotL * pbrInfo.NdotV); // Obtain final intensity as reflectance (BRDF) scaled by the energy of the light (cosine law) return pbrInfo.NdotL * lightColor * (diffuseContrib + specContrib); } vec4 pbr_filterColor(vec4 colorUnused) { vec2 baseColorUV = getMaterialUV(pbrMaterial.baseColorUVSet, pbrMaterial.baseColorUVTransform); vec2 metallicRoughnessUV = getMaterialUV( pbrMaterial.metallicRoughnessUVSet, pbrMaterial.metallicRoughnessUVTransform ); vec2 normalUV = getMaterialUV(pbrMaterial.normalUVSet, pbrMaterial.normalUVTransform); vec2 occlusionUV = getMaterialUV(pbrMaterial.occlusionUVSet, pbrMaterial.occlusionUVTransform); vec2 emissiveUV = getMaterialUV(pbrMaterial.emissiveUVSet, pbrMaterial.emissiveUVTransform); vec2 specularColorUV = getMaterialUV( pbrMaterial.specularColorUVSet, pbrMaterial.specularColorUVTransform ); vec2 specularIntensityUV = getMaterialUV( pbrMaterial.specularIntensityUVSet, pbrMaterial.specularIntensityUVTransform ); vec2 transmissionUV = getMaterialUV( pbrMaterial.transmissionUVSet, pbrMaterial.transmissionUVTransform ); vec2 thicknessUV = getMaterialUV(pbrMaterial.thicknessUVSet, pbrMaterial.thicknessUVTransform); vec2 clearcoatUV = getMaterialUV(pbrMaterial.clearcoatUVSet, pbrMaterial.clearcoatUVTransform); vec2 clearcoatRoughnessUV = getMaterialUV( pbrMaterial.clearcoatRoughnessUVSet, pbrMaterial.clearcoatRoughnessUVTransform ); vec2 clearcoatNormalUV = getMaterialUV( pbrMaterial.clearcoatNormalUVSet, pbrMaterial.clearcoatNormalUVTransform ); vec2 sheenColorUV = getMaterialUV( pbrMaterial.sheenColorUVSet, pbrMaterial.sheenColorUVTransform ); vec2 sheenRoughnessUV = getMaterialUV( pbrMaterial.sheenRoughnessUVSet, pbrMaterial.sheenRoughnessUVTransform ); vec2 iridescenceUV = getMaterialUV( pbrMaterial.iridescenceUVSet, pbrMaterial.iridescenceUVTransform ); vec2 iridescenceThicknessUV = getMaterialUV( pbrMaterial.iridescenceThicknessUVSet, pbrMaterial.iridescenceThicknessUVTransform ); vec2 anisotropyUV = getMaterialUV( pbrMaterial.anisotropyUVSet, pbrMaterial.anisotropyUVTransform ); // The albedo may be defined from a base texture or a flat color #ifdef HAS_BASECOLORMAP vec4 baseColor = SRGBtoLINEAR(texture(pbr_baseColorSampler, baseColorUV)) * pbrMaterial.baseColorFactor; #else vec4 baseColor = pbrMaterial.baseColorFactor; #endif #ifdef ALPHA_CUTOFF if (baseColor.a < pbrMaterial.alphaCutoff) { discard; } #endif vec3 color = vec3(0, 0, 0); float transmission = 0.0; if(pbrMaterial.unlit){ color.rgb = baseColor.rgb; } else{ // Metallic and Roughness material properties are packed together // In glTF, these factors can be specified by fixed scalar values // or from a metallic-roughness map float perceptualRoughness = pbrMaterial.metallicRoughnessValues.y; float metallic = pbrMaterial.metallicRoughnessValues.x; #ifdef HAS_METALROUGHNESSMAP // Roughness is stored in the 'g' channel, metallic is stored in the 'b' channel. // This layout intentionally reserves the 'r' channel for (optional) occlusion map data vec4 mrSample = texture(pbr_metallicRoughnessSampler, metallicRoughnessUV); perceptualRoughness = mrSample.g * perceptualRoughness; metallic = mrSample.b * metallic; #endif perceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0); metallic = clamp(metallic, 0.0, 1.0); mat3 tbn = getTBN(normalUV); vec3 n = getNormal(tbn, normalUV); // normal at surface point vec3 v = normalize(pbrProjection.camera - pbr_vPosition); // Vector from surface point to camera float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0); #ifdef USE_MATERIAL_EXTENSIONS bool useExtendedPBR = pbrMaterial.specularColorMapEnabled || pbrMaterial.specularIntensityMapEnabled || abs(pbrMaterial.specularIntensityFactor - 1.0) > 0.0001 || maxComponent(abs(pbrMaterial.specularColorFactor - vec3(1.0))) > 0.0001 || abs(pbrMaterial.ior - 1.5) > 0.0001 || pbrMaterial.transmissionMapEnabled || pbrMaterial.transmissionFactor > 0.0001 || pbrMaterial.clearcoatMapEnabled || pbrMaterial.clearcoatRoughnessMapEnabled || pbrMaterial.clearcoatFactor > 0.0001 || pbrMaterial.clearcoatRoughnessFactor > 0.0001 || pbrMaterial.sheenColorMapEnabled || pbrMaterial.sheenRoughnessMapEnabled || maxComponent(pbrMaterial.sheenColorFactor) > 0.0001 || pbrMaterial.sheenRoughnessFactor > 0.0001 || pbrMaterial.iridescenceMapEnabled || pbrMaterial.iridescenceFactor > 0.0001 || abs(pbrMaterial.iridescenceIor - 1.3) > 0.0001 || abs(pbrMaterial.iridescenceThicknessRange.x - 100.0) > 0.0001 || abs(pbrMaterial.iridescenceThicknessRange.y - 400.0) > 0.0001 || pbrMaterial.anisotropyMapEnabled || pbrMaterial.anisotropyStrength > 0.0001 || abs(pbrMaterial.anisotropyRotation) > 0.0001 || length(pbrMaterial.anisotropyDirection - vec2(1.0, 0.0)) > 0.0001; #else bool useExtendedPBR = false; #endif if (!useExtendedPBR) { // Keep the baseline metallic-roughness implementation byte-for-byte equivalent in behavior. float alphaRoughness = perceptualRoughness * perceptualRoughness; vec3 f0 = vec3(0.04); vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - f0); diffuseColor *= 1.0 - metallic; vec3 specularColor = mix(f0, baseColor.rgb, metallic); float reflectance = max(max(specularColor.r, specularColor.g), specularColor.b); float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0); vec3 specularEnvironmentR0 = specularColor.rgb; vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90; vec3 reflection = -normalize(reflect(v, n)); PBRInfo pbrInfo = PBRInfo( 0.0, // NdotL NdotV, 0.0, // NdotH 0.0, // LdotH 0.0, // VdotH perceptualRoughness, metallic, specularEnvironmentR0, specularEnvironmentR90, alphaRoughness, diffuseColor, specularColor, n, v ); #ifdef USE_LIGHTS PBRInfo_setAmbientLight(pbrInfo); color += calculateFinalColor(pbrInfo, lighting.ambientColor); for(int i = 0; i < lighting.directionalLightCount; i++) { if (i < lighting.directionalLightCount) { PBRInfo_setDirectionalLight(pbrInfo, lighting_getDirectionalLight(i).direction); color += calculateFinalColor(pbrInfo, lighting_getDirectionalLight(i).color); } } for(int i = 0; i < lighting.pointLightCount; i++) { if (i < lighting.pointLightCount) { PBRInfo_setPointLight(pbrInfo, lighting_getPointLight(i)); float attenuation = getPointLightAttenuation(lighting_getPointLight(i), distance(lighting_getPointLight(i).position, pbr_vPosition)); color += calculateFinalColor(pbrInfo, lighting_getPointLight(i).color / attenuation); } } for(int i = 0; i < lighting.spotLightCount; i++) { if (i < lighting.spotLightCount) { PBRInfo_setSpotLight(pbrInfo, lighting_getSpotLight(i)); float attenuation = getSpotLightAttenuation(lighting_getSpotLight(i), pbr_vPosition); color += calculateFinalColor(pbrInfo, lighting_getSpotLight(i).color / attenuation); } } #endif #ifdef USE_IBL if (pbrMaterial.IBLenabled) { color += getIBLContribution(pbrInfo, n, reflection); } #endif #ifdef HAS_OCCLUSIONMAP if (pbrMaterial.occlusionMapEnabled) { float ao = texture(pbr_occlusionSampler, occlusionUV).r; color = mix(color, color * ao, pbrMaterial.occlusionStrength); } #endif vec3 emissive = pbrMaterial.emissiveFactor; #ifdef HAS_EMISSIVEMAP if (pbrMaterial.emissiveMapEnabled) { emissive *= SRGBtoLINEAR(texture(pbr_emissiveSampler, emissiveUV)).rgb; } #endif color += emissive * pbrMaterial.emissiveStrength; #ifdef PBR_DEBUG color = mix(color, baseColor.rgb, pbrMaterial.scaleDiffBaseMR.y); color = mix(color, vec3(metallic), pbrMaterial.scaleDiffBaseMR.z); color = mix(color, vec3(perceptualRoughness), pbrMaterial.scaleDiffBaseMR.w); #endif return vec4(pow(color, vec3(1.0 / 2.2)), baseColor.a); } float specularIntensity = pbrMaterial.specularIntensityFactor; #ifdef HAS_SPECULARINTENSITYMAP if (pbrMaterial.specularIntensityMapEnabled) { specularIntensity *= texture(pbr_specularIntensitySampler, specularIntensityUV).a; } #endif vec3 specularFactor = pbrMaterial.specularColorFactor; #ifdef HAS_SPECULARCOLORMAP if (pbrMaterial.specularColorMapEnabled) { specularFactor *= SRGBtoLINEAR(texture(pbr_specularColorSampler, specularColorUV)).rgb; } #endif transmission = pbrMaterial.transmissionFactor; #ifdef HAS_TRANSMISSIONMAP if (pbrMaterial.transmissionMapEnabled) { transmission *= texture(pbr_transmissionSampler, transmissionUV).r; } #endif transmission = clamp(transmission * (1.0 - metallic), 0.0, 1.0); float thickness = max(pbrMaterial.thicknessFactor, 0.0); #ifdef HAS_THICKNESSMAP thickness *= texture(pbr_thicknessSampler, thicknessUV).g; #endif float clearcoatFactor = pbrMaterial.clearcoatFactor; float clearcoatRoughness = pbrMaterial.clearcoatRoughnessFactor; #ifdef HAS_CLEARCOATMAP if (pbrMaterial.clearcoatMapEnabled) { clearcoatFactor *= texture(pbr_clearcoatSampler, clearcoatUV).r; } #endif #ifdef HAS_CLEARCOATROUGHNESSMAP if (pbrMaterial.clearcoatRoughnessMapEnabled) { clearcoatRoughness *= texture(pbr_clearcoatRoughnessSampler, clearcoatRoughnessUV).g; } #endif clearcoatFactor = clamp(clearcoatFactor, 0.0, 1.0); clearcoatRoughness = clamp(clearcoatRoughness, c_MinRoughness, 1.0); vec3 clearcoatNormal = getClearcoatNormal(getTBN(clearcoatNormalUV), n, clearcoatNormalUV); vec3 sheenColor = pbrMaterial.sheenColorFactor; float sheenRoughness = pbrMaterial.sheenRoughnessFactor; #ifdef HAS_SHEENCOLORMAP if (pbrMaterial.sheenColorMapEnabled) { sheenColor *= SRGBtoLINEAR(texture(pbr_sheenColorSampler, sheenColorUV)).rgb; } #endif #ifdef HAS_SHEENROUGHNESSMAP if (pbrMaterial.sheenRoughnessMapEnabled) { sheenRoughness *= texture(pbr_sheenRoughnessSampler, sheenRoughnessUV).a; } #endif sheenRoughness = clamp(sheenRoughness, c_MinRoughness, 1.0); float iridescence = pbrMaterial.iridescenceFactor; #ifdef HAS_IRIDESCENCEMAP if (pbrMaterial.iridescenceMapEnabled) { iridescence *= texture(pbr_iridescenceSampler, iridescenceUV).r; } #endif iridescence = clamp(iridescence, 0.0, 1.0); float iridescenceThickness = mix( pbrMaterial.iridescenceThicknessRange.x, pbrMaterial.iridescenceThicknessRange.y, 0.5 ); #ifdef HAS_IRIDESCENCETHICKNESSMAP iridescenceThickness = mix( pbrMaterial.iridescenceThicknessRange.x, pbrMaterial.iridescenceThicknessRange.y, texture(pbr_iridescenceThicknessSampler, iridescenceThicknessUV).g ); #endif float anisotropyStrength = clamp(pbrMaterial.anisotropyStrength, 0.0, 1.0); vec2 anisotropyDirection = normalizeDirection(pbrMaterial.anisotropyDirection); #ifdef HAS_ANISOTROPYMAP if (pbrMaterial.anisotropyMapEnabled) { vec3 anisotropySample = texture(pbr_anisotropySampler, anisotropyUV).rgb; anisotropyStrength *= anisotropySample.b; vec2 mappedDirection = anisotropySample.rg * 2.0 - 1.0; if (length(mappedDirection) > 0.0001) { anisotropyDirection = normalize(mappedDirection); } } #endif anisotropyDirection = rotateDirection(anisotropyDirection, pbrMaterial.anisotropyRotation); vec3 anisotropyTangent = normalize(tbn[0] * anisotropyDirection.x + tbn[1] * anisotropyDirection.y); if (length(anisotropyTangent) < 0.0001) { anisotropyTangent = normalize(tbn[0]); } float anisotropyViewAlignment = abs(dot(v, anisotropyTangent)); perceptualRoughness = mix( perceptualRoughness, clamp(perceptualRoughness * (1.0 - 0.6 * anisotropyViewAlignment), c_MinRoughness, 1.0), anisotropyStrength ); // Roughness is authored as perceptual roughness; as is convention, // convert to material roughness by squaring the perceptual roughness [2]. float alphaRoughness = perceptualRoughness * perceptualRoughness; float dielectricF0 = getDielectricF0(pbrMaterial.ior); vec3 dielectricSpecularF0 = min( vec3(dielectricF0) * specularFactor * specularIntensity, vec3(1.0) ); vec3 iridescenceTint = getIridescenceTint(iridescence, iridescenceThickness, NdotV); dielectricSpecularF0 = mix( dielectricSpecularF0, dielectricSpecularF0 * iridescenceTint, iridescence ); vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - dielectricSpecularF0); diffuseColor *= (1.0 - metallic) * (1.0 - transmission); vec3 specularColor = mix(dielectricSpecularF0, baseColor.rgb, metallic); float baseLayerEnergy = 1.0 - clearcoatFactor * 0.25; diffuseColor *= baseLayerEnergy; specularColor *= baseLayerEnergy; // Compute reflectance. float reflectance = max(max(specularColor.r, specularColor.g), specularColor.b); // For typical incident reflectance range (between 4% to 100%) set the grazing // reflectance to 100% for typical fresnel effect. // For very low reflectance range on highly diffuse objects (below 4%), // incrementally reduce grazing reflecance to 0%. float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0); vec3 specularEnvironmentR0 = specularColor.rgb; vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90; vec3 reflection = -normalize(reflect(v, n)); PBRInfo pbrInfo = PBRInfo( 0.0, // NdotL NdotV, 0.0, // NdotH 0.0, // LdotH 0.0, // VdotH perceptualRoughness, metallic, specularEnvironmentR0, specularEnvironmentR90, alphaRoughness, diffuseColor, specularColor, n, v ); #ifdef USE_LIGHTS // Apply ambient light PBRInfo_setAmbientLight(pbrInfo); color += calculateMaterialLightColor( pbrInfo, lighting.ambientColor, clearcoatNormal, clearcoatFactor, clearcoatRoughness, sheenColor, sheenRoughness, anisotropyTangent, anisotropyStrength ); // Apply directional light for(int i = 0; i < lighting.directionalLightCount; i++) { if (i < lighting.directionalLightCount) { PBRInfo_setDirectionalLight(pbrInfo, lighting_getDirectionalLight(i).direction); color += calculateMaterialLightColor( pbrInfo, lighting_getDirectionalLight(i).color, clearcoatNormal, clearcoatFactor, clearcoatRoughness, sheenColor, sheenRoughness, anisotropyTangent, anisotropyStrength ); } } // Apply point light for(int i = 0; i < lighting.pointLightCount; i++) { if (i < lighting.pointLightCount) { PBRInfo_setPointLight(pbrInfo, lighting_getPointLight(i)); float attenuation = getPointLightAttenuation(lighting_getPointLight(i), distance(lighting_getPointLight(i).position, pbr_vPosition)); color += calculateMaterialLightColor( pbrInfo, lighting_getPointLight(i).color / attenuation, clearcoatNormal, clearcoatFactor, clearcoatRoughness, sheenColor, sheenRoughness, anisotropyTangent, anisotropyStrength ); } } for(int i = 0; i < lighting.spotLightCount; i++) { if (i < lighting.spotLightCount) { PBRInfo_setSpotLight(pbrInfo, lighting_getSpotLight(i)); float attenuation = getSpotLightAttenuation(lighting_getSpotLight(i), pbr_vPosition); color += calculateMaterialLightColor( pbrInfo, lighting_getSpotLight(i).color / attenuation, clearcoatNormal, clearcoatFactor, clearcoatRoughness, sheenColor, sheenRoughness, anisotropyTangent, anisotropyStrength ); } } #endif // Calculate lighting contribution from image based lighting source (IBL) #ifdef USE_IBL if (pbrMaterial.IBLenabled) { color += getIBLContribution(pbrInfo, n, reflection) * calculateAnisotropyBoost(pbrInfo, anisotropyTangent, anisotropyStrength); color += calculateClearcoatIBLContribution( pbrInfo, clearcoatNormal, -normalize(reflect(v, clearcoatNormal)), clearcoatFactor, clearcoatRoughness ); color += sheenColor * pbrMaterial.scaleIBLAmbient.x * (1.0 - sheenRoughness) * 0.25; } #endif // Apply optional PBR terms for additional (optional) shading #ifdef HAS_OCCLUSIONMAP if (pbrMaterial.occlusionMapEnabled) { float ao = texture(pbr_occlusionSampler, occlusionUV).r; color = mix(color, color * ao, pbrMaterial.occlusionStrength); } #endif vec3 emissive = pbrMaterial.emissiveFactor; #ifdef HAS_EMISSIVEMAP if (pbrMaterial.emissiveMapEnabled) { emissive *= SRGBtoLINEAR(texture(pbr_emissiveSampler, emissiveUV)).rgb; } #endif color += emissive * pbrMaterial.emissiveStrength; if (transmission > 0.0) { color = mix(color, color * getVolumeAttenuation(thickness), transmission); } // This section uses mix to override final color for reference app visualization // of various parameters in the lighting equation. #ifdef PBR_DEBUG // TODO: Figure out how to debug multiple lights // color = mix(color, F, pbr_scaleFGDSpec.x); // color = mix(color, vec3(G), pbr_scaleFGDSpec.y); // color = mix(color, vec3(D), pbr_scaleFGDSpec.z); // color = mix(color, specContrib, pbr_scaleFGDSpec.w); // color = mix(color, diffuseContrib, pbr_scaleDiffBaseMR.x); color = mix(color, baseColor.rgb, pbrMaterial.scaleDiffBaseMR.y); color = mix(color, vec3(metallic), pbrMaterial.scaleDiffBaseMR.z); color = mix(color, vec3(perceptualRoughness), pbrMaterial.scaleDiffBaseMR.w); #endif } float alpha = clamp(baseColor.a * (1.0 - transmission), 0.0, 1.0); return vec4(pow(color,vec3(1.0/2.2)), alpha); } `;var hI=`struct PBRFragmentInputs { pbr_vPosition: vec3f, pbr_vUV0: vec2f, pbr_vUV1: vec2f, pbr_vTBN: mat3x3f, pbr_vNormal: vec3f }; var<private> fragmentInputs: PBRFragmentInputs; fn pbr_setPositionNormalTangentUV( position: vec4f, normal: vec4f, tangent: vec4f, uv0: vec2f, uv1: vec2f ) { var pos: vec4f = pbrProjection.modelMatrix * position; fragmentInputs.pbr_vPosition = pos.xyz / pos.w; fragmentInputs.pbr_vNormal = vec3f(0.0, 0.0, 1.0); fragmentInputs.pbr_vTBN = mat3x3f( vec3f(1.0, 0.0, 0.0), vec3f(0.0, 1.0, 0.0), vec3f(0.0, 0.0, 1.0) ); fragmentInputs.pbr_vUV0 = vec2f(0.0, 0.0); fragmentInputs.pbr_vUV1 = uv1; #ifdef HAS_NORMALS let normalW: vec3f = normalize((pbrProjection.normalMatrix * vec4f(normal.xyz, 0.0)).xyz); fragmentInputs.pbr_vNormal = normalW; #ifdef HAS_TANGENTS let tangentW: vec3f = normalize((pbrProjection.modelMatrix * vec4f(tangent.xyz, 0.0)).xyz); let bitangentW: vec3f = cross(normalW, tangentW) * tangent.w; fragmentInputs.pbr_vTBN = mat3x3f(tangentW, bitangentW, normalW); #endif #endif #ifdef HAS_UV fragmentInputs.pbr_vUV0 = uv0; #endif } struct pbrMaterialUniforms { // Material is unlit unlit: u32, // Base color map baseColorMapEnabled: u32, baseColorFactor: vec4f, normalMapEnabled : u32, normalScale: f32, // #ifdef HAS_NORMALMAP emissiveMapEnabled: u32, emissiveFactor: vec3f, // #ifdef HAS_EMISSIVEMAP metallicRoughnessValues: vec2f, metallicRoughnessMapEnabled: u32, occlusionMapEnabled: i32, occlusionStrength: f32, // #ifdef HAS_OCCLUSIONMAP alphaCutoffEnabled: i32, alphaCutoff: f32, // #ifdef ALPHA_CUTOFF specularColorFactor: vec3f, specularIntensityFactor: f32, specularColorMapEnabled: i32, specularIntensityMapEnabled: i32, ior: f32, transmissionFactor: f32, transmissionMapEnabled: i32, thicknessFactor: f32, attenuationDistance: f32, attenuationColor: vec3f, clearcoatFactor: f32, clearcoatRoughnessFactor: f32, clearcoatMapEnabled: i32, clearcoatRoughnessMapEnabled: i32, sheenColorFactor: vec3f, sheenRoughnessFactor: f32, sheenColorMapEnabled: i32, sheenRoughnessMapEnabled: i32, iridescenceFactor: f32, iridescenceIor: f32, iridescenceThicknessRange: vec2f, iridescenceMapEnabled: i32, anisotropyStrength: f32, anisotropyRotation: f32, anisotropyDirection: vec2f, anisotropyMapEnabled: i32, emissiveStrength: f32, // IBL IBLenabled: i32, scaleIBLAmbient: vec2f, // #ifdef USE_IBL // debugging flags used for shader output of intermediate PBR variables // #ifdef PBR_DEBUG scaleDiffBaseMR: vec4f, scaleFGDSpec: vec4f, // #endif baseColorUVSet: i32, baseColorUVTransform: mat3x3f, metallicRoughnessUVSet: i32, metallicRoughnessUVTransform: mat3x3f, normalUVSet: i32, normalUVTransform: mat3x3f, occlusionUVSet: i32, occlusionUVTransform: mat3x3f, emissiveUVSet: i32, emissiveUVTransform: mat3x3f, specularColorUVSet: i32, specularColorUVTransform: mat3x3f, specularIntensityUVSet: i32, specularIntensityUVTransform: mat3x3f, transmissionUVSet: i32, transmissionUVTransform: mat3x3f, thicknessUVSet: i32, thicknessUVTransform: mat3x3f, clearcoatUVSet: i32, clearcoatUVTransform: mat3x3f, clearcoatRoughnessUVSet: i32, clearcoatRoughnessUVTransform: mat3x3f, clearcoatNormalUVSet: i32, clearcoatNormalUVTransform: mat3x3f, sheenColorUVSet: i32, sheenColorUVTransform: mat3x3f, sheenRoughnessUVSet: i32, sheenRoughnessUVTransform: mat3x3f, iridescenceUVSet: i32, iridescenceUVTransform: mat3x3f, iridescenceThicknessUVSet: i32, iridescenceThicknessUVTransform: mat3x3f, anisotropyUVSet: i32, anisotropyUVTransform: mat3x3f, } @group(3) @binding(auto) var<uniform> pbrMaterial : pbrMaterialUniforms; // Samplers #ifdef HAS_BASECOLORMAP @group(3) @binding(auto) var pbr_baseColorSampler: texture_2d<f32>; @group(3) @binding(auto) var pbr_baseColorSamplerSampler: sampler; #endif #ifdef HAS_NORMALMAP @group(3) @binding(auto) var pbr_normalSampler: texture_2d<f32>; @group(3) @binding(auto) var pbr_normalSamplerSampler: sampler; #endif #ifdef HAS_EMISSIVEMAP @group(3) @binding(auto) var pbr_emissiveSampler: texture_2d<f32>; @group(3) @binding(auto) var pbr_emissiveSamplerSampler: sampler; #endif #ifdef HAS_METALROUGHNESSMAP @group(3) @binding(auto) var pbr_metallicRoughnessSampler: texture_2d<f32>; @group(3) @binding(auto) var pbr_metallicRoughnessSamplerSampler: sampler; #endif #ifdef HAS_OCCLUSIONMAP @group(3) @binding(auto) var pbr_occlusionSampler: texture_2d<f32>; @group(3) @binding(auto) var pbr_occlusionSamplerSampler: sampler; #endif #ifdef HAS_SPECULARCOLORMAP @group(3) @binding(auto) var pbr_specularColorSampler: texture_2d<f32>; @group(3) @binding(auto) var pbr_specularColorSamplerSampler: sampler; #endif #ifdef HAS_SPECULARINTENSITYMAP @group(3) @binding(auto) var pbr_specularIntensitySampler: texture_2d<f32>; @group(3) @binding(auto) var pbr_specularIntensitySamplerSampler: sampler; #endif #ifdef HAS_TRANSMISSIONMAP @group(3) @binding(auto) var pbr_transmissionSampler: texture_2d<f32>; @group(3) @binding(auto) var pbr_transmissionSamplerSampler: sampler; #endif #ifdef HAS_THICKNESSMAP @group(3) @binding(auto) var pbr_thicknessSampler: texture_2d<f32>; @group(3) @binding(auto) var pbr_thicknessSamplerSampler: sampler; #endif #ifdef HAS_CLEARCOATMAP @group(3) @binding(auto) var pbr_clearcoatSampler: texture_2d<f32>; @group(3) @binding(auto) var pbr_clearcoatSamplerSampler: sampler; #endif #ifdef HAS_CLEARCOATROUGHNESSMAP @group(3) @binding(auto) var pbr_clearcoatRoughnessSampler: texture_2d<f32>; @group(3) @binding(auto) var pbr_clearcoatRoughnessSamplerSampler: sampler; #endif #ifdef HAS_CLEARCOATNORMALMAP @group(3) @binding(auto) var pbr_clearcoatNormalSampler: texture_2d<f32>; @group(3) @binding(auto) var pbr_clearcoatNormalSamplerSampler: sampler; #endif #ifdef HAS_SHEENCOLORMAP @group(3) @binding(auto) var pbr_sheenColorSampler: texture_2d<f32>; @group(3) @binding(auto) var pbr_sheenColorSamplerSampler: sampler; #endif #ifdef HAS_SHEENROUGHNESSMAP @group(3) @binding(auto) var pbr_sheenRoughnessSampler: texture_2d<f32>; @group(3) @binding(auto) var pbr_sheenRoughnessSamplerSampler: sampler; #endif #ifdef HAS_IRIDESCENCEMAP @group(3) @binding(auto) var pbr_iridescenceSampler: texture_2d<f32>; @group(3) @binding(auto) var pbr_iridescenceSamplerSampler: sampler; #endif #ifdef HAS_IRIDESCENCETHICKNESSMAP @group(3) @binding(auto) var pbr_iridescenceThicknessSampler: texture_2d<f32>; @group(3) @binding(auto) var pbr_iridescenceThicknessSamplerSampler: sampler; #endif #ifdef HAS_ANISOTROPYMAP @group(3) @binding(auto) var pbr_anisotropySampler: texture_2d<f32>; @group(3) @binding(auto) var pbr_anisotropySamplerSampler: sampler; #endif // Encapsulate the various inputs used by the various functions in the shading equation // We store values in this struct to simplify the integration of alternative implementations // of the shading terms, outlined in the Readme.MD Appendix. struct PBRInfo { NdotL: f32, // cos angle between normal and light direction NdotV: f32, // cos angle between normal and view direction NdotH: f32, // cos angle between normal and half vector LdotH: f32, // cos angle between light direction and half vector VdotH: f32, // cos angle between view direction and half vector perceptualRoughness: f32, // roughness value, as authored by the model creator (input to shader) metalness: f32, // metallic value at the surface reflectance0: vec3f, // full reflectance color (normal incidence angle) reflectance90: vec3f, // reflectance color at grazing angle alphaRoughness: f32, // roughness mapped to a more linear change in the roughness (proposed by [2]) diffuseColor: vec3f, // color contribution from diffuse lighting specularColor: vec3f, // color contribution from specular lighting n: vec3f, // normal at surface point v: vec3f, // vector from surface point to camera }; const M_PI = 3.141592653589793; const c_MinRoughness = 0.04; fn SRGBtoLINEAR(srgbIn: vec4f ) -> vec4f { var linOut: vec3f = srgbIn.xyz; #ifdef MANUAL_SRGB let bLess: vec3f = step(vec3f(0.04045), srgbIn.xyz); linOut = mix( srgbIn.xyz / vec3f(12.92), pow((srgbIn.xyz + vec3f(0.055)) / vec3f(1.055), vec3f(2.4)), bLess ); #ifdef SRGB_FAST_APPROXIMATION linOut = pow(srgbIn.xyz, vec3f(2.2)); #endif #endif return vec4f(linOut, srgbIn.w); } fn getMaterialUV(uvSet: i32, uvTransform: mat3x3f) -> vec2f { var baseUV = fragmentInputs.pbr_vUV0; if (uvSet == 1) { baseUV = fragmentInputs.pbr_vUV1; } return (uvTransform * vec3f(baseUV, 1.0)).xy; } // Build the tangent basis from interpolated attributes or screen-space derivatives. fn getTBN(uv: vec2f) -> mat3x3f { let pos_dx: vec3f = dpdx(fragmentInputs.pbr_vPosition); let pos_dy: vec3f = dpdy(fragmentInputs.pbr_vPosition); let tex_dx: vec3f = dpdx(vec3f(uv, 0.0)); let tex_dy: vec3f = dpdy(vec3f(uv, 0.0)); var t: vec3f = (tex_dy.y * pos_dx - tex_dx.y * pos_dy) / (tex_dx.x * tex_dy.y - tex_dy.x * tex_dx.y); var ng: vec3f = cross(pos_dx, pos_dy); #ifdef HAS_NORMALS ng = normalize(fragmentInputs.pbr_vNormal); #endif t = normalize(t - ng * dot(ng, t)); var b: vec3f = normalize(cross(ng, t)); var tbn: mat3x3f = mat3x3f(t, b, ng); #ifdef HAS_TANGENTS tbn = fragmentInputs.pbr_vTBN; #endif return tbn; } // Find the normal for this fragment, pulling either from a predefined normal map // or from the interpolated mesh normal and tangent attributes. fn getMappedNormal( normalSampler: texture_2d<f32>, normalSamplerBinding: sampler, tbn: mat3x3f, normalScale: f32, uv: vec2f ) -> vec3f { let n = textureSample(normalSampler, normalSamplerBinding, uv).rgb; return normalize(tbn * ((2.0 * n - 1.0) * vec3f(normalScale, normalScale, 1.0))); } fn getNormal(tbn: mat3x3f, uv: vec2f) -> vec3f { // The tbn matrix is linearly interpolated, so we need to re-normalize var n: vec3f = normalize(tbn[2].xyz); #ifdef HAS_NORMALMAP n = getMappedNormal( pbr_normalSampler, pbr_normalSamplerSampler, tbn, pbrMaterial.normalScale, uv ); #endif return n; } fn getClearcoatNormal(tbn: mat3x3f, baseNormal: vec3f, uv: vec2f) -> vec3f { #ifdef HAS_CLEARCOATNORMALMAP return getMappedNormal( pbr_clearcoatNormalSampler, pbr_clearcoatNormalSamplerSampler, tbn, 1.0, uv ); #else return baseNormal; #endif } // Calculation of the lighting contribution from an optional Image Based Light source. // Precomputed Environment Maps are required uniform inputs and are computed as outlined in [1]. // See our README.md on Environment Maps [3] for additional discussion. #ifdef USE_IBL fn getIBLContribution(pbrInfo: PBRInfo, n: vec3f, reflection: vec3f) -> vec3f { let mipCount: f32 = 9.0; // resolution of 512x512 let lod: f32 = pbrInfo.perceptualRoughness * mipCount; // retrieve a scale and bias to F0. See [1], Figure 3 let brdf = SRGBtoLINEAR( textureSampleLevel( pbr_brdfLUT, pbr_brdfLUTSampler, vec2f(pbrInfo.NdotV, 1.0 - pbrInfo.perceptualRoughness), 0.0 ) ).rgb; let diffuseLight = SRGBtoLINEAR( textureSampleLevel(pbr_diffuseEnvSampler, pbr_diffuseEnvSamplerSampler, n, 0.0) ).rgb; var specularLight = SRGBtoLINEAR( textureSampleLevel( pbr_specularEnvSampler, pbr_specularEnvSamplerSampler, reflection, 0.0 ) ).rgb; #ifdef USE_TEX_LOD specularLight = SRGBtoLINEAR( textureSampleLevel( pbr_specularEnvSampler, pbr_specularEnvSamplerSampler, reflection, lod ) ).rgb; #endif let diffuse = diffuseLight * pbrInfo.diffuseColor * pbrMaterial.scaleIBLAmbient.x; let specular = specularLight * (pbrInfo.specularColor * brdf.x + brdf.y) * pbrMaterial.scaleIBLAmbient.y; return diffuse + specular; } #endif // Basic Lambertian diffuse // Implementation from Lambert's Photometria https://archive.org/details/lambertsphotome00lambgoog // See also [1], Equation 1 fn diffuse(pbrInfo: PBRInfo) -> vec3<f32> { return pbrInfo.diffuseColor / M_PI; } // The following equation models the Fresnel reflectance term of the spec equation (aka F()) // Implementation of fresnel from [4], Equation 15 fn specularReflection(pbrInfo: PBRInfo) -> vec3<f32> { return pbrInfo.reflectance0 + (pbrInfo.reflectance90 - pbrInfo.reflectance0) * pow(clamp(1.0 - pbrInfo.VdotH, 0.0, 1.0), 5.0); } // This calculates the specular geometric attenuation (aka G()), // where rougher material will reflect less light back to the viewer. // This implementation is based on [1] Equation 4, and we adopt their modifications to // alphaRoughness as input as originally proposed in [2]. fn geometricOcclusion(pbrInfo: PBRInfo) -> f32 { let NdotL: f32 = pbrInfo.NdotL; let NdotV: f32 = pbrInfo.NdotV; let r: f32 = pbrInfo.alphaRoughness; let attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL))); let attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV))); return attenuationL * attenuationV; } // The following equation(s) model the distribution of microfacet normals across // the area being drawn (aka D()) // Implementation from "Average Irregularity Representation of a Roughened Surface // for Ray Reflection" by T. S. Trowbridge, and K. P. Reitz // Follows the distribution function recommended in the SIGGRAPH 2013 course notes // from EPIC Games [1], Equation 3. fn microfacetDistribution(pbrInfo: PBRInfo) -> f32 { let roughnessSq = pbrInfo.alphaRoughness * pbrInfo.alphaRoughness; let f = (pbrInfo.NdotH * roughnessSq - pbrInfo.NdotH) * pbrInfo.NdotH + 1.0; return roughnessSq / (M_PI * f * f); } fn maxComponent(value: vec3f) -> f32 { return max(max(value.r, value.g), value.b); } fn getDielectricF0(ior: f32) -> f32 { let clampedIor = max(ior, 1.0); let ratio = (clampedIor - 1.0) / (clampedIor + 1.0); return ratio * ratio; } fn normalizeDirection(direction: vec2f) -> vec2f { let directionLength = length(direction); if (directionLength > 0.0001) { return direction / directionLength; } return vec2f(1.0, 0.0); } fn rotateDirection(direction: vec2f, rotation: f32) -> vec2f { let s = sin(rotation); let c = cos(rotation); return vec2f(direction.x * c - direction.y * s, direction.x * s + direction.y * c); } fn getIridescenceTint(iridescence: f32, thickness: f32, NdotV: f32) -> vec3f { if (iridescence <= 0.0) { return vec3f(1.0); } let phase = 0.015 * thickness * pbrMaterial.iridescenceIor + (1.0 - NdotV) * 6.0; let thinFilmTint = 0.5 + 0.5 * cos(vec3f(phase, phase + 2.0943951, phase + 4.1887902)); return mix(vec3f(1.0), thinFilmTint, iridescence); } fn getVolumeAttenuation(thickness: f32) -> vec3f { if (thickness <= 0.0) { return vec3f(1.0); } let attenuationCoefficient = -log(max(pbrMaterial.attenuationColor, vec3f(0.0001))) / max(pbrMaterial.attenuationDistance, 0.0001); return exp(-attenuationCoefficient * thickness); } fn createClearcoatPBRInfo( basePBRInfo: PBRInfo, clearcoatNormal: vec3f, clearcoatRoughness: f32 ) -> PBRInfo { let perceptualRoughness = clamp(clearcoatRoughness, c_MinRoughness, 1.0); let alphaRoughness = perceptualRoughness * perceptualRoughness; let NdotV = clamp(abs(dot(clearcoatNormal, basePBRInfo.v)), 0.001, 1.0); return PBRInfo( basePBRInfo.NdotL, NdotV, basePBRInfo.NdotH, basePBRInfo.LdotH, basePBRInfo.VdotH, perceptualRoughness, 0.0, vec3f(0.04), vec3f(1.0), alphaRoughness, vec3f(0.0), vec3f(0.04), clearcoatNormal, basePBRInfo.v ); } fn calculateClearcoatContribution( pbrInfo: PBRInfo, lightColor: vec3f, clearcoatNormal: vec3f, clearcoatFactor: f32, clearcoatRoughness: f32 ) -> vec3f { if (clearcoatFactor <= 0.0) { return vec3f(0.0); } let clearcoatPBRInfo = createClearcoatPBRInfo(pbrInfo, clearcoatNormal, clearcoatRoughness); return calculateFinalColor(clearcoatPBRInfo, lightColor) * clearcoatFactor; } #ifdef USE_IBL fn calculateClearcoatIBLContribution( pbrInfo: PBRInfo, clearcoatNormal: vec3f, reflection: vec3f, clearcoatFactor: f32, clearcoatRoughness: f32 ) -> vec3f { if (clearcoatFactor <= 0.0) { return vec3f(0.0); } let clearcoatPBRInfo = createClearcoatPBRInfo(pbrInfo, clearcoatNormal, clearcoatRoughness); return getIBLContribution(clearcoatPBRInfo, clearcoatNormal, reflection) * clearcoatFactor; } #endif fn calculateSheenContribution( pbrInfo: PBRInfo, lightColor: vec3f, sheenColor: vec3f, sheenRoughness: f32 ) -> vec3f { if (maxComponent(sheenColor) <= 0.0) { return vec3f(0.0); } let sheenFresnel = pow(clamp(1.0 - pbrInfo.VdotH, 0.0, 1.0), 5.0); let sheenVisibility = mix(1.0, pbrInfo.NdotL * pbrInfo.NdotV, sheenRoughness); return pbrInfo.NdotL * lightColor * sheenColor * (0.25 + 0.75 * sheenFresnel) * sheenVisibility * (1.0 - pbrInfo.metalness); } fn calculateAnisotropyBoost( pbrInfo: PBRInfo, anisotropyTangent: vec3f, anisotropyStrength: f32 ) -> f32 { if (anisotropyStrength <= 0.0) { return 1.0; } let anisotropyBitangent = normalize(cross(pbrInfo.n, anisotropyTangent)); let bitangentViewAlignment = abs(dot(pbrInfo.v, anisotropyBitangent)); return mix(1.0, 0.65 + 0.7 * bitangentViewAlignment, anisotropyStrength); } fn calculateMaterialLightColor( pbrInfo: PBRInfo, lightColor: vec3f, clearcoatNormal: vec3f, clearcoatFactor: f32, clearcoatRoughness: f32, sheenColor: vec3f, sheenRoughness: f32, anisotropyTangent: vec3f, anisotropyStrength: f32 ) -> vec3f { let anisotropyBoost = calculateAnisotropyBoost(pbrInfo, anisotropyTangent, anisotropyStrength); var color = calculateFinalColor(pbrInfo, lightColor) * anisotropyBoost; color += calculateClearcoatContribution( pbrInfo, lightColor, clearcoatNormal, clearcoatFactor, clearcoatRoughness ); color += calculateSheenContribution(pbrInfo, lightColor, sheenColor, sheenRoughness); return color; } fn PBRInfo_setAmbientLight(pbrInfo: ptr<function, PBRInfo>) { (*pbrInfo).NdotL = 1.0; (*pbrInfo).NdotH = 0.0; (*pbrInfo).LdotH = 0.0; (*pbrInfo).VdotH = 1.0; } fn PBRInfo_setDirectionalLight(pbrInfo: ptr<function, PBRInfo>, lightDirection: vec3<f32>) { let n = (*pbrInfo).n; let v = (*pbrInfo).v; let l = normalize(lightDirection); // Vector from surface point to light let h = normalize(l + v); // Half vector between both l and v (*pbrInfo).NdotL = clamp(dot(n, l), 0.001, 1.0); (*pbrInfo).NdotH = clamp(dot(n, h), 0.0, 1.0); (*pbrInfo).LdotH = clamp(dot(l, h), 0.0, 1.0); (*pbrInfo).VdotH = clamp(dot(v, h), 0.0, 1.0); } fn PBRInfo_setPointLight(pbrInfo: ptr<function, PBRInfo>, pointLight: PointLight) { let light_direction = normalize(pointLight.position - fragmentInputs.pbr_vPosition); PBRInfo_setDirectionalLight(pbrInfo, light_direction); } fn PBRInfo_setSpotLight(pbrInfo: ptr<function, PBRInfo>, spotLight: SpotLight) { let light_direction = normalize(spotLight.position - fragmentInputs.pbr_vPosition); PBRInfo_setDirectionalLight(pbrInfo, light_direction); } fn calculateFinalColor(pbrInfo: PBRInfo, lightColor: vec3<f32>) -> vec3<f32> { // Calculate the shading terms for the microfacet specular shading model let F = specularReflection(pbrInfo); let G = geometricOcclusion(pbrInfo); let D = microfacetDistribution(pbrInfo); // Calculation of analytical lighting contribution let diffuseContrib = (1.0 - F) * diffuse(pbrInfo); let specContrib = F * G * D / (4.0 * pbrInfo.NdotL * pbrInfo.NdotV); // Obtain final intensity as reflectance (BRDF) scaled by the energy of the light (cosine law) return pbrInfo.NdotL * lightColor * (diffuseContrib + specContrib); } fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> { let baseColorUV = getMaterialUV(pbrMaterial.baseColorUVSet, pbrMaterial.baseColorUVTransform); let metallicRoughnessUV = getMaterialUV( pbrMaterial.metallicRoughnessUVSet, pbrMaterial.metallicRoughnessUVTransform ); let normalUV = getMaterialUV(pbrMaterial.normalUVSet, pbrMaterial.normalUVTransform); let occlusionUV = getMaterialUV(pbrMaterial.occlusionUVSet, pbrMaterial.occlusionUVTransform); let emissiveUV = getMaterialUV(pbrMaterial.emissiveUVSet, pbrMaterial.emissiveUVTransform); let specularColorUV = getMaterialUV( pbrMaterial.specularColorUVSet, pbrMaterial.specularColorUVTransform ); let specularIntensityUV = getMaterialUV( pbrMaterial.specularIntensityUVSet, pbrMaterial.specularIntensityUVTransform ); let transmissionUV = getMaterialUV( pbrMaterial.transmissionUVSet, pbrMaterial.transmissionUVTransform ); let thicknessUV = getMaterialUV(pbrMaterial.thicknessUVSet, pbrMaterial.thicknessUVTransform); let clearcoatUV = getMaterialUV(pbrMaterial.clearcoatUVSet, pbrMaterial.clearcoatUVTransform); let clearcoatRoughnessUV = getMaterialUV( pbrMaterial.clearcoatRoughnessUVSet, pbrMaterial.clearcoatRoughnessUVTransform ); let clearcoatNormalUV = getMaterialUV( pbrMaterial.clearcoatNormalUVSet, pbrMaterial.clearcoatNormalUVTransform ); let sheenColorUV = getMaterialUV( pbrMaterial.sheenColorUVSet, pbrMaterial.sheenColorUVTransform ); let sheenRoughnessUV = getMaterialUV( pbrMaterial.sheenRoughnessUVSet, pbrMaterial.sheenRoughnessUVTransform ); let iridescenceUV = getMaterialUV( pbrMaterial.iridescenceUVSet, pbrMaterial.iridescenceUVTransform ); let iridescenceThicknessUV = getMaterialUV( pbrMaterial.iridescenceThicknessUVSet, pbrMaterial.iridescenceThicknessUVTransform ); let anisotropyUV = getMaterialUV( pbrMaterial.anisotropyUVSet, pbrMaterial.anisotropyUVTransform ); // The albedo may be defined from a base texture or a flat color var baseColor: vec4<f32> = pbrMaterial.baseColorFactor; #ifdef HAS_BASECOLORMAP baseColor = SRGBtoLINEAR( textureSample(pbr_baseColorSampler, pbr_baseColorSamplerSampler, baseColorUV) ) * pbrMaterial.baseColorFactor; #endif #ifdef ALPHA_CUTOFF if (baseColor.a < pbrMaterial.alphaCutoff) { discard; } #endif var color = vec3<f32>(0.0, 0.0, 0.0); var transmission = 0.0; if (pbrMaterial.unlit != 0u) { color = baseColor.rgb; } else { // Metallic and Roughness material properties are packed together // In glTF, these factors can be specified by fixed scalar values // or from a metallic-roughness map var perceptualRoughness = pbrMaterial.metallicRoughnessValues.y; var metallic = pbrMaterial.metallicRoughnessValues.x; #ifdef HAS_METALROUGHNESSMAP // Roughness is stored in the 'g' channel, metallic is stored in the 'b' channel. // This layout intentionally reserves the 'r' channel for (optional) occlusion map data let mrSample = textureSample( pbr_metallicRoughnessSampler, pbr_metallicRoughnessSamplerSampler, metallicRoughnessUV ); perceptualRoughness = mrSample.g * perceptualRoughness; metallic = mrSample.b * metallic; #endif perceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0); metallic = clamp(metallic, 0.0, 1.0); let tbn = getTBN(normalUV); let n = getNormal(tbn, normalUV); // normal at surface point let v = normalize(pbrProjection.camera - fragmentInputs.pbr_vPosition); // Vector from surface point to camera let NdotV = clamp(abs(dot(n, v)), 0.001, 1.0); var useExtendedPBR = false; #ifdef USE_MATERIAL_EXTENSIONS useExtendedPBR = pbrMaterial.specularColorMapEnabled != 0 || pbrMaterial.specularIntensityMapEnabled != 0 || abs(pbrMaterial.specularIntensityFactor - 1.0) > 0.0001 || maxComponent(abs(pbrMaterial.specularColorFactor - vec3f(1.0))) > 0.0001 || abs(pbrMaterial.ior - 1.5) > 0.0001 || pbrMaterial.transmissionMapEnabled != 0 || pbrMaterial.transmissionFactor > 0.0001 || pbrMaterial.clearcoatMapEnabled != 0 || pbrMaterial.clearcoatRoughnessMapEnabled != 0 || pbrMaterial.clearcoatFactor > 0.0001 || pbrMaterial.clearcoatRoughnessFactor > 0.0001 || pbrMaterial.sheenColorMapEnabled != 0 || pbrMaterial.sheenRoughnessMapEnabled != 0 || maxComponent(pbrMaterial.sheenColorFactor) > 0.0001 || pbrMaterial.sheenRoughnessFactor > 0.0001 || pbrMaterial.iridescenceMapEnabled != 0 || pbrMaterial.iridescenceFactor > 0.0001 || abs(pbrMaterial.iridescenceIor - 1.3) > 0.0001 || abs(pbrMaterial.iridescenceThicknessRange.x - 100.0) > 0.0001 || abs(pbrMaterial.iridescenceThicknessRange.y - 400.0) > 0.0001 || pbrMaterial.anisotropyMapEnabled != 0 || pbrMaterial.anisotropyStrength > 0.0001 || abs(pbrMaterial.anisotropyRotation) > 0.0001 || length(pbrMaterial.anisotropyDirection - vec2f(1.0, 0.0)) > 0.0001; #endif if (!useExtendedPBR) { let alphaRoughness = perceptualRoughness * perceptualRoughness; let f0 = vec3<f32>(0.04); var diffuseColor = baseColor.rgb * (vec3<f32>(1.0) - f0); diffuseColor *= 1.0 - metallic; let specularColor = mix(f0, baseColor.rgb, metallic); let reflectance = max(max(specularColor.r, specularColor.g), specularColor.b); let reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0); let specularEnvironmentR0 = specularColor; let specularEnvironmentR90 = vec3<f32>(1.0, 1.0, 1.0) * reflectance90; let reflection = -normalize(reflect(v, n)); var pbrInfo = PBRInfo( 0.0, // NdotL NdotV, 0.0, // NdotH 0.0, // LdotH 0.0, // VdotH perceptualRoughness, metallic, specularEnvironmentR0, specularEnvironmentR90, alphaRoughness, diffuseColor, specularColor, n, v ); #ifdef USE_LIGHTS PBRInfo_setAmbientLight(&pbrInfo); color += calculateFinalColor(pbrInfo, lighting.ambientColor); for (var i = 0; i < lighting.directionalLightCount; i++) { if (i < lighting.directionalLightCount) { PBRInfo_setDirectionalLight(&pbrInfo, lighting_getDirectionalLight(i).direction); color += calculateFinalColor(pbrInfo, lighting_getDirectionalLight(i).color); } } for (var i = 0; i < lighting.pointLightCount; i++) { if (i < lighting.pointLightCount) { PBRInfo_setPointLight(&pbrInfo, lighting_getPointLight(i)); let attenuation = getPointLightAttenuation( lighting_getPointLight(i), distance(lighting_getPointLight(i).position, fragmentInputs.pbr_vPosition) ); color += calculateFinalColor(pbrInfo, lighting_getPointLight(i).color / attenuation); } } for (var i = 0; i < lighting.spotLightCount; i++) { if (i < lighting.spotLightCount) { PBRInfo_setSpotLight(&pbrInfo, lighting_getSpotLight(i)); let attenuation = getSpotLightAttenuation( lighting_getSpotLight(i), fragmentInputs.pbr_vPosition ); color += calculateFinalColor(pbrInfo, lighting_getSpotLight(i).color / attenuation); } } #endif #ifdef USE_IBL if (pbrMaterial.IBLenabled != 0) { color += getIBLContribution(pbrInfo, n, reflection); } #endif #ifdef HAS_OCCLUSIONMAP if (pbrMaterial.occlusionMapEnabled != 0) { let ao = textureSample(pbr_occlusionSampler, pbr_occlusionSamplerSampler, occlusionUV).r; color = mix(color, color * ao, pbrMaterial.occlusionStrength); } #endif var emissive = pbrMaterial.emissiveFactor; #ifdef HAS_EMISSIVEMAP if (pbrMaterial.emissiveMapEnabled != 0u) { emissive *= SRGBtoLINEAR( textureSample(pbr_emissiveSampler, pbr_emissiveSamplerSampler, emissiveUV) ).rgb; } #endif color += emissive * pbrMaterial.emissiveStrength; #ifdef PBR_DEBUG color = mix(color, baseColor.rgb, pbrMaterial.scaleDiffBaseMR.y); color = mix(color, vec3<f32>(metallic), pbrMaterial.scaleDiffBaseMR.z); color = mix(color, vec3<f32>(perceptualRoughness), pbrMaterial.scaleDiffBaseMR.w); #endif return vec4<f32>(pow(color, vec3<f32>(1.0 / 2.2)), baseColor.a); } var specularIntensity = pbrMaterial.specularIntensityFactor; #ifdef HAS_SPECULARINTENSITYMAP if (pbrMaterial.specularIntensityMapEnabled != 0) { specularIntensity *= textureSample( pbr_specularIntensitySampler, pbr_specularIntensitySamplerSampler, specularIntensityUV ).a; } #endif var specularFactor = pbrMaterial.specularColorFactor; #ifdef HAS_SPECULARCOLORMAP if (pbrMaterial.specularColorMapEnabled != 0) { specularFactor *= SRGBtoLINEAR( textureSample( pbr_specularColorSampler, pbr_specularColorSamplerSampler, specularColorUV ) ).rgb; } #endif transmission = pbrMaterial.transmissionFactor; #ifdef HAS_TRANSMISSIONMAP if (pbrMaterial.transmissionMapEnabled != 0) { transmission *= textureSample( pbr_transmissionSampler, pbr_transmissionSamplerSampler, transmissionUV ).r; } #endif transmission = clamp(transmission * (1.0 - metallic), 0.0, 1.0); var thickness = max(pbrMaterial.thicknessFactor, 0.0); #ifdef HAS_THICKNESSMAP thickness *= textureSample( pbr_thicknessSampler, pbr_thicknessSamplerSampler, thicknessUV ).g; #endif var clearcoatFactor = pbrMaterial.clearcoatFactor; var clearcoatRoughness = pbrMaterial.clearcoatRoughnessFactor; #ifdef HAS_CLEARCOATMAP if (pbrMaterial.clearcoatMapEnabled != 0) { clearcoatFactor *= textureSample( pbr_clearcoatSampler, pbr_clearcoatSamplerSampler, clearcoatUV ).r; } #endif #ifdef HAS_CLEARCOATROUGHNESSMAP if (pbrMaterial.clearcoatRoughnessMapEnabled != 0) { clearcoatRoughness *= textureSample( pbr_clearcoatRoughnessSampler, pbr_clearcoatRoughnessSamplerSampler, clearcoatRoughnessUV ).g; } #endif clearcoatFactor = clamp(clearcoatFactor, 0.0, 1.0); clearcoatRoughness = clamp(clearcoatRoughness, c_MinRoughness, 1.0); let clearcoatNormal = getClearcoatNormal(getTBN(clearcoatNormalUV), n, clearcoatNormalUV); var sheenColor = pbrMaterial.sheenColorFactor; var sheenRoughness = pbrMaterial.sheenRoughnessFactor; #ifdef HAS_SHEENCOLORMAP if (pbrMaterial.sheenColorMapEnabled != 0) { sheenColor *= SRGBtoLINEAR( textureSample( pbr_sheenColorSampler, pbr_sheenColorSamplerSampler, sheenColorUV ) ).rgb; } #endif #ifdef HAS_SHEENROUGHNESSMAP if (pbrMaterial.sheenRoughnessMapEnabled != 0) { sheenRoughness *= textureSample( pbr_sheenRoughnessSampler, pbr_sheenRoughnessSamplerSampler, sheenRoughnessUV ).a; } #endif sheenRoughness = clamp(sheenRoughness, c_MinRoughness, 1.0); var iridescence = pbrMaterial.iridescenceFactor; #ifdef HAS_IRIDESCENCEMAP if (pbrMaterial.iridescenceMapEnabled != 0) { iridescence *= textureSample( pbr_iridescenceSampler, pbr_iridescenceSamplerSampler, iridescenceUV ).r; } #endif iridescence = clamp(iridescence, 0.0, 1.0); var iridescenceThickness = mix( pbrMaterial.iridescenceThicknessRange.x, pbrMaterial.iridescenceThicknessRange.y, 0.5 ); #ifdef HAS_IRIDESCENCETHICKNESSMAP iridescenceThickness = mix( pbrMaterial.iridescenceThicknessRange.x, pbrMaterial.iridescenceThicknessRange.y, textureSample( pbr_iridescenceThicknessSampler, pbr_iridescenceThicknessSamplerSampler, iridescenceThicknessUV ).g ); #endif var anisotropyStrength = clamp(pbrMaterial.anisotropyStrength, 0.0, 1.0); var anisotropyDirection = normalizeDirection(pbrMaterial.anisotropyDirection); #ifdef HAS_ANISOTROPYMAP if (pbrMaterial.anisotropyMapEnabled != 0) { let anisotropySample = textureSample( pbr_anisotropySampler, pbr_anisotropySamplerSampler, anisotropyUV ).rgb; anisotropyStrength *= anisotropySample.b; let mappedDirection = anisotropySample.rg * 2.0 - 1.0; if (length(mappedDirection) > 0.0001) { anisotropyDirection = normalize(mappedDirection); } } #endif anisotropyDirection = rotateDirection(anisotropyDirection, pbrMaterial.anisotropyRotation); var anisotropyTangent = normalize(tbn[0] * anisotropyDirection.x + tbn[1] * anisotropyDirection.y); if (length(anisotropyTangent) < 0.0001) { anisotropyTangent = normalize(tbn[0]); } let anisotropyViewAlignment = abs(dot(v, anisotropyTangent)); perceptualRoughness = mix( perceptualRoughness, clamp(perceptualRoughness * (1.0 - 0.6 * anisotropyViewAlignment), c_MinRoughness, 1.0), anisotropyStrength ); // Roughness is authored as perceptual roughness; as is convention, // convert to material roughness by squaring the perceptual roughness [2]. let alphaRoughness = perceptualRoughness * perceptualRoughness; let dielectricF0 = getDielectricF0(pbrMaterial.ior); var dielectricSpecularF0 = min( vec3f(dielectricF0) * specularFactor * specularIntensity, vec3f(1.0) ); let iridescenceTint = getIridescenceTint(iridescence, iridescenceThickness, NdotV); dielectricSpecularF0 = mix( dielectricSpecularF0, dielectricSpecularF0 * iridescenceTint, iridescence ); var diffuseColor = baseColor.rgb * (vec3f(1.0) - dielectricSpecularF0); diffuseColor *= (1.0 - metallic) * (1.0 - transmission); var specularColor = mix(dielectricSpecularF0, baseColor.rgb, metallic); let baseLayerEnergy = 1.0 - clearcoatFactor * 0.25; diffuseColor *= baseLayerEnergy; specularColor *= baseLayerEnergy; // Compute reflectance. let reflectance = max(max(specularColor.r, specularColor.g), specularColor.b); // For typical incident reflectance range (between 4% to 100%) set the grazing // reflectance to 100% for typical fresnel effect. // For very low reflectance range on highly diffuse objects (below 4%), // incrementally reduce grazing reflectance to 0%. let reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0); let specularEnvironmentR0 = specularColor; let specularEnvironmentR90 = vec3<f32>(1.0, 1.0, 1.0) * reflectance90; let reflection = -normalize(reflect(v, n)); var pbrInfo = PBRInfo( 0.0, // NdotL NdotV, 0.0, // NdotH 0.0, // LdotH 0.0, // VdotH perceptualRoughness, metallic, specularEnvironmentR0, specularEnvironmentR90, alphaRoughness, diffuseColor, specularColor, n, v ); #ifdef USE_LIGHTS // Apply ambient light PBRInfo_setAmbientLight(&pbrInfo); color += calculateMaterialLightColor( pbrInfo, lighting.ambientColor, clearcoatNormal, clearcoatFactor, clearcoatRoughness, sheenColor, sheenRoughness, anisotropyTangent, anisotropyStrength ); // Apply directional light for (var i = 0; i < lighting.directionalLightCount; i++) { if (i < lighting.directionalLightCount) { PBRInfo_setDirectionalLight(&pbrInfo, lighting_getDirectionalLight(i).direction); color += calculateMaterialLightColor( pbrInfo, lighting_getDirectionalLight(i).color, clearcoatNormal, clearcoatFactor, clearcoatRoughness, sheenColor, sheenRoughness, anisotropyTangent, anisotropyStrength ); } } // Apply point light for (var i = 0; i < lighting.pointLightCount; i++) { if (i < lighting.pointLightCount) { PBRInfo_setPointLight(&pbrInfo, lighting_getPointLight(i)); let attenuation = getPointLightAttenuation( lighting_getPointLight(i), distance(lighting_getPointLight(i).position, fragmentInputs.pbr_vPosition) ); color += calculateMaterialLightColor( pbrInfo, lighting_getPointLight(i).color / attenuation, clearcoatNormal, clearcoatFactor, clearcoatRoughness, sheenColor, sheenRoughness, anisotropyTangent, anisotropyStrength ); } } for (var i = 0; i < lighting.spotLightCount; i++) { if (i < lighting.spotLightCount) { PBRInfo_setSpotLight(&pbrInfo, lighting_getSpotLight(i)); let attenuation = getSpotLightAttenuation(lighting_getSpotLight(i), fragmentInputs.pbr_vPosition); color += calculateMaterialLightColor( pbrInfo, lighting_getSpotLight(i).color / attenuation, clearcoatNormal, clearcoatFactor, clearcoatRoughness, sheenColor, sheenRoughness, anisotropyTangent, anisotropyStrength ); } } #endif // Calculate lighting contribution from image based lighting source (IBL) #ifdef USE_IBL if (pbrMaterial.IBLenabled != 0) { color += getIBLContribution(pbrInfo, n, reflection) * calculateAnisotropyBoost(pbrInfo, anisotropyTangent, anisotropyStrength); color += calculateClearcoatIBLContribution( pbrInfo, clearcoatNormal, -normalize(reflect(v, clearcoatNormal)), clearcoatFactor, clearcoatRoughness ); color += sheenColor * pbrMaterial.scaleIBLAmbient.x * (1.0 - sheenRoughness) * 0.25; } #endif // Apply optional PBR terms for additional (optional) shading #ifdef HAS_OCCLUSIONMAP if (pbrMaterial.occlusionMapEnabled != 0) { let ao = textureSample(pbr_occlusionSampler, pbr_occlusionSamplerSampler, occlusionUV).r; color = mix(color, color * ao, pbrMaterial.occlusionStrength); } #endif var emissive = pbrMaterial.emissiveFactor; #ifdef HAS_EMISSIVEMAP if (pbrMaterial.emissiveMapEnabled != 0u) { emissive *= SRGBtoLINEAR( textureSample(pbr_emissiveSampler, pbr_emissiveSamplerSampler, emissiveUV) ).rgb; } #endif color += emissive * pbrMaterial.emissiveStrength; if (transmission > 0.0) { color = mix(color, color * getVolumeAttenuation(thickness), transmission); } // This section uses mix to override final color for reference app visualization // of various parameters in the lighting equation. #ifdef PBR_DEBUG // TODO: Figure out how to debug multiple lights // color = mix(color, F, pbr_scaleFGDSpec.x); // color = mix(color, vec3(G), pbr_scaleFGDSpec.y); // color = mix(color, vec3(D), pbr_scaleFGDSpec.z); // color = mix(color, specContrib, pbr_scaleFGDSpec.w); // color = mix(color, diffuseContrib, pbr_scaleDiffBaseMR.x); color = mix(color, baseColor.rgb, pbrMaterial.scaleDiffBaseMR.y); color = mix(color, vec3<f32>(metallic), pbrMaterial.scaleDiffBaseMR.z); color = mix(color, vec3<f32>(perceptualRoughness), pbrMaterial.scaleDiffBaseMR.w); #endif } let alpha = clamp(baseColor.a * (1.0 - transmission), 0.0, 1.0); return vec4<f32>(pow(color, vec3<f32>(1.0 / 2.2)), alpha); } `;var pI=`layout(std140) uniform pbrProjectionUniforms { mat4 modelViewProjectionMatrix; mat4 modelMatrix; mat4 normalMatrix; vec3 camera; } pbrProjection; `,w7=`struct pbrProjectionUniforms { modelViewProjectionMatrix: mat4x4<f32>, modelMatrix: mat4x4<f32>, normalMatrix: mat4x4<f32>, camera: vec3<f32> }; @group(0) @binding(auto) var<uniform> pbrProjection: pbrProjectionUniforms; `,mI={name:"pbrProjection",bindingLayout:[{name:"pbrProjection",group:0}],source:w7,vs:pI,fs:pI,getUniforms:t=>t,uniformTypes:{modelViewProjectionMatrix:"mat4x4<f32>",modelMatrix:"mat4x4<f32>",normalMatrix:"mat4x4<f32>",camera:"vec3<f32>"}};var Po={props:{},uniforms:{},defaultUniforms:{unlit:!1,baseColorMapEnabled:!1,baseColorFactor:[1,1,1,1],normalMapEnabled:!1,normalScale:1,emissiveMapEnabled:!1,emissiveFactor:[0,0,0],metallicRoughnessValues:[1,1],metallicRoughnessMapEnabled:!1,occlusionMapEnabled:!1,occlusionStrength:1,alphaCutoffEnabled:!1,alphaCutoff:.5,IBLenabled:!1,scaleIBLAmbient:[1,1],scaleDiffBaseMR:[0,0,0,0],scaleFGDSpec:[0,0,0,0],specularColorFactor:[1,1,1],specularIntensityFactor:1,specularColorMapEnabled:!1,specularIntensityMapEnabled:!1,ior:1.5,transmissionFactor:0,transmissionMapEnabled:!1,thicknessFactor:0,attenuationDistance:1e9,attenuationColor:[1,1,1],clearcoatFactor:0,clearcoatRoughnessFactor:0,clearcoatMapEnabled:!1,clearcoatRoughnessMapEnabled:!1,sheenColorFactor:[0,0,0],sheenRoughnessFactor:0,sheenColorMapEnabled:!1,sheenRoughnessMapEnabled:!1,iridescenceFactor:0,iridescenceIor:1.3,iridescenceThicknessRange:[100,400],iridescenceMapEnabled:!1,anisotropyStrength:0,anisotropyRotation:0,anisotropyDirection:[1,0],anisotropyMapEnabled:!1,emissiveStrength:1,baseColorUVSet:0,baseColorUVTransform:[1,0,0,0,1,0,0,0,1],metallicRoughnessUVSet:0,metallicRoughnessUVTransform:[1,0,0,0,1,0,0,0,1],normalUVSet:0,normalUVTransform:[1,0,0,0,1,0,0,0,1],occlusionUVSet:0,occlusionUVTransform:[1,0,0,0,1,0,0,0,1],emissiveUVSet:0,emissiveUVTransform:[1,0,0,0,1,0,0,0,1],specularColorUVSet:0,specularColorUVTransform:[1,0,0,0,1,0,0,0,1],specularIntensityUVSet:0,specularIntensityUVTransform:[1,0,0,0,1,0,0,0,1],transmissionUVSet:0,transmissionUVTransform:[1,0,0,0,1,0,0,0,1],thicknessUVSet:0,thicknessUVTransform:[1,0,0,0,1,0,0,0,1],clearcoatUVSet:0,clearcoatUVTransform:[1,0,0,0,1,0,0,0,1],clearcoatRoughnessUVSet:0,clearcoatRoughnessUVTransform:[1,0,0,0,1,0,0,0,1],clearcoatNormalUVSet:0,clearcoatNormalUVTransform:[1,0,0,0,1,0,0,0,1],sheenColorUVSet:0,sheenColorUVTransform:[1,0,0,0,1,0,0,0,1],sheenRoughnessUVSet:0,sheenRoughnessUVTransform:[1,0,0,0,1,0,0,0,1],iridescenceUVSet:0,iridescenceUVTransform:[1,0,0,0,1,0,0,0,1],iridescenceThicknessUVSet:0,iridescenceThicknessUVTransform:[1,0,0,0,1,0,0,0,1],anisotropyUVSet:0,anisotropyUVTransform:[1,0,0,0,1,0,0,0,1]},name:"pbrMaterial",firstBindingSlot:0,bindingLayout:[{name:"pbrMaterial",group:3},{name:"pbr_baseColorSampler",group:3},{name:"pbr_normalSampler",group:3},{name:"pbr_emissiveSampler",group:3},{name:"pbr_metallicRoughnessSampler",group:3},{name:"pbr_occlusionSampler",group:3},{name:"pbr_specularColorSampler",group:3},{name:"pbr_specularIntensitySampler",group:3},{name:"pbr_transmissionSampler",group:3},{name:"pbr_thicknessSampler",group:3},{name:"pbr_clearcoatSampler",group:3},{name:"pbr_clearcoatRoughnessSampler",group:3},{name:"pbr_clearcoatNormalSampler",group:3},{name:"pbr_sheenColorSampler",group:3},{name:"pbr_sheenRoughnessSampler",group:3},{name:"pbr_iridescenceSampler",group:3},{name:"pbr_iridescenceThicknessSampler",group:3},{name:"pbr_anisotropySampler",group:3}],dependencies:[Ka,fI,mI],source:hI,vs:uI,fs:dI,defines:{LIGHTING_FRAGMENT:!0,HAS_NORMALMAP:!1,HAS_EMISSIVEMAP:!1,HAS_OCCLUSIONMAP:!1,HAS_BASECOLORMAP:!1,HAS_METALROUGHNESSMAP:!1,HAS_SPECULARCOLORMAP:!1,HAS_SPECULARINTENSITYMAP:!1,HAS_TRANSMISSIONMAP:!1,HAS_THICKNESSMAP:!1,HAS_CLEARCOATMAP:!1,HAS_CLEARCOATROUGHNESSMAP:!1,HAS_CLEARCOATNORMALMAP:!1,HAS_SHEENCOLORMAP:!1,HAS_SHEENROUGHNESSMAP:!1,HAS_IRIDESCENCEMAP:!1,HAS_IRIDESCENCETHICKNESSMAP:!1,HAS_ANISOTROPYMAP:!1,USE_MATERIAL_EXTENSIONS:!1,ALPHA_CUTOFF:!1,USE_IBL:!1,PBR_DEBUG:!1},getUniforms:t=>t,uniformTypes:{unlit:"i32",baseColorMapEnabled:"i32",baseColorFactor:"vec4<f32>",normalMapEnabled:"i32",normalScale:"f32",emissiveMapEnabled:"i32",emissiveFactor:"vec3<f32>",metallicRoughnessValues:"vec2<f32>",metallicRoughnessMapEnabled:"i32",occlusionMapEnabled:"i32",occlusionStrength:"f32",alphaCutoffEnabled:"i32",alphaCutoff:"f32",specularColorFactor:"vec3<f32>",specularIntensityFactor:"f32",specularColorMapEnabled:"i32",specularIntensityMapEnabled:"i32",ior:"f32",transmissionFactor:"f32",transmissionMapEnabled:"i32",thicknessFactor:"f32",attenuationDistance:"f32",attenuationColor:"vec3<f32>",clearcoatFactor:"f32",clearcoatRoughnessFactor:"f32",clearcoatMapEnabled:"i32",clearcoatRoughnessMapEnabled:"i32",sheenColorFactor:"vec3<f32>",sheenRoughnessFactor:"f32",sheenColorMapEnabled:"i32",sheenRoughnessMapEnabled:"i32",iridescenceFactor:"f32",iridescenceIor:"f32",iridescenceThicknessRange:"vec2<f32>",iridescenceMapEnabled:"i32",anisotropyStrength:"f32",anisotropyRotation:"f32",anisotropyDirection:"vec2<f32>",anisotropyMapEnabled:"i32",emissiveStrength:"f32",IBLenabled:"i32",scaleIBLAmbient:"vec2<f32>",scaleDiffBaseMR:"vec4<f32>",scaleFGDSpec:"vec4<f32>",baseColorUVSet:"i32",baseColorUVTransform:"mat3x3<f32>",metallicRoughnessUVSet:"i32",metallicRoughnessUVTransform:"mat3x3<f32>",normalUVSet:"i32",normalUVTransform:"mat3x3<f32>",occlusionUVSet:"i32",occlusionUVTransform:"mat3x3<f32>",emissiveUVSet:"i32",emissiveUVTransform:"mat3x3<f32>",specularColorUVSet:"i32",specularColorUVTransform:"mat3x3<f32>",specularIntensityUVSet:"i32",specularIntensityUVTransform:"mat3x3<f32>",transmissionUVSet:"i32",transmissionUVTransform:"mat3x3<f32>",thicknessUVSet:"i32",thicknessUVTransform:"mat3x3<f32>",clearcoatUVSet:"i32",clearcoatUVTransform:"mat3x3<f32>",clearcoatRoughnessUVSet:"i32",clearcoatRoughnessUVTransform:"mat3x3<f32>",clearcoatNormalUVSet:"i32",clearcoatNormalUVTransform:"mat3x3<f32>",sheenColorUVSet:"i32",sheenColorUVTransform:"mat3x3<f32>",sheenRoughnessUVSet:"i32",sheenRoughnessUVTransform:"mat3x3<f32>",iridescenceUVSet:"i32",iridescenceUVTransform:"mat3x3<f32>",iridescenceThicknessUVSet:"i32",iridescenceThicknessUVTransform:"mat3x3<f32>",anisotropyUVSet:"i32",anisotropyUVTransform:"mat3x3<f32>"}};var P7=`struct LayerUniforms { opacity: f32, }; @group(0) @binding(auto) var<uniform> layer: LayerUniforms; `,gI=`layout(std140) uniform layerUniforms { uniform float opacity; } layer; `,mv={name:"layer",source:P7,vs:gI,fs:gI,getUniforms:t=>({opacity:Math.pow(t.opacity,.45454545454545453)}),uniformTypes:{opacity:"f32"}};var M7=` @must_use fn deckgl_premultiplied_alpha(fragColor: vec4<f32>) -> vec4<f32> { return vec4(fragColor.rgb * fragColor.a, fragColor.a); }; `,Yr={name:"color",dependencies:[],source:M7,getUniforms:t=>({})};var R7=`const SMOOTH_EDGE_RADIUS: f32 = 0.5; struct VertexGeometry { position: vec4<f32>, worldPosition: vec3<f32>, worldPositionAlt: vec3<f32>, normal: vec3<f32>, uv: vec2<f32>, pickingColor: vec3<f32>, }; var<private> geometry_: VertexGeometry = VertexGeometry( vec4<f32>(0.0, 0.0, 1.0, 0.0), vec3<f32>(0.0, 0.0, 0.0), vec3<f32>(0.0, 0.0, 0.0), vec3<f32>(0.0, 0.0, 0.0), vec2<f32>(0.0, 0.0), vec3<f32>(0.0, 0.0, 0.0) ); struct FragmentGeometry { uv: vec2<f32>, }; var<private> fragmentGeometry: FragmentGeometry; fn smoothedge(edge: f32, x: f32) -> f32 { return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x); } `,_I="#define SMOOTH_EDGE_RADIUS 0.5",I7=`${_I} struct VertexGeometry { vec4 position; vec3 worldPosition; vec3 worldPositionAlt; vec3 normal; vec2 uv; vec3 pickingColor; } geometry = VertexGeometry( vec4(0.0, 0.0, 1.0, 0.0), vec3(0.0), vec3(0.0), vec3(0.0), vec2(0.0), vec3(0.0) ); `,L7=`${_I} struct FragmentGeometry { vec2 uv; } geometry; float smoothedge(float edge, float x) { return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x); } `,Km={name:"geometry",source:R7,vs:I7,fs:L7};var Te;(function(t){t[t.Start=1]="Start",t[t.Move=2]="Move",t[t.End=4]="End",t[t.Cancel=8]="Cancel"})(Te||(Te={}));var Le;(function(t){t[t.None=0]="None",t[t.Left=1]="Left",t[t.Right=2]="Right",t[t.Up=4]="Up",t[t.Down=8]="Down",t[t.Horizontal=3]="Horizontal",t[t.Vertical=12]="Vertical",t[t.All=15]="All"})(Le||(Le={}));var Z;(function(t){t[t.Possible=1]="Possible",t[t.Began=2]="Began",t[t.Changed=4]="Changed",t[t.Ended=8]="Ended",t[t.Recognized=8]="Recognized",t[t.Cancelled=16]="Cancelled",t[t.Failed=32]="Failed"})(Z||(Z={}));var yI="compute",gv="auto",Of="manipulation",as="none",Ff="pan-x",Nf="pan-y";function _v(t){if(t.includes(as))return as;let e=t.includes(Ff),r=t.includes(Nf);return e&&r?as:e||r?e?Ff:Nf:t.includes(Of)?Of:gv}var Df=class{constructor(e,r){this.actions="",this.manager=e,this.set(r)}set(e){e===yI&&(e=this.compute()),this.manager.element&&(this.manager.element.style.touchAction=e,this.actions=e)}update(){this.set(this.manager.options.touchAction)}compute(){let e=[];for(let r of this.manager.recognizers)r.options.enable&&(e=e.concat(r.getTouchAction()));return _v(e.join(" "))}};function qa(t){return t.trim().split(/\s+/g)}function qm(t,e,r){if(t)for(let o of qa(e))t.addEventListener(o,r,!1)}function Zm(t,e,r){if(t)for(let o of qa(e))t.removeEventListener(o,r,!1)}function yv(t){return(t.ownerDocument||t).defaultView}function xv(t,e){let r=t;for(;r;){if(r===e)return!0;r=r.parentNode}return!1}function Jm(t){let e=t.length;if(e===1)return{x:Math.round(t[0].clientX),y:Math.round(t[0].clientY)};let r=0,o=0,n=0;for(;n<e;)r+=t[n].clientX,o+=t[n].clientY,n++;return{x:Math.round(r/e),y:Math.round(o/e)}}function bv(t){let e=[],r=0;for(;r<t.pointers.length;)e[r]={clientX:Math.round(t.pointers[r].clientX),clientY:Math.round(t.pointers[r].clientY)},r++;return{timeStamp:Date.now(),pointers:e,center:Jm(e),deltaX:t.deltaX,deltaY:t.deltaY}}function Qm(t,e){let r=e.x-t.x,o=e.y-t.y;return Math.sqrt(r*r+o*o)}function Av(t,e){let r=e.clientX-t.clientX,o=e.clientY-t.clientY;return Math.sqrt(r*r+o*o)}function xI(t,e){let r=e.x-t.x,o=e.y-t.y;return Math.atan2(o,r)*180/Math.PI}function Tv(t,e){let r=e.clientX-t.clientX,o=e.clientY-t.clientY;return Math.atan2(o,r)*180/Math.PI}function eg(t,e){return t===e?Le.None:Math.abs(t)>=Math.abs(e)?t<0?Le.Left:Le.Right:e<0?Le.Up:Le.Down}function bI(t,e){let r=e.center,o=t.offsetDelta,n=t.prevDelta,i=t.prevInput;return(e.eventType===Te.Start||i?.eventType===Te.End)&&(n=t.prevDelta={x:i?.deltaX||0,y:i?.deltaY||0},o=t.offsetDelta={x:r.x,y:r.y}),{deltaX:n.x+(r.x-o.x),deltaY:n.y+(r.y-o.y)}}function tg(t,e,r){return{x:e/t||0,y:r/t||0}}function AI(t,e){return Av(e[0],e[1])/Av(t[0],t[1])}function TI(t,e){return Tv(e[1],e[0])-Tv(t[1],t[0])}function vI(t,e){let r=t.lastInterval||e,o=e.timeStamp-r.timeStamp,n,i,s,a;if(e.eventType!==Te.Cancel&&(o>25||r.velocity===void 0)){let c=e.deltaX-r.deltaX,l=e.deltaY-r.deltaY,f=tg(o,c,l);i=f.x,s=f.y,n=Math.abs(f.x)>Math.abs(f.y)?f.x:f.y,a=eg(c,l),t.lastInterval=e}else n=r.velocity,i=r.velocityX,s=r.velocityY,a=r.direction;e.velocity=n,e.velocityX=i,e.velocityY=s,e.direction=a}function SI(t,e){let{session:r}=t,{pointers:o}=e,{length:n}=o;r.firstInput||(r.firstInput=bv(e)),n>1&&!r.firstMultiple?r.firstMultiple=bv(e):n===1&&(r.firstMultiple=!1);let{firstInput:i,firstMultiple:s}=r,a=s?s.center:i.center,c=e.center=Jm(o);e.timeStamp=Date.now(),e.deltaTime=e.timeStamp-i.timeStamp,e.angle=xI(a,c),e.distance=Qm(a,c);let{deltaX:l,deltaY:f}=bI(r,e);e.deltaX=l,e.deltaY=f,e.offsetDirection=eg(e.deltaX,e.deltaY);let u=tg(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=u.x,e.overallVelocityY=u.y,e.overallVelocity=Math.abs(u.x)>Math.abs(u.y)?u.x:u.y,e.scale=s?AI(s.pointers,o):1,e.rotation=s?TI(s.pointers,o):0,e.maxPointers=r.prevInput?e.pointers.length>r.prevInput.maxPointers?e.pointers.length:r.prevInput.maxPointers:e.pointers.length;let d=t.element;return xv(e.srcEvent.target,d)&&(d=e.srcEvent.target),e.target=d,vI(r,e),e}function CI(t,e,r){let o=r.pointers.length,n=r.changedPointers.length,i=e&Te.Start&&o-n===0,s=e&(Te.End|Te.Cancel)&&o-n===0;r.isFirst=Boolean(i),r.isFinal=Boolean(s),i&&(t.session={}),r.eventType=e;let a=SI(t,r);t.emit("hammer.input",a),t.recognize(a),t.session.prevInput=a}var Uf=class{constructor(e){this.evEl="",this.evWin="",this.evTarget="",this.domHandler=r=>{this.manager.options.enable&&this.handler(r)},this.manager=e,this.element=e.element,this.target=e.options.inputTarget||e.element}callback(e,r){CI(this.manager,e,r)}init(){qm(this.element,this.evEl,this.domHandler),qm(this.target,this.evTarget,this.domHandler),qm(yv(this.element),this.evWin,this.domHandler)}destroy(){Zm(this.element,this.evEl,this.domHandler),Zm(this.target,this.evTarget,this.domHandler),Zm(yv(this.element),this.evWin,this.domHandler)}};var O7={pointerdown:Te.Start,pointermove:Te.Move,pointerup:Te.End,pointercancel:Te.Cancel,pointerout:Te.Cancel},F7="pointerdown",N7="pointermove pointerup pointercancel",kf=class extends Uf{constructor(e){super(e),this.evEl=F7,this.evWin=N7,this.store=this.manager.session.pointerEvents=[],this.init()}handler(e){let{store:r}=this,o=!1,n=O7[e.type],i=e.pointerType,s=i==="touch",a=r.findIndex(c=>c.pointerId===e.pointerId);n&Te.Start&&(e.buttons||s)?a<0&&(r.push(e),a=r.length-1):n&(Te.End|Te.Cancel)&&(o=!0),!(a<0)&&(r[a]=e,this.callback(n,{pointers:r,changedPointers:[e],eventType:n,pointerType:i,srcEvent:e}),o&&r.splice(a,1))}};var D7=["","webkit","Moz","MS","ms","o"];function EI(t,e){let r=e[0].toUpperCase()+e.slice(1);for(let o of D7){let n=o?o+r:e;if(n in t)return n}}var U7=1,wI=2,PI={touchAction:"compute",enable:!0,inputTarget:null,cssProps:{userSelect:"none",userDrag:"none",touchCallout:"none",tapHighlightColor:"rgba(0,0,0,0)"}},Vf=class{constructor(e,r){this.options={...PI,...r,cssProps:{...PI.cssProps,...r.cssProps},inputTarget:r.inputTarget||e},this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=e,this.input=new kf(this),this.touchAction=new Df(this,this.options.touchAction),this.toggleCssProps(!0)}set(e){return Object.assign(this.options,e),e.touchAction&&this.touchAction.update(),e.inputTarget&&(this.input.destroy(),this.input.target=e.inputTarget,this.input.init()),this}stop(e){this.session.stopped=e?wI:U7}recognize(e){let{session:r}=this;if(r.stopped)return;this.session.prevented&&e.srcEvent.preventDefault();let o,{recognizers:n}=this,{curRecognizer:i}=r;(!i||i&&i.state&Z.Recognized)&&(i=r.curRecognizer=null);let s=0;for(;s<n.length;)o=n[s],r.stopped!==wI&&(!i||o===i||o.canRecognizeWith(i))?o.recognize(e):o.reset(),!i&&o.state&(Z.Began|Z.Changed|Z.Ended)&&(i=r.curRecognizer=o),s++}get(e){let{recognizers:r}=this;for(let o=0;o<r.length;o++)if(r[o].options.event===e)return r[o];return null}add(e){if(Array.isArray(e)){for(let o of e)this.add(o);return this}let r=this.get(e.options.event);return r&&this.remove(r),this.recognizers.push(e),e.manager=this,this.touchAction.update(),e}remove(e){if(Array.isArray(e)){for(let o of e)this.remove(o);return this}let r=typeof e=="string"?this.get(e):e;if(r){let{recognizers:o}=this,n=o.indexOf(r);n!==-1&&(o.splice(n,1),this.touchAction.update())}return this}on(e,r){if(!e||!r)return;let{handlers:o}=this;for(let n of qa(e))o[n]=o[n]||[],o[n].push(r)}off(e,r){if(!e)return;let{handlers:o}=this;for(let n of qa(e))r?o[n]&&o[n].splice(o[n].indexOf(r),1):delete o[n]}emit(e,r){let o=this.handlers[e]&&this.handlers[e].slice();if(!o||!o.length)return;let n=r;n.type=e,n.preventDefault=function(){r.srcEvent.preventDefault()};let i=0;for(;i<o.length;)o[i](n),i++}destroy(){this.toggleCssProps(!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}toggleCssProps(e){let{element:r}=this;if(r){for(let[o,n]of Object.entries(this.options.cssProps)){let i=EI(r.style,o);e?(this.oldCssProps[i]=r.style[i],r.style[i]=n):r.style[i]=this.oldCssProps[i]||""}e||(this.oldCssProps={})}}};var k7=1;function MI(){return k7++}function vv(t){return t&Z.Cancelled?"cancel":t&Z.Ended?"end":t&Z.Changed?"move":t&Z.Began?"start":""}var sn=class{constructor(e){this.options=e,this.id=MI(),this.state=Z.Possible,this.simultaneous={},this.requireFail=[]}set(e){return Object.assign(this.options,e),this.manager.touchAction.update(),this}recognizeWith(e){if(Array.isArray(e)){for(let n of e)this.recognizeWith(n);return this}let r;if(typeof e=="string"){if(r=this.manager.get(e),!r)throw new Error(`Cannot find recognizer ${e}`)}else r=e;let{simultaneous:o}=this;return o[r.id]||(o[r.id]=r,r.recognizeWith(this)),this}dropRecognizeWith(e){if(Array.isArray(e)){for(let o of e)this.dropRecognizeWith(o);return this}let r;return typeof e=="string"?r=this.manager.get(e):r=e,r&&delete this.simultaneous[r.id],this}requireFailure(e){if(Array.isArray(e)){for(let n of e)this.requireFailure(n);return this}let r;if(typeof e=="string"){if(r=this.manager.get(e),!r)throw new Error(`Cannot find recognizer ${e}`)}else r=e;let{requireFail:o}=this;return o.indexOf(r)===-1&&(o.push(r),r.requireFailure(this)),this}dropRequireFailure(e){if(Array.isArray(e)){for(let o of e)this.dropRequireFailure(o);return this}let r;if(typeof e=="string"?r=this.manager.get(e):r=e,r){let o=this.requireFail.indexOf(r);o>-1&&this.requireFail.splice(o,1)}return this}hasRequireFailures(){return Boolean(this.requireFail.find(e=>e.options.enable))}canRecognizeWith(e){return Boolean(this.simultaneous[e.id])}emit(e){if(!e)return;let{state:r}=this;r<Z.Ended&&this.manager.emit(this.options.event+vv(r),e),this.manager.emit(this.options.event,e),e.additionalEvent&&this.manager.emit(e.additionalEvent,e),r>=Z.Ended&&this.manager.emit(this.options.event+vv(r),e)}tryEmit(e){this.canEmit()?this.emit(e):this.state=Z.Failed}canEmit(){let e=0;for(;e<this.requireFail.length;){if(!(this.requireFail[e].state&(Z.Failed|Z.Possible)))return!1;e++}return!0}recognize(e){let r={...e};if(!this.options.enable){this.reset(),this.state=Z.Failed;return}this.state&(Z.Recognized|Z.Cancelled|Z.Failed)&&(this.state=Z.Possible),this.state=this.process(r),this.state&(Z.Began|Z.Changed|Z.Ended|Z.Cancelled)&&this.tryEmit(r)}getEventNames(){return[this.options.event]}reset(){}};var an=class extends sn{attrTest(e){let r=this.options.pointers;return r===0||e.pointers.length===r}process(e){let{state:r}=this,{eventType:o}=e,n=r&(Z.Began|Z.Changed),i=this.attrTest(e);return n&&(o&Te.Cancel||!i)?r|Z.Cancelled:n||i?o&Te.End?r|Z.Ended:r&Z.Began?r|Z.Changed:Z.Began:Z.Failed}};var cs=class extends sn{constructor(e={}){super({enable:!0,event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10,...e}),this.pTime=null,this.pCenter=null,this._timer=null,this._input=null,this.count=0}getTouchAction(){return[Of]}process(e){let{options:r}=this,o=e.pointers.length===r.pointers,n=e.distance<r.threshold,i=e.deltaTime<r.time;if(this.reset(),e.eventType&Te.Start&&this.count===0)return this.failTimeout();if(n&&i&&o){if(e.eventType!==Te.End)return this.failTimeout();let s=this.pTime?e.timeStamp-this.pTime<r.interval:!0,a=!this.pCenter||Qm(this.pCenter,e.center)<r.posThreshold;if(this.pTime=e.timeStamp,this.pCenter=e.center,!a||!s?this.count=1:this.count+=1,this._input=e,this.count%r.taps===0)return this.hasRequireFailures()?(this._timer=setTimeout(()=>{this.state=Z.Recognized,this.tryEmit(this._input)},r.interval),Z.Began):Z.Recognized}return Z.Failed}failTimeout(){return this._timer=setTimeout(()=>{this.state=Z.Failed},this.options.interval),Z.Failed}reset(){clearTimeout(this._timer)}emit(e){this.state===Z.Recognized&&(e.tapCount=this.count,this.manager.emit(this.options.event,e))}};var V7=["","start","move","end","cancel","up","down","left","right"],ii=class extends an{constructor(e={}){super({enable:!0,pointers:1,event:"pan",threshold:10,direction:Le.All,...e}),this.pX=null,this.pY=null}getTouchAction(){let{options:{direction:e}}=this,r=[];return e&Le.Horizontal&&r.push(Nf),e&Le.Vertical&&r.push(Ff),r}getEventNames(){return V7.map(e=>this.options.event+e)}directionTest(e){let{options:r}=this,o=!0,{distance:n}=e,{direction:i}=e,s=e.deltaX,a=e.deltaY;return i&r.direction||(r.direction&Le.Horizontal?(i=s===0?Le.None:s<0?Le.Left:Le.Right,o=s!==this.pX,n=Math.abs(e.deltaX)):(i=a===0?Le.None:a<0?Le.Up:Le.Down,o=a!==this.pY,n=Math.abs(e.deltaY))),e.direction=i,o&&n>r.threshold&&Boolean(i&r.direction)}attrTest(e){return super.attrTest(e)&&(Boolean(this.state&Z.Began)||!(this.state&Z.Began)&&this.directionTest(e))}emit(e){this.pX=e.deltaX,this.pY=e.deltaY;let r=Le[e.direction].toLowerCase();r&&(e.additionalEvent=this.options.event+r),super.emit(e)}};var z7=["","start","move","end","cancel","in","out"],Za=class extends an{constructor(e={}){super({enable:!0,event:"pinch",threshold:0,pointers:2,...e})}getTouchAction(){return[as]}getEventNames(){return z7.map(e=>this.options.event+e)}attrTest(e){return super.attrTest(e)&&(Math.abs(e.scale-1)>this.options.threshold||Boolean(this.state&Z.Began))}emit(e){if(e.scale!==1){let r=e.scale<1?"in":"out";e.additionalEvent=this.options.event+r}super.emit(e)}};var Mo=class{constructor(e,r,o){this.element=e,this.callback=r,this.options=o}};var RI=typeof navigator<"u"&&navigator.userAgent?navigator.userAgent.toLowerCase():"",sRe=typeof window<"u"?window:global;var G7=RI.indexOf("firefox")!==-1,II=4.000244140625,$7=40,X7=.25,rg=class extends Mo{constructor(e,r,o){super(e,r,{enable:!0,...o}),this.handleEvent=n=>{if(!this.options.enable)return;let i=n.deltaY;globalThis.WheelEvent&&(G7&&n.deltaMode===globalThis.WheelEvent.DOM_DELTA_PIXEL&&(i/=globalThis.devicePixelRatio),n.deltaMode===globalThis.WheelEvent.DOM_DELTA_LINE&&(i*=$7)),i!==0&&i%II===0&&(i=Math.floor(i/II)),n.shiftKey&&i&&(i=i*X7),this.callback({type:"wheel",center:{x:n.clientX,y:n.clientY},delta:-i,srcEvent:n,pointerType:"mouse",target:n.target})},e.addEventListener("wheel",this.handleEvent,{passive:!1})}destroy(){this.element.removeEventListener("wheel",this.handleEvent)}enableEventType(e,r){e==="wheel"&&(this.options.enable=r)}};var LI=["mousedown","mousemove","mouseup","mouseover","mouseout","mouseleave"],og=class extends Mo{constructor(e,r,o){super(e,r,{enable:!0,...o}),this.handleEvent=i=>{this.handleOverEvent(i),this.handleOutEvent(i),this.handleEnterEvent(i),this.handleLeaveEvent(i),this.handleMoveEvent(i)},this.pressed=!1;let{enable:n}=this.options;this.enableMoveEvent=n,this.enableLeaveEvent=n,this.enableEnterEvent=n,this.enableOutEvent=n,this.enableOverEvent=n,LI.forEach(i=>e.addEventListener(i,this.handleEvent))}destroy(){LI.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,r){switch(e){case"pointermove":this.enableMoveEvent=r;break;case"pointerover":this.enableOverEvent=r;break;case"pointerout":this.enableOutEvent=r;break;case"pointerenter":this.enableEnterEvent=r;break;case"pointerleave":this.enableLeaveEvent=r;break;default:}}handleOverEvent(e){this.enableOverEvent&&e.type==="mouseover"&&this._emit("pointerover",e)}handleOutEvent(e){this.enableOutEvent&&e.type==="mouseout"&&this._emit("pointerout",e)}handleEnterEvent(e){this.enableEnterEvent&&e.type==="mouseenter"&&this._emit("pointerenter",e)}handleLeaveEvent(e){this.enableLeaveEvent&&e.type==="mouseleave"&&this._emit("pointerleave",e)}handleMoveEvent(e){if(this.enableMoveEvent)switch(e.type){case"mousedown":e.button>=0&&(this.pressed=!0);break;case"mousemove":e.buttons===0&&(this.pressed=!1),this.pressed||this._emit("pointermove",e);break;case"mouseup":this.pressed=!1;break;default:}}_emit(e,r){this.callback({type:e,center:{x:r.clientX,y:r.clientY},srcEvent:r,pointerType:"mouse",target:r.target})}};var BI=["keydown","keyup"],ng=class extends Mo{constructor(e,r,o){super(e,r,{enable:!0,tabIndex:0,...o}),this.handleEvent=n=>{let i=n.target||n.srcElement;i.tagName==="INPUT"&&i.type==="text"||i.tagName==="TEXTAREA"||(this.enableDownEvent&&n.type==="keydown"&&this.callback({type:"keydown",srcEvent:n,key:n.key,target:n.target}),this.enableUpEvent&&n.type==="keyup"&&this.callback({type:"keyup",srcEvent:n,key:n.key,target:n.target}))},this.enableDownEvent=this.options.enable,this.enableUpEvent=this.options.enable,e.tabIndex=this.options.tabIndex,e.style.outline="none",BI.forEach(n=>e.addEventListener(n,this.handleEvent))}destroy(){BI.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,r){e==="keydown"&&(this.enableDownEvent=r),e==="keyup"&&(this.enableUpEvent=r)}};var ig=class extends Mo{constructor(e,r,o){super(e,r,o),this.handleEvent=n=>{this.options.enable&&this.callback({type:"contextmenu",center:{x:n.clientX,y:n.clientY},srcEvent:n,pointerType:"mouse",target:n.target})},e.addEventListener("contextmenu",this.handleEvent)}destroy(){this.element.removeEventListener("contextmenu",this.handleEvent)}enableEventType(e,r){e==="contextmenu"&&(this.options.enable=r)}};var Y7={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4},K7=0,q7=1,Z7=2,J7=1,Q7=2,eY=4;function OI(t){let e=Y7[t.srcEvent.type];if(!e)return null;let{buttons:r,button:o}=t.srcEvent,n=!1,i=!1,s=!1;return e===2?(n=Boolean(r&J7),i=Boolean(r&eY),s=Boolean(r&Q7)):(n=o===K7,i=o===q7,s=o===Z7),{leftButton:n,middleButton:i,rightButton:s}}function FI(t,e){let r=t.center;if(!r)return null;let o=e.getBoundingClientRect(),n=o.width/e.offsetWidth||1,i=o.height/e.offsetHeight||1,s={x:(r.x-o.left-e.clientLeft)/n,y:(r.y-o.top-e.clientTop)/i};return{center:r,offsetCenter:s}}var tY={srcElement:"root",priority:0},sg=class{constructor(e,r){this.handleEvent=o=>{if(this.isEmpty())return;let n=this._normalizeEvent(o),i=o.srcEvent.target;for(;i&&i!==n.rootElement;){if(this._emit(n,i),n.handled)return;i=i.parentNode}this._emit(n,"root")},this.eventManager=e,this.recognizerName=r,this.handlers=[],this.handlersByElement=new Map,this._active=!1}isEmpty(){return!this._active}add(e,r,o,n=!1,i=!1){let{handlers:s,handlersByElement:a}=this,c={...tY,...o},l=a.get(c.srcElement);l||(l=[],a.set(c.srcElement,l));let f={type:e,handler:r,srcElement:c.srcElement,priority:c.priority};n&&(f.once=!0),i&&(f.passive=!0),s.push(f),this._active=this._active||!f.passive;let u=l.length-1;for(;u>=0&&!(l[u].priority>=f.priority);)u--;l.splice(u+1,0,f)}remove(e,r){let{handlers:o,handlersByElement:n}=this;for(let i=o.length-1;i>=0;i--){let s=o[i];if(s.type===e&&s.handler===r){o.splice(i,1);let a=n.get(s.srcElement);a.splice(a.indexOf(s),1),a.length===0&&n.delete(s.srcElement)}}this._active=o.some(i=>!i.passive)}_emit(e,r){let o=this.handlersByElement.get(r);if(o){let n=!1,i=()=>{e.handled=!0},s=()=>{e.handled=!0,n=!0},a=[];for(let c=0;c<o.length;c++){let{type:l,handler:f,once:u}=o[c];if(f({...e,type:l,stopPropagation:i,stopImmediatePropagation:s}),u&&a.push(o[c]),n)break}for(let c=0;c<a.length;c++){let{type:l,handler:f}=a[c];this.remove(l,f)}}}_normalizeEvent(e){let r=this.eventManager.getElement();return{...e,...OI(e),...FI(e,r),preventDefault:()=>{e.srcEvent.preventDefault()},stopImmediatePropagation:null,stopPropagation:null,handled:!1,rootElement:r}}};function rY(t){if("recognizer"in t)return t;let e,r=Array.isArray(t)?[...t]:[t];if(typeof r[0]=="function"){let o=r.shift(),n=r.shift()||{};e=new o(n)}else e=r.shift();return{recognizer:e,recognizeWith:typeof r[0]=="string"?[r[0]]:r[0],requireFailure:typeof r[1]=="string"?[r[1]]:r[1]}}var zf=class{constructor(e=null,r={}){if(this._onBasicInput=o=>{this.manager.emit(o.srcEvent.type,o)},this._onOtherEvent=o=>{this.manager.emit(o.type,o)},this.options={recognizers:[],events:{},touchAction:"compute",tabIndex:0,cssProps:{},...r},this.events=new Map,this.element=e,!!e){this.manager=new Vf(e,this.options);for(let o of this.options.recognizers){let{recognizer:n,recognizeWith:i,requireFailure:s}=rY(o);this.manager.add(n),i&&n.recognizeWith(i),s&&n.requireFailure(s)}this.manager.on("hammer.input",this._onBasicInput),this.wheelInput=new rg(e,this._onOtherEvent,{enable:!1}),this.moveInput=new og(e,this._onOtherEvent,{enable:!1}),this.keyInput=new ng(e,this._onOtherEvent,{enable:!1,tabIndex:r.tabIndex}),this.contextmenuInput=new ig(e,this._onOtherEvent,{enable:!1}),this.on(this.options.events)}}getElement(){return this.element}destroy(){this.element&&(this.wheelInput.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy())}on(e,r,o){this._addEventHandler(e,r,o,!1)}once(e,r,o){this._addEventHandler(e,r,o,!0)}watch(e,r,o){this._addEventHandler(e,r,o,!1,!0)}off(e,r){this._removeEventHandler(e,r)}_toggleRecognizer(e,r){let{manager:o}=this;if(!o)return;let n=o.get(e);n&&(n.set({enable:r}),o.touchAction.update()),this.wheelInput?.enableEventType(e,r),this.moveInput?.enableEventType(e,r),this.keyInput?.enableEventType(e,r),this.contextmenuInput?.enableEventType(e,r)}_addEventHandler(e,r,o,n,i){if(typeof e!="string"){o=r;for(let[l,f]of Object.entries(e))this._addEventHandler(l,f,o,n,i);return}let{manager:s,events:a}=this;if(!s)return;let c=a.get(e);if(!c){let l=this._getRecognizerName(e)||e;c=new sg(this,l),a.set(e,c),s&&s.on(e,c.handleEvent)}c.add(e,r,o,n,i),c.isEmpty()||this._toggleRecognizer(c.recognizerName,!0)}_removeEventHandler(e,r){if(typeof e!="string"){for(let[i,s]of Object.entries(e))this._removeEventHandler(i,s);return}let{events:o}=this,n=o.get(e);if(n&&(n.remove(e,r),n.isEmpty())){let{recognizerName:i}=n,s=!1;for(let a of o.values())if(a.recognizerName===i&&!a.isEmpty()){s=!0;break}s||this._toggleRecognizer(i,!1)}}_getRecognizerName(e){return this.manager.recognizers.find(r=>r.getEventNames().includes(e))?.options.event}};var Be={DEFAULT:"default",LNGLAT:"lnglat",METER_OFFSETS:"meter-offsets",LNGLAT_OFFSETS:"lnglat-offsets",CARTESIAN:"cartesian"};Object.defineProperty(Be,"IDENTITY",{get:()=>(N.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),Be.CARTESIAN)});var ft={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},Pe={common:0,meters:1,pixels:2},Ja={click:"onClick",dblclick:"onClick",panstart:"onDragStart",panmove:"onDrag",panend:"onDragEnd"},Sv={multipan:[ii,{threshold:10,direction:Le.Vertical,pointers:2}],pinch:[Za,{},null,["multipan"]],pan:[ii,{threshold:1},["pinch"],["multipan"]],dblclick:[cs,{event:"dblclick",taps:2}],click:[cs,{event:"click"},null,["dblclick"]]},NI={DRAW:"draw",MASK:"mask",TERRAIN:"terrain"};function oY(t,e){if(t===e)return!0;if(Array.isArray(t)){let r=t.length;if(!e||e.length!==r)return!1;for(let o=0;o<r;o++)if(t[o]!==e[o])return!1;return!0}return!1}function Yt(t){let e={},r;return o=>{for(let n in o)if(!oY(o[n],e[n])){r=t(o),e=o;break}return r}}var DI=[0,0,0,0],nY=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],UI=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],iY=[0,0,0],kI=[0,0,0],sY={default:-1,cartesian:0,lnglat:1,"meter-offsets":2,"lnglat-offsets":3};function ls(t){let e=sY[t];if(e===void 0)throw new Error(`Invalid coordinateSystem: ${t}`);return e}var aY=Yt(lY);function Cv(t,e,r=kI){r.length<3&&(r=[r[0],r[1],0]);let o=r,n,i=!0;switch(e==="lnglat-offsets"||e==="meter-offsets"?n=r:n=t.isGeospatial?[Math.fround(t.longitude),Math.fround(t.latitude),0]:null,t.projectionMode){case ft.WEB_MERCATOR:(e==="lnglat"||e==="cartesian")&&(n=[0,0,0],i=!1);break;case ft.WEB_MERCATOR_AUTO_OFFSET:e==="lnglat"?o=n:e==="cartesian"&&(o=[Math.fround(t.center[0]),Math.fround(t.center[1]),0],n=t.unprojectPosition(o),o[0]-=r[0],o[1]-=r[1],o[2]-=r[2]);break;case ft.IDENTITY:o=t.position.map(Math.fround),o[2]=o[2]||0;break;case ft.GLOBE:i=!1,n=null;break;default:i=!1}return{geospatialOrigin:n,shaderCoordinateOrigin:o,offsetMode:i}}function cY(t,e,r){let{viewMatrixUncentered:o,projectionMatrix:n}=t,{viewMatrix:i,viewProjectionMatrix:s}=t,a=DI,c=DI,l=t.cameraPosition,{geospatialOrigin:f,shaderCoordinateOrigin:u,offsetMode:d}=Cv(t,e,r);return d&&(c=t.projectPosition(f||u),l=[l[0]-c[0],l[1]-c[1],l[2]-c[2]],c[3]=1,a=Nt.transformMat4([],c,s),i=o||i,s=je.multiply([],n,i),s=je.multiply([],s,nY)),{viewMatrix:i,viewProjectionMatrix:s,projectionCenter:a,originCommon:c,cameraPosCommon:l,shaderCoordinateOrigin:u,geospatialOrigin:f}}function ag({viewport:t,devicePixelRatio:e=1,modelMatrix:r=null,coordinateSystem:o="default",coordinateOrigin:n=kI,autoWrapLongitude:i=!1}){o==="default"&&(o=t.isGeospatial?"lnglat":"cartesian");let s=aY({viewport:t,devicePixelRatio:e,coordinateSystem:o,coordinateOrigin:n});return s.wrapLongitude=i,s.modelMatrix=r||UI,s}function lY({viewport:t,devicePixelRatio:e,coordinateSystem:r,coordinateOrigin:o}){let{projectionCenter:n,viewProjectionMatrix:i,originCommon:s,cameraPosCommon:a,shaderCoordinateOrigin:c,geospatialOrigin:l}=cY(t,r,o),f=t.getDistanceScales(),u=[t.width*e,t.height*e],d=Nt.transformMat4([],[0,0,-t.focalDistance,1],t.projectionMatrix)[3]||1,h={coordinateSystem:ls(r),projectionMode:t.projectionMode,coordinateOrigin:c,commonOrigin:s.slice(0,3),center:n,pseudoMeters:Boolean(t._pseudoMeters),viewportSize:u,devicePixelRatio:e,focalDistance:d,commonUnitsPerMeter:f.unitsPerMeter,commonUnitsPerWorldUnit:f.unitsPerMeter,commonUnitsPerWorldUnit2:iY,scale:t.scale,wrapLongitude:!1,viewProjectionMatrix:i,modelMatrix:UI,cameraPosition:a};if(l){let p=t.getDistanceScales(l);switch(r){case"meter-offsets":h.commonUnitsPerWorldUnit=p.unitsPerMeter,h.commonUnitsPerWorldUnit2=p.unitsPerMeter2;break;case"lnglat":case"lnglat-offsets":t._pseudoMeters||(h.commonUnitsPerMeter=p.unitsPerMeter),h.commonUnitsPerWorldUnit=p.unitsPerDegree,h.commonUnitsPerWorldUnit2=p.unitsPerDegree2;break;case"cartesian":h.commonUnitsPerWorldUnit=[1,1,p.unitsPerMeter[2]],h.commonUnitsPerWorldUnit2=[0,0,p.unitsPerMeter2[2]];break;default:break}}return h}var fY=["default","lnglat","meter-offsets","lnglat-offsets","cartesian"],uY=fY.map(t=>`const COORDINATE_SYSTEM_${t.toUpperCase().replaceAll("-","_")}: i32 = ${ls(t)};`).join(""),dY=Object.keys(ft).map(t=>`const PROJECTION_MODE_${t}: i32 = ${ft[t]};`).join(""),hY=Object.keys(Pe).map(t=>`const UNIT_${t.toUpperCase()}: i32 = ${Pe[t]};`).join(""),pY=`${uY} ${dY} ${hY} const TILE_SIZE: f32 = 512.0; const PI: f32 = 3.1415926536; const WORLD_SCALE: f32 = TILE_SIZE / (PI * 2.0); const ZERO_64_LOW: vec3<f32> = vec3<f32>(0.0, 0.0, 0.0); const EARTH_RADIUS: f32 = 6370972.0; // meters const GLOBE_RADIUS: f32 = 256.0; // ----------------------------------------------------------------------------- // Uniform block (converted from GLSL uniform block) // ----------------------------------------------------------------------------- struct ProjectUniforms { wrapLongitude: i32, coordinateSystem: i32, commonUnitsPerMeter: vec3<f32>, projectionMode: i32, scale: f32, commonUnitsPerWorldUnit: vec3<f32>, commonUnitsPerWorldUnit2: vec3<f32>, center: vec4<f32>, modelMatrix: mat4x4<f32>, viewProjectionMatrix: mat4x4<f32>, viewportSize: vec2<f32>, devicePixelRatio: f32, focalDistance: f32, cameraPosition: vec3<f32>, coordinateOrigin: vec3<f32>, commonOrigin: vec3<f32>, pseudoMeters: i32, }; @group(0) @binding(auto) var<uniform> project: ProjectUniforms; // ----------------------------------------------------------------------------- // Geometry data shared across the project helpers. // The active layer shader is responsible for populating this private module // state before calling the project functions below. // ----------------------------------------------------------------------------- // Structure to carry additional geometry data used by deck.gl filters. struct Geometry { worldPosition: vec3<f32>, worldPositionAlt: vec3<f32>, position: vec4<f32>, normal: vec3<f32>, uv: vec2<f32>, pickingColor: vec3<f32>, }; var<private> geometry: Geometry; `,VI=`${pY} // ----------------------------------------------------------------------------- // Functions // ----------------------------------------------------------------------------- // Returns an adjustment factor for commonUnitsPerMeter fn _project_size_at_latitude(lat: f32) -> f32 { let y = clamp(lat, -89.9, 89.9); return 1.0 / cos(radians(y)); } // Overloaded version: scales a value in meters at a given latitude. fn _project_size_at_latitude_m(meters: f32, lat: f32) -> f32 { return meters * project.commonUnitsPerMeter.z * _project_size_at_latitude(lat); } // Computes a non-linear scale factor based on geometry. // (Note: This function relies on "geometry" being provided.) fn project_size() -> f32 { if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR && project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT && project.pseudoMeters == 0) { if (geometry.position.w == 0.0) { return _project_size_at_latitude(geometry.worldPosition.y); } let y: f32 = geometry.position.y / TILE_SIZE * 2.0 - 1.0; let y2 = y * y; let y4 = y2 * y2; let y6 = y4 * y2; return 1.0 + 4.9348 * y2 + 4.0587 * y4 + 1.5642 * y6; } return 1.0; } // Overloads to scale offsets (meters to world units) fn project_size_float(meters: f32) -> f32 { return meters * project.commonUnitsPerMeter.z * project_size(); } fn project_size_vec2(meters: vec2<f32>) -> vec2<f32> { return meters * project.commonUnitsPerMeter.xy * project_size(); } fn project_size_vec3(meters: vec3<f32>) -> vec3<f32> { return meters * project.commonUnitsPerMeter * project_size(); } fn project_size_vec4(meters: vec4<f32>) -> vec4<f32> { return vec4<f32>(meters.xyz * project.commonUnitsPerMeter, meters.w); } // Returns a rotation matrix aligning the z\u2011axis with the given up vector. fn project_get_orientation_matrix(up: vec3<f32>) -> mat3x3<f32> { let uz = normalize(up); let ux = select( vec3<f32>(1.0, 0.0, 0.0), normalize(vec3<f32>(uz.y, -uz.x, 0.0)), abs(uz.z) == 1.0 ); let uy = cross(uz, ux); return mat3x3<f32>(ux, uy, uz); } // Since WGSL does not support "out" parameters, we return a struct. struct RotationResult { needsRotation: bool, transform: mat3x3<f32>, }; fn project_needs_rotation(commonPosition: vec3<f32>) -> RotationResult { if (project.projectionMode == PROJECTION_MODE_GLOBE) { return RotationResult(true, project_get_orientation_matrix(commonPosition)); } else { return RotationResult(false, mat3x3<f32>()); // identity alternative if needed }; } // Projects a normal vector from the current coordinate system to world space. fn project_normal(vector: vec3<f32>) -> vec3<f32> { let normal_modelspace = project.modelMatrix * vec4<f32>(vector, 0.0); var n = normalize(normal_modelspace.xyz * project.commonUnitsPerMeter); let rotResult = project_needs_rotation(geometry.position.xyz); if (rotResult.needsRotation) { n = rotResult.transform * n; } return n; } // Applies a scale offset based on y-offset (dy) fn project_offset_(offset: vec4<f32>) -> vec4<f32> { let dy: f32 = offset.y; let commonUnitsPerWorldUnit = project.commonUnitsPerWorldUnit + project.commonUnitsPerWorldUnit2 * dy; return vec4<f32>(offset.xyz * commonUnitsPerWorldUnit, offset.w); } // Projects lng/lat coordinates to a unit tile [0,1] fn project_mercator_(lnglat: vec2<f32>) -> vec2<f32> { var x = lnglat.x; if (project.wrapLongitude != 0) { x = ((x + 180.0) % 360.0) - 180.0; } let y = clamp(lnglat.y, -89.9, 89.9); return vec2<f32>( radians(x) + PI, PI + log(tan(PI * 0.25 + radians(y) * 0.5)) ) * WORLD_SCALE; } // Projects lng/lat/z coordinates for a globe projection. fn project_globe_(lnglatz: vec3<f32>) -> vec3<f32> { let lambda = radians(lnglatz.x); let phi = radians(lnglatz.y); let cosPhi = cos(phi); let D = (lnglatz.z / EARTH_RADIUS + 1.0) * GLOBE_RADIUS; return vec3<f32>( sin(lambda) * cosPhi, -cos(lambda) * cosPhi, sin(phi) ) * D; } // Projects positions (with an optional 64-bit low part) from the input // coordinate system to the common space. fn project_position_vec4_f64(position: vec4<f32>, position64Low: vec3<f32>) -> vec4<f32> { var position_world = project.modelMatrix * position; // Work around for a Mac+NVIDIA bug: if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR) { if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) { return vec4<f32>( project_mercator_(position_world.xy), _project_size_at_latitude_m(position_world.z, position_world.y), position_world.w ); } if (project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN) { position_world = vec4f(position_world.xyz + project.coordinateOrigin, position_world.w); } } if (project.projectionMode == PROJECTION_MODE_GLOBE) { if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) { return vec4<f32>( project_globe_(position_world.xyz), position_world.w ); } } if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) { if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) { if (abs(position_world.y - project.coordinateOrigin.y) > 0.25) { return vec4<f32>( project_mercator_(position_world.xy) - project.commonOrigin.xy, project_size_float(position_world.z), position_world.w ); } } } if (project.projectionMode == PROJECTION_MODE_IDENTITY || (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET && (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT || project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN))) { position_world = vec4f(position_world.xyz - project.coordinateOrigin, position_world.w); } return project_offset_(position_world) + project_offset_(project.modelMatrix * vec4<f32>(position64Low, 0.0)); } // Overloaded versions for different input types. fn project_position_vec4_f32(position: vec4<f32>) -> vec4<f32> { return project_position_vec4_f64(position, ZERO_64_LOW); } fn project_position_vec3_f64(position: vec3<f32>, position64Low: vec3<f32>) -> vec3<f32> { let projected_position = project_position_vec4_f64(vec4<f32>(position, 1.0), position64Low); return projected_position.xyz; } fn project_position_vec3_f32(position: vec3<f32>) -> vec3<f32> { let projected_position = project_position_vec4_f64(vec4<f32>(position, 1.0), ZERO_64_LOW); return projected_position.xyz; } fn project_position_vec2_f32(position: vec2<f32>) -> vec2<f32> { let projected_position = project_position_vec4_f64(vec4<f32>(position, 0.0, 1.0), ZERO_64_LOW); return projected_position.xy; } // Transforms a common space position to clip space. fn project_common_position_to_clipspace_with_projection(position: vec4<f32>, viewProjectionMatrix: mat4x4<f32>, center: vec4<f32>) -> vec4<f32> { return viewProjectionMatrix * position + center; } // Uses the project viewProjectionMatrix and center. fn project_common_position_to_clipspace(position: vec4<f32>) -> vec4<f32> { return project_common_position_to_clipspace_with_projection(position, project.viewProjectionMatrix, project.center); } // Returns a clip space offset corresponding to a given number of screen pixels. fn project_pixel_size_to_clipspace(pixels: vec2<f32>) -> vec2<f32> { let offset = pixels / project.viewportSize * project.devicePixelRatio * 2.0; return offset * project.focalDistance; } fn project_meter_size_to_pixel(meters: f32) -> f32 { return project_size_float(meters) * project.scale; } fn project_unit_size_to_pixel(size: f32, unit: i32) -> f32 { if (unit == UNIT_METERS) { return project_meter_size_to_pixel(size); } else if (unit == UNIT_COMMON) { return size * project.scale; } // UNIT_PIXELS: no scaling applied. return size; } fn project_pixel_size_float(pixels: f32) -> f32 { return pixels / project.scale; } fn project_pixel_size_vec2(pixels: vec2<f32>) -> vec2<f32> { return pixels / project.scale; } `;var mY=["default","lnglat","meter-offsets","lnglat-offsets","cartesian"],gY=mY.map(t=>`const int COORDINATE_SYSTEM_${t.toUpperCase().replaceAll("-","_")} = ${ls(t)};`).join(""),_Y=Object.keys(ft).map(t=>`const int PROJECTION_MODE_${t} = ${ft[t]};`).join(""),yY=Object.keys(Pe).map(t=>`const int UNIT_${t.toUpperCase()} = ${Pe[t]};`).join(""),zI=`${gY} ${_Y} ${yY} layout(std140) uniform projectUniforms { bool wrapLongitude; int coordinateSystem; vec3 commonUnitsPerMeter; int projectionMode; float scale; vec3 commonUnitsPerWorldUnit; vec3 commonUnitsPerWorldUnit2; vec4 center; mat4 modelMatrix; mat4 viewProjectionMatrix; vec2 viewportSize; float devicePixelRatio; float focalDistance; vec3 cameraPosition; vec3 coordinateOrigin; vec3 commonOrigin; bool pseudoMeters; } project; const float TILE_SIZE = 512.0; const float PI = 3.1415926536; const float WORLD_SCALE = TILE_SIZE / (PI * 2.0); const vec3 ZERO_64_LOW = vec3(0.0); const float EARTH_RADIUS = 6370972.0; const float GLOBE_RADIUS = 256.0; float project_size_at_latitude(float lat) { float y = clamp(lat, -89.9, 89.9); return 1.0 / cos(radians(y)); } float project_size() { if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR && project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT && project.pseudoMeters == false) { if (geometry.position.w == 0.0) { return project_size_at_latitude(geometry.worldPosition.y); } float y = geometry.position.y / TILE_SIZE * 2.0 - 1.0; float y2 = y * y; float y4 = y2 * y2; float y6 = y4 * y2; return 1.0 + 4.9348 * y2 + 4.0587 * y4 + 1.5642 * y6; } return 1.0; } float project_size_at_latitude(float meters, float lat) { return meters * project.commonUnitsPerMeter.z * project_size_at_latitude(lat); } float project_size(float meters) { return meters * project.commonUnitsPerMeter.z * project_size(); } vec2 project_size(vec2 meters) { return meters * project.commonUnitsPerMeter.xy * project_size(); } vec3 project_size(vec3 meters) { return meters * project.commonUnitsPerMeter * project_size(); } vec4 project_size(vec4 meters) { return vec4(meters.xyz * project.commonUnitsPerMeter, meters.w); } mat3 project_get_orientation_matrix(vec3 up) { vec3 uz = normalize(up); vec3 ux = abs(uz.z) == 1.0 ? vec3(1.0, 0.0, 0.0) : normalize(vec3(uz.y, -uz.x, 0)); vec3 uy = cross(uz, ux); return mat3(ux, uy, uz); } bool project_needs_rotation(vec3 commonPosition, out mat3 transform) { if (project.projectionMode == PROJECTION_MODE_GLOBE) { transform = project_get_orientation_matrix(commonPosition); return true; } return false; } vec3 project_normal(vec3 vector) { vec4 normal_modelspace = project.modelMatrix * vec4(vector, 0.0); vec3 n = normalize(normal_modelspace.xyz * project.commonUnitsPerMeter); mat3 rotation; if (project_needs_rotation(geometry.position.xyz, rotation)) { n = rotation * n; } return n; } vec4 project_offset_(vec4 offset) { float dy = offset.y; vec3 commonUnitsPerWorldUnit = project.commonUnitsPerWorldUnit + project.commonUnitsPerWorldUnit2 * dy; return vec4(offset.xyz * commonUnitsPerWorldUnit, offset.w); } vec2 project_mercator_(vec2 lnglat) { float x = lnglat.x; if (project.wrapLongitude) { x = mod(x + 180., 360.0) - 180.; } float y = clamp(lnglat.y, -89.9, 89.9); return vec2( radians(x) + PI, PI + log(tan_fp32(PI * 0.25 + radians(y) * 0.5)) ) * WORLD_SCALE; } vec3 project_globe_(vec3 lnglatz) { float lambda = radians(lnglatz.x); float phi = radians(lnglatz.y); float cosPhi = cos(phi); float D = (lnglatz.z / EARTH_RADIUS + 1.0) * GLOBE_RADIUS; return vec3( sin(lambda) * cosPhi, -cos(lambda) * cosPhi, sin(phi) ) * D; } vec4 project_position(vec4 position, vec3 position64Low) { vec4 position_world = project.modelMatrix * position; if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR) { if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) { return vec4( project_mercator_(position_world.xy), project_size_at_latitude(position_world.z, position_world.y), position_world.w ); } if (project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN) { position_world.xyz += project.coordinateOrigin; } } if (project.projectionMode == PROJECTION_MODE_GLOBE) { if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) { return vec4( project_globe_(position_world.xyz), position_world.w ); } } if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) { if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) { if (abs(position_world.y - project.coordinateOrigin.y) > 0.25) { return vec4( project_mercator_(position_world.xy) - project.commonOrigin.xy, project_size(position_world.z), position_world.w ); } } } if (project.projectionMode == PROJECTION_MODE_IDENTITY || (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET && (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT || project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN))) { position_world.xyz -= project.coordinateOrigin; } return project_offset_(position_world) + project_offset_(project.modelMatrix * vec4(position64Low, 0.0)); } vec4 project_position(vec4 position) { return project_position(position, ZERO_64_LOW); } vec3 project_position(vec3 position, vec3 position64Low) { vec4 projected_position = project_position(vec4(position, 1.0), position64Low); return projected_position.xyz; } vec3 project_position(vec3 position) { vec4 projected_position = project_position(vec4(position, 1.0), ZERO_64_LOW); return projected_position.xyz; } vec2 project_position(vec2 position) { vec4 projected_position = project_position(vec4(position, 0.0, 1.0), ZERO_64_LOW); return projected_position.xy; } vec4 project_common_position_to_clipspace(vec4 position, mat4 viewProjectionMatrix, vec4 center) { return viewProjectionMatrix * position + center; } vec4 project_common_position_to_clipspace(vec4 position) { return project_common_position_to_clipspace(position, project.viewProjectionMatrix, project.center); } vec2 project_pixel_size_to_clipspace(vec2 pixels) { vec2 offset = pixels / project.viewportSize * project.devicePixelRatio * 2.0; return offset * project.focalDistance; } float project_size_to_pixel(float meters) { return project_size(meters) * project.scale; } vec2 project_size_to_pixel(vec2 meters) { return project_size(meters) * project.scale; } float project_size_to_pixel(float size, int unit) { if (unit == UNIT_METERS) return project_size_to_pixel(size); if (unit == UNIT_COMMON) return size * project.scale; return size; } float project_pixel_size(float pixels) { return pixels / project.scale; } vec2 project_pixel_size(vec2 pixels) { return pixels / project.scale; } `;var xY={};function bY(t=xY){return"viewport"in t?ag(t):{}}var We={name:"project",dependencies:[mT,Km],source:VI,vs:zI,getUniforms:bY,uniformTypes:{wrapLongitude:"f32",coordinateSystem:"i32",commonUnitsPerMeter:"vec3<f32>",projectionMode:"i32",scale:"f32",commonUnitsPerWorldUnit:"vec3<f32>",commonUnitsPerWorldUnit2:"vec3<f32>",center:"vec4<f32>",modelMatrix:"mat4x4<f32>",viewProjectionMatrix:"mat4x4<f32>",viewportSize:"vec2<f32>",devicePixelRatio:"f32",focalDistance:"f32",cameraPosition:"vec3<f32>",coordinateOrigin:"vec3<f32>",commonOrigin:"vec3<f32>",pseudoMeters:"f32"}};var AY=`// Define a structure to hold both the clip-space position and the common position. struct ProjectResult { clipPosition: vec4<f32>, commonPosition: vec4<f32>, }; // This function mimics the GLSL version with the 'out' parameter by returning both values. fn project_position_to_clipspace_and_commonspace( position: vec3<f32>, position64Low: vec3<f32>, offset: vec3<f32> ) -> ProjectResult { // Compute the projected position. let projectedPosition: vec3<f32> = project_position_vec3_f64(position, position64Low); // Start with the provided offset. var finalOffset: vec3<f32> = offset; // Get whether a rotation is needed and the rotation matrix. let rotationResult = project_needs_rotation(projectedPosition); // If rotation is needed, update the offset. if (rotationResult.needsRotation) { finalOffset = rotationResult.transform * offset; } // Compute the common position. let commonPosition: vec4<f32> = vec4<f32>(projectedPosition + finalOffset, 1.0); // Convert to clip-space. let clipPosition: vec4<f32> = project_common_position_to_clipspace(commonPosition); return ProjectResult(clipPosition, commonPosition); } // A convenience overload that returns only the clip-space position. fn project_position_to_clipspace( position: vec3<f32>, position64Low: vec3<f32>, offset: vec3<f32> ) -> vec4<f32> { return project_position_to_clipspace_and_commonspace(position, position64Low, offset).clipPosition; } `,TY=`vec4 project_position_to_clipspace( vec3 position, vec3 position64Low, vec3 offset, out vec4 commonPosition ) { vec3 projectedPosition = project_position(position, position64Low); mat3 rotation; if (project_needs_rotation(projectedPosition, rotation)) { // offset is specified as ENU // when in globe projection, rotate offset so that the ground alighs with the surface of the globe offset = rotation * offset; } commonPosition = vec4(projectedPosition + offset, 1.0); return project_common_position_to_clipspace(commonPosition); } vec4 project_position_to_clipspace( vec3 position, vec3 position64Low, vec3 offset ) { vec4 commonPosition; return project_position_to_clipspace(position, position64Low, offset, commonPosition); } `,fe={name:"project32",dependencies:[We],source:AY,vs:TY};function Ev(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function si(t,e){let r=Nt.transformMat4([],e,t);return Nt.scale(r,r,1/r[3]),r}function HI(t,e,r){return r*e+(1-r)*t}function Hf(t,e,r){return t<e?e:t>r?r:t}function vY(t){return Math.log(t)*Math.LOG2E}var jf=Math.log2||vY;function Kr(t,e){if(!t)throw new Error(e||"@math.gl/web-mercator: assertion failed.")}var qr=Math.PI,jI=qr/4,Pr=qr/180,wv=180/qr,Qa=512,cg=4003e4,Ut=85.051129,WI=1.5;function Wf(t){return Math.pow(2,t)}function lg(t){return jf(t)}function Oe(t){let[e,r]=t;Kr(Number.isFinite(e)),Kr(Number.isFinite(r)&&r>=-90&&r<=90,"invalid latitude");let o=e*Pr,n=r*Pr,i=Qa*(o+qr)/(2*qr),s=Qa*(qr+Math.log(Math.tan(jI+n*.5)))/(2*qr);return[i,s]}function pt(t){let[e,r]=t,o=e/Qa*(2*qr)-qr,n=2*(Math.atan(Math.exp(r/Qa*(2*qr)-qr))-jI);return[o*wv,n*wv]}function Gf(t){let{latitude:e}=t;Kr(Number.isFinite(e));let r=Math.cos(e*Pr);return lg(cg*r)-9}function fs(t){let e=Math.cos(t*Pr);return Qa/cg/e}function ec(t){let{latitude:e,longitude:r,highPrecision:o=!1}=t;Kr(Number.isFinite(e)&&Number.isFinite(r));let n=Qa,i=Math.cos(e*Pr),s=n/360,a=s/i,c=n/cg/i,l={unitsPerMeter:[c,c,c],metersPerUnit:[1/c,1/c,1/c],unitsPerDegree:[s,a,c],degreesPerUnit:[1/s,1/a,1/c]};if(o){let f=Pr*Math.tan(e*Pr)/i,u=s*f/2,d=n/cg*f,h=d/a*c;l.unitsPerDegree2=[0,u,d],l.unitsPerMeter2=[h,0,h]}return l}function $f(t,e){let[r,o,n]=t,[i,s,a]=e,{unitsPerMeter:c,unitsPerMeter2:l}=ec({longitude:r,latitude:o,highPrecision:!0}),f=Oe(t);f[0]+=i*(c[0]+l[0]*s),f[1]+=s*(c[1]+l[1]*s);let u=pt(f),d=(n||0)+(a||0);return Number.isFinite(n)||Number.isFinite(a)?[u[0],u[1],d]:u}function fg(t){let{height:e,pitch:r,bearing:o,altitude:n,scale:i,center:s}=t,a=Ev();je.translate(a,a,[0,0,-n]),je.rotateX(a,a,-r*Pr),je.rotateZ(a,a,o*Pr);let c=i/e;return je.scale(a,a,[c,c,c]),s&&je.translate(a,a,Ke.negate([],s)),a}function Pv(t){let{width:e,height:r,altitude:o,pitch:n=0,offset:i,center:s,scale:a,nearZMultiplier:c=1,farZMultiplier:l=1}=t,{fovy:f=cn(WI)}=t;o!==void 0&&(f=cn(o));let u=f*Pr,d=n*Pr,h=ln(f),p=h;s&&(p+=s[2]*a/Math.cos(d)/r);let m=u*(.5+(i?i[1]:0)/r),g=Math.sin(m)*p/Math.sin(Hf(Math.PI/2-d-m,.01,Math.PI-.01)),_=Math.sin(d)*g+p,x=p*10,y=Math.min(_*l,x);return{fov:u,aspect:e/r,focalDistance:h,near:c,far:y}}function cn(t){return 2*Math.atan(.5/t)*wv}function ln(t){return .5/Math.tan(.5*t*Pr)}function tc(t,e){let[r,o,n=0]=t;return Kr(Number.isFinite(r)&&Number.isFinite(o)&&Number.isFinite(n)),si(e,[r,o,n,1])}function Mr(t,e,r=0){let[o,n,i]=t;if(Kr(Number.isFinite(o)&&Number.isFinite(n),"invalid pixel coordinate"),Number.isFinite(i))return si(e,[o,n,i,1]);let s=si(e,[o,n,0,1]),a=si(e,[o,n,1,1]),c=s[2],l=a[2],f=c===l?0:((r||0)-c)/(l-c);return Ye.lerp([],s,a,f)}function ug(t){let{width:e,height:r,bounds:o,minExtent:n=0,maxZoom:i=24,offset:s=[0,0]}=t,[[a,c],[l,f]]=o,u=SY(t.padding),d=Oe([a,Hf(f,-Ut,Ut)]),h=Oe([l,Hf(c,-Ut,Ut)]),p=[Math.max(Math.abs(h[0]-d[0]),n),Math.max(Math.abs(h[1]-d[1]),n)],m=[e-u.left-u.right-Math.abs(s[0])*2,r-u.top-u.bottom-Math.abs(s[1])*2];Kr(m[0]>0&&m[1]>0);let g=m[0]/p[0],_=m[1]/p[1],x=(u.right-u.left)/2/g,y=(u.top-u.bottom)/2/_,b=[(h[0]+d[0])/2+x,(h[1]+d[1])/2+y],T=pt(b),v=Math.min(i,jf(Math.abs(Math.min(g,_))));return Kr(Number.isFinite(v)),{longitude:T[0],latitude:T[1],zoom:v}}function SY(t=0){return typeof t=="number"?{top:t,bottom:t,left:t,right:t}:(Kr(Number.isFinite(t.top)&&Number.isFinite(t.bottom)&&Number.isFinite(t.left)&&Number.isFinite(t.right)),t)}var GI=Math.PI/180;function dg(t,e=0){let{width:r,height:o,unproject:n}=t,i={targetZ:e},s=n([0,o],i),a=n([r,o],i),c,l,f=t.fovy?.5*t.fovy*GI:Math.atan(.5/t.altitude),u=(90-t.pitch)*GI;return f>u-.01?(c=$I(t,0,e),l=$I(t,r,e)):(c=n([0,0],i),l=n([r,0],i)),[s,a,l,c]}function $I(t,e,r){let{pixelUnprojectionMatrix:o}=t,n=si(o,[e,0,1,1]),i=si(o,[e,t.height,1,1]),a=(r*t.distanceScales.unitsPerMeter[2]-n[2])/(i[2]-n[2]),c=Ye.lerp([],n,i,a),l=pt(c);return l.push(r),l}var XI=.01,EY=["longitude","latitude","zoom"],YI={curve:1.414,speed:1.2};function Mv(t,e,r,o){let{startZoom:n,startCenterXY:i,uDelta:s,w0:a,u1:c,S:l,rho:f,rho2:u,r0:d}=KI(t,e,o);if(c<XI){let b={};for(let T of EY){let v=t[T],w=e[T];b[T]=HI(v,w,r)}return b}let h=r*l,p=Math.cosh(d)/Math.cosh(d+f*h),m=a*((Math.cosh(d)*Math.tanh(d+f*h)-Math.sinh(d))/u)/c,g=1/p,_=n+lg(g),x=Ye.scale([],s,m);Ye.add(x,x,i);let y=pt(x);return{longitude:y[0],latitude:y[1],zoom:_}}function Rv(t,e,r){let o={...YI,...r},{screenSpeed:n,speed:i,maxDuration:s}=o,{S:a,rho:c}=KI(t,e,o),l=1e3*a,f;return Number.isFinite(n)?f=l/(n/c):f=l/i,Number.isFinite(s)&&f>s?0:f}function KI(t,e,r){r=Object.assign({},YI,r);let o=r.curve,n=t.zoom,i=[t.longitude,t.latitude],s=Wf(n),a=e.zoom,c=[e.longitude,e.latitude],l=Wf(a-n),f=Oe(i),u=Oe(c),d=Ye.sub([],u,f),h=Math.max(t.width,t.height),p=h/l,m=Ye.length(d)*s,g=Math.max(m,XI),_=o*o,x=(p*p-h*h+_*_*g*g)/(2*h*_*g),y=(p*p-h*h-_*_*g*g)/(2*p*_*g),b=Math.log(Math.sqrt(x*x+1)-x),T=Math.log(Math.sqrt(y*y+1)-y),v=(T-b)/o;return{startZoom:n,startCenterXY:f,uDelta:d,w0:h,u1:m,S:v,rho:o,rho2:_,r0:b,r1:T}}var qI=` layout(std140) uniform shadowUniforms { bool drawShadowMap; bool useShadowMap; vec4 color; highp int lightId; float lightCount; mat4 viewProjectionMatrix0; mat4 viewProjectionMatrix1; vec4 projectCenter0; vec4 projectCenter1; } shadow; `,PY=` const int max_lights = 2; out vec3 shadow_vPosition[max_lights]; vec4 shadow_setVertexPosition(vec4 position_commonspace) { mat4 viewProjectionMatrices[max_lights]; viewProjectionMatrices[0] = shadow.viewProjectionMatrix0; viewProjectionMatrices[1] = shadow.viewProjectionMatrix1; vec4 projectCenters[max_lights]; projectCenters[0] = shadow.projectCenter0; projectCenters[1] = shadow.projectCenter1; if (shadow.drawShadowMap) { return project_common_position_to_clipspace(position_commonspace, viewProjectionMatrices[shadow.lightId], projectCenters[shadow.lightId]); } if (shadow.useShadowMap) { for (int i = 0; i < max_lights; i++) { if(i < int(shadow.lightCount)) { vec4 shadowMap_position = project_common_position_to_clipspace(position_commonspace, viewProjectionMatrices[i], projectCenters[i]); shadow_vPosition[i] = (shadowMap_position.xyz / shadowMap_position.w + 1.0) / 2.0; } } } return gl_Position; } `,MY=` ${qI} ${PY} `,RY=` const int max_lights = 2; uniform sampler2D shadow_uShadowMap0; uniform sampler2D shadow_uShadowMap1; in vec3 shadow_vPosition[max_lights]; const vec4 bitPackShift = vec4(1.0, 255.0, 65025.0, 16581375.0); const vec4 bitUnpackShift = 1.0 / bitPackShift; const vec4 bitMask = vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0); float shadow_getShadowWeight(vec3 position, sampler2D shadowMap) { vec4 rgbaDepth = texture(shadowMap, position.xy); float z = dot(rgbaDepth, bitUnpackShift); return smoothstep(0.001, 0.01, position.z - z); } vec4 shadow_filterShadowColor(vec4 color) { if (shadow.drawShadowMap) { vec4 rgbaDepth = fract(gl_FragCoord.z * bitPackShift); rgbaDepth -= rgbaDepth.gbaa * bitMask; return rgbaDepth; } if (shadow.useShadowMap) { float shadowAlpha = 0.0; shadowAlpha += shadow_getShadowWeight(shadow_vPosition[0], shadow_uShadowMap0); if(shadow.lightCount > 1.0) { shadowAlpha += shadow_getShadowWeight(shadow_vPosition[1], shadow_uShadowMap1); } shadowAlpha *= shadow.color.a / shadow.lightCount; float blendedAlpha = shadowAlpha + color.a * (1.0 - shadowAlpha); return vec4( mix(color.rgb, shadow.color.rgb, shadowAlpha / blendedAlpha), blendedAlpha ); } return color; } `,IY=` ${qI} ${RY} `,LY=Yt(DY),BY=Yt(UY),OY=[0,0,0,1],FY=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0];function NY(t,e){let[r,o,n]=t,i=Mr([r,o,n],e);return Number.isFinite(n)?i:[i[0],i[1],0]}function DY({viewport:t,center:e}){return new V(t.viewProjectionMatrix).invert().transform(e)}function UY({viewport:t,shadowMatrices:e}){let r=[],o=t.pixelUnprojectionMatrix,n=t.isGeospatial?void 0:1,i=[[0,0,n],[t.width,0,n],[0,t.height,n],[t.width,t.height,n],[0,0,-1],[t.width,0,-1],[0,t.height,-1],[t.width,t.height,-1]].map(s=>NY(s,o));for(let s of e){let a=s.clone().translate(new E(t.center).negate()),c=i.map(f=>a.transform(f)),l=new V().ortho({left:Math.min(...c.map(f=>f[0])),right:Math.max(...c.map(f=>f[0])),bottom:Math.min(...c.map(f=>f[1])),top:Math.max(...c.map(f=>f[1])),near:Math.min(...c.map(f=>-f[2])),far:Math.max(...c.map(f=>-f[2]))});r.push(l.multiplyRight(s))}return r}function kY(t){let{shadowEnabled:e=!0,project:r}=t;if(!e||!r||!t.shadowMatrices||!t.shadowMatrices.length)return{drawShadowMap:!1,useShadowMap:!1,shadow_uShadowMap0:t.dummyShadowMap,shadow_uShadowMap1:t.dummyShadowMap};let o=We.getUniforms(r),n=LY({viewport:r.viewport,center:o.center}),i=[],s=BY({shadowMatrices:t.shadowMatrices,viewport:r.viewport}).slice();for(let c=0;c<t.shadowMatrices.length;c++){let l=s[c],f=l.clone().translate(new E(r.viewport.center).negate());o.coordinateSystem===ls("lnglat")&&o.projectionMode===ft.WEB_MERCATOR?(s[c]=f,i[c]=n):(s[c]=l.clone().multiplyRight(FY),i[c]=f.transform(n))}let a={drawShadowMap:Boolean(t.drawToShadowMap),useShadowMap:t.shadowMaps?t.shadowMaps.length>0:!1,color:t.shadowColor||OY,lightId:t.shadowLightId||0,lightCount:t.shadowMatrices.length,shadow_uShadowMap0:t.dummyShadowMap,shadow_uShadowMap1:t.dummyShadowMap};for(let c=0;c<s.length;c++)a[`viewProjectionMatrix${c}`]=s[c],a[`projectCenter${c}`]=i[c];for(let c=0;c<2;c++)a[`shadow_uShadowMap${c}`]=t.shadowMaps&&t.shadowMaps[c]||t.dummyShadowMap;return a}var rc={name:"shadow",dependencies:[We],vs:MY,fs:IY,inject:{"vs:DECKGL_FILTER_GL_POSITION":` position = shadow_setVertexPosition(geometry.position); `,"fs:DECKGL_FILTER_COLOR":` color = shadow_filterShadowColor(color); `},getUniforms:kY,uniformTypes:{drawShadowMap:"f32",useShadowMap:"f32",color:"vec4<f32>",lightId:"i32",lightCount:"f32",viewProjectionMatrix0:"mat4x4<f32>",viewProjectionMatrix1:"mat4x4<f32>",projectCenter0:"vec4<f32>",projectCenter1:"vec4<f32>"}};var VY=`struct pickingUniforms { isActive: f32, isAttribute: f32, isHighlightActive: f32, useByteColors: f32, highlightedObjectColor: vec3<f32>, highlightColor: vec4<f32>, }; @group(0) @binding(auto) var<uniform> picking: pickingUniforms; fn picking_normalizeColor(color: vec3<f32>) -> vec3<f32> { return select(color, color / 255.0, picking.useByteColors > 0.5); } fn picking_normalizeColor4(color: vec4<f32>) -> vec4<f32> { return select(color, color / 255.0, picking.useByteColors > 0.5); } fn picking_isColorZero(color: vec3<f32>) -> bool { return dot(color, vec3<f32>(1.0)) < 0.00001; } fn picking_isColorValid(color: vec3<f32>) -> bool { return dot(color, vec3<f32>(1.0)) > 0.00001; } `,Se={...vm,source:VY,defaultUniforms:{...vm.defaultUniforms,useByteColors:!0},inject:{"vs:DECKGL_FILTER_GL_POSITION":` // for picking depth values picking_setPickingAttribute(position.z / position.w); `,"vs:DECKGL_FILTER_COLOR":` picking_setPickingColor(geometry.pickingColor); `,"fs:DECKGL_FILTER_COLOR":{order:99,injection:` // use highlight color if this fragment belongs to the selected object. color = picking_filterHighlightColor(color); // use picking color if rendering to picking FBO. color = picking_filterPickingColor(color); `}}};var zY=[Km],HY=["vs:DECKGL_FILTER_SIZE(inout vec3 size, VertexGeometry geometry)","vs:DECKGL_FILTER_GL_POSITION(inout vec4 position, VertexGeometry geometry)","vs:DECKGL_FILTER_COLOR(inout vec4 color, VertexGeometry geometry)","fs:DECKGL_FILTER_COLOR(inout vec4 color, FragmentGeometry geometry)"],jY=[];function hg(t){let e=Zn.getDefaultShaderAssembler();for(let o of zY)e.addDefaultModule(o);e._hookFunctions.length=0;let r=t==="glsl"?HY:jY;for(let o of r)e.addShaderHook(o);return e}var WY=[255,255,255],GY=1,$Y=0,oc=class{constructor(e={}){this.type="ambient";let{color:r=WY}=e,{intensity:o=GY}=e;this.id=e.id||`ambient-${$Y++}`,this.color=r,this.intensity=o}};var XY=[255,255,255],YY=1,KY=[0,0,-1],qY=0,fn=class{constructor(e={}){this.type="directional";let{color:r=XY}=e,{intensity:o=YY}=e,{direction:n=KY}=e,{_shadow:i=!1}=e;this.id=e.id||`directional-${qY++}`,this.color=r,this.intensity=o,this.type="directional",this.direction=new E(n).normalize().toArray(),this.shadow=i}getProjectedLight(e){return this}};var us=class{constructor(e,r={id:"pass"}){let{id:o}=r;this.id=o,this.device=e,this.props={...r}}setProps(e){Object.assign(this.props,e)}render(e){}cleanup(){}};var ZY={depthWriteEnabled:!0,depthCompare:"less-equal",blendColorOperation:"add",blendColorSrcFactor:"src-alpha",blendColorDstFactor:"one",blendAlphaOperation:"add",blendAlphaSrcFactor:"one-minus-dst-alpha",blendAlphaDstFactor:"one"},At=class extends us{constructor(){super(...arguments),this._lastRenderIndex=-1}render(e){this._render(e)}_render(e){let r=this.device.canvasContext,o=e.target??r.getCurrentFramebuffer(),[n,i]=r.getDrawingBufferSize(),s=e.clearCanvas??!0,a=e.clearColor??(s?[0,0,0,0]:!1),c=s?1:!1,l=s?0:!1,f=e.colorMask??15,u={viewport:[0,0,n,i]};e.colorMask&&(u.colorMask=f),e.scissorRect&&(u.scissorRect=e.scissorRect);let d=this.device.beginRenderPass({framebuffer:o,parameters:u,clearColor:a,clearDepth:c,clearStencil:l});try{return this._drawLayers(d,e)}finally{d.end(),this.device.submit()}}_drawLayers(e,r){let{target:o,shaderModuleProps:n,viewports:i,views:s,onViewportActive:a,clearStack:c=!0}=r;r.pass=r.pass||"unknown",c&&(this._lastRenderIndex=-1);let l=[];for(let f of i){let u=s&&s[f.id];a?.(f);let d=this._getDrawLayerParams(f,r),h=f.subViewports||[f];for(let p of h){let m=this._drawLayersInViewport(e,{target:o,shaderModuleProps:n,viewport:p,view:u,pass:r.pass,layers:r.layers,isPicking:r.isPicking},d);l.push(m)}}return l}_getDrawLayerParams(e,{layers:r,pass:o,isPicking:n=!1,layerFilter:i,cullRect:s,views:a,effects:c,shaderModuleProps:l},f=!1){let u=[],d=JI(this._lastRenderIndex+1),h={layer:r[0],viewport:e,isPicking:n,renderPass:o,cullRect:s},p={};for(let m=0;m<r.length;m++){let g=r[m],_=this._shouldDrawLayer(g,h,i,p),x={shouldDrawLayer:_};if(_&&!f){x.shouldDrawLayer=!0,x.layerRenderIndex=d(g,_),x.shaderModuleProps=this._getShaderModuleProps(g,c,o,l);let y=g.context.device.type==="webgpu"?ZY:null;x.layerParameters={...y,...g.context.deck?.props.parameters,...a?.[e.id]?.props.parameters,...this.getLayerParameters(g,m,e)}}u[m]=x}return u}_drawLayersInViewport(e,{layers:r,shaderModuleProps:o,pass:n,target:i,viewport:s,view:a,isPicking:c},l){let f=JY(this.device,{shaderModuleProps:o,target:i,viewport:s});if(a){let{clear:d,clearColor:h,clearDepth:p,clearStencil:m}=a.props;if(d){let g=[0,0,0,0],_=1,x=0;Array.isArray(h)&&!c?g=[...h.slice(0,3),h[3]||255].map(b=>b/255):h===!1&&(g=!1),p!==void 0&&(_=p),m!==void 0&&(x=m),this.device.beginRenderPass({framebuffer:i,parameters:{viewport:f,scissorRect:f},clearColor:g,clearDepth:_,clearStencil:x}).end()}}let u={totalCount:r.length,visibleCount:0,compositeCount:0,pickableCount:0};e.setParameters({viewport:f});for(let d=0;d<r.length;d++){let h=r[d],p=l[d],{shouldDrawLayer:m}=p;if(m&&h.props.pickable&&u.pickableCount++,h.isComposite&&u.compositeCount++,h.isDrawable&&p.shouldDrawLayer){let{layerRenderIndex:g,shaderModuleProps:_,layerParameters:x}=p;u.visibleCount++,this._lastRenderIndex=Math.max(this._lastRenderIndex,g),_.project&&(_.project.viewport=s),h.context.renderPass=e;try{h._drawLayer({renderPass:e,shaderModuleProps:_,uniforms:{layerIndex:g},parameters:x})}catch(y){h.raiseError(y,`drawing ${h} to ${n}`)}}}return u}shouldDrawLayer(e){return!0}getShaderModuleProps(e,r,o){return null}getLayerParameters(e,r,o){return e.props.parameters}_shouldDrawLayer(e,r,o,n){if(!(e.props.visible&&this.shouldDrawLayer(e)))return!1;r.layer=e;let s=e.parent;for(;s;){if(!s.props.visible||!s.filterSubLayer(r))return!1;r.layer=s,s=s.parent}if(o){let a=r.layer.id;if(a in n||(n[a]=o(r)),!n[a])return!1}return e.activateViewport(r.viewport),!0}_getShaderModuleProps(e,r,o,n){let i=this.device.canvasContext.cssToDeviceRatio(),s=e.internalState?.propsInTransition||e.props,a={layer:s,picking:{isActive:!1},project:{viewport:e.context.viewport,devicePixelRatio:i,modelMatrix:s.modelMatrix,coordinateSystem:s.coordinateSystem,coordinateOrigin:s.coordinateOrigin,autoWrapLongitude:e.wrapLongitude}};if(r)for(let c of r)ZI(a,c.getShaderModuleProps?.(e,a));for(let c of e.context.defaultShaderModules)c.name in a||(a[c.name]={});return ZI(a,this.getShaderModuleProps(e,r,a),n)}};function JI(t=0,e={}){let r={},o=(n,i)=>{let s=n.props._offset,a=n.id,c=n.parent&&n.parent.id,l;if(c&&!(c in e)&&o(n.parent,!1),c in r){let f=r[c]=r[c]||JI(e[c],e);l=f(n,i),r[a]=f}else Number.isFinite(s)?(l=s+(e[c]||0),r[a]=null):l=t;return i&&l>=t&&(t=l+1),e[a]=l,l};return o}function JY(t,{shaderModuleProps:e,target:r,viewport:o}){let n=e?.project?.devicePixelRatio??t.canvasContext.cssToDeviceRatio(),[,i]=t.canvasContext.getDrawingBufferSize(),s=r?r.height:i,a=o;return[a.x*n,s-(a.y+a.height)*n,a.width*n,a.height*n]}function ZI(t,...e){for(let r of e)if(r)for(let o in r)t[o]?Object.assign(t[o],r[o]):t[o]=r[o];return t}var Xf=class extends At{constructor(e,r){super(e,r);let o=e.createTexture({format:"rgba8unorm",width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),n=e.createTexture({format:"depth16unorm",width:1,height:1});this.fbo=e.createFramebuffer({id:"shadowmap",width:1,height:1,colorAttachments:[o],depthStencilAttachment:n})}delete(){this.fbo&&(this.fbo.destroy(),this.fbo=null)}getShadowMap(){return this.fbo.colorAttachments[0].texture}render(e){let r=this.fbo,o=this.device.canvasContext.cssToDeviceRatio(),n=e.viewports[0],i=n.width*o,s=n.height*o,a=[1,1,1,1];(i!==r.width||s!==r.height)&&r.resize({width:i,height:s}),super.render({...e,clearColor:a,target:r,pass:"shadow"})}getLayerParameters(e,r,o){return{...e.props.parameters,blend:!1,depthWriteEnabled:!0,depthCompare:"less-equal"}}shouldDrawLayer(e){return e.props.shadowEnabled!==!1}getShaderModuleProps(e,r,o){return{shadow:{project:o.project,drawToShadowMap:!0}}}};var QY={color:[255,255,255],intensity:1},QI=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],eK=[0,0,0,200/255],ai=class{constructor(e={}){this.id="lighting-effect",this.shadowColor=eK,this.shadow=!1,this.directionalLights=[],this.pointLights=[],this.shadowPasses=[],this.dummyShadowMap=null,this.setProps(e)}setup(e){this.context=e;let{device:r,deck:o}=e;this.shadow&&!this.dummyShadowMap&&(this._createShadowPasses(r),o._addDefaultShaderModule(rc),this.dummyShadowMap=r.createTexture({width:1,height:1}))}setProps(e){this.ambientLight=void 0,this.directionalLights=[],this.pointLights=[];for(let r in e){let o=e[r];switch(o.type){case"ambient":this.ambientLight=o;break;case"directional":this.directionalLights.push(o);break;case"point":this.pointLights.push(o);break;default:}}this._applyDefaultLights(),this.shadow=this.directionalLights.some(r=>r.shadow),this.context&&this.setup(this.context),this.props=e}preRender({layers:e,layerFilter:r,viewports:o,onViewportActive:n,views:i}){if(this.shadow){this.shadowMatrices=this._calculateMatrices();for(let s=0;s<this.shadowPasses.length;s++)this.shadowPasses[s].render({layers:e,layerFilter:r,viewports:o,onViewportActive:n,views:i,shaderModuleProps:{shadow:{shadowLightId:s,dummyShadowMap:this.dummyShadowMap,shadowMatrices:this.shadowMatrices}}})}}getShaderModuleProps(e,r){let o=this.shadow?{project:r.project,shadowMaps:this.shadowPasses.map(s=>s.getShadowMap()),dummyShadowMap:this.dummyShadowMap,shadowColor:this.shadowColor,shadowMatrices:this.shadowMatrices}:{},n={enabled:!0,lights:this._getLights(e)},i=e.props.material;return{shadow:o,lighting:n,phongMaterial:i,gouraudMaterial:i}}cleanup(e){for(let r of this.shadowPasses)r.delete();this.shadowPasses.length=0,this.dummyShadowMap&&(this.dummyShadowMap.destroy(),this.dummyShadowMap=null,e.deck._removeDefaultShaderModule(rc))}_calculateMatrices(){let e=[];for(let r of this.directionalLights){let o=new V().lookAt({eye:new E(r.direction).negate()});e.push(o)}return e}_createShadowPasses(e){for(let r=0;r<this.directionalLights.length;r++){let o=new Xf(e);this.shadowPasses[r]=o}}_applyDefaultLights(){let{ambientLight:e,pointLights:r,directionalLights:o}=this;!e&&r.length===0&&o.length===0&&(this.ambientLight=new oc(QY),this.directionalLights.push(new fn(QI[0]),new fn(QI[1])))}_getLights(e){let r=[];this.ambientLight&&r.push(this.ambientLight);for(let o of this.pointLights)r.push(o.getProjectedLight({layer:e}));for(let o of this.directionalLights)r.push(o.getProjectedLight({layer:e}));return r}};var Iv=class{constructor(e={}){this._pool=[],this.opts={overAlloc:2,poolSize:100},this.setOptions(e)}setOptions(e){Object.assign(this.opts,e)}allocate(e,r,{size:o=1,type:n,padding:i=0,copy:s=!1,initialize:a=!1,maxCount:c}){let l=n||e&&e.constructor||Float32Array,f=r*o+i;if(ArrayBuffer.isView(e)){if(f<=e.length)return e;if(f*e.BYTES_PER_ELEMENT<=e.buffer.byteLength)return new l(e.buffer,0,f)}let u=1/0;c&&(u=c*o+i);let d=this._allocate(l,f,a,u);return e&&s?d.set(e):a||d.fill(0,0,4),this._release(e),d}release(e){this._release(e)}_allocate(e,r,o,n){let i=Math.max(Math.ceil(r*this.opts.overAlloc),1);i>n&&(i=n);let s=this._pool,a=e.BYTES_PER_ELEMENT*i,c=s.findIndex(l=>l.byteLength>=a);if(c>=0){let l=new e(s.splice(c,1)[0],0,i);return o&&l.fill(0),l}return new e(i)}_release(e){if(!ArrayBuffer.isView(e))return;let r=this._pool,{buffer:o}=e,{byteLength:n}=o,i=r.findIndex(s=>s.byteLength>=n);i<0?r.push(o):(i>0||r.length<this.opts.poolSize)&&r.splice(i,0,o),r.length>this.opts.poolSize&&r.shift()}},Zr=new Iv;function ic(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Ro(t,e){let r=t%e;return r<0?e+r:r}function t3(t){return[t[12],t[13],t[14]]}function r3(t){let e=t[10],r=t[14];return{near:r/(e-1),far:r/(e+1)}}function o3(t){return{left:nc(t[3]+t[0],t[7]+t[4],t[11]+t[8],t[15]+t[12]),right:nc(t[3]-t[0],t[7]-t[4],t[11]-t[8],t[15]-t[12]),bottom:nc(t[3]+t[1],t[7]+t[5],t[11]+t[9],t[15]+t[13]),top:nc(t[3]-t[1],t[7]-t[5],t[11]-t[9],t[15]-t[13]),near:nc(t[3]+t[2],t[7]+t[6],t[11]+t[10],t[15]+t[14]),far:nc(t[3]-t[2],t[7]-t[6],t[11]-t[10],t[15]-t[14])}}var e3=new E;function nc(t,e,r,o){e3.set(t,e,r);let n=e3.len();return{distance:o/n,normal:new E(-t/n,-e/n,-r/n)}}function sc(t){return t-Math.fround(t)}var Yf;function pg(t,e){let{size:r=1,startIndex:o=0}=e,n=e.endIndex!==void 0?e.endIndex:t.length,i=(n-o)/r;Yf=Zr.allocate(Yf,i,{type:Float32Array,size:r*2});let s=o,a=0;for(;s<n;){for(let c=0;c<r;c++){let l=t[s++];Yf[a+c]=l,Yf[a+c+r]=sc(l)}a+=r*2}return Yf.subarray(0,i*r*2)}function n3(t){let e=null,r=!1;for(let o of t)o&&(e?(r||(e=[[e[0][0],e[0][1]],[e[1][0],e[1][1]]],r=!0),e[0][0]=Math.min(e[0][0],o[0][0]),e[0][1]=Math.min(e[0][1],o[0][1]),e[1][0]=Math.max(e[1][0],o[1][0]),e[1][1]=Math.max(e[1][1],o[1][1])):e=o);return e}var tK=Math.PI/180,rK=ic(),i3=[0,0,0],oK={unitsPerMeter:[1,1,1],metersPerUnit:[1,1,1]};function nK({width:t,height:e,orthographic:r,fovyRadians:o,focalDistance:n,padding:i,near:s,far:a}){let c=t/e,l=r?new V().orthographic({fovy:o,aspect:c,focalDistance:n,near:s,far:a}):new V().perspective({fovy:o,aspect:c,near:s,far:a});if(i){let{left:f=0,right:u=0,top:d=0,bottom:h=0}=i,p=ee((f+t-u)/2,0,t)-t/2,m=ee((d+e-h)/2,0,e)-e/2;l[8]-=p*2/t,l[9]+=m*2/e}return l}var ac=class{constructor(e={}){this._frustumPlanes={},this.id=e.id||this.constructor.displayName||"viewport",this.x=e.x||0,this.y=e.y||0,this.width=e.width||1,this.height=e.height||1,this.zoom=e.zoom||0,this.padding=e.padding,this.distanceScales=e.distanceScales||oK,this.focalDistance=e.focalDistance||1,this.position=e.position||i3,this.modelMatrix=e.modelMatrix||null;let{longitude:r,latitude:o}=e;this.isGeospatial=Number.isFinite(o)&&Number.isFinite(r),this._initProps(e),this._initMatrices(e),this.equals=this.equals.bind(this),this.project=this.project.bind(this),this.unproject=this.unproject.bind(this),this.projectPosition=this.projectPosition.bind(this),this.unprojectPosition=this.unprojectPosition.bind(this),this.projectFlat=this.projectFlat.bind(this),this.unprojectFlat=this.unprojectFlat.bind(this)}get subViewports(){return null}get metersPerPixel(){return this.distanceScales.metersPerUnit[2]/this.scale}get projectionMode(){return this.isGeospatial?this.zoom<12?ft.WEB_MERCATOR:ft.WEB_MERCATOR_AUTO_OFFSET:ft.IDENTITY}equals(e){return e instanceof ac?this===e?!0:e.width===this.width&&e.height===this.height&&e.scale===this.scale&&Ce(e.projectionMatrix,this.projectionMatrix)&&Ce(e.viewMatrix,this.viewMatrix):!1}project(e,{topLeft:r=!0}={}){let o=this.projectPosition(e),n=tc(o,this.pixelProjectionMatrix),[i,s]=n,a=r?s:this.height-s;return e.length===2?[i,a]:[i,a,n[2]]}unproject(e,{topLeft:r=!0,targetZ:o}={}){let[n,i,s]=e,a=r?i:this.height-i,c=o&&o*this.distanceScales.unitsPerMeter[2],l=Mr([n,a,s],this.pixelUnprojectionMatrix,c),[f,u,d]=this.unprojectPosition(l);return Number.isFinite(s)?[f,u,d]:Number.isFinite(o)?[f,u,o]:[f,u]}projectPosition(e){let[r,o]=this.projectFlat(e),n=(e[2]||0)*this.distanceScales.unitsPerMeter[2];return[r,o,n]}unprojectPosition(e){let[r,o]=this.unprojectFlat(e),n=(e[2]||0)*this.distanceScales.metersPerUnit[2];return[r,o,n]}projectFlat(e){if(this.isGeospatial){let r=Oe(e);return r[1]=ee(r[1],-318,830),r}return e}unprojectFlat(e){return this.isGeospatial?pt(e):e}getBounds(e={}){let r={targetZ:e.z||0},o=this.unproject([0,0],r),n=this.unproject([this.width,0],r),i=this.unproject([0,this.height],r),s=this.unproject([this.width,this.height],r);return[Math.min(o[0],n[0],i[0],s[0]),Math.min(o[1],n[1],i[1],s[1]),Math.max(o[0],n[0],i[0],s[0]),Math.max(o[1],n[1],i[1],s[1])]}getDistanceScales(e){return e&&this.isGeospatial?ec({longitude:e[0],latitude:e[1],highPrecision:!0}):this.distanceScales}containsPixel({x:e,y:r,width:o=1,height:n=1}){return e<this.x+this.width&&this.x<e+o&&r<this.y+this.height&&this.y<r+n}getFrustumPlanes(){return this._frustumPlanes.near?this._frustumPlanes:(Object.assign(this._frustumPlanes,o3(this.viewProjectionMatrix)),this._frustumPlanes)}panByPosition(e,r,o){return null}_initProps(e){let r=e.longitude,o=e.latitude;this.isGeospatial&&(Number.isFinite(e.zoom)||(this.zoom=Gf({latitude:o})+Math.log2(this.focalDistance)),this.distanceScales=e.distanceScales||ec({latitude:o,longitude:r}));let n=Math.pow(2,this.zoom);this.scale=n;let{position:i,modelMatrix:s}=e,a=i3;if(i&&(a=s?new V(s).transformAsVector(i,[]):i),this.isGeospatial){let c=this.projectPosition([r,o,0]);this.center=new E(a).scale(this.distanceScales.unitsPerMeter).add(c)}else this.center=this.projectPosition(a)}_initMatrices(e){let{viewMatrix:r=rK,projectionMatrix:o=null,orthographic:n=!1,fovyRadians:i,fovy:s=75,near:a=.1,far:c=1e3,padding:l=null,focalDistance:f=1}=e;this.viewMatrixUncentered=r,this.viewMatrix=new V().multiplyRight(r).translate(new E(this.center).negate()),this.projectionMatrix=o||nK({width:this.width,height:this.height,orthographic:n,fovyRadians:i||s*tK,focalDistance:f,padding:l,near:a,far:c});let u=ic();je.multiply(u,u,this.projectionMatrix),je.multiply(u,u,this.viewMatrix),this.viewProjectionMatrix=u,this.viewMatrixInverse=je.invert([],this.viewMatrix)||this.viewMatrix,this.cameraPosition=t3(this.viewMatrixInverse);let d=ic(),h=ic();je.scale(d,d,[this.width/2,-this.height/2,1]),je.translate(d,d,[1,-1,0]),je.multiply(h,d,this.viewProjectionMatrix),this.pixelProjectionMatrix=h,this.pixelUnprojectionMatrix=je.invert(ic(),this.pixelProjectionMatrix),this.pixelUnprojectionMatrix||N.warn("Pixel project matrix not invertible")()}};ac.displayName="Viewport";var ot=ac;var ds=class extends ot{constructor(e={}){let{latitude:r=0,longitude:o=0,zoom:n=0,pitch:i=0,bearing:s=0,nearZMultiplier:a=.1,farZMultiplier:c=1.01,nearZ:l,farZ:f,orthographic:u=!1,projectionMatrix:d,repeat:h=!1,worldOffset:p=0,position:m,padding:g,legacyMeterSizes:_=!1}=e,{width:x,height:y,altitude:b=1.5}=e,T=Math.pow(2,n);x=x||1,y=y||1;let v,w=null;if(d)b=d[5]/2,v=cn(b);else{e.fovy?(v=e.fovy,b=ln(v)):v=cn(b);let S;if(g){let{top:A=0,bottom:M=0}=g;S=[0,ee((A+y-M)/2,0,y)-y/2]}w=Pv({width:x,height:y,scale:T,center:m&&[0,0,m[2]*fs(r)],offset:S,pitch:i,fovy:v,nearZMultiplier:a,farZMultiplier:c}),Number.isFinite(l)&&(w.near=l),Number.isFinite(f)&&(w.far=f)}let C=fg({height:y,pitch:i,bearing:s,scale:T,altitude:b});p&&(C=new V().translate([512*p,0,0]).multiplyLeft(C)),super({...e,width:x,height:y,viewMatrix:C,longitude:o,latitude:r,zoom:n,...w,fovy:v,focalDistance:b}),this.latitude=r,this.longitude=o,this.zoom=n,this.pitch=i,this.bearing=s,this.altitude=b,this.fovy=v,this.orthographic=u,this._subViewports=h?[]:null,this._pseudoMeters=_,Object.freeze(this)}get subViewports(){if(this._subViewports&&!this._subViewports.length){let e=this.getBounds(),r=Math.floor((e[0]+180)/360),o=Math.ceil((e[2]-180)/360);for(let n=r;n<=o;n++){let i=n?new ds({...this,worldOffset:n}):this;this._subViewports.push(i)}}return this._subViewports}projectPosition(e){if(this._pseudoMeters)return super.projectPosition(e);let[r,o]=this.projectFlat(e),n=(e[2]||0)*fs(e[1]);return[r,o,n]}unprojectPosition(e){if(this._pseudoMeters)return super.unprojectPosition(e);let[r,o]=this.unprojectFlat(e),n=(e[2]||0)/fs(o);return[r,o,n]}addMetersToLngLat(e,r){return $f(e,r)}panByPosition(e,r,o){let n=Mr(r,this.pixelUnprojectionMatrix),i=this.projectFlat(e),s=Ye.add([],i,Ye.negate([],n)),a=Ye.add([],this.center,s),[c,l]=this.unprojectFlat(a);return{longitude:c,latitude:l}}panByPosition3D(e,r){let o=e[2]||0,n=Ye.sub([],e,this.unproject(r,{targetZ:o}));return{longitude:this.longitude+n[0],latitude:this.latitude+n[1]}}getBounds(e={}){let r=dg(this,e.z||0);return[Math.min(r[0][0],r[1][0],r[2][0],r[3][0]),Math.min(r[0][1],r[1][1],r[2][1],r[3][1]),Math.max(r[0][0],r[1][0],r[2][0],r[3][0]),Math.max(r[0][1],r[1][1],r[2][1],r[3][1])]}fitBounds(e,r={}){let{width:o,height:n}=this,{longitude:i,latitude:s,zoom:a}=ug({width:o,height:n,bounds:e,...r});return new ds({width:o,height:n,longitude:i,latitude:s,zoom:a})}};ds.displayName="WebMercatorViewport";var Mt=ds;var s3=[0,0,0];function Lv(t,e,r=!1){let o=e.projectPosition(t);if(r&&e instanceof Mt){let[n,i,s=0]=t,a=e.getDistanceScales([n,i]);o[2]=s*a.unitsPerMeter[2]}return o}function iK(t){let{viewport:e,modelMatrix:r,coordinateOrigin:o}=t,{coordinateSystem:n,fromCoordinateSystem:i,fromCoordinateOrigin:s}=t;return n==="default"&&(n=e.isGeospatial?"lnglat":"cartesian"),i===void 0?i=n:i==="default"&&(i=e.isGeospatial?"lnglat":"cartesian"),s===void 0&&(s=o),{viewport:e,coordinateSystem:n,coordinateOrigin:o,modelMatrix:r,fromCoordinateSystem:i,fromCoordinateOrigin:s}}function mg(t,{viewport:e,modelMatrix:r,coordinateSystem:o,coordinateOrigin:n,offsetMode:i}){let[s,a,c=0]=t;switch(r&&([s,a,c]=Nt.transformMat4([],[s,a,c,1],r)),o){case"default":return mg(t,{viewport:e,modelMatrix:r,coordinateSystem:e.isGeospatial?"lnglat":"cartesian",coordinateOrigin:n,offsetMode:i});case"lnglat":return Lv([s,a,c],e,i);case"lnglat-offsets":return Lv([s+n[0],a+n[1],c+(n[2]||0)],e,i);case"meter-offsets":return Lv($f(n,[s,a,c]),e,i);case"cartesian":return e.isGeospatial?[s+n[0],a+n[1],c+n[2]]:e.projectPosition([s,a,c]);default:throw new Error(`Invalid coordinateSystem: ${o}`)}}function gg(t,e){let{viewport:r,coordinateSystem:o,coordinateOrigin:n,modelMatrix:i,fromCoordinateSystem:s,fromCoordinateOrigin:a}=iK(e),{autoOffset:c=!0}=e,{geospatialOrigin:l=s3,shaderCoordinateOrigin:f=s3,offsetMode:u=!1}=c?Cv(r,o,n):{},d=mg(t,{viewport:r,modelMatrix:i,coordinateSystem:s,coordinateOrigin:a,offsetMode:u});if(u){let h=r.projectPosition(l||f);Ke.sub(d,d,h)}return d}var sK=[255,255,255],aK=1,cK=[1,0,0],lK=[0,0,1],fK=0,cc=class{constructor(e={}){this.type="point";let{color:r=sK}=e,{intensity:o=aK}=e,{position:n=lK}=e;this.id=e.id||`point-${fK++}`,this.color=r,this.intensity=o,this.type="point",this.position=n,this.attenuation=uK(e),this.projectedLight={...this}}getProjectedLight({layer:e}){let{projectedLight:r}=this,o=e.context.viewport,{coordinateSystem:n,coordinateOrigin:i}=e.props,s=gg(this.position,{viewport:o,coordinateSystem:n,coordinateOrigin:i,fromCoordinateSystem:o.isGeospatial?Be.LNGLAT:Be.CARTESIAN,fromCoordinateOrigin:[0,0,0]});return r.color=this.color,r.intensity=this.intensity,r.position=s,r}};function uK(t){return t.attenuation?t.attenuation:cK}var Kf=class extends cc{getProjectedLight({layer:e}){let{projectedLight:r}=this,o=e.context.viewport,{coordinateSystem:n,coordinateOrigin:i,modelMatrix:s}=e.props,{cameraPosition:a}=ag({viewport:o,modelMatrix:s,coordinateSystem:n,coordinateOrigin:i});return r.color=this.color,r.intensity=this.intensity,r.position=a,r}};var hs=Math.PI/180,dK=1e3*60*60*24,hK=2440588,pK=2451545,_g=hs*23.4397,mK=357.5291,gK=.98560028,_K=280.147,yK=360.9856235;function a3(t,e,r){let o=hs*-r,n=hs*e,i=bK(t),s=PK(i),a=CK(i,o)-s.rightAscension;return{azimuth:vK(a,n,s.declination),altitude:SK(a,n,s.declination)}}function yg(t,e,r){let{azimuth:o,altitude:n}=a3(t,e,r);return[Math.sin(o)*Math.cos(n),Math.cos(o)*Math.cos(n),-Math.sin(n)]}function xK(t){return(typeof t=="number"?t:t.getTime())/dK-.5+hK}function bK(t){return xK(t)-pK}function AK(t,e){let r=t;return Math.atan2(Math.sin(r)*Math.cos(_g)-Math.tan(e)*Math.sin(_g),Math.cos(r))}function TK(t,e){let r=t;return Math.asin(Math.sin(e)*Math.cos(_g)+Math.cos(e)*Math.sin(_g)*Math.sin(r))}function vK(t,e,r){let o=t,n=e,i=r;return Math.atan2(Math.sin(o),Math.cos(o)*Math.sin(n)-Math.tan(i)*Math.cos(n))}function SK(t,e,r){let o=t,n=e,i=r;return Math.asin(Math.sin(n)*Math.sin(i)+Math.cos(n)*Math.cos(i)*Math.cos(o))}function CK(t,e){return hs*(_K+yK*t)-e}function EK(t){return hs*(mK+gK*t)}function wK(t){let e=t,r=hs*(1.9148*Math.sin(e)+.02*Math.sin(2*e)+3e-4*Math.sin(3*e)),o=hs*102.9372;return e+r+o+Math.PI}function PK(t){let e=EK(t),r=wK(e);return{declination:TK(r,0),rightAscension:AK(r,0)}}var qf=class extends fn{constructor(e){super(e),this.timestamp=e.timestamp}getProjectedLight({layer:e}){let{viewport:r}=e.context;if(r.resolution&&r.resolution>0){let[n,i,s]=yg(this.timestamp,0,0);this.direction=[n,-s,i]}else{let{latitude:n,longitude:i}=r;this.direction=yg(this.timestamp,n,i)}return this}};var MK=1,RK=1,ps=class{time=0;channels=new Map;animations=new Map;playing=!1;lastEngineTime=-1;constructor(){}addChannel(e){let{delay:r=0,duration:o=Number.POSITIVE_INFINITY,rate:n=1,repeat:i=1}=e,s=MK++,a={time:0,delay:r,duration:o,rate:n,repeat:i};return this._setChannelTime(a,this.time),this.channels.set(s,a),s}removeChannel(e){this.channels.delete(e);for(let[r,o]of this.animations)o.channel===e&&this.detachAnimation(r)}isFinished(e){let r=this.channels.get(e);return r===void 0?!1:this.time>=r.delay+r.duration*r.repeat}getTime(e){if(e===void 0)return this.time;let r=this.channels.get(e);return r===void 0?-1:r.time}setTime(e){this.time=Math.max(0,e);let r=this.channels.values();for(let n of r)this._setChannelTime(n,this.time);let o=this.animations.values();for(let n of o){let{animation:i,channel:s}=n;i.setTime(this.getTime(s))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(e,r){let o=RK++;return this.animations.set(o,{animation:e,channel:r}),e.setTime(this.getTime(r)),o}detachAnimation(e){this.animations.delete(e)}update(e){this.playing&&(this.lastEngineTime===-1&&(this.lastEngineTime=e),this.setTime(this.time+(e-this.lastEngineTime)),this.lastEngineTime=e)}_setChannelTime(e,r){let o=r-e.delay,n=e.duration*e.repeat;o>=n?e.time=e.duration*e.rate:(e.time=Math.max(0,o)%e.duration,e.time*=e.rate)}};q();function c3(t){let e=typeof window<"u"?window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame:null;return e?e.call(window,t):setTimeout(()=>t(typeof performance<"u"?performance.now():Date.now()),1e3/60)}function l3(t){let e=typeof window<"u"?window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame:null;if(e){e.call(window,t);return}clearTimeout(t)}Xi();var IK=0,LK="Animation Loop",Bv=class{device=null;canvas=null;props;animationProps=null;timeline=null;stats;sharedStats;cpuTime;gpuTime;frameRate;display;_needsRedraw="initialized";_initialized=!1;_running=!1;_animationFrameId=null;_nextFramePromise=null;_resolveNextFrame=null;_cpuStartTime=0;_error=null;_lastFrameTime=0;constructor(e){if(this.props={...Bv.defaultAnimationLoopProps,...e},e=this.props,!e.device)throw new Error("No device provided");this.stats=e.stats||new Et({id:`animation-loop-${IK++}`}),this.sharedStats=Co.stats.get(LK),this.frameRate=this.stats.get("Frame Rate"),this.frameRate.setSampleSize(1),this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.setProps({autoResizeViewport:e.autoResizeViewport}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}destroy(){this.stop(),this._setDisplay(null),this.device?._disableDebugGPUTime()}delete(){this.destroy()}reportError(e){this.props.onError(e),this._error=e}setNeedsRedraw(e){return this._needsRedraw=this._needsRedraw||e,this}needsRedraw(){let e=this._needsRedraw;return this._needsRedraw=!1,e}setProps(e){return"autoResizeViewport"in e&&(this.props.autoResizeViewport=e.autoResizeViewport||!1),this}async start(){if(this._running)return this;this._running=!0;try{let e;if(!this._initialized){if(this._initialized=!0,await this._initDevice(),this._initialize(),!this._running)return null;await this.props.onInitialize(this._getAnimationProps())}return this._running?(e!==!1&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(e){let r=e instanceof Error?e:new Error("Unknown error");throw this.props.onError(r),r}}stop(){return this._running&&(this.animationProps&&!this._error&&this.props.onFinalize(this.animationProps),this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1,this._lastFrameTime=0),this}redraw(e){return this.device?.isLost||this._error?this:(this._beginFrameTimers(e),this._setupFrame(),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endFrameTimers(),this)}attachTimeline(e){return this.timeline=e,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(e=>{this._resolveNextFrame=e})),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw("toDataURL"),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw new Error("OffscreenCanvas")}_initialize(){this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeViewport(),this.device?._enableDebugGPUTime()}_setDisplay(e){this.display&&(this.display.destroy(),this.display.animationLoop=null),e&&(e.animationLoop=this),this.display=e}_requestAnimationFrame(){this._running&&(this._animationFrameId=c3(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&(l3(this._animationFrameId),this._animationFrameId=null)}_animationFrame(e){this._running&&(this.redraw(e),this._requestAnimationFrame())}_renderFrame(e){if(this.display){this.display._renderFrame(e);return}this.props.onRender(this._getAnimationProps()),this.device?.submit()}_clearNeedsRedraw(){this._needsRedraw=!1}_setupFrame(){this._resizeViewport()}_initializeAnimationProps(){let e=this.device?.getDefaultCanvasContext();if(!this.device||!e)throw new Error("loop");let r=e?.canvas,o=e.props.useDevicePixels;this.animationProps={animationLoop:this,device:this.device,canvasContext:e,canvas:r,useDevicePixels:o,timeline:this.timeline,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw new Error("animationProps");return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;let{width:e,height:r,aspect:o}=this._getSizeAndAspect();(e!==this.animationProps.width||r!==this.animationProps.height)&&this.setNeedsRedraw("drawing buffer resized"),o!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=e,this.animationProps.height=r,this.animationProps.aspect=o,this.animationProps.needsRedraw=this._needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){if(this.device=await this.props.device,!this.device)throw new Error("No device provided");this.canvas=this.device.getDefaultCanvasContext().canvas||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){let e=document.createElement("div");document.body.appendChild(e),e.style.position="relative";let r=document.createElement("div");r.style.position="absolute",r.style.left="10px",r.style.bottom="10px",r.style.width="300px",r.style.background="white",this.canvas instanceof HTMLCanvasElement&&e.appendChild(this.canvas),e.appendChild(r);let o=this.props.onAddHTML(r);o&&(r.innerHTML=o)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};let[e,r]=this.device.getDefaultCanvasContext().getDrawingBufferSize(),o=e>0&&r>0?e/r:1;return{width:e,height:r,aspect:o}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_beginFrameTimers(e){let r=e??(typeof performance<"u"?performance.now():Date.now());if(this._lastFrameTime){let o=r-this._lastFrameTime;o>0&&this.frameRate.addTime(o)}this._lastFrameTime=r,this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeStart()}_endFrameTimers(){this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeEnd(),this._updateSharedStats()}_consumeEncodedGpuTime(){if(!this.device)return;let e=this.device.commandEncoder._gpuTimeMs;e!==void 0&&(this.gpuTime.addTime(e),this.device.commandEncoder._gpuTimeMs=void 0)}_updateSharedStats(){if(this.stats!==this.sharedStats){for(let e of Object.keys(this.sharedStats.stats))this.stats.stats[e]||delete this.sharedStats.stats[e];this.stats.forEach(e=>{let r=this.sharedStats.get(e.name,e.type);r.sampleSize=e.sampleSize,r.time=e.time,r.count=e.count,r.samples=e.samples,r.lastTiming=e.lastTiming,r.lastSampleTime=e.lastSampleTime,r.lastSampleCount=e.lastSampleCount,r._count=e._count,r._time=e._time,r._samples=e._samples,r._startTime=e._startTime,r._timerPending=e._timerPending})}}_startEventHandling(){this.canvas&&(this.canvas.addEventListener("mousemove",this._onMousemove.bind(this)),this.canvas.addEventListener("mouseleave",this._onMouseleave.bind(this)))}_onMousemove(e){e instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[e.offsetX,e.offsetY])}_onMouseleave(e){this._getAnimationProps()._mousePosition=null}},lc=Bv;k(lc,"defaultAnimationLoopProps",{device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:e=>console.error(e),stats:void 0,autoResizeViewport:!1});q();q();var Ov={};function nt(t="id"){Ov[t]=Ov[t]||1;let e=Ov[t]++;return`${t}-${e}`}var xg=class{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(e){if(this.id=e.id||nt("geometry"),this.topology=e.topology,this.indices=e.indices||null,this.attributes=e.attributes,this.vertexCount=e.vertexCount,this.bufferLayout=e.bufferLayout||[],this.indices&&!(this.indices.usage&K.INDEX))throw new Error("Index buffer must have INDEX usage")}destroy(){this.indices?.destroy();for(let e of Object.values(this.attributes))e.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices||null}_calculateVertexCount(e){return e.byteLength/12}};function f3(t,e){if(e instanceof xg)return e;let r=BK(t,e),{attributes:o,bufferLayout:n}=OK(t,e);return new xg({topology:e.topology||"triangle-list",bufferLayout:n,vertexCount:e.vertexCount,indices:r,attributes:o})}function BK(t,e){if(!e.indices)return;let r=e.indices.value;return t.createBuffer({usage:K.INDEX,data:r})}function OK(t,e){let r=[],o={};for(let[i,s]of Object.entries(e.attributes)){let a=i;switch(i){case"POSITION":a="positions";break;case"NORMAL":a="normals";break;case"TEXCOORD_0":a="texCoords";break;case"TEXCOORD_1":a="texCoords1";break;case"COLOR_0":a="colors";break}if(s){o[a]=t.createBuffer({data:s.value,id:`${i}-buffer`});let{value:c,size:l,normalized:f}=s;if(l===void 0)throw new Error(`Attribute ${i} is missing a size`);r.push({name:a,format:tn.getVertexFormatFromAttribute(c,l,f)})}}let n=e._calculateVertexCount(e.attributes,e.indices);return{attributes:o,bufferLayout:r,vertexCount:n}}function u3(t,e){let r={},o="Values";if(t.attributes.length===0&&!t.varyings?.length)return{"No attributes or varyings":{[o]:"N/A"}};for(let n of t.attributes)if(n){let i=`${n.location} ${n.name}: ${n.type}`;r[`in ${i}`]={[o]:n.stepMode||"vertex"}}for(let n of t.varyings||[]){let i=`${n.location} ${n.name}`;r[`out ${i}`]={[o]:JSON.stringify(n)}}return r}var d3="__debugFramebufferState";function p3(t,e,r){if(t.device.type!=="webgl")return;let o=DK(t.device);if(!o.flushing){if(kK(t)){FK(t,r,o);return}e&&UK(e)&&e.handle!==null&&(o.queuedFramebuffers.includes(e)||o.queuedFramebuffers.push(e))}}function FK(t,e,r){if(r.queuedFramebuffers.length===0)return;let o=t.device,{gl:n}=o,i=n.getParameter(36010),s=n.getParameter(36006),[a,c]=t.device.getDefaultCanvasContext().getDrawingBufferSize(),l=h3(e.top,8),f=h3(e.left,8);r.flushing=!0;try{for(let u of r.queuedFramebuffers){let[d,h,p,m,g]=NK({framebuffer:u,targetWidth:a,targetHeight:c,topPx:l,leftPx:f,minimap:e.minimap});n.bindFramebuffer(36008,u.handle),n.bindFramebuffer(36009,null),n.blitFramebuffer(0,0,u.width,u.height,d,h,p,m,16384,9728),l+=g+8}}finally{n.bindFramebuffer(36008,i),n.bindFramebuffer(36009,s),r.flushing=!1}}function NK(t){let{framebuffer:e,targetWidth:r,targetHeight:o,topPx:n,leftPx:i,minimap:s}=t,a=s?Math.max(Math.floor(r/4),1):r,c=s?Math.max(Math.floor(o/4),1):o,l=Math.min(a/e.width,c/e.height),f=Math.max(Math.floor(e.width*l),1),u=Math.max(Math.floor(e.height*l),1),d=i,h=Math.max(o-n-u,0),p=d+f,m=h+u;return[d,h,p,m,u]}function DK(t){return t.userData[d3]||={flushing:!1,queuedFramebuffers:[]},t.userData[d3]}function UK(t){return"colorAttachments"in t}function kK(t){let e=t.props.framebuffer;return!e||e.handle===null}function h3(t,e){if(!t)return e;let r=Number.parseInt(t,10);return Number.isFinite(r)?r:e}function bg(t,e,r){if(t===e)return!0;if(!r||!t||!e)return!1;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let o=0;o<t.length;o++)if(!bg(t[o],e[o],r-1))return!1;return!0}if(Array.isArray(e))return!1;if(typeof t=="object"&&typeof e=="object"){let o=Object.keys(t),n=Object.keys(e);if(o.length!==n.length)return!1;for(let i of o)if(!e.hasOwnProperty(i)||!bg(t[i],e[i],r-1))return!1;return!0}return!1}q();var fc=class{bufferLayouts;constructor(e){this.bufferLayouts=e}getBufferLayout(e){return this.bufferLayouts.find(r=>r.name===e)||null}getAttributeNamesForBuffer(e){return e.attributes?e.attributes?.map(r=>r.attribute):[e.name]}mergeBufferLayouts(e,r){let o=[...e];for(let n of r){let i=o.findIndex(s=>s.name===n.name);i<0?o.push(n):o[i]=n}return o}getBufferIndex(e){let r=this.bufferLayouts.findIndex(o=>o.name===e);return r===-1&&P.warn(`BufferLayout: Missing buffer for "${e}".`)(),r}};function m3(t,e){let r=1/0;for(let o of t){let n=e[o];n!==void 0&&(r=Math.min(r,n))}return r}function g3(t,e){let r=Object.fromEntries(t.attributes.map(n=>[n.name,n.location])),o=e.slice();return o.sort((n,i)=>{let s=n.attributes?n.attributes.map(f=>f.attribute):[n.name],a=i.attributes?i.attributes.map(f=>f.attribute):[i.name],c=m3(s,r),l=m3(a,r);return c-l}),o}function Fv(t,e){if(!t||!e.some(o=>o.bindingLayout?.length))return t;let r={...t,bindings:t.bindings.map(o=>({...o}))};"attributes"in(t||{})&&(r.attributes=t?.attributes||[]);for(let o of e)for(let n of o.bindingLayout||[])for(let i of VK(n.name)){let s=r.bindings.find(a=>a.name===i);s?.group===0&&(s.group=n.group)}return r}function Ag(t){return Boolean(t.uniformTypes&&!zK(t.uniformTypes))}function VK(t){let e=new Set([t,`${t}Uniforms`]);return t.endsWith("Uniforms")||e.add(`${t}Sampler`),[...e]}function zK(t){for(let e in t)return!1;return!0}q();function HK(t){return nA(t)||typeof t=="number"||typeof t=="boolean"}function _3(t,e={}){let r={bindings:{},uniforms:{}};return Object.keys(t).forEach(o=>{let n=t[o];Object.prototype.hasOwnProperty.call(e,o)||HK(n)?r.uniforms[o]=n:r.bindings[o]=n}),r}var ci=class{options={disableWarnings:!1};modules;moduleUniforms;moduleBindings;constructor(e,r){Object.assign(this.options,r);let o=wa(Object.values(e).filter(jK));for(let n of o)e[n.name]=n;P.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(let[n,i]of Object.entries(e))i&&(this._addModule(i),i.name&&n!==i.name&&!this.options.disableWarnings&&P.warn(`Module name: ${n} vs ${i.name}`)())}destroy(){}setProps(e){for(let r of Object.keys(e)){let o=r,n=e[o]||{},i=this.modules[o];if(!i)this.options.disableWarnings||P.warn(`Module ${r} not found`)();else{let s=this.moduleUniforms[o],a=this.moduleBindings[o],c=i.getUniforms?.(n,s)||n,{uniforms:l,bindings:f}=_3(c,i.uniformTypes);this.moduleUniforms[o]=y3(s,l,i.uniformTypes),this.moduleBindings[o]={...a,...f}}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindingValues(){let e={};for(let r of Object.values(this.moduleBindings))Object.assign(e,r);return e}getDebugTable(){let e={};for(let[r,o]of Object.entries(this.moduleUniforms))for(let[n,i]of Object.entries(o))e[`${r}.${n}`]={type:this.modules[r].uniformTypes?.[n],value:String(i)};return e}_addModule(e){let r=e.name;this.moduleUniforms[r]=y3({},e.defaultUniforms||{},e.uniformTypes),this.moduleBindings[r]={}}};function y3(t={},e={},r={}){let o={...t};for(let[n,i]of Object.entries(e))i!==void 0&&(o[n]=Nv(t[n],i,r[n]));return o}function Nv(t,e,r){if(!r||typeof r=="string")return Zf(e);if(Array.isArray(r)){if(Dv(e)||!Array.isArray(e))return Zf(e);let s=Array.isArray(t)&&!Dv(t)?[...t]:[],a=s.slice();for(let c=0;c<e.length;c++){let l=e[c];l!==void 0&&(a[c]=Nv(s[c],l,r[0]))}return a}if(!Uv(e))return Zf(e);let o=r,n=Uv(t)?t:{},i={...n};for(let[s,a]of Object.entries(e))a!==void 0&&(i[s]=Nv(n[s],a,o[s]));return i}function Zf(t){return ArrayBuffer.isView(t)?Array.prototype.slice.call(t):Array.isArray(t)?Dv(t)?t.slice():t.map(r=>r===void 0?void 0:Zf(r)):Uv(t)?Object.fromEntries(Object.entries(t).map(([e,r])=>[e,r===void 0?void 0:Zf(r)])):t}function Dv(t){return ArrayBuffer.isView(t)||Array.isArray(t)&&(t.length===0||typeof t[0]=="number")}function Uv(t){return Boolean(t)&&typeof t=="object"&&!Array.isArray(t)&&!ArrayBuffer.isView(t)}function jK(t){return Boolean(t?.dependencies)}q();q();var kv={"+X":0,"-X":1,"+Y":2,"-Y":3,"+Z":4,"-Z":5};function Jf(t){return t?Array.isArray(t)?t[0]??null:t:null}function x3(t){let{dimension:e,data:r}=t;if(!r)return null;switch(e){case"1d":{let o=Jf(r);if(!o)return null;let{width:n}=Qf(o);return{width:n,height:1}}case"2d":{let o=Jf(r);return o?Qf(o):null}case"3d":case"2d-array":{if(!Array.isArray(r)||r.length===0)return null;let o=Jf(r[0]);return o?Qf(o):null}case"cube":{let o=Object.keys(r)[0]??null;if(!o)return null;let n=r[o],i=Jf(n);return i?Qf(i):null}case"cube-array":{if(!Array.isArray(r)||r.length===0)return null;let o=r[0],n=Object.keys(o)[0]??null;if(!n)return null;let i=Jf(o[n]);return i?Qf(i):null}default:return null}}function Qf(t){if(Na(t))return Sf(t);if(typeof t=="object"&&"width"in t&&"height"in t)return{width:t.width,height:t.height};throw new Error("Unsupported mip-level data")}function WK(t){return typeof t=="object"&&t!==null&&"data"in t&&"width"in t&&"height"in t}function GK(t){return ArrayBuffer.isView(t)}function Vv(t){let{textureFormat:e,format:r}=t;if(e&&r&&e!==r)throw new Error(`Conflicting texture formats "${e}" and "${r}" provided for the same mip level`);return e??r}function b3(t){let e=kv[t];if(e===void 0)throw new Error(`Invalid cube face: ${t}`);return e}function $K(t,e){return 6*t+b3(e)}function zv(t){throw new Error("setTexture1DData not supported in WebGL.")}function XK(t){return Array.isArray(t)?t:[t]}function ms(t,e,r,o){let n=XK(e),i=t,s=[];for(let a=0;a<n.length;a++){let c=n[a];if(Na(c))s.push({type:"external-image",image:c,z:i,mipLevel:a});else if(WK(c))s.push({type:"texture-data",data:c,textureFormat:Vv(c),z:i,mipLevel:a});else if(GK(c)&&r)s.push({type:"texture-data",data:{data:c,width:Math.max(1,r.width>>a),height:Math.max(1,r.height>>a),...o?{format:o}:{}},textureFormat:o,z:i,mipLevel:a});else throw new Error("Unsupported 2D mip-level payload")}return s}function Hv(t){let e=[];for(let r=0;r<t.length;r++)e.push(...ms(r,t[r]));return e}function jv(t){let e=[];for(let r=0;r<t.length;r++)e.push(...ms(r,t[r]));return e}function Wv(t){let e=[];for(let[r,o]of Object.entries(t)){let n=b3(r);e.push(...ms(n,o))}return e}function Gv(t){let e=[];return t.forEach((r,o)=>{for(let[n,i]of Object.entries(r)){let s=$K(o,n);e.push(...ms(s,i))}}),e}var Xv=class{device;id;props;_texture=null;_sampler=null;_view=null;ready;isReady=!1;destroyed=!1;resolveReady=()=>{};rejectReady=()=>{};get texture(){if(!this._texture)throw new Error("Texture not initialized yet");return this._texture}get sampler(){if(!this._sampler)throw new Error("Sampler not initialized yet");return this._sampler}get view(){if(!this._view)throw new Error("View not initialized yet");return this._view}get[Symbol.toStringTag](){return"DynamicTexture"}toString(){let e=this._texture?.width??this.props.width??"?",r=this._texture?.height??this.props.height??"?";return`DynamicTexture:"${this.id}":${e}x${r}px:(${this.isReady?"ready":"loading..."})`}constructor(e,r){this.device=e;let o=nt("dynamic-texture"),n=r;this.props={...Xv.defaultProps,id:o,...r,data:null},this.id=this.props.id,this.ready=new Promise((i,s)=>{this.resolveReady=i,this.rejectReady=s}),this.initAsync(n)}async initAsync(e){try{let r=await this._loadAllData(e);this._checkNotDestroyed();let o=r.data?YK({...r,width:e.width,height:e.height,format:e.format}):[],n="format"in e&&e.format!==void 0,i="usage"in e&&e.usage!==void 0,a=(()=>{if(this.props.width&&this.props.height)return{width:this.props.width,height:this.props.height};let m=x3(r);return m||{width:this.props.width||1,height:this.props.height||1}})();if(!a||a.width<=0||a.height<=0)throw new Error(`${this} size could not be determined or was zero`);let c=KK(this.device,o,a,{format:n?e.format:void 0}),l=c.format??this.props.format,f={...this.props,...a,format:l,mipLevels:1,data:void 0};this.device.isTextureFormatCompressed(l)&&!i&&(f.usage=Y.SAMPLE|Y.COPY_DST);let u=this.props.mipmaps&&!c.hasExplicitMipChain&&!this.device.isTextureFormatCompressed(l);if(this.device.type==="webgpu"&&u){let m=this.props.dimension==="3d"?Y.SAMPLE|Y.STORAGE|Y.COPY_DST|Y.COPY_SRC:Y.SAMPLE|Y.RENDER|Y.COPY_DST|Y.COPY_SRC;f.usage|=m}let d=this.device.getMipLevelCount(f.width,f.height),h=c.hasExplicitMipChain?c.mipLevels:this.props.mipLevels==="auto"?d:Math.max(1,Math.min(d,this.props.mipLevels??1)),p={...f,mipLevels:h};this._texture=this.device.createTexture(p),this._sampler=this.texture.sampler,this._view=this.texture.view,c.subresources.length&&this._setTextureSubresources(c.subresources),this.props.mipmaps&&!c.hasExplicitMipChain&&!u&&P.warn(`${this} skipping auto-generated mipmaps for compressed texture format`)(),u&&this.generateMipmaps(),this.isReady=!0,this.resolveReady(this.texture),P.info(0,`${this} created`)()}catch(r){let o=r instanceof Error?r:new Error(String(r));this.rejectReady(o)}}destroy(){this._texture&&(this._texture.destroy(),this._texture=null,this._sampler=null,this._view=null),this.destroyed=!0}generateMipmaps(){this.device.type==="webgl"?this.texture.generateMipmapsWebGL():this.device.type==="webgpu"?this.device.generateMipmapsWebGPU(this.texture):P.warn(`${this} mipmaps not supported on ${this.device.type}`)}setSampler(e={}){this._checkReady();let r=e instanceof Pt?e:this.device.createSampler(e);this.texture.setSampler(r),this._sampler=r}async readBuffer(e={}){this.isReady||await this.ready;let r=e.width??this.texture.width,o=e.height??this.texture.height,n=e.depthOrArrayLayers??this.texture.depth,i=this.texture.computeMemoryLayout({width:r,height:o,depthOrArrayLayers:n}),s=this.device.createBuffer({byteLength:i.byteLength,usage:K.COPY_DST|K.MAP_READ});this.texture.readBuffer({...e,width:r,height:o,depthOrArrayLayers:n},s);let a=this.device.createFence();return await a.signaled,a.destroy(),s}async readAsync(e={}){this.isReady||await this.ready;let r=e.width??this.texture.width,o=e.height??this.texture.height,n=e.depthOrArrayLayers??this.texture.depth,i=this.texture.computeMemoryLayout({width:r,height:o,depthOrArrayLayers:n}),s=await this.readBuffer(e),a=await s.readAsync(0,i.byteLength);return s.destroy(),a.buffer}resize(e){if(this._checkReady(),e.width===this.texture.width&&e.height===this.texture.height)return!1;let r=this.texture;return this._texture=r.clone(e),this._sampler=this.texture.sampler,this._view=this.texture.view,r.destroy(),P.info(`${this} resized`),!0}getCubeFaceIndex(e){let r=kv[e];if(r===void 0)throw new Error(`Invalid cube face: ${e}`);return r}getCubeArrayFaceIndex(e,r){return 6*e+this.getCubeFaceIndex(r)}setTexture1DData(e){if(this._checkReady(),this.texture.props.dimension!=="1d")throw new Error(`${this} is not 1d`);let r=zv(e);this._setTextureSubresources(r)}setTexture2DData(e,r=0){if(this._checkReady(),this.texture.props.dimension!=="2d")throw new Error(`${this} is not 2d`);let o=ms(r,e);this._setTextureSubresources(o)}setTexture3DData(e){if(this.texture.props.dimension!=="3d")throw new Error(`${this} is not 3d`);let r=Hv(e);this._setTextureSubresources(r)}setTextureArrayData(e){if(this.texture.props.dimension!=="2d-array")throw new Error(`${this} is not 2d-array`);let r=jv(e);this._setTextureSubresources(r)}setTextureCubeData(e){if(this.texture.props.dimension!=="cube")throw new Error(`${this} is not cube`);let r=Wv(e);this._setTextureSubresources(r)}setTextureCubeArrayData(e){if(this.texture.props.dimension!=="cube-array")throw new Error(`${this} is not cube-array`);let r=Gv(e);this._setTextureSubresources(r)}_setTextureSubresources(e){for(let r of e){let{z:o,mipLevel:n}=r;switch(r.type){case"external-image":let{image:i,flipY:s}=r;this.texture.copyExternalImage({image:i,z:o,mipLevel:n,flipY:s});break;case"texture-data":let{data:a,textureFormat:c}=r;if(c&&c!==this.texture.format)throw new Error(`${this} mip level ${n} uses format "${c}" but texture format is "${this.texture.format}"`);this.texture.writeData(a.data,{x:0,y:0,z:o,width:a.width,height:a.height,depthOrArrayLayers:1,mipLevel:n});break;default:throw new Error("Unsupported 2D mip-level payload")}}}async _loadAllData(e){let r=await $v(e.data);return{dimension:e.dimension??"2d",data:r??null}}_checkNotDestroyed(){this.destroyed&&P.warn(`${this} already destroyed`)}_checkReady(){this.isReady||P.warn(`${this} Cannot perform this operation before ready`)}},Kt=Xv;k(Kt,"defaultProps",{...Y.defaultProps,dimension:"2d",data:null,mipmaps:!1});function YK(t){if(!t.data)return[];let e=t.width&&t.height?{width:t.width,height:t.height}:void 0,r="format"in t?t.format:void 0;switch(t.dimension){case"1d":return zv(t.data);case"2d":return ms(0,t.data,e,r);case"3d":return Hv(t.data);case"2d-array":return jv(t.data);case"cube":return Wv(t.data);case"cube-array":return Gv(t.data);default:throw new Error(`Unhandled dimension ${t.dimension}`)}}function KK(t,e,r,o){if(e.length===0)return{subresources:e,mipLevels:1,format:o.format,hasExplicitMipChain:!1};let n=new Map;for(let f of e){let u=n.get(f.z)??[];u.push(f),n.set(f.z,u)}let i=e.some(f=>f.mipLevel>0),s=o.format,a=Number.POSITIVE_INFINITY,c=[];for(let[f,u]of n){let d=[...u].sort((x,y)=>x.mipLevel-y.mipLevel),h=d[0];if(!h||h.mipLevel!==0)throw new Error(`DynamicTexture: slice ${f} is missing mip level 0`);let p=T3(t,h);if(p.width!==r.width||p.height!==r.height)throw new Error(`DynamicTexture: slice ${f} base level dimensions ${p.width}x${p.height} do not match expected ${r.width}x${r.height}`);let m=A3(h);if(m){if(s&&s!==m)throw new Error(`DynamicTexture: slice ${f} base level format "${m}" does not match texture format "${s}"`);s=m}let g=s&&t.isTextureFormatCompressed(s)?qK(t,p.width,p.height,s):t.getMipLevelCount(p.width,p.height),_=0;for(let x=0;x<d.length;x++){let y=d[x];if(!y||y.mipLevel!==x||x>=g)break;let b=T3(t,y),T=Math.max(1,p.width>>x),v=Math.max(1,p.height>>x);if(b.width!==T||b.height!==v)break;let w=A3(y);if(w&&(s||(s=w),w!==s))break;_++,c.push(y)}a=Math.min(a,_)}let l=Number.isFinite(a)?Math.max(1,a):1;return{subresources:c.filter(f=>f.mipLevel<l),mipLevels:l,format:s,hasExplicitMipChain:i}}function A3(t){if(t.type==="texture-data")return t.textureFormat??Vv(t.data)}function T3(t,e){switch(e.type){case"external-image":return t.getExternalImageSize(e.image);case"texture-data":return{width:e.data.width,height:e.data.height};default:throw new Error("Unsupported texture subresource")}}function qK(t,e,r,o){let{blockWidth:n=1,blockHeight:i=1}=t.getTextureFormatInfo(o),s=1;for(let a=1;;a++){let c=Math.max(1,e>>a),l=Math.max(1,r>>a);if(c<n||l<i)break;s++}return s}async function $v(t){if(t=await t,Array.isArray(t))return await Promise.all(t.map($v));if(t&&typeof t=="object"&&t.constructor===Object){let e=t,r=await Promise.all(Object.values(e).map($v)),o=Object.keys(e),n={};for(let i=0;i<o.length;i++)n[o[i]]=r[i];return n}return t}var li=2,ZK=1e4,v3="render pipeline initialization failed",Yv=class{device;id;source;vs;fs;pipelineFactory;shaderFactory;userData={};parameters;topology;bufferLayout;isInstanced=void 0;instanceCount=0;vertexCount;indexBuffer=null;bufferAttributes={};constantAttributes={};bindings={};vertexArray;transformFeedback=null;pipeline;shaderInputs;material=null;_uniformStore;_attributeInfos={};_gpuGeometry=null;props;_pipelineNeedsUpdate="newly created";_needsRedraw="initializing";_destroyed=!1;_lastDrawTimestamp=-1;_bindingTable=[];get[Symbol.toStringTag](){return"Model"}toString(){return`Model(${this.id})`}constructor(e,r){this.props={...Yv.defaultProps,...r},r=this.props,this.id=r.id||nt("model"),this.device=e,Object.assign(this.userData,r.userData),this.material=r.material||null;let o=Object.fromEntries(this.props.modules?.map(c=>[c.name,c])||[]),n=r.shaderInputs||new ci(o,{disableWarnings:this.props.disableWarnings});this.setShaderInputs(n);let i=JK(e),s=(this.props.modules?.length>0?this.props.modules:this.shaderInputs?.getModules())||[];if(this.props.shaderLayout=Fv(this.props.shaderLayout,s)||null,this.device.type==="webgpu"&&this.props.source){let{source:c,getUniforms:l,bindingTable:f}=this.props.shaderAssembler.assembleWGSLShader({platformInfo:i,...this.props,modules:s});this.source=c,this._getModuleUniforms=l,this._bindingTable=f;let u=e.getShaderLayout?.(this.source);this.props.shaderLayout=Fv(this.props.shaderLayout||u||null,s)||null}else{let{vs:c,fs:l,getUniforms:f}=this.props.shaderAssembler.assembleGLSLShaderPair({platformInfo:i,...this.props,modules:s});this.vs=c,this.fs=l,this._getModuleUniforms=f,this._bindingTable=[]}this.vertexCount=this.props.vertexCount,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,r.geometry&&this.setGeometry(r.geometry),this.pipelineFactory=r.pipelineFactory||ka.getDefaultPipelineFactory(this.device),this.shaderFactory=r.shaderFactory||Va.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=e.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in r&&(this.isInstanced=r.isInstanced),r.instanceCount&&this.setInstanceCount(r.instanceCount),r.vertexCount&&this.setVertexCount(r.vertexCount),r.indexBuffer&&this.setIndexBuffer(r.indexBuffer),r.attributes&&this.setAttributes(r.attributes),r.constantAttributes&&this.setConstantAttributes(r.constantAttributes),r.bindings&&this.setBindings(r.bindings),r.transformFeedback&&(this.transformFeedback=r.transformFeedback)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.pipeline.fs!==this.pipeline.vs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),this._gpuGeometry?.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");let e=this._needsRedraw;return this._needsRedraw=!1,e}setNeedsRedraw(e){this._needsRedraw||=e}getBindingDebugTable(){return this._bindingTable}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(e){let r=this._areBindingsLoading();if(r)return P.info(li,`>>> DRAWING ABORTED ${this.id}: ${r} not loaded`)(),!1;try{e.pushDebugGroup(`${this}.predraw(${e})`),this.predraw()}finally{e.popDebugGroup()}let o,n=this.pipeline.isErrored;try{if(e.pushDebugGroup(`${this}.draw(${e})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline(),n=this.pipeline.isErrored,n)P.info(li,`>>> DRAWING ABORTED ${this.id}: ${v3}`)(),o=!1;else{let i=this._getBindings(),s=this._getBindGroups(),{indexBuffer:a}=this.vertexArray,c=a?a.byteLength/(a.indexType==="uint32"?4:2):void 0;o=this.pipeline.draw({renderPass:e,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:c,transformFeedback:this.transformFeedback||void 0,bindings:i,bindGroups:s,_bindGroupCacheKeys:this._getBindGroupCacheKeys(),uniforms:this.props.uniforms,parameters:this.parameters,topology:this.topology})}}finally{e.popDebugGroup(),this._logDrawCallEnd()}return this._logFramebuffer(e),o?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):n?this._needsRedraw=v3:this._needsRedraw="waiting for resource initialization",o}setGeometry(e){this._gpuGeometry?.destroy();let r=e&&f3(this.device,e);if(r){this.setTopology(r.topology||"triangle-list");let o=new fc(this.bufferLayout);this.bufferLayout=o.mergeBufferLayouts(r.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(r)}this._gpuGeometry=r}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){let r=new fc(this.bufferLayout);this.bufferLayout=this._gpuGeometry?r.mergeBufferLayouts(e,this._gpuGeometry.bufferLayout):e,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(e){bg(e,this.parameters,2)||(this.parameters=e,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(e){this.instanceCount=e,this.isInstanced===void 0&&e>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(e){this.vertexCount=e,this.setNeedsRedraw("vertexCount")}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new is(this.device,this.shaderInputs.modules);for(let[r,o]of Object.entries(this.shaderInputs.modules))if(Ag(o)&&!this.material?.ownsModule(r)){let n=this._uniformStore.getManagedUniformBuffer(r);this.bindings[`${r}Uniforms`]=n}this.setNeedsRedraw("shaderInputs")}setMaterial(e){this.material=e,this.setNeedsRedraw("material")}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues()),this.setBindings(this._getNonMaterialBindings(this.shaderInputs.getBindingValues())),this.setNeedsRedraw("shaderInputs")}setBindings(e){Object.assign(this.bindings,e),this.setNeedsRedraw("bindings")}setTransformFeedback(e){this.transformFeedback=e,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(e){this.vertexArray.setIndexBuffer(e),this.setNeedsRedraw("indexBuffer")}setAttributes(e,r){let o=r?.disableWarnings??this.props.disableWarnings;e.indices&&P.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=g3(this.pipeline.shaderLayout,this.bufferLayout);let n=new fc(this.bufferLayout);for(let[i,s]of Object.entries(e)){let a=n.getBufferLayout(i);if(!a){o||P.warn(`Model(${this.id}): Missing layout for buffer "${i}".`)();continue}let c=n.getAttributeNamesForBuffer(a),l=!1;for(let f of c){let u=this._attributeInfos[f];if(u){let d=this.device.type==="webgpu"?n.getBufferIndex(u.bufferName):u.location;this.vertexArray.setBuffer(d,s),l=!0}}!l&&!o&&P.warn(`Model(${this.id}): Ignoring buffer "${s.id}" for unknown attribute "${i}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,r){for(let[o,n]of Object.entries(e)){let i=this._attributeInfos[o];i?this.vertexArray.setConstantWebGL(i.location,n):(r?.disableWarnings??this.props.disableWarnings)||P.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${o}"`)()}this.setNeedsRedraw("constants")}_areBindingsLoading(){for(let e of Object.values(this.bindings))if(e instanceof Kt&&!e.isReady)return e.id;for(let e of Object.values(this.material?.bindings||{}))if(e instanceof Kt&&!e.isReady)return e.id;return!1}_getBindings(){let e={};for(let[r,o]of Object.entries(this.bindings))o instanceof Kt?o.isReady&&(e[r]=o.texture):e[r]=o;return e}_getBindGroups(){let e=this.pipeline?.shaderLayout||this.props.shaderLayout||{bindings:[]},r=e.bindings.length?If(e,this._getBindings()):{0:this._getBindings()};if(!this.material)return r;for(let[o,n]of Object.entries(this.material.getBindingsByGroup())){let i=Number(o);r[i]={...r[i]||{},...n}}return r}_getBindGroupCacheKeys(){let e=this.material?.getBindGroupCacheKey(3);return e?{3:e}:{}}_getBindingsUpdateTimestamp(){let e=0;for(let r of Object.values(this.bindings))r instanceof wr?e=Math.max(e,r.texture.updateTimestamp):r instanceof K||r instanceof Y?e=Math.max(e,r.updateTimestamp):r instanceof Kt?e=r.texture?Math.max(e,r.texture.updateTimestamp):1/0:r instanceof Pt||(e=Math.max(e,r.buffer.updateTimestamp));return Math.max(e,this.material?.getBindingsUpdateTimestamp()||0)}_setGeometryAttributes(e){let r={...e.attributes};for(let[o]of Object.entries(r))!this.pipeline.shaderLayout.attributes.find(n=>n.name===o)&&o!=="positions"&&delete r[o];this.vertexCount=e.vertexCount,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(r,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||=e,this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,r=null;this.pipeline&&(P.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,r=this.pipeline.fs),this._pipelineNeedsUpdate=!1;let o=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debugShaders:this.props.debugShaders}),n=null;this.source?n=o:this.fs&&(n=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debugShaders:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bindings:void 0,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,bindGroups:this._getBindGroups(),vs:o,fs:n}),this._attributeInfos=Vm(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),r&&r!==e&&this.shaderFactory.release(r)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let e=P.level>3?0:ZK;P.level<2||Date.now()-this._lastLogTime<e||(this._lastLogTime=Date.now(),this._logOpen=!0,P.group(li,`>>> DRAWING MODEL ${this.id}`,{collapsed:P.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let e=u3(this.pipeline.shaderLayout,this.id);P.table(li,e)();let r=this.shaderInputs.getDebugTable();P.table(li,r)();let o=this._getAttributeDebugTable();P.table(li,this._attributeInfos)(),P.table(li,o)(),P.groupEnd(li)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(e){let r=this.device.props.debugFramebuffers;if(this._drawCount++,!r)return;let o=e.props.framebuffer;p3(e,o,{id:o?.id||`${this.id}-framebuffer`,minimap:!0})}_getAttributeDebugTable(){let e={};for(let[r,o]of Object.entries(this._attributeInfos)){let n=this.vertexArray.attributes[o.location];e[o.location]={name:r,type:o.shaderType,values:n?this._getBufferOrConstantValues(n,o.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){let{indexBuffer:r}=this.vertexArray,o=r.indexType==="uint32"?new Uint32Array(r.debugData):new Uint16Array(r.debugData);e.indices={name:"indices",type:r.indexType,values:o.toString()}}return e}_getBufferOrConstantValues(e,r){let o=Dt.getTypedArrayConstructor(r);return(e instanceof K?new o(e.debugData):e).toString()}_getNonMaterialBindings(e){if(!this.material)return e;let r={};for(let[o,n]of Object.entries(e))this.material.ownsBinding(o)||(r[o]=n);return r}},Q=Yv;k(Q,"defaultProps",{...fr.defaultProps,source:void 0,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},bindings:{},uniforms:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,material:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:Zn.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0});function JK(t){return{type:t.type,shaderLanguage:t.info.shadingLanguage,shaderLanguageVersion:t.info.shadingLanguageVersion,gpu:t.info.gpu,features:t.features}}q();var eu=3,un=class{device;modules;_materialBindingNames;_materialModuleNames;constructor(e,r={}){this.device=e,this.modules=r.modules||[];let o=new ci(Object.fromEntries(this.modules.map(n=>[n.name,n])));this._materialBindingNames=QK(o),this._materialModuleNames=eq(o)}createMaterial(e={}){return new Tg(this.device,{...e,factory:this})}getBindingNames(){return Array.from(this._materialBindingNames)}ownsBinding(e){if(this._materialBindingNames.has(e))return!0;let r=Kv(e);return r?this._materialModuleNames.has(r):!1}ownsModule(e){return this._materialModuleNames.has(e)}getBindingsByGroup(e){return Object.keys(e).length>0?{[eu]:e}:{}}};function Kv(t){return t.endsWith("Uniforms")?t.slice(0,-8):null}function QK(t){let e=new Set;for(let r of Object.values(t.modules))for(let o of r.bindingLayout||[])o.group===eu&&e.add(o.name);return e}function eq(t){let e=new Set;for(let r of Object.values(t.modules))r.name&&r.bindingLayout?.some(o=>o.group===eu&&o.name===r.name)&&e.add(r.name);return e}var Tg=class{id;device;factory;shaderInputs;bindings={};_uniformStore;_bindGroupCacheToken={};constructor(e,r={}){this.id=r.id||nt("material"),this.device=e,this.factory=r.factory||new un(e,{modules:r.modules||r.shaderInputs?.getModules()||[]});let o=Object.fromEntries((r.shaderInputs?.getModules()||this.factory.modules).map(n=>[n.name,n]));this.shaderInputs=r.shaderInputs||new ci(o),this._uniformStore=new is(this.device,this.shaderInputs.modules);for(let[n,i]of Object.entries(this.shaderInputs.modules))if(this.ownsModule(n)&&Ag(i)){let s=this._uniformStore.getManagedUniformBuffer(n);this.bindings[`${n}Uniforms`]=s}this.updateShaderInputs(),r.bindings&&this._replaceOwnedBindings(r.bindings)}destroy(){this._uniformStore.destroy()}clone(e={}){let r=this.factory.createMaterial({id:e.id,shaderInputs:e.shaderInputs,bindings:{...this.getResourceBindings(),...e.bindings}});return e.shaderInputs||r.setProps(this.shaderInputs.getUniformValues()),e.moduleProps&&r.setProps(e.moduleProps),r}ownsBinding(e){return this.factory.ownsBinding(e)}ownsModule(e){return this.factory.ownsModule(e)}setProps(e){this.shaderInputs.setProps(e),this.updateShaderInputs()}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues()),this._setOwnedBindings(this.shaderInputs.getBindingValues())&&(this._bindGroupCacheToken={})}getResourceBindings(){let e={};for(let[r,o]of Object.entries(this.bindings))Kv(r)||(e[r]=o);return e}getBindings(){let e={},r=e;for(let[o,n]of Object.entries(this.bindings))n instanceof Kt?n.isReady&&(r[o]=n.texture):r[o]=n;return e}getBindingsByGroup(){return this.factory.getBindingsByGroup(this.getBindings())}getBindGroupCacheKey(e){return e===eu?this._bindGroupCacheToken:null}getBindingsUpdateTimestamp(){let e=0;for(let r of Object.values(this.bindings))r instanceof wr?e=Math.max(e,r.texture.updateTimestamp):r instanceof K||r instanceof Y?e=Math.max(e,r.updateTimestamp):r instanceof Kt?e=r.texture?Math.max(e,r.texture.updateTimestamp):1/0:r instanceof Pt||(e=Math.max(e,r.buffer.updateTimestamp));return e}_replaceOwnedBindings(e){this._setOwnedBindings(e)&&(this._bindGroupCacheToken={})}_setOwnedBindings(e){let r=!1;for(let[o,n]of Object.entries(e))n!==void 0&&this.ownsBinding(o)&&this.bindings[o]!==n&&(this.bindings[o]=n,r=!0);return r}};q();var vg=class{device;model;transformFeedback;static isSupported(e){return e?.info?.type==="webgl"}constructor(e,r=vg.defaultProps){if(!vg.isSupported(e))throw new Error("BufferTransform not yet implemented on WebGPU");this.device=e,this.model=new Q(this.device,{id:r.id||"buffer-transform-model",fs:r.fs||uf(),topology:r.topology||"point-list",varyings:r.outputs||r.varyings,...r}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:r.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback),Object.seal(this)}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(e){e?.inputBuffers&&this.model.setAttributes(e.inputBuffers),e?.outputBuffers&&this.transformFeedback.setBuffers(e.outputBuffers);let r=this.device.beginRenderPass(e);this.model.draw(r),r.end()}getBuffer(e){return this.transformFeedback.getBuffer(e)}readAsync(e){let r=this.getBuffer(e);if(!r)throw new Error("BufferTransform#getBuffer");if(r instanceof K)return r.readAsync();let{buffer:o,byteOffset:n=0,byteLength:i=o.byteLength}=r;return o.readAsync(n,i)}},ur=vg;k(ur,"defaultProps",{...Q.defaultProps,outputs:void 0,feedbackBuffers:void 0});var tq="transform_output",fi=class{device;model;sampler;currentIndex=0;samplerTextureMap=null;bindings=[];resources={};constructor(e,r){this.device=e,this.sampler=e.createSampler({addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",minFilter:"nearest",magFilter:"nearest",mipmapFilter:"nearest"}),this.model=new Q(this.device,{id:r.id||nt("texture-transform-model"),fs:r.fs||uf({input:r.targetTextureVarying,inputChannels:r.targetTextureChannels,output:tq}),vertexCount:r.vertexCount,...r}),this._initialize(r),Object.seal(this)}destroy(){this.model.destroy();for(let e of this.bindings)e.framebuffer?.destroy()}delete(){this.destroy()}run(e){let{framebuffer:r}=this.bindings[this.currentIndex],o=this.device.beginRenderPass({framebuffer:r,...e});this.model.draw(o),o.end(),this.device.submit()}getTargetTexture(){let{targetTexture:e}=this.bindings[this.currentIndex];return e}getFramebuffer(){return this.bindings[this.currentIndex].framebuffer}_initialize(e){this._updateBindings(e)}_updateBindings(e){this.bindings[this.currentIndex]=this._updateBinding(this.bindings[this.currentIndex],e)}_updateBinding(e,{sourceBuffers:r,sourceTextures:o,targetTexture:n}){if(e||(e={sourceBuffers:{},sourceTextures:{},targetTexture:null}),Object.assign(e.sourceTextures,o),Object.assign(e.sourceBuffers,r),n){e.targetTexture=n;let{width:i,height:s}=n;e.framebuffer&&e.framebuffer.destroy(),e.framebuffer=this.device.createFramebuffer({id:"transform-framebuffer",width:i,height:s,colorAttachments:[n]}),e.framebuffer.resize({width:i,height:s})}return e}_setSourceTextureParameters(){let e=this.currentIndex,{sourceTextures:r}=this.bindings[e];for(let o in r)r[o].sampler=this.sampler}};var ce=class{id;topology;vertexCount;indices;attributes;userData={};constructor(e){let{attributes:r={},indices:o=null,vertexCount:n=null}=e;this.id=e.id||nt("geometry"),this.topology=e.topology,o&&(this.indices=ArrayBuffer.isView(o)?{value:o,size:1}:o),this.attributes={};for(let[i,s]of Object.entries(r)){let a=ArrayBuffer.isView(s)?{value:s}:s;if(!ArrayBuffer.isView(a.value))throw new Error(`${this._print(i)}: must be typed array or object with value as typed array`);if((i==="POSITION"||i==="positions")&&!a.size&&(a.size=3),i==="indices"){if(this.indices)throw new Error("Multiple indices detected");this.indices=a}else this.attributes[i]=a}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=n||this._calculateVertexCount(this.attributes,this.indices)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(e){return`Geometry ${this.id} attribute ${e}`}_setAttributes(e,r){return this}_calculateVertexCount(e,r){if(r)return r.value.length;let o=1/0;for(let n of Object.values(e)){let{value:i,size:s,constant:a}=n;!a&&i&&s!==void 0&&s>=1&&(o=Math.min(o,i.length/s))}return o}};var rq=`struct VertexInputs { @location(0) clipSpacePositions: vec2<f32>, @location(1) texCoords: vec2<f32>, @location(2) coordinates: vec2<f32> } struct FragmentInputs { @builtin(position) Position : vec4<f32>, @location(0) position : vec2<f32>, @location(1) coordinate : vec2<f32>, @location(2) uv : vec2<f32> }; @vertex fn vertexMain(inputs: VertexInputs) -> FragmentInputs { var outputs: FragmentInputs; outputs.Position = vec4(inputs.clipSpacePositions, 0., 1.); outputs.position = inputs.clipSpacePositions; outputs.coordinate = inputs.coordinates; outputs.uv = inputs.texCoords; return outputs; } `,oq=`#version 300 es in vec2 clipSpacePositions; in vec2 texCoords; in vec2 coordinates; out vec2 position; out vec2 coordinate; out vec2 uv; void main(void) { gl_Position = vec4(clipSpacePositions, 0., 1.); position = clipSpacePositions; coordinate = coordinates; uv = texCoords; } `,S3=[-1,-1,1,-1,-1,1,1,1],tu=class extends Q{constructor(e,r){let o=S3.map(n=>n===-1?0:n);r.source&&(r={...r,source:`${rq} ${r.source}`}),super(e,{id:r.id||nt("clip-space"),...r,vs:oq,vertexCount:4,geometry:new ce({topology:"triangle-strip",vertexCount:4,attributes:{clipSpacePositions:{size:2,value:new Float32Array(S3)},texCoords:{size:2,value:new Float32Array(o)},coordinates:{size:2,value:new Float32Array(o)}}})})}};var ru=class extends ce{constructor(e={}){let{id:r=nt("sphere-geometry")}=e,{indices:o,attributes:n}=nq(e);super({...e,id:r,topology:"triangle-list",indices:o,attributes:{...n,...e.attributes}})}};function nq(t){let{nlat:e=10,nlong:r=10}=t,i=Math.PI-0,s=0,c=2*Math.PI-s,l=(e+1)*(r+1),f=(_,x,y,b,T)=>t.radius||1,u=new Float32Array(l*3),d=new Float32Array(l*3),h=new Float32Array(l*2),p=l>65535?Uint32Array:Uint16Array,m=new p(e*r*6);for(let _=0;_<=e;_++)for(let x=0;x<=r;x++){let y=x/r,b=_/e,T=x+_*(r+1),v=T*2,w=T*3,C=c*y,S=i*b,A=Math.sin(C),M=Math.cos(C),B=Math.sin(S),O=Math.cos(S),F=M*B,X=O,G=A*B,j=f(F,X,G,y,b);u[w+0]=j*F,u[w+1]=j*X,u[w+2]=j*G,d[w+0]=F,d[w+1]=X,d[w+2]=G,h[v+0]=y,h[v+1]=1-b}let g=r+1;for(let _=0;_<r;_++)for(let x=0;x<e;x++){let y=(_*e+x)*6;m[y+0]=x*g+_,m[y+1]=x*g+_+1,m[y+2]=(x+1)*g+_,m[y+3]=(x+1)*g+_,m[y+4]=x*g+_+1,m[y+5]=(x+1)*g+_+1}return{indices:{size:1,value:m},attributes:{POSITION:{size:3,value:u},NORMAL:{size:3,value:d},TEXCOORD_0:{size:2,value:h}}}}function qv(t,e){if(!t)throw new Error(e)}var Rr=class{id;matrix=new V;display=!0;position=new E;rotation=new E;scale=new E(1,1,1);userData={};props={};constructor(e={}){let{id:r}=e;this.id=r||nt(this.constructor.name),this._setScenegraphNodeProps(e)}getBounds(){return null}destroy(){}delete(){this.destroy()}setProps(e){return this._setScenegraphNodeProps(e),this}toString(){return`{type: ScenegraphNode, id: ${this.id})}`}setPosition(e){return qv(e.length===3,"setPosition requires vector argument"),this.position=e,this}setRotation(e){return qv(e.length===3||e.length===4,"setRotation requires vector argument"),this.rotation=e,this}setScale(e){return qv(e.length===3,"setScale requires vector argument"),this.scale=e,this}setMatrix(e,r=!0){r?this.matrix.copy(e):this.matrix=e}setMatrixComponents(e){let{position:r,rotation:o,scale:n,update:i=!0}=e;return r&&this.setPosition(r),o&&this.setRotation(o),n&&this.setScale(n),i&&this.updateMatrix(),this}updateMatrix(){if(this.matrix.identity(),this.matrix.translate(this.position),this.rotation.length===4){let e=new V().fromQuaternion(this.rotation);this.matrix.multiplyRight(e)}else this.matrix.rotateXYZ(this.rotation);return this.matrix.scale(this.scale),this}update({position:e,rotation:r,scale:o}={}){return e&&this.setPosition(e),r&&this.setRotation(r),o&&this.setScale(o),this.updateMatrix(),this}getCoordinateUniforms(e,r){r=r||this.matrix;let o=new V(e).multiplyRight(r),n=o.invert(),i=n.transpose();return{viewMatrix:e,modelMatrix:r,objectMatrix:r,worldMatrix:o,worldInverseMatrix:n,worldInverseTransposeMatrix:i}}_setScenegraphNodeProps(e){e?.position&&this.setPosition(e.position),e?.rotation&&this.setRotation(e.rotation),e?.scale&&this.setScale(e.scale),this.updateMatrix(),e?.matrix&&this.setMatrix(e.matrix),Object.assign(this.props,e)}};q();var qt=class extends Rr{children;constructor(e={}){e=Array.isArray(e)?{children:e}:e;let{children:r=[]}=e;P.assert(r.every(o=>o instanceof Rr),"every child must an instance of ScenegraphNode"),super(e),this.children=r}getBounds(){let e=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]];return this.traverse((r,{worldMatrix:o})=>{let n=r.getBounds();if(!n)return;let[i,s]=n,a=new E(i).add(s).divide([2,2,2]);o.transformAsPoint(a,a);let c=new E(s).subtract(i).divide([2,2,2]);o.transformAsVector(c,c);for(let l=0;l<8;l++){let f=new E(l&1?-1:1,l&2?-1:1,l&4?-1:1).multiply(c).add(a);for(let u=0;u<3;u++)e[0][u]=Math.min(e[0][u],f[u]),e[1][u]=Math.max(e[1][u],f[u])}}),Number.isFinite(e[0][0])?e:null}destroy(){this.children.forEach(e=>e.destroy()),this.removeAll(),super.destroy()}add(...e){for(let r of e)Array.isArray(r)?this.add(...r):this.children.push(r);return this}remove(e){let r=this.children,o=r.indexOf(e);return o>-1&&r.splice(o,1),this}removeAll(){return this.children=[],this}traverse(e,{worldMatrix:r=new V}={}){let o=new V(r).multiplyRight(this.matrix);for(let n of this.children)n instanceof qt?n.traverse(e,{worldMatrix:o}):e(n,{worldMatrix:o})}preorderTraversal(e,{worldMatrix:r=new V}={}){let o=new V(r).multiplyRight(this.matrix);e(this,{worldMatrix:o});for(let n of this.children)n instanceof qt?n.preorderTraversal(e,{worldMatrix:o}):e(n,{worldMatrix:o})}};var Io=class extends Rr{model;bounds=null;managedResources;constructor(e){super(e),this.model=e.model,this.managedResources=e.managedResources||[],this.bounds=e.bounds||null,this.setProps(e)}destroy(){this.model&&(this.model.destroy(),this.model=null),this.managedResources.forEach(e=>e.destroy()),this.managedResources=[]}getBounds(){return this.bounds}draw(e){return this.model.draw(e)}};var dn=class extends ce{constructor(e={}){let{id:r=nt("cube-geometry"),indices:o=!0}=e;super(o?{...e,id:r,topology:"triangle-list",indices:{size:1,value:iq},attributes:{...dq,...e.attributes}}:{...e,id:r,topology:"triangle-list",indices:void 0,attributes:{...hq,...e.attributes}})}},iq=new Uint16Array([0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]),sq=new Float32Array([-1,-1,1,1,-1,1,1,1,1,-1,1,1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1,-1,1,1,1,1,1,1,1,-1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,-1,1,-1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1]),aq=new Float32Array([0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0]),cq=new Float32Array([0,0,1,0,1,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,1,1,1,0,1,0,0,1,0,1,0,1,1,0,1,0,0,0,0,1,0,1,1,0,1]),lq=new Float32Array([1,-1,1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,-1,-1,-1,1,1,1,1,1,1,1,-1,-1,1,-1,-1,1,1,1,1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1,1,-1,1,1,1,-1,1,1,-1,-1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1]),fq=new Float32Array([1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,0,0,1,0,1,1,1,1,0,1,0,0,1,0,1,1,0,0]),uq=new Float32Array([1,0,1,1,0,0,1,1,0,0,0,1,1,0,0,1,1,0,1,1,0,0,0,1,1,1,1,1,1,0,1,1,1,0,0,1,1,1,0,1,1,1,1,1,1,0,0,1,0,1,1,1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,1,1,1,1,0,1,0,0,1,1,0,1,1,1,0,1,0,1,0,0,0,1,0,0,1,1,0,1,0,1,1,1,1,1,0,1,1,1,0,0,1,1,0,0,1,1,1,0,1,1,1,1,1,1,1,0,0,1,0,0,0,1,0,1,0,1,1,1,0,1,1,0,0,1,0,1,0,1]),dq={POSITION:{size:3,value:sq},NORMAL:{size:3,value:aq},TEXCOORD_0:{size:2,value:cq}},hq={POSITION:{size:3,value:lq},TEXCOORD_0:{size:2,value:fq},COLOR_0:{size:3,value:uq}};var pq=`layout(std140) uniform screenUniforms { vec2 texSize; } screen; `,C3={name:"screen",fs:pq,uniformTypes:{texSize:"vec2<f32>"}};var ou=class extends us{constructor(e,r){super(e,r);let{module:o,fs:n,id:i}=r,s={depthWriteEnabled:!1,depthCompare:"always",depthBias:0,blend:!0,blendColorSrcFactor:"one",blendColorDstFactor:"one-minus-src-alpha",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one-minus-src-alpha",blendColorOperation:"add",blendAlphaOperation:"add"};this.model=new tu(e,{id:i,fs:n,modules:[o,C3],parameters:s})}render(e){this._renderPass(this.device,e)}delete(){this.model.destroy(),this.model=null}_renderPass(e,r){let{clearCanvas:o,inputBuffer:n,outputBuffer:i}=r,s=[n.width,n.height],a={texSrc:n.colorAttachments[0],texSize:s};this.model.shaderInputs.setProps({screen:a,...r.moduleProps});let c=this.device.beginRenderPass({framebuffer:i,parameters:{viewport:[0,0,...s]},clearColor:o?[0,0,0,0]:!1,clearDepth:1,clearStencil:!1});this.model.draw(c),c.end()}};var nu=class{constructor(e,r){this.id=`${e.name}-pass`,this.props=r,tm(e),this.module=e}setup({device:e}){this.passes=mq(e,this.module,this.id)}setProps(e){this.props=e}preRender(){}postRender(e){let r=this.passes,{target:o}=e,n=e.inputBuffer,i=e.swapBuffer;for(let s=0;s<r.length;s++){let a=s===r.length-1,c=o!==void 0&&a;c&&(i=o);let l=!c||Boolean(e.clearCanvas),f={},u=this.module.passes[s].uniforms;f[this.module.name]={...this.props,...u},r[s].render({clearCanvas:l,inputBuffer:n,outputBuffer:i,moduleProps:f});let d=i;i=n,n=d}return n}cleanup(){if(this.passes){for(let e of this.passes)e.delete();this.passes=void 0}}};function mq(t,e,r){return e.passes.map((o,n)=>{let i=yq(e,o),s=`${r}-${n}`;return new ou(t,{id:s,module:e,fs:i})})}var E3=`#version 300 es uniform sampler2D texSrc; in vec2 position; in vec2 coordinate; in vec2 uv; out vec4 fragColor; `,gq=t=>`${E3} void main() { fragColor = texture(texSrc, coordinate); fragColor = ${t}(fragColor, screen.texSize, coordinate); } `,_q=t=>`${E3} void main() { fragColor = ${t}(texSrc, screen.texSize, coordinate); } `;function yq(t,e){if(e.filter){let r=typeof e.filter=="string"?e.filter:`${t.name}_filterColor_ext`;return gq(r)}if(e.sampler){let r=typeof e.sampler=="string"?e.sampler:`${t.name}_sampleColor`;return _q(r)}return""}var xq={blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"zero",blendAlphaOperation:"add",blendAlphaSrcFactor:"constant",blendAlphaDstFactor:"zero"},Jr=class extends At{constructor(){super(...arguments),this._colorEncoderState=null}render(e){return"pickingFBO"in e?this._drawPickingBuffer(e):{decodePickingColor:null,stats:super._render(e)}}_drawPickingBuffer({layers:e,layerFilter:r,views:o,viewports:n,onViewportActive:i,pickingFBO:s,deviceRect:{x:a,y:c,width:l,height:f},cullRect:u,effects:d,pass:h="picking",pickZ:p,shaderModuleProps:m,clearColor:g}){this.pickZ=p;let _=this._resetColorEncoder(p),x=[a,c,l,f],y=super._render({target:s,layers:e,layerFilter:r,views:o,viewports:n,onViewportActive:i,cullRect:u,effects:d?.filter(T=>T.useInPicking),pass:h,isPicking:!0,shaderModuleProps:m,clearColor:g??[0,0,0,0],colorMask:15,scissorRect:x});return this._colorEncoderState=null,{decodePickingColor:_&&bq.bind(null,_),stats:y}}shouldDrawLayer(e){let{pickable:r,operation:o}=e.props;return r&&o.includes("draw")||o.includes("terrain")||o.includes("mask")}getShaderModuleProps(e,r,o){return{picking:{isActive:1,isAttribute:this.pickZ},lighting:{enabled:!1}}}getLayerParameters(e,r,o){let n={...e.props.parameters},{pickable:i,operation:s}=e.props;return this._colorEncoderState?i&&s.includes("draw")?(Object.assign(n,xq),n.blend=!0,this.device.type==="webgpu"?n.blendConstant=w3(this._colorEncoderState,e,o):n.blendColor=w3(this._colorEncoderState,e,o),s.includes("terrain")&&e.state?._hasPickingCover&&(n.blendAlphaSrcFactor="one")):s.includes("terrain")&&(n.blend=!1):n.blend=!1,n}_resetColorEncoder(e){return this._colorEncoderState=e?null:{byLayer:new Map,byAlpha:[]},this._colorEncoderState}};function w3(t,e,r){let{byLayer:o,byAlpha:n}=t,i,s=o.get(e);return s?(s.viewports.push(r),i=s.a):(i=o.size+1,i<=255?(s={a:i,layer:e,viewports:[r]},o.set(e,s),n[i]=s):(N.warn("Too many pickable layers, only picking the first 255")(),i=0)),[0,0,0,i/255]}function bq(t,e){let r=t.byAlpha[e[3]];return r&&{pickedLayer:r.layer,pickedViewports:r.viewports,pickedObjectIndex:r.layer.decodePickingColor(e)}}var ui={NO_STATE:"Awaiting state",MATCHED:"Matched. State transferred from previous layer",INITIALIZED:"Initialized",AWAITING_GC:"Discarded. Awaiting garbage collection",AWAITING_FINALIZATION:"No longer matched. Awaiting garbage collection",FINALIZED:"Finalized! Awaiting garbage collection"},uc=Symbol.for("component"),Ir=Symbol.for("propTypes"),Sg=Symbol.for("deprecatedProps"),hn=Symbol.for("asyncPropDefaults"),Lo=Symbol.for("asyncPropOriginal"),Qr=Symbol.for("asyncPropResolved");function kt(t,e=()=>!0){return Array.isArray(t)?P3(t,e,[]):e(t)?[t]:[]}function P3(t,e,r){let o=-1;for(;++o<t.length;){let n=t[o];Array.isArray(n)?P3(n,e,r):e(n)&&r.push(n)}return r}function Cg({target:t,source:e,start:r=0,count:o=1}){let n=e.length,i=o*n,s=0;for(let a=r;s<n;s++)t[a++]=e[s];for(;s<i;)s<i-s?(t.copyWithin(r+s,r,r+s),s*=2):(t.copyWithin(r+s,r,r+i-s),s=i);return t}Xi();var iu=class{constructor(e,r,o){this._loadCount=0,this._subscribers=new Set,this.id=e,this.context=o,this.setData(r)}subscribe(e){this._subscribers.add(e)}unsubscribe(e){this._subscribers.delete(e)}inUse(){return this._subscribers.size>0}delete(){}getData(){return this.isLoaded?this._error?Promise.reject(this._error):this._content:this._loader.then(()=>this.getData())}setData(e,r){if(e===this._data&&!r)return;this._data=e;let o=++this._loadCount,n=e;typeof e=="string"&&(n=Kn(e)),n instanceof Promise?(this.isLoaded=!1,this._loader=n.then(i=>{this._loadCount===o&&(this.isLoaded=!0,this._error=void 0,this._content=i)}).catch(i=>{this._loadCount===o&&(this.isLoaded=!0,this._error=i||!0)})):(this.isLoaded=!0,this._error=void 0,this._content=e);for(let i of this._subscribers)i.onChange(this.getData())}};var su=class{constructor(e){this.protocol=e.protocol||"resource://",this._context={device:e.device,gl:e.device?.gl,resourceManager:this},this._resources={},this._consumers={},this._pruneRequest=null}contains(e){return e.startsWith(this.protocol)?!0:e in this._resources}add({resourceId:e,data:r,forceUpdate:o=!1,persistent:n=!0}){let i=this._resources[e];i?i.setData(r,o):(i=new iu(e,r,this._context),this._resources[e]=i),i.persistent=n}remove(e){let r=this._resources[e];r&&(r.delete(),delete this._resources[e])}unsubscribe({consumerId:e}){let r=this._consumers[e];if(r){for(let o in r){let n=r[o],i=this._resources[n.resourceId];i&&i.unsubscribe(n)}delete this._consumers[e],this.prune()}}subscribe({resourceId:e,onChange:r,consumerId:o,requestId:n="default"}){let{_resources:i,protocol:s}=this;e.startsWith(s)&&(e=e.replace(s,""),i[e]||this.add({resourceId:e,data:null,persistent:!1}));let a=i[e];if(this._track(o,n,a,r),a)return a.getData()}prune(){this._pruneRequest||(this._pruneRequest=setTimeout(()=>this._prune(),0))}finalize(){for(let e in this._resources)this._resources[e].delete()}_track(e,r,o,n){let i=this._consumers,s=i[e]=i[e]||{},a=s[r],c=a&&a.resourceId&&this._resources[a.resourceId];c&&(c.unsubscribe(a),this.prune()),o&&(a?(a.onChange=n,a.resourceId=o.id):a={onChange:n,resourceId:o.id},s[r]=a,o.subscribe(a))}_prune(){this._pruneRequest=null;for(let e of Object.keys(this._resources)){let r=this._resources[e];!r.persistent&&!r.inUse()&&(r.delete(),delete this._resources[e])}}};var Aq="layerManager.setLayers",Tq="layerManager.activateViewport",gs=class{constructor(e,r){this._lastRenderedLayers=[],this._needsRedraw=!1,this._needsUpdate=!1,this._nextLayers=null,this._debug=!1,this._defaultShaderModulesChanged=!1,this.activateViewport=a=>{He(Tq,this,a),a&&(this.context.viewport=a)};let{deck:o,stats:n,viewport:i,timeline:s}=r||{};this.layers=[],this.resourceManager=new su({device:e,protocol:"deck://"}),this.context={mousePosition:null,userData:{},layerManager:this,device:e,gl:e?.gl,deck:o,shaderAssembler:hg(e?.info?.shadingLanguage||"glsl"),defaultShaderModules:[mv],renderPass:void 0,stats:n||new Et({id:"deck.gl"}),viewport:i||new ot({id:"DEFAULT-INITIAL-VIEWPORT"}),timeline:s||new ps,resourceManager:this.resourceManager,onError:void 0},Object.seal(this)}finalize(){this.resourceManager.finalize();for(let e of this.layers)this._finalizeLayer(e)}needsRedraw(e={clearRedrawFlags:!1}){let r=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);for(let o of this.layers){let n=o.getNeedsRedraw(e);r=r||n}return r}needsUpdate(){return this._nextLayers&&this._nextLayers!==this._lastRenderedLayers?"layers changed":this._defaultShaderModulesChanged?"shader modules changed":this._needsUpdate}setNeedsRedraw(e){this._needsRedraw=this._needsRedraw||e}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e}getLayers({layerIds:e}={}){return e?this.layers.filter(r=>e.find(o=>r.id.indexOf(o)===0)):this.layers}setProps(e){"debug"in e&&(this._debug=e.debug),"userData"in e&&(this.context.userData=e.userData),"layers"in e&&(this._nextLayers=e.layers),"onError"in e&&(this.context.onError=e.onError)}setLayers(e,r){He(Aq,this,r,e),this._lastRenderedLayers=e;let o=kt(e,Boolean);for(let n of o)n.context=this.context;this._updateLayers(this.layers,o)}updateLayers(){let e=this.needsUpdate();e&&(this.setNeedsRedraw(`updating layers: ${e}`),this.setLayers(this._nextLayers||this._lastRenderedLayers,e)),this._nextLayers=null}addDefaultShaderModule(e){let{defaultShaderModules:r}=this.context;r.find(o=>o.name===e.name)||(r.push(e),this._defaultShaderModulesChanged=!0)}removeDefaultShaderModule(e){let{defaultShaderModules:r}=this.context,o=r.findIndex(n=>n.name===e.name);o>=0&&(r.splice(o,1),this._defaultShaderModulesChanged=!0)}_handleError(e,r,o){o.raiseError(r,`${e} of ${o}`)}_updateLayers(e,r){let o={};for(let s of e)o[s.id]?N.warn(`Multiple old layers with same id ${s.id}`)():o[s.id]=s;if(this._defaultShaderModulesChanged){for(let s of e)s.setNeedsUpdate(),s.setChangeFlags({extensionsChanged:!0});this._defaultShaderModulesChanged=!1}let n=[];this._updateSublayersRecursively(r,o,n),this._finalizeOldLayers(o);let i=!1;for(let s of n)if(s.hasUniformTransition()){i=`Uniform transition in ${s}`;break}this._needsUpdate=i,this.layers=n}_updateSublayersRecursively(e,r,o){for(let n of e){n.context=this.context;let i=r[n.id];i===null&&N.warn(`Multiple new layers with same id ${n.id}`)(),r[n.id]=null;let s=null;try{this._debug&&i!==n&&n.validateProps(),i?(this._transferLayerState(i,n),this._updateLayer(n)):this._initializeLayer(n),o.push(n),s=n.isComposite?n.getSubLayers():null}catch(a){this._handleError("matching",a,n)}s&&this._updateSublayersRecursively(s,r,o)}}_finalizeOldLayers(e){for(let r in e){let o=e[r];o&&this._finalizeLayer(o)}}_initializeLayer(e){try{e._initialize(),e.lifecycle=ui.INITIALIZED}catch(r){this._handleError("initialization",r,e)}}_transferLayerState(e,r){r._transferState(e),r.lifecycle=ui.MATCHED,r!==e&&(e.lifecycle=ui.AWAITING_GC)}_updateLayer(e){try{e._update()}catch(r){this._handleError("update",r,e)}}_finalizeLayer(e){this._needsRedraw=this._needsRedraw||`finalized ${e}`,e.lifecycle=ui.AWAITING_FINALIZATION;try{e._finalize(),e.lifecycle=ui.FINALIZED}catch(r){this._handleError("finalization",r,e)}}};function ie(t,e,r){if(t===e)return!0;if(!r||!t||!e)return!1;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let o=0;o<t.length;o++)if(!ie(t[o],e[o],r-1))return!1;return!0}if(Array.isArray(e))return!1;if(typeof t=="object"&&typeof e=="object"){let o=Object.keys(t),n=Object.keys(e);if(o.length!==n.length)return!1;for(let i of o)if(!e.hasOwnProperty(i)||!ie(t[i],e[i],r-1))return!1;return!0}return!1}var au=class{constructor(e){this.views=[],this.width=100,this.height=100,this.viewState={},this.controllers={},this.timeline=e.timeline,this._viewports=[],this._viewportMap={},this._isUpdating=!1,this._needsRedraw="First render",this._needsUpdate="Initialize",this._eventManager=e.eventManager,this._eventCallbacks={onViewStateChange:e.onViewStateChange,onInteractionStateChange:e.onInteractionStateChange},this._pickPosition=e.pickPosition,Object.seal(this),this.setProps(e)}finalize(){for(let e in this.controllers){let r=this.controllers[e];r&&r.finalize()}this.controllers={}}needsRedraw(e={clearRedrawFlags:!1}){let r=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),r}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e,this._needsRedraw=this._needsRedraw||e}updateViewStates(){for(let e in this.controllers){let r=this.controllers[e];r&&r.updateTransition()}}getViewports(e){return e?this._viewports.filter(r=>r.containsPixel(e)):this._viewports}getViews(){let e={};return this.views.forEach(r=>{e[r.id]=r}),e}getView(e){return this.views.find(r=>r.id===e)}getViewState(e){let r=typeof e=="string"?this.getView(e):e,o=r&&this.viewState[r.getViewStateId()]||this.viewState;return r?r.filterViewState(o):o}getViewport(e){return this._viewportMap[e]}unproject(e,r){let o=this.getViewports(),n={x:e[0],y:e[1]};for(let i=o.length-1;i>=0;--i){let s=o[i];if(s.containsPixel(n)){let a=e.slice();return a[0]-=s.x,a[1]-=s.y,s.unproject(a,r)}}return null}setProps(e){e.views&&this._setViews(e.views),e.viewState&&this._setViewState(e.viewState),("width"in e||"height"in e)&&this._setSize(e.width,e.height),"pickPosition"in e&&(this._pickPosition=e.pickPosition),this._isUpdating||this._update()}_update(){this._isUpdating=!0,this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._isUpdating=!1}_setSize(e,r){(e!==this.width||r!==this.height)&&(this.width=e,this.height=r,this.setNeedsUpdate("Size changed"))}_setViews(e){e=kt(e,Boolean),this._diffViews(e,this.views)&&this.setNeedsUpdate("views changed"),this.views=e}_setViewState(e){e?(!ie(e,this.viewState,3)&&this.setNeedsUpdate("viewState changed"),this.viewState=e):N.warn("missing `viewState` or `initialViewState`")()}_createController(e,r){let o=r.type;return new o({timeline:this.timeline,eventManager:this._eventManager,onViewStateChange:this._eventCallbacks.onViewStateChange,onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:i=>this.getView(e.id)?.makeViewport({viewState:i,width:this.width,height:this.height}),pickPosition:this._pickPosition})}_updateController(e,r,o,n){let i=e.controller;if(i&&o){let s={...r,...i,id:e.id,x:o.x,y:o.y,width:o.width,height:o.height};return(!n||n.constructor!==i.type)&&(n=this._createController(e,s)),n&&n.setProps(s),n}return null}_rebuildViewports(){let{views:e}=this,r=this.controllers;this._viewports=[],this.controllers={};let o=!1;for(let n=e.length;n--;){let i=e[n],s=this.getViewState(i),a=i.makeViewport({viewState:s,width:this.width,height:this.height}),c=r[i.id],l=Boolean(i.controller);l&&!c&&(o=!0),(o||!l)&&c&&(c.finalize(),c=null),this.controllers[i.id]=this._updateController(i,s,a,c),a&&this._viewports.unshift(a)}for(let n in r){let i=r[n];i&&!this.controllers[n]&&i.finalize()}this._buildViewportMap()}_buildViewportMap(){this._viewportMap={},this._viewports.forEach(e=>{e.id&&(this._viewportMap[e.id]=this._viewportMap[e.id]||e)})}_diffViews(e,r){return e.length!==r.length?!0:e.some((o,n)=>!e[n].equals(r[n]))}};var vq=/^(?:\d+\.?\d*|\.\d+)$/;function pn(t){switch(typeof t){case"number":if(!Number.isFinite(t))throw new Error(`Could not parse position string ${t}`);return{type:"literal",value:t};case"string":try{let e=Sq(t);return new Jv(e).parseExpression()}catch(e){let r=e instanceof Error?e.message:String(e);throw new Error(`Could not parse position string ${t}: ${r}`)}default:throw new Error(`Could not parse position string ${t}`)}}function Zv(t,e){switch(t.type){case"literal":return t.value;case"percentage":return Math.round(t.value*e);case"binary":let r=Zv(t.left,e),o=Zv(t.right,e);return t.operator==="+"?r+o:r-o;default:throw new Error("Unknown layout expression type")}}function mn(t,e){return Zv(t,e)}function Sq(t){let e=[],r=0;for(;r<t.length;){let o=t[r];if(/\s/.test(o)){r++;continue}if(o==="+"||o==="-"||o==="("||o===")"||o==="%"){e.push({type:"symbol",value:o}),r++;continue}if(M3(o)||o==="."){let n=r,i=o===".";for(r++;r<t.length;){let a=t[r];if(M3(a)){r++;continue}if(a==="."&&!i){i=!0,r++;continue}break}let s=t.slice(n,r);if(!vq.test(s))throw new Error("Invalid number token");e.push({type:"number",value:parseFloat(s)});continue}if(R3(o)){let n=r;for(;r<t.length&&R3(t[r]);)r++;let i=t.slice(n,r).toLowerCase();e.push({type:"word",value:i});continue}throw new Error("Invalid token in position string")}return e}var Jv=class{constructor(e){this.index=0,this.tokens=e}parseExpression(){let e=this.parseBinaryExpression();if(this.index<this.tokens.length)throw new Error("Unexpected token at end of expression");return e}parseBinaryExpression(){let e=this.parseFactor(),r=this.peek();for(;Cq(r);){this.index++;let o=this.parseFactor();e={type:"binary",operator:r.value,left:e,right:o},r=this.peek()}return e}parseFactor(){let e=this.peek();if(!e)throw new Error("Unexpected end of expression");if(e.type==="symbol"&&e.value==="+")return this.index++,this.parseFactor();if(e.type==="symbol"&&e.value==="-"){this.index++;let r=this.parseFactor();return{type:"binary",operator:"-",left:{type:"literal",value:0},right:r}}if(e.type==="symbol"&&e.value==="("){this.index++;let r=this.parseBinaryExpression();if(!this.consumeSymbol(")"))throw new Error("Missing closing parenthesis");return r}if(e.type==="word"&&e.value==="calc"){if(this.index++,!this.consumeSymbol("("))throw new Error("Missing opening parenthesis after calc");let r=this.parseBinaryExpression();if(!this.consumeSymbol(")"))throw new Error("Missing closing parenthesis");return r}if(e.type==="number"){this.index++;let r=e.value,o=this.peek();return o&&o.type==="symbol"&&o.value==="%"?(this.index++,{type:"percentage",value:r/100}):o&&o.type==="word"&&o.value==="px"?(this.index++,{type:"literal",value:r}):{type:"literal",value:r}}throw new Error("Unexpected token in expression")}consumeSymbol(e){let r=this.peek();return r&&r.type==="symbol"&&r.value===e?(this.index++,!0):!1}peek(){return this.tokens[this.index]||null}};function M3(t){return t>="0"&&t<="9"}function R3(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"}function Cq(t){return Boolean(t&&t.type==="symbol"&&(t.value==="+"||t.value==="-"))}function I3(t,e){let r={...t};for(let o in e)o!=="id"&&(Array.isArray(r[o])&&Array.isArray(e[o])?r[o]=Eq(r[o],e[o]):r[o]=e[o]);return r}function Eq(t,e){t=t.slice();for(let r=0;r<e.length;r++){let o=e[r];Number.isFinite(o)&&(t[r]=o)}return t}var Vt=class{constructor(e){let{id:r,x:o=0,y:n=0,width:i="100%",height:s="100%",padding:a=null}=e;this.id=r||this.constructor.displayName||"view",this.props={...e,id:this.id},this._x=pn(o),this._y=pn(n),this._width=pn(i),this._height=pn(s),this._padding=a&&{left:pn(a.left||0),right:pn(a.right||0),top:pn(a.top||0),bottom:pn(a.bottom||0)},this.equals=this.equals.bind(this),Object.seal(this)}equals(e){return this===e?!0:this.constructor===e.constructor&&ie(this.props,e.props,2)}clone(e){let r=this.constructor;return new r({...this.props,...e})}makeViewport({width:e,height:r,viewState:o}){o=this.filterViewState(o);let n=this.getDimensions({width:e,height:r});if(!n.height||!n.width)return null;let i=this.getViewportType(o);return new i({...o,...this.props,...n})}getViewStateId(){let{viewState:e}=this.props;return typeof e=="string"?e:e?.id||this.id}filterViewState(e){return this.props.viewState&&typeof this.props.viewState=="object"?this.props.viewState.id?I3(e,this.props.viewState):this.props.viewState:e}getDimensions({width:e,height:r}){let o={x:mn(this._x,e),y:mn(this._y,r),width:mn(this._width,e),height:mn(this._height,r)};return this._padding&&(o.padding={left:mn(this._padding.left,e),top:mn(this._padding.top,r),right:mn(this._padding.right,e),bottom:mn(this._padding.bottom,r)}),o}get controller(){let e=this.props.controller;return e?e===!0?{type:this.ControllerType}:typeof e=="function"?{type:e}:{type:this.ControllerType,...e}:null}};var eo=class{constructor(e){this._inProgress=!1,this._handle=null,this.time=0,this.settings={duration:0},this._timeline=e}get inProgress(){return this._inProgress}start(e){this.cancel(),this.settings=e,this._inProgress=!0,this.settings.onStart?.(this)}end(){this._inProgress&&(this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1,this.settings.onEnd?.(this))}cancel(){this._inProgress&&(this.settings.onInterrupt?.(this),this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1)}update(){if(!this._inProgress)return!1;if(this._handle===null){let{_timeline:e,settings:r}=this;this._handle=e.addChannel({delay:e.getTime(),duration:r.duration})}return this.time=this._timeline.getTime(this._handle),this._onUpdate(),this.settings.onUpdate?.(this),this._timeline.isFinished(this._handle)&&this.end(),!0}_onUpdate(){}};var L3=()=>{},cu={BREAK:1,SNAP_TO_END:2,IGNORE:3},wq=t=>t,Pq=cu.BREAK,lu=class{constructor(e){this._onTransitionUpdate=r=>{let{time:o,settings:{interpolator:n,startProps:i,endProps:s,duration:a,easing:c}}=r,l=c(o/a),f=n.interpolateProps(i,s,l);this.propsInTransition=this.getControllerState({...this.props,...f}).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})},this.getControllerState=e.getControllerState,this.propsInTransition=null,this.transition=new eo(e.timeline),this.onViewStateChange=e.onViewStateChange||L3,this.onStateChange=e.onStateChange||L3}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(e){let r=!1,o=this.props;if(this.props=e,!o||this._shouldIgnoreViewportChange(o,e))return!1;if(this._isTransitionEnabled(e)){let n=o;if(this.transition.inProgress){let{interruption:i,endProps:s}=this.transition.settings;n={...o,...i===cu.SNAP_TO_END?s:this.propsInTransition||o}}this._triggerTransition(n,e),r=!0}else this.transition.cancel();return r}updateTransition(){this.transition.update()}_isTransitionEnabled(e){let{transitionDuration:r,transitionInterpolator:o}=e;return(r>0||r==="auto")&&Boolean(o)}_isUpdateDueToCurrentTransition(e){return this.transition.inProgress&&this.propsInTransition?this.transition.settings.interpolator.arePropsEqual(e,this.propsInTransition):!1}_shouldIgnoreViewportChange(e,r){return this.transition.inProgress?this.transition.settings.interruption===cu.IGNORE||this._isUpdateDueToCurrentTransition(r):this._isTransitionEnabled(r)?r.transitionInterpolator.arePropsEqual(e,r):!0}_triggerTransition(e,r){let o=this.getControllerState(e),n=this.getControllerState(r).shortestPathFrom(o),i=r.transitionInterpolator,s=i.getDuration?i.getDuration(e,r):r.transitionDuration;if(s===0)return;let a=i.initializeProps(e,n);this.propsInTransition={};let c={duration:s,easing:r.transitionEasing||wq,interpolator:i,interruption:r.transitionInterruption||Pq,startProps:a.start,endProps:a.end,onStart:r.onTransitionStart,onUpdate:this._onTransitionUpdate,onInterrupt:this._onTransitionEnd(r.onTransitionInterrupt),onEnd:this._onTransitionEnd(r.onTransitionEnd)};this.transition.start(c),this.onStateChange({inTransition:!0}),this.updateTransition()}_onTransitionEnd(e){return r=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),e?.(r)}}};function ge(t,e){if(!t)throw new Error(e||"deck.gl: assertion failed.")}var gn=class{constructor(e){let{compare:r,extract:o,required:n}=e;this._propsToCompare=r,this._propsToExtract=o||r,this._requiredProps=n}arePropsEqual(e,r){for(let o of this._propsToCompare)if(!(o in e)||!(o in r)||!Ce(e[o],r[o]))return!1;return!0}initializeProps(e,r){let o={},n={};for(let i of this._propsToExtract)(i in e||i in r)&&(o[i]=e[i],n[i]=r[i]);return this._checkRequiredProps(o),this._checkRequiredProps(n),{start:o,end:n}}getDuration(e,r){return r.transitionDuration}_checkRequiredProps(e){this._requiredProps&&this._requiredProps.forEach(r=>{let o=e[r];ge(Number.isFinite(o)||Array.isArray(o),`${r} is required for transition`)})}};var Eg=Math.PI/180,B3=180/Math.PI,wg=6370972,_n=256;function Mq(){let t=_n/wg,e=Math.PI/180*_n;return{unitsPerMeter:[t,t,t],unitsPerMeter2:[0,0,0],metersPerUnit:[1/t,1/t,1/t],unitsPerDegree:[e,e,t],unitsPerDegree2:[0,0,0],degreesPerUnit:[1/e,1/e,1/t]}}var Pg=class extends ot{constructor(e={}){let{longitude:r=0,zoom:o=0,nearZMultiplier:n=.5,farZMultiplier:i=1,resolution:s=10}=e,{latitude:a=0,height:c,altitude:l=1.5,fovy:f}=e;a=Math.max(Math.min(a,Ut),-Ut),c=c||1,f?l=ln(f):f=cn(l);let u=Math.pow(2,o-Bo(a)),d=e.nearZ??n,h=e.farZ??(l+_n*2*u/c)*i,p=new V().lookAt({eye:[0,-l,0],up:[0,0,1]});p.rotateX(a*Eg),p.rotateZ(-r*Eg),p.scale(u/c),super({...e,height:c,viewMatrix:p,longitude:r,latitude:a,zoom:o,distanceScales:Mq(),fovy:f,focalDistance:l,near:d,far:h}),this.scale=u,this.latitude=a,this.longitude=r,this.fovy=f,this.resolution=s}get projectionMode(){return ft.GLOBE}getDistanceScales(){return this.distanceScales}getBounds(e={}){let r={targetZ:e.z||0},o=this.unproject([0,this.height/2],r),n=this.unproject([this.width/2,0],r),i=this.unproject([this.width,this.height/2],r),s=this.unproject([this.width/2,this.height],r);return i[0]<this.longitude&&(i[0]+=360),o[0]>this.longitude&&(o[0]-=360),[Math.min(o[0],i[0],n[0],s[0]),Math.min(o[1],i[1],n[1],s[1]),Math.max(o[0],i[0],n[0],s[0]),Math.max(o[1],i[1],n[1],s[1])]}unproject(e,{topLeft:r=!0,targetZ:o}={}){let[n,i,s]=e,a=r?i:this.height-i,{pixelUnprojectionMatrix:c}=this,l;if(Number.isFinite(s))l=Qv(c,[n,a,s,1]);else{let h=Qv(c,[n,a,-1,1]),p=Qv(c,[n,a,1,1]),m=((o||0)/wg+1)*_n,g=Ke.sqrLen(Ke.sub([],h,p)),_=Ke.sqrLen(h),x=Ke.sqrLen(p),b=4*((4*_*x-(g-_-x)**2)/16)/g,T=Math.sqrt(_-b),v=Math.sqrt(Math.max(0,m*m-b)),w=(T-v)/Math.sqrt(g);l=Ke.lerp([],h,p,w)}let[f,u,d]=this.unprojectPosition(l);return Number.isFinite(s)?[f,u,d]:Number.isFinite(o)?[f,u,o]:[f,u]}projectPosition(e){let[r,o,n=0]=e,i=r*Eg,s=o*Eg,a=Math.cos(s),c=(n/wg+1)*_n;return[Math.sin(i)*a*c,-Math.cos(i)*a*c,Math.sin(s)*c]}unprojectPosition(e){let[r,o,n]=e,i=Ke.len(e),s=Math.asin(n/i),c=Math.atan2(r,-o)*B3,l=s*B3,f=(i/_n-1)*wg;return[c,l,f]}projectFlat(e){return e}unprojectFlat(e){return e}panByPosition([e,r,o],n,i){let a=.25/Math.pow(2,this.zoom-Bo(this.latitude)),c=e+a*(i[0]-n[0]),l=r-a*(i[1]-n[1]);l=Math.max(Math.min(l,Ut),-Ut);let f={longitude:c,latitude:l,zoom:o-Bo(r)};return f.zoom+=Bo(f.latitude),f}};Pg.displayName="GlobeViewport";var Oo=Pg;function Bo(t){let e=Math.PI*Math.cos(t*Math.PI/180);return Math.log2(e)}function Qv(t,e){let r=Nt.transformMat4([],e,t);return Nt.scale(r,r,1/r[3]),r}var Rq=["longitude","latitude","zoom","bearing","pitch"],Iq=["longitude","latitude","zoom"],Ue=class extends gn{constructor(e={}){let r=Array.isArray(e)?e:e.transitionProps,o=Array.isArray(e)?{}:e;o.transitionProps=Array.isArray(r)?{compare:r,required:r}:r||{compare:Rq,required:Iq},super(o.transitionProps),this.opts=o}initializeProps(e,r){let o=super.initializeProps(e,r),{makeViewport:n,around:i}=this.opts;if(n&&i)if(n(e)instanceof Oo)N.warn("around not supported in GlobeView")();else{let a=n(e),c=n(r),l=a.unproject(i);o.start.around=i,Object.assign(o.end,{around:c.project(l),aroundPosition:l,width:r.width,height:r.height})}return o}interpolateProps(e,r,o){let n={};for(let i of this._propsToExtract)n[i]=lt(e[i]||0,r[i]||0,o);if(r.aroundPosition&&this.opts.makeViewport){let i=this.opts.makeViewport({...r,...n});Object.assign(n,i.panByPosition(r.aroundPosition,lt(e.around,r.around,o)))}return n}};var yn={transitionDuration:0},Lq=300,Mg=t=>1-(1-t)*(1-t),dc={WHEEL:["wheel"],PAN:["panstart","panmove","panend"],PINCH:["pinchstart","pinchmove","pinchend"],MULTI_PAN:["multipanstart","multipanmove","multipanend"],DOUBLE_CLICK:["dblclick"],KEYBOARD:["keydown"]},_s={},zt=class{constructor(e){this.state={},this._events={},this._interactionState={isDragging:!1},this._customEvents=[],this._eventStartBlocked=null,this._panMove=!1,this.invertPan=!1,this.dragMode="rotate",this.inertia=0,this.scrollZoom=!0,this.dragPan=!0,this.dragRotate=!0,this.doubleClickZoom=!0,this.touchZoom=!0,this.touchRotate=!1,this.keyboard=!0,this.transitionManager=new lu({...e,getControllerState:r=>new this.ControllerState(r),onViewStateChange:this._onTransition.bind(this),onStateChange:this._setInteractionState.bind(this)}),this.handleEvent=this.handleEvent.bind(this),this.eventManager=e.eventManager,this.onViewStateChange=e.onViewStateChange||(()=>{}),this.onStateChange=e.onStateChange||(()=>{}),this.makeViewport=e.makeViewport,this.pickPosition=e.pickPosition}set events(e){this.toggleEvents(this._customEvents,!1),this.toggleEvents(e,!0),this._customEvents=e,this.props&&this.setProps(this.props)}finalize(){for(let e in this._events)this._events[e]&&this.eventManager?.off(e,this.handleEvent);this.transitionManager.finalize()}handleEvent(e){this._controllerState=void 0;let r=this._eventStartBlocked;switch(e.type){case"panstart":return r?!1:this._onPanStart(e);case"panmove":return this._onPan(e);case"panend":return this._onPanEnd(e);case"pinchstart":return r?!1:this._onPinchStart(e);case"pinchmove":return this._onPinch(e);case"pinchend":return this._onPinchEnd(e);case"multipanstart":return r?!1:this._onMultiPanStart(e);case"multipanmove":return this._onMultiPan(e);case"multipanend":return this._onMultiPanEnd(e);case"dblclick":return this._onDoubleClick(e);case"wheel":return this._onWheel(e);case"keydown":return this._onKeyDown(e);default:return!1}}get controllerState(){return this._controllerState=this._controllerState||new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),this._controllerState}getCenter(e){let{x:r,y:o}=this.props,{offsetCenter:n}=e;return[n.x-r,n.y-o]}isPointInBounds(e,r){let{width:o,height:n}=this.props;if(r&&r.handled)return!1;let i=e[0]>=0&&e[0]<=o&&e[1]>=0&&e[1]<=n;return i&&r&&r.stopPropagation(),i}isFunctionKeyPressed(e){let{srcEvent:r}=e;return Boolean(r.metaKey||r.altKey||r.ctrlKey||r.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(e){let r=setTimeout(()=>{this._eventStartBlocked===r&&(this._eventStartBlocked=null)},e);this._eventStartBlocked=r}setProps(e){e.dragMode&&(this.dragMode=e.dragMode);let r=this.props;this.props=e,"transitionInterpolator"in e||(e.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(e);let{inertia:o}=e;this.inertia=Number.isFinite(o)?o:o===!0?Lq:0;let{scrollZoom:n=!0,dragPan:i=!0,dragRotate:s=!0,doubleClickZoom:a=!0,touchZoom:c=!0,touchRotate:l=!1,keyboard:f=!0}=e,u=Boolean(this.onViewStateChange);if(this.toggleEvents(dc.WHEEL,u&&n),this.toggleEvents(dc.PAN,u),this.toggleEvents(dc.PINCH,u&&(c||l)),this.toggleEvents(dc.MULTI_PAN,u&&l),this.toggleEvents(dc.DOUBLE_CLICK,u&&a),this.toggleEvents(dc.KEYBOARD,u&&f),this.scrollZoom=n,this.dragPan=i,this.dragRotate=s,this.doubleClickZoom=a,this.touchZoom=c,this.touchRotate=l,this.keyboard=f,(!r||r.height!==e.height||r.width!==e.width||r.maxBounds!==e.maxBounds)&&e.maxBounds){let h=new this.ControllerState({...e,makeViewport:this.makeViewport}),p=h.getViewportProps();Object.keys(p).some(g=>!ie(p[g],e[g],1))&&this.updateViewport(h)}}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(e,r){this.eventManager&&e.forEach(o=>{this._events[o]!==r&&(this._events[o]=r,r?this.eventManager.on(o,this.handleEvent):this.eventManager.off(o,this.handleEvent))})}updateViewport(e,r=null,o={}){let n={...e.getViewportProps(),...r},i=this.controllerState!==e;if(this.state=e.getState(),this._setInteractionState(o),i){let s=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:n,interactionState:this._interactionState,oldViewState:s,viewId:this.props.id})}}_onTransition(e){this.onViewStateChange({...e,interactionState:this._interactionState,viewId:this.props.id})}_setInteractionState(e){Object.assign(this._interactionState,e),this.onStateChange(this._interactionState)}_onPanStart(e){let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let o=this.isFunctionKeyPressed(e)||e.rightButton||!1;(this.invertPan||this.dragMode==="pan")&&(o=!o);let n=this.controllerState[o?"panStart":"rotateStart"]({pos:r});return this._panMove=o,this.updateViewport(n,yn,{isDragging:!0}),!0}_onPan(e){return this.isDragging()?this._panMove?this._onPanMove(e):this._onPanRotate(e):!1}_onPanEnd(e){return this.isDragging()?this._panMove?this._onPanMoveEnd(e):this._onPanRotateEnd(e):!1}_onPanMove(e){if(!this.dragPan)return!1;let r=this.getCenter(e),o=this.controllerState.pan({pos:r});return this.updateViewport(o,yn,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(e){let{inertia:r}=this;if(this.dragPan&&r&&e.velocity){let o=this.getCenter(e),n=[o[0]+e.velocityX*r/2,o[1]+e.velocityY*r/2],i=this.controllerState.pan({pos:n}).panEnd();this.updateViewport(i,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:Mg},{isDragging:!1,isPanning:!0})}else{let o=this.controllerState.panEnd();this.updateViewport(o,null,{isDragging:!1,isPanning:!1})}return!0}_onPanRotate(e){if(!this.dragRotate)return!1;let r=this.getCenter(e),o=this.controllerState.rotate({pos:r});return this.updateViewport(o,yn,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(e){let{inertia:r}=this;if(this.dragRotate&&r&&e.velocity){let o=this.getCenter(e),n=[o[0]+e.velocityX*r/2,o[1]+e.velocityY*r/2],i=this.controllerState.rotate({pos:n}).rotateEnd();this.updateViewport(i,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:Mg},{isDragging:!1,isRotating:!0})}else{let o=this.controllerState.rotateEnd();this.updateViewport(o,null,{isDragging:!1,isRotating:!1})}return!0}_onWheel(e){if(!this.scrollZoom)return!1;let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;e.srcEvent.preventDefault();let{speed:o=.01,smooth:n=!1}=this.scrollZoom===!0?{}:this.scrollZoom,{delta:i}=e,s=2/(1+Math.exp(-Math.abs(i*o)));i<0&&s!==0&&(s=1/s);let a=n?{...this._getTransitionProps({around:r}),transitionDuration:250}:yn,c=this.controllerState.zoom({pos:r,scale:s});return this.updateViewport(c,a,{isZooming:!0,isPanning:!0}),n||this._setInteractionState({isZooming:!1,isPanning:!1}),!0}_onMultiPanStart(e){let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let o=this.controllerState.rotateStart({pos:r});return this.updateViewport(o,yn,{isDragging:!0}),!0}_onMultiPan(e){if(!this.touchRotate||!this.isDragging())return!1;let r=this.getCenter(e);r[0]-=e.deltaX;let o=this.controllerState.rotate({pos:r});return this.updateViewport(o,yn,{isDragging:!0,isRotating:!0}),!0}_onMultiPanEnd(e){if(!this.isDragging())return!1;let{inertia:r}=this;if(this.touchRotate&&r&&e.velocityY){let o=this.getCenter(e),n=[o[0],o[1]+=e.velocityY*r/2],i=this.controllerState.rotate({pos:n});this.updateViewport(i,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:Mg},{isDragging:!1,isRotating:!0}),this.blockEvents(r)}else{let o=this.controllerState.rotateEnd();this.updateViewport(o,null,{isDragging:!1,isRotating:!1})}return!0}_onPinchStart(e){let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let o=this.controllerState.zoomStart({pos:r}).rotateStart({pos:r});return _s._startPinchRotation=e.rotation,_s._lastPinchEvent=e,this.updateViewport(o,yn,{isDragging:!0}),!0}_onPinch(e){if(!this.touchZoom&&!this.touchRotate||!this.isDragging())return!1;let r=this.controllerState;if(this.touchZoom){let{scale:o}=e,n=this.getCenter(e);r=r.zoom({pos:n,scale:o})}if(this.touchRotate){let{rotation:o}=e;r=r.rotate({deltaAngleX:_s._startPinchRotation-o})}return this.updateViewport(r,yn,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),_s._lastPinchEvent=e,!0}_onPinchEnd(e){if(!this.isDragging())return!1;let{inertia:r}=this,{_lastPinchEvent:o}=_s;if(this.touchZoom&&r&&o&&e.scale!==o.scale){let n=this.getCenter(e),i=this.controllerState.rotateEnd(),s=Math.log2(e.scale),a=(s-Math.log2(o.scale))/(e.deltaTime-o.deltaTime),c=Math.pow(2,s+a*r/2);i=i.zoom({pos:n,scale:c}).zoomEnd(),this.updateViewport(i,{...this._getTransitionProps({around:n}),transitionDuration:r,transitionEasing:Mg},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(r)}else{let n=this.controllerState.zoomEnd().rotateEnd();this.updateViewport(n,null,{isDragging:!1,isPanning:!1,isZooming:!1,isRotating:!1})}return _s._startPinchRotation=null,_s._lastPinchEvent=null,!0}_onDoubleClick(e){if(!this.doubleClickZoom)return!1;let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let o=this.isFunctionKeyPressed(e),n=this.controllerState.zoom({pos:r,scale:o?.5:2});return this.updateViewport(n,this._getTransitionProps({around:r}),{isZooming:!0,isPanning:!0}),this.blockEvents(100),!0}_onKeyDown(e){if(!this.keyboard)return!1;let r=this.isFunctionKeyPressed(e),{zoomSpeed:o,moveSpeed:n,rotateSpeedX:i,rotateSpeedY:s}=this.keyboard===!0?{}:this.keyboard,{controllerState:a}=this,c,l={};switch(e.srcEvent.code){case"Minus":c=r?a.zoomOut(o).zoomOut(o):a.zoomOut(o),l.isZooming=!0;break;case"Equal":c=r?a.zoomIn(o).zoomIn(o):a.zoomIn(o),l.isZooming=!0;break;case"ArrowLeft":r?(c=a.rotateLeft(i),l.isRotating=!0):(c=a.moveLeft(n),l.isPanning=!0);break;case"ArrowRight":r?(c=a.rotateRight(i),l.isRotating=!0):(c=a.moveRight(n),l.isPanning=!0);break;case"ArrowUp":r?(c=a.rotateUp(s),l.isRotating=!0):(c=a.moveUp(n),l.isPanning=!0);break;case"ArrowDown":r?(c=a.rotateDown(s),l.isRotating=!0):(c=a.moveDown(n),l.isPanning=!0);break;default:return!1}return this.updateViewport(c,this._getTransitionProps(),l),!0}_getTransitionProps(e){let{transition:r}=this;return!r||!r.transitionInterpolator?yn:e?{...r,transitionInterpolator:new Ue({...e,...r.transitionInterpolator.opts,makeViewport:this.controllerState.makeViewport})}:r}};var to=class{constructor(e,r,o){this.makeViewport=o,this._viewportProps=this.applyConstraints(e),this._state=r}getViewportProps(){return this._viewportProps}getState(){return this._state}};var O3=5,Bq=1.2,F3=512,N3=[[-1/0,-90],[1/0,90]];function Rg([t,e]){if(Math.abs(e)>90&&(e=Math.sign(e)*90),Number.isFinite(t)){let[o,n]=Oe([t,e]);return[o,ee(n,0,F3)]}let[,r]=Oe([0,e]);return[t,ee(r,0,F3)]}var fu=class extends to{constructor(e){let{width:r,height:o,latitude:n,longitude:i,zoom:s,bearing:a=0,pitch:c=0,altitude:l=1.5,position:f=[0,0,0],maxZoom:u=20,minZoom:d=0,maxPitch:h=60,minPitch:p=0,startPanLngLat:m,startZoomLngLat:g,startRotatePos:_,startRotateLngLat:x,startBearing:y,startPitch:b,startZoom:T,normalize:v=!0}=e;ge(Number.isFinite(i)),ge(Number.isFinite(n)),ge(Number.isFinite(s));let w=e.maxBounds||(v?N3:null);super({width:r,height:o,latitude:n,longitude:i,zoom:s,bearing:a,pitch:c,altitude:l,maxZoom:u,minZoom:d,maxPitch:h,minPitch:p,normalize:v,position:f,maxBounds:w},{startPanLngLat:m,startZoomLngLat:g,startRotatePos:_,startRotateLngLat:x,startBearing:y,startPitch:b,startZoom:T},e.makeViewport),this.getAltitude=e.getAltitude}panStart({pos:e}){return this._getUpdatedState({startPanLngLat:this._unproject(e)})}pan({pos:e,startPos:r}){let o=this.getState().startPanLngLat||this._unproject(r);if(!o)return this;let i=this.makeViewport(this.getViewportProps()).panByPosition(o,e);return this._getUpdatedState(i)}panEnd(){return this._getUpdatedState({startPanLngLat:null})}rotateStart({pos:e}){let r=this.getAltitude?.(e);return this._getUpdatedState({startRotatePos:e,startRotateLngLat:r!==void 0?this._unproject3D(e,r):void 0,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:e,deltaAngleX:r=0,deltaAngleY:o=0}){let{startRotatePos:n,startRotateLngLat:i,startBearing:s,startPitch:a}=this.getState();if(!n||s===void 0||a===void 0)return this;let c;if(e?c=this._getNewRotation(e,n,a,s):c={bearing:s+r,pitch:a+o},i){let l=this.makeViewport({...this.getViewportProps(),...c}),f="panByPosition3D"in l?"panByPosition3D":"panByPosition";return this._getUpdatedState({...c,...l[f](i,n)})}return this._getUpdatedState(c)}rotateEnd(){return this._getUpdatedState({startRotatePos:null,startRotateLngLat:null,startBearing:null,startPitch:null})}zoomStart({pos:e}){return this._getUpdatedState({startZoomLngLat:this._unproject(e),startZoom:this.getViewportProps().zoom})}zoom({pos:e,startPos:r,scale:o}){let{startZoom:n,startZoomLngLat:i}=this.getState();if(i||(n=this.getViewportProps().zoom,i=this._unproject(r)||this._unproject(e)),!i)return this;let s=this._constrainZoom(n+Math.log2(o)),a=this.makeViewport({...this.getViewportProps(),zoom:s});return this._getUpdatedState({zoom:s,...a.panByPosition(i,e)})}zoomEnd(){return this._getUpdatedState({startZoomLngLat:null,startZoom:null})}zoomIn(e=2){return this._zoomFromCenter(e)}zoomOut(e=2){return this._zoomFromCenter(1/e)}moveLeft(e=100){return this._panFromCenter([e,0])}moveRight(e=100){return this._panFromCenter([-e,0])}moveUp(e=100){return this._panFromCenter([0,e])}moveDown(e=100){return this._panFromCenter([0,-e])}rotateLeft(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-e})}rotateRight(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+e})}rotateUp(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+e})}rotateDown(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-e})}shortestPathFrom(e){let r=e.getViewportProps(),o={...this.getViewportProps()},{bearing:n,longitude:i}=o;return Math.abs(n-r.bearing)>180&&(o.bearing=n<0?n+360:n-360),Math.abs(i-r.longitude)>180&&(o.longitude=i<0?i+360:i-360),o}applyConstraints(e){let{maxPitch:r,minPitch:o,pitch:n,longitude:i,bearing:s,normalize:a,maxBounds:c}=e;if(a&&((i<-180||i>180)&&(e.longitude=Ro(i+180,360)-180),(s<-180||s>180)&&(e.bearing=Ro(s+180,360)-180)),e.pitch=ee(n,o,r),e.zoom=this._constrainZoom(e.zoom,e),c){let l=Rg(c[0]),f=Rg(c[1]),u=2**e.zoom,d=e.width/2/u,h=e.height/2/u,[p,m]=pt([l[0]+d,l[1]+h]),[g,_]=pt([f[0]-d,f[1]-h]);e.longitude=ee(e.longitude,p,g),e.latitude=ee(e.latitude,m,_)}return e}_constrainZoom(e,r){r||(r=this.getViewportProps());let{maxZoom:o,maxBounds:n}=r,i=n!==null&&r.width>0&&r.height>0,{minZoom:s}=r;if(i){let a=Rg(n[0]),c=Rg(n[1]),l=c[0]-a[0],f=c[1]-a[1];Number.isFinite(l)&&l>0&&(s=Math.max(s,Math.log2(r.width/l))),Number.isFinite(f)&&f>0&&(s=Math.max(s,Math.log2(r.height/f))),s>o&&(s=o)}return ee(e,s,o)}_zoomFromCenter(e){let{width:r,height:o}=this.getViewportProps();return this.zoom({pos:[r/2,o/2],scale:e})}_panFromCenter(e){let{width:r,height:o}=this.getViewportProps();return this.pan({startPos:[r/2,o/2],pos:[r/2+e[0],o/2+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}_unproject(e){let r=this.makeViewport(this.getViewportProps());return e&&r.unproject(e)}_unproject3D(e,r){return this.makeViewport(this.getViewportProps()).unproject(e,{targetZ:r})}_getNewRotation(e,r,o,n){let i=e[0]-r[0],s=e[1]-r[1],a=e[1],c=r[1],{width:l,height:f}=this.getViewportProps(),u=i/l,d=0;s>0?Math.abs(f-c)>O3&&(d=s/(c-f)*Bq):s<0&&c>O3&&(d=1-a/c),d=ee(d,-1,1);let{minPitch:h,maxPitch:p}=this.getViewportProps(),m=n+180*u,g=o;return d>0?g=o+d*(p-o):d<0&&(g=o-d*(h-o)),{pitch:g,bearing:m}}},xn=class extends zt{constructor(){super(...arguments),this.ControllerState=fu,this.transition={transitionDuration:300,transitionInterpolator:new Ue({transitionProps:{compare:["longitude","latitude","zoom","bearing","pitch","position"],required:["longitude","latitude","zoom"]}})},this.dragMode="pan",this.rotationPivot="center",this._getAltitude=e=>{if(this.rotationPivot==="2d")return 0;if(this.rotationPivot==="3d"&&this.pickPosition){let{x:r,y:o}=this.props,n=this.pickPosition(r+e[0],o+e[1]);if(n&&n.coordinate&&n.coordinate.length>=3)return n.coordinate[2]}}}setProps(e){"rotationPivot"in e&&(this.rotationPivot=e.rotationPivot||"center"),e.getAltitude=this._getAltitude,e.position=e.position||[0,0,0],e.maxBounds=e.maxBounds||(e.normalize===!1?null:N3),super.setProps(e)}updateViewport(e,r=null,o={}){let n=e.getState();o.isDragging&&n.startRotateLngLat?o={...o,rotationPivotPosition:n.startRotateLngLat}:o.isDragging===!1&&(o={...o,rotationPivotPosition:void 0}),super.updateViewport(e,r,o)}};var Ig=class extends Vt{constructor(e={}){super(e)}getViewportType(){return Mt}get ControllerType(){return xn}};Ig.displayName="MapView";var di=Ig;var Oq=new ai;function Fq(t,e){let r=t.order??1/0,o=e.order??1/0;return r-o}var uu=class{constructor(e){this._resolvedEffects=[],this._defaultEffects=[],this.effects=[],this._context=e,this._needsRedraw="Initial render",this._setEffects([])}addDefaultEffect(e){let r=this._defaultEffects;if(!r.find(o=>o.id===e.id)){let o=r.findIndex(n=>Fq(n,e)>0);o<0?r.push(e):r.splice(o,0,e),e.setup(this._context),this._setEffects(this.effects)}}setProps(e){"effects"in e&&(ie(e.effects,this.effects,1)||this._setEffects(e.effects))}needsRedraw(e={clearRedrawFlags:!1}){let r=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),r}getEffects(){return this._resolvedEffects}_setEffects(e){let r={};for(let n of this.effects)r[n.id]=n;let o=[];for(let n of e){let i=r[n.id],s=n;i&&i!==n?i.setProps?(i.setProps(n.props),s=i):i.cleanup(this._context):i||n.setup(this._context),o.push(s),delete r[n.id]}for(let n in r)r[n].cleanup(this._context);this.effects=o,this._resolvedEffects=o.concat(this._defaultEffects),e.some(n=>n instanceof ai)||this._resolvedEffects.push(Oq),this._needsRedraw="effects changed"}finalize(){for(let e of this._resolvedEffects)e.cleanup(this._context);this.effects.length=0,this._resolvedEffects.length=0,this._defaultEffects.length=0}};var du=class extends At{shouldDrawLayer(e){let{operation:r}=e.props;return r.includes("draw")||r.includes("terrain")}render(e){return this._render(e)}};var Nq="deckRenderer.renderLayers",ys=class{constructor(e,r={}){this.device=e,this.stats=r.stats,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new du(e),this.pickLayersPass=new Jr(e),this.renderCount=0,this._needsRedraw="Initial render",this.renderBuffers=[],this.lastPostProcessEffect=null}setProps(e){this.layerFilter!==e.layerFilter&&(this.layerFilter=e.layerFilter,this._needsRedraw="layerFilter changed"),this.drawPickingColors!==e.drawPickingColors&&(this.drawPickingColors=e.drawPickingColors,this._needsRedraw="drawPickingColors changed")}renderLayers(e){if(!e.viewports.length)return;let r=this.drawPickingColors?this.pickLayersPass:this.drawLayersPass,o={layerFilter:this.layerFilter,isPicking:this.drawPickingColors,...e};o.effects&&this._preRender(o.effects,o);let n=this.lastPostProcessEffect?this.renderBuffers[0]:o.target;this.lastPostProcessEffect&&(o.clearColor=[0,0,0,0],o.clearCanvas=!0);let i=r.render({...o,target:n}),s="stats"in i?i.stats:i;o.effects&&(this.lastPostProcessEffect&&(o.clearCanvas=e.clearCanvas===void 0?!0:e.clearCanvas),this._postRender(o.effects,o)),this.renderCount++,He(Nq,this,s,e),this._updateStats(s)}needsRedraw(e={clearRedrawFlags:!1}){let r=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),r}finalize(){let{renderBuffers:e}=this;for(let r of e)r.delete();e.length=0}_updateStats(e){if(!this.stats)return;let r=0;for(let{visibleCount:o}of e)r+=o;this.stats.get("Layers rendered").addCount(r)}_preRender(e,r){this.lastPostProcessEffect=null,r.preRenderStats=r.preRenderStats||{};for(let o of e)r.preRenderStats[o.id]=o.preRender(r),o.postRender&&(this.lastPostProcessEffect=o.id);this.lastPostProcessEffect&&this._resizeRenderBuffers()}_resizeRenderBuffers(){let{renderBuffers:e}=this,r=this.device.canvasContext.getDrawingBufferSize(),[o,n]=r;e.length===0&&[0,1].map(i=>{let s=this.device.createTexture({sampler:{minFilter:"linear",magFilter:"linear"},width:o,height:n});e.push(this.device.createFramebuffer({id:`deck-renderbuffer-${i}`,colorAttachments:[s]}))});for(let i of e)i.resize(r)}_postRender(e,r){let{renderBuffers:o}=this,n={...r,inputBuffer:o[0],swapBuffer:o[1]};for(let i of e)if(i.postRender){n.target=i.id===this.lastPostProcessEffect?r.target:void 0;let s=i.postRender(n);n.inputBuffer=s,n.swapBuffer=s===o[0]?o[1]:o[0]}}};q();var Dq={pickedColor:null,pickedObjectIndex:-1};function e1({pickedColors:t,decodePickingColor:e,deviceX:r,deviceY:o,deviceRadius:n,deviceRect:i}){let{x:s,y:a,width:c,height:l}=i,f=n*n,u=-1,d=0;for(let h=0;h<l;h++){let p=h+a-o,m=p*p;if(m>f)d+=4*c;else for(let g=0;g<c;g++){if(t[d+3]-1>=0){let x=g+s-r,y=x*x+m;y<=f&&(f=y,u=d)}d+=4}}if(u>=0){let h=t.slice(u,u+4),p=e(h);if(p){let m=Math.floor(u/4/c),g=u/4-m*c;return{...p,pickedColor:h,pickedX:s+g,pickedY:a+m}}N.error("Picked non-existent layer. Is picking buffer corrupt?")()}return Dq}function t1({pickedColors:t,decodePickingColor:e}){let r=new Map;if(t){for(let o=0;o<t.length;o+=4)if(t[o+3]-1>=0){let i=t.slice(o,o+4),s=i.join(",");if(!r.has(s)){let a=e(i);a?r.set(s,{...a,color:i}):N.error("Picked non-existent layer. Is picking buffer corrupt?")()}}}return Array.from(r.values())}function Lg({pickInfo:t,viewports:e,pixelRatio:r,x:o,y:n,z:i}){let s=e[0];e.length>1&&(s=Uq(t?.pickedViewports||e,{x:o,y:n}));let a;if(s){let c=[o-s.x,n-s.y];i!==void 0&&(c[2]=i),a=s.unproject(c)}return{color:null,layer:null,viewport:s,index:-1,picked:!1,x:o,y:n,pixel:[o,n],coordinate:a,devicePixel:t&&"pickedX"in t?[t.pickedX,t.pickedY]:void 0,pixelRatio:r}}function r1(t){let{pickInfo:e,lastPickedInfo:r,mode:o,layers:n}=t,{pickedColor:i,pickedLayer:s,pickedObjectIndex:a}=e,c=s?[s]:[];if(o==="hover"){let u=r.index,d=r.layerId,h=s?s.props.id:null;if(h!==d||a!==u){if(h!==d){let p=n.find(m=>m.props.id===d);p&&c.unshift(p)}r.layerId=h,r.index=a,r.info=null}}let l=Lg(t),f=new Map;return f.set(null,l),c.forEach(u=>{let d={...l};u===s&&(d.color=i,d.index=a,d.picked=!0),d=Bg({layer:u,info:d,mode:o});let h=d.layer;u===s&&o==="hover"&&(r.info=d),f.set(h.id,d),o==="hover"&&h.updateAutoHighlight(d)}),f}function Bg({layer:t,info:e,mode:r}){for(;t&&e;){let o=e.layer||null;e.sourceLayer=o,e.layer=t,e=t.getPickingInfo({info:e,mode:r,sourceLayer:o}),t=t.parent}return e}function Uq(t,e){for(let r=t.length-1;r>=0;r--){let o=t[r];if(o.containsPixel(e))return o}return t[0]}var hu=class{constructor(e,r={}){this._pickable=!0,this.device=e,this.stats=r.stats,this.pickLayersPass=new Jr(e),this.lastPickedInfo={index:-1,layerId:null,info:null}}setProps(e){"layerFilter"in e&&(this.layerFilter=e.layerFilter),"_pickable"in e&&(this._pickable=e._pickable)}finalize(){this.pickingFBO&&this.pickingFBO.destroy(),this.depthFBO&&this.depthFBO.destroy()}pickObjectAsync(e){return this._pickClosestObjectAsync(e)}pickObjectsAsync(e){return this._pickVisibleObjectsAsync(e)}pickObject(e){return this._pickClosestObject(e)}pickObjects(e){return this._pickVisibleObjects(e)}getLastPickedObject({x:e,y:r,layers:o,viewports:n},i=this.lastPickedInfo.info){let s=i&&i.layer&&i.layer.id,a=i&&i.viewport&&i.viewport.id,c=s?o.find(d=>d.id===s):null,l=a&&n.find(d=>d.id===a)||n[0],f=l&&l.unproject([e-l.x,r-l.y]);return{...i,...{x:e,y:r,viewport:l,coordinate:f,layer:c}}}_resizeBuffer(e=this.device.getDefaultCanvasContext()){if(!this.pickingFBO){let n=this.device.createTexture({format:"rgba8unorm",width:1,height:1,usage:Y.RENDER_ATTACHMENT|Y.COPY_SRC});if(this.pickingFBO=this.device.createFramebuffer({colorAttachments:[n],depthStencilAttachment:"depth16unorm"}),this.device.isTextureFormatRenderable("rgba32float")){let i=this.device.createTexture({format:"rgba32float",width:1,height:1,usage:Y.RENDER_ATTACHMENT|Y.COPY_SRC}),s=this.device.createFramebuffer({colorAttachments:[i],depthStencilAttachment:"depth16unorm"});this.depthFBO=s}}let[r,o]=e.getDrawingBufferSize();this.pickingFBO?.resize({width:r,height:o}),this.depthFBO?.resize({width:r,height:o})}_getPickable(e){if(this._pickable===!1)return null;let r=e.filter(o=>this.pickLayersPass.shouldDrawLayer(o)&&!o.isComposite);return r.length?r:null}async _pickClosestObjectAsync({layers:e,views:r,viewports:o,x:n,y:i,radius:s=0,depth:a=1,mode:c="query",unproject3D:l,canvasContext:f=this.device.getDefaultCanvasContext(),onViewportActive:u,effects:d}){let h=f.cssToDeviceRatio(),p=this._getPickable(e);if(!p||o.length===0)return{result:[],emptyInfo:Lg({viewports:o,x:n,y:i,pixelRatio:h})};this._resizeBuffer(f);let m=f.cssToDevicePixels([n,i],!0),g=[m.x+Math.floor(m.width/2),m.y+Math.floor(m.height/2)],_=Math.round(s*h),{width:x,height:y}=this.pickingFBO,b=this._getPickingRect({deviceX:g[0],deviceY:g[1],deviceRadius:_,deviceWidth:x,deviceHeight:y}),T={x:n-s,y:i-s,width:s*2+1,height:s*2+1},v,w=[],C=new Set;for(let S=0;S<a;S++){let A;if(b){let O=await this._drawAndSampleAsync({layers:p,views:r,viewports:o,onViewportActive:u,deviceRect:b,cullRect:T,effects:d,pass:`picking:${c}`});A=e1({...O,deviceX:g[0],deviceY:g[1],deviceRadius:_,deviceRect:b})}else A={pickedColor:null,pickedObjectIndex:-1};let M,B=this._getDepthLayers(A,p,l);if(B.length>0){let{pickedColors:O}=await this._drawAndSampleAsync({layers:B,views:r,viewports:o,onViewportActive:u,deviceRect:{x:A.pickedX??g[0],y:A.pickedY??g[1],width:1,height:1},cullRect:T,effects:d,pass:`picking:${c}:z`},!0);O[3]&&(M=O[0])}A.pickedLayer&&S+1<a&&(C.add(A.pickedLayer),A.pickedLayer.disablePickingIndex(A.pickedObjectIndex)),v=r1({pickInfo:A,lastPickedInfo:this.lastPickedInfo,mode:c,layers:p,viewports:o,x:n,y:i,z:M,pixelRatio:h});for(let O of v.values())O.layer&&w.push(O);if(!A.pickedColor)break}for(let S of C)S.restorePickingColors();return{result:w,emptyInfo:v.get(null)}}_pickClosestObject({layers:e,views:r,viewports:o,x:n,y:i,radius:s=0,depth:a=1,mode:c="query",unproject3D:l,canvasContext:f=this.device.getDefaultCanvasContext(),onViewportActive:u,effects:d}){let h=f.cssToDeviceRatio(),p=this._getPickable(e);if(!p||o.length===0)return{result:[],emptyInfo:Lg({viewports:o,x:n,y:i,pixelRatio:h})};this._resizeBuffer(f);let m=f.cssToDevicePixels([n,i],!0),g=[m.x+Math.floor(m.width/2),m.y+Math.floor(m.height/2)],_=Math.round(s*h),{width:x,height:y}=this.pickingFBO,b=this._getPickingRect({deviceX:g[0],deviceY:g[1],deviceRadius:_,deviceWidth:x,deviceHeight:y}),T={x:n-s,y:i-s,width:s*2+1,height:s*2+1},v,w=[],C=new Set;for(let S=0;S<a;S++){let A;if(b){let O=this._drawAndSample({layers:p,views:r,viewports:o,onViewportActive:u,deviceRect:b,cullRect:T,effects:d,pass:`picking:${c}`});A=e1({...O,deviceX:g[0],deviceY:g[1],deviceRadius:_,deviceRect:b})}else A={pickedColor:null,pickedObjectIndex:-1};let M,B=this._getDepthLayers(A,p,l);if(B.length>0){let{pickedColors:O}=this._drawAndSample({layers:B,views:r,viewports:o,onViewportActive:u,deviceRect:{x:A.pickedX??g[0],y:A.pickedY??g[1],width:1,height:1},cullRect:T,effects:d,pass:`picking:${c}:z`},!0);O[3]&&(M=O[0])}A.pickedLayer&&S+1<a&&(C.add(A.pickedLayer),A.pickedLayer.disablePickingIndex(A.pickedObjectIndex)),v=r1({pickInfo:A,lastPickedInfo:this.lastPickedInfo,mode:c,layers:p,viewports:o,x:n,y:i,z:M,pixelRatio:h});for(let O of v.values())O.layer&&w.push(O);if(!A.pickedColor)break}for(let S of C)S.restorePickingColors();return{result:w,emptyInfo:v.get(null)}}async _pickVisibleObjectsAsync({layers:e,views:r,viewports:o,x:n,y:i,width:s=1,height:a=1,mode:c="query",maxObjects:l=null,canvasContext:f=this.device.getDefaultCanvasContext(),onViewportActive:u,effects:d}){let h=this._getPickable(e);if(!h||o.length===0)return[];this._resizeBuffer(f);let p=f.cssToDeviceRatio(),m=f.cssToDevicePixels([n,i],!0),g=m.x,_=m.y+m.height,x=f.cssToDevicePixels([n+s,i+a],!0),y=x.x+x.width,b=x.y,T={x:g,y:b,width:y-g,height:_-b},v=await this._drawAndSampleAsync({layers:h,views:r,viewports:o,onViewportActive:u,deviceRect:T,cullRect:{x:n,y:i,width:s,height:a},effects:d,pass:`picking:${c}`}),w=t1(v),C=new Map,S=[],A=Number.isFinite(l);for(let M=0;M<w.length&&!(A&&S.length>=l);M++){let B=w[M],O={color:B.pickedColor,layer:null,index:B.pickedObjectIndex,picked:!0,x:n,y:i,pixelRatio:p};O=Bg({layer:B.pickedLayer,info:O,mode:c});let F=O.layer.id;C.has(F)||C.set(F,new Set);let X=C.get(F),G=O.object??O.index;X.has(G)||(X.add(G),S.push(O))}return S}_pickVisibleObjects({layers:e,views:r,viewports:o,x:n,y:i,width:s=1,height:a=1,mode:c="query",maxObjects:l=null,canvasContext:f=this.device.getDefaultCanvasContext(),onViewportActive:u,effects:d}){let h=this._getPickable(e);if(!h||o.length===0)return[];this._resizeBuffer(f);let p=f.cssToDeviceRatio(),m=f.cssToDevicePixels([n,i],!0),g=m.x,_=m.y+m.height,x=f.cssToDevicePixels([n+s,i+a],!0),y=x.x+x.width,b=x.y,T={x:g,y:b,width:y-g,height:_-b},v=this._drawAndSample({layers:h,views:r,viewports:o,onViewportActive:u,deviceRect:T,cullRect:{x:n,y:i,width:s,height:a},effects:d,pass:`picking:${c}`}),w=t1(v),C=new Map,S=[],A=Number.isFinite(l);for(let M=0;M<w.length&&!(A&&S.length>=l);M++){let B=w[M],O={color:B.pickedColor,layer:null,index:B.pickedObjectIndex,picked:!0,x:n,y:i,pixelRatio:p};O=Bg({layer:B.pickedLayer,info:O,mode:c});let F=O.layer.id;C.has(F)||C.set(F,new Set);let X=C.get(F),G=O.object??O.index;X.has(G)||(X.add(G),S.push(O))}return S}async _drawAndSampleAsync({layers:e,views:r,viewports:o,onViewportActive:n,deviceRect:i,cullRect:s,effects:a,pass:c},l=!1){let f=l?this.depthFBO:this.pickingFBO,u={layers:e,layerFilter:this.layerFilter,views:r,viewports:o,onViewportActive:n,pickingFBO:f,deviceRect:i,cullRect:s,effects:a,pass:c,pickZ:l,preRenderStats:{},isPicking:!0};for(let b of a)b.useInPicking&&(u.preRenderStats[b.id]=b.preRender(u));let{decodePickingColor:d,stats:h}=this.pickLayersPass.render(u);this._updateStats(h);let{x:p,y:m,width:g,height:_}=i,x=f.colorAttachments[0]?.texture;if(!x)throw new Error("Picking framebuffer color attachment is missing");let y=await this._readTextureDataAsync(x,{x:p,y:m,width:g,height:_},l?Float32Array:Uint8Array);if(!l){let b=!1;for(let T=3;T<y.length;T+=4)if(y[T]!==0){b=!0;break}!b&&y.length>0&&N.warn("Async pick readback returned only zero alpha values",{deviceRect:i,bytes:Array.from(y.subarray(0,Math.min(y.length,16)))})()}return{pickedColors:y,decodePickingColor:d}}async _readTextureDataAsync(e,r,o){let{width:n,height:i}=r,s=e.computeMemoryLayout(r),a=this.device.createBuffer({byteLength:s.byteLength,usage:K.COPY_DST|K.MAP_READ});try{e.readBuffer(r,a);let c=await a.readAsync(0,s.byteLength),l=o.BYTES_PER_ELEMENT;if(s.bytesPerRow%l!==0)throw new Error(`Texture readback row stride ${s.bytesPerRow} is not aligned to ${l}-byte elements.`);let f=new o(c.buffer,c.byteOffset,s.byteLength/l),u=n*4,d=s.bytesPerRow/l;if(d<u)throw new Error(`Texture readback row stride ${d} is smaller than packed row length ${u}.`);let h=new o(n*i*4);for(let p=0;p<i;p++){let m=p*d;h.set(f.subarray(m,m+u),p*u)}return h}finally{a.destroy()}}_drawAndSample({layers:e,views:r,viewports:o,onViewportActive:n,deviceRect:i,cullRect:s,effects:a,pass:c},l=!1){let f=l?this.depthFBO:this.pickingFBO,u={layers:e,layerFilter:this.layerFilter,views:r,viewports:o,onViewportActive:n,pickingFBO:f,deviceRect:i,cullRect:s,effects:a,pass:c,pickZ:l,preRenderStats:{},isPicking:!0};for(let y of a)y.useInPicking&&(u.preRenderStats[y.id]=y.preRender(u));let{decodePickingColor:d,stats:h}=this.pickLayersPass.render(u);this._updateStats(h);let{x:p,y:m,width:g,height:_}=i,x=new(l?Float32Array:Uint8Array)(g*_*4);return this.device.readPixelsToArrayWebGL(f,{sourceX:p,sourceY:m,sourceWidth:g,sourceHeight:_,target:x}),{pickedColors:x,decodePickingColor:d}}_updateStats(e){if(!this.stats)return;let r=0;for(let{visibleCount:o}of e)r+=o;this.stats.get("Layers picked").addCount(r)}_getDepthLayers(e,r,o){if(!o||!this.depthFBO)return[];let{pickedLayer:n}=e,i=n?.state?.terrainDrawMode==="drape";return n&&!i?[n]:r.filter(s=>s.props.operation.includes("terrain"))}_getPickingRect({deviceX:e,deviceY:r,deviceRadius:o,deviceWidth:n,deviceHeight:i}){let s=Math.max(0,e-o),a=Math.max(0,r-o),c=Math.min(n,e+o+1)-s,l=Math.min(i,r+o+1)-a;return c<=0||l<=0?null:{x:s,y:a,width:c,height:l}}};var kq={"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0},"bottom-right":{bottom:0,right:0},fill:{top:0,left:0,bottom:0,right:0}},Vq="top-left",D3="root",Og=class{constructor({deck:e,parentElement:r}){this.defaultWidgets=[],this.widgets=[],this.resolvedWidgets=[],this.containers={},this.lastViewports={},this.deck=e,r?.classList.add("deck-widget-container"),this.parentElement=r}getWidgets(){return this.resolvedWidgets}setProps(e){if(e.widgets&&!ie(e.widgets,this.widgets,1)){let r=e.widgets.filter(Boolean);this._setWidgets(r)}}finalize(){for(let e of this.getWidgets())this._removeWidget(e);this.defaultWidgets.length=0,this.resolvedWidgets.length=0;for(let e in this.containers)this.containers[e].remove()}addDefault(e){this.defaultWidgets.find(r=>r.id===e.id)||(this._addWidget(e),this.defaultWidgets.push(e),this._setWidgets(this.widgets))}onRedraw({viewports:e,layers:r}){let o=e.reduce((n,i)=>(n[i.id]=i,n),{});for(let n of this.getWidgets()){let{viewId:i}=n;if(i){let s=o[i];s&&(n.onViewportChange&&n.onViewportChange(s),n.onRedraw?.({viewports:[s],layers:r}))}else{if(n.onViewportChange)for(let s of e)n.onViewportChange(s);n.onRedraw?.({viewports:e,layers:r})}}this.lastViewports=o,this._updateContainers()}onHover(e,r){for(let o of this.getWidgets()){let{viewId:n}=o;(!n||n===e.viewport?.id)&&o.onHover?.(e,r)}}onEvent(e,r){let o=Ja[r.type];if(o)for(let n of this.getWidgets()){let{viewId:i}=n;(!i||i===e.viewport?.id)&&n[o]?.(e,r)}}_setWidgets(e){let r={};for(let o of this.resolvedWidgets)r[o.id]=o;this.resolvedWidgets.length=0;for(let o of this.defaultWidgets)r[o.id]=null,this.resolvedWidgets.push(o);for(let o of e){let n=r[o.id];n?n.viewId!==o.viewId||n.placement!==o.placement?(this._removeWidget(n),this._addWidget(o)):o!==n&&(n.setProps(o.props),o=n):this._addWidget(o),r[o.id]=null,this.resolvedWidgets.push(o)}for(let o in r){let n=r[o];n&&this._removeWidget(n)}this.widgets=e}_addWidget(e){let{viewId:r=null,placement:o=Vq}=e,n=e.props._container??r;e.widgetManager=this,e.deck=this.deck,e.rootElement=e._onAdd({deck:this.deck,viewId:r}),e.rootElement&&this._getContainer(n,o).append(e.rootElement),e.updateHTML()}_removeWidget(e){e.onRemove?.(),e.rootElement&&e.rootElement.remove(),e.rootElement=void 0,e.deck=void 0,e.widgetManager=void 0}_getContainer(e,r){if(e&&typeof e!="string")return e;let o=e||D3,n=this.containers[o];n||(n=document.createElement("div"),n.style.pointerEvents="none",n.style.position="absolute",n.style.overflow="hidden",this.parentElement?.append(n),this.containers[o]=n);let i=n.querySelector(`.${r}`);return i||(i=globalThis.document.createElement("div"),i.className=r,i.style.position="absolute",i.style.zIndex="2",Object.assign(i.style,kq[r]),n.append(i)),i}_updateContainers(){let e=this.deck.width,r=this.deck.height;for(let o in this.containers){let n=this.lastViewports[o]||null,i=o===D3||n,s=this.containers[o];i?(s.style.display="block",s.style.left=`${n?n.x:0}px`,s.style.top=`${n?n.y:0}px`,s.style.width=`${n?n.width:e}px`,s.style.height=`${n?n.height:r}px`):s.style.display="none"}}};function xs(t,e){e&&Object.entries(e).map(([r,o])=>{r.startsWith("--")?t.style.setProperty(r,o):t.style[r]=o})}function Fg(t,e){e&&Object.keys(e).map(r=>{r.startsWith("--")?t.style.removeProperty(r):t.style[r]=""})}var $=class{constructor(e){this.viewId=null,this.props={...this.constructor.defaultProps,...e},this.id=this.props.id}setProps(e){let r=this.props,o=this.rootElement;o&&r.className!==e.className&&(r.className&&o.classList.remove(r.className),e.className&&o.classList.add(e.className)),o&&!ie(r.style,e.style,1)&&(Fg(o,r.style),xs(o,e.style)),Object.assign(this.props,e),this.updateHTML()}updateHTML(){this.rootElement&&this.onRenderHTML(this.rootElement)}get viewIds(){return this.viewId?[this.viewId]:this.deck?.getViews().map(e=>e.id)??[]}getViewState(e){return this.deck?.viewManager?.getViewState(e)||{}}setViewState(e,r){this.deck?._onViewStateChange({viewId:e,viewState:r,interactionState:{}})}onCreateRootElement(){let e=["deck-widget",this.className,this.props.className],r=document.createElement("div");return e.filter(o=>typeof o=="string"&&o.length>0).forEach(o=>r.classList.add(o)),xs(r,this.props.style),r}_onAdd(e){return this.onAdd(e)??this.onCreateRootElement()}onAdd(e){}onRemove(){}onViewportChange(e){}onRedraw(e){}onHover(e,r){}onClick(e,r){}onDrag(e,r){}onDragStart(e,r){}onDragEnd(e,r){}};$.defaultProps={id:"widget",style:{},_container:null,className:""};var zq={zIndex:"1",position:"absolute",pointerEvents:"none",color:"#a0a7b4",backgroundColor:"#29323c",padding:"10px",top:"0",left:"0",display:"none"},pu=class extends ${constructor(e={}){super(e),this.id="default-tooltip",this.placement="fill",this.className="deck-tooltip",this.isVisible=!1,this.setProps(e)}onCreateRootElement(){let e=document.createElement("div");return e.className=this.className,Object.assign(e.style,zq),e}onRenderHTML(e){}onViewportChange(e){this.isVisible&&e.id===this.lastViewport?.id&&!e.equals(this.lastViewport)&&this.setTooltip(null),this.lastViewport=e}onHover(e){let{deck:r}=this,o=r&&r.props.getTooltip;if(!o)return;let n=o(e);this.setTooltip(n,e.x,e.y)}setTooltip(e,r,o){let n=this.rootElement;if(n){if(typeof e=="string")n.innerText=e;else if(e)e.text&&(n.innerText=e.text),e.html&&(n.innerHTML=e.html),e.className&&(n.className=e.className);else{this.isVisible=!1,n.style.display="none";return}this.isVisible=!0,n.style.display="block",n.style.transform=`translate(${r}px, ${o}px)`,e&&typeof e=="object"&&"style"in e&&Object.assign(n.style,e.style)}}};pu.defaultProps={...$.defaultProps};q();Au();Xi();function bn(){}var ZZ=({isDragging:t})=>t?"grabbing":"grab",cB={id:"",width:"100%",height:"100%",style:null,viewState:null,initialViewState:null,pickingRadius:0,pickAsync:"auto",layerFilter:null,parameters:{},parent:null,device:null,deviceProps:{},gl:null,canvas:null,layers:[],effects:[],views:null,controller:null,useDevicePixels:!0,touchAction:"none",eventRecognizerOptions:{},_framebuffer:null,_animate:!1,_pickable:!0,_typedArrayManagerProps:{},_customRender:null,widgets:[],onDeviceInitialized:bn,onWebGLInitialized:bn,onResize:bn,onViewStateChange:bn,onInteractionStateChange:bn,onBeforeRender:bn,onAfterRender:bn,onLoad:bn,onError:t=>N.error(t.message,t.cause)(),onHover:null,onClick:null,onDragStart:null,onDrag:null,onDragEnd:null,_onMetrics:null,getCursor:ZZ,getTooltip:null,debug:!1,drawPickingColors:!1},Su=class{constructor(e){this.width=0,this.height=0,this.userData={},this.device=null,this.canvas=null,this.viewManager=null,this.layerManager=null,this.effectManager=null,this.deckRenderer=null,this.deckPicker=null,this.eventManager=null,this.widgetManager=null,this.tooltip=null,this.animationLoop=null,this._canvasContext=null,this._deviceResizeHandler=null,this.cursorState={isHovering:!1,isDragging:!1},this.stats=new Et({id:"deck.gl"}),this.metrics={fps:0,setPropsTime:0,layersCount:0,drawLayersCount:0,updateLayersCount:0,updateAttributesCount:0,updateAttributesTime:0,framesRedrawn:0,pickTime:0,pickCount:0,pickLayersCount:0,gpuTime:0,gpuTimePerFrame:0,cpuTime:0,cpuTimePerFrame:0,bufferMemory:0,textureMemory:0,renderbufferMemory:0,gpuMemory:0},this._metricsCounter=0,this._hoverPickSequence=0,this._pointerDownPickSequence=0,this._needsRedraw="Initial render",this._pickRequest={mode:"hover",x:-1,y:-1,radius:0,event:null,unproject3D:!1},this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=null,this._onPointerMove=n=>{let{_pickRequest:i}=this;if(n.type==="pointerleave")i.x=-1,i.y=-1,i.radius=0;else{if(n.leftButton||n.rightButton)return;{let s=n.offsetCenter;if(!s)return;i.x=s.x,i.y=s.y,i.radius=this.props.pickingRadius}}this.layerManager&&(this.layerManager.context.mousePosition={x:i.x,y:i.y}),i.event=n},this._onEvent=n=>{let i=Ja[n.type],s=n.offsetCenter;if(!i||!s||!this.layerManager)return;let a=this.layerManager.getLayers(),c=this._getInternalPickingMode();if(!c)return;if(c==="sync"){let f=n.type==="click"&&this._shouldUnproject3D(a)?this._getFirstPickedInfo(this._pickPointSync(this._getPointPickOptions(s.x,s.y,{unproject3D:!0},a))):this._getLastPointerDownPickingInfo(s.x,s.y,a);this._dispatchPickingEvent(f,n);return}(this._lastPointerDownInfoPromise||Promise.resolve(this._getLastPointerDownPickingInfo(s.x,s.y,a))).then(f=>{this._dispatchPickingEvent(f,n)}).catch(f=>this.props.onError?.(f))},this._onPointerDown=n=>{let i=n.offsetCenter;if(!i)return;let s=this._getInternalPickingMode();if(!s)return;let a=this.layerManager?.getLayers()||[],c=++this._pointerDownPickSequence;if(s==="sync"){let f=this._pickPointSync({x:i.x,y:i.y,radius:this.props.pickingRadius}),u=this._getFirstPickedInfo(f);this._lastPointerDownInfo=u,this._lastPointerDownInfoPromise=Promise.resolve(u);return}let l=this._pickPointAsync(this._getPointPickOptions(i.x,i.y,{},a)).then(f=>this._getFirstPickedInfo(f)).then(f=>(c===this._pointerDownPickSequence&&(this._lastPointerDownInfo=f),f)).catch(f=>{this.props.onError?.(f);let u=this.deckPicker&&this.viewManager?this._getLastPointerDownPickingInfo(i.x,i.y,a):{};return c===this._pointerDownPickSequence&&(this._lastPointerDownInfo=u),u});this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=l};let r=e;this.props={...cB,...e},e=this.props,e.viewState&&e.initialViewState&&N.warn("View state tracking is disabled. Use either `initialViewState` for auto update or `viewState` for manual update.")(),this.viewState=this.props.initialViewState,e.device&&(this.device=e.device,this._setDeviceCanvasContext(e.device));let o=this.device;!o&&e.gl&&(e.gl instanceof WebGLRenderingContext&&N.error("WebGL1 context not supported.")(),o=vu.attach(e.gl,{_cacheShaders:!0,_cachePipelines:!0,...this.props.deviceProps})),o||(o=this._createDevice(e)),this.animationLoop=this._createAnimationLoop(o,e),this.setProps(r),e._typedArrayManagerProps&&Zr.setOptions(e._typedArrayManagerProps),this.animationLoop.start()}finalize(){this._restoreDeviceResizeHandler(),this.animationLoop?.stop(),this.animationLoop?.destroy(),this.animationLoop=null,this._hoverPickSequence++,this._pointerDownPickSequence++,this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=null,this.layerManager?.finalize(),this.layerManager=null,this.viewManager?.finalize(),this.viewManager=null,this.effectManager?.finalize(),this.effectManager=null,this.deckRenderer?.finalize(),this.deckRenderer=null,this.deckPicker?.finalize(),this.deckPicker=null,this.eventManager?.destroy(),this.eventManager=null,this.widgetManager?.finalize(),this.widgetManager=null,!this.props.canvas&&!this.props.device&&!this.props.gl&&this.canvas&&(this.canvas.parentElement?.removeChild(this.canvas),this.canvas=null),this._canvasContext=null}setProps(e){this.stats.get("setProps Time").timeStart(),"onLayerHover"in e&&N.removed("onLayerHover","onHover")(),"onLayerClick"in e&&N.removed("onLayerClick","onClick")(),e.initialViewState&&!ie(this.props.initialViewState,e.initialViewState,3)&&(this.viewState=e.initialViewState),Object.assign(this.props,e),this._validateInternalPickingMode(),this._setCanvasSize(this.props);let r=Object.create(this.props);if(Object.assign(r,{views:this._getViews(),width:this.width,height:this.height,viewState:this._getViewState()}),e.device&&e.device.id!==this.device?.id){let o=e.device.getDefaultCanvasContext();this.animationLoop?.stop(),this.canvas!==o.canvas&&(this.canvas?.remove(),this.eventManager?.destroy(),this.canvas=null),this._setDeviceCanvasContext(e.device),N.log(`recreating animation loop for new device! id=${e.device.id}`)(),this.animationLoop=this._createAnimationLoop(e.device,e),this.animationLoop.start()}this.animationLoop?.setProps(r),e.useDevicePixels!==void 0&&this._canvasContext?.setProps&&this._canvasContext.setProps({useDevicePixels:e.useDevicePixels}),this.layerManager&&(this.viewManager.setProps(r),this.layerManager.activateViewport(this.getViewports()[0]),this.layerManager.setProps(r),this.effectManager.setProps(r),this.deckRenderer.setProps(r),this.deckPicker.setProps(r),this.widgetManager.setProps(r)),this.stats.get("setProps Time").timeEnd()}needsRedraw(e={clearRedrawFlags:!1}){if(!this.layerManager)return!1;if(this.props._animate)return"Deck._animate";let r=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);let o=this.viewManager.needsRedraw(e),n=this.layerManager.needsRedraw(e),i=this.effectManager.needsRedraw(e),s=this.deckRenderer.needsRedraw(e);return r=r||o||n||i||s,r}redraw(e){if(!this.layerManager)return;let r=this.needsRedraw({clearRedrawFlags:!0});r=e||r,r&&(this.stats.get("Redraw Count").incrementCount(),this.props._customRender?this.props._customRender(r):this._drawLayers(r))}get isInitialized(){return this.viewManager!==null}getViews(){return ge(this.viewManager),this.viewManager.views}getView(e){return ge(this.viewManager),this.viewManager.getView(e)}getViewports(e){return ge(this.viewManager),this.viewManager.getViewports(e)}getCanvas(){return this.canvas}async pickObjectAsync(e){let r=(await this._pickAsync("pickObjectAsync","pickObject Time",e)).result;return r.length?r[0]:null}async pickObjectsAsync(e){return await this._pickAsync("pickObjectsAsync","pickObjects Time",e)}pickObject(e){let r=this._pick("pickObject","pickObject Time",e).result;return r.length?r[0]:null}pickMultipleObjects(e){return e.depth=e.depth||10,this._pick("pickObject","pickMultipleObjects Time",e).result}pickObjects(e){return this._pick("pickObjects","pickObjects Time",e)}_pickPositionForController(e,r){return this._getInternalPickingMode()!=="sync"?null:this.pickObject({x:e,y:r,radius:0,unproject3D:!0})}_addResources(e,r=!1){for(let o in e)this.layerManager.resourceManager.add({resourceId:o,data:e[o],forceUpdate:r})}_removeResources(e){for(let r of e)this.layerManager.resourceManager.remove(r)}_addDefaultEffect(e){this.effectManager.addDefaultEffect(e)}_addDefaultShaderModule(e){this.layerManager.addDefaultShaderModule(e)}_removeDefaultShaderModule(e){this.layerManager?.removeDefaultShaderModule(e)}_resolveInternalPickingMode(){let{pickAsync:e}=this.props,r=this.device?.type||this.props.deviceProps?.type;if(e==="auto")return r==="webgpu"?"async":"sync";if(e==="sync"&&r==="webgpu")throw new Error('`pickAsync: "sync"` is not supported when Deck is using a WebGPU device.');return e}_getInternalPickingMode(){try{return this._resolveInternalPickingMode()}catch(e){return this.props.onError?.(e),null}}_validateInternalPickingMode(){this._getInternalPickingMode()}_getFirstPickedInfo({result:e,emptyInfo:r}){return e[0]||r}_shouldUnproject3D(e=this.layerManager?.getLayers()||[]){return e.some(r=>r.props.pickable==="3d")}_getPointPickOptions(e,r,o={},n=this.layerManager?.getLayers()||[]){return{x:e,y:r,radius:this.props.pickingRadius,unproject3D:this._shouldUnproject3D(n),...o}}_pickPointSync(e){return this._pick("pickObject","pickObject Time",e)}_pickPointAsync(e){return this._pickAsync("pickObjectAsync","pickObject Time",e)}_getLastPointerDownPickingInfo(e,r,o=this.layerManager?.getLayers()||[]){return this.deckPicker.getLastPickedObject({x:e,y:r,layers:o,viewports:this.getViewports({x:e,y:r})},this._lastPointerDownInfo)}_applyHoverCallbacks({result:e,emptyInfo:r},o){if(!this.widgetManager)return;this.cursorState.isHovering=e.length>0;let n=r,i=!1;for(let s of e)n=s,i=s.layer?.onHover(s,o)||i;i||(this.props.onHover?.(n,o),this.widgetManager.onHover(n,o))}_dispatchPickingEvent(e,r){if(!this.layerManager||!this.widgetManager)return;let o=Ja[r.type];if(!o)return;let{layer:n}=e,i=n&&(n[o]||n.props[o]),s=this.props[o],a=!1;i&&(a=i.call(n,e,r)),a||(s?.(e,r),this.widgetManager.onEvent(e,r))}_pickAsync(e,r,o){ge(this.deckPicker);let{stats:n}=this;n.get("Pick Count").incrementCount(),n.get(r).timeStart();let i=this.deckPicker[e]({layers:this.layerManager.getLayers(o),views:this.viewManager.getViews(),viewports:this.getViewports(o),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...o,canvasContext:this._canvasContext||void 0});return n.get(r).timeEnd(),i}_pick(e,r,o){ge(this.deckPicker);let{stats:n}=this;n.get("Pick Count").incrementCount(),n.get(r).timeStart();let i=this.deckPicker[e]({layers:this.layerManager.getLayers(o),views:this.viewManager.getViews(),viewports:this.getViewports(o),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...o,canvasContext:this._canvasContext||void 0});return n.get(r).timeEnd(),i}_createCanvas(e){let r=e.canvas;return typeof r=="string"&&(r=document.getElementById(r),ge(r)),r||(r=document.createElement("canvas"),r.id=e.id||"deckgl-overlay",e.width&&typeof e.width=="number"&&(r.width=e.width),e.height&&typeof e.height=="number"&&(r.height=e.height),(e.parent||document.body).appendChild(r)),Object.assign(r.style,e.style),r}_setCanvasContext(e){this._canvasContext=e,"style"in e.canvas&&(this.canvas=e.canvas)}_setDeviceCanvasContext(e,r={}){let o=e.getDefaultCanvasContext();this._setCanvasContext(o),this._setDeviceResizeHandler(e,r)}_setDeviceResizeHandler(e,r={}){let o=Boolean(r.syncDrawingBuffer);if(this._deviceResizeHandler?.device===e){this._deviceResizeHandler.syncDrawingBuffer=o;return}this._restoreDeviceResizeHandler();let n=i=>{i===this._canvasContext&&this._canvasContext&&this._onCanvasContextResize(this._canvasContext,{syncDrawingBuffer:this._deviceResizeHandler?.syncDrawingBuffer})};e.props.onResize=n,this._deviceResizeHandler={device:e,onResize:n,syncDrawingBuffer:o}}_restoreDeviceResizeHandler(){let e=this._deviceResizeHandler;e&&e.device.props?.onResize===e.onResize&&(e.device.props.onResize=bn),this._deviceResizeHandler=null}_setCanvasSize(e){if(!this.canvas)return;let{width:r,height:o}=e;if(r||r===0){let n=Number.isFinite(r)?`${r}px`:r;this.canvas.style.width=n}if(o||o===0){let n=Number.isFinite(o)?`${o}px`:o;this.canvas.style.position=e.style?.position||"absolute",this.canvas.style.height=n}}_updateCanvasSize(e=this._canvasContext){let{canvas:r}=this,[o,n]=e?e.getCSSSize():[r?.clientWidth??r?.width??0,r?.clientHeight??r?.height??0];(o!==this.width||n!==this.height)&&(this.width=o,this.height=n,this.viewManager?.setProps({width:o,height:n}),this.layerManager?.activateViewport(this.getViewports()[0]),this.props.onResize({width:o,height:n},e||void 0))}_onCanvasContextResize(e,r={}){if(r.syncDrawingBuffer){let{width:o,height:n}=e.canvas;e.setDrawingBufferSize(o,n)}this._needsRedraw="Canvas resized",this._updateCanvasSize(e)}_createAnimationLoop(e,r){let{gl:o,onError:n}=r;return new lc({device:e,autoResizeDrawingBuffer:!o,autoResizeViewport:!1,onInitialize:i=>this._setDevice(i.device),onRender:this._onRenderFrame.bind(this),onError:n})}_createDevice(e){let r=this.props.deviceProps?.createCanvasContext,o=typeof r=="object"?r:void 0,n={adapters:[],_cacheShaders:!0,_cachePipelines:!0,...e.deviceProps};n.adapters.includes(vu)||n.adapters.push(vu);let i={alphaMode:this.props.deviceProps?.type==="webgpu"?"premultiplied":void 0};return Co.createDevice({_reuseDevices:!0,type:"webgl",...n,createCanvasContext:{...i,...o,canvas:this._createCanvas(e),useDevicePixels:this.props.useDevicePixels,autoResize:!0}})}_getViewState(){return this.props.viewState||this.viewState}_getViews(){let{views:e}=this.props,r=Array.isArray(e)?e:e?[e]:[new di({id:"default-view"})];return r.length&&this.props.controller&&(r[0].props.controller=this.props.controller),r}_onContextLost(){let{onError:e}=this.props;this.animationLoop&&e&&e(new Error("WebGL context is lost"))}_pickAndCallback(){let{_pickRequest:e}=this;if(e.event){let r=e.event,o=this.layerManager?.getLayers()||[],n=this._getPointPickOptions(e.x,e.y,{radius:e.radius,mode:e.mode},o),i=this._getInternalPickingMode(),s=++this._hoverPickSequence;if(e.event=null,!i)return;if(i==="sync"){this._applyHoverCallbacks(this._pickPointSync(n),r);return}this._pickPointAsync(n).then(({result:a,emptyInfo:c})=>{s===this._hoverPickSequence&&this._applyHoverCallbacks({result:a,emptyInfo:c},r)}).catch(a=>this.props.onError?.(a))}}_updateCursor(){let e=this.props.parent||this.canvas;e&&(e.style.cursor=this.props.getCursor(this.cursorState))}_setDevice(e){if(this.device=e,this._validateInternalPickingMode(),!this.animationLoop)return;this._setDeviceCanvasContext(e,{syncDrawingBuffer:Boolean(this.props.gl&&this.props.device!==e)}),this.canvas&&!this.canvas.isConnected&&this.props.parent&&this.props.parent.insertBefore(this.canvas,this.props.parent.firstChild),this.device.type==="webgl"&&this.device.setParametersWebGL({blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthTest:!0,depthFunc:515}),this.props.onDeviceInitialized(this.device),this.device.type==="webgl"&&this.props.onWebGLInitialized(this.device.gl);let r=new ps;r.play(),this.animationLoop.attachTimeline(r);let o=this.props.parent?.querySelector(".deck-events-root")||this.canvas;this.eventManager=new zf(o,{touchAction:this.props.touchAction,recognizers:Object.keys(Sv).map(s=>{let[a,c,l,f]=Sv[s],u=this.props.eventRecognizerOptions?.[s],d={...c,...u,event:s};return{recognizer:new a(d),recognizeWith:l,requireFailure:f}}),events:{pointerdown:this._onPointerDown,pointermove:this._onPointerMove,pointerleave:this._onPointerMove}});for(let s in Ja)this.eventManager.on(s,this._onEvent);this.viewManager=new au({timeline:r,eventManager:this.eventManager,onViewStateChange:this._onViewStateChange.bind(this),onInteractionStateChange:this._onInteractionStateChange.bind(this),pickPosition:this._pickPositionForController.bind(this),views:this._getViews(),viewState:this._getViewState(),width:this.width,height:this.height});let n=this.viewManager.getViewports()[0];this.layerManager=new gs(this.device,{deck:this,stats:this.stats,viewport:n,timeline:r}),this.effectManager=new uu({deck:this,device:this.device}),this.deckRenderer=new ys(this.device,{stats:this.stats}),this.deckPicker=new hu(this.device,{stats:this.stats});let i=this.props.parent?.querySelector(".deck-widgets-root")||this.canvas?.parentElement;this.widgetManager=new Og({deck:this,parentElement:i}),this.widgetManager.addDefault(new pu),this.setProps({}),this._updateCanvasSize(this._canvasContext),this.props.onLoad()}_drawLayers(e,r){let{device:o,gl:n}=this.layerManager.context;this.props.onBeforeRender({device:o,gl:n});let i={target:this.props._framebuffer,layers:this.layerManager.getLayers(),viewports:this.viewManager.getViewports(),onViewportActive:this.layerManager.activateViewport,views:this.viewManager.getViews(),pass:"screen",effects:this.effectManager.getEffects(),...r};this.deckRenderer?.renderLayers(i),i.pass==="screen"&&this.widgetManager.onRedraw({viewports:i.viewports,layers:i.layers}),this.props.onAfterRender({device:o,gl:n})}_onRenderFrame(){this._getFrameStats(),this._metricsCounter++%60===0&&(this._getMetrics(),this.stats.reset(),N.table(4,this.metrics)(),this.props._onMetrics&&this.props._onMetrics(this.metrics)),this._updateCursor(),this.layerManager.updateLayers(),this._pickAndCallback(),this.redraw(),this.viewManager&&this.viewManager.updateViewStates()}_onViewStateChange(e){let r=this.props.onViewStateChange(e)||e.viewState;this.viewState&&(this.viewState={...this.viewState,[e.viewId]:r},this.props.viewState||this.viewManager&&this.viewManager.setProps({viewState:this.viewState}))}_onInteractionStateChange(e){this.cursorState.isDragging=e.isDragging||!1,this.props.onInteractionStateChange(e)}_getFrameStats(){let{stats:e}=this;e.get("frameRate").timeEnd(),e.get("frameRate").timeStart();let r=this.animationLoop.stats;e.get("GPU Time").addTime(r.get("GPU Time").lastTiming),e.get("CPU Time").addTime(r.get("CPU Time").lastTiming)}_getMetrics(){let{metrics:e,stats:r}=this;e.fps=r.get("frameRate").getHz(),e.setPropsTime=r.get("setProps Time").time,e.updateAttributesTime=r.get("Update Attributes").time,e.framesRedrawn=r.get("Redraw Count").count,e.pickTime=r.get("pickObject Time").time+r.get("pickMultipleObjects Time").time+r.get("pickObjects Time").time,e.pickCount=r.get("Pick Count").count,e.layersCount=this.layerManager?.layers.length??0,e.drawLayersCount=r.get("Layers rendered").lastSampleCount,e.pickLayersCount=r.get("Layers picked").lastSampleCount,e.updateAttributesCount=r.get("Layers updated").count,e.updateAttributesCount=r.get("Attributes updated").count,e.gpuTime=r.get("GPU Time").time,e.cpuTime=r.get("CPU Time").time,e.gpuTimePerFrame=r.get("GPU Time").getAverageTime(),e.cpuTimePerFrame=r.get("CPU Time").getAverageTime();let o=Co.stats.get("GPU Time and Memory");e.bufferMemory=o.get("Buffer Memory").count,e.textureMemory=o.get("Texture Memory").count,e.renderbufferMemory=o.get("Renderbuffer Memory").count,e.gpuMemory=o.get("GPU Memory").count}};Su.defaultProps=cB;Su.VERSION=em;var An=Su;q();q();function lB(t){switch(t){case"float64":return Float64Array;case"uint8":case"unorm8":return Uint8ClampedArray;default:return Lf(t)}}var fB=Dt.getDataType.bind(Dt);function Cu(t,e,r){if(e.size>4)return null;let o=r==="webgpu"&&e.type==="uint8"?"unorm8":e.type;return{attribute:t,format:e.size>1?`${o}x${e.size}`:e.type,byteOffset:e.offset||0}}function pi(t){return t.stride||t.size*t.bytesPerElement}function uB(t,e){return t.type===e.type&&t.size===e.size&&pi(t)===pi(e)&&(t.offset||0)===(e.offset||0)}function M1(t,e){e.offset&&N.removed("shaderAttribute.offset","vertexOffset, elementOffset")();let r=pi(t),o=e.vertexOffset!==void 0?e.vertexOffset:t.vertexOffset||0,n=e.elementOffset||0,i=o*r+n*t.bytesPerElement+(t.offset||0);return{...e,offset:i,stride:r}}function JZ(t,e){let r=M1(t,e);return{high:r,low:{...r,offset:r.offset+t.size*4}}}var Eu=class{constructor(e,r,o){this._buffer=null,this.device=e,this.id=r.id||"",this.size=r.size||1;let n=r.logicalType||r.type,i=n==="float64",{defaultValue:s}=r;s=Number.isFinite(s)?[s]:s||new Array(this.size).fill(0);let a;i?a="float32":!n&&r.isIndexed?a="uint32":a=n||"float32";let c=lB(n||a);this.doublePrecision=i,i&&r.fp64===!1&&(c=Float32Array),this.value=null,this.settings={...r,defaultType:c,defaultValue:s,logicalType:n,type:a,normalized:a.includes("norm"),size:this.size,bytesPerElement:c.BYTES_PER_ELEMENT},this.state={...o,externalBuffer:null,bufferAccessor:this.settings,allocatedValue:null,numInstances:0,bounds:null,constant:!1}}get isConstant(){return this.state.constant}get buffer(){return this._buffer}get byteOffset(){let e=this.getAccessor();return e.vertexOffset?e.vertexOffset*pi(e):0}get numInstances(){return this.state.numInstances}set numInstances(e){this.state.numInstances=e}delete(){this._buffer&&(this._buffer.delete(),this._buffer=null),Zr.release(this.state.allocatedValue)}getBuffer(){return this.state.constant?null:this.state.externalBuffer||this._buffer}getValue(e=this.id,r=null){let o={};if(this.state.constant){let n=this.value;if(r){let i=M1(this.getAccessor(),r),s=i.offset/n.BYTES_PER_ELEMENT,a=i.size||this.size;o[e]=n.subarray(s,s+a)}else o[e]=n}else o[e]=this.getBuffer();return this.doublePrecision&&(this.value instanceof Float64Array?o[`${e}64Low`]=o[e]:o[`${e}64Low`]=new Float32Array(this.size)),o}_getBufferLayout(e=this.id,r=null){let o=this.getAccessor(),n=[],i={name:this.id,byteStride:pi(o)};if(this.doublePrecision){let s=JZ(o,r||{});n.push(Cu(e,{...o,...s.high},this.device.type),Cu(`${e}64Low`,{...o,...s.low},this.device.type))}else if(r){let s=M1(o,r);n.push(Cu(e,{...o,...s},this.device.type))}else n.push(Cu(e,o,this.device.type));return i.attributes=n.filter(Boolean),i}setAccessor(e){this.state.bufferAccessor=e}getAccessor(){return this.state.bufferAccessor}getBounds(){if(this.state.bounds)return this.state.bounds;let e=null;if(this.state.constant&&this.value){let r=Array.from(this.value);e=[r,r]}else{let{value:r,numInstances:o,size:n}=this,i=o*n;if(r&&i&&r.length>=i){let s=new Array(n).fill(1/0),a=new Array(n).fill(-1/0);for(let c=0;c<i;)for(let l=0;l<n;l++){let f=r[c++];f<s[l]&&(s[l]=f),f>a[l]&&(a[l]=f)}e=[s,a]}}return this.state.bounds=e,e}setData(e){let{state:r}=this,o;ArrayBuffer.isView(e)?o={value:e}:e instanceof K?o={buffer:e}:o=e;let n={...this.settings,...o};if(ArrayBuffer.isView(o.value)){if(!o.type)if(this.doublePrecision&&o.value instanceof Float64Array)n.type="float32";else{let s=fB(o.value);n.type=n.normalized?s.replace("int","norm"):s}n.bytesPerElement=o.value.BYTES_PER_ELEMENT,n.stride=pi(n)}if(r.bounds=null,o.constant){let i=o.value;if(i=this._normalizeValue(i,[],0),this.settings.normalized&&(i=this.normalizeConstant(i)),!(!r.constant||!this._areValuesEqual(i,this.value)))return!1;r.externalBuffer=null,r.constant=!0,this.value=ArrayBuffer.isView(i)?i:new Float32Array(i)}else if(o.buffer){let i=o.buffer;r.externalBuffer=i,r.constant=!1,this.value=o.value||null}else if(o.value){this._checkExternalBuffer(o);let i=o.value;r.externalBuffer=null,r.constant=!1,this.value=i;let{buffer:s}=this,a=pi(n),c=(n.vertexOffset||0)*a;if(this.doublePrecision&&i instanceof Float64Array&&(i=pg(i,n)),this.settings.isIndexed){let f=this.settings.defaultType;i.constructor!==f&&(i=new f(i))}let l=i.byteLength+c+a*2;(!s||s.byteLength<l)&&(s=this._createBuffer(l)),s.write(i,c)}return this.setAccessor(n),!0}updateSubBuffer(e={}){this.state.bounds=null;let r=this.value,{startOffset:o=0,endOffset:n}=e;this.buffer.write(this.doublePrecision&&r instanceof Float64Array?pg(r,{size:this.size,startIndex:o,endIndex:n}):r.subarray(o,n),o*r.BYTES_PER_ELEMENT+this.byteOffset)}allocate(e,r=!1){let{state:o}=this,n=o.allocatedValue,i=Zr.allocate(n,e+1,{size:this.size,type:this.settings.defaultType,copy:r});this.value=i;let{byteOffset:s}=this,{buffer:a}=this;return(!a||a.byteLength<i.byteLength+s)&&(a=this._createBuffer(i.byteLength+s),r&&n&&a.write(n instanceof Float64Array?pg(n,this):n,s)),o.allocatedValue=i,o.constant=!1,o.externalBuffer=null,this.setAccessor(this.settings),!0}_checkExternalBuffer(e){let{value:r}=e;if(!ArrayBuffer.isView(r))throw new Error(`Attribute ${this.id} value is not TypedArray`);let o=this.settings.defaultType,n=!1;if(this.doublePrecision&&(n=r.BYTES_PER_ELEMENT<4),n)throw new Error(`Attribute ${this.id} does not support ${r.constructor.name}`);!(r instanceof o)&&this.settings.normalized&&!("normalized"in e)&&N.warn(`Attribute ${this.id} is normalized`)()}normalizeConstant(e){switch(this.settings.type){case"snorm8":return new Float32Array(e).map(r=>(r+128)/255*2-1);case"snorm16":return new Float32Array(e).map(r=>(r+32768)/65535*2-1);case"unorm8":return new Float32Array(e).map(r=>r/255);case"unorm16":return new Float32Array(e).map(r=>r/65535);default:return e}}_normalizeValue(e,r,o){let{defaultValue:n,size:i}=this.settings;if(Number.isFinite(e))return r[o]=e,r;if(!e){let s=i;for(;--s>=0;)r[o+s]=n[s];return r}switch(i){case 4:r[o+3]=Number.isFinite(e[3])?e[3]:n[3];case 3:r[o+2]=Number.isFinite(e[2])?e[2]:n[2];case 2:r[o+1]=Number.isFinite(e[1])?e[1]:n[1];case 1:r[o+0]=Number.isFinite(e[0])?e[0]:n[0];break;default:let s=i;for(;--s>=0;)r[o+s]=Number.isFinite(e[s])?e[s]:n[s]}return r}_areValuesEqual(e,r){if(!e||!r)return!1;let{size:o}=this;for(let n=0;n<o;n++)if(e[n]!==r[n])return!1;return!0}_createBuffer(e){this._buffer&&this._buffer.destroy();let{isIndexed:r,type:o}=this.settings;return this._buffer=this.device.createBuffer({...this._buffer?.props,id:this.id,usage:(r?K.INDEX:K.VERTEX)|K.COPY_DST,indexType:r?o:void 0,byteLength:e}),this._buffer}};var dB=[],hB=[];function Fe(t,e=0,r=1/0){let o=dB,n={index:-1,data:t,target:[]};return t?typeof t[Symbol.iterator]=="function"?o=t:t.length>0&&(hB.length=t.length,o=hB):o=dB,(e>0||Number.isFinite(r))&&(o=(Array.isArray(o)?o:Array.from(o)).slice(e,r),n.index=e-1),{iterable:o,objectInfo:n}}function y_(t){return t&&t[Symbol.asyncIterator]}function x_(t,e){let{size:r,stride:o,offset:n,startIndices:i,nested:s}=e,a=t.BYTES_PER_ELEMENT,c=o?o/a:r,l=n?n/a:0,f=Math.floor((t.length-l)/c);return(u,{index:d,target:h})=>{if(!i){let _=d*c+l;for(let x=0;x<r;x++)h[x]=t[_+x];return h}let p=i[d],m=i[d+1]||f,g;if(s){g=new Array(m-p);for(let _=p;_<m;_++){let x=_*c+l;h=new Array(r);for(let y=0;y<r;y++)h[y]=t[x+y];g[_-p]=h}}else if(c===r)g=t.subarray(p*r+l,m*r+l);else{g=new t.constructor((m-p)*r);let _=0;for(let x=p;x<m;x++){let y=x*c+l;for(let b=0;b<r;b++)g[_++]=t[y+b]}}return g}}var pB=[],wu=[[0,1/0]];function mB(t,e){if(t===wu||(e[0]<0&&(e[0]=0),e[0]>=e[1]))return t;let r=[],o=t.length,n=0;for(let i=0;i<o;i++){let s=t[i];s[1]<e[0]?(r.push(s),n=i+1):s[0]>e[1]?r.push(s):e=[Math.min(s[0],e[0]),Math.max(s[1],e[1])]}return r.splice(n,0,e),r}var eJ={interpolation:{duration:0,easing:t=>t},spring:{stiffness:.05,damping:.5}};function b_(t,e){if(!t)return null;Number.isFinite(t)&&(t={type:"interpolation",duration:t});let r=t.type||"interpolation";return{...eJ[r],...e,...t,type:r}}var Tn=class extends Eu{constructor(e,r){super(e,r,{startIndices:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,layoutChanged:!1,updateRanges:wu}),this.constant=!1,this.settings.update=r.update||(r.accessor?this._autoUpdater:void 0),Object.seal(this.settings),Object.seal(this.state),this._validateAttributeUpdaters()}get startIndices(){return this.state.startIndices}set startIndices(e){this.state.startIndices=e}needsUpdate(){return this.state.needsUpdate}needsRedraw({clearChangedFlags:e=!1}={}){let r=this.state.needsRedraw;return this.state.needsRedraw=r&&!e,r}layoutChanged(){return this.state.layoutChanged}setAccessor(e){var r;(r=this.state).layoutChanged||(r.layoutChanged=!uB(e,this.getAccessor())),super.setAccessor(e)}getUpdateTriggers(){let{accessor:e}=this.settings;return[this.id].concat(typeof e!="function"&&e||[])}supportsTransition(){return Boolean(this.settings.transition)}getTransitionSetting(e){if(!e||!this.supportsTransition())return null;let{accessor:r}=this.settings,o=this.settings.transition,n=Array.isArray(r)?e[r.find(i=>e[i])]:e[r];return b_(n,o)}setNeedsUpdate(e=this.id,r){if(this.state.needsUpdate=this.state.needsUpdate||e,this.setNeedsRedraw(e),r){let{startRow:o=0,endRow:n=1/0}=r;this.state.updateRanges=mB(this.state.updateRanges,[o,n])}else this.state.updateRanges=wu}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=pB}setNeedsRedraw(e=this.id){this.state.needsRedraw=this.state.needsRedraw||e}allocate(e){let{state:r,settings:o}=this;return o.noAlloc?!1:o.update?(super.allocate(e,r.updateRanges!==wu),!0):!1}updateBuffer({numInstances:e,data:r,props:o,context:n}){if(!this.needsUpdate())return!1;let{state:{updateRanges:i},settings:{update:s,noAlloc:a}}=this,c=!0;if(s){for(let[l,f]of i)s.call(n,this,{data:r,startRow:l,endRow:f,props:o,numInstances:e});if(this.value)if(this.constant||!this.buffer||this.buffer.byteLength<this.value.byteLength+this.byteOffset)this.constant?this.setConstantValue(n,this.value):this.setData({value:this.value,constant:this.constant}),this.constant=!1;else for(let[l,f]of i){let u=Number.isFinite(l)?this.getVertexOffset(l):0,d=Number.isFinite(f)?this.getVertexOffset(f):a||!Number.isFinite(e)?this.value.length:e*this.size;super.updateSubBuffer({startOffset:u,endOffset:d})}this._checkAttributeArray()}else c=!1;return this.clearNeedsUpdate(),this.setNeedsRedraw(),c}setConstantValue(e,r){if(r===void 0||typeof r=="function")return!1;let o=this.settings.transform&&e?this.settings.transform.call(e,r):r;return this.device.type==="webgpu"?this.setConstantBufferValue(o,this.numInstances):(this.setData({constant:!0,value:o})&&this.setNeedsRedraw(),this.clearNeedsUpdate(),!0)}setConstantBufferValue(e,r){let o=this.settings.defaultType,n=this._normalizeValue(e,new o(this.size),0);if(this._hasConstantBufferValue(n,r))return this.constant=!1,this.clearNeedsUpdate(),!1;let i=new o(Math.max(r,1)*this.size);for(let a=0;a<i.length;a+=this.size)i.set(n,a);let s=this.setData({value:i});return this.constant=!1,this.clearNeedsUpdate(),s&&this.setNeedsRedraw(),s}_hasConstantBufferValue(e,r){let o=this.value,n=Math.max(r,1)*this.size;if(!ArrayBuffer.isView(o)||o.length!==n||o.length%this.size!==0)return!1;for(let i=0;i<o.length;i+=this.size)for(let s=0;s<this.size;s++)if(o[i+s]!==e[s])return!1;return!0}setExternalBuffer(e){let{state:r}=this;return e?(this.clearNeedsUpdate(),r.lastExternalBuffer===e||(r.lastExternalBuffer=e,this.setNeedsRedraw(),this.setData(e)),!0):(r.lastExternalBuffer=null,!1)}setBinaryValue(e,r=null){let{state:o,settings:n}=this;if(!e)return o.binaryValue=null,o.binaryAccessor=null,!1;if(n.noAlloc)return!1;if(o.binaryValue===e)return this.clearNeedsUpdate(),!0;if(o.binaryValue=e,this.setNeedsRedraw(),n.transform||r!==this.startIndices){ArrayBuffer.isView(e)&&(e={value:e});let s=e;ge(ArrayBuffer.isView(s.value),`invalid ${n.accessor}`);let a=Boolean(s.size)&&s.size!==this.size;return o.binaryAccessor=x_(s.value,{size:s.size||this.size,stride:s.stride,offset:s.offset,startIndices:r,nested:a}),!1}return this.clearNeedsUpdate(),this.setData(e),!0}getVertexOffset(e){let{startIndices:r}=this;return(r?e<r.length?r[e]:this.numInstances:e)*this.size}getValue(){let e=this.settings.shaderAttributes,r=super.getValue();if(!e)return r;for(let o in e)Object.assign(r,super.getValue(o,e[o]));return r}getBufferLayout(e){this.state.layoutChanged=!1;let r=this.settings.shaderAttributes,o=super._getBufferLayout(),{stepMode:n}=this.settings;if(n==="dynamic"?o.stepMode=e?e.isInstanced?"instance":"vertex":"instance":o.stepMode=n??"vertex",!r)return o;for(let i in r){let s=super._getBufferLayout(i,r[i]);o.attributes.push(...s.attributes)}return o}_autoUpdater(e,{data:r,startRow:o,endRow:n,props:i,numInstances:s}){let{settings:a,state:c,value:l,size:f,startIndices:u}=e,{accessor:d,transform:h}=a,p=c.binaryAccessor||(typeof d=="function"?d:i[d]);ge(typeof p=="function",`accessor "${d}" is not a function`);let m=e.getVertexOffset(o),{iterable:g,objectInfo:_}=Fe(r,o,n);for(let x of g){_.index++;let y=p(x,_);if(h&&(y=h.call(this,y)),u){let b=(_.index<u.length-1?u[_.index+1]:s)-u[_.index];if(y&&Array.isArray(y[0])){let T=m;for(let v of y)e._normalizeValue(v,l,T),T+=f}else y&&y.length>f?l.set(y,m):(e._normalizeValue(y,_.target,0),Cg({target:l,source:_.target,start:m,count:b}));m+=b*f}else e._normalizeValue(y,l,m),m+=f}}_validateAttributeUpdaters(){let{settings:e}=this;if(!(e.noAlloc||typeof e.update=="function"))throw new Error(`Attribute ${this.id} missing update or accessor`)}_checkAttributeArray(){let{value:e}=this,r=Math.min(4,this.size);if(e&&e.length>=r){let o=!0;switch(r){case 4:o=o&&Number.isFinite(e[3]);case 3:o=o&&Number.isFinite(e[2]);case 2:o=o&&Number.isFinite(e[1]);case 1:o=o&&Number.isFinite(e[0]);break;default:o=!1}if(!o)throw new Error(`Illegal attribute generated for ${this.id}`)}}};function R1(t){let{source:e,target:r,start:o=0,size:n,getData:i}=t,s=t.end||r.length,a=e.length,c=s-o;if(a>c){r.set(e.subarray(0,c),o);return}if(r.set(e,o),!i)return;let l=a;for(;l<c;){let f=i(l,e);for(let u=0;u<n;u++)r[o+l]=f[u]||0,l++}}function gB({source:t,target:e,size:r,getData:o,sourceStartIndices:n,targetStartIndices:i}){if(!n||!i)return R1({source:t,target:e,size:r,getData:o}),e;let s=0,a=0,c=o&&((f,u)=>o(f+a,u)),l=Math.min(n.length,i.length);for(let f=1;f<l;f++){let u=n[f]*r,d=i[f]*r;R1({source:t.subarray(s,u),target:e,start:a,end:d,size:r,getData:c}),s=u,a=d}return a<e.length&&R1({source:[],target:e,start:a,size:r,getData:c}),e}function _B(t){let{device:e,settings:r,value:o}=t,n=new Tn(e,r);return n.setData({value:o instanceof Float64Array?new Float64Array(0):new Float32Array(0),normalized:r.normalized}),n}function A_(t){switch(t){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`No defined attribute type for size "${t}"`)}}function T_(t){switch(t){case 1:return"float32";case 2:return"float32x2";case 3:return"float32x3";case 4:return"float32x4";default:throw new Error("invalid type size")}}function v_(t){t.push(t.shift())}function yB(t,e){let{doublePrecision:r,settings:o,value:n,size:i}=t,s=r&&n instanceof Float64Array?2:1,a=0,{shaderAttributes:c}=t.settings;if(c)for(let l of Object.values(c))a=Math.max(a,l.vertexOffset??0);return(o.noAlloc?n.length:(e+a)*i)*s}function S_({device:t,source:e,target:r}){return(!r||r.byteLength<e.byteLength)&&(r?.destroy(),r=t.createBuffer({byteLength:e.byteLength,usage:e.usage})),r}function C_({device:t,buffer:e,attribute:r,fromLength:o,toLength:n,fromStartIndices:i,getData:s=a=>a}){let a=r.doublePrecision&&r.value instanceof Float64Array?2:1,c=r.size*a,l=r.byteOffset,f=r.settings.bytesPerElement<4?l/r.settings.bytesPerElement*4:l,u=r.startIndices,d=i&&u,h=r.isConstant;if(!d&&e&&o>=n)return e;let p=r.value instanceof Float64Array?Float32Array:r.value.constructor,m=h?r.value:new p(r.getBuffer().readSyncWebGL(l,n*p.BYTES_PER_ELEMENT).buffer);if(r.settings.normalized&&!h){let y=s;s=(b,T)=>r.normalizeConstant(y(b,T))}let g=h?(y,b)=>s(m,b):(y,b)=>s(m.subarray(y+l,y+l+c),b),_=e?new Float32Array(e.readSyncWebGL(f,o*4).buffer):new Float32Array(0),x=new Float32Array(n);return gB({source:_,target:x,sourceStartIndices:i,targetStartIndices:u,size:c,getData:g}),(!e||e.byteLength<x.byteLength+f)&&(e?.destroy(),e=t.createBuffer({byteLength:x.byteLength+f,usage:35050})),e.write(x,f),e}var yc=class{constructor({device:e,attribute:r,timeline:o}){this.buffers=[],this.currentLength=0,this.device=e,this.transition=new eo(o),this.attribute=r,this.attributeInTransition=_B(r),this.currentStartIndices=r.startIndices}get inProgress(){return this.transition.inProgress}start(e,r,o=1/0){this.settings=e,this.currentStartIndices=this.attribute.startIndices,this.currentLength=yB(this.attribute,r),this.transition.start({...e,duration:o})}update(){let e=this.transition.update();return e&&this.onUpdate(),e}setBuffer(e){this.attributeInTransition.setData({buffer:e,normalized:this.attribute.settings.normalized,value:this.attributeInTransition.value})}cancel(){this.transition.cancel()}delete(){this.cancel();for(let e of this.buffers)e.destroy();this.buffers.length=0}};var Pu=class extends yc{constructor({device:e,attribute:r,timeline:o}){super({device:e,attribute:r,timeline:o}),this.type="interpolation",this.transform=nJ(e,r)}start(e,r){let o=this.currentLength,n=this.currentStartIndices;if(super.start(e,r,e.duration),e.duration<=0){this.transition.cancel();return}let{buffers:i,attribute:s}=this;v_(i),i[0]=C_({device:this.device,buffer:i[0],attribute:s,fromLength:o,toLength:this.currentLength,fromStartIndices:n,getData:e.enter}),i[1]=S_({device:this.device,source:i[0],target:i[1]}),this.setBuffer(i[1]);let{transform:a}=this,c=a.model,l=Math.floor(this.currentLength/s.size);bB(s)&&(l/=2),c.setVertexCount(l),s.isConstant?(c.setAttributes({aFrom:i[0]}),c.setConstantAttributes({aTo:s.value})):c.setAttributes({aFrom:i[0],aTo:s.getBuffer()}),a.transformFeedback.setBuffers({vCurrent:i[1]})}onUpdate(){let{duration:e,easing:r}=this.settings,{time:o}=this.transition,n=o/e;r&&(n=r(n));let{model:i}=this.transform,s={time:n};i.shaderInputs.setProps({interpolation:s}),this.transform.run({discard:!0})}delete(){super.delete(),this.transform.destroy()}},tJ=`layout(std140) uniform interpolationUniforms { float time; } interpolation; `,xB={name:"interpolation",vs:tJ,uniformTypes:{time:"f32"}},rJ=`#version 300 es #define SHADER_NAME interpolation-transition-vertex-shader in ATTRIBUTE_TYPE aFrom; in ATTRIBUTE_TYPE aTo; out ATTRIBUTE_TYPE vCurrent; void main(void) { vCurrent = mix(aFrom, aTo, interpolation.time); gl_Position = vec4(0.0); } `,oJ=`#version 300 es #define SHADER_NAME interpolation-transition-vertex-shader in ATTRIBUTE_TYPE aFrom; in ATTRIBUTE_TYPE aFrom64Low; in ATTRIBUTE_TYPE aTo; in ATTRIBUTE_TYPE aTo64Low; out ATTRIBUTE_TYPE vCurrent; out ATTRIBUTE_TYPE vCurrent64Low; vec2 mix_fp64(vec2 a, vec2 b, float x) { vec2 range = sub_fp64(b, a); return sum_fp64(a, mul_fp64(range, vec2(x, 0.0))); } void main(void) { for (int i=0; i<ATTRIBUTE_SIZE; i++) { vec2 value = mix_fp64(vec2(aFrom[i], aFrom64Low[i]), vec2(aTo[i], aTo64Low[i]), interpolation.time); vCurrent[i] = value.x; vCurrent64Low[i] = value.y; } gl_Position = vec4(0.0); } `;function bB(t){return t.doublePrecision&&t.value instanceof Float64Array}function nJ(t,e){let r=e.size,o=A_(r),n=T_(r),i=e.getBufferLayout();return bB(e)?new ur(t,{vs:oJ,bufferLayout:[{name:"aFrom",byteStride:8*r,attributes:[{attribute:"aFrom",format:n,byteOffset:0},{attribute:"aFrom64Low",format:n,byteOffset:4*r}]},{name:"aTo",byteStride:8*r,attributes:[{attribute:"aTo",format:n,byteOffset:0},{attribute:"aTo64Low",format:n,byteOffset:4*r}]}],modules:[bm,xB],defines:{ATTRIBUTE_TYPE:o,ATTRIBUTE_SIZE:r},moduleSettings:{},varyings:["vCurrent","vCurrent64Low"],bufferMode:35980,disableWarnings:!0}):new ur(t,{vs:rJ,bufferLayout:[{name:"aFrom",format:n},{name:"aTo",format:i.attributes[0].format}],modules:[xB],defines:{ATTRIBUTE_TYPE:o},varyings:["vCurrent"],disableWarnings:!0})}var Mu=class extends yc{constructor({device:e,attribute:r,timeline:o}){super({device:e,attribute:r,timeline:o}),this.type="spring",this.texture=fJ(e),this.framebuffer=uJ(e,this.texture),this.transform=lJ(e,r)}start(e,r){let o=this.currentLength,n=this.currentStartIndices;super.start(e,r);let{buffers:i,attribute:s}=this;for(let c=0;c<2;c++)i[c]=C_({device:this.device,buffer:i[c],attribute:s,fromLength:o,toLength:this.currentLength,fromStartIndices:n,getData:e.enter});i[2]=S_({device:this.device,source:i[0],target:i[2]}),this.setBuffer(i[1]);let{model:a}=this.transform;a.setVertexCount(Math.floor(this.currentLength/s.size)),s.isConstant?a.setConstantAttributes({aTo:s.value}):a.setAttributes({aTo:s.getBuffer()})}onUpdate(){let{buffers:e,transform:r,framebuffer:o,transition:n}=this,i=this.settings;r.model.setAttributes({aPrev:e[0],aCur:e[1]}),r.transformFeedback.setBuffers({vNext:e[2]});let s={stiffness:i.stiffness,damping:i.damping};r.model.shaderInputs.setProps({spring:s}),r.run({framebuffer:o,discard:!1,parameters:{viewport:[0,0,1,1]},clearColor:[0,0,0,0]}),v_(e),this.setBuffer(e[1]),this.device.readPixelsToArrayWebGL(o)[0]>0||n.end()}delete(){super.delete(),this.transform.destroy(),this.texture.destroy(),this.framebuffer.destroy()}},iJ=`layout(std140) uniform springUniforms { float damping; float stiffness; } spring; `,sJ={name:"spring",vs:iJ,uniformTypes:{damping:"f32",stiffness:"f32"}},aJ=`#version 300 es #define SHADER_NAME spring-transition-vertex-shader #define EPSILON 0.00001 in ATTRIBUTE_TYPE aPrev; in ATTRIBUTE_TYPE aCur; in ATTRIBUTE_TYPE aTo; out ATTRIBUTE_TYPE vNext; out float vIsTransitioningFlag; ATTRIBUTE_TYPE getNextValue(ATTRIBUTE_TYPE cur, ATTRIBUTE_TYPE prev, ATTRIBUTE_TYPE dest) { ATTRIBUTE_TYPE velocity = cur - prev; ATTRIBUTE_TYPE delta = dest - cur; ATTRIBUTE_TYPE force = delta * spring.stiffness; ATTRIBUTE_TYPE resistance = velocity * spring.damping; return force - resistance + velocity + cur; } void main(void) { bool isTransitioning = length(aCur - aPrev) > EPSILON || length(aTo - aCur) > EPSILON; vIsTransitioningFlag = isTransitioning ? 1.0 : 0.0; vNext = getNextValue(aCur, aPrev, aTo); gl_Position = vec4(0, 0, 0, 1); gl_PointSize = 100.0; } `,cJ=`#version 300 es #define SHADER_NAME spring-transition-is-transitioning-fragment-shader in float vIsTransitioningFlag; out vec4 fragColor; void main(void) { if (vIsTransitioningFlag == 0.0) { discard; } fragColor = vec4(1.0); }`;function lJ(t,e){let r=A_(e.size),o=T_(e.size);return new ur(t,{vs:aJ,fs:cJ,bufferLayout:[{name:"aPrev",format:o},{name:"aCur",format:o},{name:"aTo",format:e.getBufferLayout().attributes[0].format}],varyings:["vNext"],modules:[sJ],defines:{ATTRIBUTE_TYPE:r},parameters:{depthCompare:"always",blendColorOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}})}function fJ(t){return t.createTexture({data:new Uint8Array(4),format:"rgba8unorm",width:1,height:1})}function uJ(t,e){return t.createFramebuffer({id:"spring-transition-is-transitioning-framebuffer",width:1,height:1,colorAttachments:[e]})}var dJ={interpolation:Pu,spring:Mu},Ru=class{constructor(e,{id:r,timeline:o}){if(!e)throw new Error("AttributeTransitionManager is constructed without device");this.id=r,this.device=e,this.timeline=o,this.transitions={},this.needsRedraw=!1,this.numInstances=1}finalize(){for(let e in this.transitions)this._removeTransition(e)}update({attributes:e,transitions:r,numInstances:o}){this.numInstances=o||1;for(let n in e){let i=e[n],s=i.getTransitionSetting(r);s&&this._updateAttribute(n,i,s)}for(let n in this.transitions){let i=e[n];(!i||!i.getTransitionSetting(r))&&this._removeTransition(n)}}hasAttribute(e){let r=this.transitions[e];return r&&r.inProgress}getAttributes(){let e={};for(let r in this.transitions){let o=this.transitions[r];o.inProgress&&(e[r]=o.attributeInTransition)}return e}run(){if(this.numInstances===0)return!1;for(let r in this.transitions)this.transitions[r].update()&&(this.needsRedraw=!0);let e=this.needsRedraw;return this.needsRedraw=!1,e}_removeTransition(e){this.transitions[e].delete(),delete this.transitions[e]}_updateAttribute(e,r,o){let n=this.transitions[e],i=!n||n.type!==o.type;if(i){n&&this._removeTransition(e);let s=dJ[o.type];s?this.transitions[e]=new s({attribute:r,timeline:this.timeline,device:this.device}):(N.error(`unsupported transition type '${o.type}'`)(),i=!1)}(i||r.needsRedraw())&&(this.needsRedraw=!0,this.transitions[e].start(o,this.numInstances))}};var AB="attributeManager.invalidate",hJ="attributeManager.updateStart",pJ="attributeManager.updateEnd",mJ="attribute.updateStart",gJ="attribute.allocate",_J="attribute.updateEnd",pr=class{constructor(e,{id:r="attribute-manager",stats:o,timeline:n}={}){this.mergeBoundsMemoized=Yt(n3),this.id=r,this.device=e,this.attributes={},this.updateTriggers={},this.needsRedraw=!0,this.userData={},this.stats=o,this.attributeTransitionManager=new Ru(e,{id:`${r}-transitions`,timeline:n}),Object.seal(this)}finalize(){for(let e in this.attributes)this.attributes[e].delete();this.attributeTransitionManager.finalize()}getNeedsRedraw(e={clearRedrawFlags:!1}){let r=this.needsRedraw;return this.needsRedraw=this.needsRedraw&&!e.clearRedrawFlags,r&&this.id}setNeedsRedraw(){this.needsRedraw=!0}add(e){this._add(e)}addInstanced(e){this._add(e,{stepMode:"instance"})}remove(e){for(let r of e)this.attributes[r]!==void 0&&(this.attributes[r].delete(),delete this.attributes[r])}invalidate(e,r){let o=this._invalidateTrigger(e,r);He(AB,this,e,o)}invalidateAll(e){for(let r in this.attributes)this.attributes[r].setNeedsUpdate(r,e);He(AB,this,"all")}update({data:e,numInstances:r,startIndices:o=null,transitions:n,props:i={},buffers:s={},context:a={}}){let c=!1;He(hJ,this),this.stats&&this.stats.get("Update Attributes").timeStart();for(let l in this.attributes){let f=this.attributes[l],u=f.settings.accessor;f.startIndices=o,f.numInstances=r,i[l]&&N.removed(`props.${l}`,`data.attributes.${l}`)(),f.setExternalBuffer(s[l])||f.setBinaryValue(typeof u=="string"?s[u]:void 0,e.startIndices)||typeof u=="string"&&!s[u]&&f.setConstantValue(a,i[u])||f.needsUpdate()&&(c=!0,this._updateAttribute({attribute:f,numInstances:r,data:e,props:i,context:a})),this.needsRedraw=this.needsRedraw||f.needsRedraw()}c&&He(pJ,this,r),this.stats&&(this.stats.get("Update Attributes").timeEnd(),c&&this.stats.get("Attributes updated").incrementCount()),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:r,transitions:n})}updateTransition(){let{attributeTransitionManager:e}=this,r=e.run();return this.needsRedraw=this.needsRedraw||r,r}getAttributes(){return{...this.attributes,...this.attributeTransitionManager.getAttributes()}}getBounds(e){let r=e.map(o=>this.attributes[o]?.getBounds());return this.mergeBoundsMemoized(r)}getChangedAttributes(e={clearChangedFlags:!1}){let{attributes:r,attributeTransitionManager:o}=this,n={...o.getAttributes()};for(let i in r){let s=r[i];s.needsRedraw(e)&&!o.hasAttribute(i)&&(n[i]=s)}return n}getBufferLayouts(e){return Object.values(this.getAttributes()).map(r=>r.getBufferLayout(e))}_add(e,r){for(let o in e){let n=e[o],i={...n,id:o,size:n.isIndexed&&1||n.size||1,...r};this.attributes[o]=new Tn(this.device,i)}this._mapUpdateTriggersToAttributes()}_mapUpdateTriggersToAttributes(){let e={};for(let r in this.attributes)this.attributes[r].getUpdateTriggers().forEach(n=>{e[n]||(e[n]=[]),e[n].push(r)});this.updateTriggers=e}_invalidateTrigger(e,r){let{attributes:o,updateTriggers:n}=this,i=n[e];return i&&i.forEach(s=>{let a=o[s];a&&a.setNeedsUpdate(a.id,r)}),i}_updateAttribute(e){let{attribute:r,numInstances:o}=e;if(He(mJ,r),r.constant){r.setConstantValue(e.context,r.value);return}r.allocate(o)&&He(gJ,r,o),r.updateBuffer(e)&&(this.needsRedraw=!0,He(_J,r,o))}};q();Au();var Iu=class extends eo{get value(){return this._value}_onUpdate(){let{time:e,settings:{fromValue:r,toValue:o,duration:n,easing:i}}=this,s=i(e/n);this._value=lt(r,o,s)}};var TB=1e-5;function vB(t,e,r,o,n){let i=e-t,a=(r-e)*n,c=-i*o;return a+c+i+e}function yJ(t,e,r,o,n){if(Array.isArray(r)){let i=[];for(let s=0;s<r.length;s++)i[s]=vB(t[s],e[s],r[s],o,n);return i}return vB(t,e,r,o,n)}function SB(t,e){if(Array.isArray(t)){let r=0;for(let o=0;o<t.length;o++){let n=t[o]-e[o];r+=n*n}return Math.sqrt(r)}return Math.abs(t-e)}var Lu=class extends eo{get value(){return this._currValue}_onUpdate(){let{fromValue:e,toValue:r,damping:o,stiffness:n}=this.settings,{_prevValue:i=e,_currValue:s=e}=this,a=yJ(i,s,r,o,n),c=SB(a,r),l=SB(a,s);c<TB&&l<TB&&(a=r,this.end()),this._prevValue=s,this._currValue=a}};var xJ={interpolation:Iu,spring:Lu},Bu=class{constructor(e){this.transitions=new Map,this.timeline=e}get active(){return this.transitions.size>0}add(e,r,o,n){let{transitions:i}=this;if(i.has(e)){let c=i.get(e),{value:l=c.settings.fromValue}=c;r=l,this.remove(e)}if(n=b_(n),!n)return;let s=xJ[n.type];if(!s){N.error(`unsupported transition type '${n.type}'`)();return}let a=new s(this.timeline);a.start({...n,fromValue:r,toValue:o}),i.set(e,a)}remove(e){let{transitions:r}=this;r.has(e)&&(r.get(e).cancel(),r.delete(e))}update(){let e={};for(let[r,o]of this.transitions)o.update(),e[r]=o.value,o.inProgress||this.remove(r);return e}clear(){for(let e of this.transitions.keys())this.remove(e)}};function EB(t){let e=t[Ir];for(let r in e){let o=e[r],{validate:n}=o;if(n&&!n(t[r],o))throw new Error(`Invalid prop ${r}: ${t[r]}`)}}function wB(t,e){let r=xc({newProps:t,oldProps:e,propTypes:t[Ir],ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),o=AJ(t,e),n=!1;return o||(n=TJ(t,e)),{dataChanged:o,propsChanged:r,updateTriggersChanged:n,extensionsChanged:vJ(t,e),transitionsChanged:bJ(t,e)}}function bJ(t,e){if(!t.transitions)return!1;let r={},o=t[Ir],n=!1;for(let i in t.transitions){let s=o[i],a=s&&s.type;(a==="number"||a==="color"||a==="array")&&I1(t[i],e[i],s)&&(r[i]=!0,n=!0)}return n?r:!1}function xc({newProps:t,oldProps:e,ignoreProps:r={},propTypes:o={},triggerName:n="props"}){if(e===t)return!1;if(typeof t!="object"||t===null)return`${n} changed shallowly`;if(typeof e!="object"||e===null)return`${n} changed shallowly`;for(let i of Object.keys(t))if(!(i in r)){if(!(i in e))return`${n}.${i} added`;let s=I1(t[i],e[i],o[i]);if(s)return`${n}.${i} ${s}`}for(let i of Object.keys(e))if(!(i in r)){if(!(i in t))return`${n}.${i} dropped`;if(!Object.hasOwnProperty.call(t,i)){let s=I1(t[i],e[i],o[i]);if(s)return`${n}.${i} ${s}`}}return!1}function I1(t,e,r){let o=r&&r.equal;return o&&!o(t,e,r)||!o&&(o=t&&e&&t.equals,o&&!o.call(t,e))?"changed deeply":!o&&e!==t?"changed shallowly":null}function AJ(t,e){if(e===null)return"oldProps is null, initial diff";let r=!1,{dataComparator:o,_dataDiff:n}=t;return o?o(t.data,e.data)||(r="Data comparator detected a change"):t.data!==e.data&&(r="A new data container was supplied"),r&&n&&(r=n(t.data,e.data)||r),r}function TJ(t,e){if(e===null)return{all:!0};if("all"in t.updateTriggers&&CB(t,e,"all"))return{all:!0};let r={},o=!1;for(let n in t.updateTriggers)n!=="all"&&CB(t,e,n)&&(r[n]=!0,o=!0);return o?r:!1}function vJ(t,e){if(e===null)return!0;let r=e.extensions,{extensions:o}=t;if(o===r)return!1;if(!r||!o||o.length!==r.length)return!0;for(let n=0;n<o.length;n++)if(!o[n].equals(r[n]))return!0;return!1}function CB(t,e,r){let o=t.updateTriggers[r];o=o??{};let n=e.updateTriggers[r];return n=n??{},xc({oldProps:n,newProps:o,triggerName:r})}var SJ="count(): argument not an object",CJ="count(): argument not a container";function E_(t){if(!wJ(t))throw new Error(SJ);if(typeof t.count=="function")return t.count();if(Number.isFinite(t.size))return t.size;if(Number.isFinite(t.length))return t.length;if(EJ(t))return Object.keys(t).length;throw new Error(CJ)}function EJ(t){return t!==null&&typeof t=="object"&&t.constructor===Object}function wJ(t){return t!==null&&typeof t=="object"}function mi(t,e){if(!e)return t;let r={...t,...e};if("defines"in e&&(r.defines={...t.defines,...e.defines}),"modules"in e&&(r.modules=(t.modules||[]).concat(e.modules),e.modules.some(o=>o.name==="project64"))){let o=r.modules.findIndex(n=>n.name==="project32");o>=0&&r.modules.splice(o,1)}if("inject"in e)if(!t.inject)r.inject=e.inject;else{let o={...t.inject};for(let n in e.inject)o[n]=(o[n]||"")+e.inject[n];r.inject=o}return r}q();var PJ={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},L1={};function PB(t,e,r,o){if(r instanceof Y)return r;r.constructor&&r.constructor.name!=="Object"&&(r={data:r});let n=null;r.compressed&&(n={minFilter:"linear",mipmapFilter:r.data.length>1?"nearest":"linear"});let{width:i,height:s}=r.data,a=e.createTexture({...r,sampler:{...PJ,...n,...o},mipLevels:e.getMipLevelCount(i,s)});return e.type==="webgl"?a.generateMipmapsWebGL():e.type==="webgpu"&&e.generateMipmapsWebGPU(a),L1[a.id]=t,a}function MB(t,e){!e||!(e instanceof Y)||L1[e.id]===t&&(e.delete(),delete L1[e.id])}var MJ={boolean:{validate(t,e){return!0},equal(t,e,r){return Boolean(t)===Boolean(e)}},number:{validate(t,e){return Number.isFinite(t)&&(!("max"in e)||t<=e.max)&&(!("min"in e)||t>=e.min)}},color:{validate(t,e){return e.optional&&!t||B1(t)&&(t.length===3||t.length===4)},equal(t,e,r){return ie(t,e,1)}},accessor:{validate(t,e){let r=w_(t);return r==="function"||r===w_(e.value)},equal(t,e,r){return typeof e=="function"?!0:ie(t,e,1)}},array:{validate(t,e){return e.optional&&!t||B1(t)},equal(t,e,r){let{compare:o}=r,n=Number.isInteger(o)?o:o?1:0;return o?ie(t,e,n):t===e}},object:{equal(t,e,r){if(r.ignore)return!0;let{compare:o}=r,n=Number.isInteger(o)?o:o?1:0;return o?ie(t,e,n):t===e}},function:{validate(t,e){return e.optional&&!t||typeof t=="function"},equal(t,e,r){return!r.compare&&r.ignore!==!1||t===e}},data:{transform:(t,e,r)=>{if(!t)return t;let{dataTransform:o}=r.props;return o?o(t):typeof t.shape=="string"&&t.shape.endsWith("-table")&&Array.isArray(t.data)?t.data:t}},image:{transform:(t,e,r)=>{let o=r.context;return!o||!o.device?null:PB(r.id,o.device,t,{...e.parameters,...r.props.textureParameters})},release:(t,e,r)=>{MB(r.id,t)}}};function RB(t){let e={},r={},o={};for(let[n,i]of Object.entries(t)){let s=i?.deprecatedFor;if(s)o[n]=Array.isArray(s)?s:[s];else{let a=RJ(n,i);e[n]=a,r[n]=a.value}}return{propTypes:e,defaultProps:r,deprecatedProps:o}}function RJ(t,e){switch(w_(e)){case"object":return Ou(t,e);case"array":return Ou(t,{type:"array",value:e,compare:!1});case"boolean":return Ou(t,{type:"boolean",value:e});case"number":return Ou(t,{type:"number",value:e});case"function":return Ou(t,{type:"function",value:e,compare:!0});default:return{name:t,type:"unknown",value:e}}}function Ou(t,e){return"type"in e?{name:t,...MJ[e.type],...e}:"value"in e?{name:t,type:w_(e.value),...e}:{name:t,type:"object",value:e}}function B1(t){return Array.isArray(t)||ArrayBuffer.isView(t)}function w_(t){return B1(t)?"array":t===null?"null":typeof t}function IB(t,e){let r;for(let i=e.length-1;i>=0;i--){let s=e[i];"extensions"in s&&(r=s.extensions)}let o=O1(t.constructor,r),n=Object.create(o);n[uc]=t,n[Lo]={},n[Qr]={};for(let i=0;i<e.length;++i){let s=e[i];for(let a in s)n[a]=s[a]}return Object.freeze(n),n}var IJ="_mergedDefaultProps";function O1(t,e){if(!(t instanceof bc.constructor))return{};let r=IJ;if(e)for(let n of e){let i=n.constructor;i&&(r+=`:${i.extensionName||i.name}`)}let o=LB(t,r);return o||(t[r]=LJ(t,e||[]))}function LJ(t,e){if(!t.prototype)return null;let o=Object.getPrototypeOf(t),n=O1(o),i=LB(t,"defaultProps")||{},s=RB(i),a=Object.assign(Object.create(null),n,s.defaultProps),c=Object.assign(Object.create(null),n?.[Ir],s.propTypes),l=Object.assign(Object.create(null),n?.[Sg],s.deprecatedProps);for(let f of e){let u=O1(f.constructor);u&&(Object.assign(a,u),Object.assign(c,u[Ir]),Object.assign(l,u[Sg]))}return BJ(a,t),FJ(a,c),OJ(a,l),a[Ir]=c,a[Sg]=l,e.length===0&&!F1(t,"_propTypes")&&(t._propTypes=c),a}function BJ(t,e){let r=DJ(e);Object.defineProperties(t,{id:{writable:!0,value:r}})}function OJ(t,e){for(let r in e)Object.defineProperty(t,r,{enumerable:!1,set(o){let n=`${this.id}: ${r}`;for(let i of e[r])F1(this,i)||(this[i]=o);N.deprecated(n,e[r].join("/"))()}})}function FJ(t,e){let r={},o={};for(let n in e){let i=e[n],{name:s,value:a}=i;i.async&&(r[s]=a,o[s]=NJ(s))}t[hn]=r,t[Lo]={},Object.defineProperties(t,o)}function NJ(t){return{enumerable:!0,set(e){typeof e=="string"||e instanceof Promise||y_(e)?this[Lo][t]=e:this[Qr][t]=e},get(){if(this[Qr]){if(t in this[Qr])return this[Qr][t]||this[hn][t];if(t in this[Lo]){let e=this[uc]&&this[uc].internalState;if(e&&e.hasAsyncProp(t))return e.getAsyncProp(t)||this[hn][t]}}return this[hn][t]}}}function F1(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function LB(t,e){return F1(t,e)&&t[e]}function DJ(t){let e=t.componentName;return e||N.warn(`${t.name}.componentName not specified`)(),e||t.name}var UJ=0,Fu=class{constructor(...e){this.props=IB(this,e),this.id=this.props.id,this.count=UJ++}clone(e){let{props:r}=this,o={};for(let n in r[hn])n in r[Qr]?o[n]=r[Qr][n]:n in r[Lo]&&(o[n]=r[Lo][n]);return new this.constructor({...r,...o,...e})}};Fu.componentName="Component";Fu.defaultProps={};var bc=Fu;var kJ=Object.freeze({}),Ts=class{constructor(e){this.component=e,this.asyncProps={},this.onAsyncPropUpdated=()=>{},this.oldProps=null,this.oldAsyncProps=null}finalize(){for(let e in this.asyncProps){let r=this.asyncProps[e];r&&r.type&&r.type.release&&r.type.release(r.resolvedValue,r.type,this.component)}this.asyncProps={},this.component=null,this.resetOldProps()}getOldProps(){return this.oldAsyncProps||this.oldProps||kJ}resetOldProps(){this.oldAsyncProps=null,this.oldProps=this.component?this.component.props:null}hasAsyncProp(e){return e in this.asyncProps}getAsyncProp(e){let r=this.asyncProps[e];return r&&r.resolvedValue}isAsyncPropLoading(e){if(e){let r=this.asyncProps[e];return Boolean(r&&r.pendingLoadCount>0&&r.pendingLoadCount!==r.resolvedLoadCount)}for(let r in this.asyncProps)if(this.isAsyncPropLoading(r))return!0;return!1}reloadAsyncProp(e,r){this._watchPromise(e,Promise.resolve(r))}setAsyncProps(e){this.component=e[uc]||this.component;let r=e[Qr]||{},o=e[Lo]||e,n=e[hn]||{};for(let i in r){let s=r[i];this._createAsyncPropData(i,n[i]),this._updateAsyncProp(i,s),r[i]=this.getAsyncProp(i)}for(let i in o){let s=o[i];this._createAsyncPropData(i,n[i]),this._updateAsyncProp(i,s)}}_fetch(e,r){return null}_onResolve(e,r){}_onError(e,r){}_updateAsyncProp(e,r){if(this._didAsyncInputValueChange(e,r)){if(typeof r=="string"&&(r=this._fetch(e,r)),r instanceof Promise){this._watchPromise(e,r);return}if(y_(r)){this._resolveAsyncIterable(e,r);return}this._setPropValue(e,r)}}_freezeAsyncOldProps(){if(!this.oldAsyncProps&&this.oldProps){this.oldAsyncProps=Object.create(this.oldProps);for(let e in this.asyncProps)Object.defineProperty(this.oldAsyncProps,e,{enumerable:!0,value:this.oldProps[e]})}}_didAsyncInputValueChange(e,r){let o=this.asyncProps[e];return r===o.resolvedValue||r===o.lastValue?!1:(o.lastValue=r,!0)}_setPropValue(e,r){this._freezeAsyncOldProps();let o=this.asyncProps[e];o&&(r=this._postProcessValue(o,r),o.resolvedValue=r,o.pendingLoadCount++,o.resolvedLoadCount=o.pendingLoadCount)}_setAsyncPropValue(e,r,o){let n=this.asyncProps[e];n&&o>=n.resolvedLoadCount&&r!==void 0&&(this._freezeAsyncOldProps(),n.resolvedValue=r,n.resolvedLoadCount=o,this.onAsyncPropUpdated(e,r))}_watchPromise(e,r){let o=this.asyncProps[e];if(o){o.pendingLoadCount++;let n=o.pendingLoadCount;r.then(i=>{this.component&&(i=this._postProcessValue(o,i),this._setAsyncPropValue(e,i,n),this._onResolve(e,i))}).catch(i=>{this._onError(e,i)})}}async _resolveAsyncIterable(e,r){if(e!=="data"){this._setPropValue(e,r);return}let o=this.asyncProps[e];if(!o)return;o.pendingLoadCount++;let n=o.pendingLoadCount,i=[],s=0;for await(let a of r){if(!this.component)return;let{dataTransform:c}=this.component.props;c?i=c(a,i):i=i.concat(a),Object.defineProperty(i,"__diff",{enumerable:!1,value:[{startRow:s,endRow:i.length}]}),s=i.length,this._setAsyncPropValue(e,i,n)}this._onResolve(e,i)}_postProcessValue(e,r){let o=e.type;return o&&this.component&&(o.release&&o.release(e.resolvedValue,o,this.component),o.transform)?o.transform(r,o,this.component):r}_createAsyncPropData(e,r){if(!this.asyncProps[e]){let n=this.component&&this.component.props[Ir];this.asyncProps[e]={type:n&&n[e],lastValue:null,resolvedValue:r,pendingLoadCount:0,resolvedLoadCount:0}}}};var Nu=class extends Ts{constructor({attributeManager:e,layer:r}){super(r),this.attributeManager=e,this.needsRedraw=!0,this.needsUpdate=!0,this.subLayers=null,this.usesPickingColorCache=!1}get layer(){return this.component}_fetch(e,r){let o=this.layer,n=o?.props.fetch;return n?n(r,{propName:e,layer:o}):super._fetch(e,r)}_onResolve(e,r){let o=this.layer;if(o){let n=o.props.onDataLoad;e==="data"&&n&&n(r,{propName:e,layer:o})}}_onError(e,r){let o=this.layer;o&&o.raiseError(r,`loading ${e} of ${this.layer}`)}};var VJ="layer.changeFlag",zJ="layer.initialize",HJ="layer.update",jJ="layer.finalize",WJ="layer.matched",BB=2**24-1,GJ=Object.freeze([]),$J=Yt(({oldViewport:t,viewport:e})=>t.equals(e)),Lr=new Uint8ClampedArray(0),XJ={data:{type:"data",value:GJ,async:!0},dataComparator:{type:"function",value:null,optional:!0},_dataDiff:{type:"function",value:t=>t&&t.__diff,optional:!0},dataTransform:{type:"function",value:null,optional:!0},onDataLoad:{type:"function",value:null,optional:!0},onError:{type:"function",value:null,optional:!0},fetch:{type:"function",value:(t,{propName:e,layer:r,loaders:o,loadOptions:n,signal:i})=>{let{resourceManager:s}=r.context;n=n||r.getLoadOptions(),o=o||r.props.loaders,i&&(n={...n,core:{...n?.core,fetch:{...n?.core?.fetch,signal:i}}});let a=s.contains(t);return!a&&!n&&(s.add({resourceId:t,data:Kn(t,o),persistent:!1}),a=!0),a?s.subscribe({resourceId:t,onChange:c=>r.internalState?.reloadAsyncProp(e,c),consumerId:r.id,requestId:e}):Kn(t,o,n)}},updateTriggers:{},visible:!0,pickable:!1,opacity:{type:"number",min:0,max:1,value:1},operation:"draw",onHover:{type:"function",value:null,optional:!0},onClick:{type:"function",value:null,optional:!0},onDragStart:{type:"function",value:null,optional:!0},onDrag:{type:"function",value:null,optional:!0},onDragEnd:{type:"function",value:null,optional:!0},coordinateSystem:"default",coordinateOrigin:{type:"array",value:[0,0,0],compare:!0},modelMatrix:{type:"array",value:null,compare:!0,optional:!0},wrapLongitude:!1,positionFormat:"XYZ",colorFormat:"RGBA",parameters:{type:"object",value:{},optional:!0,compare:2},loadOptions:{type:"object",value:null,optional:!0,ignore:!0},transitions:null,extensions:[],loaders:{type:"array",value:[],optional:!0,ignore:!0},getPolygonOffset:{type:"function",value:({layerIndex:t})=>[0,-t*100]},highlightedObjectIndex:null,autoHighlight:!1,highlightColor:{type:"accessor",value:[0,0,128,128]}},Du=class extends bc{constructor(){super(...arguments),this.internalState=null,this.lifecycle=ui.NO_STATE,this.parent=null}static get componentName(){return Object.prototype.hasOwnProperty.call(this,"layerName")?this.layerName:""}get root(){let e=this;for(;e.parent;)e=e.parent;return e}toString(){return`${this.constructor.layerName||this.constructor.name}({id: '${this.props.id}'})`}project(e){ge(this.internalState);let r=this.internalState.viewport||this.context.viewport,o=mg(e,{viewport:r,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),[n,i,s]=tc(o,r.pixelProjectionMatrix);return e.length===2?[n,i]:[n,i,s]}unproject(e){return ge(this.internalState),(this.internalState.viewport||this.context.viewport).unproject(e)}projectPosition(e,r){ge(this.internalState);let o=this.internalState.viewport||this.context.viewport;return gg(e,{viewport:o,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem,...r})}get isComposite(){return!1}get isDrawable(){return!0}setState(e){this.setChangeFlags({stateChanged:!0}),Object.assign(this.state,e),this.setNeedsRedraw()}setNeedsRedraw(){this.internalState&&(this.internalState.needsRedraw=!0)}setNeedsUpdate(){this.internalState&&(this.context.layerManager.setNeedsUpdate(String(this)),this.internalState.needsUpdate=!0)}get isLoaded(){return this.internalState?!this.internalState.isAsyncPropLoading():!1}get wrapLongitude(){return this.props.wrapLongitude}isPickable(){return this.props.pickable&&this.props.visible}getModels(){let e=this.state;return e&&(e.models||e.model&&[e.model])||[]}setShaderModuleProps(...e){for(let r of this.getModels())r.shaderInputs.setProps(...e)}getAttributeManager(){return this.internalState&&this.internalState.attributeManager}getCurrentLayer(){return this.internalState&&this.internalState.layer}getLoadOptions(){return this.props.loadOptions}use64bitPositions(){let{coordinateSystem:e}=this.props;return e==="default"||e==="lnglat"||e==="cartesian"}onHover(e,r){return this.props.onHover&&this.props.onHover(e,r)||!1}onClick(e,r){return this.props.onClick&&this.props.onClick(e,r)||!1}nullPickingColor(){return[0,0,0]}encodePickingColor(e,r=[]){return r[0]=e+1&255,r[1]=e+1>>8&255,r[2]=e+1>>8>>8&255,r}decodePickingColor(e){ge(e instanceof Uint8Array);let[r,o,n]=e;return r+o*256+n*65536-1}getNumInstances(){return Number.isFinite(this.props.numInstances)?this.props.numInstances:this.state&&this.state.numInstances!==void 0?this.state.numInstances:E_(this.props.data)}getStartIndices(){return this.props.startIndices?this.props.startIndices:this.state&&this.state.startIndices?this.state.startIndices:null}getBounds(){return this.getAttributeManager()?.getBounds(["positions","instancePositions"])}getShaders(e){e=mi(e,{disableWarnings:!0,modules:this.context.defaultShaderModules});for(let r of this.props.extensions)e=mi(e,r.getShaders.call(this,r));return e}shouldUpdateState(e){return e.changeFlags.propsOrDataChanged}updateState(e){let r=this.getAttributeManager(),{dataChanged:o}=e.changeFlags;if(o&&r)if(Array.isArray(o))for(let n of o)r.invalidateAll(n);else r.invalidateAll();if(r){let{props:n}=e,i=this.internalState.hasPickingBuffer,s=Number.isInteger(n.highlightedObjectIndex)||Boolean(n.pickable)||n.extensions.some(a=>a.getNeedsPickingBuffer.call(this,a));if(i!==s){this.internalState.hasPickingBuffer=s;let{pickingColors:a,instancePickingColors:c}=r.attributes,l=a||c;l&&(s&&l.constant&&(l.constant=!1,r.invalidate(l.id)),!l.value&&!s&&(l.constant=!0,l.value=[0,0,0]))}}}finalizeState(e){for(let o of this.getModels())o.destroy();let r=this.getAttributeManager();r&&r.finalize(),this.context&&this.context.resourceManager.unsubscribe({consumerId:this.id}),this.internalState&&(this.internalState.uniformTransitions.clear(),this.internalState.finalize())}draw(e){for(let r of this.getModels())r.draw(e.renderPass)}getPickingInfo({info:e,mode:r,sourceLayer:o}){let{index:n}=e;return n>=0&&Array.isArray(this.props.data)&&(e.object=this.props.data[n]),e}raiseError(e,r){r&&(e=new Error(`${r}: ${e.message}`,{cause:e})),this.props.onError?.(e)||this.context?.onError?.(e,this)}getNeedsRedraw(e={clearRedrawFlags:!1}){return this._getNeedsRedraw(e)}needsUpdate(){return this.internalState?this.internalState.needsUpdate||this.hasUniformTransition()||this.shouldUpdateState(this._getUpdateParams()):!1}hasUniformTransition(){return this.internalState?.uniformTransitions.active||!1}activateViewport(e){if(!this.internalState)return;let r=this.internalState.viewport;this.internalState.viewport=e,(!r||!$J({oldViewport:r,viewport:e}))&&(this.setChangeFlags({viewportChanged:!0}),this.isComposite?this.needsUpdate()&&this.setNeedsUpdate():this._update())}invalidateAttribute(e="all"){let r=this.getAttributeManager();r&&(e==="all"?r.invalidateAll():r.invalidate(e))}updateAttributes(e){let r=!1;for(let o in e)e[o].layoutChanged()&&(r=!0);for(let o of this.getModels())this._setModelAttributes(o,e,r)}_updateAttributes(){let e=this.getAttributeManager();if(!e)return;let r=this.props,o=this.getNumInstances(),n=this.getStartIndices();e.update({data:r.data,numInstances:o,startIndices:n,props:r,transitions:r.transitions,buffers:r.data.attributes,context:this});let i=e.getChangedAttributes({clearChangedFlags:!0});this.updateAttributes(i)}_updateAttributeTransition(){let e=this.getAttributeManager();e&&e.updateTransition()}_updateUniformTransition(){let{uniformTransitions:e}=this.internalState;if(e.active){let r=e.update(),o=Object.create(this.props);for(let n in r)Object.defineProperty(o,n,{value:r[n]});return o}return this.props}calculateInstancePickingColors(e,{numInstances:r}){if(e.constant)return;let o=Math.floor(Lr.length/4);this.internalState.usesPickingColorCache=!0;let n=r>0&&Lr[0]===0;if(o<r||n){r>BB&&N.warn("Layer has too many data objects. Picking might not be able to distinguish all objects.")(),Lr=Zr.allocate(Lr,r,{size:4,copy:!0,maxCount:Math.max(r,BB)});let i=Math.floor(Lr.length/4),s=[0,0,0],a=n?0:o;for(let c=a;c<i;c++)this.encodePickingColor(c,s),Lr[c*4+0]=s[0],Lr[c*4+1]=s[1],Lr[c*4+2]=s[2],Lr[c*4+3]=0}e.value=Lr.subarray(0,r*4)}_setModelAttributes(e,r,o=!1){if(!Object.keys(r).length)return;if(o){let a=this.getAttributeManager();e.setBufferLayout(a.getBufferLayouts(e)),r=a.getAttributes()}let n=e.userData?.excludeAttributes||{},i={},s={};for(let a in r){if(n[a])continue;let c=r[a].getValue();for(let l in c){let f=c[l];f instanceof K?r[a].settings.isIndexed?e.setIndexBuffer(f):i[l]=f:f&&(s[l]=f)}}e.setAttributes(i),e.setConstantAttributes(s)}disablePickingIndex(e){let r=this.props.data;if(!("attributes"in r)){this._disablePickingIndex(e);return}let{pickingColors:o,instancePickingColors:n}=this.getAttributeManager().attributes,i=o||n,s=i&&r.attributes&&r.attributes[i.id];if(s&&s.value){let a=s.value,c=this.encodePickingColor(e);for(let l=0;l<r.length;l++){let f=i.getVertexOffset(l);a[f]===c[0]&&a[f+1]===c[1]&&a[f+2]===c[2]&&this._disablePickingIndex(l)}}else this._disablePickingIndex(e)}_disablePickingIndex(e){let{pickingColors:r,instancePickingColors:o}=this.getAttributeManager().attributes,n=r||o;if(!n)return;let i=n.getVertexOffset(e),s=n.getVertexOffset(e+1);n.buffer.write(new Uint8Array(s-i),i)}restorePickingColors(){let{pickingColors:e,instancePickingColors:r}=this.getAttributeManager().attributes,o=e||r;o&&(this.internalState.usesPickingColorCache&&o.value.buffer!==Lr.buffer&&(o.value=Lr.subarray(0,o.value.length)),o.updateSubBuffer({startOffset:0}))}_initialize(){ge(!this.internalState),He(zJ,this);let e=this._getAttributeManager();e&&e.addInstanced({instancePickingColors:{type:"uint8",size:4,noAlloc:!0,update:this.calculateInstancePickingColors}}),this.internalState=new Nu({attributeManager:e,layer:this}),this._clearChangeFlags(),this.state={},Object.defineProperty(this.state,"attributeManager",{get:()=>(N.deprecated("layer.state.attributeManager","layer.getAttributeManager()")(),e)}),this.internalState.uniformTransitions=new Bu(this.context.timeline),this.internalState.onAsyncPropUpdated=this._onAsyncPropUpdated.bind(this),this.internalState.setAsyncProps(this.props),this.initializeState(this.context);for(let r of this.props.extensions)r.initializeState.call(this,this.context,r);this.setChangeFlags({dataChanged:"init",propsChanged:"init",viewportChanged:!0,extensionsChanged:!0}),this._update()}_transferState(e){He(WJ,this,this===e);let{state:r,internalState:o}=e;this!==e&&(this.internalState=o,this.state=r,this.internalState.setAsyncProps(this.props),this._diffProps(this.props,this.internalState.getOldProps()))}_update(){let e=this.needsUpdate();if(He(HJ,this,e),!e)return;this.context.stats.get("Layer updates").incrementCount();let r=this.props,o=this.context,n=this.internalState,i=o.viewport,s=this._updateUniformTransition();n.propsInTransition=s,o.viewport=n.viewport||i,this.props=s;try{let a=this._getUpdateParams(),c=this.getModels();if(o.device)this.updateState(a);else try{this.updateState(a)}catch{}for(let f of this.props.extensions)f.updateState.call(this,a,f);this.setNeedsRedraw(),this._updateAttributes();let l=this.getModels()[0]!==c[0];this._postUpdate(a,l)}finally{o.viewport=i,this.props=r,this._clearChangeFlags(),n.needsUpdate=!1,n.resetOldProps()}}_finalize(){He(jJ,this),this.finalizeState(this.context);for(let e of this.props.extensions)e.finalizeState.call(this,this.context,e)}_drawLayer({renderPass:e,shaderModuleProps:r=null,uniforms:o={},parameters:n={}}){this._updateAttributeTransition();let i=this.props,s=this.context;this.props=this.internalState.propsInTransition||i;try{r&&this.setShaderModuleProps(r);let{getPolygonOffset:a}=this.props,c=a&&a(o)||[0,0];s.device instanceof Zt&&s.device.setParametersWebGL({polygonOffset:c});let l=s.device instanceof Zt?null:YJ(n);if(KJ(this.getModels(),e,n,l),s.device instanceof Zt)s.device.withParametersWebGL(n,()=>{let f={renderPass:e,shaderModuleProps:r,uniforms:o,parameters:n,context:s};for(let u of this.props.extensions)u.draw.call(this,f,u);this.draw(f)});else{l?.renderPassParameters&&e.setParameters(l.renderPassParameters);let f={renderPass:e,shaderModuleProps:r,uniforms:o,parameters:n,context:s};for(let u of this.props.extensions)u.draw.call(this,f,u);this.draw(f)}}finally{this.props=i}}getChangeFlags(){return this.internalState?.changeFlags}setChangeFlags(e){if(!this.internalState)return;let{changeFlags:r}=this.internalState;for(let n in e)if(e[n]){let i=!1;switch(n){case"dataChanged":let s=e[n],a=r[n];s&&Array.isArray(a)&&(r.dataChanged=Array.isArray(s)?a.concat(s):s,i=!0);default:r[n]||(r[n]=e[n],i=!0)}i&&He(VJ,this,n,e)}let o=Boolean(r.dataChanged||r.updateTriggersChanged||r.propsChanged||r.extensionsChanged);r.propsOrDataChanged=o,r.somethingChanged=o||r.viewportChanged||r.stateChanged}_clearChangeFlags(){this.internalState.changeFlags={dataChanged:!1,propsChanged:!1,updateTriggersChanged:!1,viewportChanged:!1,stateChanged:!1,extensionsChanged:!1,propsOrDataChanged:!1,somethingChanged:!1}}_diffProps(e,r){let o=wB(e,r);if(o.updateTriggersChanged)for(let n in o.updateTriggersChanged)o.updateTriggersChanged[n]&&this.invalidateAttribute(n);if(o.transitionsChanged)for(let n in o.transitionsChanged)this.internalState.uniformTransitions.add(n,r[n],e[n],e.transitions?.[n]);return this.setChangeFlags(o)}validateProps(){EB(this.props)}updateAutoHighlight(e){this.props.autoHighlight&&!Number.isInteger(this.props.highlightedObjectIndex)&&this._updateAutoHighlight(e)}_updateAutoHighlight(e){let r={highlightedObjectColor:e.picked?e.color:null},{highlightColor:o}=this.props;e.picked&&typeof o=="function"&&(r.highlightColor=o(e)),this.setShaderModuleProps({picking:r}),this.setNeedsRedraw()}_getAttributeManager(){let e=this.context;return new pr(e.device,{id:this.props.id,stats:e.stats,timeline:e.timeline})}_postUpdate(e,r){let{props:o,oldProps:n}=e,i=this.state.model;i?.isInstanced&&i.setInstanceCount(this.getNumInstances());let{autoHighlight:s,highlightedObjectIndex:a,highlightColor:c}=o;if(r||n.autoHighlight!==s||n.highlightedObjectIndex!==a||n.highlightColor!==c){let l={};Array.isArray(c)&&(l.highlightColor=c),(r||n.autoHighlight!==s||a!==n.highlightedObjectIndex)&&(l.highlightedObjectColor=Number.isFinite(a)&&a>=0?this.encodePickingColor(a):null),this.setShaderModuleProps({picking:l})}}_getUpdateParams(){return{props:this.props,oldProps:this.internalState.getOldProps(),context:this.context,changeFlags:this.internalState.changeFlags}}_getNeedsRedraw(e){if(!this.internalState)return!1;let r=!1;r=r||this.internalState.needsRedraw&&this.id;let o=this.getAttributeManager(),n=o?o.getNeedsRedraw(e):!1;if(r=r||n,r)for(let i of this.props.extensions)i.onNeedsRedraw.call(this,i);return this.internalState.needsRedraw=this.internalState.needsRedraw&&!e.clearRedrawFlags,r}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}};Du.defaultProps=XJ;Du.layerName="Layer";var _e=Du;function YJ(t){let{blendConstant:e,...r}=t;return e?{pipelineParameters:r,renderPassParameters:{blendConstant:e}}:{pipelineParameters:r}}function KJ(t,e,r,o){for(let n of t)n.device.type==="webgpu"?(qJ(n,e),n.setParameters({...n.parameters,...o?.pipelineParameters})):n.setParameters(r)}function qJ(t,e){let r=e.props.framebuffer||(e.framebuffer??null);if(!r)return;let o=r.colorAttachments.map(s=>s?.texture?.format??null),n=r.depthStencilAttachment?.texture?.format,i=t;(!ZJ(i.props.colorAttachmentFormats,o)||i.props.depthStencilAttachmentFormat!==n)&&(i.props.colorAttachmentFormats=o,i.props.depthStencilAttachmentFormat=n,i._setPipelineNeedsUpdate("attachment formats"))}function ZJ(t,e){if(t===e)return!0;if(!t||!e||t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}var JJ="compositeLayer.renderLayers",P_=class extends _e{get isComposite(){return!0}get isDrawable(){return!1}get isLoaded(){return super.isLoaded&&this.getSubLayers().every(e=>e.isLoaded)}getSubLayers(){return this.internalState&&this.internalState.subLayers||[]}initializeState(e){}setState(e){super.setState(e),this.setNeedsUpdate()}getPickingInfo({info:e}){let{object:r}=e;return r&&r.__source&&r.__source.parent&&r.__source.parent.id===this.id&&(e.object=r.__source.object,e.index=r.__source.index),e}filterSubLayer(e){return!0}shouldRenderSubLayer(e,r){return r&&r.length}getSubLayerClass(e,r){let{_subLayerProps:o}=this.props;return o&&o[e]&&o[e].type||r}getSubLayerRow(e,r,o){return e.__source={parent:this,object:r,index:o},e}getSubLayerAccessor(e){if(typeof e=="function"){let r={index:-1,data:this.props.data,target:[]};return(o,n)=>o&&o.__source?(r.index=o.__source.index,e(o.__source.object,r)):e(o,n)}return e}getSubLayerProps(e={}){let{opacity:r,pickable:o,visible:n,parameters:i,getPolygonOffset:s,highlightedObjectIndex:a,autoHighlight:c,highlightColor:l,coordinateSystem:f,coordinateOrigin:u,wrapLongitude:d,positionFormat:h,modelMatrix:p,extensions:m,fetch:g,operation:_,_subLayerProps:x}=this.props,y={id:"",updateTriggers:{},opacity:r,pickable:o,visible:n,parameters:i,getPolygonOffset:s,highlightedObjectIndex:a,autoHighlight:c,highlightColor:l,coordinateSystem:f,coordinateOrigin:u,wrapLongitude:d,positionFormat:h,modelMatrix:p,extensions:m,fetch:g,operation:_},b=x&&e.id&&x[e.id],T=b&&b.updateTriggers,v=e.id||"sublayer";if(b){let w=this.props[Ir],C=e.type?e.type._propTypes:{};for(let S in b){let A=C[S]||w[S];A&&A.type==="accessor"&&(b[S]=this.getSubLayerAccessor(b[S]))}}Object.assign(y,e,b),y.id=`${this.props.id}-${v}`,y.updateTriggers={all:this.props.updateTriggers?.all,...e.updateTriggers,...T};for(let w of m){let C=w.getSubLayerProps.call(this,w);C&&Object.assign(y,C,{updateTriggers:Object.assign(y.updateTriggers,C.updateTriggers)})}return y}_updateAutoHighlight(e){for(let r of this.getSubLayers())r.updateAutoHighlight(e)}_getAttributeManager(){return null}_postUpdate(e,r){let o=this.internalState.subLayers,n=!o||this.needsUpdate();if(n){let i=this.renderLayers();o=kt(i,Boolean),this.internalState.subLayers=o}He(JJ,this,n,o);for(let i of o)i.parent=this}};P_.layerName="CompositeLayer";var Ne=P_;var N1=Math.PI/180;function QJ({height:t,focalDistance:e,orbitAxis:r,rotationX:o,rotationOrbit:n,zoom:i}){let s=r==="Z"?[0,0,1]:[0,1,0],a=r==="Z"?[0,-e,0]:[0,0,e],c=new V().lookAt({eye:a,up:s});c.rotateX(o*N1),r==="Z"?c.rotateZ(n*N1):c.rotateY(n*N1);let l=Math.pow(2,i)/t;return c.scale(l),c}var M_=class extends ot{constructor(e){let{height:r,projectionMatrix:o,fovy:n=50,orbitAxis:i="Z",target:s=[0,0,0],rotationX:a=0,rotationOrbit:c=0,zoom:l=0}=e,f=o?o[5]/2:ln(n);super({...e,longitude:void 0,viewMatrix:QJ({height:r||1,focalDistance:f,orbitAxis:i,rotationX:a,rotationOrbit:c,zoom:l}),fovy:n,focalDistance:f,position:s,zoom:l}),this.target=s,this.orbitAxis=i,this.rotationX=a,this.rotationOrbit=c,this.fovy=n,this.projectedCenter=this.project(this.center)}unproject(e,{topLeft:r=!0}={}){let[o,n,i=this.projectedCenter[2]]=e,s=r?n:this.height-n,[a,c,l]=Mr([o,s,i],this.pixelUnprojectionMatrix);return[a,c,l]}panByPosition(e,r,o){let n=this.project(e),{near:i,far:s}=r3(this.projectionMatrix),a=i*s/(s-n[2]*(s-i)),c=i*s/(s-this.projectedCenter[2]*(s-i)),l=a/c,f=[this.width/2+(n[0]-r[0])*l,this.height/2+(n[1]-r[1])*l,this.projectedCenter[2]];return{target:this.unproject(f)}}};M_.displayName="OrbitViewport";var R_=M_;var eQ=new V().lookAt({eye:[0,0,1]});function tQ({width:t,height:e,near:r,far:o,padding:n}){let i=-t/2,s=t/2,a=-e/2,c=e/2;if(n){let{left:l=0,right:f=0,top:u=0,bottom:d=0}=n,h=ee((l+t-f)/2,0,t)-t/2,p=ee((u+e-d)/2,0,e)-e/2;i-=h,s-=h,a+=p,c+=p}return new V().ortho({left:i,right:s,bottom:a,top:c,near:r,far:o})}var I_=class extends ot{constructor(e){let{width:r,height:o,near:n=.1,far:i=1e3,zoom:s=0,target:a=[0,0,0],padding:c=null,flipY:l=!0}=e,f=e.zoomX??(Array.isArray(s)?s[0]:s),u=e.zoomY??(Array.isArray(s)?s[1]:s),d=Math.min(f,u),h=Math.pow(2,d),p;if(f!==u){let m=Math.pow(2,f),g=Math.pow(2,u);p={unitsPerMeter:[m/h,g/h,1],metersPerUnit:[h/m,h/g,1]}}super({...e,longitude:void 0,position:a,viewMatrix:eQ.clone().scale([h,h*(l?-1:1),h]),projectionMatrix:tQ({width:r||1,height:o||1,padding:c,near:n,far:i}),zoom:d,distanceScales:p}),this.target=a,this.zoomX=f,this.zoomY=u,this.flipY=l}projectFlat([e,r]){let{unitsPerMeter:o}=this.distanceScales;return[e*o[0],r*o[1]]}unprojectFlat([e,r]){let{metersPerUnit:o}=this.distanceScales;return[e*o[0],r*o[1]]}panByPosition(e,r,o){let n=Mr(r,this.pixelUnprojectionMatrix),i=this.projectFlat(e),s=Ye.add([],i,Ye.negate([],n)),a=Ye.add([],this.center,s);return{target:this.unprojectFlat(a)}}};I_.displayName="OrthographicViewport";var Ac=I_;var L_=class extends ot{constructor(e){let{longitude:r,latitude:o,modelMatrix:n,bearing:i=0,pitch:s=0,up:a=[0,0,1]}=e,l=new $r({bearing:i,pitch:s===-90?1e-4:90+s}).toVector3().normalize(),f=n?new V(n).transformAsVector(l):l,u=Number.isFinite(o)?Gf({latitude:o}):0,d=Math.pow(2,u),h=new V().lookAt({eye:[0,0,0],center:f,up:a}).scale(d);super({...e,zoom:u,viewMatrix:h}),this.latitude=o,this.longitude=r,this.pitch=s,this.bearing=i,this.up=a}};L_.displayName="FirstPersonViewport";var B_=L_;var vs=20,OB=500,Uu=class extends to{constructor(e){let{width:r,height:o,position:n=[0,0,0],bearing:i=0,pitch:s=0,longitude:a=null,latitude:c=null,maxPitch:l=90,minPitch:f=-90,maxBounds:u=null,startRotatePos:d,startBearing:h,startPitch:p,startZoomPosition:m,startPanPos:g,startPanPosition:_}=e;super({width:r,height:o,position:n,bearing:i,pitch:s,longitude:a,latitude:c,maxPitch:l,minPitch:f,maxBounds:u},{startRotatePos:d,startBearing:h,startPitch:p,startZoomPosition:m,startPanPos:g,startPanPosition:_},e.makeViewport)}panStart({pos:e}){let{position:r}=this.getViewportProps();return this._getUpdatedState({startPanPos:e,startPanPosition:r})}pan({pos:e}){if(!e)return this;let{startPanPos:r=[0,0],startPanPosition:o=[0,0]}=this.getState(),{width:n,height:i,bearing:s,pitch:a}=this.getViewportProps(),c=OB*(e[0]-r[0])/n,l=OB*(e[1]-r[1])/i,f=new $r({bearing:s,pitch:a}),u=new $r({bearing:s,pitch:-90}),d=f.toVector3().normalize(),h=u.toVector3().cross(d).normalize();return this._getUpdatedState({position:new E(o).add(h.scale(c)).add(d.scale(l))})}panEnd(){return this._getUpdatedState({startPanPos:null,startPanPosition:null})}rotateStart({pos:e}){return this._getUpdatedState({startRotatePos:e,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:e,deltaAngleX:r=0,deltaAngleY:o=0}){let{startRotatePos:n,startBearing:i,startPitch:s}=this.getState(),{width:a,height:c}=this.getViewportProps();if(!n||i===void 0||s===void 0)return this;let l;if(e){let f=(e[0]-n[0])/a,u=(e[1]-n[1])/c;l={bearing:i-f*180,pitch:s-u*90}}else l={bearing:i-r,pitch:s-o};return this._getUpdatedState(l)}rotateEnd(){return this._getUpdatedState({startRotatePos:null,startBearing:null,startPitch:null})}zoomStart(){return this._getUpdatedState({startZoomPosition:this.getViewportProps().position})}zoom({pos:e,scale:r}){let o=this.getViewportProps(),n=this.getState().startZoomPosition||o.position,i=this.makeViewport(o),{projectionMatrix:s,width:a}=i,l=2*Math.atan(1/s[0])*(e[0]/a-.5),f=this.getDirection(!0);return this._move(f.rotateZ({radians:-l}),Math.log2(r)*vs,n)}zoomEnd(){return this._getUpdatedState({startZoomPosition:null})}moveLeft(e=vs){let r=this.getDirection(!0);return this._move(r.rotateZ({radians:Math.PI/2}),e)}moveRight(e=vs){let r=this.getDirection(!0);return this._move(r.rotateZ({radians:-Math.PI/2}),e)}moveUp(e=vs){let r=this.getDirection(!0);return this._move(r,e)}moveDown(e=vs){let r=this.getDirection(!0);return this._move(r.negate(),e)}rotateLeft(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-e})}rotateRight(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+e})}rotateUp(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+e})}rotateDown(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-e})}zoomIn(e=vs){return this._move(new E(0,0,1),e)}zoomOut(e=vs){return this._move(new E(0,0,-1),e)}shortestPathFrom(e){let r=e.getViewportProps(),o={...this.getViewportProps()},{bearing:n,longitude:i}=o;return Math.abs(n-r.bearing)>180&&(o.bearing=n<0?n+360:n-360),i!==null&&r.longitude!==null&&Math.abs(i-r.longitude)>180&&(o.longitude=i<0?i+360:i-360),o}_move(e,r,o=this.getViewportProps().position){let n=e.scale(r);return this._getUpdatedState({position:new E(o).add(n)})}getDirection(e=!1){return new $r({bearing:this.getViewportProps().bearing,pitch:e?90:90+this.getViewportProps().pitch}).toVector3().normalize()}_getUpdatedState(e){return new Uu({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}applyConstraints(e){let{pitch:r,maxPitch:o,minPitch:n,longitude:i,position:s,bearing:a,maxBounds:c}=e;if(e.pitch=ee(r,n,o),i!==null&&(i<-180||i>180)&&(e.longitude=Ro(i+180,360)-180),(a<-180||a>180)&&(e.bearing=Ro(a+180,360)-180),c){let l=ee(s[0],c[0][0],c[1][0]),f=ee(s[1],c[0][1],c[1][1]),u=ee(s[2]??0,c[0][2]??0,c[1][2]??0);(l!==s[0]||f!==s[1]||u!==s[2])&&(e.position=[l,f,u])}return e}},Ss=class extends zt{constructor(){super(...arguments),this.ControllerState=Uu,this.transition={transitionDuration:300,transitionInterpolator:new Ue(["position","pitch","bearing"])}}};var O_=class extends Vt{constructor(e={}){super(e)}getViewportType(){return B_}get ControllerType(){return Ss}};O_.displayName="FirstPersonView";var FB=O_;var D1=class extends to{constructor(e){let{width:r,height:o,rotationX:n=0,rotationOrbit:i=0,target:s=[0,0,0],zoom:a=0,minRotationX:c=-90,maxRotationX:l=90,minZoom:f=-1/0,maxZoom:u=1/0,maxBounds:d=null,startPanPosition:h,startRotatePos:p,startRotationX:m,startRotationOrbit:g,startZoomPosition:_,startZoom:x}=e;super({width:r,height:o,rotationX:n,rotationOrbit:i,target:s,zoom:a,minRotationX:c,maxRotationX:l,minZoom:f,maxZoom:u,maxBounds:d},{startPanPosition:h,startRotatePos:p,startRotationX:m,startRotationOrbit:g,startZoomPosition:_,startZoom:x},e.makeViewport),this.unproject3D=e.unproject3D}panStart({pos:e}){return this._getUpdatedState({startPanPosition:this._unproject(e)})}pan({pos:e,startPosition:r}){let o=this.getState().startPanPosition||r;if(!o)return this;let i=this.makeViewport(this.getViewportProps()).panByPosition(o,e);return this._getUpdatedState(i)}panEnd(){return this._getUpdatedState({startPanPosition:null})}rotateStart({pos:e}){return this._getUpdatedState({startRotatePos:e,startRotationX:this.getViewportProps().rotationX,startRotationOrbit:this.getViewportProps().rotationOrbit})}rotate({pos:e,deltaAngleX:r=0,deltaAngleY:o=0}){let{startRotatePos:n,startRotationX:i,startRotationOrbit:s}=this.getState(),{width:a,height:c}=this.getViewportProps();if(!n||i===void 0||s===void 0)return this;let l;if(e){let f=(e[0]-n[0])/a,u=(e[1]-n[1])/c;(i<-90||i>90)&&(f*=-1),l={rotationX:i+u*180,rotationOrbit:s+f*180}}else l={rotationX:i+o,rotationOrbit:s+r};return this._getUpdatedState(l)}rotateEnd(){return this._getUpdatedState({startRotationX:null,startRotationOrbit:null})}shortestPathFrom(e){let r=e.getViewportProps(),o={...this.getViewportProps()},{rotationOrbit:n}=o;return Math.abs(n-r.rotationOrbit)>180&&(o.rotationOrbit=n<0?n+360:n-360),o}zoomStart({pos:e}){return this._getUpdatedState({startZoomPosition:this._unproject(e),startZoom:this.getViewportProps().zoom})}zoom({pos:e,startPos:r,scale:o}){let{startZoom:n,startZoomPosition:i}=this.getState();if(i||(n=this.getViewportProps().zoom,i=this._unproject(r||e)),!i)return this;let s=this._calculateNewZoom({scale:o,startZoom:n}),a=this.makeViewport({...this.getViewportProps(),zoom:s});return this._getUpdatedState({zoom:s,...a.panByPosition(i,e)})}zoomEnd(){return this._getUpdatedState({startZoomPosition:null,startZoom:null})}zoomIn(e=2){return this._getUpdatedState({zoom:this._calculateNewZoom({scale:e})})}zoomOut(e=2){return this._getUpdatedState({zoom:this._calculateNewZoom({scale:1/e})})}moveLeft(e=50){return this._panFromCenter([-e,0])}moveRight(e=50){return this._panFromCenter([e,0])}moveUp(e=50){return this._panFromCenter([0,-e])}moveDown(e=50){return this._panFromCenter([0,e])}rotateLeft(e=15){return this._getUpdatedState({rotationOrbit:this.getViewportProps().rotationOrbit-e})}rotateRight(e=15){return this._getUpdatedState({rotationOrbit:this.getViewportProps().rotationOrbit+e})}rotateUp(e=10){return this._getUpdatedState({rotationX:this.getViewportProps().rotationX-e})}rotateDown(e=10){return this._getUpdatedState({rotationX:this.getViewportProps().rotationX+e})}_project(e){return this.makeViewport(this.getViewportProps()).project(e)}_unproject(e){let r=this.unproject3D?.(e);return r||this.makeViewport(this.getViewportProps()).unproject(e)}_calculateNewZoom({scale:e,startZoom:r}){r===void 0&&(r=this.getViewportProps().zoom);let o=r+Math.log2(e);return this._constrainZoom(o)}_panFromCenter(e){let{target:r}=this.getViewportProps(),o=this._project(r);return this.pan({startPosition:r,pos:[o[0]+e[0],o[1]+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}applyConstraints(e){let{maxRotationX:r,minRotationX:o,rotationOrbit:n}=e;return e.zoom=this._constrainZoom(e.zoom,e),e.rotationX=ee(e.rotationX,o,r),(n<-180||n>180)&&(e.rotationOrbit=Ro(n+180,360)-180),e.target=this._constrainTarget(e),e}_constrainZoom(e,r){r||(r=this.getViewportProps());let{maxZoom:o,maxBounds:n}=r,{minZoom:i}=r;if(n&&r.width>0&&r.height>0){let s=n[1][0]-n[0][0],a=n[1][1]-n[0][1],c=(n[1][2]??0)-(n[0][2]??0),l=Math.sqrt(s*s+a*a+c*c);l>0&&(i=Math.max(i,Math.log2(Math.min(r.width,r.height)/l)),i>o&&(i=o))}return ee(e,i,o)}_constrainTarget(e){let{target:r,maxBounds:o}=e;if(!o)return r;let[[n,i,s=0],[a,c,l=0]]=o;if(r[0]>=n&&r[0]<=a&&r[1]>=i&&r[1]<=c&&r[2]>=s&&r[2]<=l)return r;let f=this.makeViewport?.(e);if(f){let{cameraPosition:u}=f,d=u[0]-r[0],h=u[1]-r[1],p=u[2]-r[2],m=d*r[0]+h*r[1]+p*r[2],g=d*(d>=0?n:a)+h*(h>=0?i:c)+p*(p>=0?s:l),_=d*(d>=0?a:n)+h*(h>=0?c:i)+p*(p>=0?l:s);if((d||h||p)&&m>=g&&m<=_){let x=M=>ee(M,n,a),y=M=>ee(M,i,c),b=M=>ee(M,s,l),T=M=>d*x(r[0]-M*d)+h*y(r[1]-M*h)+p*b(r[2]-M*p)-m,v=-1,w=1,C=T(v),S=T(w);for(;C<0;)w=v,S=C,v*=2,C=T(v);for(;S>0;)v=w,C=S,w*=2,S=T(w);for(let M=0;M<30;M++){let B=(v+w)/2;T(B)>0?v=B:w=B}let A=(v+w)/2;return[x(r[0]-A*d),y(r[1]-A*h),b(r[2]-A*p)]}}return[ee(r[0],n,a),ee(r[1],i,c),ee(r[2],s,l)]}},Cs=class extends zt{constructor(){super(...arguments),this.ControllerState=D1,this.transition={transitionDuration:300,transitionInterpolator:new Ue({transitionProps:{compare:["target","zoom","rotationX","rotationOrbit"],required:["target","zoom"]}})},this._unproject3D=e=>{if(this.pickPosition){let{x:r,y:o}=this.props,n=this.pickPosition(r+e[0],o+e[1]);if(n&&n.coordinate)return n.coordinate}return null}}setProps(e){e.unproject3D=this._unproject3D,super.setProps(e)}};var F_=class extends Vt{constructor(e={}){super(e),this.props.orbitAxis=e.orbitAxis||"Z"}getViewportType(){return R_}get ControllerType(){return Cs}};F_.displayName="OrbitView";var NB=F_;function DB({zoom:t=0,zoomX:e,zoomY:r}){return e=e??(Array.isArray(t)?t[0]:t),r=r??(Array.isArray(t)?t[1]:t),{zoomX:e,zoomY:r}}var U1=class extends to{constructor(e){let{width:r,height:o,target:n=[0,0,0],zoom:i=0,zoomAxis:s="all",minZoom:a=-1/0,maxZoom:c=1/0,minZoomX:l=a,maxZoomX:f=c,minZoomY:u=a,maxZoomY:d=c,maxBounds:h=null,startPanPosition:p,startZoomPosition:m,startZoom:g}=e,{zoomX:_,zoomY:x}=DB(e);super({width:r,height:o,target:n,zoom:i,zoomX:_,zoomY:x,zoomAxis:s,minZoomX:l,maxZoomX:f,minZoomY:u,maxZoomY:d,maxBounds:h},{startPanPosition:p,startZoomPosition:m,startZoom:g},e.makeViewport)}panStart({pos:e}){return this._getUpdatedState({startPanPosition:this._unproject(e)})}pan({pos:e,startPosition:r}){let o=this.getState().startPanPosition||r;if(!o)return this;let i=this.makeViewport(this.getViewportProps()).panByPosition(o,e);return this._getUpdatedState(i)}panEnd(){return this._getUpdatedState({startPanPosition:null})}rotateStart(){return this}rotate(){return this}rotateEnd(){return this}shortestPathFrom(e){let r=e.getViewportProps();return{...this.getViewportProps()}}zoomStart({pos:e}){let{zoomX:r,zoomY:o}=this.getViewportProps();return this._getUpdatedState({startZoomPosition:this._unproject(e),startZoom:[r,o]})}zoom({pos:e,startPos:r,scale:o}){let{startZoom:n,startZoomPosition:i}=this.getState();if(!i){let{zoomX:c,zoomY:l}=this.getViewportProps();n=[c,l],i=this._unproject(r||e)}if(!i)return this;let s=this._constrainZoom(this._calculateNewZoom({scale:o,startZoom:n})),a=this.makeViewport({...this.getViewportProps(),...s});return this._getUpdatedState({...s,...a.panByPosition(i,e)})}zoomEnd(){return this._getUpdatedState({startZoomPosition:null,startZoom:null})}zoomIn(e=2){return this._getUpdatedState(this._calculateNewZoom({scale:e}))}zoomOut(e=2){return this._getUpdatedState(this._calculateNewZoom({scale:1/e}))}moveLeft(e=50){return this._panFromCenter([-e,0])}moveRight(e=50){return this._panFromCenter([e,0])}moveUp(e=50){return this._panFromCenter([0,-e])}moveDown(e=50){return this._panFromCenter([0,e])}rotateLeft(e=15){return this}rotateRight(e=15){return this}rotateUp(e=10){return this}rotateDown(e=10){return this}_project(e){return this.makeViewport(this.getViewportProps()).project(e)}_unproject(e){return this.makeViewport(this.getViewportProps()).unproject(e)}_calculateNewZoom({scale:e,startZoom:r}){let{zoomX:o,zoomY:n,zoomAxis:i}=this.getViewportProps();r===void 0&&(r=[o,n]);let s=Math.log2(e),[a,c]=r;switch(i){case"X":a+=s;break;case"Y":c+=s;break;default:a+=s,c+=s}return{zoomX:a,zoomY:c}}_panFromCenter(e){let{target:r}=this.getViewportProps(),o=this._project(r);return this.pan({startPosition:r,pos:[o[0]+e[0],o[1]+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}applyConstraints(e){let{zoomX:r,zoomY:o}=this._constrainZoom(e,e);e.zoomX=r,e.zoomY=o,e.zoom=Array.isArray(e.zoom)||e.zoomX!==e.zoomY?[e.zoomX,e.zoomY]:e.zoomX;let{maxBounds:n,target:i}=e;if(n){let s=e.width/2/2**r,a=e.height/2/2**o,c=n[0][0]+s,l=n[1][0]-s,f=n[0][1]+a,u=n[1][1]-a,d=ee(i[0],c,l),h=ee(i[1],f,u);(d!==i[0]||h!==i[1])&&(e.target=i.slice(),e.target[0]=d,e.target[1]=h)}return e}_constrainZoom({zoomX:e,zoomY:r},o){o||(o=this.getViewportProps());let{zoomAxis:n,maxZoomX:i,maxZoomY:s,maxBounds:a}=o,{minZoomX:c,minZoomY:l}=o;if(a!==null&&o.width>0&&o.height>0){let u=a[0],d=a[1],h=d[0]-u[0],p=d[1]-u[1];Number.isFinite(h)&&h>0&&(c=Math.max(c,Math.log2(o.width/h)),c>i&&(c=i)),Number.isFinite(p)&&p>0&&(l=Math.max(l,Math.log2(o.height/p)),l>s&&(l=s))}switch(n){case"X":e=ee(e,c,i);break;case"Y":r=ee(r,l,s);break;default:let u=Math.min(i-e,s-r,0);u===0&&(u=Math.max(c-e,l-r,0)),u!==0&&(e+=u,r+=u)}return{zoomX:e,zoomY:r}}},Es=class extends zt{constructor(){super(...arguments),this.ControllerState=U1,this.transition={transitionDuration:300,transitionInterpolator:new Ue(["target","zoomX","zoomY"])},this.dragMode="pan"}setProps(e){Object.assign(e,DB(e)),super.setProps(e)}_onPanRotate(){return!1}};var N_=class extends Vt{constructor(e={}){super(e)}getViewportType(){return Ac}get ControllerType(){return Es}};N_.displayName="OrthographicView";var D_=N_;var k1=Math.PI/180,rQ=180/Math.PI;function UB(t,e=0){let r=Math.min(180,t)*k1;return _n*2*Math.sin(r/2)*Math.pow(2,e)}function kB(t,e=0){let r=t/Math.pow(2,e);return Math.asin(Math.min(1,r/_n/2))*2*rQ}var V1=class extends fu{constructor(e){let{startPanPos:r,...o}=e;o.normalize=!1,super(o),r!==void 0&&(this._state.startPanPos=r)}panStart({pos:e}){let{latitude:r,longitude:o,zoom:n}=this.getViewportProps();return this._getUpdatedState({startPanLngLat:[o,r],startPanPos:e,startZoom:n})}pan({pos:e,startPos:r}){let o=this.getState(),n=o.startPanLngLat||this._unproject(r);if(!n)return this;let i=o.startZoom??this.getViewportProps().zoom,s=o.startPanPos||r,a=[n[0],n[1],i],l=this.makeViewport(this.getViewportProps()).panByPosition(a,e,s);return this._getUpdatedState(l)}panEnd(){return this._getUpdatedState({startPanLngLat:null,startPanPos:null,startZoom:null})}zoom({scale:e}){let o=(this.getState().startZoom||this.getViewportProps().zoom)+Math.log2(e);return this._getUpdatedState({zoom:o})}applyConstraints(e){let{longitude:r,latitude:o,maxBounds:n}=e;if(e.zoom=this._constrainZoom(e.zoom,e),(r<-180||r>180)&&(e.longitude=Ro(r+180,360)-180),e.latitude=ee(o,-Ut,Ut),n&&(e.longitude=ee(e.longitude,n[0][0],n[1][0]),e.latitude=ee(e.latitude,n[0][1],n[1][1])),n){let i=e.zoom-Bo(o),s=n[1][0]-n[0][0],a=n[1][1]-n[0][1];if(a>0&&a<Ut*2){let c=Math.min(kB(e.height,i),a)/2;e.latitude=ee(e.latitude,n[0][1]+c,n[1][1]-c)}if(s>0&&s<360){let c=Math.min(kB(e.width/Math.cos(e.latitude*k1),i),s)/2;e.longitude=ee(e.longitude,n[0][0]+c,n[1][0]-c)}}return e.latitude!==o&&(e.zoom+=Bo(e.latitude)-Bo(o)),e}_constrainZoom(e,r){r||(r=this.getViewportProps());let{latitude:o,maxZoom:n,maxBounds:i}=r,{minZoom:s}=r,a=Bo(0),c=Bo(o)-a;if(i!==null&&r.width>0&&r.height>0){let f=i[0][1],u=i[1][1],d=Math.sign(f)===Math.sign(u)?Math.min(Math.abs(f),Math.abs(u)):0,h=UB(i[1][0]-i[0][0])*Math.cos(d*k1),p=UB(i[1][1]-i[0][1]);h>0&&(s=Math.max(s,Math.log2(r.width/h)+a)),p>0&&(s=Math.max(s,Math.log2(r.height/p)+a)),s>n&&(s=n)}return ee(e,s+c,n+c)}},ws=class extends zt{constructor(){super(...arguments),this.ControllerState=V1,this.transition={transitionDuration:300,transitionInterpolator:new Ue(["longitude","latitude","zoom"])},this.dragMode="pan"}setProps(e){super.setProps(e),this.dragRotate=!1,this.touchRotate=!1}};var oQ={cullMode:"back"},U_=class extends Vt{constructor(e={}){super({...e,parameters:{...oQ,...e.parameters}})}getViewportType(e){return e.zoom>12?Mt:Oo}get ControllerType(){return ws}};U_.displayName="GlobeView";var k_=U_;var ku=class extends xn{constructor(){super(...arguments),this._terrainAltitude=void 0,this._terrainAltitudeTarget=void 0,this._pickFrameId=null,this._lastPickTime=0}setProps(e){if(super.setProps({rotationPivot:"3d",...e}),this._pickFrameId===null){let r=()=>{let o=Date.now();if(o-this._lastPickTime>500&&!this.isDragging()&&(this._lastPickTime=o,this._pickTerrainCenterAltitude(),this._terrainAltitude===void 0&&this._terrainAltitudeTarget!==void 0)){this._terrainAltitude=this._terrainAltitudeTarget;let n=new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),i=this._rebaseViewport(this._terrainAltitudeTarget,n);if(i){let s=new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state,...i});super.updateViewport(s)}}this._pickFrameId=requestAnimationFrame(r)};this._pickFrameId=requestAnimationFrame(r)}}finalize(){this._pickFrameId!==null&&(cancelAnimationFrame(this._pickFrameId),this._pickFrameId=null),super.finalize()}updateViewport(e,r=null,o={}){if(this._terrainAltitude===void 0){super.updateViewport(e,r,o);return}let n=.05;this._terrainAltitude+=(this._terrainAltitudeTarget-this._terrainAltitude)*n;let s=e.getViewportProps().position||[0,0,0];r={...r,position:[s[0],s[1],this._terrainAltitude]},super.updateViewport(e,r,o)}_pickTerrainCenterAltitude(){if(!this.pickPosition)return;let{x:e,y:r,width:o,height:n}=this.props,i=this.pickPosition(e+o/2,r+n/2);i?.coordinate&&i.coordinate.length>=3&&(this._terrainAltitudeTarget=i.coordinate[2])}_rebaseViewport(e,r){let o=r.getViewportProps(),n=this.makeViewport({...o,position:[0,0,0]}),i=n.cameraPosition,s=e*n.distanceScales.unitsPerMeter[2],a=i[2],c=a-s;if(c<=0)return null;let l=Math.log2(a/c),f=o.zoom+l,u=this.makeViewport({...o,zoom:f,position:[0,0,e]}),{width:d,height:h}=o,p=[d/2,h/2],m=n.unproject(p,{targetZ:e});if(m&&"panByPosition3D"in u&&typeof u.panByPosition3D=="function"){let g=u.panByPosition3D(m,p);return{position:[0,0,e],zoom:f,...g}}return null}};var Vu=class{static get componentName(){return Object.prototype.hasOwnProperty.call(this,"extensionName")?this.extensionName:""}constructor(e){e&&(this.opts=e)}equals(e){return this===e?!0:this.constructor===e.constructor&&ie(this.opts,e.opts,1)}getShaders(e){return null}getSubLayerProps(e){let{defaultProps:r}=e.constructor,o={updateTriggers:{}};for(let n in r)if(n in this.props){let i=r[n],s=this.props[n];o[n]=s,i&&i.type==="accessor"&&(o.updateTriggers[n]=this.props.updateTriggers[n],typeof s=="function"&&(o[n]=this.getSubLayerAccessor(s)))}return o}initializeState(e,r){}updateState(e,r){}onNeedsRedraw(e){}getNeedsPickingBuffer(e){return!1}draw(e,r){}finalizeState(e,r){}};Vu.defaultProps={};Vu.extensionName="LayerExtension";var st=Vu;var z1={bearing:0,pitch:0,position:[0,0,0]},nQ={speed:1.2,curve:1.414},so=class extends gn{constructor(e={}){super({compare:["longitude","latitude","zoom","bearing","pitch","position"],extract:["width","height","longitude","latitude","zoom","bearing","pitch","position"],required:["width","height","latitude","longitude","zoom"]}),this.opts={...nQ,...e}}interpolateProps(e,r,o){let n=Mv(e,r,o,this.opts);for(let i in z1)n[i]=lt(e[i]||z1[i],r[i]||z1[i],o);return n}getDuration(e,r){let{transitionDuration:o}=r;return o==="auto"&&(o=Rv(e,r,this.opts)),o}};q();var vn=class{constructor(e){this.indexStarts=[0],this.vertexStarts=[0],this.vertexCount=0,this.instanceCount=0;let{attributes:r={}}=e;this.typedArrayManager=Zr,this.attributes={},this._attributeDefs=r,this.opts=e,this.updateGeometry(e)}updateGeometry(e){Object.assign(this.opts,e);let{data:r,buffers:o={},getGeometry:n,geometryBuffer:i,positionFormat:s,dataChanged:a,normalize:c=!0}=this.opts;if(this.data=r,this.getGeometry=n,this.positionSize=i&&i.size||(s==="XY"?2:3),this.buffers=o,this.normalize=c,i&&(ge(r.startIndices),this.getGeometry=this.getGeometryFromBuffer(i),c||(o.vertexPositions=i)),this.geometryBuffer=o.vertexPositions,Array.isArray(a))for(let l of a)this._rebuildGeometry(l);else this._rebuildGeometry()}updatePartialGeometry({startRow:e,endRow:r}){this._rebuildGeometry({startRow:e,endRow:r})}getGeometryFromBuffer(e){let r=e.value||e;return ArrayBuffer.isView(r)?x_(r,{size:this.positionSize,offset:e.offset,stride:e.stride,startIndices:this.data.startIndices}):null}_allocate(e,r){let{attributes:o,buffers:n,_attributeDefs:i,typedArrayManager:s}=this;for(let a in i)if(a in n)s.release(o[a]),o[a]=null;else{let c=i[a];c.copy=r,o[a]=s.allocate(o[a],e,c)}}_forEachGeometry(e,r,o){let{data:n,getGeometry:i}=this,{iterable:s,objectInfo:a}=Fe(n,r,o);for(let c of s){a.index++;let l=i?i(c,a):null;e(l,a.index)}}_rebuildGeometry(e){if(!this.data)return;let{indexStarts:r,vertexStarts:o,instanceCount:n}=this,{data:i,geometryBuffer:s}=this,{startRow:a=0,endRow:c=1/0}=e||{},l={};if(e||(r=[0],o=[0]),this.normalize||!s)this._forEachGeometry((u,d)=>{let h=u&&this.normalizeGeometry(u);l[d]=h,o[d+1]=o[d]+(h?this.getGeometrySize(h):0)},a,c),n=o[o.length-1];else if(o=i.startIndices,n=o[i.length]||0,ArrayBuffer.isView(s))n=n||s.length/this.positionSize;else if(s instanceof K){let u=this.positionSize*4;n=n||s.byteLength/u}else if(s.buffer){let u=s.stride||this.positionSize*4;n=n||s.buffer.byteLength/u}else if(s.value){let u=s.value,d=s.stride/u.BYTES_PER_ELEMENT||this.positionSize;n=n||u.length/d}this._allocate(n,Boolean(e)),this.indexStarts=r,this.vertexStarts=o,this.instanceCount=n;let f={};this._forEachGeometry((u,d)=>{let h=l[d]||u;f.vertexStart=o[d],f.indexStart=r[d];let p=d<o.length-1?o[d+1]:n;f.geometrySize=p-o[d],f.geometryIndex=d,this.updateGeometryAttributes(h,f)},a,c),this.vertexCount=r[r.length-1]}};var VB=`layout(std140) uniform arcUniforms { bool greatCircle; bool useShortestPath; float numSegments; float widthScale; float widthMinPixels; float widthMaxPixels; highp int widthUnits; } arc; `,zB={name:"arc",vs:VB,fs:VB,uniformTypes:{greatCircle:"f32",useShortestPath:"f32",numSegments:"f32",widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",widthUnits:"i32"}};var HB=`#version 300 es #define SHADER_NAME arc-layer-vertex-shader in vec4 instanceSourceColors; in vec4 instanceTargetColors; in vec3 instanceSourcePositions; in vec3 instanceSourcePositions64Low; in vec3 instanceTargetPositions; in vec3 instanceTargetPositions64Low; in vec3 instancePickingColors; in float instanceWidths; in float instanceHeights; in float instanceTilts; out vec4 vColor; out vec2 uv; out float isValid; float paraboloid(float distance, float sourceZ, float targetZ, float ratio) { float deltaZ = targetZ - sourceZ; float dh = distance * instanceHeights; if (dh == 0.0) { return sourceZ + deltaZ * ratio; } float unitZ = deltaZ / dh; float p2 = unitZ * unitZ + 1.0; float dir = step(deltaZ, 0.0); float z0 = mix(sourceZ, targetZ, dir); float r = mix(ratio, 1.0 - ratio, dir); return sqrt(r * (p2 - r)) * dh + z0; } vec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction, float width) { vec2 dir_screenspace = normalize(line_clipspace * project.viewportSize); dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x); return dir_screenspace * offset_direction * width / 2.0; } float getSegmentRatio(float index) { return smoothstep(0.0, 1.0, index / (arc.numSegments - 1.0)); } vec3 interpolateFlat(vec3 source, vec3 target, float segmentRatio) { float distance = length(source.xy - target.xy); float z = paraboloid(distance, source.z, target.z, segmentRatio); float tiltAngle = radians(instanceTilts); vec2 tiltDirection = normalize(target.xy - source.xy); vec2 tilt = vec2(-tiltDirection.y, tiltDirection.x) * z * sin(tiltAngle); return vec3( mix(source.xy, target.xy, segmentRatio) + tilt, z * cos(tiltAngle) ); } float getAngularDist (vec2 source, vec2 target) { vec2 sourceRadians = radians(source); vec2 targetRadians = radians(target); vec2 sin_half_delta = sin((sourceRadians - targetRadians) / 2.0); vec2 shd_sq = sin_half_delta * sin_half_delta; float a = shd_sq.y + cos(sourceRadians.y) * cos(targetRadians.y) * shd_sq.x; return 2.0 * asin(sqrt(a)); } vec3 interpolateGreatCircle(vec3 source, vec3 target, vec3 source3D, vec3 target3D, float angularDist, float t) { vec2 lngLat; if(abs(angularDist - PI) < 0.001) { lngLat = (1.0 - t) * source.xy + t * target.xy; } else { float a = sin((1.0 - t) * angularDist); float b = sin(t * angularDist); vec3 p = source3D.yxz * a + target3D.yxz * b; lngLat = degrees(vec2(atan(p.y, -p.x), atan(p.z, length(p.xy)))); } float z = paraboloid(angularDist * EARTH_RADIUS, source.z, target.z, t); return vec3(lngLat, z); } void main(void) { geometry.worldPosition = instanceSourcePositions; geometry.worldPositionAlt = instanceTargetPositions; float segmentIndex = float(gl_VertexID / 2); float segmentSide = mod(float(gl_VertexID), 2.) == 0. ? -1. : 1.; float segmentRatio = getSegmentRatio(segmentIndex); float prevSegmentRatio = getSegmentRatio(max(0.0, segmentIndex - 1.0)); float nextSegmentRatio = getSegmentRatio(min(arc.numSegments - 1.0, segmentIndex + 1.0)); float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0)); isValid = 1.0; uv = vec2(segmentRatio, segmentSide); geometry.uv = uv; geometry.pickingColor = instancePickingColors; vec4 curr; vec4 next; vec3 source; vec3 target; if ((arc.greatCircle || project.projectionMode == PROJECTION_MODE_GLOBE) && project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) { source = project_globe_(vec3(instanceSourcePositions.xy, 0.0)); target = project_globe_(vec3(instanceTargetPositions.xy, 0.0)); float angularDist = getAngularDist(instanceSourcePositions.xy, instanceTargetPositions.xy); vec3 prevPos = interpolateGreatCircle(instanceSourcePositions, instanceTargetPositions, source, target, angularDist, prevSegmentRatio); vec3 currPos = interpolateGreatCircle(instanceSourcePositions, instanceTargetPositions, source, target, angularDist, segmentRatio); vec3 nextPos = interpolateGreatCircle(instanceSourcePositions, instanceTargetPositions, source, target, angularDist, nextSegmentRatio); if (abs(currPos.x - prevPos.x) > 180.0) { indexDir = -1.0; isValid = 0.0; } else if (abs(currPos.x - nextPos.x) > 180.0) { indexDir = 1.0; isValid = 0.0; } nextPos = indexDir < 0.0 ? prevPos : nextPos; nextSegmentRatio = indexDir < 0.0 ? prevSegmentRatio : nextSegmentRatio; if (isValid == 0.0) { nextPos.x += nextPos.x > 0.0 ? -360.0 : 360.0; float t = ((currPos.x > 0.0 ? 180.0 : -180.0) - currPos.x) / (nextPos.x - currPos.x); currPos = mix(currPos, nextPos, t); segmentRatio = mix(segmentRatio, nextSegmentRatio, t); } vec3 currPos64Low = mix(instanceSourcePositions64Low, instanceTargetPositions64Low, segmentRatio); vec3 nextPos64Low = mix(instanceSourcePositions64Low, instanceTargetPositions64Low, nextSegmentRatio); curr = project_position_to_clipspace(currPos, currPos64Low, vec3(0.0), geometry.position); next = project_position_to_clipspace(nextPos, nextPos64Low, vec3(0.0)); } else { vec3 source_world = instanceSourcePositions; vec3 target_world = instanceTargetPositions; if (arc.useShortestPath) { source_world.x = mod(source_world.x + 180., 360.0) - 180.; target_world.x = mod(target_world.x + 180., 360.0) - 180.; float deltaLng = target_world.x - source_world.x; if (deltaLng > 180.) target_world.x -= 360.; if (deltaLng < -180.) source_world.x -= 360.; } source = project_position(source_world, instanceSourcePositions64Low); target = project_position(target_world, instanceTargetPositions64Low); float antiMeridianX = 0.0; if (arc.useShortestPath) { if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) { antiMeridianX = -(project.coordinateOrigin.x + 180.) / 360. * TILE_SIZE; } float thresholdRatio = (antiMeridianX - source.x) / (target.x - source.x); if (prevSegmentRatio <= thresholdRatio && nextSegmentRatio > thresholdRatio) { isValid = 0.0; indexDir = sign(segmentRatio - thresholdRatio); segmentRatio = thresholdRatio; } } nextSegmentRatio = indexDir < 0.0 ? prevSegmentRatio : nextSegmentRatio; vec3 currPos = interpolateFlat(source, target, segmentRatio); vec3 nextPos = interpolateFlat(source, target, nextSegmentRatio); if (arc.useShortestPath) { if (nextPos.x < antiMeridianX) { currPos.x += TILE_SIZE; nextPos.x += TILE_SIZE; } } curr = project_common_position_to_clipspace(vec4(currPos, 1.0)); next = project_common_position_to_clipspace(vec4(nextPos, 1.0)); geometry.position = vec4(currPos, 1.0); } float widthPixels = clamp( project_size_to_pixel(instanceWidths * arc.widthScale, arc.widthUnits), arc.widthMinPixels, arc.widthMaxPixels ); vec3 offset = vec3( getExtrusionOffset((next.xy - curr.xy) * indexDir, segmentSide, widthPixels), 0.0); DECKGL_FILTER_SIZE(offset, geometry); DECKGL_FILTER_GL_POSITION(curr, geometry); gl_Position = curr + vec4(project_pixel_size_to_clipspace(offset.xy), 0.0, 0.0); vec4 color = mix(instanceSourceColors, instanceTargetColors, segmentRatio); vColor = vec4(color.rgb, color.a * layer.opacity); DECKGL_FILTER_COLOR(vColor, geometry); } `;var jB=`#version 300 es #define SHADER_NAME arc-layer-fragment-shader precision highp float; in vec4 vColor; in vec2 uv; in float isValid; out vec4 fragColor; void main(void) { if (isValid == 0.0) { discard; } fragColor = vColor; geometry.uv = uv; DECKGL_FILTER_COLOR(fragColor, geometry); } `;var V_=[0,0,0,255],iQ={getSourcePosition:{type:"accessor",value:t=>t.sourcePosition},getTargetPosition:{type:"accessor",value:t=>t.targetPosition},getSourceColor:{type:"accessor",value:V_},getTargetColor:{type:"accessor",value:V_},getWidth:{type:"accessor",value:1},getHeight:{type:"accessor",value:1},getTilt:{type:"accessor",value:0},greatCircle:!1,numSegments:{type:"number",value:50,min:1},widthUnits:"pixels",widthScale:{type:"number",value:1,min:0},widthMinPixels:{type:"number",value:0,min:0},widthMaxPixels:{type:"number",value:Number.MAX_SAFE_INTEGER,min:0}},zu=class extends _e{getBounds(){return this.getAttributeManager()?.getBounds(["instanceSourcePositions","instanceTargetPositions"])}getShaders(){return super.getShaders({vs:HB,fs:jB,modules:[fe,Se,zB]})}get wrapLongitude(){return!1}initializeState(){this.getAttributeManager().addInstanced({instanceSourcePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getSourcePosition"},instanceTargetPositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getTargetPosition"},instanceSourceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getSourceColor",defaultValue:V_},instanceTargetColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getTargetColor",defaultValue:V_},instanceWidths:{size:1,transition:!0,accessor:"getWidth",defaultValue:1},instanceHeights:{size:1,transition:!0,accessor:"getHeight",defaultValue:1},instanceTilts:{size:1,transition:!0,accessor:"getTilt",defaultValue:0}})}updateState(e){super.updateState(e),e.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){let{widthUnits:r,widthScale:o,widthMinPixels:n,widthMaxPixels:i,greatCircle:s,wrapLongitude:a,numSegments:c}=this.props,l={numSegments:c,widthUnits:Pe[r],widthScale:o,widthMinPixels:n,widthMaxPixels:i,greatCircle:s,useShortestPath:a},f=this.state.model;f.shaderInputs.setProps({arc:l}),f.setVertexCount(c*2),f.draw(this.context.renderPass)}_getModel(){return new Q(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),topology:"triangle-strip",isInstanced:!0})}};zu.layerName="ArcLayer";zu.defaultProps=iQ;var z_=zu;var sQ=new Uint32Array([0,2,1,0,3,2]),aQ=new Float32Array([0,1,0,0,1,0,1,1]);function H1(t,e){if(!e)return cQ(t);let r=Math.max(Math.abs(t[0][0]-t[3][0]),Math.abs(t[1][0]-t[2][0])),o=Math.max(Math.abs(t[1][1]-t[0][1]),Math.abs(t[2][1]-t[3][1])),n=Math.ceil(r/e)+1,i=Math.ceil(o/e)+1,s=(n-1)*(i-1)*6,a=new Uint32Array(s),c=new Float32Array(n*i*2),l=new Float64Array(n*i*3),f=0,u=0;for(let d=0;d<n;d++){let h=d/(n-1);for(let p=0;p<i;p++){let m=p/(i-1),g=lQ(t,h,m);l[f*3+0]=g[0],l[f*3+1]=g[1],l[f*3+2]=g[2]||0,c[f*2+0]=h,c[f*2+1]=1-m,d>0&&p>0&&(a[u++]=f-i,a[u++]=f-i-1,a[u++]=f-1,a[u++]=f-i,a[u++]=f-1,a[u++]=f),f++}}return{vertexCount:s,positions:l,indices:a,texCoords:c}}function cQ(t){let e=new Float64Array(12);for(let r=0;r<t.length;r++)e[r*3+0]=t[r][0],e[r*3+1]=t[r][1],e[r*3+2]=t[r][2]||0;return{vertexCount:6,positions:e,indices:sQ,texCoords:aQ}}function lQ(t,e,r){return lt(lt(t[0],t[1],r),lt(t[3],t[2],r),e)}var WB=`layout(std140) uniform bitmapUniforms { vec4 bounds; float coordinateConversion; float desaturate; vec3 tintColor; vec4 transparentColor; } bitmap; `,GB={name:"bitmap",vs:WB,fs:WB,uniformTypes:{bounds:"vec4<f32>",coordinateConversion:"f32",desaturate:"f32",tintColor:"vec3<f32>",transparentColor:"vec4<f32>"}};var $B=`#version 300 es #define SHADER_NAME bitmap-layer-vertex-shader in vec2 texCoords; in vec3 positions; in vec3 positions64Low; out vec2 vTexCoord; out vec2 vTexPos; const vec3 pickingColor = vec3(1.0, 0.0, 0.0); void main(void) { geometry.worldPosition = positions; geometry.uv = texCoords; geometry.pickingColor = pickingColor; gl_Position = project_position_to_clipspace(positions, positions64Low, vec3(0.0), geometry.position); DECKGL_FILTER_GL_POSITION(gl_Position, geometry); vTexCoord = texCoords; if (bitmap.coordinateConversion < -0.5) { vTexPos = geometry.position.xy + project.commonOrigin.xy; } else if (bitmap.coordinateConversion > 0.5) { vTexPos = geometry.worldPosition.xy; } vec4 color = vec4(0.0); DECKGL_FILTER_COLOR(color, geometry); } `;var fQ=` vec3 packUVsIntoRGB(vec2 uv) { // Extract the top 8 bits. We want values to be truncated down so we can add a fraction vec2 uv8bit = floor(uv * 256.); // Calculate the normalized remainders of u and v parts that do not fit into 8 bits // Scale and clamp to 0-1 range vec2 uvFraction = fract(uv * 256.); vec2 uvFraction4bit = floor(uvFraction * 16.); // Remainder can be encoded in blue channel, encode as 4 bits for pixel coordinates float fractions = uvFraction4bit.x + uvFraction4bit.y * 16.; return vec3(uv8bit, fractions) / 255.; } `,XB=`#version 300 es #define SHADER_NAME bitmap-layer-fragment-shader #ifdef GL_ES precision highp float; #endif uniform sampler2D bitmapTexture; in vec2 vTexCoord; in vec2 vTexPos; out vec4 fragColor; /* projection utils */ const float TILE_SIZE = 512.0; const float PI = 3.1415926536; const float WORLD_SCALE = TILE_SIZE / PI / 2.0; // from degrees to Web Mercator vec2 lnglat_to_mercator(vec2 lnglat) { float x = lnglat.x; float y = clamp(lnglat.y, -89.9, 89.9); return vec2( radians(x) + PI, PI + log(tan(PI * 0.25 + radians(y) * 0.5)) ) * WORLD_SCALE; } // from Web Mercator to degrees vec2 mercator_to_lnglat(vec2 xy) { xy /= WORLD_SCALE; return degrees(vec2( xy.x - PI, atan(exp(xy.y - PI)) * 2.0 - PI * 0.5 )); } /* End projection utils */ // apply desaturation vec3 color_desaturate(vec3 color) { float luminance = (color.r + color.g + color.b) * 0.333333333; return mix(color, vec3(luminance), bitmap.desaturate); } // apply tint vec3 color_tint(vec3 color) { return color * bitmap.tintColor; } // blend with background color vec4 apply_opacity(vec3 color, float alpha) { if (bitmap.transparentColor.a == 0.0) { return vec4(color, alpha); } float blendedAlpha = alpha + bitmap.transparentColor.a * (1.0 - alpha); float highLightRatio = alpha / blendedAlpha; vec3 blendedRGB = mix(bitmap.transparentColor.rgb, color, highLightRatio); return vec4(blendedRGB, blendedAlpha); } vec2 getUV(vec2 pos) { return vec2( (pos.x - bitmap.bounds[0]) / (bitmap.bounds[2] - bitmap.bounds[0]), (pos.y - bitmap.bounds[3]) / (bitmap.bounds[1] - bitmap.bounds[3]) ); } ${fQ} void main(void) { vec2 uv = vTexCoord; if (bitmap.coordinateConversion < -0.5) { vec2 lnglat = mercator_to_lnglat(vTexPos); uv = getUV(lnglat); } else if (bitmap.coordinateConversion > 0.5) { vec2 commonPos = lnglat_to_mercator(vTexPos); uv = getUV(commonPos); } vec4 bitmapColor = texture(bitmapTexture, uv); fragColor = apply_opacity(color_tint(color_desaturate(bitmapColor.rgb)), bitmapColor.a * layer.opacity); geometry.uv = uv; DECKGL_FILTER_COLOR(fragColor, geometry); if (bool(picking.isActive) && !bool(picking.isAttribute)) { // Since instance information is not used, we can use picking color for pixel index fragColor.rgb = packUVsIntoRGB(uv); } } `;var uQ={image:{type:"image",value:null,async:!0},bounds:{type:"array",value:[1,0,0,1],compare:!0},_imageCoordinateSystem:"default",desaturate:{type:"number",min:0,max:1,value:0},transparentColor:{type:"color",value:[0,0,0,0]},tintColor:{type:"color",value:[255,255,255]},textureParameters:{type:"object",ignore:!0,value:null}},Hu=class extends _e{getShaders(){return super.getShaders({vs:$B,fs:XB,modules:[fe,Se,GB]})}initializeState(){let e=this.getAttributeManager();e.remove(["instancePickingColors"]);let r=!0;e.add({indices:{size:1,isIndexed:!0,update:o=>o.value=this.state.mesh.indices,noAlloc:r},positions:{size:3,type:"float64",fp64:this.use64bitPositions(),update:o=>o.value=this.state.mesh.positions,noAlloc:r},texCoords:{size:2,update:o=>o.value=this.state.mesh.texCoords,noAlloc:r}})}updateState({props:e,oldProps:r,changeFlags:o}){let n=this.getAttributeManager();if(o.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),n.invalidateAll()),e.bounds!==r.bounds){let i=this.state.mesh,s=this._createMesh();this.state.model.setVertexCount(s.vertexCount);for(let a in s)i&&i[a]!==s[a]&&n.invalidate(a);this.setState({mesh:s,...this._getCoordinateUniforms()})}else e._imageCoordinateSystem!==r._imageCoordinateSystem&&this.setState(this._getCoordinateUniforms())}getPickingInfo(e){let{image:r}=this.props,o=e.info;if(!o.color||!r)return o.bitmap=null,o;let{width:n,height:i}=r;o.index=0;let s=dQ(o.color);return o.bitmap={size:{width:n,height:i},uv:s,pixel:[Math.floor(s[0]*n),Math.floor(s[1]*i)]},o}disablePickingIndex(){this.setState({disablePicking:!0})}restorePickingColors(){this.setState({disablePicking:!1})}_updateAutoHighlight(e){super._updateAutoHighlight({...e,color:this.encodePickingColor(0)})}_createMesh(){let{bounds:e}=this.props,r=e;return YB(e)&&(r=[[e[0],e[1]],[e[0],e[3]],[e[2],e[3]],[e[2],e[1]]]),H1(r,this.context.viewport.resolution)}_getModel(){return new Q(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),topology:"triangle-list",isInstanced:!1})}draw(e){let{shaderModuleProps:r}=e,{model:o,coordinateConversion:n,bounds:i,disablePicking:s}=this.state,{image:a,desaturate:c,transparentColor:l,tintColor:f}=this.props;if(!(r.picking.isActive&&s)&&a&&o){let u={bitmapTexture:a,bounds:i,coordinateConversion:n,desaturate:c,tintColor:f.slice(0,3).map(d=>d/255),transparentColor:l.map(d=>d/255)};o.shaderInputs.setProps({bitmap:u}),o.draw(this.context.renderPass)}}_getCoordinateUniforms(){let{_imageCoordinateSystem:e}=this.props;if(e!=="default"){let{bounds:r}=this.props;if(!YB(r))throw new Error("_imageCoordinateSystem only supports rectangular bounds");let o=this.context.viewport.resolution?"lnglat":"cartesian";if(e=e==="lnglat"?"lnglat":"cartesian",e==="lnglat"&&o==="cartesian")return{coordinateConversion:-1,bounds:r};if(e==="cartesian"&&o==="lnglat"){let n=Oe([r[0],r[1]]),i=Oe([r[2],r[3]]);return{coordinateConversion:1,bounds:[n[0],n[1],i[0],i[1]]}}}return{coordinateConversion:0,bounds:[0,0,0,0]}}};Hu.layerName="BitmapLayer";Hu.defaultProps=uQ;var H_=Hu;function dQ(t){let[e,r,o]=t,n=(o&240)/256,i=(o&15)/16;return[(e+i)/256,(r+n)/256]}function YB(t){return Number.isFinite(t[0])}var KB=`layout(std140) uniform iconUniforms { float sizeScale; vec2 iconsTextureDim; float sizeBasis; float sizeMinPixels; float sizeMaxPixels; bool billboard; highp int sizeUnits; float alphaCutoff; } icon; `,qB={name:"icon",vs:KB,fs:KB,uniformTypes:{sizeScale:"f32",iconsTextureDim:"vec2<f32>",sizeBasis:"f32",sizeMinPixels:"f32",sizeMaxPixels:"f32",billboard:"f32",sizeUnits:"i32",alphaCutoff:"f32"}};var ZB=`#version 300 es #define SHADER_NAME icon-layer-vertex-shader in vec2 positions; in vec3 instancePositions; in vec3 instancePositions64Low; in float instanceSizes; in float instanceAngles; in vec4 instanceColors; in vec3 instancePickingColors; in vec4 instanceIconFrames; in float instanceColorModes; in vec2 instanceOffsets; in vec2 instancePixelOffset; out float vColorMode; out vec4 vColor; out vec2 vTextureCoords; out vec2 uv; vec2 rotate_by_angle(vec2 vertex, float angle) { float angle_radian = angle * PI / 180.0; float cos_angle = cos(angle_radian); float sin_angle = sin(angle_radian); mat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle); return rotationMatrix * vertex; } void main(void) { geometry.worldPosition = instancePositions; geometry.uv = positions; geometry.pickingColor = instancePickingColors; uv = positions; vec2 iconSize = instanceIconFrames.zw; float sizePixels = clamp( project_size_to_pixel(instanceSizes * icon.sizeScale, icon.sizeUnits), icon.sizeMinPixels, icon.sizeMaxPixels ); float iconConstraint = icon.sizeBasis == 0.0 ? iconSize.x : iconSize.y; float instanceScale = iconConstraint == 0.0 ? 0.0 : sizePixels / iconConstraint; vec2 pixelOffset = positions / 2.0 * iconSize + instanceOffsets; pixelOffset = rotate_by_angle(pixelOffset, instanceAngles) * instanceScale; pixelOffset += instancePixelOffset; pixelOffset.y *= -1.0; if (icon.billboard) { gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position); DECKGL_FILTER_GL_POSITION(gl_Position, geometry); vec3 offset = vec3(pixelOffset, 0.0); DECKGL_FILTER_SIZE(offset, geometry); gl_Position.xy += project_pixel_size_to_clipspace(offset.xy); } else { vec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0); DECKGL_FILTER_SIZE(offset_common, geometry); gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position); DECKGL_FILTER_GL_POSITION(gl_Position, geometry); } vTextureCoords = mix( instanceIconFrames.xy, instanceIconFrames.xy + iconSize, (positions.xy + 1.0) / 2.0 ) / icon.iconsTextureDim; vColor = instanceColors; DECKGL_FILTER_COLOR(vColor, geometry); vColorMode = instanceColorModes; } `;var JB=`#version 300 es #define SHADER_NAME icon-layer-fragment-shader precision highp float; uniform sampler2D iconsTexture; in float vColorMode; in vec4 vColor; in vec2 vTextureCoords; in vec2 uv; out vec4 fragColor; void main(void) { geometry.uv = uv; vec4 texColor = texture(iconsTexture, vTextureCoords); vec3 color = mix(texColor.rgb, vColor.rgb, vColorMode); float a = texColor.a * layer.opacity * vColor.a; if (a < icon.alphaCutoff) { discard; } fragColor = vec4(color, a); DECKGL_FILTER_COLOR(fragColor, geometry); } `;var QB=`struct IconUniforms { sizeScale: f32, iconsTextureDim: vec2<f32>, sizeBasis: f32, sizeMinPixels: f32, sizeMaxPixels: f32, billboard: i32, sizeUnits: i32, alphaCutoff: f32 }; @group(0) @binding(auto) var<uniform> icon: IconUniforms; @group(0) @binding(auto) var iconsTexture : texture_2d<f32>; @group(0) @binding(auto) var iconsTextureSampler : sampler; fn rotate_by_angle(vertex: vec2<f32>, angle_deg: f32) -> vec2<f32> { let angle_radian = angle_deg * PI / 180.0; let c = cos(angle_radian); let s = sin(angle_radian); let rotation = mat2x2<f32>(vec2<f32>(c, s), vec2<f32>(-s, c)); return rotation * vertex; } struct Attributes { @location(0) positions: vec2<f32>, @location(1) instancePositions: vec3<f32>, @location(2) instancePositions64Low: vec3<f32>, @location(3) instanceSizes: f32, @location(4) instanceAngles: f32, @location(5) instanceColors: vec4<f32>, @location(6) instancePickingColors: vec3<f32>, @location(7) instanceIconFrames: vec4<f32>, @location(8) instanceColorModes: f32, @location(9) instanceOffsets: vec2<f32>, @location(10) instancePixelOffset: vec2<f32>, }; struct Varyings { @builtin(position) position: vec4<f32>, @location(0) vColorMode: f32, @location(1) vColor: vec4<f32>, @location(2) vTextureCoords: vec2<f32>, @location(3) uv: vec2<f32>, @location(4) pickingColor: vec3<f32>, }; @vertex fn vertexMain(inp: Attributes) -> Varyings { // write geometry fields used by filters + FS geometry.worldPosition = inp.instancePositions; geometry.uv = inp.positions; geometry.pickingColor = inp.instancePickingColors; var outp: Varyings; outp.uv = inp.positions; let iconSize = inp.instanceIconFrames.zw; // convert size in meters to pixels, then clamp let sizePixels = clamp( project_unit_size_to_pixel(inp.instanceSizes * icon.sizeScale, icon.sizeUnits), icon.sizeMinPixels, icon.sizeMaxPixels ); // scale icon height to match instanceSize let iconConstraint = select(iconSize.y, iconSize.x, icon.sizeBasis == 0.0); let instanceScale = select(sizePixels / iconConstraint, 0.0, iconConstraint == 0.0); // scale and rotate vertex in "pixel" units; then add per-instance pixel offset var pixelOffset = inp.positions / 2.0 * iconSize + inp.instanceOffsets; pixelOffset = rotate_by_angle(pixelOffset, inp.instanceAngles) * instanceScale; pixelOffset = pixelOffset + inp.instancePixelOffset; pixelOffset.y = pixelOffset.y * -1.0; if (icon.billboard != 0) { var pos = project_position_to_clipspace(inp.instancePositions, inp.instancePositions64Low, vec3<f32>(0.0)); // TODO, &geometry.position); // DECKGL_FILTER_GL_POSITION(pos, geometry); var offset = vec3<f32>(pixelOffset, 0.0); // DECKGL_FILTER_SIZE(offset, geometry); let clipOffset = project_pixel_size_to_clipspace(offset.xy); pos = vec4<f32>(pos.x + clipOffset.x, pos.y + clipOffset.y, pos.z, pos.w); outp.position = pos; } else { var offset_common = vec3<f32>(project_pixel_size_vec2(pixelOffset), 0.0); // DECKGL_FILTER_SIZE(offset_common, geometry); var pos = project_position_to_clipspace(inp.instancePositions, inp.instancePositions64Low, offset_common); // TODO, &geometry.position); // DECKGL_FILTER_GL_POSITION(pos, geometry); outp.position = pos; } let uvMix = (inp.positions.xy + vec2<f32>(1.0, 1.0)) * 0.5; outp.vTextureCoords = mix(inp.instanceIconFrames.xy, inp.instanceIconFrames.xy + iconSize, uvMix) / icon.iconsTextureDim; outp.vColor = inp.instanceColors; // DECKGL_FILTER_COLOR(outp.vColor, geometry); outp.vColorMode = inp.instanceColorModes; outp.pickingColor = inp.instancePickingColors; return outp; } @fragment fn fragmentMain(inp: Varyings) -> @location(0) vec4<f32> { // expose to deck.gl filter hooks geometry.uv = inp.uv; let texColor = textureSample(iconsTexture, iconsTextureSampler, inp.vTextureCoords); // if colorMode == 0, use pixel color from the texture // if colorMode == 1 (or picking), use texture as transparency mask let rgb = mix(texColor.rgb, inp.vColor.rgb, inp.vColorMode); let a = texColor.a * layer.opacity * inp.vColor.a; if (a < icon.alphaCutoff) { discard; } if (picking.isActive > 0.5) { if (!picking_isColorValid(inp.pickingColor)) { discard; } return vec4<f32>(inp.pickingColor, 1.0); } var fragColor = deckgl_premultiplied_alpha(vec4<f32>(rgb, a)); if (picking.isHighlightActive > 0.5) { let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor); if (picking_isColorZero(abs(inp.pickingColor - highlightedObjectColor))) { let highLightAlpha = picking.highlightColor.a; let blendedAlpha = highLightAlpha + fragColor.a * (1.0 - highLightAlpha); if (blendedAlpha > 0.0) { let highLightRatio = highLightAlpha / blendedAlpha; fragColor = vec4<f32>( mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio), blendedAlpha ); } else { fragColor = vec4<f32>(fragColor.rgb, 0.0); } } } return fragColor; } `;function j_(t,e){if(!t)throw new Error(e||"loader assertion failed.")}var Vo={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},hQ=Vo.self||Vo.window||Vo.global||{},pQ=Vo.window||Vo.self||Vo.global||{},mQ=Vo.global||Vo.self||Vo.window||{},gQ=Vo.document||{};var ju=Boolean(typeof process!="object"||String(process)!=="[object process]"||process.browser);var eO=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),_Q=eO&&parseFloat(eO[1])||0;zn();var j1="4.4.1",yQ=j1[0]>="0"&&j1[0]<="9"?`v${j1}`:"";function xQ(){let t=new ct({id:"loaders.gl"});return globalThis.loaders||={},globalThis.loaders.log=t,globalThis.loaders.version=yQ,globalThis.probe||={},globalThis.probe.loaders=t,t}var W1=xQ();var bQ=t=>typeof t=="boolean",zo=t=>typeof t=="function",Ho=t=>t!==null&&typeof t=="object",W_=t=>Ho(t)&&t.constructor==={}.constructor;var G1=t=>typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer,Tc=t=>Ho(t)&&typeof t.byteLength=="number"&&typeof t.slice=="function";var $1=t=>Boolean(t)&&zo(t[Symbol.iterator]),X1=t=>Boolean(t)&&zo(t[Symbol.asyncIterator]);var mr=t=>typeof Response<"u"&&t instanceof Response||Ho(t)&&zo(t.arrayBuffer)&&zo(t.text)&&zo(t.json);var gr=t=>typeof Blob<"u"&&t instanceof Blob;var tO=t=>typeof ReadableStream<"u"&&t instanceof ReadableStream||Ho(t)&&zo(t.tee)&&zo(t.cancel)&&zo(t.getReader);var rO=t=>Ho(t)&&zo(t.read)&&zo(t.pipe)&&bQ(t.readable),Wu=t=>tO(t)||rO(t);function Y1(t,e){return oO(t||{},e)}function oO(t,e,r=0){if(r>3)return e;let o={...t};for(let[n,i]of Object.entries(e))i&&typeof i=="object"&&!Array.isArray(i)?o[n]=oO(o[n]||{},e[n],r+1):o[n]=e[n];return o}var nO="latest";function AQ(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.4.1"),globalThis._loadersgl_.version}var iO=AQ();function Ht(t,e){if(!t)throw new Error(e||"loaders.gl assertion failed.")}var jo={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},YVe=jo.self||jo.window||jo.global||{},KVe=jo.window||jo.self||jo.global||{},qVe=jo.global||jo.self||jo.window||{},ZVe=jo.document||{};var Br=typeof process!="object"||String(process)!=="[object process]"||process.browser;var aO=typeof window<"u"&&typeof window.orientation<"u",sO=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),JVe=sO&&parseFloat(sO[1])||0;var Gu=class{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(e,r){this.name=e,this.workerThread=r,this.result=new Promise((o,n)=>{this._resolve=o,this._reject=n})}postMessage(e,r){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:r})}done(e){Ht(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){Ht(this.isRunning),this.isRunning=!1,this._reject(e)}};var vc=class{terminate(){}};var K1=new Map;function cO(t){Ht(t.source&&!t.url||!t.source&&t.url);let e=K1.get(t.source||t.url);return e||(t.url&&(e=TQ(t.url),K1.set(t.url,e)),t.source&&(e=lO(t.source),K1.set(t.source,e))),Ht(e),e}function TQ(t){if(!t.startsWith("http"))return t;let e=vQ(t);return lO(e)}function lO(t){let e=new Blob([t],{type:"application/javascript"});return URL.createObjectURL(e)}function vQ(t){return`try { importScripts('${t}'); } catch (error) { console.error(error); throw error; }`}function q1(t,e=!0,r){let o=r||new Set;if(t){if(fO(t))o.add(t);else if(fO(t.buffer))o.add(t.buffer);else if(!ArrayBuffer.isView(t)){if(e&&typeof t=="object")for(let n in t)q1(t[n],e,o)}}return r===void 0?Array.from(o):[]}function fO(t){return t?t instanceof ArrayBuffer||typeof MessagePort<"u"&&t instanceof MessagePort||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas:!1}var Z1=()=>{},gi=class{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return typeof Worker<"u"&&Br||typeof vc<"u"&&!Br}constructor(e){let{name:r,source:o,url:n}=e;Ht(o||n),this.name=r,this.source=o,this.url=n,this.onMessage=Z1,this.onError=i=>console.log(i),this.worker=Br?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=Z1,this.onError=Z1,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(e,r){r=r||q1(e),this.worker.postMessage(e,r)}_getErrorFromErrorEvent(e){let r="Failed to load ";return r+=`worker ${this.name} from ${this.url}. `,e.message&&(r+=`${e.message} in `),e.lineno&&(r+=`:${e.lineno}:${e.colno}`),new Error(r)}_createBrowserWorker(){this._loadableURL=cO({source:this.source,url:this.url});let e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=r=>{r.data?this.onMessage(r.data):this.onError(new Error("No data received"))},e.onerror=r=>{this.onError(this._getErrorFromErrorEvent(r)),this.terminated=!0},e.onmessageerror=r=>console.error(r),e}_createNodeWorker(){let e;if(this.url){let o=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`,n=this.url.endsWith(".ts")||this.url.endsWith(".mjs")?"module":"commonjs";e=new vc(o,{eval:!1,type:n})}else if(this.source)e=new vc(this.source,{eval:!0});else throw new Error("no worker");return e.on("message",r=>{this.onMessage(r)}),e.on("error",r=>{this.onError(r)}),e.on("exit",r=>{}),e}};var $u=class{name="unnamed";source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return gi.isSupported()}constructor(e){this.source=e.source,this.url=e.url,this.setProps(e)}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},e.name!==void 0&&(this.name=e.name),e.maxConcurrency!==void 0&&(this.maxConcurrency=e.maxConcurrency),e.maxMobileConcurrency!==void 0&&(this.maxMobileConcurrency=e.maxMobileConcurrency),e.reuseWorkers!==void 0&&(this.reuseWorkers=e.reuseWorkers),e.onDebug!==void 0&&(this.onDebug=e.onDebug)}async startJob(e,r=(n,i,s)=>n.done(s),o=(n,i)=>n.error(i)){let n=new Promise(i=>(this.jobQueue.push({name:e,onMessage:r,onError:o,onStart:i}),this));return this._startQueuedJob(),await n}async _startQueuedJob(){if(!this.jobQueue.length)return;let e=this._getAvailableWorker();if(!e)return;let r=this.jobQueue.shift();if(r){this.onDebug({message:"Starting job",name:r.name,workerThread:e,backlog:this.jobQueue.length});let o=new Gu(r.name,e);e.onMessage=n=>r.onMessage(o,n.type,n.payload),e.onError=n=>r.onError(o,n),r.onStart(o);try{await o.result}catch(n){console.error(`Worker exception: ${n}`)}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){!Br||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count<this._getMaxConcurrency()){this.count++;let e=`${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;return new gi({name:e,source:this.source,url:this.url})}return null}_getMaxConcurrency(){return aO?this.maxMobileConcurrency:this.maxConcurrency}};var SQ={maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:!0,onDebug:()=>{}},Ps=class{props;workerPools=new Map;static isSupported(){return gi.isSupported()}static getWorkerFarm(e={}){return Ps._workerFarm=Ps._workerFarm||new Ps({}),Ps._workerFarm.setProps(e),Ps._workerFarm}constructor(e){this.props={...SQ},this.setProps(e),this.workerPools=new Map}destroy(){for(let e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(let r of this.workerPools.values())r.setProps(this._getWorkerPoolProps())}getWorkerPool(e){let{name:r,source:o,url:n}=e,i=this.workerPools.get(r);return i||(i=new $u({name:r,source:o,url:n}),i.setProps(this._getWorkerPoolProps()),this.workerPools.set(r,i)),i}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}},_i=Ps;k(_i,"_workerFarm");function J1(t,e={}){let r=e[t.id]||{},o=Br?`${t.id}-worker.js`:`${t.id}-worker-node.js`,n=r.workerUrl;if(!n&&t.id==="compression"&&(n=e.workerUrl),(e._workerType||e?.core?._workerType)==="test"&&(Br?n=`modules/${t.module}/dist/${o}`:n=`modules/${t.module}/src/workers/${t.id}-worker-node.ts`),!n){let s=t.version;s==="latest"&&(s=nO);let a=s?`@${s}`:"";n=`https://unpkg.com/@loaders.gl/${t.module}${a}/dist/${o}`}return Ht(n),n}function Q1(t,e=iO){Ht(t,"no worker provided");let r=t.version;return!(!e||!r)}function eS(t,e){if(!_i.isSupported())return!1;let r=e?._nodeWorkers??e?.core?._nodeWorkers;if(!Br&&!r)return!1;let o=e?.worker??e?.core?.worker;return Boolean(t.worker&&o)}async function tS(t,e,r,o,n){let i=t.id,s=J1(t,r),c=_i.getWorkerFarm(r?.core).getWorkerPool({name:i,url:s});r=JSON.parse(JSON.stringify(r)),o=JSON.parse(JSON.stringify(o||{}));let l=await c.startJob("process-on-worker",CQ.bind(null,n));return l.postMessage("process",{input:e,options:r,context:o}),await(await l.result).result}async function CQ(t,e,r,o){switch(r){case"done":e.done(o);break;case"error":e.error(new Error(o.error));break;case"process":let{id:n,input:i,options:s}=o;try{let a=await t(i,s);e.postMessage("done",{id:n,result:a})}catch(a){let c=a instanceof Error?a.message:"unknown error";e.postMessage("error",{id:n,error:c})}break;default:console.warn(`parse-with-worker unknown message ${r}`)}}function rS(t,e,r){if(r=r||t.byteLength,t.byteLength<r||e.byteLength<r)return!1;let o=new Uint8Array(t),n=new Uint8Array(e);for(let i=0;i<o.length;++i)if(o[i]!==n[i])return!1;return!0}function oS(...t){return uO(t)}function uO(t){let e=t.map(i=>i instanceof ArrayBuffer?new Uint8Array(i):i),r=e.reduce((i,s)=>i+s.byteLength,0),o=new Uint8Array(r),n=0;for(let i of e)o.set(i,n),n+=i.byteLength;return o.buffer}async function nS(t){let e=[];for await(let r of t)e.push(EQ(r));return oS(...e)}function EQ(t){if(t instanceof ArrayBuffer)return t;if(ArrayBuffer.isView(t)){let{buffer:e,byteOffset:r,byteLength:o}=t;return dO(e,r,o)}return dO(t)}function dO(t,e=0,r=t.byteLength-e){let o=new Uint8Array(t,e,r),n=new Uint8Array(o.length);return n.set(o),n.buffer}var wQ="",hO={};function iS(t){for(let e in hO)if(t.startsWith(e)){let r=hO[e];t=t.replace(e,r)}return!t.startsWith("http://")&&!t.startsWith("https://")&&(t=`${wQ}${t}`),t}function $_(t){return t&&typeof t=="object"&&t.isBuffer}function Sc(t){if($_(t))return t;if(t instanceof ArrayBuffer)return t;if(G1(t))return G_(t);if(ArrayBuffer.isView(t)){let e=t.buffer;return t.byteOffset===0&&t.byteLength===t.buffer.byteLength?e:e.slice(t.byteOffset,t.byteOffset+t.byteLength)}if(typeof t=="string"){let e=t;return new TextEncoder().encode(e).buffer}if(t&&typeof t=="object"&&t._toArrayBuffer)return t._toArrayBuffer();throw new Error("toArrayBuffer")}function Xu(t){if(t instanceof ArrayBuffer)return t;if(G1(t))return G_(t);let{buffer:e,byteOffset:r,byteLength:o}=t;return e instanceof ArrayBuffer&&r===0&&o===e.byteLength?e:G_(e,r,o)}function G_(t,e=0,r=t.byteLength-e){let o=new Uint8Array(t,e,r),n=new Uint8Array(o.length);return n.set(o),n.buffer}function sS(t){return ArrayBuffer.isView(t)?t:new Uint8Array(t)}var Sn={};ze(Sn,{dirname:()=>MQ,filename:()=>PQ,join:()=>RQ,resolve:()=>IQ});function pO(){if(typeof process<"u"&&typeof process.cwd<"u")return process.cwd();let t=window.location?.pathname;return t?.slice(0,t.lastIndexOf("/")+1)||""}function PQ(t){let e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(e+1):t}function MQ(t){let e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(0,e):""}function RQ(...t){let e="/";return t=t.map((r,o)=>(o&&(r=r.replace(new RegExp(`^${e}`),"")),o!==t.length-1&&(r=r.replace(new RegExp(`${e}$`),"")),r)),t.join(e)}function IQ(...t){let e=[];for(let i=0;i<t.length;i++)e[i]=t[i];let r="",o=!1,n;for(let i=e.length-1;i>=-1&&!o;i--){let s;i>=0?s=e[i]:(n===void 0&&(n=pO()),s=n),s.length!==0&&(r=`${s}/${r}`,o=s.charCodeAt(0)===Yu)}return r=LQ(r,!o),o?`/${r}`:r.length>0?r:"."}var Yu=47,aS=46;function LQ(t,e){let r="",o=-1,n=0,i,s=!1;for(let a=0;a<=t.length;++a){if(a<t.length)i=t.charCodeAt(a);else{if(i===Yu)break;i=Yu}if(i===Yu){if(!(o===a-1||n===1))if(o!==a-1&&n===2){if(r.length<2||!s||r.charCodeAt(r.length-1)!==aS||r.charCodeAt(r.length-2)!==aS){if(r.length>2){let c=r.length-1,l=c;for(;l>=0&&r.charCodeAt(l)!==Yu;--l);if(l!==c){r=l===-1?"":r.slice(0,l),o=a,n=0,s=!1;continue}}else if(r.length===2||r.length===1){r="",o=a,n=0,s=!1;continue}}e&&(r.length>0?r+="/..":r="..",s=!0)}else{let c=t.slice(o+1,a);r.length>0?r+=`/${c}`:r=c,s=!1}o=a,n=0}else i===aS&&n!==-1?++n:n=-1}return r}var X_=class extends Error{constructor(e,r){super(e),this.reason=r.reason,this.url=r.url,this.response=r.response}reason;url;response};var FQ=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,NQ=/^([-\w.]+\/[-\w.+]+)/;function cS(t,e){return t.toLowerCase()===e.toLowerCase()}function mO(t){let e=NQ.exec(t);return e?e[1]:t}function lS(t){let e=FQ.exec(t);return e?e[1]:""}var gO=/\?.*/;function _O(t){let e=t.match(gO);return e&&e[0]}function yi(t){return t.replace(gO,"")}function yO(t){if(t.length<50)return t;let e=t.slice(t.length-15);return`${t.substr(0,32)}...${e}`}function Ms(t){return mr(t)?t.url:gr(t)?("name"in t?t.name:"")||"":typeof t=="string"?t:""}function Cc(t){if(mr(t)){let e=t.headers.get("content-type")||"",r=yi(t.url);return mO(e)||lS(r)}return gr(t)?t.type||"":typeof t=="string"?lS(t):""}function xO(t){return mr(t)?t.headers["content-length"]||-1:gr(t)?t.size:typeof t=="string"?t.length:t instanceof ArrayBuffer||ArrayBuffer.isView(t)?t.byteLength:-1}async function Y_(t){if(mr(t))return t;let e={},r=xO(t);r>=0&&(e["content-length"]=String(r));let o=Ms(t),n=Cc(t);n&&(e["content-type"]=n);let i=await UQ(t);i&&(e["x-first-bytes"]=i),typeof t=="string"&&(t=new TextEncoder().encode(t));let s=new Response(t,{headers:e});return Object.defineProperty(s,"url",{value:o}),s}async function bO(t){if(!t.ok)throw await DQ(t)}async function DQ(t){let e=yO(t.url),r=`Failed to fetch resource (${t.status}) ${t.statusText}: ${e}`;r=r.length>100?`${r.slice(0,100)}...`:r;let o={reason:t.statusText,url:t.url,response:t};try{let n=t.headers.get("Content-Type");o.reason=!t.bodyUsed&&n?.includes("application/json")?await t.json():await t.text()}catch{}return new X_(r,o)}async function UQ(t){if(typeof t=="string")return`data:,${t.slice(0,5)}`;if(t instanceof Blob){let r=t.slice(0,5);return await new Promise(o=>{let n=new FileReader;n.onload=i=>o(i?.target?.result),n.readAsDataURL(r)})}if(t instanceof ArrayBuffer){let r=t.slice(0,5);return`data:base64,${kQ(r)}`}return null}function kQ(t){let e="",r=new Uint8Array(t);for(let o=0;o<r.byteLength;o++)e+=String.fromCharCode(r[o]);return btoa(e)}function VQ(t){return!zQ(t)&&!HQ(t)}function zQ(t){return t.startsWith("http:")||t.startsWith("https:")}function HQ(t){return t.startsWith("data:")}async function fS(t,e){if(typeof t=="string"){let r=iS(t);return VQ(r)&&globalThis.loaders?.fetchNode?globalThis.loaders?.fetchNode(r,e):await fetch(r,e)}return await Y_(t)}zn();var Ku=new ct({id:"loaders.gl"}),K_=class{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}},q_=class{console;constructor(){this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}};var Z_={core:{baseUrl:void 0,fetch:null,mimeType:void 0,fallbackMimeType:void 0,ignoreRegisteredLoaders:void 0,nothrow:!1,log:new q_,useLocalLibraries:!1,CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:ju,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]}},AO={baseUri:"core.baseUrl",fetch:"core.fetch",mimeType:"core.mimeType",fallbackMimeType:"core.fallbackMimeType",ignoreRegisteredLoaders:"core.ignoreRegisteredLoaders",nothrow:"core.nothrow",log:"core.log",useLocalLibraries:"core.useLocalLibraries",CDN:"core.CDN",worker:"core.worker",maxConcurrency:"core.maxConcurrency",maxMobileConcurrency:"core.maxMobileConcurrency",reuseWorkers:"core.reuseWorkers",_nodeWorkers:"core.nodeWorkers",_workerType:"core._workerType",_worker:"core._workerType",limit:"core.limit",_limitMB:"core._limitMB",batchSize:"core.batchSize",batchDebounceMs:"core.batchDebounceMs",metadata:"core.metadata",transforms:"core.transforms",throws:"nothrow",dataType:"(no longer used)",uri:"core.baseUrl",method:"core.fetch.method",headers:"core.fetch.headers",body:"core.fetch.body",mode:"core.fetch.mode",credentials:"core.fetch.credentials",cache:"core.fetch.cache",redirect:"core.fetch.redirect",referrer:"core.fetch.referrer",referrerPolicy:"core.fetch.referrerPolicy",integrity:"core.fetch.integrity",keepalive:"core.fetch.keepalive",signal:"core.fetch.signal"};var uS=["baseUrl","fetch","mimeType","fallbackMimeType","ignoreRegisteredLoaders","nothrow","log","useLocalLibraries","CDN","worker","maxConcurrency","maxMobileConcurrency","reuseWorkers","_nodeWorkers","_workerType","limit","_limitMB","batchSize","batchDebounceMs","metadata","transforms"];function dS(){globalThis.loaders=globalThis.loaders||{};let{loaders:t}=globalThis;return t._state||(t._state={}),t._state}function hS(){let t=dS();return t.globalOptions=t.globalOptions||{...Z_,core:{...Z_.core}},Cn(t.globalOptions)}function SO(t,e,r,o){return r=r||[],r=Array.isArray(r)?r:[r],jQ(t,r),Cn(GQ(e,t,o))}function Cn(t){let e=XQ(t);CO(e);for(let r of uS)e.core&&e.core[r]!==void 0&&delete e[r];return e.core&&e.core._workerType!==void 0&&delete e._worker,e}function jQ(t,e){TO(t,null,Z_,AO,e);for(let r of e){let o=t&&t[r.id]||{},n=r.options&&r.options[r.id]||{},i=r.deprecatedOptions&&r.deprecatedOptions[r.id]||{};TO(o,r.id,n,i,e)}}function TO(t,e,r,o,n){let i=e||"Top level",s=e?`${e}.`:"";for(let a in t){let c=!e&&Ho(t[a]),l=a==="baseUri"&&!e,f=a==="workerUrl"&&e;if(!(a in r)&&!l&&!f){if(a in o)Ku.level>0&&Ku.warn(`${i} loader option '${s}${a}' no longer supported, use '${o[a]}'`)();else if(!c&&Ku.level>0){let u=WQ(a,n);Ku.warn(`${i} loader option '${s}${a}' not recognized. ${u}`)()}}}}function WQ(t,e){let r=t.toLowerCase(),o="";for(let n of e)for(let i in n.options){if(t===i)return`Did you mean '${n.id}.${i}'?`;let s=i.toLowerCase();(r.startsWith(s)||s.startsWith(r))&&(o=o||`Did you mean '${n.id}.${i}'?`)}return o}function GQ(t,e,r){let o=t.options||{},n={...o};o.core&&(n.core={...o.core}),CO(n),n.core?.log===null&&(n.core={...n.core,log:new K_}),vO(n,Cn(hS()));let i=Cn(e);return vO(n,i),$Q(n,r),YQ(n),n}function vO(t,e){for(let r in e)if(r in e){let o=e[r];W_(o)&&W_(t[r])?t[r]={...t[r],...e[r]}:t[r]=e[r]}}function $Q(t,e){if(!e)return;t.core?.baseUrl!==void 0||(t.core||={},t.core.baseUrl=Sn.dirname(yi(e)))}function XQ(t){let e={...t};return t.core&&(e.core={...t.core}),e}function CO(t){t.baseUri!==void 0&&(t.core||={},t.core.baseUrl===void 0&&(t.core.baseUrl=t.baseUri));for(let r of uS)if(t[r]!==void 0){let n=t.core=t.core||{};n[r]===void 0&&(n[r]=t[r])}let e=t._worker;e!==void 0&&(t.core||={},t.core._workerType===void 0&&(t.core._workerType=e))}function YQ(t){let e=t.core;if(e)for(let r of uS)e[r]!==void 0&&(t[r]=e[r])}function qu(t){return t?(Array.isArray(t)&&(t=t[0]),Array.isArray(t?.extensions)):!1}function pS(t){j_(t,"null loader"),j_(qu(t),"invalid loader");let e;return Array.isArray(t)&&(e=t[1],t=t[0],t={...t,options:{...t.options,...e}}),(t?.parseTextSync||t?.parseText)&&(t.text=!0),t.text||(t.binary=!0),t}var KQ=()=>{let t=dS();return t.loaderRegistry=t.loaderRegistry||[],t.loaderRegistry};function EO(){return KQ()}var qQ=/\.([^.]+)$/;async function MO(t,e=[],r,o){if(!RO(t))return null;let n=Cn(r||{});if(n.core||={},t instanceof Response&&wO(t)){let s=await t.clone().text(),a=J_(s,e,{...n,core:{...n.core,nothrow:!0}},o);if(a)return a}let i=J_(t,e,{...n,core:{...n.core,nothrow:!0}},o);if(i)return i;if(gr(t)&&(t=await t.slice(0,10).arrayBuffer(),i=J_(t,e,n,o)),!i&&t instanceof Response&&wO(t)){let s=await t.clone().text();i=J_(s,e,n,o)}if(!i&&!n.core.nothrow)throw new Error(IO(t));return i}function wO(t){let e=Cc(t);return Boolean(e&&(e.startsWith("text/")||e==="application/json"||e.endsWith("+json")))}function J_(t,e=[],r,o){if(!RO(t))return null;let n=Cn(r||{});if(n.core||={},e&&!Array.isArray(e))return pS(e);let i=[];e&&(i=i.concat(e)),n.core.ignoreRegisteredLoaders||i.push(...EO()),JQ(i);let s=ZQ(t,i,n,o);if(!s&&!n.core.nothrow)throw new Error(IO(t));return s}function ZQ(t,e,r,o){let n=Ms(t),i=Cc(t),s=yi(n)||o?.url,a=null,c="";return r?.core?.mimeType&&(a=mS(e,r?.core?.mimeType),c=`match forced by supplied MIME type ${r?.core?.mimeType}`),a=a||QQ(e,s),c=c||(a?`matched url ${s}`:""),a=a||mS(e,i),c=c||(a?`matched MIME type ${i}`:""),a=a||tee(e,t),c=c||(a?`matched initial data ${LO(t)}`:""),r?.core?.fallbackMimeType&&(a=a||mS(e,r?.core?.fallbackMimeType),c=c||(a?`matched fallback MIME type ${i}`:"")),c&&W1.log(1,`selectLoader selected ${a?.name}: ${c}.`),a}function RO(t){return!(t instanceof Response&&t.status===204)}function IO(t){let e=Ms(t),r=Cc(t),o="No valid loader found (";o+=e?`${Sn.filename(e)}, `:"no url provided, ",o+=`MIME type: ${r?`"${r}"`:"not provided"}, `;let n=t?LO(t):"";return o+=n?` first bytes: "${n}"`:"first bytes: not available",o+=")",o}function JQ(t){for(let e of t)pS(e)}function QQ(t,e){let r=e&&qQ.exec(e),o=r&&r[1];return o?eee(t,o):null}function eee(t,e){e=e.toLowerCase();for(let r of t)for(let o of r.extensions)if(o.toLowerCase()===e)return r;return null}function mS(t,e){for(let r of t)if(r.mimeTypes?.some(o=>cS(e,o))||cS(e,`application/x.${r.id}`))return r;return null}function tee(t,e){if(!e)return null;for(let r of t)if(typeof e=="string"){if(ree(e,r))return r}else if(ArrayBuffer.isView(e)){if(PO(e.buffer,e.byteOffset,r))return r}else if(e instanceof ArrayBuffer&&PO(e,0,r))return r;return null}function ree(t,e){return e.testText?e.testText(t):(Array.isArray(e.tests)?e.tests:[e.tests]).some(o=>t.startsWith(o))}function PO(t,e,r){return(Array.isArray(r.tests)?r.tests:[r.tests]).some(n=>oee(t,e,r,n))}function oee(t,e,r,o){if(Tc(o))return rS(o,t,o.byteLength);switch(typeof o){case"function":return o(Xu(t));case"string":let n=gS(t,e,o.length);return o===n;default:return!1}}function LO(t,e=5){return typeof t=="string"?t.slice(0,e):ArrayBuffer.isView(t)?gS(t.buffer,t.byteOffset,e):t instanceof ArrayBuffer?gS(t,0,e):""}function gS(t,e,r){if(t.byteLength<e+r)return"";let o=new DataView(t),n="";for(let i=0;i<r;i++)n+=String.fromCharCode(o.getUint8(e+i));return n}var nee=256*1024;function*BO(t,e){let r=e?.chunkSize||nee,o=0,n=new TextEncoder;for(;o<t.length;){let i=Math.min(t.length-o,r),s=t.slice(o,o+i);o+=i,yield Xu(n.encode(s))}}function*OO(t,e={}){let{chunkSize:r=262144}=e,o=0;for(;o<t.byteLength;){let n=Math.min(t.byteLength-o,r),i=new ArrayBuffer(n),s=new Uint8Array(t,o,n);new Uint8Array(i).set(s),o+=n,yield i}}async function*FO(t,e){let r=e?.chunkSize||1048576,o=0;for(;o<t.size;){let n=o+r,i=await t.slice(o,n).arrayBuffer();o=n,yield i}}function _S(t,e){return ju?iee(t,e):see(t,e)}async function*iee(t,e){let r=t.getReader(),o;try{for(;;){let n=o||r.read();e?._streamReadAhead&&(o=r.read());let{done:i,value:s}=await n;if(i)return;yield Sc(s)}}catch{r.releaseLock()}}async function*see(t,e){for await(let r of t)yield Sc(r)}function NO(t,e){if(typeof t=="string")return BO(t,e);if(t instanceof ArrayBuffer)return OO(t,e);if(gr(t))return FO(t,e);if(Wu(t))return _S(t,e);if(mr(t)){let r=t.body;if(!r)throw new Error("Readable stream not available on Response");return _S(r,e)}throw new Error("makeIterator")}var DO="Cannot convert supplied data type";function aee(t,e,r){if(e.text&&typeof t=="string")return t;if($_(t)&&(t=t.buffer),Tc(t)){let o=sS(t);return e.text&&!e.binary?new TextDecoder("utf8").decode(o):Sc(o)}throw new Error(DO)}async function UO(t,e,r){if(typeof t=="string"||Tc(t))return aee(t,e,r);if(gr(t)&&(t=await Y_(t)),mr(t))return await bO(t),e.binary?await t.arrayBuffer():await t.text();if(Wu(t)&&(t=NO(t,r)),$1(t)||X1(t))return nS(t);throw new Error(DO)}function Q_(t,e){let r=hS(),o=t||r,n=o.fetch??o.core?.fetch;return typeof n=="function"?n:Ho(n)?i=>fS(i,n):e?.fetch?e?.fetch:fS}function kO(t,e,r){if(r)return r;let o={fetch:Q_(e,t),...t};if(o.url){let n=yi(o.url);o.baseUrl=n,o.queryString=_O(o.url),o.filename=Sn.filename(n),o.baseUrl=Sn.dirname(n)}return Array.isArray(o.loaders)||(o.loaders=null),o}function VO(t,e){if(t&&!Array.isArray(t))return t;let r;if(t&&(r=Array.isArray(t)?t:[t]),e&&e.loaders){let o=Array.isArray(e.loaders)?e.loaders:[e.loaders];r=r?[...r,...o]:o}return r&&r.length?r:void 0}async function Zu(t,e,r,o){e&&!Array.isArray(e)&&!qu(e)&&(o=void 0,r=e,e=void 0),t=await t,r=r||{};let n=Ms(t),s=VO(e,o),a=await MO(t,s,r);if(!a)return null;let c=SO(r,a,s,n);return o=kO({url:n,_parse:Zu,loaders:s},c,o||null),await cee(a,t,c,o)}async function cee(t,e,r,o){if(Q1(t),r=Y1(t.options,r),mr(e)){let{ok:i,redirected:s,status:a,statusText:c,type:l,url:f}=e,u=Object.fromEntries(e.headers.entries());o.response={headers:u,ok:i,redirected:s,status:a,statusText:c,type:l,url:f}}e=await UO(e,t,r);let n=t;if(n.parseTextSync&&typeof e=="string")return n.parseTextSync(e,r,o);if(eS(t,r))return await tS(t,e,r,o,Zu);if(n.parseText&&typeof e=="string")return await n.parseText(e,r,o);if(n.parse)return await n.parse(e,r,o);throw Ht(!n.parseSync),new Error(`${t.id} loader - no parser found and worker is disabled`)}async function _r(t,e,r,o){let n,i;!Array.isArray(e)&&!qu(e)?(n=[],i=e,o=void 0):(n=e,i=r);let s=Q_(i),a=t;return typeof t=="string"&&(a=await s(t)),gr(t)&&(a=await s(t)),typeof t=="string"&&(Cn(i||{}).core?.baseUrl||(i={...i,core:{...i?.core,baseUrl:t}})),Array.isArray(n)?await Zu(a,n,i):await Zu(a,n,i)}function yS(t,e,r){let o=r?.core?.type||r.type||"auto",n=o==="auto"?lee(t,e):fee(o,e);if(!n)throw new Error("Not a valid source type");return n.createDataSource(t,r)}function lee(t,e){for(let r of e)if(r.testURL&&r.testURL(t))return r;return null}function fee(t,e){for(let r of e)if(r.type===t)return r;return null}var uee=1024,dee=4,zO=()=>{},HO={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},hee={x:0,y:0,width:0,height:0};function pee(t){return Math.pow(2,Math.ceil(Math.log2(t)))}function mee(t,e,r,o){let n=Math.min(r/e.width,o/e.height),i=Math.floor(e.width*n),s=Math.floor(e.height*n);return n===1?{image:e,width:i,height:s}:(t.canvas.height=s,t.canvas.width=i,t.clearRect(0,0,i,s),t.drawImage(e,0,0,e.width,e.height,0,0,i,s),{image:t.canvas,width:i,height:s})}function Ju(t){return t&&(t.id||t.url)}function WO(t){let{device:e}=t;e.type==="webgl"?t.generateMipmapsWebGL():e.type==="webgpu"&&e.generateMipmapsWebGPU(t)}function gee(t,e,r,o){let{width:n,height:i,device:s}=t,a=s.createTexture({format:"rgba8unorm",width:e,height:r,sampler:o,mipLevels:s.getMipLevelCount(e,r)}),c=s.createCommandEncoder();c.copyTextureToTexture({sourceTexture:t,destinationTexture:a,width:n,height:i});let l=c.finish();return s.submit(l),WO(a),t.destroy(),a}function jO(t,e,r){for(let o=0;o<e.length;o++){let{icon:n,xOffset:i}=e[o],s=Ju(n);t[s]={...n,x:i,y:r}}}function _ee({icons:t,buffer:e,mapping:r={},xOffset:o=0,yOffset:n=0,rowHeight:i=0,canvasWidth:s}){let a=[];for(let c=0;c<t.length;c++){let l=t[c],f=Ju(l);if(!r[f]){let{height:u,width:d}=l;o+d+e>s&&(jO(r,a,n),o=0,n=i+n+e,i=0,a=[]),a.push({icon:l,xOffset:o}),o=o+d+e,i=Math.max(i,u)}}return a.length>0&&jO(r,a,n),{mapping:r,rowHeight:i,xOffset:o,yOffset:n,canvasWidth:s,canvasHeight:pee(i+n+e)}}function yee(t,e,r){if(!t||!e)return null;r=r||{};let o={},{iterable:n,objectInfo:i}=Fe(t);for(let s of n){i.index++;let a=e(s,i),c=Ju(a);if(!a)throw new Error("Icon is missing.");if(!a.url)throw new Error("Icon url is missing.");!o[c]&&(!r[c]||a.url!==r[c].url)&&(o[c]={...a,source:s,sourceIndex:i.index})}return o}var Qu=class{constructor(e,{onUpdate:r=zO,onError:o=zO}){this._loadOptions=null,this._texture=null,this._externalTexture=null,this._mapping={},this._samplerParameters=null,this._pendingCount=0,this._autoPacking=!1,this._xOffset=0,this._yOffset=0,this._rowHeight=0,this._buffer=dee,this._canvasWidth=uee,this._canvasHeight=0,this._canvas=null,this.device=e,this.onUpdate=r,this.onError=o}finalize(){this._texture?.delete()}getTexture(){return this._texture||this._externalTexture}getIconMapping(e){let r=this._autoPacking?Ju(e):e;return this._mapping[r]||hee}setProps({loadOptions:e,autoPacking:r,iconAtlas:o,iconMapping:n,textureParameters:i}){e&&(this._loadOptions=e),r!==void 0&&(this._autoPacking=r),n&&(this._mapping=n),o&&(this._texture?.delete(),this._texture=null,this._externalTexture=o),i&&(this._samplerParameters=i)}get isLoaded(){return this._pendingCount===0}packIcons(e,r){if(!this._autoPacking||typeof document>"u")return;let o=Object.values(yee(e,r,this._mapping)||{});if(o.length>0){let{mapping:n,xOffset:i,yOffset:s,rowHeight:a,canvasHeight:c}=_ee({icons:o,buffer:this._buffer,canvasWidth:this._canvasWidth,mapping:this._mapping,rowHeight:this._rowHeight,xOffset:this._xOffset,yOffset:this._yOffset});this._rowHeight=a,this._mapping=n,this._xOffset=i,this._yOffset=s,this._canvasHeight=c,this._texture||(this._texture=this.device.createTexture({format:"rgba8unorm",data:null,width:this._canvasWidth,height:this._canvasHeight,sampler:this._samplerParameters||HO,mipLevels:this.device.getMipLevelCount(this._canvasWidth,this._canvasHeight)})),this._texture.height!==this._canvasHeight&&(this._texture=gee(this._texture,this._canvasWidth,this._canvasHeight,this._samplerParameters||HO)),this.onUpdate(!0),this._canvas=this._canvas||document.createElement("canvas"),this._loadIcons(o)}}_loadIcons(e){let r=this._canvas.getContext("2d",{willReadFrequently:!0});for(let o of e)this._pendingCount++,_r(o.url,this._loadOptions).then(n=>{let i=Ju(o),s=this._mapping[i],{x:a,y:c,width:l,height:f}=s,{image:u,width:d,height:h}=mee(r,n,l,f),p=a+(l-d)/2,m=c+(f-h)/2;this._texture?.copyExternalImage({image:u,x:p,y:m,width:d,height:h}),s.x=p,s.y=m,s.width=d,s.height=h,this._texture&&WO(this._texture),this.onUpdate(d!==l||h!==f)}).catch(n=>{this.onError({url:o.url,source:o.source,sourceIndex:o.sourceIndex,loadOptions:this._loadOptions,error:n})}).finally(()=>{this._pendingCount--})}};var GO=[0,0,0,255],xee={iconAtlas:{type:"image",value:null,async:!0},iconMapping:{type:"object",value:{},async:!0},sizeScale:{type:"number",value:1,min:0},billboard:!0,sizeUnits:"pixels",sizeBasis:"height",sizeMinPixels:{type:"number",min:0,value:0},sizeMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},alphaCutoff:{type:"number",value:.05,min:0,max:1},getPosition:{type:"accessor",value:t=>t.position},getIcon:{type:"accessor",value:t=>t.icon},getColor:{type:"accessor",value:GO},getSize:{type:"accessor",value:1},getAngle:{type:"accessor",value:0},getPixelOffset:{type:"accessor",value:[0,0]},onIconError:{type:"function",value:null,optional:!0},textureParameters:{type:"object",ignore:!0,value:null}},ed=class extends _e{getShaders(){return super.getShaders({vs:ZB,fs:JB,source:QB,modules:[fe,Yr,Se,qB]})}initializeState(){this.state={iconManager:new Qu(this.context.device,{onUpdate:this._onUpdate.bind(this),onError:this._onError.bind(this)})},this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceSizes:{size:1,transition:!0,accessor:"getSize",defaultValue:1},instanceIconDefs:{size:7,accessor:"getIcon",transform:this.getInstanceIconDef,shaderAttributes:{instanceOffsets:{size:2,elementOffset:0},instanceIconFrames:{size:4,elementOffset:2},instanceColorModes:{size:1,elementOffset:6}}},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getColor",defaultValue:GO},instanceAngles:{size:1,transition:!0,accessor:"getAngle"},instancePixelOffset:{size:2,transition:!0,accessor:"getPixelOffset"}})}updateState(e){super.updateState(e);let{props:r,oldProps:o,changeFlags:n}=e,i=this.getAttributeManager(),{iconAtlas:s,iconMapping:a,data:c,getIcon:l,textureParameters:f}=r,{iconManager:u}=this.state;if(typeof s=="string")return;let d=s||this.internalState.isAsyncPropLoading("iconAtlas");u.setProps({loadOptions:r.loadOptions,autoPacking:!d,iconAtlas:s,iconMapping:d?a:null,textureParameters:f}),d?o.iconMapping!==r.iconMapping&&i.invalidate("getIcon"):(n.dataChanged||n.updateTriggersChanged&&(n.updateTriggersChanged.all||n.updateTriggersChanged.getIcon))&&u.packIcons(c,l),n.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),i.invalidateAll())}get isLoaded(){return super.isLoaded&&this.state.iconManager.isLoaded}finalizeState(e){super.finalizeState(e),this.state.iconManager.finalize()}draw({uniforms:e}){let{sizeScale:r,sizeBasis:o,sizeMinPixels:n,sizeMaxPixels:i,sizeUnits:s,billboard:a,alphaCutoff:c}=this.props,{iconManager:l}=this.state,f=l.getTexture();if(f){let u=this.state.model,d={iconsTexture:f,iconsTextureDim:[f.width,f.height],sizeUnits:Pe[s],sizeScale:r,sizeBasis:o==="height"?1:0,sizeMinPixels:n,sizeMaxPixels:i,billboard:a,alphaCutoff:c};u.shaderInputs.setProps({icon:d}),u.draw(this.context.renderPass)}}_getModel(){let e=[-1,-1,1,-1,-1,1,1,1];return new Q(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new ce({topology:"triangle-strip",attributes:{positions:{size:2,value:new Float32Array(e)}}}),isInstanced:!0})}_onUpdate(e){e?(this.getAttributeManager()?.invalidate("getIcon"),this.setNeedsUpdate()):this.setNeedsRedraw()}_onError(e){let r=this.getCurrentLayer()?.props.onIconError;r?r(e):N.error(e.error.message)()}getInstanceIconDef(e){let{x:r,y:o,width:n,height:i,mask:s,anchorX:a=n/2,anchorY:c=i/2}=this.state.iconManager.getIconMapping(e);return[n/2-a,i/2-c,r,o,n,i,s?1:0]}};ed.defaultProps=xee;ed.layerName="IconLayer";var Ec=ed;var $O=`layout(std140) uniform lineUniforms { float widthScale; float widthMinPixels; float widthMaxPixels; float useShortestPath; highp int widthUnits; } line; `,XO={name:"line",source:"",vs:$O,fs:$O,uniformTypes:{widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",useShortestPath:"f32",widthUnits:"i32"}};var YO=`// ---------- Helper Structures & Functions ---------- // Placeholder filter functions. fn deckgl_filter_size(offset: vec3<f32>, geometry: Geometry) -> vec3<f32> { return offset; } fn deckgl_filter_gl_position(p: vec4<f32>, geometry: Geometry) -> vec4<f32> { if (picking.isAttribute > 0.5) { // For depth picking, write normalized depth into the picking payload. // This mirrors the legacy DECKGL_FILTER_GL_POSITION hook on WebGL. } return p; } // Compute an extrusion offset given a line direction (in clipspace), // an offset direction (-1 or 1), and a width in pixels. // Assumes a uniform "project" with a viewportSize field is available. fn getExtrusionOffset(line_clipspace: vec2<f32>, offset_direction: f32, width: f32) -> vec2<f32> { // project.viewportSize should be provided as a uniform (not shown here) let dir_screenspace = normalize(line_clipspace * project.viewportSize); // Rotate by 90\xB0: (x,y) becomes (-y,x) let rotated = vec2<f32>(-dir_screenspace.y, dir_screenspace.x); return rotated * offset_direction * width / 2.0; } // Splits the line between two points at a given x coordinate. // Interpolates the y and z components. fn splitLine(a: vec3<f32>, b: vec3<f32>, x: f32) -> vec3<f32> { let t: f32 = (x - a.x) / (b.x - a.x); return vec3<f32>(x, a.yz + t * (b.yz - a.yz)); } // ---------- Uniforms & Global Structures ---------- struct LineUniforms { widthScale: f32, widthMinPixels: f32, widthMaxPixels: f32, useShortestPath: f32, widthUnits: i32, }; @group(0) @binding(0) var<uniform> line: LineUniforms; // ---------- Vertex Output Structure ---------- struct Varyings { @builtin(position) gl_Position: vec4<f32>, @location(0) vColor: vec4<f32>, @location(1) uv: vec2<f32>, @location(2) pickingColor: vec3<f32>, }; // ---------- Vertex Shader Entry Point ---------- @vertex fn vertexMain( @location(0) positions: vec3<f32>, @location(1) instanceSourcePositions: vec3<f32>, @location(2) instanceTargetPositions: vec3<f32>, @location(3) instanceSourcePositions64Low: vec3<f32>, @location(4) instanceTargetPositions64Low: vec3<f32>, @location(5) instanceColors: vec4<f32>, @location(6) instancePickingColors: vec3<f32>, @location(7) instanceWidths: f32 ) -> Varyings { geometry.worldPosition = instanceSourcePositions; geometry.worldPositionAlt = instanceTargetPositions; var source_world: vec3<f32> = instanceSourcePositions; var target_world: vec3<f32> = instanceTargetPositions; var source_world_64low: vec3<f32> = instanceSourcePositions64Low; var target_world_64low: vec3<f32> = instanceTargetPositions64Low; // Apply shortest-path adjustments if needed. if (line.useShortestPath > 0.5 || line.useShortestPath < -0.5) { source_world.x = (source_world.x + 180.0 % 360.0) - 180.0; target_world.x = (target_world.x + 180.0 % 360.0) - 180.0; let deltaLng: f32 = target_world.x - source_world.x; if (deltaLng * line.useShortestPath > 180.0) { source_world.x = source_world.x + 360.0 * line.useShortestPath; source_world = splitLine(source_world, target_world, 180.0 * line.useShortestPath); source_world_64low = vec3<f32>(0.0, 0.0, 0.0); } else if (deltaLng * line.useShortestPath < -180.0) { target_world.x = target_world.x + 360.0 * line.useShortestPath; target_world = splitLine(source_world, target_world, 180.0 * line.useShortestPath); target_world_64low = vec3<f32>(0.0, 0.0, 0.0); } else if (line.useShortestPath < 0.0) { var abortOut: Varyings; abortOut.gl_Position = vec4<f32>(0.0); abortOut.vColor = vec4<f32>(0.0); abortOut.uv = vec2<f32>(0.0); return abortOut; } } // Project Pos and target positions to clip space. let sourceResult = project_position_to_clipspace_and_commonspace(source_world, source_world_64low, vec3<f32>(0.0)); let targetResult = project_position_to_clipspace_and_commonspace(target_world, target_world_64low, vec3<f32>(0.0)); let sourcePos: vec4<f32> = sourceResult.clipPosition; let targetPos: vec4<f32> = targetResult.clipPosition; let source_commonspace: vec4<f32> = sourceResult.commonPosition; let target_commonspace: vec4<f32> = targetResult.commonPosition; // Interpolate along the line segment. let segmentIndex: f32 = positions.x; let p: vec4<f32> = sourcePos + segmentIndex * (targetPos - sourcePos); geometry.position = source_commonspace + segmentIndex * (target_commonspace - source_commonspace); let uv: vec2<f32> = positions.xy; geometry.uv = uv; geometry.pickingColor = instancePickingColors; // Determine width in pixels. let widthPixels: f32 = clamp( project_unit_size_to_pixel(instanceWidths * line.widthScale, line.widthUnits), line.widthMinPixels, line.widthMaxPixels ); // Compute extrusion offset. let extrusion: vec2<f32> = getExtrusionOffset(targetPos.xy - sourcePos.xy, positions.y, widthPixels); let offset: vec3<f32> = vec3<f32>(extrusion, 0.0); // Apply deck.gl filter functions. let filteredOffset = deckgl_filter_size(offset, geometry); let filteredP = deckgl_filter_gl_position(p, geometry); let clipOffset: vec2<f32> = project_pixel_size_to_clipspace(filteredOffset.xy); let finalPosition: vec4<f32> = filteredP + vec4<f32>(clipOffset, 0.0, 0.0); // Compute color. var vColor: vec4<f32> = vec4<f32>(instanceColors.rgb, instanceColors.a * layer.opacity); // vColor = deckgl_filter_color(vColor, geometry); var output: Varyings; output.gl_Position = finalPosition; output.vColor = vColor; output.uv = uv; output.pickingColor = instancePickingColors; return output; } @fragment fn fragmentMain( @location(0) vColor: vec4<f32>, @location(1) uv: vec2<f32>, @location(2) pickingColor: vec3<f32> ) -> @location(0) vec4<f32> { // Create and initialize geometry with the provided uv. var geometry: Geometry; geometry.uv = uv; // Start with the input color. var fragColor: vec4<f32> = vColor; if (picking.isActive > 0.5) { if (!picking_isColorValid(pickingColor)) { discard; } return vec4<f32>(pickingColor, 1.0); } if (picking.isHighlightActive > 0.5) { let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor); if (picking_isColorZero(abs(pickingColor - highlightedObjectColor))) { let highLightAlpha = picking.highlightColor.a; let blendedAlpha = highLightAlpha + fragColor.a * (1.0 - highLightAlpha); if (blendedAlpha > 0.0) { let highLightRatio = highLightAlpha / blendedAlpha; fragColor = vec4<f32>( mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio), blendedAlpha ); } else { fragColor = vec4<f32>(fragColor.rgb, 0.0); } } } // Apply premultiplied alpha as required by transparent canvas fragColor = deckgl_premultiplied_alpha(fragColor); return fragColor; } `;var KO=`#version 300 es #define SHADER_NAME line-layer-vertex-shader in vec3 positions; in vec3 instanceSourcePositions; in vec3 instanceTargetPositions; in vec3 instanceSourcePositions64Low; in vec3 instanceTargetPositions64Low; in vec4 instanceColors; in vec3 instancePickingColors; in float instanceWidths; out vec4 vColor; out vec2 uv; vec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction, float width) { vec2 dir_screenspace = normalize(line_clipspace * project.viewportSize); dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x); return dir_screenspace * offset_direction * width / 2.0; } vec3 splitLine(vec3 a, vec3 b, float x) { float t = (x - a.x) / (b.x - a.x); return vec3(x, mix(a.yz, b.yz, t)); } void main(void) { geometry.worldPosition = instanceSourcePositions; geometry.worldPositionAlt = instanceTargetPositions; vec3 source_world = instanceSourcePositions; vec3 target_world = instanceTargetPositions; vec3 source_world_64low = instanceSourcePositions64Low; vec3 target_world_64low = instanceTargetPositions64Low; if (line.useShortestPath > 0.5 || line.useShortestPath < -0.5) { source_world.x = mod(source_world.x + 180., 360.0) - 180.; target_world.x = mod(target_world.x + 180., 360.0) - 180.; float deltaLng = target_world.x - source_world.x; if (deltaLng * line.useShortestPath > 180.) { source_world.x += 360. * line.useShortestPath; source_world = splitLine(source_world, target_world, 180. * line.useShortestPath); source_world_64low = vec3(0.0); } else if (deltaLng * line.useShortestPath < -180.) { target_world.x += 360. * line.useShortestPath; target_world = splitLine(source_world, target_world, 180. * line.useShortestPath); target_world_64low = vec3(0.0); } else if (line.useShortestPath < 0.) { gl_Position = vec4(0.); return; } } vec4 source_commonspace; vec4 target_commonspace; vec4 source = project_position_to_clipspace(source_world, source_world_64low, vec3(0.), source_commonspace); vec4 target = project_position_to_clipspace(target_world, target_world_64low, vec3(0.), target_commonspace); float segmentIndex = positions.x; vec4 p = mix(source, target, segmentIndex); geometry.position = mix(source_commonspace, target_commonspace, segmentIndex); uv = positions.xy; geometry.uv = uv; geometry.pickingColor = instancePickingColors; float widthPixels = clamp( project_size_to_pixel(instanceWidths * line.widthScale, line.widthUnits), line.widthMinPixels, line.widthMaxPixels ); vec3 offset = vec3( getExtrusionOffset(target.xy - source.xy, positions.y, widthPixels), 0.0); DECKGL_FILTER_SIZE(offset, geometry); DECKGL_FILTER_GL_POSITION(p, geometry); gl_Position = p + vec4(project_pixel_size_to_clipspace(offset.xy), 0.0, 0.0); vColor = vec4(instanceColors.rgb, instanceColors.a * layer.opacity); DECKGL_FILTER_COLOR(vColor, geometry); } `;var qO=`#version 300 es #define SHADER_NAME line-layer-fragment-shader precision highp float; in vec4 vColor; in vec2 uv; out vec4 fragColor; void main(void) { geometry.uv = uv; fragColor = vColor; DECKGL_FILTER_COLOR(fragColor, geometry); } `;var bee=[0,0,0,255],Aee={getSourcePosition:{type:"accessor",value:t=>t.sourcePosition},getTargetPosition:{type:"accessor",value:t=>t.targetPosition},getColor:{type:"accessor",value:bee},getWidth:{type:"accessor",value:1},widthUnits:"pixels",widthScale:{type:"number",value:1,min:0},widthMinPixels:{type:"number",value:0,min:0},widthMaxPixels:{type:"number",value:Number.MAX_SAFE_INTEGER,min:0}},td=class extends _e{getBounds(){return this.getAttributeManager()?.getBounds(["instanceSourcePositions","instanceTargetPositions"])}getShaders(){return super.getShaders({vs:KO,fs:qO,source:YO,modules:[fe,Yr,Se,XO]})}get wrapLongitude(){return!1}initializeState(){this.getAttributeManager().addInstanced({instanceSourcePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getSourcePosition"},instanceTargetPositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getTargetPosition"},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getColor",defaultValue:[0,0,0,255]},instanceWidths:{size:1,transition:!0,accessor:"getWidth",defaultValue:1}})}updateState(e){super.updateState(e),e.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){let{widthUnits:r,widthScale:o,widthMinPixels:n,widthMaxPixels:i,wrapLongitude:s}=this.props,a=this.state.model,c={widthUnits:Pe[r],widthScale:o,widthMinPixels:n,widthMaxPixels:i,useShortestPath:s?1:0};a.shaderInputs.setProps({line:c}),a.draw(this.context.renderPass),s&&(a.shaderInputs.setProps({line:{...c,useShortestPath:-1}}),a.draw(this.context.renderPass))}_getModel(){let e=[0,-1,0,0,1,0,1,-1,0,1,1,0];return new Q(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new ce({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array(e)}}}),isInstanced:!0})}};td.layerName="LineLayer";td.defaultProps=Aee;var ZO=td;var JO=`layout(std140) uniform pointCloudUniforms { float radiusPixels; highp int sizeUnits; } pointCloud; `,QO={name:"pointCloud",source:"",vs:JO,fs:JO,uniformTypes:{radiusPixels:"f32",sizeUnits:"i32"}};var eF=`#version 300 es #define SHADER_NAME point-cloud-layer-vertex-shader in vec3 positions; in vec3 instanceNormals; in vec4 instanceColors; in vec3 instancePositions; in vec3 instancePositions64Low; in vec3 instancePickingColors; out vec4 vColor; out vec2 unitPosition; void main(void) { geometry.worldPosition = instancePositions; geometry.normal = project_normal(instanceNormals); unitPosition = positions.xy; geometry.uv = unitPosition; geometry.pickingColor = instancePickingColors; vec3 offset = vec3(positions.xy * project_size_to_pixel(pointCloud.radiusPixels, pointCloud.sizeUnits), 0.0); DECKGL_FILTER_SIZE(offset, geometry); gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.), geometry.position); DECKGL_FILTER_GL_POSITION(gl_Position, geometry); gl_Position.xy += project_pixel_size_to_clipspace(offset.xy); vec3 lightColor = lighting_getLightColor(instanceColors.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal); vColor = vec4(lightColor, instanceColors.a * layer.opacity); DECKGL_FILTER_COLOR(vColor, geometry); } `;var tF=`#version 300 es #define SHADER_NAME point-cloud-layer-fragment-shader precision highp float; in vec4 vColor; in vec2 unitPosition; out vec4 fragColor; void main(void) { geometry.uv = unitPosition.xy; float distToCenter = length(unitPosition); if (distToCenter > 1.0) { discard; } fragColor = vColor; DECKGL_FILTER_COLOR(fragColor, geometry); } `;var rF=`struct PointCloudUniforms { radiusPixels: f32, sizeUnits: i32, }; @group(0) @binding(0) var<uniform> pointCloudUniforms: PointCloudUniforms; struct ConstantAttributes { instanceNormals: vec3<f32>, instanceColors: vec4<f32>, instancePositions: vec3<f32>, instancePositions64Low: vec3<f32>, instancePickingColors: vec3<f32> }; const constants = ConstantAttributes( vec3<f32>(1.0, 0.0, 0.0), vec4<f32>(0.0, 0.0, 0.0, 1.0), vec3<f32>(0.0), vec3<f32>(0.0), vec3<f32>(0.0) ); struct Attributes { @builtin(instance_index) instanceIndex : u32, @builtin(vertex_index) vertexIndex : u32, @location(0) positions: vec3<f32>, @location(1) instancePositions: vec3<f32>, @location(2) instancePositions64Low: vec3<f32>, @location(3) instanceNormals: vec3<f32>, @location(4) instanceColors: vec4<f32>, @location(5) instancePickingColors: vec3<f32> }; struct Varyings { @builtin(position) position: vec4<f32>, @location(0) vColor: vec4<f32>, @location(1) unitPosition: vec2<f32>, @location(2) pickingColor: vec3<f32>, }; @vertex fn vertexMain(attributes: Attributes) -> Varyings { var varyings: Varyings; geometry.worldPosition = attributes.instancePositions; let centerResult = project_position_to_clipspace_and_commonspace( attributes.instancePositions, attributes.instancePositions64Low, vec3<f32>(0.0) ); geometry.position = centerResult.commonPosition; geometry.normal = project_normal(attributes.instanceNormals); // position on the containing square in [-1, 1] space varyings.unitPosition = attributes.positions.xy; geometry.uv = varyings.unitPosition; geometry.pickingColor = attributes.instancePickingColors; // Find the center of the point and add the current vertex let offset = vec3<f32>( attributes.positions.xy * project_unit_size_to_pixel(pointCloudUniforms.radiusPixels, pointCloudUniforms.sizeUnits), 0.0 ); // DECKGL_FILTER_SIZE(offset, geometry); varyings.position = centerResult.clipPosition; // DECKGL_FILTER_GL_POSITION(gl_Position, geometry); let clipPixels = project_pixel_size_to_clipspace(offset.xy); varyings.position.x += clipPixels.x; varyings.position.y += clipPixels.y; // Apply lighting let lightColor = lighting_getLightColor2(attributes.instanceColors.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal); // Apply opacity to instance color, or return instance picking color varyings.vColor = vec4(lightColor, attributes.instanceColors.a * layer.opacity); // DECKGL_FILTER_COLOR(vColor, geometry); varyings.pickingColor = attributes.instancePickingColors; return varyings; } @fragment fn fragmentMain(varyings: Varyings) -> @location(0) vec4<f32> { // var geometry: Geometry; // geometry.uv = unitPosition.xy; let distToCenter = length(varyings.unitPosition); if (distToCenter > 1.0) { discard; } var fragColor: vec4<f32>; fragColor = varyings.vColor; if (picking.isActive > 0.5) { if (!picking_isColorValid(varyings.pickingColor)) { discard; } return vec4<f32>(varyings.pickingColor, 1.0); } if (picking.isHighlightActive > 0.5) { let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor); if (picking_isColorZero(abs(varyings.pickingColor - highlightedObjectColor))) { let highLightAlpha = picking.highlightColor.a; let blendedAlpha = highLightAlpha + fragColor.a * (1.0 - highLightAlpha); if (blendedAlpha > 0.0) { let highLightRatio = highLightAlpha / blendedAlpha; fragColor = vec4<f32>( mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio), blendedAlpha ); } else { fragColor = vec4<f32>(fragColor.rgb, 0.0); } } } // Apply premultiplied alpha as required by transparent canvas fragColor = deckgl_premultiplied_alpha(fragColor); return fragColor; } `;var oF=[0,0,0,255],nF=[0,0,1],Tee={sizeUnits:"pixels",pointSize:{type:"number",min:0,value:10},getPosition:{type:"accessor",value:t=>t.position},getNormal:{type:"accessor",value:nF},getColor:{type:"accessor",value:oF},material:!0,radiusPixels:{deprecatedFor:"pointSize"}};function vee(t){let{header:e,attributes:r}=t;if(!(!e||!r)&&(t.length=e.vertexCount,r.POSITION&&(r.instancePositions=r.POSITION),r.NORMAL&&(r.instanceNormals=r.NORMAL),r.COLOR_0)){let{size:o,value:n}=r.COLOR_0;r.instanceColors={size:o,type:"unorm8",value:n}}}var rd=class extends _e{getShaders(){return super.getShaders({vs:eF,fs:tF,source:rF,modules:[fe,Yr,Xr,Se,QO]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceNormals:{size:3,transition:!0,accessor:"getNormal",defaultValue:nF},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getColor",defaultValue:oF}})}updateState(e){let{changeFlags:r,props:o}=e;super.updateState(e),r.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll()),r.dataChanged&&vee(o.data)}draw({uniforms:e}){let{pointSize:r,sizeUnits:o}=this.props,n=this.state.model,i={sizeUnits:Pe[o],radiusPixels:r};n.shaderInputs.setProps({pointCloud:i}),n.draw(this.context.renderPass)}_getModel(){let e=[];for(let r=0;r<3;r++){let o=r/3*Math.PI*2;e.push(Math.cos(o)*2,Math.sin(o)*2,0)}return new Q(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new ce({topology:"triangle-list",attributes:{positions:new Float32Array(e)}}),isInstanced:!0})}};rd.layerName="PointCloudLayer";rd.defaultProps=Tee;var e0=rd;var iF=`layout(std140) uniform scatterplotUniforms { float radiusScale; float radiusMinPixels; float radiusMaxPixels; float lineWidthScale; float lineWidthMinPixels; float lineWidthMaxPixels; float stroked; float filled; bool antialiasing; bool billboard; highp int radiusUnits; highp int lineWidthUnits; } scatterplot; `,sF={name:"scatterplot",vs:iF,fs:iF,source:"",uniformTypes:{radiusScale:"f32",radiusMinPixels:"f32",radiusMaxPixels:"f32",lineWidthScale:"f32",lineWidthMinPixels:"f32",lineWidthMaxPixels:"f32",stroked:"f32",filled:"f32",antialiasing:"f32",billboard:"f32",radiusUnits:"i32",lineWidthUnits:"i32"}};var aF=`#version 300 es #define SHADER_NAME scatterplot-layer-vertex-shader in vec3 positions; in vec3 instancePositions; in vec3 instancePositions64Low; in float instanceRadius; in float instanceLineWidths; in vec4 instanceFillColors; in vec4 instanceLineColors; in vec3 instancePickingColors; in vec2 instancePixelOffset; out vec4 vFillColor; out vec4 vLineColor; out vec2 unitPosition; out float innerUnitRadius; out float outerRadiusPixels; void main(void) { geometry.worldPosition = instancePositions; outerRadiusPixels = clamp( project_size_to_pixel(scatterplot.radiusScale * instanceRadius, scatterplot.radiusUnits), scatterplot.radiusMinPixels, scatterplot.radiusMaxPixels ); float lineWidthPixels = clamp( project_size_to_pixel(scatterplot.lineWidthScale * instanceLineWidths, scatterplot.lineWidthUnits), scatterplot.lineWidthMinPixels, scatterplot.lineWidthMaxPixels ); outerRadiusPixels += scatterplot.stroked * lineWidthPixels / 2.0; float edgePadding = scatterplot.antialiasing ? (outerRadiusPixels + SMOOTH_EDGE_RADIUS) / outerRadiusPixels : 1.0; unitPosition = edgePadding * positions.xy; geometry.uv = unitPosition; geometry.pickingColor = instancePickingColors; innerUnitRadius = 1.0 - scatterplot.stroked * lineWidthPixels / outerRadiusPixels; if (scatterplot.billboard) { gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position); DECKGL_FILTER_GL_POSITION(gl_Position, geometry); vec3 offset = edgePadding * positions * outerRadiusPixels; offset.xy += instancePixelOffset; DECKGL_FILTER_SIZE(offset, geometry); gl_Position.xy += project_pixel_size_to_clipspace(offset.xy); } else { vec3 offset = edgePadding * positions * project_pixel_size(outerRadiusPixels); offset.xy += project_pixel_size(instancePixelOffset); DECKGL_FILTER_SIZE(offset, geometry); gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset, geometry.position); DECKGL_FILTER_GL_POSITION(gl_Position, geometry); } vFillColor = vec4(instanceFillColors.rgb, instanceFillColors.a * layer.opacity); DECKGL_FILTER_COLOR(vFillColor, geometry); vLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * layer.opacity); DECKGL_FILTER_COLOR(vLineColor, geometry); } `;var cF=`#version 300 es #define SHADER_NAME scatterplot-layer-fragment-shader precision highp float; in vec4 vFillColor; in vec4 vLineColor; in vec2 unitPosition; in float innerUnitRadius; in float outerRadiusPixels; out vec4 fragColor; void main(void) { geometry.uv = unitPosition; float distToCenter = length(unitPosition) * outerRadiusPixels; float inCircle = scatterplot.antialiasing ? smoothedge(distToCenter, outerRadiusPixels) : step(distToCenter, outerRadiusPixels); if (inCircle == 0.0) { discard; } if (scatterplot.stroked > 0.5) { float isLine = scatterplot.antialiasing ? smoothedge(innerUnitRadius * outerRadiusPixels, distToCenter) : step(innerUnitRadius * outerRadiusPixels, distToCenter); if (scatterplot.filled > 0.5) { fragColor = mix(vFillColor, vLineColor, isLine); } else { if (isLine == 0.0) { discard; } fragColor = vec4(vLineColor.rgb, vLineColor.a * isLine); } } else if (scatterplot.filled < 0.5) { discard; } else { fragColor = vFillColor; } fragColor.a *= inCircle; DECKGL_FILTER_COLOR(fragColor, geometry); } `;var lF=`// Main shaders struct ScatterplotUniforms { radiusScale: f32, radiusMinPixels: f32, radiusMaxPixels: f32, lineWidthScale: f32, lineWidthMinPixels: f32, lineWidthMaxPixels: f32, stroked: f32, filled: i32, antialiasing: i32, billboard: i32, radiusUnits: i32, lineWidthUnits: i32, }; struct ConstantAttributeUniforms { instancePositions: vec3<f32>, instancePositions64Low: vec3<f32>, instanceRadius: f32, instanceLineWidths: f32, instanceFillColors: vec4<f32>, instanceLineColors: vec4<f32>, instancePickingColors: vec3<f32>, instancePixelOffset: vec2<f32>, instancePositionsConstant: i32, instancePositions64LowConstant: i32, instanceRadiusConstant: i32, instanceLineWidthsConstant: i32, instanceFillColorsConstant: i32, instanceLineColorsConstant: i32, instancePickingColorsConstant: i32, instancePixelOffsetConstant: i32 }; @group(0) @binding(0) var<uniform> scatterplot: ScatterplotUniforms; struct ConstantAttributes { instancePositions: vec3<f32>, instancePositions64Low: vec3<f32>, instanceRadius: f32, instanceLineWidths: f32, instanceFillColors: vec4<f32>, instanceLineColors: vec4<f32>, instancePickingColors: vec3<f32>, instancePixelOffset: vec2<f32> }; const constants = ConstantAttributes( vec3<f32>(0.0), vec3<f32>(0.0), 0.0, 0.0, vec4<f32>(0.0, 0.0, 0.0, 1.0), vec4<f32>(0.0, 0.0, 0.0, 1.0), vec3<f32>(0.0), vec2<f32>(0.0) ); struct Attributes { @builtin(instance_index) instanceIndex : u32, @builtin(vertex_index) vertexIndex : u32, @location(0) positions: vec3<f32>, @location(1) instancePositions: vec3<f32>, @location(2) instancePositions64Low: vec3<f32>, @location(3) instanceRadius: f32, @location(4) instanceLineWidths: f32, @location(5) instanceFillColors: vec4<f32>, @location(6) instanceLineColors: vec4<f32>, @location(7) instancePickingColors: vec3<f32>, @location(8) instancePixelOffset: vec2<f32> }; struct Varyings { @builtin(position) position: vec4<f32>, @location(0) vFillColor: vec4<f32>, @location(1) vLineColor: vec4<f32>, @location(2) unitPosition: vec2<f32>, @location(3) innerUnitRadius: f32, @location(4) outerRadiusPixels: f32, @location(5) pickingColor: vec3<f32>, }; @vertex fn vertexMain(attributes: Attributes) -> Varyings { var varyings: Varyings; // Draw an inline geometry constant array clip space triangle to verify that rendering works. // var positions = array<vec2<f32>, 3>(vec2(0.0, 0.5), vec2(-0.5, -0.5), vec2(0.5, -0.5)); // if (attributes.instanceIndex == 0) { // varyings.position = vec4<f32>(positions[attributes.vertexIndex], 0.0, 1.0); // return varyings; // } geometry.worldPosition = attributes.instancePositions; // Multiply out radius and clamp to limits varyings.outerRadiusPixels = clamp( project_unit_size_to_pixel(scatterplot.radiusScale * attributes.instanceRadius, scatterplot.radiusUnits), scatterplot.radiusMinPixels, scatterplot.radiusMaxPixels ); // Multiply out line width and clamp to limits let lineWidthPixels = clamp( project_unit_size_to_pixel(scatterplot.lineWidthScale * attributes.instanceLineWidths, scatterplot.lineWidthUnits), scatterplot.lineWidthMinPixels, scatterplot.lineWidthMaxPixels ); // outer radius needs to offset by half stroke width varyings.outerRadiusPixels += scatterplot.stroked * lineWidthPixels / 2.0; // Expand geometry to accommodate edge smoothing let edgePadding = select( (varyings.outerRadiusPixels + SMOOTH_EDGE_RADIUS) / varyings.outerRadiusPixels, 1.0, scatterplot.antialiasing != 0 ); // position on the containing square in [-1, 1] space varyings.unitPosition = edgePadding * attributes.positions.xy; geometry.uv = varyings.unitPosition; geometry.pickingColor = attributes.instancePickingColors; varyings.innerUnitRadius = 1.0 - scatterplot.stroked * lineWidthPixels / varyings.outerRadiusPixels; if (scatterplot.billboard != 0) { varyings.position = project_position_to_clipspace(attributes.instancePositions, attributes.instancePositions64Low, vec3<f32>(0.0)); // TODO , geometry.position); // DECKGL_FILTER_GL_POSITION(varyings.position, geometry); var offset = edgePadding * attributes.positions * varyings.outerRadiusPixels; offset = vec3<f32>(offset.xy + attributes.instancePixelOffset, offset.z); // DECKGL_FILTER_SIZE(offset, geometry); let clipPixels = project_pixel_size_to_clipspace(offset.xy); varyings.position = vec4<f32>(varyings.position.x + clipPixels.x, varyings.position.y + clipPixels.y, varyings.position.z, varyings.position.w); } else { var offset = edgePadding * attributes.positions * project_pixel_size_float(varyings.outerRadiusPixels); offset = vec3<f32>(offset.xy + project_pixel_size_vec2(attributes.instancePixelOffset), offset.z); // DECKGL_FILTER_SIZE(offset, geometry); varyings.position = project_position_to_clipspace(attributes.instancePositions, attributes.instancePositions64Low, offset); // TODO , geometry.position); // DECKGL_FILTER_GL_POSITION(varyings.position, geometry); } // Apply opacity to instance color, or return instance picking color varyings.vFillColor = vec4<f32>(attributes.instanceFillColors.rgb, attributes.instanceFillColors.a * layer.opacity); // DECKGL_FILTER_COLOR(varyings.vFillColor, geometry); varyings.vLineColor = vec4<f32>(attributes.instanceLineColors.rgb, attributes.instanceLineColors.a * layer.opacity); // DECKGL_FILTER_COLOR(varyings.vLineColor, geometry); varyings.pickingColor = attributes.instancePickingColors; return varyings; } @fragment fn fragmentMain(varyings: Varyings) -> @location(0) vec4<f32> { // var geometry: Geometry; // geometry.uv = unitPosition; let distToCenter = length(varyings.unitPosition) * varyings.outerRadiusPixels; let inCircle = select( smoothedge(distToCenter, varyings.outerRadiusPixels), step(distToCenter, varyings.outerRadiusPixels), scatterplot.antialiasing != 0 ); if (inCircle == 0.0) { discard; } var fragColor: vec4<f32>; if (scatterplot.stroked != 0) { let isLine = select( smoothedge(varyings.innerUnitRadius * varyings.outerRadiusPixels, distToCenter), step(varyings.innerUnitRadius * varyings.outerRadiusPixels, distToCenter), scatterplot.antialiasing != 0 ); if (scatterplot.filled != 0) { fragColor = mix(varyings.vFillColor, varyings.vLineColor, isLine); } else { if (isLine == 0.0) { discard; } fragColor = vec4<f32>(varyings.vLineColor.rgb, varyings.vLineColor.a * isLine); } } else if (scatterplot.filled == 0) { discard; } else { fragColor = varyings.vFillColor; } fragColor.a *= inCircle; if (picking.isActive > 0.5) { if (!picking_isColorValid(varyings.pickingColor)) { discard; } return vec4<f32>(varyings.pickingColor, 1.0); } if (picking.isHighlightActive > 0.5) { let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor); if (picking_isColorZero(abs(varyings.pickingColor - highlightedObjectColor))) { let highLightAlpha = picking.highlightColor.a; let blendedAlpha = highLightAlpha + fragColor.a * (1.0 - highLightAlpha); if (blendedAlpha > 0.0) { let highLightRatio = highLightAlpha / blendedAlpha; fragColor = vec4<f32>( mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio), blendedAlpha ); } else { fragColor = vec4<f32>(fragColor.rgb, 0.0); } } } // Apply premultiplied alpha as required by transparent canvas fragColor = deckgl_premultiplied_alpha(fragColor); return fragColor; // return vec4<f32>(0, 0, 1, 1); } `;var fF=[0,0,0,255],See={radiusUnits:"meters",radiusScale:{type:"number",min:0,value:1},radiusMinPixels:{type:"number",min:0,value:0},radiusMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},lineWidthUnits:"meters",lineWidthScale:{type:"number",min:0,value:1},lineWidthMinPixels:{type:"number",min:0,value:0},lineWidthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},stroked:!1,filled:!0,billboard:!1,antialiasing:!0,getPosition:{type:"accessor",value:t=>t.position},getRadius:{type:"accessor",value:1},getFillColor:{type:"accessor",value:fF},getLineColor:{type:"accessor",value:fF},getLineWidth:{type:"accessor",value:1},getPixelOffset:{type:"accessor",value:[0,0]},strokeWidth:{deprecatedFor:"getLineWidth"},outline:{deprecatedFor:"stroked"},getColor:{deprecatedFor:["getFillColor","getLineColor"]}},od=class extends _e{getShaders(){return super.getShaders({vs:aF,fs:cF,source:lF,modules:[fe,Yr,Se,sF]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceRadius:{size:1,transition:!0,accessor:"getRadius",defaultValue:1},instanceFillColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getFillColor",defaultValue:[0,0,0,255]},instanceLineColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getLineColor",defaultValue:[0,0,0,255]},instanceLineWidths:{size:1,transition:!0,accessor:"getLineWidth",defaultValue:1},instancePixelOffset:{size:2,transition:!0,accessor:"getPixelOffset"}})}updateState(e){super.updateState(e),e.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){let{radiusUnits:r,radiusScale:o,radiusMinPixels:n,radiusMaxPixels:i,stroked:s,filled:a,billboard:c,antialiasing:l,lineWidthUnits:f,lineWidthScale:u,lineWidthMinPixels:d,lineWidthMaxPixels:h}=this.props,p={stroked:s,filled:a,billboard:c,antialiasing:l,radiusUnits:Pe[r],radiusScale:o,radiusMinPixels:n,radiusMaxPixels:i,lineWidthUnits:Pe[f],lineWidthScale:u,lineWidthMinPixels:d,lineWidthMaxPixels:h},m=this.state.model;m.shaderInputs.setProps({scatterplot:p}),m.draw(this.context.renderPass)}_getModel(){let e=[-1,-1,0,1,-1,0,-1,1,0,1,1,0];return new Q(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new ce({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array(e)}}}),isInstanced:!0})}};od.defaultProps=See;od.layerName="ScatterplotLayer";var t0=od;var wc={CLOCKWISE:1,COUNTER_CLOCKWISE:-1};function Rs(t,e,r={}){return uF(t,r)!==e?(Cee(t,r),!0):!1}function uF(t,e={}){return Math.sign(xi(t,e))}var nd={x:0,y:1,z:2};function xi(t,e={}){let{start:r=0,end:o=t.length,plane:n="xy"}=e,i=e.size||2,s=0,a=nd[n[0]],c=nd[n[1]];for(let l=r,f=o-i;l<o;l+=i)s+=(t[l+a]-t[f+a])*(t[l+c]+t[f+c]),f=l;return s/2}function Cee(t,e){let{start:r=0,end:o=t.length,size:n=2}=e,i=(o-r)/n,s=Math.floor(i/2);for(let a=0;a<s;++a){let c=r+a*n,l=r+(i-1-a)*n;for(let f=0;f<n;++f){let u=t[c+f];t[c+f]=t[l+f],t[l+f]=u}}}function bS(t,e,r=2,o,n="xy"){let i=e&&e.length,s=i?e[0]*r:t.length,a=hF(t,0,s,r,!0,o&&o[0],n),c=[];if(!a||a.next===a.prev)return c;let l,f,u,d,h,p,m;if(i&&(a=Iee(t,e,a,r,o,n)),t.length>80*r){d=f=t[0],h=u=t[1];for(let g=r;g<s;g+=r)p=t[g],m=t[g+1],p<d&&(d=p),m<h&&(h=m),p>f&&(f=p),m>u&&(u=m);l=Math.max(f-d,u-h),l=l!==0?32767/l:0}return id(a,c,r,d,h,l,0),c}function hF(t,e,r,o,n,i,s){let a,c;i===void 0&&(i=xi(t,{start:e,end:r,size:o,plane:s}));let l=nd[s[0]],f=nd[s[1]];if(n===i<0)for(a=e;a<r;a+=o)c=dF(a,t[a+l],t[a+f],c);else for(a=r-o;a>=e;a-=o)c=dF(a,t[a+l],t[a+f],c);return c&&n0(c,c.next)&&(ad(c),c=c.next),c}function Is(t,e){if(!t)return t;e||(e=t);let r=t,o;do if(o=!1,!r.steiner&&(n0(r,r.next)||ke(r.prev,r,r.next)===0)){if(ad(r),r=e=r.prev,r===r.next)break;o=!0}else r=r.next;while(o||r!==e);return e}function id(t,e,r,o,n,i,s){if(!t)return;!s&&i&&Nee(t,o,n,i);let a=t,c,l;for(;t.prev!==t.next;){if(c=t.prev,l=t.next,i?Pee(t,o,n,i):wee(t)){e.push(c.i/r|0),e.push(t.i/r|0),e.push(l.i/r|0),ad(t),t=l.next,a=l.next;continue}if(t=l,t===a){s?s===1?(t=Mee(Is(t),e,r),id(t,e,r,o,n,i,2)):s===2&&Ree(t,e,r,o,n,i):id(Is(t),e,r,o,n,i,1);break}}}function wee(t){let e=t.prev,r=t,o=t.next;if(ke(e,r,o)>=0)return!1;let n=e.x,i=r.x,s=o.x,a=e.y,c=r.y,l=o.y,f=n<i?n<s?n:s:i<s?i:s,u=a<c?a<l?a:l:c<l?c:l,d=n>i?n>s?n:s:i>s?i:s,h=a>c?a>l?a:l:c>l?c:l,p=o.next;for(;p!==e;){if(p.x>=f&&p.x<=d&&p.y>=u&&p.y<=h&&Pc(n,a,i,c,s,l,p.x,p.y)&&ke(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Pee(t,e,r,o){let n=t.prev,i=t,s=t.next;if(ke(n,i,s)>=0)return!1;let a=n.x,c=i.x,l=s.x,f=n.y,u=i.y,d=s.y,h=a<c?a<l?a:l:c<l?c:l,p=f<u?f<d?f:d:u<d?u:d,m=a>c?a>l?a:l:c>l?c:l,g=f>u?f>d?f:d:u>d?u:d,_=xS(h,p,e,r,o),x=xS(m,g,e,r,o),y=t.prevZ,b=t.nextZ;for(;y&&y.z>=_&&b&&b.z<=x;){if(y.x>=h&&y.x<=m&&y.y>=p&&y.y<=g&&y!==n&&y!==s&&Pc(a,f,c,u,l,d,y.x,y.y)&&ke(y.prev,y,y.next)>=0||(y=y.prevZ,b.x>=h&&b.x<=m&&b.y>=p&&b.y<=g&&b!==n&&b!==s&&Pc(a,f,c,u,l,d,b.x,b.y)&&ke(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;y&&y.z>=_;){if(y.x>=h&&y.x<=m&&y.y>=p&&y.y<=g&&y!==n&&y!==s&&Pc(a,f,c,u,l,d,y.x,y.y)&&ke(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;b&&b.z<=x;){if(b.x>=h&&b.x<=m&&b.y>=p&&b.y<=g&&b!==n&&b!==s&&Pc(a,f,c,u,l,d,b.x,b.y)&&ke(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Mee(t,e,r){let o=t;do{let n=o.prev,i=o.next.next;!n0(n,i)&&pF(n,o,o.next,i)&&sd(n,i)&&sd(i,n)&&(e.push(n.i/r|0),e.push(o.i/r|0),e.push(i.i/r|0),ad(o),ad(o.next),o=t=i),o=o.next}while(o!==t);return Is(o)}function Ree(t,e,r,o,n,i){let s=t;do{let a=s.next.next;for(;a!==s.prev;){if(s.i!==a.i&&kee(s,a)){let c=mF(s,a);s=Is(s,s.next),c=Is(c,c.next),id(s,e,r,o,n,i,0),id(c,e,r,o,n,i,0);return}a=a.next}s=s.next}while(s!==t)}function Iee(t,e,r,o,n,i){let s=[],a,c,l,f,u;for(a=0,c=e.length;a<c;a++)l=e[a]*o,f=a<c-1?e[a+1]*o:t.length,u=hF(t,l,f,o,!1,n&&n[a+1],i),u===u.next&&(u.steiner=!0),s.push(Uee(u));for(s.sort(Lee),a=0;a<s.length;a++)r=Bee(s[a],r);return r}function Lee(t,e){return t.x-e.x}function Bee(t,e){let r=Oee(t,e);if(!r)return e;let o=mF(r,t);return Is(o,o.next),Is(r,r.next)}function Oee(t,e){let r=e,o=t.x,n=t.y,i=-1/0,s;do{if(n<=r.y&&n>=r.next.y&&r.next.y!==r.y){let d=r.x+(n-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(d<=o&&d>i&&(i=d,s=r.x<r.next.x?r:r.next,d===o))return s}r=r.next}while(r!==e);if(!s)return null;let a=s,c=s.x,l=s.y,f=1/0,u;r=s;do o>=r.x&&r.x>=c&&o!==r.x&&Pc(n<l?o:i,n,c,l,n<l?i:o,n,r.x,r.y)&&(u=Math.abs(n-r.y)/(o-r.x),sd(r,t)&&(u<f||u===f&&(r.x>s.x||r.x===s.x&&Fee(s,r)))&&(s=r,f=u)),r=r.next;while(r!==a);return s}function Fee(t,e){return ke(t.prev,t,e.prev)<0&&ke(e.next,t,t.next)<0}function Nee(t,e,r,o){let n=t;do n.z===0&&(n.z=xS(n.x,n.y,e,r,o)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==t);n.prevZ.nextZ=null,n.prevZ=null,Dee(n)}function Dee(t){let e,r,o=1,n,i,s,a,c,l;do{for(i=t,t=null,l=null,n=0;i;){for(n++,a=i,s=0,r=0;r<o&&(s++,a=a.nextZ,!!a);r++);for(c=o;s>0||c>0&&a;)s!==0&&(c===0||!a||i.z<=a.z)?(e=i,i=i.nextZ,s--):(e=a,a=a.nextZ,c--),l?l.nextZ=e:t=e,e.prevZ=l,l=e;i=a}l.nextZ=null,o*=2}while(n>1);return t}function xS(t,e,r,o,n){return t=(t-r)*n|0,e=(e-o)*n|0,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t|e<<1}function Uee(t){let e=t,r=t;do(e.x<r.x||e.x===r.x&&e.y<r.y)&&(r=e),e=e.next;while(e!==t);return r}function Pc(t,e,r,o,n,i,s,a){return(n-s)*(e-a)>=(t-s)*(i-a)&&(t-s)*(o-a)>=(r-s)*(e-a)&&(r-s)*(i-a)>=(n-s)*(o-a)}function kee(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!Vee(t,e)&&(sd(t,e)&&sd(e,t)&&zee(t,e)&&(ke(t.prev,t,e.prev)||ke(t,e.prev,e))||n0(t,e)&&ke(t.prev,t,t.next)>0&&ke(e.prev,e,e.next)>0)}function ke(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function n0(t,e){return t.x===e.x&&t.y===e.y}function pF(t,e,r,o){let n=o0(ke(t,e,r)),i=o0(ke(t,e,o)),s=o0(ke(r,o,t)),a=o0(ke(r,o,e));return!!(n!==i&&s!==a||n===0&&r0(t,r,e)||i===0&&r0(t,o,e)||s===0&&r0(r,t,o)||a===0&&r0(r,e,o))}function r0(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function o0(t){return t>0?1:t<0?-1:0}function Vee(t,e){let r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&pF(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}function sd(t,e){return ke(t.prev,t,t.next)<0?ke(t,e,t.next)>=0&&ke(t,t.prev,e)>=0:ke(t,e,t.prev)<0||ke(t,t.next,e)<0}function zee(t,e){let r=t,o=!1,n=(t.x+e.x)/2,i=(t.y+e.y)/2;do r.y>i!=r.next.y>i&&r.next.y!==r.y&&n<(r.next.x-r.x)*(i-r.y)/(r.next.y-r.y)+r.x&&(o=!o),r=r.next;while(r!==t);return o}function mF(t,e){let r=new cd(t.i,t.x,t.y),o=new cd(e.i,e.x,e.y),n=t.next,i=e.prev;return t.next=e,e.prev=t,r.next=n,n.prev=r,o.next=r,r.prev=o,i.next=o,o.prev=i,o}function dF(t,e,r,o){let n=new cd(t,e,r);return o?(n.next=o.next,n.prev=o,o.next.prev=n,o.next=n):(n.prev=n,n.next=n),n}function ad(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}var cd=class{constructor(e,r,o){this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1,this.i=e,this.x=r,this.y=o}};function Jt(t,e){let r=e.length,o=t.length;if(o>0){let n=!0;for(let i=0;i<r;i++)if(t[o-r+i]!==e[i]){n=!1;break}if(n)return!1}for(let n=0;n<r;n++)t[o+n]=e[n];return!0}function ld(t,e){let r=e.length;for(let o=0;o<r;o++)t[o]=e[o]}function bi(t,e,r,o,n=[]){let i=o+e*r;for(let s=0;s<r;s++)n[s]=t[i+s];return n}function i0(t,e,r,o,n=[]){let i,s;if(r&8)i=(o[3]-t[1])/(e[1]-t[1]),s=3;else if(r&4)i=(o[1]-t[1])/(e[1]-t[1]),s=1;else if(r&2)i=(o[2]-t[0])/(e[0]-t[0]),s=2;else if(r&1)i=(o[0]-t[0])/(e[0]-t[0]),s=0;else return null;for(let a=0;a<t.length;a++)n[a]=(s&1)===a?o[s]:i*(e[a]-t[a])+t[a];return n}function fd(t,e){let r=0;return t[0]<e[0]?r|=1:t[0]>e[2]&&(r|=2),t[1]<e[1]?r|=4:t[1]>e[3]&&(r|=8),r}function ud(t,e){let{size:r=2,broken:o=!1,gridResolution:n=10,gridOffset:i=[0,0],startIndex:s=0,endIndex:a=t.length}=e||{},c=(a-s)/r,l=[],f=[l],u=bi(t,0,r,s),d,h,p=yF(u,n,i,[]),m=[];Jt(l,u);for(let g=1;g<c;g++){for(d=bi(t,g,r,s,d),h=fd(d,p);h;){i0(u,d,h,p,m);let _=fd(m,p);_&&(i0(u,m,_,p,m),h=_),Jt(l,m),ld(u,m),jee(p,n,h),o&&l.length>r&&(l=[],f.push(l),Jt(l,u)),h=fd(d,p)}Jt(l,d),ld(u,d)}return o?f:f[0]}var gF=0,Hee=1;function dd(t,e=null,r){if(!t.length)return[];let{size:o=2,gridResolution:n=10,gridOffset:i=[0,0],edgeTypes:s=!1}=r||{},a=[],c=[{pos:t,types:s?new Array(t.length/o).fill(Hee):null,holes:e||[]}],l=[[],[]],f=[];for(;c.length;){let{pos:u,types:d,holes:h}=c.shift();Wee(u,o,h[0]||u.length,l),f=yF(l[0],n,i,f);let p=fd(l[1],f);if(p){let m=_F(u,d,o,0,h[0]||u.length,f,p),g={pos:m[0].pos,types:m[0].types,holes:[]},_={pos:m[1].pos,types:m[1].types,holes:[]};c.push(g,_);for(let x=0;x<h.length;x++)m=_F(u,d,o,h[x],h[x+1]||u.length,f,p),m[0]&&(g.holes.push(g.pos.length),g.pos=s0(g.pos,m[0].pos),s&&(g.types=s0(g.types,m[0].types))),m[1]&&(_.holes.push(_.pos.length),_.pos=s0(_.pos,m[1].pos),s&&(_.types=s0(_.types,m[1].types)))}else{let m={positions:u};s&&(m.edgeTypes=d),h.length&&(m.holeIndices=h),a.push(m)}}return a}function _F(t,e,r,o,n,i,s){let a=(n-o)/r,c=[],l=[],f=[],u=[],d=[],h,p,m,g=bi(t,a-1,r,o),_=Math.sign(s&8?g[1]-i[3]:g[0]-i[2]),x=e&&e[a-1],y=0,b=0;for(let T=0;T<a;T++)h=bi(t,T,r,o,h),p=Math.sign(s&8?h[1]-i[3]:h[0]-i[2]),m=e&&e[o/r+T],p&&_&&_!==p&&(i0(g,h,s,i,d),Jt(c,d)&&f.push(x),Jt(l,d)&&u.push(x)),p<=0?(Jt(c,h)&&f.push(m),y-=p):f.length&&(f[f.length-1]=gF),p>=0?(Jt(l,h)&&u.push(m),b+=p):u.length&&(u[u.length-1]=gF),ld(g,h),_=p,x=m;return[y?{pos:c,types:e&&f}:null,b?{pos:l,types:e&&u}:null]}function yF(t,e,r,o){let n=Math.floor((t[0]-r[0])/e)*e+r[0],i=Math.floor((t[1]-r[1])/e)*e+r[1];return o[0]=n,o[1]=i,o[2]=n+e,o[3]=i+e,o}function jee(t,e,r){r&8?(t[1]+=e,t[3]+=e):r&4?(t[1]-=e,t[3]-=e):r&2?(t[0]+=e,t[2]+=e):r&1&&(t[0]-=e,t[2]-=e)}function Wee(t,e,r,o){let n=1/0,i=-1/0,s=1/0,a=-1/0;for(let c=0;c<r;c+=e){let l=t[c],f=t[c+1];n=l<n?l:n,i=l>i?l:i,s=f<s?f:s,a=f>a?f:a}return o[0][0]=n,o[0][1]=s,o[1][0]=i,o[1][1]=a,o}function s0(t,e){for(let r=0;r<e.length;r++)t.push(e[r]);return t}var Gee=85.051129;function AS(t,e){let{size:r=2,startIndex:o=0,endIndex:n=t.length,normalize:i=!0}=e||{},s=t.slice(o,n);xF(s,r,0,n-o);let a=ud(s,{size:r,broken:!0,gridResolution:360,gridOffset:[-180,-180]});if(i)for(let c of a)bF(c,r);return a}function TS(t,e=null,r){let{size:o=2,normalize:n=!0,edgeTypes:i=!1}=r||{};e=e||[];let s=[],a=[],c=0,l=0;for(let u=0;u<=e.length;u++){let d=e[u]||t.length,h=l,p=$ee(t,o,c,d);for(let m=p;m<d;m++)s[l++]=t[m];for(let m=c;m<p;m++)s[l++]=t[m];xF(s,o,h,l),Xee(s,o,h,l,r?.maxLatitude),c=d,a[u]=l}a.pop();let f=dd(s,a,{size:o,gridResolution:360,gridOffset:[-180,-180],edgeTypes:i});if(n)for(let u of f)bF(u.positions,o);return f}function $ee(t,e,r,o){let n=-1,i=-1;for(let s=r+1;s<o;s+=e){let a=Math.abs(t[s]);a>n&&(n=a,i=s-1)}return i}function Xee(t,e,r,o,n=Gee){let i=t[r],s=t[o-e];if(Math.abs(i-s)>180){let a=bi(t,0,e,r);a[0]+=Math.round((s-i)/360)*360,Jt(t,a),a[1]=Math.sign(a[1])*n,Jt(t,a),a[0]=i,Jt(t,a)}}function xF(t,e,r,o){let n=t[0],i;for(let s=r;s<o;s+=e){i=t[s];let a=i-n;(a>180||a<-180)&&(i-=Math.round(a/360)*360),t[s]=n=i}}function bF(t,e){let r,o=t.length/e;for(let i=0;i<o&&(r=t[i*e],(r+180)%360===0);i++);let n=-Math.round(r/360)*360;if(n!==0)for(let i=0;i<o;i++)t[i*e]+=n}var hd=class extends ce{constructor(e){let{indices:r,attributes:o}=Kee(e);super({...e,indices:r,attributes:o})}};function Kee(t){let{radius:e,height:r=1,nradial:o=10}=t,{vertices:n}=t;n&&(N.assert(n.length>=o),n=n.flatMap(h=>[h[0],h[1]]),Rs(n,wc.COUNTER_CLOCKWISE));let i=r>0,s=o+1,a=i?s*3+1:o,c=Math.PI*2/o,l=new Uint16Array(i?o*3*2:0),f=new Float32Array(a*3),u=new Float32Array(a*3),d=0;if(i){for(let h=0;h<s;h++){let p=h*c,m=h%o,g=Math.sin(p),_=Math.cos(p);for(let x=0;x<2;x++)f[d+0]=n?n[m*2]:_*e,f[d+1]=n?n[m*2+1]:g*e,f[d+2]=(1/2-x)*r,u[d+0]=n?n[m*2]:_,u[d+1]=n?n[m*2+1]:g,d+=3}f[d+0]=f[d-3],f[d+1]=f[d-2],f[d+2]=f[d-1],d+=3}for(let h=i?0:1;h<s;h++){let p=Math.floor(h/2)*Math.sign(.5-h%2),m=p*c,g=(p+o)%o,_=Math.sin(m),x=Math.cos(m);f[d+0]=n?n[g*2]:x*e,f[d+1]=n?n[g*2+1]:_*e,f[d+2]=r/2,u[d+2]=1,d+=3}if(i){let h=0;for(let p=0;p<o;p++)l[h++]=p*2+0,l[h++]=p*2+2,l[h++]=p*2+0,l[h++]=p*2+1,l[h++]=p*2+1,l[h++]=p*2+3}return{indices:l,attributes:{POSITION:{size:3,value:f},NORMAL:{size:3,value:u}}}}var AF=`layout(std140) uniform columnUniforms { float radius; float angle; vec2 offset; bool extruded; bool stroked; bool isStroke; float coverage; float elevationScale; float edgeDistance; float widthScale; float widthMinPixels; float widthMaxPixels; highp int radiusUnits; highp int widthUnits; } column; `,TF={name:"column",vs:AF,fs:AF,uniformTypes:{radius:"f32",angle:"f32",offset:"vec2<f32>",extruded:"f32",stroked:"f32",isStroke:"f32",coverage:"f32",elevationScale:"f32",edgeDistance:"f32",widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",radiusUnits:"i32",widthUnits:"i32"}};var vF=`#version 300 es #define SHADER_NAME column-layer-vertex-shader in vec3 positions; in vec3 normals; in vec3 instancePositions; in float instanceElevations; in vec3 instancePositions64Low; in vec4 instanceFillColors; in vec4 instanceLineColors; in float instanceStrokeWidths; in vec3 instancePickingColors; out vec4 vColor; #ifdef FLAT_SHADING out vec3 cameraPosition; out vec4 position_commonspace; #endif void main(void) { geometry.worldPosition = instancePositions; vec4 color = column.isStroke ? instanceLineColors : instanceFillColors; mat2 rotationMatrix = mat2(cos(column.angle), sin(column.angle), -sin(column.angle), cos(column.angle)); float elevation = 0.0; float strokeOffsetRatio = 1.0; if (column.extruded) { elevation = instanceElevations * (positions.z + 1.0) / 2.0 * column.elevationScale; } else if (column.stroked) { float widthPixels = clamp( project_size_to_pixel(instanceStrokeWidths * column.widthScale, column.widthUnits), column.widthMinPixels, column.widthMaxPixels) / 2.0; float halfOffset = project_pixel_size(widthPixels) / project_size(column.edgeDistance * column.coverage * column.radius); if (column.isStroke) { strokeOffsetRatio -= sign(positions.z) * halfOffset; } else { strokeOffsetRatio -= halfOffset; } } float shouldRender = float(color.a > 0.0 && instanceElevations >= 0.0); float dotRadius = column.radius * column.coverage * shouldRender; geometry.pickingColor = instancePickingColors; vec3 centroidPosition = vec3(instancePositions.xy, instancePositions.z + elevation); vec3 centroidPosition64Low = instancePositions64Low; vec2 offset = (rotationMatrix * positions.xy * strokeOffsetRatio + column.offset) * dotRadius; if (column.radiusUnits == UNIT_METERS) { offset = project_size(offset); } else if (column.radiusUnits == UNIT_PIXELS) { offset = project_pixel_size(offset); } vec3 pos = vec3(offset, 0.); DECKGL_FILTER_SIZE(pos, geometry); gl_Position = project_position_to_clipspace(centroidPosition, centroidPosition64Low, pos, geometry.position); geometry.normal = project_normal(vec3(rotationMatrix * normals.xy, normals.z)); DECKGL_FILTER_GL_POSITION(gl_Position, geometry); if (column.extruded && !column.isStroke) { #ifdef FLAT_SHADING cameraPosition = project.cameraPosition; position_commonspace = geometry.position; vColor = vec4(color.rgb, color.a * layer.opacity); #else vec3 lightColor = lighting_getLightColor(color.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal); vColor = vec4(lightColor, color.a * layer.opacity); #endif } else { vColor = vec4(color.rgb, color.a * layer.opacity); } DECKGL_FILTER_COLOR(vColor, geometry); } `;var SF=`#version 300 es #define SHADER_NAME column-layer-fragment-shader precision highp float; out vec4 fragColor; in vec4 vColor; #ifdef FLAT_SHADING in vec3 cameraPosition; in vec4 position_commonspace; #endif void main(void) { fragColor = vColor; geometry.uv = vec2(0.); #ifdef FLAT_SHADING if (column.extruded && !column.isStroke && !bool(picking.isActive)) { vec3 normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz))); fragColor.rgb = lighting_getLightColor(vColor.rgb, cameraPosition, position_commonspace.xyz, normal); } #endif DECKGL_FILTER_COLOR(fragColor, geometry); } `;var a0=[0,0,0,255],qee={diskResolution:{type:"number",min:4,value:20},vertices:null,radius:{type:"number",min:0,value:1e3},angle:{type:"number",value:0},offset:{type:"array",value:[0,0]},coverage:{type:"number",min:0,max:1,value:1},elevationScale:{type:"number",min:0,value:1},radiusUnits:"meters",lineWidthUnits:"meters",lineWidthScale:1,lineWidthMinPixels:0,lineWidthMaxPixels:Number.MAX_SAFE_INTEGER,extruded:!0,wireframe:!1,filled:!0,stroked:!1,flatShading:!1,getPosition:{type:"accessor",value:t=>t.position},getFillColor:{type:"accessor",value:a0},getLineColor:{type:"accessor",value:a0},getLineWidth:{type:"accessor",value:1},getElevation:{type:"accessor",value:1e3},material:!0,getColor:{deprecatedFor:["getFillColor","getLineColor"]}},pd=class extends _e{getShaders(){let e={},{flatShading:r}=this.props;return r&&(e.FLAT_SHADING=1),super.getShaders({vs:vF,fs:SF,defines:e,modules:[fe,r?nn:Xr,Se,TF]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceElevations:{size:1,transition:!0,accessor:"getElevation"},instanceFillColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getFillColor",defaultValue:a0},instanceLineColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getLineColor",defaultValue:a0},instanceStrokeWidths:{size:1,accessor:"getLineWidth",transition:!0}})}updateState(e){super.updateState(e);let{props:r,oldProps:o,changeFlags:n}=e,i=n.extensionsChanged||r.flatShading!==o.flatShading;i&&(this.state.models?.forEach(a=>a.destroy()),this.setState(this._getModels()),this.getAttributeManager().invalidateAll());let s=this.getNumInstances();this.state.fillModel.setInstanceCount(s),this.state.wireframeModel.setInstanceCount(s),(i||r.diskResolution!==o.diskResolution||r.vertices!==o.vertices||(r.extruded||r.stroked)!==(o.extruded||o.stroked))&&this._updateGeometry(r)}getGeometry(e,r,o){let n=new hd({radius:1,height:o?2:0,vertices:r,nradial:e}),i=0;if(r)for(let s=0;s<e;s++){let a=r[s],c=Math.sqrt(a[0]*a[0]+a[1]*a[1]);i+=c/e}else i=1;return this.setState({edgeDistance:Math.cos(Math.PI/e)*i}),n}_getModels(){let e=this.getShaders(),r=this.getAttributeManager().getBufferLayouts(),o=new Q(this.context.device,{...e,id:`${this.props.id}-fill`,bufferLayout:r,isInstanced:!0}),n=new Q(this.context.device,{...e,id:`${this.props.id}-wireframe`,bufferLayout:r,isInstanced:!0});return{fillModel:o,wireframeModel:n,models:[n,o]}}_updateGeometry({diskResolution:e,vertices:r,extruded:o,stroked:n}){let i=this.getGeometry(e,r,o||n);this.setState({fillVertexCount:i.attributes.POSITION.value.length/3});let s=this.state.fillModel,a=this.state.wireframeModel,{POSITION:c,NORMAL:l}=i.attributes,f=new ce({topology:"triangle-strip",attributes:{POSITION:c,NORMAL:l}});s.setGeometry(f),a.setGeometry(i),a.setTopology("line-list")}draw({uniforms:e}){let{lineWidthUnits:r,lineWidthScale:o,lineWidthMinPixels:n,lineWidthMaxPixels:i,radiusUnits:s,elevationScale:a,extruded:c,filled:l,stroked:f,wireframe:u,offset:d,coverage:h,radius:p,angle:m}=this.props,g=this.state.fillModel,_=this.state.wireframeModel,{fillVertexCount:x,edgeDistance:y}=this.state,b={radius:p,angle:m/180*Math.PI,offset:d,extruded:c,stroked:f,coverage:h,elevationScale:a,edgeDistance:y,radiusUnits:Pe[s],widthUnits:Pe[r],widthScale:o,widthMinPixels:n,widthMaxPixels:i};c&&u&&(_.shaderInputs.setProps({column:{...b,isStroke:!0}}),_.draw(this.context.renderPass)),l&&(g.setVertexCount(x),g.shaderInputs.setProps({column:{...b,isStroke:!1}}),g.draw(this.context.renderPass)),!c&&f&&(g.setVertexCount(x*2/3),g.shaderInputs.setProps({column:{...b,isStroke:!0}}),g.draw(this.context.renderPass))}};pd.layerName="ColumnLayer";pd.defaultProps=qee;var Wo=pd;var Zee={cellSize:{type:"number",min:0,value:1e3},offset:{type:"array",value:[1,1]}},md=class extends Wo{_updateGeometry(){let e=new dn;this.state.fillModel.setGeometry(e)}draw({uniforms:e}){let{elevationScale:r,extruded:o,offset:n,coverage:i,cellSize:s,angle:a,radiusUnits:c}=this.props,l=this.state.fillModel,f={radius:s/2,radiusUnits:Pe[c],angle:a,offset:n,extruded:o,stroked:!1,coverage:i,elevationScale:r,edgeDistance:1,isStroke:!1,widthUnits:0,widthScale:0,widthMinPixels:0,widthMaxPixels:0};l.shaderInputs.setProps({column:f}),l.draw(this.context.renderPass)}};md.layerName="GridCellLayer";md.defaultProps=Zee;var CF=md;function EF(t,e,r,o){let n;if(Array.isArray(t[0])){let i=t.length*e;n=new Array(i);for(let s=0;s<t.length;s++)for(let a=0;a<e;a++)n[s*e+a]=t[s][a]||0}else n=t;return r?ud(n,{size:e,gridResolution:r}):o?AS(n,{size:e}):n}var Jee=1,Qee=2,vS=4,gd=class extends vn{constructor(e){super({...e,attributes:{positions:{size:3,padding:18,initialize:!0,type:e.fp64?Float64Array:Float32Array},segmentTypes:{size:1,type:Uint8ClampedArray}}})}get(e){return this.attributes[e]}getGeometryFromBuffer(e){return this.normalize?super.getGeometryFromBuffer(e):null}normalizeGeometry(e){return this.normalize?EF(e,this.positionSize,this.opts.resolution,this.opts.wrapLongitude):e}getGeometrySize(e){if(wF(e)){let o=0;for(let n of e)o+=this.getGeometrySize(n);return o}let r=this.getPathLength(e);return r<2?0:this.isClosed(e)?r<3?0:r+2:r}updateGeometryAttributes(e,r){if(r.geometrySize!==0)if(e&&wF(e))for(let o of e){let n=this.getGeometrySize(o);r.geometrySize=n,this.updateGeometryAttributes(o,r),r.vertexStart+=n}else this._updateSegmentTypes(e,r),this._updatePositions(e,r)}_updateSegmentTypes(e,r){let o=this.attributes.segmentTypes,n=e?this.isClosed(e):!1,{vertexStart:i,geometrySize:s}=r;o.fill(0,i,i+s),n?(o[i]=vS,o[i+s-2]=vS):(o[i]+=Jee,o[i+s-2]+=Qee),o[i+s-1]=vS}_updatePositions(e,r){let{positions:o}=this.attributes;if(!o||!e)return;let{vertexStart:n,geometrySize:i}=r,s=new Array(3);for(let a=n,c=0;c<i;a++,c++)this.getPointOnPath(e,c,s),o[a*3]=s[0],o[a*3+1]=s[1],o[a*3+2]=s[2]}getPathLength(e){return e.length/this.positionSize}getPointOnPath(e,r,o=[]){let{positionSize:n}=this;r*n>=e.length&&(r+=1-e.length/n);let i=r*n;return o[0]=e[i],o[1]=e[i+1],o[2]=n===3&&e[i+2]||0,o}isClosed(e){if(!this.normalize)return Boolean(this.opts.loop);let{positionSize:r}=this,o=e.length-r;return e[0]===e[o]&&e[1]===e[o+1]&&(r===2||e[2]===e[o+2])}};function wF(t){return Array.isArray(t[0])}var PF=`layout(std140) uniform pathUniforms { float widthScale; float widthMinPixels; float widthMaxPixels; float jointType; float capType; float miterLimit; bool billboard; highp int widthUnits; } path; `,MF={name:"path",vs:PF,fs:PF,uniformTypes:{widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",jointType:"f32",capType:"f32",miterLimit:"f32",billboard:"f32",widthUnits:"i32"}};var RF=`#version 300 es #define SHADER_NAME path-layer-vertex-shader in vec2 positions; in float instanceTypes; in vec3 instanceStartPositions; in vec3 instanceEndPositions; in vec3 instanceLeftPositions; in vec3 instanceRightPositions; in vec3 instanceLeftPositions64Low; in vec3 instanceStartPositions64Low; in vec3 instanceEndPositions64Low; in vec3 instanceRightPositions64Low; in float instanceStrokeWidths; in vec4 instanceColors; in vec3 instancePickingColors; uniform float opacity; out vec4 vColor; out vec2 vCornerOffset; out float vMiterLength; out vec2 vPathPosition; out float vPathLength; out float vJointType; const float EPSILON = 0.001; const vec3 ZERO_OFFSET = vec3(0.0); float flipIfTrue(bool flag) { return -(float(flag) * 2. - 1.); } vec3 getLineJoinOffset( vec3 prevPoint, vec3 currPoint, vec3 nextPoint, vec2 width ) { bool isEnd = positions.x > 0.0; float sideOfPath = positions.y; float isJoint = float(sideOfPath == 0.0); vec3 deltaA3 = (currPoint - prevPoint); vec3 deltaB3 = (nextPoint - currPoint); mat3 rotationMatrix; bool needsRotation = !path.billboard && project_needs_rotation(currPoint, rotationMatrix); if (needsRotation) { deltaA3 = deltaA3 * rotationMatrix; deltaB3 = deltaB3 * rotationMatrix; } vec2 deltaA = deltaA3.xy / width; vec2 deltaB = deltaB3.xy / width; float lenA = length(deltaA); float lenB = length(deltaB); vec2 dirA = lenA > 0. ? normalize(deltaA) : vec2(0.0, 0.0); vec2 dirB = lenB > 0. ? normalize(deltaB) : vec2(0.0, 0.0); vec2 perpA = vec2(-dirA.y, dirA.x); vec2 perpB = vec2(-dirB.y, dirB.x); vec2 tangent = dirA + dirB; tangent = length(tangent) > 0. ? normalize(tangent) : perpA; vec2 miterVec = vec2(-tangent.y, tangent.x); vec2 dir = isEnd ? dirA : dirB; vec2 perp = isEnd ? perpA : perpB; float L = isEnd ? lenA : lenB; float sinHalfA = abs(dot(miterVec, perp)); float cosHalfA = abs(dot(dirA, miterVec)); float turnDirection = flipIfTrue(dirA.x * dirB.y >= dirA.y * dirB.x); float cornerPosition = sideOfPath * turnDirection; float miterSize = 1.0 / max(sinHalfA, EPSILON); miterSize = mix( min(miterSize, max(lenA, lenB) / max(cosHalfA, EPSILON)), miterSize, step(0.0, cornerPosition) ); vec2 offsetVec = mix(miterVec * miterSize, perp, step(0.5, cornerPosition)) * (sideOfPath + isJoint * turnDirection); bool isStartCap = lenA == 0.0 || (!isEnd && (instanceTypes == 1.0 || instanceTypes == 3.0)); bool isEndCap = lenB == 0.0 || (isEnd && (instanceTypes == 2.0 || instanceTypes == 3.0)); bool isCap = isStartCap || isEndCap; if (isCap) { offsetVec = mix(perp * sideOfPath, dir * path.capType * 4.0 * flipIfTrue(isStartCap), isJoint); vJointType = path.capType; } else { vJointType = path.jointType; } vPathLength = L; vCornerOffset = offsetVec; vMiterLength = dot(vCornerOffset, miterVec * turnDirection); vMiterLength = isCap ? isJoint : vMiterLength; vec2 offsetFromStartOfPath = vCornerOffset + deltaA * float(isEnd); vPathPosition = vec2( dot(offsetFromStartOfPath, perp), dot(offsetFromStartOfPath, dir) ); geometry.uv = vPathPosition; float isValid = step(instanceTypes, 3.5); vec3 offset = vec3(offsetVec * width * isValid, 0.0); if (needsRotation) { offset = rotationMatrix * offset; } return offset; } void clipLine(inout vec4 position, vec4 refPosition) { if (position.w < EPSILON) { float r = (EPSILON - refPosition.w) / (position.w - refPosition.w); position = refPosition + (position - refPosition) * r; } } void main() { geometry.pickingColor = instancePickingColors; vColor = vec4(instanceColors.rgb, instanceColors.a * layer.opacity); float isEnd = positions.x; vec3 prevPosition = mix(instanceLeftPositions, instanceStartPositions, isEnd); vec3 prevPosition64Low = mix(instanceLeftPositions64Low, instanceStartPositions64Low, isEnd); vec3 currPosition = mix(instanceStartPositions, instanceEndPositions, isEnd); vec3 currPosition64Low = mix(instanceStartPositions64Low, instanceEndPositions64Low, isEnd); vec3 nextPosition = mix(instanceEndPositions, instanceRightPositions, isEnd); vec3 nextPosition64Low = mix(instanceEndPositions64Low, instanceRightPositions64Low, isEnd); geometry.worldPosition = currPosition; vec2 widthPixels = vec2(clamp( project_size_to_pixel(instanceStrokeWidths * path.widthScale, path.widthUnits), path.widthMinPixels, path.widthMaxPixels) / 2.0); vec3 width; if (path.billboard) { vec4 prevPositionScreen = project_position_to_clipspace(prevPosition, prevPosition64Low, ZERO_OFFSET); vec4 currPositionScreen = project_position_to_clipspace(currPosition, currPosition64Low, ZERO_OFFSET, geometry.position); vec4 nextPositionScreen = project_position_to_clipspace(nextPosition, nextPosition64Low, ZERO_OFFSET); clipLine(prevPositionScreen, currPositionScreen); clipLine(nextPositionScreen, currPositionScreen); clipLine(currPositionScreen, mix(nextPositionScreen, prevPositionScreen, isEnd)); width = vec3(widthPixels, 0.0); DECKGL_FILTER_SIZE(width, geometry); vec3 offset = getLineJoinOffset( prevPositionScreen.xyz / prevPositionScreen.w, currPositionScreen.xyz / currPositionScreen.w, nextPositionScreen.xyz / nextPositionScreen.w, project_pixel_size_to_clipspace(width.xy) ); DECKGL_FILTER_GL_POSITION(currPositionScreen, geometry); gl_Position = vec4(currPositionScreen.xyz + offset * currPositionScreen.w, currPositionScreen.w); } else { prevPosition = project_position(prevPosition, prevPosition64Low); currPosition = project_position(currPosition, currPosition64Low); nextPosition = project_position(nextPosition, nextPosition64Low); width = vec3(project_pixel_size(widthPixels), 0.0); DECKGL_FILTER_SIZE(width, geometry); vec3 offset = getLineJoinOffset(prevPosition, currPosition, nextPosition, width.xy); geometry.position = vec4(currPosition + offset, 1.0); gl_Position = project_common_position_to_clipspace(geometry.position); DECKGL_FILTER_GL_POSITION(gl_Position, geometry); } DECKGL_FILTER_COLOR(vColor, geometry); } `;var IF=`#version 300 es #define SHADER_NAME path-layer-fragment-shader precision highp float; in vec4 vColor; in vec2 vCornerOffset; in float vMiterLength; in vec2 vPathPosition; in float vPathLength; in float vJointType; out vec4 fragColor; void main(void) { geometry.uv = vPathPosition; if (vPathPosition.y < 0.0 || vPathPosition.y > vPathLength) { if (vJointType > 0.5 && length(vCornerOffset) > 1.0) { discard; } if (vJointType < 0.5 && vMiterLength > path.miterLimit + 1.0) { discard; } } fragColor = vColor; DECKGL_FILTER_COLOR(fragColor, geometry); } `;var LF=[0,0,0,255],ete={widthUnits:"meters",widthScale:{type:"number",min:0,value:1},widthMinPixels:{type:"number",min:0,value:0},widthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},jointRounded:!1,capRounded:!1,miterLimit:{type:"number",min:0,value:4},billboard:!1,_pathType:null,getPath:{type:"accessor",value:t=>t.path},getColor:{type:"accessor",value:LF},getWidth:{type:"accessor",value:1},rounded:{deprecatedFor:["jointRounded","capRounded"]}},SS={enter:(t,e)=>e.length?e.subarray(e.length-t.length):t},_d=class extends _e{getShaders(){return super.getShaders({vs:RF,fs:IF,modules:[fe,Se,MF]})}get wrapLongitude(){return!1}getBounds(){return this.getAttributeManager()?.getBounds(["vertexPositions"])}initializeState(){this.getAttributeManager().addInstanced({vertexPositions:{size:3,vertexOffset:1,type:"float64",fp64:this.use64bitPositions(),transition:SS,accessor:"getPath",update:this.calculatePositions,noAlloc:!0,shaderAttributes:{instanceLeftPositions:{vertexOffset:0},instanceStartPositions:{vertexOffset:1},instanceEndPositions:{vertexOffset:2},instanceRightPositions:{vertexOffset:3}}},instanceTypes:{size:1,type:"uint8",update:this.calculateSegmentTypes,noAlloc:!0},instanceStrokeWidths:{size:1,accessor:"getWidth",transition:SS,defaultValue:1},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",accessor:"getColor",transition:SS,defaultValue:LF},instancePickingColors:{size:4,type:"uint8",accessor:(o,{index:n,target:i})=>this.encodePickingColor(o&&o.__source?o.__source.index:n,i)}}),this.setState({pathTesselator:new gd({fp64:this.use64bitPositions()})})}updateState(e){super.updateState(e);let{props:r,changeFlags:o}=e,n=this.getAttributeManager();if(o.dataChanged||o.updateTriggersChanged&&(o.updateTriggersChanged.all||o.updateTriggersChanged.getPath)){let{pathTesselator:s}=this.state,a=r.data.attributes||{};s.updateGeometry({data:r.data,geometryBuffer:a.getPath,buffers:a,normalize:!r._pathType,loop:r._pathType==="loop",getGeometry:r.getPath,positionFormat:r.positionFormat,wrapLongitude:r.wrapLongitude,resolution:this.context.viewport.resolution,dataChanged:o.dataChanged}),this.setState({numInstances:s.instanceCount,startIndices:s.vertexStarts}),o.dataChanged||n.invalidateAll()}o.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),n.invalidateAll())}getPickingInfo(e){let r=super.getPickingInfo(e),{index:o}=r,n=this.props.data;return n[0]&&n[0].__source&&(r.object=n.find(i=>i.__source.index===o)),r}disablePickingIndex(e){let r=this.props.data;if(r[0]&&r[0].__source)for(let o=0;o<r.length;o++)r[o].__source.index===e&&this._disablePickingIndex(o);else super.disablePickingIndex(e)}draw({uniforms:e}){let{jointRounded:r,capRounded:o,billboard:n,miterLimit:i,widthUnits:s,widthScale:a,widthMinPixels:c,widthMaxPixels:l}=this.props,f=this.state.model,u={jointType:Number(r),capType:Number(o),billboard:n,widthUnits:Pe[s],widthScale:a,miterLimit:i,widthMinPixels:c,widthMaxPixels:l};f.shaderInputs.setProps({path:u}),f.draw(this.context.renderPass)}_getModel(){let e=[0,1,2,1,4,2,1,3,4,3,5,4],r=[0,0,0,-1,0,1,1,-1,1,1,1,0];return new Q(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new ce({topology:"triangle-list",attributes:{indices:new Uint16Array(e),positions:{value:new Float32Array(r),size:2}}}),isInstanced:!0})}calculatePositions(e){let{pathTesselator:r}=this.state;e.startIndices=r.vertexStarts,e.value=r.get("positions")}calculateSegmentTypes(e){let{pathTesselator:r}=this.state;e.startIndices=r.vertexStarts,e.value=r.get("segmentTypes")}};_d.defaultProps=ete;_d.layerName="PathLayer";var Go=_d;var HF=kn(DF(),1);var d0=wc.CLOCKWISE,UF=wc.COUNTER_CLOCKWISE,Ai={isClosed:!0};function gte(t){if(t=t&&t.positions||t,!Array.isArray(t)&&!ArrayBuffer.isView(t))throw new Error("invalid polygon")}function Rc(t){return"positions"in t?t.positions:t}function Ad(t){return"holeIndices"in t?t.holeIndices:null}function _te(t){return Array.isArray(t[0])}function yte(t){return t.length>=1&&t[0].length>=2&&Number.isFinite(t[0][0])}function xte(t){let e=t[0],r=t[t.length-1];return e[0]===r[0]&&e[1]===r[1]&&e[2]===r[2]}function bte(t,e,r,o){for(let n=0;n<e;n++)if(t[r+n]!==t[o-e+n])return!1;return!0}function kF(t,e,r,o,n){let i=e,s=r.length;for(let a=0;a<s;a++)for(let c=0;c<o;c++)t[i++]=r[a][c]||0;if(!xte(r))for(let a=0;a<o;a++)t[i++]=r[0][a]||0;return Ai.start=e,Ai.end=i,Ai.size=o,Rs(t,n,Ai),i}function VF(t,e,r,o,n=0,i,s){i=i||r.length;let a=i-n;if(a<=0)return e;let c=e;for(let l=0;l<a;l++)t[c++]=r[n+l];if(!bte(r,o,n,i))for(let l=0;l<o;l++)t[c++]=r[n+l];return Ai.start=e,Ai.end=c,Ai.size=o,Rs(t,s,Ai),c}function h0(t,e){gte(t);let r=[],o=[];if("positions"in t){let{positions:n,holeIndices:i}=t;if(i){let s=0;for(let a=0;a<=i.length;a++)s=VF(r,s,n,e,i[a-1],i[a],a===0?d0:UF),o.push(s);return o.pop(),{positions:r,holeIndices:o}}t=n}if(!_te(t))return VF(r,0,t,e,0,r.length,d0),r;if(!yte(t)){let n=0;for(let[i,s]of t.entries())n=kF(r,n,s,e,i===0?d0:UF),o.push(n);return o.pop(),{positions:r,holeIndices:o}}return kF(r,0,t,e,d0),r}function MS(t,e,r){let o=t.length/3,n=0;for(let i=0;i<o;i++){let s=(i+1)%o;n+=t[i*3+e]*t[s*3+r],n-=t[s*3+e]*t[i*3+r]}return Math.abs(n/2)}function zF(t,e,r,o){let n=t.length/3;for(let i=0;i<n;i++){let s=i*3,a=t[s+0],c=t[s+1],l=t[s+2];t[s+e]=a,t[s+r]=c,t[s+o]=l}}function jF(t,e,r,o){let n=Ad(t);n&&(n=n.map(a=>a/e));let i=Rc(t),s=o&&e===3;if(r){let a=i.length;i=i.slice();let c=[];for(let l=0;l<a;l+=e){c[0]=i[l],c[1]=i[l+1],s&&(c[2]=i[l+2]);let f=r(c);i[l]=f[0],i[l+1]=f[1],s&&(i[l+2]=f[2])}}if(s){let a=MS(i,0,1),c=MS(i,0,2),l=MS(i,1,2);if(!a&&!c&&!l)return[];a>c&&a>l||(c>l?(r||(i=i.slice()),zF(i,0,2,1)):(r||(i=i.slice()),zF(i,2,0,1)))}return(0,HF.default)(i,n,e)}var Td=class extends vn{constructor(e){let{fp64:r,IndexType:o=Uint32Array}=e;super({...e,attributes:{positions:{size:3,type:r?Float64Array:Float32Array},vertexValid:{type:Uint16Array,size:1},indices:{type:o,size:1}}})}get(e){let{attributes:r}=this;return e==="indices"?r.indices&&r.indices.subarray(0,this.vertexCount):r[e]}updateGeometry(e){super.updateGeometry(e);let r=this.buffers.indices;if(r)this.vertexCount=(r.value||r).length;else if(this.data&&!this.getGeometry)throw new Error("missing indices buffer")}normalizeGeometry(e){if(this.normalize){let r=h0(e,this.positionSize);return this.opts.resolution?dd(Rc(r),Ad(r),{size:this.positionSize,gridResolution:this.opts.resolution,edgeTypes:!0}):this.opts.wrapLongitude?TS(Rc(r),Ad(r),{size:this.positionSize,maxLatitude:86,edgeTypes:!0}):r}return e}getGeometrySize(e){if(GF(e)){let r=0;for(let o of e)r+=this.getGeometrySize(o);return r}return Rc(e).length/this.positionSize}getGeometryFromBuffer(e){return this.normalize||!this.buffers.indices?super.getGeometryFromBuffer(e):null}updateGeometryAttributes(e,r){if(e&&GF(e))for(let o of e){let n=this.getGeometrySize(o);r.geometrySize=n,this.updateGeometryAttributes(o,r),r.vertexStart+=n,r.indexStart=this.indexStarts[r.geometryIndex+1]}else{let o=e;this._updateIndices(o,r),this._updatePositions(o,r),this._updateVertexValid(o,r)}}_updateIndices(e,{geometryIndex:r,vertexStart:o,indexStart:n}){let{attributes:i,indexStarts:s,typedArrayManager:a}=this,c=i.indices;if(!c||!e)return;let l=n,f=jF(e,this.positionSize,this.opts.preproject,this.opts.full3d);c=a.allocate(c,n+f.length,{copy:!0});for(let u=0;u<f.length;u++)c[l++]=f[u]+o;s[r+1]=n+f.length,i.indices=c}_updatePositions(e,{vertexStart:r,geometrySize:o}){let{attributes:{positions:n},positionSize:i}=this;if(!n||!e)return;let s=Rc(e);for(let a=r,c=0;c<o;a++,c++){let l=s[c*i],f=s[c*i+1],u=i>2?s[c*i+2]:0;n[a*3]=l,n[a*3+1]=f,n[a*3+2]=u}}_updateVertexValid(e,{vertexStart:r,geometrySize:o}){let{positionSize:n}=this,i=this.attributes.vertexValid,s=e&&Ad(e);if(e&&e.edgeTypes?i.set(e.edgeTypes,r):i.fill(1,r,r+o),s)for(let a=0;a<s.length;a++)i[r+s[a]/n-1]=0;i[r+o-1]=0}};function GF(t){return Array.isArray(t)&&t.length>0&&!Number.isFinite(t[0])}var $F=`layout(std140) uniform solidPolygonUniforms { bool extruded; bool isWireframe; float elevationScale; } solidPolygon; `,XF={name:"solidPolygon",vs:$F,fs:$F,uniformTypes:{extruded:"f32",isWireframe:"f32",elevationScale:"f32"}};var p0=`in vec4 fillColors; in vec4 lineColors; in vec3 pickingColors; out vec4 vColor; struct PolygonProps { vec3 positions; vec3 positions64Low; vec3 normal; float elevations; }; vec3 project_offset_normal(vec3 vector) { if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT || project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSETS) { return normalize(vector * project.commonUnitsPerWorldUnit); } return project_normal(vector); } void calculatePosition(PolygonProps props) { vec3 pos = props.positions; vec3 pos64Low = props.positions64Low; vec3 normal = props.normal; vec4 colors = solidPolygon.isWireframe ? lineColors : fillColors; geometry.worldPosition = props.positions; geometry.pickingColor = pickingColors; if (solidPolygon.extruded) { pos.z += props.elevations * solidPolygon.elevationScale; } gl_Position = project_position_to_clipspace(pos, pos64Low, vec3(0.), geometry.position); DECKGL_FILTER_GL_POSITION(gl_Position, geometry); if (solidPolygon.extruded) { #ifdef IS_SIDE_VERTEX normal = project_offset_normal(normal); #else normal = project_normal(normal); #endif geometry.normal = normal; vec3 lightColor = lighting_getLightColor(colors.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal); vColor = vec4(lightColor, colors.a * layer.opacity); } else { vColor = vec4(colors.rgb, colors.a * layer.opacity); } DECKGL_FILTER_COLOR(vColor, geometry); } `;var YF=`#version 300 es #define SHADER_NAME solid-polygon-layer-vertex-shader in vec3 vertexPositions; in vec3 vertexPositions64Low; in float elevations; ${p0} void main(void) { PolygonProps props; props.positions = vertexPositions; props.positions64Low = vertexPositions64Low; props.elevations = elevations; props.normal = vec3(0.0, 0.0, 1.0); calculatePosition(props); } `;var KF=`#version 300 es #define SHADER_NAME solid-polygon-layer-vertex-shader-side #define IS_SIDE_VERTEX in vec2 positions; in vec3 vertexPositions; in vec3 nextVertexPositions; in vec3 vertexPositions64Low; in vec3 nextVertexPositions64Low; in float elevations; in float instanceVertexValid; ${p0} void main(void) { if(instanceVertexValid < 0.5){ gl_Position = vec4(0.); return; } PolygonProps props; vec3 pos; vec3 pos64Low; vec3 nextPos; vec3 nextPos64Low; #if RING_WINDING_ORDER_CW == 1 pos = vertexPositions; pos64Low = vertexPositions64Low; nextPos = nextVertexPositions; nextPos64Low = nextVertexPositions64Low; #else pos = nextVertexPositions; pos64Low = nextVertexPositions64Low; nextPos = vertexPositions; nextPos64Low = vertexPositions64Low; #endif props.positions = mix(pos, nextPos, positions.x); props.positions64Low = mix(pos64Low, nextPos64Low, positions.x); props.normal = vec3( pos.y - nextPos.y + (pos64Low.y - nextPos64Low.y), nextPos.x - pos.x + (nextPos64Low.x - pos64Low.x), 0.0); props.elevations = elevations * positions.y; calculatePosition(props); } `;var qF=`#version 300 es #define SHADER_NAME solid-polygon-layer-fragment-shader precision highp float; in vec4 vColor; out vec4 fragColor; void main(void) { fragColor = vColor; geometry.uv = vec2(0.); DECKGL_FILTER_COLOR(fragColor, geometry); } `;var g0=[0,0,0,255],Ate={filled:!0,extruded:!1,wireframe:!1,_normalize:!0,_windingOrder:"CW",_full3d:!1,elevationScale:{type:"number",min:0,value:1},getPolygon:{type:"accessor",value:t=>t.polygon},getElevation:{type:"accessor",value:1e3},getFillColor:{type:"accessor",value:g0},getLineColor:{type:"accessor",value:g0},material:!0},m0={enter:(t,e)=>e.length?e.subarray(e.length-t.length):t},vd=class extends _e{getShaders(e){return super.getShaders({vs:e==="top"?YF:KF,fs:qF,defines:{RING_WINDING_ORDER_CW:!this.props._normalize&&this.props._windingOrder==="CCW"?0:1},modules:[fe,Xr,Se,XF]})}get wrapLongitude(){return!1}getBounds(){return this.getAttributeManager()?.getBounds(["vertexPositions"])}initializeState(){let{viewport:e}=this.context,{coordinateSystem:r}=this.props,{_full3d:o}=this.props;e.isGeospatial&&r==="default"&&(r="lnglat");let n;r==="lnglat"&&(o?n=e.projectPosition.bind(e):n=e.projectFlat.bind(e)),this.setState({numInstances:0,polygonTesselator:new Td({preproject:n,fp64:this.use64bitPositions(),IndexType:Uint32Array})});let i=this.getAttributeManager(),s=!0;i.remove(["instancePickingColors"]),i.add({indices:{size:1,isIndexed:!0,update:this.calculateIndices,noAlloc:s},vertexPositions:{size:3,type:"float64",stepMode:"dynamic",fp64:this.use64bitPositions(),transition:m0,accessor:"getPolygon",update:this.calculatePositions,noAlloc:s,shaderAttributes:{nextVertexPositions:{vertexOffset:1}}},instanceVertexValid:{size:1,type:"uint16",stepMode:"instance",update:this.calculateVertexValid,noAlloc:s},elevations:{size:1,stepMode:"dynamic",transition:m0,accessor:"getElevation"},fillColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:m0,accessor:"getFillColor",defaultValue:g0},lineColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:m0,accessor:"getLineColor",defaultValue:g0},pickingColors:{size:4,type:"uint8",stepMode:"dynamic",accessor:(a,{index:c,target:l})=>this.encodePickingColor(a&&a.__source?a.__source.index:c,l)}})}getPickingInfo(e){let r=super.getPickingInfo(e),{index:o}=r,n=this.props.data;return n[0]&&n[0].__source&&(r.object=n.find(i=>i.__source.index===o)),r}disablePickingIndex(e){let r=this.props.data;if(r[0]&&r[0].__source)for(let o=0;o<r.length;o++)r[o].__source.index===e&&this._disablePickingIndex(o);else super.disablePickingIndex(e)}draw({uniforms:e}){let{extruded:r,filled:o,wireframe:n,elevationScale:i}=this.props,{topModel:s,sideModel:a,wireframeModel:c,polygonTesselator:l}=this.state,f={extruded:Boolean(r),elevationScale:i,isWireframe:!1};c&&n&&(c.setInstanceCount(l.instanceCount-1),c.shaderInputs.setProps({solidPolygon:{...f,isWireframe:!0}}),c.draw(this.context.renderPass)),a&&o&&(a.setInstanceCount(l.instanceCount-1),a.shaderInputs.setProps({solidPolygon:f}),a.draw(this.context.renderPass)),s&&o&&(s.setVertexCount(l.vertexCount),s.shaderInputs.setProps({solidPolygon:f}),s.draw(this.context.renderPass))}updateState(e){super.updateState(e),this.updateGeometry(e);let{props:r,oldProps:o,changeFlags:n}=e,i=this.getAttributeManager();(n.extensionsChanged||r.filled!==o.filled||r.extruded!==o.extruded)&&(this.state.models?.forEach(a=>a.destroy()),this.setState(this._getModels()),i.invalidateAll())}updateGeometry({props:e,oldProps:r,changeFlags:o}){if(o.dataChanged||o.updateTriggersChanged&&(o.updateTriggersChanged.all||o.updateTriggersChanged.getPolygon)){let{polygonTesselator:i}=this.state,s=e.data.attributes||{};i.updateGeometry({data:e.data,normalize:e._normalize,geometryBuffer:s.getPolygon,buffers:s,getGeometry:e.getPolygon,positionFormat:e.positionFormat,wrapLongitude:e.wrapLongitude,resolution:this.context.viewport.resolution,fp64:this.use64bitPositions(),dataChanged:o.dataChanged,full3d:e._full3d}),this.setState({numInstances:i.instanceCount,startIndices:i.vertexStarts}),o.dataChanged||this.getAttributeManager().invalidateAll()}}_getModels(){let{id:e,filled:r,extruded:o}=this.props,n,i,s;if(r){let a=this.getShaders("top");a.defines.NON_INSTANCED_MODEL=1;let c=this.getAttributeManager().getBufferLayouts({isInstanced:!1});n=new Q(this.context.device,{...a,id:`${e}-top`,topology:"triangle-list",bufferLayout:c,isIndexed:!0,userData:{excludeAttributes:{instanceVertexValid:!0}}})}if(o){let a=this.getAttributeManager().getBufferLayouts({isInstanced:!0});i=new Q(this.context.device,{...this.getShaders("side"),id:`${e}-side`,bufferLayout:a,geometry:new ce({topology:"triangle-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,1,1,0,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}}),s=new Q(this.context.device,{...this.getShaders("side"),id:`${e}-wireframe`,bufferLayout:a,geometry:new ce({topology:"line-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,0,1,1,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}})}return{models:[i,s,n].filter(Boolean),topModel:n,sideModel:i,wireframeModel:s}}calculateIndices(e){let{polygonTesselator:r}=this.state;e.startIndices=r.indexStarts,e.value=r.get("indices")}calculatePositions(e){let{polygonTesselator:r}=this.state;e.startIndices=r.vertexStarts,e.value=r.get("positions")}calculateVertexValid(e){e.value=this.state.polygonTesselator.get("vertexValid")}};vd.defaultProps=Ate;vd.layerName="SolidPolygonLayer";var Ti=vd;function _0({data:t,getIndex:e,dataRange:r,replace:o}){let{startRow:n=0,endRow:i=1/0}=r,s=t.length,a=s,c=s;for(let d=0;d<s;d++){let h=e(t[d]);if(a>d&&h>=n&&(a=d),h>=i){c=d;break}}let l=a,u=c-a!==o.length?t.slice(c):void 0;for(let d=0;d<o.length;d++)t[l++]=o[d];if(u){for(let d=0;d<u.length;d++)t[l++]=u[d];t.length=l}return{startRow:a,endRow:a+o.length}}var ZF=[0,0,0,255],Tte=[0,0,0,255],vte={stroked:!0,filled:!0,extruded:!1,elevationScale:1,wireframe:!1,_normalize:!0,_windingOrder:"CW",lineWidthUnits:"meters",lineWidthScale:1,lineWidthMinPixels:0,lineWidthMaxPixels:Number.MAX_SAFE_INTEGER,lineJointRounded:!1,lineMiterLimit:4,getPolygon:{type:"accessor",value:t=>t.polygon},getFillColor:{type:"accessor",value:Tte},getLineColor:{type:"accessor",value:ZF},getLineWidth:{type:"accessor",value:1},getElevation:{type:"accessor",value:1e3},material:!0},Sd=class extends Ne{initializeState(){this.state={paths:[],pathsDiff:null},this.props.getLineDashArray&&N.removed("getLineDashArray","PathStyleExtension")()}updateState({changeFlags:e}){let r=e.dataChanged||e.updateTriggersChanged&&(e.updateTriggersChanged.all||e.updateTriggersChanged.getPolygon);if(r&&Array.isArray(e.dataChanged)){let o=this.state.paths.slice(),n=e.dataChanged.map(i=>_0({data:o,getIndex:s=>s.__source.index,dataRange:i,replace:this._getPaths(i)}));this.setState({paths:o,pathsDiff:n})}else r&&this.setState({paths:this._getPaths(),pathsDiff:null})}_getPaths(e={}){let{data:r,getPolygon:o,positionFormat:n,_normalize:i}=this.props,s=[],a=n==="XY"?2:3,{startRow:c,endRow:l}=e,{iterable:f,objectInfo:u}=Fe(r,c,l);for(let d of f){u.index++;let h=o(d,u);i&&(h=h0(h,a));let{holeIndices:p}=h,m=h.positions||h;if(p)for(let g=0;g<=p.length;g++){let _=m.slice(p[g-1]||0,p[g]||m.length);s.push(this.getSubLayerRow({path:_},d,u.index))}else s.push(this.getSubLayerRow({path:m},d,u.index))}return s}renderLayers(){let{data:e,_dataDiff:r,stroked:o,filled:n,extruded:i,wireframe:s,_normalize:a,_windingOrder:c,elevationScale:l,transitions:f,positionFormat:u}=this.props,{lineWidthUnits:d,lineWidthScale:h,lineWidthMinPixels:p,lineWidthMaxPixels:m,lineJointRounded:g,lineMiterLimit:_,lineDashJustified:x}=this.props,{getFillColor:y,getLineColor:b,getLineWidth:T,getLineDashArray:v,getElevation:w,getPolygon:C,updateTriggers:S,material:A}=this.props,{paths:M,pathsDiff:B}=this.state,O=this.getSubLayerClass("fill",Ti),F=this.getSubLayerClass("stroke",Go),X=this.shouldRenderSubLayer("fill",M)&&new O({_dataDiff:r,extruded:i,elevationScale:l,filled:n,wireframe:s,_normalize:a,_windingOrder:c,getElevation:w,getFillColor:y,getLineColor:i&&s?b:ZF,material:A,transitions:f},this.getSubLayerProps({id:"fill",updateTriggers:S&&{getPolygon:S.getPolygon,getElevation:S.getElevation,getFillColor:S.getFillColor,lineColors:i&&s,getLineColor:S.getLineColor}}),{data:e,positionFormat:u,getPolygon:C}),G=!i&&o&&this.shouldRenderSubLayer("stroke",M)&&new F({_dataDiff:B&&(()=>B),widthUnits:d,widthScale:h,widthMinPixels:p,widthMaxPixels:m,jointRounded:g,miterLimit:_,dashJustified:x,_pathType:"loop",transitions:f&&{getWidth:f.getLineWidth,getColor:f.getLineColor,getPath:f.getPolygon},getColor:this.getSubLayerAccessor(b),getWidth:this.getSubLayerAccessor(T),getDashArray:this.getSubLayerAccessor(v)},this.getSubLayerProps({id:"stroke",updateTriggers:S&&{getWidth:S.getLineWidth,getColor:S.getLineColor,getDashArray:S.getLineDashArray}}),{data:M,positionFormat:u,getPath:j=>j.path});return[!i&&X,G,i&&X]}};Sd.layerName="PolygonLayer";Sd.defaultProps=vte;var vi=Sd;function JF(t,e){if(!t)return null;let r="startIndices"in t?t.startIndices[e]:e,o=t.featureIds.value[r];return r!==-1?Ste(t,o,r):null}function Ste(t,e,r){let o={properties:{...t.properties[e]}};for(let n in t.numericProps)o.properties[n]=t.numericProps[n].value[r];return o}function QF(t,e){let r={points:null,lines:null,polygons:null};for(let o in r){let n=t[o].globalFeatureIds.value;r[o]=new Uint8ClampedArray(n.length*4);let i=[];for(let s=0;s<n.length;s++)e(n[s],i),r[o][s*4+0]=i[0],r[o][s*4+1]=i[1],r[o][s*4+2]=i[2],r[o][s*4+3]=255}return r}var eN=`layout(std140) uniform sdfUniforms { float gamma; bool enabled; float buffer; float outlineBuffer; vec4 outlineColor; } sdf; `,tN={name:"sdf",vs:eN,fs:eN,uniformTypes:{gamma:"f32",enabled:"f32",buffer:"f32",outlineBuffer:"f32",outlineColor:"vec4<f32>"}};var Cd={none:0,start:1,center:2,end:3},Cte=`layout(std140) uniform textUniforms { highp vec2 cutoffPixels; highp ivec2 align; highp float fontSize; bool flipY; } text; #define ALIGN_MODE_START ${Cd.start} #define ALIGN_MODE_CENTER ${Cd.center} #define ALIGN_MODE_END ${Cd.end} `,y0={name:"text",vs:Cte,getUniforms:({contentCutoffPixels:t=[0,0],contentAlignHorizontal:e="none",contentAlignVertical:r="none",fontSize:o,viewport:n})=>({cutoffPixels:t,align:[Cd[e],Cd[r]],fontSize:o,flipY:n?.flipY??!1}),uniformTypes:{cutoffPixels:"vec2<f32>",align:"vec2<i32>",fontSize:"f32",flipY:"f32"}};var rN=`#version 300 es #define SHADER_NAME multi-icon-layer-vertex-shader in vec2 positions; in vec3 instancePositions; in vec3 instancePositions64Low; in float instanceSizes; in float instanceAngles; in vec4 instanceColors; in vec3 instancePickingColors; in vec4 instanceIconFrames; in float instanceColorModes; in vec2 instanceOffsets; in vec2 instancePixelOffset; in vec4 instanceClipRect; out float vColorMode; out vec4 vColor; out vec2 vTextureCoords; out vec2 uv; vec2 rotate_by_angle(vec2 vertex, float angle) { float angle_radian = angle * PI / 180.0; float cos_angle = cos(angle_radian); float sin_angle = sin(angle_radian); mat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle); return rotationMatrix * vertex; } float getPixelOffsetFromAlignment(float anchor, float extent, float clipStart, float clipEnd, int mode) { if (clipEnd < clipStart) return 0.0; if (mode == ALIGN_MODE_START) { return max(- (anchor + clipStart), 0.0); } if (mode == ALIGN_MODE_CENTER) { float _min = max(0., anchor + clipStart); float _max = min(extent, anchor + clipEnd); return _min < _max ? (_min + _max) / 2.0 - anchor : 0.0; } if (mode == ALIGN_MODE_END) { return min(extent - (anchor + clipEnd), 0.); } return 0.0; } void main(void) { geometry.worldPosition = instancePositions; geometry.uv = positions; geometry.pickingColor = instancePickingColors; uv = positions; vec2 iconSize = instanceIconFrames.zw; float sizePixels = clamp( project_size_to_pixel(instanceSizes * icon.sizeScale, icon.sizeUnits), icon.sizeMinPixels, icon.sizeMaxPixels ); float instanceScale = sizePixels / text.fontSize; vec2 pixelOffset = positions / 2.0 * iconSize + instanceOffsets; pixelOffset = rotate_by_angle(pixelOffset, instanceAngles) * instanceScale; pixelOffset += instancePixelOffset; pixelOffset.y *= -1.0; vec2 anchorPosScreen; if (icon.billboard) { gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position); anchorPosScreen = gl_Position.xy / gl_Position.w; DECKGL_FILTER_GL_POSITION(gl_Position, geometry); vec3 offset = vec3(pixelOffset, 0.0); DECKGL_FILTER_SIZE(offset, geometry); gl_Position.xy += project_pixel_size_to_clipspace(offset.xy); } else { vec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0); if (text.flipY) { offset_common.y *= -1.; } DECKGL_FILTER_SIZE(offset_common, geometry); vec4 anchorPos = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0)); anchorPosScreen = anchorPos.xy / anchorPos.w; gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position); DECKGL_FILTER_GL_POSITION(gl_Position, geometry); } anchorPosScreen = vec2(anchorPosScreen.x + 1.0, 1.0 - anchorPosScreen.y) / 2.0 * project.viewportSize / project.devicePixelRatio; vec2 xy = project_size_to_pixel(instanceClipRect.xy); vec2 wh = project_size_to_pixel(instanceClipRect.zw); if (text.flipY) { xy.y = -xy.y - wh.y; } if (text.align.x > 0 || text.align.y > 0) { vec2 viewportPixels = project.viewportSize / project.devicePixelRatio; vec2 scrollPixels = vec2( getPixelOffsetFromAlignment(anchorPosScreen.x, viewportPixels.x, xy.x, xy.x + wh.x, text.align.x), -getPixelOffsetFromAlignment(anchorPosScreen.y, viewportPixels.y, -xy.y - wh.y, -xy.y, text.align.y) ); pixelOffset += scrollPixels; gl_Position.xy += project_pixel_size_to_clipspace(scrollPixels); } if (instanceClipRect.z >= 0.) { if (pixelOffset.x < xy.x || pixelOffset.x > xy.x + wh.x) { gl_Position = vec4(0.0); } else if (text.cutoffPixels.x > 0.) { float vpWidth = project.viewportSize.x / project.devicePixelRatio; float l = max(anchorPosScreen.x + xy.x, 0.0); float r = min(anchorPosScreen.x + xy.x + wh.x, vpWidth); if (r - l < text.cutoffPixels.x) { gl_Position = vec4(0.0); } } } if (instanceClipRect.w >= 0.) { if (pixelOffset.y < xy.y || pixelOffset.y > xy.y + wh.y) { gl_Position = vec4(0.0); } else if (text.cutoffPixels.y > 0.) { float vpHeight = project.viewportSize.y / project.devicePixelRatio; float t = max(anchorPosScreen.y - xy.y - wh.y, 0.0); float b = min(anchorPosScreen.y - xy.y, vpHeight); if (b - t < text.cutoffPixels.y) { gl_Position = vec4(0.0); } } } vTextureCoords = mix( instanceIconFrames.xy, instanceIconFrames.xy + iconSize, (positions.xy + 1.0) / 2.0 ) / icon.iconsTextureDim; vColor = instanceColors; DECKGL_FILTER_COLOR(vColor, geometry); vColorMode = instanceColorModes; } `;var oN=`#version 300 es #define SHADER_NAME multi-icon-layer-fragment-shader precision highp float; uniform sampler2D iconsTexture; in vec4 vColor; in vec2 vTextureCoords; in vec2 uv; out vec4 fragColor; void main(void) { geometry.uv = uv; if (!bool(picking.isActive)) { float alpha = texture(iconsTexture, vTextureCoords).a; vec4 color = vColor; if (sdf.enabled) { float distance = alpha; alpha = smoothstep(sdf.buffer - sdf.gamma, sdf.buffer + sdf.gamma, distance); if (sdf.outlineBuffer > 0.0) { float inFill = alpha; float inBorder = smoothstep(sdf.outlineBuffer - sdf.gamma, sdf.outlineBuffer + sdf.gamma, distance); color = mix(sdf.outlineColor, vColor, inFill); alpha = inBorder; } } float a = alpha * color.a; if (a < icon.alphaCutoff) { discard; } fragColor = vec4(color.rgb, a * layer.opacity); } DECKGL_FILTER_COLOR(fragColor, geometry); } `;var RS=192/256;var Ete={getIconOffsets:{type:"accessor",value:t=>t.offsets},getContentBox:{type:"accessor",value:[0,0,-1,-1]},fontSize:1,alphaCutoff:.001,smoothing:.1,outlineWidth:0,outlineColor:{type:"color",value:[0,0,0,255]},contentCutoffPixels:{type:"array",value:[0,0]},contentAlignHorizontal:"none",contentAlignVertical:"none"},Ed=class extends Ec{getShaders(){let e=super.getShaders();return{...e,modules:[...e.modules,y0,tN],vs:rN,fs:oN}}initializeState(){super.initializeState();let e=this.getAttributeManager(),r=e.attributes.instanceIconDefs;r.settings.update=this.calculateInstanceIconDefs,e.addInstanced({instancePickingColors:{type:"uint8",size:4,accessor:(o,{index:n,target:i})=>this.encodePickingColor(n,i)},instanceClipRect:{size:4,accessor:"getContentBox",defaultValue:[0,0,-1,-1]}})}updateState(e){super.updateState(e);let{props:r,oldProps:o,changeFlags:n}=e,{outlineColor:i}=r;if(n.updateTriggersChanged&&(n.updateTriggersChanged.getIcon||n.updateTriggersChanged.getIconOffsets)&&this.getAttributeManager().invalidate("instanceIconDefs"),i!==o.outlineColor){let s=[i[0]/255,i[1]/255,i[2]/255,(i[3]??255)/255];this.setState({outlineColor:s})}!r.sdf&&r.outlineWidth&&N.warn(`${this.id}: fontSettings.sdf is required to render outline`)()}draw(e){let{sdf:r,smoothing:o,fontSize:n,outlineWidth:i,contentCutoffPixels:s,contentAlignHorizontal:a,contentAlignVertical:c}=this.props,{outlineColor:l}=this.state,f=i?Math.max(o,RS*(1-i)):-1,u=this.state.model,d={buffer:RS,outlineBuffer:f,gamma:o,enabled:Boolean(r),outlineColor:l},h={contentCutoffPixels:s,contentAlignHorizontal:a,contentAlignVertical:c,fontSize:n,viewport:this.context.viewport};if(u.shaderInputs.setProps({sdf:d,text:h}),super.draw(e),r&&i){let{iconManager:p}=this.state;p.getTexture()&&(u.shaderInputs.setProps({sdf:{...d,outlineBuffer:RS}}),u.draw(this.context.renderPass))}}calculateInstanceIconDefs(e,{startRow:r,endRow:o}){let{data:n,getIcon:i,getIconOffsets:s}=this.props,a=e.getVertexOffset(r),c=e.value,{iterable:l,objectInfo:f}=Fe(n,r,o);for(let u of l){f.index++;let d=i(u,f),h=s(u,f);if(d){let p=0;for(let m of Array.from(d)){let g=super.getInstanceIconDef(m);g[0]=h[p*2],g[1]+=h[p*2+1],g[6]=1,c.set(g,a),a+=e.size,p++}}}}};Ed.defaultProps=Ete;Ed.layerName="MultiIconLayer";var x0=Ed;var wd=class{constructor({fontSize:e=24,buffer:r=3,radius:o=8,cutoff:n=.25,fontFamily:i="sans-serif",fontWeight:s="normal",fontStyle:a="normal"}={}){this.buffer=r,this.cutoff=n,this.radius=o;let c=this.size=e+r*4,l=this._createCanvas(c),f=this.ctx=l.getContext("2d",{willReadFrequently:!0});f.font=`${a} ${s} ${e}px ${i}`,f.textBaseline="alphabetic",f.textAlign="left",f.fillStyle="black",this.gridOuter=new Float64Array(c*c),this.gridInner=new Float64Array(c*c),this.f=new Float64Array(c),this.z=new Float64Array(c+1),this.v=new Uint16Array(c)}_createCanvas(e){let r=document.createElement("canvas");return r.width=r.height=e,r}draw(e){let{width:r,actualBoundingBoxAscent:o,actualBoundingBoxDescent:n,actualBoundingBoxLeft:i,actualBoundingBoxRight:s}=this.ctx.measureText(e),a=Math.ceil(o),c=0,l=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(s-i))),f=Math.min(this.size-this.buffer,a+Math.ceil(n)),u=l+2*this.buffer,d=f+2*this.buffer,h=Math.max(u*d,0),p=new Uint8ClampedArray(h),m={data:p,width:u,height:d,glyphWidth:l,glyphHeight:f,glyphTop:a,glyphLeft:c,glyphAdvance:r};if(l===0||f===0)return m;let{ctx:g,buffer:_,gridInner:x,gridOuter:y}=this;g.clearRect(_,_,l,f),g.fillText(e,_,_+a);let b=g.getImageData(_,_,l,f);y.fill(1e20,0,h),x.fill(0,0,h);for(let T=0;T<f;T++)for(let v=0;v<l;v++){let w=b.data[4*(T*l+v)+3]/255;if(w===0)continue;let C=(T+_)*u+v+_;if(w===1)y[C]=0,x[C]=1e20;else{let S=.5-w;y[C]=S>0?S*S:0,x[C]=S<0?S*S:0}}nN(y,0,0,u,d,u,this.f,this.v,this.z),nN(x,_,_,l,f,u,this.f,this.v,this.z);for(let T=0;T<h;T++){let v=Math.sqrt(y[T])-Math.sqrt(x[T]);p[T]=Math.round(255-255*(v/this.radius+this.cutoff))}return m}};function nN(t,e,r,o,n,i,s,a,c){for(let l=e;l<e+o;l++)iN(t,r*i+l,i,n,s,a,c);for(let l=r;l<r+n;l++)iN(t,l*i+e,1,o,s,a,c)}function iN(t,e,r,o,n,i,s){i[0]=0,s[0]=-1e20,s[1]=1e20,n[0]=t[e];for(let a=1,c=0,l=0;a<o;a++){n[a]=t[e+a*r];let f=a*a;do{let u=i[c];l=(n[a]-n[u]+f-u*u)/(a-u)/2}while(l<=s[c]&&--c>-1);c++,i[c]=a,s[c]=l,s[c+1]=1e20}for(let a=0,c=0;a<o;a++){for(;s[c+1]<a;)c++;let l=i[c],f=a-l;t[e+a*r]=n[l]+f*f}}var wte=32,Pte=[];function Mte(t){return Math.pow(2,Math.ceil(Math.log2(t)))}function sN({characterSet:t,measureText:e,buffer:r,maxCanvasWidth:o,mapping:n={},xOffset:i=0,yOffsetMin:s=0,yOffsetMax:a=0}){let l=i,f=s,u=a;for(let d of t)if(!n[d]){let{advance:h,width:p,ascent:m,descent:g}=e(d),_=m+g;l+p+r*2>o&&(l=0,f=u),n[d]={x:l+r,y:f+r,width:p,height:_,advance:h,anchorX:p/2,anchorY:m},l+=p+r*2,u=Math.max(u,f+_+r*2)}return{mapping:n,xOffset:l,yOffsetMin:f,yOffsetMax:u,canvasHeight:Mte(u)}}function aN(t,e,r,o){let n=0;for(let i=e;i<r;i++){let s=t[i];n+=o[s]?.advance||0}return n}function cN(t,e,r,o,n,i){let s=e,a=0;for(let c=e;c<r;c++){let l=aN(t,c,c+1,n);a+l>o&&(s<c&&i.push(c),s=c,a=0),a+=l}return a}function Rte(t,e,r,o,n,i){let s=e,a=e,c=e,l=0;for(let f=e;f<r;f++)if((t[f]===" "||t[f+1]===" "||f+1===r)&&(c=f+1),c>a){let u=aN(t,a,c,n);l+u>o&&(s<a&&(i.push(a),s=a,l=0),u>o&&(u=cN(t,a,c,o,n,i),s=i[i.length-1])),a=c,l+=u}return l}function Ite(t,e,r,o,n=0,i){i===void 0&&(i=t.length);let s=[];return e==="break-all"?cN(t,n,i,r,o,s):Rte(t,n,i,r,o,s),s}function Lte(t,e,r,o,n,i){let s=0,a=0;for(let c=e;c<r;c++){let l=t[c],f=o[l];f&&(a=Math.max(a,f.height))}for(let c=e;c<r;c++){let l=t[c],f=o[l];f?(n[c]=s+f.anchorX,s+=f.advance):(N.warn(`Missing character: ${l} (${l.codePointAt(0)})`)(),n[c]=s,s+=wte)}i[0]=s,i[1]=a}function lN(t,e,r,o,n,i){let s=Array.from(t),a=s.length,c=new Array(a),l=new Array(a),f=new Array(a),u=(o==="break-word"||o==="break-all")&&isFinite(n)&&n>0,d=[0,0],h=[0,0],p=0,m=e+r/2,g=0,_=0;for(let x=0;x<=a;x++){let y=s[x];if((y===` `||x===a)&&(_=x),_>g){let b=u?Ite(s,o,n,i,g,_):Pte;for(let T=0;T<=b.length;T++){let v=T===0?g:b[T-1],w=T<b.length?b[T]:_;Lte(s,v,w,i,c,h);for(let C=v;C<w;C++)l[C]=m,f[C]=h[0];p++,m+=r,d[0]=Math.max(d[0],h[0])}g=_}y===` `&&(c[g]=0,l[g]=0,f[g]=0,g++)}return d[1]=p*r,{x:c,y:l,rowWidth:f,size:d}}function fN({value:t,length:e,stride:r,offset:o,startIndices:n,characterSet:i}){let s=t.BYTES_PER_ELEMENT,a=r?r/s:1,c=o?o/s:0,l=n[e]||Math.ceil((t.length-c)/a),f=i&&new Set,u=new Array(e),d=t;if(a>1||c>0){let h=t.constructor;d=new h(l);for(let p=0;p<l;p++)d[p]=t[p*a+c]}for(let h=0;h<e;h++){let p=n[h],m=n[h+1]||l,g=d.subarray(p,m);u[h]=String.fromCodePoint.apply(null,g),f&&g.forEach(f.add,f)}if(f)for(let h of f)i.add(String.fromCodePoint(h));return{texts:u,characterCount:l}}var Ic=class{constructor(e=5){this._cache={},this._order=[],this.limit=e}get(e){let r=this._cache[e];return r&&(this._deleteOrder(e),this._appendOrder(e)),r}set(e,r){this._cache[e]?(this.delete(e),this._cache[e]=r,this._appendOrder(e)):(Object.keys(this._cache).length===this.limit&&this.delete(this._order[0]),this._cache[e]=r,this._appendOrder(e))}delete(e){this._cache[e]&&(delete this._cache[e],this._deleteOrder(e))}_deleteOrder(e){let r=this._order.indexOf(e);r>=0&&this._order.splice(r,1)}_appendOrder(e){this._order.push(e)}};function Bte(){let t=[];for(let e=32;e<128;e++)t.push(String.fromCharCode(e));return t}var Bs={fontFamily:"Monaco, monospace",fontWeight:"normal",characterSet:Bte(),fontSize:64,buffer:4,sdf:!1,cutoff:.25,radius:12,smoothing:.1},uN=1024,dN=.9,hN=.3,mN=3,b0=new Ic(mN);function Ote(t,e){let r;typeof e=="string"?r=new Set(Array.from(e)):r=new Set(e);let o=b0.get(t);if(!o)return r;for(let n in o.mapping)r.has(n)&&r.delete(n);return r}function Fte(t,e){for(let r=0;r<t.length;r++)e.data[4*r+3]=t[r]}function pN(t,e,r,o){t.font=`${o} ${r}px ${e}`,t.fillStyle="#000",t.textBaseline="alphabetic",t.textAlign="left"}function Nte(t,e,r){if(r===void 0){let n=t.measureText("A");return n.fontBoundingBoxAscent?{advance:0,width:0,ascent:Math.ceil(n.fontBoundingBoxAscent),descent:Math.ceil(n.fontBoundingBoxDescent)}:{advance:0,width:0,ascent:e*dN,descent:e*hN}}let o=t.measureText(r);return o.actualBoundingBoxAscent?{advance:o.width,width:Math.ceil(o.actualBoundingBoxRight-o.actualBoundingBoxLeft),ascent:Math.ceil(o.actualBoundingBoxAscent),descent:Math.ceil(o.actualBoundingBoxDescent)}:{advance:o.width,width:o.width,ascent:e*dN,descent:e*hN}}function gN(t){N.assert(Number.isFinite(t)&&t>=mN,"Invalid cache limit"),b0=new Ic(t)}var Pd=class{constructor(){this.props={...Bs}}get atlas(){return this._atlas}get mapping(){return this._atlas&&this._atlas.mapping}setProps(e={}){Object.assign(this.props,e),e._getFontRenderer&&(this._getFontRenderer=e._getFontRenderer),this._key=this._getKey();let r=Ote(this._key,this.props.characterSet),o=b0.get(this._key);if(o&&r.size===0){this._atlas!==o&&(this._atlas=o);return}let n=this._generateFontAtlas(r,o);this._atlas=n,b0.set(this._key,n)}_generateFontAtlas(e,r){let{fontFamily:o,fontWeight:n,fontSize:i,buffer:s,sdf:a,radius:c,cutoff:l}=this.props,f=r&&r.data;f||(f=document.createElement("canvas"),f.width=uN);let u=f.getContext("2d",{willReadFrequently:!0});pN(u,o,i,n);let d=b=>Nte(u,i,b),h;this._getFontRenderer?h=this._getFontRenderer(this.props):a&&(h={measure:d,draw:Dte(this.props)});let{mapping:p,canvasHeight:m,xOffset:g,yOffsetMin:_,yOffsetMax:x}=sN({measureText:b=>h?h.measure(b):d(b),buffer:s,characterSet:e,maxCanvasWidth:uN,...r&&{mapping:r.mapping,xOffset:r.xOffset,yOffsetMin:r.yOffsetMin,yOffsetMax:r.yOffsetMax}});if(f.height!==m){let b=f.height>0?u.getImageData(0,0,f.width,f.height):null;f.height=m,b&&u.putImageData(b,0,0)}if(pN(u,o,i,n),h)for(let b of e){let T=p[b],{data:v,left:w=0,top:C=0}=h.draw(b),S=T.x-w,A=T.y-C,M=Math.max(0,Math.round(S)),B=Math.max(0,Math.round(A)),O=Math.min(v.width,f.width-M),F=Math.min(v.height,f.height-B);u.putImageData(v,M,B,0,0,O,F),T.x+=M-S,T.y+=B-A}else for(let b of e){let T=p[b];u.fillText(b,T.x,T.y+T.anchorY)}let y=h?h.measure():d();return{baselineOffset:(y.ascent-y.descent)/2,xOffset:g,yOffsetMin:_,yOffsetMax:x,mapping:p,data:f,width:f.width,height:f.height}}_getKey(){let{fontFamily:e,fontWeight:r,fontSize:o,buffer:n,sdf:i,radius:s,cutoff:a}=this.props;return i?`${e} ${r} ${o} ${n} ${s} ${a}`:`${e} ${r} ${o} ${n}`}};function Dte({fontSize:t,buffer:e,radius:r,cutoff:o,fontFamily:n,fontWeight:i}){let s=new wd({fontSize:t,buffer:e,radius:r,cutoff:o,fontFamily:n,fontWeight:`${i}`});return a=>{let{data:c,width:l,height:f}=s.draw(a),u=new ImageData(l,f);return Fte(c,u),{data:u,left:e,top:e}}}var _N=`layout(std140) uniform textBackgroundUniforms { bool billboard; float sizeScale; float sizeMinPixels; float sizeMaxPixels; vec4 borderRadius; vec4 padding; highp int sizeUnits; bool stroked; } textBackground; `,yN={name:"textBackground",vs:_N,fs:_N,uniformTypes:{billboard:"f32",sizeScale:"f32",sizeMinPixels:"f32",sizeMaxPixels:"f32",borderRadius:"vec4<f32>",padding:"vec4<f32>",sizeUnits:"i32",stroked:"f32"}};var xN=`#version 300 es #define SHADER_NAME text-background-layer-vertex-shader in vec2 positions; in vec3 instancePositions; in vec3 instancePositions64Low; in vec4 instanceRects; in vec4 instanceClipRect; in float instanceSizes; in float instanceAngles; in vec2 instancePixelOffsets; in float instanceLineWidths; in vec4 instanceFillColors; in vec4 instanceLineColors; in vec3 instancePickingColors; out vec4 vFillColor; out vec4 vLineColor; out float vLineWidth; out vec2 uv; out vec2 dimensions; vec2 rotate_by_angle(vec2 vertex, float angle) { float angle_radian = radians(angle); float cos_angle = cos(angle_radian); float sin_angle = sin(angle_radian); mat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle); return rotationMatrix * vertex; } void main(void) { geometry.worldPosition = instancePositions; geometry.uv = positions; geometry.pickingColor = instancePickingColors; uv = positions; vLineWidth = instanceLineWidths; float sizePixels = clamp( project_size_to_pixel(instanceSizes * textBackground.sizeScale, textBackground.sizeUnits), textBackground.sizeMinPixels, textBackground.sizeMaxPixels ); float instanceScale = sizePixels / text.fontSize; dimensions = instanceRects.zw * instanceScale + textBackground.padding.xy + textBackground.padding.zw; vec2 pixelOffset = (positions * instanceRects.zw + instanceRects.xy) * instanceScale + mix(-textBackground.padding.xy, textBackground.padding.zw, positions); pixelOffset = rotate_by_angle(pixelOffset, instanceAngles); pixelOffset += instancePixelOffsets; pixelOffset.y *= -1.0; vec2 xy = project_size_to_pixel(instanceClipRect.xy); vec2 wh = project_size_to_pixel(instanceClipRect.zw); if (text.flipY) { xy.y = -xy.y - wh.y; } if (instanceClipRect.z >= 0.0) { dimensions.x = wh.x; pixelOffset.x = xy.x + uv.x * wh.x + mix(-textBackground.padding.x, textBackground.padding.z, uv.x); } if (instanceClipRect.w >= 0.0) { dimensions.y = wh.y; pixelOffset.y = xy.y + uv.y * wh.y + mix(-textBackground.padding.y, textBackground.padding.w, uv.y); } if (textBackground.billboard) { gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position); DECKGL_FILTER_GL_POSITION(gl_Position, geometry); vec3 offset = vec3(pixelOffset, 0.0); DECKGL_FILTER_SIZE(offset, geometry); gl_Position.xy += project_pixel_size_to_clipspace(offset.xy); } else { vec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0); if (text.flipY) { offset_common.y *= -1.; } DECKGL_FILTER_SIZE(offset_common, geometry); gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position); DECKGL_FILTER_GL_POSITION(gl_Position, geometry); } vFillColor = vec4(instanceFillColors.rgb, instanceFillColors.a * layer.opacity); DECKGL_FILTER_COLOR(vFillColor, geometry); vLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * layer.opacity); DECKGL_FILTER_COLOR(vLineColor, geometry); } `;var bN=`#version 300 es #define SHADER_NAME text-background-layer-fragment-shader precision highp float; in vec4 vFillColor; in vec4 vLineColor; in float vLineWidth; in vec2 uv; in vec2 dimensions; out vec4 fragColor; float round_rect(vec2 p, vec2 size, vec4 radii) { vec2 pixelPositionCB = (p - 0.5) * size; vec2 sizeCB = size * 0.5; float maxBorderRadius = min(size.x, size.y) * 0.5; vec4 borderRadius = vec4(min(radii, maxBorderRadius)); borderRadius.xy = (pixelPositionCB.x > 0.0) ? borderRadius.xy : borderRadius.zw; borderRadius.x = (pixelPositionCB.y > 0.0) ? borderRadius.x : borderRadius.y; vec2 q = abs(pixelPositionCB) - sizeCB + borderRadius.x; return -(min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - borderRadius.x); } float rect(vec2 p, vec2 size) { vec2 pixelPosition = p * size; return min(min(pixelPosition.x, size.x - pixelPosition.x), min(pixelPosition.y, size.y - pixelPosition.y)); } vec4 get_stroked_fragColor(float dist) { float isBorder = smoothedge(dist, vLineWidth); return mix(vFillColor, vLineColor, isBorder); } void main(void) { geometry.uv = uv; if (textBackground.borderRadius != vec4(0.0)) { float distToEdge = round_rect(uv, dimensions, textBackground.borderRadius); float shapeAlpha = smoothedge(-distToEdge, 0.0); if (shapeAlpha == 0.0) { discard; } if (textBackground.stroked) { fragColor = get_stroked_fragColor(distToEdge); } else { fragColor = vFillColor; } fragColor.a *= shapeAlpha; } else { if (textBackground.stroked) { float distToEdge = rect(uv, dimensions); fragColor = get_stroked_fragColor(distToEdge); } else { fragColor = vFillColor; } } DECKGL_FILTER_COLOR(fragColor, geometry); } `;var Ute={billboard:!0,sizeScale:1,sizeUnits:"pixels",sizeMinPixels:0,sizeMaxPixels:Number.MAX_SAFE_INTEGER,fontSize:1,borderRadius:{type:"object",value:0},padding:{type:"array",value:[0,0,0,0]},getPosition:{type:"accessor",value:t=>t.position},getSize:{type:"accessor",value:1},getAngle:{type:"accessor",value:0},getPixelOffset:{type:"accessor",value:[0,0]},getBoundingRect:{type:"accessor",value:[0,0,0,0]},getClipRect:{type:"accessor",value:[0,0,-1,-1]},getFillColor:{type:"accessor",value:[0,0,0,255]},getLineColor:{type:"accessor",value:[0,0,0,255]},getLineWidth:{type:"accessor",value:1}},Md=class extends _e{getShaders(){return super.getShaders({vs:xN,fs:bN,modules:[fe,Se,yN,y0]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceSizes:{size:1,transition:!0,accessor:"getSize",defaultValue:1},instanceAngles:{size:1,transition:!0,accessor:"getAngle"},instanceRects:{size:4,accessor:"getBoundingRect"},instanceClipRect:{size:4,accessor:"getClipRect",defaultValue:[0,0,-1,-1]},instancePixelOffsets:{size:2,transition:!0,accessor:"getPixelOffset"},instanceFillColors:{size:4,transition:!0,type:"unorm8",accessor:"getFillColor",defaultValue:[0,0,0,255]},instanceLineColors:{size:4,transition:!0,type:"unorm8",accessor:"getLineColor",defaultValue:[0,0,0,255]},instanceLineWidths:{size:1,transition:!0,accessor:"getLineWidth",defaultValue:1}})}updateState(e){super.updateState(e);let{changeFlags:r}=e;r.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){let{billboard:r,sizeScale:o,sizeUnits:n,sizeMinPixels:i,sizeMaxPixels:s,getLineWidth:a,fontSize:c}=this.props,{padding:l,borderRadius:f}=this.props;l.length<4&&(l=[l[0],l[1],l[0],l[1]]),Array.isArray(f)||(f=[f,f,f,f]);let u=this.state.model,d={billboard:r,stroked:Boolean(a),borderRadius:f,padding:l,sizeUnits:Pe[n],sizeScale:o,sizeMinPixels:i,sizeMaxPixels:s},h={fontSize:c,viewport:this.context.viewport};u.shaderInputs.setProps({textBackground:d,text:h}),u.draw(this.context.renderPass)}_getModel(){let e=[0,0,1,0,0,1,1,1];return new Q(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new ce({topology:"triangle-strip",vertexCount:4,attributes:{positions:{size:2,value:new Float32Array(e)}}}),isInstanced:!0})}};Md.defaultProps=Ute;Md.layerName="TextBackgroundLayer";var A0=Md;var AN={start:1,middle:0,end:-1},TN={top:1,center:0,bottom:-1},IS=[0,0,0,255],kte=1,Vte={billboard:!0,sizeScale:1,sizeUnits:"pixels",sizeMinPixels:0,sizeMaxPixels:Number.MAX_SAFE_INTEGER,background:!1,getBackgroundColor:{type:"accessor",value:[255,255,255,255]},getBorderColor:{type:"accessor",value:IS},getBorderWidth:{type:"accessor",value:0},backgroundBorderRadius:{type:"object",value:0},backgroundPadding:{type:"array",value:[0,0,0,0]},characterSet:{type:"object",value:Bs.characterSet},fontFamily:Bs.fontFamily,fontWeight:Bs.fontWeight,lineHeight:kte,outlineWidth:{type:"number",value:0,min:0},outlineColor:{type:"color",value:IS},fontSettings:{type:"object",value:{},compare:1},wordBreak:"break-word",maxWidth:{type:"number",value:-1},contentCutoffPixels:{type:"array",value:[0,0]},contentAlignHorizontal:"none",contentAlignVertical:"none",getText:{type:"accessor",value:t=>t.text},getPosition:{type:"accessor",value:t=>t.position},getColor:{type:"accessor",value:IS},getSize:{type:"accessor",value:32},getAngle:{type:"accessor",value:0},getTextAnchor:{type:"accessor",value:"middle"},getAlignmentBaseline:{type:"accessor",value:"center"},getPixelOffset:{type:"accessor",value:[0,0]},getContentBox:{type:"accessor",value:[0,0,-1,-1]},backgroundColor:{deprecatedFor:["background","getBackgroundColor"]}},Rd=class extends Ne{constructor(){super(...arguments),this.getBoundingRect=(e,r)=>{let{size:[o,n]}=this.transformParagraph(e,r),{getTextAnchor:i,getAlignmentBaseline:s}=this.props,a=AN[typeof i=="function"?i(e,r):i],c=TN[typeof s=="function"?s(e,r):s];return[(a-1)*o/2,(c-1)*n/2,o,n]},this.getIconOffsets=(e,r)=>{let{getTextAnchor:o,getAlignmentBaseline:n}=this.props,{x:i,y:s,rowWidth:a,size:[,c]}=this.transformParagraph(e,r),l=AN[typeof o=="function"?o(e,r):o],f=TN[typeof n=="function"?n(e,r):n],u=i.length,d=new Array(u*2),h=0;for(let p=0;p<u;p++)d[h++]=(l-1)*a[p]/2+i[p],d[h++]=(f-1)*c/2+s[p];return d}}initializeState(){this.state={styleVersion:0,fontAtlasManager:new Pd},this.props.maxWidth>0&&N.once(1,"v8.9 breaking change: TextLayer maxWidth is now relative to text size")()}updateState(e){let{props:r,oldProps:o,changeFlags:n}=e;(n.dataChanged||n.updateTriggersChanged&&(n.updateTriggersChanged.all||n.updateTriggersChanged.getText))&&this._updateText(),(this._updateFontAtlas()||r.lineHeight!==o.lineHeight||r.wordBreak!==o.wordBreak||r.maxWidth!==o.maxWidth)&&this.setState({styleVersion:this.state.styleVersion+1})}getPickingInfo({info:e}){return e.object=e.index>=0?this.props.data[e.index]:null,e}_updateFontAtlas(){let{fontSettings:e,fontFamily:r,fontWeight:o,_getFontRenderer:n}=this.props,{fontAtlasManager:i,characterSet:s}=this.state,a={...e,characterSet:s,fontFamily:r,fontWeight:o,_getFontRenderer:n};if(!i.mapping)return i.setProps(a),!0;for(let c in a)if(a[c]!==i.props[c])return i.setProps(a),!0;return!1}_updateText(){let{data:e,characterSet:r}=this.props,o=e.attributes?.getText,{getText:n}=this.props,i=e.startIndices,s,a=r==="auto"&&new Set;if(o&&i){let{texts:c,characterCount:l}=fN({...ArrayBuffer.isView(o)?{value:o}:o,length:e.length,startIndices:i,characterSet:a});s=l,n=(f,{index:u})=>c[u]}else{let{iterable:c,objectInfo:l}=Fe(e);i=[0],s=0;for(let f of c){l.index++;let u=Array.from(n(f,l)||"");a&&u.forEach(a.add,a),s+=u.length,i.push(s)}}this.setState({getText:n,startIndices:i,numInstances:s,characterSet:a||r})}transformParagraph(e,r){let{fontAtlasManager:o}=this.state,n=o.mapping,{baselineOffset:i}=o.atlas,{fontSize:s}=o.props,a=this.state.getText,{wordBreak:c,lineHeight:l,maxWidth:f}=this.props,u=a(e,r)||"";return lN(u,i,l*s,c,f*s,n)}renderLayers(){let{startIndices:e,numInstances:r,getText:o,fontAtlasManager:{atlas:n,mapping:i},styleVersion:s}=this.state,{data:a,_dataDiff:c,getPosition:l,getColor:f,getSize:u,getAngle:d,getPixelOffset:h,getBackgroundColor:p,getBorderColor:m,getBorderWidth:g,getContentBox:_,backgroundBorderRadius:x,backgroundPadding:y,background:b,billboard:T,fontSettings:v,outlineWidth:w,outlineColor:C,sizeScale:S,sizeUnits:A,sizeMinPixels:M,sizeMaxPixels:B,contentCutoffPixels:O,contentAlignHorizontal:F,contentAlignVertical:X,transitions:G,updateTriggers:j}=this.props,se=this.getSubLayerClass("characters",x0),ne=this.getSubLayerClass("background",A0),{fontSize:pe}=this.state.fontAtlasManager.props;return[b&&new ne({getFillColor:p,getLineColor:m,getLineWidth:g,borderRadius:x,padding:y,getPosition:l,getSize:u,getAngle:d,getPixelOffset:h,getClipRect:_,billboard:T,sizeScale:S,sizeUnits:A,sizeMinPixels:M,sizeMaxPixels:B,fontSize:pe,transitions:G&&{getPosition:G.getPosition,getAngle:G.getAngle,getSize:G.getSize,getFillColor:G.getBackgroundColor,getLineColor:G.getBorderColor,getLineWidth:G.getBorderWidth,getPixelOffset:G.getPixelOffset}},this.getSubLayerProps({id:"background",updateTriggers:{getPosition:j.getPosition,getAngle:j.getAngle,getSize:j.getSize,getFillColor:j.getBackgroundColor,getLineColor:j.getBorderColor,getLineWidth:j.getBorderWidth,getPixelOffset:j.getPixelOffset,getBoundingRect:{getText:j.getText,getTextAnchor:j.getTextAnchor,getAlignmentBaseline:j.getAlignmentBaseline,styleVersion:s}}}),{data:a.attributes&&a.attributes.background?{length:a.length,attributes:a.attributes.background}:a,_dataDiff:c,autoHighlight:!1,getBoundingRect:this.getBoundingRect}),new se({sdf:v.sdf,smoothing:Number.isFinite(v.smoothing)?v.smoothing:Bs.smoothing,outlineWidth:w/(v.radius||Bs.radius),outlineColor:C,iconAtlas:n,iconMapping:i,getPosition:l,getColor:f,getSize:u,getAngle:d,getPixelOffset:h,getContentBox:_,billboard:T,sizeScale:S,sizeUnits:A,sizeMinPixels:M,sizeMaxPixels:B,fontSize:pe,contentCutoffPixels:O,contentAlignHorizontal:F,contentAlignVertical:X,transitions:G&&{getPosition:G.getPosition,getAngle:G.getAngle,getColor:G.getColor,getSize:G.getSize,getPixelOffset:G.getPixelOffset,getContentBox:G.getContentBox}},this.getSubLayerProps({id:"characters",updateTriggers:{all:j.getText,getPosition:j.getPosition,getAngle:j.getAngle,getColor:j.getColor,getSize:j.getSize,getPixelOffset:j.getPixelOffset,getContentBox:j.getContentBox,getIconOffsets:{getTextAnchor:j.getTextAnchor,getAlignmentBaseline:j.getAlignmentBaseline,styleVersion:s}}}),{data:a,_dataDiff:c,startIndices:e,numInstances:r,getIconOffsets:this.getIconOffsets,getIcon:o})]}static set fontAtlasCacheLimit(e){gN(e)}};Rd.defaultProps=Vte;Rd.layerName="TextLayer";var T0=Rd;var Id={circle:{type:t0,props:{filled:"filled",stroked:"stroked",lineWidthMaxPixels:"lineWidthMaxPixels",lineWidthMinPixels:"lineWidthMinPixels",lineWidthScale:"lineWidthScale",lineWidthUnits:"lineWidthUnits",pointRadiusMaxPixels:"radiusMaxPixels",pointRadiusMinPixels:"radiusMinPixels",pointRadiusScale:"radiusScale",pointRadiusUnits:"radiusUnits",pointAntialiasing:"antialiasing",pointBillboard:"billboard",getFillColor:"getFillColor",getLineColor:"getLineColor",getLineWidth:"getLineWidth",getPointRadius:"getRadius"}},icon:{type:Ec,props:{iconAtlas:"iconAtlas",iconMapping:"iconMapping",iconSizeMaxPixels:"sizeMaxPixels",iconSizeMinPixels:"sizeMinPixels",iconSizeScale:"sizeScale",iconSizeUnits:"sizeUnits",iconAlphaCutoff:"alphaCutoff",iconBillboard:"billboard",getIcon:"getIcon",getIconAngle:"getAngle",getIconColor:"getColor",getIconPixelOffset:"getPixelOffset",getIconSize:"getSize"}},text:{type:T0,props:{textSizeMaxPixels:"sizeMaxPixels",textSizeMinPixels:"sizeMinPixels",textSizeScale:"sizeScale",textSizeUnits:"sizeUnits",textBackground:"background",textBackgroundPadding:"backgroundPadding",textFontFamily:"fontFamily",textFontWeight:"fontWeight",textLineHeight:"lineHeight",textMaxWidth:"maxWidth",textOutlineColor:"outlineColor",textOutlineWidth:"outlineWidth",textWordBreak:"wordBreak",textCharacterSet:"characterSet",textBillboard:"billboard",textFontSettings:"fontSettings",getText:"getText",getTextAngle:"getAngle",getTextColor:"getColor",getTextPixelOffset:"getPixelOffset",getTextSize:"getSize",getTextAnchor:"getTextAnchor",getTextAlignmentBaseline:"getAlignmentBaseline",getTextBackgroundColor:"getBackgroundColor",getTextBorderColor:"getBorderColor",getTextBorderWidth:"getBorderWidth"}}},Ld={type:Go,props:{lineWidthUnits:"widthUnits",lineWidthScale:"widthScale",lineWidthMinPixels:"widthMinPixels",lineWidthMaxPixels:"widthMaxPixels",lineJointRounded:"jointRounded",lineCapRounded:"capRounded",lineMiterLimit:"miterLimit",lineBillboard:"billboard",getLineColor:"getColor",getLineWidth:"getWidth"}},v0={type:Ti,props:{extruded:"extruded",filled:"filled",wireframe:"wireframe",elevationScale:"elevationScale",material:"material",_full3d:"_full3d",getElevation:"getElevation",getFillColor:"getFillColor",getLineColor:"getLineColor"}};function Lc({type:t,props:e}){let r={};for(let o in e)r[o]=t.defaultProps[e[o]];return r}function S0(t,e){let{transitions:r,updateTriggers:o}=t.props,n={updateTriggers:{},transitions:r&&{getPosition:r.geometry}};for(let i in e){let s=e[i],a=t.props[i];i.startsWith("get")&&(a=t.getSubLayerAccessor(a),n.updateTriggers[s]=o[i],r&&(n.transitions[s]=r[i])),n[s]=a}return n}function SN(t){if(Array.isArray(t))return t;switch(N.assert(t.type,"GeoJSON does not have type"),t.type){case"Feature":return[t];case"FeatureCollection":return N.assert(Array.isArray(t.features),"GeoJSON does not have features array"),t.features;default:return[{geometry:t}]}}function LS(t,e,r={}){let o={pointFeatures:[],lineFeatures:[],polygonFeatures:[],polygonOutlineFeatures:[]},{startRow:n=0,endRow:i=t.length}=r;for(let s=n;s<i;s++){let a=t[s],{geometry:c}=a;if(c)if(c.type==="GeometryCollection"){N.assert(Array.isArray(c.geometries),"GeoJSON does not have geometries array");let{geometries:l}=c;for(let f=0;f<l.length;f++){let u=l[f];vN(u,o,e,a,s)}}else vN(c,o,e,a,s)}return o}function vN(t,e,r,o,n){let{type:i,coordinates:s}=t,{pointFeatures:a,lineFeatures:c,polygonFeatures:l,polygonOutlineFeatures:f}=e;if(!Hte(i,s)){N.warn(`${i} coordinates are malformed`)();return}switch(i){case"Point":a.push(r({geometry:t},o,n));break;case"MultiPoint":s.forEach(u=>{a.push(r({geometry:{type:"Point",coordinates:u}},o,n))});break;case"LineString":c.push(r({geometry:t},o,n));break;case"MultiLineString":s.forEach(u=>{c.push(r({geometry:{type:"LineString",coordinates:u}},o,n))});break;case"Polygon":l.push(r({geometry:t},o,n)),s.forEach(u=>{f.push(r({geometry:{type:"LineString",coordinates:u}},o,n))});break;case"MultiPolygon":s.forEach(u=>{l.push(r({geometry:{type:"Polygon",coordinates:u}},o,n)),u.forEach(d=>{f.push(r({geometry:{type:"LineString",coordinates:d}},o,n))})});break;default:}}var zte={Point:1,MultiPoint:2,LineString:2,MultiLineString:3,Polygon:3,MultiPolygon:4};function Hte(t,e){let r=zte[t];for(N.assert(r,`Unknown GeoJSON type ${t}`);e&&--r>0;)e=e[0];return e&&Number.isFinite(e[0])}function CN(){return{points:{},lines:{},polygons:{},polygonsOutline:{}}}function C0(t){return t.geometry.coordinates}function EN(t,e){let r=CN(),{pointFeatures:o,lineFeatures:n,polygonFeatures:i,polygonOutlineFeatures:s}=t;return r.points.data=o,r.points._dataDiff=e.pointFeatures&&(()=>e.pointFeatures),r.points.getPosition=C0,r.lines.data=n,r.lines._dataDiff=e.lineFeatures&&(()=>e.lineFeatures),r.lines.getPath=C0,r.polygons.data=i,r.polygons._dataDiff=e.polygonFeatures&&(()=>e.polygonFeatures),r.polygons.getPolygon=C0,r.polygonsOutline.data=s,r.polygonsOutline._dataDiff=e.polygonOutlineFeatures&&(()=>e.polygonOutlineFeatures),r.polygonsOutline.getPath=C0,r}function wN(t,e){let r=CN(),{points:o,lines:n,polygons:i}=t,s=QF(t,e);r.points.data={length:o.positions.value.length/o.positions.size,attributes:{...o.attributes,getPosition:o.positions,instancePickingColors:{size:4,value:s.points}},properties:o.properties,numericProps:o.numericProps,featureIds:o.featureIds},r.lines.data={length:n.pathIndices.value.length-1,startIndices:n.pathIndices.value,attributes:{...n.attributes,getPath:n.positions,instancePickingColors:{size:4,value:s.lines}},properties:n.properties,numericProps:n.numericProps,featureIds:n.featureIds},r.lines._pathType="open";let a=i.positions.value.length/i.positions.size,c=Array(a).fill(1);for(let l of i.primitivePolygonIndices.value)c[l-1]=0;return r.polygons.data={length:i.polygonIndices.value.length-1,startIndices:i.polygonIndices.value,attributes:{...i.attributes,getPolygon:i.positions,instanceVertexValid:{size:1,value:new Uint16Array(c)},pickingColors:{size:4,value:s.polygons}},properties:i.properties,numericProps:i.numericProps,featureIds:i.featureIds},r.polygons._normalize=!1,i.triangles&&(r.polygons.data.attributes.indices=i.triangles.value),r.polygonsOutline.data={length:i.primitivePolygonIndices.value.length-1,startIndices:i.primitivePolygonIndices.value,attributes:{...i.attributes,getPath:i.positions,instancePickingColors:{size:4,value:s.polygons}},properties:i.properties,numericProps:i.numericProps,featureIds:i.featureIds},r.polygonsOutline._pathType="open",r}var jte=["points","linestrings","polygons"],Wte={...Lc(Id.circle),...Lc(Id.icon),...Lc(Id.text),...Lc(Ld),...Lc(v0),stroked:!0,filled:!0,extruded:!1,wireframe:!1,_full3d:!1,iconAtlas:{type:"object",value:null},iconMapping:{type:"object",value:{}},getIcon:{type:"accessor",value:t=>t.properties.icon},getText:{type:"accessor",value:t=>t.properties.text},pointType:"circle",getRadius:{deprecatedFor:"getPointRadius"}},Bd=class extends Ne{initializeState(){this.state={layerProps:{},features:{},featuresDiff:{}}}updateState({props:e,changeFlags:r}){if(!r.dataChanged)return;let{data:o}=this.props,n=o&&"points"in o&&"polygons"in o&&"lines"in o;this.setState({binary:n}),n?this._updateStateBinary({props:e,changeFlags:r}):this._updateStateJSON({props:e,changeFlags:r})}_updateStateBinary({props:e,changeFlags:r}){let o=wN(e.data,this.encodePickingColor);this.setState({layerProps:o})}_updateStateJSON({props:e,changeFlags:r}){let o=SN(e.data),n=this.getSubLayerRow.bind(this),i={},s={};if(Array.isArray(r.dataChanged)){let c=this.state.features;for(let l in c)i[l]=c[l].slice(),s[l]=[];for(let l of r.dataChanged){let f=LS(o,n,l);for(let u in c)s[u].push(_0({data:i[u],getIndex:d=>d.__source.index,dataRange:l,replace:f[u]}))}}else i=LS(o,n);let a=EN(i,s);this.setState({features:i,featuresDiff:s,layerProps:a})}getPickingInfo(e){let r=super.getPickingInfo(e),{index:o,sourceLayer:n}=r;return r.featureType=jte.find(i=>n.id.startsWith(`${this.id}-${i}-`)),o>=0&&n.id.startsWith(`${this.id}-points-text`)&&this.state.binary&&(r.index=this.props.data.points.globalFeatureIds.value[o]),r}_updateAutoHighlight(e){let r=`${this.id}-points-`,o=e.featureType==="points";for(let n of this.getSubLayers())n.id.startsWith(r)===o&&n.updateAutoHighlight(e)}_renderPolygonLayer(){let{extruded:e,wireframe:r}=this.props,{layerProps:o}=this.state,n="polygons-fill",i=this.shouldRenderSubLayer(n,o.polygons?.data)&&this.getSubLayerClass(n,v0.type);if(i){let s=S0(this,v0.props),a=e&&r;return a||delete s.getLineColor,s.updateTriggers.lineColors=a,new i(s,this.getSubLayerProps({id:n,updateTriggers:s.updateTriggers}),o.polygons)}return null}_renderLineLayers(){let{extruded:e,stroked:r}=this.props,{layerProps:o}=this.state,n="polygons-stroke",i="linestrings",s=!e&&r&&this.shouldRenderSubLayer(n,o.polygonsOutline?.data)&&this.getSubLayerClass(n,Ld.type),a=this.shouldRenderSubLayer(i,o.lines?.data)&&this.getSubLayerClass(i,Ld.type);if(s||a){let c=S0(this,Ld.props);return[s&&new s(c,this.getSubLayerProps({id:n,updateTriggers:c.updateTriggers}),o.polygonsOutline),a&&new a(c,this.getSubLayerProps({id:i,updateTriggers:c.updateTriggers}),o.lines)]}return null}_renderPointLayers(){let{pointType:e}=this.props,{layerProps:r,binary:o}=this.state,{highlightedObjectIndex:n}=this.props;!o&&Number.isFinite(n)&&(n=r.points.data.findIndex(a=>a.__source.index===n));let i=new Set(e.split("+")),s=[];for(let a of i){let c=`points-${a}`,l=Id[a],f=l&&this.shouldRenderSubLayer(c,r.points?.data)&&this.getSubLayerClass(c,l.type);if(f){let u=S0(this,l.props),d=r.points;if(a==="text"&&o){let{instancePickingColors:h,...p}=d.data.attributes;d={...d,data:{...d.data,attributes:p}}}s.push(new f(u,this.getSubLayerProps({id:c,updateTriggers:u.updateTriggers,highlightedObjectIndex:n}),d))}}return s}renderLayers(){let{extruded:e}=this.props,r=this._renderPolygonLayer(),o=this._renderLineLayers(),n=this._renderPointLayers();return[!e&&r,o,n,e&&r]}getSubLayerAccessor(e){let{binary:r}=this.state;return!r||typeof e!="function"?super.getSubLayerAccessor(e):(o,n)=>{let{data:i,index:s}=n,a=JF(i,s);return e(a,n)}}};Bd.layerName="GeoJsonLayer";Bd.defaultProps=Wte;var Os=Bd;var Gte={...vi.defaultProps},Od=class extends Ne{indexToBounds(){return null}renderLayers(){let{elevationScale:e,extruded:r,wireframe:o,filled:n,stroked:i,lineWidthUnits:s,lineWidthScale:a,lineWidthMinPixels:c,lineWidthMaxPixels:l,lineJointRounded:f,lineMiterLimit:u,lineDashJustified:d,getElevation:h,getFillColor:p,getLineColor:m,getLineWidth:g}=this.props,{updateTriggers:_,material:x,transitions:y}=this.props,b=this.getSubLayerClass("cell",vi),{updateTriggers:T,...v}=this.indexToBounds()||{};return new b({filled:n,wireframe:o,extruded:r,elevationScale:e,stroked:i,lineWidthUnits:s,lineWidthScale:a,lineWidthMinPixels:c,lineWidthMaxPixels:l,lineJointRounded:f,lineMiterLimit:u,lineDashJustified:d,material:x,transitions:y,getElevation:h,getFillColor:p,getLineColor:m,getLineWidth:g},this.getSubLayerProps({id:"cell",updateTriggers:_&&{...T,getElevation:_.getElevation,getFillColor:_.getFillColor,getLineColor:_.getLineColor,getLineWidth:_.getLineWidth}}),v)}};Od.layerName="GeoCellLayer";Od.defaultProps=Gte;var Or=Od;var $te=Object.defineProperty,Ud=(t,e)=>{for(var r in e)$te(t,r,{get:e[r],enumerable:!0})},vt={};Ud(vt,{ARRAY_TYPE:()=>$e,EPSILON:()=>Tt,RANDOM:()=>Fs,equals:()=>qte,setMatrixArrayType:()=>Xte,toRadian:()=>Kte});var Tt=1e-6,$e=typeof Float32Array<"u"?Float32Array:Array,Fs=Math.random;function Xte(t){$e=t}var Yte=Math.PI/180;function Kte(t){return t*Yte}function qte(t,e){return Math.abs(t-e)<=Tt*Math.max(1,Math.abs(t),Math.abs(e))}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var Ns={};Ud(Ns,{LDU:()=>hre,add:()=>pre,adjoint:()=>ire,clone:()=>Jte,copy:()=>Qte,create:()=>Zte,determinant:()=>sre,equals:()=>gre,exactEquals:()=>mre,frob:()=>dre,fromRotation:()=>lre,fromScaling:()=>fre,fromValues:()=>tre,identity:()=>ere,invert:()=>nre,mul:()=>xre,multiply:()=>KN,multiplyScalar:()=>_re,multiplyScalarAndAdd:()=>yre,rotate:()=>are,scale:()=>cre,set:()=>rre,str:()=>ure,sub:()=>bre,subtract:()=>qN,transpose:()=>ore});function Zte(){var t=new $e(4);return $e!=Float32Array&&(t[1]=0,t[2]=0),t[0]=1,t[3]=1,t}function Jte(t){var e=new $e(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function Qte(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function ere(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t}function tre(t,e,r,o){var n=new $e(4);return n[0]=t,n[1]=e,n[2]=r,n[3]=o,n}function rre(t,e,r,o,n){return t[0]=e,t[1]=r,t[2]=o,t[3]=n,t}function ore(t,e){if(t===e){var r=e[1];t[1]=e[2],t[2]=r}else t[0]=e[0],t[1]=e[2],t[2]=e[1],t[3]=e[3];return t}function nre(t,e){var r=e[0],o=e[1],n=e[2],i=e[3],s=r*i-n*o;return s?(s=1/s,t[0]=i*s,t[1]=-o*s,t[2]=-n*s,t[3]=r*s,t):null}function ire(t,e){var r=e[0];return t[0]=e[3],t[1]=-e[1],t[2]=-e[2],t[3]=r,t}function sre(t){return t[0]*t[3]-t[2]*t[1]}function KN(t,e,r){var o=e[0],n=e[1],i=e[2],s=e[3],a=r[0],c=r[1],l=r[2],f=r[3];return t[0]=o*a+i*c,t[1]=n*a+s*c,t[2]=o*l+i*f,t[3]=n*l+s*f,t}function are(t,e,r){var o=e[0],n=e[1],i=e[2],s=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=o*c+i*a,t[1]=n*c+s*a,t[2]=o*-a+i*c,t[3]=n*-a+s*c,t}function cre(t,e,r){var o=e[0],n=e[1],i=e[2],s=e[3],a=r[0],c=r[1];return t[0]=o*a,t[1]=n*a,t[2]=i*c,t[3]=s*c,t}function lre(t,e){var r=Math.sin(e),o=Math.cos(e);return t[0]=o,t[1]=r,t[2]=-r,t[3]=o,t}function fre(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=e[1],t}function ure(t){return"mat2("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"}function dre(t){return Math.hypot(t[0],t[1],t[2],t[3])}function hre(t,e,r,o){return t[2]=o[2]/o[0],r[0]=o[0],r[1]=o[1],r[3]=o[3]-t[2]*r[1],[t,e,r]}function pre(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}function qN(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}function mre(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]}function gre(t,e){var r=t[0],o=t[1],n=t[2],i=t[3],s=e[0],a=e[1],c=e[2],l=e[3];return Math.abs(r-s)<=Tt*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(o-a)<=Tt*Math.max(1,Math.abs(o),Math.abs(a))&&Math.abs(n-c)<=Tt*Math.max(1,Math.abs(n),Math.abs(c))&&Math.abs(i-l)<=Tt*Math.max(1,Math.abs(i),Math.abs(l))}function _re(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}function yre(t,e,r,o){return t[0]=e[0]+r[0]*o,t[1]=e[1]+r[1]*o,t[2]=e[2]+r[2]*o,t[3]=e[3]+r[3]*o,t}var xre=KN,bre=qN;function Are(){var t=new $e(9);return $e!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}var NS={};Ud(NS,{add:()=>Ooe,calculateW:()=>voe,clone:()=>Roe,conjugate:()=>woe,copy:()=>Loe,create:()=>US,dot:()=>dD,equals:()=>Voe,exactEquals:()=>koe,exp:()=>cD,fromEuler:()=>Poe,fromMat3:()=>fD,fromValues:()=>Ioe,getAngle:()=>xoe,getAxisAngle:()=>yoe,identity:()=>_oe,invert:()=>Eoe,len:()=>Doe,length:()=>hD,lerp:()=>Noe,ln:()=>lD,mul:()=>Foe,multiply:()=>aD,normalize:()=>YS,pow:()=>Soe,random:()=>Coe,rotateX:()=>boe,rotateY:()=>Aoe,rotateZ:()=>Toe,rotationTo:()=>zoe,scale:()=>uD,set:()=>Boe,setAxes:()=>joe,setAxisAngle:()=>sD,slerp:()=>F0,sqlerp:()=>Hoe,sqrLen:()=>Uoe,squaredLength:()=>pD,str:()=>Moe});var z={};Ud(z,{add:()=>Cre,angle:()=>Gre,bezier:()=>Dre,ceil:()=>Ere,clone:()=>Tre,copy:()=>vre,create:()=>$S,cross:()=>O0,dist:()=>Qre,distance:()=>tD,div:()=>Jre,divide:()=>eD,dot:()=>XS,equals:()=>Kre,exactEquals:()=>Yre,floor:()=>wre,forEach:()=>roe,fromValues:()=>DS,hermite:()=>Nre,inverse:()=>Ore,len:()=>iD,length:()=>ZN,lerp:()=>Fre,max:()=>Mre,min:()=>Pre,mul:()=>Zre,multiply:()=>QN,negate:()=>Bre,normalize:()=>nD,random:()=>Ure,rotateX:()=>Hre,rotateY:()=>jre,rotateZ:()=>Wre,round:()=>Rre,scale:()=>Ire,scaleAndAdd:()=>Lre,set:()=>Sre,sqrDist:()=>eoe,sqrLen:()=>toe,squaredDistance:()=>rD,squaredLength:()=>oD,str:()=>Xre,sub:()=>qre,subtract:()=>JN,transformMat3:()=>Vre,transformMat4:()=>kre,transformQuat:()=>zre,zero:()=>$re});function $S(){var t=new $e(3);return $e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Tre(t){var e=new $e(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function ZN(t){var e=t[0],r=t[1],o=t[2];return Math.hypot(e,r,o)}function DS(t,e,r){var o=new $e(3);return o[0]=t,o[1]=e,o[2]=r,o}function vre(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Sre(t,e,r,o){return t[0]=e,t[1]=r,t[2]=o,t}function Cre(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function JN(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function QN(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function eD(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}function Ere(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t}function wre(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t}function Pre(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t}function Mre(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t}function Rre(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t}function Ire(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function Lre(t,e,r,o){return t[0]=e[0]+r[0]*o,t[1]=e[1]+r[1]*o,t[2]=e[2]+r[2]*o,t}function tD(t,e){var r=e[0]-t[0],o=e[1]-t[1],n=e[2]-t[2];return Math.hypot(r,o,n)}function rD(t,e){var r=e[0]-t[0],o=e[1]-t[1],n=e[2]-t[2];return r*r+o*o+n*n}function oD(t){var e=t[0],r=t[1],o=t[2];return e*e+r*r+o*o}function Bre(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}function Ore(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t}function nD(t,e){var r=e[0],o=e[1],n=e[2],i=r*r+o*o+n*n;return i>0&&(i=1/Math.sqrt(i)),t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t}function XS(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function O0(t,e,r){var o=e[0],n=e[1],i=e[2],s=r[0],a=r[1],c=r[2];return t[0]=n*c-i*a,t[1]=i*s-o*c,t[2]=o*a-n*s,t}function Fre(t,e,r,o){var n=e[0],i=e[1],s=e[2];return t[0]=n+o*(r[0]-n),t[1]=i+o*(r[1]-i),t[2]=s+o*(r[2]-s),t}function Nre(t,e,r,o,n,i){var s=i*i,a=s*(2*i-3)+1,c=s*(i-2)+i,l=s*(i-1),f=s*(3-2*i);return t[0]=e[0]*a+r[0]*c+o[0]*l+n[0]*f,t[1]=e[1]*a+r[1]*c+o[1]*l+n[1]*f,t[2]=e[2]*a+r[2]*c+o[2]*l+n[2]*f,t}function Dre(t,e,r,o,n,i){var s=1-i,a=s*s,c=i*i,l=a*s,f=3*i*a,u=3*c*s,d=c*i;return t[0]=e[0]*l+r[0]*f+o[0]*u+n[0]*d,t[1]=e[1]*l+r[1]*f+o[1]*u+n[1]*d,t[2]=e[2]*l+r[2]*f+o[2]*u+n[2]*d,t}function Ure(t,e){e=e||1;var r=Fs()*2*Math.PI,o=Fs()*2-1,n=Math.sqrt(1-o*o)*e;return t[0]=Math.cos(r)*n,t[1]=Math.sin(r)*n,t[2]=o*e,t}function kre(t,e,r){var o=e[0],n=e[1],i=e[2],s=r[3]*o+r[7]*n+r[11]*i+r[15];return s=s||1,t[0]=(r[0]*o+r[4]*n+r[8]*i+r[12])/s,t[1]=(r[1]*o+r[5]*n+r[9]*i+r[13])/s,t[2]=(r[2]*o+r[6]*n+r[10]*i+r[14])/s,t}function Vre(t,e,r){var o=e[0],n=e[1],i=e[2];return t[0]=o*r[0]+n*r[3]+i*r[6],t[1]=o*r[1]+n*r[4]+i*r[7],t[2]=o*r[2]+n*r[5]+i*r[8],t}function zre(t,e,r){var o=r[0],n=r[1],i=r[2],s=r[3],a=e[0],c=e[1],l=e[2],f=n*l-i*c,u=i*a-o*l,d=o*c-n*a,h=n*d-i*u,p=i*f-o*d,m=o*u-n*f,g=s*2;return f*=g,u*=g,d*=g,h*=2,p*=2,m*=2,t[0]=a+f+h,t[1]=c+u+p,t[2]=l+d+m,t}function Hre(t,e,r,o){var n=[],i=[];return n[0]=e[0]-r[0],n[1]=e[1]-r[1],n[2]=e[2]-r[2],i[0]=n[0],i[1]=n[1]*Math.cos(o)-n[2]*Math.sin(o),i[2]=n[1]*Math.sin(o)+n[2]*Math.cos(o),t[0]=i[0]+r[0],t[1]=i[1]+r[1],t[2]=i[2]+r[2],t}function jre(t,e,r,o){var n=[],i=[];return n[0]=e[0]-r[0],n[1]=e[1]-r[1],n[2]=e[2]-r[2],i[0]=n[2]*Math.sin(o)+n[0]*Math.cos(o),i[1]=n[1],i[2]=n[2]*Math.cos(o)-n[0]*Math.sin(o),t[0]=i[0]+r[0],t[1]=i[1]+r[1],t[2]=i[2]+r[2],t}function Wre(t,e,r,o){var n=[],i=[];return n[0]=e[0]-r[0],n[1]=e[1]-r[1],n[2]=e[2]-r[2],i[0]=n[0]*Math.cos(o)-n[1]*Math.sin(o),i[1]=n[0]*Math.sin(o)+n[1]*Math.cos(o),i[2]=n[2],t[0]=i[0]+r[0],t[1]=i[1]+r[1],t[2]=i[2]+r[2],t}function Gre(t,e){var r=t[0],o=t[1],n=t[2],i=e[0],s=e[1],a=e[2],c=Math.sqrt(r*r+o*o+n*n),l=Math.sqrt(i*i+s*s+a*a),f=c*l,u=f&&XS(t,e)/f;return Math.acos(Math.min(Math.max(u,-1),1))}function $re(t){return t[0]=0,t[1]=0,t[2]=0,t}function Xre(t){return"vec3("+t[0]+", "+t[1]+", "+t[2]+")"}function Yre(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}function Kre(t,e){var r=t[0],o=t[1],n=t[2],i=e[0],s=e[1],a=e[2];return Math.abs(r-i)<=Tt*Math.max(1,Math.abs(r),Math.abs(i))&&Math.abs(o-s)<=Tt*Math.max(1,Math.abs(o),Math.abs(s))&&Math.abs(n-a)<=Tt*Math.max(1,Math.abs(n),Math.abs(a))}var qre=JN,Zre=QN,Jre=eD,Qre=tD,eoe=rD,iD=ZN,toe=oD,roe=function(){var t=$S();return function(e,r,o,n,i,s){var a,c;for(r||(r=3),o||(o=0),n?c=Math.min(n*r+o,e.length):c=e.length,a=o;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],i(t,t,s),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2];return e}}();function ooe(){var t=new $e(4);return $e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function noe(t){var e=new $e(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function ioe(t,e,r,o){var n=new $e(4);return n[0]=t,n[1]=e,n[2]=r,n[3]=o,n}function soe(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function aoe(t,e,r,o,n){return t[0]=e,t[1]=r,t[2]=o,t[3]=n,t}function coe(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}function loe(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}function foe(t){var e=t[0],r=t[1],o=t[2],n=t[3];return Math.hypot(e,r,o,n)}function uoe(t){var e=t[0],r=t[1],o=t[2],n=t[3];return e*e+r*r+o*o+n*n}function doe(t,e){var r=e[0],o=e[1],n=e[2],i=e[3],s=r*r+o*o+n*n+i*i;return s>0&&(s=1/Math.sqrt(s)),t[0]=r*s,t[1]=o*s,t[2]=n*s,t[3]=i*s,t}function hoe(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function poe(t,e,r,o){var n=e[0],i=e[1],s=e[2],a=e[3];return t[0]=n+o*(r[0]-n),t[1]=i+o*(r[1]-i),t[2]=s+o*(r[2]-s),t[3]=a+o*(r[3]-a),t}function moe(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]}function goe(t,e){var r=t[0],o=t[1],n=t[2],i=t[3],s=e[0],a=e[1],c=e[2],l=e[3];return Math.abs(r-s)<=Tt*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(o-a)<=Tt*Math.max(1,Math.abs(o),Math.abs(a))&&Math.abs(n-c)<=Tt*Math.max(1,Math.abs(n),Math.abs(c))&&Math.abs(i-l)<=Tt*Math.max(1,Math.abs(i),Math.abs(l))}var LGe=function(){var t=ooe();return function(e,r,o,n,i,s){var a,c;for(r||(r=4),o||(o=0),n?c=Math.min(n*r+o,e.length):c=e.length,a=o;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],t[3]=e[a+3],i(t,t,s),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2],e[a+3]=t[3];return e}}();function US(){var t=new $e(4);return $e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function _oe(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function sD(t,e,r){r=r*.5;var o=Math.sin(r);return t[0]=o*e[0],t[1]=o*e[1],t[2]=o*e[2],t[3]=Math.cos(r),t}function yoe(t,e){var r=Math.acos(e[3])*2,o=Math.sin(r/2);return o>Tt?(t[0]=e[0]/o,t[1]=e[1]/o,t[2]=e[2]/o):(t[0]=1,t[1]=0,t[2]=0),r}function xoe(t,e){var r=dD(t,e);return Math.acos(2*r*r-1)}function aD(t,e,r){var o=e[0],n=e[1],i=e[2],s=e[3],a=r[0],c=r[1],l=r[2],f=r[3];return t[0]=o*f+s*a+n*l-i*c,t[1]=n*f+s*c+i*a-o*l,t[2]=i*f+s*l+o*c-n*a,t[3]=s*f-o*a-n*c-i*l,t}function boe(t,e,r){r*=.5;var o=e[0],n=e[1],i=e[2],s=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=o*c+s*a,t[1]=n*c+i*a,t[2]=i*c-n*a,t[3]=s*c-o*a,t}function Aoe(t,e,r){r*=.5;var o=e[0],n=e[1],i=e[2],s=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=o*c-i*a,t[1]=n*c+s*a,t[2]=i*c+o*a,t[3]=s*c-n*a,t}function Toe(t,e,r){r*=.5;var o=e[0],n=e[1],i=e[2],s=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=o*c+n*a,t[1]=n*c-o*a,t[2]=i*c+s*a,t[3]=s*c-i*a,t}function voe(t,e){var r=e[0],o=e[1],n=e[2];return t[0]=r,t[1]=o,t[2]=n,t[3]=Math.sqrt(Math.abs(1-r*r-o*o-n*n)),t}function cD(t,e){var r=e[0],o=e[1],n=e[2],i=e[3],s=Math.sqrt(r*r+o*o+n*n),a=Math.exp(i),c=s>0?a*Math.sin(s)/s:0;return t[0]=r*c,t[1]=o*c,t[2]=n*c,t[3]=a*Math.cos(s),t}function lD(t,e){var r=e[0],o=e[1],n=e[2],i=e[3],s=Math.sqrt(r*r+o*o+n*n),a=s>0?Math.atan2(s,i)/s:0;return t[0]=r*a,t[1]=o*a,t[2]=n*a,t[3]=.5*Math.log(r*r+o*o+n*n+i*i),t}function Soe(t,e,r){return lD(t,e),uD(t,t,r),cD(t,t),t}function F0(t,e,r,o){var n=e[0],i=e[1],s=e[2],a=e[3],c=r[0],l=r[1],f=r[2],u=r[3],d,h,p,m,g;return h=n*c+i*l+s*f+a*u,h<0&&(h=-h,c=-c,l=-l,f=-f,u=-u),1-h>Tt?(d=Math.acos(h),p=Math.sin(d),m=Math.sin((1-o)*d)/p,g=Math.sin(o*d)/p):(m=1-o,g=o),t[0]=m*n+g*c,t[1]=m*i+g*l,t[2]=m*s+g*f,t[3]=m*a+g*u,t}function Coe(t){var e=Fs(),r=Fs(),o=Fs(),n=Math.sqrt(1-e),i=Math.sqrt(e);return t[0]=n*Math.sin(2*Math.PI*r),t[1]=n*Math.cos(2*Math.PI*r),t[2]=i*Math.sin(2*Math.PI*o),t[3]=i*Math.cos(2*Math.PI*o),t}function Eoe(t,e){var r=e[0],o=e[1],n=e[2],i=e[3],s=r*r+o*o+n*n+i*i,a=s?1/s:0;return t[0]=-r*a,t[1]=-o*a,t[2]=-n*a,t[3]=i*a,t}function woe(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t}function fD(t,e){var r=e[0]+e[4]+e[8],o;if(r>0)o=Math.sqrt(r+1),t[3]=.5*o,o=.5/o,t[0]=(e[5]-e[7])*o,t[1]=(e[6]-e[2])*o,t[2]=(e[1]-e[3])*o;else{var n=0;e[4]>e[0]&&(n=1),e[8]>e[n*3+n]&&(n=2);var i=(n+1)%3,s=(n+2)%3;o=Math.sqrt(e[n*3+n]-e[i*3+i]-e[s*3+s]+1),t[n]=.5*o,o=.5/o,t[3]=(e[i*3+s]-e[s*3+i])*o,t[i]=(e[i*3+n]+e[n*3+i])*o,t[s]=(e[s*3+n]+e[n*3+s])*o}return t}function Poe(t,e,r,o){var n=.5*Math.PI/180;e*=n,r*=n,o*=n;var i=Math.sin(e),s=Math.cos(e),a=Math.sin(r),c=Math.cos(r),l=Math.sin(o),f=Math.cos(o);return t[0]=i*c*f-s*a*l,t[1]=s*a*f+i*c*l,t[2]=s*c*l-i*a*f,t[3]=s*c*f+i*a*l,t}function Moe(t){return"quat("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"}var Roe=noe,Ioe=ioe,Loe=soe,Boe=aoe,Ooe=coe,Foe=aD,uD=loe,dD=hoe,Noe=poe,hD=foe,Doe=hD,pD=uoe,Uoe=pD,YS=doe,koe=moe,Voe=goe,zoe=function(){var t=$S(),e=DS(1,0,0),r=DS(0,1,0);return function(o,n,i){var s=XS(n,i);return s<-.999999?(O0(t,e,n),iD(t)<1e-6&&O0(t,r,n),nD(t,t),sD(o,t,Math.PI),o):s>.999999?(o[0]=0,o[1]=0,o[2]=0,o[3]=1,o):(O0(t,n,i),o[0]=t[0],o[1]=t[1],o[2]=t[2],o[3]=1+s,YS(o,o))}}(),Hoe=function(){var t=US(),e=US();return function(r,o,n,i,s,a){return F0(t,o,s,a),F0(e,n,i,a),F0(r,t,e,2*a*(1-a)),r}}(),joe=function(){var t=Are();return function(e,r,o,n){return t[0]=o[0],t[3]=o[1],t[6]=o[2],t[1]=n[0],t[4]=n[1],t[7]=n[2],t[2]=-r[0],t[5]=-r[1],t[8]=-r[2],YS(e,fD(e,t))}}(),oe={};Ud(oe,{add:()=>Yoe,angle:()=>pne,ceil:()=>Koe,clone:()=>Woe,copy:()=>$oe,create:()=>mD,cross:()=>sne,dist:()=>vne,distance:()=>xD,div:()=>Tne,divide:()=>yD,dot:()=>ine,equals:()=>yne,exactEquals:()=>_ne,floor:()=>qoe,forEach:()=>Ene,fromValues:()=>Goe,inverse:()=>one,len:()=>xne,length:()=>AD,lerp:()=>ane,max:()=>Joe,min:()=>Zoe,mul:()=>Ane,multiply:()=>_D,negate:()=>rne,normalize:()=>nne,random:()=>cne,rotate:()=>hne,round:()=>Qoe,scale:()=>ene,scaleAndAdd:()=>tne,set:()=>Xoe,sqrDist:()=>Sne,sqrLen:()=>Cne,squaredDistance:()=>bD,squaredLength:()=>TD,str:()=>gne,sub:()=>bne,subtract:()=>gD,transformMat2:()=>lne,transformMat2d:()=>fne,transformMat3:()=>une,transformMat4:()=>dne,zero:()=>mne});function mD(){var t=new $e(2);return $e!=Float32Array&&(t[0]=0,t[1]=0),t}function Woe(t){var e=new $e(2);return e[0]=t[0],e[1]=t[1],e}function Goe(t,e){var r=new $e(2);return r[0]=t,r[1]=e,r}function $oe(t,e){return t[0]=e[0],t[1]=e[1],t}function Xoe(t,e,r){return t[0]=e,t[1]=r,t}function Yoe(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t}function gD(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t}function _D(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t}function yD(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t}function Koe(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t}function qoe(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t}function Zoe(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t}function Joe(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t}function Qoe(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t}function ene(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t}function tne(t,e,r,o){return t[0]=e[0]+r[0]*o,t[1]=e[1]+r[1]*o,t}function xD(t,e){var r=e[0]-t[0],o=e[1]-t[1];return Math.hypot(r,o)}function bD(t,e){var r=e[0]-t[0],o=e[1]-t[1];return r*r+o*o}function AD(t){var e=t[0],r=t[1];return Math.hypot(e,r)}function TD(t){var e=t[0],r=t[1];return e*e+r*r}function rne(t,e){return t[0]=-e[0],t[1]=-e[1],t}function one(t,e){return t[0]=1/e[0],t[1]=1/e[1],t}function nne(t,e){var r=e[0],o=e[1],n=r*r+o*o;return n>0&&(n=1/Math.sqrt(n)),t[0]=e[0]*n,t[1]=e[1]*n,t}function ine(t,e){return t[0]*e[0]+t[1]*e[1]}function sne(t,e,r){var o=e[0]*r[1]-e[1]*r[0];return t[0]=t[1]=0,t[2]=o,t}function ane(t,e,r,o){var n=e[0],i=e[1];return t[0]=n+o*(r[0]-n),t[1]=i+o*(r[1]-i),t}function cne(t,e){e=e||1;var r=Fs()*2*Math.PI;return t[0]=Math.cos(r)*e,t[1]=Math.sin(r)*e,t}function lne(t,e,r){var o=e[0],n=e[1];return t[0]=r[0]*o+r[2]*n,t[1]=r[1]*o+r[3]*n,t}function fne(t,e,r){var o=e[0],n=e[1];return t[0]=r[0]*o+r[2]*n+r[4],t[1]=r[1]*o+r[3]*n+r[5],t}function une(t,e,r){var o=e[0],n=e[1];return t[0]=r[0]*o+r[3]*n+r[6],t[1]=r[1]*o+r[4]*n+r[7],t}function dne(t,e,r){var o=e[0],n=e[1];return t[0]=r[0]*o+r[4]*n+r[12],t[1]=r[1]*o+r[5]*n+r[13],t}function hne(t,e,r,o){var n=e[0]-r[0],i=e[1]-r[1],s=Math.sin(o),a=Math.cos(o);return t[0]=n*a-i*s+r[0],t[1]=n*s+i*a+r[1],t}function pne(t,e){var r=t[0],o=t[1],n=e[0],i=e[1],s=Math.sqrt(r*r+o*o)*Math.sqrt(n*n+i*i),a=s&&(r*n+o*i)/s;return Math.acos(Math.min(Math.max(a,-1),1))}function mne(t){return t[0]=0,t[1]=0,t}function gne(t){return"vec2("+t[0]+", "+t[1]+")"}function _ne(t,e){return t[0]===e[0]&&t[1]===e[1]}function yne(t,e){var r=t[0],o=t[1],n=e[0],i=e[1];return Math.abs(r-n)<=Tt*Math.max(1,Math.abs(r),Math.abs(n))&&Math.abs(o-i)<=Tt*Math.max(1,Math.abs(o),Math.abs(i))}var xne=AD,bne=gD,Ane=_D,Tne=yD,vne=xD,Sne=bD,Cne=TD,Ene=function(){var t=mD();return function(e,r,o,n,i,s){var a,c;for(r||(r=2),o||(o=0),n?c=Math.min(n*r+o,e.length):c=e.length,a=o;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],i(t,t,s),e[a]=t[0],e[a+1]=t[1];return e}}(),V0=(1+Math.sqrt(5))/2,BGe=2*Math.PI,N0=2*Math.PI/5,$o=Math.PI/5,PN=Math.PI/10,wne=2*Math.atan(V0),kS=Math.PI-wne,OGe=-.5*Math.PI+Math.acos(-1/Math.sqrt(3-V0)),z0=(Math.sqrt(5)-1)/2,Pne=3-Math.sqrt(5),Mne=Math.sqrt(3-V0),FGe=Math.sqrt(3)*Mne/V0,D0=63710072e-1,NGe=4*Math.PI*D0*D0;vt.setMatrixArrayType(Float64Array);var KS=class VS{constructor(e){this.vertices=e,this.isWindingCorrect()||this.vertices.reverse()}getArea(){let e=0,r=this.vertices.length;for(let o=0;o<r;o++){let n=(o+1)%r;e+=(this.vertices[n][0]-this.vertices[o][0])*(this.vertices[n][1]+this.vertices[o][1])}return e}isWindingCorrect(){return this.getArea()>=0}getVertices(){return this.vertices}scale(e){for(let r of this.vertices)oe.scale(r,r,e);return this}rotate180(){for(let e of this.vertices)oe.negate(e,e);return this}reflectY(){for(let e of this.vertices)e[1]=-e[1];return this.vertices.reverse(),this}translate(e){for(let r of this.vertices)oe.add(r,r,e);return this}transform(e){for(let r of this.vertices)oe.transformMat2(r,r,e);return this}transform2d(e){for(let r of this.vertices)oe.transformMat2d(r,r,e);return this}clone(){return new VS(this.vertices.map(r=>oe.clone(r)))}getCenter(){let e=this.vertices.length;return this.vertices.reduce((o,n)=>[o[0]+n[0]/e,o[1]+n[1]/e],[0,0])}containsPoint(e){if(!this.isWindingCorrect())throw new Error("Pentagon is not counter-clockwise");let r=this.vertices.length,o=1;for(let n=0;n<r;n++){let i=this.vertices[n],s=this.vertices[(n+1)%r],a=i[0]-s[0],c=i[1]-s[1],l=e[0]-i[0],f=e[1]-i[1],u=a*f-c*l;if(u<0){let d=Math.sqrt(l*l+f*f);o=Math.min(o,u/d)}}return o}splitEdges(e){if(e<=1)return this;let r=[],o=this.vertices.length;for(let n=0;n<o;n++){let i=this.vertices[n],s=this.vertices[(n+1)%o];r.push(oe.clone(i));for(let a=1;a<e;a++){let c=a/e,l=oe.create();oe.lerp(l,i,s,c),r.push(l)}}return new VS(r)}};vt.setMatrixArrayType(Float64Array);var vD=[0,0],SD=[0,1],Ds=[.7885966681787006,1.6149108024237764],CD=[1.6171013659387945,1.054928690397459],ED=[Math.cos(PN),Math.sin(PN)],Rne=2*oe.length(Ds)*Math.cos($o),Ine=$o-Math.atan2(Ds[1],Ds[0]),Lne=2*z0/Rne;[vD,SD,Ds,CD,ED].forEach(t=>{oe.scale(t,t,Lne),oe.rotate(t,t,[0,0],Ine)});var Bne=new KS([vD,SD,Ds,CD,ED]),wD=Math.atan2(Ds[1],Ds[0])-$o,One=[0,0],U0=z0/Math.cos($o),MN=wD+$o,k0=[U0*Math.cos(MN),U0*Math.sin(MN)],RN=wD-$o,Dd=[U0*Math.cos(RN),U0*Math.sin(RN)],PD=new KS([One,k0,Dd]),MD=Ns.fromValues(k0[0],k0[1],Dd[0],Dd[1]),DGe=Ns.invert(Ns.create(),MD),Fne=new Float64Array([-.0022392098386786394,21308606513250217e-22,-2559257686421274e-24,33701965267802837e-28,-4667545312611249e-30,667492870384816e-32]),Nne=new Float64Array([.0022392089963541657,28831978048607556e-22,508622073997266e-23,102018123778161e-25,21912872306767718e-30,49284235482523806e-33]),Dne=class{applyCoefficients(t,e){let r=Math.sin(t),o=Math.cos(t),n=2*(o-r)*(o+r),i,s;return i=n*e[5]+e[4],s=n*i+e[3],i=n*s-i+e[2],s=n*i-s+e[1],i=n*s-i+e[0],t+2*r*o*i}forward(t){return this.applyCoefficients(t,Fne)}inverse(t){return this.applyCoefficients(t,Nne)}};vt.setMatrixArrayType(Float64Array);var RD=new Dne;function IN(t){return t*(Math.PI/180)}function LN(t){return t*(180/Math.PI)}function BN(t){let e=oe.length(t),r=Math.atan2(t[1],t[0]);return[e,r]}function Une([t,e]){let r=t*Math.cos(e),o=t*Math.sin(e);return[r,o]}function kne(t,[e,r,o]){let n=[e[0]-o[0],e[1]-o[1]],i=[o[0]-r[0],o[1]-r[1]],s=[t[0]-o[0],t[1]-o[1]],a=i[0]*n[1]-i[1]*n[0],c=(i[0]*s[1]-i[1]*s[0])/a,l=(n[0]*s[1]-n[1]*s[0])/a,f=1-(c+l);return[c,l,f]}function Vne(t,[e,r,o]){return[t[0]*e[0]+t[1]*r[0]+t[2]*o[0],t[0]*e[1]+t[1]*r[1]+t[2]*o[1]]}function zS(t){let e=Math.atan2(t[1],t[0]),r=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]),o=Math.acos(t[2]/r);return[e,o]}function Nc([t,e]){let r=Math.sin(e),o=r*Math.cos(t),n=r*Math.sin(t),i=Math.cos(e);return[o,n,i]}var ID=93;function zne([t,e]){let r=IN(t+ID),o=IN(e),n=RD.forward(o),i=Math.PI/2-n;return[r,i]}function LD([t,e]){let r=LN(t)-ID,o=Math.PI/2-e,n=RD.inverse(o),i=LN(n);return[r,i]}function Hne(t){let e=t.map(i=>Nc(zne(i))),r=z.create();for(let i of e)z.add(r,r,i);z.normalize(r,r);let[o,n]=LD(zS(r));return(n>89.99||n<-89.99)&&(o=t[0][0]),o=((o+180)%360+360)%360-180,t.map(i=>{let[s,a]=i;for(;s-o>180;)s=s-360;for(;s-o<-180;)s=s+360;return[s,a]})}vt.setMatrixArrayType(Float64Array);var H0=Math.sqrt(5),j0=Math.sqrt(.2),BD=Math.sqrt((1-j0)/2),OD=Math.sqrt((1+j0)/2),E0=.5,ON=Math.sqrt((2.5-H0)/10),FN=Math.sqrt((2.5+H0)/10),NN=Math.sqrt((1+j0)/8),DN=Math.sqrt((1-j0)/8),UN=Math.sqrt((3-H0)/8),kN=Math.sqrt((3+H0)/8),jne=[[0,0],[BD,0],[ON,E0],[-NN,UN],[-NN,-UN],[ON,-E0],[-OD,0],[-DN,-kN],[FN,-E0],[FN,E0],[-DN,kN],[0,0]],Wne=jne.map(([t,e])=>[-e,t]),w0=Wne.map((t,e)=>e===0?[0,0,0,1]:e===11?[0,-1,0,0]:[...t,0,e<6?OD:BD]);vt.setMatrixArrayType(Float64Array);var FD=["vu","uw","vw","vw","vw"],Fd=["wu","uw","vw","vu","uw"],BS=["wu","uv","wv","wu","uw"],P0=["vu","uv","wv","wu","uw"],Gne=[FD,P0,BS,Fd,BS,P0,BS,Fd,Fd,Fd,P0,P0],$ne=[4,2,3,2,0,4,3,2,2,0,3,0],VN=[0,1,2,4,3,5,7,8,6,11,10,9],ao=[];function Xne(){M0([0,0],0,w0[0]);for(let t=0;t<5;t++){let e=t*N0,r=e+$o;M0([e,kS],$o,w0[t+1]),M0([r,Math.PI-kS],$o,w0[(t+3)%5+6])}M0([0,Math.PI],0,w0[11])}var Bc=0;function M0(t,e,r){if(Bc>11)throw new Error(`Too many origins: ${Bc}`);let o=NS.create();NS.conjugate(o,r);let n={id:Bc,axis:t,quat:r,inverseQuat:o,angle:e,orientation:Gne[Bc],firstQuintant:$ne[Bc]};ao.push(n),Bc++}Xne();ao.sort((t,e)=>VN.indexOf(t.id)-VN.indexOf(e.id));ao.forEach((t,e)=>t.id=e);function Yne(t,e){let r=e.orientation,o=r===FD||r===Fd?-1:1,n=(t-e.firstQuintant+5)%5,i=r[n];return{quintant:(e.firstQuintant+o*n+5)%5,orientation:i}}var Kne=class{forward([t,e]){return[Math.tan(e),t]}inverse([t,e]){return[e,Math.atan(t)]}},Oc=z.create(),Nd=z.create(),zN=z.create(),HN=z.create();function OS(t,e){z.lerp(Oc,t,e,.5),z.normalize(Oc,Oc),z.cross(Oc,t,Oc);let r=z.length(Oc);if(r<1e-8){let o=z.subtract(z.create(),t,e);return .5*z.length(o)}return r}function qne(t,e,r){return z.cross(Nd,e,r),z.dot(t,Nd)}function Zne(t,e,r,o,n){z.cross(Nd,o,n);let i=z.dot(e,Nd),s=z.dot(r,Nd);return z.scale(zN,e,s),z.scale(HN,r,i),z.sub(t,HN,zN)}function HS(t,e,r,o){let n=z.angle(e,r);if(n<1e-12)return z.lerp(t,e,r,o);let i=Math.sin((1-o)*n)/Math.sin(n),s=Math.sin(o*n)/Math.sin(n),a=z.scale(z.create(),e,i),c=z.scale(z.create(),r,s);return z.add(t,a,c)}vt.setMatrixArrayType(Float64Array);var R0=z.create(),I0=z.create(),L0=z.create(),Fc=z.create(),Jne=class{constructor(t){this._area=null,this.vertices=t,Object.freeze(this.vertices)}getBoundary(t=1,e=!0){let r=[],o=this.vertices.length;for(let n=0;n<o*t;n++){let i=n/t;r.push(this.slerp(i))}return e&&r.push(r[0]),r}slerp(t){let e=this.vertices.length,r=t%1,o=Math.floor(t%e),n=(o+1)%e;return HS(z.create(),this.vertices[o],this.vertices[n],r)}getTransformedVertices(t){let e=this.vertices.length,r=Math.floor(t%e),o=(r+1)%e,n=(r+e-1)%e,i=z.clone(this.vertices[r]),s=z.clone(this.vertices[o]),a=z.clone(this.vertices[n]);return z.sub(s,s,i),z.sub(a,a,i),[i,s,a]}containsPoint(t){let e=this.vertices.length,r=1/0;for(let o=0;o<e;o++){let[n,i,s]=this.getTransformedVertices(o),a=z.sub(z.create(),t,n);z.normalize(a,a),z.normalize(i,i),z.normalize(s,s);let c=z.cross(z.create(),i,a),l=z.cross(z.create(),a,s),f=z.dot(n,c),u=z.dot(n,l);r=Math.min(r,f,u)}return r}getTriangleArea(t,e,r){z.lerp(R0,e,r,.5),z.lerp(I0,r,t,.5),z.lerp(L0,t,e,.5),z.normalize(R0,R0),z.normalize(I0,I0),z.normalize(L0,L0);let o=qne(R0,I0,L0),n=Math.max(-1,Math.min(1,o));return Math.abs(n)<1e-8?2*n:Math.asin(n)*2}getArea(){return this._area===null&&(this._area=this._getArea()),this._area}_getArea(){if(this.vertices.length<3)return 0;if(this.vertices.length===3)return this._area=this.getTriangleArea(this.vertices[0],this.vertices[1],this.vertices[2]),this._area;z.set(Fc,0,0,0);for(let e of this.vertices)z.add(Fc,Fc,e);z.normalize(Fc,Fc);let t=0;for(let e=0;e<this.vertices.length;e++){let r=this.vertices[e],o=this.vertices[(e+1)%this.vertices.length],n=this.getTriangleArea(Fc,r,o);isNaN(n)||(t+=n)}return this._area=t,this._area}isWindingCorrect(){if(!(this.getArea()>0))debugger}};vt.setMatrixArrayType(Float64Array);var B0=class extends Jne{constructor(t){if(t.length!==3)throw new Error("SphericalTriangleShape requires exactly 3 vertices");super(t)}};vt.setMatrixArrayType(Float64Array);var Qne=class{forward(t,e,r){let[o,n,i]=e,s=new B0([o,n,i]),a=z.subtract(z.create(),t,o);z.normalize(a,a);let c=Zne(z.create(),o,a,n,i);z.normalize(c,c);let l=OS(o,t)/OS(o,c),f=s.getArea(),u=l/f,d=[1-l,u*new B0([o,c,i]).getArea(),u*new B0([o,n,c]).getArea()];return Vne(d,r)}inverse(t,e,r){let[o,n,i]=r,s=new B0([o,n,i]),a=kne(t,e),c=1-1e-14;if(a[0]>c)return o;if(a[1]>c)return n;if(a[2]>c)return i;let l=z.create();z.cross(l,n,i);let f=s.getArea(),u=1-a[0],h=a[2]/u*f,p=Math.sin(h),m=Math.sin(h/2),g=2*m*m,_=z.dot(o,n),x=z.dot(n,i),y=z.dot(i,o),b=z.length(l),T=z.dot(o,l),v=p*T+g*(_*x-y),w=g*b*(1+_),C=2/Math.acos(x)*Math.atan2(w,v),S=HS(z.create(),n,i,C),A=OS(o,S),M=this.safeAcos(u*A)/this.safeAcos(A);return HS([0,0,0],o,S,M)}safeAcos(t){return t<.001?2*t+t*t*t/3:Math.acos(1-2*t*t)}},yr=-1,jt=1;vt.setMatrixArrayType(Float64Array);var eie=([t,e])=>oe.fromValues(t-e,e);vt.setMatrixArrayType(Float64Array);var jS=oe.fromValues(1,0),WS=oe.fromValues(0,1),jN=oe.negate(oe.create(),jS),WN=oe.negate(oe.create(),WS),FS=oe.fromValues(0,0),tie=(t,[e,r])=>{let o=FS,n=FS;switch(e===jt&&r===jt?(o=jS,n=WS):e===yr&&r===jt?(o=WN,n=jN):e===jt&&r===yr?(o=WS,n=jS):e===yr&&r===yr&&(o=jN,n=WN),t){case 0:return FS;case 1:return o;case 2:return oe.add(oe.create(),n,o);case 3:return oe.scaleAndAdd(oe.create(),n,o,2);default:throw new Error(`Invalid Quaternary value: ${t}`)}},GN=t=>[[jt,jt],[jt,yr],[jt,jt],[yr,jt]][t];function ND(t){return Array.from({length:t.length},(e,r)=>t.indexOf(r))}var DD=[0,1,3,4,5,6,7,2],UD=[0,1,2,7,3,4,5,6],UGe=ND(DD),kGe=ND(UD),rie=(t,e,r,o,n)=>{if(e<=0)return;let i=t[e]||0,s=t[e-1],a=r[0]+r[1],c=!0,l=!0;if(o!==(a===0)?(c=i===1||i===2,l=i===1):(c=i<2,l=i===0),!c)return;let f=l?s:s+4,u=n[f];t[e-1]=u%4,t[e]=(i+4+Math.floor(u/4)-Math.floor(f/4))%4};vt.setMatrixArrayType(Float64Array);var $N=oe.fromValues(-1,1),kD=!0,oie=(t,e,r,o=kD)=>{let n=BigInt(t),i=r==="vu"||r==="wu"||r==="vw",s=r==="wv"||r==="vw",a=r==="wu"||r==="uw";i&&(n=(1n<<BigInt(2*e))-n-1n);let c=nie(n,e,s,a,o);if(a){let{offset:[l,f],flips:[u,d]}=c;c.offset=[f,l],u===yr&&oe.add(c.offset,c.offset,$N),d===yr&&oe.subtract(c.offset,c.offset,$N)}if(s){let{offset:[l,f],flips:u}=c,d=(1<<e)-(l+f);u[0]=-u[0],c.offset[1]=d,c.flips=u}return c},nie=(t,e,r,o,n=kD)=>{let i=oe.create(),s=[jt,jt],a=BigInt(t),c=[];for(;a>0n||c.length<e;)c.push(Number(a%4n)),a=a>>2n;let l=o?UD:DD;for(let u=c.length-1;u>=0;u--)n&&rie(c,u,s,r,l),oe.multiply(s,s,GN(c[u]));s[0]=jt,s[1]=jt;for(let u=c.length-1;u>=0;u--){oe.scale(i,i,2);let d=tie(c[u],s);oe.add(i,i,d),oe.multiply(s,s,GN(c[u]))}return{q:c[0]||0,offset:eie(i),flips:s}};var Si=.1,VGe=[[Si*Math.cos(45*Math.PI/180),Si*Math.sin(45*Math.PI/180)],[Si*Math.cos(113*Math.PI/180),Si*Math.sin(113*Math.PI/180)],[Si*Math.cos(293*Math.PI/180),Si*Math.sin(293*Math.PI/180)],[Si*Math.cos(225*Math.PI/180),Si*Math.sin(225*Math.PI/180)]];vt.setMatrixArrayType(Float64Array);var iie=!1,sie=oe.clone(Dd),aie=oe.negate(oe.create(),Dd),qS=[0,1,2,3,4].map(t=>{let e=Ns.create();return Ns.fromRotation(e,N0*t),e}),XN=oe.create();function cie(t,e,r){let o=(iie?PD:Bne).clone();oe.transformMat2(XN,r.offset,MD),r.flips[0]===jt&&r.flips[1]===yr&&o.rotate180();let{q:n}=r,i=r.flips[0]+r.flips[1];return((i===-2||i===2)&&n>1||i===0&&(n===0||n===3))&&o.reflectY(),r.flips[0]===yr&&r.flips[1]===yr?o.rotate180():r.flips[0]===yr?o.translate(aie):r.flips[1]===yr&&o.translate(sie),o.translate(XN),o.scale(1/2**t),o.transform(qS[e]),o}function VD(t){let e=PD.clone();return e.transform(qS[t]),e}function lie(){let t=[];for(let e of qS)t.push(oe.transformMat2(oe.create(),k0,e));return t.reverse(),new KS(t)}vt.setMatrixArrayType(Float64Array);var fie=class{constructor(){if(this.vertices=[],this.invocations=0,this.addFaceCenters(),this.addVertices(),this.addMidpoints(),this.vertices.length!==62)throw new Error("Failed to construct CRS: vertices length is not 62");Object.freeze(this.vertices)}getVertex(t){this.invocations++,this.invocations===1e4&&console.warn("Too many CRS invocations, results should be cached");for(let e of this.vertices)if(z.distance(t,e)<1e-5)return e;throw new Error("Failed to find vertex in CRS")}addFaceCenters(){ao.forEach(t=>this.add(Nc(t.axis)))}addVertices(){let t=Math.atan(Pne);for(let e of ao)for(let r=0;r<5;r++){let o=(2*r+1)*Math.PI/5,n=Nc([o+e.angle,t]);z.transformQuat(n,n,e.quat),this.add(n)}}addMidpoints(){let t=Math.atan(z0);for(let e of ao)for(let r=0;r<5;r++){let o=2*r*Math.PI/5,n=Nc([o+e.angle,t]);z.transformQuat(n,n,e.quat),this.add(n)}}add(t){let e=z.normalize(z.create(),t);return this.vertices.find(o=>z.distance(e,o)<1e-5)?!1:(this.vertices.push(e),!0)}};vt.setMatrixArrayType(Float64Array);var uie=new fie,die=class{constructor(){this.faceTriangles=[],this.sphericalTriangles=[],this.polyhedral=new Qne,this.gnomonic=new Kne}forward(t,e){let r=ao[e],o=Nc(t),n=z.create();z.transformQuat(n,o,r.inverseQuat);let i=zS(n),s=this.gnomonic.forward(i);s[1]=s[1]-r.angle;let a=this.getFaceTriangleIndex(s),c=this.shouldReflect(s),l=this.getFaceTriangle(a,c,!1),f=this.getSphericalTriangle(a,e,c);return this.polyhedral.forward(o,f,l)}inverse(t,e){let r=BN(t),o=this.getFaceTriangleIndex(r),n=this.shouldReflect(r),i=this.getFaceTriangle(o,n,!1),s=this.getSphericalTriangle(o,e,n),a=this.polyhedral.inverse(t,i,s);return zS(a)}shouldReflect(t){let[e,r]=t;return Une([e,this.normalizeGamma(r)])[0]>z0}getFaceTriangleIndex([t,e]){return(Math.floor(e/$o)+10)%10}getFaceTriangle(t,e=!1,r=!1){let o=t;return e&&(o+=r?20:10),this.faceTriangles[o]?this.faceTriangles[o]:(this.faceTriangles[o]=e?this._getReflectedFaceTriangle(t,r):this._getFaceTriangle(t),Object.freeze(this.faceTriangles[o]),this.faceTriangles[o])}_getFaceTriangle(t){let e=Math.floor((t+1)/2)%5,[r,o,n]=VD(e).getVertices(),i=oe.create();return oe.lerp(i,o,n,.5),t%2===0?[r,i,o]:[r,n,i]}_getReflectedFaceTriangle(t,e=!1){let[r,o,n]=this._getFaceTriangle(t).map(a=>oe.clone(a)),i=t%2===0;oe.negate(r,r);let s=i?o:n;return oe.scaleAndAdd(r,r,s,e?1+1/Math.cos(kS):2),[r,n,o]}getSphericalTriangle(t,e,r=!1){let o=10*e+t;return r&&(o+=120),this.sphericalTriangles[o]?this.sphericalTriangles[o]:(this.sphericalTriangles[o]=this._getSphericalTriangle(t,e,r),Object.freeze(this.sphericalTriangles[o]),this.sphericalTriangles[o])}_getSphericalTriangle(t,e,r=!1){let o=ao[e];return this.getFaceTriangle(t,r,!0).map(s=>{let[a,c]=BN(s),l=[a,c+o.angle],f=Nc(this.gnomonic.inverse(l));return z.transformQuat(f,f,o.quat),uie.getVertex(f)})}normalizeGamma(t){let e=t/N0,r=Math.round(e);return(e-r)*N0}},Dc=2,GS=30,YN=58n,hie=0n;function pie(t){if(t===0n)return-1;if(t&1n||(t&0b111n)===0b100n||(t&0b11111n)===0b10000n)return GS;let e=GS-1,r=t>>1n;if(r===0n)return-1;let o=Number(r&0xFFFFFFFFn),n;for(o===0?(r>>=32n,e-=16,n=Number(r)):n=o,n&65535||(n>>=16,e-=8),e>=6&&!(n&255)&&(n>>=8,e-=4),e>=4&&!(n&15)&&(n>>=4,e-=2);e>-1&&!(n&1);)e-=1,n=n>>(e<Dc?1:2);return e}function mie(t){let e=pie(t);if(e===-1)return{origin:ao[0],segment:0,S:0n,resolution:e};let r=YN,o=0;if(e===GS){let u=t&1n?1n:t&0b100n?3n:5n;r=YN+u,o=u===1n?0:u===3n?32:40}let n=Number(t>>r)+o,i,s;if(e===0)i=ao[n],s=0;else{let u=Math.floor(n/5);i=ao[u],s=(n+i.firstQuintant)%5}if(!i)throw new Error(`Could not parse origin: ${n}`);if(e<Dc)return{origin:i,segment:s,S:0n,resolution:e};let a=e-Dc+1,c=BigInt(2*a),l=(1n<<r)-1n,f=(t&l)>>r-c;return{origin:i,segment:s,S:f,resolution:e}}vt.setMatrixArrayType(Float64Array);var zGe=Ns.create(),gie=new die;function _ie({S:t,segment:e,origin:r,resolution:o}){let{quintant:n,orientation:i}=Yne(e,r);if(o===Dc-1)return VD(n);if(o===Dc-2)return lie();let s=o-Dc+1,a=oie(t,s,i);return cie(s,n,a)}function zD(t,{closedRing:e=!0,segments:r="auto"}={closedRing:!0,segments:"auto"}){if(t===hie)return[];let{S:o,segment:n,origin:i,resolution:s}=mie(t);r==="auto"&&(r=Math.max(1,Math.pow(2,6-s)));let u=_ie({S:o,segment:n,origin:i,resolution:s}).splitEdges(r).getVertices().map(h=>gie.inverse(h,i.id)).map(h=>LD(h)),d=Hne(u);return e&&d.push(d[0]),d.reverse(),d}function HD(t){return BigInt(`0x${t}`)}var jD=2;var yie=jD*D0/Math.sqrt(15),WD=new Array(31);WD[0]=jD*D0/Math.sqrt(3);for(let t=1;t<=30;t++)WD[t]=yie/(1<<t-1);vt.setMatrixArrayType(Float64Array);var Vd=kn(kd(),1);function W0(t,e){e=e===void 0?t[0][0]:e;for(let r of t){let o=r[0]-e;o>180?r[0]-=360:o<-180&&(r[0]+=360)}}function xie(t,e,r){let[o,n]=(0,Vd.cellToLatLng)(t),i=e.length;W0(e,n);let s=e[0]===e[i-1]?i-1:i;for(let a=0;a<s;a++)e[a][0]=lt(n,e[a][0],r),e[a][1]=lt(o,e[a][1],r)}function $D(t,e,r){let o=t(e,r),[n,i]=(0,Vd.cellToLatLng)(o);return[i,n]}function ZS(t,e=1){let r=(0,Vd.cellToBoundary)(t,!0);return e!==1?xie(t,r,e):W0(r),r}function G0(t){let e=new Float64Array(t.length*2),r=0;for(let o of t)e[r++]=o[0],e[r++]=o[1];return e}var bie={getPentagon:{type:"accessor",value:t=>t.pentagon}},zd=class extends Or{indexToBounds(){let{data:e,getPentagon:r}=this.props;return{data:e,_normalize:!1,_windingOrder:"CCW",positionFormat:"XY",getPolygon:(o,n)=>{let i=r(o,n),s=zD(typeof i=="string"?HD(i):i,{closedRing:!0,segments:"auto"});return G0(s)}}}};zd.layerName="A5Layer";zd.defaultProps=bie;var XD=zd;function Aie(t){return typeof t=="string"?t.charAt(0).toLowerCase()+t.slice(1):t}function $0(t){if(Array.isArray(t))return t.map(e=>$0(e));if(t&&typeof t=="object"){let e={};for(let[r,o]of Object.entries(t))e[Aie(r)]=$0(o);return e}return t}var YD=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",Tie=YD+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",vie="["+YD+"]["+Tie+"]*",Sie=new RegExp("^"+vie+"$");function X0(t,e){let r=[],o=e.exec(t);for(;o;){let n=[];n.startIndex=e.lastIndex-o[0].length;let i=o.length;for(let s=0;s<i;s++)n.push(o[s]);r.push(n),o=e.exec(t)}return r}var Uc=function(t){let e=Sie.exec(t);return!(e===null||typeof e>"u")};function KD(t){return typeof t<"u"}var Hd=["hasOwnProperty","toString","valueOf","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"],Y0=["__proto__","constructor","prototype"];var Cie={allowBooleanAttributes:!1,unpairedTags:[]};function eU(t,e){e=Object.assign({},Cie,e);let r=[],o=!1,n=!1;t[0]==="\uFEFF"&&(t=t.substr(1));for(let i=0;i<t.length;i++)if(t[i]==="<"&&t[i+1]==="?"){if(i+=2,i=ZD(t,i),i.err)return i}else if(t[i]==="<"){let s=i;if(i++,t[i]==="!"){i=JD(t,i);continue}else{let a=!1;t[i]==="/"&&(a=!0,i++);let c="";for(;i<t.length&&t[i]!==">"&&t[i]!==" "&&t[i]!==" "&&t[i]!==` `&&t[i]!=="\r";i++)c+=t[i];if(c=c.trim(),c[c.length-1]==="/"&&(c=c.substring(0,c.length-1),i--),!Bie(c)){let u;return c.trim().length===0?u="Invalid space after '<'.":u="Tag '"+c+"' is an invalid name.",qe("InvalidTag",u,Wt(t,i))}let l=Pie(t,i);if(l===!1)return qe("InvalidAttr","Attributes for '"+c+"' have open quote.",Wt(t,i));let f=l.value;if(i=l.index,f[f.length-1]==="/"){let u=i-f.length;f=f.substring(0,f.length-1);let d=QD(f,e);if(d===!0)o=!0;else return qe(d.err.code,d.err.msg,Wt(t,u+d.err.line))}else if(a)if(l.tagClosed){if(f.trim().length>0)return qe("InvalidTag","Closing tag '"+c+"' can't have attributes or invalid starting.",Wt(t,s));if(r.length===0)return qe("InvalidTag","Closing tag '"+c+"' has not been opened.",Wt(t,s));{let u=r.pop();if(c!==u.tagName){let d=Wt(t,u.tagStartPos);return qe("InvalidTag","Expected closing tag '"+u.tagName+"' (opened in line "+d.line+", col "+d.col+") instead of closing tag '"+c+"'.",Wt(t,s))}r.length==0&&(n=!0)}}else return qe("InvalidTag","Closing tag '"+c+"' doesn't have proper closing.",Wt(t,i));else{let u=QD(f,e);if(u!==!0)return qe(u.err.code,u.err.msg,Wt(t,i-f.length+u.err.line));if(n===!0)return qe("InvalidXml","Multiple possible root nodes found.",Wt(t,i));e.unpairedTags.indexOf(c)!==-1||r.push({tagName:c,tagStartPos:s}),o=!0}for(i++;i<t.length;i++)if(t[i]==="<")if(t[i+1]==="!"){i++,i=JD(t,i);continue}else if(t[i+1]==="?"){if(i=ZD(t,++i),i.err)return i}else break;else if(t[i]==="&"){let u=Iie(t,i);if(u==-1)return qe("InvalidChar","char '&' is not expected.",Wt(t,i));i=u}else if(n===!0&&!qD(t[i]))return qe("InvalidXml","Extra text at the end",Wt(t,i));t[i]==="<"&&i--}}else{if(qD(t[i]))continue;return qe("InvalidChar","char '"+t[i]+"' is not expected.",Wt(t,i))}if(o){if(r.length==1)return qe("InvalidTag","Unclosed tag '"+r[0].tagName+"'.",Wt(t,r[0].tagStartPos));if(r.length>0)return qe("InvalidXml","Invalid '"+JSON.stringify(r.map(i=>i.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return qe("InvalidXml","Start tag expected.",1);return!0}function qD(t){return t===" "||t===" "||t===` `||t==="\r"}function ZD(t,e){let r=e;for(;e<t.length;e++)if(t[e]=="?"||t[e]==" "){let o=t.substr(r,e-r);if(e>5&&o==="xml")return qe("InvalidXml","XML declaration allowed only at the start of the document.",Wt(t,e));if(t[e]=="?"&&t[e+1]==">"){e++;break}else continue}return e}function JD(t,e){if(t.length>e+5&&t[e+1]==="-"&&t[e+2]==="-"){for(e+=3;e<t.length;e++)if(t[e]==="-"&&t[e+1]==="-"&&t[e+2]===">"){e+=2;break}}else if(t.length>e+8&&t[e+1]==="D"&&t[e+2]==="O"&&t[e+3]==="C"&&t[e+4]==="T"&&t[e+5]==="Y"&&t[e+6]==="P"&&t[e+7]==="E"){let r=1;for(e+=8;e<t.length;e++)if(t[e]==="<")r++;else if(t[e]===">"&&(r--,r===0))break}else if(t.length>e+9&&t[e+1]==="["&&t[e+2]==="C"&&t[e+3]==="D"&&t[e+4]==="A"&&t[e+5]==="T"&&t[e+6]==="A"&&t[e+7]==="["){for(e+=8;e<t.length;e++)if(t[e]==="]"&&t[e+1]==="]"&&t[e+2]===">"){e+=2;break}}return e}var Eie='"',wie="'";function Pie(t,e){let r="",o="",n=!1;for(;e<t.length;e++){if(t[e]===Eie||t[e]===wie)o===""?o=t[e]:o!==t[e]||(o="");else if(t[e]===">"&&o===""){n=!0;break}r+=t[e]}return o!==""?!1:{value:r,index:e,tagClosed:n}}var Mie=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function QD(t,e){let r=X0(t,Mie),o={};for(let n=0;n<r.length;n++){if(r[n][1].length===0)return qe("InvalidAttr","Attribute '"+r[n][2]+"' has no space in starting.",jd(r[n]));if(r[n][3]!==void 0&&r[n][4]===void 0)return qe("InvalidAttr","Attribute '"+r[n][2]+"' is without value.",jd(r[n]));if(r[n][3]===void 0&&!e.allowBooleanAttributes)return qe("InvalidAttr","boolean attribute '"+r[n][2]+"' is not allowed.",jd(r[n]));let i=r[n][2];if(!Lie(i))return qe("InvalidAttr","Attribute '"+i+"' is an invalid name.",jd(r[n]));if(!Object.prototype.hasOwnProperty.call(o,i))o[i]=1;else return qe("InvalidAttr","Attribute '"+i+"' is repeated.",jd(r[n]))}return!0}function Rie(t,e){let r=/\d/;for(t[e]==="x"&&(e++,r=/[\da-fA-F]/);e<t.length;e++){if(t[e]===";")return e;if(!t[e].match(r))break}return-1}function Iie(t,e){if(e++,t[e]===";")return-1;if(t[e]==="#")return e++,Rie(t,e);let r=0;for(;e<t.length;e++,r++)if(!(t[e].match(/\w/)&&r<20)){if(t[e]===";")break;return-1}return e}function qe(t,e,r){return{err:{code:t,msg:e,line:r.line||r,col:r.col}}}function Lie(t){return Uc(t)}function Bie(t){return Uc(t)}function Wt(t,e){let r=t.substring(0,e).split(/\r?\n/);return{line:r.length,col:r[r.length-1].length+1}}function jd(t){return t.startIndex+t[1].length}var tU=t=>Hd.includes(t)?"__"+t:t,Oie={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(t,e,r){return t},captureMetaData:!1,maxNestedTags:100,strictReservedNames:!0,jPath:!0,onDangerousProperty:tU};function Fie(t,e){if(typeof t!="string")return;let r=t.toLowerCase();if(Hd.some(o=>r===o.toLowerCase()))throw new Error(`[SECURITY] Invalid ${e}: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`);if(Y0.some(o=>r===o.toLowerCase()))throw new Error(`[SECURITY] Invalid ${e}: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`)}function rU(t){return typeof t=="boolean"?{enabled:t,maxEntitySize:1e4,maxExpansionDepth:10,maxTotalExpansions:1e3,maxExpandedLength:1e5,maxEntityCount:100,allowedTags:null,tagFilter:null}:typeof t=="object"&&t!==null?{enabled:t.enabled!==!1,maxEntitySize:Math.max(1,t.maxEntitySize??1e4),maxExpansionDepth:Math.max(1,t.maxExpansionDepth??1e4),maxTotalExpansions:Math.max(1,t.maxTotalExpansions??1/0),maxExpandedLength:Math.max(1,t.maxExpandedLength??1e5),maxEntityCount:Math.max(1,t.maxEntityCount??1e3),allowedTags:t.allowedTags??null,tagFilter:t.tagFilter??null}:rU(!0)}var oU=function(t){let e=Object.assign({},Oie,t),r=[{value:e.attributeNamePrefix,name:"attributeNamePrefix"},{value:e.attributesGroupName,name:"attributesGroupName"},{value:e.textNodeName,name:"textNodeName"},{value:e.cdataPropName,name:"cdataPropName"},{value:e.commentPropName,name:"commentPropName"}];for(let{value:o,name:n}of r)o&&Fie(o,n);return e.onDangerousProperty===null&&(e.onDangerousProperty=tU),e.processEntities=rU(e.processEntities),e.unpairedTagsSet=new Set(e.unpairedTags),e.stopNodes&&Array.isArray(e.stopNodes)&&(e.stopNodes=e.stopNodes.map(o=>typeof o=="string"&&o.startsWith("*.")?".."+o.substring(2):o)),e};var K0;typeof Symbol!="function"?K0="@@xmlMetadata":K0=Symbol("XML Node Metadata");var Qt=class{constructor(e){this.tagname=e,this.child=[],this[":@"]=Object.create(null)}add(e,r){e==="__proto__"&&(e="#__proto__"),this.child.push({[e]:r})}addChild(e,r){e.tagname==="__proto__"&&(e.tagname="#__proto__"),e[":@"]&&Object.keys(e[":@"]).length>0?this.child.push({[e.tagname]:e.child,[":@"]:e[":@"]}):this.child.push({[e.tagname]:e.child}),r!==void 0&&(this.child[this.child.length-1][K0]={startIndex:r})}static getMetaDataSymbol(){return K0}};var Gd=class{constructor(e){this.suppressValidationErr=!e,this.options=e}readDocType(e,r){let o=Object.create(null),n=0;if(e[r+3]==="O"&&e[r+4]==="C"&&e[r+5]==="T"&&e[r+6]==="Y"&&e[r+7]==="P"&&e[r+8]==="E"){r=r+9;let i=1,s=!1,a=!1,c="";for(;r<e.length;r++)if(e[r]==="<"&&!a){if(s&&Us(e,"!ENTITY",r)){r+=7;let l,f;if([l,f,r]=this.readEntityExp(e,r+1,this.suppressValidationErr),f.indexOf("&")===-1){if(this.options.enabled!==!1&&this.options.maxEntityCount!=null&&n>=this.options.maxEntityCount)throw new Error(`Entity count (${n+1}) exceeds maximum allowed (${this.options.maxEntityCount})`);let u=l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");o[l]={regx:RegExp(`&${u};`,"g"),val:f},n++}}else if(s&&Us(e,"!ELEMENT",r)){r+=8;let{index:l}=this.readElementExp(e,r+1);r=l}else if(s&&Us(e,"!ATTLIST",r))r+=8;else if(s&&Us(e,"!NOTATION",r)){r+=9;let{index:l}=this.readNotationExp(e,r+1,this.suppressValidationErr);r=l}else if(Us(e,"!--",r))a=!0;else throw new Error("Invalid DOCTYPE");i++,c=""}else if(e[r]===">"){if(a?e[r-1]==="-"&&e[r-2]==="-"&&(a=!1,i--):i--,i===0)break}else e[r]==="["?s=!0:c+=e[r];if(i!==0)throw new Error("Unclosed DOCTYPE")}else throw new Error("Invalid Tag instead of DOCTYPE");return{entities:o,i:r}}readEntityExp(e,r){r=er(e,r);let o=r;for(;r<e.length&&!/\s/.test(e[r])&&e[r]!=='"'&&e[r]!=="'";)r++;let n=e.substring(o,r);if(Wd(n),r=er(e,r),!this.suppressValidationErr){if(e.substring(r,r+6).toUpperCase()==="SYSTEM")throw new Error("External entities are not supported");if(e[r]==="%")throw new Error("Parameter entities are not supported")}let i="";if([r,i]=this.readIdentifierVal(e,r,"entity"),this.options.enabled!==!1&&this.options.maxEntitySize!=null&&i.length>this.options.maxEntitySize)throw new Error(`Entity "${n}" size (${i.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return r--,[n,i,r]}readNotationExp(e,r){r=er(e,r);let o=r;for(;r<e.length&&!/\s/.test(e[r]);)r++;let n=e.substring(o,r);!this.suppressValidationErr&&Wd(n),r=er(e,r);let i=e.substring(r,r+6).toUpperCase();if(!this.suppressValidationErr&&i!=="SYSTEM"&&i!=="PUBLIC")throw new Error(`Expected SYSTEM or PUBLIC, found "${i}"`);r+=i.length,r=er(e,r);let s=null,a=null;if(i==="PUBLIC")[r,s]=this.readIdentifierVal(e,r,"publicIdentifier"),r=er(e,r),(e[r]==='"'||e[r]==="'")&&([r,a]=this.readIdentifierVal(e,r,"systemIdentifier"));else if(i==="SYSTEM"&&([r,a]=this.readIdentifierVal(e,r,"systemIdentifier"),!this.suppressValidationErr&&!a))throw new Error("Missing mandatory system identifier for SYSTEM notation");return{notationName:n,publicIdentifier:s,systemIdentifier:a,index:--r}}readIdentifierVal(e,r,o){let n="",i=e[r];if(i!=='"'&&i!=="'")throw new Error(`Expected quoted string, found "${i}"`);r++;let s=r;for(;r<e.length&&e[r]!==i;)r++;if(n=e.substring(s,r),e[r]!==i)throw new Error(`Unterminated ${o} value`);return r++,[r,n]}readElementExp(e,r){r=er(e,r);let o=r;for(;r<e.length&&!/\s/.test(e[r]);)r++;let n=e.substring(o,r);if(!this.suppressValidationErr&&!Uc(n))throw new Error(`Invalid element name: "${n}"`);r=er(e,r);let i="";if(e[r]==="E"&&Us(e,"MPTY",r))r+=4;else if(e[r]==="A"&&Us(e,"NY",r))r+=2;else if(e[r]==="("){r++;let s=r;for(;r<e.length&&e[r]!==")";)r++;if(i=e.substring(s,r),e[r]!==")")throw new Error("Unterminated content model")}else if(!this.suppressValidationErr)throw new Error(`Invalid Element Expression, found "${e[r]}"`);return{elementName:n,contentModel:i.trim(),index:r}}readAttlistExp(e,r){r=er(e,r);let o=r;for(;r<e.length&&!/\s/.test(e[r]);)r++;let n=e.substring(o,r);for(Wd(n),r=er(e,r),o=r;r<e.length&&!/\s/.test(e[r]);)r++;let i=e.substring(o,r);if(!Wd(i))throw new Error(`Invalid attribute name: "${i}"`);r=er(e,r);let s="";if(e.substring(r,r+8).toUpperCase()==="NOTATION"){if(s="NOTATION",r+=8,r=er(e,r),e[r]!=="(")throw new Error(`Expected '(', found "${e[r]}"`);r++;let c=[];for(;r<e.length&&e[r]!==")";){let l=r;for(;r<e.length&&e[r]!=="|"&&e[r]!==")";)r++;let f=e.substring(l,r);if(f=f.trim(),!Wd(f))throw new Error(`Invalid notation name: "${f}"`);c.push(f),e[r]==="|"&&(r++,r=er(e,r))}if(e[r]!==")")throw new Error("Unterminated list of notations");r++,s+=" ("+c.join("|")+")"}else{let c=r;for(;r<e.length&&!/\s/.test(e[r]);)r++;s+=e.substring(c,r);let l=["CDATA","ID","IDREF","IDREFS","ENTITY","ENTITIES","NMTOKEN","NMTOKENS"];if(!this.suppressValidationErr&&!l.includes(s.toUpperCase()))throw new Error(`Invalid attribute type: "${s}"`)}r=er(e,r);let a="";return e.substring(r,r+8).toUpperCase()==="#REQUIRED"?(a="#REQUIRED",r+=8):e.substring(r,r+7).toUpperCase()==="#IMPLIED"?(a="#IMPLIED",r+=7):[r,a]=this.readIdentifierVal(e,r,"ATTLIST"),{elementName:n,attributeName:i,attributeType:s,defaultValue:a,index:r}}},er=(t,e)=>{for(;e<t.length&&/\s/.test(t[e]);)e++;return e};function Us(t,e,r){for(let o=0;o<e.length;o++)if(e[o]!==t[r+o+1])return!1;return!0}function Wd(t){if(Uc(t))return t;throw new Error(`Invalid entity name ${t}`)}var Nie=/^[-+]?0x[a-fA-F0-9]+$/,Die=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,Uie={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0,infinity:"original"};function JS(t,e={}){if(e=Object.assign({},Uie,e),!t||typeof t!="string")return t;let r=t.trim();if(r.length===0)return t;if(e.skipLike!==void 0&&e.skipLike.test(r))return t;if(r==="0")return 0;if(e.hex&&Nie.test(r))return Hie(r,16);if(isFinite(r)){if(r.includes("e")||r.includes("E"))return Vie(t,r,e);{let o=Die.exec(r);if(o){let n=o[1]||"",i=o[2],s=zie(o[3]),a=n?t[i.length+1]===".":t[i.length]===".";if(!e.leadingZeros&&(i.length>1||i.length===1&&!a))return t;{let c=Number(r),l=String(c);if(c===0)return c;if(l.search(/[eE]/)!==-1)return e.eNotation?c:t;if(r.indexOf(".")!==-1)return l==="0"||l===s||l===`${n}${s}`?c:t;let f=i?s:r;return i?f===l||n+f===l?c:t:f===l||f===n+l?c:t}}else return t}}else return jie(t,Number(r),e)}var kie=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function Vie(t,e,r){if(!r.eNotation)return t;let o=e.match(kie);if(o){let n=o[1]||"",i=o[3].indexOf("e")===-1?"E":"e",s=o[2],a=n?t[s.length+1]===i:t[s.length]===i;return s.length>1&&a?t:s.length===1&&(o[3].startsWith(`.${i}`)||o[3][0]===i)?Number(e):s.length>0?r.leadingZeros&&!a?(e=(o[1]||"")+o[3],Number(e)):t:Number(e)}else return t}function zie(t){return t&&t.indexOf(".")!==-1&&(t=t.replace(/0+$/,""),t==="."?t="0":t[0]==="."?t="0"+t:t[t.length-1]==="."&&(t=t.substring(0,t.length-1))),t}function Hie(t,e){if(parseInt)return parseInt(t,e);if(Number.parseInt)return Number.parseInt(t,e);if(window&&window.parseInt)return window.parseInt(t,e);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}function jie(t,e,r){let o=e===1/0;switch(r.infinity.toLowerCase()){case"null":return null;case"infinity":return e;case"string":return o?"Infinity":"-Infinity";case"original":default:return t}}function QS(t){return typeof t=="function"?t:Array.isArray(t)?e=>{for(let r of t)if(typeof r=="string"&&e===r||r instanceof RegExp&&r.test(e))return!0}:()=>!1}var ks=class{constructor(e,r={},o){this.pattern=e,this.separator=r.separator||".",this.segments=this._parse(e),this.data=o,this._hasDeepWildcard=this.segments.some(n=>n.type==="deep-wildcard"),this._hasAttributeCondition=this.segments.some(n=>n.attrName!==void 0),this._hasPositionSelector=this.segments.some(n=>n.position!==void 0)}_parse(e){let r=[],o=0,n="";for(;o<e.length;)e[o]===this.separator?o+1<e.length&&e[o+1]===this.separator?(n.trim()&&(r.push(this._parseSegment(n.trim())),n=""),r.push({type:"deep-wildcard"}),o+=2):(n.trim()&&r.push(this._parseSegment(n.trim())),n="",o++):(n+=e[o],o++);return n.trim()&&r.push(this._parseSegment(n.trim())),r}_parseSegment(e){let r={type:"tag"},o=null,n=e,i=e.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);if(i&&(n=i[1]+i[3],i[2])){let f=i[2].slice(1,-1);f&&(o=f)}let s,a=n;if(n.includes("::")){let f=n.indexOf("::");if(s=n.substring(0,f).trim(),a=n.substring(f+2).trim(),!s)throw new Error(`Invalid namespace in pattern: ${e}`)}let c,l=null;if(a.includes(":")){let f=a.lastIndexOf(":"),u=a.substring(0,f).trim(),d=a.substring(f+1).trim();["first","last","odd","even"].includes(d)||/^nth\(\d+\)$/.test(d)?(c=u,l=d):c=a}else c=a;if(!c)throw new Error(`Invalid segment pattern: ${e}`);if(r.tag=c,s&&(r.namespace=s),o)if(o.includes("=")){let f=o.indexOf("=");r.attrName=o.substring(0,f).trim(),r.attrValue=o.substring(f+1).trim()}else r.attrName=o.trim();if(l){let f=l.match(/^nth\((\d+)\)$/);f?(r.position="nth",r.positionValue=parseInt(f[1],10)):r.position=l}return r}get length(){return this.segments.length}hasDeepWildcard(){return this._hasDeepWildcard}hasAttributeCondition(){return this._hasAttributeCondition}hasPositionSelector(){return this._hasPositionSelector}toString(){return this.pattern}};var kc=class{constructor(){this._byDepthAndTag=new Map,this._wildcardByDepth=new Map,this._deepWildcards=[],this._patterns=new Set,this._sealed=!1}add(e){if(this._sealed)throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions.");if(this._patterns.has(e.pattern))return this;if(this._patterns.add(e.pattern),e.hasDeepWildcard())return this._deepWildcards.push(e),this;let r=e.length,n=e.segments[e.segments.length-1]?.tag;if(!n||n==="*")this._wildcardByDepth.has(r)||this._wildcardByDepth.set(r,[]),this._wildcardByDepth.get(r).push(e);else{let i=`${r}:${n}`;this._byDepthAndTag.has(i)||this._byDepthAndTag.set(i,[]),this._byDepthAndTag.get(i).push(e)}return this}addAll(e){for(let r of e)this.add(r);return this}has(e){return this._patterns.has(e.pattern)}get size(){return this._patterns.size}seal(){return this._sealed=!0,this}get isSealed(){return this._sealed}matchesAny(e){return this.findMatch(e)!==null}findMatch(e){let r=e.getDepth(),o=e.getCurrentTag(),n=`${r}:${o}`,i=this._byDepthAndTag.get(n);if(i){for(let a=0;a<i.length;a++)if(e.matches(i[a]))return i[a]}let s=this._wildcardByDepth.get(r);if(s){for(let a=0;a<s.length;a++)if(e.matches(s[a]))return s[a]}for(let a=0;a<this._deepWildcards.length;a++)if(e.matches(this._deepWildcards[a]))return this._deepWildcards[a];return null}};var Wie=new Set(["push","pop","reset","updateCurrent","restore"]),Vc=class{constructor(e={}){this.separator=e.separator||".",this.path=[],this.siblingStacks=[],this._pathStringCache=null,this._frozenPathCache=null,this._frozenSiblingsCache=null}push(e,r=null,o=null){if(this._pathStringCache=null,this._frozenPathCache=null,this._frozenSiblingsCache=null,this.path.length>0){let f=this.path[this.path.length-1];f.values=void 0}let n=this.path.length;this.siblingStacks[n]||(this.siblingStacks[n]=new Map);let i=this.siblingStacks[n],s=o?`${o}:${e}`:e,a=i.get(s)||0,c=0;for(let f of i.values())c+=f;i.set(s,a+1);let l={tag:e,position:c,counter:a};o!=null&&(l.namespace=o),r!=null&&(l.values=r),this.path.push(l)}pop(){if(this.path.length===0)return;this._pathStringCache=null,this._frozenPathCache=null,this._frozenSiblingsCache=null;let e=this.path.pop();return this.siblingStacks.length>this.path.length+1&&(this.siblingStacks.length=this.path.length+1),e}updateCurrent(e){if(this.path.length>0){let r=this.path[this.path.length-1];e!=null&&(r.values=e,this._frozenPathCache=null)}}getCurrentTag(){return this.path.length>0?this.path[this.path.length-1].tag:void 0}getCurrentNamespace(){return this.path.length>0?this.path[this.path.length-1].namespace:void 0}getAttrValue(e){return this.path.length===0?void 0:this.path[this.path.length-1].values?.[e]}hasAttr(e){if(this.path.length===0)return!1;let r=this.path[this.path.length-1];return r.values!==void 0&&e in r.values}getPosition(){return this.path.length===0?-1:this.path[this.path.length-1].position??0}getCounter(){return this.path.length===0?-1:this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(e,r=!0){let o=e||this.separator;if(o===this.separator&&r===!0){if(this._pathStringCache!==null&&this._pathStringCache!==void 0)return this._pathStringCache;let i=this.path.map(s=>r&&s.namespace?`${s.namespace}:${s.tag}`:s.tag).join(o);return this._pathStringCache=i,i}return this.path.map(i=>r&&i.namespace?`${i.namespace}:${i.tag}`:i.tag).join(o)}toArray(){return this.path.map(e=>e.tag)}reset(){this._pathStringCache=null,this._frozenPathCache=null,this._frozenSiblingsCache=null,this.path=[],this.siblingStacks=[]}matches(e){let r=e.segments;return r.length===0?!1:e.hasDeepWildcard()?this._matchWithDeepWildcard(r):this._matchSimple(r)}_matchSimple(e){if(this.path.length!==e.length)return!1;for(let r=0;r<e.length;r++){let o=e[r],n=this.path[r],i=r===this.path.length-1;if(!this._matchSegment(o,n,i))return!1}return!0}_matchWithDeepWildcard(e){let r=this.path.length-1,o=e.length-1;for(;o>=0&&r>=0;){let n=e[o];if(n.type==="deep-wildcard"){if(o--,o<0)return!0;let i=e[o],s=!1;for(let a=r;a>=0;a--){let c=a===this.path.length-1;if(this._matchSegment(i,this.path[a],c)){r=a-1,o--,s=!0;break}}if(!s)return!1}else{let i=r===this.path.length-1;if(!this._matchSegment(n,this.path[r],i))return!1;r--,o--}}return o<0}_matchSegment(e,r,o){if(e.tag!=="*"&&e.tag!==r.tag||e.namespace!==void 0&&e.namespace!=="*"&&e.namespace!==r.namespace)return!1;if(e.attrName!==void 0){if(!o||!r.values||!(e.attrName in r.values))return!1;if(e.attrValue!==void 0){let n=r.values[e.attrName];if(String(n)!==String(e.attrValue))return!1}}if(e.position!==void 0){if(!o)return!1;let n=r.counter??0;if(e.position==="first"&&n!==0)return!1;if(e.position==="odd"&&n%2!==1)return!1;if(e.position==="even"&&n%2!==0)return!1;if(e.position==="nth"&&n!==e.positionValue)return!1}return!0}matchesAny(e){return e.matchesAny(this)}snapshot(){return{path:this.path.map(e=>({...e})),siblingStacks:this.siblingStacks.map(e=>new Map(e))}}restore(e){this._pathStringCache=null,this._frozenPathCache=null,this._frozenSiblingsCache=null,this.path=e.path.map(r=>({...r})),this.siblingStacks=e.siblingStacks.map(r=>new Map(r))}readOnly(){let e=this;return new Proxy(e,{get(r,o,n){if(Wie.has(o))return()=>{throw new TypeError(`Cannot call '${o}' on a read-only Matcher. Obtain a writable instance to mutate state.`)};if(o==="path")return r._frozenPathCache===null&&(r._frozenPathCache=Object.freeze(r.path.map(s=>Object.freeze({...s})))),r._frozenPathCache;if(o==="siblingStacks")return r._frozenSiblingsCache===null&&(r._frozenSiblingsCache=Object.freeze(r.siblingStacks.map(s=>Object.freeze(new Map(s))))),r._frozenSiblingsCache;let i=Reflect.get(r,o,n);return typeof i=="function"?i.bind(r):i},set(r,o){throw new TypeError(`Cannot set property '${String(o)}' on a read-only Matcher.`)},deleteProperty(r,o){throw new TypeError(`Cannot delete property '${String(o)}' from a read-only Matcher.`)}})}};function Gie(t,e){if(!t)return{};let r=e.attributesGroupName?t[e.attributesGroupName]:t;if(!r)return{};let o={};for(let n in r)if(n.startsWith(e.attributeNamePrefix)){let i=n.substring(e.attributeNamePrefix.length);o[i]=r[n]}else o[n]=r[n];return o}function $ie(t){if(!t||typeof t!="string")return;let e=t.indexOf(":");if(e!==-1&&e>0){let r=t.substring(0,e);if(r!=="xmlns")return r}}var $d=class{constructor(e){this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"\xA2"},pound:{regex:/&(pound|#163);/g,val:"\xA3"},yen:{regex:/&(yen|#165);/g,val:"\xA5"},euro:{regex:/&(euro|#8364);/g,val:"\u20AC"},copyright:{regex:/&(copy|#169);/g,val:"\xA9"},reg:{regex:/&(reg|#174);/g,val:"\xAE"},inr:{regex:/&(inr|#8377);/g,val:"\u20B9"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(o,n)=>nU(n,10,"&#")},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(o,n)=>nU(n,16,"&#x")}},this.addExternalEntities=Xie,this.parseXml=Jie,this.parseTextData=Yie,this.resolveNameSpace=Kie,this.buildAttributesMap=Zie,this.isItStopNode=rse,this.replaceEntitiesValue=ese,this.readStopNodeData=ise,this.saveTextToParentTag=tse,this.addChild=Qie,this.ignoreAttributesFn=QS(this.options.ignoreAttributes),this.entityExpansionCount=0,this.currentExpandedLength=0,this.matcher=new Vc,this.readonlyMatcher=this.matcher.readOnly(),this.isCurrentNodeStopNode=!1,this.stopNodeExpressionsSet=new kc;let r=this.options.stopNodes;if(r&&r.length>0){for(let o=0;o<r.length;o++){let n=r[o];typeof n=="string"?this.stopNodeExpressionsSet.add(new ks(n)):n instanceof ks&&this.stopNodeExpressionsSet.add(n)}this.stopNodeExpressionsSet.seal()}}};function Xie(t){let e=Object.keys(t);for(let r=0;r<e.length;r++){let o=e[r],n=o.replace(/[.\-+*:]/g,"\\.");this.lastEntities[o]={regex:new RegExp("&"+n+";","g"),val:t[o]}}}function Yie(t,e,r,o,n,i,s){let a=this.options;if(t!==void 0&&(a.trimValues&&!o&&(t=t.trim()),t.length>0)){s||(t=this.replaceEntitiesValue(t,e,r));let c=a.jPath?r.toString():r,l=a.tagValueProcessor(e,t,c,n,i);return l==null?t:typeof l!=typeof t||l!==t?l:a.trimValues||t.trim()===t?rC(t,a.parseTagValue,a.numberParseOptions):t}}function Kie(t){if(this.options.removeNSPrefix){let e=t.split(":"),r=t.charAt(0)==="/"?"/":"";if(e[0]==="xmlns")return"";e.length===2&&(t=r+e[1])}return t}var qie=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function Zie(t,e,r){let o=this.options;if(o.ignoreAttributes!==!0&&typeof t=="string"){let n=X0(t,qie),i=n.length,s={},a=new Array(i),c=!1,l={};for(let d=0;d<i;d++){let h=this.resolveNameSpace(n[d][1]),p=n[d][4];if(h.length&&p!==void 0){let m=p;o.trimValues&&(m=m.trim()),m=this.replaceEntitiesValue(m,r,this.readonlyMatcher),a[d]=m,l[h]=m,c=!0}}c&&typeof e=="object"&&e.updateCurrent&&e.updateCurrent(l);let f=o.jPath?e.toString():this.readonlyMatcher,u=!1;for(let d=0;d<i;d++){let h=this.resolveNameSpace(n[d][1]);if(this.ignoreAttributesFn(h,f))continue;let p=o.attributeNamePrefix+h;if(h.length)if(o.transformAttributeName&&(p=o.transformAttributeName(p)),p=iU(p,o),n[d][4]!==void 0){let m=a[d],g=o.attributeValueProcessor(h,m,f);g==null?s[p]=m:typeof g!=typeof m||g!==m?s[p]=g:s[p]=rC(m,o.parseAttributeValue,o.numberParseOptions),u=!0}else o.allowBooleanAttributes&&(s[p]=!0,u=!0)}if(!u)return;if(o.attributesGroupName){let d={};return d[o.attributesGroupName]=s,d}return s}}var Jie=function(t){t=t.replace(/\r\n?/g,` `);let e=new Qt("!xml"),r=e,o="";this.matcher.reset(),this.entityExpansionCount=0,this.currentExpandedLength=0,this.docTypeEntitiesKeys=[],this.lastEntitiesKeys=Object.keys(this.lastEntities),this.htmlEntitiesKeys=this.options.htmlEntities?Object.keys(this.htmlEntities):[];let n=this.options,i=new Gd(n.processEntities),s=t.length;for(let a=0;a<s;a++)if(t[a]==="<"){let l=t.charCodeAt(a+1);if(l===47){let f=zc(t,">",a,"Closing Tag is not closed."),u=t.substring(a+2,f).trim();if(n.removeNSPrefix){let h=u.indexOf(":");h!==-1&&(u=u.substr(h+1))}u=eC(n.transformTagName,u,"",n).tagName,r&&(o=this.saveTextToParentTag(o,r,this.readonlyMatcher));let d=this.matcher.getCurrentTag();if(u&&n.unpairedTagsSet.has(u))throw new Error(`Unpaired tag can not be used as closing tag: </${u}>`);d&&n.unpairedTagsSet.has(d)&&(this.matcher.pop(),this.tagsNodeStack.pop()),this.matcher.pop(),this.isCurrentNodeStopNode=!1,r=this.tagsNodeStack.pop(),o="",a=f}else if(l===63){let f=tC(t,a,!1,"?>");if(!f)throw new Error("Pi Tag is not closed.");if(o=this.saveTextToParentTag(o,r,this.readonlyMatcher),!(n.ignoreDeclaration&&f.tagName==="?xml"||n.ignorePiTags)){let u=new Qt(f.tagName);u.add(n.textNodeName,""),f.tagName!==f.tagExp&&f.attrExpPresent&&(u[":@"]=this.buildAttributesMap(f.tagExp,this.matcher,f.tagName)),this.addChild(r,u,this.readonlyMatcher,a)}a=f.closeIndex+1}else if(l===33&&t.charCodeAt(a+2)===45&&t.charCodeAt(a+3)===45){let f=zc(t,"-->",a+4,"Comment is not closed.");if(n.commentPropName){let u=t.substring(a+4,f-2);o=this.saveTextToParentTag(o,r,this.readonlyMatcher),r.add(n.commentPropName,[{[n.textNodeName]:u}])}a=f}else if(l===33&&t.charCodeAt(a+2)===68){let f=i.readDocType(t,a);this.docTypeEntities=f.entities,this.docTypeEntitiesKeys=Object.keys(this.docTypeEntities)||[],a=f.i}else if(l===33&&t.charCodeAt(a+2)===91){let f=zc(t,"]]>",a,"CDATA is not closed.")-2,u=t.substring(a+9,f);o=this.saveTextToParentTag(o,r,this.readonlyMatcher);let d=this.parseTextData(u,r.tagname,this.readonlyMatcher,!0,!1,!0,!0);d==null&&(d=""),n.cdataPropName?r.add(n.cdataPropName,[{[n.textNodeName]:u}]):r.add(n.textNodeName,d),a=f+2}else{let f=tC(t,a,n.removeNSPrefix);if(!f){let v=t.substring(Math.max(0,a-50),Math.min(s,a+50));throw new Error(`readTagExp returned undefined at position ${a}. Context: "${v}"`)}let u=f.tagName,d=f.rawTagName,h=f.tagExp,p=f.attrExpPresent,m=f.closeIndex;if({tagName:u,tagExp:h}=eC(n.transformTagName,u,h,n),n.strictReservedNames&&(u===n.commentPropName||u===n.cdataPropName||u===n.textNodeName||u===n.attributesGroupName))throw new Error(`Invalid tag name: ${u}`);r&&o&&r.tagname!=="!xml"&&(o=this.saveTextToParentTag(o,r,this.readonlyMatcher,!1));let g=r;g&&n.unpairedTagsSet.has(g.tagname)&&(r=this.tagsNodeStack.pop(),this.matcher.pop());let _=!1;h.length>0&&h.lastIndexOf("/")===h.length-1&&(_=!0,u[u.length-1]==="/"?(u=u.substr(0,u.length-1),h=u):h=h.substr(0,h.length-1),p=u!==h);let x=null,y={},b;b=$ie(d),u!==e.tagname&&this.matcher.push(u,{},b),u!==h&&p&&(x=this.buildAttributesMap(h,this.matcher,u),x&&(y=Gie(x,n))),u!==e.tagname&&(this.isCurrentNodeStopNode=this.isItStopNode());let T=a;if(this.isCurrentNodeStopNode){let v="";if(_)a=f.closeIndex;else if(n.unpairedTagsSet.has(u))a=f.closeIndex;else{let C=this.readStopNodeData(t,d,m+1);if(!C)throw new Error(`Unexpected end of ${d}`);a=C.i,v=C.tagContent}let w=new Qt(u);x&&(w[":@"]=x),w.add(n.textNodeName,v),this.matcher.pop(),this.isCurrentNodeStopNode=!1,this.addChild(r,w,this.readonlyMatcher,T)}else{if(_){({tagName:u,tagExp:h}=eC(n.transformTagName,u,h,n));let v=new Qt(u);x&&(v[":@"]=x),this.addChild(r,v,this.readonlyMatcher,T),this.matcher.pop(),this.isCurrentNodeStopNode=!1}else if(n.unpairedTagsSet.has(u)){let v=new Qt(u);x&&(v[":@"]=x),this.addChild(r,v,this.readonlyMatcher,T),this.matcher.pop(),this.isCurrentNodeStopNode=!1,a=f.closeIndex;continue}else{let v=new Qt(u);if(this.tagsNodeStack.length>n.maxNestedTags)throw new Error("Maximum nested tags exceeded");this.tagsNodeStack.push(r),x&&(v[":@"]=x),this.addChild(r,v,this.readonlyMatcher,T),r=v}o="",a=m}}}else o+=t[a];return e.child};function Qie(t,e,r,o){this.options.captureMetaData||(o=void 0);let n=this.options.jPath?r.toString():r,i=this.options.updateTag(e.tagname,n,e[":@"]);i===!1||(typeof i=="string"&&(e.tagname=i),t.addChild(e,o))}function ese(t,e,r){let o=this.options.processEntities;if(!o||!o.enabled)return t;if(o.allowedTags){let n=this.options.jPath?r.toString():r;if(!(Array.isArray(o.allowedTags)?o.allowedTags.includes(e):o.allowedTags(e,n)))return t}if(o.tagFilter){let n=this.options.jPath?r.toString():r;if(!o.tagFilter(e,n))return t}for(let n of this.docTypeEntitiesKeys){let i=this.docTypeEntities[n],s=t.match(i.regx);if(s){if(this.entityExpansionCount+=s.length,o.maxTotalExpansions&&this.entityExpansionCount>o.maxTotalExpansions)throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${o.maxTotalExpansions}`);let a=t.length;if(t=t.replace(i.regx,i.val),o.maxExpandedLength&&(this.currentExpandedLength+=t.length-a,this.currentExpandedLength>o.maxExpandedLength))throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${o.maxExpandedLength}`)}}if(t.indexOf("&")===-1)return t;for(let n of this.lastEntitiesKeys){let i=this.lastEntities[n],s=t.match(i.regex);if(s&&(this.entityExpansionCount+=s.length,o.maxTotalExpansions&&this.entityExpansionCount>o.maxTotalExpansions))throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${o.maxTotalExpansions}`);t=t.replace(i.regex,i.val)}if(t.indexOf("&")===-1)return t;for(let n of this.htmlEntitiesKeys){let i=this.htmlEntities[n],s=t.match(i.regex);if(s&&(this.entityExpansionCount+=s.length,o.maxTotalExpansions&&this.entityExpansionCount>o.maxTotalExpansions))throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${o.maxTotalExpansions}`);t=t.replace(i.regex,i.val)}return t=t.replace(this.ampEntity.regex,this.ampEntity.val),t}function tse(t,e,r,o){return t&&(o===void 0&&(o=e.child.length===0),t=this.parseTextData(t,e.tagname,r,!1,e[":@"]?Object.keys(e[":@"]).length!==0:!1,o),t!==void 0&&t!==""&&e.add(this.options.textNodeName,t),t=""),t}function rse(){return this.stopNodeExpressionsSet.size===0?!1:this.matcher.matchesAny(this.stopNodeExpressionsSet)}function ose(t,e,r=">"){let o=0,n=[],i=t.length,s=r.charCodeAt(0),a=r.length>1?r.charCodeAt(1):-1;for(let c=e;c<i;c++){let l=t.charCodeAt(c);if(o)l===o&&(o=0);else if(l===34||l===39)o=l;else if(l===s)if(a!==-1){if(t.charCodeAt(c+1)===a)return{data:String.fromCharCode(...n),index:c}}else return{data:String.fromCharCode(...n),index:c};else if(l===9){n.push(32);continue}n.push(l)}}function zc(t,e,r,o){let n=t.indexOf(e,r);if(n===-1)throw new Error(o);return n+e.length-1}function nse(t,e,r,o){let n=t.indexOf(e,r);if(n===-1)throw new Error(o);return n}function tC(t,e,r,o=">"){let n=ose(t,e+1,o);if(!n)return;let i=n.data,s=n.index,a=i.search(/\s/),c=i,l=!0;a!==-1&&(c=i.substring(0,a),i=i.substring(a+1).trimStart());let f=c;if(r){let u=c.indexOf(":");u!==-1&&(c=c.substr(u+1),l=c!==n.data.substr(u+1))}return{tagName:c,tagExp:i,closeIndex:s,attrExpPresent:l,rawTagName:f}}function ise(t,e,r){let o=r,n=1,i=t.length;for(;r<i;r++)if(t[r]==="<"){let s=t.charCodeAt(r+1);if(s===47){let a=nse(t,">",r,`${e} is not closed`);if(t.substring(r+2,a).trim()===e&&(n--,n===0))return{tagContent:t.substring(o,r),i:a};r=a}else if(s===63)r=zc(t,"?>",r+1,"StopNode is not closed.");else if(s===33&&t.charCodeAt(r+2)===45&&t.charCodeAt(r+3)===45)r=zc(t,"-->",r+3,"StopNode is not closed.");else if(s===33&&t.charCodeAt(r+2)===91)r=zc(t,"]]>",r,"StopNode is not closed.")-2;else{let a=tC(t,r,">");a&&((a&&a.tagName)===e&&a.tagExp[a.tagExp.length-1]!=="/"&&n++,r=a.closeIndex)}}}function rC(t,e,r){if(e&&typeof t=="string"){let o=t.trim();return o==="true"?!0:o==="false"?!1:JS(t,r)}else return KD(t)?t:""}function nU(t,e,r){let o=Number.parseInt(t,e);return o>=0&&o<=1114111?String.fromCodePoint(o):r+t+";"}function eC(t,e,r,o){if(t){let n=t(e);r===e&&(r=n),e=n}return e=iU(e,o),{tagName:e,tagExp:r}}function iU(t,e){if(Y0.includes(t))throw new Error(`[SECURITY] Invalid name: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`);return Hd.includes(t)?e.onDangerousProperty(t):t}var oC=Qt.getMetaDataSymbol();function sse(t,e){if(!t||typeof t!="object")return{};if(!e)return t;let r={};for(let o in t)if(o.startsWith(e)){let n=o.substring(e.length);r[n]=t[o]}else r[o]=t[o];return r}function nC(t,e,r,o){return sU(t,e,r,o)}function sU(t,e,r,o){let n,i={};for(let s=0;s<t.length;s++){let a=t[s],c=ase(a);if(c!==void 0&&c!==e.textNodeName){let l=sse(a[":@"]||{},e.attributeNamePrefix);r.push(c,l)}if(c===e.textNodeName)n===void 0?n=a[c]:n+=""+a[c];else{if(c===void 0)continue;if(a[c]){let l=sU(a[c],e,r,o),f=lse(l,e);if(a[":@"]?cse(l,a[":@"],o,e):Object.keys(l).length===1&&l[e.textNodeName]!==void 0&&!e.alwaysCreateTextNode?l=l[e.textNodeName]:Object.keys(l).length===0&&(e.alwaysCreateTextNode?l[e.textNodeName]="":l=""),a[oC]!==void 0&&typeof l=="object"&&l!==null&&(l[oC]=a[oC]),i[c]!==void 0&&Object.prototype.hasOwnProperty.call(i,c))Array.isArray(i[c])||(i[c]=[i[c]]),i[c].push(l);else{let u=e.jPath?o.toString():o;e.isArray(c,u,f)?i[c]=[l]:i[c]=l}c!==void 0&&c!==e.textNodeName&&r.pop()}}}return typeof n=="string"?n.length>0&&(i[e.textNodeName]=n):n!==void 0&&(i[e.textNodeName]=n),i}function ase(t){let e=Object.keys(t);for(let r=0;r<e.length;r++){let o=e[r];if(o!==":@")return o}}function cse(t,e,r,o){if(e){let n=Object.keys(e),i=n.length;for(let s=0;s<i;s++){let a=n[s],c=a.startsWith(o.attributeNamePrefix)?a.substring(o.attributeNamePrefix.length):a,l=o.jPath?r.toString()+"."+c:r;o.isArray(a,l,!0,!0)?t[a]=[e[a]]:t[a]=e[a]}}}function lse(t,e){let{textNodeName:r}=e,o=Object.keys(t).length;return!!(o===0||o===1&&(t[r]||typeof t[r]=="boolean"||t[r]===0))}var Hc=class{constructor(e){this.externalEntities={},this.options=oU(e)}parse(e,r){if(typeof e!="string"&&e.toString)e=e.toString();else if(typeof e!="string")throw new Error("XML data is accepted in String or Bytes[] form.");if(r){r===!0&&(r={});let i=eU(e,r);if(i!==!0)throw Error(`${i.err.msg}:${i.err.line}:${i.err.col}`)}let o=new $d(this.options);o.addExternalEntities(this.externalEntities);let n=o.parseXml(e);return this.options.preserveOrder||n===void 0?n:nC(n,this.options,o.matcher,o.readonlyMatcher)}addEntity(e,r){if(r.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(e.indexOf("&")!==-1||e.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'");if(r==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[e]=r}static getMetaDataSymbol(){return Qt.getMetaDataSymbol()}};function iC(t,e){if(e?._parser&&e._parser!=="fast-xml-parser")throw new Error(e?._parser);let r={allowBooleanAttributes:!0,ignoreDeclaration:!0,removeNSPrefix:e?.removeNSPrefix,textNodeName:e?.textNodeName,isArray:(n,i,s,a)=>Boolean(e?.arrayPaths?.some(l=>i===l)),...e?._fastXML},o=fse(t,r);return e?.uncapitalizeKeys?$0(o):o}function fse(t,e){return new Hc({ignoreAttributes:!1,attributeNamePrefix:"",...e}).parse(t)}var use="4.4.3",co={dataType:null,batchType:null,name:"XML",id:"xml",module:"xml",version:use,worker:!1,extensions:["xml"],mimeTypes:["application/xml","text/xml"],testText:dse,options:{xml:{_parser:"fast-xml-parser",uncapitalizeKeys:!1,removeNSPrefix:!1,textNodeName:"value",arrayPaths:[]}},parse:async(t,e)=>iC(new TextDecoder().decode(t),{...co.options.xml,...e?.xml}),parseTextSync:(t,e)=>iC(t,{...co.options.xml,...e?.xml})};function dse(t){return t.startsWith("<?xml")}function aU(t,e){let r=co.parseTextSync?.(t,e),o=r?.ServiceExceptionReport?.ServiceException||r?.["ogc:ServiceExceptionReport"]?.["ogc:ServiceException"];return typeof o=="string"?o:o.value||o.code||"Unknown error"}var hse="4.4.3",Xd={dataType:null,batchType:null,id:"wms-error",name:"WMS Error",module:"wms",version:hse,worker:!1,extensions:["xml"],mimeTypes:["application/vnd.ogc.se_xml","application/xml","text/xml"],testText:pse,options:{wms:{throwOnError:!1}},parse:async(t,e)=>sC(new TextDecoder().decode(t),e),parseSync:(t,e)=>sC(new TextDecoder().decode(t),e),parseTextSync:(t,e)=>sC(t,e)};function pse(t){return t.startsWith("<?xml")}function sC(t,e){let r={...Xd.options.wms,...e?.wms},o=aU(t,r),n=r.minimalErrors?o:`WMS Service error: ${o}`;if(r.throwOnError)throw new Error(n);return n}function Vs(t){return Array.isArray(t)?t:t?[t]:[]}function Yd(t){let e=Vs(t);return e.length>0&&e.every(r=>typeof r=="string")?e:[]}function Kd(t,e=void 0){switch(typeof t){case"number":return t;case"string":return parseFloat(t);default:return}}function q0(t,e=void 0){switch(typeof t){case"number":return t;case"string":return parseInt(t,10);default:return}}function zs(t){switch(t){case"true":return!0;case"false":return!1;case"1":return!0;case"0":return!1;default:return!1}}function aC(t,e){let r=co.parseTextSync?.(t,e),o=r.WMT_MS_Capabilities||r.WMS_Capabilities||r,n=mse(o);if(e?.inheritedLayerProps)for(let i of n.layers)lU(i,null);return e?.includeRawJSON&&(n.json=o),e?.includeXMLText&&(n.xml=t),n}function mse(t){let e={version:String(t.version||""),name:String(t.Service?.Name||"unnamed"),title:t.Service?.Title?String(t.Service?.Title):void 0,abstract:t.Service?.Abstract?String(t.Service?.Abstract):void 0,keywords:Yd(t.Service?.KeywordList?.Keyword),fees:t.Service?.Fees?JSON.stringify(t.Service?.Fees):void 0,accessConstraints:t.Service?.AccessConstraints?JSON.stringify(t.Service?.AccessConstraints):void 0,layerLimit:q0(t.Service?.LayerLimit),maxWidth:q0(t.Service?.maxWidth),maxHeight:q0(t.Service?.maxHeight),layers:[],requests:gse(t.Capability?.Request),exceptions:_se(t.Exception)},r=Vs(t.Capability?.Layer);for(let o of r)e.layers.push(cU(o));for(let[o,n]of Object.entries(e))n===void 0&&delete e[o];return e}function gse(t){let e={};for(let[r,o]of Object.entries(t||{})){let n=Yd(o?.Format);e[r]={mimeTypes:n}}return e}function _se(t){if(Vs(t?.Format).length>0)return{mimeTypes:Yd(t)}}function cU(t){let e={title:String(t?.Title||""),name:t?.Name&&String(t?.Name),abstract:t?.Name&&String(t?.Abstract),keywords:Yd(t.KeywordList?.Keyword)},r=t?.CRS||t?.SRS;r&&Array.isArray(r)&&r.every(l=>typeof l=="string")&&(e.crs=r);let o=t?.EX_GeographicBoundingBox&&yse(t?.EX_GeographicBoundingBox);o&&(e.geographicBoundingBox=o),o=t?.LatLonBoundingBox&&xse(t?.LatLonBoundingBox),o&&(e.geographicBoundingBox=o);let n=t?.BoundingBox&&bse(t?.BoundingBox);n&&n.length>0&&(e.boundingBoxes=n);let s=Vs(t?.Dimension).map(l=>Tse(l));s.length&&(e.dimensions=s),t?.opaque&&(e.opaque=zs(t?.opaque)),t?.cascaded&&(e.cascaded=zs(t?.cascaded)),t?.queryable&&(e.queryable=zs(t?.queryable));let a=Vs(t?.Layer),c=[];for(let l of a)c.push(cU(l));c.length>0&&(e.layers=c);for(let[l,f]of Object.entries(e))f===void 0&&delete e[l];return e}function yse(t){let{westBoundLongitude:e,northBoundLatitude:r,eastBoundLongitude:o,southBoundLatitude:n}=t;return[[e,n],[o,r]]}function xse(t){let{minx:e,miny:r,maxx:o,maxy:n}=t;return[[e,r],[o,n]]}function bse(t){return Vs(t).map(r=>Ase(r))}function Ase(t){let{CRS:e,SRS:r,minx:o,miny:n,maxx:i,maxy:s,resx:a,resy:c}=t,l={crs:e||r,boundingBox:[[Kd(o),Kd(n)],[Kd(i),Kd(s)]]};return a&&(l.xResolution=a),c&&(l.yResolution=c),l}function Tse(t){let{name:e,units:r,value:o}=t,n={name:e,units:r,extent:o};return t.unitSymbol&&(n.unitSymbol=t.unitSymbol),t.default&&(n.defaultValue=t.default),t.multipleValues&&(n.multipleValues=zs(t.multipleValues)),t.nearestValue&&(n.nearestValue=zs(t.nearestValue)),t.current&&(n.current=zs(t.current)),n}function lU(t,e){e?.geographicBoundingBox&&!t.geographicBoundingBox&&(t.geographicBoundingBox=[...e.geographicBoundingBox]),e?.crs&&!t.crs&&(t.crs=[...e.crs]),e?.boundingBoxes&&!t.boundingBoxes&&(t.boundingBoxes=[...e.boundingBoxes]),e?.dimensions&&!t.dimensions&&(t.dimensions=[...e.dimensions]);for(let r of t.layers||[])lU(r,t)}var vse="4.4.3",jc={dataType:null,batchType:null,id:"wms-capabilities",name:"WMS Capabilities",module:"wms",version:vse,worker:!1,extensions:["xml"],mimeTypes:["application/vnd.ogc.wms_xml","application/xml","text/xml"],testText:Sse,options:{wms:{}},parse:async(t,e)=>aC(new TextDecoder().decode(t),e?.wms),parseTextSync:(t,e)=>aC(t,e?.wms)};function Sse(t){return t.startsWith("<?xml")}function cC(t,e){let o=(co.parseTextSync?.(t,e)).FeatureInfoResponse?.FIELDS||[];return{features:(Array.isArray(o)?o:[o]).map(i=>Cse(i))}}function Cse(t){return{attributes:t||{},type:"",bounds:{bottom:0,top:0,left:0,right:0}}}var fU={...jc,dataType:null,id:"wms-feature-info",name:"WMS FeatureInfo",parse:async(t,e)=>cC(new TextDecoder().decode(t),e),parseTextSync:(t,e)=>cC(t,e)};function lC(t,e){return co.parseTextSync?.(t,e)}var uU={...jc,dataType:null,id:"wms-layer-description",name:"WMS DescribeLayer",parse:async(t,e)=>lC(new TextDecoder().decode(t),e),parseTextSync:(t,e)=>lC(t,e)};var J0={name:"Web Map Service (OGC WMS)",id:"wms",module:"wms",version:"0.0.0",extensions:[],mimeTypes:[],type:"wms",fromUrl:!0,fromBlob:!1,defaultOptions:{wms:{}},testURL:t=>t.toLowerCase().includes("wms"),createDataSource:(t,e)=>new Z0(t,e)},Z0=class extends Sa{substituteCRS84;flipCRS;wmsParameters;vendorParameters;capabilities=null;constructor(e,r){super(e,r,J0.defaultOptions),this.substituteCRS84=r.wms?.substituteCRS84??!1,this.flipCRS=["EPSG:4326"],this.wmsParameters={layers:void 0,query_layers:void 0,styles:void 0,version:"1.3.0",crs:"EPSG:4326",format:"image/png",info_format:"text/plain",transparent:void 0,time:void 0,elevation:void 0,...r.wmsParameters,...r.wms?.wmsParameters},this.vendorParameters=r.wms?.vendorParameters||r.vendorParameters||{}}async getMetadata(){let e=await this.getCapabilities();return this.normalizeMetadata(e)}async getImage(e){let{boundingBox:r,bbox:o,...n}=e,i={bbox:r?[...r[0],...r[1]]:o,...n};return await this.getMap(i)}normalizeMetadata(e){return e}async getCapabilities(e,r){let o=this.getCapabilitiesURL(e,r),n=await this.fetch(o),i=await n.arrayBuffer();this._checkResponse(n,i);let s=await jc.parse(i,this.loadOptions);return this.capabilities=s,s}async getMap(e,r){let o=this.getMapURL(e,r),n=await this.fetch(o),i=await n.arrayBuffer();this._checkResponse(n,i);try{return await qn.parse(i,this.loadOptions)}catch{throw this._parseError(i)}}async getFeatureInfo(e,r){let o=this.getFeatureInfoURL(e,r),n=await this.fetch(o),i=await n.arrayBuffer();return this._checkResponse(n,i),await fU.parse(i,this.loadOptions)}async getFeatureInfoText(e,r){let o=this.getFeatureInfoURL(e,r),n=await this.fetch(o),i=await n.arrayBuffer();return this._checkResponse(n,i),new TextDecoder().decode(i)}async describeLayer(e,r){let o=this.describeLayerURL(e,r),n=await this.fetch(o),i=await n.arrayBuffer();return this._checkResponse(n,i),await uU.parse(i,this.loadOptions)}async getLegendGraphic(e,r){let o=this.getLegendGraphicURL(e,r),n=await this.fetch(o),i=await n.arrayBuffer();this._checkResponse(n,i);try{return await qn.parse(i,this.loadOptions)}catch{throw this._parseError(i)}}getCapabilitiesURL(e,r){let o={version:this.wmsParameters.version,...e};return this._getWMSUrl("GetCapabilities",o,r)}getMapURL(e,r){e=this._getWMS130Parameters(e);let o={version:this.wmsParameters.version,format:this.wmsParameters.format,transparent:this.wmsParameters.transparent,time:this.wmsParameters.time,elevation:this.wmsParameters.elevation,layers:this.wmsParameters.layers,styles:this.wmsParameters.styles,crs:this.wmsParameters.crs,...e};return this._getWMSUrl("GetMap",o,r)}getFeatureInfoURL(e,r){e=this._getWMS130Parameters(e);let{boundingBox:o,bbox:n}=e;e.bbox=o?[...o[0],...o[1]]:n;let i={version:this.wmsParameters.version,info_format:this.wmsParameters.info_format,layers:this.wmsParameters.layers,query_layers:this.wmsParameters.query_layers,styles:this.wmsParameters.styles,crs:this.wmsParameters.crs,...e};return this._getWMSUrl("GetFeatureInfo",i,r)}describeLayerURL(e,r){let o={version:this.wmsParameters.version,...e};return this._getWMSUrl("DescribeLayer",o,r)}getLegendGraphicURL(e,r){let o={version:this.wmsParameters.version,...e};return this._getWMSUrl("GetLegendGraphic",o,r)}_parseWMSUrl(e){let[r,o]=e.split("?"),n=o.split("&"),i={};for(let s of n){let[a,c]=s.split("=");i[a]=c}return{url:r,parameters:i}}_getWMSUrl(e,r,o){let n=this.url,i=!0,s={service:"WMS",version:r.version,request:e,...r,...this.vendorParameters,...o},a=["transparent","time","elevation"];for(let[c,l]of Object.entries(s))(!a.includes(c)||l)&&(n+=i?"?":"&",i=!1,n+=this._getURLParameter(c,l,r));return encodeURI(n)}_getWMS130Parameters(e){let r={...e};return r.srs&&(r.crs=r.crs||r.srs,delete r.srs),r}_getURLParameter(e,r,o){switch(e){case"crs":o.version!=="1.3.0"?e="srs":this.substituteCRS84&&r==="EPSG:4326"&&(r="CRS:84");break;case"srs":o.version==="1.3.0"&&(e="crs");break;case"bbox":let n=this._flipBoundingBox(r,o);n&&(r=n);break;case"x":o.version==="1.3.0"&&(e="i");break;case"y":o.version==="1.3.0"&&(e="j");break;default:}return e=e.toUpperCase(),Array.isArray(r)?`${e}=${r.join(",")}`:`${e}=${r?String(r):""}`}_flipBoundingBox(e,r){if(!Array.isArray(e)||e.length!==4)return null;let o=r.version==="1.3.0"&&this.flipCRS.includes(r.crs||"")&&!(this.substituteCRS84&&r.crs==="EPSG:4326"),n=e;return o?[n[1],n[0],n[3],n[2]]:n}async _fetchArrayBuffer(e){let r=await this.fetch(e),o=await r.arrayBuffer();return this._checkResponse(r,o),o}_checkResponse(e,r){let o=e.headers["content-type"];if(!e.ok||Xd.mimeTypes.includes(o)){let n=ji(this.loadOptions,{wms:{throwOnError:!0}}),i=Xd.parseSync?.(r,n);throw new Error(i)}}_parseError(e){let r=Xd.parseSync?.(e,this.options.core?.loadOptions);return new Error(r)}};var dU=6378137*Math.PI;function fC(t){let e=Oe(t);return e[0]=(e[0]/256-1)*dU,e[1]=(e[1]/256-1)*dU,e}var Ese={id:"imagery-layer",data:"",serviceType:"auto",srs:"auto",layers:{type:"array",compare:!0,value:[]},onMetadataLoad:{type:"function",value:()=>{}},onMetadataLoadError:{type:"function",value:console.error},onImageLoadStart:{type:"function",value:()=>{}},onImageLoad:{type:"function",value:()=>{}},onImageLoadError:{type:"function",compare:!1,value:(t,e)=>console.error(e,t)}},Wc=class extends Ne{get isLoaded(){return this.state?.loadCounter===0&&super.isLoaded}shouldUpdateState(){return!0}initializeState(){this.state._nextRequestId=0,this.state.lastRequestId=-1,this.state.loadCounter=0}updateState({changeFlags:e,props:r,oldProps:o}){let{viewport:n}=this.context;e.dataChanged||r.serviceType!==o.serviceType?(this.state.imageSource=this._createImageSource(r),this._loadMetadata(),this.debounce(()=>this.loadImage(n,"image source changed"),0)):ie(r.layers,o.layers,1)?e.viewportChanged&&this.debounce(()=>this.loadImage(n,"viewport changed")):this.debounce(()=>this.loadImage(n,"layers changed"),0)}finalizeState(){}renderLayers(){let{bounds:e,image:r,lastRequestParameters:o}=this.state;return r&&new H_({...this.getSubLayerProps({id:"bitmap"}),_imageCoordinateSystem:o.srs==="EPSG:4326"?Be.LNGLAT:Be.CARTESIAN,bounds:e,image:r})}async getFeatureInfoText(e,r){let{lastRequestParameters:o}=this.state;return o?await this.state.imageSource.getFeatureInfoText?.({...o,query_layers:o.layers,x:e,y:r,info_format:"application/vnd.ogc.gml"}):""}_createImageSource(e){if(e.data instanceof $n)return e.data;if(typeof e.data=="string")return yS(e.data,[J0],{core:{type:e.serviceType,loadOptions:e.loadOptions}});throw new Error("invalid image source in props.data")}async _loadMetadata(){let{imageSource:e}=this.state;try{this.state.loadCounter++;let r=await e.getMetadata();this.state.imageSource===e&&this.getCurrentLayer()?.props.onMetadataLoad(r)}catch(r){this.getCurrentLayer()?.props.onMetadataLoadError(r)}finally{this.state.loadCounter--}}async loadImage(e,r){let{layers:o,serviceType:n}=this.props;if(n==="wms"&&o.length===0)return;let i=e.getBounds(),{width:s,height:a}=e,c=this.getRequestId(),{srs:l}=this.props;l==="auto"&&(l=e.resolution?"EPSG:4326":"EPSG:3857");let f={width:s,height:a,boundingBox:[[i[0],i[1]],[i[2],i[3]]],layers:o,crs:l};if(l==="EPSG:3857"){let u=fC([i[0],i[1]]),d=fC([i[2],i[3]]);f.boundingBox=[u,d]}try{this.state.loadCounter++,this.props.onImageLoadStart(c);let u=await this.state.imageSource.getImage(f);this.state.lastRequestId<c&&(this.getCurrentLayer()?.props.onImageLoad(c),this.setState({image:u,bounds:i,lastRequestParameters:f,lastRequestId:c}))}catch(u){this.raiseError(u,"Load image"),this.getCurrentLayer()?.props.onImageLoadError(c,u)}finally{this.state.loadCounter--}}getRequestId(){return this.state._nextRequestId++}debounce(e,r=500){clearTimeout(this.state._timeoutId),this.state._timeoutId=setTimeout(()=>e(),r)}};Wc.layerName="WMSLayer";Wc.defaultProps=Ese;var wse={getHeight:{type:"accessor",value:0},greatCircle:!0},qd=class extends z_{};qd.layerName="GreatCircleLayer";qd.defaultProps=wse;var hU=qd;var Q0=kn(uC(),1),Pse=3,Mse=30,Rse=2*Mse+1,mU=180/Math.PI;function _U(t,e,r){let o=1<<e;return[(t[0]+r[0])/o,(t[1]+r[1])/o]}function gU(t){return t>=.5?1/3*(4*t*t-1):1/3*(1-4*(1-t)*(1-t))}function yU(t){return[gU(t[0]),gU(t[1])]}function xU(t,[e,r]){switch(t){case 0:return[1,e,r];case 1:return[-e,1,r];case 2:return[-e,-r,1];case 3:return[-1,-r,-e];case 4:return[r,-1,-e];case 5:return[r,e,-1];default:throw new Error("Invalid face")}}function bU([t,e,r]){let o=Math.atan2(r,Math.sqrt(t*t+e*e));return[Math.atan2(e,t)*mU,o*mU]}function AU(t){let e=Q0.default.fromString(t,!0,10).toString(2);for(;e.length<Pse+Rse;)e="0"+e;let r=e.lastIndexOf("1"),o=e.substring(0,3),n=e.substring(3,r),i=n.length/2,s=Q0.default.fromString(o,!0,2).toString(10),a=Q0.default.fromString(n,!0,2).toString(4);for(;a.length<i;)a="0"+a;return`${s}/${a}`}function Ise(t,e,r,o){if(o===0){r===1&&(e[0]=t-1-e[0],e[1]=t-1-e[1]);let n=e[0];e[0]=e[1],e[1]=n}}function TU(t){let e=t.split("/"),r=parseInt(e[0],10),o=e[1],n=o.length,i=[0,0],s;for(let a=n-1;a>=0;a--){s=n-a;let c=o[a],l=0,f=0;c==="1"?f=1:c==="2"?(l=1,f=1):c==="3"&&(l=1);let u=Math.pow(2,s-1);Ise(u,i,l,f),i[0]+=u*l,i[1]+=u*f}if(r%2===1){let a=i[0];i[0]=i[1],i[1]=a}return{face:r,ij:i,level:s}}var vU=kn(uC(),1);function Lse(t){let e=t.padEnd(16,"0");return vU.default.fromString(e,16)}var Bse=100;function Ose({face:t,ij:e,level:r}){let o=[[0,0],[0,1],[1,1],[1,0],[0,0]],n=Math.max(1,Math.ceil(Bse*Math.pow(2,-r))),i=new Float64Array(4*n*2+2),s=0,a=0;for(let c=0;c<4;c++){let l=o[c].slice(0),f=o[c+1],u=(f[0]-l[0])/n,d=(f[1]-l[1])/n;for(let h=0;h<n;h++){l[0]+=u,l[1]+=d;let p=_U(e,r,l),m=yU(p),g=xU(t,m),_=bU(g);Math.abs(_[1])>89.999&&(_[0]=a);let x=_[0]-a;_[0]+=x>180?-360:x<-180?360:0,i[s++]=_[0],i[s++]=_[1],a=_[0]}}return i[s++]=i[0],i[s++]=i[1],i}function Fse(t){if(typeof t=="string"){if(t.indexOf("/")>0)return t;t=Lse(t)}return AU(t.toString())}function SU(t){let e=Fse(t),r=TU(e);return Ose(r)}var Nse={getS2Token:{type:"accessor",value:t=>t.token}},Jd=class extends Or{indexToBounds(){let{data:e,getS2Token:r}=this.props;return{data:e,_normalize:!1,positionFormat:"XY",getPolygon:(o,n)=>SU(r(o,n))}}};Jd.layerName="S2Layer";Jd.defaultProps=Nse;var CU=Jd;var dC=512;function Dse(t,e){let r=0,o=0,n=1<<t.length,i=n/dC;for(let s=0;s<t.length;s++){n>>=1;let a=parseInt(t[s]);a%2&&(r|=n),a>1&&(o|=n)}return[[r/i,dC-o/i],[(r+e)/i,dC-(o+e)/i]]}function EU(t,e=1){let[r,o]=Dse(t,e),[n,i]=pt(r),[s,a]=pt(o);return[s,i,s,a,n,a,n,i,s,i]}var Use={getQuadkey:{type:"accessor",value:t=>t.quadkey}},Qd=class extends Or{indexToBounds(){let{data:e,extruded:r,getQuadkey:o}=this.props,n=r?.99:1;return{data:e,_normalize:!1,positionFormat:"XY",getPolygon:(i,s)=>EU(o(i,s),n),updateTriggers:{getPolygon:n}}}};Qd.layerName="QuadkeyLayer";Qd.defaultProps=Use;var wU=Qd;var Hs=class{constructor(e){this.index=e,this.isVisible=!1,this.isSelected=!1,this.parent=null,this.children=[],this.content=null,this._loader=void 0,this._abortController=null,this._loaderId=0,this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1}get bbox(){return this._bbox}set bbox(e){this._bbox||(this._bbox=e,"west"in e?this.boundingBox=[[e.west,e.south],[e.east,e.north]]:this.boundingBox=[[e.left,e.top],[e.right,e.bottom]])}get data(){return this.isLoading&&this._loader?this._loader.then(()=>this.data):this.content}get isLoaded(){return this._isLoaded&&!this._needsReload}get isLoading(){return Boolean(this._loader)&&!this._isCancelled}get needsReload(){return this._needsReload||this._isCancelled}get byteLength(){let e=this.content?this.content.byteLength:0;return Number.isFinite(e)||console.error("byteLength not defined in tile data"),e}async _loadData({getData:e,requestScheduler:r,onLoad:o,onError:n}){let{index:i,id:s,bbox:a,userData:c,zoom:l}=this,f=this._loaderId;this._abortController=new AbortController;let{signal:u}=this._abortController,d=await r.scheduleRequest(this,m=>m.isSelected?1:-1);if(!d){this._isCancelled=!0;return}if(this._isCancelled){d.done();return}let h=null,p;try{h=await e({index:i,id:s,bbox:a,userData:c,zoom:l,signal:u})}catch(m){p=m||!0}finally{d.done()}if(f===this._loaderId){if(this._loader=void 0,this.content=h,this._isCancelled&&!h){this._isLoaded=!1;return}this._isLoaded=!0,this._isCancelled=!1,p?n(p,this):o(this)}}loadData(e){return this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1,this._loaderId++,this._loader=this._loadData(e),this._loader}setNeedsReload(){this.isLoading&&(this.abort(),this._loader=void 0),this._needsReload=!0}abort(){this.isLoaded||(this._isCancelled=!0,this._abortController?.abort())}};var Ze={OUTSIDE:-1,INTERSECTING:0,INSIDE:1};var PU=new E,kse=new E,Ci=class{constructor(e=[0,0,0],r=[0,0,0],o){o=o||PU.copy(e).add(r).scale(.5),this.center=new E(o),this.halfDiagonal=new E(r).subtract(this.center),this.minimum=new E(e),this.maximum=new E(r)}clone(){return new Ci(this.minimum,this.maximum,this.center)}equals(e){return this===e||Boolean(e)&&this.minimum.equals(e.minimum)&&this.maximum.equals(e.maximum)}transform(e){return this.center.transformAsPoint(e),this.halfDiagonal.transform(e),this.minimum.transform(e),this.maximum.transform(e),this}intersectPlane(e){let{halfDiagonal:r}=this,o=kse.from(e.normal),n=r.x*Math.abs(o.x)+r.y*Math.abs(o.y)+r.z*Math.abs(o.z),i=this.center.dot(o)+e.distance;return i-n>0?Ze.INSIDE:i+n<0?Ze.OUTSIDE:Ze.INTERSECTING}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}distanceSquaredTo(e){let r=PU.from(e).subtract(this.center),{halfDiagonal:o}=this,n=0,i;return i=Math.abs(r.x)-o.x,i>0&&(n+=i*i),i=Math.abs(r.y)-o.y,i>0&&(n+=i*i),i=Math.abs(r.z)-o.z,i>0&&(n+=i*i),n}};var eh=new E,MU=new E,Fr=class{constructor(e=[0,0,0],r=0){this.radius=-0,this.center=new E,this.fromCenterRadius(e,r)}fromCenterRadius(e,r){return this.center.from(e),this.radius=r,this}fromCornerPoints(e,r){return r=eh.from(r),this.center=new E().from(e).add(r).scale(.5),this.radius=this.center.distance(r),this}equals(e){return this===e||Boolean(e)&&this.center.equals(e.center)&&this.radius===e.radius}clone(){return new Fr(this.center,this.radius)}union(e){let r=this.center,o=this.radius,n=e.center,i=e.radius,s=eh.copy(n).subtract(r),a=s.magnitude();if(o>=a+i)return this.clone();if(i>=a+o)return e.clone();let c=(o+a+i)*.5;return MU.copy(s).scale((-o+c)/a).add(r),this.center.copy(MU),this.radius=c,this}expand(e){let o=eh.from(e).subtract(this.center).magnitude();return o>this.radius&&(this.radius=o),this}transform(e){this.center.transform(e);let r=je.getScaling(eh,e);return this.radius=Math.max(r[0],Math.max(r[1],r[2]))*this.radius,this}distanceSquaredTo(e){let r=this.distanceTo(e);return r*r}distanceTo(e){let o=eh.from(e).subtract(this.center);return Math.max(0,o.len()-this.radius)}intersectPlane(e){let r=this.center,o=this.radius,i=e.normal.dot(r)+e.distance;return i<-o?Ze.OUTSIDE:i<o?Ze.INTERSECTING:Ze.INSIDE}};var Vse=new E,zse=new E,ey=new E,ty=new E,ry=new E,Hse=new E,jse=new E,En={COLUMN0ROW0:0,COLUMN0ROW1:1,COLUMN0ROW2:2,COLUMN1ROW0:3,COLUMN1ROW1:4,COLUMN1ROW2:5,COLUMN2ROW0:6,COLUMN2ROW1:7,COLUMN2ROW2:8},lo=class{constructor(e=[0,0,0],r=[0,0,0,0,0,0,0,0,0]){this.center=new E().from(e),this.halfAxes=new ue(r)}get halfSize(){let e=this.halfAxes.getColumn(0),r=this.halfAxes.getColumn(1),o=this.halfAxes.getColumn(2);return[new E(e).len(),new E(r).len(),new E(o).len()]}get quaternion(){let e=this.halfAxes.getColumn(0),r=this.halfAxes.getColumn(1),o=this.halfAxes.getColumn(2),n=new E(e).normalize(),i=new E(r).normalize(),s=new E(o).normalize();return new Sr().fromMatrix3(new ue([...n,...i,...s]))}fromCenterHalfSizeQuaternion(e,r,o){let n=new Sr(o),i=new ue().fromQuaternion(n);return i[0]=i[0]*r[0],i[1]=i[1]*r[0],i[2]=i[2]*r[0],i[3]=i[3]*r[1],i[4]=i[4]*r[1],i[5]=i[5]*r[1],i[6]=i[6]*r[2],i[7]=i[7]*r[2],i[8]=i[8]*r[2],this.center=new E().from(e),this.halfAxes=i,this}clone(){return new lo(this.center,this.halfAxes)}equals(e){return this===e||Boolean(e)&&this.center.equals(e.center)&&this.halfAxes.equals(e.halfAxes)}getBoundingSphere(e=new Fr){let r=this.halfAxes,o=r.getColumn(0,ey),n=r.getColumn(1,ty),i=r.getColumn(2,ry),s=Vse.copy(o).add(n).add(i);return e.center.copy(this.center),e.radius=s.magnitude(),e}intersectPlane(e){let r=this.center,o=e.normal,n=this.halfAxes,i=o.x,s=o.y,a=o.z,c=Math.abs(i*n[En.COLUMN0ROW0]+s*n[En.COLUMN0ROW1]+a*n[En.COLUMN0ROW2])+Math.abs(i*n[En.COLUMN1ROW0]+s*n[En.COLUMN1ROW1]+a*n[En.COLUMN1ROW2])+Math.abs(i*n[En.COLUMN2ROW0]+s*n[En.COLUMN2ROW1]+a*n[En.COLUMN2ROW2]),l=o.dot(r)+e.distance;return l<=-c?Ze.OUTSIDE:l>=c?Ze.INSIDE:Ze.INTERSECTING}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}distanceSquaredTo(e){let r=zse.from(e).subtract(this.center),o=this.halfAxes,n=o.getColumn(0,ey),i=o.getColumn(1,ty),s=o.getColumn(2,ry),a=n.magnitude(),c=i.magnitude(),l=s.magnitude();n.normalize(),i.normalize(),s.normalize();let f=0,u;return u=Math.abs(r.dot(n))-a,u>0&&(f+=u*u),u=Math.abs(r.dot(i))-c,u>0&&(f+=u*u),u=Math.abs(r.dot(s))-l,u>0&&(f+=u*u),f}computePlaneDistances(e,r,o=[-0,-0]){let n=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,s=this.center,a=this.halfAxes,c=a.getColumn(0,ey),l=a.getColumn(1,ty),f=a.getColumn(2,ry),u=Hse.copy(c).add(l).add(f).add(s),d=jse.copy(u).subtract(e),h=r.dot(d);return n=Math.min(h,n),i=Math.max(h,i),u.copy(s).add(c).add(l).subtract(f),d.copy(u).subtract(e),h=r.dot(d),n=Math.min(h,n),i=Math.max(h,i),u.copy(s).add(c).subtract(l).add(f),d.copy(u).subtract(e),h=r.dot(d),n=Math.min(h,n),i=Math.max(h,i),u.copy(s).add(c).subtract(l).subtract(f),d.copy(u).subtract(e),h=r.dot(d),n=Math.min(h,n),i=Math.max(h,i),s.copy(u).subtract(c).add(l).add(f),d.copy(u).subtract(e),h=r.dot(d),n=Math.min(h,n),i=Math.max(h,i),s.copy(u).subtract(c).add(l).subtract(f),d.copy(u).subtract(e),h=r.dot(d),n=Math.min(h,n),i=Math.max(h,i),s.copy(u).subtract(c).subtract(l).add(f),d.copy(u).subtract(e),h=r.dot(d),n=Math.min(h,n),i=Math.max(h,i),s.copy(u).subtract(c).subtract(l).subtract(f),d.copy(u).subtract(e),h=r.dot(d),n=Math.min(h,n),i=Math.max(h,i),o[0]=n,o[1]=i,o}transform(e){this.center.transformAsPoint(e);let r=this.halfAxes.getColumn(0,ey);r.transformAsPoint(e);let o=this.halfAxes.getColumn(1,ty);o.transformAsPoint(e);let n=this.halfAxes.getColumn(2,ry);return n.transformAsPoint(e),this.halfAxes=new ue([...r,...o,...n]),this}getTransform(){throw new Error("not implemented")}};var RU=new E,IU=new E,mt=class{constructor(e=[0,0,1],r=0){this.normal=new E,this.distance=-0,this.fromNormalDistance(e,r)}fromNormalDistance(e,r){return ht(Number.isFinite(r)),this.normal.from(e).normalize(),this.distance=r,this}fromPointNormal(e,r){e=RU.from(e),this.normal.from(r).normalize();let o=-this.normal.dot(e);return this.distance=o,this}fromCoefficients(e,r,o,n){return this.normal.set(e,r,o),ht(Ce(this.normal.len(),1)),this.distance=n,this}clone(){return new mt(this.normal,this.distance)}equals(e){return Ce(this.distance,e.distance)&&Ce(this.normal,e.normal)}getPointDistance(e){return this.normal.dot(e)+this.distance}transform(e){let r=IU.copy(this.normal).transformAsVector(e).normalize(),o=this.normal.scale(-this.distance).transform(e);return this.fromPointNormal(o,r)}projectPointOntoPlane(e,r=[0,0,0]){let o=RU.from(e),n=this.getPointDistance(o),i=IU.copy(this.normal).scale(n);return o.subtract(i).to(r)}};var LU=[new E([1,0,0]),new E([0,1,0]),new E([0,0,1])],BU=new E,Wse=new E,at=class{constructor(e=[]){this.planes=e}fromBoundingSphere(e){this.planes.length=2*LU.length;let r=e.center,o=e.radius,n=0;for(let i of LU){let s=this.planes[n],a=this.planes[n+1];s||(s=this.planes[n]=new mt),a||(a=this.planes[n+1]=new mt);let c=BU.copy(i).scale(-o).add(r);s.fromPointNormal(c,i);let l=BU.copy(i).scale(o).add(r),f=Wse.copy(i).negate();a.fromPointNormal(l,f),n+=2}return this}computeVisibility(e){let r=Ze.INSIDE;for(let o of this.planes)switch(e.intersectPlane(o)){case Ze.OUTSIDE:return Ze.OUTSIDE;case Ze.INTERSECTING:r=Ze.INTERSECTING;break;default:}return r}computeVisibilityWithPlaneMask(e,r){if(ht(Number.isFinite(r),"parentPlaneMask is required."),r===at.MASK_OUTSIDE||r===at.MASK_INSIDE)return r;let o=at.MASK_INSIDE,n=this.planes;for(let i=0;i<this.planes.length;++i){let s=i<31?1<<i:0;if(i<31&&!(r&s))continue;let a=n[i],c=e.intersectPlane(a);if(c===Ze.OUTSIDE)return at.MASK_OUTSIDE;c===Ze.INTERSECTING&&(o|=s)}return o}};at.MASK_OUTSIDE=4294967295;at.MASK_INSIDE=0;at.MASK_INDETERMINATE=2147483647;var uXe=new E,dXe=new E,hXe=new E,pXe=new E,mXe=new E;var AXe=new E,TXe=new E,vXe=new E,SXe=new E,CXe=new E,EXe=new E,wXe=new E,PXe=new E,MXe=new E,RXe=new E,IXe=new E,LXe=new E;var Xo=new ue,$se=new ue,Xse=new ue,oy=new ue,OU=new ue;function mC(t,e={}){let r=Cr.EPSILON20,o=10,n=0,i=0,s=$se,a=Xse;s.identity(),a.copy(t);let c=r*Yse(a);for(;i<o&&Kse(a)>c;)qse(a,oy),OU.copy(oy).transpose(),a.multiplyRight(oy),a.multiplyLeft(OU),s.multiplyRight(oy),++n>2&&(++i,n=0);return e.unitary=s.toTarget(e.unitary),e.diagonal=a.toTarget(e.diagonal),e}function Yse(t){let e=0;for(let r=0;r<9;++r){let o=t[r];e+=o*o}return Math.sqrt(e)}var hC=[1,0,0],pC=[2,2,1];function Kse(t){let e=0;for(let r=0;r<3;++r){let o=t[Xo.getElementIndex(pC[r],hC[r])];e+=2*o*o}return Math.sqrt(e)}function qse(t,e){let r=Cr.EPSILON15,o=0,n=1;for(let l=0;l<3;++l){let f=Math.abs(t[Xo.getElementIndex(pC[l],hC[l])]);f>o&&(n=l,o=f)}let i=hC[n],s=pC[n],a=1,c=0;if(Math.abs(t[Xo.getElementIndex(s,i)])>r){let l=t[Xo.getElementIndex(s,s)],f=t[Xo.getElementIndex(i,i)],u=t[Xo.getElementIndex(s,i)],d=(l-f)/2/u,h;d<0?h=-1/(-d+Math.sqrt(1+d*d)):h=1/(d+Math.sqrt(1+d*d)),a=1/Math.sqrt(1+h*h),c=h*a}return ue.IDENTITY.to(e),e[Xo.getElementIndex(i,i)]=e[Xo.getElementIndex(s,s)]=a,e[Xo.getElementIndex(s,i)]=c,e[Xo.getElementIndex(i,s)]=-c,e}var Ei=new E,Zse=new E,Jse=new E,Qse=new E,eae=new E,tae=new ue,rae={diagonal:new ue,unitary:new ue};function th(t,e=new lo){if(!t||t.length===0)return e.halfAxes=new ue([0,0,0,0,0,0,0,0,0]),e.center=new E,e;let r=t.length,o=new E(0,0,0);for(let S of t)o.add(S);let n=1/r;o.multiplyByScalar(n);let i=0,s=0,a=0,c=0,l=0,f=0;for(let S of t){let A=Ei.copy(S).subtract(o);i+=A.x*A.x,s+=A.x*A.y,a+=A.x*A.z,c+=A.y*A.y,l+=A.y*A.z,f+=A.z*A.z}i*=n,s*=n,a*=n,c*=n,l*=n,f*=n;let u=tae;u[0]=i,u[1]=s,u[2]=a,u[3]=s,u[4]=c,u[5]=l,u[6]=a,u[7]=l,u[8]=f;let{unitary:d}=mC(u,rae),h=e.halfAxes.copy(d),p=h.getColumn(0,Jse),m=h.getColumn(1,Qse),g=h.getColumn(2,eae),_=-Number.MAX_VALUE,x=-Number.MAX_VALUE,y=-Number.MAX_VALUE,b=Number.MAX_VALUE,T=Number.MAX_VALUE,v=Number.MAX_VALUE;for(let S of t)Ei.copy(S),_=Math.max(Ei.dot(p),_),x=Math.max(Ei.dot(m),x),y=Math.max(Ei.dot(g),y),b=Math.min(Ei.dot(p),b),T=Math.min(Ei.dot(m),T),v=Math.min(Ei.dot(g),v);p=p.multiplyByScalar(.5*(b+_)),m=m.multiplyByScalar(.5*(T+x)),g=g.multiplyByScalar(.5*(v+y)),e.center.copy(p).add(m).add(g);let w=Zse.set(_-b,x-T,y-v).multiplyByScalar(.5),C=new ue([w[0],0,0,0,w[1],0,0,0,w[2]]);return e.halfAxes.multiplyRight(C),e}var Gc=512,FU=3,NU=[[.5,.5],[0,0],[0,1],[1,0],[1,1]],DU=NU.concat([[0,.5],[.5,0],[1,.5],[.5,1]]),oae=DU.concat([[.25,.5],[.75,.5]]),wi=class{constructor(e,r,o){this.x=e,this.y=r,this.z=o}get children(){if(!this._children){let e=this.x*2,r=this.y*2,o=this.z+1;this._children=[new wi(e,r,o),new wi(e,r+1,o),new wi(e+1,r,o),new wi(e+1,r+1,o)]}return this._children}update(e){let{viewport:r,cullingVolume:o,elevationBounds:n,minZ:i,maxZ:s,bounds:a,offset:c,project:l}=e,f=this.getBoundingVolume(n,c,l);if(a&&!this.insideBounds(a)||o.computeVisibility(f)<0)return!1;if(!this.childVisible){let{z:d}=this;if(d<s&&d>=i){let h=f.distanceTo(r.cameraPosition)*r.scale/r.height;d+=Math.floor(Math.log2(h))}if(d>=s)return this.selected=!0,!0}this.selected=!1,this.childVisible=!0;for(let d of this.children)d.update(e);return!0}getSelected(e=[]){if(this.selected&&e.push(this),this._children)for(let r of this._children)r.getSelected(e);return e}insideBounds([e,r,o,n]){let i=Math.pow(2,this.z),s=Gc/i;return this.x*s<o&&this.y*s<n&&(this.x+1)*s>e&&(this.y+1)*s>r}getBoundingVolume(e,r,o){if(o){let c=this.z<1?oae:this.z<2?DU:NU,l=[];for(let f of c){let u=ny(this.x+f[0],this.y+f[1],this.z);u[2]=e[0],l.push(o(u)),e[0]!==e[1]&&(u[2]=e[1],l.push(o(u)))}return th(l)}let n=Math.pow(2,this.z),i=Gc/n,s=this.x*i+r*Gc,a=Gc-(this.y+1)*i;return new Ci([s,a,e[0]],[s+i,a+i,e[1]])}};function UU(t,e,r,o){let n=t instanceof Oo&&t.resolution?t.projectPosition:null,i=Object.values(t.getFrustumPlanes()).map(({normal:h,distance:p})=>new mt(h.clone().negate(),p)),s=new at(i),a=t.distanceScales.unitsPerMeter[2],c=r&&r[0]*a||0,l=r&&r[1]*a||0,f=t instanceof Mt&&t.pitch<=60?e:0;if(o){let[h,p,m,g]=o,_=Oe([h,g]),x=Oe([m,p]);o=[_[0],Gc-_[1],x[0],Gc-x[1]]}let u=new wi(0,0,0),d={viewport:t,project:n,cullingVolume:s,elevationBounds:[c,l],minZ:f,maxZ:e,bounds:o,offset:0};if(u.update(d),t instanceof Mt&&t.subViewports&&t.subViewports.length>1){for(d.offset=-1;u.update(d)&&!(--d.offset<-FU););for(d.offset=1;u.update(d)&&!(++d.offset>FU););}return u.getSelected()}var wn=512,nae=[-1/0,-1/0,1/0,1/0],Pi={type:"object",value:null,validate:(t,e)=>e.optional&&t===null||typeof t=="string"||Array.isArray(t)&&t.every(r=>typeof r=="string"),equal:(t,e)=>{if(t===e)return!0;if(!Array.isArray(t)||!Array.isArray(e))return!1;let r=t.length;if(r!==e.length)return!1;for(let o=0;o<r;o++)if(t[o]!==e[o])return!1;return!0}};function iy(t,e){let r=[e.transformAsPoint([t[0],t[1]]),e.transformAsPoint([t[2],t[1]]),e.transformAsPoint([t[0],t[3]]),e.transformAsPoint([t[2],t[3]])];return[Math.min(...r.map(n=>n[0])),Math.min(...r.map(n=>n[1])),Math.max(...r.map(n=>n[0])),Math.max(...r.map(n=>n[1]))]}function iae(t){return Math.abs(t.split("").reduce((e,r)=>(e<<5)-e+r.charCodeAt(0)|0,0))}function Yo(t,e){if(!t||!t.length)return null;let{index:r,id:o}=e;if(Array.isArray(t)){let i=iae(o)%t.length;t=t[i]}let n=t;for(let i of Object.keys(r)){let s=new RegExp(`{${i}}`,"g");n=n.replace(s,String(r[i]))}return Number.isInteger(r.y)&&Number.isInteger(r.z)&&(n=n.replace(/\{-y\}/g,String(Math.pow(2,r.z)-r.y-1))),n}function sae(t,e,r){let o;if(e&&e.length===2){let[n,i]=e,s=t.getBounds({z:n}),a=t.getBounds({z:i});o=[Math.min(s[0],a[0]),Math.min(s[1],a[1]),Math.max(s[2],a[2]),Math.max(s[3],a[3])]}else o=t.getBounds();return t.isGeospatial?[Math.max(o[0],r[0]),Math.max(o[1],r[1]),Math.min(o[2],r[2]),Math.min(o[3],r[3])]:[Math.max(Math.min(o[0],r[2]),r[0]),Math.max(Math.min(o[1],r[3]),r[1]),Math.min(Math.max(o[2],r[0]),r[2]),Math.min(Math.max(o[3],r[1]),r[3])]}function VU({viewport:t,z:e,cullRect:r}){return(t.subViewports||[t]).map(n=>gC(n,e||0,r))}function gC(t,e,r){if(!Array.isArray(e)){let i=r.x-t.x,s=r.y-t.y,{width:a,height:c}=r,l={targetZ:e},f=t.unproject([i,s],l),u=t.unproject([i+a,s],l),d=t.unproject([i,s+c],l),h=t.unproject([i+a,s+c],l);return[Math.min(f[0],u[0],d[0],h[0]),Math.min(f[1],u[1],d[1],h[1]),Math.max(f[0],u[0],d[0],h[0]),Math.max(f[1],u[1],d[1],h[1])]}let o=gC(t,e[0],r),n=gC(t,e[1],r);return[Math.min(o[0],n[0]),Math.min(o[1],n[1]),Math.max(o[2],n[2]),Math.max(o[3],n[3])]}function aae(t,e,r){return r?iy(t,r).map(n=>n*e/wn):t.map(o=>o*e/wn)}function _C(t,e){return Math.pow(2,t)*wn/e}function ny(t,e,r){let o=_C(r,wn),n=t/o*360-180,i=Math.PI-2*Math.PI*e/o,s=180/Math.PI*Math.atan(.5*(Math.exp(i)-Math.exp(-i)));return[n,s]}function kU(t,e,r,o){let n=_C(r,o);return[t/n*wn,e/n*wn]}function yC(t,e,r,o,n=wn){if(t.isGeospatial){let[l,f]=ny(e,r,o),[u,d]=ny(e+1,r+1,o);return{west:l,north:f,east:u,south:d}}let[i,s]=kU(e,r,o,n),[a,c]=kU(e+1,r+1,o,n);return{left:i,top:s,right:a,bottom:c}}function cae(t,e,r,o,n){let i=sae(t,null,o),s=_C(e,r),[a,c,l,f]=aae(i,s,n),u=[];for(let d=Math.floor(a);d<l;d++)for(let h=Math.floor(c);h<f;h++)u.push({x:d,y:h,z:e});return u}function xC({viewport:t,maxZoom:e,minZoom:r,zRange:o,extent:n,tileSize:i=wn,modelMatrix:s,modelMatrixInverse:a,zoomOffset:c=0,visibleMinZoom:l,visibleMaxZoom:f}){let u=t.isGeospatial?Math.round(t.zoom+Math.log2(wn/i)+c):Math.ceil(t.zoom+c);if(typeof r=="number"&&Number.isFinite(r)&&u<r){if(!n)return[];u=r}if(typeof e=="number"&&Number.isFinite(e)&&u>e&&(u=e),l!=null&&t.zoom<l)return[];if(f!=null&&t.zoom>f)return[];let d=n;return s&&a&&n&&!t.isGeospatial&&(d=iy(n,s)),t.isGeospatial?UU(t,u,o,n):cae(t,u,i,d||nae,a)}function bC(t){return/(?=.*{z})(?=.*{x})(?=.*({y}|{-y}))/.test(t)}function AC(t){return Number.isFinite(t.west)&&Number.isFinite(t.north)&&Number.isFinite(t.east)&&Number.isFinite(t.south)}function zU(t){let e={},r;return o=>{for(let n in o)if(!lae(o[n],e[n])){r=t(o),e=o;break}return r}}function lae(t,e){if(t===e)return!0;if(Array.isArray(t)){let r=t.length;if(!e||e.length!==r)return!1;for(let o=0;o<r;o++)if(t[o]!==e[o])return!1;return!0}return!1}var HU=1,sy=2,fae="never",uae="no-overlap",rh="best-available",dae=5,hae={[rh]:mae,[uae]:gae,[fae]:()=>{}},pae={extent:null,tileSize:512,maxZoom:null,minZoom:null,maxCacheSize:null,maxCacheByteSize:null,refinementStrategy:"best-available",zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0,visibleMinZoom:null,visibleMaxZoom:null,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{}},js=class{constructor(e){this._getCullBounds=zU(VU),this.opts={...pae,...e},this.setOptions(this.opts),this.onTileLoad=r=>{this.opts.onTileLoad?.(r),this.opts.maxCacheByteSize!==null&&(this._cacheByteSize+=r.byteLength,this._resizeCache())},this._requestScheduler=new Gn({throttleRequests:this.opts.maxRequests>0||this.opts.debounceTime>0,maxRequests:this.opts.maxRequests,debounceTime:this.opts.debounceTime}),this._cache=new Map,this._tiles=[],this._dirty=!1,this._cacheByteSize=0,this._viewport=null,this._zRange=null,this._selectedTiles=null,this._frameNumber=0,this._modelMatrix=new V,this._modelMatrixInverse=new V}get tiles(){return this._tiles}get selectedTiles(){return this._selectedTiles}get isLoaded(){return this._selectedTiles!==null&&this._selectedTiles.every(e=>e.isLoaded)}get needsReload(){return this._selectedTiles!==null&&this._selectedTiles.some(e=>e.needsReload)}setOptions(e){Object.assign(this.opts,e),Number.isFinite(e.maxZoom)&&(this._maxZoom=Math.floor(e.maxZoom)),Number.isFinite(e.minZoom)&&(this._minZoom=Math.ceil(e.minZoom)),this._viewport=null}finalize(){for(let e of this._cache.values())e.isLoading&&e.abort();this._cache.clear(),this._tiles=[],this._selectedTiles=null}reloadAll(){for(let e of this._cache.keys()){let r=this._cache.get(e);!this._selectedTiles||!this._selectedTiles.includes(r)?this._cache.delete(e):r.setNeedsReload()}}update(e,{zRange:r,modelMatrix:o}={zRange:null,modelMatrix:null}){let n=o?new V(o):new V,i=!n.equals(this._modelMatrix);if(!this._viewport||!e.equals(this._viewport)||!Ce(this._zRange,r)||i){i&&(this._modelMatrixInverse=n.clone().invert(),this._modelMatrix=n),this._viewport=e,this._zRange=r;let a=this.getTileIndices({viewport:e,maxZoom:this._maxZoom,minZoom:this._minZoom,zRange:r,modelMatrix:this._modelMatrix,modelMatrixInverse:this._modelMatrixInverse});this._selectedTiles=a.map(c=>this._getTile(c,!0)),this._dirty&&this._rebuildTree()}else this.needsReload&&(this._selectedTiles=this._selectedTiles.map(a=>this._getTile(a.index,!0)));let s=this.updateTileStates();return this._pruneRequests(),this._dirty&&this._resizeCache(),s&&this._frameNumber++,this._frameNumber}isTileVisible(e,r,o){if(!e.isVisible)return!1;if(r&&this._viewport){let n=this._getCullBounds({viewport:this._viewport,z:this._zRange,cullRect:r}),{bbox:i}=e;for(let[s,a,c,l]of n){let f;if("west"in i)f=i.west<c&&i.east>s&&i.south<l&&i.north>a;else{if(o&&!V.IDENTITY.equals(o)){let[h,p,m,g]=iy([i.left,i.top,i.right,i.bottom],o);i={left:h,top:p,right:m,bottom:g}}let u=Math.min(i.top,i.bottom),d=Math.max(i.top,i.bottom);f=i.left<c&&i.right>s&&u<l&&d>a}if(f)return!0}return!1}return!0}getTileIndices({viewport:e,maxZoom:r,minZoom:o,zRange:n,modelMatrix:i,modelMatrixInverse:s}){let{tileSize:a,extent:c,zoomOffset:l,visibleMinZoom:f,visibleMaxZoom:u}=this.opts;return xC({viewport:e,maxZoom:r,minZoom:o,zRange:n,tileSize:a,extent:c,modelMatrix:i,modelMatrixInverse:s,zoomOffset:l,visibleMinZoom:f,visibleMaxZoom:u})}getTileId(e){return`${e.x}-${e.y}-${e.z}`}getTileZoom(e){return e.z}getTileMetadata(e){let{tileSize:r}=this.opts;return{bbox:yC(this._viewport,e.x,e.y,e.z,r)}}getParentIndex(e){let r=Math.floor(e.x/2),o=Math.floor(e.y/2),n=e.z-1;return{x:r,y:o,z:n}}updateTileStates(){let e=this.opts.refinementStrategy||rh,r=new Array(this._cache.size),o=0;for(let n of this._cache.values())r[o++]=n.isVisible,n.isSelected=!1,n.isVisible=!1;for(let n of this._selectedTiles)n.isSelected=!0,n.isVisible=!0;(typeof e=="function"?e:hae[e])(Array.from(this._cache.values())),o=0;for(let n of this._cache.values())if(r[o++]!==n.isVisible)return!0;return!1}_pruneRequests(){let{maxRequests:e=0}=this.opts,r=[],o=0;for(let n of this._cache.values())n.isLoading&&(o++,!n.isSelected&&!n.isVisible&&r.push(n));for(;e>0&&o>e&&r.length>0;)r.shift().abort(),o--}_rebuildTree(){let{_cache:e}=this;for(let r of e.values())r.parent=null,r.children&&(r.children.length=0);for(let r of e.values()){let o=this._getNearestAncestor(r);r.parent=o,o?.children&&o.children.push(r)}}_resizeCache(){let{_cache:e,opts:r}=this,o=r.maxCacheSize??(r.maxCacheByteSize!==null?1/0:dae*this.selectedTiles.length),n=r.maxCacheByteSize??1/0;if(e.size>o||this._cacheByteSize>n){for(let[s,a]of e)if(!a.isVisible&&!a.isSelected&&(this._cacheByteSize-=r.maxCacheByteSize!==null?a.byteLength:0,e.delete(s),this.opts.onTileUnload?.(a)),e.size<=o&&this._cacheByteSize<=n)break;this._rebuildTree(),this._dirty=!0}this._dirty&&(this._tiles=Array.from(this._cache.values()).sort((s,a)=>s.zoom-a.zoom),this._dirty=!1)}_getTile(e,r){let o=this.getTileId(e),n=this._cache.get(o),i=!1;return!n&&r?(n=new Hs(e),Object.assign(n,this.getTileMetadata(n.index)),Object.assign(n,{id:o,zoom:this.getTileZoom(n.index)}),i=!0,this._cache.set(o,n),this._dirty=!0):n&&n.needsReload&&(i=!0),n&&i&&n.loadData({getData:this.opts.getTileData,requestScheduler:this._requestScheduler,onLoad:this.onTileLoad,onError:this.opts.onTileError}),n}_getNearestAncestor(e){let{_minZoom:r=0}=this,o=e.index;for(;this.getTileZoom(o)>r;){o=this.getParentIndex(o);let n=this._getTile(o);if(n)return n}return null}};function mae(t){for(let e of t)e.state=0;for(let e of t)e.isSelected&&!jU(e)&&TC(e);for(let e of t)e.isVisible=Boolean(e.state&sy)}function gae(t){for(let r of t)r.state=0;for(let r of t)r.isSelected&&jU(r);let e=Array.from(t).sort((r,o)=>r.zoom-o.zoom);for(let r of e)if(r.isVisible=Boolean(r.state&sy),r.children&&(r.isVisible||r.state&HU))for(let o of r.children)o.state=HU;else r.isSelected&&TC(r)}function jU(t){let e=t;for(;e;){if(e.isLoaded||e.content)return e.state|=sy,!0;e=e.parent}return!1}function TC(t){for(let e of t.children)e.isLoaded||e.content?e.state|=sy:TC(e)}var _ae={TilesetClass:js,data:{type:"data",value:[]},dataComparator:Pi.equal,renderSubLayers:{type:"function",value:t=>new Os(t)},getTileData:{type:"function",optional:!0,value:null},onViewportLoad:{type:"function",optional:!0,value:null},onTileLoad:{type:"function",value:t=>{}},onTileUnload:{type:"function",value:t=>{}},onTileError:{type:"function",value:t=>console.error(t)},extent:{type:"array",optional:!0,value:null,compare:!0},tileSize:512,maxZoom:null,minZoom:0,maxCacheSize:null,maxCacheByteSize:null,refinementStrategy:rh,zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0,visibleMinZoom:null,visibleMaxZoom:null},oh=class extends Ne{initializeState(){this.state={tileset:null,isLoaded:!1}}finalizeState(){this.state?.tileset?.finalize()}get isLoaded(){return Boolean(this.state?.tileset?.selectedTiles?.every(e=>e.isLoaded&&(!e.content||!e.layers||e.layers.every(r=>r.isLoaded))))}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState({changeFlags:e}){let{tileset:r}=this.state,o=e.propsOrDataChanged||e.updateTriggersChanged,n=e.dataChanged||e.updateTriggersChanged&&(e.updateTriggersChanged.all||e.updateTriggersChanged.getTileData);r?o&&(r.setOptions(this._getTilesetOptions()),n?r.reloadAll():r.tiles.forEach(i=>{i.layers=null})):(r=new this.props.TilesetClass(this._getTilesetOptions()),this.setState({tileset:r})),this._updateTileset()}_getTilesetOptions(){let{tileSize:e,maxCacheSize:r,maxCacheByteSize:o,refinementStrategy:n,extent:i,maxZoom:s,minZoom:a,maxRequests:c,debounceTime:l,zoomOffset:f,visibleMinZoom:u,visibleMaxZoom:d}=this.props;return{maxCacheSize:r,maxCacheByteSize:o,maxZoom:s,minZoom:a,tileSize:e,refinementStrategy:n,extent:i,maxRequests:c,debounceTime:l,zoomOffset:f,visibleMinZoom:u,visibleMaxZoom:d,getTileData:this.getTileData.bind(this),onTileLoad:this._onTileLoad.bind(this),onTileError:this._onTileError.bind(this),onTileUnload:this._onTileUnload.bind(this)}}_updateTileset(){let e=this.state.tileset,{zRange:r,modelMatrix:o}=this.props,n=e.update(this.context.viewport,{zRange:r,modelMatrix:o}),{isLoaded:i}=e,s=this.state.isLoaded!==i,a=this.state.frameNumber!==n;i&&(s||a)&&this._onViewportLoad(),a&&this.setState({frameNumber:n}),this.state.isLoaded=i}_onViewportLoad(){let{tileset:e}=this.state,{onViewportLoad:r}=this.props;r&&r(e.selectedTiles)}_onTileLoad(e){this.props.onTileLoad(e),e.layers=null,this.setNeedsUpdate()}_onTileError(e,r){this.props.onTileError(e),r.layers=null,this.setNeedsUpdate()}_onTileUnload(e){this.props.onTileUnload(e)}getTileData(e){let{data:r,getTileData:o,fetch:n}=this.props,{signal:i}=e;return e.url=typeof r=="string"||Array.isArray(r)?Yo(r,e):null,o?o(e):n&&e.url?n(e.url,{propName:"data",layer:this,signal:i}):null}renderSubLayers(e){return this.props.renderSubLayers(e)}getSubLayerPropsByTile(e){return null}getPickingInfo(e){let r=e.sourceLayer,o=r.props.tile,n=e.info;return n.picked&&(n.tile=o),n.sourceTile=o,n.sourceTileSubLayer=r,n}_updateAutoHighlight(e){e.sourceTileSubLayer.updateAutoHighlight(e)}renderLayers(){let{visibleMinZoom:e,visibleMaxZoom:r,minZoom:o,extent:n}=this.props,i=this.context.viewport.zoom;if(e!=null&&i<e||r!=null&&i>r||o!=null&&!n&&i<o){for(let a of this.state.tileset.tiles)a.layers=null;return[]}return this.state.tileset.tiles.map(a=>{let c=this.getSubLayerPropsByTile(a);if(!(!a.isLoaded&&!a.content))if(a.layers)c&&a.layers[0]&&Object.keys(c).some(l=>a.layers[0].props[l]!==c[l])&&(a.layers=a.layers.map(l=>l.clone(c)));else{let l=this.renderSubLayers({...this.props,...this.getSubLayerProps({id:a.id,updateTriggers:this.props.updateTriggers}),data:a.content,_offset:0,tile:a});a.layers=kt(l,Boolean).map(f=>f.clone({tile:a,...c}))}return a.layers})}filterSubLayer({layer:e,cullRect:r}){let{tile:o}=e.props,{modelMatrix:n}=this.props;return this.state.tileset.isTileVisible(o,r,n?new V(n):null)}};oh.defaultProps=_ae;oh.layerName="TileLayer";var Ws=oh;var WU=`layout(std140) uniform tripsUniforms { bool fadeTrail; float trailLength; float currentTime; } trips; `,GU={name:"trips",vs:WU,fs:WU,uniformTypes:{fadeTrail:"f32",trailLength:"f32",currentTime:"f32"}};var yae={fadeTrail:!0,trailLength:{type:"number",value:120,min:0},currentTime:{type:"number",value:0,min:0},getTimestamps:{type:"accessor",value:t=>t.timestamps}},nh=class extends Go{getShaders(){let e=super.getShaders();return e.inject={"vs:#decl":`in float instanceTimestamps; in float instanceNextTimestamps; out float vTime; `,"vs:#main-end":`vTime = instanceTimestamps + (instanceNextTimestamps - instanceTimestamps) * vPathPosition.y / vPathLength; `,"fs:#decl":`in float vTime; `,"fs:#main-start":`if(vTime > trips.currentTime || (trips.fadeTrail && (vTime < trips.currentTime - trips.trailLength))) { discard; } `,"fs:DECKGL_FILTER_COLOR":`if(trips.fadeTrail) { color.a *= 1.0 - (trips.currentTime - vTime) / trips.trailLength; } `},e.modules=[...e.modules,GU],e}initializeState(){super.initializeState(),this.getAttributeManager().addInstanced({timestamps:{size:1,accessor:"getTimestamps",shaderAttributes:{instanceTimestamps:{vertexOffset:0},instanceNextTimestamps:{vertexOffset:1}}}})}draw(e){let{fadeTrail:r,trailLength:o,currentTime:n}=this.props,i={fadeTrail:r,trailLength:o,currentTime:n};this.state.model.shaderInputs.setProps({trips:i}),super.draw(e)}};nh.layerName="TripsLayer";nh.defaultProps=yae;var $U=nh;var XU=kn(kd(),1);var Nr=kn(kd(),1);var xae=10;function bae(t,e){let r;return t==null?r=e:typeof t=="object"?r={...t,coverage:e}:r={getHexagon:t,coverage:e},r}var Aae={...vi.defaultProps,highPrecision:"auto",coverage:{type:"number",min:0,max:1,value:1},centerHexagon:null,getHexagon:{type:"accessor",value:t=>t.hexagon},extruded:!0},Mi=class extends Ne{initializeState(){Mi._checkH3Lib(),this.state={edgeLengthKM:0,resolution:-1}}shouldUpdateState({changeFlags:e}){return this._shouldUseHighPrecision()?e.propsOrDataChanged:e.somethingChanged}updateState({props:e,changeFlags:r}){if(e.highPrecision!==!0&&(r.dataChanged||r.updateTriggersChanged&&r.updateTriggersChanged.getHexagon)){let o=this._calculateH3DataProps();this.setState(o)}this._updateVertices(this.context.viewport)}_calculateH3DataProps(){let e=-1,r=!1,o=!1,{iterable:n,objectInfo:i}=Fe(this.props.data);for(let s of n){i.index++;let a=this.props.getHexagon(s,i),c=(0,Nr.getResolution)(a);if(e<0){if(e=c,!this.props.highPrecision)break}else if(e!==c){o=!0;break}if((0,Nr.isPentagon)(a)){r=!0;break}}return{resolution:e,edgeLengthKM:e>=0?(0,Nr.getHexagonEdgeLengthAvg)(e,"km"):0,hasMultipleRes:o,hasPentagon:r}}_shouldUseHighPrecision(){if(this.props.highPrecision==="auto"){let{resolution:e,hasPentagon:r,hasMultipleRes:o}=this.state,{viewport:n}=this.context;return Boolean(n?.resolution)||o||r||e>=0&&e<=5}return this.props.highPrecision}_updateVertices(e){if(this._shouldUseHighPrecision())return;let{resolution:r,edgeLengthKM:o,centerHex:n}=this.state;if(r<0)return;let i=this.props.centerHexagon||(0,Nr.latLngToCell)(e.latitude,e.longitude,r);if(n===i)return;if(n)try{if((0,Nr.gridDistance)(n,i)*o<xae)return}catch{}let{unitsPerMeter:s}=e.distanceScales,a=ZS(i),[c,l]=(0,Nr.cellToLatLng)(i),[f,u]=e.projectFlat([l,c]);a=a.map(d=>{let h=e.projectFlat(d);return[(h[0]-f)/s[0],(h[1]-u)/s[1]]}),this.setState({centerHex:i,vertices:a})}renderLayers(){return this._shouldUseHighPrecision()?this._renderPolygonLayer():this._renderColumnLayer()}_getForwardProps(){let{elevationScale:e,material:r,coverage:o,extruded:n,wireframe:i,stroked:s,filled:a,lineWidthUnits:c,lineWidthScale:l,lineWidthMinPixels:f,lineWidthMaxPixels:u,getFillColor:d,getElevation:h,getLineColor:p,getLineWidth:m,transitions:g,updateTriggers:_}=this.props;return{elevationScale:e,extruded:n,coverage:o,wireframe:i,stroked:s,filled:a,lineWidthUnits:c,lineWidthScale:l,lineWidthMinPixels:f,lineWidthMaxPixels:u,material:r,getElevation:h,getFillColor:d,getLineColor:p,getLineWidth:m,transitions:g,updateTriggers:{getFillColor:_.getFillColor,getElevation:_.getElevation,getLineColor:_.getLineColor,getLineWidth:_.getLineWidth}}}_renderPolygonLayer(){let{data:e,getHexagon:r,updateTriggers:o,coverage:n}=this.props,i=this.getSubLayerClass("hexagon-cell-hifi",vi),s=this._getForwardProps();return s.updateTriggers.getPolygon=bae(o.getHexagon,n),new i(s,this.getSubLayerProps({id:"hexagon-cell-hifi",updateTriggers:s.updateTriggers}),{data:e,_normalize:!1,_windingOrder:"CCW",positionFormat:"XY",getPolygon:(a,c)=>{let l=r(a,c);return G0(ZS(l,n))}})}_renderColumnLayer(){let{data:e,getHexagon:r,updateTriggers:o}=this.props,n=this.getSubLayerClass("hexagon-cell",Wo),i=this._getForwardProps();return i.updateTriggers.getPosition=o.getHexagon,new n(i,this.getSubLayerProps({id:"hexagon-cell",flatShading:!0,updateTriggers:i.updateTriggers}),{data:e,diskResolution:6,radius:1,vertices:this.state.vertices,getPosition:$D.bind(null,r)})}};Mi.defaultProps=Aae;Mi.layerName="H3HexagonLayer";Mi._checkH3Lib=()=>{};var $c=Mi;var Tae={getHexagons:{type:"accessor",value:t=>t.hexagons}},ih=class extends Or{initializeState(){$c._checkH3Lib()}updateState({props:e,changeFlags:r}){if(r.dataChanged||r.updateTriggersChanged&&r.updateTriggersChanged.getHexagons){let{data:o,getHexagons:n}=e,i=[],{iterable:s,objectInfo:a}=Fe(o);for(let c of s){a.index++;let l=n(c,a),f=(0,XU.cellsToMultiPolygon)(l,!0);for(let u of f){for(let d of u)W0(d);i.push(this.getSubLayerRow({polygon:u},c,a.index))}}this.setState({polygons:i})}}indexToBounds(){let{getElevation:e,getFillColor:r,getLineColor:o,getLineWidth:n}=this.props;return{data:this.state.polygons,getPolygon:i=>i.polygon,getElevation:this.getSubLayerAccessor(e),getFillColor:this.getSubLayerAccessor(r),getLineColor:this.getSubLayerAccessor(o),getLineWidth:this.getSubLayerAccessor(n)}}};ih.layerName="H3ClusterLayer";ih.defaultProps=Tae;var YU=ih;q();var vC=Math.PI/180,ay=new Float32Array(16),KU=new Float32Array(12);function qU(t,e,r){let o=e[0]*vC,n=e[1]*vC,i=e[2]*vC,s=Math.sin(i),a=Math.sin(o),c=Math.sin(n),l=Math.cos(i),f=Math.cos(o),u=Math.cos(n),d=r[0],h=r[1],p=r[2];t[0]=d*u*f,t[1]=d*c*f,t[2]=d*-a,t[3]=h*(-c*l+u*a*s),t[4]=h*(u*l+c*a*s),t[5]=h*f*s,t[6]=p*(c*s+u*a*l),t[7]=p*(-u*s+c*a*l),t[8]=p*f*l}function ZU(t){return t[0]=t[0],t[1]=t[1],t[2]=t[2],t[3]=t[4],t[4]=t[5],t[5]=t[6],t[6]=t[8],t[7]=t[9],t[8]=t[10],t[9]=t[12],t[10]=t[13],t[11]=t[14],t.subarray(0,12)}var cy={size:12,accessor:["getOrientation","getScale","getTranslation","getTransformMatrix"],shaderAttributes:{instanceModelMatrixCol0:{size:3,elementOffset:0},instanceModelMatrixCol1:{size:3,elementOffset:3},instanceModelMatrixCol2:{size:3,elementOffset:6},instanceTranslation:{size:3,elementOffset:9}},update(t,{startRow:e,endRow:r}){let{data:o,getOrientation:n,getScale:i,getTranslation:s,getTransformMatrix:a}=this.props,c=Array.isArray(a),l=c&&a.length===16,f=Array.isArray(i),u=Array.isArray(n),d=Array.isArray(s),h=l||!c&&Boolean(a(o[0]));h?t.constant=l:t.constant=u&&f&&d;let p=t.value;if(t.constant){let m;h?(ay.set(a),m=ZU(ay)):(m=KU,qU(m,n,i),m.set(s,9)),t.value=new Float32Array(m)}else{let m=e*t.size,{iterable:g,objectInfo:_}=Fe(o,e,r);for(let x of g){_.index++;let y;if(h)ay.set(l?a:a(x,_)),y=ZU(ay);else{y=KU;let b=u?n:n(x,_),T=f?i:i(x,_);qU(y,b,T),y.set(d?s:s(x,_),9)}p[m++]=y[0],p[m++]=y[1],p[m++]=y[2],p[m++]=y[3],p[m++]=y[4],p[m++]=y[5],p[m++]=y[6],p[m++]=y[7],p[m++]=y[8],p[m++]=y[9],p[m++]=y[10],p[m++]=y[11]}}}};function ly(t,e){return e==="cartesian"||e==="meter-offsets"||e==="default"&&!t.isGeospatial}var JU=`layout(std140) uniform simpleMeshUniforms { float sizeScale; bool composeModelMatrix; bool hasTexture; bool flatShading; } simpleMesh; `,QU={name:"simpleMesh",vs:JU,fs:JU,uniformTypes:{sizeScale:"f32",composeModelMatrix:"f32",hasTexture:"f32",flatShading:"f32"}};var e4=`#version 300 es #define SHADER_NAME simple-mesh-layer-vs in vec3 positions; in vec3 normals; in vec3 colors; in vec2 texCoords; in vec3 instancePositions; in vec3 instancePositions64Low; in vec4 instanceColors; in vec3 instancePickingColors; in vec3 instanceModelMatrixCol0; in vec3 instanceModelMatrixCol1; in vec3 instanceModelMatrixCol2; in vec3 instanceTranslation; out vec2 vTexCoord; out vec3 cameraPosition; out vec3 normals_commonspace; out vec4 position_commonspace; out vec4 vColor; void main(void) { geometry.worldPosition = instancePositions; geometry.uv = texCoords; geometry.pickingColor = instancePickingColors; vTexCoord = texCoords; cameraPosition = project.cameraPosition; vColor = vec4(colors * instanceColors.rgb, instanceColors.a); mat3 instanceModelMatrix = mat3(instanceModelMatrixCol0, instanceModelMatrixCol1, instanceModelMatrixCol2); vec3 pos = (instanceModelMatrix * positions) * simpleMesh.sizeScale + instanceTranslation; if (simpleMesh.composeModelMatrix) { DECKGL_FILTER_SIZE(pos, geometry); normals_commonspace = project_normal(instanceModelMatrix * normals); geometry.worldPosition += pos; gl_Position = project_position_to_clipspace(pos + instancePositions, instancePositions64Low, vec3(0.0), position_commonspace); geometry.position = position_commonspace; } else { pos = project_size(pos); DECKGL_FILTER_SIZE(pos, geometry); gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, pos, position_commonspace); geometry.position = position_commonspace; normals_commonspace = project_normal(instanceModelMatrix * normals); } geometry.normal = normals_commonspace; DECKGL_FILTER_GL_POSITION(gl_Position, geometry); DECKGL_FILTER_COLOR(vColor, geometry); } `;var t4=`#version 300 es #define SHADER_NAME simple-mesh-layer-fs precision highp float; uniform sampler2D sampler; in vec2 vTexCoord; in vec3 cameraPosition; in vec3 normals_commonspace; in vec4 position_commonspace; in vec4 vColor; out vec4 fragColor; void main(void) { geometry.uv = vTexCoord; vec3 normal; if (simpleMesh.flatShading) { normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz))); } else { normal = normals_commonspace; } vec4 color = simpleMesh.hasTexture ? texture(sampler, vTexCoord) : vColor; DECKGL_FILTER_COLOR(color, geometry); vec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal); fragColor = vec4(lightColor, color.a * layer.opacity); } `;function SC(t){let e=1/0,r=1/0,o=1/0,n=-1/0,i=-1/0,s=-1/0,a=t.POSITION?t.POSITION.value:[],c=a&&a.length;for(let l=0;l<c;l+=3){let f=a[l],u=a[l+1],d=a[l+2];e=f<e?f:e,r=u<r?u:r,o=d<o?d:o,n=f>n?f:n,i=u>i?u:i,s=d>s?d:s}return[[e,r,o],[n,i,s]]}function CC(t){let e=t.positions||t.POSITION;N.assert(e,'no "postions" or "POSITION" attribute in mesh');let r=e.value.length/e.size,o=t.COLOR_0||t.colors;o||(o={size:3,value:new Float32Array(r*3).fill(1)});let n=t.NORMAL||t.normals;n||(n={size:3,value:new Float32Array(r*3).fill(0)});let i=t.TEXCOORD_0||t.texCoords;return i||(i={size:2,value:new Float32Array(r*2).fill(0)}),{positions:e,colors:o,normals:n,texCoords:i}}function r4(t){return t instanceof ce?(t.attributes=CC(t.attributes),t):t.attributes?new ce({...t,topology:"triangle-list",attributes:CC(t.attributes)}):new ce({topology:"triangle-list",attributes:CC(t)})}var vae=[0,0,0,255],Sae={mesh:{type:"object",value:null,async:!0},texture:{type:"image",value:null,async:!0},sizeScale:{type:"number",value:1,min:0},_instanced:!0,wireframe:!1,material:!0,getPosition:{type:"accessor",value:t=>t.position},getColor:{type:"accessor",value:vae},getOrientation:{type:"accessor",value:[0,0,0]},getScale:{type:"accessor",value:[1,1,1]},getTranslation:{type:"accessor",value:[0,0,0]},getTransformMatrix:{type:"accessor",value:[]},textureParameters:{type:"object",ignore:!0,value:null}},sh=class extends _e{getShaders(){return super.getShaders({vs:e4,fs:t4,modules:[fe,nn,Se,QU]})}getBounds(){if(this.props._instanced)return super.getBounds();let e=this.state.positionBounds;if(e)return e;let{mesh:r}=this.props;if(!r)return null;if(e=r.header?.boundingBox,!e){let{attributes:o}=r4(r);o.POSITION=o.POSITION||o.positions,e=SC(o)}return this.state.positionBounds=e,e}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{transition:!0,type:"float64",fp64:this.use64bitPositions(),size:3,accessor:"getPosition"},instanceColors:{type:"unorm8",transition:!0,size:this.props.colorFormat.length,accessor:"getColor",defaultValue:[0,0,0,255]},instanceModelMatrix:cy}),this.setState({emptyTexture:this.context.device.createTexture({data:new Uint8Array(4),width:1,height:1})})}updateState(e){super.updateState(e);let{props:r,oldProps:o,changeFlags:n}=e;if(r.mesh!==o.mesh||n.extensionsChanged){if(this.state.positionBounds=null,this.state.model?.destroy(),r.mesh){this.state.model=this.getModel(r.mesh);let i=r.mesh.attributes||r.mesh;this.setState({hasNormals:Boolean(i.NORMAL||i.normals)})}this.getAttributeManager().invalidateAll()}r.texture!==o.texture&&r.texture instanceof Y&&this.setTexture(r.texture),this.state.model&&this.state.model.setTopology(this.props.wireframe?"line-strip":"triangle-list")}finalizeState(e){super.finalizeState(e),this.state.emptyTexture.delete()}draw({uniforms:e}){let{model:r}=this.state;if(!r)return;let{viewport:o,renderPass:n}=this.context,{sizeScale:i,coordinateSystem:s,_instanced:a}=this.props,c={sizeScale:i,composeModelMatrix:!a||ly(o,s),flatShading:!this.state.hasNormals};r.shaderInputs.setProps({simpleMesh:c}),r.draw(n)}get isLoaded(){return Boolean(this.state?.model&&super.isLoaded)}getModel(e){let r=new Q(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:r4(e),isInstanced:!0}),{texture:o}=this.props,{emptyTexture:n}=this.state,i={sampler:o||n,hasTexture:Boolean(o)};return r.shaderInputs.setProps({simpleMesh:i}),r}setTexture(e){let{emptyTexture:r,model:o}=this.state;if(o){let n={sampler:e||r,hasTexture:Boolean(e)};o.shaderInputs.setProps({simpleMesh:n})}}};sh.defaultProps=Sae;sh.layerName="SimpleMeshLayer";var Gs=sh;q();var be;(function(t){t[t.POINTS=0]="POINTS",t[t.LINES=1]="LINES",t[t.LINE_LOOP=2]="LINE_LOOP",t[t.LINE_STRIP=3]="LINE_STRIP",t[t.TRIANGLES=4]="TRIANGLES",t[t.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",t[t.TRIANGLE_FAN=6]="TRIANGLE_FAN",t[t.ONE=1]="ONE",t[t.SRC_ALPHA=770]="SRC_ALPHA",t[t.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",t[t.FUNC_ADD=32774]="FUNC_ADD",t[t.LINEAR=9729]="LINEAR",t[t.NEAREST=9728]="NEAREST",t[t.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",t[t.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",t[t.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",t[t.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",t[t.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",t[t.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",t[t.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",t[t.REPEAT=10497]="REPEAT",t[t.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",t[t.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",t[t.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL"})(be||(be={}));function n4(t){return{addressModeU:o4(t.wrapS),addressModeV:o4(t.wrapT),magFilter:Cae(t.magFilter),...Eae(t.minFilter)}}function o4(t){switch(t){case be.CLAMP_TO_EDGE:return"clamp-to-edge";case be.REPEAT:return"repeat";case be.MIRRORED_REPEAT:return"mirror-repeat";default:return}}function Cae(t){switch(t){case be.NEAREST:return"nearest";case be.LINEAR:return"linear";default:return}}function Eae(t){switch(t){case be.NEAREST:return{minFilter:"nearest"};case be.LINEAR:return{minFilter:"linear"};case be.NEAREST_MIPMAP_NEAREST:return{minFilter:"nearest",mipmapFilter:"nearest"};case be.LINEAR_MIPMAP_NEAREST:return{minFilter:"linear",mipmapFilter:"nearest"};case be.NEAREST_MIPMAP_LINEAR:return{minFilter:"nearest",mipmapFilter:"linear"};case be.LINEAR_MIPMAP_LINEAR:return{minFilter:"linear",mipmapFilter:"linear"};default:return{}}}var EC=[St("baseColor","pbr_baseColorSampler","baseColorTexture",["pbrMetallicRoughness","baseColorTexture"]),St("metallicRoughness","pbr_metallicRoughnessSampler","metallicRoughnessTexture",["pbrMetallicRoughness","metallicRoughnessTexture"]),St("normal","pbr_normalSampler","normalTexture",["normalTexture"]),St("occlusion","pbr_occlusionSampler","occlusionTexture",["occlusionTexture"]),St("emissive","pbr_emissiveSampler","emissiveTexture",["emissiveTexture"]),St("specularColor","pbr_specularColorSampler","KHR_materials_specular.specularColorTexture",["extensions","KHR_materials_specular","specularColorTexture"]),St("specularIntensity","pbr_specularIntensitySampler","KHR_materials_specular.specularTexture",["extensions","KHR_materials_specular","specularTexture"]),St("transmission","pbr_transmissionSampler","KHR_materials_transmission.transmissionTexture",["extensions","KHR_materials_transmission","transmissionTexture"]),St("thickness","pbr_thicknessSampler","KHR_materials_volume.thicknessTexture",["extensions","KHR_materials_volume","thicknessTexture"]),St("clearcoat","pbr_clearcoatSampler","KHR_materials_clearcoat.clearcoatTexture",["extensions","KHR_materials_clearcoat","clearcoatTexture"]),St("clearcoatRoughness","pbr_clearcoatRoughnessSampler","KHR_materials_clearcoat.clearcoatRoughnessTexture",["extensions","KHR_materials_clearcoat","clearcoatRoughnessTexture"]),St("clearcoatNormal","pbr_clearcoatNormalSampler","KHR_materials_clearcoat.clearcoatNormalTexture",["extensions","KHR_materials_clearcoat","clearcoatNormalTexture"]),St("sheenColor","pbr_sheenColorSampler","KHR_materials_sheen.sheenColorTexture",["extensions","KHR_materials_sheen","sheenColorTexture"]),St("sheenRoughness","pbr_sheenRoughnessSampler","KHR_materials_sheen.sheenRoughnessTexture",["extensions","KHR_materials_sheen","sheenRoughnessTexture"]),St("iridescence","pbr_iridescenceSampler","KHR_materials_iridescence.iridescenceTexture",["extensions","KHR_materials_iridescence","iridescenceTexture"]),St("iridescenceThickness","pbr_iridescenceThicknessSampler","KHR_materials_iridescence.iridescenceThicknessTexture",["extensions","KHR_materials_iridescence","iridescenceThicknessTexture"]),St("anisotropy","pbr_anisotropySampler","KHR_materials_anisotropy.anisotropyTexture",["extensions","KHR_materials_anisotropy","anisotropyTexture"])],wae=new Map(EC.map(t=>[t.slot,t]));function St(t,e,r,o){return{slot:t,binding:e,displayName:r,pathSegments:o,uvSetUniform:`${t}UVSet`,uvTransformUniform:`${t}UVTransform`}}function i4(){return EC}function uy(t){let e=wae.get(t);if(!e)throw new Error(`Unknown PBR texture transform slot ${t}`);return e}function dy(t){let e=t?.extensions?.KHR_texture_transform;return{offset:e?.offset?[e.offset[0],e.offset[1]]:[0,0],rotation:e?.rotation??0,scale:e?.scale?[e.scale[0],e.scale[1]]:[1,1]}}function wC(t){return t?.extensions?.KHR_texture_transform?.texCoord??t?.texCoord??0}function s4(t){return EC.find(e=>e.pathSegments.length===t.length&&e.pathSegments.every((r,o)=>t[o]===r))||null}function fy(t){let e=new ue().set(1,0,0,0,1,0,t.offset[0],t.offset[1],1),r=new ue().set(Math.cos(t.rotation),Math.sin(t.rotation),0,-Math.sin(t.rotation),Math.cos(t.rotation),0,0,0,1),o=new ue().set(t.scale[0],0,0,0,t.scale[1],0,0,0,1);return Array.from(e.multiplyRight(r).multiplyRight(o))}function a4(t,e){let r=new ue(fy(t)),o=new ue(fy(e)),n=new ue(r).invert();return Array.from(o.multiplyRight(n))}function Xc(t,e,r,o){let n={defines:{MANUAL_SRGB:!0,SRGB_FAST_APPROXIMATION:!0},bindings:{},uniforms:{camera:[0,0,0],metallicRoughnessValues:[1,1]},parameters:{},glParameters:{},generatedTextures:[]};n.defines.USE_TEX_LOD=!0;let{imageBasedLightingEnvironment:i}=o;return i&&(n.bindings.pbr_diffuseEnvSampler=i.diffuseEnvSampler.texture,n.bindings.pbr_specularEnvSampler=i.specularEnvSampler.texture,n.bindings.pbr_brdfLUT=i.brdfLutTexture.texture,n.uniforms.IBLenabled=!0,n.uniforms.scaleIBLAmbient=[1,1]),o?.pbrDebug&&(n.defines.PBR_DEBUG=!0,n.uniforms.scaleDiffBaseMR=[0,0,0,0],n.uniforms.scaleFGDSpec=[0,0,0,0]),r.NORMAL&&(n.defines.HAS_NORMALS=!0),r.TANGENT&&o?.useTangents&&(n.defines.HAS_TANGENTS=!0),r.TEXCOORD_0&&(n.defines.HAS_UV=!0),r.TEXCOORD_1&&(n.defines.HAS_UV_1=!0),r.JOINTS_0&&r.WEIGHTS_0&&(n.defines.HAS_SKIN=!0),r.COLOR_0&&(n.defines.HAS_COLORS=!0),o?.imageBasedLightingEnvironment&&(n.defines.USE_IBL=!0),o?.lights&&(n.defines.USE_LIGHTS=!0),e&&(o.validateAttributes!==!1&&Pae(e,r),Rae(t,e,n,r,o.gltf)),n}function Pae(t,e){let r=c4(t,0);r.length>0&&!e.TEXCOORD_0&&P.warn(`glTF material uses ${r.join(", ")} but primitive is missing TEXCOORD_0; textured shading will sample the default UV coordinates`)();let o=c4(t,1);if(o.length>0&&!e.TEXCOORD_1&&P.warn(`glTF material uses ${o.join(", ")} with TEXCOORD_1 but primitive is missing TEXCOORD_1; those textures will be skipped`)(),Boolean(t.unlit||t.extensions?.KHR_materials_unlit)||e.NORMAL)return;let i=t.normalTexture?"lit PBR shading with normalTexture":"lit PBR shading";P.warn(`glTF primitive is missing NORMAL while using ${i}; shading will fall back to geometric normals`)()}function c4(t,e){let r=[];for(let o of i4()){let n=Mae(t,o.pathSegments);n&&wC(n)===e&&r.push(o.displayName)}return r}function Mae(t,e){let r=t;for(let o of e)if(r=r?.[o],!r)return null;return r}function Rae(t,e,r,o,n){if(r.uniforms.unlit=Boolean(e.unlit||e.extensions?.KHR_materials_unlit),e.pbrMetallicRoughness&&Bae(t,e.pbrMetallicRoughness,r,o,n),e.normalTexture){Ct(t,e.normalTexture,"pbr_normalSampler",r,{featureOptions:{define:"HAS_NORMALMAP",enabledUniformName:"normalMapEnabled"},gltf:n,attributes:o,textureTransformSlot:"normal"});let{scale:i=1}=e.normalTexture;r.uniforms.normalScale=i}if(e.occlusionTexture){Ct(t,e.occlusionTexture,"pbr_occlusionSampler",r,{featureOptions:{define:"HAS_OCCLUSIONMAP",enabledUniformName:"occlusionMapEnabled"},gltf:n,attributes:o,textureTransformSlot:"occlusion"});let{strength:i=1}=e.occlusionTexture;r.uniforms.occlusionStrength=i}switch(r.uniforms.emissiveFactor=e.emissiveFactor||[0,0,0],e.emissiveTexture&&Ct(t,e.emissiveTexture,"pbr_emissiveSampler",r,{featureOptions:{define:"HAS_EMISSIVEMAP",enabledUniformName:"emissiveMapEnabled"},gltf:n,attributes:o,textureTransformSlot:"emissive"}),Oae(t,e.extensions,r,n,o),e.alphaMode||"OPAQUE"){case"OPAQUE":break;case"MASK":{let{alphaCutoff:i=.5}=e;r.defines.ALPHA_CUTOFF=!0,r.uniforms.alphaCutoffEnabled=!0,r.uniforms.alphaCutoff=i;break}case"BLEND":P.warn("glTF BLEND alphaMode might not work well because it requires mesh sorting")(),Iae(r);break}}function Iae(t){t.parameters.blend=!0,t.parameters.blendColorOperation="add",t.parameters.blendColorSrcFactor="src-alpha",t.parameters.blendColorDstFactor="one-minus-src-alpha",t.parameters.blendAlphaOperation="add",t.parameters.blendAlphaSrcFactor="one",t.parameters.blendAlphaDstFactor="one-minus-src-alpha",t.glParameters.blend=!0,t.glParameters.blendEquation=be.FUNC_ADD,t.glParameters.blendFunc=[be.SRC_ALPHA,be.ONE_MINUS_SRC_ALPHA,be.ONE,be.ONE_MINUS_SRC_ALPHA]}function Lae(t){t.parameters.blend=!0,t.parameters.depthWriteEnabled=!1,t.parameters.blendColorOperation="add",t.parameters.blendColorSrcFactor="one",t.parameters.blendColorDstFactor="one-minus-src-alpha",t.parameters.blendAlphaOperation="add",t.parameters.blendAlphaSrcFactor="one",t.parameters.blendAlphaDstFactor="one-minus-src-alpha",t.glParameters.blend=!0,t.glParameters.depthMask=!1,t.glParameters.blendEquation=be.FUNC_ADD,t.glParameters.blendFunc=[be.ONE,be.ONE_MINUS_SRC_ALPHA,be.ONE,be.ONE_MINUS_SRC_ALPHA]}function Bae(t,e,r,o,n){e.baseColorTexture&&Ct(t,e.baseColorTexture,"pbr_baseColorSampler",r,{featureOptions:{define:"HAS_BASECOLORMAP",enabledUniformName:"baseColorMapEnabled"},gltf:n,attributes:o,textureTransformSlot:"baseColor"}),r.uniforms.baseColorFactor=e.baseColorFactor||[1,1,1,1],e.metallicRoughnessTexture&&Ct(t,e.metallicRoughnessTexture,"pbr_metallicRoughnessSampler",r,{featureOptions:{define:"HAS_METALROUGHNESSMAP",enabledUniformName:"metallicRoughnessMapEnabled"},gltf:n,attributes:o,textureTransformSlot:"metallicRoughness"});let{metallicFactor:i=1,roughnessFactor:s=1}=e;r.uniforms.metallicRoughnessValues=[i,s]}function Oae(t,e,r,o,n={}){e&&(Fae(e)&&(r.defines.USE_MATERIAL_EXTENSIONS=!0),Nae(t,e.KHR_materials_specular,r,o,n),Dae(e.KHR_materials_ior,r),Uae(t,e.KHR_materials_transmission,r,o,n),kae(t,e.KHR_materials_volume,r,o,n),Vae(t,e.KHR_materials_clearcoat,r,o,n),zae(t,e.KHR_materials_sheen,r,o,n),Hae(t,e.KHR_materials_iridescence,r,o,n),jae(t,e.KHR_materials_anisotropy,r,o,n),Wae(e.KHR_materials_emissive_strength,r))}function Fae(t){return Boolean(t.KHR_materials_specular||t.KHR_materials_ior||t.KHR_materials_transmission||t.KHR_materials_volume||t.KHR_materials_clearcoat||t.KHR_materials_sheen||t.KHR_materials_iridescence||t.KHR_materials_anisotropy)}function Nae(t,e,r,o,n={}){e&&(e.specularColorFactor&&(r.uniforms.specularColorFactor=e.specularColorFactor),e.specularFactor!==void 0&&(r.uniforms.specularIntensityFactor=e.specularFactor),e.specularColorTexture&&Ct(t,e.specularColorTexture,"pbr_specularColorSampler",r,{featureOptions:{define:"HAS_SPECULARCOLORMAP",enabledUniformName:"specularColorMapEnabled"},gltf:o,attributes:n,textureTransformSlot:"specularColor"}),e.specularTexture&&Ct(t,e.specularTexture,"pbr_specularIntensitySampler",r,{featureOptions:{define:"HAS_SPECULARINTENSITYMAP",enabledUniformName:"specularIntensityMapEnabled"},gltf:o,attributes:n,textureTransformSlot:"specularIntensity"}))}function Dae(t,e){t?.ior!==void 0&&(e.uniforms.ior=t.ior)}function Uae(t,e,r,o,n={}){e&&(e.transmissionFactor!==void 0&&(r.uniforms.transmissionFactor=e.transmissionFactor),e.transmissionTexture&&Ct(t,e.transmissionTexture,"pbr_transmissionSampler",r,{featureOptions:{define:"HAS_TRANSMISSIONMAP",enabledUniformName:"transmissionMapEnabled"},gltf:o,attributes:n,textureTransformSlot:"transmission"}),((e.transmissionFactor??0)>0||e.transmissionTexture)&&(P.warn("KHR_materials_transmission uses a premultiplied-alpha blending approximation and may require mesh sorting")(),Lae(r)))}function kae(t,e,r,o,n={}){e&&(e.thicknessFactor!==void 0&&(r.uniforms.thicknessFactor=e.thicknessFactor),e.thicknessTexture&&Ct(t,e.thicknessTexture,"pbr_thicknessSampler",r,{featureOptions:{define:"HAS_THICKNESSMAP"},gltf:o,attributes:n,textureTransformSlot:"thickness"}),e.attenuationDistance!==void 0&&(r.uniforms.attenuationDistance=e.attenuationDistance),e.attenuationColor&&(r.uniforms.attenuationColor=e.attenuationColor))}function Vae(t,e,r,o,n={}){e&&(e.clearcoatFactor!==void 0&&(r.uniforms.clearcoatFactor=e.clearcoatFactor),e.clearcoatRoughnessFactor!==void 0&&(r.uniforms.clearcoatRoughnessFactor=e.clearcoatRoughnessFactor),e.clearcoatTexture&&Ct(t,e.clearcoatTexture,"pbr_clearcoatSampler",r,{featureOptions:{define:"HAS_CLEARCOATMAP",enabledUniformName:"clearcoatMapEnabled"},gltf:o,attributes:n,textureTransformSlot:"clearcoat"}),e.clearcoatRoughnessTexture&&Ct(t,e.clearcoatRoughnessTexture,"pbr_clearcoatRoughnessSampler",r,{featureOptions:{define:"HAS_CLEARCOATROUGHNESSMAP",enabledUniformName:"clearcoatRoughnessMapEnabled"},gltf:o,attributes:n,textureTransformSlot:"clearcoatRoughness"}),e.clearcoatNormalTexture&&Ct(t,e.clearcoatNormalTexture,"pbr_clearcoatNormalSampler",r,{featureOptions:{define:"HAS_CLEARCOATNORMALMAP"},gltf:o,attributes:n,textureTransformSlot:"clearcoatNormal"}))}function zae(t,e,r,o,n={}){e&&(e.sheenColorFactor&&(r.uniforms.sheenColorFactor=e.sheenColorFactor),e.sheenRoughnessFactor!==void 0&&(r.uniforms.sheenRoughnessFactor=e.sheenRoughnessFactor),e.sheenColorTexture&&Ct(t,e.sheenColorTexture,"pbr_sheenColorSampler",r,{featureOptions:{define:"HAS_SHEENCOLORMAP",enabledUniformName:"sheenColorMapEnabled"},gltf:o,attributes:n,textureTransformSlot:"sheenColor"}),e.sheenRoughnessTexture&&Ct(t,e.sheenRoughnessTexture,"pbr_sheenRoughnessSampler",r,{featureOptions:{define:"HAS_SHEENROUGHNESSMAP",enabledUniformName:"sheenRoughnessMapEnabled"},gltf:o,attributes:n,textureTransformSlot:"sheenRoughness"}))}function Hae(t,e,r,o,n={}){e&&(e.iridescenceFactor!==void 0&&(r.uniforms.iridescenceFactor=e.iridescenceFactor),e.iridescenceIor!==void 0&&(r.uniforms.iridescenceIor=e.iridescenceIor),(e.iridescenceThicknessMinimum!==void 0||e.iridescenceThicknessMaximum!==void 0)&&(r.uniforms.iridescenceThicknessRange=[e.iridescenceThicknessMinimum??100,e.iridescenceThicknessMaximum??400]),e.iridescenceTexture&&Ct(t,e.iridescenceTexture,"pbr_iridescenceSampler",r,{featureOptions:{define:"HAS_IRIDESCENCEMAP",enabledUniformName:"iridescenceMapEnabled"},gltf:o,attributes:n,textureTransformSlot:"iridescence"}),e.iridescenceThicknessTexture&&Ct(t,e.iridescenceThicknessTexture,"pbr_iridescenceThicknessSampler",r,{featureOptions:{define:"HAS_IRIDESCENCETHICKNESSMAP"},gltf:o,attributes:n,textureTransformSlot:"iridescenceThickness"}))}function jae(t,e,r,o,n={}){e&&(e.anisotropyStrength!==void 0&&(r.uniforms.anisotropyStrength=e.anisotropyStrength),e.anisotropyRotation!==void 0&&(r.uniforms.anisotropyRotation=e.anisotropyRotation),e.anisotropyTexture&&Ct(t,e.anisotropyTexture,"pbr_anisotropySampler",r,{featureOptions:{define:"HAS_ANISOTROPYMAP",enabledUniformName:"anisotropyMapEnabled"},gltf:o,attributes:n,textureTransformSlot:"anisotropy"}))}function Wae(t,e){t?.emissiveStrength!==void 0&&(e.uniforms.emissiveStrength=t.emissiveStrength)}function Ct(t,e,r,o,n={}){let{featureOptions:i={},gltf:s,attributes:a={},textureTransformSlot:c}=n,{define:l,enabledUniformName:f}=i,u=wC(e);if(u>1){P.warn(`Skipping ${String(r)} because ${u} is not supported; only TEXCOORD_0 and TEXCOORD_1 are currently available`)();return}if(u===1&&!a.TEXCOORD_1){P.warn(`Skipping ${String(r)} because it requires TEXCOORD_1 but the primitive does not provide TEXCOORD_1`)();return}let d=Gae(e,s),h=d.texture?.source?.image;if(!h){P.warn(`Skipping unresolved glTF texture for ${String(r)}`)();return}let p={wrapS:10497,wrapT:10497,minFilter:9729,magFilter:9729,...d?.texture?.sampler},m={id:d.uniformName||d.id,sampler:n4(p)},g;if(h.compressed)g=Xae(t,h,m);else{let{width:_,height:x}=t.getExternalImageSize(h);g=t.createTexture({...m,width:_,height:x,data:h})}if(o.bindings[r]=g,l&&(o.defines[l]=!0),f&&(o.uniforms[f]=!0),c){let _=uy(c);o.uniforms[_.uvSetUniform]=u,o.uniforms[_.uvTransformUniform]=fy(dy(e))}o.generatedTextures.push(g)}function Gae(t,e){if(t.texture||t.index===void 0||!e?.textures)return t;let r=e.textures[t.index];return r?"texture"in r&&r.texture?{...r,...t,texture:r.texture}:"source"in r?{...t,texture:r}:t:t}function PC(t,e){return t.createTexture({...e,format:"rgba8unorm",width:1,height:1,mipLevels:1})}function l4(t){return t.textureFormat}function $ae(t,e,r){let{blockWidth:o=1,blockHeight:n=1}=bt.getInfo(r),i=1;for(let s=1;;s++){let a=Math.max(1,t>>s),c=Math.max(1,e>>s);if(a<o||c<n)break;i++}return i}function Xae(t,e,r){let o;if(Array.isArray(e.data)&&e.data[0]?.data?o=e.data:"mipmaps"in e&&Array.isArray(e.mipmaps)?o=e.mipmaps:o=[],o.length===0||!o[0]?.data)return P.warn("createCompressedTexture: compressed image has no valid mip levels, creating fallback")(),PC(t,r);let n=o[0],i=n.width??e.width??0,s=n.height??e.height??0;if(i<=0||s<=0)return P.warn("createCompressedTexture: base level has invalid dimensions, creating fallback")(),PC(t,r);let a=l4(n);if(!a)return P.warn("createCompressedTexture: compressed image has no textureFormat, creating fallback")(),PC(t,r);let c=$ae(i,s,a),l=Math.min(o.length,c),f=1;for(let d=1;d<l;d++){let h=o[d];if(!h.data||h.width<=0||h.height<=0){P.warn(`createCompressedTexture: mip level ${d} has invalid data/dimensions, truncating`)();break}let p=l4(h);if(p&&p!==a){P.warn(`createCompressedTexture: mip level ${d} format '${p}' differs from base '${a}', truncating`)();break}let m=Math.max(1,i>>d),g=Math.max(1,s>>d);if(h.width!==m||h.height!==g){P.warn(`createCompressedTexture: mip level ${d} dimensions ${h.width}x${h.height} don't match expected ${m}x${g}, truncating`)();break}f++}let u=t.createTexture({...r,format:a,usage:Y.TEXTURE|Y.COPY_DST,width:i,height:s,mipLevels:f,data:n.data});for(let d=1;d<f;d++)u.writeData(o[d].data,{width:o[d].width,height:o[d].height,mipLevel:d});return u}function f4(t,e={}){let r=t.lights||t.extensions?.KHR_lights_punctual?.lights;if(!r||!Array.isArray(r)||r.length===0)return[];let o=[],n=Jae(t.nodes||[]),i=new Map;for(let s of t.nodes||[]){let a=s.light??s.extensions?.KHR_lights_punctual?.light;if(typeof a!="number")continue;let c=r[a];if(!c)continue;let l=Yae(c.color||[1,1,1],e.useByteColors??!0),f=c.intensity??1,u=c.range,d=u4(s,n,i);switch(c.type){case"directional":o.push(qae(d,l,f));break;case"point":o.push(Kae(d,l,f,u));break;case"spot":o.push(Zae(d,l,f,u,c.spot));break;default:break}}return o}function Yae(t,e){return e?t.map(r=>r*255):Oa(t,!1)}function Kae(t,e,r,o){let n=d4(t),i=[1,0,0];return o!==void 0&&o>0&&(i=[1,0,1/(o*o)]),{type:"point",position:n,color:e,intensity:r,attenuation:i}}function qae(t,e,r){return{type:"directional",direction:h4(t),color:e,intensity:r}}function Zae(t,e,r,o,n={}){let i=d4(t),s=h4(t),a=[1,0,0];return o!==void 0&&o>0&&(a=[1,0,1/(o*o)]),{type:"spot",position:i,direction:s,color:e,intensity:r,attenuation:a,innerConeAngle:n.innerConeAngle??0,outerConeAngle:n.outerConeAngle??Math.PI/4}}function Jae(t){let e=new Map;for(let r of t)for(let o of r.children||[])e.set(o.id,r);return e}function u4(t,e,r){let o=r.get(t.id);if(o)return o;let n=Qae(t),i=e.get(t.id),s=i?new V(u4(i,e,r)).multiplyRight(n):n;return r.set(t.id,s),s}function Qae(t){if(t.matrix)return new V(t.matrix);let e=new V;return t.translation&&e.translate(t.translation),t.rotation&&e.multiplyRight(new V().fromQuaternion(t.rotation)),t.scale&&e.scale(t.scale),e}function d4(t){return t.transformAsPoint([0,0,0])}function h4(t){return t.transformDirection([0,0,-1])}function p4(t){switch(t){case be.POINTS:return"point-list";case be.LINES:return"line-list";case be.LINE_STRIP:return"line-strip";case be.TRIANGLES:return"triangle-list";case be.TRIANGLE_STRIP:return"triangle-strip";default:throw new Error(String(t))}}q();var ece=` struct VertexInputs { @location(0) positions: vec3f, #ifdef HAS_NORMALS @location(1) normals: vec3f, #endif #ifdef HAS_TANGENTS @location(2) TANGENT: vec4f, #endif #ifdef HAS_UV @location(3) texCoords: vec2f, #endif #ifdef HAS_UV_1 @location(4) texCoords1: vec2f, #endif #ifdef HAS_SKIN @location(5) JOINTS_0: vec4u, @location(6) WEIGHTS_0: vec4f, #endif }; struct FragmentInputs { @builtin(position) position: vec4f, @location(0) pbrPosition: vec3f, @location(1) pbrUV0: vec2f, @location(2) pbrUV1: vec2f, @location(3) pbrNormal: vec3f, #ifdef HAS_TANGENTS @location(4) pbrTangent: vec4f, #endif }; @vertex fn vertexMain(inputs: VertexInputs) -> FragmentInputs { var outputs: FragmentInputs; var position = vec4f(inputs.positions, 1.0); var normal = vec3f(0.0, 0.0, 1.0); var tangent = vec4f(1.0, 0.0, 0.0, 1.0); var uv0 = vec2f(0.0, 0.0); var uv1 = vec2f(0.0, 0.0); #ifdef HAS_NORMALS normal = inputs.normals; #endif #ifdef HAS_UV uv0 = inputs.texCoords; #endif #ifdef HAS_UV_1 uv1 = inputs.texCoords1; #endif #ifdef HAS_TANGENTS tangent = inputs.TANGENT; #endif #ifdef HAS_SKIN let skinMatrix = getSkinMatrix(inputs.WEIGHTS_0, inputs.JOINTS_0); position = skinMatrix * position; normal = normalize((skinMatrix * vec4f(normal, 0.0)).xyz); #ifdef HAS_TANGENTS tangent = vec4f(normalize((skinMatrix * vec4f(tangent.xyz, 0.0)).xyz), tangent.w); #endif #endif let worldPosition = pbrProjection.modelMatrix * position; #ifdef HAS_NORMALS normal = normalize((pbrProjection.normalMatrix * vec4f(normal, 0.0)).xyz); #endif #ifdef HAS_TANGENTS let worldTangent = normalize((pbrProjection.modelMatrix * vec4f(tangent.xyz, 0.0)).xyz); outputs.pbrTangent = vec4f(worldTangent, tangent.w); #endif outputs.position = pbrProjection.modelViewProjectionMatrix * position; outputs.pbrPosition = worldPosition.xyz / worldPosition.w; outputs.pbrUV0 = uv0; outputs.pbrUV1 = uv1; outputs.pbrNormal = normal; return outputs; } @fragment fn fragmentMain(inputs: FragmentInputs) -> @location(0) vec4f { fragmentInputs.pbr_vPosition = inputs.pbrPosition; fragmentInputs.pbr_vUV0 = inputs.pbrUV0; fragmentInputs.pbr_vUV1 = inputs.pbrUV1; fragmentInputs.pbr_vNormal = inputs.pbrNormal; #ifdef HAS_TANGENTS let tangent = normalize(inputs.pbrTangent.xyz); let bitangent = normalize(cross(inputs.pbrNormal, tangent)) * inputs.pbrTangent.w; fragmentInputs.pbr_vTBN = mat3x3f(tangent, bitangent, inputs.pbrNormal); #endif return pbr_filterColor(vec4f(1.0)); } `,tce=`#version 300 es // in vec4 POSITION; in vec4 positions; #ifdef HAS_NORMALS // in vec4 NORMAL; in vec4 normals; #endif #ifdef HAS_TANGENTS in vec4 TANGENT; #endif #ifdef HAS_UV // in vec2 TEXCOORD_0; in vec2 texCoords; #endif #ifdef HAS_UV_1 in vec2 texCoords1; #endif #ifdef HAS_SKIN in uvec4 JOINTS_0; in vec4 WEIGHTS_0; #endif void main(void) { vec4 _NORMAL = vec4(0.); vec4 _TANGENT = vec4(0.); vec2 _TEXCOORD_0 = vec2(0.); vec2 _TEXCOORD_1 = vec2(0.); #ifdef HAS_NORMALS _NORMAL = normals; #endif #ifdef HAS_TANGENTS _TANGENT = TANGENT; #endif #ifdef HAS_UV _TEXCOORD_0 = texCoords; #endif #ifdef HAS_UV_1 _TEXCOORD_1 = texCoords1; #endif vec4 pos = positions; #ifdef HAS_SKIN mat4 skinMat = getSkinMatrix(WEIGHTS_0, JOINTS_0); pos = skinMat * pos; _NORMAL = skinMat * _NORMAL; _TANGENT = vec4((skinMat * vec4(_TANGENT.xyz, 0.)).xyz, _TANGENT.w); #endif pbr_setPositionNormalTangentUV(pos, _NORMAL, _TANGENT, _TEXCOORD_0, _TEXCOORD_1); gl_Position = pbrProjection.modelViewProjectionMatrix * pos; } `,rce=`#version 300 es out vec4 fragmentColor; void main(void) { vec3 pos = pbr_vPosition; fragmentColor = pbr_filterColor(vec4(1.0)); } `;function MC(t,e){let r=e.materialFactory||new un(t,{modules:[Po]}),o={...e.parsedPPBRMaterial.uniforms};delete o.camera;let n=Object.fromEntries(Object.entries({...o,...e.parsedPPBRMaterial.bindings}).filter(([s,a])=>r.ownsBinding(s)&&oce(a))),i=r.createMaterial({id:e.id,bindings:n});return i.setProps({pbrMaterial:o}),i}function m4(t,e){let{id:r,geometry:o,parsedPPBRMaterial:n,vertexCount:i,modelOptions:s={}}=e;P.info(4,"createGLTFModel defines: ",n.defines)();let a=[],c={depthWriteEnabled:!0,depthCompare:"less",depthFormat:"depth24plus",cullMode:"back"},l={id:r,source:ece,vs:tce,fs:rce,geometry:o,topology:o.topology,vertexCount:i,modules:[Po,_T],...s,defines:{...n.defines,...s.defines},parameters:{...c,...n.parameters,...s.parameters}},f=e.material||MC(t,{id:r?`${r}-material`:void 0,parsedPPBRMaterial:n});l.material=f;let u=new Q(t,l),d={...n.uniforms,...s.uniforms,...n.bindings,...s.bindings},h=nce(u.shaderInputs.getModules(),f,d);return u.shaderInputs.setProps(h),new Io({managedResources:a,model:u})}function oce(t){return t instanceof K||t instanceof Kt||t instanceof Pt||t instanceof Y||t instanceof wr}function nce(t,e,r){let o=new Map;for(let i of t){for(let s of Object.keys(i.uniformTypes||{}))o.set(s,i.name);for(let s of i.bindingLayout||[])o.set(s.name,i.name)}let n={};for(let[i,s]of Object.entries(r)){if(s===void 0)continue;let a=o.get(i);!a||e.ownsModule(a)||(n[a]||={},n[a][i]=s)}return n}var ice={modelOptions:{},pbrDebug:!1,imageBasedLightingEnvironment:void 0,lights:!0,useTangents:!1,useByteColors:!0};function g4(t,e,r={}){let o={...ice,...r},n=new un(t,{modules:[Po]}),i=(e.materials||[]).map((u,d)=>MC(t,{id:uce(u,d),parsedPPBRMaterial:Xc(t,u,{},{...o,gltf:e,validateAttributes:!1}),materialFactory:n})),s=new Map;(e.materials||[]).forEach((u,d)=>{s.set(u.id,i[d])});let a=new Map;e.meshes.forEach((u,d)=>{let h=ace(t,u,e,s,o);a.set(u.id,h)});let c=new Map,l=new Map;return e.nodes.forEach((u,d)=>{let h=sce(t,u,o);c.set(d,h),l.set(u.id,h)}),e.nodes.forEach((u,d)=>{if(c.get(d).add((u.children??[]).map(({id:h})=>{let p=l.get(h);if(!p)throw new Error(`Cannot find child ${h} of node ${d}`);return p})),u.mesh){let h=a.get(u.mesh.id);if(!h)throw new Error(`Cannot find mesh child ${u.mesh.id} of node ${d}`);c.get(d).add(h)}}),{scenes:e.scenes.map(u=>{let d=(u.nodes||[]).map(({id:h})=>{let p=l.get(h);if(!p)throw new Error(`Cannot find child ${h} of scene ${u.name||u.id}`);return p});return new qt({id:u.name||u.id,children:d})}),materials:i,gltfMeshIdToNodeMap:a,gltfNodeIdToNodeMap:l,gltfNodeIndexToNodeMap:c}}function sce(t,e,r){return new qt({id:e.name||e.id,children:[],matrix:e.matrix,position:e.translation,rotation:e.rotation,scale:e.scale})}function ace(t,e,r,o,n){let s=(e.primitives||[]).map((c,l)=>cce({device:t,gltfPrimitive:c,primitiveIndex:l,gltfMesh:e,gltf:r,gltfMaterialIdToMaterialMap:o,options:n}));return new qt({id:e.name||e.id,children:s})}function cce({device:t,gltfPrimitive:e,primitiveIndex:r,gltfMesh:o,gltf:n,gltfMaterialIdToMaterialMap:i,options:s}){let a=e.name||`${o.name||o.id}-primitive-${r}`,c=p4(e.mode??4),l=e.indices?e.indices.count:lce(e.attributes),f=fce(a,e,c),u=Xc(t,e.material,f.attributes,{...s,gltf:n}),d=m4(t,{id:a,geometry:f,material:e.material&&i.get(e.material.id)||null,parsedPPBRMaterial:u,modelOptions:s.modelOptions,vertexCount:l});return d.bounds=[e.attributes.POSITION.min,e.attributes.POSITION.max],d}function lce(t){let e=1/0;for(let r of Object.values(t))if(r){let{value:o,size:n,components:i}=r,s=n??i;o?.length!==void 0&&s>=1&&(e=Math.min(e,o.length/s))}if(!Number.isFinite(e))throw new Error("Could not determine vertex count from attributes");return e}function fce(t,e,r){let o={};for(let[n,i]of Object.entries(e.attributes)){let{components:s,size:a,value:c,normalized:l}=i;o[n]={size:a??s,value:c,normalized:l}}return new ce({id:t,topology:r,indices:e.indices?.value,attributes:o})}function uce(t,e){return t.name||t.id||`material-${e}`}q();q();function dce(t,e,r){switch(e){case"translation":return t.setPosition(r).updateMatrix();case"rotation":return t.setRotation(r).updateMatrix();case"scale":return t.setScale(r).updateMatrix();default:return P.warn(`Bad animation path ${e}`)(),null}}function _4(t,{input:e,interpolation:r,output:o},n,i){let s=RC(t,{input:e,interpolation:r,output:o},i);s&&dce(n,i,s)}function RC(t,{input:e,interpolation:r,output:o},n){let i=e[e.length-1];if(!Number.isFinite(i)||i<=0)return o[0]||null;let s=t%i,a=e.findIndex(u=>u>=s);if(a<0)return o[o.length-1]||null;let c=Math.max(0,a-1),l=e[c],f=e[a];switch(r){case"STEP":return o[c];case"LINEAR":if(f>l){let u=(s-l)/(f-l);return hce(n,o[c],o[a],u)}return o[c]||null;case"CUBICSPLINE":if(f>l){let u=(s-l)/(f-l),d=f-l,h=o[3*c+1],p=o[3*c+2],m=o[3*a+0],g=o[3*a+1];return pce({p0:h,outTangent0:p,inTangent1:m,p1:g,tDiff:d,ratio:u})}return o[3*c+1]||null;default:return P.warn(`Interpolation ${r} not supported`)(),null}}function hce(t,e,r,o){if(t==="rotation")return new Sr().slerp({start:e,target:r,ratio:o});let n=[];for(let i=0;i<e.length;i++)n[i]=o*r[i]+(1-o)*e[i];return n}function pce({p0:t,outTangent0:e,inTangent1:r,p1:o,tDiff:n,ratio:i}){let s=[];for(let a=0;a<t.length;a++){let c=e[a]*n,l=r[a]*n;s[a]=(2*Math.pow(i,3)-3*Math.pow(i,2)+1)*t[a]+(Math.pow(i,3)-2*Math.pow(i,2)+i)*c+(-2*Math.pow(i,3)+3*Math.pow(i,2))*o[a]+(Math.pow(i,3)-Math.pow(i,2))*l}return s}var IC=class{animation;gltfNodeIdToNodeMap;materials;startTime=0;playing=!0;speed=1;materialTextureTransformState=new Map;constructor(e){if(this.animation=e.animation,this.gltfNodeIdToNodeMap=e.gltfNodeIdToNodeMap,this.materials=e.materials||[],this.animation.name||="unnamed",Object.assign(this,e),this.animation.channels.some(r=>r.type!=="node")&&!this.materials.length)throw new Error(`Animation ${this.animation.name} targets materials, but GLTFAnimator was created without a materials array`)}setTime(e){if(!this.playing)return;let o=(e/1e3-this.startTime)*this.speed;this.animation.channels.forEach(n=>{if(n.type==="node"){let{sampler:a,targetNodeId:c,path:l}=n,f=this.gltfNodeIdToNodeMap.get(c);if(!f)throw new Error(`Cannot find animation target node ${c}`);_4(o,a,f,l);return}let i=this.materials[n.targetMaterialIndex];if(!i)throw new Error(`Cannot find animation target material ${n.targetMaterialIndex} for ${n.pointer}`);let s=RC(o,n.sampler);s&&(n.type==="material"?mce(i,n,s):yce(i,n,s,this.materialTextureTransformState))})}},hy=class{animations;constructor(e){this.animations=e.animations.map((r,o)=>{let n=r.name||`Animation-${o}`;return new IC({gltfNodeIdToNodeMap:e.gltfNodeIdToNodeMap,materials:e.materials,animation:{name:n,channels:r.channels}})})}animate(e){P.warn("GLTFAnimator#animate is deprecated. Use GLTFAnimator#setTime instead")(),this.setTime(e)}setTime(e){this.animations.forEach(r=>r.setTime(e))}getAnimations(){return this.animations}};function mce(t,e,r){let o=e.component!==void 0?{[e.property]:_ce(gce(t,e.property),e.component,r[0])}:{[e.property]:r.length===1?r[0]:r};t.setProps({pbrMaterial:o})}function gce(t,e){let o=t.shaderInputs.getUniformValues().pbrMaterial?.[e];return Array.isArray(o)?[...o]:[]}function _ce(t,e,r){let o=[...t];return o[e]=r,o}function yce(t,e,r,o){let n=uy(e.textureSlot),i=xce(o,t,e);switch(e.path){case"offset":e.component!==void 0?i.offset[e.component]=r[0]:i.offset=[r[0],r[1]];break;case"rotation":i.rotation=r[0];break;case"scale":e.component!==void 0?i.scale[e.component]=r[0]:i.scale=[r[0],r[1]];break}t.setProps({pbrMaterial:{[n.uvTransformUniform]:a4(e.baseTransform,i)}})}function xce(t,e,r){let o=t.get(e)||{},n=o[r.textureSlot];return n||(n={offset:[...r.baseTransform.offset],rotation:r.baseTransform.rotation,scale:[...r.baseTransform.scale]},o[r.textureSlot]=n,t.set(e,o)),n}q();var bce={supportLevel:"none",comment:"Not currently listed in the luma.gl glTF extension support registry."},y4={KHR_draco_mesh_compression:{supportLevel:"built-in",comment:"Decoded by loaders.gl before luma.gl builds the scenegraph."},EXT_meshopt_compression:{supportLevel:"built-in",comment:"Meshopt-compressed primitives are decoded during load."},KHR_mesh_quantization:{supportLevel:"built-in",comment:"Quantized accessors are unpacked before geometry creation."},KHR_lights_punctual:{supportLevel:"built-in",comment:"Parsed into luma.gl Light objects."},KHR_materials_unlit:{supportLevel:"built-in",comment:"Unlit materials bypass the default lighting path."},KHR_materials_emissive_strength:{supportLevel:"built-in",comment:"Applied by the stock PBR shader."},KHR_texture_basisu:{supportLevel:"built-in",comment:"BasisU / KTX2 textures pass through when the device supports them."},KHR_texture_transform:{supportLevel:"built-in",comment:"UV transforms are applied during load."},EXT_texture_webp:{supportLevel:"loader-only",comment:"Texture source is resolved during load; final support depends on browser and device decode support."},EXT_texture_avif:{supportLevel:"loader-only",comment:"Texture source is resolved during load; final support depends on browser and device decode support."},KHR_materials_specular:{supportLevel:"built-in",comment:"The stock shader now applies specular factors and textures to the dielectric F0 term."},KHR_materials_ior:{supportLevel:"built-in",comment:"The stock shader now drives dielectric reflectance from the glTF IOR value."},KHR_materials_transmission:{supportLevel:"built-in",comment:"The stock shader now applies transmission to the base layer and exposes transparency through alpha, without a scene-color refraction buffer."},KHR_materials_volume:{supportLevel:"built-in",comment:"Thickness and attenuation now tint transmitted light in the stock shader."},KHR_materials_clearcoat:{supportLevel:"built-in",comment:"The stock shader now adds a secondary clearcoat specular lobe."},KHR_materials_sheen:{supportLevel:"built-in",comment:"The stock shader now adds a sheen lobe for cloth-like materials."},KHR_materials_iridescence:{supportLevel:"built-in",comment:"The stock shader now tints specular response with a view-dependent thin-film iridescence approximation."},KHR_materials_anisotropy:{supportLevel:"built-in",comment:"The stock shader now shapes highlights and IBL response with an anisotropy-direction approximation."},KHR_materials_pbrSpecularGlossiness:{supportLevel:"loader-only",comment:"Extension data can be loaded, but it is not translated into the default metallic-roughness material path."},KHR_materials_variants:{supportLevel:"loader-only",comment:"Variant metadata can be loaded, but applications must choose and apply variants."},EXT_mesh_gpu_instancing:{supportLevel:"none",comment:"GPU instancing data is not yet converted into luma.gl instanced draw setup."},KHR_node_visibility:{supportLevel:"none",comment:"Node-visibility animations and toggles are not mapped onto runtime scenegraph state."},KHR_animation_pointer:{supportLevel:"parsed-and-wired",comment:"Selected node TRS, material factor, and KHR_texture_transform offset/rotation/scale pointers are wired to runtime updates; unsupported targets are skipped."},KHR_materials_diffuse_transmission:{supportLevel:"none",comment:"Diffuse-transmission shading is not implemented in the stock PBR shader."},KHR_materials_dispersion:{supportLevel:"none",comment:"Chromatic dispersion is not implemented in the stock PBR shader."},KHR_materials_volume_scatter:{supportLevel:"none",comment:"Volume scattering is not implemented in the stock PBR shader."},KHR_xmp:{supportLevel:"none",comment:"Metadata payloads remain in the loaded glTF, but luma.gl does not interpret them."},KHR_xmp_json_ld:{supportLevel:"none",comment:"Metadata is preserved in the glTF, but luma.gl does not interpret it."},EXT_lights_image_based:{supportLevel:"none",comment:"Use loadPBREnvironment() or custom environment setup instead."},EXT_texture_video:{supportLevel:"none",comment:"Video textures are not created automatically by the stock pipeline."},MSFT_lod:{supportLevel:"none",comment:"Level-of-detail switching is not implemented in the stock scenegraph loader."}};function x4(t){let r=Array.from(Ace(t)).sort().map(o=>{let n=y4[o]||bce;return[o,{extensionName:o,supported:n.supportLevel==="built-in"||n.supportLevel==="parsed-and-wired",supportLevel:n.supportLevel,comment:n.comment}]});return new Map(r)}function LC(t){return y4[t]||null}function Ace(t){let e=t,r=new Set;return py(r,t.extensionsUsed),py(r,t.extensionsRequired),py(r,e.extensionsRemoved),py(r,Object.keys(t.extensions||{})),(e.lights?.length||(t.nodes||[]).some(o=>"light"in o))&&r.add("KHR_lights_punctual"),(t.materials||[]).some(o=>{let n=o;return n.unlit||n.extensions?.KHR_materials_unlit})&&r.add("KHR_materials_unlit"),r}function py(t,e=[]){for(let r of e)t.add(r)}var Tce={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},vce={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function BC(t){let e=vce[t.componentType],r=Tce[t.type],o=r*t.count,{buffer:n,byteOffset:i=0}=t.bufferView?.data??{};return{typedArray:new e(n,i+(t.byteOffset||0),o),components:r}}function b4(t){let e=t.animations||[],r=new Map,o=new Map;return e.flatMap((n,i)=>{let s=n.name||`Animation-${i}`,a=new Map,c=n.channels.flatMap(({sampler:l,target:f})=>{let u=a.get(l);if(!u){let h=n.samplers[l];if(!h)throw new Error(`Cannot find animation sampler ${l}`);let{input:p,interpolation:m="LINEAR",output:g}=h;u={input:Bce(t.accessors[p],r),interpolation:m,output:Oce(t.accessors[g],o)},a.set(l,u)}let d=Sce(t,f,u);return d?[d]:[]});return c.length?[{name:s,channels:c}]:[]})}function Sce(t,e,r){if(e.path==="pointer")return Cce(t,e,r);let o=A4(e.path);if(!o)return null;let n=t.nodes[e.node??0];if(!n)throw new Error(`Cannot find animation target ${e.node}`);return{type:"node",sampler:r,targetNodeId:n.id,path:o}}function Cce(t,e,r){let o=e.extensions?.KHR_animation_pointer?.pointer;if(typeof o!="string"||!o.startsWith("/"))return P.warn("KHR_animation_pointer channel is missing a valid JSON pointer and will be skipped")(),null;let n=Ice(o);switch(n[0]){case"nodes":return Ece(t,n,r,o);case"materials":return wce(t,n,r,o);default:return ah(o,`top-level target "${n[0]}" has no runtime animation mapping`),null}}function Ece(t,e,r,o){if(e.length!==3)return ah(o,"node pointers must use /nodes/{index}/{translation|rotation|scale|weights}"),null;let n=Number(e[1]),i=t.nodes[n];if(!Number.isInteger(n)||!i)return P.warn(`KHR_animation_pointer target ${o} references a missing node and will be skipped`)(),null;let s=A4(e[2]);return s?s==="weights"?(P.warn(`KHR_animation_pointer target ${o} will be skipped because morph weights are not implemented in GLTFAnimator`)(),null):{type:"node",sampler:r,targetNodeId:i.id,path:s}:(ah(o,`node property "${e[2]}" has no runtime animation mapping`),null)}function wce(t,e,r,o){if(e.length<3)return ah(o,"material pointers must include a material index and target property path"),null;let n=Number(e[1]),i=t.materials[n];if(!Number.isInteger(n)||!i)return P.warn(`KHR_animation_pointer target ${o} references a missing material and will be skipped`)(),null;let s=Pce(i,e.slice(2));return"reason"in s?(ah(o,s.reason),null):{sampler:r,pointer:o,targetMaterialIndex:n,...s}}function A4(t){switch(t){case"translation":case"rotation":case"scale":case"weights":return t;default:return null}}function Pce(t,e){let r=Mce(t,e);if(!("reason"in r)||r.reason!=="not-a-texture-transform-target")return r;switch(e.join("/")){case"pbrMetallicRoughness/baseColorFactor":return t.pbrMetallicRoughness?{type:"material",property:"baseColorFactor"}:{reason:De(e)};case"pbrMetallicRoughness/metallicFactor":return t.pbrMetallicRoughness?{type:"material",property:"metallicRoughnessValues",component:0}:{reason:De(e)};case"pbrMetallicRoughness/roughnessFactor":return t.pbrMetallicRoughness?{type:"material",property:"metallicRoughnessValues",component:1}:{reason:De(e)};case"normalTexture/scale":return t.normalTexture?{type:"material",property:"normalScale"}:{reason:De(e)};case"occlusionTexture/strength":return t.occlusionTexture?{type:"material",property:"occlusionStrength"}:{reason:De(e)};case"emissiveFactor":return{type:"material",property:"emissiveFactor"};case"alphaCutoff":return{type:"material",property:"alphaCutoff"};case"extensions/KHR_materials_specular/specularFactor":return t.extensions?.KHR_materials_specular?{type:"material",property:"specularIntensityFactor"}:{reason:De(e)};case"extensions/KHR_materials_specular/specularColorFactor":return t.extensions?.KHR_materials_specular?{type:"material",property:"specularColorFactor"}:{reason:De(e)};case"extensions/KHR_materials_ior/ior":return t.extensions?.KHR_materials_ior?{type:"material",property:"ior"}:{reason:De(e)};case"extensions/KHR_materials_transmission/transmissionFactor":return t.extensions?.KHR_materials_transmission?{type:"material",property:"transmissionFactor"}:{reason:De(e)};case"extensions/KHR_materials_volume/thicknessFactor":return t.extensions?.KHR_materials_volume?{type:"material",property:"thicknessFactor"}:{reason:De(e)};case"extensions/KHR_materials_volume/attenuationDistance":return t.extensions?.KHR_materials_volume?{type:"material",property:"attenuationDistance"}:{reason:De(e)};case"extensions/KHR_materials_volume/attenuationColor":return t.extensions?.KHR_materials_volume?{type:"material",property:"attenuationColor"}:{reason:De(e)};case"extensions/KHR_materials_clearcoat/clearcoatFactor":return t.extensions?.KHR_materials_clearcoat?{type:"material",property:"clearcoatFactor"}:{reason:De(e)};case"extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor":return t.extensions?.KHR_materials_clearcoat?{type:"material",property:"clearcoatRoughnessFactor"}:{reason:De(e)};case"extensions/KHR_materials_sheen/sheenColorFactor":return t.extensions?.KHR_materials_sheen?{type:"material",property:"sheenColorFactor"}:{reason:De(e)};case"extensions/KHR_materials_sheen/sheenRoughnessFactor":return t.extensions?.KHR_materials_sheen?{type:"material",property:"sheenRoughnessFactor"}:{reason:De(e)};case"extensions/KHR_materials_iridescence/iridescenceFactor":return t.extensions?.KHR_materials_iridescence?{type:"material",property:"iridescenceFactor"}:{reason:De(e)};case"extensions/KHR_materials_iridescence/iridescenceIor":return t.extensions?.KHR_materials_iridescence?{type:"material",property:"iridescenceIor"}:{reason:De(e)};case"extensions/KHR_materials_iridescence/iridescenceThicknessMinimum":return t.extensions?.KHR_materials_iridescence?{type:"material",property:"iridescenceThicknessRange",component:0}:{reason:De(e)};case"extensions/KHR_materials_iridescence/iridescenceThicknessMaximum":return t.extensions?.KHR_materials_iridescence?{type:"material",property:"iridescenceThicknessRange",component:1}:{reason:De(e)};case"extensions/KHR_materials_anisotropy/anisotropyStrength":return t.extensions?.KHR_materials_anisotropy?{type:"material",property:"anisotropyStrength"}:{reason:De(e)};case"extensions/KHR_materials_anisotropy/anisotropyRotation":return t.extensions?.KHR_materials_anisotropy?{type:"material",property:"anisotropyRotation"}:{reason:De(e)};case"extensions/KHR_materials_emissive_strength/emissiveStrength":return t.extensions?.KHR_materials_emissive_strength?{type:"material",property:"emissiveStrength"}:{reason:De(e)};default:return{reason:De(e)}}}function Mce(t,e){let r=e.lastIndexOf("extensions");if(r<0||e[r+1]!=="KHR_texture_transform"||r<1)return{reason:"not-a-texture-transform-target"};let o=s4(e.slice(0,r));if(!o)return{reason:Lce(e.slice(0,r))};let n=Rce(t,o.pathSegments);if(!n)return{reason:`texture-transform target "${e.slice(0,r).join("/")}" does not exist on the referenced material`};let i=e[r+2];if(i==="texCoord")return{reason:"animated KHR_texture_transform.texCoord is unsupported because texCoord selection is structural, not a runtime float/vector update"};if(i!=="offset"&&i!=="rotation"&&i!=="scale")return{reason:`KHR_texture_transform property "${i}" is not animatable; supported properties are offset, rotation, and scale`};let s=e[r+3];if(e.length>r+4)return{reason:`KHR_texture_transform.${i} does not support nested property paths`};let a;if(s!==void 0){if(a=Number(s),i==="rotation")return{reason:"KHR_texture_transform.rotation does not support component indices"};if(!Number.isInteger(a)||a<0||a>1)return{reason:`KHR_texture_transform.${i} component index "${s}" is invalid; only 0 and 1 are supported`}}return{type:"textureTransform",textureSlot:o.slot,path:i,component:a,baseTransform:dy(n)}}function Rce(t,e){let r=t;for(let o of e)if(r=r?.[o],!r)return null;return r}function Ice(t){return t.slice(1).split("/").map(e=>e.replace(/~1/g,"/").replace(/~0/g,"~"))}function De(t){let e=T4(t);if(e){let r=LC(e);if(r?.supportLevel==="none")return`${e} is referenced by this pointer, but ${r.comment.charAt(0).toLowerCase()}${r.comment.slice(1)}`}return`no runtime target exists for material property "${t.join("/")}"`}function Lce(t){let e=T4(t);if(e){let r=LC(e);if(r?.supportLevel==="none")return`${e} is referenced by this pointer, but ${r.comment.charAt(0).toLowerCase()}${r.comment.slice(1)}`}return`texture-transform target "${t.join("/")}" has no runtime texture-slot mapping`}function T4(t){let e=t.indexOf("extensions"),r=t[e+1];return e>=0&&r?r:null}function ah(t,e){P.warn(`KHR_animation_pointer target ${t} will be skipped because ${e}`)()}function Bce(t,e){if(e.has(t))return e.get(t);let{typedArray:r,components:o}=BC(t);v4(o===1,"accessorToJsArray1D must have exactly 1 component");let n=Array.from(r);return e.set(t,n),n}function Oce(t,e){if(e.has(t))return e.get(t);let{typedArray:r,components:o}=BC(t);v4(o>=1,"accessorToJsArray2D must have at least 1 component");let n=[];for(let i=0;i<r.length;i+=o)n.push(Array.from(r.slice(i,i+o)));return e.set(t,n),n}function v4(t,e){if(!t)throw new Error(e)}function OC(t,e,r){let{scenes:o,materials:n,gltfMeshIdToNodeMap:i,gltfNodeIdToNodeMap:s,gltfNodeIndexToNodeMap:a}=g4(t,e,r),c=b4(e),l=new hy({animations:c,gltfNodeIdToNodeMap:s,materials:n}),f=f4(e,{useByteColors:r?.useByteColors??!0}),u=x4(e),d=o.map(p=>S4(p.getBounds())),h=Fce(d);return{scenes:o,materials:n,animator:l,lights:f,extensionSupport:u,sceneBounds:d,modelBounds:h,gltfMeshIdToNodeMap:i,gltfNodeIdToNodeMap:s,gltfNodeIndexToNodeMap:a,gltf:e}}function S4(t){if(!t)return{bounds:null,center:[0,0,0],size:[0,0,0],radius:.5,recommendedOrbitDistance:1};let e=[[t[0][0],t[0][1],t[0][2]],[t[1][0],t[1][1],t[1][2]]],r=[e[1][0]-e[0][0],e[1][1]-e[0][1],e[1][2]-e[0][2]],o=[e[0][0]+r[0]*.5,e[0][1]+r[1]*.5,e[0][2]+r[2]*.5],n=Math.max(r[0],r[1],r[2])*.5,i=Math.max(.5*Math.hypot(r[0],r[1],r[2]),.001);return{bounds:e,center:o,size:r,radius:i,recommendedOrbitDistance:Math.max(Math.max(n,.001)/Math.tan(Math.PI/6)*1.15,i*1.1)}}function Fce(t){let e=null;for(let r of t)if(r.bounds){if(!e){e=[[...r.bounds[0]],[...r.bounds[1]]];continue}for(let o=0;o<3;o++)e[0][o]=Math.min(e[0][o],r.bounds[0][o]),e[1][o]=Math.max(e[1][o],r.bounds[1][o])}return S4(e)}var FC={};ze(FC,{createExtMeshFeatures:()=>Jce,decode:()=>Xce,encode:()=>Yce,name:()=>$ce});function ut(t,e){if(!t)throw new Error(e||"assert failed: gltf")}var my={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},gy={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4};var Nce=1.33,C4=["SCALAR","VEC2","VEC3","VEC4"],Dce=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]],Uce=new Map(Dce),kce={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Vce={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},zce={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function _y(t){return C4[t-1]||C4[0]}function Ri(t){let e=Uce.get(t.constructor);if(!e)throw new Error("Illegal typed array");return e}function Yc(t,e){let r=zce[t.componentType],o=kce[t.type],n=Vce[t.componentType],i=t.count*o,s=t.count*o*n;ut(s>=0&&s<=e.byteLength);let a=gy[t.componentType],c=my[t.type];return{ArrayType:r,length:i,byteLength:s,componentByteSize:a,numberOfComponentsInElement:c}}function ch(t){let{images:e,bufferViews:r}=t;e=e||[],r=r||[];let o=e.map(s=>s.bufferView);r=r.filter(s=>!o.includes(s));let n=r.reduce((s,a)=>s+a.byteLength,0),i=e.reduce((s,a)=>{let{width:c,height:l}=a.image;return s+c*l},0);return n+Math.ceil(4*i*Nce)}function E4(t,e,r){let o=t.bufferViews[r];ut(o);let n=o.buffer,i=e[n];ut(i);let s=(o.byteOffset||0)+i.byteOffset;return new Uint8Array(i.arrayBuffer,s,o.byteLength)}function w4(t,e,r){let o=typeof r=="number"?t.accessors?.[r]:r;if(!o)throw new Error(`No gltf accessor ${JSON.stringify(r)}`);let n=t.bufferViews?.[o.bufferView||0];if(!n)throw new Error(`No gltf buffer view for accessor ${n}`);let{arrayBuffer:i,byteOffset:s}=e[n.buffer],a=(s||0)+(o.byteOffset||0)+(n.byteOffset||0),{ArrayType:c,length:l,componentByteSize:f,numberOfComponentsInElement:u}=Yc(o,n),d=f*u,h=n.byteStride||d;if(typeof n.byteStride>"u"||n.byteStride===d)return new c(i,a,l);let p=new c(l);for(let m=0;m<o.count;m++){let g=new c(i,a+m*h,u);p.set(g,m*u)}return p}function Hce(){return{asset:{version:"2.0",generator:"loaders.gl"},buffers:[],extensions:{},extensionsRequired:[],extensionsUsed:[]}}var ye=class{gltf;sourceBuffers;byteLength;constructor(e){this.gltf={json:e?.json||Hce(),buffers:e?.buffers||[],images:e?.images||[]},this.sourceBuffers=[],this.byteLength=0,this.gltf.buffers&&this.gltf.buffers[0]&&(this.byteLength=this.gltf.buffers[0].byteLength,this.sourceBuffers=[this.gltf.buffers[0]])}get json(){return this.gltf.json}getApplicationData(e){return this.json[e]}getExtraData(e){return(this.json.extras||{})[e]}hasExtension(e){let r=this.getUsedExtensions().find(n=>n===e),o=this.getRequiredExtensions().find(n=>n===e);return typeof r=="string"||typeof o=="string"}getExtension(e){let r=this.getUsedExtensions().find(n=>n===e),o=this.json.extensions||{};return r?o[e]:null}getRequiredExtension(e){return this.getRequiredExtensions().find(o=>o===e)?this.getExtension(e):null}getRequiredExtensions(){return this.json.extensionsRequired||[]}getUsedExtensions(){return this.json.extensionsUsed||[]}getRemovedExtensions(){return this.json.extensionsRemoved||[]}getObjectExtension(e,r){return(e.extensions||{})[r]}getScene(e){return this.getObject("scenes",e)}getNode(e){return this.getObject("nodes",e)}getSkin(e){return this.getObject("skins",e)}getMesh(e){return this.getObject("meshes",e)}getMaterial(e){return this.getObject("materials",e)}getAccessor(e){return this.getObject("accessors",e)}getTexture(e){return this.getObject("textures",e)}getSampler(e){return this.getObject("samplers",e)}getImage(e){return this.getObject("images",e)}getBufferView(e){return this.getObject("bufferViews",e)}getBuffer(e){return this.getObject("buffers",e)}getObject(e,r){if(typeof r=="object")return r;let o=this.json[e]&&this.json[e][r];if(!o)throw new Error(`glTF file error: Could not find ${e}[${r}]`);return o}getTypedArrayForBufferView(e){e=this.getBufferView(e);let r=e.buffer,o=this.gltf.buffers[r];ut(o);let n=(e.byteOffset||0)+o.byteOffset;return new Uint8Array(o.arrayBuffer,n,e.byteLength)}getTypedArrayForAccessor(e){let r=this.getAccessor(e);return w4(this.gltf.json,this.gltf.buffers,r)}getTypedArrayForImageData(e){e=this.getAccessor(e);let r=this.getBufferView(e.bufferView),n=this.getBuffer(r.buffer).data,i=r.byteOffset||0;return new Uint8Array(n,i,r.byteLength)}addApplicationData(e,r){return this.json[e]=r,this}addExtraData(e,r){return this.json.extras=this.json.extras||{},this.json.extras[e]=r,this}addObjectExtension(e,r,o){return e.extensions=e.extensions||{},e.extensions[r]=o,this.registerUsedExtension(r),this}setObjectExtension(e,r,o){let n=e.extensions||{};n[r]=o}removeObjectExtension(e,r){let o=e?.extensions||{};if(o[r]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];let n=this.json.extensionsRemoved;n.includes(r)||n.push(r)}delete o[r]}addExtension(e,r={}){return ut(r),this.json.extensions=this.json.extensions||{},this.json.extensions[e]=r,this.registerUsedExtension(e),r}addRequiredExtension(e,r={}){return ut(r),this.addExtension(e,r),this.registerRequiredExtension(e),r}registerUsedExtension(e){this.json.extensionsUsed=this.json.extensionsUsed||[],this.json.extensionsUsed.find(r=>r===e)||this.json.extensionsUsed.push(e)}registerRequiredExtension(e){this.registerUsedExtension(e),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find(r=>r===e)||this.json.extensionsRequired.push(e)}removeExtension(e){if(this.json.extensions?.[e]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];let r=this.json.extensionsRemoved;r.includes(e)||r.push(e)}this.json.extensions&&delete this.json.extensions[e],this.json.extensionsRequired&&this._removeStringFromArray(this.json.extensionsRequired,e),this.json.extensionsUsed&&this._removeStringFromArray(this.json.extensionsUsed,e)}setDefaultScene(e){this.json.scene=e}addScene(e){let{nodeIndices:r}=e;return this.json.scenes=this.json.scenes||[],this.json.scenes.push({nodes:r}),this.json.scenes.length-1}addNode(e){let{meshIndex:r,matrix:o}=e;this.json.nodes=this.json.nodes||[];let n={mesh:r};return o&&(n.matrix=o),this.json.nodes.push(n),this.json.nodes.length-1}addMesh(e){let{attributes:r,indices:o,material:n,mode:i=4}=e,a={primitives:[{attributes:this._addAttributes(r),mode:i}]};if(o){let c=this._addIndices(o);a.primitives[0].indices=c}return Number.isFinite(n)&&(a.primitives[0].material=n),this.json.meshes=this.json.meshes||[],this.json.meshes.push(a),this.json.meshes.length-1}addPointCloud(e){let o={primitives:[{attributes:this._addAttributes(e),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(o),this.json.meshes.length-1}addImage(e,r){let o=qi(e),n=r||o?.mimeType,s={bufferView:this.addBufferView(e),mimeType:n};return this.json.images=this.json.images||[],this.json.images.push(s),this.json.images.length-1}addBufferView(e,r=0,o=this.byteLength){let n=e.byteLength;ut(Number.isFinite(n)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(e);let i={buffer:r,byteOffset:o,byteLength:n};return this.byteLength+=Wn(n,4),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(i),this.json.bufferViews.length-1}addAccessor(e,r){let o={bufferView:e,type:_y(r.size),componentType:r.componentType,count:r.count,max:r.max,min:r.min};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(o),this.json.accessors.length-1}addBinaryBuffer(e,r={size:3}){let o=this.addBufferView(e),n={min:r.min,max:r.max};(!n.min||!n.max)&&(n=this._getAccessorMinMax(e,r.size));let i={size:r.size,componentType:Ri(e),count:Math.round(e.length/r.size),min:n.min,max:n.max};return this.addAccessor(o,Object.assign(i,r))}addTexture(e){let{imageIndex:r}=e,o={source:r};return this.json.textures=this.json.textures||[],this.json.textures.push(o),this.json.textures.length-1}addMaterial(e){return this.json.materials=this.json.materials||[],this.json.materials.push(e),this.json.materials.length-1}createBinaryChunk(){let e=this.byteLength,r=new ArrayBuffer(e),o=new Uint8Array(r),n=0;for(let i of this.sourceBuffers||[])n=jb(i,o,n);this.json?.buffers?.[0]?this.json.buffers[0].byteLength=e:this.json.buffers=[{byteLength:e}],this.gltf.binary=r,this.sourceBuffers=[r],this.gltf.buffers=[{arrayBuffer:r,byteOffset:0,byteLength:r.byteLength}]}_removeStringFromArray(e,r){let o=!0;for(;o;){let n=e.indexOf(r);n>-1?e.splice(n,1):o=!1}}_addAttributes(e={}){let r={};for(let o in e){let n=e[o],i=this._getGltfAttributeName(o),s=this.addBinaryBuffer(n.value,n);r[i]=s}return r}_addIndices(e){return this.addBinaryBuffer(e,{size:1})}_getGltfAttributeName(e){switch(e.toLowerCase()){case"position":case"positions":case"vertices":return"POSITION";case"normal":case"normals":return"NORMAL";case"color":case"colors":return"COLOR_0";case"texcoord":case"texcoords":return"TEXCOORD_0";default:return e}}_getAccessorMinMax(e,r){let o={min:null,max:null};if(e.length<r)return o;o.min=[],o.max=[];let n=e.subarray(0,r);for(let i of n)o.min.push(i),o.max.push(i);for(let i=r;i<e.length;i+=r)for(let s=0;s<r;s++)o.min[0+s]=Math.min(o.min[0+s],e[i+s]),o.max[0+s]=Math.max(o.max[0+s],e[i+s]);return o}};function P4(t){return(t%1+1)%1}var M4={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16,BOOLEAN:1,STRING:1,ENUM:1},jce={INT8:Int8Array,UINT8:Uint8Array,INT16:Int16Array,UINT16:Uint16Array,INT32:Int32Array,UINT32:Uint32Array,INT64:BigInt64Array,UINT64:BigUint64Array,FLOAT32:Float32Array,FLOAT64:Float64Array},R4={INT8:1,UINT8:1,INT16:2,UINT16:2,INT32:4,UINT32:4,INT64:8,UINT64:8,FLOAT32:4,FLOAT64:8};function lh(t,e){return R4[e]*M4[t]}function Kc(t,e,r,o){if(r!=="UINT8"&&r!=="UINT16"&&r!=="UINT32"&&r!=="UINT64")return null;let n=t.getTypedArrayForBufferView(e),i=qc(n,"SCALAR",r,o+1);return i instanceof BigInt64Array||i instanceof BigUint64Array?null:i}function qc(t,e,r,o=1){let n=M4[e],i=jce[r],s=R4[r],a=o*n,c=a*s,l=t.buffer,f=t.byteOffset;return f%s!==0&&(l=new Uint8Array(l).slice(f,f+c).buffer,f=0),new i(Ar(l),f,a)}function Zc(t,e,r){let o=`TEXCOORD_${e.texCoord||0}`,n=r.attributes[o],i=t.getTypedArrayForAccessor(n),s=t.gltf.json,a=e.index,c=s.textures?.[a]?.source;if(typeof c<"u"){let l=s.images?.[c]?.mimeType,f=t.gltf.images?.[c];if(f&&typeof f.width<"u"){let u=[];for(let d=0;d<i.length;d+=2){let h=Wce(f,l,i,d,e.channels);u.push(h)}return u}}return[]}function yy(t,e,r,o,n){if(!r?.length)return;let i=[];for(let f of r){let u=o.findIndex(d=>d===f);u===-1&&(u=o.push(f)-1),i.push(u)}let s=new Uint32Array(i),a=t.gltf.buffers.push({arrayBuffer:s.buffer,byteOffset:s.byteOffset,byteLength:s.byteLength})-1,c=t.addBufferView(s,a,0),l=t.addAccessor(c,{size:1,componentType:Ri(s),count:s.length});n.attributes[e]=l}function Wce(t,e,r,o,n=[0]){let i={r:{offset:0,shift:0},g:{offset:1,shift:8},b:{offset:2,shift:16},a:{offset:3,shift:24}},s=r[o],a=r[o+1],c=1;e&&(e.indexOf("image/jpeg")!==-1||e.indexOf("image/png")!==-1)&&(c=4);let l=Gce(s,a,t,c),f=0;for(let u of n){let d=typeof u=="number"?Object.values(i)[u]:i[u],h=l+d.offset,p=nf(t);if(p.data.length<=h)throw new Error(`${p.data.length} <= ${h}`);let m=p.data[h];f|=m<<d.shift}return f}function Gce(t,e,r,o=1){let n=r.width,i=P4(t)*(n-1),s=Math.round(i),a=r.height,c=P4(e)*(a-1),l=Math.round(c),f=r.components?r.components:o;return(l*n+s)*f}function xy(t,e,r,o,n){let i=[];for(let s=0;s<e;s++){let a=r[s],c=r[s+1]-r[s];if(c+a>o)break;let l=a/n,f=c/n;i.push(t.slice(l,l+f))}return i}function by(t,e,r){let o=[];for(let n=0;n<e;n++){let i=n*r;o.push(t.slice(i,i+r))}return o}function Ay(t,e,r,o){if(r)throw new Error("Not implemented - arrayOffsets for strings is specified");if(o){let n=[],i=new TextDecoder("utf8"),s=0;for(let a=0;a<t;a++){let c=o[a+1]-o[a];if(c+s<=e.length){let l=e.subarray(s,c+s),f=i.decode(l);n.push(f),s+=c}}return n}return[]}var Jc="EXT_mesh_features",$ce=Jc;async function Xce(t,e){let r=new ye(t);Kce(r,e)}function Yce(t,e){let r=new ye(t);return Zce(r,e),r.createBinaryChunk(),r.gltf}function Kce(t,e){let r=t.gltf.json;if(r.meshes)for(let o of r.meshes)for(let n of o.primitives)qce(t,n,e)}function qce(t,e,r){if(!r?.gltf?.loadBuffers)return;let n=e.extensions?.[Jc]?.featureIds;if(n)for(let i of n){let s;if(typeof i.attribute<"u"){let a=`_FEATURE_ID_${i.attribute}`,c=e.attributes[a];s=t.getTypedArrayForAccessor(c)}else typeof i.texture<"u"&&r?.gltf?.loadImages?s=Zc(t,i.texture,e):s=[];i.data=s}}function Zce(t,e){let r=t.gltf.json.meshes;if(r)for(let o of r)for(let n of o.primitives)Qce(t,n)}function Jce(t,e,r,o){e.extensions||(e.extensions={});let n=e.extensions[Jc];n||(n={featureIds:[]},e.extensions[Jc]=n);let{featureIds:i}=n,s={featureCount:r.length,propertyTable:o,data:r};i.push(s),t.addObjectExtension(e,Jc,n)}function Qce(t,e){let r=e.extensions?.[Jc];if(!r)return;let o=r.featureIds;o.forEach((n,i)=>{if(n.data){let{accessorKey:s,index:a}=ele(e.attributes),c=new Uint32Array(n.data);o[i]={featureCount:c.length,propertyTable:n.propertyTable,attribute:a},t.gltf.buffers.push({arrayBuffer:c.buffer,byteOffset:c.byteOffset,byteLength:c.byteLength});let l=t.addBufferView(c),f=t.addAccessor(l,{size:1,componentType:Ri(c),count:c.length});e.attributes[s]=f}})}function ele(t){let e="_FEATURE_ID_",r=Object.keys(t).filter(i=>i.indexOf(e)===0),o=-1;for(let i of r){let s=Number(i.substring(e.length));s>o&&(o=s)}return o++,{accessorKey:`${e}${o}`,index:o}}var UC={};ze(UC,{createExtStructuralMetadata:()=>Tle,decode:()=>rle,encode:()=>ole,name:()=>tle});var Qc="EXT_structural_metadata",tle=Qc;async function rle(t,e){let r=new ye(t);nle(r,e)}function ole(t,e){let r=new ye(t);return ble(r,e),r.createBinaryChunk(),r.gltf}function nle(t,e){if(!e.gltf?.loadBuffers)return;let r=t.getExtension(Qc);r&&(e.gltf?.loadImages&&ile(t,r),sle(t,r))}function ile(t,e){let r=e.propertyTextures,o=t.gltf.json;if(r&&o.meshes)for(let n of o.meshes)for(let i of n.primitives)cle(t,r,i,e)}function sle(t,e){let r=e.schema;if(!r)return;let o=r.classes,n=e.propertyTables;if(o&&n)for(let i in o){let s=ale(n,i);s&&fle(t,r,s)}}function ale(t,e){for(let r of t)if(r.class===e)return r;return null}function cle(t,e,r,o){if(!e)return;let i=r.extensions?.[Qc]?.propertyTextures;if(i)for(let s of i){let a=e[s];lle(t,a,r,o)}}function lle(t,e,r,o){if(!e.properties)return;o.dataAttributeNames||(o.dataAttributeNames=[]);let n=e.class;for(let i in e.properties){let s=`${n}_${i}`,a=e.properties?.[i];if(!a)continue;a.data||(a.data=[]);let c=a.data,l=Zc(t,a,r);l!==null&&(yy(t,s,l,c,r),a.data=c,o.dataAttributeNames.push(s))}}function fle(t,e,r){let o=e.classes?.[r.class];if(!o)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${r.class}`);let n=r.count;for(let i in o.properties){let s=o.properties[i],a=r.properties?.[i];if(a){let c=ule(t,e,s,n,a);a.data=c}}}function ule(t,e,r,o,n){let i=[],s=n.values,a=t.getTypedArrayForBufferView(s),c=dle(t,r,n,o),l=hle(t,n,o);switch(r.type){case"SCALAR":case"VEC2":case"VEC3":case"VEC4":case"MAT2":case"MAT3":case"MAT4":{i=ple(r,o,a,c);break}case"BOOLEAN":throw new Error(`Not implemented - classProperty.type=${r.type}`);case"STRING":{i=Ay(o,a,c,l);break}case"ENUM":{i=mle(e,r,o,a,c);break}default:throw new Error(`Unknown classProperty type ${r.type}`)}return i}function dle(t,e,r,o){return e.array&&typeof e.count>"u"&&typeof r.arrayOffsets<"u"?Kc(t,r.arrayOffsets,r.arrayOffsetType||"UINT32",o):null}function hle(t,e,r){return typeof e.stringOffsets<"u"?Kc(t,e.stringOffsets,e.stringOffsetType||"UINT32",r):null}function ple(t,e,r,o){let n=t.array,i=t.count,s=lh(t.type,t.componentType),a=r.byteLength/s,c;return t.componentType?c=qc(r,t.type,t.componentType,a):c=r,n?o?xy(c,e,o,r.length,s):i?by(c,e,i):[]:c}function mle(t,e,r,o,n){let i=e.enumType;if(!i)throw new Error("Incorrect data in the EXT_structural_metadata extension: classProperty.enumType is not set for type ENUM");let s=t.enums?.[i];if(!s)throw new Error(`Incorrect data in the EXT_structural_metadata extension: schema.enums does't contain ${i}`);let a=s.valueType||"UINT16",c=lh(e.type,a),l=o.byteLength/c,f=qc(o,e.type,a,l);if(f||(f=o),e.array){if(n)return gle({valuesData:f,numberOfElements:r,arrayOffsets:n,valuesDataBytesLength:o.length,elementSize:c,enumEntry:s});let u=e.count;return u?_le(f,r,u,s):[]}return DC(f,0,r,s)}function gle(t){let{valuesData:e,numberOfElements:r,arrayOffsets:o,valuesDataBytesLength:n,elementSize:i,enumEntry:s}=t,a=[];for(let c=0;c<r;c++){let l=o[c],f=o[c+1]-o[c];if(f+l>n)break;let u=l/i,d=f/i,h=DC(e,u,d,s);a.push(h)}return a}function _le(t,e,r,o){let n=[];for(let i=0;i<e;i++){let s=r*i,a=DC(t,s,r,o);n.push(a)}return n}function DC(t,e,r,o){let n=[];for(let i=0;i<r;i++)if(t instanceof BigInt64Array||t instanceof BigUint64Array)n.push("");else{let s=t[e+i],a=yle(o,s);a?n.push(a.name):n.push("")}return n}function yle(t,e){for(let r of t.values)if(r.value===e)return r;return null}var xle="schemaClassId";function ble(t,e){let r=t.getExtension(Qc);if(r&&r.propertyTables)for(let o of r.propertyTables){let n=o.class,i=r.schema?.classes?.[n];o.properties&&i&&Ale(o,i,t)}}function Ale(t,e,r){for(let o in t.properties){let n=t.properties[o].data;if(n){let i=e.properties[o];if(i){let s=Cle(n,i,r);t.properties[o]=s}}}}function Tle(t,e,r=xle){let o=t.getExtension(Qc);o||(o=t.addExtension(Qc)),o.schema=vle(e,r,o.schema);let n=Sle(e,r,o.schema);return o.propertyTables||(o.propertyTables=[]),o.propertyTables.push(n)-1}function vle(t,e,r){let o=r??{id:"schema_id"},n={properties:{}};for(let i of t){let s={type:i.elementType,componentType:i.componentType};n.properties[i.name]=s}return o.classes={},o.classes[e]=n,o}function Sle(t,e,r){let o={class:e,count:0},n=0,i=r.classes?.[e];for(let s of t){if(n===0&&(n=s.values.length),n!==s.values.length&&s.values.length)throw new Error("Illegal values in attributes");i?.properties[s.name]&&(o.properties||(o.properties={}),o.properties[s.name]={values:0,data:s.values})}return o.count=n,o}function Cle(t,e,r){let o={values:0};if(e.type==="STRING"){let{stringData:n,stringOffsets:i}=Ple(t);o.stringOffsets=NC(i,r),o.values=NC(n,r)}else if(e.type==="SCALAR"&&e.componentType){let n=wle(t,e.componentType);o.values=NC(n,r)}return o}var Ele={INT8:Int8Array,UINT8:Uint8Array,INT16:Int16Array,UINT16:Uint16Array,INT32:Int32Array,UINT32:Uint32Array,INT64:Int32Array,UINT64:Uint32Array,FLOAT32:Float32Array,FLOAT64:Float64Array};function wle(t,e){let r=[];for(let n of t)r.push(Number(n));let o=Ele[e];if(!o)throw new Error("Illegal component type");return new o(r)}function Ple(t){let e=new TextEncoder,r=[],o=0;for(let c of t){let l=e.encode(c);o+=l.length,r.push(l)}let n=new Uint8Array(o),i=[],s=0;for(let c of r)n.set(c,s),i.push(s),s+=c.length;i.push(s);let a=new Uint32Array(i);return{stringData:n,stringOffsets:a}}function NC(t,e){return e.gltf.buffers.push({arrayBuffer:Ar(t.buffer),byteOffset:t.byteOffset,byteLength:t.byteLength}),e.addBufferView(t)}var kC={};ze(kC,{decode:()=>Rle,name:()=>Mle});var I4="EXT_feature_metadata",Mle=I4;async function Rle(t,e){let r=new ye(t);Ile(r,e)}function Ile(t,e){if(!e.gltf?.loadBuffers)return;let r=t.getExtension(I4);r&&(e.gltf?.loadImages&&Lle(t,r),Ble(t,r))}function Lle(t,e){let r=e.schema;if(!r)return;let o=r.classes,{featureTextures:n}=e;if(o&&n)for(let i in o){let s=o[i],a=Fle(n,i);a&&Dle(t,a,s)}}function Ble(t,e){let r=e.schema;if(!r)return;let o=r.classes,n=e.featureTables;if(o&&n)for(let i in o){let s=Ole(n,i);s&&Nle(t,r,s)}}function Ole(t,e){for(let r in t){let o=t[r];if(o.class===e)return o}return null}function Fle(t,e){for(let r in t){let o=t[r];if(o.class===e)return o}return null}function Nle(t,e,r){if(!r.class)return;let o=e.classes?.[r.class];if(!o)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${r.class}`);let n=r.count;for(let i in o.properties){let s=o.properties[i],a=r.properties?.[i];if(a){let c=Ule(t,e,s,n,a);a.data=c}}}function Dle(t,e,r){let o=e.class;for(let n in r.properties){let i=e?.properties?.[n];if(i){let s=jle(t,i,o);i.data=s}}}function Ule(t,e,r,o,n){let i=[],s=n.bufferView,a=t.getTypedArrayForBufferView(s),c=kle(t,r,n,o),l=Vle(t,r,n,o);return r.type==="STRING"||r.componentType==="STRING"?i=Ay(o,a,c,l):zle(r)&&(i=Hle(r,o,a,c)),i}function kle(t,e,r,o){return e.type==="ARRAY"&&typeof e.componentCount>"u"&&typeof r.arrayOffsetBufferView<"u"?Kc(t,r.arrayOffsetBufferView,r.offsetType||"UINT32",o):null}function Vle(t,e,r,o){return typeof r.stringOffsetBufferView<"u"?Kc(t,r.stringOffsetBufferView,r.offsetType||"UINT32",o):null}function zle(t){let e=["UINT8","INT16","UINT16","INT32","UINT32","INT64","UINT64","FLOAT32","FLOAT64"];return e.includes(t.type)||typeof t.componentType<"u"&&e.includes(t.componentType)}function Hle(t,e,r,o){let n=t.type==="ARRAY",i=t.componentCount,s="SCALAR",a=t.componentType||t.type,c=lh(s,a),l=r.byteLength/c,f=qc(r,s,a,l);return n?o?xy(f,e,o,r.length,c):i?by(f,e,i):[]:f}function jle(t,e,r){let o=t.gltf.json;if(!o.meshes)return[];let n=[];for(let i of o.meshes)for(let s of i.primitives)Wle(t,r,e,n,s);return n}function Wle(t,e,r,o,n){let i={channels:r.channels,...r.texture},s=Zc(t,i,n);s&&yy(t,e,s,o,n)}var L4="4.4.3";var B4="4.4.3";var Ty={TRANSCODER:"basis_transcoder.js",TRANSCODER_WASM:"basis_transcoder.wasm",ENCODER:"basis_encoder.js",ENCODER_WASM:"basis_encoder.wasm"},O4;async function zC(t){zp(t.modules);let e=Ib("basis");return e||(O4||=Gle(t),await O4)}async function Gle(t){let e=null,r=null;return[e,r]=await Promise.all([await br(Ty.TRANSCODER,"textures",t),await br(Ty.TRANSCODER_WASM,"textures",t)]),e=e||globalThis.BASIS,await $le(e,r)}function $le(t,e){let r={};return e&&(r.wasmBinary=e),new Promise(o=>{t(r).then(n=>{let{BasisFile:i,initializeBasis:s}=n;s(),o({BasisFile:i})})})}var VC;async function HC(t){let e=t.modules||{};return e.basisEncoder?e.basisEncoder:(VC=VC||Xle(t),await VC)}async function Xle(t){let e=null,r=null;return[e,r]=await Promise.all([await br(Ty.ENCODER,"textures",t),await br(Ty.ENCODER_WASM,"textures",t)]),e=e||globalThis.BASIS,await Yle(e,r)}function Yle(t,e){let r={};return e&&(r.wasmBinary=e),new Promise(o=>{t(r).then(n=>{let{BasisFile:i,KTX2File:s,initializeBasis:a,BasisEncoder:c}=n;a(),o({BasisFile:i,KTX2File:s,BasisEncoder:c})})})}var Kle=["","WEBKIT_","MOZ_"],F4={WEBGL_compressed_texture_s3tc:["bc1-rgb-unorm-webgl","bc1-rgba-unorm","bc2-rgba-unorm","bc3-rgba-unorm"],WEBGL_compressed_texture_s3tc_srgb:["bc1-rgb-unorm-srgb-webgl","bc1-rgba-unorm-srgb","bc2-rgba-unorm-srgb","bc3-rgba-unorm-srgb"],EXT_texture_compression_rgtc:["bc4-r-unorm","bc4-r-snorm","bc5-rg-unorm","bc5-rg-snorm"],EXT_texture_compression_bptc:["bc6h-rgb-ufloat","bc6h-rgb-float","bc7-rgba-unorm","bc7-rgba-unorm-srgb"],WEBGL_compressed_texture_etc1:["etc1-rgb-unorm-webgl"],WEBGL_compressed_texture_etc:["etc2-rgb8unorm","etc2-rgb8unorm-srgb","etc2-rgb8a1unorm","etc2-rgb8a1unorm-srgb","etc2-rgba8unorm","etc2-rgba8unorm-srgb","eac-r11unorm","eac-r11snorm","eac-rg11unorm","eac-rg11snorm"],WEBGL_compressed_texture_pvrtc:["pvrtc-rgb4unorm-webgl","pvrtc-rgba4unorm-webgl","pvrtc-rgb2unorm-webgl","pvrtc-rgba2unorm-webgl"],WEBGL_compressed_texture_atc:["atc-rgb-unorm-webgl","atc-rgba-unorm-webgl","atc-rgbai-unorm-webgl"],WEBGL_compressed_texture_astc:["astc-4x4-unorm","astc-4x4-unorm-srgb","astc-5x4-unorm","astc-5x4-unorm-srgb","astc-5x5-unorm","astc-5x5-unorm-srgb","astc-6x5-unorm","astc-6x5-unorm-srgb","astc-6x6-unorm","astc-6x6-unorm-srgb","astc-8x5-unorm","astc-8x5-unorm-srgb","astc-8x6-unorm","astc-8x6-unorm-srgb","astc-8x8-unorm","astc-8x8-unorm-srgb","astc-10x5-unorm","astc-10x5-unorm-srgb","astc-10x6-unorm","astc-10x6-unorm-srgb","astc-10x8-unorm","astc-10x8-unorm-srgb","astc-10x10-unorm","astc-10x10-unorm-srgb","astc-12x10-unorm","astc-12x10-unorm-srgb","astc-12x12-unorm","astc-12x12-unorm-srgb"]};var vy=null;function N4(t){if(!vy){t=t||qle()||void 0,vy=new Set;for(let e of Kle)for(let r in F4)if(t&&t.getExtension(`${e}${r}`))for(let o of F4[r])vy.add(o)}return vy}function qle(){try{return document.createElement("canvas").getContext("webgl")}catch{return null}}var xr=[171,75,84,88,32,50,48,187,13,10,26,10];function D4(t){let e=new Uint8Array(t);return!(e.byteLength<xr.length||e[0]!==xr[0]||e[1]!==xr[1]||e[2]!==xr[2]||e[3]!==xr[3]||e[4]!==xr[4]||e[5]!==xr[5]||e[6]!==xr[6]||e[7]!==xr[7]||e[8]!==xr[8]||e[9]!==xr[9]||e[10]!==xr[10]||e[11]!==xr[11])}var U4=Promise.resolve(),z4={etc1:{basisFormat:0,compressed:!0,format:36196,textureFormat:"etc1-rgb-unorm-webgl"},etc2:{basisFormat:1,compressed:!0,format:37493,textureFormat:"etc2-rgba8unorm"},bc1:{basisFormat:2,compressed:!0,format:33776,textureFormat:"bc1-rgb-unorm-webgl"},bc3:{basisFormat:3,compressed:!0,format:33779,textureFormat:"bc3-rgba-unorm"},bc4:{basisFormat:4,compressed:!0,format:36283,textureFormat:"bc4-r-unorm"},bc5:{basisFormat:5,compressed:!0,format:36285,textureFormat:"bc5-rg-unorm"},"bc7-m6-opaque-only":{basisFormat:6,compressed:!0,format:36492,textureFormat:"bc7-rgba-unorm"},"bc7-m5":{basisFormat:7,compressed:!0,format:36492,textureFormat:"bc7-rgba-unorm"},"pvrtc1-4-rgb":{basisFormat:8,compressed:!0,format:35840,textureFormat:"pvrtc-rgb4unorm-webgl"},"pvrtc1-4-rgba":{basisFormat:9,compressed:!0,format:35842,textureFormat:"pvrtc-rgba4unorm-webgl"},"astc-4x4":{basisFormat:10,compressed:!0,format:37808,textureFormat:"astc-4x4-unorm"},"atc-rgb":{basisFormat:11,compressed:!0,format:35986,textureFormat:"atc-rgb-unorm-webgl"},"atc-rgba-interpolated-alpha":{basisFormat:12,compressed:!0,format:34798,textureFormat:"atc-rgbai-unorm-webgl"},rgba32:{basisFormat:13,compressed:!1,format:32856,textureFormat:"rgba8unorm"},rgb565:{basisFormat:14,compressed:!1,format:36194,textureFormat:"rgb565unorm-webgl"},bgr565:{basisFormat:15,compressed:!1,format:36194,textureFormat:"rgb565unorm-webgl"},rgba4444:{basisFormat:16,compressed:!1,format:32854,textureFormat:"rgba4unorm-webgl"}},YKe=Object.freeze(Object.keys(z4));async function Qle(t){let e=U4,r;U4=new Promise(o=>{r=o}),await e;try{return await t()}finally{r()}}async function H4(t,e={}){let r=Kl(e);return await Qle(async()=>{if(!e.basis?.containerFormat||e.basis.containerFormat==="auto"){if(D4(t)){let n=await HC(r);return k4(n.KTX2File,t,e)}let{BasisFile:o}=await zC(r);return jC(o,t,e)}switch(e.basis.module){case"encoder":let o=await HC(r);switch(e.basis.containerFormat){case"ktx2":return k4(o.KTX2File,t,e);case"basis":default:return jC(o.BasisFile,t,e)}case"transcoder":default:let{BasisFile:n}=await zC(r);return jC(n,t,e)}})}function jC(t,e,r){let o=new t(new Uint8Array(e));try{if(!o.startTranscoding())throw new Error("Failed to start basis transcoding");let n=o.getNumImages(),i=[];for(let s=0;s<n;s++){let a=o.getNumLevels(s),c=[];for(let l=0;l<a;l++)c.push(efe(o,s,l,r));i.push(c)}return i}finally{o.close(),o.delete()}}function efe(t,e,r,o){let n=t.getImageWidth(e,r),i=t.getImageHeight(e,r),s=t.getHasAlpha(),{compressed:a,format:c,basisFormat:l,textureFormat:f}=j4(o,s),u=t.getImageTranscodedSizeInBytes(e,r,l),d=new Uint8Array(u);if(!t.transcodeImage(d,e,r,l,0,0))throw new Error("failed to start Basis transcoding");return{shape:"texture-level",width:n,height:i,data:d,compressed:a,...c!==void 0?{format:c}:{},...f!==void 0?{textureFormat:f}:{},hasAlpha:s}}function k4(t,e,r){let o=new t(new Uint8Array(e));try{if(!o.startTranscoding())throw new Error("failed to start KTX2 transcoding");let n=o.getLevels(),i=[];for(let s=0;s<n;s++)i.push(tfe(o,s,r));return[i]}finally{o.close(),o.delete()}}function tfe(t,e,r){let{alphaFlag:o,height:n,width:i}=t.getImageLevelInfo(e,0,0),{compressed:s,format:a,basisFormat:c,textureFormat:l}=j4(r,o),f=t.getImageTranscodedSizeInBytes(e,0,0,c),u=new Uint8Array(f);if(!t.transcodeImage(u,e,0,0,c,0,-1,-1))throw new Error("Failed to transcode KTX2 image");return{shape:"texture-level",width:i,height:n,data:u,compressed:s,...a!==void 0?{format:a}:{},...l!==void 0?{textureFormat:l}:{},levelSize:f,hasAlpha:o}}function j4(t,e){let r=t.basis?.format||"auto";r==="auto"&&(r=t.basis?.supportedTextureFormats?V4(t.basis.supportedTextureFormats):V4()),typeof r=="object"&&(r=e?r.alpha:r.noAlpha);let o=r.toLowerCase(),n=z4[o];if(!n)throw new Error(`Unknown Basis format ${r}`);return n}function V4(t=N4()){let e=new Set(t);return el(e,["astc-4x4-unorm","astc-4x4-unorm-srgb"])?"astc-4x4":el(e,["bc7-rgba-unorm","bc7-rgba-unorm-srgb"])?{alpha:"bc7-m5",noAlpha:"bc7-m6-opaque-only"}:el(e,["bc1-rgb-unorm-webgl","bc1-rgb-unorm-srgb-webgl","bc1-rgba-unorm","bc1-rgba-unorm-srgb","bc2-rgba-unorm","bc2-rgba-unorm-srgb","bc3-rgba-unorm","bc3-rgba-unorm-srgb"])?{alpha:"bc3",noAlpha:"bc1"}:el(e,["pvrtc-rgb4unorm-webgl","pvrtc-rgba4unorm-webgl","pvrtc-rgb2unorm-webgl","pvrtc-rgba2unorm-webgl"])?{alpha:"pvrtc1-4-rgba",noAlpha:"pvrtc1-4-rgb"}:el(e,["etc2-rgb8unorm","etc2-rgb8unorm-srgb","etc2-rgb8a1unorm","etc2-rgb8a1unorm-srgb","etc2-rgba8unorm","etc2-rgba8unorm-srgb","eac-r11unorm","eac-r11snorm","eac-rg11unorm","eac-rg11snorm"])?"etc2":e.has("etc1-rgb-unorm-webgl")?"etc1":el(e,["atc-rgb-unorm-webgl","atc-rgba-unorm-webgl","atc-rgbai-unorm-webgl"])?{alpha:"atc-rgba-interpolated-alpha",noAlpha:"atc-rgb"}:"rgb565"}function el(t,e){return e.some(r=>t.has(r))}var W4={dataType:null,batchType:null,name:"Basis",id:"basis",module:"textures",version:B4,worker:!0,extensions:["basis","ktx2"],mimeTypes:["application/octet-stream","image/ktx2"],tests:["sB"],binary:!0,options:{basis:{format:"auto",containerFormat:"auto",module:"transcoder"}}},WC={...W4,parse:H4};var tl=!0,G4=1735152710,XC=12,Sy=8,rfe=1313821514,ofe=5130562,nfe=0,ife=0,sfe=1;function afe(t,e=0){return`${String.fromCharCode(t.getUint8(e+0))}${String.fromCharCode(t.getUint8(e+1))}${String.fromCharCode(t.getUint8(e+2))}${String.fromCharCode(t.getUint8(e+3))}`}function $4(t,e=0,r={}){let o=new DataView(t),{magic:n=G4}=r,i=o.getUint32(e,!1);return i===n||i===G4}function X4(t,e,r=0,o={}){let n=new DataView(e),i=afe(n,r+0),s=n.getUint32(r+4,tl),a=n.getUint32(r+8,tl);switch(Object.assign(t,{header:{byteOffset:r,byteLength:a,hasBinChunk:!1},type:i,version:s,json:{},binChunks:[]}),r+=XC,t.version){case 1:return cfe(t,n,r);case 2:return lfe(t,n,r,o={});default:throw new Error(`Invalid GLB version ${t.version}. Only supports version 1 and 2.`)}}function cfe(t,e,r){le(t.header.byteLength>XC+Sy);let o=e.getUint32(r+0,tl),n=e.getUint32(r+4,tl);return r+=Sy,le(n===nfe),GC(t,e,r,o),r+=o,r+=$C(t,e,r,t.header.byteLength),r}function lfe(t,e,r,o){return le(t.header.byteLength>XC+Sy),ffe(t,e,r,o),r+t.header.byteLength}function ffe(t,e,r,o){for(;r+8<=t.header.byteLength;){let n=e.getUint32(r+0,tl),i=e.getUint32(r+4,tl);switch(r+=Sy,i){case rfe:GC(t,e,r,n);break;case ofe:$C(t,e,r,n);break;case ife:o.strict||GC(t,e,r,n);break;case sfe:o.strict||$C(t,e,r,n);break;default:break}r+=Wn(n,4)}return r}function GC(t,e,r,o){let n=new Uint8Array(e.buffer,r,o),s=new TextDecoder("utf8").decode(n);return t.json=JSON.parse(s),Wn(o,4)}function $C(t,e,r,o){return t.header.hasBinChunk=!0,t.binChunks.push({byteOffset:r,byteLength:o,arrayBuffer:e.buffer}),Wn(o,4)}function YC(t,e,r){if(t.startsWith("data:")||t.startsWith("http:")||t.startsWith("https:"))return t;let n=r?.baseUrl||ufe(e?.core?.baseUrl);if(!n)throw new Error(`'baseUrl' must be provided to resolve relative url ${t}`);return n.endsWith("/")?`${n}${t}`:`${n}/${t}`}function ufe(t){if(!t)return;if(t.endsWith("/"))return t;let e=t.lastIndexOf("/");return e>=0?t.slice(0,e+1):""}var qC={};ze(qC,{decode:()=>vfe,name:()=>Tfe});var dfe="B9h9z9tFBBBF8fL9gBB9gLaaaaaFa9gEaaaB9gFaFa9gEaaaFaEMcBFFFGGGEIIILF9wFFFLEFBFKNFaFCx/IFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBF8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBGy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBEn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBIi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBKI9z9iqlBOc+x8ycGBM/qQFTa8jUUUUBCU/EBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAGTkUUUBRNCUoBAG9uC/wgBZHKCUGAKCUG9JyRVAECFJRICBRcGXEXAcAF9PQFAVAFAclAcAVJAF9JyRMGXGXAG9FQBAMCbJHKC9wZRSAKCIrCEJCGrRQANCUGJRfCBRbAIRTEXGXAOATlAQ9PQBCBRISEMATAQJRIGXAS9FQBCBRtCBREEXGXAOAIlCi9PQBCBRISLMANCU/CBJAEJRKGXGXGXGXGXATAECKrJ2BBAtCKZrCEZfIBFGEBMAKhB83EBAKCNJhB83EBSEMAKAI2BIAI2BBHmCKrHYAYCE6HYy86BBAKCFJAICIJAYJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCGJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCEJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCIJAYAmJHY2BBAI2BFHmCKrHPAPCE6HPy86BBAKCLJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCKJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCOJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCNJAYAmJHY2BBAI2BGHmCKrHPAPCE6HPy86BBAKCVJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCcJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCMJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCSJAYAmJHm2BBAI2BEHICKrHYAYCE6HYy86BBAKCQJAmAYJHm2BBAICIrCEZHYAYCE6HYy86BBAKCfJAmAYJHm2BBAICGrCEZHYAYCE6HYy86BBAKCbJAmAYJHK2BBAICEZHIAICE6HIy86BBAKAIJRISGMAKAI2BNAI2BBHmCIrHYAYCb6HYy86BBAKCFJAICNJAYJHY2BBAmCbZHmAmCb6Hmy86BBAKCGJAYAmJHm2BBAI2BFHYCIrHPAPCb6HPy86BBAKCEJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCIJAmAYJHm2BBAI2BGHYCIrHPAPCb6HPy86BBAKCLJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCKJAmAYJHm2BBAI2BEHYCIrHPAPCb6HPy86BBAKCOJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCNJAmAYJHm2BBAI2BIHYCIrHPAPCb6HPy86BBAKCVJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCcJAmAYJHm2BBAI2BLHYCIrHPAPCb6HPy86BBAKCMJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCSJAmAYJHm2BBAI2BKHYCIrHPAPCb6HPy86BBAKCQJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCfJAmAYJHm2BBAI2BOHICIrHYAYCb6HYy86BBAKCbJAmAYJHK2BBAICbZHIAICb6HIy86BBAKAIJRISFMAKAI8pBB83BBAKCNJAICNJ8pBB83BBAICTJRIMAtCGJRtAECTJHEAS9JQBMMGXAIQBCBRISEMGXAM9FQBANAbJ2BBRtCBRKAfREEXAEANCU/CBJAKJ2BBHTCFrCBATCFZl9zAtJHt86BBAEAGJREAKCFJHKAM9HQBMMAfCFJRfAIRTAbCFJHbAG9HQBMMABAcAG9sJANCUGJAMAG9sTkUUUBpANANCUGJAMCaJAG9sJAGTkUUUBpMAMCBAIyAcJRcAIQBMC9+RKSFMCBC99AOAIlAGCAAGCA9Ly6yRKMALCU/EBJ8kUUUUBAKM+OmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUFT+JUUUBpALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM+lLKFaF99GaG99FaG99GXGXAGCI9HQBAF9FQFEXGXGX9DBBB8/9DBBB+/ABCGJHG1BB+yAB1BBHE+yHI+L+TABCFJHL1BBHK+yHO+L+THN9DBBBB9gHVyAN9DBB/+hANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE86BBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG86BBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG86BBABCIJRBAFCaJHFQBSGMMAF9FQBEXGXGX9DBBB8/9DBBB+/ABCIJHG8uFB+yAB8uFBHE+yHI+L+TABCGJHL8uFBHK+yHO+L+THN9DBBBB9gHVyAN9DB/+g6ANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE87FBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG87FBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG87FBABCNJRBAFCaJHFQBMMM/SEIEaE99EaF99GXAF9FQBCBREABRIEXGXGX9D/zI818/AICKJ8uFBHLCEq+y+VHKAI8uFB+y+UHO9DB/+g6+U9DBBB8/9DBBB+/AO9DBBBB9gy+SHN+L9DBBB9P9d9FQBAN+oRVSFMCUUUU94RVMAICIJ8uFBRcAICGJ8uFBRMABALCFJCEZAEqCFWJAV87FBGXGXAKAM+y+UHN9DB/+g6+U9DBBB8/9DBBB+/AN9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRMSFMCUUUU94RMMABALCGJCEZAEqCFWJAM87FBGXGXAKAc+y+UHK9DB/+g6+U9DBBB8/9DBBB+/AK9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRcSFMCUUUU94RcMABALCaJCEZAEqCFWJAc87FBGXGX9DBBU8/AOAO+U+TANAN+U+TAKAK+U+THO9DBBBBAO9DBBBB9gy+R9DB/+g6+U9DBBB8/+SHO+L9DBBB9P9d9FQBAO+oRcSFMCUUUU94RcMABALCEZAEqCFWJAc87FBAICNJRIAECIJREAFCaJHFQBMMM9JBGXAGCGrAF9sHF9FQBEXABAB8oGBHGCNWCN91+yAGCi91CnWCUUU/8EJ+++U84GBABCIJRBAFCaJHFQBMMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEM/lFFFaGXGXAFABqCEZ9FQBABRESFMGXGXAGCT9PQBABRESFMABREEXAEAF8oGBjGBAECIJAFCIJ8oGBjGBAECNJAFCNJ8oGBjGBAECSJAFCSJ8oGBjGBAECTJREAFCTJRFAGC9wJHGCb9LQBMMAGCI9JQBEXAEAF8oGBjGBAFCIJRFAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF2BB86BBAECFJREAFCFJRFAGCaJHGQBMMABMoFFGaGXGXABCEZ9FQBABRESFMAFCgFZC+BwsN9sRIGXGXAGCT9PQBABRESFMABREEXAEAIjGBAECSJAIjGBAECNJAIjGBAECIJAIjGBAECTJREAGC9wJHGCb9LQBMMAGCI9JQBEXAEAIjGBAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF86BBAECFJREAGCaJHGQBMMABMMMFBCUNMIT9kBB",hfe="B9h9z9tFBBBF8dL9gBB9gLaaaaaFa9gEaaaB9gGaaB9gFaFaEQSBBFBFFGEGEGIILF9wFFFLEFBFKNFaFCx/aFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBG8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBIy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBKi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBNn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBcI9z9iqlBMc/j9JSIBTEM9+FLa8jUUUUBCTlRBCBRFEXCBRGCBREEXABCNJAGJAECUaAFAGrCFZHIy86BBAEAIJREAGCFJHGCN9HQBMAFCx+YUUBJAE86BBAFCEWCxkUUBJAB8pEN83EBAFCFJHFCUG9HQBMMkRIbaG97FaK978jUUUUBCU/KBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAG/8cBBCUoBAG9uC/wgBZHKCUGAKCUG9JyRNAECFJRKCBRVGXEXAVAF9PQFANAFAVlAVANJAF9JyRcGXGXAG9FQBAcCbJHIC9wZHMCE9sRSAMCFWRQAICIrCEJCGrRfCBRbEXAKRTCBRtGXEXGXAOATlAf9PQBCBRKSLMALCU/CBJAtAM9sJRmATAfJRKCBREGXAMCoB9JQBAOAKlC/gB9JQBCBRIEXAmAIJREGXGXGXGXGXATAICKrJ2BBHYCEZfIBFGEBMAECBDtDMIBSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMIBAKCTJRKMGXGXGXGXGXAYCGrCEZfIBFGEBMAECBDtDMITSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMITAKCTJRKMGXGXGXGXGXAYCIrCEZfIBFGEBMAECBDtDMIASEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMIAAKCTJRKMGXGXGXGXGXAYCKrfIBFGEBMAECBDtDMI8wSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCIJAnDeBJAYCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCNJAnDeBJAYCx+YUUBJ2BBJRKSFMAEAKDBBBDMI8wAKCTJRKMAICoBJREAICUFJAM9LQFAERIAOAKlC/fB9LQBMMGXAEAM9PQBAECErRIEXGXAOAKlCi9PQBCBRKSOMAmAEJRYGXGXGXGXGXATAECKrJ2BBAICKZrCEZfIBFGEBMAYCBDtDMIBSEMAYAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAYAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAYAKDBBBDMIBAKCTJRKMAICGJRIAECTJHEAM9JQBMMGXAK9FQBAKRTAtCFJHtCI6QGSFMMCBRKSEMGXAM9FQBALCUGJAbJREALAbJDBGBRnCBRYEXAEALCU/CBJAYJHIDBIBHdCFD9tAdCFDbHPD9OD9hD9RHdAIAMJDBIBHiCFD9tAiAPD9OD9hD9RHiDQBTFtGmEYIPLdKeOnH8ZAIAQJDBIBHpCFD9tApAPD9OD9hD9RHpAIASJDBIBHyCFD9tAyAPD9OD9hD9RHyDQBTFtGmEYIPLdKeOnH8cDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGEAnD9uHnDyBjGBAEAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnA8ZA8cDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnAdAiDQNiV8ZcpMyS8cQ8df8eb8fHdApAyDQNiV8ZcpMyS8cQ8df8eb8fHiDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnAdAiDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJREAYCTJHYAM9JQBMMAbCIJHbAG9JQBMMABAVAG9sJALCUGJAcAG9s/8cBBALALCUGJAcCaJAG9sJAG/8cBBMAcCBAKyAVJRVAKQBMC9+RKSFMCBC99AOAKlAGCAAGCA9Ly6yRKMALCU/KBJ8kUUUUBAKMNBT+BUUUBM+KmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUF/8MBALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM/xLGEaK978jUUUUBCAlHE8kUUUUBGXGXAGCI9HQBGXAFC98ZHI9FQBABRGCBRLEXAGAGDBBBHKCiD+rFCiD+sFD/6FHOAKCND+rFCiD+sFD/6FAOD/gFAKCTD+rFCiD+sFD/6FHND/gFD/kFD/lFHVCBDtD+2FHcAOCUUUU94DtHMD9OD9RD/kFHO9DBB/+hDYAOAOD/mFAVAVD/mFANAcANAMD9OD9RD/kFHOAOD/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHcD/kFCgFDtD9OAKCUUU94DtD9OD9QAOAND/mFAcD/kFCND+rFCU/+EDtD9OD9QAVAND/mFAcD/kFCTD+rFCUU/8ODtD9OD9QDMBBAGCTJRGALCIJHLAI9JQBMMAIAF9PQFAEAFCEZHLCGWHGqCBCTAGl/8MBAEABAICGWJHIAG/8cBBGXAL9FQBAEAEDBIBHKCiD+rFCiD+sFD/6FHOAKCND+rFCiD+sFD/6FAOD/gFAKCTD+rFCiD+sFD/6FHND/gFD/kFD/lFHVCBDtD+2FHcAOCUUUU94DtHMD9OD9RD/kFHO9DBB/+hDYAOAOD/mFAVAVD/mFANAcANAMD9OD9RD/kFHOAOD/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHcD/kFCgFDtD9OAKCUUU94DtD9OD9QAOAND/mFAcD/kFCND+rFCU/+EDtD9OD9QAVAND/mFAcD/kFCTD+rFCUU/8ODtD9OD9QDMIBMAIAEAG/8cBBSFMABAFC98ZHGT+HUUUBAGAF9PQBAEAFCEZHICEWHLJCBCAALl/8MBAEABAGCEWJHGAL/8cBBAEAIT+HUUUBAGAEAL/8cBBMAECAJ8kUUUUBM+yEGGaO97GXAF9FQBCBRGEXABCTJHEAEDBBBHICBDtHLCUU98D8cFCUU98D8cEHKD9OABDBBBHOAIDQILKOSQfbPden8c8d8e8fCggFDtD9OD/6FAOAIDQBFGENVcMTtmYi8ZpyHICTD+sFD/6FHND/gFAICTD+rFCTD+sFD/6FHVD/gFD/kFD/lFHI9DB/+g6DYAVAIALD+2FHLAVCUUUU94DtHcD9OD9RD/kFHVAVD/mFAIAID/mFANALANAcD9OD9RD/kFHIAID/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHLD/kFCTD+rFAVAND/mFALD/kFCggEDtD9OD9QHVAIAND/mFALD/kFCaDbCBDnGCBDnECBDnKCBDnOCBDncCBDnMCBDnfCBDnbD9OHIDQNVi8ZcMpySQ8c8dfb8e8fD9QDMBBABAOAKD9OAVAIDQBFTtGEmYILPdKOenD9QDMBBABCAJRBAGCIJHGAF9JQBMMM94FEa8jUUUUBCAlHE8kUUUUBABAFC98ZHIT+JUUUBGXAIAF9PQBAEAFCEZHLCEWHFJCBCAAFl/8MBAEABAICEWJHBAF/8cBBAEALT+JUUUBABAEAF/8cBBMAECAJ8kUUUUBM/hEIGaF97FaL978jUUUUBCTlRGGXAF9FQBCBREEXAGABDBBBHIABCTJHLDBBBHKDQILKOSQfbPden8c8d8e8fHOCTD+sFHNCID+rFDMIBAB9DBBU8/DY9D/zI818/DYANCEDtD9QD/6FD/nFHNAIAKDQBFGENVcMTtmYi8ZpyHICTD+rFCTD+sFD/6FD/mFHKAKD/mFANAICTD+sFD/6FD/mFHVAVD/mFANAOCTD+rFCTD+sFD/6FD/mFHOAOD/mFD/kFD/kFD/lFCBDtD+4FD/jF9DB/+g6DYHND/mF9DBBX9LDYHID/kFCggEDtHcD9OAVAND/mFAID/kFCTD+rFD9QHVAOAND/mFAID/kFCTD+rFAKAND/mFAID/kFAcD9OD9QHNDQBFTtGEmYILPdKOenHID8dBAGDBIBDyB+t+J83EBABCNJAID8dFAGDBIBDyF+t+J83EBALAVANDQNVi8ZcMpySQ8c8dfb8e8fHND8dBAGDBIBDyG+t+J83EBABCiJAND8dFAGDBIBDyE+t+J83EBABCAJRBAECIJHEAF9JQBMMM/3FGEaF978jUUUUBCoBlREGXAGCGrAF9sHIC98ZHL9FQBCBRGABRFEXAFAFDBBBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMBBAFCTJRFAGCIJHGAL9JQBMMGXALAI9PQBAEAICEZHGCGWHFqCBCoBAFl/8MBAEABALCGWJHLAF/8cBBGXAG9FQBAEAEDBIBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMIBMALAEAF/8cBBMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEMMMFBCUNMIT9tBB",pfe=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),mfe=new Uint8Array([32,0,65,253,3,1,2,34,4,106,6,5,11,8,7,20,13,33,12,16,128,9,116,64,19,113,127,15,10,21,22,14,255,66,24,54,136,107,18,23,192,26,114,118,132,17,77,101,130,144,27,87,131,44,45,74,156,154,70,167]),gfe={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},_fe={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};async function Y4(t,e,r,o,n,i="NONE"){let s=await yfe();Afe(s,s.exports[_fe[n]],t,e,r,o,s.exports[gfe[i||"NONE"]])}var KC;async function yfe(){return KC||(KC=xfe()),KC}async function xfe(){let t=dfe;WebAssembly.validate(pfe)&&(t=hfe,console.log("Warning: meshopt_decoder is using experimental SIMD support"));let e=await WebAssembly.instantiate(bfe(t),{});return await e.instance.exports.__wasm_call_ctors(),e.instance}function bfe(t){let e=new Uint8Array(t.length);for(let o=0;o<t.length;++o){let n=t.charCodeAt(o);e[o]=n>96?n-71:n>64?n-65:n>47?n+4:n>46?63:62}let r=0;for(let o=0;o<t.length;++o)e[r++]=e[o]<60?mfe[e[o]]:(e[o]-60)*64+e[++o];return e.buffer.slice(0,r)}function Afe(t,e,r,o,n,i,s){let a=t.exports.sbrk,c=o+3&-4,l=a(c*n),f=a(i.length),u=new Uint8Array(t.exports.memory.buffer);u.set(i,f);let d=e(l,o,n,f,i.length);if(d===0&&s&&s(l,c,n),r.set(u.subarray(l,l+o*n)),a(l-a(0)),d!==0)throw new Error(`Malformed buffer data: ${d}`)}var Cy="EXT_meshopt_compression",Tfe=Cy;async function vfe(t,e){let r=new ye(t);if(!e?.gltf?.decompressMeshes||!e.gltf?.loadBuffers)return;let o=[];for(let n of t.json.bufferViews||[])o.push(Sfe(r,n));await Promise.all(o),r.removeExtension(Cy)}async function Sfe(t,e){let r=t.getObjectExtension(e,Cy);if(r){let{byteOffset:o=0,byteLength:n=0,byteStride:i,count:s,mode:a,filter:c="NONE",buffer:l}=r,f=t.gltf.buffers[l],u=new Uint8Array(f.arrayBuffer,f.byteOffset+o,n),d=new Uint8Array(t.gltf.buffers[e.buffer].arrayBuffer,e.byteOffset,e.byteLength);await Y4(d,s,i,u,a,c),t.removeObjectExtension(e,Cy)}}var ZC={};ze(ZC,{name:()=>Cfe,preprocess:()=>Efe});var rl="EXT_texture_webp",Cfe=rl;function Efe(t,e){let r=new ye(t);if(!uA("image/webp")){if(r.getRequiredExtensions().includes(rl))throw new Error(`gltf: Required extension ${rl} not supported by browser`);return}let{json:o}=r;for(let n of o.textures||[]){let i=r.getObjectExtension(n,rl);i&&(n.source=i.source),r.removeObjectExtension(n,rl)}r.removeExtension(rl)}var JC={};ze(JC,{name:()=>wfe,preprocess:()=>Pfe});var Ey="KHR_texture_basisu",wfe=Ey;function Pfe(t,e){let r=new ye(t),{json:o}=r;for(let n of o.textures||[]){let i=r.getObjectExtension(n,Ey);i&&(n.source=i.source,r.removeObjectExtension(n,Ey))}r.removeExtension(Ey)}var rE={};ze(rE,{decode:()=>Wfe,encode:()=>Gfe,name:()=>Hfe,preprocess:()=>jfe});var Mfe="1.5.6",Rfe="1.4.1",QC=`https://www.gstatic.com/draco/versioned/decoders/${Mfe}`,gt={DECODER:"draco_wasm_wrapper.js",DECODER_WASM:"draco_decoder.wasm",FALLBACK_DECODER:"draco_decoder.js",ENCODER:"draco_encoder.js"},fh={[gt.DECODER]:`${QC}/${gt.DECODER}`,[gt.DECODER_WASM]:`${QC}/${gt.DECODER_WASM}`,[gt.FALLBACK_DECODER]:`${QC}/${gt.FALLBACK_DECODER}`,[gt.ENCODER]:`https://raw.githubusercontent.com/google/draco/${Rfe}/javascript/${gt.ENCODER}`},eE;async function q4(t={},e){let r=t.modules||{};return r.draco3d?eE||=r.draco3d.createDecoderModule({}).then(o=>({draco:o})):eE||=Ife(t,e),await eE}function K4(t,e){if(t&&typeof t=="object"){if(t.default)return t.default;if(t[e])return t[e]}return t}async function Ife(t,e){let r,o;switch(e){case"js":r=await br(fh[gt.FALLBACK_DECODER],"draco",t,gt.FALLBACK_DECODER);break;case"wasm":default:try{[r,o]=await Promise.all([await br(fh[gt.DECODER],"draco",t,gt.DECODER),await br(fh[gt.DECODER_WASM],"draco",t,gt.DECODER_WASM)])}catch{r=null,o=null}}return r=K4(r,"DracoDecoderModule"),r=r||globalThis.DracoDecoderModule,!r&&!tt&&([r,o]=await Promise.all([await br(fh[gt.DECODER],"draco",{...t,useLocalLibraries:!0},gt.DECODER),await br(fh[gt.DECODER_WASM],"draco",{...t,useLocalLibraries:!0},gt.DECODER_WASM)]),r=K4(r,"DracoDecoderModule"),r=r||globalThis.DracoDecoderModule),await Lfe(r,o)}function Lfe(t,e){if(typeof t!="function")throw new Error("DracoDecoderModule could not be loaded");let r={};return e&&(r.wasmBinary=e),new Promise(o=>{t({...r,onModuleLoaded:n=>o({draco:n})})})}var Z4="4.4.3";function Q4(t,e,r){let o=ek(e.metadata),n=[],i=Bfe(e.attributes);for(let s in t){let a=t[s],c=J4(s,a,i[s]);n.push(c)}if(r){let s=J4("indices",r);n.push(s)}return{fields:n,metadata:o}}function Bfe(t){let e={};for(let r in t){let o=t[r];e[o.name||"undefined"]=o}return e}function J4(t,e,r){let o=r?ek(r.metadata):void 0;return iA(t,e,o)}function ek(t){Object.entries(t);let e={};for(let r in t)e[`${r}.string`]=JSON.stringify(t[r]);return e}var tk={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},Ofe={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array},Ffe=4,uh=class{draco;decoder;metadataQuerier;constructor(e){this.draco=e,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(e,r={}){let o=new this.draco.DecoderBuffer;o.Init(new Int8Array(e),e.byteLength),this._disableAttributeTransforms(r);let n=this.decoder.GetEncodedGeometryType(o),i=n===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let s;switch(n){case this.draco.TRIANGULAR_MESH:s=this.decoder.DecodeBufferToMesh(o,i);break;case this.draco.POINT_CLOUD:s=this.decoder.DecodeBufferToPointCloud(o,i);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!s.ok()||!i.ptr){let d=`DRACO decompression failed: ${s.error_msg()}`;throw new Error(d)}let a=this._getDracoLoaderData(i,n,r),c=this._getMeshData(i,a,r),l=Ki(c.attributes),f=Q4(c.attributes,a,c.indices);return{loader:"draco",loaderData:a,header:{vertexCount:i.num_points(),boundingBox:l},...c,schema:f}}finally{this.draco.destroy(o),i&&this.draco.destroy(i)}}_getDracoLoaderData(e,r,o){let n=this._getTopLevelMetadata(e),i=this._getDracoAttributes(e,o);return{geometry_type:r,num_attributes:e.num_attributes(),num_points:e.num_points(),num_faces:e instanceof this.draco.Mesh?e.num_faces():0,metadata:n,attributes:i}}_getDracoAttributes(e,r){let o={};for(let n=0;n<e.num_attributes();n++){let i=this.decoder.GetAttribute(e,n),s=this._getAttributeMetadata(e,n);o[i.unique_id()]={unique_id:i.unique_id(),attribute_type:i.attribute_type(),data_type:i.data_type(),num_components:i.num_components(),byte_offset:i.byte_offset(),byte_stride:i.byte_stride(),normalized:i.normalized(),attribute_index:n,metadata:s};let a=this._getQuantizationTransform(i,r);a&&(o[i.unique_id()].quantization_transform=a);let c=this._getOctahedronTransform(i,r);c&&(o[i.unique_id()].octahedron_transform=c)}return o}_getMeshData(e,r,o){let n=this._getMeshAttributes(r,e,o);if(!n.POSITION)throw new Error("DRACO: No position attribute found.");if(e instanceof this.draco.Mesh)switch(o.topology){case"triangle-strip":return{topology:"triangle-strip",mode:4,attributes:n,indices:{value:this._getTriangleStripIndices(e),size:1}};case"triangle-list":default:return{topology:"triangle-list",mode:5,attributes:n,indices:{value:this._getTriangleListIndices(e),size:1}}}return{topology:"point-list",mode:0,attributes:n}}_getMeshAttributes(e,r,o){let n={};for(let i of Object.values(e.attributes)){let s=this._deduceAttributeName(i,o);i.name=s;let a=this._getAttributeValues(r,i);if(a){let{value:c,size:l}=a;n[s]={value:c,size:l,byteOffset:i.byte_offset,byteStride:i.byte_stride,normalized:i.normalized}}}return n}_getTriangleListIndices(e){let o=e.num_faces()*3,n=o*Ffe,i=this.draco._malloc(n);try{return this.decoder.GetTrianglesUInt32Array(e,n,i),new Uint32Array(this.draco.HEAPF32.buffer,i,o).slice()}finally{this.draco._free(i)}}_getTriangleStripIndices(e){let r=new this.draco.DracoInt32Array;try{return this.decoder.GetTriangleStripsFromMesh(e,r),Ufe(r)}finally{this.draco.destroy(r)}}_getAttributeValues(e,r){let o=Ofe[r.data_type];if(!o)return console.warn(`DRACO: Unsupported attribute type ${r.data_type}`),null;let n=r.num_components,s=e.num_points()*n,a=s*o.BYTES_PER_ELEMENT,c=Nfe(this.draco,o),l,f=this.draco._malloc(a);try{let u=this.decoder.GetAttribute(e,r.attribute_index);this.decoder.GetAttributeDataArrayForAllPoints(e,u,c,a,f),l=new o(this.draco.HEAPF32.buffer,f,s).slice()}finally{this.draco._free(f)}return{value:l,size:n}}_deduceAttributeName(e,r){let o=e.unique_id;for(let[s,a]of Object.entries(r.extraAttributes||{}))if(a===o)return s;let n=e.attribute_type;for(let s in tk)if(this.draco[s]===n)return tk[s];let i=r.attributeNameEntry||"name";return e.metadata[i]?e.metadata[i].string:`CUSTOM_ATTRIBUTE_${o}`}_getTopLevelMetadata(e){let r=this.decoder.GetMetadata(e);return this._getDracoMetadata(r)}_getAttributeMetadata(e,r){let o=this.decoder.GetAttributeMetadata(e,r);return this._getDracoMetadata(o)}_getDracoMetadata(e){if(!e||!e.ptr)return{};let r={},o=this.metadataQuerier.NumEntries(e);for(let n=0;n<o;n++){let i=this.metadataQuerier.GetEntryName(e,n);r[i]=this._getDracoMetadataField(e,i)}return r}_getDracoMetadataField(e,r){let o=new this.draco.DracoInt32Array;try{this.metadataQuerier.GetIntEntryArray(e,r,o);let n=Dfe(o);return{int:this.metadataQuerier.GetIntEntry(e,r),string:this.metadataQuerier.GetStringEntry(e,r),double:this.metadataQuerier.GetDoubleEntry(e,r),intArray:n}}finally{this.draco.destroy(o)}}_disableAttributeTransforms(e){let{quantizedAttributes:r=[],octahedronAttributes:o=[]}=e,n=[...r,...o];for(let i of n)this.decoder.SkipAttributeTransform(this.draco[i])}_getQuantizationTransform(e,r){let{quantizedAttributes:o=[]}=r,n=e.attribute_type();if(o.map(s=>this.decoder[s]).includes(n)){let s=new this.draco.AttributeQuantizationTransform;try{if(s.InitFromAttribute(e))return{quantization_bits:s.quantization_bits(),range:s.range(),min_values:new Float32Array([1,2,3]).map(a=>s.min_value(a))}}finally{this.draco.destroy(s)}}return null}_getOctahedronTransform(e,r){let{octahedronAttributes:o=[]}=r,n=e.attribute_type();if(o.map(s=>this.decoder[s]).includes(n)){let s=new this.draco.AttributeQuantizationTransform;try{if(s.InitFromAttribute(e))return{quantization_bits:s.quantization_bits()}}finally{this.draco.destroy(s)}}return null}};function Nfe(t,e){switch(e){case Float32Array:return t.DT_FLOAT32;case Int8Array:return t.DT_INT8;case Int16Array:return t.DT_INT16;case Int32Array:return t.DT_INT32;case Uint8Array:return t.DT_UINT8;case Uint16Array:return t.DT_UINT16;case Uint32Array:return t.DT_UINT32;default:return t.DT_INVALID}}function Dfe(t){let e=t.size(),r=new Int32Array(e);for(let o=0;o<e;o++)r[o]=t.GetValue(o);return r}function Ufe(t){let e=t.size(),r=new Int32Array(e);for(let o=0;o<e;o++)r[o]=t.GetValue(o);return r}var rk={dataType:null,batchType:null,name:"Draco",id:"draco",module:"draco",version:Z4,worker:!0,extensions:["drc"],mimeTypes:["application/octet-stream"],binary:!0,tests:["DRACO"],options:{draco:{decoderType:typeof WebAssembly=="object"?"wasm":"js",extraAttributes:{},attributeNameEntry:void 0}}},dh={...rk,parse:kfe};async function kfe(t,e){let{draco:r}=await q4(Kl(e),e?.draco?.decoderType||"wasm"),o=new uh(r);try{return o.parseSync(t,e?.draco)}finally{o.destroy()}}function ok(t){let e={};for(let r in t){let o=t[r];if(r!=="indices"){let n=tE(o);e[r]=n}}return e}function tE(t){let{buffer:e,size:r,count:o}=Vfe(t);return{value:e,size:r,byteOffset:0,count:o,type:_y(r),componentType:Ri(e)}}function Vfe(t){let e=t,r=1,o=0;return t&&t.value&&(e=t.value,r=t.size||1),e&&(ArrayBuffer.isView(e)||(e=zfe(e,Float32Array)),o=e.length/r),{buffer:e,size:r,count:o}}function zfe(t,e,r=!1){return t?Array.isArray(t)?new e(t):r&&!(t instanceof e)?new e(t):t:null}var Ii="KHR_draco_mesh_compression",Hfe=Ii;function jfe(t,e,r){let o=new ye(t);for(let n of nk(o))o.getObjectExtension(n,Ii)}async function Wfe(t,e,r){if(!e?.gltf?.decompressMeshes)return;let o=new ye(t),n=[];for(let i of nk(o))o.getObjectExtension(i,Ii)&&n.push($fe(o,i,e,r));await Promise.all(n),o.removeExtension(Ii)}function Gfe(t,e={}){let r=new ye(t);for(let o of r.json.meshes||[])Xfe(o,e),r.addRequiredExtension(Ii)}async function $fe(t,e,r,o){let n=t.getObjectExtension(e,Ii);if(!n)return;let i=t.getTypedArrayForBufferView(n.bufferView),s=Gi(i.buffer,i.byteOffset),a={...r};delete a["3d-tiles"];let c=await nr(s,dh,a,o),l=ok(c.attributes);for(let[f,u]of Object.entries(l))if(f in e.attributes){let d=e.attributes[f],h=t.getAccessor(d);h?.min&&h?.max&&(u.min=h.min,u.max=h.max)}e.attributes=l,c.indices&&(e.indices=tE(c.indices)),t.removeObjectExtension(e,Ii),Yfe(e)}function Xfe(t,e,r=4,o,n){if(!o.DracoWriter)throw new Error("options.gltf.DracoWriter not provided");let i=o.DracoWriter.encodeSync({attributes:t}),s=n?.parseSync?.({attributes:t}),a=o._addFauxAttributes(s.attributes),c=o.addBufferView(i);return{primitives:[{attributes:a,mode:r,extensions:{[Ii]:{bufferView:c,attributes:a}}}]}}function Yfe(t){if(!t.attributes&&Object.keys(t.attributes).length>0)throw new Error("glTF: Empty primitive detected: Draco decompression failure?")}function*nk(t){for(let e of t.json.meshes||[])for(let r of e.primitives)yield r}var oE={};ze(oE,{decode:()=>Jfe,name:()=>Kfe});var Py="KHR_texture_transform",Kfe=Py,wy=new E,qfe=new ue,Zfe=new ue;async function Jfe(t,e){if(!new ye(t).hasExtension(Py)||!e.gltf?.loadBuffers)return;let n=t.json.materials||[];for(let i=0;i<n.length;i++)Qfe(i,t)}function Qfe(t,e){let r=e.json.materials?.[t],o=[r?.pbrMetallicRoughness?.baseColorTexture,r?.emissiveTexture,r?.normalTexture,r?.occlusionTexture,r?.pbrMetallicRoughness?.metallicRoughnessTexture],n=[];for(let i of o)i&&i?.extensions?.[Py]&&eue(e,t,i,n)}function eue(t,e,r,o){let n=tue(r,o);if(!n)return;let i=t.json.meshes||[];for(let s of i)for(let a of s.primitives){let c=a.material;Number.isFinite(c)&&e===c&&rue(t,a,n)}}function tue(t,e){let r=t.extensions?.[Py],{texCoord:o=0}=t,{texCoord:n=o}=r;if(!(e.findIndex(([s,a])=>s===o&&a===n)!==-1)){let s=iue(r);return o!==n&&(t.texCoord=n),e.push([o,n]),{originalTexCoord:o,texCoord:n,matrix:s}}return null}function rue(t,e,r){let{originalTexCoord:o,texCoord:n,matrix:i}=r,s=e.attributes[`TEXCOORD_${o}`];if(Number.isFinite(s)){let a=t.json.accessors?.[s];if(a&&a.bufferView!==void 0){let c=t.json.bufferViews?.[a.bufferView];if(c){let{arrayBuffer:l,byteOffset:f}=t.buffers[c.buffer],u=(f||0)+(a.byteOffset||0)+(c.byteOffset||0),{ArrayType:d,length:h}=Yc(a,c),p=gy[a.componentType],m=my[a.type],g=c.byteStride||p*m,_=new Float32Array(h);for(let x=0;x<a.count;x++){let y=new d(l,u+x*g,2);wy.set(y[0],y[1],1),wy.transformByMatrix3(i),_.set([wy[0],wy[1]],x*m)}o===n?oue(a,t,_,a.bufferView):nue(n,a,e,t,_)}}}}function oue(t,e,r,o){t.componentType=5126,t.byteOffset=0;let s=(e.json.accessors||[]).reduce((l,f)=>f.bufferView===o?l+1:l,0)>1;e.buffers.push({arrayBuffer:Ar(r.buffer),byteOffset:0,byteLength:r.buffer.byteLength});let a=e.buffers.length-1;if(e.json.bufferViews=e.json.bufferViews||[],s){e.json.bufferViews.push({buffer:a,byteLength:r.buffer.byteLength,byteOffset:0}),t.bufferView=e.json.bufferViews.length-1;return}let c=e.json.bufferViews[o];c&&(c.buffer=a,c.byteOffset=0,c.byteLength=r.buffer.byteLength,c.byteStride!==void 0&&delete c.byteStride)}function nue(t,e,r,o,n){o.buffers.push({arrayBuffer:Ar(n.buffer),byteOffset:0,byteLength:n.buffer.byteLength}),o.json.bufferViews=o.json.bufferViews||[];let i=o.json.bufferViews;i.push({buffer:o.buffers.length-1,byteLength:n.buffer.byteLength,byteOffset:0});let s=o.json.accessors;s&&(s.push({bufferView:i?.length-1,byteOffset:0,componentType:5126,count:e.count,type:"VEC2"}),r.attributes[`TEXCOORD_${t}`]=s.length-1)}function iue(t){let{offset:e=[0,0],rotation:r=0,scale:o=[1,1]}=t,n=new ue().set(1,0,0,0,1,0,e[0],e[1],1),i=qfe.set(Math.cos(r),Math.sin(r),0,-Math.sin(r),Math.cos(r),0,0,0,1),s=Zfe.set(o[0],0,0,0,o[1],0,0,0,1);return n.multiplyRight(i).multiplyRight(s)}var nE={};ze(nE,{decode:()=>aue,encode:()=>cue,name:()=>sue});var $s="KHR_lights_punctual",sue=$s;async function aue(t){let e=new ye(t),{json:r}=e,o=e.getExtension($s);o&&(e.json.lights=o.lights,e.removeExtension($s));for(let n of r.nodes||[]){let i=e.getObjectExtension(n,$s);i&&(n.light=i.light),e.removeObjectExtension(n,$s)}}async function cue(t){let e=new ye(t),{json:r}=e;if(r.lights){let o=e.addExtension($s);ut(!o.lights),o.lights=r.lights,delete r.lights}if(e.json.lights){for(let o of e.json.lights){let n=o.node;e.addObjectExtension(n,$s,o)}delete e.json.lights}}var iE={};ze(iE,{decode:()=>fue,encode:()=>uue,name:()=>lue});var hh="KHR_materials_unlit",lue=hh;async function fue(t){let e=new ye(t),{json:r}=e;for(let o of r.materials||[])o.extensions&&o.extensions.KHR_materials_unlit&&(o.unlit=!0),e.removeObjectExtension(o,hh);e.removeExtension(hh)}function uue(t){let e=new ye(t),{json:r}=e;if(e.materials)for(let o of r.materials||[])o.unlit&&(delete o.unlit,e.addObjectExtension(o,hh,{}),e.addExtension(hh))}var sE={};ze(sE,{decode:()=>hue,encode:()=>pue,name:()=>due});var ph="KHR_techniques_webgl",due=ph;async function hue(t){let e=new ye(t),{json:r}=e,o=e.getExtension(ph);if(o){let n=mue(o,e);for(let i of r.materials||[]){let s=e.getObjectExtension(i,ph);s&&(i.technique=Object.assign({},s,n[s.technique]),i.technique.values=gue(i.technique,e)),e.removeObjectExtension(i,ph)}e.removeExtension(ph)}}async function pue(t,e){}function mue(t,e){let{programs:r=[],shaders:o=[],techniques:n=[]}=t,i=new TextDecoder;return o.forEach(s=>{if(Number.isFinite(s.bufferView))s.code=i.decode(e.getTypedArrayForBufferView(s.bufferView));else throw new Error("KHR_techniques_webgl: no shader code")}),r.forEach(s=>{s.fragmentShader=o[s.fragmentShader],s.vertexShader=o[s.vertexShader]}),n.forEach(s=>{s.program=r[s.program]}),n}function gue(t,e){let r=Object.assign({},t.values);return Object.keys(t.uniforms||{}).forEach(o=>{t.uniforms[o].value&&!(o in r)&&(r[o]=t.uniforms[o].value)}),Object.keys(r).forEach(o=>{typeof r[o]=="object"&&r[o].index!==void 0&&(r[o].texture=e.getTexture(r[o].index))}),r}var ik=[UC,FC,qC,ZC,JC,rE,nE,iE,sE,oE,kC];function sk(t,e={},r){let o=ik.filter(n=>ck(n.name,e));for(let n of o)n.preprocess?.(t,e,r)}async function ak(t,e={},r){let o=ik.filter(n=>ck(n.name,e));for(let n of o)await n.decode?.(t,e,r)}function ck(t,e){let r=e?.gltf?.excludeExtensions||{};return!(t in r&&!r[t])}var aE="KHR_binary_glTF";function lk(t){let e=new ye(t),{json:r}=e;for(let o of r.images||[]){let n=e.getObjectExtension(o,aE);n&&Object.assign(o,n),e.removeObjectExtension(o,aE)}r.buffers&&r.buffers[0]&&delete r.buffers[0].uri,e.removeExtension(aE)}var fk={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},yue={accessor:"accessors",animations:"animation",buffer:"buffers",bufferView:"bufferViews",image:"images",material:"materials",mesh:"meshes",node:"nodes",sampler:"samplers",scene:"scenes",skin:"skins",texture:"textures"},cE=class{idToIndexMap={animations:{},accessors:{},buffers:{},bufferViews:{},images:{},materials:{},meshes:{},nodes:{},samplers:{},scenes:{},skins:{},textures:{}};json;normalize(e,r){this.json=e.json;let o=e.json;switch(o.asset&&o.asset.version){case"2.0":return;case void 0:case"1.0":break;default:console.warn(`glTF: Unknown version ${o.asset.version}`);return}if(!r.normalize)throw new Error("glTF v1 is not supported.");console.warn("Converting glTF v1 to glTF v2 format. This is experimental and may fail."),this._addAsset(o),this._convertTopLevelObjectsToArrays(o),lk(e),this._convertObjectIdsToArrayIndices(o),this._updateObjects(o),this._updateMaterial(o)}_addAsset(e){e.asset=e.asset||{},e.asset.version="2.0",e.asset.generator=e.asset.generator||"Normalized to glTF 2.0 by loaders.gl"}_convertTopLevelObjectsToArrays(e){for(let r in fk)this._convertTopLevelObjectToArray(e,r)}_convertTopLevelObjectToArray(e,r){let o=e[r];if(!(!o||Array.isArray(o))){e[r]=[];for(let n in o){let i=o[n];i.id=i.id||n;let s=e[r].length;e[r].push(i),this.idToIndexMap[r][n]=s}}}_convertObjectIdsToArrayIndices(e){for(let r in fk)this._convertIdsToIndices(e,r);"scene"in e&&(e.scene=this._convertIdToIndex(e.scene,"scene"));for(let r of e.textures)this._convertTextureIds(r);for(let r of e.meshes)this._convertMeshIds(r);for(let r of e.nodes)this._convertNodeIds(r);for(let r of e.scenes)this._convertSceneIds(r)}_convertTextureIds(e){e.source&&(e.source=this._convertIdToIndex(e.source,"image"))}_convertMeshIds(e){for(let r of e.primitives){let{attributes:o,indices:n,material:i}=r;for(let s in o)o[s]=this._convertIdToIndex(o[s],"accessor");n&&(r.indices=this._convertIdToIndex(n,"accessor")),i&&(r.material=this._convertIdToIndex(i,"material"))}}_convertNodeIds(e){e.children&&(e.children=e.children.map(r=>this._convertIdToIndex(r,"node"))),e.meshes&&(e.meshes=e.meshes.map(r=>this._convertIdToIndex(r,"mesh")))}_convertSceneIds(e){e.nodes&&(e.nodes=e.nodes.map(r=>this._convertIdToIndex(r,"node")))}_convertIdsToIndices(e,r){e[r]||(console.warn(`gltf v1: json doesn't contain attribute ${r}`),e[r]=[]);for(let o of e[r])for(let n in o){let i=o[n],s=this._convertIdToIndex(i,n);o[n]=s}}_convertIdToIndex(e,r){let o=yue[r];if(o in this.idToIndexMap){let n=this.idToIndexMap[o][e];if(!Number.isFinite(n))throw new Error(`gltf v1: failed to resolve ${r} with id ${e}`);return n}return e}_updateObjects(e){for(let r of this.json.buffers)delete r.type}_updateMaterial(e){for(let r of e.materials){r.pbrMetallicRoughness={baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1};let o=r.values?.tex||r.values?.texture2d_0||r.values?.diffuseTex,n=e.textures.findIndex(i=>i.id===o);n!==-1&&(r.pbrMetallicRoughness.baseColorTexture={index:n})}}};function uk(t,e={}){return new cE().normalize(t,e)}async function dk(t,e,r=0,o,n){return xue(t,e,r,o),uk(t,{normalize:o?.gltf?.normalize}),sk(t,o,n),o?.gltf?.loadBuffers&&t.json.buffers&&await bue(t,o,n),o?.gltf?.loadImages&&await Aue(t,o,n),await ak(t,o,n),t}function xue(t,e,r,o){if(o.core?.baseUrl&&(t.baseUri=o.core?.baseUrl),e instanceof ArrayBuffer&&!$4(e,r,o.glb)&&(e=new TextDecoder().decode(e)),typeof e=="string")t.json=Vb(e);else if(e instanceof ArrayBuffer){let s={};r=X4(s,e,r,o.glb),ut(s.type==="glTF",`Invalid GLB magic string ${s.type}`),t._glb=s,t.json=s.json}else ut(!1,"GLTF: must be ArrayBuffer or string");let n=t.json.buffers||[];if(t.buffers=new Array(n.length).fill(null),t._glb&&t._glb.header.hasBinChunk){let{binChunks:s}=t._glb;t.buffers[0]={arrayBuffer:s[0].arrayBuffer,byteOffset:s[0].byteOffset,byteLength:s[0].byteLength}}let i=t.json.images||[];t.images=new Array(i.length).fill({})}async function bue(t,e,r){let o=t.json.buffers||[];for(let n=0;n<o.length;++n){let i=o[n];if(i.uri){let{fetch:s}=r;ut(s);let a=YC(i.uri,e,r),l=await(await r?.fetch?.(a))?.arrayBuffer?.();t.buffers[n]={arrayBuffer:l,byteOffset:0,byteLength:l.byteLength},delete i.uri}else t.buffers[n]===null&&(t.buffers[n]={arrayBuffer:new ArrayBuffer(i.byteLength),byteOffset:0,byteLength:i.byteLength})}}async function Aue(t,e,r){let o=Tue(t),n=t.json.images||[],i=[];for(let s of o)i.push(vue(t,n[s],s,e,r));return await Promise.all(i)}function Tue(t){let e=new Set,r=t.json.textures||[];for(let o of r)o.source!==void 0&&e.add(o.source);return Array.from(e).sort()}async function vue(t,e,r,o,n){let i;if(e.uri&&!e.hasOwnProperty("bufferView")){let l=YC(e.uri,o,n),{fetch:f}=n;i=await(await f(l)).arrayBuffer(),e.bufferView={data:i}}if(Number.isFinite(e.bufferView)){let l=E4(t.json,t.buffers,e.bufferView);i=Gi(l.buffer,l.byteOffset,l.byteLength)}ut(i,"glTF image has no data");let s=o,a={...s,core:{...s?.core,mimeType:e.mimeType}},c=await nr(i,[qn,WC],a,n);c&&c[0]&&(c={compressed:!0,mipmaps:!1,width:c[0].width,height:c[0].height,data:c[0]}),t.images=t.images||[],t.images[r]=c}var Pn={dataType:null,batchType:null,name:"glTF",id:"gltf",module:"gltf",version:L4,extensions:["gltf","glb"],mimeTypes:["model/gltf+json","model/gltf-binary"],text:!0,binary:!0,tests:["glTF"],parse:Sue,options:{gltf:{normalize:!0,loadBuffers:!0,loadImages:!0,decompressMeshes:!0}}};async function Sue(t,e={},r){let o={...Pn.options,...e};o.gltf={...Pn.options.gltf,...o.gltf};let n=e?.glb?.byteOffset||0;return await dk({},t,n,o,r)}var Cue={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Eue={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},Dr={TEXTURE_MAG_FILTER:10240,TEXTURE_MIN_FILTER:10241,TEXTURE_WRAP_S:10242,TEXTURE_WRAP_T:10243,REPEAT:10497,LINEAR:9729,NEAREST_MIPMAP_LINEAR:9986},wue={magFilter:Dr.TEXTURE_MAG_FILTER,minFilter:Dr.TEXTURE_MIN_FILTER,wrapS:Dr.TEXTURE_WRAP_S,wrapT:Dr.TEXTURE_WRAP_T},Pue={[Dr.TEXTURE_MAG_FILTER]:Dr.LINEAR,[Dr.TEXTURE_MIN_FILTER]:Dr.NEAREST_MIPMAP_LINEAR,[Dr.TEXTURE_WRAP_S]:Dr.REPEAT,[Dr.TEXTURE_WRAP_T]:Dr.REPEAT};function Mue(){return{id:"default-sampler",parameters:Pue}}function Rue(t){return Eue[t]}function Iue(t){return Cue[t]}var lE=class{baseUri="";jsonUnprocessed;json;buffers=[];images=[];postProcess(e,r={}){let{json:o,buffers:n=[],images:i=[]}=e,{baseUri:s=""}=e;return ut(o),this.baseUri=s,this.buffers=n,this.images=i,this.jsonUnprocessed=o,this.json=this._resolveTree(e.json,r),this.json}_resolveTree(e,r={}){let o={...e};return this.json=o,e.bufferViews&&(o.bufferViews=e.bufferViews.map((n,i)=>this._resolveBufferView(n,i))),e.images&&(o.images=e.images.map((n,i)=>this._resolveImage(n,i))),e.samplers&&(o.samplers=e.samplers.map((n,i)=>this._resolveSampler(n,i))),e.textures&&(o.textures=e.textures.map((n,i)=>this._resolveTexture(n,i))),e.accessors&&(o.accessors=e.accessors.map((n,i)=>this._resolveAccessor(n,i))),e.materials&&(o.materials=e.materials.map((n,i)=>this._resolveMaterial(n,i))),e.meshes&&(o.meshes=e.meshes.map((n,i)=>this._resolveMesh(n,i))),e.nodes&&(o.nodes=e.nodes.map((n,i)=>this._resolveNode(n,i)),o.nodes=o.nodes.map((n,i)=>this._resolveNodeChildren(n))),e.skins&&(o.skins=e.skins.map((n,i)=>this._resolveSkin(n,i))),e.scenes&&(o.scenes=e.scenes.map((n,i)=>this._resolveScene(n,i))),typeof this.json.scene=="number"&&o.scenes&&(o.scene=o.scenes[this.json.scene]),o}getScene(e){return this._get(this.json.scenes,e)}getNode(e){return this._get(this.json.nodes,e)}getSkin(e){return this._get(this.json.skins,e)}getMesh(e){return this._get(this.json.meshes,e)}getMaterial(e){return this._get(this.json.materials,e)}getAccessor(e){return this._get(this.json.accessors,e)}getCamera(e){return this._get(this.json.cameras,e)}getTexture(e){return this._get(this.json.textures,e)}getSampler(e){return this._get(this.json.samplers,e)}getImage(e){return this._get(this.json.images,e)}getBufferView(e){return this._get(this.json.bufferViews,e)}getBuffer(e){return this._get(this.json.buffers,e)}_get(e,r){if(typeof r=="object")return r;let o=e&&e[r];return o||console.warn(`glTF file error: Could not find ${e}[${r}]`),o}_resolveScene(e,r){return{...e,id:e.id||`scene-${r}`,nodes:(e.nodes||[]).map(o=>this.getNode(o))}}_resolveNode(e,r){let o={...e,id:e?.id||`node-${r}`};return e.mesh!==void 0&&(o.mesh=this.getMesh(e.mesh)),e.camera!==void 0&&(o.camera=this.getCamera(e.camera)),e.skin!==void 0&&(o.skin=this.getSkin(e.skin)),e.meshes!==void 0&&e.meshes.length&&(o.mesh=e.meshes.reduce((n,i)=>{let s=this.getMesh(i);return n.id=s.id,n.primitives=n.primitives.concat(s.primitives),n},{primitives:[]})),o}_resolveNodeChildren(e){return e.children&&(e.children=e.children.map(r=>this.getNode(r))),e}_resolveSkin(e,r){let o=typeof e.inverseBindMatrices=="number"?this.getAccessor(e.inverseBindMatrices):void 0;return{...e,id:e.id||`skin-${r}`,inverseBindMatrices:o}}_resolveMesh(e,r){let o={...e,id:e.id||`mesh-${r}`,primitives:[]};return e.primitives&&(o.primitives=e.primitives.map(n=>{let i={...n,attributes:{},indices:void 0,material:void 0},s=n.attributes;for(let a in s)i.attributes[a]=this.getAccessor(s[a]);return n.indices!==void 0&&(i.indices=this.getAccessor(n.indices)),n.material!==void 0&&(i.material=this.getMaterial(n.material)),i})),o}_resolveMaterial(e,r){let o={...e,id:e.id||`material-${r}`};if(o.normalTexture&&(o.normalTexture={...o.normalTexture},o.normalTexture.texture=this.getTexture(o.normalTexture.index)),o.occlusionTexture&&(o.occlusionTexture={...o.occlusionTexture},o.occlusionTexture.texture=this.getTexture(o.occlusionTexture.index)),o.emissiveTexture&&(o.emissiveTexture={...o.emissiveTexture},o.emissiveTexture.texture=this.getTexture(o.emissiveTexture.index)),o.emissiveFactor||(o.emissiveFactor=o.emissiveTexture?[1,1,1]:[0,0,0]),o.pbrMetallicRoughness){o.pbrMetallicRoughness={...o.pbrMetallicRoughness};let n=o.pbrMetallicRoughness;n.baseColorTexture&&(n.baseColorTexture={...n.baseColorTexture},n.baseColorTexture.texture=this.getTexture(n.baseColorTexture.index)),n.metallicRoughnessTexture&&(n.metallicRoughnessTexture={...n.metallicRoughnessTexture},n.metallicRoughnessTexture.texture=this.getTexture(n.metallicRoughnessTexture.index))}return o}_resolveAccessor(e,r){let o=Rue(e.componentType),n=Iue(e.type),i=o*n,s={...e,id:e.id||`accessor-${r}`,bytesPerComponent:o,components:n,bytesPerElement:i,value:void 0,bufferView:void 0,sparse:void 0};if(e.bufferView!==void 0&&(s.bufferView=this.getBufferView(e.bufferView)),s.bufferView){let a=s.bufferView.buffer,{ArrayType:c,byteLength:l}=Yc(s,s.bufferView),f=(s.bufferView.byteOffset||0)+(s.byteOffset||0)+a.byteOffset,u=Ta(a.arrayBuffer,f,l);s.bufferView.byteStride&&(u=this._getValueFromInterleavedBuffer(a,f,s.bufferView.byteStride,s.bytesPerElement,s.count)),s.value=new c(u)}return s}_getValueFromInterleavedBuffer(e,r,o,n,i){let s=new Uint8Array(i*n);for(let a=0;a<i;a++){let c=r+a*o;s.set(new Uint8Array(e.arrayBuffer.slice(c,c+n)),a*n)}return s.buffer}_resolveTexture(e,r){return{...e,id:e.id||`texture-${r}`,sampler:typeof e.sampler=="number"?this.getSampler(e.sampler):Mue(),source:typeof e.source=="number"?this.getImage(e.source):void 0}}_resolveSampler(e,r){let o={id:e.id||`sampler-${r}`,...e,parameters:{}};for(let n in o){let i=this._enumSamplerParameter(n);i!==void 0&&(o.parameters[i]=o[n])}return o}_enumSamplerParameter(e){return wue[e]}_resolveImage(e,r){let o={...e,id:e.id||`image-${r}`,image:null,bufferView:e.bufferView!==void 0?this.getBufferView(e.bufferView):void 0},n=this.images[r];return n&&(o.image=n),o}_resolveBufferView(e,r){let o=e.buffer,n=this.buffers[o].arrayBuffer,i=this.buffers[o].byteOffset||0;return e.byteOffset&&(i+=e.byteOffset),{id:`bufferView-${r}`,...e,buffer:this.buffers[o],data:new Uint8Array(n,i,e.byteLength)}}_resolveCamera(e,r){let o={...e,id:e.id||`camera-${r}`};return o.perspective,o.orthographic,o}};function Xs(t,e){return new lE().postProcess(t,e)}async function hk(t){let e=[];return t.scenes.forEach(r=>{r.traverse(o=>{})}),await Lue(()=>e.some(r=>!r.loaded))}async function Lue(t){for(;t();)await new Promise(e=>requestAnimationFrame(e))}var pk=`layout(std140) uniform scenegraphUniforms { float sizeScale; float sizeMinPixels; float sizeMaxPixels; mat4 sceneModelMatrix; bool composeModelMatrix; } scenegraph; `,mk={name:"scenegraph",vs:pk,fs:pk,uniformTypes:{sizeScale:"f32",sizeMinPixels:"f32",sizeMaxPixels:"f32",sceneModelMatrix:"mat4x4<f32>",composeModelMatrix:"f32"}};var gk=`#version 300 es #define SHADER_NAME scenegraph-layer-vertex-shader in vec3 instancePositions; in vec3 instancePositions64Low; in vec4 instanceColors; in vec3 instancePickingColors; in vec3 instanceModelMatrixCol0; in vec3 instanceModelMatrixCol1; in vec3 instanceModelMatrixCol2; in vec3 instanceTranslation; in vec3 positions; #ifdef HAS_UV in vec2 texCoords; #endif #ifdef LIGHTING_PBR #ifdef HAS_NORMALS in vec3 normals; #endif #endif out vec4 vColor; #ifndef LIGHTING_PBR #ifdef HAS_UV out vec2 vTEXCOORD_0; #endif #endif void main(void) { #if defined(HAS_UV) && !defined(LIGHTING_PBR) vTEXCOORD_0 = texCoords; geometry.uv = texCoords; #endif geometry.worldPosition = instancePositions; geometry.pickingColor = instancePickingColors; mat3 instanceModelMatrix = mat3(instanceModelMatrixCol0, instanceModelMatrixCol1, instanceModelMatrixCol2); vec3 normal = vec3(0.0, 0.0, 1.0); #ifdef LIGHTING_PBR #ifdef HAS_NORMALS normal = instanceModelMatrix * (scenegraph.sceneModelMatrix * vec4(normals, 0.0)).xyz; #endif #endif float originalSize = project_size_to_pixel(scenegraph.sizeScale); float clampedSize = clamp(originalSize, scenegraph.sizeMinPixels, scenegraph.sizeMaxPixels); vec3 pos = (instanceModelMatrix * (scenegraph.sceneModelMatrix * vec4(positions, 1.0)).xyz) * scenegraph.sizeScale * (clampedSize / originalSize) + instanceTranslation; if(scenegraph.composeModelMatrix) { DECKGL_FILTER_SIZE(pos, geometry); geometry.normal = project_normal(normal); geometry.worldPosition += pos; gl_Position = project_position_to_clipspace(pos + instancePositions, instancePositions64Low, vec3(0.0), geometry.position); } else { pos = project_size(pos); DECKGL_FILTER_SIZE(pos, geometry); gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, pos, geometry.position); geometry.normal = project_normal(normal); } DECKGL_FILTER_GL_POSITION(gl_Position, geometry); #ifdef LIGHTING_PBR pbr_vPosition = geometry.position.xyz; #ifdef HAS_NORMALS pbr_vNormal = geometry.normal; #endif #ifdef HAS_UV pbr_vUV0 = texCoords; #else pbr_vUV0 = vec2(0., 0.); #endif pbr_vUV1 = vec2(0., 0.); geometry.uv = pbr_vUV0; #endif vColor = instanceColors; DECKGL_FILTER_COLOR(vColor, geometry); } `;var _k=`#version 300 es #define SHADER_NAME scenegraph-layer-fragment-shader in vec4 vColor; out vec4 fragColor; #ifndef LIGHTING_PBR #if defined(HAS_UV) && defined(HAS_BASECOLORMAP) in vec2 vTEXCOORD_0; uniform sampler2D pbr_baseColorSampler; #endif #endif void main(void) { #ifdef LIGHTING_PBR fragColor = vColor * pbr_filterColor(vec4(0)); geometry.uv = pbr_vUV0; #else #if defined(HAS_UV) && defined(HAS_BASECOLORMAP) fragColor = vColor * texture(pbr_baseColorSampler, vTEXCOORD_0); geometry.uv = vTEXCOORD_0; #else fragColor = vColor; #endif #endif fragColor.a *= layer.opacity; DECKGL_FILTER_COLOR(fragColor, geometry); } `;var yk=[255,255,255,255],Bue={scenegraph:{type:"object",value:null,async:!0},getScene:t=>t&&t.scenes?typeof t.scene=="object"?t.scene:t.scenes[t.scene||0]:t,getAnimator:t=>t&&t.animator,_animations:null,onFirstDraw:{type:"function",value:()=>{}},sizeScale:{type:"number",value:1,min:0},sizeMinPixels:{type:"number",min:0,value:0},sizeMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},getPosition:{type:"accessor",value:t=>t.position},getColor:{type:"accessor",value:yk},_lighting:"flat",_imageBasedLightingEnvironment:void 0,getOrientation:{type:"accessor",value:[0,0,0]},getScale:{type:"accessor",value:[1,1,1]},getTranslation:{type:"accessor",value:[0,0,0]},getTransformMatrix:{type:"accessor",value:[]},loaders:[Pn]},mh=class extends _e{getShaders(){let e={},r;this.props._lighting==="pbr"?(r=Po,e.LIGHTING_PBR=1):r={name:"pbrMaterial"};let o=[fe,Se,mk,r];return super.getShaders({defines:e,vs:gk,fs:_k,modules:o})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),accessor:"getPosition",transition:!0},instanceColors:{type:"unorm8",size:this.props.colorFormat.length,accessor:"getColor",defaultValue:yk,transition:!0},instanceModelMatrix:cy})}updateState(e){super.updateState(e);let{props:r,oldProps:o}=e;r.scenegraph!==o.scenegraph?this._updateScenegraph():r._animations!==o._animations&&this._applyAnimationsProp(this.state.animator,r._animations)}finalizeState(e){super.finalizeState(e),this._destroyScenegraphAssets()}get isLoaded(){return Boolean(this.state?.scenegraph&&super.isLoaded)}_updateScenegraph(){let e=this.props,{device:r}=this.context,o=null;if(e.scenegraph instanceof Rr)o={scenes:[e.scenegraph]};else if(e.scenegraph&&typeof e.scenegraph=="object"){let a=e.scenegraph,c=a.json?Xs(a):a,l=OC(r,c,this._getModelOptions());o=l,hk(l).then(()=>this.setNeedsRedraw()).catch(f=>{this.raiseError(f,"loading glTF")})}let n={layer:this,device:this.context.device},i=e.getScene(o,n),s=e.getAnimator(o,n);if(i instanceof qt){this._destroyScenegraphAssets(),this._applyAnimationsProp(s,e._animations);let a=[];i.traverse(c=>{c instanceof Io&&a.push(c.model)}),this.setState({scenegraph:i,animator:s,materials:o?.materials||null,models:a,firstDrawSignaled:!1}),this.getAttributeManager().invalidateAll()}else i!==null&&N.warn("invalid scenegraph:",i)()}_destroyScenegraphAssets(){this.state.scenegraph?.destroy(),this.state.materials?.forEach(e=>e.destroy()),this.state.scenegraph=null,this.state.animator=null,this.state.materials=null,this.state.models=[]}_applyAnimationsProp(e,r){if(!e||!r)return;let o=e.getAnimations();Object.keys(r).sort().forEach(n=>{let i=r[n];if(n==="*")o.forEach(s=>{Object.assign(s,i)});else if(Number.isFinite(Number(n))){let s=Number(n);s>=0&&s<o.length?Object.assign(o[s],i):N.warn(`animation ${n} not found`)()}else{let s=o.find(({animation:a})=>a.name===n);s?Object.assign(s,i):N.warn(`animation ${n} not found`)()}})}_getModelOptions(){let{_imageBasedLightingEnvironment:e}=this.props,r;return e&&(typeof e=="function"?r=e({gl:this.context.gl,layer:this}):r=e),{imageBasedLightingEnvironment:r,modelOptions:{id:this.props.id,isInstanced:!0,bufferLayout:this.getAttributeManager().getBufferLayouts(),...this.getShaders()},useTangents:!1}}draw({context:e}){if(!this.state.scenegraph)return;this.props._animations&&this.state.animator&&(this.state.animator.setTime(e.timeline.getTime()),this.setNeedsRedraw());let{viewport:r,renderPass:o}=this.context,{sizeScale:n,sizeMinPixels:i,sizeMaxPixels:s,coordinateSystem:a}=this.props,c={camera:r.cameraPosition},l=this.getNumInstances();this.state.scenegraph.traverse((f,{worldMatrix:u})=>{if(f instanceof Io){let{model:d}=f;d.setInstanceCount(l);let h={sizeScale:n,sizeMinPixels:i,sizeMaxPixels:s,composeModelMatrix:ly(r,a),sceneModelMatrix:u};d.shaderInputs.setProps({pbrProjection:c,scenegraph:h}),d.draw(o)}}),this.state.firstDrawSignaled||(this.state.firstDrawSignaled=!0,this.props.onFirstDraw?.())}};mh.defaultProps=Bue;mh.layerName="ScenegraphLayer";var My=mh;var xk=`layout(std140) uniform meshUniforms { bool pickFeatureIds; } mesh; `,bk={name:"mesh",vs:xk,fs:xk,uniformTypes:{pickFeatureIds:"f32"}};var Ak=`#version 300 es #define SHADER_NAME simple-mesh-layer-vs in vec3 positions; in vec3 normals; in vec3 colors; in vec2 texCoords; in vec4 uvRegions; in vec3 featureIdsPickingColors; in vec4 instanceColors; in vec3 instancePickingColors; in vec3 instanceModelMatrixCol0; in vec3 instanceModelMatrixCol1; in vec3 instanceModelMatrixCol2; out vec2 vTexCoord; out vec3 cameraPosition; out vec3 normals_commonspace; out vec4 position_commonspace; out vec4 vColor; vec2 applyUVRegion(vec2 uv) { #ifdef HAS_UV_REGIONS return fract(uv) * (uvRegions.zw - uvRegions.xy) + uvRegions.xy; #else return uv; #endif } void main(void) { vec2 uv = applyUVRegion(texCoords); geometry.uv = uv; if (mesh.pickFeatureIds) { geometry.pickingColor = featureIdsPickingColors; } else { geometry.pickingColor = instancePickingColors; } mat3 instanceModelMatrix = mat3(instanceModelMatrixCol0, instanceModelMatrixCol1, instanceModelMatrixCol2); vTexCoord = uv; cameraPosition = project.cameraPosition; vColor = vec4(colors * instanceColors.rgb, instanceColors.a); vec3 pos = (instanceModelMatrix * positions) * simpleMesh.sizeScale; vec3 projectedPosition = project_position(positions); position_commonspace = vec4(projectedPosition, 1.0); gl_Position = project_common_position_to_clipspace(position_commonspace); geometry.position = position_commonspace; normals_commonspace = project_normal(instanceModelMatrix * normals); geometry.normal = normals_commonspace; DECKGL_FILTER_GL_POSITION(gl_Position, geometry); #ifdef MODULE_PBRMATERIAL pbr_vPosition = geometry.position.xyz; #ifdef HAS_NORMALS pbr_vNormal = geometry.normal; #endif #ifdef HAS_UV pbr_vUV0 = uv; #else pbr_vUV0 = vec2(0., 0.); #endif pbr_vUV1 = vec2(0., 0.); geometry.uv = pbr_vUV0; #endif DECKGL_FILTER_COLOR(vColor, geometry); } `;var Tk=`#version 300 es #define SHADER_NAME simple-mesh-layer-fs precision highp float; uniform sampler2D sampler; in vec2 vTexCoord; in vec3 cameraPosition; in vec3 normals_commonspace; in vec4 position_commonspace; in vec4 vColor; out vec4 fragColor; void main(void) { #ifdef MODULE_PBRMATERIAL fragColor = vColor * pbr_filterColor(vec4(0)); geometry.uv = pbr_vUV0; fragColor.a *= layer.opacity; #else geometry.uv = vTexCoord; vec3 normal; if (simpleMesh.flatShading) { normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz))); } else { normal = normals_commonspace; } vec4 color = simpleMesh.hasTexture ? texture(sampler, vTexCoord) : vColor; vec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal); fragColor = vec4(lightColor, color.a * layer.opacity); #endif DECKGL_FILTER_COLOR(fragColor, geometry); } `;function Oue(t){let e=t.positions||t.POSITION,r=e.value.length/e.size;t.COLOR_0||t.colors||(t.colors={size:4,value:new Uint8Array(r*4).fill(255),normalized:!0})}var Fue={pbrMaterial:{type:"object",value:null},featureIds:{type:"array",value:null,optional:!0}},gh=class extends Gs{getShaders(){let e=super.getShaders();return e.modules.push(Po,bk),{...e,vs:Ak,fs:Tk}}initializeState(){let{featureIds:e}=this.props;super.initializeState();let r=this.getAttributeManager();e&&r.add({featureIdsPickingColors:{type:"uint8",size:3,noAlloc:!0,update:this.calculateFeatureIdsPickingColors}})}updateState(e){super.updateState(e);let{props:r,oldProps:o}=e;r.pbrMaterial!==o.pbrMaterial&&this.updatePbrMaterialUniforms(r.pbrMaterial)}draw(e){let{featureIds:r}=this.props,{model:o}=this.state;if(!o)return;let n={pickFeatureIds:Boolean(r)},i={camera:this.context.viewport.cameraPosition};o.shaderInputs.setProps({pbrProjection:i,mesh:n}),super.draw(e)}getModel(e){let{id:r}=this.props,o=this.parseMaterial(this.props.pbrMaterial,e);this.setState({parsedPBRMaterial:o});let n=this.getShaders();return Oue(e.attributes),new Q(this.context.device,{...this.getShaders(),id:r,geometry:e,bufferLayout:this.getAttributeManager().getBufferLayouts(),defines:{...n.defines,...o?.defines,HAS_UV_REGIONS:e.attributes.uvRegions?1:0},parameters:o?.parameters,isInstanced:!0})}updatePbrMaterialUniforms(e){let{model:r}=this.state;if(r){let{mesh:o}=this.props,n=this.parseMaterial(e,o);this.setState({parsedPBRMaterial:n});let{pbr_baseColorSampler:i}=n.bindings,{emptyTexture:s}=this.state,a={sampler:i||s,hasTexture:Boolean(i)},{camera:c,...l}={...n.bindings,...n.uniforms};r.shaderInputs.setProps({simpleMesh:a,pbrMaterial:l})}}parseMaterial(e,r){let o=Boolean(e.pbrMetallicRoughness&&e.pbrMetallicRoughness.baseColorTexture);return Xc(this.context.device,{unlit:o,...e},{NORMAL:r.attributes.normals,TEXCOORD_0:r.attributes.texCoords},{pbrDebug:!1,lights:!0,useTangents:!1})}calculateFeatureIdsPickingColors(e){let r=this.props.featureIds,o=new Uint8ClampedArray(r.length*e.size),n=[];for(let i=0;i<r.length;i++)this.encodePickingColor(r[i],n),o[i*3]=n[0],o[i*3+1]=n[1],o[i*3+2]=n[2];e.value=o}finalizeState(e){super.finalizeState(e),this.state.parsedPBRMaterial?.generatedTextures.forEach(r=>r.destroy()),this.setState({parsedPBRMaterial:null})}};gh.layerName="MeshLayer";gh.defaultProps=Fue;var vk=gh;var Mn=6356752314245179e-9,Nue={radii:[6378137,6378137,Mn],radiiSquared:[6378137*6378137,6378137*6378137,Mn*Mn],oneOverRadii:[1/6378137,1/6378137,1/Mn],oneOverRadiiSquared:[1/(6378137*6378137),1/(6378137*6378137),1/(Mn*Mn)],maximumRadius:Math.max(6378137,6378137,Mn),centerToleranceSquared:.1};function Ry(t){return t}var jZe=new E;function Due(t,e=[],r=Ry){return"longitude"in t?(e[0]=r(t.longitude),e[1]=r(t.latitude),e[2]=t.height):"x"in t?(e[0]=r(t.x),e[1]=r(t.y),e[2]=t.z):(e[0]=r(t[0]),e[1]=r(t[1]),e[2]=t[2]),e}function Sk(t,e=[]){return Due(t,e,ve._cartographicRadians?Ry:SA)}function Uue(t,e,r=Ry){return"longitude"in e?(e.longitude=r(t[0]),e.latitude=r(t[1]),e.height=t[2]):"x"in e?(e.x=r(t[0]),e.y=r(t[1]),e.z=t[2]):(e[0]=r(t[0]),e[1]=r(t[1]),e[2]=t[2]),e}function Ck(t,e){return Uue(t,e,ve._cartographicRadians?Ry:CA)}var Ek=1e-14,kue=new E,wk={up:{south:"east",north:"west",west:"south",east:"north"},down:{south:"west",north:"east",west:"north",east:"south"},south:{up:"west",down:"east",west:"down",east:"up"},north:{up:"east",down:"west",west:"up",east:"down"},west:{up:"north",down:"south",north:"down",south:"up"},east:{up:"south",down:"north",north:"up",south:"down"}},fE={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},_h={east:new E,north:new E,up:new E,west:new E,south:new E,down:new E},Vue=new E,zue=new E,Hue=new E;function uE(t,e,r,o,n,i){let s=wk[e]&&wk[e][r];ht(s&&(!o||o===s));let a,c,l,f=kue.copy(n);if(Ce(f.x,0,Ek)&&Ce(f.y,0,Ek)){let d=Math.sign(f.z);a=Vue.fromArray(fE[e]),e!=="east"&&e!=="west"&&a.scale(d),c=zue.fromArray(fE[r]),r!=="east"&&r!=="west"&&c.scale(d),l=Hue.fromArray(fE[o]),o!=="east"&&o!=="west"&&l.scale(d)}else{let{up:d,east:h,north:p}=_h;h.set(-f.y,f.x,0).normalize(),t.geodeticSurfaceNormal(f,d),p.copy(d).cross(h);let{down:m,west:g,south:_}=_h;m.copy(d).scale(-1),g.copy(h).scale(-1),_.copy(p).scale(-1),a=_h[e],c=_h[r],l=_h[o]}return i[0]=a.x,i[1]=a.y,i[2]=a.z,i[3]=0,i[4]=c.x,i[5]=c.y,i[6]=c.z,i[7]=0,i[8]=l.x,i[9]=l.y,i[10]=l.z,i[11]=0,i[12]=f.x,i[13]=f.y,i[14]=f.z,i[15]=1,i}var ol=new E,jue=new E,Wue=new E;function Pk(t,e,r=[]){let{oneOverRadii:o,oneOverRadiiSquared:n,centerToleranceSquared:i}=e;ol.from(t);let s=ol.x,a=ol.y,c=ol.z,l=o.x,f=o.y,u=o.z,d=s*s*l*l,h=a*a*f*f,p=c*c*u*u,m=d+h+p,g=Math.sqrt(1/m);if(!Number.isFinite(g))return;let _=jue;if(_.copy(t).scale(g),m<i)return _.to(r);let x=n.x,y=n.y,b=n.z,T=Wue;T.set(_.x*x*2,_.y*y*2,_.z*b*2);let v=(1-g)*ol.len()/(.5*T.len()),w=0,C,S,A,M;do{v-=w,C=1/(1+v*x),S=1/(1+v*y),A=1/(1+v*b);let B=C*C,O=S*S,F=A*A,X=B*C,G=O*S,j=F*A;M=d*B+h*O+p*F-1;let ne=-2*(d*X*x+h*G*y+p*j*b);w=M/ne}while(Math.abs(M)>Cr.EPSILON12);return ol.scale([C,S,A]).to(r)}var Iy=new E,Mk=new E,Xue=new E,fo=new E,Yue=new E,Ly=new E,de=class{constructor(e=0,r=0,o=0){this.centerToleranceSquared=Cr.EPSILON1,ht(e>=0),ht(r>=0),ht(o>=0),this.radii=new E(e,r,o),this.radiiSquared=new E(e*e,r*r,o*o),this.radiiToTheFourth=new E(e*e*e*e,r*r*r*r,o*o*o*o),this.oneOverRadii=new E(e===0?0:1/e,r===0?0:1/r,o===0?0:1/o),this.oneOverRadiiSquared=new E(e===0?0:1/(e*e),r===0?0:1/(r*r),o===0?0:1/(o*o)),this.minimumRadius=Math.min(e,r,o),this.maximumRadius=Math.max(e,r,o),this.radiiSquared.z!==0&&(this.squaredXOverSquaredZ=this.radiiSquared.x/this.radiiSquared.z),Object.freeze(this)}equals(e){return this===e||Boolean(e&&this.radii.equals(e.radii))}toString(){return this.radii.toString()}cartographicToCartesian(e,r=[0,0,0]){let o=Mk,n=Xue,[,,i]=e;this.geodeticSurfaceNormalCartographic(e,o),n.copy(this.radiiSquared).scale(o);let s=Math.sqrt(o.dot(n));return n.scale(1/s),o.scale(i),n.add(o),n.to(r)}cartesianToCartographic(e,r=[0,0,0]){Ly.from(e);let o=this.scaleToGeodeticSurface(Ly,fo);if(!o)return;let n=this.geodeticSurfaceNormal(o,Mk),i=Yue;i.copy(Ly).subtract(o);let s=Math.atan2(n.y,n.x),a=Math.asin(n.z),c=Math.sign(Ke.dot(i,Ly))*Ke.length(i);return Ck([s,a,c],r)}eastNorthUpToFixedFrame(e,r=new V){return uE(this,"east","north","up",e,r)}localFrameToFixedFrame(e,r,o,n,i=new V){return uE(this,e,r,o,n,i)}geocentricSurfaceNormal(e,r=[0,0,0]){return Iy.from(e).normalize().to(r)}geodeticSurfaceNormalCartographic(e,r=[0,0,0]){let o=Sk(e),n=o[0],i=o[1],s=Math.cos(i);return Iy.set(s*Math.cos(n),s*Math.sin(n),Math.sin(i)).normalize(),Iy.to(r)}geodeticSurfaceNormal(e,r=[0,0,0]){return Iy.from(e).scale(this.oneOverRadiiSquared).normalize().to(r)}scaleToGeodeticSurface(e,r){return Pk(e,this,r)}scaleToGeocentricSurface(e,r=[0,0,0]){fo.from(e);let o=fo.x,n=fo.y,i=fo.z,s=this.oneOverRadiiSquared,a=1/Math.sqrt(o*o*s.x+n*n*s.y+i*i*s.z);return fo.multiplyScalar(a).to(r)}transformPositionToScaledSpace(e,r=[0,0,0]){return fo.from(e).scale(this.oneOverRadii).to(r)}transformPositionFromScaledSpace(e,r=[0,0,0]){return fo.from(e).scale(this.radii).to(r)}getSurfaceNormalIntersectionWithZAxis(e,r=0,o=[0,0,0]){ht(Ce(this.radii.x,this.radii.y,Cr.EPSILON15)),ht(this.radii.z>0),fo.from(e);let n=fo.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(n)>=this.radii.z-r))return fo.set(0,0,n).to(o)}};de.WGS84=new de(6378137,6378137,Mn);Xi();var By=class{item;previous;next;constructor(e,r,o){this.item=e,this.previous=r,this.next=o}};var Oy=class{head=null;tail=null;_length=0;get length(){return this._length}add(e){let r=new By(e,this.tail,null);return this.tail?(this.tail.next=r,this.tail=r):(this.head=r,this.tail=r),++this._length,r}remove(e){e&&(e.previous&&e.next?(e.previous.next=e.next,e.next.previous=e.previous):e.previous?(e.previous.next=null,this.tail=e.previous):e.next?(e.next.previous=null,this.head=e.next):(this.head=null,this.tail=null),e.next=null,e.previous=null,--this._length)}splice(e,r){e!==r&&(this.remove(r),this._insert(e,r))}_insert(e,r){let o=e.next;e.next=r,this.tail===e?this.tail=r:o.previous=r,r.next=o,r.previous=e,++this._length}};var Fy=class{_list;_sentinel;_trimTiles;constructor(){this._list=new Oy,this._sentinel=this._list.add("sentinel"),this._trimTiles=!1}reset(){this._list.splice(this._list.tail,this._sentinel)}touch(e){let r=e._cacheNode;r&&this._list.splice(this._sentinel,r)}add(e,r,o){r._cacheNode||(r._cacheNode=this._list.add(r),o&&o(e,r))}unloadTile(e,r,o){let n=r._cacheNode;n&&(this._list.remove(n),r._cacheNode=null,o&&o(e,r))}unloadTiles(e,r){let o=this._trimTiles;this._trimTiles=!1;let n=this._list,i=e.maximumMemoryUsage*1024*1024,s=this._sentinel,a=n.head;for(;a!==s&&(e.gpuMemoryUsageInBytes>i||o);){let c=a.item;a=a.next,this.unloadTile(e,c,r)}}trim(){this._trimTiles=!0}};function Rk(t,e){le(t),le(e);let{rtcCenter:r,gltfUpAxis:o}=e,{computedTransform:n,boundingVolume:{center:i}}=t,s=new V(n);switch(r&&s.translate(r),o){case"Z":break;case"Y":let d=new V().rotateX(Math.PI/2);s=s.multiplyRight(d);break;case"X":let h=new V().rotateY(-Math.PI/2);s=s.multiplyRight(h);break;default:break}e.isQuantized&&s.translate(e.quantizedVolumeOffset).scale(e.quantizedVolumeScale);let a=new E(i);e.cartesianModelMatrix=s,e.cartesianOrigin=a;let c=de.WGS84.cartesianToCartographic(a,new E),f=de.WGS84.eastNorthUpToFixedFrame(a).invert();e.cartographicModelMatrix=f.multiplyRight(s),e.cartographicOrigin=c;let u=que(e);u&&(e.cartesianModelMatrix=new V(s).multiplyRight(u.matrix),e.cartographicModelMatrix.multiplyRight(u.matrix),u.matrix=V.IDENTITY),e.coordinateSystem||(e.modelMatrix=e.cartographicModelMatrix)}var Kue=1e6**2;function que(t){let e=t.gltf;if(!e)return null;let r=typeof e.scene=="number"?e.scene:0,n=e.scenes?.[r]?.nodes?.[0];if(!n?.matrix)return null;let i=n.matrix;return i[12]*i[12]+i[13]*i[13]+i[14]*i[14]<=Kue?null:n}var Ik=new E,dE=new E,hE=new at([new mt,new mt,new mt,new mt,new mt,new mt]);function Bk(t,e){let{cameraDirection:r,cameraUp:o,height:n}=t,{metersPerUnit:i}=t.distanceScales,s=Ny(t,t.center),a=de.WGS84.eastNorthUpToFixedFrame(s),c=t.unprojectPosition(t.cameraPosition),l=de.WGS84.cartographicToCartesian(c,new E),f=new E(a.transformAsVector(new E(r).scale(i))).normalize(),u=new E(a.transformAsVector(new E(o).scale(i))).normalize();Zue(t);let d=t.constructor,{longitude:h,latitude:p,width:m,bearing:g,zoom:_}=t,x=new d({longitude:h,latitude:p,height:n,width:m,bearing:g,zoom:_,pitch:0});return{camera:{position:l,direction:f,up:u},viewport:t,topDownViewport:x,height:n,cullingVolume:hE,frameNumber:e,sseDenominator:1.15}}function Ok(t,e,r){if(r===0||t.length<=r)return[t,[]];let o=[],{longitude:n,latitude:i}=e.viewport;for(let[l,f]of t.entries()){let[u,d]=f.header.mbs,h=Math.abs(n-u),p=Math.abs(i-d),m=Math.sqrt(p*p+h*h);o.push([l,m])}let s=o.sort((l,f)=>l[1]-f[1]),a=[];for(let l=0;l<r;l++)a.push(t[s[l][0]]);let c=[];for(let l=r;l<s.length;l++)c.push(t[s[l][0]]);return[a,c]}function Zue(t){let e=t.getFrustumPlanes(),r=Lk(e.near,t.cameraPosition),o=Ny(t,r),n=Ny(t,t.cameraPosition,dE),i=0;hE.planes[i++].fromPointNormal(o,Ik.copy(o).subtract(n));for(let s in e){if(s==="near")continue;let a=e[s],c=Lk(a,r,dE),l=Ny(t,c,dE);hE.planes[i++].fromPointNormal(l,Ik.copy(o).subtract(l))}}function Lk(t,e,r=new E){let o=t.normal.dot(e);return r.copy(t.normal).scale(t.distance-o).add(e),r}function Ny(t,e,r=new E){let o=t.unprojectPosition(e);return de.WGS84.cartographicToCartesian(o,r)}var Jue=6378137,Que=6378137,pE=6356752314245179e-9,nl=new E;function Fk(t,e){if(t instanceof lo){let{halfAxes:r}=t,o=ede(r);return Math.log2(pE/(o+e[2]))}else if(t instanceof Fr){let{radius:r}=t;return Math.log2(pE/(r+e[2]))}else if(t.width&&t.height){let{width:r,height:o}=t,n=Math.log2(Jue/r),i=Math.log2(Que/o);return(n+i)/2}return 1}function mE(t,e,r){de.WGS84.cartographicToCartesian([t.xmax,t.ymax,t.zmax],nl);let o=Math.sqrt(Math.pow(nl[0]-r[0],2)+Math.pow(nl[1]-r[1],2)+Math.pow(nl[2]-r[2],2));return Math.log2(pE/(o+e[2]))}function Nk(t,e,r){let[o,n,i,s]=t;return mE({xmin:o,xmax:i,ymin:n,ymax:s,zmin:0,zmax:0},e,r)}function ede(t){t.getColumn(0,nl);let e=t.getColumn(1),r=t.getColumn(2);return nl.add(e).add(r).len()}var Gt={UNLOADED:0,LOADING:1,PROCESSING:2,READY:3,EXPIRED:4,FAILED:5},Rt;(function(t){t[t.ADD=1]="ADD",t[t.REPLACE=2]="REPLACE"})(Rt||(Rt={}));var Ur;(function(t){t.EMPTY="empty",t.SCENEGRAPH="scenegraph",t.POINTCLOUD="pointcloud",t.MESH="mesh"})(Ur||(Ur={}));var _t;(function(t){t.I3S="I3S",t.TILES3D="TILES3D"})(_t||(_t={}));var Rn;(function(t){t.GEOMETRIC_ERROR="geometricError",t.MAX_SCREEN_THRESHOLD="maxScreenThreshold"})(Rn||(Rn={}));var Dk={NOT_COMPUTED:-1,USE_OPTIMIZATION:1,SKIP_OPTIMIZATION:0};function zk(t){return t!=null}var It=new E,Dy=new E,tde=new E,rde=new E,Ys=new E,Uk=new E,kk=new E,Vk=new E;function Uy(t,e,r){if(le(t,"3D Tile: boundingVolume must be defined"),t.box)return jk(t.box,e,r);if(t.region)return nde(t.region);if(t.sphere)return ode(t.sphere,e,r);throw new Error("3D Tile: boundingVolume must contain a sphere, region, or box")}function Hk(t,e){if(t.box)return ide(e);if(t.region){let[r,o,n,i,s,a]=t.region;return[[rt(r),rt(o),s],[rt(n),rt(i),a]]}if(t.sphere)return sde(e);throw new Error("Unkown boundingVolume type")}function jk(t,e,r){let o=new E(t[0],t[1],t[2]);e.transform(o,o);let n=[];if(t.length===10){let l=t.slice(3,6),f=new Sr;f.fromArray(t,6);let u=new E([1,0,0]),d=new E([0,1,0]),h=new E([0,0,1]);u.transformByQuaternion(f),u.scale(l[0]),d.transformByQuaternion(f),d.scale(l[1]),h.transformByQuaternion(f),h.scale(l[2]),n=[...u.toArray(),...d.toArray(),...h.toArray()]}else n=[...t.slice(3,6),...t.slice(6,9),...t.slice(9,12)];let i=e.transformAsVector(n.slice(0,3)),s=e.transformAsVector(n.slice(3,6)),a=e.transformAsVector(n.slice(6,9)),c=new ue([i[0],i[1],i[2],s[0],s[1],s[2],a[0],a[1],a[2]]);return zk(r)?(r.center=o,r.halfAxes=c,r):new lo(o,c)}function ode(t,e,r){let o=new E(t[0],t[1],t[2]);e.transform(o,o);let n=e.getScale(Dy),i=Math.max(Math.max(n[0],n[1]),n[2]),s=t[3]*i;return zk(r)?(r.center=o,r.radius=s,r):new Fr(o,s)}function nde(t){let[e,r,o,n,i,s]=t,a=de.WGS84.cartographicToCartesian([rt(e),rt(n),i],tde),c=de.WGS84.cartographicToCartesian([rt(o),rt(r),s],rde),l=new E().addVectors(a,c).multiplyByScalar(.5);return de.WGS84.cartesianToCartographic(l,Ys),de.WGS84.cartographicToCartesian([rt(o),Ys[1],Ys[2]],Uk),de.WGS84.cartographicToCartesian([Ys[0],rt(n),Ys[2]],kk),de.WGS84.cartographicToCartesian([Ys[0],Ys[1],s],Vk),jk([...l,...Uk.subtract(l),...kk.subtract(l),...Vk.subtract(l)],new V)}function ide(t){let e=Wk(),{halfAxes:r}=t,o=new E(r.getColumn(0)),n=new E(r.getColumn(1)),i=new E(r.getColumn(2));for(let s=0;s<2;s++){for(let a=0;a<2;a++){for(let c=0;c<2;c++)It.copy(t.center),It.add(o),It.add(n),It.add(i),Gk(e,It),i.negate();n.negate()}o.negate()}return e}function sde(t){let e=Wk(),{center:r,radius:o}=t,n=de.WGS84.scaleToGeodeticSurface(r,It),i;n?i=de.WGS84.geodeticSurfaceNormal(n):i=new E(0,0,1);let s=new E(i[2],-i[1],0);s.len()>0?s.normalize():s=new E(0,1,0);let a=s.clone().cross(i);for(let c of[s,a,i]){Dy.copy(c).scale(o);for(let l=0;l<2;l++)It.copy(r),It.add(Dy),Gk(e,It),Dy.negate()}return e}function Wk(){return[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]]}function Gk(t,e){de.WGS84.cartesianToCartographic(e,It),t[0][0]=Math.min(t[0][0],It[0]),t[0][1]=Math.min(t[0][1],It[1]),t[0][2]=Math.min(t[0][2],It[2]),t[1][0]=Math.max(t[1][0],It[0]),t[1][1]=Math.max(t[1][1],It[1]),t[1][2]=Math.max(t[1][2],It[2])}var MJe=new E,RJe=new E,IJe=new V,LJe=new E,BJe=new E,OJe=new E;function ade(t,e){let r=t*e;return 1-Math.exp(-(r*r))}function cde(t,e){if(t.dynamicScreenSpaceError&&t.dynamicScreenSpaceErrorComputedDensity){let r=t.dynamicScreenSpaceErrorComputedDensity,o=t.dynamicScreenSpaceErrorFactor;return ade(e,r)*o}return 0}function $k(t,e,r){let o=t.tileset,n=t.parent&&t.parent.lodMetricValue||t.lodMetricValue,i=r?n:t.lodMetricValue;if(i===0)return 0;let s=Math.max(t._distanceToCamera,1e-7),{height:a,sseDenominator:c}=e,{viewDistanceScale:l}=o.options,f=i*a*(l||1)/(s*c);return f-=cde(o,s),f}var gE=new E,Xk=new E,Li=new E,Yk=new E,lde=new E,_E=new V,Kk=new V;function qk(t,e){if(t.lodMetricValue===0||isNaN(t.lodMetricValue))return"DIG";let r=2*yE(t,e);return r<2?"OUT":!t.header.children||r<=t.lodMetricValue?"DRAW":t.header.children?"DIG":"OUT"}function yE(t,e){let{topDownViewport:r}=e,o=t.header.mbs[1],n=t.header.mbs[0],i=t.header.mbs[2],s=t.header.mbs[3],a=[...t.boundingVolume.center],c=r.unprojectPosition(r.cameraPosition);de.WGS84.cartographicToCartesian(c,gE),Xk.copy(gE).subtract(a).normalize(),de.WGS84.eastNorthUpToFixedFrame(a,_E),Kk.copy(_E).invert(),Li.copy(gE).transform(Kk);let l=Math.sqrt(Li[0]*Li[0]+Li[1]*Li[1]),f=l*l/Li[2];Yk.copy([Li[0],Li[1],f]);let d=Yk.transform(_E).subtract(a).normalize(),p=Xk.cross(d).normalize().scale(s).add(a),m=de.WGS84.cartesianToCartographic(p),g=r.project([n,o,i]),_=r.project(m);return lde.copy(g).subtract(_).magnitude()}function Zk(t){return{assetGltfUpAxis:t.asset&&t.asset.gltfUpAxis||"Y"}}var yh=class{_map=new Map;_array;_length;constructor(e=0){this._array=new Array(e),this._length=e}get length(){return this._length}set length(e){this._length=e,e>this._array.length&&(this._array.length=e)}get values(){return this._array}get(e){return le(e<this._array.length),this._array[e]}set(e,r){le(e>=0),e>=this.length&&(this.length=e+1),this._map.has(this._array[e])&&this._map.delete(this._array[e]),this._array[e]=r,this._map.set(r,e)}delete(e){let r=this._map.get(e);r>=0&&(this._array.splice(r,1),this._map.delete(e),this.length--)}peek(){return this._array[this._length-1]}push(e){if(!this._map.has(e)){let r=this.length++;this._array[r]=e,this._map.set(e,r)}}pop(){let e=this._array[--this.length];return this._map.delete(e),e}reserve(e){le(e>=0),e>this._array.length&&(this._array.length=e)}resize(e){le(e>=0),this.length=e}trim(e){e==null&&(e=this.length),this._array.length=e}reset(){this._array=[],this._map=new Map,this._length=0}find(e){return this._map.has(e)}};var fde={loadSiblings:!1,skipLevelOfDetail:!1,updateTransforms:!0,onTraversalEnd:()=>{},viewportTraversersMap:{},basePath:""},Ko=class{options;root=null;selectedTiles={};requestedTiles={};emptyTiles={};lastUpdate=new Date().getTime();updateDebounceTime=1e3;_traversalStack=new yh;_emptyTraversalStack=new yh;_frameNumber=null;traversalFinished(e){return!0}constructor(e){this.options={...fde,...e}}traverse(e,r,o){this.root=e,this.options={...this.options,...o},this.reset(),this.updateTile(e,r),this._frameNumber=r.frameNumber,this.executeTraversal(e,r)}reset(){this.requestedTiles={},this.selectedTiles={},this.emptyTiles={},this._traversalStack.reset(),this._emptyTraversalStack.reset()}executeTraversal(e,r){let o=this._traversalStack;for(e._selectionDepth=1,o.push(e);o.length>0;){let i=o.pop(),s=!1;this.canTraverse(i,r)&&(this.updateChildTiles(i,r),s=this.updateAndPushChildren(i,r,o,i.hasRenderContent?i._selectionDepth+1:i._selectionDepth));let a=i.parent,c=Boolean(!a||a._shouldRefine),l=!s;i.hasRenderContent?i.refine===Rt.ADD?(this.loadTile(i,r),this.selectTile(i,r)):i.refine===Rt.REPLACE&&(this.loadTile(i,r),l&&this.selectTile(i,r)):(this.emptyTiles[i.id]=i,this.loadTile(i,r),l&&this.selectTile(i,r)),this.touchTile(i,r),i._shouldRefine=s&&c}let n=new Date().getTime();(this.traversalFinished(r)||n-this.lastUpdate>this.updateDebounceTime)&&(this.lastUpdate=n,this.options.onTraversalEnd(r))}updateChildTiles(e,r){let o=e.children;for(let n of o)this.updateTile(n,r)}updateAndPushChildren(e,r,o,n){let{loadSiblings:i,skipLevelOfDetail:s}=this.options,a=e.children;a.sort(this.compareDistanceToCamera.bind(this));let c=e.refine===Rt.REPLACE&&e.hasRenderContent&&!s,l=!1,f=!0;for(let u of a)if(u._selectionDepth=n,u.isVisibleAndInRequestVolume?(o.find(u)&&o.delete(u),o.push(u),l=!0):(c||i)&&(this.loadTile(u,r),this.touchTile(u,r)),c){let d;if(u._inRequestVolume?u.hasRenderContent?d=u.contentAvailable:d=this.executeEmptyTraversal(u,r):d=!1,f=f&&d,!f)return!1}return l||(f=!1),f}updateTile(e,r){this.updateTileVisibility(e,r)}selectTile(e,r){this.shouldSelectTile(e)&&(e._selectedFrame=r.frameNumber,this.selectedTiles[e.id]=e)}loadTile(e,r){this.shouldLoadTile(e)&&(e._requestedFrame=r.frameNumber,e._priority=e._getPriority(),this.requestedTiles[e.id]=e)}touchTile(e,r){e.tileset._cache.touch(e),e._touchedFrame=r.frameNumber}canTraverse(e,r){return e.hasChildren?e.hasTilesetContent?!e.contentExpired:this.shouldRefine(e,r):!1}shouldLoadTile(e){return e.hasUnloadedContent||e.contentExpired}shouldSelectTile(e){return e.contentAvailable&&!this.options.skipLevelOfDetail}shouldRefine(e,r,o=!1){let n=e._screenSpaceError;return o&&(n=e.getScreenSpaceError(r,!0)),n>e.tileset.memoryAdjustedScreenSpaceError}updateTileVisibility(e,r){let o=[];if(this.options.viewportTraversersMap)for(let n in this.options.viewportTraversersMap)this.options.viewportTraversersMap[n]===r.viewport.id&&o.push(n);else o.push(r.viewport.id);e.updateVisibility(r,o)}compareDistanceToCamera(e,r){return e._distanceToCamera-r._distanceToCamera}anyChildrenVisible(e,r){let o=!1;for(let n of e.children)n.updateVisibility(r),o=o||n.isVisibleAndInRequestVolume;return o}executeEmptyTraversal(e,r){let o=!0,n=this._emptyTraversalStack;for(n.push(e);n.length>0;){let i=n.pop(),s=!i.hasRenderContent&&this.canTraverse(i,r),a=!i.hasRenderContent&&i.children.length===0;if(!s&&!i.contentAvailable&&!a&&(o=!1),this.updateTile(i,r),i.isVisibleAndInRequestVolume||(this.loadTile(i,r),this.touchTile(i,r)),s){let c=i.children;for(let l of c)n.push(l)}}return e.hasEmptyContent||o}};var Jk=new E;function ude(t){return t!=null}var Ks=class{tileset;header;id;url;parent;refine;type;contentUrl;lodMetricType="geometricError";lodMetricValue=0;boundingVolume=null;content=null;contentState=Gt.UNLOADED;gpuMemoryUsageInBytes=0;children=[];depth=0;viewportIds=[];transform=new V;extensions=null;implicitTiling=null;userData={};computedTransform;hasEmptyContent=!1;hasTilesetContent=!1;traverser=new Ko({});_cacheNode=null;_frameNumber=null;_expireDate=null;_expiredContent=null;_boundingBox=void 0;_distanceToCamera=0;_screenSpaceError=0;_visibilityPlaneMask;_visible=void 0;_contentBoundingVolume;_viewerRequestVolume;_initialTransform=new V;_priority=0;_selectedFrame=0;_requestedFrame=0;_selectionDepth=0;_touchedFrame=0;_centerZDepth=0;_shouldRefine=!1;_stackLength=0;_visitedFrame=0;_inRequestVolume=!1;_lodJudge=null;tileDrawn=!0;constructor(e,r,o,n=""){this.header=r,this.tileset=e,this.id=n||r.id,this.url=r.url,this.parent=o,this.refine=this._getRefine(r.refine),this.type=r.type,this.contentUrl=r.contentUrl,this._initializeLodMetric(r),this._initializeTransforms(r),this._initializeBoundingVolumes(r),this._initializeContent(r),this._initializeRenderingState(r),Object.seal(this)}destroy(){this.header=null}isDestroyed(){return this.header===null}get selected(){return this._selectedFrame===this.tileset._frameNumber}get isVisible(){return this._visible}get isVisibleAndInRequestVolume(){return this._visible&&this._inRequestVolume}get hasRenderContent(){return!this.hasEmptyContent&&!this.hasTilesetContent}get hasChildren(){return this.children.length>0||this.header.children&&this.header.children.length>0}get contentReady(){return this.contentState===Gt.READY||this.hasEmptyContent}get contentAvailable(){return Boolean(this.contentReady&&this.hasRenderContent||this._expiredContent&&!this.contentFailed)}get hasUnloadedContent(){return this.hasRenderContent&&this.contentUnloaded}get contentUnloaded(){return this.contentState===Gt.UNLOADED}get contentExpired(){return this.contentState===Gt.EXPIRED}get contentFailed(){return this.contentState===Gt.FAILED}get distanceToCamera(){return this._distanceToCamera}get screenSpaceError(){return this._screenSpaceError}get boundingBox(){return this._boundingBox||(this._boundingBox=Hk(this.header.boundingVolume,this.boundingVolume)),this._boundingBox}getScreenSpaceError(e,r){switch(this.tileset.type){case _t.I3S:return yE(this,e);case _t.TILES3D:return $k(this,e,r);default:throw new Error("Unsupported tileset type")}}unselect(){this._selectedFrame=0}_getGpuMemoryUsageInBytes(){return this.content.gpuMemoryUsageInBytes||this.content.byteLength||0}_getPriority(){let e=this.tileset._traverser,{skipLevelOfDetail:r}=e.options,o=this.refine===Rt.ADD||r;if(o&&!this.isVisible&&this._visible!==void 0||this.tileset._frameNumber-this._touchedFrame>=1||this.contentState===Gt.UNLOADED)return-1;let n=this.parent,s=n&&(!o||this._screenSpaceError===0||n.hasTilesetContent)?n._screenSpaceError:this._screenSpaceError,a=e.root?e.root._screenSpaceError:0;return Math.max(a-s,0)}async loadContent(){if(this.hasEmptyContent)return!1;if(this.content)return!0;this.contentExpired&&(this._expireDate=null),this.contentState=Gt.LOADING;let r=await this.tileset._requestScheduler.scheduleRequest(this.id,this._getPriority.bind(this));if(!r)return this.contentState=Gt.UNLOADED,!1;try{let o=this.tileset.getTileUrl(this.contentUrl),n=this.tileset.loader,i=this.tileset.loadOptions[n.id]||{},s={...this.tileset.loadOptions,[n.id]:{...i,isTileset:this.type==="json",...this._getLoaderSpecificOptions(n.id)}};return this.content=await _r(o,n,s),this.tileset.options.contentLoader&&await this.tileset.options.contentLoader(this),this._isTileset()&&this.tileset._initializeTileHeaders(this.content,this),this.contentState=Gt.READY,this._onContentLoaded(),!0}catch(o){throw this.contentState=Gt.FAILED,o}finally{r.done()}}unloadContent(){return this.content&&this.content.destroy&&this.content.destroy(),this.content=null,this.header.content&&this.header.content.destroy&&this.header.content.destroy(),this.header.content=null,this.contentState=Gt.UNLOADED,this.tileDrawn=!0,!0}updateVisibility(e,r){if(this._frameNumber===e.frameNumber)return;let o=this.parent,n=o?o._visibilityPlaneMask:at.MASK_INDETERMINATE;if(this.tileset._traverser.options.updateTransforms){let i=o?o.computedTransform:this.tileset.modelMatrix;this._updateTransform(i)}this._distanceToCamera=this.distanceToTile(e),this._screenSpaceError=this.getScreenSpaceError(e,!1),this._visibilityPlaneMask=this.visibility(e,n),this._visible=this._visibilityPlaneMask!==at.MASK_OUTSIDE,this._inRequestVolume=this.insideViewerRequestVolume(e),this._frameNumber=e.frameNumber,this.viewportIds=r}visibility(e,r){let{cullingVolume:o}=e,{boundingVolume:n}=this;return o.computeVisibilityWithPlaneMask(n,r)}contentVisibility(){return!0}distanceToTile(e){let r=this.boundingVolume;return Math.sqrt(Math.max(r.distanceSquaredTo(e.camera.position),0))}cameraSpaceZDepth({camera:e}){let r=this.boundingVolume;return Jk.subVectors(r.center,e.position),e.direction.dot(Jk)}insideViewerRequestVolume(e){let r=this._viewerRequestVolume;return!r||r.distanceSquaredTo(e.camera.position)<=0}updateExpiration(){if(ude(this._expireDate)&&this.contentReady&&!this.hasEmptyContent){let e=Date.now();Date.lessThan(this._expireDate,e)&&(this.contentState=Gt.EXPIRED,this._expiredContent=this.content)}}get extras(){return this.header.extras}_initializeLodMetric(e){"lodMetricType"in e?this.lodMetricType=e.lodMetricType:(this.lodMetricType=this.parent&&this.parent.lodMetricType||this.tileset.lodMetricType,console.warn("3D Tile: Required prop lodMetricType is undefined. Using parent lodMetricType")),"lodMetricValue"in e?this.lodMetricValue=e.lodMetricValue:(this.lodMetricValue=this.parent&&this.parent.lodMetricValue||this.tileset.lodMetricValue,console.warn("3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue"))}_initializeTransforms(e){this.transform=e.transform?new V(e.transform):new V;let r=this.parent,o=this.tileset,n=r&&r.computedTransform?r.computedTransform.clone():o.modelMatrix.clone();this.computedTransform=new V(n).multiplyRight(this.transform);let i=r&&r._initialTransform?r._initialTransform.clone():new V;this._initialTransform=new V(i).multiplyRight(this.transform)}_initializeBoundingVolumes(e){this._contentBoundingVolume=null,this._viewerRequestVolume=null,this._updateBoundingVolume(e)}_initializeContent(e){this.content={_tileset:this.tileset,_tile:this},this.hasEmptyContent=!0,this.contentState=Gt.UNLOADED,this.hasTilesetContent=!1,e.contentUrl&&(this.content=null,this.hasEmptyContent=!1)}_initializeRenderingState(e){this.depth=e.level||(this.parent?this.parent.depth+1:0),this._shouldRefine=!1,this._distanceToCamera=0,this._centerZDepth=0,this._screenSpaceError=0,this._visibilityPlaneMask=at.MASK_INDETERMINATE,this._visible=void 0,this._inRequestVolume=!1,this._stackLength=0,this._selectionDepth=0,this._frameNumber=0,this._touchedFrame=0,this._visitedFrame=0,this._selectedFrame=0,this._requestedFrame=0,this._priority=0}_getRefine(e){return e||this.parent&&this.parent.refine||Rt.REPLACE}_isTileset(){return this.contentUrl.indexOf(".json")!==-1}_onContentLoaded(){switch(this.content&&this.content.type){case"vctr":case"geom":this.tileset._traverser.disableSkipLevelOfDetail=!0;break;default:}this._isTileset()?this.hasTilesetContent=!0:this.gpuMemoryUsageInBytes=this._getGpuMemoryUsageInBytes()}_updateBoundingVolume(e){this.boundingVolume=Uy(e.boundingVolume,this.computedTransform,this.boundingVolume);let r=e.content;r&&(r.boundingVolume&&(this._contentBoundingVolume=Uy(r.boundingVolume,this.computedTransform,this._contentBoundingVolume)),e.viewerRequestVolume&&(this._viewerRequestVolume=Uy(e.viewerRequestVolume,this.computedTransform,this._viewerRequestVolume)))}_updateTransform(e=new V){let r=e.clone().multiplyRight(this.transform);r.equals(this.computedTransform)||(this.computedTransform=r,this._updateBoundingVolume(this.header))}_getLoaderSpecificOptions(e){switch(e){case"i3s":return{...this.tileset.options.i3s,_tileOptions:{attributeUrls:this.header.attributeUrls,textureUrl:this.header.textureUrl,textureFormat:this.header.textureFormat,textureLoaderOptions:this.header.textureLoaderOptions,materialDefinition:this.header.materialDefinition,isDracoGeometry:this.header.isDracoGeometry,mbs:this.header.mbs},_tilesetOptions:{store:this.tileset.tileset.store,attributeStorageInfo:this.tileset.tileset.attributeStorageInfo,fields:this.tileset.tileset.fields},isTileHeader:!1};case"3d-tiles":case"cesium-ion":default:return Zk(this.tileset.tileset)}}};var ky=class extends Ko{compareDistanceToCamera(e,r){return r._distanceToCamera===0&&e._distanceToCamera===0?r._centerZDepth-e._centerZDepth:r._distanceToCamera-e._distanceToCamera}updateTileVisibility(e,r){if(super.updateTileVisibility(e,r),!e.isVisibleAndInRequestVolume)return;let o=e.children.length>0;if(e.hasTilesetContent&&o){let s=e.children[0];this.updateTileVisibility(s,r),e._visible=s._visible;return}if(this.meetsScreenSpaceErrorEarly(e,r)){e._visible=!1;return}let n=e.refine===Rt.REPLACE,i=e._optimChildrenWithinParent===Dk.USE_OPTIMIZATION;if(n&&i&&o&&!this.anyChildrenVisible(e,r)){e._visible=!1;return}}meetsScreenSpaceErrorEarly(e,r){let{parent:o}=e;return!o||o.hasTilesetContent||o.refine!==Rt.ADD?!1:!this.shouldRefine(e,r,!0)}};var Vy=class{frameNumberMap=new Map;register(e,r){let o=this.frameNumberMap.get(e)||new Map,n=o.get(r)||0;o.set(r,n+1),this.frameNumberMap.set(e,o)}deregister(e,r){let o=this.frameNumberMap.get(e);if(!o)return;let n=o.get(r)||1;o.set(r,n-1)}isZero(e,r){return(this.frameNumberMap.get(e)?.get(r)||0)===0}};var xE={REQUESTED:"REQUESTED",COMPLETED:"COMPLETED",ERROR:"ERROR"},zy=class{_statusMap;pendingTilesRegister=new Vy;constructor(){this._statusMap={}}add(e,r,o,n){if(!this._statusMap[r]){let{frameNumber:i,viewport:{id:s}}=n;this._statusMap[r]={request:e,callback:o,key:r,frameState:n,status:xE.REQUESTED},this.pendingTilesRegister.register(s,i),e().then(a=>{this._statusMap[r].status=xE.COMPLETED;let{frameNumber:c,viewport:{id:l}}=this._statusMap[r].frameState;this.pendingTilesRegister.deregister(l,c),this._statusMap[r].callback(a,n)}).catch(a=>{this._statusMap[r].status=xE.ERROR;let{frameNumber:c,viewport:{id:l}}=this._statusMap[r].frameState;this.pendingTilesRegister.deregister(l,c),o(a)})}}update(e,r){if(this._statusMap[e]){let{frameNumber:o,viewport:{id:n}}=this._statusMap[e].frameState;this.pendingTilesRegister.deregister(n,o);let{frameNumber:i,viewport:{id:s}}=r;this.pendingTilesRegister.register(s,i),this._statusMap[e].frameState=r}}find(e){return this._statusMap[e]}hasPendingTiles(e,r){return!this.pendingTilesRegister.isZero(e,r)}};var Hy=class extends Ko{_tileManager;constructor(e){super(e),this._tileManager=new zy}traversalFinished(e){return!this._tileManager.hasPendingTiles(e.viewport.id,this._frameNumber||0)}shouldRefine(e,r){return e._lodJudge=qk(e,r),e._lodJudge==="DIG"}updateChildTiles(e,r){let o=e.header.children||[],n=e.children,i=e.tileset;for(let s of o){let a=`${s.id}-${r.viewport.id}`,c=n&&n.find(l=>l.id===a);if(c)c&&this.updateTile(c,r);else{let l=()=>this._loadTile(s.id,i);this._tileManager.find(a)?this._tileManager.update(a,r):(i.tileset.nodePages&&(l=()=>i.tileset.nodePagesTile.formTileFromNodePages(s.id)),this._tileManager.add(l,a,u=>this._onTileLoad(u,e,a),r))}}return!1}async _loadTile(e,r){let{loader:o}=r,n=r.getTileUrl(`${r.url}/nodes/${e}`),i={...r.loadOptions,i3s:{...r.loadOptions.i3s,isTileHeader:!0}};return await _r(n,o,i)}_onTileLoad(e,r,o){let n=new Ks(r.tileset,e,r,o);r.children.push(n);let i=this._tileManager.find(n.id).frameState;this.updateTile(n,i),this._frameNumber===i.frameNumber&&(this.traversalFinished(i)||new Date().getTime()-this.lastUpdate>this.updateDebounceTime)&&this.executeTraversal(n,i)}};var dde={description:"",ellipsoid:de.WGS84,modelMatrix:new V,throttleRequests:!0,maxRequests:64,maximumMemoryUsage:32,memoryCacheOverflow:1,maximumTilesSelected:0,debounceTime:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},onTraversalComplete:t=>t,onUpdate:()=>{},contentLoader:void 0,viewDistanceScale:1,maximumScreenSpaceError:8,memoryAdjustedScreenSpaceError:!1,loadTiles:!0,updateTransforms:!0,viewportTraversersMap:null,loadOptions:{fetch:{}},attributions:[],basePath:"",i3s:{}},jy="Tiles In Tileset(s)",bE="Tiles In Memory",Qk="Tiles In View",e6="Tiles To Render",t6="Tiles Loaded",AE="Tiles Loading",r6="Tiles Unloaded",o6="Failed Tile Loads",n6="Points/Vertices",TE="Tile Memory Use",i6="Maximum Screen Space Error",xh=class{options;loadOptions;type;tileset;loader;url;basePath;modelMatrix;ellipsoid;lodMetricType;lodMetricValue;refine;root=null;roots={};asset={};description="";properties;extras=null;attributions={};credits={};stats;contentFormats={draco:!1,meshopt:!1,dds:!1,ktx2:!1};cartographicCenter=null;cartesianCenter=null;zoom=1;boundingVolume=null;dynamicScreenSpaceErrorComputedDensity=0;maximumMemoryUsage=32;gpuMemoryUsageInBytes=0;memoryAdjustedScreenSpaceError=0;_cacheBytes=0;_cacheOverflowBytes=0;_frameNumber=0;_queryParams={};_extensionsUsed=[];_tiles={};_pendingCount=0;selectedTiles=[];traverseCounter=0;geometricError=0;lastUpdatedVieports=null;_requestedTiles=[];_emptyTiles=[];frameStateData={};_traverser;_cache=new Fy;_requestScheduler;_heldTiles=new Set;updatePromise=null;tilesetInitializationPromise;constructor(e,r){this.options={...dde,...r},this.tileset=e,this.loader=e.loader,this.type=e.type,this.url=e.url,this.basePath=e.basePath||Ft.dirname(this.url),this.modelMatrix=this.options.modelMatrix,this.ellipsoid=this.options.ellipsoid,this.lodMetricType=e.lodMetricType,this.lodMetricValue=e.lodMetricValue,this.refine=e.root.refine,this.loadOptions=this.options.loadOptions||{},this._traverser=this._initializeTraverser(),this._requestScheduler=new Gn({throttleRequests:this.options.throttleRequests,maxRequests:this.options.maxRequests}),this.memoryAdjustedScreenSpaceError=this.options.maximumScreenSpaceError,this._cacheBytes=this.options.maximumMemoryUsage*1024*1024,this._cacheOverflowBytes=this.options.memoryCacheOverflow*1024*1024,this.stats=new Et({id:this.url}),this._initializeStats(),this.tilesetInitializationPromise=this._initializeTileSet(e)}destroy(){this._destroy()}isLoaded(){return this._pendingCount===0&&this._frameNumber!==0&&this._requestedTiles.length===0}get tiles(){return Object.values(this._tiles)}get frameNumber(){return this._frameNumber}get queryParams(){return new URLSearchParams(this._queryParams).toString()}setProps(e){this.options={...this.options,...e}}getTileUrl(e){if(e.startsWith("data:"))return e;let o=e;return this.queryParams.length&&(o=`${e}${e.includes("?")?"&":"?"}${this.queryParams}`),o}hasExtension(e){return Boolean(this._extensionsUsed.indexOf(e)>-1)}update(e=null){this.tilesetInitializationPromise.then(()=>{!e&&this.lastUpdatedVieports?e=this.lastUpdatedVieports:this.lastUpdatedVieports=e,e&&this.doUpdate(e)})}async selectTiles(e=null){return await this.tilesetInitializationPromise,e&&(this.lastUpdatedVieports=e),this.updatePromise||(this.updatePromise=new Promise(r=>{setTimeout(()=>{this.lastUpdatedVieports&&this.doUpdate(this.lastUpdatedVieports),r(this._frameNumber),this.updatePromise=null},this.options.debounceTime)})),this.updatePromise}adjustScreenSpaceError(){this.gpuMemoryUsageInBytes<this._cacheBytes?this.memoryAdjustedScreenSpaceError=Math.max(this.memoryAdjustedScreenSpaceError/1.02,this.options.maximumScreenSpaceError):this.gpuMemoryUsageInBytes>this._cacheBytes+this._cacheOverflowBytes&&(this.memoryAdjustedScreenSpaceError*=1.02)}doUpdate(e){if("loadTiles"in this.options&&!this.options.loadTiles||this.traverseCounter>0)return;let r=e instanceof Array?e:[e];this._cache.reset(),this._frameNumber++,this.traverseCounter=r.length;let o=[];for(let n of r){let i=n.id;this._needTraverse(i)?o.push(i):this.traverseCounter--}for(let n of r){let i=n.id;if(this.roots[i]||(this.roots[i]=this._initializeTileHeaders(this.tileset,null)),!o.includes(i))continue;let s=Bk(n,this._frameNumber);this._traverser.traverse(this.roots[i],s,this.options)}}_needTraverse(e){let r=e;return this.options.viewportTraversersMap&&(r=this.options.viewportTraversersMap[e]),r===e}_onTraversalEnd(e){let r=e.viewport.id;this.frameStateData[r]||(this.frameStateData[r]={selectedTiles:[],_requestedTiles:[],_emptyTiles:[]});let o=this.frameStateData[r],n=Object.values(this._traverser.selectedTiles),[i,s]=Ok(n,e,this.options.maximumTilesSelected);o.selectedTiles=i;for(let a of s)a.unselect();o._requestedTiles=Object.values(this._traverser.requestedTiles),o._emptyTiles=Object.values(this._traverser.emptyTiles),this.traverseCounter--,!(this.traverseCounter>0)&&this._updateTiles()}_updateTiles(){let e=this.selectedTiles;this.selectedTiles=[],this._requestedTiles=[],this._emptyTiles=[];for(let i in this.frameStateData){let s=this.frameStateData[i];this.selectedTiles=this.selectedTiles.concat(s.selectedTiles),this._requestedTiles=this._requestedTiles.concat(s._requestedTiles),this._emptyTiles=this._emptyTiles.concat(s._emptyTiles)}this.selectedTiles=this.options.onTraversalComplete(this.selectedTiles);let r=new Set(this.selectedTiles.map(i=>i.id)),o=this.selectedTiles.some(i=>!i.tileDrawn),n=0;if(o){for(let i of r)this._heldTiles.add(i);for(let i of this._heldTiles){if(r.has(i))continue;let s=this._tiles[i];s&&s.contentAvailable?(s._selectedFrame=this._frameNumber,this.selectedTiles.push(s),n++):this._heldTiles.delete(i)}}else this._heldTiles=r;n>0&&setTimeout(()=>{this.selectTiles()},0);for(let i of this.selectedTiles)this._tiles[i.id]=i;this._loadTiles(),this._unloadTiles(),this._updateStats(),this._tilesChanged(e,this.selectedTiles)&&this.options.onUpdate()}_tilesChanged(e,r){if(e.length!==r.length)return!0;let o=new Set(e.map(s=>s.id)),n=new Set(r.map(s=>s.id)),i=e.filter(s=>!n.has(s.id)).length>0;return i=i||r.filter(s=>!o.has(s.id)).length>0,i}_loadTiles(){this._requestedTiles.sort((e,r)=>e._priority-r._priority);for(let e of this._requestedTiles)e.contentUnloaded&&this._loadTile(e)}_unloadTiles(){this._cache.unloadTiles(this,(e,r)=>e._unloadTile(r))}_updateStats(){let e=0,r=0;for(let o of this.selectedTiles)o.contentAvailable&&o.content&&(e++,o.content.pointCount?r+=o.content.pointCount:r+=o.content.vertexCount);this.stats.get(Qk).count=this.selectedTiles.length,this.stats.get(e6).count=e,this.stats.get(n6).count=r,this.stats.get(i6).count=this.memoryAdjustedScreenSpaceError}async _initializeTileSet(e){this.type===_t.I3S&&(this.calculateViewPropsI3S(),e.root=await e.root),this.root=this._initializeTileHeaders(e,null),this.type===_t.TILES3D&&(this._initializeTiles3DTileset(e),this.calculateViewPropsTiles3D()),this.type===_t.I3S&&this._initializeI3STileset()}calculateViewPropsI3S(){let e=this.tileset.fullExtent;if(e){let{xmin:o,xmax:n,ymin:i,ymax:s,zmin:a,zmax:c}=e;this.cartographicCenter=new E(o+(n-o)/2,i+(s-i)/2,a+(c-a)/2),this.cartesianCenter=new E,de.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),this.zoom=mE(e,this.cartographicCenter,this.cartesianCenter);return}let r=this.tileset.store?.extent;if(r){let[o,n,i,s]=r;this.cartographicCenter=new E(o+(i-o)/2,n+(s-n)/2,0),this.cartesianCenter=new E,de.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),this.zoom=Nk(r,this.cartographicCenter,this.cartesianCenter);return}console.warn("Extent is not defined in the tileset header"),this.cartographicCenter=new E,this.zoom=1}calculateViewPropsTiles3D(){let e=this.root,{center:r}=e.boundingVolume;if(!r){console.warn("center was not pre-calculated for the root tile"),this.cartographicCenter=new E,this.zoom=1;return}r[0]!==0||r[1]!==0||r[2]!==0?(this.cartographicCenter=new E,de.WGS84.cartesianToCartographic(r,this.cartographicCenter)):this.cartographicCenter=new E(0,0,-de.WGS84.radii[0]),this.cartesianCenter=r,this.zoom=Fk(e.boundingVolume,this.cartographicCenter)}_initializeStats(){this.stats.get(jy),this.stats.get(AE),this.stats.get(bE),this.stats.get(Qk),this.stats.get(e6),this.stats.get(t6),this.stats.get(r6),this.stats.get(o6),this.stats.get(n6),this.stats.get(TE,"memory"),this.stats.get(i6)}_initializeTileHeaders(e,r){let o=new Ks(this,e.root,r);if(r&&(r.children.push(o),o.depth=r.depth+1),this.type===_t.TILES3D){let n=[];for(n.push(o);n.length>0;){let i=n.pop();this.stats.get(jy).incrementCount();let s=i.header.children||[];for(let a of s){let c=new Ks(this,a,i);if(c.contentUrl?.includes("?session=")){let f=new URL(c.contentUrl).searchParams.get("session");f&&(this._queryParams.session=f)}i.children.push(c),c.depth=i.depth+1,n.push(c)}}}return o}_initializeTraverser(){let e;switch(this.type){case _t.TILES3D:e=ky;break;case _t.I3S:e=Hy;break;default:e=Ko}return new e({basePath:this.basePath,onTraversalEnd:this._onTraversalEnd.bind(this)})}_destroyTileHeaders(e){this._destroySubtree(e)}async _loadTile(e){let r;try{this._onStartTileLoading(),r=await e.loadContent()}catch(o){this._onTileLoadError(e,o instanceof Error?o:new Error("load failed"))}finally{this._onEndTileLoading(),this._onTileLoad(e,r)}}_onTileLoadError(e,r){this.stats.get(o6).incrementCount();let o=r.message||r.toString(),n=e.url;console.error(`A 3D tile failed to load: ${e.url} ${o}`),this.options.onTileError(e,o,n)}_onTileLoad(e,r){if(r){if(this.type===_t.I3S){let o=this.tileset?.nodePagesTile?.nodesInNodePages||0;this.stats.get(jy).reset(),this.stats.get(jy).addCount(o)}e&&e.content&&Rk(e,e.content),this.updateContentTypes(e),this._addTileToCache(e),this.options.onTileLoad(e)}}updateContentTypes(e){if(this.type===_t.I3S)switch(e.header.isDracoGeometry&&(this.contentFormats.draco=!0),e.header.textureFormat){case"dds":this.contentFormats.dds=!0;break;case"ktx2":this.contentFormats.ktx2=!0;break;default:}else if(this.type===_t.TILES3D){let{extensionsRemoved:r=[]}=e.content?.gltf||{};r.includes("KHR_draco_mesh_compression")&&(this.contentFormats.draco=!0),r.includes("EXT_meshopt_compression")&&(this.contentFormats.meshopt=!0),r.includes("KHR_texture_basisu")&&(this.contentFormats.ktx2=!0)}}_onStartTileLoading(){this._pendingCount++,this.stats.get(AE).incrementCount()}_onEndTileLoading(){this._pendingCount--,this.stats.get(AE).decrementCount()}_addTileToCache(e){this._cache.add(this,e,r=>r._updateCacheStats(e))}_updateCacheStats(e){this.stats.get(t6).incrementCount(),this.stats.get(bE).incrementCount(),this.gpuMemoryUsageInBytes+=e.gpuMemoryUsageInBytes||0,this.stats.get(TE).count=this.gpuMemoryUsageInBytes,this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_unloadTile(e){this.gpuMemoryUsageInBytes-=e.gpuMemoryUsageInBytes||0,this.stats.get(bE).decrementCount(),this.stats.get(r6).incrementCount(),this.stats.get(TE).count=this.gpuMemoryUsageInBytes,this.options.onTileUnload(e),e.unloadContent()}_destroy(){let e=[];for(this.root&&e.push(this.root);e.length>0;){let r=e.pop();for(let o of r.children)e.push(o);this._destroyTile(r)}this.root=null}_destroySubtree(e){let r=e,o=[];for(o.push(r);o.length>0;){e=o.pop();for(let n of e.children)o.push(n);e!==r&&this._destroyTile(e)}r.children=[]}_destroyTile(e){this._cache.unloadTile(this,e),this._unloadTile(e),e.destroy()}_initializeTiles3DTileset(e){if(e.queryString){let r=new URLSearchParams(e.queryString),o=Object.fromEntries(r.entries());this._queryParams={...this._queryParams,...o}}if(this.asset=e.asset,!this.asset)throw new Error("Tileset must have an asset property.");if(this.asset.version!=="0.0"&&this.asset.version!=="1.0"&&this.asset.version!=="1.1")throw new Error("The tileset must be 3D Tiles version either 0.0 or 1.0 or 1.1.");"tilesetVersion"in this.asset&&(this._queryParams.v=this.asset.tilesetVersion),this.credits={attributions:this.options.attributions||[]},this.description=this.options.description||"",this.properties=e.properties,this.geometricError=e.geometricError,this._extensionsUsed=e.extensionsUsed||[],this.extras=e.extras}_initializeI3STileset(){let e=this.loadOptions.i3s;e&&typeof e=="object"&&"token"in e&&(this._queryParams.token=e.token)}};var Wy="4.4.3";var qs={COMPOSITE:"cmpt",POINT_CLOUD:"pnts",BATCHED_3D_MODEL:"b3dm",INSTANCED_3D_MODEL:"i3dm",GEOMETRY:"geom",VECTOR:"vect",GLTF:"glTF"},IQe=Object.keys(qs);function vE(t,e,r){le(t instanceof ArrayBuffer);let o=new TextDecoder("utf8"),n=new Uint8Array(t,e,r);return o.decode(n)}function s6(t,e=0){let r=new DataView(t);return`${String.fromCharCode(r.getUint8(e+0))}${String.fromCharCode(r.getUint8(e+1))}${String.fromCharCode(r.getUint8(e+2))}${String.fromCharCode(r.getUint8(e+3))}`}var hde={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Je={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DOUBLE:5130},ae={...hde,...Je};var SE={[Je.DOUBLE]:Float64Array,[Je.FLOAT]:Float32Array,[Je.UNSIGNED_SHORT]:Uint16Array,[Je.UNSIGNED_INT]:Uint32Array,[Je.UNSIGNED_BYTE]:Uint8Array,[Je.BYTE]:Int8Array,[Je.SHORT]:Int16Array,[Je.INT]:Int32Array},pde={DOUBLE:Je.DOUBLE,FLOAT:Je.FLOAT,UNSIGNED_SHORT:Je.UNSIGNED_SHORT,UNSIGNED_INT:Je.UNSIGNED_INT,UNSIGNED_BYTE:Je.UNSIGNED_BYTE,BYTE:Je.BYTE,SHORT:Je.SHORT,INT:Je.INT},CE="Failed to convert GL type",dt=class{static fromTypedArray(e){e=ArrayBuffer.isView(e)?e.constructor:e;for(let r in SE)if(SE[r]===e)return r;throw new Error(CE)}static fromName(e){let r=pde[e];if(!r)throw new Error(CE);return r}static getArrayType(e){switch(e){case Je.UNSIGNED_SHORT_5_6_5:case Je.UNSIGNED_SHORT_4_4_4_4:case Je.UNSIGNED_SHORT_5_5_5_1:return Uint16Array;default:let r=SE[e];if(!r)throw new Error(CE);return r}}static getByteSize(e){return dt.getArrayType(e).BYTES_PER_ELEMENT}static validate(e){return Boolean(dt.getArrayType(e))}static createTypedArray(e,r,o=0,n){n===void 0&&(n=(r.byteLength-o)/dt.getByteSize(e));let i=ArrayBuffer.isView(r)?r.buffer:r,s=dt.getArrayType(e);return new s(i,o,n)}};function a6(t,e){if(!t)throw new Error(`math.gl assertion failed. ${e}`)}function EE(t,e=[0,0,0]){let r=t>>11&31,o=t>>5&63,n=t&31;return e[0]=r<<3,e[1]=o<<2,e[2]=n<<3,e}var HQe=1/256;var jQe=new Gr,WQe=new E,GQe=new Gr,$Qe=new Gr,XQe=new Uint8Array(1);function c6(t,e=255){return ee(t,0,e)/e*2-1}function l6(t){return t<0?-1:1}function f6(t,e,r,o){if(a6(o),t<0||t>r||e<0||e>r)throw new Error(`x and y must be unsigned normalized integers between 0 and ${r}`);if(o.x=c6(t,r),o.y=c6(e,r),o.z=1-(Math.abs(o.x)+Math.abs(o.y)),o.z<0){let n=o.x;o.x=(1-Math.abs(o.y))*l6(n),o.y=(1-Math.abs(n))*l6(o.y)}return o.normalize()}function wE(t,e,r){return f6(t,e,255,r)}var In=class{json;buffer;featuresLength=0;_cachedTypedArrays={};constructor(e,r){this.json=e,this.buffer=r}getExtension(e){return this.json.extensions&&this.json.extensions[e]}hasProperty(e){return Boolean(this.json[e])}getGlobalProperty(e,r=ae.UNSIGNED_INT,o=1){let n=this.json[e];return n&&Number.isFinite(n.byteOffset)?this._getTypedArrayFromBinary(e,r,o,1,n.byteOffset):n}getPropertyArray(e,r,o){let n=this.json[e];return n&&Number.isFinite(n.byteOffset)?("componentType"in n&&(r=dt.fromName(n.componentType)),this._getTypedArrayFromBinary(e,r,o,this.featuresLength,n.byteOffset)):this._getTypedArrayFromArray(e,r,n)}getProperty(e,r,o,n,i){let s=this.json[e];if(!s)return s;let a=this.getPropertyArray(e,r,o);if(o===1)return a[n];for(let c=0;c<o;++c)i[c]=a[o*n+c];return i}_getTypedArrayFromBinary(e,r,o,n,i){let s=this._cachedTypedArrays,a=s[e];return a||(a=dt.createTypedArray(r,this.buffer.buffer,this.buffer.byteOffset+i,n*o),s[e]=a),a}_getTypedArrayFromArray(e,r,o){let n=this._cachedTypedArrays,i=n[e];if(!i){if(ArrayBuffer.isView(o)){let s=o.byteOffset,c=o.byteLength/dt.getByteSize(r);i=dt.createTypedArray(r,o.buffer,s,c)}else if(o instanceof ArrayBuffer)i=dt.createTypedArray(r,o);else{let s=dt.getArrayType(r);i=new s(o)}n[e]=i}return i}};var mde={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},gde={SCALAR:(t,e)=>t[e],VEC2:(t,e)=>[t[2*e+0],t[2*e+1]],VEC3:(t,e)=>[t[3*e+0],t[3*e+1],t[3*e+2]],VEC4:(t,e)=>[t[4*e+0],t[4*e+1],t[4*e+2],t[4*e+3]],MAT2:(t,e)=>[t[4*e+0],t[4*e+1],t[4*e+2],t[4*e+3]],MAT3:(t,e)=>[t[9*e+0],t[9*e+1],t[9*e+2],t[9*e+3],t[9*e+4],t[9*e+5],t[9*e+6],t[9*e+7],t[9*e+8]],MAT4:(t,e)=>[t[16*e+0],t[16*e+1],t[16*e+2],t[16*e+3],t[16*e+4],t[16*e+5],t[16*e+6],t[16*e+7],t[16*e+8],t[16*e+9],t[16*e+10],t[16*e+11],t[16*e+12],t[16*e+13],t[16*e+14],t[16*e+15]]},_de={SCALAR:(t,e,r)=>{e[r]=t},VEC2:(t,e,r)=>{e[2*r+0]=t[0],e[2*r+1]=t[1]},VEC3:(t,e,r)=>{e[3*r+0]=t[0],e[3*r+1]=t[1],e[3*r+2]=t[2]},VEC4:(t,e,r)=>{e[4*r+0]=t[0],e[4*r+1]=t[1],e[4*r+2]=t[2],e[4*r+3]=t[3]},MAT2:(t,e,r)=>{e[4*r+0]=t[0],e[4*r+1]=t[1],e[4*r+2]=t[2],e[4*r+3]=t[3]},MAT3:(t,e,r)=>{e[9*r+0]=t[0],e[9*r+1]=t[1],e[9*r+2]=t[2],e[9*r+3]=t[3],e[9*r+4]=t[4],e[9*r+5]=t[5],e[9*r+6]=t[6],e[9*r+7]=t[7],e[9*r+8]=t[8],e[9*r+9]=t[9]},MAT4:(t,e,r)=>{e[16*r+0]=t[0],e[16*r+1]=t[1],e[16*r+2]=t[2],e[16*r+3]=t[3],e[16*r+4]=t[4],e[16*r+5]=t[5],e[16*r+6]=t[6],e[16*r+7]=t[7],e[16*r+8]=t[8],e[16*r+9]=t[9],e[16*r+10]=t[10],e[16*r+11]=t[11],e[16*r+12]=t[12],e[16*r+13]=t[13],e[16*r+14]=t[14],e[16*r+15]=t[15]}};function u6(t,e,r,o){let{componentType:n}=t;le(t.componentType);let i=typeof n=="string"?dt.fromName(n):n,s=mde[t.type],a=gde[t.type],c=_de[t.type];return r+=t.byteOffset,{values:dt.createTypedArray(i,e,r,s*o),type:i,size:s,unpacker:a,packer:c}}var qo=t=>t!==void 0;function d6(t,e,r){if(!e)return null;let o=t.getExtension("3DTILES_batch_table_hierarchy"),n=e.HIERARCHY;return n&&(console.warn("3D Tile Parser: HIERARCHY is deprecated. Use 3DTILES_batch_table_hierarchy."),e.extensions=e.extensions||{},e.extensions["3DTILES_batch_table_hierarchy"]=n,o=n),o?yde(o,r):null}function yde(t,e){let r,o,n,i=t.instancesLength,s=t.classes,a=t.classIds,c=t.parentCounts,l=t.parentIds,f=i;qo(a.byteOffset)&&(a.componentType=defaultValue(a.componentType,GL.UNSIGNED_SHORT),a.type=AttributeType.SCALAR,n=getBinaryAccessor(a),a=n.createArrayBufferView(e.buffer,e.byteOffset+a.byteOffset,i));let u;if(qo(c))for(qo(c.byteOffset)&&(c.componentType=defaultValue(c.componentType,GL.UNSIGNED_SHORT),c.type=AttributeType.SCALAR,n=getBinaryAccessor(c),c=n.createArrayBufferView(e.buffer,e.byteOffset+c.byteOffset,i)),u=new Uint16Array(i),f=0,r=0;r<i;++r)u[r]=f,f+=c[r];qo(l)&&qo(l.byteOffset)&&(l.componentType=defaultValue(l.componentType,GL.UNSIGNED_SHORT),l.type=AttributeType.SCALAR,n=getBinaryAccessor(l),l=n.createArrayBufferView(e.buffer,e.byteOffset+l.byteOffset,f));let d=s.length;for(r=0;r<d;++r){let g=s[r].length,_=s[r].instances,x=getBinaryProperties(g,_,e);s[r].instances=combine(x,_)}let h=new Array(d).fill(0),p=new Uint16Array(i);for(r=0;r<i;++r)o=a[r],p[r]=h[o],++h[o];let m={classes:s,classIds:a,classIndexes:p,parentCounts:c,parentIndexes:u,parentIds:l};return Ade(m),m}function il(t,e,r){if(!t)return;let o=t.parentCounts;return t.parentIds?r(t,e):o>0?xde(t,e,r):bde(t,e,r)}function xde(t,e,r){let o=t.classIds,n=t.parentCounts,i=t.parentIds,s=t.parentIndexes,a=o.length,c=scratchVisited;c.length=Math.max(c.length,a);let l=++marker,f=scratchStack;for(f.length=0,f.push(e);f.length>0;){if(e=f.pop(),c[e]===l)continue;c[e]=l;let u=r(t,e);if(qo(u))return u;let d=n[e],h=s[e];for(let p=0;p<d;++p){let m=i[h+p];m!==e&&f.push(m)}}return null}function bde(t,e,r){let o=!0;for(;o;){let n=r(t,e);if(qo(n))return n;let i=t.parentIds[e];o=i!==e,e=i}throw new Error("traverseHierarchySingleParent")}function Ade(t){let e=[],o=t.classIds.length;for(let n=0;n<o;++n)h6(t,n,stack)}function h6(t,e,r){let o=t.parentCounts,n=t.parentIds,i=t.parentIndexes,a=t.classIds.length;if(!qo(n))return;assert(e<a,`Parent index ${e} exceeds the total number of instances: ${a}`),assert(r.indexOf(e)===-1,"Circular dependency detected in the batch table hierarchy."),r.push(e);let c=qo(o)?o[e]:1,l=qo(o)?i[e]:e;for(let f=0;f<c;++f){let u=n[l+f];u!==e&&h6(t,u,r)}r.pop(e)}function tr(t){return t!=null}var Gy=(t,e)=>t,Tde={HIERARCHY:!0,extensions:!0,extras:!0},Zs=class{json;binary;featureCount;_extensions;_properties;_binaryProperties;_hierarchy;constructor(e,r,o,n={}){le(o>=0),this.json=e||{},this.binary=r,this.featureCount=o,this._extensions=this.json?.extensions||{},this._properties={};for(let i in this.json)Tde[i]||(this._properties[i]=this.json[i]);this._binaryProperties=this._initializeBinaryProperties(),n["3DTILES_batch_table_hierarchy"]&&(this._hierarchy=d6(this,this.json,this.binary))}getExtension(e){return this.json&&this.json.extensions&&this.json.extensions[e]}memorySizeInBytes(){return 0}isClass(e,r){if(this._checkBatchId(e),le(typeof r=="string",r),this._hierarchy){let o=il(this._hierarchy,e,(n,i)=>{let s=n.classIds[i];return n.classes[s].name===r});return tr(o)}return!1}isExactClass(e,r){return le(typeof r=="string",r),this.getExactClassName(e)===r}getExactClassName(e){if(this._checkBatchId(e),this._hierarchy){let r=this._hierarchy.classIds[e];return this._hierarchy.classes[r].name}}hasProperty(e,r){return this._checkBatchId(e),le(typeof r=="string",r),tr(this._properties[r])||this._hasPropertyInHierarchy(e,r)}getPropertyNames(e,r){this._checkBatchId(e),r=tr(r)?r:[],r.length=0;let o=Object.keys(this._properties);return r.push(...o),this._hierarchy&&this._getPropertyNamesInHierarchy(e,r),r}getProperty(e,r){if(this._checkBatchId(e),le(typeof r=="string",r),this._binaryProperties){let n=this._binaryProperties[r];if(tr(n))return this._getBinaryProperty(n,e)}let o=this._properties[r];if(tr(o))return Gy(o[e],!0);if(this._hierarchy){let n=this._getHierarchyProperty(e,r);if(tr(n))return n}}setProperty(e,r,o){let n=this.featureCount;if(this._checkBatchId(e),le(typeof r=="string",r),this._binaryProperties){let s=this._binaryProperties[r];if(s){this._setBinaryProperty(s,e,o);return}}if(this._hierarchy&&this._setHierarchyProperty(this,e,r,o))return;let i=this._properties[r];tr(i)||(this._properties[r]=new Array(n),i=this._properties[r]),i[e]=Gy(o,!0)}_checkBatchId(e){if(!(e>=0&&e<this.featureCount))throw new Error("batchId not in range [0, featureCount - 1].")}_getBinaryProperty(e,r){return e.unpack(e.typedArray,r)}_setBinaryProperty(e,r,o){e.pack(o,e.typedArray,r)}_initializeBinaryProperties(){let e=null;for(let r in this._properties){let o=this._properties[r],n=this._initializeBinaryProperty(r,o);n&&(e=e||{},e[r]=n)}return e}_initializeBinaryProperty(e,r){if("byteOffset"in r){let o=r;le(this.binary,`Property ${e} requires a batch table binary.`),le(o.type,`Property ${e} requires a type.`);let n=u6(o,this.binary.buffer,this.binary.byteOffset|0,this.featureCount);return{typedArray:n.values,componentCount:n.size,unpack:n.unpacker,pack:n.packer}}return null}_hasPropertyInHierarchy(e,r){if(!this._hierarchy)return!1;let o=il(this._hierarchy,e,(n,i)=>{let s=n.classIds[i],a=n.classes[s].instances;return tr(a[r])});return tr(o)}_getPropertyNamesInHierarchy(e,r){il(this._hierarchy,e,(o,n)=>{let i=o.classIds[n],s=o.classes[i].instances;for(let a in s)s.hasOwnProperty(a)&&r.indexOf(a)===-1&&r.push(a)})}_getHierarchyProperty(e,r){return il(this._hierarchy,e,(o,n)=>{let i=o.classIds[n],s=o.classes[i],a=o.classIndexes[n],c=s.instances[r];return tr(c)?tr(c.typedArray)?this._getBinaryProperty(c,a):Gy(c[a],!0):null})}_setHierarchyProperty(e,r,o,n){let i=il(this._hierarchy,r,(s,a)=>{let c=s.classIds[a],l=s.classes[c],f=s.classIndexes[a],u=l.instances[o];return tr(u)?(le(a===r,`Inherited property "${o}" is read-only.`),tr(u.typedArray)?this._setBinaryProperty(u,f,n):u[f]=Gy(n,!0),!0):!1});return tr(i)}};function Bi(t,e,r=0){let o=new DataView(e);if(t.magic=o.getUint32(r,!0),r+=4,t.version=o.getUint32(r,!0),r+=4,t.byteLength=o.getUint32(r,!0),r+=4,t.version!==1)throw new Error(`3D Tile Version ${t.version} not supported`);return r}var sl=4,p6="b3dm tile in legacy format.";function al(t,e,r){let o=new DataView(e),n;t.header=t.header||{};let i=o.getUint32(r,!0);r+=sl;let s=o.getUint32(r,!0);r+=sl;let a=o.getUint32(r,!0);r+=sl;let c=o.getUint32(r,!0);return r+=sl,a>=570425344?(r-=sl*2,n=i,a=s,c=0,i=0,s=0,console.warn(p6)):c>=570425344&&(r-=sl,n=a,a=i,c=s,i=0,s=0,console.warn(p6)),t.header.featureTableJsonByteLength=i,t.header.featureTableBinaryByteLength=s,t.header.batchTableJsonByteLength=a,t.header.batchTableBinaryByteLength=c,t.header.batchLength=n,r}function cl(t,e,r,o){return r=vde(t,e,r,o),r=Sde(t,e,r,o),r}function vde(t,e,r,o){let{featureTableJsonByteLength:n,featureTableBinaryByteLength:i,batchLength:s}=t.header||{};if(t.featureTableJson={BATCH_LENGTH:s||0},n&&n>0){let a=vE(e,r,n);t.featureTableJson=JSON.parse(a)}return r+=n||0,t.featureTableBinary=new Uint8Array(e,r,i),r+=i||0,r}function Sde(t,e,r,o){let{batchTableJsonByteLength:n,batchTableBinaryByteLength:i}=t.header||{};if(n&&n>0){let s=vE(e,r,n);t.batchTableJson=JSON.parse(s),r+=n,i&&i>0&&(t.batchTableBinary=new Uint8Array(e,r,i),t.batchTableBinary=new Uint8Array(t.batchTableBinary),r+=i)}return r}function PE(t,e,r){if(!e&&(!t||!t.batchIds||!r))return null;let{batchIds:o,isRGB565:n,pointCount:i=0}=t;if(o&&r){let s=new Uint8ClampedArray(i*3);for(let a=0;a<i;a++){let c=o[a],f=r.getProperty(c,"dimensions").map(u=>u*255);s[a*3]=f[0],s[a*3+1]=f[1],s[a*3+2]=f[2]}return{type:ae.UNSIGNED_BYTE,value:s,size:3,normalized:!0}}if(e&&n){let s=new Uint8ClampedArray(i*3);for(let a=0;a<i;a++){let c=EE(e[a]);s[a*3]=c[0],s[a*3+1]=c[1],s[a*3+2]=c[2]}return{type:ae.UNSIGNED_BYTE,value:s,size:3,normalized:!0}}return e&&e.length===i*3?{type:ae.UNSIGNED_BYTE,value:e,size:3,normalized:!0}:{type:ae.UNSIGNED_BYTE,value:e||new Uint8ClampedArray,size:4,normalized:!0}}var m6=new E;function g6(t,e){if(!e)return null;if(t.isOctEncoded16P){let r=new Float32Array((t.pointsLength||0)*3);for(let o=0;o<(t.pointsLength||0);o++)wE(e[o*2],e[o*2+1],m6),m6.toArray(r,o*3);return{type:ae.FLOAT,size:2,value:r}}return{type:ae.FLOAT,size:2,value:e}}function _6(t,e,r){return t.isQuantized?r["3d-tiles"]&&r["3d-tiles"].decodeQuantizedPositions?(t.isQuantized=!1,Cde(t,e)):{type:ae.UNSIGNED_SHORT,value:e,size:3,normalized:!0}:e}function Cde(t,e){let r=new E,o=new Float32Array(t.pointCount*3);for(let n=0;n<t.pointCount;n++)r.set(e[n*3],e[n*3+1],e[n*3+2]).scale(1/t.quantizedRange).multiply(t.quantizedVolumeScale).add(t.quantizedVolumeOffset).toArray(o,n*3);return o}async function y6(t,e,r,o,n){r=Bi(t,e,r),r=al(t,e,r),r=cl(t,e,r,o),Ede(t);let{featureTable:i,batchTable:s}=wde(t);return await Lde(t,i,s,o,n),Pde(t,i,o),Mde(t,i,s),Rde(t,i),r}function Ede(t){t.attributes={positions:null,colors:null,normals:null,batchIds:null},t.isQuantized=!1,t.isTranslucent=!1,t.isRGB565=!1,t.isOctEncoded16P=!1}function wde(t){let e=new In(t.featureTableJson,t.featureTableBinary),r=e.getGlobalProperty("POINTS_LENGTH");if(!Number.isFinite(r))throw new Error("POINTS_LENGTH must be defined");e.featuresLength=r,t.featuresLength=r,t.pointsLength=r,t.pointCount=r,t.rtcCenter=e.getGlobalProperty("RTC_CENTER",ae.FLOAT,3);let o=Ide(t,e);return{featureTable:e,batchTable:o}}function Pde(t,e,r){if(t.attributes=t.attributes||{positions:null,colors:null,normals:null,batchIds:null},!t.attributes.positions){if(e.hasProperty("POSITION"))t.attributes.positions=e.getPropertyArray("POSITION",ae.FLOAT,3);else if(e.hasProperty("POSITION_QUANTIZED")){let o=e.getPropertyArray("POSITION_QUANTIZED",ae.UNSIGNED_SHORT,3);if(t.isQuantized=!0,t.quantizedRange=(1<<16)-1,t.quantizedVolumeScale=e.getGlobalProperty("QUANTIZED_VOLUME_SCALE",ae.FLOAT,3),!t.quantizedVolumeScale)throw new Error("QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");if(t.quantizedVolumeOffset=e.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",ae.FLOAT,3),!t.quantizedVolumeOffset)throw new Error("QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");t.attributes.positions=_6(t,o,r)}}if(!t.attributes.positions)throw new Error("Either POSITION or POSITION_QUANTIZED must be defined.")}function Mde(t,e,r){if(t.attributes=t.attributes||{positions:null,colors:null,normals:null,batchIds:null},!t.attributes.colors){let o=null;e.hasProperty("RGBA")?(o=e.getPropertyArray("RGBA",ae.UNSIGNED_BYTE,4),t.isTranslucent=!0):e.hasProperty("RGB")?o=e.getPropertyArray("RGB",ae.UNSIGNED_BYTE,3):e.hasProperty("RGB565")&&(o=e.getPropertyArray("RGB565",ae.UNSIGNED_SHORT,1),t.isRGB565=!0),t.attributes.colors=PE(t,o,r)}e.hasProperty("CONSTANT_RGBA")&&(t.constantRGBA=e.getGlobalProperty("CONSTANT_RGBA",ae.UNSIGNED_BYTE,4))}function Rde(t,e){if(t.attributes=t.attributes||{positions:null,colors:null,normals:null,batchIds:null},!t.attributes.normals){let r=null;e.hasProperty("NORMAL")?r=e.getPropertyArray("NORMAL",ae.FLOAT,3):e.hasProperty("NORMAL_OCT16P")&&(r=e.getPropertyArray("NORMAL_OCT16P",ae.UNSIGNED_BYTE,2),t.isOctEncoded16P=!0),t.attributes.normals=g6(t,r)}}function Ide(t,e){let r=null;if(!t.batchIds&&e.hasProperty("BATCH_ID")&&(t.batchIds=e.getPropertyArray("BATCH_ID",ae.UNSIGNED_SHORT,1),t.batchIds)){let o=e.getGlobalProperty("BATCH_LENGTH");if(!o)throw new Error("Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.");let{batchTableJson:n,batchTableBinary:i}=t;r=new Zs(n,i,o)}return r}async function Lde(t,e,r,o,n){let i,s,a,c=t.batchTableJson&&t.batchTableJson.extensions&&t.batchTableJson.extensions["3DTILES_draco_point_compression"];c&&(a=c.properties);let l=e.getExtension("3DTILES_draco_point_compression");if(l){s=l.properties;let u=l.byteOffset,d=l.byteLength;if(!s||!Number.isFinite(u)||!d)throw new Error("Draco properties, byteOffset, and byteLength must be defined");i=(t.featureTableBinary||[]).slice(u,u+d),t.hasPositions=Number.isFinite(s.POSITION),t.hasColors=Number.isFinite(s.RGB)||Number.isFinite(s.RGBA),t.hasNormals=Number.isFinite(s.NORMAL),t.hasBatchIds=Number.isFinite(s.BATCH_ID),t.isTranslucent=Number.isFinite(s.RGBA)}if(!i)return!0;let f={buffer:i,properties:{...s,...a},featureTableProperties:s,batchTableProperties:a,dequantizeInShader:!1};return await Bde(t,f,o,n)}async function Bde(t,e,r,o){if(!o)return;let n={...r,draco:{...r?.draco,extraAttributes:e.batchTableProperties||{}}};delete n["3d-tiles"];let i=await nr(e.buffer,dh,n,o),s=i.attributes.POSITION&&i.attributes.POSITION.value,a=i.attributes.COLOR_0&&i.attributes.COLOR_0.value,c=i.attributes.NORMAL&&i.attributes.NORMAL.value,l=i.attributes.BATCH_ID&&i.attributes.BATCH_ID.value,f=s&&i.attributes.POSITION.value.quantization,u=c&&i.attributes.NORMAL.value.quantization;if(f){let h=i.POSITION.data.quantization,p=h.range;t.quantizedVolumeScale=new E(p,p,p),t.quantizedVolumeOffset=new E(h.minValues),t.quantizedRange=(1<<h.quantizationBits)-1,t.isQuantizedDraco=!0}u&&(t.octEncodedRange=(1<<i.NORMAL.data.quantization.quantizationBits)-1,t.isOctEncodedDraco=!0);let d={};if(e.batchTableProperties)for(let h of Object.keys(e.batchTableProperties))i.attributes[h]&&i.attributes[h].value&&(d[h.toLowerCase()]=i.attributes[h].value);t.attributes={positions:s,colors:PE(t,a,void 0),normals:c,batchIds:l,...d}}var $y={URI:0,EMBEDDED:1};function Xy(t,e,r,o){t.rotateYtoZ=!0;let n=(t.byteOffset||0)+(t.byteLength||0)-r;if(n===0)throw new Error("glTF byte length must be greater than 0.");return t.gltfUpAxis=o?.["3d-tiles"]&&o["3d-tiles"].assetGltfUpAxis?o["3d-tiles"].assetGltfUpAxis:"Y",t.gltfArrayBuffer=Gi(e,r,n),t.gltfByteOffset=0,t.gltfByteLength=n,r%4===0||console.warn(`${t.type}: embedded glb is not aligned to a 4-byte boundary.`),(t.byteOffset||0)+(t.byteLength||0)}async function Yy(t,e,r,o){let n=r?.["3d-tiles"]||{};if(Ode(t,e,r),n.loadGLTF){if(!o)return;if(t.gltfUrl){let{fetch:i}=o,s=await i(t.gltfUrl,r?.core);t.gltfArrayBuffer=await s.arrayBuffer(),t.gltfByteOffset=0}if(t.gltfArrayBuffer){let i=await nr(t.gltfArrayBuffer,Pn,r,o);t.gltf=Xs(i),t.gpuMemoryUsageInBytes=ch(t.gltf),delete t.gltfArrayBuffer,delete t.gltfByteOffset,delete t.gltfByteLength}}}function Ode(t,e,r){switch(e){case $y.URI:if(t.gltfArrayBuffer){let o=new Uint8Array(t.gltfArrayBuffer,t.gltfByteOffset),i=new TextDecoder().decode(o);t.gltfUrl=i.replace(/[\s\0]+$/,"")}delete t.gltfArrayBuffer,delete t.gltfByteOffset,delete t.gltfByteLength;break;case $y.EMBEDDED:break;default:throw new Error("b3dm: Illegal glTF format field")}}async function x6(t,e,r,o,n){r=Fde(t,e,r,o,n),await Yy(t,$y.EMBEDDED,o,n);let i=t?.gltf?.extensions;return i&&i.CESIUM_RTC&&(t.rtcCenter=i.CESIUM_RTC.center),r}function Fde(t,e,r,o,n){r=Bi(t,e,r),r=al(t,e,r),r=cl(t,e,r,o),r=Xy(t,e,r,o);let i=new In(t.featureTableJson,t.featureTableBinary);return t.rtcCenter=i.getGlobalProperty("RTC_CENTER",ae.FLOAT,3),r}async function b6(t,e,r,o,n){return r=Nde(t,e,r,o,n),await Yy(t,t.gltfFormat||0,o,n),r}function Nde(t,e,r,o,n){if(r=Bi(t,e,r),t.version!==1)throw new Error(`Instanced 3D Model version ${t.version} is not supported`);r=al(t,e,r);let i=new DataView(e);if(t.gltfFormat=i.getUint32(r,!0),r+=4,r=cl(t,e,r,o),r=Xy(t,e,r,o),!t?.header?.featureTableJsonByteLength||t.header.featureTableJsonByteLength===0)throw new Error("i3dm parser: featureTableJsonByteLength is zero.");let s=new In(t.featureTableJson,t.featureTableBinary),a=s.getGlobalProperty("INSTANCES_LENGTH");if(s.featuresLength=a,!Number.isFinite(a))throw new Error("i3dm parser: INSTANCES_LENGTH must be defined");t.eastNorthUp=s.getGlobalProperty("EAST_NORTH_UP"),t.rtcCenter=s.getGlobalProperty("RTC_CENTER",ae.FLOAT,3);let c=new Zs(t.batchTableJson,t.batchTableBinary,a);return Dde(t,s,c,a),r}function Dde(t,e,r,o){let n=new Array(o),i=new E,s=new E,a=new E,c=new E,l=new ue,f=new Sr,u=new E,d={},h=new V,p=[],m=[],g=[],_=[];for(let x=0;x<o;x++){let y;if(e.hasProperty("POSITION"))y=e.getProperty("POSITION",ae.FLOAT,3,x,i);else if(e.hasProperty("POSITION_QUANTIZED")){y=e.getProperty("POSITION_QUANTIZED",ae.UNSIGNED_SHORT,3,x,i);let A=e.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",ae.FLOAT,3);if(!A)throw new Error("i3dm parser: QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");let M=e.getGlobalProperty("QUANTIZED_VOLUME_SCALE",ae.FLOAT,3);if(!M)throw new Error("i3dm parser: QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");let B=65535;for(let O=0;O<3;O++)y[O]=y[O]/B*M[O]+A[O]}if(!y)throw new Error("i3dm: POSITION or POSITION_QUANTIZED must be defined for each instance.");i.copy(y),d.translation=i,t.normalUp=e.getProperty("NORMAL_UP",ae.FLOAT,3,x,p),t.normalRight=e.getProperty("NORMAL_RIGHT",ae.FLOAT,3,x,m);let b=!1;if(t.normalUp){if(!t.normalRight)throw new Error("i3dm: Custom orientation requires both NORMAL_UP and NORMAL_RIGHT.");t.hasCustomOrientation=!0}else{if(t.octNormalUp=e.getProperty("NORMAL_UP_OCT32P",ae.UNSIGNED_SHORT,2,x,p),t.octNormalRight=e.getProperty("NORMAL_RIGHT_OCT32P",ae.UNSIGNED_SHORT,2,x,m),t.octNormalUp)throw t.octNormalRight?new Error("i3dm: oct-encoded orientation not implemented"):new Error("i3dm: oct-encoded orientation requires NORMAL_UP_OCT32P and NORMAL_RIGHT_OCT32P");t.eastNorthUp?(de.WGS84.eastNorthUpToFixedFrame(i,h),h.getRotationMatrix3(l)):l.identity()}b&&(c.copy(s).cross(a).normalize(),l.setColumn(0,s),l.setColumn(1,a),l.setColumn(2,c)),f.fromMatrix3(l),d.rotation=f,u.set(1,1,1);let T=e.getProperty("SCALE",ae.FLOAT,1,x,g);Number.isFinite(T)&&u.multiplyByScalar(T);let v=e.getProperty("SCALE_NON_UNIFORM",ae.FLOAT,3,x,p);v&&u.scale(v),d.scale=u;let w=e.getProperty("BATCH_ID",ae.UNSIGNED_SHORT,1,x,_);w===void 0&&(w=x);let C=new V().fromQuaternion(d.rotation);h.identity(),h.translate(d.translation),h.multiplyRight(C),h.scale(d.scale);let S=h.clone();n[x]={modelMatrix:S,batchId:w}}t.instances=n}async function A6(t,e,r,o,n,i){r=Bi(t,e,r);let s=new DataView(e);for(t.tilesLength=s.getUint32(r,!0),r+=4,t.tiles=[];t.tiles.length<t.tilesLength&&(t.byteLength||0)-r>12;){let a={shape:"tile3d"};t.tiles.push(a),r=await i(e,r,o,n,a)}return r}async function T6(t,e,r,o){if(t.rotateYtoZ=!0,t.gltfUpAxis=r?.["3d-tiles"]?.assetGltfUpAxis?r["3d-tiles"].assetGltfUpAxis:"Y",r?.["3d-tiles"]?.loadGLTF){if(!o)return e.byteLength;let n=await nr(e,Pn,r,o);t.gltf=Xs(n),t.gpuMemoryUsageInBytes=ch(t.gltf)}else t.gltfArrayBuffer=e;return e.byteLength}async function ME(t,e=0,r,o,n={shape:"tile3d"}){switch(n.byteOffset=e,n.type=s6(t,e),n.type){case qs.COMPOSITE:return await A6(n,t,e,r,o,ME);case qs.BATCHED_3D_MODEL:return await x6(n,t,e,r,o);case qs.GLTF:return await T6(n,t,r,o);case qs.INSTANCED_3D_MODEL:return await b6(n,t,e,r,o);case qs.POINT_CLOUD:return await y6(n,t,e,r,o);default:throw new Error(`3DTileLoader: unknown type ${n.type}`)}}async function RE(t,e,r){if(new Uint32Array(t.slice(0,4))[0]!==1952609651)throw new Error("Wrong subtree file magic number");if(new Uint32Array(t.slice(4,8))[0]!==1)throw new Error("Wrong subtree file verson, must be 1");let i=v6(t.slice(8,16)),s=new Uint8Array(t,24,i),c=new TextDecoder("utf8").decode(s),l=JSON.parse(c),f=v6(t.slice(16,24)),u=new ArrayBuffer(0);if(f&&(u=t.slice(24+i)),await Ky(l,l.tileAvailability,u,r),Array.isArray(l.contentAvailability))for(let d of l.contentAvailability)await Ky(l,d,u,r);else await Ky(l,l.contentAvailability,u,r);return await Ky(l,l.childSubtreeAvailability,u,r),l}async function Ky(t,e,r,o){let n=Number.isFinite(e.bitstream)?e.bitstream:e.bufferView;if(typeof n!="number")return;let i=t.bufferViews[n],s=t.buffers[i.buffer];if(!o?.baseUrl)throw new Error("Url is not provided");if(!o.fetch)throw new Error("fetch is not provided");if(s.uri){let c=`${o?.baseUrl||""}/${s.uri}`,f=await(await o.fetch(c)).arrayBuffer();e.explicitBitstream=new Uint8Array(f,i.byteOffset,i.byteLength);return}let a=t.buffers.slice(0,i.buffer).reduce((c,l)=>c+l.byteLength,0);e.explicitBitstream=new Uint8Array(r.slice(a,a+s.byteLength),i.byteOffset,i.byteLength)}function v6(t){let e=new DataView(t),r=e.getUint32(0,!0),o=e.getUint32(4,!0);return r+2**32*o}var qy={dataType:null,batchType:null,id:"3d-tiles-subtree",name:"3D Tiles Subtree",module:"3d-tiles",version:Wy,extensions:["subtree"],mimeTypes:["application/octet-stream"],tests:["subtree"],parse:RE,options:{}};zn();var kr=null;try{kr=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}function Ie(t,e,r){this.low=t|0,this.high=e|0,this.unsigned=!!r}Ie.prototype.__isLong__;Object.defineProperty(Ie.prototype,"__isLong__",{value:!0});function Lt(t){return(t&&t.__isLong__)===!0}function S6(t){var e=Math.clz32(t&-t);return t?31-e:e}Ie.isLong=Lt;var C6={},E6={};function Js(t,e){var r,o,n;return e?(t>>>=0,(n=0<=t&&t<256)&&(o=E6[t],o)?o:(r=xe(t,0,!0),n&&(E6[t]=r),r)):(t|=0,(n=-128<=t&&t<128)&&(o=C6[t],o)?o:(r=xe(t,t<0?-1:0,!1),n&&(C6[t]=r),r))}Ie.fromInt=Js;function Vr(t,e){if(isNaN(t))return e?Ln:uo;if(e){if(t<0)return Ln;if(t>=R6)return B6}else{if(t<=-P6)return rr;if(t+1>=P6)return L6}return t<0?Vr(-t,e).neg():xe(t%fl|0,t/fl|0,e)}Ie.fromNumber=Vr;function xe(t,e,r){return new Ie(t,e,r)}Ie.fromBits=xe;var Zy=Math.pow;function LE(t,e,r){if(t.length===0)throw Error("empty string");if(typeof e=="number"?(r=e,e=!1):e=!!e,t==="NaN"||t==="Infinity"||t==="+Infinity"||t==="-Infinity")return e?Ln:uo;if(r=r||10,r<2||36<r)throw RangeError("radix");var o;if((o=t.indexOf("-"))>0)throw Error("interior hyphen");if(o===0)return LE(t.substring(1),e,r).neg();for(var n=Vr(Zy(r,8)),i=uo,s=0;s<t.length;s+=8){var a=Math.min(8,t.length-s),c=parseInt(t.substring(s,s+a),r);if(a<8){var l=Vr(Zy(r,a));i=i.mul(l).add(Vr(c))}else i=i.mul(n),i=i.add(Vr(c))}return i.unsigned=e,i}Ie.fromString=LE;function ho(t,e){return typeof t=="number"?Vr(t,e):typeof t=="string"?LE(t,e):xe(t.low,t.high,typeof e=="boolean"?e:t.unsigned)}Ie.fromValue=ho;var w6=1<<16,Ude=1<<24,fl=w6*w6,R6=fl*fl,P6=R6/2,M6=Js(Ude),uo=Js(0);Ie.ZERO=uo;var Ln=Js(0,!0);Ie.UZERO=Ln;var ll=Js(1);Ie.ONE=ll;var I6=Js(1,!0);Ie.UONE=I6;var IE=Js(-1);Ie.NEG_ONE=IE;var L6=xe(-1,2147483647,!1);Ie.MAX_VALUE=L6;var B6=xe(-1,-1,!0);Ie.MAX_UNSIGNED_VALUE=B6;var rr=xe(0,-2147483648,!1);Ie.MIN_VALUE=rr;var D=Ie.prototype;D.toInt=function(){return this.unsigned?this.low>>>0:this.low};D.toNumber=function(){return this.unsigned?(this.high>>>0)*fl+(this.low>>>0):this.high*fl+(this.low>>>0)};D.toString=function(e){if(e=e||10,e<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(rr)){var r=Vr(e),o=this.div(r),n=o.mul(r).sub(this);return o.toString(e)+n.toInt().toString(e)}else return"-"+this.neg().toString(e);for(var i=Vr(Zy(e,6),this.unsigned),s=this,a="";;){var c=s.div(i),l=s.sub(c.mul(i)).toInt()>>>0,f=l.toString(e);if(s=c,s.isZero())return f+a;for(;f.length<6;)f="0"+f;a=""+f+a}};D.getHighBits=function(){return this.high};D.getHighBitsUnsigned=function(){return this.high>>>0};D.getLowBits=function(){return this.low};D.getLowBitsUnsigned=function(){return this.low>>>0};D.getNumBitsAbs=function(){if(this.isNegative())return this.eq(rr)?64:this.neg().getNumBitsAbs();for(var e=this.high!=0?this.high:this.low,r=31;r>0&&!(e&1<<r);r--);return this.high!=0?r+33:r+1};D.isZero=function(){return this.high===0&&this.low===0};D.eqz=D.isZero;D.isNegative=function(){return!this.unsigned&&this.high<0};D.isPositive=function(){return this.unsigned||this.high>=0};D.isOdd=function(){return(this.low&1)===1};D.isEven=function(){return(this.low&1)===0};D.equals=function(e){return Lt(e)||(e=ho(e)),this.unsigned!==e.unsigned&&this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low};D.eq=D.equals;D.notEquals=function(e){return!this.eq(e)};D.neq=D.notEquals;D.ne=D.notEquals;D.lessThan=function(e){return this.comp(e)<0};D.lt=D.lessThan;D.lessThanOrEqual=function(e){return this.comp(e)<=0};D.lte=D.lessThanOrEqual;D.le=D.lessThanOrEqual;D.greaterThan=function(e){return this.comp(e)>0};D.gt=D.greaterThan;D.greaterThanOrEqual=function(e){return this.comp(e)>=0};D.gte=D.greaterThanOrEqual;D.ge=D.greaterThanOrEqual;D.compare=function(e){if(Lt(e)||(e=ho(e)),this.eq(e))return 0;var r=this.isNegative(),o=e.isNegative();return r&&!o?-1:!r&&o?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1};D.comp=D.compare;D.negate=function(){return!this.unsigned&&this.eq(rr)?rr:this.not().add(ll)};D.neg=D.negate;D.add=function(e){Lt(e)||(e=ho(e));var r=this.high>>>16,o=this.high&65535,n=this.low>>>16,i=this.low&65535,s=e.high>>>16,a=e.high&65535,c=e.low>>>16,l=e.low&65535,f=0,u=0,d=0,h=0;return h+=i+l,d+=h>>>16,h&=65535,d+=n+c,u+=d>>>16,d&=65535,u+=o+a,f+=u>>>16,u&=65535,f+=r+s,f&=65535,xe(d<<16|h,f<<16|u,this.unsigned)};D.subtract=function(e){return Lt(e)||(e=ho(e)),this.add(e.neg())};D.sub=D.subtract;D.multiply=function(e){if(this.isZero())return this;if(Lt(e)||(e=ho(e)),kr){var r=kr.mul(this.low,this.high,e.low,e.high);return xe(r,kr.get_high(),this.unsigned)}if(e.isZero())return this.unsigned?Ln:uo;if(this.eq(rr))return e.isOdd()?rr:uo;if(e.eq(rr))return this.isOdd()?rr:uo;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(M6)&&e.lt(M6))return Vr(this.toNumber()*e.toNumber(),this.unsigned);var o=this.high>>>16,n=this.high&65535,i=this.low>>>16,s=this.low&65535,a=e.high>>>16,c=e.high&65535,l=e.low>>>16,f=e.low&65535,u=0,d=0,h=0,p=0;return p+=s*f,h+=p>>>16,p&=65535,h+=i*f,d+=h>>>16,h&=65535,h+=s*l,d+=h>>>16,h&=65535,d+=n*f,u+=d>>>16,d&=65535,d+=i*l,u+=d>>>16,d&=65535,d+=s*c,u+=d>>>16,d&=65535,u+=o*f+n*l+i*c+s*a,u&=65535,xe(h<<16|p,u<<16|d,this.unsigned)};D.mul=D.multiply;D.divide=function(e){if(Lt(e)||(e=ho(e)),e.isZero())throw Error("division by zero");if(kr){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;var r=(this.unsigned?kr.div_u:kr.div_s)(this.low,this.high,e.low,e.high);return xe(r,kr.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?Ln:uo;var o,n,i;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return Ln;if(e.gt(this.shru(1)))return I6;i=Ln}else{if(this.eq(rr)){if(e.eq(ll)||e.eq(IE))return rr;if(e.eq(rr))return ll;var s=this.shr(1);return o=s.div(e).shl(1),o.eq(uo)?e.isNegative()?ll:IE:(n=this.sub(e.mul(o)),i=o.add(n.div(e)),i)}else if(e.eq(rr))return this.unsigned?Ln:uo;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();i=uo}for(n=this;n.gte(e);){o=Math.max(1,Math.floor(n.toNumber()/e.toNumber()));for(var a=Math.ceil(Math.log(o)/Math.LN2),c=a<=48?1:Zy(2,a-48),l=Vr(o),f=l.mul(e);f.isNegative()||f.gt(n);)o-=c,l=Vr(o,this.unsigned),f=l.mul(e);l.isZero()&&(l=ll),i=i.add(l),n=n.sub(f)}return i};D.div=D.divide;D.modulo=function(e){if(Lt(e)||(e=ho(e)),kr){var r=(this.unsigned?kr.rem_u:kr.rem_s)(this.low,this.high,e.low,e.high);return xe(r,kr.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))};D.mod=D.modulo;D.rem=D.modulo;D.not=function(){return xe(~this.low,~this.high,this.unsigned)};D.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32};D.clz=D.countLeadingZeros;D.countTrailingZeros=function(){return this.low?S6(this.low):S6(this.high)+32};D.ctz=D.countTrailingZeros;D.and=function(e){return Lt(e)||(e=ho(e)),xe(this.low&e.low,this.high&e.high,this.unsigned)};D.or=function(e){return Lt(e)||(e=ho(e)),xe(this.low|e.low,this.high|e.high,this.unsigned)};D.xor=function(e){return Lt(e)||(e=ho(e)),xe(this.low^e.low,this.high^e.high,this.unsigned)};D.shiftLeft=function(e){return Lt(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?xe(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):xe(0,this.low<<e-32,this.unsigned)};D.shl=D.shiftLeft;D.shiftRight=function(e){return Lt(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?xe(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):xe(this.high>>e-32,this.high>=0?0:-1,this.unsigned)};D.shr=D.shiftRight;D.shiftRightUnsigned=function(e){return Lt(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?xe(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):e===32?xe(this.high,0,this.unsigned):xe(this.high>>>e-32,0,this.unsigned)};D.shru=D.shiftRightUnsigned;D.shr_u=D.shiftRightUnsigned;D.rotateLeft=function(e){var r;return Lt(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?xe(this.high,this.low,this.unsigned):e<32?(r=32-e,xe(this.low<<e|this.high>>>r,this.high<<e|this.low>>>r,this.unsigned)):(e-=32,r=32-e,xe(this.high<<e|this.low>>>r,this.low<<e|this.high>>>r,this.unsigned))};D.rotl=D.rotateLeft;D.rotateRight=function(e){var r;return Lt(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?xe(this.high,this.low,this.unsigned):e<32?(r=32-e,xe(this.high<<r|this.low>>>e,this.low<<r|this.high>>>e,this.unsigned)):(e-=32,r=32-e,xe(this.low<<r|this.high>>>e,this.high<<r|this.low>>>e,this.unsigned))};D.rotr=D.rotateRight;D.toSigned=function(){return this.unsigned?xe(this.low,this.high,!1):this};D.toUnsigned=function(){return this.unsigned?this:xe(this.low,this.high,!0)};D.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()};D.toBytesLE=function(){var e=this.high,r=this.low;return[r&255,r>>>8&255,r>>>16&255,r>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]};D.toBytesBE=function(){var e=this.high,r=this.low;return[e>>>24,e>>>16&255,e>>>8&255,e&255,r>>>24,r>>>16&255,r>>>8&255,r&255]};Ie.fromBytes=function(e,r,o){return o?Ie.fromBytesLE(e,r):Ie.fromBytesBE(e,r)};Ie.fromBytesLE=function(e,r){return new Ie(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,r)};Ie.fromBytesBE=function(e,r){return new Ie(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],r)};var ul=Ie;var kde=16;function bh(t){t==="X"&&(t="");let e=t.padEnd(kde,"0");return ul.fromString(e,!0,16)}function BE(t){if(t.isZero())return"X";let e=t.countTrailingZeros(),r=e%4;e=(e-r)/4;let o=e;e*=4;let i=t.shiftRightUnsigned(e).toString(16).replace(/0+$/,"");return Array(17-o-i.length).join("0")+i}function OE(t,e){let r=Vde(t).shiftRightUnsigned(2);return t.add(ul.fromNumber(2*e+1-4).multiply(r))}function Vde(t){return t.and(t.not().add(1))}var zde=3,Hde=30,jde=2*Hde+1,O6=180/Math.PI;function N6(t){if(t.length===0)throw new Error(`Invalid Hilbert quad key ${t}`);let e=t.split("/"),r=parseInt(e[0],10),o=e[1],n=o.length,i=0,s=[0,0];for(let a=n-1;a>=0;a--){i=n-a;let c=o[a],l=0,f=0;c==="1"?f=1:c==="2"?(l=1,f=1):c==="3"&&(l=1);let u=Math.pow(2,i-1);Wde(u,s,l,f),s[0]+=u*l,s[1]+=u*f}if(r%2===1){let a=s[0];s[0]=s[1],s[1]=a}return{face:r,ij:s,level:i}}function D6(t){if(t.isZero())return"";let e=t.toString(2);for(;e.length<zde+jde;)e="0"+e;let r=e.lastIndexOf("1"),o=e.substring(0,3),n=e.substring(3,r),i=n.length/2,s=ul.fromString(o,!0,2).toString(10),a="";if(i!==0)for(a=ul.fromString(n,!0,2).toString(4);a.length<i;)a="0"+a;return`${s}/${a}`}function FE(t,e,r){let o=1<<e;return[(t[0]+r[0])/o,(t[1]+r[1])/o]}function F6(t){return t>=.5?1/3*(4*t*t-1):1/3*(1-4*(1-t)*(1-t))}function NE(t){return[F6(t[0]),F6(t[1])]}function DE(t,[e,r]){switch(t){case 0:return[1,e,r];case 1:return[-e,1,r];case 2:return[-e,-r,1];case 3:return[-1,-r,-e];case 4:return[r,-1,-e];case 5:return[r,e,-1];default:throw new Error("Invalid face")}}function UE([t,e,r]){let o=Math.atan2(r,Math.sqrt(t*t+e*e));return[Math.atan2(e,t)*O6,o*O6]}function Wde(t,e,r,o){if(o===0){r===1&&(e[0]=t-1-e[0],e[1]=t-1-e[1]);let n=e[0];e[0]=e[1],e[1]=n}}function U6(t){let e=FE(t.ij,t.level,[.5,.5]),r=NE(e),o=DE(t.face,r);return UE(o)}var Gde=100;function kE(t){let{face:e,ij:r,level:o}=t,n=[[0,0],[0,1],[1,1],[1,0],[0,0]],i=Math.max(1,Math.ceil(Gde*Math.pow(2,-o))),s=new Float64Array(4*i*2+2),a=0,c=0;for(let l=0;l<4;l++){let f=n[l].slice(0),u=n[l+1],d=(u[0]-f[0])/i,h=(u[1]-f[1])/i;for(let p=0;p<i;p++){f[0]+=d,f[1]+=h;let m=FE(r,o,f),g=NE(m),_=DE(e,g),x=UE(_);Math.abs(x[1])>89.999&&(x[0]=c);let y=x[0]-c;x[0]+=y>180?-360:y<-180?360:0,s[a++]=x[0],s[a++]=x[1],c=x[0]}}return s[a++]=s[0],s[a++]=s[1],s}function dl(t){let e=$de(t);return N6(e)}function $de(t){if(t.indexOf("/")>0)return t;let e=bh(t);return D6(e)}function VE(t){let e=dl(t);return U6(e)}function V6(t){let e;if(t.face===2||t.face===5){let r=null,o=0;for(let n=0;n<4;n++){let i=`${t.face}/${n}`,s=dl(i),a=kE(s);(typeof r>"u"||r===null)&&(r=new Float64Array(4*a.length)),r.set(a,o),o+=a.length}e=k6(r)}else{let r=kE(t);e=k6(r)}return e}function k6(t){if(t.length%2!==0)throw new Error("Invalid corners");let e=[],r=[];for(let o=0;o<t.length;o+=2)e.push(t[o]),r.push(t[o+1]);return e.sort((o,n)=>o-n),r.sort((o,n)=>o-n),{west:e[0],east:e[e.length-1],north:r[r.length-1],south:r[0]}}function zE(t,e){let r=e?.minimumHeight||0,o=e?.maximumHeight||0,n=dl(t),i=V6(n),s=i.west,a=i.south,c=i.east,l=i.north,f=[];return f.push(new E(s,l,r)),f.push(new E(c,l,r)),f.push(new E(c,a,r)),f.push(new E(s,a,r)),f.push(new E(s,l,o)),f.push(new E(c,l,o)),f.push(new E(c,a,o)),f.push(new E(s,a,o)),f}function Jy(t){let e=t.token,r={minimumHeight:t.minimumHeight,maximumHeight:t.maximumHeight},o=zE(e,r),n=VE(e),i=n[0],s=n[1],a=de.WGS84.cartographicToCartesian([i,s,r.maximumHeight]),c=new E(a[0],a[1],a[2]);o.push(c);let l=th(o);return[...l.center,...l.halfAxes]}var Xde=4,Yde=8,Kde={QUADTREE:Xde,OCTREE:Yde};function qde(t,e,r){if(t?.box){let o=bh(t.s2VolumeInfo.token),n=OE(o,e),i=BE(n),s={...t.s2VolumeInfo};switch(s.token=i,r){case"OCTREE":let l=t.s2VolumeInfo,f=l.maximumHeight-l.minimumHeight,u=f/2,d=l.minimumHeight+f/2;l.minimumHeight=d-u,l.maximumHeight=d+u;break;default:break}return{box:Jy(s),s2VolumeInfo:s}}}async function jE(t){let{subtree:e,subtreeData:r={level:0,x:0,y:0,z:0},parentData:o={mortonIndex:0,localLevel:-1,localX:0,localY:0,localZ:0},childIndex:n=0,implicitOptions:i,loaderOptions:s,s2VolumeBox:a}=t,{subdivisionScheme:c,subtreeLevels:l,maximumLevel:f,contentUrlTemplate:u,subtreesUriTemplate:d,basePath:h}=i,p={children:[],lodMetricValue:0,contentUrl:""};if(!f)return Eb.once(`Missing 'maximumLevel' or 'availableLevels' property. The subtree ${u} won't be loaded...`),p;let m=o.localLevel+1,g=r.level+m;if(g>f)return p;let _=Kde[c],x=Math.log2(_),y=n&1,b=n>>1&1,T=n>>2&1,v=Qs(o.localX,y,1),w=Qs(o.localY,b,1),C=Qs(o.localZ,T,1),S=Qs(r.x,v,m),A=Qs(r.y,w,m),M=Qs(r.z,C,m),B=Qs(o.mortonIndex,n,x),O=m===l&&HE(e.childSubtreeAvailability,B),F,X,G,j;if(O){let pe=`${h}/${d}`,U=Qy(pe,g,S,A,M);F=await _r(U,qy,s),j=0,X={level:g,x:S,y:A,z:M},G={mortonIndex:0,localLevel:0,localX:0,localY:0,localZ:0}}else F=e,j=(_**m-1)/(_-1)+B,X=r,G={mortonIndex:B,localLevel:m,localX:v,localY:w,localZ:C};if(!HE(F.tileAvailability,j))return p;HE(F.contentAvailability,j)&&(p.contentUrl=Qy(u,g,S,A,M));for(let pe=0;pe<_;pe++){let U=qde(a,pe,c),re=await jE({subtree:F,subtreeData:X,parentData:G,childIndex:pe,implicitOptions:i,loaderOptions:s,s2VolumeBox:U});(re.contentUrl||re.children.length)&&p.children.push(re)}return p.contentUrl||p.children.length?Zde(p,{level:g,x:S,y:A,z:M},i,a):p}function HE(t,e){let r;return Array.isArray(t)?(r=t[0],t.length>1&&Eb.once('Not supported extension "3DTILES_multiple_contents" has been detected')):r=t,"constant"in r?Boolean(r.constant):r.explicitBitstream?ehe(e,r.explicitBitstream):!1}function Zde(t,e,r,o){let{basePath:n,refine:i,getRefine:s,lodMetricType:a,getTileType:c,rootLodMetricValue:l,rootBoundingVolume:f}=r,u=t.contentUrl&&t.contentUrl.replace(`${n}/`,""),d=l/2**e.level,h=o?.box?{box:o.box}:f,p=Jde(h,e,r.subdivisionScheme);return{children:t.children,contentUrl:t.contentUrl,content:{uri:u},id:t.contentUrl,refine:s(i),type:c(t),lodMetricType:a,lodMetricValue:d,geometricError:d,transform:t.transform,boundingVolume:p}}function Jde(t,e,r){if(t.region){let{level:o,x:n,y:i,z:s}=e,[a,c,l,f,u,d]=t.region,h=2**o,p=(l-a)/h,[m,g]=[a+p*n,a+p*(n+1)],_=(f-c)/h,[x,y]=[c+_*i,c+_*(i+1)],b,T;if(r==="OCTREE"){let v=(d-u)/h;[b,T]=[u+v*s,u+v*(s+1)]}else[b,T]=[u,d];return{region:[m,x,g,y,b,T]}}if(t.box)return t;throw new Error(`Unsupported bounding volume type ${JSON.stringify(t)}`)}function Qs(t,e,r){return(t<<r)+e}function Qy(t,e,r,o,n){let i=Qde({level:e,x:r,y:o,z:n});return t.replace(/{level}|{x}|{y}|{z}/gi,s=>i[s])}function Qde(t){let e={};for(let r in t)e[`{${r}}`]=t[r];return e}function ehe(t,e){let r=Math.floor(t/8),o=t%8;return(e[r]>>o&1)===1}function GE(t,e=""){if(!e)return Ur.EMPTY;let o=e.split("?")[0].split(".").pop();switch(o){case"pnts":return Ur.POINTCLOUD;case"i3dm":case"b3dm":case"glb":case"gltf":return Ur.SCENEGRAPH;default:return o||Ur.EMPTY}}function $E(t){switch(t){case"REPLACE":case"replace":return Rt.REPLACE;case"ADD":case"add":return Rt.ADD;default:return t}}function WE(t,e){if(/^[a-z][0-9a-z+.-]*:/i.test(e)){let o=new URL(t,`${e}/`);return decodeURI(o.toString())}else if(t.startsWith("/"))return t;return Ft.resolve(e,t)}function z6(t,e){if(!t)return null;let r;if(t.content){let n=t.content.uri||t.content?.url;typeof n<"u"&&(r=WE(n,e))}return{...t,id:r,contentUrl:r,lodMetricType:Rn.GEOMETRIC_ERROR,lodMetricValue:t.geometricError,transformMatrix:t.transform,type:GE(t,r),refine:$E(t.refine)}}async function W6(t,e,r){let o=null,n=j6(t.root);n&&t.root?o=await H6(t.root,t,e,n,r):o=z6(t.root,e);let i=[];for(i.push(o);i.length>0;){let s=i.pop()||{},a=s.children||[],c=[];for(let l of a){let f=j6(l),u;f?u=await H6(l,t,e,f,r):u=z6(l,e),u&&(c.push(u),i.push(u))}s.children=c}return o}async function H6(t,e,r,o,n){let{subdivisionScheme:i,maximumLevel:s,availableLevels:a,subtreeLevels:c,subtrees:{uri:l}}=o,f=Qy(l,0,0,0,0),u=WE(f,r),d=await _r(u,qy,n),h=t.content?.uri,p=h?WE(h,r):"",m=e?.root?.refine,g=t.geometricError,_=t.boundingVolume.extensions?.["3DTILES_bounding_volume_S2"];if(_){let T={box:Jy(_),s2VolumeInfo:_};t.boundingVolume=T}let x=t.boundingVolume,y={contentUrlTemplate:p,subtreesUriTemplate:l,subdivisionScheme:i,subtreeLevels:c,maximumLevel:Number.isFinite(a)?a-1:s,refine:m,basePath:r,lodMetricType:Rn.GEOMETRIC_ERROR,rootLodMetricValue:g,rootBoundingVolume:x,getTileType:GE,getRefine:$E};return await the(t,r,d,y,n)}async function the(t,e,r,o,n){if(!t)return null;let{children:i,contentUrl:s}=await jE({subtree:r,implicitOptions:o,loaderOptions:n}),a,c=null;return s&&(a=s,c={uri:s.replace(`${e}/`,"")}),{...t,id:a,contentUrl:a,lodMetricType:Rn.GEOMETRIC_ERROR,lodMetricValue:t.geometricError,transformMatrix:t.transform,type:GE(t,a),refine:$E(t.refine),content:c||t.content,children:i}}function j6(t){return t?.extensions?.["3DTILES_implicit_tiling"]||t?.implicitTiling}var ex={dataType:null,batchType:null,id:"3d-tiles",name:"3D Tiles",module:"3d-tiles",version:Wy,extensions:["cmpt","pnts","b3dm","i3dm"],mimeTypes:["application/octet-stream"],tests:["cmpt","pnts","b3dm","i3dm"],parse:rhe,options:{"3d-tiles":{loadGLTF:!0,decodeQuantizedPositions:!1,isTileset:"auto",assetGltfUpAxis:null}}};async function rhe(t,e={},r){let o=e["3d-tiles"]||{},n;return o.isTileset==="auto"?n=r?.url&&r.url.indexOf(".json")!==-1:n=o.isTileset,n?ohe(t,e,r):nhe(t,e,r)}async function ohe(t,e,r){let o=JSON.parse(new TextDecoder().decode(t)),n=r?.url||"",i=ihe(n),s=await W6(o,i,e||{});return{...o,shape:"tileset3d",loader:ex,url:n,queryString:r?.queryString||"",basePath:i,root:s||o.root,type:_t.TILES3D,lodMetricType:Rn.GEOMETRIC_ERROR,lodMetricValue:o.root?.geometricError||0}}async function nhe(t,e,r){let o={content:{shape:"tile3d",featureIds:null}};return await ME(t,0,e,r,o.content),o.content}function ihe(t){return Ft.dirname(t)}var G6=[0],she={getPointColor:{type:"accessor",value:[0,0,0,255]},pointSize:1,data:"",loader:ex,onTilesetLoad:{type:"function",value:t=>{}},onTileLoad:{type:"function",value:t=>{}},onTileUnload:{type:"function",value:t=>{}},onTileError:{type:"function",value:(t,e,r)=>{}},_getMeshColor:{type:"function",value:t=>[255,255,255]}},Ah=class extends Ne{initializeState(){"onTileLoadFail"in this.props&&N.removed("onTileLoadFail","onTileError")(),this.state={layerMap:{},tileset3d:null,activeViewports:{},lastUpdatedViewports:null}}get isLoaded(){return Boolean(this.state?.tileset3d?.isLoaded()&&super.isLoaded)}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState({props:e,oldProps:r,changeFlags:o}){if(e.data&&e.data!==r.data&&this._loadTileset(e.data),o.viewportChanged){let{activeViewports:n}=this.state;Object.keys(n).length&&(this._updateTileset(n),this.state.lastUpdatedViewports=n,this.state.activeViewports={})}if(o.propsChanged){let{layerMap:n}=this.state;for(let i in n)n[i].needsUpdate=!0}}finalizeState(e){this.state.tileset3d?.destroy(),this.state.tileset3d=null,this.state.layerMap={},this.state.activeViewports={},this.state.lastUpdatedViewports=null,super.finalizeState(e)}activateViewport(e){let{activeViewports:r,lastUpdatedViewports:o}=this.state;this.internalState.viewport=e,r[e.id]=e;let n=o?.[e.id];(!n||!e.equals(n))&&(this.setChangeFlags({viewportChanged:!0}),this.setNeedsUpdate())}getPickingInfo({info:e,sourceLayer:r}){let o=r&&r.props.tile;return e.picked&&(e.object=o),e.sourceTile=o,e}filterSubLayer({layer:e,viewport:r,cullRect:o,isPicking:n}){let{tile:i}=e.props,{id:s}=r;if(!i.selected||!i.viewportIds.includes(s))return!1;if(n&&o&&i.content?.cartographicOrigin){let[a,c]=r.project(i.content.cartographicOrigin),l=o.x+o.width/2,f=o.y+o.height/2,u=Math.max(r.width,r.height)/4,d=a-l,h=c-f;if(d*d+h*h>u*u)return!1}return!0}_updateAutoHighlight(e){let r=e.sourceTile,o=this.state.layerMap[r?.id];o&&o.layer&&o.layer.updateAutoHighlight(e)}async _loadTileset(e){let r=this.props.loadOptions||{},o=this.props.loaders?.length?this.props.loaders:this.props.loader,n=Array.isArray(o)?o[0]:o,{tileset:i,...s}=r,a={loadOptions:{...s},...i},c=e;if("preload"in n&&typeof n.preload=="function"){let u=await n.preload(e,r);u.url&&(c=u.url),u.headers&&(a.loadOptions.core={...a.loadOptions.core,fetch:{...a.loadOptions.core?.fetch,headers:u.headers}}),Object.assign(a,u)}let l=await _r(c,n,a.loadOptions),f=new xh(l,{onTileLoad:this._onTileLoad.bind(this),onTileUnload:this._onTileUnload.bind(this),onTileError:this.props.onTileError,onUpdate:()=>this.setNeedsUpdate(),...a});this.setState({tileset3d:f,layerMap:{}}),this._updateTileset(this.state.activeViewports),this.props.onTilesetLoad(f)}_onTileLoad(e){let{lastUpdatedViewports:r}=this.state;e.tileDrawn=!1,this.props.onTileLoad(e),this._updateTileset(r),this.setNeedsUpdate()}_onTileUnload(e){delete this.state.layerMap[e.id],this.props.onTileUnload(e)}_updateTileset(e){if(!e)return;let{tileset3d:r}=this.state,{timeline:o}=this.context,n=Object.keys(e).length;!o||!n||!r||r.selectTiles(Object.values(e)).then(i=>{this.state.frameNumber!==i&&this.setState({frameNumber:i})})}_getSubLayer(e,r){if(!e.content)return null;switch(e.type){case Ur.POINTCLOUD:return this._makePointCloudLayer(e,r);case Ur.SCENEGRAPH:return this._make3DModelLayer(e);case Ur.MESH:return this._makeSimpleMeshLayer(e,r);default:throw new Error(`Tile3DLayer: Failed to render layer of type ${e.content.type}`)}}_makePointCloudLayer(e,r){let{attributes:o,pointCount:n,constantRGBA:i,cartographicOrigin:s,modelMatrix:a}=e.content,{positions:c,normals:l,colors:f}=o;if(!c)return null;let u=r&&r.props.data||{header:{vertexCount:n},attributes:{POSITION:c,NORMAL:l,COLOR_0:f}},{pointSize:d,getPointColor:h}=this.props,p=this.getSubLayerClass("pointcloud",e0);return new p({pointSize:d},this.getSubLayerProps({id:"pointcloud"}),{id:`${this.id}-pointcloud-${e.id}`,tile:e,data:u,coordinateSystem:Be.METER_OFFSETS,coordinateOrigin:s,modelMatrix:a,getColor:i||h,_offset:0})}_make3DModelLayer(e){let{gltf:r,instances:o,cartographicOrigin:n,modelMatrix:i}=e.content,s=this.getSubLayerClass("scenegraph",My);return new s({_lighting:"pbr"},this.getSubLayerProps({id:"scenegraph"}),{id:`${this.id}-scenegraph-${e.id}`,tile:e,data:o||G6,scenegraph:r,coordinateSystem:Be.METER_OFFSETS,coordinateOrigin:n,modelMatrix:i,getTransformMatrix:a=>a.modelMatrix,getPosition:[0,0,0],_offset:0,onFirstDraw:()=>{e.tileDrawn=!0}})}_makeSimpleMeshLayer(e,r){let o=e.content,{attributes:n,indices:i,modelMatrix:s,cartographicOrigin:a,coordinateSystem:c=Be.METER_OFFSETS,material:l,featureIds:f}=o,{_getMeshColor:u}=this.props,d=r&&r.props.mesh||new ce({topology:"triangle-list",attributes:ahe(n),indices:i}),h=this.getSubLayerClass("mesh",vk);return new h(this.getSubLayerProps({id:"mesh"}),{id:`${this.id}-mesh-${e.id}`,tile:e,mesh:d,data:G6,getColor:u(e),pbrMaterial:l,modelMatrix:s,coordinateOrigin:a,coordinateSystem:c,featureIds:f,_offset:0})}renderLayers(){let{tileset3d:e,layerMap:r}=this.state;return e?e.tiles.map(o=>{let n=r[o.id]=r[o.id]||{tile:o},{layer:i}=n;return o.selected&&(i?n.needsUpdate&&(i=this._getSubLayer(o,i),n.needsUpdate=!1):i=this._getSubLayer(o)),n.layer=i,i}).filter(Boolean):null}};Ah.defaultProps=she;Ah.layerName="Tile3DLayer";var $6=Ah;function ahe(t){let e={};return e.positions={...t.positions,value:new Float32Array(t.positions.value)},t.normals&&(e.normals=t.normals),t.texCoords&&(e.texCoords=t.texCoords),t.colors&&(e.colors=t.colors),t.uvRegions&&(e.uvRegions=t.uvRegions),e}var che=new Map([["centerX",Float64Array.BYTES_PER_ELEMENT],["centerY",Float64Array.BYTES_PER_ELEMENT],["centerZ",Float64Array.BYTES_PER_ELEMENT],["minHeight",Float32Array.BYTES_PER_ELEMENT],["maxHeight",Float32Array.BYTES_PER_ELEMENT],["boundingSphereCenterX",Float64Array.BYTES_PER_ELEMENT],["boundingSphereCenterY",Float64Array.BYTES_PER_ELEMENT],["boundingSphereCenterZ",Float64Array.BYTES_PER_ELEMENT],["boundingSphereRadius",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointX",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointY",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointZ",Float64Array.BYTES_PER_ELEMENT]]);function XE(t){return t>>1^-(t&1)}function lhe(t){let e=0,r={};for(let[o,n]of che){let i=n===8?t.getFloat64:t.getFloat32;r[o]=i.call(t,e,!0),e+=n}return{header:r,headerEndPosition:e}}function fhe(t,e){let r=e,o=3,n=t.getUint32(r,!0),i=new Uint16Array(n*o);r+=Uint32Array.BYTES_PER_ELEMENT;let s=Uint16Array.BYTES_PER_ELEMENT,a=n*s,c=r,l=c+a,f=l+a,u=0,d=0,h=0;for(let p=0;p<n;p++)u+=XE(t.getUint16(c+s*p,!0)),d+=XE(t.getUint16(l+s*p,!0)),h+=XE(t.getUint16(f+s*p,!0)),i[p]=u,i[p+n]=d,i[p+n*2]=h;return r+=a*3,{vertexData:i,vertexDataEndPosition:r}}function Th(t,e,r,o,n=!0){let i;if(o===2?i=new Uint16Array(t,e,r):i=new Uint32Array(t,e,r),!n)return i;let s=0;for(let a=0;a<i.length;++a){let c=i[a];i[a]=s-c,c===0&&++s}return i}function uhe(t,e,r){let o=r,n=3,s=e.length/n>65536?Uint32Array.BYTES_PER_ELEMENT:Uint16Array.BYTES_PER_ELEMENT;o%s!==0&&(o+=s-o%s);let a=t.getUint32(o,!0);o+=Uint32Array.BYTES_PER_ELEMENT;let c=a*3,l=Th(t.buffer,o,c,s);return o+=c*s,{triangleIndicesEndPosition:o,triangleIndices:l}}function dhe(t,e,r){let o=r,n=3,s=e.length/n>65536?Uint32Array.BYTES_PER_ELEMENT:Uint16Array.BYTES_PER_ELEMENT,a=t.getUint32(o,!0);o+=Uint32Array.BYTES_PER_ELEMENT;let c=Th(t.buffer,o,a,s,!1);o+=a*s;let l=t.getUint32(o,!0);o+=Uint32Array.BYTES_PER_ELEMENT;let f=Th(t.buffer,o,l,s,!1);o+=l*s;let u=t.getUint32(o,!0);o+=Uint32Array.BYTES_PER_ELEMENT;let d=Th(t.buffer,o,u,s,!1);o+=u*s;let h=t.getUint32(o,!0);o+=Uint32Array.BYTES_PER_ELEMENT;let p=Th(t.buffer,o,h,s,!1);return o+=h*s,{edgeIndicesEndPosition:o,westIndices:c,southIndices:f,eastIndices:d,northIndices:p}}function hhe(t){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}function phe(t){return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}function mhe(t,e){let r={};if(t.byteLength<=e)return{extensions:r,extensionsEndPosition:e};let o=e;for(;o<t.byteLength;){let n=t.getUint8(o,!0);o+=Uint8Array.BYTES_PER_ELEMENT;let i=t.getUint32(o,!0);o+=Uint32Array.BYTES_PER_ELEMENT;let s=new DataView(t.buffer,o,i);switch(n){case 1:{r.vertexNormals=hhe(s);break}case 2:{r.waterMask=phe(s);break}default:}o+=i}return{extensions:r,extensionsEndPosition:o}}var ea={header:0,vertices:1,triangleIndices:2,edgeIndices:3,extensions:4},ghe={maxDecodingStep:ea.extensions};function YE(t,e){let r=Object.assign({},ghe,e),o=new DataView(t),{header:n,headerEndPosition:i}=lhe(o);if(r.maxDecodingStep<ea.vertices)return{header:n};let{vertexData:s,vertexDataEndPosition:a}=fhe(o,i);if(r.maxDecodingStep<ea.triangleIndices)return{header:n,vertexData:s};let{triangleIndices:c,triangleIndicesEndPosition:l}=uhe(o,s,a);if(r.maxDecodingStep<ea.edgeIndices)return{header:n,vertexData:s,triangleIndices:c};let{westIndices:f,southIndices:u,eastIndices:d,northIndices:h,edgeIndicesEndPosition:p}=dhe(o,s,l);if(r.maxDecodingStep<ea.extensions)return{header:n,vertexData:s,triangleIndices:c,westIndices:f,northIndices:h,eastIndices:d,southIndices:u};let{extensions:m}=mhe(o,p);return{header:n,vertexData:s,triangleIndices:c,westIndices:f,northIndices:h,eastIndices:d,southIndices:u,extensions:m}}function tx(t,e,r,o){let n=o?yhe(o,t.POSITION.value):_he(e),i=new t.POSITION.value.constructor(n.length*6),s=new t.TEXCOORD_0.value.constructor(n.length*4),a=new e.constructor(n.length*6);for(let l=0;l<n.length;l++){let f=n[l];xhe({edge:f,edgeIndex:l,attributes:t,skirtHeight:r,newPosition:i,newTexcoord0:s,newTriangles:a})}t.POSITION.value=ql(t.POSITION.value,i),t.TEXCOORD_0.value=ql(t.TEXCOORD_0.value,s);let c=e instanceof Array?e.concat(a):ql(e,a);return{attributes:t,triangles:c}}function _he(t){let e=[];for(let n=0;n<t.length;n+=3)e.push([t[n],t[n+1]]),e.push([t[n+1],t[n+2]]),e.push([t[n+2],t[n]]);e.sort((n,i)=>Math.min(...n)-Math.min(...i)||Math.max(...n)-Math.max(...i));let r=[],o=0;for(;o<e.length;)e[o][0]===e[o+1]?.[1]&&e[o][1]===e[o+1]?.[0]?o+=2:(r.push(e[o]),o++);return r}function yhe(t,e){t.westIndices.sort((o,n)=>e[3*o+1]-e[3*n+1]),t.eastIndices.sort((o,n)=>e[3*n+1]-e[3*o+1]),t.southIndices.sort((o,n)=>e[3*n]-e[3*o]),t.northIndices.sort((o,n)=>e[3*o]-e[3*n]);let r=[];for(let o in t){let n=t[o];for(let i=0;i<n.length-1;i++)r.push([n[i],n[i+1]])}return r}function xhe({edge:t,edgeIndex:e,attributes:r,skirtHeight:o,newPosition:n,newTexcoord0:i,newTriangles:s}){let a=r.POSITION.value.length,c=e*2,l=e*2+1;n.set(r.POSITION.value.subarray(t[0]*3,t[0]*3+3),c*3),n[c*3+2]=n[c*3+2]-o,n.set(r.POSITION.value.subarray(t[1]*3,t[1]*3+3),l*3),n[l*3+2]=n[l*3+2]-o,i.set(r.TEXCOORD_0.value.subarray(t[0]*2,t[0]*2+2),c*2),i.set(r.TEXCOORD_0.value.subarray(t[1]*2,t[1]*2+2),l*2);let f=e*2*3;s[f]=t[0],s[f+1]=a/3+l,s[f+2]=t[1],s[f+3]=a/3+l,s[f+4]=t[0],s[f+5]=a/3+c}function KE(t,e={}){let{bounds:r}=e,{header:o,vertexData:n,triangleIndices:i,westIndices:s,northIndices:a,eastIndices:c,southIndices:l}=YE(t,ea.triangleIndices),f=i,u=bhe(n,o,r),d=Ki(u);if(e?.skirtHeight){let{attributes:h,triangles:p}=tx(u,f,e.skirtHeight,{westIndices:s,northIndices:a,eastIndices:c,southIndices:l});u=h,f=p}return{loaderData:{header:{}},header:{vertexCount:f.length,boundingBox:d},schema:void 0,topology:"triangle-list",mode:4,indices:{value:f,size:1},attributes:u}}function bhe(t,e,r){let{minHeight:o,maxHeight:n}=e,[i,s,a,c]=r||[0,0,1,1],l=a-i,f=c-s,u=n-o,d=t.length/3,h=new Float32Array(d*3),p=new Float32Array(d*2);for(let m=0;m<d;m++){let g=t[m]/32767,_=t[m+d]/32767,x=t[m+d*2]/32767;h[3*m+0]=g*l+i,h[3*m+1]=_*f+s,h[3*m+2]=x*u+o,p[2*m+0]=g,p[2*m+1]=_}return{POSITION:{value:h,size:3},TEXCOORD_0:{value:p,size:2}}}var vh=class{constructor(e=257){this.gridSize=e;let r=e-1;if(r&r-1)throw new Error(`Expected grid size to be 2^n+1, got ${e}.`);this.numTriangles=r*r*2-2,this.numParentTriangles=this.numTriangles-r*r,this.indices=new Uint32Array(this.gridSize*this.gridSize),this.coords=new Uint16Array(this.numTriangles*4);for(let o=0;o<this.numTriangles;o++){let n=o+2,i=0,s=0,a=0,c=0,l=0,f=0;for(n&1?a=c=l=r:i=s=f=r;(n>>=1)>1;){let d=i+a>>1,h=s+c>>1;n&1?(a=i,c=s,i=l,s=f):(i=a,s=c,a=l,c=f),l=d,f=h}let u=o*4;this.coords[u+0]=i,this.coords[u+1]=s,this.coords[u+2]=a,this.coords[u+3]=c}}createTile(e){return new qE(e,this)}},qE=class{constructor(e,r){let o=r.gridSize;if(e.length!==o*o)throw new Error(`Expected terrain data of length ${o*o} (${o} x ${o}), got ${e.length}.`);this.terrain=e,this.martini=r,this.errors=new Float32Array(e.length),this.update()}update(){let{numTriangles:e,numParentTriangles:r,coords:o,gridSize:n}=this.martini,{terrain:i,errors:s}=this;for(let a=e-1;a>=0;a--){let c=a*4,l=o[c+0],f=o[c+1],u=o[c+2],d=o[c+3],h=l+u>>1,p=f+d>>1,m=h+p-f,g=p+l-h,_=(i[f*n+l]+i[d*n+u])/2,x=p*n+h,y=Math.abs(_-i[x]);if(s[x]=Math.max(s[x],y),a<r){let b=(f+g>>1)*n+(l+m>>1),T=(d+g>>1)*n+(u+m>>1);s[x]=Math.max(s[x],s[b],s[T])}}}getMesh(e=0){let{gridSize:r,indices:o}=this.martini,{errors:n}=this,i=0,s=0,a=r-1;o.fill(0);function c(h,p,m,g,_,x){let y=h+m>>1,b=p+g>>1;Math.abs(h-_)+Math.abs(p-x)>1&&n[b*r+y]>e?(c(_,x,h,p,y,b),c(m,g,_,x,y,b)):(o[p*r+h]=o[p*r+h]||++i,o[g*r+m]=o[g*r+m]||++i,o[x*r+_]=o[x*r+_]||++i,s++)}c(0,0,a,a,a,0),c(a,a,0,0,0,a);let l=new Uint16Array(i*2),f=new Uint32Array(s*3),u=0;function d(h,p,m,g,_,x){let y=h+m>>1,b=p+g>>1;if(Math.abs(h-_)+Math.abs(p-x)>1&&n[b*r+y]>e)d(_,x,h,p,y,b),d(m,g,_,x,y,b);else{let T=o[p*r+h]-1,v=o[g*r+m]-1,w=o[x*r+_]-1;l[2*T]=h,l[2*T+1]=p,l[2*v]=m,l[2*v+1]=g,l[2*w]=_,l[2*w+1]=x,f[u++]=T,f[u++]=v,f[u++]=w}}return d(0,0,a,a,a,0),d(a,a,0,0,0,a),{vertices:l,triangles:f}}};var Sh=class{constructor(e,r,o=r){this.data=e,this.width=r,this.height=o,this.coords=[],this.triangles=[],this._halfedges=[],this._candidates=[],this._queueIndices=[],this._queue=[],this._errors=[],this._rms=[],this._pending=[],this._pendingLen=0,this._rmsSum=0;let n=r-1,i=o-1,s=this._addPoint(0,0),a=this._addPoint(n,0),c=this._addPoint(0,i),l=this._addPoint(n,i),f=this._addTriangle(l,s,c,-1,-1,-1);this._addTriangle(s,l,a,f,-1,-1),this._flush()}run(e=1){for(;this.getMaxError()>e;)this.refine()}refine(){this._step(),this._flush()}getMaxError(){return this._errors[0]}getRMSD(){return this._rmsSum>0?Math.sqrt(this._rmsSum/(this.width*this.height)):0}heightAt(e,r){return this.data[this.width*r+e]}_flush(){let e=this.coords;for(let r=0;r<this._pendingLen;r++){let o=this._pending[r],n=2*this.triangles[o*3+0],i=2*this.triangles[o*3+1],s=2*this.triangles[o*3+2];this._findCandidate(e[n],e[n+1],e[i],e[i+1],e[s],e[s+1],o)}this._pendingLen=0}_findCandidate(e,r,o,n,i,s,a){let c=Math.min(e,o,i),l=Math.min(r,n,s),f=Math.max(e,o,i),u=Math.max(r,n,s),d=ta(o,n,i,s,c,l),h=ta(i,s,e,r,c,l),p=ta(e,r,o,n,c,l),m=n-r,g=e-o,_=s-n,x=o-i,y=r-s,b=i-e,T=ta(e,r,o,n,i,s),v=this.heightAt(e,r)/T,w=this.heightAt(o,n)/T,C=this.heightAt(i,s)/T,S=0,A=0,M=0,B=0;for(let O=l;O<=u;O++){let F=0;d<0&&_!==0&&(F=Math.max(F,Math.floor(-d/_))),h<0&&y!==0&&(F=Math.max(F,Math.floor(-h/y))),p<0&&m!==0&&(F=Math.max(F,Math.floor(-p/m)));let X=d+_*F,G=h+y*F,j=p+m*F,se=!1;for(let ne=c+F;ne<=f;ne++){if(X>=0&&G>=0&&j>=0){se=!0;let pe=v*X+w*G+C*j,U=Math.abs(pe-this.heightAt(ne,O));B+=U*U,U>S&&(S=U,A=ne,M=O)}else if(se)break;X+=_,G+=y,j+=m}d+=x,h+=b,p+=g}(A===e&&M===r||A===o&&M===n||A===i&&M===s)&&(S=0),this._candidates[2*a]=A,this._candidates[2*a+1]=M,this._rms[a]=B,this._queuePush(a,S,B)}_step(){let e=this._queuePop(),r=e*3+0,o=e*3+1,n=e*3+2,i=this.triangles[r],s=this.triangles[o],a=this.triangles[n],c=this.coords[2*i],l=this.coords[2*i+1],f=this.coords[2*s],u=this.coords[2*s+1],d=this.coords[2*a],h=this.coords[2*a+1],p=this._candidates[2*e],m=this._candidates[2*e+1],g=this._addPoint(p,m);if(ta(c,l,f,u,p,m)===0)this._handleCollinear(g,r);else if(ta(f,u,d,h,p,m)===0)this._handleCollinear(g,o);else if(ta(d,h,c,l,p,m)===0)this._handleCollinear(g,n);else{let _=this._halfedges[r],x=this._halfedges[o],y=this._halfedges[n],b=this._addTriangle(i,s,g,_,-1,-1,r),T=this._addTriangle(s,a,g,x,-1,b+1),v=this._addTriangle(a,i,g,y,b+2,T+1);this._legalize(b),this._legalize(T),this._legalize(v)}}_addPoint(e,r){let o=this.coords.length>>1;return this.coords.push(e,r),o}_addTriangle(e,r,o,n,i,s,a=this.triangles.length){let c=a/3;return this.triangles[a+0]=e,this.triangles[a+1]=r,this.triangles[a+2]=o,this._halfedges[a+0]=n,this._halfedges[a+1]=i,this._halfedges[a+2]=s,n>=0&&(this._halfedges[n]=a+0),i>=0&&(this._halfedges[i]=a+1),s>=0&&(this._halfedges[s]=a+2),this._candidates[2*c+0]=0,this._candidates[2*c+1]=0,this._queueIndices[c]=-1,this._rms[c]=0,this._pending[this._pendingLen++]=c,a}_legalize(e){let r=this._halfedges[e];if(r<0)return;let o=e-e%3,n=r-r%3,i=o+(e+1)%3,s=o+(e+2)%3,a=n+(r+2)%3,c=n+(r+1)%3,l=this.triangles[s],f=this.triangles[e],u=this.triangles[i],d=this.triangles[a],h=this.coords;if(!Ahe(h[2*l],h[2*l+1],h[2*f],h[2*f+1],h[2*u],h[2*u+1],h[2*d],h[2*d+1]))return;let p=this._halfedges[i],m=this._halfedges[s],g=this._halfedges[a],_=this._halfedges[c];this._queueRemove(o/3),this._queueRemove(n/3);let x=this._addTriangle(l,d,u,-1,g,p,o),y=this._addTriangle(d,l,f,x,m,_,n);this._legalize(x+1),this._legalize(y+2)}_handleCollinear(e,r){let o=r-r%3,n=o+(r+1)%3,i=o+(r+2)%3,s=this.triangles[i],a=this.triangles[r],c=this.triangles[n],l=this._halfedges[n],f=this._halfedges[i],u=this._halfedges[r];if(u<0){let v=this._addTriangle(e,s,a,-1,f,-1,o),w=this._addTriangle(s,e,c,v,-1,l);this._legalize(v+1),this._legalize(w+2);return}let d=u-u%3,h=d+(u+2)%3,p=d+(u+1)%3,m=this.triangles[h],g=this._halfedges[h],_=this._halfedges[p];this._queueRemove(d/3);let x=this._addTriangle(s,a,e,f,-1,-1,o),y=this._addTriangle(a,m,e,_,-1,x+1,d),b=this._addTriangle(m,c,e,g,-1,y+1),T=this._addTriangle(c,s,e,l,x+2,b+1);this._legalize(x),this._legalize(y),this._legalize(b),this._legalize(T)}_queuePush(e,r,o){let n=this._queue.length;this._queueIndices[e]=n,this._queue.push(e),this._errors.push(r),this._rmsSum+=o,this._queueUp(n)}_queuePop(){let e=this._queue.length-1;return this._queueSwap(0,e),this._queueDown(0,e),this._queuePopBack()}_queuePopBack(){let e=this._queue.pop();return this._errors.pop(),this._rmsSum-=this._rms[e],this._queueIndices[e]=-1,e}_queueRemove(e){let r=this._queueIndices[e];if(r<0){let n=this._pending.indexOf(e);if(n!==-1)this._pending[n]=this._pending[--this._pendingLen];else throw new Error("Broken triangulation (something went wrong).");return}let o=this._queue.length-1;o!==r&&(this._queueSwap(r,o),this._queueDown(r,o)||this._queueUp(r)),this._queuePopBack()}_queueLess(e,r){return this._errors[e]>this._errors[r]}_queueSwap(e,r){let o=this._queue[e],n=this._queue[r];this._queue[e]=n,this._queue[r]=o,this._queueIndices[o]=r,this._queueIndices[n]=e;let i=this._errors[e];this._errors[e]=this._errors[r],this._errors[r]=i}_queueUp(e){let r=e;for(;;){let o=r-1>>1;if(o===r||!this._queueLess(r,o))break;this._queueSwap(o,r),r=o}}_queueDown(e,r){let o=e;for(;;){let n=2*o+1;if(n>=r||n<0)break;let i=n+1,s=n;if(i<r&&this._queueLess(i,n)&&(s=i),!this._queueLess(s,o))break;this._queueSwap(o,s),o=s}return o>e}};function ta(t,e,r,o,n,i){return(r-n)*(e-i)-(o-i)*(t-n)}function Ahe(t,e,r,o,n,i,s,a){let c=t-s,l=e-a,f=r-s,u=o-a,d=n-s,h=i-a,p=c*c+l*l,m=f*f+u*u,g=d*d+h*h;return c*(u*g-m*h)-l*(f*g-m*d)+p*(f*h-u*d)<0}function K6(t,e){let{meshMaxError:r,bounds:o,elevationDecoder:n}=e,{data:i,width:s,height:a}=t,c,l;switch(e.tesselator){case"martini":c=rx(i,s,a,n,e.tesselator),l=X6(r,s,c);break;case"delatin":c=rx(i,s,a,n,e.tesselator),l=Y6(r,s,a,c);break;default:s===a&&!(a&s-1)?(c=rx(i,s,a,n,"martini"),l=X6(r,s,c)):(c=rx(i,s,a,n,"delatin"),l=Y6(r,s,a,c));break}let{vertices:f}=l,{triangles:u}=l,d=The(f,c,s,a,o),h=Ki(d);if(e.skirtHeight){let{attributes:p,triangles:m}=tx(d,u,e.skirtHeight);d=p,u=m}return{loaderData:{header:{}},header:{vertexCount:u.length,boundingBox:h},mode:4,indices:{value:Uint32Array.from(u),size:1},attributes:d}}function X6(t,e,r){let o=e+1,i=new vh(o).createTile(r),{vertices:s,triangles:a}=i.getMesh(t);return{vertices:s,triangles:a}}function Y6(t,e,r,o){let n=new Sh(o,e+1,r+1);n.run(t);let{coords:i,triangles:s}=n;return{vertices:i,triangles:s}}function rx(t,e,r,o,n){let{rScaler:i,bScaler:s,gScaler:a,offset:c}=o,l=new Float32Array((e+1)*(r+1));for(let f=0,u=0;u<r;u++)for(let d=0;d<e;d++,f++){let h=f*4,p=t[h+0],m=t[h+1],g=t[h+2];l[f+u]=p*i+m*a+g*s+c}if(n==="martini"){for(let f=(e+1)*e,u=0;u<e;u++,f++)l[f]=l[f-e-1];for(let f=r,u=0;u<r+1;u++,f+=r+1)l[f]=l[f-1]}return l}function The(t,e,r,o,n){let i=r+1,s=t.length/2,a=new Float32Array(s*3),c=new Float32Array(s*2),[l,f,u,d]=n||[0,0,r,o],h=(u-l)/r,p=(d-f)/o;for(let m=0;m<s;m++){let g=t[m*2],_=t[m*2+1],x=_*i+g;a[3*m+0]=g*h+l,a[3*m+1]=-_*p+d,a[3*m+2]=e[x],c[2*m+0]=g/r,c[2*m+1]=_/o}return{POSITION:{value:a,size:3},TEXCOORD_0:{value:c,size:2}}}var ox="4.4.3";var nx={dataType:null,batchType:null,name:"Terrain",id:"terrain",module:"terrain",version:ox,worker:!0,extensions:["png","pngraw","jpg","jpeg","gif","webp","bmp"],mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/bmp"],options:{terrain:{tesselator:"auto",bounds:void 0,meshMaxError:10,elevationDecoder:{rScaler:1,gScaler:0,bScaler:0,offset:0},skirtHeight:void 0}}};var q6={dataType:null,batchType:null,name:"Quantized Mesh",id:"quantized-mesh",module:"terrain",version:ox,worker:!0,extensions:["terrain"],mimeTypes:["application/vnd.quantized-mesh"],options:{"quantized-mesh":{bounds:[0,0,1,1],skirtHeight:null}}};var vhe={...nx,parse:She};async function She(t,e,r){let o={...e,core:{...e?.core,mimeType:"application/x.image"},image:{...e?.image,type:"data"}},n=await nr(t,[],o,r),i={...vhe.options.terrain,...e?.terrain};return K6(n,i)}var iot={...q6,parseSync:(t,e)=>KE(t,e?.["quantized-mesh"]),parse:async(t,e)=>KE(t,e?.["quantized-mesh"])};var Z6=[1],Che={...Ws.defaultProps,elevationData:Pi,texture:{...Pi,optional:!0},meshMaxError:{type:"number",value:4},bounds:{type:"array",value:null,optional:!0,compare:!0},color:{type:"color",value:[255,255,255]},elevationDecoder:{type:"object",value:{rScaler:1,gScaler:0,bScaler:0,offset:0}},workerUrl:"",wireframe:!1,material:!0,loaders:[nx]};function J6(t){return Array.isArray(t)?t.join(";"):t||""}var Ch=class extends Ne{updateState({props:e,oldProps:r}){let o=e.elevationData!==r.elevationData;if(o){let{elevationData:i}=e,s=i&&(Array.isArray(i)||Ehe(i));this.setState({isTiled:s})}let n=o||e.meshMaxError!==r.meshMaxError||e.elevationDecoder!==r.elevationDecoder||e.bounds!==r.bounds;if(!this.state.isTiled&&n){let i=this.loadTerrain(e);this.setState({terrain:i})}e.workerUrl&&N.removed("workerUrl","loadOptions.terrain.workerUrl")()}loadTerrain({elevationData:e,bounds:r,elevationDecoder:o,meshMaxError:n,signal:i}){if(!e)return null;let s=this.getLoadOptions();s={...s,terrain:{skirtHeight:this.state.isTiled?n*2:0,...s?.terrain,bounds:r,meshMaxError:n,elevationDecoder:o}};let{fetch:a}=this.props;return a(e,{propName:"elevationData",layer:this,loadOptions:s,signal:i})}getTiledTerrainData(e){let{elevationData:r,fetch:o,texture:n,elevationDecoder:i,meshMaxError:s}=this.props,{viewport:a}=this.context,c=Yo(r,e),l=n&&Yo(n,e),{signal:f}=e,u=[0,0],d=[0,0];if(a.isGeospatial){let g=e.bbox;u=a.projectFlat([g.west,g.south]),d=a.projectFlat([g.east,g.north])}else{let g=e.bbox;u=[g.left,g.bottom],d=[g.right,g.top]}let h=[u[0],u[1],d[0],d[1]],p=this.loadTerrain({elevationData:c,bounds:h,elevationDecoder:i,meshMaxError:s,signal:f}),m=l?o(l,{propName:"texture",layer:this,loaders:[],signal:f}).catch(g=>null):Promise.resolve(null);return Promise.all([p,m])}renderSubLayers(e){let r=this.getSubLayerClass("mesh",Gs),{color:o,wireframe:n,material:i}=this.props,{data:s}=e;if(!s)return null;let[a,c]=s;return new r(e,{data:Z6,mesh:a,texture:c,_instanced:!1,coordinateSystem:Be.CARTESIAN,getPosition:l=>[0,0,0],getColor:o,wireframe:n,material:i})}onViewportLoad(e){if(!e)return;let{zRange:r}=this.state,o=e.map(s=>s.content).filter(Boolean).map(s=>s[0].header.boundingBox.map(c=>c[2]));if(o.length===0)return;let n=Math.min(...o.map(s=>s[0])),i=Math.max(...o.map(s=>s[1]));(!r||n<r[0]||i>r[1])&&this.setState({zRange:[n,i]})}renderLayers(){let{color:e,material:r,elevationData:o,texture:n,wireframe:i,meshMaxError:s,elevationDecoder:a,tileSize:c,maxZoom:l,minZoom:f,extent:u,maxRequests:d,onTileLoad:h,onTileUnload:p,onTileError:m,maxCacheSize:g,maxCacheByteSize:_,refinementStrategy:x,zoomOffset:y}=this.props;if(this.state.isTiled)return new Ws(this.getSubLayerProps({id:"tiles"}),{getTileData:this.getTiledTerrainData.bind(this),renderSubLayers:this.renderSubLayers.bind(this),updateTriggers:{getTileData:{elevationData:J6(o),texture:J6(n),meshMaxError:s,elevationDecoder:a,projectionMode:this.context.viewport.projectionMode,zoomOffset:y}},onViewportLoad:this.onViewportLoad.bind(this),zRange:this.state.zRange||null,tileSize:c,maxZoom:l,minZoom:f,extent:u,maxRequests:d,onTileLoad:h,onTileUnload:p,onTileError:m,maxCacheSize:g,maxCacheByteSize:_,refinementStrategy:x,zoomOffset:y});if(!o)return null;let b=this.getSubLayerClass("mesh",Gs);return new b(this.getSubLayerProps({id:"mesh"}),{data:Z6,mesh:this.state.terrain,texture:n,_instanced:!1,getPosition:T=>[0,0,0],getColor:e,material:r,wireframe:i})}};Ch.defaultProps=Che;Ch.layerName="TerrainLayer";var Q6=Ch,Ehe=t=>t.includes("{x}")&&(t.includes("{y}")||t.includes("{-y}"));var eV=`layout(std140) uniform brushingUniforms { bool enabled; highp int target; vec2 mousePos; float radius; } brushing; `,whe=` in vec2 brushingTargets; out float brushing_isVisible; bool brushing_isPointInRange(vec2 position) { if (!brushing.enabled) { return true; } vec2 source_commonspace = project_position(position); vec2 target_commonspace = project_position(brushing.mousePos); float distance = length((target_commonspace - source_commonspace) / project.commonUnitsPerMeter.xy); return distance <= brushing.radius; } bool brushing_arePointsInRange(vec2 sourcePos, vec2 targetPos) { return brushing_isPointInRange(sourcePos) || brushing_isPointInRange(targetPos); } void brushing_setVisible(bool visible) { brushing_isVisible = float(visible); } `,Phe=` ${eV} ${whe} `,Mhe=` in float brushing_isVisible; `,Rhe=` ${eV} ${Mhe} `,Ihe={source:0,target:1,custom:2,source_target:3},Lhe={"vs:DECKGL_FILTER_GL_POSITION":` vec2 brushingTarget; vec2 brushingSource; if (brushing.target == 3) { brushingTarget = geometry.worldPositionAlt.xy; brushingSource = geometry.worldPosition.xy; } else if (brushing.target == 0) { brushingTarget = geometry.worldPosition.xy; } else if (brushing.target == 1) { brushingTarget = geometry.worldPositionAlt.xy; } else { brushingTarget = brushingTargets; } bool visible; if (brushing.target == 3) { visible = brushing_arePointsInRange(brushingSource, brushingTarget); } else { visible = brushing_isPointInRange(brushingTarget); } brushing_setVisible(visible); `,"fs:DECKGL_FILTER_COLOR":` if (brushing.enabled && brushing_isVisible < 0.5) { discard; } `},tV={name:"brushing",dependencies:[We],vs:Phe,fs:Rhe,inject:Lhe,getUniforms:t=>{if(!t||!("viewport"in t))return{};let{brushingEnabled:e=!0,brushingRadius:r=1e4,brushingTarget:o="source",mousePosition:n,viewport:i}=t;return{enabled:Boolean(e&&n&&i.containsPixel(n)),radius:r,target:Ihe[o]||0,mousePos:n?i.unproject([n.x-i.x,n.y-i.y]):[0,0]}},uniformTypes:{enabled:"i32",target:"i32",mousePos:"vec2<f32>",radius:"f32"}};var Bhe={getBrushingTarget:{type:"accessor",value:[0,0]},brushingTarget:"source",brushingEnabled:!0,brushingRadius:1e4},Eh=class extends st{getShaders(){return{modules:[tV]}}initializeState(e,r){let o=this.getAttributeManager();o&&o.add({brushingTargets:{size:2,stepMode:"dynamic",accessor:"getBrushingTarget"}});let n=()=>{this.getCurrentLayer()?.setNeedsRedraw()};this.state.onMouseMove=n,e.deck&&e.deck.eventManager.on({pointermove:n,pointerleave:n})}finalizeState(e,r){if(e.deck){let o=this.state.onMouseMove;e.deck.eventManager.off({pointermove:o,pointerleave:o})}}draw(e,r){let{viewport:o,mousePosition:n}=e.context,{brushingEnabled:i,brushingRadius:s,brushingTarget:a}=this.props,c={viewport:o,mousePosition:n,brushingEnabled:i,brushingRadius:s,brushingTarget:a};this.setShaderModuleProps({brushing:c})}};Eh.defaultProps=Bhe;Eh.extensionName="BrushingExtension";var rV=Eh;var oV=`layout(std140) uniform dataFilterUniforms { bool useSoftMargin; bool enabled; bool transformSize; bool transformColor; vec4 min; vec4 softMin; vec4 softMax; vec4 max; vec4 min64High; vec4 max64High; highp uvec4 categoryBitMask; } dataFilter; `,Ohe=` #ifdef DATAFILTER_TYPE in DATAFILTER_TYPE filterValues; #ifdef DATAFILTER_DOUBLE in DATAFILTER_TYPE filterValues64Low; #endif #endif #ifdef DATACATEGORY_TYPE in DATACATEGORY_TYPE filterCategoryValues; #endif out float dataFilter_value; #ifdef DATAFILTER_TYPE float dataFilter_getMin(float _) { return dataFilter.min.x; } vec2 dataFilter_getMin(vec2 _) { return dataFilter.min.xy; } vec3 dataFilter_getMin(vec3 _) { return dataFilter.min.xyz; } vec4 dataFilter_getMin(vec4 _) { return dataFilter.min; } float dataFilter_getSoftMin(float _) { return dataFilter.softMin.x; } vec2 dataFilter_getSoftMin(vec2 _) { return dataFilter.softMin.xy; } vec3 dataFilter_getSoftMin(vec3 _) { return dataFilter.softMin.xyz; } vec4 dataFilter_getSoftMin(vec4 _) { return dataFilter.softMin; } float dataFilter_getSoftMax(float _) { return dataFilter.softMax.x; } vec2 dataFilter_getSoftMax(vec2 _) { return dataFilter.softMax.xy; } vec3 dataFilter_getSoftMax(vec3 _) { return dataFilter.softMax.xyz; } vec4 dataFilter_getSoftMax(vec4 _) { return dataFilter.softMax; } float dataFilter_getMax(float _) { return dataFilter.max.x; } vec2 dataFilter_getMax(vec2 _) { return dataFilter.max.xy; } vec3 dataFilter_getMax(vec3 _) { return dataFilter.max.xyz; } vec4 dataFilter_getMax(vec4 _) { return dataFilter.max; } float dataFilter_getMin64High(float _) { return dataFilter.min64High.x; } vec2 dataFilter_getMin64High(vec2 _) { return dataFilter.min64High.xy; } vec3 dataFilter_getMin64High(vec3 _) { return dataFilter.min64High.xyz; } vec4 dataFilter_getMin64High(vec4 _) { return dataFilter.min64High; } float dataFilter_getMax64High(float _) { return dataFilter.max64High.x; } vec2 dataFilter_getMax64High(vec2 _) { return dataFilter.max64High.xy; } vec3 dataFilter_getMax64High(vec3 _) { return dataFilter.max64High.xyz; } vec4 dataFilter_getMax64High(vec4 _) { return dataFilter.max64High; } #endif float dataFilter_reduceValue(float value) { return value; } float dataFilter_reduceValue(vec2 value) { return min(value.x, value.y); } float dataFilter_reduceValue(vec3 value) { return min(min(value.x, value.y), value.z); } float dataFilter_reduceValue(vec4 value) { return min(min(value.x, value.y), min(value.z, value.w)); } #ifdef DATAFILTER_TYPE void dataFilter_setValue(DATAFILTER_TYPE valueFromMin, DATAFILTER_TYPE valueFromMax) { DATAFILTER_TYPE dataFilter_min = dataFilter_getMin(valueFromMin); DATAFILTER_TYPE dataFilter_softMin = dataFilter_getSoftMin(valueFromMin); DATAFILTER_TYPE dataFilter_softMax = dataFilter_getSoftMax(valueFromMin); DATAFILTER_TYPE dataFilter_max = dataFilter_getMax(valueFromMin); if (dataFilter.useSoftMargin) { // smoothstep results are undefined if edge0 \u2265 edge1 // Fallback to ignore filterSoftRange if it is truncated by filterRange DATAFILTER_TYPE leftInRange = mix( smoothstep(dataFilter_min, dataFilter_softMin, valueFromMin), step(dataFilter_min, valueFromMin), step(dataFilter_softMin, dataFilter_min) ); DATAFILTER_TYPE rightInRange = mix( 1.0 - smoothstep(dataFilter_softMax, dataFilter_max, valueFromMax), step(valueFromMax, dataFilter_max), step(dataFilter_max, dataFilter_softMax) ); dataFilter_value = dataFilter_reduceValue(leftInRange * rightInRange); } else { dataFilter_value = dataFilter_reduceValue( step(dataFilter_min, valueFromMin) * step(valueFromMax, dataFilter_max) ); } } #endif #ifdef DATACATEGORY_TYPE void dataFilter_setCategoryValue(DATACATEGORY_TYPE category) { #if DATACATEGORY_CHANNELS == 1 // One 128-bit mask uint dataFilter_masks = dataFilter.categoryBitMask[category / 32u]; #elif DATACATEGORY_CHANNELS == 2 // Two 64-bit masks uvec2 dataFilter_masks = uvec2( dataFilter.categoryBitMask[category.x / 32u], dataFilter.categoryBitMask[category.y / 32u + 2u] ); #elif DATACATEGORY_CHANNELS == 3 // Three 32-bit masks uvec3 dataFilter_masks = dataFilter.categoryBitMask.xyz; #else // Four 32-bit masks uvec4 dataFilter_masks = dataFilter.categoryBitMask; #endif // Shift mask and extract relevant bits DATACATEGORY_TYPE dataFilter_bits = DATACATEGORY_TYPE(dataFilter_masks) >> (category & 31u); dataFilter_bits &= 1u; #if DATACATEGORY_CHANNELS == 1 if (dataFilter_bits == 0u) dataFilter_value = 0.0; #else if (any(equal(dataFilter_bits, DATACATEGORY_TYPE(0u)))) dataFilter_value = 0.0; #endif } #endif `,nV=` ${oV} ${Ohe} `,Fhe=` in float dataFilter_value; `,iV=` ${oV} ${Fhe} `;function sV(t){if(!t||!("extensions"in t))return{};let{filterRange:e=[-1,1],filterEnabled:r=!0,filterTransformSize:o=!0,filterTransformColor:n=!0,categoryBitMask:i}=t,s=t.filterSoftRange||e,a=c=>Array.isArray(c)?[c[0]||0,c[1]||0,c[2]||0,c[3]||0]:[c,0,0,0];return{...Number.isFinite(e[0])?{min:a(e[0]),softMin:a(s[0]),softMax:a(s[1]),max:a(e[1])}:{min:a(e.map(c=>c[0])),softMin:a(s.map(c=>c[0])),softMax:a(s.map(c=>c[1])),max:a(e.map(c=>c[1]))},enabled:r,useSoftMargin:Boolean(t.filterSoftRange),transformSize:r&&o,transformColor:r&&n,...i&&{categoryBitMask:i}}}function Nhe(t){if(!t||!("extensions"in t))return{};let e=sV(t),r=e.min.map(Math.fround);e.min=e.min.map((n,i)=>n-r[i]),e.softMin=e.softMin.map((n,i)=>n-r[i]),e.min64High=r;let o=e.max.map(Math.fround);return e.max=e.max.map((n,i)=>n-o[i]),e.softMax=e.softMax.map((n,i)=>n-o[i]),e.max64High=o,e}var aV={"vs:#main-start":` dataFilter_value = 1.0; if (dataFilter.enabled) { #ifdef DATAFILTER_TYPE #ifdef DATAFILTER_DOUBLE dataFilter_setValue( filterValues - dataFilter_getMin64High(filterValues) + filterValues64Low, filterValues - dataFilter_getMax64High(filterValues) + filterValues64Low ); #else dataFilter_setValue(filterValues, filterValues); #endif #endif #ifdef DATACATEGORY_TYPE dataFilter_setCategoryValue(filterCategoryValues); #endif } `,"vs:#main-end":` if (dataFilter_value == 0.0) { gl_Position = vec4(0.); } `,"vs:DECKGL_FILTER_SIZE":` if (dataFilter.transformSize) { size = size * dataFilter_value; } `,"fs:DECKGL_FILTER_COLOR":` if (dataFilter_value == 0.0) discard; if (dataFilter.transformColor) { color.a *= dataFilter_value; } `};function cV(t){return{useSoftMargin:"i32",enabled:"i32",transformSize:"i32",transformColor:"i32",min:"vec4<f32>",softMin:"vec4<f32>",softMax:"vec4<f32>",max:"vec4<f32>",min64High:"vec4<f32>",max64High:"vec4<f32>",categoryBitMask:"vec4<u32>"}}var lV={name:"dataFilter",vs:nV,fs:iV,inject:aV,getUniforms:sV,uniformTypesFromOptions:cV},fV={name:"dataFilter",vs:nV,fs:iV,inject:aV,getUniforms:Nhe,uniformTypesFromOptions:cV};var Dhe=`#version 300 es #define SHADER_NAME data-filter-vertex-shader #ifdef FLOAT_TARGET in float filterIndices; in float filterPrevIndices; #else in vec2 filterIndices; in vec2 filterPrevIndices; #endif out vec4 vColor; const float component = 1.0 / 255.0; void main() { #ifdef FLOAT_TARGET dataFilter_value *= float(filterIndices != filterPrevIndices); gl_Position = vec4(0.0, 0.0, 0.0, 1.0); vColor = vec4(0.0, 0.0, 0.0, 1.0); #else // Float texture is not supported: pack result into 4 channels x 256 px x 64px dataFilter_value *= float(filterIndices.x != filterPrevIndices.x); float col = filterIndices.x; float row = filterIndices.y * 4.0; float channel = floor(row); row = fract(row); vColor = component * vec4(bvec4(channel == 0.0, channel == 1.0, channel == 2.0, channel == 3.0)); gl_Position = vec4(col * 2.0 - 1.0, row * 2.0 - 1.0, 0.0, 1.0); #endif gl_PointSize = 1.0; } `,Uhe=`#version 300 es #define SHADER_NAME data-filter-fragment-shader precision highp float; in vec4 vColor; out vec4 fragColor; void main() { if (dataFilter_value < 0.5) { discard; } fragColor = vColor; } `,khe=["float32-renderable-webgl","texture-blend-float-webgl"];function uV(t){return khe.every(e=>t.features.has(e))}function dV(t,e){return e?t.createFramebuffer({width:1,height:1,colorAttachments:[t.createTexture({format:"rgba32float",dimension:"2d",width:1,height:1})]}):t.createFramebuffer({width:256,height:64,colorAttachments:[t.createTexture({format:"rgba8unorm",dimension:"2d",width:256,height:64})]})}function hV(t,e,r,o){return r.defines.NON_INSTANCED_MODEL=1,o&&(r.defines.FLOAT_TARGET=1),new Q(t,{id:"data-filter-aggregation-model",vertexCount:1,isInstanced:!1,topology:"point-list",disableWarnings:!0,vs:Dhe,fs:Uhe,bufferLayout:e,...r})}var pV={blend:!0,blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",blendColorOperation:"add",blendAlphaOperation:"add",depthCompare:"never"};var zhe={getFilterValue:{type:"accessor",value:0},getFilterCategory:{type:"accessor",value:0},onFilteredItemsChange:{type:"function",value:null,optional:!0},filterEnabled:!0,filterRange:[-1,1],filterSoftRange:null,filterCategories:[0],filterTransformSize:!0,filterTransformColor:!0},Hhe={categorySize:0,filterSize:1,fp64:!1,countItems:!1},jhe={1:"uint",2:"uvec2",3:"uvec3",4:"uvec4"},Whe={1:"float",2:"vec2",3:"vec3",4:"vec4"},wh=class extends st{constructor(e={}){super({...Hhe,...e})}getShaders(e){let{categorySize:r,filterSize:o,fp64:n}=e.opts,i={};r&&(i.DATACATEGORY_TYPE=jhe[r],i.DATACATEGORY_CHANNELS=r),o&&(i.DATAFILTER_TYPE=Whe[o],i.DATAFILTER_DOUBLE=Boolean(n));let s=n?fV:lV;return s.uniformTypes=s.uniformTypesFromOptions(e.opts),{modules:[s],defines:i}}initializeState(e,r){let o=this.getAttributeManager(),{categorySize:n,filterSize:i,fp64:s}=r.opts;o&&(i&&o.add({filterValues:{size:i,type:s?"float64":"float32",stepMode:"dynamic",accessor:"getFilterValue"}}),n&&o.add({filterCategoryValues:{size:n,stepMode:"dynamic",accessor:"getFilterCategory",type:"uint32",transform:n===1?c=>r._getCategoryKey.call(this,c,0):c=>c.map((l,f)=>r._getCategoryKey.call(this,l,f))}}));let{device:a}=this.context;if(o&&r.opts.countItems){let c=uV(a);o.add({filterVertexIndices:{size:c?1:2,vertexOffset:1,type:"unorm8",accessor:(u,{index:d})=>{let h=u&&u.__source?u.__source.index:d;return c?(h+1)%255:[(h+1)%255,Math.floor(h/255)%255]},shaderAttributes:{filterPrevIndices:{vertexOffset:0},filterIndices:{vertexOffset:1}}}});let l=dV(a,c),f=hV(a,o.getBufferLayouts({isInstanced:!1}),r.getShaders.call(this,r),c);this.setState({filterFBO:l,filterModel:f})}}updateState({props:e,oldProps:r,changeFlags:o},n){let i=this.getAttributeManager(),{categorySize:s}=n.opts;if(this.state.filterModel){let a=i.attributes.filterValues?.needsUpdate()||i.attributes.filterCategoryValues?.needsUpdate()||e.filterEnabled!==r.filterEnabled||e.filterRange!==r.filterRange||e.filterSoftRange!==r.filterSoftRange||e.filterCategories!==r.filterCategories;a&&this.setState({filterNeedsUpdate:a})}i?.attributes.filterCategoryValues&&((i.attributes.filterCategoryValues.needsUpdate()||!ie(e.filterCategories,r.filterCategories,2))&&this.setState({categoryBitMask:null}),o.dataChanged&&(this.setState({categoryMap:Array(s).fill(0).map(()=>({}))}),i.attributes.filterCategoryValues.setNeedsUpdate("categoryMap")))}draw(e,r){let o=this.state.filterFBO,n=this.state.filterModel,i=this.state.filterNeedsUpdate;this.state.categoryBitMask||r._updateCategoryBitMask.call(this,e,r);let{onFilteredItemsChange:s,extensions:a,filterEnabled:c,filterRange:l,filterSoftRange:f,filterTransformSize:u,filterTransformColor:d,filterCategories:h}=this.props,p={extensions:a,filterEnabled:c,filterRange:l,filterSoftRange:f,filterTransformSize:u,filterTransformColor:d,filterCategories:h};if(this.state.categoryBitMask&&(p.categoryBitMask=this.state.categoryBitMask),this.setShaderModuleProps({dataFilter:p}),i&&s&&n){let m=this.getAttributeManager(),{attributes:{filterValues:g,filterCategoryValues:_,filterVertexIndices:x}}=m;n.setVertexCount(this.getNumInstances());let y={...g?.getValue(),..._?.getValue(),...x?.getValue()};n.setAttributes(y),n.shaderInputs.setProps({dataFilter:p});let b=[0,0,o.width,o.height],T=n.device.beginRenderPass({id:"data-filter-aggregation",framebuffer:o,parameters:{viewport:b},clearColor:[0,0,0,0]});n.setParameters(pV),n.draw(T),T.end();let v=n.device.readPixelsToArrayWebGL(o),w=0;for(let C=0;C<v.length;C++)w+=v[C];s({id:this.id,count:w}),this.state.filterNeedsUpdate=!1}}finalizeState(){let e=this.state.filterFBO,r=this.state.filterModel;e?.destroy(),r?.destroy()}_updateCategoryBitMask(e,r){let{categorySize:o}=r.opts;if(!o)return;let{filterCategories:n}=this.props,i=new Uint32Array([0,0,0,0]),s=o===1?[n]:n,a=o===1?128:o===2?64:32;for(let c=0;c<s.length;c++){let l=s[c];for(let f of l){let u=r._getCategoryKey.call(this,f,c);if(u<a){let d=c*(a/32)+Math.floor(u/32);i[d]+=Math.pow(2,u%32)}else N.warn(`Exceeded maximum number of categories (${a})`)()}}this.state.categoryBitMask=i}_getCategoryKey(e,r){let o=this.state.categoryMap[r];return e in o||(o[e]=Object.keys(o).length),o[e]}};wh.defaultProps=zhe;wh.extensionName="DataFilterExtension";var mV=wh;var gV=`const vec2 WORLD_SCALE_FP64 = vec2(81.4873275756836, 0.0000032873668232014097); layout(std140) uniform project64Uniforms { vec2 scale; mat4 viewProjectionMatrix; mat4 viewProjectionMatrix64Low; } project64; void mercatorProject_fp64(vec4 lnglat_fp64, out vec2 out_val[2]) { #if defined(NVIDIA_FP64_WORKAROUND) out_val[0] = sum_fp64(radians_fp64(lnglat_fp64.xy), PI_FP64 * ONE); #else out_val[0] = sum_fp64(radians_fp64(lnglat_fp64.xy), PI_FP64); #endif out_val[1] = sum_fp64(PI_FP64, log_fp64(tan_fp64(sum_fp64(PI_4_FP64, radians_fp64(lnglat_fp64.zw) / 2.0)))); return; } void project_position_fp64(vec4 position_fp64, out vec2 out_val[2]) { vec2 pos_fp64[2]; mercatorProject_fp64(position_fp64, pos_fp64); out_val[0] = mul_fp64(pos_fp64[0], WORLD_SCALE_FP64); out_val[1] = mul_fp64(pos_fp64[1], WORLD_SCALE_FP64); return; } void project_position_fp64(vec2 position, vec2 position64xyLow, out vec2 out_val[2]) { vec4 position64xy = vec4( position.x, position64xyLow.x, position.y, position64xyLow.y); project_position_fp64(position64xy, out_val); } vec4 project_common_position_to_clipspace_fp64(vec2 vertex_pos_modelspace[4]) { vec2 vertex_pos_clipspace[4]; vec2 viewProjectionMatrixFP64[16]; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { viewProjectionMatrixFP64[4 * i + j] = vec2( project64.viewProjectionMatrix[j][i], project64.viewProjectionMatrix64Low[j][i] ); } } mat4_vec4_mul_fp64(viewProjectionMatrixFP64, vertex_pos_modelspace, vertex_pos_clipspace); return vec4( vertex_pos_clipspace[0].x, vertex_pos_clipspace[1].x, vertex_pos_clipspace[2].x, vertex_pos_clipspace[3].x ); } vec4 project_position_to_clipspace( vec3 position, vec3 position64xyLow, vec3 offset, out vec4 commonPosition ) { vec2 offset64[4]; vec4_fp64(vec4(offset, 0.0), offset64); float z = project_size(position.z); vec2 projectedPosition64xy[2]; project_position_fp64(position.xy, position64xyLow.xy, projectedPosition64xy); vec2 commonPosition64[4]; commonPosition64[0] = sum_fp64(offset64[0], projectedPosition64xy[0]); commonPosition64[1] = sum_fp64(offset64[1], projectedPosition64xy[1]); commonPosition64[2] = sum_fp64(offset64[2], vec2(z, 0.0)); commonPosition64[3] = vec2(1.0, 0.0); commonPosition = vec4(projectedPosition64xy[0].x, projectedPosition64xy[1].x, z, 1.0); return project_common_position_to_clipspace_fp64(commonPosition64); } vec4 project_position_to_clipspace( vec3 position, vec3 position64xyLow, vec3 offset ) { vec4 commonPosition; return project_position_to_clipspace( position, position64xyLow, offset, commonPosition ); } `;var{fp64ify:Ghe,fp64ifyMatrix4:$he}=Am,ix={name:"project64",dependencies:[We,Am],vs:gV,getUniforms:Yhe,uniformTypes:{scale:"vec2<f32>",viewProjectionMatrix:"mat4x4<f32>",viewProjectionMatrix64Low:"mat4x4<f32>"}},Xhe=Yt(Khe);function Yhe(t){if(t&&"viewport"in t){let{viewProjectionMatrix:e,scale:r}=t.viewport;return Xhe({viewProjectionMatrix:e,scale:r})}return{}}function Khe({viewProjectionMatrix:t,scale:e}){let r=$he(t),o=new Float32Array(16),n=new Float32Array(16);for(let i=0;i<4;i++)for(let s=0;s<4;s++){let a=4*i+s,c=4*s+i;o[c]=r[2*a],n[c]=r[2*a+1]}return{scale:Ghe(e),viewProjectionMatrix:[...o],viewProjectionMatrix64Low:[...n]}}var sx=class extends st{getShaders(){let{coordinateSystem:e}=this.props;if(e!=="lnglat"&&e!=="default")throw new Error("fp64: coordinateSystem must be LNGLAT");return{modules:[ix]}}draw(e,r){let{viewport:o}=e.context;this.setShaderModuleProps({project64:{viewport:o}})}};sx.extensionName="Fp64Extension";var _V=sx;var yV={inject:{"vs:#decl":` in vec2 instanceDashArrays; #ifdef HIGH_PRECISION_DASH in float instanceDashOffsets; #endif out vec2 vDashArray; out float vDashOffset; `,"vs:#main-end":` vDashArray = instanceDashArrays; #ifdef HIGH_PRECISION_DASH vDashOffset = instanceDashOffsets / width.x; #else vDashOffset = 0.0; #endif `,"fs:#decl":` layout(std140) uniform pathStyleUniforms { float dashAlignMode; bool dashGapPickable; } pathStyle; in vec2 vDashArray; in float vDashOffset; `,"fs:#main-start":` float solidLength = vDashArray.x; float gapLength = vDashArray.y; float unitLength = solidLength + gapLength; float offset; if (unitLength > 0.0) { if (pathStyle.dashAlignMode == 0.0) { offset = vDashOffset; } else { unitLength = vPathLength / round(vPathLength / unitLength); offset = solidLength / 2.0; } float unitOffset = mod(vPathPosition.y + offset, unitLength); if (gapLength > 0.0 && unitOffset > solidLength) { if (path.capType <= 0.5) { if (!(pathStyle.dashGapPickable && bool(picking.isActive))) { discard; } } else { float distToEnd = length(vec2( min(unitOffset - solidLength, unitLength - unitOffset), vPathPosition.x )); if (distToEnd > 1.0) { if (!(pathStyle.dashGapPickable && bool(picking.isActive))) { discard; } } } } } `}},xV={inject:{"vs:#decl":` in vec2 instanceDashArrays; out vec2 vDashArray; `,"vs:#main-end":` vDashArray = instanceDashArrays; `,"fs:#decl":` layout(std140) uniform pathStyleUniforms { bool dashGapPickable; } pathStyle; in vec2 vDashArray; #define PI 3.141592653589793 `,"fs:#main-start":` bool inDashGap = false; float dashUnitLength = vDashArray.x + vDashArray.y; if (dashUnitLength > 0.0 && scatterplot.stroked > 0.5) { float _distToCenter = length(unitPosition) * outerRadiusPixels; float innerRadius = innerUnitRadius * outerRadiusPixels; if (_distToCenter >= innerRadius) { float strokeWidth = (1.0 - innerUnitRadius) * outerRadiusPixels; float midStrokeRadius = (innerUnitRadius + 1.0) * 0.5 * outerRadiusPixels; float angle = atan(unitPosition.y, unitPosition.x) + PI; float circumference = 2.0 * PI * midStrokeRadius; float posAlongStroke = (angle / (2.0 * PI)) * circumference / strokeWidth; float unitOffset = mod(posAlongStroke, dashUnitLength); if (unitOffset > vDashArray.x) { if (scatterplot.filled > 0.5) { inDashGap = true; } else { if (!(pathStyle.dashGapPickable && bool(picking.isActive))) { discard; } } } } } `,"fs:#main-end":` if (inDashGap) { float alphaFactor = fragColor.a / max(vLineColor.a, 0.001); fragColor = vec4(vFillColor.rgb, vFillColor.a * alphaFactor); fragColor = picking_filterPickingColor(fragColor); fragColor = picking_filterHighlightColor(fragColor); } `}},bV={inject:{"vs:#decl":` in vec2 instanceDashArrays; out vec2 vDashArray; `,"vs:#main-end":` vDashArray = instanceDashArrays; `,"fs:#decl":` layout(std140) uniform pathStyleUniforms { bool dashGapPickable; } pathStyle; in vec2 vDashArray; #define PI 3.141592653589793 float getPerimeterPosition(vec2 fragUV, vec2 dims, vec4 radii, float lineWidth) { float width = dims.x; float height = dims.y; float maxRadius = min(width, height) * 0.5; float rBL = min(radii.w, maxRadius); float rTL = min(radii.z, maxRadius); float rTR = min(radii.x, maxRadius); float rBR = min(radii.y, maxRadius); vec2 p = fragUV * dims; float leftLen = height - rBL - rTL; float topLen = width - rTL - rTR; float rightLen = height - rTR - rBR; float bottomLen = width - rBR - rBL; float arcBL = PI * 0.5 * rBL; float arcTL = PI * 0.5 * rTL; float arcTR = PI * 0.5 * rTR; float arcBR = PI * 0.5 * rBR; float pos = 0.0; float distLeft = p.x; float distRight = width - p.x; float distBottom = p.y; float distTop = height - p.y; float minDist = min(min(distLeft, distRight), min(distBottom, distTop)); if (p.x < rBL && p.y < rBL) { vec2 c = vec2(rBL, rBL); vec2 d = p - c; float angle = atan(-d.x, -d.y); pos = angle / (PI * 0.5) * arcBL; } else if (p.x < rTL && p.y > height - rTL) { vec2 c = vec2(rTL, height - rTL); vec2 d = p - c; float angle = atan(d.y, -d.x); pos = arcBL + leftLen + angle / (PI * 0.5) * arcTL; } else if (p.x > width - rTR && p.y > height - rTR) { vec2 c = vec2(width - rTR, height - rTR); vec2 d = p - c; float angle = atan(d.x, d.y); pos = arcBL + leftLen + arcTL + topLen + angle / (PI * 0.5) * arcTR; } else if (p.x > width - rBR && p.y < rBR) { vec2 c = vec2(width - rBR, rBR); vec2 d = p - c; float angle = atan(-d.y, d.x); pos = arcBL + leftLen + arcTL + topLen + arcTR + rightLen + angle / (PI * 0.5) * arcBR; } else if (minDist == distLeft) { pos = arcBL + clamp(p.y - rBL, 0.0, leftLen); } else if (minDist == distTop) { pos = arcBL + leftLen + arcTL + clamp(p.x - rTL, 0.0, topLen); } else if (minDist == distRight) { pos = arcBL + leftLen + arcTL + topLen + arcTR + clamp(height - rTR - p.y, 0.0, rightLen); } else { pos = arcBL + leftLen + arcTL + topLen + arcTR + rightLen + arcBR + clamp(width - rBR - p.x, 0.0, bottomLen); } return pos / lineWidth; } float getRectPerimeterPosition(vec2 fragUV, vec2 dims, float lineWidth) { float width = dims.x; float height = dims.y; float distLeft = fragUV.x * width; float distRight = (1.0 - fragUV.x) * width; float distBottom = fragUV.y * height; float distTop = (1.0 - fragUV.y) * height; float minDist = min(min(distLeft, distRight), min(distBottom, distTop)); float pos = 0.0; if (minDist == distLeft) { pos = fragUV.y * height; } else if (minDist == distTop) { pos = height + fragUV.x * width; } else if (minDist == distRight) { pos = height + width + (1.0 - fragUV.y) * height; } else { pos = 2.0 * height + width + (1.0 - fragUV.x) * width; } return pos / lineWidth; } `,"fs:#main-start":` bool inDashGap = false; float dashUnitLength = vDashArray.x + vDashArray.y; if (dashUnitLength > 0.0 && textBackground.stroked) { float distToEdge; bool hasRoundedCorners = textBackground.borderRadius != vec4(0.0); if (hasRoundedCorners) { distToEdge = round_rect(uv, dimensions, textBackground.borderRadius); } else { distToEdge = rect(uv, dimensions); } if (distToEdge <= vLineWidth && distToEdge >= 0.0) { float posAlongStroke; if (hasRoundedCorners) { posAlongStroke = getPerimeterPosition(uv, dimensions, textBackground.borderRadius, vLineWidth); } else { posAlongStroke = getRectPerimeterPosition(uv, dimensions, vLineWidth); } float unitOffset = mod(posAlongStroke, dashUnitLength); if (unitOffset > vDashArray.x) { if (vFillColor.a > 0.0) { inDashGap = true; } else { if (!(pathStyle.dashGapPickable && bool(picking.isActive))) { discard; } } } } } `,"fs:#main-end":` if (inDashGap) { float alphaFactor = fragColor.a / max(vLineColor.a, 0.001); fragColor = vec4(vFillColor.rgb, vFillColor.a * alphaFactor); fragColor = picking_filterPickingColor(fragColor); fragColor = picking_filterHighlightColor(fragColor); } `}},AV={inject:{"vs:#decl":` in float instanceOffsets; `,"vs:DECKGL_FILTER_SIZE":` float offsetWidth = abs(instanceOffsets * 2.0) + 1.0; size *= offsetWidth; `,"vs:#main-end":` float offsetWidth = abs(instanceOffsets * 2.0) + 1.0; float offsetDir = sign(instanceOffsets); vPathPosition.x = (vPathPosition.x + offsetDir) * offsetWidth - offsetDir; vPathPosition.y *= offsetWidth; vPathLength *= offsetWidth; `,"fs:#main-start":` float isInside; isInside = step(-1.0, vPathPosition.x) * step(vPathPosition.x, 1.0); if (isInside == 0.0) { discard; } `}};var qhe={getDashArray:{type:"accessor",value:[0,0]},getOffset:{type:"accessor",value:0},dashJustified:!1,dashGapPickable:!1},Ph=class extends st{constructor({dash:e=!1,offset:r=!1,highPrecisionDash:o=!1}={}){super({dash:e||o,offset:r,highPrecisionDash:o})}getLayerType(e){if("pathTesselator"in e.state)return"path";let r=e.constructor.layerName;return r==="ScatterplotLayer"?"scatterplot":r==="TextBackgroundLayer"?"textBackground":null}isEnabled(e){return this.getLayerType(e)!==null}getShaders(e){let r=e.getLayerType(this);if(!r)return null;if(r==="scatterplot"||r==="textBackground")return e.opts.dash?{modules:[{name:"pathStyle",inject:r==="scatterplot"?xV.inject:bV.inject,uniformTypes:{dashGapPickable:"i32"}}]}:null;let o={},n={};e.opts.dash&&(o=mi(o,yV),e.opts.highPrecisionDash&&(n.HIGH_PRECISION_DASH=!0)),e.opts.offset&&(o=mi(o,AV));let{inject:i}=o;return{modules:[{name:"pathStyle",inject:i,uniformTypes:{dashAlignMode:"f32",dashGapPickable:"i32"}}],defines:n}}initializeState(e,r){let o=this.getAttributeManager(),n=r.getLayerType(this);!o||!n||(r.opts.dash&&o.addInstanced({instanceDashArrays:{size:2,accessor:"getDashArray"},...n==="path"&&r.opts.highPrecisionDash?{instanceDashOffsets:{size:1,accessor:"getPath",transform:r.getDashOffsets.bind(this)}}:{}}),n==="path"&&r.opts.offset&&o.addInstanced({instanceOffsets:{size:1,accessor:"getOffset"}}))}updateState(e,r){if(r.isEnabled(this)&&r.opts.dash){let o=r.getLayerType(this);if(o==="scatterplot"||o==="textBackground"){let n={dashGapPickable:Boolean(this.props.dashGapPickable)};this.setShaderModuleProps({pathStyle:n})}else{let n={dashAlignMode:this.props.dashJustified?1:0,dashGapPickable:Boolean(this.props.dashGapPickable)};this.setShaderModuleProps({pathStyle:n})}}}getDashOffsets(e){let r=[0],o=this.props.positionFormat==="XY"?2:3,n=Array.isArray(e[0]),i=n?e.length:e.length/o,s,a;for(let c=0;c<i-1;c++)s=n?e[c]:e.slice(c*o,c*o+o),s=this.projectPosition(s),c>0&&(r[c]=r[c-1]+Ke.dist(a,s)),a=s;return r[i-1]=0,r}};Ph.defaultProps=qhe;Ph.extensionName="PathStyleExtension";var TV=Ph;var vV=`layout(std140) uniform fillUniforms { vec2 patternTextureSize; bool patternEnabled; bool patternMask; vec2 uvCoordinateOrigin; vec2 uvCoordinateOrigin64Low; } fill; `,Zhe=` in vec4 fillPatternFrames; in float fillPatternScales; in vec2 fillPatternOffsets; out vec2 fill_uv; out vec4 fill_patternBounds; out vec4 fill_patternPlacement; `,Jhe=` ${vV} ${Zhe} `,Qhe=` uniform sampler2D fill_patternTexture; in vec4 fill_patternBounds; in vec4 fill_patternPlacement; in vec2 fill_uv; const float FILL_UV_SCALE = 512.0 / 40000000.0; `,epe=` ${vV} ${Qhe} `,tpe={"vs:DECKGL_FILTER_GL_POSITION":` fill_uv = geometry.position.xy; `,"vs:DECKGL_FILTER_COLOR":` if (fill.patternEnabled) { fill_patternBounds = fillPatternFrames / vec4(fill.patternTextureSize, fill.patternTextureSize); fill_patternPlacement.xy = fillPatternOffsets; fill_patternPlacement.zw = fillPatternScales * fillPatternFrames.zw; } `,"fs:DECKGL_FILTER_COLOR":` if (fill.patternEnabled) { vec2 scale = FILL_UV_SCALE * fill_patternPlacement.zw; vec2 patternUV = mod(mod(fill.uvCoordinateOrigin, scale) + fill.uvCoordinateOrigin64Low + fill_uv, scale) / scale; patternUV = mod(fill_patternPlacement.xy + patternUV, 1.0); vec2 texCoords = fill_patternBounds.xy + fill_patternBounds.zw * patternUV; vec4 patternColor = texture(fill_patternTexture, texCoords); color.a *= patternColor.a; if (!fill.patternMask) { color.rgb = patternColor.rgb; } } `};function rpe(t){if(!t)return{};let e={};if("fillPatternTexture"in t){let{fillPatternTexture:r}=t;e.fill_patternTexture=r,e.patternTextureSize=[r.width,r.height]}if("project"in t){let{fillPatternMask:r=!0,fillPatternEnabled:o=!0}=t,n=We.getUniforms(t.project),{commonOrigin:i}=n,s=[sc(i[0]),sc(i[1])];e.uvCoordinateOrigin=i.slice(0,2),e.uvCoordinateOrigin64Low=s,e.patternMask=r,e.patternEnabled=o}return e}var SV={name:"fill",vs:Jhe,fs:epe,inject:tpe,dependencies:[We],getUniforms:rpe,uniformTypes:{patternTextureSize:"vec2<f32>",patternEnabled:"i32",patternMask:"i32",uvCoordinateOrigin:"vec2<f32>",uvCoordinateOrigin64Low:"vec2<f32>"}};var ope={fillPatternEnabled:!0,fillPatternAtlas:{type:"image",value:null,async:!0,parameters:{lodMaxClamp:0}},fillPatternMapping:{type:"object",value:{},async:!0},fillPatternMask:!0,getFillPattern:{type:"accessor",value:t=>t.pattern},getFillPatternScale:{type:"accessor",value:1},getFillPatternOffset:{type:"accessor",value:[0,0]}},Mh=class extends st{constructor({pattern:e=!1}={}){super({pattern:e})}isEnabled(e){return e.getAttributeManager()!==null&&!("pathTesselator"in e.state)}getShaders(e){return e.isEnabled(this)?{modules:[e.opts.pattern&&SV].filter(Boolean)}:null}initializeState(e,r){if(!r.isEnabled(this))return;let o=this.getAttributeManager();r.opts.pattern&&o.add({fillPatternFrames:{size:4,stepMode:"dynamic",accessor:"getFillPattern",transform:r.getPatternFrame.bind(this)},fillPatternScales:{size:1,stepMode:"dynamic",accessor:"getFillPatternScale",defaultValue:1},fillPatternOffsets:{size:2,stepMode:"dynamic",accessor:"getFillPatternOffset"}}),this.setState({emptyTexture:this.context.device.createTexture({data:new Uint8Array(4),width:1,height:1})})}updateState({props:e,oldProps:r},o){o.isEnabled(this)&&e.fillPatternMapping&&e.fillPatternMapping!==r.fillPatternMapping&&this.getAttributeManager().invalidate("getFillPattern")}draw(e,r){if(!r.isEnabled(this))return;let{fillPatternAtlas:o,fillPatternEnabled:n,fillPatternMask:i}=this.props,s={project:e.shaderModuleProps.project,fillPatternEnabled:n,fillPatternMask:i,fillPatternTexture:o||this.state.emptyTexture};this.setShaderModuleProps({fill:s})}finalizeState(){this.state.emptyTexture?.delete()}getPatternFrame(e){let{fillPatternMapping:r}=this.getCurrentLayer().props,o=r&&r[e];return o?[o.x,o.y,o.width,o.height]:[0,0,0,0]}};Mh.defaultProps=ope;Mh.extensionName="FillStyleExtension";var CV=Mh;var npe={clipBounds:[0,0,1,1],clipByInstance:void 0},EV=` layout(std140) uniform clipUniforms { vec4 bounds; } clip; bool clip_isInBounds(vec2 position) { return position.x >= clip.bounds[0] && position.y >= clip.bounds[1] && position.x < clip.bounds[2] && position.y < clip.bounds[3]; } `,ipe={name:"clip",vs:EV,uniformTypes:{bounds:"vec4<f32>"}},spe={"vs:#decl":` out float clip_isVisible; `,"vs:DECKGL_FILTER_GL_POSITION":` clip_isVisible = float(clip_isInBounds(geometry.worldPosition.xy)); `,"fs:#decl":` in float clip_isVisible; `,"fs:DECKGL_FILTER_COLOR":` if (clip_isVisible < 0.5) discard; `},ape={name:"clip",fs:EV,uniformTypes:{bounds:"vec4<f32>"}},cpe={"vs:#decl":` out vec2 clip_commonPosition; `,"vs:DECKGL_FILTER_GL_POSITION":` clip_commonPosition = geometry.position.xy; `,"fs:#decl":` in vec2 clip_commonPosition; `,"fs:DECKGL_FILTER_COLOR":` if (!clip_isInBounds(clip_commonPosition)) discard; `},Rh=class extends st{getShaders(){let e="instancePositions"in this.getAttributeManager().attributes;return this.props.clipByInstance!==void 0&&(e=Boolean(this.props.clipByInstance)),this.state.clipByInstance=e,e?{modules:[ipe],inject:spe}:{modules:[ape],inject:cpe}}draw(){let{clipBounds:e}=this.props,r={};if(this.state.clipByInstance)r.bounds=e;else{let o=this.projectPosition([e[0],e[1],0]),n=this.projectPosition([e[2],e[3],0]);r.bounds=[Math.min(o[0],n[0]),Math.min(o[1],n[1]),Math.max(o[0],n[0]),Math.max(o[1],n[1])]}this.setShaderModuleProps({clip:r})}};Rh.defaultProps=npe;Rh.extensionName="ClipExtension";var ax=Rh;var lpe=` in float collisionPriorities; uniform sampler2D collision_texture; layout(std140) uniform collisionUniforms { bool sort; bool enabled; } collision; vec2 collision_getCoords(vec4 position) { vec4 collision_clipspace = project_common_position_to_clipspace(position); return (1.0 + collision_clipspace.xy / collision_clipspace.w) / 2.0; } float collision_match(vec2 tex, vec3 pickingColor) { vec4 collision_pickingColor = texture(collision_texture, tex); float delta = dot(abs(collision_pickingColor.rgb - pickingColor), vec3(1.0)); float e = 0.001; return step(delta, e); } float collision_isVisible(vec2 texCoords, vec3 pickingColor) { if (!collision.enabled) { return 1.0; } // Visibility test, sample area of 5x5 pixels in order to fade in/out. // Due to the locality, the lookups will be cached // This reduces the flicker present when objects are shown/hidden const int N = 2; float accumulator = 0.0; vec2 step = vec2(1.0 / project.viewportSize); const float floatN = float(N); vec2 delta = -floatN * step; for(int i = -N; i <= N; i++) { delta.x = -step.x * floatN; for(int j = -N; j <= N; j++) { accumulator += collision_match(texCoords + delta, pickingColor); delta.x += step.x; } delta.y += step.y; } float W = 2.0 * floatN + 1.0; return pow(accumulator / (W * W), 2.2); } `,fpe={"vs:#decl":` float collision_fade = 1.0; `,"vs:DECKGL_FILTER_GL_POSITION":` if (collision.sort) { float collisionPriority = collisionPriorities; position.z = -0.001 * collisionPriority * position.w; // Support range -1000 -> 1000 } if (collision.enabled) { vec4 collision_common_position = project_position(vec4(geometry.worldPosition, 1.0)); vec2 collision_texCoords = collision_getCoords(collision_common_position); collision_fade = collision_isVisible(collision_texCoords, geometry.pickingColor / 255.0); if (collision_fade < 0.0001) { // Position outside clip space bounds to discard position = vec4(0.0, 0.0, 2.0, 1.0); } } `,"vs:DECKGL_FILTER_COLOR":` color.a *= collision_fade; `},upe=t=>{if(!t||!("dummyCollisionMap"in t))return{};let{enabled:e,collisionFBO:r,drawToCollisionMap:o,dummyCollisionMap:n}=t;return{enabled:e&&!o,sort:Boolean(o),collision_texture:!o&&r?r.colorAttachments[0]:n}},wV={name:"collision",dependencies:[We],vs:lpe,inject:fpe,getUniforms:upe,uniformTypes:{sort:"i32",enabled:"i32"}};var Ih=class extends At{renderCollisionMap(e,r){let n=[0,0,0,0],i=[1,1,e.width-2*1,e.height-2*1];this.render({...r,clearColor:n,scissorRect:i,target:e,pass:"collision"})}getLayerParameters(e,r,o){return{...e.props.parameters,blend:!1,depthWriteEnabled:!0,depthCompare:"less-equal"}}getShaderModuleProps(){return{collision:{drawToCollisionMap:!0},picking:{isActive:1,isAttribute:!1},lighting:{enabled:!1}}}};var ZE=2,Lh=class{constructor(){this.id="collision-filter-effect",this.props=null,this.useInPicking=!0,this.order=1,this.channels={},this.collisionFBOs={}}setup(e){this.context=e;let{device:r}=e;this.dummyCollisionMap=r.createTexture({width:1,height:1}),this.collisionFilterPass=new Ih(r,{id:"default-collision-filter"})}preRender({effects:e,layers:r,layerFilter:o,viewports:n,onViewportActive:i,views:s,isPicking:a,preRenderStats:c={}}){let{device:l}=this.context;if(a)return;let f=r.filter(({props:{visible:g,collisionEnabled:_}})=>g&&_);if(f.length===0){this.channels={};return}let u=e?.filter(g=>g.useInPicking&&c[g.id]),d=c["mask-effect"]?.didRender,h=this._groupByCollisionGroup(l,f),p=n[0],m=!this.lastViewport||!this.lastViewport.equals(p)||d;for(let g in h){let _=this.collisionFBOs[g],x=h[g],[y,b]=l.canvasContext.getPixelSize();_.resize({width:y/ZE,height:b/ZE}),this._render(x,{effects:u,layerFilter:o,onViewportActive:i,views:s,viewport:p,viewportChanged:m})}}_render(e,{effects:r,layerFilter:o,onViewportActive:n,views:i,viewport:s,viewportChanged:a}){let{collisionGroup:c}=e,l=this.channels[c];if(!l)return;let f=a||e===l||!ie(l.layers,e.layers,1)||e.layerBounds.some((u,d)=>!Ce(u,l.layerBounds[d]))||e.allLayersLoaded!==l.allLayersLoaded||e.layers.some(u=>u.props.transitions);if(this.channels[c]=e,f){this.lastViewport=s;let u=this.collisionFBOs[c];this.collisionFilterPass.renderCollisionMap(u,{pass:"collision-filter",isPicking:!0,layers:e.layers,effects:r,layerFilter:o,viewports:s?[s]:[],onViewportActive:n,views:i,shaderModuleProps:{collision:{enabled:!0,dummyCollisionMap:this.dummyCollisionMap},project:{devicePixelRatio:u.device.canvasContext.getDevicePixelRatio()/ZE}}})}}_groupByCollisionGroup(e,r){let o={};for(let n of r){let i=n.props.collisionGroup,s=o[i];s||(s={collisionGroup:i,layers:[],layerBounds:[],allLayersLoaded:!0},o[i]=s),s.layers.push(n),s.layerBounds.push(n.getBounds()),n.isLoaded||(s.allLayersLoaded=!1)}for(let n of Object.keys(o))this.collisionFBOs[n]||this.createFBO(e,n),this.channels[n]||(this.channels[n]=o[n]);for(let n of Object.keys(this.collisionFBOs))o[n]||this.destroyFBO(n);return o}getShaderModuleProps(e){let{collisionGroup:r,collisionEnabled:o}=e.props,{collisionFBOs:n,dummyCollisionMap:i}=this,s=n[r];return{collision:{enabled:o&&Boolean(s),collisionFBO:s,dummyCollisionMap:i}}}cleanup(){this.dummyCollisionMap&&(this.dummyCollisionMap.delete(),this.dummyCollisionMap=void 0),this.channels={};for(let e of Object.keys(this.collisionFBOs))this.destroyFBO(e);this.collisionFBOs={},this.lastViewport=void 0}createFBO(e,r){let{width:o,height:n}=e.getDefaultCanvasContext().canvas,i=e.createTexture({format:"rgba8unorm",width:o,height:n,sampler:{minFilter:"nearest",magFilter:"nearest",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),s=e.createTexture({format:"depth16unorm",width:o,height:n});this.collisionFBOs[r]=e.createFramebuffer({id:`collision-${r}`,width:o,height:n,colorAttachments:[i],depthStencilAttachment:s})}destroyFBO(e){let r=this.collisionFBOs[e];r.colorAttachments[0]?.destroy(),r.depthStencilAttachment?.destroy(),r.destroy(),delete this.collisionFBOs[e]}};var dpe={getCollisionPriority:{type:"accessor",value:0},collisionEnabled:!0,collisionGroup:{type:"string",value:"default"},collisionTestProps:{}},Bh=class extends st{getShaders(){return{modules:[wV]}}draw({shaderModuleProps:e}){e.collision?.drawToCollisionMap&&(this.props=this.clone(this.props.collisionTestProps).props)}initializeState(e,r){if(this.getAttributeManager()===null)return;this.context.deck?._addDefaultEffect(new Lh),this.getAttributeManager().add({collisionPriorities:{size:1,stepMode:"dynamic",accessor:"getCollisionPriority"}})}getNeedsPickingBuffer(){return this.props.collisionEnabled}};Bh.defaultProps=dpe;Bh.extensionName="CollisionFilterExtension";var PV=Bh;var MV=`layout(std140) uniform maskUniforms { vec4 bounds; highp int channel; bool enabled; bool inverted; bool maskByInstance; } mask; `,hpe=` vec2 mask_getCoords(vec4 position) { return (position.xy - mask.bounds.xy) / (mask.bounds.zw - mask.bounds.xy); } `,ppe=` ${MV} ${hpe} `,mpe=` uniform sampler2D mask_texture; bool mask_isInBounds(vec2 texCoords) { if (!mask.enabled) { return true; } vec4 maskColor = texture(mask_texture, texCoords); float maskValue = 1.0; if (mask.channel == 0) { maskValue = maskColor.r; } else if (mask.channel == 1) { maskValue = maskColor.g; } else if (mask.channel == 2) { maskValue = maskColor.b; } else if (mask.channel == 3) { maskValue = maskColor.a; } if (mask.inverted) { return maskValue >= 0.5; } else { return maskValue < 0.5; } } `,gpe=` ${MV} ${mpe} `,_pe={"vs:#decl":` out vec2 mask_texCoords; `,"vs:#main-end":` vec4 mask_common_position; if (mask.maskByInstance) { mask_common_position = project_position(vec4(geometry.worldPosition, 1.0)); } else { mask_common_position = geometry.position; } mask_texCoords = mask_getCoords(mask_common_position); `,"fs:#decl":` in vec2 mask_texCoords; `,"fs:#main-start":` if (mask.enabled) { bool mask = mask_isInBounds(mask_texCoords); // Debug: show extent of render target // fragColor = vec4(mask_texCoords, 0.0, 1.0); // fragColor = texture(mask_texture, mask_texCoords); if (!mask) discard; } `},ype=t=>t&&"maskMap"in t?{mask_texture:t.maskMap}:t||{},RV={name:"mask",dependencies:[We],vs:ppe,fs:gpe,inject:_pe,getUniforms:ype,uniformTypes:{bounds:"vec4<f32>",channel:"i32",enabled:"i32",inverted:"i32",maskByInstance:"i32"}};var xpe={blendColorOperation:"subtract",blendColorSrcFactor:"zero",blendColorDstFactor:"one",blendAlphaOperation:"subtract",blendAlphaSrcFactor:"zero",blendAlphaDstFactor:"one"},Oh=class extends At{constructor(e,r){super(e,r);let{mapSize:o=2048}=r;this.maskMap=e.createTexture({format:"rgba8unorm",width:o,height:o,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),this.fbo=e.createFramebuffer({id:"maskmap",width:o,height:o,colorAttachments:[this.maskMap]})}render(e){let r=2**e.channel,o=[255,255,255,255];super.render({...e,clearColor:o,colorMask:r,target:this.fbo,pass:"mask"})}getLayerParameters(e,r,o){return{...e.props.parameters,blend:!0,depthCompare:"always",...xpe}}shouldDrawLayer(e){return e.props.operation.includes("mask")}delete(){this.fbo.delete(),this.maskMap.delete()}};function hl(t,e){let r=[1/0,1/0,-1/0,-1/0];for(let o of t){let n=o.getBounds();if(n){let i=o.projectPosition(n[0],{viewport:e,autoOffset:!1}),s=o.projectPosition(n[1],{viewport:e,autoOffset:!1});r[0]=Math.min(r[0],i[0]),r[1]=Math.min(r[1],i[1]),r[2]=Math.max(r[2],s[0]),r[3]=Math.max(r[3],s[1])}}return Number.isFinite(r[0])?r:null}var bpe=2048;function pl(t){let{bounds:e,viewport:r,border:o=0}=t,{isGeospatial:n}=r;if(e[2]<=e[0]||e[3]<=e[1])return null;let i=r.unprojectPosition([(e[0]+e[2])/2,(e[1]+e[3])/2,0]),{width:s,height:a,zoom:c}=t;if(c===void 0){s=s-o*2,a=a-o*2;let l=Math.min(s/(e[2]-e[0]),a/(e[3]-e[1]));c=Math.min(Math.log2(l),20)}else if(!s||!a){let l=2**c;s=Math.round(Math.abs(e[2]-e[0])*l),a=Math.round(Math.abs(e[3]-e[1])*l);let f=bpe-o*2;if(s>f||a>f){let u=f/Math.max(s,a);s=Math.round(s*u),a=Math.round(a*u),c+=Math.log2(u)}}return n?new Mt({id:r.id,x:o,y:o,width:s,height:a,longitude:i[0],latitude:i[1],zoom:c,orthographic:!0}):new Ac({id:r.id,x:o,y:o,width:s,height:a,target:i,zoom:c,flipY:!1})}function Ape(t,e){let r;if(e&&e.length===2){let[i,s]=e,a=t.getBounds({z:i}),c=t.getBounds({z:s});r=[Math.min(a[0],c[0]),Math.min(a[1],c[1]),Math.max(a[2],c[2]),Math.max(a[3],c[3])]}else r=t.getBounds();let o=t.projectPosition(r.slice(0,2)),n=t.projectPosition(r.slice(2,4));return[o[0],o[1],n[0],n[1]]}function ml(t,e,r){if(!t)return[0,0,1,1];let o=Ape(e,r),n=Tpe(o);return t[2]-t[0]<=n[2]-n[0]&&t[3]-t[1]<=n[3]-n[1]?t:[Math.max(t[0],n[0]),Math.max(t[1],n[1]),Math.min(t[2],n[2]),Math.min(t[3],n[3])]}function Tpe(t){let e=t[2]-t[0],r=t[3]-t[1],o=(t[0]+t[2])/2,n=(t[1]+t[3])/2;return[o-e,n-r,o+e,n+r]}var Fh=class{constructor(){this.id="mask-effect",this.props=null,this.useInPicking=!0,this.order=0,this.channels=[],this.masks=null}setup({device:e}){this.dummyMaskMap=e.createTexture({width:1,height:1}),this.maskPass=new Oh(e,{id:"default-mask"}),this.maskMap=this.maskPass.maskMap}preRender({layers:e,layerFilter:r,viewports:o,onViewportActive:n,views:i,effects:s,isPicking:a}){let c=!1;if(a)return{didRender:c};let l=e.filter(h=>h.props.visible&&h.props.operation.includes("mask"));if(l.length===0)return this.masks=null,this.channels.length=0,{didRender:c};this.masks={};let f=this._sortMaskChannels(l),u=o[0],d=!this.lastViewport||!this.lastViewport.equals(u);if(u.resolution!==void 0)return N.warn("MaskExtension is not supported in GlobeView")(),{didRender:c};for(let h in f){let p=this._renderChannel(f[h],{layerFilter:r,onViewportActive:n,views:i,effects:s,viewport:u,viewportChanged:d});c||(c=p)}return{didRender:c}}_renderChannel(e,{layerFilter:r,onViewportActive:o,views:n,effects:i,viewport:s,viewportChanged:a}){let c=!1,l=this.channels[e.index];if(!l)return c;let f=e===l||e.layers.length!==l.layers.length||e.layers.some((u,d)=>u!==l.layers[d]||u.props.transitions)||e.layerBounds.some((u,d)=>u!==l.layerBounds[d]);if(e.bounds=l.bounds,e.maskBounds=l.maskBounds,this.channels[e.index]=e,f||a){this.lastViewport=s;let u=hl(e.layers,s);if(e.bounds=u&&ml(u,s),f||!Ce(e.bounds,l.bounds)){let{maskPass:d,maskMap:h}=this,p=u&&pl({bounds:e.bounds,viewport:s,width:h.width,height:h.height,border:1});e.maskBounds=p?p.getBounds():[0,0,1,1],d.render({pass:"mask",channel:e.index,layers:e.layers,layerFilter:r,viewports:p?[p]:[],onViewportActive:o,views:n,effects:i,shaderModuleProps:{project:{devicePixelRatio:1}}}),c=!0}}return this.masks[e.id]={index:e.index,bounds:e.maskBounds,coordinateOrigin:e.coordinateOrigin,coordinateSystem:e.coordinateSystem},c}_sortMaskChannels(e){let r={},o=0;for(let n of e){let{id:i}=n.root,s=r[i];if(!s){if(++o>4){N.warn("Too many mask layers. The max supported is 4")();continue}s={id:i,index:this.channels.findIndex(a=>a?.id===i),layers:[],layerBounds:[],coordinateOrigin:n.root.props.coordinateOrigin,coordinateSystem:n.root.props.coordinateSystem},r[i]=s}s.layers.push(n),s.layerBounds.push(n.getBounds())}for(let n=0;n<4;n++){let i=this.channels[n];(!i||!(i.id in r))&&(this.channels[n]=null)}for(let n in r){let i=r[n];i.index<0&&(i.index=this.channels.findIndex(s=>!s),this.channels[i.index]=i)}return r}getShaderModuleProps(){return{mask:{maskMap:this.masks?this.maskMap:this.dummyMaskMap,maskChannels:this.masks}}}cleanup(){this.dummyMaskMap&&(this.dummyMaskMap.delete(),this.dummyMaskMap=void 0),this.maskPass&&(this.maskPass.delete(),this.maskPass=void 0,this.maskMap=void 0),this.lastViewport=void 0,this.masks=null,this.channels.length=0}};var vpe={maskId:"",maskByInstance:void 0,maskInverted:!1},Nh=class extends st{initializeState(){this.context.deck?._addDefaultEffect(new Fh)}getShaders(){let e="instancePositions"in this.getAttributeManager().attributes;return this.props.maskByInstance!==void 0&&(e=Boolean(this.props.maskByInstance)),this.state.maskByInstance=e,{modules:[RV]}}draw({context:e,shaderModuleProps:r}){let o={};o.maskByInstance=Boolean(this.state.maskByInstance);let{maskId:n,maskInverted:i}=this.props,{maskChannels:s}=r.mask||{},{viewport:a}=e;if(s&&s[n]){let{index:c,bounds:l,coordinateOrigin:f}=s[n],{coordinateSystem:u}=s[n];o.enabled=!0,o.channel=c,o.inverted=i,u===Be.DEFAULT&&(u=a.isGeospatial?Be.LNGLAT:Be.CARTESIAN);let d={modelMatrix:null,fromCoordinateOrigin:f,fromCoordinateSystem:u},h=this.projectPosition([l[0],l[1],0],d),p=this.projectPosition([l[2],l[3],0],d);o.bounds=[h[0],h[1],p[0],p[1]]}else n&&N.warn(`Could not find a mask layer with id: ${n}`)(),o.enabled=!1;this.setShaderModuleProps({mask:o})}};Nh.defaultProps=vpe;Nh.extensionName="MaskExtension";var IV=Nh;var zr={NONE:0,WRITE_HEIGHT_MAP:1,USE_HEIGHT_MAP:2,USE_COVER:3,USE_COVER_ONLY:4,SKIP:5},Spe=Object.keys(zr).map(t=>`const float TERRAIN_MODE_${t} = ${zr[t]}.0;`).join(` `),LV=Spe+` layout(std140) uniform terrainUniforms { float mode; vec4 bounds; } terrain; uniform sampler2D terrain_map; `,Dh={name:"terrain",dependencies:[We],vs:LV+"out vec3 commonPos;",fs:LV+"in vec3 commonPos;",inject:{"vs:#main-start":` if (terrain.mode == TERRAIN_MODE_SKIP) { gl_Position = vec4(0.0); return; } `,"vs:DECKGL_FILTER_GL_POSITION":` commonPos = geometry.position.xyz; if (terrain.mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) { vec2 texCoords = (commonPos.xy - terrain.bounds.xy) / terrain.bounds.zw; position = vec4(texCoords * 2.0 - 1.0, 0.0, 1.0); commonPos.z += project.commonOrigin.z; } if (terrain.mode == TERRAIN_MODE_USE_HEIGHT_MAP) { vec3 anchor = geometry.worldPosition; anchor.z = 0.0; vec3 anchorCommon = project_position(anchor); vec2 texCoords = (anchorCommon.xy - terrain.bounds.xy) / terrain.bounds.zw; if (texCoords.x >= 0.0 && texCoords.y >= 0.0 && texCoords.x <= 1.0 && texCoords.y <= 1.0) { float terrainZ = texture(terrain_map, texCoords).r; geometry.position.z += terrainZ; position = project_common_position_to_clipspace(geometry.position); } } `,"fs:#main-start":` if (terrain.mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) { fragColor = vec4(commonPos.z, 0.0, 0.0, 1.0); return; } `,"fs:DECKGL_FILTER_COLOR":` if ((terrain.mode == TERRAIN_MODE_USE_COVER) || (terrain.mode == TERRAIN_MODE_USE_COVER_ONLY)) { vec2 texCoords = (commonPos.xy - terrain.bounds.xy) / terrain.bounds.zw; vec4 pixel = texture(terrain_map, texCoords); if (terrain.mode == TERRAIN_MODE_USE_COVER_ONLY) { color = pixel; } else { // pixel is premultiplied color = pixel + color * (1.0 - pixel.a); } return; } `},getUniforms:(t={})=>{if(!t.dummyHeightMap)return{};if("terrainSkipRender"in t||"drawToTerrainHeightMap"in t){let{drawToTerrainHeightMap:e,heightMap:r,heightMapBounds:o,dummyHeightMap:n,terrainCover:i,useTerrainHeightMap:s,terrainSkipRender:a}=t,c=We.getUniforms(t.project),{commonOrigin:l}=c,f=a?zr.SKIP:zr.NONE,u=n,d=null;if(e)f=zr.WRITE_HEIGHT_MAP,d=o;else if(s&&r)f=zr.USE_HEIGHT_MAP,u=r,d=o;else if(i){let p=(t.isPicking?i.getPickingFramebuffer():i.getRenderFramebuffer())?.colorAttachments[0].texture;t.isPicking&&(f=zr.SKIP),p?(u=p,f=f===zr.SKIP?zr.USE_COVER_ONLY:zr.USE_COVER,d=i.bounds):t.isPicking&&!a&&(f=zr.NONE)}return{mode:f,terrain_map:u,bounds:d?[d[0]-l[0],d[1]-l[1],d[2]-d[0],d[3]-d[1]]:[0,0,0,0]}}return{mode:zr.NONE,terrain_map:t.dummyHeightMap,bounds:[0,0,0,0]}},uniformTypes:{mode:"f32",bounds:"vec4<f32>"}};function Uh(t,e){return t.createFramebuffer({id:e.id,colorAttachments:[t.createTexture({id:e.id,...e.float&&{format:"rgba32float",type:5126},dimension:"2d",width:1,height:1,sampler:e.interpolate===!1?{minFilter:"nearest",magFilter:"nearest"}:{minFilter:"linear",magFilter:"linear"}})]})}var cx=class{constructor(e){this.isDirty=!0,this.renderViewport=null,this.bounds=null,this.layers=[],this.targetBounds=null,this.targetBoundsCommon=null,this.targetLayer=e,this.tile=BV(e)}get id(){return this.targetLayer.id}get isActive(){return Boolean(this.targetLayer.getCurrentLayer())}shouldUpdate({targetLayer:e,viewport:r,layers:o,layerNeedsRedraw:n}){e&&(this.targetLayer=e);let i=r?this._updateViewport(r):!1,s=o?this._updateLayers(o):!1;if(n){for(let a of this.layers)if(n[a]){s=!0;break}}return s||i}_updateLayers(e){let r=!1;if(e=this.tile?Cpe(this.tile,e):e,e.length!==this.layers.length)r=!0;else for(let o=0;o<e.length;o++)if(e[o].id!==this.layers[o]){r=!0;break}return r&&(this.layers=e.map(o=>o.id)),r}_updateViewport(e){let r=this.targetLayer,o=!1;if(this.tile&&"boundingBox"in this.tile){if(!this.targetBounds){o=!0,this.targetBounds=this.tile.boundingBox;let i=e.projectPosition(this.targetBounds[0]),s=e.projectPosition(this.targetBounds[1]);this.targetBoundsCommon=[i[0],i[1],s[0],s[1]]}}else this.targetBounds!==r.getBounds()&&(o=!0,this.targetBounds=r.getBounds(),this.targetBoundsCommon=hl([r],e));if(!this.targetBoundsCommon)return!1;let n=Math.ceil(e.zoom+.5);if(this.tile)this.bounds=this.targetBoundsCommon;else{let i=this.renderViewport?.zoom;o=o||n!==i;let s=ml(this.targetBoundsCommon,e),a=this.bounds;o=o||!a||s.some((c,l)=>c!==a[l]),this.bounds=s}return o&&(this.renderViewport=pl({bounds:this.bounds,zoom:n,viewport:e})),o}getRenderFramebuffer(){return!this.renderViewport||this.layers.length===0?null:(this.fbo||(this.fbo=Uh(this.targetLayer.context.device,{id:this.id})),this.fbo)}getPickingFramebuffer(){return!this.renderViewport||this.layers.length===0&&!this.targetLayer.props.pickable?null:(this.pickingFbo||(this.pickingFbo=Uh(this.targetLayer.context.device,{id:`${this.id}-picking`,interpolate:!1})),this.pickingFbo)}filterLayers(e){return e.filter(({id:r})=>this.layers.includes(r))}delete(){let{fbo:e,pickingFbo:r}=this;e&&(e.colorAttachments[0].destroy(),e.destroy()),r&&(r.colorAttachments[0].destroy(),r.destroy())}};function Cpe(t,e){return e.filter(r=>{let o=BV(r);return o?Epe(t.boundingBox,o.boundingBox):!0})}function BV(t){for(;t;){let{tile:e}=t.props;if(e)return e;t=t.parent}return null}function Epe(t,e){return t&&e?t[0][0]<e[1][0]&&e[0][0]<t[1][0]&&t[0][1]<e[1][1]&&e[0][1]<t[1][1]:!1}var wpe={blendColorOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"},lx=class extends At{getRenderableLayers(e,r){let{layers:o}=r,n=[],i=this._getDrawLayerParams(e,r,!0);for(let s=0;s<o.length;s++){let a=o[s];!a.isComposite&&i[s].shouldDrawLayer&&n.push(a)}return n}renderHeightMap(e,r){let o=e.getRenderFramebuffer(),n=e.renderViewport;!o||!n||(o.resize(n),this.render({...r,target:o,pass:"terrain-height-map",layers:r.layers,viewports:[n],effects:[],clearColor:[0,0,0,0]}))}renderTerrainCover(e,r){let o=e.getRenderFramebuffer(),n=e.renderViewport;if(!o||!n)return;let i=e.filterLayers(r.layers);o.resize(n),this.render({...r,target:o,pass:`terrain-cover-${e.id}`,layers:i,viewports:[n],clearColor:[0,0,0,0]})}getLayerParameters(e,r,o){return{...e.props.parameters,blend:!0,depthCompare:"always",...e.props.operation.includes("terrain")&&wpe}}getShaderModuleProps(e,r,o){return{terrain:{project:o.project}}}};var fx=class extends Jr{constructor(){super(...arguments),this.drawParameters={}}getRenderableLayers(e,r){let{layers:o}=r,n=[];this.drawParameters={},this._resetColorEncoder(r.pickZ);let i=this._getDrawLayerParams(e,r);for(let s=0;s<o.length;s++){let a=o[s];!a.isComposite&&i[s].shouldDrawLayer&&(n.push(a),this.drawParameters[a.id]=i[s].layerParameters)}return n}renderTerrainCover(e,r){let o=e.getPickingFramebuffer(),n=e.renderViewport;if(!o||!n)return;let i=e.filterLayers(r.layers),s=e.targetLayer;s.props.pickable&&i.unshift(s),o.resize(n);let c=this.drawParameters[s.id]?.blendColor?.[3]??0;this.render({...r,pickingFBO:o,pass:`terrain-cover-picking-${e.id}`,layers:i,viewports:[n],cullRect:void 0,deviceRect:n,pickZ:!1,clearColor:[0,0,0,c]})}getLayerParameters(e,r,o){let n;return this.drawParameters[e.id]?n=this.drawParameters[e.id]:(n=super.getLayerParameters(e,r,o),n.blend=!0),{...n,depthCompare:"always",blendAlphaSrcFactor:"constant"}}getShaderModuleProps(e,r,o){return{...super.getShaderModuleProps(e,r,o),terrain:{project:o.project}}}};var OV=2048,kh=class{static isSupported(e){return e.isTextureFormatRenderable("rgba32float")}constructor(e){this.renderViewport=null,this.bounds=null,this.layers=[],this.layersBounds=[],this.layersBoundsCommon=null,this.lastViewport=null,this.device=e}getRenderFramebuffer(){return this.renderViewport?(this.fbo||(this.fbo=Uh(this.device,{id:"height-map",float:!0})),this.fbo):null}shouldUpdate({layers:e,viewport:r}){let o=e.length!==this.layers.length||e.some((i,s)=>i!==this.layers[s]||i.props.transitions||i.getBounds()!==this.layersBounds[s]);o&&(this.layers=e,this.layersBounds=e.map(i=>i.getBounds()),this.layersBoundsCommon=hl(e,r));let n=!this.lastViewport||!r.equals(this.lastViewport);if(!this.layersBoundsCommon)this.renderViewport=null;else if(o||n){let i=ml(this.layersBoundsCommon,r);if(i[2]<=i[0]||i[3]<=i[1])return this.renderViewport=null,!1;this.bounds=i,this.lastViewport=r;let s=r.scale,a=(i[2]-i[0])*s,c=(i[3]-i[1])*s;return this.renderViewport=a>0||c>0?pl({bounds:[r.center[0]-1,r.center[1]-1,r.center[0]+1,r.center[1]+1],zoom:r.zoom,width:Math.min(a,OV),height:Math.min(c,OV),viewport:r}):null,!0}return!1}delete(){this.fbo&&(this.fbo.colorAttachments[0].delete(),this.fbo.delete())}};var ux=class{constructor(){this.id="terrain-effect",this.props=null,this.useInPicking=!0,this.isPicking=!1,this.isDrapingEnabled=!1,this.terrainCovers=new Map}setup({device:e,deck:r}){this.dummyHeightMap=e.createTexture({width:1,height:1,data:new Uint8Array([0,0,0,0])}),this.terrainPass=new lx(e,{id:"terrain"}),this.terrainPickingPass=new fx(e,{id:"terrain-picking"}),kh.isSupported(e)?this.heightMap=new kh(e):N.warn("Terrain offset mode is not supported by this browser")(),r._addDefaultShaderModule(Dh)}preRender(e){if(e.pickZ){this.isDrapingEnabled=!1;return}let{viewports:r}=e,o=e.pass.startsWith("picking");this.isPicking=o,this.isDrapingEnabled=!0;let n=r[0],i=(o?this.terrainPickingPass:this.terrainPass).getRenderableLayers(n,e),s=i.filter(l=>l.props.operation.includes("terrain"));if(s.length===0)return;o||i.filter(f=>f.state.terrainDrawMode==="offset").length>0&&this._updateHeightMap(s,n,e);let a=i.filter(l=>l.state.terrainDrawMode==="drape"),c=e.effects?.filter(l=>l!==this);this._updateTerrainCovers(s,a,n,{...e,effects:c})}getShaderModuleProps(e,r){if(e.props.operation.includes("mask"))return{terrain:{dummyHeightMap:this.dummyHeightMap}};let{terrainDrawMode:o}=e.state,n=this.isDrapingEnabled?this.terrainCovers.get(e.id)??null:null;return this.isPicking&&e.props.operation.includes("terrain")&&(e.state._hasPickingCover=Boolean(n?.getPickingFramebuffer())),{terrain:{project:r.project,isPicking:this.isPicking,heightMap:this.heightMap?.getRenderFramebuffer()?.colorAttachments[0].texture||null,heightMapBounds:this.heightMap?.bounds,dummyHeightMap:this.dummyHeightMap,terrainCover:n,useTerrainHeightMap:o==="offset",terrainSkipRender:o==="drape"||!e.props.operation.includes("draw")}}}cleanup({deck:e}){this.dummyHeightMap&&(this.dummyHeightMap.delete(),this.dummyHeightMap=void 0),this.heightMap&&(this.heightMap.delete(),this.heightMap=void 0);for(let r of this.terrainCovers.values())r.delete();this.terrainCovers.clear(),e._removeDefaultShaderModule(Dh)}_updateHeightMap(e,r,o){!this.heightMap||!this.heightMap.shouldUpdate({layers:e,viewport:r})||this.terrainPass.renderHeightMap(this.heightMap,{...o,layers:e,shaderModuleProps:{terrain:{heightMapBounds:this.heightMap.bounds,dummyHeightMap:this.dummyHeightMap,drawToTerrainHeightMap:!0},project:{devicePixelRatio:1}}})}_updateTerrainCovers(e,r,o,n){let i={};for(let s of r)s.state.terrainCoverNeedsRedraw&&(i[s.id]=!0,s.state.terrainCoverNeedsRedraw=!1);for(let s of this.terrainCovers.values())s.isDirty=s.isDirty||s.shouldUpdate({layerNeedsRedraw:i});for(let s of e)this._updateTerrainCover(s,r,o,n);this.isPicking||this._pruneTerrainCovers()}_updateTerrainCover(e,r,o,n){let i=this.isPicking?this.terrainPickingPass:this.terrainPass,s=this.terrainCovers.get(e.id);s||(s=new cx(e),this.terrainCovers.set(e.id,s));try{let a=s.shouldUpdate({targetLayer:e,viewport:o,layers:r});(this.isPicking||s.isDirty||a)&&(i.renderTerrainCover(s,{...n,layers:r,shaderModuleProps:{terrain:{dummyHeightMap:this.dummyHeightMap,terrainSkipRender:!1},project:{devicePixelRatio:1}}}),this.isPicking||(s.isDirty=!1))}catch(a){e.raiseError(a,`Error rendering terrain cover ${s.id}`)}}_pruneTerrainCovers(){let e=[];for(let[r,o]of this.terrainCovers)o.isActive||e.push(r);for(let r of e)this.terrainCovers.delete(r)}};var Ppe={terrainDrawMode:void 0},Vh=class extends st{getShaders(){return{modules:[Dh]}}initializeState(){this.context.deck?._addDefaultEffect(new ux)}updateState(e){let{props:r,oldProps:o}=e;if(this.state.terrainDrawMode&&r.terrainDrawMode===o.terrainDrawMode&&r.extruded===o.extruded)return;let{terrainDrawMode:n}=r;if(!n){let i=this.props.extruded,s=this.getAttributeManager()?.attributes,a=s&&"instancePositions"in s;n=i||a?"offset":"drape"}this.setState({terrainDrawMode:n})}onNeedsRedraw(){let e=this.state;e.terrainDrawMode==="drape"&&(e.terrainCoverNeedsRedraw=!0)}};Vh.defaultProps=Ppe;Vh.extensionName="TerrainExtension";var FV=Vh;function NV(t,e,r){switch(t.type){case"Point":return Rpe(t,e,r);case"LineString":return Mpe(t,e,r);case"Polygon":return DV(t,e,r);default:let o=t;throw new Error(`Unsupported geometry type: ${o?.type}`)}}function DV(t,e=-1/0,r=1/0){let{positions:o}=t,n=t.polygonIndices.value.filter(c=>c>=e&&c<=r),i=t.primitivePolygonIndices.value.filter(c=>c>=e&&c<=r);if(!(n.length>2)){let c=[];for(let l=0;l<i.length-1;l++){let f=i[l],u=i[l+1],d=dx(o,f,u);c.push(d)}return{type:"Polygon",coordinates:c}}let a=[];for(let c=0;c<n.length-1;c++){let l=n[c],f=n[c+1],u=DV(t,l,f).coordinates;a.push(u)}return{type:"MultiPolygon",coordinates:a}}function Mpe(t,e=-1/0,r=1/0){let{positions:o}=t,n=t.pathIndices.value.filter(a=>a>=e&&a<=r);if(!(n.length>2))return{type:"LineString",coordinates:dx(o,n[0],n[1])};let s=[];for(let a=0;a<n.length-1;a++){let c=dx(o,n[a],n[a+1]);s.push(c)}return{type:"MultiLineString",coordinates:s}}function Rpe(t,e,r){let{positions:o}=t,n=dx(o,e,r);return n.length>1?{type:"MultiPoint",coordinates:n}:{type:"Point",coordinates:n[0]}}function dx(t,e,r){e=e||0,r=r||t.value.length/t.size;let o=[];for(let n=e;n<r;n++){let i=Array();for(let s=n*t.size;s<(n+1)*t.size;s++)i.push(Number(t.value[s]));o.push(i)}return o}function hx(t,e,r){let o=Ipe(t),n=Object.keys(o).filter(i=>o[i]!==Array);return Lpe(t,{propArrayTypes:o,...e},{numericPropKeys:r&&r.numericPropKeys||n,PositionDataType:r?r.PositionDataType:Float32Array,triangulate:r?r.triangulate:!0})}function Ipe(t){let e={};for(let r of t)if(r.properties)for(let o in r.properties){let n=r.properties[o];e[o]=Upe(n,e[o])}return e}function Lpe(t,e,r){let{pointPositionsCount:o,pointFeaturesCount:n,linePositionsCount:i,linePathsCount:s,lineFeaturesCount:a,polygonPositionsCount:c,polygonObjectsCount:l,polygonRingsCount:f,polygonFeaturesCount:u,propArrayTypes:d,coordLength:h}=e,{numericPropKeys:p=[],PositionDataType:m=Float32Array,triangulate:g=!0}=r,_=t[0]&&"id"in t[0],x=t.length>65535?Uint32Array:Uint16Array,y={type:"Point",positions:new m(o*h),globalFeatureIds:new x(o),featureIds:n>65535?new Uint32Array(o):new Uint16Array(o),numericProps:{},properties:[],fields:[]},b={type:"LineString",pathIndices:i>65535?new Uint32Array(s+1):new Uint16Array(s+1),positions:new m(i*h),globalFeatureIds:new x(i),featureIds:a>65535?new Uint32Array(i):new Uint16Array(i),numericProps:{},properties:[],fields:[]},T={type:"Polygon",polygonIndices:c>65535?new Uint32Array(l+1):new Uint16Array(l+1),primitivePolygonIndices:c>65535?new Uint32Array(f+1):new Uint16Array(f+1),positions:new m(c*h),globalFeatureIds:new x(c),featureIds:u>65535?new Uint32Array(c):new Uint16Array(c),numericProps:{},properties:[],fields:[]};g&&(T.triangles=[]);for(let w of[y,b,T])for(let C of p){let S=d[C];w.numericProps[C]=new S(w.positions.length/h)}b.pathIndices[s]=i,T.polygonIndices[l]=c,T.primitivePolygonIndices[f]=c;let v={pointPosition:0,pointFeature:0,linePosition:0,linePath:0,lineFeature:0,polygonPosition:0,polygonObject:0,polygonRing:0,polygonFeature:0,feature:0};for(let w of t){let C=w.geometry,S=w.properties||{};switch(C.type){case"Point":Bpe(C,y,v,h,S),y.properties.push(QE(S,p)),_&&y.fields.push({id:w.id}),v.pointFeature++;break;case"LineString":Ope(C,b,v,h,S),b.properties.push(QE(S,p)),_&&b.fields.push({id:w.id}),v.lineFeature++;break;case"Polygon":Fpe(C,T,v,h,S),T.properties.push(QE(S,p)),_&&T.fields.push({id:w.id}),v.polygonFeature++;break;default:throw new Error("Invalid geometry type")}v.feature++}return Dpe(y,b,T,h)}function Bpe(t,e,r,o,n){e.positions.set(t.data,r.pointPosition*o);let i=t.data.length/o;ew(e,n,r.pointPosition,i),e.globalFeatureIds.fill(r.feature,r.pointPosition,r.pointPosition+i),e.featureIds.fill(r.pointFeature,r.pointPosition,r.pointPosition+i),r.pointPosition+=i}function Ope(t,e,r,o,n){e.positions.set(t.data,r.linePosition*o);let i=t.data.length/o;ew(e,n,r.linePosition,i),e.globalFeatureIds.fill(r.feature,r.linePosition,r.linePosition+i),e.featureIds.fill(r.lineFeature,r.linePosition,r.linePosition+i);for(let s=0,a=t.indices.length;s<a;++s){let c=t.indices[s],l=s===a-1?t.data.length:t.indices[s+1];e.pathIndices[r.linePath++]=r.linePosition,r.linePosition+=(l-c)/o}}function Fpe(t,e,r,o,n){e.positions.set(t.data,r.polygonPosition*o);let i=t.data.length/o;ew(e,n,r.polygonPosition,i),e.globalFeatureIds.fill(r.feature,r.polygonPosition,r.polygonPosition+i),e.featureIds.fill(r.polygonFeature,r.polygonPosition,r.polygonPosition+i);for(let s=0,a=t.indices.length;s<a;++s){let c=r.polygonPosition;e.polygonIndices[r.polygonObject++]=c;let l=t.areas[s],f=t.indices[s],u=t.indices[s+1];for(let h=0,p=f.length;h<p;++h){let m=f[h],g=h===p-1?u===void 0?t.data.length:u[0]:f[h+1];e.primitivePolygonIndices[r.polygonRing++]=r.polygonPosition,r.polygonPosition+=(g-m)/o}let d=r.polygonPosition;Npe(e,l,f,{startPosition:c,endPosition:d,coordLength:o})}}function Npe(t,e,r,{startPosition:o,endPosition:n,coordLength:i}){if(!t.triangles)return;let s=o*i,a=n*i,c=t.positions.subarray(s,a),l=r[0],f=r.slice(1).map(d=>(d-l)/i),u=bS(c,f,i,e);for(let d=0,h=u.length;d<h;++d)t.triangles.push(o+u[d])}function JE(t,e){let r={};for(let o in t)r[o]={value:t[o],size:e};return r}function Dpe(t,e,r,o){let n={shape:"binary-feature-collection",points:{...t,positions:{value:t.positions,size:o},globalFeatureIds:{value:t.globalFeatureIds,size:1},featureIds:{value:t.featureIds,size:1},numericProps:JE(t.numericProps,1)},lines:{...e,positions:{value:e.positions,size:o},pathIndices:{value:e.pathIndices,size:1},globalFeatureIds:{value:e.globalFeatureIds,size:1},featureIds:{value:e.featureIds,size:1},numericProps:JE(e.numericProps,1)},polygons:{...r,positions:{value:r.positions,size:o},polygonIndices:{value:r.polygonIndices,size:1},primitivePolygonIndices:{value:r.primitivePolygonIndices,size:1},globalFeatureIds:{value:r.globalFeatureIds,size:1},featureIds:{value:r.featureIds,size:1},numericProps:JE(r.numericProps,1)}};return n.polygons&&r.triangles&&(n.polygons.triangles={value:new Uint32Array(r.triangles),size:1}),n}function ew(t,e,r,o){for(let n in t.numericProps)if(n in e){let i=e[n];t.numericProps[n].fill(i,r,r+o)}}function QE(t,e){let r={};for(let o in t)e.includes(o)||(r[o]=t[o]);return r}function Upe(t,e){return e===Array||!Number.isFinite(t)?Array:e===Float64Array||Math.fround(t)!==t?Float64Array:Float32Array}function zh(t,e){let r=e?.globalFeatureId;return r!==void 0?kpe(t,r):Vpe(t,e?.type)}function kpe(t,e){let r=UV(t);for(let o of r){let n=0,i=o.featureIds.value[0];for(let s=0;s<o.featureIds.value.length;s++){let a=o.featureIds.value[s];if(a!==i){if(e===o.globalFeatureIds.value[n])return px(o,n,s);n=s,i=a}}if(e===o.globalFeatureIds.value[n])return px(o,n,o.featureIds.value.length)}throw new Error(`featureId:${e} not found`)}function Vpe(t,e){let r=UV(t,e);return zpe(r)}function UV(t,e){let r=[];return t.points&&(t.points.type="Point",r.push(t.points)),t.lines&&(t.lines.type="LineString",r.push(t.lines)),t.polygons&&(t.polygons.type="Polygon",r.push(t.polygons)),r}function zpe(t){let e=[];for(let r of t){if(r.featureIds.value.length===0)continue;let o=0,n=r.featureIds.value[0];for(let i=0;i<r.featureIds.value.length;i++){let s=r.featureIds.value[i];s!==n&&(e.push(px(r,o,i)),o=i,n=s)}e.push(px(r,o,r.featureIds.value.length))}return e}function px(t,e,r){let o=NV(t,e,r),n=jpe(t,e,r),i=Hpe(t,e,r);return{type:"Feature",geometry:o,properties:n,...i}}function Hpe(t,e=0,r){return t.fields&&t.fields[t.featureIds.value[e]]}function jpe(t,e=0,r){let o=Object.assign({},t.properties[t.featureIds.value[e]]);for(let n in t.numericProps)o[n]=t.numericProps[n].value[e];return o}var sw=kn(GV(),1);function ame(t){let e=0;for(let r=0,o=t.length-1,n,i;r<t.length;o=r++)n=t[r],i=t[o],e+=(i[0]-n[0])*(n[1]+i[1]);return e}function ow(t,e){if(Array.isArray(t[0])){for(let o of t)ow(o,e);return}let r=t;r[0]/=e,r[1]/=e}function $V(t,e){for(let r=0;r<t.length;++r)t[r]/=e}function nw(t,e,r){if(typeof t[0][0]!="number"){for(let s of t)nw(s,e,r);return}let o=r*Math.pow(2,e.z),n=r*e.x,i=r*e.y;for(let s=0;s<t.length;s++){let a=t[s];a[0]=(a[0]+n)*360/o-180;let c=180-(a[1]+i)*360/o;a[1]=360/Math.PI*Math.atan(Math.exp(c*Math.PI/180))-90}}function XV(t,e,r){let{x:o,y:n,z:i}=e,s=r*Math.pow(2,i),a=r*o,c=r*n;for(let l=0,f=t.length;l<f;l+=2){t[l]=(t[l]+a)*360/s-180;let u=180-(t[l+1]+c)*360/s;t[l+1]=360/Math.PI*Math.atan(Math.exp(u*Math.PI/180))-90}}function YV(t){let e=t.length;if(e<=1)return[t];let r=[],o,n;for(let i=0;i<e;i++){let s=ame(t[i]);s!==0&&(n===void 0&&(n=s<0),n===s<0?(o&&r.push(o),o=[t[i]]):o&&o.push(t[i]))}return o&&r.push(o),r}function KV(t){let e=t.indices.length,r="Polygon";if(e<=1)return{type:r,data:t.data,areas:[[xi(t.data)]],indices:[t.indices]};let o=[],n=[],i=[],s=[],a,c=0;for(let l,f=0,u;f<e;f++){u=t.indices[f]-c,l=t.indices[f+1]-c||t.data.length;let d=t.data.slice(u,l),h=xi(d);if(h===0){let p=t.data.slice(0,u),m=t.data.slice(l);t.data=p.concat(m),c+=l-u;continue}a===void 0&&(a=h<0),a===h<0?(s.length&&(o.push(i),n.push(s)),s=[u],i=[h]):(i.push(h),s.push(u))}return i&&o.push(i),s.length&&n.push(s),{type:r,areas:o,indices:n,data:t.data}}var ra=class{properties;extent;type;id;_pbf;_geometry;_keys;_values;_geometryInfo;constructor(e,r,o,n,i,s){this.properties={},this.extent=o,this.type=0,this.id=null,this._pbf=e,this._geometry=-1,this._keys=n,this._values=i,this._geometryInfo=s,e.readFields(cme,this,r)}toGeoJSONFeature(e,r){let o=this.loadGeometry();switch(e){case"wgs84":return qV(this,o,n=>nw(n,r,this.extent));default:return qV(this,o,ow)}}toBinaryFeature(e,r){let o=this.loadFlatGeometry();switch(e){case"wgs84":return this._toBinaryCoordinates(o,n=>XV(n,r,this.extent));default:return this._toBinaryCoordinates(o,$V)}}bbox(){let e=this._pbf;e.pos=this._geometry;let r=e.readVarint()+e.pos,o=1,n=0,i=0,s=0,a=1/0,c=-1/0,l=1/0,f=-1/0;for(;e.pos<r;){if(n<=0){let u=e.readVarint();o=u&7,n=u>>3}if(n--,o===1||o===2)i+=e.readSVarint(),s+=e.readSVarint(),i<a&&(a=i),i>c&&(c=i),s<l&&(l=s),s>f&&(f=s);else if(o!==7)throw new Error(`unknown command ${o}`)}return[a,l,c,f]}_toBinaryCoordinates(e,r){let o;r(e.data,this.extent);let n=2;switch(this.type){case 1:this._geometryInfo.pointFeaturesCount++,this._geometryInfo.pointPositionsCount+=e.indices.length,o={type:"Point",...e};break;case 2:this._geometryInfo.lineFeaturesCount++,this._geometryInfo.linePathsCount+=e.indices.length,this._geometryInfo.linePositionsCount+=e.data.length/n,o={type:"LineString",...e};break;case 3:o=KV(e),this._geometryInfo.polygonFeaturesCount++,this._geometryInfo.polygonObjectsCount+=o.indices.length;for(let s of o.indices)this._geometryInfo.polygonRingsCount+=s.length;this._geometryInfo.polygonPositionsCount+=o.data.length/n;break;default:throw new Error(`Invalid geometry type: ${this.type}`)}let i={type:"Feature",geometry:o,properties:this.properties};return this.id!==null&&(i.id=this.id),i}loadGeometry(){let e=this._pbf;e.pos=this._geometry;let r=e.readVarint()+e.pos,o=1,n=0,i=0,s=0,a=[],c;for(;e.pos<r;){if(n<=0){let l=e.readVarint();o=l&7,n=l>>3}switch(n--,o){case 1:case 2:i+=e.readSVarint(),s+=e.readSVarint(),o===1&&(c&&a.push(c),c=[]),c&&c.push([i,s]);break;case 7:c&&c.push(c[0].slice());break;default:throw new Error(`unknown command ${o}`)}}return c&&a.push(c),a}loadFlatGeometry(){let e=this._pbf;e.pos=this._geometry;let r=e.readVarint()+e.pos,o=1,n,i=0,s=0,a=0,c=0,l=[],f=[];for(;e.pos<r;)if(i<=0&&(n=e.readVarint(),o=n&7,i=n>>3),i--,o===1||o===2)s+=e.readSVarint(),a+=e.readSVarint(),o===1&&l.push(c),f.push(s,a),c+=2;else if(o===7){if(c>0){let u=l[l.length-1];f.push(f[u],f[u+1]),c+=2}}else throw new Error(`unknown command ${o}`);return{data:f,indices:l}}};k(ra,"types",["Unknown","Point","LineString","Polygon"]);function qV(t,e,r){let o=ra.types[t.type],n,i,s;switch(t.type){case 1:let c=[];for(n=0;n<e.length;n++)c[n]=e[n][0];s=c,r(s,t.extent);break;case 2:for(s=e,n=0;n<s.length;n++)r(s[n],t.extent);break;case 3:for(s=YV(e),n=0;n<s.length;n++)for(i=0;i<s[n].length;i++)r(s[n][i],t.extent);break;default:throw new Error("illegal vector tile type")}s.length===1?s=s[0]:o=`Multi${o}`;let a={type:"Feature",geometry:{type:o,coordinates:s},properties:t.properties};return t.id!==null&&(a.properties||={},a.properties.id=t.id),a}function cme(t,e,r){e&&r&&(t===1?e.id=r.readVarint():t===2?lme(r,e):t===3?e.type=r.readVarint():t===4&&(e._geometry=r.pos))}function lme(t,e){let r=t.readVarint()+t.pos;for(;t.pos<r;){let o=e._keys[t.readVarint()],n=e._values[t.readVarint()];e.properties[o]=n}}var _x=class{version;name;extent;length;_pbf;_keys;_values;_features;constructor(e,r){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],e.readFields(fme,this,r),this.length=this._features.length}getGeoJSONFeature(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];let r=this._pbf.readVarint()+this._pbf.pos;return new ra(this._pbf,r,this.extent,this._keys,this._values)}getBinaryFeature(e,r){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];let o=this._pbf.readVarint()+this._pbf.pos;return new ra(this._pbf,o,this.extent,this._keys,this._values,r)}};function fme(t,e,r){e&&r&&(t===15?e.version=r.readVarint():t===1?e.name=r.readString():t===5?e.extent=r.readVarint():t===2?e._features.push(r.pos):t===3?e._keys.push(r.readString()):t===4&&e._values.push(ume(r)))}function ume(t){let e=null,r=t.readVarint()+t.pos;for(;t.pos<r;){let o=t.readVarint()>>3;e=o===1?t.readString():o===2?t.readFloat():o===3?t.readDouble():o===4?t.readVarint64():o===5?t.readVarint():o===6?t.readSVarint():o===7?t.readBoolean():null}return e}var Hh=class{layers;constructor(e,r){this.layers=e.readFields(dme,{},r)}};function dme(t,e,r){if(t===3&&r){let o=new _x(r,r.readVarint()+r.pos);o.length&&e&&(e[o.name]=o)}}function aw(t,e){let r=pme(e),o=e?.gis?.format||e?.mvt?.shape||e?.shape;switch(o){case"columnar-table":return{shape:"columnar-table",data:iw(t,r)};case"geojson-table":return{shape:"geojson-table",type:"FeatureCollection",features:ZV(t,r)};case"geojson":return ZV(t,r);case"binary-geometry":return iw(t,r);case"binary":return iw(t,r);default:throw new Error(o||"undefined shape")}}function iw(t,e){let[r,o]=hme(t,e),n=hx(r,o);return n.byteLength=t.byteLength,n}function hme(t,e){let r=[],o={coordLength:2,pointPositionsCount:0,pointFeaturesCount:0,linePositionsCount:0,linePathsCount:0,lineFeaturesCount:0,polygonPositionsCount:0,polygonObjectsCount:0,polygonRingsCount:0,polygonFeaturesCount:0};if(t.byteLength<=0)return[r,o];let n=new Hh(new sw.default(t));return(e&&Array.isArray(e.layers)?e.layers:Object.keys(n.layers)).forEach(s=>{let a=n.layers[s];if(a)for(let c=0;c<a.length;c++){let l=a.getBinaryFeature(c,o),f=gme(l,e,s);r.push(f)}}),[r,o]}function ZV(t,e){if(t.byteLength<=0)return[];let r=[],o=new Hh(new sw.default(t));return(Array.isArray(e.layers)?e.layers:Object.keys(o.layers)).forEach(i=>{let s=o.layers[i];if(s)for(let a=0;a<s.length;a++){let c=s.getGeoJSONFeature(a),l=mme(c,e,i);r.push(l)}}),r}function pme(t){if(!t?.mvt)throw new Error("mvt options required");if(t.mvt?.coordinates==="wgs84"&&!t.mvt.tileIndex)throw new Error("MVT Loader: WGS84 coordinates need tileIndex property");return t.gis&&Wl.warn('MVTLoader: "options.gis" is deprecated, use "options.mvt.shape" instead')(),t.mvt}function mme(t,e,r){let o=t.toGeoJSONFeature(e.coordinates||"local",e.tileIndex);return e.layerProperty&&(o.properties||={},o.properties[e.layerProperty]=r),o}function gme(t,e,r){let o=t.toBinaryFeature(e.coordinates||"local",e.tileIndex);return e.layerProperty&&o.properties&&(o.properties[e.layerProperty]=r),o}var JV={name:"Mapbox Vector Tile",id:"mvt",module:"mvt",extensions:["mvt","pbf"],mimeTypes:["application/vnd.mapbox-vector-tile","application/x-protobuf"],category:"geometry"};var _me="4.4.3",yx={...JV,dataType:null,batchType:null,version:_me,worker:!0,options:{mvt:{shape:"geojson",coordinates:"local",layerProperty:"layerName",layers:void 0,tileIndex:void 0}}},yme={...yx,parse:async(t,e)=>aw(t,e),parseSync:aw,binary:!0};var xme={Point:QV,MultiPoint:bme,LineString:ez,MultiLineString:Ame,Polygon:tz,MultiPolygon:Tme};function QV([t,e],[r,o],n){let i=lt(r[0],o[0],t),s=lt(r[1],o[1],e);return n.unprojectFlat([i,s])}function cw(t,e,r){return t.map(o=>QV(o,e,r))}function bme(t,e,r){return cw(t,e,r)}function ez(t,e,r){return cw(t,e,r)}function Ame(t,e,r){return t.map(o=>ez(o,e,r))}function tz(t,e,r){return t.map(o=>cw(o,e,r))}function Tme(t,e,r){return t.map(o=>tz(o,e,r))}function rz(t,e,r){let o=r.projectFlat([e.west,e.north]),n=r.projectFlat([e.east,e.south]),i=[o,n];return{...t,coordinates:xme[t.type](t.coordinates,i,r)}}var vme=["points","lines","polygons"];function lw(t,e,r,o){for(let n of vme){let i=t[n]&&Sme(t[n],e,r,o);if(i>=0)return i}return-1}function Sme(t,e,r,o){let n=t.featureIds.value;if(!n.length)return-1;let i=0,s=n[n.length-1]+1;if(o){let c=Cme(t,o);if(c)i=c[0],s=c[1]+1;else return-1}let a=-1;if(e in t.numericProps){let c=t.numericProps[e].value.findIndex((l,f)=>l===r&&n[f]>=i&&n[f]<s);return c>=0?t.globalFeatureIds.value[c]:-1}else e?a=oz(t.properties,c=>c[e]===r,i,s):t.fields&&(a=oz(t.fields,c=>c.id===r,i,s));return a>=0?Eme(t,a):-1}function Cme(t,e){if(!t.__layers){let r={},{properties:o}=t;for(let n=0;n<o.length;n++){let{layerName:i}=o[n];i&&(r[i]?r[i][1]=n:r[i]=[n,n])}t.__layers=r}return t.__layers[e]}function Eme(t,e){if(!t.__ids){let r=[],o=t.featureIds.value,n=t.globalFeatureIds.value;for(let i=0;i<o.length;i++)r[o[i]]=n[i];t.__ids=r}return t.__ids[e]}function oz(t,e,r,o){for(let n=r;n<o;n++)if(e(t[n],n))return n;return-1}var fw=512,wme={...Os.defaultProps,data:Pi,onDataLoad:{type:"function",value:null,optional:!0,compare:!1},uniqueIdProperty:"",highlightedFeatureId:null,loaders:[yx],binary:!0},jh=class extends Ws{initializeState(){super.initializeState();let e=this.context.viewport.resolution!==void 0?!1:this.props.binary;this.setState({binary:e,data:null,tileJSON:null,hoveredFeatureId:null,hoveredFeatureLayerName:null})}get isLoaded(){return Boolean(this.state?.data&&super.isLoaded)}updateState({props:e,oldProps:r,context:o,changeFlags:n}){n.dataChanged&&this._updateTileData(),this.state?.data&&(super.updateState({props:e,oldProps:r,context:o,changeFlags:n}),this._setWGS84PropertyForTiles());let{highlightColor:i}=e;i!==r.highlightColor&&Array.isArray(i)&&this.setState({highlightColor:i})}async _updateTileData(){let e=this.props.data,r=null;if(typeof e=="string"&&!bC(e)){let{onDataLoad:o,fetch:n}=this.props;this.setState({data:null,tileJSON:null});try{r=await n(e,{propName:"data",layer:this,loaders:[]})}catch(i){this.raiseError(i,"loading TileJSON"),e=null}o&&o(r,{propName:"data",layer:this})}else e&&typeof e=="object"&&"tilejson"in e&&(r=e);r&&(e=r.tiles),this.setState({data:e,tileJSON:r})}_getTilesetOptions(){let e=super._getTilesetOptions(),r=this.state.tileJSON,{minZoom:o,maxZoom:n}=this.props;return r&&(Number.isFinite(r.minzoom)&&r.minzoom>o&&(e.minZoom=r.minzoom),Number.isFinite(r.maxzoom)&&(!Number.isFinite(n)||r.maxzoom<n)&&(e.maxZoom=r.maxzoom)),e}renderLayers(){return this.state?.data?super.renderLayers():null}getTileData(e){let{data:r,binary:o}=this.state,{index:n,signal:i}=e,s=Yo(r,e);if(!s)return Promise.reject("Invalid URL");let a=this.getLoadOptions(),{fetch:c}=this.props;return a={...a,core:{...a?.core,mimeType:"application/x-protobuf"},mvt:{...a?.mvt,shape:o?"binary":"geojson",coordinates:this.context.viewport.resolution?"wgs84":"local",tileIndex:n}},c(s,{propName:"data",layer:this,loadOptions:a,signal:i})}renderSubLayers(e){let{x:r,y:o,z:n}=e.tile.index,i=Math.pow(2,n),s=fw/i,a=-s,c=fw*r/i,l=fw*(1-o/i),f=new V().scale([s,a,1]);e.autoHighlight=!1,this.context.viewport.resolution||(e.modelMatrix=f,e.coordinateOrigin=[c,l,0],e.coordinateSystem=Be.CARTESIAN,e.extensions=[...e.extensions||[],new ax]);let u=super.renderSubLayers(e);return this.state.binary&&!(u instanceof Os)&&N.warn("renderSubLayers() must return GeoJsonLayer when using binary:true")(),u}_updateAutoHighlight(e){let{uniqueIdProperty:r}=this.props,{hoveredFeatureId:o,hoveredFeatureLayerName:n}=this.state,i=e.object,s=null,a=null;i&&(s=uw(i,r),a=nz(i));let{highlightColor:c}=this.props;typeof c=="function"&&(c=c(e)),(o!==s||n!==a)&&this.setState({highlightColor:c,hoveredFeatureId:s,hoveredFeatureLayerName:a})}_isWGS84(){return Boolean(this.context.viewport.resolution)}getPickingInfo(e){let r=super.getPickingInfo(e);if(this.state.binary&&r.index!==-1){let{data:o}=e.sourceLayer.props;r.object=zh(o,{globalFeatureId:r.index})}return r.object&&!this._isWGS84()&&(r.object=sz(r.object,r.tile.bbox,this.context.viewport)),r}getSubLayerPropsByTile(e){return{highlightedObjectIndex:this.getHighlightedObjectIndex(e),highlightColor:this.state.highlightColor}}getHighlightedObjectIndex(e){let{hoveredFeatureId:r,hoveredFeatureLayerName:o,binary:n}=this.state,{uniqueIdProperty:i,highlightedFeatureId:s}=this.props,a=e.content,c=iz(s);if(!(iz(r)||c))return-1;let f=c?s:r;return Array.isArray(a)?a.findIndex(u=>{let d=uw(u,i)===f,h=c||nz(u)===o;return d&&h}):a&&n?lw(a,i,f,c?"":o):-1}_pickObjects(e){let{deck:r,viewport:o}=this.context,n=o.width,i=o.height,s=o.x,a=o.y,c=[this.id];return r.pickObjects({x:s,y:a,width:n,height:i,layerIds:c,maxObjects:e})}getRenderedFeatures(e=null){let r=this._pickObjects(e),o=new Set,n=[];for(let i of r){let s=uw(i.object,this.props.uniqueIdProperty);s===void 0?n.push(i.object):o.has(s)||(o.add(s),n.push(i.object))}return n}_setWGS84PropertyForTiles(){let e="dataInWGS84";this.state.tileset.selectedTiles.forEach(o=>{o.hasOwnProperty(e)||Object.defineProperty(o,e,{get:()=>{if(!o.content)return null;if(this.state.binary&&Array.isArray(o.content)&&!o.content.length)return[];let{bbox:n}=o;if(o._contentWGS84===void 0&&AC(n)){let i=this.state.binary?zh(o.content):o.content;o._contentWGS84=i.map(s=>sz(s,n,this.context.viewport))}return o._contentWGS84}})})}};jh.layerName="MVTLayer";jh.defaultProps=wme;var az=jh;function uw(t,e){if(t.properties&&e)return t.properties[e];if("id"in t)return t.id}function nz(t){return t.properties?.layerName||null}function iz(t){return t!=null&&t!==""}function sz(t,e,r){let o={...t,geometry:{type:t.geometry.type}};return Object.defineProperty(o.geometry,"coordinates",{get:()=>rz(t.geometry,e,r).coordinates}),o}var cz="0123456789bcdefghjkmnpqrstuvwxyz",lz={};for(let t=0;t<cz.length;t++)lz[cz.charAt(t)]=t;var Pme=-90,Mme=90,Rme=-180,Ime=180;function Lme(t){let e=!0,r=Mme,o=Pme,n=Ime,i=Rme,s,a=0;for(let c=0,l=t.length;c<l;c++){let f=t[c].toLowerCase();a=lz[f];for(let u=4;u>=0;u--){let d=a>>u&1;e?(s=(n+i)/2,d===1?i=s:n=s):(s=(r+o)/2,d===1?o=s:r=s),e=!e}}return[o,i,r,n]}function fz(t){let[e,r,o,n]=Lme(t);return[n,o,n,e,r,e,r,o,n,o]}var Bme={getGeohash:{type:"accessor",value:t=>t.geohash}},Wh=class extends Or{indexToBounds(){let{data:e,getGeohash:r}=this.props;return{data:e,_normalize:!1,positionFormat:"XY",getPolygon:(o,n)=>fz(r(o,n))}}};Wh.layerName="GeohashLayer";Wh.defaultProps=Bme;var uz=Wh;var dw={};ze(dw,{Buffer:()=>K,BufferTransform:()=>ur,CubeGeometry:()=>dn,Device:()=>Xt,Framebuffer:()=>Eo,Geometry:()=>ce,GroupNode:()=>qt,Model:()=>Q,ModelNode:()=>Io,ScenegraphNode:()=>Rr,SphereGeometry:()=>ru,Texture:()=>Y,TextureTransform:()=>fi,attachDevice:()=>Dme,createDevice:()=>Ume,enforceWebGL2:()=>kme,getSupportedAdapters:()=>Fme,setDefaultDeviceProps:()=>Nme,stats:()=>Ome});q();q();var{stats:Ome,getSupportedAdapters:Fme,setDefaultDeviceProps:Nme,attachDevice:Dme,createDevice:Ume,enforceWebGL2:kme}=Co;var hw={};ze(hw,{fetchFile:()=>Ea,load:()=>Kn,parse:()=>Yn,registerLoaders:()=>of});var xx=class{constructor(e){this.map=null,this.width=0,this.height=0,this.props={...e},this._initialize(this.props)}finalize(){this.map?.remove(),this.map=null}setProps(e){let r=this.props,o={...this.props,...e};if(this.props=o,!this.map)return;this._update(r,o)&&this.redraw()}redraw(){let e=this.map;e.style&&(e._frame&&(e._frame.cancel(),e._frame=null),e._render())}getMap(){return this.map}_initialize(e){let{mapLib:r,container:o}=e;r.accessToken=e.mapboxApiAccessToken||"",this.map=new e.mapLib.Map({container:o,maxZoom:24,...e.mapOptions,...dz(e.viewState),style:e.mapStyle,interactive:!1,trackResize:!1}),Object.defineProperty(o,"offsetWidth",{get:()=>this.width}),Object.defineProperty(o,"clientWidth",{get:()=>this.width}),Object.defineProperty(o,"offsetHeight",{get:()=>this.height}),Object.defineProperty(o,"clientHeight",{get:()=>this.height}),this.map.resize()}_update(e,r){e.mapStyle!==r.mapStyle&&this.map.setStyle(r.mapStyle);let n=e.width!==r.width||e.height!==r.height;n&&(this.width=r.width,this.height=r.height,this.map.resize());let i=e.viewState,s=r.viewState,a=s.latitude!==i.latitude||s.longitude!==i.longitude||s.zoom!==i.zoom||s.pitch!==i.pitch||s.bearing!==i.bearing;return a&&this.map.jumpTo(dz(s)),n||a}};function dz(t){return{center:[t.longitude,t.latitude],zoom:t.zoom,bearing:t.bearing??0,pitch:t.pitch??0}}var hz={position:"absolute",left:0,top:0,width:"100%",height:"100%"};function Vme(t){let{container:e=document.body}=t;if(typeof e=="string"&&(e=document.getElementById(e)),!e)throw Error("Deck: container not found");window.getComputedStyle(e).position==="static"&&(e.style.position="relative");let o=document.createElement("div");e.appendChild(o),Object.assign(o.style,hz);let n=document.createElement("canvas");return e.appendChild(n),Object.assign(n.style,hz),{container:e,mapCanvas:o,deckCanvas:n}}var Gh=class extends An{constructor(e){if(typeof document>"u")throw Error("Deck can only be used in the browser");let{mapCanvas:r,deckCanvas:o}=Vme(e),n=e.viewState||e.initialViewState,i=Number.isFinite(n&&n.latitude),{map:s=globalThis.mapboxgl||globalThis.maplibregl}=e;super({canvas:o,...e}),s&&s.Map?this._map=i&&new xx({...e,width:0,height:0,viewState:n,container:r,mapLib:s}):this._map=s}getMapboxMap(){return this._map&&this._map.getMap()}finalize(){this._map&&this._map.finalize(),super.finalize()}setProps(e){"mapStyle"in e&&this._map&&this._map.setProps({mapStyle:e.mapStyle}),super.setProps(e)}_drawLayers(e,r){if(this._map){let o=this.getViewports()[0];o&&this._map.setProps({width:o.width,height:o.height,viewState:o})}super._drawLayers(e,r)}};globalThis.luma=globalThis.luma||{};globalThis.loaders=globalThis.loaders||{};Object.assign(globalThis.luma,dw);Object.assign(globalThis.loaders,hw);function pz({pointCount:t,getBinId:e}){let r=new Map;for(let o=0;o<t;o++){let n=e(o);if(n===null)continue;let i=r.get(String(n));i?i.points.push(o):(i={id:n,index:r.size,points:[o]},r.set(String(n),i))}return Array.from(r.values())}function mz({bins:t,dimensions:e,target:r}){let o=t.length*e;(!r||r.length<o)&&(r=new Float32Array(o));for(let n=0;n<t.length;n++){let{id:i}=t[n];Array.isArray(i)?r.set(i,n*e):r[n]=i}return r}var zme=t=>t.length,gz=(t,e)=>{let r=0;for(let o of t)r+=e(o);return r},Hme=(t,e)=>t.length===0?NaN:gz(t,e)/t.length,jme=(t,e)=>{let r=1/0;for(let o of t){let n=e(o);n<r&&(r=n)}return r},Wme=(t,e)=>{let r=-1/0;for(let o of t){let n=e(o);n>r&&(r=n)}return r},_z={COUNT:zme,SUM:gz,MEAN:Hme,MIN:jme,MAX:Wme};function yz({bins:t,getValue:e,operation:r,target:o}){(!o||o.length<t.length)&&(o=new Float32Array(t.length));let n=1/0,i=-1/0;for(let s=0;s<t.length;s++){let{points:a}=t[s];o[s]=r(a,e),o[s]<n&&(n=o[s]),o[s]>i&&(i=o[s])}return{value:o,domain:[n,i]}}function pw(t,e,r){let o={};for(let i of t.sources||[]){let s=e[i];if(s)o[i]=Gme(s);else throw new Error(`Cannot find attribute ${i}`)}let n={};return i=>{for(let s in o)n[s]=o[s](i);return t.getValue(n,i,r)}}function Gme(t){let e=t.value,{offset:r=0,stride:o,size:n}=t.getAccessor(),i=e.BYTES_PER_ELEMENT,s=r/i,a=o?o/i:n;if(n===1)return t.isConstant?()=>e[0]:l=>{let f=s+a*l;return e[f]};let c;return t.isConstant?(c=Array.from(e),()=>c):(c=new Array(n),l=>{let f=s+a*l;for(let u=0;u<n;u++)c[u]=e[f+u];return c})}var $t=class{constructor(e){this.bins=[],this.binIds=null,this.results=[],this.dimensions=e.dimensions,this.channelCount=e.getValue.length,this.props={...e,binOptions:{},pointCount:0,operations:[],customOperations:[],attributes:{}},this.needsUpdate=!0,this.setProps(e)}destroy(){}get binCount(){return this.bins.length}setProps(e){let r=this.props;if(e.binOptions&&(ie(e.binOptions,r.binOptions,2)||this.setNeedsUpdate()),e.operations)for(let o=0;o<this.channelCount;o++)e.operations[o]!==r.operations[o]&&this.setNeedsUpdate(o);if(e.customOperations)for(let o=0;o<this.channelCount;o++)Boolean(e.customOperations[o])!==Boolean(r.customOperations[o])&&this.setNeedsUpdate(o);e.pointCount!==void 0&&e.pointCount!==r.pointCount&&this.setNeedsUpdate(),e.attributes&&(e.attributes={...r.attributes,...e.attributes}),Object.assign(this.props,e)}setNeedsUpdate(e){e===void 0?this.needsUpdate=!0:this.needsUpdate!==!0&&(this.needsUpdate=this.needsUpdate||[],this.needsUpdate[e]=!0)}update(){if(this.needsUpdate===!0){this.bins=pz({pointCount:this.props.pointCount,getBinId:pw(this.props.getBin,this.props.attributes,this.props.binOptions)});let e=mz({bins:this.bins,dimensions:this.dimensions,target:this.binIds?.value});this.binIds={value:e,type:"float32",size:this.dimensions}}for(let e=0;e<this.channelCount;e++)if(this.needsUpdate===!0||this.needsUpdate[e]){let r=this.props.customOperations[e]||_z[this.props.operations[e]],{value:o,domain:n}=yz({bins:this.bins,getValue:pw(this.props.getValue[e],this.props.attributes,void 0),operation:r,target:this.results[e]?.value});this.results[e]={value:o,domain:n,type:"float32",size:1},this.props.onUpdate?.({channel:e})}this.needsUpdate=!1}preDraw(){}getBins(){return this.binIds}getResult(e){return this.results[e]}getResultDomain(e){return this.results[e]?.domain??[1/0,-1/0]}getBin(e){let r=this.bins[e];if(!r)return null;let o=new Array(this.channelCount);for(let n=0;n<o.length;n++){let i=this.results[n];o[n]=i?.value[e]}return{id:r.id,value:o,count:r.points.length,pointIndices:r.points}}};function bx(t,e,r){return t.createFramebuffer({width:e,height:r,colorAttachments:[t.createTexture({width:e,height:r,format:"rgba32float",sampler:{minFilter:"nearest",magFilter:"nearest"}})]})}var $me=`layout(std140) uniform binSorterUniforms { ivec4 binIdRange; ivec2 targetSize; } binSorter; `,xz={name:"binSorter",vs:$me,uniformTypes:{binIdRange:"vec4<i32>",targetSize:"vec2<i32>"}};var Az=[1,2,4,8],bz=3e38,Xme={SUM:0,MEAN:0,MIN:0,MAX:0,COUNT:0},$h=1024,Ax=class{constructor(e,r){this.binsFBO=null,this.device=e,this.model=Kme(e,r)}get texture(){return this.binsFBO?this.binsFBO.colorAttachments[0].texture:null}destroy(){this.model.destroy(),this.binsFBO?.colorAttachments[0].texture.destroy(),this.binsFBO?.destroy()}getBinValues(e){if(!this.binsFBO)return null;let r=e%$h,o=Math.floor(e/$h),n=this.device.readPixelsToArrayWebGL(this.binsFBO,{sourceX:r,sourceY:o,sourceWidth:1,sourceHeight:1}).buffer;return new Float32Array(n)}setDimensions(e,r){let o=$h,n=Math.ceil(e/o);this.binsFBO?this.binsFBO.height<n&&this.binsFBO.resize({width:o,height:n}):this.binsFBO=bx(this.device,o,n);let i={binIdRange:[r[0][0],r[0][1],r[1]?.[0]||0,r[1]?.[1]||0],targetSize:[this.binsFBO.width,this.binsFBO.height]};this.model.shaderInputs.setProps({binSorter:i})}setModelProps(e){let r=this.model;e.attributes&&r.setAttributes(e.attributes),e.constantAttributes&&r.setConstantAttributes(e.constantAttributes),e.vertexCount!==void 0&&r.setVertexCount(e.vertexCount),e.shaderModuleProps&&r.shaderInputs.setProps(e.shaderModuleProps)}update(e){if(!this.binsFBO)return;let r=Yme(e);this._updateBins("SUM",r.SUM+r.MEAN),this._updateBins("MIN",r.MIN),this._updateBins("MAX",r.MAX)}_updateBins(e,r){if(r===0)return;r|=Az[3];let o=this.model,n=this.binsFBO,i=e==="MAX"?-bz:e==="MIN"?bz:0,s=this.device.beginRenderPass({id:`gpu-aggregation-${e}`,framebuffer:n,parameters:{viewport:[0,0,n.width,n.height],colorMask:r},clearColor:[i,i,i,0],clearDepth:!1,clearStencil:!1});o.setParameters({blend:!0,blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",blendColorOperation:e==="MAX"?"max":e==="MIN"?"min":"add",blendAlphaOperation:"add"}),o.draw(s),s.end()}};function Yme(t){let e={...Xme};for(let r=0;r<t.length;r++){let o=t[r];o&&(e[o]+=Az[r])}return e}function Kme(t,e){let r=e.vs;e.dimensions===2&&(r+=` void getBin(out int binId) { ivec2 binId2; getBin(binId2); if (binId2.x < binSorter.binIdRange.x || binId2.x >= binSorter.binIdRange.y) { binId = -1; } else { binId = (binId2.y - binSorter.binIdRange.z) * (binSorter.binIdRange.y - binSorter.binIdRange.x) + binId2.x; } } `);let o=`#version 300 es #define SHADER_NAME gpu-aggregation-sort-bins-vertex ${r} out vec3 v_Value; void main() { int binIndex; getBin(binIndex); binIndex = binIndex - binSorter.binIdRange.x; if (binIndex < 0) { gl_Position = vec4(0.); return; } int row = binIndex / binSorter.targetSize.x; int col = binIndex - row * binSorter.targetSize.x; vec2 position = (vec2(col, row) + 0.5) / vec2(binSorter.targetSize) * 2.0 - 1.0; gl_Position = vec4(position, 0.0, 1.0); gl_PointSize = 1.0; #if NUM_CHANNELS == 3 getValue(v_Value); #elif NUM_CHANNELS == 2 getValue(v_Value.xy); #else getValue(v_Value.x); #endif } `,n=`#version 300 es #define SHADER_NAME gpu-aggregation-sort-bins-fragment precision highp float; in vec3 v_Value; out vec4 fragColor; void main() { fragColor.xyz = v_Value; #ifdef MODULE_GEOMETRY geometry.uv = vec2(0.); DECKGL_FILTER_COLOR(fragColor, geometry); #endif fragColor.w = 1.0; } `;return new Q(t,{bufferLayout:e.bufferLayout,modules:[...e.modules||[],xz],defines:{...e.defines,NON_INSTANCED_MODEL:1,NUM_CHANNELS:e.channelCount},isInstanced:!1,vs:o,fs:n,topology:"point-list",disableWarnings:!0})}var qme=`layout(std140) uniform aggregatorTransformUniforms { ivec4 binIdRange; bvec3 isCount; bvec3 isMean; float naN; } aggregatorTransform; `,Tz={name:"aggregatorTransform",vs:qme,uniformTypes:{binIdRange:"vec4<i32>",isCount:"vec3<f32>",isMean:"vec3<f32>",naN:"f32"}};var mw=3e38,Tx=class{constructor(e,r){this.binBuffer=null,this.valueBuffer=null,this._domains=null,this.device=e,this.channelCount=r.channelCount,this.transform=Zme(e,r),this.domainFBO=bx(e,2,1)}destroy(){this.transform.destroy(),this.binBuffer?.destroy(),this.valueBuffer?.destroy(),this.domainFBO.colorAttachments[0].texture.destroy(),this.domainFBO.destroy()}get domains(){if(!this._domains){let e=this.device.readPixelsToArrayWebGL(this.domainFBO).buffer,r=new Float32Array(e);this._domains=[[-r[4],r[0]],[-r[5],r[1]],[-r[6],r[2]]].slice(0,this.channelCount)}return this._domains}setDimensions(e,r){let{model:o,transformFeedback:n}=this.transform;o.setVertexCount(e);let i={binIdRange:[r[0][0],r[0][1],r[1]?.[0]||0,r[1]?.[1]||0]};o.shaderInputs.setProps({aggregatorTransform:i});let s=e*r.length*4;(!this.binBuffer||this.binBuffer.byteLength<s)&&(this.binBuffer?.destroy(),this.binBuffer=this.device.createBuffer({byteLength:s}),n.setBuffer("binIds",this.binBuffer));let a=e*this.channelCount*4;(!this.valueBuffer||this.valueBuffer.byteLength<a)&&(this.valueBuffer?.destroy(),this.valueBuffer=this.device.createBuffer({byteLength:a}),n.setBuffer("values",this.valueBuffer))}update(e,r){if(!e)return;let o=this.transform,n=this.domainFBO,i=[0,1,2].map(c=>r[c]==="COUNT"?1:0),s=[0,1,2].map(c=>r[c]==="MEAN"?1:0),a={isCount:i,isMean:s,bins:e};o.model.shaderInputs.setProps({aggregatorTransform:a}),o.run({id:"gpu-aggregation-domain",framebuffer:n,parameters:{viewport:[0,0,2,1]},clearColor:[-mw,-mw,-mw,0],clearDepth:!1,clearStencil:!1}),this._domains=null}};function Zme(t,e){let r=`#version 300 es #define SHADER_NAME gpu-aggregation-domain-vertex uniform sampler2D bins; #if NUM_DIMS == 1 out float binIds; #else out vec2 binIds; #endif #if NUM_CHANNELS == 1 flat out float values; #elif NUM_CHANNELS == 2 flat out vec2 values; #else flat out vec3 values; #endif const float NAN = intBitsToFloat(-1); void main() { int row = gl_VertexID / SAMPLER_WIDTH; int col = gl_VertexID - row * SAMPLER_WIDTH; vec4 weights = texelFetch(bins, ivec2(col, row), 0); vec3 value3 = mix( mix(weights.rgb, vec3(weights.a), aggregatorTransform.isCount), weights.rgb / max(weights.a, 1.0), aggregatorTransform.isMean ); if (weights.a == 0.0) { value3 = vec3(NAN); } #if NUM_DIMS == 1 binIds = float(gl_VertexID + aggregatorTransform.binIdRange.x); #else int y = gl_VertexID / (aggregatorTransform.binIdRange.y - aggregatorTransform.binIdRange.x); int x = gl_VertexID - y * (aggregatorTransform.binIdRange.y - aggregatorTransform.binIdRange.x); binIds.y = float(y + aggregatorTransform.binIdRange.z); binIds.x = float(x + aggregatorTransform.binIdRange.x); #endif #if NUM_CHANNELS == 3 values = value3; #elif NUM_CHANNELS == 2 values = value3.xy; #else values = value3.x; #endif gl_Position = vec4(0., 0., 0., 1.); // This model renders into a 2x1 texture to obtain min and max simultaneously. // See comments in fragment shader gl_PointSize = 2.0; } `,o=`#version 300 es #define SHADER_NAME gpu-aggregation-domain-fragment precision highp float; #if NUM_CHANNELS == 1 flat in float values; #elif NUM_CHANNELS == 2 flat in vec2 values; #else flat in vec3 values; #endif out vec4 fragColor; void main() { vec3 value3; #if NUM_CHANNELS == 3 value3 = values; #elif NUM_CHANNELS == 2 value3.xy = values; #else value3.x = values; #endif if (isnan(value3.x)) discard; // This shader renders into a 2x1 texture with blending=max // The left pixel yields the max value of each channel // The right pixel yields the min value of each channel if (gl_FragCoord.x < 1.0) { fragColor = vec4(value3, 1.0); } else { fragColor = vec4(-value3, 1.0); } } `;return t.type==="webgl"&&t.getExtension("GL_ARB_shader_bit_encoding"),new ur(t,{vs:r,fs:o,topology:"point-list",modules:[Tz],parameters:{blend:!0,blendColorSrcFactor:"one",blendColorDstFactor:"one",blendColorOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",blendAlphaOperation:"max"},defines:{NUM_DIMS:e.dimensions,NUM_CHANNELS:e.channelCount,SAMPLER_WIDTH:$h},varyings:["binIds","values"],disableWarnings:!0})}var Qe=class{static isSupported(e){return e.features.has("float32-renderable-webgl")&&e.features.has("texture-blend-float-webgl")}constructor(e,r){this.binCount=0,this.binIds=null,this.results=[],this.device=e,this.dimensions=r.dimensions,this.channelCount=r.channelCount,this.props={...r,pointCount:0,binIdRange:[[0,0]],operations:[],attributes:{},binOptions:{}},this.needsUpdate=new Array(this.channelCount).fill(!0),this.binSorter=new Ax(e,r),this.aggregationTransform=new Tx(e,r),this.setProps(r)}getBins(){let e=this.aggregationTransform.binBuffer;return e?(this.binIds?.buffer!==e&&(this.binIds={buffer:e,type:"float32",size:this.dimensions}),this.binIds):null}getResult(e){let r=this.aggregationTransform.valueBuffer;return!r||e>=this.channelCount?null:(this.results[e]?.buffer!==r&&(this.results[e]={buffer:r,type:"float32",size:1,stride:this.channelCount*4,offset:e*4}),this.results[e])}getResultDomain(e){return this.aggregationTransform.domains[e]}getBin(e){if(e<0||e>=this.binCount)return null;let{binIdRange:r}=this.props,o;if(this.dimensions===1)o=[e+r[0][0]];else{let[[a,c],[l]]=r,f=c-a;o=[e%f+a,Math.floor(e/f)+l]}let n=this.binSorter.getBinValues(e);if(!n)return null;let i=n[3],s=[];for(let a=0;a<this.channelCount;a++){let c=this.props.operations[a];c==="COUNT"?s[a]=i:i===0?s[a]=NaN:s[a]=c==="MEAN"?n[a]/i:n[a]}return{id:o,value:s,count:i}}destroy(){this.binSorter.destroy(),this.aggregationTransform.destroy()}setProps(e){let r=this.props;if("binIdRange"in e&&!ie(e.binIdRange,r.binIdRange,2)){let o=e.binIdRange;if(N.assert(o.length===this.dimensions),this.dimensions===1){let[[n,i]]=o;this.binCount=i-n}else{let[[n,i],[s,a]]=o;this.binCount=(i-n)*(a-s)}this.binSorter.setDimensions(this.binCount,o),this.aggregationTransform.setDimensions(this.binCount,o),this.setNeedsUpdate()}if(e.operations)for(let o=0;o<this.channelCount;o++)e.operations[o]!==r.operations[o]&&this.setNeedsUpdate(o);if(e.pointCount!==void 0&&e.pointCount!==r.pointCount&&(this.binSorter.setModelProps({vertexCount:e.pointCount}),this.setNeedsUpdate()),e.binOptions&&(ie(e.binOptions,r.binOptions,2)||this.setNeedsUpdate(),this.binSorter.model.shaderInputs.setProps({binOptions:e.binOptions})),e.attributes){let o={},n={};for(let i of Object.values(e.attributes))for(let[s,a]of Object.entries(i.getValue()))ArrayBuffer.isView(a)?n[s]=a:a&&(o[s]=a);this.binSorter.setModelProps({attributes:o,constantAttributes:n})}e.shaderModuleProps&&this.binSorter.setModelProps({shaderModuleProps:e.shaderModuleProps}),Object.assign(this.props,e)}setNeedsUpdate(e){e===void 0?this.needsUpdate.fill(!0):this.needsUpdate[e]=!0}update(){}preDraw(){if(!this.needsUpdate.some(Boolean))return;let{operations:e}=this.props,r=this.needsUpdate.map((o,n)=>o?e[n]:null);this.binSorter.update(r),this.aggregationTransform.update(this.binSorter.texture,e);for(let o=0;o<this.channelCount;o++)this.needsUpdate[o]&&(this.needsUpdate[o]=!1,this.props.onUpdate?.({channel:o}))}};var vx=class extends Ne{get isDrawable(){return!0}initializeState(){this.getAttributeManager().remove(["instancePickingColors"])}updateState(e){super.updateState(e);let r=this.getAggregatorType();if(e.changeFlags.extensionsChanged||this.state.aggregatorType!==r){this.state.aggregator?.destroy();let o=this.createAggregator(r);return o.setProps({attributes:this.getAttributeManager()?.attributes}),this.setState({aggregator:o,aggregatorType:r}),!0}return!1}finalizeState(e){super.finalizeState(e),this.state.aggregator.destroy()}updateAttributes(e){let{aggregator:r}=this.state;r.setProps({attributes:e});for(let o in e)this.onAttributeChange(o);r.update()}draw({shaderModuleProps:e}){let{aggregator:r}=this.state;r.setProps({shaderModuleProps:e}),r.preDraw()}_getAttributeManager(){return new pr(this.context.device,{id:this.props.id,stats:this.context.stats})}};vx.layerName="AggregationLayer";var Zo=vx;var Oi=[[255,255,178],[254,217,118],[254,178,76],[253,141,60],[240,59,32],[189,0,38]];function gw(t,e=!1,r=Float32Array){let o;if(Number.isFinite(t[0]))o=new r(t);else{o=new r(t.length*4);let n=0;for(let i=0;i<t.length;i++){let s=t[i];o[n++]=s[0],o[n++]=s[1],o[n++]=s[2],o[n++]=Number.isFinite(s[3])?s[3]:255}}if(e)for(let n=0;n<o.length;n++)o[n]/=255;return o}var Sx={linear:"linear",quantile:"nearest",quantize:"nearest",ordinal:"nearest"};function yl(t,e){t.setSampler({minFilter:Sx[e],magFilter:Sx[e]})}function xl(t,e,r="linear"){let o=gw(e,!1,Uint8Array);return t.createTexture({format:"rgba8unorm",sampler:{minFilter:Sx[r],magFilter:Sx[r],addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},data:o,width:o.length/4,height:1})}var vz=`#version 300 es #define SHADER_NAME screen-grid-layer-vertex-shader #define RANGE_COUNT 6 in vec2 positions; in vec2 instancePositions; in float instanceWeights; in vec3 instancePickingColors; uniform sampler2D colorRange; out vec4 vColor; vec4 interp(float value, vec2 domain, sampler2D range) { float r = (value - domain.x) / (domain.y - domain.x); return texture(range, vec2(r, 0.5)); } void main(void) { if (isnan(instanceWeights)) { gl_Position = vec4(0.); return; } vec2 pos = instancePositions * screenGrid.gridSizeClipspace + positions * screenGrid.cellSizeClipspace; pos.x = pos.x - 1.0; pos.y = 1.0 - pos.y; gl_Position = vec4(pos, 0., 1.); vColor = interp(instanceWeights, screenGrid.colorDomain, colorRange); vColor.a *= layer.opacity; picking_setPickingColor(instancePickingColors); } `;var Sz=`#version 300 es #define SHADER_NAME screen-grid-layer-fragment-shader precision highp float; in vec4 vColor; out vec4 fragColor; void main(void) { fragColor = vColor; DECKGL_FILTER_COLOR(fragColor, geometry); } `;var Jme=`layout(std140) uniform screenGridUniforms { vec2 cellSizeClipspace; vec2 gridSizeClipspace; vec2 colorDomain; } screenGrid; `,Cz={name:"screenGrid",vs:Jme,uniformTypes:{cellSizeClipspace:"vec2<f32>",gridSizeClipspace:"vec2<f32>",colorDomain:"vec2<f32>"}};var Cx=class extends _e{getShaders(){return super.getShaders({vs:vz,fs:Sz,modules:[Se,Cz]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:2,type:"float32",accessor:"getBin"},instanceWeights:{size:1,type:"float32",accessor:"getWeight"}}),this.state.model=this._getModel()}updateState(e){super.updateState(e);let{props:r,oldProps:o,changeFlags:n}=e,i=this.state.model;if(o.colorRange!==r.colorRange){this.state.colorTexture?.destroy(),this.state.colorTexture=xl(this.context.device,r.colorRange,r.colorScaleType);let s={colorRange:this.state.colorTexture};i.shaderInputs.setProps({screenGrid:s})}else o.colorScaleType!==r.colorScaleType&&yl(this.state.colorTexture,r.colorScaleType);if(o.cellMarginPixels!==r.cellMarginPixels||o.cellSizePixels!==r.cellSizePixels||n.viewportChanged){let{width:s,height:a}=this.context.viewport,{cellSizePixels:c,cellMarginPixels:l}=this.props,f=Math.max(c-l,0),u={gridSizeClipspace:[c/s*2,c/a*2],cellSizeClipspace:[f/s*2,f/a*2]};i.shaderInputs.setProps({screenGrid:u})}}finalizeState(e){super.finalizeState(e),this.state.colorTexture?.destroy()}draw({uniforms:e}){let r=this.props.colorDomain(),o=this.state.model,n={colorDomain:r};o.shaderInputs.setProps({screenGrid:n}),o.draw(this.context.renderPass)}_getModel(){return new Q(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new ce({topology:"triangle-strip",attributes:{positions:{value:new Float32Array([0,0,1,0,0,1,1,1]),size:2}}}),isInstanced:!0})}};Cx.layerName="ScreenGridCellLayer";var Ez=Cx;var Qme=`layout(std140) uniform binOptionsUniforms { float cellSizePixels; } binOptions; `,wz={name:"binOptions",vs:Qme,uniformTypes:{cellSizePixels:"f32"}};var ege={cellSizePixels:{type:"number",value:100,min:1},cellMarginPixels:{type:"number",value:2,min:0},colorRange:Oi,colorScaleType:"linear",getPosition:{type:"accessor",value:t=>t.position},getWeight:{type:"accessor",value:1},gpuAggregation:!0,aggregation:"SUM"},Xh=class extends Zo{getAggregatorType(){return this.props.gpuAggregation&&Qe.isSupported(this.context.device)?"gpu":"cpu"}createAggregator(e){return e==="cpu"||!Qe.isSupported(this.context.device)?new $t({dimensions:2,getBin:{sources:["positions"],getValue:({positions:r},o,n)=>{let i=this.context.viewport,s=i.project(r),a=n.cellSizePixels;return s[0]<0||s[0]>=i.width||s[1]<0||s[1]>=i.height?null:[Math.floor(s[0]/a),Math.floor(s[1]/a)]}},getValue:[{sources:["counts"],getValue:({counts:r})=>r}]}):new Qe(this.context.device,{dimensions:2,channelCount:1,bufferLayout:this.getAttributeManager().getBufferLayouts({isInstanced:!1}),...super.getShaders({modules:[fe,wz],vs:` in vec3 positions; in vec3 positions64Low; in float counts; void getBin(out ivec2 binId) { vec4 pos = project_position_to_clipspace(positions, positions64Low, vec3(0.0)); vec2 screenCoords = vec2(pos.x / pos.w + 1.0, 1.0 - pos.y / pos.w) / 2.0 * project.viewportSize.xy / project.devicePixelRatio; vec2 gridCoords = floor(screenCoords / binOptions.cellSizePixels); binId = ivec2(gridCoords); } void getValue(out float weight) { weight = counts; } `})})}initializeState(){super.initializeState(),this.getAttributeManager().add({positions:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},counts:{size:1,accessor:"getWeight"}})}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState(e){let r=super.updateState(e),{props:o,oldProps:n,changeFlags:i}=e,{cellSizePixels:s,aggregation:a}=o;if(r||i.dataChanged||i.updateTriggersChanged||i.viewportChanged||a!==n.aggregation||s!==n.cellSizePixels){let{width:c,height:l}=this.context.viewport,{aggregator:f}=this.state;f instanceof Qe&&f.setProps({binIdRange:[[0,Math.ceil(c/s)],[0,Math.ceil(l/s)]]}),f.setProps({pointCount:this.getNumInstances(),operations:[a],binOptions:{cellSizePixels:s}})}return i.viewportChanged&&this.state.aggregator.setNeedsUpdate(),r}onAttributeChange(e){let{aggregator:r}=this.state;switch(e){case"positions":r.setNeedsUpdate();break;case"counts":r.setNeedsUpdate(0);break;default:}}renderLayers(){let{aggregator:e}=this.state,r=this.getSubLayerClass("cells",Ez),o=e.getBins(),n=e.getResult(0);return new r(this.props,this.getSubLayerProps({id:"cell-layer"}),{data:{length:e.binCount,attributes:{getBin:o,getWeight:n}},dataComparator:(i,s)=>i.length===s.length,updateTriggers:{getBin:[o],getWeight:[n]},parameters:{depthWriteEnabled:!1,...this.props.parameters},colorDomain:()=>this.props.colorDomain||e.getResultDomain(0),extensions:[]})}getPickingInfo(e){let r=e.info,{index:o}=r;if(o>=0){let n=this.state.aggregator.getBin(o),i;n&&(i={col:n.id[0],row:n.id[1],value:n.value[0],count:n.count},n.pointIndices&&(i.pointIndices=n.pointIndices,i.points=Array.isArray(this.props.data)?n.pointIndices.map(s=>this.props.data[s]):[])),r.object=i}return r}};Xh.layerName="ScreenGridLayer";Xh.defaultProps=ege;var Pz=Xh;var Fi=class{constructor(e,r){this.props={scaleType:"linear",lowerPercentile:0,upperPercentile:100},this.domain=null,this.cutoff=null,this.input=e,this.inputLength=r,this.attribute=e}getScalePercentile(){if(!this._percentile){let e=Mz(this.input,this.inputLength);this._percentile=rge(e)}return this._percentile}getScaleOrdinal(){if(!this._ordinal){let e=Mz(this.input,this.inputLength);this._ordinal=tge(e)}return this._ordinal}getCutoff({scaleType:e,lowerPercentile:r,upperPercentile:o}){if(e==="quantile")return[r,o-1];if(r>0||o<100){let{domain:n}=this.getScalePercentile(),i=n[Math.floor(r)-1]??-1/0,s=n[Math.floor(o)-1]??1/0;if(e==="ordinal"){let{domain:a}=this.getScaleOrdinal();i=a.findIndex(c=>c>=i),s=a.findIndex(c=>c>s)-1,s===-2&&(s=a.length-1)}return[i,s]}return null}update(e){let r=this.props;if(e.scaleType!==r.scaleType)switch(e.scaleType){case"quantile":{let{attribute:o}=this.getScalePercentile();this.attribute=o,this.domain=[0,99];break}case"ordinal":{let{attribute:o,domain:n}=this.getScaleOrdinal();this.attribute=o,this.domain=[0,n.length-1];break}default:this.attribute=this.input,this.domain=null}return(e.scaleType!==r.scaleType||e.lowerPercentile!==r.lowerPercentile||e.upperPercentile!==r.upperPercentile)&&(this.cutoff=this.getCutoff(e)),this.props=e,this}};function tge(t){let e=new Set;for(let n of t)Number.isFinite(n)&&e.add(n);let r=Array.from(e).sort(),o=new Map;for(let n=0;n<r.length;n++)o.set(r[n],n);return{attribute:{value:t.map(n=>Number.isFinite(n)?o.get(n):NaN),type:"float32",size:1},domain:r}}function rge(t,e=100){let r=Array.from(t).filter(Number.isFinite).sort(oge),o=0,n=Math.max(1,e),i=new Array(n-1);for(;++o<n;)i[o-1]=nge(r,o/n);return{attribute:{value:t.map(s=>Number.isFinite(s)?ige(i,s):NaN),type:"float32",size:1},domain:i}}function Mz(t,e){let r=(t.stride??4)/4,o=(t.offset??0)/4,n=t.value;if(!n){let s=t.buffer?.readSyncWebGL(0,r*4*e);s&&(n=new Float32Array(s.buffer),t.value=n)}if(r===1)return n.subarray(0,e);let i=new Float32Array(e);for(let s=0;s<e;s++)i[s]=n[s*r+o];return i}function oge(t,e){return t-e}function nge(t,e){let r=t.length;if(e<=0||r<2)return t[0];if(e>=1)return t[r-1];let o=(r-1)*e,n=Math.floor(o),i=t[n],s=t[n+1];return i+(s-i)*(o-n)}function ige(t,e){let r=0,o=t.length;for(;r<o;){let n=r+o>>>1;t[n]>e?o=n:r=n+1}return r}function bl({dataBounds:t,getBinId:e,padding:r=0}){let o=[t[0],t[1],[t[0][0],t[1][1]],[t[1][0],t[0][1]]].map(c=>e(c)),n=Math.min(...o.map(c=>c[0]))-r,i=Math.min(...o.map(c=>c[1]))-r,s=Math.max(...o.map(c=>c[0]))+r+1,a=Math.max(...o.map(c=>c[1]))+r+1;return[[n,s],[i,a]]}var Rz=Math.PI/3,Ex=2*Math.sin(Rz),wx=1.5,Iz=Array.from({length:6},(t,e)=>{let r=e*Rz;return[Math.sin(r),-Math.cos(r)]});function Px([t,e],r){let o=Math.round(e=e/r/wx),n=Math.round(t=t/r/Ex-(o&1)/2),i=e-o;if(Math.abs(i)*3>1){let s=t-n,a=n+(t<n?-1:1)/2,c=o+(e<o?-1:1),l=t-a,f=e-c;s*s+i*i>l*l+f*f&&(n=a+(o&1?1:-1)/2,o=c)}return[n,o]}var Lz=` const vec2 DIST = vec2(${Ex}, ${wx}); ivec2 pointToHexbin(vec2 p, float radius) { p /= radius * DIST; float pj = round(p.y); float pjm2 = mod(pj, 2.0); p.x -= pjm2 * 0.5; float pi = round(p.x); vec2 d1 = p - vec2(pi, pj); if (abs(d1.y) * 3. > 1.) { vec2 v2 = step(0.0, d1) - 0.5; v2.y *= 2.0; vec2 d2 = d1 - v2; if (dot(d1, d1) > dot(d2, d2)) { pi += v2.x + pjm2 - 0.5; pj += v2.y; } } return ivec2(pi, pj); } `;function _w([t,e],r){return[(t+(e&1)/2)*r*Ex,e*r*wx]}var Bz=` const vec2 DIST = vec2(${Ex}, ${wx}); vec2 hexbinCentroid(vec2 binId, float radius) { binId.x += fract(binId.y * 0.5); return binId * DIST * radius; } `;var Oz=`#version 300 es #define SHADER_NAME hexagon-cell-layer-vertex-shader in vec3 positions; in vec3 normals; in vec2 instancePositions; in float instanceElevationValues; in float instanceColorValues; in vec3 instancePickingColors; uniform sampler2D colorRange; out vec4 vColor; ${Bz} float interp(float value, vec2 domain, vec2 range) { float r = min(max((value - domain.x) / (domain.y - domain.x), 0.), 1.); return mix(range.x, range.y, r); } vec4 interp(float value, vec2 domain, sampler2D range) { float r = (value - domain.x) / (domain.y - domain.x); return texture(range, vec2(r, 0.5)); } void main(void) { geometry.pickingColor = instancePickingColors; if (isnan(instanceColorValues) || instanceColorValues < hexagon.colorDomain.z || instanceColorValues > hexagon.colorDomain.w || instanceElevationValues < hexagon.elevationDomain.z || instanceElevationValues > hexagon.elevationDomain.w ) { gl_Position = vec4(0.); return; } vec2 commonPosition = hexbinCentroid(instancePositions, column.radius) + (hexagon.originCommon - project.commonOrigin.xy); commonPosition += positions.xy * column.radius * column.coverage; geometry.position = vec4(commonPosition, 0.0, 1.0); geometry.normal = project_normal(normals); float elevation = 0.0; if (column.extruded) { elevation = interp(instanceElevationValues, hexagon.elevationDomain.xy, hexagon.elevationRange); elevation = project_size(elevation); geometry.position.z = (positions.z + 1.0) / 2.0 * elevation; } gl_Position = project_common_position_to_clipspace(geometry.position); DECKGL_FILTER_GL_POSITION(gl_Position, geometry); vColor = interp(instanceColorValues, hexagon.colorDomain.xy, colorRange); vColor.a *= layer.opacity; if (column.extruded) { vColor.rgb = lighting_getLightColor(vColor.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal); } DECKGL_FILTER_COLOR(vColor, geometry); } `;var sge=`layout(std140) uniform hexagonUniforms { vec4 colorDomain; vec4 elevationDomain; vec2 elevationRange; vec2 originCommon; } hexagon; `,Fz={name:"hexagon",vs:sge,uniformTypes:{colorDomain:"vec4<f32>",elevationDomain:"vec4<f32>",elevationRange:"vec2<f32>",originCommon:"vec2<f32>"}};var Mx=class extends Wo{getShaders(){let e=super.getShaders();return e.modules.push(Fz),{...e,vs:Oz}}initializeState(){super.initializeState();let e=this.getAttributeManager();e.remove(["instanceElevations","instanceFillColors","instanceLineColors","instanceStrokeWidths"]),e.addInstanced({instancePositions:{size:2,type:"float32",accessor:"getBin"},instanceColorValues:{size:1,type:"float32",accessor:"getColorValue"},instanceElevationValues:{size:1,type:"float32",accessor:"getElevationValue"}})}updateState(e){super.updateState(e);let{props:r,oldProps:o}=e,n=this.state.fillModel;if(o.colorRange!==r.colorRange){this.state.colorTexture?.destroy(),this.state.colorTexture=xl(this.context.device,r.colorRange,r.colorScaleType);let i={colorRange:this.state.colorTexture};n.shaderInputs.setProps({hexagon:i})}else o.colorScaleType!==r.colorScaleType&&yl(this.state.colorTexture,r.colorScaleType)}finalizeState(e){super.finalizeState(e),this.state.colorTexture?.destroy()}draw({uniforms:e}){let{radius:r,hexOriginCommon:o,elevationRange:n,elevationScale:i,extruded:s,coverage:a,colorDomain:c,elevationDomain:l}=this.props,f=this.props.colorCutoff||[-1/0,1/0],u=this.props.elevationCutoff||[-1/0,1/0],d=this.state.fillModel;d.setVertexCount(this.state.fillVertexCount);let h={colorDomain:[Math.max(c[0],f[0]),Math.min(c[1],f[1]),Math.max(c[0]-1,f[0]),Math.min(c[1]+1,f[1])],elevationDomain:[Math.max(l[0],u[0]),Math.min(l[1],u[1]),Math.max(l[0]-1,u[0]),Math.min(l[1]+1,u[1])],elevationRange:[n[0]*i,n[1]*i],originCommon:o};d.shaderInputs.setProps({column:{extruded:s,coverage:a,radius:r},hexagon:h}),d.draw(this.context.renderPass)}};Mx.layerName="HexagonCellLayer";var Nz=Mx;var age=`layout(std140) uniform binOptionsUniforms { vec2 hexOriginCommon; float radiusCommon; } binOptions; `,Dz={name:"binOptions",vs:age,uniformTypes:{hexOriginCommon:"vec2<f32>",radiusCommon:"f32"}};function Uz(){}var cge={gpuAggregation:!0,colorDomain:null,colorRange:Oi,getColorValue:{type:"accessor",value:null},getColorWeight:{type:"accessor",value:1},colorAggregation:"SUM",lowerPercentile:{type:"number",min:0,max:100,value:0},upperPercentile:{type:"number",min:0,max:100,value:100},colorScaleType:"quantize",onSetColorDomain:Uz,elevationDomain:null,elevationRange:[0,1e3],getElevationValue:{type:"accessor",value:null},getElevationWeight:{type:"accessor",value:1},elevationAggregation:"SUM",elevationScale:{type:"number",min:0,value:1},elevationLowerPercentile:{type:"number",min:0,max:100,value:0},elevationUpperPercentile:{type:"number",min:0,max:100,value:100},elevationScaleType:"linear",onSetElevationDomain:Uz,radius:{type:"number",min:1,value:1e3},coverage:{type:"number",min:0,max:1,value:1},getPosition:{type:"accessor",value:t=>t.position},hexagonAggregator:{type:"function",optional:!0,value:null},extruded:!1,material:!0},Yh=class extends Zo{getAggregatorType(){let{gpuAggregation:e,hexagonAggregator:r,getColorValue:o,getElevationValue:n}=this.props;return e&&(r||o||n)?(N.warn("Features not supported by GPU aggregation, falling back to CPU")(),"cpu"):e&&Qe.isSupported(this.context.device)?"gpu":"cpu"}createAggregator(e){if(e==="cpu"){let{hexagonAggregator:r,radius:o}=this.props;return new $t({dimensions:2,getBin:{sources:["positions"],getValue:({positions:n},i,s)=>{if(r)return r(n,o);let c=this.state.aggregatorViewport.projectPosition(n),{radiusCommon:l,hexOriginCommon:f}=s;return Px([c[0]-f[0],c[1]-f[1]],l)}},getValue:[{sources:["colorWeights"],getValue:({colorWeights:n})=>n},{sources:["elevationWeights"],getValue:({elevationWeights:n})=>n}]})}return new Qe(this.context.device,{dimensions:2,channelCount:2,bufferLayout:this.getAttributeManager().getBufferLayouts({isInstanced:!1}),...super.getShaders({modules:[fe,Dz],vs:` in vec3 positions; in vec3 positions64Low; in float colorWeights; in float elevationWeights; ${Lz} void getBin(out ivec2 binId) { vec3 positionCommon = project_position(positions, positions64Low); binId = pointToHexbin(positionCommon.xy, binOptions.radiusCommon); } void getValue(out vec2 value) { value = vec2(colorWeights, elevationWeights); } `})})}initializeState(){super.initializeState(),this.getAttributeManager().add({positions:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},colorWeights:{size:1,accessor:"getColorWeight"},elevationWeights:{size:1,accessor:"getElevationWeight"}})}updateState(e){let r=super.updateState(e),{props:o,oldProps:n,changeFlags:i}=e,{aggregator:s}=this.state;if((i.dataChanged||!this.state.dataAsArray)&&(o.getColorValue||o.getElevationValue)&&(this.state.dataAsArray=Array.from(Fe(o.data).iterable)),r||i.dataChanged||o.radius!==n.radius||o.getColorValue!==n.getColorValue||o.getElevationValue!==n.getElevationValue||o.colorAggregation!==n.colorAggregation||o.elevationAggregation!==n.elevationAggregation){this._updateBinOptions();let{radiusCommon:a,hexOriginCommon:c,binIdRange:l,dataAsArray:f}=this.state;if(s.setProps({binIdRange:l,pointCount:this.getNumInstances(),operations:[o.colorAggregation,o.elevationAggregation],binOptions:{radiusCommon:a,hexOriginCommon:c},onUpdate:this._onAggregationUpdate.bind(this)}),f){let{getColorValue:u,getElevationValue:d}=this.props;s.setProps({customOperations:[u&&(h=>u(h.map(p=>f[p]),{indices:h,data:o.data})),d&&(h=>d(h.map(p=>f[p]),{indices:h,data:o.data}))]})}}return i.updateTriggersChanged&&i.updateTriggersChanged.getColorValue&&s.setNeedsUpdate(0),i.updateTriggersChanged&&i.updateTriggersChanged.getElevationValue&&s.setNeedsUpdate(1),r}_updateBinOptions(){let e=this.getBounds(),r=1,o=[0,0],n=[[0,1],[0,1]],i=this.context.viewport;if(e&&Number.isFinite(e[0][0])){let s=[(e[0][0]+e[1][0])/2,(e[0][1]+e[1][1])/2],{radius:a}=this.props,{unitsPerMeter:c}=i.getDistanceScales(s);r=c[0]*a;let l=Px(i.projectFlat(s),r);s=i.unprojectFlat(_w(l,r));let f=i.constructor;i=i.isGeospatial?new f({longitude:s[0],latitude:s[1],zoom:12}):new ot({position:[s[0],s[1],0],zoom:12}),o=[Math.fround(i.center[0]),Math.fround(i.center[1])],n=bl({dataBounds:e,getBinId:u=>{let d=i.projectFlat(u);return d[0]-=o[0],d[1]-=o[1],Px(d,r)},padding:1})}this.setState({radiusCommon:r,hexOriginCommon:o,binIdRange:n,aggregatorViewport:i})}draw(e){e.shaderModuleProps.project&&(e.shaderModuleProps.project.viewport=this.state.aggregatorViewport),super.draw(e)}_onAggregationUpdate({channel:e}){let r=this.getCurrentLayer().props,{aggregator:o}=this.state;if(e===0){let n=o.getResult(0);this.setState({colors:new Fi(n,o.binCount)}),r.onSetColorDomain(o.getResultDomain(0))}else if(e===1){let n=o.getResult(1);this.setState({elevations:new Fi(n,o.binCount)}),r.onSetElevationDomain(o.getResultDomain(1))}}onAttributeChange(e){let{aggregator:r}=this.state;switch(e){case"positions":r.setNeedsUpdate(),this._updateBinOptions();let{radiusCommon:o,hexOriginCommon:n,binIdRange:i}=this.state;r.setProps({binIdRange:i,binOptions:{radiusCommon:o,hexOriginCommon:n}});break;case"colorWeights":r.setNeedsUpdate(0);break;case"elevationWeights":r.setNeedsUpdate(1);break;default:}}renderLayers(){let{aggregator:e,radiusCommon:r,hexOriginCommon:o}=this.state,{elevationScale:n,colorRange:i,elevationRange:s,extruded:a,coverage:c,material:l,transitions:f,colorScaleType:u,lowerPercentile:d,upperPercentile:h,colorDomain:p,elevationScaleType:m,elevationLowerPercentile:g,elevationUpperPercentile:_,elevationDomain:x}=this.props,y=this.getSubLayerClass("cells",Nz),b=e.getBins(),T=this.state.colors?.update({scaleType:u,lowerPercentile:d,upperPercentile:h}),v=this.state.elevations?.update({scaleType:m,lowerPercentile:g,upperPercentile:_});return!T||!v?null:new y(this.getSubLayerProps({id:"cells"}),{data:{length:e.binCount,attributes:{getBin:b,getColorValue:T.attribute,getElevationValue:v.attribute}},dataComparator:(w,C)=>w.length===C.length,updateTriggers:{getBin:[b],getColorValue:[T.attribute],getElevationValue:[v.attribute]},diskResolution:6,vertices:Iz,radius:r,hexOriginCommon:o,elevationScale:n,colorRange:i,colorScaleType:u,elevationRange:s,extruded:a,coverage:c,material:l,colorDomain:T.domain||p||e.getResultDomain(0),elevationDomain:v.domain||x||e.getResultDomain(1),colorCutoff:T.cutoff,elevationCutoff:v.cutoff,transitions:f&&{getFillColor:f.getColorValue||f.getColorWeight,getElevation:f.getElevationValue||f.getElevationWeight},extensions:[]})}getPickingInfo(e){let r=e.info,{index:o}=r;if(o>=0){let n=this.state.aggregator.getBin(o),i;if(n){let s=_w(n.id,this.state.radiusCommon),a=this.context.viewport.unprojectFlat(s);i={col:n.id[0],row:n.id[1],position:a,colorValue:n.value[0],elevationValue:n.value[1],count:n.count},n.pointIndices&&(i.pointIndices=n.pointIndices,i.points=Array.isArray(this.props.data)?n.pointIndices.map(c=>this.props.data[c]):[])}r.object=i}return r}};Yh.layerName="HexagonLayer";Yh.defaultProps=cge;var kz=Yh;var W=.16666666666666666,R={N:[0,.5],E:[.5,0],S:[0,-.5],W:[-.5,0],NE:[.5,.5],NW:[-.5,.5],SE:[.5,-.5],SW:[-.5,-.5]},Al=[R.W,R.SW,R.S],Tl=[R.S,R.SE,R.E],vl=[R.E,R.NE,R.N],Sl=[R.NW,R.W,R.N],Cl=[[-.5,W],[-.5,-W],[-W,-.5],[W,-.5]],El=[[-W,-.5],[W,-.5],[.5,-W],[.5,W]],wl=[[.5,-W],[.5,W],[W,.5],[-W,.5]],Pl=[[-.5,W],[-.5,-W],[W,.5],[-W,.5]],Vz=[R.W,R.SW,R.SE,R.E],zz=[R.S,R.SE,R.NE,R.N],Hz=[R.NW,R.W,R.E,R.NE],jz=[R.NW,R.SW,R.S,R.N],Wz=[[-.5,W],[-.5,-W],[.5,-W],[.5,W]],Gz=[[-W,-.5],[W,-.5],[W,.5],[-W,.5]],lge=[R.NW,R.SW,R.SE,R.NE],$z=[R.NW,R.SW,R.SE,R.E,R.N],Xz=[R.W,R.SW,R.SE,R.NE,R.N],Yz=[R.NW,R.W,R.S,R.SE,R.NE],Kz=[R.NW,R.SW,R.S,R.E,R.NE],qz=[R.NW,R.W,[.5,-W],[.5,W],R.N],Zz=[[-W,-.5],[W,-.5],R.E,R.NE,R.N],Jz=[[-.5,W],[-.5,-W],R.S,R.SE,R.E],Qz=[R.W,R.SW,R.S,[W,.5],[-W,.5]],eH=[R.NW,R.W,[-W,-.5],[W,-.5],R.N],tH=[[-.5,W],[-.5,-W],R.E,R.NE,R.N],rH=[R.S,R.SE,R.E,[W,.5],[-W,.5]],oH=[R.W,R.SW,R.S,[.5,-W],[.5,W]],nH=[R.W,R.SW,R.SE,R.E,[W,.5],[-W,.5]],iH=[[-.5,W],[-.5,-W],R.S,R.SE,R.NE,R.N],sH=[R.NW,R.W,[-W,-.5],[W,-.5],R.E,R.NE],aH=[R.NW,R.SW,R.S,[.5,-W],[.5,W],R.N],Ml=[R.W,R.SW,R.S,R.E,R.NE,R.N],Rl=[R.NW,R.W,R.S,R.SE,R.E,R.N],Rx=[[-.5,W],[-.5,-W],[-W,-.5],[W,-.5],R.E,R.NE,R.N],Ix=[R.W,R.SW,R.S,[.5,-W],[.5,W],[W,.5],[-W,.5]],Lx=[R.NW,R.W,[-W,-.5],[W,-.5],[.5,-W],[.5,W],R.N],Bx=[[-.5,W],[-.5,-W],R.S,R.SE,R.E,[W,.5],[-W,.5]],cH=[[-.5,W],[-.5,-W],[-W,-.5],[W,-.5],[.5,-W],[.5,W],[W,.5],[-W,.5]],lH={0:[],1:[[R.W,R.S]],2:[[R.S,R.E]],3:[[R.W,R.E]],4:[[R.N,R.E]],5:{0:[[R.W,R.S],[R.N,R.E]],1:[[R.W,R.N],[R.S,R.E]]},6:[[R.N,R.S]],7:[[R.W,R.N]],8:[[R.W,R.N]],9:[[R.N,R.S]],10:{0:[[R.W,R.N],[R.S,R.E]],1:[[R.W,R.S],[R.N,R.E]]},11:[[R.N,R.E]],12:[[R.W,R.E]],13:[[R.S,R.E]],14:[[R.W,R.S]],15:[]};function H(t){return parseInt(t,4)}var fH={[H("0000")]:[],[H("2222")]:[],[H("2221")]:[Al],[H("2212")]:[Tl],[H("2122")]:[vl],[H("1222")]:[Sl],[H("0001")]:[Al],[H("0010")]:[Tl],[H("0100")]:[vl],[H("1000")]:[Sl],[H("2220")]:[Cl],[H("2202")]:[El],[H("2022")]:[wl],[H("0222")]:[Pl],[H("0002")]:[Cl],[H("0020")]:[El],[H("0200")]:[wl],[H("2000")]:[Pl],[H("0011")]:[Vz],[H("0110")]:[zz],[H("1100")]:[Hz],[H("1001")]:[jz],[H("2211")]:[Vz],[H("2112")]:[zz],[H("1122")]:[Hz],[H("1221")]:[jz],[H("2200")]:[Wz],[H("2002")]:[Gz],[H("0022")]:[Wz],[H("0220")]:[Gz],[H("1111")]:[lge],[H("1211")]:[$z],[H("2111")]:[Xz],[H("1112")]:[Yz],[H("1121")]:[Kz],[H("1011")]:[$z],[H("0111")]:[Xz],[H("1110")]:[Yz],[H("1101")]:[Kz],[H("1200")]:[qz],[H("0120")]:[Zz],[H("0012")]:[Jz],[H("2001")]:[Qz],[H("1022")]:[qz],[H("2102")]:[Zz],[H("2210")]:[Jz],[H("0221")]:[Qz],[H("1002")]:[eH],[H("2100")]:[tH],[H("0210")]:[rH],[H("0021")]:[oH],[H("1220")]:[eH],[H("0122")]:[tH],[H("2012")]:[rH],[H("2201")]:[oH],[H("0211")]:[nH],[H("2110")]:[iH],[H("1102")]:[sH],[H("1021")]:[aH],[H("2011")]:[nH],[H("0112")]:[iH],[H("1120")]:[sH],[H("1201")]:[aH],[H("2101")]:[Ml],[H("0121")]:[Ml],[H("1012")]:[Rl],[H("1210")]:[Rl],[H("0101")]:{0:[Al,vl],1:[Ml],2:[Ml]},[H("1010")]:{0:[Sl,Tl],1:[Rl],2:[Rl]},[H("2121")]:{0:[Ml],1:[Ml],2:[Al,vl]},[H("1212")]:{0:[Rl],1:[Rl],2:[Sl,Tl]},[H("2120")]:{0:[Rx],1:[Rx],2:[Cl,vl]},[H("2021")]:{0:[Ix],1:[Ix],2:[Al,wl]},[H("1202")]:{0:[Lx],1:[Lx],2:[Sl,El]},[H("0212")]:{0:[Bx],1:[Bx],2:[Tl,Pl]},[H("0102")]:{0:[Cl,vl],1:[Rx],2:[Rx]},[H("0201")]:{0:[Al,wl],1:[Ix],2:[Ix]},[H("1020")]:{0:[Sl,El],1:[Lx],2:[Lx]},[H("2010")]:{0:[Tl,Pl],1:[Bx],2:[Bx]},[H("2020")]:{0:[Pl,El],1:[cH],2:[Cl,wl]},[H("0202")]:{0:[wl,Cl],1:[cH],2:[Pl,El]}};function Kh(t,e){return Number.isNaN(t)?0:Array.isArray(e)?t<e[0]?0:t<e[1]?1:2:t>=e?1:0}function uH(t){let{x:e,y:r,xRange:o,yRange:n,getValue:i,threshold:s}=t,a=e<o[0],c=e>=o[1]-1,l=r<n[0],f=r>=n[1]-1,u=a||c||l||f,d=0,h,p,m,g;if(a||f)m=0;else{let y=i(e,r+1);m=Kh(y,s),d+=y}if(c||f)g=0;else{let y=i(e+1,r+1);g=Kh(y,s),d+=y}if(c||l)p=0;else{let y=i(e+1,r);p=Kh(y,s),d+=y}if(a||l)h=0;else{let y=i(e,r);h=Kh(y,s),d+=y}let _=-1;Number.isFinite(s)&&(_=m<<3|g<<2|p<<1|h),Array.isArray(s)&&(_=m<<6|g<<4|p<<2|h);let x=0;return u||(x=Kh(d/4,s)),{code:_,meanCode:x}}function dH(t){let{x:e,y:r,z:o,code:n,meanCode:i}=t,s=fH[n];Array.isArray(s)||(s=s[i]);let a=e+1,c=r+1,l=[];return s.forEach(f=>{let u=[];f.forEach(d=>{let h=a+d[0],p=c+d[1];u.push([h,p,o])}),l.push(u)}),l}function hH(t){let{x:e,y:r,z:o,code:n,meanCode:i}=t,s=lH[n];Array.isArray(s)||(s=s[i]);let a=e+1,c=r+1,l=[];return s.forEach(f=>{f.forEach(u=>{let d=a+u[0],h=c+u[1];l.push([d,h,o])})}),l}function pH({contours:t,getValue:e,xRange:r,yRange:o}){let n=[],i=[],s=0,a=0;for(let c=0;c<t.length;c++){let l=t[c],f=l.zIndex??c,{threshold:u}=l;for(let d=r[0]-1;d<r[1];d++)for(let h=o[0]-1;h<o[1];h++){let{code:p,meanCode:m}=uH({getValue:e,threshold:u,x:d,y:h,xRange:r,yRange:o}),g={x:d,y:h,z:f,code:p,meanCode:m};if(Array.isArray(u)){let _=dH(g);for(let x of _)i[a++]={vertices:x,contour:l}}else{let _=hH(g);_.length>0&&(n[s++]={vertices:_,contour:l})}}}return{lines:n,polygons:i}}function mH(t){let{aggregator:e,binIdRange:r,channel:o}=t;if(e instanceof Qe){let n=e.getResult(o)?.buffer;if(n){let i=new Float32Array(n.readSyncWebGL().buffer);return fge(i,r)}}if(e instanceof $t){let n=e.getResult(o)?.value,i=e.getBins()?.value;if(i&&n)return uge(n,i,e.binCount)}return null}function fge(t,e){let[[r,o],[n,i]]=e,s=o-r,a=i-n;return(c,l)=>(c-=r,l-=n,c<0||c>=s||l<0||l>=a?NaN:t[l*s+c])}function uge(t,e,r){let o={};for(let n=0;n<r;n++){let i=e[n*2],s=e[n*2+1];o[i]=o[i]||{},o[i][s]=t[n]}return(n,i)=>o[n]?.[i]??NaN}var dge=`layout(std140) uniform binOptionsUniforms { vec2 cellOriginCommon; vec2 cellSizeCommon; } binOptions; `,gH={name:"binOptions",vs:dge,uniformTypes:{cellOriginCommon:"vec2<f32>",cellSizeCommon:"vec2<f32>"}};var _H=[255,255,255,255],hge=1,pge={cellSize:{type:"number",min:1,value:1e3},gridOrigin:{type:"array",compare:!0,value:[0,0]},getPosition:{type:"accessor",value:t=>t.position},getWeight:{type:"accessor",value:1},gpuAggregation:!0,aggregation:"SUM",contours:{type:"object",value:[{threshold:1}],optional:!0,compare:3},zOffset:.005},qh=class extends Zo{getAggregatorType(){return this.props.gpuAggregation&&Qe.isSupported(this.context.device)?"gpu":"cpu"}createAggregator(e){return e==="cpu"?new $t({dimensions:2,getBin:{sources:["positions"],getValue:({positions:r},o,n)=>{let s=this.state.aggregatorViewport.projectPosition(r),{cellSizeCommon:a,cellOriginCommon:c}=n;return[Math.floor((s[0]-c[0])/a[0]),Math.floor((s[1]-c[1])/a[1])]}},getValue:[{sources:["counts"],getValue:({counts:r})=>r}],onUpdate:this._onAggregationUpdate.bind(this)}):new Qe(this.context.device,{dimensions:2,channelCount:1,bufferLayout:this.getAttributeManager().getBufferLayouts({isInstanced:!1}),...super.getShaders({modules:[fe,gH],vs:` in vec3 positions; in vec3 positions64Low; in float counts; void getBin(out ivec2 binId) { vec3 positionCommon = project_position(positions, positions64Low); vec2 gridCoords = floor(positionCommon.xy / binOptions.cellSizeCommon); binId = ivec2(gridCoords); } void getValue(out float value) { value = counts; } `}),onUpdate:this._onAggregationUpdate.bind(this)})}initializeState(){super.initializeState(),this.getAttributeManager().add({positions:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},counts:{size:1,accessor:"getWeight"}})}updateState(e){let r=super.updateState(e),{props:o,oldProps:n,changeFlags:i}=e,{aggregator:s}=this.state;if(r||i.dataChanged||o.cellSize!==n.cellSize||!ie(o.gridOrigin,n.gridOrigin,1)||o.aggregation!==n.aggregation){this._updateBinOptions();let{cellSizeCommon:a,cellOriginCommon:c,binIdRange:l}=this.state;s.setProps({binIdRange:l,pointCount:this.getNumInstances(),operations:[o.aggregation],binOptions:{cellSizeCommon:a,cellOriginCommon:c}})}return ie(n.contours,o.contours,2)||this.setState({contourData:null}),r}_updateBinOptions(){let e=this.getBounds(),r=[1,1],o=[0,0],n=[[0,1],[0,1]],i=this.context.viewport;if(e&&Number.isFinite(e[0][0])){let s=[(e[0][0]+e[1][0])/2,(e[0][1]+e[1][1])/2],{cellSize:a,gridOrigin:c}=this.props,{unitsPerMeter:l}=i.getDistanceScales(s);r[0]=l[0]*a,r[1]=l[1]*a;let f=i.projectFlat(s);o=[Math.floor((f[0]-c[0])/r[0])*r[0]+c[0],Math.floor((f[1]-c[1])/r[1])*r[1]+c[1]],s=i.unprojectFlat(o);let u=i.constructor;i=i.isGeospatial?new u({longitude:s[0],latitude:s[1],zoom:12}):new ot({position:[s[0],s[1],0],zoom:12}),o=[Math.fround(i.center[0]),Math.fround(i.center[1])],n=bl({dataBounds:e,getBinId:d=>{let h=i.projectFlat(d);return[Math.floor((h[0]-o[0])/r[0]),Math.floor((h[1]-o[1])/r[1])]}})}this.setState({cellSizeCommon:r,cellOriginCommon:o,binIdRange:n,aggregatorViewport:i})}draw(e){e.shaderModuleProps.project&&(e.shaderModuleProps.project.viewport=this.state.aggregatorViewport),super.draw(e)}_onAggregationUpdate(){let{aggregator:e,binIdRange:r}=this.state;this.setState({aggregatedValueReader:mH({aggregator:e,binIdRange:r,channel:0}),contourData:null})}_getContours(){let{aggregatedValueReader:e}=this.state;if(!e)return null;if(!this.state.contourData){let{binIdRange:r}=this.state,{contours:o}=this.props,n=pH({contours:o,getValue:e,xRange:r[0],yRange:r[1]});this.state.contourData=n}return this.state.contourData}onAttributeChange(e){let{aggregator:r}=this.state;switch(e){case"positions":r.setNeedsUpdate(),this._updateBinOptions();let{cellSizeCommon:o,cellOriginCommon:n,binIdRange:i}=this.state;r.setProps({binIdRange:i,binOptions:{cellSizeCommon:o,cellOriginCommon:n}});break;case"counts":r.setNeedsUpdate(0);break;default:}}renderLayers(){let e=this._getContours();if(!e)return null;let{lines:r,polygons:o}=e,{zOffset:n}=this.props,{cellOriginCommon:i,cellSizeCommon:s}=this.state,a=this.getSubLayerClass("lines",Go),c=this.getSubLayerClass("bands",Ti),l=new V().translate([i[0],i[1],0]).scale([s[0],s[1],n]),f=r&&r.length>0&&new a(this.getSubLayerProps({id:"lines"}),{data:r,coordinateSystem:Be.CARTESIAN,modelMatrix:l,getPath:d=>d.vertices,getColor:d=>d.contour.color??_H,getWidth:d=>d.contour.strokeWidth??hge,widthUnits:"pixels"}),u=o&&o.length>0&&new c(this.getSubLayerProps({id:"bands"}),{data:o,coordinateSystem:Be.CARTESIAN,modelMatrix:l,getPolygon:d=>d.vertices,getFillColor:d=>d.contour.color??_H});return[f,u]}getPickingInfo(e){let r=e.info,{object:o}=r;return o&&(r.object={contour:o.contour}),r}};qh.layerName="ContourLayer";qh.defaultProps=pge;var yH=qh;var xH=`#version 300 es #define SHADER_NAME grid-cell-layer-vertex-shader in vec3 positions; in vec3 normals; in vec2 instancePositions; in float instanceElevationValues; in float instanceColorValues; in vec3 instancePickingColors; uniform sampler2D colorRange; out vec4 vColor; float interp(float value, vec2 domain, vec2 range) { float r = min(max((value - domain.x) / (domain.y - domain.x), 0.), 1.); return mix(range.x, range.y, r); } vec4 interp(float value, vec2 domain, sampler2D range) { float r = (value - domain.x) / (domain.y - domain.x); return texture(range, vec2(r, 0.5)); } void main(void) { geometry.pickingColor = instancePickingColors; if (isnan(instanceColorValues) || instanceColorValues < grid.colorDomain.z || instanceColorValues > grid.colorDomain.w || instanceElevationValues < grid.elevationDomain.z || instanceElevationValues > grid.elevationDomain.w ) { gl_Position = vec4(0.); return; } vec2 commonPosition = (instancePositions + (positions.xy + 1.0) / 2.0 * column.coverage) * grid.sizeCommon + grid.originCommon - project.commonOrigin.xy; geometry.position = vec4(commonPosition, 0.0, 1.0); geometry.normal = project_normal(normals); float elevation = 0.0; if (column.extruded) { elevation = interp(instanceElevationValues, grid.elevationDomain.xy, grid.elevationRange); elevation = project_size(elevation); geometry.position.z = (positions.z + 1.0) / 2.0 * elevation; } gl_Position = project_common_position_to_clipspace(geometry.position); DECKGL_FILTER_GL_POSITION(gl_Position, geometry); vColor = interp(instanceColorValues, grid.colorDomain.xy, colorRange); vColor.a *= layer.opacity; if (column.extruded) { vColor.rgb = lighting_getLightColor(vColor.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal); } DECKGL_FILTER_COLOR(vColor, geometry); } `;var mge=`layout(std140) uniform gridUniforms { vec4 colorDomain; vec4 elevationDomain; vec2 elevationRange; vec2 originCommon; vec2 sizeCommon; } grid; `,bH={name:"grid",vs:mge,uniformTypes:{colorDomain:"vec4<f32>",elevationDomain:"vec4<f32>",elevationRange:"vec2<f32>",originCommon:"vec2<f32>",sizeCommon:"vec2<f32>"}};var Zh=class extends Wo{getShaders(){let e=super.getShaders();return e.modules.push(bH),{...e,vs:xH}}initializeState(){super.initializeState();let e=this.getAttributeManager();e.remove(["instanceElevations","instanceFillColors","instanceLineColors","instanceStrokeWidths"]),e.addInstanced({instancePositions:{size:2,type:"float32",accessor:"getBin"},instanceColorValues:{size:1,type:"float32",accessor:"getColorValue"},instanceElevationValues:{size:1,type:"float32",accessor:"getElevationValue"}})}updateState(e){super.updateState(e);let{props:r,oldProps:o}=e,n=this.state.fillModel;if(o.colorRange!==r.colorRange){this.state.colorTexture?.destroy(),this.state.colorTexture=xl(this.context.device,r.colorRange,r.colorScaleType);let i={colorRange:this.state.colorTexture};n.shaderInputs.setProps({grid:i})}else o.colorScaleType!==r.colorScaleType&&yl(this.state.colorTexture,r.colorScaleType)}finalizeState(e){super.finalizeState(e),this.state.colorTexture?.destroy()}_updateGeometry(){let e=new dn;this.state.fillModel.setGeometry(e)}draw({uniforms:e}){let{cellOriginCommon:r,cellSizeCommon:o,elevationRange:n,elevationScale:i,extruded:s,coverage:a,colorDomain:c,elevationDomain:l}=this.props,f=this.props.colorCutoff||[-1/0,1/0],u=this.props.elevationCutoff||[-1/0,1/0],d=this.state.fillModel,h={colorDomain:[Math.max(c[0],f[0]),Math.min(c[1],f[1]),Math.max(c[0]-1,f[0]),Math.min(c[1]+1,f[1])],elevationDomain:[Math.max(l[0],u[0]),Math.min(l[1],u[1]),Math.max(l[0]-1,u[0]),Math.min(l[1]+1,u[1])],elevationRange:[n[0]*i,n[1]*i],originCommon:r,sizeCommon:o};d.shaderInputs.setProps({column:{extruded:s,coverage:a},grid:h}),d.draw(this.context.renderPass)}};Zh.layerName="GridCellLayer";var gge=`layout(std140) uniform binOptionsUniforms { vec2 cellOriginCommon; vec2 cellSizeCommon; } binOptions; `,AH={name:"binOptions",vs:gge,uniformTypes:{cellOriginCommon:"vec2<f32>",cellSizeCommon:"vec2<f32>"}};function TH(){}var _ge={gpuAggregation:!0,colorDomain:null,colorRange:Oi,getColorValue:{type:"accessor",value:null},getColorWeight:{type:"accessor",value:1},colorAggregation:"SUM",lowerPercentile:{type:"number",min:0,max:100,value:0},upperPercentile:{type:"number",min:0,max:100,value:100},colorScaleType:"quantize",onSetColorDomain:TH,elevationDomain:null,elevationRange:[0,1e3],getElevationValue:{type:"accessor",value:null},getElevationWeight:{type:"accessor",value:1},elevationAggregation:"SUM",elevationScale:{type:"number",min:0,value:1},elevationLowerPercentile:{type:"number",min:0,max:100,value:0},elevationUpperPercentile:{type:"number",min:0,max:100,value:100},elevationScaleType:"linear",onSetElevationDomain:TH,cellSize:{type:"number",min:0,value:1e3},coverage:{type:"number",min:0,max:1,value:1},getPosition:{type:"accessor",value:t=>t.position},gridAggregator:{type:"function",optional:!0,value:null},extruded:!1,material:!0},Jh=class extends Zo{getAggregatorType(){let{gpuAggregation:e,gridAggregator:r,getColorValue:o,getElevationValue:n}=this.props;return e&&(r||o||n)?(N.warn("Features not supported by GPU aggregation, falling back to CPU")(),"cpu"):e&&Qe.isSupported(this.context.device)?"gpu":"cpu"}createAggregator(e){if(e==="cpu"){let{gridAggregator:r,cellSize:o}=this.props;return new $t({dimensions:2,getBin:{sources:["positions"],getValue:({positions:n},i,s)=>{if(r)return r(n,o);let c=this.state.aggregatorViewport.projectPosition(n),{cellSizeCommon:l,cellOriginCommon:f}=s;return[Math.floor((c[0]-f[0])/l[0]),Math.floor((c[1]-f[1])/l[1])]}},getValue:[{sources:["colorWeights"],getValue:({colorWeights:n})=>n},{sources:["elevationWeights"],getValue:({elevationWeights:n})=>n}]})}return new Qe(this.context.device,{dimensions:2,channelCount:2,bufferLayout:this.getAttributeManager().getBufferLayouts({isInstanced:!1}),...super.getShaders({modules:[fe,AH],vs:` in vec3 positions; in vec3 positions64Low; in float colorWeights; in float elevationWeights; void getBin(out ivec2 binId) { vec3 positionCommon = project_position(positions, positions64Low); vec2 gridCoords = floor(positionCommon.xy / binOptions.cellSizeCommon); binId = ivec2(gridCoords); } void getValue(out vec2 value) { value = vec2(colorWeights, elevationWeights); } `})})}initializeState(){super.initializeState(),this.getAttributeManager().add({positions:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},colorWeights:{size:1,accessor:"getColorWeight"},elevationWeights:{size:1,accessor:"getElevationWeight"}})}updateState(e){let r=super.updateState(e),{props:o,oldProps:n,changeFlags:i}=e,{aggregator:s}=this.state;if((i.dataChanged||!this.state.dataAsArray)&&(o.getColorValue||o.getElevationValue)&&(this.state.dataAsArray=Array.from(Fe(o.data).iterable)),r||i.dataChanged||o.cellSize!==n.cellSize||o.getColorValue!==n.getColorValue||o.getElevationValue!==n.getElevationValue||o.colorAggregation!==n.colorAggregation||o.elevationAggregation!==n.elevationAggregation){this._updateBinOptions();let{cellSizeCommon:a,cellOriginCommon:c,binIdRange:l,dataAsArray:f}=this.state;if(s.setProps({binIdRange:l,pointCount:this.getNumInstances(),operations:[o.colorAggregation,o.elevationAggregation],binOptions:{cellSizeCommon:a,cellOriginCommon:c},onUpdate:this._onAggregationUpdate.bind(this)}),f){let{getColorValue:u,getElevationValue:d}=this.props;s.setProps({customOperations:[u&&(h=>u(h.map(p=>f[p]),{indices:h,data:o.data})),d&&(h=>d(h.map(p=>f[p]),{indices:h,data:o.data}))]})}}return i.updateTriggersChanged&&i.updateTriggersChanged.getColorValue&&s.setNeedsUpdate(0),i.updateTriggersChanged&&i.updateTriggersChanged.getElevationValue&&s.setNeedsUpdate(1),r}_updateBinOptions(){let e=this.getBounds(),r=[1,1],o=[0,0],n=[[0,1],[0,1]],i=this.context.viewport;if(e&&Number.isFinite(e[0][0])){let s=[(e[0][0]+e[1][0])/2,(e[0][1]+e[1][1])/2],{cellSize:a}=this.props,{unitsPerMeter:c}=i.getDistanceScales(s);r[0]=c[0]*a,r[1]=c[1]*a;let l=i.projectFlat(s);o=[Math.floor(l[0]/r[0])*r[0],Math.floor(l[1]/r[1])*r[1]],s=i.unprojectFlat(o);let f=i.constructor;i=i.isGeospatial?new f({longitude:s[0],latitude:s[1],zoom:12}):new ot({position:[s[0],s[1],0],zoom:12}),o=[Math.fround(i.center[0]),Math.fround(i.center[1])],n=bl({dataBounds:e,getBinId:u=>{let d=i.projectFlat(u);return[Math.floor((d[0]-o[0])/r[0]),Math.floor((d[1]-o[1])/r[1])]}})}this.setState({cellSizeCommon:r,cellOriginCommon:o,binIdRange:n,aggregatorViewport:i})}draw(e){e.shaderModuleProps.project&&(e.shaderModuleProps.project.viewport=this.state.aggregatorViewport),super.draw(e)}_onAggregationUpdate({channel:e}){let r=this.getCurrentLayer().props,{aggregator:o}=this.state;if(e===0){let n=o.getResult(0);this.setState({colors:new Fi(n,o.binCount)}),r.onSetColorDomain(o.getResultDomain(0))}else if(e===1){let n=o.getResult(1);this.setState({elevations:new Fi(n,o.binCount)}),r.onSetElevationDomain(o.getResultDomain(1))}}onAttributeChange(e){let{aggregator:r}=this.state;switch(e){case"positions":r.setNeedsUpdate(),this._updateBinOptions();let{cellSizeCommon:o,cellOriginCommon:n,binIdRange:i}=this.state;r.setProps({binIdRange:i,binOptions:{cellSizeCommon:o,cellOriginCommon:n}});break;case"colorWeights":r.setNeedsUpdate(0);break;case"elevationWeights":r.setNeedsUpdate(1);break;default:}}renderLayers(){let{aggregator:e,cellOriginCommon:r,cellSizeCommon:o}=this.state,{elevationScale:n,colorRange:i,elevationRange:s,extruded:a,coverage:c,material:l,transitions:f,colorScaleType:u,lowerPercentile:d,upperPercentile:h,colorDomain:p,elevationScaleType:m,elevationLowerPercentile:g,elevationUpperPercentile:_,elevationDomain:x}=this.props,y=this.getSubLayerClass("cells",Zh),b=e.getBins(),T=this.state.colors?.update({scaleType:u,lowerPercentile:d,upperPercentile:h}),v=this.state.elevations?.update({scaleType:m,lowerPercentile:g,upperPercentile:_});return!T||!v?null:new y(this.getSubLayerProps({id:"cells"}),{data:{length:e.binCount,attributes:{getBin:b,getColorValue:T.attribute,getElevationValue:v.attribute}},dataComparator:(w,C)=>w.length===C.length,updateTriggers:{getBin:[b],getColorValue:[T.attribute],getElevationValue:[v.attribute]},cellOriginCommon:r,cellSizeCommon:o,elevationScale:n,colorRange:i,colorScaleType:u,elevationRange:s,extruded:a,coverage:c,material:l,colorDomain:T.domain||p||e.getResultDomain(0),elevationDomain:v.domain||x||e.getResultDomain(1),colorCutoff:T.cutoff,elevationCutoff:v.cutoff,transitions:f&&{getFillColor:f.getColorValue||f.getColorWeight,getElevation:f.getElevationValue||f.getElevationWeight},extensions:[]})}getPickingInfo(e){let r=e.info,{index:o}=r;if(o>=0){let n=this.state.aggregator.getBin(o),i;n&&(i={col:n.id[0],row:n.id[1],colorValue:n.value[0],elevationValue:n.value[1],count:n.count},n.pointIndices&&(i.pointIndices=n.pointIndices,i.points=Array.isArray(this.props.data)?n.pointIndices.map(s=>this.props.data[s]):[])),r.object=i}return r}};Jh.layerName="GridLayer";Jh.defaultProps=_ge;var vH=Jh;function CH(t){let e=t.map(a=>a[0]),r=t.map(a=>a[1]),o=Math.min.apply(null,e),n=Math.max.apply(null,e),i=Math.min.apply(null,r),s=Math.max.apply(null,r);return[o,i,n,s]}function EH(t,e){return e[0]>=t[0]&&e[2]<=t[2]&&e[1]>=t[1]&&e[3]<=t[3]}var SH=new Float32Array(12);function yw(t,e=2){let r=0;for(let o of t)for(let n=0;n<e;n++)SH[r++]=o[n]||0;return SH}function wH(t,e,r){let[o,n,i,s]=t,a=i-o,c=s-n,l=a,f=c;a/c<e/r?l=e/r*c:f=r/e*a,l<e&&(l=e,f=r);let u=(i+o)/2,d=(s+n)/2;return[u-l/2,d-f/2,u+l/2,d+f/2]}function PH(t,e){let[r,o,n,i]=e;return[(t[0]-r)/(n-r),(t[1]-o)/(i-o)]}var MH=`#version 300 es #define SHADER_NAME heatp-map-layer-vertex-shader uniform sampler2D maxTexture; in vec3 positions; in vec2 texCoords; out vec2 vTexCoords; out float vIntensityMin; out float vIntensityMax; void main(void) { gl_Position = project_position_to_clipspace(positions, vec3(0.0), vec3(0.0)); vTexCoords = texCoords; vec4 maxTexture = texture(maxTexture, vec2(0.5)); float maxValue = triangle.aggregationMode < 0.5 ? maxTexture.r : maxTexture.g; float minValue = maxValue * triangle.threshold; if (triangle.colorDomain[1] > 0.) { maxValue = triangle.colorDomain[1]; minValue = triangle.colorDomain[0]; } vIntensityMax = triangle.intensity / maxValue; vIntensityMin = triangle.intensity / minValue; } `;var RH=`#version 300 es #define SHADER_NAME triangle-layer-fragment-shader precision highp float; uniform sampler2D weightsTexture; uniform sampler2D colorTexture; in vec2 vTexCoords; in float vIntensityMin; in float vIntensityMax; out vec4 fragColor; vec4 getLinearColor(float value) { float factor = clamp(value * vIntensityMax, 0., 1.); vec4 color = texture(colorTexture, vec2(factor, 0.5)); color.a *= min(value * vIntensityMin, 1.0); return color; } void main(void) { vec4 weights = texture(weightsTexture, vTexCoords); float weight = weights.r; if (triangle.aggregationMode > 0.5) { weight /= max(1.0, weights.a); } if (weight <= 0.) { discard; } vec4 linearColor = getLinearColor(weight); linearColor.a *= layer.opacity; fragColor = linearColor; } `;var IH=`layout(std140) uniform triangleUniforms { float aggregationMode; vec2 colorDomain; float intensity; float threshold; } triangle; `,LH={name:"triangle",vs:IH,fs:IH,uniformTypes:{aggregationMode:"f32",colorDomain:"vec2<f32>",intensity:"f32",threshold:"f32"}};var Ox=class extends _e{getShaders(){return super.getShaders({vs:MH,fs:RH,modules:[fe,LH]})}initializeState({device:e}){this.setState({model:this._getModel(e)})}_getModel(e){let{vertexCount:r,data:o}=this.props;return new Q(e,{...this.getShaders(),id:this.props.id,attributes:o.attributes,bufferLayout:[{name:"positions",format:"float32x3"},{name:"texCoords",format:"float32x2"}],topology:"triangle-strip",vertexCount:r})}draw(){let{model:e}=this.state,{aggregationMode:r,colorDomain:o,intensity:n,threshold:i,colorTexture:s,maxTexture:a,weightsTexture:c}=this.props,l={aggregationMode:r,colorDomain:o,intensity:n,threshold:i,colorTexture:s,maxTexture:a,weightsTexture:c};e.shaderInputs.setProps({triangle:l}),e.draw(this.context.renderPass)}};Ox.layerName="TriangleLayer";var BH=Ox;function OH(t,e){let r={};for(let o in t)e.includes(o)||(r[o]=t[o]);return r}var Fx=class extends Ne{initializeAggregationLayer(e){super.initializeState(this.context),this.setState({ignoreProps:OH(this.constructor._propTypes,e.data.props),dimensions:e})}updateState(e){super.updateState(e);let{changeFlags:r}=e;if(r.extensionsChanged){let o=this.getShaders({});o&&o.defines&&(o.defines.NON_INSTANCED_MODEL=1),this.updateShaders(o)}this._updateAttributes()}updateAttributes(e){this.setState({changedAttributes:e})}getAttributes(){return this.getAttributeManager().getAttributes()}getModuleSettings(){let{viewport:e,mousePosition:r,device:o}=this.context;return Object.assign(Object.create(this.props),{viewport:e,mousePosition:r,picking:{isActive:0},devicePixelRatio:o.canvasContext.cssToDeviceRatio()})}updateShaders(e){}isAggregationDirty(e,r={}){let{props:o,oldProps:n,changeFlags:i}=e,{compareAll:s=!1,dimension:a}=r,{ignoreProps:c}=this.state,{props:l,accessors:f=[]}=a,{updateTriggersChanged:u}=i;if(i.dataChanged)return!0;if(u){if(u.all)return!0;for(let d of f)if(u[d])return!0}if(s)return i.extensionsChanged?!0:xc({oldProps:n,newProps:o,ignoreProps:c,propTypes:this.constructor._propTypes});for(let d of l)if(o[d]!==n[d])return!0;return!1}isAttributeChanged(e){let{changedAttributes:r}=this.state;return e?r&&r[e]!==void 0:!yge(r)}_getAttributeManager(){return new pr(this.context.device,{id:this.props.id,stats:this.context.stats})}};Fx.layerName="AggregationLayer";var FH=Fx;function yge(t){let e=!0;for(let r in t){e=!1;break}return e}var Nx=`#version 300 es in vec3 positions; in vec3 positions64Low; in float weights; out vec4 weightsTexture; void main() { weightsTexture = vec4(weights * weight.weightsScale, 0., 0., 1.); float radiusTexels = project_pixel_size(weight.radiusPixels) * weight.textureWidth / (weight.commonBounds.z - weight.commonBounds.x); gl_PointSize = radiusTexels * 2.; vec3 commonPosition = project_position(positions, positions64Low); gl_Position.xy = (commonPosition.xy - weight.commonBounds.xy) / (weight.commonBounds.zw - weight.commonBounds.xy) ; gl_Position.xy = (gl_Position.xy * 2.) - (1.); gl_Position.w = 1.0; } `;var Dx=`#version 300 es in vec4 weightsTexture; out vec4 fragColor; float gaussianKDE(float u){ return pow(2.71828, -u*u/0.05555)/(1.77245385*0.166666); } void main() { float dist = length(gl_PointCoord - vec2(0.5, 0.5)); if (dist > 0.5) { discard; } fragColor = weightsTexture * gaussianKDE(2. * dist); DECKGL_FILTER_COLOR(fragColor, geometry); } `;var NH=`#version 300 es uniform sampler2D inTexture; out vec4 outTexture; void main() { int yIndex = gl_VertexID / int(maxWeight.textureSize); int xIndex = gl_VertexID - (yIndex * int(maxWeight.textureSize)); vec2 uv = (0.5 + vec2(float(xIndex), float(yIndex))) / maxWeight.textureSize; outTexture = texture(inTexture, uv); gl_Position = vec4(0.0, 0.0, 0.0, 1.0); gl_PointSize = 1.0; } `;var DH=`#version 300 es in vec4 outTexture; out vec4 fragColor; void main() { fragColor = outTexture; fragColor.g = outTexture.r / max(1.0, outTexture.a); } `;var xge=`layout(std140) uniform weightUniforms { vec4 commonBounds; float radiusPixels; float textureWidth; float weightsScale; } weight; `,UH={name:"weight",vs:xge,uniformTypes:{commonBounds:"vec4<f32>",radiusPixels:"f32",textureWidth:"f32",weightsScale:"f32"}},kH={name:"maxWeight",vs:`layout(std140) uniform maxWeightUniforms { float textureSize; } maxWeight; `,uniformTypes:{textureSize:"f32"}};var bge=2,xw={format:"rgba8unorm",dimension:"2d",width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}},VH=[0,0],Age={SUM:0,MEAN:1},Tge={getPosition:{type:"accessor",value:t=>t.position},getWeight:{type:"accessor",value:1},intensity:{type:"number",min:0,value:1},radiusPixels:{type:"number",min:1,max:100,value:50},colorRange:Oi,threshold:{type:"number",min:0,max:1,value:.05},colorDomain:{type:"array",value:null,optional:!0},aggregation:"SUM",weightsTextureSize:{type:"number",min:128,max:2048,value:2048},debounceTimeout:{type:"number",min:0,max:1e3,value:500}},vge=["float32-renderable-webgl","texture-blend-float-webgl"],Sge={data:{props:["radiusPixels"]}},Qh=class extends FH{getShaders(e){let r=[fe];return e.modules&&(r=[...r,...e.modules]),super.getShaders({...e,modules:r})}initializeState(){super.initializeAggregationLayer(Sge),this.setState({colorDomain:VH}),this._setupTextureParams(),this._setupAttributes(),this._setupResources()}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState(e){super.updateState(e),this._updateHeatmapState(e)}_updateHeatmapState(e){let{props:r,oldProps:o}=e,n=this._getChangeFlags(e);if((n.dataChanged||n.viewportChanged)&&(n.boundsChanged=this._updateBounds(n.dataChanged),this._updateTextureRenderingBounds()),n.dataChanged||n.boundsChanged){if(clearTimeout(this.state.updateTimer),this.setState({isWeightMapDirty:!0}),n.dataChanged){let i=this.getShaders({vs:Nx,fs:Dx});this._createWeightsTransform(i)}}else n.viewportZoomChanged&&this._debouncedUpdateWeightmap();r.colorRange!==o.colorRange&&this._updateColorTexture(e),this.state.isWeightMapDirty&&this._updateWeightmap(),this.setState({zoom:e.context.viewport.zoom})}renderLayers(){let{weightsTexture:e,triPositionBuffer:r,triTexCoordBuffer:o,maxWeightsTexture:n,colorTexture:i,colorDomain:s}=this.state,{updateTriggers:a,intensity:c,threshold:l,aggregation:f}=this.props,u=this.getSubLayerClass("triangle",BH);return new u(this.getSubLayerProps({id:"triangle-layer",updateTriggers:a}),{coordinateSystem:"default",data:{attributes:{positions:r,texCoords:o}},vertexCount:4,maxTexture:n,colorTexture:i,aggregationMode:Age[f]||0,weightsTexture:e,intensity:c,threshold:l,colorDomain:s})}finalizeState(e){super.finalizeState(e);let{weightsTransform:r,weightsTexture:o,maxWeightTransform:n,maxWeightsTexture:i,triPositionBuffer:s,triTexCoordBuffer:a,colorTexture:c,updateTimer:l}=this.state;r?.destroy(),o?.destroy(),n?.destroy(),i?.destroy(),s?.destroy(),a?.destroy(),c?.destroy(),l&&clearTimeout(l)}_getAttributeManager(){return new pr(this.context.device,{id:this.props.id,stats:this.context.stats})}_getChangeFlags(e){let r={},{dimensions:o}=this.state;r.dataChanged=this.isAttributeChanged()&&"attribute changed"||this.isAggregationDirty(e,{compareAll:!0,dimension:o.data})&&"aggregation is dirty",r.viewportChanged=e.changeFlags.viewportChanged;let{zoom:n}=this.state;return(!e.context.viewport||e.context.viewport.zoom!==n)&&(r.viewportZoomChanged=!0),r}_createTextures(){let{textureSize:e,format:r}=this.state;this.setState({weightsTexture:this.context.device.createTexture({...xw,width:e,height:e,format:r}),maxWeightsTexture:this.context.device.createTexture({...xw,width:1,height:1,format:r})})}_setupAttributes(){this.getAttributeManager().add({positions:{size:3,type:"float64",accessor:"getPosition"},weights:{size:1,accessor:"getWeight"}}),this.setState({positionAttributeName:"positions"})}_setupTextureParams(){let{device:e}=this.context,{weightsTextureSize:r}=this.props,o=Math.min(r,e.limits.maxTextureDimension2D),n=vge.every(a=>e.features.has(a)),i=n?"rgba32float":"rgba8unorm",s=n?1:1/255;this.setState({textureSize:o,format:i,weightsScale:s}),n||N.warn(`HeatmapLayer: ${this.id} rendering to float texture not supported, falling back to low precision format`)()}_createWeightsTransform(e){let{weightsTransform:r}=this.state,{weightsTexture:o}=this.state,n=this.getAttributeManager();r?.destroy(),r=new fi(this.context.device,{id:`${this.id}-weights-transform`,...e,bufferLayout:n.getBufferLayouts(),vertexCount:1,targetTexture:o,parameters:{depthWriteEnabled:!1,blend:!0,blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"},topology:"point-list",modules:[...e.modules,UH]}),this.setState({weightsTransform:r})}_setupResources(){this._createTextures();let{device:e}=this.context,{textureSize:r,weightsTexture:o,maxWeightsTexture:n}=this.state,i=this.getShaders({vs:Nx,fs:Dx});this._createWeightsTransform(i);let s=this.getShaders({vs:NH,fs:DH,modules:[kH]}),a=new fi(e,{id:`${this.id}-max-weights-transform`,targetTexture:n,...s,vertexCount:r*r,topology:"point-list",parameters:{depthWriteEnabled:!1,blend:!0,blendColorOperation:"max",blendAlphaOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}}),c={inTexture:o,textureSize:r};a.model.shaderInputs.setProps({maxWeight:c}),this.setState({weightsTexture:o,maxWeightsTexture:n,maxWeightTransform:a,zoom:null,triPositionBuffer:e.createBuffer({byteLength:48}),triTexCoordBuffer:e.createBuffer({byteLength:48})})}updateShaders(e){this._createWeightsTransform({vs:Nx,fs:Dx,...e})}_updateMaxWeightValue(){let{maxWeightTransform:e}=this.state;e.run({parameters:{viewport:[0,0,1,1]},clearColor:[0,0,0,0]})}_updateBounds(e=!1){let{viewport:r}=this.context,o=[r.unproject([0,0]),r.unproject([r.width,0]),r.unproject([0,r.height]),r.unproject([r.width,r.height])].map(a=>a.map(Math.fround)),n=CH(o),i={visibleWorldBounds:n,viewportCorners:o},s=!1;if(e||!this.state.worldBounds||!EH(this.state.worldBounds,n)){let a=this._worldToCommonBounds(n),c=this._commonToWorldBounds(a);this.props.coordinateSystem==="lnglat"&&(c[1]=Math.max(c[1],-85.051129),c[3]=Math.min(c[3],85.051129),c[0]=Math.max(c[0],-360),c[2]=Math.min(c[2],360));let l=this._worldToCommonBounds(c);i.worldBounds=c,i.normalizedCommonBounds=l,s=!0}return this.setState(i),s}_updateTextureRenderingBounds(){let{triPositionBuffer:e,triTexCoordBuffer:r,normalizedCommonBounds:o,viewportCorners:n}=this.state,{viewport:i}=this.context;e.write(yw(n,3));let s=n.map(a=>PH(i.projectPosition(a),o));r.write(yw(s,2))}_updateColorTexture(e){let{colorRange:r}=e.props,{colorTexture:o}=this.state,n=gw(r,!1,Uint8Array);o?.destroy(),o=this.context.device.createTexture({...xw,data:n,width:r.length,height:1}),this.setState({colorTexture:o})}_updateWeightmap(){let{radiusPixels:e,colorDomain:r,aggregation:o}=this.props,{worldBounds:n,textureSize:i,weightsScale:s,weightsTexture:a}=this.state,c=this.state.weightsTransform;this.state.isWeightMapDirty=!1;let l=this._worldToCommonBounds(n,{useLayerCoordinateSystem:!0});if(r&&o==="SUM"){let{viewport:y}=this.context,b=y.distanceScales.metersPerUnit[2]*(l[2]-l[0])/i;this.state.colorDomain=[r[0]*b*s,r[1]*b*s]}else this.state.colorDomain=r||VH;let u=this.getAttributeManager().getAttributes(),d=this.getModuleSettings();this._setModelAttributes(c.model,u),c.model.setVertexCount(this.getNumInstances());let h={radiusPixels:e,commonBounds:l,textureWidth:i,weightsScale:s,weightsTexture:a},{viewport:p,devicePixelRatio:m,coordinateSystem:g,coordinateOrigin:_}=d,{modelMatrix:x}=this.props;c.model.shaderInputs.setProps({project:{viewport:p,devicePixelRatio:m,modelMatrix:x,coordinateSystem:g,coordinateOrigin:_},weight:h}),c.run({parameters:{viewport:[0,0,i,i]},clearColor:[0,0,0,0]}),this._updateMaxWeightValue()}_debouncedUpdateWeightmap(e=!1){let{updateTimer:r}=this.state,{debounceTimeout:o}=this.props;e?(r=null,this._updateBounds(!0),this._updateTextureRenderingBounds(),this.setState({isWeightMapDirty:!0})):(this.setState({isWeightMapDirty:!1}),clearTimeout(r),r=setTimeout(this._debouncedUpdateWeightmap.bind(this,!0),o)),this.setState({updateTimer:r})}_worldToCommonBounds(e,r={}){let{useLayerCoordinateSystem:o=!1}=r,[n,i,s,a]=e,{viewport:c}=this.context,{textureSize:l}=this.state,{coordinateSystem:f}=this.props,u=o&&(f==="lnglat-offsets"||f==="meter-offsets"),d=u?c.projectPosition(this.props.coordinateOrigin):[0,0],h=l*bge/c.scale,p,m;return o&&!u?(p=this.projectPosition([n,i,0]),m=this.projectPosition([s,a,0])):(p=c.projectPosition([n,i,0]),m=c.projectPosition([s,a,0])),wH([p[0]-d[0],p[1]-d[1],m[0]-d[0],m[1]-d[1]],h,h)}_commonToWorldBounds(e){let[r,o,n,i]=e,{viewport:s}=this.context,a=s.unprojectPosition([r,o]),c=s.unprojectPosition([n,i]);return a.slice(0,2).concat(c.slice(0,2))}};Qh.layerName="HeatmapLayer";Qh.defaultProps=Tge;var zH=Qh;Au();var Ux="deck-gl-google-maps-container",bw=85.05113;function kx(t,e,r,o){if(r){if(r.userData._googleMap===t)return r;Vx(r)}let n={click:null,rightclick:null,dblclick:null,mousemove:null,mouseout:null},i=new An({...o,useDevicePixels:o.useDevicePixels??!0,style:o.interleaved?null:{pointerEvents:"none"},parent:Cge(e,o.style),views:new di({repeat:!0}),initialViewState:{longitude:0,latitude:0,zoom:1},controller:!1});for(let s in n)n[s]=t.addListener(s,a=>wge(i,s,a));return i.userData._googleMap=t,i.userData._eventListeners=n,i}function Cge(t,e){let r=document.createElement("div");r.style.position="absolute",Object.assign(r.style,e);let n=t.getMap().getDiv().querySelector(`#${Ux}`);return n?n.appendChild(r):"getPanes"in t&&t.getPanes()?.overlayLayer.appendChild(r),r}function Vx(t){let{_eventListeners:e}=t.userData;for(let r in e)e[r]&&e[r].remove();t.finalize()}function HH(t,e){let{width:r,height:o}=WH(t),n=e.getProjection(),i=t.getBounds();if(!i)return{width:r,height:o,left:0,top:0};let s=i.getNorthEast(),a=i.getSouthWest(),c=n.fromLatLngToDivPixel(s),l=n.fromLatLngToDivPixel(a),f=Aw(n,r/2,o/2),u=new google.maps.LatLng(0,f[0]),d=n.fromLatLngToContainerPixel(u),h=n.fromLatLngToDivPixel(u);if(!c||!l||!h||!d)return{width:r,height:o,left:0,top:0};let p=Math.round(h.x-d.x),m=h.y-d.y,g=Aw(n,r/2,0),_=Aw(n,r/2,o),x=f[1],y=f[0];if(Math.abs(x)>bw){x=x>0?bw:-bw;let S=new google.maps.LatLng(x,y),A=n.fromLatLngToContainerPixel(S);m+=A.y-o/2}m=Math.round(m);let T=180*new Gr(g).sub(_).verticalAngle()/Math.PI;T<0&&(T+=360);let v=t.getHeading()||0,w=t.getZoom()-1,C;if(T===0)C=o?(l.y-c.y)/o:1;else if(T===v){let S=new Gr([c.x,c.y]).sub([l.x,l.y]).len(),A=new Gr([r,-o]).len();C=A?S/A:1}return w+=Math.log2(C||1),{width:r,height:o,left:p,top:m,zoom:w,bearing:T,pitch:t.getTilt(),latitude:x,longitude:y}}function jH(t,e){let{width:r,height:o}=WH(t),{center:n,heading:i,tilt:s,zoom:a}=e.getCameraParams(),c=25,l=o?r/o:1,f=.75,u=3e14,d=new V().perspective({fovy:c*Math.PI/180,aspect:l,near:f,far:u}),h=.5*d[5];return{width:r,height:o,viewState:{altitude:h,bearing:i,latitude:n.lat(),longitude:n.lng(),pitch:s,projectionMatrix:d,repeat:!0,zoom:a-1}}}function WH(t){let e=t.getDiv().firstChild;return{width:e.offsetWidth,height:e.offsetHeight}}function Aw(t,e,r){let o=new google.maps.Point(e,r),n=t.fromContainerPixelToLatLng(o);return[n.lng(),n.lat()]}function Ege(t,e){if(t.pixel)return t.pixel;let r=e.getViewports()[0].project([t.latLng.lng(),t.latLng.lat()]);return{x:r[0],y:r[1]}}function wge(t,e,r){if(!t.isInitialized)return;let o={type:e,offsetCenter:Ege(r,t),srcEvent:r};switch(e){case"click":case"rightclick":o.type="click",o.tapCount=1,t._onPointerDown(o),t._onEvent(o);break;case"dblclick":o.type="click",o.tapCount=2,t._onEvent(o);break;case"mousemove":o.type="pointermove",t._onPointerMove(o);break;case"mouseout":o.type="pointerleave",t._onPointerMove(o);break;default:return}}var Pge=()=>!1,Mge={depthMask:!0,depthTest:!0,blend:!0,blendFunc:[770,771,1,771],blendEquation:32774};function zx(){}var GH={interleaved:!0},ep=class{constructor(e){this.props={},this._map=null,this._deck=null,this._overlay=null,this._positioningOverlay=null,this._externalFramebuffer=null,this.setProps({...GH,...e})}setMap(e){if(e===this._map)return;let{VECTOR:r,UNINITIALIZED:o}=google.maps.RenderingType;this._map&&(!e&&this._map.getRenderingType()===r&&this.props.interleaved&&this._overlay.requestRedraw(),this._overlay?.setMap(null),this._positioningOverlay?.setMap(null),this._map=null),e&&(this._map=e,e.getRenderingType()!==o?this._createOverlay(e):e.addListener("renderingtype_changed",()=>{this._createOverlay(e)}))}setProps(e){if(Object.assign(this.props,e),this._deck){let r=this._deck.props.parent||this._deck.getCanvas()?.parentElement;if(e.style&&r){let o=r.style;Object.assign(o,e.style),e.style=null}this._deck.setProps(e)}}pickObject(e){return this._deck&&this._deck.pickObject(e)}pickMultipleObjects(e){return this._deck&&this._deck.pickMultipleObjects(e)}pickObjects(e){return this._deck&&this._deck.pickObjects(e)}finalize(){this.setMap(null),this._deck&&(Vx(this._deck),this._deck=null)}_createOverlay(e){let{VECTOR:r,UNINITIALIZED:o}=google.maps.RenderingType,n=e.getRenderingType();if(n===o)return;n===r&&google.maps.WebGLOverlayView?this._createOverlayVector(e):this._createOverlayRaster(e)}_createOverlayVector(e){let r=this.props.interleaved??GH.interleaved,o=new google.maps.OverlayView;o.onAdd=this._onAddVectorOverlay.bind(this),o.draw=this._updateContainerSize.bind(this),o.onRemove=this._onRemove.bind(this),this._positioningOverlay=o,this._positioningOverlay.setMap(e);let n=new google.maps.WebGLOverlayView;n.onAdd=zx,n.onContextRestored=r?this._onContextRestored.bind(this):zx,n.onDraw=this._onDrawVector.bind(this),n.onContextLost=r?this._onContextLost.bind(this):zx,n.onRemove=r?this._onRemove.bind(this):zx,this._overlay=n,this._overlay.setMap(e)}_createOverlayRaster(e){let r=new google.maps.OverlayView;r.onAdd=this._onAdd.bind(this),r.draw=this._onDrawRaster.bind(this),r.onRemove=this._onRemove.bind(this),this._overlay=r,this._overlay.setMap(e)}_onAdd(){this._deck=kx(this._map,this._overlay,this._deck,this.props)}_onAddVectorOverlay(){let e=this._positioningOverlay,r=e.getPanes();if(r){let o=document.createElement("div");o.id=Ux,o.style.position="absolute",r.overlayLayer.appendChild(o)}this._deck=kx(this._map,e,this._deck,this.props)}_updateContainerSize(){if(!this._map)return;let e=this._map.getDiv().querySelector(`#${Ux}`);if(!e)return;let r=this._map.getDiv().firstChild;if(!r)return;let o=r.offsetWidth,n=r.offsetHeight;e.style.width=`${o}px`,e.style.height=`${n}px`,e.style.left=`${-o/2}px`,e.style.top=`${-n/2}px`}_onContextRestored({gl:e}){if(!this._map||!this._overlay)return;let r=()=>{this._overlay&&this._overlay.requestRedraw()},o=kx(this._map,this._overlay,this._deck,{gl:e,_customRender:r,...this.props});this._deck=o;let n=o.animationLoop;n._renderFrame=()=>{let i=e.getParameter(34964);o.device.withParametersWebGL({},()=>{n.props.onRender(n.animationProps)}),e.bindBuffer(34962,i)}}_onContextLost(){this._deck&&(Vx(this._deck),this._deck=null)}_onRemove(){this._deck?.setProps({layerFilter:Pge})}_onDrawRaster(){if(!this._deck||!this._map)return;let e=this._deck,{width:r,height:o,left:n,top:i,...s}=HH(this._map,this._overlay),c=e.getCanvas()?.parentElement||e.props.parent;if(c){let f=c.style;f.left=`${n}px`,f.top=`${i}px`}let l=1e4;e.setProps({width:r,height:o,viewState:{altitude:l,...s}}),e.redraw()}_onDrawVector({gl:e,transformer:r}){if(!this._deck||!this._map)return;let o=this._deck,{interleaved:n}=this.props;if(o.setProps({...jH(this._map,r),...n&&{width:null,height:null}}),n&&o.isInitialized){let i=o.device;if(i instanceof Zt){let s=i.getParametersWebGL(36006),a=null;if(s){if(this._externalFramebuffer?.handle!==s){this._externalFramebuffer?.wrapper.destroy();let c=i.createFramebuffer({handle:s,width:e.canvas.width,height:e.canvas.height});this._externalFramebuffer={handle:s,wrapper:c}}a=this._externalFramebuffer.wrapper}o.setProps({_framebuffer:a})}o.needsRedraw({clearRedrawFlags:!0}),i instanceof Zt&&(i.setParametersWebGL({viewport:[0,0,e.canvas.width,e.canvas.height],scissor:[0,0,e.canvas.width,e.canvas.height],stencilFunc:[519,0,255,519,0,255]}),i.withParametersWebGL(Mge,()=>{o._drawLayers("google-vector",{clearCanvas:!1})}))}else n||o.redraw()}};var tp=class{constructor(e){ge(e.id,"id is required"),this.id=e.id,this.type="custom",this.renderingMode=e.renderingMode||"3d",this.slot=e.slot,this.beforeId=e.beforeId,this.map=null}onAdd(e,r){this.map=e}render(e,r){this.map&&$H(this.map.__deck,this.map,this,r)}};var Tw="__UNDEFINED__";function Il(t){return t.props.beforeId?`deck-layer-group-before:${t.props.beforeId}`:t.props.slot?`deck-layer-group-slot:${t.props.slot}`:"deck-layer-group-last"}function XH(t,e,r){if(!t||!t.style||!t.style._loaded)return;let o=kt(r,Boolean);if(e!==r){let s=kt(e,Boolean),a=new Set(s.map(l=>Il(l))),c=new Set(o.map(l=>Il(l)));for(let l of a)c.has(l)||t.getLayer(l)&&t.removeLayer(l)}let n={};for(let s of o){let a=Il(s),c=t.getLayer(a);if(c){let l=c.implementation||c;n[a]=l}else{let l=new tp({id:a,slot:s.props.slot,beforeId:s.props.beforeId});n[a]=l,t.addLayer(l,s.props.beforeId)}}let i=t.style._order;for(let[s,a]of Object.entries(n)){let c=a.beforeId||Tw,l=c===Tw?i.length:i.indexOf(c);if(l===-1)continue;if(i.indexOf(s)!==l-1){let u=c===Tw?void 0:c;t.moveLayer(s,u)}}}var oa="mapbox",vw=512,Rge=Math.PI/180;function KH({map:t,deck:e}){if(t.__deck)return t.__deck;let r=e.props._customRender,o=e.props.onLoad,n={...e.props,_customRender:()=>{t.triggerRepaint(),r?.("")}};return n.views||(n.views=rp(t)),Object.assign(n,{width:null,height:null,touchAction:"unset",viewState:Ll(t)}),e.isInitialized?YH(e,t):n.onLoad=()=>{o?.(),YH(e,t)},e.setProps(n),t.__deck=e,t.on("render",()=>{e.isInitialized&&Lge(e,t)}),e}function YH(t,e){let r=()=>{t.isInitialized?Bge(t,e):e.off("move",r)};e.on("move",r)}function qH(t){t.__deck?.finalize(),t.__deck=null}function Hx(t,e){return e?{depthWriteEnabled:!0,depthCompare:"less-equal",depthBias:0,blend:!0,blendColorSrcFactor:"src-alpha",blendColorDstFactor:"one-minus-src-alpha",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one-minus-src-alpha",blendColorOperation:"add",blendAlphaOperation:"add"}:{}}function $H(t,e,r,o){if(!t.isInitialized)return;let{currentViewport:n}=t.userData,i=!1;n||(n=ZH(t,e,o),t.userData.currentViewport=n,i=!0),n&&t._drawLayers("mapbox-repaint",{viewports:[n],layerFilter:s=>{if(t.props.layerFilter&&!t.props.layerFilter(s))return!1;let a=s.layer;return a.props.beforeId===r.beforeId&&a.props.slot===r.slot},clearStack:i,clearCanvas:!1})}function Sw(t){let e=t.getProjection?.(),r=e?.type||e?.name;if(r==="globe")return"globe";if(r&&r!=="mercator")throw new Error("Unsupported projection");return"mercator"}function rp(t){return Sw(t)==="globe"?new k_({id:oa}):new di({id:oa})}function Ll(t){let{lng:e,lat:r}=t.getCenter(),o={longitude:(e+540)%360-180,latitude:r,zoom:t.getZoom(),bearing:t.getBearing(),pitch:t.getPitch(),padding:t.getPadding(),repeat:t.getRenderWorldCopies()};return t.getTerrain?.()&&Ige(t,o),o}function Ige(t,e){if(t.getFreeCameraOptions){let{position:r}=t.getFreeCameraOptions();if(!r||r.z===void 0)return;let o=t.transform.height,{longitude:n,latitude:i,pitch:s}=e,a=r.x*vw,c=(1-r.y)*vw,l=r.z*vw,f=Oe([n,i]),u=a-f[0],d=c-f[1],h=Math.sqrt(u*u+d*d),p=s*Rge,m=1.5*o,g=p<.001?m*Math.cos(p)/l:m*Math.sin(p)/h;e.zoom=Math.log2(g);let _=m*Math.cos(p)/g,x=l-_;e.position=[0,0,x/fs(i)]}else typeof t.transform.elevation=="number"&&(e.position=[0,0,t.transform.elevation])}function ZH(t,e,r){let o=Ll(e),n=t.getView(oa)||rp(e);r&&(n.props.nearZMultiplier=.2);let i=r?.nearZ??e.transform._nearZ,s=r?.farZ??e.transform._farZ;return Number.isFinite(i)&&(o.nearZ=i/e.transform.height,o.farZ=s/e.transform.height),n.makeViewport({width:t.width,height:t.height,viewState:o})}function Lge(t,e){let o=kt(t.props.layers,Boolean).some(a=>a&&!e.getLayer(Il(a))),n=t.getViewports(),i=n.findIndex(a=>a.id===oa),s=n.length>1||i<0;if(o||s){if(i>=0){n=n.slice();let a=ZH(t,e);a?n[i]=a:n.splice(i,1)}t._drawLayers("mapbox-repaint",{viewports:n,layerFilter:a=>(!t.props.layerFilter||t.props.layerFilter(a))&&(a.viewport.id!==oa||!e.getLayer(Il(a.layer))),clearCanvas:!1})}else{let a=t.device,c=a?.gl;t.props.onBeforeRender?.({device:a,gl:c}),t.props.onAfterRender?.({device:a,gl:c})}t.userData.currentViewport=null}function Bge(t,e){t.setProps({viewState:Ll(e)}),t.needsRedraw({clearRedrawFlags:!0})}var op=class{constructor(e){this._handleStyleChange=()=>{if(this._resolveLayers(this._map,this._deck,this._props.layers,this._props.layers),!this._map)return;Sw(this._map)&&this._deck?.setProps({views:this._getViews(this._map)})},this._updateContainerSize=()=>{if(this._map&&this._container){let{clientWidth:o,clientHeight:n}=this._map.getContainer();Object.assign(this._container.style,{width:`${o}px`,height:`${n}px`})}},this._updateViewState=()=>{let o=this._deck,n=this._map;o&&n&&(o.setProps({views:this._getViews(n),viewState:Ll(n)}),o.isInitialized&&o.redraw())},this._handleMouseEvent=o=>{let n=this._deck;if(!n||!n.isInitialized)return;let i={type:o.type,offsetCenter:o.point,srcEvent:o},s=this._lastMouseDownPoint;switch(!o.point&&s&&(i.deltaX=o.originalEvent.clientX-s.clientX,i.deltaY=o.originalEvent.clientY-s.clientY,i.offsetCenter={x:s.x+i.deltaX,y:s.y+i.deltaY}),i.type){case"mousedown":n._onPointerDown(i),this._lastMouseDownPoint={...o.point,clientX:o.originalEvent.clientX,clientY:o.originalEvent.clientY};break;case"dragstart":i.type="panstart",n._onEvent(i);break;case"drag":i.type="panmove",n._onEvent(i);break;case"dragend":i.type="panend",n._onEvent(i);break;case"click":i.tapCount=1,n._onEvent(i);break;case"dblclick":i.type="click",i.tapCount=2,n._onEvent(i);break;case"mousemove":i.type="pointermove",n._onPointerMove(i);break;case"mouseout":i.type="pointerleave",n._onPointerMove(i);break;default:return}};let{interleaved:r=!1}=e;this._interleaved=r,this._props=this.filterProps(e)}filterProps(e){let{interleaved:r=!1,useDevicePixels:o,...n}=e;return!r&&o!==void 0&&(n.useDevicePixels=o),n}setProps(e){this._interleaved&&e.layers&&this._resolveLayers(this._map,this._deck,this._props.layers,e.layers),Object.assign(this._props,this.filterProps(e)),this._deck&&this._map&&this._deck.setProps({...this._props,views:this._getViews(this._map),parameters:{...Hx(this._map,this._interleaved),...this._props.parameters}})}onAdd(e){return this._map=e,this._interleaved?this._onAddInterleaved(e):this._onAddOverlaid(e)}_onAddOverlaid(e){let r=document.createElement("div");return Object.assign(r.style,{position:"absolute",left:0,top:0,textAlign:"initial",pointerEvents:"none"}),this._container=r,this._deck=new An({...this._props,parent:r,parameters:{...Hx(e,!1),...this._props.parameters},views:this._getViews(e),viewState:Ll(e)}),e.on("resize",this._updateContainerSize),e.on("render",this._updateViewState),e.on("mousedown",this._handleMouseEvent),e.on("dragstart",this._handleMouseEvent),e.on("drag",this._handleMouseEvent),e.on("dragend",this._handleMouseEvent),e.on("mousemove",this._handleMouseEvent),e.on("mouseout",this._handleMouseEvent),e.on("click",this._handleMouseEvent),e.on("dblclick",this._handleMouseEvent),this._updateContainerSize(),r}_onAddInterleaved(e){let r=e.painter.context.gl;return r instanceof WebGLRenderingContext&&N.warn("Incompatible basemap library. See: https://deck.gl/docs/api-reference/mapbox/overview#compatibility")(),this._deck=KH({map:e,deck:new An({...this._props,views:this._getViews(e),gl:r,parameters:{...Hx(e,!0),...this._props.parameters}})}),e.on("styledata",this._handleStyleChange),this._resolveLayers(e,this._deck,[],this._props.layers),document.createElement("div")}_resolveLayers(e,r,o,n){XH(e,o,n)}onRemove(){let e=this._map;e&&(this._interleaved?this._onRemoveInterleaved(e):this._onRemoveOverlaid(e)),this._deck=void 0,this._map=void 0,this._container=void 0}_onRemoveOverlaid(e){e.off("resize",this._updateContainerSize),e.off("render",this._updateViewState),e.off("mousedown",this._handleMouseEvent),e.off("dragstart",this._handleMouseEvent),e.off("drag",this._handleMouseEvent),e.off("dragend",this._handleMouseEvent),e.off("mousemove",this._handleMouseEvent),e.off("mouseout",this._handleMouseEvent),e.off("click",this._handleMouseEvent),e.off("dblclick",this._handleMouseEvent),this._deck?.finalize()}_onRemoveInterleaved(e){e.off("styledata",this._handleStyleChange),this._resolveLayers(e,this._deck,this._props.layers,[]),qH(e)}getDefaultPosition(){return"top-left"}pickObject(e){return ge(this._deck),this._deck.pickObject(e)}pickMultipleObjects(e){return ge(this._deck),this._deck.pickMultipleObjects(e)}pickObjects(e){return ge(this._deck),this._deck.pickObjects(e)}finalize(){this._map&&this._map.removeControl(this)}getCanvas(){return this._map?this._interleaved?this._map.getCanvas():this._deck.getCanvas():null}_getViews(e){if(!this._props.views)return rp(e);let r=Array.isArray(this._props.views)?this._props.views:[this._props.views];return r.some(n=>n.id===oa)?this._props.views:[rp(e),...r]}};var Xx,Re,r8,Oge,na,JH,o8,Cw,Mw,Ew,ww,Fge,np={},n8=[],Nge=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Rw=Array.isArray;function Ni(t,e){for(var r in e)t[r]=e[r];return t}function i8(t){var e=t.parentNode;e&&e.removeChild(t)}function Dge(t,e,r){var o,n,i,s={};for(i in e)i=="key"?o=e[i]:i=="ref"?n=e[i]:s[i]=e[i];if(arguments.length>2&&(s.children=arguments.length>3?Xx.call(arguments,2):r),typeof t=="function"&&t.defaultProps!=null)for(i in t.defaultProps)s[i]===void 0&&(s[i]=t.defaultProps[i]);return Wx(t,s,o,n,null)}function Wx(t,e,r,o,n){var i={type:t,props:e,key:r,ref:o,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:n??++r8,__i:-1,__u:0};return n==null&&Re.vnode!=null&&Re.vnode(i),i}function Di(t){return t.children}function Gx(t,e){this.props=t,this.context=e}function ia(t,e){if(e==null)return t.__?ia(t.__,t.__i+1):null;for(var r;e<t.__k.length;e++)if((r=t.__k[e])!=null&&r.__e!=null)return r.__e;return typeof t.type=="function"?ia(t):null}function s8(t){var e,r;if((t=t.__)!=null&&t.__c!=null){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if((r=t.__k[e])!=null&&r.__e!=null){t.__e=t.__c.base=r.__e;break}return s8(t)}}function QH(t){(!t.__d&&(t.__d=!0)&&na.push(t)&&!$x.__r++||JH!==Re.debounceRendering)&&((JH=Re.debounceRendering)||o8)($x)}function $x(){var t,e,r,o,n,i,s,a;for(na.sort(Cw);t=na.shift();)t.__d&&(e=na.length,o=void 0,i=(n=(r=t).__v).__e,s=[],a=[],r.__P&&((o=Ni({},n)).__v=n.__v+1,Re.vnode&&Re.vnode(o),Iw(r.__P,o,n,r.__n,r.__P.namespaceURI,32&n.__u?[i]:null,s,i??ia(n),!!(32&n.__u),a),o.__v=n.__v,o.__.__k[o.__i]=o,l8(s,o,a),o.__e!=i&&s8(o)),na.length>e&&na.sort(Cw));$x.__r=0}function a8(t,e,r,o,n,i,s,a,c,l,f){var u,d,h,p,m,g=o&&o.__k||n8,_=e.length;for(r.__d=c,Uge(r,e,g),c=r.__d,u=0;u<_;u++)(h=r.__k[u])!=null&&typeof h!="boolean"&&typeof h!="function"&&(d=h.__i===-1?np:g[h.__i]||np,h.__i=u,Iw(t,h,d,n,i,s,a,c,l,f),p=h.__e,h.ref&&d.ref!=h.ref&&(d.ref&&Lw(d.ref,null,h),f.push(h.ref,h.__c||p,h)),m==null&&p!=null&&(m=p),65536&h.__u||d.__k===h.__k?c=c8(h,c,t):typeof h.type=="function"&&h.__d!==void 0?c=h.__d:p&&(c=p.nextSibling),h.__d=void 0,h.__u&=-196609);r.__d=c,r.__e=m}function Uge(t,e,r){var o,n,i,s,a,c=e.length,l=r.length,f=l,u=0;for(t.__k=[],o=0;o<c;o++)s=o+u,(n=t.__k[o]=(n=e[o])==null||typeof n=="boolean"||typeof n=="function"?null:typeof n=="string"||typeof n=="number"||typeof n=="bigint"||n.constructor==String?Wx(null,n,null,null,null):Rw(n)?Wx(Di,{children:n},null,null,null):n.constructor===void 0&&n.__b>0?Wx(n.type,n.props,n.key,n.ref?n.ref:null,n.__v):n)!=null?(n.__=t,n.__b=t.__b+1,a=kge(n,r,s,f),n.__i=a,i=null,a!==-1&&(f--,(i=r[a])&&(i.__u|=131072)),i==null||i.__v===null?(a==-1&&u--,typeof n.type!="function"&&(n.__u|=65536)):a!==s&&(a==s-1?u--:a==s+1?u++:a>s?f>c-s?u+=a-s:u--:a<s&&(a==s-u?u-=a-s:u++),a!==o+u&&(n.__u|=65536))):(i=r[s])&&i.key==null&&i.__e&&!(131072&i.__u)&&(i.__e==t.__d&&(t.__d=ia(i)),Pw(i,i,!1),r[s]=null,f--);if(f)for(o=0;o<l;o++)(i=r[o])!=null&&!(131072&i.__u)&&(i.__e==t.__d&&(t.__d=ia(i)),Pw(i,i))}function c8(t,e,r){var o,n;if(typeof t.type=="function"){for(o=t.__k,n=0;o&&n<o.length;n++)o[n]&&(o[n].__=t,e=c8(o[n],e,r));return e}t.__e!=e&&(e&&t.type&&!r.contains(e)&&(e=ia(t)),r.insertBefore(t.__e,e||null),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType===8);return e}function kge(t,e,r,o){var n=t.key,i=t.type,s=r-1,a=r+1,c=e[r];if(c===null||c&&n==c.key&&i===c.type&&!(131072&c.__u))return r;if(o>(c!=null&&!(131072&c.__u)?1:0))for(;s>=0||a<e.length;){if(s>=0){if((c=e[s])&&!(131072&c.__u)&&n==c.key&&i===c.type)return s;s--}if(a<e.length){if((c=e[a])&&!(131072&c.__u)&&n==c.key&&i===c.type)return a;a++}}return-1}function e8(t,e,r){e[0]==="-"?t.setProperty(e,r??""):t[e]=r==null?"":typeof r!="number"||Nge.test(e)?r:r+"px"}function jx(t,e,r,o,n){var i;e:if(e==="style")if(typeof r=="string")t.style.cssText=r;else{if(typeof o=="string"&&(t.style.cssText=o=""),o)for(e in o)r&&e in r||e8(t.style,e,"");if(r)for(e in r)o&&r[e]===o[e]||e8(t.style,e,r[e])}else if(e[0]==="o"&&e[1]==="n")i=e!==(e=e.replace(/(PointerCapture)$|Capture$/i,"$1")),e=e.toLowerCase()in t||e==="onFocusOut"||e==="onFocusIn"?e.toLowerCase().slice(2):e.slice(2),t.l||(t.l={}),t.l[e+i]=r,r?o?r.u=o.u:(r.u=Mw,t.addEventListener(e,i?ww:Ew,i)):t.removeEventListener(e,i?ww:Ew,i);else{if(n=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=r??"";break e}catch{}typeof r=="function"||(r==null||r===!1&&e[4]!=="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&r==1?"":r))}}function t8(t){return function(e){if(this.l){var r=this.l[e.type+t];if(e.t==null)e.t=Mw++;else if(e.t<r.u)return;return r(Re.event?Re.event(e):e)}}}function Iw(t,e,r,o,n,i,s,a,c,l){var f,u,d,h,p,m,g,_,x,y,b,T,v,w,C,S,A=e.type;if(e.constructor!==void 0)return null;128&r.__u&&(c=!!(32&r.__u),i=[a=e.__e=r.__e]),(f=Re.__b)&&f(e);e:if(typeof A=="function")try{if(_=e.props,x="prototype"in A&&A.prototype.render,y=(f=A.contextType)&&o[f.__c],b=f?y?y.props.value:f.__:o,r.__c?g=(u=e.__c=r.__c).__=u.__E:(x?e.__c=u=new A(_,b):(e.__c=u=new Gx(_,b),u.constructor=A,u.render=zge),y&&y.sub(u),u.props=_,u.state||(u.state={}),u.context=b,u.__n=o,d=u.__d=!0,u.__h=[],u._sb=[]),x&&u.__s==null&&(u.__s=u.state),x&&A.getDerivedStateFromProps!=null&&(u.__s==u.state&&(u.__s=Ni({},u.__s)),Ni(u.__s,A.getDerivedStateFromProps(_,u.__s))),h=u.props,p=u.state,u.__v=e,d)x&&A.getDerivedStateFromProps==null&&u.componentWillMount!=null&&u.componentWillMount(),x&&u.componentDidMount!=null&&u.__h.push(u.componentDidMount);else{if(x&&A.getDerivedStateFromProps==null&&_!==h&&u.componentWillReceiveProps!=null&&u.componentWillReceiveProps(_,b),!u.__e&&(u.shouldComponentUpdate!=null&&u.shouldComponentUpdate(_,u.__s,b)===!1||e.__v===r.__v)){for(e.__v!==r.__v&&(u.props=_,u.state=u.__s,u.__d=!1),e.__e=r.__e,e.__k=r.__k,e.__k.forEach(function(M){M&&(M.__=e)}),T=0;T<u._sb.length;T++)u.__h.push(u._sb[T]);u._sb=[],u.__h.length&&s.push(u);break e}u.componentWillUpdate!=null&&u.componentWillUpdate(_,u.__s,b),x&&u.componentDidUpdate!=null&&u.__h.push(function(){u.componentDidUpdate(h,p,m)})}if(u.context=b,u.props=_,u.__P=t,u.__e=!1,v=Re.__r,w=0,x){for(u.state=u.__s,u.__d=!1,v&&v(e),f=u.render(u.props,u.state,u.context),C=0;C<u._sb.length;C++)u.__h.push(u._sb[C]);u._sb=[]}else do u.__d=!1,v&&v(e),f=u.render(u.props,u.state,u.context),u.state=u.__s;while(u.__d&&++w<25);u.state=u.__s,u.getChildContext!=null&&(o=Ni(Ni({},o),u.getChildContext())),x&&!d&&u.getSnapshotBeforeUpdate!=null&&(m=u.getSnapshotBeforeUpdate(h,p)),a8(t,Rw(S=f!=null&&f.type===Di&&f.key==null?f.props.children:f)?S:[S],e,r,o,n,i,s,a,c,l),u.base=e.__e,e.__u&=-161,u.__h.length&&s.push(u),g&&(u.__E=u.__=null)}catch(M){if(e.__v=null,c||i!=null){for(e.__u|=c?160:32;a&&a.nodeType===8&&a.nextSibling;)a=a.nextSibling;i[i.indexOf(a)]=null,e.__e=a}else e.__e=r.__e,e.__k=r.__k;Re.__e(M,e,r)}else i==null&&e.__v===r.__v?(e.__k=r.__k,e.__e=r.__e):e.__e=Vge(r.__e,e,r,o,n,i,s,c,l);(f=Re.diffed)&&f(e)}function l8(t,e,r){e.__d=void 0;for(var o=0;o<r.length;o++)Lw(r[o],r[++o],r[++o]);Re.__c&&Re.__c(e,t),t.some(function(n){try{t=n.__h,n.__h=[],t.some(function(i){i.call(n)})}catch(i){Re.__e(i,n.__v)}})}function Vge(t,e,r,o,n,i,s,a,c){var l,f,u,d,h,p,m,g=r.props,_=e.props,x=e.type;if(x==="svg"?n="http://www.w3.org/2000/svg":x==="math"?n="http://www.w3.org/1998/Math/MathML":n||(n="http://www.w3.org/1999/xhtml"),i!=null){for(l=0;l<i.length;l++)if((h=i[l])&&"setAttribute"in h==!!x&&(x?h.localName===x:h.nodeType===3)){t=h,i[l]=null;break}}if(t==null){if(x===null)return document.createTextNode(_);t=document.createElementNS(n,x,_.is&&_),i=null,a=!1}if(x===null)g===_||a&&t.data===_||(t.data=_);else{if(i=i&&Xx.call(t.childNodes),g=r.props||np,!a&&i!=null)for(g={},l=0;l<t.attributes.length;l++)g[(h=t.attributes[l]).name]=h.value;for(l in g)if(h=g[l],l!="children"){if(l=="dangerouslySetInnerHTML")u=h;else if(l!=="key"&&!(l in _)){if(l=="value"&&"defaultValue"in _||l=="checked"&&"defaultChecked"in _)continue;jx(t,l,null,h,n)}}for(l in _)h=_[l],l=="children"?d=h:l=="dangerouslySetInnerHTML"?f=h:l=="value"?p=h:l=="checked"?m=h:l==="key"||a&&typeof h!="function"||g[l]===h||jx(t,l,h,g[l],n);if(f)a||u&&(f.__html===u.__html||f.__html===t.innerHTML)||(t.innerHTML=f.__html),e.__k=[];else if(u&&(t.innerHTML=""),a8(t,Rw(d)?d:[d],e,r,o,x==="foreignObject"?"http://www.w3.org/1999/xhtml":n,i,s,i?i[0]:r.__k&&ia(r,0),a,c),i!=null)for(l=i.length;l--;)i[l]!=null&&i8(i[l]);a||(l="value",p!==void 0&&(p!==t[l]||x==="progress"&&!p||x==="option"&&p!==g[l])&&jx(t,l,p,g[l],n),l="checked",m!==void 0&&m!==t[l]&&jx(t,l,m,g[l],n))}return t}function Lw(t,e,r){try{if(typeof t=="function"){var o=typeof t.__u=="function";o&&t.__u(),o&&e==null||(t.__u=t(e))}else t.current=e}catch(n){Re.__e(n,r)}}function Pw(t,e,r){var o,n;if(Re.unmount&&Re.unmount(t),(o=t.ref)&&(o.current&&o.current!==t.__e||Lw(o,null,e)),(o=t.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(i){Re.__e(i,e)}o.base=o.__P=null}if(o=t.__k)for(n=0;n<o.length;n++)o[n]&&Pw(o[n],e,r||typeof t.type!="function");r||t.__e==null||i8(t.__e),t.__c=t.__=t.__e=t.__d=void 0}function zge(t,e,r){return this.constructor(t,r)}function te(t,e,r){var o,n,i,s;Re.__&&Re.__(t,e),n=(o=typeof r=="function")?null:r&&r.__k||e.__k,i=[],s=[],Iw(e,t=(!o&&r||e).__k=Dge(Di,null,[t]),n||np,np,e.namespaceURI,!o&&r?[r]:n?null:e.firstChild?Xx.call(e.childNodes):null,i,!o&&r?r:n?n.__e:e.firstChild,o,s),l8(i,t,s)}Xx=n8.slice,Re={__e:function(t,e,r,o){for(var n,i,s;e=e.__;)if((n=e.__c)&&!n.__)try{if((i=n.constructor)&&i.getDerivedStateFromError!=null&&(n.setState(i.getDerivedStateFromError(t)),s=n.__d),n.componentDidCatch!=null&&(n.componentDidCatch(t,o||{}),s=n.__d),s)return n.__E=n}catch(a){t=a}throw t}},r8=0,Oge=function(t){return t!=null&&t.constructor==null},Gx.prototype.setState=function(t,e){var r;r=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=Ni({},this.state),typeof t=="function"&&(t=t(Ni({},r),this.props)),t&&Ni(r,t),t!=null&&this.__v&&(e&&this._sb.push(e),QH(this))},Gx.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),QH(this))},Gx.prototype.render=Di,na=[],o8=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Cw=function(t,e){return t.__v.__b-e.__v.__b},$x.__r=0,Mw=0,Ew=t8(!1),ww=t8(!0),Fge=0;var Hge=0,Mlt=Array.isArray;function I(t,e,r,o,n,i){e||(e={});var s,a,c=e;if("ref"in c)for(a in c={},e)a=="ref"?s=e[a]:c[a]=e[a];var l={type:t,props:c,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:--Hge,__i:-1,__u:0,__source:n,__self:i};if(typeof t=="function"&&(s=t.defaultProps))for(a in s)c[a]===void 0&&(c[a]=s[a]);return Re.vnode&&Re.vnode(l),l}var Yx=t=>{let{children:e,orientation:r="horizontal"}=t;return I("div",{className:`deck-widget-button-group ${r}`,children:e})};var Bl,Xe,Bw,f8,ip=0,y8=[],et=Re,u8=et.__b,d8=et.__r,h8=et.diffed,p8=et.__c,m8=et.unmount,g8=et.__;function qx(t,e){et.__h&&et.__h(Xe,t,ip||e),ip=0;var r=Xe.__H||(Xe.__H={__:[],__h:[]});return t>=r.__.length&&r.__.push({}),r.__[t]}function Ui(t){return ip=1,jge(x8,t)}function jge(t,e,r){var o=qx(Bl++,2);if(o.t=t,!o.__c&&(o.__=[r?r(e):x8(void 0,e),function(a){var c=o.__N?o.__N[0]:o.__[0],l=o.t(c,a);c!==l&&(o.__N=[l,o.__[1]],o.__c.setState({}))}],o.__c=Xe,!Xe.u)){var n=function(a,c,l){if(!o.__c.__H)return!0;var f=o.__c.__H.__.filter(function(d){return!!d.__c});if(f.every(function(d){return!d.__N}))return!i||i.call(this,a,c,l);var u=!1;return f.forEach(function(d){if(d.__N){var h=d.__[0];d.__=d.__N,d.__N=void 0,h!==d.__[0]&&(u=!0)}}),!(!u&&o.__c.props===a)&&(!i||i.call(this,a,c,l))};Xe.u=!0;var i=Xe.shouldComponentUpdate,s=Xe.componentWillUpdate;Xe.componentWillUpdate=function(a,c,l){if(this.__e){var f=i;i=void 0,n(a,c,l),i=f}s&&s.call(this,a,c,l)},Xe.shouldComponentUpdate=n}return o.__N||o.__}function Hr(t,e){var r=qx(Bl++,3);!et.__s&&Nw(r.__H,e)&&(r.__=t,r.i=e,Xe.__H.__h.push(r))}function Fw(t,e){var r=qx(Bl++,4);!et.__s&&Nw(r.__H,e)&&(r.__=t,r.i=e,Xe.__h.push(r))}function Bt(t){return ip=5,On(function(){return{current:t}},[])}function On(t,e){var r=qx(Bl++,7);return Nw(r.__H,e)&&(r.__=t(),r.__H=e,r.__h=t),r.__}function Fn(t,e){return ip=8,On(function(){return t},e)}function Wge(){for(var t;t=y8.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(Kx),t.__H.__h.forEach(Ow),t.__H.__h=[]}catch(e){t.__H.__h=[],et.__e(e,t.__v)}}et.__b=function(t){Xe=null,u8&&u8(t)},et.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),g8&&g8(t,e)},et.__r=function(t){d8&&d8(t),Bl=0;var e=(Xe=t.__c).__H;e&&(Bw===Xe?(e.__h=[],Xe.__h=[],e.__.forEach(function(r){r.__N&&(r.__=r.__N),r.i=r.__N=void 0})):(e.__h.forEach(Kx),e.__h.forEach(Ow),e.__h=[],Bl=0)),Bw=Xe},et.diffed=function(t){h8&&h8(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(y8.push(e)!==1&&f8===et.requestAnimationFrame||((f8=et.requestAnimationFrame)||Gge)(Wge)),e.__H.__.forEach(function(r){r.i&&(r.__H=r.i),r.i=void 0})),Bw=Xe=null},et.__c=function(t,e){e.some(function(r){try{r.__h.forEach(Kx),r.__h=r.__h.filter(function(o){return!o.__||Ow(o)})}catch(o){e.some(function(n){n.__h&&(n.__h=[])}),e=[],et.__e(o,r.__v)}}),p8&&p8(t,e)},et.unmount=function(t){m8&&m8(t);var e,r=t.__c;r&&r.__H&&(r.__H.__.forEach(function(o){try{Kx(o)}catch(n){e=n}}),r.__H=void 0,e&&et.__e(e,r.__v))};var _8=typeof requestAnimationFrame=="function";function Gge(t){var e,r=function(){clearTimeout(o),_8&&cancelAnimationFrame(e),setTimeout(t)},o=setTimeout(r,100);_8&&(e=requestAnimationFrame(r))}function Kx(t){var e=Xe,r=t.__c;typeof r=="function"&&(t.__c=void 0,r()),Xe=e}function Ow(t){var e=Xe;t.__c=t.__(),Xe=e}function Nw(t,e){return!t||t.length!==e.length||e.some(function(r,o){return r!==t[o]})}function x8(t,e){return typeof e=="function"?e(t):e}function Zx(t){if(!t)return;let e=`url("${t.replace(/"/g,"'")}")`;return{maskImage:e,WebkitMaskImage:e}}var Me=t=>{let{className:e="",style:r,color:o,icon:n,label:i,onClick:s,children:a}=t,c=On(()=>{let l=Zx(n);return o?{...l,backgroundColor:o}:l},[o,n]);return I("div",{className:"deck-widget-button",style:r,children:I("button",{className:`deck-widget-icon-button ${e}`,type:"button",onClick:s,title:i,children:a||I("div",{className:"deck-widget-icon",style:c})})})};var sp=class extends ${constructor(e={}){super(e),this.className="deck-widget-zoom",this.placement="top-left",this.setProps(this.props)}setProps(e){this.placement=e.placement??this.placement,this.viewId=e.viewId??this.viewId,super.setProps(e)}onRenderHTML(e){let r=I(Yx,{orientation:this.props.orientation,children:[I(Me,{onClick:()=>this.handleZoomIn(),label:this.props.zoomInLabel,className:"deck-widget-zoom-in"}),I(Me,{onClick:()=>this.handleZoomOut(),label:this.props.zoomOutLabel,className:"deck-widget-zoom-out"})]});te(r,e)}isOrthographicView(e){let r=this.deck;return(r?.isInitialized&&r.getView(e))instanceof D_}handleZoom(e,r){let o=this.getViewState(e),n={};if(this.isOrthographicView(e)){let{zoomAxis:s}=this.props,{zoomX:a,minZoomX:c,maxZoomX:l,zoomY:f,minZoomY:u,maxZoomY:d}=$ge(o),h,p;if(s==="X")h=Jx(a+r,c,l),p=f;else if(s==="Y")h=a,p=Jx(f+r,u,d);else{let m=Jx(r,Math.max(c-a,u-f),Math.min(l-a,d-f));h=a+m,p=f+m}n.zoom=[h,p],n.zoomX=h,n.zoomY=p,this.props.onZoom?.({viewId:e,delta:r,zoom:s==="Y"?p:h,zoomX:h,zoomY:p})}else{let{zoom:s=0,minZoom:a,maxZoom:c}=o,l=Jx(s+r,a,c);n.zoom=l,this.props.onZoom?.({viewId:e,delta:r,zoom:l})}let i={...o,...n};this.props.transitionDuration>0&&(i.transitionDuration=this.props.transitionDuration,i.transitionInterpolator="latitude"in i?new so:new Ue({transitionProps:"zoomX"in n?["zoomX","zoomY"]:["zoom"]})),this.setViewState(e,i)}handleZoomIn(){for(let e of this.viewIds)this.handleZoom(e,1)}handleZoomOut(){for(let e of this.viewIds)this.handleZoom(e,-1)}};sp.defaultProps={...$.defaultProps,id:"zoom",placement:"top-left",orientation:"vertical",transitionDuration:200,zoomInLabel:"Zoom In",zoomOutLabel:"Zoom Out",zoomAxis:"all",viewId:null,onZoom:()=>{}};function Jx(t,e,r){return t<e?e:t>r?r:t}function $ge({zoom:t=0,zoomX:e,zoomY:r,minZoom:o=-1/0,maxZoom:n=1/0,minZoomX:i=o,maxZoomX:s=n,minZoomY:a=o,maxZoomY:c=n}){return e=e??(Array.isArray(t)?t[0]:t),r=r??(Array.isArray(t)?t[1]:t),{zoomX:e,zoomY:r,minZoomX:i,minZoomY:a,maxZoomX:s,maxZoomY:c}}var ap=class extends ${constructor(e={}){super(e),this.className="deck-widget-reset-view",this.placement="top-left",this.setProps(this.props)}setProps(e){this.placement=e.placement??this.placement,this.viewId=e.viewId??this.viewId,super.setProps(e)}onRenderHTML(e){te(I(Me,{className:"deck-widget-reset-focus",label:this.props.label,onClick:this.handleClick.bind(this)}),e)}handleClick(){let e=this.props.initialViewState||this.deck?.props.initialViewState;this.resetViewState(e)}resetViewState(e){for(let r of this.viewIds){let o={...e?.[r]??e};this.props.onReset?.({viewId:r,viewState:o}),this.setViewState(r,o)}}};ap.defaultProps={...$.defaultProps,id:"reset-view",placement:"top-left",label:"Reset View",initialViewState:void 0,viewId:null,onReset:()=>{}};var cp=class extends ${constructor(e={}){super(e),this.className="deck-widget-gimbal",this.placement="top-left",this.viewports={},this.setProps(this.props)}setProps(e){this.placement=e.placement??this.placement,this.viewId=e.viewId??this.viewId,super.setProps(e)}onRenderHTML(e){let r=this.viewId||Object.values(this.viewports)[0]?.id||"default-view",o=this.viewports[r],{rotationOrbit:n,rotationX:i}=this.getNormalizedRotation(o),s=I("div",{className:"deck-widget-button",style:{perspective:100,pointerEvents:"auto"},children:I("button",{type:"button",onClick:()=>{for(let a of Object.values(this.viewports))this.resetOrbitView(a)},title:this.props.label,style:{position:"relative",width:26,height:26},children:[I("svg",{className:"gimbal-outer-ring",width:"100%",height:"100%",viewBox:"0 0 26 26",style:{position:"absolute",top:0,left:0,transform:`rotateY(${n}deg)`},children:I("circle",{cx:"13",cy:"13",r:"10",stroke:"var(--icon-gimbal-outer-color, rgb(68, 92, 204))",strokeWidth:this.props.strokeWidth,fill:"none"})}),I("svg",{className:"gimbal-inner-ring",width:"100%",height:"100%",viewBox:"0 0 26 26",style:{position:"absolute",top:0,left:0,transform:`rotateX(${i}deg)`},children:I("circle",{cx:"13",cy:"13",r:"7",stroke:"var(--icon-gimbal-inner-color, rgb(240, 92, 68))",strokeWidth:this.props.strokeWidth,fill:"none"})})]})});te(s,e)}onViewportChange(e){this.viewports[e.id]=e,this.updateHTML()}resetOrbitView(e){let r=this.viewId||e?.id||"OrbitView",o=this.getViewState(r);if("rotationOrbit"in o||"rotationX"in o){this.props.onReset?.({viewId:r,rotationOrbit:0,rotationX:0});let n={...o,rotationOrbit:0,rotationX:0,transitionDuration:this.props.transitionDuration,transitionInterpolator:new Ue({transitionProps:["rotationOrbit","rotationX"]})};this.setViewState(r,n)}}getNormalizedRotation(e){let r=this.viewId||e?.id||"OrbitView",o=this.getViewState(r),[n,i]=this.getRotation(o),s=b8(n),a=b8(i);return{rotationOrbit:s,rotationX:a}}getRotation(e){return e&&("rotationOrbit"in e||"rotationX"in e)?[-(e.rotationOrbit||0),e.rotationX||0]:[0,0]}};cp.defaultProps={...$.defaultProps,id:"gimbal",placement:"top-left",viewId:null,label:"Gimbal",strokeWidth:1.5,transitionDuration:200,onReset:()=>{}};function b8(t){let e=((t+180)%360+360)%360-180,r=10,o=e-90;return Math.abs(o)<r&&(o<r?e=90+r:o>-r&&(e=90-r)),e}var lp=class extends ${constructor(e={}){super(e),this.className="deck-widget-compass",this.placement="top-left",this.viewports={},this.setProps(this.props)}setProps(e){this.placement=e.placement??this.placement,this.viewId=e.viewId??this.viewId,super.setProps(e)}onRenderHTML(e){let r=this.viewId||Object.values(this.viewports)[0]?.id,o=this.viewports[r],[n,i]=this.getRotation(o),s=I("div",{className:"deck-widget-button",style:{perspective:100},children:I("button",{type:"button",onClick:()=>{for(let a of Object.values(this.viewports))this.handleCompassReset(a)},title:this.props.label,style:{transform:`rotateX(${i}deg)`},children:I("svg",{fill:"none",width:"100%",height:"100%",viewBox:"0 0 26 26",children:I("g",{transform:`rotate(${n},13,13)`,children:[I("path",{d:"M10 13.0001L12.9999 5L15.9997 13.0001H10Z",fill:"var(--icon-compass-north-color, rgb(240, 92, 68))"}),I("path",{d:"M16.0002 12.9999L13.0004 21L10.0005 12.9999H16.0002Z",fill:"var(--icon-compass-south-color, rgb(204, 204, 204))"})]})})})});te(s,e)}onViewportChange(e){e.equals(this.viewports[e.id])||(this.viewports[e.id]=e,this.updateHTML())}getRotation(e){return e instanceof Mt?[-e.bearing,e.pitch]:e instanceof Oo?[0,Math.max(-80,Math.min(80,e.latitude))]:[0,0]}handleCompassReset(e){let r=this.viewId||e.id;if(e instanceof Mt){let o=this.getViewState(r),n=this.getRotation(e)[0]===0,i=0,s=n?0:e.pitch;this.props.onReset?.({viewId:r,bearing:i,pitch:s});let a={...o,bearing:i,...n?{pitch:s}:{},transitionDuration:this.props.transitionDuration,transitionInterpolator:new so};this.setViewState(r,a)}}};lp.defaultProps={...$.defaultProps,id:"compass",placement:"top-left",viewId:null,label:"Reset Compass",transitionDuration:200,onReset:()=>{}};var fp=class extends ${constructor(e={}){super(e),this.className="deck-widget-scale",this.placement="bottom-left",this.scaleWidth=10,this.scaleValue=0,this.scaleText="",this.setProps(this.props)}setProps(e){this.placement=e.placement??this.placement,this.viewId=e.viewId??this.viewId,super.setProps(e)}onRenderHTML(e){let o=50+this.scaleWidth,n=10;te(I("svg",{className:"deck-widget-scale",width:o,height:30,style:{overflow:"visible",background:"transparent"},onClick:this.handleClick.bind(this),children:[I("text",{x:50+5,y:"10",textAnchor:"end",alignmentBaseline:"middle",style:{fontSize:"16px",fill:"black",fontWeight:"bold",fontFamily:"sans-serif"},children:this.scaleText}),I("line",{x1:50,y1:"15",x2:50+this.scaleWidth,y2:"15",stroke:"black",strokeWidth:"6"}),I("line",{x1:50,y1:"15",x2:50,y2:15-n,stroke:"black",strokeWidth:"6"}),I("line",{x1:50+this.scaleWidth,y1:"15",x2:50+this.scaleWidth,y2:15-n,stroke:"black",strokeWidth:"6"})]}),e)}onViewportChange(e){if(!("latitude"in e))return;let{latitude:r,zoom:o}=e,n=Xge(r,o),{candidate:i,candidatePixels:s}=Yge(n);this.scaleValue=i,this.scaleWidth=s,i>=1e3?this.scaleText=`${(i/1e3).toFixed(1)} km`:this.scaleText=`${i} m`,this.updateHTML()}handleClick(){}};fp.defaultProps={...$.defaultProps,id:"scale",placement:"bottom-left",label:"Scale",viewId:null};function Xge(t,e){return 40075016686e-3*Math.cos(t*Math.PI/180)/Math.pow(2,e+8)}function Yge(t){let n=150*t,i=Math.floor(Math.log10(n)),s=Math.pow(10,i),a=[1,2,5],c=a[0]*s,l=c/t;for(let f=0;f<a.length;f++){let u=a[f]*s,d=u/t;if(d>=100&&d<=200){c=u,l=d;break}if(d>200){c=f>0?a[f-1]*s:u,l=c/t;break}f===a.length-1&&d<100&&(c=a[0]*s*10,l=c/t)}return{candidate:c,candidatePixels:l}}function Kge(t){return typeof t=="string"?t:t.value}function qge(t){return typeof t=="string"?t:t.label}function Zge(t){return typeof t=="string"?void 0:t.icon}var Qx=t=>{let[e,r]=Ui(!1);return I(sa,{...t,style:{...t.style,position:"absolute"},isOpen:e,onClose:()=>r(!1),trigger:I("button",{className:"deck-widget-dropdown-button",onClick:()=>r(!e),children:I("span",{className:`deck-widget-dropdown-icon ${e?"open":""}`})})})},sa=t=>{let e=Bt(null);Hr(()=>{let o=n=>{e.current&&!e.current.contains(n.target)&&t.onClose()};return document.addEventListener("mousedown",o),()=>{document.removeEventListener("mousedown",o)}},[]);let r=(o,n)=>{o&&(typeof n=="object"&&n.onSelect?.(),t.onSelect?.(o),t.onClose())};return t.menuItems.length===0?null:I("div",{className:"deck-widget-dropdown-container",ref:e,children:[t.trigger,t.isOpen&&I("ul",{className:"deck-widget-dropdown-menu",style:t.style,children:t.menuItems.map((o,n)=>{let i=Kge(o),s=Zge(o);return I("li",{className:`deck-widget-dropdown-item ${i?"":"disabled"}`,onClick:()=>r(i,o),children:[s&&I("span",{className:"deck-widget-dropdown-item-icon",style:Zx(s)}),qge(o)]},n)})})]})};var Jge="current",A8="deck-geocoder-history",eb=class{constructor(e){this.addressText="",this.errorText="",this.addressHistory=[],this.props={maxEntries:5,...e},this.addressHistory=this.loadPreviousAddresses()}async geocode(e,r,o){this.errorText="",this.addressText=r;try{let n=await e.geocode(r,o);if(n)return this.storeAddress(this.addressText),n;this.errorText="Invalid address"}catch(n){this.errorText=`${n.message}`}return null}loadPreviousAddresses(){try{let e=window.localStorage.getItem(A8),r=e&&JSON.parse(e);return Array.isArray(r)?r.filter(n=>typeof n=="string"):[]}catch{}return[]}storeAddress(e){let r=e.trim();if(!r||r===Jge)return;let o=[r,...this.addressHistory.filter(n=>n!==r)];this.addressHistory=o.slice(0,this.props.maxEntries);try{window.localStorage.setItem(A8,JSON.stringify(this.addressHistory))}catch{}}};var Qge="https://maps.googleapis.com/maps/api/geocode/json",e_e="https://api.mapbox.com/geocoding/v5/mapbox.places",t_e="https://api.opencagedata.com/geocode/v1/json",tb={name:"google",requiresApiKey:!0,async geocode(t,e){let r=encodeURIComponent(t),o=await Dw(`${Qge}?address=${r}&key=${e}`);switch(o.status){case"OK":let n=o.results.length>0&&o.results[0].geometry.location;return n?{longitude:n.lng,latitude:n.lat}:null;default:throw new Error(`Google Geocoder failed: ${o.status}`)}}},rb={name:"google",requiresApiKey:!0,async geocode(t,e){let r=encodeURIComponent(t),o=await Dw(`${e_e}/${r}.json?access_token=${e}`);if(Array.isArray(o.features)&&o.features.length>0){let n=o.features[0].center;if(Array.isArray(n)&&n.length>=2)return{longitude:n[0],latitude:n[1]}}return null}},ob={name:"opencage",requiresApiKey:!0,async geocode(t,e){let r=encodeURIComponent(t),o=await Dw(`${t_e}?q=${r}&key=${e}`);if(Array.isArray(o.results)&&o.results.length>0){let n=o.results[0].geometry;return{longitude:n.lng,latitude:n.lat}}return null}},nb={name:"current",requiresApiKey:!1,async geocode(){if(!navigator.geolocation)throw new Error("Geolocation not supported");return new Promise((t,e)=>{navigator.geolocation.getCurrentPosition(r=>{let{longitude:o,latitude:n}=r.coords;t({longitude:o,latitude:n})},r=>e(new Error(r.message)))})}};async function Dw(t){let e;try{e=await fetch(t)}catch(o){throw new Error(`CORS error? ${o}. ${t}: `)}if(!e.ok)throw new Error(`${e.statusText}. ${t}: `);let r=await e.json();if(!r)throw new Error(`No data returned. ${t}`);return r}var Ol={name:"coordinates",requiresApiKey:!1,placeholderLocation:"-122.45, 37.8 or 37\xB048'N, 122\xB027'W",async geocode(t){return r_e(t)||null}};function r_e(t){t=t.trim();let e=t.split(/[,;]/).map(n=>n.trim());if(e.length<2)return null;let r=T8(e[0]),o=T8(e[1]);return r===null||o===null||Math.abs(r)>90&&Math.abs(o)>90?null:Math.abs(r)>90?{longitude:r,latitude:o}:Math.abs(o)>90?{longitude:o,latitude:r}:{latitude:r,longitude:o}}function T8(t){if(t=t.trim(),t.includes("\xB0")||t.includes("'")||t.includes('"')){let o=o_e(t);return isNaN(o)?null:o}let e=1;/[SW]/i.test(t)&&(e=-1),t=t.replace(/[NSEW]/gi,"");let r=parseFloat(t);return isNaN(r)?null:e*r}function o_e(t){let e=/(-?\d+)[°d]\s*(\d+)?['′m]?\s*(\d+(?:\.\d+)?)?[\"″s]?\s*([NSEW])?/i,r=t.match(e);if(!r)return NaN;let o=parseFloat(r[1])||0,n=parseFloat(r[2])||0,i=parseFloat(r[3])||0,s=r[4]||"",a=o<0?-1:1,c=Math.abs(o)+n/60+i/3600;return/[SW]/i.test(s)?c=-c:c=a*c,c}var v8="current",n_e="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'%3E%3Cpath d='M480-480q33 0 56.5-23.5T560-560q0-33-23.5-56.5T480-640q-33 0-56.5 23.5T400-560q0 33 23.5 56.5T480-480Zm0 294q122-112 181-203.5T720-552q0-109-69.5-178.5T480-800q-101 0-170.5 69.5T240-552q0 71 59 162.5T480-186Zm0 106Q319-217 239.5-334.5T160-552q0-150 96.5-239T480-880q127 0 223.5 89T800-552q0 100-79.5 217.5T480-80Z'/%3E%3C/svg%3E",i_e={label:"Current location",value:v8,icon:n_e},up=class extends ${constructor(e={}){super(e),this.className="deck-widget-geocoder",this.placement="top-left",this.geocodeHistory=new eb({}),this.addressText="",this.geocoder=Ol,this.isGettingLocation=!1,this.setInput=r=>{this.addressText=r},this.handleKeyPress=r=>{r.key==="Enter"&&this.handleSubmit()},this.handleSelect=r=>{r===v8?this.getCurrentLocation():(this.setInput(r),this.handleSubmit())},this.handleSubmit=()=>{this.geocode(this.addressText)},this.getCurrentLocation=async()=>{this.isGettingLocation=!0,this.rootElement&&this.updateHTML();try{let r=await nb.geocode();r&&this.flyTo(r)}catch(r){this.geocodeHistory.errorText=r instanceof Error?r.message:"Location error"}finally{this.isGettingLocation=!1,this.rootElement&&this.updateHTML()}},this.geocode=async r=>{let o=await this.geocodeHistory.geocode(this.geocoder,this.addressText,this.props.apiKey);this.rootElement&&this.updateHTML(),o&&this.flyTo(o)},this.setProps(this.props)}setProps(e){if(this.placement=e.placement??this.placement,this.viewId=e.viewId??this.viewId,this.geocoder=s_e(this.props),this.geocoder.requiresApiKey&&!this.props.apiKey)throw new Error(`API key is required for the ${this.geocoder.name} geocoder`);super.setProps(e)}onRenderHTML(e){let r=this.props._geolocation?[i_e,...this.geocodeHistory.addressHistory]:[...this.geocodeHistory.addressHistory];te(I("div",{className:"deck-widget-geocoder",children:[I("input",{className:"deck-widget-geocoder-input",type:"text",placeholder:this.isGettingLocation?"Finding your location...":this.geocoder.placeholderLocation??"Enter address or location",value:this.geocodeHistory.addressText,onInput:o=>this.setInput(o.target?.value||""),onKeyPress:this.handleKeyPress}),I(Qx,{menuItems:r,onSelect:this.handleSelect}),this.geocodeHistory.errorText&&I("div",{className:"deck-widget-geocoder-error",children:this.geocodeHistory.errorText})]}),e)}flyTo(e){for(let r of this.viewIds){"longitude"in e&&"latitude"in e&&this.props.onGeocode?.({viewId:r,coordinates:{longitude:e.longitude,latitude:e.latitude,zoom:e.zoom}});let n={...this.getViewState(r),...e};this.props.transitionDuration>0&&(n.transitionDuration=this.props.transitionDuration,n.transitionInterpolator="latitude"in n?new so:new Ue),this.setViewState(r,n)}}};up.defaultProps={...$.defaultProps,id:"geocoder",viewId:null,placement:"top-left",label:"Geocoder",transitionDuration:200,geocoder:"coordinates",customGeocoder:Ol,apiKey:"",_geolocation:!1,onGeocode:()=>{}};function s_e(t){switch(t.geocoder){case"google":return tb;case"mapbox":return rb;case"opencage":return ob;case"coordinates":return Ol;case"custom":if(!t.customGeocoder)throw new Error("Custom geocoder is not defined");return t.customGeocoder;default:throw new Error(`Unknown geocoder: ${t.geocoder}`)}}var dp=class extends ${constructor(e={}){super(e),this.className="deck-widget-fullscreen",this.placement="top-left",this.fullscreen=!1,this.setProps(this.props)}onAdd(){document.addEventListener("fullscreenchange",this.onFullscreenChange.bind(this))}onRemove(){document.removeEventListener("fullscreenchange",this.onFullscreenChange.bind(this))}onRenderHTML(e){let r=this.getFullscreen();te(I(Me,{onClick:()=>{this.handleClick().catch(o=>N.error(o)())},label:r?this.props.exitLabel:this.props.enterLabel,className:r?"deck-widget-fullscreen-exit":"deck-widget-fullscreen-enter"}),e)}setProps(e){this.placement=e.placement??this.placement,this.viewId=e.viewId??this.viewId,super.setProps(e)}getContainer(){return this.props.container||this.deck?.props.parent||this.deck?.getCanvas()?.parentElement}getFullscreen(){return this.fullscreen}onFullscreenChange(){let e=document.fullscreenElement===this.getContainer();e!==this.fullscreen&&(this.fullscreen=e,this.props.onFullscreenChange?.(e),this.updateHTML())}async handleClick(){this.getFullscreen()?await this.exitFullscreen():await this.requestFullscreen()}async requestFullscreen(){let e=this.getContainer();e?.requestFullscreen?await e.requestFullscreen({navigationUI:"hide"}):this.togglePseudoFullscreen()}async exitFullscreen(){document.exitFullscreen?await document.exitFullscreen():this.togglePseudoFullscreen()}togglePseudoFullscreen(){this.getContainer()?.classList.toggle("deck-pseudo-fullscreen"),this.fullscreen=!this.fullscreen,this.props.onFullscreenChange?.(this.fullscreen),this.updateHTML()}};dp.defaultProps={...$.defaultProps,id:"fullscreen",placement:"top-left",viewId:null,enterLabel:"Enter Fullscreen",exitLabel:"Exit Fullscreen",container:void 0,onFullscreenChange:()=>{}};function S8(t){let e=[],r=n=>"views"in n;function o(n){let i=e.length,s=n.minSplit??.05,a=n.maxSplit??.95,c=Math.min(Math.max(n.initialSplit??.5,s),a),l={id:i,orientation:n.orientation,views:n.views,split:c,editable:n.editable??!0,minSplit:s,maxSplit:a,x:0,y:0,width:0,height:0};return e.push(l),l.views=[r(n.views[0])?o(n.views[0]):n.views[0],r(n.views[1])?o(n.views[1]):n.views[1]],l}return o(t),e}function C8(t){let e=[];function r(o,n,i,s,a){o.x=n,o.y=i,o.width=s,o.height=a;let c=n,l=i,f=s,u=a,d=n,h=i,p=s,m=a;o.orientation==="horizontal"?(f=s*o.split,d=n+f,p=s-f):(u=a*o.split,h=i+u,m=a-u);let[g,_]=o.views;"views"in g?r(g,c,l,f,u):e.push(g.clone({x:`${c}%`,y:`${l}%`,width:`${f}%`,height:`${u}%`})),"views"in _?r(_,d,h,p,m):e.push(_.clone({x:`${d}%`,y:`${h}%`,width:`${p}%`,height:`${m}%`}))}return r(t,0,0,100,100),e}var hp=class extends ${constructor(e){super(e),this.className="deck-widget-splitter",this.placement="fill",this.needsUpdate=!0,this.viewLayouts=S8(this.props.viewLayout)}setProps(e){e.viewLayout&&!ie(e.viewLayout,this.props.viewLayout,-1)&&(this.viewLayouts=S8(e.viewLayout),this.views=void 0),super.setProps(e)}onRedraw(){super.updateHTML()}updateHTML(){this.views||(this.views=C8(this.viewLayouts[0]),this.props.onChange(this.views.slice())),requestAnimationFrame(()=>{this.doUpdate()})}doUpdate(){if(this.deck){let e=this.deck.props.views;!(e&&e!==this.lastViews)&&this.lastViews!==this.views&&(this.lastViews=this.views,this.deck.setProps({views:this.views}))}}onChange(e,r){r.split=e,this.views=C8(this.viewLayouts[0]),this.props.onChange(this.views.slice()),this.doUpdate()}onRenderHTML(e){te(I(Di,{children:this.viewLayouts.map(r=>r.editable&&I(a_e,{...r,onChange:o=>this.onChange(o,r),onDragStart:()=>this.props.onDragStart(),onDragEnd:()=>this.props.onDragStart()}))}),e)}};hp.defaultProps={...$.defaultProps,id:"splitter-widget",viewLayout:void 0,onChange:()=>{},onDragStart:()=>{},onDragEnd:()=>{}};function a_e({orientation:t,x:e,y:r,width:o,height:n,split:i,minSplit:s,maxSplit:a,onChange:c,onDragStart:l,onDragEnd:f}){let[u,d]=Ui(!1),h=Bt(null);Hr(()=>{if(!u)return;let _=y=>{if(!h.current)return;let b=h.current.getBoundingClientRect(),T;t==="horizontal"?T=(y.clientX-b.left)/b.width:T=(y.clientY-b.top)/b.height,T=Math.min(Math.max(T,s),a),c?.(T)},x=()=>{f?.(),d(!1)};return document.addEventListener("pointermove",_),document.addEventListener("pointerup",x),document.addEventListener("pointerleave",x),()=>{document.removeEventListener("pointermove",_),document.removeEventListener("pointerup",x),document.removeEventListener("pointerleave",x)}},[u]);let p=_=>{d(!0),l?.(),_.preventDefault()},m=t==="horizontal"?{left:`${i*100}%`}:{top:`${i*100}%`},g={position:"absolute",top:`${r}%`,left:`${e}%`,width:`${o}%`,height:`${n}%`};return I("div",{ref:h,style:g,children:I("div",{className:`deck-widget-splitter-handle deck-widget-splitter-handle--${t} ${u?"active":""}`,style:m,onPointerDown:p})})}var ki=Math.min,Nn=Math.max,mp=Math.round,gp=Math.floor,po=t=>({x:t,y:t}),c_e={left:"right",right:"left",bottom:"top",top:"bottom"};function sb(t,e,r){return Nn(t,ki(e,r))}function Fl(t,e){return typeof t=="function"?t(e):t}function Vi(t){return t.split("-")[0]}function Nl(t){return t.split("-")[1]}function Uw(t){return t==="x"?"y":"x"}function ab(t){return t==="y"?"height":"width"}function Dn(t){let e=t[0];return e==="t"||e==="b"?"y":"x"}function cb(t){return Uw(Dn(t))}function P8(t,e,r){r===void 0&&(r=!1);let o=Nl(t),n=cb(t),i=ab(n),s=n==="x"?o===(r?"end":"start")?"right":"left":o==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(s=pp(s)),[s,pp(s)]}function M8(t){let e=pp(t);return[ib(t),e,ib(e)]}function ib(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}var E8=["left","right"],w8=["right","left"],l_e=["top","bottom"],f_e=["bottom","top"];function u_e(t,e,r){switch(t){case"top":case"bottom":return r?e?w8:E8:e?E8:w8;case"left":case"right":return e?l_e:f_e;default:return[]}}function R8(t,e,r,o){let n=Nl(t),i=u_e(Vi(t),r==="start",o);return n&&(i=i.map(s=>s+"-"+n),e&&(i=i.concat(i.map(ib)))),i}function pp(t){let e=Vi(t);return c_e[e]+t.slice(e.length)}function d_e(t){return{top:0,right:0,bottom:0,left:0,...t}}function kw(t){return typeof t!="number"?d_e(t):{top:t,right:t,bottom:t,left:t}}function aa(t){let{x:e,y:r,width:o,height:n}=t;return{width:o,height:n,top:r,left:e,right:e+o,bottom:r+n,x:e,y:r}}function I8(t,e,r){let{reference:o,floating:n}=t,i=Dn(e),s=cb(e),a=ab(s),c=Vi(e),l=i==="y",f=o.x+o.width/2-n.width/2,u=o.y+o.height/2-n.height/2,d=o[a]/2-n[a]/2,h;switch(c){case"top":h={x:f,y:o.y-n.height};break;case"bottom":h={x:f,y:o.y+o.height};break;case"right":h={x:o.x+o.width,y:u};break;case"left":h={x:o.x-n.width,y:u};break;default:h={x:o.x,y:o.y}}switch(Nl(e)){case"start":h[s]-=d*(r&&l?-1:1);break;case"end":h[s]+=d*(r&&l?-1:1);break}return h}async function L8(t,e){var r;e===void 0&&(e={});let{x:o,y:n,platform:i,rects:s,elements:a,strategy:c}=t,{boundary:l="clippingAncestors",rootBoundary:f="viewport",elementContext:u="floating",altBoundary:d=!1,padding:h=0}=Fl(e,t),p=kw(h),g=a[d?u==="floating"?"reference":"floating":u],_=aa(await i.getClippingRect({element:(r=await(i.isElement==null?void 0:i.isElement(g)))==null||r?g:g.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(a.floating)),boundary:l,rootBoundary:f,strategy:c})),x=u==="floating"?{x:o,y:n,width:s.floating.width,height:s.floating.height}:s.reference,y=await(i.getOffsetParent==null?void 0:i.getOffsetParent(a.floating)),b=await(i.isElement==null?void 0:i.isElement(y))?await(i.getScale==null?void 0:i.getScale(y))||{x:1,y:1}:{x:1,y:1},T=aa(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:x,offsetParent:y,strategy:c}):x);return{top:(_.top-T.top+p.top)/b.y,bottom:(T.bottom-_.bottom+p.bottom)/b.y,left:(_.left-T.left+p.left)/b.x,right:(T.right-_.right+p.right)/b.x}}var h_e=50,B8=async(t,e,r)=>{let{placement:o="bottom",strategy:n="absolute",middleware:i=[],platform:s}=r,a=s.detectOverflow?s:{...s,detectOverflow:L8},c=await(s.isRTL==null?void 0:s.isRTL(e)),l=await s.getElementRects({reference:t,floating:e,strategy:n}),{x:f,y:u}=I8(l,o,c),d=o,h=0,p={};for(let m=0;m<i.length;m++){let g=i[m];if(!g)continue;let{name:_,fn:x}=g,{x:y,y:b,data:T,reset:v}=await x({x:f,y:u,initialPlacement:o,placement:d,strategy:n,middlewareData:p,rects:l,platform:a,elements:{reference:t,floating:e}});f=y??f,u=b??u,p[_]={...p[_],...T},v&&h<h_e&&(h++,typeof v=="object"&&(v.placement&&(d=v.placement),v.rects&&(l=v.rects===!0?await s.getElementRects({reference:t,floating:e,strategy:n}):v.rects),{x:f,y:u}=I8(l,d,c)),m=-1)}return{x:f,y:u,placement:d,strategy:n,middlewareData:p}},O8=t=>({name:"arrow",options:t,async fn(e){let{x:r,y:o,placement:n,rects:i,platform:s,elements:a,middlewareData:c}=e,{element:l,padding:f=0}=Fl(t,e)||{};if(l==null)return{};let u=kw(f),d={x:r,y:o},h=cb(n),p=ab(h),m=await s.getDimensions(l),g=h==="y",_=g?"top":"left",x=g?"bottom":"right",y=g?"clientHeight":"clientWidth",b=i.reference[p]+i.reference[h]-d[h]-i.floating[p],T=d[h]-i.reference[h],v=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l)),w=v?v[y]:0;(!w||!await(s.isElement==null?void 0:s.isElement(v)))&&(w=a.floating[y]||i.floating[p]);let C=b/2-T/2,S=w/2-m[p]/2-1,A=ki(u[_],S),M=ki(u[x],S),B=A,O=w-m[p]-M,F=w/2-m[p]/2+C,X=sb(B,F,O),G=!c.arrow&&Nl(n)!=null&&F!==X&&i.reference[p]/2-(F<B?A:M)-m[p]/2<0,j=G?F<B?F-B:F-O:0;return{[h]:d[h]+j,data:{[h]:X,centerOffset:F-X-j,...G&&{alignmentOffset:j}},reset:G}}});var F8=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var r,o;let{placement:n,middlewareData:i,rects:s,initialPlacement:a,platform:c,elements:l}=e,{mainAxis:f=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:m=!0,...g}=Fl(t,e);if((r=i.arrow)!=null&&r.alignmentOffset)return{};let _=Vi(n),x=Dn(a),y=Vi(a)===a,b=await(c.isRTL==null?void 0:c.isRTL(l.floating)),T=d||(y||!m?[pp(a)]:M8(a)),v=p!=="none";!d&&v&&T.push(...R8(a,m,p,b));let w=[a,...T],C=await c.detectOverflow(e,g),S=[],A=((o=i.flip)==null?void 0:o.overflows)||[];if(f&&S.push(C[_]),u){let F=P8(n,s,b);S.push(C[F[0]],C[F[1]])}if(A=[...A,{placement:n,overflows:S}],!S.every(F=>F<=0)){var M,B;let F=(((M=i.flip)==null?void 0:M.index)||0)+1,X=w[F];if(X&&(!(u==="alignment"?x!==Dn(X):!1)||A.every(se=>Dn(se.placement)===x?se.overflows[0]>0:!0)))return{data:{index:F,overflows:A},reset:{placement:X}};let G=(B=A.filter(j=>j.overflows[0]<=0).sort((j,se)=>j.overflows[1]-se.overflows[1])[0])==null?void 0:B.placement;if(!G)switch(h){case"bestFit":{var O;let j=(O=A.filter(se=>{if(v){let ne=Dn(se.placement);return ne===x||ne==="y"}return!0}).map(se=>[se.placement,se.overflows.filter(ne=>ne>0).reduce((ne,pe)=>ne+pe,0)]).sort((se,ne)=>se[1]-ne[1])[0])==null?void 0:O[0];j&&(G=j);break}case"initialPlacement":G=a;break}if(n!==G)return{reset:{placement:G}}}return{}}}};var p_e=new Set(["left","top"]);async function m_e(t,e){let{placement:r,platform:o,elements:n}=t,i=await(o.isRTL==null?void 0:o.isRTL(n.floating)),s=Vi(r),a=Nl(r),c=Dn(r)==="y",l=p_e.has(s)?-1:1,f=i&&c?-1:1,u=Fl(e,t),{mainAxis:d,crossAxis:h,alignmentAxis:p}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return a&&typeof p=="number"&&(h=a==="end"?p*-1:p),c?{x:h*f,y:d*l}:{x:d*l,y:h*f}}var N8=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var r,o;let{x:n,y:i,placement:s,middlewareData:a}=e,c=await m_e(e,t);return s===((r=a.offset)==null?void 0:r.placement)&&(o=a.arrow)!=null&&o.alignmentOffset?{}:{x:n+c.x,y:i+c.y,data:{...c,placement:s}}}}},D8=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){let{x:r,y:o,placement:n,platform:i}=e,{mainAxis:s=!0,crossAxis:a=!1,limiter:c={fn:_=>{let{x,y}=_;return{x,y}}},...l}=Fl(t,e),f={x:r,y:o},u=await i.detectOverflow(e,l),d=Dn(Vi(n)),h=Uw(d),p=f[h],m=f[d];if(s){let _=h==="y"?"top":"left",x=h==="y"?"bottom":"right",y=p+u[_],b=p-u[x];p=sb(y,p,b)}if(a){let _=d==="y"?"top":"left",x=d==="y"?"bottom":"right",y=m+u[_],b=m-u[x];m=sb(y,m,b)}let g=c.fn({...e,[h]:p,[d]:m});return{...g,data:{x:g.x-r,y:g.y-o,enabled:{[h]:s,[d]:a}}}}}};function lb(){return typeof window<"u"}function la(t){return k8(t)?(t.nodeName||"").toLowerCase():"#document"}function or(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function mo(t){var e;return(e=(k8(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function k8(t){return lb()?t instanceof Node||t instanceof or(t).Node:!1}function jr(t){return lb()?t instanceof Element||t instanceof or(t).Element:!1}function Jo(t){return lb()?t instanceof HTMLElement||t instanceof or(t).HTMLElement:!1}function U8(t){return!lb()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof or(t).ShadowRoot}function Ul(t){let{overflow:e,overflowX:r,overflowY:o,display:n}=Wr(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+r)&&n!=="inline"&&n!=="contents"}function V8(t){return/^(table|td|th)$/.test(la(t))}function _p(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}var g_e=/transform|translate|scale|rotate|perspective|filter/,__e=/paint|layout|strict|content/,ca=t=>!!t&&t!=="none",Vw;function fb(t){let e=jr(t)?Wr(t):t;return ca(e.transform)||ca(e.translate)||ca(e.scale)||ca(e.rotate)||ca(e.perspective)||!ub()&&(ca(e.backdropFilter)||ca(e.filter))||g_e.test(e.willChange||"")||__e.test(e.contain||"")}function z8(t){let e=Un(t);for(;Jo(e)&&!fa(e);){if(fb(e))return e;if(_p(e))return null;e=Un(e)}return null}function ub(){return Vw==null&&(Vw=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Vw}function fa(t){return/^(html|body|#document)$/.test(la(t))}function Wr(t){return or(t).getComputedStyle(t)}function yp(t){return jr(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Un(t){if(la(t)==="html")return t;let e=t.assignedSlot||t.parentNode||U8(t)&&t.host||mo(t);return U8(e)?e.host:e}function H8(t){let e=Un(t);return fa(e)?t.ownerDocument?t.ownerDocument.body:t.body:Jo(e)&&Ul(e)?e:H8(e)}function Dl(t,e,r){var o;e===void 0&&(e=[]),r===void 0&&(r=!0);let n=H8(t),i=n===((o=t.ownerDocument)==null?void 0:o.body),s=or(n);if(i){let a=db(s);return e.concat(s,s.visualViewport||[],Ul(n)?n:[],a&&r?Dl(a):[])}else return e.concat(n,Dl(n,[],r))}function db(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function $8(t){let e=Wr(t),r=parseFloat(e.width)||0,o=parseFloat(e.height)||0,n=Jo(t),i=n?t.offsetWidth:r,s=n?t.offsetHeight:o,a=mp(r)!==i||mp(o)!==s;return a&&(r=i,o=s),{width:r,height:o,$:a}}function Hw(t){return jr(t)?t:t.contextElement}function kl(t){let e=Hw(t);if(!Jo(e))return po(1);let r=e.getBoundingClientRect(),{width:o,height:n,$:i}=$8(e),s=(i?mp(r.width):r.width)/o,a=(i?mp(r.height):r.height)/n;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}var y_e=po(0);function X8(t){let e=or(t);return!ub()||!e.visualViewport?y_e:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function x_e(t,e,r){return e===void 0&&(e=!1),!r||e&&r!==or(t)?!1:e}function ua(t,e,r,o){e===void 0&&(e=!1),r===void 0&&(r=!1);let n=t.getBoundingClientRect(),i=Hw(t),s=po(1);e&&(o?jr(o)&&(s=kl(o)):s=kl(t));let a=x_e(i,r,o)?X8(i):po(0),c=(n.left+a.x)/s.x,l=(n.top+a.y)/s.y,f=n.width/s.x,u=n.height/s.y;if(i){let d=or(i),h=o&&jr(o)?or(o):o,p=d,m=db(p);for(;m&&o&&h!==p;){let g=kl(m),_=m.getBoundingClientRect(),x=Wr(m),y=_.left+(m.clientLeft+parseFloat(x.paddingLeft))*g.x,b=_.top+(m.clientTop+parseFloat(x.paddingTop))*g.y;c*=g.x,l*=g.y,f*=g.x,u*=g.y,c+=y,l+=b,p=or(m),m=db(p)}}return aa({width:f,height:u,x:c,y:l})}function hb(t,e){let r=yp(t).scrollLeft;return e?e.left+r:ua(mo(t)).left+r}function Y8(t,e){let r=t.getBoundingClientRect(),o=r.left+e.scrollLeft-hb(t,r),n=r.top+e.scrollTop;return{x:o,y:n}}function b_e(t){let{elements:e,rect:r,offsetParent:o,strategy:n}=t,i=n==="fixed",s=mo(o),a=e?_p(e.floating):!1;if(o===s||a&&i)return r;let c={scrollLeft:0,scrollTop:0},l=po(1),f=po(0),u=Jo(o);if((u||!u&&!i)&&((la(o)!=="body"||Ul(s))&&(c=yp(o)),u)){let h=ua(o);l=kl(o),f.x=h.x+o.clientLeft,f.y=h.y+o.clientTop}let d=s&&!u&&!i?Y8(s,c):po(0);return{width:r.width*l.x,height:r.height*l.y,x:r.x*l.x-c.scrollLeft*l.x+f.x+d.x,y:r.y*l.y-c.scrollTop*l.y+f.y+d.y}}function A_e(t){return Array.from(t.getClientRects())}function T_e(t){let e=mo(t),r=yp(t),o=t.ownerDocument.body,n=Nn(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),i=Nn(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight),s=-r.scrollLeft+hb(t),a=-r.scrollTop;return Wr(o).direction==="rtl"&&(s+=Nn(e.clientWidth,o.clientWidth)-n),{width:n,height:i,x:s,y:a}}var j8=25;function v_e(t,e){let r=or(t),o=mo(t),n=r.visualViewport,i=o.clientWidth,s=o.clientHeight,a=0,c=0;if(n){i=n.width,s=n.height;let f=ub();(!f||f&&e==="fixed")&&(a=n.offsetLeft,c=n.offsetTop)}let l=hb(o);if(l<=0){let f=o.ownerDocument,u=f.body,d=getComputedStyle(u),h=f.compatMode==="CSS1Compat"&&parseFloat(d.marginLeft)+parseFloat(d.marginRight)||0,p=Math.abs(o.clientWidth-u.clientWidth-h);p<=j8&&(i-=p)}else l<=j8&&(i+=l);return{width:i,height:s,x:a,y:c}}function S_e(t,e){let r=ua(t,!0,e==="fixed"),o=r.top+t.clientTop,n=r.left+t.clientLeft,i=Jo(t)?kl(t):po(1),s=t.clientWidth*i.x,a=t.clientHeight*i.y,c=n*i.x,l=o*i.y;return{width:s,height:a,x:c,y:l}}function W8(t,e,r){let o;if(e==="viewport")o=v_e(t,r);else if(e==="document")o=T_e(mo(t));else if(jr(e))o=S_e(e,r);else{let n=X8(t);o={x:e.x-n.x,y:e.y-n.y,width:e.width,height:e.height}}return aa(o)}function K8(t,e){let r=Un(t);return r===e||!jr(r)||fa(r)?!1:Wr(r).position==="fixed"||K8(r,e)}function C_e(t,e){let r=e.get(t);if(r)return r;let o=Dl(t,[],!1).filter(a=>jr(a)&&la(a)!=="body"),n=null,i=Wr(t).position==="fixed",s=i?Un(t):t;for(;jr(s)&&!fa(s);){let a=Wr(s),c=fb(s);!c&&a.position==="fixed"&&(n=null),(i?!c&&!n:!c&&a.position==="static"&&!!n&&(n.position==="absolute"||n.position==="fixed")||Ul(s)&&!c&&K8(t,s))?o=o.filter(f=>f!==s):n=a,s=Un(s)}return e.set(t,o),o}function E_e(t){let{element:e,boundary:r,rootBoundary:o,strategy:n}=t,s=[...r==="clippingAncestors"?_p(e)?[]:C_e(e,this._c):[].concat(r),o],a=W8(e,s[0],n),c=a.top,l=a.right,f=a.bottom,u=a.left;for(let d=1;d<s.length;d++){let h=W8(e,s[d],n);c=Nn(h.top,c),l=ki(h.right,l),f=ki(h.bottom,f),u=Nn(h.left,u)}return{width:l-u,height:f-c,x:u,y:c}}function w_e(t){let{width:e,height:r}=$8(t);return{width:e,height:r}}function P_e(t,e,r){let o=Jo(e),n=mo(e),i=r==="fixed",s=ua(t,!0,i,e),a={scrollLeft:0,scrollTop:0},c=po(0);function l(){c.x=hb(n)}if(o||!o&&!i)if((la(e)!=="body"||Ul(n))&&(a=yp(e)),o){let h=ua(e,!0,i,e);c.x=h.x+e.clientLeft,c.y=h.y+e.clientTop}else n&&l();i&&!o&&n&&l();let f=n&&!o&&!i?Y8(n,a):po(0),u=s.left+a.scrollLeft-c.x-f.x,d=s.top+a.scrollTop-c.y-f.y;return{x:u,y:d,width:s.width,height:s.height}}function zw(t){return Wr(t).position==="static"}function G8(t,e){if(!Jo(t)||Wr(t).position==="fixed")return null;if(e)return e(t);let r=t.offsetParent;return mo(t)===r&&(r=r.ownerDocument.body),r}function q8(t,e){let r=or(t);if(_p(t))return r;if(!Jo(t)){let n=Un(t);for(;n&&!fa(n);){if(jr(n)&&!zw(n))return n;n=Un(n)}return r}let o=G8(t,e);for(;o&&V8(o)&&zw(o);)o=G8(o,e);return o&&fa(o)&&zw(o)&&!fb(o)?r:o||z8(t)||r}var M_e=async function(t){let e=this.getOffsetParent||q8,r=this.getDimensions,o=await r(t.floating);return{reference:P_e(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function R_e(t){return Wr(t).direction==="rtl"}var I_e={convertOffsetParentRelativeRectToViewportRelativeRect:b_e,getDocumentElement:mo,getClippingRect:E_e,getOffsetParent:q8,getElementRects:M_e,getClientRects:A_e,getDimensions:w_e,getScale:kl,isElement:jr,isRTL:R_e};function Z8(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function L_e(t,e){let r=null,o,n=mo(t);function i(){var a;clearTimeout(o),(a=r)==null||a.disconnect(),r=null}function s(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),i();let l=t.getBoundingClientRect(),{left:f,top:u,width:d,height:h}=l;if(a||e(),!d||!h)return;let p=gp(u),m=gp(n.clientWidth-(f+d)),g=gp(n.clientHeight-(u+h)),_=gp(f),y={rootMargin:-p+"px "+-m+"px "+-g+"px "+-_+"px",threshold:Nn(0,ki(1,c))||1},b=!0;function T(v){let w=v[0].intersectionRatio;if(w!==c){if(!b)return s();w?s(!1,w):o=setTimeout(()=>{s(!1,1e-7)},1e3)}w===1&&!Z8(l,t.getBoundingClientRect())&&s(),b=!1}try{r=new IntersectionObserver(T,{...y,root:n.ownerDocument})}catch{r=new IntersectionObserver(T,y)}r.observe(t)}return s(!0),i}function J8(t,e,r,o){o===void 0&&(o={});let{ancestorScroll:n=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:c=!1}=o,l=Hw(t),f=n||i?[...l?Dl(l):[],...e?Dl(e):[]]:[];f.forEach(_=>{n&&_.addEventListener("scroll",r,{passive:!0}),i&&_.addEventListener("resize",r)});let u=l&&a?L_e(l,r):null,d=-1,h=null;s&&(h=new ResizeObserver(_=>{let[x]=_;x&&x.target===l&&h&&e&&(h.unobserve(e),cancelAnimationFrame(d),d=requestAnimationFrame(()=>{var y;(y=h)==null||y.observe(e)})),r()}),l&&!c&&h.observe(l),e&&h.observe(e));let p,m=c?ua(t):null;c&&g();function g(){let _=ua(t);m&&!Z8(m,_)&&r(),m=_,p=requestAnimationFrame(g)}return r(),()=>{var _;f.forEach(x=>{n&&x.removeEventListener("scroll",r),i&&x.removeEventListener("resize",r)}),u?.(),(_=h)==null||_.disconnect(),h=null,c&&cancelAnimationFrame(p)}}var jw=N8;var Ww=D8,Gw=F8;var Q8=O8;var e5=(t,e,r)=>{let o=new Map,n={platform:I_e,...r},i={...n.platform,_c:o};return B8(t,e,{...n,platform:i})};var zi=({x:t,y:e,placement:r="right",offset:o=0,arrow:n=!1,arrowColor:i="white",children:s})=>{let a=Bt(null),c=Bt(null),l=Bt(null),f=Bt();return f.current=()=>{if(!a.current||!c.current)return;let u=Array.isArray(n)?n[0]:n||0,d=Array.isArray(n)?n[1]:n||0,h=o+Math.max(d,u),p=r.includes("-")?[jw(h),Gw(),Ww()]:[jw(h),Ww(),Gw()];l.current&&p.push(Q8({element:l.current})),e5(a.current,c.current,{placement:r,strategy:"fixed",middleware:p}).then(m=>{c.current&&Object.assign(c.current.style,{left:`${m.x}px`,top:`${m.y}px`});let g=m.middlewareData.arrow;if(g&&l.current){let _=B_e(u,d,i,m.placement);_.transform=`translate(${g.x||0}px, ${g.y||0}px)`,Object.assign(l.current.style,_)}})},On(()=>{f.current?.()},[t,e,r,n,o]),Hr(()=>{let u=a.current,d=c.current;if(!u||!d)return;d.style.visibility="visible";let h=J8(u,d,()=>f.current?.());return()=>{h()}},[]),I("div",{style:{position:"absolute",left:t,top:e},ref:a,children:I("div",{className:"deck-widget deck-widget-popover",style:{position:"fixed",visibility:"hidden",pointerEvents:"none"},ref:c,children:[Boolean(n)&&I("div",{className:"deck-widget-popover-arrow",style:{position:"absolute"},ref:l}),s]})})};function B_e(t,e,r,o){let n={width:0,height:0,top:"",bottom:"",left:"",right:""};return o.startsWith("bottom")?(n.borderLeft=`${t/2}px solid transparent`,n.borderRight=`${t/2}px solid transparent`,n.borderBottom=`${e}px solid ${r}`,n.borderTop="",n.top=`${-e}px`):o.startsWith("top")?(n.borderLeft=`${t/2}px solid transparent`,n.borderRight=`${t/2}px solid transparent`,n.borderTop=`${e}px solid ${r}`,n.borderBottom="",n.bottom=`${-e}px`):o.startsWith("right")?(n.borderTop=`${t/2}px solid transparent`,n.borderBottom=`${t/2}px solid transparent`,n.borderRight=`${e}px solid ${r}`,n.borderLeft="",n.left=`${-e}px`):o.startsWith("left")&&(n.borderTop=`${t/2}px solid transparent`,n.borderBottom=`${t/2}px solid transparent`,n.borderLeft=`${e}px solid ${r}`,n.borderRight="",n.right=`${-e}px`),n}var xp=({text:t,html:e,element:r,...o})=>{let n=Bt(null);return Hr(()=>(n.current&&r&&n.current.append(r),()=>{r?.remove()}),[r]),I("div",{ref:n,...o,dangerouslySetInnerHTML:e?{__html:e}:void 0,children:t})};var bp=class extends ${constructor(e){super(e),this.className="deck-widget-info",this.placement="fill",this.tooltip=null,this.setProps(this.props)}setProps(e){this.viewId=e.viewId??this.viewId,super.setProps(e)}onAdd({deck:e}){this.deck=e}onRemove(){this.rootElement&&te(null,this.rootElement)}onViewportChange(e){this.viewport=e,this.updateHTML()}onHover(e){this.props.mode==="hover"&&(this.tooltip=this._getTooltip(e),this.updateHTML())}onClick(e){this.props.mode==="click"&&(this.tooltip=this._getTooltip(e),this.updateHTML())}_getTooltip(e){if(!this.props.getTooltip)return null;let r=this.props.getTooltip(e,this)??null;if(r===null)return null;let o=typeof r=="string"?{text:r}:r,n=o.position||e.coordinate;return n?{position:n,text:"",html:"",element:null,className:"",style:{},...o}:null}onRenderHTML(e){if(!this.viewport||this.tooltip===null){te(null,e);return}let r={...this.props.style,...this.tooltip.style},[o,n]=this.viewport.project(this.tooltip.position),i=I(zi,{x:o,y:n,placement:this.props.placement,arrow:this.props.arrow,arrowColor:"var(--menu-background, #fff)",offset:this.props.offset,children:I(xp,{className:`deck-widget-popup-content ${this.tooltip.className} ${this.props.className}`,style:r,html:this.tooltip.html,text:this.tooltip.text,element:this.tooltip.element})});te(i,e)}};bp.defaultProps={...$.defaultProps,id:"info",viewId:null,mode:"hover",getTooltip:void 0,placement:"right",offset:10,arrow:10};var Ap=class extends ${constructor(e){super(e),this.className="deck-widget-popup",this.placement="fill",this.setProps(this.props),this.isOpen=this.props.defaultIsOpen}setProps(e){this.viewId=e.viewId??this.viewId,super.setProps(e)}onAdd({deck:e}){this.deck=e}onRemove(){this.rootElement&&te(null,this.rootElement)}onViewportChange(e){this.viewport=e,this.updateHTML()}onClick(){this.props.closeOnClickOutside&&this._setIsOpen(!1)}_setIsOpen(e){this.isOpen!==e&&(this.isOpen=e,this.props.onOpenChange?.(e),this.updateHTML())}onRenderHTML(e){if(!this.viewport){te(null,e);return}let{marker:r,content:o,style:n}=this.props,[i,s]=this.viewport.project(this.props.position),a=I("div",{children:[r&&I("div",{className:"deck-widget-popup-marker",style:{left:i,top:s},children:I(xp,{...r,onClick:()=>this._setIsOpen(!0)})}),this.isOpen&&I(zi,{x:i,y:s,placement:this.props.placement,arrow:this.props.arrow,arrowColor:"var(--menu-background, #fff)",offset:this.props.offset,children:I("div",{className:`deck-widget-popup-content ${this.props.className}`,style:n,children:[this.props.closeButton&&I("div",{className:"deck-widget-popup-controls",style:{width:"100%",display:"flex",justifyContent:"end"},children:I(Me,{className:"deck-widget-popup-close-button",onClick:()=>this._setIsOpen(!1)})}),I(xp,{...typeof o=="string"?{text:o}:o})]})})]});te(a,e)}};Ap.defaultProps={...$.defaultProps,id:"info",viewId:null,position:[0,0],marker:null,defaultIsOpen:!0,content:"",placement:"right",offset:10,arrow:10,closeButton:!0,closeOnClickOutside:!1,onOpenChange:()=>{}};var Tp=class extends ${constructor(e){super(e),this.className="deck-widget-context-menu",this.placement="fill",this.menu=null,this.setProps(this.props)}onAdd({deck:e}){e.getCanvas()?.addEventListener("contextmenu",r=>this.handleContextMenu(r))}handleContextMenu(e){let r=e.target.getBoundingClientRect(),o=e.clientX-r.x,n=e.clientY-r.y,i=this.deck?.pickObject({x:o,y:n})||{x:o,y:n,picked:!1,layer:null,color:null,index:-1,pixelRatio:1},s=this.props.getMenuItems?.(i,this)||this.props.menuItems;this.menu=s.length>0?{items:s,pickInfo:i}:null,e.preventDefault(),this.updateHTML()}onRenderHTML(e){if(!this.menu){te(null,e);return}let{items:r,pickInfo:o}=this.menu,n={pointerEvents:"auto",position:"static",...this.props.style},i=I(zi,{x:o.x,y:o.y,placement:this.props.placement,arrow:this.props.arrow,arrowColor:"var(--menu-background, #fff)",offset:this.props.offset,children:I(sa,{menuItems:r,onSelect:s=>this.props.onMenuItemSelected(s,o),style:n,isOpen:!0,onClose:()=>this.hide()})});te(i,e)}hide(){this.menu=null,this.updateHTML()}};Tp.defaultProps={...$.defaultProps,id:"context",viewId:null,menuItems:[],getMenuItems:void 0,onMenuItemSelected:()=>{},placement:"bottom-start",offset:10,arrow:!1};var t5={passive:!1},vp=(t,e,r)=>t<e?e:t>r?r:t,pb=(t,e)=>{if(!t||!t.firstElementChild)return[0,0];let r=t.firstElementChild.getBoundingClientRect();return e?[r.top,r.height]:e?[r.top,r.height]:[r.left,r.width]},Sp=(t,e)=>typeof t=="number"&&!Number.isNaN(t)&&t>0?t:Math.max(1,e/10||1),$w=(t,e)=>typeof t=="number"&&!Number.isNaN(t)&&t>0?t:Math.max(1,e||1);function Vl(t){let{className:e="",min:r,max:o,step:n,value:i,orientation:s,pageSize:a,stepButtons:c=!1,startButtonAriaLabel:l,endButtonAriaLabel:f,eventTarget:u,decorations:d=[],onChange:h}=t,p=s!=="horizontal",m=Bt(null),g=Bt(null),_=Bt(null),x=Bt(null),[y,b]=Ui(0),T=o-r,v=Math.max(0,i[1]-i[0]),w=Math.max(0,T-v),C=vp(i[0],r,r+w),{thumbLength:S,thumbOffset:A}=On(()=>{if(y<=0||T<=0)return{thumbLength:0,thumbOffset:0};if(T<=v)return{thumbLength:1,thumbOffset:0};let U=v/T,re=Math.max(0,1-U),go=w<=0?0:vp((C-r)/w,0,1);return{thumbLength:Math.max(0,Math.min(U,1)),thumbOffset:re*go}},[y,T,v,w,C,r]),M=Fn(U=>{if(!h)return;let re=vp(U,r,r+w);h([re,re+v])},[h,r,w,v]),B=Fn(U=>{U.stopPropagation(),M(C-Sp(n,T))},[M,C,n,T]),O=Fn(U=>{U.stopPropagation(),M(C+Sp(n,T))},[M,C,n,T]),F=Fn(U=>{if(U.button!==0||U.target?.dataset.scrollbarThumb==="true")return;let go=g.current;if(!go)return;U.preventDefault(),U.stopPropagation();let[ha]=pb(go,p),zl=p?U.clientY-ha:U.clientX-ha,pa=Math.max(1,1-S)*y,ma=S/2*y,ga=pa<=0?0:vp((zl-ma)/pa,0,1);M(r+ga*w)},[p,y,S,M,r,w]),X=U=>{U.button!==0||!g.current||(x.current={pointerId:U.pointerId,startCoord:p?U.clientY:U.clientX,startRatio:A,min:r,max:o,maxStart:w},U.currentTarget.setPointerCapture(U.pointerId),U.preventDefault(),U.stopPropagation())},G=Fn(U=>{let re=x.current;if(!re||re.pointerId!==U.pointerId)return;let[go,ha]=pb(g.current,p),pa=(p?U.clientY:U.clientX)-re.startCoord,ma=re.startRatio+pa/ha,ga=vp(ma*(re.max-re.min),0,re.maxStart)+re.min;M(ga),U.preventDefault()},[M,p]),j=Fn(U=>{let re=x.current;re&&re.pointerId===U.pointerId&&(x.current=null,_.current?.releasePointerCapture(U.pointerId),U.preventDefault())},[]),se=Fn(U=>{switch(U.key){case"ArrowUp":case"ArrowLeft":(p&&U.key==="ArrowUp"||!p&&U.key==="ArrowLeft")&&(M(C-Sp(n,T)),U.preventDefault());break;case"ArrowDown":case"ArrowRight":(p&&U.key==="ArrowDown"||!p&&U.key==="ArrowRight")&&(M(C+Sp(n,T)),U.preventDefault());break;case"PageUp":M(C-$w(a,v)),U.preventDefault();break;case"PageDown":M(C+$w(a,v)),U.preventDefault();break;case"Home":M(r),U.preventDefault();break;case"End":M(r+w),U.preventDefault();break;default:break}},[p,M,C,n,T,a,v,r,w]),ne=Fn(U=>{if(U.preventDefault(),U.stopPropagation(),w===0)return;let re=p?U.deltaY:U.deltaX;!p&&re===0&&(re=U.deltaY),U.deltaMode===WheelEvent.DOM_DELTA_LINE?re*=Sp(n,T):U.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(re*=$w(a,v)),re!==0&&M(C+re)},[M,C,w,p,n,T,a,v]);Fw(()=>{b(pb(g.current,p)[1])},[p]),Fw(()=>{let U=g.current;if(!U)return;let re=()=>{b(pb(U,p)[1])};if(re(),typeof ResizeObserver<"u"){let go=new ResizeObserver(re);return go.observe(U),()=>go.disconnect()}if(typeof window<"u")return window.addEventListener("resize",re),()=>window.removeEventListener("resize",re)},[p]),Hr(()=>{let U=u??m.current;if(U)return U.addEventListener("keydown",se),U.addEventListener("wheel",ne,t5),()=>{U.removeEventListener("keydown",se),U.removeEventListener("wheel",ne,t5)}},[u,se,ne]);let pe=On(()=>!d.length||T<=0?[]:d.map((U,re)=>{let[go,ha]=U.position,zl=(go-r)/T,pa=(ha-r)/T,ma=Math.round(zl*1e3)/10,ga=Math.max(0,Math.round((pa-zl)*1e3)/10),a5=p?{left:"0",width:"100%",top:`${ma}%`,height:`${ga}%`}:{top:"0",height:"100%",left:`${ma}%`,width:`${ga}%`};return I("div",{className:"deck-widget-range__decoration",style:a5,children:U.element},`decoration-${re}`)}),[d,T,r,p]);return I("div",{ref:m,tabIndex:0,role:"scrollbar","aria-valuemin":r,"aria-valuemax":r+w,"aria-valuenow":C,"aria-orientation":s,className:`${e} deck-widget-range deck-widget-range--${s} ${w===0?"deck-widget-range--disabled":""}`,children:[c&&I("button",{type:"button",className:"deck-widget-range__button deck-widget-range__button--start","aria-label":l,disabled:C<=r,onClick:B,children:I("span",{className:"deck-widget-icon"})}),I("div",{className:"deck-widget-range__track",ref:g,onClick:F,children:[I("div",{className:"deck-widget-range__decorations",children:pe}),I("div",{className:"deck-widget-range__thumb","data-scrollbar-thumb":"true",ref:_,style:p?{height:`${S*100}%`,top:`${A*100}%`}:{width:`${S*100}%`,left:`${A*100}%`},onPointerDown:X,onPointerMove:G,onPointerUp:j,onPointerCancel:j})]}),c&&I("button",{type:"button",className:"deck-widget-range__button deck-widget-range__button--end","aria-label":f,disabled:C>=r+w,onClick:O,children:I("span",{className:"deck-widget-icon"})})]})}var r5=(t,e,r)=>t<e?e:t>r?r:t,da=class extends ${constructor(e){let r={...da.defaultProps,...e};super(r),this.className="deck-widget-scrollbar",this.placement="fill",this.contentSize=0,this.viewportSize=0,this.scrollOffset=0,this.handleRangeChange=o=>{this.emitScroll(o[0])},this.viewId=r.viewId??null}onViewportChange(e){this.viewport=e,this.onRenderHTML()}onRenderHTML(){let e=this.rootElement;if(!e)return;e.dataset.placement=this.props.placement;let r=this.viewport;this.updateViewport(r);let o=this.getClampedOffset(),n=this.getWheelEventTarget(this.props.captureWheel?"global":"local"),i=this.getDecorations(r),s=this.isVertical(),a=this.props.startButtonAriaLabel??(s?"Scroll up":"Scroll left"),c=this.props.endButtonAriaLabel??(s?"Scroll down":"Scroll right"),l=I(Vl,{min:0,max:Math.max(0,this.contentSize),step:this.getEffectiveStep(),pageSize:this.getEffectivePage(),value:[o,o+this.viewportSize],orientation:this.props.orientation,stepButtons:!0,startButtonAriaLabel:a,endButtonAriaLabel:c,eventTarget:n,decorations:i,onChange:this.handleRangeChange});te(l,e)}onRemove(){this.rootElement&&te(null,this.rootElement),super.onRemove()}getContentBounds(e){return this.props.contentBounds??this.deck?.getView(e)?.controller?.maxBounds??null}updateViewport(e){if(!e){this.contentSize=0,this.scrollOffset=0,this.viewportSize=0;return}let r=this.getContentBounds(e.id),o=this.isVertical(),n=r?Xw(r,e,o):[0,0];this.contentSize=n[1]-n[0],this.scrollOffset=-n[0],this.viewportSize=o?e.height:e.width}getDecorations(e){let{decorations:r=[]}=this.props;if(!e||r.length===0)return[];let o=this.getContentBounds(e.id);if(!o)return[];let n=this.isVertical(),[i]=Xw(o,e,n);return r.map(s=>{let[a,c]=Xw(s.contentBounds,e,n),l=s.onClick?f=>{s.onClick?.(f)&&(f.stopPropagation(),f.preventDefault())}:void 0;return{position:[a-i,c-i],element:I("div",{style:{pointerEvents:l?"all":"none",width:"100%",height:"100%",backgroundColor:s.color},title:s.title,onClick:l})}})}getWheelEventTarget(e){return e===null?null:e==="local"?this.rootElement:this.deck?.props.parent||this.deck?.getCanvas()?.parentElement||this.rootElement}getMaxScroll(){return Math.max(0,this.contentSize-this.viewportSize)}getClampedOffset(){let e=this.getMaxScroll();return r5(this.scrollOffset,0,e)}isVertical(){return this.props.orientation!=="horizontal"}getEffectiveStep(){return typeof this.props.stepSize=="number"&&!Number.isNaN(this.props.stepSize)?this.props.stepSize:Math.max(1,this.viewportSize/10||1)}getEffectivePage(){return typeof this.props.pageSize=="number"&&!Number.isNaN(this.props.pageSize)?this.props.pageSize:this.viewportSize}emitScroll(e){let r=this.getMaxScroll(),o=r5(Math.round(e),0,r),n=this.viewport;if(n&&o!==this.getClampedOffset()){let i=n.project(n.position);this.isVertical()?i[1]-=o-this.scrollOffset:i[0]-=o-this.scrollOffset;let{target:s}=n.panByPosition(n.position,i);this.deck._onViewStateChange({viewId:n.id,viewState:{...this.getViewState(n.id),target:s},interactionState:{}})}}};da.defaultProps={...$.defaultProps,contentBounds:null,placement:"top-right",viewId:null,orientation:"vertical",stepSize:null,pageSize:null,startButtonAriaLabel:"",endButtonAriaLabel:"",captureWheel:!1,decorations:[]};function Xw(t,e,r){return t.map(([o,n])=>e.project([o,n,0])).reduce((o,[n,i])=>{let s=r?i:n;return o[0]=Math.min(o[0],s),o[1]=Math.max(o[1],s),o},[1/0,-1/0])}var Cp=class extends ${constructor(e){super(e),this.className="",this.placement="top-left",this.setProps(this.props)}setProps(e){this.placement=e.placement??this.placement,this.viewId=e.viewId,super.setProps(e)}onRenderHTML(e){let{className:r,style:o,icon:n,color:i,label:s,onClick:a}=this.props;te(I(Me,{className:r,style:o,color:i,icon:n,label:s,onClick:a}),e)}};Cp.defaultProps={...$.defaultProps,id:"icon",placement:"top-left",viewId:null,icon:"",label:"",color:"",onClick:void 0};var Ep=class extends ${constructor(e){super(e),this.className="deck-widget-toggle",this.placement="top-left",this._toggle=()=>{this.checked=!this.checked,this.props.onChange?.(this.checked),this.updateHTML()},this.checked=this.props.initialChecked,this.setProps(this.props)}setProps(e){this.placement=e.placement??this.placement,this.viewId=e.viewId,super.setProps(e)}onRenderHTML(e){let{className:r,style:o,icon:n,label:i,color:s,onIcon:a=n,onLabel:c=i,onColor:l=s}=this.props,f=this.checked;e.dataset.checked=String(f),te(I(Me,{className:r,style:o,icon:f?a:n,label:f?c:i,color:f?l:s,onClick:this._toggle}),e)}};Ep.defaultProps={...$.defaultProps,id:"icon",placement:"top-left",viewId:null,initialChecked:!1,icon:"",onIcon:void 0,label:"",onLabel:void 0,color:"",onColor:void 0,onChange:void 0};var wp=class extends ${constructor(e){super(e),this.className="deck-widget-selector",this.placement="top-left",this.isOpen=!1,this._toggleMenu=()=>{this.isOpen?this.isOpen=!1:this.rootElement&&(this.isOpen={x:this.rootElement.offsetLeft,y:this.rootElement.offsetTop,placement:this.props.placement.includes("right")?"left-start":"right-start"}),this.updateHTML()},this._handleSelectMode=r=>{this.value=r,this.props.onChange(r),this.updateHTML()},this.value=this.props.initialValue,this.setProps(this.props)}setProps(e){this.placement=e.placement??this.placement,this.viewId=e.viewId??this.viewId,super.setProps(e)}onRenderHTML(e){let r=this.props.options.find(o=>o.value===this.value)??this.props.options[0];te(I("div",{children:[I(Me,{icon:r.icon,label:r.label,onClick:this._toggleMenu}),this.isOpen&&I(zi,{...this.isOpen,children:I(sa,{isOpen:!0,style:{pointerEvents:"auto",position:"static"},menuItems:this.props.options,onSelect:this._handleSelectMode,onClose:this._toggleMenu})})]}),e)}};wp.defaultProps={...$.defaultProps,id:"view-selector",placement:"top-left",viewId:null,initialValue:"",options:[],onChange:()=>{}};var Pp=class extends ${getTime(){return this.props.time??this.currentTime}getPlaying(){return this.props.playing??this._playing}constructor(e={}){super(e),this.id="timeline",this.className="deck-widget-timeline",this.placement="fill",this._playing=!1,this.timerId=null,this.handlePlayPause=()=>{let n=!this.getPlaying();this.props.onPlayingChange?.(n),this.props.playing===void 0&&(n?this.play():this.stop())},this.handleTimeChange=([o])=>{this.props.onTimeChange(o),this.props.time===void 0&&(this.currentTime=o,this.props.timeline?.setTime(o),this.updateHTML())},this.tick=()=>{let{timeRange:[o,n],step:i,loop:s}=this.props;if(i>0){let a=this.getTime(),c=Math.round(a/i)*i+i;c>n&&(a<n?c=n:s?c=o:(c=n,this._playing=!1,this.props.onPlayingChange?.(!1))),this.props.onTimeChange(c),this.props.time===void 0&&(this.currentTime=c,this.props.timeline?.setTime(c)),this.updateHTML()}this._playing?this.timerId=window.setTimeout(this.tick,this.props.playInterval):this.timerId=null},this.currentTime=this.props.initialTime??this.props.timeRange[0];let r=this.props.time??this.currentTime;this.props.timeline?.setTime(r),this.setProps(this.props)}setProps(e){let{playing:r,time:o}=this.props;this.viewId=e.viewId??this.viewId,super.setProps(e),e.time!==void 0&&e.time!==o&&this.props.timeline?.setTime(e.time),e.playing!==void 0&&e.playing!==r&&(e.playing&&!this._playing?this._startTimer():!e.playing&&this._playing&&this._stopTimer())}onAdd(){this._playing=!1,this.timerId=null,this.props.autoPlay&&(this.props.playing!==void 0?this.props.onPlayingChange?.(!0):this.play())}onRemove(){this.stop()}onRenderHTML(e){let{timeRange:r,step:o,formatLabel:n}=this.props,i=this.getPlaying(),s=this.getTime();e.dataset.placement=this.props.placement,te(I("div",{className:"deck-widget-button-group",children:[i?I(Me,{label:"Pause",className:"deck-widget-timeline-pause",onClick:this.handlePlayPause}):I(Me,{label:"Play",className:"deck-widget-timeline-play",onClick:this.handlePlayPause}),I(Vl,{min:r[0],max:r[1],orientation:"horizontal",step:o,value:[s,s],onChange:this.handleTimeChange,decorations:[{position:[s,s+o],element:I("div",{className:"deck-widget-timeline-label deck-widget-timeline-label--current",children:n(s)})}]})]}),e)}play(){this._playing=!0;let{timeRange:[e,r]}=this.props;this.props.time===void 0&&this.getTime()>=r&&(this.currentTime=e,this.props.onTimeChange(e),this.props.timeline?.setTime(e)),this.updateHTML(),this.tick()}stop(){this._stopTimer(),this.updateHTML()}_startTimer(){this._playing=!0,this.tick()}_stopTimer(){this._playing=!1,this.timerId!==null&&(window.clearTimeout(this.timerId),this.timerId=null)}};Pp.defaultProps={...$.defaultProps,id:"timeline",placement:"bottom-left",viewId:null,timeline:null,timeRange:[0,100],step:1,initialTime:void 0,time:void 0,onTimeChange:()=>{},autoPlay:!1,loop:!1,playInterval:1e3,playing:void 0,onPlayingChange:()=>{},formatLabel:String};var Mp=class extends ${constructor(e={}){super(e),this.className="deck-widget-screenshot",this.placement="top-left",this.setProps(this.props)}setProps(e){this.placement=e.placement??this.placement,this.viewId=e.viewId??this.viewId,super.setProps(e)}onRenderHTML(e){te(I(Me,{className:"deck-widget-camera",label:this.props.label,onClick:this.handleClick.bind(this)}),e)}handleClick(){if(this.props.onCapture){this.props.onCapture(this);return}let e=this.captureScreenToDataURL(this.props.imageFormat);e&&this.downloadDataURL(e,this.props.filename)}captureScreenToDataURL(e){return this.deck?.getCanvas()?.toDataURL(e)}downloadDataURL(e,r){let o=document.createElement("a");o.href=e,o.download=r,o.click()}};Mp.defaultProps={...$.defaultProps,id:"screenshot",placement:"top-left",viewId:null,label:"Screenshot",filename:"screenshot.png",imageFormat:"image/png",onCapture:void 0};var o5={"--widget-margin":"12px","--button-size":"28px","--button-corner-radius":"8px","--button-background":"#fff","--button-stroke":"rgba(255, 255, 255, 0.3)","--button-inner-stroke":"unset","--button-shadow":"0px 0px 8px 0px rgba(0, 0, 0, 0.25)","--button-backdrop-filter":"unset","--button-icon-idle":"rgba(97, 97, 102, 1)","--button-icon-hover":"rgba(24, 24, 26, 1)","--button-text":"rgb(24, 24, 26, 1)","--icon-compass-north-color":"rgb(240, 92, 68)","--icon-compass-south-color":"rgb(204, 204, 204)","--menu-gap":"4px","--menu-background":"#fff","--menu-backdrop-filter":"unset","--menu-border":"unset","--menu-shadow":"0px 0px 8px 0px rgba(0, 0, 0, 0.25)","--menu-text":"rgb(24, 24, 26, 1)","--menu-item-hover":"rgba(0, 0, 0, 0.08)","--range-step-button-size":"24px","--range-track-size":"16px","--range-thumb-size":"10px","--range-track-color":"#d8d8e5","--range-thumb-color":"#616166","--range-decoration-active-color":"#f8dd50"},n5={"--widget-margin":"12px","--button-size":"28px","--button-corner-radius":"8px","--button-background":"rgba(18, 18, 20, 1)","--button-stroke":"rgba(18, 18, 20, 0.30)","--button-inner-stroke":"unset","--button-shadow":"0px 0px 8px 0px rgba(0, 0, 0, 0.25)","--button-backdrop-filter":"unset","--button-icon-idle":"rgba(158, 157, 168, 1)","--button-icon-hover":"rgba(215, 214, 229, 1)","--button-text":"rgb(215, 214, 229, 1)","--icon-compass-north-color":"rgb(240, 92, 68)","--icon-compass-south-color":"rgb(200, 199, 209)","--menu-gap":"4px","--menu-background":"rgba(18, 18, 20, 1)","--menu-backdrop-filter":"unset","--menu-border":"unset","--menu-shadow":"0px 0px 8px 0px rgba(0, 0, 0, 0.25)","--menu-text":"rgb(215, 214, 229, 1)","--menu-item-hover":"rgba(255, 255, 255, 0.1)","--range-step-button-size":"24px","--range-track-size":"16px","--range-thumb-size":"10px","--range-track-color":"#2c2c30","--range-thumb-color":"#9e9da8","--range-decoration-active-color":"#dd7d2c"},mb={"--widget-margin":"12px","--button-size":"28px","--button-corner-radius":"8px","--button-background":"rgba(255, 255, 255, 0.6)","--button-stroke":"rgba(255, 255, 255, 0.3)","--button-inner-stroke":"1px solid rgba(255, 255, 255, 0.6)","--button-shadow":"0px 0px 8px 0px rgba(0, 0, 0, 0.25), 0px 0px 8px 0px rgba(0, 0, 0, 0.1) inset","--button-backdrop-filter":"blur(4px)","--button-icon-idle":"rgba(97, 97, 102, 1)","--button-icon-hover":"rgba(24, 24, 26, 1)","--button-text":"rgb(24, 24, 26, 1)","--icon-compass-north-color":"rgb(240, 92, 68)","--icon-compass-south-color":"rgb(204, 204, 204)","--menu-gap":"4px","--menu-background":"rgba(255, 255, 255, 0.6)","--menu-backdrop-filter":"blur(4px)","--menu-border":"1px solid rgba(255, 255, 255, 0.6)","--menu-shadow":"0px 0px 8px 0px rgba(0, 0, 0, 0.25), 0px 0px 8px 0px rgba(0, 0, 0, 0.1) inset","--menu-text":"rgb(24, 24, 26, 1)","--menu-item-hover":"rgba(0, 0, 0, 0.08)","--range-step-button-size":"24px","--range-track-size":"16px","--range-thumb-size":"10px","--range-track-color":"rgba(215, 214, 229, 0.3)","--range-thumb-color":"rgba(97, 97, 102, 1)","--range-decoration-active-color":"rgba(255, 215, 0, 0.6)"},gb={"--widget-margin":"12px","--button-size":"28px","--button-corner-radius":"8px","--button-background":"rgba(18, 18, 20, 0.75)","--button-stroke":"rgba(18, 18, 20, 0.30)","--button-inner-stroke":"1px solid rgba(18, 18, 20, 0.75)","--button-shadow":"0px 0px 8px 0px rgba(0, 0, 0, 0.25), 0px 0px 8px 0px rgba(0, 0, 0, 0.1) inset","--button-backdrop-filter":"blur(4px)","--button-icon-idle":"rgba(158, 157, 168, 1)","--button-icon-hover":"rgba(215, 214, 229, 1)","--button-text":"rgb(215, 214, 229, 1)","--icon-compass-north-color":"rgb(240, 92, 68)","--icon-compass-south-color":"rgb(200, 199, 209)","--menu-gap":"4px","--menu-background":"rgba(18, 18, 20, 0.75)","--menu-backdrop-filter":"blur(4px)","--menu-border":"1px solid rgba(18, 18, 20, 0.75)","--menu-shadow":"0px 0px 8px 0px rgba(0, 0, 0, 0.25), 0px 0px 8px 0px rgba(0, 0, 0, 0.1) inset","--menu-text":"rgb(215, 214, 229, 1)","--menu-item-hover":"rgba(255, 255, 255, 0.1)","--range-step-button-size":"24px","--range-track-size":"16px","--range-thumb-size":"10px","--range-track-color":"rgba(24, 24, 26, 0.3)","--range-thumb-color":"rgba(158, 157, 168, 1)","--range-decoration-active-color":"rgba(255, 145, 0, 0.6)"};var Rp=class extends ${constructor(e={}){super(e),this.className="deck-widget-theme",this.placement="top-left",this.themeMode="dark",this.appliedTheme={},this.themeMode=this._getInitialThemeMode(),this.setProps(this.props)}setProps(e){this.placement=e.placement??this.placement,this.viewId=e.viewId??this.viewId,super.setProps(e)}onRenderHTML(e){let{lightModeLabel:r,darkModeLabel:o}=this.props,n=this.getThemeMode();this._applyTheme(n,e),te(I(Me,{onClick:this._handleClick.bind(this),label:n==="dark"?o:r,className:n==="dark"?"deck-widget-moon":"deck-widget-sun"}),e)}getThemeMode(){return this.props.themeMode??this.themeMode}_handleClick(){let r=this.getThemeMode()==="dark"?"light":"dark";this.props.onThemeModeChange?.(r),this.props.themeMode===void 0&&(this.themeMode=r,this.updateHTML())}_applyTheme(e,r){let o=e==="dark"?this.props.darkModeTheme:this.props.lightModeTheme;if(ie(o,this.appliedTheme,1))return;let n=r.closest(".deck-widget-container");if(!n)return;xs(n,o),this.appliedTheme=o;let i=e==="dark"?this.props.darkModeLabel:this.props.lightModeLabel;N.log(1,`Switched theme to ${i}`,o)()}_getInitialThemeMode(){let{initialThemeMode:e}=this.props;return e!=="auto"?e:typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}};Rp.defaultProps={...$.defaultProps,id:"theme",placement:"top-left",viewId:null,lightModeLabel:"Light Mode",lightModeTheme:mb,darkModeLabel:"Dark Mode",darkModeTheme:gb,initialThemeMode:"auto",themeMode:void 0,onThemeModeChange:()=>{}};var Ip=class extends ${constructor(e={}){super(e),this.className="deck-widget-loading",this.placement="top-left",this.loading=!0,this.setProps(this.props)}setProps(e){this.placement=e.placement??this.placement,this.viewId=e.viewId??this.viewId,super.setProps(e)}onRenderHTML(e){te(this.loading&&I(Me,{className:"deck-widget-spinner",label:this.props.label,onClick:this.handleClick.bind(this)}),e)}onRedraw({layers:e}){let r=e.some(o=>!o.isLoaded);r!==this.loading&&(this.loading=r,this.props.onLoadingChange?.(r),this.updateHTML())}handleClick(){}};Ip.defaultProps={...$.defaultProps,id:"loading",placement:"top-left",viewId:null,label:"Loading layer data",onLoadingChange:()=>{}};q();var Yw=t=>`${t.name}: ${t.count}`;function Kw(t){return t<1e3?`${t.toFixed(2)}ms`:`${(t/1e3).toFixed(2)}s`}function s5(t){return`${(t/1e6).toFixed(1)} MB`}var i5={count:Yw,averageTime:t=>`${t.name}: ${Kw(t.getAverageTime())}`,totalTime:t=>`${t.name}: ${Kw(t.time)}`,fps:t=>`${t.name}: ${Math.round(t.getHz())}fps`,memory:t=>`${t.name}: ${s5(t.count)}`},Lp=class extends ${getExpanded(){return this.props.expanded??this._expanded}constructor(e={}){super(e),this.className="deck-widget-stats",this.placement="top-left",this._counter=0,this._expanded=!1,this._toggleExpanded=()=>{let r=!this.getExpanded();this.props.onExpandedChange?.(r),this.props.expanded===void 0&&(this._expanded=r,this.updateHTML())},this._getFps=()=>Math.round(this.deck?.metrics.fps??0),this._formatters={...i5},this._resetOnUpdate={...this.props.resetOnUpdate},this._expanded=Boolean(e.initialExpanded),this.setProps(e)}setProps(e){if(this.placement=e.placement??this.placement,this.viewId=e.viewId??this.viewId,e.formatters)for(let r in e.formatters){let o=e.formatters[r];this._formatters[r]=typeof o=="string"?i5[o]||Yw:o}e.resetOnUpdate&&(this._resetOnUpdate={...e.resetOnUpdate}),super.setProps(e)}onRemove(){this.rootElement&&te(null,this.rootElement)}onRenderHTML(e){if(!this.getExpanded()){te(I(O_e,{getFps:this._getFps,onClick:this._toggleExpanded}),e);return}let o=this._getStats(),n=this.props.title||("id"in o?o.id:null)||"Stats",i=this._getDeviceLabel(),s=[];o&&o.forEach(a=>{let c=this._getLines(a).split(` `);this._resetOnUpdate&&this._resetOnUpdate[a.name]&&a.reset(),c.forEach((l,f)=>{s.push(I("div",{style:{whiteSpace:"pre"},children:l},`${a.name}-${f}`))})}),te(I("div",{className:"deck-widget-stats-container",style:{cursor:"default"},children:[I("div",{className:"deck-widget-stats-header",style:{cursor:"pointer",pointerEvents:"auto"},onClick:this._toggleExpanded,children:[I("b",{children:n}),i&&I("span",{className:"deck-widget-stats-device",children:i}),I("button",{className:"deck-widget-dropdown-button",children:I("span",{className:"deck-widget-dropdown-icon open"})})]}),I("div",{className:"deck-widget-stats-content",children:s})]}),e)}onRedraw(){if(this.getExpanded()){let e=Math.max(1,this.props.framesPerUpdate||1);this._counter++%e===0&&this.updateHTML()}}_getStats(){switch(this.props.type){case"deck":let e=this.deck?.metrics??{};return Object.entries(e);case"luma":return Array.from(Co.stats.stats.values())[0];case"device":let o=this.deck?.device?.statsManager.stats.values();return o?Array.from(o)[0]:[];case"custom":return this.props.stats;default:throw new Error(`Unknown stats type: ${this.props.type}`)}}_getDeviceLabel(){let e=this.deck?.device?.type;if(!e)return null;switch(e){case"webgpu":return"WebGPU";case"webgl":return"WebGL";default:return String(e)}}_getLines(e){if("count"in e)return(this._formatters[e.name]||this._formatters[e.type||""]||Yw)(e);let[r,o]=e,n=r.endsWith("Memory")?s5(o):r.includes("Time")?Kw(o):`${o.toFixed(2)}`;return`${r}: ${n}`}};Lp.defaultProps={...$.defaultProps,type:"deck",placement:"top-left",viewId:null,initialExpanded:!1,stats:void 0,title:"Stats",framesPerUpdate:1,formatters:{},resetOnUpdate:{},id:"stats",expanded:void 0,onExpandedChange:()=>{}};function O_e({getFps:t,onClick:e}){let[r,o]=Ui(t());return Hr(()=>{let n=()=>{o(t()),i=requestAnimationFrame(n)},i=requestAnimationFrame(n);return()=>{cancelAnimationFrame(i)}},[t]),I(Me,{onClick:e,children:I("div",{className:"text",children:["FPS",I("br",{}),r]})})}var Bp=kn(kd(),1);$c._checkH3Lib=()=>{let t='include the <script src="https://unpkg.com/h3-js@^4.0.0"><\/script> tag before the deck.gl script tag. https://deck.gl/docs/api-reference/geo-layers/h3-hexagon-layer';if(Bp){if(Bp.polyfill&&!Bp.polygonToCells)throw new Error(`Incompatible h3-js version. ${t}`)}else throw new Error(`To use H3 functionality, ${t}`)};return p5(F_e);})(); /*! Bundled license information: long/dist/long.js: (** * @license long.js (c) 2013 Daniel Wirtz <dcode@dcode.io> * Released under the Apache License, Version 2.0 * see: https://github.com/dcodeIO/long.js for details *) ieee754/index.js: (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *) long/index.js: (** * @license * Copyright 2009 The Closure Library Authors * Copyright 2020 Daniel Wirtz / The long.js Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0 *) */ return __exports__; }); polygon-clipping.umd.min.js 0000666 00000071020 15244655454 0011764 0 ustar 00 /* polygon-clipping v0.15.7 — https://github.com/mfogel/polygon-clipping — MIT License */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).polygonClipping=e()}(this,(function(){"use strict"; /** * splaytree v3.1.2 * Fast Splay tree for Node and browser * * @author Alexander Milevski <info@w8r.name> * @license MIT * @preserve */ /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */function t(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function l(o){return function(l){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,l])}}}var e=function(t,e){this.next=null,this.key=t,this.data=e,this.left=null,this.right=null};function n(t,e){return t>e?1:t<e?-1:0}function r(t,n,r){for(var i=new e(null,null),o=i,s=i;;){var l=r(t,n.key);if(l<0){if(null===n.left)break;if(r(t,n.left.key)<0){var h=n.left;if(n.left=h.right,h.right=n,null===(n=h).left)break}s.left=n,s=n,n=n.left}else{if(!(l>0))break;if(null===n.right)break;if(r(t,n.right.key)>0){h=n.right;if(n.right=h.left,h.left=n,null===(n=h).right)break}o.right=n,o=n,n=n.right}}return o.right=n.left,s.left=n.right,n.left=i.right,n.right=i.left,n}function i(t,n,i,o){var s=new e(t,n);if(null===i)return s.left=s.right=null,s;var l=o(t,(i=r(t,i,o)).key);return l<0?(s.left=i.left,s.right=i,i.left=null):l>=0&&(s.right=i.right,s.left=i,i.right=null),s}function o(t,e,n){var i=null,o=null;if(e){var s=n((e=r(t,e,n)).key,t);0===s?(i=e.left,o=e.right):s<0?(o=e.right,e.right=null,i=e):(i=e.left,e.left=null,o=e)}return{left:i,right:o}}function s(t,e,n,r,i){if(t){r(e+(n?"└── ":"├── ")+i(t)+"\n");var o=e+(n?" ":"│ ");t.left&&s(t.left,o,!1,r,i),t.right&&s(t.right,o,!0,r,i)}}var l=function(){function l(t){void 0===t&&(t=n),this._root=null,this._size=0,this._comparator=t}return l.prototype.insert=function(t,e){return this._size++,this._root=i(t,e,this._root,this._comparator)},l.prototype.add=function(t,n){var i=new e(t,n);null===this._root&&(i.left=i.right=null,this._size++,this._root=i);var o=this._comparator,s=r(t,this._root,o),l=o(t,s.key);return 0===l?this._root=s:(l<0?(i.left=s.left,i.right=s,s.left=null):l>0&&(i.right=s.right,i.left=s,s.right=null),this._size++,this._root=i),this._root},l.prototype.remove=function(t){this._root=this._remove(t,this._root,this._comparator)},l.prototype._remove=function(t,e,n){var i;return null===e?null:0===n(t,(e=r(t,e,n)).key)?(null===e.left?i=e.right:(i=r(t,e.left,n)).right=e.right,this._size--,i):e},l.prototype.pop=function(){var t=this._root;if(t){for(;t.left;)t=t.left;return this._root=r(t.key,this._root,this._comparator),this._root=this._remove(t.key,this._root,this._comparator),{key:t.key,data:t.data}}return null},l.prototype.findStatic=function(t){for(var e=this._root,n=this._comparator;e;){var r=n(t,e.key);if(0===r)return e;e=r<0?e.left:e.right}return null},l.prototype.find=function(t){return this._root&&(this._root=r(t,this._root,this._comparator),0!==this._comparator(t,this._root.key))?null:this._root},l.prototype.contains=function(t){for(var e=this._root,n=this._comparator;e;){var r=n(t,e.key);if(0===r)return!0;e=r<0?e.left:e.right}return!1},l.prototype.forEach=function(t,e){for(var n=this._root,r=[],i=!1;!i;)null!==n?(r.push(n),n=n.left):0!==r.length?(n=r.pop(),t.call(e,n),n=n.right):i=!0;return this},l.prototype.range=function(t,e,n,r){for(var i=[],o=this._comparator,s=this._root;0!==i.length||s;)if(s)i.push(s),s=s.left;else{if(o((s=i.pop()).key,e)>0)break;if(o(s.key,t)>=0&&n.call(r,s))return this;s=s.right}return this},l.prototype.keys=function(){var t=[];return this.forEach((function(e){var n=e.key;return t.push(n)})),t},l.prototype.values=function(){var t=[];return this.forEach((function(e){var n=e.data;return t.push(n)})),t},l.prototype.min=function(){return this._root?this.minNode(this._root).key:null},l.prototype.max=function(){return this._root?this.maxNode(this._root).key:null},l.prototype.minNode=function(t){if(void 0===t&&(t=this._root),t)for(;t.left;)t=t.left;return t},l.prototype.maxNode=function(t){if(void 0===t&&(t=this._root),t)for(;t.right;)t=t.right;return t},l.prototype.at=function(t){for(var e=this._root,n=!1,r=0,i=[];!n;)if(e)i.push(e),e=e.left;else if(i.length>0){if(e=i.pop(),r===t)return e;r++,e=e.right}else n=!0;return null},l.prototype.next=function(t){var e=this._root,n=null;if(t.right){for(n=t.right;n.left;)n=n.left;return n}for(var r=this._comparator;e;){var i=r(t.key,e.key);if(0===i)break;i<0?(n=e,e=e.left):e=e.right}return n},l.prototype.prev=function(t){var e=this._root,n=null;if(null!==t.left){for(n=t.left;n.right;)n=n.right;return n}for(var r=this._comparator;e;){var i=r(t.key,e.key);if(0===i)break;i<0?e=e.left:(n=e,e=e.right)}return n},l.prototype.clear=function(){return this._root=null,this._size=0,this},l.prototype.toList=function(){return function(t){var n=t,r=[],i=!1,o=new e(null,null),s=o;for(;!i;)n?(r.push(n),n=n.left):r.length>0?n=(n=s=s.next=r.pop()).right:i=!0;return s.next=null,o.next}(this._root)},l.prototype.load=function(t,n,r){void 0===n&&(n=[]),void 0===r&&(r=!1);var i=t.length,o=this._comparator;if(r&&f(t,n,0,i-1,o),null===this._root)this._root=h(t,n,0,i),this._size=i;else{var s=function(t,n,r){var i=new e(null,null),o=i,s=t,l=n;for(;null!==s&&null!==l;)r(s.key,l.key)<0?(o.next=s,s=s.next):(o.next=l,l=l.next),o=o.next;null!==s?o.next=s:null!==l&&(o.next=l);return i.next}(this.toList(),function(t,n){for(var r=new e(null,null),i=r,o=0;o<t.length;o++)i=i.next=new e(t[o],n[o]);return i.next=null,r.next}(t,n),o);i=this._size+i,this._root=u({head:s},0,i)}return this},l.prototype.isEmpty=function(){return null===this._root},Object.defineProperty(l.prototype,"size",{get:function(){return this._size},enumerable:!0,configurable:!0}),Object.defineProperty(l.prototype,"root",{get:function(){return this._root},enumerable:!0,configurable:!0}),l.prototype.toString=function(t){void 0===t&&(t=function(t){return String(t.key)});var e=[];return s(this._root,"",!0,(function(t){return e.push(t)}),t),e.join("")},l.prototype.update=function(t,e,n){var s=this._comparator,l=o(t,this._root,s),h=l.left,u=l.right;s(t,e)<0?u=i(e,n,u,s):h=i(e,n,h,s),this._root=function(t,e,n){return null===e?t:(null===t||((e=r(t.key,e,n)).left=t),e)}(h,u,s)},l.prototype.split=function(t){return o(t,this._root,this._comparator)},l.prototype[Symbol.iterator]=function(){var e,n,r;return t(this,(function(t){switch(t.label){case 0:e=this._root,n=[],r=!1,t.label=1;case 1:return r?[3,6]:null===e?[3,2]:(n.push(e),e=e.left,[3,5]);case 2:return 0===n.length?[3,4]:[4,e=n.pop()];case 3:return t.sent(),e=e.right,[3,5];case 4:r=!0,t.label=5;case 5:return[3,1];case 6:return[2]}}))},l}();function h(t,n,r,i){var o=i-r;if(o>0){var s=r+Math.floor(o/2),l=t[s],u=n[s],f=new e(l,u);return f.left=h(t,n,r,s),f.right=h(t,n,s+1,i),f}return null}function u(t,e,n){var r=n-e;if(r>0){var i=e+Math.floor(r/2),o=u(t,e,i),s=t.head;return s.left=o,t.head=t.head.next,s.right=u(t,i+1,n),s}return null}function f(t,e,n,r,i){if(!(n>=r)){for(var o=t[n+r>>1],s=n-1,l=r+1;;){do{s++}while(i(t[s],o)<0);do{l--}while(i(t[l],o)>0);if(s>=l)break;var h=t[s];t[s]=t[l],t[l]=h,h=e[s],e[s]=e[l],e[l]=h}f(t,e,n,l,i),f(t,e,l+1,r,i)}}const c=(t,e)=>t.ll.x<=e.x&&e.x<=t.ur.x&&t.ll.y<=e.y&&e.y<=t.ur.y,p=(t,e)=>{if(e.ur.x<t.ll.x||t.ur.x<e.ll.x||e.ur.y<t.ll.y||t.ur.y<e.ll.y)return null;const n=t.ll.x<e.ll.x?e.ll.x:t.ll.x,r=t.ur.x<e.ur.x?t.ur.x:e.ur.x;return{ll:{x:n,y:t.ll.y<e.ll.y?e.ll.y:t.ll.y},ur:{x:r,y:t.ur.y<e.ur.y?t.ur.y:e.ur.y}}};let g=Number.EPSILON;void 0===g&&(g=Math.pow(2,-52));const a=g*g,y=(t,e)=>{if(-g<t&&t<g&&-g<e&&e<g)return 0;const n=t-e;return n*n<a*t*e?0:t<e?-1:1};class x{constructor(){this.tree=new l,this.round(0)}round(t){const e=this.tree.add(t),n=this.tree.prev(e);if(null!==n&&0===y(e.key,n.key))return this.tree.remove(t),n.key;const r=this.tree.next(e);return null!==r&&0===y(e.key,r.key)?(this.tree.remove(t),r.key):t}}const b=new class{constructor(){this.reset()}reset(){this.xRounder=new x,this.yRounder=new x}round(t,e){return{x:this.xRounder.round(t),y:this.yRounder.round(e)}}},v=11102230246251565e-32,d=134217729,m=(3+8*v)*v;function E(t,e,n,r,i){let o,s,l,h,u=e[0],f=r[0],c=0,p=0;f>u==f>-u?(o=u,u=e[++c]):(o=f,f=r[++p]);let g=0;if(c<t&&p<n)for(f>u==f>-u?(s=u+o,l=o-(s-u),u=e[++c]):(s=f+o,l=o-(s-f),f=r[++p]),o=s,0!==l&&(i[g++]=l);c<t&&p<n;)f>u==f>-u?(s=o+u,h=s-o,l=o-(s-h)+(u-h),u=e[++c]):(s=o+f,h=s-o,l=o-(s-h)+(f-h),f=r[++p]),o=s,0!==l&&(i[g++]=l);for(;c<t;)s=o+u,h=s-o,l=o-(s-h)+(u-h),u=e[++c],o=s,0!==l&&(i[g++]=l);for(;p<n;)s=o+f,h=s-o,l=o-(s-h)+(f-h),f=r[++p],o=s,0!==l&&(i[g++]=l);return 0===o&&0!==g||(i[g++]=o),g}function S(t){return new Float64Array(t)}const _=22204460492503146e-32,w=11093356479670487e-47,k=S(4),R=S(8),I=S(12),P=S(16),N=S(4);function A(t,e,n,r,i,o){const s=(e-o)*(n-i),l=(t-i)*(r-o),h=s-l,u=Math.abs(s+l);return Math.abs(h)>=33306690738754716e-32*u?h:-function(t,e,n,r,i,o,s){let l,h,u,f,c,p,g,a,y,x,b,v,S,A,O,L,$,M;const z=t-i,B=n-i,G=e-o,T=r-o;A=z*T,p=d*z,g=p-(p-z),a=z-g,p=d*T,y=p-(p-T),x=T-y,O=a*x-(A-g*y-a*y-g*x),L=G*B,p=d*G,g=p-(p-G),a=G-g,p=d*B,y=p-(p-B),x=B-y,$=a*x-(L-g*y-a*y-g*x),b=O-$,c=O-b,k[0]=O-(b+c)+(c-$),v=A+b,c=v-A,S=A-(v-c)+(b-c),b=S-L,c=S-b,k[1]=S-(b+c)+(c-L),M=v+b,c=M-v,k[2]=v-(M-c)+(b-c),k[3]=M;let q=function(t,e){let n=e[0];for(let r=1;r<t;r++)n+=e[r];return n}(4,k),C=_*s;if(q>=C||-q>=C)return q;if(c=t-z,l=t-(z+c)+(c-i),c=n-B,u=n-(B+c)+(c-i),c=e-G,h=e-(G+c)+(c-o),c=r-T,f=r-(T+c)+(c-o),0===l&&0===h&&0===u&&0===f)return q;if(C=w*s+m*Math.abs(q),q+=z*f+T*l-(G*u+B*h),q>=C||-q>=C)return q;A=l*T,p=d*l,g=p-(p-l),a=l-g,p=d*T,y=p-(p-T),x=T-y,O=a*x-(A-g*y-a*y-g*x),L=h*B,p=d*h,g=p-(p-h),a=h-g,p=d*B,y=p-(p-B),x=B-y,$=a*x-(L-g*y-a*y-g*x),b=O-$,c=O-b,N[0]=O-(b+c)+(c-$),v=A+b,c=v-A,S=A-(v-c)+(b-c),b=S-L,c=S-b,N[1]=S-(b+c)+(c-L),M=v+b,c=M-v,N[2]=v-(M-c)+(b-c),N[3]=M;const F=E(4,k,4,N,R);A=z*f,p=d*z,g=p-(p-z),a=z-g,p=d*f,y=p-(p-f),x=f-y,O=a*x-(A-g*y-a*y-g*x),L=G*u,p=d*G,g=p-(p-G),a=G-g,p=d*u,y=p-(p-u),x=u-y,$=a*x-(L-g*y-a*y-g*x),b=O-$,c=O-b,N[0]=O-(b+c)+(c-$),v=A+b,c=v-A,S=A-(v-c)+(b-c),b=S-L,c=S-b,N[1]=S-(b+c)+(c-L),M=v+b,c=M-v,N[2]=v-(M-c)+(b-c),N[3]=M;const j=E(F,R,4,N,I);A=l*f,p=d*l,g=p-(p-l),a=l-g,p=d*f,y=p-(p-f),x=f-y,O=a*x-(A-g*y-a*y-g*x),L=h*u,p=d*h,g=p-(p-h),a=h-g,p=d*u,y=p-(p-u),x=u-y,$=a*x-(L-g*y-a*y-g*x),b=O-$,c=O-b,N[0]=O-(b+c)+(c-$),v=A+b,c=v-A,S=A-(v-c)+(b-c),b=S-L,c=S-b,N[1]=S-(b+c)+(c-L),M=v+b,c=M-v,N[2]=v-(M-c)+(b-c),N[3]=M;const U=E(j,I,4,N,P);return P[U-1]}(t,e,n,r,i,o,u)}const O=(t,e)=>t.x*e.y-t.y*e.x,L=(t,e)=>t.x*e.x+t.y*e.y,$=(t,e,n)=>{const r=A(t.x,t.y,e.x,e.y,n.x,n.y);return r>0?-1:r<0?1:0},M=t=>Math.sqrt(L(t,t)),z=(t,e,n)=>{const r={x:e.x-t.x,y:e.y-t.y},i={x:n.x-t.x,y:n.y-t.y};return O(i,r)/M(i)/M(r)},B=(t,e,n)=>{const r={x:e.x-t.x,y:e.y-t.y},i={x:n.x-t.x,y:n.y-t.y};return L(i,r)/M(i)/M(r)},G=(t,e,n)=>0===e.y?null:{x:t.x+e.x/e.y*(n-t.y),y:n},T=(t,e,n)=>0===e.x?null:{x:n,y:t.y+e.y/e.x*(n-t.x)};class q{static compare(t,e){const n=q.comparePoints(t.point,e.point);return 0!==n?n:(t.point!==e.point&&t.link(e),t.isLeft!==e.isLeft?t.isLeft?1:-1:F.compare(t.segment,e.segment))}static comparePoints(t,e){return t.x<e.x?-1:t.x>e.x?1:t.y<e.y?-1:t.y>e.y?1:0}constructor(t,e){void 0===t.events?t.events=[this]:t.events.push(this),this.point=t,this.isLeft=e}link(t){if(t.point===this.point)throw new Error("Tried to link already linked events");const e=t.point.events;for(let t=0,n=e.length;t<n;t++){const n=e[t];this.point.events.push(n),n.point=this.point}this.checkForConsuming()}checkForConsuming(){const t=this.point.events.length;for(let e=0;e<t;e++){const n=this.point.events[e];if(void 0===n.segment.consumedBy)for(let r=e+1;r<t;r++){const t=this.point.events[r];void 0===t.consumedBy&&(n.otherSE.point.events===t.otherSE.point.events&&n.segment.consume(t.segment))}}}getAvailableLinkedEvents(){const t=[];for(let e=0,n=this.point.events.length;e<n;e++){const n=this.point.events[e];n!==this&&!n.segment.ringOut&&n.segment.isInResult()&&t.push(n)}return t}getLeftmostComparator(t){const e=new Map,n=n=>{const r=n.otherSE;e.set(n,{sine:z(this.point,t.point,r.point),cosine:B(this.point,t.point,r.point)})};return(t,r)=>{e.has(t)||n(t),e.has(r)||n(r);const{sine:i,cosine:o}=e.get(t),{sine:s,cosine:l}=e.get(r);return i>=0&&s>=0?o<l?1:o>l?-1:0:i<0&&s<0?o<l?-1:o>l?1:0:s<i?-1:s>i?1:0}}}let C=0;class F{static compare(t,e){const n=t.leftSE.point.x,r=e.leftSE.point.x,i=t.rightSE.point.x,o=e.rightSE.point.x;if(o<n)return 1;if(i<r)return-1;const s=t.leftSE.point.y,l=e.leftSE.point.y,h=t.rightSE.point.y,u=e.rightSE.point.y;if(n<r){if(l<s&&l<h)return 1;if(l>s&&l>h)return-1;const n=t.comparePoint(e.leftSE.point);if(n<0)return 1;if(n>0)return-1;const r=e.comparePoint(t.rightSE.point);return 0!==r?r:-1}if(n>r){if(s<l&&s<u)return-1;if(s>l&&s>u)return 1;const n=e.comparePoint(t.leftSE.point);if(0!==n)return n;const r=t.comparePoint(e.rightSE.point);return r<0?1:r>0?-1:1}if(s<l)return-1;if(s>l)return 1;if(i<o){const n=e.comparePoint(t.rightSE.point);if(0!==n)return n}if(i>o){const n=t.comparePoint(e.rightSE.point);if(n<0)return 1;if(n>0)return-1}if(i!==o){const t=h-s,e=i-n,f=u-l,c=o-r;if(t>e&&f<c)return 1;if(t<e&&f>c)return-1}return i>o?1:i<o||h<u?-1:h>u?1:t.id<e.id?-1:t.id>e.id?1:0}constructor(t,e,n,r){this.id=++C,this.leftSE=t,t.segment=this,t.otherSE=e,this.rightSE=e,e.segment=this,e.otherSE=t,this.rings=n,this.windings=r}static fromRing(t,e,n){let r,i,o;const s=q.comparePoints(t,e);if(s<0)r=t,i=e,o=1;else{if(!(s>0))throw new Error(`Tried to create degenerate segment at [${t.x}, ${t.y}]`);r=e,i=t,o=-1}const l=new q(r,!0),h=new q(i,!1);return new F(l,h,[n],[o])}replaceRightSE(t){this.rightSE=t,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}bbox(){const t=this.leftSE.point.y,e=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:t<e?t:e},ur:{x:this.rightSE.point.x,y:t>e?t:e}}}vector(){return{x:this.rightSE.point.x-this.leftSE.point.x,y:this.rightSE.point.y-this.leftSE.point.y}}isAnEndpoint(t){return t.x===this.leftSE.point.x&&t.y===this.leftSE.point.y||t.x===this.rightSE.point.x&&t.y===this.rightSE.point.y}comparePoint(t){if(this.isAnEndpoint(t))return 0;const e=this.leftSE.point,n=this.rightSE.point,r=this.vector();if(e.x===n.x)return t.x===e.x?0:t.x<e.x?1:-1;const i=(t.y-e.y)/r.y,o=e.x+i*r.x;if(t.x===o)return 0;const s=(t.x-e.x)/r.x,l=e.y+s*r.y;return t.y===l?0:t.y<l?-1:1}getIntersection(t){const e=this.bbox(),n=t.bbox(),r=p(e,n);if(null===r)return null;const i=this.leftSE.point,o=this.rightSE.point,s=t.leftSE.point,l=t.rightSE.point,h=c(e,s)&&0===this.comparePoint(s),u=c(n,i)&&0===t.comparePoint(i),f=c(e,l)&&0===this.comparePoint(l),g=c(n,o)&&0===t.comparePoint(o);if(u&&h)return g&&!f?o:!g&&f?l:null;if(u)return f&&i.x===l.x&&i.y===l.y?null:i;if(h)return g&&o.x===s.x&&o.y===s.y?null:s;if(g&&f)return null;if(g)return o;if(f)return l;const a=((t,e,n,r)=>{if(0===e.x)return T(n,r,t.x);if(0===r.x)return T(t,e,n.x);if(0===e.y)return G(n,r,t.y);if(0===r.y)return G(t,e,n.y);const i=O(e,r);if(0==i)return null;const o={x:n.x-t.x,y:n.y-t.y},s=O(o,e)/i,l=O(o,r)/i;return{x:(t.x+l*e.x+(n.x+s*r.x))/2,y:(t.y+l*e.y+(n.y+s*r.y))/2}})(i,this.vector(),s,t.vector());return null===a?null:c(r,a)?b.round(a.x,a.y):null}split(t){const e=[],n=void 0!==t.events,r=new q(t,!0),i=new q(t,!1),o=this.rightSE;this.replaceRightSE(i),e.push(i),e.push(r);const s=new F(r,o,this.rings.slice(),this.windings.slice());return q.comparePoints(s.leftSE.point,s.rightSE.point)>0&&s.swapEvents(),q.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),n&&(r.checkForConsuming(),i.checkForConsuming()),e}swapEvents(){const t=this.rightSE;this.rightSE=this.leftSE,this.leftSE=t,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(let t=0,e=this.windings.length;t<e;t++)this.windings[t]*=-1}consume(t){let e=this,n=t;for(;e.consumedBy;)e=e.consumedBy;for(;n.consumedBy;)n=n.consumedBy;const r=F.compare(e,n);if(0!==r){if(r>0){const t=e;e=n,n=t}if(e.prev===n){const t=e;e=n,n=t}for(let t=0,r=n.rings.length;t<r;t++){const r=n.rings[t],i=n.windings[t],o=e.rings.indexOf(r);-1===o?(e.rings.push(r),e.windings.push(i)):e.windings[o]+=i}n.rings=null,n.windings=null,n.consumedBy=e,n.leftSE.consumedBy=e.leftSE,n.rightSE.consumedBy=e.rightSE}}prevInResult(){return void 0!==this._prevInResult||(this.prev?this.prev.isInResult()?this._prevInResult=this.prev:this._prevInResult=this.prev.prevInResult():this._prevInResult=null),this._prevInResult}beforeState(){if(void 0!==this._beforeState)return this._beforeState;if(this.prev){const t=this.prev.consumedBy||this.prev;this._beforeState=t.afterState()}else this._beforeState={rings:[],windings:[],multiPolys:[]};return this._beforeState}afterState(){if(void 0!==this._afterState)return this._afterState;const t=this.beforeState();this._afterState={rings:t.rings.slice(0),windings:t.windings.slice(0),multiPolys:[]};const e=this._afterState.rings,n=this._afterState.windings,r=this._afterState.multiPolys;for(let t=0,r=this.rings.length;t<r;t++){const r=this.rings[t],i=this.windings[t],o=e.indexOf(r);-1===o?(e.push(r),n.push(i)):n[o]+=i}const i=[],o=[];for(let t=0,r=e.length;t<r;t++){if(0===n[t])continue;const r=e[t],s=r.poly;if(-1===o.indexOf(s))if(r.isExterior)i.push(s);else{-1===o.indexOf(s)&&o.push(s);const t=i.indexOf(r.poly);-1!==t&&i.splice(t,1)}}for(let t=0,e=i.length;t<e;t++){const e=i[t].multiPoly;-1===r.indexOf(e)&&r.push(e)}return this._afterState}isInResult(){if(this.consumedBy)return!1;if(void 0!==this._isInResult)return this._isInResult;const t=this.beforeState().multiPolys,e=this.afterState().multiPolys;switch(H.type){case"union":{const n=0===t.length,r=0===e.length;this._isInResult=n!==r;break}case"intersection":{let n,r;t.length<e.length?(n=t.length,r=e.length):(n=e.length,r=t.length),this._isInResult=r===H.numMultiPolys&&n<r;break}case"xor":{const n=Math.abs(t.length-e.length);this._isInResult=n%2==1;break}case"difference":{const n=t=>1===t.length&&t[0].isSubject;this._isInResult=n(t)!==n(e);break}default:throw new Error(`Unrecognized operation type found ${H.type}`)}return this._isInResult}}class j{constructor(t,e,n){if(!Array.isArray(t)||0===t.length)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=e,this.isExterior=n,this.segments=[],"number"!=typeof t[0][0]||"number"!=typeof t[0][1])throw new Error("Input geometry is not a valid Polygon or MultiPolygon");const r=b.round(t[0][0],t[0][1]);this.bbox={ll:{x:r.x,y:r.y},ur:{x:r.x,y:r.y}};let i=r;for(let e=1,n=t.length;e<n;e++){if("number"!=typeof t[e][0]||"number"!=typeof t[e][1])throw new Error("Input geometry is not a valid Polygon or MultiPolygon");let n=b.round(t[e][0],t[e][1]);n.x===i.x&&n.y===i.y||(this.segments.push(F.fromRing(i,n,this)),n.x<this.bbox.ll.x&&(this.bbox.ll.x=n.x),n.y<this.bbox.ll.y&&(this.bbox.ll.y=n.y),n.x>this.bbox.ur.x&&(this.bbox.ur.x=n.x),n.y>this.bbox.ur.y&&(this.bbox.ur.y=n.y),i=n)}r.x===i.x&&r.y===i.y||this.segments.push(F.fromRing(i,r,this))}getSweepEvents(){const t=[];for(let e=0,n=this.segments.length;e<n;e++){const n=this.segments[e];t.push(n.leftSE),t.push(n.rightSE)}return t}}class U{constructor(t,e){if(!Array.isArray(t))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");this.exteriorRing=new j(t[0],this,!0),this.bbox={ll:{x:this.exteriorRing.bbox.ll.x,y:this.exteriorRing.bbox.ll.y},ur:{x:this.exteriorRing.bbox.ur.x,y:this.exteriorRing.bbox.ur.y}},this.interiorRings=[];for(let e=1,n=t.length;e<n;e++){const n=new j(t[e],this,!1);n.bbox.ll.x<this.bbox.ll.x&&(this.bbox.ll.x=n.bbox.ll.x),n.bbox.ll.y<this.bbox.ll.y&&(this.bbox.ll.y=n.bbox.ll.y),n.bbox.ur.x>this.bbox.ur.x&&(this.bbox.ur.x=n.bbox.ur.x),n.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=n.bbox.ur.y),this.interiorRings.push(n)}this.multiPoly=e}getSweepEvents(){const t=this.exteriorRing.getSweepEvents();for(let e=0,n=this.interiorRings.length;e<n;e++){const n=this.interiorRings[e].getSweepEvents();for(let e=0,r=n.length;e<r;e++)t.push(n[e])}return t}}class Y{constructor(t,e){if(!Array.isArray(t))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");try{"number"==typeof t[0][0][0]&&(t=[t])}catch(t){}this.polys=[],this.bbox={ll:{x:Number.POSITIVE_INFINITY,y:Number.POSITIVE_INFINITY},ur:{x:Number.NEGATIVE_INFINITY,y:Number.NEGATIVE_INFINITY}};for(let e=0,n=t.length;e<n;e++){const n=new U(t[e],this);n.bbox.ll.x<this.bbox.ll.x&&(this.bbox.ll.x=n.bbox.ll.x),n.bbox.ll.y<this.bbox.ll.y&&(this.bbox.ll.y=n.bbox.ll.y),n.bbox.ur.x>this.bbox.ur.x&&(this.bbox.ur.x=n.bbox.ur.x),n.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=n.bbox.ur.y),this.polys.push(n)}this.isSubject=e}getSweepEvents(){const t=[];for(let e=0,n=this.polys.length;e<n;e++){const n=this.polys[e].getSweepEvents();for(let e=0,r=n.length;e<r;e++)t.push(n[e])}return t}}class V{static factory(t){const e=[];for(let n=0,r=t.length;n<r;n++){const r=t[n];if(!r.isInResult()||r.ringOut)continue;let i=null,o=r.leftSE,s=r.rightSE;const l=[o],h=o.point,u=[];for(;i=o,o=s,l.push(o),o.point!==h;)for(;;){const t=o.getAvailableLinkedEvents();if(0===t.length){const t=l[0].point,e=l[l.length-1].point;throw new Error(`Unable to complete output ring starting at [${t.x}, ${t.y}]. Last matching segment found ends at [${e.x}, ${e.y}].`)}if(1===t.length){s=t[0].otherSE;break}let n=null;for(let t=0,e=u.length;t<e;t++)if(u[t].point===o.point){n=t;break}if(null!==n){const t=u.splice(n)[0],r=l.splice(t.index);r.unshift(r[0].otherSE),e.push(new V(r.reverse()));continue}u.push({index:l.length,point:o.point});const r=o.getLeftmostComparator(i);s=t.sort(r)[0].otherSE;break}e.push(new V(l))}return e}constructor(t){this.events=t;for(let e=0,n=t.length;e<n;e++)t[e].segment.ringOut=this;this.poly=null}getGeom(){let t=this.events[0].point;const e=[t];for(let n=1,r=this.events.length-1;n<r;n++){const r=this.events[n].point,i=this.events[n+1].point;0!==$(r,t,i)&&(e.push(r),t=r)}if(1===e.length)return null;const n=e[0],r=e[1];0===$(n,t,r)&&e.shift(),e.push(e[0]);const i=this.isExteriorRing()?1:-1,o=this.isExteriorRing()?0:e.length-1,s=this.isExteriorRing()?e.length:-1,l=[];for(let t=o;t!=s;t+=i)l.push([e[t].x,e[t].y]);return l}isExteriorRing(){if(void 0===this._isExteriorRing){const t=this.enclosingRing();this._isExteriorRing=!t||!t.isExteriorRing()}return this._isExteriorRing}enclosingRing(){return void 0===this._enclosingRing&&(this._enclosingRing=this._calcEnclosingRing()),this._enclosingRing}_calcEnclosingRing(){let t=this.events[0];for(let e=1,n=this.events.length;e<n;e++){const n=this.events[e];q.compare(t,n)>0&&(t=n)}let e=t.segment.prevInResult(),n=e?e.prevInResult():null;for(;;){if(!e)return null;if(!n)return e.ringOut;if(n.ringOut!==e.ringOut)return n.ringOut.enclosingRing()!==e.ringOut?e.ringOut:e.ringOut.enclosingRing();e=n.prevInResult(),n=e?e.prevInResult():null}}}class X{constructor(t){this.exteriorRing=t,t.poly=this,this.interiorRings=[]}addInterior(t){this.interiorRings.push(t),t.poly=this}getGeom(){const t=[this.exteriorRing.getGeom()];if(null===t[0])return null;for(let e=0,n=this.interiorRings.length;e<n;e++){const n=this.interiorRings[e].getGeom();null!==n&&t.push(n)}return t}}class Q{constructor(t){this.rings=t,this.polys=this._composePolys(t)}getGeom(){const t=[];for(let e=0,n=this.polys.length;e<n;e++){const n=this.polys[e].getGeom();null!==n&&t.push(n)}return t}_composePolys(t){const e=[];for(let n=0,r=t.length;n<r;n++){const r=t[n];if(!r.poly)if(r.isExteriorRing())e.push(new X(r));else{const t=r.enclosingRing();t.poly||e.push(new X(t)),t.poly.addInterior(r)}}return e}}class W{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:F.compare;this.queue=t,this.tree=new l(e),this.segments=[]}process(t){const e=t.segment,n=[];if(t.consumedBy)return t.isLeft?this.queue.remove(t.otherSE):this.tree.remove(e),n;const r=t.isLeft?this.tree.add(e):this.tree.find(e);if(!r)throw new Error(`Unable to find segment #${e.id} [${e.leftSE.point.x}, ${e.leftSE.point.y}] -> [${e.rightSE.point.x}, ${e.rightSE.point.y}] in SweepLine tree.`);let i,o,s=r,l=r;for(;void 0===i;)s=this.tree.prev(s),null===s?i=null:void 0===s.key.consumedBy&&(i=s.key);for(;void 0===o;)l=this.tree.next(l),null===l?o=null:void 0===l.key.consumedBy&&(o=l.key);if(t.isLeft){let r=null;if(i){const t=i.getIntersection(e);if(null!==t&&(e.isAnEndpoint(t)||(r=t),!i.isAnEndpoint(t))){const e=this._splitSafely(i,t);for(let t=0,r=e.length;t<r;t++)n.push(e[t])}}let s=null;if(o){const t=o.getIntersection(e);if(null!==t&&(e.isAnEndpoint(t)||(s=t),!o.isAnEndpoint(t))){const e=this._splitSafely(o,t);for(let t=0,r=e.length;t<r;t++)n.push(e[t])}}if(null!==r||null!==s){let t=null;if(null===r)t=s;else if(null===s)t=r;else{t=q.comparePoints(r,s)<=0?r:s}this.queue.remove(e.rightSE),n.push(e.rightSE);const i=e.split(t);for(let t=0,e=i.length;t<e;t++)n.push(i[t])}n.length>0?(this.tree.remove(e),n.push(t)):(this.segments.push(e),e.prev=i)}else{if(i&&o){const t=i.getIntersection(o);if(null!==t){if(!i.isAnEndpoint(t)){const e=this._splitSafely(i,t);for(let t=0,r=e.length;t<r;t++)n.push(e[t])}if(!o.isAnEndpoint(t)){const e=this._splitSafely(o,t);for(let t=0,r=e.length;t<r;t++)n.push(e[t])}}}this.tree.remove(e)}return n}_splitSafely(t,e){this.tree.remove(t);const n=t.rightSE;this.queue.remove(n);const r=t.split(e);return r.push(n),void 0===t.consumedBy&&this.tree.add(t),r}}const Z="undefined"!=typeof process&&process.env.POLYGON_CLIPPING_MAX_QUEUE_SIZE||1e6,D="undefined"!=typeof process&&process.env.POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS||1e6;const H=new class{run(t,e,n){H.type=t,b.reset();const r=[new Y(e,!0)];for(let t=0,e=n.length;t<e;t++)r.push(new Y(n[t],!1));if(H.numMultiPolys=r.length,"difference"===H.type){const t=r[0];let e=1;for(;e<r.length;)null!==p(r[e].bbox,t.bbox)?e++:r.splice(e,1)}if("intersection"===H.type)for(let t=0,e=r.length;t<e;t++){const e=r[t];for(let n=t+1,i=r.length;n<i;n++)if(null===p(e.bbox,r[n].bbox))return[]}const i=new l(q.compare);for(let t=0,e=r.length;t<e;t++){const e=r[t].getSweepEvents();for(let t=0,n=e.length;t<n;t++)if(i.insert(e[t]),i.size>Z)throw new Error("Infinite loop when putting segment endpoints in a priority queue (queue size too big).")}const o=new W(i);let s=i.size,h=i.pop();for(;h;){const t=h.key;if(i.size===s){const e=t.segment;throw new Error(`Unable to pop() ${t.isLeft?"left":"right"} SweepEvent [${t.point.x}, ${t.point.y}] from segment #${e.id} [${e.leftSE.point.x}, ${e.leftSE.point.y}] -> [${e.rightSE.point.x}, ${e.rightSE.point.y}] from queue.`)}if(i.size>Z)throw new Error("Infinite loop when passing sweep line over endpoints (queue size too big).");if(o.segments.length>D)throw new Error("Infinite loop when passing sweep line over endpoints (too many sweep line segments).");const e=o.process(t);for(let t=0,n=e.length;t<n;t++){const n=e[t];void 0===n.consumedBy&&i.insert(n)}s=i.size,h=i.pop()}b.reset();const u=V.factory(o.segments);return new Q(u).getGeom()}};var J={union:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return H.run("union",t,n)},intersection:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return H.run("intersection",t,n)},xor:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return H.run("xor",t,n)},difference:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return H.run("difference",t,n)}};return J})); //# sourceMappingURL=polygon-clipping.umd.min.js.map maplibre-gl.js 0000666 00004020105 15244655455 0007322 0 ustar 00 /** * MapLibre GL JS * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v5.24.0/LICENSE.txt */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.maplibregl = factory()); })(this, (function () { 'use strict'; /* eslint-disable */ var maplibregl = {}; var modules = {}; function define(moduleName, _dependencies, moduleFactory) { modules[moduleName] = moduleFactory; // to get the list of modules see generated dist/maplibre-gl-dev.js file (look for `define(` calls) if (moduleName !== 'index') { return; } // we assume that when an index module is initializing then other modules are loaded already var workerBundleString = 'var sharedModule = {}; (' + modules.shared + ')(sharedModule); (' + modules.worker + ')(sharedModule);' var sharedModule = {}; // the order of arguments of a module factory depends on rollup (it decides who is whose dependency) // to check the correct order, see dist/maplibre-gl-dev.js file (look for `define(` calls) // we assume that for our 3 chunks it will generate 3 modules and their order is predefined like the following modules.shared(sharedModule); modules.index(maplibregl, sharedModule); if (typeof window !== 'undefined') { maplibregl.setWorkerUrl(window.URL.createObjectURL(new Blob([workerBundleString], { type: 'text/javascript' }))); } return maplibregl; }; define("shared",["exports"],(function(t){"use strict";function e(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{l(r.next(t));}catch(t){s(t);}}function a(t){try{l(r.throw(t));}catch(t){s(t);}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e);}))).then(o,a);}l((r=r.apply(t,e||[])).next());}))}function n(t,e){this.x=t,this.y=e;}function r(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var i,s;"function"==typeof SuppressedError&&SuppressedError,n.prototype={clone(){return new n(this.x,this.y)},add(t){return this.clone()._add(t)},sub(t){return this.clone()._sub(t)},multByPoint(t){return this.clone()._multByPoint(t)},divByPoint(t){return this.clone()._divByPoint(t)},mult(t){return this.clone()._mult(t)},div(t){return this.clone()._div(t)},rotate(t){return this.clone()._rotate(t)},rotateAround(t,e){return this.clone()._rotateAround(t,e)},matMult(t){return this.clone()._matMult(t)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(t){return this.x===t.x&&this.y===t.y},dist(t){return Math.sqrt(this.distSqr(t))},distSqr(t){const e=t.x-this.x,n=t.y-this.y;return e*e+n*n},angle(){return Math.atan2(this.y,this.x)},angleTo(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith(t){return this.angleWithSep(t.x,t.y)},angleWithSep(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult(t){const e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add(t){return this.x+=t.x,this.y+=t.y,this},_sub(t){return this.x-=t.x,this.y-=t.y,this},_mult(t){return this.x*=t,this.y*=t,this},_div(t){return this.x/=t,this.y/=t,this},_multByPoint(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint(t){return this.x/=t.x,this.y/=t.y,this},_unit(){return this._div(this.mag()),this},_perp(){const t=this.y;return this.y=this.x,this.x=-t,this},_rotate(t){const e=Math.cos(t),n=Math.sin(t),r=n*this.x+e*this.y;return this.x=e*this.x-n*this.y,this.y=r,this},_rotateAround(t,e){const n=Math.cos(t),r=Math.sin(t),i=e.y+r*(this.x-e.x)+n*(this.y-e.y);return this.x=e.x+n*(this.x-e.x)-r*(this.y-e.y),this.y=i,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:n},n.convert=function(t){if(t instanceof n)return t;if(Array.isArray(t))return new n(+t[0],+t[1]);if(void 0!==t.x&&void 0!==t.y)return new n(+t.x,+t.y);throw new Error("Expected [x, y] or {x, y} point format")};var o=function(){if(s)return i;function t(t,e,n,r){this.cx=3*t,this.bx=3*(n-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(r-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=n,this.p2y=r;}return s=1,i=t,t.prototype={sampleCurveX:function(t){return ((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return ((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return (3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var n=t,r=0;r<8;r++){var i=this.sampleCurveX(n)-t;if(Math.abs(i)<e)return n;var s=this.sampleCurveDerivativeX(n);if(Math.abs(s)<1e-6)break;n-=i/s;}var o=0,a=1;for(n=t,r=0;r<20&&(i=this.sampleCurveX(n),!(Math.abs(i-t)<e));r++)t>i?o=n:a=n,n=.5*(a-o)+o;return n},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}},i}(),a=r(o);let l,u;function c(){return null!=l||(l="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),l}function h(){if(null==u&&(u=!1,c())){const t=5,e=new OffscreenCanvas(t,t).getContext("2d",{willReadFrequently:!0});if(e){for(let n=0;n<t*t;n++){const r=4*n;e.fillStyle=`rgb(${r},${r+1},${r+2})`,e.fillRect(n%t,Math.floor(n/t),1,1);}const n=e.getImageData(0,0,t,t).data;for(let e=0;e<t*t*4;e++)if(e%4!=3&&n[e]!==e){u=!0;break}}}return u||!1}var p=1e-6,f="undefined"!=typeof Float32Array?Float32Array:Array;function d(){var t=new f(9);return f!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function y(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function m(){var t=new f(3);return f!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function g(t){var e=t[0],n=t[1],r=t[2];return Math.sqrt(e*e+n*n+r*r)}function x(t,e,n){var r=new f(3);return r[0]=t,r[1]=e,r[2]=n,r}function v(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function b(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function w(t,e,n){var r=e[0],i=e[1],s=e[2],o=n[0],a=n[1],l=n[2];return t[0]=i*l-s*a,t[1]=s*o-r*l,t[2]=r*a-i*o,t}var _,S=g;function A(t,e,n){var r=e[0],i=e[1],s=e[2],o=e[3];return t[0]=n[0]*r+n[4]*i+n[8]*s+n[12]*o,t[1]=n[1]*r+n[5]*i+n[9]*s+n[13]*o,t[2]=n[2]*r+n[6]*i+n[10]*s+n[14]*o,t[3]=n[3]*r+n[7]*i+n[11]*s+n[15]*o,t}function M(){var t=new f(4);return f!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function k(t,e,n,r){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"zyx",s=Math.PI/360;e*=s,r*=s,n*=s;var o=Math.sin(e),a=Math.cos(e),l=Math.sin(n),u=Math.cos(n),c=Math.sin(r),h=Math.cos(r);switch(i){case "xyz":t[0]=o*u*h+a*l*c,t[1]=a*l*h-o*u*c,t[2]=a*u*c+o*l*h,t[3]=a*u*h-o*l*c;break;case "xzy":t[0]=o*u*h-a*l*c,t[1]=a*l*h-o*u*c,t[2]=a*u*c+o*l*h,t[3]=a*u*h+o*l*c;break;case "yxz":t[0]=o*u*h+a*l*c,t[1]=a*l*h-o*u*c,t[2]=a*u*c-o*l*h,t[3]=a*u*h+o*l*c;break;case "yzx":t[0]=o*u*h+a*l*c,t[1]=a*l*h+o*u*c,t[2]=a*u*c-o*l*h,t[3]=a*u*h-o*l*c;break;case "zxy":t[0]=o*u*h-a*l*c,t[1]=a*l*h+o*u*c,t[2]=a*u*c+o*l*h,t[3]=a*u*h-o*l*c;break;case "zyx":t[0]=o*u*h-a*l*c,t[1]=a*l*h+o*u*c,t[2]=a*u*c-o*l*h,t[3]=a*u*h+o*l*c;break;default:throw new Error("Unknown angle order "+i)}return t}function I(){var t=new f(2);return f!=Float32Array&&(t[0]=0,t[1]=0),t}function E(t,e){var n=new f(2);return n[0]=t,n[1]=e,n}m(),_=new f(4),f!=Float32Array&&(_[0]=0,_[1]=0,_[2]=0,_[3]=0),m(),x(1,0,0),x(0,1,0),M(),M(),d(),I();const T=8192;function F(t,e,n){return e*(T/(t.tileSize*Math.pow(2,n-t.tileID.overscaledZ)))}function P(t){return t instanceof Error?t:new Error("string"==typeof t?t:String(t))}function D(t,e){return (t%e+e)%e}function z(t,e,n){return t*(1-n)+e*n}function B(t){if(t<=0)return 0;if(t>=1)return 1;const e=t*t,n=e*t;return 4*(t<.5?n:3*(t-e)+n-.75)}function C(t,e,n,r){const i=new a(t,e,n,r);return t=>i.solve(t)}const V=C(.25,.1,.25,1);function L(t,e,n){return Math.min(n,Math.max(e,t))}function O(t,e,n){const r=n-e,i=((t-e)%r+r)%r+e;return i===e?n:i}function $(t,...e){for(const n of e)for(const e in n)t[e]=n[e];return t}let R=1;function N(t,e,n){const r={};for(const n in t)r[n]=e.call(this,t[n],n,t);return r}function U(t,e,n){const r={};for(const n in t)e.call(this,t[n],n,t)&&(r[n]=t[n]);return r}function j(t){return Array.isArray(t)?t.map(j):"object"==typeof t&&t?N(t,j):t}const q={};function G(t){q[t]||("undefined"!=typeof console&&console.warn(t),q[t]=!0);}function X(t,e,n){return (n.y-t.y)*(e.x-t.x)>(e.y-t.y)*(n.x-t.x)}function Y(t){return "undefined"!=typeof WorkerGlobalScope&&void 0!==t&&t instanceof WorkerGlobalScope}let Z=null;function H(t){return "undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap}const W="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function K(t,n,r,i,s){return e(this,void 0,void 0,(function*(){if("undefined"==typeof VideoFrame)throw new Error("VideoFrame not supported");const e=new VideoFrame(t,{timestamp:0});try{const o=null==e?void 0:e.format;if(!o||!o.startsWith("BGR")&&!o.startsWith("RGB"))throw new Error(`Unrecognized format ${o}`);const a=o.startsWith("BGR"),l=new Uint8ClampedArray(i*s*4);if(yield e.copyTo(l,function(t,e,n,r,i){const s=4*Math.max(-e,0),o=(Math.max(0,n)-n)*r*4+s,a=4*r,l=Math.max(0,e),u=Math.max(0,n);return {rect:{x:l,y:u,width:Math.min(t.width,e+r)-l,height:Math.min(t.height,n+i)-u},layout:[{offset:o,stride:a}]}}(t,n,r,i,s)),a)for(let t=0;t<l.length;t+=4){const e=l[t];l[t]=l[t+2],l[t+2]=e;}return l}finally{e.close();}}))}let J,Q;function tt(t,e,n,r){return t.addEventListener(e,n,r),{unsubscribe:()=>{t.removeEventListener(e,n,r);}}}function et(t){return t*Math.PI/180}function nt(t){return t/Math.PI*180}const rt={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},it={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},st="AbortError";class ot extends Error{constructor(t=st){super(t instanceof Error?t.message:t),this.name=st,t instanceof Error&&t.stack&&(this.stack=t.stack);}}function at(t){return t instanceof Error&&t.name===st}function lt(t){if(t.aborted)throw new ot(t.reason)}const ut={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function ct(t){return ut.REGISTERED_PROTOCOLS[t.substring(0,t.indexOf("://"))]}const ht="global-dispatcher";class pt extends Error{constructor(t,e,n,r){super(`AJAXError: ${e} (${t}): ${n}`),this.status=t,this.statusText=e,this.url=n,this.body=r;}}const ft=()=>{var t;return Y(self)?null===(t=self.worker)||void 0===t?void 0:t.referrer:("blob:"===window.location.protocol?window.parent:window).location.href},dt=function(t,n){return e(this,void 0,void 0,(function*(){var r,i;if(t.url.includes("://")&&!/^https?:|^file:/.test(t.url)){const e=ct(t.url);if(e){const r=yield e(t,n);return r.data||"arrayBuffer"!==t.type?r:$(r,{data:new ArrayBuffer(0)})}if(Y(self)&&(null===(r=self.worker)||void 0===r?void 0:r.actor))return self.worker.actor.sendAsync({type:"GR",data:t,targetMapId:ht},n)}if(!(t=>{var e;return t.startsWith("file:")||(null===(e=ft())||void 0===e?void 0:e.startsWith("file:"))&&!/^\w+:/.test(t)})(t.url)){if(fetch&&Request&&AbortController&&Object.hasOwn(Request.prototype,"signal"))return function(t,n){return e(this,void 0,void 0,(function*(){const e=new Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,cache:t.cache,referrer:ft(),referrerPolicy:t.referrerPolicy,signal:n.signal});let r,i;"json"!==t.type||e.headers.has("Accept")||e.headers.set("Accept","application/json");try{r=yield fetch(e);}catch(e){if(at(e))throw e;throw new pt(0,P(e).message,t.url,new Blob)}if(!r.ok){const e=yield r.blob();throw new pt(r.status,r.statusText,t.url,e)}i="arrayBuffer"===t.type||"image"===t.type?r.arrayBuffer():"json"===t.type?r.json():r.text();const s=yield i;return lt(n.signal),{data:s,cacheControl:r.headers.get("Cache-Control"),expires:r.headers.get("Expires"),etag:r.headers.get("ETag")}}))}(t,n);if(Y(self)&&(null===(i=self.worker)||void 0===i?void 0:i.actor))return self.worker.actor.sendAsync({type:"GR",data:t,mustQueue:!0,targetMapId:ht},n)}return function(t,e){return new Promise(((n,r)=>{var i;const s=new XMLHttpRequest;s.open(t.method||"GET",t.url,!0),"arrayBuffer"!==t.type&&"image"!==t.type||(s.responseType="arraybuffer");for(const e in t.headers)s.setRequestHeader(e,t.headers[e]);"json"===t.type&&(s.responseType="text",(null===(i=t.headers)||void 0===i?void 0:i.Accept)||s.setRequestHeader("Accept","application/json")),s.withCredentials="include"===t.credentials,s.onerror=()=>{r(new Error(s.statusText));},s.onload=()=>{if(!e.signal.aborted)if((s.status>=200&&s.status<300||0===s.status)&&null!==s.response){let e=s.response;if("json"===t.type)try{e=JSON.parse(s.response);}catch(t){return void r(t)}n({data:e,cacheControl:s.getResponseHeader("Cache-Control"),expires:s.getResponseHeader("Expires"),etag:s.getResponseHeader("ETag")});}else {const e=new Blob([s.response],{type:s.getResponseHeader("Content-Type")});r(new pt(s.status,s.statusText,t.url,e));}},e.signal.addEventListener("abort",(()=>{s.abort(),r(new ot(e.signal.reason));})),s.send(t.body);}))}(t,n)}))};function yt(t){if(!t||t.indexOf("://")<=0||t.startsWith("data:image/")||t.startsWith("blob:"))return !0;const e=new URL(t),n=window.location;return e.protocol===n.protocol&&e.host===n.host}function mt(t,e,n){var r;(null===(r=n[t])||void 0===r?void 0:r.includes(e))||(n[t]||(n[t]=[]),n[t].push(e));}function gt(t,e,n){if(null==n?void 0:n[t]){const r=n[t].indexOf(e);-1!==r&&n[t].splice(r,1);}}class xt{constructor(t,e={}){$(this,e),this.type=t;}}class vt extends xt{constructor(t,e={}){super("error",$({error:t},e));}}class bt{on(t,e){return this._listeners||(this._listeners={}),mt(t,e,this._listeners),{unsubscribe:()=>{this.off(t,e);}}}off(t,e){return gt(t,e,this._listeners),gt(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners||(this._oneTimeListeners={}),mt(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){var n,r;"string"==typeof t&&(t=new xt(t,e||{}));const i=t.type;if(this.listens(i)){t.target=this;const e=(null===(n=this._listeners)||void 0===n?void 0:n[i])?this._listeners[i].slice():[];for(const n of e)n.call(this,t);const s=(null===(r=this._oneTimeListeners)||void 0===r?void 0:r[i])?this._oneTimeListeners[i].slice():[];for(const e of s)gt(i,e,this._oneTimeListeners),e.call(this,t);const o=this._eventedParent;o&&($(t,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),o.fire(t));}else t instanceof vt&&console.error(t.error);return this}listens(t){var e,n,r,i,s;return (null===(n=null===(e=this._listeners)||void 0===e?void 0:e[t])||void 0===n?void 0:n.length)>0||(null===(i=null===(r=this._oneTimeListeners)||void 0===r?void 0:r[t])||void 0===i?void 0:i.length)>0||(null===(s=this._eventedParent)||void 0===s?void 0:s.listens(t))}setEventedParent(t,e){return this._eventedParent=t,this._eventedParentData=e,this}}var wt={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number",length:2},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},state:{type:"state",default:{}},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},"font-faces":{type:"fontFaces"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},encoding:{type:"enum",values:{mvt:{},mlt:{}},default:"mvt"},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"filter"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},"color-relief":{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_color-relief","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_color-relief":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},filter:{type:"boolean",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"expression_name",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_color-relief","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"numberArray",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-altitude":{type:"numberArray",default:45,minimum:0,maximum:90,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"colorArray",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"colorArray",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-method":{type:"enum",values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:"standard",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},"paint_color-relief":{"color-relief-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"color-relief-color":{type:"color",transition:!1,expression:{interpolated:!0,parameters:["elevation"]},"property-type":"color-ramp"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}},interpolation:{type:"array",value:"interpolation_name",minimum:1},interpolation_name:{type:"enum",values:{linear:{syntax:{overloads:[{parameters:[],"output-type":"interpolation"}],parameters:[]}},exponential:{syntax:{overloads:[{parameters:["base"],"output-type":"interpolation"}],parameters:[{name:"base",type:"number literal"}]}},"cubic-bezier":{syntax:{overloads:[{parameters:["x1","y1","x2","y2"],"output-type":"interpolation"}],parameters:[{name:"x1",type:"number literal"},{name:"y1",type:"number literal"},{name:"x2",type:"number literal"},{name:"y2",type:"number literal"}]}}}}};const _t=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function St(t,e){const n={};for(const e in t)"ref"!==e&&(n[e]=t[e]);return _t.forEach((t=>{t in e&&(n[t]=e[t]);})),n}function At(t,e){if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return !1;for(let n=0;n<t.length;n++)if(!At(t[n],e[n]))return !1;return !0}if("object"==typeof t&&null!==t&&null!==e){if("object"!=typeof e)return !1;if(Object.keys(t).length!==Object.keys(e).length)return !1;for(const n in t)if(!At(t[n],e[n]))return !1;return !0}return t===e}function Mt(t,e){t.push(e);}function kt(t,e,n){Mt(n,{command:"addSource",args:[t,e[t]]});}function It(t,e,n){Mt(e,{command:"removeSource",args:[t]}),n[t]=!0;}function Et(t,e,n,r){It(t,n,r),kt(t,e,n);}function Tt(t,e,n){let r;for(r in t[n])if(Object.prototype.hasOwnProperty.call(t[n],r)&&"data"!==r&&!At(t[n][r],e[n][r]))return !1;for(r in e[n])if(Object.prototype.hasOwnProperty.call(e[n],r)&&"data"!==r&&!At(t[n][r],e[n][r]))return !1;return !0}function Ft(t,e,n,r,i,s){t=t||{},e=e||{};for(const o in t)Object.prototype.hasOwnProperty.call(t,o)&&(At(t[o],e[o])||n.push({command:s,args:[r,o,e[o],i]}));for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&!Object.prototype.hasOwnProperty.call(t,o)&&(At(t[o],e[o])||n.push({command:s,args:[r,o,e[o],i]}));}function Pt(t){return t.id}function Dt(t,e){return t[e.id]=e,t}class zt{constructor(t,e,n,r){this.message=(t?`${t}: `:"")+n,r&&(this.identifier=r),null!=e&&e.__line__&&(this.line=e.__line__);}}function Bt(t,...e){for(const n of e)for(const e in n)t[e]=n[e];return t}class Ct extends Error{constructor(t,e){super(e),this.message=e,this.key=t;}}class Vt{constructor(t,e=[]){this.parent=t,this.bindings={};for(const[t,n]of e)this.bindings[t]=n;}concat(t){return new Vt(this,t)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw new Error(`${t} not found in scope.`)}has(t){return !!this.bindings[t]||!!this.parent&&this.parent.has(t)}}const Lt={kind:"null"},Ot={kind:"number"},$t={kind:"string"},Rt={kind:"boolean"},Nt={kind:"color"},Ut={kind:"projectionDefinition"},jt={kind:"object"},qt={kind:"value"},Gt={kind:"collator"},Xt={kind:"formatted"},Yt={kind:"padding"},Zt={kind:"colorArray"},Ht={kind:"numberArray"},Wt={kind:"resolvedImage"},Kt={kind:"variableAnchorOffsetCollection"};function Jt(t,e){return {kind:"array",itemType:t,N:e}}function Qt(t){if("array"===t.kind){const e=Qt(t.itemType);return "number"==typeof t.N?`array<${e}, ${t.N}>`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const te=[Lt,Ot,$t,Rt,Nt,Ut,Xt,jt,Jt(qt),Yt,Ht,Zt,Wt,Kt];function ee(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!ee(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else {if(t.kind===e.kind)return null;if("value"===t.kind)for(const t of te)if(!ee(t,e))return null}return `Expected ${Qt(t)} but found ${Qt(e)} instead.`}function ne(t,e){return e.some((e=>e.kind===t.kind))}function re(t,e){return e.some((e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t))}function ie(t,e){return "array"===t.kind&&"array"===e.kind?t.itemType.kind===e.itemType.kind&&"number"==typeof t.N:t.kind===e.kind}const se=.96422,oe=.82521,ae=4/29,le=6/29,ue=3*le*le,ce=le*le*le,he=Math.PI/180,pe=180/Math.PI;function fe(t){return (t%=360)<0&&(t+=360),t}function de([t,e,n,r]){let i,s;const o=me((.2225045*(t=ye(t))+.7168786*(e=ye(e))+.0606169*(n=ye(n)))/1);t===e&&e===n?i=s=o:(i=me((.4360747*t+.3850649*e+.1430804*n)/se),s=me((.0139322*t+.0971045*e+.7141733*n)/oe));const a=116*o-16;return [a<0?0:a,500*(i-o),200*(o-s),r]}function ye(t){return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function me(t){return t>ce?Math.pow(t,1/3):t/ue+ae}function ge([t,e,n,r]){let i=(t+16)/116,s=isNaN(e)?i:i+e/500,o=isNaN(n)?i:i-n/200;return i=1*ve(i),s=se*ve(s),o=oe*ve(o),[xe(3.1338561*s-1.6168667*i-.4906146*o),xe(-.9787684*s+1.9161415*i+.033454*o),xe(.0719453*s-.2289914*i+1.4052427*o),r]}function xe(t){return (t=t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055)<0?0:t>1?1:t}function ve(t){return t>le?t*t*t:ue*(t-ae)}const be=Object.hasOwn||function(t,e){return Object.prototype.hasOwnProperty.call(t,e)};function we(t,e){return be(t,e)?t[e]:void 0}function _e(t){return parseInt(t.padEnd(2,t),16)/255}function Se(t,e){return Ae(e?t/100:t,0,1)}function Ae(t,e,n){return Math.min(Math.max(e,t),n)}function Me(t){return !t.some(Number.isNaN)}const ke={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function Ie(t,e,n){return t+n*(e-t)}function Ee(t,e,n){return t.map(((t,r)=>Ie(t,e[r],n)))}class Te{constructor(t,e,n,r=1,i=!0){this.r=t,this.g=e,this.b=n,this.a=r,i||(this.r*=r,this.g*=r,this.b*=r,r||this.overwriteGetter("rgb",[t,e,n,r]));}static parse(t){if(t instanceof Te)return t;if("string"!=typeof t)return;const e=function(t){if("transparent"===(t=t.toLowerCase().trim()))return [0,0,0,0];const e=we(ke,t);if(e){const[t,n,r]=e;return [t/255,n/255,r/255,1]}if(t.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(t)){const e=t.length<6?1:2;let n=1;return [_e(t.slice(n,n+=e)),_e(t.slice(n,n+=e)),_e(t.slice(n,n+=e)),_e(t.slice(n,n+e)||"ff")]}if(t.startsWith("rgb")){const e=t.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(e){const[t,n,r,i,s,o,a,l,u,c,h,p]=e,f=[i||" ",a||" ",c].join("");if(" "===f||" /"===f||",,"===f||",,,"===f){const t=[r,o,u].join(""),e="%%%"===t?100:""===t?255:0;if(e){const t=[Ae(+n/e,0,1),Ae(+s/e,0,1),Ae(+l/e,0,1),h?Se(+h,p):1];if(Me(t))return t}}return}}const n=t.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(n){const[t,e,r,i,s,o,a,l,u]=n,c=[r||" ",s||" ",a].join("");if(" "===c||" /"===c||",,"===c||",,,"===c){const t=[+e,Ae(+i,0,100),Ae(+o,0,100),l?Se(+l,u):1];if(Me(t))return function([t,e,n,r]){function i(r){const i=(r+t/30)%12,s=e*Math.min(n,1-n);return n-s*Math.max(-1,Math.min(i-3,9-i,1))}return t=fe(t),e/=100,n/=100,[i(0),i(8),i(4),r]}(t)}}}(t);return e?new Te(...e,!1):void 0}get rgb(){const{r:t,g:e,b:n,a:r}=this,i=r||1/0;return this.overwriteGetter("rgb",[t/i,e/i,n/i,r])}get hcl(){return this.overwriteGetter("hcl",function(t){const[e,n,r,i]=de(t),s=Math.sqrt(n*n+r*r);return [Math.round(1e4*s)?fe(Math.atan2(r,n)*pe):NaN,s,e,i]}(this.rgb))}get lab(){return this.overwriteGetter("lab",de(this.rgb))}overwriteGetter(t,e){return Object.defineProperty(this,t,{value:e}),e}toString(){const[t,e,n,r]=this.rgb;return `rgba(${[t,e,n].map((t=>Math.round(255*t))).join(",")},${r})`}static interpolate(t,e,n,r="rgb"){switch(r){case "rgb":{const[r,i,s,o]=Ee(t.rgb,e.rgb,n);return new Te(r,i,s,o,!1)}case "hcl":{const[r,i,s,o]=t.hcl,[a,l,u,c]=e.hcl;let h,p;if(isNaN(r)||isNaN(a))isNaN(r)?isNaN(a)?h=NaN:(h=a,1!==s&&0!==s||(p=l)):(h=r,1!==u&&0!==u||(p=i));else {let t=a-r;a>r&&t>180?t-=360:a<r&&r-a>180&&(t+=360),h=r+n*t;}const[f,d,y,m]=function([t,e,n,r]){return t=isNaN(t)?0:t*he,ge([n,Math.cos(t)*e,Math.sin(t)*e,r])}([h,null!=p?p:Ie(i,l,n),Ie(s,u,n),Ie(o,c,n)]);return new Te(f,d,y,m,!1)}case "lab":{const[r,i,s,o]=ge(Ee(t.lab,e.lab,n));return new Te(r,i,s,o,!1)}}}}Te.black=new Te(0,0,0,1),Te.white=new Te(1,1,1,1),Te.transparent=new Te(0,0,0,0),Te.red=new Te(1,0,0,1);class Fe{constructor(t,e,n){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=n,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"});}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}const Pe=["bottom","center","top"];class De{constructor(t,e,n,r,i,s){this.text=t,this.image=e,this.scale=n,this.fontStack=r,this.textColor=i,this.verticalAlign=s;}}class ze{constructor(t){this.sections=t;}static fromString(t){return new ze([new De(t,null,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||t.image&&0!==t.image.name.length))}static factory(t){return t instanceof ze?t:ze.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}}class Be{constructor(t){this.values=t.slice();}static parse(t){if(t instanceof Be)return t;if("number"==typeof t)return new Be([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(const e of t)if("number"!=typeof e)return;switch(t.length){case 1:t=[t[0],t[0],t[0],t[0]];break;case 2:t=[t[0],t[1],t[0],t[1]];break;case 3:t=[t[0],t[1],t[2],t[1]];}return new Be(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,e,n){return new Be(Ee(t.values,e.values,n))}}class Ce{constructor(t){this.values=t.slice();}static parse(t){if(t instanceof Ce)return t;if("number"==typeof t)return new Ce([t]);if(Array.isArray(t)){for(const e of t)if("number"!=typeof e)return;return new Ce(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,e,n){return new Ce(Ee(t.values,e.values,n))}}class Ve{constructor(t){this.values=t.slice();}static parse(t){if(t instanceof Ve)return t;if("string"==typeof t){const e=Te.parse(t);if(!e)return;return new Ve([e])}if(!Array.isArray(t))return;const e=[];for(const n of t){if("string"!=typeof n)return;const t=Te.parse(n);if(!t)return;e.push(t);}return new Ve(e)}toString(){return JSON.stringify(this.values)}static interpolate(t,e,n,r="rgb"){const i=[];if(t.values.length!=e.values.length)throw new Error(`colorArray: Arrays have mismatched length (${t.values.length} vs. ${e.values.length}), cannot interpolate.`);for(let s=0;s<t.values.length;s++)i.push(Te.interpolate(t.values[s],e.values[s],n,r));return new Ve(i)}}class Le extends Error{constructor(t){super(t),this.name="RuntimeError";}toJSON(){return this.message}}const Oe=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class $e{constructor(t){this.values=t.slice();}static parse(t){if(t instanceof $e)return t;if(Array.isArray(t)&&!(t.length<1)&&t.length%2==0){for(let e=0;e<t.length;e+=2){const n=t[e],r=t[e+1];if("string"!=typeof n||!Oe.has(n))return;if(!Array.isArray(r)||2!==r.length||"number"!=typeof r[0]||"number"!=typeof r[1])return}return new $e(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,e,n){const r=t.values,i=e.values;if(r.length!==i.length)throw new Le(`Cannot interpolate values of different length. from: ${t.toString()}, to: ${e.toString()}`);const s=[];for(let t=0;t<r.length;t+=2){if(r[t]!==i[t])throw new Le(`Cannot interpolate values containing mismatched anchors. from[${t}]: ${r[t]}, to[${t}]: ${i[t]}`);s.push(r[t]);const[e,o]=r[t+1],[a,l]=i[t+1];s.push([Ie(e,a,n),Ie(o,l,n)]);}return new $e(s)}}class Re{constructor(t){this.name=t.name,this.available=t.available;}toString(){return this.name}static fromString(t){return t?new Re({name:t,available:!1}):null}}class Ne{constructor(t,e,n){this.from=t,this.to=e,this.transition=n;}static interpolate(t,e,n){return new Ne(t,e,n)}static parse(t){return t instanceof Ne?t:Array.isArray(t)&&3===t.length&&"string"==typeof t[0]&&"string"==typeof t[1]&&"number"==typeof t[2]?new Ne(t[0],t[1],t[2]):"object"==typeof t&&"string"==typeof t.from&&"string"==typeof t.to&&"number"==typeof t.transition?new Ne(t.from,t.to,t.transition):"string"==typeof t?new Ne(t,t,1):void 0}}function Ue(t,e,n,r){return "number"==typeof t&&t>=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof n&&n>=0&&n<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[t,e,n,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[t,e,n,r]:[t,e,n]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function je(t){if(null===t||"string"==typeof t||"boolean"==typeof t||"number"==typeof t||t instanceof Ne||t instanceof Te||t instanceof Fe||t instanceof ze||t instanceof Be||t instanceof Ce||t instanceof Ve||t instanceof $e||t instanceof Re)return !0;if(Array.isArray(t)){for(const e of t)if(!je(e))return !1;return !0}if("object"==typeof t){for(const e in t)if(!je(t[e]))return !1;return !0}return !1}function qe(t){if(null===t)return Lt;if("string"==typeof t)return $t;if("boolean"==typeof t)return Rt;if("number"==typeof t)return Ot;if(t instanceof Te)return Nt;if(t instanceof Ne)return Ut;if(t instanceof Fe)return Gt;if(t instanceof ze)return Xt;if(t instanceof Be)return Yt;if(t instanceof Ce)return Ht;if(t instanceof Ve)return Zt;if(t instanceof $e)return Kt;if(t instanceof Re)return Wt;if(Array.isArray(t)){const e=t.length;let n;for(const e of t){const t=qe(e);if(n){if(n===t)continue;n=qt;break}n=t;}return Jt(n||qt,e)}return jt}function Ge(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof Te||t instanceof Ne||t instanceof ze||t instanceof Be||t instanceof Ce||t instanceof Ve||t instanceof $e||t instanceof Re?t.toString():JSON.stringify(t)}class Xe{constructor(t,e){this.type=t,this.value=e;}static parse(t,e){if(2!==t.length)return e.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!je(t[1]))return e.error("invalid value");const n=t[1];let r=qe(n);const i=e.expectedType;return "array"!==r.kind||0!==r.N||!i||"array"!==i.kind||"number"==typeof i.N&&0!==i.N||(r=i),new Xe(r,n)}evaluate(){return this.value}eachChild(){}outputDefined(){return !0}}const Ye={string:$t,number:Ot,boolean:Rt,object:jt};class Ze{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let n,r=1;const i=t[0];if("array"===i){let i,s;if(t.length>2){const n=t[1];if("string"!=typeof n||!(n in Ye)||"object"===n)return e.error('The item type argument of "array" must be one of string, number, boolean',1);i=Ye[n],r++;}else i=qt;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return e.error('The length argument to "array" must be a positive integer literal',2);s=t[2],r++;}n=Jt(i,s);}else {if(!Ye[i])throw new Error(`Types doesn't contain name = ${i}`);n=Ye[i];}const s=[];for(;r<t.length;r++){const n=e.parse(t[r],r,qt);if(!n)return null;s.push(n);}return new Ze(n,s)}evaluate(t){for(let e=0;e<this.args.length;e++){const n=this.args[e].evaluate(t);if(!ee(this.type,qe(n)))return n;if(e===this.args.length-1)throw new Le(`Expected value to be of type ${Qt(this.type)}, but found ${Qt(qe(n))} instead.`)}throw new Error}eachChild(t){this.args.forEach(t);}outputDefined(){return this.args.every((t=>t.outputDefined()))}}const He={"to-boolean":Rt,"to-color":Nt,"to-number":Ot,"to-string":$t};class We{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const n=t[0];if(!He[n])throw new Error(`Can't parse ${n} as it is not part of the known types`);if(("to-boolean"===n||"to-string"===n)&&2!==t.length)return e.error("Expected one argument.");const r=He[n],i=[];for(let n=1;n<t.length;n++){const r=e.parse(t[n],n,qt);if(!r)return null;i.push(r);}return new We(r,i)}evaluate(t){switch(this.type.kind){case "boolean":return Boolean(this.args[0].evaluate(t));case "color":{let e,n;for(const r of this.args){if(e=r.evaluate(t),n=null,e instanceof Te)return e;if("string"==typeof e){const n=t.parseColor(e);if(n)return n}else if(Array.isArray(e)&&(n=e.length<3||e.length>4?`Invalid rgba value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:Ue(e[0],e[1],e[2],e[3]),!n))return new Te(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new Le(n||`Could not parse color from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case "padding":{let e;for(const n of this.args){e=n.evaluate(t);const r=Be.parse(e);if(r)return r}throw new Le(`Could not parse padding from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case "numberArray":{let e;for(const n of this.args){e=n.evaluate(t);const r=Ce.parse(e);if(r)return r}throw new Le(`Could not parse numberArray from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case "colorArray":{let e;for(const n of this.args){e=n.evaluate(t);const r=Ve.parse(e);if(r)return r}throw new Le(`Could not parse colorArray from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case "variableAnchorOffsetCollection":{let e;for(const n of this.args){e=n.evaluate(t);const r=$e.parse(e);if(r)return r}throw new Le(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case "number":{let e=null;for(const n of this.args){if(e=n.evaluate(t),null===e)return 0;const r=Number(e);if(!isNaN(r))return r}throw new Le(`Could not convert ${JSON.stringify(e)} to number.`)}case "formatted":return ze.fromString(Ge(this.args[0].evaluate(t)));case "resolvedImage":return Re.fromString(Ge(this.args[0].evaluate(t)));case "projectionDefinition":return this.args[0].evaluate(t);default:return Ge(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t);}outputDefined(){return this.args.every((t=>t.outputDefined()))}}const Ke=["Unknown","Point","LineString","Polygon"];class Je{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=new Map,this.availableImages=null,this.canonical=null;}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Ke[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(t){let e=this._parseColorCache.get(t);return e||(e=Te.parse(t),this._parseColorCache.set(t,e)),e}}class Qe{constructor(t,e,n=[],r,i=new Vt,s=[]){this.registry=t,this.path=n,this.key=n.map((t=>`[${t}]`)).join(""),this.scope=i,this.errors=s,this.expectedType=r,this._isConstant=e;}parse(t,e,n,r,i={}){return e?this.concat(e,n,r)._parse(t,i):this._parse(t,i)}_parse(t,e){function n(t,e,n){return "assert"===n?new Ze(e,[t]):"coerce"===n?new We(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const r=t[0];if("string"!=typeof r)return this.error(`Expression name must be a string, but found ${typeof r} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const i=this.registry[r];if(i){let r=i.parse(t,this);if(!r)return null;if(this.expectedType){const t=this.expectedType,i=r.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==i.kind){if("projectionDefinition"===t.kind&&["string","array"].includes(i.kind)||["color","formatted","resolvedImage"].includes(t.kind)&&["value","string"].includes(i.kind)||["padding","numberArray"].includes(t.kind)&&["value","number","array"].includes(i.kind)||"colorArray"===t.kind&&["value","string","array"].includes(i.kind)||"variableAnchorOffsetCollection"===t.kind&&["value","array"].includes(i.kind))r=n(r,t,e.typeAnnotation||"coerce");else if(this.checkSubtype(t,i))return null}else r=n(r,t,e.typeAnnotation||"assert");}if(!(r instanceof Xe)&&"resolvedImage"!==r.type.kind&&this._isConstant(r)){const t=new Je;try{r=new Xe(r.type,r.evaluate(t));}catch(t){return this.error(t.message),null}}return r}return this.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,n){const r="number"==typeof t?this.path.concat(t):this.path,i=n?this.scope.concat(n):this.scope;return new Qe(this.registry,this._isConstant,r,e||null,i,this.errors)}error(t,...e){const n=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new Ct(n,t));}checkSubtype(t,e){const n=ee(t,e);return n&&this.error(n),n}}class tn{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e;}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result);}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const n=[];for(let r=1;r<t.length-1;r+=2){const i=t[r];if("string"!=typeof i)return e.error(`Expected string, but found ${typeof i} instead.`,r);if(/[^a-zA-Z0-9_]/.test(i))return e.error("Variable names must contain only alphanumeric characters or '_'.",r);const s=e.parse(t[r+1],r+1);if(!s)return null;n.push([i,s]);}const r=e.parse(t[t.length-1],t.length-1,e.expectedType,n);return r?new tn(n,r):null}outputDefined(){return this.result.outputDefined()}}class en{constructor(t,e){this.type=e.type,this.name=t,this.boundExpression=e;}static parse(t,e){if(2!==t.length||"string"!=typeof t[1])return e.error("'var' expression requires exactly one string literal argument.");const n=t[1];return e.scope.has(n)?new en(n,e.scope.get(n)):e.error(`Unknown variable "${n}". Make sure "${n}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return !1}}class nn{constructor(t,e,n){this.type=t,this.index=e,this.input=n;}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const n=e.parse(t[1],1,Ot),r=e.parse(t[2],2,Jt(e.expectedType||qt));return n&&r?new nn(r.type.itemType,n,r):null}evaluate(t){const e=this.index.evaluate(t),n=this.input.evaluate(t);if(e<0)throw new Le(`Array index out of bounds: ${e} < 0.`);if(e>=n.length)throw new Le(`Array index out of bounds: ${e} > ${n.length-1}.`);if(e!==Math.floor(e))throw new Le(`Array index must be an integer, but found ${e} instead.`);return n[e]}eachChild(t){t(this.index),t(this.input);}outputDefined(){return !1}}class rn{constructor(t,e){this.type=Rt,this.needle=t,this.haystack=e;}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const n=e.parse(t[1],1,qt),r=e.parse(t[2],2,qt);return n&&r?ne(n.type,[Rt,$t,Ot,Lt,qt])?new rn(n,r):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Qt(n.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),n=this.haystack.evaluate(t);if(!n)return !1;if(!re(e,["boolean","string","number","null"]))throw new Le(`Expected first argument to be of type boolean, string, number or null, but found ${Qt(qe(e))} instead.`);if(!re(n,["string","array"]))throw new Le(`Expected second argument to be of type array or string, but found ${Qt(qe(n))} instead.`);return n.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack);}outputDefined(){return !0}}class sn{constructor(t,e,n){this.type=Ot,this.needle=t,this.haystack=e,this.fromIndex=n;}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 2 or 3 arguments, but found ${t.length-1} instead.`);const n=e.parse(t[1],1,qt),r=e.parse(t[2],2,qt);if(!n||!r)return null;if(!ne(n.type,[Rt,$t,Ot,Lt,qt]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Qt(n.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,Ot);return i?new sn(n,r,i):null}return new sn(n,r)}evaluate(t){const e=this.needle.evaluate(t),n=this.haystack.evaluate(t);if(!re(e,["boolean","string","number","null"]))throw new Le(`Expected first argument to be of type boolean, string, number or null, but found ${Qt(qe(e))} instead.`);let r;if(this.fromIndex&&(r=this.fromIndex.evaluate(t)),re(n,["string"])){const t=n.indexOf(e,r);return -1===t?-1:[...n.slice(0,t)].length}if(re(n,["array"]))return n.indexOf(e,r);throw new Le(`Expected second argument to be of type array or string, but found ${Qt(qe(n))} instead.`)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex);}outputDefined(){return !1}}class on{constructor(t,e,n,r,i,s){this.inputType=t,this.type=e,this.input=n,this.cases=r,this.outputs=i,this.otherwise=s;}static parse(t,e){if(t.length<5)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return e.error("Expected an even number of arguments.");let n,r;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);const i={},s=[];for(let o=2;o<t.length-1;o+=2){let a=t[o];const l=t[o+1];Array.isArray(a)||(a=[a]);const u=e.concat(o);if(0===a.length)return u.error("Expected at least one branch label.");for(const t of a){if("number"!=typeof t&&"string"!=typeof t)return u.error("Branch labels must be numbers or strings.");if("number"==typeof t&&Math.abs(t)>Number.MAX_SAFE_INTEGER)return u.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return u.error("Numeric branch labels must be integer values.");if(n){if(u.checkSubtype(n,qe(t)))return null}else n=qe(t);if(void 0!==i[String(t)])return u.error("Branch labels must be unique.");i[String(t)]=s.length;}const c=e.parse(l,o,r);if(!c)return null;r=r||c.type,s.push(c);}const o=e.parse(t[1],1,qt);if(!o)return null;const a=e.parse(t[t.length-1],t.length-1,r);return a?"value"!==o.type.kind&&e.concat(1).checkSubtype(n,o.type)?null:new on(n,r,o,i,s,a):null}evaluate(t){const e=this.input.evaluate(t);return (qe(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}}class an{constructor(t,e,n){this.type=t,this.branches=e,this.otherwise=n;}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return e.error("Expected an odd number of arguments.");let n;e.expectedType&&"value"!==e.expectedType.kind&&(n=e.expectedType);const r=[];for(let i=1;i<t.length-1;i+=2){const s=e.parse(t[i],i,Rt);if(!s)return null;const o=e.parse(t[i+1],i+1,n);if(!o)return null;r.push([s,o]),n=n||o.type;}const i=e.parse(t[t.length-1],t.length-1,n);if(!i)return null;if(!n)throw new Error("Can't infer output type");return new an(n,r,i)}evaluate(t){for(const[e,n]of this.branches)if(e.evaluate(t))return n.evaluate(t);return this.otherwise.evaluate(t)}eachChild(t){for(const[e,n]of this.branches)t(e),t(n);t(this.otherwise);}outputDefined(){return this.branches.every((([t,e])=>e.outputDefined()))&&this.otherwise.outputDefined()}}class ln{constructor(t,e,n,r){this.type=t,this.input=e,this.beginIndex=n,this.endIndex=r;}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 2 or 3 arguments, but found ${t.length-1} instead.`);const n=e.parse(t[1],1,qt),r=e.parse(t[2],2,Ot);if(!n||!r)return null;if(!ne(n.type,[Jt(qt),$t,qt]))return e.error(`Expected first argument to be of type array or string, but found ${Qt(n.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,Ot);return i?new ln(n.type,n,r,i):null}return new ln(n.type,n,r)}evaluate(t){const e=this.input.evaluate(t),n=this.beginIndex.evaluate(t);let r;if(this.endIndex&&(r=this.endIndex.evaluate(t)),re(e,["string"]))return [...e].slice(n,r).join("");if(re(e,["array"]))return e.slice(n,r);throw new Le(`Expected first argument to be of type array or string, but found ${Qt(qe(e))} instead.`)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex);}outputDefined(){return !1}}function un(t,e){const n=t.length-1;let r,i,s=0,o=n,a=0;for(;s<=o;)if(a=Math.floor((s+o)/2),r=t[a],i=t[a+1],r<=e){if(a===n||e<i)return a;s=a+1;}else {if(!(r>e))throw new Le("Input is not a number.");o=a-1;}return 0}class cn{constructor(t,e,n){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of n)this.labels.push(t),this.outputs.push(e);}static parse(t,e){if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");const n=e.parse(t[1],1,Ot);if(!n)return null;const r=[];let i=null;e.expectedType&&"value"!==e.expectedType.kind&&(i=e.expectedType);for(let n=1;n<t.length;n+=2){const s=1===n?-1/0:t[n],o=t[n+1],a=n,l=n+1;if("number"!=typeof s)return e.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',a);if(r.length&&r[r.length-1][0]>=s)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const u=e.parse(o,l,i);if(!u)return null;i=i||u.type,r.push([s,u]);}return new cn(i,n,r)}evaluate(t){const e=this.labels,n=this.outputs;if(1===e.length)return n[0].evaluate(t);const r=this.input.evaluate(t);if(r<=e[0])return n[0].evaluate(t);const i=e.length;return r>=e[i-1]?n[i-1].evaluate(t):n[un(e,r)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function hn(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var pn,fn,dn=function(){if(fn)return pn;function t(t,e,n,r){this.cx=3*t,this.bx=3*(n-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(r-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=n,this.p2y=r;}return fn=1,pn=t,t.prototype={sampleCurveX:function(t){return ((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return ((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return (3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var n=t,r=0;r<8;r++){var i=this.sampleCurveX(n)-t;if(Math.abs(i)<e)return n;var s=this.sampleCurveDerivativeX(n);if(Math.abs(s)<1e-6)break;n-=i/s;}var o=0,a=1;for(n=t,r=0;r<20&&(i=this.sampleCurveX(n),!(Math.abs(i-t)<e));r++)t>i?o=n:a=n,n=.5*(a-o)+o;return n},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}},pn}(),yn=hn(dn);class mn{constructor(t,e,n,r,i){this.type=t,this.operator=e,this.interpolation=n,this.input=r,this.labels=[],this.outputs=[];for(const[t,e]of i)this.labels.push(t),this.outputs.push(e);}static interpolationFactor(t,e,n,r){let i=0;if("exponential"===t.name)i=gn(e,t.base,n,r);else if("linear"===t.name)i=gn(e,1,n,r);else if("cubic-bezier"===t.name){const s=t.controlPoints;i=new yn(s[0],s[1],s[2],s[3]).solve(gn(e,1,n,r));}return i}static parse(t,e){let[n,r,i,...s]=t;if(!Array.isArray(r)||0===r.length)return e.error("Expected an interpolation type expression.",1);if("linear"===r[0])r={name:"linear"};else if("exponential"===r[0]){const t=r[1];if("number"!=typeof t)return e.error("Exponential interpolation requires a numeric base.",1,1);r={name:"exponential",base:t};}else {if("cubic-bezier"!==r[0])return e.error(`Unknown interpolation type ${String(r[0])}`,1,0);{const t=r.slice(1);if(4!==t.length||t.some((t=>"number"!=typeof t||t<0||t>1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);r={name:"cubic-bezier",controlPoints:t};}}if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(i=e.parse(i,2,Ot),!i)return null;const o=[];let a=null;"interpolate-hcl"!==n&&"interpolate-lab"!==n||e.expectedType==Zt?e.expectedType&&"value"!==e.expectedType.kind&&(a=e.expectedType):a=Nt;for(let t=0;t<s.length;t+=2){const n=s[t],r=s[t+1],i=t+3,l=t+4;if("number"!=typeof n)return e.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',i);if(o.length&&o[o.length-1][0]>=n)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',i);const u=e.parse(r,l,a);if(!u)return null;a=a||u.type,o.push([n,u]);}return ie(a,Ot)||ie(a,Ut)||ie(a,Nt)||ie(a,Yt)||ie(a,Ht)||ie(a,Zt)||ie(a,Kt)||ie(a,Jt(Ot))?new mn(a,n,r,i,o):e.error(`Type ${Qt(a)} is not interpolatable.`)}evaluate(t){const e=this.labels,n=this.outputs;if(1===e.length)return n[0].evaluate(t);const r=this.input.evaluate(t);if(r<=e[0])return n[0].evaluate(t);const i=e.length;if(r>=e[i-1])return n[i-1].evaluate(t);const s=un(e,r),o=mn.interpolationFactor(this.interpolation,r,e[s],e[s+1]),a=n[s].evaluate(t),l=n[s+1].evaluate(t);switch(this.operator){case "interpolate":switch(this.type.kind){case "number":return Ie(a,l,o);case "color":return Te.interpolate(a,l,o);case "padding":return Be.interpolate(a,l,o);case "colorArray":return Ve.interpolate(a,l,o);case "numberArray":return Ce.interpolate(a,l,o);case "variableAnchorOffsetCollection":return $e.interpolate(a,l,o);case "array":return Ee(a,l,o);case "projectionDefinition":return Ne.interpolate(a,l,o)}case "interpolate-hcl":switch(this.type.kind){case "color":return Te.interpolate(a,l,o,"hcl");case "colorArray":return Ve.interpolate(a,l,o,"hcl")}case "interpolate-lab":switch(this.type.kind){case "color":return Te.interpolate(a,l,o,"lab");case "colorArray":return Ve.interpolate(a,l,o,"lab")}}}eachChild(t){t(this.input);for(const e of this.outputs)t(e);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function gn(t,e,n,r){const i=r-n,s=t-n;return 0===i?0:1===e?s/i:(Math.pow(e,s)-1)/(Math.pow(e,i)-1)}const xn={color:Te.interpolate,number:Ie,padding:Be.interpolate,numberArray:Ce.interpolate,colorArray:Ve.interpolate,variableAnchorOffsetCollection:$e.interpolate,array:Ee};class vn{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let n=null;const r=e.expectedType;r&&"value"!==r.kind&&(n=r);const i=[];for(const r of t.slice(1)){const t=e.parse(r,1+i.length,n,void 0,{typeAnnotation:"omit"});if(!t)return null;n=n||t.type,i.push(t);}if(!n)throw new Error("No output type");const s=r&&i.some((t=>ee(r,t.type)));return new vn(s?qt:n,i)}evaluate(t){let e,n=null,r=0;for(const i of this.args)if(r++,n=i.evaluate(t),n&&n instanceof Re&&!n.available&&(e||(e=n.name),n=null,r===this.args.length&&(n=e)),null!==n)break;return n}eachChild(t){this.args.forEach(t);}outputDefined(){return this.args.every((t=>t.outputDefined()))}}function bn(t,e){return "=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function wn(t,e,n,r){return 0===r.compare(e,n)}function _n(t,e,n){const r="=="!==t&&"!="!==t;return class i{constructor(t,e,n){this.type=Rt,this.lhs=t,this.rhs=e,this.collator=n,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind;}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const n=t[0];let s=e.parse(t[1],1,qt);if(!s)return null;if(!bn(n,s.type))return e.concat(1).error(`"${n}" comparisons are not supported for type '${Qt(s.type)}'.`);let o=e.parse(t[2],2,qt);if(!o)return null;if(!bn(n,o.type))return e.concat(2).error(`"${n}" comparisons are not supported for type '${Qt(o.type)}'.`);if(s.type.kind!==o.type.kind&&"value"!==s.type.kind&&"value"!==o.type.kind)return e.error(`Cannot compare types '${Qt(s.type)}' and '${Qt(o.type)}'.`);r&&("value"===s.type.kind&&"value"!==o.type.kind?s=new Ze(o.type,[s]):"value"!==s.type.kind&&"value"===o.type.kind&&(o=new Ze(s.type,[o])));let a=null;if(4===t.length){if("string"!==s.type.kind&&"string"!==o.type.kind&&"value"!==s.type.kind&&"value"!==o.type.kind)return e.error("Cannot use collator to compare non-string types.");if(a=e.parse(t[3],3,Gt),!a)return null}return new i(s,o,a)}evaluate(i){const s=this.lhs.evaluate(i),o=this.rhs.evaluate(i);if(r&&this.hasUntypedArgument){const e=qe(s),n=qe(o);if(e.kind!==n.kind||"string"!==e.kind&&"number"!==e.kind)throw new Le(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${n.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){const t=qe(s),n=qe(o);if("string"!==t.kind||"string"!==n.kind)return e(i,s,o)}return this.collator?n(i,s,o,this.collator.evaluate(i)):e(i,s,o)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator);}outputDefined(){return !0}}}const Sn=_n("==",(function(t,e,n){return e===n}),wn),An=_n("!=",(function(t,e,n){return e!==n}),(function(t,e,n,r){return !wn(0,e,n,r)})),Mn=_n("<",(function(t,e,n){return e<n}),(function(t,e,n,r){return r.compare(e,n)<0})),kn=_n(">",(function(t,e,n){return e>n}),(function(t,e,n,r){return r.compare(e,n)>0})),In=_n("<=",(function(t,e,n){return e<=n}),(function(t,e,n,r){return r.compare(e,n)<=0})),En=_n(">=",(function(t,e,n){return e>=n}),(function(t,e,n,r){return r.compare(e,n)>=0}));class Tn{constructor(t,e,n){this.type=Gt,this.locale=n,this.caseSensitive=t,this.diacriticSensitive=e;}static parse(t,e){if(2!==t.length)return e.error("Expected one argument.");const n=t[1];if("object"!=typeof n||Array.isArray(n))return e.error("Collator options argument must be an object.");const r=e.parse(void 0!==n["case-sensitive"]&&n["case-sensitive"],1,Rt);if(!r)return null;const i=e.parse(void 0!==n["diacritic-sensitive"]&&n["diacritic-sensitive"],1,Rt);if(!i)return null;let s=null;return n.locale&&(s=e.parse(n.locale,1,$t),!s)?null:new Tn(r,i,s)}evaluate(t){return new Fe(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale);}outputDefined(){return !1}}class Fn{constructor(t,e,n,r,i,s){this.type=$t,this.number=t,this.locale=e,this.currency=n,this.unit=r,this.minFractionDigits=i,this.maxFractionDigits=s;}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const n=e.parse(t[1],1,Ot);if(!n)return null;const r=t[2];if("object"!=typeof r||Array.isArray(r))return e.error("NumberFormat options argument must be an object.");let i=null;if(r.locale&&(i=e.parse(r.locale,1,$t),!i))return null;let s=null;if(r.currency&&(s=e.parse(r.currency,1,$t),!s))return null;let o=null;if(r.unit&&(o=e.parse(r.unit,1,$t),!o))return null;if(s&&o)return e.error("NumberFormat options `currency` and `unit` are mutually exclusive");let a=null;if(r["min-fraction-digits"]&&(a=e.parse(r["min-fraction-digits"],1,Ot),!a))return null;let l=null;return r["max-fraction-digits"]&&(l=e.parse(r["max-fraction-digits"],1,Ot),!l)?null:new Fn(n,i,s,o,a,l)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":this.unit?"unit":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,unit:this.unit?this.unit.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.unit&&t(this.unit),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits);}outputDefined(){return !1}}class Pn{constructor(t){this.type=Xt,this.sections=t;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const n=t[1];if(!Array.isArray(n)&&"object"==typeof n)return e.error("First argument must be an image or text section.");const r=[];let i=!1;for(let n=1;n<=t.length-1;++n){const s=t[n];if(i&&"object"==typeof s&&!Array.isArray(s)){i=!1;let t=null;if(s["font-scale"]&&(t=e.parse(s["font-scale"],1,Ot),!t))return null;let n=null;if(s["text-font"]&&(n=e.parse(s["text-font"],1,Jt($t)),!n))return null;let o=null;if(s["text-color"]&&(o=e.parse(s["text-color"],1,Nt),!o))return null;let a=null;if(s["vertical-align"]){if("string"==typeof s["vertical-align"]&&!Pe.includes(s["vertical-align"]))return e.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${s["vertical-align"]}' instead.`);if(a=e.parse(s["vertical-align"],1,$t),!a)return null}const l=r[r.length-1];l.scale=t,l.font=n,l.textColor=o,l.verticalAlign=a;}else {const s=e.parse(t[n],1,qt);if(!s)return null;const o=s.type.kind;if("string"!==o&&"value"!==o&&"null"!==o&&"resolvedImage"!==o)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");i=!0,r.push({content:s,scale:null,font:null,textColor:null,verticalAlign:null});}}return new Pn(r)}evaluate(t){return new ze(this.sections.map((e=>{const n=e.content.evaluate(t);return qe(n)===Wt?new De("",n,null,null,null,e.verticalAlign?e.verticalAlign.evaluate(t):null):new De(Ge(n),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null,e.verticalAlign?e.verticalAlign.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor),e.verticalAlign&&t(e.verticalAlign);}outputDefined(){return !1}}class Dn{constructor(t){this.type=Wt,this.input=t;}static parse(t,e){if(2!==t.length)return e.error("Expected two arguments.");const n=e.parse(t[1],1,$t);return n?new Dn(n):e.error("No image name provided.")}evaluate(t){const e=this.input.evaluate(t),n=Re.fromString(e);return n&&t.availableImages&&(n.available=t.availableImages.indexOf(e)>-1),n}eachChild(t){t(this.input);}outputDefined(){return !1}}class zn{constructor(t){this.type=Ot,this.input=t;}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const n=e.parse(t[1],1);return n?"array"!==n.type.kind&&"string"!==n.type.kind&&"value"!==n.type.kind?e.error(`Expected argument of type string or array, but found ${Qt(n.type)} instead.`):new zn(n):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return [...e].length;if(Array.isArray(e))return e.length;throw new Le(`Expected value to be of type string or array, but found ${Qt(qe(e))} instead.`)}eachChild(t){t(this.input);}outputDefined(){return !1}}const Bn=8192;function Cn(t,e){const n=(180+t[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,i=Math.pow(2,e.z);return [Math.round(n*i*Bn),Math.round(r*i*Bn)]}function Vn(t,e){const n=Math.pow(2,e.z);return [(i=(t[0]/Bn+e.x)/n,360*i-180),(r=(t[1]/Bn+e.y)/n,360/Math.PI*Math.atan(Math.exp((180-360*r)*Math.PI/180))-90)];var r,i;}function Ln(t,e){t[0]=Math.min(t[0],e[0]),t[1]=Math.min(t[1],e[1]),t[2]=Math.max(t[2],e[0]),t[3]=Math.max(t[3],e[1]);}function On(t,e){return !(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function $n(t,e,n){const r=t[0]-e[0],i=t[1]-e[1],s=t[0]-n[0],o=t[1]-n[1];return r*o-s*i==0&&r*s<=0&&i*o<=0}function Rn(t,e,n,r){return 0!=(i=[r[0]-n[0],r[1]-n[1]])[0]*(s=[e[0]-t[0],e[1]-t[1]])[1]-i[1]*s[0]&&!(!Xn(t,e,n,r)||!Xn(n,r,t,e));var i,s;}function Nn(t,e,n){for(const r of n)for(let n=0;n<r.length-1;++n)if(Rn(t,e,r[n],r[n+1]))return !0;return !1}function Un(t,e,n=!1){let r=!1;for(const a of e)for(let e=0;e<a.length-1;e++){if($n(t,a[e],a[e+1]))return n;(s=a[e])[1]>(i=t)[1]!=(o=a[e+1])[1]>i[1]&&i[0]<(o[0]-s[0])*(i[1]-s[1])/(o[1]-s[1])+s[0]&&(r=!r);}var i,s,o;return r}function jn(t,e){for(const n of e)if(Un(t,n))return !0;return !1}function qn(t,e){for(const n of t)if(!Un(n,e))return !1;for(let n=0;n<t.length-1;++n)if(Nn(t[n],t[n+1],e))return !1;return !0}function Gn(t,e){for(const n of e)if(qn(t,n))return !0;return !1}function Xn(t,e,n,r){const i=r[0]-n[0],s=r[1]-n[1],o=(t[0]-n[0])*s-i*(t[1]-n[1]),a=(e[0]-n[0])*s-i*(e[1]-n[1]);return o>0&&a<0||o<0&&a>0}function Yn(t,e,n){const r=[];for(let i=0;i<t.length;i++){const s=[];for(let r=0;r<t[i].length;r++){const o=Cn(t[i][r],n);Ln(e,o),s.push(o);}r.push(s);}return r}function Zn(t,e,n){const r=[];for(let i=0;i<t.length;i++){const s=Yn(t[i],e,n);r.push(s);}return r}function Hn(t,e,n,r){if(t[0]<n[0]||t[0]>n[2]){const e=.5*r;let i=t[0]-n[0]>e?-r:n[0]-t[0]>e?r:0;0===i&&(i=t[0]-n[2]>e?-r:n[2]-t[0]>e?r:0),t[0]+=i;}Ln(e,t);}function Wn(t,e,n,r){const i=Math.pow(2,r.z)*Bn,s=[r.x*Bn,r.y*Bn],o=[];for(const r of t)for(const t of r){const r=[t.x+s[0],t.y+s[1]];Hn(r,e,n,i),o.push(r);}return o}function Kn(t,e,n,r){const i=Math.pow(2,r.z)*Bn,s=[r.x*Bn,r.y*Bn],o=[];for(const n of t){const t=[];for(const r of n){const n=[r.x+s[0],r.y+s[1]];Ln(e,n),t.push(n);}o.push(t);}if(e[2]-e[0]<=i/2){(a=e)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const t of o)for(const r of t)Hn(r,e,n,i);}var a;return o}class Jn{constructor(t,e){this.type=Rt,this.geojson=t,this.geometries=e;}static parse(t,e){if(2!==t.length)return e.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(je(t[1])){const e=t[1];if("FeatureCollection"===e.type){const t=[];for(const n of e.features){const{type:e,coordinates:r}=n.geometry;"Polygon"===e&&t.push(r),"MultiPolygon"===e&&t.push(...r);}if(t.length)return new Jn(e,{type:"MultiPolygon",coordinates:t})}else if("Feature"===e.type){const t=e.geometry.type;if("Polygon"===t||"MultiPolygon"===t)return new Jn(e,e.geometry)}else if("Polygon"===e.type||"MultiPolygon"===e.type)return new Jn(e,e)}return e.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const n=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],i=t.canonicalID();if("Polygon"===e.type){const s=Yn(e.coordinates,r,i),o=Wn(t.geometry(),n,r,i);if(!On(n,r))return !1;for(const t of o)if(!Un(t,s))return !1}if("MultiPolygon"===e.type){const s=Zn(e.coordinates,r,i),o=Wn(t.geometry(),n,r,i);if(!On(n,r))return !1;for(const t of o)if(!jn(t,s))return !1}return !0}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const n=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],i=t.canonicalID();if("Polygon"===e.type){const s=Yn(e.coordinates,r,i),o=Kn(t.geometry(),n,r,i);if(!On(n,r))return !1;for(const t of o)if(!qn(t,s))return !1}if("MultiPolygon"===e.type){const s=Zn(e.coordinates,r,i),o=Kn(t.geometry(),n,r,i);if(!On(n,r))return !1;for(const t of o)if(!Gn(t,s))return !1}return !0}(t,this.geometries)}return !1}eachChild(){}outputDefined(){return !0}}let Qn=class{constructor(t=[],e=(t,e)=>t<e?-1:t>e?1:0){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t);}push(t){this.data.push(t),this._up(this.length++);}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return --this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:n}=this,r=e[t];for(;t>0;){const i=t-1>>1,s=e[i];if(n(r,s)>=0)break;e[t]=s,t=i;}e[t]=r;}_down(t){const{data:e,compare:n}=this,r=this.length>>1,i=e[t];for(;t<r;){let r=1+(t<<1);const s=r+1;if(s<this.length&&n(e[s],e[r])<0&&(r=s),n(e[r],i)>=0)break;e[t]=e[r],t=r;}e[t]=i;}};function tr(t,e,n=0,r=t.length-1,i=nr){for(;r>n;){if(r-n>600){const s=r-n+1,o=e-n+1,a=Math.log(s),l=.5*Math.exp(2*a/3),u=.5*Math.sqrt(a*l*(s-l)/s)*(o-s/2<0?-1:1);tr(t,e,Math.max(n,Math.floor(e-o*l/s+u)),Math.min(r,Math.floor(e+(s-o)*l/s+u)),i);}const s=t[e];let o=n,a=r;for(er(t,n,e),i(t[r],s)>0&&er(t,n,r);o<a;){for(er(t,o,a),o++,a--;i(t[o],s)<0;)o++;for(;i(t[a],s)>0;)a--;}0===i(t[n],s)?er(t,n,a):(a++,er(t,a,r)),a<=e&&(n=a+1),e<=a&&(r=a-1);}}function er(t,e,n){const r=t[e];t[e]=t[n],t[n]=r;}function nr(t,e){return t<e?-1:t>e?1:0}function rr(t,e){if(t.length<=1)return [t];const n=[];let r,i;for(const e of t){const t=sr(e);0!==t&&(e.area=Math.abs(t),void 0===i&&(i=t<0),i===t<0?(r&&n.push(r),r=[e]):r.push(e));}if(r&&n.push(r),e>1)for(let t=0;t<n.length;t++)n[t].length<=e||(tr(n[t],e,1,n[t].length-1,ir),n[t]=n[t].slice(0,e));return n}function ir(t,e){return e.area-t.area}function sr(t){let e=0;for(let n,r,i=0,s=t.length,o=s-1;i<s;o=i++)n=t[i],r=t[o],e+=(r.x-n.x)*(n.y+r.y);return e}const or=1/298.257223563,ar=or*(2-or),lr=Math.PI/180;class ur{constructor(t){const e=6378.137*lr*1e3,n=Math.cos(t*lr),r=1/(1-ar*(1-n*n)),i=Math.sqrt(r);this.kx=e*i*n,this.ky=e*i*r*(1-ar);}distance(t,e){const n=this.wrap(t[0]-e[0])*this.kx,r=(t[1]-e[1])*this.ky;return Math.sqrt(n*n+r*r)}pointOnLine(t,e){let n,r,i,s,o=1/0;for(let a=0;a<t.length-1;a++){let l=t[a][0],u=t[a][1],c=this.wrap(t[a+1][0]-l)*this.kx,h=(t[a+1][1]-u)*this.ky,p=0;0===c&&0===h||(p=(this.wrap(e[0]-l)*this.kx*c+(e[1]-u)*this.ky*h)/(c*c+h*h),p>1?(l=t[a+1][0],u=t[a+1][1]):p>0&&(l+=c/this.kx*p,u+=h/this.ky*p)),c=this.wrap(e[0]-l)*this.kx,h=(e[1]-u)*this.ky;const f=c*c+h*h;f<o&&(o=f,n=l,r=u,i=a,s=p);}return {point:[n,r],index:i,t:Math.max(0,Math.min(1,s))}}wrap(t){for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}}function cr(t,e){return e[0]-t[0]}function hr(t){return t[1]-t[0]+1}function pr(t,e){return t[1]>=t[0]&&t[1]<e}function fr(t,e){if(t[0]>t[1])return [null,null];const n=hr(t);if(e){if(2===n)return [t,null];const e=Math.floor(n/2);return [[t[0],t[0]+e],[t[0]+e,t[1]]]}if(1===n)return [t,null];const r=Math.floor(n/2)-1;return [[t[0],t[0]+r],[t[0]+r+1,t[1]]]}function dr(t,e){if(!pr(e,t.length))return [1/0,1/0,-1/0,-1/0];const n=[1/0,1/0,-1/0,-1/0];for(let r=e[0];r<=e[1];++r)Ln(n,t[r]);return n}function yr(t){const e=[1/0,1/0,-1/0,-1/0];for(const n of t)for(const t of n)Ln(e,t);return e}function mr(t){return t[0]!==-1/0&&t[1]!==-1/0&&t[2]!==1/0&&t[3]!==1/0}function gr(t,e,n){if(!mr(t)||!mr(e))return NaN;let r=0,i=0;return t[2]<e[0]&&(r=e[0]-t[2]),t[0]>e[2]&&(r=t[0]-e[2]),t[1]>e[3]&&(i=t[1]-e[3]),t[3]<e[1]&&(i=e[1]-t[3]),n.distance([0,0],[r,i])}function xr(t,e,n){const r=n.pointOnLine(e,t);return n.distance(t,r.point)}function vr(t,e,n,r,i){const s=Math.min(xr(t,[n,r],i),xr(e,[n,r],i)),o=Math.min(xr(n,[t,e],i),xr(r,[t,e],i));return Math.min(s,o)}function br(t,e,n,r,i){if(!pr(e,t.length)||!pr(r,n.length))return 1/0;let s=1/0;for(let o=e[0];o<e[1];++o){const e=t[o],a=t[o+1];for(let t=r[0];t<r[1];++t){const r=n[t],o=n[t+1];if(Rn(e,a,r,o))return 0;s=Math.min(s,vr(e,a,r,o,i));}}return s}function wr(t,e,n,r,i){if(!pr(e,t.length)||!pr(r,n.length))return NaN;let s=1/0;for(let o=e[0];o<=e[1];++o)for(let e=r[0];e<=r[1];++e)if(s=Math.min(s,i.distance(t[o],n[e])),0===s)return s;return s}function _r(t,e,n){if(Un(t,e,!0))return 0;let r=1/0;for(const i of e){const e=i[0],s=i[i.length-1];if(e!==s&&(r=Math.min(r,xr(t,[s,e],n)),0===r))return r;const o=n.pointOnLine(i,t);if(r=Math.min(r,n.distance(t,o.point)),0===r)return r}return r}function Sr(t,e,n,r){if(!pr(e,t.length))return NaN;for(let r=e[0];r<=e[1];++r)if(Un(t[r],n,!0))return 0;let i=1/0;for(let s=e[0];s<e[1];++s){const e=t[s],o=t[s+1];for(const t of n)for(let n=0,s=t.length,a=s-1;n<s;a=n++){const s=t[a],l=t[n];if(Rn(e,o,s,l))return 0;i=Math.min(i,vr(e,o,s,l,r));}}return i}function Ar(t,e){for(const n of t)for(const t of n)if(Un(t,e,!0))return !0;return !1}function Mr(t,e,n,r=1/0){const i=yr(t),s=yr(e);if(r!==1/0&&gr(i,s,n)>=r)return r;if(On(i,s)){if(Ar(t,e))return 0}else if(Ar(e,t))return 0;let o=1/0;for(const r of t)for(let t=0,i=r.length,s=i-1;t<i;s=t++){const i=r[s],a=r[t];for(const t of e)for(let e=0,r=t.length,s=r-1;e<r;s=e++){const r=t[s],l=t[e];if(Rn(i,a,r,l))return 0;o=Math.min(o,vr(i,a,r,l,n));}}return o}function kr(t,e,n,r,i,s){if(!s)return;const o=gr(dr(r,s),i,n);o<e&&t.push([o,s,[0,0]]);}function Ir(t,e,n,r,i,s,o){if(!s||!o)return;const a=gr(dr(r,s),dr(i,o),n);a<e&&t.push([a,s,o]);}function Er(t,e,n,r,i=1/0){let s=Math.min(r.distance(t[0],n[0][0]),i);if(0===s)return s;const o=new Qn([[0,[0,t.length-1],[0,0]]],cr),a=yr(n);for(;o.length>0;){const i=o.pop();if(i[0]>=s)continue;const l=i[1],u=e?50:100;if(hr(l)<=u){if(!pr(l,t.length))return NaN;if(e){const e=Sr(t,l,n,r);if(isNaN(e)||0===e)return e;s=Math.min(s,e);}else for(let e=l[0];e<=l[1];++e){const i=_r(t[e],n,r);if(s=Math.min(s,i),0===s)return 0}}else {const n=fr(l,e);kr(o,s,r,t,a,n[0]),kr(o,s,r,t,a,n[1]);}}return s}function Tr(t,e,n,r,i,s=1/0){let o=Math.min(s,i.distance(t[0],n[0]));if(0===o)return o;const a=new Qn([[0,[0,t.length-1],[0,n.length-1]]],cr);for(;a.length>0;){const s=a.pop();if(s[0]>=o)continue;const l=s[1],u=s[2],c=e?50:100,h=r?50:100;if(hr(l)<=c&&hr(u)<=h){if(!pr(l,t.length)&&pr(u,n.length))return NaN;let s;if(e&&r)s=br(t,l,n,u,i),o=Math.min(o,s);else if(e&&!r){const e=t.slice(l[0],l[1]+1);for(let t=u[0];t<=u[1];++t)if(s=xr(n[t],e,i),o=Math.min(o,s),0===o)return o}else if(!e&&r){const e=n.slice(u[0],u[1]+1);for(let n=l[0];n<=l[1];++n)if(s=xr(t[n],e,i),o=Math.min(o,s),0===o)return o}else s=wr(t,l,n,u,i),o=Math.min(o,s);}else {const s=fr(l,e),c=fr(u,r);Ir(a,o,i,t,n,s[0],c[0]),Ir(a,o,i,t,n,s[0],c[1]),Ir(a,o,i,t,n,s[1],c[0]),Ir(a,o,i,t,n,s[1],c[1]);}}return o}function Fr(t){return "MultiPolygon"===t.type?t.coordinates.map((t=>({type:"Polygon",coordinates:t}))):"MultiLineString"===t.type?t.coordinates.map((t=>({type:"LineString",coordinates:t}))):"MultiPoint"===t.type?t.coordinates.map((t=>({type:"Point",coordinates:t}))):[t]}class Pr{constructor(t,e){this.type=Ot,this.geojson=t,this.geometries=e;}static parse(t,e){if(2!==t.length)return e.error(`'distance' expression requires exactly one argument, but found ${t.length-1} instead.`);if(je(t[1])){const e=t[1];if("FeatureCollection"===e.type)return new Pr(e,e.features.map((t=>Fr(t.geometry))).flat());if("Feature"===e.type)return new Pr(e,Fr(e.geometry));if("type"in e&&"coordinates"in e)return new Pr(e,Fr(e))}return e.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const n=t.geometry(),r=n.flat().map((e=>Vn([e.x,e.y],t.canonical)));if(0===n.length)return NaN;const i=new ur(r[0][1]);let s=1/0;for(const t of e){switch(t.type){case "Point":s=Math.min(s,Tr(r,!1,[t.coordinates],!1,i,s));break;case "LineString":s=Math.min(s,Tr(r,!1,t.coordinates,!0,i,s));break;case "Polygon":s=Math.min(s,Er(r,!1,t.coordinates,i,s));}if(0===s)return s}return s}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const n=t.geometry(),r=n.flat().map((e=>Vn([e.x,e.y],t.canonical)));if(0===n.length)return NaN;const i=new ur(r[0][1]);let s=1/0;for(const t of e){switch(t.type){case "Point":s=Math.min(s,Tr(r,!0,[t.coordinates],!1,i,s));break;case "LineString":s=Math.min(s,Tr(r,!0,t.coordinates,!0,i,s));break;case "Polygon":s=Math.min(s,Er(r,!0,t.coordinates,i,s));}if(0===s)return s}return s}(t,this.geometries);if("Polygon"===t.geometryType())return function(t,e){const n=t.geometry();if(0===n.length||0===n[0].length)return NaN;const r=rr(n,0).map((e=>e.map((e=>e.map((e=>Vn([e.x,e.y],t.canonical))))))),i=new ur(r[0][0][0][1]);let s=1/0;for(const t of e)for(const e of r){switch(t.type){case "Point":s=Math.min(s,Er([t.coordinates],!1,e,i,s));break;case "LineString":s=Math.min(s,Er(t.coordinates,!0,e,i,s));break;case "Polygon":s=Math.min(s,Mr(e,t.coordinates,i,s));}if(0===s)return s}return s}(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return !0}}class Dr{constructor(t){this.type=qt,this.key=t;}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const n=t[1];return null==n?e.error("Global state property must be defined."):"string"!=typeof n?e.error(`Global state property must be string, but found ${typeof t[1]} instead.`):new Dr(n)}evaluate(t){var e;const n=null===(e=t.globals)||void 0===e?void 0:e.globalState;return n&&0!==Object.keys(n).length?we(n,this.key):null}eachChild(){}outputDefined(){return !1}}const zr={"==":Sn,"!=":An,">":kn,"<":Mn,">=":En,"<=":In,array:Ze,at:nn,boolean:Ze,case:an,coalesce:vn,collator:Tn,format:Pn,image:Dn,in:rn,"index-of":sn,interpolate:mn,"interpolate-hcl":mn,"interpolate-lab":mn,length:zn,let:tn,literal:Xe,match:on,number:Ze,"number-format":Fn,object:Ze,slice:ln,step:cn,string:Ze,"to-boolean":We,"to-color":We,"to-number":We,"to-string":We,var:en,within:Jn,distance:Pr,"global-state":Dr};class Br{constructor(t,e,n,r){this.name=t,this.type=e,this._evaluate=n,this.args=r;}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t);}outputDefined(){return !1}static parse(t,e){const n=t[0],r=Br.definitions[n];if(!r)return e.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0);const i=Array.isArray(r)?r[0]:r.type,s=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,o=s.filter((([e])=>!Array.isArray(e)||e.length===t.length-1));let a=null;for(const[r,s]of o){a=new Qe(e.registry,$r,e.path,null,e.scope);const o=[];let l=!1;for(let e=1;e<t.length;e++){const n=t[e],i=Array.isArray(r)?r[e-1]:r.type,s=a.parse(n,1+o.length,i);if(!s){l=!0;break}o.push(s);}if(!l)if(Array.isArray(r)&&r.length!==o.length)a.error(`Expected ${r.length} arguments, but found ${o.length} instead.`);else {for(let t=0;t<o.length;t++){const e=Array.isArray(r)?r[t]:r.type,n=o[t];a.concat(t+1).checkSubtype(e,n.type);}if(0===a.errors.length)return new Br(n,i,s,o)}}if(1===o.length)e.errors.push(...a.errors);else {const n=(o.length?o:s).map((([t])=>{return e=t,Array.isArray(e)?`(${e.map(Qt).join(", ")})`:`(${Qt(e.type)}...)`;var e;})).join(" | "),r=[];for(let n=1;n<t.length;n++){const i=e.parse(t[n],1+r.length);if(!i)return null;r.push(Qt(i.type));}e.error(`Expected arguments of type ${n}, but found (${r.join(", ")}) instead.`);}return null}static register(t,e){Br.definitions=e;for(const n in e)t[n]=Br;}}function Cr(t,[e,n,r,i]){e=e.evaluate(t),n=n.evaluate(t),r=r.evaluate(t);const s=i?i.evaluate(t):1,o=Ue(e,n,r,s);if(o)throw new Le(o);return new Te(e/255,n/255,r/255,s,!1)}function Vr(t,e){return t in e}function Lr(t,e){const n=e[t];return void 0===n?null:n}function Or(t){return {type:t}}function $r(t){if(t instanceof en)return $r(t.boundExpression);if(t instanceof Br&&"error"===t.name)return !1;if(t instanceof Tn)return !1;if(t instanceof Jn)return !1;if(t instanceof Pr)return !1;if(t instanceof Dr)return !1;const e=t instanceof We||t instanceof Ze;let n=!0;return t.eachChild((t=>{n=e?n&&$r(t):n&&t instanceof Xe;})),!!n&&Rr(t)&&Ur(t,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function Rr(t){if(t instanceof Br){if("get"===t.name&&1===t.args.length)return !1;if("feature-state"===t.name)return !1;if("has"===t.name&&1===t.args.length)return !1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return !1;if(/^filter-/.test(t.name))return !1}if(t instanceof Jn)return !1;if(t instanceof Pr)return !1;let e=!0;return t.eachChild((t=>{e&&!Rr(t)&&(e=!1);})),e}function Nr(t){if(t instanceof Br&&"feature-state"===t.name)return !1;let e=!0;return t.eachChild((t=>{e&&!Nr(t)&&(e=!1);})),e}function Ur(t,e){if(t instanceof Br&&e.indexOf(t.name)>=0)return !1;let n=!0;return t.eachChild((t=>{n&&!Ur(t,e)&&(n=!1);})),n}function jr(t){return {result:"success",value:t}}function qr(t){return {result:"error",value:t}}function Gr(t){return "data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function Xr(t){return !!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function Yr(t){return !!t.expression&&t.expression.interpolated}function Zr(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function Hr(t){return "object"==typeof t&&null!==t&&!Array.isArray(t)&&qe(t)===jt}function Wr(t){return t}function Kr(t,e){const n=t.stops&&"object"==typeof t.stops[0][0],r=n||!(n||void 0!==t.property),i=t.type||(Yr(e)?"exponential":"interval"),s=function(t){switch(t.type){case "color":return Te.parse;case "padding":return Be.parse;case "numberArray":return Ce.parse;case "colorArray":return Ve.parse;default:return null}}(e);if(s&&((t=Bt({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],s(t[1])]))),t.default=s(t.default?t.default:e.default)),t.colorSpace&&"rgb"!==(o=t.colorSpace)&&"hcl"!==o&&"lab"!==o)throw new Error(`Unknown color space: "${t.colorSpace}"`);var o;const a=function(t){switch(t){case "exponential":return ei;case "interval":return ti;case "categorical":return Qr;case "identity":return ni;default:throw new Error(`Unknown function type "${t}"`)}}(i);let l,u;if("categorical"===i){l=Object.create(null);for(const e of t.stops)l[e[0]]=e[1];u=typeof t.stops[0][0];}if(n){const n={},r=[];for(let e=0;e<t.stops.length;e++){const i=t.stops[e],s=i[0].zoom;void 0===n[s]&&(n[s]={zoom:s,type:t.type,property:t.property,default:t.default,stops:[]},r.push(s)),n[s].stops.push([i[0].value,i[1]]);}const i=[];for(const t of r)i.push([n[t].zoom,Kr(n[t],e)]);const s={name:"linear"};return {kind:"composite",interpolationType:s,interpolationFactor:mn.interpolationFactor.bind(void 0,s),zoomStops:i.map((t=>t[0])),evaluate:({zoom:n},r)=>ei({stops:i,base:t.base},e,n).evaluate(n,r)}}if(r){const n="exponential"===i?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return {kind:"camera",interpolationType:n,interpolationFactor:mn.interpolationFactor.bind(void 0,n),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:n})=>a(t,e,n,l,u)}}return {kind:"source",evaluate(n,r){const i=r&&r.properties?r.properties[t.property]:void 0;return void 0===i?Jr(t.default,e.default):a(t,e,i,l,u)}}}function Jr(t,e,n){return void 0!==t?t:void 0!==e?e:void 0!==n?n:void 0}function Qr(t,e,n,r,i){return Jr(typeof n===i?r[n]:void 0,t.default,e.default)}function ti(t,e,n){if("number"!==Zr(n))return Jr(t.default,e.default);const r=t.stops.length;if(1===r)return t.stops[0][1];if(n<=t.stops[0][0])return t.stops[0][1];if(n>=t.stops[r-1][0])return t.stops[r-1][1];const i=un(t.stops.map((t=>t[0])),n);return t.stops[i][1]}function ei(t,e,n){const r=void 0!==t.base?t.base:1;if("number"!==Zr(n))return Jr(t.default,e.default);const i=t.stops.length;if(1===i)return t.stops[0][1];if(n<=t.stops[0][0])return t.stops[0][1];if(n>=t.stops[i-1][0])return t.stops[i-1][1];const s=un(t.stops.map((t=>t[0])),n),o=function(t,e,n,r){const i=r-n,s=t-n;return 0===i?0:1===e?s/i:(Math.pow(e,s)-1)/(Math.pow(e,i)-1)}(n,r,t.stops[s][0],t.stops[s+1][0]),a=t.stops[s][1],l=t.stops[s+1][1],u=xn[e.type]||Wr;return "function"==typeof a.evaluate?{evaluate(...e){const n=a.evaluate.apply(void 0,e),r=l.evaluate.apply(void 0,e);if(void 0!==n&&void 0!==r)return u(n,r,o,t.colorSpace)}}:u(a,l,o,t.colorSpace)}function ni(t,e,n){switch(e.type){case "color":n=Te.parse(n);break;case "formatted":n=ze.fromString(n.toString());break;case "resolvedImage":n=Re.fromString(n.toString());break;case "padding":n=Be.parse(n);break;case "colorArray":n=Ve.parse(n);break;case "numberArray":n=Ce.parse(n);break;default:Zr(n)===e.type||"enum"===e.type&&e.values[n]||(n=void 0);}return Jr(n,t.default,e.default)}Br.register(zr,{error:[{kind:"error"},[$t],(t,[e])=>{throw new Le(e.evaluate(t))}],typeof:[$t,[qt],(t,[e])=>Qt(qe(e.evaluate(t)))],"to-rgba":[Jt(Ot,4),[Nt],(t,[e])=>{const[n,r,i,s]=e.evaluate(t).rgb;return [255*n,255*r,255*i,s]}],rgb:[Nt,[Ot,Ot,Ot],Cr],rgba:[Nt,[Ot,Ot,Ot,Ot],Cr],has:{type:Rt,overloads:[[[$t],(t,[e])=>Vr(e.evaluate(t),t.properties())],[[$t,jt],(t,[e,n])=>Vr(e.evaluate(t),n.evaluate(t))]]},get:{type:qt,overloads:[[[$t],(t,[e])=>Lr(e.evaluate(t),t.properties())],[[$t,jt],(t,[e,n])=>Lr(e.evaluate(t),n.evaluate(t))]]},"feature-state":[qt,[$t],(t,[e])=>Lr(e.evaluate(t),t.featureState||{})],properties:[jt,[],t=>t.properties()],"geometry-type":[$t,[],t=>t.geometryType()],id:[qt,[],t=>t.id()],zoom:[Ot,[],t=>t.globals.zoom],"heatmap-density":[Ot,[],t=>t.globals.heatmapDensity||0],elevation:[Ot,[],t=>t.globals.elevation||0],"line-progress":[Ot,[],t=>t.globals.lineProgress||0],accumulated:[qt,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[Ot,Or(Ot),(t,e)=>{let n=0;for(const r of e)n+=r.evaluate(t);return n}],"*":[Ot,Or(Ot),(t,e)=>{let n=1;for(const r of e)n*=r.evaluate(t);return n}],"-":{type:Ot,overloads:[[[Ot,Ot],(t,[e,n])=>e.evaluate(t)-n.evaluate(t)],[[Ot],(t,[e])=>-e.evaluate(t)]]},"/":[Ot,[Ot,Ot],(t,[e,n])=>e.evaluate(t)/n.evaluate(t)],"%":[Ot,[Ot,Ot],(t,[e,n])=>e.evaluate(t)%n.evaluate(t)],ln2:[Ot,[],()=>Math.LN2],pi:[Ot,[],()=>Math.PI],e:[Ot,[],()=>Math.E],"^":[Ot,[Ot,Ot],(t,[e,n])=>Math.pow(e.evaluate(t),n.evaluate(t))],sqrt:[Ot,[Ot],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[Ot,[Ot],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[Ot,[Ot],(t,[e])=>Math.log(e.evaluate(t))],log2:[Ot,[Ot],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[Ot,[Ot],(t,[e])=>Math.sin(e.evaluate(t))],cos:[Ot,[Ot],(t,[e])=>Math.cos(e.evaluate(t))],tan:[Ot,[Ot],(t,[e])=>Math.tan(e.evaluate(t))],asin:[Ot,[Ot],(t,[e])=>Math.asin(e.evaluate(t))],acos:[Ot,[Ot],(t,[e])=>Math.acos(e.evaluate(t))],atan:[Ot,[Ot],(t,[e])=>Math.atan(e.evaluate(t))],min:[Ot,Or(Ot),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[Ot,Or(Ot),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[Ot,[Ot],(t,[e])=>Math.abs(e.evaluate(t))],round:[Ot,[Ot],(t,[e])=>{const n=e.evaluate(t);return n<0?-Math.round(-n):Math.round(n)}],floor:[Ot,[Ot],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[Ot,[Ot],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[Rt,[$t,qt],(t,[e,n])=>t.properties()[e.value]===n.value],"filter-id-==":[Rt,[qt],(t,[e])=>t.id()===e.value],"filter-type-==":[Rt,[$t],(t,[e])=>t.geometryType()===e.value],"filter-<":[Rt,[$t,qt],(t,[e,n])=>{const r=t.properties()[e.value],i=n.value;return typeof r==typeof i&&r<i}],"filter-id-<":[Rt,[qt],(t,[e])=>{const n=t.id(),r=e.value;return typeof n==typeof r&&n<r}],"filter->":[Rt,[$t,qt],(t,[e,n])=>{const r=t.properties()[e.value],i=n.value;return typeof r==typeof i&&r>i}],"filter-id->":[Rt,[qt],(t,[e])=>{const n=t.id(),r=e.value;return typeof n==typeof r&&n>r}],"filter-<=":[Rt,[$t,qt],(t,[e,n])=>{const r=t.properties()[e.value],i=n.value;return typeof r==typeof i&&r<=i}],"filter-id-<=":[Rt,[qt],(t,[e])=>{const n=t.id(),r=e.value;return typeof n==typeof r&&n<=r}],"filter->=":[Rt,[$t,qt],(t,[e,n])=>{const r=t.properties()[e.value],i=n.value;return typeof r==typeof i&&r>=i}],"filter-id->=":[Rt,[qt],(t,[e])=>{const n=t.id(),r=e.value;return typeof n==typeof r&&n>=r}],"filter-has":[Rt,[qt],(t,[e])=>e.value in t.properties()],"filter-has-id":[Rt,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[Rt,[Jt($t)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[Rt,[Jt(qt)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[Rt,[$t,Jt(qt)],(t,[e,n])=>n.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[Rt,[$t,Jt(qt)],(t,[e,n])=>function(t,e,n,r){for(;n<=r;){const i=n+r>>1;if(e[i]===t)return !0;e[i]>t?r=i-1:n=i+1;}return !1}(t.properties()[e.value],n.value,0,n.value.length-1)],all:{type:Rt,overloads:[[[Rt,Rt],(t,[e,n])=>e.evaluate(t)&&n.evaluate(t)],[Or(Rt),(t,e)=>{for(const n of e)if(!n.evaluate(t))return !1;return !0}]]},any:{type:Rt,overloads:[[[Rt,Rt],(t,[e,n])=>e.evaluate(t)||n.evaluate(t)],[Or(Rt),(t,e)=>{for(const n of e)if(n.evaluate(t))return !0;return !1}]]},"!":[Rt,[Rt],(t,[e])=>!e.evaluate(t)],"is-supported-script":[Rt,[$t],(t,[e])=>{const n=t.globals&&t.globals.isSupportedScript;return !n||n(e.evaluate(t))}],upcase:[$t,[$t],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[$t,[$t],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[$t,Or(qt),(t,e)=>e.map((e=>Ge(e.evaluate(t)))).join("")],split:[Jt($t),[$t,$t],(t,[e,n])=>e.evaluate(t).split(n.evaluate(t))],join:[$t,[Jt($t),$t],(t,[e,n])=>e.evaluate(t).join(n.evaluate(t))],"resolved-locale":[$t,[Gt],(t,[e])=>e.evaluate(t).resolvedLocale()]});class ri{constructor(t,e,n){this.expression=t,this._warningHistory={},this._evaluator=new Je,this._defaultValue=e?function(t){if("color"===t.type&&Hr(t.default))return new Te(0,0,0,0);switch(t.type){case "color":return Te.parse(t.default)||null;case "padding":return Be.parse(t.default)||null;case "numberArray":return Ce.parse(t.default)||null;case "colorArray":return Ve.parse(t.default)||null;case "variableAnchorOffsetCollection":return $e.parse(t.default)||null;case "projectionDefinition":return Ne.parse(t.default)||null;default:return void 0===t.default?null:t.default}}(e):null,this._enumValues=e&&"enum"===e.type?e.values:null,this._globalState=n;}evaluateWithoutErrorHandling(t,e,n,r,i,s){return this._globalState&&(t=pi(t,this._globalState)),this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=n,this._evaluator.canonical=r,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=s,this.expression.evaluate(this._evaluator)}evaluate(t,e,n,r,i,s){this._globalState&&(t=pi(t,this._globalState)),this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=n||null,this._evaluator.canonical=r,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=s||null;try{const t=this.expression.evaluate(this._evaluator);if(null==t||"number"==typeof t&&t!=t)return this._defaultValue;if(this._enumValues&&!(t in this._enumValues))throw new Le(`Expected value to be one of ${Object.keys(this._enumValues).map((t=>JSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}}}function ii(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in zr}function si(t,e,n){const r=new Qe(zr,$r,[],e?function(t){const e={color:Nt,string:$t,number:Ot,enum:$t,boolean:Rt,formatted:Xt,padding:Yt,numberArray:Ht,colorArray:Zt,projectionDefinition:Ut,resolvedImage:Wt,variableAnchorOffsetCollection:Kt};return "array"===t.type?Jt(e[t.value]||qt,t.length):e[t.type]}(e):void 0),i=r.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return i?jr(new ri(i,e,n)):qr(r.errors)}class oi{constructor(t,e,n){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!Nr(e.expression),this.globalStateRefs=hi(e.expression),this._globalState=n;}evaluateWithoutErrorHandling(t,e,n,r,i,s){return this._globalState&&(t=pi(t,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(t,e,n,r,i,s)}evaluate(t,e,n,r,i,s){return this._globalState&&(t=pi(t,this._globalState)),this._styleExpression.evaluate(t,e,n,r,i,s)}}class ai{constructor(t,e,n,r,i){this.kind=t,this.zoomStops=n,this._styleExpression=e,this.isStateDependent="camera"!==t&&!Nr(e.expression),this.globalStateRefs=hi(e.expression),this.interpolationType=r,this._globalState=i;}evaluateWithoutErrorHandling(t,e,n,r,i,s){return this._globalState&&(t=pi(t,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(t,e,n,r,i,s)}evaluate(t,e,n,r,i,s){return this._globalState&&(t=pi(t,this._globalState)),this._styleExpression.evaluate(t,e,n,r,i,s)}interpolationFactor(t,e,n){return this.interpolationType?mn.interpolationFactor(this.interpolationType,t,e,n):0}}function li(t,e,n){const r=si(t,e,n);if("error"===r.result)return r;const i=r.value.expression,s=Rr(i);if(!s&&!Gr(e))return qr([new Ct("","data expressions not supported")]);const o=Ur(i,["zoom"]);if(!o&&!Xr(e))return qr([new Ct("","zoom expressions not supported")]);const a=ci(i);return a||o?a instanceof Ct?qr([a]):a instanceof mn&&!Yr(e)?qr([new Ct("",'"interpolate" expressions cannot be used with this property')]):jr(a?new ai(s?"camera":"composite",r.value,a.labels,a instanceof mn?a.interpolation:void 0,n):new oi(s?"constant":"source",r.value,n)):qr([new Ct("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class ui{constructor(t,e){this._parameters=t,this._specification=e,Bt(this,Kr(this._parameters,this._specification));}static deserialize(t){return new ui(t._parameters,t._specification)}static serialize(t){return {_parameters:t._parameters,_specification:t._specification}}}function ci(t){let e=null;if(t instanceof tn)e=ci(t.result);else if(t instanceof vn){for(const n of t.args)if(e=ci(n),e)break}else (t instanceof cn||t instanceof mn)&&t.input instanceof Br&&"zoom"===t.input.name&&(e=t);return e instanceof Ct||t.eachChild((t=>{const n=ci(t);n instanceof Ct?e=n:!e&&n?e=new Ct("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&n&&e!==n&&(e=new Ct("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'));})),e}function hi(t,e=new Set){return t instanceof Dr&&e.add(t.key),t.eachChild((t=>{hi(t,e);})),e}function pi(t,e){const{zoom:n,heatmapDensity:r,elevation:i,lineProgress:s,isSupportedScript:o,accumulated:a}=null!=t?t:{};return {zoom:n,heatmapDensity:r,elevation:i,lineProgress:s,isSupportedScript:o,accumulated:a,globalState:e}}function fi(t){if(!0===t||!1===t)return !0;if(!Array.isArray(t)||0===t.length)return !1;switch(t[0]){case "has":return t.length>=2&&"$id"!==t[1]&&"$type"!==t[1];case "in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case "!in":case "!has":case "none":return !1;case "==":case "!=":case ">":case ">=":case "<":case "<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2]);case "any":case "all":for(const e of t.slice(1))if(!fi(e)&&"boolean"!=typeof e)return !1;return !0;default:return !0}}const di={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function yi(t,e){if(null==t)return {filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};fi(t)||(t=xi(t));const n=si(t,di,e);if("error"===n.result)throw new Error(n.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return {filter:(t,e,r)=>n.value.evaluate(t,e,{},r),needGeometry:gi(t),getGlobalStateRefs:()=>hi(n.value.expression)}}function mi(t,e){return t<e?-1:t>e?1:0}function gi(t){if(!Array.isArray(t))return !1;if("within"===t[0]||"distance"===t[0])return !0;for(let e=1;e<t.length;e++)if(gi(t[e]))return !0;return !1}function xi(t){if(!t)return !0;const e=t[0];return t.length<=1?"any"!==e:"=="===e?vi(t[1],t[2],"=="):"!="===e?_i(vi(t[1],t[2],"==")):"<"===e||">"===e||"<="===e||">="===e?vi(t[1],t[2],e):"any"===e?(n=t.slice(1),["any"].concat(n.map(xi))):"all"===e?["all"].concat(t.slice(1).map(xi)):"none"===e?["all"].concat(t.slice(1).map(xi).map(_i)):"in"===e?bi(t[1],t.slice(2)):"!in"===e?_i(bi(t[1],t.slice(2))):"has"===e?wi(t[1]):"!has"!==e||_i(wi(t[1]));var n;}function vi(t,e,n){switch(t){case "$type":return [`filter-type-${n}`,e];case "$id":return [`filter-id-${n}`,e];default:return [`filter-${n}`,t,e]}}function bi(t,e){if(0===e.length)return !1;switch(t){case "$type":return ["filter-type-in",["literal",e]];case "$id":return ["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((t=>typeof t!=typeof e[0]))?["filter-in-large",t,["literal",e.sort(mi)]]:["filter-in-small",t,["literal",e]]}}function wi(t){switch(t){case "$type":return !0;case "$id":return ["filter-has-id"];default:return ["filter-has",t]}}function _i(t){return ["!",t]}function Si(t){const e=typeof t;if("number"===e||"boolean"===e||"string"===e||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${Si(n)},`;return `${e}]`}const n=Object.keys(t).sort();let r="{";for(let e=0;e<n.length;e++)r+=`${JSON.stringify(n[e])}:${Si(t[n[e]])},`;return `${r}}`}function Ai(t){let e="";for(const n of _t)e+=`/${Si(t[n])}`;return e}function Mi(t){const e=t.value;return e?[new zt(t.key,e,"constants have been deprecated as of v8")]:[]}function ki(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}function Ii(t){if(Array.isArray(t))return t.map(Ii);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){const e={};for(const n in t)e[n]=Ii(t[n]);return e}return ki(t)}function Ei(t){const e=t.key,n=t.value,r=t.valueSpec||{},i=t.objectElementValidators||{},s=t.style,o=t.styleSpec,a=t.validateSpec;let l=[];const u=Zr(n);if("object"!==u)return [new zt(e,n,`object expected, ${u} found`)];for(const t in n){const u=t.split(".")[0],c=we(r,u)||r["*"];let h;if(we(i,u))h=i[u];else if(we(r,u)){if(void 0===n[t])continue;h=a;}else if(i["*"])h=i["*"];else {if(!r["*"]){l.push(new zt(e,n[t],`unknown property "${t}"`));continue}h=a;}l=l.concat(h({key:(e?`${e}.`:e)+t,value:n[t],valueSpec:c,style:s,styleSpec:o,object:n,objectKey:t,validateSpec:a},n));}for(const t in r)i[t]||r[t].required&&void 0===r[t].default&&void 0===n[t]&&l.push(new zt(e,n,`missing required property "${t}"`));return l}function Ti(t){const e=t.value,n=t.valueSpec,r=t.style,i=t.styleSpec,s=t.key,o=t.arrayElementValidator||t.validateSpec;if("array"!==Zr(e))return [new zt(s,e,`array expected, ${Zr(e)} found`)];if(n.length&&e.length!==n.length)return [new zt(s,e,`array length ${n.length} expected, length ${e.length} found`)];let a={type:n.value,values:n.values};i.$version<7&&(a.function=n.function),"object"===Zr(n.value)&&(a=n.value);let l=[];for(let n=0;n<e.length;n++)l=l.concat(o({array:e,arrayIndex:n,value:e[n],valueSpec:a,validateSpec:t.validateSpec,style:r,styleSpec:i,key:`${s}[${n}]`}));return l}function Fi(t){const e=t.key,n=t.value,r=t.valueSpec;let i=Zr(n);return "number"===i&&n!=n&&(i="NaN"),"number"!==i?[new zt(e,n,`number expected, ${i} found`)]:"minimum"in r&&n<r.minimum?[new zt(e,n,`${n} is less than the minimum value ${r.minimum}`)]:"maximum"in r&&n>r.maximum?[new zt(e,n,`${n} is greater than the maximum value ${r.maximum}`)]:[]}function Pi(t){const e=t.valueSpec,n=ki(t.value.type);let r,i,s,o={};const a="categorical"!==n&&void 0===t.value.property,l=!a,u="array"===Zr(t.value.stops)&&"array"===Zr(t.value.stops[0])&&"object"===Zr(t.value.stops[0][0]),c=Ei({key:t.key,value:t.value,valueSpec:t.styleSpec.function,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===n)return [new zt(t.key,t.value,'identity function may not have a "stops" property')];let e=[];const r=t.value;return e=e.concat(Ti({key:t.key,value:r,valueSpec:t.valueSpec,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:h})),"array"===Zr(r)&&0===r.length&&e.push(new zt(t.key,r,"array must have at least one stop")),e},default:function(t){return t.validateSpec({key:t.key,value:t.value,valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec})}}});return "identity"===n&&a&&c.push(new zt(t.key,t.value,'missing required property "property"')),"identity"===n||t.value.stops||c.push(new zt(t.key,t.value,'missing required property "stops"')),"exponential"===n&&t.valueSpec.expression&&!Yr(t.valueSpec)&&c.push(new zt(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!Gr(t.valueSpec)?c.push(new zt(t.key,t.value,"property functions not supported")):a&&!Xr(t.valueSpec)&&c.push(new zt(t.key,t.value,"zoom functions not supported"))),"categorical"!==n&&!u||void 0!==t.value.property||c.push(new zt(t.key,t.value,'"property" property is required')),c;function h(t){let n=[];const r=t.value,a=t.key;if("array"!==Zr(r))return [new zt(a,r,`array expected, ${Zr(r)} found`)];if(2!==r.length)return [new zt(a,r,`array length 2 expected, length ${r.length} found`)];if(u){if("object"!==Zr(r[0]))return [new zt(a,r,`object expected, ${Zr(r[0])} found`)];if(void 0===r[0].zoom)return [new zt(a,r,"object stop key must have zoom")];if(void 0===r[0].value)return [new zt(a,r,"object stop key must have value")];if(s&&s>ki(r[0].zoom))return [new zt(a,r[0].zoom,"stop zoom values must appear in ascending order")];ki(r[0].zoom)!==s&&(s=ki(r[0].zoom),i=void 0,o={}),n=n.concat(Ei({key:`${a}[0]`,value:r[0],valueSpec:{zoom:{}},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:Fi,value:p}}));}else n=n.concat(p({key:`${a}[0]`,value:r[0],validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec},r));return ii(Ii(r[1]))?n.concat([new zt(`${a}[1]`,r[1],"expressions are not allowed in function stops.")]):n.concat(t.validateSpec({key:`${a}[1]`,value:r[1],valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec}))}function p(t,s){const a=Zr(t.value),l=ki(t.value),u=null!==t.value?t.value:s;if(r){if(a!==r)return [new zt(t.key,u,`${a} stop domain type must match previous stop domain type ${r}`)]}else r=a;if("number"!==a&&"string"!==a&&"boolean"!==a)return [new zt(t.key,u,"stop domain value must be a number, string, or boolean")];if("number"!==a&&"categorical"!==n){let r=`number expected, ${a} found`;return Gr(e)&&void 0===n&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new zt(t.key,u,r)]}return "categorical"!==n||"number"!==a||isFinite(l)&&Math.floor(l)===l?"categorical"!==n&&"number"===a&&void 0!==i&&l<i?[new zt(t.key,u,"stop domain values must appear in ascending order")]:(i=l,"categorical"===n&&l in o?[new zt(t.key,u,"stop domain values must be unique")]:(o[l]=!0,[])):[new zt(t.key,u,`integer expected, found ${l}`)]}}function Di(t){const e=("property"===t.expressionContext?li:si)(Ii(t.value),t.valueSpec);if("error"===e.result)return e.value.map((e=>new zt(`${t.key}${e.key}`,t.value,e.message)));const n=e.value.expression||e.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!n.outputDefined())return [new zt(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!Nr(n))return [new zt(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext&&!Nr(n))return [new zt(t.key,t.value,'"feature-state" data expressions are not supported with filters.')];if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!Ur(n,["zoom","feature-state"]))return [new zt(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!Rr(n))return [new zt(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return []}function zi(t){const e=t.key,n=t.value,r=Zr(n);return "string"!==r?[new zt(e,n,`color expected, ${r} found`)]:Te.parse(String(n))?[]:[new zt(e,n,`color expected, "${n}" found`)]}function Bi(t){const e=t.key,n=t.value,r=t.valueSpec,i=[];return Array.isArray(r.values)?-1===r.values.indexOf(ki(n))&&i.push(new zt(e,n,`expected one of [${r.values.join(", ")}], ${JSON.stringify(n)} found`)):-1===Object.keys(r.values).indexOf(ki(n))&&i.push(new zt(e,n,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(n)} found`)),i}function Ci(t){return fi(Ii(t.value))?Di(Bt({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}})):Vi(t)}function Vi(t){const e=t.value,n=t.key;if("array"!==Zr(e))return [new zt(n,e,`array expected, ${Zr(e)} found`)];const r=t.styleSpec;let i,s=[];if(e.length<1)return [new zt(n,e,"filter array must have at least 1 element")];switch(s=s.concat(Bi({key:`${n}[0]`,value:e[0],valueSpec:r.filter_operator,style:t.style,styleSpec:t.styleSpec})),ki(e[0])){case "<":case "<=":case ">":case ">=":e.length>=2&&"$type"===ki(e[1])&&s.push(new zt(n,e,`"$type" cannot be use with operator "${e[0]}"`));case "==":case "!=":3!==e.length&&s.push(new zt(n,e,`filter array for operator "${e[0]}" must have 3 elements`));case "in":case "!in":e.length>=2&&(i=Zr(e[1]),"string"!==i&&s.push(new zt(`${n}[1]`,e[1],`string expected, ${i} found`)));for(let o=2;o<e.length;o++)i=Zr(e[o]),"$type"===ki(e[1])?s=s.concat(Bi({key:`${n}[${o}]`,value:e[o],valueSpec:r.geometry_type,style:t.style,styleSpec:t.styleSpec})):"string"!==i&&"number"!==i&&"boolean"!==i&&s.push(new zt(`${n}[${o}]`,e[o],`string, number, or boolean expected, ${i} found`));break;case "any":case "all":case "none":for(let r=1;r<e.length;r++)s=s.concat(Vi({key:`${n}[${r}]`,value:e[r],style:t.style,styleSpec:t.styleSpec}));break;case "has":case "!has":i=Zr(e[1]),2!==e.length?s.push(new zt(n,e,`filter array for "${e[0]}" operator must have 2 elements`)):"string"!==i&&s.push(new zt(`${n}[1]`,e[1],`string expected, ${i} found`));}return s}function Li(t,e){const n=t.key,r=t.validateSpec,i=t.style,s=t.styleSpec,o=t.value,a=t.objectKey,l=s[`${e}_${t.layerType}`];if(!l)return [];const u=a.match(/^(.*)-transition$/);if("paint"===e&&u&&l[u[1]]&&l[u[1]].transition)return r({key:n,value:o,valueSpec:s.transition,style:i,styleSpec:s});const c=t.valueSpec||l[a];if(!c)return [new zt(n,o,`unknown property "${a}"`)];let h;if("string"===Zr(o)&&Gr(c)&&!c.tokens&&(h=/^{([^}]+)}$/.exec(o)))return [new zt(n,o,`"${a}" does not support interpolation syntax\nUse an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(h[1])} }\`.`)];const p=[];return "symbol"===t.layerType&&"text-font"===a&&Hr(Ii(o))&&"identity"===ki(o.type)&&p.push(new zt(n,o,'"text-font" does not support identity functions')),p.concat(r({key:t.key,value:o,valueSpec:c,style:i,styleSpec:s,expressionContext:"property",propertyType:e,propertyKey:a}))}function Oi(t){return Li(t,"paint")}function $i(t){return Li(t,"layout")}function Ri(t){var e,n;let r=[];const i=t.value,s=t.key,o=t.style,a=t.styleSpec;if("object"!==Zr(i))return [new zt(s,i,`object expected, ${Zr(i)} found`)];i.type||i.ref||r.push(new zt(s,i,'either "type" or "ref" is required'));let l=ki(i.type);const u=ki(i.ref);if(i.id){const e=ki(i.id);for(let n=0;n<t.arrayIndex;n++){const t=o.layers[n];ki(t.id)===e&&r.push(new zt(s,i.id,`duplicate layer id "${i.id}", previously used at line ${t.id.__line__}`));}}if("ref"in i){let t;["type","source","source-layer","filter","layout"].forEach((t=>{t in i&&r.push(new zt(s,i[t],`"${t}" is prohibited for ref layers`));})),o.layers.forEach((e=>{ki(e.id)===u&&(t=e);})),t?t.ref?r.push(new zt(s,i.ref,"ref cannot reference another ref layer")):l=ki(t.type):r.push(new zt(s,i.ref,`ref layer "${u}" not found`));}else if("background"!==l)if(i.source){const t=o.sources&&o.sources[i.source],e=t&&ki(t.type);t?"vector"===e&&"raster"===l?r.push(new zt(s,i.source,`layer "${i.id}" requires a raster source`)):"raster-dem"!==e&&"hillshade"===l||"raster-dem"!==e&&"color-relief"===l?r.push(new zt(s,i.source,`layer "${i.id}" requires a raster-dem source`)):"raster"===e&&"raster"!==l?r.push(new zt(s,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==e||i["source-layer"]?"raster-dem"===e&&"hillshade"!==l&&"color-relief"!==l?r.push(new zt(s,i.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):"line"!==l||!i.paint||!i.paint["line-gradient"]||"geojson"===e&&t.lineMetrics||r.push(new zt(s,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):r.push(new zt(s,i,`layer "${i.id}" must specify a "source-layer"`)):r.push(new zt(s,i.source,`source "${i.source}" not found`));}else r.push(new zt(s,i,'missing required property "source"'));return "raster"===l&&(null===(e=i.paint)||void 0===e?void 0:e.resampling)&&(null===(n=i.paint)||void 0===n?void 0:n["raster-resampling"])&&r.push(new zt(s,i.paint,`layer "${i.id}" redundantly specifies "resampling" and "raster-resampling" paint properties, but only one is allowed. It is advised to use "resampling".`)),r=r.concat(Ei({key:s,value:i,valueSpec:a.layer,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":()=>[],type:()=>t.validateSpec({key:`${s}.type`,value:i.type,valueSpec:a.layer.type,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,object:i,objectKey:"type"}),filter:Ci,layout:t=>Ei({layer:i,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>$i(Bt({layerType:l},t))}}),paint:t=>Ei({layer:i,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>Oi(Bt({layerType:l},t))}})}})),r}function Ni(t){const e=t.value,n=t.key,r=Zr(e);return "string"!==r?[new zt(n,e,`string expected, ${r} found`)]:[]}const Ui={promoteId:function({key:t,value:e}){if("string"===Zr(e))return Ni({key:t,value:e});{const n=[];for(const r in e)n.push(...Ni({key:`${t}.${r}`,value:e[r]}));return n}}};function ji(t){const e=t.value,n=t.key,r=t.styleSpec,i=t.style,s=t.validateSpec;if(!e.type)return [new zt(n,e,'"type" is required')];const o=ki(e.type);let a;switch(o){case "vector":case "raster":return a=Ei({key:n,value:e,valueSpec:r[`source_${o.replace("-","_")}`],style:t.style,styleSpec:r,objectElementValidators:Ui,validateSpec:s}),a;case "raster-dem":return a=function(t){var e;const n=null!==(e=t.sourceName)&&void 0!==e?e:"",r=t.value,i=t.styleSpec,s=i.source_raster_dem,o=t.style;let a=[];const l=Zr(r);if(void 0===r)return a;if("object"!==l)return a.push(new zt("source_raster_dem",r,`object expected, ${l} found`)),a;const u="custom"===ki(r.encoding),c=["redFactor","greenFactor","blueFactor","baseShift"],h=t.value.encoding?`"${t.value.encoding}"`:"Default";for(const e in r)!u&&c.includes(e)?a.push(new zt(e,r[e],`In "${n}": "${e}" is only valid when "encoding" is set to "custom". ${h} encoding found`)):s[e]?a=a.concat(t.validateSpec({key:e,value:r[e],valueSpec:s[e],validateSpec:t.validateSpec,style:o,styleSpec:i})):a.push(new zt(e,r[e],`unknown property "${e}"`));return a}({sourceName:n,value:e,style:t.style,styleSpec:r,validateSpec:s}),a;case "geojson":if(a=Ei({key:n,value:e,valueSpec:r.source_geojson,style:i,styleSpec:r,validateSpec:s,objectElementValidators:Ui}),e.cluster)for(const t in e.clusterProperties){const[r,i]=e.clusterProperties[t],s="string"==typeof r?[r,["accumulated"],["get",t]]:r;a.push(...Di({key:`${n}.${t}.map`,value:i,expressionContext:"cluster-map"})),a.push(...Di({key:`${n}.${t}.reduce`,value:s,expressionContext:"cluster-reduce"}));}return a;case "video":return Ei({key:n,value:e,valueSpec:r.source_video,style:i,validateSpec:s,styleSpec:r});case "image":return Ei({key:n,value:e,valueSpec:r.source_image,style:i,validateSpec:s,styleSpec:r});case "canvas":return [new zt(n,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Bi({key:`${n}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function qi(t){const e=t.value,n=t.styleSpec,r=n.light,i=t.style;let s=[];const o=Zr(e);if(void 0===e)return s;if("object"!==o)return s=s.concat([new zt("light",e,`object expected, ${o} found`)]),s;for(const o in e){const a=o.match(/^(.*)-transition$/);s=s.concat(a&&r[a[1]]&&r[a[1]].transition?t.validateSpec({key:o,value:e[o],valueSpec:n.transition,validateSpec:t.validateSpec,style:i,styleSpec:n}):r[o]?t.validateSpec({key:o,value:e[o],valueSpec:r[o],validateSpec:t.validateSpec,style:i,styleSpec:n}):[new zt(o,e[o],`unknown property "${o}"`)]);}return s}function Gi(t){const e=t.value,n=t.styleSpec,r=n.sky,i=t.style,s=Zr(e);if(void 0===e)return [];if("object"!==s)return [new zt("sky",e,`object expected, ${s} found`)];let o=[];for(const s in e)o=o.concat(r[s]?t.validateSpec({key:s,value:e[s],valueSpec:r[s],style:i,styleSpec:n}):[new zt(s,e[s],`unknown property "${s}"`)]);return o}function Xi(t){const e=t.value,n=t.styleSpec,r=n.terrain,i=t.style;let s=[];const o=Zr(e);if(void 0===e)return s;if("object"!==o)return s=s.concat([new zt("terrain",e,`object expected, ${o} found`)]),s;for(const o in e)s=s.concat(r[o]?t.validateSpec({key:o,value:e[o],valueSpec:r[o],validateSpec:t.validateSpec,style:i,styleSpec:n}):[new zt(o,e[o],`unknown property "${o}"`)]);return s}function Yi(t){let e=[];const n=t.value,r=t.key;if(Array.isArray(n)){const i=[],s=[];for(const o in n)n[o].id&&i.includes(n[o].id)&&e.push(new zt(r,n,`all the sprites' ids must be unique, but ${n[o].id} is duplicated`)),i.push(n[o].id),n[o].url&&s.includes(n[o].url)&&e.push(new zt(r,n,`all the sprites' URLs must be unique, but ${n[o].url} is duplicated`)),s.push(n[o].url),e=e.concat(Ei({key:`${r}[${o}]`,value:n[o],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:t.validateSpec}));return e}return Ni({key:r,value:n})}function Zi(t){return Boolean(t)&&t.constructor===Object}function Hi(t){return Zi(t.value)?[]:[new zt(t.key,t.value,`object expected, ${Zr(t.value)} found`)]}const Wi={"*":()=>[],array:Ti,boolean:function(t){const e=t.value,n=t.key,r=Zr(e);return "boolean"!==r?[new zt(n,e,`boolean expected, ${r} found`)]:[]},number:Fi,color:zi,constants:Mi,enum:Bi,filter:Ci,function:Pi,layer:Ri,object:Ei,source:ji,light:qi,sky:Gi,terrain:Xi,projection:function(t){const e=t.value,n=t.styleSpec,r=n.projection,i=t.style,s=Zr(e);if(void 0===e)return [];if("object"!==s)return [new zt("projection",e,`object expected, ${s} found`)];let o=[];for(const s in e)o=o.concat(r[s]?t.validateSpec({key:s,value:e[s],valueSpec:r[s],style:i,styleSpec:n}):[new zt(s,e[s],`unknown property "${s}"`)]);return o},projectionDefinition:function(t){const e=t.key;let n=t.value;n=n instanceof String?n.valueOf():n;const r=Zr(n);return "array"!==r||function(t){return Array.isArray(t)&&3===t.length&&"string"==typeof t[0]&&"string"==typeof t[1]&&"number"==typeof t[2]}(n)||function(t){return !!["interpolate","step","literal"].includes(t[0])}(n)?["array","string"].includes(r)?[]:[new zt(e,n,`projection expected, invalid type "${r}" found`)]:[new zt(e,n,`projection expected, invalid array ${JSON.stringify(n)} found`)]},string:Ni,formatted:function(t){return 0===Ni(t).length?[]:Di(t)},resolvedImage:function(t){return 0===Ni(t).length?[]:Di(t)},padding:function(t){const e=t.key,n=t.value;if("array"===Zr(n)){if(n.length<1||n.length>4)return [new zt(e,n,`padding requires 1 to 4 values; ${n.length} values found`)];const r={type:"number"};let i=[];for(let s=0;s<n.length;s++)i=i.concat(t.validateSpec({key:`${e}[${s}]`,value:n[s],validateSpec:t.validateSpec,valueSpec:r}));return i}return Fi({key:e,value:n,valueSpec:{}})},numberArray:function(t){const e=t.key,n=t.value;if("array"===Zr(n)){const r={type:"number"};if(n.length<1)return [new zt(e,n,"array length at least 1 expected, length 0 found")];let i=[];for(let s=0;s<n.length;s++)i=i.concat(t.validateSpec({key:`${e}[${s}]`,value:n[s],validateSpec:t.validateSpec,valueSpec:r}));return i}return Fi({key:e,value:n,valueSpec:{}})},colorArray:function(t){const e=t.key,n=t.value;if("array"===Zr(n)){if(n.length<1)return [new zt(e,n,"array length at least 1 expected, length 0 found")];let t=[];for(let r=0;r<n.length;r++)t=t.concat(zi({key:`${e}[${r}]`,value:n[r]}));return t}return zi({key:e,value:n})},variableAnchorOffsetCollection:function(t){const e=t.key,n=t.value,r=Zr(n),i=t.styleSpec;if("array"!==r||n.length<1||n.length%2!=0)return [new zt(e,n,"variableAnchorOffsetCollection requires a non-empty array of even length")];let s=[];for(let r=0;r<n.length;r+=2)s=s.concat(Bi({key:`${e}[${r}]`,value:n[r],valueSpec:i.layout_symbol["text-anchor"]})),s=s.concat(Ti({key:`${e}[${r+1}]`,value:n[r+1],valueSpec:{length:2,value:"number"},validateSpec:t.validateSpec,style:t.style,styleSpec:i}));return s},sprite:Yi,state:Hi,fontFaces:function(t){const e=t.key,n=t.value,r=t.validateSpec,i=t.styleSpec,s=t.style;if(!Zi(n))return [new zt(e,n,`object expected, ${Zr(n)} found`)];const o=[];for(const t in n){const a=n[t],l=Zr(a);if("string"===l)o.push(...Ni({key:`${e}.${t}`,value:a}));else if("array"===l){const n={url:{type:"string",required:!0},"unicode-range":{type:"array",value:"string"}};for(const[l,u]of a.entries())o.push(...Ei({key:`${e}.${t}[${l}]`,value:u,valueSpec:n,styleSpec:i,style:s,validateSpec:r}));}else o.push(new zt(`${e}.${t}`,a,`string or array expected, ${l} found`));}return o}};function Ki(t){const e=t.value,n=t.valueSpec,r=t.styleSpec;return t.validateSpec=Ki,n.expression&&Hr(ki(e))?Pi(t):n.expression&&ii(Ii(e))?Di(t):n.type&&Wi[n.type]?Wi[n.type](t):Ei(Bt({},t,{valueSpec:n.type?r[n.type]:n}))}function Ji(t){const e=t.value,n=t.key,r=Ni(t);return r.length||(-1===e.indexOf("{fontstack}")&&r.push(new zt(n,e,'"glyphs" url must include a "{fontstack}" token')),-1===e.indexOf("{range}")&&r.push(new zt(n,e,'"glyphs" url must include a "{range}" token'))),r}function Qi(t,e=wt){let n=[];return n=n.concat(Ki({key:"",value:t,valueSpec:e.$root,styleSpec:e,style:t,validateSpec:Ki,objectElementValidators:{glyphs:Ji,"*":()=>[]}})),t.constants&&(n=n.concat(Mi({key:"constants",value:t.constants}))),es(n)}function ts(t){return function(e){return t(Object.assign({},e,{validateSpec:Ki}))}}function es(t){return [].concat(t).sort(((t,e)=>t.line-e.line))}function ns(t){return function(...e){return es(t.apply(this,e))}}Qi.source=ns(ts(ji)),Qi.sprite=ns(ts(Yi)),Qi.glyphs=ns(ts(Ji)),Qi.light=ns(ts(qi)),Qi.sky=ns(ts(Gi)),Qi.terrain=ns(ts(Xi)),Qi.state=ns(ts(Hi)),Qi.layer=ns(ts(Ri)),Qi.filter=ns(ts(Ci)),Qi.paintProperty=ns(ts(Oi)),Qi.layoutProperty=ns(ts($i));const rs={type:"enum","property-type":"data-constant",expression:{interpolated:!1,parameters:["global-state"]},values:{visible:{},none:{}},transition:!1,default:"visible"};class is{constructor(t,e){this._globalState=e,this.setValue(t);}evaluate(){var t;return null!==(t=this._literalValue)&&void 0!==t?t:this._compiledValue.evaluate({})}setValue(t){if(null==t||"visible"===t||"none"===t)return this._literalValue="none"===t?"none":"visible",this._compiledValue=void 0,void(this._globalStateRefs=new Set);const e=si(t,rs,this._globalState);if("error"===e.result)throw this._literalValue="visible",this._compiledValue=void 0,new Error(e.value.map((t=>`${t.key}: ${t.message}`)).join(", "));this._literalValue=void 0,this._compiledValue=e.value,this._globalStateRefs=hi(e.value.expression);}getGlobalStateRefs(){return this._globalStateRefs}}const ss=wt,os=Qi,as=os.light,ls=os.sky,us=os.paintProperty,cs=os.layoutProperty;function hs(t,e){let n=!1;if(null==e?void 0:e.length)for(const r of e)t.fire(new vt(new Error(r.message))),n=!0;return n}class ps{constructor(t,e,n){const r=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;const i=new Int32Array(this.arrayBuffer);t=i[0],this.d=(e=i[1])+2*(n=i[2]);for(let t=0;t<this.d*this.d;t++){const e=i[3+t],n=i[3+t+1];r.push(e===n?null:i.subarray(e,n));}const s=i[3+r.length+1];this.keys=i.subarray(i[3+r.length],s),this.bboxes=i.subarray(s),this.insert=this._insertReadonly;}else {this.d=e+2*n;for(let t=0;t<this.d*this.d;t++)r.push([]);this.keys=[],this.bboxes=[];}this.n=e,this.extent=t,this.padding=n,this.scale=e/t,this.uid=0;const i=n/e*t;this.min=-i,this.max=t+i;}insert(t,e,n,r,i){this._forEachCell(e,n,r,i,this._insertCell,this.uid++,void 0,void 0),this.keys.push(t),this.bboxes.push(e),this.bboxes.push(n),this.bboxes.push(r),this.bboxes.push(i);}_insertReadonly(){throw new Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(t,e,n,r,i,s){this.cells[i].push(s);}query(t,e,n,r,i){const s=this.min,o=this.max;if(t<=s&&e<=s&&o<=n&&o<=r&&!i)return [...this.keys];{const s=[];return this._forEachCell(t,e,n,r,this._queryCell,s,{},i),s}}_queryCell(t,e,n,r,i,s,o,a){const l=this.cells[i];if(null!==l){const i=this.keys,u=this.bboxes;for(const c of l)if(void 0===o[c]){const l=4*c;(a?a(u[l+0],u[l+1],u[l+2],u[l+3]):t<=u[l+2]&&e<=u[l+3]&&n>=u[l+0]&&r>=u[l+1])?(o[c]=!0,s.push(i[c])):o[c]=!1;}}}_forEachCell(t,e,n,r,i,s,o,a){const l=this._convertToCellCoord(t),u=this._convertToCellCoord(e),c=this._convertToCellCoord(n),h=this._convertToCellCoord(r);for(let p=l;p<=c;p++)for(let l=u;l<=h;l++){const u=this.d*l+p;if((!a||a(this._convertFromCellCoord(p),this._convertFromCellCoord(l),this._convertFromCellCoord(p+1),this._convertFromCellCoord(l+1)))&&i.call(this,t,e,n,r,u,s,o,a))return}}_convertFromCellCoord(t){return (t-this.padding)/this.scale}_convertToCellCoord(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const t=this.cells,e=3+this.cells.length+1+1;let n=0;for(const t of this.cells)n+=t.length;const r=new Int32Array(e+n+this.keys.length+this.bboxes.length);r[0]=this.extent,r[1]=this.n,r[2]=this.padding;let i=e;for(let e=0;e<t.length;e++){const n=t[e];r[3+e]=i,r.set(n,i),i+=n.length;}return r[3+t.length]=i,r.set(this.keys,i),i+=this.keys.length,r[3+t.length+1]=i,r.set(this.bboxes,i),i+=this.bboxes.length,r.buffer}static serialize(t,e){const n=t.toArrayBuffer();return e&&e.push(n),{buffer:n}}static deserialize(t){return new ps(t.buffer)}}const fs={};function ds(t,e,n={}){if(fs[t])throw new Error(`${t} is already registered.`);Object.defineProperty(e,"_classRegistryKey",{value:t,writeable:!1}),fs[t]={klass:e,omit:n.omit||[],shallow:n.shallow||[]};}ds("Object",Object),ds("Set",Set),ds("TransferableGridIndex",ps),ds("Color",Te),ds("Error",Error),ds("AJAXError",pt),ds("ResolvedImage",Re),ds("StylePropertyFunction",ui),ds("StyleExpression",ri,{omit:["_evaluator"]}),ds("ZoomDependentExpression",ai),ds("ZoomConstantExpression",oi),ds("CompoundExpression",Br,{omit:["_evaluate"]});for(const t in zr)zr[t]._classRegistryKey||ds(`Expression_${t}`,zr[t]);function ys(t){var e;return t&&"undefined"!=typeof ArrayBuffer&&(t instanceof ArrayBuffer||"ArrayBuffer"===(null===(e=t.constructor)||void 0===e?void 0:e.name))}function ms(t){return t.$name||t.constructor._classRegistryKey}function gs(t){return !function(t){if(null===t||"object"!=typeof t)return !1;const e=ms(t);return e&&"Object"!==e}(t)&&(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||t instanceof Blob||t instanceof Error||ys(t)||H(t)||ArrayBuffer.isView(t)||t instanceof ImageData)}function xs(t,e){if(gs(t))return (ys(t)||H(t))&&e&&e.push(t),ArrayBuffer.isView(t)&&e&&e.push(t.buffer),t instanceof ImageData&&e&&e.push(t.data.buffer),t;if(Array.isArray(t)){const n=[];for(const r of t)n.push(xs(r,e));return n}if("object"!=typeof t)throw new Error("can't serialize object of type "+typeof t);const n=ms(t);if(!n)throw new Error(`can't serialize object of unregistered class ${t.constructor.name}`);if(!fs[n])throw new Error(`${n} is not registered.`);const{klass:r}=fs[n],i=r.serialize?r.serialize(t,e):{};if(r.serialize){if(i===(null==e?void 0:e[e.length-1]))throw new Error("statically serialized object won't survive transfer of $name property")}else {for(const r in t){if(!t.hasOwnProperty(r))continue;if(fs[n].omit.includes(r))continue;const s=t[r];i[r]=fs[n].shallow.includes(r)?s:xs(s,e);}t instanceof Error&&(i.message=t.message);}if(i.$name)throw new Error("$name property is reserved for worker serialization logic.");return "Object"!==n&&(i.$name=n),i}function vs(t){if(gs(t))return t;if(Array.isArray(t))return t.map(vs);if("object"!=typeof t)throw new Error("can't deserialize object of type "+typeof t);const e=ms(t)||"Object";if(!fs[e])throw new Error(`can't deserialize unregistered class ${e}`);const{klass:n}=fs[e];if(!n)throw new Error(`can't deserialize unregistered class ${e}`);if(n.deserialize)return n.deserialize(t);const r=Object.create(n.prototype);for(const n of Object.keys(t)){if("$name"===n)continue;const i=t[n];r[n]=fs[e].shallow.includes(n)?i:vs(i);}return r}class bs{constructor(){this.first=!0;}update(t,e){const n=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=n,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=n,!0):(this.lastFloorZoom>n?(this.lastIntegerZoom=n+1,this.lastIntegerZoomTime=e):this.lastFloorZoom<n&&(this.lastIntegerZoom=n,this.lastIntegerZoomTime=e),t!==this.lastZoom&&(this.lastZoom=t,this.lastFloorZoom=n,!0))}}function ws(t){return /[\u02EA\u02EB\u2E80-\u2FDF\u2FF0-\u303F\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FD-\u30FF\u3105-\u312F\u31A0-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE4F\uFF00-\uFFEF]|\uD81B[\uDFE0-\uDFFF]|[\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFB]|\uD83C[\uDE00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(t))}function _s(t){return /[\u02EA\u02EB\u1100-\u11FF\u1400-\u167F\u18B0-\u18F5\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u3007\u3012\u3013\u3020-\u302F\u3031-\u303F\u3041-\u3096\u309D-\u30FB\u30FD-\u30FF\u3105-\u312F\u3131-\u318E\u3190-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE48\uFE50-\uFE57\uFE5F-\uFE62\uFE67-\uFE6F\uFF00-\uFF07\uFF0A-\uFF0C\uFF0E-\uFF19\uFF1F-\uFF3A\uFF3C\uFF3E\uFF40-\uFF5A\uFFE0-\uFFE2\uFFE4-\uFFE7]|\uD802[\uDD80-\uDD9F]|\uD805[\uDD80-\uDDFF]|\uD806[\uDE00-\uDEBF]|\uD811[\uDC00-\uDE7F]|\uD81B[\uDFE0-\uDFE4\uDFF0-\uDFF6]|[\uD81C-\uD822\uD83D\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD30-\uDEFB]|\uD833[\uDEC0-\uDFCF]|\uD834[\uDC00-\uDDFF\uDEE0-\uDF7F]|\uD836[\uDC00-\uDEAF]|\uD83C[\uDC00-\uDE00\uDF00-\uDFFF]|\uD83E[\uDD00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(t))}function Ss(t){return /\s/u.test(String.fromCodePoint(t))}function As(t){for(const e of t)if(_s(e.codePointAt(0)))return !0;return !1}function Ms(t){for(const e of t)if(!Es(e.codePointAt(0)))return !1;return !0}function ks(t){const e=t.map((t=>{try{return new RegExp(`\\p{sc=${t}}`,"u").source}catch(t){return null}})).filter((t=>t));return new RegExp(e.join("|"),"u")}const Is=ks(["Arab","Dupl","Mong","Ougr","Syrc"]);function Es(t){return !Is.test(String.fromCodePoint(t))}function Ts(t){return !(_s(t)||(e=t,/[\xA7\xA9\xAE\xB1\xBC-\xBE\xD7\xF7\u2016\u2020\u2021\u2030\u2031\u203B\u203C\u2042\u2047-\u2049\u2051\u2100-\u218F\u221E\u2234\u2235\u2300-\u2307\u230C-\u231F\u2324-\u2328\u232B\u237D-\u239A\u23BE-\u23CD\u23CF\u23D1-\u23DB\u23E2-\u2422\u2424-\u24FF\u25A0-\u2619\u2620-\u2767\u2776-\u2793\u2B12-\u2B2F\u2B50-\u2B59\u2BB8-\u2BEB\u3000-\u303F\u30A0-\u30FF\uE000-\uF8FF\uFE30-\uFE6F\uFF00-\uFFEF\uFFFC\uFFFD]|[\uDB80-\uDBFF][\uDC00-\uDFFF]/gim.test(String.fromCodePoint(e))));var e;}const Fs=ks(["Adlm","Arab","Armi","Avst","Chrs","Cprt","Egyp","Elym","Gara","Hatr","Hebr","Hung","Khar","Lydi","Mand","Mani","Mend","Merc","Mero","Narb","Nbat","Nkoo","Orkh","Palm","Phli","Phlp","Phnx","Prti","Rohg","Samr","Sarb","Sogo","Syrc","Thaa","Todr","Yezi"]);function Ps(t){return Fs.test(String.fromCodePoint(t))}function Ds(t,e){return !(!e&&Ps(t)||/[\u0900-\u0DFF\u0F00-\u109F\u1780-\u17FF]/gim.test(String.fromCodePoint(t)))}function zs(t){for(const e of t)if(Ps(e.codePointAt(0)))return !0;return !1}const Bs=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{};}setState(t){this.pluginStatus=t.pluginStatus,this.pluginURL=t.pluginURL;}getState(){return {pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(t){if(Bs.isParsed())throw new Error("RTL text plugin already registered.");this.applyArabicShaping=t.applyArabicShaping,this.processBidirectionalText=t.processBidirectionalText,this.processStyledBidirectionalText=t.processStyledBidirectionalText,this.loadScriptResolve();}isParsed(){return null!=this.applyArabicShaping&&null!=this.processBidirectionalText&&null!=this.processStyledBidirectionalText}getRTLTextPluginStatus(){return this.pluginStatus}syncState(t,n){return e(this,void 0,void 0,(function*(){if(this.isParsed())return this.getState();if("loading"!==t.pluginStatus)return this.setState(t),t;const e=t.pluginURL,r=new Promise((t=>{this.loadScriptResolve=t;}));n(e);const i=new Promise((t=>setTimeout((()=>t()),this.TIMEOUT)));if(yield Promise.race([r,i]),this.isParsed()){const t={pluginStatus:"loaded",pluginURL:e};return this.setState(t),t}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${e}`)}))}};class Cs{constructor(t,e){this.isSupportedScript=Vs,this.zoom=t,e?(this.now=e.now||0,this.fadeDuration=e.fadeDuration||0,this.zoomHistory=e.zoomHistory||new bs,this.transition=e.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new bs,this.transition={});}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const t=this.zoom,e=t-Math.floor(t),n=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:e+(1-e)*n}:{fromScale:.5,toScale:1,t:1-(1-n)*e}}}function Vs(t){return function(t,e){for(const n of t)if(!Ds(n.codePointAt(0),e))return !1;return !0}(t,"loaded"===Bs.getRTLTextPluginStatus())}const Ls="-transition";class Os{constructor(t,e,n){this.property=t,this.value=e,this.expression=function(t,e,n){if(Hr(t))return new ui(t,e);if(ii(t)){const r=li(t,e,n);if("error"===r.result)throw new Error(r.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return r.value}{let n=t;return "color"===e.type&&"string"==typeof t?n=Te.parse(t):"padding"!==e.type||"number"!=typeof t&&!Array.isArray(t)?"numberArray"!==e.type||"number"!=typeof t&&!Array.isArray(t)?"colorArray"!==e.type||"string"!=typeof t&&!Array.isArray(t)?"variableAnchorOffsetCollection"===e.type&&Array.isArray(t)?n=$e.parse(t):"projectionDefinition"===e.type&&"string"==typeof t&&(n=Ne.parse(t)):n=Ve.parse(t):n=Ce.parse(t):n=Be.parse(t),{globalStateRefs:new Set,_globalState:null,kind:"constant",evaluate:()=>n}}}(void 0===e?t.specification.default:e,t.specification,n);}isDataDriven(){return "source"===this.expression.kind||"composite"===this.expression.kind}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}possiblyEvaluate(t,e,n){return this.property.possiblyEvaluate(this,t,e,n)}}class $s{constructor(t,e){this.property=t,this.value=new Os(t,void 0,e);}transitioned(t,e){return new Ns(this.property,this.value,e,$({},t.transition,this.transition),t.now)}untransitioned(){return new Ns(this.property,this.value,null,{},0)}}class Rs{constructor(t,e){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues),this._globalState=e;}hasProperty(t){return t in this._properties.defaultTransitionablePropertyValues}getValue(t){return j(this._values[t].value.value)}setValue(t,e){Object.hasOwn(this._values,t)||(this._values[t]=new $s(this._values[t].property,this._globalState)),this._values[t].value=new Os(this._values[t].property,null===e?void 0:j(e),this._globalState);}getTransition(t){return j(this._values[t].transition)}setTransition(t,e){Object.hasOwn(this._values,t)||(this._values[t]=new $s(this._values[t].property,this._globalState)),this._values[t].transition=j(e)||void 0;}serialize(){const t={};for(const e of Object.keys(this._values)){const n=this.getValue(e);void 0!==n&&(t[e]=n);const r=this.getTransition(e);void 0!==r&&(t[`${e}${Ls}`]=r);}return t}transitioned(t,e){const n=new Us(this._properties);for(const r of Object.keys(this._values))n._values[r]=this._values[r].transitioned(t,e._values[r]);return n}untransitioned(){const t=new Us(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class Ns{constructor(t,e,n,r,i){this.property=t,this.value=e,this.begin=i+r.delay||0,this.end=this.begin+r.duration||0,t.specification.transition&&(r.delay||r.duration)&&(this.prior=n);}possiblyEvaluate(t,e,n){const r=t.now||0,i=this.value.possiblyEvaluate(t,e,n),s=this.prior;if(s){if(r>this.end)return this.prior=null,i;if(this.value.isDataDriven())return this.prior=null,i;if(r<this.begin)return s.possiblyEvaluate(t,e,n);{const o=(r-this.begin)/(this.end-this.begin);return this.property.interpolate(s.possiblyEvaluate(t,e,n),i,B(o))}}return i}}class Us{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues);}possiblyEvaluate(t,e,n){const r=new Gs(this._properties);for(const i of Object.keys(this._values))r._values[i]=this._values[i].possiblyEvaluate(t,e,n);return r}hasTransition(){for(const t of Object.keys(this._values))if(this._values[t].prior)return !0;return !1}}class js{constructor(t,e){this._properties=t,this._values=Object.create(t.defaultPropertyValues),this._globalState=e;}hasValue(t){return void 0!==this._values[t].value}hasProperty(t){return t in this._properties.defaultPropertyValues}getValue(t){return j(this._values[t].value)}setValue(t,e){this._values[t]=new Os(this._values[t].property,null===e?void 0:j(e),this._globalState);}serialize(){const t={};for(const e of Object.keys(this._values)){const n=this.getValue(e);void 0!==n&&(t[e]=n);}return t}possiblyEvaluate(t,e,n){const r=new Gs(this._properties);for(const i of Object.keys(this._values))r._values[i]=this._values[i].possiblyEvaluate(t,e,n);return r}}class qs{constructor(t,e,n){this.property=t,this.value=e,this.parameters=n;}isConstant(){return "constant"===this.value.kind}constantOr(t){return "constant"===this.value.kind?this.value.value:t}evaluate(t,e,n,r){return this.property.evaluate(this.value,this.parameters,t,e,n,r)}}class Gs{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues);}get(t){return this._values[t]}}class Xs{constructor(t){this.specification=t;}possiblyEvaluate(t,e){if(t.isDataDriven())throw new Error("Value should not be data driven");return t.expression.evaluate(e)}interpolate(t,e,n){const r=xn[this.specification.type];return r?r(t,e,n):t}}class Ys{constructor(t,e){this.specification=t,this.overrides=e;}possiblyEvaluate(t,e,n,r){return new qs(this,"constant"===t.expression.kind||"camera"===t.expression.kind?{kind:"constant",value:t.expression.evaluate(e,null,{},n,r)}:t.expression,e)}interpolate(t,e,n){if("constant"!==t.value.kind||"constant"!==e.value.kind)return t;if(void 0===t.value.value||void 0===e.value.value)return new qs(this,{kind:"constant",value:void 0},t.parameters);const r=xn[this.specification.type];if(r){const i=r(t.value.value,e.value.value,n);return new qs(this,{kind:"constant",value:i},t.parameters)}return t}evaluate(t,e,n,r,i,s){return "constant"===t.kind?t.value:t.evaluate(e,n,r,i,s)}}class Zs extends Ys{possiblyEvaluate(t,e,n,r){if(void 0===t.value)return new qs(this,{kind:"constant",value:void 0},e);if("constant"===t.expression.kind){const i=t.expression.evaluate(e,null,{},n,r),s="resolvedImage"===t.property.specification.type&&"string"!=typeof i?i.name:i,o=this._calculate(s,s,s,e);return new qs(this,{kind:"constant",value:o},e)}if("camera"===t.expression.kind){const n=this._calculate(t.expression.evaluate({zoom:e.zoom-1}),t.expression.evaluate({zoom:e.zoom}),t.expression.evaluate({zoom:e.zoom+1}),e);return new qs(this,{kind:"constant",value:n},e)}return new qs(this,t.expression,e)}evaluate(t,e,n,r,i,s){if("source"===t.kind){const o=t.evaluate(e,n,r,i,s);return this._calculate(o,o,o,e)}return "composite"===t.kind?this._calculate(t.evaluate({zoom:Math.floor(e.zoom)-1},n,r),t.evaluate({zoom:Math.floor(e.zoom)},n,r),t.evaluate({zoom:Math.floor(e.zoom)+1},n,r),e):t.value}_calculate(t,e,n,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:n,to:e}}interpolate(t){return t}}class Hs{constructor(t){this.specification=t;}possiblyEvaluate(t,e,n,r){if(void 0!==t.value){if("constant"===t.expression.kind){const i=t.expression.evaluate(e,null,{},n,r);return this._calculate(i,i,i,e)}return this._calculate(t.expression.evaluate(new Cs(Math.floor(e.zoom-1),e)),t.expression.evaluate(new Cs(Math.floor(e.zoom),e)),t.expression.evaluate(new Cs(Math.floor(e.zoom+1),e)),e)}}_calculate(t,e,n,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:n,to:e}}interpolate(t){return t}}class Ws{constructor(t){this.specification=t;}possiblyEvaluate(t,e,n,r){return !!t.expression.evaluate(e,null,{},n,r)}interpolate(){return !1}}class Ks{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const e in t){const n=t[e];n.specification.overridable&&this.overridableProperties.push(e);const r=this.defaultPropertyValues[e]=new Os(n,void 0,void 0),i=this.defaultTransitionablePropertyValues[e]=new $s(n,void 0);this.defaultTransitioningPropertyValues[e]=i.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=r.possiblyEvaluate({});}}}ds("DataDrivenProperty",Ys),ds("DataConstantProperty",Xs),ds("CrossFadedDataDrivenProperty",Zs),ds("CrossFadedProperty",Hs),ds("ColorRampProperty",Ws);const Js=" is a PAINT property not a LAYOUT property. Use get/setPaintProperty instead?",Qs=" is a LAYOUT property not a PAINT property. Use get/setLayoutProperty instead?";class to extends bt{constructor(t,e,n){if(super(),this.id=t.id,this.type=t.type,this._globalState=n,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},this._visibilityExpression=function(t,e){return new is(t,e)}(this.visibility,n),"custom"!==t.type&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter,this._featureFilter=yi(t.filter,n)),e.layout&&(this._unevaluatedLayout=new js(e.layout,n)),e.paint)){this._transitionablePaint=new Rs(e.paint,n);for(const e in t.paint)this.setPaintProperty(e,t.paint[e],{validate:!1});for(const e in t.layout)this.setLayoutProperty(e,t.layout[e],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Gs(e.paint);}}setFilter(t){this.filter=t,this._featureFilter=yi(t,this._globalState);}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){var e;if("visibility"===t)return this.visibility;if(null===(e=this._transitionablePaint)||void 0===e?void 0:e.hasProperty(t))throw new Error(t+Js);if(!this._unevaluatedLayout)throw new Error(`Cannot get layout property "${t}" on layer type "${this.type}" which has no layout properties.`);return this._unevaluatedLayout.getValue(t)}getLayoutAffectingGlobalStateRefs(){const t=new Set;for(const e of this._visibilityExpression.getGlobalStateRefs())t.add(e);if(this._unevaluatedLayout)for(const e in this._unevaluatedLayout._values){const n=this._unevaluatedLayout._values[e];for(const e of n.getGlobalStateRefs())t.add(e);}for(const e of this._featureFilter.getGlobalStateRefs())t.add(e);return t}getPaintAffectingGlobalStateRefs(){var t;const e=new globalThis.Map;if(this._transitionablePaint)for(const n in this._transitionablePaint._values){const r=this._transitionablePaint._values[n].value;for(const i of r.getGlobalStateRefs()){const s=null!==(t=e.get(i))&&void 0!==t?t:[];s.push({name:n,value:r.value}),e.set(i,s);}}return e}getVisibilityAffectingGlobalStateRefs(){return this._visibilityExpression.getGlobalStateRefs()}setLayoutProperty(t,e,n={}){var r;if("visibility"===t)return this.visibility=e,this._visibilityExpression.setValue(e),void this.recalculateVisibility();(null===(r=this._transitionablePaint)||void 0===r?void 0:r.hasProperty(t))?this.fire(new vt(new Error(t+Js))):null!=e&&this._validate(cs,`layers.${this.id}.layout.${t}`,t,e,n)||this._unevaluatedLayout.setValue(t,e);}getPaintProperty(t){var e,n;if(t.endsWith(Ls)){const n=t.slice(0,-11);if("visibility"===n||(null===(e=this._unevaluatedLayout)||void 0===e?void 0:e.hasProperty(n)))throw new Error(t+Qs);return this._transitionablePaint.getTransition(n)}if("visibility"===t||(null===(n=this._unevaluatedLayout)||void 0===n?void 0:n.hasProperty(t)))throw new Error(t+Qs);return this._transitionablePaint.getValue(t)}setPaintProperty(t,e,n={}){var r;if("visibility"===t||(null===(r=this._unevaluatedLayout)||void 0===r?void 0:r.hasProperty(t)))return this.fire(new vt(new Error(t+Qs))),!1;if(null!=e&&this._validate(us,`layers.${this.id}.paint.${t}`,t,e,n))return !1;if(t.endsWith(Ls))return this._transitionablePaint.setTransition(t.slice(0,-11),e||void 0),!1;{const n=this._transitionablePaint._values[t],r="cross-faded-data-driven"===n.property.specification["property-type"],i=n.value.isDataDriven(),s=n.value;this._transitionablePaint.setValue(t,e),this._handleSpecialPaintPropertyUpdate(t);const o=this._transitionablePaint._values[t].value;return o.isDataDriven()||i||r||this._handleOverridablePaintPropertyUpdate(t,s,o)}}_handleSpecialPaintPropertyUpdate(t){}_handleOverridablePaintPropertyUpdate(t,e,n){return !1}isHidden(t=this.minzoom,e=!1){return !!(this.minzoom&&t<(e?Math.floor(this.minzoom):this.minzoom))||!!(this.maxzoom&&t>=this.maxzoom)||"none"===this._evaluatedVisibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint);}hasTransition(){return this._transitioningPaint.hasTransition()}recalculateVisibility(){this._evaluatedVisibility=this._visibilityExpression.evaluate();}recalculate(t,e){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e);}serialize(){var t,e;const n={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:null===(t=this._unevaluatedLayout)||void 0===t?void 0:t.serialize(),paint:null===(e=this._transitionablePaint)||void 0===e?void 0:e.serialize()};return this.visibility&&(n.layout||(n.layout={}),n.layout.visibility=this.visibility),U(n,((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}_validate(t,e,n,r,i={}){return !1!==(null==i?void 0:i.validate)&&hs(this,t.call(os,{key:e,layerType:this.type,objectKey:n,value:r,styleSpec:wt,style:{glyphs:!0,sprite:!0}}))}is3D(){return !1}isTileClipped(){return !1}hasOffscreenPass(){return !1}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof qs&&Gr(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return !0}return !1}}let eo;var no={get paint(){return eo=eo||new Ks({"raster-opacity":new Xs(wt.paint_raster["raster-opacity"]),"raster-hue-rotate":new Xs(wt.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Xs(wt.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Xs(wt.paint_raster["raster-brightness-max"]),"raster-saturation":new Xs(wt.paint_raster["raster-saturation"]),"raster-contrast":new Xs(wt.paint_raster["raster-contrast"]),resampling:new Xs(wt.paint_raster.resampling),"raster-resampling":new Xs(wt.paint_raster["raster-resampling"]),"raster-fade-duration":new Xs(wt.paint_raster["raster-fade-duration"])})}};class ro extends to{constructor(t,e){super(t,no,e);}}const io={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class so{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8;}}class oo{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0);}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews());}clear(){this.length=0;}resize(t){this.reserve(t),this.length=t;}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e);}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}freeBufferAfterUpload(){this.arrayBuffer=new ArrayBuffer(0),this._refreshViews();}}function ao(t,e=1){let n=0,r=0;return {members:t.map((t=>{const i=io[t.type].BYTES_PER_ELEMENT,s=n=lo(n,Math.max(e,i)),o=t.components||1;return r=Math.max(r,i),n+=i*o,{name:t.name,type:t.type,components:o,offset:s}})),size:lo(n,Math.max(r,e)),alignment:e}}function lo(t,e){return Math.ceil(t/e)*e}class uo extends oo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e){const n=this.length;return this.resize(n+1),this.emplace(n,t,e)}emplace(t,e,n){const r=2*t;return this.int16[r+0]=e,this.int16[r+1]=n,t}}uo.prototype.bytesPerElement=4,ds("StructArrayLayout2i4",uo);class co extends oo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,n)}emplace(t,e,n,r){const i=3*t;return this.int16[i+0]=e,this.int16[i+1]=n,this.int16[i+2]=r,t}}co.prototype.bytesPerElement=6,ds("StructArrayLayout3i6",co);class ho extends oo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,n,r){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,n,r)}emplace(t,e,n,r,i){const s=4*t;return this.int16[s+0]=e,this.int16[s+1]=n,this.int16[s+2]=r,this.int16[s+3]=i,t}}ho.prototype.bytesPerElement=8,ds("StructArrayLayout4i8",ho);class po extends oo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,n,r,i,s){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,n,r,i,s)}emplace(t,e,n,r,i,s,o){const a=6*t;return this.int16[a+0]=e,this.int16[a+1]=n,this.int16[a+2]=r,this.int16[a+3]=i,this.int16[a+4]=s,this.int16[a+5]=o,t}}po.prototype.bytesPerElement=12,ds("StructArrayLayout2i4i12",po);class fo extends oo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,n,r,i,s){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,n,r,i,s)}emplace(t,e,n,r,i,s,o){const a=4*t,l=8*t;return this.int16[a+0]=e,this.int16[a+1]=n,this.uint8[l+4]=r,this.uint8[l+5]=i,this.uint8[l+6]=s,this.uint8[l+7]=o,t}}fo.prototype.bytesPerElement=8,ds("StructArrayLayout2i4ub8",fo);class yo extends oo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e){const n=this.length;return this.resize(n+1),this.emplace(n,t,e)}emplace(t,e,n){const r=2*t;return this.float32[r+0]=e,this.float32[r+1]=n,t}}yo.prototype.bytesPerElement=8,ds("StructArrayLayout2f8",yo);class mo extends oo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,n,r,i,s,o,a,l,u){const c=this.length;return this.resize(c+1),this.emplace(c,t,e,n,r,i,s,o,a,l,u)}emplace(t,e,n,r,i,s,o,a,l,u,c){const h=10*t;return this.uint16[h+0]=e,this.uint16[h+1]=n,this.uint16[h+2]=r,this.uint16[h+3]=i,this.uint16[h+4]=s,this.uint16[h+5]=o,this.uint16[h+6]=a,this.uint16[h+7]=l,this.uint16[h+8]=u,this.uint16[h+9]=c,t}}mo.prototype.bytesPerElement=20,ds("StructArrayLayout10ui20",mo);class go extends oo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,n,r,i,s,o,a){const l=this.length;return this.resize(l+1),this.emplace(l,t,e,n,r,i,s,o,a)}emplace(t,e,n,r,i,s,o,a,l){const u=8*t;return this.uint16[u+0]=e,this.uint16[u+1]=n,this.uint16[u+2]=r,this.uint16[u+3]=i,this.uint16[u+4]=s,this.uint16[u+5]=o,this.uint16[u+6]=a,this.uint16[u+7]=l,t}}go.prototype.bytesPerElement=16,ds("StructArrayLayout8ui16",go);class xo extends oo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,n,r,i,s,o,a,l,u,c,h){const p=this.length;return this.resize(p+1),this.emplace(p,t,e,n,r,i,s,o,a,l,u,c,h)}emplace(t,e,n,r,i,s,o,a,l,u,c,h,p){const f=12*t;return this.int16[f+0]=e,this.int16[f+1]=n,this.int16[f+2]=r,this.int16[f+3]=i,this.uint16[f+4]=s,this.uint16[f+5]=o,this.uint16[f+6]=a,this.uint16[f+7]=l,this.int16[f+8]=u,this.int16[f+9]=c,this.int16[f+10]=h,this.int16[f+11]=p,t}}xo.prototype.bytesPerElement=24,ds("StructArrayLayout4i4ui4i24",xo);class vo extends oo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,n)}emplace(t,e,n,r){const i=3*t;return this.float32[i+0]=e,this.float32[i+1]=n,this.float32[i+2]=r,t}}vo.prototype.bytesPerElement=12,ds("StructArrayLayout3f12",vo);class bo extends oo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}bo.prototype.bytesPerElement=4,ds("StructArrayLayout1ul4",bo);class wo extends oo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,n,r,i,s,o,a,l){const u=this.length;return this.resize(u+1),this.emplace(u,t,e,n,r,i,s,o,a,l)}emplace(t,e,n,r,i,s,o,a,l,u){const c=10*t,h=5*t;return this.int16[c+0]=e,this.int16[c+1]=n,this.int16[c+2]=r,this.int16[c+3]=i,this.int16[c+4]=s,this.int16[c+5]=o,this.uint32[h+3]=a,this.uint16[c+8]=l,this.uint16[c+9]=u,t}}wo.prototype.bytesPerElement=20,ds("StructArrayLayout6i1ul2ui20",wo);class _o extends oo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,n,r,i,s){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,n,r,i,s)}emplace(t,e,n,r,i,s,o){const a=6*t;return this.int16[a+0]=e,this.int16[a+1]=n,this.int16[a+2]=r,this.int16[a+3]=i,this.int16[a+4]=s,this.int16[a+5]=o,t}}_o.prototype.bytesPerElement=12,ds("StructArrayLayout2i2i2i12",_o);class So extends oo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,n,r,i){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,n,r,i)}emplace(t,e,n,r,i,s){const o=4*t,a=8*t;return this.float32[o+0]=e,this.float32[o+1]=n,this.float32[o+2]=r,this.int16[a+6]=i,this.int16[a+7]=s,t}}So.prototype.bytesPerElement=16,ds("StructArrayLayout2f1f2i16",So);class Ao extends oo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,n,r,i,s){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,n,r,i,s)}emplace(t,e,n,r,i,s,o){const a=16*t,l=4*t,u=8*t;return this.uint8[a+0]=e,this.uint8[a+1]=n,this.float32[l+1]=r,this.float32[l+2]=i,this.int16[u+6]=s,this.int16[u+7]=o,t}}Ao.prototype.bytesPerElement=16,ds("StructArrayLayout2ub2f2i16",Ao);class Mo extends oo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,n)}emplace(t,e,n,r){const i=3*t;return this.uint16[i+0]=e,this.uint16[i+1]=n,this.uint16[i+2]=r,t}}Mo.prototype.bytesPerElement=6,ds("StructArrayLayout3ui6",Mo);class ko extends oo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,n,r,i,s,o,a,l,u,c,h,p,f,d,y,m){const g=this.length;return this.resize(g+1),this.emplace(g,t,e,n,r,i,s,o,a,l,u,c,h,p,f,d,y,m)}emplace(t,e,n,r,i,s,o,a,l,u,c,h,p,f,d,y,m,g){const x=24*t,v=12*t,b=48*t;return this.int16[x+0]=e,this.int16[x+1]=n,this.uint16[x+2]=r,this.uint16[x+3]=i,this.uint32[v+2]=s,this.uint32[v+3]=o,this.uint32[v+4]=a,this.uint16[x+10]=l,this.uint16[x+11]=u,this.uint16[x+12]=c,this.float32[v+7]=h,this.float32[v+8]=p,this.uint8[b+36]=f,this.uint8[b+37]=d,this.uint8[b+38]=y,this.uint32[v+10]=m,this.int16[x+22]=g,t}}ko.prototype.bytesPerElement=48,ds("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",ko);class Io extends oo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,n,r,i,s,o,a,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,S,A,M,k,I){const E=this.length;return this.resize(E+1),this.emplace(E,t,e,n,r,i,s,o,a,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,S,A,M,k,I)}emplace(t,e,n,r,i,s,o,a,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,S,A,M,k,I,E){const T=32*t,F=16*t;return this.int16[T+0]=e,this.int16[T+1]=n,this.int16[T+2]=r,this.int16[T+3]=i,this.int16[T+4]=s,this.int16[T+5]=o,this.int16[T+6]=a,this.int16[T+7]=l,this.uint16[T+8]=u,this.uint16[T+9]=c,this.uint16[T+10]=h,this.uint16[T+11]=p,this.uint16[T+12]=f,this.uint16[T+13]=d,this.uint16[T+14]=y,this.uint16[T+15]=m,this.uint16[T+16]=g,this.uint16[T+17]=x,this.uint16[T+18]=v,this.uint16[T+19]=b,this.uint16[T+20]=w,this.uint16[T+21]=_,this.uint16[T+22]=S,this.uint32[F+12]=A,this.float32[F+13]=M,this.float32[F+14]=k,this.uint16[T+30]=I,this.uint16[T+31]=E,t}}Io.prototype.bytesPerElement=64,ds("StructArrayLayout8i15ui1ul2f2ui64",Io);class Eo extends oo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}Eo.prototype.bytesPerElement=4,ds("StructArrayLayout1f4",Eo);class To extends oo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,n)}emplace(t,e,n,r){const i=3*t;return this.uint16[6*t+0]=e,this.float32[i+1]=n,this.float32[i+2]=r,t}}To.prototype.bytesPerElement=12,ds("StructArrayLayout1ui2f12",To);class Fo extends oo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,n)}emplace(t,e,n,r){const i=4*t;return this.uint32[2*t+0]=e,this.uint16[i+2]=n,this.uint16[i+3]=r,t}}Fo.prototype.bytesPerElement=8,ds("StructArrayLayout1ul2ui8",Fo);class Po extends oo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e){const n=this.length;return this.resize(n+1),this.emplace(n,t,e)}emplace(t,e,n){const r=2*t;return this.uint16[r+0]=e,this.uint16[r+1]=n,t}}Po.prototype.bytesPerElement=4,ds("StructArrayLayout2ui4",Po);class Do extends oo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}Do.prototype.bytesPerElement=2,ds("StructArrayLayout1ui2",Do);class zo extends oo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,n,r){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,n,r)}emplace(t,e,n,r,i){const s=4*t;return this.float32[s+0]=e,this.float32[s+1]=n,this.float32[s+2]=r,this.float32[s+3]=i,t}}zo.prototype.bytesPerElement=16,ds("StructArrayLayout4f16",zo);class Bo extends so{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new n(this.anchorPointX,this.anchorPointY)}}Bo.prototype.size=20;class Co extends wo{get(t){return new Bo(this,t)}}ds("CollisionBoxArray",Co);class Vo extends so{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(t){this._structArray.uint8[this._pos1+37]=t;}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(t){this._structArray.uint8[this._pos1+38]=t;}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(t){this._structArray.uint32[this._pos4+10]=t;}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}Vo.prototype.size=48;class Lo extends ko{get(t){return new Vo(this,t)}}ds("PlacedSymbolArray",Lo);class Oo extends so{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(t){this._structArray.uint32[this._pos4+12]=t;}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}Oo.prototype.size=64;class $o extends Io{get(t){return new Oo(this,t)}}ds("SymbolInstanceArray",$o);class Ro extends Eo{getoffsetX(t){return this.float32[1*t+0]}}ds("GlyphOffsetArray",Ro);class No extends co{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}ds("SymbolLineVertexArray",No);class Uo extends so{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}Uo.prototype.size=12;class jo extends To{get(t){return new Uo(this,t)}}ds("TextAnchorOffsetArray",jo);class qo extends so{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}}qo.prototype.size=8;class Go extends Fo{get(t){return new qo(this,t)}}ds("FeatureIndexArray",Go);class Xo extends uo{}class Yo extends uo{}class Zo extends uo{}class Ho extends po{}class Wo extends fo{}class Ko extends yo{}class Jo extends mo{}class Qo extends go{}class ta extends xo{}class ea extends vo{}class na extends bo{}class ra extends _o{}class ia extends Ao{}class sa extends Mo{}class oa extends Po{}const aa=ao([{name:"a_pos",components:2,type:"Int16"}],4),{members:la}=aa;class ua{constructor(t=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=t;}prepareSegment(t,e,n,r){const i=this.segments[this.segments.length-1];return t>ua.MAX_VERTEX_ARRAY_LENGTH&&G(`Max vertices per segment is ${ua.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${ua.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!i||i.vertexLength+t>ua.MAX_VERTEX_ARRAY_LENGTH||i.sortKey!==r?this.createNewSegment(e,n,r):i}createNewSegment(t,e,n){const r={vertexOffset:t.length,primitiveOffset:e.length,vertexLength:0,primitiveLength:0,vaos:{}};return void 0!==n&&(r.sortKey=n),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(r),r}getOrCreateLatestSegment(t,e,n){return this.prepareSegment(0,t,e,n)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0;}get(){return this.segments}destroy(){for(const t of this.segments)for(const e in t.vaos)t.vaos[e].destroy();}static simpleSegment(t,e,n,r){return new ua([{vertexOffset:t,primitiveOffset:e,vertexLength:n,primitiveLength:r,vaos:{},sortKey:0}])}}function ca(t,e){return 256*(t=L(Math.floor(t),0,255))+L(Math.floor(e),0,255)}ua.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,ds("SegmentVector",ua);const ha=ao([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]),pa=ao([{name:"a_dasharray_from",components:4,type:"Uint16"},{name:"a_dasharray_to",components:4,type:"Uint16"}]);var fa,da,ya,ma={exports:{}},ga={exports:{}},xa={exports:{}},va=function(){if(ya)return ma.exports;ya=1;var t=(fa||(fa=1,ga.exports=function(t,e){var n,r,i,s,o,a,l,u;for(r=t.length-(n=3&t.length),i=e,o=3432918353,a=461845907,u=0;u<r;)l=255&t.charCodeAt(u)|(255&t.charCodeAt(++u))<<8|(255&t.charCodeAt(++u))<<16|(255&t.charCodeAt(++u))<<24,++u,i=27492+(65535&(s=5*(65535&(i=(i^=l=(65535&(l=(l=(65535&l)*o+(((l>>>16)*o&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|i>>>19))+((5*(i>>>16)&65535)<<16)&4294967295))+((58964+(s>>>16)&65535)<<16);switch(l=0,n){case 3:l^=(255&t.charCodeAt(u+2))<<16;case 2:l^=(255&t.charCodeAt(u+1))<<8;case 1:i^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(u)))*o+(((l>>>16)*o&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295;}return i^=t.length,i=2246822507*(65535&(i^=i>>>16))+((2246822507*(i>>>16)&65535)<<16)&4294967295,i=3266489909*(65535&(i^=i>>>13))+((3266489909*(i>>>16)&65535)<<16)&4294967295,(i^=i>>>16)>>>0}),ga.exports),e=(da||(da=1,xa.exports=function(t,e){for(var n,r=t.length,i=e^r,s=0;r>=4;)n=1540483477*(65535&(n=255&t.charCodeAt(s)|(255&t.charCodeAt(++s))<<8|(255&t.charCodeAt(++s))<<16|(255&t.charCodeAt(++s))<<24))+((1540483477*(n>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^(n=1540483477*(65535&(n^=n>>>24))+((1540483477*(n>>>16)&65535)<<16)),r-=4,++s;switch(r){case 3:i^=(255&t.charCodeAt(s+2))<<16;case 2:i^=(255&t.charCodeAt(s+1))<<8;case 1:i=1540483477*(65535&(i^=255&t.charCodeAt(s)))+((1540483477*(i>>>16)&65535)<<16);}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0}),xa.exports);return ma.exports=t,ma.exports.murmur3=t,ma.exports.murmur2=e,ma.exports}(),ba=r(va);class wa{constructor(){this.ids=[],this.positions=[],this.indexed=!1;}add(t,e,n,r){this.ids.push(_a(t)),this.positions.push(e,n,r);}getPositions(t){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const e=_a(t);let n=0,r=this.ids.length-1;for(;n<r;){const t=n+r>>1;this.ids[t]>=e?r=t:n=t+1;}const i=[];for(;this.ids[n]===e;)i.push({index:this.positions[3*n],start:this.positions[3*n+1],end:this.positions[3*n+2]}),n++;return i}static serialize(t,e){const n=new Float64Array(t.ids),r=new Uint32Array(t.positions);return Sa(n,r,0,n.length-1),e&&e.push(n.buffer,r.buffer),{ids:n,positions:r}}static deserialize(t){const e=new wa;return e.ids=t.ids,e.positions=t.positions,e.indexed=!0,e}}function _a(t){const e=+t;return !isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:ba(String(t))}function Sa(t,e,n,r){for(;n<r;){const i=t[n+r>>1];let s=n-1,o=r+1;for(;;){do{s++;}while(t[s]<i);do{o--;}while(t[o]>i);if(s>=o)break;Aa(t,s,o),Aa(e,3*s,3*o),Aa(e,3*s+1,3*o+1),Aa(e,3*s+2,3*o+2);}o-n<r-o?(Sa(t,e,n,o),n=o+1):(Sa(t,e,o+1,r),r=o);}}function Aa(t,e,n){const r=t[e];t[e]=t[n],t[n]=r;}ds("FeaturePositionMap",wa);class Ma{constructor(t,e){this.gl=t.gl,this.location=e;}}class ka extends Ma{constructor(t,e){super(t,e),this.current=0;}set(t){this.current!==t&&(this.current=t,this.gl.uniform1f(this.location,t));}}class Ia extends Ma{constructor(t,e){super(t,e),this.current=[0,0,0,0];}set(t){t[0]===this.current[0]&&t[1]===this.current[1]&&t[2]===this.current[2]&&t[3]===this.current[3]||(this.current=t,this.gl.uniform4f(this.location,t[0],t[1],t[2],t[3]));}}class Ea extends Ma{constructor(t,e){super(t,e),this.current=Te.transparent;}set(t){t.r===this.current.r&&t.g===this.current.g&&t.b===this.current.b&&t.a===this.current.a||(this.current=t,this.gl.uniform4f(this.location,t.r,t.g,t.b,t.a));}}const Ta=new Float32Array(16);function Fa(t){return [ca(255*t.r,255*t.g),ca(255*t.b,255*t.a)]}class Pa{constructor(t,e,n){this.value=t,this.uniformNames=e.map((t=>`u_${t}`)),this.type=n;}setUniform(t,e,n){t.set(n.constantOr(this.value));}getBinding(t,e,n){return "color"===this.type?new Ea(t,e):new ka(t,e)}}class Da{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1;}setConstantPatternPositions(t,e){this.pixelRatioFrom=e.pixelRatio,this.pixelRatioTo=t.pixelRatio,this.patternFrom=e.tlbr,this.patternTo=t.tlbr;}setConstantDashPositions(t,e){this.dashTo=[0,t.y,t.height,t.width],this.dashFrom=[0,e.y,e.height,e.width];}setUniform(t,e,n,r){let i=null;"u_pattern_to"===r?i=this.patternTo:"u_pattern_from"===r?i=this.patternFrom:"u_dasharray_to"===r?i=this.dashTo:"u_dasharray_from"===r?i=this.dashFrom:"u_pixel_ratio_to"===r?i=this.pixelRatioTo:"u_pixel_ratio_from"===r&&(i=this.pixelRatioFrom),null!==i&&t.set(i);}getBinding(t,e,n){return n.startsWith("u_pattern")||n.startsWith("u_dasharray_")?new Ia(t,e):new ka(t,e)}}class za{constructor(t,e,n,r){this.expression=t,this.type=n,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===n?2:1,offset:0}))),this.paintVertexArray=new r;}populatePaintArray(t,e,n){const r=this.paintVertexArray.length,i=this.expression.evaluate(new Cs(0,n),e,{},n.canonical,[],n.formattedSection);this.paintVertexArray.resize(t),this._setPaintValue(r,t,i);}updatePaintArray(t,e,n,r,i){const s=this.expression.evaluate(new Cs(0,i),n,r);this._setPaintValue(t,e,s);}_setPaintValue(t,e,n){if("color"===this.type){const r=Fa(n);for(let n=t;n<e;n++)this.paintVertexArray.emplace(n,r[0],r[1]);}else {for(let r=t;r<e;r++)this.paintVertexArray.emplace(r,n);this.maxValue=Math.max(this.maxValue,Math.abs(n));}}upload(t){var e,n;(null===(e=this.paintVertexArray)||void 0===e?void 0:e.arrayBuffer.byteLength)&&((null===(n=this.paintVertexBuffer)||void 0===n?void 0:n.buffer)?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent));}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy();}}class Ba{constructor(t,e,n,r,i,s){this.expression=t,this.uniformNames=e.map((t=>`u_${t}_t`)),this.type=n,this.useIntegerZoom=r,this.zoom=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===n?4:2,offset:0}))),this.paintVertexArray=new s;}populatePaintArray(t,e,n){const r=this.expression.evaluate(new Cs(this.zoom,n),e,{},n.canonical,[],n.formattedSection),i=this.expression.evaluate(new Cs(this.zoom+1,n),e,{},n.canonical,[],n.formattedSection),s=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(s,t,r,i);}updatePaintArray(t,e,n,r,i){const s=this.expression.evaluate(new Cs(this.zoom,i),n,r),o=this.expression.evaluate(new Cs(this.zoom+1,i),n,r);this._setPaintValue(t,e,s,o);}_setPaintValue(t,e,n,r){if("color"===this.type){const i=Fa(n),s=Fa(r);for(let n=t;n<e;n++)this.paintVertexArray.emplace(n,i[0],i[1],s[0],s[1]);}else {for(let i=t;i<e;i++)this.paintVertexArray.emplace(i,n,r);this.maxValue=Math.max(this.maxValue,Math.abs(n),Math.abs(r));}}upload(t){var e,n;(null===(e=this.paintVertexArray)||void 0===e?void 0:e.arrayBuffer.byteLength)&&((null===(n=this.paintVertexBuffer)||void 0===n?void 0:n.buffer)?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent));}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy();}setUniform(t,e){const n=this.useIntegerZoom?Math.floor(e.zoom):e.zoom,r=L(this.expression.interpolationFactor(n,this.zoom,this.zoom+1),0,1);t.set(r);}getBinding(t,e,n){return new ka(t,e)}}class Ca{constructor(t,e,n,r,i,s){this.expression=t,this.type=e,this.useIntegerZoom=n,this.zoom=r,this.layerId=s,this.zoomInPaintVertexArray=new i,this.zoomOutPaintVertexArray=new i;}populatePaintArray(t,e,n){const r=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(t),this.zoomOutPaintVertexArray.resize(t),this._setPaintValues(r,t,this.getPositionIds(e),n);}updatePaintArray(t,e,n,r,i){this._setPaintValues(t,e,this.getPositionIds(n),i);}_setPaintValues(t,e,n,r){const i=this.getPositions(r);if(!i||!n)return;const s=i[n.min],o=i[n.mid],a=i[n.max];if(s&&o&&a)for(let n=t;n<e;n++)this.emplace(this.zoomInPaintVertexArray,n,o,s),this.emplace(this.zoomOutPaintVertexArray,n,o,a);}upload(t){var e,n;if((null===(e=this.zoomInPaintVertexArray)||void 0===e?void 0:e.arrayBuffer.byteLength)&&(null===(n=this.zoomOutPaintVertexArray)||void 0===n?void 0:n.arrayBuffer.byteLength)){const e=this.getVertexAttributes();this.zoomInPaintVertexBuffer=t.createVertexBuffer(this.zoomInPaintVertexArray,e,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=t.createVertexBuffer(this.zoomOutPaintVertexArray,e,this.expression.isStateDependent);}}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy();}}class Va extends Ca{getPositions(t){return t.imagePositions}getPositionIds(t){var e;return null===(e=t.patterns)||void 0===e?void 0:e[this.layerId]}getVertexAttributes(){return ha.members}emplace(t,e,n,r){t.emplace(e,n.tlbr[0],n.tlbr[1],n.tlbr[2],n.tlbr[3],r.tlbr[0],r.tlbr[1],r.tlbr[2],r.tlbr[3],n.pixelRatio,r.pixelRatio);}}class La extends Ca{getPositions(t){return t.dashPositions}getPositionIds(t){var e;return null===(e=t.dashes)||void 0===e?void 0:e[this.layerId]}getVertexAttributes(){return pa.members}emplace(t,e,n,r){t.emplace(e,0,n.y,n.height,n.width,0,r.y,r.height,r.width);}}class Oa{constructor(t,e,n){this.binders={},this._buffers=[];const r=[];for(const i in t.paint._values){if(!n(i))continue;const s=t.paint.get(i);if(!(s instanceof qs&&Gr(s.property.specification)))continue;const o=Ra(i,t.type),a=s.value,l=s.property.specification.type,u=s.property.useIntegerZoom,c=s.property.specification["property-type"],h="cross-faded"===c||"cross-faded-data-driven"===c;if("constant"===a.kind)this.binders[i]=h?new Da(a.value,o):new Pa(a.value,o,l),r.push(`/u_${i}`);else if("source"===a.kind||h){const n=Na(i,l,"source");this.binders[i]=h?"line-dasharray"===i?new La(a,l,u,e,n,t.id):new Va(a,l,u,e,n,t.id):new za(a,o,l,n),r.push(`/a_${i}`);}else {const t=Na(i,l,"composite");this.binders[i]=new Ba(a,o,l,u,e,t),r.push(`/z_${i}`);}}this.cacheKey=r.sort().join("");}getMaxValue(t){const e=this.binders[t];return e instanceof za||e instanceof Ba?e.maxValue:0}populatePaintArrays(t,e,n){for(const r in this.binders){const i=this.binders[r];(i instanceof za||i instanceof Ba||i instanceof Ca)&&i.populatePaintArray(t,e,n);}}setConstantPatternPositions(t,e){for(const n in this.binders){const r=this.binders[n];r instanceof Da&&r.setConstantPatternPositions(t,e);}}setConstantDashPositions(t,e){for(const n in this.binders){const r=this.binders[n];r instanceof Da&&r.setConstantDashPositions(t,e);}}updatePaintArrays(t,e,n,r,i){let s=!1;for(const o in t){const a=e.getPositions(o);for(const e of a){const a=n.feature(e.index);for(const n in this.binders){const l=this.binders[n];if((l instanceof za||l instanceof Ba||l instanceof Ca)&&!0===l.expression.isStateDependent){const u=r.paint.get(n);l.expression=u.value,l.updatePaintArray(e.start,e.end,a,t[o],i),s=!0;}}}}return s}defines(){const t=[];for(const e in this.binders){const n=this.binders[e];(n instanceof Pa||n instanceof Da)&&t.push(...n.uniformNames.map((t=>`#define HAS_UNIFORM_${t}`)));}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const n=this.binders[e];if(n instanceof za||n instanceof Ba)for(const e of n.paintVertexAttributes)t.push(e.name);else if(n instanceof Ca){const e=n.getVertexAttributes();for(const n of e)t.push(n.name);}}return t}getBinderUniforms(){const t=[];for(const e in this.binders){const n=this.binders[e];if(n instanceof Pa||n instanceof Da||n instanceof Ba)for(const e of n.uniformNames)t.push(e);}return t}getPaintVertexBuffers(){return this._buffers}getUniforms(t,e){const n=[];for(const r in this.binders){const i=this.binders[r];if(i instanceof Pa||i instanceof Da||i instanceof Ba)for(const s of i.uniformNames)if(e[s]){const o=i.getBinding(t,e[s],s);n.push({name:s,property:r,binding:o});}}return n}setUniforms(t,e,n,r){for(const{name:t,property:i,binding:s}of e)this.binders[i].setUniform(s,r,n.get(i),t);}updatePaintBuffers(t){this._buffers=[];for(const e in this.binders){const n=this.binders[e];if(t&&n instanceof Ca){const e=2===t.fromScale?n.zoomInPaintVertexBuffer:n.zoomOutPaintVertexBuffer;e&&this._buffers.push(e);}else (n instanceof za||n instanceof Ba)&&n.paintVertexBuffer&&this._buffers.push(n.paintVertexBuffer);}}upload(t){for(const e in this.binders){const n=this.binders[e];(n instanceof za||n instanceof Ba||n instanceof Ca)&&n.upload(t);}this.updatePaintBuffers();}destroy(){for(const t in this.binders){const e=this.binders[t];(e instanceof za||e instanceof Ba||e instanceof Ca)&&e.destroy();}}}class $a{constructor(t,e,n=()=>!0){this.programConfigurations={};for(const r of t)this.programConfigurations[r.id]=new Oa(r,e,n);this.needsUpload=!1,this._featureMap=new wa,this._bufferOffset=0;}populatePaintArrays(t,e,n,r){for(const n in this.programConfigurations)this.programConfigurations[n].populatePaintArrays(t,e,r);void 0!==e.id&&this._featureMap.add(e.id,n,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0;}updatePaintArrays(t,e,n,r){for(const i of n)this.needsUpload=this.programConfigurations[i.id].updatePaintArrays(t,this._featureMap,e,i,r)||this.needsUpload;}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1;}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy();}}function Ra(t,e){return {"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-dasharray":["dasharray_to","dasharray_from"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}function Na(t,e,n){const r={color:{source:yo,composite:zo},number:{source:Eo,composite:yo}},i=function(t){return {"line-pattern":{source:Jo,composite:Jo},"fill-pattern":{source:Jo,composite:Jo},"fill-extrusion-pattern":{source:Jo,composite:Jo},"line-dasharray":{source:Qo,composite:Qo}}[t]}(t);return (null==i?void 0:i[n])||r[e][n]}ds("ConstantBinder",Pa),ds("CrossFadedConstantBinder",Da),ds("SourceExpressionBinder",za),ds("CrossFadedPatternBinder",Va),ds("CrossFadedDasharrayBinder",La),ds("CompositeExpressionBinder",Ba),ds("ProgramConfiguration",Oa,{omit:["_buffers"]}),ds("ProgramConfigurationSet",$a);const Ua=Math.pow(2,14)-1,ja=-Ua-1;function qa(t){const e=T/t.extent,n=t.loadGeometry();for(const t of n)for(const n of t){const t=Math.round(n.x*e),r=Math.round(n.y*e);n.x=L(t,ja,Ua),n.y=L(r,ja,Ua),(t<n.x||t>n.x+1||r<n.y||r>n.y+1)&&G("Geometry exceeds allowed extent, reduce your vector tile buffer size");}return n}function Ga(t,e){return {type:t.type,id:t.id,properties:t.properties,geometry:e?qa(t):[]}}const Xa=-32768;function Ya(t,e,n,r,i){t.emplaceBack(Xa+8*e+r,Xa+8*n+i);}class Za{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasDependencies=!1,this.layoutVertexArray=new Yo,this.indexArray=new sa,this.segments=new ua,this.programConfigurations=new $a(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,n){const r=this.layers[0],i=[];let s=null,o=!1,a="heatmap"===r.type;if("circle"===r.type){const t=r;s=t.layout.get("circle-sort-key"),o=!s.isConstant(),a||(a="map"===t.paint.get("circle-pitch-alignment"));}const l=a?e.subdivisionGranularity.circle:1;for(const{feature:e,id:r,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,u=Ga(e,t);if(!this.layers[0]._featureFilter.filter(new Cs(this.zoom),u,n))continue;const c=o?s.evaluate(u,{},n):void 0,h={id:r,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?u.geometry:qa(e),patterns:{},sortKey:c};i.push(h);}o&&i.sort(((t,e)=>t.sortKey-e.sortKey));for(const r of i){const{geometry:i,index:s,sourceLayerIndex:o}=r,a=t[s].feature;this.addFeature(r,i,s,n,l),e.featureIndex.insert(a,i,s,o,this.index);}}update(t,e,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,{imagePositions:n});}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,la),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}addFeature(t,e,n,r,i=1){let s;switch(i){case 1:s=[0,7];break;case 3:s=[0,2,5,7];break;case 5:s=[0,1,3,4,6,7];break;case 7:s=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${i}; valid values are 1, 3, 5, 7.`)}const o=s.length;for(const n of e)for(const e of n){const n=e.x,r=e.y;if(n<0||n>=T||r<0||r>=T)continue;const i=this.segments.prepareSegment(o*o,this.layoutVertexArray,this.indexArray,t.sortKey),a=i.vertexLength;for(let t=0;t<o;t++)for(let e=0;e<o;e++)Ya(this.layoutVertexArray,n,r,s[e],s[t]);for(let t=0;t<o-1;t++)for(let e=0;e<o-1;e++){const n=a+t*o+e,r=a+(t+1)*o+e;this.indexArray.emplaceBack(n,r+1,n+1),this.indexArray.emplaceBack(n,r,r+1);}i.vertexLength+=o*o,i.primitiveLength+=(o-1)*(o-1)*2;}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,n,{imagePositions:{},canonical:r});}}function Ha(t,e){for(const n of t)if(il(e,n))return !0;for(const n of e)if(il(t,n))return !0;return Qa(t,e)}function Wa(t,e,n){return !!il(t,e)||el(e,t,n)}function Ka(t,e){if(1===t.length)return rl(e,t[0]);for(const n of e)for(const e of n)if(il(t,e))return !0;for(const n of t)if(rl(e,n))return !0;for(const n of e)if(Qa(t,n))return !0;return !1}function Ja(t,e,n){if(t.length>1){if(Qa(t,e))return !0;for(const r of e)if(el(r,t,n))return !0}for(const r of t)if(el(r,e,n))return !0;return !1}function Qa(t,e){if(0===t.length||0===e.length)return !1;for(let n=0;n<t.length-1;n++){const r=t[n],i=t[n+1];for(let t=0;t<e.length-1;t++)if(tl(r,i,e[t],e[t+1]))return !0}return !1}function tl(t,e,n,r){return X(t,n,r)!==X(e,n,r)&&X(t,e,n)!==X(t,e,r)}function el(t,e,n){const r=n*n;if(1===e.length)return t.distSqr(e[0])<r;for(let n=1;n<e.length;n++)if(nl(t,e[n-1],e[n])<r)return !0;return !1}function nl(t,e,n){const r=e.distSqr(n);if(0===r)return t.distSqr(e);const i=((t.x-e.x)*(n.x-e.x)+(t.y-e.y)*(n.y-e.y))/r;return t.distSqr(i<0?e:i>1?n:n.sub(e)._mult(i)._add(e))}function rl(t,e){let n,r,i,s=!1;for(const o of t){n=o;for(let t=0,o=n.length-1;t<n.length;o=t++)r=n[t],i=n[o],r.y>e.y!=i.y>e.y&&e.x<(i.x-r.x)*(e.y-r.y)/(i.y-r.y)+r.x&&(s=!s);}return s}function il(t,e){let n=!1;for(let r=0,i=t.length-1;r<t.length;i=r++){const s=t[r],o=t[i];s.y>e.y!=o.y>e.y&&e.x<(o.x-s.x)*(e.y-s.y)/(o.y-s.y)+s.x&&(n=!n);}return n}function sl(t,e,n){const r=n[0],i=n[2];if(t.x<r.x&&e.x<r.x||t.x>i.x&&e.x>i.x||t.y<r.y&&e.y<r.y||t.y>i.y&&e.y>i.y)return !1;const s=X(t,e,n[0]);return s!==X(t,e,n[1])||s!==X(t,e,n[2])||s!==X(t,e,n[3])}function ol(t,e,n){const r=e.paint.get(t).value;return "constant"===r.kind?r.value:n.programConfigurations.get(e.id).getMaxValue(t)}function al(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function ll(t,e,r,i,s){if(!e[0]&&!e[1])return t;const o=n.convert(e)._mult(s);"viewport"===r&&o._rotate(-i);const a=[];for(const e of t)a.push(e.sub(o));return a}function ul(t){const e=[];for(let n=0;n<t.length;n++){const r=t[n],i=e.at(-1);(0===n||i&&!r.equals(i))&&e.push(r);}return e}function cl({queryGeometry:t,size:e},n){return Wa(t,n,e)}function hl({queryGeometry:t,size:e,transform:n,unwrappedTileID:r,getElevation:i},s){return Wa(t,s,e*(n.projectTileCoordinates(s.x,s.y,r,i).signedDistanceFromCamera/n.cameraToCenterDistance))}function pl({queryGeometry:t,size:e,transform:n,unwrappedTileID:r,getElevation:i},s){const o=n.projectTileCoordinates(s.x,s.y,r,i).signedDistanceFromCamera,a=e*(n.cameraToCenterDistance/o);return Wa(t,yl(s,n,r,i),a)}function fl({queryGeometry:t,size:e,transform:n,unwrappedTileID:r,getElevation:i},s){return Wa(t,yl(s,n,r,i),e)}function dl({queryGeometry:t,size:e,transform:n,unwrappedTileID:r,getElevation:i,pitchAlignment:s="map",pitchScale:o="map"},a){const l="map"===s?"map"===o?cl:hl:"map"===o?pl:fl,u={queryGeometry:t,size:e,transform:n,unwrappedTileID:r,getElevation:i};for(const t of a)for(const e of t)if(l(u,e))return !0;return !1}function yl(t,e,r,i){const s=e.projectTileCoordinates(t.x,t.y,r,i).point;return new n((.5*s.x+.5)*e.width,(.5*-s.y+.5)*e.height)}let ml,gl;ds("CircleBucket",Za,{omit:["layers"]});var xl={get paint(){return gl=gl||new Ks({"circle-radius":new Ys(wt.paint_circle["circle-radius"]),"circle-color":new Ys(wt.paint_circle["circle-color"]),"circle-blur":new Ys(wt.paint_circle["circle-blur"]),"circle-opacity":new Ys(wt.paint_circle["circle-opacity"]),"circle-translate":new Xs(wt.paint_circle["circle-translate"]),"circle-translate-anchor":new Xs(wt.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new Xs(wt.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new Xs(wt.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new Ys(wt.paint_circle["circle-stroke-width"]),"circle-stroke-color":new Ys(wt.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new Ys(wt.paint_circle["circle-stroke-opacity"])})},get layout(){return ml=ml||new Ks({"circle-sort-key":new Ys(wt.layout_circle["circle-sort-key"])})}};class vl extends to{constructor(t,e){super(t,xl,e);}createBucket(t){return new Za(t)}queryRadius(t){const e=t;return ol("circle-radius",this,e)+ol("circle-stroke-width",this,e)+al(this.paint.get("circle-translate"))}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:n,geometry:r,transform:i,pixelsToTileUnits:s,unwrappedTileID:o,getElevation:a}){const l=ll(t,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),-i.bearingInRadians,s),u=this.paint.get("circle-radius").evaluate(e,n)+this.paint.get("circle-stroke-width").evaluate(e,n),c=this.paint.get("circle-pitch-scale"),h=this.paint.get("circle-pitch-alignment");let p,f;return "map"===h?(p=l,f=u*s):(p=function(t,e,n,r){return t.map((t=>yl(t,e,n,r)))}(l,i,o,a),f=u),dl({queryGeometry:p,size:f,transform:i,unwrappedTileID:o,getElevation:a,pitchAlignment:h,pitchScale:c},r)}}class bl extends Za{}let wl;ds("HeatmapBucket",bl,{omit:["layers"]});var _l={get paint(){return wl=wl||new Ks({"heatmap-radius":new Ys(wt.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Ys(wt.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Xs(wt.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Ws(wt.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Xs(wt.paint_heatmap["heatmap-opacity"])})}};function Sl(t,{width:e,height:n},r,i){if(i){if(i instanceof Uint8ClampedArray)i=new Uint8Array(i.buffer);else if(i.length!==e*n*r)throw new RangeError(`mismatched image size. expected: ${i.length} but got: ${e*n*r}`)}else i=new Uint8Array(e*n*r);return t.width=e,t.height=n,t.data=i,t}function Al(t,{width:e,height:n},r){if(e===t.width&&n===t.height)return;const i=Sl({},{width:e,height:n},r);Ml(t,i,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,e),height:Math.min(t.height,n)},r),t.width=e,t.height=n,t.data=i.data;}function Ml(t,e,n,r,i,s){if(0===i.width||0===i.height)return e;if(i.width>t.width||i.height>t.height||n.x>t.width-i.width||n.y>t.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>e.width||i.height>e.height||r.x>e.width-i.width||r.y>e.height-i.height)throw new RangeError("out of range destination coordinates for image copy");const o=t.data,a=e.data;if(o===a)throw new Error("srcData equals dstData, so image is already copied");for(let l=0;l<i.height;l++){const u=((n.y+l)*t.width+n.x)*s,c=((r.y+l)*e.width+r.x)*s;for(let t=0;t<i.width*s;t++)a[c+t]=o[u+t];}return e}class kl{constructor(t,e){Sl(this,t,1,e);}resize(t){Al(this,t,1);}clone(){return new kl({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,n,r,i){Ml(t,e,n,r,i,1);}}class Il{constructor(t,e){Sl(this,t,4,e);}resize(t){Al(this,t,4);}replace(t,e){e?this.data.set(t):this.data=t instanceof Uint8ClampedArray?new Uint8Array(t.buffer):t;}clone(){return new Il({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,n,r,i){Ml(t,e,n,r,i,4);}setPixel(t,e,n){const r=4*(t*this.width+e);this.data[r+0]=Math.round(255*n.r/n.a),this.data[r+1]=Math.round(255*n.g/n.a),this.data[r+2]=Math.round(255*n.b/n.a),this.data[r+3]=Math.round(255*n.a);}}function El(t){const e=new Uint8Array(t.length);for(let n=0;n<t.length;n+=4){const r=t[n+3];e[n+0]=Math.round(t[n+0]*r/255),e[n+1]=Math.round(t[n+1]*r/255),e[n+2]=Math.round(t[n+2]*r/255),e[n+3]=r;}return e}function Tl(t){const e={},n=t.resolution||256,r=t.clips?t.clips.length:1,i=t.image||new Il({width:n,height:r});if(Math.log(n)/Math.LN2%1!=0)throw new Error(`width is not a power of 2 - ${n}`);const s=(r,s,o)=>{e[t.evaluationKey]=o;const a=t.expression.evaluate(e);i.setPixel(r/4/n,s/4,a);};if(t.clips)for(let e=0,i=0;e<r;++e,i+=4*n)for(let r=0,o=0;r<n;r++,o+=4){const a=r/(n-1),{start:l,end:u}=t.clips[e];s(i,o,l*(1-a)+u*a);}else for(let t=0,e=0;t<n;t++,e+=4)s(0,e,t/(n-1));return i}ds("AlphaImage",kl),ds("RGBAImage",Il);const Fl="big-fb";class Pl extends to{createBucket(t){return new bl(t)}constructor(t,e){super(t,_l,e),this.heatmapFbos=new Map,this._updateColorRamp();}_handleSpecialPaintPropertyUpdate(t){"heatmap-color"===t&&this._updateColorRamp();}_updateColorRamp(){this.colorRamp=Tl({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null;}resize(){this.heatmapFbos.has(Fl)&&this.heatmapFbos.delete(Fl);}queryRadius(t){return ol("heatmap-radius",this,t)}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:n,geometry:r,transform:i,pixelsToTileUnits:s,unwrappedTileID:o,getElevation:a}){return dl({queryGeometry:t,size:this.paint.get("heatmap-radius").evaluate(e,n)*s,transform:i,unwrappedTileID:o,getElevation:a},r)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&!this.isHidden()}}let Dl;var zl={get paint(){return Dl=Dl||new Ks({"hillshade-illumination-direction":new Xs(wt.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-altitude":new Xs(wt.paint_hillshade["hillshade-illumination-altitude"]),"hillshade-illumination-anchor":new Xs(wt.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new Xs(wt.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new Xs(wt.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new Xs(wt.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new Xs(wt.paint_hillshade["hillshade-accent-color"]),"hillshade-method":new Xs(wt.paint_hillshade["hillshade-method"]),resampling:new Xs(wt.paint_hillshade.resampling)})}};class Bl extends to{constructor(t,e){super(t,zl,e),this.recalculate({zoom:0,zoomHistory:{}},void 0);}getIlluminationProperties(){let t=this.paint.get("hillshade-illumination-direction").values,e=this.paint.get("hillshade-illumination-altitude").values,n=this.paint.get("hillshade-highlight-color").values,r=this.paint.get("hillshade-shadow-color").values;const i=Math.max(t.length,e.length,n.length,r.length);t=t.concat(Array(i-t.length).fill(t.at(-1))),e=e.concat(Array(i-e.length).fill(e.at(-1))),n=n.concat(Array(i-n.length).fill(n.at(-1))),r=r.concat(Array(i-r.length).fill(r.at(-1)));const s=e.map(et);return {directionRadians:t.map(et),altitudeRadians:s,shadowColor:r,highlightColor:n}}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&!this.isHidden()}}let Cl;var Vl={get paint(){return Cl=Cl||new Ks({"color-relief-opacity":new Xs(wt["paint_color-relief"]["color-relief-opacity"]),"color-relief-color":new Ws(wt["paint_color-relief"]["color-relief-color"]),resampling:new Xs(wt["paint_color-relief"].resampling)})}};function Ll(t){return "data"in t}class Ol{constructor(t,e,n,r){this.context=t,this.format=n,this.texture=t.gl.createTexture(),this._ownedHandle=this.texture,this.update(e,r);}update(t,e,n){var r;const{width:i,height:s}=t,o=((null===(r=this.size)||void 0===r?void 0:r[0])!==i||this.size[1]!==s)&&!n,{context:a}=this,{gl:l}=a;this.useMipmap=Boolean(null==e?void 0:e.useMipmap),l.bindTexture(l.TEXTURE_2D,this.texture),a.pixelStoreUnpackFlipY.set(!1),a.pixelStoreUnpack.set(1);const u=this.format===l.RGBA&&!1!==(null==e?void 0:e.premultiply);if(o)this.size=[i,s],Ll(t)?(a.pixelStoreUnpackPremultiplyAlpha.set(!1),this._uploadRawData(t,u,i,s,l)):(a.pixelStoreUnpackPremultiplyAlpha.set(u),this._uploadDomImage(t,l));else {const{x:e,y:r}=n||{x:0,y:0};Ll(t)?(a.pixelStoreUnpackPremultiplyAlpha.set(!1),this._updateRawData(t,u,e,r,i,s,l)):(a.pixelStoreUnpackPremultiplyAlpha.set(u),this._updateDomImage(t,e,r,l));}this.useMipmap&&this.isSizePowerOfTwo()&&l.generateMipmap(l.TEXTURE_2D),a.pixelStoreUnpackFlipY.setDefault(),a.pixelStoreUnpack.setDefault(),a.pixelStoreUnpackPremultiplyAlpha.setDefault();}_uploadDomImage(t,e){e.texImage2D(e.TEXTURE_2D,0,this.format,this.format,e.UNSIGNED_BYTE,t);}_uploadRawData(t,e,n,r,i){let{data:s}=t;e&&s&&(s=El(s)),i.texImage2D(i.TEXTURE_2D,0,this.format,n,r,0,this.format,i.UNSIGNED_BYTE,s);}_updateDomImage(t,e,n,r){r.texSubImage2D(r.TEXTURE_2D,0,e,n,r.RGBA,r.UNSIGNED_BYTE,t);}_updateRawData(t,e,n,r,i,s,o){let{data:a}=t;e&&a&&(a=El(a)),o.texSubImage2D(o.TEXTURE_2D,0,n,r,i,s,o.RGBA,o.UNSIGNED_BYTE,a);}bind(t,e,n){const{context:r}=this,{gl:i}=r;this.texture!==this._ownedHandle&&(this.texture=this._ownedHandle),i.bindTexture(i.TEXTURE_2D,this.texture),n!==i.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(n=i.LINEAR),t!==this.filter&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,n||t),this.filter=t),e!==this.wrap&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,e),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,e),this.wrap=e);}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null,this._ownedHandle=null;}}class $l{constructor(t,e,n,r=1,i=1,s=1,o=0){if(this.uid=t,e.height!==e.width)throw new RangeError("DEM tiles must be square");if(n&&!["mapbox","terrarium","custom"].includes(n))return void G(`"${n}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);this.stride=e.height;const a=this.dim=e.height-2;switch(this.data=new Uint32Array(e.data.buffer),n){case "terrarium":this.redFactor=256,this.greenFactor=1,this.blueFactor=1/256,this.baseShift=32768;break;case "custom":this.redFactor=r,this.greenFactor=i,this.blueFactor=s,this.baseShift=o;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4;}for(let t=0;t<a;t++)this.data[this._idx(-1,t)]=this.data[this._idx(0,t)],this.data[this._idx(a,t)]=this.data[this._idx(a-1,t)],this.data[this._idx(t,-1)]=this.data[this._idx(t,0)],this.data[this._idx(t,a)]=this.data[this._idx(t,a-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(a,-1)]=this.data[this._idx(a-1,0)],this.data[this._idx(-1,a)]=this.data[this._idx(0,a-1)],this.data[this._idx(a,a)]=this.data[this._idx(a-1,a-1)],this.min=Number.MAX_SAFE_INTEGER,this.max=Number.MIN_SAFE_INTEGER;for(let t=0;t<a;t++)for(let e=0;e<a;e++){const n=this.get(t,e);n>this.max&&(this.max=n),n<this.min&&(this.min=n);}}get(t,e){const n=new Uint8Array(this.data.buffer),r=4*this._idx(t,e);return this.unpack(n[r],n[r+1],n[r+2])}getUnpackVector(){return [this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_idx(t,e){if(t<-1||t>=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError(`Out of range source coordinates for DEM data. x: ${t}, y: ${e}, dim: ${this.dim}`);return (e+1)*this.stride+(t+1)}unpack(t,e,n){return t*this.redFactor+e*this.greenFactor+n*this.blueFactor-this.baseShift}pack(t){return Rl(t,this.getUnpackVector())}getPixels(){return new Il({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(t,e,n){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let r=e*this.dim,i=e*this.dim+this.dim,s=n*this.dim,o=n*this.dim+this.dim;switch(e){case -1:r=i-1;break;case 1:i=r+1;}switch(n){case -1:s=o-1;break;case 1:o=s+1;}const a=-e*this.dim,l=-n*this.dim;for(let e=s;e<o;e++)for(let n=r;n<i;n++)this.data[this._idx(n,e)]=t.data[this._idx(n+a,e+l)];}}function Rl(t,e){const n=e[0],r=e[1],i=e[2],s=e[3],o=Math.min(n,r,i),a=Math.round((t+s)/o);return {r:Math.floor(a*o/n)%256,g:Math.floor(a*o/r)%256,b:Math.floor(a*o/i)%256}}ds("DEMData",$l);class Nl extends to{constructor(t,e){super(t,Vl,e);}_createColorRamp(t){const e={elevationStops:[],colorStops:[]},n=this._transitionablePaint._values["color-relief-color"].value.expression;if(n instanceof oi&&n._styleExpression.expression instanceof mn){this.colorRampExpression=n;const t=n._styleExpression.expression;e.elevationStops=t.labels,e.colorStops=[];for(const n of e.elevationStops)e.colorStops.push(t.evaluate({globals:{elevation:n}}));}if(e.elevationStops.length<1&&(e.elevationStops=[0],e.colorStops=[Te.transparent]),e.elevationStops.length<2&&(e.elevationStops.push(e.elevationStops[0]+1),e.colorStops.push(e.colorStops[0])),e.elevationStops.length<=t)return e;const r={elevationStops:[],colorStops:[]},i=(e.elevationStops.length-1)/(t-1);for(let t=0;t<e.elevationStops.length-.5;t+=i)r.elevationStops.push(e.elevationStops[Math.round(t)]),r.colorStops.push(e.colorStops[Math.round(t)]);return G(`Too many colors in specification of ${this.id} color-relief layer, may not render properly. Max possible colors: ${t}, provided: ${e.elevationStops.length}`),r}_colorRampChanged(){return this.colorRampExpression!=this._transitionablePaint._values["color-relief-color"].value.expression}getColorRampTextures(t,e,n){if(this.colorRampTextures&&!this._colorRampChanged())return this.colorRampTextures;const r=this._createColorRamp(e),i=new Il({width:r.colorStops.length,height:1}),s=new Il({width:r.colorStops.length,height:1});for(let t=0;t<r.elevationStops.length;t++){const e=Rl(r.elevationStops[t],n);s.setPixel(0,t,new Te(e.r/255,e.g/255,e.b/255,1)),i.setPixel(0,t,r.colorStops[t]);}return this.colorRampTextures={elevationTexture:new Ol(t,s,t.gl.RGBA),colorTexture:new Ol(t,i,t.gl.RGBA)},this.colorRampTextures}hasOffscreenPass(){return !this.isHidden()&&!!this.colorRampTextures}}const Ul=ao([{name:"a_pos",components:2,type:"Int16"}],4),{members:jl}=Ul;function ql(t,e,n){const r=n.patternDependencies;let i=!1;for(const n of e){const e=n.paint.get(`${t}-pattern`);e.isConstant()||(i=!0);const s=e.constantOr(null);s&&(i=!0,r[s.to]=!0,r[s.from]=!0);}return i}function Gl(t,e,n,r,i){const{zoom:s}=r,o=i.patternDependencies;for(const r of e){const e=r.paint.get(`${t}-pattern`).value;if("constant"!==e.kind){let t=e.evaluate({zoom:s-1},n,{},i.availableImages),a=e.evaluate({zoom:s},n,{},i.availableImages),l=e.evaluate({zoom:s+1},n,{},i.availableImages);t=(null==t?void 0:t.name)?t.name:t,a=(null==a?void 0:a.name)?a.name:a,l=(null==l?void 0:l.name)?l.name:l,o[t]=!0,o[a]=!0,o[l]=!0,n.patterns[r.id]={min:t,mid:a,max:l};}}return n}function Xl(t,e,n,r,i){let s;if(i===function(t,e,n,r){let i=0;for(let s=e,o=n-r;s<n;s+=r)i+=(t[o]-t[s])*(t[s+1]+t[o+1]),o=s;return i}(t,e,n,r)>0)for(let i=e;i<n;i+=r)s=du(i/r|0,t[i],t[i+1],s);else for(let i=n-r;i>=e;i-=r)s=du(i/r|0,t[i],t[i+1],s);return s&&lu(s,s.next)&&(yu(s),s=s.next),s}function Yl(t,e){if(!t)return t;e||(e=t);let n,r=t;do{if(n=!1,r.steiner||!lu(r,r.next)&&0!==au(r.prev,r,r.next))r=r.next;else {if(yu(r),r=e=r.prev,r===r.next)break;n=!0;}}while(n||r!==e);return e}function Zl(t,e,n,r,i,s,o){if(!t)return;!o&&s&&function(t,e,n,r){let i=t;do{0===i.z&&(i.z=nu(i.x,i.y,e,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){let e,n=1;do{let r,i=t;t=null;let s=null;for(e=0;i;){e++;let o=i,a=0;for(let t=0;t<n&&(a++,o=o.nextZ,o);t++);let l=n;for(;a>0||l>0&&o;)0!==a&&(0===l||!o||i.z<=o.z)?(r=i,i=i.nextZ,a--):(r=o,o=o.nextZ,l--),s?s.nextZ=r:t=r,r.prevZ=s,s=r;i=o;}s.nextZ=null,n*=2;}while(e>1)}(i);}(t,r,i,s);let a=t;for(;t.prev!==t.next;){const l=t.prev,u=t.next;if(s?Wl(t,r,i,s):Hl(t))e.push(l.i,t.i,u.i),yu(t),t=u.next,a=u.next;else if((t=u)===a){o?1===o?Zl(t=Kl(Yl(t),e),e,n,r,i,s,2):2===o&&Jl(t,e,n,r,i,s):Zl(Yl(t),e,n,r,i,s,1);break}}}function Hl(t){const e=t.prev,n=t,r=t.next;if(au(e,n,r)>=0)return !1;const i=e.x,s=n.x,o=r.x,a=e.y,l=n.y,u=r.y,c=Math.min(i,s,o),h=Math.min(a,l,u),p=Math.max(i,s,o),f=Math.max(a,l,u);let d=r.next;for(;d!==e;){if(d.x>=c&&d.x<=p&&d.y>=h&&d.y<=f&&su(i,a,s,l,o,u,d.x,d.y)&&au(d.prev,d,d.next)>=0)return !1;d=d.next;}return !0}function Wl(t,e,n,r){const i=t.prev,s=t,o=t.next;if(au(i,s,o)>=0)return !1;const a=i.x,l=s.x,u=o.x,c=i.y,h=s.y,p=o.y,f=Math.min(a,l,u),d=Math.min(c,h,p),y=Math.max(a,l,u),m=Math.max(c,h,p),g=nu(f,d,e,n,r),x=nu(y,m,e,n,r);let v=t.prevZ,b=t.nextZ;for(;v&&v.z>=g&&b&&b.z<=x;){if(v.x>=f&&v.x<=y&&v.y>=d&&v.y<=m&&v!==i&&v!==o&&su(a,c,l,h,u,p,v.x,v.y)&&au(v.prev,v,v.next)>=0)return !1;if(v=v.prevZ,b.x>=f&&b.x<=y&&b.y>=d&&b.y<=m&&b!==i&&b!==o&&su(a,c,l,h,u,p,b.x,b.y)&&au(b.prev,b,b.next)>=0)return !1;b=b.nextZ;}for(;v&&v.z>=g;){if(v.x>=f&&v.x<=y&&v.y>=d&&v.y<=m&&v!==i&&v!==o&&su(a,c,l,h,u,p,v.x,v.y)&&au(v.prev,v,v.next)>=0)return !1;v=v.prevZ;}for(;b&&b.z<=x;){if(b.x>=f&&b.x<=y&&b.y>=d&&b.y<=m&&b!==i&&b!==o&&su(a,c,l,h,u,p,b.x,b.y)&&au(b.prev,b,b.next)>=0)return !1;b=b.nextZ;}return !0}function Kl(t,e){let n=t;do{const r=n.prev,i=n.next.next;!lu(r,i)&&uu(r,n,n.next,i)&&pu(r,i)&&pu(i,r)&&(e.push(r.i,n.i,i.i),yu(n),yu(n.next),n=t=i),n=n.next;}while(n!==t);return Yl(n)}function Jl(t,e,n,r,i,s){let o=t;do{let t=o.next.next;for(;t!==o.prev;){if(o.i!==t.i&&ou(o,t)){let a=fu(o,t);return o=Yl(o,o.next),a=Yl(a,a.next),Zl(o,e,n,r,i,s,0),void Zl(a,e,n,r,i,s,0)}t=t.next;}o=o.next;}while(o!==t)}function Ql(t,e){let n=t.x-e.x;return 0===n&&(n=t.y-e.y,0===n)&&(n=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)),n}function tu(t,e){const n=function(t,e){let n=e;const r=t.x,i=t.y;let s,o=-1/0;if(lu(t,n))return n;do{if(lu(t,n.next))return n.next;if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){const t=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(t<=r&&t>o&&(o=t,s=n.x<n.next.x?n:n.next,t===r))return s}n=n.next;}while(n!==e);if(!s)return null;const a=s,l=s.x,u=s.y;let c=1/0;n=s;do{if(r>=n.x&&n.x>=l&&r!==n.x&&iu(i<u?r:o,i,l,u,i<u?o:r,i,n.x,n.y)){const e=Math.abs(i-n.y)/(r-n.x);pu(n,t)&&(e<c||e===c&&(n.x>s.x||n.x===s.x&&eu(s,n)))&&(s=n,c=e);}n=n.next;}while(n!==a);return s}(t,e);if(!n)return e;const r=fu(n,t);return Yl(r,r.next),Yl(n,n.next)}function eu(t,e){return au(t.prev,t,e.prev)<0&&au(e.next,t,t.next)<0}function nu(t,e,n,r,i){return (t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function ru(t){let e=t,n=t;do{(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next;}while(e!==t);return n}function iu(t,e,n,r,i,s,o,a){return (i-o)*(e-a)>=(t-o)*(s-a)&&(t-o)*(r-a)>=(n-o)*(e-a)&&(n-o)*(s-a)>=(i-o)*(r-a)}function su(t,e,n,r,i,s,o,a){return !(t===o&&e===a)&&iu(t,e,n,r,i,s,o,a)}function ou(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&uu(n,n.next,t,e))return !0;n=n.next;}while(n!==t);return !1}(t,e)&&(pu(t,e)&&pu(e,t)&&function(t,e){let n=t,r=!1;const i=(t.x+e.x)/2,s=(t.y+e.y)/2;do{n.y>s!=n.next.y>s&&n.next.y!==n.y&&i<(n.next.x-n.x)*(s-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;}while(n!==t);return r}(t,e)&&(au(t.prev,t,e.prev)||au(t,e.prev,e))||lu(t,e)&&au(t.prev,t,t.next)>0&&au(e.prev,e,e.next)>0)}function au(t,e,n){return (e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function lu(t,e){return t.x===e.x&&t.y===e.y}function uu(t,e,n,r){const i=hu(au(t,e,n)),s=hu(au(t,e,r)),o=hu(au(n,r,t)),a=hu(au(n,r,e));return i!==s&&o!==a||!(0!==i||!cu(t,n,e))||!(0!==s||!cu(t,r,e))||!(0!==o||!cu(n,t,r))||!(0!==a||!cu(n,e,r))}function cu(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function hu(t){return t>0?1:t<0?-1:0}function pu(t,e){return au(t.prev,t,t.next)<0?au(t,e,t.next)>=0&&au(t,t.prev,e)>=0:au(t,e,t.prev)<0||au(t,t.next,e)<0}function fu(t,e){const n=mu(t.i,t.x,t.y),r=mu(e.i,e.x,e.y),i=t.next,s=e.prev;return t.next=e,e.prev=t,n.next=i,i.prev=n,r.next=n,n.prev=r,s.next=r,r.prev=s,r}function du(t,e,n,r){const i=mu(t,e,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function yu(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ);}function mu(t,e,n){return {i:t,x:e,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class gu{constructor(t,e){if(e>t)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=t,this._minGranularity=e;}getGranularityForZoomLevel(t){return Math.max(Math.floor(this._baseZoomGranularity/(1<<t)),this._minGranularity,1)}}class xu{constructor(t){this.fill=t.fill,this.line=t.line,this.tile=t.tile,this.stencil=t.stencil,this.circle=t.circle;}}xu.noSubdivision=new xu({fill:new gu(0,0),line:new gu(0,0),tile:new gu(0,0),stencil:new gu(0,0),circle:1}),ds("SubdivisionGranularityExpression",gu),ds("SubdivisionGranularitySetting",xu);const vu=-32768,bu=32767;class wu{constructor(t,e){this._vertexBuffer=[],this._vertexDictionary=new Map,this._used=!1,this._granularity=t,this._granularityCellSize=T/t,this._canonical=e;}_getKey(t,e){return (t+=32768)<<16|e+32768}_vertexToIndex(t,e){if(t<-32768||e<-32768||t>32767||e>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const n=0|Math.round(t),r=0|Math.round(e),i=this._getKey(n,r);if(this._vertexDictionary.has(i))return this._vertexDictionary.get(i);const s=this._vertexBuffer.length/2;return this._vertexDictionary.set(i,s),this._vertexBuffer.push(n,r),s}_subdivideTrianglesScanline(t){if(this._granularity<2)return function(t,e){const n=[];for(let r=0;r<e.length;r+=3){const i=e[r],s=e[r+1],o=e[r+2],a=t[2*i],l=t[2*i+1];(t[2*s]-a)*(t[2*o+1]-l)-(t[2*s+1]-l)*(t[2*o]-a)>0?(n.push(i),n.push(o),n.push(s)):(n.push(i),n.push(s),n.push(o));}return n}(this._vertexBuffer,t);const e=[],n=t.length;for(let r=0;r<n;r+=3){const n=[t[r+0],t[r+1],t[r+2]],i=[this._vertexBuffer[2*t[r+0]+0],this._vertexBuffer[2*t[r+0]+1],this._vertexBuffer[2*t[r+1]+0],this._vertexBuffer[2*t[r+1]+1],this._vertexBuffer[2*t[r+2]+0],this._vertexBuffer[2*t[r+2]+1]];let s=1/0,o=1/0,a=-1/0,l=-1/0;for(let t=0;t<3;t++){const e=i[2*t],n=i[2*t+1];s=Math.min(s,e),a=Math.max(a,e),o=Math.min(o,n),l=Math.max(l,n);}if(s===a||o===l)continue;const u=Math.floor(s/this._granularityCellSize),c=Math.ceil(a/this._granularityCellSize),h=Math.floor(o/this._granularityCellSize),p=Math.ceil(l/this._granularityCellSize);if(u!==c||h!==p)for(let t=h;t<p;t++){const r=this._scanlineGenerateVertexRingForCellRow(t,i,n);Au(this._vertexBuffer,r,e);}else e.push(...n);}return e}_scanlineGenerateVertexRingForCellRow(t,e,n){const r=t*this._granularityCellSize,i=r+this._granularityCellSize,s=[];for(let t=0;t<3;t++){const o=e[2*t],a=e[2*t+1],l=e[2*(t+1)%6],u=e[(2*(t+1)+1)%6],c=e[2*(t+2)%6],h=e[(2*(t+2)+1)%6],p=l-o,f=u-a,d=0===p,y=0===f,m=(r-a)/f,g=(i-a)/f,x=Math.min(m,g),v=Math.max(m,g);if(!y&&(x>=1||v<=0)||y&&(a<r||a>i)){u>=r&&u<=i&&s.push(n[(t+1)%3]);continue}!y&&x>0&&s.push(this._vertexToIndex(o+p*x,a+f*x));const b=o+p*Math.max(x,0),w=o+p*Math.min(v,1);d||this._generateIntraEdgeVertices(s,o,a,l,u,b,w),!y&&v<1&&s.push(this._vertexToIndex(o+p*v,a+f*v)),(y||u>=r&&u<=i)&&s.push(n[(t+1)%3]),!y&&(u<=r||u>=i)&&this._generateInterEdgeVertices(s,o,a,l,u,c,h,w,r,i);}return s}_generateIntraEdgeVertices(t,e,n,r,i,s,o){const a=r-e,l=i-n,u=0===l,c=u?Math.min(e,r):Math.min(s,o),h=u?Math.max(e,r):Math.max(s,o),p=Math.floor(c/this._granularityCellSize)+1,f=Math.ceil(h/this._granularityCellSize)-1;if(u?e<r:s<o)for(let r=p;r<=f;r++){const i=r*this._granularityCellSize;t.push(this._vertexToIndex(i,n+l*(i-e)/a));}else for(let r=f;r>=p;r--){const i=r*this._granularityCellSize;t.push(this._vertexToIndex(i,n+l*(i-e)/a));}}_generateInterEdgeVertices(t,e,n,r,i,s,o,a,l,u){const c=i-n,h=s-r,p=o-i,f=(l-i)/p,d=(u-i)/p,y=Math.min(f,d),m=Math.max(f,d),g=r+h*y;let x=Math.floor(Math.min(g,a)/this._granularityCellSize)+1,v=Math.ceil(Math.max(g,a)/this._granularityCellSize)-1,b=a<g;const w=0===p;if(w&&(o===l||o===u))return;if(w||y>=1||m<=0){const t=n-o,r=s+(e-s)*Math.min((l-o)/t,(u-o)/t);x=Math.floor(Math.min(r,a)/this._granularityCellSize)+1,v=Math.ceil(Math.max(r,a)/this._granularityCellSize)-1,b=a<r;}const _=c>0?u:l;if(b)for(let e=x;e<=v;e++)t.push(this._vertexToIndex(e*this._granularityCellSize,_));else for(let e=v;e>=x;e--)t.push(this._vertexToIndex(e*this._granularityCellSize,_));}_generateOutline(t){const e=[];for(const n of t){const t=Su(n,this._granularity,!0),r=this._pointArrayToIndices(t),i=[];for(let t=1;t<r.length;t++)i.push(r[t-1]),i.push(r[t]);e.push(i);}return e}_handlePoles(t){let e=!1,n=!1;this._canonical&&(0===this._canonical.y&&(e=!0),this._canonical.y===(1<<this._canonical.z)-1&&(n=!0)),(e||n)&&this._fillPoles(t,e,n);}_ensureNoPoleVertices(){const t=this._vertexBuffer;for(let e=0;e<t.length;e+=2){const n=t[e+1];n===vu&&(t[e+1]=-32767),n===bu&&(t[e+1]=32766);}}_generatePoleQuad(t,e,n,r,i,s){r>i!=(s===vu)?(t.push(e),t.push(n),t.push(this._vertexToIndex(r,s)),t.push(n),t.push(this._vertexToIndex(i,s)),t.push(this._vertexToIndex(r,s))):(t.push(n),t.push(e),t.push(this._vertexToIndex(r,s)),t.push(this._vertexToIndex(i,s)),t.push(n),t.push(this._vertexToIndex(r,s)));}_fillPoles(t,e,n){const r=this._vertexBuffer,i=T,s=t.length;for(let o=2;o<s;o+=3){const s=t[o-2],a=t[o-1],l=t[o],u=r[2*s],c=r[2*s+1],h=r[2*a],p=r[2*a+1],f=r[2*l],d=r[2*l+1];e&&(0===c&&0===p&&this._generatePoleQuad(t,s,a,u,h,vu),0===p&&0===d&&this._generatePoleQuad(t,a,l,h,f,vu),0===d&&0===c&&this._generatePoleQuad(t,l,s,f,u,vu)),n&&(c===i&&p===i&&this._generatePoleQuad(t,s,a,u,h,bu),p===i&&d===i&&this._generatePoleQuad(t,a,l,h,f,bu),d===i&&c===i&&this._generatePoleQuad(t,l,s,f,u,bu));}}_initializeVertices(t){for(let e=0;e<t.length;e+=2)this._vertexToIndex(t[e],t[e+1]);}subdividePolygonInternal(t,e){if(this._used)throw new Error("Subdivision: multiple use not allowed.");this._used=!0;const{flattened:n,holeIndices:r}=function(t){const e=[],n=[];for(const r of t)if(0!==r.length){r!==t[0]&&e.push(n.length/2);for(const t of r)n.push(t.x),n.push(t.y);}return {flattened:n,holeIndices:e}}(t);let i;this._initializeVertices(n);try{const t=function(t,e,n=2){const r=e&&e.length,i=r?e[0]*n:t.length;let s=Xl(t,0,i,n,!0);const o=[];if(!s||s.next===s.prev)return o;let a,l,u;if(r&&(s=function(t,e,n,r){const i=[];for(let n=0,s=e.length;n<s;n++){const o=Xl(t,e[n]*r,n<s-1?e[n+1]*r:t.length,r,!1);o===o.next&&(o.steiner=!0),i.push(ru(o));}i.sort(Ql);for(let t=0;t<i.length;t++)n=tu(i[t],n);return n}(t,e,s,n)),t.length>80*n){a=t[0],l=t[1];let e=a,r=l;for(let s=n;s<i;s+=n){const n=t[s],i=t[s+1];n<a&&(a=n),i<l&&(l=i),n>e&&(e=n),i>r&&(r=i);}u=Math.max(e-a,r-l),u=0!==u?32767/u:0;}return Zl(s,o,n,a,l,u,0),o}(n,r),e=this._convertIndices(n,t);i=this._subdivideTrianglesScanline(e);}catch(t){console.error(t);}let s=[];return e&&(s=this._generateOutline(t)),this._ensureNoPoleVertices(),this._handlePoles(i),{verticesFlattened:this._vertexBuffer,indicesTriangles:i,indicesLineList:s}}_convertIndices(t,e){const n=[];for(const r of e)n.push(this._vertexToIndex(t[2*r],t[2*r+1]));return n}_pointArrayToIndices(t){const e=[];for(const n of t)e.push(this._vertexToIndex(n.x,n.y));return e}}function _u(t,e,n,r=!0){return new wu(n,e).subdividePolygonInternal(t,r)}function Su(t,e,r=!1){if(!t||t.length<1)return [];if(t.length<2)return [];const i=t[0],s=t[t.length-1],o=r&&(i.x!==s.x||i.y!==s.y);if(e<2)return o?[...t,t[0]]:[...t];const a=Math.floor(T/e),l=[];l.push(new n(t[0].x,t[0].y));const u=t.length,c=o?u:u-1;for(let e=0;e<c;e++){const r=t[e],i=e<u-1?t[e+1]:t[0],s=r.x,o=r.y,c=i.x,h=i.y,p=s!==c,f=o!==h;if(!p&&!f)continue;const d=c-s,y=h-o,m=Math.abs(d),g=Math.abs(y);let x=s,v=o;for(;;){const t=d>0?(Math.floor(x/a)+1)*a:(Math.ceil(x/a)-1)*a,e=y>0?(Math.floor(v/a)+1)*a:(Math.ceil(v/a)-1)*a,r=Math.abs(x-t),i=Math.abs(v-e),s=Math.abs(x-c),o=Math.abs(v-h),u=p?r/m:Number.POSITIVE_INFINITY,b=f?i/g:Number.POSITIVE_INFINITY;if((s<=r||!p)&&(o<=i||!f))break;if(u<b&&p||!f){x=t,v+=y*u;const e=new n(x,Math.round(v));l[l.length-1].x===e.x&&l[l.length-1].y===e.y||l.push(e);}else {x+=d*b,v=e;const t=new n(Math.round(x),v);l[l.length-1].x===t.x&&l[l.length-1].y===t.y||l.push(t);}}const b=new n(c,h);l[l.length-1].x===b.x&&l[l.length-1].y===b.y||l.push(b);}return l}function Au(t,e,n){if(0===e.length)throw new Error("Subdivision vertex ring is empty.");let r=0,i=t[2*e[0]];for(let n=1;n<e.length;n++){const s=t[2*e[n]];s<i&&(i=s,r=n);}const s=e.length;let o=r,a=(o+1)%s;for(;;){const r=o-1>=0?o-1:s-1,i=(a+1)%s,l=t[2*e[r]],u=t[2*e[i]],c=t[2*e[o]],h=t[2*e[o]+1],p=t[2*e[a]+1];let f=!1;if(l<u)f=!0;else if(l>u)f=!1;else {const n=p-h,s=-(t[2*e[a]]-c),o=h<p?1:-1;((l-c)*n+(t[2*e[r]+1]-h)*s)*o>((u-c)*n+(t[2*e[i]+1]-h)*s)*o&&(f=!0);}if(f){const t=e[r],i=e[o],l=e[a];t!==i&&t!==l&&i!==l&&n.push(l,i,t),o--,o<0&&(o=s-1);}else {const t=e[i],r=e[o],l=e[a];t!==r&&t!==l&&r!==l&&n.push(l,r,t),a++,a>=s&&(a=0);}if(r===i)break}}function Mu(t,e,n,r,i,s,o,a,l){const u=i.length/2,c=o&&a&&l;if(u<ua.MAX_VERTEX_ARRAY_LENGTH){const h=e.prepareSegment(u,n,r),p=h.vertexLength;for(let t=0;t<s.length;t+=3)r.emplaceBack(p+s[t],p+s[t+1],p+s[t+2]);let f,d;h.vertexLength+=u,h.primitiveLength+=s.length/3,c&&(d=o.prepareSegment(u,n,a),f=d.vertexLength,d.vertexLength+=u);for(let e=0;e<i.length;e+=2)t(i[e],i[e+1]);if(c)for(const t of l){for(let e=1;e<t.length;e+=2)a.emplaceBack(f+t[e-1],f+t[e]);d.primitiveLength+=t.length/2;}}else !function(t,e,n,r,i,s){const o=[];for(let t=0;t<r.length/2;t++)o.push(-1);const a={count:0};let l=0,u=t.getOrCreateLatestSegment(e,n),c=u.vertexLength;for(let h=2;h<i.length;h+=3){const p=i[h-2],f=i[h-1],d=i[h];let y=o[p]<l,m=o[f]<l,g=o[d]<l;u.vertexLength+((y?1:0)+(m?1:0)+(g?1:0))>ua.MAX_VERTEX_ARRAY_LENGTH&&(u=t.createNewSegment(e,n),l=a.count,y=!0,m=!0,g=!0,c=0);const x=ku(o,r,s,a,p,y,u),v=ku(o,r,s,a,f,m,u),b=ku(o,r,s,a,d,g,u);n.emplaceBack(c+x-l,c+v-l,c+b-l),u.primitiveLength++;}}(e,n,r,i,s,t),c&&function(t,e,n,r,i,s){const o=[];for(let t=0;t<r.length/2;t++)o.push(-1);const a={count:0};let l=0,u=t.getOrCreateLatestSegment(e,n),c=u.vertexLength;for(const h of i)for(let i=1;i<h.length;i+=2){const p=h[i-1],f=h[i];let d=o[p]<l,y=o[f]<l;u.vertexLength+((d?1:0)+(y?1:0))>ua.MAX_VERTEX_ARRAY_LENGTH&&(u=t.createNewSegment(e,n),l=a.count,d=!0,y=!0,c=0);const m=ku(o,r,s,a,p,d,u),g=ku(o,r,s,a,f,y,u);n.emplaceBack(c+m-l,c+g-l),u.primitiveLength++;}}(o,n,a,i,l,t),e.forceNewSegmentOnNextPrepare(),null==o||o.forceNewSegmentOnNextPrepare();}function ku(t,e,n,r,i,s,o){if(s){const s=r.count;return n(e[2*i],e[2*i+1]),t[i]=r.count,r.count++,o.vertexLength++,s}return t[i]}class Iu{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasDependencies=!1,this.patternFeatures=[],this.layoutVertexArray=new Zo,this.indexArray=new sa,this.indexArray2=new oa,this.programConfigurations=new $a(t.layers,t.zoom),this.segments=new ua,this.segments2=new ua,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,n){this.hasDependencies=ql("fill",this.layers,e);const r=this.layers[0].layout.get("fill-sort-key"),i=!r.isConstant(),s=[];for(const{feature:o,id:a,index:l,sourceLayerIndex:u}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Ga(o,t);if(!this.layers[0]._featureFilter.filter(new Cs(this.zoom),c,n))continue;const h=i?r.evaluate(c,{},n,e.availableImages):void 0,p={id:a,properties:o.properties,type:o.type,sourceLayerIndex:u,index:l,geometry:t?c.geometry:qa(o),patterns:{},sortKey:h};s.push(p);}i&&s.sort(((t,e)=>t.sortKey-e.sortKey));for(const r of s){const{geometry:i,index:s,sourceLayerIndex:o}=r;if(this.hasDependencies){const t=Gl("fill",this.layers,r,{zoom:this.zoom},e);this.patternFeatures.push(t);}else this.addFeature(r,i,s,n,{},e.subdivisionGranularity);e.featureIndex.insert(t[s].feature,i,s,o,this.index);}}update(t,e,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,{imagePositions:n});}addFeatures(t,e,n){for(const r of this.patternFeatures)this.addFeature(r,r.geometry,r.index,e,n,t.subdivisionGranularity);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,jl),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy());}addFeature(t,e,n,r,i,s){for(const t of rr(e,500)){const e=_u(t,r,s.fill.getGranularityForZoomLevel(r.z)),n=this.layoutVertexArray;Mu(((t,e)=>{n.emplaceBack(t,e);}),this.segments,this.layoutVertexArray,this.indexArray,e.verticesFlattened,e.indicesTriangles,this.segments2,this.indexArray2,e.indicesLineList);}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,n,{imagePositions:i,canonical:r});}}let Eu,Tu;ds("FillBucket",Iu,{omit:["layers","patternFeatures"]});var Fu={get paint(){return Tu=Tu||new Ks({"fill-antialias":new Xs(wt.paint_fill["fill-antialias"]),"fill-opacity":new Ys(wt.paint_fill["fill-opacity"]),"fill-color":new Ys(wt.paint_fill["fill-color"]),"fill-outline-color":new Ys(wt.paint_fill["fill-outline-color"]),"fill-translate":new Xs(wt.paint_fill["fill-translate"]),"fill-translate-anchor":new Xs(wt.paint_fill["fill-translate-anchor"]),"fill-pattern":new Zs(wt.paint_fill["fill-pattern"])})},get layout(){return Eu=Eu||new Ks({"fill-sort-key":new Ys(wt.layout_fill["fill-sort-key"])})}};class Pu extends to{constructor(t,e){super(t,Fu,e);}recalculate(t,e){super.recalculate(t,e);const n=this.paint._values["fill-outline-color"];"constant"===n.value.kind&&void 0===n.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"]);}createBucket(t){return new Iu(t)}queryRadius(){return al(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:t,geometry:e,transform:n,pixelsToTileUnits:r}){return Ka(ll(t,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-n.bearingInRadians,r),e)}isTileClipped(){return !0}}const Du=ao([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),zu=ao([{name:"a_centroid",components:2,type:"Int16"}],4),{members:Bu}=Du;class Cu{constructor(t,e,n,r,i){this.properties={},this.extent=n,this.type=0,this.id=void 0,this._pbf=t,this._geometry=-1,this._keys=r,this._values=i,t.readFields(Vu,this,e);}loadGeometry(){const t=this._pbf;t.pos=this._geometry;const e=t.readVarint()+t.pos,r=[];let i,s=1,o=0,a=0,l=0;for(;t.pos<e;){if(o<=0){const e=t.readVarint();s=7&e,o=e>>3;}if(o--,1===s||2===s)a+=t.readSVarint(),l+=t.readSVarint(),1===s&&(i&&r.push(i),i=[]),i&&i.push(new n(a,l));else {if(7!==s)throw new Error(`unknown command ${s}`);i&&i.push(i[0].clone());}}return i&&r.push(i),r}bbox(){const t=this._pbf;t.pos=this._geometry;const e=t.readVarint()+t.pos;let n=1,r=0,i=0,s=0,o=1/0,a=-1/0,l=1/0,u=-1/0;for(;t.pos<e;){if(r<=0){const e=t.readVarint();n=7&e,r=e>>3;}if(r--,1===n||2===n)i+=t.readSVarint(),s+=t.readSVarint(),i<o&&(o=i),i>a&&(a=i),s<l&&(l=s),s>u&&(u=s);else if(7!==n)throw new Error(`unknown command ${n}`)}return [o,l,a,u]}toGeoJSON(t,e,n){const r=this.extent*Math.pow(2,n),i=this.extent*t,s=this.extent*e,o=this.loadGeometry();function a(t){return [360*(t.x+i)/r-180,360/Math.PI*Math.atan(Math.exp((1-2*(t.y+s)/r)*Math.PI))-90]}function l(t){return t.map(a)}let u;if(1===this.type){const t=[];for(const e of o)t.push(e[0]);const e=l(t);u=1===t.length?{type:"Point",coordinates:e[0]}:{type:"MultiPoint",coordinates:e};}else if(2===this.type){const t=o.map(l);u=1===t.length?{type:"LineString",coordinates:t[0]}:{type:"MultiLineString",coordinates:t};}else {if(3!==this.type)throw new Error("unknown feature type");{const t=Lu(o),e=[];for(const n of t)e.push(n.map(l));u=1===e.length?{type:"Polygon",coordinates:e[0]}:{type:"MultiPolygon",coordinates:e};}}const c={type:"Feature",geometry:u,properties:this.properties};return null!=this.id&&(c.id=this.id),c}}function Vu(t,e,n){1===t?e.id=n.readVarint():2===t?function(t,e){const n=t.readVarint()+t.pos;for(;t.pos<n;){const n=e._keys[t.readVarint()],r=e._values[t.readVarint()];e.properties[n]=r;}}(n,e):3===t?e.type=n.readVarint():4===t&&(e._geometry=n.pos);}function Lu(t){const e=t.length;if(e<=1)return [t];const n=[];let r,i;for(let s=0;s<e;s++){const e=Ou(t[s]);0!==e&&(void 0===i&&(i=e<0),i===e<0?(r&&n.push(r),r=[t[s]]):r&&r.push(t[s]));}return r&&n.push(r),n}function Ou(t){let e=0;for(let n,r,i=0,s=t.length,o=s-1;i<s;o=i++)n=t[i],r=t[o],e+=(r.x-n.x)*(n.y+r.y);return e}Cu.types=["Unknown","Point","LineString","Polygon"];class $u{constructor(t,e){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(Ru,this,e),this.length=this._features.length;}feature(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];const e=this._pbf.readVarint()+this._pbf.pos;return new Cu(this._pbf,e,this.extent,this._keys,this._values)}}function Ru(t,e,n){15===t?e.version=n.readVarint():1===t?e.name=n.readString():5===t?e.extent=n.readVarint():2===t?e._features.push(n.pos):3===t?e._keys.push(n.readString()):4===t&&e._values.push(function(t){let e=null;const n=t.readVarint()+t.pos;for(;t.pos<n;){const n=t.readVarint()>>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null;}if(null==e)throw new Error("unknown feature value");return e}(n));}class Nu{constructor(t,e){this.layers=t.readFields(Uu,{},e);}}function Uu(t,e,n){if(3===t){const t=new $u(n,n.readVarint()+n.pos);t.length&&(e[t.name]=t);}}const ju=Math.pow(2,13);function qu(t,e,n,r,i,s,o,a){t.emplaceBack(e,n,2*Math.floor(r*ju)+o,i*ju*2,s*ju*2,Math.round(a));}class Gu{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasDependencies=!1,this.layoutVertexArray=new Ho,this.centroidVertexArray=new Xo,this.indexArray=new sa,this.programConfigurations=new $a(t.layers,t.zoom),this.segments=new ua,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,n){this.features=[],this.hasDependencies=ql("fill-extrusion",this.layers,e);for(const{feature:r,id:i,index:s,sourceLayerIndex:o}of t){const t=this.layers[0]._featureFilter.needGeometry,a=Ga(r,t);if(!this.layers[0]._featureFilter.filter(new Cs(this.zoom),a,n))continue;const l={id:i,sourceLayerIndex:o,index:s,geometry:t?a.geometry:qa(r),properties:r.properties,type:r.type,patterns:{}};this.hasDependencies?this.features.push(Gl("fill-extrusion",this.layers,l,{zoom:this.zoom},e)):this.addFeature(l,l.geometry,s,n,{},e.subdivisionGranularity),e.featureIndex.insert(r,l.geometry,s,o,this.index,!0);}}addFeatures(t,e,n){for(const r of this.features){const{geometry:i}=r;this.addFeature(r,i,r.index,e,n,t.subdivisionGranularity);}}update(t,e,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,{imagePositions:n});}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.centroidVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Bu),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,zu.members,!0),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy());}addFeature(t,e,n,r,i,s){for(const n of rr(e,500)){const e={x:0,y:0,sampleCount:0},i=this.layoutVertexArray.length;this.processPolygon(e,r,t,n,s);const o=this.layoutVertexArray.length-i,a=Math.floor(e.x/e.sampleCount),l=Math.floor(e.y/e.sampleCount);for(let t=0;t<o;t++)this.centroidVertexArray.emplaceBack(a,l);}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,n,{imagePositions:i,canonical:r});}processPolygon(t,e,n,r,i){if(r.length<1)return;if(Zu(r[0]))return;for(const e of r)0!==e.length&&Xu(t,e);const s={segment:this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray)},o=i.fill.getGranularityForZoomLevel(e.z),a="Polygon"===Cu.types[n.type];for(const t of r){if(0===t.length)continue;if(Zu(t))continue;const e=Su(t,o,a);this._generateSideFaces(e,s);}if(!a)return;const l=_u(r,e,o,!1),u=this.layoutVertexArray;Mu(((t,e)=>{qu(u,t,e,0,0,1,1,0);}),this.segments,this.layoutVertexArray,this.indexArray,l.verticesFlattened,l.indicesTriangles);}_generateSideFaces(t,e){let n=0;for(let r=1;r<t.length;r++){const i=t[r],s=t[r-1];if(Yu(i,s))continue;e.segment.vertexLength+4>ua.MAX_VERTEX_ARRAY_LENGTH&&(e.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const o=i.sub(s)._perp()._unit(),a=s.dist(i);n+a>32768&&(n=0),qu(this.layoutVertexArray,i.x,i.y,o.x,o.y,0,0,n),qu(this.layoutVertexArray,i.x,i.y,o.x,o.y,0,1,n),n+=a,qu(this.layoutVertexArray,s.x,s.y,o.x,o.y,0,0,n),qu(this.layoutVertexArray,s.x,s.y,o.x,o.y,0,1,n);const l=e.segment.vertexLength;this.indexArray.emplaceBack(l,l+2,l+1),this.indexArray.emplaceBack(l+1,l+2,l+3),e.segment.vertexLength+=4,e.segment.primitiveLength+=2;}}}function Xu(t,e){for(let n=0;n<e.length;n++){const r=e[n];n===e.length-1&&e[0].x===r.x&&e[0].y===r.y||(t.x+=r.x,t.y+=r.y,t.sampleCount++);}}function Yu(t,e){return t.x===e.x&&(t.x<0||t.x>T)||t.y===e.y&&(t.y<0||t.y>T)}function Zu(t){return t.every((t=>t.x<0))||t.every((t=>t.x>T))||t.every((t=>t.y<0))||t.every((t=>t.y>T))}let Hu;ds("FillExtrusionBucket",Gu,{omit:["layers","features"]});var Wu={get paint(){return Hu=Hu||new Ks({"fill-extrusion-opacity":new Xs(wt["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Ys(wt["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Xs(wt["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Xs(wt["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Zs(wt["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Ys(wt["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Ys(wt["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Xs(wt["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class Ku extends to{constructor(t,e){super(t,Wu,e);}createBucket(t){return new Gu(t)}queryRadius(){return al(this.paint.get("fill-extrusion-translate"))}is3D(){return !0}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:r,geometry:i,transform:s,pixelsToTileUnits:o,pixelPosMatrix:a}){const l=ll(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-s.bearingInRadians,o),u=this.paint.get("fill-extrusion-height").evaluate(e,r),c=this.paint.get("fill-extrusion-base").evaluate(e,r),h=function(t,e){const r=[];for(const i of t){const t=[i.x,i.y,0,1];A(t,t,e),r.push(new n(t[0]/t[3],t[1]/t[3]));}return r}(l,a),p=function(t,e,r,i){const s=[],o=[],a=i[8]*e,l=i[9]*e,u=i[10]*e,c=i[11]*e,h=i[8]*r,p=i[9]*r,f=i[10]*r,d=i[11]*r;for(const e of t){const t=[],r=[];for(const s of e){const e=s.x,o=s.y,y=i[0]*e+i[4]*o+i[12],m=i[1]*e+i[5]*o+i[13],g=i[2]*e+i[6]*o+i[14],x=i[3]*e+i[7]*o+i[15],v=g+u,b=x+c,w=y+h,_=m+p,S=g+f,A=x+d,M=new n((y+a)/b,(m+l)/b);M.z=v/b,t.push(M);const k=new n(w/A,_/A);k.z=S/A,r.push(k);}s.push(t),o.push(r);}return [s,o]}(i,c,u,a);return function(t,e,n){let r=1/0;Ka(n,e)&&(r=Qu(n,e[0]));for(let i=0;i<e.length;i++){const s=e[i],o=t[i];for(let t=0;t<s.length-1;t++){const e=s[t],i=[e,s[t+1],o[t+1],o[t],e];Ha(n,i)&&(r=Math.min(r,Qu(n,i)));}}return r!==1/0&&r}(p[0],p[1],h)}}function Ju(t,e){return t.x*e.x+t.y*e.y}function Qu(t,e){if(1===t.length){let n=0;const r=e[n++];let i;for(;!i||r.equals(i);)if(i=e[n++],!i)return 1/0;for(;n<e.length;n++){const s=e[n],o=t[0],a=i.sub(r),l=s.sub(r),u=o.sub(r),c=Ju(a,a),h=Ju(a,l),p=Ju(l,l),f=Ju(u,a),d=Ju(u,l),y=c*p-h*h,m=(p*f-h*d)/y,g=(c*d-h*f)/y,x=r.z*(1-m-g)+i.z*m+s.z*g;if(isFinite(x))return x}return 1/0}{let t=1/0;for(const n of e)t=Math.min(t,n.z);return t}}const tc=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class ec{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[e,n]=new Uint8Array(t,0,2);if(219!==e)throw new Error("Data does not appear to be in a KDBush format.");const r=n>>4;if(1!==r)throw new Error(`Got v${r} data when expected v1.`);const i=tc[15&n];if(!i)throw new Error("Unrecognized array type.");const[s]=new Uint16Array(t,2,1),[o]=new Uint32Array(t,4,1);return new ec(o,s,i,t)}constructor(t,e=64,n=Float64Array,r){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.ArrayType=n,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const i=tc.indexOf(this.ArrayType),s=2*t*this.ArrayType.BYTES_PER_ELEMENT,o=t*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-o%8)%8;if(i<0)throw new Error(`Unexpected typed array class: ${n}.`);r&&r instanceof ArrayBuffer?(this.data=r,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+o+a,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+s+o+a),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+o+a,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+i]),new Uint16Array(this.data,2,1)[0]=e,new Uint32Array(this.data,4,1)[0]=t);}add(t,e){const n=this._pos>>1;return this.ids[n]=n,this.coords[this._pos++]=t,this.coords[this._pos++]=e,n}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return nc(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,n,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:s,nodeSize:o}=this,a=[0,i.length-1,0],l=[];for(;a.length;){const u=a.pop()||0,c=a.pop()||0,h=a.pop()||0;if(c-h<=o){for(let o=h;o<=c;o++){const a=s[2*o],u=s[2*o+1];a>=t&&a<=n&&u>=e&&u<=r&&l.push(i[o]);}continue}const p=h+c>>1,f=s[2*p],d=s[2*p+1];f>=t&&f<=n&&d>=e&&d<=r&&l.push(i[p]),(0===u?t<=f:e<=d)&&(a.push(h),a.push(p-1),a.push(1-u)),(0===u?n>=f:r>=d)&&(a.push(p+1),a.push(c),a.push(1-u));}return l}within(t,e,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:i,nodeSize:s}=this,o=[0,r.length-1,0],a=[],l=n*n;for(;o.length;){const u=o.pop()||0,c=o.pop()||0,h=o.pop()||0;if(c-h<=s){for(let n=h;n<=c;n++)oc(i[2*n],i[2*n+1],t,e)<=l&&a.push(r[n]);continue}const p=h+c>>1,f=i[2*p],d=i[2*p+1];oc(f,d,t,e)<=l&&a.push(r[p]),(0===u?t-n<=f:e-n<=d)&&(o.push(h),o.push(p-1),o.push(1-u)),(0===u?t+n>=f:e+n>=d)&&(o.push(p+1),o.push(c),o.push(1-u));}return a}}function nc(t,e,n,r,i,s){if(i-r<=n)return;const o=r+i>>1;rc(t,e,o,r,i,s),nc(t,e,n,r,o-1,1-s),nc(t,e,n,o+1,i,1-s);}function rc(t,e,n,r,i,s){for(;i>r;){if(i-r>600){const o=i-r+1,a=n-r+1,l=Math.log(o),u=.5*Math.exp(2*l/3),c=.5*Math.sqrt(l*u*(o-u)/o)*(a-o/2<0?-1:1);rc(t,e,n,Math.max(r,Math.floor(n-a*u/o+c)),Math.min(i,Math.floor(n+(o-a)*u/o+c)),s);}const o=e[2*n+s];let a=r,l=i;for(ic(t,e,r,n),e[2*i+s]>o&&ic(t,e,r,i);a<l;){for(ic(t,e,a,l),a++,l--;e[2*a+s]<o;)a++;for(;e[2*l+s]>o;)l--;}e[2*r+s]===o?ic(t,e,r,l):(l++,ic(t,e,l,i)),l<=n&&(r=l+1),n<=l&&(i=l-1);}}function ic(t,e,n,r){sc(t,n,r),sc(e,2*n,2*r),sc(e,2*n+1,2*r+1);}function sc(t,e,n){const r=t[e];t[e]=t[n],t[n]=r;}function oc(t,e,n,r){const i=t-n,s=e-r;return i*i+s*s}function ac(t,e,n,r){let i=r;const s=e+(n-e>>1);let o,a=n-e;const l=t[e],u=t[e+1],c=t[n],h=t[n+1];for(let r=e+3;r<n;r+=3){const e=lc(t[r],t[r+1],l,u,c,h);if(e>i)o=r,i=e;else if(e===i){const t=Math.abs(r-s);t<a&&(o=r,a=t);}}i>r&&(o-e>3&&ac(t,e,o,r),t[o+2]=i,n-o>3&&ac(t,o,n,r));}function lc(t,e,n,r,i,s){let o=i-n,a=s-r;if(0!==o||0!==a){const l=((t-n)*o+(e-r)*a)/(o*o+a*a);l>1?(n=i,r=s):l>0&&(n+=o*l,r+=a*l);}return o=t-n,a=e-r,o*o+a*a}function uc(t,e,n,r){const i={type:e,geom:n},s={id:null==t?null:t,type:i.type,geometry:i.geom,tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};switch(i.type){case "Point":case "MultiPoint":hc(s,i.geom);break;case "LineString":hc(s,i.geom.points);break;case "Polygon":hc(s,i.geom[0].points);break;case "MultiLineString":for(const t of i.geom)hc(s,t.points);break;case "MultiPolygon":for(const t of i.geom)hc(s,t[0].points);}return s}function cc(t){t.points.length>64&&(t.points=new Float64Array(t.points));}function hc(t,e){for(let n=0;n<e.length;n+=3)t.minX=Math.min(t.minX,e[n]),t.minY=Math.min(t.minY,e[n+1]),t.maxX=Math.max(t.maxX,e[n]),t.maxY=Math.max(t.maxY,e[n+1]);}function pc(t,e){const n=[];switch(t.type){case "FeatureCollection":for(let r=0;r<t.features.length;r++)fc(n,t.features[r],e,r);break;case "Feature":fc(n,t,e);break;default:fc(n,{geometry:t,properties:void 0},e);}return n}function fc(t,e,n,r){if(!e.geometry)return;if("GeometryCollection"===e.geometry.type)return void function(t,e,n,r,i){for(const s of n.geometries)fc(t,{id:e.id,geometry:s,properties:e.properties},r,i);}(t,e,e.geometry,n,r);const i=e.geometry.coordinates;if(!i?.length)return;const s=function(t,e,n){return e.promoteId?t.properties?.[e.promoteId]:e.generateId?n||0:t.id}(e,n,r),o=Math.pow(n.tolerance/((1<<n.maxZoom)*n.extent),2);switch(e.geometry.type){case "Point":return void function(t,e,n,r){const i=[];i.push(mc(n.coordinates[0]),gc(n.coordinates[1]),0),t.push(uc(e,"Point",i,r));}(t,s,e.geometry,e.properties);case "MultiPoint":return void function(t,e,n,r){const i=[];for(const t of n.coordinates)i.push(mc(t[0]),gc(t[1]),0);t.push(uc(e,"MultiPoint",i,r));}(t,s,e.geometry,e.properties);case "LineString":return void function(t,e,n,r,i){const s={points:[]};dc(n.coordinates,s,r,!1),t.push(uc(e,"LineString",s,i));}(t,s,e.geometry,o,e.properties);case "MultiLineString":return void function(t,e,n,r,i,s){if(i.lineMetrics)for(const i of n.coordinates){const n={points:[]};dc(i,n,r,!1),t.push(uc(e,"LineString",n,s));}else {const i=[];yc(n.coordinates,i,r,!1),t.push(uc(e,"MultiLineString",i,s));}}(t,s,e.geometry,o,n,e.properties);case "Polygon":return void function(t,e,n,r,i){const s=[];yc(n.coordinates,s,r,!0),t.push(uc(e,"Polygon",s,i));}(t,s,e.geometry,o,e.properties);case "MultiPolygon":return void function(t,e,n,r,i){const s=[];for(const t of n.coordinates){const e=[];yc(t,e,r,!0),s.push(e);}t.push(uc(e,"MultiPolygon",s,i));}(t,s,e.geometry,o,e.properties);default:throw new Error("Input data is not a valid GeoJSON object.")}}function dc(t,e,n,r){let i,s,o=0;for(let n=0;n<t.length;n++){const a=mc(t[n][0]),l=gc(t[n][1]);e.points.push(a,l,0),n>0&&(o+=r?(i*l-a*s)/2:Math.sqrt(Math.pow(a-i,2)+Math.pow(l-s,2))),i=a,s=l;}const a=e.points.length-3;e.points[2]=1,n>0&&ac(e.points,0,a,n),e.points[a+2]=1,cc(e),e.size=Math.abs(o),e.start=0,e.end=e.size;}function yc(t,e,n,r){for(let i=0;i<t.length;i++){const s={points:[]};dc(t[i],s,n,r),e.push(s);}}function mc(t){return t/360+.5}function gc(t){const e=Math.sin(t*Math.PI/180),n=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return n<0?0:n>1?1:n}function xc(t){const e={type:"Feature",geometry:vc(t),properties:t.tags};return null!=t.id&&(e.id=t.id),e}function vc(t){const{type:e,geometry:n}=t;switch(e){case "Point":return {type:e,coordinates:wc(n[0],n[1])};case "MultiPoint":return {type:e,coordinates:bc(n)};case "LineString":return {type:e,coordinates:bc(n.points)};case "MultiLineString":case "Polygon":return {type:e,coordinates:n.map((t=>bc(t.points)))};case "MultiPolygon":return {type:e,coordinates:n.map((t=>t.map((t=>bc(t.points)))))}}}function bc(t){const e=[];for(let n=0;n<t.length;n+=3)e.push(wc(t[n],t[n+1]));return e}function wc(t,e){return [_c(t),Sc(e)]}function _c(t){return 360*(t-.5)}function Sc(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}var Ac;function Mc(t,e,n,r,i,s,o,a){if(r/=e,s>=(n/=e)&&o<r)return t;if(o<n||s>=r)return null;const l=[];for(const e of t){const t=i===Ac.X?e.minX:e.minY,s=i===Ac.X?e.maxX:e.maxY;if(t>=n&&s<r)l.push(e);else if(!(s<n||t>=r))switch(e.type){case "Point":case "MultiPoint":kc(e,l,n,r,i);continue;case "LineString":Ic(e,l,n,r,i,a);continue;case "MultiLineString":Ec(e,l,n,r,i);continue;case "Polygon":Tc(e,l,n,r,i);continue;case "MultiPolygon":Fc(e,l,n,r,i);continue}}return l.length?l:null}function kc(t,e,n,r,i){const s=[];((function(t,e,n,r,i){for(let s=0;s<t.length;s+=3){const o=t[s+i];o>=n&&o<=r&&Bc(e,t[s],t[s+1],t[s+2]);}}))(t.geometry,s,n,r,i),s.length&&e.push(uc(t.id,3===s.length?"Point":"MultiPoint",s,t.tags));}function Ic(t,e,n,r,i,s){const o=[];if(Pc(t.geometry,o,n,r,i,!1,s.lineMetrics),o.length)if(s.lineMetrics)for(const n of o)e.push(uc(t.id,"LineString",n,t.tags));else e.push(o.length>1?uc(t.id,"MultiLineString",o,t.tags):uc(t.id,"LineString",o[0],t.tags));}function Ec(t,e,n,r,i){const s=[];zc(t.geometry,s,n,r,i,!1),s.length&&e.push(1!==s.length?uc(t.id,"MultiLineString",s,t.tags):uc(t.id,"LineString",s[0],t.tags));}function Tc(t,e,n,r,i){const s=[];zc(t.geometry,s,n,r,i,!0),s.length&&e.push(uc(t.id,"Polygon",s,t.tags));}function Fc(t,e,n,r,i){const s=[];for(const e of t.geometry){const t=[];zc(e,t,n,r,i,!0),t.length&&s.push(t);}s.length&&e.push(uc(t.id,"MultiPolygon",s,t.tags));}function Pc(t,e,n,r,i,s,o){let a=Dc(t);const l=i===Ac.X?Cc:Vc;let u,c,h=t.start;for(let p=0;p<t.points.length-3;p+=3){const f=t.points[p],d=t.points[p+1],y=t.points[p+2],m=t.points[p+3],g=t.points[p+4],x=i===Ac.X?f:d,v=i===Ac.X?m:g;let b=!1;o&&(u=Math.sqrt(Math.pow(f-m,2)+Math.pow(d-g,2))),x<n?v>n&&(c=l(a,f,d,m,g,n),o&&(a.start=h+u*c)):x>r?v<r&&(c=l(a,f,d,m,g,r),o&&(a.start=h+u*c)):Bc(a.points,f,d,y),v<n&&x>=n&&(c=l(a,f,d,m,g,n),b=!0),v>r&&x<=r&&(c=l(a,f,d,m,g,r),b=!0),!s&&b&&(o&&(a.end=h+u*c),e.push(a),a=Dc(t)),o&&(h+=u);}let p=t.points.length-3;const f=t.points[p],d=t.points[p+1],y=i===Ac.X?f:d;y>=n&&y<=r&&Bc(a.points,f,d,t.points[p+2]),p=a.points.length-3,s&&p>=3&&(a.points[p]!==a.points[0]||a.points[p+1]!==a.points[1])&&Bc(a.points,a.points[0],a.points[1],a.points[2]),a.points.length&&(cc(a),e.push(a));}function Dc(t){return {points:[],size:t.size,start:t.start,end:t.end}}function zc(t,e,n,r,i,s){for(const o of t)Pc(o,e,n,r,i,s,!1);}function Bc(t,e,n,r){t.push(e,n,r);}function Cc(t,e,n,r,i,s){const o=(s-e)/(r-e);return Bc(t.points,s,n+(i-n)*o,1),o}function Vc(t,e,n,r,i,s){const o=(s-n)/(i-n);return Bc(t.points,e+(r-e)*o,s,1),o}function Lc(t,e){const n=e.buffer/e.extent;let r=t;const i=Mc(t,1,-1-n,n,Ac.X,-1,2,e),s=Mc(t,1,1-n,2+n,Ac.X,-1,2,e);return i||s?(r=Mc(t,1,-n,1+n,Ac.X,-1,2,e)||[],i&&(r=Oc(i,1).concat(r)),s&&(r=r.concat(Oc(s,-1))),r):r}function Oc(t,e){const n=[];for(const r of t)switch(r.type){case "Point":case "MultiPoint":{const t=$c(r.geometry,e);n.push(uc(r.id,r.type,t,r.tags));continue}case "LineString":{const t=Rc(r.geometry,e);n.push(uc(r.id,r.type,t,r.tags));continue}case "MultiLineString":case "Polygon":{const t=[];for(const n of r.geometry)t.push(Rc(n,e));n.push(uc(r.id,r.type,t,r.tags));continue}case "MultiPolygon":{const t=[];for(const n of r.geometry){const r=[];for(const t of n)r.push(Rc(t,e));t.push(r);}n.push(uc(r.id,r.type,t,r.tags));continue}}return n}function $c(t,e){const n=[];for(let r=0;r<t.length;r+=3)n.push(t[r]+e,t[r+1],t[r+2]);return n}function Rc(t,e){const n={points:[],size:t.size};void 0!==t.start&&(n.start=t.start,n.end=t.end);for(let r=0;r<t.points.length;r+=3)n.points.push(t.points[r]+e,t.points[r+1],t.points[r+2]);return cc(n),n}function Nc(t,e,n){const r=!!e.newGeometry,i=e.removeAllProperties||e.removeProperties?.length>0||e.addOrUpdateProperties?.length>0;if(r){const r=t[0];let s=pc({type:"FeatureCollection",features:[{type:"Feature",id:r.id,geometry:e.newGeometry,properties:i?Uc(r.tags,e):r.tags}]},n);return s=Lc(s,n),s}if(i){const n=[];for(const r of t){const t={...r};t.tags=Uc(t.tags,e),n.push(t);}return n}return t}function Uc(t,e){if(e.removeAllProperties)return {};const n={...t||{}};if(e.removeProperties)for(const t of e.removeProperties)delete n[t];if(e.addOrUpdateProperties)for(const{key:t,value:r}of e.addOrUpdateProperties)n[t]=r;return n}!function(t){t[t.X=0]="X",t[t.Y=1]="Y";}(Ac||(Ac={}));const jc={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:t=>t};class qc{constructor(t){this.options=Object.assign(Object.create(jc),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[],this.points=[];}load(t){const e=[];for(const n of t){if(!n.geometry)continue;const[t,r]=n.geometry.coordinates,[i,s]=[mc(t),gc(r)];e.push({id:n.id,type:"Point",geometry:[i,s],tags:n.properties});}this.createIndex(e);}initialize(t){const e=[];for(const n of t)"Point"===n.type&&e.push(n);this.createIndex(e);}updateIndex(t,e,n){this.options=Object.assign(Object.create(jc),n.clusterOptions),this.initialize(t);}createIndex(t){const{log:e,minZoom:n,maxZoom:r}=this.options;e&&console.time("total time");const i=`prepare ${t.length} points`;e&&console.time(i),this.points=t;const s=[];for(let e=0;e<t.length;e++){const n=t[e];if(!n?.geometry)continue;let[r,i]=n.geometry;r=Math.fround(r),i=Math.fround(i),s.push(r,i,1/0,e,-1,1),this.options.reduce&&s.push(0);}let o=this.trees[r+1]=this.createTree(s);e&&console.timeEnd(i);for(let t=r;t>=n;t--){const n=Date.now();o=this.trees[t]=this.createTree(this.cluster(o,t)),e&&console.log("z%d: %d clusters in %dms",t,o.numItems,Date.now()-n);}e&&console.timeEnd("total time");}getClusters(t,e){return this.getClustersInternal(t,e).map((t=>xc(t)))}getClustersInternal(t,e){let n=((t[0]+180)%360+360)%360-180;const r=Math.max(-90,Math.min(90,t[1]));let i=180===t[2]?180:((t[2]+180)%360+360)%360-180;const s=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)n=-180,i=180;else if(n>i){const t=this.getClustersInternal([n,r,180,s],e),o=this.getClustersInternal([-180,r,i,s],e);return t.concat(o)}const o=this.trees[this.limitZoom(e)],a=o.range(mc(n),gc(s),mc(i),gc(r)),l=o.flatData,u=[];for(const t of a){const e=this.stride*t;u.push(l[e+5]>1?Gc(l,e,this.clusterProps):this.points[l[e+3]]);}return u}getChildren(t){const e=this.getOriginId(t),n=this.getOriginZoom(t),r=new Error("No cluster with the specified id: "+t),i=this.trees[n];if(!i)throw r;const s=i.flatData;if(e*this.stride>=s.length)throw r;const o=this.options.radius/(this.options.extent*Math.pow(2,n-1)),a=i.within(s[e*this.stride],s[e*this.stride+1],o),l=[];for(const e of a){const n=e*this.stride;s[n+4]===t&&l.push(s[n+5]>1?Xc(s,n,this.clusterProps):xc(this.points[s[n+3]]));}if(0===l.length)throw r;return l}getLeaves(t,e,n){const r=[];return this.appendLeaves(r,t,e=e||10,n=n||0,0),r}getTile(t,e,n){const r=this.trees[this.limitZoom(t)];if(!r)return null;const i=Math.pow(2,t),{extent:s,radius:o}=this.options,a=o/s,l=(n-a)/i,u=(n+1+a)/i,c={transformed:!0,features:[],source:null,x:e,y:n,z:t};return this.addTileFeatures(r.range((e-a)/i,l,(e+1+a)/i,u),r.flatData,e,n,i,c),0===e&&this.addTileFeatures(r.range(1-a/i,l,1,u),r.flatData,i,n,i,c),e===i-1&&this.addTileFeatures(r.range(0,l,a/i,u),r.flatData,-1,n,i,c),c}getClusterExpansionZoom(t){return this.getOriginZoom(t)}appendLeaves(t,e,n,r,i){const s=this.getChildren(e);for(const e of s){const s=e.properties;if(s?.cluster?i+s.point_count<=r?i+=s.point_count:i=this.appendLeaves(t,s.cluster_id,n,r,i):i<r?i++:t.push(e),t.length===n)break}return i}createTree(t){const e=new ec(t.length/this.stride|0,this.options.nodeSize,Float32Array);for(let n=0;n<t.length;n+=this.stride)e.add(t[n],t[n+1]);return e.finish(),e.flatData=t,e.data=null,e}addTileFeatures(t,e,n,r,i,s){for(const o of t){const t=o*this.stride,a=e[t+5]>1;let l,u,c;if(a)l=Yc(e,t,this.clusterProps),u=e[t],c=e[t+1];else {const n=this.points[e[t+3]];l=n.tags,[u,c]=n.geometry;}const h={type:1,geometry:[[Math.round(this.options.extent*(u*i-n)),Math.round(this.options.extent*(c*i-r))]],tags:l};let p;p=a||this.options.generateId?e[t+3]:this.points[e[t+3]].id,void 0!==p&&(h.id=p),s.features.push(h);}}limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}cluster(t,e){const{radius:n,extent:r,reduce:i,minPoints:s}=this.options,o=n/(r*Math.pow(2,e)),a=t.flatData,l=[],u=this.stride;for(let n=0;n<a.length;n+=u){if(a[n+2]<=e)continue;a[n+2]=e;const r=a[n],c=a[n+1],h=t.within(a[n],a[n+1],o),p=a[n+5];let f=p;for(const t of h){const n=t*u;a[n+2]>e&&(f+=a[n+5]);}if(f>p&&f>=s){let t,s=r*p,o=c*p,d=-1;const y=(n/u<<5)+(e+1)+this.points.length;for(const r of h){const l=r*u;if(a[l+2]<=e)continue;a[l+2]=e;const c=a[l+5];s+=a[l]*c,o+=a[l+1]*c,a[l+4]=y,i&&(t||(t=this.map(a,n,!0),d=this.clusterProps.length,this.clusterProps.push(t)),i(t,this.map(a,l)));}a[n+4]=y,l.push(s/f,o/f,1/0,y,-1,f),i&&l.push(d);}else {for(let t=0;t<u;t++)l.push(a[n+t]);if(f>1)for(const t of h){const n=t*u;if(!(a[n+2]<=e)){a[n+2]=e;for(let t=0;t<u;t++)l.push(a[n+t]);}}}}return l}getOriginId(t){return t-this.points.length>>5}getOriginZoom(t){return (t-this.points.length)%32}map(t,e,n){if(t[e+5]>1){const r=this.clusterProps[t[e+6]];return n?Object.assign({},r):r}const r=this.points[t[e+3]].tags,i=this.options.map(r);return n&&i===r?Object.assign({},i):i}}function Gc(t,e,n){return {id:t[e+3],type:"Point",tags:Yc(t,e,n),geometry:[t[e],t[e+1]]}}function Xc(t,e,n){return {type:"Feature",id:t[e+3],properties:Yc(t,e,n),geometry:{type:"Point",coordinates:[_c(t[e]),Sc(t[e+1])]}}}function Yc(t,e,n){const r=t[e+5],i=r>=1e4?`${Math.round(r/1e3)}k`:r>=1e3?Math.round(r/100)/10+"k":r,s=t[e+6],o=-1===s?{}:Object.assign({},n[s]);return Object.assign(o,{cluster:!0,cluster_id:t[e+3],point_count:r,point_count_abbreviated:i})}const Zc="geojsonvt_clip_start",Hc="geojsonvt_clip_end";function Wc(t,e,n,r,i){const s=e===i.maxZoom?0:i.tolerance/((1<<e)*i.extent),o={transformed:!1,features:[],source:null,x:n,y:r,z:e,minX:2,minY:1,maxX:-1,maxY:0,numPoints:0,numSimplified:0,numFeatures:t.length};for(const e of t)Kc(o,e,s,i);return o}function Kc(t,e,n,r){switch(t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),e.type){case "Point":case "MultiPoint":return void function(t,e){const n=[];for(let r=0;r<e.geometry.length;r+=3)n.push(e.geometry[r],e.geometry[r+1]),t.numPoints++,t.numSimplified++;if(!n.length)return;const r={type:1,tags:e.tags||null,geometry:n};null!==e.id&&(r.id=e.id),t.features.push(r);}(t,e);case "LineString":return void function(t,e,n,r){const i=[];if(Jc(i,e.geometry,t,n,!1,!1),!i.length)return;let s=e.tags||null;if(r.lineMetrics){s={};for(const t in e.tags)s[t]=e.tags[t];s[Zc]=e.geometry.start/e.geometry.size,s[Hc]=e.geometry.end/e.geometry.size;}const o={type:2,tags:s,geometry:i};null!==e.id&&(o.id=e.id),t.features.push(o);}(t,e,n,r);case "MultiLineString":case "Polygon":return void function(t,e,n){const r=[];for(let i=0;i<e.geometry.length;i++)Jc(r,e.geometry[i],t,n,"Polygon"===e.type,0===i);if(!r.length)return;const i={type:"Polygon"===e.type?3:2,tags:e.tags||null,geometry:r};null!==e.id&&(i.id=e.id),t.features.push(i);}(t,e,n);case "MultiPolygon":return void function(t,e,n){const r=[];for(let i=0;i<e.geometry.length;i++){const s=e.geometry[i];for(let e=0;e<s.length;e++)Jc(r,s[e],t,n,!0,0===e);}if(!r.length)return;const i={type:3,tags:e.tags||null,geometry:r};null!==e.id&&(i.id=e.id),t.features.push(i);}(t,e,n)}}function Jc(t,e,n,r,i,s){const o=r*r;if(r>0&&e.size<(i?o:r))return void(n.numPoints+=e.points.length/3);const a=[];for(let t=0;t<e.points.length;t+=3)(0===r||e.points[t+2]>o)&&(n.numSimplified++,a.push(e.points[t],e.points[t+1])),n.numPoints++;i&&function(t,e){let n=0;for(let e=0,r=t.length,i=r-2;e<r;i=e,e+=2)n+=(t[e]-t[i])*(t[e+1]+t[i+1]);if(n>0===e)for(let e=0,n=t.length;e<n/2;e+=2){const r=t[e],i=t[e+1];t[e]=t[n-2-e],t[e+1]=t[n-1-e],t[n-2-e]=r,t[n-1-e]=i;}}(a,s),t.push(a);}function Qc(t,e){if(t.transformed)return t;const n=1<<t.z,r=t.x,i=t.y;for(const s of t.features)1===s.type?th(s,e,n,r,i):eh(s,e,n,r,i);return t.transformed=!0,t}function th(t,e,n,r,i){const s=t,o=t.geometry,a=[];for(let t=0;t<o.length;t+=2)a.push(nh(o[t],o[t+1],e,n,r,i));return s.geometry=a,s}function eh(t,e,n,r,i){const s=t,o=t.geometry,a=[];for(const t of o){const s=[];for(let o=0;o<t.length;o+=2)s.push(nh(t[o],t[o+1],e,n,r,i));a.push(s);}return s.geometry=a,s}function nh(t,e,n,r,i,s){return [Math.round(n*(t*r-i)),Math.round(n*(e*r-s))]}class rh{constructor(t){this.options=t,this.total=0,this.stats={},this.tiles={},this.tileCoords=[],this.stats={},this.total=0;}initialize(t){this.splitTile(t,0,0,0),this.options.debug&&(t.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)));}updateIndex(t,e,n){n.debug>1&&(console.log("invalidating tiles"),console.time("invalidating")),this.invalidateTiles(e),n.debug>1&&console.timeEnd("invalidating");const[r,i,s]=[0,0,0],o=Wc(t,r,i,s,n);o.source=t;const a=ih(r,i,s);if(this.tiles[a]=o,this.tileCoords.push({z:r,x:i,y:s,id:a}),n.debug){const t=`z${r}`;this.stats[t]=(this.stats[t]||0)+1,this.total++;}}getClusterExpansionZoom(t){return null}getChildren(t){return null}getLeaves(t,e,n){return null}getTile(t,e,n){const{extent:r,debug:i}=this.options,s=1<<t,o=ih(t,e=e+s&s-1,n);if(this.tiles[o])return Qc(this.tiles[o],r);i>1&&console.log("drilling down to z%d-%d-%d",t,e,n);let a,l=t,u=e,c=n;for(;!a&&l>0;)l--,u>>=1,c>>=1,a=this.tiles[ih(l,u,c)];return a?.source?(i>1&&(console.log("found parent tile z%d-%d-%d",l,u,c),console.time("drilling down")),this.splitTile(a.source,l,u,c,t,e,n),i>1&&console.timeEnd("drilling down"),this.tiles[o]?Qc(this.tiles[o],r):null):null}splitTile(t,e,n,r,i,s,o){const a=[t,e,n,r],l=this.options,u=l.debug;for(;a.length;){r=a.pop(),n=a.pop(),e=a.pop(),t=a.pop();const c=1<<e,h=ih(e,n,r);let p=this.tiles[h];if(!p&&(u>1&&console.time("creation"),p=this.tiles[h]=Wc(t,e,n,r,l),this.tileCoords.push({z:e,x:n,y:r,id:h}),u)){u>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",e,n,r,p.numFeatures,p.numPoints,p.numSimplified),console.timeEnd("creation"));const t=`z${e}`;this.stats[t]=(this.stats[t]||0)+1,this.total++;}if(p.source=t,null==i){if(e===l.indexMaxZoom||p.numPoints<=l.indexMaxPoints)continue}else {if(e===l.maxZoom||e===i)continue;if(null!=i){const t=i-e;if(n!==s>>t||r!==o>>t)continue}}if(p.source=null,!t.length)continue;u>1&&console.time("clipping");const f=.5*l.buffer/l.extent,d=.5-f,y=.5+f,m=1+f;let g=null,x=null,v=null,b=null;const w=Mc(t,c,n-f,n+y,Ac.X,p.minX,p.maxX,l),_=Mc(t,c,n+d,n+m,Ac.X,p.minX,p.maxX,l);w&&(g=Mc(w,c,r-f,r+y,Ac.Y,p.minY,p.maxY,l),x=Mc(w,c,r+d,r+m,Ac.Y,p.minY,p.maxY,l)),_&&(v=Mc(_,c,r-f,r+y,Ac.Y,p.minY,p.maxY,l),b=Mc(_,c,r+d,r+m,Ac.Y,p.minY,p.maxY,l)),u>1&&console.timeEnd("clipping"),a.push(g||[],e+1,2*n,2*r),a.push(x||[],e+1,2*n,2*r+1),a.push(v||[],e+1,2*n+1,2*r),a.push(b||[],e+1,2*n+1,2*r+1);}}invalidateTiles(t){if(!t.length)return;const e=this.options,{debug:n}=e;let r=1/0,i=-1/0,s=1/0,o=-1/0;for(const e of t)r=Math.min(r,e.minX),i=Math.max(i,e.maxX),s=Math.min(s,e.minY),o=Math.max(o,e.maxY);const a=e.buffer/e.extent,l=new Set;for(const e in this.tiles){const u=this.tiles[e],c=1<<u.z,h=(u.x-a)/c,p=(u.x+1+a)/c,f=(u.y-a)/c,d=(u.y+1+a)/c;if(i<h||r>=p||o<f||s>=d)continue;let y=!1;for(const e of t)if(e.maxX>=h&&e.minX<p&&e.maxY>=f&&e.minY<d){y=!0;break}if(y){if(n){n>1&&console.log("invalidate tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",u.z,u.x,u.y,u.numFeatures,u.numPoints,u.numSimplified);const t=`z${u.z}`;this.stats[t]=(this.stats[t]||0)-1,this.total--;}delete this.tiles[e],l.add(e);}}l.size&&(this.tileCoords=this.tileCoords.filter((t=>!l.has(t.id))));}}function ih(t,e,n){return 32*((1<<t)*n+e)+t}const sh={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,updateable:!1,cluster:!1,clusterOptions:jc,debug:0},oh=ao([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4),{members:ah}=oh,lh=ao([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),{members:uh}=lh,ch=Math.cos(Math.PI/180*37.5),hh=Math.pow(2,14)/.5;class ph{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasDependencies=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={};for(const t of this.layers)this.gradients[t.id]={};this.layoutVertexArray=new Wo,this.layoutVertexArray2=new Ko,this.indexArray=new sa,this.programConfigurations=new $a(t.layers,t.zoom),this.segments=new ua,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,n){this.hasDependencies=ql("line",this.layers,e)||this.hasLineDasharray(this.layers);const r=this.layers[0].layout.get("line-sort-key"),i=!r.isConstant(),s=[];for(const{feature:e,id:o,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,u=Ga(e,t);if(!this.layers[0]._featureFilter.filter(new Cs(this.zoom),u,n))continue;const c=i?r.evaluate(u,{},n):void 0,h={id:o,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?u.geometry:qa(e),patterns:{},dashes:{},sortKey:c};s.push(h);}i&&s.sort(((t,e)=>t.sortKey-e.sortKey));for(const r of s){const{geometry:i,index:s,sourceLayerIndex:o}=r;this.hasDependencies?(ql("line",this.layers,e)?Gl("line",this.layers,r,{zoom:this.zoom},e):this.hasLineDasharray(this.layers)&&this.addLineDashDependencies(this.layers,r,this.zoom,e),this.patternFeatures.push(r)):this.addFeature(r,i,s,n,{},{},e.subdivisionGranularity),e.featureIndex.insert(t[s].feature,i,s,o,this.index);}}update(t,e,n,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,{imagePositions:n,dashPositions:r});}addFeatures(t,e,n,r){for(const i of this.patternFeatures)this.addFeature(i,i.geometry,i.index,e,n,r,t.subdivisionGranularity);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,uh)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,ah),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}lineFeatureClips(t){if(t.properties&&Object.hasOwn(t.properties,Zc)&&Object.hasOwn(t.properties,Hc))return {start:+t.properties[Zc],end:+t.properties[Hc]}}addFeature(t,e,n,r,i,s,o){const a=this.layers[0].layout,l=a.get("line-join").evaluate(t,{}),u=a.get("line-cap").evaluate(t,{}),c=a.get("line-miter-limit").evaluate(t,{}),h=a.get("line-round-limit").evaluate(t,{});this.lineClips=this.lineFeatureClips(t);for(const n of e)this.addLine(n,t,l,u,c,h,r,o);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,n,{imagePositions:i,dashPositions:s,canonical:r});}addLine(t,e,n,r,i,s,o,a){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,t=Su(t,o?a.line.getGranularityForZoomLevel(o.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e<t.length-1;e++)this.totalDistance+=t[e].dist(t[e+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance);}const l="Polygon"===Cu.types[e.type];let u=t.length;for(;u>=2&&t[u-1].equals(t[u-2]);)u--;let c=0;for(;c<u-1&&t[c].equals(t[c+1]);)c++;if(u<(l?3:2))return;"bevel"===n&&(i=1.05);const h=this.overscaling<=16?122880/(512*this.overscaling):0,p=this.segments.prepareSegment(10*u,this.layoutVertexArray,this.indexArray);let f,d,y,m,g;this.e1=this.e2=-1,l&&(f=t[u-2],g=t[c].sub(f)._unit()._perp());for(let e=c;e<u;e++){if(y=e===u-1?l?t[c+1]:void 0:t[e+1],y&&t[e].equals(y))continue;g&&(m=g),f&&(d=f),f=t[e],g=y?y.sub(f)._unit()._perp():m,m||(m=g);let o=m.add(g);0===o.x&&0===o.y||o._unit();const a=m.x*g.x+m.y*g.y,x=o.x*g.x+o.y*g.y,v=0!==x?1/x:1/0,b=2*Math.sqrt(2-2*x),w=x<ch&&d&&y,_=m.x*g.y-m.y*g.x>0;if(w&&e>c){const t=f.dist(d);if(t>2*h){const e=f.sub(f.sub(d)._mult(h/t)._round());this.updateDistance(d,e),this.addCurrentVertex(e,m,0,0,p),d=e;}}const S=d&&y;let A=S?n:l?"butt":r;if(S&&"round"===A&&(v<s?A="miter":v<=2&&(A="fakeround")),"miter"===A&&v>i&&(A="bevel"),"bevel"===A&&(v>2&&(A="flipbevel"),v<i&&(A="miter")),d&&this.updateDistance(d,f),"miter"===A)o._mult(v),this.addCurrentVertex(f,o,0,0,p);else if("flipbevel"===A){if(v>100)o=g.mult(-1);else {const t=v*m.add(g).mag()/m.sub(g).mag();o._perp()._mult(t*(_?-1:1));}this.addCurrentVertex(f,o,0,0,p),this.addCurrentVertex(f,o.mult(-1),0,0,p);}else if("bevel"===A||"fakeround"===A){const t=-Math.sqrt(v*v-1),e=_?t:0,n=_?0:t;if(d&&this.addCurrentVertex(f,m,e,n,p),"fakeround"===A){const t=Math.round(180*b/Math.PI/20);for(let e=1;e<t;e++){let n=e/t;if(.5!==n){const t=n-.5;n+=n*t*(n-1)*((1.0904+a*(a*(3.55645-1.43519*a)-3.2452))*t*t+(.848013+a*(.215638*a-1.06021)));}const r=g.sub(m)._mult(n)._add(m)._unit()._mult(_?-1:1);this.addHalfVertex(f,r.x,r.y,!1,_,0,p);}}y&&this.addCurrentVertex(f,g,-e,-n,p);}else if("butt"===A)this.addCurrentVertex(f,o,0,0,p);else if("square"===A){const t=d?1:-1;this.addCurrentVertex(f,o,t,t,p);}else "round"===A&&(d&&(this.addCurrentVertex(f,m,0,0,p),this.addCurrentVertex(f,m,1,1,p,!0)),y&&(this.addCurrentVertex(f,g,-1,-1,p,!0),this.addCurrentVertex(f,g,0,0,p)));if(w&&e<u-1){const t=f.dist(y);if(t>2*h){const e=f.add(y.sub(f)._mult(h/t)._round());this.updateDistance(f,e),this.addCurrentVertex(e,g,0,0,p),f=e;}}}}addCurrentVertex(t,e,n,r,i,s=!1){const o=e.y*r-e.x,a=-e.y-e.x*r;this.addHalfVertex(t,e.x+e.y*n,e.y-e.x*n,s,!1,n,i),this.addHalfVertex(t,o,a,s,!0,-r,i),this.distance>hh/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(t,e,n,r,i,s));}addHalfVertex({x:t,y:e},n,r,i,s,o,a){const l=.5*(this.lineClips?this.scaledDistance*(hh-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((t<<1)+(i?1:0),(e<<1)+(s?1:0),Math.round(63*n)+128,Math.round(63*r)+128,1+(0===o?0:o<0?-1:1)|(63&l)<<2,l>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const u=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,u,this.e2),a.primitiveLength++),s?this.e2=u:this.e1=u;}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance;}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance();}hasLineDasharray(t){for(const e of t){const t=e.paint.get("line-dasharray");if(t&&!t.isConstant())return !0}return !1}addLineDashDependencies(t,e,n,r){for(const i of t){const t=i.paint.get("line-dasharray");if(!t||"constant"===t.value.kind)continue;const s="round"===i.layout.get("line-cap").evaluate(e,{}),o={dasharray:t.value.evaluate({zoom:n-1},e,{}),round:s},a={dasharray:t.value.evaluate({zoom:n},e,{}),round:s},l={dasharray:t.value.evaluate({zoom:n+1},e,{}),round:s},u=`${o.dasharray.join(",")},${o.round}`,c=`${a.dasharray.join(",")},${a.round}`,h=`${l.dasharray.join(",")},${l.round}`;r.dashDependencies[u]=o,r.dashDependencies[c]=a,r.dashDependencies[h]=l,e.dashes[i.id]={min:u,mid:c,max:h};}}}let fh,dh;ds("LineBucket",ph,{omit:["layers","patternFeatures"]});var yh={get paint(){return dh=dh||new Ks({"line-opacity":new Ys(wt.paint_line["line-opacity"]),"line-color":new Ys(wt.paint_line["line-color"]),"line-translate":new Xs(wt.paint_line["line-translate"]),"line-translate-anchor":new Xs(wt.paint_line["line-translate-anchor"]),"line-width":new Ys(wt.paint_line["line-width"]),"line-gap-width":new Ys(wt.paint_line["line-gap-width"]),"line-offset":new Ys(wt.paint_line["line-offset"]),"line-blur":new Ys(wt.paint_line["line-blur"]),"line-dasharray":new Zs(wt.paint_line["line-dasharray"]),"line-pattern":new Zs(wt.paint_line["line-pattern"]),"line-gradient":new Ws(wt.paint_line["line-gradient"])})},get layout(){return fh=fh||new Ks({"line-cap":new Ys(wt.layout_line["line-cap"]),"line-join":new Ys(wt.layout_line["line-join"]),"line-miter-limit":new Ys(wt.layout_line["line-miter-limit"]),"line-round-limit":new Ys(wt.layout_line["line-round-limit"]),"line-sort-key":new Ys(wt.layout_line["line-sort-key"])})}};class mh extends Ys{possiblyEvaluate(t,e){return e=new Cs(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,zoomHistory:e.zoomHistory,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,n,r){return e=$({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,n,r)}}let gh;class xh extends to{constructor(t,e){super(t,yh,e),this.gradientVersion=0,gh||(gh=new mh(yh.paint.properties["line-width"].specification),gh.useIntegerZoom=!0);}_handleSpecialPaintPropertyUpdate(t){if("line-gradient"===t){const t=this.gradientExpression();this.stepInterpolant=!!function(t){return void 0!==t._styleExpression}(t)&&t._styleExpression.expression instanceof cn,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER;}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(t,e){super.recalculate(t,e),this.paint._values["line-floorwidth"]=gh.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t);}createBucket(t){return new ph(t)}queryRadius(t){const e=t,n=vh(ol("line-width",this,e),ol("line-gap-width",this,e)),r=ol("line-offset",this,e);return n/2+Math.abs(r)+al(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:r,geometry:i,transform:s,pixelsToTileUnits:o}){const a=ll(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-s.bearingInRadians,o),l=o/2*vh(this.paint.get("line-width").evaluate(e,r),this.paint.get("line-gap-width").evaluate(e,r)),u=this.paint.get("line-offset").evaluate(e,r);return u&&(i=function(t,e){const r=[];for(const i of t){const t=ul(i),s=[];for(let r=0;r<t.length;r++){const i=t[r],o=t[r-1],a=t[r+1],l=0===r?new n(0,0):i.sub(o)._unit()._perp(),u=r===t.length-1?new n(0,0):a.sub(i)._unit()._perp(),c=l._add(u)._unit(),h=c.x*u.x+c.y*u.y;0!==h&&c._mult(1/h),s.push(c._mult(e)._add(i));}r.push(s);}return r}(i,u*o)),function(t,e,n){for(const r of e){if(t.length>=3)for(const e of r)if(il(t,e))return !0;if(Ja(t,r,n))return !0}return !1}(a,i,l)}isTileClipped(){return !0}}function vh(t,e){return e>0?e+2*t:t}const bh=ao([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),wh=ao([{name:"a_projected_pos",components:3,type:"Float32"}],4);ao([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const _h=ao([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);ao([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Sh=ao([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Ah=ao([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function Mh(t,e,n){const r=e.layout.get("text-transform").evaluate(n,{});return "uppercase"===r?t=t.toLocaleUpperCase():"lowercase"===r&&(t=t.toLocaleLowerCase()),Bs.applyArabicShaping&&(t=Bs.applyArabicShaping(t)),t}function kh(t,e,n){for(const r of t.sections)r.text=Mh(r.text,e,n);return t}ao([{name:"triangle",components:3,type:"Uint16"}]),ao([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"}]),ao([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),ao([{type:"Float32",name:"offsetX"}]),ao([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),ao([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);var Ih=24;const Eh={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","⋯":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"},Th={10:!0,32:!0,38:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0},Fh={40:!0};function Ph(t,e,n,r,i,s){if("fontStack"in e){const r=n[e.fontStack],s=null==r?void 0:r[t];return s?s.metrics.advance*e.scale+i:0}{const t=r[e.imageName];return t?t.displaySize[0]*e.scale*Ih/s+i:0}}function Dh(t,e,n,r){const i=Math.pow(t-e,2);return r?t<e?i/2:2*i:i+Math.abs(n)*n}function zh(t,e,n){let r=0;return 10===t&&(r-=1e4),n&&(r+=150),40!==t&&65288!==t||(r+=50),41!==e&&65289!==e||(r+=50),r}function Bh(t,e,n,r,i,s){let o=null,a=Dh(e,n,i,s);for(const t of r){const r=Dh(e-t.x,n,i,s)+t.badness;r<=a&&(o=t,a=r);}return {index:t,x:e,priorBreak:o,badness:a}}function Ch(t){return t?Ch(t.priorBreak).concat(t.index):[]}class Vh{constructor(t="",e=[],n=[]){this.text=t,this.sections=e,this.sectionIndex=n,this.imageSectionID=null;}static fromFeature(t,e){const n=new Vh;for(const r of t.sections)r.image?n.addImageSection(r):n.addTextSection(r,e);return n}length(){return [...this.text].length}getSection(t){return this.sections[this.sectionIndex[t]]}getSectionIndex(t){return this.sectionIndex[t]}verticalizePunctuation(){this.text=function(t){let e="",n={premature:!0,value:void 0};const r=t[Symbol.iterator]();let i=r.next();const s=t[Symbol.iterator]();s.next();let o=s.next();for(;!i.done;)e+=!o.done&&Ts(o.value.codePointAt(0))&&!Eh[o.value]||!n.premature&&Ts(n.value.codePointAt(0))&&!Eh[n.value]||!Eh[i.value]?i.value:Eh[i.value],n={value:i.value,premature:!1},i=r.next(),o=s.next();return e}(this.text);}hasZeroWidthSpaces(){return this.text.includes("")}trim(){const t=this.text.match(/^\s*/),e=t?t[0].length:0,n=this.text.match(/\S\s*$/),r=n?n[0].length-1:0;this.text=this.text.substring(e,this.text.length-r),this.sectionIndex=this.sectionIndex.slice(e,this.sectionIndex.length-r);}substring(t,e){const n=[...this.text].slice(t,e).join(""),r=this.sectionIndex.slice(t,e);return new Vh(n,this.sections,r)}toCodeUnitIndex(t){return [...this.text].slice(0,t).join("").length}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}getMaxImageSize(t){let e=0,n=0;for(let r=0;r<this.length();r++){const i=this.getSection(r);if("imageName"in i){const r=t[i.imageName];if(!r)continue;const s=r.displaySize;e=Math.max(e,s[0]),n=Math.max(n,s[1]);}}return {maxImageWidth:e,maxImageHeight:n}}addTextSection(t,e){this.text+=t.text,this.sections.push({scale:t.scale||1,verticalAlign:t.verticalAlign||"bottom",fontStack:t.fontStack||e});const n=this.sections.length-1;this.sectionIndex.push(...[...t.text].map((()=>n)));}addImageSection(t){const e=t.image?t.image.name:"";if(0===e.length)return void G("Can't add FormattedSection with an empty image.");const n=this.getNextImageSectionCharCode();n?(this.text+=String.fromCharCode(n),this.sections.push({scale:1,verticalAlign:t.verticalAlign||"bottom",imageName:e}),this.sectionIndex.push(this.sections.length-1)):G("Reached maximum number of images 6401");}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}determineLineBreaks(t,e,n,r,i){const s=[],o=this.determineAverageLineWidth(t,e,n,r,i),a=this.hasZeroWidthSpaces();let l=0,u=0;const c=this.text[Symbol.iterator]();let h=c.next();const p=this.text[Symbol.iterator]();p.next();let f=p.next();const d=this.text[Symbol.iterator]();d.next(),d.next();let y=d.next();for(;!h.done;){const e=this.getSection(u),m=h.value.codePointAt(0);if(Ss(m)||(l+=Ph(m,e,n,r,t,i)),!f.done){const t=ws(m),n=f.value.codePointAt(0);(Th[m]||t||"imageName"in e||!y.done&&Fh[n])&&s.push(Bh(u+1,l,o,s,zh(m,n,t&&a),!1));}u++,h=c.next(),f=p.next(),y=d.next();}return Ch(Bh(this.length(),l,o,s,0,!0))}determineAverageLineWidth(t,e,n,r,i){let s=0,o=0;for(const e of this.text){const a=this.getSection(o);s+=Ph(e.codePointAt(0),a,n,r,t,i),o++;}return s/Math.max(1,Math.ceil(s/e))}}const Lh=4294967296,Oh=1/Lh,$h="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");class Rh{constructor(t=new Uint8Array(16)){this.buf=ArrayBuffer.isView(t)?t:new Uint8Array(t),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length;}readFields(t,e,n=this.length){for(;this.pos<n;){const n=this.readVarint(),r=n>>3,i=this.pos;this.type=7&n,t(r,e,this),this.pos===i&&this.skip(n);}return e}readMessage(t,e){return this.readFields(t,e,this.readVarint()+this.pos)}readFixed32(){const t=this.dataView.getUint32(this.pos,!0);return this.pos+=4,t}readSFixed32(){const t=this.dataView.getInt32(this.pos,!0);return this.pos+=4,t}readFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Lh;return this.pos+=8,t}readSFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Lh;return this.pos+=8,t}readFloat(){const t=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,t}readDouble(){const t=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,t}readVarint(t){const e=this.buf;let n,r;return r=e[this.pos++],n=127&r,r<128?n:(r=e[this.pos++],n|=(127&r)<<7,r<128?n:(r=e[this.pos++],n|=(127&r)<<14,r<128?n:(r=e[this.pos++],n|=(127&r)<<21,r<128?n:(r=e[this.pos],n|=(15&r)<<28,function(t,e,n){const r=n.buf;let i,s;if(s=r[n.pos++],i=(112&s)>>4,s<128)return Nh(t,i,e);if(s=r[n.pos++],i|=(127&s)<<3,s<128)return Nh(t,i,e);if(s=r[n.pos++],i|=(127&s)<<10,s<128)return Nh(t,i,e);if(s=r[n.pos++],i|=(127&s)<<17,s<128)return Nh(t,i,e);if(s=r[n.pos++],i|=(127&s)<<24,s<128)return Nh(t,i,e);if(s=r[n.pos++],i|=(1&s)<<31,s<128)return Nh(t,i,e);throw new Error("Expected varint not more than 10 bytes")}(n,t,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const t=this.readVarint();return t%2==1?(t+1)/-2:t/2}readBoolean(){return Boolean(this.readVarint())}readString(){const t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&$h?$h.decode(this.buf.subarray(e,t)):function(t,e,n){let r="",i=e;for(;i<n;){const e=t[i];let s,o,a,l=null,u=e>239?4:e>223?3:e>191?2:1;if(i+u>n)break;1===u?e<128&&(l=e):2===u?(s=t[i+1],128==(192&s)&&(l=(31&e)<<6|63&s,l<=127&&(l=null))):3===u?(s=t[i+1],o=t[i+2],128==(192&s)&&128==(192&o)&&(l=(15&e)<<12|(63&s)<<6|63&o,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===u&&(s=t[i+1],o=t[i+2],a=t[i+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(l=(15&e)<<18|(63&s)<<12|(63&o)<<6|63&a,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,u=1):l>65535&&(l-=65536,r+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),r+=String.fromCharCode(l),i+=u;}return r}(this.buf,e,t)}readBytes(){const t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e}readPackedVarint(t=[],e){const n=this.readPackedEnd();for(;this.pos<n;)t.push(this.readVarint(e));return t}readPackedSVarint(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSVarint());return t}readPackedBoolean(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readBoolean());return t}readPackedFloat(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFloat());return t}readPackedDouble(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readDouble());return t}readPackedFixed32(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFixed32());return t}readPackedSFixed32(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSFixed32());return t}readPackedFixed64(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFixed64());return t}readPackedSFixed64(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSFixed64());return t}readPackedEnd(){return 2===this.type?this.readVarint()+this.pos:this.pos+1}skip(t){const e=7&t;if(0===e)for(;this.buf[this.pos++]>127;);else if(2===e)this.pos=this.readVarint()+this.pos;else if(5===e)this.pos+=4;else {if(1!==e)throw new Error(`Unimplemented type: ${e}`);this.pos+=8;}}writeTag(t,e){this.writeVarint(t<<3|e);}realloc(t){let e=this.length||16;for(;e<this.pos+t;)e*=2;if(e!==this.length){const t=new Uint8Array(e);t.set(this.buf),this.buf=t,this.dataView=new DataView(t.buffer),this.length=e;}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(t){this.realloc(4),this.dataView.setInt32(this.pos,t,!0),this.pos+=4;}writeSFixed32(t){this.realloc(4),this.dataView.setInt32(this.pos,t,!0),this.pos+=4;}writeFixed64(t){this.realloc(8),this.dataView.setInt32(this.pos,-1&t,!0),this.dataView.setInt32(this.pos+4,Math.floor(t*Oh),!0),this.pos+=8;}writeSFixed64(t){this.realloc(8),this.dataView.setInt32(this.pos,-1&t,!0),this.dataView.setInt32(this.pos+4,Math.floor(t*Oh),!0),this.pos+=8;}writeVarint(t){(t=+t||0)>268435455||t<0?function(t,e){let n,r;if(t>=0?(n=t%4294967296|0,r=t/4294967296|0):(n=~(-t%4294967296),r=~(-t/4294967296),4294967295^n?n=n+1|0:(n=0,r=r+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,n){n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos++]=127&t|128,n.buf[n.pos]=127&(t>>>=7);}(n,0,e),function(t,e){const n=(7&t)<<4;e.buf[e.pos++]|=n|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))));}(r,e);}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))));}writeSVarint(t){this.writeVarint(t<0?2*-t-1:2*t);}writeBoolean(t){this.writeVarint(+t);}writeString(t){t=String(t),this.realloc(4*t.length),this.pos++;const e=this.pos;this.pos=function(t,e,n){for(let r,i,s=0;s<e.length;s++){if(r=e.charCodeAt(s),r>55295&&r<57344){if(!i){r>56319||s+1===e.length?(t[n++]=239,t[n++]=191,t[n++]=189):i=r;continue}if(r<56320){t[n++]=239,t[n++]=191,t[n++]=189,i=r;continue}r=i-55296<<10|r-56320|65536,i=null;}else i&&(t[n++]=239,t[n++]=191,t[n++]=189,i=null);r<128?t[n++]=r:(r<2048?t[n++]=r>>6|192:(r<65536?t[n++]=r>>12|224:(t[n++]=r>>18|240,t[n++]=r>>12&63|128),t[n++]=r>>6&63|128),t[n++]=63&r|128);}return n}(this.buf,t,this.pos);const n=this.pos-e;n>=128&&Uh(e,n,this),this.pos=e-1,this.writeVarint(n),this.pos+=n;}writeFloat(t){this.realloc(4),this.dataView.setFloat32(this.pos,t,!0),this.pos+=4;}writeDouble(t){this.realloc(8),this.dataView.setFloat64(this.pos,t,!0),this.pos+=8;}writeBytes(t){const e=t.length;this.writeVarint(e),this.realloc(e);for(let n=0;n<e;n++)this.buf[this.pos++]=t[n];}writeRawMessage(t,e){this.pos++;const n=this.pos;t(e,this);const r=this.pos-n;r>=128&&Uh(n,r,this),this.pos=n-1,this.writeVarint(r),this.pos+=r;}writeMessage(t,e,n){this.writeTag(t,2),this.writeRawMessage(e,n);}writePackedVarint(t,e){e.length&&this.writeMessage(t,jh,e);}writePackedSVarint(t,e){e.length&&this.writeMessage(t,qh,e);}writePackedBoolean(t,e){e.length&&this.writeMessage(t,Yh,e);}writePackedFloat(t,e){e.length&&this.writeMessage(t,Gh,e);}writePackedDouble(t,e){e.length&&this.writeMessage(t,Xh,e);}writePackedFixed32(t,e){e.length&&this.writeMessage(t,Zh,e);}writePackedSFixed32(t,e){e.length&&this.writeMessage(t,Hh,e);}writePackedFixed64(t,e){e.length&&this.writeMessage(t,Wh,e);}writePackedSFixed64(t,e){e.length&&this.writeMessage(t,Kh,e);}writeBytesField(t,e){this.writeTag(t,2),this.writeBytes(e);}writeFixed32Field(t,e){this.writeTag(t,5),this.writeFixed32(e);}writeSFixed32Field(t,e){this.writeTag(t,5),this.writeSFixed32(e);}writeFixed64Field(t,e){this.writeTag(t,1),this.writeFixed64(e);}writeSFixed64Field(t,e){this.writeTag(t,1),this.writeSFixed64(e);}writeVarintField(t,e){this.writeTag(t,0),this.writeVarint(e);}writeSVarintField(t,e){this.writeTag(t,0),this.writeSVarint(e);}writeStringField(t,e){this.writeTag(t,2),this.writeString(e);}writeFloatField(t,e){this.writeTag(t,5),this.writeFloat(e);}writeDoubleField(t,e){this.writeTag(t,1),this.writeDouble(e);}writeBooleanField(t,e){this.writeVarintField(t,+e);}}function Nh(t,e,n){return n?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function Uh(t,e,n){const r=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));n.realloc(r);for(let e=n.pos-1;e>=t;e--)n.buf[e+r]=n.buf[e];}function jh(t,e){for(let n=0;n<t.length;n++)e.writeVarint(t[n]);}function qh(t,e){for(let n=0;n<t.length;n++)e.writeSVarint(t[n]);}function Gh(t,e){for(let n=0;n<t.length;n++)e.writeFloat(t[n]);}function Xh(t,e){for(let n=0;n<t.length;n++)e.writeDouble(t[n]);}function Yh(t,e){for(let n=0;n<t.length;n++)e.writeBoolean(t[n]);}function Zh(t,e){for(let n=0;n<t.length;n++)e.writeFixed32(t[n]);}function Hh(t,e){for(let n=0;n<t.length;n++)e.writeSFixed32(t[n]);}function Wh(t,e){for(let n=0;n<t.length;n++)e.writeFixed64(t[n]);}function Kh(t,e){for(let n=0;n<t.length;n++)e.writeSFixed64(t[n]);}function Jh(t,e,n){1===t&&n.readMessage(Qh,e);}function Qh(t,e,n){if(3===t){const{id:t,bitmap:r,width:i,height:s,left:o,top:a,advance:l}=n.readMessage(tp,{});e.push({id:t,bitmap:new kl({width:i+6,height:s+6},r),metrics:{width:i,height:s,left:o,top:a,advance:l}});}}function tp(t,e,n){1===t?e.id=n.readVarint():2===t?e.bitmap=n.readBytes():3===t?e.width=n.readVarint():4===t?e.height=n.readVarint():5===t?e.left=n.readSVarint():6===t?e.top=n.readSVarint():7===t&&(e.advance=n.readVarint());}function ep(t){let e=0,n=0;for(const r of t)e+=r.w*r.h,n=Math.max(n,r.w);t.sort(((t,e)=>e.h-t.h));const r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),n),h:1/0}];let i=0,s=0;for(const e of t)for(let t=r.length-1;t>=0;t--){const n=r[t];if(!(e.w>n.w||e.h>n.h)){if(e.x=n.x,e.y=n.y,s=Math.max(s,e.y+e.h),i=Math.max(i,e.x+e.w),e.w===n.w&&e.h===n.h){const e=r.pop();e&&t<r.length&&(r[t]=e);}else e.h===n.h?(n.x+=e.w,n.w-=e.w):e.w===n.w?(n.y+=e.h,n.h-=e.h):(r.push({x:n.x+e.w,y:n.y,w:n.w-e.w,h:e.h}),n.y+=e.h,n.h-=e.h);break}}return {w:i,h:s,fill:e/(i*s)||0}}class np{constructor(t,{pixelRatio:e,version:n,stretchX:r,stretchY:i,content:s,textFitWidth:o,textFitHeight:a}){this.paddedRect=t,this.pixelRatio=e,this.stretchX=r,this.stretchY=i,this.content=s,this.version=n,this.textFitWidth=o,this.textFitHeight=a;}get tl(){return [this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return [this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return [(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class rp{constructor(t,e){const n={},r={};this.haveRenderCallbacks=[];const i=[];this.addImages(t,n,i),this.addImages(e,r,i);const{w:s,h:o}=ep(i),a=new Il({width:s||1,height:o||1});for(const e in t){const r=t[e],i=n[e].paddedRect;Il.copy(r.data,a,{x:0,y:0},{x:i.x+1,y:i.y+1},r.data);}for(const t in e){const n=e[t],i=r[t].paddedRect,s=i.x+1,o=i.y+1,l=n.data.width,u=n.data.height;Il.copy(n.data,a,{x:0,y:0},{x:s,y:o},n.data),Il.copy(n.data,a,{x:0,y:u-1},{x:s,y:o-1},{width:l,height:1}),Il.copy(n.data,a,{x:0,y:0},{x:s,y:o+u},{width:l,height:1}),Il.copy(n.data,a,{x:l-1,y:0},{x:s-1,y:o},{width:1,height:u}),Il.copy(n.data,a,{x:0,y:0},{x:s+l,y:o},{width:1,height:u});}this.image=a,this.iconPositions=n,this.patternPositions=r;}addImages(t,e,n){for(const r in t){const i=t[r],s={x:0,y:0,w:i.data.width+2,h:i.data.height+2};n.push(s),e[r]=new np(s,i),i.hasRenderCallback&&this.haveRenderCallbacks.push(r);}}patchUpdatedImages(t,e){t.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const n in t.updatedImages)this.patchUpdatedImage(this.iconPositions[n],t.getImage(n),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n),e);}patchUpdatedImage(t,e,n){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[r,i]=t.tl;n.update(e.data,void 0,{x:r,y:i});}}var ip;function sp(e,n,r,i,s,o,a,l,u,c,h,p,f,d,y){const m=Vh.fromFeature(e,s);let g;p===t.ax.vertical&&m.verticalizePunctuation();let x=m.determineLineBreaks(c,o,n,i,d);const{processBidirectionalText:v,processStyledBidirectionalText:b}=Bs;if(v&&1===m.sections.length){g=[],x=x.map((t=>m.toCodeUnitIndex(t)));const t=v(m.toString(),x);for(const e of t){const t=[...e].map((()=>0));g.push(new Vh(e,m.sections,t));}}else if(b){g=[],x=x.map((t=>m.toCodeUnitIndex(t)));let t=0;const e=[];for(const n of m.text)e.push(...Array(n.length).fill(m.sectionIndex[t])),t++;const n=b(m.text,e,x);for(const t of n){const e=[];let n="";for(const r of t[0])e.push(t[1][n.length]),n+=r;g.push(new Vh(t[0],m.sections,e));}}else g=function(t,e){const n=[];let r=0;for(const i of e)n.push(t.substring(r,i)),r=i;return r<t.length()&&n.push(t.substring(r,t.length())),n}(m,x);const w=[],_={positionedLines:w,text:m.toString(),top:h[1],bottom:h[1],left:h[0],right:h[0],writingMode:p,iconsInText:!1,verticalizable:!1};return function(t,e,n,r,i,s,o,a,l,u,c,h){let p=0,f=0,d=0,y=0;const m="right"===a?1:"left"===a?0:.5,g=Ih/h;let x=0;for(const o of i){o.trim();const i=o.getMaxScale(),a={positionedGlyphs:[],lineOffset:0};t.positionedLines[x]=a;const h=a.positionedGlyphs;let v=0;if(!o.length()){f+=s,++x;continue}const b=ap(r,o,g);let w=0;for(const s of o.text){const a=o.getSection(w),d=s.codePointAt(0),y=up(l,c,d),m={glyph:d,imageName:null,x:p,y:f+-17,vertical:y,scale:1,fontStack:"",sectionIndex:o.getSectionIndex(w),metrics:null,rect:null};let x;if("fontStack"in a){if(x=cp(a,d,y,b,e,n),!x)continue;m.fontStack=a.fontStack;}else {if(t.iconsInText=!0,a.scale*=g,x=hp(a,y,i,b,r),!x)continue;v=Math.max(v,x.imageOffset),m.imageName=a.imageName;}const{rect:_,metrics:S,baselineOffset:A}=x;m.y+=A,m.scale=a.scale,m.metrics=S,m.rect=_,h.push(m),y?(t.verticalizable=!0,p+=("imageName"in a?S.advance:Ih)*a.scale+u):p+=S.advance*a.scale+u,w++;}0!==h.length&&(d=Math.max(p-u,d),pp(h,0,h.length-1,m)),p=0,a.lineOffset=Math.max(v,(i-1)*Ih);const _=s*i+v;f+=_,y=Math.max(_,y),++x;}const{horizontalAlign:v,verticalAlign:b}=op(o);((function(t,e,n,r,i,s,o,a,l){const u=(e-n)*i;let c=0;c=s!==o?-a*r- -17:-r*l*o+.5*o;for(const e of t)for(const t of e.positionedGlyphs)t.x+=u,t.y+=c;}))(t.positionedLines,m,v,b,d,y,s,f,i.length),t.top+=-b*f,t.bottom=t.top+f,t.left+=-v*d,t.right=t.left+d;}(_,n,r,i,g,a,l,u,p,c,f,y),!function(t){for(const e of t)if(0!==e.positionedGlyphs.length)return !1;return !0}(w)&&_}function op(t){let e=.5,n=.5;switch(t){case "right":case "top-right":case "bottom-right":e=1;break;case "left":case "top-left":case "bottom-left":e=0;}switch(t){case "bottom":case "bottom-right":case "bottom-left":n=1;break;case "top":case "top-right":case "top-left":n=0;}return {horizontalAlign:e,verticalAlign:n}}function ap(t,e,n){const r=e.getMaxScale()*Ih,{maxImageWidth:i,maxImageHeight:s}=e.getMaxImageSize(t),o=Math.max(r,s*n);return {verticalLineContentWidth:Math.max(r,i*n),horizontalLineContentHeight:o}}function lp(t){switch(t){case "top":return 0;case "center":return .5;default:return 1}}function up(e,n,r){return !(e===t.ax.horizontal||!n&&!_s(r)||n&&(Ss(r)||(i=r,/\p{sc=Arab}/u.test(String.fromCodePoint(i)))));var i;}function cp(t,e,n,r,i,s){const o=s[t.fontStack],a=function(t,e,n,r){if(null==t?void 0:t.rect)return t;const i=e[n.fontStack],s=null==i?void 0:i[r];return s?{rect:null,metrics:s.metrics}:null}(null==o?void 0:o[e],i,t,e);if(null===a)return null;let l;if(n)l=r.verticalLineContentWidth-t.scale*Ih;else {const e=lp(t.verticalAlign);l=(r.horizontalLineContentHeight-t.scale*Ih)*e;}return {rect:a.rect,metrics:a.metrics,baselineOffset:l}}function hp(t,e,n,r,i){const s=i[t.imageName];if(!s)return null;const o=s.paddedRect,a=s.displaySize,l={width:a[0],height:a[1],left:1,top:-3,advance:e?a[1]:a[0]};let u;if(e)u=r.verticalLineContentWidth-a[1]*t.scale;else {const e=lp(t.verticalAlign);u=(r.horizontalLineContentHeight-a[1]*t.scale)*e;}return {rect:o,metrics:l,baselineOffset:u,imageOffset:(e?a[0]:a[1])*t.scale-Ih*n}}function pp(t,e,n,r){if(0===r)return;const i=t[n],s=(t[n].x+i.metrics.advance*i.scale)*r;for(let r=e;r<=n;r++)t[r].x-=s;}function fp(t,e,n){const{horizontalAlign:r,verticalAlign:i}=op(n),s=e[0]-t.displaySize[0]*r,o=e[1]-t.displaySize[1]*i;return {image:t,top:o,bottom:o+t.displaySize[1],left:s,right:s+t.displaySize[0]}}function dp(t){var e,n;let r=t.left,i=t.top,s=t.right-r,o=t.bottom-i;const a=null!==(e=t.image.textFitWidth)&&void 0!==e?e:"stretchOrShrink",l=null!==(n=t.image.textFitHeight)&&void 0!==n?n:"stretchOrShrink",u=(t.image.content[2]-t.image.content[0])/(t.image.content[3]-t.image.content[1]);if("proportional"===l){if("stretchOnly"===a&&s/o<u||"proportional"===a){const t=Math.ceil(o*u);r*=t/s,s=t;}}else if("proportional"===a&&"stretchOnly"===l&&0!==u&&s/o>u){const t=Math.ceil(s/u);i*=t/o,o=t;}return {x1:r,y1:i,x2:r+s,y2:i+o}}function yp(t,e,n,r,i,s){const o=t.image;let a;if(o.content){const t=o.content,e=o.pixelRatio||1;a=[t[0]/e,t[1]/e,o.displaySize[0]-t[2]/e,o.displaySize[1]-t[3]/e];}const l=e.left*s,u=e.right*s;let c,h,p,f;"width"===n||"both"===n?(f=i[0]+l-r[3],h=i[0]+u+r[1]):(f=i[0]+(l+u-o.displaySize[0])/2,h=f+o.displaySize[0]);const d=e.top*s,y=e.bottom*s;return "height"===n||"both"===n?(c=i[1]+d-r[0],p=i[1]+y+r[2]):(c=i[1]+(d+y-o.displaySize[1])/2,p=c+o.displaySize[1]),{image:o,top:c,right:h,bottom:p,left:f,collisionPadding:a}}ds("ImagePosition",np),ds("ImageAtlas",rp),t.ax=void 0,(ip=t.ax||(t.ax={}))[ip.none=0]="none",ip[ip.horizontal=1]="horizontal",ip[ip.vertical=2]="vertical",ip[ip.horizontalOnly=3]="horizontalOnly";const mp=128,gp=32640;function xp(t,e){const{expression:n}=e;if("constant"===n.kind)return {kind:"constant",layoutSize:n.evaluate(new Cs(t+1))};if("source"===n.kind)return {kind:"source"};{const{zoomStops:e,interpolationType:r}=n;let i=0;for(;i<e.length&&e[i]<=t;)i++;i=Math.max(0,i-1);let s=i;for(;s<e.length&&e[s]<t+1;)s++;s=Math.min(e.length-1,s);const o=e[i],a=e[s];return "composite"===n.kind?{kind:"composite",minZoom:o,maxZoom:a,interpolationType:r}:{kind:"camera",minZoom:o,maxZoom:a,minSize:n.evaluate(new Cs(o)),maxSize:n.evaluate(new Cs(a)),interpolationType:r}}}function vp(t,e,n){let r="never";const i=t.get(e);return i?r=i:t.get(n)&&(r="always"),r}const bp=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function wp(t,e,n,r,i,s,o,a,l,u,c,h,p){const f=a?Math.min(gp,Math.round(a[0])):0,d=a?Math.min(gp,Math.round(a[1])):0;t.emplaceBack(e,n,Math.round(32*r),Math.round(32*i),s,o,(f<<1)+(l?1:0),d,16*u,16*c,256*h,256*p);}function _p(t,e,n){t.emplaceBack(e.x,e.y,n),t.emplaceBack(e.x,e.y,n),t.emplaceBack(e.x,e.y,n),t.emplaceBack(e.x,e.y,n);}function Sp(t){for(const e of t.sections)if(zs(e.text))return !0;return !1}class Ap{constructor(t){this.layoutVertexArray=new ta,this.indexArray=new sa,this.programConfigurations=t,this.segments=new ua,this.dynamicLayoutVertexArray=new ea,this.opacityVertexArray=new na,this.hasVisibleVertices=!1,this.placedSymbolArray=new Lo;}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(t,e,n,r){this.isEmpty()||(n&&(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,bh.members),this.indexBuffer=t.createIndexBuffer(this.indexArray,e),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,wh.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,bp,!0),this.opacityVertexBuffer.itemSize=1),(n||r)&&this.programConfigurations.upload(t));}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy());}}ds("SymbolBuffers",Ap);class Mp{constructor(t,e,n){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new n,this.segments=new ua,this.collisionVertexArray=new ia;}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,_h.members,!0);}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy());}}ds("CollisionBuffers",Mp);class kp{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasDependencies=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const n=this.layers[0]._unevaluatedLayout._values;this.textSizeData=xp(this.zoom,n["text-size"]),this.iconSizeData=xp(this.zoom,n["icon-size"]);const r=this.layers[0].layout,i=r.get("symbol-sort-key"),s=r.get("symbol-z-order");this.canOverlap="never"!==vp(r,"text-overlap","text-allow-overlap")||"never"!==vp(r,"icon-overlap","icon-allow-overlap")||r.get("text-ignore-placement")||r.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==s&&!i.isConstant(),this.sortFeaturesByY=("viewport-y"===s||"auto"===s&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===r.get("symbol-placement")&&(this.writingModes=r.get("text-writing-mode").map((e=>t.ax[e]))),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID;}createArrays(){this.text=new Ap(new $a(this.layers,this.zoom,(t=>t.startsWith("text")))),this.icon=new Ap(new $a(this.layers,this.zoom,(t=>t.startsWith("icon")))),this.glyphOffsetArray=new Ro,this.lineVertexArray=new No,this.symbolInstances=new $o,this.textAnchorOffsets=new jo;}calculateGlyphDependencies(t,e,n,r,i){for(const s of t)if(e[s.codePointAt(0)]=!0,(n||r)&&i){const t=Eh[s];t&&(e[t.codePointAt(0)]=!0);}}populate(e,n,r){var i;const s=this.layers[0],o=s.layout,a=o.get("text-font"),l=o.get("text-field"),u=o.get("icon-image"),c=("constant"!==l.value.kind||l.value.value instanceof ze&&!l.value.value.isEmpty()||l.value.value.toString().length>0)&&("constant"!==a.value.kind||a.value.value.length>0),h="constant"!==u.value.kind||!!u.value.value||Object.keys(u.parameters).length>0,p=o.get("symbol-sort-key");if(this.features=[],!c&&!h)return;const f=n.iconDependencies,d=n.glyphDependencies,y=n.availableImages,m=new Cs(this.zoom);for(const{feature:n,id:l,index:u,sourceLayerIndex:g}of e){const e=s._featureFilter.needGeometry,x=Ga(n,e);if(!s._featureFilter.filter(m,x,r))continue;let v,b;if(e||(x.geometry=qa(n)),c){const t=s.getValueAndResolveTokens("text-field",x,r,y),e=ze.factory(t);this.hasRTLText||(this.hasRTLText=Sp(e)),(!this.hasRTLText||"unavailable"===Bs.getRTLTextPluginStatus()||this.hasRTLText&&Bs.isParsed())&&(v=kh(e,s,x));}if(h){const t=s.getValueAndResolveTokens("icon-image",x,r,y);b=t instanceof Re?t:Re.fromString(t);}if(!v&&!b)continue;const w=this.sortFeaturesByKey?p.evaluate(x,{},r):void 0;if(this.features.push({id:l,text:v,icon:b,index:u,sourceLayerIndex:g,geometry:x.geometry,properties:n.properties,type:Cu.types[n.type],sortKey:w}),b&&(f[b.name]=!0),v){const e=a.evaluate(x,{},r).join(","),n="viewport"!==o.get("text-rotation-alignment")&&"point"!==o.get("symbol-placement");this.allowVerticalPlacement=null===(i=this.writingModes)||void 0===i?void 0:i.includes(t.ax.vertical);for(const t of v.sections)if(t.image)f[t.image.name]=!0;else {const r=As(v.toString()),i=t.fontStack||e;d[i]||(d[i]={}),this.calculateGlyphDependencies(t.text,d[i],n,this.allowVerticalPlacement,r);}}}"line"===o.get("symbol-placement")&&(this.features=function(t){const e={},n={},r=[];let i=0;function s(e){r.push(t[e]),i++;}function o(t,e,i){const s=n[t];return delete n[t],n[e]=s,r[s].geometry[0].pop(),r[s].geometry[0]=r[s].geometry[0].concat(i[0]),s}function a(t,n,i){const s=e[n];return delete e[n],e[t]=s,r[s].geometry[0].shift(),r[s].geometry[0]=i[0].concat(r[s].geometry[0]),s}function l(t,e,n){const r=n?e[0][e[0].length-1]:e[0][0];return `${t}:${r.x}:${r.y}`}for(let u=0;u<t.length;u++){const c=t[u],h=c.geometry,p=c.text?c.text.toString():null;if(!p){s(u);continue}const f=l(p,h),d=l(p,h,!0);if(f in n&&d in e&&n[f]!==e[d]){const t=a(f,d,h),i=o(f,d,r[t].geometry);delete e[f],delete n[d],n[l(p,r[i].geometry,!0)]=i,r[t].geometry=null;}else f in n?o(f,d,h):d in e?a(f,d,h):(s(u),e[f]=i-1,n[d]=i-1);}return r.filter((t=>t.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey));}update(t,e,n){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,{imagePositions:n}),this.icon.programConfigurations.updatePaintArrays(t,e,this.layers,{imagePositions:n}));}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return !this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0;}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy();}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();}addToLineVertexArray(t,e){const n=this.lineVertexArray.length;if(void 0!==t.segment){let n=t.dist(e[t.segment+1]),r=t.dist(e[t.segment]);const i={};for(let r=t.segment+1;r<e.length;r++)i[r]={x:e[r].x,y:e[r].y,tileUnitDistanceFromAnchor:n},r<e.length-1&&(n+=e[r+1].dist(e[r]));for(let n=t.segment||0;n>=0;n--)i[n]={x:e[n].x,y:e[n].y,tileUnitDistanceFromAnchor:r},n>0&&(r+=e[n-1].dist(e[n]));for(let t=0;t<e.length;t++){const e=i[t];this.lineVertexArray.emplaceBack(e.x,e.y,e.tileUnitDistanceFromAnchor);}}return {lineStartIndex:n,lineLength:this.lineVertexArray.length-n}}addSymbols(e,n,r,i,s,o,a,l,u,c,h,p){const f=e.indexArray,d=e.layoutVertexArray,y=e.segments.prepareSegment(4*n.length,d,f,this.canOverlap?o.sortKey:void 0),m=this.glyphOffsetArray.length,g=y.vertexLength,x=this.allowVerticalPlacement&&a===t.ax.vertical?Math.PI/2:0,v=o.text&&o.text.sections;for(let t=0;t<n.length;t++){const{tl:i,tr:s,bl:a,br:u,tex:c,pixelOffsetTL:h,pixelOffsetBR:m,minFontScaleX:g,minFontScaleY:b,glyphOffset:w,isSDF:_,sectionIndex:S}=n[t],A=y.vertexLength,M=w[1];wp(d,l.x,l.y,i.x,M+i.y,c.x,c.y,r,_,h.x,h.y,g,b),wp(d,l.x,l.y,s.x,M+s.y,c.x+c.w,c.y,r,_,m.x,h.y,g,b),wp(d,l.x,l.y,a.x,M+a.y,c.x,c.y+c.h,r,_,h.x,m.y,g,b),wp(d,l.x,l.y,u.x,M+u.y,c.x+c.w,c.y+c.h,r,_,m.x,m.y,g,b),_p(e.dynamicLayoutVertexArray,l,x),f.emplaceBack(A,A+2,A+1),f.emplaceBack(A+1,A+2,A+3),y.vertexLength+=4,y.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(w[0]),t!==n.length-1&&S===n[t+1].sectionIndex||e.programConfigurations.populatePaintArrays(d.length,o,o.index,{imagePositions:{},canonical:p,formattedSection:null==v?void 0:v[S]});}e.placedSymbolArray.emplaceBack(l.x,l.y,m,this.glyphOffsetArray.length-m,g,u,c,l.segment,r?r[0]:0,r?r[1]:0,i[0],i[1],a,0,!1,0,h);}_addCollisionDebugVertex(t,e,n,r,i,s){return e.emplaceBack(0,0),t.emplaceBack(n.x,n.y,r,i,Math.round(s.x),Math.round(s.y))}addCollisionDebugVertices(t,e,r,i,s,o,a){const l=s.segments.prepareSegment(4,s.layoutVertexArray,s.indexArray),u=l.vertexLength,c=s.layoutVertexArray,h=s.collisionVertexArray,p=a.anchorX,f=a.anchorY;this._addCollisionDebugVertex(c,h,o,p,f,new n(t,e)),this._addCollisionDebugVertex(c,h,o,p,f,new n(r,e)),this._addCollisionDebugVertex(c,h,o,p,f,new n(r,i)),this._addCollisionDebugVertex(c,h,o,p,f,new n(t,i)),l.vertexLength+=4;const d=s.indexArray;d.emplaceBack(u,u+1),d.emplaceBack(u+1,u+2),d.emplaceBack(u+2,u+3),d.emplaceBack(u+3,u),l.primitiveLength+=4;}addDebugCollisionBoxes(t,e,n,r){for(let i=t;i<e;i++){const t=this.collisionBoxArray.get(i);this.addCollisionDebugVertices(t.x1,t.y1,t.x2,t.y2,r?this.textCollisionBox:this.iconCollisionBox,t.anchorPoint,n);}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Mp(ra,Sh.members,oa),this.iconCollisionBox=new Mp(ra,Sh.members,oa);for(let t=0;t<this.symbolInstances.length;t++){const e=this.symbolInstances.get(t);this.addDebugCollisionBoxes(e.textBoxStartIndex,e.textBoxEndIndex,e,!0),this.addDebugCollisionBoxes(e.verticalTextBoxStartIndex,e.verticalTextBoxEndIndex,e,!0),this.addDebugCollisionBoxes(e.iconBoxStartIndex,e.iconBoxEndIndex,e,!1),this.addDebugCollisionBoxes(e.verticalIconBoxStartIndex,e.verticalIconBoxEndIndex,e,!1);}}_deserializeCollisionBoxesForSymbol(t,e,n,r,i,s,o,a,l){const u={};for(let r=e;r<n;r++){const e=t.get(r);u.textBox={x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,anchorPointX:e.anchorPointX,anchorPointY:e.anchorPointY},u.textFeatureIndex=e.featureIndex;break}for(let e=r;e<i;e++){const n=t.get(e);u.verticalTextBox={x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,anchorPointX:n.anchorPointX,anchorPointY:n.anchorPointY},u.verticalTextFeatureIndex=n.featureIndex;break}for(let e=s;e<o;e++){const n=t.get(e);u.iconBox={x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,anchorPointX:n.anchorPointX,anchorPointY:n.anchorPointY},u.iconFeatureIndex=n.featureIndex;break}for(let e=a;e<l;e++){const n=t.get(e);u.verticalIconBox={x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,anchorPointX:n.anchorPointX,anchorPointY:n.anchorPointY},u.verticalIconFeatureIndex=n.featureIndex;break}return u}deserializeCollisionBoxes(t){this.collisionArrays=[];for(let e=0;e<this.symbolInstances.length;e++){const n=this.symbolInstances.get(e);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(t,n.textBoxStartIndex,n.textBoxEndIndex,n.verticalTextBoxStartIndex,n.verticalTextBoxEndIndex,n.iconBoxStartIndex,n.iconBoxEndIndex,n.verticalIconBoxStartIndex,n.verticalIconBoxEndIndex));}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(t,e){const n=t.placedSymbolArray.get(e),r=n.vertexStartIndex+4*n.numGlyphs;for(let e=n.vertexStartIndex;e<r;e+=4)t.indexArray.emplaceBack(e,e+2,e+1),t.indexArray.emplaceBack(e+1,e+2,e+3);}getSortedSymbolIndexes(t){if(this.sortedAngle===t&&void 0!==this.symbolInstanceIndexes)return this.symbolInstanceIndexes;const e=Math.sin(t),n=Math.cos(t),r=[],i=[],s=[];for(let t=0;t<this.symbolInstances.length;++t){s.push(t);const o=this.symbolInstances.get(t);r.push(0|Math.round(e*o.anchorX+n*o.anchorY)),i.push(o.featureIndex);}return s.sort(((t,e)=>r[t]-r[e]||i[e]-i[t])),s}addToSortKeyRanges(t,e){const n=this.sortKeyRanges[this.sortKeyRanges.length-1];(null==n?void 0:n.sortKey)===e?n.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1});}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex);const n=[e.rightJustifiedTextSymbolIndex,e.centerJustifiedTextSymbolIndex,e.leftJustifiedTextSymbolIndex];for(let t=0;t<n.length;t++){const e=n[t];e>=0&&n.indexOf(e)===t&&this.addIndicesForPlacedSymbol(this.text,e);}e.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,e.verticalPlacedTextSymbolIndex),e.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.placedIconSymbolIndex),e.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.verticalPlacedIconSymbolIndex);}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray);}}}let Ip,Ep;ds("SymbolBucket",kp,{omit:["layers","collisionBoxArray","features","compareText"]}),kp.MAX_GLYPHS=65535,kp.addDynamicAttributes=_p;var Tp={get paint(){return Ep=Ep||new Ks({"icon-opacity":new Ys(wt.paint_symbol["icon-opacity"]),"icon-color":new Ys(wt.paint_symbol["icon-color"]),"icon-halo-color":new Ys(wt.paint_symbol["icon-halo-color"]),"icon-halo-width":new Ys(wt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Ys(wt.paint_symbol["icon-halo-blur"]),"icon-translate":new Xs(wt.paint_symbol["icon-translate"]),"icon-translate-anchor":new Xs(wt.paint_symbol["icon-translate-anchor"]),"text-opacity":new Ys(wt.paint_symbol["text-opacity"]),"text-color":new Ys(wt.paint_symbol["text-color"],{runtimeType:Nt,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new Ys(wt.paint_symbol["text-halo-color"]),"text-halo-width":new Ys(wt.paint_symbol["text-halo-width"]),"text-halo-blur":new Ys(wt.paint_symbol["text-halo-blur"]),"text-translate":new Xs(wt.paint_symbol["text-translate"]),"text-translate-anchor":new Xs(wt.paint_symbol["text-translate-anchor"])})},get layout(){return Ip=Ip||new Ks({"symbol-placement":new Xs(wt.layout_symbol["symbol-placement"]),"symbol-spacing":new Xs(wt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Xs(wt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Ys(wt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Xs(wt.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Xs(wt.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Xs(wt.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Xs(wt.layout_symbol["icon-ignore-placement"]),"icon-optional":new Xs(wt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Xs(wt.layout_symbol["icon-rotation-alignment"]),"icon-size":new Ys(wt.layout_symbol["icon-size"]),"icon-text-fit":new Xs(wt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Xs(wt.layout_symbol["icon-text-fit-padding"]),"icon-image":new Ys(wt.layout_symbol["icon-image"]),"icon-rotate":new Ys(wt.layout_symbol["icon-rotate"]),"icon-padding":new Ys(wt.layout_symbol["icon-padding"]),"icon-keep-upright":new Xs(wt.layout_symbol["icon-keep-upright"]),"icon-offset":new Ys(wt.layout_symbol["icon-offset"]),"icon-anchor":new Ys(wt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Xs(wt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Xs(wt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Xs(wt.layout_symbol["text-rotation-alignment"]),"text-field":new Ys(wt.layout_symbol["text-field"]),"text-font":new Ys(wt.layout_symbol["text-font"]),"text-size":new Ys(wt.layout_symbol["text-size"]),"text-max-width":new Ys(wt.layout_symbol["text-max-width"]),"text-line-height":new Xs(wt.layout_symbol["text-line-height"]),"text-letter-spacing":new Ys(wt.layout_symbol["text-letter-spacing"]),"text-justify":new Ys(wt.layout_symbol["text-justify"]),"text-radial-offset":new Ys(wt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Xs(wt.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Ys(wt.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Ys(wt.layout_symbol["text-anchor"]),"text-max-angle":new Xs(wt.layout_symbol["text-max-angle"]),"text-writing-mode":new Xs(wt.layout_symbol["text-writing-mode"]),"text-rotate":new Ys(wt.layout_symbol["text-rotate"]),"text-padding":new Xs(wt.layout_symbol["text-padding"]),"text-keep-upright":new Xs(wt.layout_symbol["text-keep-upright"]),"text-transform":new Ys(wt.layout_symbol["text-transform"]),"text-offset":new Ys(wt.layout_symbol["text-offset"]),"text-allow-overlap":new Xs(wt.layout_symbol["text-allow-overlap"]),"text-overlap":new Xs(wt.layout_symbol["text-overlap"]),"text-ignore-placement":new Xs(wt.layout_symbol["text-ignore-placement"]),"text-optional":new Xs(wt.layout_symbol["text-optional"])})}};class Fp{constructor(t){if(void 0===t.property.overrides)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=t.property.overrides?t.property.overrides.runtimeType:Lt,this.defaultValue=t;}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(null==e?void 0:e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression);}outputDefined(){return !1}serialize(){return null}}ds("FormatSectionOverride",Fp,{omit:["defaultValue"]});class Pp extends to{constructor(t,e){super(t,Tp,e);}recalculate(t,e){if(super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){const t=this.layout.get("text-writing-mode");if(t){const e=[];for(const n of t)e.includes(n)||e.push(n);this.layout._values["text-writing-mode"]=e;}else this.layout._values["text-writing-mode"]=["horizontal"];}this._setPaintOverrides();}getValueAndResolveTokens(t,e,n,r){const i=this.layout.get(t).evaluate(e,{},n,r),s=this._unevaluatedLayout._values[t];return s.isDataDriven()||ii(s.value)||!i?i:function(t,e){return e.replace(/{([^{}]+)}/g,((e,n)=>t&&n in t?String(t[n]):""))}(e.properties,i)}createBucket(t){return new kp(t)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const t of Tp.paint.overridableProperties){if(!Pp.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),n=new Fp(e),r=new ri(n,e.property.specification);let i=null;i="constant"===e.value.kind||"source"===e.value.kind?new oi("source",r):new ai("composite",r,e.value.zoomStops),this.paint._values[t]=new qs(e.property,i,e.parameters);}}_handleOverridablePaintPropertyUpdate(t,e,n){return !(!this.layout||e.isDataDriven()||n.isDataDriven())&&Pp.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const n=t.get("text-field"),r=Tp.paint.properties[e];let i=!1;const s=t=>{var e;for(const n of t)if(null===(e=r.overrides)||void 0===e?void 0:e.hasOverride(n))return void(i=!0)};if("constant"===n.value.kind&&n.value.value instanceof ze)s(n.value.value.sections);else if("source"===n.value.kind||"composite"===n.value.kind){const t=e=>{i||(e instanceof Xe&&qe(e.value)===Xt?s(e.value.sections):e instanceof Pn?s(e.sections):e.eachChild(t));},e=n.value;e._styleExpression&&t(e._styleExpression.expression);}return i}}let Dp;var zp={get paint(){return Dp=Dp||new Ks({"background-color":new Xs(wt.paint_background["background-color"]),"background-pattern":new Hs(wt.paint_background["background-pattern"]),"background-opacity":new Xs(wt.paint_background["background-opacity"])})}};class Bp extends to{constructor(t,e){super(t,zp,e);}}class Cp extends to{constructor(t,e){super(t,{},e),this.onAdd=t=>{this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl);},this.onRemove=t=>{this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl);},this.implementation=t;}is3D(){return "3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return !1}serialize(){throw new Error("Custom layers cannot be serialized")}}class Vp{constructor(t){this._methodToThrottle=t,this._triggered=!1,this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle();};}trigger(){var t;this._triggered||(this._triggered=!0,null===(t=this._channel)||void 0===t||t.port1.postMessage(!0));}remove(){delete this._channel,this._methodToThrottle=()=>{};}}const Lp={once:!0},Op=6371008.8;class $p{constructor(t,e){if(isNaN(t)||isNaN(e))throw new Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new $p(O(this.lng,-180,180),this.lat)}toArray(){return [this.lng,this.lat]}toString(){return `LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const e=Math.PI/180,n=this.lat*e,r=t.lat*e,i=Math.sin(n)*Math.sin(r)+Math.cos(n)*Math.cos(r)*Math.cos((t.lng-this.lng)*e);return Op*Math.acos(Math.min(i,1))}static convert(t){if(t instanceof $p)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new $p(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new $p(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}const Rp=2*Math.PI*Op;function Np(t){return Rp*Math.cos(t*Math.PI/180)}function Up(t){return (180+t)/360}function jp(t){return (180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function qp(t,e){return t/Np(e)}function Gp(t){return 360*t-180}function Xp(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function Yp(t,e){return t*Np(Xp(e))}class Zp{constructor(t,e,n=0){this.x=+t,this.y=+e,this.z=+n;}static fromLngLat(t,e=0){const n=$p.convert(t);return new Zp(Up(n.lng),jp(n.lat),qp(e,n.lat))}toLngLat(){return new $p(Gp(this.x),Xp(this.y))}toAltitude(){return Yp(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Rp*(t=Xp(this.y),1/Math.cos(t*Math.PI/180));var t;}}function Hp(t,e,n){var r=2*Math.PI*6378137/256/Math.pow(2,n);return [t*r-2*Math.PI*6378137/2,e*r-2*Math.PI*6378137/2]}class Wp{constructor(t,e,n){if(!function(t,e,n){return !(t<0||t>25||n<0||n>=Math.pow(2,t)||e<0||e>=Math.pow(2,t))}(t,e,n))throw new Error(`x=${e}, y=${n}, z=${t} outside of bounds. 0<=x<${Math.pow(2,t)}, 0<=y<${Math.pow(2,t)} 0<=z<=25 `);this.z=t,this.x=e,this.y=n,this.key=Qp(0,t,t,e,n);}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e,n){const r=(s=this.y,o=this.z,a=Hp(256*(i=this.x),256*(s=Math.pow(2,o)-s-1),o),l=Hp(256*(i+1),256*(s+1),o),a[0]+","+a[1]+","+l[0]+","+l[1]);var i,s,o,a,l;const u=function(t,e,n){let r="";for(let i=t;i>0;i--){const t=1<<i-1;r+=(e&t?1:0)+(n&t?2:0);}return r}(this.z,this.x,this.y);return t[(this.x+this.y)%t.length].replace(/{prefix}/g,(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String("tms"===n?Math.pow(2,this.z)-this.y-1:this.y)).replace(/{ratio}/g,e>1?"@2x":"").replace(/{quadkey}/g,u).replace(/{bbox-epsg-3857}/g,r)}isChildOf(t){const e=this.z-t.z;return e>0&&t.x===this.x>>e&&t.y===this.y>>e}getTilePoint(t){const e=Math.pow(2,this.z);return new n((t.x*e-this.x)*T,(t.y*e-this.y)*T)}toString(){return `${this.z}/${this.x}/${this.y}`}}class Kp{constructor(t,e){this.wrap=t,this.canonical=e,this.key=Qp(t,e.z,e.z,e.x,e.y);}}class Jp{constructor(t,e,n,r,i){if(this.terrainRttPosMatrix32f=null,t<n)throw new Error(`overscaledZ should be >= z; overscaledZ = ${t}; z = ${n}`);this.overscaledZ=t,this.wrap=e,this.canonical=new Wp(n,+r,+i),this.key=Qp(e,t,n,r,i);}clone(){return new Jp(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const e=this.canonical.z-t;return t>this.canonical.z?new Jp(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Jp(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(t,e){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const n=this.canonical.z-t;return t>this.canonical.z?Qp(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y):Qp(this.wrap*+e,t,t,this.canonical.x>>n,this.canonical.y>>n)}isChildOf(t){if(t.wrap!==this.wrap)return !1;if(this.overscaledZ-t.overscaledZ<=0)return !1;if(0===t.overscaledZ)return this.overscaledZ>0;const e=this.canonical.z-t.canonical.z;return !(e<0)&&t.canonical.x===this.canonical.x>>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return [new Jp(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,n=2*this.canonical.x,r=2*this.canonical.y;return [new Jp(e,this.wrap,e,n,r),new Jp(e,this.wrap,e,n+1,r),new Jp(e,this.wrap,e,n,r+1),new Jp(e,this.wrap,e,n+1,r+1)]}isLessThan(t){return this.wrap<t.wrap||!(this.wrap>t.wrap)&&(this.overscaledZ<t.overscaledZ||!(this.overscaledZ>t.overscaledZ)&&(this.canonical.x<t.canonical.x||!(this.canonical.x>t.canonical.x)&&this.canonical.y<t.canonical.y))}wrapped(){return new Jp(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(t){return new Jp(this.overscaledZ,t,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new Kp(this.wrap,this.canonical)}toString(){return `${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(t){return this.canonical.getTilePoint(new Zp(t.x-this.wrap,t.y))}normalizeCoordinates(t,e,n=8192){if(t>=0&&t<n&&e>=0&&e<n)return {tileID:this,x:t,y:e};const r=Math.floor(t/n),i=Math.floor(e/n),s=t-r*n,o=e-i*n,a=this.canonical.z,l=1<<a,u=this.canonical.y+i;if(u<0||u>=l)return null;let c=this.canonical.x+r,h=this.wrap;return c<0?(h-=Math.ceil(-c/l),c=(c%l+l)%l):c>=l&&(h+=Math.floor(c/l),c%=l),{tileID:new Jp(this.overscaledZ,h,a,c,u),x:s,y:o}}}function Qp(t,e,n,r,i){(t*=2)<0&&(t=-1*t-1);const s=1<<n;return (s*s*t+s*i+r).toString(36)+n.toString(36)+e.toString(36)}ds("CanonicalTileID",Wp),ds("OverscaledTileID",Jp,{omit:["terrainRttPosMatrix32f"]});class tf{constructor(){this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0;}extend(t){return this.minX=Math.min(this.minX,t.x),this.minY=Math.min(this.minY,t.y),this.maxX=Math.max(this.maxX,t.x),this.maxY=Math.max(this.maxY,t.y),this}expandBy(t){return this.minX-=t,this.minY-=t,this.maxX+=t,this.maxY+=t,(this.minX>this.maxX||this.minY>this.maxY)&&(this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0),this}shrinkBy(t){return this.expandBy(-t)}map(t){const e=new tf;return e.extend(t(new n(this.minX,this.minY))),e.extend(t(new n(this.maxX,this.minY))),e.extend(t(new n(this.minX,this.maxY))),e.extend(t(new n(this.maxX,this.maxY))),e}static fromPoints(t){const e=new tf;for(const n of t)e.extend(n);return e}contains(t){return t.x>=this.minX&&t.x<=this.maxX&&t.y>=this.minY&&t.y<=this.maxY}empty(){return this.minX>this.maxX}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}covers(t){return !this.empty()&&!t.empty()&&t.minX>=this.minX&&t.maxX<=this.maxX&&t.minY>=this.minY&&t.maxY<=this.maxY}intersects(t){return !this.empty()&&!t.empty()&&t.minX<=this.maxX&&t.maxX>=this.minX&&t.minY<=this.maxY&&t.maxY>=this.minY}}class ef{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e<t.length;e++){const n=t[e];this._stringToNumber[n]=e,this._numberToString[e]=n;}}encode(t){return this._stringToNumber[t]}decode(t){if(t>=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${t} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[t]}}class nf{constructor(t,e,n,r,i){this.type="Feature",this._vectorTileFeature=t,this._x=n,this._y=r,this._z=e,this.properties=t.properties,this.id=i;}projectPoint(t,e,n,r){return [360*(t.x+e)/r-180,360/Math.PI*Math.atan(Math.exp((1-2*(t.y+n)/r)*Math.PI))-90]}projectLine(t,e,n,r){return t.map((t=>this.projectPoint(t,e,n,r)))}get geometry(){if(this._geometry)return this._geometry;const t=this._vectorTileFeature,e=t.extent*Math.pow(2,this._z),n=t.extent*this._x,r=t.extent*this._y,i=t.loadGeometry();switch(t.type){case 1:{const t=[];for(const e of i)t.push(e[0]);const s=this.projectLine(t,n,r,e);this._geometry=1===t.length?{type:"Point",coordinates:s[0]}:{type:"MultiPoint",coordinates:s};break}case 2:{const t=i.map((t=>this.projectLine(t,n,r,e)));this._geometry=1===t.length?{type:"LineString",coordinates:t[0]}:{type:"MultiLineString",coordinates:t};break}case 3:{const t=Lu(i),s=[];for(const i of t)s.push(i.map((t=>this.projectLine(t,n,r,e))));this._geometry=1===s.length?{type:"Polygon",coordinates:s[0]}:{type:"MultiPolygon",coordinates:s};break}default:throw new Error(`unknown feature type: ${t.type}`)}return this._geometry}set geometry(t){this._geometry=t;}toJSON(){const t={geometry:this.geometry};for(const e in this)"_geometry"!==e&&"_vectorTileFeature"!==e&&"_x"!==e&&"_y"!==e&&"_z"!==e&&(t[e]=this[e]);return t}}class rf{constructor(t,e,n){this._name=t,this.dataBuffer=e,"number"==typeof n?this._size=n:(this.nullabilityBuffer=n,this._size=n.size());}getValue(t){return this.nullabilityBuffer&&!this.nullabilityBuffer.get(t)?null:this.getValueFromBuffer(t)}has(t){return this.nullabilityBuffer?.get(t)||!this.nullabilityBuffer}get name(){return this._name}get size(){return this._size}}class sf extends rf{}class of extends sf{getValueFromBuffer(t){return this.dataBuffer[t]}}class af extends sf{getValueFromBuffer(t){return this.dataBuffer[t]}}class lf extends rf{constructor(t,e,n,r){super(t,e,r),this.delta=n;}}class uf extends lf{constructor(t,e,n,r){super(t,Int32Array.of(e),n,r);}getValueFromBuffer(t){return this.dataBuffer[0]+t*this.delta}}class cf extends rf{constructor(t,e,n,r){super(t,r?Int32Array.of(e):Uint32Array.of(e),n);}getValueFromBuffer(t){return this.dataBuffer[0]}}class hf{constructor(t,e,n,r,i=4096){this._name=t,this._geometryVector=e,this._idVector=n,this._propertyVectors=r,this._extent=i;}get name(){return this._name}get idVector(){return this._idVector}get geometryVector(){return this._geometryVector}get propertyVectors(){return this._propertyVectors}getPropertyVector(t){return this.propertyVectorsMap||(this.propertyVectorsMap=new Map(this._propertyVectors.map((t=>[t.name,t])))),this.propertyVectorsMap.get(t)}get numFeatures(){return this.geometryVector.numGeometries}get extent(){return this._extent}getFeatures(){const t=[],e=this.geometryVector.getGeometries();for(let n=0;n<this.numFeatures;n++){let r;if(this.idVector){const t=this.idVector.getValue(n);r=this.containsMaxSafeIntegerValues(this.idVector)&&null!==t?Number(t):t;}const i={coordinates:e[n],type:this.geometryVector.geometryType(n)},s={};for(const t of this.propertyVectors){if(!t)continue;const e=t.name,r=t.getValue(n);null!==r&&(s[e]=r);}t.push({id:r,geometry:i,properties:s});}return t}containsMaxSafeIntegerValues(t){return t instanceof of||t instanceof cf||t instanceof uf||t instanceof af}}class pf{constructor(t){this.value=t;}get(){return this.value}set(t){this.value=t;}increment(){return this.value++}add(t){this.value+=t;}}var ff,df;!function(t){t.NONE="NONE",t.DELTA="DELTA",t.COMPONENTWISE_DELTA="COMPONENTWISE_DELTA",t.RLE="RLE",t.MORTON="MORTON",t.PDE="PDE";}(ff||(ff={})),function(t){t.NONE="NONE",t.FAST_PFOR="FAST_PFOR",t.VARINT="VARINT",t.ALP="ALP";}(df||(df={}));const yf=new Uint32Array(33);yf[0]=0;for(let t=1;t<=32;t++)yf[t]=32===t?4294967295:4294967295>>>32-t;const mf=yf,gf=256;function xf(t,e){return t-t%e}function vf(t){const e=t>>>0;return ((255&e)<<24|(65280&e)<<8|e>>>8&65280|e>>>24&255)>>>0}const bf=function(){if(!Number.isFinite(65536))return 65536;const t=xf(Math.floor(65536),gf);return 0===t?gf:t}(),wf=3*bf/gf+bf|0;function _f(){const t=new Uint8Array(wf);return {dataToBePacked:new Array(33),dataPointers:new Int32Array(33),byteContainer:t,byteContainerI32:new Int32Array(t.buffer,t.byteOffset,t.byteLength>>>2),exceptionSizes:new Int32Array(33)}}function Sf(t,e,n,r,i){switch(i){case 1:!function(t,e,n,r){let i=r,s=e;for(let e=0;e<8;e++){const e=t[s++]>>>0;n[i++]=e>>>0&1,n[i++]=e>>>1&1,n[i++]=e>>>2&1,n[i++]=e>>>3&1,n[i++]=e>>>4&1,n[i++]=e>>>5&1,n[i++]=e>>>6&1,n[i++]=e>>>7&1,n[i++]=e>>>8&1,n[i++]=e>>>9&1,n[i++]=e>>>10&1,n[i++]=e>>>11&1,n[i++]=e>>>12&1,n[i++]=e>>>13&1,n[i++]=e>>>14&1,n[i++]=e>>>15&1,n[i++]=e>>>16&1,n[i++]=e>>>17&1,n[i++]=e>>>18&1,n[i++]=e>>>19&1,n[i++]=e>>>20&1,n[i++]=e>>>21&1,n[i++]=e>>>22&1,n[i++]=e>>>23&1,n[i++]=e>>>24&1,n[i++]=e>>>25&1,n[i++]=e>>>26&1,n[i++]=e>>>27&1,n[i++]=e>>>28&1,n[i++]=e>>>29&1,n[i++]=e>>>30&1,n[i++]=e>>>31&1;}}(t,e,n,r);break;case 2:!function(t,e,n,r){let i=r,s=e;for(let e=0;e<8;e++){const e=t[s++]>>>0,r=t[s++]>>>0;n[i++]=e>>>0&3,n[i++]=e>>>2&3,n[i++]=e>>>4&3,n[i++]=e>>>6&3,n[i++]=e>>>8&3,n[i++]=e>>>10&3,n[i++]=e>>>12&3,n[i++]=e>>>14&3,n[i++]=e>>>16&3,n[i++]=e>>>18&3,n[i++]=e>>>20&3,n[i++]=e>>>22&3,n[i++]=e>>>24&3,n[i++]=e>>>26&3,n[i++]=e>>>28&3,n[i++]=e>>>30&3,n[i++]=r>>>0&3,n[i++]=r>>>2&3,n[i++]=r>>>4&3,n[i++]=r>>>6&3,n[i++]=r>>>8&3,n[i++]=r>>>10&3,n[i++]=r>>>12&3,n[i++]=r>>>14&3,n[i++]=r>>>16&3,n[i++]=r>>>18&3,n[i++]=r>>>20&3,n[i++]=r>>>22&3,n[i++]=r>>>24&3,n[i++]=r>>>26&3,n[i++]=r>>>28&3,n[i++]=r>>>30&3;}}(t,e,n,r);break;case 3:!function(t,e,n,r){let i=r,s=e;for(let e=0;e<8;e++){const e=t[s++]>>>0,r=t[s++]>>>0,o=t[s++]>>>0;n[i++]=e>>>0&7,n[i++]=e>>>3&7,n[i++]=e>>>6&7,n[i++]=e>>>9&7,n[i++]=e>>>12&7,n[i++]=e>>>15&7,n[i++]=e>>>18&7,n[i++]=e>>>21&7,n[i++]=e>>>24&7,n[i++]=e>>>27&7,n[i++]=7&(e>>>30|(1&r)<<2),n[i++]=r>>>1&7,n[i++]=r>>>4&7,n[i++]=r>>>7&7,n[i++]=r>>>10&7,n[i++]=r>>>13&7,n[i++]=r>>>16&7,n[i++]=r>>>19&7,n[i++]=r>>>22&7,n[i++]=r>>>25&7,n[i++]=r>>>28&7,n[i++]=7&(r>>>31|(3&o)<<1),n[i++]=o>>>2&7,n[i++]=o>>>5&7,n[i++]=o>>>8&7,n[i++]=o>>>11&7,n[i++]=o>>>14&7,n[i++]=o>>>17&7,n[i++]=o>>>20&7,n[i++]=o>>>23&7,n[i++]=o>>>26&7,n[i++]=o>>>29&7;}}(t,e,n,r);break;case 4:!function(t,e,n,r){let i=r,s=e;for(let e=0;e<8;e++){const e=t[s++]>>>0,r=t[s++]>>>0,o=t[s++]>>>0,a=t[s++]>>>0;n[i++]=e>>>0&15,n[i++]=e>>>4&15,n[i++]=e>>>8&15,n[i++]=e>>>12&15,n[i++]=e>>>16&15,n[i++]=e>>>20&15,n[i++]=e>>>24&15,n[i++]=e>>>28&15,n[i++]=r>>>0&15,n[i++]=r>>>4&15,n[i++]=r>>>8&15,n[i++]=r>>>12&15,n[i++]=r>>>16&15,n[i++]=r>>>20&15,n[i++]=r>>>24&15,n[i++]=r>>>28&15,n[i++]=o>>>0&15,n[i++]=o>>>4&15,n[i++]=o>>>8&15,n[i++]=o>>>12&15,n[i++]=o>>>16&15,n[i++]=o>>>20&15,n[i++]=o>>>24&15,n[i++]=o>>>28&15,n[i++]=a>>>0&15,n[i++]=a>>>4&15,n[i++]=a>>>8&15,n[i++]=a>>>12&15,n[i++]=a>>>16&15,n[i++]=a>>>20&15,n[i++]=a>>>24&15,n[i++]=a>>>28&15;}}(t,e,n,r);break;case 5:!function(t,e,n,r){let i=r,s=e;for(let e=0;e<8;e++){const e=t[s++]>>>0,r=t[s++]>>>0,o=t[s++]>>>0,a=t[s++]>>>0,l=t[s++]>>>0;n[i++]=e>>>0&31,n[i++]=e>>>5&31,n[i++]=e>>>10&31,n[i++]=e>>>15&31,n[i++]=e>>>20&31,n[i++]=e>>>25&31,n[i++]=31&(e>>>30|(7&r)<<2),n[i++]=r>>>3&31,n[i++]=r>>>8&31,n[i++]=r>>>13&31,n[i++]=r>>>18&31,n[i++]=r>>>23&31,n[i++]=31&(r>>>28|(1&o)<<4),n[i++]=o>>>1&31,n[i++]=o>>>6&31,n[i++]=o>>>11&31,n[i++]=o>>>16&31,n[i++]=o>>>21&31,n[i++]=o>>>26&31,n[i++]=31&(o>>>31|(15&a)<<1),n[i++]=a>>>4&31,n[i++]=a>>>9&31,n[i++]=a>>>14&31,n[i++]=a>>>19&31,n[i++]=a>>>24&31,n[i++]=31&(a>>>29|(3&l)<<3),n[i++]=l>>>2&31,n[i++]=l>>>7&31,n[i++]=l>>>12&31,n[i++]=l>>>17&31,n[i++]=l>>>22&31,n[i++]=l>>>27&31;}}(t,e,n,r);break;case 6:!function(t,e,n,r){let i=r,s=e;for(let e=0;e<8;e++){const e=t[s++]>>>0,r=t[s++]>>>0,o=t[s++]>>>0,a=t[s++]>>>0,l=t[s++]>>>0,u=t[s++]>>>0;n[i++]=e>>>0&63,n[i++]=e>>>6&63,n[i++]=e>>>12&63,n[i++]=e>>>18&63,n[i++]=e>>>24&63,n[i++]=63&(e>>>30|(15&r)<<2),n[i++]=r>>>4&63,n[i++]=r>>>10&63,n[i++]=r>>>16&63,n[i++]=r>>>22&63,n[i++]=63&(r>>>28|(3&o)<<4),n[i++]=o>>>2&63,n[i++]=o>>>8&63,n[i++]=o>>>14&63,n[i++]=o>>>20&63,n[i++]=o>>>26&63,n[i++]=a>>>0&63,n[i++]=a>>>6&63,n[i++]=a>>>12&63,n[i++]=a>>>18&63,n[i++]=a>>>24&63,n[i++]=63&(a>>>30|(15&l)<<2),n[i++]=l>>>4&63,n[i++]=l>>>10&63,n[i++]=l>>>16&63,n[i++]=l>>>22&63,n[i++]=63&(l>>>28|(3&u)<<4),n[i++]=u>>>2&63,n[i++]=u>>>8&63,n[i++]=u>>>14&63,n[i++]=u>>>20&63,n[i++]=u>>>26&63;}}(t,e,n,r);break;case 7:!function(t,e,n,r){let i=r,s=e;for(let e=0;e<8;e++){const e=t[s++]>>>0,r=t[s++]>>>0,o=t[s++]>>>0,a=t[s++]>>>0,l=t[s++]>>>0,u=t[s++]>>>0,c=t[s++]>>>0;n[i++]=e>>>0&127,n[i++]=e>>>7&127,n[i++]=e>>>14&127,n[i++]=e>>>21&127,n[i++]=127&(e>>>28|(7&r)<<4),n[i++]=r>>>3&127,n[i++]=r>>>10&127,n[i++]=r>>>17&127,n[i++]=r>>>24&127,n[i++]=127&(r>>>31|(63&o)<<1),n[i++]=o>>>6&127,n[i++]=o>>>13&127,n[i++]=o>>>20&127,n[i++]=127&(o>>>27|(3&a)<<5),n[i++]=a>>>2&127,n[i++]=a>>>9&127,n[i++]=a>>>16&127,n[i++]=a>>>23&127,n[i++]=127&(a>>>30|(31&l)<<2),n[i++]=l>>>5&127,n[i++]=l>>>12&127,n[i++]=l>>>19&127,n[i++]=127&(l>>>26|(1&u)<<6),n[i++]=u>>>1&127,n[i++]=u>>>8&127,n[i++]=u>>>15&127,n[i++]=u>>>22&127,n[i++]=127&(u>>>29|(15&c)<<3),n[i++]=c>>>4&127,n[i++]=c>>>11&127,n[i++]=c>>>18&127,n[i++]=c>>>25&127;}}(t,e,n,r);break;case 8:!function(t,e,n,r){let i=r,s=e;for(let e=0;e<8;e++){const e=t[s++]>>>0,r=t[s++]>>>0,o=t[s++]>>>0,a=t[s++]>>>0,l=t[s++]>>>0,u=t[s++]>>>0,c=t[s++]>>>0,h=t[s++]>>>0;n[i++]=e>>>0&255,n[i++]=e>>>8&255,n[i++]=e>>>16&255,n[i++]=e>>>24&255,n[i++]=r>>>0&255,n[i++]=r>>>8&255,n[i++]=r>>>16&255,n[i++]=r>>>24&255,n[i++]=o>>>0&255,n[i++]=o>>>8&255,n[i++]=o>>>16&255,n[i++]=o>>>24&255,n[i++]=a>>>0&255,n[i++]=a>>>8&255,n[i++]=a>>>16&255,n[i++]=a>>>24&255,n[i++]=l>>>0&255,n[i++]=l>>>8&255,n[i++]=l>>>16&255,n[i++]=l>>>24&255,n[i++]=u>>>0&255,n[i++]=u>>>8&255,n[i++]=u>>>16&255,n[i++]=u>>>24&255,n[i++]=c>>>0&255,n[i++]=c>>>8&255,n[i++]=c>>>16&255,n[i++]=c>>>24&255,n[i++]=h>>>0&255,n[i++]=h>>>8&255,n[i++]=h>>>16&255,n[i++]=h>>>24&255;}}(t,e,n,r);break;case 16:!function(t,e,n,r){let i=r,s=e;for(let e=0;e<128;e++){const e=t[s++]>>>0;n[i++]=65535&e,n[i++]=e>>>16&65535;}}(t,e,n,r);break;default:!function(t,e,n,r,i){const s=mf[i]>>>0;let o=e,a=0,l=t[o]>>>0,u=r;for(let e=0;e<8;e++){for(let e=0;e<32;e++)if(a+i<=32)n[u+e]=l>>>a&s,a+=i,32===a&&(a=0,o++,31!==e&&(l=t[o]>>>0));else {const r=32-a,c=l>>>a;o++,l=t[o]>>>0;const h=i-r;n[u+e]=(c|(l&-1>>>32-h>>>0)<<r)&s,a=h;}u+=32,a=0,e<7&&(l=t[o]>>>0);}}(t,e,n,r,i);}return e+(i<<3)|0}function Af(t,e,n,r){if(n+2>e)throw new Error(`FastPFOR decode: byteContainer underflow at block=${r} (need 2 bytes for [bitWidth, exceptionCount], bytePos=${n}, byteSize=${e})`);const i=t[n++],s=t[n++];if(i>32)throw new Error(`FastPFOR decode: invalid bitWidth=${i} at block=${r} (expected 0..32). This likely indicates corrupted or truncated input.`);return {bitWidth:i,exceptionCount:s,bytePosIn:n}}function Mf(t,e,n,r,i,s,o,a,l){const{maxBits:u,exceptionBitWidth:c,bytePosIn:h}=function(t,e,n,r,i,s){if(n+1>e)throw new Error(`FastPFOR decode: exception header underflow at block=${s} (need 1 byte for maxBits, bytePos=${n}, byteSize=${e})`);const o=t[n++];if(o<r||o>32)throw new Error(`FastPFOR decode: invalid maxBits=${o} at block=${s} (bitWidth=${r}, expected ${r}..32)`);const a=o-r|0;if(a<1||a>32)throw new Error(`FastPFOR decode: invalid exceptionBitWidth=${a} at block=${s} (bitWidth=${r}, maxBits=${o})`);if(n+i>e)throw new Error(`FastPFOR decode: exception positions underflow at block=${s} (need=${i}, have=${e-n})`);return {maxBits:o,exceptionBitWidth:a,bytePosIn:n}}(i,s,o,n,r,l);if(o=h,1===c){const s=1<<n;for(let n=0;n<r;n=n+1|0)t[i[o++]+e|0]|=s;return o}const p=a.dataToBePacked[c];if(!p)throw new Error(`FastPFOR decode: missing exception stream for exceptionBitWidth=${c} (bitWidth=${n}, maxBits=${u}) at block ${l}`);const f=a.dataPointers;let d=0|f[c];const y=0|a.exceptionSizes[c];if(d+r>y)throw new Error(`FastPFOR decode: exception stream overflow for exceptionBitWidth=${c} (ptr=${d}, need ${r}, size=${y}) at block ${l}`);for(let s=0;s<r;s=s+1|0){const r=i[o++],s=0|p[d++];t[r+e|0]|=s<<n;}return f[c]=d,o}function kf(t,e,n,r,i,s){const o=0|n,a=0|t[o];if(a<=0||o+a>t.length-1)throw new Error(`FastPFOR decode: invalid whereMeta=${a} at pageStart=${o} (expected > 0 and pageStart+whereMeta < encoded.length=${t.length})`);const l=o+1|0,u=o+a|0,c=t[u]>>>0,h=c+3>>>2,p=u+1,f=p+h;if(f>=t.length)throw new Error(`FastPFOR decode: invalid byteSize=${c} (metaInts=${h}, pageStart=${o}, packedEnd=${u}, byteContainerStart=${p}) causes bitmapPos=${f} out of bounds (encoded.length=${t.length})`);const d=function(t,e,n,r){r.byteContainer.length<n&&(r.byteContainer=new Uint8Array(2*n),r.byteContainerI32=void 0);const i=r.byteContainer,s=n>>>2;if(3&i.byteOffset)for(let n=0;n<s;n=n+1|0){const r=0|t[e+n|0],s=n<<2;i[s]=255&r,i[s+1|0]=r>>>8&255,i[s+2|0]=r>>>16&255,i[s+3|0]=r>>>24&255;}else {let n=r.byteContainerI32;(!n||n.buffer!==i.buffer||n.byteOffset!==i.byteOffset||n.length<s)&&(n=r.byteContainerI32=new Int32Array(i.buffer,i.byteOffset,i.byteLength>>>2)),n.set(t.subarray(e,e+s));}const o=3&n;if(o>0){const n=0|t[e+s|0],r=s<<2;for(let t=0;t<o;t=t+1|0)i[r+t|0]=n>>>(t<<3)&255;}return i}(t,p,c,s),y=c,m=function(t,e,n){const r=0|t[e++],i=n.dataToBePacked;for(let s=2;s<=32;s=s+1|0){if(!(r>>>s-1&1))continue;if(e>=t.length)throw new Error(`FastPFOR decode: truncated exception stream header (bitWidth=${s}, streamWordIndex=${e}, needWords=1, availableWords=${t.length-e}, encodedWords=${t.length})`);const o=t[e++]>>>0,a=xf(o+31,32),l=o*s+31>>>5;if(e+l>t.length)throw new Error(`FastPFOR decode: truncated exception stream (bitWidth=${s}, size=${o}, streamWordIndex=${e}, needWords=${l}, availableWords=${t.length-e}, encodedWords=${t.length})`);let u=i[s];(!u||u.length<a)&&(u=i[s]=new Uint32Array(a));let c=0;for(;c<o;c=c+32|0)If(t,e,u,c,s),e=e+s|0;e=e-((c-o|0)*s>>>5)|0,n.exceptionSizes[s]=o;}return e}(t,f,s);return s.dataPointers.fill(0),function(t,e,n,r,i,s,o,a,l,u){let c=0|n,h=0;for(let e=0;e<o;e=e+1|0){const n=Af(a,l,h,e);h=n.bytePosIn;const r=n.bitWidth,o=n.exceptionCount,p=s+e*gf|0;switch(r){case 0:i.fill(0,p,p+gf);break;case 32:for(let e=0;e<gf;e=e+1|0)i[p+e|0]=0|t[c+e|0];c=c+gf|0;break;default:c=Sf(t,c,i,p,r);}o>0&&(h=Mf(i,p,r,o,a,l,h,u,e));}if(c!==r)throw new Error(`FastPFOR decode: packed region mismatch (pageStart=${e}, packedStart=${n}, consumedPackedEnd=${c}, expectedPackedEnd=${r}, packedWords=${r-n}, encoded.length=${t.length})`)}(t,o,l,u,e,0|r,i/gf|0,d,y,s),m}function If(t,e,n,r,i){switch(i){case 2:return void function(t,e,n,r){let i=r;const s=t[e]>>>0,o=t[e+1]>>>0;n[i++]=s>>>0&3,n[i++]=s>>>2&3,n[i++]=s>>>4&3,n[i++]=s>>>6&3,n[i++]=s>>>8&3,n[i++]=s>>>10&3,n[i++]=s>>>12&3,n[i++]=s>>>14&3,n[i++]=s>>>16&3,n[i++]=s>>>18&3,n[i++]=s>>>20&3,n[i++]=s>>>22&3,n[i++]=s>>>24&3,n[i++]=s>>>26&3,n[i++]=s>>>28&3,n[i++]=s>>>30&3,n[i++]=o>>>0&3,n[i++]=o>>>2&3,n[i++]=o>>>4&3,n[i++]=o>>>6&3,n[i++]=o>>>8&3,n[i++]=o>>>10&3,n[i++]=o>>>12&3,n[i++]=o>>>14&3,n[i++]=o>>>16&3,n[i++]=o>>>18&3,n[i++]=o>>>20&3,n[i++]=o>>>22&3,n[i++]=o>>>24&3,n[i++]=o>>>26&3,n[i++]=o>>>28&3,n[i]=o>>>30&3;}(t,e,n,r);case 3:return void function(t,e,n,r){let i=r;const s=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0;n[i++]=s>>>0&7,n[i++]=s>>>3&7,n[i++]=s>>>6&7,n[i++]=s>>>9&7,n[i++]=s>>>12&7,n[i++]=s>>>15&7,n[i++]=s>>>18&7,n[i++]=s>>>21&7,n[i++]=s>>>24&7,n[i++]=s>>>27&7,n[i++]=7&(s>>>30|(1&o)<<2),n[i++]=o>>>1&7,n[i++]=o>>>4&7,n[i++]=o>>>7&7,n[i++]=o>>>10&7,n[i++]=o>>>13&7,n[i++]=o>>>16&7,n[i++]=o>>>19&7,n[i++]=o>>>22&7,n[i++]=o>>>25&7,n[i++]=o>>>28&7,n[i++]=7&(o>>>31|(3&a)<<1),n[i++]=a>>>2&7,n[i++]=a>>>5&7,n[i++]=a>>>8&7,n[i++]=a>>>11&7,n[i++]=a>>>14&7,n[i++]=a>>>17&7,n[i++]=a>>>20&7,n[i++]=a>>>23&7,n[i++]=a>>>26&7,n[i]=a>>>29&7;}(t,e,n,r);case 4:return void function(t,e,n,r){let i=r;const s=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,l=t[e+3]>>>0;n[i++]=s>>>0&15,n[i++]=s>>>4&15,n[i++]=s>>>8&15,n[i++]=s>>>12&15,n[i++]=s>>>16&15,n[i++]=s>>>20&15,n[i++]=s>>>24&15,n[i++]=s>>>28&15,n[i++]=o>>>0&15,n[i++]=o>>>4&15,n[i++]=o>>>8&15,n[i++]=o>>>12&15,n[i++]=o>>>16&15,n[i++]=o>>>20&15,n[i++]=o>>>24&15,n[i++]=o>>>28&15,n[i++]=a>>>0&15,n[i++]=a>>>4&15,n[i++]=a>>>8&15,n[i++]=a>>>12&15,n[i++]=a>>>16&15,n[i++]=a>>>20&15,n[i++]=a>>>24&15,n[i++]=a>>>28&15,n[i++]=l>>>0&15,n[i++]=l>>>4&15,n[i++]=l>>>8&15,n[i++]=l>>>12&15,n[i++]=l>>>16&15,n[i++]=l>>>20&15,n[i++]=l>>>24&15,n[i]=l>>>28&15;}(t,e,n,r);case 5:return void function(t,e,n,r){let i=r;const s=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,l=t[e+3]>>>0,u=t[e+4]>>>0;n[i++]=s>>>0&31,n[i++]=s>>>5&31,n[i++]=s>>>10&31,n[i++]=s>>>15&31,n[i++]=s>>>20&31,n[i++]=s>>>25&31,n[i++]=31&(s>>>30|(7&o)<<2),n[i++]=o>>>3&31,n[i++]=o>>>8&31,n[i++]=o>>>13&31,n[i++]=o>>>18&31,n[i++]=o>>>23&31,n[i++]=31&(o>>>28|(1&a)<<4),n[i++]=a>>>1&31,n[i++]=a>>>6&31,n[i++]=a>>>11&31,n[i++]=a>>>16&31,n[i++]=a>>>21&31,n[i++]=a>>>26&31,n[i++]=31&(a>>>31|(15&l)<<1),n[i++]=l>>>4&31,n[i++]=l>>>9&31,n[i++]=l>>>14&31,n[i++]=l>>>19&31,n[i++]=l>>>24&31,n[i++]=31&(l>>>29|(3&u)<<3),n[i++]=u>>>2&31,n[i++]=u>>>7&31,n[i++]=u>>>12&31,n[i++]=u>>>17&31,n[i++]=u>>>22&31,n[i]=u>>>27&31;}(t,e,n,r);case 6:return void function(t,e,n,r){let i=r;const s=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,l=t[e+3]>>>0,u=t[e+4]>>>0,c=t[e+5]>>>0;n[i++]=s>>>0&63,n[i++]=s>>>6&63,n[i++]=s>>>12&63,n[i++]=s>>>18&63,n[i++]=s>>>24&63,n[i++]=63&(s>>>30|(15&o)<<2),n[i++]=o>>>4&63,n[i++]=o>>>10&63,n[i++]=o>>>16&63,n[i++]=o>>>22&63,n[i++]=63&(o>>>28|(3&a)<<4),n[i++]=a>>>2&63,n[i++]=a>>>8&63,n[i++]=a>>>14&63,n[i++]=a>>>20&63,n[i++]=a>>>26&63,n[i++]=l>>>0&63,n[i++]=l>>>6&63,n[i++]=l>>>12&63,n[i++]=l>>>18&63,n[i++]=l>>>24&63,n[i++]=63&(l>>>30|(15&u)<<2),n[i++]=u>>>4&63,n[i++]=u>>>10&63,n[i++]=u>>>16&63,n[i++]=u>>>22&63,n[i++]=63&(u>>>28|(3&c)<<4),n[i++]=c>>>2&63,n[i++]=c>>>8&63,n[i++]=c>>>14&63,n[i++]=c>>>20&63,n[i]=c>>>26&63;}(t,e,n,r);case 7:return void function(t,e,n,r){let i=r;const s=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,l=t[e+3]>>>0,u=t[e+4]>>>0,c=t[e+5]>>>0,h=t[e+6]>>>0;n[i++]=s>>>0&127,n[i++]=s>>>7&127,n[i++]=s>>>14&127,n[i++]=s>>>21&127,n[i++]=127&(s>>>28|(7&o)<<4),n[i++]=o>>>3&127,n[i++]=o>>>10&127,n[i++]=o>>>17&127,n[i++]=o>>>24&127,n[i++]=127&(o>>>31|(63&a)<<1),n[i++]=a>>>6&127,n[i++]=a>>>13&127,n[i++]=a>>>20&127,n[i++]=127&(a>>>27|(3&l)<<5),n[i++]=l>>>2&127,n[i++]=l>>>9&127,n[i++]=l>>>16&127,n[i++]=l>>>23&127,n[i++]=127&(l>>>30|(31&u)<<2),n[i++]=u>>>5&127,n[i++]=u>>>12&127,n[i++]=u>>>19&127,n[i++]=127&(u>>>26|(1&c)<<6),n[i++]=c>>>1&127,n[i++]=c>>>8&127,n[i++]=c>>>15&127,n[i++]=c>>>22&127,n[i++]=127&(c>>>29|(15&h)<<3),n[i++]=h>>>4&127,n[i++]=h>>>11&127,n[i++]=h>>>18&127,n[i]=h>>>25&127;}(t,e,n,r);case 8:return void function(t,e,n,r){let i=r;const s=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,l=t[e+3]>>>0,u=t[e+4]>>>0,c=t[e+5]>>>0,h=t[e+6]>>>0,p=t[e+7]>>>0;n[i++]=s>>>0&255,n[i++]=s>>>8&255,n[i++]=s>>>16&255,n[i++]=s>>>24&255,n[i++]=o>>>0&255,n[i++]=o>>>8&255,n[i++]=o>>>16&255,n[i++]=o>>>24&255,n[i++]=a>>>0&255,n[i++]=a>>>8&255,n[i++]=a>>>16&255,n[i++]=a>>>24&255,n[i++]=l>>>0&255,n[i++]=l>>>8&255,n[i++]=l>>>16&255,n[i++]=l>>>24&255,n[i++]=u>>>0&255,n[i++]=u>>>8&255,n[i++]=u>>>16&255,n[i++]=u>>>24&255,n[i++]=c>>>0&255,n[i++]=c>>>8&255,n[i++]=c>>>16&255,n[i++]=c>>>24&255,n[i++]=h>>>0&255,n[i++]=h>>>8&255,n[i++]=h>>>16&255,n[i++]=h>>>24&255,n[i++]=p>>>0&255,n[i++]=p>>>8&255,n[i++]=p>>>16&255,n[i]=p>>>24&255;}(t,e,n,r);case 9:return void function(t,e,n,r){let i=r;const s=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,l=t[e+3]>>>0,u=t[e+4]>>>0,c=t[e+5]>>>0,h=t[e+6]>>>0,p=t[e+7]>>>0,f=t[e+8]>>>0;n[i++]=s>>>0&511,n[i++]=s>>>9&511,n[i++]=s>>>18&511,n[i++]=511&(s>>>27|(15&o)<<5),n[i++]=o>>>4&511,n[i++]=o>>>13&511,n[i++]=o>>>22&511,n[i++]=511&(o>>>31|(255&a)<<1),n[i++]=a>>>8&511,n[i++]=a>>>17&511,n[i++]=511&(a>>>26|(7&l)<<6),n[i++]=l>>>3&511,n[i++]=l>>>12&511,n[i++]=l>>>21&511,n[i++]=511&(l>>>30|(127&u)<<2),n[i++]=u>>>7&511,n[i++]=u>>>16&511,n[i++]=511&(u>>>25|(3&c)<<7),n[i++]=c>>>2&511,n[i++]=c>>>11&511,n[i++]=c>>>20&511,n[i++]=511&(c>>>29|(63&h)<<3),n[i++]=h>>>6&511,n[i++]=h>>>15&511,n[i++]=511&(h>>>24|(1&p)<<8),n[i++]=p>>>1&511,n[i++]=p>>>10&511,n[i++]=p>>>19&511,n[i++]=511&(p>>>28|(31&f)<<4),n[i++]=f>>>5&511,n[i++]=f>>>14&511,n[i]=f>>>23&511;}(t,e,n,r);case 10:return void function(t,e,n,r){let i=r;const s=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,l=t[e+3]>>>0,u=t[e+4]>>>0,c=t[e+5]>>>0,h=t[e+6]>>>0,p=t[e+7]>>>0,f=t[e+8]>>>0,d=t[e+9]>>>0;n[i++]=s>>>0&1023,n[i++]=s>>>10&1023,n[i++]=s>>>20&1023,n[i++]=1023&(s>>>30|(255&o)<<2),n[i++]=o>>>8&1023,n[i++]=o>>>18&1023,n[i++]=1023&(o>>>28|(63&a)<<4),n[i++]=a>>>6&1023,n[i++]=a>>>16&1023,n[i++]=1023&(a>>>26|(15&l)<<6),n[i++]=l>>>4&1023,n[i++]=l>>>14&1023,n[i++]=1023&(l>>>24|(3&u)<<8),n[i++]=u>>>2&1023,n[i++]=u>>>12&1023,n[i++]=u>>>22&1023,n[i++]=c>>>0&1023,n[i++]=c>>>10&1023,n[i++]=c>>>20&1023,n[i++]=1023&(c>>>30|(255&h)<<2),n[i++]=h>>>8&1023,n[i++]=h>>>18&1023,n[i++]=1023&(h>>>28|(63&p)<<4),n[i++]=p>>>6&1023,n[i++]=p>>>16&1023,n[i++]=1023&(p>>>26|(15&f)<<6),n[i++]=f>>>4&1023,n[i++]=f>>>14&1023,n[i++]=1023&(f>>>24|(3&d)<<8),n[i++]=d>>>2&1023,n[i++]=d>>>12&1023,n[i]=d>>>22&1023;}(t,e,n,r);case 11:return void function(t,e,n,r){let i=r;const s=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,l=t[e+3]>>>0,u=t[e+4]>>>0,c=t[e+5]>>>0,h=t[e+6]>>>0,p=t[e+7]>>>0,f=t[e+8]>>>0,d=t[e+9]>>>0,y=t[e+10]>>>0;n[i++]=s>>>0&2047,n[i++]=s>>>11&2047,n[i++]=2047&(s>>>22|(1&o)<<10),n[i++]=o>>>1&2047,n[i++]=o>>>12&2047,n[i++]=2047&(o>>>23|(3&a)<<9),n[i++]=a>>>2&2047,n[i++]=a>>>13&2047,n[i++]=2047&(a>>>24|(7&l)<<8),n[i++]=l>>>3&2047,n[i++]=l>>>14&2047,n[i++]=2047&(l>>>25|(15&u)<<7),n[i++]=u>>>4&2047,n[i++]=u>>>15&2047,n[i++]=2047&(u>>>26|(31&c)<<6),n[i++]=c>>>5&2047,n[i++]=c>>>16&2047,n[i++]=2047&(c>>>27|(63&h)<<5),n[i++]=h>>>6&2047,n[i++]=h>>>17&2047,n[i++]=2047&(h>>>28|(127&p)<<4),n[i++]=p>>>7&2047,n[i++]=p>>>18&2047,n[i++]=2047&(p>>>29|(255&f)<<3),n[i++]=f>>>8&2047,n[i++]=f>>>19&2047,n[i++]=2047&(f>>>30|(511&d)<<2),n[i++]=d>>>9&2047,n[i++]=d>>>20&2047,n[i++]=2047&(d>>>31|(1023&y)<<1),n[i++]=y>>>10&2047,n[i]=y>>>21&2047;}(t,e,n,r);case 12:return void function(t,e,n,r){let i=r;const s=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,l=t[e+3]>>>0,u=t[e+4]>>>0,c=t[e+5]>>>0,h=t[e+6]>>>0,p=t[e+7]>>>0,f=t[e+8]>>>0,d=t[e+9]>>>0,y=t[e+10]>>>0,m=t[e+11]>>>0;n[i++]=s>>>0&4095,n[i++]=s>>>12&4095,n[i++]=4095&(s>>>24|(15&o)<<8),n[i++]=o>>>4&4095,n[i++]=o>>>16&4095,n[i++]=4095&(o>>>28|(255&a)<<4),n[i++]=a>>>8&4095,n[i++]=a>>>20&4095,n[i++]=l>>>0&4095,n[i++]=l>>>12&4095,n[i++]=4095&(l>>>24|(15&u)<<8),n[i++]=u>>>4&4095,n[i++]=u>>>16&4095,n[i++]=4095&(u>>>28|(255&c)<<4),n[i++]=c>>>8&4095,n[i++]=c>>>20&4095,n[i++]=h>>>0&4095,n[i++]=h>>>12&4095,n[i++]=4095&(h>>>24|(15&p)<<8),n[i++]=p>>>4&4095,n[i++]=p>>>16&4095,n[i++]=4095&(p>>>28|(255&f)<<4),n[i++]=f>>>8&4095,n[i++]=f>>>20&4095,n[i++]=d>>>0&4095,n[i++]=d>>>12&4095,n[i++]=4095&(d>>>24|(15&y)<<8),n[i++]=y>>>4&4095,n[i++]=y>>>16&4095,n[i++]=4095&(y>>>28|(255&m)<<4),n[i++]=m>>>8&4095,n[i]=m>>>20&4095;}(t,e,n,r);case 16:return void function(t,e,n,r){let i=r;const s=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,l=t[e+3]>>>0,u=t[e+4]>>>0,c=t[e+5]>>>0,h=t[e+6]>>>0,p=t[e+7]>>>0,f=t[e+8]>>>0,d=t[e+9]>>>0,y=t[e+10]>>>0,m=t[e+11]>>>0,g=t[e+12]>>>0,x=t[e+13]>>>0,v=t[e+14]>>>0,b=t[e+15]>>>0;n[i++]=s>>>0&65535,n[i++]=s>>>16&65535,n[i++]=o>>>0&65535,n[i++]=o>>>16&65535,n[i++]=a>>>0&65535,n[i++]=a>>>16&65535,n[i++]=l>>>0&65535,n[i++]=l>>>16&65535,n[i++]=u>>>0&65535,n[i++]=u>>>16&65535,n[i++]=c>>>0&65535,n[i++]=c>>>16&65535,n[i++]=h>>>0&65535,n[i++]=h>>>16&65535,n[i++]=p>>>0&65535,n[i++]=p>>>16&65535,n[i++]=f>>>0&65535,n[i++]=f>>>16&65535,n[i++]=d>>>0&65535,n[i++]=d>>>16&65535,n[i++]=y>>>0&65535,n[i++]=y>>>16&65535,n[i++]=m>>>0&65535,n[i++]=m>>>16&65535,n[i++]=g>>>0&65535,n[i++]=g>>>16&65535,n[i++]=x>>>0&65535,n[i++]=x>>>16&65535,n[i++]=v>>>0&65535,n[i++]=v>>>16&65535,n[i++]=b>>>0&65535,n[i]=b>>>16&65535;}(t,e,n,r);case 32:for(let i=0;i<32;i=i+1|0)n[r+i|0]=0|t[e+i|0];return}const s=mf[i]>>>0;let o=e,a=0,l=t[o]>>>0;for(let e=0;e<32;e++)if(a+i<=32)n[r+e]=l>>>a&s,a+=i,32===a&&(a=0,o++,31!==e&&(l=t[o]>>>0));else {const u=32-a,c=l>>>a;o++,l=t[o]>>>0,n[r+e]=(c|(l&mf[i-u]>>>0)<<u)&s,a=i-u;}}function Ef(t,e,n){const r=new Uint32Array(n);let i=0,s=e.get();for(let e=0;e<r.length;e++){let e=t[s++],n=127&e;e<128||(e=t[s++],n|=(127&e)<<7,e<128||(e=t[s++],n|=(127&e)<<14,e<128||(e=t[s++],n|=(127&e)<<21,e<128||(e=t[s++],n|=(15&e)<<28)))),r[i++]=n;}return e.set(s),r}function Tf(t,e,n){const r=new BigUint64Array(n);for(let n=0;n<r.length;n++)r[n]=Ff(t,e);return r}function Ff(t,e){let n=0n,r=0,i=e.get();for(;i<t.length;){const e=t[i++];if(n|=BigInt(127&e)<<BigInt(r),!(128&e))break;if(r+=7,r>=64)throw new Error("Varint too long")}return e.set(i),n}function Pf(t,e){let n,r;return r=t[e.get()],e.increment(),n=127&r,r<128?n:(r=t[e.get()],e.increment(),n|=(127&r)<<7,r<128?n:(r=t[e.get()],e.increment(),n|=(127&r)<<14,r<128?n:(r=t[e.get()],e.increment(),n|=(127&r)<<21,r<128?n:(r=t[e.get()],n|=(15&r)<<28,function(t,e,n){let r,i;if(i=e[n.get()],n.increment(),r=(112&i)>>4,i<128)return 4294967296*r+(t>>>0);if(i=e[n.get()],n.increment(),r|=(127&i)<<3,i<128)return 4294967296*r+(t>>>0);if(i=e[n.get()],n.increment(),r|=(127&i)<<10,i<128)return 4294967296*r+(t>>>0);if(i=e[n.get()],n.increment(),r|=(127&i)<<17,i<128)return 4294967296*r+(t>>>0);if(i=e[n.get()],n.increment(),r|=(127&i)<<24,i<128)return 4294967296*r+(t>>>0);if(i=e[n.get()],n.increment(),r|=(1&i)<<31,i<128)return 4294967296*r+(t>>>0);throw new Error("Expected varint not more than 10 bytes")}(n,t,e)))))}function Df(t){return t>>>1^-(1&t)}function zf(t){return t>>1n^-(1n&t)}function Bf(t){return t%2==1?(t+1)/-2:t/2}function Cf(t,e,n){if(void 0===n){n=0;for(let r=0;r<e;r++)n+=t[r];}const r=new Uint32Array(n);let i=0;for(let n=0;n<e;n++){const s=t[n];r.fill(t[n+e],i,i+s),i+=s;}return r}function Vf(t,e,n){if(void 0===n){n=0;for(let r=0;r<e;r++)n+=Number(t[r]);}const r=new BigUint64Array(n);let i=0;for(let n=0;n<e;n++){const s=Number(t[n]);r.fill(t[n+e],i,i+s),i+=s;}return r}function Lf(t,e,n){const r=new Float64Array(n);let i=0;for(let n=0;n<e;n++){const s=t[n];r.fill(t[n+e],i,i+s),i+=s;}return r}function Of(t){const e=new Int32Array(t.length);e[0]=Df(t[0]);const n=t.length/4*4;let r=1;if(n>=4)for(;r<n-4;r+=4){const n=t[r+1],i=t[r+2],s=t[r+3];e[r]=Df(t[r])+e[r-1],e[r+1]=Df(n)+e[r],e[r+2]=Df(i)+e[r+1],e[r+3]=Df(s)+e[r+2];}for(;r!==t.length;++r)e[r]=Df(t[r])+e[r-1];return e}function $f(t){const e=new BigInt64Array(t.length);e[0]=zf(t[0]);const n=t.length/4*4;let r=1;if(n>=4)for(;r<n-4;r+=4){const n=t[r+1],i=t[r+2],s=t[r+3];e[r]=zf(t[r])+e[r-1],e[r+1]=zf(n)+e[r],e[r+2]=zf(i)+e[r+1],e[r+3]=zf(s)+e[r+2];}for(;r!==e.length;++r)e[r]=zf(t[r])+e[r-1];return e}function Rf(t){const e=t.length/4*4;let n=1;if(e>=4)for(let r=t[0];n<e-4;n+=4)r=t[n]+=r,r=t[n+1]+=r,r=t[n+2]+=r,r=t[n+3]+=r;for(;n!==t.length;)t[n]+=t[n-1],++n;}var Nf,Uf,jf,qf,Gf,Xf,Yf,Zf;function Hf(t,e){const n=function(t,e){const n=t[e.get()],r=Object.values(Nf)[n>>4];let i=null;switch(r){case Nf.DATA:i={dictionaryType:Object.values(Uf)[15&n]};break;case Nf.OFFSET:i={offsetType:Object.values(jf)[15&n]};break;case Nf.LENGTH:i={lengthType:Object.values(qf)[15&n]};}e.increment();const s=t[e.get()],o=Object.values(ff)[s>>5],a=Object.values(ff)[s>>2&7],l=Object.values(df)[3&s];e.increment();const u=Ef(t,e,2),c=u[0];return {physicalStreamType:r,logicalStreamType:i,logicalLevelTechnique1:o,logicalLevelTechnique2:a,physicalLevelTechnique:l,numValues:c,byteLength:u[1],decompressedCount:c}}(t,e);return n.logicalLevelTechnique1===ff.MORTON?function(t,e,n){const r=Ef(e,n,2);return {physicalStreamType:t.physicalStreamType,logicalStreamType:t.logicalStreamType,logicalLevelTechnique1:t.logicalLevelTechnique1,logicalLevelTechnique2:t.logicalLevelTechnique2,physicalLevelTechnique:t.physicalLevelTechnique,numValues:t.numValues,byteLength:t.byteLength,decompressedCount:t.decompressedCount,numBits:r[0],coordinateShift:r[1]}}(n,t,e):ff.RLE!==n.logicalLevelTechnique1&&ff.RLE!==n.logicalLevelTechnique2||df.NONE===n.physicalLevelTechnique?n:function(t,e,n){const r=Ef(e,n,2);return {physicalStreamType:t.physicalStreamType,logicalStreamType:t.logicalStreamType,logicalLevelTechnique1:t.logicalLevelTechnique1,logicalLevelTechnique2:t.logicalLevelTechnique2,physicalLevelTechnique:t.physicalLevelTechnique,numValues:t.numValues,byteLength:t.byteLength,decompressedCount:r[1],runs:r[0],numRleValues:r[1]}}(n,t,e)}!function(t){t.PRESENT="PRESENT",t.DATA="DATA",t.OFFSET="OFFSET",t.LENGTH="LENGTH";}(Nf||(Nf={})),function(t){t.NONE="NONE",t.SINGLE="SINGLE",t.SHARED="SHARED",t.VERTEX="VERTEX",t.MORTON="MORTON",t.FSST="FSST";}(Uf||(Uf={})),function(t){t.VERTEX="VERTEX",t.INDEX="INDEX",t.STRING="STRING",t.KEY="KEY";}(jf||(jf={})),function(t){t.VAR_BINARY="VAR_BINARY",t.GEOMETRIES="GEOMETRIES",t.PARTS="PARTS",t.RINGS="RINGS",t.TRIANGLES="TRIANGLES",t.SYMBOL="SYMBOL",t.DICTIONARY="DICTIONARY";}(qf||(qf={})),function(t){t[t.FLAT=0]="FLAT",t[t.CONST=1]="CONST",t[t.SEQUENCE=2]="SEQUENCE",t[t.DICTIONARY=3]="DICTIONARY",t[t.FSST_DICTIONARY=4]="FSST_DICTIONARY";}(Gf||(Gf={}));class Wf{constructor(t,e){this.values=t,this._size=e;}get(t){const e=Math.floor(t/8);return 1==(this.values[e]>>t%8&1)}set(t,e){const n=Math.floor(t/8);this.values[n]=this.values[n]|(e?1:0)<<t%8;}getInt(t){const e=Math.floor(t/8);return this.values[e]>>t%8&1}size(){return this._size}getBuffer(){return this.values}}function Kf(t,e,n){if(!e)return t;const r=e.size(),i=new(0,t.constructor)(r);let s=0;for(let o=0;o<r;o++)i[o]=e.get(o)?t[s++]:n;return i}function Jf(t,e,n,r,i){return function(t,e,n,r){let i;switch(e.logicalLevelTechnique1){case ff.DELTA:if(e.logicalLevelTechnique2===ff.RLE){const n=e;if(!r)return function(t,e,n){const r=new Int32Array(n);let i=0,s=0;for(let n=0;n<e;n++){const o=t[n],a=Df(t[n+e]);for(let t=0;t<o;t++)s+=a,r[i++]=s;}return r}(t,n.runs,n.numRleValues);i=Of(t=Cf(t,n.runs,n.numRleValues));}else i=Of(t);break;case ff.RLE:i=function(t,e,n){if(void 0===n){n=0;for(let r=0;r<e;r++)n+=t[r];}const r=new Int32Array(n);let i=0;for(let n=0;n<e;n++){const s=t[n];let o=t[n+e];o=Df(o),r.fill(o,i,i+s),i+=s;}return r}(t,e.runs,e.numRleValues);break;case ff.MORTON:Rf(t),i=new Int32Array(t);break;case ff.COMPONENTWISE_DELTA:i=function(t){if(t.length<2)return new Int32Array(t);const e=new Int32Array(t.length);e[0]=Df(t[0]),e[1]=Df(t[1]);const n=t.length/4*4;let r=2;if(n>=4)for(;r<n-4;r+=4){const n=t[r+1],i=t[r+2],s=t[r+3];e[r]=Df(t[r])+e[r-2],e[r+1]=Df(n)+e[r-1],e[r+2]=Df(i)+e[r],e[r+3]=Df(s)+e[r+1];}for(;r!==t.length;r+=2)e[r]=Df(t[r])+e[r-2],e[r+1]=Df(t[r+1])+e[r-1];return e}(t);break;case ff.NONE:i=function(t){const e=new Int32Array(t.length);for(let n=0;n<t.length;n++)e[n]=Df(t[n]);return e}(t);break;default:throw new Error(`The specified Logical level technique is not supported: ${e.logicalLevelTechnique1}`)}return r?Kf(i,r,0):i}(ed(t,e,n),n,0,i)}function Qf(t,e,n,r,i){return function(t,e,n,r){let i;switch(e.logicalLevelTechnique1){case ff.DELTA:i=function(t){const e=new Uint32Array(t.length);e[0]=Df(t[0])>>>0;for(let n=1;n<t.length;n++)e[n]=e[n-1]+Df(t[n])>>>0;return e}(e.logicalLevelTechnique2===ff.RLE?Cf(t,e.runs,e.numRleValues):t);break;case ff.RLE:i=Cf(t,e.runs,e.numRleValues);break;case ff.MORTON:Rf(t),i=t;break;case ff.COMPONENTWISE_DELTA:i=function(t){if(t.length<2)return new Uint32Array(t);const e=new Uint32Array(t.length);e[0]=Df(t[0])>>>0,e[1]=Df(t[1])>>>0;for(let n=2;n<t.length;n+=2)e[n]=e[n-2]+Df(t[n])>>>0,e[n+1]=e[n-1]+Df(t[n+1])>>>0;return e}(t);break;case ff.NONE:i=t;break;default:throw new Error(`The specified Logical level technique is not supported: ${e.logicalLevelTechnique1}`)}return r?Kf(i,r,0):i}(ed(t,e,n),n,0,i)}function td(t,e,n){return function(t,e){if(e.logicalLevelTechnique1===ff.DELTA&&e.logicalLevelTechnique2===ff.NONE)return function(t){const e=new Int32Array(t.length+1);e[0]=0,e[1]=Df(t[0]);let n=e[1];for(let r=2;r!==e.length;++r)n+=Df(t[r-1]),e[r]=e[r-1]+n;return new Uint32Array(e)}(t);if(e.logicalLevelTechnique1===ff.RLE&&e.logicalLevelTechnique2===ff.NONE)return function(t,e,n){const r=new Uint32Array(n+1);r[0]=0;let i=1,s=r[0];for(let n=0;n<e;n++){const o=t[n],a=t[n+e];for(let t=i;t<i+o;t++)r[t]=a+s,s=r[t];i+=o;}return r}(t,e.runs,e.numRleValues);if(e.logicalLevelTechnique1===ff.NONE&&e.logicalLevelTechnique2===ff.NONE){!function(t){let e=0;for(let n=0;n<t.length;n++)t[n]+=e,e=t[n];}(t);const n=new Uint32Array(e.numValues+1);return n[0]=0,n.set(t,1),n}if(e.logicalLevelTechnique1===ff.DELTA&&e.logicalLevelTechnique2===ff.RLE){const n=function(t,e,n){const r=new Int32Array(n+1);r[0]=0;let i=1,s=r[0];for(let n=0;n<e;n++){const o=t[n];let a=t[n+e];a=Df(a);for(let t=i;t<i+o;t++)r[t]=a+s,s=r[t];i+=o;}return r}(t,e.runs,e.numRleValues);return Rf(n),new Uint32Array(n)}throw new Error("Only delta encoding is supported for transforming length to offset streams yet.")}(ed(t,e,n),n)}function ed(t,e,n){const r=n.physicalLevelTechnique;switch(r){case df.FAST_PFOR:return function(t,e,n,r){return function(t,e,n,r,i){const s=r.get();if(3&n)throw new Error(`FastPFOR: invalid encodedByteLength=${n} at offset=${s} (encodedBytes.length=${t.length}; expected a multiple of 4 bytes for an int32 big-endian word stream)`);const o=n>>>2,a=function(t,e){if(e<=t.encodedWords.length)return t.encodedWords;const n=new Uint32Array(Math.max(16,2*e));return t.encodedWords=n,n}(i,o);!function(t,e,n,r){if(e<0||n<0||e+n>t.length)throw new RangeError(`decodeBigEndianInt32sInto: out of bounds (offset=${e}, byteLength=${n}, bytes.length=${t.length})`);const i=Math.floor(n/4),s=n%4!=0,o=s?i+1:i;if(r.length<o)throw new RangeError(`decodeBigEndianInt32sInto: out.length=${r.length} < ${o}`);if(i>0){const n=t.byteOffset+e;if(3&n)for(let n=0;n<i;n++){const i=e+4*n;r[n]=t[i]<<24|t[i+1]<<16|t[i+2]<<8|t[i+3];}else {const e=new Uint32Array(t.buffer,n,i);for(let t=0;t<i;t++)r[t]=0|vf(e[t]);}}if(s){const s=e+4*i,o=n-4*i;let a=0;for(let e=0;e<o;e++)a|=t[s+e]<<24-8*e;r[i]=0|a;}}(t,s,n,a);const l=function(t,e,n){let r=0,i=0;const s=new Uint32Array(e),o=n??_f();if(t.length>0){const e=0|t[r];if(r=r+1|0,255&e)throw new Error(`FastPFOR decode: invalid alignedLength=${e} (expected multiple of 256)`);if(i+e>s.length)throw new Error(`FastPFOR decode: output buffer too small (outPos=${i}, alignedLength=${e}, out.length=${s.length})`);r=function(t,e,n,r,i,s){const o=r+xf(i,gf);let a=r,l=n;for(;a!==o;){const n=Math.min(bf,o-a);l=kf(t,e,l,a,n,s),a=a+n|0;}return l}(t,s,r,i,e,o),i=i+e|0;}return function(t,e,n,r,i,s){if(0===s)return e;let o=0,a=e;const l=e+n,u=i;let c=i;const h=i+s;let p=0,f=0;for(;a<l&&c<h;){const e=t[a]>>>o&255;if(o+=8,a+=o>>>5,o&=31,p|=(127&e)<<f,128&e)r[c++]=0|p,p=0,f=0;else if(f+=7,f>28)throw new Error(`FastPFOR VByte: unterminated value (expected MSB=1 terminator within 5 bytes; shift=${f}, partial=${p}, decoded=${c-u}/${s}, inPos=${a}, inEnd=${l})`)}if(c!==h)throw new Error(`FastPFOR VByte: truncated stream (decoded=${c-u}, expected=${s}, consumedWords=${a-e}/${n}, vbyteStart=${e}, vbyteEnd=${l})`)}(t,r,t.length-r|0,s,i,e-i|0),s}(a.subarray(0,o),e,i.decoderWorkspace);return r.add(n),l}(t,e,n,r,function(t=16){if(t<0)throw new RangeError(`initialEncodedWordCapacity must be >= 0, got ${t}`);const e=Math.max(16,0|t);return {encodedWords:new Uint32Array(e),decoderWorkspace:_f()}}(n>>>2))}(t,n.numValues,n.byteLength,e);case df.VARINT:return Ef(t,e,n.numValues);case df.NONE:{const r=e.get();e.add(n.byteLength);const i=t.subarray(r,e.get());return new Uint32Array(i)}default:throw new Error(`Specified physicalLevelTechnique ${r} is not supported (yet).`)}}function nd(t,e,n){const r=ed(t,e,n);return 1===r.length?r[0]:function(t){return t[1]}(r)}function rd(t,e,n){return function(t){if(2===t.length){const e=Df(t[1]);return [e,e]}return [Df(t[2]),Df(t[3])]}(ed(t,e,n))}function id(t,e,n){return function(t){if(2===t.length){const e=zf(t[1]);return [e,e]}return [zf(t[2]),zf(t[3])]}(Tf(t,e,n.numValues))}function sd(t,e,n,r){return function(t,e,n){let r;switch(e.logicalLevelTechnique1){case ff.DELTA:r=function(t){const e=new BigUint64Array(t.length);e[0]=BigInt.asUintN(64,zf(t[0]));for(let n=1;n<t.length;n++)e[n]=BigInt.asUintN(64,e[n-1]+zf(t[n]));return e}(e.logicalLevelTechnique2===ff.RLE?Vf(t,e.runs,e.numRleValues):t);break;case ff.RLE:r=Vf(t,e.runs,e.numRleValues);break;case ff.NONE:r=t;break;default:throw new Error(`The specified Logical level technique is not supported: ${e.logicalLevelTechnique1}`)}return n?Kf(r,n,0n):r}(Tf(t,e,n.numValues),n,r)}function od(t,e,n){const r=Tf(t,e,n.numValues);return 1===r.length?r[0]:function(t){return t[1]}(r)}function ad(t,e,n,r,i="int32"){const s=t.logicalLevelTechnique1;if(s===ff.RLE)return 1===t.runs?Gf.CONST:Gf.FLAT;if(s!==ff.DELTA||t.logicalLevelTechnique2!==ff.RLE)return 1===t.numValues?Gf.CONST:Gf.FLAT;const o=e instanceof Wf?e.size():e;if(t.numRleValues!==o)return Gf.FLAT;if(1===t.runs)return Gf.SEQUENCE;if(2!==t.runs)return 1===t.numValues?Gf.CONST:Gf.FLAT;const a=r.get();if(t.physicalLevelTechnique===df.VARINT)return function(t,e,n){const r=new pf(e.get());if("int64"===n){const e=Tf(t,r,4);return 2n===e[2]&&2n===e[3]}const i=Ef(t,r,4);return 2===i[2]&&2===i[3]}(n,r,i)?Gf.SEQUENCE:1===t.numValues?Gf.CONST:Gf.FLAT;const l=r.get(),u=new Int32Array(n.buffer,n.byteOffset+l,4);return r.set(a),2===u[2]&&2===u[3]?Gf.SEQUENCE:1===t.numValues?Gf.CONST:Gf.FLAT}class ld extends sf{getValueFromBuffer(t){return this.dataBuffer[t]}}class ud extends lf{constructor(t,e,n,r){super(t,BigInt64Array.of(e),n,r);}getValueFromBuffer(t){return this.dataBuffer[0]+BigInt(t)*this.delta}}function cd(t,e,n){return {x:hd(t,e)-n,y:hd(t>>1,e)-n}}function hd(t,e){let n=0;for(let r=0;r<e;r++)n|=(t&1<<2*r)>>r;return n}function pd(t,e,r,i,s,o,a){return t===Zf.MORTON?function(t,e,r,i,s,o){const a=new Array(s?i+1:i);for(let s=0;s<i;s++){const i=cd(t[e[r+s]],o.numBits,o.coordinateShift);a[s]=new n(i.x,i.y);}return s&&(a[a.length-1]=a[0]),a}(e,r,i,s,o,a):function(t,e,r,i,s){const o=new Array(s?i+1:i);for(let s=0;s<2*i;s+=2){const i=2*e[r+s/2];o[s/2]=new n(t[i],t[i+1]);}return s&&(o[o.length-1]=o[0]),o}(e,r,i,s,o)}function fd(t,e,r,i){const s=new Array(i?r+1:r);for(let i=0;i<2*r;i+=2)s[i/2]=new n(t[e+i],t[e+i+1]);return i&&(s[s.length-1]=s[0]),s}!function(t){t[t.POINT=0]="POINT",t[t.LINESTRING=1]="LINESTRING",t[t.POLYGON=2]="POLYGON",t[t.MULTIPOINT=3]="MULTIPOINT",t[t.MULTILINESTRING=4]="MULTILINESTRING",t[t.MULTIPOLYGON=5]="MULTIPOLYGON";}(Xf||(Xf={})),function(t){t[t.POINT=0]="POINT",t[t.LINESTRING=1]="LINESTRING",t[t.POLYGON=2]="POLYGON";}(Yf||(Yf={})),function(t){t[t.MORTON=0]="MORTON",t[t.VEC_2=1]="VEC_2",t[t.VEC_3=2]="VEC_3";}(Zf||(Zf={}));class dd{constructor(t,e,n,r,i){this._vertexBufferType=t,this._topologyVector=e,this._vertexOffsets=n,this._vertexBuffer=r,this._mortonSettings=i;}get vertexBufferType(){return this._vertexBufferType}get topologyVector(){return this._topologyVector}get vertexOffsets(){return this._vertexOffsets}get vertexBuffer(){return this._vertexBuffer}getSimpleEncodedVertex(t){const e=this.vertexOffsets?2*this.vertexOffsets[t]:2*t;return [this.vertexBuffer[e],this.vertexBuffer[e+1]]}getVertex(t){if(this.vertexOffsets&&this.mortonSettings){const e=cd(this.vertexBuffer[this.vertexOffsets[t]],this.mortonSettings.numBits,this.mortonSettings.coordinateShift);return [e.x,e.y]}const e=this.vertexOffsets?2*this.vertexOffsets[t]:2*t;return [this.vertexBuffer[e],this.vertexBuffer[e+1]]}getGeometries(){return function(t){const e=new Array(t.numGeometries);let r=1,i=1,s=1,o=0,a=0,l=0;const u=t.mortonSettings,c=t.topologyVector,h=c.geometryOffsets,p=c.partOffsets,f=c.ringOffsets,d=t.vertexOffsets,y=!d||0===d.length,m=t.containsPolygonGeometry(),g=t.vertexBuffer;for(let c=0;c<t.numGeometries;c++)switch(t.geometryType(c)){case Xf.POINT:{let c,m;if(y)c=g[a++],m=g[a++];else if(t.vertexBufferType===Zf.MORTON){const t=cd(g[d[l++]],u.numBits,u.coordinateShift);c=t.x,m=t.y;}else {const t=2*d[l++];c=g[t],m=g[t+1];}e[o++]=[[new n(c,m)]],h&&s++,p&&r++,f&&i++;}break;case Xf.MULTIPOINT:{const t=h[s]-h[s-1];s++;const u=new Array(t);if(y)for(let e=0;e<t;e++){const t=g[a++],r=g[a++];u[e]=new n(t,r);}else for(let e=0;e<t;e++){const t=2*d[l++];u[e]=new n(g[t],g[t+1]);}e[o++]=u.map((t=>[t])),r+=t,i+=t;}break;case Xf.LINESTRING:{let n,c;m?(n=f[i]-f[i-1],i++):n=p[r]-p[r-1],r++,y?(c=fd(g,a,n,!1),a+=2*n):(c=pd(t.vertexBufferType,g,d,l,n,!1,u),l+=n),e[o++]=[c],h&&s++;}break;case Xf.POLYGON:{const n=p[r]-p[r-1];r++;const c=new Array(n-1);let m,x=f[i]-f[i-1];if(i++,y){m=fd(g,a,x,!0),a+=2*x;for(let t=0;t<c.length;t++)x=f[i]-f[i-1],i++,c[t]=fd(g,a,x,!0),a+=2*x;}else {m=pd(t.vertexBufferType,g,d,l,x,!0,u),l+=x;for(let e=0;e<c.length;e++)x=f[i]-f[i-1],i++,c[e]=pd(t.vertexBufferType,g,d,l,x,!0,u),l+=x;}e[o++]=[m].concat(c),h&&s++;}break;case Xf.MULTILINESTRING:{const n=h[s]-h[s-1];s++;const c=new Array(n);for(let e=0;e<n;e++){let n;if(m?(n=f[i]-f[i-1],i++):n=p[r]-p[r-1],r++,y)c[e]=fd(g,a,n,!1),a+=2*n;else {const r=pd(t.vertexBufferType,g,d,l,n,!1,u);c[e]=r,l+=n;}}e[o++]=c;}break;case Xf.MULTIPOLYGON:{const n=h[s]-h[s-1];s++;const c=new Array(n);for(let e=0;e<n;e++){const n=p[r]-p[r-1];let s;r++;const o=new Array(n-1),h=f[i]-f[i-1];i++,y?(s=fd(g,a,h,!0),a+=2*h):(s=pd(t.vertexBufferType,g,d,l,h,!0,u),l+=h);for(let e=0;e<o.length;e++){const n=f[i]-f[i-1];i++,y?(o[e]=fd(g,a,n,!0),a+=2*n):(o[e]=pd(t.vertexBufferType,g,d,l,n,!0,u),l+=n);}c[e]=[s].concat(o);}e[o++]=c.flat();}break;default:throw new Error("The specified geometry type is currently not supported.")}return e}(this)}get mortonSettings(){return this._mortonSettings}}class yd extends dd{constructor(t,e,n,r,i,s,o){super(n,r,i,s,o),this._numGeometries=t,this._geometryType=e;}geometryType(t){return this._geometryType}get numGeometries(){return this._numGeometries}containsPolygonGeometry(){return this._geometryType===Xf.POLYGON||this._geometryType===Xf.MULTIPOLYGON}containsSingleGeometryType(){return !0}}class md extends dd{constructor(t,e,n,r,i,s){super(t,n,r,i,s),this._geometryTypes=e;}geometryType(t){return this._geometryTypes[t]}get numGeometries(){return this._geometryTypes.length}containsPolygonGeometry(){for(let t=0;t<this.numGeometries;t++)if(this.geometryType(t)===Xf.POLYGON||this.geometryType(t)===Xf.MULTIPOLYGON)return !0;return !1}containsSingleGeometryType(){return !1}}class gd{constructor(t,e,n,r){this._triangleOffsets=t,this._indexBuffer=e,this._vertexBuffer=n,this._topologyVector=r;}get triangleOffsets(){return this._triangleOffsets}get indexBuffer(){return this._indexBuffer}get vertexBuffer(){return this._vertexBuffer}get topologyVector(){return this._topologyVector}getGeometries(){if(!this._topologyVector)throw new Error("Cannot convert GpuVector to coordinates without topology information");const t=new Array(this.numGeometries),e=this._topologyVector,r=e.partOffsets,i=e.ringOffsets,s=e.geometryOffsets;let o=0,a=1,l=1,u=1;for(let e=0;e<this.numGeometries;e++)switch(this.geometryType(e)){case Xf.POLYGON:{const c=r[a]-r[a-1];a++;const h=[];for(let t=0;t<c;t++){const t=i[l]-i[l-1];l++;const e=[];for(let r=0;r<t;r++){const t=this._vertexBuffer[o++],r=this._vertexBuffer[o++];e.push(new n(t,r));}e.length>0&&e.push(e[0]),h.push(e);}t[e]=h,s&&u++;}break;case Xf.MULTIPOLYGON:{const c=s[u]-s[u-1];u++;const h=[];for(let t=0;t<c;t++){const t=r[a]-r[a-1];a++;for(let e=0;e<t;e++){const t=i[l]-i[l-1];l++;const e=[];for(let r=0;r<t;r++){const t=this._vertexBuffer[o++],r=this._vertexBuffer[o++];e.push(new n(t,r));}e.length>0&&e.push(e[0]),h.push(e);}}t[e]=h;}}return t}[Symbol.iterator](){return null}}function xd(t,e,n,r,i,s){return new vd(t,e,n,r,i,s)}class vd extends gd{constructor(t,e,n,r,i,s){super(n,r,i,s),this._numGeometries=t,this._geometryType=e;}geometryType(t){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return !0}}function bd(t,e,n,r,i){return new wd(t,e,n,r,i)}class wd extends gd{constructor(t,e,n,r,i){super(e,n,r,i),this._geometryTypes=t;}geometryType(t){return this._geometryTypes[t]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return !1}}function _d(t,e,n,r,i){const s=Hf(t,n);let o,a,l,u;if(ad(s,r,t,n)===Gf.CONST){const i=nd(t,n,s);let c,h,p,f;for(let r=0;r<e-1;r++){const e=Hf(t,n);switch(e.physicalStreamType){case Nf.LENGTH:switch(e.logicalStreamType.lengthType){case qf.GEOMETRIES:c=td(t,n,e);break;case qf.PARTS:h=td(t,n,e);break;case qf.RINGS:p=td(t,n,e);break;case qf.TRIANGLES:f=td(t,n,e);}break;case Nf.OFFSET:switch(e.logicalStreamType.offsetType){case jf.VERTEX:o=Qf(t,n,e);break;case jf.INDEX:u=Qf(t,n,e);}break;case Nf.DATA:Uf.VERTEX===e.logicalStreamType.dictionaryType?a=Jf(t,n,e):(l={numBits:e.numBits,coordinateShift:e.coordinateShift},a=Qf(t,n,e));}}return u?void 0!==c||void 0!==h?xd(r,i,f,u,a,{geometryOffsets:c,partOffsets:h,ringOffsets:p}):xd(r,i,f,u,a):void 0===l?function(t,e,n,r,i){return new yd(t,e,Zf.VEC_2,n,r,i)}(r,i,{geometryOffsets:c,partOffsets:h,ringOffsets:p},o,a):function(t,e,n,r,i,s){return new yd(t,e,Zf.MORTON,n,r,i,s)}(r,i,{geometryOffsets:c,partOffsets:h,ringOffsets:p},o,a,l)}const c=Qf(t,n,s);let h,p,f,d,y,m,g;for(let r=0;r<e-1;r++){const e=Hf(t,n);switch(e.physicalStreamType){case Nf.LENGTH:switch(e.logicalStreamType.lengthType){case qf.GEOMETRIES:h=Qf(t,n,e);break;case qf.PARTS:p=Qf(t,n,e);break;case qf.RINGS:f=Qf(t,n,e);break;case qf.TRIANGLES:d=td(t,n,e);}break;case Nf.OFFSET:switch(e.logicalStreamType.offsetType){case jf.VERTEX:o=Qf(t,n,e);break;case jf.INDEX:u=Qf(t,n,e);}break;case Nf.DATA:Uf.VERTEX===e.logicalStreamType.dictionaryType?a=Jf(t,n,e):(l={numBits:e.numBits,coordinateShift:e.coordinateShift},a=Qf(t,n,e));}}return h?(y=Sd(c,h,2),p&&f?(m=Ad(c,y,p,!1),g=function(t,e,n,r){const i=new Uint32Array(n[n.length-1]+1);let s=0;i[0]=s;let o=1,a=1,l=0;for(let u=0;u<t.length;u++){const c=t[u],h=e[u+1]-e[u];if(0!==c&&3!==c)for(let t=0;t<h;t++){const t=n[o]-n[o-1];o++;for(let e=0;e<t;e++)s=i[a++]=s+r[l++];}else for(let t=0;t<h;t++)i[a++]=++s,o++;}return i}(c,y,m,f)):p&&(m=function(t,e,n){const r=new Uint32Array(e[e.length-1]+1);let i=0;r[0]=i;let s=1,o=0;for(let a=0;a<t.length;a++){const l=t[a],u=e[a+1]-e[a];if(4===l||1===l)for(let t=0;t<u;t++)i=r[s++]=i+n[o++];else for(let t=0;t<u;t++)r[s++]=++i;}return r}(c,y,p))):p&&f?(m=Sd(c,p,1),g=Ad(c,m,f,!0)):p&&(m=Sd(c,p,0)),u&&!m?bd(c,d,u,a):u?bd(c,d,u,a,{geometryOffsets:y,partOffsets:m,ringOffsets:g}):void 0===l?function(t,e,n,r){return new md(Zf.VEC_2,t,e,n,r)}(c,{geometryOffsets:y,partOffsets:m,ringOffsets:g},o,a):function(t,e,n,r,i){return new md(Zf.MORTON,t,e,n,r,i)}(c,{geometryOffsets:y,partOffsets:m,ringOffsets:g},o,a,l)}function Sd(t,e,n){const r=new Uint32Array(t.length+1);let i=0;r[0]=i;let s=0;for(let o=0;o<t.length;o++)i=r[o+1]=i+(t[o]>n?e[s++]:1);return r}function Ad(t,e,n,r){const i=new Uint32Array(e[e.length-1]+1);let s=0;i[0]=s;let o=1,a=0;for(let l=0;l<t.length;l++){const u=t[l],c=e[l+1]-e[l];if(5===u||2===u||r&&(4===u||1===u))for(let t=0;t<c;t++)s=i[o++]=s+n[a++];else for(let t=0;t<c;t++)i[o++]=++s;}return i}class Md extends rf{constructor(t,e,n){super(t,e.getBuffer(),n),this.dataVector=e;}getValueFromBuffer(t){return this.dataVector.get(t)}}class kd extends sf{getValueFromBuffer(t){return this.dataBuffer[t]}}class Id extends rf{constructor(t,e,n,r){super(t,r?BigInt64Array.of(e):BigUint64Array.of(e),n);}getValueFromBuffer(t){return this.dataBuffer[0]}}function Ed(t,e,n,r,i){const s=function(t,e,n,r){const i=new Uint8Array(e);let s=0;const o=r.get()+n;for(;s<e&&!(r.get()>=o);){const n=t[r.increment()];if(n<=127){const o=n+3,a=t[r.increment()],l=Math.min(s+o,e);i.fill(a,s,l),s=l;}else {const o=256-n;for(let n=0;n<o&&s<e;n++)i[s++]=t[r.increment()];}}return r.set(o),i}(t,Math.ceil(e/8),n,r);return i?function(t,e,n){if(!n)return t;const r=n.size(),i=new Wf(t,e),s=new Wf(new Uint8Array(Math.ceil(r/8)),r);let o=0;for(let t=0;t<r;t++){const e=!!n.get(t)&&i.get(o++);s.set(t,e);}return s.getBuffer()}(s,e,i):s}const Td=new TextDecoder;function Fd(t,e,n){return n-e>=12?Td.decode(t.subarray(e,n)):function(t,e,n){let r="",i=e;for(;i<n;){const e=t[i];let s,o,a,l=null,u=e>239?4:e>223?3:e>191?2:1;if(i+u>n)break;1===u?e<128&&(l=e):2===u?(s=t[i+1],128==(192&s)&&(l=(31&e)<<6|63&s,l<=127&&(l=null))):3===u?(s=t[i+1],o=t[i+2],128==(192&s)&&128==(192&o)&&(l=(15&e)<<12|(63&s)<<6|63&o,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===u&&(s=t[i+1],o=t[i+2],a=t[i+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(l=(15&e)<<18|(63&s)<<12|(63&o)<<6|63&a,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,u=1):l>65535&&(l-=65536,r+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),r+=String.fromCharCode(l),i+=u;}return r}(t,e,n)}class Pd extends rf{constructor(t,e,n,r){super(t,n,r),this.offsetBuffer=e;}}class Dd extends Pd{constructor(t,e,n,r){super(t,e,n,r??e.length-1);}getValueFromBuffer(t){return Fd(this.dataBuffer,this.offsetBuffer[t],this.offsetBuffer[t+1])}}class zd extends Pd{constructor(t,e,n,r,i){super(t,n,r,i??e.length),this.indexBuffer=e,this.indexBuffer=e;}getValueFromBuffer(t){const e=this.indexBuffer[t];return Fd(this.dataBuffer,this.offsetBuffer[e],this.offsetBuffer[e+1])}}class Bd extends Pd{constructor(t,e,n,r,i,s,o){super(t,n,r,o),this.indexBuffer=e,this.symbolOffsetBuffer=i,this.symbolTableBuffer=s;}getValueFromBuffer(t){null==this.decodedDictionary&&(null==this.symbolLengthBuffer&&(this.symbolLengthBuffer=this.offsetToLengthBuffer(this.symbolOffsetBuffer)),this.decodedDictionary=function(t,e,n){const r=[],i=new Array(e.length).fill(0);for(let t=1;t<e.length;t++)i[t]=i[t-1]+e[t-1];for(let s=0;s<n.length;s++)if(255===n[s])r.push(n[++s]);else {const o=e[n[s]],a=i[n[s]];for(let e=0;e<o;e++)r.push(t[a+e]);}return new Uint8Array(r)}(this.symbolTableBuffer,this.symbolLengthBuffer,this.dataBuffer));const e=this.indexBuffer[t];return Fd(this.decodedDictionary,this.offsetBuffer[e],this.offsetBuffer[e+1])}offsetToLengthBuffer(t){const e=new Uint32Array(t.length-1);let n=t[0];for(let r=1;r<t.length;r++){const i=t[r];e[r-1]=i-n,n=i;}return e}}function Cd(t,e,n,r,i,s){return "scalarType"===n.type?function(t,e,n,r,i,s){let o=null;if(0===t)return null;if(s.nullable){const t=Hf(e,n),r=t.numValues,i=n.get(),s=Ed(e,r,t.byteLength,n);n.set(i+t.byteLength),o=new Wf(s,t.numValues);}const a=o??r;switch(i.physicalType){case 4:case 3:return function(t,e,n,r,i){const s=Hf(t,e),o=ad(s,i,t,e),a=3===r.physicalType;if(o===Gf.FLAT){const r=Vd(i)?i:void 0,o=a?Jf(t,e,s,0,r):Qf(t,e,s,0,r);return new of(n.name,o,i)}if(o===Gf.SEQUENCE){const r=rd(t,e,s);return new uf(n.name,r[0],r[1],s.numRleValues)}const l=a?function(t,e,n){const r=ed(t,e,n);return 1===r.length?Df(r[0]):function(t){return Df(t[1])}(r)}(t,e,s):nd(t,e,s);return new cf(n.name,l,i,a)}(e,n,s,i,a);case 9:return function(t,e,n,r,i){let s=null,o=null,a=null,l=null,u=null,c=i??null,h=null,p=null;for(let t=0;t<r;t++){const t=Hf(e,n);switch(t.physicalStreamType){case Nf.PRESENT:{const r=Ed(e,t.numValues,t.byteLength,n),s=new Wf(r,t.numValues);c=i??s;break}case Nf.OFFSET:o=Qf(e,n,t,0,c);break;case Nf.LENGTH:{const r=td(e,n,t);qf.DICTIONARY===t.logicalStreamType.lengthType?s=r:qf.SYMBOL===t.logicalStreamType.lengthType?l=r:h=r;break}case Nf.DATA:{const r=e.subarray(n.get(),n.get()+t.byteLength);n.add(t.byteLength);const i=t.logicalStreamType.dictionaryType;Uf.FSST===i?u=r:Uf.SINGLE===i||Uf.SHARED===i?a=r:Uf.NONE===i&&(p=r);break}}}return function(t,e,n,r,i,s,o){return e?new Bd(t,n,r,i,s,e,o):null}(t,u,o,s,a,l,c)??function(t,e,n,r,i){return e?i?new zd(t,n,r,e,i):new zd(t,n,r,e):null}(t,a,o,s,c)??function(t,e,n,r,i){if(!e||!n)return null;if(r)return i?new zd(t,r,e,n,i):new zd(t,r,e,n);if(i&&i.size()!==e.length-1){const r=new Uint32Array(i.size());let s=0;for(let t=0;t<i.size();t++)r[t]=i.get(t)?s++:0;return new zd(t,r,e,n,i)}return i?new Dd(t,e,n,i):new Dd(t,e,n)}(t,h,p,o,c)}(s.name,e,n,s.nullable?t-1:t,o);case 0:return function(t,e,n,r,i){const s=Hf(t,e),o=s.numValues,a=e.get(),l=Vd(i)?i:void 0,u=Ed(t,o,s.byteLength,e,l);e.set(a+s.byteLength);const c=new Wf(u,o);return new Md(n.name,c,i)}(e,n,s,0,a);case 6:case 5:return function(t,e,n,r,i){const s=Hf(t,e),o=ad(s,r,t,e,"int64"),a=5===i.physicalType;if(o===Gf.FLAT){const i=Vd(r)?r:void 0,o=a?function(t,e,n,r){return function(t,e,n){let r;switch(e.logicalLevelTechnique1){case ff.DELTA:if(e.logicalLevelTechnique2===ff.RLE){const i=e;if(!n)return function(t,e,n){const r=new BigInt64Array(n);let i=0,s=0n;for(let n=0;n<e;n++){const o=Number(t[n]),a=zf(t[n+e]);for(let t=0;t<o;t++)s+=a,r[i++]=s;}return r}(t,i.runs,i.numRleValues);r=$f(t=Vf(t,i.runs,i.numRleValues));}else r=$f(t);break;case ff.RLE:r=function(t,e,n){if(void 0===n){n=0;for(let r=0;r<e;r++)n+=Number(t[r]);}const r=new BigInt64Array(n);let i=0;for(let n=0;n<e;n++){const s=Number(t[n]);let o=t[n+e];o=zf(o),r.fill(o,i,i+s),i+=s;}return r}(t,e.runs,e.numRleValues);break;case ff.NONE:r=function(t){const e=new BigInt64Array(t.length);for(let n=0;n<t.length;n++)e[n]=zf(t[n]);return e}(t);break;default:throw new Error(`The specified Logical level technique is not supported: ${e.logicalLevelTechnique1}`)}return n?Kf(r,n,0n):r}(Tf(t,e,n.numValues),n,r)}(t,e,s,i):sd(t,e,s,i);return new ld(n.name,o,r)}if(o===Gf.SEQUENCE){const r=id(t,e,s);return new ud(n.name,r[0],r[1],s.numRleValues)}const l=a?function(t,e,n){const r=Tf(t,e,n.numValues);return 1===r.length?zf(r[0]):function(t){return zf(t[1])}(r)}(t,e,s):od(t,e,s);return new Id(n.name,l,r,a)}(e,n,s,a,i);case 7:return function(t,e,n,r){const i=Hf(t,e),s=Vd(r)?r:void 0,o=function(t,e,n,r){const i=e.get(),s=i+n*Float32Array.BYTES_PER_ELEMENT,o=new Uint8Array(t.subarray(i,s)).buffer,a=new Float32Array(o);return e.set(s),r?Kf(a,r,0):a}(t,e,i.numValues,s);return new kd(n.name,o,r)}(e,n,s,a);case 8:return function(t,e,n,r){const i=Hf(t,e),s=Vd(r)?r:void 0,o=function(t,e,n,r){const i=e.get(),s=i+n*Float64Array.BYTES_PER_ELEMENT,o=new Uint8Array(t.subarray(i,s)).buffer,a=new Float64Array(o);return e.set(s),r?Kf(a,r,0):a}(t,e,i.numValues,s);return new af(n.name,o,r)}(e,n,s,a);default:throw new Error(`The specified data type for the field is currently not supported: ${i}`)}}(r,t,e,i,n.scalarType,n):0===r?null:function(t,e,n,r){let i=null,s=null,o=null,a=null,l=!1;for(;!l;){const n=Hf(t,e);switch(n.physicalStreamType){case Nf.LENGTH:qf.DICTIONARY===n.logicalStreamType.lengthType?i=td(t,e,n):o=td(t,e,n);break;case Nf.DATA:Uf.SINGLE===n.logicalStreamType.dictionaryType||Uf.SHARED===n.logicalStreamType.dictionaryType?(s=t.subarray(e.get(),e.get()+n.byteLength),l=!0):a=t.subarray(e.get(),e.get()+n.byteLength),e.add(n.byteLength);}}const u=n.complexType.children,c=[];let h=0;for(const l of u){const u=Ef(t,e,1)[0];if(0===u)continue;const p=l.name?`${n.name}${l.name}`:n.name;if(2!==u||"scalarField"!==l.type||9!==l.scalarField.physicalType)throw new Error("Currently only optional string fields are implemented for a struct.");const f=Hf(t,e),d=Ed(t,f.numValues,f.byteLength,e),y=Hf(t,e),m=Qf(t,e,y,0,y.decompressedCount!==r?new Wf(d,f.numValues):void 0);c[h++]=a?new Bd(p,m,i,s,o,a,new Wf(d,f.numValues)):new zd(p,m,i,s,new Wf(d,f.numValues));}return c}(t,e,n,i)}function Vd(t){return t instanceof Wf}function Ld(t){switch(t){case 0:case 1:case 2:case 3:{const e={};e.nullable=!!(1&t),e.columnScope=0;const n={type:"logicalType",logicalType:0};return n.longID=!!(2&t),e.scalarType=n,e.type="scalarType",e}case 4:{const t={nullable:!1,columnScope:0},e={type:"physicalType",physicalType:0};return t.type="complexType",t.complexType=e,t}case 30:{const t={nullable:!1,columnScope:0},e={type:"physicalType",physicalType:1};return t.type="complexType",t.complexType=e,t}default:return function(t){let e;switch(t){case 10:case 11:e=0;break;case 12:case 13:e=1;break;case 14:case 15:e=2;break;case 16:case 17:e=3;break;case 18:case 19:e=4;break;case 20:case 21:e=5;break;case 22:case 23:e=6;break;case 24:case 25:e=7;break;case 26:case 27:e=8;break;case 28:case 29:e=9;break;default:return null}const n={};n.nullable=!!(1&t),n.columnScope=0;const r={type:"physicalType"};return r.physicalType=e,n.type="scalarType",n.scalarType=r,n}(t)}}function Od(t){return t>=10}function $d(t){return 30===t}function Rd(t){if("scalarType"===t.type){const e=t.scalarType;if("physicalType"===e.type)switch(e.physicalType){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:default:return !1;case 9:return !0}if("logicalType"===e.type)return !1}else if("complexType"===t.type){const e=t.complexType;if("physicalType"===e.type)switch(e.physicalType){case 0:case 1:return !0;default:return !1}}return console.warn("Unexpected column type in hasStreamCount",t),!1}function Nd(t){return "complexType"===t.type&&"physicalType"===t.complexType?.type&&0===t.complexType.physicalType}const Ud=new TextDecoder;function jd(t,e){const n=Ef(t,e,1)[0];if(0===n)return "";const r=e.get(),i=t.subarray(r,r+n);return e.add(n),Ud.decode(i)}function qd(t,e){const n=Ef(t,e,1)[0]>>>0;if(n<10||n>30)throw new Error(`Unsupported field type code ${n}. Supported: 10-29(scalars), 30(STRUCT)`);const r=Ld(n);if(Od(n)&&(r.name=jd(t,e)),$d(n)){const n=Ef(t,e,1)[0]>>>0;r.complexType.children=new Array(n);for(let i=0;i<n;i++)r.complexType.children[i]=qd(t,e);}return function(t){return {name:t.name,nullable:t.nullable,scalarField:t.scalarType,complexField:t.complexType,type:"scalarType"===t.type?"scalarField":"complexField"}}(r)}function Gd(t,e){const n=Ef(t,e,1)[0]>>>0,r=Ld(n);if(!r)throw new Error(`Unsupported column type code ${n}. Supported: 0-3(ID), 4(GEOMETRY), 10-29(scalars), 30(STRUCT)`);if(Od(n)?r.name=jd(t,e):n>=0&&n<=3?r.name="id":4===n&&(r.name="geometry"),$d(n)){const n=Ef(t,e,1)[0]>>>0,i=r.complexType;i.children=new Array(n);for(let r=0;r<n;r++)i.children[r]=qd(t,e);}return r}function Xd(t,e){const n={featureTables:[]},r={};r.name=jd(t,e);const i=Ef(t,e,1)[0]>>>0,s=Ef(t,e,1)[0]>>>0;r.columns=new Array(s);for(let n=0;n<s;n++)r.columns[n]=Gd(t,e);return n.featureTables.push(r),[n,i]}function Yd(t,e,n,r,i,s,o=!1){const a=e.scalarType;if(!a||"logicalType"!==a.type||0!==a.logicalType)throw new Error(`ID column must be a logical ID scalar type: ${r}`);const l=a.longID?6:4,u="number"==typeof s?void 0:s,c=ad(i,s,t,n,6===l?"int64":"int32");if(4===l)switch(c){case Gf.FLAT:{const e=Qf(t,n,i,0,u);return new of(r,e,s)}case Gf.SEQUENCE:{const e=rd(t,n,i);return new uf(r,e[0],e[1],i.numRleValues)}case Gf.CONST:{const e=nd(t,n,i);return new cf(r,e,s,!1)}}switch(c){case Gf.FLAT:{if(o){const e=function(t,e,n){const r=function(t,e,n){const r=new Float64Array(n);for(let i=0;i<n;i++)r[i]=Pf(t,e);return r}(t,e,n.numValues);return function(t,e){switch(e.logicalLevelTechnique1){case ff.DELTA:return e.logicalLevelTechnique2===ff.RLE&&(t=Lf(t,e.runs,e.numRleValues)),function(t){t[0]=Bf(t[0]);const e=t.length/4*4;let n=1;if(e>=4)for(;n<e-4;n+=4){const e=t[n+1],r=t[n+2],i=t[n+3];t[n]=Bf(t[n])+t[n-1],t[n+1]=Bf(e)+t[n],t[n+2]=Bf(r)+t[n+1],t[n+3]=Bf(i)+t[n+2];}for(;n!==t.length;++n)t[n]=Bf(t[n])+t[n-1];}(t),t;case ff.RLE:return function(t,e){return Lf(t,e.runs,e.numRleValues)}(t,e);case ff.NONE:return t;default:throw new Error(`The specified Logical level technique is not supported: ${e.logicalLevelTechnique1}`)}}(r,n)}(t,n,i);return new af(r,e,s)}const e=sd(t,n,i,u);return new ld(r,e,s)}case Gf.SEQUENCE:{const e=id(t,n,i);return new ud(r,e[0],e[1],i.numRleValues)}case Gf.CONST:{const e=od(t,n,i);return new Id(r,e,s,!1)}}throw new Error("Vector type not supported for id column.")}class Zd{constructor(t,e){var n;switch(this._featureData=t,this.properties=this._featureData.properties||{},null===(n=this._featureData.geometry)||void 0===n?void 0:n.type){case Xf.POINT:case Xf.MULTIPOINT:this.type=1;break;case Xf.LINESTRING:case Xf.MULTILINESTRING:this.type=2;break;case Xf.POLYGON:case Xf.MULTIPOLYGON:this.type=3;break;default:this.type=0;}this.extent=e,this.id=Number(this._featureData.id);}loadGeometry(){const t=[];for(const e of this._featureData.geometry.coordinates){const r=[];for(const t of e)r.push(new n(t.x,t.y));t.push(r);}return t}}class Hd{constructor(t){this.features=[],this.featureTable=t,this.name=t.name,this.extent=t.extent,this.version=2,this.features=t.getFeatures(),this.length=this.features.length;}feature(t){return new Zd(this.features[t],this.extent)}}class Wd{constructor(t){this.layers={};const e=function(t,e,n=!0){const r=new pf(0),i=[];for(;r.get()<t.length;){const e=Ef(t,r,1)[0]>>>0,o=r.get()+e;if(o>t.length)throw new Error(`Block overruns tile: ${o} > ${t.length}`);if(1!=Ef(t,r,1)[0]>>>0){r.set(o);continue}const[a,l]=Xd(t,r),u=a.featureTables[0];let c=null,h=null;const p=[];let f=0;for(const e of u.columns){const i=e.name;if("scalarType"===(s=e).type&&"logicalType"===s.scalarType?.type&&0===s.scalarType.logicalType){let s=null;if(e.nullable){const e=Hf(t,r),n=r.get(),i=Ed(t,e.numValues,e.byteLength,r);r.set(n+e.byteLength),s=new Wf(i,e.numValues);}const o=Hf(t,r);f=s?s.size():o.decompressedCount,c=Yd(t,e,r,i,o,s??f,n);}else if(Nd(e)){const e=Ef(t,r,1)[0];if(0===f){const e=r.get();f=Hf(t,r).decompressedCount,r.set(e);}h=_d(t,e,r,f);}else {const n=Rd(e)?Ef(t,r,1)[0]:1;if(0===n)continue;const i=Cd(t,r,e,n,f);if(i)if(Array.isArray(i))for(const t of i)p.push(t);else p.push(i);}}const d=new hf(u.name,h,c,p,l);i.push(d),r.set(o);}var s;return i}(new Uint8Array(t));this.layers=e.reduce(((t,e)=>Object.assign(Object.assign({},t),{[e.name]:new Hd(e)})),{});}}class Kd{constructor(t,e){this.feature=t,this.type=t.type,this.properties=t.tags?t.tags:{},this.extent=e,"id"in t&&("string"==typeof t.id?this.id=parseInt(t.id,10):"number"!=typeof t.id||isNaN(t.id)||(this.id=t.id));}loadGeometry(){const t=[],e=1===this.feature.type?[this.feature.geometry]:this.feature.geometry;for(const r of e){const e=[];for(const t of r)e.push(new n(t[0],t[1]));t.push(e);}return t}}const Jd="_geojsonTileLayer";function Qd(t,e,n=""){e.writeVarintField(15,t.version||1),e.writeStringField(1,t.name||""),e.writeVarintField(5,t.extent||4096);const r={jsonPrefix:n,keys:[],values:[],keycache:{},valuecache:{}};for(let n=0;n<t.length;n++)r.feature=t.feature(n),e.writeMessage(2,ty,r);const i=r.keys;for(const t of i)e.writeStringField(3,t);const s=r.values;for(const t of s)e.writeMessage(4,sy,t);}function ty(t,e){if(!t.feature)return;const n=t.feature;void 0!==n.id&&e.writeVarintField(1,n.id),e.writeMessage(2,ey,t),e.writeVarintField(3,n.type),e.writeMessage(4,iy,n);}function ey(t,e){for(const n in t.feature?.properties){let r=t.feature.properties[n],i=t.keycache[n];if(null==r)continue;void 0===i&&(t.keys.push(n),i=t.keys.length-1,t.keycache[n]=i),e.writeVarint(i),"string"!=typeof r&&"boolean"!=typeof r&&"number"!=typeof r&&(r=t.jsonPrefix+JSON.stringify(r));const s=typeof r+":"+r;let o=t.valuecache[s];void 0===o&&(t.values.push(r),o=t.values.length-1,t.valuecache[s]=o),e.writeVarint(o);}}function ny(t,e){return (e<<3)+(7&t)}function ry(t){return t<<1^t>>31}function iy(t,e){const n=t.loadGeometry(),r=t.type;let i=0,s=0;for(const o of n){let n=1;1===r&&(n=o.length),e.writeVarint(ny(1,n));const a=3===r?o.length-1:o.length;for(let t=0;t<a;t++){1===t&&1!==r&&e.writeVarint(ny(2,a-1));const n=o[t].x-i,l=o[t].y-s;e.writeVarint(ry(n)),e.writeVarint(ry(l)),i+=n,s+=l;}3===t.type&&e.writeVarint(ny(7,1));}}function sy(t,e){const n=typeof t;"string"===n?e.writeStringField(1,t):"boolean"===n?e.writeBooleanField(7,t):"number"===n&&(t%1!=0?e.writeDoubleField(3,t):t<0?e.writeSVarintField(6,t):e.writeVarintField(5,t));}class oy{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new ps(T,16,0),this.grid3D=new ps(T,16,0),this.featureIndexArray=new Go,this.promoteId=e;}insert(t,e,n,r,i,s){const o=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(n,r,i);const a=s?this.grid3D:this.grid;for(const t of e){const e=[1/0,1/0,-1/0,-1/0];for(const n of t)e[0]=Math.min(e[0],n.x),e[1]=Math.min(e[1],n.y),e[2]=Math.max(e[2],n.x),e[3]=Math.max(e[3],n.y);e[0]<T&&e[1]<T&&e[2]>=0&&e[3]>=0&&a.insert(o,e[0],e[1],e[2],e[3]);}}loadVTLayers(){return this.vtLayers||(this.vtLayers="mlt"!==this.encoding?new Nu(new Rh(this.rawTileData)).layers:new Wd(this.rawTileData).layers,this.sourceLayerCoder=new ef(this.vtLayers?Object.keys(this.vtLayers).sort():[Jd])),this.vtLayers}query(t,e,r,i){this.loadVTLayers();const s=t.params,o=T/t.tileSize/t.scale,a=yi(s.filter,s.globalState),l=t.queryGeometry,u=t.queryPadding*o,c=tf.fromPoints(l),h=this.grid.query(c.minX-u,c.minY-u,c.maxX+u,c.maxY+u),p=tf.fromPoints(t.cameraQueryGeometry).expandBy(u),f=this.grid3D.query(p.minX,p.minY,p.maxX,p.maxY,((e,r,i,s)=>function(t,e,r,i,s){for(const n of t)if(e<=n.x&&r<=n.y&&i>=n.x&&s>=n.y)return !0;const o=[new n(e,r),new n(e,s),new n(i,s),new n(i,r)];if(t.length>2)for(const e of o)if(il(t,e))return !0;for(let e=0;e<t.length-1;e++)if(sl(t[e],t[e+1],o))return !0;return !1}(t.cameraQueryGeometry,e-u,r-u,i+u,s+u)));for(const t of f)h.push(t);h.sort(ly);const d={};let y;for(const n of h){if(n===y)continue;y=n;const u=this.featureIndexArray.get(n);let c=null;this.loadMatchingFeature(d,u.bucketIndex,u.sourceLayerIndex,u.featureIndex,a,s.layers,s.availableImages,e,r,i,((e,n,r)=>(c||(c=qa(e)),n.queryIntersectsFeature({queryGeometry:l,feature:e,featureState:r,geometry:c,zoom:this.z,transform:t.transform,pixelsToTileUnits:o,pixelPosMatrix:t.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:t.getElevation}))));}return d}loadMatchingFeature(t,e,n,r,i,s,o,a,l,u,c){const h=this.bucketLayerIDs[e];if(s&&!h.some((t=>s.has(t))))return;const p=this.sourceLayerCoder.decode(n),f=this.vtLayers[p].feature(r);if(i.needGeometry){const t=Ga(f,!0);if(!i.filter(new Cs(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new Cs(this.tileID.overscaledZ),f))return;const d=this.getId(f,p);for(const e of h){if(s&&!s.has(e))continue;const n=a[e];if(!n)continue;let i={};d&&u&&(i=u.getState(n.sourceLayer||Jd,d));const h=$({},l[e]);h.paint=ay(h.paint,n.paint,f,i,o),h.layout=ay(h.layout,n.layout,f,i,o);const p=!c||c(f,n,i);if(!p)continue;const y=new nf(f,this.z,this.x,this.y,d);y.layer=h;let m=t[e];void 0===m&&(m=t[e]=[]),m.push({featureIndex:r,feature:y,intersectionZ:p});}}lookupSymbolFeatures(t,e,n,r,i,s,o,a){const l={};this.loadVTLayers();const u=yi(i.filterSpec,i.globalState);for(const i of t)this.loadMatchingFeature(l,n,r,i,u,s,o,a,e);return l}hasLayer(t){for(const e of this.bucketLayerIDs)for(const n of e)if(t===n)return !0;return !1}getId(t,e){var n;let r=t.id;return this.promoteId&&(r=t.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[e]],"boolean"==typeof r&&(r=Number(r)),void 0===r&&(null===(n=t.properties)||void 0===n?void 0:n.cluster)&&this.promoteId&&(r=Number(t.properties.cluster_id))),r}}function ay(t,e,n,r,i){return N(t,((t,s)=>{const o=e instanceof Gs?e.get(s):null;return (null==o?void 0:o.evaluate)?o.evaluate(n,r,i):o}))}function ly(t,e){return e-t}function uy(t,e,r,i,s){const o=[];for(const a of t){let t;for(let l=0;l<a.length-1;l++){let u=a[l],c=a[l+1];u.x<e&&c.x<e||(u.x<e?u=new n(e,u.y+(e-u.x)/(c.x-u.x)*(c.y-u.y))._round():c.x<e&&(c=new n(e,u.y+(e-u.x)/(c.x-u.x)*(c.y-u.y))._round()),u.y<r&&c.y<r||(u.y<r?u=new n(u.x+(r-u.y)/(c.y-u.y)*(c.x-u.x),r)._round():c.y<r&&(c=new n(u.x+(r-u.y)/(c.y-u.y)*(c.x-u.x),r)._round()),u.x>=i&&c.x>=i||(u.x>=i?u=new n(i,u.y+(i-u.x)/(c.x-u.x)*(c.y-u.y))._round():c.x>=i&&(c=new n(i,u.y+(i-u.x)/(c.x-u.x)*(c.y-u.y))._round()),u.y>=s&&c.y>=s||(u.y>=s?u=new n(u.x+(s-u.y)/(c.y-u.y)*(c.x-u.x),s)._round():c.y>=s&&(c=new n(u.x+(s-u.y)/(c.y-u.y)*(c.x-u.x),s)._round()),t&&u.equals(t[t.length-1])||(t=[u],o.push(t)),t.push(c)))));}}return o}function cy(t,e,n,r,i){switch(e){case 1:return function(t,e,n,r){const i=[];for(const s of t)for(const t of s){const s=0===r?t.x:t.y;s>=e&&s<=n&&i.push([t]);}return i}(t,n,r,i);case 2:return py(t,n,r,i,!1);case 3:return py(t,n,r,i,!0)}return []}function hy(t,e,r,i,s){const o=0===i?fy:dy;let a=[];const l=[];for(let n=0;n<t.length-1;n++){const u=t[n],c=t[n+1],h=0===i?u.x:u.y,p=0===i?c.x:c.y;let f=!1;h<e?p>e&&a.push(o(u,c,e)):h>r?p<r&&a.push(o(u,c,r)):a.push(u),p<e&&h>=e&&(a.push(o(u,c,e)),f=!0),p>r&&h<=r&&(a.push(o(u,c,r)),f=!0),!s&&f&&(l.push(a),a=[]);}const u=t.length-1,c=0===i?t[u].x:t[u].y;return c>=e&&c<=r&&a.push(t[u]),s&&a.length>0&&!a[0].equals(a[a.length-1])&&a.push(new n(a[0].x,a[0].y)),a.length>0&&l.push(a),l}function py(t,e,n,r,i){const s=[];for(const o of t){const t=hy(o,e,n,r,i);t.length>0&&s.push(...t);}return s}function fy(t,e,r){return new n(r,t.y+(r-t.x)/(e.x-t.x)*(e.y-t.y))}function dy(t,e,r){return new n(t.x+(r-t.y)/(e.y-t.y)*(e.x-t.x),r)}ds("FeatureIndex",oy,{omit:["rawTileData","sourceLayerCoder"]});class yy extends n{constructor(t,e,n,r){super(t,e),this.angle=n,void 0!==r&&(this.segment=r);}clone(){return new yy(this.x,this.y,this.angle,this.segment)}}function my(t,e,n,r,i){if(void 0===e.segment||0===n)return !0;let s=e,o=e.segment+1,a=0;for(;a>-n/2;){if(o--,o<0)return !1;a-=t[o].dist(s),s=t[o];}a+=t[o].dist(t[o+1]),o++;const l=[];let u=0;for(;a<n/2;){const e=t[o],n=t[o+1];if(!n)return !1;let s=t[o-1].angleTo(e)-e.angleTo(n);for(s=Math.abs((s+3*Math.PI)%(2*Math.PI)-Math.PI),l.push({distance:a,angleDelta:s}),u+=s;a-l[0].distance>r;)u-=l.shift().angleDelta;if(u>i)return !1;o++,a+=e.dist(n);}return !0}function gy(t){let e=0;for(let n=0;n<t.length-1;n++)e+=t[n].dist(t[n+1]);return e}function xy(t,e,n){return t?.6*e*n:0}function vy(t,e){return Math.max(t?t.right-t.left:0,e?e.right-e.left:0)}function by(t,e,n,r,i,s){const o=xy(n,i,s),a=vy(n,r)*s;let l=0;const u=gy(t)/2;for(let n=0;n<t.length-1;n++){const r=t[n],i=t[n+1],s=r.dist(i);if(l+s>u){const c=(u-l)/s,h=xn.number(r.x,i.x,c),p=xn.number(r.y,i.y,c),f=new yy(h,p,i.angleTo(r),n);return f._round(),!o||my(t,f,a,o,e)?f:void 0}l+=s;}}function wy(t,e,n,r,i,s,o,a,l){const u=xy(r,s,o),c=vy(r,i),h=c*o,p=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-h<e/4&&(e=h+e/4),_y(t,p?e/2*a%e:(c/2+2*s)*o*a%e,e,u,n,h,p,!1,l)}function _y(t,e,n,r,i,s,o,a,l){const u=s/2,c=gy(t);let h=0,p=e-n,f=[];for(let e=0;e<t.length-1;e++){const o=t[e],a=t[e+1],d=o.dist(a),y=a.angleTo(o);for(;p+n<h+d;){p+=n;const m=(p-h)/d,g=xn.number(o.x,a.x,m),x=xn.number(o.y,a.y,m);if(g>=0&&g<l&&x>=0&&x<l&&p-u>=0&&p+u<=c){const n=new yy(g,x,y,e);n._round(),r&&!my(t,n,s,r,i)||f.push(n);}}h+=d;}return a||f.length||o||(f=_y(t,h/2,n,r,i,s,o,!0,l)),f}function Sy(t,e,r,i){const s=[],o=t.image,a=o.pixelRatio,l=o.paddedRect.w-2,u=o.paddedRect.h-2;let c={x1:t.left,y1:t.top,x2:t.right,y2:t.bottom};const h=o.stretchX||[[0,l]],p=o.stretchY||[[0,u]],f=(t,e)=>t+e[1]-e[0],d=h.reduce(f,0),y=p.reduce(f,0),m=l-d,g=u-y;let x=0,v=d,b=0,w=y,_=0,S=m,A=0,M=g;if(o.content&&i){const e=o.content,n=e[2]-e[0],r=e[3]-e[1];(o.textFitWidth||o.textFitHeight)&&(c=dp(t)),x=Ay(h,0,e[0]),b=Ay(p,0,e[1]),v=Ay(h,e[0],e[2]),w=Ay(p,e[1],e[3]),_=e[0]-x,A=e[1]-b,S=n-v,M=r-w;}const k=c.x1,I=c.y1,E=c.x2-k,T=c.y2-I,F=(t,i,s,l)=>{const u=ky(t.stretch-x,v,E,k),c=Iy(t.fixed-_,S,t.stretch,d),h=ky(i.stretch-b,w,T,I),p=Iy(i.fixed-A,M,i.stretch,y),f=ky(s.stretch-x,v,E,k),m=Iy(s.fixed-_,S,s.stretch,d),g=ky(l.stretch-b,w,T,I),F=Iy(l.fixed-A,M,l.stretch,y),P=new n(u,h),D=new n(f,h),z=new n(f,g),B=new n(u,g),C=new n(c/a,p/a),V=new n(m/a,F/a),L=e*Math.PI/180;if(L){const t=Math.sin(L),e=Math.cos(L),n=[e,-t,t,e];P._matMult(n),D._matMult(n),B._matMult(n),z._matMult(n);}const O=t.stretch+t.fixed,$=i.stretch+i.fixed;return {tl:P,tr:D,bl:B,br:z,tex:{x:o.paddedRect.x+1+O,y:o.paddedRect.y+1+$,w:s.stretch+s.fixed-O,h:l.stretch+l.fixed-$},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:C,pixelOffsetBR:V,minFontScaleX:S/a/E,minFontScaleY:M/a/T,isSDF:r}};if(i&&(o.stretchX||o.stretchY)){const t=My(h,m,d),e=My(p,g,y);for(let n=0;n<t.length-1;n++){const r=t[n],i=t[n+1];for(let t=0;t<e.length-1;t++)s.push(F(r,e[t],i,e[t+1]));}}else s.push(F({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:l+1},{fixed:0,stretch:u+1}));return s}function Ay(t,e,n){let r=0;for(const i of t)r+=Math.max(e,Math.min(n,i[1]))-Math.max(e,Math.min(n,i[0]));return r}function My(t,e,n){const r=[{fixed:-1,stretch:0}];for(const[e,n]of t){const t=r[r.length-1];r.push({fixed:e-t.stretch,stretch:t.stretch}),r.push({fixed:e-t.stretch,stretch:t.stretch+(n-e)});}return r.push({fixed:e+1,stretch:n}),r}function ky(t,e,n,r){return t/e*n+r}function Iy(t,e,n,r){return t-e*n/r}ds("Anchor",yy);class Ey{constructor(t,e,r,i,s,o,a,l,u,c){var h;if(this.boxStartIndex=t.length,u){let t=o.top,e=o.bottom;const n=o.collisionPadding;n&&(t-=n[1],e+=n[3]);let r=e-t;r>0&&(r=Math.max(10,r),this.circleDiameter=r);}else {const u=(null===(h=o.image)||void 0===h?void 0:h.content)&&(o.image.textFitWidth||o.image.textFitHeight)?dp(o):{x1:o.left,y1:o.top,x2:o.right,y2:o.bottom};u.y1=u.y1*a-l[0],u.y2=u.y2*a+l[2],u.x1=u.x1*a-l[3],u.x2=u.x2*a+l[1];const p=o.collisionPadding;if(p&&(u.x1-=p[0]*a,u.y1-=p[1]*a,u.x2+=p[2]*a,u.y2+=p[3]*a),c){const t=new n(u.x1,u.y1),e=new n(u.x2,u.y1),r=new n(u.x1,u.y2),i=new n(u.x2,u.y2),s=c*Math.PI/180;t._rotate(s),e._rotate(s),r._rotate(s),i._rotate(s),u.x1=Math.min(t.x,e.x,r.x,i.x),u.x2=Math.max(t.x,e.x,r.x,i.x),u.y1=Math.min(t.y,e.y,r.y,i.y),u.y2=Math.max(t.y,e.y,r.y,i.y);}t.emplaceBack(e.x,e.y,u.x1,u.y1,u.x2,u.y2,r,i,s);}this.boxEndIndex=t.length;}}class Ty{constructor(t=[],e=(t,e)=>t<e?-1:t>e?1:0){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t);}push(t){this.data.push(t),this._up(this.length++);}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return --this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:n}=this,r=e[t];for(;t>0;){const i=t-1>>1,s=e[i];if(n(r,s)>=0)break;e[t]=s,t=i;}e[t]=r;}_down(t){const{data:e,compare:n}=this,r=this.length>>1,i=e[t];for(;t<r;){let r=1+(t<<1);const s=r+1;if(s<this.length&&n(e[s],e[r])<0&&(r=s),n(e[r],i)>=0)break;e[t]=e[r],t=r;}e[t]=i;}}function Fy(t,e=1){const r=tf.fromPoints(t[0]),i=Math.min(r.width(),r.height());let s=i/2;const o=new Ty([],Py),{minX:a,minY:l,maxX:u,maxY:c}=r;if(0===i)return new n(a,l);for(let e=a;e<u;e+=i)for(let n=l;n<c;n+=i)o.push(new Dy(e+s,n+s,s,t));const h=function(t){let e=0,n=0,r=0;const i=t[0];for(let t=0,s=i.length,o=s-1;t<s;o=t++){const s=i[t],a=i[o],l=s.x*a.y-a.x*s.y;n+=(s.x+a.x)*l,r+=(s.y+a.y)*l,e+=3*l;}return new Dy(n/e,r/e,0,t)}(t);let p=h;for(;o.length;){const n=o.pop();(n.d>p.d||!p.d)&&(p=n),n.max-p.d<=e||(s=n.h/2,o.push(new Dy(n.p.x-s,n.p.y-s,s,t)),o.push(new Dy(n.p.x+s,n.p.y-s,s,t)),o.push(new Dy(n.p.x-s,n.p.y+s,s,t)),o.push(new Dy(n.p.x+s,n.p.y+s,s,t)));}return h.d>0&&p.d-h.d<=e?h.p:p.p}function Py(t,e){return e.max-t.max}class Dy{constructor(t,e,r,i){this.p=new n(t,e),this.h=r,this.d=function(t,e){let n=!1,r=1/0;for(const i of e)for(let e=0,s=i.length,o=s-1;e<s;o=e++){const s=i[e],a=i[o];s.y>t.y!=a.y>t.y&&t.x<(a.x-s.x)*(t.y-s.y)/(a.y-s.y)+s.x&&(n=!n),r=Math.min(r,nl(t,s,a));}return (n?1:-1)*Math.sqrt(r)}(this.p,i),this.max=this.d+this.h*Math.SQRT2;}}var zy;t.aM=void 0,(zy=t.aM||(t.aM={}))[zy.center=1]="center",zy[zy.left=2]="left",zy[zy.right=3]="right",zy[zy.top=4]="top",zy[zy.bottom=5]="bottom",zy[zy["top-left"]=6]="top-left",zy[zy["top-right"]=7]="top-right",zy[zy["bottom-left"]=8]="bottom-left",zy[zy["bottom-right"]=9]="bottom-right";const By=Number.POSITIVE_INFINITY;function Cy(t,e){return e[1]!==By?function(t,e,n){let r=0,i=0;switch(e=Math.abs(e),n=Math.abs(n),t){case "top-right":case "top-left":case "top":i=n-7;break;case "bottom-right":case "bottom-left":case "bottom":i=7-n;}switch(t){case "top-right":case "bottom-right":case "right":r=-e;break;case "top-left":case "bottom-left":case "left":r=e;}return [r,i]}(t,e[0],e[1]):function(t,e){let n=0,r=0;e<0&&(e=0);const i=e/Math.SQRT2;switch(t){case "top-right":case "top-left":r=i-7;break;case "bottom-right":case "bottom-left":r=7-i;break;case "bottom":r=7-e;break;case "top":r=e-7;}switch(t){case "top-right":case "bottom-right":n=-i;break;case "top-left":case "bottom-left":n=i;break;case "left":n=e;break;case "right":n=-e;}return [n,r]}(t,e[0])}function Vy(t,e,n){var r;const i=t.layout,s=null===(r=i.get("text-variable-anchor-offset"))||void 0===r?void 0:r.evaluate(e,{},n);if(s){const t=s.values,e=[];for(let n=0;n<t.length;n+=2){const r=e[n]=t[n],i=t[n+1].map((t=>t*Ih));r.startsWith("top")?i[1]-=7:r.startsWith("bottom")&&(i[1]+=7),e[n+1]=i;}return new $e(e)}const o=i.get("text-variable-anchor");if(o){let r;r=void 0!==t._unevaluatedLayout.getValue("text-radial-offset")?[i.get("text-radial-offset").evaluate(e,{},n)*Ih,By]:i.get("text-offset").evaluate(e,{},n).map((t=>t*Ih));const s=[];for(const t of o)s.push(t,Cy(t,r));return new $e(s)}return null}function Ly(t){switch(t){case "right":case "top-right":case "bottom-right":return "right";case "left":case "top-left":case "bottom-left":return "left"}return "center"}function Oy(e,n,r,i,s,o,a,l,u,c,h,p){let f=o.textMaxSize.evaluate(n,{});void 0===f&&(f=a);const d=e.layers[0].layout,y=d.get("icon-offset").evaluate(n,{},h),m=Ry(r.horizontal),g=a/24,x=e.tilePixelRatio*g,v=e.tilePixelRatio*f/24,b=e.tilePixelRatio*l,w=e.tilePixelRatio*d.get("symbol-spacing"),_=d.get("text-padding")*e.tilePixelRatio,S=function(t,e,n,r=1){const i=t.get("icon-padding").evaluate(e,{},n),s=null==i?void 0:i.values;return [s[0]*r,s[1]*r,s[2]*r,s[3]*r]}(d,n,h,e.tilePixelRatio),A=d.get("text-max-angle")/180*Math.PI,M="viewport"!==d.get("text-rotation-alignment")&&"point"!==d.get("symbol-placement"),k="map"===d.get("icon-rotation-alignment")&&"point"!==d.get("symbol-placement"),I=d.get("symbol-placement"),E=w/2,F=d.get("icon-text-fit");let P;i&&"none"!==F&&(e.allowVerticalPlacement&&r.vertical&&(P=yp(i,r.vertical,F,d.get("icon-text-fit-padding"),y,g)),m&&(i=yp(i,m,F,d.get("icon-text-fit-padding"),y,g)));const D=h?p.line.getGranularityForZoomLevel(h.z):1,z=(l,p)=>{p.x<0||p.x>=T||p.y<0||p.y>=T||function(e,n,r,i,s,o,a,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,S,A,M){const k=e.addToLineVertexArray(n,r);let I,E,T,F,P=0,D=0,z=0,B=0,C=-1,V=-1;const L={};let O=ba("");if(e.allowVerticalPlacement&&i.vertical){const t=l.layout.get("text-rotate").evaluate(w,{},A)+90;T=new Ey(u,n,c,h,p,i.vertical,f,d,y,t),a&&(F=new Ey(u,n,c,h,p,a,g,x,y,t));}if(s){const r=l.layout.get("icon-rotate").evaluate(w,{}),i="none"!==l.layout.get("icon-text-fit"),o=Sy(s,r,S,i),f=a?Sy(a,r,S,i):void 0;E=new Ey(u,n,c,h,p,s,g,x,!1,r),P=4*o.length;const d=e.iconSizeData;let y=null;"source"===d.kind?(y=[mp*l.layout.get("icon-size").evaluate(w,{})],y[0]>gp&&G(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):"composite"===d.kind&&(y=[mp*_.compositeIconSizes[0].evaluate(w,{},A),mp*_.compositeIconSizes[1].evaluate(w,{},A)],(y[0]>gp||y[1]>gp)&&G(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),e.addSymbols(e.icon,o,y,b,v,w,t.ax.none,n,k.lineStartIndex,k.lineLength,-1,A),C=e.icon.placedSymbolArray.length-1,f&&(D=4*f.length,e.addSymbols(e.icon,f,y,b,v,w,t.ax.vertical,n,k.lineStartIndex,k.lineLength,-1,A),V=e.icon.placedSymbolArray.length-1);}const $=Object.keys(i.horizontal);for(const r of $){const s=i.horizontal[r];if(!I){O=ba(s.text);const t=l.layout.get("text-rotate").evaluate(w,{},A);I=new Ey(u,n,c,h,p,s,f,d,y,t);}const a=1===s.positionedLines.length;if(z+=$y(e,n,s,o,l,y,w,m,k,i.vertical?t.ax.horizontal:t.ax.horizontalOnly,a?$:[r],L,C,_,A),a)break}i.vertical&&(B+=$y(e,n,i.vertical,o,l,y,w,m,k,t.ax.vertical,["vertical"],L,V,_,A));const R=I?I.boxStartIndex:e.collisionBoxArray.length,N=I?I.boxEndIndex:e.collisionBoxArray.length,U=T?T.boxStartIndex:e.collisionBoxArray.length,j=T?T.boxEndIndex:e.collisionBoxArray.length,q=E?E.boxStartIndex:e.collisionBoxArray.length,X=E?E.boxEndIndex:e.collisionBoxArray.length,Y=F?F.boxStartIndex:e.collisionBoxArray.length,Z=F?F.boxEndIndex:e.collisionBoxArray.length;let H=-1;const W=(t,e)=>(null==t?void 0:t.circleDiameter)?Math.max(t.circleDiameter,e):e;H=W(I,H),H=W(T,H),H=W(E,H),H=W(F,H);const K=H>-1?1:0;K&&(H*=M/Ih),e.glyphOffsetArray.length>=kp.MAX_GLYPHS&&G("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==w.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,w.sortKey);const J=Vy(l,w,A),[Q,tt]=function(e,n){const r=e.length,i=null==n?void 0:n.values;if((null==i?void 0:i.length)>0)for(let n=0;n<i.length;n+=2){const r=i[n+1];e.emplaceBack(t.aM[i[n]],r[0],r[1]);}return [r,e.length]}(e.textAnchorOffsets,J);e.symbolInstances.emplaceBack(n.x,n.y,L.right>=0?L.right:-1,L.center>=0?L.center:-1,L.left>=0?L.left:-1,L.vertical||-1,C,V,O,R,N,U,j,q,X,Y,Z,c,z,B,P,D,K,0,f,H,Q,tt);}(e,p,l,r,i,s,P,e.layers[0],e.collisionBoxArray,n.index,n.sourceLayerIndex,e.index,x,[_,_,_,_],M,u,b,S,k,y,n,o,c,h,a);};if("line"===I)for(const t of uy(n.geometry,0,0,T,T)){const n=Su(t,D),s=wy(n,w,A,r.vertical||m,i,24,v,e.overscaling,T);for(const t of s)m&&Ny(e,m.text,E,t)||z(n,t);}else if("line-center"===I){for(const t of n.geometry)if(t.length>1){const e=Su(t,D),n=by(e,A,r.vertical||m,i,24,v);n&&z(e,n);}}else if("Polygon"===n.type)for(const t of rr(n.geometry,0)){const e=Fy(t,16);z(Su(t[0],D,!0),new yy(e.x,e.y,0));}else if("LineString"===n.type)for(const t of n.geometry){const e=Su(t,D);z(e,new yy(e[0].x,e[0].y,0));}else if("Point"===n.type)for(const t of n.geometry)for(const e of t)z([e],new yy(e.x,e.y,0));}function $y(t,e,r,i,s,o,a,l,u,c,h,p,f,d,y){const m=function(t,e,r,i,s,o,a,l){const u=i.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,c=[];for(const t of e.positionedLines)for(const i of t.positionedGlyphs){if(!i.rect)continue;const o=i.rect||{};let h=4,p=!0,f=1,d=0;const y=(s||l)&&i.vertical,m=i.metrics.advance*i.scale/2;if(l&&e.verticalizable&&(d=t.lineOffset/2-(i.imageName?-(Ih-i.metrics.width*i.scale)/2:(i.scale-1)*Ih)),i.imageName){const t=a[i.imageName];p=t.sdf,f=t.pixelRatio,h=1/f;}const g=s?[i.x+m,i.y]:[0,0];let x=s?[0,0]:[i.x+m+r[0],i.y+r[1]-d],v=[0,0];y&&(v=x,x=[0,0]);const b=i.metrics.isDoubleResolution?2:1,w=(i.metrics.left-h)*i.scale-m+x[0],_=(-i.metrics.top-h)*i.scale+x[1],S=w+o.w/b*i.scale/f,A=_+o.h/b*i.scale/f,M=new n(w,_),k=new n(S,_),I=new n(w,A),E=new n(S,A);if(y){const t=new n(-m,m- -17),e=-Math.PI/2,r=12-m,s=new n(22-r,-(i.imageName?r:0)),o=new n(...v);M._rotateAround(e,t)._add(s)._add(o),k._rotateAround(e,t)._add(s)._add(o),I._rotateAround(e,t)._add(s)._add(o),E._rotateAround(e,t)._add(s)._add(o);}if(u){const t=Math.sin(u),e=Math.cos(u),n=[e,-t,t,e];M._matMult(n),k._matMult(n),I._matMult(n),E._matMult(n);}const T=new n(0,0),F=new n(0,0);c.push({tl:M,tr:k,bl:I,br:E,tex:o,writingMode:e.writingMode,glyphOffset:g,sectionIndex:i.sectionIndex,isSDF:p,pixelOffsetTL:T,pixelOffsetBR:F,minFontScaleX:0,minFontScaleY:0});}return c}(0,r,l,s,o,a,i,t.allowVerticalPlacement),g=t.textSizeData;let x=null;"source"===g.kind?(x=[mp*s.layout.get("text-size").evaluate(a,{})],x[0]>gp&&G(`${t.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):"composite"===g.kind&&(x=[mp*d.compositeTextSizes[0].evaluate(a,{},y),mp*d.compositeTextSizes[1].evaluate(a,{},y)],(x[0]>gp||x[1]>gp)&&G(`${t.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),t.addSymbols(t.text,m,x,l,o,a,c,e,u.lineStartIndex,u.lineLength,f,y);for(const e of h)p[e]=t.text.placedSymbolArray.length-1;return 4*m.length}function Ry(t){for(const e in t)return t[e];return null}function Ny(t,e,n,r){const i=t.compareText;if(e in i){const t=i[e];for(let e=t.length-1;e>=0;e--)if(r.dist(t[e])<n)return !0}else i[e]=[];return i[e].push(r),!1}t.$=at,t.A=f,t.B=Ls,t.C=hs,t.D=Xs,t.E=bt,t.F=os,t.G=function([t,e,n]){return e+=90,e*=Math.PI/180,n*=Math.PI/180,{x:t*Math.cos(e)*Math.sin(n),y:t*Math.sin(e)*Math.sin(n),z:t*Math.cos(n)}},t.H=xn,t.I=np,t.J=Cs,t.K=ls,t.L=function(t){if(null==Z){const e=t.navigator?t.navigator.userAgent:null;Z=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")));}return Z},t.M=ht,t.N=class{constructor(t,e){this.target=t,this.mapId=e,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new Vp((()=>this.process())),this.subscription=tt(this.target,"message",(t=>this.receive(t)),!1),this.globalScope=Y(self)?t:window;}registerMessageHandler(t,e){this.messageHandlers[t]=e;}unregisterMessageHandler(t){delete this.messageHandlers[t];}sendAsync(t,e){return new Promise(((n,r)=>{const i=Math.round(1e18*Math.random()).toString(36).substring(0,10),s=e?tt(e.signal,"abort",(()=>{null==s||s.unsubscribe(),delete this.resolveRejects[i];const e={id:i,type:"<cancel>",origin:location.origin,targetMapId:t.targetMapId,sourceMapId:this.mapId};this.target.postMessage(e);}),Lp):null;this.resolveRejects[i]={resolve:t=>{null==s||s.unsubscribe(),n(t);},reject:t=>{null==s||s.unsubscribe(),r(t);}};const o=[],a=Object.assign(Object.assign({},t),{id:i,sourceMapId:this.mapId,origin:location.origin,data:xs(t.data,o)});this.target.postMessage(a,{transfer:o});}))}receive(t){const e=t.data,n=e.id,r=["file://","resource://android","null"],i=[e.origin,location.origin],s=e.origin===location.origin,o=i.some((t=>r.includes(t)));if((s||o)&&(!e.targetMapId||this.mapId===e.targetMapId)){if("<cancel>"===e.type){delete this.tasks[n];const t=this.abortControllers[n];return delete this.abortControllers[n],void(t&&t.abort())}if(Y(self)||e.mustQueue)return this.tasks[n]=e,this.taskQueue.push(n),void this.invoker.trigger();this.processTask(n,e);}}process(){if(0===this.taskQueue.length)return;const t=this.taskQueue.shift(),e=this.tasks[t];delete this.tasks[t],this.taskQueue.length>0&&this.invoker.trigger(),e&&this.processTask(t,e);}processTask(t,n){return e(this,void 0,void 0,(function*(){if("<response>"===n.type){const e=this.resolveRejects[t];if(delete this.resolveRejects[t],!e)return;return void(n.error?e.reject(P(vs(n.error))):e.resolve(vs(n.data)))}if(!this.messageHandlers[n.type])return void this.completeTask(t,new Error(`Could not find a registered handler for ${n.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const e=vs(n.data),r=new AbortController;this.abortControllers[t]=r;try{const i=yield this.messageHandlers[n.type](n.sourceMapId,e,r);this.completeTask(t,null,i);}catch(e){this.completeTask(t,P(e));}}))}completeTask(t,e,n){const r=[];delete this.abortControllers[t];const i={id:t,type:"<response>",sourceMapId:this.mapId,origin:location.origin,error:e?xs(e):null,data:xs(n,r)};this.target.postMessage(i,{transfer:r});}remove(){this.invoker.remove(),this.subscription.unsubscribe();}},t.O=function(){var t=new f(16);return f!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t},t.P=n,t.Q=function(t,e,n){var r,i,s,o,a,l,u,c,h,p,f,d,y=n[0],m=n[1],g=n[2];return e===t?(t[12]=e[0]*y+e[4]*m+e[8]*g+e[12],t[13]=e[1]*y+e[5]*m+e[9]*g+e[13],t[14]=e[2]*y+e[6]*m+e[10]*g+e[14],t[15]=e[3]*y+e[7]*m+e[11]*g+e[15]):(i=e[1],s=e[2],o=e[3],a=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=e[9],f=e[10],d=e[11],t[0]=r=e[0],t[1]=i,t[2]=s,t[3]=o,t[4]=a,t[5]=l,t[6]=u,t[7]=c,t[8]=h,t[9]=p,t[10]=f,t[11]=d,t[12]=r*y+a*m+h*g+e[12],t[13]=i*y+l*m+p*g+e[13],t[14]=s*y+u*m+f*g+e[14],t[15]=o*y+c*m+d*g+e[15]),t},t.R=Il,t.S=function(t,e,n){var r=n[0],i=n[1],s=n[2];return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*s,t[9]=e[9]*s,t[10]=e[10]*s,t[11]=e[11]*s,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},t.T=Ol,t.U=function(t,e,n){var r=e[0],i=e[1],s=e[2],o=e[3],a=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=e[9],f=e[10],d=e[11],y=e[12],m=e[13],g=e[14],x=e[15],v=n[0],b=n[1],w=n[2],_=n[3];return t[0]=v*r+b*a+w*h+_*y,t[1]=v*i+b*l+w*p+_*m,t[2]=v*s+b*u+w*f+_*g,t[3]=v*o+b*c+w*d+_*x,t[4]=(v=n[4])*r+(b=n[5])*a+(w=n[6])*h+(_=n[7])*y,t[5]=v*i+b*l+w*p+_*m,t[6]=v*s+b*u+w*f+_*g,t[7]=v*o+b*c+w*d+_*x,t[8]=(v=n[8])*r+(b=n[9])*a+(w=n[10])*h+(_=n[11])*y,t[9]=v*i+b*l+w*p+_*m,t[10]=v*s+b*u+w*f+_*g,t[11]=v*o+b*c+w*d+_*x,t[12]=(v=n[12])*r+(b=n[13])*a+(w=n[14])*h+(_=n[15])*y,t[13]=v*i+b*l+w*p+_*m,t[14]=v*s+b*u+w*f+_*g,t[15]=v*o+b*c+w*d+_*x,t},t.V=function(t,e){const n={};for(const r of e)r in t&&(n[r]=t[r]);return n},t.W=$p,t.X=O,t.Y=jp,t.Z=Up,t._=e,t.a=ot,t.a$=function(t){var e=new f(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},t.a0=c,t.a1=h,t.a2=K,t.a3=Jp,t.a4=Gp,t.a5=Xp,t.a6=T,t.a7=Zp,t.a8=tf,t.a9=25,t.aA=function(t){var e=t[0],n=t[1];return Math.sqrt(e*e+n*n)},t.aB=function(t){return t[0]=0,t[1]=0,t},t.aC=function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t},t.aD=_p,t.aE=A,t.aF=function(t,e,r,i){const s=e.y-t.y,o=e.x-t.x,a=i.y-r.y,l=i.x-r.x,u=a*o-l*s;if(0===u)return null;const c=(l*(t.y-r.y)-a*(t.x-r.x))/u;return new n(t.x+c*o,t.y+c*s)},t.aG=uy,t.aH=Ha,t.aI=function(t){let e=1/0,n=1/0,r=-1/0,i=-1/0;for(const s of t)e=Math.min(e,s.x),n=Math.min(n,s.y),r=Math.max(r,s.x),i=Math.max(i,s.y);return [e,n,r,i]},t.aJ=Ih,t.aK=F,t.aL=function(t,e,n,r,i=!1){if(!n[0]&&!n[1])return [0,0];const s=i?"map"===r?-t.bearingInRadians:0:"viewport"===r?t.bearingInRadians:0;if(s){const t=Math.sin(s),e=Math.cos(s);n=[n[0]*e-n[1]*t,n[0]*t+n[1]*e];}return [i?n[0]:F(e,n[0],t.zoom),i?n[1]:F(e,n[1],t.zoom)]},t.aN=vp,t.aO=Ly,t.aP=op,t.aQ=t=>"symbol"===t.type,t.aR=ec,t.aS=ao,t.aT=xu,t.aU=Xo,t.aV=ua,t.aW=sa,t.aX=nt,t.aY=Yp,t.aZ=b,t.a_=v,t.aa=Wp,t.ab=t=>{const e=window.document.createElement("video");return e.muted=!0,new Promise((n=>{e.onloadstart=()=>{n(e);};for(const n of t){const t=window.document.createElement("source");yt(n)||(e.crossOrigin="Anonymous"),t.src=n,e.appendChild(t);}}))},t.ac=zt,t.ad=function(){return R++},t.ae=Co,t.af=kp,t.ag=Jd,t.ah=yi,t.ai=Ga,t.aj=nf,t.ak=function(t){const e={};if(t.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((t,n,r,i)=>{const s=r||i;return e[n]=!s||s.toLowerCase(),""})),e["max-age"]){const t=parseInt(e["max-age"],10);isNaN(t)?delete e["max-age"]:e["max-age"]=t;}return e},t.al=L,t.am=85.051129,t.an=et,t.ao=function(t){return Math.pow(2,t)},t.ap=y,t.aq=qp,t.ar=function(t){return Math.log(t)/Math.LN2},t.as=function(t){var e=t[0],n=t[1];return e*e+n*n},t.at=function(t){if(!t.length)return new Set;const e=Math.max(...t.map((t=>t.canonical.z)));let n=1/0,r=-1/0,i=1/0,s=-1/0;const o=[];for(const a of t){const{x:t,y:l,z:u}=a.canonical,c=Math.pow(2,e-u),h=t*c,p=l*c;o.push({id:a,x:h,y:p}),h<n&&(n=h),h>r&&(r=h),p<i&&(i=p),p>s&&(s=p);}const a=new Set;for(const t of o)t.x!==n&&t.x!==r&&t.y!==i&&t.y!==s||a.add(t.id);return a},t.au=function(t,e){const n=Math.abs(2*t.wrap)-+(t.wrap<0),r=Math.abs(2*e.wrap)-+(e.wrap<0);return t.overscaledZ-e.overscaledZ||r-n||e.canonical.y-t.canonical.y||e.canonical.x-t.canonical.x},t.av=class{constructor(t,e){this.max=t,this.onRemove=e,this.reset();}reset(){for(const t in this.data)for(const e of this.data[t])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(t,e,n){const r=t.wrapped().key;void 0===this.data[r]&&(this.data[r]=[]);const i={value:e,timeout:void 0};if(void 0!==n&&(i.timeout=setTimeout((()=>{this.remove(t,i);}),n)),this.data[r].push(i),this.order.push(r),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t);}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const n=t.wrapped().key,r=void 0===e?0:this.data[n].indexOf(e),i=this.data[n][r];return this.data[n].splice(r,1),i.timeout&&clearTimeout(i.timeout),0===this.data[n].length&&delete this.data[n],this.onRemove(i.value),this.order.splice(this.order.indexOf(n),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t);}return this}filter(t){const e=[];for(const n in this.data)for(const r of this.data[n])t(r.value)||e.push(r);for(const t of e)this.remove(t.value.tileID,t);}},t.aw=function(t,e){let n=0,r=0;if("constant"===t.kind)r=t.layoutSize;else if("source"!==t.kind){const{interpolationType:i,minZoom:s,maxZoom:o}=t,a=i?L(mn.interpolationFactor(i,e,s,o),0,1):0;"camera"===t.kind?r=xn.number(t.minSize,t.maxSize,a):n=a;}return {uSizeT:n,uSize:r}},t.ay=function(t,{uSize:e,uSizeT:n},{lowerSize:r,upperSize:i}){return "source"===t.kind?r/mp:"composite"===t.kind?xn.number(r/mp,i/mp,n):e},t.az=I,t.b=H,t.b$=Ea,t.b0=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t},t.b1=function(t,e){var n=e[0],r=e[1],i=e[2],s=n*n+r*r+i*i;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t},t.b2=w,t.b3=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},t.b4=function(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t[3]=e[3]*n[3],t},t.b5=g,t.b6=function(t,e,n){const r=e[0]*n[0]+e[1]*n[1]+e[2]*n[2];return 0===r?null:(-(t[0]*n[0]+t[1]*n[1]+t[2]*n[2])-n[3])/r},t.b7=S,t.b8=function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t},t.b9=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]},t.bA=k,t.bB=function(t,e,n){var r=n[0],i=n[1],s=n[2],o=n[3],a=e[0],l=e[1],u=e[2],c=i*u-s*l,h=s*a-r*u,p=r*l-i*a;return t[0]=a+o*(c+=c)+i*(p+=p)-s*(h+=h),t[1]=l+o*h+s*c-r*p,t[2]=u+o*p+r*h-i*c,t},t.bC=function(t,e,n){const r=(i=[t[0],t[1],t[2],e[0],e[1],e[2],n[0],n[1],n[2]])[0]*((c=i[8])*(o=i[4])-(a=i[5])*(u=i[7]))+i[1]*(-c*(s=i[3])+a*(l=i[6]))+i[2]*(u*s-o*l);var i,s,o,a,l,u,c;if(0===r)return null;const h=w([],[e[0],e[1],e[2]],[n[0],n[1],n[2]]),p=w([],[n[0],n[1],n[2]],[t[0],t[1],t[2]]),f=w([],[t[0],t[1],t[2]],[e[0],e[1],e[2]]),d=b([],h,-t[3]);return v(d,d,b([],p,-e[3])),v(d,d,b([],f,-n[3])),b(d,d,1/r),d},t.bD=Op,t.bE=function(){return new Float64Array(4)},t.bF=function(t,e,n,r){var i=[],s=[];return i[0]=e[0]-n[0],i[1]=e[1]-n[1],i[2]=e[2]-n[2],s[0]=i[0]*Math.cos(r)-i[1]*Math.sin(r),s[1]=i[0]*Math.sin(r)+i[1]*Math.cos(r),s[2]=i[2],t[0]=s[0]+n[0],t[1]=s[1]+n[1],t[2]=s[2]+n[2],t},t.bG=function(t,e,n,r){var i=[],s=[];return i[0]=e[0]-n[0],i[1]=e[1]-n[1],i[2]=e[2]-n[2],s[0]=i[0],s[1]=i[1]*Math.cos(r)-i[2]*Math.sin(r),s[2]=i[1]*Math.sin(r)+i[2]*Math.cos(r),t[0]=s[0]+n[0],t[1]=s[1]+n[1],t[2]=s[2]+n[2],t},t.bH=function(t,e,n,r){var i=[],s=[];return i[0]=e[0]-n[0],i[1]=e[1]-n[1],i[2]=e[2]-n[2],s[0]=i[2]*Math.sin(r)+i[0]*Math.cos(r),s[1]=i[1],s[2]=i[2]*Math.cos(r)-i[0]*Math.sin(r),t[0]=s[0]+n[0],t[1]=s[1]+n[1],t[2]=s[2]+n[2],t},t.bI=function(t,e,n){var r=Math.sin(n),i=Math.cos(n),s=e[0],o=e[1],a=e[2],l=e[3],u=e[8],c=e[9],h=e[10],p=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=s*i-u*r,t[1]=o*i-c*r,t[2]=a*i-h*r,t[3]=l*i-p*r,t[8]=s*r+u*i,t[9]=o*r+c*i,t[10]=a*r+h*i,t[11]=l*r+p*i,t},t.bJ=function(t,e){const n=D(t,360),r=D(e,360),i=r-n,s=r>n?i-360:i+360;return Math.abs(i)<Math.abs(s)?i:s},t.bK=function(t){return t[0]=0,t[1]=0,t[2]=0,t},t.bL=function(t,e,n,r){const i=Math.sqrt(t*t+e*e),s=Math.sqrt(n*n+r*r);t/=i,e/=i,n/=s,r/=s;const o=Math.acos(t*n+e*r);return -e*n+t*r>0?o:-o},t.bM=function(t,e){const n=D(t,2*Math.PI),r=D(e,2*Math.PI);return Math.min(Math.abs(n-r),Math.abs(n-r+2*Math.PI),Math.abs(n-r-2*Math.PI))},t.bN=function(){const t={},e=wt.$version;for(const n in wt.$root){const r=wt.$root[n];if(r.required){let i=null;i="version"===n?e:"array"===r.type?[]:{},null!=i&&(t[n]=i);}}return t},t.bO=ft,t.bP=bs,t.bQ=function t(e,n){if(Array.isArray(e)){if(!Array.isArray(n)||e.length!==n.length)return !1;for(let r=0;r<e.length;r++)if(!t(e[r],n[r]))return !1;return !0}if("object"==typeof e&&null!==e&&null!==n){if("object"!=typeof n)return !1;if(Object.keys(e).length!==Object.keys(n).length)return !1;for(const r in e)if(!t(e[r],n[r]))return !1;return !0}return e===n},t.bR=lt,t.bS=function(t){t=t.slice();const e=Object.create(null);for(let n=0;n<t.length;n++)e[t[n].id]=t[n];for(let n=0;n<t.length;n++)"ref"in t[n]&&(t[n]=St(t[n],e[t[n].ref]));return t},t.bT=function(t,e){if("custom"===t.type)return new Cp(t,e);switch(t.type){case "background":return new Bp(t,e);case "circle":return new vl(t,e);case "color-relief":return new Nl(t,e);case "fill":return new Pu(t,e);case "fill-extrusion":return new Ku(t,e);case "heatmap":return new Pl(t,e);case "hillshade":return new Bl(t,e);case "line":return new xh(t,e);case "raster":return new ro(t,e);case "symbol":return new Pp(t,e)}},t.bU=t=>"raster"===t.type,t.bV=j,t.bW=function(t,e){if(!t)return [{command:"setStyle",args:[e]}];let n=[];try{if(!At(t.version,e.version))return [{command:"setStyle",args:[e]}];At(t.center,e.center)||n.push({command:"setCenter",args:[e.center]}),At(t.state,e.state)||n.push({command:"setGlobalState",args:[e.state]}),At(t.centerAltitude,e.centerAltitude)||n.push({command:"setCenterAltitude",args:[e.centerAltitude]}),At(t.zoom,e.zoom)||n.push({command:"setZoom",args:[e.zoom]}),At(t.bearing,e.bearing)||n.push({command:"setBearing",args:[e.bearing]}),At(t.pitch,e.pitch)||n.push({command:"setPitch",args:[e.pitch]}),At(t.roll,e.roll)||n.push({command:"setRoll",args:[e.roll]}),At(t.sprite,e.sprite)||n.push({command:"setSprite",args:[e.sprite]}),At(t.glyphs,e.glyphs)||n.push({command:"setGlyphs",args:[e.glyphs]}),At(t.transition,e.transition)||n.push({command:"setTransition",args:[e.transition]}),At(t.light,e.light)||n.push({command:"setLight",args:[e.light]}),At(t.terrain,e.terrain)||n.push({command:"setTerrain",args:[e.terrain]}),At(t.sky,e.sky)||n.push({command:"setSky",args:[e.sky]}),At(t.projection,e.projection)||n.push({command:"setProjection",args:[e.projection]});const r={},i=[];!function(t,e,n,r){let i;for(i in e=e||{},t=t||{})Object.prototype.hasOwnProperty.call(t,i)&&(Object.prototype.hasOwnProperty.call(e,i)||It(i,n,r));for(i in e)Object.prototype.hasOwnProperty.call(e,i)&&(Object.prototype.hasOwnProperty.call(t,i)?At(t[i],e[i])||("geojson"===t[i].type&&"geojson"===e[i].type&&Tt(t,e,i)?Mt(n,{command:"setGeoJSONSourceData",args:[i,e[i].data]}):Et(i,e,n,r)):kt(i,e,n));}(t.sources,e.sources,i,r);const s=[];t.layers&&t.layers.forEach((t=>{"source"in t&&r[t.source]?n.push({command:"removeLayer",args:[t.id]}):s.push(t);})),n=n.concat(i),function(t,e,n){e=e||[];const r=(t=t||[]).map(Pt),i=e.map(Pt),s=t.reduce(Dt,{}),o=e.reduce(Dt,{}),a=r.slice(),l=Object.create(null);let u,c,h,p,f;for(let t=0,e=0;t<r.length;t++)u=r[t],Object.prototype.hasOwnProperty.call(o,u)?e++:(Mt(n,{command:"removeLayer",args:[u]}),a.splice(a.indexOf(u,e),1));for(let t=0,e=0;t<i.length;t++)u=i[i.length-1-t],a[a.length-1-t]!==u&&(Object.prototype.hasOwnProperty.call(s,u)?(Mt(n,{command:"removeLayer",args:[u]}),a.splice(a.lastIndexOf(u,a.length-e),1)):e++,p=a[a.length-t],Mt(n,{command:"addLayer",args:[o[u],p]}),a.splice(a.length-t,0,u),l[u]=!0);for(let t=0;t<i.length;t++)if(u=i[t],c=s[u],h=o[u],!l[u]&&!At(c,h))if(At(c.source,h.source)&&At(c["source-layer"],h["source-layer"])&&At(c.type,h.type)){for(f in Ft(c.layout,h.layout,n,u,null,"setLayoutProperty"),Ft(c.paint,h.paint,n,u,null,"setPaintProperty"),At(c.filter,h.filter)||Mt(n,{command:"setFilter",args:[u,h.filter]}),At(c.minzoom,h.minzoom)&&At(c.maxzoom,h.maxzoom)||Mt(n,{command:"setLayerZoomRange",args:[u,h.minzoom,h.maxzoom]}),c)Object.prototype.hasOwnProperty.call(c,f)&&"layout"!==f&&"paint"!==f&&"filter"!==f&&"metadata"!==f&&"minzoom"!==f&&"maxzoom"!==f&&(0===f.indexOf("paint.")?Ft(c[f],h[f],n,u,f.slice(6),"setPaintProperty"):At(c[f],h[f])||Mt(n,{command:"setLayerProperty",args:[u,f,h[f]]}));for(f in h)Object.prototype.hasOwnProperty.call(h,f)&&!Object.prototype.hasOwnProperty.call(c,f)&&"layout"!==f&&"paint"!==f&&"filter"!==f&&"metadata"!==f&&"minzoom"!==f&&"maxzoom"!==f&&(0===f.indexOf("paint.")?Ft(c[f],h[f],n,u,f.slice(6),"setPaintProperty"):At(c[f],h[f])||Mt(n,{command:"setLayerProperty",args:[u,f,h[f]]}));}else Mt(n,{command:"removeLayer",args:[u]}),p=a[a.lastIndexOf(u)+1],Mt(n,{command:"addLayer",args:[h,p]});}(s,e.layers,n);}catch(t){console.warn("Unable to compute style diff:",t),n=[{command:"setStyle",args:[e]}];}return n},t.bX=function(t){const e=[],n=t.id;return void 0===n&&e.push({message:`layers.${n}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${n}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${n}: property "renderingMode" must be either "2d" or "3d"`}),e},t.bY=N,t.bZ=U,t.b_=class extends Ma{constructor(t,e){super(t,e),this.current=0;}set(t){this.current!==t&&(this.current=t,this.gl.uniform1i(this.location,t));}},t.ba=Kp,t.bb=Qp,t.bc=function(t,e,n,r,i){var s=1/Math.tan(e/2);if(t[0]=s/n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=i&&i!==1/0){var o=1/(r-i);t[10]=(i+r)*o,t[14]=2*i*r*o;}else t[10]=-1,t[14]=-2*r;return t},t.bd=function(t){var e=new f(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},t.be=function(t,e,n){var r=Math.sin(n),i=Math.cos(n),s=e[0],o=e[1],a=e[2],l=e[3],u=e[4],c=e[5],h=e[6],p=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=s*i+u*r,t[1]=o*i+c*r,t[2]=a*i+h*r,t[3]=l*i+p*r,t[4]=u*i-s*r,t[5]=c*i-o*r,t[6]=h*i-a*r,t[7]=p*i-l*r,t},t.bf=function(t,e,n){var r=Math.sin(n),i=Math.cos(n),s=e[4],o=e[5],a=e[6],l=e[7],u=e[8],c=e[9],h=e[10],p=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=s*i+u*r,t[5]=o*i+c*r,t[6]=a*i+h*r,t[7]=l*i+p*r,t[8]=u*i-s*r,t[9]=c*i-o*r,t[10]=h*i-a*r,t[11]=p*i-l*r,t},t.bg=function(t,e){var n=e[0],r=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],u=e[7],c=e[8],h=e[9],p=e[10],f=e[11],d=e[12],y=e[13],m=e[14],g=e[15],x=n*a-r*o,v=n*l-i*o,b=n*u-s*o,w=r*l-i*a,_=r*u-s*a,S=i*u-s*l,A=c*y-h*d,M=c*m-p*d,k=c*g-f*d,I=h*m-p*y,E=h*g-f*y,T=p*g-f*m,F=x*T-v*E+b*I+w*k-_*M+S*A;return F?(t[0]=(a*T-l*E+u*I)*(F=1/F),t[1]=(i*E-r*T-s*I)*F,t[2]=(y*S-m*_+g*w)*F,t[3]=(p*_-h*S-f*w)*F,t[4]=(l*k-o*T-u*M)*F,t[5]=(n*T-i*k+s*M)*F,t[6]=(m*b-d*S-g*v)*F,t[7]=(c*S-p*b+f*v)*F,t[8]=(o*E-a*k+u*A)*F,t[9]=(r*k-n*E-s*A)*F,t[10]=(d*_-y*b+g*x)*F,t[11]=(h*b-c*_-f*x)*F,t[12]=(a*M-o*I-l*A)*F,t[13]=(n*I-r*M+i*A)*F,t[14]=(y*v-d*w-m*x)*F,t[15]=(c*w-h*v+p*x)*F,t):null},t.bh=function(){const t=new Float32Array(16);return y(t),t},t.bi=function(){const t=new Float64Array(16);return y(t),t},t.bj=function(){return new Float64Array(16)},t.bk=function(t,e,n){const r=new Float64Array(4);return k(r,t,e-90,n),r},t.bl=function(t,e,n,r){var i,s,o,a,l,u=e[0],c=e[1],h=e[2],f=e[3],d=n[0],y=n[1],m=n[2],g=n[3];return (s=u*d+c*y+h*m+f*g)<0&&(s=-s,d=-d,y=-y,m=-m,g=-g),1-s>p?(i=Math.acos(s),o=Math.sin(i),a=Math.sin((1-r)*i)/o,l=Math.sin(r*i)/o):(a=1-r,l=r),t[0]=a*u+l*d,t[1]=a*c+l*y,t[2]=a*h+l*m,t[3]=a*f+l*g,t},t.bm=function(t){const e=new Float64Array(9);var n,r,i,s,o,a,l,u,c,h,p,f,d,y,m,g,x,v;h=(i=(r=t)[0])*(l=i+i),p=(s=r[1])*l,d=(o=r[2])*l,y=o*(u=s+s),g=(a=r[3])*l,x=a*u,v=a*(c=o+o),(n=e)[0]=1-(f=s*u)-(m=o*c),n[3]=p-v,n[6]=d+x,n[1]=p+v,n[4]=1-h-m,n[7]=y-g,n[2]=d-x,n[5]=y+g,n[8]=1-h-f;const b=nt(-Math.asin(L(e[2],-1,1)));let w,_;return Math.hypot(e[5],e[8])<.001?(w=0,_=-nt(Math.atan2(e[3],e[4]))):(w=nt(0===e[5]&&0===e[8]?0:Math.atan2(e[5],e[8])),_=nt(0===e[1]&&0===e[0]?0:Math.atan2(e[1],e[0]))),{roll:w,pitch:b+90,bearing:_}},t.bn=function(t,e){return t.roll==e.roll&&t.pitch==e.pitch&&t.bearing==e.bearing},t.bo=Te,t.bp=ka,t.bq=vu,t.br=bu,t.bs=gu,t.bt=z,t.bu=B,t.bv=Ne,t.bw=function(t,e,n,r,i){return z(r,i,L((t-e)/(n-e),0,1))},t.bx=function(t,e,n,r){return t[0]=e[0]+n[0]*r,t[1]=e[1]+n[1]*r,t[2]=e[2]+n[2]*r,t},t.by=D,t.bz=function(){return new Float64Array(3)},t.c=ut,t.c$=si,t.c0=class extends Ma{constructor(t,e){super(t,e),this.current=Ta;}set(t){if(t[12]!==this.current[12]||t[0]!==this.current[0])return this.current=t,void this.gl.uniformMatrix4fv(this.location,!1,t);for(let e=1;e<16;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix4fv(this.location,!1,t);break}}},t.c1=Ia,t.c2=class extends Ma{constructor(t,e){super(t,e),this.current=[0,0,0];}set(t){t[0]===this.current[0]&&t[1]===this.current[1]&&t[2]===this.current[2]||(this.current=t,this.gl.uniform3f(this.location,t[0],t[1],t[2]));}},t.c3=class extends Ma{constructor(t,e){super(t,e),this.current=[0,0];}set(t){t[0]===this.current[0]&&t[1]===this.current[1]||(this.current=t,this.gl.uniform2f(this.location,t[0],t[1]));}},t.c4=d,t.c5=function(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=n,t[2]=0,t[3]=-n,t[4]=r,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},t.c6=function(t,e,n){var r=e[0],i=e[1],s=e[2];return t[0]=r*n[0]+i*n[3]+s*n[6],t[1]=r*n[1]+i*n[4]+s*n[7],t[2]=r*n[2]+i*n[5]+s*n[8],t},t.c7=function(t,e,n,r,i,s,o){var a=1/(e-n),l=1/(r-i),u=1/(s-o);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*u,t[11]=0,t[12]=(e+n)*a,t[13]=(i+r)*l,t[14]=(o+s)*u,t[15]=1,t},t.c8=class extends Ma{constructor(t,e){super(t,e),this.current=new Array;}set(t){if(t!=this.current){this.current=t;const e=new Float32Array(4*t.length);for(let n=0;n<t.length;n++)e[4*n]=t[n].r,e[4*n+1]=t[n].g,e[4*n+2]=t[n].b,e[4*n+3]=t[n].a;this.gl.uniform4fv(this.location,e);}}},t.c9=class extends Ma{constructor(t,e){super(t,e),this.current=new Array;}set(t){if(t!=this.current){this.current=t;const e=new Float32Array(t);this.gl.uniform1fv(this.location,e);}}},t.cA=function(t,e){return rt[e]&&"touches"in t},t.cB=function(t){return rt[t]||it[t]},t.cC=function(t,e,n){var r=e[0],i=e[1];return t[0]=n[0]*r+n[4]*i+n[12],t[1]=n[1]*r+n[5]*i+n[13],t},t.cD=function(t,e){const{x:n,y:r}=Zp.fromLngLat(e);return !(t<0||t>25||r<0||r>=1||n<0||n>=1)},t.cE=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},t.cF=class extends co{},t.cG=pt,t.cH=function(t,e){ut.REGISTERED_PROTOCOLS[t]=e;},t.cI=function(t){delete ut.REGISTERED_PROTOCOLS[t];},t.cJ=function(t,e){const n={};for(let r=0;r<t.length;r++){const i=e&&e[t[r].id]||Ai(t[r]);e&&(e[t[r].id]=i);let s=n[i];s||(s=n[i]=[]),s.push(t[r]);}const r=[];for(const t in n)r.push(n[t]);return r},t.cK=ds,t.cL=ef,t.cM=oy,t.cN=rp,t.cO=function(e){var n,r;e.bucket.createArrays(),e.bucket.tilePixelRatio=T/(512*e.bucket.overscaling),e.bucket.compareText={},e.bucket.iconsNeedLinear=!1;const i=e.bucket.layers[0],s=i.layout,o=i._unevaluatedLayout._values,a={layoutIconSize:o["icon-size"].possiblyEvaluate(new Cs(e.bucket.zoom+1),e.canonical),layoutTextSize:o["text-size"].possiblyEvaluate(new Cs(e.bucket.zoom+1),e.canonical),textMaxSize:o["text-size"].possiblyEvaluate(new Cs(18))};if("composite"===e.bucket.textSizeData.kind){const{minZoom:t,maxZoom:n}=e.bucket.textSizeData;a.compositeTextSizes=[o["text-size"].possiblyEvaluate(new Cs(t),e.canonical),o["text-size"].possiblyEvaluate(new Cs(n),e.canonical)];}if("composite"===e.bucket.iconSizeData.kind){const{minZoom:t,maxZoom:n}=e.bucket.iconSizeData;a.compositeIconSizes=[o["icon-size"].possiblyEvaluate(new Cs(t),e.canonical),o["icon-size"].possiblyEvaluate(new Cs(n),e.canonical)];}const l=s.get("text-line-height")*Ih,u="viewport"!==s.get("text-rotation-alignment")&&"point"!==s.get("symbol-placement"),c=s.get("text-keep-upright"),h=s.get("text-size");for(const o of e.bucket.features){const p=s.get("text-font").evaluate(o,{},e.canonical).join(","),f=h.evaluate(o,{},e.canonical),d=a.layoutTextSize.evaluate(o,{},e.canonical),y=a.layoutIconSize.evaluate(o,{},e.canonical),m={horizontal:{},vertical:void 0},g=o.text;let x,v=[0,0];if(g){const n=g.toString(),r=s.get("text-letter-spacing").evaluate(o,{},e.canonical)*Ih,a=Ms(n)?r:0,h=s.get("text-anchor").evaluate(o,{},e.canonical),y=Vy(i,o,e.canonical);if(!y){const t=s.get("text-radial-offset").evaluate(o,{},e.canonical);v=t?Cy(h,[t*Ih,By]):s.get("text-offset").evaluate(o,{},e.canonical).map((t=>t*Ih));}let x=u?"center":s.get("text-justify").evaluate(o,{},e.canonical);const b="point"===s.get("symbol-placement")?s.get("text-max-width").evaluate(o,{},e.canonical)*Ih:1/0,w=()=>{e.bucket.allowVerticalPlacement&&As(n)&&(m.vertical=sp(g,e.glyphMap,e.glyphPositions,e.imagePositions,p,b,l,h,"left",a,v,t.ax.vertical,!0,d,f));};if(!u&&y){const n=new Set;if("auto"===x)for(let t=0;t<y.values.length;t+=2)n.add(Ly(y.values[t]));else n.add(x);let r=!1;for(const i of n)if(!m.horizontal[i])if(r)m.horizontal[i]=m.horizontal[0];else {const n=sp(g,e.glyphMap,e.glyphPositions,e.imagePositions,p,b,l,"center",i,a,v,t.ax.horizontal,!1,d,f);n&&(m.horizontal[i]=n,r=1===n.positionedLines.length);}w();}else {"auto"===x&&(x=Ly(h));const r=sp(g,e.glyphMap,e.glyphPositions,e.imagePositions,p,b,l,h,x,a,v,t.ax.horizontal,!1,d,f);r&&(m.horizontal[x]=r),w(),As(n)&&u&&c&&(m.vertical=sp(g,e.glyphMap,e.glyphPositions,e.imagePositions,p,b,l,h,x,a,v,t.ax.vertical,!1,d,f));}}let b=!1;if(null===(n=o.icon)||void 0===n?void 0:n.name){const t=e.imageMap[o.icon.name];t&&(x=fp(e.imagePositions[o.icon.name],s.get("icon-offset").evaluate(o,{},e.canonical),s.get("icon-anchor").evaluate(o,{},e.canonical)),b=!!t.sdf,void 0===e.bucket.sdfIcons?e.bucket.sdfIcons=b:e.bucket.sdfIcons!==b&&G("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(t.pixelRatio!==e.bucket.pixelRatio||0!==s.get("icon-rotate").constantOr(1))&&(e.bucket.iconsNeedLinear=!0));}const w=Ry(m.horizontal)||m.vertical;(r=e.bucket).iconsInText||(r.iconsInText=!!w&&w.iconsInText),(w||x)&&Oy(e.bucket,o,m,x,e.imageMap,a,d,y,v,b,e.canonical,e.subdivisionGranularity);}e.showCollisionBoxes&&e.bucket.generateCollisionDebugBuffers();},t.cP=Iu,t.cQ=Gu,t.cR=ph,t.cS=function(t,e=""){const n=new Rh;return function(t,e,n=""){for(const r in t.layers)e.writeMessage(3,((t,e)=>Qd(t,e,n)),t.layers[r]);}(t,n,e),n.finish()},t.cT=function(t,e,n,r,i,s){let o=cy(t,e,n,i,0);return o=cy(o,e,r,s,1),o},t.cU=class{constructor(t){this.maxEntries=t,this.map=new Map;}get(t){const e=this.map.get(t);return void 0!==e&&(this.map.delete(t),this.map.set(t,e)),e}set(t,e){if(this.map.has(t))this.map.delete(t);else if(this.map.size>=this.maxEntries){const t=this.map.keys().next().value;this.map.delete(t);}this.map.set(t,e);}clear(){this.map.clear();}},t.cV=Nu,t.cW=Rh,t.cX=Wd,t.cY=function(t,n,r,i,s){return e(this,void 0,void 0,(function*(){if(h())try{return yield K(t,n,r,i,s)}catch(t){}return function(t,e,n,r,i){const s=t.width,o=t.height;J&&Q||(J=new OffscreenCanvas(s,o),Q=J.getContext("2d",{willReadFrequently:!0})),J.width=s,J.height=o,Q.drawImage(t,0,0,s,o);const a=Q.getImageData(e,n,r,i);return Q.clearRect(0,0,s,o),a.data}(t,n,r,i,s)}))},t.cZ=$l,t.c_=class{constructor(t,e){this.layers={[Jd]:this},this.name=Jd,this.version=e?e.version:1,this.extent=e?e.extent:4096,this.length=t.length,this.features=t;}feature(t){return new Kd(this.features[t],this.extent)}},t.ca=class extends So{},t.cb=Ah,t.cc=class extends Mo{},t.cd=Fl,t.ce=function(t){return t<=1?1:Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},t.cf=Tl,t.cg=function(t,e,n){var r=e[0],i=e[1],s=e[2],o=n[3]*r+n[7]*i+n[11]*s+n[15];return t[0]=(n[0]*r+n[4]*i+n[8]*s+n[12])/(o=o||1),t[1]=(n[1]*r+n[5]*i+n[9]*s+n[13])/o,t[2]=(n[2]*r+n[6]*i+n[10]*s+n[14])/o,t},t.ch=class extends ho{},t.ci=class extends Do{},t.cj=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]},t.ck=function(t,e){var n=t[0],r=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],u=t[7],c=t[8],h=t[9],f=t[10],d=t[11],y=t[12],m=t[13],g=t[14],x=t[15],v=e[0],b=e[1],w=e[2],_=e[3],S=e[4],A=e[5],M=e[6],k=e[7],I=e[8],E=e[9],T=e[10],F=e[11],P=e[12],D=e[13],z=e[14],B=e[15];return Math.abs(n-v)<=p*Math.max(1,Math.abs(n),Math.abs(v))&&Math.abs(r-b)<=p*Math.max(1,Math.abs(r),Math.abs(b))&&Math.abs(i-w)<=p*Math.max(1,Math.abs(i),Math.abs(w))&&Math.abs(s-_)<=p*Math.max(1,Math.abs(s),Math.abs(_))&&Math.abs(o-S)<=p*Math.max(1,Math.abs(o),Math.abs(S))&&Math.abs(a-A)<=p*Math.max(1,Math.abs(a),Math.abs(A))&&Math.abs(l-M)<=p*Math.max(1,Math.abs(l),Math.abs(M))&&Math.abs(u-k)<=p*Math.max(1,Math.abs(u),Math.abs(k))&&Math.abs(c-I)<=p*Math.max(1,Math.abs(c),Math.abs(I))&&Math.abs(h-E)<=p*Math.max(1,Math.abs(h),Math.abs(E))&&Math.abs(f-T)<=p*Math.max(1,Math.abs(f),Math.abs(T))&&Math.abs(d-F)<=p*Math.max(1,Math.abs(d),Math.abs(F))&&Math.abs(y-P)<=p*Math.max(1,Math.abs(y),Math.abs(P))&&Math.abs(m-D)<=p*Math.max(1,Math.abs(m),Math.abs(D))&&Math.abs(g-z)<=p*Math.max(1,Math.abs(g),Math.abs(z))&&Math.abs(x-B)<=p*Math.max(1,Math.abs(x),Math.abs(B))},t.cl=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},t.cm=t=>"circle"===t.type,t.cn=t=>"heatmap"===t.type,t.co=t=>"line"===t.type,t.cp=t=>"fill"===t.type,t.cq=t=>"fill-extrusion"===t.type,t.cr=t=>"hillshade"===t.type,t.cs=t=>"color-relief"===t.type,t.ct=t=>"background"===t.type,t.cu=t=>"custom"===t.type,t.cv=C,t.cw=function(t,e,n){if(e<=0)return t;const r=1/e;return void 0===n||Math.abs(n)<1e-10?Math.round(t*r)/r:(n>0?Math.ceil(t*r-1e-9):Math.floor(t*r+1e-10))/r},t.cx=function(t,e,n){const r=E(e.x-n.x,e.y-n.y),i=E(t.x-n.x,t.y-n.y);var s,o;return nt(Math.atan2(r[0]*i[1]-r[1]*i[0],(s=r)[0]*(o=i)[0]+s[1]*o[1]))},t.cy=V,t.cz=function(t,e){var n;if(!it[e])return !1;const r=null==t?void 0:t.target,i=(null===(n=null==r?void 0:r.ownerDocument)||void 0===n?void 0:n.defaultView)||window;return t instanceof i.MouseEvent||t instanceof i.WheelEvent},t.d=P,t.d0=class{constructor(t,e){const n=(e=this.options=Object.assign({},sh,e)).debug;if(n&&console.time("preprocess data"),e.maxZoom<0||e.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(e.promoteId&&e.generateId)throw new Error("promoteId and generateId cannot be used together.");let r=pc(t,e);n&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",e.indexMaxZoom,e.indexMaxPoints),console.time("generate tiles")),r=Lc(r,e),e.updateable&&(this.source=r),this.initializeIndex(r,e);}initializeIndex(t,e){this.tileIndex=e.cluster?new qc(e.clusterOptions):new rh(e),t.length&&this.tileIndex.initialize(t);}getTile(t,e,n){return e=+e,n=+n,(t=+t)<0||t>24?null:this.tileIndex.getTile(t,e,n)}updateData(t,e){const n=this.options;if(!n.updateable)throw new Error("to update tile geojson `updateable` option must be set to true");let{affected:r,source:i}=function(t,e,n){const r=function(t,e){return t?{removeAll:t.removeAll,remove:new Set(t.remove||[]),add:new Map(t.add?.map((t=>[e.promoteId?t.properties[e.promoteId]:t.id,t]))),update:new Map(t.update?.map((t=>[t.id,t])))}:{remove:new Set,add:new Map,update:new Map}}(e,n);let i=[];if(r.removeAll&&(i=t,t=[]),r.remove.size||r.add.size){const e=[];for(const n of t)(r.remove.has(n.id)||r.add.has(n.id))&&e.push(n);if(e.length){i.push(...e);const n=new Set(e.map((t=>t.id)));t=t.filter((t=>!n.has(t.id)));}if(r.add.size){let e=pc({type:"FeatureCollection",features:Array.from(r.add.values())},n);e=Lc(e,n),i.push(...e),t.push(...e);}}if(r.update.size){const e=new Map,s=[];for(const n of t)r.update.has(n.id)?e.set(n.id,[...e.get(n.id)||[],n]):s.push(n);for(const[t,o]of r.update){const r=e.get(t);if(!r||0===r.length)continue;const a=Nc(r,o,n);i.push(...r,...a),s.push(...a);}t=s;}return {affected:i,source:t}}(this.source,t,n);e&&({affected:r,source:i}=this.filterUpdate(i,r,e)),r.length&&(this.source=i,this.tileIndex.updateIndex(i,r,n));}filterUpdate(t,e,n){const r=new Set;for(const i of t)null!=i.id&&(n(xc(i))||(e.push(i),r.add(i.id)));return {affected:e,source:t=t.filter((t=>!r.has(t.id)))}}getData(){if(!this.options.updateable)throw new Error("to retrieve data the `updateable` option must be set to true");return {type:"FeatureCollection",features:this.source.map((t=>xc(t)))}}updateClusterOptions(t,e){const n=this.options.cluster;this.options.cluster=t,this.options.clusterOptions=e,n!=t?this.initializeIndex(this.source,this.options):this.tileIndex.updateIndex(this.source,[],this.options);}getClusterExpansionZoom(t){return this.tileIndex.getClusterExpansionZoom(t)}getClusterChildren(t){return this.tileIndex.getChildren(t)}getClusterLeaves(t,e,n){return this.tileIndex.getLeaves(t,e,n)}},t.d1=Bs,t.e=$,t.f=yt,t.g=ct,t.h=t=>e(void 0,void 0,void 0,(function*(){if(0===t.byteLength)return createImageBitmap(new ImageData(1,1));const e=new Blob([new Uint8Array(t)],{type:"image/png"});try{return createImageBitmap(e)}catch(t){throw new Error(`Could not load image because of ${P(t).message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}})),t.i=Y,t.j=t=>new Promise(((e,n)=>{const r=new Image;r.onload=()=>{e(r),URL.revokeObjectURL(r.src),r.onload=null,window.requestAnimationFrame((()=>r.src=W));},r.onerror=()=>n(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const i=new Blob([new Uint8Array(t)],{type:"image/png"});r.src=t.byteLength?URL.createObjectURL(i):W;})),t.k=(t,e)=>dt($(t,{type:"json"}),e),t.l=vt,t.m=dt,t.n=xt,t.o=(t,e)=>dt($(t,{type:"arrayBuffer"}),e),t.p=ep,t.q=function(t){return new Rh(t).readFields(Jh,[])},t.r=function(t){return /[\u02EA\u02EB\u1100-\u11FF\u2E80-\u2FDF\u3000-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE4F\uFF00-\uFFEF]|\uD81B[\uDFE0-\uDFFF]|[\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFB]|\uD83C[\uDE00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(t))},t.s=tt,t.t=kl,t.u=Ks,t.v=ss,t.w=G,t.x=wt,t.y=Rs,t.z=as;})); define("worker",["./shared"],(function(e){"use strict";class t{constructor(e,t){this.keyCache={},e&&this.replace(e,t);}replace(e,t){this._layerConfigs={},this._layers={},this.update(e,[],t);}update(t,i,s){for(const i of t){this._layerConfigs[i.id]=i;const t=this._layers[i.id]=e.bT(i,s);t._featureFilter=e.ah(t.filter,s),this.keyCache[i.id]&&delete this.keyCache[i.id];}for(const e of i)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const r=e.cJ(Object.values(this._layerConfigs),this.keyCache);for(const t of r){const i=t.map((e=>this._layers[e.id])),s=i[0];if(s.isHidden())continue;const r=s.source||"";let o=this.familiesBySource[r];o||(o=this.familiesBySource[r]={});const n=s.sourceLayer||e.ag;let a=o[n];a||(a=o[n]=[]),a.push(i);}}}class i{constructor(t){const i={},s=[];for(const e in t){const r=t[e],o=i[e]={};for(const e in r){const t=r[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const i={x:0,y:0,w:t.bitmap.width+2,h:t.bitmap.height+2};s.push(i),o[e]={rect:i,metrics:t.metrics};}}const{w:r,h:o}=e.p(s),n=new e.t({width:r||1,height:o||1});for(const s in t){const r=t[s];for(const t in r){const o=r[+t];if(!o||0===o.bitmap.width||0===o.bitmap.height)continue;const a=i[s][t].rect;e.t.copy(o.bitmap,n,{x:0,y:0},{x:a.x+1,y:a.y+1},o.bitmap);}}this.image=n,this.positions=i;}}e.cK("GlyphAtlas",i);class s{constructor(t){this.tileID=new e.a3(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.uid=t.uid,this.zoom=t.zoom,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.collectResourceTiming,this.returnDependencies=!!t.returnDependencies,this.promoteId=t.promoteId,this.inFlightDependencies=[];}parse(t,s,o,n,a){return e._(this,void 0,void 0,(function*(){this.status="parsing",this.data=t,this.collisionBoxArray=new e.ae;const l=new e.cL(Object.keys(t.layers).sort()),c=new e.cM(this.tileID,this.promoteId);c.bucketLayerIDs=[];const h={},d={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},dashDependencies:{},availableImages:o,subdivisionGranularity:a},u=s.familiesBySource[this.source];for(const i in u){const s=t.layers[i];if(!s)continue;1===s.version&&e.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const n=l.encode(i),a=[];for(let e=0;e<s.length;e++){const t=s.feature(e),r=c.getId(t,i);a.push({feature:t,id:r,index:e,sourceLayerIndex:n});}for(const t of u[i]){const i=t[0];i.source!==this.source&&e.w(`layer.source = ${i.source} does not equal this.source = ${this.source}`),i.isHidden(this.zoom,!0)||(r(t,this.zoom,o),(h[i.id]=i.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:n,sourceID:this.source})).populate(a,d,this.tileID.canonical),c.bucketLayerIDs.push(t.map((e=>e.id))));}}const g=e.bY(d.glyphDependencies,(e=>Object.keys(e).map(Number)));for(const e of this.inFlightDependencies)null==e||e.abort();this.inFlightDependencies=[];let p=Promise.resolve({});if(Object.keys(g).length){const e=new AbortController;this.inFlightDependencies.push(e),p=n.sendAsync({type:"GG",data:{stacks:g,source:this.source,tileID:this.tileID,type:"glyphs"}},e);}const f=Object.keys(d.iconDependencies);let y=Promise.resolve({});if(f.length){const e=new AbortController;this.inFlightDependencies.push(e),y=n.sendAsync({type:"GI",data:{icons:f,source:this.source,tileID:this.tileID,type:"icons"}},e);}const v=Object.keys(d.patternDependencies);let m=Promise.resolve({});if(v.length){const e=new AbortController;this.inFlightDependencies.push(e),m=n.sendAsync({type:"GI",data:{icons:v,source:this.source,tileID:this.tileID,type:"patterns"}},e);}const _=d.dashDependencies;let S=Promise.resolve({});if(Object.keys(_).length){const e=new AbortController;this.inFlightDependencies.push(e),S=n.sendAsync({type:"GDA",data:{dashes:_}},e);}const[w,b,I,T]=yield Promise.all([p,y,m,S]),k=new i(w),x=new e.cN(b,I);for(const t in h){const i=h[t];i instanceof e.af?(r(i.layers,this.zoom,o),e.cO({bucket:i,glyphMap:w,glyphPositions:k.positions,imageMap:b,imagePositions:x.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:d.subdivisionGranularity})):i.hasDependencies&&(i instanceof e.cP||i instanceof e.cQ||i instanceof e.cR)&&(r(i.layers,this.zoom,o),i.addFeatures(d,this.tileID.canonical,x.patternPositions,T));}return this.status="done",{buckets:Object.values(h).filter((e=>!e.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:k.image,imageAtlas:x,dashPositions:T,glyphMap:this.returnDependencies?w:null,iconMap:this.returnDependencies?b:null,glyphPositions:this.returnDependencies?k.positions:null}}))}}function r(t,i,s){const r=new e.J(i);for(const e of t)e.recalculate(r,s);}class o{constructor(){this.loading={},this.loaded={},this.parsing={};}startLoading(e,t){this.loading[e]=t;}finishLoading(e){delete this.loading[e];}abort(e){const t=this.loading[e];(null==t?void 0:t.abort)&&(t.abort.abort(),delete this.loading[e]);}setParsing(e,t){this.parsing[e]=t;}consumeParsing(e){const t=this.parsing[e];if(t)return delete this.parsing[e],t}clearParsing(e){delete this.parsing[e];}markLoaded(e,t){this.loaded[e]=t;}getLoaded(e){const t=this.loaded[e];if(t)return t}removeLoaded(e){delete this.loaded[e];}clearLoaded(){this.loaded={};}}class n{constructor(e){this.start=`${e}#start`,this.end=`${e}#end`,this.measure=e,performance.mark(this.start);}finish(){performance.mark(this.end);let e=performance.getEntriesByName(this.measure);return 0===e.length&&(performance.measure(this.measure,this.start,this.end),e=performance.getEntriesByName(this.measure),performance.clearMarks(this.start),performance.clearMarks(this.end),performance.clearMeasures(this.measure)),e}}class a{constructor(e,t,i,s,r){this.type=e,this.properties=i||{},this.extent=r,this.pointsArray=t,this.id=s;}loadGeometry(){return this.pointsArray.map((t=>t.map((t=>new e.P(t.x,t.y)))))}}class l{constructor(e,t,i){this.version=2,this._myFeatures=e,this.name=t,this.length=e.length,this.extent=i;}feature(e){return this._myFeatures[e]}}class c{constructor(){this.layers={};}addLayer(e){this.layers[e.name]=e;}}function h(t){let i=e.cS(t);return 0===i.byteOffset&&i.byteLength===i.buffer.byteLength||(i=new Uint8Array(i)),{vectorTile:t,rawData:i.buffer}}function d(t,i,s){const{extent:r}=t,o=Math.pow(2,s.z-i.z),n=(s.x-i.x*o)*r,c=(s.y-i.y*o)*r,h=[];for(let i=0;i<t.length;i++){const s=t.feature(i);let l=s.loadGeometry();for(const e of l)for(const t of e)t.x=t.x*o-n,t.y=t.y*o-c;const d=128;l=e.cT(l,s.type,-d,-d,r+d,r+d),0!==l.length&&h.push(new a(s.type,l,s.properties,s.id,r));}return new l(h,t.name,r)}class u{constructor(t,i,s){this.actor=t,this.layerIndex=i,this.availableImages=s,this.tileState=new o,this.overzoomedTileResultCache=new e.cU(1e3);}loadVectorTile(t,i){try{return {vectorTile:"mlt"!==t.encoding?new e.cV(new e.cW(i)):new e.cX(i),rawData:i}}catch(s){const r=new Uint8Array(i);let o=`Unable to parse the tile at ${t.request.url}, `;throw o+=31===r[0]&&139===r[1]?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${e.d(s).message}`,new Error(o)}}loadTile(t){return e._(this,void 0,void 0,(function*(){const{uid:i,overzoomParameters:r}=t;r&&(t.request=r.overzoomRequest);const o=this._startRequestTiming(t),n=new s(t);this.tileState.startLoading(i,n);const a=new AbortController;n.abort=a;try{const s=yield e.o(t.request,a);if(t.etag&&t.etag===s.etag)return this.tileState.finishLoading(i),this._getEtagUnmodifiedResult(s,o);const l=this.loadVectorTile(t,s.data);if(this.tileState.finishLoading(i),!l)return null;let{vectorTile:c,rawData:h}=l;r&&({vectorTile:c,rawData:h}=this._getOverzoomTile(t,c));const d=this._getExpiryData(s),u=this._finishRequestTiming(o);n.vectorTile=c,this.tileState.markLoaded(i,n);const g={rawData:h,cacheControl:d,resourceTiming:u};this.tileState.setParsing(i,g);try{return yield this._parseWorkerTile(n,t,g)}finally{this.tileState.clearParsing(i);}}catch(e){throw this.tileState.finishLoading(i),n.status="done",this.tileState.markLoaded(i,n),e}}))}_getEtagUnmodifiedResult(t,i){const s=this._getExpiryData(t),r=this._finishRequestTiming(i);return e.e({etagUnmodified:!0},s,r)}_parseWorkerTile(t,i,s){return e._(this,void 0,void 0,(function*(){let r=yield t.parse(t.vectorTile,this.layerIndex,this.availableImages,this.actor,i.subdivisionGranularity);if(s){const{rawData:t,cacheControl:o,resourceTiming:n}=s;r=e.e({rawTileData:t.slice(0),encoding:i.encoding},r,o,n);}return r}))}_getExpiryData({expires:e,cacheControl:t,etag:i}){const s={};return e&&(s.expires=e),t&&(s.cacheControl=t),i&&(s.etag=i),s}_startRequestTiming(e){var t;if(null===(t=e.request)||void 0===t?void 0:t.collectResourceTiming)return new n(e.request.url)}_finishRequestTiming(e){const t=null==e?void 0:e.finish();return t?{resourceTiming:JSON.parse(JSON.stringify(t))}:{}}_getOverzoomTile(e,t){var i;const{tileID:s,source:r,overzoomParameters:o}=e,{maxZoomTileID:n}=o,a=`${n.key}_${s.key}_${null===(i=e.request)||void 0===i?void 0:i.url}`,l=this.overzoomedTileResultCache.get(a);if(l)return l;const u=new c,g=this.layerIndex.familiesBySource[r];for(const e in g){const i=t.layers[e];if(!i)continue;const r=d(i,n,s.canonical);r.length>0&&u.addLayer(r);}const p=h(u);return this.overzoomedTileResultCache.set(a,p),p}reloadTile(t){return e._(this,void 0,void 0,(function*(){const e=t.uid,i=this.tileState.getLoaded(e);if(!i)throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");if(i.showCollisionBoxes=t.showCollisionBoxes,"parsing"===i.status){const s=this.tileState.consumeParsing(e);return yield this._parseWorkerTile(i,t,s)}if("done"===i.status&&i.vectorTile)return yield this._parseWorkerTile(i,t)}))}abortTile(t){return e._(this,void 0,void 0,(function*(){this.tileState.abort(t.uid);}))}removeTile(t){return e._(this,void 0,void 0,(function*(){this.tileState.removeLoaded(t.uid);}))}}class g{constructor(){this.loaded={};}loadTile(t){return e._(this,void 0,void 0,(function*(){const{uid:i,encoding:s,rawImageData:r,redFactor:o,greenFactor:n,blueFactor:a,baseShift:l}=t,c=r.width+2,h=r.height+2,d=e.b(r)?new e.R({width:c,height:h},yield e.cY(r,-1,-1,c,h)):r,u=new e.cZ(i,d,s,o,n,a,l);return this.loaded||(this.loaded={}),this.loaded[i]=u,u}))}removeTile(e){const t=this.loaded,i=e.uid;(null==t?void 0:t[i])&&delete t[i];}}class p{constructor(e,t,i,s=f){this.actor=e,this.layerIndex=t,this.availableImages=i,this.tileState=new o,this._createGeoJSONIndex=s;}loadVectorTile(t){if(!this._geoJSONIndex)throw new Error("Unable to parse the data into a cluster or geojson");const{z:i,x:s,y:r}=t.tileID.canonical,o=this._geoJSONIndex.getTile(i,s,r);return o?h(new e.c_(o.features,{version:2,extent:e.a6})):null}loadTile(t){return e._(this,void 0,void 0,(function*(){const{uid:e}=t,i=new s(t);i.abort=new AbortController;try{const s=this.loadVectorTile(t);if(!s)return null;const{vectorTile:r,rawData:o}=s;i.vectorTile=r,this.tileState.markLoaded(e,i);const n={rawData:o};this.tileState.setParsing(e,n);try{return yield this._parseWorkerTile(i,t,n)}finally{this.tileState.clearParsing(e);}}catch(t){throw i.status="done",this.tileState.markLoaded(e,i),t}}))}_reloadLoadedTile(t){return e._(this,void 0,void 0,(function*(){const e=t.uid,i=this.tileState.getLoaded(e);if(!i)throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");if(i.showCollisionBoxes=t.showCollisionBoxes,"parsing"===i.status){const s=this.tileState.consumeParsing(e);return yield this._parseWorkerTile(i,t,s)}if("done"===i.status&&i.vectorTile)return yield this._parseWorkerTile(i,t)}))}_parseWorkerTile(t,i,s){return e._(this,void 0,void 0,(function*(){let r=yield t.parse(t.vectorTile,this.layerIndex,this.availableImages,this.actor,i.subdivisionGranularity);if(s){const{rawData:t}=s;r=e.e({rawTileData:t.slice(0),encoding:"mvt"},r);}return r}))}abortTile(t){return e._(this,void 0,void 0,(function*(){this.tileState.abort(t.uid);}))}removeTile(t){return e._(this,void 0,void 0,(function*(){this.tileState.removeLoaded(t.uid);}))}loadData(t){return e._(this,void 0,void 0,(function*(){var i;null===(i=this._pendingRequest)||void 0===i||i.abort();const s=this._startRequestTiming(t);this._pendingRequest=new AbortController;try{yield this.loadAndProcessGeoJSON(t,this._pendingRequest),delete this._pendingRequest,this.tileState.clearLoaded();const e={};return t.request&&(e.data=t.data),this._finishRequestTiming(s,t,e),e}catch(t){if(delete this._pendingRequest,!e.$(t))throw t;return {abandoned:!0}}}))}_startRequestTiming(e){var t;if(null===(t=e.request)||void 0===t?void 0:t.collectResourceTiming)return new n(e.request.url)}_finishRequestTiming(e,t,i){const s=null==e?void 0:e.finish();s&&(i.resourceTiming={[t.source]:JSON.parse(JSON.stringify(s))});}reloadTile(e){return this.tileState.getLoaded(e.uid)?this._reloadLoadedTile(e):this.loadTile(e)}loadAndProcessGeoJSON(t,i){return e._(this,void 0,void 0,(function*(){var s;if(t.request&&(t.data=(yield e.k(t.request,i)).data),t.data)return t.data=this._filterGeoJSON(t.data,t.filter),void(this._geoJSONIndex=this._createGeoJSONIndex(t.data,t));if(t.dataDiff)return null!==(s=this._geoJSONIndex)&&void 0!==s||(this._geoJSONIndex=this._createGeoJSONIndex({type:"FeatureCollection",features:[]},t)),void this._geoJSONIndex.updateData(t.dataDiff,this._getFilterPredicate(t.filter));if(t.updateCluster&&this._geoJSONIndex.updateClusterOptions(t.geojsonVtOptions.cluster,y(t)),null==this._geoJSONIndex)throw new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`)}))}_filterGeoJSON(e,t){if("FeatureCollection"!==e.type)return e;const i=this._getFilterPredicate(t);return i?{type:"FeatureCollection",features:e.features.filter((e=>i(e)))}:e}_getFilterPredicate(t){if("boolean"!=typeof t&&!(null==t?void 0:t.length))return;const i=e.c$(t,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===i.result)throw new Error(i.value.map((e=>`${e.key}: ${e.message}`)).join(", "));return e=>i.value.evaluate({zoom:0},e)}removeSource(t){return e._(this,void 0,void 0,(function*(){var e;null===(e=this._pendingRequest)||void 0===e||e.abort();}))}getClusterExpansionZoom(e){return this._geoJSONIndex.getClusterExpansionZoom(e.clusterId)}getClusterChildren(e){return this._geoJSONIndex.getClusterChildren(e.clusterId)}getClusterLeaves(e){return this._geoJSONIndex.getClusterLeaves(e.clusterId,e.limit,e.offset)}}function f(t,i){const s=e.e(i.geojsonVtOptions||{},{updateable:!0,clusterOptions:y(i)});return new e.d0(t,s)}function y({geojsonVtOptions:t,clusterProperties:i}){if(!i||!t.clusterOptions)return t.clusterOptions;const s={},r={},o={accumulated:null,zoom:0},n={properties:null},a=Object.keys(i);for(const t of a){const[o,n]=i[t],a=e.c$(n),l=e.c$("string"==typeof o?[o,["accumulated"],["get",t]]:o);s[t]=a.value,r[t]=l.value;}return t.clusterOptions.map=e=>{n.properties=e;const t={};for(const e of a)t[e]=s[e].evaluate(o,n);return t},t.clusterOptions.reduce=(e,t)=>{n.properties=t;for(const t of a)o.accumulated=e[t],e[t]=r[t].evaluate(o,n);},t.clusterOptions}class v{constructor(t){this.self=t,this.actor=new e.N(t),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.globalStates=new Map,this.self.registerWorkerSource=(e,t)=>{if(this.externalWorkerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.externalWorkerSourceTypes[e]=t;},this.self.addProtocol=e.cH,this.self.removeProtocol=e.cI,this.self.registerRTLTextPlugin=t=>{e.d1.setMethods(t);},this.self.makeRequest=e.m,this.actor.registerMessageHandler("LDT",((e,t)=>this._getDEMWorkerSource(e,t.source).loadTile(t))),this.actor.registerMessageHandler("RDT",((t,i)=>e._(this,void 0,void 0,(function*(){this._getDEMWorkerSource(t,i.source).removeTile(i);})))),this.actor.registerMessageHandler("GCEZ",((t,i)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(t,i.type,i.source).getClusterExpansionZoom(i)})))),this.actor.registerMessageHandler("GCC",((t,i)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(t,i.type,i.source).getClusterChildren(i)})))),this.actor.registerMessageHandler("GCL",((t,i)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(t,i.type,i.source).getClusterLeaves(i)})))),this.actor.registerMessageHandler("LD",((e,t)=>this._getWorkerSource(e,t.type,t.source).loadData(t))),this.actor.registerMessageHandler("LT",((e,t)=>this._getWorkerSource(e,t.type,t.source).loadTile(t))),this.actor.registerMessageHandler("RT",((e,t)=>this._getWorkerSource(e,t.type,t.source).reloadTile(t))),this.actor.registerMessageHandler("AT",((e,t)=>this._getWorkerSource(e,t.type,t.source).abortTile(t))),this.actor.registerMessageHandler("RMT",((e,t)=>this._getWorkerSource(e,t.type,t.source).removeTile(t))),this.actor.registerMessageHandler("RS",((t,i)=>e._(this,void 0,void 0,(function*(){var e,s;if(!(null===(s=null===(e=this.workerSources[t])||void 0===e?void 0:e[i.type])||void 0===s?void 0:s[i.source]))return;const r=this.workerSources[t][i.type][i.source];delete this.workerSources[t][i.type][i.source],void 0!==r.removeSource&&r.removeSource(i);})))),this.actor.registerMessageHandler("RM",(t=>e._(this,void 0,void 0,(function*(){delete this.layerIndexes[t],delete this.availableImages[t],delete this.workerSources[t],delete this.demWorkerSources[t],this.globalStates.delete(t);})))),this.actor.registerMessageHandler("SR",((t,i)=>e._(this,void 0,void 0,(function*(){this.referrer=i;})))),this.actor.registerMessageHandler("SRPS",((e,t)=>this._syncRTLPluginState(e,t))),this.actor.registerMessageHandler("IS",((t,i)=>e._(this,void 0,void 0,(function*(){this.self.importScripts(i);})))),this.actor.registerMessageHandler("SI",((e,t)=>this._setImages(e,t))),this.actor.registerMessageHandler("UL",((t,i)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(t).update(i.layers,i.removedIds,this._getGlobalState(t));})))),this.actor.registerMessageHandler("UGS",((t,i)=>e._(this,void 0,void 0,(function*(){const e=this._getGlobalState(t);for(const t in i)e[t]=i[t];})))),this.actor.registerMessageHandler("SL",((t,i)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(t).replace(i,this._getGlobalState(t));}))));}_getGlobalState(e){let t=this.globalStates.get(e);return t||(t={},this.globalStates.set(e,t)),t}_setImages(t,i){return e._(this,void 0,void 0,(function*(){this.availableImages[t]=i;for(const e in this.workerSources[t]){const s=this.workerSources[t][e];for(const e in s)s[e].availableImages=i;}}))}_syncRTLPluginState(t,i){return e._(this,void 0,void 0,(function*(){return yield e.d1.syncState(i,this.self.importScripts)}))}_getAvailableImages(e){let t=this.availableImages[e];return t||(t=[]),t}_getLayerIndex(e){let i=this.layerIndexes[e];return i||(i=this.layerIndexes[e]=new t),i}_getWorkerSource(e,t,i){var s,r;if((s=this.workerSources)[e]||(s[e]={}),(r=this.workerSources[e])[t]||(r[t]={}),!this.workerSources[e][t][i]){const s={sendAsync:(t,i)=>(t.targetMapId=e,this.actor.sendAsync(t,i))};switch(t){case "vector":this.workerSources[e][t][i]=new u(s,this._getLayerIndex(e),this._getAvailableImages(e));break;case "geojson":this.workerSources[e][t][i]=new p(s,this._getLayerIndex(e),this._getAvailableImages(e));break;default:this.workerSources[e][t][i]=new this.externalWorkerSourceTypes[t](s,this._getLayerIndex(e),this._getAvailableImages(e));}}return this.workerSources[e][t][i]}_getDEMWorkerSource(e,t){var i,s;return (i=this.demWorkerSources)[e]||(i[e]={}),(s=this.demWorkerSources[e])[t]||(s[t]=new g),this.demWorkerSources[e][t]}}return e.i(self)&&(self.worker=new v(self)),v})); define("index",["exports","./shared"],(function(e,t){"use strict";var i="5.24.0";function o(){var e=new t.A(4);return t.A!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}let a,r,s;const n={frame(e,i,o,a){const r=a||window,s=r.requestAnimationFrame((e=>{n(),i(e);})),{unsubscribe:n}=t.s(e.signal,"abort",(()=>{n(),r.cancelAnimationFrame(s),o(new t.a(e.signal.reason));}),!1);},frameAsync(e,t){return new Promise(((i,o)=>{this.frame(e,i,o,t);}))},getImageData(e,t=0){return this.getImageCanvasContext(e).getImageData(-t,-t,e.width+2*t,e.height+2*t)},getImageCanvasContext(e){const t=window.document.createElement("canvas"),i=t.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("failed to create canvas 2d context");return t.width=e.width,t.height=e.height,i.drawImage(e,0,0,e.width,e.height),i},resolveURL:e=>(a||(a=document.createElement("a")),a.href=e,a.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return void 0!==s?s:!!matchMedia&&(null!=r||(r=matchMedia("(prefers-reduced-motion: reduce)")),r.matches)},set prefersReducedMotion(e){s=e;}},l=new class{constructor(){this._frozenAt=null;}getCurrentTime(){return null!==this._frozenAt?this._frozenAt:performance.now()}setNow(e){this._frozenAt=e;}restoreNow(){this._frozenAt=null;}isFrozen(){return null!==this._frozenAt}};function c(){return l.getCurrentTime()}var h,u;class d{static create(e,t,i){const o=window.document.createElement(e);return void 0!==t&&(o.className=t),i&&i.appendChild(o),o}static createNS(e,t){return window.document.createElementNS(e,t)}static disableDrag(){d.docStyle&&d.selectProp&&(d.userSelect=d.docStyle[d.selectProp],d.docStyle[d.selectProp]="none");}static enableDrag(){d.docStyle&&d.selectProp&&(d.docStyle[d.selectProp]=d.userSelect);}static suppressClickInternal(e){e.preventDefault(),e.stopPropagation(),window.removeEventListener("click",d.suppressClickInternal,!0);}static suppressClick(){window.addEventListener("click",d.suppressClickInternal,!0),window.setTimeout((()=>{window.removeEventListener("click",d.suppressClickInternal,!0);}),0);}static getScale(e){const t=e.getBoundingClientRect();return {x:t.width/e.offsetWidth||1,y:t.height/e.offsetHeight||1,boundingClientRect:t}}static getPoint(e,i,o){const a=i.boundingClientRect;return new t.P((o.clientX-a.left)/i.x-e.clientLeft,(o.clientY-a.top)/i.y-e.clientTop)}static mousePos(e,t){const i=d.getScale(e);return d.getPoint(e,i,t)}static touchPos(e,t){const i=[],o=d.getScale(e);for(const a of t)i.push(d.getPoint(e,o,a));return i}static sanitize(e){const t=(new DOMParser).parseFromString(e,"text/html").body||document.createElement("body"),i=t.querySelectorAll("script");for(const e of i)e.remove();return d.clean(t),t.innerHTML}static isPossiblyDangerous(e,t){const i=t.replace(/\s+/g,"").toLowerCase();return !(!["src","href","xlink:href"].includes(e)||!i.includes("javascript:")&&!i.includes("data:"))||!!e.startsWith("on")||void 0}static clean(e){const t=e.children;for(const e of t)d.removeAttributes(e),d.clean(e);}static removeAttributes(e){for(const{name:t,value:i}of e.attributes)d.isPossiblyDangerous(t,i)&&e.removeAttribute(t);}}d.docStyle="undefined"!=typeof window&&(null===(h=window.document)||void 0===h?void 0:h.documentElement.style),d.selectProp=!d.docStyle||"userSelect"in d.docStyle?"userSelect":"webkitUserSelect",function(e){let i,o,a,r;e.resetRequestQueue=()=>{i=[],o=0,a=0,r={};},e.addThrottleControl=e=>{const t=a++;return r[t]=e,t},e.removeThrottleControl=e=>{delete r[e],n();},e.getImage=(e,o,a=!0)=>new Promise(((r,s)=>{e.headers||(e.headers={}),e.headers.accept="image/webp,*/*",t.e(e,{type:"image"}),i.push({abortController:o,requestParameters:e,supportImageRefresh:a,state:"queued",onError:e=>{s(e);},onSuccess:e=>{r(e);}}),n();}));const s=e=>t._(this,void 0,void 0,(function*(){e.state="running";const{requestParameters:i,supportImageRefresh:a,onError:r,onSuccess:s,abortController:c}=e,h=!1===a&&!t.i(self)&&!t.g(i.url)&&(!i.headers||Object.keys(i.headers).reduce(((e,t)=>e&&"accept"===t),!0));o++;const u=h?l(i,c):t.m(i,c);try{const i=yield u;delete e.abortController,e.state="completed",i.data instanceof HTMLImageElement||t.b(i.data)?s(i):i.data&&s({data:yield(d=i.data,"function"==typeof createImageBitmap?t.h(d):t.j(d)),cacheControl:i.cacheControl,expires:i.expires});}catch(i){delete e.abortController,r(t.d(i));}finally{o--,n();}var d;})),n=()=>{const e=(()=>{for(const e of Object.keys(r))if(r[e]())return !0;return !1})()?t.c.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:t.c.MAX_PARALLEL_IMAGE_REQUESTS;for(let t=o;t<e&&i.length>0;t++){const e=i.shift();e.abortController.signal.aborted?t--:s(e);}},l=(e,i)=>new Promise(((o,a)=>{const r=new Image,s=e.url,n=e.credentials;n&&"include"===n?r.crossOrigin="use-credentials":(n&&"same-origin"===n||!t.f(s))&&(r.crossOrigin="anonymous"),i.signal.addEventListener("abort",(()=>{r.src="",a(new t.a(i.signal.reason));})),r.fetchPriority="high",r.onload=()=>{r.onerror=r.onload=null,o({data:r});},r.onerror=()=>{r.onerror=r.onload=null,i.signal.aborted||a(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));},r.src=s;}));}(u||(u={})),u.resetRequestQueue();class _{constructor(e){this._transformRequestFn=null!=e?e:null;}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}setTransformRequest(e){this._transformRequestFn=e;}}function p(e){const t=[];if("string"==typeof e)t.push({id:"default",url:e});else if(e&&e.length>0){const i=[];for(const{id:o,url:a}of e){const e=`${o}${a}`;i.includes(e)||(i.push(e),t.push({id:o,url:a}));}}return t}function m(e,t,i){try{const o=new URL(e);return o.pathname+=`${t}${i}`,o.toString()}catch(t){throw new Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}function f(e){const{userImage:t}=e;return !(!(null==t?void 0:t.render)||!t.render()||(e.data.replace(new Uint8Array(t.data.buffer)),0))}class g extends t.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new t.R({width:1,height:1}),this.dirty=!0;}destroy(){this.atlasTexture&&(this.atlasTexture.destroy(),this.atlasTexture=null);for(const e of Object.keys(this.images))this.removeImage(e);this.patterns={},this.atlasImage=new t.R({width:1,height:1}),this.dirty=!0;}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:e,promiseResolve:t}of this.requestors)t(this._getImagesForIds(e));this.requestors=[];}}getImage(e){const i=this.images[e];if(i&&!i.data&&i.spriteData){const e=i.spriteData;i.data=new t.R({width:e.width,height:e.height},e.context.getImageData(e.x,e.y,e.width,e.height).data),i.spriteData=null;}return i}addImage(e,t){if(this.images[e])throw new Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,t)&&(this.images[e]=t);}_validate(e,i){let o=!0;const a=i.data||i.spriteData;return this._validateStretch(i.stretchX,null==a?void 0:a.width)||(this.fire(new t.l(new Error(`Image "${e}" has invalid "stretchX" value`))),o=!1),this._validateStretch(i.stretchY,null==a?void 0:a.height)||(this.fire(new t.l(new Error(`Image "${e}" has invalid "stretchY" value`))),o=!1),this._validateContent(i.content,i)||(this.fire(new t.l(new Error(`Image "${e}" has invalid "content" value`))),o=!1),o}_validateStretch(e,t){if(!e)return !0;let i=0;for(const o of e){if(o[0]<i||o[1]<o[0]||t<o[1])return !1;i=o[1];}return !0}_validateContent(e,t){if(!e)return !0;if(4!==e.length)return !1;const i=t.spriteData,o=(null==i?void 0:i.width)||t.data.width,a=(null==i?void 0:i.height)||t.data.height;return !(e[0]<0||o<e[0]||e[1]<0||a<e[1]||e[2]<0||o<e[2]||e[3]<0||a<e[3]||e[2]<e[0]||!(e[3]>=e[1]))}updateImage(e,t,i=!0){const o=this.getImage(e);if(i&&(o.data.width!==t.data.width||o.data.height!==t.data.height))throw new Error(`size mismatch between old image (${o.data.width}x${o.data.height}) and new image (${t.data.width}x${t.data.height}).`);t.version=o.version+1,this.images[e]=t,this.updatedImages[e]=!0;}removeImage(e){var t;const i=this.images[e];delete this.images[e],delete this.patterns[e],(null===(t=i.userImage)||void 0===t?void 0:t.onRemove)&&i.userImage.onRemove();}listImages(){return Object.keys(this.images)}getImages(e){return new Promise(((t,i)=>{let o=!0;if(!this.isLoaded())for(const t of e)this.images[t]||(o=!1);this.isLoaded()||o?t(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:t});}))}_getImagesForIds(e){var i;const o={};for(const a of e){let e=this.getImage(a);e||(this.fire(new t.n("styleimagemissing",{id:a})),e=this.getImage(a)),e?o[a]={data:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,version:e.version,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,textFitWidth:e.textFitWidth,textFitHeight:e.textFitHeight,hasRenderCallback:Boolean(null===(i=e.userImage)||void 0===i?void 0:i.render)}:t.w(`Image "${a}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`);}return o}getPixelSize(){const{width:e,height:t}=this.atlasImage;return {width:e,height:t}}getPattern(e){const i=this.patterns[e],o=this.getImage(e);if(!o)return null;if(i&&i.position.version===o.version)return i.position;if(i)i.position.version=o.version;else {const i={w:o.data.width+2,h:o.data.height+2,x:0,y:0},a=new t.I(i,o);this.patterns[e]={bin:i,position:a};}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const i=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new t.T(e,this.atlasImage,i.RGBA),this.atlasTexture.bind(i.LINEAR,i.CLAMP_TO_EDGE);}_updatePatternAtlas(){const e=[];for(const t in this.patterns)e.push(this.patterns[t].bin);const{w:i,h:o}=t.p(e),a=this.atlasImage;a.resize({width:i||1,height:o||1});for(const e in this.patterns){const{bin:i}=this.patterns[e],o=i.x+1,r=i.y+1,s=this.getImage(e).data,n=s.width,l=s.height;t.R.copy(s,a,{x:0,y:0},{x:o,y:r},{width:n,height:l}),t.R.copy(s,a,{x:0,y:l-1},{x:o,y:r-1},{width:n,height:1}),t.R.copy(s,a,{x:0,y:0},{x:o,y:r+l},{width:n,height:1}),t.R.copy(s,a,{x:n-1,y:0},{x:o-1,y:r},{width:1,height:l}),t.R.copy(s,a,{x:0,y:0},{x:o+n,y:r},{width:1,height:l});}this.dirty=!0;}beginFrame(){this.callbackDispatchedThisFrame={};}dispatchRenderCallbacks(e){for(const i of e){if(this.callbackDispatchedThisFrame[i])continue;this.callbackDispatchedThisFrame[i]=!0;const e=this.getImage(i);e||t.w(`Image with ID: "${i}" was not found`),f(e)&&this.updateImage(i,e);}}cloneImages(){const e={};for(const t in this.images){const i=this.images[t];e[t]=Object.assign(Object.assign({},i),{data:i.data?i.data.clone():null});}return e}}const v=1e20,x=new Float64Array(256);for(let e=0;e<256;e++){const t=.5-Math.pow(e/255,1/2.2);x[e]=t*Math.abs(t);}function b(e,t,i,o,a,r,s,n,l){for(let c=t;c<t+o;c++)y(e,i*r+c,r,a,s,n,l);for(let c=i;c<i+a;c++)y(e,c*r+t,1,o,s,n,l);}function y(e,t,i,o,a,r,s){r[0]=0,s[0]=-v,s[1]=v,a[0]=e[t];for(let n=1,l=0,c=0;n<o;n++){a[n]=e[t+n*i];const o=n*n;do{const e=r[l];c=(a[n]-a[e]+o-e*e)/(n-e)/2;}while(c<=s[l]&&--l>-1);l++,r[l]=n,s[l]=c,s[l+1]=v;}for(let n=0,l=0;n<o;n++){for(;s[l+1]<n;)l++;const o=r[l],c=n-o;e[t+n*i]=a[o]+c*c;}}x[255]=-v;const w=t.v.layout_symbol["text-font"].default.join(",");class T{constructor(e,t,i){this.requestManager=e,this.localIdeographFontFamily=t,this.entries={},this.lang=i;}setURL(e){this.url=e;}getGlyphs(e){return t._(this,void 0,void 0,(function*(){const t=[];for(const i in e)for(const o of e[i])t.push(this._getAndCacheGlyphsPromise(i,o));const i=yield Promise.all(t),o={};for(const{stack:e,id:t,glyph:a}of i)o[e]||(o[e]={}),o[e][t]=a&&{id:a.id,bitmap:a.bitmap.clone(),metrics:a.metrics};return o}))}_getAndCacheGlyphsPromise(e,i){return t._(this,void 0,void 0,(function*(){var t,o;null!==(t=(o=this.entries)[e])&&void 0!==t||(o[e]={glyphs:{},requests:{},ranges:{}});const a=this.entries[e];let r=a.glyphs[i];return void 0!==r?{stack:e,id:i,glyph:r}:!this.url||this._charUsesLocalIdeographFontFamily(i)?(r=a.glyphs[i]=this._drawGlyph(a,e,i),{stack:e,id:i,glyph:r}):yield this._downloadAndCacheRangePromise(e,i)}))}_downloadAndCacheRangePromise(e,i){return t._(this,void 0,void 0,(function*(){var o;const a=this.entries[e],r=Math.floor(i/256);if(a.ranges[r])return {stack:e,id:i,glyph:null};(o=a.requests)[r]||(o[r]=T.loadGlyphRange(e,r,this.url,this.requestManager));try{const t=yield a.requests[r];for(const e in t)a.glyphs[+e]=t[+e];return a.ranges[r]=!0,{stack:e,id:i,glyph:t[i]||null}}catch(o){const s=a.glyphs[i]=this._drawGlyph(a,e,i);return this._warnOnMissingGlyphRange(s,r,i,t.d(o)),{stack:e,id:i,glyph:s}}}))}_warnOnMissingGlyphRange(e,i,o,a){const r=256*i,s=r+255,n=o.toString(16).padStart(4,"0").toUpperCase();t.w(`Unable to load glyph range ${i}, ${r}-${s}. Rendering codepoint U+${n} locally instead. ${a}`);}_charUsesLocalIdeographFontFamily(e){return !!this.localIdeographFontFamily&&t.r(e)}_drawGlyph(e,i,o){const a=i===w&&""!==this.localIdeographFontFamily&&this._charUsesLocalIdeographFontFamily(o),r=a?"ideographTinySDF":"tinySDF";e[r]||(e[r]=this._createTinySDF(a?this.localIdeographFontFamily:i));const s=e[r].draw(String.fromCodePoint(o)),n=/^\p{gc=Cf}+$/u.test(String.fromCodePoint(o));return {id:o,bitmap:new t.t({width:s.width||60,height:s.height||60},s.data),metrics:{width:n?0:s.glyphWidth/2||24,height:s.glyphHeight/2||24,left:s.glyphLeft/2+.5||0,top:s.glyphTop/2-27.5||-8,advance:n?0:s.glyphAdvance/2||24,isDoubleResolution:!0}}}_createTinySDF(e){const t=e?e.split(","):[];t.push("sans-serif");const i=t.map((e=>/[-\w]+/.test(e)?e:`'${CSS.escape(e)}'`)).join(",");return new T.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:i,fontWeight:this._fontWeight(t[0]),fontStyle:this._fontStyle(t[0]),lang:this.lang})}_fontStyle(e){return /italic/i.test(e)?"italic":/oblique/i.test(e)?"oblique":"normal"}_fontWeight(e){const t={thin:100,hairline:100,"extra light":200,"ultra light":200,light:300,normal:400,regular:400,medium:500,semibold:600,demibold:600,bold:700,"extra bold":800,"ultra bold":800,black:900,heavy:900,"extra black":950,"ultra black":950};let i;for(const[o,a]of Object.entries(t))new RegExp(`\\b${o}\\b`,"i").test(e)&&(i=`${a}`);return i}destroy(){for(const e in this.entries){const t=this.entries[e];t.tinySDF=null,t.ideographTinySDF=null,t.glyphs={},t.requests={},t.ranges={};}this.entries={};}}T.loadGlyphRange=function(e,i,o,a){return t._(this,void 0,void 0,(function*(){const r=256*i,s=r+255,n=yield a.transformRequest(o.replace("{fontstack}",e).replace("{range}",`${r}-${s}`),"Glyphs"),l=yield t.o(n,new AbortController);if(!(null==l?void 0:l.data))throw new Error(`Could not load glyph range. range: ${i}, ${r}-${s}`);const c={};for(const e of t.q(l.data))c[e.id]=e;return c}))},T.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:o=.25,fontFamily:a="sans-serif",fontWeight:r="normal",fontStyle:s="normal",lang:n=null}={}){this.buffer=t,this.radius=i,this.cutoff=o,this.lang=n;const l=this.size=e+4*t,c=this._createCanvas(l),h=this.ctx=c.getContext("2d",{willReadFrequently:!0});h.font=`${s} ${r} ${e}px ${a}`,h.textBaseline="alphabetic",h.textAlign="left",h.fillStyle="black",this.gridOuter=new Float64Array(l*l),this.gridInner=new Float64Array(l*l),this.f=new Float64Array(l),this.z=new Float64Array(l+1),this.v=new Uint16Array(l);}_createCanvas(e){if("undefined"!=typeof OffscreenCanvas)return new OffscreenCanvas(e,e);const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:i,actualBoundingBoxDescent:o,actualBoundingBoxLeft:a,actualBoundingBoxRight:r}=this.ctx.measureText(e),s=Math.ceil(i),n=Math.floor(a),l=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(r)-n)),c=Math.max(0,Math.min(this.size-this.buffer,s+Math.ceil(o))),h=l+2*this.buffer,u=c+2*this.buffer,d=Math.max(h*u,0),_=new Uint8ClampedArray(d),p={data:_,width:h,height:u,glyphWidth:l,glyphHeight:c,glyphTop:s,glyphLeft:n,glyphAdvance:t};if(0===l||0===c)return p;const{ctx:m,buffer:f,gridInner:g,gridOuter:y}=this;this.lang&&(m.lang=this.lang),m.clearRect(f,f,l,c),m.fillText(e,f-n,f+s);const w=m.getImageData(f,f,l,c);y.fill(v,0,d),g.fill(0,0,d);let T=3;for(let e=0;e<c;e++){let t=(e+f)*h+f;for(let e=0;e<l;e++,T+=4,t++){const e=w.data[T];if(0===e)continue;const i=x[e];y[t]=Math.max(0,i),g[t]=Math.max(0,-i);}}b(y,0,0,h,u,h,this.f,this.v,this.z),b(g,f,f,l,c,h,this.f,this.v,this.z);const P=255/this.radius,C=255*(1-this.cutoff);for(let e=0;e<d;e++){const t=Math.sqrt(y[e])-Math.sqrt(g[e]);_[e]=Math.round(C-P*t);}return p}};class P{constructor(){this.specification=t.x.light.position;}possiblyEvaluate(e,i){return t.G(e.expression.evaluate(i))}interpolate(e,i,o){return {x:t.H.number(e.x,i.x,o),y:t.H.number(e.y,i.y,o),z:t.H.number(e.z,i.z,o)}}}let C;class M extends t.E{constructor(e){super(),C||(C=new t.u({anchor:new t.D(t.x.light.anchor),position:new P,color:new t.D(t.x.light.color),intensity:new t.D(t.x.light.intensity)})),this._transitionable=new t.y(C,void 0),this.setLight(e),this._transitioning=this._transitionable.untransitioned();}getLight(){return this._transitionable.serialize()}setLight(e,i={}){if(!this._validate(t.z,e,i))for(const i in e){const o=e[i];i.endsWith(t.B)?this._transitionable.setTransition(i.slice(0,-t.B.length),o):this._transitionable.setValue(i,o);}}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}_validate(e,i,o){return !1!==(null==o?void 0:o.validate)&&t.C(this,e.call(t.F,{value:i,style:{glyphs:!0,sprite:!0},styleSpec:t.x}))}}const I=new t.u({"sky-color":new t.D(t.x.sky["sky-color"]),"horizon-color":new t.D(t.x.sky["horizon-color"]),"fog-color":new t.D(t.x.sky["fog-color"]),"fog-ground-blend":new t.D(t.x.sky["fog-ground-blend"]),"horizon-fog-blend":new t.D(t.x.sky["horizon-fog-blend"]),"sky-horizon-blend":new t.D(t.x.sky["sky-horizon-blend"]),"atmosphere-blend":new t.D(t.x.sky["atmosphere-blend"])});class E extends t.E{constructor(e){super(),this._transitionable=new t.y(I,void 0),this.setSky(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new t.J(0));}setSky(e,i={}){if(!this._validate(t.K,e,i)){e||(e={"sky-color":"transparent","horizon-color":"transparent","fog-color":"transparent","fog-ground-blend":1,"atmosphere-blend":0});for(const i in e){const o=e[i];i.endsWith(t.B)?this._transitionable.setTransition(i.slice(0,-t.B.length),o):this._transitionable.setValue(i,o);}}}getSky(){return this._transitionable.serialize()}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}_validate(e,i,o={}){return !1!==(null==o?void 0:o.validate)&&t.C(this,e.call(t.F,t.e({value:i,style:{glyphs:!0,sprite:!0},styleSpec:t.x})))}calculateFogBlendOpacity(e){return e<60?0:e<70?(e-60)/10:1}}class S{constructor(e,t){this.width=e,this.height=t,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={};}getDash(e,t){var i;const o=e.join(",")+String(t);return (i=this.dashEntry)[o]||(i[o]=this.addDash(e,t)),this.dashEntry[o]}getDashRanges(e,t,i){const o=[];let a=e.length%2==1?-e[e.length-1]*i:0,r=e[0]*i,s=!0;o.push({left:a,right:r,isDash:s,zeroLength:0===e[0]});let n=e[0];for(let t=1;t<e.length;t++){s=!s;const l=e[t];a=n*i,n+=l,r=n*i,o.push({left:a,right:r,isDash:s,zeroLength:0===l});}return o}addRoundDash(e,t,i){const o=t/2;for(let t=-i;t<=i;t++){const a=this.width*(this.nextRow+i+t);let r=0,s=e[r];for(let n=0;n<this.width;n++){n/s.right>1&&(s=e[++r]);const l=Math.abs(n-s.left),c=Math.abs(n-s.right),h=Math.min(l,c);let u;const d=t/i*(o+1);if(s.isDash){const e=o-Math.abs(d);u=Math.sqrt(h*h+e*e);}else u=o-Math.sqrt(h*h+d*d);this.data[a+n]=Math.max(0,Math.min(255,u+128));}}}addRegularDash(e){for(let t=e.length-1;t>=0;--t){const i=e[t],o=e[t+1];i.zeroLength?e.splice(t,1):o&&o.isDash===i.isDash&&(o.left=i.left,e.splice(t,1));}const t=e[0],i=e[e.length-1];t.isDash===i.isDash&&(t.left=i.left-this.width,i.right=t.right+this.width);const o=this.width*this.nextRow;let a=0,r=e[a];for(let t=0;t<this.width;t++){t/r.right>1&&(r=e[++a]);const i=Math.abs(t-r.left),s=Math.abs(t-r.right),n=Math.min(i,s);this.data[o+t]=Math.max(0,Math.min(255,(r.isDash?n:-n)+128));}}addDash(e,i){const o=i?7:0,a=2*o+1;if(this.nextRow+a>this.height)return t.w("LineAtlas out of space"),null;let r=0;for(const t of e)r+=t;if(0!==r){const t=this.width/r,a=this.getDashRanges(e,this.width,t);i?this.addRoundDash(a,t,o):this.addRegularDash(a);}const s={y:this.nextRow+o,height:2*o,width:r};return this.nextRow+=a,this.dirty=!0,s}bind(e){const t=e.gl;this.texture?(t.bindTexture(t.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,t.texSubImage2D(t.TEXTURE_2D,0,0,0,this.width,this.height,t.ALPHA,t.UNSIGNED_BYTE,this.data))):(this.texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this.texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texImage2D(t.TEXTURE_2D,0,t.ALPHA,this.width,this.height,0,t.ALPHA,t.UNSIGNED_BYTE,this.data));}}const z="maplibre_preloaded_worker_pool";class R{constructor(){this.active={};}acquire(e){if(!this.workers)for(this.workers=[];this.workers.length<R.workerCount;)this.workers.push(new Worker(t.c.WORKER_URL));return this.active[e]=!0,this.workers.slice()}release(e){if(delete this.active[e],0===this.numActive()){for(const e of this.workers)e.terminate();this.workers=null;}}isPreloaded(){return !!this.active[z]}numActive(){return Object.keys(this.active).length}}const D=Math.floor(n.hardwareConcurrency/2);let A,L;function F(){return A||(A=new R),A}R.workerCount=t.L(globalThis)?Math.max(Math.min(D,3),1):1;class k{constructor(e,i){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=i;const o=this.workerPool.acquire(i);for(let e=0;e<o.length;e++){const a=new t.N(o[e],i);a.name=`Worker ${e}`,this.actors.push(a);}if(!this.actors.length)throw new Error("No actors found")}broadcast(e,t){const i=[];for(const o of this.actors)i.push(o.sendAsync({type:e,data:t}));return Promise.all(i)}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(e=!0){for(const e of this.actors)e.remove();this.actors=[],e&&this.workerPool.release(this.id);}registerMessageHandler(e,t){for(const i of this.actors)i.registerMessageHandler(e,t);}unregisterMessageHandler(e){for(const t of this.actors)t.unregisterMessageHandler(e);}}function B(){return L||(L=new k(F(),t.M),L.registerMessageHandler("GR",((e,i,o)=>t.m(i,o)))),L}function O(e,i){const o=t.O();return t.Q(o,o,[1,1,0]),t.S(o,o,[.5*e.width,.5*e.height,1]),e.calculatePosMatrix?t.U(o,o,e.calculatePosMatrix(i.toUnwrapped())):o}function j(e,t,i,o,a,r,s){var n;const l=function(e,t,i){if(e)for(const o of e){const e=t[o];if((null==e?void 0:e.source)===i&&"fill-extrusion"===e.type)return !0}else for(const e in t){const o=t[e];if(o.source===i&&"fill-extrusion"===o.type)return !0}return !1}(null!==(n=null==a?void 0:a.layers)&&void 0!==n?n:null,t,e.id),c=r.maxPitchScaleFactor(),h=e.tilesIn(o,c,l);h.sort(N);const u=[];for(const o of h)u.push({wrappedTileID:o.tileID.wrapped().key,queryResults:o.tile.queryRenderedFeatures(t,i,e.getState(),o.queryGeometry,o.cameraQueryGeometry,o.scale,a,r,c,O(r,o.tileID),s?(e,t)=>s(o.tileID,e,t):void 0)});return function(e,t){for(const i in e)for(const o of e[i])Z(o,t);return e}(function(e){const t={},i={};for(const{queryResults:o,wrappedTileID:a}of e){i[a]||(i[a]={});const e=i[a];for(const i in o){const a=o[i];e[i]||(e[i]={});const r=e[i];t[i]||(t[i]=[]);for(const e of a)r[e.featureIndex]||(r[e.featureIndex]=!0,t[i].push(e));}}return t}(u),e)}function N(e,t){const i=e.tileID,o=t.tileID;return i.overscaledZ-o.overscaledZ||i.canonical.y-o.canonical.y||i.wrap-o.wrap||i.canonical.x-o.canonical.x}function Z(e,t){const i=e.feature,o=t.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=o;}function U(e,i,o,a){return t._(this,void 0,void 0,(function*(){let r=e;if(e.url?r=(yield t.k(yield i.transformRequest(e.url,"Source"),o)).data:yield n.frameAsync(o,a),!r)return null;const s=t.V(t.e(r,e),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return "vector_layers"in r&&r.vector_layers&&(s.vectorLayerIds=r.vector_layers.map((e=>e.id))),s}))}class G{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):Array.isArray(e)&&(4===e.length?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1])));}setNorthEast(e){return this._ne=e instanceof t.W?new t.W(e.lng,e.lat):t.W.convert(e),this}setSouthWest(e){return this._sw=e instanceof t.W?new t.W(e.lng,e.lat):t.W.convert(e),this}extend(e){const i=this._sw,o=this._ne;let a,r;if(e instanceof t.W)a=e,r=e;else {if(!(e instanceof G))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(G.convert(e)):this.extend(t.W.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(t.W.convert(e)):this;if(a=e._sw,r=e._ne,!a||!r)return this}return i||o?(i.lng=Math.min(a.lng,i.lng),i.lat=Math.min(a.lat,i.lat),o.lng=Math.max(r.lng,o.lng),o.lat=Math.max(r.lat,o.lat)):(this._sw=new t.W(a.lng,a.lat),this._ne=new t.W(r.lng,r.lat)),this}getCenter(){return new t.W((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new t.W(this.getWest(),this.getNorth())}getSouthEast(){return new t.W(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return [this._sw.toArray(),this._ne.toArray()]}toString(){return `LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return !(this._sw&&this._ne)}contains(e){const{lng:i,lat:o}=t.W.convert(e);let a=this._sw.lng<=i&&i<=this._ne.lng;return this._sw.lng>this._ne.lng&&(a=this._sw.lng>=i&&i>=this._ne.lng),this._sw.lat<=o&&o<=this._ne.lat&&a}intersects(e){if(!((e=G.convert(e)).getNorth()>=this.getSouth()&&e.getSouth()<=this.getNorth()))return !1;const i=Math.abs(this.getEast()-this.getWest()),o=Math.abs(e.getEast()-e.getWest());if(i>=360||o>=360)return !0;const a=t.X(this.getWest(),-180,180),r=t.X(this.getEast(),-180,180),s=t.X(e.getWest(),-180,180),n=t.X(e.getEast(),-180,180),l=a>r,c=s>n;return !(!l||!c)||(l?n>=a||s<=r:c?r>=s||a<=n:s<=r&&n>=a)}static convert(e){return e instanceof G?e:e?new G(e):e}static fromLngLat(e,i=0){const o=360*i/40075017,a=o/Math.cos(Math.PI/180*e.lat);return new G(new t.W(e.lng-a,e.lat-o),new t.W(e.lng+a,e.lat+o))}adjustAntiMeridian(){const e=new t.W(this._sw.lng,this._sw.lat),i=new t.W(this._ne.lng,this._ne.lat);return new G(e,e.lng>i.lng?new t.W(i.lng+360,i.lat):i)}}class V{constructor(e,t,i){this.bounds=G.convert(this.validateBounds(e)),this.minzoom=t||0,this.maxzoom=i||24;}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){const i=Math.pow(2,e.z),o=Math.floor(t.Z(this.bounds.getWest())*i),a=Math.floor(t.Y(this.bounds.getNorth())*i),r=Math.ceil(t.Z(this.bounds.getEast())*i),s=Math.ceil(t.Y(this.bounds.getSouth())*i);return e.x>=o&&e.x<r&&e.y>=a&&e.y<s}}class W extends t.E{constructor(e,i,o,a){if(super(),this.id=e,this.dispatcher=o,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,t.e(this,t.V(i,["url","scheme","tileSize","promoteId","encoding"])),this._options=t.e({type:"vector"},i),this._collectResourceTiming=i.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(a);}load(){return t._(this,arguments,void 0,(function*(e=!1){this._loaded=!1,this.fire(new t.n("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const i=yield U(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,i&&(t.e(this,i),i.bounds&&(this.tileBounds=new V(i.bounds,this.minzoom,this.maxzoom)),this.fire(new t.n("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.n("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:e})));}catch(e){this._tileJSONRequest=null,this._loaded=!0,t.$(e)||this.fire(new t.l(t.d(e)));}}))}loaded(){return this._loaded}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load();}setSourceProperty(e){this._tileJSONRequest&&this._tileJSONRequest.abort(),e(),this.load(!0);}setTiles(e){return this.setSourceProperty((()=>{this._options.tiles=e;})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e;})),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null);}serialize(){return t.e({},this._options)}loadTile(e){return t._(this,void 0,void 0,(function*(){const t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),i={request:yield this.map._requestManager.transformRequest(t,"Tile"),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity,encoding:this.encoding,overzoomParameters:yield this._getOverzoomParameters(e),etag:e.etag};i.request.collectResourceTiming=this._collectResourceTiming;let o="RT";if(e.actor&&"expired"!==e.state){if("loading"===e.state)return new Promise(((t,i)=>{e.reloadPromise={resolve:t,reject:i};}))}else e.actor=this.dispatcher.getActor(),o="LT";e.abortController=new AbortController;try{const t=yield e.actor.sendAsync({type:o,data:i},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,t);const a={};return (null==t?void 0:t.etagUnmodified)&&(a.unmodified=!0),a}catch(t){if(delete e.abortController,e.aborted)return;if(t&&404!==t.status)throw t;this._afterTileLoadWorkerResponse(e,null);}}))}_getOverzoomParameters(e){return t._(this,void 0,void 0,(function*(){if(e.tileID.canonical.z<=this.maxzoom)return;if(void 0===this.map._zoomLevelsToOverscale)return;const t=e.tileID.scaledTo(this.maxzoom).canonical,i=t.url(this.tiles,this.map.getPixelRatio(),this.scheme);return {maxZoomTileID:t,overzoomRequest:yield this.map._requestManager.transformRequest(i,"Tile")}}))}_afterTileLoadWorkerResponse(e,t){if((null==t?void 0:t.resourceTiming)&&(e.resourceTiming=t.resourceTiming),t&&this.map._refreshExpiredTiles&&e.setExpiryData(t),e.etag=null==t?void 0:t.etag,e.loadVectorData(t,this.map.painter),e.reloadPromise){const t=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(t.resolve).catch(t.reject);}}abortTile(e){return t._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.actor&&(yield e.actor.sendAsync({type:"AT",data:{uid:e.uid,type:this.type,source:this.id}}));}))}unloadTile(e){return t._(this,void 0,void 0,(function*(){e.unloadVectorData(),e.actor&&(yield e.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}}));}))}hasTransition(){return !1}}class q extends t.E{constructor(e,i,o,a){super(),this.id=e,this.dispatcher=o,this.setEventedParent(a),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=t.e({type:"raster"},i),t.e(this,t.V(i,["url","scheme","tileSize"]));}load(){return t._(this,arguments,void 0,(function*(e=!1){this._loaded=!1,this.fire(new t.n("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const i=yield U(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,i&&(t.e(this,i),i.bounds&&(this.tileBounds=new V(i.bounds,this.minzoom,this.maxzoom)),this.fire(new t.n("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.n("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:e})));}catch(e){this._tileJSONRequest=null,this._loaded=!0,t.$(e)||this.fire(new t.l(t.d(e)));}}))}loaded(){return this._loaded}onAdd(e){this.map=e,this.load();}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null);}setSourceProperty(e){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),e(),this.load(!0);}setTiles(e){return this.setSourceProperty((()=>{this._options.tiles=e;})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e;})),this}serialize(){return t.e({},this._options)}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return t._(this,void 0,void 0,(function*(){const i=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{const o=yield u.getImage(yield this.map._requestManager.transformRequest(i,"Tile"),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(null==o?void 0:o.data){this.map._refreshExpiredTiles&&(o.cacheControl||o.expires)&&e.setExpiryData({cacheControl:o.cacheControl,expires:o.expires});const i=this.map.painter.context,a=i.gl,r=o.data;e.texture=this.map.painter.getTileTexture(r.width),e.texture?e.texture.update(r,{useMipmap:!0}):(e.texture=new t.T(i,r,a.RGBA,{useMipmap:!0}),e.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE,a.LINEAR_MIPMAP_NEAREST)),e.state="loaded";}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}}))}abortTile(e){return t._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController);}))}unloadTile(e){return t._(this,void 0,void 0,(function*(){e.texture&&this.map.painter.saveTileTexture(e.texture);}))}hasTransition(){return !1}}class $ extends q{constructor(e,i,o,a){super(e,i,o,a),this.type="raster-dem",this.maxzoom=22,this._options=t.e({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox",this.redFactor=i.redFactor,this.greenFactor=i.greenFactor,this.blueFactor=i.blueFactor,this.baseShift=i.baseShift;}loadTile(e){return t._(this,void 0,void 0,(function*(){const i=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),o=yield this.map._requestManager.transformRequest(i,"Tile");e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{const i=yield u.getImage(o,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(null==i?void 0:i.data){const o=i.data;this.map._refreshExpiredTiles&&(i.cacheControl||i.expires)&&e.setExpiryData({cacheControl:i.cacheControl,expires:i.expires});const a=t.b(o)&&t.a0()?o:yield this.readImageNow(o),r={type:this.type,uid:e.uid,source:this.id,rawImageData:a,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(e.actor&&"expired"!==e.state&&"reloading"!==e.state)return;e.actor&&"expired"!==e.state||(e.actor=this.dispatcher.getActor()),e.dem=yield e.actor.sendAsync({type:"LDT",data:r}),e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded";}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}}))}readImageNow(e){return t._(this,void 0,void 0,(function*(){if("undefined"!=typeof VideoFrame&&t.a1()){const i=e.width+2,o=e.height+2;try{return new t.R({width:i,height:o},yield t.a2(e,-1,-1,i,o))}catch(e){}}return n.getImageData(e,1)}))}_getNeighboringTiles(e){const i=e.canonical,o=Math.pow(2,i.z),a=(i.x-1+o)%o,r=0===i.x?e.wrap-1:e.wrap,s=(i.x+1+o)%o,n=i.x+1===o?e.wrap+1:e.wrap,l={};return l[new t.a3(e.overscaledZ,r,i.z,a,i.y).key]={backfilled:!1},l[new t.a3(e.overscaledZ,n,i.z,s,i.y).key]={backfilled:!1},i.y>0&&(l[new t.a3(e.overscaledZ,r,i.z,a,i.y-1).key]={backfilled:!1},l[new t.a3(e.overscaledZ,e.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new t.a3(e.overscaledZ,n,i.z,s,i.y-1).key]={backfilled:!1}),i.y+1<o&&(l[new t.a3(e.overscaledZ,r,i.z,a,i.y+1).key]={backfilled:!1},l[new t.a3(e.overscaledZ,e.wrap,i.z,i.x,i.y+1).key]={backfilled:!1},l[new t.a3(e.overscaledZ,n,i.z,s,i.y+1).key]={backfilled:!1}),l}unloadTile(e){return t._(this,void 0,void 0,(function*(){e.demTexture&&this.map.painter.saveTileTexture(e.demTexture),e.fbo&&(e.fbo.destroy(),delete e.fbo),e.dem&&delete e.dem,delete e.neighboringTiles,e.state="unloaded",e.actor&&(yield e.actor.sendAsync({type:"RDT",data:{type:this.type,uid:e.uid,source:this.id}}));}))}}function H(e,t){return t?e.properties[t]:e.id}function X(e,t){const i={id:e.id};if(t.removeAllProperties&&(delete e.removeProperties,delete e.addOrUpdateProperties,delete t.removeProperties),t.removeProperties)for(const i of t.removeProperties){const t=e.addOrUpdateProperties.findIndex((e=>e.key===i));t>-1&&e.addOrUpdateProperties.splice(t,1);}return (e.removeAllProperties||t.removeAllProperties)&&(i.removeAllProperties=!0),(e.removeProperties||t.removeProperties)&&(i.removeProperties=[...e.removeProperties||[],...t.removeProperties||[]]),(e.addOrUpdateProperties||t.addOrUpdateProperties)&&(i.addOrUpdateProperties=[...e.addOrUpdateProperties||[],...t.addOrUpdateProperties||[]]),(e.newGeometry||t.newGeometry)&&(i.newGeometry=t.newGeometry||e.newGeometry),i}function K(e){var t,i;if(!e)return {};const o={};return o.removeAll=e.removeAll,o.remove=new Set(e.remove||[]),o.add=new Map(null===(t=e.add)||void 0===t?void 0:t.map((e=>[e.id,e]))),o.update=new Map(null===(i=e.update)||void 0===i?void 0:i.map((e=>[e.id,e]))),o}function Y(e){return e&&0!==e.length?"number"==typeof e[0]?[e]:e.flatMap((e=>Y(e))):[]}function Q(e){return "GeometryCollection"===e.type?e.geometries.flatMap((e=>Q(e))):Y(e.coordinates)}function J(e){const t=new G;let i;switch(e.type){case "FeatureCollection":i=e.features.flatMap((e=>Q(e.geometry)));break;case "Feature":i=Q(e.geometry);break;default:i=Q(e);}if(0===i.length)return t;for(const e of i){const[i,o]=e;t.extend([i,o]);}return t}class ee extends t.E{constructor(e,i,o,a){super(),this.id=e,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._removed=!1,this._isUpdatingWorker=!1,this._pendingWorkerUpdate={data:i.data},this.actor=o.getActor(),this.setEventedParent(a),this._data="string"==typeof i.data?{url:i.data}:{geojson:i.data},this._options=t.e({},i),this._collectResourceTiming=i.collectResourceTiming,void 0!==i.maxzoom&&(this.maxzoom=i.maxzoom),i.type&&(this.type=i.type),i.attribution&&(this.attribution=i.attribution),this.promoteId=i.promoteId,void 0!==i.clusterMaxZoom&&this.maxzoom<=i.clusterMaxZoom&&t.w(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${i.clusterMaxZoom}".`),this.workerOptions=t.e({source:this.id,geojsonVtOptions:{buffer:this._pixelsToTileUnits(void 0!==i.buffer?i.buffer:128),tolerance:this._pixelsToTileUnits(void 0!==i.tolerance?i.tolerance:.375),extent:t.a6,maxZoom:this.maxzoom,lineMetrics:i.lineMetrics||!1,generateId:i.generateId||!1,promoteId:"string"==typeof i.promoteId?i.promoteId:void 0,cluster:i.cluster||!1,clusterOptions:{maxZoom:this._getClusterMaxZoom(i.clusterMaxZoom),minPoints:Math.max(2,i.clusterMinPoints||2),extent:t.a6,radius:this._pixelsToTileUnits(i.clusterRadius||50),log:!1,generateId:i.generateId||!1}},clusterProperties:i.clusterProperties,filter:i.filter},i.workerOptions);}_hasPendingWorkerUpdate(){return void 0!==this._pendingWorkerUpdate.data||void 0!==this._pendingWorkerUpdate.diff||this._pendingWorkerUpdate.updateCluster}_pixelsToTileUnits(e){return e*(t.a6/this.tileSize)}_getClusterMaxZoom(e){const i=e?Math.round(e):this.maxzoom-1;return Number.isInteger(e)||void 0===e||t.w(`Integer expected for option 'clusterMaxZoom': provided value "${e}" rounded to "${i}"`),i}load(){return t._(this,void 0,void 0,(function*(){yield this._updateWorkerData();}))}onAdd(e){this.map=e,this.load();}setData(e,t){this._data="string"==typeof e?{url:e}:{geojson:e},this._pendingWorkerUpdate={data:e};const i=this._updateWorkerData();return t?i:this}updateData(e,t){this._pendingWorkerUpdate.diff=function(e,t){if(!e)return t||{};if(!t)return e||{};const i=K(e),o=K(t);!function(e,t){t.removeAll&&(e.add.clear(),e.update.clear(),e.remove.clear(),t.remove.clear());for(const i of t.remove)e.add.delete(i),e.update.delete(i);for(const[i,o]of t.update){const a=e.update.get(i);a&&(t.update.set(i,X(a,o)),e.update.delete(i));}}(i,o);const a={};if((i.removeAll||o.removeAll)&&(a.removeAll=!0),a.remove=new Set([...i.remove,...o.remove]),a.add=new Map([...i.add,...o.add]),a.update=new Map([...i.update,...o.update]),a.remove.size&&a.add.size)for(const e of a.add.keys())a.remove.delete(e);return function(e){const t={};return e.removeAll&&(t.removeAll=e.removeAll),e.remove&&(t.remove=Array.from(e.remove)),e.add&&(t.add=Array.from(e.add.values())),e.update&&(t.update=Array.from(e.update.values())),t}(a)}(this._pendingWorkerUpdate.diff,e);const i=this._updateWorkerData();return t?i:this}getData(){return t._(this,void 0,void 0,(function*(){return this._data.url&&(yield this.once("data")),this._data.geojson?this._data.geojson:{type:"FeatureCollection",features:Array.from(this._data.updateable.values())}}))}getBounds(){return t._(this,void 0,void 0,(function*(){return J(yield this.getData())}))}setClusterOptions(e){return this.workerOptions.geojsonVtOptions.cluster=e.cluster,void 0!==e.clusterRadius&&(this.workerOptions.geojsonVtOptions.clusterOptions.radius=this._pixelsToTileUnits(e.clusterRadius)),void 0!==e.clusterMaxZoom&&(this.workerOptions.geojsonVtOptions.clusterOptions.maxZoom=this._getClusterMaxZoom(e.clusterMaxZoom)),this._pendingWorkerUpdate.updateCluster=!0,this._updateWorkerData(),this}getClusterExpansionZoom(e){return this.actor.sendAsync({type:"GCEZ",data:{type:this.type,clusterId:e,source:this.id}})}getClusterChildren(e){return this.actor.sendAsync({type:"GCC",data:{type:this.type,clusterId:e,source:this.id}})}getClusterLeaves(e,t,i){return this.actor.sendAsync({type:"GCL",data:{type:this.type,source:this.id,clusterId:e,limit:t,offset:i}})}_updateWorkerData(){return t._(this,void 0,void 0,(function*(){if(this._isUpdatingWorker)return;if(!this._hasPendingWorkerUpdate())return void t.w(`No pending worker updates for GeoJSONSource ${this.id}.`);const{data:e,diff:i,updateCluster:o}=this._pendingWorkerUpdate,a=this._getLoadGeoJSONParameters(e,i,o);void 0!==e?this._pendingWorkerUpdate.data=void 0:i?this._pendingWorkerUpdate.diff=void 0:o&&(this._pendingWorkerUpdate.updateCluster=void 0),yield this._dispatchWorkerUpdate(a);}))}_getLoadGeoJSONParameters(e,i,o){return t._(this,void 0,void 0,(function*(){const a=t.e({type:this.type},this.workerOptions);return "string"==typeof e?(a.request=yield this.map._requestManager.transformRequest(n.resolveURL(e),"Source"),a.request.collectResourceTiming=this._collectResourceTiming,a):void 0!==e?(a.data=e,a):i?(a.dataDiff=i,a):o?(a.updateCluster=!0,a):void 0}))}_dispatchWorkerUpdate(e){return t._(this,void 0,void 0,(function*(){this._isUpdatingWorker=!0,this.fire(new t.n("dataloading",{dataType:"source"}));try{const i=yield e,o=yield this.actor.sendAsync({type:"LD",data:i});if(this._isUpdatingWorker=!1,this._removed||o.abandoned)return void this.fire(new t.n("dataabort",{dataType:"source"}));o.data&&(this._data={geojson:o.data});const a=this._applyDiffToSource(i.dataDiff),r=this._getShouldReloadTileOptions(a),s={dataType:"source"};this._applyResourceTiming(s,o),this.fire(new t.n("data",Object.assign(Object.assign({},s),{sourceDataType:"metadata"}))),this.fire(new t.n("data",Object.assign(Object.assign({},s),{sourceDataType:"content",shouldReloadTileOptions:r})));}catch(e){if(this._isUpdatingWorker=!1,this._removed)return void this.fire(new t.n("dataabort",{dataType:"source"}));this.fire(new t.l(t.d(e)));}finally{this._hasPendingWorkerUpdate()&&this._updateWorkerData();}}))}_applyResourceTiming(e,i){var o;if(!this._collectResourceTiming)return;const a=null===(o=i.resourceTiming)||void 0===o?void 0:o[this.id];if(!a)return;const r=a.slice(0);(null==r?void 0:r.length)&&t.e(e,{resourceTiming:r});}_applyDiffToSource(e){if(!e)return;const t="string"==typeof this.promoteId?this.promoteId:void 0;if(!this._data.url&&!this._data.updateable){const e=function(e,t){const i=new Map;if(null==e)return i;if(null==e.type)return i;if("Feature"===e.type){const o=H(e,t);if(null==o)return;return i.set(o,e),i}if("FeatureCollection"===e.type){const o=new Set;for(const a of e.features){const e=H(a,t);if(null==e)return;if(o.has(e))return;o.add(e),i.set(e,a);}return i}}(this._data.geojson,t);if(!e)throw new Error(`GeoJSONSource "${this.id}": GeoJSON data is not compatible with updateData`);this._data={updateable:e};}if(!this._data.updateable)return;const i=function(e,t,i){var o,a;const r=[];if(t.removeAll)e.clear();else if(t.remove)for(const i of t.remove){const t=e.get(i);t&&(r.push(t.geometry),e.delete(i));}if(t.add)for(const o of t.add){const t=H(o,i);if(null==t)continue;const a=e.get(t);a&&r.push(a.geometry),r.push(o.geometry),e.set(t,o);}if(t.update)for(const i of t.update){const t=e.get(i.id);if(!t)continue;const s=!!i.newGeometry,n=i.removeAllProperties||(null===(o=i.removeProperties)||void 0===o?void 0:o.length)>0||(null===(a=i.addOrUpdateProperties)||void 0===a?void 0:a.length)>0;if(!s&&!n)continue;r.push(t.geometry);const l=Object.assign({},t);if(e.set(i.id,l),s&&(r.push(i.newGeometry),l.geometry=i.newGeometry),n){if(l.properties=i.removeAllProperties?{}:Object.assign({},l.properties||{}),i.removeProperties)for(const e of i.removeProperties)delete l.properties[e];if(i.addOrUpdateProperties)for(const{key:e,value:t}of i.addOrUpdateProperties)l.properties[e]=t;}}return r}(this._data.updateable,e,t);return e.removeAll||this._options.cluster?void 0:i}_getShouldReloadTileOptions(e){if(e)return {affectedBounds:e.filter(Boolean).map((e=>J(e)))}}shouldReloadTile(e,{affectedBounds:i}){if("loading"===e.state)return !0;if("unloaded"===e.state)return !1;const{buffer:o,extent:a}=this.workerOptions.geojsonVtOptions,r=function({x:e,y:i,z:o},a=0){const r=t.a4((e-a)/Math.pow(2,o)),s=t.a5((i+1+a)/Math.pow(2,o)),n=t.a4((e+1+a)/Math.pow(2,o)),l=t.a5((i-a)/Math.pow(2,o));return new G([r,s],[n,l])}(e.tileID.canonical,o/a);for(const e of i)if(r.intersects(e))return !0;return !1}loaded(){return !this._isUpdatingWorker&&!this._hasPendingWorkerUpdate()}loadTile(e){return t._(this,void 0,void 0,(function*(){const t=e.actor?"RT":"LT";e.actor=this.actor;const i={type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};e.abortController=new AbortController;const o=yield this.actor.sendAsync({type:t,data:i},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(o,this.map.painter,"RT"===t);}))}abortTile(e){return t._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0;}))}unloadTile(e){return t._(this,void 0,void 0,(function*(){e.unloadVectorData(),yield this.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}});}))}onRemove(){this._removed=!0,this.actor.sendAsync({type:"RS",data:{type:this.type,source:this.id}});}serialize(){return t.e({},this._options,{type:this.type,data:this._data.updateable?{type:"FeatureCollection",features:Array.from(this._data.updateable.values())}:this._data.url||this._data.geojson})}hasTransition(){return !1}}class te extends t.E{constructor(e,t,i,o){super(),this.flippedWindingOrder=!1,this.id=e,this.dispatcher=i,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(o),this.options=t;}load(e){return t._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new t.n("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const t=yield u.getImage(yield this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,(null==t?void 0:t.data)&&(this.image=t.data,e&&(this.coordinates=e),this._finishLoading());}catch(e){this._request=null,this._loaded=!0,t.$(e)||this.fire(new t.l(t.d(e)));}}))}loaded(){return this._loaded}updateImage(e){return e.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=e.url,this.load(e.coordinates).finally((()=>this.texture=null)),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new t.n("data",{dataType:"source",sourceDataType:"metadata"})));}onAdd(e){this.map=e,this.load();}onRemove(){this._request&&(this._request.abort(),this._request=null);}setCoordinates(e){this.coordinates=e;const i=e.map(t.a7.fromLngLat);var o;return this.tileID=function(e){const i=t.a8.fromPoints(e),o=i.width(),a=i.height(),r=Math.max(o,a),s=Math.max(0,Math.floor(-Math.log(r)/Math.LN2)),n=Math.pow(2,s);return new t.aa(s,Math.floor((i.minX+i.maxX)/2*n),Math.floor((i.minY+i.maxY)/2*n))}(i),this.terrainTileRanges=this._getOverlappingTileRanges(i),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=i.map((e=>this.tileID.getTilePoint(e)._round())),this.flippedWindingOrder=((o=this.tileCoords)[1].x-o[0].x)*(o[2].y-o[0].y)-(o[1].y-o[0].y)*(o[2].x-o[0].x)<0,this.fire(new t.n("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const e=this.map.painter.context,i=e.gl;this.texture||(this.texture=new t.T(e,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let o=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,o=!0);}o&&this.fire(new t.n("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}));}loadTile(e){return t._(this,void 0,void 0,(function*(){var t;(null===(t=this.tileID)||void 0===t?void 0:t.equals(e.tileID.canonical))?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state="errored";}))}serialize(){return {type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return !1}_getOverlappingTileRanges(e){const{minX:i,minY:o,maxX:a,maxY:r}=t.a8.fromPoints(e),s={};for(let e=0;e<=t.a9;e++){const t=Math.pow(2,e),n=Math.floor(i*t),l=Math.floor(o*t),c=Math.floor(a*t),h=Math.floor(r*t),u=(n%t+t)%t,d=c%t,_=Math.floor(n/t),p=Math.floor(c/t);s[e]={minWrap:_,maxWrap:p,minTileXWrapped:u,maxTileXWrapped:d,minTileY:l,maxTileY:h};}return s}}class ie extends te{constructor(e,t,i,o){super(e,t,i,o),this._onPlayingHandler=()=>{var e;null===(e=this.map)||void 0===e||e.triggerRepaint();},this.roundZoom=!0,this.type="video",this.options=t;}load(){return t._(this,void 0,void 0,(function*(){this._loaded=!1;const e=this.options;this.urls=[];for(const t of e.urls)this.urls.push((yield this.map._requestManager.transformRequest(t,"Source")).url);try{const e=yield t.ab(this.urls);if(this._loaded=!0,!e)return;this.video=e,this.video.loop=!0,this.video.addEventListener("playing",this._onPlayingHandler),this.map&&this.video.play(),this._finishLoading();}catch(e){this.fire(new t.l(t.d(e)));}}))}pause(){this.video&&this.video.pause();}play(){this.video&&this.video.play();}seek(e){if(this.video){const i=this.video.seekable;e<i.start(0)||e>i.end(0)?this.fire(new t.l(new t.ac(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=e;}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)));}onRemove(){super.onRemove(),this.video&&(this.video.removeEventListener("playing",this._onPlayingHandler),this.video.pause());}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const e=this.map.painter.context,i=e.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new t.T(e,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let o=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,o=!0);}o&&this.fire(new t.n("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}));}serialize(){return {type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class oe extends te{constructor(e,i,o,a){super(e,i,o,a),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some((e=>!Array.isArray(e)||2!==e.length||e.some((e=>"number"!=typeof e))))||this.fire(new t.l(new t.ac(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new t.l(new t.ac(`sources.${e}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new t.l(new t.ac(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new t.l(new t.ac(`sources.${e}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new t.l(new t.ac(`sources.${e}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate;}load(){return t._(this,void 0,void 0,(function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new t.l(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint();},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1);},this._finishLoading());}))}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play();}onRemove(){this.pause();}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context,o=i.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):(this.texture=new t.T(i,this.canvas,o.RGBA,{premultiply:!0}),this.texture.bind(o.LINEAR,o.CLAMP_TO_EDGE));let a=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,a=!0);}a&&this.fire(new t.n("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}));}serialize(){return {type:"canvas",animate:this.animate,canvas:this.options.canvas,coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of [this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return !0;return !1}}const ae={},re=e=>{switch(e){case "geojson":return ee;case "image":return te;case "raster":return q;case "raster-dem":return $;case "vector":return W;case "video":return ie;case "canvas":return oe}return ae[e]},se="RTLPluginLoaded";class ne extends t.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=B();}_syncState(e){return this.status=e,this.dispatcher.broadcast("SRPS",{pluginStatus:e,pluginURL:this.url}).catch((e=>{throw this.status="error",e}))}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null;}setRTLTextPlugin(e){return t._(this,arguments,void 0,(function*(e,t=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=n.resolveURL(e),!this.url)throw new Error(`requested url ${e} is invalid`);if("unavailable"===this.status){if(!t)return this._requestImport();this.status="deferred",this._syncState(this.status);}else if("requested"===this.status)return this._requestImport()}))}_requestImport(){return t._(this,void 0,void 0,(function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new t.n(se));}))}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport();}}let le=null;function ce(){return le||(le=new ne),le}var he,ue;!function(e){e[e.Base=0]="Base",e[e.Parent=1]="Parent";}(he||(he={})),function(e){e[e.Departing=0]="Departing",e[e.Incoming=1]="Incoming";}(ue||(ue={}));class de{constructor(e,i){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=e,this.uid=t.ad(),this.uses=0,this.tileSize=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttFingerprint={},this.expiredRequestCount=0,this.state="loading";}isRenderable(e){return this.hasData()&&(!this.fadeEndTime||this.fadeOpacity>0)&&(e||!this.holdingForSymbolFade())}setCrossFadeLogic({fadingRole:e,fadingDirection:t,fadingParentID:i,fadeEndTime:o}){this.resetFadeLogic(),this.fadingRole=e,this.fadingDirection=t,this.fadingParentID=i,this.fadeEndTime=o;}setSelfFadeLogic(e){this.resetFadeLogic(),this.selfFading=!0,this.fadeEndTime=e;}resetFadeLogic(){this.fadingRole=null,this.fadingDirection=null,this.fadingParentID=null,this.selfFading=!1,this.timeAdded=c(),this.fadeEndTime=0,this.fadeOpacity=1;}wasRequested(){return "errored"===this.state||"loaded"===this.state||"reloading"===this.state}clearTextures(e){this.demTexture&&e.saveTileTexture(this.demTexture),this.demTexture=null;}loadVectorData(e,i,o){if(!0!==(null==e?void 0:e.etagUnmodified))if(this.hasData()&&this.unloadVectorData(),this.state="loaded",e){e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestEncoding=e.encoding,this.latestFeatureIndex.rawTileData=e.rawTileData,this.latestFeatureIndex.encoding=e.encoding):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData,this.latestFeatureIndex.encoding=this.latestEncoding)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=function(e,t){const i={};if(!t)return i;for(const o of e){const e=o.layerIds.map((e=>t.getLayer(e))).filter(Boolean);if(0!==e.length){o.layers=e,o.stateDependentLayerIds&&(o.stateDependentLayers=o.stateDependentLayerIds.map((t=>e.filter((e=>e.id===t))[0])));for(const t of e)i[t.id]=o;}}return i}(e.buckets,null==i?void 0:i.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.af){if(this.hasSymbolBuckets=!0,!o)break;i.justReloaded=!0;}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.af&&i.hasRTLText){this.hasRTLText=!0,ce().lazyLoad();break}}this.queryPadding=0;for(const e in this.buckets){const t=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,i.style.getLayer(e).queryRadius(t));}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),this.dashPositions=e.dashPositions;}else this.collisionBoxArray=new t.ae;else this.state="loaded";}unloadVectorData(){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.imageAtlas=null,this.dashPositions=null,this.latestFeatureIndex=null,this.state="unloaded";}getBucket(e){return this.buckets[e.id]}upload(e){for(const t in this.buckets){const i=this.buckets[t];i.uploadPending()&&i.upload(e);}const i=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new t.T(e,this.imageAtlas.image,i.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new t.T(e,this.glyphAtlasImage,i.ALPHA),this.glyphAtlasImage=null);}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture);}queryRenderedFeatures(e,t,i,o,a,r,s,n,l,c,h){var u;return (null===(u=this.latestFeatureIndex)||void 0===u?void 0:u.rawTileData)?this.latestFeatureIndex.query({queryGeometry:o,cameraQueryGeometry:a,scale:r,tileSize:this.tileSize,pixelPosMatrix:c,transform:n,params:s,queryPadding:this.queryPadding*l,getElevation:h},e,t,i):{}}querySourceFeatures(e,i){const o=this.latestFeatureIndex;if(!(null==o?void 0:o.rawTileData))return;const a=o.loadVTLayers(),r=(null==i?void 0:i.sourceLayer)?i.sourceLayer:"",s=a[t.ag]||a[r];if(!s)return;const n=t.ah(null==i?void 0:i.filter,null==i?void 0:i.globalState),{z:l,x:c,y:h}=this.tileID.canonical,u={z:l,x:c,y:h};for(let i=0;i<s.length;i++){const a=s.feature(i);if(n.needGeometry){const e=t.ai(a,!0);if(!n.filter(new t.J(this.tileID.overscaledZ),e,this.tileID.canonical))continue}else if(!n.filter(new t.J(this.tileID.overscaledZ),a))continue;const d=o.getId(a,r),_=new t.aj(a,l,c,h,d);_.tile=u,e.push(_);}}hasData(){return "loaded"===this.state||"reloading"===this.state||"expired"===this.state}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(e){const i=this.expirationTime;if(e.cacheControl){const i=t.ak(e.cacheControl);i["max-age"]&&(this.expirationTime=Date.now()+1e3*i["max-age"]);}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){const e=Date.now();let t=!1;if(this.expirationTime>e)t=!1;else if(i)if(this.expirationTime<i)t=!0;else {const o=this.expirationTime-i;o?this.expirationTime=e+Math.max(o,3e4):t=!0;}else t=!0;t?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0;}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-(new Date).getTime(),Math.pow(2,31)-1)}setFeatureState(e,i){var o,a,r;if(!(null===(o=this.latestFeatureIndex)||void 0===o?void 0:o.rawTileData)||0===Object.keys(e).length)return;const s=this.latestFeatureIndex.loadVTLayers();for(const o in this.buckets){if(!i.style.hasLayer(o))continue;const n=this.buckets[o],l=n.layers[0].sourceLayer||t.ag,c=s[l],h=e[l];if(!c||!h||0===Object.keys(h).length)continue;n.update(h,c,(null===(a=this.imageAtlas)||void 0===a?void 0:a.patternPositions)||{},this.dashPositions||{});const u=null===(r=null==i?void 0:i.style)||void 0===r?void 0:r.getLayer(o);u&&(this.queryPadding=Math.max(this.queryPadding,u.queryRadius(n)));}}holdingForSymbolFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return !this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<c()}clearSymbolFadeHold(){this.symbolFadeHoldUntil=void 0;}setSymbolHoldDuration(e){this.symbolFadeHoldUntil=c()+e;}setDependencies(e,t){const i={};for(const e of t)i[e]=!0;this.dependencies[e]=i;}hasDependency(e,t){for(const i of e){const e=this.dependencies[i];if(e)for(const i of t)if(e[i])return !0}return !1}}class _e{constructor(){this.state={},this.stateChanges={},this.deletedStates={},this.revision=0;}updateState(e,i,o){var a,r,s,n,l;const c=String(i);if((n=this.stateChanges)[e]||(n[e]={}),(l=this.stateChanges[e])[c]||(l[c]={}),t.e(this.stateChanges[e][c],o),null===this.deletedStates[e]){this.deletedStates[e]={};for(const t in this.state[e])t!==c&&(this.deletedStates[e][t]=null);}else if(null===(null===(a=this.deletedStates[e])||void 0===a?void 0:a[c])){this.deletedStates[e][c]={};for(const t in this.state[e][c])o[t]||(this.deletedStates[e][c][t]=null);}else for(const t in o)null===(null===(s=null===(r=this.deletedStates[e])||void 0===r?void 0:r[c])||void 0===s?void 0:s[t])&&delete this.deletedStates[e][c][t];}removeFeatureState(e,t,i){var o,a,r;if(null===this.deletedStates[e])return;const s=String(t);if((a=this.deletedStates)[e]||(a[e]={}),i&&void 0!==t)null!==this.deletedStates[e][s]&&((r=this.deletedStates[e])[s]||(r[s]={}),this.deletedStates[e][s][i]=null);else if(void 0!==t)if(null===(o=this.stateChanges[e])||void 0===o?void 0:o[s])for(i in this.deletedStates[e][s]={},this.stateChanges[e][s])this.deletedStates[e][s][i]=null;else this.deletedStates[e][s]=null;else this.deletedStates[e]=null;}getState(e,i){const o=String(i),a=t.e({},(this.state[e]||{})[o],(this.stateChanges[e]||{})[o]);if(null===this.deletedStates[e])return {};if(this.deletedStates[e]){const t=this.deletedStates[e][i];if(null===t)return {};for(const e in t)delete a[e];}return a}initializeTileState(e,t){e.setFeatureState(this.state,t);}coalesceChanges(e,i){var o,a,r;const s={};for(const e in this.stateChanges){(o=this.state)[e]||(o[e]={});const i={};for(const o in this.stateChanges[e])(a=this.state[e])[o]||(a[o]={}),t.e(this.state[e][o],this.stateChanges[e][o]),i[o]=this.state[e][o];s[e]=i;}for(const e in this.deletedStates){(r=this.state)[e]||(r[e]={});const i={};if(null===this.deletedStates[e])for(const t in this.state[e])i[t]={},this.state[e][t]={};else for(const t in this.deletedStates[e]){if(null===this.deletedStates[e][t])this.state[e][t]={};else for(const i of Object.keys(this.deletedStates[e][t]))delete this.state[e][t][i];i[t]=this.state[e][t];}s[e]||(s[e]={}),t.e(s[e],i);}this.stateChanges={},this.deletedStates={},0!==Object.keys(s).length&&(this.revision++,e.setFeatureState(s,i));}}const pe=89.25;function me(e,i){const o=t.al(i.lat,-t.am,t.am);return new t.P(t.Z(i.lng)*e,t.Y(o)*e)}function fe(e,i){return new t.a7(i.x/e,i.y/e).toLngLat()}function ge(e){return e.cameraToCenterDistance*Math.min(.85*Math.tan(t.an(90-e.pitch)),Math.tan(t.an(pe-e.pitch)))}function ve(e,i){const o=e.canonical,a=i/t.ao(o.z),r=o.x+Math.pow(2,o.z)*e.wrap,s=t.ap(new Float64Array(16));return t.Q(s,s,[r*a,o.y*a,0]),t.S(s,s,[a/t.a6,a/t.a6,1]),s}function xe(e,i,o,a,r){const s=t.a7.fromLngLat(e,i),n=r*t.aq(1,e.lat),{x:l,y:c,z:h}=be(o,a);return new t.a7(s.x+n*-l,s.y+n*-c,s.z+n*-h)}function be(e,i){const o=t.an(e),a=t.an(i),r=Math.cos(-o),s=Math.sin(o);return {x:s*Math.sin(a),y:-s*Math.cos(a),z:r}}function ye(e,t,i){const o=t.intersectsFrustum(e);if(!i||0===o)return o;const a=t.intersectsPlane(i);return 0===a?0:2===o&&2===a?2:1}function we(e,t,i){let o=0;const a=(i-t)/10;for(let r=0;r<10;r++)o+=a*Math.pow(Math.cos(t+(r+.5)/10*(i-t)),e);return o}function Te(e,i){return function(o,a,r,s,n){const l=2*((e-1)/t.ar(Math.cos(t.an(pe-n))/Math.cos(t.an(pe)))-1),c=Math.acos(r/s),h=2*we(l-1,0,t.an(n/2)),u=Math.min(t.an(pe),c+t.an(n/2)),d=we(l-1,Math.min(u,c-t.an(n/2)),u),_=Math.atan(a/r),p=Math.hypot(a,r);let m=o;return m+=t.ar(s/p/Math.max(.5,Math.cos(t.an(n/2)))),m+=l*t.ar(Math.cos(_))/2,m-=t.ar(Math.max(1,d/h/i))/2,m}}const Pe=Te(9.314,3);function Ce(e,i){const o=(i.roundZoom?Math.round:Math.floor)(e.zoom+t.ar(e.tileSize/i.tileSize));return Math.max(0,o)}function Me(e,i){const o=e.getCameraFrustum(),a=e.getClippingPlane(),r=e.screenPointToMercatorCoordinate(e.getCameraPoint()),s=t.a7.fromLngLat(e.center,e.elevation);r.z=s.z+Math.cos(e.pitchInRadians)*e.cameraToCenterDistance/e.worldSize;const n=e.getCoveringTilesDetailsProvider(),l=n.allowVariableZoom(e,i),c=Ce(e,i),h=i.minzoom||0,u=void 0!==i.maxzoom?i.maxzoom:e.maxZoom,d=Math.min(Math.max(0,c),u),_=Math.pow(2,d),p=[_*r.x,_*r.y,0],m=[_*s.x,_*s.y,0],f=Math.hypot(s.x-r.x,s.y-r.y),g=Math.abs(s.z-r.z),v=Math.hypot(f,g),x=e=>({zoom:0,x:0,y:0,wrap:e,fullyVisible:!1}),b=[],y=[];if(e.renderWorldCopies&&n.allowWorldCopies())for(let e=1;e<=3;e++)b.push(x(-e)),b.push(x(e));for(b.push(x(0));b.length>0;){const _=b.pop(),f=_.x,x=_.y;let w=_.fullyVisible;const T={x:f,y:x,z:_.zoom},P=n.getTileBoundingVolume(T,_.wrap,e.elevation,i);if(!w){const e=ye(o,P,a);if(0===e)continue;w=2===e;}const C=n.distanceToTile2d(r.x,r.y,T,P);let M=c;l&&(M=(i.calculateTileZoom||Pe)(e.zoom+t.ar(e.tileSize/i.tileSize),C,g,v,e.fov)),M=(i.roundZoom?Math.round:Math.floor)(M),M=Math.max(0,M);const I=Math.min(M,u);if(_.wrap=n.getWrap(s,T,_.wrap),_.zoom>=I){if(_.zoom<h)continue;const e=d-_.zoom,o=p[0]-.5-(f<<e),a=p[1]-.5-(x<<e),r=i.reparseOverscaled?Math.max(_.zoom,M):_.zoom;y.push({tileID:new t.a3(_.zoom===u?r:_.zoom,_.wrap,_.zoom,f,x),distanceSq:t.as([m[0]-.5-f,m[1]-.5-x]),tileDistanceToCamera:Math.sqrt(o*o+a*a)});}else for(let e=0;e<4;e++)b.push({zoom:_.zoom+1,x:(f<<1)+e%2,y:(x<<1)+(e>>1),wrap:_.wrap,fullyVisible:w});}return y.sort(((e,t)=>e.distanceSq-t.distanceSq)).map((e=>e.tileID))}const Ie=t.a8.fromPoints([new t.P(0,0),new t.P(t.a6,t.a6)]);function Ee(e){return "raster"===e||"image"===e||"video"===e}function Se(e,t,i,o,a,r,s){if(!t.hasData())return !1;const{tileID:n,fadingRole:l,fadingDirection:c,fadingParentID:h}=t;if(l===he.Base&&c===ue.Incoming&&h)return i[h.key]=h,!0;const u=Math.max(n.overscaledZ-a,r);for(let a=n.overscaledZ-1;a>=u;a--){const r=n.scaledTo(a),l=e.getLoadedTile(r);if(l)return t.setCrossFadeLogic({fadingRole:he.Base,fadingDirection:ue.Incoming,fadingParentID:l.tileID,fadeEndTime:o+s}),l.setCrossFadeLogic({fadingRole:he.Parent,fadingDirection:ue.Departing,fadeEndTime:o+s}),i[r.key]=r,!0}return !1}function ze(e,t,i,o,a,r){if(!t.hasData())return !1;const s=t.tileID.children(a);let n=Re(e,t,s,i,o,a,r);if(n)return !0;for(const l of s)Re(e,t,l.children(a),i,o,a,r)&&(n=!0);return n}function Re(e,t,i,o,a,r,s){if(i[0].overscaledZ>=r)return !1;let n=!1;for(const r of i){const i=e.getLoadedTile(r);if(!i)continue;const{fadingRole:l,fadingDirection:c,fadingParentID:h}=i;l===he.Base&&c===ue.Departing&&h||(i.setCrossFadeLogic({fadingRole:he.Base,fadingDirection:ue.Departing,fadingParentID:t.tileID,fadeEndTime:a+s}),t.setCrossFadeLogic({fadingRole:he.Parent,fadingDirection:ue.Incoming,fadeEndTime:a+s})),o[r.key]=r,n=!0;}return n}function De(e,t,i,o){const a=e.tileID;return !!e.selfFading||!e.hasData()&&!!t.has(a)&&(e.setSelfFadeLogic(i+o),!0)}function Ae(e,t){var i;e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0;let o=t.tileID.canonical.x-e.tileID.canonical.x;const a=t.tileID.canonical.y-e.tileID.canonical.y,r=Math.pow(2,e.tileID.canonical.z),s=t.tileID.key;0===o&&0===a||Math.abs(a)>1||(Math.abs(o)>1&&(1===Math.abs(o+r)?o+=r:1===Math.abs(o-r)&&(o-=r)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,o,a),(null===(i=e.neighboringTiles)||void 0===i?void 0:i[s])&&(e.neighboringTiles[s].backfilled=!0)));}class Le{constructor(){this._tiles={};}handleWrapJump(e){const t={};for(const i in this._tiles){const o=this._tiles[i];o.tileID=o.tileID.unwrapTo(o.tileID.wrap+e),t[o.tileID.key]=o;}this._tiles=t;}setFeatureState(e,t){for(const i in this._tiles)this._tiles[i].setFeatureState(e,t);}getAllTiles(){return Object.values(this._tiles)}getAllIds(e=!1){return e?Object.values(this._tiles).map((e=>e.tileID)).sort(t.au).map((e=>e.key)):Object.keys(this._tiles)}getTileById(e){return this._tiles[e]}setTile(e,t){this._tiles[e]=t;}deleteTileById(e){delete this._tiles[e];}getLoadedTile(e){const t=this.getTileById(e.key);return (null==t?void 0:t.hasData())?t:null}isIdRenderable(e,t=!1){var i;return null===(i=this.getTileById(e))||void 0===i?void 0:i.isRenderable(t)}getRenderableIds(e=0,i){const o=[];for(const e of this.getAllIds())this.isIdRenderable(e,i)&&o.push(this.getTileById(e));return i?o.sort(((i,o)=>{const a=i.tileID,r=o.tileID,s=new t.P(a.canonical.x,a.canonical.y)._rotate(-e),n=new t.P(r.canonical.x,r.canonical.y)._rotate(-e);return a.overscaledZ-r.overscaledZ||n.y-s.y||n.x-s.x})).map((e=>e.tileID.key)):o.map((e=>e.tileID)).sort(t.au).map((e=>e.key))}}class Fe extends t.E{constructor(e,i,o){super(),this.id=e,this.dispatcher=o,this.on("data",(e=>{this._dataHandler(e);})),this.on("dataloading",(()=>{this._sourceErrored=!1;})),this.on("error",(()=>{this._sourceErrored=this._source.loaded();})),this._source=((e,t,i,o)=>{const a=new(re(t.type))(e,t,i,o);if(a.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${a.id}`);return a})(e,i,o,this),this._inViewTiles=new Le,this._outOfViewCache=new t.av(0,(e=>this._unloadTile(e))),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new _e,this._didEmitContent=!1,this._updated=!1;}onAdd(e){var t;this.map=e,this._maxTileCacheSize=e?e._maxTileCacheSize:null,this._maxTileCacheZoomLevels=e?e._maxTileCacheZoomLevels:null,(null===(t=this._source)||void 0===t?void 0:t.onAdd)&&this._source.onAdd(e);}onRemove(e){var t;for(const e of this._inViewTiles.getAllTiles())e.unloadVectorData();this.clearTiles(),(null===(t=this._source)||void 0===t?void 0:t.onRemove)&&this._source.onRemove(e),this._inViewTiles=new Le;}loaded(){if(this._sourceErrored)return !0;if(!this._sourceLoaded)return !1;if(!this._source.loaded())return !1;if(!(void 0===this.used&&void 0===this.usedForTerrain||this.used||this.usedForTerrain))return !0;if(!this._updated)return !1;for(const e of this._inViewTiles.getAllTiles())if("loaded"!==e.state&&"errored"!==e.state)return !1;return !0}getSource(){return this._source}getState(){return this._state}pause(){this._paused=!0;}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform,this.terrain);}_loadTile(e,i,o){return t._(this,void 0,void 0,(function*(){try{const t=yield this._source.loadTile(e);this._tileLoaded(e,i,o,t);}catch(i){e.state="errored",404!==i.status?this._source.fire(new t.l(t.d(i),{tile:e})):this.update(this.transform,this.terrain);}}))}_unloadTile(e){this._source.unloadTile&&this._source.unloadTile(e);}_abortTile(e){this._source.abortTile&&this._source.abortTile(e),this._source.fire(new t.n("dataabort",{tile:e,coord:e.tileID,dataType:"source"}));}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._inViewTiles,this.map?this.map.painter:null);for(const t of this._inViewTiles.getAllTiles())t.upload(e),t.prepare(this.map.style.imageManager);}getIds(){return this._inViewTiles.getAllIds(!0)}getRenderableIds(e){var t;return this._inViewTiles.getRenderableIds(null===(t=this.transform)||void 0===t?void 0:t.bearingInRadians,e)}hasRenderableParent(e){const t=e.overscaledZ-1;if(t>=this._source.minzoom){const i=this.getLoadedTile(e.scaledTo(t));if(i)return this._inViewTiles.isIdRenderable(i.tileID.key)}return !1}reload(e,t=void 0){if(this._paused)this._shouldReloadOnResume=!0;else {this._outOfViewCache.reset();for(const i of this._inViewTiles.getAllIds()){const o=this._inViewTiles.getTileById(i);t&&!this._source.shouldReloadTile(o,t)||(e?this._reloadTile(i,"expired"):"errored"!==o.state&&this._reloadTile(i,"reloading"));}}}_reloadTile(e,i){return t._(this,void 0,void 0,(function*(){const t=this._inViewTiles.getTileById(e);t&&("loading"!==t.state&&(t.state=i),yield this._loadTile(t,e,i));}))}_tileLoaded(e,i,o,a){e.timeAdded=c(),e.selfFading&&(e.fadeEndTime=e.timeAdded+this._rasterFadeDuration),"expired"===o&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(i,e),(null==a?void 0:a.unmodified)||("raster-dem"===this.getSource().type&&e.dem&&function(e,t){var i,o,a;const r=t.getRenderableIds();for(const s of r){if(!(null===(i=e.neighboringTiles)||void 0===i?void 0:i[s]))continue;const r=t.getTileById(s);e.neighboringTiles[s].backfilled||Ae(e,r),(null===(a=null===(o=r.neighboringTiles)||void 0===o?void 0:o[e.tileID.key])||void 0===a?void 0:a.backfilled)||Ae(r,e);}}(e,this._inViewTiles),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new t.n("data",{dataType:"source",tile:e,coord:e.tileID})));}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._inViewTiles.getTileById(e)}_retainLoadedChildren(e,t){const i=this._getLoadedDescendents(t),o=new Set;for(const a of t){const t=i[a.key];if(!(null==t?void 0:t.length)){o.add(a);continue}const r=a.overscaledZ+Fe.maxOverzooming,s=t.filter((e=>e.tileID.overscaledZ<=r));if(!s.length){o.add(a);continue}const n=Math.min(...s.map((e=>e.tileID.overscaledZ))),l=s.filter((e=>e.tileID.overscaledZ===n)).map((e=>e.tileID));for(const t of l)e[t.key]=t;this._areDescendentsComplete(l,n,a.overscaledZ)||o.add(a);}return o}_getLoadedDescendents(e){var t;const i={};for(const o of this._inViewTiles.getAllTiles().filter((e=>e.hasData())))for(const a of e)o.tileID.isChildOf(a)&&(i[t=a.key]||(i[t]=[]),i[a.key].push(o));return i}_areDescendentsComplete(e,t,i){return 1===e.length&&e[0].isOverscaled()?e[0].overscaledZ===t:Math.pow(4,t-i)===e.length}getLoadedTile(e){return this._inViewTiles.getLoadedTile(e)}updateCacheSize(e){const i=Math.ceil(e.width/this._source.tileSize)+1,o=Math.ceil(e.height/this._source.tileSize)+1,a=Math.floor(i*o*(null===this._maxTileCacheZoomLevels?t.c.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),r="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,a):a;this._outOfViewCache.setMaxSize(r);}handleWrapJump(e){const t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);this._prevLng=e,t&&(this._inViewTiles.handleWrapJump(t),this._resetTileReloadTimers());}update(e,i){if(!this._sourceLoaded||this._paused)return;let o;this.transform=e,this.terrain=i,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this.used||this.usedForTerrain?this._source.tileID?o=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((e=>new t.a3(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y))):(o=Me(e,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:"vector"===this._source.type&&void 0!==this.map._zoomLevelsToOverscale?e.maxZoom-this.map._zoomLevelsToOverscale:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:i,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(o=o.filter((e=>this._source.hasTile(e))))):o=[],this.usedForTerrain&&(o=this._addTerrainIdealTiles(o));const a=0===o.length&&!this._updated&&this._didEmitContent;this._updated=!0,a&&this.fire(new t.n("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const r=Ce(e,this._source),s=this._updateRetainedTiles(o,r),n=Ee(this._source.type);n&&this._rasterFadeDuration>0&&!i&&function(e,i,o,a,r,s,n){const l=c(),h=t.at(i);for(const t of i){const i=e.getTileById(t.key);i.fadingDirection!==ue.Departing&&0!==i.fadeOpacity||i.resetFadeLogic(),Se(e,i,o,l,a,r,n)||ze(e,i,o,l,s,n)||De(i,h,l,n)||i.resetFadeLogic();}}(this._inViewTiles,o,s,this._maxFadingAncestorLevels,this._source.minzoom,this._source.maxzoom,this._rasterFadeDuration),n?this._cleanUpRasterTiles(s):this._cleanUpVectorTiles(s);}_cleanUpRasterTiles(e){for(const t of this._inViewTiles.getAllIds())e[t]||this._removeTile(t);}_cleanUpVectorTiles(e){for(const t of this._inViewTiles.getAllIds()){const i=this._inViewTiles.getTileById(t);e[t]?i.clearSymbolFadeHold():i.hasSymbolBuckets?i.holdingForSymbolFade()?i.symbolFadeFinished()&&this._removeTile(t):i.setSymbolHoldDuration(this.map._fadeDuration):this._removeTile(t);}}_addTerrainIdealTiles(e){const t=[];for(const i of e)if(i.canonical.z>this._source.minzoom){const e=i.scaledTo(i.canonical.z-1);t.push(e);const o=i.scaledTo(Math.max(this._source.minzoom,Math.min(i.canonical.z,5)));t.push(o);}return e.concat(t)}releaseSymbolFadeTiles(){for(const e of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(e).holdingForSymbolFade()&&this._removeTile(e);}_updateRetainedTiles(e,t){var i;const o=new Set;for(const t of e)this._addTile(t).hasData()||o.add(t);const a=e.reduce(((e,t)=>(e[t.key]=t,e)),{}),r=this._retainLoadedChildren(a,o),s={},n=Math.max(t-Fe.maxUnderzooming,this._source.minzoom);for(const e of r){let t=this._inViewTiles.getTileById(e.key),o=null==t?void 0:t.wasRequested();for(let r=e.overscaledZ-1;r>=n;--r){const n=e.scaledTo(r);if(s[n.key])break;if(s[n.key]=!0,t=this.getTile(n),!t&&o&&(t=this._addTile(n)),t){const e=t.hasData();if((e||!(null===(i=this.map)||void 0===i?void 0:i.cancelPendingTileRequestsWhileZooming)||o)&&(a[n.key]=n),o=t.wasRequested(),e)break}}}return a}_addTile(e){let i=this._inViewTiles.getTileById(e.key);if(i)return i;i=this._outOfViewCache.getAndRemove(e),i&&(i.resetFadeLogic(),this._setTileReloadTimer(e.key,i),i.tileID=e,this._state.initializeTileState(i,this.map?this.map.painter:null));const o=i;return i||(i=new de(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(i,e.key,i.state)),i.uses++,this._inViewTiles.setTile(e.key,i),o||this._source.fire(new t.n("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i}_setTileReloadTimer(e,t){this._clearTileReloadTimer(e);const i=t.getExpiryTimeout();i&&(this._timers[e]=setTimeout((()=>{this._reloadTile(e,"expired"),delete this._timers[e];}),i));}_clearTileReloadTimer(e){const t=this._timers[e];t&&(clearTimeout(t),delete this._timers[e]);}_resetTileReloadTimers(){for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e of this._inViewTiles.getAllIds()){const t=this._inViewTiles.getTileById(e);this._setTileReloadTimer(e,t);}}refreshTiles(e){for(const t of this._inViewTiles.getAllIds()){const i=this._inViewTiles.getTileById(t);(this._inViewTiles.isIdRenderable(t)||"errored"==i.state)&&e.some((e=>e.equals(i.tileID.canonical)))&&this._reloadTile(t,"expired");}}_removeTile(e){const t=this._inViewTiles.getTileById(e);t&&(t.uses--,this._inViewTiles.deleteTileById(e),this._clearTileReloadTimer(e),t.uses>0||(t.hasData()&&"reloading"!==t.state?this._outOfViewCache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))));}_dataHandler(e){"source"===e.dataType&&("metadata"!==e.sourceDataType?"content"===e.sourceDataType&&this._sourceLoaded&&!this._paused&&(this.reload(e.sourceDataChanged,e.shouldReloadTileOptions),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0):this._sourceLoaded=!0);}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e of this._inViewTiles.getAllIds())this._removeTile(e);this._outOfViewCache.reset();}tilesIn(e,i,o){const a=[],r=this.transform;if(!r)return a;const s=r.getCoveringTilesDetailsProvider().allowWorldCopies(),n=o?r.getCameraQueryGeometry(e):e,l=e=>r.screenPointToMercatorCoordinate(e,this.terrain),c=this.transformBbox(e,l,!s),h=this.transformBbox(n,l,!s),u=this.getIds(),d=t.a8.fromPoints(h);for(const e of u){const o=this._inViewTiles.getTileById(e);if(o.holdingForSymbolFade())continue;const n=s?[o.tileID]:[o.tileID.unwrapTo(-1),o.tileID.unwrapTo(0)],l=Math.pow(2,r.zoom-o.tileID.overscaledZ),u=i*o.queryPadding*t.a6/o.tileSize/l;for(const e of n){const i=d.map((i=>e.getTilePoint(new t.a7(i.x,i.y))));if(i.expandBy(u),i.intersects(Ie)){const t=c.map((t=>e.getTilePoint(t))),i=h.map((t=>e.getTilePoint(t)));a.push({tile:o,tileID:s?e:e.unwrapTo(0),queryGeometry:t,cameraQueryGeometry:i,scale:l});}}}return a}transformBbox(e,i,o){let a=e.map(i);if(o){const o=t.a8.fromPoints(e);o.shrinkBy(.001*Math.min(o.width(),o.height()));const r=o.map(i);t.a8.fromPoints(a).covers(r)||(a=a.map((e=>e.x>.5?new t.a7(e.x-1,e.y,e.z):e)));}return a}getVisibleCoordinates(e){const t=this.getRenderableIds(e).map((e=>this._inViewTiles.getTileById(e).tileID));return this.transform&&this.transform.populateCache(t),t}hasTransition(){return !!this._source.hasTransition()||Ee(this._source.type)&&function(e,t){if(t<=0)return !1;const i=c();for(const t of e.getAllTiles())if(t.fadeEndTime>=i)return !0;return !1}(this._inViewTiles,this._rasterFadeDuration)}setRasterFadeDuration(e){this._rasterFadeDuration=e;}setFeatureState(e,i,o){e||(e=t.ag),this._state.updateState(e,i,o);}removeFeatureState(e,i,o){e||(e=t.ag),this._state.removeFeatureState(e,i,o);}getFeatureState(e,i){return e||(e=t.ag),this._state.getState(e,i)}setDependencies(e,t,i){const o=this._inViewTiles.getTileById(e);o&&o.setDependencies(t,i);}reloadTilesForDependencies(e,t){for(const i of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(i).hasDependency(e,t)&&this._reloadTile(i,"reloading");this._outOfViewCache.filter((i=>!i.hasDependency(e,t)));}areTilesLoaded(){for(const e of this._inViewTiles.getAllTiles())if("loaded"!==e.state&&"errored"!==e.state)return !1;return !0}}Fe.maxUnderzooming=10,Fe.maxOverzooming=3;class ke{constructor(e,t){this.reset(e,t);}reset(e,t){this.points=e||[],this._distances=[0];for(let e=1;e<this.points.length;e++)this._distances[e]=this._distances[e-1]+this.points[e].dist(this.points[e-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(t||0,.5*this.length),this.paddedLength=this.length-2*this.padding;}lerp(e){if(1===this.points.length)return this.points[0];e=t.al(e,0,1);let i=1,o=this._distances[i];const a=e*this.paddedLength+this.padding;for(;o<a&&i<this._distances.length;)o=this._distances[++i];const r=i-1,s=this._distances[r],n=o-s,l=n>0?(a-s)/n:0;return this.points[r].mult(1-l).add(this.points[i].mult(l))}}function Be(e,t){let i=!0;return "always"===e||"never"!==e&&"never"!==t||(i=!1),i}class Oe{constructor(e,t,i){const o=this.boxCells=[],a=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;e<this.xCellCount*this.yCellCount;e++)o.push([]),a.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=e,this.height=t,this.xScale=this.xCellCount/e,this.yScale=this.yCellCount/t,this.boxUid=0,this.circleUid=0;}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(e,t,i,o,a){this._forEachCell(t,i,o,a,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(t),this.bboxes.push(i),this.bboxes.push(o),this.bboxes.push(a);}insertCircle(e,t,i,o){this._forEachCell(t-o,i-o,t+o,i+o,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(t),this.circles.push(i),this.circles.push(o);}_insertBoxCell(e,t,i,o,a,r){this.boxCells[a].push(r);}_insertCircleCell(e,t,i,o,a,r){this.circleCells[a].push(r);}_query(e,t,i,o,a,r,s){if(i<0||e>this.width||o<0||t>this.height)return [];const n=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=o){if(a)return [{key:null,x1:e,y1:t,x2:i,y2:o}];for(let e=0;e<this.boxKeys.length;e++)n.push({key:this.boxKeys[e],x1:this.bboxes[4*e],y1:this.bboxes[4*e+1],x2:this.bboxes[4*e+2],y2:this.bboxes[4*e+3]});for(let e=0;e<this.circleKeys.length;e++){const t=this.circles[3*e],i=this.circles[3*e+1],o=this.circles[3*e+2];n.push({key:this.circleKeys[e],x1:t-o,y1:i-o,x2:t+o,y2:i+o});}}else this._forEachCell(e,t,i,o,this._queryCell,n,{hitTest:a,overlapMode:r,seenUids:{box:{},circle:{}}},s);return n}query(e,t,i,o){return this._query(e,t,i,o,!1,null)}hitTest(e,t,i,o,a,r){return this._query(e,t,i,o,!0,a,r).length>0}hitTestCircle(e,t,i,o,a){const r=e-i,s=e+i,n=t-i,l=t+i;if(s<0||r>this.width||l<0||n>this.height)return !1;const c=[];return this._forEachCell(r,n,s,l,this._queryCellCircle,c,{hitTest:!0,overlapMode:o,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},a),c.length>0}_queryCell(e,t,i,o,a,r,s,n){const{seenUids:l,hitTest:c,overlapMode:h}=s,u=this.boxCells[a],d=1e-6;if(null!==u){const a=this.bboxes;for(const s of u)if(!l.box[s]){l.box[s]=!0;const u=4*s,_=this.boxKeys[s];if(e<=a[u+2]+d&&t<=a[u+3]+d&&i>=a[u+0]-d&&o>=a[u+1]-d&&(!n||n(_))&&(!c||!Be(h,_.overlapMode))&&(r.push({key:_,x1:a[u],y1:a[u+1],x2:a[u+2],y2:a[u+3]}),c))return !0}}const _=this.circleCells[a];if(null!==_){const a=this.circles;for(const s of _)if(!l.circle[s]){l.circle[s]=!0;const u=3*s,d=this.circleKeys[s];if(this._circleAndRectCollide(a[u],a[u+1],a[u+2],e,t,i,o)&&(!n||n(d))&&(!c||!Be(h,d.overlapMode))){const e=a[u],t=a[u+1],i=a[u+2];if(r.push({key:d,x1:e-i,y1:t-i,x2:e+i,y2:t+i}),c)return !0}}}return !1}_queryCellCircle(e,t,i,o,a,r,s,n){const{circle:l,seenUids:c,overlapMode:h}=s,u=this.boxCells[a];if(null!==u){const e=this.bboxes;for(const t of u)if(!c.box[t]){c.box[t]=!0;const i=4*t,o=this.boxKeys[t];if(this._circleAndRectCollide(l.x,l.y,l.radius,e[i+0],e[i+1],e[i+2],e[i+3])&&(!n||n(o))&&!Be(h,o.overlapMode))return r.push(!0),!0}}const d=this.circleCells[a];if(null!==d){const e=this.circles;for(const t of d)if(!c.circle[t]){c.circle[t]=!0;const i=3*t,o=this.circleKeys[t];if(this._circlesCollide(e[i],e[i+1],e[i+2],l.x,l.y,l.radius)&&(!n||n(o))&&!Be(h,o.overlapMode))return r.push(!0),!0}}}_forEachCell(e,t,i,o,a,r,s,n){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(o);for(let d=l;d<=h;d++)for(let l=c;l<=u;l++)if(a.call(this,e,t,i,o,this.xCellCount*l+d,r,s,n))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,i,o,a,r){const s=o-e,n=a-t,l=i+r;return l*l>s*s+n*n}_circleAndRectCollide(e,t,i,o,a,r,s){const n=(r-o)/2,l=Math.abs(e-(o+n));if(l>n+i)return !1;const c=(s-a)/2,h=Math.abs(t-(a+c));if(h>c+i)return !1;if(l<=n||h<=c)return !0;const u=l-n,d=h-c;return u*u+d*d<=i*i}}function je(e,t){const i=1/(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]),o=1/(t[8]*t[8]+t[9]*t[9]+t[10]*t[10]),a=t[0]*i,r=t[4]*i,s=t[8]*o,n=t[1]*i,l=t[5]*i,c=t[9]*o,h=t[2]*i,u=t[6]*i,d=t[10]*o;e[0]=a,e[1]=r,e[2]=s,e[4]=n,e[5]=l,e[6]=c,e[8]=h,e[9]=u,e[10]=d;const _=t[12],p=t[13],m=t[14];return e[12]=-a*_-n*p-h*m,e[13]=-r*_-l*p-u*m,e[14]=-s*_-c*p-d*m,e[3]=0,e[7]=0,e[11]=0,e[15]=1,e}const Ne=t.O();function Ze(e,i,a){const r=t.O();if(!e){const{vecSouth:e,vecEast:t}=Ge(i),a=o();a[0]=t[0],a[1]=t[1],a[2]=e[0],a[3]=e[1],s=a,(d=(l=(n=a)[0])*(u=n[3])-(h=n[2])*(c=n[1]))&&(s[0]=u*(d=1/d),s[1]=-c*d,s[2]=-h*d,s[3]=l*d),r[0]=a[0],r[1]=a[1],r[4]=a[2],r[5]=a[3];}var s,n,l,c,h,u,d;return t.S(r,r,[1/a,1/a,1]),r}function Ue(e,i,o,a){if(e){const e=t.O();if(!i){const{vecSouth:t,vecEast:i}=Ge(o);e[0]=i[0],e[1]=i[1],e[4]=t[0],e[5]=t[1];}return t.S(e,e,[a,a,1]),e}return o.pixelsToClipSpaceMatrix}function Ge(e){const i=Math.cos(e.rollInRadians),o=Math.sin(e.rollInRadians),a=Math.cos(e.pitchInRadians),r=Math.cos(e.bearingInRadians),s=Math.sin(e.bearingInRadians),n=t.az();n[0]=-r*a*o-s*i,n[1]=-s*a*o+r*i;const l=t.aA(n);l<1e-9?t.aB(n):t.aC(n,n,1/l);const c=t.az();c[0]=r*a*i-s*o,c[1]=s*a*i+r*o;const h=t.aA(c);return h<1e-9?t.aB(c):t.aC(c,c,1/h),{vecEast:c,vecSouth:n}}function Ve(e,i,o,a){let r;a?(r=[e,i,a(e,i),1],t.aE(r,r,o)):(r=[e,i,0,1],nt(r,r,o));const s=r[3];return {point:new t.P(r[0]/s,r[1]/s),signedDistanceFromCamera:s,isOccluded:!1}}function We(e,t){return .5+e/t*.5}function qe(e,t){return e.x>=-t[0]&&e.x<=t[0]&&e.y>=-t[1]&&e.y<=t[1]}function $e(e,i,o,a,r,s,n,l,c,h,u,d,_){const p=o?e.textSizeData:e.iconSizeData,m=t.aw(p,i.transform.zoom),f=[256/i.width*2+1,256/i.height*2+1],g=o?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;g.clear();const v=e.lineVertexArray,x=o?e.text.placedSymbolArray:e.icon.placedSymbolArray,b=i.transform.width/i.transform.height;let y=!1;for(let o=0;o<x.length;o++){const w=x.get(o);if(w.hidden||w.writingMode===t.ax.vertical&&!y){st(w.numGlyphs,g);continue}y=!1;const T=new t.P(w.anchorX,w.anchorY),P={getElevation:_,pitchedLabelPlaneMatrix:a,lineVertexArray:v,pitchWithMap:s,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:i.transform,tileAnchorPoint:T,unwrappedTileID:c,width:h,height:u,translation:d},C=tt(w.anchorX,w.anchorY,P);if(!qe(C.point,f)){st(w.numGlyphs,g);continue}const M=We(i.transform.cameraToCenterDistance,C.signedDistanceFromCamera),I=t.ay(p,m,w),E=s?I*i.transform.getPitchedTextCorrection(w.anchorX,w.anchorY,c)/M:I*M,S=Ke({projectionContext:P,pitchedLabelPlaneMatrixInverse:r,symbol:w,fontSize:E,flip:!1,keepUpright:n,glyphOffsetArray:e.glyphOffsetArray,dynamicLayoutVertexArray:g,aspectRatio:b,rotateToLine:l});y=S.useVertical,(S.notEnoughRoom||y||S.needsFlipping&&Ke({projectionContext:P,pitchedLabelPlaneMatrixInverse:r,symbol:w,fontSize:E,flip:!0,keepUpright:n,glyphOffsetArray:e.glyphOffsetArray,dynamicLayoutVertexArray:g,aspectRatio:b,rotateToLine:l}).notEnoughRoom)&&st(w.numGlyphs,g);}o?e.text.dynamicLayoutVertexBuffer.updateData(g):e.icon.dynamicLayoutVertexBuffer.updateData(g);}function He(e,t,i,o,a,r,s,n){const l=r.glyphStartIndex+r.numGlyphs,c=r.lineStartIndex,h=r.lineStartIndex+r.lineLength,u=t.getoffsetX(r.glyphStartIndex),d=t.getoffsetX(l-1),_=at(e*u,i,o,a,r.segment,c,h,n,s);if(!_)return null;const p=at(e*d,i,o,a,r.segment,c,h,n,s);return p?n.projectionCache.anyProjectionOccluded?null:{first:_,last:p}:null}function Xe(e,i,o,a){return e===t.ax.horizontal&&Math.abs(o.y-i.y)>Math.abs(o.x-i.x)*a?{useVertical:!0}:(e===t.ax.vertical?i.y<o.y:i.x>o.x)?{needsFlipping:!0}:null}function Ke(e){const{projectionContext:i,pitchedLabelPlaneMatrixInverse:o,symbol:a,fontSize:r,flip:s,keepUpright:n,glyphOffsetArray:l,dynamicLayoutVertexArray:c,aspectRatio:h,rotateToLine:u}=e,d=r/24,_=a.lineOffsetX*d,p=a.lineOffsetY*d;let m;if(a.numGlyphs>1){const e=a.glyphStartIndex+a.numGlyphs,t=a.lineStartIndex,r=a.lineStartIndex+a.lineLength,c=He(d,l,_,p,s,a,u,i);if(!c)return {notEnoughRoom:!0};const f=et(c.first.point.x,c.first.point.y,i,o),g=et(c.last.point.x,c.last.point.y,i,o);if(n&&!s){const e=Xe(a.writingMode,f,g,h);if(e)return e}m=[c.first];for(let o=a.glyphStartIndex+1;o<e-1;o++){const e=at(d*l.getoffsetX(o),_,p,s,a.segment,t,r,i,u);if(!e)return {notEnoughRoom:!0};m.push(e);}m.push(c.last);}else {if(n&&!s){const e=Je(i.tileAnchorPoint.x,i.tileAnchorPoint.y,i).point,r=a.lineStartIndex+a.segment+1,s=new t.P(i.lineVertexArray.getx(r),i.lineVertexArray.gety(r)),n=Je(s.x,s.y,i),l=n.signedDistanceFromCamera>0?n.point:Ye(i.tileAnchorPoint,s,e,1,i),c=et(e.x,e.y,i,o),u=et(l.x,l.y,i,o),d=Xe(a.writingMode,c,u,h);if(d)return d}const e=at(d*l.getoffsetX(a.glyphStartIndex),_,p,s,a.segment,a.lineStartIndex,a.lineStartIndex+a.lineLength,i,u);if(!e||i.projectionCache.anyProjectionOccluded)return {notEnoughRoom:!0};m=[e];}for(const e of m)t.aD(c,e.point,e.angle);return {}}function Ye(e,t,i,o,a){const r=e.add(e.sub(t)._unit()),s=Je(r.x,r.y,a).point,n=i.sub(s);return i.add(n._mult(o/n.mag()))}function Qe(e,i,o){const a=i.projectionCache;if(a.projections[e])return a.projections[e];const r=new t.P(i.lineVertexArray.getx(e),i.lineVertexArray.gety(e)),s=Je(r.x,r.y,i);if(s.signedDistanceFromCamera>0)return a.projections[e]=s.point,a.anyProjectionOccluded||(a.anyProjectionOccluded=s.isOccluded),s.point;const n=e-o.direction;return Ye(0===o.distanceFromAnchor?i.tileAnchorPoint:new t.P(i.lineVertexArray.getx(n),i.lineVertexArray.gety(n)),r,o.previousVertex,o.absOffsetX-o.distanceFromAnchor+1,i)}function Je(e,t,i){const o=e+i.translation[0],a=t+i.translation[1];let r;return i.pitchWithMap?(r=Ve(o,a,i.pitchedLabelPlaneMatrix,i.getElevation),r.isOccluded=!1):(r=i.transform.projectTileCoordinates(o,a,i.unwrappedTileID,i.getElevation),r.point.x=(.5*r.point.x+.5)*i.width,r.point.y=(.5*-r.point.y+.5)*i.height),r}function et(e,i,o,a){if(o.pitchWithMap){const r=[e,i,0,1];return t.aE(r,r,a),o.transform.projectTileCoordinates(r[0]/r[3],r[1]/r[3],o.unwrappedTileID,o.getElevation).point}return {x:e/o.width*2-1,y:1-i/o.height*2}}function tt(e,t,i){return i.transform.projectTileCoordinates(e,t,i.unwrappedTileID,i.getElevation)}function it(e,t,i){return e._unit()._perp()._mult(t*i)}function ot(e,i,o,a,r,s,n,l,c){if(l.projectionCache.offsets[e])return l.projectionCache.offsets[e];const h=o.add(i);if(e+c.direction<a||e+c.direction>=r)return l.projectionCache.offsets[e]=h,h;const u=Qe(e+c.direction,l,c),d=it(u.sub(o),n,c.direction),_=o.add(d),p=u.add(d);return l.projectionCache.offsets[e]=t.aF(s,h,_,p)||h,l.projectionCache.offsets[e]}function at(e,t,i,o,a,r,s,n,l){const c=o?e-t:e+t;let h=c>0?1:-1,u=0;o&&(h*=-1,u=Math.PI),h<0&&(u+=Math.PI);let d,_=h>0?r+a:r+a+1;n.projectionCache.cachedAnchorPoint?d=n.projectionCache.cachedAnchorPoint:(d=Je(n.tileAnchorPoint.x,n.tileAnchorPoint.y,n).point,n.projectionCache.cachedAnchorPoint=d);let p,m,f=d,g=d,v=0,x=0;const b=Math.abs(c),y=[];let w;for(;v+x<=b;){if(_+=h,_<r||_>=s)return null;v+=x,g=f,m=p;const e={absOffsetX:b,direction:h,distanceFromAnchor:v,previousVertex:g};if(f=Qe(_,n,e),0===i)y.push(g),w=f.sub(g);else {let t;const o=f.sub(g);t=0===o.mag()?it(Qe(_+h,n,e).sub(f),i,h):it(o,i,h),m||(m=g.add(t)),p=ot(_,t,f,r,s,m,i,n,e),y.push(m),w=p.sub(m);}x=w.mag();}const T=w._mult((b-v)/x)._add(m||g),P=u+Math.atan2(f.y-g.y,f.x-g.x);return y.push(T),{point:T,angle:l?P:0,path:y}}const rt=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function st(e,t){for(let i=0;i<e;i++){const e=t.length;t.resize(e+4),t.float32.set(rt,3*e);}}function nt(e,t,i){const o=t[0],a=t[1];return e[0]=i[0]*o+i[4]*a+i[12],e[1]=i[1]*o+i[5]*a+i[13],e[3]=i[3]*o+i[7]*a+i[15],e}const lt=100;class ct{constructor(e,t=new Oe(e.width+200,e.height+200,25),i=new Oe(e.width+200,e.height+200,25)){this.transform=e,this.grid=t,this.ignoredGrid=i,this.pitchFactor=Math.cos(e.pitch*Math.PI/180)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+lt,this.screenBottomBoundary=e.height+lt,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.perspectiveRatioCutoff=.6;}placeCollisionBox(e,t,i,o,a,r,s,n,l,c,h,u){const d=this.projectAndGetPerspectiveRatio(e.anchorPointX+n[0],e.anchorPointY+n[1],a,c,u),_=i*d.perspectiveRatio;let p;if(r||s)p=this._projectCollisionBox(e,_,o,a,r,s,n,d,c,h,u);else {const t=d.x+(h?h.x*_:0),i=d.y+(h?h.y*_:0);p={allPointsOccluded:!1,box:[t+e.x1*_,i+e.y1*_,t+e.x2*_,i+e.y2*_]};}const[m,f,g,v]=p.box,x=r?p.allPointsOccluded:d.isOccluded;let b=x;return b||(b=d.perspectiveRatio<this.perspectiveRatioCutoff),b||(b=!this.isInsideGrid(m,f,g,v)),b||"always"!==t&&this.grid.hitTest(m,f,g,v,t,l)?{box:[m,f,g,v],placeable:!1,offscreen:!1,occluded:x}:{box:[m,f,g,v],placeable:!0,offscreen:this.isOffscreen(m,f,g,v),occluded:x}}placeCollisionCircles(e,i,o,a,r,s,n,l,c,h,u,d,_,p){const m=[],f=new t.P(i.anchorX,i.anchorY),g=this.getPerspectiveRatio(f.x,f.y,s,p),v=(c?r*this.transform.getPitchedTextCorrection(i.anchorX,i.anchorY,s)/g:r*g)/t.aJ,x={getElevation:p,pitchedLabelPlaneMatrix:n,lineVertexArray:o,pitchWithMap:c,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:this.transform,tileAnchorPoint:f,unwrappedTileID:s,width:this.transform.width,height:this.transform.height,translation:_},b=He(v,a,i.lineOffsetX*v,i.lineOffsetY*v,!1,i,!1,x);let y=!1,w=!1,T=!0;if(b){const i=.5*u*g+d,o=new t.P(-100,-100),a=new t.P(this.screenRightBoundary,this.screenBottomBoundary),r=new ke,s=b.first,n=b.last;let _=[];for(let e=s.path.length-1;e>=1;e--)_.push(s.path[e]);for(let e=1;e<n.path.length;e++)_.push(n.path[e]);const p=2.5*i;if(c){const e=this.projectPathToScreenSpace(_,x);_=e.some((e=>e.signedDistanceFromCamera<=0))?[]:e.map((e=>e.point));}let f=[];if(_.length>0){const e=_[0].clone(),i=_[0].clone();for(let t=1;t<_.length;t++)e.x=Math.min(e.x,_[t].x),e.y=Math.min(e.y,_[t].y),i.x=Math.max(i.x,_[t].x),i.y=Math.max(i.y,_[t].y);f=e.x>=o.x&&i.x<=a.x&&e.y>=o.y&&i.y<=a.y?[_]:i.x<o.x||e.x>a.x||i.y<o.y||e.y>a.y?[]:t.aG([_],o.x,o.y,a.x,a.y);}for(const t of f){r.reset(t,.25*i);let o=0;o=r.length<=.5*i?1:Math.ceil(r.paddedLength/p)+1;for(let t=0;t<o;t++){const a=t/Math.max(o-1,1),s=r.lerp(a),n=s.x+lt,c=s.y+lt;m.push(n,c,i,0);const u=n-i,d=c-i,_=n+i,p=c+i;if(T&&(T=this.isOffscreen(u,d,_,p)),w||(w=this.isInsideGrid(u,d,_,p)),"always"!==e&&this.grid.hitTestCircle(n,c,i,e,h)&&(y=!0,!l))return {circles:[],offscreen:!1,collisionDetected:y}}}}return {circles:!l&&y||!w||g<this.perspectiveRatioCutoff?[]:m,offscreen:T,collisionDetected:y}}projectPathToScreenSpace(e,t){const i=function(e,t){const i=Ne;return function(e,t){const i=1/(t[0]*t[5]-t[1]*t[4]);e[0]=t[5]*i,e[1]=-t[1]*i,e[2]=0,e[3]=0,e[4]=-t[4]*i,e[5]=t[0]*i,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1/t[10],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1/t[15];}(i,t.pitchedLabelPlaneMatrix),e.map((e=>{const o=Ve(e.x,e.y,i,t.getElevation),a=t.transform.projectTileCoordinates(o.point.x,o.point.y,t.unwrappedTileID,t.getElevation);return a.point.x=(.5*a.point.x+.5)*t.width,a.point.y=(.5*-a.point.y+.5)*t.height,a}))}(e,t);return function(e){let t=0,i=0,o=0,a=0;for(let r=0;r<e.length;r++)e[r].isOccluded?(o=r+1,a=0):(a++,a>i&&(i=a,t=o));return e.slice(t,t+i)}(i)}queryRenderedSymbols(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return {};const i=[],o=new t.a8;for(const a of e){const e=new t.P(a.x+lt,a.y+lt);o.extend(e),i.push(e);}const{minX:a,minY:r,maxX:s,maxY:n}=o,l=this.grid.query(a,r,s,n).concat(this.ignoredGrid.query(a,r,s,n)),c={},h={};for(const e of l){const o=e.key;if(void 0===c[o.bucketInstanceId]&&(c[o.bucketInstanceId]={}),c[o.bucketInstanceId][o.featureIndex])continue;const a=[new t.P(e.x1,e.y1),new t.P(e.x2,e.y1),new t.P(e.x2,e.y2),new t.P(e.x1,e.y2)];t.aH(i,a)&&(c[o.bucketInstanceId][o.featureIndex]=!0,void 0===h[o.bucketInstanceId]&&(h[o.bucketInstanceId]=[]),h[o.bucketInstanceId].push(o.featureIndex));}return h}insertCollisionBox(e,t,i,o,a,r){(i?this.ignoredGrid:this.grid).insert({bucketInstanceId:o,featureIndex:a,collisionGroupID:r,overlapMode:t},e[0],e[1],e[2],e[3]);}insertCollisionCircles(e,t,i,o,a,r){const s=i?this.ignoredGrid:this.grid,n={bucketInstanceId:o,featureIndex:a,collisionGroupID:r,overlapMode:t};for(let t=0;t<e.length;t+=4)s.insertCircle(n,e[t],e[t+1],e[t+2]);}projectAndGetPerspectiveRatio(e,i,o,a,r){if(r){let o;a?(o=[e,i,a(e,i),1],t.aE(o,o,r)):(o=[e,i,0,1],nt(o,o,r));const s=o[3];return {x:(o[0]/s+1)/2*this.transform.width+lt,y:(-o[1]/s+1)/2*this.transform.height+lt,perspectiveRatio:.5+this.transform.cameraToCenterDistance/s*.5,isOccluded:!1,signedDistanceFromCamera:s}}{const t=this.transform.projectTileCoordinates(e,i,o,a);return {x:(t.point.x+1)/2*this.transform.width+lt,y:(1-t.point.y)/2*this.transform.height+lt,perspectiveRatio:.5+this.transform.cameraToCenterDistance/t.signedDistanceFromCamera*.5,isOccluded:t.isOccluded,signedDistanceFromCamera:t.signedDistanceFromCamera}}}getPerspectiveRatio(e,t,i,o){const a=this.transform.projectTileCoordinates(e,t,i,o);return .5+this.transform.cameraToCenterDistance/a.signedDistanceFromCamera*.5}isOffscreen(e,t,i,o){return i<lt||e>=this.screenRightBoundary||o<lt||t>this.screenBottomBoundary}isInsideGrid(e,t,i,o){return i>=0&&e<this.gridRightBoundary&&o>=0&&t<this.gridBottomBoundary}getViewportMatrix(){const e=t.ap([]);return t.Q(e,e,[-100,-100,0]),e}_projectCollisionBox(e,i,o,a,r,s,n,l,c,h,u){let d=1,_=0,p=0,m=1;const f=e.anchorPointX+n[0],g=e.anchorPointY+n[1];if(s&&!r){const e=this.projectAndGetPerspectiveRatio(f+1,g,a,c,u),t=e.x-l.x,i=Math.atan((e.y-l.y)/t)+(t<0?Math.PI:0),o=Math.sin(i),r=Math.cos(i);d=r,_=o,p=-o,m=r;}else if(!s&&r){const e=Ge(this.transform);d=e.vecEast[0],_=e.vecEast[1],p=e.vecSouth[0],m=e.vecSouth[1];}let v=l.x,x=l.y,b=i;r&&(v=f,x=g,b=Math.pow(2,-(this.transform.zoom-o.overscaledZ)),b*=this.transform.getPitchedTextCorrection(f,g,a),h||(b*=t.al(.5+l.signedDistanceFromCamera/this.transform.cameraToCenterDistance*.5,0,4))),h&&(v+=d*h.x*b+p*h.y*b,x+=_*h.x*b+m*h.y*b);const y=e.x1*b,w=e.x2*b,T=(y+w)/2,P=e.y1*b,C=e.y2*b,M=(P+C)/2,I=[{offsetX:y,offsetY:P},{offsetX:T,offsetY:P},{offsetX:w,offsetY:P},{offsetX:w,offsetY:M},{offsetX:w,offsetY:C},{offsetX:T,offsetY:C},{offsetX:y,offsetY:C},{offsetX:y,offsetY:M}];let E=[];for(const{offsetX:e,offsetY:i}of I)E.push(new t.P(v+d*e+p*i,x+_*e+m*i));let S=!1;if(r){const e=E.map((e=>this.projectAndGetPerspectiveRatio(e.x,e.y,a,c,u)));S=e.some((e=>!e.isOccluded)),E=e.map((e=>new t.P(e.x,e.y)));}else S=!0;return {box:t.aI(E),allPointsOccluded:!S}}}class ht{constructor(e,t,i,o){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):o&&i?1:0,this.placed=i;}isHidden(){return 0===this.opacity&&!this.placed}}class ut{constructor(e,t,i,o,a){this.text=new ht(e?e.text:null,t,i,a),this.icon=new ht(e?e.icon:null,t,o,a);}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class dt{constructor(e,t,i){this.text=e,this.icon=t,this.skipFade=i;}}class _t{constructor(e,t,i,o,a){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=i,this.bucketIndex=o,this.tileID=a;}}class pt{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={};}get(e){if(this.crossSourceCollisions)return {ID:0,predicate:null};if(!this.collisionGroups[e]){const t=++this.maxGroupID;this.collisionGroups[e]={ID:t,predicate:e=>e.collisionGroupID===t};}return this.collisionGroups[e]}}function mt(e,i,o,a,r){const{horizontalAlign:s,verticalAlign:n}=t.aP(e);return new t.P(-(s-.5)*i+a[0]*r,-(n-.5)*o+a[1]*r)}class ft{constructor(e,t,i,o,a){this.transform=e.clone(),this.terrain=t,this.collisionIndex=new ct(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new pt(o),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=a,a&&(a.prevPlacement=void 0),this.placedOrientations={};}_getTerrainElevationFunc(e){const t=this.terrain;return t?(i,o)=>t.getElevation(e,i,o):null}getBucketParts(e,i,o,a){const r=o.getBucket(i),s=o.latestFeatureIndex;if(!r||!s||i.id!==r.layerIds[0])return;const n=o.collisionBoxArray,l=r.layers[0].layout,c=r.layers[0].paint,h=Math.pow(2,this.transform.zoom-o.tileID.overscaledZ),u=o.tileSize/t.a6,d=o.tileID.toUnwrapped(),_="map"===l.get("text-rotation-alignment"),p=t.aK(o,1,this.transform.zoom),m=t.aL(this.collisionIndex.transform,o,c.get("text-translate"),c.get("text-translate-anchor")),f=t.aL(this.collisionIndex.transform,o,c.get("icon-translate"),c.get("icon-translate-anchor")),g=Ze(_,this.transform,p);this.retainedQueryData[r.bucketInstanceId]=new _t(r.bucketInstanceId,s,r.sourceLayerIndex,r.index,o.tileID);const v={bucket:r,layout:l,translationText:m,translationIcon:f,unwrappedTileID:d,pitchedLabelPlaneMatrix:g,scale:h,textPixelRatio:u,holdingForFade:o.holdingForSymbolFade(),collisionBoxArray:n,partiallyEvaluatedTextSize:t.aw(r.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(r.sourceID)};if(a)for(const t of r.sortKeyRanges){const{sortKey:i,symbolInstanceStart:o,symbolInstanceEnd:a}=t;e.push({sortKey:i,symbolInstanceStart:o,symbolInstanceEnd:a,parameters:v});}else e.push({symbolInstanceStart:0,symbolInstanceEnd:r.symbolInstances.length,parameters:v});}attemptAnchorPlacement(e,i,o,a,r,s,n,l,c,h,u,d,_,p,m,f,g,v,x,b){var y,w,T;const P=t.aM[e.textAnchor],C=[e.textOffset0,e.textOffset1],M=mt(P,o,a,C,r),I=this.collisionIndex.placeCollisionBox(i,d,l,c,h,n,s,f,u.predicate,x,M,b);if((!v||this.collisionIndex.placeCollisionBox(v,d,l,c,h,n,s,g,u.predicate,x,M,b).placeable)&&I.placeable){let e;if((null===(y=this.prevPlacement)||void 0===y?void 0:y.variableOffsets[_.crossTileID])&&(null===(T=null===(w=this.prevPlacement)||void 0===w?void 0:w.placements[_.crossTileID])||void 0===T?void 0:T.text)&&(e=this.prevPlacement.variableOffsets[_.crossTileID].anchor),0===_.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[_.crossTileID]={textOffset:C,width:o,height:a,anchor:P,textBoxScale:r,prevAnchor:e},this.markUsedJustification(p,P,_,m),p.allowVerticalPlacement&&(this.markUsedOrientation(p,m,_),this.placedOrientations[_.crossTileID]=m),{shift:M,placedGlyphBoxes:I}}}placeLayerBucketPart(e,i,o){const{bucket:a,layout:r,translationText:s,translationIcon:n,unwrappedTileID:l,pitchedLabelPlaneMatrix:c,textPixelRatio:h,holdingForFade:u,collisionBoxArray:d,partiallyEvaluatedTextSize:_,collisionGroup:p}=e.parameters,m=r.get("text-optional"),f=r.get("icon-optional"),g=t.aN(r,"text-overlap","text-allow-overlap"),v="always"===g,x=t.aN(r,"icon-overlap","icon-allow-overlap"),b="always"===x,y="map"===r.get("text-rotation-alignment"),w="map"===r.get("text-pitch-alignment"),T="none"!==r.get("icon-text-fit"),P="viewport-y"===r.get("symbol-z-order"),C=v&&(b||!a.hasIconData()||f),M=b&&(v||!a.hasTextData()||m);!a.collisionArrays&&d&&a.deserializeCollisionBoxes(d);const I=this.retainedQueryData[a.bucketInstanceId].tileID,E=this._getTerrainElevationFunc(I),S=this.transform.getFastPathSimpleProjectionMatrix(I),z=(e,d,b)=>{var P,z;if(i[e.crossTileID])return;if(u)return void(this.placements[e.crossTileID]=new dt(!1,!1,!1));let R=!1,D=!1,A=!0,L=null,F={box:null,placeable:!1,offscreen:null,occluded:!1},k={placeable:!1},B=null,O=null,j=null,N=0,Z=0,U=0;d.textFeatureIndex?N=d.textFeatureIndex:e.useRuntimeCollisionCircles&&(N=e.featureIndex),d.verticalTextFeatureIndex&&(Z=d.verticalTextFeatureIndex);const G=d.textBox;if(G){const i=i=>{let o=t.ax.horizontal;if(a.allowVerticalPlacement&&!i&&this.prevPlacement){const t=this.prevPlacement.placedOrientations[e.crossTileID];t&&(this.placedOrientations[e.crossTileID]=t,o=t,this.markUsedOrientation(a,o,e));}return o},r=(i,o)=>{if(a.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&d.verticalTextBox){for(const e of a.writingModes)if(e===t.ax.vertical?(F=o(),k=F):F=i(),null==F?void 0:F.placeable)break}else F=i();},c=e.textAnchorOffsetStartIndex,u=e.textAnchorOffsetEndIndex;if(u===c){const o=(t,i)=>{const o=this.collisionIndex.placeCollisionBox(t,g,h,I,l,w,y,s,p.predicate,E,void 0,S);return (null==o?void 0:o.placeable)&&(this.markUsedOrientation(a,i,e),this.placedOrientations[e.crossTileID]=i),o};r((()=>o(G,t.ax.horizontal)),(()=>{const i=d.verticalTextBox;return a.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&i?o(i,t.ax.vertical):{box:null,offscreen:null}})),i(null==F?void 0:F.placeable);}else {let _=t.aM[null===(z=null===(P=this.prevPlacement)||void 0===P?void 0:P.variableOffsets[e.crossTileID])||void 0===z?void 0:z.anchor];const m=(t,i,r)=>{const d=t.x2-t.x1,m=t.y2-t.y1,f=e.textBoxScale,v=T&&"never"===x?i:null;let b=null,P="never"===g?1:2,C="never";_&&P++;for(let i=0;i<P;i++){for(let i=c;i<u;i++){const o=a.textAnchorOffsets.get(i);if(_&&o.textAnchor!==_)continue;const c=this.attemptAnchorPlacement(o,t,d,m,f,y,w,h,I,l,p,C,e,a,r,s,n,v,E);if(c&&(b=c.placedGlyphBoxes,null==b?void 0:b.placeable))return R=!0,L=c.shift,b}_?_=null:C=g;}return o&&!b&&(b={box:this.collisionIndex.placeCollisionBox(G,"always",h,I,l,w,y,s,p.predicate,E,void 0,S).box,offscreen:!1,placeable:!1,occluded:!1}),b};r((()=>m(G,d.iconBox,t.ax.horizontal)),(()=>{const i=d.verticalTextBox;return a.allowVerticalPlacement&&!(null==F?void 0:F.placeable)&&e.numVerticalGlyphVertices>0&&i?m(i,d.verticalIconBox,t.ax.vertical):{box:null,occluded:!0,offscreen:null}})),F&&(R=F.placeable,A=F.offscreen);const f=i(null==F?void 0:F.placeable);if(!R&&this.prevPlacement){const t=this.prevPlacement.variableOffsets[e.crossTileID];t&&(this.variableOffsets[e.crossTileID]=t,this.markUsedJustification(a,t.anchor,e,f));}}}if(B=F,R=null==B?void 0:B.placeable,A=null==B?void 0:B.offscreen,e.useRuntimeCollisionCircles&&e.centerJustifiedTextSymbolIndex>=0){const i=a.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),n=t.ay(a.textSizeData,_,i),h=r.get("text-padding");O=this.collisionIndex.placeCollisionCircles(g,i,a.lineVertexArray,a.glyphOffsetArray,n,l,c,o,w,p.predicate,e.collisionCircleDiameter,h,s,E),O.circles.length&&O.collisionDetected&&!o&&t.w("Collisions detected, but collision boxes are not shown"),R=v||O.circles.length>0&&!O.collisionDetected,A&&(A=O.offscreen);}if(d.iconFeatureIndex&&(U=d.iconFeatureIndex),d.iconBox){const e=e=>this.collisionIndex.placeCollisionBox(e,x,h,I,l,w,y,n,p.predicate,E,T&&L?L:void 0,S);k&&k.placeable&&d.verticalIconBox?(j=e(d.verticalIconBox),D=j.placeable):(j=e(d.iconBox),D=j.placeable),A&&(A=j.offscreen);}const V=m||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,W=f||0===e.numIconVertices;V||W?W?V||D&&(D=R):R=D&&R:D=R=D&&R;const q=D&&j.placeable;if(R&&B.placeable&&this.collisionIndex.insertCollisionBox(B.box,g,r.get("text-ignore-placement"),a.bucketInstanceId,k&&k.placeable&&Z?Z:N,p.ID),q&&this.collisionIndex.insertCollisionBox(j.box,x,r.get("icon-ignore-placement"),a.bucketInstanceId,U,p.ID),O&&R&&this.collisionIndex.insertCollisionCircles(O.circles,g,r.get("text-ignore-placement"),a.bucketInstanceId,N,p.ID),o&&this.storeCollisionData(a.bucketInstanceId,b,d,B,j,O),0===e.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");if(0===a.bucketInstanceId)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[e.crossTileID]=new dt((R||C)&&!(null==B?void 0:B.occluded),(D||M)&&!(null==j?void 0:j.occluded),A||a.justReloaded),i[e.crossTileID]=!0;};if(P){if(0!==e.symbolInstanceStart)throw new Error("bucket.bucketInstanceId should be 0");const t=a.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let e=t.length-1;e>=0;--e){const i=t[e];z(a.symbolInstances.get(i),a.collisionArrays[i],i);}}else for(let t=e.symbolInstanceStart;t<e.symbolInstanceEnd;t++)z(a.symbolInstances.get(t),a.collisionArrays[t],t);a.justReloaded=!1;}storeCollisionData(e,t,i,o,a,r){if(i.textBox||i.iconBox){let r,s;this.collisionBoxArrays.has(e)?r=this.collisionBoxArrays.get(e):(r=new Map,this.collisionBoxArrays.set(e,r)),r.has(t)?s=r.get(t):(s={text:null,icon:null},r.set(t,s)),i.textBox&&(s.text=o.box),i.iconBox&&(s.icon=a.box);}if(r){let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=[]);for(let e=0;e<r.circles.length;e+=4)t.push(r.circles[e+0]-lt),t.push(r.circles[e+1]-lt),t.push(r.circles[e+2]),t.push(r.collisionDetected?1:0);}}markUsedJustification(e,i,o,a){let r;r=a===t.ax.vertical?o.verticalPlacedTextSymbolIndex:{left:o.leftJustifiedTextSymbolIndex,center:o.centerJustifiedTextSymbolIndex,right:o.rightJustifiedTextSymbolIndex}[t.aO(i)];const s=[o.leftJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.rightJustifiedTextSymbolIndex,o.verticalPlacedTextSymbolIndex];for(const t of s)t>=0&&(e.text.placedSymbolArray.get(t).crossTileID=r>=0&&t!==r?0:o.crossTileID);}markUsedOrientation(e,i,o){const a=i===t.ax.horizontal||i===t.ax.horizontalOnly?i:0,r=i===t.ax.vertical?i:0,s=[o.leftJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.rightJustifiedTextSymbolIndex];for(const t of s)e.text.placedSymbolArray.get(t).placedOrientation=a;o.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(o.verticalPlacedTextSymbolIndex).placedOrientation=r);}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let i=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const o=t?t.symbolFadeChange(e):1,a=t?t.opacities:{},r=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],r=a[e];r?(this.opacities[e]=new ut(r,o,t.text,t.icon),i||(i=t.text!==r.text.placed),i||(i=t.icon!==r.icon.placed)):(this.opacities[e]=new ut(null,o,t.text,t.icon,t.skipFade),i||(i=t.text||t.icon));}for(const e in a){const t=a[e];if(!this.opacities[e]){const a=new ut(t,o,!1,!1);a.isHidden()||(this.opacities[e]=a,i||(i=t.text.placed),i||(i=t.icon.placed));}}for(const e in r)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=r[e]);for(const e in s)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=s[e]);if(t&&void 0===t.lastPlacementChangeTime)throw new Error("Last placement time for previous placement is not defined");i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e);}updateLayerOpacities(e,t){const i={};for(const o of t){const t=o.getBucket(e);t&&o.latestFeatureIndex&&e.id===t.layerIds[0]&&this.updateBucketOpacities(t,o.tileID,i,o.collisionBoxArray);}}updateBucketOpacities(e,i,o,a){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const r=e.layers[0],s=r.layout,n=new ut(null,0,!1,!1,!0),l=s.get("text-allow-overlap"),c=s.get("icon-allow-overlap"),h=r._unevaluatedLayout.hasValue("text-variable-anchor")||r._unevaluatedLayout.hasValue("text-variable-anchor-offset"),u="map"===s.get("text-rotation-alignment"),d="map"===s.get("text-pitch-alignment"),_="none"!==s.get("icon-text-fit"),p=new ut(null,0,l&&(c||!e.hasIconData()||s.get("icon-optional")),c&&(l||!e.hasTextData()||s.get("text-optional")),!0);!e.collisionArrays&&a&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(a);const m=(e,t,i)=>{for(let o=0;o<t/4;o++)e.opacityVertexArray.emplaceBack(i);e.hasVisibleVertices||(e.hasVisibleVertices=i!==Mt);},f=this.collisionBoxArrays.get(e.bucketInstanceId);for(let i=0;i<e.symbolInstances.length;i++){const a=e.symbolInstances.get(i),{numHorizontalGlyphVertices:r,numVerticalGlyphVertices:s,crossTileID:l}=a;let c=this.opacities[l];o[l]?c=n:c||(c=p,this.opacities[l]=c),o[l]=!0;const g=a.numIconVertices>0,v=this.placedOrientations[a.crossTileID],x=v===t.ax.vertical,b=v===t.ax.horizontal||v===t.ax.horizontalOnly;if(r>0||s>0){const t=Ct(c.text);m(e.text,r,x?Mt:t),m(e.text,s,b?Mt:t);const i=c.text.isHidden(),o=[a.rightJustifiedTextSymbolIndex,a.centerJustifiedTextSymbolIndex,a.leftJustifiedTextSymbolIndex];for(const t of o)t>=0&&(e.text.placedSymbolArray.get(t).hidden=i||x?1:0);a.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(a.verticalPlacedTextSymbolIndex).hidden=i||b?1:0);const n=this.variableOffsets[a.crossTileID];n&&this.markUsedJustification(e,n.anchor,a,v);const l=this.placedOrientations[a.crossTileID];l&&(this.markUsedJustification(e,"left",a,l),this.markUsedOrientation(e,l,a));}if(g){const t=Ct(c.icon),i=!(_&&a.verticalPlacedIconSymbolIndex&&x);a.placedIconSymbolIndex>=0&&(m(e.icon,a.numIconVertices,i?t:Mt),e.icon.placedSymbolArray.get(a.placedIconSymbolIndex).hidden=c.icon.isHidden()),a.verticalPlacedIconSymbolIndex>=0&&(m(e.icon,a.numVerticalIconVertices,i?Mt:t),e.icon.placedSymbolArray.get(a.verticalPlacedIconSymbolIndex).hidden=c.icon.isHidden());}const y=(null==f?void 0:f.has(i))?f.get(i):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const o=e.collisionArrays[i];if(o){let i=new t.P(0,0);if(o.textBox||o.verticalTextBox){let t=!0;if(h){const e=this.variableOffsets[l];e?(i=mt(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),u&&i._rotate(d?-this.transform.bearingInRadians:this.transform.bearingInRadians)):t=!1;}if(o.textBox||o.verticalTextBox){let a;o.textBox&&(a=x),o.verticalTextBox&&(a=b),gt(e.textCollisionBox.collisionVertexArray,c.text.placed,!t||a,y.text,i.x,i.y);}}if(o.iconBox||o.verticalIconBox){const t=Boolean(!b&&o.verticalIconBox);let a;o.iconBox&&(a=t),o.verticalIconBox&&(a=!t),gt(e.iconCollisionBox.collisionVertexArray,c.icon.placed,a,y.icon,_?i.x:0,_?i.y:0);}}}}if(e.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);e.bucketInstanceId in this.collisionCircleArrays&&(e.collisionCircleArray=this.collisionCircleArrays[e.bucketInstanceId],delete this.collisionCircleArrays[e.bucketInstanceId]);}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(e,t){const i=this.zoomAtLastRecencyCheck===t?1-this.zoomAdjustment(t):1;return this.zoomAtLastRecencyCheck=t,this.commitTime+this.fadeDuration*i>e}setStale(){this.stale=!0;}}function gt(e,t,i,o,a,r){o&&0!==o.length||(o=[0,0,0,0]);const s=o[0]-lt,n=o[1]-lt,l=o[2]-lt,c=o[3]-lt;e.emplaceBack(t?1:0,i?1:0,a||0,r||0,s,n),e.emplaceBack(t?1:0,i?1:0,a||0,r||0,l,n),e.emplaceBack(t?1:0,i?1:0,a||0,r||0,l,c),e.emplaceBack(t?1:0,i?1:0,a||0,r||0,s,c);}const vt=Math.pow(2,25),xt=Math.pow(2,24),bt=Math.pow(2,17),yt=Math.pow(2,16),wt=Math.pow(2,9),Tt=Math.pow(2,8),Pt=Math.pow(2,1);function Ct(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const t=e.placed?1:0,i=Math.floor(127*e.opacity);return i*vt+t*xt+i*bt+t*yt+i*wt+t*Tt+i*Pt+t}const Mt=0;class It{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&!e.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[];}continuePlacement(e,t,i,o,a){const r=this._bucketParts;for(;this._currentTileIndex<e.length;)if(t.getBucketParts(r,o,e[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,a())return !0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,r.sort(((e,t)=>e.sortKey-t.sortKey)));this._currentPartIndex<r.length;)if(t.placeLayerBucketPart(r[this._currentPartIndex],this._seenCrossTileIDs,i),this._currentPartIndex++,a())return !0;return !1}}class Et{constructor(e,t,i,o,a,r,s,n){this.placement=new ft(e,t,r,s,n),this._currentPlacementIndex=i.length-1,this._forceFullPlacement=o,this._showCollisionBoxes=a,this._done=!1;}isDone(){return this._done}continuePlacement(e,i,o){const a=c(),r=()=>!this._forceFullPlacement&&c()-a>2;for(;this._currentPlacementIndex>=0;){const a=i[e[this._currentPlacementIndex]],s=this.placement.collisionIndex.transform.zoom;if(t.aQ(a)&&a.layout&&(!a.minzoom||a.minzoom<=s)&&(!a.maxzoom||a.maxzoom>s)){if(this._inProgressLayer||(this._inProgressLayer=new It(a)),this._inProgressLayer.continuePlacement(o[a.source],this.placement,this._showCollisionBoxes,a,r))return;delete this._inProgressLayer;}this._currentPlacementIndex--;}this._done=!0;}commit(e){return this.placement.commit(e),this.placement}}const St=512/t.a6/2;class zt{constructor(e,i,o){this.tileID=e,this.bucketInstanceId=o,this._symbolsByKey={};const a=new Map;for(let e=0;e<i.length;e++){const t=i.get(e),o=t.key,r=a.get(o);r?r.push(t):a.set(o,[t]);}for(const[e,i]of a){const o={positions:i.map((e=>({x:Math.floor(e.anchorX*St),y:Math.floor(e.anchorY*St)}))),crossTileIDs:i.map((e=>e.crossTileID))};if(o.positions.length>128){const e=new t.aR(o.positions.length,16,Uint16Array);for(const{x:t,y:i}of o.positions)e.add(t,i);e.finish(),delete o.positions,o.index=e;}this._symbolsByKey[e]=o;}}getScaledCoordinates(e,i){const{x:o,y:a,z:r}=this.tileID.canonical,{x:s,y:n,z:l}=i.canonical,c=St/Math.pow(2,l-r),h=(n*t.a6+e.anchorY)*c,u=a*t.a6*St;return {x:Math.floor((s*t.a6+e.anchorX)*c-o*t.a6*St),y:Math.floor(h-u)}}findMatches(e,t,i){const o=this.tileID.canonical.z<t.canonical.z?1:Math.pow(2,this.tileID.canonical.z-t.canonical.z);for(let a=0;a<e.length;a++){const r=e.get(a);if(r.crossTileID)continue;const s=this._symbolsByKey[r.key];if(!s)continue;const n=this.getScaledCoordinates(r,t);if(s.index){const e=s.index.range(n.x-o,n.y-o,n.x+o,n.y+o).sort();for(const t of e){const e=s.crossTileIDs[t];if(!i[e]){i[e]=!0,r.crossTileID=e;break}}}else if(s.positions)for(let e=0;e<s.positions.length;e++){const t=s.positions[e],a=s.crossTileIDs[e];if(Math.abs(t.x-n.x)<=o&&Math.abs(t.y-n.y)<=o&&!i[a]){i[a]=!0,r.crossTileID=a;break}}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map((({crossTileIDs:e})=>e))}}class Rt{constructor(){this.maxCrossTileID=0;}generate(){return ++this.maxCrossTileID}}class Dt{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0;}handleWrapJump(e){const t=Math.round((e-this.lng)/360);if(0!==t)for(const e in this.indexes){const i=this.indexes[e],o={};for(const e in i){const a=i[e];a.tileID=a.tileID.unwrapTo(a.tileID.wrap+t),o[a.tileID.key]=a;}this.indexes[e]=o;}this.lng=e;}addBucket(e,t,i){var o,a,r;if(null===(o=this.indexes[e.overscaledZ])||void 0===o?void 0:o[e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===t.bucketInstanceId)return !1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key]);}for(let e=0;e<t.symbolInstances.length;e++)t.symbolInstances.get(e).crossTileID=0;(a=this.usedCrossTileIDs)[r=e.overscaledZ]||(a[r]={});const s=this.usedCrossTileIDs[e.overscaledZ];for(const i in this.indexes){const o=this.indexes[i];if(Number(i)>e.overscaledZ)for(const i in o){const a=o[i];a.tileID.isChildOf(e)&&a.findMatches(t.symbolInstances,e,s);}else {const a=o[e.scaledTo(Number(i)).key];a&&a.findMatches(t.symbolInstances,e,s);}}for(let e=0;e<t.symbolInstances.length;e++){const o=t.symbolInstances.get(e);o.crossTileID||(o.crossTileID=i.generate(),s[o.crossTileID]=!0);}return void 0===this.indexes[e.overscaledZ]&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new zt(e,t.symbolInstances,t.bucketInstanceId),!0}removeBucketCrossTileIDs(e,t){for(const i of t.getCrossTileIDsLists())for(const t of i)delete this.usedCrossTileIDs[e][t];}removeStaleBuckets(e){let t=!1;for(const i in this.indexes){const o=this.indexes[i];for(const a in o)e[o[a].bucketInstanceId]||(this.removeBucketCrossTileIDs(i,o[a]),delete o[a],t=!0);}return t}}class At{constructor(){this.layerIndexes={},this.crossTileIDs=new Rt,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={};}addLayer(e,t,i){let o=this.layerIndexes[e.id];void 0===o&&(o=this.layerIndexes[e.id]=new Dt);let a=!1;const r={};o.handleWrapJump(i);for(const i of t){const t=i.getBucket(e);e.id===(null==t?void 0:t.layerIds[0])&&(t.bucketInstanceId||(this.maxBucketInstanceId+=1,t.bucketInstanceId=this.maxBucketInstanceId),o.addBucket(i.tileID,t,this.crossTileIDs)&&(a=!0),r[t.bucketInstanceId]=!0);}return o.removeStaleBuckets(r)&&(a=!0),a}pruneUnusedLayers(e){const t={};for(const i of e)t[i]=!0;for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e];}}var Lt="void main() {fragColor=vec4(1.0);}";const Ft={prelude:kt("#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nout highp vec4 fragColor;","#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}mat3 rotationMatrixFromAxisAngle(vec3 u,float angle) {float c=cos(angle);float s=sin(angle);float c2=1.0-c;return mat3(u.x*u.x*c2+ c,u.x*u.y*c2-u.z*s,u.x*u.z*c2+u.y*s,u.y*u.x*c2+u.z*s,u.y*u.y*c2+ c,u.y*u.z*c2-u.x*s,u.z*u.x*c2-u.y*s,u.z*u.y*c2+u.x*s,u.z*u.z*c2+ c\n);}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\n#else\nreturn 1.0;\n#endif\n}float ele(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\n#ifdef GLOBE\nif ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}\n#endif\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}const float PI=3.141592653589793;uniform mat4 u_projection_matrix;"),projectionMercator:kt("","float projectLineThickness(float tileY) {return 1.0;}float projectCircleRadius(float tileY) {return 1.0;}vec4 projectTile(vec2 p) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);return result;}vec4 projectTile(vec2 p,vec2 rawPos) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);if (rawPos.y <-32767.5 || rawPos.y > 32766.5) {result.z=-10000000.0;}return result;}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_projection_matrix*vec4(posInTile,elevation,1.0);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {return projectTileWithElevation(posInTile,elevation);}"),projectionGlobe:kt("","#define GLOBE_RADIUS 6371008.8\nuniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos\n);}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float spherical_y=2.0*atan(exp(PI-(mercator_pos_y*PI*2.0)))-PI*0.5;return cos(spherical_y);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY); \nif (u_projection_transition < 0.999) {return mix(1.0,thickness,u_projection_transition);} else {return thickness;}}vec3 projectToSphere(vec2 translatedPos,vec2 rawPos) {vec2 mercator_pos=u_projection_tile_mercator_coords.xy+u_projection_tile_mercator_coords.zw*translatedPos;vec2 spherical;spherical.x=mercator_pos.x*PI*2.0+PI;spherical.y=2.0*atan(exp(PI-(mercator_pos.y*PI*2.0)))-PI*0.5;float len=cos(spherical.y);vec3 pos=vec3(sin(spherical.x)*len,sin(spherical.y),cos(spherical.x)*len\n);if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}"),background:kt("uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),backgroundPattern:kt("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:kt("in vec3 v_data;in float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;uniform vec2 u_translate;in vec2 a_pos;out vec3 v_data;out float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 pos_raw=a_pos+32768.0;vec2 extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);vec2 circle_center=floor(pos_raw/8.0)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) {\n#ifdef GLOBE\nvec3 center_vector=projectToSphere(circle_center);\n#endif\nfloat angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else {\n#ifdef GLOBE\nvec4 projected_center=interpolateProjection(circle_center,center_vector,ele);\n#else\nvec4 projected_center=projectTileWithElevation(circle_center,ele);\n#endif\ncorner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);}\n#ifdef GLOBE\nvec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);\n#else\ngl_Position=projectTileWithElevation(corner_position,ele);\n#endif\n} else {gl_Position=projectTileWithElevation(circle_center,ele);if (gl_Position.z/gl_Position.w > 1.0) {gl_Position.xy=vec2(10000.0);}if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}"),clippingMask:kt(Lt,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:kt("uniform highp float u_intensity;in vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);fragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;in vec2 a_pos;out vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 pos_raw=a_pos+32768.0;vec2 unscaled_extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 circle_center=floor(pos_raw/8.0);\n#ifdef GLOBE\nvec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphere(circle_center);vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0);\n#else\ngl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));\n#endif\n}"),heatmapTexture:kt("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));fragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(0.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:kt("in float v_placed;in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}","in vec2 a_anchor_pos;in vec2 a_placed;in vec2 a_box_real;uniform vec2 u_pixel_extrude_scale;out float v_placed;out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:kt("in float v_radius;in vec2 v_extrude;in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);fragColor=color*alpha*opacity_t;}","in vec2 a_pos;in float a_radius;in vec2 a_flags;uniform vec2 u_viewport_size;out float v_radius;out vec2 v_extrude;out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),colorRelief:kt("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;uniform vec4 u_unpack;uniform sampler2D u_elevation_stops;uniform sampler2D u_color_stops;uniform int u_color_ramp_size;uniform float u_opacity;in vec2 v_pos;float getElevation(vec2 coord) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}float getElevationStop(int stop) {float x=(float(stop)+0.5)/float(u_color_ramp_size);vec4 data=texture(u_elevation_stops,vec2(x,0))*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {float el=getElevation(v_pos);int r=(u_color_ramp_size-1);int l=0;float el_l=getElevationStop(l);float el_r=getElevationStop(r);while(r-l > 1){int m=(r+l)/2;float el_m=getElevationStop(m);if(el < el_m){r=m;el_r=el_m;}else\n{l=m;el_l=el_m;}}float x=(float(l)+(el-el_l)/(el_r-el_l)+0.5)/float(u_color_ramp_size);fragColor=u_opacity*texture(u_color_stops,vec2(x,0));\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_dimension;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_pos/8192.0)*scale+epsilon;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),debug:kt("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}","in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}"),depth:kt(Lt,"in vec2 a_pos;void main() {\n#ifdef GLOBE\ngl_Position=projectTileFor3D(a_pos,0.0);\n#else\ngl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);\n#endif\n}"),fill:kt("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nfragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_fill_translate;in vec2 a_pos;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=projectTile(a_pos+u_fill_translate,a_pos);}"),fillOutline:kt("in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=outline_color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillOutlinePattern:kt("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillPattern:kt("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}"),fillExtrusion:kt("in vec4 v_color;void main() {fragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\nout vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 normal=a_normal_ed.xyz;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nfloat colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);\n#ifdef GLOBE\nmat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);\n#endif\ndirectional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}"),fillExtrusionPattern:kt("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\n#ifdef GLOBE\nout vec3 v_sphere_pos;\n#endif\nout vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nvec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\n: vec2(edgedistance,elevation*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}"),hillshadePrepare:kt("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {vec2 epsilon=1.0/u_dimension;float tileSize=u_dimension.x-2.0;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))*tileSize/pow(2.0,exaggeration+(28.2562-u_zoom));fragColor=clamp(vec4(deriv.x/8.0+0.5,deriv.y/8.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:kt("uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform float u_exaggeration;uniform vec4 u_accent;uniform int u_method;uniform float u_altitudes[NUM_ILLUMINATION_SOURCES];uniform float u_azimuths[NUM_ILLUMINATION_SOURCES];uniform vec4 u_shadows[NUM_ILLUMINATION_SOURCES];uniform vec4 u_highlights[NUM_ILLUMINATION_SOURCES];\n#define PI 3.141592653589793\n#define STANDARD 0\n#define COMBINED 1\n#define IGOR 2\n#define MULTIDIRECTIONAL 3\n#define BASIC 4\nfloat get_aspect(vec2 deriv){return deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);}void igor_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float aspect=get_aspect(deriv);float azimuth=u_azimuths[0]+PI;float slope_stength=atan(length(deriv))*2.0/PI;float aspect_strength=1.0-abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);float shadow_strength=slope_stength*aspect_strength;float highlight_strength=slope_stength*(1.0-aspect_strength);fragColor=u_shadows[0]*shadow_strength+u_highlights[0]*highlight_strength;}void standard_hillshade(vec2 deriv){float azimuth=u_azimuths[0]+PI;float slope=atan(0.625*length(deriv));float aspect=get_aspect(deriv);float intensity=u_exaggeration;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadows[0],u_highlights[0],shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;}void basic_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor=u_highlights[0]*(2.0*shade-1.0);}else\n{fragColor=u_shadows[0]*(1.0-2.0*shade);}}void multidirectional_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;fragColor=vec4(0,0,0,0);for(int i=0; i < NUM_ILLUMINATION_SOURCES; i++){float cos_alt=cos(u_altitudes[i]);float sin_alt=sin(u_altitudes[i]);float cos_az=-cos(u_azimuths[i]);float sin_az=-sin(u_azimuths[i]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor+=u_highlights[i]*(2.0*shade-1.0)/float(NUM_ILLUMINATION_SOURCES);}else\n{fragColor+=u_shadows[i]*(1.0-2.0*shade)/float(NUM_ILLUMINATION_SOURCES);}}}void combined_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=acos((sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv)));cang=clamp(cang,0.0,PI/2.0);float shade=cang*atan(length(deriv))*4.0/PI/PI;float highlight=(PI/2.0-cang)*atan(length(deriv))*4.0/PI/PI;fragColor=u_shadows[0]*shade+u_highlights[0]*highlight;}void main() {vec4 pixel=texture(u_image,v_pos);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));vec2 deriv=((pixel.rg*8.0)-4.0)/scaleFactor;if (u_method==BASIC) {basic_hillshade(deriv);} else if (u_method==COMBINED) {combined_hillshade(deriv);} else if (u_method==IGOR) {igor_hillshade(deriv);} else if (u_method==MULTIDIRECTIONAL) {multidirectional_hillshade(deriv);} else if (u_method==STANDARD) {standard_hillshade(deriv);} else {standard_hillshade(deriv);}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),line:kt("uniform lowp float u_device_pixel_ratio;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),lineGradient:kt("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),linePattern:kt("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;in float v_width;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture(u_image,pos_a),texture(u_image,pos_b),u_fade);fragColor=color*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;out float v_width;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),lineSDF:kt("uniform lowp float u_device_pixel_ratio;uniform lowp float u_lineatlas_width;uniform sampler2D u_image;uniform float u_mix;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture(u_image,v_tex_a).a;float sdfdist_b=texture(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0/u_device_pixel_ratio)/min(dasharray_from.w,dasharray_to.w);alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),lineGradientSDF:kt("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform sampler2D u_image_dash;uniform float u_mix;uniform lowp float u_lineatlas_width;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);float sdfdist_a=texture(u_image_dash,v_tex_a).a;float sdfdist_b=texture(u_image_dash,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0)/min(dasharray_from.w,dasharray_to.w);float dash_alpha=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*dash_alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;out vec2 v_tex_a;out vec2 v_tex_b;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;float texel_height=1.0/u_image_height;float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),raster:kt("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec2 v_pos0;in vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture(u_image0,v_pos0);vec4 color1=texture(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;in vec2 a_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 position=mix(mix(u_coords_top.xy,u_coords_top.zw,fractionalPos.x),mix(u_coords_bottom.xy,u_coords_bottom.zw,fractionalPos.x),fractionalPos.y);gl_Position=projectTile(position,position);v_pos0=((fractionalPos-0.5)/u_buffer_scale)+0.5;\n#ifdef GLOBE\nif (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;}\n#endif\nv_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:kt("uniform sampler2D u_texture;in vec2 v_tex;in float v_total_opacity;void main() {fragColor=texture(u_texture,v_tex)*v_total_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_tex;out float v_total_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_total_opacity=opacity*max(0.0,min(visibility,fade_opacity[0]+fade_change));if (v_total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;}"),symbolSDF:kt("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform bool u_is_plain;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;in vec2 v_data0;in vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float total_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;lowp float dist=texture(u_texture,tex).a;lowp vec4 color_alpha_out_text,color_alpha_out_halo;if (u_is_plain){highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);color_alpha_out_text=total_opacity*alpha*fill_color;}if (u_is_halo) {float gamma_halo=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);float inner_edge_halo=inner_edge+gamma_halo*gamma_scale;highp float gamma_scaled_halo=gamma_halo*gamma_scale;highp float alpha_halo=smoothstep(inner_edge_halo-gamma_scaled_halo,inner_edge_halo+gamma_scaled_halo,dist);highp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha_halo= min(smoothstep(halo_edge-gamma_scaled_halo,halo_edge+gamma_scaled_halo,dist),1.0-alpha_halo);color_alpha_out_halo=total_opacity*alpha_halo*halo_color;}if (u_is_plain && u_is_halo) {fragColor=color_alpha_out_text+(1.-color_alpha_out_text.a)*color_alpha_out_halo;} else if (u_is_halo){fragColor=color_alpha_out_halo;} else {fragColor=color_alpha_out_text;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_data0;out vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy/16.0;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));float total_opacity=opacity*interpolated_fade_opacity;if (total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,total_opacity);}"),symbolTextAndIcon:kt("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform bool u_is_text;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;in vec4 v_data0;in vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat total_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;fragColor=texture(u_texture_icon,tex_icon)*total_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;lowp float dist=texture(u_texture,tex).a;lowp vec4 color_alpha_out,color_alpha_out_halo;if (u_is_text) {highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);color_alpha_out=fill_color*(alpha*total_opacity);}if (u_is_halo) {highp float gamma_halo=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);lowp float buff_halo=(6.0-halo_width/fontScale)/SDF_PX;highp float gamma_scaled_halo=gamma_halo*gamma_scale;highp float alpha_halo=smoothstep(buff_halo-gamma_scaled_halo,buff_halo+gamma_scaled_halo,dist);color_alpha_out_halo=halo_color*(alpha_halo*total_opacity);}if (u_is_text && u_is_halo) {fragColor=color_alpha_out+(1.-color_alpha_out.a)*color_alpha_out_halo;} else if (u_is_halo) {fragColor=color_alpha_out_halo;} else {fragColor=color_alpha_out;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec4 v_data0;out vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));float total_opacity=opacity*interpolated_fade_opacity;if (total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map && !u_is_along_line) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,total_opacity,is_sdf);}"),terrain:kt("uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;uniform bool u_is_globe_mode;in vec2 v_texture_pos;in float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture(u_texture,vec2(v_texture_pos.x,1.0-v_texture_pos.y));if (!u_is_globe_mode && u_fog_ground_blend_opacity > 0.0 && v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);fragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {fragColor=surface_color;}}","in vec3 a_pos3d;uniform mat4 u_fog_matrix;uniform float u_ele_delta;out vec2 v_texture_pos;out float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}"),terrainDepth:kt("in float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {fragColor=pack(v_depth);}","in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}"),terrainCoords:kt("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;in vec2 v_texture_pos;void main() {vec4 rgba=texture(u_texture,v_texture_pos);fragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}","in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);}"),projectionErrorMeasurement:kt("in vec4 v_output_error_encoded;void main() {fragColor=v_output_error_encoded;}","in vec2 a_pos;uniform highp float u_input;uniform highp float u_output_expected;out vec4 v_output_error_encoded;void main() {float real_output=2.0*atan(exp(PI-(u_input*PI*2.0)))-PI*0.5;float error=real_output-u_output_expected;float abs_error=abs(error)*128.0;v_output_error_encoded.x=min(floor(abs_error*256.0),255.0)/255.0;abs_error-=v_output_error_encoded.x;v_output_error_encoded.y=min(floor(abs_error*65536.0),255.0)/255.0;abs_error-=v_output_error_encoded.x/255.0;v_output_error_encoded.z=min(floor(abs_error*16777216.0),255.0)/255.0;v_output_error_encoded.w=error >=0.0 ? 1.0 : 0.0;gl_Position=vec4(a_pos,0.0,1.0);}"),atmosphere:kt("#ifdef GL_ES\nprecision highp float;\n#endif\nin vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758\n);color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}","in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}"),sky:kt("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor=mix(fragColor,vec4(vec3(0.0),0.0),u_sky_blend);}","in vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}")};function kt(e,t){const i=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,o=t.match(/in ([\w]+) ([\w]+)/g),a=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),r=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),s=r?r.concat(a):a,n={};return {fragmentSource:e=e.replace(i,((e,t,i,o,a)=>(n[a]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${a}\nin ${i} ${o} ${a};\n#else\nuniform ${i} ${o} u_${a};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${a}\n ${i} ${o} ${a} = u_${a};\n#endif\n`))),vertexSource:t=t.replace(i,((e,t,i,o,a)=>{const r="float"===o?"vec2":"vec4",s=a.match(/color/)?"color":r;return n[a]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${a}\nuniform lowp float u_${a}_t;\nin ${i} ${r} a_${a};\nout ${i} ${o} ${a};\n#else\nuniform ${i} ${o} u_${a};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${a}\n ${a} = a_${a};\n#else\n ${i} ${o} ${a} = u_${a};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${a}\n ${a} = unpack_mix_${s}(a_${a}, u_${a}_t);\n#else\n ${i} ${o} ${a} = u_${a};\n#endif\n`:"define"===t?`\n#ifndef HAS_UNIFORM_u_${a}\nuniform lowp float u_${a}_t;\nin ${i} ${r} a_${a};\n#else\nuniform ${i} ${o} u_${a};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${a}\n ${i} ${o} ${a} = a_${a};\n#else\n ${i} ${o} ${a} = u_${a};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${a}\n ${i} ${o} ${a} = unpack_mix_${s}(a_${a}, u_${a}_t);\n#else\n ${i} ${o} ${a} = u_${a};\n#endif\n`})),staticAttributes:o,staticUniforms:s}}class Bt{constructor(e,t,i){this.vertexBuffer=e,this.indexBuffer=t,this.segments=i;}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null;}}var Ot=t.aS([{name:"a_pos",type:"Int16",components:2}]);const jt="#define PROJECTION_MERCATOR",Nt="mercator";class Zt{constructor(){this._cachedMesh=null;}get name(){return "mercator"}get useSubdivision(){return !1}get shaderVariantName(){return Nt}get shaderDefine(){return jt}get shaderPreludeCode(){return Ft.projectionMercator}get vertexShaderPreludeCode(){return Ft.projectionMercator.vertexSource}get subdivisionGranularity(){return t.aT.noSubdivision}get useGlobeControls(){return !1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(e){}getMeshFromTileID(e,i,o,a,r){if(this._cachedMesh)return this._cachedMesh;const s=new t.aU;s.emplaceBack(0,0),s.emplaceBack(t.a6,0),s.emplaceBack(0,t.a6),s.emplaceBack(t.a6,t.a6);const n=e.createVertexBuffer(s,Ot.members),l=t.aV.simpleSegment(0,0,4,2),c=new t.aW;c.emplaceBack(1,0,2),c.emplaceBack(1,2,3);const h=e.createIndexBuffer(c);return this._cachedMesh=new Bt(n,h,l),this._cachedMesh}recalculate(){}hasTransition(){return !1}setErrorQueryLatitudeDegrees(e){}}class Ut{constructor(e=0,t=0,i=0,o=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(o)||o<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=i,this.right=o;}interpolate(e,i,o){return null!=i.top&&null!=e.top&&(this.top=t.H.number(e.top,i.top,o)),null!=i.bottom&&null!=e.bottom&&(this.bottom=t.H.number(e.bottom,i.bottom,o)),null!=i.left&&null!=e.left&&(this.left=t.H.number(e.left,i.left,o)),null!=i.right&&null!=e.right&&(this.right=t.H.number(e.right,i.right,o)),this}getCenter(e,i){const o=t.al((this.left+e-this.right)/2,0,e),a=t.al((this.top+i-this.bottom)/2,0,i);return new t.P(o,a)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new Ut(this.top,this.bottom,this.left,this.right)}toJSON(){return {top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Gt(e,t){if(!e.renderWorldCopies||e.lngRange)return;const i=t.lng-e.center.lng;t.lng+=i>180?-360:i<-180?360:0;}function Vt(e){return Math.max(0,Math.floor(e))}class Wt{constructor(e,i){var o;this.applyConstrain=(e,t)=>null!==this._constrainOverride?this._constrainOverride(e,t):this._callbacks.defaultConstrain(e,t),this._callbacks=e,this._tileSize=512,this._renderWorldCopies=void 0===(null==i?void 0:i.renderWorldCopies)||!!(null==i?void 0:i.renderWorldCopies),this._minZoom=(null==i?void 0:i.minZoom)||0,this._maxZoom=(null==i?void 0:i.maxZoom)||22,this._minPitch=null==(null==i?void 0:i.minPitch)?0:null==i?void 0:i.minPitch,this._maxPitch=null==(null==i?void 0:i.maxPitch)?60:null==i?void 0:i.maxPitch,this._constrainOverride=null!==(o=null==i?void 0:i.constrainOverride)&&void 0!==o?o:null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new t.W(0,0),this._elevation=0,this._zoom=0,this._tileZoom=Vt(this._zoom),this._scale=t.ao(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new Ut,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0;}apply(e,i,o){this._constrainOverride=e.constrainOverride,this._latRange=e.latRange,this._lngRange=e.lngRange,this._width=e.width,this._height=e.height,this._center=e.center,this._elevation=e.elevation,this._minElevationForCurrentTile=e.minElevationForCurrentTile,this._zoom=e.zoom,this._tileZoom=Vt(this._zoom),this._scale=t.ao(this._zoom),this._bearingInRadians=e.bearingInRadians,this._fovInRadians=e.fovInRadians,this._pitchInRadians=e.pitchInRadians,this._rollInRadians=e.rollInRadians,this._unmodified=e.unmodified,this._edgeInsets=new Ut(e.padding.top,e.padding.bottom,e.padding.left,e.padding.right),this._minZoom=e.minZoom,this._maxZoom=e.maxZoom,this._minPitch=e.minPitch,this._maxPitch=e.maxPitch,this._renderWorldCopies=e.renderWorldCopies,this._cameraToCenterDistance=e.cameraToCenterDistance,this._nearZ=e.nearZ,this._farZ=e.farZ,this._autoCalculateNearFarZ=!o&&e.autoCalculateNearFarZ,i&&this.constrainInternal(),this._calcMatrices();}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(e){this._minElevationForCurrentTile=e;}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(e){this._minZoom!==e&&(this._minZoom=e,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom));}get maxZoom(){return this._maxZoom}setMaxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom));}get minPitch(){return this._minPitch}setMinPitch(e){this._minPitch!==e&&(this._minPitch=e,this.setPitch(Math.max(this.pitch,e)));}get maxPitch(){return this._maxPitch}setMaxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.setPitch(Math.min(this.pitch,e)));}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e;}get constrainOverride(){return this._constrainOverride}setConstrainOverride(e){void 0===e&&(e=null),this._constrainOverride!==e&&(this._constrainOverride=e,this.constrainInternal(),this._calcMatrices());}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new t.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){const i=t.X(e,-180,180)*Math.PI/180;var a,r,s,n,l,c,h,u,d;this._bearingInRadians!==i&&(this._unmodified=!1,this._bearingInRadians=i,this._calcMatrices(),this._rotationMatrix=o(),a=this._rotationMatrix,s=-this._bearingInRadians,n=(r=this._rotationMatrix)[0],l=r[1],c=r[2],h=r[3],u=Math.sin(s),d=Math.cos(s),a[0]=n*d+c*u,a[1]=l*d+h*u,a[2]=n*-u+c*d,a[3]=l*-u+h*d);}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){const i=t.al(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==i&&(this._unmodified=!1,this._pitchInRadians=i,this._calcMatrices());}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){const t=e/180*Math.PI;this._rollInRadians!==t&&(this._unmodified=!1,this._rollInRadians=t,this._calcMatrices());}get fovInRadians(){return this._fovInRadians}get fov(){return t.aX(this._fovInRadians)}setFov(e){e=t.al(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=t.an(e),this._calcMatrices());}get zoom(){return this._zoom}setZoom(e){const i=this.applyConstrain(this._center,e).zoom;this._zoom!==i&&(this._unmodified=!1,this._zoom=i,this._tileZoom=Math.max(0,Math.floor(i)),this._scale=t.ao(i),this.constrainInternal(),this._calcMatrices());}get center(){return this._center}setCenter(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this.constrainInternal(),this._calcMatrices());}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this.constrainInternal(),this._calcMatrices());}get padding(){return this._edgeInsets.toJSON()}setPadding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices());}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(e,t){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=t,this._calcMatrices();}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices();}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,i){this._unmodified=!1,this._edgeInsets.interpolate(e,t,i),this.constrainInternal(),this._calcMatrices();}resize(e,t,i=!0){this._width=e,this._height=t,i&&this.constrainInternal(),this._calcMatrices();}getMaxBounds(){var e,t;return 2!==(null===(e=this._latRange)||void 0===e?void 0:e.length)||2!==(null===(t=this._lngRange)||void 0===t?void 0:t.length)?null:new G([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]])}setMaxBounds(e){e?(this._lngRange=[e.getWest(),e.getEast()],this._latRange=[e.getSouth(),e.getNorth()],this.constrainInternal()):(this._lngRange=null,this._latRange=[-t.am,t.am]);}getCameraQueryGeometry(e,i){if(1===i.length)return [i[0],e];{const{minX:o,minY:a,maxX:r,maxY:s}=t.a8.fromPoints(i).extend(e);return [new t.P(o,a),new t.P(r,a),new t.P(r,s),new t.P(o,s),new t.P(o,a)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const e=this._unmodified,{center:t,zoom:i}=this.applyConstrain(this.center,this.zoom);this.setCenter(t),this.setZoom(i),this._unmodified=e,this._constraining=!1;}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=t.ap(new Float64Array(16));t.S(e,e,[this._width/2,-this._height/2,1]),t.Q(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=t.ap(new Float64Array(16)),t.S(e,e,[1,-1,1]),t.Q(e,e,[-1,-1,0]),t.S(e,e,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=e,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height;}this._callbacks.calcMatrices();}calculateCenterFromCameraLngLatAlt(e,i,o,a){const r=void 0!==o?o:this.bearing,s=a=void 0!==a?a:this.pitch,{distanceToCenter:n,clampedElevation:l}=this._distanceToCenterFromAltElevationPitch(i,this.elevation,s),{x:c,y:h}=be(s,r),u=t.a7.fromLngLat(e,i);let d,_,p=t.aY(1,u.y),m=0;do{if(m+=1,m>10)break;_=n/p,d=new t.a7(u.x+c*_,u.y+h*_),p=1/d.meterInMercatorCoordinateUnits();}while(Math.abs(n-_*p)>1e-12);return {center:d.toLngLat(),elevation:l,zoom:t.ar(this.height/2/Math.tan(this.fovInRadians/2)/_/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e==0)return;const i=1/this.worldSize,o=t.aq(1,this.center.lat)*this.worldSize,a=t.a7.fromLngLat(this.center,this.elevation),r=a.x/i,s=a.y/i,n=a.z/i,l=this.pitch,c=this.bearing,{x:h,y:u,z:d}=be(l,c),_=this.cameraToCenterDistance,p=r+_*-h,m=s+_*-u,f=n+_*d,{distanceToCenter:g,clampedElevation:v}=this._distanceToCenterFromAltElevationPitch(f/o,e,l),x=g*o,b=new t.a7((p+h*x)*i,(m+u*x)*i,0).toLngLat(),y=t.aq(1,b.lat),w=t.ar(this.height/2/Math.tan(this.fovInRadians/2)/g/y/this.tileSize);this._elevation=v,this._center=b,this.setZoom(w);}_distanceToCenterFromAltElevationPitch(e,i,o){const a=-Math.cos(t.an(o)),r=e-i;let s,n=i;return a*r>=0||Math.abs(a)<.1?(s=1e4,n=e+s*a):s=-r/a,{distanceToCenter:s,clampedElevation:n}}getCameraPoint(){const e=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new t.P(e*Math.sin(this.rollInRadians),e*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){const e=t.aq(1,this.center.lat)*this.worldSize;return xe(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/e).toLngLat()}getMercatorTileCoordinates(e){if(!e)return [0,0,1,1];const i=e.canonical.z>=0?1<<e.canonical.z:Math.pow(2,e.canonical.z);return [e.canonical.x/i,e.canonical.y/i,1/i/t.a6,1/i/t.a6]}}class qt{constructor(e,i){this.min=e,this.max=i,this.center=t.aZ([],t.a_([],this.min,this.max),.5);}quadrant(e){const i=[e%2==0,e<2],o=t.a$(this.min),a=t.a$(this.max);for(let e=0;e<i.length;e++)o[e]=i[e]?this.min[e]:this.center[e],a[e]=i[e]?this.center[e]:this.max[e];return a[2]=this.max[2],new qt(o,a)}distanceX(e){return Math.max(Math.min(this.max[0],e[0]),this.min[0])-e[0]}distanceY(e){return Math.max(Math.min(this.max[1],e[1]),this.min[1])-e[1]}intersectsFrustum(e){let t=!0;for(const i of e.planes){const e=this.intersectsPlane(i);if(0===e)return 0;1===e&&(t=!1);}return t?2:e.aabb.min[0]>this.max[0]||e.aabb.min[1]>this.max[1]||e.aabb.min[2]>this.max[2]||e.aabb.max[0]<this.min[0]||e.aabb.max[1]<this.min[1]||e.aabb.max[2]<this.min[2]?0:1}intersectsPlane(e){let t=e[3],i=e[3];for(let o=0;o<3;o++)e[o]>0?(t+=e[o]*this.min[o],i+=e[o]*this.max[o]):(i+=e[o]*this.min[o],t+=e[o]*this.max[o]);return t>=0?2:i<0?0:1}}class $t{distanceToTile2d(e,t,i,o){const a=o,r=a.distanceX([e,t]),s=a.distanceY([e,t]);return Math.hypot(r,s)}getWrap(e,t,i){return i}getTileBoundingVolume(e,i,o,a){var r,s;let n=0,l=0;if(null==a?void 0:a.terrain){const c=new t.a3(e.z,i,e.z,e.x,e.y),h=a.terrain.getMinMaxElevation(c);n=null!==(r=h.minElevation)&&void 0!==r?r:Math.min(0,o),l=null!==(s=h.maxElevation)&&void 0!==s?s:Math.max(0,o);}const c=1<<e.z;return new qt([i+e.x/c,e.y/c,n],[i+(e.x+1)/c,(e.y+1)/c,l])}allowVariableZoom(e,i){const o=e.fov*(Math.abs(Math.cos(e.rollInRadians))*e.height+Math.abs(Math.sin(e.rollInRadians))*e.width)/e.height,a=t.al(78.5-o/2,0,60);return !!i.terrain||e.pitch>a}allowWorldCopies(){return !0}prepareNextFrame(){}}class Ht{constructor(e,t,i){this.points=e,this.planes=t,this.aabb=i;}static fromInvProjectionMatrix(e,i=1,o=0,a,r){const s=r?[[6,5,4],[0,1,2],[0,3,7],[2,1,5],[3,2,6],[0,4,5]]:[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]],n=Math.pow(2,o),l=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((o=>function(e,i,o,a){const r=t.aE([],e,i),s=1/r[3]/o*a;return t.b4(r,r,[s,s,1/r[3],s])}(o,e,i,n)));a&&function(e,i,o,a){const r=a?4:0,s=a?0:4;let n=0;const l=[],c=[];for(let i=0;i<4;i++){const o=t.b0([],e[i+s],e[i+r]),a=t.b5(o);t.aZ(o,o,1/a),l.push(a),c.push(o);}for(let i=0;i<4;i++){const a=t.b6(e[i+r],c[i],o);n=null!==a&&a>=0?Math.max(n,a):Math.max(n,l[i]);}const h=function(e,i){const o=t.b0([],e[i[0]],e[i[1]]),a=t.b0([],e[i[2]],e[i[1]]),r=[0,0,0,0];return t.b1(r,t.b2([],o,a)),r[3]=-t.b3(r,e[i[0]]),r}(e,i),u=function(e,i){const o=t.b7(e),a=t.b8([],e,1/o),r=t.b0([],i,t.aZ([],a,t.b3(i,a))),s=t.b7(r);if(s>0){const e=Math.sqrt(1-a[3]*a[3]),o=t.aZ([],a,-a[3]),n=t.a_([],o,t.aZ([],r,e/s));return t.b9(i,n)}return null}(o,h);if(null!==u){const e=u/t.b3(c[0],h);n=Math.min(n,e);}for(let t=0;t<4;t++){const i=Math.min(n,l[t]);e[t+s]=[e[t+r][0]+c[t][0]*i,e[t+r][1]+c[t][1]*i,e[t+r][2]+c[t][2]*i,1];}}(l,s[0],a,r);const c=s.map((e=>{const i=t.b0([],l[e[0]],l[e[1]]),o=t.b0([],l[e[2]],l[e[1]]),a=t.b1([],t.b2([],i,o)),r=-t.b3(a,l[e[1]]);return a.concat(r)})),h=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],u=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const e of l)for(let t=0;t<3;t++)h[t]=Math.min(h[t],e[t]),u[t]=Math.max(u[t],e[t]);return new Ht(l,c,new qt(h,u))}}class Xt{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e);}setMaxZoom(e){this._helper.setMaxZoom(e);}setMinPitch(e){this._helper.setMinPitch(e);}setMaxPitch(e){this._helper.setMaxPitch(e);}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e);}setBearing(e){this._helper.setBearing(e);}setPitch(e){this._helper.setPitch(e);}setRoll(e){this._helper.setRoll(e);}setFov(e){this._helper.setFov(e);}setZoom(e){this._helper.setZoom(e);}setCenter(e){this._helper.setCenter(e);}setElevation(e){this._helper.setElevation(e);}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e);}setPadding(e){this._helper.setPadding(e);}interpolatePadding(e,t,i){this._helper.interpolatePadding(e,t,i);}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,i=!0){this._helper.resize(e,t,i);}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e);}setConstrainOverride(e){this._helper.setConstrainOverride(e);}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t);}clearNearFarZOverride(){this._helper.clearNearFarZOverride();}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e,t){}constructor(e){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this.defaultConstrain=(e,i)=>{i=t.al(+i,this.minZoom,this.maxZoom);const o={center:new t.W(e.lng,e.lat),zoom:i};let a=this._helper._lngRange;if(!this._helper._renderWorldCopies&&null===a){const e=180-1e-10;a=[-e,e];}const r=this.tileSize*t.ao(o.zoom);let s=0,n=r,l=0,c=r,h=0,u=0;const{x:d,y:_}=this.size;if(this._helper._latRange){const e=this._helper._latRange;s=t.Y(e[1])*r,n=t.Y(e[0])*r,n-s<_&&(h=_/(n-s));}a&&(l=t.X(t.Z(a[0])*r,0,r),c=t.X(t.Z(a[1])*r,0,r),c<l&&(c+=r),c-l<d&&(u=d/(c-l)));const{x:p,y:m}=me(r,e);let f,g;const v=Math.max(u||0,h||0);if(v){const e=new t.P(u?(c+l)/2:p,h?(n+s)/2:m);return o.center=fe(r,e).wrap(),o.zoom+=t.ar(v),o}if(this._helper._latRange){const e=_/2;m-e<s&&(g=s+e),m+e>n&&(g=n-e);}if(a){const e=(l+c)/2;let i=p;this._helper._renderWorldCopies&&(i=t.X(p,e-r/2,e+r/2));const o=d/2;i-o<l&&(f=l+o),i+o>c&&(f=c-o);}if(void 0!==f||void 0!==g){const e=new t.P(null!=f?f:p,null!=g?g:m);o.center=fe(r,e).wrap();}return o},this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new Wt({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._coveringTilesDetailsProvider=new $t;}clone(){const e=new Xt;return e.apply(this,!1),e}apply(e,t,i){this._helper.apply(e,t,i);}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(e){const i=[new t.ba(0,e)];if(this._helper._renderWorldCopies){const o=this.screenPointToMercatorCoordinate(new t.P(0,0)),a=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,0)),r=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,this._helper._height)),s=this.screenPointToMercatorCoordinate(new t.P(0,this._helper._height)),n=Math.floor(Math.min(o.x,a.x,r.x,s.x)),l=Math.floor(Math.max(o.x,a.x,r.x,s.x)),c=1;for(let o=n-c;o<=l+c;o++)0!==o&&i.push(new t.ba(o,e));}return i}getCameraFrustum(){return Ht.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){const t=this.screenPointToLocation(this.centerPoint,e),i=e?e.getElevationForLngLatZoom(t,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(i);}setLocationAtPoint(e,i){const o=t.aq(this.elevation,this.center.lat),a=this.screenPointToMercatorCoordinateAtZ(i,o),r=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,o),s=t.a7.fromLngLat(e),n=new t.a7(s.x-(a.x-r.x),s.y-(a.y-r.y));this.setCenter(null==n?void 0:n.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap());}locationToScreenPoint(e,i){return i?this.coordinatePoint(t.a7.fromLngLat(e),i.getElevationForLngLat(e,this),this._pixelMatrix3D):this.coordinatePoint(t.a7.fromLngLat(e))}screenPointToLocation(e,t){var i;return null===(i=this.screenPointToMercatorCoordinate(e,t))||void 0===i?void 0:i.toLngLat()}screenPointToMercatorCoordinate(e,t){if(t){const i=t.pointCoordinate(e);if(null!=i)return i}return this.screenPointToMercatorCoordinateAtZ(e)}screenPointToMercatorCoordinateAtZ(e,i){const o=i||0,a=[e.x,e.y,0,1],r=[e.x,e.y,1,1];t.aE(a,a,this._pixelMatrixInverse),t.aE(r,r,this._pixelMatrixInverse);const s=a[3],n=r[3],l=a[1]/s,c=r[1]/n,h=a[2]/s,u=r[2]/n,d=h===u?0:(o-h)/(u-h);return new t.a7(t.H.number(a[0]/s,r[0]/n,d)/this.worldSize,t.H.number(l,c,d)/this.worldSize,o)}coordinatePoint(e,i=0,o=this._pixelMatrix){const a=[e.x*this.worldSize,e.y*this.worldSize,i,1];return t.aE(a,a,o),new t.P(a[0]/a[3],a[1]/a[3])}getBounds(){const e=Math.max(0,this._helper._height/2-ge(this));return (new G).extend(this.screenPointToLocation(new t.P(0,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new t.P(0,this._helper._height)))}isPointOnMapSurface(e,t){return t?null!=t.pointCoordinate(e):e.y>this.height/2-ge(this)}calculatePosMatrix(e,i=!1,o){var a;const r=null!==(a=e.key)&&void 0!==a?a:t.bb(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),s=i?this._alignedPosMatrixCache:this._posMatrixCache;if(s.has(r)){const e=s.get(r);return o?e.f32:e.f64}const n=ve(e,this.worldSize);t.U(n,i?this._alignedProjMatrix:this._viewProjMatrix,n);const l={f64:n,f32:new Float32Array(n)};return s.set(r,l),o?l.f32:l.f64}calculateFogMatrix(e){const i=e.key,o=this._fogMatrixCacheF32;if(o.has(i))return o.get(i);const a=ve(e,this.worldSize);return t.U(a,this._fogMatrix,a),o.set(i,new Float32Array(a)),o.get(i)}calculateCenterFromCameraLngLatAlt(e,t,i,o){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,o)}_calculateNearFarZIfNeeded(e,i,o){if(!this._helper.autoCalculateNearFarZ)return;const a=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),r=e-a*this._helper._pixelPerMeter/Math.cos(i),s=a<0?r:e,n=Math.PI/2+this.pitchInRadians,l=t.an(this.fov)*(Math.abs(Math.cos(t.an(this.roll)))*this.height+Math.abs(Math.sin(t.an(this.roll)))*this.width)/this.height*(.5+o.y/this.height),c=Math.sin(l)*s/Math.sin(t.al(Math.PI-n-l,.01,Math.PI-.01)),h=ge(this),u=Math.atan(h/this._helper.cameraToCenterDistance),d=t.an(.75),_=u>d?2*u*(.5+o.y/(2*h)):d,p=Math.sin(_)*s/Math.sin(t.al(Math.PI-n-_,.01,Math.PI-.01)),m=Math.min(c,p);this._helper._farZ=1.01*(Math.cos(Math.PI/2-i)*m+s),this._helper._nearZ=this._helper._height/50;}_calcMatrices(){if(!this._helper._height)return;const e=this.centerOffset,i=me(this.worldSize,this.center),o=i.x,a=i.y;this._helper._pixelPerMeter=t.aq(1,this.center.lat)*this.worldSize;const r=t.an(Math.min(this.pitch,pe)),s=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(r));let n;var l,c;this._calculateNearFarZIfNeeded(s,r,e),n=new Float64Array(16),t.bc(n,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),(l=this._invProjMatrix)[0]=1/(c=n)[0],l[1]=0,l[2]=0,l[3]=0,l[4]=0,l[5]=1/c[5],l[6]=0,l[7]=0,l[8]=0,l[9]=0,l[10]=0,l[11]=1/c[14],l[12]=0,l[13]=0,l[14]=-1,l[15]=c[10]/c[14],n[8]=2*-e.x/this._helper._width,n[9]=2*e.y/this._helper._height,this._projectionMatrix=t.bd(n),t.S(n,n,[1,-1,1]),t.Q(n,n,[0,0,-this._helper.cameraToCenterDistance]),t.be(n,n,-this.rollInRadians),t.bf(n,n,this.pitchInRadians),t.be(n,n,-this.bearingInRadians),t.Q(n,n,[-o,-a,0]),this._mercatorMatrix=t.S([],n,[this.worldSize,this.worldSize,this.worldSize]),t.S(n,n,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=t.U(new Float64Array(16),this.clipSpaceToPixelsMatrix,n),t.Q(n,n,[0,0,-this.elevation]),this._viewProjMatrix=n,this._invViewProjMatrix=t.bg([],n);const h=[0,0,-1,1];t.aE(h,h,this._invViewProjMatrix),this._cameraPosition=[h[0]/h[3],h[1]/h[3],h[2]/h[3]],this._fogMatrix=new Float64Array(16),t.bc(this._fogMatrix,this.fovInRadians,this.width/this.height,s,this._helper._farZ),this._fogMatrix[8]=2*-e.x/this.width,this._fogMatrix[9]=2*e.y/this.height,t.S(this._fogMatrix,this._fogMatrix,[1,-1,1]),t.Q(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),t.be(this._fogMatrix,this._fogMatrix,-this.rollInRadians),t.bf(this._fogMatrix,this._fogMatrix,this.pitchInRadians),t.be(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),t.Q(this._fogMatrix,this._fogMatrix,[-o,-a,0]),t.S(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),t.Q(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=t.U(new Float64Array(16),this.clipSpaceToPixelsMatrix,n);const u=this._helper._width%2/2,d=this._helper._height%2/2,_=Math.cos(this.bearingInRadians),p=Math.sin(-this.bearingInRadians),m=o-Math.round(o)+_*u+p*d,f=a-Math.round(a)+_*d+p*u,g=new Float64Array(n);if(t.Q(g,g,[m>.5?m-1:m,f>.5?f-1:f,0]),this._alignedProjMatrix=g,n=t.bg(new Float64Array(16),this._pixelMatrix),!n)throw new Error("failed to invert matrix");this._pixelMatrixInverse=n,this._clearMatrixCaches();}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear();}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const e=this.screenPointToMercatorCoordinate(new t.P(0,0)),i=[e.x*this.worldSize,e.y*this.worldSize,0,1];return t.aE(i,i,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const e=t.aq(1,this.center.lat)*this.worldSize;return xe(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/e).toLngLat()}lngLatToCameraDepth(e,i){const o=t.a7.fromLngLat(e),a=[o.x*this.worldSize,o.y*this.worldSize,i,1];return t.aE(a,a,this._viewProjMatrix),a[2]/a[3]}getProjectionData(e){const{overscaledTileID:i,aligned:o,applyTerrainMatrix:a}=e,r=this._helper.getMercatorTileCoordinates(i),s=i?this.calculatePosMatrix(i,o,!0):null;let n;return n=(null==i?void 0:i.terrainRttPosMatrix32f)&&a?i.terrainRttPosMatrix32f:s||t.bh(),{mainMatrix:n,tileMercatorCoords:r,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:n}}isLocationOccluded(e){return !1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,t,i){return 1}transformLightDirection(e){return t.a$(e)}getRayDirectionFromPixel(e){throw new Error("Not implemented.")}projectTileCoordinates(e,i,o,a){const r=this.calculatePosMatrix(o);let s;a?(s=[e,i,a(e,i),1],t.aE(s,s,r)):(s=[e,i,0,1],nt(s,s,r));const n=s[3];return {point:new t.P(s[0]/n,s[1]/n),signedDistanceFromCamera:n,isOccluded:!1}}populateCache(e){for(const t of e)this.calculatePosMatrix(t);}getMatrixForModel(e,i){const o=t.a7.fromLngLat(e,i),a=o.meterInMercatorCoordinateUnits(),r=t.bi();return t.Q(r,r,[o.x,o.y,o.z]),t.be(r,r,Math.PI),t.bf(r,r,Math.PI/2),t.S(r,r,[-a,a,a]),r}getProjectionDataForCustomLayer(e=!0){const i=new t.a3(0,0,0,0,0),o=this.getProjectionData({overscaledTileID:i,applyGlobeMatrix:e}),a=ve(i,this.worldSize);t.U(a,this._viewProjMatrix,a),o.tileMercatorCoords=[0,0,1,1];const r=[t.a6,t.a6,this.worldSize/this._helper.pixelsPerMeter],s=t.bj();return t.S(s,a,r),o.fallbackMatrix=s,o.mainMatrix=s,o}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}}function Kt(){t.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");}function Yt(e){if(e.useSlerp)if(e.k<1){const i=t.bk(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),o=t.bk(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),a=new Float64Array(4);t.bl(a,i,o,e.k);const r=t.bm(a);e.tr.setRoll(r.roll),e.tr.setPitch(r.pitch),e.tr.setBearing(r.bearing);}else e.tr.setRoll(e.endEulerAngles.roll),e.tr.setPitch(e.endEulerAngles.pitch),e.tr.setBearing(e.endEulerAngles.bearing);else e.tr.setRoll(t.H.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(t.H.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(t.H.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k));}function Qt(e,i,o,a,r){const s=r.padding,n=me(r.worldSize,o.getNorthWest()),l=me(r.worldSize,o.getNorthEast()),c=me(r.worldSize,o.getSouthEast()),h=me(r.worldSize,o.getSouthWest()),u=t.an(-a),d=n.rotate(u),_=l.rotate(u),p=c.rotate(u),m=h.rotate(u),f=new t.P(Math.max(d.x,_.x,m.x,p.x),Math.max(d.y,_.y,m.y,p.y)),g=new t.P(Math.min(d.x,_.x,m.x,p.x),Math.min(d.y,_.y,m.y,p.y)),v=f.sub(g),x=(r.width-(s.left+s.right+i.left+i.right))/v.x,b=(r.height-(s.top+s.bottom+i.top+i.bottom))/v.y;if(b<0||x<0)return void Kt();const y=Math.min(t.ar(r.scale*Math.min(x,b)),e.maxZoom),w=t.P.convert(e.offset),T=new t.P((i.left-i.right)/2,(i.top-i.bottom)/2).rotate(t.an(a)),P=w.add(T).mult(r.scale/t.ao(y));return {center:fe(r.worldSize,n.add(c).div(2).sub(P)),zoom:y,bearing:a}}class Jt{get useGlobeControls(){return !1}handlePanInertia(e,t){const i=e.mag(),o=Math.abs(ge(t));return {easingOffset:e.mult(Math.min(.75*o/i,1)),easingCenter:t.center}}handleMapControlsRollPitchBearingZoom(e,t){e.bearingDelta&&t.setBearing(t.bearing+e.bearingDelta),e.pitchDelta&&t.setPitch(t.pitch+e.pitchDelta),e.rollDelta&&t.setRoll(t.roll+e.rollDelta),e.zoomDelta&&t.setZoom(t.zoom+e.zoomDelta);}handleMapControlsPan(e,t,i){e.around.distSqr(t.centerPoint)<.01||t.setLocationAtPoint(i,e.around);}cameraForBoxAndBearing(e,t,i,o,a){return Qt(e,t,i,o,a)}handleJumpToCenterZoom(e,i){e.zoom!==(void 0!==i.zoom?+i.zoom:e.zoom)&&e.setZoom(+i.zoom),void 0!==i.center&&e.setCenter(t.W.convert(i.center));}handleEaseTo(e,i){const o=e.zoom,a=e.padding,r={roll:e.roll,pitch:e.pitch,bearing:e.bearing},s={roll:void 0===i.roll?e.roll:i.roll,pitch:void 0===i.pitch?e.pitch:i.pitch,bearing:void 0===i.bearing?e.bearing:i.bearing},n=void 0!==i.zoom,l=!e.isPaddingEqual(i.padding);let c=!1;const h=n?+i.zoom:e.zoom;let u=e.centerPoint.add(i.offsetAsPoint);const d=e.screenPointToLocation(u),{center:_,zoom:p}=e.applyConstrain(t.W.convert(i.center||d),null!=h?h:o);Gt(e,_);const m=me(e.worldSize,d),f=me(e.worldSize,_).sub(m),g=t.ao(p-o);return c=p!==o,{easeFunc:n=>{if(c&&e.setZoom(t.H.number(o,p,n)),t.bn(r,s)||Yt({startEulerAngles:r,endEulerAngles:s,tr:e,k:n,useSlerp:r.roll!=s.roll}),l&&(e.interpolatePadding(a,i.padding,n),u=e.centerPoint.add(i.offsetAsPoint)),i.around)e.setLocationAtPoint(i.around,i.aroundPoint);else {const i=t.ao(e.zoom-o),a=p>o?Math.min(2,g):Math.max(.5,g),r=Math.pow(a,1-n),s=fe(e.worldSize,m.add(f.mult(n*r)).mult(i));e.setLocationAtPoint(e.renderWorldCopies?s.wrap():s,u);}},isZooming:c,elevationCenter:_}}handleFlyTo(e,i){const o=void 0!==i.zoom,a=e.zoom,r=e.applyConstrain(t.W.convert(i.center||i.locationAtOffset),o?+i.zoom:a),s=r.center,n=r.zoom;Gt(e,s);const l=me(e.worldSize,i.locationAtOffset),c=me(e.worldSize,s).sub(l),h=c.mag(),u=t.ao(n-a);let d;if(void 0!==i.minZoom){const o=Math.min(+i.minZoom,a,n),r=e.applyConstrain(s,o).zoom;d=t.ao(r-a);}return {easeFunc:(i,o,r,h)=>{e.setZoom(1===i?n:a+t.ar(o));const u=1===i?s:fe(e.worldSize,l.add(c.mult(r)).mult(o));e.setLocationAtPoint(e.renderWorldCopies?u.wrap():u,h);},scaleOfZoom:u,targetCenter:s,scaleOfMinZoom:d,pixelPathLength:h}}}class ei{constructor(e,t,i){this.blendFunction=e,this.blendColor=t,this.mask=i;}}ei.Replace=[1,0],ei.disabled=new ei(ei.Replace,t.bo.transparent,[!1,!1,!1,!1]),ei.unblended=new ei(ei.Replace,t.bo.transparent,[!0,!0,!0,!0]),ei.alphaBlended=new ei([1,771],t.bo.transparent,[!0,!0,!0,!0]);const ti=2305;class ii{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i;}}ii.disabled=new ii(!1,1029,ti),ii.backCCW=new ii(!0,1029,ti),ii.frontCCW=new ii(!0,1028,ti);class oi{constructor(e,t,i){this.func=e,this.mask=t,this.range=i;}}oi.ReadOnly=!1,oi.ReadWrite=!0,oi.disabled=new oi(519,oi.ReadOnly,[0,1]);const ai=7680;class ri{constructor(e,t,i,o,a,r){this.test=e,this.ref=t,this.mask=i,this.fail=o,this.depthFail=a,this.pass=r;}}function si(e){return "undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext}ri.disabled=new ri({func:519,mask:0},0,0,ai,ai,ai);class ni{get awaitingQuery(){return !!this._readbackQueue}constructor(e){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=e;const i=e.context,o=i.gl;this._texFormat=o.RGBA,this._texType=o.UNSIGNED_BYTE;const a=new t.aU;a.emplaceBack(-1,-1),a.emplaceBack(2,-1),a.emplaceBack(-1,2);const r=new t.aW;r.emplaceBack(0,1,2),this._fullscreenTriangle=new Bt(i.createVertexBuffer(a,Ot.members),i.createIndexBuffer(r),t.aV.simpleSegment(0,0,a.length,r.length)),this._resultBuffer=new Uint8Array(4),i.activeTexture.set(o.TEXTURE1);const s=o.createTexture();o.bindTexture(o.TEXTURE_2D,s),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.NEAREST),o.texImage2D(o.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=i.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(s),si(o)&&(this._pbo=o.createBuffer(),o.bindBuffer(o.PIXEL_PACK_BUFFER,this._pbo),o.bufferData(o.PIXEL_PACK_BUFFER,4,o.STREAM_READ),o.bindBuffer(o.PIXEL_PACK_BUFFER,null));}destroy(){const e=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),e.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null;}updateErrorLoop(e,t){const i=this._updateCount;return this._readbackQueue?i>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():i>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(e,t),this._updateCount++,this._measuredError}_bindFramebuffer(){const e=this._cachedRenderContext.context,t=e.gl;e.activeTexture.set(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,this._fbo.colorAttachment.get()),e.bindFramebuffer.set(this._fbo.framebuffer);}_renderErrorTexture(e,i){const o=this._cachedRenderContext.context,a=o.gl;if(this._bindFramebuffer(),o.viewport.set([0,0,this._texWidth,this._texHeight]),o.clear({color:t.bo.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(o,a.TRIANGLES,oi.disabled,ri.disabled,ei.unblended,ii.disabled,((e,t)=>({u_input:e,u_output_expected:t}))(e,i),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&si(a)){a.bindBuffer(a.PIXEL_PACK_BUFFER,this._pbo),a.readBuffer(a.COLOR_ATTACHMENT0),a.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),a.bindBuffer(a.PIXEL_PACK_BUFFER,null);const e=a.fenceSync(a.SYNC_GPU_COMMANDS_COMPLETE,0);a.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:e};}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null};}_tryReadback(){const e=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&si(e)){const i=e.clientWaitSync(this._readbackQueue.sync,0,0);if(i===e.WAIT_FAILED)return t.w("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(i===e.TIMEOUT_EXPIRED)return;e.bindBuffer(e.PIXEL_PACK_BUFFER,this._pbo),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),e.bindBuffer(e.PIXEL_PACK_BUFFER,null);}else this._bindFramebuffer(),e.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=ni._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount;}static _parseRGBA8float(e){let t=0;return t+=e[0]/256,t+=e[1]/65536,t+=e[2]/16777216,e[3]<127&&(t=-t),t/128}}const li=t.a6/128;function ci(e,i){const o=void 0!==e.granularity?Math.max(e.granularity,1):1,a=o+(e.generateBorders?2:0),r=o+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),s=a+1,n=r+1,l=e.generateBorders?-1:0,c=e.generateBorders||e.extendToNorthPole?-1:0,h=o+(e.generateBorders?1:0),u=o+(e.generateBorders||e.extendToSouthPole?1:0),d=s*n,_=a*r*6,p=s*n>65536;if(p&&"16bit"===i)throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const m=p||"32bit"===i,f=new Int16Array(2*d);let g=0;for(let i=c;i<=u;i++)for(let a=l;a<=h;a++){let r=a/o*t.a6;-1===a&&(r=-li),a===o+1&&(r=t.a6+li);let s=i/o*t.a6;-1===i&&(s=e.extendToNorthPole?t.bq:-li),i===o+1&&(s=e.extendToSouthPole?t.br:t.a6+li),f[g++]=r,f[g++]=s;}const v=m?new Uint32Array(_):new Uint16Array(_);let x=0;for(let e=0;e<r;e++)for(let t=0;t<a;t++){const i=t+1+e*s,o=t+(e+1)*s,a=t+1+(e+1)*s;v[x++]=t+e*s,v[x++]=o,v[x++]=i,v[x++]=i,v[x++]=o,v[x++]=a;}return {vertices:f.buffer.slice(0),indices:v.buffer.slice(0),uses32bitIndices:m}}const hi=new t.aT({fill:new t.bs(128,2),line:new t.bs(512,0),tile:new t.bs(128,32),stencil:new t.bs(128,1),circle:3});class ui{constructor(){this._tileMeshCache={},this._errorCorrectionUsable=0,this._errorMeasurementLastValue=0,this._errorCorrectionPreviousValue=0,this._errorMeasurementLastChangeTime=-1e3;}get name(){return "vertical-perspective"}get transitionState(){return 1}get useSubdivision(){return !0}get shaderVariantName(){return "globe"}get shaderDefine(){return "#define GLOBE"}get shaderPreludeCode(){return Ft.projectionGlobe}get vertexShaderPreludeCode(){return Ft.projectionMercator.vertexSource}get subdivisionGranularity(){return hi}get useGlobeControls(){return !0}get latitudeErrorCorrectionRadians(){return this._errorCorrectionUsable}destroy(){this._errorMeasurement&&this._errorMeasurement.destroy();}updateGPUdependent(e){this._errorMeasurement||(this._errorMeasurement=new ni(e));const i=t.Y(this._errorQueryLatitudeDegrees),o=2*Math.atan(Math.exp(Math.PI-i*Math.PI*2))-.5*Math.PI,a=this._errorMeasurement.updateErrorLoop(i,o),r=c();a!==this._errorMeasurementLastValue&&(this._errorCorrectionPreviousValue=this._errorCorrectionUsable,this._errorMeasurementLastValue=a,this._errorMeasurementLastChangeTime=r);const s=Math.min(Math.max((r-this._errorMeasurementLastChangeTime)/1e3/.5,0),1);this._errorCorrectionUsable=t.bt(this._errorCorrectionPreviousValue,-this._errorMeasurementLastValue,t.bu(s));}_getMeshKey(e){return `${e.granularity.toString(36)}_${e.generateBorders?"b":""}${e.extendToNorthPole?"n":""}${e.extendToSouthPole?"s":""}`}getMeshFromTileID(e,t,i,o,a){const r=("stencil"===a?hi.stencil:hi.tile).getGranularityForZoomLevel(t.z);return this._getMesh(e,{granularity:r,generateBorders:i,extendToNorthPole:0===t.y&&o,extendToSouthPole:t.y===(1<<t.z)-1&&o})}_getMesh(e,i){const o=this._getMeshKey(i);if(o in this._tileMeshCache)return this._tileMeshCache[o];const a=function(e,i){const o=ci(i,"16bit"),a=t.aU.deserialize({arrayBuffer:o.vertices,length:o.vertices.byteLength/2/2}),r=t.aW.deserialize({arrayBuffer:o.indices,length:o.indices.byteLength/2/3});return new Bt(e.createVertexBuffer(a,Ot.members),e.createIndexBuffer(r),t.aV.simpleSegment(0,0,a.length,r.length))}(e,i);return this._tileMeshCache[o]=a,a}recalculate(e){}hasTransition(){var e;const t=c();let i=!1;return i||(i=(t-this._errorMeasurementLastChangeTime)/1e3<.7),i||(i=null===(e=this._errorMeasurement)||void 0===e?void 0:e.awaitingQuery),i}setErrorQueryLatitudeDegrees(e){this._errorQueryLatitudeDegrees=e;}}const di=new t.u({type:new t.D(t.x.projection.type)});class _i extends t.E{constructor(e){super(),this._transitionable=new t.y(di,void 0),this.setProjection(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new t.J(0)),this._mercatorProjection=new Zt,this._verticalPerspectiveProjection=new ui;}get transitionState(){const e=this.properties.get("type");if("string"==typeof e&&"mercator"===e)return 0;if("string"==typeof e&&"vertical-perspective"===e)return 1;if(e instanceof t.bv){if("vertical-perspective"===e.from&&"mercator"===e.to)return 1-e.transition;if("mercator"===e.from&&"vertical-perspective"===e.to)return e.transition}return 1}get useGlobeRendering(){return this.transitionState>0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return "globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy();}updateGPUdependent(e){this._mercatorProjection.updateGPUdependent(e),this._verticalPerspectiveProjection.updateGPUdependent(e);}getMeshFromTileID(e,t,i,o,a){return this.currentProjection.getMeshFromTileID(e,t,i,o,a)}setProjection(e){this._transitionable.setValue("type",(null==e?void 0:e.type)||"mercator");}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}setErrorQueryLatitudeDegrees(e){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(e),this._mercatorProjection.setErrorQueryLatitudeDegrees(e);}}function pi(e){const t=gi(e.worldSize,e.center.lat);return 2*Math.PI*t}function mi(e,i,o,a,r){const s=1/(1<<r),n=i/t.a6*s+a*s,l=t.by((e/t.a6*s+o*s)*Math.PI*2+Math.PI,2*Math.PI),c=2*Math.atan(Math.exp(Math.PI-n*Math.PI*2))-.5*Math.PI,h=Math.cos(c),u=new Float64Array(3);return u[0]=Math.sin(l)*h,u[1]=Math.sin(c),u[2]=Math.cos(l)*h,u}function fi(e){return function(e,t){const i=Math.cos(t),o=new Float64Array(3);return o[0]=Math.sin(e)*i,o[1]=Math.sin(t),o[2]=Math.cos(e)*i,o}(e.lng*Math.PI/180,e.lat*Math.PI/180)}function gi(e,t){return e/(2*Math.PI)/Math.cos(t*Math.PI/180)}function vi(e){const i=Math.asin(e[1])/Math.PI*180,o=Math.sqrt(e[0]*e[0]+e[2]*e[2]);if(o>1e-6){const a=e[0]/o,r=Math.acos(e[2]/o),s=(a>0?r:-r)/Math.PI*180;return new t.W(t.X(s,-180,180),i)}return new t.W(0,i)}function xi(e){return Math.cos(e*Math.PI/180)}function bi(e,i){const o=xi(e),a=xi(i);return t.ar(a/o)}function yi(e,i){const o=e.rotate(i.bearingInRadians),a=i.zoom+bi(i.center.lat,0),r=t.bt(1/xi(i.center.lat),1/xi(Math.min(Math.abs(i.center.lat),60)),t.bw(a,7,3,0,1)),s=360/pi({worldSize:i.worldSize,center:{lat:i.center.lat}});return new t.W(i.center.lng-o.x*s*r,t.al(i.center.lat+o.y*s,-t.am,t.am))}function wi(e){const t=.5*e,i=Math.sin(t),o=Math.cos(t);return Math.log(i+o)-Math.log(o-i)}function Ti(e,i,o,a){const r=e.lat+o*a;if(Math.abs(o)>1){const s=(Math.sign(e.lat+o)!==Math.sign(e.lat)?-Math.abs(e.lat):Math.abs(e.lat))*Math.PI/180,n=Math.abs(e.lat+o)*Math.PI/180,l=wi(s+a*(n-s)),c=wi(s),h=wi(n);return new t.W(e.lng+i*((l-c)/(h-c)),r)}return new t.W(e.lng+i*a,r)}class Pi{constructor(e){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=e;}swapBuffers(){if(!this._hadAnyChanges)return;const e=this._cachePrevious;this._cachePrevious=this._cache,this._cache=e,this._cache.clear(),this._hadAnyChanges=!1;}getTileBoundingVolume(e,t,i,o){const a=`${e.z}_${e.x}_${e.y}_${(null==o?void 0:o.terrain)?"t":""}`,r=this._cache.get(a);if(r)return r;const s=this._cachePrevious.get(a);if(s)return this._cache.set(a,s),s;const n=this._boundingVolumeFactory(e,t,i,o);return this._cache.set(a,n),this._hadAnyChanges=!0,n}}class Ci{constructor(e,t,i,o){this.min=i,this.max=o,this.points=e,this.planes=t;}static fromAabb(e,t){const i=[];for(let o=0;o<8;o++)i.push([1&~o?e[0]:t[0],1==(o>>1&1)?t[1]:e[1],1==(o>>2&1)?t[2]:e[2]]);return new Ci(i,[[-1,0,0,t[0]],[1,0,0,-e[0]],[0,-1,0,t[1]],[0,1,0,-e[1]],[0,0,-1,t[2]],[0,0,1,-e[2]]],e,t)}static fromCenterSizeAngles(e,i,o){const a=t.bA([],o[0],o[1],o[2]),r=t.bB([],[i[0],0,0],a),s=t.bB([],[0,i[1],0],a),n=t.bB([],[0,0,i[2]],a),l=[...e],c=[...e];for(let t=0;t<8;t++)for(let i=0;i<3;i++){const o=e[i]+r[i]*(1&~t?-1:1)+s[i]*(1==(t>>1&1)?1:-1)+n[i]*(1==(t>>2&1)?1:-1);l[i]=Math.min(l[i],o),c[i]=Math.max(c[i],o);}const h=[];for(let i=0;i<8;i++){const o=[...e];t.a_(o,o,t.aZ([],r,1&~i?-1:1)),t.a_(o,o,t.aZ([],s,1==(i>>1&1)?1:-1)),t.a_(o,o,t.aZ([],n,1==(i>>2&1)?1:-1)),h.push(o);}return new Ci(h,[[...r,-t.b3(r,h[0])],[...s,-t.b3(s,h[0])],[...n,-t.b3(n,h[0])],[-r[0],-r[1],-r[2],-t.b3(r,h[7])],[-s[0],-s[1],-s[2],-t.b3(s,h[7])],[-n[0],-n[1],-n[2],-t.b3(n,h[7])]],l,c)}intersectsFrustum(e){let t=!0;const i=this.points.length,o=this.planes.length,a=e.planes.length,r=e.points.length;for(let o=0;o<a;o++){const a=e.planes[o];let r=0;for(let e=0;e<i;e++){const t=this.points[e];a[0]*t[0]+a[1]*t[1]+a[2]*t[2]+a[3]>=0&&r++;}if(0===r)return 0;r<i&&(t=!1);}if(t)return 2;for(let t=0;t<o;t++){const i=this.planes[t];let o=0;for(let t=0;t<r;t++){const a=e.points[t];i[0]*a[0]+i[1]*a[1]+i[2]*a[2]+i[3]>=0&&o++;}if(0===o)return 0}return 1}intersectsPlane(e){const t=this.points.length;let i=0;for(let o=0;o<t;o++){const t=this.points[o];e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]>=0&&i++;}return i===t?2:0===i?0:1}}function Mi(e,t,i){const o=e-t;return o<0?-o:Math.max(0,o-i)}function Ii(e,t,i,o,a){const r=e-i;let s;return s=r<0?Math.min(-r,1+r-a):r>a?Math.min(Math.max(r-a,0),1-r):0,Math.max(s,Mi(t,o,a))}class Ei{constructor(){this._boundingVolumeCache=new Pi(this._computeTileBoundingVolume);}prepareNextFrame(){this._boundingVolumeCache.swapBuffers();}distanceToTile2d(e,t,i,o){const a=1<<i.z,r=1/a,s=i.x/a,n=i.y/a;let l=2;return l=Math.min(l,Ii(e,t,s,n,r)),l=Math.min(l,Ii(e,t,s+.5,-n-r,r)),l=Math.min(l,Ii(e,t,s+.5,2-n-r,r)),l}getWrap(e,t,i){const o=1<<t.z,a=1/o,r=t.x/o,s=Mi(e.x,r,a),n=Mi(e.x,r-1,a),l=Mi(e.x,r+1,a),c=Math.min(s,n,l);return c===l?1:c===n?-1:0}allowVariableZoom(e,t){return Ce(e,t)>4}allowWorldCopies(){return !1}getTileBoundingVolume(e,t,i,o){return this._boundingVolumeCache.getTileBoundingVolume(e,t,i,o)}_computeTileBoundingVolume(e,i,o,a){var r,s;let n=0,l=0;if(null==a?void 0:a.terrain){const c=new t.a3(e.z,i,e.z,e.x,e.y),h=a.terrain.getMinMaxElevation(c);n=null!==(r=h.minElevation)&&void 0!==r?r:Math.min(0,o),l=null!==(s=h.maxElevation)&&void 0!==s?s:Math.max(0,o);}if(n/=t.bD,l/=t.bD,n+=1,l+=1,e.z<=0)return Ci.fromAabb([-l,-l,-l],[l,l,l]);if(1===e.z)return Ci.fromAabb([0===e.x?-l:0,0===e.y?0:-l,-l],[0===e.x?0:l,0===e.y?l:0,l]);{const i=[mi(0,0,e.x,e.y,e.z),mi(t.a6,0,e.x,e.y,e.z),mi(t.a6,t.a6,e.x,e.y,e.z),mi(0,t.a6,e.x,e.y,e.z)],o=[];for(const e of i)o.push(t.aZ([],e,l));if(l!==n)for(const e of i)o.push(t.aZ([],e,n));0===e.y&&o.push([0,1,0]),e.y===(1<<e.z)-1&&o.push([0,-1,0]);const a=[1,1,1],r=[-1,-1,-1];for(const e of o)for(let t=0;t<3;t++)a[t]=Math.min(a[t],e[t]),r[t]=Math.max(r[t],e[t]);const s=mi(t.a6/2,t.a6/2,e.x,e.y,e.z),c=t.b2([],[0,1,0],s);t.b1(c,c);const h=t.b2([],s,c);t.b1(h,h);const u=t.b2([],i[2],i[1]);t.b1(u,u);const d=t.b2([],i[0],i[3]);t.b1(d,d),o.push(t.aZ([],s,l)),e.y>=(1<<e.z)/2&&o.push(t.aZ([],mi(t.a6/2,0,e.x,e.y,e.z),l)),e.y<(1<<e.z)/2&&o.push(t.aZ([],mi(t.a6/2,t.a6,e.x,e.y,e.z),l));const _=Si(s,o),p=Si(h,o),m=[-s[0],-s[1],-s[2],_.max],f=[s[0],s[1],s[2],-_.min],g=[-h[0],-h[1],-h[2],p.max],v=[h[0],h[1],h[2],-p.min],x=[...u,0],b=[...d,0],y=[];return 0===e.y?y.push(t.bC(b,x,m),t.bC(b,x,f)):y.push(t.bC(g,x,m),t.bC(g,x,f),t.bC(g,b,m),t.bC(g,b,f)),e.y===(1<<e.z)-1?y.push(t.bC(b,x,m),t.bC(b,x,f)):y.push(t.bC(v,x,m),t.bC(v,x,f),t.bC(v,b,m),t.bC(v,b,f)),new Ci(y,[m,f,g,v,x,b],a,r)}}}function Si(e,i){let o=1/0,a=-1/0;for(const r of i){const i=t.b3(e,r);o=Math.min(o,i),a=Math.max(a,i);}return {min:o,max:a}}class zi{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e);}setMaxZoom(e){this._helper.setMaxZoom(e);}setMinPitch(e){this._helper.setMinPitch(e);}setMaxPitch(e){this._helper.setMaxPitch(e);}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e);}setBearing(e){this._helper.setBearing(e);}setPitch(e){this._helper.setPitch(e);}setRoll(e){this._helper.setRoll(e);}setFov(e){this._helper.setFov(e);}setZoom(e){this._helper.setZoom(e);}setCenter(e){this._helper.setCenter(e);}setElevation(e){this._helper.setElevation(e);}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e);}setPadding(e){this._helper.setPadding(e);}interpolatePadding(e,t,i){this._helper.interpolatePadding(e,t,i);}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t){this._helper.resize(e,t);}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e);}setConstrainOverride(e){this._helper.setConstrainOverride(e);}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t);}clearNearFarZOverride(){this._helper.clearNearFarZOverride();}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e){}constructor(e){this._cachedClippingPlane=t.bE(),this._projectionMatrix=t.bi(),this._globeViewProjMatrix32f=t.bh(),this._globeViewProjMatrixNoCorrection=t.bi(),this._globeViewProjMatrixNoCorrectionInverted=t.bi(),this._globeProjMatrixInverted=t.bi(),this._cameraPosition=t.bz(),this._globeLatitudeErrorCorrectionRadians=0,this.defaultConstrain=(e,i)=>{const o=t.al(e.lat,-t.am,t.am),a=t.al(+i,this.minZoom+bi(0,o),this.maxZoom);return {center:new t.W(e.lng,o),zoom:a}},this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new Wt({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._coveringTilesDetailsProvider=new Ei;}clone(){const e=new zi;return e.apply(this,!1),e}apply(e,t,i){this._globeLatitudeErrorCorrectionRadians=i||0,this._helper.apply(e,t);}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const e=t.bz();return e[0]=this._cameraPosition[0],e[1]=this._cameraPosition[1],e[2]=this._cameraPosition[2],e}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(e){const{overscaledTileID:t,applyGlobeMatrix:i}=e,o=this._helper.getMercatorTileCoordinates(t);return {mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:o,clippingPlane:this._cachedClippingPlane,projectionTransition:i?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(e){const i=this.pitchInRadians,o=this.cameraToCenterDistance/e,a=Math.sin(i)*o,r=Math.cos(i)*o+1,s=1/Math.sqrt(a*a+r*r)*1;let n=-a,l=r;const c=Math.sqrt(n*n+l*l);n/=c,l/=c;const h=[0,n,l];t.bF(h,h,[0,0,0],-this.bearingInRadians),t.bG(h,h,[0,0,0],-1*this.center.lat*Math.PI/180),t.bH(h,h,[0,0,0],this.center.lng*Math.PI/180);const u=1/t.b5(h);return t.aZ(h,h,u),[...h,-s*u]}isLocationOccluded(e){return !this.isSurfacePointVisible(fi(e))}transformLightDirection(e){const i=this._helper._center.lng*Math.PI/180,o=this._helper._center.lat*Math.PI/180,a=Math.cos(o),r=[Math.sin(i)*a,Math.sin(o),Math.cos(i)*a],s=[r[2],0,-r[0]],n=[0,0,0];t.b2(n,s,r),t.b1(s,s),t.b1(n,n);const l=[0,0,0];return t.b1(l,[s[0]*e[0]+n[0]*e[1]+r[0]*e[2],s[1]*e[0]+n[1]*e[1]+r[1]*e[2],s[2]*e[0]+n[2]*e[1]+r[2]*e[2]]),l}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(e,i,o){const a=function(e,i,o){const a=1/(1<<o.z);return new t.a7(e/t.a6*a+o.x*a,i/t.a6*a+o.y*a)}(e,i,o.canonical),r=(s=a.y,[t.by(a.x*Math.PI*2+Math.PI,2*Math.PI),2*Math.atan(Math.exp(Math.PI-s*Math.PI*2))-.5*Math.PI]);var s;return this.getCircleRadiusCorrection()/Math.cos(r[1])}projectTileCoordinates(e,i,o,a){const r=o.canonical,s=mi(e,i,r.x,r.y,r.z),n=1+(a?a(e,i):0)/t.bD,l=[s[0]*n,s[1]*n,s[2]*n,1];t.aE(l,l,this._globeViewProjMatrixNoCorrection);const c=this._cachedClippingPlane,h=c[0]*s[0]+c[1]*s[1]+c[2]*s[2]+c[3]<0;return {point:new t.P(l[0]/l[3],l[1]/l[3]),signedDistanceFromCamera:l[3],isOccluded:h}}_calcMatrices(){if(!this._helper._width||!this._helper._height)return;const e=gi(this.worldSize,this.center.lat),i=t.bj(),o=t.bj();this._helper.autoCalculateNearFarZ&&(this._helper._nearZ=.5,this._helper._farZ=this.cameraToCenterDistance+2*e),t.bc(i,this.fovInRadians,this.width/this.height,this._helper._nearZ,this._helper._farZ);const a=this.centerOffset;i[8]=2*-a.x/this._helper._width,i[9]=2*a.y/this._helper._height,this._projectionMatrix=t.bd(i),this._globeProjMatrixInverted=t.bj(),t.bg(this._globeProjMatrixInverted,i),t.Q(i,i,[0,0,-this.cameraToCenterDistance]),t.be(i,i,this.rollInRadians),t.bf(i,i,-this.pitchInRadians),t.be(i,i,this.bearingInRadians),t.Q(i,i,[0,0,-e]);const r=t.bz();r[0]=e,r[1]=e,r[2]=e,t.bf(o,i,this.center.lat*Math.PI/180),t.bI(o,o,-this.center.lng*Math.PI/180),t.S(o,o,r),this._globeViewProjMatrixNoCorrection=o,t.bf(i,i,this.center.lat*Math.PI/180-this._globeLatitudeErrorCorrectionRadians),t.bI(i,i,-this.center.lng*Math.PI/180),t.S(i,i,r),this._globeViewProjMatrix32f=new Float32Array(i),this._globeViewProjMatrixNoCorrectionInverted=t.bj(),t.bg(this._globeViewProjMatrixNoCorrectionInverted,o);const s=t.bz();this._cameraPosition=t.bz(),this._cameraPosition[2]=this.cameraToCenterDistance/e,t.bF(this._cameraPosition,this._cameraPosition,s,-this.rollInRadians),t.bG(this._cameraPosition,this._cameraPosition,s,this.pitchInRadians),t.bF(this._cameraPosition,this._cameraPosition,s,-this.bearingInRadians),t.a_(this._cameraPosition,this._cameraPosition,[0,0,1]),t.bG(this._cameraPosition,this._cameraPosition,s,-this.center.lat*Math.PI/180),t.bH(this._cameraPosition,this._cameraPosition,s,this.center.lng*Math.PI/180),this._cachedClippingPlane=this._computeClippingPlane(e);const n=t.bd(this._globeViewProjMatrixNoCorrectionInverted);t.S(n,n,[1,1,-1]),this._cachedFrustum=Ht.fromInvProjectionMatrix(n,1,0,this._cachedClippingPlane,!0);}calculateFogMatrix(e){t.w("calculateFogMatrix is not supported on globe projection.");const i=t.bj();return t.ap(i),i}getVisibleUnwrappedCoordinates(e){return [new t.ba(0,e)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){e&&t.w("terrain is not fully supported on vertical perspective projection."),this._helper.recalculateZoomAndCenter(0);}maxPitchScaleFactor(){return 1}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,i){if(!this._globeViewProjMatrixNoCorrection)return 1;const o=fi(e);t.aZ(o,o,1+i/t.bD);const a=t.bE();return t.aE(a,[o[0],o[1],o[2],1],this._globeViewProjMatrixNoCorrection),a[2]/a[3]}populateCache(e){}getBounds(){const e=.5*this.width,i=.5*this.height,o=[new t.P(0,0),new t.P(e,0),new t.P(this.width,0),new t.P(this.width,i),new t.P(this.width,this.height),new t.P(e,this.height),new t.P(0,this.height),new t.P(0,i)],a=[];for(const e of o)a.push(this.unprojectScreenPoint(e));let r=0,s=0,n=0,l=0;const c=this.center;for(const e of a){const i=t.bJ(c.lng,e.lng),o=t.bJ(c.lat,e.lat);i<s&&(s=i),i>r&&(r=i),o<l&&(l=o),o>n&&(n=o);}const h=[c.lng+s,c.lat+l,c.lng+r,c.lat+n];return this.isSurfacePointOnScreen([0,1,0])&&(h[3]=90,h[0]=-180,h[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(h[1]=-90,h[0]=-180,h[2]=180),new G(h)}calculateCenterFromCameraLngLatAlt(e,t,i,o){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,o)}setLocationAtPoint(e,i){const o=fi(this.unprojectScreenPoint(i)),a=fi(e),r=t.bz();t.bK(r);const s=t.bz();t.bH(s,o,r,-this.center.lng*Math.PI/180),t.bG(s,s,r,this.center.lat*Math.PI/180);const n=a[0]*a[0]+a[2]*a[2],l=s[0]*s[0];if(n<l)return;const c=Math.sqrt(n-l),h=-c,u=t.bL(a[0],a[2],s[0],c),d=t.bL(a[0],a[2],s[0],h),_=t.bz();t.bH(_,a,r,-u);const p=t.bL(_[1],_[2],s[1],s[2]),m=t.bz();t.bH(m,a,r,-d);const f=t.bL(m[1],m[2],s[1],s[2]),g=.5*Math.PI,v=p>=-g&&p<=g,x=f>=-g&&f<=g;let b,y;if(v&&x){const e=this.center.lng*Math.PI/180,i=this.center.lat*Math.PI/180;t.bM(u,e)+t.bM(p,i)<t.bM(d,e)+t.bM(f,i)?(b=u,y=p):(b=d,y=f);}else if(v)b=u,y=p;else {if(!x)return;b=d,y=f;}const w=b/Math.PI*180,T=y/Math.PI*180,P=this.center.lat;this.setCenter(new t.W(w,t.al(T,-90,90))),this.setZoom(this.zoom+bi(P,this.center.lat));}locationToScreenPoint(e,i){const o=fi(e);if(i){const a=i.getElevationForLngLatZoom(e,this._helper._tileZoom);t.aZ(o,o,1+a/t.bD);}return this._projectSurfacePointToScreen(o)}_projectSurfacePointToScreen(e){const i=t.bE();return t.aE(i,[...e,1],this._globeViewProjMatrixNoCorrection),i[0]/=i[3],i[1]/=i[3],new t.P((.5*i[0]+.5)*this.width,(.5*-i[1]+.5)*this.height)}screenPointToMercatorCoordinate(e,i){if(i){const t=i.pointCoordinate(e);if(t)return t}return t.a7.fromLngLat(this.unprojectScreenPoint(e))}screenPointToLocation(e,t){var i;return null===(i=this.screenPointToMercatorCoordinate(e,t))||void 0===i?void 0:i.toLngLat()}isPointOnMapSurface(e,t){const i=this._cameraPosition,o=this.getRayDirectionFromPixel(e);return !!this.rayPlanetIntersection(i,o)}getRayDirectionFromPixel(e){const i=t.bE();i[0]=e.x/this.width*2-1,i[1]=-1*(e.y/this.height*2-1),i[2]=1,i[3]=1,t.aE(i,i,this._globeViewProjMatrixNoCorrectionInverted),i[0]/=i[3],i[1]/=i[3],i[2]/=i[3];const o=t.bz();o[0]=i[0]-this._cameraPosition[0],o[1]=i[1]-this._cameraPosition[1],o[2]=i[2]-this._cameraPosition[2];const a=t.bz();return t.b1(a,o),a}isSurfacePointVisible(e){const t=this._cachedClippingPlane;return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]>=0}isSurfacePointOnScreen(e){if(!this.isSurfacePointVisible(e))return !1;const i=t.bE();return t.aE(i,[...e,1],this._globeViewProjMatrixNoCorrection),i[0]/=i[3],i[1]/=i[3],i[2]/=i[3],i[0]>-1&&i[0]<1&&i[1]>-1&&i[1]<1&&i[2]>-1&&i[2]<1}rayPlanetIntersection(e,i){const o=t.b3(e,i),a=t.bz(),r=t.bz();t.aZ(r,i,o),t.b0(a,e,r);const s=1-t.b3(a,a);if(s<0)return null;const n=t.b3(e,e)-1,l=-o+(o<0?1:-1)*Math.sqrt(s),c=n/l,h=l;return {tMin:Math.min(c,h),tMax:Math.max(c,h)}}unprojectScreenPoint(e){const i=this._cameraPosition,o=this.getRayDirectionFromPixel(e),a=this.rayPlanetIntersection(i,o);if(a){const e=t.bz();t.a_(e,i,[o[0]*a.tMin,o[1]*a.tMin,o[2]*a.tMin]);const r=t.bz();return t.b1(r,e),vi(r)}const r=this._cachedClippingPlane,s=r[0]*o[0]+r[1]*o[1]+r[2]*o[2],n=-t.b9(r,i)/s,l=t.bz();if(n>0)t.a_(l,i,[o[0]*n,o[1]*n,o[2]*n]);else {const e=t.bz();t.a_(e,i,[2*o[0],2*o[1],2*o[2]]);const a=t.b9(this._cachedClippingPlane,e);t.b0(l,e,[this._cachedClippingPlane[0]*a,this._cachedClippingPlane[1]*a,this._cachedClippingPlane[2]*a]);}const c=function(e){const i=t.bz();return i[0]=e[0]*-e[3],i[1]=e[1]*-e[3],i[2]=e[2]*-e[3],{center:i,radius:Math.sqrt(1-e[3]*e[3])}}(r);return vi(function(e,i,o){const a=t.bz();t.b0(a,o,e);const r=t.bz();return t.bx(r,e,a,i/t.b7(a)),r}(c.center,c.radius,l))}getMatrixForModel(e,i){const o=t.W.convert(e),a=1/t.bD,r=t.bi();return t.bI(r,r,o.lng/180*Math.PI),t.bf(r,r,-o.lat/180*Math.PI),t.Q(r,r,[0,0,1+i/t.bD]),t.bf(r,r,.5*Math.PI),t.S(r,r,[a,a,a]),r}getProjectionDataForCustomLayer(e=!0){const i=this.getProjectionData({overscaledTileID:new t.a3(0,0,0,0,0),applyGlobeMatrix:e});return i.tileMercatorCoords=[0,0,1,1],i}getFastPathSimpleProjectionMatrix(e){}}class Ri{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e);}setMaxZoom(e){this._helper.setMaxZoom(e);}setMinPitch(e){this._helper.setMinPitch(e);}setMaxPitch(e){this._helper.setMaxPitch(e);}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e);}setBearing(e){this._helper.setBearing(e);}setPitch(e){this._helper.setPitch(e);}setRoll(e){this._helper.setRoll(e);}setFov(e){this._helper.setFov(e);}setZoom(e){this._helper.setZoom(e);}setCenter(e){this._helper.setCenter(e);}setElevation(e){this._helper.setElevation(e);}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e);}setPadding(e){this._helper.setPadding(e);}interpolatePadding(e,t,i){this._helper.interpolatePadding(e,t,i);}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,i=!0){this._helper.resize(e,t,i);}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e);}setConstrainOverride(e){this._helper.setConstrainOverride(e);}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t);}clearNearFarZOverride(){this._helper.clearNearFarZOverride();}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(e,t){this._globeness=e,this._globeLatitudeErrorCorrectionRadians=t,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame();}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(e){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this.defaultConstrain=(e,t)=>this.currentTransform.defaultConstrain(e,t),this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new Wt({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._globeness=1,this._mercatorTransform=new Xt,this._verticalPerspectiveTransform=new zi;}clone(){const e=new Ri;return e._globeness=this._globeness,e._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,e.apply(this,!1),e}apply(e,t){this._helper.apply(e,t),this._mercatorTransform.apply(this,!1),this._verticalPerspectiveTransform.apply(this,!1,this._globeLatitudeErrorCorrectionRadians);}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(e){const t=this._mercatorTransform.getProjectionData(e),i=this._verticalPerspectiveTransform.getProjectionData(e);return {mainMatrix:this.isGlobeRendering?i.mainMatrix:t.mainMatrix,clippingPlane:i.clippingPlane,tileMercatorCoords:i.tileMercatorCoords,projectionTransition:e.applyGlobeMatrix?this._globeness:0,fallbackMatrix:t.fallbackMatrix}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return t.bt(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return t.bt(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,i,o){const a=this._mercatorTransform.getPitchedTextCorrection(e,i,o),r=this._verticalPerspectiveTransform.getPitchedTextCorrection(e,i,o);return t.bt(a,r,this._globeness)}projectTileCoordinates(e,t,i,o){return this.currentTransform.projectTileCoordinates(e,t,i,o)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,!1,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ);}calculateFogMatrix(e){return this.currentTransform.calculateFogMatrix(e)}getVisibleUnwrappedCoordinates(e){return this.currentTransform.getVisibleUnwrappedCoordinates(e)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(e){this._mercatorTransform.recalculateZoomAndCenter(e),this._verticalPerspectiveTransform.recalculateZoomAndCenter(e);}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,t){return this.currentTransform.lngLatToCameraDepth(e,t)}populateCache(e){this._mercatorTransform.populateCache(e),this._verticalPerspectiveTransform.populateCache(e);}getBounds(){return this.currentTransform.getBounds()}calculateCenterFromCameraLngLatAlt(e,t,i,o){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,o)}setLocationAtPoint(e,t){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,t),void this.apply(this._mercatorTransform,!1);this._verticalPerspectiveTransform.setLocationAtPoint(e,t),this.apply(this._verticalPerspectiveTransform,!1);}locationToScreenPoint(e,t){return this.currentTransform.locationToScreenPoint(e,t)}screenPointToMercatorCoordinate(e,t){return this.currentTransform.screenPointToMercatorCoordinate(e,t)}screenPointToLocation(e,t){return this.currentTransform.screenPointToLocation(e,t)}isPointOnMapSurface(e,t){return this.currentTransform.isPointOnMapSurface(e,t)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getMatrixForModel(e,t){return this.currentTransform.getMatrixForModel(e,t)}getProjectionDataForCustomLayer(e=!0){const t=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return t;const i=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return i.fallbackMatrix=t.mainMatrix,i}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}}class Di{get useGlobeControls(){return !0}handlePanInertia(e,i){const o=yi(e,i);return Math.abs(o.lng-i.center.lng)>180&&(o.lng=i.center.lng+179.5*Math.sign(o.lng-i.center.lng)),{easingCenter:o,easingOffset:new t.P(0,0)}}handleMapControlsRollPitchBearingZoom(e,i){const o=e.around,a=i.screenPointToLocation(o);e.bearingDelta&&i.setBearing(i.bearing+e.bearingDelta),e.pitchDelta&&i.setPitch(i.pitch+e.pitchDelta),e.rollDelta&&i.setRoll(i.roll+e.rollDelta);const r=i.zoom;e.zoomDelta&&i.setZoom(i.zoom+e.zoomDelta);const s=i.zoom-r;if(0===s)return;const n=t.bJ(i.center.lng,a.lng),l=n/(Math.abs(n/180)+1),c=t.bJ(i.center.lat,a.lat),h=i.getRayDirectionFromPixel(o),u=i.cameraPosition,d=-1*t.b3(u,h),_=t.bz();t.a_(_,u,[h[0]*d,h[1]*d,h[2]*d]);const p=t.b5(_)-1,m=Math.exp(.5*-Math.max(p-.3,0)),f=gi(i.worldSize,i.center.lat)/Math.min(i.width,i.height),g=t.bw(f,.9,.5,1,.25),v=(1-t.ao(-s))*Math.min(m,g),x=i.center.lat,b=i.zoom,y=new t.W(i.center.lng+l*v,t.al(i.center.lat+c*v,-t.am,t.am));i.setLocationAtPoint(a,o);const w=i.center,T=t.bw(Math.abs(n),45,85,0,1),P=t.bw(f,.75,.35,0,1),C=Math.pow(Math.max(T,P),.25),M=t.bJ(w.lng,y.lng),I=t.bJ(w.lat,y.lat);i.setCenter(new t.W(w.lng+M*C,w.lat+I*C).wrap()),i.setZoom(b+bi(x,i.center.lat));}handleMapControlsPan(e,t,i){if(!e.panDelta)return;const o=t.center.lat,a=t.zoom;t.setCenter(yi(e.panDelta,t).wrap()),t.setZoom(a+bi(o,t.center.lat));}cameraForBoxAndBearing(e,i,o,a,r){const s=Qt(e,i,o,a,r),n=i.left/r.width*2-1,l=(r.width-i.right)/r.width*2-1,c=i.top/r.height*-2+1,h=(r.height-i.bottom)/r.height*-2+1,u=t.bJ(o.getWest(),o.getEast())<0,d=u?o.getEast():o.getWest(),_=u?o.getWest():o.getEast(),p=Math.max(o.getNorth(),o.getSouth()),m=Math.min(o.getNorth(),o.getSouth()),f=d+.5*t.bJ(d,_),g=p+.5*t.bJ(p,m),v=r.clone();v.setCenter(s.center),v.setBearing(s.bearing),v.setPitch(0),v.setRoll(0),v.setZoom(s.zoom);const x=v.modelViewProjectionMatrix,b=[fi(o.getNorthWest()),fi(o.getNorthEast()),fi(o.getSouthWest()),fi(o.getSouthEast()),fi(new t.W(_,g)),fi(new t.W(d,g)),fi(new t.W(f,p)),fi(new t.W(f,m))],y=fi(s.center);let w=Number.POSITIVE_INFINITY;for(const e of b)n<0&&(w=Di.getLesserNonNegativeNonNull(w,Di.solveVectorScale(e,y,x,"x",n))),l>0&&(w=Di.getLesserNonNegativeNonNull(w,Di.solveVectorScale(e,y,x,"x",l))),c>0&&(w=Di.getLesserNonNegativeNonNull(w,Di.solveVectorScale(e,y,x,"y",c))),h<0&&(w=Di.getLesserNonNegativeNonNull(w,Di.solveVectorScale(e,y,x,"y",h)));if(Number.isFinite(w)&&0!==w)return s.zoom=Math.min(v.zoom+t.ar(w),e.maxZoom),s;Kt();}handleJumpToCenterZoom(e,i){const o=e.center.lat,a=e.applyConstrain(i.center?t.W.convert(i.center):e.center,e.zoom).center;e.setCenter(a.wrap());const r=void 0!==i.zoom?+i.zoom:e.zoom+bi(o,a.lat);e.zoom!==r&&e.setZoom(r);}handleEaseTo(e,i){const o=e.zoom,a=e.center,r=e.padding,s={roll:e.roll,pitch:e.pitch,bearing:e.bearing},n={roll:void 0===i.roll?e.roll:i.roll,pitch:void 0===i.pitch?e.pitch:i.pitch,bearing:void 0===i.bearing?e.bearing:i.bearing},l=void 0!==i.zoom,c=!e.isPaddingEqual(i.padding);let h=!1;const u=i.center?t.W.convert(i.center):a,d=e.applyConstrain(u,o).center;Gt(e,d);const _=e.clone();_.setCenter(d),_.setZoom(l?+i.zoom:o+bi(a.lat,u.lat)),_.setBearing(i.bearing);const p=new t.P(t.al(e.centerPoint.x+i.offsetAsPoint.x,0,e.width),t.al(e.centerPoint.y+i.offsetAsPoint.y,0,e.height));_.setLocationAtPoint(d,p);const m=(i.offset&&i.offsetAsPoint.mag())>0?_.center:d,f=l?+i.zoom:o+bi(a.lat,m.lat),g=o+bi(a.lat,0),v=f+bi(m.lat,0),x=t.bJ(a.lng,m.lng),b=t.bJ(a.lat,m.lat),y=t.ao(v-g);return h=f!==o,{easeFunc:o=>{if(t.bn(s,n)||Yt({startEulerAngles:s,endEulerAngles:n,tr:e,k:o,useSlerp:s.roll!=n.roll}),c&&e.interpolatePadding(r,i.padding,o),i.around)t.w("Easing around a point is not supported under globe projection."),e.setLocationAtPoint(i.around,i.aroundPoint);else {const t=v>g?Math.min(2,y):Math.max(.5,y),i=Math.pow(t,1-o),r=Ti(a,x,b,o*i);e.setCenter(r.wrap());}if(h){const i=t.H.number(g,v,o)+bi(0,e.center.lat);e.setZoom(i);}},isZooming:h,elevationCenter:m}}handleFlyTo(e,i){const o=void 0!==i.zoom,a=e.center,r=e.zoom,s=e.padding,n=!e.isPaddingEqual(i.padding),l=e.applyConstrain(t.W.convert(i.center||i.locationAtOffset),r).center,c=o?+i.zoom:e.zoom+bi(e.center.lat,l.lat),h=e.clone();h.setCenter(l),h.setZoom(c),h.setBearing(i.bearing);const u=new t.P(t.al(e.centerPoint.x+i.offsetAsPoint.x,0,e.width),t.al(e.centerPoint.y+i.offsetAsPoint.y,0,e.height));h.setLocationAtPoint(l,u);const d=h.center;Gt(e,d);const _=function(e,i,o){const a=fi(i),r=fi(o),s=t.b3(a,r),n=Math.acos(s),l=pi(e);return n/(2*Math.PI)*l}(e,a,d),p=r+bi(a.lat,0),m=c+bi(d.lat,0),f=t.ao(m-p);let g;if("number"==typeof i.minZoom){const o=+i.minZoom+bi(d.lat,0),a=Math.min(o,p,m)+bi(0,d.lat),r=e.applyConstrain(d,a).zoom+bi(d.lat,0);g=t.ao(r-p);}const v=t.bJ(a.lng,d.lng),x=t.bJ(a.lat,d.lat);return {easeFunc:(o,r,l,h)=>{const u=Ti(a,v,x,l);n&&e.interpolatePadding(s,i.padding,o);const _=1===o?d:u;e.setCenter(_.wrap());const m=p+t.ar(r);e.setZoom(1===o?c:m+bi(0,_.lat));},scaleOfZoom:f,targetCenter:d,scaleOfMinZoom:g,pixelPathLength:_}}static solveVectorScale(e,t,i,o,a){const r="x"===o?[i[0],i[4],i[8],i[12]]:[i[1],i[5],i[9],i[13]],s=[i[3],i[7],i[11],i[15]],n=e[0]*r[0]+e[1]*r[1]+e[2]*r[2],l=e[0]*s[0]+e[1]*s[1]+e[2]*s[2],c=t[0]*r[0]+t[1]*r[1]+t[2]*r[2],h=t[0]*s[0]+t[1]*s[1]+t[2]*s[2];return c+a*l===n+a*h||s[3]*(n-c)+r[3]*(h-l)+n*h==c*l?null:(c+r[3]-a*h-a*s[3])/(c-n-a*h+a*l)}static getLesserNonNegativeNonNull(e,t){return null!==t&&t>=0&&t<e?t:e}}class Ai{constructor(e){this._globe=e,this._mercatorCameraHelper=new Jt,this._verticalPerspectiveCameraHelper=new Di;}get useGlobeControls(){return this._globe.useGlobeRendering}get currentHelper(){return this.useGlobeControls?this._verticalPerspectiveCameraHelper:this._mercatorCameraHelper}handlePanInertia(e,t){return this.currentHelper.handlePanInertia(e,t)}handleMapControlsRollPitchBearingZoom(e,t){this.currentHelper.handleMapControlsRollPitchBearingZoom(e,t);}handleMapControlsPan(e,t,i){this.currentHelper.handleMapControlsPan(e,t,i);}cameraForBoxAndBearing(e,t,i,o,a){return this.currentHelper.cameraForBoxAndBearing(e,t,i,o,a)}handleJumpToCenterZoom(e,t){this.currentHelper.handleJumpToCenterZoom(e,t);}handleEaseTo(e,t){return this.currentHelper.handleEaseTo(e,t)}handleFlyTo(e,t){return this.currentHelper.handleFlyTo(e,t)}}const Li=(e,i)=>t.C(e,null==i?void 0:i.filter((e=>"source.canvas"!==e.identifier))),Fi=t.bN();class ki extends t.E{constructor(e,i={}){var o,a;super(),this._rtlPluginLoaded=()=>{for(const e in this.tileManagers){const t=this.tileManagers[e].getSource().type;"vector"!==t&&"geojson"!==t||this.tileManagers[e].reload();}},this.map=e,this.dispatcher=new k(F(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",((e,t)=>this.getGlyphs(e,t))),this.dispatcher.registerMessageHandler("GI",((e,t)=>this.getImages(e,t))),this.dispatcher.registerMessageHandler("GDA",((e,t)=>this.getDashes(e,t))),this.imageManager=new g,this.imageManager.setEventedParent(this);const r=(null===(o=e._container)||void 0===o?void 0:o.lang)||"undefined"!=typeof document&&(null===(a=document.documentElement)||void 0===a?void 0:a.lang)||void 0;this.glyphManager=new T(e._requestManager,i.localIdeographFontFamily,r),this.lineAtlas=new S(256,512),this.crossTileSymbolIndex=new At,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast("SR",t.bO()),ce().on(se,this._rtlPluginLoaded),this.on("data",(e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.tileManagers[e.sourceId];if(!t)return;const i=t.getSource();if(null==i?void 0:i.vectorLayerIds)for(const e in this._layers){const t=this._layers[e];t.source===i.id&&this._validateLayer(t);}}));}_setInitialValues(){var e;this._spritesImagesIds={},this._layers={},this._order=[],this.tileManagers={},this.zoomHistory=new t.bP,this._availableImages=[],this._globalState={},this._serializedLayers={},this.stylesheet=null,this.light=null,this.sky=null,this.projection&&(this.projection.destroy(),delete this.projection),this._loaded=!1,this._changed=!1,this._updatedLayers={},this._updatedSources={},this._changedImages={},this._glyphsDidChange=!1,this._updatedPaintProps={},this._layerOrderChanged=!1,this.crossTileSymbolIndex=new((null===(e=this.crossTileSymbolIndex)||void 0===e?void 0:e.constructor)||Object),this.pauseablePlacement=void 0,this.placement=void 0,this.z=0;}setGlobalStateProperty(e,i){var o,a,r;this._checkLoaded();const s=null===i?null!==(r=null===(a=null===(o=this.stylesheet.state)||void 0===o?void 0:o[e])||void 0===a?void 0:a.default)&&void 0!==r?r:null:i;if(t.bQ(s,this._globalState[e]))return this;this._globalState[e]=s,this._applyGlobalStateChanges([e]);}getGlobalState(){return this._globalState}setGlobalState(e){this._checkLoaded();const i=[];for(const o in e)!t.bQ(this._globalState[o],e[o].default)&&(i.push(o),this._globalState[o]=e[o].default);this._applyGlobalStateChanges(i);}_applyGlobalStateChanges(e){if(0===e.length)return;const t=new Set,i={};for(const o of e){i[o]=this._globalState[o];for(const e in this._layers){const i=this._layers[e],a=i.getLayoutAffectingGlobalStateRefs(),r=i.getPaintAffectingGlobalStateRefs(),s=i.getVisibilityAffectingGlobalStateRefs();if(a.has(o)&&t.add(i.source),r.has(o))for(const{name:e,value:t}of r.get(o))this._updatePaintProperty(i,e,t);(null==s?void 0:s.has(o))&&(i.recalculateVisibility(),this._updateLayer(i));}}this.dispatcher.broadcast("UGS",i);for(const e in this.tileManagers)t.has(e)&&(this._reloadSource(e),this._changed=!0);}loadURL(e){return t._(this,arguments,void 0,(function*(e,i={},o){this.fire(new t.n("dataloading",{dataType:"style"})),i.validate="boolean"!=typeof i.validate||i.validate,this._loadStyleRequest=new AbortController;const a=this._loadStyleRequest;try{const r=yield this.map._requestManager.transformRequest(e,"Style");t.bR(a.signal);const s=yield t.k(r,a);this._loadStyleRequest===a&&(this._loadStyleRequest=null),this._load(s.data,i,o);}catch(e){this._loadStyleRequest===a&&(this._loadStyleRequest=null),e&&!a.signal.aborted&&this.fire(new t.l(t.d(e)));}}))}loadJSON(e,i={},o){this.fire(new t.n("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,n.frameAsync(this._frameRequest,this.map._ownerWindow).then((()=>{this._frameRequest=null,i.validate=!1!==i.validate,this._load(e,i,o);})).catch((()=>{}));}loadEmpty(){this.fire(new t.n("dataloading",{dataType:"style"})),this._load(Fi,{validate:!1});}_load(e,i,o){var a,r;let s=i.transformStyle?i.transformStyle(o,e):e;if(!i.validate||!Li(this,t.F(s))){s=Object.assign({},s),this._loaded=!0,this.stylesheet=s;for(const e in s.sources)this.addSource(e,s.sources[e],{validate:!1});s.sprite?this._loadSprite(s.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(s.glyphs),this._createLayers(),this.light=new M(this.stylesheet.light),this._setProjectionInternal((null===(a=this.stylesheet.projection)||void 0===a?void 0:a.type)||"mercator"),this.sky=new E(this.stylesheet.sky),this.map.setTerrain(null!==(r=this.stylesheet.terrain)&&void 0!==r?r:null),this.fire(new t.n("data",{dataType:"style"})),this.fire(new t.n("style.load"));}}_createLayers(){var e,i,o;const a=t.bS(this.stylesheet.layers);this.setGlobalState(null!==(e=this.stylesheet.state)&&void 0!==e?e:null),this.dispatcher.broadcast("SL",a),this._order=a.map((e=>e.id)),this._layers={},this._serializedLayers=null;for(const e of a){const a=t.bT(e,this._globalState);if(a.setEventedParent(this,{layer:{id:e.id}}),this._layers[e.id]=a,t.bU(a)&&this.tileManagers[a.source]){const t=null!==(o=null===(i=e.paint)||void 0===i?void 0:i["raster-fade-duration"])&&void 0!==o?o:a.paint.get("raster-fade-duration");this.tileManagers[a.source].setRasterFadeDuration(t);}}}_loadSprite(e,i=!1,o=void 0){this.imageManager.setLoaded(!1);const a=new AbortController;let r;this._spriteRequest=a,function(e,i,o,a){return t._(this,void 0,void 0,(function*(){const r=p(e),s=o>1?"@2x":"",l={},c={};for(const{id:e,url:o}of r){const r=yield i.transformRequest(m(o,s,".json"),"SpriteJSON");l[e]=t.k(r,a);const n=yield i.transformRequest(m(o,s,".png"),"SpriteImage");c[e]=u.getImage(n,a);}return yield Promise.all([...Object.values(l),...Object.values(c)]),function(e,i){return t._(this,void 0,void 0,(function*(){const t={};for(const o in e){t[o]={};const a=n.getImageCanvasContext((yield i[o]).data),r=(yield e[o]).data;for(const e in r){const{width:i,height:s,x:n,y:l,sdf:c,pixelRatio:h,stretchX:u,stretchY:d,content:_,textFitWidth:p,textFitHeight:m}=r[e];t[o][e]={data:null,pixelRatio:h,sdf:c,stretchX:u,stretchY:d,content:_,textFitWidth:p,textFitHeight:m,spriteData:{width:i,height:s,x:n,y:l,context:a}};}}return t}))}(l,c)}))}(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then((e=>{if(this._spriteRequest=null,e)for(const t in e){this._spritesImagesIds[t]=[];const o=this._spritesImagesIds[t]?this._spritesImagesIds[t].filter((t=>!(t in e))):[];for(const e of o)this.imageManager.removeImage(e),this._changedImages[e]=!0;for(const o in e[t]){const a="default"===t?o:`${t}:${o}`;this._spritesImagesIds[t].push(a),a in this.imageManager.images?this.imageManager.updateImage(a,e[t][o],!1):this.imageManager.addImage(a,e[t][o]),i&&(this._changedImages[a]=!0);}}})).catch((e=>{this._spriteRequest=null,r=e,a.signal.aborted||this.fire(new t.l(r));})).finally((()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),i&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.n("data",{dataType:"style"})),o&&o(r);}));}_unloadSprite(){for(const e of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(e),this._changedImages[e]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.n("data",{dataType:"style"}));}_validateLayer(e){const i=this.tileManagers[e.source];if(!i)return;const o=e.sourceLayer;if(!o)return;const a=i.getSource();("geojson"===a.type||a.vectorLayerIds&&!a.vectorLayerIds.includes(o))&&this.fire(new t.l(new Error(`Source layer "${o}" does not exist on source "${a.id}" as specified by style layer "${e.id}".`)));}loaded(){if(!this._loaded)return !1;if(Object.keys(this._updatedSources).length)return !1;for(const e in this.tileManagers)if(!this.tileManagers[e].loaded())return !1;return this.imageManager.isLoaded()}_serializeByIds(e,i=!1){const o=this._serializedAllLayers();if(!e||0===e.length)return Object.values(i?t.bV(o):o);const a=[];for(const r of e)if(o[r]){const e=i?t.bV(o[r]):o[r];a.push(e);}return a}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};const t=Object.keys(this._layers);for(const i of t){const t=this._layers[i];"custom"!==t.type&&(e[i]=t.serialize());}return e}hasTransitions(){var e,t,i;if(null===(e=this.light)||void 0===e?void 0:e.hasTransition())return !0;if(null===(t=this.sky)||void 0===t?void 0:t.hasTransition())return !0;if(null===(i=this.projection)||void 0===i?void 0:i.hasTransition())return !0;for(const e in this.tileManagers)if(this.tileManagers[e].hasTransition())return !0;for(const e in this._layers)if(this._layers[e].hasTransition())return !0;return !1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(e){if(!this._loaded)return;const i=this._changed;if(i){const t=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(t.length||i.length)&&this._updateWorkerLayers(t,i);for(const e in this._updatedSources){const t=this._updatedSources[e];if("reload"===t)this._reloadSource(e);else {if("clear"!==t)throw new Error(`Invalid action ${t}`);this._clearSource(e);}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const t in this._updatedPaintProps)this._layers[t].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates();}const o={};for(const e in this.tileManagers){const t=this.tileManagers[e];o[e]=t.used,t.used=!1;}for(const t of this._order){const i=this._layers[t];i.recalculate(e,this._availableImages),!i.isHidden(e.zoom)&&i.source&&(this.tileManagers[i.source].used=!0);}for(const e in o){const i=this.tileManagers[e];!!o[e]!=!!i.used&&i.fire(new t.n("data",{sourceDataType:"visibility",dataType:"source",sourceId:e}));}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,i&&this.fire(new t.n("data",{dataType:"style"}));}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const t in this.tileManagers)this.tileManagers[t].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={};}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const e in this.tileManagers)this.tileManagers[e].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1;}}_updateWorkerLayers(e,t){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:t});}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1;}setState(e,i={}){var o;this._checkLoaded();const a=this.serialize();if(e=i.transformStyle?i.transformStyle(a,e):e,(null===(o=i.validate)||void 0===o||o)&&Li(this,t.F(e)))return !1;(e=t.bV(e)).layers=t.bS(e.layers);const r=t.bW(a,e),s=this._getOperationsToPerform(r);if(s.unimplemented.length>0)throw new Error(`Unimplemented: ${s.unimplemented.join(", ")}.`);if(0===s.operations.length)return !1;for(const e of s.operations)e();return this.stylesheet=e,this._serializedLayers=null,this.fire(new t.n("style.load",{style:this})),!0}_getOperationsToPerform(e){const t=[],i=[];for(const o of e)switch(o.command){case "setCenter":case "setZoom":case "setBearing":case "setPitch":case "setRoll":continue;case "addLayer":t.push((()=>this.addLayer.apply(this,o.args)));break;case "removeLayer":t.push((()=>this.removeLayer.apply(this,o.args)));break;case "setPaintProperty":t.push((()=>this.setPaintProperty.apply(this,o.args)));break;case "setLayoutProperty":t.push((()=>this.setLayoutProperty.apply(this,o.args)));break;case "setFilter":t.push((()=>this.setFilter.apply(this,o.args)));break;case "addSource":t.push((()=>this.addSource.apply(this,o.args)));break;case "removeSource":t.push((()=>this.removeSource.apply(this,o.args)));break;case "setLayerZoomRange":t.push((()=>this.setLayerZoomRange.apply(this,o.args)));break;case "setLight":t.push((()=>this.setLight.apply(this,o.args)));break;case "setGeoJSONSourceData":t.push((()=>this.setGeoJSONSourceData.apply(this,o.args)));break;case "setGlyphs":t.push((()=>this.setGlyphs.apply(this,o.args)));break;case "setSprite":t.push((()=>this.setSprite.apply(this,o.args)));break;case "setTerrain":t.push((()=>this.map.setTerrain.apply(this,o.args)));break;case "setSky":t.push((()=>this.setSky.apply(this,o.args)));break;case "setProjection":this.setProjection.apply(this,o.args);break;case "setGlobalState":t.push((()=>this.setGlobalState.apply(this,o.args)));break;case "setTransition":t.push((()=>{}));break;default:i.push(o.command);}return {operations:t,unimplemented:i}}addImage(e,i){if(this.getImage(e))return this.fire(new t.l(new Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,i),this._afterImageUpdated(e);}updateImage(e,t){this.imageManager.updateImage(e,t);}getImage(e){return this.imageManager.getImage(e)}removeImage(e){if(!this.getImage(e))return this.fire(new t.l(new Error(`An image named "${e}" does not exist.`)));this.imageManager.removeImage(e),this._afterImageUpdated(e);}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.n("data",{dataType:"style"}));}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,i,o={}){var a;if(this._checkLoaded(),void 0!==this.tileManagers[e])throw new Error(`Source "${e}" already exists.`);if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].includes(i.type)&&this._validate(t.F.source,`sources.${e}`,i,null,o))return;(null===(a=this.map)||void 0===a?void 0:a._collectResourceTiming)&&(i.collectResourceTiming=!0);const r=this.tileManagers[e]=new Fe(e,i,this.dispatcher);r.style=this,r.setEventedParent(this,(()=>({isSourceLoaded:r.loaded(),source:r.serialize(),sourceId:e}))),r.onAdd(this.map),this._changed=!0;}removeSource(e){if(this._checkLoaded(),void 0===this.tileManagers[e])throw new Error(`There is no source with this ID=${e}`);for(const i in this._layers)if(this._layers[i].source===e)return this.fire(new t.l(new Error(`Source "${e}" cannot be removed while layer "${i}" is using it.`)));const i=this.tileManagers[e];delete this.tileManagers[e],delete this._updatedSources[e],i.fire(new t.n("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),i.setEventedParent(null),i.onRemove(this.map),this._changed=!0;}setGeoJSONSourceData(e,t){if(this._checkLoaded(),void 0===this.tileManagers[e])throw new Error(`There is no source with this ID=${e}`);const i=this.tileManagers[e].getSource();if("geojson"!==i.type)throw new Error(`geojsonSource.type is ${i.type}, which is !== 'geojson`);i.setData(t),this._changed=!0;}getSource(e){var t;return null===(t=this.tileManagers[e])||void 0===t?void 0:t.getSource()}addLayer(e,i,o={}){this._checkLoaded();const a=e.id;if(this.getLayer(a))return void this.fire(new t.l(new Error(`Layer "${a}" already exists on this map.`)));let r;if("custom"===e.type){if(Li(this,t.bX(e)))return;r=t.bT(e,this._globalState);}else {if("source"in e&&"object"==typeof e.source&&(this.addSource(a,e.source),e=t.bV(e),e=t.e(e,{source:a})),this._validate(t.F.layer,`layers.${a}`,e,{arrayIndex:-1},o))return;r=t.bT(e,this._globalState),this._validateLayer(r),r.setEventedParent(this,{layer:{id:a}});}const s=i?this._order.indexOf(i):this._order.length;if(i&&-1===s)this.fire(new t.l(new Error(`Cannot add layer "${a}" before non-existing layer "${i}".`)));else {if(this._order.splice(s,0,a),this._layerOrderChanged=!0,this._layers[a]=r,this._removedLayers[a]&&r.source&&"custom"!==r.type){const e=this._removedLayers[a];delete this._removedLayers[a],e.type!==r.type?this._updatedSources[r.source]="clear":(this._updatedSources[r.source]="reload",this.tileManagers[r.source].pause());}this._updateLayer(r),r.onAdd&&r.onAdd(this.map);}}moveLayer(e,i){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new t.l(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===i)return;const o=this._order.indexOf(e);this._order.splice(o,1);const a=i?this._order.indexOf(i):this._order.length;i&&-1===a?this.fire(new t.l(new Error(`Cannot move layer "${e}" before non-existing layer "${i}".`))):(this._order.splice(a,0,e),this._layerOrderChanged=!0);}removeLayer(e){this._checkLoaded();const i=this._layers[e];if(!i)return void this.fire(new t.l(new Error(`Cannot remove non-existing layer "${e}".`)));i.setEventedParent(null);const o=this._order.indexOf(e);this._order.splice(o,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=i,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],i.onRemove&&i.onRemove(this.map);}getLayer(e){return this._layers[e]}getLayersOrder(){return [...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,i,o){this._checkLoaded();const a=this.getLayer(e);a?a.minzoom===i&&a.maxzoom===o||(null!=i&&(a.minzoom=i),null!=o&&(a.maxzoom=o),this._updateLayer(a)):this.fire(new t.l(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)));}setFilter(e,i,o={}){this._checkLoaded();const a=this.getLayer(e);if(a){if(!t.bQ(a.filter,i))return null==i?(a.setFilter(void 0),void this._updateLayer(a)):void(this._validate(t.F.filter,`layers.${a.id}.filter`,i,null,o)||(a.setFilter(t.bV(i)),this._updateLayer(a)))}else this.fire(new t.l(new Error(`Cannot filter non-existing layer "${e}".`)));}getFilter(e){return t.bV(this.getLayer(e).filter)}setLayoutProperty(e,i,o,a={}){this._checkLoaded();const r=this.getLayer(e);r?t.bQ(r.getLayoutProperty(i),o)||(r.setLayoutProperty(i,o,a),this._updateLayer(r)):this.fire(new t.l(new Error(`Cannot style non-existing layer "${e}".`)));}getLayoutProperty(e,i){const o=this.getLayer(e);if(o)return o.getLayoutProperty(i);this.fire(new t.l(new Error(`Cannot get style of non-existing layer "${e}".`)));}setPaintProperty(e,i,o,a={}){this._checkLoaded();const r=this.getLayer(e);r?t.bQ(r.getPaintProperty(i),o)||this._updatePaintProperty(r,i,o,a):this.fire(new t.l(new Error(`Cannot style non-existing layer "${e}".`)));}_updatePaintProperty(e,i,o,a={}){e.setPaintProperty(i,o,a)&&this._updateLayer(e),t.bU(e)&&"raster-fade-duration"===i&&this.tileManagers[e.source].setRasterFadeDuration(o),this._changed=!0,this._updatedPaintProps[e.id]=!0,this._serializedLayers=null;}getPaintProperty(e,t){return this.getLayer(e).getPaintProperty(t)}setFeatureState(e,i){this._checkLoaded();const o=e.source,a=e.sourceLayer,r=this.tileManagers[o];if(void 0===r)return void this.fire(new t.l(new Error(`The source '${o}' does not exist in the map's style.`)));const s=r.getSource().type;"geojson"===s&&a?this.fire(new t.l(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==s||a?(void 0===e.id&&this.fire(new t.l(new Error("The feature id parameter must be provided."))),r.setFeatureState(a,e.id,i)):this.fire(new t.l(new Error("The sourceLayer parameter must be provided for vector source types.")));}removeFeatureState(e,i){this._checkLoaded();const o=e.source,a=this.tileManagers[o];if(void 0===a)return void this.fire(new t.l(new Error(`The source '${o}' does not exist in the map's style.`)));const r=a.getSource().type,s="vector"===r?e.sourceLayer:void 0;"vector"!==r||s?i&&"string"!=typeof e.id&&"number"!=typeof e.id?this.fire(new t.l(new Error("A feature id is required to remove its specific state property."))):a.removeFeatureState(s,e.id,i):this.fire(new t.l(new Error("The sourceLayer parameter must be provided for vector source types.")));}getFeatureState(e){this._checkLoaded();const i=e.source,o=e.sourceLayer,a=this.tileManagers[i];if(void 0!==a)return "vector"!==a.getSource().type||o?(void 0===e.id&&this.fire(new t.l(new Error("The feature id parameter must be provided."))),a.getFeatureState(o,e.id)):void this.fire(new t.l(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new t.l(new Error(`The source '${i}' does not exist in the map's style.`)));}getTransition(){var e;return t.e({duration:300,delay:0},null===(e=this.stylesheet)||void 0===e?void 0:e.transition)}serialize(){if(!this._loaded)return;const e=t.bY(this.tileManagers,(e=>e.serialize())),i=this._serializeByIds(this._order,!0),o=this.map.getTerrain()||void 0,a=this.stylesheet;return t.bZ({version:a.version,name:a.name,metadata:a.metadata,light:a.light,sky:a.sky,center:a.center,zoom:a.zoom,bearing:a.bearing,pitch:a.pitch,sprite:a.sprite,glyphs:a.glyphs,transition:a.transition,projection:a.projection,sources:e,layers:i,terrain:o},(e=>void 0!==e))}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&"raster"!==this.tileManagers[e.source].getSource().type&&(this._updatedSources[e.source]="reload",this.tileManagers[e.source].pause()),this._serializedLayers=null,this._changed=!0;}_flattenAndSortRenderedFeatures(e){const t=e=>"fill-extrusion"===this._layers[e].type,i={},o=[];for(let a=this._order.length-1;a>=0;a--){const r=this._order[a];if(t(r)){i[r]=a;for(const t of e){const e=t[r];if(e)for(const t of e)o.push(t);}}}o.sort(((e,t)=>t.intersectionZ-e.intersectionZ));const a=[];for(let r=this._order.length-1;r>=0;r--){const s=this._order[r];if(t(s))for(let e=o.length-1;e>=0;e--){const t=o[e].feature;if(i[t.layer.id]<r)break;a.push(t),o.pop();}else for(const t of e){const e=t[s];if(e)for(const t of e)a.push(t.feature);}}return a}queryRenderedFeatures(e,i,o){(null==i?void 0:i.filter)&&this._validate(t.F.filter,"queryRenderedFeatures.filter",i.filter,null,i);const a={};if(null==i?void 0:i.layers){if(!(Array.isArray(i.layers)||i.layers instanceof Set))return this.fire(new t.l(new Error("parameters.layers must be an Array or a Set of strings"))),[];for(const e of i.layers){const i=this._layers[e];if(!i)return this.fire(new t.l(new Error(`The layer '${e}' does not exist in the map's style and cannot be queried for features.`))),[];a[i.source]=!0;}}const r=[];i.availableImages=this._availableImages;const s=this._serializedAllLayers(),n=i.layers instanceof Set?i.layers:Array.isArray(i.layers)?new Set(i.layers):null,l=Object.assign(Object.assign({},i),{layers:n,globalState:this._globalState});for(const t in this.tileManagers)i.layers&&!a[t]||r.push(j(this.tileManagers[t],this._layers,s,e,l,o,this.map.terrain?(e,t,i)=>this.map.terrain.getElevation(e,t,i):void 0));return this.placement&&r.push(function(e,t,i,o,a,r,s){const n={},l=r.queryRenderedSymbols(o),c=[];for(const e of Object.keys(l).map(Number))c.push(s[e]);c.sort(N);for(const i of c){const o=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],t,i.bucketIndex,i.sourceLayerIndex,{filterSpec:a.filter,globalState:a.globalState},a.layers,a.availableImages,e);for(const e in o){n[e]||(n[e]=[]);const t=o[e];t.sort(((e,t)=>{const o=i.featureSortOrder;if(o){const i=o.indexOf(e.featureIndex);return o.indexOf(t.featureIndex)-i}return t.featureIndex-e.featureIndex}));for(const i of t)n[e].push(i);}}return function(e,t,i){for(const o in e)for(const a of e[o])Z(a,i[t[o].source]);return e}(n,e,i)}(this._layers,s,this.tileManagers,e,l,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(r)}querySourceFeatures(e,i){(null==i?void 0:i.filter)&&this._validate(t.F.filter,"querySourceFeatures.filter",i.filter,null,i);const o=this.tileManagers[e];return o?function(e,t){const i=e.getRenderableIds().map((t=>e.getTileByID(t))),o=[],a={};for(const e of i){const i=e.tileID.canonical.key;a[i]||(a[i]=!0,e.querySourceFeatures(o,t));}return o}(o,i?Object.assign(Object.assign({},i),{globalState:this._globalState}):{globalState:this._globalState}):[]}getLight(){return this.light.getLight()}setLight(e,i={}){this._checkLoaded();const o=this.light.getLight();let a=!1;for(const i in e)if(!t.bQ(e[i],o[i])){a=!0;break}if(!a)return;const r={now:c(),transition:t.e({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(e,i),this.light.updateTransitions(r);}getProjection(){var e;return null===(e=this.stylesheet)||void 0===e?void 0:e.projection}setProjection(e){this._checkLoaded();const t=null!=e?e:{type:"mercator"};if(this.stylesheet.projection=e,this.projection){if(this.projection.name===t.type)return;this.projection.destroy(),delete this.projection;}this._setProjectionInternal(t.type);}getSky(){var e;return null===(e=this.stylesheet)||void 0===e?void 0:e.sky}setSky(e,i={}){this._checkLoaded();const o=this.getSky();let a=!1;if(!e&&!o)return;if(e&&!o)a=!0;else if(!e&&o)a=!0;else for(const i in e)if(!t.bQ(e[i],o[i])){a=!0;break}if(!a)return;const r={now:c(),transition:t.e({duration:300,delay:0},this.stylesheet.transition)};this.stylesheet.sky=e,this.sky.setSky(e,i),this.sky.updateTransitions(r);}_setProjectionInternal(e){const i=function(e,i){const o={constrainOverride:i};if(Array.isArray(e)){const t=new _i({type:e});return {projection:t,transform:new Ri(o),cameraHelper:new Ai(t)}}switch(e){case "mercator":return {projection:new Zt,transform:new Xt(o),cameraHelper:new Jt};case "globe":{const e=new _i({type:["interpolate",["linear"],["zoom"],11,"vertical-perspective",12,"mercator"]});return {projection:e,transform:new Ri(o),cameraHelper:new Ai(e)}}case "vertical-perspective":return {projection:new ui,transform:new zi(o),cameraHelper:new Di};default:return t.w(`Unknown projection name: ${e}. Falling back to mercator projection.`),{projection:new Zt,transform:new Xt(o),cameraHelper:new Jt}}}(e,this.map.transformConstrain);this.projection=i.projection,this.map.migrateProjection(i.transform,i.cameraHelper);for(const e in this.tileManagers)this.tileManagers[e].reload();}_validate(e,i,o,a,r={}){return !1!==(null==r?void 0:r.validate)&&Li(this,e.call(t.F,t.e({key:i,style:this.serialize(),value:o,styleSpec:t.x},a)))}_remove(e=!0){this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._loadStyleRequest&&(this._loadStyleRequest.abort(),this._loadStyleRequest=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null),ce().off(se,this._rtlPluginLoaded);for(const e in this._layers)this._layers[e].setEventedParent(null);for(const e in this.tileManagers){const t=this.tileManagers[e];t.setEventedParent(null),t.onRemove(this.map);}this.imageManager.setEventedParent(null),this.setEventedParent(null),e&&this.dispatcher.broadcast("RM",void 0),this.dispatcher.remove(e);}_clearSource(e){this.tileManagers[e].clearTiles();}_reloadSource(e){this.tileManagers[e].resume(),this.tileManagers[e].reload();}_updateSources(e){for(const t in this.tileManagers)this.tileManagers[t].update(e,this.map.terrain);}_generateCollisionBoxes(){for(const e in this.tileManagers)this._reloadSource(e);}_updatePlacement(e,t,i,o,a=!1){let r=!1,s=!1;const n={};for(const t of this._order){const i=this._layers[t];if("symbol"!==i.type)continue;if(!n[i.source]){const e=this.tileManagers[i.source];n[i.source]=e.getRenderableIds(!0).map((t=>e.getTileByID(t))).sort(((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1)));}const o=this.crossTileSymbolIndex.addLayer(i,n[i.source],e.center.lng);r||(r=o);}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),a||(a=this._layerOrderChanged||0===i),(a||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(c(),e.zoom))&&(this.pauseablePlacement=new Et(e,this.map.terrain,this._order,a,t,i,o,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,n),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(c()),s=!0),r&&this.pauseablePlacement.placement.setStale()),s||r)for(const e of this._order){const t=this._layers[e];"symbol"===t.type&&this.placement.updateLayerOpacities(t,n[t.source]);}return !this.pauseablePlacement.isDone()||this.placement.hasTransitions(c())}_releaseSymbolFadeTiles(){for(const e in this.tileManagers)this.tileManagers[e].releaseSymbolFadeTiles();}getImages(e,i){return t._(this,void 0,void 0,(function*(){const e=yield this.imageManager.getImages(i.icons);this._updateTilesForChangedImages();const t=this.tileManagers[i.source];return t&&t.setDependencies(i.tileID.key,i.type,i.icons),e}))}getGlyphs(e,i){return t._(this,void 0,void 0,(function*(){const e=yield this.glyphManager.getGlyphs(i.stacks),t=this.tileManagers[i.source];return t&&t.setDependencies(i.tileID.key,i.type,[""]),e}))}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,i={}){this._checkLoaded(),e&&this._validate(t.F.glyphs,"glyphs",e,null,i)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e));}getDashes(e,i){return t._(this,void 0,void 0,(function*(){const e={};for(const[t,o]of Object.entries(i.dashes))e[t]=this.lineAtlas.getDash(o.dasharray,o.round);return e}))}addSprite(e,i,o={},a){this._checkLoaded();const r=[{id:e,url:i}],s=[...p(this.stylesheet.sprite),...r];this._validate(t.F.sprite,"sprite",s,null,o)||(this.stylesheet.sprite=s,this._loadSprite(r,!0,a));}removeSprite(e){this._checkLoaded();const i=p(this.stylesheet.sprite);if(i.find((t=>t.id===e))){if(this._spritesImagesIds[e])for(const t of this._spritesImagesIds[e])this.imageManager.removeImage(t),this._changedImages[t]=!0;i.splice(i.findIndex((t=>t.id===e)),1),this.stylesheet.sprite=i.length>0?i:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.n("data",{dataType:"style"}));}else this.fire(new t.l(new Error(`Sprite "${e}" doesn't exists on this map.`)));}getSprite(){return p(this.stylesheet.sprite)}setSprite(e,i={},o){this._checkLoaded(),e&&this._validate(t.F.sprite,"sprite",e,null,i)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,o):(this._unloadSprite(),o&&o(null)));}destroy(){this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._loadStyleRequest&&(this._loadStyleRequest.abort(),this._loadStyleRequest=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null);for(const e in this.tileManagers){const t=this.tileManagers[e];t.setEventedParent(null),t.onRemove(this.map);}this.tileManagers={},this.imageManager&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this._availableImages=[],this._spritesImagesIds={}),this.glyphManager&&this.glyphManager.destroy();for(const e in this._layers){const t=this._layers[e];t.setEventedParent(null),t.onRemove&&t.onRemove(this.map);}this._setInitialValues(),this.setEventedParent(null),this.dispatcher.unregisterMessageHandler("GG"),this.dispatcher.unregisterMessageHandler("GI"),this.dispatcher.unregisterMessageHandler("GDA"),this.dispatcher.remove(!0),this._listeners={},this._oneTimeListeners={};}}var Bi=t.aS([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Oi{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null;}bind(e,t,i,o,a,r,s,n,l){this.context=e;let c=this.boundPaintVertexBuffers.length!==o.length;for(let e=0;!c&&e<o.length;e++)this.boundPaintVertexBuffers[e]!==o[e]&&(c=!0);!this.vao||this.boundProgram!==t||this.boundLayoutVertexBuffer!==i||c||this.boundIndexBuffer!==a||this.boundVertexOffset!==r||this.boundDynamicVertexBuffer!==s||this.boundDynamicVertexBuffer2!==n||this.boundDynamicVertexBuffer3!==l?this.freshBind(t,i,o,a,r,s,n,l):(e.bindVertexArray.set(this.vao),s&&s.bind(),(null==a?void 0:a.dynamicDraw)&&a.bind(),n&&n.bind(),l&&l.bind());}freshBind(e,t,i,o,a,r,s,n){const l=e.numAttributes,c=this.context,h=c.gl;this.vao&&this.destroy(),this.vao=c.createVertexArray(),c.bindVertexArray.set(this.vao),this.boundProgram=e,this.boundLayoutVertexBuffer=t,this.boundPaintVertexBuffers=i,this.boundIndexBuffer=o,this.boundVertexOffset=a,this.boundDynamicVertexBuffer=r,this.boundDynamicVertexBuffer2=s,this.boundDynamicVertexBuffer3=n,t.enableAttributes(h,e);for(const t of i)t.enableAttributes(h,e);r&&r.enableAttributes(h,e),s&&s.enableAttributes(h,e),n&&n.enableAttributes(h,e),t.bind(),t.setVertexAttribPointers(h,e,a);for(const t of i)t.bind(),t.setVertexAttribPointers(h,e,a);r&&(r.bind(),r.setVertexAttribPointers(h,e,a)),o&&o.bind(),s&&(s.bind(),s.setVertexAttribPointers(h,e,a)),n&&(n.bind(),n.setVertexAttribPointers(h,e,a)),c.currentNumAttributes=l;}destroy(){this.vao&&(this.context.deleteVertexArray(this.vao),this.vao=null);}}const ji=(e,i,o,a,r)=>({u_texture:0,u_ele_delta:e,u_fog_matrix:i,u_fog_color:o?o.properties.get("fog-color"):t.bo.white,u_fog_ground_blend:o?o.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:r?0:o?o.calculateFogBlendOpacity(a):0,u_horizon_color:o?o.properties.get("horizon-color"):t.bo.white,u_horizon_fog_blend:o?o.properties.get("horizon-fog-blend"):1,u_is_globe_mode:r?1:0}),Ni={mainMatrix:"u_projection_matrix",tileMercatorCoords:"u_projection_tile_mercator_coords",clippingPlane:"u_projection_clipping_plane",projectionTransition:"u_projection_transition",fallbackMatrix:"u_projection_fallback_matrix"};function Zi(e){const t=[];for(const i of e){if(null===i)continue;const e=i.split(" ");t.push(e.pop());}return t}class Ui{constructor(e,i,o,a,r,s,n,l,c=[]){const h=e.gl;this.program=h.createProgram();const u=Zi(i.staticAttributes),d=o?o.getBinderAttributes():[],_=u.concat(d),p=Ft.prelude.staticUniforms?Zi(Ft.prelude.staticUniforms):[],m=n.staticUniforms?Zi(n.staticUniforms):[],f=i.staticUniforms?Zi(i.staticUniforms):[],g=o?o.getBinderUniforms():[],v=p.concat(m).concat(f).concat(g),x=[];for(const e of v)x.includes(e)||x.push(e);const b=o?o.defines():[];si(h)&&b.unshift("#version 300 es"),r&&b.push("#define OVERDRAW_INSPECTOR;"),s&&b.push("#define TERRAIN3D;"),l&&b.push(l),c&&b.push(...c);let y=b.concat(Ft.prelude.fragmentSource,n.fragmentSource,i.fragmentSource).join("\n"),w=b.concat(Ft.prelude.vertexSource,n.vertexSource,i.vertexSource).join("\n");si(h)||(y=function(e){return e.replace(/\bin\s/g,"varying ").replace("out highp vec4 fragColor;","").replace(/fragColor/g,"gl_FragColor").replace(/texture\(/g,"texture2D(")}(y),w=function(e){return e.replace(/\bin\s/g,"attribute ").replace(/\bout\s/g,"varying ").replace(/texture\(/g,"texture2D(")}(w));const T=h.createShader(h.FRAGMENT_SHADER);if(h.isContextLost())return void(this.failedToCreate=!0);if(h.shaderSource(T,y),h.compileShader(T),!h.getShaderParameter(T,h.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${h.getShaderInfoLog(T)}`);h.attachShader(this.program,T);const P=h.createShader(h.VERTEX_SHADER);if(h.isContextLost())return void(this.failedToCreate=!0);if(h.shaderSource(P,w),h.compileShader(P),!h.getShaderParameter(P,h.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${h.getShaderInfoLog(P)}`);h.attachShader(this.program,P),this.attributes={};const C={};this.numAttributes=_.length;for(let e=0;e<this.numAttributes;e++)_[e]&&(h.bindAttribLocation(this.program,e,_[e]),this.attributes[_[e]]=e);if(h.linkProgram(this.program),!h.getProgramParameter(this.program,h.LINK_STATUS))throw new Error(`Program failed to link: ${h.getProgramInfoLog(this.program)}`);h.deleteShader(P),h.deleteShader(T);for(const e of x)if(e&&!C[e]){const t=h.getUniformLocation(this.program,e);t&&(C[e]=t);}this.fixedUniforms=a(e,C),this.terrainUniforms=((e,i)=>({u_depth:new t.b_(e,i.u_depth),u_terrain:new t.b_(e,i.u_terrain),u_terrain_dim:new t.bp(e,i.u_terrain_dim),u_terrain_matrix:new t.c0(e,i.u_terrain_matrix),u_terrain_unpack:new t.c1(e,i.u_terrain_unpack),u_terrain_exaggeration:new t.bp(e,i.u_terrain_exaggeration)}))(e,C),this.projectionUniforms=((e,i)=>({u_projection_matrix:new t.c0(e,i.u_projection_matrix),u_projection_tile_mercator_coords:new t.c1(e,i.u_projection_tile_mercator_coords),u_projection_clipping_plane:new t.c1(e,i.u_projection_clipping_plane),u_projection_transition:new t.bp(e,i.u_projection_transition),u_projection_fallback_matrix:new t.c0(e,i.u_projection_fallback_matrix)}))(e,C),this.binderUniforms=o?o.getUniforms(e,C):[];}draw(e,t,i,o,a,r,s,n,l,c,h,u,d,_,p,m,f,g,v){var x;const b=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(i),e.setStencilMode(o),e.setColorMode(a),e.setCullFace(r),n){e.activeTexture.set(b.TEXTURE2),b.bindTexture(b.TEXTURE_2D,n.depthTexture),e.activeTexture.set(b.TEXTURE3),b.bindTexture(b.TEXTURE_2D,n.texture);for(const e in this.terrainUniforms)this.terrainUniforms[e].set(n[e]);}if(l)for(const e in l)this.projectionUniforms[Ni[e]].set(l[e]);if(s)for(const e in this.fixedUniforms)this.fixedUniforms[e].set(s[e]);m&&m.setUniforms(e,this.binderUniforms,_,{zoom:p});let y=0;switch(t){case b.LINES:y=2;break;case b.TRIANGLES:y=3;break;case b.LINE_STRIP:y=1;}for(const i of d.get())i.vaos||(i.vaos={}),(x=i.vaos)[c]||(x[c]=new Oi),i.vaos[c].bind(e,this,h,m?m.getPaintVertexBuffers():[],u,i.vertexOffset,f,g,v),b.drawElements(t,i.primitiveLength*y,b.UNSIGNED_SHORT,i.primitiveOffset*y*2);}}function Gi(e,i,o){const a=1/t.aK(o,1,i.transform.tileZoom),r=Math.pow(2,o.tileID.overscaledZ),s=o.tileSize*Math.pow(2,i.transform.tileZoom)/r,n=s*(o.tileID.canonical.x+o.tileID.wrap*r),l=s*o.tileID.canonical.y;return {u_image:0,u_texsize:o.imageAtlasTexture.size,u_scale:[a,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[n>>16,l>>16],u_pixel_coord_lower:[65535&n,65535&l]}}const Vi=(e,i,o,a)=>{const r=e.style.light,s=r.properties.get("position"),n=[s.x,s.y,s.z],l=t.c4();"viewport"===r.properties.get("anchor")&&t.c5(l,e.transform.bearingInRadians),t.c6(n,n,l);const c=e.transform.transformLightDirection(n),h=r.properties.get("color");return {u_lightpos:n,u_lightpos_globe:c,u_lightintensity:r.properties.get("intensity"),u_lightcolor:[h.r,h.g,h.b],u_vertical_gradient:+i,u_opacity:o,u_fill_translate:a}},Wi=(e,i,o,a,r,s,n)=>t.e(Vi(e,i,o,a),Gi(s,e,n),{u_height_factor:-Math.pow(2,r.overscaledZ)/n.tileSize/8}),qi=(e,i,o,a)=>t.e(Gi(i,e,o),{u_fill_translate:a}),$i=(e,t)=>({u_world:e,u_fill_translate:t}),Hi=(e,i,o,a,r)=>t.e(qi(e,i,o,r),{u_world:a}),Xi=(e,i,o,a,r)=>{const s=e.transform;let n,l,c=0;if("map"===o.paint.get("circle-pitch-alignment")){const e=t.aK(i,1,s.zoom);n=!0,l=[e,e],c=e/(t.a6*Math.pow(2,i.tileID.overscaledZ))*2*Math.PI*r;}else n=!1,l=s.pixelsToGLUnits;return {u_camera_to_center_distance:s.cameraToCenterDistance,u_scale_with_map:+("map"===o.paint.get("circle-pitch-scale")),u_pitch_with_map:+n,u_device_pixel_ratio:e.pixelRatio,u_extrude_scale:l,u_globe_extrude_scale:c,u_translate:a}},Ki=e=>({u_pixel_extrude_scale:[1/e.width,1/e.height]}),Yi=e=>({u_viewport_size:[e.width,e.height]}),Qi=(e,t=1)=>({u_color:e,u_overlay:0,u_overlay_scale:t}),Ji=(e,i,o,a)=>{const r=t.aK(e,1,i)/(t.a6*Math.pow(2,e.tileID.overscaledZ))*2*Math.PI*a;return {u_extrude_scale:t.aK(e,1,i),u_intensity:o,u_globe_extrude_scale:r}},eo=(e,i,o,a)=>{const r=t.O();t.c7(r,0,e.width,e.height,0,0,1);const s=e.context.gl;return {u_matrix:r,u_world:[s.drawingBufferWidth,s.drawingBufferHeight],u_image:o,u_color_ramp:a,u_opacity:i.paint.get("heatmap-opacity")}},to=(e,t,i)=>{const o=i.paint.get("hillshade-accent-color");let a;switch(i.paint.get("hillshade-method")){case "basic":a=4;break;case "combined":a=1;break;case "igor":a=2;break;case "multidirectional":a=3;break;default:a=0;}const r=i.getIlluminationProperties();for(let t=0;t<r.directionRadians.length;t++)"viewport"===i.paint.get("hillshade-illumination-anchor")&&(r.directionRadians[t]+=e.transform.bearingInRadians);return {u_image:0,u_latrange:oo(0,t.tileID),u_exaggeration:i.paint.get("hillshade-exaggeration"),u_altitudes:r.altitudeRadians,u_azimuths:r.directionRadians,u_accent:o,u_method:a,u_highlights:r.highlightColor,u_shadows:r.shadowColor}},io=(e,i)=>{const o=i.stride,a=t.O();return t.c7(a,0,t.a6,-t.a6,0,0,1),t.Q(a,a,[0,-t.a6,0]),{u_matrix:a,u_image:1,u_dimension:[o,o],u_zoom:e.overscaledZ,u_unpack:i.getUnpackVector()}};function oo(e,i){const o=Math.pow(2,i.canonical.z),a=i.canonical.y;return [new t.a7(0,a/o).toLngLat().lat,new t.a7(0,(a+1)/o).toLngLat().lat]}const ao=(e,t,i=0)=>({u_image:0,u_unpack:t.getUnpackVector(),u_dimension:[t.stride,t.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:i,u_opacity:e.paint.get("color-relief-opacity")}),ro=(e,i,o,a)=>{const r=e.transform;return {u_translation:uo(e,i,o),u_ratio:a/t.aK(i,1,r.zoom),u_device_pixel_ratio:e.pixelRatio,u_units_to_pixels:[1/r.pixelsToGLUnits[0],1/r.pixelsToGLUnits[1]]}},so=(e,i,o,a,r)=>t.e(ro(e,i,o,a),{u_image:0,u_image_height:r}),no=(e,i,o,a,r)=>{const s=e.transform,n=ho(i,s);return {u_translation:uo(e,i,o),u_texsize:i.imageAtlasTexture.size,u_ratio:a/t.aK(i,1,s.zoom),u_device_pixel_ratio:e.pixelRatio,u_image:0,u_scale:[n,r.fromScale,r.toScale],u_fade:r.t,u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]]}},lo=(e,i,o,a,r)=>{const s=ho(i,e.transform);return t.e(ro(e,i,o,a),{u_tileratio:s,u_crossfade_from:r.fromScale,u_crossfade_to:r.toScale,u_image:0,u_mix:r.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})},co=(e,i,o,a,r,s)=>{const n=ho(i,e.transform);return t.e(ro(e,i,o,a),{u_image:0,u_image_height:s,u_tileratio:n,u_crossfade_from:r.fromScale,u_crossfade_to:r.toScale,u_image_dash:1,u_mix:r.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})};function ho(e,i){return 1/t.aK(e,1,i.tileZoom)}function uo(e,i,o){return t.aL(e.transform,i,o.paint.get("line-translate"),o.paint.get("line-translate-anchor"))}const _o=(e,t,i,o,a)=>{return {u_tl_parent:e,u_scale_parent:t,u_buffer_scale:1,u_fade_t:i.mix,u_opacity:i.opacity*o.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:o.paint.get("raster-brightness-min"),u_brightness_high:o.paint.get("raster-brightness-max"),u_saturation_factor:(s=o.paint.get("raster-saturation"),s>0?1-1/(1.001-s):-s),u_contrast_factor:(r=o.paint.get("raster-contrast"),r>0?1/(1-r):1+r),u_spin_weights:po(o.paint.get("raster-hue-rotate")),u_coords_top:[a[0].x,a[0].y,a[1].x,a[1].y],u_coords_bottom:[a[3].x,a[3].y,a[2].x,a[2].y]};var r,s;};function po(e){e*=Math.PI/180;const t=Math.sin(e),i=Math.cos(e);return [(2*i+1)/3,(-Math.sqrt(3)*t-i+1)/3,(Math.sqrt(3)*t-i+1)/3]}const mo=(e,t,i,o,a,r,s,n,l,c,h,u,d)=>{const _=s.transform;return {u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:_.cameraToCenterDistance,u_pitch:_.pitch/360*2*Math.PI,u_rotate_symbol:+i,u_aspect_ratio:_.width/_.height,u_fade_change:s.options.fadeDuration?s.symbolFadeChange:1,u_label_plane_matrix:n,u_coord_matrix:l,u_is_text:+h,u_pitch_with_map:+o,u_is_along_line:a,u_is_variable_anchor:r,u_texsize:u,u_texture:0,u_translation:c,u_pitched_scale:d}},fo=(e,i,o,a,r,s,n,l,c,h,u,d,_,p)=>{const m=n.transform;return t.e(mo(e,i,o,a,r,s,n,l,c,h,u,d,p),{u_gamma_scale:a?Math.cos(m.pitch*Math.PI/180)*m.cameraToCenterDistance:1,u_device_pixel_ratio:n.pixelRatio,u_is_halo:_?1:0,u_is_plain:1})},go=(e,i,o,a,r,s,n,l,c,h,u,d,_)=>t.e(fo(e,i,o,a,r,s,n,l,c,h,!0,u,!0,_),{u_texsize_icon:d,u_texture_icon:1}),vo=(e,t)=>({u_opacity:e,u_color:t}),xo=(e,i,o,a,r)=>t.e(function(e,i,o,a){const r=o.imageManager.getPattern(e.from.toString()),s=o.imageManager.getPattern(e.to.toString()),{width:n,height:l}=o.imageManager.getPixelSize(),c=Math.pow(2,a.tileID.overscaledZ),h=a.tileSize*Math.pow(2,o.transform.tileZoom)/c,u=h*(a.tileID.canonical.x+a.tileID.wrap*c),d=h*a.tileID.canonical.y;return {u_image:0,u_pattern_tl_a:r.tl,u_pattern_br_a:r.br,u_pattern_tl_b:s.tl,u_pattern_br_b:s.br,u_texsize:[n,l],u_mix:i.t,u_pattern_size_a:r.displaySize,u_pattern_size_b:s.displaySize,u_scale_a:i.fromScale,u_scale_b:i.toScale,u_tile_units_to_pixels:1/t.aK(a,1,o.transform.tileZoom),u_pixel_coord_upper:[u>>16,d>>16],u_pixel_coord_lower:[65535&u,65535&d]}}(o,r,i,a),{u_opacity:e}),bo=(e,t)=>{},yo={fillExtrusion:(e,i)=>({u_lightpos:new t.c2(e,i.u_lightpos),u_lightpos_globe:new t.c2(e,i.u_lightpos_globe),u_lightintensity:new t.bp(e,i.u_lightintensity),u_lightcolor:new t.c2(e,i.u_lightcolor),u_vertical_gradient:new t.bp(e,i.u_vertical_gradient),u_opacity:new t.bp(e,i.u_opacity),u_fill_translate:new t.c3(e,i.u_fill_translate)}),fillExtrusionPattern:(e,i)=>({u_lightpos:new t.c2(e,i.u_lightpos),u_lightpos_globe:new t.c2(e,i.u_lightpos_globe),u_lightintensity:new t.bp(e,i.u_lightintensity),u_lightcolor:new t.c2(e,i.u_lightcolor),u_vertical_gradient:new t.bp(e,i.u_vertical_gradient),u_height_factor:new t.bp(e,i.u_height_factor),u_opacity:new t.bp(e,i.u_opacity),u_fill_translate:new t.c3(e,i.u_fill_translate),u_image:new t.b_(e,i.u_image),u_texsize:new t.c3(e,i.u_texsize),u_pixel_coord_upper:new t.c3(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.c3(e,i.u_pixel_coord_lower),u_scale:new t.c2(e,i.u_scale),u_fade:new t.bp(e,i.u_fade)}),fill:(e,i)=>({u_fill_translate:new t.c3(e,i.u_fill_translate)}),fillPattern:(e,i)=>({u_image:new t.b_(e,i.u_image),u_texsize:new t.c3(e,i.u_texsize),u_pixel_coord_upper:new t.c3(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.c3(e,i.u_pixel_coord_lower),u_scale:new t.c2(e,i.u_scale),u_fade:new t.bp(e,i.u_fade),u_fill_translate:new t.c3(e,i.u_fill_translate)}),fillOutline:(e,i)=>({u_world:new t.c3(e,i.u_world),u_fill_translate:new t.c3(e,i.u_fill_translate)}),fillOutlinePattern:(e,i)=>({u_world:new t.c3(e,i.u_world),u_image:new t.b_(e,i.u_image),u_texsize:new t.c3(e,i.u_texsize),u_pixel_coord_upper:new t.c3(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.c3(e,i.u_pixel_coord_lower),u_scale:new t.c2(e,i.u_scale),u_fade:new t.bp(e,i.u_fade),u_fill_translate:new t.c3(e,i.u_fill_translate)}),circle:(e,i)=>({u_camera_to_center_distance:new t.bp(e,i.u_camera_to_center_distance),u_scale_with_map:new t.b_(e,i.u_scale_with_map),u_pitch_with_map:new t.b_(e,i.u_pitch_with_map),u_extrude_scale:new t.c3(e,i.u_extrude_scale),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_globe_extrude_scale:new t.bp(e,i.u_globe_extrude_scale),u_translate:new t.c3(e,i.u_translate)}),collisionBox:(e,i)=>({u_pixel_extrude_scale:new t.c3(e,i.u_pixel_extrude_scale)}),collisionCircle:(e,i)=>({u_viewport_size:new t.c3(e,i.u_viewport_size)}),debug:(e,i)=>({u_color:new t.b$(e,i.u_color),u_overlay:new t.b_(e,i.u_overlay),u_overlay_scale:new t.bp(e,i.u_overlay_scale)}),depth:bo,clippingMask:bo,heatmap:(e,i)=>({u_extrude_scale:new t.bp(e,i.u_extrude_scale),u_intensity:new t.bp(e,i.u_intensity),u_globe_extrude_scale:new t.bp(e,i.u_globe_extrude_scale)}),heatmapTexture:(e,i)=>({u_matrix:new t.c0(e,i.u_matrix),u_world:new t.c3(e,i.u_world),u_image:new t.b_(e,i.u_image),u_color_ramp:new t.b_(e,i.u_color_ramp),u_opacity:new t.bp(e,i.u_opacity)}),hillshade:(e,i)=>({u_image:new t.b_(e,i.u_image),u_latrange:new t.c3(e,i.u_latrange),u_exaggeration:new t.bp(e,i.u_exaggeration),u_altitudes:new t.c9(e,i.u_altitudes),u_azimuths:new t.c9(e,i.u_azimuths),u_accent:new t.b$(e,i.u_accent),u_method:new t.b_(e,i.u_method),u_shadows:new t.c8(e,i.u_shadows),u_highlights:new t.c8(e,i.u_highlights)}),hillshadePrepare:(e,i)=>({u_matrix:new t.c0(e,i.u_matrix),u_image:new t.b_(e,i.u_image),u_dimension:new t.c3(e,i.u_dimension),u_zoom:new t.bp(e,i.u_zoom),u_unpack:new t.c1(e,i.u_unpack)}),colorRelief:(e,i)=>({u_image:new t.b_(e,i.u_image),u_unpack:new t.c1(e,i.u_unpack),u_dimension:new t.c3(e,i.u_dimension),u_elevation_stops:new t.b_(e,i.u_elevation_stops),u_color_stops:new t.b_(e,i.u_color_stops),u_color_ramp_size:new t.b_(e,i.u_color_ramp_size),u_opacity:new t.bp(e,i.u_opacity)}),line:(e,i)=>({u_translation:new t.c3(e,i.u_translation),u_ratio:new t.bp(e,i.u_ratio),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.c3(e,i.u_units_to_pixels)}),lineGradient:(e,i)=>({u_translation:new t.c3(e,i.u_translation),u_ratio:new t.bp(e,i.u_ratio),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.c3(e,i.u_units_to_pixels),u_image:new t.b_(e,i.u_image),u_image_height:new t.bp(e,i.u_image_height)}),linePattern:(e,i)=>({u_translation:new t.c3(e,i.u_translation),u_texsize:new t.c3(e,i.u_texsize),u_ratio:new t.bp(e,i.u_ratio),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_image:new t.b_(e,i.u_image),u_units_to_pixels:new t.c3(e,i.u_units_to_pixels),u_scale:new t.c2(e,i.u_scale),u_fade:new t.bp(e,i.u_fade)}),lineSDF:(e,i)=>({u_translation:new t.c3(e,i.u_translation),u_ratio:new t.bp(e,i.u_ratio),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.c3(e,i.u_units_to_pixels),u_image:new t.b_(e,i.u_image),u_mix:new t.bp(e,i.u_mix),u_tileratio:new t.bp(e,i.u_tileratio),u_crossfade_from:new t.bp(e,i.u_crossfade_from),u_crossfade_to:new t.bp(e,i.u_crossfade_to),u_lineatlas_width:new t.bp(e,i.u_lineatlas_width),u_lineatlas_height:new t.bp(e,i.u_lineatlas_height)}),lineGradientSDF:(e,i)=>({u_translation:new t.c3(e,i.u_translation),u_ratio:new t.bp(e,i.u_ratio),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.c3(e,i.u_units_to_pixels),u_image:new t.b_(e,i.u_image),u_image_height:new t.bp(e,i.u_image_height),u_tileratio:new t.bp(e,i.u_tileratio),u_crossfade_from:new t.bp(e,i.u_crossfade_from),u_crossfade_to:new t.bp(e,i.u_crossfade_to),u_image_dash:new t.b_(e,i.u_image_dash),u_mix:new t.bp(e,i.u_mix),u_lineatlas_width:new t.bp(e,i.u_lineatlas_width),u_lineatlas_height:new t.bp(e,i.u_lineatlas_height)}),raster:(e,i)=>({u_tl_parent:new t.c3(e,i.u_tl_parent),u_scale_parent:new t.bp(e,i.u_scale_parent),u_buffer_scale:new t.bp(e,i.u_buffer_scale),u_fade_t:new t.bp(e,i.u_fade_t),u_opacity:new t.bp(e,i.u_opacity),u_image0:new t.b_(e,i.u_image0),u_image1:new t.b_(e,i.u_image1),u_brightness_low:new t.bp(e,i.u_brightness_low),u_brightness_high:new t.bp(e,i.u_brightness_high),u_saturation_factor:new t.bp(e,i.u_saturation_factor),u_contrast_factor:new t.bp(e,i.u_contrast_factor),u_spin_weights:new t.c2(e,i.u_spin_weights),u_coords_top:new t.c1(e,i.u_coords_top),u_coords_bottom:new t.c1(e,i.u_coords_bottom)}),symbolIcon:(e,i)=>({u_is_size_zoom_constant:new t.b_(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.b_(e,i.u_is_size_feature_constant),u_size_t:new t.bp(e,i.u_size_t),u_size:new t.bp(e,i.u_size),u_camera_to_center_distance:new t.bp(e,i.u_camera_to_center_distance),u_pitch:new t.bp(e,i.u_pitch),u_rotate_symbol:new t.b_(e,i.u_rotate_symbol),u_aspect_ratio:new t.bp(e,i.u_aspect_ratio),u_fade_change:new t.bp(e,i.u_fade_change),u_label_plane_matrix:new t.c0(e,i.u_label_plane_matrix),u_coord_matrix:new t.c0(e,i.u_coord_matrix),u_is_text:new t.b_(e,i.u_is_text),u_pitch_with_map:new t.b_(e,i.u_pitch_with_map),u_is_along_line:new t.b_(e,i.u_is_along_line),u_is_variable_anchor:new t.b_(e,i.u_is_variable_anchor),u_texsize:new t.c3(e,i.u_texsize),u_texture:new t.b_(e,i.u_texture),u_translation:new t.c3(e,i.u_translation),u_pitched_scale:new t.bp(e,i.u_pitched_scale)}),symbolSDF:(e,i)=>({u_is_size_zoom_constant:new t.b_(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.b_(e,i.u_is_size_feature_constant),u_size_t:new t.bp(e,i.u_size_t),u_size:new t.bp(e,i.u_size),u_camera_to_center_distance:new t.bp(e,i.u_camera_to_center_distance),u_pitch:new t.bp(e,i.u_pitch),u_rotate_symbol:new t.b_(e,i.u_rotate_symbol),u_aspect_ratio:new t.bp(e,i.u_aspect_ratio),u_fade_change:new t.bp(e,i.u_fade_change),u_label_plane_matrix:new t.c0(e,i.u_label_plane_matrix),u_coord_matrix:new t.c0(e,i.u_coord_matrix),u_is_text:new t.b_(e,i.u_is_text),u_pitch_with_map:new t.b_(e,i.u_pitch_with_map),u_is_along_line:new t.b_(e,i.u_is_along_line),u_is_variable_anchor:new t.b_(e,i.u_is_variable_anchor),u_texsize:new t.c3(e,i.u_texsize),u_texture:new t.b_(e,i.u_texture),u_gamma_scale:new t.bp(e,i.u_gamma_scale),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_is_halo:new t.b_(e,i.u_is_halo),u_is_plain:new t.b_(e,i.u_is_plain),u_translation:new t.c3(e,i.u_translation),u_pitched_scale:new t.bp(e,i.u_pitched_scale)}),symbolTextAndIcon:(e,i)=>({u_is_size_zoom_constant:new t.b_(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.b_(e,i.u_is_size_feature_constant),u_size_t:new t.bp(e,i.u_size_t),u_size:new t.bp(e,i.u_size),u_camera_to_center_distance:new t.bp(e,i.u_camera_to_center_distance),u_pitch:new t.bp(e,i.u_pitch),u_rotate_symbol:new t.b_(e,i.u_rotate_symbol),u_aspect_ratio:new t.bp(e,i.u_aspect_ratio),u_fade_change:new t.bp(e,i.u_fade_change),u_label_plane_matrix:new t.c0(e,i.u_label_plane_matrix),u_coord_matrix:new t.c0(e,i.u_coord_matrix),u_is_text:new t.b_(e,i.u_is_text),u_pitch_with_map:new t.b_(e,i.u_pitch_with_map),u_is_along_line:new t.b_(e,i.u_is_along_line),u_is_variable_anchor:new t.b_(e,i.u_is_variable_anchor),u_texsize:new t.c3(e,i.u_texsize),u_texsize_icon:new t.c3(e,i.u_texsize_icon),u_texture:new t.b_(e,i.u_texture),u_texture_icon:new t.b_(e,i.u_texture_icon),u_gamma_scale:new t.bp(e,i.u_gamma_scale),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_is_halo:new t.b_(e,i.u_is_halo),u_translation:new t.c3(e,i.u_translation),u_pitched_scale:new t.bp(e,i.u_pitched_scale)}),background:(e,i)=>({u_opacity:new t.bp(e,i.u_opacity),u_color:new t.b$(e,i.u_color)}),backgroundPattern:(e,i)=>({u_opacity:new t.bp(e,i.u_opacity),u_image:new t.b_(e,i.u_image),u_pattern_tl_a:new t.c3(e,i.u_pattern_tl_a),u_pattern_br_a:new t.c3(e,i.u_pattern_br_a),u_pattern_tl_b:new t.c3(e,i.u_pattern_tl_b),u_pattern_br_b:new t.c3(e,i.u_pattern_br_b),u_texsize:new t.c3(e,i.u_texsize),u_mix:new t.bp(e,i.u_mix),u_pattern_size_a:new t.c3(e,i.u_pattern_size_a),u_pattern_size_b:new t.c3(e,i.u_pattern_size_b),u_scale_a:new t.bp(e,i.u_scale_a),u_scale_b:new t.bp(e,i.u_scale_b),u_pixel_coord_upper:new t.c3(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.c3(e,i.u_pixel_coord_lower),u_tile_units_to_pixels:new t.bp(e,i.u_tile_units_to_pixels)}),terrain:(e,i)=>({u_texture:new t.b_(e,i.u_texture),u_ele_delta:new t.bp(e,i.u_ele_delta),u_fog_matrix:new t.c0(e,i.u_fog_matrix),u_fog_color:new t.b$(e,i.u_fog_color),u_fog_ground_blend:new t.bp(e,i.u_fog_ground_blend),u_fog_ground_blend_opacity:new t.bp(e,i.u_fog_ground_blend_opacity),u_horizon_color:new t.b$(e,i.u_horizon_color),u_horizon_fog_blend:new t.bp(e,i.u_horizon_fog_blend),u_is_globe_mode:new t.bp(e,i.u_is_globe_mode)}),terrainDepth:(e,i)=>({u_ele_delta:new t.bp(e,i.u_ele_delta)}),terrainCoords:(e,i)=>({u_texture:new t.b_(e,i.u_texture),u_terrain_coords_id:new t.bp(e,i.u_terrain_coords_id),u_ele_delta:new t.bp(e,i.u_ele_delta)}),projectionErrorMeasurement:(e,i)=>({u_input:new t.bp(e,i.u_input),u_output_expected:new t.bp(e,i.u_output_expected)}),atmosphere:(e,i)=>({u_sun_pos:new t.c2(e,i.u_sun_pos),u_atmosphere_blend:new t.bp(e,i.u_atmosphere_blend),u_globe_position:new t.c2(e,i.u_globe_position),u_globe_radius:new t.bp(e,i.u_globe_radius),u_inv_proj_matrix:new t.c0(e,i.u_inv_proj_matrix)}),sky:(e,i)=>({u_sky_color:new t.b$(e,i.u_sky_color),u_horizon_color:new t.b$(e,i.u_horizon_color),u_horizon:new t.c3(e,i.u_horizon),u_horizon_normal:new t.c3(e,i.u_horizon_normal),u_sky_horizon_blend:new t.bp(e,i.u_sky_horizon_blend),u_sky_blend:new t.bp(e,i.u_sky_blend)})};class wo{constructor(e,t,i){this.context=e;const o=e.gl;this.buffer=o.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?o.DYNAMIC_DRAW:o.STATIC_DRAW),this.dynamicDraw||t.freeBufferAfterUpload();}bind(){this.context.bindElementBuffer.set(this.buffer);}updateData(e){const t=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer);}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer);}}const To={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Po{constructor(e,t,i,o){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=o,this.context=e;const a=e.gl;this.buffer=a.createBuffer(),e.bindVertexBuffer.set(this.buffer),a.bufferData(a.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?a.DYNAMIC_DRAW:a.STATIC_DRAW),this.dynamicDraw||t.freeBufferAfterUpload();}bind(){this.context.bindVertexBuffer.set(this.buffer);}updateData(e){if(e.length!==this.length)throw new Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);const t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer);}enableAttributes(e,t){for(const i of this.attributes){const o=t.attributes[i.name];void 0!==o&&e.enableVertexAttribArray(o);}}setVertexAttribPointers(e,t,i){for(const o of this.attributes){const a=t.attributes[o.name];void 0!==a&&e.vertexAttribPointer(a,o.components,e[To[o.type]],!1,this.itemSize,o.offset+this.itemSize*(i||0));}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer);}}class Co{constructor(e){this.gl=e.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1;}get(){return this.current}set(e){}getDefault(){return this.default}setDefault(){this.set(this.default);}}class Mo extends Co{getDefault(){return t.bo.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1);}}class Io extends Co{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1);}}class Eo extends Co{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1);}}class So extends Co{getDefault(){return [!0,!0,!0,!0]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.colorMask(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1);}}class zo extends Co{getDefault(){return !0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1);}}class Ro extends Co{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1);}}class Do extends Co{getDefault(){return {func:this.gl.ALWAYS,ref:0,mask:255}}set(e){const t=this.current;(e.func!==t.func||e.ref!==t.ref||e.mask!==t.mask||this.dirty)&&(this.gl.stencilFunc(e.func,e.ref,e.mask),this.current=e,this.dirty=!1);}}class Ao extends Co{getDefault(){const e=this.gl;return [e.KEEP,e.KEEP,e.KEEP]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||this.dirty)&&(this.gl.stencilOp(e[0],e[1],e[2]),this.current=e,this.dirty=!1);}}class Lo extends Co{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),this.current=e,this.dirty=!1;}}class Fo extends Co{getDefault(){return [0,1]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.depthRange(e[0],e[1]),this.current=e,this.dirty=!1);}}class ko extends Co{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),this.current=e,this.dirty=!1;}}class Bo extends Co{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1);}}class Oo extends Co{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.BLEND):t.disable(t.BLEND),this.current=e,this.dirty=!1;}}class jo extends Co{getDefault(){const e=this.gl;return [e.ONE,e.ZERO]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.blendFunc(e[0],e[1]),this.current=e,this.dirty=!1);}}class No extends Co{getDefault(){return t.bo.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1);}}class Zo extends Co{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquation(e),this.current=e,this.dirty=!1);}}class Uo extends Co{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),this.current=e,this.dirty=!1;}}class Go extends Co{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1);}}class Vo extends Co{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1);}}class Wo extends Co{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1);}}class qo extends Co{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1);}}class $o extends Co{getDefault(){const e=this.gl;return [0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.viewport(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1);}}class Ho extends Co{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,e),this.current=e,this.dirty=!1;}}class Xo extends Co{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindRenderbuffer(t.RENDERBUFFER,e),this.current=e,this.dirty=!1;}}class Ko extends Co{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindTexture(t.TEXTURE_2D,e),this.current=e,this.dirty=!1;}}class Yo extends Co{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindBuffer(t.ARRAY_BUFFER,e),this.current=e,this.dirty=!1;}}class Qo extends Co{getDefault(){return null}set(e){const t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1;}}class Jo extends Co{getDefault(){return null}set(e){var t;if(e===this.current&&!this.dirty)return;const i=this.gl;si(i)?i.bindVertexArray(e):null===(t=i.getExtension("OES_vertex_array_object"))||void 0===t||t.bindVertexArrayOES(e),this.current=e,this.dirty=!1;}}class ea extends Co{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1;}}class ta extends Co{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1;}}class ia extends Co{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1;}}class oa extends Co{constructor(e,t){super(e),this.context=e,this.parent=t;}getDefault(){return null}}class aa extends oa{setDirty(){this.dirty=!0;}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1;}}class ra extends oa{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,e),this.current=e,this.dirty=!1;}}class sa extends oa{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,e),this.current=e,this.dirty=!1;}}const na="Framebuffer is not complete";class la{constructor(e,t,i,o,a){this.context=e,this.width=t,this.height=i;const r=e.gl,s=this.framebuffer=r.createFramebuffer();if(this.colorAttachment=new aa(e,s),o)this.depthAttachment=a?new sa(e,s):new ra(e,s);else if(a)throw new Error("Stencil cannot be set without depth");if(r.checkFramebufferStatus(r.FRAMEBUFFER)!==r.FRAMEBUFFER_COMPLETE)throw new Error(na)}destroy(){const e=this.context.gl,t=this.colorAttachment.get();if(t&&e.deleteTexture(t),this.depthAttachment){const t=this.depthAttachment.get();t&&e.deleteRenderbuffer(t);}e.deleteFramebuffer(this.framebuffer);}}class ca{constructor(e){var t,i;if(this.gl=e,this.clearColor=new Mo(this),this.clearDepth=new Io(this),this.clearStencil=new Eo(this),this.colorMask=new So(this),this.depthMask=new zo(this),this.stencilMask=new Ro(this),this.stencilFunc=new Do(this),this.stencilOp=new Ao(this),this.stencilTest=new Lo(this),this.depthRange=new Fo(this),this.depthTest=new ko(this),this.depthFunc=new Bo(this),this.blend=new Oo(this),this.blendFunc=new jo(this),this.blendColor=new No(this),this.blendEquation=new Zo(this),this.cullFace=new Uo(this),this.cullFaceSide=new Go(this),this.frontFace=new Vo(this),this.program=new Wo(this),this.activeTexture=new qo(this),this.viewport=new $o(this),this.bindFramebuffer=new Ho(this),this.bindRenderbuffer=new Xo(this),this.bindTexture=new Ko(this),this.bindVertexBuffer=new Yo(this),this.bindElementBuffer=new Qo(this),this.bindVertexArray=new Jo(this),this.pixelStoreUnpack=new ea(this),this.pixelStoreUnpackPremultiplyAlpha=new ta(this),this.pixelStoreUnpackFlipY=new ia(this),this.extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),si(e)){this.HALF_FLOAT=e.HALF_FLOAT;const o=e.getExtension("EXT_color_buffer_half_float");this.RGBA16F=null!==(t=e.RGBA16F)&&void 0!==t?t:null==o?void 0:o.RGBA16F_EXT,this.RGB16F=null!==(i=e.RGB16F)&&void 0!==i?i:null==o?void 0:o.RGB16F_EXT,e.getExtension("EXT_color_buffer_float");}else {e.getExtension("EXT_color_buffer_half_float"),e.getExtension("OES_texture_half_float_linear");const t=e.getExtension("OES_texture_half_float");this.HALF_FLOAT=null==t?void 0:t.HALF_FLOAT_OES;}}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault();}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArray.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0;}createIndexBuffer(e,t){return new wo(this,e,t)}createVertexBuffer(e,t,i){return new Po(this,e,t,i)}createRenderbuffer(e,t,i){const o=this.gl,a=o.createRenderbuffer();return this.bindRenderbuffer.set(a),o.renderbufferStorage(o.RENDERBUFFER,e,t,i),this.bindRenderbuffer.set(null),a}createFramebuffer(e,t,i,o){return new la(this,e,t,i,o)}clear({color:e,depth:t,stencil:i}){const o=this.gl;let a=0;e&&(a|=o.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set([!0,!0,!0,!0])),void 0!==t&&(a|=o.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),void 0!==i&&(a|=o.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),o.clear(a);}setCullFace(e){!1===e.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace));}setDepthMode(e){e.func!==this.gl.ALWAYS||e.mask?(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range)):this.depthTest.set(!1);}setStencilMode(e){e.test.func!==this.gl.ALWAYS||e.mask?(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask})):this.stencilTest.set(!1);}setColorMode(e){t.bQ(e.blendFunction,ei.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(e.blendFunction),this.blendColor.set(e.blendColor)),this.colorMask.set(e.mask);}createVertexArray(){var e;return si(this.gl)?this.gl.createVertexArray():null===(e=this.gl.getExtension("OES_vertex_array_object"))||void 0===e?void 0:e.createVertexArrayOES()}deleteVertexArray(e){var t;si(this.gl)?this.gl.deleteVertexArray(e):null===(t=this.gl.getExtension("OES_vertex_array_object"))||void 0===t||t.deleteVertexArrayOES(e);}unbindVAO(){this.bindVertexArray.set(null);}}let ha;function ua(e,i,o,a,r){var s,n;const l=e.context,c=e.transform,h=l.gl,u=e.useProgram("collisionBox"),d=[];let _=0,p=0;for(const t of a){const a=i.getTile(t).getBucket(o);if(!a)continue;const n=r?a.textCollisionBox:a.iconCollisionBox,m=a.collisionCircleArray;m.length>0&&(d.push({circleArray:m,circleOffset:p,coord:t}),_+=m.length/4,p=_),n&&u.draw(l,h.LINES,oi.disabled,ri.disabled,e.colorModeForRenderPass(),ii.disabled,Ki(e.transform),null===(s=e.style.map.terrain)||void 0===s?void 0:s.getTerrainData(t),c.getProjectionData({overscaledTileID:t,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),o.id,n.layoutVertexBuffer,n.indexBuffer,n.segments,null,e.transform.zoom,null,null,n.collisionVertexBuffer);}if(!r||!d.length)return;const m=e.useProgram("collisionCircle"),f=new t.ca;f.resize(4*_),f._trim();let g=0;for(const e of d)for(let t=0;t<e.circleArray.length/4;t++){const i=4*t,o=e.circleArray[i+0],a=e.circleArray[i+1],r=e.circleArray[i+2],s=e.circleArray[i+3];f.emplace(g++,o,a,r,s,0),f.emplace(g++,o,a,r,s,1),f.emplace(g++,o,a,r,s,2),f.emplace(g++,o,a,r,s,3);}(!ha||ha.length<2*_)&&(ha=function(e){const i=2*e,o=new t.cc;o.resize(i),o._trim();for(let e=0;e<i;e++){const t=6*e;o.uint16[t+0]=4*e+0,o.uint16[t+1]=4*e+1,o.uint16[t+2]=4*e+2,o.uint16[t+3]=4*e+2,o.uint16[t+4]=4*e+3,o.uint16[t+5]=4*e+0;}return o}(_));const v=l.createIndexBuffer(ha,!0),x=l.createVertexBuffer(f,t.cb.members,!0);for(const i of d){const a=Yi(e.transform);m.draw(l,h.TRIANGLES,oi.disabled,ri.disabled,e.colorModeForRenderPass(),ii.disabled,a,null===(n=e.style.map.terrain)||void 0===n?void 0:n.getTerrainData(i.coord),null,o.id,x,v,t.aV.simpleSegment(0,2*i.circleOffset,i.circleArray.length,i.circleArray.length/2),null,e.transform.zoom,null,null,null);}x.destroy(),v.destroy();}const da=t.ap(new Float32Array(16));function _a(e,i,o,a,r,s){const{horizontalAlign:n,verticalAlign:l}=t.aP(e);return new t.P((-(n-.5)*i/r+a[0])*s,(-(l-.5)*o/r+a[1])*s)}function pa(e,i,o,a,r,s){const n=i.tileAnchorPoint.add(new t.P(i.translation[0],i.translation[1]));if(i.pitchWithMap){let e=a.mult(s);o||(e=e.rotate(-r));const t=n.add(e);return Ve(t.x,t.y,i.pitchedLabelPlaneMatrix,i.getElevation).point}if(o){const t=Je(i.tileAnchorPoint.x+1,i.tileAnchorPoint.y,i).point.sub(e),o=Math.atan(t.y/t.x)+(t.x<0?Math.PI:0);return e.add(a.rotate(o))}return e.add(a)}function ma(e,i,o,a,r,s,n,l,c,h,u,d){const _=e.text.placedSymbolArray,p=e.text.dynamicLayoutVertexArray,m=e.icon.dynamicLayoutVertexArray,f={};p.clear();for(let m=0;m<_.length;m++){const g=_.get(m),v=g.hidden||!g.crossTileID||e.allowVerticalPlacement&&!g.placedOrientation?null:a[g.crossTileID];if(v){const a=new t.P(g.anchorX,g.anchorY),_={getElevation:d,width:r.width,height:r.height,pitchedLabelPlaneMatrix:s,pitchWithMap:o,transform:r,tileAnchorPoint:a,translation:h,unwrappedTileID:u},m=o?tt(a.x,a.y,_):Je(a.x,a.y,_),x=We(r.cameraToCenterDistance,m.signedDistanceFromCamera);let b=t.ay(e.textSizeData,l,g)*x/t.aJ;o&&(b*=e.tilePixelRatio/n);const{width:y,height:w,anchor:T,textOffset:P,textBoxScale:C}=v,M=_a(T,y,w,P,C,b),I=r.getPitchedTextCorrection(a.x+h[0],a.y+h[1],u),E=pa(m.point,_,i,M,-r.bearingInRadians,I),S=e.allowVerticalPlacement&&g.placedOrientation===t.ax.vertical?Math.PI/2:0;for(let e=0;e<g.numGlyphs;e++)t.aD(p,E,S);c&&g.associatedIconIndex>=0&&(f[g.associatedIconIndex]={shiftedAnchor:E,angle:S});}else st(g.numGlyphs,p);}if(c){m.clear();const i=e.icon.placedSymbolArray;for(let e=0;e<i.length;e++){const o=i.get(e);if(o.hidden)st(o.numGlyphs,m);else {const i=f[e];if(i)for(let e=0;e<o.numGlyphs;e++)t.aD(m,i.shiftedAnchor,i.angle);else st(o.numGlyphs,m);}}e.icon.dynamicLayoutVertexBuffer.updateData(m);}e.text.dynamicLayoutVertexBuffer.updateData(p);}function fa(e,t,i){return i.iconsInText&&t?"symbolTextAndIcon":e?"symbolSDF":"symbolIcon"}function ga(e,i,o,a,r,s,n,l,c,h,u,d,_){var p,m;const f=e.context,g=f.gl,v=e.transform,x="map"===l,b="map"===c,y="viewport"!==l&&"point"!==o.layout.get("symbol-placement"),w=x&&!b&&!y,T=!o.layout.get("symbol-sort-key").isConstant();let P=!1;const C=e.getDepthModeForSublayer(0,oi.ReadOnly),M=o._unevaluatedLayout.hasValue("text-variable-anchor")||o._unevaluatedLayout.hasValue("text-variable-anchor-offset"),I=[],E=v.getCircleRadiusCorrection();for(const l of a){const a=i.getTile(l),c=a.getBucket(o);if(!c)continue;const u=r?c.text:c.icon;if(!(null==u?void 0:u.segments.get().length)||!u.hasVisibleVertices)continue;const d=u.programConfigurations.get(o.id),m=r||c.sdfIcons,f=r?c.textSizeData:c.iconSizeData,C=b||0!==v.pitch,S=e.useProgram(fa(m,r,c),d),z=t.aw(f,v.zoom),R=null===(p=e.style.map.terrain)||void 0===p?void 0:p.getTerrainData(l);let D,A,L,F,k=[0,0],B=null;if(r)A=a.glyphAtlasTexture,L=g.LINEAR,D=a.glyphAtlasTexture.size,c.iconsInText&&(k=a.imageAtlasTexture.size,B=a.imageAtlasTexture,F=C||e.options.rotating||e.options.zooming||"composite"===f.kind||"camera"===f.kind?g.LINEAR:g.NEAREST);else {const t=1!==o.layout.get("icon-size").constantOr(0)||c.iconsNeedLinear;A=a.imageAtlasTexture,L=m||e.options.rotating||e.options.zooming||t||C?g.LINEAR:g.NEAREST,D=a.imageAtlasTexture.size;}const O=t.aK(a,1,e.transform.zoom),j=Ze(x,e.transform,O),N=Ue(b,x,e.transform,O),Z=t.aL(v,a,s,n),U=v.getProjectionData({overscaledTileID:l,applyGlobeMatrix:!_,applyTerrainMatrix:!0}),G=M&&c.hasTextData(),V="none"!==o.layout.get("icon-text-fit")&&G&&c.hasIconData();if(y){const i=t.O();je(i,j);const a=e.style.map.terrain?(t,i)=>e.style.map.terrain.getElevation(l,t,i):null,s="map"===o.layout.get("text-rotation-alignment");$e(c,e,r,j,i,b,h,s,l.toUnwrapped(),v.width,v.height,Z,a);}const W=r&&M||V,q=y||W?da:b?j:e.transform.clipSpaceToPixelsMatrix,$=m&&0!==o.paint.get(r?"text-halo-width":"icon-halo-width").constantOr(1);let H;H=m?c.iconsInText?go(f.kind,z,w,b,y,W,e,q,N,Z,D,k,E):fo(f.kind,z,w,b,y,W,e,q,N,Z,r,D,$,E):mo(f.kind,z,w,b,y,W,e,q,N,Z,r,D,E);const X={program:S,buffers:u,uniformValues:H,projectionData:U,atlasTexture:A,atlasTextureIcon:B,atlasInterpolation:L,atlasInterpolationIcon:F,isSDF:m,hasHalo:$};if(T&&c.canOverlap){P=!0;const e=u.segments.get();for(const i of e)I.push({segments:new t.aV([i]),sortKey:i.sortKey,state:X,terrainData:R});}else I.push({segments:u.segments,sortKey:0,state:X,terrainData:R});}P&&I.sort(((e,t)=>e.sortKey-t.sortKey));const S=null!==(m=o.paint.get(r?"text-halo-width":"icon-halo-width").constantOr(null))&&void 0!==m?m:1/0,z=o.layout.get("text-letter-spacing").constantOr(0)*t.aJ<0||S>1;for(const t of I){const i=t.state;f.activeTexture.set(g.TEXTURE0),i.atlasTexture.bind(i.atlasInterpolation,g.CLAMP_TO_EDGE),i.atlasTextureIcon&&(f.activeTexture.set(g.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,g.CLAMP_TO_EDGE));const a=i.isSDF&&i.hasHalo;if(a){const a=i.uniformValues;a.u_is_halo=1,z&&(a.u_is_plain=0,va(i.buffers,t.segments,o,e,i.program,C,u,d,a,i.projectionData,t.terrainData),a.u_is_halo=0,a.u_is_plain=1);}va(i.buffers,t.segments,o,e,i.program,C,u,d,i.uniformValues,i.projectionData,t.terrainData),a&&!z&&(i.uniformValues.u_is_halo=0);}}function va(e,t,i,o,a,r,s,n,l,c,h){const u=o.context;a.draw(u,u.gl.TRIANGLES,r,s,n,ii.backCCW,l,h,c,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,o.transform.zoom,e.programConfigurations.get(i.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer);}function xa(e,i,o,a,r){const s=e.context,n=s.gl,l=ri.disabled,c=new ei([n.ONE,n.ONE],t.bo.transparent,[!0,!0,!0,!0]),h=i.getBucket(o);if(!h)return;const u=a.key;let d=o.heatmapFbos.get(u);d||(d=ya(s,i.tileSize,i.tileSize),o.heatmapFbos.set(u,d)),s.bindFramebuffer.set(d.framebuffer),s.viewport.set([0,0,i.tileSize,i.tileSize]),s.clear({color:t.bo.transparent});const _=h.programConfigurations.get(o.id),p=e.useProgram("heatmap",_,!r),m=e.transform.getProjectionData({overscaledTileID:i.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),f=e.style.map.terrain.getTerrainData(a);p.draw(s,n.TRIANGLES,oi.disabled,l,c,ii.disabled,Ji(i,e.transform.zoom,o.paint.get("heatmap-intensity"),1),f,m,o.id,h.layoutVertexBuffer,h.indexBuffer,h.segments,o.paint,e.transform.zoom,_);}function ba(e,t,i,o,a){const r=e.context,s=r.gl,n=e.transform;r.setColorMode(e.colorModeForRenderPass());const l=wa(r,t),c=i.key,h=t.heatmapFbos.get(c);if(!h)return;r.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,h.colorAttachment.get()),r.activeTexture.set(s.TEXTURE1),l.bind(s.LINEAR,s.CLAMP_TO_EDGE);const u=n.getProjectionData({overscaledTileID:i,applyTerrainMatrix:a,applyGlobeMatrix:!o});e.useProgram("heatmapTexture").draw(r,s.TRIANGLES,oi.disabled,ri.disabled,e.colorModeForRenderPass(),ii.disabled,eo(e,t,0,1),null,u,t.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,t.paint,n.zoom),h.destroy(),t.heatmapFbos.delete(c);}function ya(e,t,i){var o,a;const r=e.gl,s=r.createTexture();r.bindTexture(r.TEXTURE_2D,s),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR);const n=null!==(o=e.HALF_FLOAT)&&void 0!==o?o:r.UNSIGNED_BYTE,l=null!==(a=e.RGBA16F)&&void 0!==a?a:r.RGBA;r.texImage2D(r.TEXTURE_2D,0,l,t,i,0,r.RGBA,n,null);const c=e.createFramebuffer(t,i,!1,!1);return c.colorAttachment.set(s),c}function wa(e,i){return i.colorRampTexture||(i.colorRampTexture=new t.T(e,i.colorRamp,e.gl.RGBA)),i.colorRampTexture}function Ta(e,i,o,a,r,s,n,l){let c=256;if(r.stepInterpolant){const a=i.getSource().maxzoom,r=n.canonical.z===a?Math.ceil(1<<e.transform.maxZoom-n.canonical.z):1;c=t.al(t.ce(s.maxLineLength/t.a6*1024*r),256,o.maxTextureSize);}return l.gradient=t.cf({expression:r.gradientExpression(),evaluationKey:"lineProgress",resolution:c,image:l.gradient||void 0,clips:s.lineClipsArray}),l.texture?l.texture.update(l.gradient):l.texture=new t.T(o,l.gradient,a.RGBA),l.version=r.gradientVersion,l.texture}function Pa(e,t,i,o,a){e.activeTexture.set(t.TEXTURE0),i.imageAtlasTexture.bind(t.LINEAR,t.CLAMP_TO_EDGE),o.updatePaintBuffers(a);}function Ca(e,t,i,o,a,r){(a||e.lineAtlas.dirty)&&(t.activeTexture.set(i.TEXTURE0),e.lineAtlas.bind(t)),o.updatePaintBuffers(r);}function Ma(e,t,i,o,a,r,s){const n=r.gradients[a.id];let l=n.texture;a.gradientVersion!==n.version&&(l=Ta(e,t,i,o,a,r,s,n)),i.activeTexture.set(o.TEXTURE0),l.bind(a.stepInterpolant?o.NEAREST:o.LINEAR,o.CLAMP_TO_EDGE);}function Ia(e,t,i,o,a,r,s,n,l){const c=r.gradients[a.id];let h=c.texture;a.gradientVersion!==c.version&&(h=Ta(e,t,i,o,a,r,s,c)),i.activeTexture.set(o.TEXTURE0),h.bind(a.stepInterpolant?o.NEAREST:o.LINEAR,o.CLAMP_TO_EDGE),i.activeTexture.set(o.TEXTURE1),e.lineAtlas.bind(i),n.updatePaintBuffers(l);}function Ea(e,t,i,o,a){if(!i||!(null==o?void 0:o.imageAtlas))return;const r=o.imageAtlas.patternPositions;let s=r[i.to.toString()],n=r[i.from.toString()];if(!s&&n&&(s=n),!n&&s&&(n=s),!s||!n){const e=a.getPaintProperty(t);s=r[e],n=r[e];}s&&n&&e.setConstantPatternPositions(s,n);}function Sa(e,i,o,a,r,s,n,l){var c;const h=e.context.gl,u="fill-pattern",d=o.paint.get(u),_=null==d?void 0:d.constantOr(1),p=o.getCrossfadeParameters();let m,f,g,v,x;const b=e.transform,y=o.paint.get("fill-translate"),w=o.paint.get("fill-translate-anchor");n?(f=_&&!o.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",m=h.LINES):(f=_?"fillPattern":"fill",m=h.TRIANGLES);const T=d.constantOr(null);for(const d of a){const a=i.getTile(d);if(_&&!a.patternsLoaded())continue;const P=a.getBucket(o);if(!P)continue;const C=P.programConfigurations.get(o.id),M=e.useProgram(f,C),I=null===(c=e.style.map.terrain)||void 0===c?void 0:c.getTerrainData(d);_&&(e.context.activeTexture.set(h.TEXTURE0),a.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),C.updatePaintBuffers(p)),Ea(C,u,T,a,o);const E=b.getProjectionData({overscaledTileID:d,applyGlobeMatrix:!l,applyTerrainMatrix:!0}),S=t.aL(b,a,y,w);if(n){v=P.indexBuffer2,x=P.segments2;const t=[h.drawingBufferWidth,h.drawingBufferHeight];g="fillOutlinePattern"===f&&_?Hi(e,p,a,t,S):$i(t,S);}else v=P.indexBuffer,x=P.segments,g=_?qi(e,p,a,S):{u_fill_translate:S};const z=e.stencilModeForClipping(d);M.draw(e.context,m,r,z,s,ii.backCCW,g,I,E,o.id,P.layoutVertexBuffer,v,x,o.paint,e.transform.zoom,C);}}function za(e,i,o,a,r,s,n,l){var c;const h=e.context,u=h.gl,d="fill-extrusion-pattern",_=o.paint.get(d),p=_.constantOr(1),m=o.getCrossfadeParameters(),f=o.paint.get("fill-extrusion-opacity"),g=_.constantOr(null),v=e.transform;for(const _ of a){const a=i.getTile(_),x=a.getBucket(o);if(!x)continue;const b=null===(c=e.style.map.terrain)||void 0===c?void 0:c.getTerrainData(_),y=x.programConfigurations.get(o.id),w=e.useProgram(p?"fillExtrusionPattern":"fillExtrusion",y);p&&(e.context.activeTexture.set(u.TEXTURE0),a.imageAtlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),y.updatePaintBuffers(m));const T=v.getProjectionData({overscaledTileID:_,applyGlobeMatrix:!l,applyTerrainMatrix:!0});Ea(y,d,g,a,o);const P=t.aL(v,a,o.paint.get("fill-extrusion-translate"),o.paint.get("fill-extrusion-translate-anchor")),C=o.paint.get("fill-extrusion-vertical-gradient"),M=p?Wi(e,C,f,P,_,m,a):Vi(e,C,f,P);w.draw(h,h.gl.TRIANGLES,r,s,n,ii.backCCW,M,b,T,o.id,x.layoutVertexBuffer,x.indexBuffer,x.segments,o.paint,e.transform.zoom,y,e.style.map.terrain&&x.centroidVertexBuffer);}}function Ra(e,t,i,o,a,r,s,n,l){var c;const h=e.style.projection,u=e.context,d=e.transform,_=u.gl,p=[`#define NUM_ILLUMINATION_SOURCES ${i.paint.get("hillshade-highlight-color").values.length}`],m=e.useProgram("hillshade",null,!1,p),f=!e.options.moving;for(const p of o){const o=t.getTile(p),g=o.fbo;if(!g)continue;const v=h.getMeshFromTileID(u,p.canonical,n,!0,"raster"),x=null===(c=e.style.map.terrain)||void 0===c?void 0:c.getTerrainData(p);u.activeTexture.set(_.TEXTURE0),_.bindTexture(_.TEXTURE_2D,g.colorAttachment.get());const b=d.getProjectionData({overscaledTileID:p,aligned:f,applyGlobeMatrix:!l,applyTerrainMatrix:!0});m.draw(u,_.TRIANGLES,r,a[p.overscaledZ],s,ii.backCCW,to(e,o,i),x,b,i.id,v.vertexBuffer,v.indexBuffer,v.segments);}}let Da=0;function Aa(e,i,o,a,r,s,n,l,c){var h;const u=e.style.projection,d=e.context,_=e.transform,p=d.gl,m=e.useProgram("colorRelief"),f=!e.options.moving,g="nearest"===o.paint.get("resampling")?p.NEAREST:p.LINEAR;let v=!0,x=0;for(const b of a){const a=i.getTile(b),y=a.dem;if(v){Da||(Da=p.getParameter(p.MAX_TEXTURE_SIZE));const e=Da,{elevationTexture:t,colorTexture:i}=o.getColorRampTextures(d,e,y.getUnpackVector());d.activeTexture.set(p.TEXTURE1),t.bind(p.NEAREST,p.CLAMP_TO_EDGE),d.activeTexture.set(p.TEXTURE4),i.bind(p.LINEAR,p.CLAMP_TO_EDGE),v=!1,x=t.size[0];}if(!(null==y?void 0:y.data))continue;const w=y.stride,T=y.getPixels();if(d.activeTexture.set(p.TEXTURE0),d.pixelStoreUnpackPremultiplyAlpha.set(!1),a.demTexture||(a.demTexture=e.getTileTexture(w)),a.demTexture){const e=a.demTexture;e.update(T,{premultiply:!1}),e.bind(g,p.CLAMP_TO_EDGE);}else a.demTexture=new t.T(d,T,p.RGBA,{premultiply:!1}),a.demTexture.bind(g,p.CLAMP_TO_EDGE);const P=u.getMeshFromTileID(d,b.canonical,l,!0,"raster"),C=null===(h=e.style.map.terrain)||void 0===h?void 0:h.getTerrainData(b),M=_.getProjectionData({overscaledTileID:b,aligned:f,applyGlobeMatrix:!c,applyTerrainMatrix:!0});m.draw(d,p.TRIANGLES,s,r[b.overscaledZ],n,ii.backCCW,ao(o,a.dem,x),C,M,o.id,P.vertexBuffer,P.indexBuffer,P.segments);}}const La=[new t.P(0,0),new t.P(t.a6,0),new t.P(t.a6,t.a6),new t.P(0,t.a6)];function Fa(e,t,i,o,a,r,s,n,l=!1,c=!1){var h;const u=o[o.length-1].overscaledZ,d=e.context,_=d.gl,p=e.useProgram("raster"),m=e.transform,f=e.style.projection,g=e.colorModeForRenderPass(),v=!e.options.moving,x=i.paint.get("raster-opacity"),b="nearest"===i.paint.get("resampling")||"nearest"===i.paint.get("raster-resampling")?_.NEAREST:_.LINEAR,y=i.paint.get("raster-fade-duration"),w=!!e.style.map.terrain;for(const T of o){const o=e.getDepthModeForSublayer(T.overscaledZ-u,1===x?oi.ReadWrite:oi.ReadOnly,_.LESS),P=t.getTile(T);d.activeTexture.set(_.TEXTURE0),P.texture.bind(b,_.CLAMP_TO_EDGE,_.LINEAR_MIPMAP_NEAREST),d.activeTexture.set(_.TEXTURE1);const{parentTile:C,parentScaleBy:M,parentTopLeft:I,fadeValues:E}=ka(P,t,y,w);P.fadeOpacity=E.tileOpacity,C?(C.fadeOpacity=E.parentTileOpacity,C.texture.bind(b,_.CLAMP_TO_EDGE,_.LINEAR_MIPMAP_NEAREST)):P.texture.bind(b,_.CLAMP_TO_EDGE,_.LINEAR_MIPMAP_NEAREST),P.texture.useMipmap&&d.extTextureFilterAnisotropic&&e.transform.pitch>e.options.anisotropicFilterPitch&&_.texParameterf(_.TEXTURE_2D,d.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,d.extTextureFilterAnisotropicMax);const S=null===(h=e.style.map.terrain)||void 0===h?void 0:h.getTerrainData(T),z=m.getProjectionData({overscaledTileID:T,aligned:v,applyGlobeMatrix:!c,applyTerrainMatrix:!0}),R=_o(I,M,E.fadeMix,i,n),D=f.getMeshFromTileID(d,T.canonical,r,s,"raster");p.draw(d,_.TRIANGLES,o,a?a[T.overscaledZ]:ri.disabled,g,l?ii.frontCCW:ii.backCCW,R,S,z,i.id,D.vertexBuffer,D.indexBuffer,D.segments);}}function ka(e,i,o,a){const r={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(0===o||a)return r;if(e.fadingParentID){const a=i.getLoadedTile(e.fadingParentID);if(!a)return r;const s=Math.pow(2,a.tileID.overscaledZ-e.tileID.overscaledZ),n=[e.tileID.canonical.x*s%1,e.tileID.canonical.y*s%1],l=function(e,i,o){const a=c(),r=(a-i.timeAdded)/o,s=e.fadingDirection===ue.Incoming,n=t.al((a-e.timeAdded)/o,0,1),l=t.al(1-r,0,1),h=s?n:l;return {tileOpacity:h,parentTileOpacity:s?l:n,fadeMix:{opacity:1,mix:1-h}}}(e,a,o);return {parentTile:a,parentScaleBy:s,parentTopLeft:n,fadeValues:l}}if(e.selfFading){const i=function(e,i){const o=(c()-e.timeAdded)/i,a=t.al(o,0,1);return {tileOpacity:a,fadeMix:{opacity:a,mix:0}}}(e,o);return {parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:i}}return r}const Ba=new t.bo(1,0,0,1),Oa=new t.bo(0,1,0,1),ja=new t.bo(0,0,1,1),Na=new t.bo(1,0,1,1),Za=new t.bo(0,1,1,1);function Ua(e,t,i,o){Va(e,0,t+i/2,e.transform.width,i,o);}function Ga(e,t,i,o){Va(e,t-i/2,0,i,e.transform.height,o);}function Va(e,t,i,o,a,r){const s=e.context,n=s.gl;n.enable(n.SCISSOR_TEST),n.scissor(t*e.pixelRatio,i*e.pixelRatio,o*e.pixelRatio,a*e.pixelRatio),s.clear({color:r}),n.disable(n.SCISSOR_TEST);}function Wa(e,i,o){var a;const r=e.context,s=r.gl,n=e.useProgram("debug"),l=oi.disabled,c=ri.disabled,h=e.colorModeForRenderPass(),u="$debug",d=null===(a=e.style.map.terrain)||void 0===a?void 0:a.getTerrainData(o);r.activeTexture.set(s.TEXTURE0);const _=i.getTileByID(o.key).latestRawTileData,p=Math.floor(((null==_?void 0:_.byteLength)||0)/1024),m=i.getTile(o).tileSize,f=512/Math.min(m,512)*(o.overscaledZ/e.transform.zoom)*.5;let g=o.canonical.toString();o.overscaledZ!==o.canonical.z&&(g+=` => ${o.overscaledZ}`),function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,o=e.context.gl,a=e.debugOverlayCanvas.getContext("2d");a.clearRect(0,0,i.width,i.height),a.shadowColor="white",a.shadowBlur=2,a.lineWidth=1.5,a.strokeStyle="white",a.textBaseline="top",a.font="bold 36px Open Sans, sans-serif",a.fillText(t,5,5),a.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE);}(e,`${g} ${p}kB`);const v=e.transform.getProjectionData({overscaledTileID:o,applyGlobeMatrix:!0,applyTerrainMatrix:!0});n.draw(r,s.TRIANGLES,l,c,ei.alphaBlended,ii.disabled,Qi(t.bo.transparent,f),null,v,u,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),n.draw(r,s.LINE_STRIP,l,c,h,ii.disabled,Qi(t.bo.red),d,v,u,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments);}function qa(e,t,i,o){const{isRenderingGlobe:a}=o,r=e.context,s=r.gl,n=e.transform,l=e.colorModeForRenderPass(),c=e.getDepthModeFor3D(),h=e.useProgram("terrain");r.bindFramebuffer.set(null),r.viewport.set([0,0,e.width,e.height]);for(const o of i){const i=t.getTerrainMesh(o.tileID),u=e.renderToTexture.getTexture(o),d=t.getTerrainData(o.tileID);r.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,u.texture);const _=t.getMeshFrameDelta(n.zoom),p=n.calculateFogMatrix(o.tileID.toUnwrapped()),m=ji(_,p,e.style.sky,n.pitch,a),f=n.getProjectionData({overscaledTileID:o.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});h.draw(r,s.TRIANGLES,c,ri.disabled,l,ii.backCCW,m,d,f,"terrain",i.vertexBuffer,i.indexBuffer,i.segments);}}function $a(e,i){if(!i.mesh){const o=new t.aU;o.emplaceBack(-1,-1),o.emplaceBack(1,-1),o.emplaceBack(1,1),o.emplaceBack(-1,1);const a=new t.aW;a.emplaceBack(0,1,2),a.emplaceBack(0,2,3),i.mesh=new Bt(e.createVertexBuffer(o,Ot.members),e.createIndexBuffer(a),t.aV.simpleSegment(0,0,o.length,a.length));}return i.mesh}const Ha={symbol:function(e,i,o,a,r,s){if("translucent"!==e.renderPass)return;const{isRenderingToTexture:n}=s,l=ri.disabled,c=e.colorModeForRenderPass();(o._unevaluatedLayout.hasValue("text-variable-anchor")||o._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(e,i,o,a,r,s,n,l,c){var h;const u=i.transform,d=i.style.map.terrain,_="map"===r,p="map"===s;for(const r of e){const e=a.getTile(r),s=e.getBucket(o);if(!(null===(h=null==s?void 0:s.text)||void 0===h?void 0:h.segments.get().length))continue;const m=t.aw(s.textSizeData,u.zoom),f=t.aK(e,1,i.transform.zoom),g=Ze(_,i.transform,f),v="none"!==o.layout.get("icon-text-fit")&&s.hasIconData();if(m){const i=Math.pow(2,u.zoom-e.tileID.overscaledZ),o=d?(e,t)=>d.getElevation(r,e,t):null;ma(s,_,p,c,u,g,i,m,v,t.aL(u,e,n,l),r.toUnwrapped(),o);}}}(a,e,o,i,o.layout.get("text-rotation-alignment"),o.layout.get("text-pitch-alignment"),o.paint.get("text-translate"),o.paint.get("text-translate-anchor"),r),0!==o.paint.get("icon-opacity").constantOr(1)&&ga(e,i,o,a,!1,o.paint.get("icon-translate"),o.paint.get("icon-translate-anchor"),o.layout.get("icon-rotation-alignment"),o.layout.get("icon-pitch-alignment"),o.layout.get("icon-keep-upright"),l,c,n),0!==o.paint.get("text-opacity").constantOr(1)&&ga(e,i,o,a,!0,o.paint.get("text-translate"),o.paint.get("text-translate-anchor"),o.layout.get("text-rotation-alignment"),o.layout.get("text-pitch-alignment"),o.layout.get("text-keep-upright"),l,c,n),i.map.showCollisionBoxes&&(ua(e,i,o,a,!0),ua(e,i,o,a,!1));},circle:function(e,i,o,a,r){var s;if("translucent"!==e.renderPass)return;const{isRenderingToTexture:n}=r,l=o.paint.get("circle-opacity"),c=o.paint.get("circle-stroke-width"),h=o.paint.get("circle-stroke-opacity"),u=!o.layout.get("circle-sort-key").isConstant();if(0===l.constantOr(1)&&(0===c.constantOr(1)||0===h.constantOr(1)))return;const d=e.context,_=d.gl,p=e.transform,m=e.getDepthModeForSublayer(0,oi.ReadOnly),f=ri.disabled,g=e.colorModeForRenderPass(),v=[],x=p.getCircleRadiusCorrection();for(const r of a){const a=i.getTile(r),l=a.getBucket(o);if(!l)continue;const c=o.paint.get("circle-translate"),h=o.paint.get("circle-translate-anchor"),d=t.aL(p,a,c,h),_=l.programConfigurations.get(o.id),m=e.useProgram("circle",_),f=l.layoutVertexBuffer,g=l.indexBuffer,b=null===(s=e.style.map.terrain)||void 0===s?void 0:s.getTerrainData(r),y={programConfiguration:_,program:m,layoutVertexBuffer:f,indexBuffer:g,uniformValues:Xi(e,a,o,d,x),terrainData:b,projectionData:p.getProjectionData({overscaledTileID:r,applyGlobeMatrix:!n,applyTerrainMatrix:!0})};if(u){const e=l.segments.get();for(const i of e)v.push({segments:new t.aV([i]),sortKey:i.sortKey,state:y});}else v.push({segments:l.segments,sortKey:0,state:y});}u&&v.sort(((e,t)=>e.sortKey-t.sortKey));for(const t of v){const{programConfiguration:i,program:a,layoutVertexBuffer:r,indexBuffer:s,uniformValues:n,terrainData:l,projectionData:c}=t.state;a.draw(d,_.TRIANGLES,m,f,g,ii.backCCW,n,l,c,o.id,r,s,t.segments,o.paint,e.transform.zoom,i);}},heatmap:function(e,i,o,a,r){if(0===o.paint.get("heatmap-opacity"))return;const s=e.context,{isRenderingToTexture:n,isRenderingGlobe:l}=r;if(e.style.map.terrain){for(const t of a){const a=i.getTile(t);i.hasRenderableParent(t)||("offscreen"===e.renderPass?xa(e,a,o,t,l):"translucent"===e.renderPass&&ba(e,o,t,n,l));}s.viewport.set([0,0,e.width,e.height]);}else "offscreen"===e.renderPass?function(e,i,o,a){const r=e.context,s=r.gl,n=e.transform,l=ri.disabled,c=new ei([s.ONE,s.ONE],t.bo.transparent,[!0,!0,!0,!0]);((function(e,i,o){const a=e.gl;e.activeTexture.set(a.TEXTURE1),e.viewport.set([0,0,i.width/4,i.height/4]);let r=o.heatmapFbos.get(t.cd);r?(a.bindTexture(a.TEXTURE_2D,r.colorAttachment.get()),e.bindFramebuffer.set(r.framebuffer)):(r=ya(e,i.width/4,i.height/4),o.heatmapFbos.set(t.cd,r));}))(r,e,o),r.clear({color:t.bo.transparent});for(const t of a){if(i.hasRenderableParent(t))continue;const a=i.getTile(t),h=a.getBucket(o);if(!h)continue;const u=h.programConfigurations.get(o.id),d=e.useProgram("heatmap",u),_=n.getProjectionData({overscaledTileID:t,applyGlobeMatrix:!0,applyTerrainMatrix:!1}),p=n.getCircleRadiusCorrection();d.draw(r,s.TRIANGLES,oi.disabled,l,c,ii.backCCW,Ji(a,n.zoom,o.paint.get("heatmap-intensity"),p),null,_,o.id,h.layoutVertexBuffer,h.indexBuffer,h.segments,o.paint,n.zoom,u);}r.viewport.set([0,0,e.width,e.height]);}(e,i,o,a):"translucent"===e.renderPass&&function(e,i){const o=e.context,a=o.gl;o.setColorMode(e.colorModeForRenderPass());const r=i.heatmapFbos.get(t.cd);r&&(o.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,r.colorAttachment.get()),o.activeTexture.set(a.TEXTURE1),wa(o,i).bind(a.LINEAR,a.CLAMP_TO_EDGE),e.useProgram("heatmapTexture").draw(o,a.TRIANGLES,oi.disabled,ri.disabled,e.colorModeForRenderPass(),ii.disabled,eo(e,i,0,1),null,null,i.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,i.paint,e.transform.zoom));}(e,o);},line:function(e,t,i,o,a){var r;if("translucent"!==e.renderPass)return;const{isRenderingToTexture:s}=a,n=i.paint.get("line-opacity"),l=i.paint.get("line-width");if(0===n.constantOr(1)||0===l.constantOr(1))return;const c=e.getDepthModeForSublayer(0,oi.ReadOnly),h=e.colorModeForRenderPass(),u=i.paint.get("line-dasharray"),d=u.constantOr(1),_=i.paint.get("line-pattern"),p=_.constantOr(1),m=i.paint.get("line-gradient"),f=i.getCrossfadeParameters();let g;g=p?"linePattern":d&&m?"lineGradientSDF":d?"lineSDF":m?"lineGradient":"line";const v=e.context,x=v.gl,b=e.transform;let y=!0;for(const a of o){const o=t.getTile(a);if(p&&!o.patternsLoaded())continue;const n=o.getBucket(i);if(!n)continue;const l=n.programConfigurations.get(i.id),w=e.context.program.get(),T=e.useProgram(g,l),P=y||T.program!==w,C=null===(r=e.style.map.terrain)||void 0===r?void 0:r.getTerrainData(a),M=_.constantOr(null),I=null==u?void 0:u.constantOr(null);if(M&&o.imageAtlas){const e=o.imageAtlas,t=e.patternPositions[M.to.toString()],i=e.patternPositions[M.from.toString()];t&&i&&l.setConstantPatternPositions(t,i);}else if(I){const t="round"===i.layout.get("line-cap").constantOr(null),o=e.lineAtlas.getDash(I.to,t),a=e.lineAtlas.getDash(I.from,t);l.setConstantDashPositions(o,a);}const E=b.getProjectionData({overscaledTileID:a,applyGlobeMatrix:!s,applyTerrainMatrix:!0}),S=b.getPixelScale();let z;p?(z=no(e,o,i,S,f),Pa(v,x,o,l,f)):d&&m?(z=co(e,o,i,S,f,n.lineClipsArray.length),Ia(e,t,v,x,i,n,a,l,f)):d?(z=lo(e,o,i,S,f),Ca(e,v,x,l,P,f)):m?(z=so(e,o,i,S,n.lineClipsArray.length),Ma(e,t,v,x,i,n,a)):z=ro(e,o,i,S);const R=e.stencilModeForClipping(a);T.draw(v,x.TRIANGLES,c,R,h,ii.disabled,z,C,E,i.id,n.layoutVertexBuffer,n.indexBuffer,n.segments,i.paint,e.transform.zoom,l,n.layoutVertexBuffer2),y=!1;}},fill:function(e,i,o,a,r){const s=o.paint.get("fill-color"),n=o.paint.get("fill-opacity");if(0===n.constantOr(1))return;const{isRenderingToTexture:l}=r,c=e.colorModeForRenderPass(),h=o.paint.get("fill-pattern"),u=e.opaquePassEnabledForLayer()&&!h.constantOr(1)&&1===s.constantOr(t.bo.transparent).a&&1===n.constantOr(0)?"opaque":"translucent";if(e.renderPass===u){const t=e.getDepthModeForSublayer(1,"opaque"===e.renderPass?oi.ReadWrite:oi.ReadOnly);Sa(e,i,o,a,t,c,!1,l);}if("translucent"===e.renderPass&&o.paint.get("fill-antialias")){const t=e.getDepthModeForSublayer(o.getPaintProperty("fill-outline-color")?2:0,oi.ReadOnly);Sa(e,i,o,a,t,c,!0,l);}},fillExtrusion:function(e,t,i,o,a){const r=i.paint.get("fill-extrusion-opacity");if(0===r)return;const{isRenderingToTexture:s}=a;if("translucent"===e.renderPass){const a=new oi(e.context.gl.LEQUAL,oi.ReadWrite,e.depthRangeFor3D);if(1!==r||i.paint.get("fill-extrusion-pattern").constantOr(1))za(e,t,i,o,a,ri.disabled,ei.disabled,s),za(e,t,i,o,a,e.stencilModeFor3D(),e.colorModeForRenderPass(),s);else {const r=e.colorModeForRenderPass();za(e,t,i,o,a,ri.disabled,r,s);}}},hillshade:function(e,i,o,a,r){if("offscreen"!==e.renderPass&&"translucent"!==e.renderPass)return;const{isRenderingToTexture:s}=r,n=e.context,l=e.style.projection.useSubdivision,c=e.getDepthModeForSublayer(0,oi.ReadOnly),h=e.colorModeForRenderPass();if("offscreen"===e.renderPass)!function(e,i,o,a,r,s,n){const l=e.context,c=l.gl,h="nearest"===a.paint.get("resampling")?c.NEAREST:c.LINEAR;for(const u of o){const o=i.getTile(u),d=o.dem;if(!(null==d?void 0:d.data))continue;if(!o.needsHillshadePrepare)continue;const _=d.dim,p=d.stride,m=d.getPixels();if(l.activeTexture.set(c.TEXTURE1),l.pixelStoreUnpackPremultiplyAlpha.set(!1),o.demTexture||(o.demTexture=e.getTileTexture(p)),o.demTexture){const e=o.demTexture;e.update(m,{premultiply:!1}),e.bind(c.NEAREST,c.CLAMP_TO_EDGE);}else o.demTexture=new t.T(l,m,c.RGBA,{premultiply:!1}),o.demTexture.bind(c.NEAREST,c.CLAMP_TO_EDGE);l.activeTexture.set(c.TEXTURE0);let f=o.fbo;if(!f){const e=new t.T(l,{width:_,height:_,data:null},c.RGBA);e.bind(h,c.CLAMP_TO_EDGE),f=o.fbo=l.createFramebuffer(_,_,!0,!1),f.colorAttachment.set(e.texture);}l.bindFramebuffer.set(f.framebuffer),l.viewport.set([0,0,_,_]),e.useProgram("hillshadePrepare").draw(l,c.TRIANGLES,r,s,n,ii.disabled,io(o.tileID,d),null,null,a.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments),o.needsHillshadePrepare=!1;}}(e,i,a,o,c,ri.disabled,h),n.viewport.set([0,0,e.width,e.height]);else if("translucent"===e.renderPass)if(l){const[t,r,n]=e.stencilConfigForOverlapTwoPass(a);Ra(e,i,o,n,t,c,h,!1,s),Ra(e,i,o,n,r,c,h,!0,s);}else {const[t,r]=e.getStencilConfigForOverlapAndUpdateStencilID(a);Ra(e,i,o,r,t,c,h,!1,s);}},colorRelief:function(e,t,i,o,a){if("translucent"!==e.renderPass)return;if(!o.length)return;const{isRenderingToTexture:r}=a,s=e.style.projection.useSubdivision,n=e.getDepthModeForSublayer(0,oi.ReadOnly),l=e.colorModeForRenderPass();if(s){const[a,s,c]=e.stencilConfigForOverlapTwoPass(o);Aa(e,t,i,c,a,n,l,!1,r),Aa(e,t,i,c,s,n,l,!0,r);}else {const[a,s]=e.getStencilConfigForOverlapAndUpdateStencilID(o);Aa(e,t,i,s,a,n,l,!1,r);}},raster:function(e,t,i,o,a){if("translucent"!==e.renderPass)return;if(0===i.paint.get("raster-opacity"))return;if(!o.length)return;const{isRenderingToTexture:r}=a,s=t.getSource(),n=e.style.projection.useSubdivision;if(s instanceof te)Fa(e,t,i,o,null,!1,!1,s.tileCoords,s.flippedWindingOrder,r);else if(n){const[a,s,n]=e.stencilConfigForOverlapTwoPass(o);Fa(e,t,i,n,a,!1,!0,La,!1,r),Fa(e,t,i,n,s,!0,!0,La,!1,r);}else {const[a,s]=e.getStencilConfigForOverlapAndUpdateStencilID(o);Fa(e,t,i,s,a,!1,!0,La,!1,r);}},background:function(e,t,i,o,a){var r;const s=i.paint.get("background-color"),n=i.paint.get("background-opacity");if(0===n)return;const{isRenderingToTexture:l}=a,c=e.context,h=c.gl,u=e.style.projection,d=e.transform,_=d.tileSize,p=i.paint.get("background-pattern");if(e.isPatternMissing(p))return;const m=!p&&1===s.a&&1===n&&e.opaquePassEnabledForLayer()?"opaque":"translucent";if(e.renderPass!==m)return;const f=ri.disabled,g=e.getDepthModeForSublayer(0,"opaque"===m?oi.ReadWrite:oi.ReadOnly),v=e.colorModeForRenderPass(),x=e.useProgram(p?"backgroundPattern":"background"),b=o||Me(d,{tileSize:_,terrain:e.style.map.terrain});p&&(c.activeTexture.set(h.TEXTURE0),e.imageManager.bind(e.context));const y=i.getCrossfadeParameters();for(const t of b){const o=d.getProjectionData({overscaledTileID:t,applyGlobeMatrix:!l,applyTerrainMatrix:!0}),a=p?xo(n,e,p,{tileID:t,tileSize:_},y):vo(n,s),m=null===(r=e.style.map.terrain)||void 0===r?void 0:r.getTerrainData(t),b=u.getMeshFromTileID(c,t.canonical,!1,!0,"raster");x.draw(c,h.TRIANGLES,g,f,v,ii.backCCW,a,m,o,i.id,b.vertexBuffer,b.indexBuffer,b.segments);}},sky:function(e,t){const i=e.context,o=i.gl,a=((e,t,i)=>{const o=Math.cos(t.rollInRadians),a=Math.sin(t.rollInRadians),r=ge(t),s=t.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return {u_sky_color:e.properties.get("sky-color"),u_horizon_color:e.properties.get("horizon-color"),u_horizon:[(t.width/2-r*a)*i,(t.height/2+r*o)*i],u_horizon_normal:[-a,o],u_sky_horizon_blend:e.properties.get("sky-horizon-blend")*t.height/2*i,u_sky_blend:s}})(t,e.style.map.transform,e.pixelRatio),r=new oi(o.LEQUAL,oi.ReadWrite,[0,1]),s=ri.disabled,n=e.colorModeForRenderPass(),l=e.useProgram("sky"),c=$a(i,t);l.draw(i,o.TRIANGLES,r,s,n,ii.disabled,a,null,void 0,"sky",c.vertexBuffer,c.indexBuffer,c.segments);},atmosphere:function(e,i,o){const a=e.context,r=a.gl,s=e.useProgram("atmosphere"),n=new oi(r.LEQUAL,oi.ReadOnly,[0,1]),l=e.transform,c=function(e,i){const o=e.properties.get("position"),a=[-o.x,-o.y,-o.z],r=t.ap(new Float64Array(16));return "map"===e.properties.get("anchor")&&(t.be(r,r,i.rollInRadians),t.bf(r,r,-i.pitchInRadians),t.be(r,r,i.bearingInRadians),t.bf(r,r,i.center.lat*Math.PI/180),t.bI(r,r,-i.center.lng*Math.PI/180)),t.cg(a,a,r),a}(o,e.transform),h=l.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),u=i.properties.get("atmosphere-blend")*h.projectionTransition;if(0===u)return;const d=gi(l.worldSize,l.center.lat),_=l.inverseProjectionMatrix,p=new Float64Array(4);p[3]=1,t.aE(p,p,l.modelViewProjectionMatrix),p[0]/=p[3],p[1]/=p[3],p[2]/=p[3],p[3]=1,t.aE(p,p,_),p[0]/=p[3],p[1]/=p[3],p[2]/=p[3],p[3]=1;const m=((e,t,i,o,a)=>({u_sun_pos:e,u_atmosphere_blend:t,u_globe_position:i,u_globe_radius:o,u_inv_proj_matrix:a}))(c,u,[p[0],p[1],p[2]],d,_),f=$a(a,i);s.draw(a,r.TRIANGLES,n,ri.disabled,ei.alphaBlended,ii.disabled,m,null,null,"atmosphere",f.vertexBuffer,f.indexBuffer,f.segments);},custom:function(e,t,i,o){const{isRenderingGlobe:a}=o,r=e.context,s=i.implementation,n=e.style.projection,l=e.transform,c=l.getProjectionDataForCustomLayer(a),h={farZ:l.farZ,nearZ:l.nearZ,fov:l.fov*Math.PI/180,modelViewProjectionMatrix:l.modelViewProjectionMatrix,projectionMatrix:l.projectionMatrix,shaderData:{variantName:n.shaderVariantName,vertexShaderPrelude:`const float PI = 3.141592653589793;\nuniform mat4 u_projection_matrix;\n${n.shaderPreludeCode.vertexSource}`,define:n.shaderDefine},defaultProjectionData:c},u=s.renderingMode?s.renderingMode:"2d";if("offscreen"===e.renderPass){const t=s.prerender;t&&(e.setCustomLayerDefaults(),r.setColorMode(e.colorModeForRenderPass()),t.call(s,r.gl,h),r.setDirty(),e.setBaseState());}else if("translucent"===e.renderPass){e.setCustomLayerDefaults(),r.setColorMode(e.colorModeForRenderPass()),r.setStencilMode(ri.disabled);const t="3d"===u?e.getDepthModeFor3D():e.getDepthModeForSublayer(0,oi.ReadOnly);r.setDepthMode(t),s.render(r.gl,h),r.setDirty(),e.setBaseState(),r.bindFramebuffer.set(null);}},debug:function(e,t,i){for(const o of i)Wa(e,t,o);},debugPadding:function(e){const t=e.transform.padding;Ua(e,e.transform.height-(t.top||0),3,Ba),Ua(e,t.bottom||0,3,Oa),Ga(e,t.left||0,3,ja),Ga(e,e.transform.width-(t.right||0),3,Na);const i=e.transform.centerPoint;!function(e,t,i,o){Va(e,t-1,i-10,2,20,o),Va(e,t-10,i-1,20,2,o);}(e,i.x,e.transform.height-i.y,Za);},terrainDepth:function(e,i){const o=e.context,a=o.gl,r=e.transform,s=ei.unblended,n=new oi(a.LEQUAL,oi.ReadWrite,[0,1]),l=i.tileManager.getRenderableTiles(),c=e.useProgram("terrainDepth");o.bindFramebuffer.set(i.getFramebuffer("depth").framebuffer),o.viewport.set([0,0,e.width/devicePixelRatio,e.height/devicePixelRatio]),o.clear({color:t.bo.transparent,depth:1});for(const e of l){const t=i.getTerrainMesh(e.tileID),l=i.getTerrainData(e.tileID),h=r.getProjectionData({overscaledTileID:e.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),u={u_ele_delta:i.getMeshFrameDelta(r.zoom)};c.draw(o,a.TRIANGLES,n,ri.disabled,s,ii.backCCW,u,l,h,"terrain",t.vertexBuffer,t.indexBuffer,t.segments);}o.bindFramebuffer.set(null),o.viewport.set([0,0,e.width,e.height]);},terrainCoords:function(e,i){const o=e.context,a=o.gl,r=e.transform,s=ei.unblended,n=new oi(a.LEQUAL,oi.ReadWrite,[0,1]),l=i.getCoordsTexture(),c=i.tileManager.getRenderableTiles(),h=e.useProgram("terrainCoords");o.bindFramebuffer.set(i.getFramebuffer("coords").framebuffer),o.viewport.set([0,0,e.width/devicePixelRatio,e.height/devicePixelRatio]),o.clear({color:t.bo.transparent,depth:1}),i.coordsIndex=[];for(const e of c){const t=i.getTerrainMesh(e.tileID),c=i.getTerrainData(e.tileID);o.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,l.texture);const u={u_terrain_coords_id:(255-i.coordsIndex.length)/255,u_texture:0,u_ele_delta:i.getMeshFrameDelta(r.zoom)},d=r.getProjectionData({overscaledTileID:e.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});h.draw(o,a.TRIANGLES,n,ri.disabled,s,ii.backCCW,u,c,d,"terrain",t.vertexBuffer,t.indexBuffer,t.segments),i.coordsIndex.push(e.tileID.key);}o.bindFramebuffer.set(null),o.viewport.set([0,0,e.width,e.height]);}};class Xa{constructor(e,i){this.drawFunctions=Ha,this.context=new ca(e),this.transform=i,this._tileTextures={},this.terrainFacilitator={depthDirty:!0,coordsDirty:!1,matrix:t.ap(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Fe.maxOverzooming+Fe.maxUnderzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new At;}resize(e,t,i){if(this.width=Math.floor(e*i),this.height=Math.floor(t*i),this.pixelRatio=i,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style._order)this.style._layers[e].resize();}setup(){const e=this.context,i=new t.aU;i.emplaceBack(0,0),i.emplaceBack(t.a6,0),i.emplaceBack(0,t.a6),i.emplaceBack(t.a6,t.a6),this.tileExtentBuffer=e.createVertexBuffer(i,Ot.members),this.tileExtentSegments=t.aV.simpleSegment(0,0,4,2);const o=new t.aU;o.emplaceBack(0,0),o.emplaceBack(t.a6,0),o.emplaceBack(0,t.a6),o.emplaceBack(t.a6,t.a6),this.debugBuffer=e.createVertexBuffer(o,Ot.members),this.debugSegments=t.aV.simpleSegment(0,0,4,5);const a=new t.ch;a.emplaceBack(0,0,0,0),a.emplaceBack(t.a6,0,t.a6,0),a.emplaceBack(0,t.a6,0,t.a6),a.emplaceBack(t.a6,t.a6,t.a6,t.a6),this.rasterBoundsBuffer=e.createVertexBuffer(a,Bi.members),this.rasterBoundsSegments=t.aV.simpleSegment(0,0,4,2);const r=new t.aU;r.emplaceBack(0,0),r.emplaceBack(t.a6,0),r.emplaceBack(0,t.a6),r.emplaceBack(t.a6,t.a6),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(r,Ot.members),this.rasterBoundsSegmentsPosOnly=t.aV.simpleSegment(0,0,4,5);const s=new t.aU;s.emplaceBack(0,0),s.emplaceBack(1,0),s.emplaceBack(0,1),s.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(s,Ot.members),this.viewportSegments=t.aV.simpleSegment(0,0,4,2);const n=new t.ci;n.emplaceBack(0),n.emplaceBack(1),n.emplaceBack(3),n.emplaceBack(2),n.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(n);const l=new t.aW;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(l);const c=this.context.gl;this.stencilClearMode=new ri({func:c.ALWAYS,mask:0},0,255,c.ZERO,c.ZERO,c.ZERO),this.tileExtentMesh=new Bt(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments);}clearStencil(){const e=this.context,i=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const o=t.O();t.c7(o,0,this.width,this.height,0,0,1),t.S(o,o,[i.drawingBufferWidth,i.drawingBufferHeight,0]);const a={mainMatrix:o,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:o};this.useProgram("clippingMask",null,!0).draw(e,i.TRIANGLES,oi.disabled,this.stencilClearMode,ei.disabled,ii.disabled,null,null,a,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments);}_renderTileClippingMasks(e,t,i){if(this.currentStencilSource===e.source||!e.isTileClipped()||!(null==t?void 0:t.length))return;this.currentStencilSource=e.source,this.nextStencilID+t.length>256&&this.clearStencil();const o=this.context;o.setColorMode(ei.disabled),o.setDepthMode(oi.disabled);const a={};for(const e of t)a[e.key]=this.nextStencilID++;this._renderTileMasks(a,t,i,!0),this._renderTileMasks(a,t,i,!1),this._tileClippingMaskIDs=a;}_renderTileMasks(e,t,i,o){var a;const r=this.context,s=r.gl,n=this.style.projection,l=this.transform,c=this.useProgram("clippingMask");for(const h of t){const t=e[h.key],u=null===(a=this.style.map.terrain)||void 0===a?void 0:a.getTerrainData(h),d=n.getMeshFromTileID(this.context,h.canonical,o,!0,"stencil"),_=l.getProjectionData({overscaledTileID:h,applyGlobeMatrix:!i,applyTerrainMatrix:!0});c.draw(r,s.TRIANGLES,oi.disabled,new ri({func:s.ALWAYS,mask:0},t,255,s.KEEP,s.KEEP,s.REPLACE),ei.disabled,i?ii.disabled:ii.backCCW,null,u,_,"$clipping",d.vertexBuffer,d.indexBuffer,d.segments);}}_renderTilesDepthBuffer(){var e;const t=this.context,i=t.gl,o=this.style.projection,a=this.transform,r=this.useProgram("depth"),s=this.getDepthModeFor3D(),n=Me(a,{tileSize:a.tileSize});for(const l of n){const n=null===(e=this.style.map.terrain)||void 0===e?void 0:e.getTerrainData(l),c=o.getMeshFromTileID(this.context,l.canonical,!0,!0,"raster"),h=a.getProjectionData({overscaledTileID:l,applyGlobeMatrix:!0,applyTerrainMatrix:!0});r.draw(t,i.TRIANGLES,s,ri.disabled,ei.disabled,ii.backCCW,null,n,h,"$clipping",c.vertexBuffer,c.indexBuffer,c.segments);}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new ri({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){const t=this.context.gl;return new ri({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){const t=this.context.gl,i=e.sort(((e,t)=>t.overscaledZ-e.overscaledZ)),o=i[i.length-1].overscaledZ,a=i[0].overscaledZ-o+1;if(a>1){this.currentStencilSource=void 0,this.nextStencilID+a>256&&this.clearStencil();const e={};for(let i=0;i<a;i++)e[i+o]=new ri({func:t.GEQUAL,mask:255},i+this.nextStencilID,255,t.KEEP,t.KEEP,t.REPLACE);return this.nextStencilID+=a,[e,i]}return [{[o]:ri.disabled},i]}stencilConfigForOverlapTwoPass(e){const t=this.context.gl,i=e.sort(((e,t)=>t.overscaledZ-e.overscaledZ)),o=i[i.length-1].overscaledZ,a=i[0].overscaledZ-o+1;if(this.clearStencil(),a>1){const e={},r={};for(let i=0;i<a;i++)e[i+o]=new ri({func:t.GREATER,mask:255},a+1+i,255,t.KEEP,t.KEEP,t.REPLACE),r[i+o]=new ri({func:t.GREATER,mask:255},1+i,255,t.KEEP,t.KEEP,t.REPLACE);return this.nextStencilID=2*a+1,[e,r,i]}return this.nextStencilID=3,[{[o]:new ri({func:t.GREATER,mask:255},2,255,t.KEEP,t.KEEP,t.REPLACE)},{[o]:new ri({func:t.GREATER,mask:255},1,255,t.KEEP,t.KEEP,t.REPLACE)},i]}colorModeForRenderPass(){const e=this.context.gl;if(this._showOverdrawInspector){const i=1/8;return new ei([e.CONSTANT_COLOR,e.ONE],new t.bo(i,i,i,0),[!0,!0,!0,!0])}return "opaque"===this.renderPass?ei.unblended:ei.alphaBlended}getDepthModeForSublayer(e,t,i){if(!this.opaquePassEnabledForLayer())return oi.disabled;const o=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new oi(i||this.context.gl.LEQUAL,t,[o,o])}getDepthModeFor3D(){return new oi(this.context.gl.LEQUAL,oi.ReadWrite,this.depthRangeFor3D)}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(e,i){var o,a,r;this.style=e,this.options=i,this.lineAtlas=e.lineAtlas,this.imageManager=e.imageManager,this.glyphManager=e.glyphManager,this.symbolFadeChange=e.placement.symbolFadeChange(c()),this.imageManager.beginFrame();const s=this.style._order,n=this.style.tileManagers,l={},h={},u={},d={isRenderingToTexture:!1,isRenderingGlobe:(null===(o=e.projection)||void 0===o?void 0:o.transitionState)>0};for(const e in n){const t=n[e];t.used&&t.prepare(this.context),l[e]=t.getVisibleCoordinates(!1),h[e]=l[e].slice().reverse(),u[e]=t.getVisibleCoordinates(!0).reverse();}this.opaquePassCutoff=1/0;for(let e=0;e<s.length;e++)if(this.style._layers[s[e]].is3D()){this.opaquePassCutoff=e;break}this.maybeDrawDepth(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass="offscreen";for(const e of s){const t=this.style._layers[e];if(!t.hasOffscreenPass()||t.isHidden(this.transform.zoom))continue;const i=h[t.source];("custom"===t.type||i.length)&&this.renderLayer(this,n[t.source],t,i,d);}if(null===(a=this.style.projection)||void 0===a||a.updateGPUdependent({context:this.context,useProgram:e=>this.useProgram(e)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:i.showOverdrawInspector?t.bo.black:t.bo.transparent,depth:1}),this.clearStencil(),this.style.sky&&this.drawFunctions.sky(this,this.style.sky),this._showOverdrawInspector=i.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=s.length-1;this.currentLayer>=0;this.currentLayer--){const e=this.style._layers[s[this.currentLayer]],t=n[e.source],i=l[e.source];this._renderTileClippingMasks(e,i,!1),this.renderLayer(this,t,e,i,d);}this.renderPass="translucent";let _=!1;for(this.currentLayer=0;this.currentLayer<s.length;this.currentLayer++){const e=this.style._layers[s[this.currentLayer]],t=n[e.source];if(null===(r=this.renderToTexture)||void 0===r?void 0:r.renderLayer(e,d))continue;this.opaquePassEnabledForLayer()||_||(_=!0,d.isRenderingGlobe&&!this.style.map.terrain&&this._renderTilesDepthBuffer());const i=("symbol"===e.type?u:h)[e.source];this._renderTileClippingMasks(e,l[e.source],!!this.renderToTexture),this.renderLayer(this,t,e,i,d);}if(d.isRenderingGlobe&&this.drawFunctions.atmosphere(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const e=function(e,t){let i=null;const o=Object.values(e._layers).flatMap((i=>i.source&&!i.isHidden(t)?[e.tileManagers[i.source]]:[])),a=o.filter((e=>"vector"===e.getSource().type)),r=o.filter((e=>"vector"!==e.getSource().type)),s=e=>{(!i||i.getSource().maxzoom<e.getSource().maxzoom)&&(i=e);};for(const e of a)s(e);if(!i)for(const e of r)s(e);return i}(this.style,this.transform.zoom);e&&this.drawFunctions.debug(this,e,e.getVisibleCoordinates());}this.options.showPadding&&this.drawFunctions.debugPadding(this),this.context.setDefault();}maybeDrawDepth(e){var i,o;if(!(null===(o=null===(i=this.style)||void 0===i?void 0:i.map)||void 0===o?void 0:o.terrain))return;const a=this.terrainFacilitator.matrix,r=this.transform.modelViewProjectionMatrix;let s=this.terrainFacilitator.depthDirty;s||(s=e?!t.cj(a,r):!t.ck(a,r)),s||(s=this.style.map.terrain.tileManager.anyTilesAfterTime(this.terrainFacilitator.renderTime)),s&&(t.cl(a,r),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.depthDirty=!1,this.terrainFacilitator.coordsDirty=!0,this.drawFunctions.terrainDepth(this,this.style.map.terrain));}maybeDrawCoords(){var e,t;(null===(t=null===(e=this.style)||void 0===e?void 0:e.map)||void 0===t?void 0:t.terrain)&&this.terrainFacilitator.coordsDirty&&(this.terrainFacilitator.coordsDirty=!1,this.drawFunctions.terrainCoords(this,this.style.map.terrain));}renderLayer(e,i,o,a,r){if(o.isHidden(this.transform.zoom))return;if("background"!==o.type&&"custom"!==o.type&&!(a||[]).length)return;this.id=o.id;const s=this.drawFunctions;t.aQ(o)?s.symbol(e,i,o,a,this.style.placement.variableOffsets,r):t.cm(o)?s.circle(e,i,o,a,r):t.cn(o)?s.heatmap(e,i,o,a,r):t.co(o)?s.line(e,i,o,a,r):t.cp(o)?s.fill(e,i,o,a,r):t.cq(o)?s.fillExtrusion(e,i,o,a,r):t.cr(o)?s.hillshade(e,i,o,a,r):t.cs(o)?s.colorRelief(e,i,o,a,r):t.bU(o)?s.raster(e,i,o,a,r):t.ct(o)?s.background(e,i,o,a,r):t.cu(o)&&s.custom(e,i,o,r);}saveTileTexture(e){const t=this._tileTextures[e.size[0]];t?t.length<Xa.MAX_TEXTURE_POOL_SIZE_PER_BUCKET?t.push(e):e.destroy():this._tileTextures[e.size[0]]=[e];}getTileTexture(e){const t=this._tileTextures[e];return t&&t.length>0?t.pop():null}isPatternMissing(e){if(!e)return !1;if(!e.from||!e.to)return !0;const t=this.imageManager.getPattern(e.from.toString()),i=this.imageManager.getPattern(e.to.toString());return !t||!i}useProgram(e,t,i=!1,o=[]){var a;this.cache||(this.cache={});const r=!!this.style.map.terrain,s=this.style.projection,n=i?Ft.projectionMercator:s.shaderPreludeCode,l=i?jt:s.shaderDefine,c=e+(t?t.cacheKey:"")+`/${i?Nt:s.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(r?"/terrain":"")+(o?`/${o.join("/")}`:"");return (a=this.cache)[c]||(a[c]=new Ui(this.context,Ft[e],t,yo[e],this._showOverdrawInspector,r,n,l,o)),this.cache[c]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault();}setBaseState(){const e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD);}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new t.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA));}destroy(){var e,t;if(this._tileTextures){for(const e in this._tileTextures){const t=this._tileTextures[e];if(t)for(const e of t)e.destroy();}this._tileTextures={};}if(this.tileExtentBuffer&&this.tileExtentBuffer.destroy(),this.debugBuffer&&this.debugBuffer.destroy(),this.rasterBoundsBuffer&&this.rasterBoundsBuffer.destroy(),this.rasterBoundsBufferPosOnly&&this.rasterBoundsBufferPosOnly.destroy(),this.viewportBuffer&&this.viewportBuffer.destroy(),this.tileBorderIndexBuffer&&this.tileBorderIndexBuffer.destroy(),this.quadTriangleIndexBuffer&&this.quadTriangleIndexBuffer.destroy(),this.tileExtentMesh&&(null===(e=this.tileExtentMesh.vertexBuffer)||void 0===e||e.destroy()),this.tileExtentMesh&&(null===(t=this.tileExtentMesh.indexBuffer)||void 0===t||t.destroy()),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.cache){for(const e in this.cache){const t=this.cache[e];(null==t?void 0:t.program)&&this.context.gl.deleteProgram(t.program);}this.cache={};}this.context&&this.context.setDefault();}overLimit(){const{drawingBufferWidth:e,drawingBufferHeight:t}=this.context.gl;return this.width!==e||this.height!==t}}function Ka(e,t){let i,o=!1,a=null;const r=()=>{a=null,o&&(e(...i),a=setTimeout(r,t),o=!1);};return (...e)=>(o=!0,i=e,a||r(),a)}Xa.MAX_TEXTURE_POOL_SIZE_PER_BUCKET=50;class Ya{constructor(e){this._getCurrentHash=()=>{const e=window.location.hash.replace("#","");if(this._hashName){let t;const i=e.split("&").map((e=>e.split("=")));for(const e of i)e[0]===this._hashName&&(t=e);return (t&&t[1]||"").split("/")}return e.split("/")},this._onHashChange=()=>{const e=this._getCurrentHash();if(!this._isValidHash(e))return !1;const t=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(e[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:t,pitch:+(e[4]||0)}),!0},this._updateHashUnthrottled=()=>{const e=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,e);},this._removeHash=()=>{const e=this._getCurrentHash();if(0===e.length)return;const t=e.join("/");let i=t;i.split("&").length>0&&(i=i.split("&")[0]),this._hashName&&(i=`${this._hashName}=${t}`);let o=window.location.hash.replace(i,"");o.startsWith("#&")?o=o.slice(0,1)+o.slice(2):"#"===o&&(o="");let a=window.location.href.replace(/(#.+)?$/,o);a=a.replace("&&","&"),window.history.replaceState(window.history.state,null,a);},this._updateHash=Ka(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e);}addTo(e){return this._map=e,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(e){const t=this._map.getCenter(),i=Math.round(100*this._map.getZoom())/100,o=Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),a=Math.pow(10,o),r=Math.round(t.lng*a)/a,s=Math.round(t.lat*a)/a,n=this._map.getBearing(),l=this._map.getPitch();let c="";if(c+=e?`/${r}/${s}/${i}`:`${i}/${s}/${r}`,(n||l)&&(c+="/"+Math.round(10*n)/10),l&&(c+=`/${Math.round(l)}`),this._hashName){const e=this._hashName;let t=!1;const i=window.location.hash.slice(1).split("&").map((i=>{const o=i.split("=")[0];return o===e?(t=!0,`${o}=${c}`):i})).filter((e=>e));return t||i.push(`${e}=${c}`),`#${i.join("&")}`}return `#${c}`}_isValidHash(e){if(e.length<3||e.some(isNaN))return !1;try{new t.W(+e[2],+e[1]);}catch(e){return !1}const i=+e[0],o=+(e[3]||0),a=+(e[4]||0);return i>=this._map.getMinZoom()&&i<=this._map.getMaxZoom()&&o>=-180&&o<=180&&a>=this._map.getMinPitch()&&a<=this._map.getMaxPitch()}}const Qa={linearity:.3,easing:t.cv(0,0,.3,1)},Ja=t.e({deceleration:2500,maxSpeed:1400},Qa),er=t.e({deceleration:20,maxSpeed:1400},Qa),tr=t.e({deceleration:1e3,maxSpeed:360},Qa),ir=t.e({deceleration:1e3,maxSpeed:90},Qa),or=t.e({deceleration:1e3,maxSpeed:360},Qa);class ar{constructor(e){this._map=e,this.clear();}clear(){this._inertiaBuffer=[];}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:c(),settings:e});}_drainInertiaBuffer(){const e=this._inertiaBuffer,t=c();for(;e.length>0&&t-e[0].time>160;)e.shift();}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,roll:0,pan:new t.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)i.zoom+=e.zoomDelta||0,i.bearing+=e.bearingDelta||0,i.pitch+=e.pitchDelta||0,i.roll+=e.rollDelta||0,e.panDelta&&i.pan._add(e.panDelta),e.around&&(i.around=e.around),e.pinchAround&&(i.pinchAround=e.pinchAround);const o=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,a={};if(i.pan.mag()){const r=sr(i.pan.mag(),o,t.e({},Ja,e||{})),s=i.pan.mult(r.amount/i.pan.mag()),n=this._map.cameraHelper.handlePanInertia(s,this._map.transform);a.center=n.easingCenter,a.offset=n.easingOffset,rr(a,r);}if(i.zoom){const e=sr(i.zoom,o,er);a.zoom=t.cw(this._map.transform.zoom+e.amount,this._map.getZoomSnap(),e.amount),rr(a,e);}if(i.bearing){const e=sr(i.bearing,o,tr);a.bearing=this._map.transform.bearing+t.al(e.amount,-179,179),rr(a,e);}if(i.pitch){const e=sr(i.pitch,o,ir);a.pitch=this._map.transform.pitch+e.amount,rr(a,e);}if(i.roll){const e=sr(i.roll,o,or);a.roll=this._map.transform.roll+t.al(e.amount,-179,179),rr(a,e);}if(a.zoom||a.bearing){const e=void 0===i.pinchAround?i.around:i.pinchAround;a.around=e?this._map.unproject(e):this._map.getCenter();}return this.clear(),t.e(a,{noMoveStart:!0})}}function rr(e,t){(!e.duration||e.duration<t.duration)&&(e.duration=t.duration,e.easing=t.easing);}function sr(e,i,o){const{maxSpeed:a,linearity:r,deceleration:s}=o,n=t.al(e*r/(i/1e3),-a,a),l=Math.abs(n)/(s*r);return {easing:o.easing,duration:1e3*l,amount:n*(l/2)}}class nr extends t.n{preventDefault(){this._defaultPrevented=!0;}get defaultPrevented(){return this._defaultPrevented}constructor(e,i,o,a={}){o=o instanceof MouseEvent?o:new MouseEvent(e,o);const r=d.mousePos(i.getCanvas(),o),s=i.unproject(r);super(e,t.e({point:r,lngLat:s,originalEvent:o},a)),this._defaultPrevented=!1,this.target=i;}}class lr extends t.n{preventDefault(){this._defaultPrevented=!0;}get defaultPrevented(){return this._defaultPrevented}constructor(e,i,o){const a="touchend"===e?o.changedTouches:o.touches,r=d.touchPos(i.getCanvasContainer(),a),s=r.map((e=>i.unproject(e))),n=r.reduce(((e,t,i,o)=>e.add(t.div(o.length))),new t.P(0,0));super(e,{points:r,point:n,lngLats:s,lngLat:i.unproject(n),originalEvent:o}),this._defaultPrevented=!1;}}class cr extends t.n{preventDefault(){this._defaultPrevented=!0;}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){super(e,{originalEvent:i}),this._defaultPrevented=!1;}}class hr{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance;}reset(){delete this._mousedownPos;}wheel(e){return this._firePreventable(new cr(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new nr(e.type,this._map,e))}mouseup(e){this._map.fire(new nr(e.type,this._map,e));}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||this._map.fire(new nr(e.type,this._map,e));}dblclick(e){return this._firePreventable(new nr(e.type,this._map,e))}mouseover(e){this._map.fire(new nr(e.type,this._map,e));}mouseout(e){this._map.fire(new nr(e.type,this._map,e));}touchstart(e){return this._firePreventable(new lr(e.type,this._map,e))}touchmove(e){this._map.fire(new lr(e.type,this._map,e));}touchend(e){this._map.fire(new lr(e.type,this._map,e));}touchcancel(e){this._map.fire(new lr(e.type,this._map,e));}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return {}}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class ur{constructor(e){this._map=e;}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent;}mousemove(e){this._map.fire(new nr(e.type,this._map,e));}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1;}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new nr("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent);}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new nr(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault();}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class dr{constructor(e){this._map=e;}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return {lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this._map.terrain)}}class _r{constructor(e,t){this._map=e,this._tr=new dr(e),this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1,t.boxZoom&&"object"==typeof t.boxZoom&&(this._boxZoomEnd=t.boxZoom.boxZoomEnd);}isEnabled(){return !!this._enabled}isActive(){return !!this._active}enable(){this.isEnabled()||(this._enabled=!0);}disable(){this.isEnabled()&&(this._enabled=!1);}mousedown(e,t){this.isEnabled()&&e.shiftKey&&0===e.button&&(d.disableDrag(),this._startPos=this._lastPos=t,this._active=!0);}mousemoveWindow(e,t){if(!this._active)return;const i=t;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)<this._clickTolerance)return;const o=this._startPos;this._lastPos=i,this._box||(this._box=d.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",e));const a=Math.min(o.x,i.x),r=Math.max(o.x,i.x),s=Math.min(o.y,i.y),n=Math.max(o.y,i.y);this._box.style.transform=`translate(${a}px,${s}px)`,this._box.style.width=r-a+"px",this._box.style.height=n-s+"px";}mouseupWindow(e,i){if(!this._active)return;if(0!==e.button)return;const o=this._startPos,a=i;if(this.reset(),d.suppressClick(),o.x!==a.x||o.y!==a.y)return this._map.fire(new t.n("boxzoomend",{originalEvent:e})),this._boxZoomEnd?void this._boxZoomEnd(this._map,o,a,e):{cameraAnimation:e=>e.fitScreenCoordinates(o,a,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",e);}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e));}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(this._box.remove(),this._box=null),d.enableDrag(),delete this._startPos,delete this._lastPos;}_fireEvent(e,i){return this._map.fire(new t.n(e,{originalEvent:i}))}}function pr(e,t){if(e.length!==t.length)throw new Error(`The number of touches and points are not equal - touches ${e.length}, points ${t.length}`);const i={};for(let o=0;o<e.length;o++)i[e[o].identifier]=t[o];return i}class mr{constructor(e){this.reset(),this.numTouches=e.numTouches;}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1;}touchstart(e,i,o){(this.centroid||o.length>this.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=e.timeStamp),o.length===this.numTouches&&(this.centroid=function(e){const i=new t.P(0,0);for(const t of e)i._add(t);return i.div(e.length)}(i),this.touches=pr(o,i)));}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const o=pr(i,t);for(const e in this.touches){const t=o[e];(!t||t.dist(this.touches[e])>30)&&(this.aborted=!0);}}touchend(e,t,i){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class fr{constructor(e){this.singleTap=new mr(e),this.numTaps=e.numTaps,this.reset();}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset();}touchstart(e,t,i){this.singleTap.touchstart(e,t,i);}touchmove(e,t,i){this.singleTap.touchmove(e,t,i);}touchend(e,t,i){const o=this.singleTap.touchend(e,t,i);if(o){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(o)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=o,this.count===this.numTaps)return this.reset(),o}}}class gr{constructor(e){this._tr=new dr(e),this._zoomIn=new fr({numTouches:1,numTaps:2}),this._zoomOut=new fr({numTouches:2,numTaps:1}),this.reset();}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset();}touchstart(e,t,i){this._zoomIn.touchstart(e,t,i),this._zoomOut.touchstart(e,t,i);}touchmove(e,t,i){this._zoomIn.touchmove(e,t,i),this._zoomOut.touchmove(e,t,i);}touchend(e,i,o){const a=this._zoomIn.touchend(e,i,o),r=this._zoomOut.touchend(e,i,o),s=this._tr;return a?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:i=>i.easeTo({duration:300,zoom:t.cw(s.zoom+1,i.getZoomSnap()),around:s.unproject(a)},{originalEvent:e})}):r?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:i=>i.easeTo({duration:300,zoom:t.cw(s.zoom-1,i.getZoomSnap()),around:s.unproject(r)},{originalEvent:e})}):void 0}touchcancel(){this.reset();}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class vr{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset();}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e);}_move(...e){const t=this._moveFunction(...e);if(t.bearingDelta||t.pitchDelta||t.rollDelta||t.around||t.panDelta)return this._active=!0,t}dragStart(e,t){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(t)?t[0]:t,this._activateOnStart&&this._lastPoint&&(this._active=!0));}dragMove(e,t){if(!this.isEnabled())return;const i=this._lastPoint;if(!i)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);const o=Array.isArray(t)?t[0]:t;return !this._moved&&o.dist(i)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=o,this._move(i,o))}dragEnd(e){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(e)&&(this._moved&&d.suppressClick(),this.reset(e));}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}}const xr=0,br=2,yr={[xr]:1,[br]:2};class wr{constructor(e){this._correctEvent=e.checkCorrectEvent;}startMove(e){this._eventButton=e.button;}endMove(e){delete this._eventButton;}isValidStartEvent(e){return this._correctEvent(e)}isValidMoveEvent(e){return !function(e,t){const i=yr[t];return void 0===e.buttons||(e.buttons&i)!==i}(e,this._eventButton)}isValidEndEvent(e){return e.button===this._eventButton}}class Tr{constructor(){this._firstTouch=void 0;}_isOneFingerTouch(e){return 1===e.targetTouches.length}_isSameTouchEvent(e){return e.targetTouches[0].identifier===this._firstTouch}startMove(e){this._firstTouch=e.targetTouches[0].identifier;}endMove(e){delete this._firstTouch;}isValidStartEvent(e){return this._isOneFingerTouch(e)}isValidMoveEvent(e){return this._isOneFingerTouch(e)&&this._isSameTouchEvent(e)}isValidEndEvent(e){return this._isOneFingerTouch(e)&&this._isSameTouchEvent(e)}}class Pr{constructor(e=new wr({checkCorrectEvent:()=>!0}),t=new Tr){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=t;}_executeRelevantHandler(e,t,i){return e instanceof MouseEvent?t(e):"undefined"!=typeof TouchEvent&&e instanceof TouchEvent?i(e):void 0}startMove(e){this._executeRelevantHandler(e,(e=>{this.mouseMoveStateManager.startMove(e);}),(e=>{this.oneFingerTouchMoveStateManager.startMove(e);}));}endMove(e){this._executeRelevantHandler(e,(e=>{this.mouseMoveStateManager.endMove(e);}),(e=>{this.oneFingerTouchMoveStateManager.endMove(e);}));}isValidStartEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidStartEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidStartEvent(e)))}isValidMoveEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidMoveEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(e)))}isValidEndEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidEndEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidEndEvent(e)))}}const Cr=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=e=>{e.preventDefault();};};class Mr{constructor(e,t){this._clickTolerance=e.clickTolerance||1,this._map=t,this.reset();}reset(){this._active=!1,this._touches={},this._sum=new t.P(0,0);}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,t,i){return this._calculateTransform(e,t,i)}touchmove(e,t,i){if(this._active){if(!this._shouldBePrevented(i.length))return e.preventDefault(),this._calculateTransform(e,t,i);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e);}}touchend(e,t,i){this._calculateTransform(e,t,i),this._active&&this._shouldBePrevented(i.length)&&this.reset();}touchcancel(){this.reset();}_calculateTransform(e,i,o){o.length>0&&(this._active=!0);const a=pr(o,i),r=new t.P(0,0),s=new t.P(0,0);let n=0;for(const e in a){const t=a[e],i=this._touches[e];i&&(r._add(t),s._add(t.sub(i)),n++,a[e]=t);}if(this._touches=a,this._shouldBePrevented(n)||!s.mag())return;const l=s.div(n);return this._sum._add(l),this._sum.mag()<this._clickTolerance?void 0:{around:r.div(n),panDelta:l}}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class Ir{constructor(){this.reset();}reset(){this._active=!1,delete this._firstTwoTouches;}touchstart(e,t,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([t[0],t[1]]));}touchmove(e,t,i){if(!this._firstTwoTouches)return;e.preventDefault();const[o,a]=this._firstTwoTouches,r=Er(i,t,o),s=Er(i,t,a);if(!r||!s)return;const n=this._aroundCenter?null:r.add(s).div(2);return this._move([r,s],n,e)}touchend(e,t,i){if(!this._firstTwoTouches)return;const[o,a]=this._firstTwoTouches,r=Er(i,t,o),s=Er(i,t,a);r&&s||(this._active&&d.suppressClick(),this.reset());}touchcancel(){this.reset();}enable(e){this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around;}disable(){this._enabled=!1,this.reset();}isEnabled(){return !!this._enabled}isActive(){return !!this._active}}function Er(e,t,i){for(let o=0;o<e.length;o++)if(e[o].identifier===i)return t[o]}function Sr(e,t){return Math.log(e/t)/Math.LN2}class zr extends Ir{constructor(){super(),this._zoomRate=1,this._zoomThreshold=.1;}setZoomRate(e){this._zoomRate=null!=e?e:1;}setZoomThreshold(e){this._zoomThreshold=null!=e?e:.1;}reset(){super.reset(),delete this._distance,delete this._startDistance;}_start(e){this._startDistance=this._distance=e[0].dist(e[1]);}_move(e,t){const i=this._distance;if(this._distance=e[0].dist(e[1]),this._active||!(Math.abs(Sr(this._distance,this._startDistance))<this._zoomThreshold))return this._active=!0,{zoomDelta:Sr(this._distance,i)*this._zoomRate,pinchAround:t}}}function Rr(e,t){return 180*e.angleWith(t)/Math.PI}class Dr extends Ir{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector;}_start(e){this._startVector=this._vector=e[0].sub(e[1]),this._minDiameter=e[0].dist(e[1]);}_move(e,t,i){const o=this._vector;if(this._vector=e[0].sub(e[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:Rr(this._vector,o),pinchAround:t}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());const t=25/(Math.PI*this._minDiameter)*360,i=Rr(e,this._startVector);return Math.abs(i)<t}}function Ar(e){return Math.abs(e.y)>Math.abs(e.x)}class Lr extends Ir{constructor(e){super(),this._currentTouchCount=0,this._map=e;}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints;}touchstart(e,t,i){super.touchstart(e,t,i),this._currentTouchCount=i.length;}_start(e){this._lastPoints=e,Ar(e[0].sub(e[1]))&&(this._valid=!1);}_move(e,t,i){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const o=e[0].sub(this._lastPoints[0]),a=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(o,a,i.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(o.y+a.y)/2*-.5}):void 0}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const o=e.mag()>=2,a=t.mag()>=2;if(!o&&!a)return;if(!o||!a)return void 0===this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const r=e.y>0==t.y>0;return Ar(e)&&Ar(t)&&r}}const Fr={panStep:100,bearingStep:15,pitchStep:10};class kr{constructor(e){this._tr=new dr(e);const t=Fr;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1;}reset(){this._active=!1;}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let i=0,o=0,a=0,r=0,s=0;switch(e.keyCode){case 61:case 107:case 171:case 187:i=1;break;case 189:case 109:case 173:i=-1;break;case 37:e.shiftKey?o=-1:(e.preventDefault(),r=-1);break;case 39:e.shiftKey?o=1:(e.preventDefault(),r=1);break;case 38:e.shiftKey?a=1:(e.preventDefault(),s=-1);break;case 40:e.shiftKey?a=-1:(e.preventDefault(),s=1);break;default:return}return this._rotationDisabled&&(o=0,a=0),{cameraAnimation:n=>{const l=this._tr;n.easeTo({duration:300,easeId:"keyboardHandler",easing:Br,zoom:i?t.cw(l.zoom+i*(e.shiftKey?2:1),n.getZoomSnap()):l.zoom,bearing:l.bearing+o*this._bearingStep,pitch:l.pitch+a*this._pitchStep,offset:[-r*this._panStep,-s*this._panStep],center:l.center},{originalEvent:e});}}}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0;}enableRotation(){this._rotationDisabled=!1;}}function Br(e){return e*(2-e)}const Or=4.000244140625,jr=1/450;class Nr{constructor(e,t){this._onTimeout=e=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e);},this._map=e,this._tr=new dr(e),this._triggerRenderFrame=t,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=jr;}setZoomRate(e){this._defaultZoomRate=e;}setWheelZoomRate(e){this._wheelZoomRate=e;}isEnabled(){return !!this._enabled}isActive(){return !!this._active||void 0!==this._finishTimeout}isZooming(){return !!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around);}disable(){this.isEnabled()&&(this._enabled=!1);}_shouldBePrevented(e){return !!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",e);let t=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const i=c(),o=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==t&&t%Or==0?this._type="wheel":0!==t&&Math.abs(t)<4?this._type="trackpad":o>400?(this._type=null,this._lastValue=t,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(o*t)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,t+=this._lastValue)),e.shiftKey&&t&&(t/=4),this._type&&(this._lastWheelEvent=e,this._delta-=t,this._active||this._start(e)),e.preventDefault();}_start(e){if(!this._delta)return;this._needsRerender=!1,this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const i=d.mousePos(this._map.getCanvas(),e),o=this._tr;this._aroundPoint=this._aroundCenter?o.transform.locationToScreenPoint(t.W.convert(o.center)):i,this._needsRerender||(this._needsRerender=!0,this._triggerRenderFrame());}renderFrame(){if(!this._needsRerender)return;if(this._needsRerender=!1,!this.isActive())return;const e=this._tr.transform;if("number"==typeof this._lastExpectedZoom){const t=e.zoom-this._lastExpectedZoom;"number"==typeof this._startZoom&&(this._startZoom+=t),"number"==typeof this._targetZoom&&(this._targetZoom+=t);}if(0!==this._delta){const i="wheel"===this._type&&Math.abs(this._delta)>Or?this._wheelZoomRate:this._defaultZoomRate;let o=2/(1+Math.exp(-Math.abs(this._delta*i)));this._delta<0&&0!==o&&(o=1/o);const a="number"!=typeof this._targetZoom?e.scale:t.ao(this._targetZoom),r=e.applyConstrain(e.getCameraLngLat(),t.ar(a*o)).zoom,s=this._map.getZoomSnap();if("wheel"===this._type&&s>0){const i=t.cw(e.zoom,s);this._targetZoom=t.cw(r,s,r-i);}else this._targetZoom=r;"wheel"===this._type&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0;}const i="number"!=typeof this._targetZoom?e.zoom:this._targetZoom,o=this._startZoom,a=this._easing;let r,s=!1;if("wheel"===this._type&&o&&a){const e=c()-this._lastWheelEventTime,n=Math.min((e+5)/200,1),l=a(n);r=t.H.number(o,i,l),n<1?this._needsRerender=!0:s=!0;}else r=i,s=!0;return this._active=!0,s&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout;}),200)),this._lastExpectedZoom=r,{noInertia:!0,needsRenderFrame:!s,zoomDelta:r-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let i=t.cy;if(this._prevEase){const e=this._prevEase,o=(c()-e.start)/e.duration,a=e.easing(o+.01)-e.easing(o),r=.27/Math.sqrt(a*a+1e-4)*.01,s=Math.sqrt(.0729-r*r);i=t.cv(r,s,.25,1);}return this._prevEase={start:c(),duration:e,easing:i},i}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);}}class Zr{constructor(e,t){this._clickZoom=e,this._tapZoom=t;}enable(){this._clickZoom.enable(),this._tapZoom.enable();}disable(){this._clickZoom.disable(),this._tapZoom.disable();}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class Ur{constructor(e){this._tr=new dr(e),this.reset();}reset(){this._active=!1;}dblclick(e,i){return e.preventDefault(),{cameraAnimation:o=>{o.easeTo({duration:300,zoom:t.cw(this._tr.zoom+(e.shiftKey?-1:1),o.getZoomSnap()),around:this._tr.unproject(i)},{originalEvent:e});}}}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class Gr{constructor(){this._tap=new fr({numTouches:1,numTaps:1}),this._zoomRate=1,this.reset();}setZoomRate(e){this._zoomRate=null!=e?e:1;}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset();}touchstart(e,t,i){if(!this._swipePoint)if(this._tapTime){const o=t[0],a=e.timeStamp-this._tapTime<500,r=this._tapPoint.dist(o)<30;a&&r?i.length>0&&(this._swipePoint=o,this._swipeTouch=i[0].identifier):this.reset();}else this._tap.touchstart(e,t,i);}touchmove(e,t,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const o=t[0],a=o.y-this._swipePoint.y;return this._swipePoint=o,e.preventDefault(),this._active=!0,{zoomDelta:a/128*this._zoomRate}}}else this._tap.touchmove(e,t,i);}touchend(e,t,i){if(this._tapTime)this._swipePoint&&0===i.length&&this.reset();else {const o=this._tap.touchend(e,t,i);o&&(this._tapTime=e.timeStamp,this._tapPoint=o);}}touchcancel(){this.reset();}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class Vr{constructor(e,t,i){this._el=e,this._mousePan=t,this._touchPan=i;}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan");}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan");}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Wr{constructor(e,t,i,o){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=t,this._mousePitch=i,this._mouseRoll=o;}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable();}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable();}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}}class qr{constructor(e,t,i,o){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=o,this._rotationDisabled=!1,this._enabled=!0;}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate");}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate");}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}setZoomRate(e){this._touchZoom.setZoomRate(e),this._tapDragZoom.setZoomRate(e);}setZoomThreshold(e){this._touchZoom.setZoomThreshold(e);}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable();}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable();}}class $r{constructor(e,t){this._bypassKey=navigator.userAgent.includes("Mac")?"metaKey":"ctrlKey",this._map=e,this._options=t,this._enabled=!1;}isActive(){return !1}reset(){}_setupUI(){if(this._container)return;const e=this._map.getCanvasContainer();e.classList.add("maplibregl-cooperative-gestures"),this._container=d.create("div","maplibregl-cooperative-gesture-screen",e);let t=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(t=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const i=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),o=document.createElement("div");o.className="maplibregl-desktop-message",o.textContent=t,this._container.appendChild(o);const a=document.createElement("div");a.className="maplibregl-mobile-message",a.textContent=i,this._container.appendChild(a),this._container.setAttribute("aria-hidden","true");}_destroyUI(){this._container&&(this._container.remove(),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container;}enable(){this._setupUI(),this._enabled=!0;}disable(){this._enabled=!1,this._destroyUI();}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,i){this._enabled&&(this._map.fire(new t.n("cooperativegestureprevented",{gestureType:e,originalEvent:i})),this._container.classList.add("maplibregl-show"),setTimeout((()=>{this._container.classList.remove("maplibregl-show");}),100));}}const Hr=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate;class Xr extends t.n{}function Kr(e){var t;return (null===(t=e.panDelta)||void 0===t?void 0:t.mag())||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}class Yr{get _ownerDocument(){var e;return (null===(e=this._el)||void 0===e?void 0:e.ownerDocument)||document}get _ownerWindow(){var e,t;return (null===(t=null===(e=this._el)||void 0===e?void 0:e.ownerDocument)||void 0===t?void 0:t.defaultView)||window}constructor(e,i){this.handleWindowEvent=e=>{this.handleEvent(e,`${e.type}Window`);},this.handleEvent=(e,i)=>{if("blur"===e.type)return void this.stop(!0);this._updatingCamera=!0;const o="renderFrame"===e.type?void 0:e,a={needsRenderFrame:!1},r={},s={};for(const{handlerName:n,handler:l,allowed:c}of this._handlers){if(!l.isEnabled())continue;let h;if(this._blockedByActive(s,c,n))l.reset();else if(l[i||e.type]){if(t.cz(e,i||e.type)){const t=d.mousePos(this._map.getCanvas(),e);h=l[i||e.type](e,t);}else if(t.cA(e,i||e.type)){const t=this._getMapTouches(e.touches),o=d.touchPos(this._map.getCanvas(),t);h=l[i||e.type](e,o,t);}else t.cB(i||e.type)||(h=l[i||e.type](e));this.mergeHandlerResult(a,r,h,n,o),(null==h?void 0:h.needsRenderFrame)&&this._triggerRenderFrame();}(h||l.isActive())&&(s[n]=l);}const n={};for(const e in this._previousActiveHandlers)s[e]||(n[e]=o);this._previousActiveHandlers=s,(Object.keys(n).length||Kr(a))&&(this._changes.push([a,r,n]),this._triggerRenderFrame()),(Object.keys(s).length||Kr(a))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:l}=a;l&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],l(this._map));},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new ar(e),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(i);const o=this._el;this._listeners=[[o,"touchstart",{passive:!0}],[o,"touchmove",{passive:!1}],[o,"touchend",void 0],[o,"touchcancel",void 0],[o,"mousedown",void 0],[o,"mousemove",void 0],[o,"mouseup",void 0],[this._ownerDocument,"mousemove",{capture:!0}],[this._ownerDocument,"mouseup",void 0],[o,"mouseover",void 0],[o,"mouseout",void 0],[o,"dblclick",void 0],[o,"click",void 0],[o,"keydown",{capture:!1}],[o,"keyup",void 0],[o,"wheel",{passive:!1}],[o,"contextmenu",void 0],[this._ownerWindow,"blur",void 0]];for(const[e,t,i]of this._listeners)e.addEventListener(t,e===this._ownerDocument?this.handleWindowEvent:this.handleEvent,i);}destroy(){for(const[e,t,i]of this._listeners)e.removeEventListener(t,e===this._ownerDocument?this.handleWindowEvent:this.handleEvent,i);}_addDefaultHandlers(e){const i=this._map,o=i.getCanvasContainer();this._add("mapEvent",new hr(i,e));const a=i.boxZoom=new _r(i,e);this._add("boxZoom",a),e.interactive&&e.boxZoom&&a.enable();const r=i.cooperativeGestures=new $r(i,e.cooperativeGestures);this._add("cooperativeGestures",r),e.cooperativeGestures&&r.enable();const s=new gr(i),n=new Ur(i);i.doubleClickZoom=new Zr(n,s),this._add("tapZoom",s),this._add("clickZoom",n),e.interactive&&e.doubleClickZoom&&i.doubleClickZoom.enable();const l=new Gr;this._add("tapDragZoom",l);const c=i.touchPitch=new Lr(i);this._add("touchPitch",c),e.interactive&&e.touchPitch&&i.touchPitch.enable(e.touchPitch);const h=()=>i.project(i.getCenter()),u=function({enable:e,clickTolerance:i,aroundCenter:o=!0,minPixelCenterThreshold:a=100,rotateDegreesPerPixelMoved:r=.8},s){const n=new wr({checkCorrectEvent:e=>0===e.button&&e.ctrlKey||2===e.button&&!e.ctrlKey});return new vr({clickTolerance:i,move:(e,i)=>{const n=s();if(o&&Math.abs(n.y-e.y)>a)return {bearingDelta:t.cx(new t.P(e.x,i.y),i,n)};let l=(i.x-e.x)*r;return o&&i.y<n.y&&(l=-l),{bearingDelta:l}},moveStateManager:n,enable:e,assignEvents:Cr})}(e,h),d=function({enable:e,clickTolerance:t,pitchDegreesPerPixelMoved:i=-.5}){const o=new wr({checkCorrectEvent:e=>0===e.button&&e.ctrlKey||2===e.button});return new vr({clickTolerance:t,move:(e,t)=>({pitchDelta:(t.y-e.y)*i}),moveStateManager:o,enable:e,assignEvents:Cr})}(e),_=function({enable:e,clickTolerance:t,rollDegreesPerPixelMoved:i=.3},o){const a=new wr({checkCorrectEvent:e=>2===e.button&&e.ctrlKey});return new vr({clickTolerance:t,move:(e,t)=>{const a=o();let r=(t.x-e.x)*i;return t.y<a.y&&(r=-r),{rollDelta:r}},moveStateManager:a,enable:e,assignEvents:Cr})}(e,h);i.dragRotate=new Wr(e,u,d,_),this._add("mouseRotate",u,["mousePitch"]),this._add("mousePitch",d,["mouseRotate","mouseRoll"]),this._add("mouseRoll",_,["mousePitch"]),e.interactive&&e.dragRotate&&i.dragRotate.enable();const p=function({enable:e,clickTolerance:t}){const i=new wr({checkCorrectEvent:e=>0===e.button&&!e.ctrlKey});return new vr({clickTolerance:t,move:(e,t)=>({around:t,panDelta:t.sub(e)}),activateOnStart:!0,moveStateManager:i,enable:e,assignEvents:Cr})}(e),m=new Mr(e,i);i.dragPan=new Vr(o,p,m),this._add("mousePan",p),this._add("touchPan",m,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&i.dragPan.enable(e.dragPan);const f=new Dr,g=new zr;i.touchZoomRotate=new qr(o,g,f,l),this._add("touchRotate",f,["touchPan","touchZoom"]),this._add("touchZoom",g,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&i.touchZoomRotate.enable(e.touchZoomRotate),this._add("blockableMapEvent",new ur(i));const v=i.scrollZoom=new Nr(i,(()=>this._triggerRenderFrame()));this._add("scrollZoom",v,["mousePan"]),e.interactive&&e.scrollZoom&&i.scrollZoom.enable(e.scrollZoom);const x=i.keyboard=new kr(i);this._add("keyboard",x),e.interactive&&e.keyboard&&i.keyboard.enable();}_add(e,t,i){this._handlers.push({handlerName:e,handler:t,allowed:i}),this._handlersById[e]=t;}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[];}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return !0;return !1}isZooming(){return !!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return !!this._eventsInProgress.rotate}isMoving(){return Boolean(Hr(this._eventsInProgress))||this.isZooming()}_blockedByActive(e,t,i){for(const o in e)if(o!==i&&!(null==t?void 0:t.includes(o)))return !0;return !1}_getMapTouches(e){const t=[];for(const i of e)this._el.contains(i.target)&&t.push(i);return t}mergeHandlerResult(e,i,o,a,r){if(!o)return;t.e(e,o);const s={handlerName:a,originalEvent:o.originalEvent||r};void 0!==o.zoomDelta&&(i.zoom=s),void 0!==o.panDelta&&(i.drag=s),void 0!==o.rollDelta&&(i.roll=s),void 0!==o.pitchDelta&&(i.pitch=s),void 0!==o.bearingDelta&&(i.rotate=s);}_applyChanges(){const e={},i={},o={};for(const[a,r,s]of this._changes)a.panDelta&&(e.panDelta=(e.panDelta||new t.P(0,0))._add(a.panDelta)),a.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+a.zoomDelta),a.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+a.bearingDelta),a.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+a.pitchDelta),a.rollDelta&&(e.rollDelta=(e.rollDelta||0)+a.rollDelta),void 0!==a.around&&(e.around=a.around),void 0!==a.pinchAround&&(e.pinchAround=a.pinchAround),a.noInertia&&(e.noInertia=a.noInertia),t.e(i,r),t.e(o,s);this._updateMapTransform(e,i,o),this._changes=[];}_updateMapTransform(e,t,i){const o=this._map,a=o._getTransformForUpdate(),r=o.terrain;if(!(Kr(e)||r&&this._terrainMovement))return void this._fireEvents(t,i,!0);o._stop(!0);let{panDelta:s,zoomDelta:n,bearingDelta:l,pitchDelta:c,rollDelta:h,around:u,pinchAround:d}=e;void 0!==d&&(u=d),u||(u=o.transform.centerPoint),r&&!a.isPointOnMapSurface(u)&&(u=a.centerPoint);const _={panDelta:s,zoomDelta:n,rollDelta:h,pitchDelta:c,bearingDelta:l,around:u};this._map.cameraHelper.useGlobeControls&&!a.isPointOnMapSurface(u)&&(u=a.centerPoint);const p=u.distSqr(a.centerPoint)<.01?a.center:a.screenPointToLocation(s?u.sub(s):u);this._handleMapControls({terrain:r,tr:a,deltasForHelper:_,preZoomAroundLoc:p,combinedEventsInProgress:t,panDelta:s}),o._applyUpdatedTransform(a),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(t,i,!0);}_handleMapControls({terrain:e,tr:t,deltasForHelper:i,preZoomAroundLoc:o,combinedEventsInProgress:a,panDelta:r}){const s=this._map.cameraHelper;if(s.handleMapControlsRollPitchBearingZoom(i,t),e)return s.useGlobeControls?(this._terrainMovement||!a.drag&&!a.zoom||(this._terrainMovement=!0,this._map._elevationFreeze=!0),void s.handleMapControlsPan(i,t,o)):this._terrainMovement||!a.drag&&!a.zoom?void(a.drag&&this._terrainMovement&&r?t.setCenter(t.screenPointToLocation(t.centerPoint.sub(r))):s.handleMapControlsPan(i,t,o)):(this._terrainMovement=!0,this._map._elevationFreeze=!0,void s.handleMapControlsPan(i,t,o));s.handleMapControlsPan(i,t,o);}_fireEvents(e,i,o){const a=Hr(this._eventsInProgress),r=Hr(e),s={};for(const t in e){const{originalEvent:i}=e[t];this._eventsInProgress[t]||(s[`${t}start`]=i),this._eventsInProgress[t]=e[t];}!a&&r&&this._fireEvent("movestart",r.originalEvent);for(const e in s)this._fireEvent(e,s[e]);r&&this._fireEvent("move",r.originalEvent);for(const t in e){const{originalEvent:i}=e[t];this._fireEvent(t,i);}const l={};let c;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:o}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],c=i[t]||o,l[`${e}end`]=c);}for(const e in l)this._fireEvent(e,l[e]);const h=Hr(this._eventsInProgress),u=(a||r)&&!h;if(u&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const e=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&e.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(e);}if(o&&u){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=e=>0!==e&&-this._bearingSnap<e&&e<this._bearingSnap;!e||!e.essential&&n.prefersReducedMotion?(this._map.fire(new t.n("moveend",{originalEvent:c})),i(this._map.getBearing())&&this._map.resetNorth()):(i(e.bearing||this._map.getBearing())&&(e.bearing=0),e.freezeElevation=!0,this._map.easeTo(e,{originalEvent:c})),this._updatingCamera=!1;}}_fireEvent(e,i){this._map.fire(new t.n(e,i?{originalEvent:i}:{}));}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((e=>{delete this._frameId,this.handleEvent(new Xr("renderFrame",{timeStamp:e})),this._applyChanges();}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame());}}class Qr extends t.E{constructor(e,t,i){super(),this._renderFrameCallback=()=>{const e=Math.min((c()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(e)),e<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop();},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=i.bearingSnap,this._zoomSnap=i.zoomSnap,this.cameraHelper=t,this.on("moveend",(()=>{delete this._requestedCameraState;}));}migrateProjection(e,t){e.apply(this.transform,!0),this.transform=e,this.cameraHelper=t;}getCenter(){return new t.W(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,t){return this.jumpTo({elevation:e},t),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e;}panBy(e,i,o){return e=t.P.convert(e).mult(-1),this.panTo(this.transform.center,t.e({offset:e},i),o)}panTo(e,i,o){return this.easeTo(t.e({center:e},i),o)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,i,o){return this.easeTo(t.e({zoom:e},i),o)}zoomIn(e,i){return this.zoomTo(t.cw(this.getZoom()+1,this._zoomSnap),e,i),this}zoomOut(e,i){return this.zoomTo(t.cw(this.getZoom()-1,this._zoomSnap),e,i),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,i){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new t.n("movestart",i)).fire(new t.n("move",i)).fire(new t.n("moveend",i))),this}getBearing(){return this.transform.bearing}setZoomSnap(e){return this._zoomSnap=e,this}getZoomSnap(){return this._zoomSnap}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(e,i,o){return this.easeTo(t.e({bearing:e},i),o)}resetNorth(e,i){return this.rotateTo(0,t.e({duration:1e3},e),i),this}resetNorthPitch(e,i){return this.easeTo(t.e({bearing:0,pitch:0,roll:0,duration:1e3},e),i),this}snapToNorth(e,t){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(e,t):this}getPitch(){return this.transform.pitch}setPitch(e,t){return this.jumpTo({pitch:e},t),this}getRoll(){return this.transform.roll}setRoll(e,t){return this.jumpTo({roll:e},t),this}cameraForBounds(e,t){e=G.convert(e).adjustAntiMeridian();const i=(null==t?void 0:t.bearing)||0;return this._cameraForBoxAndBearing(e.getNorthWest(),e.getSouthEast(),i,t)}_cameraForBoxAndBearing(e,i,o,a){const r={top:0,bottom:0,right:0,left:0};if("number"==typeof(a=t.e({padding:r,offset:[0,0],maxZoom:this.transform.maxZoom},a)).padding){const e=a.padding;a.padding={top:e,bottom:e,right:e,left:e};}const s=t.e(r,a.padding);a.padding=s;const n=this.transform,l=new G(e,i),c=this.cameraHelper.cameraForBoxAndBearing(a,s,l,o,n);return c&&this._zoomSnap&&(c.zoom=t.cw(c.zoom,this._zoomSnap,-1)),c}fitBounds(e,t,i){return this._fitInternal(this.cameraForBounds(e,t),t,i)}fitScreenCoordinates(e,i,o,a,r){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.screenPointToLocation(t.P.convert(e)),this.transform.screenPointToLocation(t.P.convert(i)),o,a),a,r)}_fitInternal(e,i,o){return e?(delete(i=t.e(e,i)).padding,i.linear?this.easeTo(i,o):this.flyTo(i,o)):this}jumpTo(e,i){this.stop(),"zoom"in e&&this._zoomSnap&&(e.zoom=t.cw(e.zoom,this._zoomSnap));const o=this._getTransformForUpdate();let a=!1,r=!1,s=!1;const n=o.zoom;this.terrain&&o.setElevation(this.terrain.getElevationForLngLatZoom(e.center?t.W.convert(e.center):o.center,e.zoom||o.tileZoom)),this.cameraHelper.handleJumpToCenterZoom(o,e);const l=o.zoom!==n;return "elevation"in e&&o.elevation!==+e.elevation&&o.setElevation(+e.elevation),"bearing"in e&&o.bearing!==+e.bearing&&(a=!0,o.setBearing(+e.bearing)),"pitch"in e&&o.pitch!==+e.pitch&&(r=!0,o.setPitch(+e.pitch)),"roll"in e&&o.roll!==+e.roll&&(s=!0,o.setRoll(+e.roll)),null==e.padding||o.isPaddingEqual(e.padding)||o.setPadding(e.padding),this._applyUpdatedTransform(o),this.fire(new t.n("movestart",i)).fire(new t.n("move",i)),l&&this.fire(new t.n("zoomstart",i)).fire(new t.n("zoom",i)).fire(new t.n("zoomend",i)),a&&this.fire(new t.n("rotatestart",i)).fire(new t.n("rotate",i)).fire(new t.n("rotateend",i)),r&&this.fire(new t.n("pitchstart",i)).fire(new t.n("pitch",i)).fire(new t.n("pitchend",i)),s&&this.fire(new t.n("rollstart",i)).fire(new t.n("roll",i)).fire(new t.n("rollend",i)),this.fire(new t.n("moveend",i))}calculateCameraOptionsFromTo(e,i,o,a=0){const r=t.a7.fromLngLat(e,i),s=t.a7.fromLngLat(o,a),n=s.x-r.x,l=s.y-r.y,c=s.z-r.z,h=Math.hypot(n,l,c);if(0===h)throw new Error("Can't calculate camera options with same From and To");const u=Math.hypot(n,l),d=t.ar(this.transform.cameraToCenterDistance/h/this.transform.tileSize),_=180*Math.atan2(n,-l)/Math.PI;let p=180*Math.acos(u/h)/Math.PI;return p=c<0?90-p:90+p,{center:s.toLngLat(),elevation:a,zoom:d,pitch:p,bearing:_}}calculateCameraOptionsFromCameraLngLatAltRotation(e,t,i,o,a){const r=this.transform.calculateCenterFromCameraLngLatAlt(e,t,i,o);return {center:r.center,elevation:r.elevation,zoom:r.zoom,bearing:i,pitch:o,roll:a}}easeTo(e,i){this._stop(!1,e.easeId),"zoom"in(e=t.e({offset:[0,0],duration:500,easing:t.cy},e))&&this._zoomSnap&&(e.zoom=t.cw(e.zoom,this._zoomSnap)),(!1===e.animate||!e.essential&&n.prefersReducedMotion)&&(e.duration=0);const o=this._getTransformForUpdate(),a=this.getBearing(),r=o.pitch,s=o.roll,l="bearing"in e?this._normalizeBearing(e.bearing,a):a,c="pitch"in e?+e.pitch:r,h="roll"in e?this._normalizeBearing(e.roll,s):s,u="padding"in e?e.padding:o.padding,d=t.P.convert(e.offset);let _,p;e.around&&(_=t.W.convert(e.around),p=o.locationToScreenPoint(_));const m={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching,rolling:this._rolling},f=this.cameraHelper.handleEaseTo(o,{bearing:l,pitch:c,roll:h,padding:u,around:_,aroundPoint:p,offsetAsPoint:d,offset:e.offset,zoom:e.zoom,center:e.center});return this._rotating||(this._rotating=a!==l),this._pitching||(this._pitching=c!==r),this._rolling||(this._rolling=h!==s),this._padding=!o.isPaddingEqual(u),this._zooming||(this._zooming=f.isZooming),this._easeId=e.easeId,this._prepareEase(i,e.noMoveStart,m),this.terrain&&this._prepareElevation(f.elevationCenter),this._ease((t=>{f.easeFunc(t),this.terrain&&!e.freezeElevation&&this._updateElevation(t),this._applyUpdatedTransform(o),this._fireMoveEvents(i);}),(t=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(i,t);}),e),this}_prepareEase(e,i,o={}){this._moving=!0,i||o.moving||this.fire(new t.n("movestart",e)),this._zooming&&!o.zooming&&this.fire(new t.n("zoomstart",e)),this._rotating&&!o.rotating&&this.fire(new t.n("rotatestart",e)),this._pitching&&!o.pitching&&this.fire(new t.n("pitchstart",e)),this._rolling&&!o.rolling&&this.fire(new t.n("rollstart",e));}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),this._elevationFreeze=!0;}_updateElevation(e){void 0!==this._elevationStart&&void 0!==this._elevationCenter||this._prepareElevation(this.transform.center),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));const i=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&i!==this._elevationTarget){const t=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(t-(i-(t*e+this._elevationStart))/(1-e)),this._elevationTarget=i;}this.transform.setElevation(t.H.number(this._elevationStart,this._elevationTarget,e));}_finalizeElevation(){this._elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain);}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90)return {};const t=e.getCameraLngLat(),i=e.getCameraAltitude(),o=this.terrain?this.terrain.getElevationForLngLatZoom(t,e.zoom):0;if(i<o){const i=this.calculateCameraOptionsFromTo(t,o,e.center,e.elevation);return {pitch:i.pitch,zoom:i.zoom}}return {}}_applyUpdatedTransform(e){const t=[];if(t.push((e=>this._elevateCameraIfInsideTerrain(e))),this.transformCameraUpdate&&t.push((e=>this.transformCameraUpdate(e))),!t.length)return;const i=e.clone();for(const e of t){const t=i.clone(),{center:o,zoom:a,roll:r,pitch:s,bearing:n,elevation:l}=e(t);o&&t.setCenter(o),void 0!==l&&t.setElevation(l),void 0!==a&&t.setZoom(a),void 0!==r&&t.setRoll(r),void 0!==s&&t.setPitch(s),void 0!==n&&t.setBearing(n),i.apply(t,!1);}this.transform.apply(i,!1);}_fireMoveEvents(e){this.fire(new t.n("move",e)),this._zooming&&this.fire(new t.n("zoom",e)),this._rotating&&this.fire(new t.n("rotate",e)),this._pitching&&this.fire(new t.n("pitch",e)),this._rolling&&this.fire(new t.n("roll",e));}_afterEase(e,i){if(this._easeId&&i&&this._easeId===i)return;delete this._easeId;const o=this._zooming,a=this._rotating,r=this._pitching,s=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,o&&this.fire(new t.n("zoomend",e)),a&&this.fire(new t.n("rotateend",e)),r&&this.fire(new t.n("pitchend",e)),s&&this.fire(new t.n("rollend",e)),this.fire(new t.n("moveend",e));}flyTo(e,i){if(!e.essential&&n.prefersReducedMotion){const o=t.V(e,["center","zoom","bearing","pitch","roll","elevation","padding"]);return this.jumpTo(o,i)}this.stop(),"zoom"in(e=t.e({offset:[0,0],speed:1.2,curve:1.42,easing:t.cy},e))&&this._zoomSnap&&(e.zoom=t.cw(e.zoom,this._zoomSnap));const o=this._getTransformForUpdate(),a=o.bearing,r=o.pitch,s=o.roll,l=o.padding,c="bearing"in e?this._normalizeBearing(e.bearing,a):a,h="pitch"in e?+e.pitch:r,u="roll"in e?this._normalizeBearing(e.roll,s):s,d="padding"in e?e.padding:o.padding,_=t.P.convert(e.offset);let p=o.centerPoint.add(_);const m=o.screenPointToLocation(p),f=this.cameraHelper.handleFlyTo(o,{bearing:c,pitch:h,roll:u,padding:d,locationAtOffset:m,offsetAsPoint:_,center:e.center,minZoom:e.minZoom,zoom:e.zoom});let g=e.curve;const v=Math.max(o.width,o.height),x=v/f.scaleOfZoom,b=f.pixelPathLength;"number"==typeof f.scaleOfMinZoom&&(g=Math.sqrt(v/f.scaleOfMinZoom/b*2));const y=g*g;function w(e){const t=(x*x-v*v+(e?-1:1)*y*y*b*b)/(2*(e?x:v)*y*b);return Math.log(Math.sqrt(t*t+1)-t)}function T(e){return (Math.exp(e)-Math.exp(-e))/2}function P(e){return (Math.exp(e)+Math.exp(-e))/2}const C=w(!1);let M=function(e){return P(C)/P(C+g*e)},I=function(e){return v*((P(C)*(T(t=C+g*e)/P(t))-T(C))/y)/b;var t;},E=(w(!0)-C)/g;if(Math.abs(b)<2e-6||!isFinite(E)){if(Math.abs(v-x)<1e-6)return this.easeTo(e,i);const t=x<v?-1:1;E=Math.abs(Math.log(x/v))/g,I=()=>0,M=e=>Math.exp(t*g*e);}return e.duration="duration"in e?+e.duration:1e3*E/("screenSpeed"in e?+e.screenSpeed/g:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=a!==c,this._pitching=h!==r,this._rolling=u!==s,this._padding=!o.isPaddingEqual(d),this._prepareEase(i,!1),this.terrain&&this._prepareElevation(f.targetCenter),this._ease((n=>{const m=n*E,g=1/M(m),v=I(m);this._rotating&&o.setBearing(t.H.number(a,c,n)),this._pitching&&o.setPitch(t.H.number(r,h,n)),this._rolling&&o.setRoll(t.H.number(s,u,n)),this._padding&&(o.interpolatePadding(l,d,n),p=o.centerPoint.add(_)),f.easeFunc(n,g,v,p),this.terrain&&!e.freezeElevation&&this._updateElevation(n),this._applyUpdatedTransform(o),this._fireMoveEvents(i);}),(()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(i);}),e),this}isEasing(){return !!this._easeFrameId}stop(){return this._stop()}_stop(e,t){var i;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const e=this._onEaseEnd;delete this._onEaseEnd,e.call(this,t);}return e||null===(i=this.handlers)||void 0===i||i.stop(!1),this}_ease(e,t,i){!1===i.animate||0===i.duration?(e(1),t()):(this._easeStart=c(),this._easeOptions=i,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback));}_normalizeBearing(e,i){e=t.X(e,-180,180);const o=Math.abs(e-i);return Math.abs(e-360-i)<o&&(e-=360),Math.abs(e+360-i)<o&&(e+=360),e}queryTerrainElevation(e){return this.terrain?this.terrain.getElevationForLngLat(t.W.convert(e),this.transform):null}}const Jr={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};class es{constructor(e=Jr){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")));},this._updateData=e=>{!e||"metadata"!==e.sourceDataType&&"visibility"!==e.sourceDataType&&"style"!==e.dataType&&"terrain"!==e.type||this._updateAttributions();},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"));},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show");},this.options=e;}getDefaultPosition(){return "bottom-right"}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=d.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=d.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=d.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0;}_setElementTitle(e,t){const i=this._map._getUIString(`AttributionControl.${t}`);e.title=i,e.setAttribute("aria-label",i);}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map((e=>"string"!=typeof e?"":e))):"string"==typeof this.options.customAttribution&&e.push(this.options.customAttribution)),this._map.style.stylesheet){const e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id;}const t=this._map.style.tileManagers;for(const i in t){const o=t[i];if(o.used||o.usedForTerrain){const t=o.getSource();t.attribution&&!e.includes(t.attribution)&&e.push(t.attribution);}}e=e.filter((e=>String(e).trim())),e.sort(((e,t)=>e.length-t.length)),e=e.filter(((t,i)=>{for(let o=i+1;o<e.length;o++)if(e[o].includes(t))return !1;return !0}));const i=e.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,e.length?(this._innerContainer.innerHTML=d.sanitize(i),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null);}}class ts{constructor(e={}){this._updateCompact=()=>{const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&t.classList.add("maplibregl-compact"):t.classList.remove("maplibregl-compact");}},this.options=e;}getDefaultPosition(){return "bottom-left"}onAdd(e){var t;this._map=e,this._compact=null===(t=this.options)||void 0===t?void 0:t.compact,this._container=d.create("div","maplibregl-ctrl");const i=d.create("a","maplibregl-ctrl-logo");return i.target="_blank",i.rel="noopener nofollow",i.href="https://maplibre.org/",i.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),i.setAttribute("rel","noopener nofollow"),this._container.appendChild(i),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0;}}class is{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1;}add(e){const t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){const t=this._currentlyRunning,i=t?this._queue.concat(t):this._queue;for(const t of i)if(t.id===e)return void(t.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const t=this._currentlyRunning=this._queue;this._queue=[];for(const i of t)if(!i.cancelled&&(i.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1;}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[];}}var os=t.aS([{name:"a_pos3d",type:"Int16",components:3}]);class as extends t.E{constructor(e){super(),this._lastTilesetChange=c(),this.tileManager=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=e._source.tileSize*2**this.deltaZoom,e.usedForTerrain=!0,e.tileSize=this.tileSize;}destruct(){this.tileManager.usedForTerrain=!1,this.tileManager.tileSize=null;}getSource(){return this.tileManager._source}update(e,i){this.tileManager.update(e,i),this._renderableTilesKeys=[];const o={};for(const a of Me(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:i,calculateTileZoom:this.tileManager._source.calculateTileZoom}))o[a.key]=!0,this._renderableTilesKeys.push(a.key),this._tiles[a.key]||(a.terrainRttPosMatrix32f=new Float64Array(16),t.c7(a.terrainRttPosMatrix32f,0,t.a6,t.a6,0,0,1),this._tiles[a.key]=new de(a,this.tileSize),this._lastTilesetChange=c());for(const e in this._tiles)o[e]||delete this._tiles[e];}freeRtt(e){for(const t in this._tiles){const i=this._tiles[t];(!e||i.tileID.equals(e)||i.tileID.isChildOf(e)||e.isChildOf(i.tileID))&&(i.rtt=[]);}}getRenderableTiles(){return this._renderableTilesKeys.map((e=>this.getTileByID(e)))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e,t){return t?this._getTerrainCoordsForTileRanges(e,t):this._getTerrainCoordsForRegularTile(e)}_getTerrainCoordsForRegularTile(e){const i={};for(const o of this._renderableTilesKeys){const a=this._tiles[o].tileID,r=e.clone(),s=t.bj();if(a.canonical.equals(e.canonical))t.c7(s,0,t.a6,t.a6,0,0,1);else if(a.canonical.isChildOf(e.canonical)){const i=a.canonical.z-e.canonical.z,o=a.canonical.x-(a.canonical.x>>i<<i),r=a.canonical.y-(a.canonical.y>>i<<i),n=t.a6>>i;t.c7(s,0,n,n,0,0,1),t.Q(s,s,[-o*n,-r*n,0]);}else {if(!e.canonical.isChildOf(a.canonical))continue;{const i=e.canonical.z-a.canonical.z,o=e.canonical.x-(e.canonical.x>>i<<i),r=e.canonical.y-(e.canonical.y>>i<<i),n=t.a6>>i;t.c7(s,0,t.a6,t.a6,0,0,1),t.Q(s,s,[o*n,r*n,0]),t.S(s,s,[1/2**i,1/2**i,0]);}}r.terrainRttPosMatrix32f=new Float32Array(s),i[o]=r;}return i}_getTerrainCoordsForTileRanges(e,i){const o={};for(const a of this._renderableTilesKeys){const r=this._tiles[a].tileID;if(!this._isWithinTileRanges(r,i))continue;const s=e.clone(),n=t.bj();if(r.canonical.z===e.canonical.z){const i=e.canonical.x-r.canonical.x+e.wrap*(1<<e.canonical.z),o=e.canonical.y-r.canonical.y;t.c7(n,0,t.a6,t.a6,0,0,1),t.Q(n,n,[i*t.a6,o*t.a6,0]);}else if(r.canonical.z>e.canonical.z){const i=r.canonical.z-e.canonical.z,o=r.canonical.x-(r.canonical.x>>i<<i)+e.wrap*(1<<r.canonical.z),a=r.canonical.y-(r.canonical.y>>i<<i),s=e.canonical.x-(r.canonical.x>>i),l=e.canonical.y-(r.canonical.y>>i),c=t.a6>>i;t.c7(n,0,c,c,0,0,1),t.Q(n,n,[-o*c+s*t.a6,-a*c+l*t.a6,0]);}else {const i=e.canonical.z-r.canonical.z,o=e.canonical.x-(e.canonical.x>>i<<i)+e.wrap*(1<<e.canonical.z),a=e.canonical.y-(e.canonical.y>>i<<i),s=(e.canonical.x>>i)-r.canonical.x,l=(e.canonical.y>>i)-r.canonical.y,c=t.a6<<i;t.c7(n,0,c,c,0,0,1),t.Q(n,n,[o*t.a6+s*c,a*t.a6+l*c,0]);}s.terrainRttPosMatrix32f=new Float32Array(n),o[a]=s;}return o}getSourceTile(e,t){var i,o;const a=this.tileManager._source;let r=e.overscaledZ-this.deltaZoom;if(r>a.maxzoom&&(r=a.maxzoom),r<a.minzoom)return;(i=this._sourceTileCache)[o=e.key]||(i[o]=e.scaledTo(r).key);let s=this.findTileInCaches(this._sourceTileCache[e.key]);if(!(null==s?void 0:s.dem)&&t)for(;r>=a.minzoom&&!(null==s?void 0:s.dem);)s=this.findTileInCaches(e.scaledTo(r--).key);return s}findTileInCaches(e){let t=this.tileManager.getTileByID(e);return t||(t=this.tileManager._outOfViewCache.getByKey(e),t)}anyTilesAfterTime(e=Date.now()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,t){const i=t[e.canonical.z];return !!i&&(e.wrap>i.minWrap||e.wrap<i.maxWrap||e.canonical.x>=i.minTileXWrapped&&e.canonical.x<=i.maxTileXWrapped&&e.canonical.y>=i.minTileY&&e.canonical.y<=i.maxTileY)}}class rs{constructor(e,t,i){this._meshCache={},this.painter=e,this.tileManager=new as(t),this.options=i,this.exaggeration="number"==typeof i.exaggeration?i.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024;}destroy(){this._fbo&&(this._fbo.destroy(),this._fbo=null),this._fboCoordsTexture&&(this._fboCoordsTexture.destroy(),this._fboCoordsTexture=null),this._fboDepthTexture&&(this._fboDepthTexture.destroy(),this._fboDepthTexture=null),this._emptyDemTexture&&(this._emptyDemTexture.destroy(),this._emptyDemTexture=null),this._emptyDepthTexture&&(this._emptyDepthTexture.destroy(),this._emptyDepthTexture=null),this._coordsTexture&&(this._coordsTexture.destroy(),this._coordsTexture=null);for(const e in this._meshCache)this._meshCache[e].destroy();this._meshCache={},this.tileManager.destruct();}getDEMElevation(e,i,o,a=t.a6){var r;const s=e.normalizeCoordinates(i,o,a);if(!s)return 0;const n=this.getTerrainData(s.tileID),l=null===(r=n.tile)||void 0===r?void 0:r.dem;if(!l)return 0;const c=t.cC([],[s.x/a*t.a6,s.y/a*t.a6],n.u_terrain_matrix),h=[c[0]*l.dim,c[1]*l.dim],u=Math.floor(h[0]),d=Math.floor(h[1]),_=h[0]-u,p=h[1]-d;return l.get(u,d)*(1-_)*(1-p)+l.get(u+1,d)*_*(1-p)+l.get(u,d+1)*(1-_)*p+l.get(u+1,d+1)*_*p}getElevationForLngLatZoom(e,i){if(!t.cD(i,e.wrap()))return 0;const{tileID:o,mercatorX:a,mercatorY:r}=this._getOverscaledTileIDFromLngLatZoom(e,i);return this.getElevation(o,a%t.a6,r%t.a6,t.a6)}getElevationForLngLat(e,t){const i=Me(t,{maxzoom:this.tileManager.maxzoom,minzoom:this.tileManager.minzoom,tileSize:512,terrain:this});let o=0;for(const e of i)e.canonical.z>o&&(o=Math.min(e.canonical.z,this.tileManager.maxzoom));return this.getElevationForLngLatZoom(e,o)}getElevation(e,i,o,a=t.a6){return this.getDEMElevation(e,i,o,a)*this.exaggeration}getTerrainData(e){var i,o;if(!this._emptyDemTexture){const e=this.painter.context,i=new t.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new t.T(e,i,e.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new t.T(e,new t.R({width:1,height:1}),e.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=t.ap([]);}const a=this.tileManager.getSourceTile(e,!0);if((null==a?void 0:a.dem)&&(!a.demTexture||a.needsTerrainPrepare)){const e=this.painter.context;a.demTexture=this.painter.getTileTexture(a.dem.stride),a.demTexture?a.demTexture.update(a.dem.getPixels(),{premultiply:!1}):a.demTexture=new t.T(e,a.dem.getPixels(),e.gl.RGBA,{premultiply:!1}),a.demTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),a.needsTerrainPrepare=!1;}const r=a&&a.toString()+a.tileID.key+e.key;if(r&&!this._demMatrixCache[r]){const i=this.tileManager.getSource().maxzoom;let o=e.canonical.z-a.tileID.canonical.z;e.overscaledZ>e.canonical.z&&(e.canonical.z>=i?o=e.canonical.z-i:t.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const s=e.canonical.x-(e.canonical.x>>o<<o),n=e.canonical.y-(e.canonical.y>>o<<o),l=t.cE(new Float64Array(16),[1/(t.a6<<o),1/(t.a6<<o),0]);t.Q(l,l,[s*t.a6,n*t.a6,0]),this._demMatrixCache[r]={matrix:l,coord:e};}return {u_depth:2,u_terrain:3,u_terrain_dim:(null===(i=null==a?void 0:a.dem)||void 0===i?void 0:i.dim)||1,u_terrain_matrix:r?this._demMatrixCache[r].matrix:this._emptyDemMatrix,u_terrain_unpack:(null===(o=null==a?void 0:a.dem)||void 0===o?void 0:o.getUnpackVector())||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:((null==a?void 0:a.demTexture)||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:a}}getFramebuffer(e){const i=this.painter,o=i.width/devicePixelRatio,a=i.height/devicePixelRatio;return !this._fbo||this._fbo.width===o&&this._fbo.height===a||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new t.T(i.context,{width:o,height:a,data:null},i.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(i.context.gl.NEAREST,i.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new t.T(i.context,{width:o,height:a,data:null},i.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(i.context.gl.NEAREST,i.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=i.context.createFramebuffer(o,a,!0,!1),this._fbo.depthAttachment.set(i.context.createRenderbuffer(i.context.gl.DEPTH_COMPONENT16,o,a))),this._fbo.colorAttachment.set("coords"===e?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){const e=this.painter.context;if(this._coordsTexture)return this._coordsTexture;const i=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let e=0,t=0;e<this._coordsTextureSize;e++)for(let o=0;o<this._coordsTextureSize;o++,t+=4)i[t+0]=255&o,i[t+1]=255&e,i[t+2]=o>>8<<4|e>>8,i[t+3]=0;const o=new t.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(i.buffer)),a=new t.T(e,o,e.gl.RGBA,{premultiply:!1});return a.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=a,a}pointCoordinate(e){this.painter.maybeDrawDepth(!0),this.painter.maybeDrawCoords();const i=new Uint8Array(4),o=this.painter.context,a=o.gl,r=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),s=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),n=Math.round(this.painter.height/devicePixelRatio);o.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),a.readPixels(r,n-s-1,1,1,a.RGBA,a.UNSIGNED_BYTE,i),o.bindFramebuffer.set(null);const l=i[0]+(i[2]>>4<<8),c=i[1]+((15&i[2])<<8),h=this.coordsIndex[255-i[3]],u=h&&this.tileManager.getTileByID(h);if(!u)return null;const d=this._coordsTextureSize,_=(1<<u.tileID.canonical.z)*d;return new t.a7((u.tileID.canonical.x*d+l)/_+u.tileID.wrap,(u.tileID.canonical.y*d+c)/_,this.getElevation(u.tileID,l,c,d))}depthAtPoint(e){const t=new Uint8Array(4),i=this.painter.context,o=i.gl;return i.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),o.readPixels(e.x,this.painter.height/devicePixelRatio-e.y-1,1,1,o.RGBA,o.UNSIGNED_BYTE,t),i.bindFramebuffer.set(null),(t[0]/16777216+t[1]/65536+t[2]/256+t[3])/256}getTerrainMesh(e){var i;const o=(null===(i=this.painter.style.projection)||void 0===i?void 0:i.transitionState)>0,a=o&&0===e.canonical.y,r=o&&e.canonical.y===(1<<e.canonical.z)-1,s=`m_${a?"n":""}_${r?"s":""}`;if(this._meshCache[s])return this._meshCache[s];const n=this.painter.context,l=new t.cF,c=new t.aW,h=this.meshSize,u=t.a6/h,d=h*h;for(let e=0;e<=h;e++)for(let t=0;t<=h;t++)l.emplaceBack(t*u,e*u,0);for(let e=0;e<d;e+=h+1)for(let t=0;t<h;t++)c.emplaceBack(t+e,h+t+e+1,h+t+e+2),c.emplaceBack(t+e,h+t+e+2,t+e+1);const _=l.length,p=_+(h+1),m=(h+1)*h,f=a?t.bq:0,g=a?0:1,v=r?t.br:t.a6,x=r?0:1;for(let e=0;e<=h;e++)l.emplaceBack(e*u,f,g);for(let e=0;e<=h;e++)l.emplaceBack(e*u,v,x);for(let e=0;e<h;e++)c.emplaceBack(m+e,p+e,p+e+1),c.emplaceBack(m+e,p+e+1,m+e+1),c.emplaceBack(0+e,_+e+1,_+e),c.emplaceBack(0+e,0+e+1,_+e+1);const b=l.length,y=b+2*(h+1);for(const e of [0,1])for(let i=0;i<=h;i++)for(const o of [0,1])l.emplaceBack(e*t.a6,i*u,o);for(let e=0;e<2*h;e+=2)c.emplaceBack(b+e,b+e+1,b+e+3),c.emplaceBack(b+e,b+e+3,b+e+2),c.emplaceBack(y+e,y+e+3,y+e+1),c.emplaceBack(y+e,y+e+2,y+e+3);const w=new Bt(n.createVertexBuffer(l,os.members),n.createIndexBuffer(c),t.aV.simpleSegment(0,0,l.length,c.length));return this._meshCache[s]=w,w}getMeshFrameDelta(e){return 2*Math.PI*t.bD/Math.pow(2,Math.max(e,0))/5}getMinTileElevationForLngLatZoom(e,i){var o;if(!t.cD(i,e.wrap()))return 0;const{tileID:a}=this._getOverscaledTileIDFromLngLatZoom(e,i);return null!==(o=this.getMinMaxElevation(a).minElevation)&&void 0!==o?o:0}getMinMaxElevation(e){const t=this.getTerrainData(e).tile,i={minElevation:null,maxElevation:null};return (null==t?void 0:t.dem)&&(i.minElevation=t.dem.min*this.exaggeration,i.maxElevation=t.dem.max*this.exaggeration),i}_getOverscaledTileIDFromLngLatZoom(e,i){const o=t.a7.fromLngLat(e.wrap()),a=(1<<i)*t.a6,r=o.x*a,s=o.y*a,n=Math.floor(r/t.a6),l=Math.floor(s/t.a6);return {tileID:new t.a3(i,0,i,n,l),mercatorX:r,mercatorY:s}}}class ss{constructor(e,t,i){this._context=e,this._size=t,this._tileSize=i,this._objects=[],this._recentlyUsed=[],this._stamp=0;}destruct(){for(const e of this._objects)e.texture.destroy(),e.fbo.destroy();}_createObject(e){const i=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),o=new t.T(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return o.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),this._context.extTextureFilterAnisotropic&&this._context.gl.texParameterf(this._context.gl.TEXTURE_2D,this._context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this._context.extTextureFilterAnisotropicMax),i.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),i.colorAttachment.set(o.texture),{id:e,fbo:i,texture:o,stamp:-1,inUse:!1}}getObjectForId(e){return this._objects[e]}useObject(e){e.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter((t=>e.id!==t)),this._recentlyUsed.push(e.id);}stampObject(e){e.stamp=++this._stamp;}getOrCreateFreeObject(){for(const e of this._recentlyUsed)if(!this._objects[e].inUse)return this._objects[e];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const e=this._createObject(this._objects.length);return this._objects.push(e),e}freeObject(e){e.inUse=!1;}freeAllObjects(){for(const e of this._objects)this.freeObject(e);}isFull(){return !(this._objects.length<this._size)&&!1===this._objects.some((e=>!e.inUse))}}const ns={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};class ls{constructor(e,t){this.painter=e,this.terrain=t,this.pool=new ss(e.context,30,t.tileManager.tileSize*t.qualityFactor);}destruct(){this.pool.destruct();}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,t){var i,o,a;this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=e._order.filter((i=>!e._layers[i].isHidden(t))),this._coordsAscending={};for(const t in e.tileManagers){this._coordsAscending[t]={};const i=e.tileManagers[t].getVisibleCoordinates(),o=e.tileManagers[t].getSource(),r=o instanceof te?o.terrainTileRanges:null;for(const e of i){const i=this.terrain.tileManager.getTerrainCoords(e,r);for(const e in i)(a=this._coordsAscending[t])[e]||(a[e]=[]),this._coordsAscending[t][e].push(i[e]);}}this._rttFingerprints={};for(const t of e._order){const a=e._layers[t],r=a.source;if(ns[a.type]&&!this._rttFingerprints[r]){this._rttFingerprints[r]={};const t=null!==(o=null===(i=e.tileManagers[r])||void 0===i?void 0:i.getState().revision)&&void 0!==o?o:0;for(const e in this._coordsAscending[r])this._rttFingerprints[r][e]=`${this._coordsAscending[r][e].map((e=>e.key)).sort().join()}#${t}`;}}for(const e of this._renderableTiles)for(const t in this._rttFingerprints){const i=this._rttFingerprints[t][e.tileID.key];i&&i!==e.rttFingerprint[t]&&(e.rtt=[]);}}renderLayer(e,i){if(e.isHidden(this.painter.transform.zoom))return !1;const o=Object.assign(Object.assign({},i),{isRenderingToTexture:!0}),a=e.type,r=this.painter,s=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(ns[a]&&(this._prevType&&ns[this._prevType]||this._stacks.push([]),this._prevType=a,this._stacks[this._stacks.length-1].push(e.id),!s))return !0;if(ns[this._prevType]||ns[a]&&s){this._prevType=a;const e=this._stacks.length-1,i=this._stacks[e]||[];for(const a of this._renderableTiles){if(this.pool.isFull()&&(qa(this.painter,this.terrain,this._rttTiles,o),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(a),a.rtt[e]){const t=this.pool.getObjectForId(a.rtt[e].id);if(t.stamp===a.rtt[e].stamp){this.pool.useObject(t);continue}}const s=this.pool.getOrCreateFreeObject();this.pool.useObject(s),this.pool.stampObject(s),a.rtt[e]={id:s.id,stamp:s.stamp},r.context.bindFramebuffer.set(s.fbo.framebuffer),r.context.clear({color:t.bo.transparent,stencil:0}),r.currentStencilSource=void 0;for(const e of i){const t=r.style._layers[e],i=t.source?this._coordsAscending[t.source][a.tileID.key]:[a.tileID];r.context.viewport.set([0,0,s.fbo.width,s.fbo.height]),r._renderTileClippingMasks(t,i,!0),r.renderLayer(r,r.style.tileManagers[t.source],t,i,o),t.source&&(a.rttFingerprint[t.source]=this._rttFingerprints[t.source][a.tileID.key]);}}return qa(this.painter,this.terrain,this._rttTiles,o),this._rttTiles=[],this.pool.freeAllObjects(),ns[a]}return !1}}const cs={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"MapLibre logo","Map.Title":"Map","Marker.Title":"Map marker","NavigationControl.ResetBearing":"Drag to rotate map, click to reset north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","Popup.Close":"Close popup","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","GlobeControl.Enable":"Enable globe","GlobeControl.Disable":"Disable globe","TerrainControl.Enable":"Enable terrain","TerrainControl.Disable":"Disable terrain","CooperativeGesturesHandler.WindowsHelpText":"Use Ctrl + scroll to zoom the map","CooperativeGesturesHandler.MacHelpText":"Use ⌘ + scroll to zoom the map","CooperativeGesturesHandler.MobileHelpText":"Use two fingers to move the map"},hs=i,us={hash:!1,interactive:!0,bearingSnap:7,zoomSnap:0,attributionControl:Jr,maplibreLogo:!1,refreshExpiredTiles:!0,canvasContextAttributes:{antialias:!1,preserveDrawingBuffer:!1,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,desynchronized:!1,contextType:void 0},scrollZoom:!0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:60,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,trackResize:!0,center:[0,0],elevation:0,zoom:0,bearing:0,pitch:0,roll:0,renderWorldCopies:!0,maxTileCacheSize:null,maxTileCacheZoomLevels:t.c.MAX_TILE_CACHE_ZOOM_LEVELS,transformRequest:null,transformCameraUpdate:null,transformConstrain:null,fadeDuration:300,crossSourceCollisions:!0,clickTolerance:3,localIdeographFontFamily:"sans-serif",pitchWithRotate:!0,rollEnabled:!1,reduceMotion:void 0,validateStyle:!0,maxCanvasSize:[4096,4096],cancelPendingTileRequestsWhileZooming:!0,centerClampedToGround:!0,experimentalZoomLevelsToOverscale:void 0,anisotropicFilterPitch:20};let ds=class extends Qr{get _ownerWindow(){var e,t;return (null===(t=null===(e=this._container)||void 0===e?void 0:e.ownerDocument)||void 0===t?void 0:t.defaultView)||window}constructor(e){var i,o,a;const r=Object.assign(Object.assign(Object.assign({},us),e),{canvasContextAttributes:Object.assign(Object.assign({},us.canvasContextAttributes),e.canvasContextAttributes)});if(null!=r.minZoom&&null!=r.maxZoom&&r.minZoom>r.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=r.minPitch&&null!=r.maxPitch&&r.minPitch>r.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=r.minPitch&&r.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=r.maxPitch&&r.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const s=new Xt,l=new Jt;void 0!==r.minZoom&&s.setMinZoom(r.minZoom),void 0!==r.maxZoom&&s.setMaxZoom(r.maxZoom),void 0!==r.minPitch&&s.setMinPitch(r.minPitch),void 0!==r.maxPitch&&s.setMaxPitch(r.maxPitch),void 0!==r.renderWorldCopies&&s.setRenderWorldCopies(r.renderWorldCopies),null!==r.transformConstrain&&s.setConstrainOverride(r.transformConstrain),super(s,l,{bearingSnap:r.bearingSnap,zoomSnap:r.zoomSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new is,this._controls=[],this._mapId=t.ad(),this._lostContextStyle={style:null,images:null},this._contextLost=e=>{if(e.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.painter.destroy(),this._lostContextStyle=this._getStyleAndImages(),this.style){for(const e of Object.values(this.style._layers))if("custom"===e.type&&console.warn(`Custom layer with id '${e.id}' cannot be restored after WebGL context loss. You will need to re-add it manually after context restoration.`),e._listeners)for(const[t]of Object.entries(e._listeners))console.warn(`Custom layer with id '${e.id}' had event listeners for event '${t}' which cannot be restored after WebGL context loss. You will need to re-add them manually after context restoration.`);this.style.destroy(),this.style=null,this.fire(new t.n("webglcontextlost",{originalEvent:e}));}else this.fire(new t.n("webglcontextlost",{originalEvent:e}));},this._contextRestored=e=>{this._lostContextStyle.style&&this.setStyle(this._lostContextStyle.style,{diff:!1}),this._lostContextStyle.images&&this.style&&(this.style.imageManager.images=this._lostContextStyle.images),this._lostContextStyle={style:null,images:null},this._setupPainter(),this.resize(),this._update(),this._resizeInternal(),this.fire(new t.n("webglcontextrestored",{originalEvent:e}));},this._onMapScroll=e=>{if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update();},this._interactive=r.interactive,this._maxTileCacheSize=r.maxTileCacheSize,this._maxTileCacheZoomLevels=r.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},r.canvasContextAttributes),this._trackResize=!0===r.trackResize,this._bearingSnap=r.bearingSnap,this._zoomSnap=r.zoomSnap,this._centerClampedToGround=r.centerClampedToGround,this._refreshExpiredTiles=!0===r.refreshExpiredTiles,this._fadeDuration=r.fadeDuration,this._crossSourceCollisions=!0===r.crossSourceCollisions,this._collectResourceTiming=!0===r.collectResourceTiming,this._locale=Object.assign(Object.assign({},cs),r.locale),this._clickTolerance=r.clickTolerance,this._overridePixelRatio=r.pixelRatio,this._maxCanvasSize=r.maxCanvasSize,this._zoomLevelsToOverscale=r.experimentalZoomLevelsToOverscale,this.transformCameraUpdate=r.transformCameraUpdate,this.transformConstrain=r.transformConstrain,this.cancelPendingTileRequestsWhileZooming=!0===r.cancelPendingTileRequestsWhileZooming,this.setAnisotropicFilterPitch(r.anisotropicFilterPitch),void 0!==r.reduceMotion&&(n.prefersReducedMotion=r.reduceMotion),this._imageQueueHandle=u.addThrottleControl((()=>this.isMoving())),this._requestManager=new _(r.transformRequest),this._container=this._resolveContainer(r.container),r.maxBounds&&this.setMaxBounds(r.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),this.on("terrain",(()=>{this.painter.terrainFacilitator.depthDirty=!0,this._update(!0);})),this.once("idle",(()=>this._idleTriggered=!0)),"undefined"!=typeof window&&(this._ownerWindow.addEventListener("online",this._onWindowOnline,!1),this._setupResizeObserver()),this.handlers=new Yr(this,r),this._hash=r.hash?new Ya("string"==typeof r.hash&&r.hash||void 0).addTo(this):void 0,(null===(i=this._hash)||void 0===i?void 0:i._onHashChange())||(this.jumpTo({center:r.center,elevation:r.elevation,zoom:r.zoom,bearing:r.bearing,pitch:r.pitch,roll:r.roll}),r.bounds&&(this.resize(),this.fitBounds(r.bounds,t.e({},r.fitBoundsOptions,{duration:0}))));const c="string"==typeof r.style||!("globe"===(null===(a=null===(o=r.style)||void 0===o?void 0:o.projection)||void 0===a?void 0:a.type));this.resize(null,c),this._localIdeographFontFamily=r.localIdeographFontFamily,this._validateStyle=r.validateStyle,r.style&&this.setStyle(r.style,{localIdeographFontFamily:r.localIdeographFontFamily}),r.attributionControl&&this.addControl(new es("boolean"==typeof r.attributionControl?void 0:r.attributionControl)),r.maplibreLogo&&this.addControl(new ts,r.logoPosition),this.on("style.load",(()=>{if(c||this._resizeTransform(),this.transform.unmodified){const e=t.V(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(e);}})),this.on("data",(e=>{this._update("style"===e.dataType),this.fire(new t.n(`${e.dataType}data`,e));})),this.on("dataloading",(e=>{this.fire(new t.n(`${e.dataType}dataloading`,e));})),this.on("dataabort",(e=>{this.fire(new t.n("sourcedataabort",e));}));}_getMapId(){return this._mapId}setGlobalStateProperty(e,t){return this.style.setGlobalStateProperty(e,t),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(e,i){if(void 0===i&&(i=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!(null==e?void 0:e.onAdd))return this.fire(new t.l(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const o=e.onAdd(this);this._controls.push(e);const a=this._controlPositions[i];return i.includes("bottom")?a.insertBefore(o,a.firstChild):a.appendChild(o),this}removeControl(e){if(!(null==e?void 0:e.onRemove))return this.fire(new t.l(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(e);return i>-1&&this._controls.splice(i,1),e.onRemove(this),this}hasControl(e){return this._controls.includes(e)}coveringTiles(e){return Me(this.transform,e)}calculateCameraOptionsFromTo(e,t,i,o){return null==o&&this.terrain&&(o=this.terrain.getElevationForLngLat(i,this.transform)),super.calculateCameraOptionsFromTo(e,t,i,o)}resize(e,i=!0){if(null!==this._lostContextStyle.style)return this;this._resizeInternal(i);const o=!this._moving;return o&&(this.stop(),this.fire(new t.n("movestart",e)).fire(new t.n("move",e))),this.fire(new t.n("resize",e)),o&&this.fire(new t.n("moveend",e)),this}_resizeInternal(e=!0){const[t,i]=this._containerDimensions(),o=this._getClampedPixelRatio(t,i);if(this._resizeCanvas(t,i,o),this.painter.resize(t,i,o),this.painter.overLimit()){const e=this.painter.context.gl;this._maxCanvasSize=[e.drawingBufferWidth,e.drawingBufferHeight];const o=this._getClampedPixelRatio(t,i);this._resizeCanvas(t,i,o),this.painter.resize(t,i,o);}this._resizeTransform(e);}_resizeTransform(e=!0){var t;const[i,o]=this._containerDimensions();this.transform.resize(i,o,e),null===(t=this._requestedCameraState)||void 0===t||t.resize(i,o,e);}_getClampedPixelRatio(e,t){const{0:i,1:o}=this._maxCanvasSize,a=this.getPixelRatio(),r=e*a,s=t*a;return Math.min(r>i?i/r:1,s>o?o/s:1)*a}getPixelRatio(){var e;return null!==(e=this._overridePixelRatio)&&void 0!==e?e:devicePixelRatio}setPixelRatio(e){this._overridePixelRatio=e,this.resize();}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(e){return this.transform.setMaxBounds(G.convert(e)),this._update()}setMinZoom(e){if((e=null==e?-2:e)>=-2&&e<=this.transform.maxZoom){const i=this.transform.zoom,o=this._getTransformForUpdate();return o.setMinZoom(e),this._applyUpdatedTransform(o),this._update(),i!==this.transform.zoom&&this.fire(new t.n("zoomstart")).fire(new t.n("zoom")).fire(new t.n("zoomend")).fire(new t.n("movestart")).fire(new t.n("move")).fire(new t.n("moveend")),this}throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(e){if((e=null==e?22:e)>=this.transform.minZoom){const i=this.transform.zoom,o=this._getTransformForUpdate();return o.setMaxZoom(e),this._applyUpdatedTransform(o),this._update(),i!==this.transform.zoom&&this.fire(new t.n("zoomstart")).fire(new t.n("zoom")).fire(new t.n("zoomend")).fire(new t.n("movestart")).fire(new t.n("move")).fire(new t.n("moveend")),this}throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(e){if((e=null==e?0:e)<0)throw new Error("minPitch must be greater than or equal to 0");if(e>=0&&e<=this.transform.maxPitch){const i=this.transform.pitch,o=this._getTransformForUpdate();return o.setMinPitch(e),this._applyUpdatedTransform(o),this._update(),i!==this.transform.pitch&&this.fire(new t.n("pitchstart")).fire(new t.n("pitch")).fire(new t.n("pitchend")).fire(new t.n("movestart")).fire(new t.n("move")).fire(new t.n("moveend")),this}throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(e){if((e=null==e?60:e)>180)throw new Error("maxPitch must be less than or equal to 180");if(e>=this.transform.minPitch){const i=this.transform.pitch,o=this._getTransformForUpdate();return o.setMaxPitch(e),this._applyUpdatedTransform(o),this._update(),i!==this.transform.pitch&&this.fire(new t.n("pitchstart")).fire(new t.n("pitch")).fire(new t.n("pitchend")).fire(new t.n("movestart")).fire(new t.n("move")).fire(new t.n("moveend")),this}throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getAnisotropicFilterPitch(){return this._anisotropicFilterPitch}setAnisotropicFilterPitch(e){if((e=null==e?20:e)>180)throw new Error("anisotropicFilterPitch must be less than or equal to 180");if(e<0)throw new Error("anisotropicFilterPitch must be greater than or equal to 0");return this._anisotropicFilterPitch=e,this._update()}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.setRenderWorldCopies(e),this._update()}setTransformConstrain(e){return this.transform.setConstrainOverride(e),this._update()}project(e){return this.transform.locationToScreenPoint(t.W.convert(e),this.style&&this.terrain)}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this.terrain)}isMoving(){var e;return this._moving||(null===(e=this.handlers)||void 0===e?void 0:e.isMoving())}isZooming(){var e;return this._zooming||(null===(e=this.handlers)||void 0===e?void 0:e.isZooming())}isRotating(){var e;return this._rotating||(null===(e=this.handlers)||void 0===e?void 0:e.isRotating())}_createDelegatedListener(e,t,i){if("mouseenter"===e||"mouseover"===e){let o=!1;const a=a=>{const r=t.filter((e=>this.getLayer(e))),s=0!==r.length?this.queryRenderedFeatures(a.point,{layers:r}):[];s.length?o||(o=!0,i.call(this,new nr(e,this,a.originalEvent,{features:s}))):o=!1;};return {layers:t,listener:i,delegates:{mousemove:a,mouseout:()=>{o=!1;}}}}if("mouseleave"===e||"mouseout"===e){let o=!1;const a=a=>{const r=t.filter((e=>this.getLayer(e)));(0!==r.length?this.queryRenderedFeatures(a.point,{layers:r}):[]).length?o=!0:o&&(o=!1,i.call(this,new nr(e,this,a.originalEvent)));},r=t=>{o&&(o=!1,i.call(this,new nr(e,this,t.originalEvent)));};return {layers:t,listener:i,delegates:{mousemove:a,mouseout:r}}}{const o=e=>{const o=t.filter((e=>this.getLayer(e))),a=0!==o.length?this.queryRenderedFeatures(e.point,{layers:o}):[];a.length&&(e.features=a,i.call(this,e),delete e.features);};return {layers:t,listener:i,delegates:{[e]:o}}}}_saveDelegatedListener(e,t){var i;this._delegatedListeners||(this._delegatedListeners={}),(i=this._delegatedListeners)[e]||(i[e]=[]),this._delegatedListeners[e].push(t);}_removeDelegatedListener(e,t,i){var o;if(!(null===(o=this._delegatedListeners)||void 0===o?void 0:o[e]))return;const a=this._delegatedListeners[e];for(let e=0;e<a.length;e++){const o=a[e];if(o.listener===i&&o.layers.length===t.length&&o.layers.every((e=>t.includes(e)))){for(const e in o.delegates)this.off(e,o.delegates[e]);return void a.splice(e,1)}}}on(e,t,i){if(void 0===i)return super.on(e,t);const o="string"==typeof t?[t]:t,a=this._createDelegatedListener(e,o,i);this._saveDelegatedListener(e,a);for(const e in a.delegates)this.on(e,a.delegates[e]);return {unsubscribe:()=>{this._removeDelegatedListener(e,o,i);}}}once(e,t,i){if(void 0===i)return super.once(e,t);const o="string"==typeof t?[t]:t,a=this._createDelegatedListener(e,o,i);for(const t in a.delegates){const r=a.delegates[t];a.delegates[t]=(...t)=>{this._removeDelegatedListener(e,o,i),r(...t);};}this._saveDelegatedListener(e,a);for(const e in a.delegates)this.once(e,a.delegates[e]);return this}off(e,t,i){return void 0===i?super.off(e,t):(this._removeDelegatedListener(e,"string"==typeof t?[t]:t,i),this)}queryRenderedFeatures(e,i){if(!this.style)return [];let o;const a=e instanceof t.P||Array.isArray(e),r=a?e:[[0,0],[this.transform.width,this.transform.height]];if(i||(i=(a?{}:e)||{}),r instanceof t.P||"number"==typeof r[0])o=[t.P.convert(r)];else {const e=t.P.convert(r[0]),i=t.P.convert(r[1]);o=[e,new t.P(i.x,e.y),i,new t.P(e.x,i.y),e];}return this.style.queryRenderedFeatures(o,i,this.transform)}querySourceFeatures(e,t){return this.style.querySourceFeatures(e,t)}setStyle(e,i){return !1!==(i=t.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},i)).diff&&i.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&e?(this._diffStyle(e,i),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._updateStyle(e,i))}setTransformRequest(e){return this._requestManager.setTransformRequest(e),this}_getUIString(e){const t=this._locale[e];if(null==t)throw new Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){var i,o,a;if(null===(i=this._diffStyleRequest)||void 0===i||i.abort(),this._diffStyleRequest=null,t.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",(()=>this._updateStyle(e,t)));const r=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!e)),e?(this.style=new ki(this,t||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof e?this.style.loadURL(e,t,r):this.style.loadJSON(e,t,r),this):(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),null===(a=null===(o=this.style)||void 0===o?void 0:o.projection)||void 0===a||a.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new ki(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty());}_diffStyle(e,i){return t._(this,void 0,void 0,(function*(){var o;if(null===(o=this._diffStyleRequest)||void 0===o||o.abort(),"string"==typeof e){const o=e;this._diffStyleRequest=new AbortController;const a=this._diffStyleRequest;try{const e=yield this._requestManager.transformRequest(o,"Style");if(a.signal.aborted)return void(this._diffStyleRequest=null);const r=yield t.k(e,a);this._diffStyleRequest=null,this._updateDiff(r.data,i);}catch(e){this._diffStyleRequest=null,t.$(e)||this.fire(new t.l(t.d(e)));}}else "object"==typeof e&&(this._diffStyleRequest=null,this._updateDiff(e,i));}))}_updateDiff(e,i){try{this.style.setState(e,i)&&this._update(!0);}catch(o){t.w(`Unable to perform style diff: ${t.d(o).message}. Rebuilding the style from scratch.`),this._updateStyle(e,i);}}getStyle(){if(this.style)return this.style.serialize()}_getStyleAndImages(){return this.style?{style:this.style.serialize(),images:this.style.imageManager.cloneImages()}:{style:null,images:{}}}isStyleLoaded(){if(this.style)return this.style.loaded();t.w("There is no style added to the map.");}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){var i;const o=null===(i=this.style)||void 0===i?void 0:i.tileManagers[e];if(void 0!==o)return o.loaded();this.fire(new t.l(new Error(`There is no tile manager with ID '${e}'`)));}setTerrain(e){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),e){const i=this.style.tileManagers[e.source];if(!i)throw new Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);null===this.terrain&&i.reload();for(const i in this.style._layers){const o=this.style._layers[i];"hillshade"===o.type&&o.source===e.source&&t.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality."),"color-relief"===o.type&&o.source===e.source&&t.w("You are using the same source for a color-relief layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.");}this.terrain=new rs(this.painter,i,e),this.painter.renderToTexture=new ls(this.painter,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._terrainDataCallback=t=>{var i;"style"===t.dataType?this.terrain.tileManager.freeRtt():"source"===t.dataType&&t.tile&&(t.sourceId!==e.source||this._elevationFreeze||(this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))),"image"===(null===(i=t.source)||void 0===i?void 0:i.type)?this.terrain.tileManager.freeRtt():this.terrain.tileManager.freeRtt(t.tile.tileID));},this.style.on("data",this._terrainDataCallback);}else this.terrain&&this.terrain.destroy(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0);return this.fire(new t.n("terrain",{terrain:e})),this}getTerrain(){var e,t;return null!==(t=null===(e=this.terrain)||void 0===e?void 0:e.options)&&void 0!==t?t:null}areTilesLoaded(){var e;const t=null===(e=this.style)||void 0===e?void 0:e.tileManagers;for(const e of Object.values(t))if(!e.areTilesLoaded())return !1;return !0}removeSource(e){return this.style.removeSource(e),this._update(!0)}getSource(e){return this.style.getSource(e)}setSourceTileLodParams(e,t,i){if(i){const o=this.getSource(i);if(!o)throw new Error(`There is no source with ID "${i}", cannot set LOD parameters`);o.calculateTileZoom=Te(Math.max(1,e),Math.max(1,t));}else for(const i in this.style.tileManagers)this.style.tileManagers[i].getSource().calculateTileZoom=Te(Math.max(1,e),Math.max(1,t));return this._update(!0),this}refreshTiles(e,i){const o=this.style.tileManagers[e];if(!o)throw new Error(`There is no tile manager with ID "${e}", cannot refresh tile`);void 0===i?o.reload(!0):o.refreshTiles(i.map((e=>new t.aa(e.z,e.x,e.y))));}addImage(e,i,o={}){const{pixelRatio:a=1,sdf:r=!1,stretchX:s,stretchY:l,content:c,textFitWidth:h,textFitHeight:u}=o;if(this._lazyInitEmptyStyle(),!(i instanceof HTMLImageElement||t.b(i))){if(void 0===i.width||void 0===i.height)return this.fire(new t.l(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:o,height:n,data:d}=i,_=i;return this.style.addImage(e,{data:new t.R({width:o,height:n},new Uint8Array(d)),pixelRatio:a,stretchX:s,stretchY:l,content:c,textFitWidth:h,textFitHeight:u,sdf:r,version:0,userImage:_}),_.onAdd&&_.onAdd(this,e),this}}{const{width:o,height:d,data:_}=n.getImageData(i);this.style.addImage(e,{data:new t.R({width:o,height:d},_),pixelRatio:a,stretchX:s,stretchY:l,content:c,textFitWidth:h,textFitHeight:u,sdf:r,version:0});}}updateImage(e,i){const o=this.style.getImage(e);if(!o)return this.fire(new t.l(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const a=i instanceof HTMLImageElement||t.b(i)?n.getImageData(i):i,{width:r,height:s,data:l}=a;if(void 0===r||void 0===s)return this.fire(new t.l(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(r!==o.data.width||s!==o.data.height)return this.fire(new t.l(new Error("The width and height of the updated image must be that same as the previous version of the image")));const c=!(i instanceof HTMLImageElement||t.b(i));return o.data.replace(l,c),this.style.updateImage(e,o),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new t.l(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e);}loadImage(e){return t._(this,void 0,void 0,(function*(){return u.getImage(yield this._requestManager.transformRequest(e,"Image"),new AbortController)}))}listImages(){return this.style.listImages()}addLayer(e,t){return this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)}moveLayer(e,t){return this.style.moveLayer(e,t),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style.getLayer(e)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(e,t,i){return this.style.setLayerZoomRange(e,t,i),this._update(!0)}setFilter(e,t,i={}){return this.style.setFilter(e,t,i),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,i,o={}){return this.style.setPaintProperty(e,t,i,o),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,i,o={}){return this.style.setLayoutProperty(e,t,i,o),this._update(!0)}getLayoutProperty(e,t){return this.style.getLayoutProperty(e,t)}setGlyphs(e,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(e,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(e,t,i={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,t,i,(e=>{e||this._update(!0);})),this}removeSprite(e){return this._lazyInitEmptyStyle(),this.style.removeSprite(e),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(e,t,(e=>{e||this._update(!0);})),this}setLight(e,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,t),this._update(!0)}getLight(){return this.style.getLight()}setSky(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSky(e,t),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(e,t){return this.style.setFeatureState(e,t),this._update()}removeFeatureState(e,t){return this.style.removeFeatureState(e,t),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let e=0,t=0;return this._container&&(e=this._container.clientWidth||400,t=this._container.clientHeight||300),[e,t]}_setupResizeObserver(){var e;let t=!1;const i=Ka((e=>{this._trackResize&&!this._removed&&(this.resize(e),this.redraw());}),50),o=null!==(e=this._ownerWindow.ResizeObserver)&&void 0!==e?e:ResizeObserver;this._resizeObserver=new o((e=>{t?i(e):t=!0;})),this._resizeObserver.observe(this._container);}_resolveContainer(e){if("string"==typeof e){const t=document.getElementById(e);if(!t)throw new Error(`Container '${e}' not found.`);return t}if(e instanceof HTMLElement)return e;if(e&&"object"==typeof e&&1===e.nodeType)return e;throw new Error("Invalid type: 'container' must be a String or HTMLElement.")}_setupContainer(){const e=this._container;e.classList.add("maplibregl-map");const t=this._canvasContainer=d.create("div","maplibregl-canvas-container",e);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=d.create("canvas","maplibregl-canvas",t),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const i=this._containerDimensions(),o=this._getClampedPixelRatio(i[0],i[1]);this._resizeCanvas(i[0],i[1],o);const a=this._controlContainer=d.create("div","maplibregl-control-container",e),r=this._controlPositions={};for(const e of ["top-left","top-right","bottom-left","bottom-right"])r[e]=d.create("div",`maplibregl-ctrl-${e} `,a);this._container.addEventListener("scroll",this._onMapScroll,!1);}_resizeCanvas(e,t,i){this._canvas.width=Math.floor(i*e),this._canvas.height=Math.floor(i*t),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`;}_setupPainter(){const e=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let t=null;this._canvas.addEventListener("webglcontextcreationerror",(i=>{t={requestedAttributes:e},i&&(t.statusMessage=i.statusMessage,t.type=i.type);}),{once:!0});let i=null;if(i=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,e):this._canvas.getContext("webgl2",e)||this._canvas.getContext("webgl",e),!i){const e="Failed to initialize WebGL";throw t?(t.message=e,new Error(JSON.stringify(t))):new Error(e)}this.painter=new Xa(i,this.transform);}migrateProjection(e,i){super.migrateProjection(e,i),this.painter.transform=e,this.fire(new t.n("projectiontransition",{newProjection:this.style.projection.name}));}loaded(){return !this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){var t;return (null===(t=this.style)||void 0===t?void 0:t._loaded)?(this._styleDirty||(this._styleDirty=e),this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e);}_render(e){var i,o,a,r,s,n;const l=this._idleTriggered?this._fadeDuration:0,h=(null===(i=this.style.projection)||void 0===i?void 0:i.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let u=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,i=c();this.style.zoomHistory.update(e,i);const o=new t.J(e,{now:i,fadeDuration:l,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),a=o.crossFadingFactor();1===a&&a===this._crossFadingFactor||(u=!0,this._crossFadingFactor=a),this.style.update(o);}const d=(null===(o=this.style.projection)||void 0===o?void 0:o.transitionState)>0!==h;null===(a=this.style.projection)||void 0===a||a.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState(null===(r=this.style.projection)||void 0===r?void 0:r.transitionState,null===(s=this.style.projection)||void 0===s?void 0:s.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||d)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.tileManager.update(this.transform,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),!this._elevationFreeze&&this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0)),this._placementDirty=null===(n=this.style)||void 0===n?void 0:n._updatePlacement(this.transform,this.showCollisionBoxes,l,this._crossSourceCollisions,d),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:l,showPadding:this.showPadding,anisotropicFilterPitch:this.getAnisotropicFilterPitch()}),this.fire(new t.n("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new t.n("load"))),this.style&&(this.style.hasTransitions()||u)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const _=this._sourcesDirty||this._styleDirty||this._placementDirty;return _||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new t.n("idle")),!this._loaded||this._fullyLoaded||_||(this._fullyLoaded=!0),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var e,i;this._hash&&this._hash.remove();for(const e of this._controls)e.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),null===(e=this._diffStyleRequest)||void 0===e||e.abort(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),"undefined"!=typeof window&&this._ownerWindow.removeEventListener("online",this._onWindowOnline,!1),u.removeThrottleControl(this._imageQueueHandle),null===(i=this._resizeObserver)||void 0===i||i.disconnect();const o=this.painter.context.gl.getExtension("WEBGL_lose_context");(null==o?void 0:o.loseContext)&&o.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),this._canvasContainer.remove(),this._controlContainer.remove(),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),this._removed=!0,this.fire(new t.n("remove"));}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,n.frame(this._frameRequest,(e=>{this._frameRequest=null;try{this._render(e);}catch(e){if(!t.$(e)&&!function(e){return e.message===na}(e))throw e}}),(()=>{}),this._ownerWindow));}get showTileBoundaries(){return !!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update());}get showPadding(){return !!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update());}get showCollisionBoxes(){return !!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update());}get showOverdrawInspector(){return !!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update());}get repaint(){return !!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint());}get vertices(){return !!this._vertices}set vertices(e){this._vertices=e,this._update();}get version(){return hs}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}};const _s={showCompass:!0,showZoom:!0,visualizePitch:!1,visualizeRoll:!0};class ps{constructor(e,i,o=!1){this.mousedown=e=>{this.startMove(e,d.mousePos(this.element,e)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup);},this.mousemove=e=>{this.move(e,d.mousePos(this.element,e));},this.mouseup=e=>{this._rotatePitchHandler.dragEnd(e),this.offTemp();},this.touchstart=e=>{1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=d.touchPos(this.element,e.targetTouches)[0],this.startMove(e,this._startPos),window.addEventListener("touchmove",this.touchmove,{passive:!1}),window.addEventListener("touchend",this.touchend));},this.touchmove=e=>{1!==e.targetTouches.length?this.reset():(this._lastPos=d.touchPos(this.element,e.targetTouches)[0],this.move(e,this._lastPos));},this.touchend=e=>{0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),delete this._startPos,delete this._lastPos,this.offTemp();},this.reset=()=>{this._rotatePitchHandler.reset(),delete this._startPos,delete this._lastPos,this.offTemp();},this._clickTolerance=10,this.element=i;const a=new Pr;this._rotatePitchHandler=new vr({clickTolerance:3,move:(e,a)=>{const r=i.getBoundingClientRect(),s=new t.P((r.bottom-r.top)/2,(r.right-r.left)/2);return {bearingDelta:t.cx(new t.P(e.x,a.y),a,s),pitchDelta:o?-.5*(a.y-e.y):void 0}},moveStateManager:a,enable:!0,assignEvents:()=>{}}),this.map=e,i.addEventListener("mousedown",this.mousedown),i.addEventListener("touchstart",this.touchstart,{passive:!1}),i.addEventListener("touchcancel",this.reset);}startMove(e,t){this._rotatePitchHandler.dragStart(e,t),d.disableDrag();}move(e,t){const i=this.map,{bearingDelta:o,pitchDelta:a}=this._rotatePitchHandler.dragMove(e,t)||{};o&&i.setBearing(i.getBearing()+o),a&&i.setPitch(i.getPitch()+a);}off(){const e=this.element;e.removeEventListener("mousedown",this.mousedown),e.removeEventListener("touchstart",this.touchstart),window.removeEventListener("touchmove",this.touchmove),window.removeEventListener("touchend",this.touchend),e.removeEventListener("touchcancel",this.reset),this.offTemp();}offTemp(){d.enableDrag(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup),window.removeEventListener("touchmove",this.touchmove),window.removeEventListener("touchend",this.touchend);}}let ms;function fs(e,i,o,a=!1){if(a||!o.getCoveringTilesDetailsProvider().allowWorldCopies())return null==e?void 0:e.wrap();const r=new t.W(e.lng,e.lat);if(e=new t.W(e.lng,e.lat),i){const a=new t.W(e.lng-360,e.lat),r=new t.W(e.lng+360,e.lat),s=o.locationToScreenPoint(e).distSqr(i);o.locationToScreenPoint(a).distSqr(i)<s?e=a:o.locationToScreenPoint(r).distSqr(i)<s&&(e=r);}for(;Math.abs(e.lng-o.center.lng)>180;){const t=o.locationToScreenPoint(e);if(t.x>=0&&t.y>=0&&t.x<=o.width&&t.y<=o.height)break;e.lng>o.center.lng?e.lng-=360:e.lng+=360;}return e.lng!==r.lng&&o.isPointOnMapSurface(o.locationToScreenPoint(e))?e:r}const gs={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function vs(e,t,i){const o=e.classList;for(const e in gs)o.remove(`maplibregl-${i}-anchor-${e}`);o.add(`maplibregl-${i}-anchor-${t}`);}class xs extends t.E{constructor(e){if(super(),this._onClick=e=>{this.fire(new t.n("click",{originalEvent:e}));},this._onKeyPress=e=>{"Space"!==e.code&&"Enter"!==e.code||this.togglePopup();},this._onMapClick=e=>{const t=e.originalEvent.target,i=this._element;this._popup&&(t===i||i.contains(t))&&this.togglePopup();},this._update=e=>{if(!this._map)return;const t=this._map.loaded()&&!this._map.isMoving();("terrain"===(null==e?void 0:e.type)||"render"===(null==e?void 0:e.type)&&!t)&&this._map.once("render",this._update),this._lngLat=fs(this._lngLat,this._flatPos,this._map.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let i="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?i=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(i=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let o="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?o="rotateX(0deg)":"map"===this._pitchAlignment&&(o=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||e&&"moveend"!==e.type||(this._pos=this._pos.round()),this._element.style.transform=`${gs[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${o} ${i}`,n.frameAsync(new AbortController,this._map._ownerWindow).then((()=>{this._updateOpacity("moveend"===(null==e?void 0:e.type));})).catch((()=>{}));},this._onMove=e=>{if(!this._isDragging){const t=this._clickTolerance||this._map._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=t;}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new t.n("dragstart"))),this.fire(new t.n("drag")));},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new t.n("dragend")),this._state="inactive";},this._addDragHandler=e=>{this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(this._pos).add(this._offset),this._pointerdownPos=e.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp));},this._anchor=(null==e?void 0:e.anchor)||"center",this._color=(null==e?void 0:e.color)||"#3FB1CE",this._scale=(null==e?void 0:e.scale)||1,this._draggable=(null==e?void 0:e.draggable)||!1,this._clickTolerance=(null==e?void 0:e.clickTolerance)||0,this._subpixelPositioning=(null==e?void 0:e.subpixelPositioning)||!1,this._isDragging=!1,this._state="inactive",this._rotation=(null==e?void 0:e.rotation)||0,this._rotationAlignment=(null==e?void 0:e.rotationAlignment)||"auto",this._pitchAlignment=(null==e?void 0:e.pitchAlignment)&&"auto"!==e.pitchAlignment?e.pitchAlignment:this._rotationAlignment,this.setOpacity(null==e?void 0:e.opacity,null==e?void 0:e.opacityWhenCovered),null==e?void 0:e.element)this._element=e.element,this._offset=t.P.convert((null==e?void 0:e.offset)||[0,0]);else {this._defaultMarker=!0,this._element=d.create("div");const i=d.createNS("http://www.w3.org/2000/svg","svg"),o=41,a=27;i.setAttributeNS(null,"display","block"),i.setAttributeNS(null,"height",`${o}px`),i.setAttributeNS(null,"width",`${a}px`),i.setAttributeNS(null,"viewBox",`0 0 ${a} ${o}`);const r=d.createNS("http://www.w3.org/2000/svg","g");r.setAttributeNS(null,"stroke","none"),r.setAttributeNS(null,"stroke-width","1"),r.setAttributeNS(null,"fill","none"),r.setAttributeNS(null,"fill-rule","evenodd");const s=d.createNS("http://www.w3.org/2000/svg","g");s.setAttributeNS(null,"fill-rule","nonzero");const n=d.createNS("http://www.w3.org/2000/svg","g");n.setAttributeNS(null,"transform","translate(3.0, 29.0)"),n.setAttributeNS(null,"fill","#000000");const l=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const e of l){const t=d.createNS("http://www.w3.org/2000/svg","ellipse");t.setAttributeNS(null,"opacity","0.04"),t.setAttributeNS(null,"cx","10.5"),t.setAttributeNS(null,"cy","5.80029008"),t.setAttributeNS(null,"rx",e.rx),t.setAttributeNS(null,"ry",e.ry),n.appendChild(t);}const c=d.createNS("http://www.w3.org/2000/svg","g");c.setAttributeNS(null,"fill",this._color);const h=d.createNS("http://www.w3.org/2000/svg","path");h.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),c.appendChild(h);const u=d.createNS("http://www.w3.org/2000/svg","g");u.setAttributeNS(null,"opacity","0.25"),u.setAttributeNS(null,"fill","#000000");const _=d.createNS("http://www.w3.org/2000/svg","path");_.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),u.appendChild(_);const p=d.createNS("http://www.w3.org/2000/svg","g");p.setAttributeNS(null,"transform","translate(6.0, 7.0)"),p.setAttributeNS(null,"fill","#FFFFFF");const m=d.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"transform","translate(8.0, 8.0)");const f=d.createNS("http://www.w3.org/2000/svg","circle");f.setAttributeNS(null,"fill","#000000"),f.setAttributeNS(null,"opacity","0.25"),f.setAttributeNS(null,"cx","5.5"),f.setAttributeNS(null,"cy","5.5"),f.setAttributeNS(null,"r","5.4999962");const g=d.createNS("http://www.w3.org/2000/svg","circle");g.setAttributeNS(null,"fill","#FFFFFF"),g.setAttributeNS(null,"cx","5.5"),g.setAttributeNS(null,"cy","5.5"),g.setAttributeNS(null,"r","5.4999962"),m.appendChild(f),m.appendChild(g),s.appendChild(n),s.appendChild(c),s.appendChild(u),s.appendChild(p),s.appendChild(m),i.appendChild(s),i.setAttributeNS(null,"height",o*this._scale+"px"),i.setAttributeNS(null,"width",a*this._scale+"px"),this._element.appendChild(i),this._offset=t.P.convert((null==e?void 0:e.offset)||[0,-14]);}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",(e=>{e.preventDefault();})),this._element.addEventListener("mousedown",(e=>{e.preventDefault();})),vs(this._element,this._anchor,"marker"),null==e?void 0:e.className)for(const t of e.className.split(" "))this._element.classList.add(t);this._popup=null;}addTo(e){return this.remove(),this._map=e,this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),this._element.hasAttribute("role")||this._element.setAttribute("role","button"),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",this._update),e.on("projectiontransition",this._update),this._element.addEventListener("click",this._onClick),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),this._element.removeEventListener("click",this._onClick),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.W.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){const t=38.1,i=13.5,o=Math.abs(i)/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[o,-1*(t-i+o)],"bottom-right":[-o,-1*(t-i+o)],left:[i,-1*(t-i)],right:[-i,-1*(t-i)]}:this._offset;}this._popup=e,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress);}return this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}getPopup(){return this._popup}togglePopup(){const e=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:e?(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map)),this):this}_updateOpacity(e=!1){var i,o;const a=null===(i=this._map)||void 0===i?void 0:i.terrain,r=this._map.transform.isLocationOccluded(this._lngLat);if(!a||r){const e=r?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==e&&(this._element.style.opacity=e,this._element.classList.toggle("maplibregl-marker-covered",r)))}if(e)this._opacityTimeout=null;else {if(this._opacityTimeout)return;this._opacityTimeout=setTimeout((()=>{this._opacityTimeout=null;}),100);}const s=this._map,n=s.terrain.depthAtPoint(this._pos),l=s.terrain.getElevationForLngLat(this._lngLat,s.transform);if(s.transform.lngLatToCameraDepth(this._lngLat,l)-n<.006)return this._element.style.opacity=this._opacity,void this._element.classList.remove("maplibregl-marker-covered");const c=-this._offset.y/s.transform.pixelsPerMeter,h=Math.sin(s.getPitch()*Math.PI/180)*c,u=s.terrain.depthAtPoint(new t.P(this._pos.x,this._pos.y-this._offset.y)),d=s.transform.lngLatToCameraDepth(this._lngLat,l+h)-u>.006;(null===(o=this._popup)||void 0===o?void 0:o.isOpen())&&d&&this._popup.remove(),this._element.style.opacity=d?this._opacityWhenCovered:this._opacity,this._element.classList.toggle("maplibregl-marker-covered",d);}getOffset(){return this._offset}setOffset(e){return this._offset=t.P.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e);}removeClassName(e){this._element.classList.remove(e);}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._map&&(e?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&"auto"!==e?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,t){return (void 0===this._opacity||void 0===e&&void 0===t)&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==e&&(this._opacity=String(e)),void 0!==t&&(this._opacityWhenCovered=String(t)),this._map&&this._updateOpacity(!0),this}}const bs={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let ys=0,ws=!1;const Ts={maxWidth:100,unit:"metric"};function Ps(e,t,i){const o=(null==i?void 0:i.maxWidth)||100,a=e._container.clientHeight/2,r=e._container.clientWidth/2,s=e.unproject([r-o/2,a]),n=e.unproject([r+o/2,a]),l=Math.round(e.project(n).x-e.project(s).x),c=Math.min(o,l,e._container.clientWidth),h=s.distanceTo(n);if("imperial"===(null==i?void 0:i.unit)){const i=3.2808*h;i>5280?Cs(t,c,i/5280,e._getUIString("ScaleControl.Miles")):Cs(t,c,i,e._getUIString("ScaleControl.Feet"));}else "nautical"===(null==i?void 0:i.unit)?Cs(t,c,h/1852,e._getUIString("ScaleControl.NauticalMiles")):h>=1e3?Cs(t,c,h/1e3,e._getUIString("ScaleControl.Kilometers")):Cs(t,c,h,e._getUIString("ScaleControl.Meters"));}function Cs(e,t,i,o){const a=function(e){const t=Math.pow(10,`${Math.floor(e)}`.length-1);let i=e/t;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t}(i),t*i}(i);e.style.width=t*(a/i)+"px",e.innerHTML=`${a} ${o}`;}const Ms={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0,padding:void 0},Is=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Es(e){if(e){if("number"==typeof e){const i=Math.round(Math.abs(e)/Math.SQRT2);return {center:new t.P(0,0),top:new t.P(0,e),"top-left":new t.P(i,i),"top-right":new t.P(-i,i),bottom:new t.P(0,-e),"bottom-left":new t.P(i,-i),"bottom-right":new t.P(-i,-i),left:new t.P(e,0),right:new t.P(-e,0)}}if(e instanceof t.P||Array.isArray(e)){const i=t.P.convert(e);return {center:i,top:i,"top-left":i,"top-right":i,bottom:i,"bottom-left":i,"bottom-right":i,left:i,right:i}}return {center:t.P.convert(e.center||[0,0]),top:t.P.convert(e.top||[0,0]),"top-left":t.P.convert(e["top-left"]||[0,0]),"top-right":t.P.convert(e["top-right"]||[0,0]),bottom:t.P.convert(e.bottom||[0,0]),"bottom-left":t.P.convert(e["bottom-left"]||[0,0]),"bottom-right":t.P.convert(e["bottom-right"]||[0,0]),left:t.P.convert(e.left||[0,0]),right:t.P.convert(e.right||[0,0])}}return Es(new t.P(0,0))}const Ss=i;e.AJAXError=t.cG,e.EXTENT=t.a6,e.Event=t.n,e.Evented=t.E,e.LngLat=t.W,e.MercatorCoordinate=t.a7,e.Point=t.P,e.addProtocol=t.cH,e.config=t.c,e.removeProtocol=t.cI,e.AttributionControl=es,e.BoxZoomHandler=_r,e.CanvasSource=oe,e.CooperativeGesturesHandler=$r,e.DoubleClickZoomHandler=Zr,e.DragPanHandler=Vr,e.DragRotateHandler=Wr,e.EdgeInsets=Ut,e.FullscreenControl=class extends t.E{constructor(e={}){var i;super(),this._onFullscreenChange=()=>{var e;let t=window.document.fullscreenElement||window.document.webkitFullscreenElement;for(;null===(e=null==t?void 0:t.shadowRoot)||void 0===e?void 0:e.fullscreenElement;)t=t.shadowRoot.fullscreenElement;t===this._container!==this._fullscreen&&this._handleFullscreenChange();},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen();},this._fullscreen=!1,this._pseudo=null!==(i=e.pseudo)&&void 0!==i&&i,(null==e?void 0:e.container)&&(e.container instanceof HTMLElement?this._container=e.container:t.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange");}onAdd(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=d.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange);}_setupUI(){const e=this._fullscreenButton=d.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);d.create("span","maplibregl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange);}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.title=e;}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new t.n("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new t.n("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable());}_exitFullscreen(){this._pseudo?this._togglePseudoFullScreen():window.document.exitFullscreen?window.document.exitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen();}_requestFullscreen(){this._pseudo?this._togglePseudoFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen();}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize();}},e.GeoJSONSource=ee,e.GeolocateControl=class extends t.E{constructor(e){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new t.n("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case "WAITING_ACTIVE":case "ACTIVE_LOCK":case "ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case "BACKGROUND":case "BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new t.n("geolocate",e)),this._finish();}},this._updateCamera=e=>{const i=new t.W(e.coords.longitude,e.coords.latitude),o=e.coords.accuracy,a=this._map.getBearing(),r=t.e({bearing:a},this.options.fitBoundsOptions),s=G.fromLngLat(i,o);this._map.fitBounds(s,r,{geolocateSource:!0});},this._updateMarker=e=>{if(e){const i=new t.W(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=e.coords.accuracy,this._updateCircleRadiusIfNeeded();}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove();},this._onUpdate=()=>{this._updateCircleRadiusIfNeeded();},this._onError=e=>{if(this._map){if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e),void 0!==this._geolocationWatchID&&this._clearWatch();}else {if(3===e.code&&ws)return;this._setErrorState();}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new t.n("error",e)),this._finish();}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0;},this._onMoveStart=e=>{if(!this._map)return;const i=(null==e?void 0:e[0])instanceof ResizeObserverEntry;e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||i||this._map.isZooming()||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new t.n("trackuserlocationend")),this.fire(new t.n("userlocationlostfocus")));},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",(e=>{e.preventDefault();})),this._geolocateButton=d.create("button","maplibregl-ctrl-geolocate",this._container),d.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0);},this._finishSetupUI=e=>{if(this._map){if(!1===e){t.w("Geolocation support is not available so the GeolocateControl will be disabled.");const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e);}else {const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e);}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=d.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new xs({element:this._dotElement}),this._circleElement=d.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new xs({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onUpdate),this._map.on("move",this._onUpdate),this._map.on("rotate",this._onUpdate),this._map.on("pitch",this._onUpdate)),this._geolocateButton.addEventListener("click",(()=>this.trigger())),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",this._onMoveStart);}},this.options=t.e({},bs,e);}onAdd(e){return this._map=e,this._container=d.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return t._(this,arguments,void 0,(function*(e=!1){if(void 0!==ms&&!e)return ms;if(void 0===window.navigator.permissions)return ms=!!window.navigator.geolocation,ms;try{const e=yield window.navigator.permissions.query({name:"geolocation"});ms="denied"!==e.state;}catch(e){ms=!!window.navigator.geolocation;}return ms}))}().then((e=>this._finishSetupUI(e))),this._container}onRemove(){void 0!==this._geolocationWatchID&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("movestart",this._onMoveStart),this._map.off("zoom",this._onUpdate),this._map.off("move",this._onUpdate),this._map.off("rotate",this._onUpdate),this._map.off("pitch",this._onUpdate),this._map=void 0,ys=0,ws=!1;}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),i=e.coords;return t&&(i.longitude<t.getWest()||i.longitude>t.getEast()||i.latitude<t.getSouth()||i.latitude>t.getNorth())}_setErrorState(){switch(this._watchState){case "WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case "ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case "BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case "ACTIVE_ERROR":case "BACKGROUND_ERROR":case "OFF":case void 0:break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadiusIfNeeded(){const e=this._userLocationDotMarker.getLngLat();if(!(this.options.showUserLocation&&this.options.showAccuracyCircle&&this._accuracy&&e))return;const t=this._map.project(e),i=this._map.unproject([t.x+100,t.y]),o=e.distanceTo(i)/100,a=2*this._accuracy/o;this._circleElement.style.width=`${a.toFixed(2)}px`,this._circleElement.style.height=`${a.toFixed(2)}px`;}trigger(){if(!this._setup)return t.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case "OFF":this._watchState="WAITING_ACTIVE",this.fire(new t.n("trackuserlocationstart"));break;case "WAITING_ACTIVE":case "ACTIVE_LOCK":case "ACTIVE_ERROR":case "BACKGROUND_ERROR":ys--,ws=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new t.n("trackuserlocationend"));break;case "BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new t.n("trackuserlocationstart")),this.fire(new t.n("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case "WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case "ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case "OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),ys++,ys>1?(e={maximumAge:6e5,timeout:0},ws=!0):(e=this.options.positionOptions,ws=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,e);}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return !0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null);}},e.GlobeControl=class{constructor(){this._toggleProjection=()=>{var e;const t=null===(e=this._map.getProjection())||void 0===e?void 0:e.type;this._map.setProjection("mercator"!==t&&t?{type:"mercator"}:{type:"globe"}),this._updateGlobeIcon();},this._updateGlobeIcon=()=>{var e;this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),"globe"===(null===(e=this._map.getProjection())||void 0===e?void 0:e.type)?(this._globeButton.classList.add("maplibregl-ctrl-globe-enabled"),this._globeButton.title=this._map._getUIString("GlobeControl.Disable")):(this._globeButton.classList.add("maplibregl-ctrl-globe"),this._globeButton.title=this._map._getUIString("GlobeControl.Enable"));};}onAdd(e){return this._map=e,this._container=d.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=d.create("button","maplibregl-ctrl-globe",this._container),d.create("span","maplibregl-ctrl-icon",this._globeButton).setAttribute("aria-hidden","true"),this._globeButton.type="button",this._globeButton.addEventListener("click",this._toggleProjection),this._updateGlobeIcon(),this._map.on("styledata",this._updateGlobeIcon),this._map.on("projectiontransition",this._updateGlobeIcon),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateGlobeIcon),this._map.off("projectiontransition",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0;}},e.Hash=Ya,e.ImageSource=te,e.KeyboardHandler=kr,e.LngLatBounds=G,e.LogoControl=ts,e.Map=ds,e.MapLibreMap=ds,e.MapMouseEvent=nr,e.MapTouchEvent=lr,e.MapWheelEvent=cr,e.Marker=xs,e.NavigationControl=class{constructor(e){this._updateZoomButtons=()=>{const e=this._map.getZoom(),t=e===this._map.getMaxZoom(),i=e===this._map.getMinZoom();this._zoomInButton.disabled=t,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",t.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString());},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`;},this._setButtonTitle=(e,t)=>{const i=this._map._getUIString(`NavigationControl.${t}`);e.title=i,e.setAttribute("aria-label",i);},this.options=t.e({},_s,e),this._container=d.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",(e=>this._map.zoomIn({},{originalEvent:e}))),d.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",(e=>this._map.zoomOut({},{originalEvent:e}))),d.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",(e=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e});})),this._compassIcon=d.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"));}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new ps(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){this._container.remove(),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map;}_createButton(e,t){const i=d.create("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}},e.Popup=class extends t.E{constructor(e){super(),this._updateOpacity=()=>{void 0!==this.options.locationOccludedOpacity&&(this._container.style.opacity=this._map.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:"");},this.remove=()=>(this._content&&this._content.remove(),this._container&&(this._container.remove(),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousemove",this._update),this._map.off("mouseup",this._update),this._map.off("drag",this._update),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new t.n("close"))),this),this._update=e=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=d.create("div","maplibregl-popup",this._map.getContainer()),this._tip=d.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const e of this.options.className.split(" "))this._container.classList.add(e);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer");}let t;if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=fs(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),e&&"point"in e&&e.point&&(t=e.point),this._trackPointer&&!t)return;const i=this._flatPos=this._pos=this._trackPointer&&t?t:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&t?t:this._map.transform.locationToScreenPoint(this._lngLat));let o=this.options.anchor;const a=Es(this.options.offset);if(!o){const e=this._container.offsetWidth,t=this._container.offsetHeight,r=function(e){var t,i,o,a;return e?{top:null!==(t=e.top)&&void 0!==t?t:0,right:null!==(i=e.right)&&void 0!==i?i:0,bottom:null!==(o=e.bottom)&&void 0!==o?o:0,left:null!==(a=e.left)&&void 0!==a?a:0}:{top:0,right:0,bottom:0,left:0}}(this.options.padding);let s;s=i.y+a.bottom.y<t+r.top?["top"]:i.y>this._map.transform.height-t-r.bottom?["bottom"]:[],i.x<e/2+r.left?s.push("left"):i.x>this._map.transform.width-e/2-r.right&&s.push("right"),o=0===s.length?"bottom":s.join("-");}let r=i.add(a[o]);this.options.subpixelPositioning||(r=r.round()),this._container.style.transform=`${gs[o]} translate(${r.x}px,${r.y}px)`,vs(this._container,o,"popup"),this._updateOpacity();},this._onClose=()=>{this.remove();},this.options=t.e(Object.create(Ms),e);}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._map.on("terrain",this._update),this._map.on("projectiontransition",this._update),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._update),this._map.on("mouseup",this._update),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new t.n("open")),this}isOpen(){return !!this._map}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.W.convert(e),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._update),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._update),this._map.on("drag",this._update),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){const t=document.createDocumentFragment(),i=document.createElement("body");let o;for(i.innerHTML=e;o=i.firstChild,o;)t.appendChild(o);return this.setDOMContent(t)}getMaxWidth(){var e;return null===(e=this._container)||void 0===e?void 0:e.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=d.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(e),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(e){return this._container&&this._container.classList.add(e),this}removeClassName(e){return this._container&&this._container.classList.remove(e),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){if(this._container)return this._container.classList.toggle(e)}setSubpixelPositioning(e){this.options.subpixelPositioning=e;}setPadding(e){this.options.padding=e,this._update();}_createCloseButton(){this.options.closeButton&&(this._closeButton=d.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose));}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(Is);e&&e.focus();}},e.RasterDEMTileSource=$,e.RasterTileSource=q,e.ScaleControl=class{constructor(e){this._onMove=()=>{Ps(this._map,this._container,this.options);},this.setUnit=e=>{this.options.unit=e,Ps(this._map,this._container,this.options);},this.options=Object.assign(Object.assign({},Ts),e);}getDefaultPosition(){return "bottom-left"}onAdd(e){return this._map=e,this._container=d.create("div","maplibregl-ctrl maplibregl-ctrl-scale",e.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._onMove),this._map=void 0;}},e.ScrollZoomHandler=Nr,e.Style=ki,e.TerrainControl=class{constructor(e){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon();},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"));},this.options=e;}onAdd(e){return this._map=e,this._container=d.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=d.create("button","maplibregl-ctrl-terrain",this._container),d.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){this._container.remove(),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0;}},e.TwoFingersTouchPitchHandler=Lr,e.TwoFingersTouchRotateHandler=Dr,e.TwoFingersTouchZoomHandler=zr,e.TwoFingersTouchZoomRotateHandler=qr,e.VectorTileSource=W,e.VideoSource=ie,e.addSourceType=(e,i)=>t._(void 0,void 0,void 0,(function*(){if(re(e))throw new Error(`A source type called "${e}" already exists.`);((e,t)=>{ae[e]=t;})(e,i);})),e.clearPrewarmedResources=function(){const e=A;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(z),A=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"));},e.createTileMesh=ci,e.getGlobalDispatcher=B,e.getMaxParallelImageRequests=function(){return t.c.MAX_PARALLEL_IMAGE_REQUESTS},e.getRTLTextPluginStatus=function(){return ce().getRTLTextPluginStatus()},e.getVersion=function(){return Ss},e.getWorkerCount=function(){return R.workerCount},e.getWorkerUrl=function(){return t.c.WORKER_URL},e.importScriptInWorkers=function(e){return B().broadcast("IS",e)},e.isTimeFrozen=function(){return l.isFrozen()},e.now=c,e.prewarm=function(){F().acquire(z);},e.restoreNow=function(){l.restoreNow();},e.setMaxParallelImageRequests=function(e){t.c.MAX_PARALLEL_IMAGE_REQUESTS=e;},e.setNow=function(e){l.setNow(e);},e.setRTLTextPlugin=function(e,t){return ce().setRTLTextPlugin(e,t)},e.setWorkerCount=function(e){R.workerCount=e;},e.setWorkerUrl=function(e){t.c.WORKER_URL=e;};})); // // Our custom intro provides a specialized "define()" function, called by the // AMD modules below, that sets up the worker blob URL and then executes the // main module, storing its exported value as 'maplibregl' var maplibregl$1 = maplibregl; return maplibregl$1; })); //# sourceMappingURL=maplibre-gl.js.map
| ver. 1.4 |
Github
|
.
| PHP 7.0.33 | Генерация страницы: 0.08 |
proxy
|
phpinfo
|
Настройка