export function isMapboxURL(r){return 0===r.indexOf("mapbox:")}export function transformMapboxUrl(r,t,e){return r.indexOf("/styles/")>-1&&-1===r.indexOf("/sprite")?{url:normalizeStyleURL(r,t)}:r.indexOf("/sprites/")>-1?{url:normalizeSpriteURL(r,t)}:r.indexOf("/fonts/")>-1?{url:normalizeGlyphsURL(r,t)}:r.indexOf("/v4/")>-1||"Source"===e?{url:normalizeSourceURL(r,t)}:void 0}function parseUrl(r){let t=r.match(/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/);if(!t)throw Error("Unable to parse URL object");return{protocol:t[1],authority:t[2],path:t[3]||"/",params:t[4]?t[4].split("&"):[]}}function formatUrl(r,t){let e=parseUrl("https://api.mapbox.com");r.protocol=e.protocol,r.authority=e.authority,r.params.push(`access_token=${t}`);let o=r.params.length?`?${r.params.join("&")}`:"";return`${r.protocol}://${r.authority}${r.path}${o}`}function normalizeStyleURL(r,t){let e=parseUrl(r);return e.path=`/styles/v1${e.path}`,formatUrl(e,t)}function normalizeGlyphsURL(r,t){let e=parseUrl(r);return e.path=`/fonts/v1${e.path}`,formatUrl(e,t)}function normalizeSourceURL(r,t){let e=parseUrl(r);return e.path=`/v4/${e.authority}.json`,e.params.push("secure"),formatUrl(e,t)}function normalizeSpriteURL(r,t){let e=parseUrl(r),o=e.path.split("."),a=o[0],l=o[1],n="";return a.indexOf("@2x")&&(a=a.split("@2x")[0],n="@2x"),e.path=`/styles/v1${a}/sprite${n}.${l}`,formatUrl(e,t)}