import{error as r,isNumber as i,isArray as t,coordEach as o}from"./helper";import*as e from"./crs/index";export default function n(n,a,s){n||r("coordinate is required"),a||r("original coordinate system is required"),s||r("target coordinate system is required");var u=e[a];if(u||r("original coordinate system is invalid"),a===s)return n;var m=u.i[s];m||r("target coordinate system is invalid");var c=typeof n;if("string"!==c&&"object"!==c&&r("coordinate must be an geojson or an array of position"),"string"===c)try{n=JSON.parse(n)}catch(i){r("input is not a legal JSON string")}var d=!1;t(n)&&(n.length<2&&r("position must be at 2 numbers long"),i(n[0])&&i(n[1])||r("position must contain numbers"),n=n.map(Number),d=!0);var l=null,g=m;return d?l=g(n):(o(n,(function(r){var i;i=g(r),r[0]=i[0],r[1]=i[1]})),l=n),l||""}