// All material copyright Esri, All Rights Reserved, unless otherwise specified. // See https://js.arcgis.com/4.30/esri/copyright.txt for details. //>>built define(["exports","../kernel","../core/urlUtils","../portal/support/urlUtils"],function(e,h,f,u){function m(a,b){var d=b?.url?.path;a&&d&&(a=f.makeAbsolute(a,d,{preserveProtocolRelative:!0}),b.portalItem&&b.readResourcePaths&&(d=f.makeRelative(a,b.portalItem.itemUrl),null!=d&&z.test(d)&&b.readResourcePaths.push(b.portalItem.resourceFromPath(d).path)));return(a=n(a,b?.portal))&&k.test(a)?p(a):a}function q(a,b,d=e.MarkKeep.YES){a=a&&k.test(a)?r(a):a;if(null==a)return a;!f.isAbsolute(a)&&b?.blockedRelativeUrls&& b.blockedRelativeUrls.push(a);let c=f.makeAbsolute(a);if(b){var g=b.verifyItemRelativeUrls?.rootPath||b.url?.path;if(g){g=n(g,b.portal);const l=n(c,b.portal);c=f.makeRelative(l,g,g);null!=c&&c!==l&&c!==a&&b.verifyItemRelativeUrls&&b.verifyItemRelativeUrls.writtenUrls.push(c)}}c=t(c,b?.portal);f.isAbsolute(c)&&(c=f.normalize(c));b?.resources&&b?.portalItem&&!f.isAbsolute(c)&&!f.isDataProtocol(c)&&d===e.MarkKeep.YES&&b.resources.toKeep.push({resource:b.portalItem.resourceFromPath(c),compress:!1});return c} function v(a,b,d){return m(a,d)}function w(a,b,d,c){a=q(a,c);void 0!==a&&(b[d]=a)}function x(a){return(a?.match(k)??null)?.[1]??null}function y(a){a=a?.match(k)??null;if(null==a)return null;a=a[2];const b=a.lastIndexOf("/");if(-1===b){const {path:g,extension:l}=f.splitPathExtension(a);return{prefix:null,filename:g,extension:l}}const {path:d,extension:c}=f.splitPathExtension(a.slice(b+1));return{prefix:a.slice(0,b),filename:d,extension:c}}function t(a,b){return b&&!b.isPortal&&b.urlKey&&b.customBaseUrl? f.changeDomain(a,`${b.urlKey}.${b.customBaseUrl}`,b.portalHostname):a}function n(a,b){if(!b||b.isPortal||!b.urlKey||!b.customBaseUrl)return a;const d=`${b.urlKey}.${b.customBaseUrl}`,c=f.getAppUrl();return f.hasSameOrigin(c,`${c.scheme}://${d}`)?f.changeDomain(a,b.portalHostname,d):f.changeDomain(a,d,b.portalHostname)}function p(a){if(!a)return a||null;a&&h.id&&!h.id.findCredential(a)&&(a=u.normalizeArcGISOnlineOrgDomain(a),a=a.replace(/^https?:\/\/www\.arcgis\.com/,"https://cdn.arcgis.com"),a=a.replace(/^https?:\/\/devext\.arcgis\.com/, "https://cdndev.arcgis.com"),a=a.replace(/^https?:\/\/qaext\.arcgis\.com/,"https://cdnqa.arcgis.com"));return a}function r(a){if(!a)return a||null;a=a.replace(/^https?:\/\/cdn\.arcgis\.com/,"https://www.arcgis.com");a=a.replace(/^https?:\/\/cdndev\.arcgis\.com/,"https://devext.arcgis.com");(a=a.replace(/^https?:\/\/cdnqa\.arcgis\.com/,"https://qaext.arcgis.com"))&&h.id&&!h.id.findCredential(a)&&(a=u.normalizeArcGISOnlineOrgDomain(a));return a}const k=/\/items\/([^/]+)\/resources\/(.*)/,z=/^\.\/resources\//; e.MarkKeep=void 0;(function(a){a[a.YES=0]="YES";a[a.NO=1]="NO"})(e.MarkKeep||(e.MarkKeep={}));const A=Object.freeze(Object.defineProperty({__proto__:null,get MarkKeep(){return e.MarkKeep},ensureMainOnlineDomain:t,fromCDNUrl:r,fromJSON:m,itemIdFromResourceUrl:x,prefixAndFilenameFromResourceUrl:y,read:v,toCDNUrl:p,toJSON:q,write:w},Symbol.toStringTag,{value:"Module"}));e.ensureMainOnlineDomain=t;e.fromCDNUrl=r;e.fromJSON=m;e.itemIdFromResourceUrl=x;e.persistableUrlUtils=A;e.prefixAndFilenameFromResourceUrl= y;e.read=v;e.toCDNUrl=p;e.toJSON=q;e.write=w});