function AdfSvgCacheManager(){this.Init()}AdfObject.createSubclass(AdfSvgCacheManager);AdfSvgCacheManager.prototype.Init=function(){AdfSvgCacheManager.superclass.Init.call(this);this._svgCache=AdfSvgInMemoryCache.getInstance()};
AdfSvgCacheManager.prototype.embedSVG=function(a,b,d){AdfAssert.assert(null!=a);AdfAssert.assertDomElement(b);AdfAssert.assertString(d);d=this._normalizeURL(d);var e=this._svgCache.getSvgIcon(d);e?(a=b.parentNode,AdfSvgCacheManager._copyAttributesToSVG(b,e),a.replaceChild(e,b)):this._sendRequest(a,b,d)};AdfSvgCacheManager.prototype.clearSvgIcon=function(a){this._svgCache.invalidateSvgIcon(a)};
AdfSvgCacheManager.prototype._sendRequest=function(a,b,d){var e=d.split("#"),f=e[0],g=e[1],h=new AdfXMLRequest,k=this;h.setCallback(function(h){if(0==k._inlineSVGCallback(a,b,d,g,h)){var m=a.getAltSource&&null!=a.getAltSource()?AdfPage.PAGE.getResourceURL(a.getAltSource()):null;null!=m&&(AdfAssert.assertString(m),m=k._normalizeURL(m),e=m.split("#"),m=e[0],f!=m&&(f=m,h.send(f,null,!0)))}});a._xhrInProgress=!0;AdfPage.PAGE.registerLoadingComponent(a);h.send(f,null,!0)};
AdfSvgCacheManager.prototype._cacheSvg=function(a,b){var d=a.cloneNode(!0);this._svgCache.setSvgIcon(b,d)};
AdfSvgCacheManager.prototype._inlineSVGCallback=function(a,b,d,e,f){if(f.getCompletionState()==AdfXMLRequest.COMPLETED){a._xhrInProgress=!1;if(200!=f.getStatus()&&304!=f.getStatus())return AdfLogger.LOGGER.fine("AdfRichUIPeer#_inlineSVGCallback - xhr status not OK ("+f.getStatus()+") in response of this url: "+d),!1;var g=f.getResponseXML();if(!g){var h;try{h=(new DOMParser).parseFromString(f.getResponseText(),"text/xml")}catch(q){return AdfLogger.LOGGER.warning("AdfRichUIPeer#_inlineSVGCallback - failed to parse svg to xml in response of this url : "+
d),!1}if(!h)return AdfLogger.LOGGER.warning("AdfRichUIPeer#_inlineSVGCallback - failed to get svg as xml in response of this url : "+d),!1;g=h}var k;try{if(e){var l=g.getElementById(e);if(!l.childNodes.length)return AdfLogger.LOGGER.fine("AdfRichUIPeer#_inlineSVGCallback - child for svg symbol not found in response of this url : "+d),!1;k=document.createElementNS("http://www.w3.org/2000/svg","svg");AdfDomUtils.copyAllAttributes(l,k);for(var m=document.createDocumentFragment();l.childNodes.length;)m.appendChild(l.childNodes[0]);
k.appendChild(m)}else{var n=g.getElementsByTagName("svg")[0];if(!n)return AdfLogger.LOGGER.warning("AdfRichUIPeer#_inlineSVGCallback - svg node not found in response of this url: "+d),!1;k=document.importNode(n,!0)}}catch(q){return AdfLogger.LOGGER.error("AdfRichUIPeer#_inlineSVGCallback - invalid svg url: "+d),!1}this._cacheSvg(k,d);AdfSvgCacheManager._copyAttributesToSVG(b,k);d=AdfAgent.AGENT;d.elementsRemoved(b);b.parentNode.replaceChild(k,b);d.elementsAdded(k);AdfPage.PAGE.unregisterLoadingComponent(a);
return!0}};AdfSvgCacheManager.prototype._normalizeURL=function(a){try{var b=AdfAgent.AGENT,d=b.getOrigin();-1===a.indexOf("://")&&-1===a.indexOf("//")&&("/"!=a.charAt(0)&&(a=AdfPage.PAGE.getResourceURL("/"+a)),d&&(a=d+a));var e;b.getPlatform()==AdfAgent.IE_PLATFORM?(e=document.createElement("a"),e.href=a,d=(d?d.toLowerCase():"")+"/"):(e=new URL(a),d=d?d.toLowerCase():"");return d+e.pathname+e.hash+e.search}catch(f){AdfLogger.LOGGER.warning("Invalid url could not normalize the url: "+f+"url: "+a)}return a};
AdfSvgCacheManager._copyAttributesToSVG=function(a,b){for(var d=0;d<a.attributes.length;d++){var e=a.attributes[d];if("src"!=e.name){var f=b.getAttribute(e.name);if(f&&"class"==e.name)f=f+" "+e.value;else if(f&&"style"==e.name)f=f+";"+e.value;else if("title"==e.name&&""!=e.value){b.setAttribute("role","img");f=e.value;b.setAttribute("aria-label",f);e=document.createElementNS("http://www.w3.org/2000/svg","title");e.textContent=f;b.insertBefore(e,b.firstChild);continue}else f=e.value;b.setAttribute(e.name,
f)}}};