import { c as o } from "../../chunks/runtime.js";
import { html as l } from "lit-html";
import { keyed as u } from "lit-html/directives/keyed.js";
import { watch as p } from "@geoscene/core/core/reactiveUtils.js";
import d from "@geoscene/core/geometry/SpatialReference.js";
import { LitElement as f, safeClassMap as n } from "@arcgis/lumina";
import { css as m } from "@lit/reactive-element/css-tag.js";
/*! All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
See https://js.geoscene.cn/4.33/geoscene/copyright.txt for details.
v4.33.18 */
const v = m`.geoscene-print__sr-label{display:flex;gap:var(--calcite-spacing-xs)}.geoscene-print__invalid-wkid-text{color:var(--calcite-color-status-danger);font-size:var(--calcite-font-size--0)}`, s = "geoscene-print", c = {
  srLabel: `${s}__sr-label`,
  invalidWkidText: `${s}__invalid-wkid-text`
};
function _(e) {
  if (e == null)
    return !1;
  const t = e.wkid;
  return t != null && t >= 2e3 ? !0 : e.wkt2 != null || e.wkt != null;
}
function b(e) {
  return e == null ? e : Math.round(Number.parseFloat(e));
}
class k extends f {
  constructor() {
    super(...arguments), this._isValidSpatialReference = !0;
  }
  static {
    this.properties = { _isValidSpatialReference: 16, _outSpatialReference: 16, templateOptions: 0, viewModel: 0, messages: 0 };
  }
  static {
    this.styles = v;
  }
  loaded() {
    this.manager.onLifecycle(() => [
      p(() => this.viewModel.outSpatialReference, (t) => {
        this._outSpatialReference = t ?? void 0;
      }, { initial: !0 })
    ]);
  }
  render() {
    const { messages: t, _outSpatialReference: a } = this;
    return l`<div><calcite-label><div class=${n(c.srLabel)}>${t.outSpatialReference}<calcite-link href=https://developers.geoscene.cn/rest/services-reference/enterprise/using-spatial-references/ target=_blank>(WKID)</calcite-link></div><calcite-input-number data-input-name=outSpatialReference integer number-button-type=none .value=${this._outSpatialReference?.wkid?.toString() ?? ""} .max=${Number.MAX_SAFE_INTEGER} @calciteInputNumberInput=${({ currentTarget: r }) => {
      const i = b(r.value);
      if (Number.isNaN(i) || i == null || i <= 0 || !Number.isFinite(i)) {
        r.value = `${a?.wkid ?? ""}`;
        return;
      }
      this.viewModel.outSpatialReference = Number.isNaN(i) || i == null ? null : new d({ wkid: i }), this._isValidSpatialReference = !a || _(a);
    }}></calcite-input-number>${this._isValidSpatialReference ? null : u(`out-sr-${a?.wkid}`, l`<div class=${n(c.invalidWkidText)}>${t.invalidWkid}</div>`)}</calcite-label></div>`;
  }
}
o("geoscene-print-out-spatial-reference-input", k);
export {
  k as PrintOutSpatialReferenceInput
};