// Turner XMP, Release Build, © 2007 Turner Broadcasting System, Inc. A Time Warner Company.  File: xmp_services, Version: 0.1.567.2163

xmp.CONTROL_STREAM_NODE_PATH="/PlayerContexts/Global/ControlStream";xmp.CONTROL_STREAM_SERVICE="ControlStream";xmp.CONTROL_STREAM_MEDIA_TYPE="Media Type";xmp.CONTROL_STREAM_ENVIRONMENT_LABEL="Environment Label";xmp.CONTROL_STREAM_URL="Url";xmp.CONTROL_STREAM_RECONNECT_RETRIES="Reconnect Retries";xmp.CONTROL_STREAM_RECONNECT_RETRY_INTERVAL="Reconnect Retry Interval";xmp.CONTROL_STREAM_REFRESH_INTERVAL="RefreshInterval";xmp.CONTROL_STREAM_START_DELAY="Start Delay";xmp.CONTROL_STREAM_RESOURCE_TRANSPORT="controlStreamResource";xmp.ENVIRONMENT_LABEL="{{environment_label}}";xmp.RESOURCE_NAME="name";xmp.RESOURCE_LABEL="label";xmp.RESOURCE_WEB_URL="webUrl";xmp.RESOURCE="resource";xmp.WEB_RESOURCE_CACHING_CONTEXT="retrieved from the web";xmp.TRIGGER_RESOURCE_CACHING_CONTEXT="received from trigger";xmp.START_DELAY_TIMER="StartDelay";xmp.REFRESH_RESOURCE_TIMER="RefreshResources";xmp.RECONNECT_TIMER="Reconnect";xmp.ControlStream=function(){this.listener=null;};xmp.ControlStream.prototype.init=function(aa){try{this.logger=new xmp.util.internals.CategoryLogger(xmp.CONTROL_STREAM_SERVICE);this._validateListener(aa);this.listener=aa;this._resetReconnect();var ba=xmp.util.SettingsManager.getInstance().getGlobalContextNode().getNodeForPath(xmp.CONTROL_STREAM_NODE_PATH);this._initProperties(ba);this.reader=xmp.ControlStreamReaderFactory.createReader(xmp.util.internals.BrowserDetect.OS,this,this.mimeType);this._initResources(ba);this._start();}
catch(e){this._handleError("Initializing.",e);}};xmp.ControlStream.prototype.fini=function(){if(this.reader){this.reader.close();}
if(this.startDelayTimer){this.startDelayTimer.stop();this.startDelayTimer=null;}
if(this.refreshResourcesTimer){this.refreshResourcesTimer.stop();this.refreshResourcesTimer=null;}
this._resetReconnect();};xmp.ControlStream.prototype._start=function(){if(0===this.startDelay){this._handleStart();}
else{this.startDelayTimer=this._createTimer({id:xmp.START_DELAY_TIMER,interval:this.startDelay,handler:this._onDelayedStart});this.startDelayTimer.start();}};xmp.ControlStream.prototype._validateListener=function(ca){if(!ca){throw new xmp.ControlStreamError("Validating listener.","Missing control stream listener.");}
if(false===xmp.isDefined(ca.onControlStreamError)){throw new xmp.ControlStreamError("Validating listener.","Invalid control stream listener.  Missing \"onControlStreamError\" handler.");}
if(false===xmp.isDefined(ca.onControlStreamTrigger)){throw new xmp.ControlStreamError("Validating listener.","Invalid control stream listener.  Missing \"onControlStreamTrigger\" handler.");}
if(false===xmp.isDefined(ca.onControlStreamTriggerInit)){throw new xmp.ControlStreamError("Validating listener.","Invalid control stream listener.  Missing \"onControlStreamTriggerInit\" handler.");}};xmp.ControlStream.prototype._validateResource=function(da){if(da.name.length===0){throw new xmp.ControlStreamError("Validating resource.","Missing control stream resource name.");}
if(da.label.length===0){throw new xmp.ControlStreamError("Validating resource.","Missing control stream resource label.");}
if(da.webUrl.length===0){throw new xmp.ControlStreamError("Validating resource.","Missing control stream \""+da.name+"\" web url.");}};xmp.ControlStream.prototype._initProperties=function(ea){var fa=ea.getString(xmp.CONTROL_STREAM_MEDIA_TYPE,xmp.NO_DEFAULT_VALUE);if(fa.length===0){throw new xmp.ControlStreamError("Initializing properties.","Missing control stream media type.");}
var ga=xmp.PlayerPolicy.getMediaType(fa);if(false===xmp.isDefined(ga)){throw new xmp.ControlStreamError("Initializing properties.","Invalid control stream media type \""+fa+"\".");}
this.mimeType=ga.mimeType;this.url=ea.getString(xmp.CONTROL_STREAM_URL,xmp.NO_DEFAULT_VALUE);if(this.url.length===0){throw new xmp.ControlStreamError("Initializing properties.","Missing control stream url.");}
this.reconnectRetryInterval=ea.getInt(xmp.CONTROL_STREAM_RECONNECT_RETRY_INTERVAL,0);if(this.reconnectRetryInterval===0){throw new xmp.ControlStreamError("Initializing properties.","Missing control stream reconnect retry interval.");}
this.maxReconnectRetryCount=ea.getInt(xmp.CONTROL_STREAM_RECONNECT_RETRIES,0);this.startDelay=ea.getInt(xmp.CONTROL_STREAM_START_DELAY,0);var ha=ea.getNodeForPath(xmp.CONTROL_STREAM_REFRESH_INTERVAL);this.refreshInterval=ha.getInt(xmp.util.internals.BrowserDetect.OS,0);if(this.refreshInterval===0){throw new xmp.ControlStreamError("Initializing properties.","Missing control stream refresh interval for the \""+xmp.util.internals.BrowserDetect.OS+"\" platform.");}};xmp.ControlStream.prototype._initResources=function(ia){this.resources={};var ja=ia.getString(xmp.CONTROL_STREAM_ENVIRONMENT_LABEL,xmp.NO_DEFAULT_VALUE);if(ja.Length===0){throw new xmp.ControlStreamError("Initializing resources.","Missing control stream environment label.");}
var ka=ia.retrieveChildren();var la=ka.length;for(var i=0;i<la;i++){var ma=ka[i];if(ma.getName()===xmp.CONTROL_STREAM_REFRESH_INTERVAL){continue;}
var na=ma.getString(xmp.RESOURCE_LABEL,xmp.NO_DEFAULT_VALUE);na=na.replace(xmp.ENVIRONMENT_LABEL,ja);var oa={initialized:false,name:ma.getString(xmp.RESOURCE_NAME,xmp.NO_DEFAULT_VALUE),label:na,webUrl:ma.getString(xmp.RESOURCE_WEB_URL,xmp.NO_DEFAULT_VALUE),data:null};this._validateResource(oa);this.resources[oa.name]=oa;}};xmp.ControlStream.prototype._refreshResources=function(pa){for(var qa=xmp.MapIterator.create(this.resources);qa.hasNext();qa.next()){this._getResourceFromWeb(qa.currentValue(),pa);}};xmp.ControlStream.prototype._getResourceFromWeb=function(ra,sa){var ta=((true===sa)?this._onInitResource:this._onResourceLoadedFromWeb);var ua=new xmp.util.Callback(xmp.CONTROL_STREAM_SERVICE,ta,this);ua.setMetadata(xmp.RESOURCE,ra);var va=xmp.net.AjaxRequestManager.getInstance();va.request(xmp.CONTROL_STREAM_SERVICE,ua,xmp.CONTROL_STREAM_RESOURCE_TRANSPORT,ra.webUrl,xmp.net.ContentTypes.JSON,null);};xmp.ControlStream.prototype._onResourceLoadedFromWeb=function(wa,xa){this._setWebResource(wa,xa,this.listener.onControlStreamTrigger,true);};xmp.ControlStream.prototype._onInitResource=function(ya,za){var Aa=null;try{Aa=ya.getMetadata(xmp.RESOURCE,{});this._setWebResource(ya,za,this.listener.onControlStreamTriggerInit,false);Aa.initialized=true;}
catch(e){if(Aa){if(false===Aa.initialized){try{this.listener.onControlStreamTriggerInit(Aa.name,null);}
catch(e2){}
Aa.initialized=true;}}}};xmp.ControlStream.prototype._setResource=function(Ba,Ca,Da,Ea,Fa){this._validateResourceData(Ca,Da);if(true===Ea&&false===this.checkResourceVersion(Ca,Da)){this.logger.info((new Date()).toString()+" - Ignoring resource \""+Ca.name+"\" "+Ba+".  Already up to date ("+Da.modifiedDate+").");return;}
Ca.data=Da;this.logger.info((new Date()).toString()+" - Resource \""+Ca.name+"\" "+Ba+".");Fa.call(this.listener,Ca.name,Da);};xmp.ControlStream.prototype.checkResourceVersion=function(Ga,Ha){if(!Ga.data){return true;}
return(Ha.modifiedDate>Ga.data.modifiedDate);};xmp.ControlStream.prototype._validateResourceData=function(Ia,Ja){if(!Ja){throw new xmp.ControlStreamError("Validating resource data.","NULL resource data.");}
if(!Ja.id||Ja.id.length===0){throw new xmp.ControlStreamError("Validating resource data.","Invalid control stream resource \""+Ia.name+"\" data.  Missing resource id.");}
if(Ia.label!==Ja.id){throw new xmp.ControlStreamError("Validating resource data.","Invalid control stream resource \""+Ia.name+"\" data id \""+Ja.id+"\".  Expected \""+Ia.label+"\".");}};xmp.ControlStream.prototype._createTimer=function(Ka){var La=new xmp.util.Callback(Ka.id,Ka.handler,this);return new xmp.util.Timer(Ka.id,Ka.interval,-1,La);};xmp.ControlStream.prototype._handleStart=function(){this._connect();this._refreshResources(true);this.refreshResourcesTimer=this._createTimer({id:xmp.REFRESH_RESOURCE_TIMER,interval:this.refreshInterval,handler:this._onRefreshResources});this.refreshResourcesTimer.start();};xmp.ControlStream.prototype._onDelayedStart=function(Ma,Na){try{this.startDelayTimer.stop();this.startDelayTimer=null;this._handleStart();}
catch(e){this._handleError("Starting after delay.",e);}};xmp.ControlStream.prototype._onRefreshResources=function(Oa,Pa){try{this._refreshResources(false);}
catch(e){this._handleError("Refreshing all resources.",e);}};xmp.ControlStream.prototype._handleError=function(Qa,e){var Ra=e;if(false===(Ra instanceof xmp.ControlStreamError)){Ra=new xmp.ControlStreamError(((e.context)?e.context:Qa),((e.rawMessage)?e.rawMessage:e.message));Ra.setInnerError(e);}
this._logError(Ra);if(!this.listener){xmp.handleFatalError(Ra);}
else if(true===xmp.isDefined(this.listener.onControlStreamError)){this.reader.close();this.listener.onControlStreamError(Ra);}};xmp.ControlStream.prototype.onReaderError=function(e){this._logError(e);this._reconnect();};xmp.ControlStream.prototype.onReaderTrigger=function(Sa,Ta){var Ua=null;try{Ua=this._getResourceFromLabel(Sa);this._validateTrigger(Sa,Ua);var Va=xmp.Base64.decode(Ta);var Wa=this._parseJson(Va);this._setResource(xmp.TRIGGER_RESOURCE_CACHING_CONTEXT,Ua,Wa,false,this.listener.onControlStreamTrigger);this.logger.info(Va);}
catch(e){var Xa="TRIGGER PROCESSING ERROR.";if(Ua){Xa="TRIGGER \""+Ua.name+"\" PROCESSING ERROR.";}
this._logError(e);this._getResourceFromWeb(this._getResourceFromLabel(Sa));}};xmp.ControlStream.prototype.onReaderConnected=function(){this.logger.info("Connected.");this._resetReconnect();};xmp.ControlStream.prototype.onReaderPlugInError=function(e){this.listener.onPlugInError(e);};xmp.ControlStream.prototype.onReaderUnsupportedPlatformError=function(e){this.listener.onUnsupportedPlatformError(e);};xmp.ControlStream.prototype._reconnect=function(){if(!this.reconnectTimer){this.reconnectRetryCount=0;this.reconnectTimer=this._createTimer({id:xmp.RECONNECT_TIMER,interval:this.reconnectRetryInterval,handler:this._onReconnect});this.reconnectTimer.start();}};xmp.ControlStream.prototype._onReconnect=function(Ya,Za){try{if(true===this.reader.isConnected()||(this.maxReconnectRetryCount>0&&this.reconnectRetryCount===this.maxReconnectRetryCount)){if(this.reconnectRetryCount===this.maxReconnectRetryCount&&false===this.reader.isConnected()){this.logger.warn("Control stream reconnect retry maximum "+this.maxReconnectRetryCount+" limit reached...");}
this._resetReconnect();return;}
this.reconnectRetryCount++;this.logger.warn("Control stream reconnect retry "+this.reconnectRetryCount+"...");this._connect();this._refreshResources(false);}
catch(e){this._logError(e);}};xmp.ControlStream.prototype._getResourceFromLabel=function($a){for(var ab=xmp.MapIterator.create(this.resources);ab.hasNext();ab.next()){var bb=ab.currentValue();if(bb.label===$a){return bb;}}
return null;};xmp.ControlStream.prototype._logError=function(e){this.logger.warn(e.message);};xmp.ControlStream.prototype._connect=function(){var cb=this.reader.open(this.url);if(cb){this.logger.info("Connecting to \""+cb+"\".");}};xmp.ControlStream.prototype._resetReconnect=function(){if(this.reconnectTimer){this.reconnectTimer.stop();this.reconnectTimer=null;}
this.reconnectRetryCount=0;};xmp.ControlStream.prototype._validateTrigger=function(db,eb){if(!eb){throw new xmp.ControlStreamError("Validating trigger.","Missing control stream resource configuration for \""+db+"\" trigger.");}};xmp.ControlStream.prototype._parseJson=function(fb){var gb=xmp.trimString(fb);return this._parseJavaScript('('+gb+')');};xmp.ControlStream.prototype._parseJavaScript=function(hb){return eval(hb);};xmp.ControlStream.prototype._setWebResource=function(ib,jb,kb,lb){try{var mb=ib.getMetadata(xmp.RESOURCE,{});if(true===jb.isError()){throw new xmp.ControlStreamError("Initializing resources.","Unable to retrieve control stream resource \""+mb.name+"\" from url \""+mb.webUrl+"\". \n\n"+jb.makeReport());}
this._setResource(xmp.WEB_RESOURCE_CACHING_CONTEXT,mb,jb.getJsonObject(),true,kb);}
catch(e){var nb="";if(e instanceof xmp.ControlStreamError){nb=e.message;}
else{nb="Unable to retrieve control stream resource \""+mb.name+"\" from url \""+mb.webUrl+"\". \n\n"+e.message;}
this.logger.warn(nb);if(false===lb){throw e;}}};xmp.CONTROL_STREAM_READER="ControlStreamReader";xmp.ControlStreamReader=function(ob,pb){this.listener=ob;this.mimeType=pb;this.connected=false;this.registry=new xmp.PlayerModeRegistry();this.state=this.registry.findMode(xmp.FINI);xmp.NativePlayerRegistry.createGroup(this.getName(),this);this.player=xmp.NativePlayerRegistry.findPlayerByMimeType(this.getName(),xmp.NULL_MIME_TYPE);this.viewManager=new xmp.ViewManager(this.getName());this.viewManager.setViewportConfig(xmp.NULL_MIME_TYPE,xmp.DHTML_VIEWPORT);this.viewManager.setViewportConfig(this.mimeType,xmp.DHTML_VIEWPORT);};xmp.ControlStreamReader.prototype.open=function(qb){var rb=this.createPlayableNode(qb);if(false===this._initNativePlayer(rb)){this.state.open(this,rb);}
return rb.getURI();};xmp.ControlStreamReader.prototype.close=function(){this.state.close(this);this.connected=false;};xmp.ControlStreamReader.prototype.createPlayableNode=function(sb){var tb=new xmp.util.PlayableNode();tb.setMimeTypes([this.mimeType]);tb.setURI(sb);tb.setStreamingMode(xmp.CONTROL_STREAMING_MODE);xmp.PlayerPolicy.apply(this,tb);return tb;};xmp.ControlStreamReader.prototype.onNativePlayerStateChange=function(ub,vb){try{if(ub===xmp.OPEN){this.state.play(this);this.connected=true;this.listener.onReaderConnected();}
else if(ub===xmp.ENDED){throw new xmp.ControlStreamReaderError("Handling native player state change.","Control stream ended.");}}
catch(e){this._handleError("Handling native player state change.",e);}};xmp.ControlStreamReader.prototype.onNativePlayerTrigger=function(wb,xb){try{this.listener.onReaderTrigger(wb,xb);}
catch(e){this._handleError("Forwarding trigger to listener.",e);}};xmp.ControlStreamReader.prototype.onNativePlayerError=function(e){this._handleError("Forwarding native player error to listener.",e);};xmp.ControlStreamReader.prototype.onNativePlayerTimelineChange=function(yb,zb){};xmp.ControlStreamReader.prototype.onNativePlayerCreated=function(Ab,Bb){if(this.state.type===xmp.ERRORS){return;}
this.state.open(this,Bb.node);};xmp.ControlStreamReader.prototype.onNativePlayerExecuteCommand=function(Cb,Db){return null;};xmp.ControlStreamReader.prototype.onViewportOpened=function(Eb,Fb){Fb.data.viewport=Eb;Fb.player.create(Fb.data);this.player=Fb.player;};xmp.ControlStreamReader.prototype.onCreateViewport=function(Gb,Hb,Ib,Jb){var Kb=document.createElement("div");Kb.setAttribute(xmp.ID_ATTRIBUTE,Hb);Kb.setAttribute(xmp.NAME_ATTRIBUTE,Hb);Kb.style.width="1px";Kb.style.height="1px";xmp.insertDomChildBefore(document.body,Kb,document.body.firstChild);return Kb;};xmp.ControlStreamReader.prototype.onDestroyViewport=function(Lb,Mb){var Nb=xmp.findDomElement(Mb);if(Nb){var Ob=xmp.getDomParent(Nb);Ob.removeChild(Nb);}};xmp.ControlStreamReader.prototype.onViewportCreated=function(Pb,Qb){if(this.state.type===xmp.ERRORS){return;}
if(Qb===null){return;}
this.viewManager.openViewport(this,this.getName(),Pb.mime_type,Qb);};xmp.ControlStreamReader.prototype.onViewportError=function(e){this._handleError("Forwarding viewport error to listener.",e);};xmp.ControlStreamReader.prototype.onError=function(Rb,e){this.listener.onReaderError(e);};xmp.ControlStreamReader.prototype.onPlugInError=function(e){this.listener.onReaderPlugInError(e);};xmp.ControlStreamReader.prototype.onUnsupportedPlatformError=function(e){this.listener.onReaderUnsupportedPlatformError(e);};xmp.ControlStreamReader.prototype._handleError=function(Sb,e){this.connected=false;this.state.error(this);this._setNullPlayer();var Tb=e;if(false===(Tb instanceof xmp.ControlStreamReaderError)){Tb=new xmp.ControlStreamReaderError(((e.context)?e.context:Sb),((e.rawMessage)?e.rawMessage:e.message));Tb.setInnerError(e);}
this.listener.onReaderError(Tb);};xmp.ControlStreamReader.prototype._initNativePlayer=function(Ub){try{this.state.close(this);var Vb=Ub.getMimeType();var Wb=xmp.NativePlayerRegistry.findPlayerByMimeType(this.getName(),Vb);if(!Wb){throw new xmp.InvalidMimeTypeError("Initializing native player..","Unable to find native player for MIME type \""+Vb+"\".");}
var Xb={player:Wb,data:{group:this.getName(),viewport:null,volume:0,mute:true,node:Ub,fullscreenEnabled:false,stretchToFit:false}};if(false===this.viewManager.openViewport(this,this.getName(),Ub.getMimeType(),Xb)){if(Wb.type!==this.player.type){Wb.create({group:this.getName(),viewport:this.viewManager.getActiveViewport(),volume:0,mute:true,node:Ub,fullscreenEnabled:false,stretchToFit:false});this.player=Wb;return true;}
return false;}
return true;}
catch(e){this._setNullPlayer();throw e;}
return false;};xmp.ControlStreamReader.prototype._setNullPlayer=function(){var Yb=xmp.NativePlayerRegistry.findPlayerByMimeType(this.getName(),xmp.NULL_MIME_TYPE);if(this.viewManager.getActiveViewport()===null){this.viewManager.createViewport(this,this.getName(),xmp.NULL_MIME_TYPE,null);}
Yb.create({group:this.getName(),viewport:this.viewManager.getActiveViewport(),volume:0,mute:true,node:null,fullscreenEnabled:false,stretchToFit:false});this.player=Yb;};xmp.ControlStreamReader.prototype.getName=function(){return xmp.CONTROL_STREAM_READER;};xmp.ControlStreamReader.prototype._getPlayer=function(){return this.player;};xmp.ControlStreamReader.prototype._changeState=function(Zb,$b){var ac=this.registry.findMode(Zb);this._transitionState(ac,$b);this.state=ac;};xmp.ControlStreamReader.prototype._transitionState=function(bc,cc){return bc.transition(this,cc,this.state);};xmp.ControlStreamReader.prototype.isConnected=function(){return this.connected;};xmp.ControlStreamReaderFactory=function(){return{createReader:function(dc,ec,fc){if(dc===xmp.WINDOWS_PLATFORM){return new xmp.ControlStreamReader(ec,fc);}
else{return new xmp.NullStreamReader(ec,fc);}}};}();xmp.NullStreamReader=function(gc,hc){};xmp.NullStreamReader.prototype.open=function(ic){return null;};xmp.NullStreamReader.prototype.close=function(){};xmp.NullStreamReader.prototype.isConnected=function(){return false;};xmp.IMAGE_RETRIEVER_NODE_PATH="/PlayerContexts/Global/ImageRetriever";xmp.IMAGE_RETRIEVER_SERVICE="ImageRetriever";xmp.IMAGE_RETRIEVER_REFRESH_INTERVAL="Refresh Interval";xmp.IMAGE_RETRIEVER_START_DELAY="Start Delay";xmp.RESOURCE_NAME="name";xmp.RESOURCE_URL="url";xmp.ImageRetriever=function(){this.listener=null;};xmp.ImageRetriever.prototype.init=function(jc){try{this.logger=new xmp.util.internals.CategoryLogger(xmp.IMAGE_RETRIEVER_SERVICE);this._validateListener(jc);this.listener=jc;this.cacheID=(Math.round(Math.random()*(10000000-1))+1);var kc=xmp.util.SettingsManager.getInstance().getGlobalContextNode().getNodeForPath(xmp.IMAGE_RETRIEVER_NODE_PATH);this._initProperties(kc);this._initResources(kc);this._start();}
catch(e){this._handleError("Initializing.",e);}};xmp.ImageRetriever.prototype.fini=function(){if(this.startDelayTimer){this.startDelayTimer.stop();this.startDelayTimer=null;}
if(this.refreshResourcesTimer){this.refreshResourcesTimer.stop();this.refreshResourcesTimer=null;}};xmp.ImageRetriever.prototype._start=function(){if(0===this.startDelay){this._handleStart();}
else{this.startDelayTimer=this._createTimer({id:xmp.START_DELAY_TIMER,interval:this.startDelay,handler:this._onDelayedStart});this.startDelayTimer.start();}};xmp.ImageRetriever.prototype._handleStart=function(){this.refreshResourcesTimer=this._createTimer({id:xmp.REFRESH_RESOURCE_TIMER,interval:this.refreshInterval,handler:this._onRefreshResources});this.refreshResourcesTimer.start();this._refreshResources();};xmp.ImageRetriever.prototype._validateListener=function(lc){if(!lc){throw new xmp.ImageRetrieverError("Validating listener.","Missing image retriever listener.");}
if(false===xmp.isDefined(lc.onRetrieveImage)){throw new xmp.ImageRetrieverError("Validating listener.","Invalid image retriever listener.  Missing \"onRetrieveImage\" handler.");}
if(false===xmp.isDefined(lc.onImageRetrieverError)){throw new xmp.ImageRetrieverError("Validating listener.","Invalid image retriever listener.  Missing \"onImageRetrieverError\" handler.");}};xmp.ImageRetriever.prototype._validateResource=function(mc){if(mc.name.length===0){throw new xmp.ImageRetrieverError("Validating resource.","Missing image retriever resource name.");}
if(mc.url.length===0){throw new xmp.ImageRetrieverError("Validating resource.","Missing image retriever \""+mc.name+"\" url.");}};xmp.ImageRetriever.prototype._initProperties=function(nc){this.refreshInterval=nc.getInt(xmp.IMAGE_RETRIEVER_REFRESH_INTERVAL,0);if(this.refreshInterval===0){throw new xmp.ImageRetrieverError("Initializing properties.","Missing image retriever refresh interval.");}
this.startDelay=nc.getInt(xmp.IMAGE_RETRIEVER_START_DELAY,0);};xmp.ImageRetriever.prototype._initResources=function(oc){this.resources={};var pc=oc.retrieveChildren();var qc=pc.length;for(var i=0;i<qc;i++){var rc=pc[i];var sc={name:rc.getString(xmp.RESOURCE_NAME,xmp.NO_DEFAULT_VALUE),url:rc.getString(xmp.RESOURCE_URL,xmp.NO_DEFAULT_VALUE)};this._validateResource(sc);this.resources[sc.name]=sc;}};xmp.ImageRetriever.prototype._refreshResources=function(){try{var tc=xmp.getImageRoot();var uc=this._newCacheId();for(var vc=xmp.MapIterator.create(this.resources);vc.hasNext();vc.next()){try{var wc=vc.currentValue();var xc=tc+wc.url+"?"+uc;this.listener.onRetrieveImage(wc.name,xc);this.logger.info((new Date()).toString()+" - Image resource \""+wc.name+"\" retrieval refresh ("+uc+").");}
catch(e){var yc="";if(e instanceof xmp.ImageRetrieverError){yc=e.message;}
else{yc="Error retrieving image resource \""+wc.name+"\" from url \""+xc+"\". \n\n"+e.message;}
this.logger.warn(yc);}}}
catch(e2){this._handleError("Refreshing all resources.",e2);}};xmp.ImageRetriever.prototype._createTimer=function(zc){var Ac=new xmp.util.Callback(zc.id,zc.handler,this);return new xmp.util.Timer(zc.id,zc.interval,-1,Ac);};xmp.ImageRetriever.prototype._onRefreshResources=function(Bc,Cc){this._refreshResources();};xmp.ImageRetriever.prototype._handleError=function(Dc,e){var Ec=e;if(false===(Ec instanceof xmp.ImageRetrieverError)){Ec=new xmp.ImageRetrieverError(((e.context)?e.context:Dc),((e.rawMessage)?e.rawMessage:e.message));Ec.setInnerError(e);}
this._logError(Ec);if(!this.listener){xmp.handleFatalError(Ec);}
else if(true===xmp.isDefined(this.listener.onImageRetrieverError)){this.listener.onImageRetrieverError(Ec);}};xmp.ImageRetriever.prototype._logError=function(e){this.logger.warn(e.message);};xmp.ImageRetriever.prototype._onDelayedStart=function(Fc,Gc){var Hc="";try{this.startDelayTimer.stop();this.startDelayTimer=null;this._handleStart();}
catch(e){this._handleError("Starting after delay.",e);}};xmp.ImageRetriever.prototype._newCacheId=function(){return"cacheID="+this.cacheID++;};xmp.ServiceRegistry=function(){var Ic={};return{getService:function(Jc){if(!Jc){throw new xmp.util.internals.InvalidArgsError("Missing service name.");}
if(!this.services){this.services={};}
var Kc=this.services[Jc];if(Kc){return Kc;}
if(Jc===xmp.CONTROL_STREAM_SERVICE){Kc=new xmp.ControlStream();this.services[Jc]=Kc;return Kc;}
else if(Jc===xmp.IMAGE_RETRIEVER_SERVICE){Kc=new xmp.ImageRetriever();this.services[Jc]=Kc;return Kc;}
throw new xmp.ServiceError("Retrieving service.","Unable to create service \""+Jc+"\".");},init:function(Lc,Ic){var Mc=Ic.length;for(var i=0;i<Mc;i++){this.getService(Ic[i]).init(Lc);}},fini:function(){for(var Nc=xmp.MapIterator.create(this.services);Nc.hasNext();Nc.next()){var Oc=Nc.currentValue();Oc.fini();}}};}();xmp.ControlStreamError=function(Pc,Qc){xmp.ControlStreamError.ctor.call(this,"ControlStreamError",Pc,Qc);};xmp.DERIVE_CLASS(xmp.util.internals.XMPError,xmp.ControlStreamError);xmp.ControlStreamReaderError=function(Rc,Sc){xmp.ControlStreamReaderError.ctor.call(this,"ControlStreamReaderError",Rc,Sc);};xmp.DERIVE_CLASS(xmp.util.internals.XMPError,xmp.ControlStreamReaderError);xmp.ImageRetrieverError=function(Tc,Uc){xmp.ImageRetrieverError.ctor.call(this,"ImageRetrieverError",Tc,Uc);};xmp.DERIVE_CLASS(xmp.util.internals.XMPError,xmp.ImageRetrieverError);