/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import{hasSameOrigin as r,changeHost as t}from"../core/urlUtils.js";import{parse as e}from"../layers/support/arcgisLayerUrl.js";import{isSecureProxyService as o}from"../portal/support/urlUtils.js";const s=new Map;function n(t,n){const p=n?.preferredHost;if(!p||r(t,`https://${p}`,!0))return;const u=e(t);if(!u||"FeatureServer"!==u.serverType||o(t))return;const a=u.url.path.toLowerCase();s.has(a)||s.set(a,p)}function p(r){const o=e(r)?.url.path.toLowerCase();if(!o)return r;const n=s.get(o);return n?t(r,n):r}const u={clear(){s.clear()},get size(){return s.size}};export{u as PreferredHostsTest,p as getPreferredUrl,n as setPreferredHost};
