"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("../polyfills/tslib.js");
var webmapgl_core_js_1 = require("../webmapgl.core.js");
var chunk_cf921ba9_js_1 = require("./chunk-cf921ba9.js");
var chunk_d01d69cb_js_1 = require("./chunk-d01d69cb.js");
var chunk_c82b670d_js_1 = require("./chunk-c82b670d.js");
var chunk_853b4351_js_1 = require("./chunk-853b4351.js");
var FeatureList = function () { function t() { this.data = {}, this.batchSize = 20, this.display = "visible", this.features = [], this.item = !0, this.loadingSpinner = "bubbles", this.loadingText = chunk_cf921ba9_js_1.a("webmapgl.feature-list.loading"), this.order = "asc"; } return t.prototype.componentWillLoad = function () { var t = this; this.handleSourceId(); var e = this.getMap(); e && e.on("moveend", function () { return t.filter(); }); }, t.prototype.handleInfiniteScroll = function (t) { this.limit += this.batchSize, t.target.complete(); }, t.prototype.handleStyleUpdated = function (t) { t.detail.id === this.styleId && this.handleSourceId(); }, t.prototype.handleSourceId = function () { return tslib_1.__awaiter(this, void 0, void 0, function () { var t, e, n, i; return tslib_1.__generator(this, function (r) { switch (r.label) {
    case 0: return (t = document.querySelector("#" + this.styleId)) && t.json.sources ? "string" != typeof (e = t.json.sources[this.sourceId].data) ? [3, 3] : [4, fetch(e)] : [2];
    case 1: return n = r.sent(), i = this, [4, n.json()];
    case 2: return i.data = r.sent(), [3, 4];
    case 3: this.data = e, r.label = 4;
    case 4: return this.filter(), [2];
} }); }); }, t.prototype.getMap = function () { return chunk_853b4351_js_1.a(this.mapId).map; }, t.prototype.filter = function () { return tslib_1.__awaiter(this, void 0, void 0, function () { var t, e; return tslib_1.__generator(this, function (n) { return this.data.features ? ("all" === this.display ? t = this.data.features : (e = this.getMap().getBounds(), t = this.data.features.filter(function (t) { var n = t.geometry.coordinates, i = n[0], r = n[1]; return i >= e.getWest() && i <= e.getEast() && r >= e.getSouth() && r <= e.getNorth(); })), this.limit = this.batchSize, this.features = this.sort(t), [2]) : [2]; }); }); }, t.prototype.sort = function (t) { var e = this; return "none" !== this.order && this.orderBy ? (t.sort(function (t, n) { var i = t.properties[e.orderBy], r = n.properties[e.orderBy]; return i < r ? "asc" === e.order ? -1 : 1 : i > r ? "asc" === e.order ? 1 : -1 : 0; }), t) : t; }, t.prototype.render = function () { var t = this, e = this.component, n = this.limit ? this.features.slice(0, this.limit) : this.features, i = n.length < this.features.length, r = n.map(function (n) { var i = webmapgl_core_js_1.h(e, Object.assign({ feature: n }, t.componentOptions)); return t.item ? webmapgl_core_js_1.h("ion-item", null, i) : i; }); return [webmapgl_core_js_1.h("ion-list", null, webmapgl_core_js_1.h("slot", { name: "start" }), r, webmapgl_core_js_1.h("slot", { name: "end" })), webmapgl_core_js_1.h("ion-infinite-scroll", { disabled: !i }, webmapgl_core_js_1.h("ion-infinite-scroll-content", { "loading-spinner": this.loadingSpinner, "loading-text": this.loadingText }))]; }, Object.defineProperty(t, "is", { get: function () { return "gl-feature-list"; }, enumerable: !0, configurable: !0 }), Object.defineProperty(t, "properties", { get: function () { return { batchSize: { type: Number, attr: "batch-size" }, component: { type: String, attr: "component" }, componentOptions: { type: "Any", attr: "component-options" }, data: { state: !0 }, display: { type: String, attr: "display" }, features: { type: "Any", attr: "features", mutable: !0 }, item: { type: Boolean, attr: "item" }, limit: { state: !0 }, loadingSpinner: { type: String, attr: "loading-spinner" }, loadingText: { type: String, attr: "loading-text" }, mapId: { type: String, attr: "map-id" }, order: { type: String, attr: "order" }, orderBy: { type: String, attr: "order-by" }, sourceId: { type: String, attr: "source-id", watchCallbacks: ["handleSourceId"] }, styleId: { type: String, attr: "style-id", watchCallbacks: ["handleSourceId"] } }; }, enumerable: !0, configurable: !0 }), Object.defineProperty(t, "listeners", { get: function () { return [{ name: "ionInfinite", method: "handleInfiniteScroll" }, { name: "body:glStyleElementModified", method: "handleStyleUpdated" }]; }, enumerable: !0, configurable: !0 }), t; }(), InfiniteScroll = function () { function t() { this.thrPx = 0, this.thrPc = 0, this.didFire = !1, this.isBusy = !1, this.isLoading = !1, this.threshold = "15%", this.disabled = !1, this.position = "bottom"; } return t.prototype.thresholdChanged = function (t) { t.lastIndexOf("%") > -1 ? (this.thrPx = 0, this.thrPc = parseFloat(t) / 100) : (this.thrPx = parseFloat(t), this.thrPc = 0); }, t.prototype.disabledChanged = function (t) { this.disabled && (this.isLoading = !1, this.isBusy = !1), this.enableScrollEvents(!t); }, t.prototype.componentDidLoad = function () { return tslib_1.__awaiter(this, void 0, void 0, function () { var t, e, n = this; return tslib_1.__generator(this, function (i) { switch (i.label) {
    case 0: return (t = this.el.closest("ion-content")) ? [4, t.componentOnReady()] : [3, 3];
    case 1: return i.sent(), e = this, [4, t.getScrollElement()];
    case 2: e.scrollEl = i.sent(), i.label = 3;
    case 3: return this.thresholdChanged(this.threshold), this.enableScrollEvents(!this.disabled), "top" === this.position && this.queue.write(function () { n.scrollEl && (n.scrollEl.scrollTop = n.scrollEl.scrollHeight - n.scrollEl.clientHeight); }), [2];
} }); }); }, t.prototype.componentDidUnload = function () { this.scrollEl = void 0; }, t.prototype.onScroll = function () { var t = this.scrollEl; if (!t || !this.canStart())
    return 1; var e = this.el.offsetHeight; if (0 === e)
    return 2; var n = t.scrollTop, i = t.offsetHeight, r = 0 !== this.thrPc ? i * this.thrPc : this.thrPx; if (("bottom" === this.position ? t.scrollHeight - e - n - r - i : n - e - r) < 0) {
    if (!this.didFire)
        return this.isLoading = !0, this.didFire = !0, this.ionInfinite.emit(), 3;
}
else
    this.didFire = !1; return 4; }, t.prototype.complete = function () { var t = this, e = this.scrollEl; if (this.isLoading && e && (this.isLoading = !1, "top" === this.position)) {
    this.isBusy = !0;
    var n = e.scrollHeight - e.scrollTop;
    requestAnimationFrame(function () { t.queue.read(function () { var i = e.scrollHeight - n; requestAnimationFrame(function () { t.queue.write(function () { e.scrollTop = i, t.isBusy = !1; }); }); }); });
} }, t.prototype.canStart = function () { return !(this.disabled || this.isBusy || !this.scrollEl || this.isLoading); }, t.prototype.enableScrollEvents = function (t) { this.scrollEl && this.enableListener(this, "scroll", t, this.scrollEl); }, t.prototype.hostData = function () { var t; return { class: (t = {}, t["" + this.mode] = !0, t["infinite-scroll-loading"] = this.isLoading, t["infinite-scroll-enabled"] = !this.disabled, t) }; }, Object.defineProperty(t, "is", { get: function () { return "ion-infinite-scroll"; }, enumerable: !0, configurable: !0 }), Object.defineProperty(t, "properties", { get: function () { return { complete: { method: !0 }, disabled: { type: Boolean, attr: "disabled", watchCallbacks: ["disabledChanged"] }, el: { elementRef: !0 }, enableListener: { context: "enableListener" }, isLoading: { state: !0 }, position: { type: String, attr: "position" }, queue: { context: "queue" }, threshold: { type: String, attr: "threshold", watchCallbacks: ["thresholdChanged"] } }; }, enumerable: !0, configurable: !0 }), Object.defineProperty(t, "events", { get: function () { return [{ name: "ionInfinite", method: "ionInfinite", bubbles: !0, cancelable: !0, composed: !0 }]; }, enumerable: !0, configurable: !0 }), Object.defineProperty(t, "listeners", { get: function () { return [{ name: "scroll", method: "onScroll", disabled: !0, passive: !0 }]; }, enumerable: !0, configurable: !0 }), Object.defineProperty(t, "style", { get: function () { return "ion-infinite-scroll{display:none;width:100%}.infinite-scroll-enabled{display:block}"; }, enumerable: !0, configurable: !0 }), t; }(), InfiniteScrollContent = function () { function t() { } return t.prototype.componentDidLoad = function () { void 0 === this.loadingSpinner && (this.loadingSpinner = this.config.get("infiniteLoadingSpinner", this.config.get("spinner", "ios" === this.mode ? "lines" : "crescent"))); }, t.prototype.hostData = function () { var t; return { class: (t = {}, t["" + this.mode] = !0, t["infinite-scroll-content-" + this.mode] = !0, t) }; }, t.prototype.render = function () { return webmapgl_core_js_1.h("div", { class: "infinite-loading" }, this.loadingSpinner && webmapgl_core_js_1.h("div", { class: "infinite-loading-spinner" }, webmapgl_core_js_1.h("ion-spinner", { name: this.loadingSpinner })), this.loadingText && webmapgl_core_js_1.h("div", { class: "infinite-loading-text", innerHTML: chunk_d01d69cb_js_1.a(this.loadingText) })); }, Object.defineProperty(t, "is", { get: function () { return "ion-infinite-scroll-content"; }, enumerable: !0, configurable: !0 }), Object.defineProperty(t, "properties", { get: function () { return { config: { context: "config" }, loadingSpinner: { type: String, attr: "loading-spinner", mutable: !0 }, loadingText: { type: String, attr: "loading-text" } }; }, enumerable: !0, configurable: !0 }), Object.defineProperty(t, "style", { get: function () { return "ion-infinite-scroll-content{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-pack:center;justify-content:center;min-height:84px;text-align:center;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.infinite-loading{margin-left:0;margin-right:0;margin-top:0;margin-bottom:32px;display:none;width:100%}.infinite-loading-text{margin-left:32px;margin-right:32px;margin-top:4px;margin-bottom:0}\@supports ((-webkit-margin-start:0) or (margin-inline-start:0)) or (-webkit-margin-start:0){.infinite-loading-text{margin-left:unset;margin-right:unset;-webkit-margin-start:32px;margin-inline-start:32px;-webkit-margin-end:32px;margin-inline-end:32px}}.infinite-scroll-loading ion-infinite-scroll-content>.infinite-loading{display:block}.infinite-scroll-content-md .infinite-loading-text{color:var(--ion-color-step-600,#666)}.infinite-scroll-content-md .infinite-loading-spinner .spinner-crescent circle,.infinite-scroll-content-md .infinite-loading-spinner .spinner-lines-md line,.infinite-scroll-content-md .infinite-loading-spinner .spinner-lines-small-md line{stroke:var(--ion-color-step-600,#666)}.infinite-scroll-content-md .infinite-loading-spinner .spinner-bubbles circle,.infinite-scroll-content-md .infinite-loading-spinner .spinner-circles circle,.infinite-scroll-content-md .infinite-loading-spinner .spinner-dots circle{fill:var(--ion-color-step-600,#666)}"; }, enumerable: !0, configurable: !0 }), Object.defineProperty(t, "styleMode", { get: function () { return "md"; }, enumerable: !0, configurable: !0 }), t; }(), spinners = { lines: { dur: 1e3, lines: 12, fn: function (t, e, n) { return { y1: 17, y2: 29, style: { transform: "rotate(" + (30 * e + (e < 6 ? 180 : -180)) + "deg)", "animation-delay": t * e / n - t + "ms" } }; } }, "lines-small": { dur: 1e3, lines: 12, fn: function (t, e, n) { return { y1: 12, y2: 20, style: { transform: "rotate(" + (30 * e + (e < 6 ? 180 : -180)) + "deg)", "animation-delay": t * e / n - t + "ms" } }; } }, bubbles: { dur: 1e3, circles: 9, fn: function (t, e, n) { var i = t * e / n - t + "ms", r = 2 * Math.PI * e / n; return { r: 5, style: { top: 9 * Math.sin(r) + "px", left: 9 * Math.cos(r) + "px", "animation-delay": i } }; } }, circles: { dur: 1e3, circles: 8, fn: function (t, e, n) { var i = e / n, r = t * i - t + "ms", o = 2 * Math.PI * i; return { r: 5, style: { top: 9 * Math.sin(o) + "px", left: 9 * Math.cos(o) + "px", "animation-delay": r } }; } }, crescent: { dur: 750, circles: 1, fn: function () { return { r: 26, style: {} }; } }, dots: { dur: 750, circles: 3, fn: function (t, e) { return { r: 6, style: { left: 9 - 9 * e + "px", "animation-delay": -110 * e + "ms" } }; } } }, SPINNERS = spinners, Spinner = function () { function t() { this.paused = !1; } return t.prototype.getName = function () { return this.name || this.config.get("spinner") || ("ios" === this.mode ? "lines" : "crescent"); }, t.prototype.hostData = function () { var t; return { class: Object.assign({}, chunk_c82b670d_js_1.a(this.color), (t = {}, t["" + this.mode] = !0, t["spinner-" + this.getName()] = !0, t["spinner-paused"] = !!this.paused || this.config.getBoolean("_testing"), t)) }; }, t.prototype.render = function () { var t = this.getName(), e = SPINNERS[t] || SPINNERS.lines, n = "number" == typeof this.duration && this.duration > 10 ? this.duration : e.dur, i = []; if (void 0 !== e.circles)
    for (var r = 0; r < e.circles; r++)
        i.push(buildCircle(e, n, r, e.circles));
else if (void 0 !== e.lines)
    for (r = 0; r < e.lines; r++)
        i.push(buildLine(e, n, r, e.lines)); return i; }, Object.defineProperty(t, "is", { get: function () { return "ion-spinner"; }, enumerable: !0, configurable: !0 }), Object.defineProperty(t, "encapsulation", { get: function () { return "shadow"; }, enumerable: !0, configurable: !0 }), Object.defineProperty(t, "properties", { get: function () { return { color: { type: String, attr: "color" }, config: { context: "config" }, duration: { type: Number, attr: "duration" }, name: { type: String, attr: "name" }, paused: { type: Boolean, attr: "paused" } }; }, enumerable: !0, configurable: !0 }), Object.defineProperty(t, "style", { get: function () { return ".sc-ion-spinner-h{display:inline-block;position:relative;width:28px;height:28px;color:var(--color);-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.ion-color.sc-ion-spinner-h{color:var(--ion-color-base)}svg.sc-ion-spinner{left:0;top:0;-webkit-transform-origin:center;transform-origin:center;position:absolute;width:100%;height:100%;-webkit-transform:translateZ(0);transform:translateZ(0)}[dir=rtl].sc-ion-spinner-h   svg.sc-ion-spinner, [dir=rtl]   .sc-ion-spinner-h   svg.sc-ion-spinner, [dir=rtl].sc-ion-spinner   svg.sc-ion-spinner{left:unset;right:unset;right:0;-webkit-transform-origin:calc(100% - center);transform-origin:calc(100% - center)}.spinner-lines.sc-ion-spinner-h   line.sc-ion-spinner, .spinner-lines-small.sc-ion-spinner-h   line.sc-ion-spinner{stroke-width:4px;stroke-linecap:round;stroke:currentColor}.spinner-lines.sc-ion-spinner-h   svg.sc-ion-spinner, .spinner-lines-small.sc-ion-spinner-h   svg.sc-ion-spinner{-webkit-animation:spinner-fade-out 1s linear infinite;animation:spinner-fade-out 1s linear infinite}.spinner-bubbles.sc-ion-spinner-h   svg.sc-ion-spinner{-webkit-animation:spinner-scale-out 1s linear infinite;animation:spinner-scale-out 1s linear infinite;fill:currentColor}.spinner-circles.sc-ion-spinner-h   svg.sc-ion-spinner{-webkit-animation:spinner-fade-out 1s linear infinite;animation:spinner-fade-out 1s linear infinite;fill:currentColor}.spinner-crescent.sc-ion-spinner-h   circle.sc-ion-spinner{fill:transparent;stroke-width:4px;stroke-dasharray:128px;stroke-dashoffset:82px;stroke:currentColor}.spinner-crescent.sc-ion-spinner-h   svg.sc-ion-spinner{-webkit-animation:spinner-rotate 1s linear infinite;animation:spinner-rotate 1s linear infinite}.spinner-dots.sc-ion-spinner-h   circle.sc-ion-spinner{stroke-width:0;fill:currentColor}.spinner-dots.sc-ion-spinner-h   svg.sc-ion-spinner{-webkit-animation:spinner-dots 1s linear infinite;animation:spinner-dots 1s linear infinite}.spinner-paused.sc-ion-spinner-h   svg.sc-ion-spinner{-webkit-animation-play-state:paused;animation-play-state:paused}\@-webkit-keyframes spinner-fade-out{0%{opacity:1}to{opacity:0}}\@keyframes spinner-fade-out{0%{opacity:1}to{opacity:0}}\@-webkit-keyframes spinner-scale-out{0%{-webkit-transform:scale(1);transform:scale(1)}to{-webkit-transform:scale(0);transform:scale(0)}}\@keyframes spinner-scale-out{0%{-webkit-transform:scale(1);transform:scale(1)}to{-webkit-transform:scale(0);transform:scale(0)}}\@-webkit-keyframes spinner-rotate{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}\@keyframes spinner-rotate{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}\@-webkit-keyframes spinner-dots{0%{-webkit-transform:scale(1);transform:scale(1);opacity:.9}50%{-webkit-transform:scale(.4);transform:scale(.4);opacity:.3}to{-webkit-transform:scale(1);transform:scale(1);opacity:.9}}\@keyframes spinner-dots{0%{-webkit-transform:scale(1);transform:scale(1);opacity:.9}50%{-webkit-transform:scale(.4);transform:scale(.4);opacity:.3}to{-webkit-transform:scale(1);transform:scale(1);opacity:.9}}"; }, enumerable: !0, configurable: !0 }), t; }();
exports.GlFeatureList = FeatureList;
exports.IonInfiniteScroll = InfiniteScroll;
exports.IonInfiniteScrollContent = InfiniteScrollContent;
exports.IonSpinner = Spinner;
function buildCircle(t, e, n, i) { var r = t.fn(e, n, i); return r.style["animation-duration"] = e + "ms", webmapgl_core_js_1.h("svg", { viewBox: "0 0 64 64", style: r.style }, webmapgl_core_js_1.h("circle", { transform: "translate(32,32)", r: r.r })); }
function buildLine(t, e, n, i) { var r = t.fn(e, n, i); return r.style["animation-duration"] = e + "ms", webmapgl_core_js_1.h("svg", { viewBox: "0 0 64 64", style: r.style }, webmapgl_core_js_1.h("line", { transform: "translate(32,32)", y1: r.y1, y2: r.y2 })); }
