import r from"@arcgis/core/geometry/Extent";import e from"@arcgis/core/geometry/Multipoint";import t from"@arcgis/core/geometry/Point";import o from"@arcgis/core/geometry/Polygon";import n from"@arcgis/core/geometry/Polyline";import{assertNever as i}from"../utilities/checkArg.js";import{isGeometry as s}from"../utilities/esri.js";export function toEsriApiGeometry(i){if(s(i))return i;if(i.hasOwnProperty("x")&&i.hasOwnProperty("y"))return t.fromJSON(i);if(i.hasOwnProperty("points"))return e.fromJSON(i);if(i.hasOwnProperty("paths"))return n.fromJSON(i);if(i.hasOwnProperty("rings"))return o.fromJSON(i);if(i.hasOwnProperty("xmin")&&i.hasOwnProperty("xmax")&&i.hasOwnProperty("ymin")&&i.hasOwnProperty("ymax"))return r.fromJSON(i);throw new Error("Unrecognized geometry type.")}export function toPortalGeometry(r){return r.toJSON()}export var GeometryType;function y(r,e){const t=r;switch(t){case"point":return"esriGeometryPoint";case"multipoint":return"esriGeometryMultipoint";case"polyline":return"esriGeometryPolyline";case"polygon":return"esriGeometryPolygon";case"extent":return"esriGeometryEnvelope";case"mesh":case"multipatch":if(e)throw e;return;default:return i(t,e)}}function m(r,e){const t=r;switch(t){case"esriGeometryPoint":return"point";case"esriGeometryMultipoint":return"multipoint";case"esriGeometryPolyline":return"polyline";case"esriGeometryPolygon":return"polygon";case"esriGeometryEnvelope":return"extent";default:return i(t,e)}}!function(r){r.fromEsriApiGeometryType=function(r){if(!!m(r))return r;const e=y(r);if(e)return e;throw new Error("Unrecognized geometry type.")},r.toEsriApiGeometryType=function(r){if(!!y(r)||"mesh"===r)return r;const e=m(r);if(e)return e;throw new Error("Unrecognized geometry type.")}}(GeometryType||(GeometryType={}));