'use strict';window.navigator.userAgent.match(/Chrome\/([0-9]+)/);var oi=function(a,b){this.type=a;this.entryPoint=b};m("castApp.frontEnd.ExtensionMessage",oi,void 0);var pi=function(a){return"urn:x-cast:com.google.cast."+a},qi=pi("tp.connection"),ri=pi("receiver"),si=pi("media"),ti=pi("webrtc"),ui=Jb({jga:qi,kga:pi("tp.heartbeat"),Bfa:ri,MEDIA:si,Dea:pi("media.universalRemote.optIn"),Ega:ti});var vi=function(a){return"available"==a||"available_rescan"==a};var wi=function(a,b,c,e,f){this.id=a;this.friendlyName=b;this.iconType=c||"generic";this.description=e||null;this.domain=f||null;this.isLaunching_=!1};n.SM=window.localStorage;
var xi=0,zi=function(a){return(a=window.localStorage.getItem(yi(a,!1)))?JSON.parse(a):null},Ai=function(a){return(a=window.localStorage.getItem(yi(a,!0)))?JSON.parse(a):null},Ci=function(a){if(Bi.has(a.ka()))throw Error("Duplicate instance name "+a.ka());Bi.set(a.ka(),a);a.fb()},Ii=function(a){for(var b=0,c=ja(Object.keys(n.SM)),e=c.next();!e.done;e=c.next()){var e=e.value,f=e.length+window.localStorage.getItem(e).length;e.startsWith("mr.")?xi+=f:b+=f}Di=a;(window.localStorage.getItem("version")&&window.localStorage.getItem("version")!==
chrome.runtime.getManifest().version||Ei(a))&&Fi();H(Gi,"initialize: "+xi+" bytes used, "+b+" other bytes");chrome.runtime.onSuspend.addListener(Hi)},Di=null,Gi=E("mr.PersistentDataManager"),Bi=new Map,yi=function(a,b){return"mr."+(b?"persistent.":"temp.")+a.ka()},Ei=function(a){return!!window.localStorage.getItem("mrInstanceId")&&window.localStorage.getItem("mrInstanceId")!==a},Hi=function(){H(Gi,"onSuspend");Ji("version",chrome.runtime.getManifest().version);Di&&Ji("mrInstanceId",Di);Bi.forEach(Ki)},
Ki=function(a){var b=a.getData();b&&b[0]&&Ji(yi(a,!1),JSON.stringify(b[0]));b&&b[1]&&Ji(yi(a,!0),JSON.stringify(b[1]))},Ji=function(a,b){var c;c=window.localStorage.getItem(a);c=void 0!=c?b.length-c.length:a.length+b.length;52E5<=xi+c&&(G(Gi,"Unable to write "+c+" bytes"),Fi());52E5<=xi+c?F(Gi,"Unable to write "+c+" bytes after clearing temporary"):(window.localStorage.setItem(a,b),xi+=c)},Fi=function(){for(var a=ja(Object.keys(n.SM)),b=a.next();!b.done;b=a.next())b=b.value,b.startsWith("mr.temp.")&&
(xi-=b.length+window.localStorage.getItem(b).length,delete window.localStorage[b]);H(Gi,"removeTemporary_: "+xi+" bytes used")};var Mi=function(){this.vz=Ra();this.Yi=new Li(null,null);this.Xi=new Li(null,null);this.qw=[];this.fs=this.Tj=0;Ci(this)};qa(Mi);var Li=function(a,b){this.model=a;this.ip=b};d=Mi.prototype;d.hn=function(a){a=a.toLowerCase();var b=new ji;b.update(a);b.update(this.vz);return"r"+Th(b.digest(),!0)};d.yX=function(){return this.Yi.model?this.Yi:this.Xi.model?this.Xi:new Li(null,null)};d.ka=function(){return"SinkUtils"};
d.getData=function(){return[{recentLaunchedDevice:this.Yi,recentDiscoveredDevice:this.Xi},{receiverIdToken:this.vz,fixedIpList:this.qw.join(","),castControlPort:this.Tj,lastCloudSinkCheckTimeMillis:this.fs}]};
d.fb=function(){var a=zi(this);a&&(this.Yi=a.recentLaunchedDevice||new Li(null,null),this.Xi=a.recentDiscoveredDevice||new Li(null,null));if(a=Ai(this))this.vz=a.receiverIdToken||Ra(),this.qw=a.fixedIpList&&a.fixedIpList.split(",")||[],this.Tj=a.castControlPort||0,this.fs=a.lastCloudSinkCheckTimeMillis||0};var Ni=function(a,b){this.xc=this.Gf=this.Jg=this.tb=this.pa=null;this.Nd=new wi(Mi.N().hn(b),a);this.Pc={};this.$p={};this.dm=!1};d=Ni.prototype;d.Qg=function(){return this.Nd};d.tn=function(){return this.Nd.friendlyName};d.d9=function(a){this.xc=a;return this};d.getId=function(){return this.Nd.id};d.yt=function(a){this.Nd.id=a;return this};d.vM=function(a){this.dm=a;return this};
d.update=function(a){if(this.getId()!=a.getId())return!1;var b=!1;this.Nd.friendlyName!=a.Nd.friendlyName&&(this.Nd.friendlyName=a.Nd.friendlyName,b=!0);this.Jg!=a.Jg&&(this.Jg=a.Jg,b=!0);this.Gf!=a.Gf&&(this.Gf=a.Gf,b=!0);this.pa!=a.pa&&(this.pa=a.pa,b=!0);this.tb!=a.tb&&(this.tb=a.tb,b=!0);return b};d.B8=function(a){this.pa=a;return this};d.Eb=function(){return this.tb};d.Pl=function(a){this.tb=a;return this};d.Y7=function(a){this.Jg=a;return this};d.V7=function(a){this.Gf=a;return this};
d.ie=function(a){return this.Pc[a]||"unknown"};d.$T=function(a){return this.$p[a]||null};d.Vo=function(a,b){this.Pc[a]=b;this.$p[a]=w();return this};d.fN=function(){return"name = "+this.Nd.friendlyName+(this.pa?", ip = "+this.pa:"")+(this.xc?", model = "+this.xc:"")+", apps = "+JSON.stringify(this.Pc)};var Oi=function(a){var b=new Ni(a.Nd.friendlyName,"");b.Nd.id=a.Nd.id;b.pa=a.pa;b.tb=a.tb;b.Jg=a.Jg;b.Gf=a.Gf;b.xc=a.xc;b.Pc=a.Pc;b.$p=a.$p;b.dm=a.dm;return b};var Qi=function(a,b,c,e,f,g){this.Be=new wi(Pi(a),b,this.nG(e));this.xc=c||null;this.xd=e||null;this.pa=f||null;this.tb=g||null;this.Pc={};this.lk=!1},Pi=function(a){return Mi.N().hn(a)},Ri=function(a){if(!a.xc||!a.pa)return null;var b=new Qi(a.Qg().id,a.Qg().friendlyName,a.xc,void 0,a.pa,Mi.N().Tj||8009);b.Be.id=a.Qg().id;b.hA(!0);return b};d=Qi.prototype;
d.update=function(a,b,c,e){var f=!1;this.Be.friendlyName!=a&&(this.Be.friendlyName=a,f=!0);this.pa!=b&&(this.pa=b,f=!0);this.tb!=c&&(this.tb=c,f=!0);this.xd!=e&&(this.xd=e,f=!0);return f};d.Qg=function(){return this.Be};d.tn=function(){return this.Be.friendlyName};d.nG=function(a){return a&1?"cast":a&32?"cast_audio_group":"cast_audio"};d.w7=function(a){this.xd=a;this.Be.iconType=this.nG(this.xd)};d.getId=function(){return this.Be.id};
var Si=function(a){var b=new Qi("",a.friendlyName,a.modelName,a.capabilities,a.ip,a.port);b.Be.id=a.id;b.hA(a.discoveredByDial);b.Pc=a.appStatusMap;for(var c in b.Pc)"unavailable"==b.Pc[c]&&(b.Pc[c]="unavailable_rescan");return b};d=Qi.prototype;d.Eb=function(){return this.tb};d.ie=function(a){return this.Pc[a]||"unknown"};d.Vo=function(a,b){this.Pc[a]=b};
d.fN=function(){return"name = "+this.Be.friendlyName+(this.pa?", ip = "+this.pa:"")+(this.xc?", model = "+this.xc:"")+", capabilities = "+this.xd+", apps = "+JSON.stringify(this.Pc)};d.hA=function(a){this.lk=a};var Ti={xea:0,oea:1},Ui={zga:0,YO:1,Cfa:2},Vi={DIAL:0,Bea:1,Cea:2,tda:3},Wi={Xea:0,TIMEOUT:1,FAILED:2},Xi={RB:0,Mca:1,lda:2,Nda:3,fda:4,Jea:5},Yi=function(a){Fg("MediaRouter.Cast.Session.Ended",a,Ui)},Zi=function(a){Fg("MediaRouter.Cast.Discovery.Type",a,Vi)},$i=function(a){Fg("MediaRouter.Cast.Session.Fail",a,Wi)};var aj=function(a){this.Xf=a};aj.prototype.handleEvent=n;var bj=new Map,cj=new Map,dj=function(a){var b=bj.get(a)||null;if(b)return Promise.resolve(b);b=cj.get(a);b||(b=new ff,cj.set(a,b));return b.promise},ej=function(a){var b=a.Xf;if(bj.has(b))throw Error("Duplicate module "+b);bj.set(b,a);(b=cj.get(b))&&b.resolve(a)};var fj=function(a,b,c,e){for(var f=[],g=3;g<arguments.length;++g)f[g-3]=arguments[g];this.Ib=a;this.Xf=b;this.Zg=!1;this.Da=c;this.X_=f;this.al=this.DS.bind(this)};d=fj.prototype;d.zz=function(){Ci(this);this.Zg&&this.KD()};d.KD=function(){this.Da.addListener.apply(this.Da,[].concat([this.al],ka(this.X_)))};d.register=function(){this.Zg||(this.Zg=!0,this.KD())};d.unregister=function(){this.Zg&&(this.Da.removeListener(this.al),this.Zg=!1)};d.yi=function(){return this.Zg};
d.DS=function(a){for(var b=[],c=0;c<arguments.length;++c)b[c-0]=arguments[c];var e=this;if(c=bj.get(this.Xf)||null)return c.handleEvent.apply(c,[].concat([this.Da],ka(b)));dj(this.Xf).then(function(a){return a.handleEvent.apply(a,[].concat([e.Da],ka(b)))});return this.sS()};d.sS=n;d.ka=function(){return"mr.DeferredEventListener."+this.Ib};d.getData=function(){return[this.Zg]};d.fb=function(){this.Zg=zi(this)};var gj={serviceType:"_googlecast._tcp.local"},hj=null,ij=function(){hj||(hj=new fj("CastMdnsEventListener","mr.cast.SinkDiscoveryService",chrome.mdns.onServiceList,gj));return hj},jj=null,kj=function(){jj||(jj=Ig()?new fj("CastNetworkListChangedEventListener","mr.cast.SinkDiscoveryService",chrome.networkingPrivate.onNetworkListChanged):new fj("CastNetworksChangedEventListener","mr.cast.SinkDiscoveryService",chrome.networkingPrivate.onNetworksChanged));return jj};var lj=function(a,b){this.Xf="mr.cast.SinkDiscoveryService";this.Xc=b;this.KC=a;this.KC.W=this.W.bind(this);this.Yc=new D;this.Wl=new D;this.Yf=new D;this.mI=null;this.Un=this.kh="";this.gk=null;this.zx=this.On=!1;this.a=E("mr.cast.SinkDiscoveryService")};x(lj,aj);d=lj.prototype;d.init=function(){Ci(this);this.On&&(this.TH(),this.CE());ej(this)};d.TH=function(){H(this.a,"Start listening to network changes");kj().register()};
d.start=function(){var a=w(),b=ij();if(b.yi()){if(6E4>a-this.mI)return;H(this.a,"Forcing mdns discovery");this.OT()}else H(this.a,"Adding mdns listener"),b.register();this.mI=a};d.OT=function(){chrome.mdns.forceDiscovery(n);var a=ij();a.unregister();a.register()};
d.handleEvent=function(a,b){for(var c=[],e=1;e<arguments.length;++e)c[e-1]=arguments[e];if(a==chrome.mdns.onServiceList)this.UJ.apply(this,[].concat(ka(c)));else if(a==chrome.networkingPrivate.onNetworksChanged||a==chrome.networkingPrivate.onNetworkListChanged)this.CE();else throw Error("Unhandled event");};
d.eS=function(a){if(-1==a.serviceName.indexOf("._googlecast."))return null;var b={};a.serviceData.forEach(function(a){0==a.search(/[a-z]{2}=.+/)&&(b[a.substring(0,2)]=a.substring(3))});var c=b.id;if(!c)return G(this.a,"Missing ID"),null;var e=Pi(c),f=Number(a.serviceHostPort.substring(a.serviceHostPort.indexOf(":")+1));if(isNaN(f)||0>f||65535<f)return G(this.a,"Missing or invalid port"),null;if(this.Yf.xa(e)){var g=this.Yf.get(e);if(g.pa==a.ipAddress&&g.Eb()==f)return G(this.a,"Sink has pending connection "+
e),null;G(this.a,"Pending sink changed ip "+e);this.Yf.remove(e)}g=b.fn;if(!g||!a.ipAddress)return G(this.a,"Missing friendly name or IP address"),null;var k=Number(b.ca),k=isNaN(k)?0:k;return(e=this.Yc.get(e))?(e.update(g,a.ipAddress,f,k)&&(e.hA(!1),this.Xc.ld(e)),null):new Qi(c,g,b.md||"",k,a.ipAddress,f)};d.refresh=function(){I(this.a,"Executing forceDiscovery.");chrome.mdns.forceDiscovery(n)};d.UJ=function(a){H(this.a,"Registering "+a.length+" devices");this.fS(a).forEach(this.v0,this)};
d.Bv=function(a,b){var c=this;if(!this.Yf.xa(a.getId())){this.Yf.set(a.getId(),a);var e=function(){c.Yf.remove(a.getId());0==c.Yf.R()&&c.Ao()};this.Im(a).then(function(e){e?(e=c.Yc.get(a.getId()),b&&(e?e.lk&&Zi(3):Zi(1)),c.wm(a)):H(c.a,"Inaccessible sink: "+a.getId())}).then(e,e)}};d.v0=function(a){this.Bv(a,!0)};d.fS=function(a){var b=[];a.forEach(function(a){(a=this.eS(a))&&b.push(a)},this);return b};
d.LD=function(a){var b=this.Yc.get(a.getId()),c=null,e=a.pa,f=a.Eb();null!=e&&null!=f&&(c=this.Wl.get(e+":"+f));if(b&&!c){var g=a.pa,k=a.Eb();g&&k&&this.Wl.remove(g+":"+k)}c&&!b&&this.Yc.remove(c.getId());this.Yc.set(a.getId(),a);null!=e&&null!=f&&this.Wl.set(e+":"+f,a)};d.wm=function(a){H(this.a,"Adding sink "+a.getId());this.LD(a);this.On||(this.On=!0,this.TH());this.Xc.Qi(a);Mi.N().Xi=new Li(a.xc,a.pa)};d.Cy=function(a){H(this.a,"Channel error for sink "+a);this.Dl(a)};
d.Dl=function(a){var b=this.Yc.get(a);if(b){H(this.a,"Removing sink "+a);this.Yc.remove(a);a=b.pa;var c=b.Eb();null!=a&&null!=c&&this.Wl.remove(a+":"+c);this.Xc.Gs(b)}};d.k5=function(){var a=this.Yc.C();this.Yc.clear();this.Wl.clear();a.forEach(this.Xc.Gs,this.Xc)};d.Im=function(a){I(this.a,"Checking access to "+a.getId());return this.KC.Zj(a).then(function(b){if(a.lk){var c=4;b.audioOnly||(c|=1);a.w7(c)}return!0},function(){return!1})};
d.Ao=function(){H(this.a,"Pruning inactive sinks.");xc(this.Hn(),function(a){var b=this;this.Yf.set(a.getId(),a);var c=function(){b.Yf.remove(a.getId())};this.Im(a).then(function(c){c||b.Dl(a.getId())}).then(c,c)},this)};d.W=function(a){return this.Yc.get(a,null)};d.eY=function(a,b){return this.Wl.get(a+":"+b)};d.fY=function(a){var b=[];xc(this.Hn(),function(c){vi(c.ie(a))&&b.push(c)});return b};d.Hn=function(){return this.Yc.qx()};d.ld=function(a){this.Xc.ld(a)};d.Kc=function(){return this.Yc.C()};
var mj=function(a,b){this.sinkMap=a;this.networkIds=b;this.version=3},nj=function(a){this.hasSavedSinks=a};d=lj.prototype;d.ka=function(){return"cast.SinkDiscoveryService"};d.getData=function(){var a={};xc(this.Yc.yF(),function(b){var c;c=this.Yc.get(b);c={id:c.getId(),ip:c.pa,port:c.Eb(),friendlyName:c.tn(),modelName:c.xc,capabilities:c.xd,discoveredByDial:c.lk,appStatusMap:c.Pc};a[b]=c},this);return[new mj(a,this.Un),new nj(this.On)]};
d.fb=function(){var a=zi(this);a&&3==a.version&&(this.Un=a.networkIds,this.a_(a.sinkMap));if(a=Ai(this))this.On=a.hasSavedSinks};d.a_=function(a){this.zx=0<Object.keys(a).length;for(var b in a){var c=Si(a[b]);this.W(c.getId())||this.LD(c)}this.Ao()};d.c0=function(a){this.zx=0<Object.keys(a).length;for(var b in a){var c=Si(a[b]);this.W(c.getId())||this.Bv(c,!1)}};
d.CE=function(){H(this.a,"Fetching networks state");this.gk&&Ki(this.gk);chrome.networkingPrivate.getNetworks({networkType:"All",visible:!0,configured:!0},function(a){for(var b=[],c=0;c<a.length;c++)"Connected"==a[c].ConnectionState&&b.push(a[c].GUID);this.Dba(b.sort().join(","))}.bind(this))};
d.Dba=function(a){H(this.a,"Update current network "+oj(a));a!=this.kh&&(this.gk&&(Bi.delete(this.gk.ka()),this.gk=null),a?(this.Un&&a!=this.Un?this.k5():this.Ao(),this.Un=this.kh=a,this.gk=new pj(this,this.kh)):this.kh="")};var oj=function(a){for(var b=0,c=0;c<a.length;c++)b+=a.charCodeAt(c);return b},pj=function(a,b){this.rd=a;this.kh=b;Ci(this)};pj.prototype.ka=function(){return"cast.NetworkSink."+this.kh};
pj.prototype.getData=function(){var a=null,b=this.rd.getData();b&&(this.rd.zx||0<this.rd.Kc().length)&&(a=b[0]);H(this.rd.a,"Saving sink data for network "+oj(this.kh));return[null,a]};pj.prototype.fb=function(){H(this.rd.a,"Restoring sink data for network "+oj(this.kh));var a=Ai(this);a&&3==a.version&&this.rd.c0(a.sinkMap)};var qj={STOP_MEDIA:"STOP",MEDIA_SET_VOLUME:"SET_VOLUME",MEDIA_GET_STATUS:"GET_STATUS"};var rj=function(){this.type="GET_STATUS";this.requestId=0};var sj=function(a){this.type="LAUNCH";this.requestId=0;this.appId=a;this.language=null};var tj=function(a){this.type="STOP";this.requestId=0;this.sessionId=a||null};var uj=function(a,b){this.requestId=a;this.kba=b;this.eN=null};uj.prototype.Fy=function(){};var vj=function(){this.$b=new D};vj.prototype.dC=function(a){this.$b.set(a.requestId,a);a.eN=setTimeout(this.I2.bind(this,a),a.kba)};vj.prototype.Io=function(a){var b=this.$b.get(a);if(!b)return null;clearTimeout(b.eN);this.$b.remove(a);return b};vj.prototype.oi=function(a){return this.$b.get(a,null)};vj.prototype.I2=function(a){this.$b.remove(a.requestId);a.Fy()};var wj=function(a){this.Uaa=a;this.nl=1E3*Math.floor(1E6*Math.random())};d=wj.prototype;d.VD=function(){Ci(this)};d.wr=function(){var a=this.nl++;0==a&&(a=this.nl++);return a};d.ka=function(){return"IdGenerator."+this.Uaa};d.getData=function(){return[this.nl]};d.fb=function(){var a=zi(this);a&&(this.nl=a)};var xj=function(a,b){this.Rc=a;this.qd=b;this.Ti=new vj;this.jK=new wj("cast.RequestIdGenerator")};d=xj.prototype;d.init=function(){this.jK.VD()};d.eC=function(a,b,c){var e=this.jK.wr();a.requestId=e;a=new ff;b=new yj(e,a,u(b)&&0<b?b:6E5,c);this.Ti.dC(b);return b};d.Fz=function(a){this.Ti.Io(a.requestId)};d.Io=function(a){return this.Ti.Io(a)};
d.sendRequest=function(a,b,c,e,f,g){var k=this;if(!ui.hasOwnProperty(c))return Promise.reject(Error("Custom namespace is not supported"));var p=this.eC(a,l(e)?e:3E3,f),q=p.vb;this.Rc.ot(b,c,a,f||this.qd,g).then(null,function(){k.Fz(p);q.reject(zj)});return q.promise};d.sendMessage=function(a,b,c,e,f,g){var k=this,p=this.eC(a,l(e)?e:3E3,f),q=p.vb;this.Rc.ot(b,c,a,f||this.qd,g).then(function(){k.Fz(p);q.resolve(!0)},function(){k.Fz(p);q.reject(zj)});return q.promise};
d.J5=function(a,b){var c=new sj(a.appId);c.language=a.language?a.language:chrome.i18n.getUILanguage?chrome.i18n.getUILanguage():chrome.runtime.getManifest().default_locale;return this.sendRequest(c,b,ri,a.requestSessionTimeout)};d.K5=function(a,b){return this.sendRequest(new tj(a),b,ri)};var Aj=Error("Timeout"),zj=Error("Failed to send message"),yj=function(a,b,c,e){uj.call(this,a,c);this.vb=b;this.sourceId=e};la(yj,uj);yj.prototype.Fy=function(){this.vb.reject(Aj)};var Bj=function(a,b){this.type="cast_app";this.originId=window["castApp.eventPage.Message.OriginID"]||void 0;this.subtype=a;this.devices=b;this.deviceJustSetUp=void 0};m("castApp.eventPage.Message",Bj,void 0);var Cj=function(a,b,c){this.ipAddress=a;this.appId=b;this.sessionId=c};Bj.DeviceData=Cj;Bj.DeviceJustSetUp=function(a,b,c,e){this.ipAddress=a;this.name=b;this.udn=c;this.modelName=e};var Dj=function(a,b){this.Dc=a;this.zd=b;this.kk=new D;this.jk=new Jc;this.HH=0;this.F0=new D("serviceCheck",this.sZ.bind(this),"startDeviceMonitor",this.FZ.bind(this),"releaseDeviceMonitor",this.nZ.bind(this),"deviceJustSetUp",this.ZY.bind(this));chrome.runtime.onMessage.addListener(this.iZ.bind(this));chrome.runtime.onMessageExternal.addListener(this.bZ.bind(this));this.gf("serviceReady")};d=Dj.prototype;d.a=E("castApp.eventPage.Service");d.DO=3E4;d.fO=52;d.eO=53;
d.yZ=function(){if(this.PC()){var a=new Jc;xc(this.Dc.Hn(),function(b){var c=b.pa;a.add(c);this.kk.xa(c)||this.zd.sendRequest(new rj,b,ri)}.bind(this));var b=!1;this.kk.ib().forEach(function(c){a.contains(c)||(this.kk.remove(c),b=!0)}.bind(this));b&&this.mv()}};
d.UY=function(a,b){if(this.PC()&&ui.hasOwnProperty(b.namespace_)&&(a=a.pa)&&(b=JSON.parse(b.data),"RECEIVER_STATUS"===b.type)){var c=b.status&&b.status.applications&&b.status.applications[0],e=b=null;c&&(c.appId&&(b=c.appId),c.sessionId&&(e=c.sessionId));c=this.kk.get(a);this.kk.set(a,new Cj(a,b,e));c&&c.appId===b||this.mv()}};
d.PC=function(){if(0===this.jk.R())return!1;var a=w();a-this.HH>this.DO&&(this.HH=a,chrome.tabs.query({url:["chrome://cast/*","chrome-extension://"+chrome.runtime.id+"/cast_setup/*"]},function(a){0===a.length?(H(this.a,"No tabs found. Clearing device monitor clients."),this.jk.clear()):H(this.a,"Tab check found active tabs: "+a.map(function(a){return a.id}))}.bind(this)));a=this.jk.R();H(this.a,"Monitor client count: "+a);return 0<a};
d.iZ=function(a,b,c){if("object"!==typeof a||"cast_app"!==a.type)return!1;var e=this.F0.get(a.subtype);if(!e)return!1;if(!a.originId)return y("Missing origin ID in the incoming message."),!1;try{var f=e(a,b,c);f&&c(f)}catch(g){F(this.a,"Error while handling request",g)}return!1};d.gf=function(a,b){a=new Bj(a,b);H(this.a,"Sending message: "+JSON.stringify(a));chrome.runtime.sendMessage(a)};d.sZ=function(){this.gf("serviceReady")};
d.FZ=function(a){this.jk.contains(a.originId)?H(this.a,"Client: "+a.originId+"already registered, dispatching current device list."):(H(this.a,"Registering monitor client: "+a.originId),this.jk.add(a.originId));this.mv();this.X4()};d.nZ=function(a){H(this.a,"Unregistering monitor client: "+a.originId);this.jk.remove(a.originId)};d.ZY=function(a){a=a.deviceJustSetUp;var b=a.udn.replace(/-/g,"").toLowerCase();a=new Qi(b,a.name,a.modelName,void 0,a.ipAddress,Mi.N().Tj||8009);this.Dc.Bv(a,!0)};
d.mv=function(){var a=this.kk.C();this.gf("devices",a)};d.X4=function(){this.Dc.refresh();this.Dc.Kc().forEach(function(a){this.zd.sendRequest(new rj,a,ri)}.bind(this))};
d.bZ=function(a,b,c){switch(a.type){case "handshake":c(new oi("handshake"));break;case "launch":b=b.tab&&u(b.tab.id)?b.tab.id:null,null===b||"setup"!==a.entryPoint&&"offers"!==a.entryPoint&&"devices"!==a.entryPoint||(a=0<=Ta(hi,this.eO)?"chrome://cast#"+a.entryPoint:0<=Ta(hi,this.fO)?"chrome-extension://"+chrome.runtime.id+"/cast_setup/index.html#"+a.entryPoint:"chrome-extension://"+chrome.runtime.id+"/cast_setup/"+a.entryPoint+".html",chrome.tabs.update(b,{url:a}))}};chrome.cast.nf={CUSTOM_CONTROLLER_SCOPED:"custom_controller_scoped",TAB_AND_ORIGIN_SCOPED:"tab_and_origin_scoped",ORIGIN_SCOPED:"origin_scoped",PAGE_SCOPED:"page_scoped"};m("chrome.cast.AutoJoinPolicy",chrome.cast.nf,void 0);chrome.cast.Mp={CREATE_SESSION:"create_session",CAST_THIS_TAB:"cast_this_tab"};m("chrome.cast.DefaultActionPolicy",chrome.cast.Mp,void 0);chrome.cast.ug={VIDEO_OUT:"video_out",AUDIO_OUT:"audio_out",VIDEO_IN:"video_in",AUDIO_IN:"audio_in",MULTIZONE_GROUP:"multizone_group"};
m("chrome.cast.Capability",chrome.cast.ug,void 0);chrome.cast.pf={CANCEL:"cancel",TIMEOUT:"timeout",API_NOT_INITIALIZED:"api_not_initialized",INVALID_PARAMETER:"invalid_parameter",EXTENSION_NOT_COMPATIBLE:"extension_not_compatible",EXTENSION_MISSING:"extension_missing",RECEIVER_UNAVAILABLE:"receiver_unavailable",SESSION_ERROR:"session_error",CHANNEL_ERROR:"channel_error",LOAD_MEDIA_FAILED:"load_media_failed"};m("chrome.cast.ErrorCode",chrome.cast.pf,void 0);chrome.cast.ZO={AVAILABLE:"available",UNAVAILABLE:"unavailable"};
m("chrome.cast.ReceiverAvailability",chrome.cast.ZO,void 0);chrome.cast.kP={CHROME:"chrome",IOS:"ios",ANDROID:"android"};m("chrome.cast.SenderPlatform",chrome.cast.kP,void 0);chrome.cast.Op={CAST:"cast",DIAL:"dial",HANGOUT:"hangout",CUSTOM:"custom"};m("chrome.cast.ReceiverType",chrome.cast.Op,void 0);chrome.cast.mO={RUNNING:"running",STOPPED:"stopped",ERROR:"error"};m("chrome.cast.DialAppState",chrome.cast.mO,void 0);chrome.cast.um={CAST:"cast",STOP:"stop"};
m("chrome.cast.ReceiverAction",chrome.cast.um,void 0);chrome.cast.NB={CONNECTED:"connected",DISCONNECTED:"disconnected",STOPPED:"stopped"};m("chrome.cast.SessionStatus",chrome.cast.NB,void 0);chrome.cast.VERSION=[1,2];m("chrome.cast.VERSION",chrome.cast.VERSION,void 0);chrome.cast.bca=!0;m("chrome.cast.usingPresentationApi",chrome.cast.bca,void 0);chrome.cast.Error=function(a,b,c){this.code=a;this.description=b||null;this.details=c||null};m("chrome.cast.Error",chrome.cast.Error,void 0);chrome.cast.jP=function(a){this.platform=a;this.packageId=this.url=null};m("chrome.cast.SenderApplication",chrome.cast.jP,void 0);chrome.cast.Image=function(a){this.url=a;this.width=this.height=null};
m("chrome.cast.Image",chrome.cast.Image,void 0);chrome.cast.Volume=function(a,b){this.level=l(a)?a:null;this.muted=l(b)?b:null};m("chrome.cast.Volume",chrome.cast.Volume,void 0);chrome.cast.cO=function(a,b,c,e,f){this.sessionRequest=a;this.sessionListener=b;this.receiverListener=c;this.autoJoinPolicy=e||chrome.cast.nf.TAB_AND_ORIGIN_SCOPED;this.defaultActionPolicy=f||chrome.cast.Mp.CREATE_SESSION;this.customDialLaunchCallback=null;this.invisibleSender=!1;this.additionalSessionRequests=[]};m("chrome.cast.ApiConfig",chrome.cast.cO,void 0);chrome.cast.oO=function(a,b){this.appName=a;this.launchParameter=b||null};m("chrome.cast.DialRequest",chrome.cast.oO,void 0);
chrome.cast.FB=function(a,b,c){this.receiver=a;this.appState=b;this.extraData=c||null};m("chrome.cast.DialLaunchData",chrome.cast.FB,void 0);chrome.cast.nO=function(a,b){this.doLaunch=a;this.launchParameter=b||null};m("chrome.cast.DialLaunchResponse",chrome.cast.nO,void 0);chrome.cast.MB=function(a,b,c){this.appId=a;this.capabilities=ta(b)?b:[chrome.cast.ug.VIDEO_OUT,chrome.cast.ug.AUDIO_OUT];this.requestSessionTimeout=c||chrome.cast.timeout.requestSession;this.dialRequest=this.language=null};
m("chrome.cast.SessionRequest",chrome.cast.MB,void 0);
chrome.cast.Fu=function(a,b,c,e){this.label=a;a=b;Oa.test(a)&&(-1!=a.indexOf("&")&&(a=a.replace(Ia,"&amp;")),-1!=a.indexOf("<")&&(a=a.replace(Ja,"&lt;")),-1!=a.indexOf(">")&&(a=a.replace(Ka,"&gt;")),-1!=a.indexOf('"')&&(a=a.replace(La,"&quot;")),-1!=a.indexOf("'")&&(a=a.replace(Ma,"&#39;")),-1!=a.indexOf("\x00")&&(a=a.replace(Na,"&#0;")));this.friendlyName=a;this.capabilities=c||[];this.volume=e||null;this.receiverType=chrome.cast.Op.CAST;this.displayStatus=this.isActiveInput=null};
m("chrome.cast.Receiver",chrome.cast.Fu,void 0);chrome.cast.$O=function(a,b){this.statusText=a;this.appImages=b;this.showStop=null};m("chrome.cast.ReceiverDisplayStatus",chrome.cast.$O,void 0);chrome.cast.QB=function(){this.requestSession=6E4;this.sendCustomMessage=this.setReceiverVolume=this.stopSession=this.leaveSession=3E3};m("chrome.cast.Timeout",chrome.cast.QB,void 0);chrome.cast.timeout=new chrome.cast.QB;m("chrome.cast.timeout",chrome.cast.timeout,void 0);chrome.cast.bO="auto-join";
chrome.cast.KB="cast-session_";chrome.cast.media.tm={PAUSE:"pause",SEEK:"seek",STREAM_VOLUME:"stream_volume",STREAM_MUTE:"stream_mute"};m("chrome.cast.media.MediaCommand",chrome.cast.media.tm,void 0);chrome.cast.media.Yd={GENERIC:0,MOVIE:1,TV_SHOW:2,MUSIC_TRACK:3,PHOTO:4};m("chrome.cast.media.MetadataType",chrome.cast.media.Yd,void 0);chrome.cast.media.Np={IDLE:"IDLE",PLAYING:"PLAYING",PAUSED:"PAUSED",BUFFERING:"BUFFERING"};m("chrome.cast.media.PlayerState",chrome.cast.media.Np,void 0);
chrome.cast.media.Gu={OFF:"REPEAT_OFF",ALL:"REPEAT_ALL",SINGLE:"REPEAT_SINGLE",ALL_AND_SHUFFLE:"REPEAT_ALL_AND_SHUFFLE"};m("chrome.cast.media.RepeatMode",chrome.cast.media.Gu,void 0);chrome.cast.media.aP={PLAYBACK_START:"PLAYBACK_START",PLAYBACK_PAUSE:"PLAYBACK_PAUSE"};m("chrome.cast.media.ResumeState",chrome.cast.media.aP,void 0);chrome.cast.media.OB={BUFFERED:"BUFFERED",LIVE:"LIVE",OTHER:"OTHER"};m("chrome.cast.media.StreamType",chrome.cast.media.OB,void 0);
chrome.cast.media.vO={CANCELLED:"CANCELLED",INTERRUPTED:"INTERRUPTED",FINISHED:"FINISHED",ERROR:"ERROR"};m("chrome.cast.media.IdleReason",chrome.cast.media.vO,void 0);chrome.cast.media.wP={TEXT:"TEXT",AUDIO:"AUDIO",VIDEO:"VIDEO"};m("chrome.cast.media.TrackType",chrome.cast.media.wP,void 0);chrome.cast.media.tP={SUBTITLES:"SUBTITLES",CAPTIONS:"CAPTIONS",DESCRIPTIONS:"DESCRIPTIONS",CHAPTERS:"CHAPTERS",METADATA:"METADATA"};m("chrome.cast.media.TextTrackType",chrome.cast.media.tP,void 0);
chrome.cast.media.pP={NONE:"NONE",OUTLINE:"OUTLINE",DROP_SHADOW:"DROP_SHADOW",RAISED:"RAISED",DEPRESSED:"DEPRESSED"};m("chrome.cast.media.TextTrackEdgeType",chrome.cast.media.pP,void 0);chrome.cast.media.uP={NONE:"NONE",NORMAL:"NORMAL",ROUNDED_CORNERS:"ROUNDED_CORNERS"};m("chrome.cast.media.TextTrackWindowType",chrome.cast.media.uP,void 0);
chrome.cast.media.qP={SANS_SERIF:"SANS_SERIF",MONOSPACED_SANS_SERIF:"MONOSPACED_SANS_SERIF",SERIF:"SERIF",MONOSPACED_SERIF:"MONOSPACED_SERIF",CASUAL:"CASUAL",CURSIVE:"CURSIVE",SMALL_CAPITALS:"SMALL_CAPITALS"};m("chrome.cast.media.TextTrackFontGenericFamily",chrome.cast.media.qP,void 0);chrome.cast.media.rP={NORMAL:"NORMAL",BOLD:"BOLD",BOLD_ITALIC:"BOLD_ITALIC",ITALIC:"ITALIC"};m("chrome.cast.media.TextTrackFontStyle",chrome.cast.media.rP,void 0);chrome.cast.media.sO=function(){this.customData=null};m("chrome.cast.media.GetStatusRequest",chrome.cast.media.sO,void 0);chrome.cast.media.MO=function(){this.customData=null};m("chrome.cast.media.PauseRequest",chrome.cast.media.MO,void 0);chrome.cast.media.OO=function(){this.customData=null};m("chrome.cast.media.PlayRequest",chrome.cast.media.OO,void 0);chrome.cast.media.iP=function(){this.customData=this.resumeState=this.currentTime=null};m("chrome.cast.media.SeekRequest",chrome.cast.media.iP,void 0);
chrome.cast.media.lP=function(){this.customData=null};m("chrome.cast.media.StopRequest",chrome.cast.media.lP,void 0);chrome.cast.media.zP=function(a){this.volume=a;this.customData=null};m("chrome.cast.media.VolumeRequest",chrome.cast.media.zP,void 0);chrome.cast.media.yO=function(a){this.type="LOAD";this.requestId=0;this.sessionId=null;this.media=a;this.activeTrackIds=null;this.autoplay=!0;this.customData=this.currentTime=null};m("chrome.cast.media.LoadRequest",chrome.cast.media.yO,void 0);
chrome.cast.media.qO=function(a,b){this.requestId=0;this.activeTrackIds=a||null;this.textTrackStyle=b||null};m("chrome.cast.media.EditTracksInfoRequest",chrome.cast.media.qO,void 0);chrome.cast.media.rO=function(){this.metadataType=this.type=chrome.cast.media.Yd.GENERIC;this.releaseDate=this.releaseYear=this.images=this.subtitle=this.title=null};m("chrome.cast.media.GenericMediaMetadata",chrome.cast.media.rO,void 0);
chrome.cast.media.FO=function(){this.metadataType=this.type=chrome.cast.media.Yd.MOVIE;this.releaseDate=this.releaseYear=this.images=this.subtitle=this.studio=this.title=null};m("chrome.cast.media.MovieMediaMetadata",chrome.cast.media.FO,void 0);chrome.cast.media.xP=function(){this.metadataType=this.type=chrome.cast.media.Yd.TV_SHOW;this.originalAirdate=this.releaseYear=this.images=this.episode=this.episodeNumber=this.season=this.seasonNumber=this.episodeTitle=this.title=this.seriesTitle=null};
m("chrome.cast.media.TvShowMediaMetadata",chrome.cast.media.xP,void 0);chrome.cast.media.GO=function(){this.metadataType=this.type=chrome.cast.media.Yd.MUSIC_TRACK;this.releaseDate=this.releaseYear=this.images=this.discNumber=this.trackNumber=this.artistName=this.songName=this.composer=this.artist=this.albumArtist=this.title=this.albumName=null};m("chrome.cast.media.MusicTrackMediaMetadata",chrome.cast.media.GO,void 0);
chrome.cast.media.NO=function(){this.metadataType=this.type=chrome.cast.media.Yd.PHOTO;this.creationDateTime=this.height=this.width=this.longitude=this.latitude=this.images=this.location=this.artist=this.title=null};m("chrome.cast.media.PhotoMediaMetadata",chrome.cast.media.NO,void 0);chrome.cast.media.EO=function(a,b){this.contentId=a;this.streamType=chrome.cast.media.OB.BUFFERED;this.contentType=b;this.customData=this.textTrackStyle=this.tracks=this.duration=this.metadata=null};
m("chrome.cast.media.MediaInfo",chrome.cast.media.EO,void 0);chrome.cast.media.QO=function(a){this.itemId=null;this.media=a;this.autoplay=!0;this.startTime=0;this.playbackDuration=null;this.preloadTime=0;this.customData=this.activeTrackIds=null};m("chrome.cast.media.QueueItem",chrome.cast.media.QO,void 0);chrome.cast.media.kO="CC1AD845";m("chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID",chrome.cast.media.kO,void 0);chrome.cast.media.timeout={};
m("chrome.cast.media.timeout",chrome.cast.media.timeout,void 0);chrome.cast.media.timeout.load=0;chrome.cast.media.timeout.load=chrome.cast.media.timeout.load;chrome.cast.media.timeout.eb=0;chrome.cast.media.timeout.getStatus=chrome.cast.media.timeout.eb;chrome.cast.media.timeout.play=0;chrome.cast.media.timeout.play=chrome.cast.media.timeout.play;chrome.cast.media.timeout.pause=0;chrome.cast.media.timeout.pause=chrome.cast.media.timeout.pause;chrome.cast.media.timeout.seek=0;
chrome.cast.media.timeout.seek=chrome.cast.media.timeout.seek;chrome.cast.media.timeout.stop=0;chrome.cast.media.timeout.stop=chrome.cast.media.timeout.stop;chrome.cast.media.timeout.Rl=0;chrome.cast.media.timeout.setVolume=chrome.cast.media.timeout.Rl;chrome.cast.media.timeout.cw=0;chrome.cast.media.timeout.editTracksInfo=chrome.cast.media.timeout.cw;chrome.cast.media.timeout.w4=0;chrome.cast.media.timeout.queue=chrome.cast.media.timeout.w4;
chrome.cast.media.vP=function(a,b){this.trackId=a;this.trackContentType=this.trackContentId=null;this.type=b;this.customData=this.subtype=this.language=this.name=null};m("chrome.cast.media.Track",chrome.cast.media.vP,void 0);chrome.cast.media.sP=function(){this.customData=this.fontStyle=this.fontGenericFamily=this.fontFamily=this.fontScale=this.windowRoundedCornerRadius=this.windowColor=this.windowType=this.edgeColor=this.edgeType=this.backgroundColor=this.foregroundColor=null};
m("chrome.cast.media.TextTrackStyle",chrome.cast.media.sP,void 0);chrome.cast.media.SO=function(a){this.type="QUEUE_LOAD";this.sessionId=this.requestId=null;this.items=a;this.startIndex=0;this.repeatMode=chrome.cast.media.Gu.OFF;this.customData=null};m("chrome.cast.media.QueueLoadRequest",chrome.cast.media.SO,void 0);chrome.cast.media.PO=function(a){this.type="QUEUE_INSERT";this.sessionId=this.requestId=null;this.items=a;this.customData=this.insertBefore=null};
m("chrome.cast.media.QueueInsertItemsRequest",chrome.cast.media.PO,void 0);chrome.cast.media.WO=function(a){this.type="QUEUE_UPDATE";this.sessionId=this.requestId=null;this.items=a;this.customData=null};m("chrome.cast.media.QueueUpdateItemsRequest",chrome.cast.media.WO,void 0);chrome.cast.media.RO=function(){this.type="QUEUE_UPDATE";this.customData=this.jump=this.currentItemId=this.sessionId=this.requestId=null};m("chrome.cast.media.QueueJumpRequest",chrome.cast.media.RO,void 0);
chrome.cast.media.VO=function(){this.type="QUEUE_UPDATE";this.customData=this.repeatMode=this.sessionId=this.requestId=null};m("chrome.cast.media.QueueSetPropertiesRequest",chrome.cast.media.VO,void 0);chrome.cast.media.TO=function(a){this.type="QUEUE_REMOVE";this.sessionId=this.requestId=null;this.itemIds=a;this.customData=null};m("chrome.cast.media.QueueRemoveItemsRequest",chrome.cast.media.TO,void 0);
chrome.cast.media.UO=function(a){this.type="QUEUE_REORDER";this.sessionId=this.requestId=null;this.itemIds=a;this.customData=this.insertBefore=null};m("chrome.cast.media.QueueReorderItemsRequest",chrome.cast.media.UO,void 0);chrome.cast.media.u=function(a,b){this.sessionId=a;this.mediaSessionId=b;this.media=null;this.playbackRate=1;this.playerState=chrome.cast.media.Np.IDLE;this.currentTime=0;this.CH=-1;this.supportedMediaCommands=[];this.volume=new chrome.cast.Volume;this.items=this.preloadedItemId=this.loadingItemId=this.currentItemId=this.customData=this.activeTrackIds=this.idleReason=null;this.repeatMode=chrome.cast.media.Gu.OFF};m("chrome.cast.media.Media",chrome.cast.media.u,void 0);
chrome.cast.media.u.prototype.eb=function(){};chrome.cast.media.u.prototype.getStatus=chrome.cast.media.u.prototype.eb;chrome.cast.media.u.prototype.play=function(){};chrome.cast.media.u.prototype.play=chrome.cast.media.u.prototype.play;chrome.cast.media.u.prototype.X3=function(){};chrome.cast.media.u.prototype.playWithContext=chrome.cast.media.u.prototype.X3;chrome.cast.media.u.prototype.pause=function(){};chrome.cast.media.u.prototype.pause=chrome.cast.media.u.prototype.pause;
chrome.cast.media.u.prototype.R3=function(){};chrome.cast.media.u.prototype.pauseWithContext=chrome.cast.media.u.prototype.R3;chrome.cast.media.u.prototype.seek=function(){};chrome.cast.media.u.prototype.seek=chrome.cast.media.u.prototype.seek;chrome.cast.media.u.prototype.stop=function(){};chrome.cast.media.u.prototype.stop=chrome.cast.media.u.prototype.stop;chrome.cast.media.u.prototype.Rl=function(){};chrome.cast.media.u.prototype.setVolume=chrome.cast.media.u.prototype.Rl;
chrome.cast.media.u.prototype.cw=function(){};chrome.cast.media.u.prototype.editTracksInfo=chrome.cast.media.u.prototype.cw;chrome.cast.media.u.prototype.z4=function(){};chrome.cast.media.u.prototype.queueInsertItems=chrome.cast.media.u.prototype.z4;chrome.cast.media.u.prototype.x4=function(){};chrome.cast.media.u.prototype.queueAppendItem=chrome.cast.media.u.prototype.x4;chrome.cast.media.u.prototype.J4=function(){};chrome.cast.media.u.prototype.queueUpdateItems=chrome.cast.media.u.prototype.J4;
chrome.cast.media.u.prototype.E4=function(){};chrome.cast.media.u.prototype.queuePrev=chrome.cast.media.u.prototype.E4;chrome.cast.media.u.prototype.D4=function(){};chrome.cast.media.u.prototype.queueNext=chrome.cast.media.u.prototype.D4;chrome.cast.media.u.prototype.A4=function(a){this.Pw(a)};chrome.cast.media.u.prototype.queueJumpToItem=chrome.cast.media.u.prototype.A4;chrome.cast.media.u.prototype.I4=function(){};chrome.cast.media.u.prototype.queueSetRepeatMode=chrome.cast.media.u.prototype.I4;
chrome.cast.media.u.prototype.G4=function(){};chrome.cast.media.u.prototype.queueRemoveItems=chrome.cast.media.u.prototype.G4;chrome.cast.media.u.prototype.F4=function(a){this.Pw(a)};chrome.cast.media.u.prototype.queueRemoveItem=chrome.cast.media.u.prototype.F4;chrome.cast.media.u.prototype.H4=function(){};chrome.cast.media.u.prototype.queueReorderItems=chrome.cast.media.u.prototype.H4;
chrome.cast.media.u.prototype.C4=function(a,b,c,e){a=this.Pw(a);0>a||(0>b?e&&e(new chrome.cast.Error(chrome.cast.pf.INVALID_PARAMETER)):a==b&&c&&c())};chrome.cast.media.u.prototype.queueMoveItemToNewIndex=chrome.cast.media.u.prototype.C4;chrome.cast.media.u.prototype.cba=function(a){return-1<this.supportedMediaCommands.indexOf(a)};chrome.cast.media.u.prototype.supportsCommand=chrome.cast.media.u.prototype.cba;
chrome.cast.media.u.prototype.xV=function(){if(this.playerState==chrome.cast.media.Np.PLAYING&&0<=this.CH){var a=(w()-this.CH)/1E3,a=this.currentTime+this.playbackRate*a;this.media&&null!=this.media.duration&&a>this.media.duration&&(a=this.media.duration);0>a&&(a=0);return a}return this.currentTime};chrome.cast.media.u.prototype.getEstimatedTime=chrome.cast.media.u.prototype.xV;chrome.cast.media.u.prototype.Tu=function(){};chrome.cast.media.u.prototype.addUpdateListener=chrome.cast.media.u.prototype.Tu;
chrome.cast.media.u.prototype.Uu=function(){};chrome.cast.media.u.prototype.addUpdateListenerWithContext=chrome.cast.media.u.prototype.Uu;chrome.cast.media.u.prototype.Gz=function(){};chrome.cast.media.u.prototype.removeUpdateListener=chrome.cast.media.u.prototype.Gz;chrome.cast.media.u.prototype.Hz=function(){};chrome.cast.media.u.prototype.removeUpdateListenerWithContext=chrome.cast.media.u.prototype.Hz;
chrome.cast.media.u.prototype.Pw=function(a){return db(this.items,function(b){return b.itemId==a})};var Ej=function(a,b,c){this.sessionId=a;this.namespaceName=b;this.message=c};var Fj=function(a){this.zd=a;this.a=E("mr.cast.ReceiverStatusQuerier")};Fj.prototype.Haa=function(a){var b=this;return(new gf(v(this.v4,this,a),3500,5)).tt(2).start().then(null,function(c){H(b.a,"Failed to get receiver status from "+a.getId());throw c;})};Fj.prototype.v4=function(a){H(this.a,"Query receiver status: "+a.getId());return this.zd.sendRequest(new rj,a,ri)};var Gj=function(a,b){this.type="SET_VOLUME";this.requestId=0;this.volume=a;this.expectedVolume=b||null};chrome.cast.A=function(a,b,c,e,f){this.sessionId=a;this.appId=b;this.displayName=c;this.statusText=null;this.appImages=e;this.receiver=f;this.senderApps=[];this.namespaces=[];this.media=[];this.status=chrome.cast.NB.CONNECTED;this.transportId=""};m("chrome.cast.Session",chrome.cast.A,void 0);chrome.cast.A.prototype.U9=function(a,b,c){this.fM(null,a,b,c)};chrome.cast.A.prototype.setReceiverVolumeLevel=chrome.cast.A.prototype.U9;
chrome.cast.A.prototype.fM=function(a,b,c,e){b=new Gj(new chrome.cast.Volume(b,null),this.receiver.volume);a.setReceiverVolume(this.sessionId,b,c,e)};chrome.cast.A.prototype.setReceiverVolumeLevelWithContext=chrome.cast.A.prototype.fM;chrome.cast.A.prototype.T9=function(a,b,c){this.eM(null,a,b,c)};chrome.cast.A.prototype.setReceiverMuted=chrome.cast.A.prototype.T9;
chrome.cast.A.prototype.eM=function(a,b,c,e){a=new Gj(new chrome.cast.Volume(null,b),this.receiver.volume);null.setReceiverVolume(this.sessionId,a,c,e)};chrome.cast.A.prototype.setReceiverMutedWithContext=chrome.cast.A.prototype.eM;chrome.cast.A.prototype.leave=function(a,b){null.leaveSession(this.sessionId,a,b)};chrome.cast.A.prototype.leave=chrome.cast.A.prototype.leave;chrome.cast.A.prototype.stop=function(){};chrome.cast.A.prototype.stop=chrome.cast.A.prototype.stop;
chrome.cast.A.prototype.Taa=function(){};chrome.cast.A.prototype.stopWithContext=chrome.cast.A.prototype.Taa;chrome.cast.A.prototype.sendMessage=function(){};chrome.cast.A.prototype.sendMessage=chrome.cast.A.prototype.sendMessage;chrome.cast.A.prototype.H6=function(){};chrome.cast.A.prototype.sendMessageWithContext=chrome.cast.A.prototype.H6;chrome.cast.A.prototype.Tu=function(){};chrome.cast.A.prototype.addUpdateListener=chrome.cast.A.prototype.Tu;chrome.cast.A.prototype.Uu=function(){};
chrome.cast.A.prototype.addUpdateListenerWithContext=chrome.cast.A.prototype.Uu;chrome.cast.A.prototype.Gz=function(){};chrome.cast.A.prototype.removeUpdateListener=chrome.cast.A.prototype.Gz;chrome.cast.A.prototype.Hz=function(){};chrome.cast.A.prototype.removeUpdateListenerWithContext=chrome.cast.A.prototype.Hz;chrome.cast.A.prototype.QP=function(){};chrome.cast.A.prototype.addMessageListener=chrome.cast.A.prototype.QP;chrome.cast.A.prototype.RP=function(){};
chrome.cast.A.prototype.addMessageListenerWithContext=chrome.cast.A.prototype.RP;chrome.cast.A.prototype.OP=function(){};chrome.cast.A.prototype.addMediaListener=chrome.cast.A.prototype.OP;chrome.cast.A.prototype.PP=function(){};chrome.cast.A.prototype.addMediaListenerWithContext=chrome.cast.A.prototype.PP;chrome.cast.A.prototype.v5=function(){};chrome.cast.A.prototype.removeMediaListener=chrome.cast.A.prototype.v5;chrome.cast.A.prototype.w5=function(){};
chrome.cast.A.prototype.removeMediaListenerWithContext=chrome.cast.A.prototype.w5;chrome.cast.A.prototype.x5=function(){};chrome.cast.A.prototype.removeMessageListener=chrome.cast.A.prototype.x5;chrome.cast.A.prototype.y5=function(){};chrome.cast.A.prototype.removeMessageListenerWithContext=chrome.cast.A.prototype.y5;chrome.cast.A.prototype.b0=function(a){a.sessionId=this.sessionId};chrome.cast.A.prototype.loadMedia=chrome.cast.A.prototype.b0;chrome.cast.A.prototype.B4=function(a){a.sessionId=this.sessionId};
chrome.cast.A.prototype.queueLoad=chrome.cast.A.prototype.B4;var Jj=function(a,b){if(!b.applications||1!=b.applications.length)return null;var c=b.applications[0];a=Hj(a);a=new chrome.cast.A(c.sessionId,c.appId,c.displayName,c.appImages,a);a.senderApps=c.senderApps;a.namespaces=c.namespaces||[];a.transportId=c.transportId;a.statusText=c.statusText;if(!a.sessionId||!(a.namespaces&&0!=a.namespaces.length||Ij(a)))return null;a.receiver.volume=b.volume;"boolean"==typeof b.isActiveInput&&(a.receiver.isActiveInput=b.isActiveInput);return a},Lj=function(a){var b=
[];if(!a)return b;a&1&&b.push(chrome.cast.ug.VIDEO_OUT);a&2&&b.push(chrome.cast.ug.VIDEO_IN);a&4&&b.push(chrome.cast.ug.AUDIO_OUT);a&8&&b.push(chrome.cast.ug.AUDIO_IN);a&32&&b.push(chrome.cast.ug.MULTIZONE_GROUP);return b},Hj=function(a){return new chrome.cast.Fu(a.getId(),a.tn(),Lj(a.xd))},Mj=function(a,b){if(a.statusText!=b.statusText)return!0;var c=a.namespaces||[],e=b.namespaces||[];if(c.length!=e.length)return!0;for(var f={index:0};f.index<c.length;f={index:f.index},f.index++)if(!e.some(function(a){return function(b){return b.name==
c[a.index].name}}(f)))return!0;return a.receiver.volume.level!==b.receiver.volume.level||a.receiver.volume.muted!==b.receiver.volume.muted?!0:!1},Nj=function(a){ta(a)?a.forEach(Nj):wa(a)&&Object.keys(a).forEach(function(b){null===a[b]?delete a[b]:(wa(a[b])||ta(a[b]))&&Nj(a[b])})},Oj=function(a,b){return a.namespaces.some(function(a){return a.name==b})},Pj=["MultizoneLeader","MultizoneFollower"],Ij=function(a){return null!==a&&"MultizoneLeader"==a.appId},Qj=function(a){return"E8C28D3C"==a||"00000000-0000-0000-0000-000000000000"==
a};var Rj=function(a){this.zd=a;this.a=E("mr.cast.SessionLauncher")};Rj.prototype.hy=function(a,b){Fg("MediaRouter.Cast.Session.Type",0,Ti);return this.zd.J5(a,b).then(v(this.eZ,this,b),function(a){a&&Aj==a?$i(1):$i(0);throw a;})};Rj.prototype.eZ=function(a,b){I(this.a,"Got launch result from "+a.getId());if("LAUNCH_ERROR"==b.type)throw $i(2),Error(b.reason);a=Jj(a,b.status);H(this.a,"Launched session: "+a.sessionId);return a};var Sj=function(a,b,c,e){this.type=a;this.message=b;this.sequenceNumber=l(c)?c:-1;this.timeoutMillis=e||0;this.clientId=""};var Tj=function(a,b){this.ph=a;this.Qb=b;this.VH=[];this.Ti=new vj};d=Tj.prototype;d.zr=function(a){return(a=this.Qb.Id(a))?a.routeId:null};d.listen=function(a,b){this.VH[a]=b};d.hg=function(a,b,c){I(Uj,"Sending to "+b);I(Uj,JSON.stringify(c));c.clientId=b;this.ph.FS(a,c)};d.gg=function(a,b){var c=this,e=this.Qb.Id(a);e&&e.Ix?this.hg(e.routeId,a,b):this.connect(a).then(function(e){e?(e=c.zr(a))?c.hg(e,a,b):G(Uj,"No route for "+a):G(Uj,"No connected client "+a)},null)};
d.no=function(a){I(Uj,"App "+a);var b=this.zr(a);if(b){if(b=this.Ti.Io(b))(a=this.Qb.Id(a))?(a.Ix=!0,b.vb.resolve(!0)):b.vb.resolve(!1)}else G(Uj,"No route for client "+a)};d.Y0=function(a){I(Uj,"Received: "+a);a=JSON.parse(a);var b=a.clientId;"client_connect"==a.type?this.no(b):this.zr(b)?(b=this.VH[a.type])&&b(a):G(Uj,"No route for "+b)};
d.connect=function(a){if(this.m_(a))return Promise.resolve(!0);var b=this.zr(a);if(!b)return G(Uj,"No route for client "+a),Promise.resolve(!1);if(a=this.Ti.oi(b))return a.vb.promise;a=new ff;this.Ti.dC(new Vj(b,a));return a.promise};d.m_=function(a){a=this.Qb.Id(a);return null!=a&&a.Ix};var Uj=E("mr.cast.ApiMessenger"),Vj=function(a,b){uj.call(this,a,3E4);this.vb=b};la(Vj,uj);Vj.prototype.Fy=function(){this.vb.resolve(!1)};var Wj=function(a,b){this.qk=this.lf=this.eg="";this.tb=null;this.fi=this.nd="";this.Kd=this.x_=!1;var c;a instanceof Wj?(this.Kd=l(b)?b:a.Kd,this.Ft(a.eg),this.DA(a.Kn()),this.Ml(a.Mf()),this.Pl(a.Eb()),this.Eh(a.nd),this.Ct(a.Zf.clone()),this.xt(a.fi)):a&&(c=String(a).match(bf))?(this.Kd=!!b,this.Ft(c[1]||"",!0),this.DA(c[2]||"",!0),this.Ml(c[3]||"",!0),this.Pl(c[4]),this.Eh(c[5]||"",!0),this.Ct(c[6]||"",!0),this.xt(c[7]||"",!0)):(this.Kd=!!b,this.Zf=new Xj(null,null,this.Kd))};d=Wj.prototype;
d.toString=function(){var a=[],b=this.eg;b&&a.push(Yj(b,Zj,!0),":");var c=this.Mf();if(c||"file"==b)a.push("//"),(b=this.Kn())&&a.push(Yj(b,Zj,!0),"@"),a.push(encodeURIComponent(String(c)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),c=this.Eb(),null!=c&&a.push(":",String(c));if(c=this.nd)this.Or()&&"/"!=c.charAt(0)&&a.push("/"),a.push(Yj(c,"/"==c.charAt(0)?ak:bk,!0));(c=this.vV())&&a.push("?",c);(c=this.fi)&&a.push("#",Yj(c,ck));return a.join("")};
d.resolve=function(a){var b=this.clone(),c=a.PZ();c?b.Ft(a.eg):c=a.QZ();c?b.DA(a.Kn()):c=a.Or();c?b.Ml(a.Mf()):c=a.XG();var e=a.nd;if(c)b.Pl(a.Eb());else if(c=a.WG()){if("/"!=e.charAt(0))if(this.Or()&&!this.WG())e="/"+e;else{var f=b.nd.lastIndexOf("/");-1!=f&&(e=b.nd.substr(0,f+1)+e)}f=e;if(".."==f||"."==f)e="";else if(-1!=f.indexOf("./")||-1!=f.indexOf("/.")){for(var e=Da(f,"/"),f=f.split("/"),g=[],k=0;k<f.length;){var p=f[k++];"."==p?e&&k==f.length&&g.push(""):".."==p?((1<g.length||1==g.length&&
""!=g[0])&&g.pop(),e&&k==f.length&&g.push("")):(g.push(p),e=!0)}e=g.join("/")}else e=f}c?b.Eh(e):c=a.OZ();c?b.Ct(a.WU()):c=a.MZ();c&&b.xt(a.fi);return b};d.clone=function(){return new Wj(this)};d.Ft=function(a,b){this.ci();if(this.eg=b?dk(a,!0):a)this.eg=this.eg.replace(/:$/,"");return this};d.PZ=function(){return!!this.eg};d.Kn=function(){return this.lf};d.DA=function(a,b){this.ci();this.lf=b?dk(a):a;return this};d.QZ=function(){return!!this.lf};d.Mf=function(){return this.qk};
d.Ml=function(a,b){this.ci();this.qk=b?dk(a,!0):a;return this};d.Or=function(){return!!this.qk};d.Eb=function(){return this.tb};d.Pl=function(a){this.ci();if(a){a=Number(a);if(isNaN(a)||0>a)throw Error("Bad port number "+a);this.tb=a}else this.tb=null;return this};d.XG=function(){return null!=this.tb};d.Eh=function(a,b){this.ci();this.nd=b?dk(a,!0):a;return this};d.WG=function(){return!!this.nd};d.OZ=function(){return""!==this.Zf.toString()};
d.Ct=function(a,b){this.ci();a instanceof Xj?(this.Zf=a,this.Zf.nA(this.Kd)):(b||(a=Yj(a,ek)),this.Zf=new Xj(a,null,this.Kd));return this};d.vV=function(){return this.Zf.toString()};d.WU=function(){return this.Zf.lba()};d.xt=function(a,b){this.ci();this.fi=b?dk(a):a;return this};d.MZ=function(){return!!this.fi};d.ci=function(){if(this.x_)throw Error("Tried to modify a read-only Uri");};d.nA=function(a){this.Kd=a;this.Zf&&this.Zf.nA(a);return this};
var dk=function(a,b){return a?b?decodeURI(a.replace(/%25/g,"%2525")):decodeURIComponent(a):""},Yj=function(a,b,c){return t(a)?(a=encodeURI(a).replace(b,fk),c&&(a=a.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),a):null},fk=function(a){a=a.charCodeAt(0);return"%"+(a>>4&15).toString(16)+(a&15).toString(16)},Zj=/[#\/\?@]/g,bk=/[\#\?:]/g,ak=/[\#\?]/g,ek=/[\#\?@]/g,ck=/#/g,Xj=function(a,b,c){this.Ua=this.qb=null;this.Kg=a||null;this.Kd=!!c};
Xj.prototype.If=function(){if(!this.qb&&(this.qb=new D,this.Ua=0,this.Kg)){var a=this;df(this.Kg,function(b,c){a.add(decodeURIComponent(b.replace(/\+/g," ")),c)})}};var gk=function(a,b,c){b=Ec(a);if("undefined"==typeof b)throw Error("Keys are undefined");c=new Xj(null,null,c);a=Dc(a);for(var e=0;e<b.length;e++){var f=b[e],g=a[e];ta(g)?c.AM(f,g):c.add(f,g)}return c};d=Xj.prototype;d.R=function(){this.If();return this.Ua};
d.add=function(a,b){this.If();this.Vk();a=this.Dk(a);var c=this.qb.get(a);c||this.qb.set(a,c=[]);c.push(b);this.Ua+=1;return this};d.remove=function(a){this.If();a=this.Dk(a);return this.qb.xa(a)?(this.Vk(),this.Ua-=this.qb.get(a).length,this.qb.remove(a)):!1};d.clear=function(){this.Vk();this.qb=null;this.Ua=0};d.Tb=function(){this.If();return 0==this.Ua};d.xa=function(a){this.If();a=this.Dk(a);return this.qb.xa(a)};d.bk=function(a){var b=this.C();return gb(b,a)};
d.ib=function(){this.If();for(var a=this.qb.C(),b=this.qb.ib(),c=[],e=0;e<b.length;e++)for(var f=a[e],g=0;g<f.length;g++)c.push(b[e]);return c};d.C=function(a){this.If();var b=[];if(t(a))this.xa(a)&&(b=ob(b,this.qb.get(this.Dk(a))));else{a=this.qb.C();for(var c=0;c<a.length;c++)b=ob(b,a[c])}return b};d.set=function(a,b){this.If();this.Vk();a=this.Dk(a);this.xa(a)&&(this.Ua-=this.qb.get(a).length);this.qb.set(a,[b]);this.Ua+=1;return this};
d.get=function(a,b){a=a?this.C(a):[];return 0<a.length?String(a[0]):b};d.AM=function(a,b){this.remove(a);0<b.length&&(this.Vk(),this.qb.set(this.Dk(a),pb(b)),this.Ua+=b.length)};d.toString=function(){if(this.Kg)return this.Kg;if(!this.qb)return"";for(var a=[],b=this.qb.ib(),c=0;c<b.length;c++)for(var e=b[c],f=encodeURIComponent(String(e)),e=this.C(e),g=0;g<e.length;g++){var k=f;""!==e[g]&&(k+="="+encodeURIComponent(String(e[g])));a.push(k)}return this.Kg=a.join("&")};d.lba=function(){return dk(this.toString())};
d.Vk=function(){this.Kg=null};d.clone=function(){var a=new Xj;a.Kg=this.Kg;this.qb&&(a.qb=this.qb.clone(),a.Ua=this.Ua);return a};d.Dk=function(a){a=String(a);this.Kd&&(a=a.toLowerCase());return a};d.nA=function(a){a&&!this.Kd&&(this.If(),this.Vk(),this.qb.forEach(function(a,c){var b=c.toLowerCase();c!=b&&(this.remove(c),this.AM(b,a))},this));this.Kd=a};d.extend=function(a){for(var b=0;b<arguments.length;b++)Gc(arguments[b],function(a,b){this.add(b,a)},this)};var hk=function(a,b,c,e,f,g,k,p){this.Zu=a;this.Bd=b||null;this.gq=c||null;this.Jq=e||null;this.ms=l(f)?f:null;this.$u=g||null;this.GD=k||null;this.Ex=p||!1},ik=function(a,b){return(a=a.match(b+"=([^/]*)"))?a[1]:null},kk=function(a){a=a.match(/__castAppId__=([^/]*)/g);return null==a?[]:ab(B(a,function(a){a=ik(a,"__castAppId__");if(!a)return null;a=a.match(jk);if(!a||0==a.length)return null;var b=[];3==a.length&&a[2]&&(b=a[2].split(","));return{appId:a[1],capabilities:b}}),function(a){return null!=
a})},lk=function(a){return ik(a,"__castClientId__")};d=hk.prototype;d.kn=function(){return B(this.Zu,function(a){return a.appId})};d.FE=function(){return this.$u};d.rc=function(){return this.Bd};d.zw=function(){return this.gq?this.gq:chrome.cast.nf.TAB_AND_ORIGIN_SCOPED};d.XU=function(){return this.Jq?this.Jq:chrome.cast.Mp.CREATE_SESSION};d.gW=function(){return null==this.ms?chrome.cast.timeout.requestSession:this.ms};
d.toString=function(){var a=new Wj;a.Ft("https");a.Ml("google.com");a.Eh("/cast");var b=[];z(this.Zu,function(a){var c="__castAppId__="+a.appId;a.capabilities&&0<a.capabilities.length&&(c=c+"("+a.capabilities.join(","),c+=")");b.push(c)});this.Bd&&b.push("__castClientId__="+this.Bd);this.gq&&b.push("__castAutoJoinPolicy__="+this.gq);this.Jq&&b.push("__castDefaultActionPolicy__="+this.Jq);null!=this.ms&&b.push("__castLaunchTimeout__="+this.ms);this.$u&&b.push("__dialAppName__="+this.$u);this.GD&&b.push("__dialPostData__="+
this.GD);this.Ex&&b.push("__castInvisibleSender__=true");a.xt(b.join("/"));return a.toString()};d.D_=function(a){var b=this.kn(),c=mk(a);return bb(b,function(a){return gb(c,a)})};
var nk=function(a){a=new Wj(a);if("https"!=a.eg||"google.com"!=a.Mf()||"/cast"!=a.nd)return null;var b=a.fi;a=kk(b);if(!a||0==a.length)return null;var c=lk(b),e=ik(b,"__castAutoJoinPolicy__"),f=ik(b,"__castDefaultActionPolicy__"),g;g=ik(b,"__castLaunchTimeout__");null==g?g=null:(g=Number(g),g=!isNaN(g)&&0<=g?g:null);var k=ik(b,"__dialAppName__"),p=ik(b,"__dialPostData__"),b=ik(b,"__castInvisibleSender__");return new hk(a,c,e,f,g,k,p,null===b?null:"true"==b)},mk=function(a){return(a=nk(a))?a.kn():
null},ok=function(a){return(a=nk(a))?a.rc():null},jk=/(^\w+)(?:\(([\w,\ ]*)\))?$/;var pk=function(a,b,c,e,f,g){this.cg=a;this.$=b;this.Qb=c;this.ma=e;this.Rc=f;this.ph=g;this.bd=new Tj(g,c);this.R4=new Fj(this.cg);this.W6=new Rj(this.cg)};d=pk.prototype;d.init=function(){this.Qb.init();this.bd.listen("v2_message",this.M2.bind(this));this.bd.listen("app_message",this.c1.bind(this));this.bd.listen("leave_session",this.K1.bind(this))};d.re=function(a,b){this.bd.Y0(b)};
d.Uz=function(a,b,c,e){var f=this;a=this.ma.TE(a);c&&0==a.length&&a.push(c.clientId);a.slice().forEach(function(a){a!=e&&f.LK(a,b)})};d.LK=function(a,b){b.clientId=a;this.bd.gg(a,b)};d.OK=function(a,b,c){b={receiver:Hj(b),action:c};this.LK(a,new Sj("receiver_action",b))};
d.M2=function(a){var b=a.message,c=b.sessionId;if(c){var e=this.ma.ix(c);if(e)if(c=this.ma.oG(c))if(c=this.$.W(c))switch(b.type){case "STOP":this.$0(a,c);break;case "LOAD":case "PAUSE":case "PLAY":case "SEEK":case "STOP_MEDIA":case "MEDIA_SET_VOLUME":case "MEDIA_GET_STATUS":case "EDIT_TRACKS_INFO":case "QUEUE_LOAD":case "QUEUE_INSERT":case "QUEUE_UPDATE":case "QUEUE_REMOVE":case "QUEUE_REORDER":this.X0(a,c,e);break;case "SET_VOLUME":this.Z0(a,c);break;default:G(qk,"Unknown request")}else this.Jl(a,
chrome.cast.pf.INVALID_PARAMETER,"No receiver");else this.Jl(a,chrome.cast.pf.INVALID_PARAMETER,"No sink ID");else this.Jl(a,chrome.cast.pf.INVALID_PARAMETER,"Unknown session ID")}else this.Jl(a,chrome.cast.pf.INVALID_PARAMETER,"No session ID")};d.Jl=function(a,b,c){b=new chrome.cast.Error(b,c);this.Tz(a,b)};d.Tz=function(a,b){this.bd.gg(a.clientId,new Sj("error",b,a.sequenceNumber))};
d.$0=function(a,b){var c=this,e=a.message;Eg("MediaRouter.Cast.Session.End");var f=e.sessionId,g=this.ma.le(f);g&&(g.$r=!0);this.cg.sendRequest(e,b,ri,a.timeoutMillis,a.clientId).then(function(){c.$i(f,a)},function(){c.$i(f,a)})};d.X0=function(a,b,c){var e=this,f=a.message,g=f.type;g in qj&&(f.type=qj[g]);this.cg.sendRequest(f,b,si,a.timeoutMillis,a.clientId,c.transportId).then(function(b){e.FJ(c,b);e.bd.gg(a.clientId,new Sj("v2_message",b,a.sequenceNumber))},function(b){e.Tz(a,b)})};
d.Z0=function(a,b){var c=this,e=a.message;delete e.sessionId;this.cg.sendRequest(e,b,ri,a.timeoutMillis,a.clientId).then(function(){c.bd.gg(a.clientId,new Sj("v2_message",null,a.sequenceNumber))},function(b){c.Tz(a,b)})};
d.c1=function(a){var b=this,c=a.message,e=c.sessionId;if(e){var f=this.ma.oG(e);f?(f=this.$.W(f))?(e=this.ma.ix(e),eb(e.namespaces,function(a){return a.name==c.namespaceName})?this.Rc.ot(f,c.namespaceName,c.message,a.clientId,e.transportId).then(function(){b.bd.gg(a.clientId,new Sj("app_message",null,a.sequenceNumber))},function(){b.Jl(a,chrome.cast.pf.CHANNEL_ERROR,"Channel to receiver not available")}):this.Jl(a,chrome.cast.pf.INVALID_PARAMETER,"Invalid namespace")):G(qk,"No receiver from sinkId"):
G(qk,"No sinkId from sessionId")}else G(qk,"No sessionId")};d.A5=function(a){a.Td.slice().forEach(function(a){this.ph.VX(a)||this.ph.Cl(a,!0)}.bind(this))};d.Gs=function(a){(a=this.ma.Dn(a))&&a.session&&this.$i(a.session.sessionId)};
d.K1=function(a){var b=this;H(qk,"Leave session");var c=a.message,e=this.ma.le(c);if(e){var f=a.clientId,g=this.Qb.Id(f);if(g){var k=[],p=[],q=g.tabId,A=g.origin,M=g.autoJoinPolicy;e.Bf.forEach(function(a){var c=b.Qb.Id(a);M==chrome.cast.nf.TAB_AND_ORIGIN_SCOPED&&q==c.tabId&&A==c.origin||M==chrome.cast.nf.ORIGIN_SCOPED&&A==c.origin?(c.qH=!0,k.push(a)):p.push(a)});this.bd.gg(f,new Sj("leave_session",null,a.sequenceNumber));k.forEach(function(a){b.bd.gg(a,new Sj("disconnect_session",c))});e.Bf=p}else G(qk,
"No client record")}else G(qk,"No session")};d.IJ=function(a,b){Oj(a,si)&&this.cg.sendRequest(new rj,b,si,void 0,void 0,a.transportId).catch(n)};d.JJ=function(a,b){var c=this,e=a.getId();H(qk,"Query status for "+e);this.R4.Haa(a).then(function(f){c.aJ(e,f);b&&(f=c.ma.Br(e))&&c.IJ(f,a)},n)};d.t2=function(a,b){ui.hasOwnProperty(b.namespace_)?this.q2(a,b):this.p2(a,b)};
d.J_=function(a){if("*"==a.destinationId)return!0;a=a.destinationId;if(a==this.Rc.iG()||null!=this.Qb.Id(a))return!0;H(qk,"Invalid destination "+a);return!1};
d.q2=function(a,b){var c=this;I(qk,"Cast message: "+JSON.stringify(b));if(this.J_(b))if(b.namespace_==ti)(a=this.ma.Dn(a))&&a.Td.forEach(function(a){c.ph.ES(a,b)});else{var e=JSON.parse(b.data),f=this.lZ(e),f=f?f.sourceId:void 0;switch(e.type){case "RECEIVER_STATUS":this.aJ(a,e);break;case "MEDIA_STATUS":this.s2(a,b,f)}}else this.Rc.bD(a,b.destinationId,b.sourceId,!0)};
d.lZ=function(a){var b=this.cg.Io(a.requestId);if(!b)return null;var c=b.vb;switch(a.type){case "LAUNCH_ERROR":case "INVALID_REQUEST":case "LOAD_CANCELLED":case "LOAD_FAILED":case "INVALID_PLAYER_STATE":delete a.requestId;c.reject(new chrome.cast.Error(chrome.cast.pf.SESSION_ERROR,a.reason||a.type,a));break;default:c.resolve(a)}return b};
d.p2=function(a,b){var c=this;I(qk,"App message: "+JSON.stringify(b));if(a=this.ma.Br(a)){var e;e="*"==b.destinationId?this.ma.TE(a.sessionId):[b.destinationId];var f=new Ej(a.sessionId,b.namespace_,b.data);e.forEach(function(a){c.bd.gg(a,new Sj("app_message",f))})}else G(qk,"No session for incoming app message")};
var rk=function(a,b){a.forEach(function(a){a.sessionId=b;var c=a.supportedMediaCommands,f=[];c&1&&f.push(chrome.cast.media.tm.PAUSE);c&2&&f.push(chrome.cast.media.tm.SEEK);c&4&&f.push(chrome.cast.media.tm.STREAM_VOLUME);c&8&&f.push(chrome.cast.media.tm.STREAM_MUTE);a.supportedMediaCommands=f});return a};d=pk.prototype;d.FJ=function(a,b){a=a.sessionId;b.sessionId=a;this.ma.r$(a,rk(b.status,a))};d.W1=function(a,b,c){this.bd.gg(c,new Sj("new_session",a));this.IJ(a,b)};
d.dt=function(a){if(a=this.ma.Br(a)){a=a.sessionId;var b=this.ma.le(a);b&&b.$r||this.$i(a)}};d.$i=function(a,b){this.Uz(a,new Sj("remove_session",a,b?b.sequenceNumber:void 0),b);(b=this.ma.le(a))&&this.A5(b);this.ma.$i(a)};
d.aJ=function(a,b){I(qk,"Receiver status for "+a);var c=b.status;if(c)if(b=this.$.W(a)){var c=Jj(b,c),e=this.ma.Dn(a);e?c?c.sessionId==e.session.sessionId?this.xZ(e,c):(this.OG(a),this.ph.Ie(null,b,null,c)):this.OG(a):c&&this.ph.Ie(null,b,null,c)}else Eg("MediaRouter.Cast.Error.Sink.Missing.From.Discovery.Service"),G(qk,"Got message from receiver "+a+", but sink is no longer available.")};
d.xZ=function(a,b){var c=a.session;Mj(c,b)&&(I(qk,"Updating session "+b.sessionId),c.statusText=b.statusText,c.namespaces=b.namespaces,c.receiver.volume=b.receiver.volume,this.ph.Pba(a),this.Uz(c.sessionId,new Sj("update_session",c),void 0))};d.OG=function(a){this.dt(a);Yi(1)};d.s2=function(a,b,c){if(a=this.ma.Br(a))if(b=JSON.parse(b.data))this.FJ(a,b),this.Uz(b.sessionId,new Sj("v2_message",b),void 0,c)};
d.vR=function(a,b){var c=Lj(b.xd);return(b=eb(a.Zu,function(a){return cb(a.capabilities,function(a){return gb(c,a)})}))?b.appId:a.kn()[0]};d.hy=function(a,b){var c=nk(a);if(!c)return Promise.reject(Error("Invalid source "+a));a=this.vR(c,b);var c=c.gW(),e=new wg("MediaRouter.Cast.Session.Launch");return this.W6.hy(new chrome.cast.MB(a,void 0,c),b).then(function(a){e.end("Success");return a},function(a){e.end("Failure");throw a;})};var qk=E("mr.cast.ApiHandler");var sk=E("mr.RuntimeErrorUtils"),tk=function(){chrome.runtime.lastError&&sk.mE(chrome.runtime.lastError.message||"unknown runtime error")};var uk=function(){this.bz=new D;this.cz=new D;this.uo=new D};d=uk.prototype;d.Zj=function(a,b){var c=this,e=a.getId(),f=a.pa+":"+a.Eb(),g=this.bz.get(e);if(g){if(this.uo.get(e)==f)return I(vk,"Using pending creation to "+e),g;H(vk,"Device "+e+" IP changed from "+this.uo.get(a.getId())+" to "+f);this.BP(a)}a=this.KS(a,b).then(function(a){c.Dv(e);return a},function(a){f==c.uo.get(e)&&c.Dv(e);return Promise.reject(a)});this.bz.set(e,a);this.uo.set(e,f);return a};
d.BP=function(a){a=a.getId();I(vk,"Aborting connection to device "+a);var b=this.cz.get(a);b&&b.abort();this.Dv(a)};d.Dv=function(a){this.bz.remove(a);this.cz.remove(a);this.uo.remove(a)};d.KS=function(a,b){if(1===b)return this.kJ(a);var c=u(b)&&1<b?b:3;b=new gf(v(this.kJ,this,a),1E3,c);this.cz.set(a.getId(),b);return b.tt(1.5).start().then(null,function(b){H(vk,"Failed to create channel to "+a.getId()+" after "+c+" attempts.");return Promise.reject(b)})};
d.kJ=function(a){var b=wk++;H(vk,"Connecting to (id "+b+") "+a.getId());var c=new wg("MediaRouter.Cast.Mdns.Channel.Open");return this.O2(a).then(function(a){H(vk,"Channel opened (id "+b+"): "+JSON.stringify(a));c.end("Success");return a},function(a){H(vk,"Channel did not open (id "+b+").");c.end("Failure");return Promise.reject(a)})};
d.O2=function(a){a={ipAddress:a.pa,port:a.Eb(),auth:"ssl_verified",timeout:1E4,livenessTimeout:1E4,pingInterval:5E3,capabilities:0};H(vk,"Opening channel to "+JSON.stringify(a));var b=new ff;chrome.cast.channel.open(a,function(a){tk();"open"==a.readyState?b.resolve(a):(chrome.cast.channel.close(a,function(){chrome.runtime.lastError||I(vk,"Channel close success")}),b.reject(Error(a.errorState)))});return b.promise};var vk=E("mr.cast.ChannelFactory"),wk=0;var xk=function(a,b,c,e){return{namespace_:a,data:t(b)?b:JSON.stringify(b),sourceId:c,destinationId:e}};var zk=function(a){this.type="CONNECT";this.origin={};this.userAgent=Tb;var b=this.userAgent.indexOf("(")+1,b=this.userAgent.substr(b,this.userAgent.indexOf(")",b)-1-b+1);this.senderInfo={sdkType:2,version:chrome.runtime.getManifest().version,browserVersion:hi,platform:yk(),systemVersion:b,connectionType:1};this.connType=a?0:2},yk=function(){switch(Kg()){case "ChromeOS":return 5;case "Windows":return 3;case "Mac":return 4;case "Linux":return 6}return 0};var Ak=function(){this.mf=new D};d=Ak.prototype;d.init=function(){Ci(this)};d.Ry=function(a,b,c,e){this.aD(a,b,c,!1);var f=xk(qi,new zk(e),b,c);chrome.cast.channel.send(a,f,v(this.xE,this));this.mf.set(this.Qx(a,b,c),e)};d.aD=function(a,b,c,e){if(this.ZG(a,b,c)){var f=0;this.mf.forEach(function(a,b){b=b.split("#")[2];a&&b==c&&f++});if(e||1<f)this.fK(a,b,c),b=xk(qi,{type:"CLOSE"},b,c),chrome.cast.channel.send(a,b,v(this.xE,this))}};d.fK=function(a,b,c){this.mf.remove(this.Qx(a,b,c))};
d.C5=function(a){var b=this;this.mf.ib().forEach(function(c){c.split("#")[0]==a.channelId.toString()&&b.mf.remove(c)},this)};d.Q0=function(a,b){var c=this;this.mf.forEach(function(e,f){var g=f.split("#");g[0]==a.channelId.toString()&&(c.Ry(b,g[1],g[2],e),c.mf.remove(f))},this)};d.fT=function(a,b,c){this.ZG(a,b,c)||this.Ry(a,b,c,0==c.indexOf("receiver-0"))};d.ZG=function(a,b,c){return this.mf.xa(this.Qx(a,b,c))};d.xE=function(){tk()};d.Qx=function(a,b,c){return[a.channelId,b,c].join("#")};d.ka=function(){return"cast.VirtualConnectionManager"};
d.getData=function(){var a=this.mf.b();return[new Bk(a)]};d.fb=function(){var a=zi(this);if(a)for(var b in a.RN)this.mf.set(b,a.RN[b])};qa(Ak);var Bk=function(a){this.RN=a};var Ck=function(a,b){this.Av=b;this.qd=a;this.wh=new D;this.Cg=new D;this.Ej=Ak.N();this.lR=new uk;this.W=null};d=Ck.prototype;d.init=function(){chrome.cast.channel.onMessage.addListener(v(this.j1,this));chrome.cast.channel.onError.addListener(v(this.h1,this));this.Ej.init();Ci(this)};d.iG=function(){return this.qd};d.ot=function(a,b,c,e,f){var g=this,k=e||this.qd,p=f||"receiver-0";return this.Zj(a).then(function(a){return g.O6(a,b,c,k,p)})};
d.P2=function(a,b,c,e){var f=this;return this.Zj(a).then(function(a){return f.Ej.Ry(a,b,c,e)})};d.bD=function(a,b,c,e){(a=this.wh.get(a))&&this.Ej.aD(a,b,c,e)};
d.j1=function(a,b){var c=this.Cg.get(a.channelId);if(c){var e=this.W(c);if(e){if(ui.hasOwnProperty(b.namespace_)){c=JSON.parse(b.data);if("CLOSE"==c.type){this.Ej.fK(a,b.destinationId,b.sourceId);return}H(Dk,"Got message "+(c.type||c.responseType)+" from "+e.getId())}else H(Dk,"Got message in "+b.namespace_+" from "+e.getId());this.Av.i1(e,b)}else G(Dk,"Receiver "+c+" not found.")}else G(Dk,"This message is from unknown receiver.")};
d.cD=function(a){chrome.cast.channel.close(a,function(){chrome.runtime.lastError||I(Dk,"Channel close success")});var b=this.Cg.get(a.channelId);b&&(this.Cg.remove(a.channelId),this.wh.remove(b))};d.h1=function(a,b){G(Dk,"Channel error: "+JSON.stringify(a)+(b?", "+JSON.stringify(b):""));b&&this.KP(b.errorState,b);this.$C(a)};
d.KP=function(a,b){switch(a){case "unknown":a=0;break;case "authentication_error":a=1;break;case "connect_error":a=2;break;default:return}if(b){if(-8192<=b.nssErrorCode&&-7192>b.nssErrorCode||2==b.challengeReplyErrorType||8==b.challengeReplyErrorType||9==b.challengeReplyErrorType||11==b.challengeReplyErrorType||-200>=b.netReturnValue&&-300<b.netReturnValue||30==b.eventType||31==b.eventType||32==b.eventType)a=3;if(26==b.eventType||-201==b.netReturnValue||-8181==b.nssErrorCode||-8162==b.nssErrorCode||
-8161==b.nssErrorCode)a=4;-138==b.netReturnValue&&(a=5);if(-8182==b.nssErrorCode||10==b.eventType||12==b.eventType)a=1}G(Dk,"Channel error code: "+a);Fg("MediaRouter.Cast.Channel.Error",a,Xi)};d.$C=function(a){var b=this,c=this.Cg.get(a.channelId);this.cD(a);if(c){var e=this.W(c);e&&this.Zj(e).then(function(c){H(Dk,"Re-connected to receiver: "+e.getId());b.Ej.Q0(a,c);b.Av.k1(e)},function(){H(Dk,"Failed to re-connect to receiver: "+e.getId());b.Ej.C5(a);b.Av.Cy(e,a.errorState)})}};
d.Zj=function(a){var b=this,c=a.getId(),e=this.wh.get(c);return e&&"open"==e.readyState?Promise.resolve(e):this.lR.Zj(a).then(function(a){if(b.Cg.xa(a.channelId))return a;b.wh.get(c)&&(G(Dk,"Duplicate channel to a receiver "+c),b.cD(b.wh.get(c)));H(Dk,"Connected to: "+c);b.wh.set(c,a);b.Cg.set(a.channelId,c);return a},null)};
d.O6=function(a,b,c,e,f){var g=this;this.Ej.fT(a,e,f);Nj(c);var k=xk(b,c,e,f);H(Dk,"Channel is sending message");I(Dk,"....message was: "+JSON.stringify(k));return new Promise(function(b,c){tk();chrome.cast.channel.send(a,k,function(a){a.errorState?(c(Error("Failed to send message")),g.$C(a)):b(!0)})})};d.ka=function(){return"cast.ChannelService"};d.getData=function(){return[new Ek(this.wh.b(),this.Cg.b())]};d.fb=function(){var a=zi(this);a&&(this.wh.addAll(a.Q4),this.Cg.addAll(a.mR))};
var Dk=E("mr.cast.ChannelService"),Ek=function(a,b){this.Q4=a;this.mR=b};var Fk=function(){this.requestId=0;this.type="GET_APP_AVAILABILITY";this.appId=[]};var Gk=function(a,b){this.cg=a;this.$=b;this.$b=new Jc;this.Ac=new D};d=Gk.prototype;d.a=E("mr.cast.AppDiscoveryService");d.init=function(){Ci(this)};d.xz=function(a){var b=this.Ac.get(a);b?b.Az++:this.Ac.set(a,{Az:1});this.v6()};d.eB=function(a){var b=this.Ac.get(a);b&&(b.Az--,0<b.Az||(xc(this.$.Hn(),function(b){switch(b.ie(a)){case "available":b.Vo(a,"available_rescan");break;case "unavailable":b.Vo(a,"unavailable_rescan")}}),this.Ac.remove(a)))};
d.v6=function(){H(this.a,"Scanning sinks for app availability");xc(this.$.Hn(),this.Po,this)};
d.Po=function(a){xc(this.Ac.yF(),function(b){var c=this,e;a:{switch(a.ie(b)){case "unknown":case "available_rescan":case "unavailable_rescan":e=!0;break a}e=!1}if(e){var f=a.getId()+":"+b;this.$b.contains(f)||(this.$b.add(f),e=function(){c.$b.remove(f)},(new gf(this.pR.bind(this,a,b),5500,3)).tt(2).start().then(this.vN.bind(this,a,b),function(){F(c.a,"Failed to get app availability response for "+a.getId()+", appId "+b+" after 3 attempts.");c.vN(a,b,"unknown")}).then(e,e))}},this)};
d.vN=function(a,b,c){c!=a.ie(b)&&(H(this.a,b+" on "+a.getId()+" is "+c),a.Vo(b,c),this.$.ld(a))};
d.pR=function(a,b){var c=this,e=new Fk;e.appId=[b];var f=new wg("MediaRouter.Cast.App.Availability");return this.cg.sendRequest(e,a,ri,5E3).then(function(a){f.end("Success");I(c.a,"App availability response "+JSON.stringify(a));for(var b in a.availability){if("APP_AVAILABLE"==a.availability[b])return"available";if("APP_UNAVAILABLE"==a.availability[b])return"unavailable"}return"unknown"},function(e){f.end("Failure");F(c.a,"checkAppAvailability_ failed for "+a.getId()+", appId "+b);throw e;})};
var Hk=function(a){this.f5=a};Gk.prototype.ka=function(){return"cast.AppDiscoveryService"};Gk.prototype.getData=function(){return[new Hk(this.Ac.b())]};Gk.prototype.fb=function(){var a=zi(this);a&&this.Ac.addAll(a.f5)};var Ik=function(a,b,c){this.name="RouteRequestError";this.message=b||"";if(c)this.stack=c;else if(Error.captureStackTrace)Error.captureStackTrace(this,Ik);else if(b=Error().stack)this.stack=b;this.errorCode=a};x(Ik,Error);var Jk=function(a,b){this.sinks=a;this.origins=b||null},Kk=new Jk([]);var Lk=function(){},Mk=function(a){if(!Da(a,"urn:x-org.chromium:media:route:"))return null;var b=a.substring(31);if(!b)return null;b=Va(b,"/",2);if(3!=b.length)return null;var c=Va(b[1],"-",1);if(2!=c.length)return null;var e=new Lk;e.Upa=a;e.yJ=b[0];e.bpa=c[0];e.sqa=c[1];e.Gh=b[2];return e};Lk.prototype.ba=function(){return this.Gh};var Nk=function(a,b,c,e,f,g){this.id=a;this.sinkId=b;this.mediaSource=c;this.isLocal=e;this.description=f;this.iconUrl=g;this.allowStop=!0;this.customControllerPath=null;this.forDisplay=!0;this.offTheRecord=!1;this.ek=e},Ok=function(a,b,c,e,f,g,k){return new Nk("urn:x-org.chromium:media:route:"+a+"/"+b+"-"+c+"/"+e,c,e,f,g,k)};var Pk=function(a,b,c,e){return Ok(c,"cast",b.getId(),a,e,"",null)};var Qk=function(a,b,c,e,f,g){this.routeId=a;this.clientId=b;this.autoJoinPolicy=e;this.origin=f;this.tabId=g;this.qH=this.Ix=!1},Rk=function(){this.ub=[]};d=Rk.prototype;d.init=function(){Ci(this)};d.R=function(){return this.ub.length};d.Id=function(a){return eb(this.ub,function(b){return b.clientId==a})};d.Tg=function(a){return eb(this.ub,function(b){return b.routeId==a})};d.Pu=function(a,b,c,e,f,g){a=new Qk(a,b,c,e,f,g);this.ub.push(a);return a};
d.Ez=function(a){this.ub=ab(this.ub,function(b){return b.clientId!=a})};var Sk=function(a){this.ct=a};Rk.prototype.ka=function(){return"cast.ClientRecords"};Rk.prototype.getData=function(){return[new Sk(this.ub)]};Rk.prototype.fb=function(){var a=zi(this);a&&(this.ub=a.ct)};var Tk=function(a){this.$=a},Uk=function(a){var b=[];a.forEach(function(a){var c="Receiver-"+a.replace(/\./g,"_"),f=Mi.N().Tj||8009;b.push({serviceName:c+"._googlecast._tcp.local",serviceHostPort:c+":"+f,ipAddress:a,serviceData:["id=mdns:"+c,"ve=02","ca=5","st=1","fn="+c,"md=Chromecast"]})});return b};Tk.prototype.init=function(){var a=Uk(Mi.N().qw);this.$.UJ(a)};var Vk=chrome.i18n.getMessage("4528089202128275824");chrome.i18n.getMessage("2810417817914017289");chrome.i18n.getMessage("3413021810593924462");chrome.i18n.getMessage("7603034707785674700");chrome.i18n.getMessage("8009014317872238527");chrome.i18n.getMessage("8636962961150071298");chrome.i18n.getMessage("1802762746589457177");var Wk=function(a,b){this.Bf=[];this.Td=[];this.sinkId=a;this.session=b;this.ns=this.$n=null;this.offTheRecord=this.$r=!1};d=Wk.prototype;d.Pu=function(a){if(gb(this.Bf,a))return!1;this.Bf.push(a);return!0};d.Ez=function(a){return lb(this.Bf,a)};d.Ie=function(a){if(gb(this.Td,a))return!1;this.Td.push(a);return!0};d.Cl=function(a){return lb(this.Td,a)};d.OY=function(a,b){Ij(a)?(this.ns=a,this.$n=b):Ij(this.session)&&(this.ns=this.session,this.$n=this.sinkId,this.session=a,this.sinkId=b);return this};
var Xk=function(){this.a=E("mr.cast.SessionRecords");this.ub=[]};d=Xk.prototype;d.init=function(){Ci(this)};d.Sp=function(a,b){H(this.a,"Adding new session: "+b+", "+a.sessionId);var c=this.le(a.sessionId);if(c)return c.OY(a,b);a=new Wk(b,a);this.ub.push(a);return a};d.$i=function(a){H(this.a,"Removing session "+a);this.ub=ab(this.ub,function(b){return b.session.sessionId!=a})};d.TE=function(a){return(a=this.le(a))?a.Bf:[]};d.Br=function(a){return(a=this.Dn(a))?a.session:null};
d.Id=function(a){return eb(this.ub,function(b){return gb(b.Bf,a)})};d.Tg=function(a){return eb(this.ub,function(b){return gb(b.Td,a)})};d.zX=function(a){return eb(this.ub,function(b){return null!=eb(b.Td,function(b){return Mk(b).yJ==a})})};d.Dn=function(a){return eb(this.ub,function(b){return b.sinkId==a||b.$n==a})};d.le=function(a){return eb(this.ub,function(b){return b.session.sessionId==a})};d.oG=function(a){return(a=this.le(a))?a.sinkId:null};d.ix=function(a){return(a=this.le(a))?a.session:null};
d.r$=function(a,b){var c=this.ix(a);c&&(a=ab(b,function(a){return a.playerState!=chrome.cast.media.Np.IDLE},this),a.forEach(function(a){if(!a.media){var b=eb(c.media,function(b){return b.mediaSessionId==a.mediaSessionId});b&&(a.media=b.media)}}),c.media=a)};d.q4=function(a){for(var b=0;b<this.ub.length;b++)this.ub[b].Ez(a)};var Yk=function(a){this.ct=a};Xk.prototype.ka=function(){return"cast.SessionRecords"};Xk.prototype.getData=function(){return[new Yk(this.ub)]};
Xk.prototype.fb=function(){var a=zi(this);if(a)for(var b=0;b<a.ct.length;b++){var c=a.ct[b],e=new Wk(c.sinkId,c.session);e.Bf=c.Bf;e.Td=c.Td;e.$r=c.$r;e.ns=c.ns;e.$n=c.$n;this.ub.push(e)}};var Zk=function(a){this.qd="sender-"+Ra();this.bb=new D;this.Bi=null;Ci(this);this.w=a;this.Qb=new Rk;this.ma=new Xk;this.Rc=new Ck(this.qd,this);this.$=new lj(this.Rc,this);this.pS=new Tk(this.$);this.zd=new xj(this.Rc,this.qd);this.cd=new Gk(this.zd,this.$);this.wd=new pk(this.zd,this.$,this.Qb,this.ma,this.Rc,this);this.JC=new Dj(this.$,this.zd);this.Baa=this.$.start.bind(this.$)};d=Zk.prototype;d.a=E("mr.CastProvider");d.getName=function(){return"cast"};
d.Ld=function(){this.zd.init();this.ma.init();this.wd.init();this.Rc.init();this.$.init();this.pS.init();this.cd.init();this.w.yz(this.Baa)};d.Rf=function(){return this.bb.C()};d.ln=function(a){var b=new Jc;this.ir(a).forEach(function(a){this.$.fY(a).map(function(a){return a.Qg()}).forEach(function(a){b.add(a)})}.bind(this));return new Jk(b.C(),-1!=a.indexOf("0F5096E8")?Qg:null)};d.vj=function(a){this.ir(a).forEach(function(a){this.cd.xz(a)}.bind(this));this.w.Kx()&&this.$.start()};d.yj=function(a){this.ir(a).forEach(function(a){this.cd.eB(a)}.bind(this))};
d.uj=function(){};d.xj=function(){};d.W=function(a){return(a=this.$.W(a))?a.Qg():null};d.D6=function(a){var b=new qg(Vk,"warning","dismiss");b.routeId=a;this.w.Nf().send(b)};d.NG=function(a,b){F(this.a,"Error launching.",b);this.D6(a.id);this.w.onPresentationConnectionClosed(a.id,"error","Launch error");this.Cl(a.id,!1)};
d.Nq=function(a,b,c,e,f,g,k){var p=this;Mi.N().Yi=new Li(b.xc,b.pa);var q=Pk(a,b,c,!0);q.forDisplay=!1;q.offTheRecord=e;this.bb.set(q.id,q);this.w.rl(this,q);this.w.yh(this.ka(),!0);(e=nk(a))&&e.rc()&&this.VB(e,q.id,g,k);Og(a)||Pg(a)?(q.pe={tabId:k,sessionId:"",FM:b.pa||"",GM:b.xc||""},this.w.np(this,q,function(e){return ug(p.QH(a,b,c,f,g,k,e))}).promise.then(function(){p.OL(q)},function(a){p.NG(q,a)})):this.QH(a,b,c,f,g,k,q).then(null,function(a){p.NG(q,a)});return Promise.resolve(q)};
d.QH=function(a,b,c,e,f,g,k){var p=this;return this.wd.hy(this.hz(a,b,e),b).then(function(e){p.Ie(a,b,c,e,f,g,k);return k})};d.Ne=function(a,b,c,e,f,g,k){var p=this,q=this.$.W(b);if(!q)return tg(Error("No sink with ID "+b));var A=lk(a);if(A){setTimeout(function(){p.wd.OK(A,q,chrome.cast.um.CAST)},0);var M=function(){return p.Nq(a,q,c,e,f,g,k)},Q=this.Qb.Id(A);if(Q)return ug(this.Zc(Q.routeId).then(M,M));if(g&&k&&(b=this.rD(a,g,k,e,f,b)))return b}return ug(this.Nq(a,q,c,e,f,g,k))};
d.FS=function(a,b){this.w.re(this,a,b)};d.ES=function(a,b){var c=this.bb.get(a);c&&c.ek&&this.w.Es(this,a,b)};
d.Cl=function(a,b){H(this.a,"Remove route "+a);var c=this.Qb.Tg(a);if(c){b=b||c.qH;var e=c.clientId;H(this.a,"Remove client "+e);this.ma.q4(e);this.Qb.Ez(e)}if(e=this.ma.Tg(a))e.Cl(a),this.dI(e.Td);var f=this.bb.get(a);f&&(f.ek&&e&&(this.Rc.bD(f.sinkId,c?c.clientId:this.qd,e.session.transportId,b),f.forDisplay&&c&&(this.Bi={Wj:c,TK:e})),this.bb.remove(a),this.w.Pi(this,f),this.Rf().some(function(a){return a.isLocal})||this.w.yh(this.ka(),!1))};
d.Pba=function(a){a.Td.forEach(function(b){if(b=this.bb.get(b)){var c=a.session;b.pe&&b.forDisplay?this.OL(b):(b.description=c.statusText||c.displayName,this.w.lh(this,b))}}.bind(this))};d.Iba=function(a){bb(a,function(a){a=this.bb.get(a,null);if(!a||!a.mediaSource)return!1;var b=nk(a.mediaSource),b=b?b.Ex:!1;return a.isLocal&&!b},this)&&z(a,function(a){if(a=this.bb.get(a,null))a.isLocal=!0},this)};
d.dI=function(a){var b=[],c=[],e=null;a.forEach(function(a){if(a=this.bb.get(a)){a.forDisplay=!1;var f=nk(a.mediaSource);f&&eb(f.kn(),Qj)||(a.ek?(f=f?f.zw():null,e||f==chrome.cast.nf.CUSTOM_CONTROLLER_SCOPED||(b.push(a),e=a.sinkId)):e&&e!=a.sinkId?b.push(a):c.push(a))}}.bind(this));z(0<b.length?b:c,function(a){a.forDisplay=!0})};d.VB=function(a,b,c,e){var f=a.rc();f&&!this.Qb.Id(f)&&(H(this.a,"Add client "+f),this.Qb.Pu(b,f,a.kn(),a.zw(),c||null,l(e)?e:null))};
d.OL=function(a){var b=this.ma.Tg(a.id);b&&(b=b.session,b.statusText=a.description||b.statusText)};
d.Ie=function(a,b,c,e,f,g,k){var p=null!=a,q;null==a?(q=new hk([{appId:e.appId,capabilities:e.capabilities}]),a=q.toString()):q=nk(a);var A=k;if(A){if(!this.bb.get(A.id))return G(this.a,"Route "+A.id+" not added"),A}else A=Pk(a,b,c||e.sessionId,p),this.bb.set(A.id,A);c=A.id;H(this.a,"Add route "+c);a=null;q&&(a=q.rc(),this.VB(q,c,f,g));(f=this.ma.Dn(b.getId()))||(f=this.ma.Sp(e,b.getId()));f.Ie(c);A.ek&&this.Rc.P2(b,a||this.qd,e.transportId,!(q&&q.Ex));f.offTheRecord=A.offTheRecord;q=f.Td;this.Iba(q);
this.dI(q);q=A;g=e.sessionId;c=e.appId;("0F5096E8"==c||"85CDB22F"==c)&&g&&q.pe&&(q.pe.sessionId=g);!Oj(e,si)||null!==e&&gb(Pj,e.appId)||(q.customControllerPath="cast_route_details.html?"+["sessionId="+g,"appId="+c].join("&"));q.description=e.statusText||e.displayName;k?this.w.lh(this,A):(this.w.rl(this,A),A.isLocal&&this.w.yh(this.ka(),!0));a&&f.Pu(a)&&this.wd.W1(e,b,a);return A};
d.Zc=function(a){var b=this,c=this.bb.get(a);if(!c)return Promise.reject(new Ik(3,"Route in Cast provider not found for routeId  "+a));var e=this.ma.Tg(a);if(!e)return this.Cl(a,!0),Promise.resolve();var f=e.session.sessionId,g=this.$.W(c.sinkId);if(!g)return this.wd.$i(f),Promise.resolve();(a=this.Qb.Tg(a))&&this.wd.OK(a.clientId,g,chrome.cast.um.STOP);Yi(0);return new Promise(function(a){var c=function(){b.wd.dt(g.getId());a()};b.zd.K5(f,g).then(c,c)})};
d.JT=function(a){var b=null;yc(this.bb.qx(),function(c){if(!c.ek)return!1;var e=this.$.W(c.sinkId);if(!e||!a.D_(this.hz(c.mediaSource,e)))return!1;b=c;return!0},this);if(!b||!b.mediaSource)return null;var c=ok(b.mediaSource);if(!c)return null;var e=this.Qb.Id(c);return e?(c=this.ma.Id(c))?{Wj:e,TK:c}:null:null};
d.iQ=function(a,b,c){var e=this.JT(a);if(!e){if(!this.Bi||this.Bi.Wj.origin!=b||this.Bi.Wj.tabId!=c)return null;e=this.Bi}switch(a.zw()){case chrome.cast.nf.PAGE_SCOPED:return null;case chrome.cast.nf.ORIGIN_SCOPED:if(b!=e.Wj.origin)return null;break;case chrome.cast.nf.TAB_AND_ORIGIN_SCOPED:if(b!=e.Wj.origin||c!=e.Wj.tabId)return null}return this.ma.le(e.TK.session.sessionId)};
d.rD=function(a,b,c,e,f,g){var k=this,p=null;yc(this.bb.qx(),function(a){var b=a.pe;return b&&null!=b.tabId&&b.tabId==c&&Ng(a.mediaSource)?(p=a,!0):!1});if(!p)return null;var q=function(){return k.Ne(a,g||p.sinkId,"",e,f,b,null==c?void 0:c)};return ug(this.Zc(p.id).then(q,q))};
d.Th=function(a,b,c,e,f){if(!nk(a))return tg(Error("Unsupported presentation URL"));b=Mk(b);b=this.ma.le(b.yJ);if(!b)return tg(Error("No matching route"));var g=this.$.W(b.sinkId);if(!g)return tg(Error("No sink"));a=this.Ie(a,g,c,b.session,e,f);return sg(a)};
d.Ai=function(a,b,c,e,f,g){var k=nk(a);if(!k)return tg(Error("Unsupported presentation URL"));var p;if(b==chrome.cast.bO){if(p=this.iQ(k,f,g),!p&&k.XU()!=chrome.cast.Mp.CAST_THIS_TAB&&(e=this.rD(a,f,g,c,e)))return e}else p=0==b.indexOf(chrome.cast.KB)?this.ma.le(b.substr(chrome.cast.KB.length)):this.ma.zX(b);if(!p)return tg(Error("No matching route"));if(p.offTheRecord!=c)return tg(Error("Off the record mismatch"));e=this.$.W(p.sinkId);if(!e)return tg(Error("No sink"));a=this.Ie(a,e,b,p.session,f,
g);a.offTheRecord=c;return sg(a)};d.Ig=function(a){this.Cl(a,!1)};d.Pf=function(a){var b=!0,c=!0;if(a=this.$.W(a))b=a.xd,c=!!(b&1),b=!!(b&4);return Eh(b,c)};d.xn=function(){return"cast_streaming"};
d.Ch=function(a,b,c){var e=this;if(!c)return this.wd.re(a,b),Promise.resolve();var f=this.ma.Tg(a);if(!f)return Promise.reject(Error("Not managing the route "+a));var g=this.$.W(f.sinkId);if(!g)return Promise.reject(Error("Sink no longer accessible"));var k=(a=this.Qb.Tg(a))?a.clientId:this.qd;return new Promise(function(a){e.Rc.ot(g,c.namespace,b,k,f.session.transportId).then(a,a)})};
d.Gm=function(a,b){var c=this.$.W(b);if(!c)return!1;a=this.hz(a,c);return(a=mk(a))&&0!=a.length?bb(a,function(a){return vi(c.ie(a))}):!1};d.Sj=function(a,b){var c=this.ir(a);return c&&0!=c.length?b&&b.mediaSource?(a=mk(b.mediaSource),bb(a,function(a){return gb(c,a)},this)):!0:!1};d.VX=function(a){return(a=this.bb.get(a))?lk(a.mediaSource):null};
d.hz=function(a,b,c){return Og(a)||Pg(a)?(a={appId:0==(b.xd&1)?"85CDB22F":"0F5096E8",capabilities:Lj(b.xd)},(new hk([a],void 0,void 0,void 0,c)).toString()):a};d.ir=function(a){var b=[];Og(a)||Pg(a)?(b.push("85CDB22F"),b.push("0F5096E8")):(a=mk(a))&&(b=ob(b,a));return b};d.Cy=function(a){this.$.Cy(a.getId());Yi(2)};d.k1=function(a){this.wd.JJ(a,!0)};d.i1=function(a,b){this.JC.UY(a,b);this.wd.t2(a.getId(),b)};d.Qi=function(a){this.w.onSinkAvailabilityUpdated(this,1);this.ld(a);this.wd.JJ(a)};
d.Gs=function(a){if(0==this.$.Kc().length)this.w.onSinkAvailabilityUpdated(this,0);this.wd.Gs(a.getId());this.PG()};d.ld=function(a){this.cd.Po(a);this.PG()};d.PG=function(){this.JC.yZ();this.w.Oc()};var $k=function(a,b,c){this.RK=a;this.routes=b;this.O_=c};Zk.prototype.ka=function(){return"cast.Provider"};Zk.prototype.getData=function(){return[new $k(this.qd,this.bb.b(),this.Bi)]};Zk.prototype.fb=function(){var a=zi(this);a&&(this.qd=a.RK,this.bb.addAll(a.routes),this.Bi=a.O_)};Zk.prototype.fg=function(){return null};var al=function(){if(!Qc)return!1;try{return new ActiveXObject("MSXML2.DOMDocument"),!0}catch(a){return!1}},bl=Qc&&al();var cl=function(){this.he=[];this.Ke=[]};d=cl.prototype;d.q0=function(){0==this.he.length&&(this.he=this.Ke,this.he.reverse(),this.Ke=[])};d.enqueue=function(a){this.Ke.push(a)};d.Hg=function(){this.q0();return this.he.pop()};d.R=function(){return this.he.length+this.Ke.length};d.Tb=function(){return 0==this.he.length&&0==this.Ke.length};d.clear=function(){this.he=[];this.Ke=[]};d.contains=function(a){return gb(this.he,a)||gb(this.Ke,a)};
d.remove=function(a){var b;b=this.he;var c=Za(b,a);0<=c?(kb(b,c),b=!0):b=!1;return b||lb(this.Ke,a)};d.C=function(){for(var a=[],b=this.he.length-1;0<=b;--b)a.push(this.he[b]);for(var c=this.Ke.length,b=0;b<c;++b)a.push(this.Ke[b]);return a};var dl=function(a,b){Nd.call(this);this.vI=a||0;this.Hi=b||10;if(this.vI>this.Hi)throw Error("[goog.structs.Pool] Min can not be greater than max");this.fc=new cl;this.ah=new Jc;this.Wv=0;this.Sx=null;this.Vp()};x(dl,Nd);d=dl.prototype;d.getObject=function(){var a=w();if(!(null!=this.Sx&&a-this.Sx<this.Wv)){var b=this.p5();b&&(this.Sx=a,this.ah.add(b));return b}};d.Zi=function(a){return this.ah.remove(a)?(this.Qu(a),!0):!1};
d.p5=function(){for(var a;0<this.mF()&&(a=this.fc.Hg(),!this.zy(a));)this.Vp();!a&&this.R()<this.Hi&&(a=this.Df());return a};d.Qu=function(a){this.ah.remove(a);this.zy(a)&&this.R()<this.Hi?this.fc.enqueue(a):this.Zh(a)};d.Vp=function(){for(var a=this.fc;this.R()<this.vI;)a.enqueue(this.Df());for(;this.R()>this.Hi&&0<this.mF();)this.Zh(a.Hg())};d.Df=function(){return{}};d.Zh=function(a){if("function"==typeof a.mb)a.mb();else for(var b in a)a[b]=null};
d.zy=function(a){return"function"==typeof a.aR?a.aR():!0};d.contains=function(a){return this.fc.contains(a)||this.ah.contains(a)};d.R=function(){return this.fc.R()+this.ah.R()};d.$V=function(){return this.ah.R()};d.mF=function(){return this.fc.R()};d.Tb=function(){return this.fc.Tb()&&this.ah.Tb()};d.L=function(){dl.S.L.call(this);if(0<this.$V())throw Error("[goog.structs.Pool] Objects not released");delete this.ah;for(var a=this.fc;!a.Tb();)this.Zh(a.Hg());delete this.fc};var el=function(a,b){this.es=a;this.Dj=b};el.prototype.getKey=function(){return this.es};el.prototype.hc=function(){return this.Dj};el.prototype.clone=function(){return new el(this.es,this.Dj)};var fl=function(a){this.Pd=[];a&&this.e_(a)};d=fl.prototype;d.insert=function(a,b){var c=this.Pd;c.push(new el(a,b));this.P0(c.length-1)};d.e_=function(a){var b;if(a instanceof fl){if(b=a.ib(),a=a.C(),0>=this.R()){for(var c=this.Pd,e=0;e<b.length;e++)c.push(new el(b[e],a[e]));return}}else b=Cb(a),a=Bb(a);for(e=0;e<b.length;e++)this.insert(b[e],a[e])};d.remove=function(){var a=this.Pd,b=a.length,c=a[0];if(!(0>=b))return 1==b?hb(a):(a[0]=a.pop(),this.O0(0)),c.hc()};
d.O0=function(a){for(var b=this.Pd,c=b.length,e=b[a];a<c>>1;){var f=this.hW(a),g=this.TX(a),f=g<c&&b[g].getKey()<b[f].getKey()?g:f;if(b[f].getKey()>e.getKey())break;b[a]=b[f];a=f}b[a]=e};d.P0=function(a){for(var b=this.Pd,c=b[a];0<a;){var e=this.hX(a);if(b[e].getKey()>c.getKey())b[a]=b[e],a=e;else break}b[a]=c};d.hW=function(a){return 2*a+1};d.TX=function(a){return 2*a+2};d.hX=function(a){return a-1>>1};d.C=function(){for(var a=this.Pd,b=[],c=a.length,e=0;e<c;e++)b.push(a[e].hc());return b};
d.ib=function(){for(var a=this.Pd,b=[],c=a.length,e=0;e<c;e++)b.push(a[e].getKey());return b};d.bk=function(a){return bb(this.Pd,function(b){return b.hc()==a})};d.xa=function(a){return bb(this.Pd,function(b){return b.getKey()==a})};d.clone=function(){return new fl(this)};d.R=function(){return this.Pd.length};d.Tb=function(){return 0==this.Pd.length};d.clear=function(){hb(this.Pd)};var gl=function(){fl.call(this)};x(gl,fl);gl.prototype.enqueue=function(a,b){this.insert(a,b)};gl.prototype.Hg=function(){return this.remove()};var hl=function(a,b){this.CD=void 0;this.ht=new gl;dl.call(this,a,b)};x(hl,dl);d=hl.prototype;d.getObject=function(a,b){if(!a)return(a=hl.S.getObject.call(this))&&this.Wv&&(this.CD=h.setTimeout(v(this.Mr,this),this.Wv)),a;this.ht.enqueue(l(b)?b:100,a);this.Mr()};d.Mr=function(){for(var a=this.ht;0<a.R();){var b=this.getObject();if(b)a.Hg().apply(this,[b]);else break}};d.Qu=function(a){hl.S.Qu.call(this,a);this.Mr()};d.Vp=function(){hl.S.Vp.call(this);this.Mr()};
d.L=function(){hl.S.L.call(this);h.clearTimeout(this.CD);this.ht.clear();this.ht=null};var il=function(a,b,c,e){this.wi=a;this.sg=!!e;hl.call(this,b,c)};x(il,hl);il.prototype.Df=function(){var a=new pf,b=this.wi;b&&b.forEach(function(b,e){a.headers.set(e,b)});this.sg&&a.FA(!0);return a};il.prototype.zy=function(a){return!a.isDisposed()&&!a.Tf()};var jl=function(a,b,c,e,f,g){K.call(this);this.Vf=l(a)?a:1;this.pg=l(f)?Math.max(0,f):0;this.sg=!!g;this.rm=new il(b,c,e,g);this.Bc=new D;this.Da=new Xh(this)};x(jl,K);var kl="ready complete success error abort timeout".split(" ");d=jl.prototype;d.Gt=function(a){this.pg=Math.max(0,a)};
d.send=function(a,b,c,e,f,g,k,p,q,A){if(this.Bc.get(a))throw Error("[goog.net.XhrManager] ID in use");b=new ll(b,v(this.aZ,this,a),c,e,f,k,l(p)?p:this.Vf,q,l(A)?A:this.sg);this.Bc.set(a,b);a=v(this.RY,this,a);this.rm.getObject(a,g);return b};d.abort=function(a,b){var c=this.Bc.get(a);if(c){var e=c.wu;c.Z6(!0);b&&(e&&(this.gK(e,c.uB),me(e,"ready",function(){this.rm.Zi(e)},!1,this)),this.Bc.remove(a));e&&e.abort()}};
d.RY=function(a,b){var c=this.Bc.get(a);c&&!c.wu?(this.YP(b,c.uB),b.Gt(this.pg),b.kM(c.El),b.FA(c.sg),c.wu=b,this.dispatchEvent(new ml("ready",this,a,b)),this.sK(a,b),c.SB&&b.abort()):this.rm.Zi(b)};d.aZ=function(a,b){var c=b.target;switch(b.type){case "ready":this.sK(a,c);break;case "complete":return this.XY(a,c,b);case "success":this.HZ(a,c);break;case "timeout":case "error":this.Mn(a,c);break;case "abort":this.PY(a,c)}return null};
d.sK=function(a,b){var c=this.Bc.get(a);!c||c.hD||c.yx()?(c&&(this.gK(b,c.uB),this.Bc.remove(a)),this.rm.Zi(b)):(c.VZ(),b.send(c.getUrl(),c.H0,c.ed,c.pr()))};d.XY=function(a,b,c){var e=this.Bc.get(a);if(7==b.dh||b.Md()||e.yx())if(this.dispatchEvent(new ml("complete",this,a,b)),e&&(e.H7(!0),e.gD))return e.gD.call(b,c);return null};d.PY=function(a,b){this.dispatchEvent(new ml("abort",this,a,b))};d.HZ=function(a,b){this.dispatchEvent(new ml("success",this,a,b))};
d.Mn=function(a,b){this.Bc.get(a).yx()&&this.dispatchEvent(new ml("error",this,a,b))};d.gK=function(a,b,c){this.Da.vd(a,c||kl,b)};d.YP=function(a,b,c){this.Da.listen(a,c||kl,b)};d.L=function(){jl.S.L.call(this);this.rm.mb();this.rm=null;this.Da.mb();this.Da=null;this.Bc.clear();this.Bc=null};var ml=function(a,b,c,e){J.call(this,a,b);this.id=c;this.wu=e};x(ml,J);
var ll=function(a,b,c,e,f,g,k,p,q){this.mu=a;this.H0=c||"GET";this.ed=e;this.wi=f||null;this.Vf=l(k)?k:1;this.qC=0;this.SB=this.hD=!1;this.uB=b;this.gD=g;this.El=p||"";this.sg=!!q;this.wu=null};d=ll.prototype;d.getUrl=function(){return this.mu};d.pr=function(){return this.wi};d.vr=function(){return this.Vf};d.VZ=function(){this.qC++};d.yx=function(){return this.qC>this.Vf};d.H7=function(a){this.hD=a};d.Z6=function(a){this.SB=a};var nl=function(){this.name="unknown";this.state="error";this.i_=null;this.allowStop=!0;this.serviceData=this.cj=null;this.extraData={}},ql=function(a,b,c){this.Be=a;(a=b)||(ol||(ol=new jl(3,null,1,10,2E3)),a=ol);this.Lp=a;this.sm=[];c||(pl||(pl=new jl(0,null,1,10,15E3)),c=pl);this.aO=c;this.a=E("mr.dial.Client")};ql.prototype.abort=function(){this.sm.forEach(function(a){this.Lp.abort(a,!0);this.aO.abort(a,!0)},this)};var ol=null,pl=null,rl=999;
ql.prototype.launchApp=function(a,b){var c=new ff,e=(++rl).toString();this.sm.push(e);this.aO.send(e,this.yw(a),"POST",b,null,0,this.oE("launchApp","POST",e,c));return c.promise};ql.prototype.QM=function(a){var b=new ff,c=(++rl).toString();this.sm.push(c);this.Lp.send(c,this.yw(a),"DELETE",null,null,0,this.oE("stopApp","DELETE",c,b),0);return b.promise};var sl=function(a,b){this.$N=a;this.rf=b;this.s6=!!b&&"running"==b.state};
ql.prototype.xw=function(a){var b=this;return new Promise(function(c){var e=(++rl).toString();b.sm.push(e);b.Lp.send(e,b.yw(a),"GET",null,null,0,v(b.C1,b,e,c))})};
ql.prototype.C1=function(a,b,c){lb(this.sm,a);a=c.target;hf(this.a,"GetAppInfo","GET",a,!0);if(a.Md()){c=a.gG();if(!c)if(c=a.Jk(),"undefined"!=typeof DOMParser)c=(new DOMParser).parseFromString(c,"application/xml");else if(bl){var e=new ActiveXObject("MSXML2.DOMDocument");e.resolveExternals=!1;e.validateOnParse=!1;try{e.setProperty("ProhibitDTD",!0),e.setProperty("MaxXMLSize",2048),e.setProperty("MaxElementDepth",256)}catch(p){}e.loadXML(c);c=e}else throw Error("Your browser does not support loading xml documents");
if(c)if((e=c.getElementsByTagName("service"))&&1==e.length){c=new nl;for(var f=0,g=e[0].childNodes.length;f<g;f++){var k=e[0].childNodes[f];if("state"==k.nodeName){a:switch(k.textContent){case "running":k="running";break a;case "stopped":k="stopped";break a;default:k="error"}c.state=k}else"name"==k.nodeName?c.name=k.textContent:"link"==k.nodeName?c.cj=k.getAttribute("href"):"options"==k.nodeName?c.allowStop="false"!=k.getAttribute("allowStop"):c.extraData[k.nodeName]=k.innerHTML}if("unknown"==c.name)H(this.a,
"GET response missing name value"),b(new sl(a,null));else if("error"==c.state)H(this.a,"GET response missing state value"),b(new sl(a,null));else{if((e=/installable=(.+)/.exec(c.state))&&e[1])c.state="installable",c.i_=e[1];else if("running"!=c.state&&"stopped"!=c.state){H(this.a,"GET response has invalid state value");b(new sl(a,null));return}b(new sl(a,c))}}else H(this.a,"Invalid GET response (invalid service)"),b(new sl(a,null));else H(this.a,"Empty response"),b(new sl(a,null))}else H(this.a,"Request to "+
a.sr()+" failed"),b(new sl(a,null))};ql.prototype.yw=function(a){var b=this.Be.Jg;"/"!=b.charAt(b.length-1)&&(b+="/");return b+a};ql.prototype.oE=function(a,b,c,e){return v(function(f){lb(this.sm,c);f=f.target;hf(this.a,a,b,f,!0);f.Md()?e.resolve(void 0):e.reject(Error(jf(f.dh)))},this)};var tl=function(a,b,c){this.appName=b;this.launchParameter=c||""},ul=E("mr.DialProvider"),wl=function(a){if(Da(a,"urn:dial-multiscreen-org:dial:application:")){var b=a.indexOf("?"),c=a.substring(42,0<b?b:void 0);a=c&&0<c.length?new tl(a,c,0<b?a.substring(b+1):void 0):null}else a=vl(a);return a},xl=/__dialAppName__=([A-Za-z0-9-._~!$&'()*+,;=%]+)/,yl=/__dialPostData__=([A-Za-z0-9]+={0,2})/,vl=function(a){var b=(new Wj(a)).fi;if(!b)return null;var c=xl.exec(b),c=c?c[1]:null;if(!c)return null;c=decodeURIComponent(c);
if(b=(b=yl.exec(b))?b[1]:void 0)try{b=Vh(b)}catch(e){return G(ul,"Invalid base64 encoded postData:"+b),null}return new tl(a,c,b)};var zl=function(a,b){this.ab=a;this.appName=b};var Al=function(a){this.od=new Map;this.Nu=a};d=Al.prototype;d.init=function(){Ci(this)};d.clear=function(){this.od.clear()};d.add=function(a){this.KE(a.ab.id)||(this.od.set(a.ab.id,a),this.Nu.V0(a))};d.KE=function(a){return this.od.get(a)||null};d.ME=function(a){for(var b=ja(this.od),c=b.next();!c.done;c=b.next())if(c=ja(c.value),c.next(),c=c.next().value,c.ab.sinkId==a)return c;return null};d.l5=function(a){if(a=this.ME(a))this.od.delete(a.ab.id),this.Nu.FI(a)};
d.cK=function(a){var b=this.od.get(a);b&&(this.od.delete(a),this.Nu.FI(b))};d.Rf=function(){return Array.from(this.od.values(),function(a){return a.ab})};d.YT=function(){return Array.from(this.od.values())};d.ka=function(){return"dial.ActivityRecords"};d.getData=function(){return[Array.from(this.od)]};d.fb=function(){var a=zi(this);a&&(this.od=new Map(a))};var Bl={Cda:0,Nfa:1,Vea:2,Bda:3},Cl={ERROR:0,mfa:1,EMPTY:2},Dl=function(a){Fg("MediaRouter.Dial.Create.Route",a,Bl)},El=function(a){Fg("MediaRouter.Dial.Device.Description.Failure",a,Cl)};var Fl=function(a){return Promise.all(a.map(function(a){return a.then(function(a){return{uE:!0,value:a}},function(a){return{uE:!1,reason:a}})}))};var Gl=function(a,b){this.a=E("mr.dial.AppDiscoveryService");this.Ac=new Set;this.$=a;this.$c=b;this.$b=new Map;this.Hv=new Map;this.De=null;this.Hl=!1};d=Gl.prototype;d.init=function(){Ci(this)};d.start=function(){H(this.a,"Starting periodic scanning.");this.Hl||(this.Hl=!0,this.OD())};d.stop=function(){H(this.a,"Stopping periodic scanning.");this.Hl&&(this.Hl=!1,this.De&&(clearTimeout(this.De),this.De=null),this.$b.clear(),this.Hv.forEach(function(a){a.abort()}))};
d.xz=function(a){if(!this.Ac.has(a)||this.bQ(a))this.Ac.add(a),0!=this.$.Dr()&&(this.Hl?this.$.Kc().forEach(this.ND.bind(this,a)):this.start())};d.eB=function(a){this.Ac.delete(a)};d.DX=function(){return Array.from(this.Ac)};
d.OD=function(){var a=this;H(this.a,"Start app status scan.");var b=[];this.$.Kc().forEach(function(a){b.push.apply(b,this.Po(a))},this);this.$c.YT().forEach(function(a){b.push(this.u6(a))},this);var c=function(){a.Hl&&!a.De&&(I(a.a,"Scan complete; scheduling for next scan."),a.De=setTimeout(a.OS.bind(a),6E4))};Fl(b).then(c,c)};d.OS=function(){I(this.a,"Start app status scan (timer-based)");this.De=null;this.OD()};
d.Po=function(a){if(!a.dm)return[];for(var b=[],c=ja(this.Ac),e=c.next();!e.done;e=c.next())b.push(this.ND(e.value,a));return b};d.ND=function(a,b){if("unknown"!=b.ie(a)&&36E5>w()-b.$T(a)||!b.dm)return Promise.resolve();I(this.a,"Querying "+b.getId()+" for "+a+" to update app status");return this.EE(b,a).then(this.u0.bind(this,b,a))};
d.u6=function(a){var b=this.$.W(a.ab.sinkId);if(!b)return G(this.a,"Activity refers to nonexistent sink: "+a.ab.id),Promise.resolve();if(!b.dm)return Promise.resolve();a=a.appName;I(this.a,"Querying "+b.getId()+" for "+a+" to update activity");return this.EE(b,a).then(this.t0.bind(this,b,a))};d.kV=function(a){var b=this.Hv.get(a.getId());b||(b=new ql(a),I(this.a,"Created DIAL client for "+a.getId()),this.Hv.set(a.getId(),b));return b};
d.EE=function(a,b){var c=this,e=Hl(a,b),f=this.$b.get(e);if(f)return f;f=this.kV(a).xw(b);this.$b.set(e,f);a=function(){c.$b.delete(e)};f.then(a,a);return f};d.jU=function(a,b){if(404==b.$N.eb())return"unavailable";b=b.rf;if("Netflix"==a)return this.NS(b);switch(b.state){case "running":case "stopped":return"available";default:return"unavailable"}};
d.NS=function(a){return a.extraData&&l(a.extraData.capabilities)&&"websocket"==a.extraData.capabilities&&("running"==a.state||"stopped"==a.state)?"available":"unavailable"};var Hl=function(a,b){return a.getId()+":"+b};d=Gl.prototype;d.u0=function(a,b,c){if(404==c.$N.eb()||c.rf){c=this.jU(b,c);I(this.a,"Got app status "+c+" from "+a.getId()+" for "+b);var e=a.ie(b);a.Vo(b,c);c!=e&&this.$.d1(b,a)}else G(this.a,"Failed to process app availability; "+a.getId()+" does not support app availability"),a.vM(!1)};
d.t0=function(a,b,c){(a=this.$c.ME(a.getId()))&&a.appName==b&&!c.s6&&this.$c.cK(a.ab.id)};d.bQ=function(a){return this.$.Kc().some(function(b){return"unknown"==b.ie(a)})};d.ka=function(){return"dial.AppDiscoveryService"};d.getData=function(){return[this.DX()]};d.fb=function(){var a=zi(this);this.Ac=new Set(a||[])};var Il=function(){this.configId=this.modelName=this.deviceType=this.lw=this.nw=this.aq=this.ipAddress=this.friendlyName=this.deviceLabel=this.zp=null};Il.prototype.dca=function(){return this.deviceLabel?this.zp?this.friendlyName?this.ipAddress?this.aq?this.nw?this.lw?null:"Missing expireTimeMillis":"Missing fetchTimeMillis":"Missing appUrl":"Missing ipAddress":"Missing friendlyName":"Missing uniqueId":"Missing deviceLabel"};
Il.prototype.toString=function(){return JSON.stringify(this,function(a,b){return t(b)&&0==b.indexOf("uuid:")?"***":b})};var Ll=function(a){this.sv=new D;this.$b=new Jc;this.az=new D;var b;(b=a)||(Jl||(Jl=new jl(3,null,1,10,2E3)),b=Jl);this.Lp=b;a||(Kl||(Kl=new jl(2,null,1,10,3E3)),a=Kl);this.CP=a;this.a=E("mr.dial.DeviceDescriptionService")},Jl=null,Kl=null;d=Ll.prototype;
d.hV=function(a){var b=this.oR(a);return b?(Eg("MediaRouter.Dial.Device.Description.Cached"),Promise.resolve(b)):this.$b.contains(a.deviceLabel)?Promise.reject(Error("Duplicate request for device "+a.deviceLabel)):this.AT(a)};d.oR=function(a){var b=this.sv.get(a.deviceLabel);return b?b.configId!=a.configId||w()>=b.lw?(I(this.a,"Removing invalid entry "+b.toString()),this.sv.remove(a.deviceLabel),null):b:null};
d.AT=function(a){var b=this;return new Promise(function(c,e){b.$b.add(a.deviceLabel);b.Lp.send(a.deviceLabel,a.deviceDescriptionUrl,"GET",null,null,0,function(f){(f=b.h4(a,f))?c(f):e(Error("Failed to get device description"))})})};
d.h4=function(a,b){this.$b.remove(a.deviceLabel);b=b.target;hf(this.a,"fetchDeviceDescription","GET",b);if(!b.Md())return H(this.a,"Request to "+b.sr()+" failed"),El(0),null;var c=b.gG();if(!c)return H(this.a,"Invalid or empty response"),El(2),null;b=this.k3(b,a,c);if(!b)return El(1),H(this.a,"Invalid device description"),null;H(this.a,"Got device description for "+b.deviceLabel);I(this.a,"... device description was: "+b.toString());null!=b.configId&&(I(this.a,"Caching device description for "+b.deviceLabel),
this.sv.set(a.deviceLabel,b));return b};
d.k3=function(a,b,c){var e=new Il;e.nw=w();e.lw=e.nw+18E5;e.deviceLabel=b.deviceLabel;e.configId=b.configId;e.aq=a.getResponseHeader("Application-URL")||null;a=e.aq;a=a instanceof Wj?a.clone():new Wj(a,void 0);e.ipAddress=a.Mf();e.deviceType=Ml(c,"deviceType");e.modelName=Ml(c,"modelName");e.friendlyName=Ml(c,"friendlyName");e.zp=Ml(c,"UDN");a=e.dca();I(this.a,"Device description: "+Nl(c));return a?(G(this.a,"Device description failed to validate ("+a+"): "+JSON.stringify(e)),null):e};
var Ml=function(a,b){return(a=a.getElementsByTagName(b))&&0!=a.length?a[0].textContent:null},Nl=function(a){var b=function(a){for(var b=0,c=a.length;b<c;b++)a[b].textContent="***"};b(a.getElementsByTagName("UDN"));b(a.getElementsByTagName("serialNumber"));return(new XMLSerializer).serializeToString(a)};
Ll.prototype.Im=function(a){var b=this.az.get(a);if(b)return b.promise;b=new ff;this.az.set(a,b);this.CP.send(a,a,"GET",null,null,0,v(function(c){this.az.remove(a);c=c.target;hf(this.a,"checkAccess","GET",c,!1);b.resolve(c.Md())},this));return b.promise};var Ol=null,Pl=null,Ql=function(){Ol||(Ol=new fj("dial.DialOnDeviceListEventListener","mr.dial.SinkDiscoveryService",chrome.dial.onDeviceList));Pl||(Pl=new fj("dial.DialOnErrorEventListener","mr.dial.SinkDiscoveryService",chrome.dial.onError));return[Ol,Pl]};var Rl=function(a,b){this.Xf="mr.dial.SinkDiscoveryService";this.gp=a;this.FD=b||new Ll;this.a=E("mr.dial.SinkDiscoveryService");this.Ae=new D;this.As=this.jy=!1};x(Rl,aj);var Sl={YouTube:"https://www.youtube.com",Netflix:"https://www.netflix.com",Pandora:"https://www.pandora.com",Radio:"https://www.pandora.com",Hulu:"https://www.hulu.com",Vimeo:"https://www.vimeo.com",Dailymotion:"https://www.dailymotion.com","com.dailymotion":"https://www.dailymotion.com"};d=Rl.prototype;
d.init=function(){Ci(this);ej(this)};d.start=function(){this.jy||(H(this.a,"Starting..."),this.jy=!0,Ql().forEach(function(a){return a.register()}),this.refresh())};d.refresh=function(){this.jy?chrome.dial.discoverNow(v(function(a){H(this.a,"chrome.dial.discoverNow = "+a)},this)):H(this.a,"Not started. Ignoring discover().")};
d.w1=function(a){var b=this;H(this.a,"onDeviceList returned "+a.length+" devices");I(this.a,"....the list is: "+JSON.stringify(a));this.As=!1;var c=[],e=new Jc;a.forEach(function(a){var b=this;c.push(this.i4(a).then(function(a){e.add(a.getId());b.o0(a)},function(){}))},this);a=function(){b.As||b.Ao(e)};Promise.all(c).then(a,a)};
d.o0=function(a){if(!this.As){I(this.a,"mayAddSink, id = "+a.getId());var b=this.Ae.get(a.getId());b?b.update(a)&&(I(this.a,"Updated sink "+b.getId()),this.gp.ld(b)):(I(this.a,"Adding new sink "+a.getId()),Md(this.a,Ed,"...sink was "+a.fN()),this.Ae.set(a.getId(),a),this.gp.Qi(a))}};d.Ao=function(a){this.Ae.C().forEach(function(b){var c=this;a.contains(b.getId())||this.nR(b).then(function(a){a||(c.Ae.remove(b.getId()),c.gp.se([b]))})},this)};d.nR=function(a){return a.Gf?this.FD.Im(a.Gf):Promise.resolve(!1)};
d.i4=function(a){return this.FD.hV(a).then(function(b){var c;b.zp?(c=b.zp,0==c.indexOf("uuid:")&&(c=c.substr(5)),c=c.replace(/-/g,"").toLowerCase()):c="";var e=b.zp?Mi.N().hn(c):a.deviceLabel,f=Tl.test(b.modelName);return(new Ni(b.friendlyName,c)).yt(e).B8(b.ipAddress).Y7(b.aq).V7(a.deviceDescriptionUrl).d9(b.modelName).vM(!f)})};var Tl=/Eureka Dongle|Chromecast Audio/i;d=Rl.prototype;
d.B2=function(a){switch(a.code){case "no_valid_network_interfaces":case "network_disconnected":G(this.a,"DIAL error: "+a.code+". Clear device list now.");a=this.Ae.C();this.Ae.clear();this.gp.se(a);this.As=!0;break;case "no_listeners":case "socket_error":case "cellular_network":case "unknown":G(this.a,"DIAL error: "+a.code+". Keep device list.");break;default:G(this.a,"Unhandled DIAL error: "+a.code)}};d.W=function(a){return this.Ae.get(a,null)};
d.gY=function(a){var b=[];this.Kc().forEach(function(c){"available"==c.ie(a)&&b.push(c.Qg())});var c=Sl[a];return new Jk(b,c?[c]:void 0)};d.Kc=function(){return this.Ae.C()};d.Dr=function(){return this.Ae.R()};d.d1=function(a,b){this.gp.ld(b)};
d.handleEvent=function(a,b){for(var c=[],e=1;e<arguments.length;++e)c[e-1]=arguments[e];if(a==chrome.dial.onDeviceList)this.w1.apply(this,[].concat(ka(c)));else if(a==chrome.dial.onError)this.B2.apply(this,[].concat(ka(c)));else throw Error("Unhandled event");};d.ka=function(){return"dial.DialSinkDiscoveryService"};d.getData=function(){return[this.Ae.b()]};d.fb=function(){var a=zi(this);if(a)for(var b in a)this.Ae.set(b,Oi(a[b]))};var Ul=function(a,b,c){this.w=a;this.Dc=b||new Rl(this);this.$c=new Al(this);this.cd=c||new Gl(this.Dc,this.$c);this.h6=new wj("dial.RouteIdGenerator")};d=Ul.prototype;d.a=E("mr.DialProvider");d.getName=function(){return"dial"};d.Ld=function(){this.h6.VD();this.$c.init();this.Dc.init();this.cd.init();this.eo()};d.ln=function(a){I(this.a,"GetAvailableSinks for "+a);return(a=wl(a))?this.Dc.gY(a.appName):Kk};d.vj=function(a){if(a=wl(a))this.cd.xz(a.appName),this.eo()};
d.yj=function(a){if(a=wl(a))this.cd.eB(a.appName),this.ws()};d.uj=function(){this.eo()};d.xj=function(){this.ws()};d.ws=function(){(0==this.Dc.Dr()||0==this.cd.Ac.size&&0==this.$c.od.size)&&this.cd.stop()};d.eo=function(){this.Dc.start();0<this.Dc.Dr()&&(0<this.cd.Ac.size||0<this.$c.od.size)&&this.cd.start()};d.W=function(a){return(a=this.Dc.W(a))?a.Qg():null};d.Rf=function(){return this.$c.Rf()};
d.Ne=function(a,b,c,e){var f=this,g=this.Dc.W(b);if(!g)return Dl(0),tg(Error("Unkown sink: "+b));Mi.N().Yi=new Li(g.xc,g.pa);var k=wl(a);if(!k)return tg(Error("No app name set."));var p=k.appName,q=new ql(g);return ug(q.xw(p).then(function(a){if(!a.rf)throw Error("Failed to get app info");if("running"==a.rf.state)return q.QM(p)}).then(function(){return q.launchApp(p,k.launchParameter)}).then(function(){return f.Ie(b,a,!0,p,c,e)}).catch(function(a){Dl(3);throw a;}))};d.Ai=function(){return tg(Error("no supported"))};
d.Th=function(){return tg(Error("no supported"))};d.Ig=function(){};d.Ie=function(a,b,c,e,f,g){Dl(1);a=Ok(f,this.getName(),a,b,c,e,null);a.offTheRecord=g;this.$c.add(new zl(a,e));return a};d.Qi=function(a){this.w.onSinkAvailabilityUpdated(this,1);this.eo();this.cd.Po(a);this.w.Oc();Mi.N().Xi=new Li(a.xc,a.pa)};d.se=function(a){if(0==this.Dc.Dr())this.w.onSinkAvailabilityUpdated(this,0);this.ws();a.forEach(function(a){this.$c.l5(a.getId())},this);this.w.Oc()};d.ld=function(){this.w.Oc()};
d.V0=function(a){this.eo();this.w.rl(this,a.ab)};d.FI=function(a){a=a.ab;if(a.isLocal)this.w.onPresentationConnectionStateChanged(a.id,"terminated");this.ws();this.w.Pi(this,a)};d.Zc=function(a){var b=this.$c.KE(a);if(!b)return Promise.reject(new Ik(3,"Route in DIAL provider not found for routeId "+a));this.$c.cK(a);return(a=this.Dc.W(b.ab.sinkId))?(new ql(a)).QM(b.appName):Promise.reject(new Ik(3,"Sink in DIAL provider not found for sinkId "+b.ab.sinkId))};d.Pf=function(){return null};d.xn=function(){return null};
d.Ch=function(){return Promise.reject(Error("DIAL sending message is not supported"))};d.Gm=function(a,b){b=this.Dc.W(b);return!b||Og(a)?!1:(a=wl(a))?"available"==b.ie(a.appName):!1};d.Sj=function(){return!1};d.fg=function(){return null};var Vl=function(a,b){this.hR=a;this.Zv=b;this.Bg=this.hR.$;this.a=E("mr.cast.CastDialSinkDiscoveryCallbacks")};d=Vl.prototype;d.SS=function(a){return this.Bg.Im(a)};d.mG=function(a){var b=this.Bg.W(a.getId());return b?b:(a=a.pa)?this.Bg.eY(a,Mi.N().Tj||8009):null};d.Qi=function(a){this.mG(a)?Zi(2):this.qN(a);this.Zv.Qi(a)};d.qN=function(a){var b=this,c=Ri(a);c&&this.SS(c).then(function(e){e?b.mG(a)?Zi(2):(b.Bg.wm(c),Zi(0)):Eg("MediaRouter.Dial.Sink.Discovered.NonCast")},n)};
d.se=function(a){z(a,function(a){var b=this.Bg.W(a.getId());b&&b.lk&&this.Bg.Dl(a.getId())},this);this.Zv.se(a)};d.ld=function(a){var b=this.Bg.W(a.getId());b?b.lk&&(b.update(a.tn(),a.pa,b.Eb(),b.xd)&&H(this.a,"Updated Cast sink with DIAL sink: "+a.getId()),this.Bg.ld(b)):this.qN(a);this.Zv.ld(a)};var Wl=function(a,b){this.$=new Rl(new Vl(b,this));this.Ah=new D;this.w=a;this.Uo=this.gj=0;this.Zn=new Jc;this.Xa=new Ul(this,this.$)},Xl=function(a,b,c,e){this.j6=a;this.sequenceNumber=b;this.Y6=c;this.Q_=e};Wl.prototype.ka=function(){return"cast.DialProviderWrapper"};Wl.prototype.getData=function(){return[new Xl(this.Ah.b(),this.gj,this.Uo,this.Zn.C())]};Wl.prototype.fb=function(){var a=zi(this);a&&(this.Ah.addAll(a.j6),this.gj=a.sequenceNumber,this.Uo=a.Y6,this.Zn.addAll(a.Q_))};var Yl=/__dialAppName__/;
d=Wl.prototype;d.getName=function(){return this.Xa.getName()};d.Ld=function(){this.Xa.Ld();Ci(this)};d.Rf=function(){return this.Xa.Rf()};d.TI=function(){};d.ln=function(a){return this.Xa.ln(a)};d.vj=function(a){this.Xa.vj(a)};d.yj=function(a){this.Xa.yj(a)};d.uj=function(a){this.Xa.uj(a)};d.xj=function(a){this.Xa.xj(a)};d.W=function(a){return this.Xa.W(a)};d.kr=function(a){return new ql(a)};d.Iw=function(a){return this.$.W(a)};
d.LS=function(a,b,c,e){var f=this,g=wl(a),k=this.Iw(b);if(!k)return Promise.reject(Error("Attempting custom launch with closed route"));var p=g.appName;if(!p)return Promise.reject(Error("No app name given"));var q=lk(a);if(!q)return Promise.reject(Error("No client ID"));var A=null;return this.kr(k).xw(p).then(function(a){if(!a.rf)return Promise.reject(Error("Failed to get app info"));A=a.rf}).then(function(){return f.Xa.Ie(b,a,!0,p,e||"",c)}).then(function(a){var b={routeId:a.id,wH:!1,sinkId:k.getId(),
appName:p,rf:A,launchParameter:g.launchParameter,session:null,clientId:null};f.Ah.set(a.id,b);f.$R(b,q);return a})};d.n_=function(a){return Yl.test(a)};d.Ne=function(a,b,c,e,f,g,k){return this.n_(a)?ug(this.LS(a,b,e,c)):this.Xa.Ne(a,b,c,e,f,g,k)};
d.Zc=function(a){var b=this.Ah.get(a);return b&&b.session&&b.clientId?(a={receiver:this.Ov(b.sinkId),action:chrome.cast.um.STOP},a=new Sj("receiver_action",a),a.clientId=b.clientId,this.w.re(this,b.routeId,a),a=new Sj("remove_session",b.session.sessionId,void 0),a.clientId=b.clientId,this.w.re(this,b.routeId,a),b.wH=!0,Promise.resolve()):this.Xa.Zc(a)};
d.Ch=function(a,b,c){var e=JSON.parse(b);switch(e.type){case "client_connect":return this.F5(a,e.clientId);case "custom_dial_launch":if(this.Zn.contains(e.sequenceNumber))return this.o1(a,e);break;case "v2_message":if("STOP"==e.message.type)return this.Zc(a),Promise.resolve()}return this.Xa.Ch(a,b,c)};d.aX=function(){var a=String(this.Uo);this.Uo=(this.Uo+1)%9007199254740992;return a};
d.$R=function(a,b){var c=this.Ov(a.sinkId),e=new Sj("receiver_action",{receiver:c,action:chrome.cast.um.CAST});e.clientId=b;this.w.re(this,a.routeId,e);c=new chrome.cast.A(this.aX(),"",a.appName,[],c);a.session=c;a.clientId=b;c=new Sj("new_session",c);c.clientId=b;this.w.re(this,a.routeId,c)};
d.o1=function(a,b){this.Zn.remove(b.sequenceNumber);b=b.message;a=this.Ah.get(a);if(!a)return Promise.reject(Error("Unknown route"));if(b&&!b.doLaunch)return Promise.resolve();var c=this.Iw(a.sinkId);if(!c)return Promise.reject(Error("Custom launch response for sink that no longer exists"));var c=new ql(c),e=a.launchParameter,e=(b?b.launchParameter:null)||e;return c.launchApp(a.appName,e)};
d.Ov=function(a){var b=this.Iw(a);a=new chrome.cast.Fu(a,b.tn());a.ipAddress=b.pa;a.receiverType=chrome.cast.Op.DIAL;return a};d.$W=function(){var a=this.gj;this.gj=(this.gj+1)%9007199254740992;return a};
d.F5=function(a,b){a=this.Ah.get(a);if(!a)return Promise.reject(Error("Unknown route"));var c=this.Ov(a.sinkId);c.receiverType=chrome.cast.Op.DIAL;c=new Sj("custom_dial_launch",new chrome.cast.FB(c,a.rf.state,a.rf.extraData));c.clientId=b;c.sequenceNumber=this.$W();this.Zn.add(c.sequenceNumber);this.w.re(this,a.routeId,c);return Promise.resolve()};d.Pf=function(a){return this.Xa.Pf(a)};d.xn=function(a){return this.Xa.xn(a)};d.Gm=function(a,b){return this.Xa.Gm(a,b)};
d.Sj=function(a,b){return this.Xa.Sj(a,b)};d.Th=function(a,b,c,e,f){return this.Xa.Th(a,b,c,e,f)};d.Ai=function(a,b,c,e,f,g){return this.Xa.Ai(a,b,c,e,f,g)};d.Ig=function(a){var b=this.Ah.get(a);this.Ah.remove(a);b&&b.wH?this.Xa.Zc(a):this.Xa.Ig(a)};d.Oc=function(){this.w.Oc()};d.onSinkAvailabilityUpdated=function(a,b){this.w.onSinkAvailabilityUpdated(a,b)};d.rl=function(a,b){this.w.rl(this,b)};d.Pi=function(a,b){this.w.Pi(this,b)};d.lh=function(a,b){this.w.lh(this,b)};
d.re=function(a,b,c){this.w.re(this,b,c)};d.onPresentationConnectionStateChanged=function(a,b){this.w.onPresentationConnectionStateChanged(a,b)};d.onPresentationConnectionClosed=function(a,b,c){this.w.onPresentationConnectionClosed(a,b,c)};d.cx=function(a){return this.w.cx(a)};d.gx=function(){return this.w.gx()};d.Nf=function(){return this.w.Nf()};d.Es=function(a,b,c){this.w.Es(this,b,c)};d.Iy=function(a){this.w.Iy(a)};d.Qi=function(a){this.Xa.Qi(a)};d.se=function(a){this.Xa.se(a)};d.ld=function(a){this.Xa.ld(a)};
d.np=function(){};d.ju=function(){};d.fg=function(a,b){return this.Xa.fg(a,b)};d.yz=function(a){this.w.yz(a)};d.Kx=function(){return this.w.Kx()};d.yh=function(a,b){return this.w.yh(a,b)};var Zl=function(a,b){this.routeId=a;this.message=b},$l=function(a){return"string"!=typeof a.message};var am=function(a){if(0>=a)throw Error("invalid buffer size");this.ob=[];this.fm=[];this.gl=a};d=am.prototype;d.enqueue=function(a){this.R()>=this.gl&&this.Hg();this.fm.push(a)};d.Hg=function(){if(this.Tb())throw Error("Empty queue");0==this.ob.length&&(this.ob=this.fm,this.ob.reverse(),this.fm=[]);return this.ob.pop()};d.yS=function(){var a=this.C();this.clear();return a};d.R=function(){return this.ob.length+this.fm.length};d.p_=function(){return this.R()==this.gl};d.Tb=function(){return 0==this.R()};
d.C=function(){var a=this.ob.slice();a.reverse();a.push.apply(a,[].concat(ka(this.fm)));return a};d.clear=function(){this.ob=[];this.fm=[]};var bm=function(a){Nd.call(this);this.ne=a;this.Ta=this.gs=null};x(bm,Nd);bm.prototype.L=function(){this.Ta&&($e(this.Ta),this.Ta=null)};bm.prototype.DK=function(){if(!this.Ta)if(null===this.gs||w()-this.gs>=this.ne)this.hg();else{var a=Math.max(this.gs+this.ne-w(),5);this.Ta=Ze(this.hg,a,this)}};bm.prototype.hg=function(){this.Ta=null;this.PD();this.gs=w()};bm.prototype.PD=r;var cm=function(a,b){bm.call(this,20);this.ff=new Map;this.gh=new Set;this.Vz=null;this.kq=this.qg=0;this.DM=!1;this.w=a;this.G0=b;this.a=E("mr.RouteMessageSender")};x(cm,bm);d=cm.prototype;d.init=function(a){this.Vz=a;Ci(this)};d.U_=function(a){this.gh.has(a)||(this.gh.add(a),this.NZ(a)&&this.DK())};d.QA=function(a){this.gh.delete(a)};
d.send=function(a,b){var c=this.ff.get(a);c||(c=new am(50),this.ff.set(a,c));if(c.p_()){G(this.a,"Queue is full; dropping oldest message");I(this.a,"   for route "+a);var e=c.Hg();this.qg-=$l(e)?0:e.message.length;$l(e)&&this.kq--}b=new Zl(a,b);c.enqueue(b);this.qg+=$l(b)?0:b.message.length;$l(b)&&this.kq++;this.mB();this.gh.has(a)&&this.DK()};d.Pi=function(a){this.gh.delete(a);var b=this.ff.get(a);b&&(this.ff.delete(a),this.SI(b.C()),this.mB())};
d.SI=function(a){if(0!=a.length){a=ja(a);for(var b=a.next();!b.done;b=a.next())b=b.value,this.qg-=$l(b)?0:b.message.length,$l(b)&&this.kq--}};d.NZ=function(a){return this.ff.has(a)&&!this.ff.get(a).Tb()};d.mB=function(){var a=0<this.kq||this.qg>this.G0;a!=this.DM&&(this.DM=a,this.w.yh(this.ka(),a))};d.PD=function(){if(this.Vz){for(var a=ja(this.gh),b=a.next();!b.done;b=a.next()){var b=b.value,c=this.ff.get(b);c&&!c.Tb()&&(c=c.yS(),this.Vz(b,c),this.SI(c))}this.mB()}else F(this.a,"sendMessagesCallback not set. Messages not delivered.")};
var dm=function(a,b,c){this.K4=a;this.Y_=b;this.qba=c};cm.prototype.ka=function(){return"mr.RouteMessageSender"};cm.prototype.getData=function(){var a=Array.from(this.ff,function(a){return[a[0],a[1].C()]}),b=Array.from(this.gh);return[new dm(a,b,this.qg)]};cm.prototype.fb=function(){var a=zi(this);a&&(this.ff=new Map,a.K4.forEach(function(a){var b=a[0];a=a[1];var e=new am(50);this.ff.set(b,e);a.forEach(function(a){e.enqueue(a)})},this),this.gh=new Set(a.Y_),this.qg=a.qba)};var em={PB:0,EB:1,JO:2},fm=function(a){Fg("MediaRouter.CastStreaming.Start.Success",a,em)};var gm=E("mr.mirror.cast.LogUploader"),im=function(a,b,c){hm("raw_events.log.gz",a,b,c);return b?"https://crash.corp.google.com/samples?stbtiq="+b:""},hm=function(a,b,c,e){if(0==b.size)H(gm,"Trying to upload an empty file to Crash"),e&&e(null);else{var f=new FormData;f.append("prod","Cast");f.append("ver",chrome.runtime.getManifest().version);f.append(a,b);c&&f.append("comments",c);tf("https://clients2.google.com/cr/report",function(a){a=a.target;var b=null;a.Md()?(b=a.Jk(),H(gm,"Upload to Crash succeeded: "+
b)):H(gm,"Upload to Crash failed. HTTP status: "+a.eb());e&&e(b)},"POST",f,void 0,3E4)}};var jm=function(){this.Tn=0};qa(jm);var km=E("mr.mirror.cast.LogUtils");jm.prototype.daa=function(){var a={fraction:.01,autoSubmitTimeLimitMillis:6048E5},b=a.autoSubmitTimeLimitMillis,c=w();return this.Tn&&b&&c-this.Tn<b?!1:Math.random()<a.fraction};
var lm=function(){this.ext="MR";this.senderProductName="Google Chrome";this.senderVersion=hi;this.senderPlatform=Wc;this.senderUserAgent=Tb||""},mm=function(a,b,c,e){var f=new lm;f.extVersion=chrome.runtime.getManifest().version;f.extChannel="public";f.minBitrate=c.minVideoBitrate;f.maxBitrate=c.maxVideoBitrate;f.resolution=c.wW();f.minResolution=c.NW();f.resolutionChangePolicy=c.KX();f.maxFrameRate=c.maxFrameRate;f.minLatency=c.minLatencyMillis;f.maxLatency=c.maxLatencyMillis;f.animatedLatency=c.animatedLatencyMillis;
f.useDscp=c.dscpEnabled;f.useTdls=c.useTdls;null!==b&&(f.receiverVersion=b);null!==a&&(f.receiverProductName=a);e.length&&(f.opa=e);return f},nm=function(a,b,c,e,f){H(km,"getRawEvents");return new Promise(function(g,k){var p=function(b){H(km,"Got receiver version: "+b);b=JSON.stringify(mm(c,b,e,f));chrome.cast.streaming.rtpStream.getRawEvents(a,b,g)};"Chromecast"==c?Bf(b).then(p,k):p(null)})},om=function(a,b,c,e){H(km,"getStats");return new Promise(function(f,g){var k=function(b){H(km,"Got receiver version: "+
b);var g=mm(c,b,e,[]);chrome.cast.streaming.rtpStream.getStats(a,function(a){var b={tags:g};Lb(b,a);f(b)})};"Chromecast"==c?Bf(b).then(k,g):k(null)})};jm.prototype.ka=function(){return"mirror.cast.LogUtils"};jm.prototype.getData=function(){return[null,{lastAutoSubmitMillis:this.Tn}]};jm.prototype.fb=function(){var a=Ai(this);this.Tn=a&&a.lastAutoSubmitMillis||0};var pm=function(a,b){Gh.call(this,a,b)};x(pm,Gh);var qm=function(a){return a&&a.getAudioTracks()&&0<a.getAudioTracks().length?a.getAudioTracks()[0]:null},rm=function(a){return a&&a.getVideoTracks()&&0<a.getVideoTracks().length?a.getVideoTracks()[0]:null};var sm=E("mr.NetworkUtils"),tm=function(a,b){return Ah?new Promise(function(c,e){chrome.networkingPrivate.setWifiTDLSEnabledState(a,b,function(a){chrome.runtime.lastError?(sm.da("Unable to set TDLS state: state = "+b+", error = "+chrome.runtime.lastError.message),e("Unable to set TDLS state to "+b+".")):(sm.info("TDLS state changed: state = "+b+", status = "+a),c(a))})}):Promise.reject("TDLS feature not enabled.")};var um={efa:"OFFER",Ica:"ANSWER",wfa:"PRESENTATION",Pda:"GET_STATUS",aga:"STATUS_RESPONSE"};var vm=function(a,b){this.sessionId=a;this.seqNum=b;this.type="PRESENTATION"};var wm=function(){this.bB=null;this.JK=[];this.mp=[];this.QJ=this.uO=null},xm=function(){this.details=this.description=this.code=null},ym=function(){this.status=this.Gc=this.error=this.result=this.type=this.seqNum=this.sessionId=null},zm=function(a){var b;try{if("string"!==typeof a)throw SyntaxError("Cannot parse non-string as JSON");b=JSON.parse(a);if(!(b instanceof Object))throw Error("non-Object result from JSON parse");var c=new ym;null!=b.sessionId&&(c.sessionId=String(b.sessionId));if("seqNum"in
b){if("number"!==typeof b.seqNum)throw Error('"seqNum" must be a number');c.seqNum=b.seqNum}if("type"in b){for(var e=String(b.type).toUpperCase(),f=ja(Object.keys(um)),g=f.next();!g.done;g=f.next())if(um[g.value]==e){c.type=e;break}if(!c.type)throw Error('not a known message "type"');}"result"in b&&(c.result=String(b.result));if("error"in b){var k=b.error;if(!(k instanceof Object))throw Error('"error" must be a struct');c.error=new xm;if("code"in k){if("number"!==typeof k.code)throw Error('"error.code" must be a number');
c.error.code=k.code}"description"in k&&(c.error.description=String(k.description));if("details"in k){if(!(k.details instanceof Object))throw Error('"error.details" must be a struct');c.error.details=k.details}}if("answer"in b){var p=b.answer;if(!(p instanceof Object))throw Error('"answer" must be a struct');c.Gc=new wm;if("udpPort"in p){if("number"!==typeof p.udpPort)throw Error('"answer.udpPort" must be a number');c.Gc.bB=p.udpPort}e=function(a){return a instanceof Array?a.every(function(a){return"number"===
typeof a}):!1};if("sendIndexes"in p){if(!e(p.sendIndexes))throw Error('"answer.sendIndexes" must be an array of numbers');c.Gc.JK=p.sendIndexes}if("ssrcs"in p){if(!e(p.ssrcs))throw Error('"answer.ssrcs" must be an array of numbers');c.Gc.mp=p.ssrcs}"IV"in p&&(c.Gc.uO=String(p.IV));"receiverGetStatus"in p&&(c.Gc.QJ="true"==String(p.receiverGetStatus).toLowerCase())}"status"in b&&(c.status=b.status);return c}catch(q){b=q instanceof SyntaxError?"JSON parse error: "+q.message:"Type coercion error: "+
q.message}"string"==typeof a?a="a string: "+a:a instanceof ArrayBuffer?(a=new Uint8Array(a),a="an ArrayBuffer whose base64 is "+btoa(String.fromCharCode.apply(null,a))):a="of invalid data type "+typeof a;throw Error(b+". Input was "+a);},Am=function(a,b,c){this.type="GET_STATUS";this.sessionId=a;this.seqNum=b;this.get_status=c};var Bm=function(a,b){this.address=a;this.port=b},Cm=function(a,b){Ug.call(this,b);this.a=E("mr.mirror.cast.Session");this.tl=a;this.Qa=a.Pf().clone();this.Tc=pg.qr(b.id);this.G=b.pe.sessionId;this.Rd=new Bm(b.pe.FM,2344);this.Xs=b.pe.GM;this.Qc=null;this.Oh=!1;this.dc=null;this.Gj=!1;this.Ih=0;this.qa=this.Wp=this.Xp=null;this.b4=["H264","VP8"];this.Dx=new D;this.rC=null;this.zK=v(this.A2,this);this.yK=v(this.z2,this);this.Cn=null;this.Eo=new Zh(30);this.RJ=!1;this.gm=null;this.Xz=new wj("mirror.cast.SeqNumGenerator");
this.Wc=this.bf=null;this.xy=0};x(Cm,Ug);d=Cm.prototype;d.start=function(a){var b=this,c=qm(a);a=rm(a);this.bf=new wg("MediaRouter.CastStreaming.Session.Launch");this.qa=new ff;this.ZZ();this.Qa.useTdls&&tm(this.Rd.address,!0).then(function(a){"Connected"!=a&&(b.Qa.useTdls=!1)},function(){b.Qa.useTdls=!1});chrome.cast.streaming.session.create(c,a,function(a,c,g){b.Qc=a;b.dc=c;b.Ih=g;b.Tc.onMessage=v(b.Fs,b);b.xy=0;b.Wz({type:"OFFER",sessionId:b.getId(),seqNum:b.Xz.wr(),offer:b.Qm()})});return this.qa.promise};
d.stop=function(){this.Wc&&(this.Wc.end(),this.Wc=null);H(this.a,"Stopping "+this.getId());null!==this.Qc&&(chrome.cast.streaming.rtpStream.stop(this.Qc),chrome.cast.streaming.rtpStream.destroy(this.Qc),this.Qc=null,this.Oh=!1);null!==this.dc&&(chrome.cast.streaming.rtpStream.stop(this.dc),chrome.cast.streaming.rtpStream.destroy(this.dc),this.dc=null,this.Gj=!1);this.Ih&&(chrome.cast.streaming.udpTransport.destroy(this.Ih),this.Ih=0);this.Qa.useTdls&&tm(this.Rd.address,!1);this.qa&&(this.qa.resolve(this),
this.qa=null);chrome.cast.streaming.rtpStream.onStarted.removeListener(this.zK);chrome.cast.streaming.rtpStream.onError.removeListener(this.yK);null!==this.Cn&&(window.clearTimeout(this.Cn),this.Cn=null);this.Xp=this.Wp=null;if(this.gm&&this.gm.onSessionStop)this.gm.onSessionStop(this.Rd);return!0};d.P8=function(a){this.Oh&&chrome.cast.streaming.rtpStream.toggleLogging(this.Qc,a);this.Gj&&chrome.cast.streaming.rtpStream.toggleLogging(this.dc,a)};
d.getLogs=function(){var a=this;if(!this.Oh&&!this.Gj)return Promise.reject(Error("No streams has been started yet."));var b=[];if(this.Oh){var c=nm(this.Qc,this.Rd.address,this.Xs,this.Qa,this.Eo.C());b.push(c)}this.Gj&&(c=nm(this.dc,this.Rd.address,this.Xs,this.Qa,this.Eo.C()),b.push(c));return Promise.all(b).then(function(b){b=new Blob(b,{type:"application/gzip"});H(a.a,"Events blob size: "+b.size);return b})};
d.getStats=function(){var a=[];if(this.Oh){var b=om(this.Qc,this.Rd.address,this.Xs,this.Qa);a.push(b)}this.Gj&&(b=om(this.dc,this.Rd.address,this.Xs,this.Qa),a.push(b));this.Eo.R()&&a.push(Promise.resolve({receiverStatusData:this.Eo.C()}));return Promise.all(a).then(function(a){var b={};a.forEach(function(a){Lb(b,a)});return b})};
d.UR=function(){var a=chrome.cast.streaming.rtpStream.getSupportedParams(this.Qc)[0];a.payload.maxLatency=this.Qa.maxLatencyMillis;a.payload.minLatency=this.Qa.minLatencyMillis;a.payload.animatedLatency=this.Qa.animatedLatencyMillis;a.payload.ssrc=Math.floor(499999*Math.random())+1;a.payload.feedbackSsrc=2;a.payload.payloadType=127;a.payload.aesKey=this.Xp;a.payload.aesIvMask=this.Wp;return a};
d.hS=function(){var a=[];if(null===this.dc)return a;var b=chrome.cast.streaming.rtpStream.getSupportedParams(this.dc);this.b4.forEach(function(c){var e=b.find(function(a){return a.payload.codecName.toLowerCase()==c.toLowerCase()});e&&(e.payload.maxFrameRate=this.Qa.maxFrameRate,e.payload.minBitrate=this.Qa.minVideoBitrate,e.payload.maxBitrate=this.Qa.maxVideoBitrate,e.payload.maxLatency=this.Qa.maxLatencyMillis,e.payload.minLatency=this.Qa.minLatencyMillis,e.payload.animatedLatency=this.Qa.animatedLatencyMillis,
e.payload.aesKey=this.Xp,e.payload.aesIvMask=this.Wp,e.payload.ssrc=Math.floor(499999*Math.random())+500001,e.payload.feedbackSsrc=12,e.payload.payloadType=96,a.push(e))},this);return a};
d.Qm=function(){var a=0,b=[];if(this.Qc){var c=this.UR();this.rC=c;c={index:a,type:"audio_source",codecName:c.payload.codecName.toLowerCase(),rtpProfile:"cast",rtpPayloadType:c.payload.payloadType,ssrc:c.payload.ssrc,targetDelay:this.Qa.animatedLatencyMillis,aesKey:c.payload.aesKey,aesIvMask:c.payload.aesIvMask,bitRate:128E3,sampleRate:c.payload.clockRate,timeBase:"1/"+c.payload.clockRate,channels:c.payload.channels,rtpExtensions:["adaptive_playout_delay"]};this.Qa.enableLogging&&Lb(c,{receiverRtcpEventLog:!0});
this.Qa.dscpEnabled&&Lb(c,{receiverRtcpDscp:46});b.push(c);a++}this.hS().forEach(function(c){var e={index:a,type:"video_source",codecName:c.payload.codecName.toLowerCase(),rtpProfile:"cast",rtpPayloadType:c.payload.payloadType,ssrc:c.payload.ssrc,targetDelay:this.Qa.animatedLatencyMillis,aesKey:c.payload.aesKey,aesIvMask:c.payload.aesIvMask,maxFrameRate:Math.round(1E3*c.payload.maxFrameRate)+"/1000",timeBase:"1/90000",maxBitRate:c.payload.maxBitrate,resolutions:[{width:this.Qa.maxWidth,height:this.Qa.maxHeight}],
rtpExtensions:["adaptive_playout_delay"]};this.Qa.enableLogging&&Lb(e,{receiverRtcpEventLog:!0});this.Qa.dscpEnabled&&Lb(e,{receiverRtcpDscp:46});b.push(e);this.Dx.set(a,c);a++},this);return{supportedStreams:b}};d.A2=function(a){a==this.Qc?this.Oh=!0:a==this.dc&&(this.Gj=!0);this.Oh&&(null===this.dc||this.Gj)&&(this.P8(this.Qa.enableLogging),this.qa&&(this.qa.resolve(this),this.qa=null));this.Wc=new Bg("MediaRouter.CastStreaming.Session.Length")};
d.z2=function(a,b){if(a==this.Qc)G(this.a,"Audio stream error "+b);else if(a==this.dc)G(this.a,"Video stream error "+b);else{G(this.a,"Error for stream "+a+": "+b);return}this.qa&&(this.qa.reject(Error("Error for stream "+a+": "+b)),this.qa=null);this.stop()};
d.Kaa=function(a,b){I(this.a,"Starting streaming ... "+JSON.stringify({udpTransportId:this.Ih,receiverIpEndPoint:this.Rd,"audio ID":this.Qc,"video ID":this.dc,"audio params":a,"video params":b}));if(va(chrome.cast.streaming.udpTransport.y9)){var c={};this.Qa.dscpEnabled&&(H(this.a,"Enable DSCP in sender."),c.DSCP=!0);chrome.cast.streaming.udpTransport.y9(this.Ih,c)}chrome.cast.streaming.udpTransport.setDestination(this.Ih,{address:this.Rd.address,port:this.Rd.port});chrome.cast.streaming.rtpStream.onStarted.addListener(this.zK);
chrome.cast.streaming.rtpStream.onError.addListener(this.yK);a&&chrome.cast.streaming.rtpStream.start(this.Qc,a);b&&chrome.cast.streaming.rtpStream.start(this.dc,b)};
d.Fs=function(a){var b=this;if("urn:x-cast:com.google.cast.webrtc"==a.namespace_){var c,e=null;try{c=zm(a.data)}catch(q){c=new ym,e=q.message}if("ANSWER"==c.type)if("ok"==c.result&&c.Gc){c.Gc.bB&&(this.Rd.port=c.Gc.bB);this.RJ=!!c.Gc.QJ;if(this.gm&&this.gm.onAnswer)this.gm.onAnswer(this.Rd);this.bf&&(this.bf.end(),this.bf=null);H(this.a,"Starting streaming");var f=this.rC,g=null;c.Gc.JK.forEach(function(a){f&&0==a?c.Gc.mp[a]&&(f.payload.feedbackSsrc=c.Gc.mp[a]):b.Dx.xa(a)&&(g?G(b.a,"Receiver selected multiple video stream"):
(g=b.Dx.get(a),c.Gc.mp[a]&&(g.payload.feedbackSsrc=c.Gc.mp[a])))});null!==this.dc&&null===g&&(G(this.a,"Receiver is capable of video, but did not specify a video stream index in the ANSWER message."),chrome.cast.streaming.rtpStream.destroy(this.dc),this.dc=null);if(f||g)this.$F(),this.Kaa(f,g),this.qa&&(this.qa.resolve(this),this.qa=null)}else this.qa&&(this.qa.reject(Error("Non-OK answer received: "+JSON.stringify(c))),this.qa=null),this.stop();else if("STATUS_RESPONSE"==c.type&&c.status instanceof
Object){a={};for(var e=ja(Object.keys(c.status)),k=e.next();!k.done;k=e.next()){var k=k.value,p=c.status[k];ta(p)&&p.length?a[k]=p.pop():a[k]=p}e={};e[(new Date).toISOString()]=a;this.Eo.add(e)}else e||(e="Ignoring message: "+JSON.stringify(c)),10>this.xy?G(this.a,e):I(this.a,e),++this.xy}};d.ZZ=function(){this.Wp=Nh(window.crypto.getRandomValues(new Uint8Array(16)));this.Xp=Nh(window.crypto.getRandomValues(new Uint8Array(16)))};d.MK=function(){this.Wz(this.sX())};
d.Wz=function(a){this.Tc.sendMessage(a,{namespace:"urn:x-cast:com.google.cast.webrtc"})};d.$F=function(){this.Cn=null;if(this.Ih&&this.RJ){var a=new Am(this.getId(),this.Xz.wr(),["wifiSnr","wifiSpeed","wifiFcsError"]);this.Wz(a);this.Cn=window.setTimeout(v(this.$F,this),12E4)}};d.sX=function(){var a=new vm(this.G,this.Xz.wr());a.title=this.Cz||void 0;a.icons=this.iconUrl&&!this.Wr?[new chrome.cast.Image(this.iconUrl)]:[];return a};d.getId=function(){return this.G};d.Of=function(){return this.tl};
d.L=function(){this.Tc.mb();this.stop()};var Dm=function(a){Tg.call(this,"cast_streaming",a)};x(Dm,Tg);d=Dm.prototype;d.getName=function(){return"cast_streaming"};d.Of=function(a,b){return new pm(a,b)};d.Eq=function(a,b){if(a instanceof pm)return new Cm(a,b);throw Error("Invalid parameters");};d.bt=function(){fm(0)};d.Ys=function(){fm(1)};d.wz=function(){fm(2)};d.Zs=function(){Eg("MediaRouter.CastStreaming.Session.End")};d.$s=function(a){Fg("MediaRouter.CastStreaming.Start.Failure",a,Gg)};d.at=function(){Eg("MediaRouter.CastStreaming.Stream.End")};
d.xC=function(){var a=this,b=this.La,c=b.getLogs().then(function(a){return a},function(b){G(a.o,"Get cast streaming logs failed.",b)}),b=b.getStats().then(function(a){return a},function(b){G(a.o,"Get cast streaming stats failed.",b)}),e=new Promise(function(a){chrome.metricsPrivate.getIsCrashReportingEnabled(a)});return Promise.all([c,b,e]).then(function(b){var c=ja(b);b=c.next().value;var e=c.next().value,c=c.next().value,f=new FileReader;f.onloadend=function(){Ji("mr.temp.mirror.cast.Service.mirrorLogs",
f.result)};f.readAsBinaryString(b);c&&(b&&jm.N().daa()?im(b,void 0,a.f1.bind(a)):e&&hm("stats.json",new Blob([JSON.stringify(e)],{type:"application/json"}),void 0,void 0))})};d.f1=function(a){a&&(jm.N().Tn=w())};d.QW=function(a){var b=this;H(this.o,"Received message to upload logs for "+a);return this.La?this.La.getLogs().then(function(b){return im(b,a)},function(c){G(b.o,"Get cast streaming logs failed.",c);return b.lI(a)}):Promise.resolve(this.lI(a))};
d.lI=function(a){var b=window.localStorage["mr.temp.mirror.cast.Service.mirrorLogs"];if(!b)return"";window.localStorage.removeItem("mr.temp.mirror.cast.Service.mirrorLogs");H(this.o,"Uploading saved logs for feedback.");for(var c=new Uint8Array(b.length),e=0;e<c.length;e++)c[e]=b.charCodeAt(e);return im(new Blob([c],{type:"application/gzip"}),a)};var Em=function(a,b){Ug.call(this,b);this.tl=a;this.to=new ff;this.m=this.to.promise;this.Tc=pg.qr(b.id);this.qa=new ff;this.Jx=this.zb=!1;this.Wc=this.bf=null;this.fp();this.AA();this.wb(new Vg("GET_TURN_CREDENTIALS"))};x(Em,Ug);d=Em.prototype;d.start=function(a){var b=this;return this.m.then(function(c){if(c.Zr())return Promise.reject(Error("Mirroring already started"));b.bf=new wg("MediaRouter.WebRtc.Session.Launch");c.addStream(a);c.start();return b.qa.promise})};
d.stop=function(){this.Wc&&this.Wc.end();this.Jx=this.zb=!1;this.bf=this.Wc=null;this.m.then(function(a){a.stop()});return!0};d.L=function(){this.Tc.mb();this.stop()};
d.fp=function(){var a=this;this.Tc.onMessage=function(b){if(!b.type)throw Error("Message has no type.");switch(b.type){case "TURN_CREDENTIALS":a.to.resolve(new ah(a.ab.id,b.data.credentials));break;case "ANSWER":a.m.then(function(a){a.setRemoteDescription(b.data)});break;case "KNOCK_ANSWER":a.Jx=!0;a.m.then(function(a){a.setRemoteDescription(b.data)});break;case "STOP":a.qa.reject("Stop signal received");a.stop();break;default:throw Error("Unknown message type: "+b.type);}}};
d.AA=function(){var a=this;this.m.then(function(b){b.VL(function(b){b=new Xg(b,a.tl.Pf(),$g);a.wb(new Vg("OFFER",b))});b.UL(function(b){a.wb(Wg(b))});b.TL(function(){a.zb=!0;a.wb(new Vg("SESSION_START_SUCCESS"));!a.Jx&&a.bf&&a.bf.end();a.bf=null;a.Wc=new Bg("MediaRouter.WebRtc.Session.Length");a.qa.resolve(a)});b.RL(function(){a.wb(new Vg("SESSION_END"))});b.SL(function(b){a.zb||a.qa.reject(b);a.wb(new Vg("SESSION_FAILURE"))})})};var Fm={channelType:"cloud"};
Em.prototype.wb=function(a){this.Tc.sendMessage(a,Fm)};Em.prototype.Of=function(){return this.tl};var Gm=function(a){Tg.call(this,"webrtc",a)};x(Gm,Tg);d=Gm.prototype;d.Of=function(a,b){return new Gh(a,b)};d.Eq=function(a,b){if(a instanceof Gh)return new Em(a,b);throw Error("Invalid parameters");};d.bt=function(){Zg(0)};d.Ys=function(){Zg(1)};d.wz=function(){Zg(2)};d.Zs=function(){Eg("MediaRouter.WebRtc.Session.End")};d.$s=function(a){Fg("MediaRouter.WebRtc.Start.Failure",a,Gg)};d.at=function(){Eg("MediaRouter.WebRtc.Stream.End")};var Hm=function(a,b,c,e,f,g){this.AH=a;this.rd=b;this.qk=e||null;this.il=c||null;this.Ee=f||null;this.bj=g||null};d=Hm.prototype;d.Mg=function(){var a="";this.Ee?a=this.Ee:this.il&&(a=this.il);return a};d.getId=function(){return this.AH+"@"+this.rd};d.getService=function(){return this.rd};d.Mf=function(){return this.qk};d.merge=function(a){!this.bj&&a.bj&&(this.bj=a.bj);!this.Ee&&a.Ee&&(this.Ee=a.Ee);this.Ee&&a.Ee&&this.bj&&(this.Ee=a.Ee)};var Im=function(a,b){this.wg=a;this.wba=b},Jm=new Im("https://www.googleapis.com/clouddevices/v1","AIzaSyAOZM8ZYeov685QMjXT3sC7XNizfrTEKjA"),Km=new Im("https://www.googleapis.com/calendar/v3",""),Lm=new Im("https://www.googleapis.com/hangouts/v1",""),Mm=new Im("https://networktraversal.googleapis.com/v1alpha","AIzaSyAOZM8ZYeov685QMjXT3sC7XNizfrTEKjA");var Nm=function(a,b){this.nb=a;this.Sb=b;this.a=E("mr.cloud.calendar.CalendarService")};d=Nm.prototype;d.LT=function(){var a=this;return this.SU(this.Sb.Ge,9E5).then(function(b){H(a.a,a.zE(b.length)+" events discovered before filtering.");return a.UV(b)},function(b){G(a.a,"Error getting Hangouts from calendar: "+b);return[]})};d.zE=function(a){return 20<a?"20+":a.toString()};d.SU=function(a,b){var c=w(),e=this;return this.tU(a,new Date(c),new Date(c+b)).then(function(a){return a.filter(e.v_)})};
d.v_=function(a){return!(!a.start||!a.end||a.start.date||a.end.date||!a.start.dateTime||!a.end.dateTime)};d.tU=function(a,b,c){a=this.nb.ei(Km.wg,["calendars",a,"events"],{timeMin:b.toJSON(),timeMax:c.toJSON(),singleEvents:!0});I(this.a,"Retrieving Hangouts from Calendar: "+a);return this.nb.zg(a,"GET").then(function(a){return a.items?a.items:[]})};
d.UV=function(a){var b=this;a=a.reduce(function(a,e){if(e.hangoutLink){var c=new Wj(e.hangoutLink),g=b.p3(c.nd);if(2==g.length){var c=g[0],g=g[1],k,p;-1!=c.indexOf(".")&&(k=g,p=c);a.push(new Hm(g,c,k,p,e.summary))}else G(b.a,"Invalid hangout link from calendar event: "+e.hangoutLink)}return a},[]);H(this.a,this.zE(a.length)+" events discovered with Hangout links.");return a};d.p3=function(a){return a.substring(12).split("/")};var Om=function(a,b){this.email=a;this.imageUrl=null!=b?b:null},Pm=function(a){this.type=a},Qm=function(a,b,c){this.type="__cloud_webrtc_session_message__";this.sessionDescription=a;this.user=null!=b?b:null;this.flungUrl=null!=c?c:null};x(Qm,Pm);
var Rm=function(a,b,c){this.name=a;this.parameters=b;this.minimalRole=null!=c?c:"user"},Sm={_settings:{type:"string"},_presentationRequest:{type:"string"},_optMediaConstraints:{type:"string"},_webrtcMessage:{type:"string"},_user:{type:"string"}},Tm=new Rm("_knockingStartWebrtcSession",Sm,"viewer"),Um=new Rm("_startWebrtcSession",Sm),Vm=new Rm("_stopSession",{},"viewer");var Wm=function(a){this.Ab=a;this.id=a.id;this.a=E("mr.cloud.devices.CloudDevice")};d=Wm.prototype;d.isAvailable=function(){if(this.getState().appStatus){var a=this.q_(),b=this.l_(),c=this.TC(864E5);I(this.a,"Device id: "+this.id+", availability: GCM connected "+a+", app Available: "+b+", checked in: "+c);return a&&b&&c}c=this.TC(9E5);H(this.a,"Availability for legacy receiver app: "+c);return c};d.TC=function(a){var b=this.fW();return!!(b&&b>w()-a)};d.l_=function(){return"available"==this.getState().appStatus};
d.q_=function(){return"online"==this.Ab.connectionStatus};d.fW=function(){return this.Ab.lastUpdateTimeMs?Number(this.Ab.lastUpdateTimeMs):null};d.Mg=function(){return this.getState().settings.receiverName};d.getId=function(){return this.id};d.getState=function(){return this.Ab.state._cloudCast};d.w_=function(){return this.Ab.invitations?0!=this.Ab.invitations.length:!1};var Xm=function(a){this.nb=a;this.tk=this.$k=this.Ci=null;this.as=this.Yr=!1;this.a=E("mr.cloud.devices.CloudDevicesService");Ci(this)};Xm.prototype.getDevice=function(a){a=this.nb.ei(Jm.wg,["devices",a]);return this.nb.zg(a,"GET").then(function(a){return new Wm(a)})};Xm.prototype.T_=function(){return this.RH({descriptionSubstring:"Chrome Streaming Receiver"})};
Xm.prototype.RH=function(a){var b=this,c=this.nb.ei(Jm.wg,["devices"],a);return this.nb.zg(c,"GET").then(function(c){var e=(c.devices||[]).filter(function(a){return null!=a.commandDefs&&null!=a.commandDefs._cloudCast}).map(function(a){return new Wm(a)});if(c=c.nextPageToken){var g=Hb(a);g.token=c;return b.RH(g).then(function(a){return e.concat(a)})}return e})};var Ym=function(a,b,c){this.P_=a;this.gcmRegistrationId=b;this.N_=c};d=Xm.prototype;d.ka=function(){return"CloudDevicesService"};
d.getData=function(){return[new Ym(this.Ci,this.tk,this.$k)]};d.fb=function(){var a=zi(this);a&&(this.Ci=a.P_,this.tk=a.gcmRegistrationId,this.$k=a.N_)};d.c5=function(){var a=this;return new Promise(function(b,c){a.Yr?c(Error("Registering...")):(a.Yr=!0,a.tk&&a.$k&&a.$k+864E5>=w()?(a.Yr=!1,b(a.tk)):chrome.gcm.register(["919648714761"],function(e){a.Yr=!1;e?(I(a.a,"Got GCM ID: "+e),a.tk=e,a.$k=w(),a.Ci=null,b(e)):(G(a.a,"Error: "+chrome.runtime.lastError.message),a.tk=null,a.$k=null,a.Ci=null,c(Error(chrome.runtime.lastError.message)))}))})};
d.eaa=function(){return!this.Ci||this.Ci+864E5<w()};d.subscribe=function(a){var b=this;if(this.as)return Promise.resolve();this.as=!0;if(!a||!this.eaa())return Promise.resolve();a={filters:["myDevices"],gcmRegistrationId:a,gcmSenderId:"919648714761",expirationTimeMs:864E5};var c=this.nb.ei(Jm.wg,["subscriptions","subscribe"],{});return this.nb.zg(c,"POST",a).then(function(){I(b.a,"Subscribed on: "+w());b.Ci=w();b.as=!1;return Promise.resolve()},function(a){b.as=!1;throw a;})};var Zm={ACCEPTED:0,DENIED:1,TIMEOUT:2},$m={SUCCESS:0,Hda:1},an={yP:0,YO:1,Gga:2,Zda:3,Yda:4,Gea:5,TIMEOUT:6,xfa:7},bn={Wda:0,bga:1},cn={gfa:0,Aea:1,wga:2,Rda:3},dn=function(a){Fg("MediaRouter.Cloud.Knock.Result",a,Zm)},en=function(a){Fg("MediaRouter.Cloud.Session.Start",a,$m)},fn=function(a){Fg("MediaRouter.Cloud.Session.Type",a,bn)},gn=function(a){Fg("MediaRouter.Cloud.Device.UserRole",a,cn)};var hn=function(a,b,c,e,f,g,k){var p=Mi.N().hn(a);this.Za=new wi(p,b,g,k,f);this.deviceId=a;this.aba=c;this.model=e};hn.prototype.VM=function(a){return gb(this.aba,a)};var jn=function(a,b,c,e,f){hn.call(this,a,b,["cloud"],"Chrome Streaming Receiver",e);this.Lu=c;this.isAvailable=f};x(jn,hn);var kn=function(a){var b=a.getService();a.Mf()&&(b=a.Mf());var c;a.il&&a.Mg()!=a.il&&(c=a.il);hn.call(this,a.getId(),a.Mg(),["mesi"],"Hangout",b,"hangout",c);this.Oz=a.bj||""};x(kn,hn);var ln=function(a,b,c){this.Rba=a;this.Xc=b;this.lg=new D;this.Mt=new D;this.Zk=null;this.I0=c},mn=function(a,b,c){this.sinks=a;this.dD=b;this.DH=c};d=ln.prototype;d.Kc=function(){this.bR()&&(this.Zk=w(),this.dn());return this.lg.C()};d.wm=function(a){this.lg.set(a.Za.id,a)};d.Dl=function(a){return this.lg.remove(a)};d.W=function(a){return this.lg.get(a,null)};d.bR=function(){var a=this.Zk+this.I0;return null==this.Zk||a<w()};d.dn=function(){var a=this;return this.Rba().then(function(b){a.Qba(b)})};
d.Qba=function(a){var b=new D(this.lg),c=new D,e=new D,f=[],g=[];a.forEach(function(a){var k=a.Za.id;c.set(k,a);e.set(k,a.deviceId);b.xa(k)?b.xa(k)&&JSON.stringify(b.get(k))!=JSON.stringify(a)&&g.push(a.Za):f.push(a.Za);b.remove(k)},this);a=b.ib().map(function(a){return b.get(a).Za});this.Mt.clear();this.Mt=e;this.lg.clear();this.lg=c;this.ZQ(f,g,a)};d.ZQ=function(a,b,c){0<a.length&&this.Xc.Oy(a);0<b.length&&this.Xc.Oc(b);0<c.length&&this.Xc.se(c)};
d.b=function(){return new mn(this.lg.b(),this.Mt.b(),this.Zk)};d.XH=function(a){for(var b in a.sinks){var c=a.sinks[b],e=null;"Hangout"==c.model?(e=c.deviceId.split("@"),e=new kn(new Hm(e[0],e[1],c.Za.description,c.Za.domain,c.Za.friendlyName,c.Oz))):"Chrome Streaming Receiver"==c.model&&(e=new jn(c.deviceId,c.Za.friendlyName,c.Lu,c.Za.domain,c.isAvailable));this.lg.set(b,e)}for(b in a.dD)this.Mt.set(b,a.dD[b]);a.DH&&(this.Zk=a.DH)};d.oA=function(a){this.Zk=a};var nn=function(a,b,c){this.Jv=a;this.Xc=b;this.$d=new ln(this.dn.bind(this),b,2E4);c.W7(this);c.s0();Ci(this)};d=nn.prototype;d.Kc=function(){var a=this;this.Jv.c5().then(function(b){a.Jv.subscribe(b)},function(){});return this.$d.Kc().filter(function(a){return a.isAvailable})};d.W=function(a){return this.$d.W(a)};
d.dn=function(){return this.Jv.T_().then(function(a){return a.map(function(a){Eg("MediaRouter.Cloud.CloudReceiver.Sink.Discovered");var b=a.isAvailable()&&!a.w_();return new jn(a.getId(),a.Mg(),a.Ab.personalizedInfo.maxRole,"default",b)})})};d.ka=function(){return"CloudSinkDiscoveryService"};d.getData=function(){return[{cache:this.$d.b()}]};d.fb=function(){var a=zi(this);a&&this.$d.XH(a.cache)};d.s1=function(a){a=a.Aia;this.$d.wm(a);this.$d.oA(w());this.Xc.Oy([a.Za])};
d.x1=function(a){var b=this.$d.W(a.sinkId);b&&(b.isAvailable=a.isAvailable,this.$d.oA(w()),this.Xc.Oc([b.Za]))};d.u1=function(a){if(a=this.$d.W(a.sinkId))this.$d.Dl(a.Za.id),this.$d.oA(w()),this.Xc.se([a.Za])};var on=function(a,b){this.input=a;this.domain=b};var pn=function(a,b,c){this.UQ=a;this.D0=b;this.Qk=new ln(this.dn.bind(this),c,2E4);this.co=new D;Ci(this)};pn.prototype.a=E("mr.cloud.discovery.HangoutSinkDiscoveryService");pn.prototype.$B=function(a,b){a=new Hm(a,b,a,b);this.co.set(a.getId(),a);return a};pn.prototype.addManualHangout=pn.prototype.$B;pn.prototype.s5=function(a,b){this.my(new Hm(a,b,a,b))};pn.prototype.removeManualHangout=pn.prototype.s5;d=pn.prototype;d.Kc=function(){return this.Qk.Kc()};d.W=function(a){return this.Qk.W(a)};
d.dn=function(){H(this.a,"Fetching hangouts");var a=this;return Fl([this.D0.IT(),this.UQ.LT()]).then(function(b){var c=a.co.C().slice();b.forEach(function(b){b.uE?c=c.concat(b.value):F(a.a,"Error discovering Hangouts",b.reason)});var e=c.reduce(function(a,b){var c=a[b.getId()];c?c.merge(b):c=b;a[c.getId()]=c;return a},{});return Object.keys(e).map(function(b){b=e[b];Eg("MediaRouter.Cloud.Hangout.Sink.Discovered");return a.my(b)})})};d.my=function(a){return new kn(a)};
d.NP=function(a){a=this.$B(a.input,a.domain);a=this.my(a);this.Qk.wm(a);return a.Za};d.r5=function(a){return this.co.remove(a.deviceId)?(this.Qk.Dl(a.Za.id),!0):!1};d.ka=function(){return"HangoutSinkDiscoveryService"};d.getData=function(){return[{cache:this.Qk.b(),manualHangouts:this.co.b()}]};d.fb=function(){var a=zi(this);if(a){this.Qk.XH(a.cache);for(var b in a.manualHangouts){var c=a.manualHangouts[b];this.co.set(b,new Hm(c.AH,c.rd,c.il,c.qk,c.Ee,c.bj))}}};var qn=function(a){this.Sb=a};d=qn.prototype;d.ei=function(a,b,c){var e="";b.forEach(function(a){e+="/"+encodeURIComponent(a)});a=new Wj(a+e);c&&(c=gk(c),a.Ct(c));return a};d.zg=function(a,b,c){var e=this;return this.Sb.getAuthToken().then(function(f){var g=e.iU(f);return e.VQ(g,a,b,c).catch(function(g){if("INVALID_ACCESS_ERROR"==g)return e.uT(f,a,b,c);throw g;})})};d.uT=function(a,b,c,e){var f=this;return this.Sb.tT(a).then(function(){return f.zg(b,c,e)})};
d.VQ=function(a,b,c,e){var f=this;return new Promise(function(g,k){a.sendRequest(f.RT(b,c,function(a){a&&!a.error?g(a):f.s_(a)?k("INVALID_ACCESS_ERROR"):k(f.l3(a))},e))})};d.s_=function(a){return!!a&&401==a.error.code};d.iU=function(a){a=new ki(void 0,void 0,void 0,!1,!1,a);a.init();return a};d.l3=function(a){return a&&a.error?a.error.errors?a.error.errors[0]:a:Error(a)};d.RT=function(a,b,c,e){a={callback:c,method:b,path:a.toString()};e&&(a.body=e);return a};var rn=function(){this.jf=!1;this.Ge=null;this.Yk=!1;this.a=E("mr.cloud.identity.IdentityService");Ci(this);this.V_();this.nM()},sn="cloudview.test@gmail.com castouts.qa.nohangouts@gmail.com castouts.qa@gmail.com castouts-qa.com castouts-test.com google.com youtube.com nest.com waze.com netflix.com twitter.com yahoo.com salesforce.com whirlpool.com nytimes.com kohls.com squareup.com ivci.com".split(" ");d=rn.prototype;d.r_=function(){return"google.com"==this.DG()};
d.I_=function(){return this.Yk||this.jf&&!!this.Ge&&(-1!=sn.indexOf(this.Ge)||-1!=sn.indexOf(this.DG()))};d.DG=function(){return this.Ge?this.Ge.substr(this.Ge.indexOf("@")+1):""};d.getAuthToken=function(){return this.IE(!0)};
d.IE=function(a){return chrome.identity?new Promise(function(b,c){chrome.identity.getAuthToken({interactive:a},function(a){chrome.runtime.lastError?c(Error("Unable to get user auth token: "+chrome.runtime.lastError.message)):null==a?c(Error("User is not logged in (no token found)")):b(a)})}):Promise.reject(Error("chrome.identity permission required for auth."))};d.tT=function(a){return new Promise(function(b){chrome.identity.removeCachedAuthToken({token:a},function(){b()})})};
d.nM=function(){var a=this;this.IE(!1).then(function(b){chrome.identity.getProfileUserInfo(function(c){a.jf=!!c.email||!!c.id;a.Ge=c.email||null;b&&!a.jf&&(a.Yk=!0)})},function(b){I(a.a,"Unable to set sign in and email.",b)})};d.V_=function(){var a=this;chrome.identity.onSignInChanged.addListener(function(b,c){a.jf=c;H(a.a,"Signed in change: "+a.jf);a.jf?a.nM():(a.Ge=null,a.Yk=!1)})};
d.Y4=function(){var a=this;return this.getAuthToken().then(function(b){var c=window.gapi;if(!c)return F(a.a,"gapi not loaded."),!1;H(a.a,"Setting gapi auth token");c.auth.setToken({access_token:b});return!0})};d.ka=function(){return"IdentityService"};d.getData=function(){return[null,{signedIn:this.jf,userEmail:this.Ge,kioskAuth:this.Yk}]};d.fb=function(){var a=Ai(this);a&&(a.signedIn&&(this.jf=a.signedIn),a.userEmail&&(this.Ge=a.userEmail),a.kioskAuth&&(this.Yk=a.kioskAuth))};var tn={AB:{1E3:{other:"0K"},1E4:{other:"00K"},1E5:{other:"000K"},1E6:{other:"0M"},1E7:{other:"00M"},1E8:{other:"000M"},1E9:{other:"0B"},1E10:{other:"00B"},1E11:{other:"000B"},1E12:{other:"0T"},1E13:{other:"00T"},1E14:{other:"000T"}},hO:{1E3:{other:"0 thousand"},1E4:{other:"00 thousand"},1E5:{other:"000 thousand"},1E6:{other:"0 million"},1E7:{other:"00 million"},1E8:{other:"000 million"},1E9:{other:"0 billion"},1E10:{other:"00 billion"},1E11:{other:"000 billion"},1E12:{other:"0 trillion"},1E13:{other:"00 trillion"},
1E14:{other:"000 trillion"}}},un=tn,un=tn;var wn=function(a,b){var c=["0"];b=vn[b][0]&7;if(0<b){c.push(".");for(var e=0;e<b;e++)c.push("0")}return a.replace(/0.00/g,c.join(""))},vn={AED:[2,"dh","\u062f.\u0625.","DH"],ALL:[0,"Lek","Lek"],AUD:[2,"$","AU$"],BDT:[2,"\u09f3","Tk"],BGN:[2,"lev","lev"],BRL:[2,"R$","R$"],CAD:[2,"$","C$"],CDF:[2,"FrCD","CDF"],CHF:[2,"CHF","CHF"],CLP:[0,"$","CL$"],CNY:[2,"\u00a5","RMB\u00a5"],COP:[32,"$","COL$"],CRC:[0,"\u20a1","CR\u20a1"],CZK:[50,"K\u010d","K\u010d"],DKK:[50,"kr.","kr."],DOP:[2,"RD$","RD$"],EGP:[2,
"\u00a3","LE"],ETB:[2,"Birr","Birr"],EUR:[2,"\u20ac","\u20ac"],GBP:[2,"\u00a3","GB\u00a3"],HKD:[2,"$","HK$"],HRK:[2,"kn","kn"],HUF:[34,"Ft","Ft"],IDR:[0,"Rp","Rp"],ILS:[34,"\u20aa","IL\u20aa"],INR:[2,"\u20b9","Rs"],IRR:[0,"Rial","IRR"],ISK:[0,"kr","kr"],JMD:[2,"$","JA$"],JPY:[0,"\u00a5","JP\u00a5"],KRW:[0,"\u20a9","KR\u20a9"],LKR:[2,"Rs","SLRs"],LTL:[2,"Lt","Lt"],MNT:[0,"\u20ae","MN\u20ae"],MVR:[2,"Rf","MVR"],MXN:[2,"$","Mex$"],MYR:[2,"RM","RM"],NOK:[50,"kr","NOkr"],PAB:[2,"B/.","B/."],PEN:[2,"S/.",
"S/."],PHP:[2,"\u20b1","PHP"],PKR:[0,"Rs","PKRs."],PLN:[50,"z\u0142","z\u0142"],RON:[2,"RON","RON"],RSD:[0,"din","RSD"],RUB:[50,"\u20bd","RUB"],SAR:[2,"Rial","Rial"],SEK:[50,"kr","kr"],SGD:[2,"$","S$"],THB:[2,"\u0e3f","THB"],TRY:[2,"TL","YTL"],TWD:[2,"NT$","NT$"],TZS:[0,"TSh","TSh"],UAH:[2,"\u0433\u0440\u043d.","UAH"],USD:[2,"$","US$"],UYU:[2,"$","$U"],VND:[48,"\u20ab","VN\u20ab"],YER:[0,"Rial","Rial"],ZAR:[2,"R","ZAR"]};var xn={DB:".",Bu:",",IB:"%",Ku:"0",LO:"+",CO:"-",GB:"E",JB:"\u2030",Cu:"\u221e",HO:"NaN",CB:"#,##0.###",fP:"#E0",KO:"#,##0%",iO:"\u00a4#,##0.00",lO:"USD"},yn=xn,yn=xn;var zn=function(a,b,c){this.Pn=b||yn.lO;this.mS=c||0;this.us=40;this.oe=1;this.pj=0;this.Ii=3;this.zs=this.Wf=0;this.EM=this.MN=!1;this.xo=this.Ui="";this.jh="-";this.ml="";this.Od=1;this.Ni=!1;this.vi=[];this.nu=this.AD=!1;this.Nm=0;this.wC=null;"number"==typeof a?this.fQ(a):this.Kj(a)};d=zn.prototype;d.b9=function(a){if(0<this.pj&&0<a)throw Error("Can't combine significant digits and minimum fraction digits");this.Wf=a;return this};d.Q8=function(a){this.Ii=a;return this};
d.u$=function(a){if(0<this.Wf&&0<=a)throw Error("Can't combine significant digits and minimum fraction digits");this.pj=a;return this};d.Kj=function(a){a.replace(/ /g,"\u00a0");var b=[0];this.Ui=this.Ls(a,b);var c=b[0];this.M3(a,b);c=b[0]-c;this.xo=this.Ls(a,b);b[0]<a.length&&";"==a.charAt(b[0])?(b[0]++,1!=this.Od&&(this.Ni=!0),this.jh=this.Ls(a,b),b[0]+=c,this.ml=this.Ls(a,b)):(this.jh=this.Ui+this.jh,this.ml+=this.xo)};
d.fQ=function(a){switch(a){case 1:this.Kj(yn.CB);break;case 2:this.Kj(yn.fP);break;case 3:this.Kj(yn.KO);break;case 4:this.Kj(wn(yn.iO,this.Pn));break;case 5:this.mC(1);break;case 6:this.mC(2);break;default:throw Error("Unsupported pattern type.");}};d.mC=function(a){this.Nm=a;this.Kj(yn.CB);this.b9(0);this.Q8(2);this.u$(2)};
d.parse=function(a,b){b=b||[0];if(0!=this.Nm)throw Error("Parsing of compact numbers is unimplemented");var c;a=a.replace(/ /g,"\u00a0");var e=a.indexOf(this.Ui,b[0])==b[0],f=a.indexOf(this.jh,b[0])==b[0];e&&f&&(this.Ui.length>this.jh.length?f=!1:this.Ui.length<this.jh.length&&(e=!1));e?b[0]+=this.Ui.length:f&&(b[0]+=this.jh.length);a.indexOf(yn.Cu,b[0])==b[0]?(b[0]+=yn.Cu.length,c=Infinity):c=this.w3(a,b);if(e){if(a.indexOf(this.xo,b[0])!=b[0])return NaN;b[0]+=this.xo.length}else if(f){if(a.indexOf(this.ml,
b[0])!=b[0])return NaN;b[0]+=this.ml.length}return f?-c:c};
d.w3=function(a,b){var c=!1,e=!1,f=!1,g=1,k=yn.DB,p=yn.Bu,q=yn.GB;if(0!=this.Nm)throw Error("Parsing of compact style numbers is not implemented");for(var A="";b[0]<a.length;b[0]++){var M=a.charAt(b[0]),Q=this.hF(M);if(0<=Q&&9>=Q)A+=Q,f=!0;else if(M==k.charAt(0)){if(c||e)break;A+=".";c=!0}else if(M==p.charAt(0)&&("\u00a0"!=p.charAt(0)||b[0]+1<a.length&&0<=this.hF(a.charAt(b[0]+1)))){if(c||e)break}else if(M==q.charAt(0)){if(e)break;A+="E";e=!0}else if("+"==M||"-"==M)A+=M;else if(1==this.Od&&M==yn.IB.charAt(0)){if(1!=
g)break;g=100;if(f){b[0]++;break}}else if(1==this.Od&&M==yn.JB.charAt(0)){if(1!=g)break;g=1E3;if(f){b[0]++;break}}else break}1!=this.Od&&(g=this.Od);return parseFloat(A)/g};d.format=function(a){if(isNaN(a))return yn.HO;var b=[],c=this.yY(null===this.wC?a:this.wC,a);a/=Math.pow(10,c.$v);b.push(c.prefix);var e=0>a||0==a&&0>1/a;b.push(e?this.jh:this.Ui);isFinite(a)?(a=a*(e?-1:1)*this.Od,this.nu?this.Yaa(a,b):this.UA(a,this.oe,b)):b.push(yn.Cu);b.push(e?this.ml:this.xo);b.push(c.UM);return b.join("")};
d.uK=function(a){var b=Math.pow(10,this.Ii),c=0>=this.pj?Math.round(a*b):Math.round(this.g6(a*b,this.pj,this.Ii));isFinite(c)?(a=Math.floor(c/b),b=Math.floor(c-a*b)):b=0;return{hH:a,UT:b}};
d.UA=function(a,b,c){if(this.Wf>this.Ii)throw Error("Min value must be less than max value");c||(c=[]);a=this.uK(a);var e=Math.pow(10,this.Ii),f=a.hH,g=a.UT,k=0==f?0:this.Vr(f)+1,p=0<this.Wf||0<g||this.EM&&k<this.pj;a=this.Wf;p&&(a=this.EM&&0<this.pj?this.pj-k:this.Wf);for(var q="",k=f;1E20<k;)q="0"+q,k=Math.round(k/10);var q=k+q,A=yn.DB,k=yn.Ku.charCodeAt(0),M=q.length,Q=0;if(0<f||0<b){for(f=M;f<b;f++)c.push(String.fromCharCode(k));if(2<=this.vi.length)for(b=1;b<this.vi.length;b++)Q+=this.vi[b];
b=M-Q;if(0<b)for(var f=this.vi,Q=M=0,ca,Vb=yn.Bu,Gb=q.length,Wb=0;Wb<Gb;Wb++){if(c.push(String.fromCharCode(k+1*Number(q.charAt(Wb)))),1<Gb-Wb)if(ca=f[Q],Wb<b){var Kj=b-Wb;(1===ca||0<ca&&1===Kj%ca)&&c.push(Vb)}else Q<f.length&&(Wb===b?Q+=1:ca===Wb-b-M+1&&(c.push(Vb),M+=ca,Q+=1))}else{b=q;q=this.vi;f=yn.Bu;ca=b.length;Vb=[];for(M=q.length-1;0<=M&&0<ca;M--){Q=q[M];for(Gb=0;Gb<Q&&0<=ca-Gb-1;Gb++)Vb.push(String.fromCharCode(k+1*Number(b.charAt(ca-Gb-1))));ca-=Q;0<ca&&Vb.push(f)}c.push.apply(c,Vb.reverse())}}else p||
c.push(String.fromCharCode(k));(this.AD||p)&&c.push(A);e=""+(g+e);for(g=e.length;"0"==e.charAt(g-1)&&g>a+1;)g--;for(f=1;f<g;f++)c.push(String.fromCharCode(k+1*Number(e.charAt(f))))};d.WB=function(a,b){b.push(yn.GB);0>a?(a=-a,b.push(yn.CO)):this.MN&&b.push(yn.LO);a=""+a;for(var c=yn.Ku,e=a.length;e<this.zs;e++)b.push(c);b.push(a)};d.vW=function(a,b){var c=Math.pow(10,b);if(isFinite(c)&&0!==c)return a/c;c=Math.pow(10,Math.floor(b/2));a=a/c/c;1==b%2&&(a=0<b?a/10:10*a);return a};
d.Yaa=function(a,b){if(0==a)this.UA(a,this.oe,b),this.WB(0,b);else{var c=Math.floor(Math.log(a)/Math.log(10)+2E-15);a=this.vW(a,c);var e=this.oe;if(1<this.us&&this.us>this.oe){for(;0!=c%this.us;)a*=10,c--;e=1}else 1>this.oe?(c++,a/=10):(c-=this.oe-1,a*=Math.pow(10,this.oe-1));this.UA(a,e,b);this.WB(c,b)}};d.hF=function(a){a=a.charCodeAt(0);if(48<=a&&58>a)return a-48;var b=yn.Ku.charCodeAt(0);return b<=a&&a<b+10?a-b:-1};
d.Ls=function(a,b){for(var c="",e=!1,f=a.length;b[0]<f;b[0]++){var g=a.charAt(b[0]);if("'"==g)b[0]+1<f&&"'"==a.charAt(b[0]+1)?(b[0]++,c+="'"):e=!e;else if(e)c+=g;else switch(g){case "#":case "0":case ",":case ".":case ";":return c;case "\u00a4":if(b[0]+1<f&&"\u00a4"==a.charAt(b[0]+1))b[0]++,c+=this.Pn;else switch(this.mS){case 0:c+=vn[this.Pn][1];break;case 2:var g=this.Pn,k=vn[g],c=c+(g==k[1]?g:g+" "+k[1]);break;case 1:c+=vn[this.Pn][2]}break;case "%":if(!this.Ni&&1!=this.Od)throw Error("Too many percent/permill");
if(this.Ni&&100!=this.Od)throw Error("Inconsistent use of percent/permill characters");this.Od=100;this.Ni=!1;c+=yn.IB;break;case "\u2030":if(!this.Ni&&1!=this.Od)throw Error("Too many percent/permill");if(this.Ni&&1E3!=this.Od)throw Error("Inconsistent use of percent/permill characters");this.Od=1E3;this.Ni=!1;c+=yn.JB;break;default:c+=g}}return c};
d.M3=function(a,b){for(var c=-1,e=0,f=0,g=0,k=-1,p=a.length,q=!0;b[0]<p&&q;b[0]++)switch(a.charAt(b[0])){case "#":0<f?g++:e++;0<=k&&0>c&&k++;break;case "0":if(0<g)throw Error('Unexpected "0" in pattern "'+a+'"');f++;0<=k&&0>c&&k++;break;case ",":0<k&&this.vi.push(k);k=0;break;case ".":if(0<=c)throw Error('Multiple decimal separators in pattern "'+a+'"');c=e+f+g;break;case "E":if(this.nu)throw Error('Multiple exponential symbols in pattern "'+a+'"');this.nu=!0;this.zs=0;b[0]+1<p&&"+"==a.charAt(b[0]+
1)&&(b[0]++,this.MN=!0);for(;b[0]+1<p&&"0"==a.charAt(b[0]+1);)b[0]++,this.zs++;if(1>e+f||1>this.zs)throw Error('Malformed exponential pattern "'+a+'"');q=!1;break;default:b[0]--,q=!1}0==f&&0<e&&0<=c&&(f=c,0==f&&f++,g=e-f,e=f-1,f=1);if(0>c&&0<g||0<=c&&(c<e||c>e+f)||0==k)throw Error('Malformed pattern "'+a+'"');a=e+f+g;this.Ii=0<=c?a-c:0;0<=c&&(this.Wf=e+f-c,0>this.Wf&&(this.Wf=0));this.oe=(0<=c?c:a)-e;this.nu&&(this.us=e+this.oe,0==this.Ii&&0==this.oe&&(this.oe=1));this.vi.push(Math.max(0,k));this.AD=
0==c||c==a};var An={prefix:"",UM:"",$v:0};zn.prototype.zG=function(a,b){var c=1==this.Nm?un.AB:un.hO;null==c&&(c=un.AB);if(3>a)return An;a=Math.min(14,a);var e=c[Math.pow(10,a)];for(--a;!e&&3<=a;)e=c[Math.pow(10,a)],a--;if(!e)return An;b=e[b];return b&&"0"!=b?(b=/([^0]*)(0+)(.*)/.exec(b))?{prefix:b[1],UM:b[3],$v:a+1-(b[2].length-1)}:An:An};
zn.prototype.yY=function(a){if(0==this.Nm)return An;a=Math.abs(a);var b=this.zG(1>=a?0:this.Vr(a),"other").$v;return this.zG(b+this.Vr(this.uK(a/Math.pow(10,b)).hH),"other")};zn.prototype.Vr=function(a){for(var b=0;1<=(a/=10);)b++;return b};zn.prototype.g6=function(a,b,c){if(!a)return a;b=b-this.Vr(a)-1;if(b<-c)return c=Math.pow(10,c),Math.round(a/c)*c;c=Math.pow(10,b);return Math.round(a*c)/c};var Bn=function(a){return 1==a%10&&11!=a%100?"one":2==a%10&&12!=a%100?"two":3==a%10&&13!=a%100?"few":"other"},Cn=Bn,Cn=Bn;var Dn=function(a,b){if(void 0===b){b=a+"";var c=b.indexOf(".");b=Math.min(-1==c?0:b.length-c-1,3)}return 1==(a|0)&&0==b?"one":"other"},En=Dn,En=Dn;var Fn=function(a){this.bl=[];this.Yy=[];this.yy=new zn(1);this.y3(a)},Gn=/'([{}#].*?)'/g,Hn=/''/g;d=Fn.prototype;d.format=function(a){return this.cr(a,!1)};d.cr=function(a,b){if(0==this.Yy.length)return"";var c=[];this.sw(this.Yy,a,b,c);for(a=c.join("");0<this.bl.length;)a=a.replace(this.ov(this.bl),this.bl.pop());return a};
d.sw=function(a,b,c,e){for(var f=0;f<a.length;f++)switch(a[f].type){case 4:e.push(a[f].value);break;case 3:var g=a[f].value;this.TT(g,b,e);break;case 2:g=a[f].value;this.ST(g,b,c,e);break;case 0:g=a[f].value;this.tE(g,b,En,c,e);break;case 1:g=a[f].value;this.tE(g,b,Cn,c,e);break;default:y("Unrecognized block type: "+a[f].type)}};d.TT=function(a,b,c){b=b[a];l(b)?(this.bl.push(b),c.push(this.ov(this.bl))):c.push("Undefined parameter - "+a)};
d.ST=function(a,b,c,e){var f=a.bq;l(b[f])?(f=a[b[f]],l(f)||(f=a.other),this.sw(f,b,c,e)):e.push("Undefined parameter - "+f)};d.tE=function(a,b,c,e,f){var g=a.bq,k=a.oC,p=+b[g];isNaN(p)?f.push("Undefined or invalid parameter - "+g):(k=p-k,g=a[b[g]],l(g)||(c=this.yy.OW?c(k,this.yy.OW()):c(k),g=a[c],l(g)||(g=a.other)),a=[],this.sw(g,b,e,a),b=a.join(""),e?f.push(b):(e=this.yy.format(k),f.push(b.replace(/#/g,e))))};d.y3=function(a){a&&(a=this.f_(a),this.Yy=this.Ms(a))};
d.f_=function(a){var b=this.bl,c=v(this.ov,this);a=a.replace(Hn,function(){b.push("'");return c(b)});return a=a.replace(Gn,function(a,f){b.push(f);return c(b)})};d.Uq=function(a){var b=0,c=[],e=[],f=/[{}]/g;f.lastIndex=0;for(var g;g=f.exec(a);){var k=g.index;"}"==g[0]?(c.pop(),0==c.length&&(g={type:1},g.value=a.substring(b,k),e.push(g),b=k+1)):(0==c.length&&(b=a.substring(b,k),""!=b&&e.push({type:0,value:b}),b=k+1),c.push("{"))}b=a.substring(b);""!=b&&e.push({type:0,value:b});return e};
var In=/^\s*(\w+)\s*,\s*plural\s*,(?:\s*offset:(\d+))?/,Jn=/^\s*(\w+)\s*,\s*selectordinal\s*,/,Kn=/^\s*(\w+)\s*,\s*select\s*,/;d=Fn.prototype;d.V2=function(a){return In.test(a)?0:Jn.test(a)?1:Kn.test(a)?2:/^\s*\w+\s*/.test(a)?3:5};
d.Ms=function(a){var b=[];a=this.Uq(a);for(var c=0;c<a.length;c++){var e={};if(0==a[c].type)e.type=4,e.value=a[c].value;else if(1==a[c].type)switch(this.V2(a[c].value)){case 2:e.type=2;e.value=this.D3(a[c].value);break;case 0:e.type=0;e.value=this.z3(a[c].value);break;case 1:e.type=1;e.value=this.x3(a[c].value);break;case 3:e.type=3;e.value=a[c].value;break;default:y("Unknown block type for pattern: "+a[c].value)}else y("Unknown part of the pattern.");b.push(e)}return b};
d.D3=function(a){var b="";a=a.replace(Kn,function(a,c){b=c;return""});var c={};c.bq=b;a=this.Uq(a);for(var e=0;e<a.length;){var f=a[e].value;e++;if(1==a[e].type)var g=this.Ms(a[e].value);else y("Expected block type.");c[f.replace(/\s/g,"")]=g;e++}return c};
d.z3=function(a){var b="",c=0;a=a.replace(In,function(a,e,f){b=e;f&&(c=parseInt(f,10));return""});var e={};e.bq=b;e.oC=c;a=this.Uq(a);for(var f=0;f<a.length;){var g=a[f].value;f++;if(1==a[f].type)var k=this.Ms(a[f].value);else y("Expected block type.");e[g.replace(/\s*(?:=)?(\w+)\s*/,"$1")]=k;f++}return e};
d.x3=function(a){var b="";a=a.replace(Jn,function(a,c){b=c;return""});var c={};c.bq=b;c.oC=0;a=this.Uq(a);for(var e=0;e<a.length;){var f=a[e].value;e++;if(1==a[e].type)var g=this.Ms(a[e].value);else y("Expected block type.");c[f.replace(/\s*(?:=)?(\w+)\s*/,"$1")]=g;e++}return c};d.ov=function(a){return"\ufddf_"+(a.length-1).toString(10)+"_"};var Ln=chrome.i18n.getMessage("1522140683318860351"),Mn=chrome.i18n.getMessage("4246483347873264186"),Nn=chrome.i18n.getMessage("5991427458288444010"),On=chrome.i18n.getMessage("6063910461797960050"),Pn=chrome.i18n.getMessage("7735695102441495789"),Qn=chrome.i18n.getMessage("4575332923598659024"),Rn=chrome.i18n.getMessage("2297080986956220930"),Sn=new Fn(Rn),Tn=function(a,b){return Sn.format({ORGANIZER:a,PARTICIPANTS:b})};var Un=function(a){this.nb=a;this.a=E("mr.cloud.mesi.MesiService")},Vn={request_header:{client_version:{client_id:"39"}},search_sources:["0"]};
Un.prototype.IT=function(){var a=Lm.wg;.1>Math.random()&&(a=a.replace("v1","v1_preprod"));a=this.nb.ei(a,["hangouts","search"]);H(this.a,"Retrieving Hangouts from MESI: "+a);return this.nb.zg(a,"POST",Vn).then(function(a){var b=[];a.result&&(b=a.result.map(function(a){var b=a.hangout,c,e;b.external_key?(c=b.external_key.value.replace(/@.*/,""),e=b.external_key.service):b.sharing_url&&(e=b.sharing_url.split("/"),c=e[4],e=e[3]);var p=b.meeting_room_name,q;b.meeting_domain?(q=b.meeting_domain,p&&(c=
p,e=q)):"BUSINESS"==b.type&&b.company_title&&(q=b.company_title.toLowerCase());var A=Tn("",0);if((a=a.participant)&&0<a.length){var M=a[0].display_name;a=a.reduce(function(a,b){a.add(b.user_id);"ORGANIZER"==b.role&&(M=b.display_name);return a},new Jc);A=Tn(M,a.R())}return new Hm(c,e,p,q,A,b.hangout_id)}));return b})};var Wn=function(a,b,c){this.state=a;this.type=null!=b?b:null;this.results=null!=c?c:null},Xn=function(a){this.nb=a};Xn.$inject=["gapiService"];d=Xn.prototype;d.G6=function(a,b,c){var e=this;return this.NK(Tm,a,b,c,35E3).then(function(a){return e.MG(a)})};d.I6=function(a,b,c){var e=this;return this.NK(Um,a,b,c,23E3).then(function(a){var b=a.state;return"done"==b?(a=e.rJ(a),new Wn(b,a.type,new Qm(a.sessionDescription))):new Wn(b)})};d.N6=function(a){return this.gf(a,Vm,{})};
d.NK=function(a,b,c,e,f){var g={_webrtcMessage:JSON.stringify(c.presentationUrl?new Qm(c.description,null,c.presentationUrl):new Qm(c.description))};c.settings&&(g._settings=c.settings.YA());c.mediaConstraints&&(g._optMediaConstraints=JSON.stringify(c.mediaConstraints));e&&(g._user=JSON.stringify(e));return this.gf(b,a,g,f)};
d.MG=function(a){var b=a.state;switch(b){case "done":return Promise.resolve(this.h3(a));case "queued":case "inProgress":var c=this;return c.fca(a).then(function(a){return c.MG(a)});default:return Promise.resolve(new Wn(b))}};d.fca=function(a){var b=this;return new Promise(function(c){var e=setInterval(function(){b.zT(a.id).then(function(a){"queued"!=a.state&&"inProgress"!=a.state&&(clearInterval(e),c(a))})},2E3)})};
d.h3=function(a){a=this.rJ(a);return"__cloud_webrtc_session_message__"==a.type?new Wn("done","knocking_cloud_webrtc_session_message",new Qm(a.sessionDescription)):new Wn("done",a.type)};d.gf=function(a,b,c,e){a={deviceId:a,name:"_cloudCast."+b.name,parameters:c,expirationTimeoutMs:e||1E4};b={};e&&(b.responseAwaitMs=Math.min(e+5E3,25E3));e=this.nb.ei(Jm.wg,["commands"],b);return this.nb.zg(e,"POST",a)};d.rJ=function(a){return a.results&&a.results.results?JSON.parse(a.results.results):null};
d.zT=function(a){a=this.nb.ei(Jm.wg,["commands",a]);return this.nb.zg(a,"GET")};var Yn=function(a,b,c,e){this.Lf=a;this.Sb=b;this.wp=c;this.Lb=e};d=Yn.prototype;d.kZ=function(a,b,c){var e=this;return this.B6(a,b,c).then(function(a){return e.WY(a,b.id)})};d.dZ=function(a){var b=this;return this.wp.RU().then(function(c){b.Lb.pd(new Vg("TURN_CREDENTIALS",{credentials:c}),a.id)})};
d.B6=function(a,b,c){b=c.deviceId;var e=this.Sb.Ge,e=e?new Om(e):void 0;a=a.data;switch(c.Lu){case "owner":gn(0);break;case "manager":gn(1);break;case "user":gn(2);break;case "viewer":gn(3)}return"viewer"==c.Lu?this.Lf.G6(b,a,e):this.Lf.I6(b,a,e)};
d.WY=function(a,b){if("done"!=a.state)return Promise.reject(Error("Offer not executed by receiver. State: "+a.state));switch(a.type){case "__cloud_webrtc_session_message__":a=new Vg("ANSWER",a.results.sessionDescription);this.Lb.pd(a,b);break;case "knocking_cloud_webrtc_session_message":dn(0);a=new Vg("KNOCK_ANSWER",a.results.sessionDescription);this.Lb.pd(a,b);break;case "knock_denied":dn(1);this.LG(Mn,b);break;case "knock_timeout":dn(2);this.LG(Nn,b);break;default:return Promise.reject(Error("Invalid message type: "+
a.type))}return Promise.resolve()};d.LG=function(a,b){a=new qg(a,"warning","dismiss");a.C8(!0);this.Lb.Nf().send(a);this.Lb.pd(new Vg("STOP"),b)};var Zn=function(){this.ik=null;this.a=E("mr.cloud.messaging.CloudMessageListener");this.ez=[]};d=Zn.prototype;d.W7=function(a){this.ik=a};d.onMessage=function(a){this.ik?this.EJ(a):(I(this.a,"[pending] "+a.data.notification),this.ez.push(a))};d.s0=function(){var a=this;this.ik&&(this.ez.forEach(function(b){a.EJ(b)}),this.ez=[])};
d.EJ=function(a){var b=this;if(a.data.notification&&(I(this.a,"[processing] "+a.data.notification),(a=JSON.parse(a.data.notification))&&a.events)){var c=Mi.N();a.events.forEach(function(a){var e=c.hn(a.deviceId);switch(a.type){case "deviceCreated":b.t1(a,e);break;case "deviceUpdated":b.y1(a,e);break;case "deviceDeleted":b.v1(a,e);break;default:I(b.a,"[unhandled event] "+JSON.stringify(a))}})}};
d.t1=function(a,b){a=new jn(a.deviceId,a.statePatch._cloudCast.settings.receiverName,"owner","default",!0);this.ik.s1({sinkId:b,cloudSink:a})};d.y1=function(a,b){a.statePatch._cloudCast&&a.statePatch._cloudCast.appStatus&&this.ik.x1({sinkId:b,isAvailable:"available"==a.statePatch._cloudCast.appStatus})};d.v1=function(a,b){this.ik.u1({sinkId:b})};var $n=function(a,b){this.Sb=a;this.Lb=b};
$n.prototype.hZ=function(a,b,c){switch(a.type){case "REFRESH_AUTH":var e=c.deviceId,f=c.Oz,g=this;return this.Sb.Y4().then(function(){g.Lb.pd(new Vg("AUTH_READY",{hangoutId:e,resolvedId:f}),b.id)});case "LOCAL_PRESENT":return e=c.deviceId,f=c.Oz,this.Lb.pd(new Vg("AUTH_READY",{hangoutId:e,resolvedId:f,conferenceMode:!a.data.local}),b.id),Promise.resolve();case "STATUS_REQUEST":return this.Lb.pd(a,b.id),Promise.resolve();case "STATUS_RESPONSE":return this.Lb.pd(a,b.id,!0),a.data.routeDescription||
this.Lb.pd(a,b.id),Promise.resolve();case "HANGOUT_INACTIVE":return this.Lb.Bj(b,4,new qg(Pn,"warning","dismiss"));case "HANGOUT_INVALID":return this.Lb.Bj(b,3,new qg(Qn,"warning","dismiss"));default:return Promise.reject(Error("Unknown type: "+a.type))}};var ao=function(a,b,c){this.Xj=a;this.Nn=b;this.Lb=c};
ao.prototype.j4=function(a,b,c,e){var f=this;return new Promise(function(g){switch(a){case "cloud":case "mesi":break;default:throw Error("Unrecognized channel type");}if(!b.type)throw Error("Message has no type");switch(b.type){case "STOP":g(f.Lb.Bj(c,1,null));return;case "SESSION_START_SUCCESS":en(0);break;case "SESSION_END":break;case "SESSION_FAILURE":en(1);g(f.Lb.Bj(c,2,new qg(Ln,"warning","dismiss")));return;case "__webrtc_stats__":break;case "PRESENTATION_CONNECTION_MESSAGE":f.Lb.pd(b.data,
c.id,!0);break;case "OFFER":g(f.Xj.kZ(b,c,e));return;case "GET_TURN_CREDENTIALS":g(f.Xj.dZ(c));return;case "REFRESH_AUTH":case "LOCAL_PRESENT":case "MUTE":case "STATUS_REQUEST":case "STATUS_RESPONSE":case "HANGOUT_INACTIVE":case "HANGOUT_INVALID":g(f.Nn.hZ(b,c,e));return;case "new_session":f.Lb.pd(b,c.id,!0);break;case "remove_session":f.Lb.pd(b,c.id,!0);f.Lb.Zc(c.id);break;default:throw Error("Unknown type: "+b.type);}g()})};var bo=function(){var a=this;this.a=E("mr.cloud.settings.SettingsService");this.Dy=null;chrome.settingsPrivate.onPrefsChanged.addListener(function(b){if(a.Dy){b=ja(b);for(var c=b.next();!c.done;c=b.next())if(c=c.value,"media_router.cloudservices.enabled"==c.key){a.Dy.call(null,c.value);break}}})};d=bo.prototype;d.t9=function(a){this.Dy=a};d.vba=function(){var a=this.a;chrome.storage.sync.set({"mr.cloud.cloudEnabled":!0},function(){chrome.runtime.lastError&&G(a,"Error setting cloud setting: "+JSON.stringify(chrome.runtime.lastError))})};
d.NU=function(){var a=this;return this.WE().catch(function(){return a.WE().catch(function(b){G(a.a,"Error retrieving cloud on setting: "+JSON.stringify(b));return!1})})};d.WE=function(){return this.wF("mr.cloud.cloudEnabled").then(function(a){return!!a["mr.cloud.cloudEnabled"]})};d.wF=function(a){return new Promise(function(b,c){chrome.storage.sync.get(a,function(a){chrome.runtime.lastError?c(chrome.runtime.lastError):b(a)})})};
d.LU=function(){var a=this;return this.UE().catch(function(){return a.UE().catch(function(b){G(a.a,"Error retrieving cloud enabled setting: "+JSON.stringify(b));return!1})})};d.UE=function(){return this.qX("media_router.cloudservices.enabled").then(function(a){return!!a.value})};d.qX=function(a){return new Promise(function(b,c){chrome.settingsPrivate.getPref(a,function(a){chrome.runtime.lastError?c(chrome.runtime.lastError):b(a)})})};
d.s9=function(){var a=this.a;chrome.storage.sync.set({"mr.cloud.notifiedHangouts":!0},function(){chrome.runtime.lastError&&G(a,"Error setting notified Hangout privacy: "+JSON.stringify(chrome.runtime.lastError))})};d.dX=function(){var a=this;return this.PF().catch(function(){return a.PF().catch(function(b){G(a.a,"Error retrieving hangouts notified setting: "+JSON.stringify(b));return!1})})};d.PF=function(){return this.wF("mr.cloud.notifiedHangouts").then(function(a){return!!a["mr.cloud.notifiedHangouts"]})};var co=function(a){this.a=E("mr.cloud.CredentialService");this.nb=a};co.prototype.RU=function(){var a=this,b=new ff,c=Mm.wg+"/iceconfig?key="+Mm.wba;H(this.a,"Requesting TURN credentials from "+c);var e=tf(c,function(){return a.N2(e,b)},"POST",void 0,{"Content-Type":"application/json"});return b.promise};co.prototype.N2=function(a,b){a.Md()?(H(this.a,"Got TURN credentials: "+a.Jk()),b.resolve(this.D1(a.MX()))):b.resolve(this.E1(null))};
co.prototype.D1=function(a){try{var b=[];a.iceServers.forEach(function(a){a.urls.forEach(function(c){0==c.indexOf("turn:")&&b.push({url:c,credential:a.credential,username:a.username})})});return b}catch(c){return F(this.a,"Error parsing TURN credentials.",c),[]}};co.prototype.E1=function(a){F(this.a,"XHR failed fetching TURN credentials.",a instanceof Error?a:void 0);return[]};var eo=function(){this.vw=this.wp=this.ze=this.jl=this.Nn=this.Xj=this.Lf=this.ux=this.tv=this.ry=this.Kv=this.Iv=this.nb=this.ev=null};qa(eo);d=eo.prototype;d.Bk=function(){null==this.ev&&(this.ev=new rn);return this.ev};d.un=function(){null==this.nb&&(this.nb=new qn(this.Bk()));return this.nb};d.KU=function(){null==this.Iv&&(this.Iv=new Xm(this.un()));return this.Iv};d.VE=function(){this.vw||(this.vw=new Zn);return this.vw};
d.OU=function(a){null==this.Kv&&(this.Kv=new nn(this.KU(),a,this.VE()));return this.Kv};d.KW=function(){null==this.ry&&(this.ry=new Un(this.un()));return this.ry};d.uU=function(){null==this.tv&&(this.tv=new Nm(this.un(),this.Bk()));return this.tv};d.TV=function(a){null==this.ux&&(this.ux=new pn(this.uU(),this.KW(),a));return this.ux};d.nF=function(){null==this.Lf&&(this.Lf=new Xn(this.un()));return this.Lf};d.MU=function(a){null==this.Xj&&(this.Xj=new Yn(this.nF(),this.Bk(),this.vY(),a));return this.Xj};
d.MV=function(a){null==this.Nn&&(this.Nn=new $n(this.Bk(),a));return this.Nn};d.LW=function(a){null==this.jl&&(this.jl=new ao(this.MU(a),this.MV(a),a));return this.jl};d.bY=function(){null==this.ze&&(this.ze=new bo);return this.ze};d.vY=function(){null==this.wp&&(this.wp=new co(this.un()));return this.wp};var fo=function(a,b,c){Nd.call(this);this.al=null!=c?v(a,c):a;this.ne=b;this.Fm=v(this.J2,this);this.bv=[]};x(fo,Nd);d=fo.prototype;d.Tl=!1;d.so=0;d.Ta=null;d.pw=function(a){this.bv=arguments;this.Ta||this.so?this.Tl=!0:this.aw()};d.stop=function(){this.Ta&&($e(this.Ta),this.Ta=null,this.Tl=!1,this.bv=[])};d.pause=function(){this.so++};d.resume=function(){this.so--;this.so||!this.Tl||this.Ta||(this.Tl=!1,this.aw())};d.L=function(){fo.S.L.call(this);this.stop()};
d.J2=function(){this.Ta=null;this.Tl&&!this.so&&(this.Tl=!1,this.aw())};d.aw=function(){this.Ta=Ze(this.Fm,this.ne);this.al.apply(null,this.bv)};var go=function(){this.Yb=null;this.a=E("mr.IssueSenderImpl")};go.prototype.init=function(a){this.Yb=a};go.prototype.send=function(a){if(this.Yb)if(this.Yb.onIssue)this.Yb.onIssue(a);else F(this.a,"MediaRouterService.onIssue not defined.");else F(this.a,"MediaRouterService is not set.")};var ho=new Set;var io=function(a,b){J.call(this,"internal_message");this.routeId=a;this.message=b};x(io,J);var jo=function(a,b,c){Nd.call(this);this.vK=a;this.gf=b;this.E0=c;this.onMessage=n;c.listen("internal_message",this.Fs,!1,this)};x(jo,Nd);jo.prototype.sendMessage=function(a,b){return this.gf(this.vK,a,b)};jo.prototype.Fs=function(a){if(a.routeId==this.vK)this.onMessage(a.message)};jo.prototype.L=function(){this.E0.vd("internal_message",this.Fs,!1,this)};var ko=new jo("",function(){return Promise.resolve()},new K),lo=function(a){this.w=a};
lo.prototype.qr=function(a){var b=this.w.cx(a);return b?new jo(a,v(b.Ch,b),this.w.gx()):ko};var mo=function(){this.a=E("mr.ProviderManager");this.Qd=[];this.Sd=new Map;this.Fl=new Map;this.kg=new Set;this.fj=new Set;this.Li=new Map;this.Yb=null;this.Ul=!1;this.wK=new K;this.xK=new fo(this.L6,500,this);this.naa=new fo(this.pT,500,this);this.jo=new cm(this,524288);this.fz=0;this.yH=new go;this.Vl=new Map;this.ys=-1==window.navigator.userAgent.indexOf("Windows");this.xs=[];this.ds=[];this.createRoute=this.Ne;this.joinRoute=this.Ai;this.connectRouteByRouteId=this.Th;this.terminateRoute=this.Zc;
this.startObservingMediaSinks=this.vj;this.stopObservingMediaSinks=this.yj;this.sendRouteMessage=this.Ch;this.sendRouteBinaryMessage=this.K6;this.startListeningForRouteMessages=this.Caa;this.stopListeningForRouteMessages=this.QA;this.startObservingMediaRoutes=this.uj;this.stopObservingMediaRoutes=this.xj;this.onPresentationSessionDetached=this.detachRoute=this.Ig;this.enableMdnsDiscovery=this.UD;this.searchSinksAndCreateRoute=this.w6;this.searchSinks=this.fg;this.updateMediaSinks=this.Jba};d=mo.prototype;
d.PW=function(a){return this.Li.get(a).cl()};d.Z4=function(a){a.forEach(this.d5,this)};d.Ld=function(a,b){this.Li.set("webrtc",new ch(new Gm(this)));this.Li.set("cast_streaming",new ch(new Dm(this)));var c=zh.N();c.c9(this);c.y8(eo.N().Bk());this.Li.set("hangouts",c);c=new lo(this);pg||(pg=c);this.Yb=a;this.yH.init(a);this.jo.init(this.Yb.onRouteMessagesReceived.bind(this.Yb));this.Z4(b);Ci(this)};
d.d5=function(a){if(this.yr(a.getName()))G(this.a,"Provider "+a.getName()+" already registered.");else try{a.Ld(),this.Qd.push(a),this.Vl.set(a.getName(),0)}catch(b){G(this.a,"Provider "+a.getName()+" failed to initialize.",b)}};
d.Tp=function(a,b){var c=this;return new Promise(function(e,f){var g=null;c.f4();var g=window.setTimeout(function(){g=null;a.cancel(new Ik(2,"timeout after "+b+" ms."))},b),k=function(){c.ZP();null!=g&&window.clearTimeout(g)};a.promise.then(function(a){k();e(a)},function(a){k();f(a instanceof Ik?a:a instanceof Error?new Ik(0,a.message,a.stack):new Ik(0))})})};d.LP=function(a,b){return this.Tp(ug(a),b)};d.f4=function(){this.fz++;this.py()};d.ZP=function(){this.fz--;this.py()};
d.Ne=function(a,b,c,e,f,g,k){var p=this,q=this.vX(a,b);if(!q)return Promise.reject(new Ik(7,"No provider supports createRoute with source: "+a+" and sink: "+b));ho.add(b);this.Oc();g=g&&0<g?g:6E4;a=q.Ne(a,b,c,k||!1,g,e,f);return this.Tp(a,g).then(function(a){ho.delete(b);p.Oc();return a},function(a){F(p.a,"Error creating route.",a);ho.delete(b);p.Oc();throw a;})};
d.Th=function(a,b,c,e,f,g){var k=this.Sd.get(b);if(!k)return Promise.reject(new Ik(7,"No provider supports join "+b));a=k.Th(a,b,c,e,f);return this.Tp(a,g&&0<g?g:3E4)};d.Ai=function(a,b,c,e,f,g){var k=this.uX(a);if(!k)return Promise.reject(new Ik(7,"No provider supports join "+b));f=f&&0<f?f:3E4;a=k.Ai(a,b,g||!1,f,c,e);return this.Tp(a,f)};d.Zc=function(a){var b=this.Sd.get(a);return b?this.kI(a).then(function(){b.Zc(a)}):Promise.reject(new Ik(3,"Route not found for routeId "+a))};
d.vj=function(a){this.kg.has(a)||(this.kg.add(a),this.Qd.forEach(function(b){b.vj(a)}));this.qz(a)};d.yj=function(a){this.kg.delete(a)?this.QD(a):H(this.a,"No existing query "+a)};d.QD=function(a){this.Qd.forEach(function(b){b.yj(a)})};
d.qz=function(a){if("urn:x-org.chromium.media:source:tab:-1"==a)G(this.a,"No sinks for sourceUrn: "+a);else{var b=new Map,c=[];this.Qd.forEach(function(e){var f=e.ln(a);0<f.sinks.length&&(c=f.origins);f.sinks.forEach(function(a){b.has(a.id)?G(this.a,"Detected duplicate sink "+a.id+" from provider: "+e.getName()):b.set(a.id,a)},this)},this);this.M6(a,Array.from(b.values()),c||[])}};d.M6=function(a,b,c){H(this.a,"Sending "+b.length+" sinks to MR for "+a);no(b);this.Yb.onSinksReceived(a,b,c)};
var no=function(a){a.forEach(function(a){a.isLaunching_=ho.has(a.id)})};d=mo.prototype;d.Ch=function(a,b,c){var e=this.Sd.get(a);return e?this.LP(e.Ch(a,b,c),3E4):Promise.reject(Error("Invalid route ID "+a))};d.K6=function(a){return Promise.reject(Error("Route "+a+" does not support sending binary data"))};d.Caa=function(a){this.jo.U_(a)};d.QA=function(a){this.jo.QA(a)};d.Ig=function(a){var b=this.Sd.get(a);b?b.Ig(a):H(this.a,"Route "+a+" does not exist.")};
d.UD=function(){this.ys=!0;this.xs.forEach(function(a){a()});this.xs.length=0};d.vX=function(a,b){return this.Qd.find(function(c){return c.Gm(a,b)})||null};d.uX=function(a){return this.Qd.find(function(b){return b.Sj(a)})||null};d.pT=function(){this.kg.forEach(function(a){this.qz(a)},this)};d.py=function(){this.Yb.setKeepAlive(0<this.fz||0<this.ds.length)};d.uj=function(a){this.fj.has(a)||(this.Ul=!0,this.fj.add(a),this.Qd.forEach(function(b){b.uj(a)}));this.xK.pw()};
d.xj=function(a){this.fj.delete(a)?(0==this.fj.size&&(this.Ul=!1),this.Qd.forEach(function(b){b.xj(a)})):H(this.a,"No existing route query "+a)};d.L6=function(){if(this.Ul){var a=[];this.Qd.forEach(function(b){a=a.concat(b.Rf())});this.fj.forEach(function(b){var c=[];this.Qd.forEach(function(a){a.Rf().forEach(function(e){!e.ek&&a.Sj(b,e)&&c.push(e.id)})});this.Yb.onRoutesUpdated(a,b,c)},this)}};var oo=function(a,b,c,e,f,g,k){this.maa=b;this.k6=c;this.haa=e;this.i6=f;this.laa=g;this.w0=k};d=mo.prototype;
d.ka=function(){return"ProviderManager"};d.getData=function(){return[new oo(this.Qd.map(function(a){return a.getName()}),Array.from(this.kg),Array.from(this.fj),this.Ul,Array.from(this.Sd,function(a){var b=ja(a);a=b.next().value;b=b.next().value;return[a,b.getName()]}),Array.from(this.Vl),this.ys)]};
d.fb=function(){var a=zi(this);if(a){this.kg=new Set(a.maa);this.fj=new Set(a.k6);this.Ul=a.haa;for(var b=ja(a.i6),c=b.next();!c.done;c=b.next()){var e=ja(c.value),c=e.next().value,e=e.next().value,e=this.yr(e);this.Sd.set(c,e)}this.Vl=new Map(a.laa);a.w0&&this.UD()}};d.cx=function(a){return this.Sd.get(a)};d.rl=function(a,b){this.Sd.set(b.id,a);this.lh(a,b)};d.Pi=function(a,b){this.kI(b.id);this.Sd.delete(b.id);this.jo.Pi(b.id);this.lh(a,b)};d.lh=function(){this.Ul&&this.xK.pw()};
d.TI=function(a){var b=this.Sd.get(a.id);b&&this.lh(b,a)};d.re=function(a,b,c){this.Sd.has(b)?("string"!=typeof c&&(c=JSON.stringify(c)),this.jo.send(b,c)):G(this.a,"Got route message for closed route "+b)};d.onPresentationConnectionStateChanged=function(a,b){this.Yb.onPresentationConnectionStateChanged(a,b)};
d.onPresentationConnectionClosed=function(a,b,c){if("function"!=typeof this.Yb.onPresentationConnectionClosed)this.onPresentationConnectionStateChanged(a,"closed");else this.Yb.onPresentationConnectionClosed(a,b,c)};d.Iy=function(a){this.Fl.delete(a);var b=this.Sd.get(a);b&&b.Zc(a)};d.Es=function(a,b,c){this.wK.dispatchEvent(new io(b,c))};d.Oc=function(){this.naa.pw()};
d.onSinkAvailabilityUpdated=function(a,b){if("function"==typeof this.Yb.onSinkAvailabilityUpdated&&this.Vl.get(a.getName())!=b){var c=this.iD();this.Vl.set(a.getName(),b);a=this.iD();c!=a&&(this.Yb.onSinkAvailabilityUpdated(a),0==a&&(this.kg.forEach(function(a){this.QD(a)},this),this.kg.clear()))}};d.iD=function(){return Array.from(this.Vl.values()).reduce(function(a,b){return Math.max(a,b)},0)};d.gx=function(){return this.wK};d.Nf=function(){return this.yH};
d.kI=function(a){if(this.Fl.has(a)){var b=this;return this.Li.get(this.Fl.get(a)).cl().then(function(c){b.Fl.delete(a);return c.RM()})}return Promise.resolve(!1)};d.np=function(a,b,c){var e=a.xn(b.sinkId);this.Fl.set(b.id,e);return vg(this.Li.get(e).cl(),function(e){return e.np(b,b.mediaSource,a.Pf(b.sinkId),c)})};d.ju=function(a,b,c,e,f){var g=this.Fl.get(b.id);return g?vg(this.Li.get(g).cl(),function(g){return g.ju(b,c,a.Pf(b.sinkId),e,f)}):tg(Error("Route "+b.id+" is not mirroring"))};
d.yz=function(a){this.ys?a():-1==this.xs.indexOf(a)&&this.xs.push(a)};d.Kx=function(){return this.ys};d.yh=function(a,b){var c=this.ds.indexOf(a),e=0<=c;b&&!e?this.ds.push(a):!b&&e&&this.ds.splice(c,1);this.py()};d.yr=function(a){return this.Qd.find(function(b){return b.getName()==a})||null};d.WF=function(a){return a.startsWith("pseudo:")?a.substring(7):null};
d.w6=function(a,b,c,e,f,g,k,p){var q=this.WF(a),q=q?this.yr(q):null,A=null;q&&(A=q.fg(b,c));if(A)return this.Yb.onSearchSinkIdReceived(a,A.id),this.Ne(b,A.id,e,f,g,k,p);this.Yb.onSearchSinkIdReceived(a,"");return Promise.reject(new Ik(0,"No sink found for search input: "+c.input+" and source: "+b))};d.fg=function(a,b,c){a=(a=this.WF(a))?this.yr(a):null;var e=null;a&&(e=a.fg(b,c));return e?e.id:""};d.Jba=function(a){this.kg.has(a)||this.qz(a)};var po=function(a,b){this.ab=a;this.vaa=b;this.to=new ff;this.m=this.to.promise;this.Tc=pg.qr(a.id);this.qa=new ff;this.zb=!1;this.fp();this.AA();this.wb(new Vg("GET_TURN_CREDENTIALS"))};po.prototype.start=function(){var a=this;return this.m.then(function(b){if(b.Zr())return Promise.reject(Error("Presentation already started"));b.start();return a.qa.promise})};po.prototype.stop=function(){var a=this;this.zb=!1;return this.m.then(function(b){b.stop();a.m=Promise.reject(Error("Peer connection has already been stopped"))})};
po.prototype.fp=function(){var a=this;this.Tc.onMessage=function(b){if(b.type)switch(b.type){case "TURN_CREDENTIALS":a.to.resolve(new ah(a.ab.id,b.data.credentials));break;case "ANSWER":a.m.then(function(a){a.setRemoteDescription(b.data)});break;case "STOP":a.qa.reject("Stop signal received");a.stop();break;default:throw Error("Unknown message type: "+b.type);}else a.m.then(function(a){a.C6({type:"PRESENTATION_CONNECTION_MESSAGE",data:b})})}};
po.prototype.AA=function(){var a=this;this.m.then(function(b){b.VL(function(b){a.wb(new Vg("OFFER",new Xg(b,null,null,a.vaa)))});b.UL(function(b){b=Wg(b);"STOP"==b.type&&a.stop();a.wb(b)});b.TL(function(){a.zb=!0;a.wb(new Vg("SESSION_START_SUCCESS"));a.qa.resolve(a)});b.RL(function(){a.wb(new Vg("SESSION_END"))});b.SL(function(b){a.zb||a.qa.reject(b);a.wb(new Vg("SESSION_FAILURE"))})})};var qo={channelType:"cloud"};po.prototype.wb=function(a){this.Tc.sendMessage(a,qo)};var ro=function(a){this.w=a;this.bb=new D;this.lt=new Map;this.hp=[];this.ze=this.jl=this.Sb=this.Lf=this.Pk=null;this.pl=this.Sh=this.Dg=!1;this.jp=new D;this.im=new D;Ci(this)};ro.prototype.a=E("mr.CloudProvider");var so=new wi("pseudo:cloud","","hangout","Add a hangout","default");d=ro.prototype;d.getName=function(){return"cloud"};
d.Ld=function(){var a=this;H(this.a,"Initializing Cloud MRP");var b=eo.N(),c=b.OU(this);this.hp.push(c);this.Pk=b.TV(this);this.hp.push(this.Pk);this.Lf=b.nF();this.Sb=b.Bk();this.jl=b.LW(this);this.ze=b.bY();this.ze.LU().then(function(b){a.Dg=b;H(a.a,"Cloud enabled setting: "+a.Dg)});this.ze.NU().then(function(b){a.Sh=b;H(a.a,"Cloud on setting: "+a.Sh)});this.ze.t9(function(b){a.Dg=b;H(a.a,"Cloud enabled setting: "+a.Dg);a.Dg&&a.eH()});this.ze.dX().then(function(b){a.pl=b;H(a.a,"Privacy notified setting: "+
a.pl)})};d.Rf=function(){return this.bb.C()};
d.ln=function(a){var b=this;if(!this.Gx(a))return Kk;I(this.a,"GetAvailableSinks for "+a);var c=[];if(this.Sh||this.faa())c=this.eH();this.im.clear();this.jp.C().forEach(function(a){var e=!1;c.forEach(function(b){b.Za.id==a.Za.id&&(e=!0,b.Za.friendlyName=a.Za.friendlyName)});e||b.im.set(a.Za.id,a)});c=c.concat(this.im.C());I(this.a,"Available sinks are..."+JSON.stringify(c));var e=c.map(function(a){return a.Za});this.Pk&&(e=e.concat(so));return new Jk(e,-1!=a.indexOf("0F5096E8")?Qg:null)};
d.eH=function(){var a=[];H(this.a,"Checking cloud discovery services");Mi.N().fs=w();this.hp.forEach(function(b){b=b.Kc();a=a.concat(b)});return a};d.vj=function(){};d.yj=function(){};d.uj=function(){};d.xj=function(){};d.W=function(a){return(a=this.nn(a))?a.Za:null};
d.Ne=function(a,b,c,e,f,g,k){var p=this;H(this.a,"createRoute called");I(this.a,"urn: "+a+" sinkId:"+b);if(f=this.lt.get(b))return this.w.ju(this,f,a,k,function(b){b.mediaSource=a;b.pe.tabId=k;return sg(b)}).zv(function(a){p.w.lh(p,a);return a});f=this.nn(b);return this.Nq(a,f,b,c,e,g,k)};
d.yD=function(a,b,c,e){a instanceof Ik&&2==a.errorCode?this.Bj(b,6,null):(F(this.a,"Error on start session",a instanceof Error?a:Error("Expected an Error value, got "+a)),this.Bj(b,e,new qg(Ln,"warning","dismiss")));this.Pk&&this.Pk.r5(c)&&this.se([c.Za])};
d.Nq=function(a,b,c,e,f,g,k){var p=this;if(f)return tg(Error("not supported"));f=!1;switch(this.bx(b)){case "cloud":fn(1);break;case "mesi":f=!0,this.pl||(this.pl=!0,this.ze.s9(),g=new qg(On,"notification","learn_more"),g.k$(["dismiss"]),g.w8(6320939),this.w.Nf().send(g)),fn(0)}Mi.N().Yi=new Li(b.model,null);var q=Ok(e,this.getName(),c,a,!0,"",null);f&&(q.customControllerPath="cloud_route_details/view.html?routeId="+q.id);this.bb.set(q.id,q);this.lt.set(c,q);this.jp.set(q.id,b);this.w.rl(this,q);
this.w.yh(this.ka(),!0);if(Pg(a)&&!f)return H(this.a,"starting presentation on route: "+q.id),this.Gaa(q,a).catch(function(a){p.yD(a,q,b,7);throw a;});H(this.a,"starting mirroring on route: "+q.id);q.pe={tabId:k,sessionId:"",FM:"",GM:b.model};return this.w.np(this,q).catch(function(a){p.yD(a,q,b,5);throw a;})};d.Zc=function(a){var b=this.bb.get(a);return b?this.Bj(b,0,null):Promise.reject(new Ik(3,"Route in cloud provider not found for routeId "+a))};
d.Bj=function(a,b,c){H(this.a,"terminating route: "+a.id);this.bb.remove(a.id);this.lt.delete(a.sinkId);var e=this.jp.get(a.id);this.jp.remove(a.id);c&&this.Nf().send(c);Fg("MediaRouter.Cloud.Session.End",b,an);switch(b){case 1:break;default:this.FR(e)}this.w.Pi(this,a);this.bb.Tb()&&this.w.yh(this.ka(),!1);this.w.onPresentationConnectionStateChanged(a.id,"terminated");this.im.xa(a.sinkId)&&(b=this.im.get(a.sinkId),this.se([b.Za]),this.im.remove(a.sinkId));return Promise.resolve()};
d.Ch=function(a,b,c){if(c&&c.channelType){c=c.channelType;var e=(a=this.bb.get(a)||void 0)?this.nn(a.sinkId):void 0;return this.jl.j4(c,b,a,e)}return t(b)?(this.pd(b,a),Promise.resolve()):Promise.reject(Error("Channel type missing"))};d.Pf=function(){return Eh(!0,!0)};d.xn=function(a){var b=null;a=this.nn(a);switch(this.bx(a)){case "cloud":b="webrtc";break;case "mesi":b="hangouts"}H(this.a,"mirror service: "+b);return b};
d.Gm=function(a,b){I(this.a,"Checking canRoute: "+a+" for sinkId: "+b);return this.Gx(a)&&!!this.W(b)};d.Sj=function(a){return"chrome://media-router/cloudmrp-mirroring"==a};d.Ai=function(a,b){return(a=this.bb.get(b))?sg(a):tg(Error("not supported"))};d.Th=function(){return tg(Error("not supported"))};d.Ig=function(){};
d.Oy=function(a){H(this.a,a.length+" sinks added");0<a.length&&!this.Sh&&(this.ze.vba(),this.Sh=!0);a=this.nn(a[0].id);Mi.N().Xi=new Li(a.model,null);this.w.Oc();this.w.onSinkAvailabilityUpdated(this,2);H(this.a,"sinkAvailability changed to AVAILABLE")};d.se=function(a){H(this.a,a.length+" sinks removed");this.hp.some(function(a){return 0<a.Kc().length})||(this.w.onSinkAvailabilityUpdated(this,0),H(this.a,"sinkAvailability changed to UNAVAILABLE"));this.w.Oc()};
d.Oc=function(a){H(this.a,a.length+" sinks updated");this.w.Oc()};d.Nf=function(){return this.w.Nf()};d.pd=function(a,b,c){c?this.w.re(this,b,a):this.w.Es(this,b,a)};d.nn=function(a){var b=this.lV(a);b||(b=this.WX(a));return b};d.lV=function(a){var b=null;this.hp.some(function(c){b=c.W(a);return!!b});return b};d.WX=function(a){var b=null;(a=this.lt.get(a))&&(b=this.jp.get(a.id));return b};d.FR=function(a){switch(this.bx(a)){case "cloud":this.Lf.N6(a.deviceId)}};
d.bx=function(a){return a.VM("cloud")?"cloud":a.VM("mesi")?"mesi":null};d.faa=function(){var a=Mi.N().fs;return 3E5<=w()-a};d.Gx=function(a){var b=Og(a);a=Pg(a);if(this.Sb.Yk&&!this.Sb.jf&&b)return this.w.onSinkAvailabilityUpdated(this,2),!0;var c=!1;this.Dg&&this.Sb.jf&&(c=!0);return chrome.declarativeWebRequest||this.Sb.I_()||!a?c&&(b||a):!1};d.fg=function(a,b){if(!this.Gx(a))return null;(a=this.Pk.NP(b))&&this.Oy([a]);return a};d.ka=function(){return"CloudProvider"};
d.getData=function(){return[void 0,{cloudEnabled:this.Dg,cloudOn:this.Sh,notifiedHangoutsPrivacy:this.pl}]};d.fb=function(){var a=Ai(this);a&&(a.cloudEnabled&&(this.Dg=a.cloudEnabled),a.cloudOn&&(this.Sh=a.cloudOn),a.notifiedHangoutsPrivacy&&(this.pl=a.notifiedHangoutsPrivacy))};d.Gaa=function(a,b){a=new po(a,b);return ug(a.start())};var to=function(a){this.zo=a;this.a=E("mr.ExternalMessageHandler")},uo=["idmofbkcelhplfjnmmdolenpigiiiecc","ggedfkijiiammpnbdadhllnehapomdge","njjegkblellcjnakomndbaloifhcoccg"],vo=0;to.prototype.zz=function(){chrome.runtime.onMessageExternal.addListener(this.al.bind(this))};
to.prototype.al=function(a,b,c){if(!b.id||-1==uo.indexOf(b.id))return!1;H(this.a,"Received a message from "+b.id+" type: "+a.type);var e=chrome.runtime.id;if("start"==a.type)a=a.message,a=this.zo.fg("pseudo:cloud","urn:x-org.chromium.media:source:desktop",new on(a.meetingName,a.domain)),b="PresentationId"+b.id+vo++,this.zo.Ne("urn:x-org.chromium.media:source:desktop",a,b).then(function(a){c(new Cf(e,"route",a.id))}).catch(function(a){c(new Cf(e,"error",a))});else if("stop"==a.type)this.zo.Zc(a.message.routeId).then(function(){c(new Cf(e,
"stopped"))});else return!1;return!0};var wo=function(){this.GJ=v(this.MP,this);this.ge=new fi;this.ge.HA=!1;this.ge.Lt=!1;this.mH=this.ge.lC=!1;this.GT={}};wo.prototype.y7=function(a){if(a!=this.mH){var b=Jd();a?b.XB(this.GJ):b.q5(this.GJ);this.mH=a}};wo.prototype.MP=function(a){if(!this.GT[a.$H]){var b=this.ge.tw(a),c=xo;if(c)switch(a.Di){case yd:yo(c,"info",b);break;case zd:yo(c,"error",b);break;case Ad:yo(c,"warn",b);break;default:yo(c,"debug",b)}}};var xo=h.console,yo=function(a,b,c){if(a[b])a[b](c);else a.log(c)};var zo=function(){this.uf=new am(1E3);this.ge=new fi};qa(zo);d=zo.prototype;d.init=function(){var a=this.ZU();Kd("mr").Nl(a);Kd("goog").Nl(Bd);od(Ld(Kd("browser")));Jd().XB(v(this.V1,this));this.ge.IA=!0;this.ge.Lt=!0;if(a=window.localStorage["debug.logs"]){var b={all:Fd,fine:Dd,info:Bd,warning:Ad,severe:zd,off:xd};Kd("mr").Nl(b[a.toLowerCase()]||Dd)}window.localStorage["debug.console"]&&(a=new wo,a.ge.IA=!0,a.ge.Lt=!0,a.ge.HA=!0,a.y7(!0))};
d.V1=function(a){this.uf.enqueue(this.ge.tw(a));(a=a.Tq)&&a.stack&&this.uf.enqueue(a.stack)};d.getLogs=function(){return 0==this.uf.R()?"NA":this.uf.C().join("")};d.ZU=function(){return Bd};d.a5=function(){Ci(this)};d.ka=function(){return"LogManager"};d.getData=function(){return[this.uf.C()]};d.fb=function(){var a=this.uf.C();this.uf.clear();for(var b=ja(zi(this)||[]),c=b.next();!c.done;c=b.next())this.uf.enqueue(c.value);a=ja(a);for(c=a.next();!c.done;c=a.next())this.uf.enqueue(c.value)};var Ao=function(a){this.zo=a};Ao.prototype.zz=function(){chrome.runtime.onMessage.addListener(this.U1.bind(this))};
Ao.prototype.U1=function(a,b,c){if(b.id!=chrome.runtime.id||b.url!="chrome-extension://"+b.id+"/feedback.html")return!1;if("retrieve_log_data"==a.type){var e={logs:zo.N().getLogs(),device:Mi.N().yX()};b=Bf(e.device.ip).then(function(a){a&&(e.device.version=a)});var f=this.zo.PW("cast_streaming").then(function(b){return b.QW(a.source)}).then(function(a){e.castStreamingLogs=a});Fl([b,f]).then(function(){c(e)});return!0}return!1};var Bo,Co=E("mr.Init"),Do=function(a){var b=new Zk(a),c=new Wl(a,b),b=[b,c];b.push(new ro(a));return b};zo.N().init();Bo=new zg("MediaRouter.Provider.WakeDuration");
var Eo=new mo,Fo=(new Promise(function(a,b){switch(window.location.host){case "enhhojjnijigcajfphajepfemndkmdlo":a();break;case "pkedcjkdefgpdelpbcmbmeomcjbeemfm":chrome.management.get("enhhojjnijigcajfphajepfemndkmdlo",function(c){chrome.runtime.lastError||!c.enabled?a():b(Error("Dev extension is enabled"))});break;default:b(Error("Unknown extension id"))}})).then(function(){return chrome.mojoPrivate&&chrome.mojoPrivate.requireAsync?new Promise(function(a){chrome.mojoPrivate.requireAsync("media_router_bindings").then(function(b){b.start().then(function(c){a({mrService:b,mrInstanceId:c})})})}):
Promise.reject(Error("No mojo service loaded"))}).then(function(a){if(!a.mrService)throw Error("Failed to get MR service");var b=a.mrInstanceId;if(!b)throw Error("Failed to get MR instance ID.");H(Co,"MR instance ID: "+b);a=a.mrService;if(!Eo)throw Error("providerManager not initialized.");a.setHandlers(Eo);Ei(b)&&Bo.Ol("MediaRouter.Provider.FirstWakeDuration");chrome.runtime.onSuspend.addListener(Bo.end.bind(Bo));Ii(b);zo.N().a5();b=Do(Eo);window.addEventListener("unhandledrejection",function(a){a=
a.reason;a.stack||(a=Error(a));F(Co,"Unhandled promise rejection.",a)});Eo.Ld(a,b)}).then(void 0,function(a){G(Co,a.message);throw a;});(function(a){[].concat([new Ao(a),new to(a)],ka([].concat(ka(Ql()),ka([ij(),kj()])))).forEach(function(a){return a.zz()});a=eo.N().VE();chrome.gcm.onMessage.addListener(a.onMessage.bind(a))})(Eo);Fo.then(void 0,function(){return window.close()});
