import{g as P,gu as G,gv as N,eS as $,aB as C}from"./index.6c049565.js";const J={LineString:"esriGeometryPolyline",MultiLineString:"esriGeometryPolyline",MultiPoint:"esriGeometryMultipoint",Point:"esriGeometryPoint",Polygon:"esriGeometryPolygon",MultiPolygon:"esriGeometryPolygon"};function S(n){return J[n]}function*M(n){switch(n.type){case"Feature":yield n;break;case"FeatureCollection":for(const t of n.features)t&&(yield t)}}function*x(n){if(!n)return null;switch(n.type){case"Point":yield n.coordinates;break;case"LineString":case"MultiPoint":yield*n.coordinates;break;case"MultiLineString":case"Polygon":for(const t of n.coordinates)yield*t;break;case"MultiPolygon":for(const t of n.coordinates)for(const e of t)yield*e}}function*A(n,t={}){var r;const{geometryType:e,objectIdField:o}=t;for(const a of n){const{geometry:c,properties:i,id:l}=a;if(c&&S(c.type)!==e)continue;const s=i||{};let d=(r=s[o])!=null?r:null;o&&l!=null&&!s[o]&&(s[o]=d=l),yield new $(c?Z(new C,c,t):null,s,null,d)}}function D(n){for(const t of n)if(t.length>2)return!0;return!1}function E(n){return!k(n)}function R(n){return k(n)}function k(n){let t=0;for(let e=0;e=0;o--)b(n,t[o],e);n.lengths.push(t.length)}function b(n,t,e){const[o,r,a]=t;n.coords.push(o,r),e.hasZ&&n.coords.push(a||0)}function Q(n){switch(typeof n){case"string":return"esriFieldTypeString";case"number":return"esriFieldTypeDouble";default:return"unknown"}}function V(n){if(!n)throw new P("geojson-layer:empty","GeoJSON data is empty");if(n.type!=="Feature"&&n.type!=="FeatureCollection")throw new P("geojson-layer:unsupported-geojson-object","missing or not supported GeoJSON object type",{data:n});const{crs:t}=n;if(!t)return;const e=typeof t=="string"?t:t.type==="name"?t.properties.name:t.type==="EPSG"?t.properties.code:null,o=new RegExp(".*(CRS84H?|4326)$","i");if(!e||!o.test(e))throw new P("geojson-layer:unsupported-crs","unsupported GeoJSON 'crs' member",{crs:t})}function W(n,t={}){const e=[],o=new Set,r=new Set;let a,c=!1,i=null,l=!1,{geometryType:s=null}=t,d=!1;for(const g of M(n)){const{geometry:w,properties:f,id:y}=g;if((!w||(s||(s=S(w.type)),S(w.type)===s))&&(c||(c=D(x(w))),l||(l=y!=null,l&&(a=typeof y,i=Object.keys(f).filter(p=>f[p]===y))),l&&y!=null&&(i.length>1?i=i.filter(p=>f[p]===y):i.length===1&&(i=f[i[0]]===y?i:[])),!d&&f)){let p=!0;for(const u in f){if(o.has(u))continue;const F=f[u];if(F==null){p=!1,r.add(u);continue}const j=Q(F);j!=="unknown"?(r.delete(u),o.add(u),e.push({name:G(u),alias:u,type:j})):r.add(u)}d=p}}const m=G((i==null?void 0:i.length)===1&&i[0]||null);if(m){for(const g of e)if(g.name===m&&N(g)){g.type="esriFieldTypeOID";break}}return{fields:e,geometryType:s,hasZ:c,objectIdFieldName:m,objectIdFieldType:a,unknownFields:Array.from(r)}}function X(n,t){return Array.from(A(M(n),t))}export{X as I,W as L,V as T,S as s};