var __decorate=this&&this.__decorate||function(t,e,r,s){var i,h=arguments.length,o=h<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,r,s);else for(var l=t.length-1;l>=0;l--)(i=t[l])&&(o=(h<3?i(o):h>3?i(e,r,o):i(e,r))||o);return h>3&&o&&Object.defineProperty(e,r,o),o},__awaiter=this&&this.__awaiter||function(t,e,r,s){return new(r||(r=Promise))(function(i,h){function o(t){try{n(s.next(t))}catch(t){h(t)}}function l(t){try{n(s.throw(t))}catch(t){h(t)}}function n(t){var e;t.done?i(t.value):((e=t.value)instanceof r?e:new r(function(t){t(e)})).then(o,l)}n((s=s.apply(t,e||[])).next())})};import{svg as t,LitElement as e}from"lit";import{customElement as r}from"lit/decorators.js";let OrClusterMarker=class extends e{constructor(t,e,r,s,i){super(),this._slices=[],this._highThreshold=99,this._midTreshold=this._highThreshold/10,this._lowTreshold=this._midTreshold/10,this._clusterId=e,this._slices=t,this.lng=r,this.lat=s,this._map=i}hasTypes(t){for(let e of t)if(!this._slices.some(([t])=>t===e))return!1;return!0}render(){return t`${this._createDonutChart(this._slices)}`}_createDonutChart(e){let r=0;for(let t of e)t.push(r),r+=t[2];let s=r>=this._highThreshold?18:r>=this._midTreshold?16:r>=this._lowTreshold?14:12,i=r>=this._highThreshold?32:r>=this._midTreshold?26:r>=this._lowTreshold?16:12,h=r>=this._highThreshold?28:r>=this._midTreshold?24:r>=this._lowTreshold?16:8,o=i-h,l=Math.round(.6*i),n=2*i,a=r>this._highThreshold;return t`
            <svg 
                width="${n}"
                height="${n}"
                viewbox="0 0 ${n} ${n}"
                text-anchor="middle"
                style="cursor: pointer; pointer-events: auto; font: ${s}px Helvetica Neue,Arial,Helvetica,sans-serif; display: block">
                    ${e.map(([,t,e,s])=>this._donutSegment(s/r,(s+e)/r,h,l,t,o))}
                    <circle cx="${i}" cy="${i}" r="${l}" fill="white" />
                    <text dominant-baseline="central" transform="translate(${i}, ${i})">
                        ${(a?this._highThreshold:r).toLocaleString()+(a?"+":"")}
                    </text>
            </svg>
        `}_donutSegment(e,r,s,i,h,o){r-e==1&&(r-=1e-5);let l=2*Math.PI*(e-.25),n=2*Math.PI*(r-.25),a=Math.cos(l),c=Math.sin(l),d=Math.cos(n),u=Math.sin(n),_=+(r-e>.5);return t`<path fill="#${h}" transform="translate(${o}, ${o})" d="
            M ${s+i*a} ${s+i*c}
            L ${s+s*a} ${s+s*c}
            A ${s} ${s} 0 ${_} 1 ${s+s*d} ${s+s*u}
            L ${s+i*d} ${s+i*u}
            A ${i} ${i} 0 ${_} 0 ${s+i*a} ${s+i*c}
            "
        />`}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this.onClick)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",this.onClick)}onClick(){return __awaiter(this,void 0,void 0,function*(){if(this.lng&&this.lat){let t=yield this._map.getSource("mapPoints").getClusterExpansionZoom(this._clusterId);this._map.easeTo({center:[this.lng,this.lat],zoom:t+.99,essential:!0})}})}};OrClusterMarker=__decorate([r("or-cluster-marker")],OrClusterMarker);export{OrClusterMarker};