text: 'use strict';var vf;var wf=chrome.i18n.getMessage("545449835455981095");v("mr.IssueSeverity",{zt:"fatal",qy:"warning",Cv:"notification"});v("mr.IssueAction",{mt:"dismiss",Ku:"learn_more"});
  var xf=function(a,b){this.sinkId=this.routeId=null;this.severity=b;this.isBlocking="fatal"==this.severity?!0:!1;this.title=a;this.message=null;this.defaultAction="dismiss";this.helpPageId=this.secondaryActions=null},zf=function(){var a=new xf(yf,"notification");a.helpPageId=6320939;a.defaultAction="learn_more";a.secondaryActions=["dismiss"];return a},Af=function(a){a.isBlocking=!0;return a},Bf=function(a,b){a.routeId=b;return a},Cf=function(a,b){a.sinkId=b;return a};var Df=function(a,b){var c=this;this.f=void 0===b?null:b;this.b=new Promise(function(b,e){var d=function(a){c.f=null;e(a)};c.g=d;a(function(a){c.f=null;b(a)},d)})};Df.prototype.cancel=function(a){this.g(a);if(this.f){var b=this.f;this.f=null;setTimeout(function(){return b(a)},0)}};var Ef=function(a,b,c){c=void 0===c?null:c;return new Df(function(d,e){a.b.then(function(a){if(b)try{d(b(a))}catch(h){e(h)}else d(a)},function(a){if(c)try{d(c(a))}catch(h){e(h)}else e(a)})},function(b){a.cancel(b)})};
  Df.prototype.then=function(a,b){return Ef(this,a,void 0===b?null:b)};Df.prototype.catch=function(a){return Ef(this,null,a)};var Ff=function(a){return new Df(function(b){b(a)})},Gf=function(a){return new Df(function(b,c){c(a)})},Hf=function(a){return new Df(function(b,c){a.then(b,c)})},If=function(a,b){var c=!1,d=null;return new Df(function(e,f){a.then(function(a){c||(d=b(a),d.b.then(e,f))},f)},function(a){d?d.cancel(a):c=!0})};var Jf={ys:0,ws:1,As:2,xs:3,Xr:4,zs:5,fu:6,Ox:7,ht:8,Zn:9},Kf=function(a,b){a=Error.call(this,a);this.message=a.message;"stack"in a&&(this.stack=a.stack);this.reason=0<=b&&9>=b?b:9};n(Kf,Error);var Lf=function(){var a=k(navigator.userAgent.match(/Windows NT (\d+.\d+)/)||[]);a.next();a=a.next().value;return 6.2<=parseFloat(a)},Mf=function(){var a=navigator.userAgent;return a.includes("CrOS")?"ChromeOS":a.includes("Windows")?"Windows":a.includes("Macintosh")?"Mac":a.includes("Linux")?"Linux":"Other"};var Nf=!("undefined"==typeof chrome||!chrome.networkingPrivate||!chrome.networkingPrivate.setWifiTDLSEnabledState||"ChromeOS"!=Mf()),Of=["ChromeOS","Windows"].includes(Mf());var Pf=function(a,b,c,d){this.f=a;this.b=b;this.g=c||null;this.presentationId=d||null},Sf=function(a,b){if("tab"==a.f)a=Qf(a);else if("offscreen_tab"==a.f)b=Qf(a),b.presentationId=a.presentationId,a=b;else{var c={audio:!1,video:!1};a.b.shouldCaptureVideo?(c.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:b}},Rf(a,c.video.mandatory),Of&&a.b.shouldCaptureAudio&&(c.audio={mandatory:{chromeMediaSource:"system",chromeMediaSourceId:b}})):a.b.shouldCaptureAudio&&(c.audio={mandatory:{chromeMediaSource:"system"}});
  a=c}return a},Qf=function(a){var b={audio:a.b.shouldCaptureAudio,video:a.b.shouldCaptureVideo};a.b.shouldCaptureVideo&&(b.videoConstraints={mandatory:{enableAutoThrottling:!0}},Rf(a,b.videoConstraints.mandatory));return b},Rf=function(a,b){var c=a.b.minWidth,d=a.b.minHeight;if(a.b.senderSideLetterboxing){c=a.b;if(0==c.minHeight||0==c.maxHeight?0:Math.floor(100*c.minWidth/c.minHeight)==Math.floor(100*c.maxWidth/c.maxHeight))c={width:c.minWidth,height:c.minHeight};else{d=c.maxWidth;for(var e=c.maxHeight;0!=
  e;){var f=d%e;d=e;e=f}e=c.maxWidth/d;d=c.maxHeight/d;if(e<c.minWidth||d<c.minHeight)if(f=Math.max(c.minWidth/e,c.minHeight/d),e*=f,d*=f,e>c.maxWidth||d>c.maxHeight)e=c.maxWidth,d=c.maxHeight;e=Math.round(e);d=Math.round(d);c={width:e,height:d}}d=c;c=d.width;d=d.height}Object.assign(b,{minWidth:c,minHeight:d,maxWidth:a.b.maxWidth,maxHeight:a.b.maxHeight,minFrameRate:a.b.minFrameRate,maxFrameRate:a.b.maxFrameRate})};var Tf=function(a){this.b=a;this.f=this.xf=null;this.m=db("mr.mirror.MirrorMediaStream")};Tf.prototype.start=function(){return"tab"==this.b.f?Uf(this):"offscreen_tab"==this.b.f?Vf(this):Wf(this)};var Uf=function(a){var b=Sf(a.b);a.m.info("Starting tab capture with constraints "+JSON.stringify(b));return new Promise(function(c,d){chrome.tabCapture.capture(b,function(b){b?(Xf(a,b),c(a)):d(Yf())});window.setTimeout(function(){d(new Kf("chrome.tabCapture.capture failed to call its callback",2))},5E3)})};
  Tf.prototype.g=function(a){a&&this.m.info(function(){return"Track "+JSON.stringify(a.target)+" ended"});this.stop()};
  var Yf=function(){return chrome.runtime.lastError&&chrome.runtime.lastError.message?new Kf(chrome.runtime.lastError.message,7):new Kf("empty_stream",0)},Zf=function(a){var b=void 0===b?6E4:b;return new Promise(function(c,d){var e=["screen","audio"];"Linux"==Mf()&&e.push("window");var f=window.setTimeout(function(){h&&chrome.desktopCapture.cancelChooseDesktopMedia(h);d(new Kf("timeout",1))},b);var h=chrome.desktopCapture.chooseDesktopMedia(e,a||null,function(a){window.clearTimeout(f);a?c(a):d(new Kf("User cancelled capture dialog",
  3))})})},$f=function(a,b){return new Promise(function(c,d){a.m.info(function(){return"Starting desktop capture with constraints "+JSON.stringify(b)});navigator.mediaDevices.getUserMedia(b).then(function(b){b||d(new Kf("empty_stream",8));Xf(a,b);c(b)},function(a){var b=8;"NotAllowedError"==a.name&&(b=3);d(new Kf(a.name+" "+a.constraintName+": "+a.message,b))})})},Wf=function(a){return Of&&a.b.b.shouldCaptureAudio&&!a.b.b.shouldCaptureVideo?$f(a,Sf(a.b)).then(function(){return a}):Zf().then(function(b){b=
  Sf(a.b,b);return $f(a,b).then(function(){return a})})},Vf=function(a){var b=Sf(a.b);a.m.info(function(){return"Starting offscreen tab capture with constraints "+JSON.stringify(b)});return new Promise(function(c,d){chrome.tabCapture.captureOffscreenTab(a.b.g.toString(),b,function(b){b?(Xf(a,b),c(a)):d(Yf())})})},Xf=function(a,b){a.f=b;b.getAudioTracks().length||b.getVideoTracks();b.getTracks().forEach(function(b){b.onended=a.g.bind(a)})};
  Tf.prototype.stop=function(){this.f&&(this.f.getTracks().forEach(function(a){a.onended=null;a.stop()}),this.f=null,this.xf&&this.xf())};var ag=function(){},eg=function(a){var b=bg.get(a)||null;if(b)return Promise.resolve(b);b=cg.get(a);b||(b=new zb,cg.set(a,b),dg(a,b));return b.b},dg=function(a,b){var c=fg.get(a)||null;if(!c)b.reject(Error("No corresponding bundle for "+a));else if(!gg.has(c)){var d=hg.get(c);d||(ig.info("Loading bundle "+c+" for module "+a),d=jg(c),hg.set(c,d));d.catch(function(a){b.reject(a)})}},jg=function(a){var b=new zb;b.b.then(function(){ig.info("Bundle "+a+" loaded")},function(b){ig.error("Failed to load bundle "+
  a);throw b;});var c=document.createElement("script");c.src=chrome.extension.getURL(a);c.setAttribute("type","text/javascript");c.async=!0;c.onload=function(){return b.resolve(void 0)};c.onerror=function(){return b.reject(Error("Failed to load bundle "+a))};document.head.appendChild(c);return b.b},kg=function(a,b){if(bg.has(a))throw Error("Duplicate module "+a);bg.set(a,b);(a=cg.get(a))&&a.resolve(b)};
  ag.prototype.handleEvent=function(a,b){for(var c=1;c<arguments.length;++c);throw Error("Not implemented");};
  var fg=new Map([["mr.cast.ChannelService","background_script.js"],["mr.cast.SinkDiscoveryService","background_script.js"],["mr.mirror.cast.Service","mirroring_cast_streaming.js"],["mr.cloud.slarti.SinkDiscoveryService","background_script.js"],["mr.cloud.discovery.WeaveSinkDiscoveryService","background_script.js"],["mr.mirror.hangouts.HangoutsService","mirroring_hangouts.js"],["mr.mirror.hangouts.MeetingsService","mirroring_hangouts.js"],["mr.ProviderManager","background_script.js"],["mr.mirror.webrtc.WebRtcService",
  "mirroring_webrtc.js"]]),gg=new Set(["background_script.js"]),ig=db("mr.Module"),bg=new Map,cg=new Map,hg=new Map;var lg,mg={Su:0,Bs:1,Cs:2,it:3,jt:4,Kt:5,gu:6,Qu:7,sv:8,tv:9,Aw:10,kx:11,lx:12,zx:13,Nx:14},og=function(a){void 0==lg&&(yb("MediaRouter.Provider.WakeEvent",a,mg),lg=a)};var sg=function(a){return qg(a)||rg(a)},tg=function(a){if(!a.startsWith("http:")&&!a.startsWith("https:"))return!1;var b=document.createElement("a");b.href=a;return"http:"!=b.protocol&&"https:"!=b.protocol?!1:-1==b.hash.indexOf("__castAppId__")},ug=["https://docs.google.com"],qg=function(a){return a.startsWith("urn:x-org.chromium.media:source:tab:")||-1!=a.indexOf("0F5096E8")},rg=function(a){return"urn:x-org.chromium.media:source:desktop"==a},vg=function(a){var b=a.search("urn:x-org.chromium.media:source:tab:");
  return-1==b?null:parseInt(a.substr(b+36),10)||null};var wg=function(a,b){this.Z=a;this.g=b||null;this.f=this.b=null;this.L=db("mr.mirror.Service."+a);this.M=this.Za.bind(this);this.C=!1};n(wg,ag);g=wg.prototype;g.Ya=function(a,b){this.C||(this.g=a,this.C=!0,this.Uf(b))};g.Uf=function(){};g.getName=function(){return this.Z};
  g.Ti=function(a,b,c,d,e){var f=this;this.L.info("Start mirroring on route "+a.id);if(!this.C)return Gf(Error("Not initialized"));var h=new Promise(function(h,t){f.l().then(function(){var a=xg(b,c,d);return(new Tf(a)).start()}).then(function(b){if(f.f)throw b.stop(),new Kf("Cannot start multiple streams");f.f=b;b=f.w.bind(f);f.f.xf=b;return e?e(a).b:a}).then(function(a){if(f.b)throw new Kf("Cannot start multiple sessions");if(!f.f)throw new Kf("Media stream ended before session could start.");f.b=
  f.Wg(c,a);a.ib.cc=f.b.cc;a=f.g.vi.bind(f.g);f.b.D=a;return f.b.start(f.f.f)}).then(function(){qg(b)&&!chrome.tabs.onUpdated.hasListener(f.M)&&chrome.tabs.onUpdated.addListener(f.M);return f.P(a,b,c)}).then(function(){h(a)}).catch(function(a){yg(f,a);return f.w().then(function(){t(a)})})});return Hf(h)};g.Ui=function(a,b,c,d,e,f){this.L.info("Update mirroring on route "+a.id);return this.C?Hf(zg(this,a,b,c,d,f)):Gf(Error("Not initialized"))};
  var zg=function(a,b,c,d,e,f){if(!a.b)return Promise.reject(new Kf("No session to update streams on",7));if(!a.b.pm())return Promise.reject(new Kf("Session does not support updating stream",7));var h=!1;return new Promise(function(l,t){var u=xg(c,d,e);(new Tf(u)).start().then(function(c){a.f&&(a.f.xf=null,a.f.stop(),a.vg());a.f=c;c=a.w.bind(a);a.f.xf=c;h=!0;return f?f(b).b:b}).then(function(){if(!a.b)throw new Kf("Session ended while updating stream");if(!a.f)throw new Kf("Media stream ended before session could be updated.");
  return a.b.wm(a.f.f)}).then(a.P.bind(a,b,c,d)).then(function(){return l(b)}).catch(function(b){yg(a,b);if(h)return a.w().then(function(){t(b)});t(b)})})};
  wg.prototype.P=function(a,b,c){var d=this;return new Promise(function(e,f){if(d.b){qg(b)?(Ag(d.b,a.ib.tabId),d.wg()):tg(b)?(Ag(d.b,a.ib.tabId),d.Ch()):d.tg();f=d.f;var h=a.sinkId;c.shouldCaptureAudio&&f.f&&!f.f.getAudioTracks().length&&d.g.ze(Cf(new xf(wf,"notification"),h));Bg(d.b);e()}else f(new Kf("Session gone before executing post-startup steps",7))})};
  var yg=function(a,b){b.reason=null!=b.reason?b.reason:9;a.L.error("Failed to start mirroring: "+b.message+(",  reason = "+b.reason+": "+b.stack));a.Bh(b.reason)};wg.prototype.l=function(){var a=this;return this.C?this.w().then(function(b){b&&a.ug();return b}):Promise.reject("Not initialized")};
  wg.prototype.w=function(){var a=this;chrome.tabs.onUpdated.removeListener(this.M);var b=this.f;this.f=null;b&&(b.xf=null);var c=this.b;this.b=null;var d;c?d=this.bi(c).catch(function(b){return a.L.error("Error in before-cleanup steps",b)}).then(function(){return c.stop()}).catch(function(b){return a.L.error("Error stopping session",b)}).then(function(){a.g.Wi(c.g.id)}).catch(function(b){return a.L.error("Error in ended callbacks",b)}).then(function(){return!0}):d=Promise.resolve(!1);b&&(d=d.then(function(c){b.stop();
  a.vg();return c}));return d};wg.prototype.bi=function(){return Promise.resolve()};wg.prototype.Za=function(a,b,c){og(14);this.b&&Cg(this.b,a,b,c)};var xg=function(a,b,c){if(qg(a))return new Pf("tab",b);if(rg(a))return new Pf("desktop",b);if(tg(a)){if(!c)throw new Kf("Missing offscreen tab presentation id");return new Pf("offscreen_tab",b,a,c)}throw new Kf("Source URN does not suggest a known capture type.");};g=wg.prototype;g.Wg=function(){};g.wg=function(){};g.tg=function(){};g.Ch=function(){};
  g.ug=function(){};g.Bh=function(){};g.vg=function(){};g.Si=function(){return ab()};g.createMediaRouteController=function(){return ab()};var Dg=function(a,b,c){this.f=a;this.h=b;this.b=void 0===c?null:c;this.g=null},Eg=function(a){switch(a.f){case "mirror_tab":return a.b?"Casting tab ("+a.b+")":"Casting tab";case "mirror_desktop":return"Casting desktop";case "mirror_file":return"Casting local content";case "media_remoting":return a.b?"Casting media ("+a.b+")":"Casting media";case "presentation":return"Casting "+(a.b||"site");default:return""}},Fg=function(a){if(a.h)return"Casting active";switch(a.f){case "mirror_tab":return"Casting tab";
  case "mirror_desktop":return"Casting desktop";case "mirror_file":return"Casting local content";case "media_remoting":return"Casting media";case "presentation":return"Casting site";default:return""}};var Gg=function(a){return(new Promise(function(b){chrome.tabs.get(a,b)})).then(function(b){if(!b)throw Error("No such tab "+a);return b})};var Hg=function(a,b){this.g=a;this.D=void 0===b?null:b;b=null;var c=a.mediaSource;if(tg(c)){var d="presentation";b=(new URL(c)).origin}else qg(c)?d="mirror_tab":rg(c)&&(d="mirror_desktop");this.cc=new Dg(d,a.offTheRecord,b);this.C=this.tabId=null;this.H=!1},Ag=function(a,b){a.tabId!=b?(a.tabId=b,Gg(b).then(function(b){a.C=b;Bg(a)})):Promise.resolve()},Cg=function(a,b,c,d){b==a.tabId&&("complete"==c.status||c.favIconUrl&&"complete"==d.status)&&(a.C=d,Bg(a))},Bg=function(a){if(a.C){a.cc.g=a.C.title;
  a.cc.h=a.C.incognito;var b=new URL(a.C.url);"file:"==b.protocol?(a.cc.f="mirror_file",a.cc.b=null):(a.cc.f=a.H?"media_remoting":"mirror_tab",a.cc.b="https:"==b.protocol?b.origin.substr(8):b.origin)}a.g.description=Eg(a.cc);a.D&&a.D(a.g,a.cc);a.Ul()};g=Hg.prototype;g.start=function(){};g.pm=function(){return!1};g.wm=function(){};g.stop=function(){return Promise.resolve()};g.Ul=function(){};var Lg=function(){var a=this;this.maxWidth=1920;this.maxHeight=1080;this.minHeight=this.minWidth=180;this.senderSideLetterboxing=!1;this.minFrameRate=0;this.maxFrameRate=30;this.minVideoBitrate=300;this.maxVideoBitrate=5E3;this.audioBitrate=0;this.maxLatencyMillis=800;this.animatedLatencyMillis=this.minLatencyMillis=400;this.dscpEnabled=["Mac","Linux","ChromeOS"].includes(Mf())||Lf();this.enableLogging=!0;this.useTdls=!1;this.shouldCaptureAudio=this.shouldCaptureVideo=!0;var b=window.localStorage?
  window.localStorage.getItem(Ig):null;if(b)try{var c=JSON.parse(String(b));if(c instanceof Object)Jg(this,c),db("mr.mirror.Settings").F(function(){return"Initial mr.mirror.Settings overridden to: "+Kg(a)});else throw Error("localStorage["+Ig+"] "+("does not parse as an Object: "+b));}catch(d){throw db("mr.mirror.Settings").error(Ig+' must be of the form \'{"maxWidth":640, "maxHeight":360}\'.',d),Error("Overrides not parseable.  See ERROR log for details.");}};
  Lg.prototype.clone=function(){var a=new Lg;Jg(a,this);return a};
  var Kg=function(a){return JSON.stringify(a,function(a,c){if(0==a.length||!a.endsWith("_"))return c})},Jg=function(a,b){for(var c=k(Object.keys(b)),d=c.next();!d.done;d=c.next())d=d.value,d.endsWith("_")||typeof b[d]!==typeof a[d]||(a[d]=b[d])},Mg=function(a){var b=screen.width,c=screen.height;a.maxHeight*b<a.maxWidth*c?(b=Math.min(a.maxWidth,b),b-=b%160,c=90*b/160):(c=Math.min(a.maxHeight,c),c-=c%90,b=160*c/90);if(b<Math.max(160,a.minWidth)||c<Math.max(90,a.minHeight))b=Math.max(160,a.minWidth),c=
  Math.max(90,a.minHeight);a.maxWidth=b;a.maxHeight=c},Ig="mr.mirror.Settings.Overrides";var Ng=function(a,b){this.type=a;this.data=b},Og=function(a){a=JSON.parse(a);if(!a.type)throw Error("Invalid message");return new Ng(a.type,a.data)},Pg=function(a,b,c,d,e){this.description=a;this.settings=b||null;this.mediaConstraints=c||null;this.presentationUrl=d||null;this.presentationId=e||null};var Sg=function(a,b){this.m=db("cv2.PeerConnection");this.H=Qg;this.b=Rg(this,b);this.j=this.b.createDataChannel(a,{reliable:!1});this.D=new zb;this.s=!1;this.h=0;this.g=null;this.C=this.l=0;this.f=!1;this.B=function(){};this.o=function(){};this.w=function(){};this.A=function(){}},Tg=function(a,b){a.o=b},Ug=function(a,b){a.w=b},Vg=function(a,b){a.A=b},Wg=function(a,b){a.B=b},Xg=function(a,b){a.j.onmessage=function(a){b(a.data)}},Yg=function(a){var b={};b.iceServers=[{url:"stun:stun.l.google.com:19302"}].concat(a);
  return b},Rg=function(a,b){var c=Yg(b);b=new webkitRTCPeerConnection(c);b.onicecandidate=a.W.bind(a);b.b=a.N.bind(a);b.oniceconnectionstatechange=a.M.bind(a);a.m.info(function(){return"Created webkitRTCPeerConnnection with config: "+JSON.stringify(c)});return b};Sg.prototype.start=function(){this.f||(this.f=!0,Zg(this))};Sg.prototype.stop=function(){this.m.info("Stopping peer connection...");this.f&&(this.f=!1,"closed"!=this.b.signalingState&&this.b.close());this.b=null};
  var Zg=function(a){a.m.info("Sending offer to peer.");a.l=Date.now();a.b.createOffer(a.G.bind(a),function(b){a.m.F("Error creating offer.",b)},a.H);a.D.b.then(function(b){a.B(b)})};Sg.prototype.G=function(a){var b=this;this.m.info(function(){return"Setting local description: "+JSON.stringify(a)});this.b.setLocalDescription(a,function(){b.m.info("Local description set successfully")},function(a){b.m.F("Error setting local description.",a)})};
  var $g=function(a,b){kb(a.m,function(){return"<===: "+JSON.stringify(b)});var c=new RTCSessionDescription(b);a.m.info(function(){return"Setting remote description: "+JSON.stringify(c)});a.b.setRemoteDescription(c,function(){a.m.info("Remote description set successfully.")},function(b){a.m.F("Error setting remote description.",b)})};
  Sg.prototype.W=function(a){var b=this;a.candidate?(this.h++,this.C=Date.now(),1==this.h?this.g=setTimeout(function(){b.m.info("ICE candidate gathering timed out.");b.g=null;ah(b)},5E3):this.s&&this.m.F("Received ICE candidate after resolving session description.")):(this.m.info("End of ICE candidates."),qb("MediaRouter.WebRtc.IceCandidateGathering.Duration.Reported",Date.now()-this.l),ah(this),0<this.h&&qb("MediaRouter.WebRtc.IceCandidateGathering.Duration.Real",this.C-this.l))};
  Sg.prototype.N=function(){"completed"==this.b.iceGatheringState&&ah(this)};var ah=function(a){clearTimeout(a.g);a.g=null;if(!a.s){a.m.info("Resolving sesion description after gathering "+a.h+" ICE candidates.");var b=a.b.localDescription;a.D.resolve({type:b.type,sdp:b.sdp});a.s=!0}};
  Sg.prototype.M=function(a){var b=this;if(this.b){var c=this.b.iceConnectionState;this.m.info("New ICE connection state: "+c+".");"connected"==c?this.o("iceconnected"):"completed"==c?this.o("icecompleted"):"failed"==c?(this.m.F(function(){return"Ice connection failed: "+JSON.stringify(a)}),this.w("icefailed")):"closed"==c?this.A("iceclosed"):"disconnected"==c&&(this.m.F("Ice connection state is bad."),this.f&&(this.m.info("Restarting ICE."),this.b.createOffer(this.G.bind(this),function(a){b.m.F("Error creating new offer.",
  a)},bh)))}};var Qg={mandatory:{OfferToReceiveAudio:!0,OfferToReceiveVideo:!0}},bh={mandatory:{IceRestart:!0,OfferToReceiveAudio:!0,OfferToReceiveVideo:!0}};var ch=function(){var a=window.crypto.getRandomValues(new Uint8Array(16));return Jb(a,function(a){a=a.toString(16);return 1<a.length?a:"0"+a}).join("")},dh=function(a){for(var b=[],c=0,d=0;d<a.length;d++){var e=a.charCodeAt(d);128>e?b[c++]=e:(2048>e?b[c++]=e>>6|192:(55296==(e&64512)&&d+1<a.length&&56320==(a.charCodeAt(d+1)&64512)?(e=65536+((e&1023)<<10)+(a.charCodeAt(++d)&1023),b[c++]=e>>18|240,b[c++]=e>>12&63|128):b[c++]=e>>12|224,b[c++]=e>>6&63|128),b[c++]=e&63|128)}return b},eh=function(a){for(var b=
  [],c=0,d=0;c<a.length;){var e=a[c++];if(128>e)b[d++]=String.fromCharCode(e);else if(191<e&&224>e){var f=a[c++];b[d++]=String.fromCharCode((e&31)<<6|f&63)}else if(239<e&&365>e){f=a[c++];var h=a[c++],l=a[c++];e=((e&7)<<18|(f&63)<<12|(h&63)<<6|l&63)-65536;b[d++]=String.fromCharCode(55296+(e>>10));b[d++]=String.fromCharCode(56320+(e&1023))}else f=a[c++],h=a[c++],b[d++]=String.fromCharCode((e&15)<<12|(f&63)<<6|h&63)}return b.join("")};var fh=Hc("Firefox"),gh=Zc()||Hc("iPod"),hh=Hc("iPad"),ih=Hc("Android")&&!(Yc()||Hc("Firefox")||Hc("Opera")||Hc("Silk")),jh=Yc(),kh=Hc("Safari")&&!(Yc()||Hc("Coast")||Hc("Opera")||Hc("Edge")||Hc("Silk")||Hc("Android"))&&!$c();var lh=null,mh=null,oh=function(a){nh();for(var b=lh,c=[],d=0;d<a.length;d+=3){var e=a[d],f=d+1<a.length,h=f?a[d+1]:0,l=d+2<a.length,t=l?a[d+2]:0,u=e>>2;e=(e&3)<<4|h>>4;h=(h&15)<<2|t>>6;t&=63;l||(t=64,f||(h=64));c.push(b[u],b[e],b[h],b[t])}return c.join("")},qh=function(a){var b=a.length,c=0;"="===a[b-2]?c=2:"="===a[b-1]&&(c=1);var d=new Uint8Array(Math.ceil(3*b/4)-c),e=0;ph(a,function(a){d[e++]=a});return d.subarray(0,e)},ph=function(a,b){function c(b){for(;d<a.length;){var c=a.charAt(d++),e=mh[c];
  if(null!=e)return e;if(!nc(c))throw Error("Unknown base64 encoding at char: "+c);}return b}nh();for(var d=0;;){var e=c(-1),f=c(0),h=c(64),l=c(64);if(64===l&&-1===e)break;b(e<<2|f>>4);64!=h&&(b(f<<4&240|h>>2),64!=l&&b(h<<6&192|l))}},nh=function(){if(!lh){lh={};mh={};for(var a=0;65>a;a++)lh[a]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(a),mh[lh[a]]=a,62<=a&&(mh["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.".charAt(a)]=a)}};var rh=0,sh=0,th=function(a){var b=0>a;a=Math.abs(a);var c=a>>>0;a=Math.floor((a-c)/4294967296);a>>>=0;b&&(a=~a>>>0,c=(~c>>>0)+1,4294967295<c&&(c=0,a++,4294967295<a&&(a=0)));rh=c;sh=a},uh=function(a){if(a.constructor===Uint8Array)return a;if(a.constructor===ArrayBuffer)return new Uint8Array(a);if(a.constructor===Array)return new Uint8Array(a);if(a.constructor===String)return qh(a);Db("Type not convertible to Uint8Array.");return new Uint8Array(0)};var wh=function(a,b,c){this.g=null;this.s=this.C=this.b=this.h=this.j=0;this.l=!1;a&&vh(this,a,b,c)},xh=[],yh=function(a,b,c){if(xh.length){var d=xh.pop();a&&vh(d,a,b,c);return d}return new wh(a,b,c)};wh.prototype.clone=function(){return yh(this.g,this.j,this.h-this.j)};wh.prototype.clear=function(){this.g=null;this.b=this.h=this.j=0;this.l=!1};var vh=function(a,b,c,d){a.g=uh(b);a.j=Ha(c)?c:0;a.h=Ha(d)?a.j+d:a.g.length;a.b=a.j};wh.prototype.reset=function(){this.b=this.j};
  wh.prototype.f=function(){var a=this.g;var b=a[this.b+0];var c=b&127;if(128>b)return this.b+=1,c;b=a[this.b+1];c|=(b&127)<<7;if(128>b)return this.b+=2,c;b=a[this.b+2];c|=(b&127)<<14;if(128>b)return this.b+=3,c;b=a[this.b+3];c|=(b&127)<<21;if(128>b)return this.b+=4,c;b=a[this.b+4];c|=(b&15)<<28;if(128>b)return this.b+=5,c>>>0;this.b+=5;128<=a[this.b++]&&128<=a[this.b++]&&128<=a[this.b++]&&128<=a[this.b++]&&this.b++;return c};wh.prototype.o=wh.prototype.f;wh.prototype.A=function(){return this.o()};var zh=function(a){this.b=yh(a,void 0,void 0);this.l=this.b.b;this.h=this.f=-1;this.j=!1},Ah=function(a){return 4==a.h};zh.prototype.reset=function(){this.b.reset();this.h=this.f=-1};
  var Bh=function(a){var b=a.b;if(b.b==b.h)return!1;(b=a.j)||(b=a.b,b=b.l||0>b.b||b.b>b.h);if(b)return Db("Decoder hit an error"),!1;a.l=a.b.b;var c=a.b.f();b=c>>>3;c&=7;if(0!=c&&5!=c&&1!=c&&2!=c&&3!=c&&4!=c)return Db("Invalid wire type: %s (at position %s)",c,a.l),a.j=!0,!1;a.f=b;a.h=c;return!0},Ch=function(a){switch(a.h){case 0:if(0!=a.h)Db("Invalid wire type for skipVarintField"),Ch(a);else{for(a=a.b;a.g[a.b]&128;)a.b++;a.b++}break;case 1:1!=a.h?(Db("Invalid wire type for skipFixed64Field"),Ch(a)):
  (a=a.b,a.b+=8);break;case 2:if(2!=a.h)Db("Invalid wire type for skipDelimitedField"),Ch(a);else{var b=a.b.f();a=a.b;a.b+=b}break;case 5:5!=a.h?(Db("Invalid wire type for skipFixed32Field"),Ch(a)):(a=a.b,a.b+=4);break;case 3:b=a.f;do{if(!Bh(a)){Db("Unmatched start-group tag: stream EOF");a.j=!0;break}if(4==a.h){a.f!=b&&(Db("Unmatched end-group tag"),a.j=!0);break}Ch(a)}while(1);break;default:Db("Invalid wire encoding for field.")}};
  zh.prototype.g=function(a,b){var c=this.b.h,d=this.b.f();d=this.b.b+d;this.b.h=d;b(a,this);this.b.b=d;this.b.h=c};
  var Dh=function(a){a=a.b;a:{for(var b,c=0,d,e=0;4>e;e++)if(b=a.g[a.b++],c|=(b&127)<<7*e,128>b){a.C=c>>>0;a.s=0;break a}b=a.g[a.b++];c|=(b&127)<<28;d=0|(b&127)>>4;if(128>b)a.C=c>>>0,a.s=d>>>0;else{for(e=0;5>e;e++)if(b=a.g[a.b++],d|=(b&127)<<7*e+3,128>b){a.C=c>>>0;a.s=d>>>0;break a}Db("Failed to read varint, encoding is invalid.");a.l=!0}}b=a.C;c=a.s;if(a=c&2147483648)b=~b+1>>>0,c=~c>>>0,0==b&&(c=c+1>>>0);b=4294967296*c+b;return a?-b:b},Eh=function(a){var b=a.b.f();a=a.b;var c=a.g,d=a.b,e=d+b,f=[];
  for(b="";d<e;){var h=c[d++];if(128>h)f.push(h);else if(192>h)continue;else if(224>h){var l=c[d++];f.push((h&31)<<6|l&63)}else if(240>h){l=c[d++];var t=c[d++];f.push((h&15)<<12|(l&63)<<6|t&63)}else if(248>h){l=c[d++];t=c[d++];var u=c[d++];h=(h&7)<<18|(l&63)<<12|(t&63)<<6|u&63;h-=65536;f.push((h>>10&1023)+55296,(h&1023)+56320)}8192<=f.length&&(b+=String.fromCharCode.apply(null,f),f.length=0)}if(8192>=f.length)f=String.fromCharCode.apply(null,f);else{c="";for(e=0;e<f.length;e+=8192)c+=String.fromCharCode.apply(null,
  cc(f,e,e+8192));f=c}a.b=d;return b+f},Fh=function(a,b){var c=a.b.f();c=a.b.b+c;for(var d=[];a.b.b<c;)d.push(b.call(a.b));return d};var Gh=function(a,b){this.b=a;this.f=b},Hh=function(a){return new Gh((a.b>>>1|(a.f&1)<<31)>>>0,a.f>>>1>>>0)},Ih=function(a){return new Gh(a.b<<1>>>0,(a.f<<1|a.b>>>31)>>>0)};Gh.prototype.add=function(a){return new Gh((this.b+a.b&4294967295)>>>0>>>0,((this.f+a.f&4294967295)>>>0)+(4294967296<=this.b+a.b?1:0)>>>0)};Gh.prototype.sub=function(a){return new Gh((this.b-a.b&4294967295)>>>0>>>0,((this.f-a.f&4294967295)>>>0)-(0>this.b-a.b?1:0)>>>0)};
  var Jh=function(a){var b=a&65535,c=a>>>16;a=10*b+65536*(0*b&65535)+65536*(10*c&65535);for(b=0*c+(0*b>>>16)+(10*c>>>16);4294967296<=a;)a-=4294967296,b+=1;return new Gh(a>>>0,b>>>0)};
  Gh.prototype.toString=function(){for(var a="",b=this;0!=b.b||0!=b.f;){var c=new Gh(0,0);b=new Gh(b.b,b.f);for(var d=new Gh(10,0),e=new Gh(1,0);!(d.f&2147483648);)d=Ih(d),e=Ih(e);for(;0!=e.b||0!=e.f;)0>=(d.f<b.f||d.f==b.f&&d.b<b.b?-1:d.f==b.f&&d.b==b.b?0:1)&&(c=c.add(e),b=b.sub(d)),d=Hh(d),e=Hh(e);c=[c,b];b=c[0];a=c[1].b+a}""==a&&(a="0");return a};
  var Kh=function(a){for(var b=new Gh(0,0),c=new Gh(0,0),d=0;d<a.length;d++){if("0">a[d]||"9"<a[d])return null;c.b=parseInt(a[d],10);var e=Jh(b.b);b=Jh(b.f);b.f=b.b;b.b=0;b=e.add(b).add(c)}return b};Gh.prototype.clone=function(){return new Gh(this.b,this.f)};var Lh=function(a,b){this.b=a;this.f=b};Lh.prototype.add=function(a){return new Lh((this.b+a.b&4294967295)>>>0>>>0,((this.f+a.f&4294967295)>>>0)+(4294967296<=this.b+a.b?1:0)>>>0)};
  Lh.prototype.sub=function(a){return new Lh((this.b-a.b&4294967295)>>>0>>>0,((this.f-a.f&4294967295)>>>0)-(0>this.b-a.b?1:0)>>>0)};Lh.prototype.clone=function(){return new Lh(this.b,this.f)};Lh.prototype.toString=function(){var a=0!=(this.f&2147483648),b=new Gh(this.b,this.f);a&&(b=(new Gh(0,0)).sub(b));return(a?"-":"")+b.toString()};var Mh=function(){this.b=[]};Mh.prototype.length=function(){return this.b.length};var Nh=function(a){var b=a.b;a.b=[];return b},Oh=function(a,b,c){for(;0<c||127<b;)a.b.push(b&127|128),b=(b>>>7|c<<25)>>>0,c>>>=7;a.b.push(b)},Ph=function(a,b){for(;127<b;)a.b.push(b&127|128),b>>>=7;a.b.push(b)},Qh=function(a,b){if(0<=b)Ph(a,b);else{for(var c=0;9>c;c++)a.b.push(b&127|128),b>>=7;a.b.push(1)}},Rh=function(a,b){a.b.push(b>>>0&255);a.b.push(b>>>8&255);a.b.push(b>>>16&255);a.b.push(b>>>24&255)};var z=function(){this.h=[];this.g=0;this.f=new Mh},Th=function(a,b){Sh(a,b,2);b=Nh(a.f);a.h.push(b);a.g+=b.length;b.push(a.g);return b},Uh=function(a,b){var c=b.pop();for(c=a.g+a.f.length()-c;127<c;)b.push(c&127|128),c>>>=7,a.g++;b.push(c);a.g++};z.prototype.reset=function(){this.h=[];Nh(this.f);this.g=0};
  var B=function(a){for(var b=new Uint8Array(a.g+a.f.length()),c=a.h,d=c.length,e=0,f=0;f<d;f++){var h=c[f];b.set(h,e);e+=h.length}c=Nh(a.f);b.set(c,e);a.h=[b];return b},Sh=function(a,b,c){Ph(a.f,8*b+c)},C=function(a,b,c){null!=c&&null!=c&&(Sh(a,b,0),Qh(a.f,c))},D=function(a,b,c){null!=c&&null!=c&&(Sh(a,b,0),a=a.f,th(c),Oh(a,rh,sh))},Vh=function(a,b,c){if(null!=c){var d=c;(c=0<d.length&&"-"==d[0])&&(d=d.substring(1));d=Kh(d);null===d?c=null:(c&&(d=(new Gh(0,0)).sub(d)),c=new Lh(d.b,d.f));Sh(a,b,0);
  Oh(a.f,c.b,c.f)}},Wh=function(a,b,c){null!=c&&null!=c&&(Sh(a,b,0),Ph(a.f,c))},Xh=function(a,b,c){null!=c&&null!=c&&(Sh(a,b,0),a=a.f,th(c),Oh(a,rh,sh))},Yh=function(a,b,c){null!=c&&(c=Kh(c),Sh(a,b,0),Oh(a.f,c.b,c.f))},Zh=function(a,b,c){null!=c&&(Sh(a,b,5),Rh(a.f,c))},$h=function(a,b,c){if(null!=c){Sh(a,b,5);a=a.f;var d=c;d=(c=0>d?1:0)?-d:d;0===d?0<1/d?rh=sh=0:(sh=0,rh=2147483648):isNaN(d)?(sh=0,rh=2147483647):3.4028234663852886E38<d?(sh=0,rh=(c<<31|2139095040)>>>0):1.1754943508222875E-38>d?(d=Math.round(d/
  Math.pow(2,-149)),sh=0,rh=(c<<31|d)>>>0):(b=Math.floor(Math.log(d)/Math.LN2),d*=Math.pow(2,-b),d=Math.round(8388608*d)&8388607,sh=0,rh=(c<<31|b+127<<23|d)>>>0);Rh(a,rh)}},E=function(a,b,c){null!=c&&(Sh(a,b,0),a.f.b.push(c?1:0))},F=function(a,b,c){null!=c&&(Sh(a,b,0),Qh(a.f,c))},H=function(a,b,c){if(null!=c){b=Th(a,b);for(var d=a.f,e=0;e<c.length;e++){var f=c.charCodeAt(e);if(128>f)d.b.push(f);else if(2048>f)d.b.push(f>>6|192),d.b.push(f&63|128);else if(65536>f)if(55296<=f&&56319>=f&&e+1<c.length){var h=
  c.charCodeAt(e+1);56320<=h&&57343>=h&&(f=1024*(f-55296)+h-56320+65536,d.b.push(f>>18|240),d.b.push(f>>12&63|128),d.b.push(f>>6&63|128),d.b.push(f&63|128),e++)}else d.b.push(f>>12|224),d.b.push(f>>6&63|128),d.b.push(f&63|128)}Uh(a,b)}},ai=function(a,b,c){null!=c&&(c=uh(c),Sh(a,b,2),Ph(a.f,c.length),b=Nh(a.f),a.h.push(b),a.h.push(c),a.g+=b.length+c.length)};z.prototype.b=function(a,b,c){null!=b&&(a=Th(this,a),c(b,this),Uh(this,a))};
  var bi=function(a,b,c){if(null!=c)for(var d=0;d<c.length;d++){var e=a,f=c[d];null!=f&&(Sh(e,b,0),Qh(e.f,f))}},ci=function(a,b,c){if(null!=c)for(var d=0;d<c.length;d++){var e=a,f=c[d];null!=f&&(Sh(e,b,0),e=e.f,th(f),Oh(e,rh,sh))}},di=function(a,b,c){if(null!=c)for(var d=0;d<c.length;d++){var e=a,f=c[d];null!=f&&(Sh(e,b,0),Ph(e.f,f))}},ei=function(a,b,c){if(null!=c)for(var d=0;d<c.length;d++)Zh(a,b,c[d])},fi=function(a,b,c){if(null!=c)for(var d=0;d<c.length;d++)F(a,b,c[d])},gi=function(a,b,c){if(null!=
  c)for(var d=0;d<c.length;d++)H(a,b,c[d])},hi=function(a,b,c){if(null!=c)for(var d=0;d<c.length;d++)ai(a,b,c[d])},I=function(a,b,c,d){if(null!=c)for(var e=0;e<c.length;e++){var f=Th(a,b);d(c[e],a);Uh(a,f)}},ii=function(a,b,c,d){if(null!=c)for(var e=0;e<c.length;e++)Sh(a,b,3),d(c[e],a),Sh(a,b,4)},ji=function(a,b,c){if(null!=c&&c.length){b=Th(a,b);for(var d=0;d<c.length;d++)Qh(a.f,c[d]);Uh(a,b)}},ki=function(a,b,c){if(null!=c&&c.length){b=Th(a,b);for(var d=0;d<c.length;d++)Qh(a.f,c[d]);Uh(a,b)}};var J=function(){},li="function"==typeof Uint8Array,M=function(a,b,c,d,e,f){a.b=null;b||(b=c?[c]:[]);a.Mg=c?String(c):void 0;a.h=0===c?-1:0;a.f=b;a:{c=a.f.length;b=-1;if(c&&(b=c-1,c=a.f[b],!(null===c||"object"!=typeof c||Ra(c)||li&&c instanceof Uint8Array))){a.s=b-a.h;a.g=c;break a}-1<d?(a.s=Math.max(d,b+1-a.h),a.g=null):a.s=Number.MAX_VALUE}a.Jy={};if(e)for(d=0;d<e.length;d++)b=e[d],b<a.s?(b+=a.h,a.f[b]=a.f[b]||mi):(ni(a),a.g[b]=a.g[b]||mi);if(f&&f.length)for(d=0;d<f.length;d++){b=e=void 0;c=a;for(var h=
  f[d],l=0;l<h.length;l++){var t=h[l],u=K(c,t);null!=u&&(b=t,e=u,L(c,t,void 0))}b&&L(c,b,e)}},mi=Object.freeze?Object.freeze([]):[],ni=function(a){var b=a.s+a.h;a.f[b]||(a.g=a.f[b]={})},oi=function(a,b,c,d){for(var e in c){var f=c[e],h=f.Ro;if(!f.di)throw Error("Message extension present that was generated without binary serialization support");var l=d.call(a,h);if(null!=l)if(h.pe)if(f.nk)f.di.call(b,h.ki,l,f.nk);else throw Error("Message extension present holding submessage without binary support enabled, and message is being serialized to binary format");
  else f.di.call(b,h.ki,l)}},K=function(a,b){if(b<a.s){b+=a.h;var c=a.f[b];return c===mi?a.f[b]=[]:c}if(a.g)return c=a.g[b],c===mi?a.g[b]=[]:c},N=function(a,b){if(b<a.s){b+=a.h;var c=a.f[b];return c===mi?a.f[b]=[]:c}c=a.g[b];return c===mi?a.g[b]=[]:c},pi=function(a,b){a=K(a,b);return null==a?a:+a},qi=function(a){if(null==a||a instanceof Uint8Array)return a;if(Ia(a))return qh(a);Db("Cannot coerce to Uint8Array: "+Pa(a));return null},si=function(a){ri(a);return!a.length||a[0]instanceof Uint8Array?a:Jb(a,
  qi)},ri=function(a){if(a&&1<a.length){var b=Pa(a[0]);x(a,function(a){Pa(a)!=b&&Db("Inconsistent type in JSPB repeated field array. Got "+Pa(a)+" expected "+b)})}},O=function(a,b,c){a=K(a,b);return null==a?c:a},L=function(a,b,c){b<a.s?a.f[b+a.h]=c:(ni(a),a.g[b]=c)},ui=function(a,b,c){ti(a,b,c,"")},vi=function(a,b,c){ti(a,b,c,0)},ti=function(a,b,c,d){c!==d?L(a,b,c):a.f[b+a.h]=null},R=function(a,b,c,d){a.b||(a.b={});if(!a.b[c]){var e=K(a,c);if(d||e)a.b[c]=new b(e)}return a.b[c]},S=function(a,b,c){wi(a,
  b,c);b=a.b[c];b==mi&&(b=a.b[c]=[]);return b},wi=function(a,b,c){a.b||(a.b={});if(!a.b[c]){for(var d=N(a,c),e=[],f=0;f<d.length;f++)e[f]=new b(d[f]);a.b[c]=e}},T=function(a,b,c){a.b||(a.b={});var d=c?xi(c):c;a.b[b]=c;L(a,b,d)},yi=function(a,b,c){a.b||(a.b={});c=c||[];for(var d=[],e=0;e<c.length;e++)d[e]=xi(c[e]);a.b[b]=c;L(a,b,d)},zi=function(a,b,c,d,e){wi(a,d,b);var f=a.b[b];f||(f=a.b[b]=[]);c=c?c:new d;a=N(a,b);void 0!=e?(f.splice(e,0,c),a.splice(e,0,xi(c))):(f.push(c),a.push(xi(c)));return c},Ai=
  function(a){if(a.b)for(var b in a.b){var c=a.b[b];if(Ra(c))for(var d=0;d<c.length;d++)c[d]&&xi(c[d]);else c&&xi(c)}},xi=function(a){Ai(a);return a.f};J.prototype.ua=li?function(){var a=Uint8Array.prototype.toJSON;Uint8Array.prototype.toJSON=function(){return oh(this)};try{return JSON.stringify(this.f&&xi(this),Bi)}finally{Uint8Array.prototype.toJSON=a}}:function(){return JSON.stringify(this.f&&xi(this),Bi)};
  var Bi=function(a,b){return p(b)&&(isNaN(b)||Infinity===b||-Infinity===b)?String(b):b},Di=function(a){var b=Ci[a[0]];if(!b)throw Error("Unknown JsPb message type: "+a[0]);return new b(a)};J.prototype.toString=function(){Ai(this);return this.f.toString()};
  J.prototype.C=function(a){if(this.g){this.b||(this.b={});var b=a.ki;if(a.b){if(a.pe)return this.b[b]||(this.b[b]=Jb(this.g[b]||[],function(b){return new a.pe(b)})),this.b[b]}else if(a.pe)return!this.b[b]&&this.g[b]&&(this.b[b]=new a.pe(this.g[b])),this.b[b];return this.g[b]}};
  var Fi=function(a,b){a=a||{};b=b||{};var c={},d;for(d in a)c[d]=0;for(d in b)c[d]=0;for(d in c)if(!Ei(a[d],b[d]))return!1;return!0},Ei=function(a,b){if(a==b)return!0;if(!Ua(a)||!Ua(b))return p(a)&&isNaN(a)||p(b)&&isNaN(b)?String(a)==String(b):!1;if(a.constructor!=b.constructor)return!1;if(li&&a.constructor===Uint8Array){if(a.length!=b.length)return!1;for(var c=0;c<a.length;c++)if(a[c]!=b[c])return!1;return!0}if(a.constructor===Array){var d=void 0,e=void 0,f=Math.max(a.length,b.length);for(c=0;c<f;c++){var h=
  a[c],l=b[c];h&&h.constructor==Object&&(d=h,h=void 0);l&&l.constructor==Object&&(e=l,l=void 0);if(!Ei(h,l))return!1}return d||e?(d=d||{},e=e||{},Fi(d,e)):!0}if(a.constructor===Object)return Fi(a,b);throw Error("Invalid type in JSPB array");};J.prototype.clone=function(){return Gi(this)};
  var Gi=function(a){return new a.constructor(Hi(xi(a)))},Hi=function(a){if(Ra(a)){for(var b=Array(a.length),c=0;c<a.length;c++){var d=a[c];null!=d&&(b[c]="object"==typeof d?Hi(d):d)}return b}if(li&&a instanceof Uint8Array)return new Uint8Array(a);b={};for(c in a)d=a[c],null!=d&&(b[c]="object"==typeof d?Hi(d):d);return b},Ii=function(a,b){Ci[a]=b;b.messageId=a},Ci={};var Ji=function(a){M(this,a,0,-1,null,null)};w(Ji,J);var Ki=function(a){M(this,a,0,-1,null,null)};w(Ki,J);Ji.prototype.u=function(){var a=new z;Li(this,a);return B(a)};var Li=function(a,b){var c=K(a,1);null!=c&&D(b,1,c);c=K(a,2);null!=c&&H(b,2,c);c=R(a,Ki,3);null!=c&&b.b(3,c,Mi)};Ki.prototype.u=function(){var a=new z;Mi(this,a);return B(a)};var Mi=function(a,b){var c=K(a,1);null!=c&&H(b,1,c);c=K(a,2);null!=c&&D(b,2,c)};Ji.prototype.ic=function(){return K(this,1)};var Ni=function(a,b){this.type="cast_app";this.originId=window["castApp.eventPage.Message.OriginID"]||void 0;this.subtype=a;this.devices=b;this.logRecord=this.deviceJustSetUp=void 0};v("castApp.eventPage.Message",Ni);var Oi=function(a,b,c){this.ipAddress=a;this.appId=b;this.sessionId=c};Ni.DeviceData=Oi;Ni.DeviceJustSetUp=function(a,b,c,d){this.ipAddress=a;this.name=b;this.udn=c;this.modelName=d};Ni.DeviceCapabilities=function(){};
  Ni.LogRecord=function(a,b,c,d){this.levelValue=a;this.msg=b;this.loggerName=c;this.time=d};var Pi=function(a,b){this.type=a;this.entryPoint=b};v("castApp.frontEnd.ExtensionMessage",Pi);var Qi=function(a){return"urn:x-cast:com.google.cast."+a},Ri=Qi("tp.connection"),Si=Qi("receiver"),Ti=Qi("remoting"),Ui=Qi("media"),Vi=Qi("webrtc"),Wi=Qi("broadcast"),Xi=Uc({Tx:Ri,Ux:Qi("tp.heartbeat"),Hw:Si,Lw:Ti,Ru:Ui,Uu:Qi("media.universalRemote.optIn"),sy:Vi,ks:Wi});var Yi=function(a){return"available"==a||"available_rescan"==a};var Zi=function(a,b,c,d,e){this.id=a;this.friendlyName=b;this.iconType=c||"generic";this.description=void 0===d?null:d;this.domain=void 0===e?null:e};var $i=window.localStorage,aj=0,cj=function(a){return(a=window.localStorage.getItem(bj(a,!1)))?JSON.parse(a):null},dj=function(a){return(a=window.localStorage.getItem(bj(a,!0)))?JSON.parse(a):null},fj=function(a){if(ej.has(a.Aa()))throw Error("Duplicate instance name "+a.Aa());ej.set(a.Aa(),a);a.fb()},lj=function(a){for(var b=0,c=k(Object.keys($i)),d=c.next();!d.done;d=c.next()){d=d.value;var e=d.length+window.localStorage.getItem(d).length;d.startsWith("mr.")?aj+=e:b+=e}gj=a;(window.localStorage.getItem("version")&&
  window.localStorage.getItem("version")!==chrome.runtime.getManifest().version||hj(a))&&ij();jj.info("initialize: "+aj+" chars used, "+b+" other chars");chrome.runtime.onSuspend.addListener(kj)},gj=null,jj=db("mr.PersistentDataManager"),ej=new Map,bj=function(a,b){return"mr."+(b?"persistent.":"temp.")+a.Aa()},hj=function(a){return!!window.localStorage.getItem("mrInstanceId")&&window.localStorage.getItem("mrInstanceId")!==a},kj=function(){jj.info("onSuspend");mj("version",chrome.runtime.getManifest().version);
  gj&&mj("mrInstanceId",gj);for(var a=ej.get("LogManager"),b=k(ej),c=b.next();!c.done;c=b.next())c=k(c.value),c.next(),c=c.next().value,c!=a&&nj(c);a&&nj(a)},nj=function(a){try{var b=a.gb();b&&void 0!=b[0]&&mj(bj(a,!1),JSON.stringify(b[0]));b&&void 0!=b[1]&&mj(bj(a,!0),JSON.stringify(b[1]))}catch(c){jj.error("Error while saving data for "+a.Aa()+": "+c.message)}},mj=function(a,b){var c=window.localStorage.getItem(a);c=null!=c?b.length-c.length:a.length+b.length;52E5<aj+c&&(jj.F("Unable to write "+c+
  " chars"),ij());if(52E5<aj+c)throw jj.error("Unable to write "+c+" chars after clearing temporary"),Error("Setting the value of '"+a+"' would exceed the quota, according to accounting.");try{window.localStorage.setItem(a,b)}catch(d){throw Error("Setting the value of '"+a+"' would exceed the quota, according to the browser.");}aj+=c},oj=function(a){a=0==a.size%2?new Blob([a,new Uint8Array([0,0])]):new Blob([a,new Uint8Array([1])]);return new Promise(function(b,c){var d=new FileReader;d.onloadend=function(){if(d.error)c(d.error);
  else try{for(var a=d.result,f=[],h=0,l=a.byteLength;h<l;h+=8192)f.push(String.fromCharCode.apply(null,new Uint16Array(a,h,Math.min(l-h,8192)/2)));mj("mr.temp.mirror.cast.Service.eventsBlob",f.join(""));b()}catch(t){c(t)}};d.readAsArrayBuffer(a)})},ij=function(){for(var a=k(Object.keys($i)),b=a.next();!b.done;b=a.next())b=b.value,b.startsWith("mr.temp.")&&(aj-=b.length+window.localStorage.getItem(b).length,delete window.localStorage[b]);jj.info("removeTemporary_: "+aj+" chars used")};var pj=(new Map).set("+","-").set("/","_").set("=","."),qj=(new Map).set("-","+").set("_","/").set(".","="),rj=function(a){return atob(a.replace(/[-_.]/g,function(a){return qj.get(a)}))},sj=function(a){return btoa(String.fromCharCode.apply(String,m(a))).replace(/[+/=]/g,function(a){return pj.get(a)})};var tj=function(){this.b=[];this.j=[];this.l=[];this.g=[];this.g[0]=128;for(var a=1;64>a;++a)this.g[a]=0;this.h=this.f=0;this.reset()};tj.prototype.reset=function(){this.b[0]=1732584193;this.b[1]=4023233417;this.b[2]=2562383102;this.b[3]=271733878;this.b[4]=3285377520;this.h=this.f=0};
  var uj=function(a,b,c){c=void 0===c?0:c;var d=a.l;if("string"===typeof b)for(var e=0;16>e;e++)d[e]=b.charCodeAt(c)<<24|b.charCodeAt(c+1)<<16|b.charCodeAt(c+2)<<8|b.charCodeAt(c+3),c+=4;else for(e=0;16>e;e++)d[e]=b[c]<<24|b[c+1]<<16|b[c+2]<<8|b[c+3],c+=4;for(b=16;80>b;b++)c=d[b-3]^d[b-8]^d[b-14]^d[b-16],d[b]=(c<<1|c>>>31)&4294967295;b=a.b[0];c=a.b[1];e=a.b[2];for(var f=a.b[3],h=a.b[4],l,t,u=0;80>u;u++)40>u?20>u?(l=f^c&(e^f),t=1518500249):(l=c^e^f,t=1859775393):60>u?(l=c&e|f&(c|e),t=2400959708):(l=
  c^e^f,t=3395469782),l=(b<<5|b>>>27)+l+h+t+d[u]&4294967295,h=f,f=e,e=(c<<30|c>>>2)&4294967295,c=b,b=l;a.b[0]=a.b[0]+b&4294967295;a.b[1]=a.b[1]+c&4294967295;a.b[2]=a.b[2]+e&4294967295;a.b[3]=a.b[3]+f&4294967295;a.b[4]=a.b[4]+h&4294967295};
  tj.prototype.update=function(a,b){b=void 0===b?a.length:b;for(var c=b-64,d=0,e=this.j,f=this.f;d<b;){if(0==f)for(;d<=c;)uj(this,a,d),d+=64;if("string"===typeof a)for(;d<b;){if(e[f]=a.charCodeAt(d),++f,++d,64==f){uj(this,e);f=0;break}}else for(;d<b;)if(e[f]=a[d],++f,++d,64==f){uj(this,e);f=0;break}}this.f=f;this.h+=b};
  tj.prototype.digest=function(){var a=[],b=8*this.h;56>this.f?this.update(this.g,56-this.f):this.update(this.g,64-(this.f-56));for(var c=63;56<=c;c--)this.j[c]=b&255,b/=256;uj(this,this.j);for(c=b=0;5>c;c++)for(var d=24;0<=d;d-=8)a[b]=this.b[c]>>d&255,++b;return a};var vj=function(){return Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)};var xj=function(){this.j=vj();this.f=new wj(null,null);this.b=new wj(null,null);this.l=[];this.g=this.h=0;fj(this)},zj=function(){yj||(yj=new xj);return yj},Aj=function(a,b){b=b.toLowerCase();var c=new tj;c.update(b);c.update(a.j);return"r"+sj(c.digest())},Bj=function(){var a=zj();return a.f.model?a.f:a.b.model?a.b:new wj(null,null)};xj.prototype.Aa=function(){return"SinkUtils"};
  xj.prototype.gb=function(){return[{recentLaunchedDevice:this.f,recentDiscoveredDevice:this.b},{receiverIdToken:this.j,fixedIpList:this.l.join(","),castControlPort:this.h,lastCloudSinkCheckTimeMillis:this.g}]};
  xj.prototype.fb=function(){var a=cj(this);a&&(this.f=a.recentLaunchedDevice||new wj(null,null),this.b=a.recentDiscoveredDevice||new wj(null,null));if(a=dj(this))this.j=a.receiverIdToken||vj(),this.l=a.fixedIpList&&a.fixedIpList.split(",")||[],this.h=a.castControlPort||0,this.g=a.lastCloudSinkCheckTimeMillis||0};var yj=null,wj=function(a,b){this.model=a;this.ip=b};var Cj=function(a,b){this.lc=this.Te=this.yd=this.Ea=this.Wb=null;this.mc=new Zi(b,a);this.Qb={};this.ah={};this.ee=!1};Cj.prototype.getId=function(){return this.mc.id};Cj.prototype.update=function(a){if(this.getId()!=a.getId())return!1;var b=!1;this.mc.friendlyName!=a.mc.friendlyName&&(this.mc.friendlyName=a.mc.friendlyName,b=!0);this.yd!=a.yd&&(this.yd=a.yd,b=!0);this.Te!=a.Te&&(this.Te=a.Te,b=!0);this.Wb!=a.Wb&&(this.Wb=a.Wb,b=!0);this.Ea!=a.Ea&&(this.Ea=a.Ea,b=!0);return b};Cj.prototype.Ob=function(){return this.Wb};
  Cj.prototype.vb=function(){return this.Ea};var Dj=function(a,b){return a.Qb[b]||"unknown"},Ej=function(a){var b=new Cj(a.mc.friendlyName,"");b.mc.id=a.mc.id;b.Wb=a.Wb;b.Ea=a.Ea;b.yd=a.yd;b.Te=a.Te;b.lc=a.lc;b.Qb=a.Qb;b.ah=a.ah;b.ee=a.ee;return b};var Fj=function(a,b,c,d,e,f){this.f=new Zi(a,b,d&1?"cast":d&32?"cast_audio_group":"cast_audio");this.lc=c||null;this.b=d||null;this.Wb=e||null;this.Ea=f||null;this.Qb={};this.hi=!1};Fj.prototype.update=function(a,b,c,d){var e=!1;this.f.friendlyName!=a&&(this.f.friendlyName=a,e=!0);null!=b&&this.Wb!=b&&(this.Wb=b,e=!0);null!=c&&this.Ea!=c&&(this.Ea=c,e=!0);null!=d&&this.b!=d&&(this.b=d,e=!0);return e};Fj.prototype.getId=function(){return this.f.id};Fj.prototype.Ob=function(){return this.Wb};
  Fj.prototype.vb=function(){return this.Ea};var Gj=function(a,b){return a.Qb[b]||"unknown"};var Hj="StopIteration"in Ga?Ga.StopIteration:{message:"StopIteration",stack:""},Ij=function(){};Ij.prototype.next=function(){throw Hj;};Ij.prototype.zb=function(){return this};
  var Jj=function(a){if(a instanceof Ij)return a;if("function"==typeof a.zb)return a.zb(!1);if(Sa(a)){var b=0,c=new Ij;c.next=function(){for(;;){if(b>=a.length)throw Hj;if(b in a)return a[b++];b++}};return c}throw Error("Not implemented");},Kj=function(a,b,c){if(Sa(a))try{x(a,b,c)}catch(d){if(d!==Hj)throw d;}else{a=Jj(a);try{for(;;)b.call(c,a.next(),void 0,a)}catch(d){if(d!==Hj)throw d;}}},Lj=function(a,b){a=Jj(a);try{for(;!b.call(void 0,a.next(),void 0,a););}catch(c){if(c!==Hj)throw c;}},Mj=function(a){if(Sa(a))return y(a);
  a=Jj(a);var b=[];Kj(a,function(a){b.push(a)});return b};var Oj=function(a,b){this.f={};this.b=[];this.h=this.g=0;var c=arguments.length;if(1<c){if(c%2)throw Error("Uneven number of arguments");for(var d=0;d<c;d+=2)this.set(arguments[d],arguments[d+1])}else a&&Nj(this,a)};Oj.prototype.sa=function(){return this.g};Oj.prototype.ga=function(){Pj(this);for(var a=[],b=0;b<this.b.length;b++)a.push(this.f[this.b[b]]);return a};Oj.prototype.rb=function(){Pj(this);return this.b.concat()};var Rj=function(a,b){return Qj(a.f,b)};
  Oj.prototype.cf=function(a){for(var b=0;b<this.b.length;b++){var c=this.b[b];if(Qj(this.f,c)&&this.f[c]==a)return!0}return!1};Oj.prototype.equals=function(a,b){if(this===a)return!0;if(this.g!=a.sa())return!1;b=b||Sj;Pj(this);for(var c,d=0;c=this.b[d];d++)if(!b(this.get(c),a.get(c)))return!1;return!0};var Sj=function(a,b){return a===b};Oj.prototype.Db=function(){return 0==this.g};Oj.prototype.clear=function(){this.f={};this.h=this.g=this.b.length=0};
  Oj.prototype.remove=function(a){return Qj(this.f,a)?(delete this.f[a],this.g--,this.h++,this.b.length>2*this.g&&Pj(this),!0):!1};var Pj=function(a){if(a.g!=a.b.length){for(var b=0,c=0;b<a.b.length;){var d=a.b[b];Qj(a.f,d)&&(a.b[c++]=d);b++}a.b.length=c}if(a.g!=a.b.length){var e={};for(c=b=0;b<a.b.length;)d=a.b[b],Qj(e,d)||(a.b[c++]=d,e[d]=1),b++;a.b.length=c}};Oj.prototype.get=function(a,b){return Qj(this.f,a)?this.f[a]:b};
  Oj.prototype.set=function(a,b){Qj(this.f,a)||(this.g++,this.b.push(a),this.h++);this.f[a]=b};var Nj=function(a,b){if(b instanceof Oj)for(var c=b.rb(),d=0;d<c.length;d++)a.set(c[d],b.get(c[d]));else for(c in b)a.set(c,b[c])};Oj.prototype.forEach=function(a,b){for(var c=this.rb(),d=0;d<c.length;d++){var e=c[d],f=this.get(e);a.call(b,f,e,this)}};Oj.prototype.clone=function(){return new Oj(this)};var Tj=function(a){Pj(a);for(var b={},c=0;c<a.b.length;c++){var d=a.b[c];b[d]=a.f[d]}return b};
  Oj.prototype.zb=function(a){Pj(this);var b=0,c=this.h,d=this,e=new Ij;e.next=function(){if(c!=d.h)throw Error("The map has changed since the iterator was created");if(b>=d.b.length)throw Hj;var e=d.b[b++];return a?e:d.f[e]};return e};var Qj=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)};var Uj=function(a,b){this.h=b;this.f=a;this.f.ja=this.ja.bind(this);this.b=new Oj;this.j=new Oj;this.m=db("mr.cast.SinkDiscoveryService");this.g={Nf:0,cg:0}};n(Uj,ag);Uj.prototype.init=function(){fj(this);kg("mr.cast.SinkDiscoveryService",this)};
  var ck=function(a,b){a.m.info("addSinks returned "+b.length+" sinks");kb(a.m,function(){return"....the list is: "+JSON.stringify(b)});var c=new Set(a.b.rb());b.forEach(function(b){var d=b.sink_id;var e=b.extra_data.cast_media_sink,l=e.ip_endpoint?e.ip_endpoint.address:e.ip_address,t=e.ip_endpoint?e.ip_endpoint.port:zj().h||8009;d=new Fj(d,b.name,e.model_name,e.capabilities,l.address_bytes.join("."),t);e=a.b.get(d.getId());l=a.f;b=b.extra_data.cast_media_sink.cast_channel_id;t=d.getId();var u=l.f.get(t);
  if(!u||u.channelId!=b){Vj.info("Added cast channel "+b+" to receiver: "+t);u&&l.b.remove(u.channelId);u={auth:"ssl_verified",ipAddress:d.Ob(),port:d.vb()};u={channelId:b,readyState:"open",keepAlive:!0,audioOnly:!(d.b&1),connectInfo:u};l.f.set(t,u);l.b.set(b,t);var A=l.h.get(t);A&&A.channelId!=b&&(Vj.info("Re-connected to receiver: "+d.getId()),Wj(l.g,A,u),Xj(l.j.j,d,!0));l.h.set(t,u)}if(e){if(l=e.update(d.f.friendlyName,d.Ob(),d.vb(),d.b))e.hi=!1;l&&Yj(a.h,e)}else a.m.info("Adding sink "+d.getId()),
  Zj(a,d),e=a.h,e.g.onSinkAvailabilityUpdated(e,1),Yj(e,d),Xj(e.j,d),zj().b=new wj(d.lc,d.Ob());c.delete(d.getId())});c.forEach(function(b){var c=a.f,d=c.h.get(b);d&&(ak(c.g,d),c.h.remove(b));bk(a,b)});var d=a.b.sa();a.g={Nf:d,cg:d}};Uj.prototype.se=function(){return this.g};
  var Zj=function(a,b){var c=a.b.get(b.getId()),d=null,e=b.Ob(),f=b.vb();null!=e&&null!=f&&(d=a.j.get(e+":"+f));if(c&&!d){var h=b.Ob(),l=b.vb();h&&l&&a.j.remove(h+":"+l)}d&&!c&&a.b.remove(d.getId());a.b.set(b.getId(),b);null!=e&&null!=f&&a.j.set(e+":"+f,b)},bk=function(a,b){var c=a.b.get(b);if(c){a.m.info("Removing sink "+b);a.b.remove(b);b=c.Ob();var d=c.vb();null!=b&&null!=d&&a.j.remove(b+":"+d);a=a.h;if(0==a.b.b.sa())a.g.onSinkAvailabilityUpdated(a,0);b=a.j;c=c.getId();(c=dk(b.b,c))&&c.session&&
  ek(b,c.session.sessionId);fk(a.B);a.g.Sc()}},hk=function(a){a.m.info("Pruning inactive sinks.");Kj(a.b.zb(!1),function(b){gk(a.f,b)||bk(a,b.getId())})};Uj.prototype.ja=function(a){return this.b.get(a,null)};var ik=function(a,b){var c=[];Kj(a.b.zb(!1),function(a){Yi(Gj(a,b))&&c.push(a)});return c};Uj.prototype.Aa=function(){return"cast.SinkDiscoveryService"};
  Uj.prototype.gb=function(){var a=this,b={};Kj(this.b.zb(!0),function(c){var d=a.b.get(c);d={id:d.getId(),ip:d.Ob(),port:d.vb(),friendlyName:d.f.friendlyName,modelName:d.lc,capabilities:d.b,discoveredByDial:d.hi,appStatusMap:d.Qb};b[c]=d});return[new jk(b,this.g)]};
  Uj.prototype.fb=function(){var a=cj(this);if(a&&4==a.version){this.g=a.deviceCounts;a=a.sinkMap;for(var b in a){var c=void 0,d=a[b],e=new Fj("",d.friendlyName,d.modelName,d.capabilities,d.ip,d.port);e.f.id=d.id;e.hi=d.discoveredByDial;e.Qb=d.appStatusMap;for(c in e.Qb)"unavailable"==e.Qb[c]&&(e.Qb[c]="unavailable_rescan");c=e;this.ja(c.getId())||Zj(this,c)}hk(this)}};var jk=function(a,b){this.sinkMap=a;this.deviceCounts=b;this.version=4};var kk={STOP_MEDIA:"STOP",MEDIA_SET_VOLUME:"SET_VOLUME",MEDIA_GET_STATUS:"GET_STATUS"};var lk=function(){this.type="GET_STATUS";this.requestId=0};var mk=function(a,b){this.requestId=a;this.Ag=b;this.rm=null};mk.prototype.b=function(){};var nk=function(){this.b=new Oj},ok=function(a,b){a.b.set(b.requestId,b);b.rm=setTimeout(function(){a.b.remove(b.requestId);b.b()},b.Ag)},pk=function(a,b){var c=a.b.get(b);if(!c)return null;clearTimeout(c.rm);a.b.remove(b);return c};var qk=function(a,b,c){this.type="APPLICATION_BROADCAST";this.requestId=0;this.appIds=a;this.namespace=b;this.message=c};var rk=function(a){this.type="LAUNCH";this.requestId=0;this.appId=a;this.language=null};var sk=function(a){this.type="STOP";this.requestId=0;this.sessionId=a||null};var tk=function(a){this.f=a;this.b=1E3*Math.floor(1E6*Math.random())},uk=function(a){var b=a.b++;0==b&&(b=a.b++);return b};tk.prototype.Aa=function(){return"IdGenerator."+this.f};tk.prototype.gb=function(){return[this.b]};tk.prototype.fb=function(){var a=cj(this);a&&(this.b=a)};var vk=function(a,b){this.f=a;this.g=b;this.b=new nk;this.h=new tk("cast.RequestIdGenerator")};vk.prototype.init=function(){fj(this.h)};var xk=function(a,b,c,d){var e=uk(a.h);b.requestId=e;b=new zb;c=new wk(e,b,p(c)&&0<c?c:6E5,d);ok(a.b,c);return c};
  vk.prototype.sendRequest=function(a,b,c,d,e,f){var h=this;if(!Xi.hasOwnProperty(c))return Promise.reject(Error("Custom namespace is not supported"));var l=xk(this,a,Ha(d)?d:3E3,e),t=l.ob;yk(this.f,b,c,a,e||this.g,f).then(null,function(){pk(h.b,l.requestId);t.reject(zk)});return t.b};
  vk.prototype.sendMessage=function(a,b,c,d,e,f){var h=this,l=xk(this,a,Ha(d)?d:3E3,e),t=l.ob;yk(this.f,b,c,a,e||this.g,f).then(function(){pk(h.b,l.requestId);t.resolve(!0)},function(){pk(h.b,l.requestId);t.reject(zk)});return t.b};
  var Ak=function(a,b,c){var d=new rk(b.appId);d.language=b.language?b.language:chrome.i18n.getUILanguage?chrome.i18n.getUILanguage():chrome.runtime.getManifest().default_locale;return a.sendRequest(d,c,Si,b.requestSessionTimeout)},Bk=Error("Timeout"),zk=Error("Failed to send message"),wk=function(a,b,c,d){mk.call(this,a,c);this.ob=b;this.sourceId=d};n(wk,mk);wk.prototype.b=function(){this.ob.reject(Bk)};var Ck=function(a){return a.sa&&"function"==typeof a.sa?a.sa():Sa(a)||Ia(a)?a.length:Kc(a)},Dk=function(a){if(a.ga&&"function"==typeof a.ga)return a.ga();if(Ia(a))return a.split("");if(Sa(a)){for(var b=[],c=a.length,d=0;d<c;d++)b.push(a[d]);return b}return Mc(a)},Ek=function(a){if(a.rb&&"function"==typeof a.rb)return a.rb();if(!a.ga||"function"!=typeof a.ga){if(Sa(a)||Ia(a)){var b=[];a=a.length;for(var c=0;c<a;c++)b.push(c);return b}return Nc(a)}},Fk=function(a){return a.Db&&"function"==typeof a.Db?
  a.Db():Sa(a)||Ia(a)?Rb(a):Qc(a)},Gk=function(a,b,c){if(a.forEach&&"function"==typeof a.forEach)a.forEach(b,c);else if(Sa(a)||Ia(a))x(a,b,c);else for(var d=Ek(a),e=Dk(a),f=e.length,h=0;h<f;h++)b.call(c,e[h],d&&d[h],a)},Hk=function(a,b,c){if("function"==typeof a.map)return a.map(b,c);if(Sa(a)||Ia(a))return Jb(a,b,c);var d=Ek(a),e=Dk(a),f=e.length;if(d){var h={};for(var l=0;l<f;l++)h[d[l]]=b.call(c,e[l],d[l],a)}else for(h=[],l=0;l<f;l++)h[l]=b.call(c,e[l],void 0,a);return h},Ik=function(a,b){if("function"==
  typeof a.every)return a.every(b,void 0);if(Sa(a)||Ia(a))return Mb(a,b,void 0);for(var c=Ek(a),d=Dk(a),e=d.length,f=0;f<e;f++)if(!b.call(void 0,d[f],c&&c[f],a))return!1;return!0};var Kk=function(a){this.b=new Oj;a&&Jk(this,a)},Lk=function(a){var b=typeof a;return"object"==b&&a||"function"==b?"o"+(a[Va]||(a[Va]=++Xa)):b.substr(0,1)+a};Kk.prototype.sa=function(){return this.b.sa()};Kk.prototype.add=function(a){this.b.set(Lk(a),a)};var Jk=function(a,b){b=Dk(b);for(var c=b.length,d=0;d<c;d++)a.add(b[d])};g=Kk.prototype;g.removeAll=function(a){a=Dk(a);for(var b=a.length,c=0;c<b;c++)this.remove(a[c])};g.remove=function(a){return this.b.remove(Lk(a))};g.clear=function(){this.b.clear()};
  g.Db=function(){return this.b.Db()};g.contains=function(a){return Rj(this.b,Lk(a))};g.ga=function(){return this.b.ga()};g.clone=function(){return new Kk(this)};g.equals=function(a){return this.sa()==Ck(a)&&Mk(this,a)};var Mk=function(a,b){var c=Ck(b);if(a.sa()>c)return!1;!(b instanceof Kk)&&5<c&&(b=new Kk(b));return Ik(a,function(a){var c=b;return c.contains&&"function"==typeof c.contains?c.contains(a):c.cf&&"function"==typeof c.cf?c.cf(a):Sa(c)||Ia(c)?Qb(c,a):Pc(c,a)})};Kk.prototype.zb=function(){return this.b.zb(!1)};var Ok=function(a,b){this.h=a;this.g=b;this.f=new Oj;this.b=new Kk;this.j=0;this.s=new Oj("serviceCheck",this.gp.bind(this),"startDeviceMonitor",this.hp.bind(this),"releaseDeviceMonitor",this.fp.bind(this),"deviceJustSetUp",this.bp.bind(this),"logRecord",this.cp.bind(this));chrome.runtime.onMessage.addListener(this.o.bind(this));chrome.runtime.onMessageExternal.addListener(this.l.bind(this));Nk(this,"serviceReady")};Ok.prototype.m=db("castApp.eventPage.Service");
  var fk=function(a){if(Pk(a)){var b=new Kk;Kj(a.h.b.zb(!1),function(a){var c=a.Ob();b.add(c);Rj(this.f,c)||this.g.sendRequest(new lk,a,Si)}.bind(a));var c=!1;a.f.rb().forEach(function(a){b.contains(a)||(this.f.remove(a),c=!0)}.bind(a));c&&Qk(a)}},Pk=function(a){if(0===a.b.sa())return!1;var b=r();3E4<b-a.j&&(a.j=b,chrome.tabs.query({url:["chrome://cast/*","chrome-extension://"+chrome.runtime.id+"/cast_setup/*"]},function(a){0===a.length?(this.m.info("No tabs found. Clearing device monitor clients."),
  this.b.clear()):this.m.info(function(){return"Tab check found active tabs: "+a.map(function(a){return a.id})})}.bind(a)));b=a.b.sa();a.m.info("Monitor client count: "+b);return 0<b};Ok.prototype.o=function(a,b,c){if("object"!==typeof a||"cast_app"!==a.type)return!1;var d=this.s.get(a.subtype);if(!d)return!1;if(!a.originId)return Db("Missing origin ID in the incoming message."),!1;try{var e=d(a,b,c);e&&c(e)}catch(f){this.m.error("Error while handling request",f)}return!1};
  var Nk=function(a,b,c){var d=new Ni(b,c);kb(a.m,function(){return"Sending message: "+JSON.stringify(d)});chrome.runtime.sendMessage(d)};g=Ok.prototype;g.gp=function(){Nk(this,"serviceReady")};g.hp=function(a){this.b.contains(a.originId)?this.m.info("Client: "+a.originId+"already registered, dispatching current device list."):(this.m.info("Registering monitor client: "+a.originId),this.b.add(a.originId));Qk(this);Rk(this)};g.fp=function(a){this.m.info("Unregistering monitor client: "+a.originId);this.b.remove(a.originId)};
  g.bp=function(a){a=a.deviceJustSetUp.udn.replace(/-/g,"").toLowerCase();this.m.info("Device just set up: "+a.slice(-4))};g.cp=function(a){a=a.logRecord;gb({level:nb(a.levelValue),L:a.loggerName,time:a.time,message:a.msg})};var Qk=function(a){var b=a.f.ga();Nk(a,"devices",b)},Rk=function(a){a.h.b.ga().forEach(function(a){this.g.sendRequest(new lk,a,Si)}.bind(a))};
  Ok.prototype.l=function(a,b,c){switch(a.type){case "handshake":c(new Pi("handshake"));break;case "launch":b=b.tab&&p(b.tab.id)?b.tab.id:null,null===b||"setup"!==a.entryPoint&&"offers"!==a.entryPoint&&"devices"!==a.entryPoint||chrome.tabs.update(b,{url:"chrome://cast#"+a.entryPoint})}};chrome.cast.VERSION=[1,2];v("chrome.cast.VERSION",chrome.cast.VERSION);chrome.cast.ur=!0;v("chrome.cast.usingPresentationApi",chrome.cast.ur);chrome.cast.Error=function(a,b,c){this.code=a;this.description=b||null;this.details=c||null};v("chrome.cast.Error",chrome.cast.Error);chrome.cast.Ln=function(a){this.platform=a;this.packageId=this.url=null};v("chrome.cast.SenderApplication",chrome.cast.Ln);chrome.cast.Image=function(a){this.url=a;this.width=this.height=null};v("chrome.cast.Image",chrome.cast.Image);
  chrome.cast.Volume=function(a,b){this.level=Ha(a)?a:null;this.muted=Ha(b)?b:null};v("chrome.cast.Volume",chrome.cast.Volume);chrome.cast.Yc={CUSTOM_CONTROLLER_SCOPED:"custom_controller_scoped",TAB_AND_ORIGIN_SCOPED:"tab_and_origin_scoped",ORIGIN_SCOPED:"origin_scoped",PAGE_SCOPED:"page_scoped"};v("chrome.cast.AutoJoinPolicy",chrome.cast.Yc);chrome.cast.Eg={CREATE_SESSION:"create_session",CAST_THIS_TAB:"cast_this_tab"};v("chrome.cast.DefaultActionPolicy",chrome.cast.Eg);chrome.cast.xd={VIDEO_OUT:"video_out",AUDIO_OUT:"audio_out",VIDEO_IN:"video_in",AUDIO_IN:"audio_in",MULTIZONE_GROUP:"multizone_group"};
  v("chrome.cast.Capability",chrome.cast.xd);chrome.cast.ad={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"};v("chrome.cast.ErrorCode",chrome.cast.ad);chrome.cast.xn={AVAILABLE:"available",UNAVAILABLE:"unavailable"};
  v("chrome.cast.ReceiverAvailability",chrome.cast.xn);chrome.cast.Mn={CHROME:"chrome",IOS:"ios",ANDROID:"android"};v("chrome.cast.SenderPlatform",chrome.cast.Mn);chrome.cast.Ng={CAST:"cast",DIAL:"dial",HANGOUT:"hangout",CUSTOM:"custom"};v("chrome.cast.ReceiverType",chrome.cast.Ng);chrome.cast.Jm={RUNNING:"running",STOPPED:"stopped",ERROR:"error"};v("chrome.cast.DialAppState",chrome.cast.Jm);chrome.cast.Lf={CAST:"cast",STOP:"stop"};v("chrome.cast.ReceiverAction",chrome.cast.Lf);
  chrome.cast.Wj={CONNECTED:"connected",DISCONNECTED:"disconnected",STOPPED:"stopped"};v("chrome.cast.SessionStatus",chrome.cast.Wj);chrome.cast.ak={ATTENUATION:"attenuation",FIXED:"fixed",MASTER:"master"};v("chrome.cast.VolumeControlType",chrome.cast.ak);chrome.cast.Bm=function(a,b,c,d,e){this.sessionRequest=a;this.sessionListener=b;this.receiverListener=c;this.autoJoinPolicy=d||chrome.cast.Yc.TAB_AND_ORIGIN_SCOPED;this.defaultActionPolicy=e||chrome.cast.Eg.CREATE_SESSION;this.customDialLaunchCallback=null;this.invisibleSender=!1;this.additionalSessionRequests=[]};v("chrome.cast.ApiConfig",chrome.cast.Bm);chrome.cast.Lm=function(a,b){this.appName=a;this.launchParameter=b||null};v("chrome.cast.DialRequest",chrome.cast.Lm);
  chrome.cast.Hj=function(a,b,c){this.receiver=a;this.appState=b;this.extraData=c||null};v("chrome.cast.DialLaunchData",chrome.cast.Hj);chrome.cast.Km=function(a,b){this.doLaunch=a;this.launchParameter=b||null};v("chrome.cast.DialLaunchResponse",chrome.cast.Km);chrome.cast.Vj=function(a,b,c){this.appId=a;this.capabilities=Ra(b)?b:[chrome.cast.xd.VIDEO_OUT,chrome.cast.xd.AUDIO_OUT];this.requestSessionTimeout=c||chrome.cast.timeout.requestSession;this.dialRequest=this.language=null};
  v("chrome.cast.SessionRequest",chrome.cast.Vj);
  chrome.cast.Ih=function(a,b,c,d){this.label=a;a=b;vc.test(a)&&(-1!=a.indexOf("&")&&(a=a.replace(pc,"&amp;")),-1!=a.indexOf("<")&&(a=a.replace(qc,"&lt;")),-1!=a.indexOf(">")&&(a=a.replace(rc,"&gt;")),-1!=a.indexOf('"')&&(a=a.replace(sc,"&quot;")),-1!=a.indexOf("'")&&(a=a.replace(tc,"&#39;")),-1!=a.indexOf("\x00")&&(a=a.replace(uc,"&#0;")));this.friendlyName=a;this.capabilities=c||[];this.volume=d||null;this.receiverType=chrome.cast.Ng.CAST;this.displayStatus=this.isActiveInput=null};
  v("chrome.cast.Receiver",chrome.cast.Ih);chrome.cast.yn=function(a,b){this.statusText=a;this.appImages=b;this.showStop=null};v("chrome.cast.ReceiverDisplayStatus",chrome.cast.yn);chrome.cast.Zj=function(){this.requestSession=6E4;this.sendCustomMessage=this.setReceiverVolume=this.stopSession=this.leaveSession=3E3};v("chrome.cast.Timeout",chrome.cast.Zj);chrome.cast.timeout=new chrome.cast.Zj;v("chrome.cast.timeout",chrome.cast.timeout);chrome.cast.Dj="auto-join";chrome.cast.Sj="cast-session_";chrome.cast.media.de={PAUSE:"pause",SEEK:"seek",STREAM_VOLUME:"stream_volume",STREAM_MUTE:"stream_mute"};v("chrome.cast.media.MediaCommand",chrome.cast.media.de);chrome.cast.media.zc={GENERIC:0,MOVIE:1,TV_SHOW:2,MUSIC_TRACK:3,PHOTO:4};v("chrome.cast.media.MetadataType",chrome.cast.media.zc);chrome.cast.media.Se={IDLE:"IDLE",PLAYING:"PLAYING",PAUSED:"PAUSED",BUFFERING:"BUFFERING"};v("chrome.cast.media.PlayerState",chrome.cast.media.Se);
  chrome.cast.media.Jh={OFF:"REPEAT_OFF",ALL:"REPEAT_ALL",SINGLE:"REPEAT_SINGLE",ALL_AND_SHUFFLE:"REPEAT_ALL_AND_SHUFFLE"};v("chrome.cast.media.RepeatMode",chrome.cast.media.Jh);chrome.cast.media.zn={PLAYBACK_START:"PLAYBACK_START",PLAYBACK_PAUSE:"PLAYBACK_PAUSE"};v("chrome.cast.media.ResumeState",chrome.cast.media.zn);chrome.cast.media.Xj={BUFFERED:"BUFFERED",LIVE:"LIVE",OTHER:"OTHER"};v("chrome.cast.media.StreamType",chrome.cast.media.Xj);
  chrome.cast.media.Um={CANCELLED:"CANCELLED",INTERRUPTED:"INTERRUPTED",FINISHED:"FINISHED",ERROR:"ERROR"};v("chrome.cast.media.IdleReason",chrome.cast.media.Um);chrome.cast.media.Xn={TEXT:"TEXT",AUDIO:"AUDIO",VIDEO:"VIDEO"};v("chrome.cast.media.TrackType",chrome.cast.media.Xn);chrome.cast.media.Un={SUBTITLES:"SUBTITLES",CAPTIONS:"CAPTIONS",DESCRIPTIONS:"DESCRIPTIONS",CHAPTERS:"CHAPTERS",METADATA:"METADATA"};v("chrome.cast.media.TextTrackType",chrome.cast.media.Un);
  chrome.cast.media.Qn={NONE:"NONE",OUTLINE:"OUTLINE",DROP_SHADOW:"DROP_SHADOW",RAISED:"RAISED",DEPRESSED:"DEPRESSED"};v("chrome.cast.media.TextTrackEdgeType",chrome.cast.media.Qn);chrome.cast.media.Vn={NONE:"NONE",NORMAL:"NORMAL",ROUNDED_CORNERS:"ROUNDED_CORNERS"};v("chrome.cast.media.TextTrackWindowType",chrome.cast.media.Vn);
  chrome.cast.media.Rn={SANS_SERIF:"SANS_SERIF",MONOSPACED_SANS_SERIF:"MONOSPACED_SANS_SERIF",SERIF:"SERIF",MONOSPACED_SERIF:"MONOSPACED_SERIF",CASUAL:"CASUAL",CURSIVE:"CURSIVE",SMALL_CAPITALS:"SMALL_CAPITALS"};v("chrome.cast.media.TextTrackFontGenericFamily",chrome.cast.media.Rn);chrome.cast.media.Sn={NORMAL:"NORMAL",BOLD:"BOLD",BOLD_ITALIC:"BOLD_ITALIC",ITALIC:"ITALIC"};v("chrome.cast.media.TextTrackFontStyle",chrome.cast.media.Sn);chrome.cast.media.Qm=function(){this.customData=null};v("chrome.cast.media.GetStatusRequest",chrome.cast.media.Qm);chrome.cast.media.hn=function(){this.customData=null};v("chrome.cast.media.PauseRequest",chrome.cast.media.hn);chrome.cast.media.kn=function(){this.customData=null};v("chrome.cast.media.PlayRequest",chrome.cast.media.kn);chrome.cast.media.Kn=function(){this.customData=this.resumeState=this.currentTime=null};v("chrome.cast.media.SeekRequest",chrome.cast.media.Kn);
  chrome.cast.media.Nn=function(){this.customData=null};v("chrome.cast.media.StopRequest",chrome.cast.media.Nn);chrome.cast.media.bo=function(a){this.volume=a;this.customData=null};v("chrome.cast.media.VolumeRequest",chrome.cast.media.bo);chrome.cast.media.Wm=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};v("chrome.cast.media.LoadRequest",chrome.cast.media.Wm);
  chrome.cast.media.Ew=function(a){this.type="PRECACHE";this.requestId=0;this.precacheData=a};chrome.cast.media.Om=function(a,b){this.requestId=0;this.activeTrackIds=a||null;this.textTrackStyle=b||null};v("chrome.cast.media.EditTracksInfoRequest",chrome.cast.media.Om);chrome.cast.media.Pm=function(){this.metadataType=this.type=chrome.cast.media.zc.GENERIC;this.releaseDate=this.releaseYear=this.images=this.subtitle=this.title=null};v("chrome.cast.media.GenericMediaMetadata",chrome.cast.media.Pm);
  chrome.cast.media.Zm=function(){this.metadataType=this.type=chrome.cast.media.zc.MOVIE;this.releaseDate=this.releaseYear=this.images=this.subtitle=this.studio=this.title=null};v("chrome.cast.media.MovieMediaMetadata",chrome.cast.media.Zm);chrome.cast.media.Yn=function(){this.metadataType=this.type=chrome.cast.media.zc.TV_SHOW;this.originalAirdate=this.releaseYear=this.images=this.episode=this.episodeNumber=this.season=this.seasonNumber=this.episodeTitle=this.title=this.seriesTitle=null};
  v("chrome.cast.media.TvShowMediaMetadata",chrome.cast.media.Yn);chrome.cast.media.an=function(){this.metadataType=this.type=chrome.cast.media.zc.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};v("chrome.cast.media.MusicTrackMediaMetadata",chrome.cast.media.an);
  chrome.cast.media.jn=function(){this.metadataType=this.type=chrome.cast.media.zc.PHOTO;this.creationDateTime=this.height=this.width=this.longitude=this.latitude=this.images=this.location=this.artist=this.title=null};v("chrome.cast.media.PhotoMediaMetadata",chrome.cast.media.jn);chrome.cast.media.Ym=function(a,b){this.contentId=a;this.streamType=chrome.cast.media.Xj.BUFFERED;this.contentType=b;this.customData=this.textTrackStyle=this.tracks=this.duration=this.metadata=null};
  v("chrome.cast.media.MediaInfo",chrome.cast.media.Ym);chrome.cast.media.nn=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};v("chrome.cast.media.QueueItem",chrome.cast.media.nn);chrome.cast.media.Hm="CC1AD845";v("chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID",chrome.cast.media.Hm);chrome.cast.media.timeout={};chrome.cast.media.timeout.load=0;v("chrome.cast.media.timeout.load",chrome.cast.media.timeout.load);
  chrome.cast.media.timeout.La=0;v("chrome.cast.media.timeout.getStatus",chrome.cast.media.timeout.La);chrome.cast.media.timeout.play=0;v("chrome.cast.media.timeout.play",chrome.cast.media.timeout.play);chrome.cast.media.timeout.pause=0;v("chrome.cast.media.timeout.pause",chrome.cast.media.timeout.pause);chrome.cast.media.timeout.seek=0;v("chrome.cast.media.timeout.seek",chrome.cast.media.timeout.seek);chrome.cast.media.timeout.stop=0;v("chrome.cast.media.timeout.stop",chrome.cast.media.timeout.stop);
  chrome.cast.media.timeout.kc=0;v("chrome.cast.media.timeout.setVolume",chrome.cast.media.timeout.kc);chrome.cast.media.timeout.ii=0;v("chrome.cast.media.timeout.editTracksInfo",chrome.cast.media.timeout.ii);chrome.cast.media.timeout.Bq=0;v("chrome.cast.media.timeout.queue",chrome.cast.media.timeout.Bq);chrome.cast.media.Wn=function(a,b){this.trackId=a;this.trackContentType=this.trackContentId=null;this.type=b;this.customData=this.subtype=this.language=this.name=null};v("chrome.cast.media.Track",chrome.cast.media.Wn);
  chrome.cast.media.Tn=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};v("chrome.cast.media.TextTrackStyle",chrome.cast.media.Tn);chrome.cast.media.qn=function(a){this.type="QUEUE_LOAD";this.sessionId=this.requestId=null;this.items=a;this.startIndex=0;this.repeatMode=chrome.cast.media.Jh.OFF;this.customData=null};
  v("chrome.cast.media.QueueLoadRequest",chrome.cast.media.qn);chrome.cast.media.mn=function(a){this.type="QUEUE_INSERT";this.sessionId=this.requestId=null;this.items=a;this.customData=this.insertBefore=null};v("chrome.cast.media.QueueInsertItemsRequest",chrome.cast.media.mn);chrome.cast.media.un=function(a){this.type="QUEUE_UPDATE";this.sessionId=this.requestId=null;this.items=a;this.customData=null};v("chrome.cast.media.QueueUpdateItemsRequest",chrome.cast.media.un);
  chrome.cast.media.pn=function(){this.type="QUEUE_UPDATE";this.customData=this.jump=this.currentItemId=this.sessionId=this.requestId=null};v("chrome.cast.media.QueueJumpRequest",chrome.cast.media.pn);chrome.cast.media.tn=function(){this.type="QUEUE_UPDATE";this.customData=this.repeatMode=this.sessionId=this.requestId=null};v("chrome.cast.media.QueueSetPropertiesRequest",chrome.cast.media.tn);
  chrome.cast.media.rn=function(a){this.type="QUEUE_REMOVE";this.sessionId=this.requestId=null;this.itemIds=a;this.customData=null};v("chrome.cast.media.QueueRemoveItemsRequest",chrome.cast.media.rn);chrome.cast.media.sn=function(a){this.type="QUEUE_REORDER";this.sessionId=this.requestId=null;this.itemIds=a;this.customData=this.insertBefore=null};v("chrome.cast.media.QueueReorderItemsRequest",chrome.cast.media.sn);chrome.cast.media.O=function(a,b){this.sessionId=a;this.mediaSessionId=b;this.media=null;this.playbackRate=1;this.playerState=chrome.cast.media.Se.IDLE;this.currentTime=0;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.Jh.OFF};v("chrome.cast.media.Media",chrome.cast.media.O);chrome.cast.media.O.prototype.La=function(){};
  chrome.cast.media.O.prototype.getStatus=chrome.cast.media.O.prototype.La;chrome.cast.media.O.prototype.play=function(){};chrome.cast.media.O.prototype.play=chrome.cast.media.O.prototype.play;chrome.cast.media.O.prototype.vq=function(){};chrome.cast.media.O.prototype.playWithContext=chrome.cast.media.O.prototype.vq;chrome.cast.media.O.prototype.pause=function(){};chrome.cast.media.O.prototype.pause=chrome.cast.media.O.prototype.pause;chrome.cast.media.O.prototype.uq=function(){};
  chrome.cast.media.O.prototype.pauseWithContext=chrome.cast.media.O.prototype.uq;chrome.cast.media.O.prototype.seek=function(){};chrome.cast.media.O.prototype.seek=chrome.cast.media.O.prototype.seek;chrome.cast.media.O.prototype.stop=function(){};chrome.cast.media.O.prototype.stop=chrome.cast.media.O.prototype.stop;chrome.cast.media.O.prototype.kc=function(){};chrome.cast.media.O.prototype.setVolume=chrome.cast.media.O.prototype.kc;chrome.cast.media.O.prototype.ii=function(){};
  chrome.cast.media.O.prototype.editTracksInfo=chrome.cast.media.O.prototype.ii;chrome.cast.media.O.prototype.Dq=function(){};chrome.cast.media.O.prototype.queueInsertItems=chrome.cast.media.O.prototype.Dq;chrome.cast.media.O.prototype.Cq=function(){};chrome.cast.media.O.prototype.queueAppendItem=chrome.cast.media.O.prototype.Cq;chrome.cast.media.O.prototype.Nq=function(){};chrome.cast.media.O.prototype.queueUpdateItems=chrome.cast.media.O.prototype.Nq;chrome.cast.media.O.prototype.Iq=function(){};
  chrome.cast.media.O.prototype.queuePrev=chrome.cast.media.O.prototype.Iq;chrome.cast.media.O.prototype.Hq=function(){};chrome.cast.media.O.prototype.queueNext=chrome.cast.media.O.prototype.Hq;chrome.cast.media.O.prototype.Eq=function(a){Sk(this,a)};chrome.cast.media.O.prototype.queueJumpToItem=chrome.cast.media.O.prototype.Eq;chrome.cast.media.O.prototype.Mq=function(){};chrome.cast.media.O.prototype.queueSetRepeatMode=chrome.cast.media.O.prototype.Mq;chrome.cast.media.O.prototype.Kq=function(){};
  chrome.cast.media.O.prototype.queueRemoveItems=chrome.cast.media.O.prototype.Kq;chrome.cast.media.O.prototype.Jq=function(a){Sk(this,a)};chrome.cast.media.O.prototype.queueRemoveItem=chrome.cast.media.O.prototype.Jq;chrome.cast.media.O.prototype.Lq=function(){};chrome.cast.media.O.prototype.queueReorderItems=chrome.cast.media.O.prototype.Lq;chrome.cast.media.O.prototype.Gq=function(a,b,c,d){a=Sk(this,a);0>a||(0>b?d&&d(new chrome.cast.Error(chrome.cast.ad.INVALID_PARAMETER)):a==b&&c&&c())};
  chrome.cast.media.O.prototype.queueMoveItemToNewIndex=chrome.cast.media.O.prototype.Gq;chrome.cast.media.O.prototype.sr=function(a){return-1<this.supportedMediaCommands.indexOf(a)};chrome.cast.media.O.prototype.supportsCommand=chrome.cast.media.O.prototype.sr;chrome.cast.media.O.prototype.Uo=function(){return this.currentTime};chrome.cast.media.O.prototype.getEstimatedTime=chrome.cast.media.O.prototype.Uo;chrome.cast.media.O.prototype.Yh=function(){};
  chrome.cast.media.O.prototype.addUpdateListener=chrome.cast.media.O.prototype.Yh;chrome.cast.media.O.prototype.Zh=function(){};chrome.cast.media.O.prototype.addUpdateListenerWithContext=chrome.cast.media.O.prototype.Zh;chrome.cast.media.O.prototype.mj=function(){};chrome.cast.media.O.prototype.removeUpdateListener=chrome.cast.media.O.prototype.mj;chrome.cast.media.O.prototype.nj=function(){};chrome.cast.media.O.prototype.removeUpdateListenerWithContext=chrome.cast.media.O.prototype.nj;
  var Sk=function(a,b){return Nb(a.items,function(a){return a.itemId==b})};var Tk=function(a,b,c){this.sessionId=a;this.namespaceName=b;this.message=c};var Uk=function(a,b){this.type="SET_VOLUME";this.requestId=0;this.volume=a;this.expectedVolume=b||null};chrome.cast.U=function(a,b,c,d,e){this.sessionId=a;this.appId=b;this.displayName=c;this.statusText=null;this.appImages=d;this.receiver=e;this.senderApps=[];this.namespaces=[];this.media=[];this.status=chrome.cast.Wj.CONNECTED;this.transportId=""};v("chrome.cast.Session",chrome.cast.U);chrome.cast.U.prototype.ir=function(a,b,c){this.hm(null,a,b,c)};chrome.cast.U.prototype.setReceiverVolumeLevel=chrome.cast.U.prototype.ir;
  chrome.cast.U.prototype.hm=function(a,b,c,d){b=new Uk(new chrome.cast.Volume(b,null),this.receiver.volume);a.setReceiverVolume(this.sessionId,b,c,d)};chrome.cast.U.prototype.setReceiverVolumeLevelWithContext=chrome.cast.U.prototype.hm;chrome.cast.U.prototype.hr=function(a,b,c){this.gm(null,a,b,c)};chrome.cast.U.prototype.setReceiverMuted=chrome.cast.U.prototype.hr;
  chrome.cast.U.prototype.gm=function(a,b,c,d){a=new Uk(new chrome.cast.Volume(null,b),this.receiver.volume);null.setReceiverVolume(this.sessionId,a,c,d)};chrome.cast.U.prototype.setReceiverMutedWithContext=chrome.cast.U.prototype.gm;chrome.cast.U.prototype.leave=function(a,b){null.leaveSession(this.sessionId,a,b)};chrome.cast.U.prototype.leave=chrome.cast.U.prototype.leave;chrome.cast.U.prototype.stop=function(){};chrome.cast.U.prototype.stop=chrome.cast.U.prototype.stop;
  chrome.cast.U.prototype.pr=function(){};chrome.cast.U.prototype.stopWithContext=chrome.cast.U.prototype.pr;chrome.cast.U.prototype.sendMessage=function(){};chrome.cast.U.prototype.sendMessage=chrome.cast.U.prototype.sendMessage;chrome.cast.U.prototype.Yq=function(){};chrome.cast.U.prototype.sendMessageWithContext=chrome.cast.U.prototype.Yq;chrome.cast.U.prototype.Yh=function(){};chrome.cast.U.prototype.addUpdateListener=chrome.cast.U.prototype.Yh;chrome.cast.U.prototype.Zh=function(){};
  chrome.cast.U.prototype.addUpdateListenerWithContext=chrome.cast.U.prototype.Zh;chrome.cast.U.prototype.mj=function(){};chrome.cast.U.prototype.removeUpdateListener=chrome.cast.U.prototype.mj;chrome.cast.U.prototype.nj=function(){};chrome.cast.U.prototype.removeUpdateListenerWithContext=chrome.cast.U.prototype.nj;chrome.cast.U.prototype.to=function(){};chrome.cast.U.prototype.addMessageListener=chrome.cast.U.prototype.to;chrome.cast.U.prototype.uo=function(){};
  chrome.cast.U.prototype.addMessageListenerWithContext=chrome.cast.U.prototype.uo;chrome.cast.U.prototype.ro=function(){};chrome.cast.U.prototype.addMediaListener=chrome.cast.U.prototype.ro;chrome.cast.U.prototype.so=function(){};chrome.cast.U.prototype.addMediaListenerWithContext=chrome.cast.U.prototype.so;chrome.cast.U.prototype.Qq=function(){};chrome.cast.U.prototype.removeMediaListener=chrome.cast.U.prototype.Qq;chrome.cast.U.prototype.Rq=function(){};
  chrome.cast.U.prototype.removeMediaListenerWithContext=chrome.cast.U.prototype.Rq;chrome.cast.U.prototype.Sq=function(){};chrome.cast.U.prototype.removeMessageListener=chrome.cast.U.prototype.Sq;chrome.cast.U.prototype.Tq=function(){};chrome.cast.U.prototype.removeMessageListenerWithContext=chrome.cast.U.prototype.Tq;chrome.cast.U.prototype.tp=function(a){a.sessionId=this.sessionId};chrome.cast.U.prototype.loadMedia=chrome.cast.U.prototype.tp;chrome.cast.U.prototype.Fq=function(a){a.sessionId=this.sessionId};
  chrome.cast.U.prototype.queueLoad=chrome.cast.U.prototype.Fq;var Xk=function(a,b){if(!b.applications||1!=b.applications.length)return null;var c=b.applications[0];a=Vk(a);a=new chrome.cast.U(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||Wk(a)))return null;a.receiver.volume=b.volume;Ja(b.isActiveInput)&&(a.receiver.isActiveInput=b.isActiveInput);return a},Yk=function(a){var b=[];if(!a)return b;
  a&1&&b.push(chrome.cast.xd.VIDEO_OUT);a&2&&b.push(chrome.cast.xd.VIDEO_IN);a&4&&b.push(chrome.cast.xd.AUDIO_OUT);a&8&&b.push(chrome.cast.xd.AUDIO_IN);a&32&&b.push(chrome.cast.xd.MULTIZONE_GROUP);return b},Vk=function(a){var b=Aj(zj(),a.getId());return new chrome.cast.Ih(b,a.f.friendlyName,Yk(a.b))},Zk=function(a,b){if(a.statusText!=b.statusText)return!0;var c=a.namespaces||[],d=b.namespaces||[];if(c.length!=d.length)return!0;for(var e={index:0};e.index<c.length;e={index:e.index},e.index++)if(!d.some(function(a){return function(b){return b.name==
  c[a.index].name}}(e)))return!0;return a.receiver.volume.level!==b.receiver.volume.level||a.receiver.volume.muted!==b.receiver.volume.muted?!0:!1},$k=function(a){Ra(a)?a.forEach($k):Ua(a)&&Object.keys(a).forEach(function(b){null===a[b]?delete a[b]:(Ua(a[b])||Ra(a[b]))&&$k(a[b])})},al=function(a){return a.namespaces.some(function(a){return a.name==Ui})},Wk=function(a){return null!==a&&"MultizoneLeader"==a.appId},bl=function(a){return"E8C28D3C"==a||"00000000-0000-0000-0000-000000000000"==a};var cl=function(a,b,c){this.type=a;this.message=b;this.sequenceNumber=Ha(c)?c:-1;this.timeoutMillis=0;this.clientId=""};var dl=function(a,b){this.h=a;this.b=b;this.g=[];this.f=new nk},fl=function(a,b){return(a=el(a.b,b))?a.routeId:null};dl.prototype.listen=function(a,b){this.g[a]=b};var hl=function(a,b,c,d){kb(gl,"Sending to "+c);kb(gl,JSON.stringify(d));d.clientId=c;a.h.g.Kd(b,d)},il=function(a,b,c){var d=el(a.b,b);d&&d.b?hl(a,d.routeId,b,c):a.connect(b).then(function(d){d?(d=fl(a,b))?hl(a,d,b,c):gl.F("No route for "+b):gl.F("No connected client "+b)},null)};
  dl.prototype.connect=function(a){var b=el(this.b,a);if(null!=b&&b.b)return Promise.resolve(!0);b=fl(this,a);if(!b)return gl.F("No route for client "+a),Promise.resolve(!1);if(a=this.f.b.get(b,null))return a.ob.b;a=new zb;ok(this.f,new jl(b,a));return a.b};var gl=db("mr.cast.ApiMessenger"),jl=function(a,b){mk.call(this,a,3E4);this.ob=b};n(jl,mk);jl.prototype.b=function(){this.ob.resolve(!1)};var kl=function(a,b,c){this.g=a;this.b=b;this.f=c},ll=function(a){var b="cast-dial:"+a.g,c=new URLSearchParams;a.b&&c.set("dialPostData",a.b);a.f&&c.set("clientId",a.f);(a=c.toString())&&(b+="?"+a);return b};var ml=function(a,b,c,d,e,f,h,l,t,u){this.j=a;this.b=b||null;this.f=c||null;this.g=d||null;this.h=Ha(e)?e:null;this.C=f||null;this.A=h||null;this.s=l||!1;this.o=t||null;this.l=u||null},nl=function(a,b){return(a=a.match(b+"=([^/]*)"))?a[1]:null},pl=function(a){a=a.match(/__castAppId__=([^/]*)/g);return null==a?[]:Ib(Jb(a,function(a){a=nl(a,"__castAppId__");if(!a)return null;a=a.match(ol);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})},ql=function(a){return Jb(a.j,function(a){return a.appId})},rl=function(a){return a.f?a.f:chrome.cast.Yc.TAB_AND_ORIGIN_SCOPED},sl=function(a){var b=a.j.map(function(b){var c="cast:"+b.appId,e=new URLSearchParams;b.capabilities&&0<b.capabilities.length&&e.set("capabilities",b.capabilities.join(","));a.b&&e.set("clientId",a.b);a.f&&e.set("autoJoinPolicy",a.f);a.g&&e.set("defaultActionPolicy",a.g);null!=a.h&&e.set("launchTimeout",String(a.h));a.s&&e.set("invisibleSender",
  "true");a.o&&(e.set("broadcastNamespace",a.o),e.set("broadcastId",String(Math.random())));a.l&&e.set("broadcastMessage",encodeURIComponent(JSON.stringify(a.l)));return c+"?"+e.toString()});a.C&&b.push(ll(new kl(a.C,a.A,a.b)));return b},ul=function(a,b){a=ql(a);var c=tl(b);return Lb(a,function(a){return Qb(c,a)})},vl=function(a){try{var b=new URL(a)}catch(A){return null}if("https:"==b.protocol)if("https:"!=b.protocol||"google.com"!=b.host||"/cast"!=b.pathname)a=null;else{var c=b.hash;if((a=pl(c))&&
  0!=a.length){b=nl(c,"__castClientId__");var d=nl(c,"__castAutoJoinPolicy__"),e=nl(c,"__castDefaultActionPolicy__");var f=nl(c,"__castLaunchTimeout__");null==f?f=null:(f=Number(f),f=!isNaN(f)&&0<f?f:null);var h=nl(c,"__dialAppName__"),l=nl(c,"__dialPostData__");var t=nl(c,"__castInvisibleSender__");t=null===t?null:"true"==t;var u=nl(c,"__castBroadcastNamespace__");c=(c=nl(c,"__castBroadcastMessage__"))?JSON.parse(decodeURIComponent(c)):null;a=new ml(a,b,d,e,f,h,l,t,u,c)}else a=null}else if("cast:"==
  b.protocol){a=b.pathname;d=b.searchParams.get("capabilities");a={appId:a,capabilities:d?d.split(","):[]};l=b.searchParams;b=l.get("clientId");d=l.get("autoJoinPolicy");e=l.get("defaultActionPolicy");c=Number(l.get("launchTimeout"));if(isNaN(c)||0>=c)c=null;f="true"==l.get("invisibleSender");h=l.get("broadcastNamespace");l=(l=l.get("broadcastMessage"))?JSON.parse(decodeURIComponent(l)):null;a=new ml([a],b,d,e,c,void 0,void 0,f,h,l)}else a=null;return a},tl=function(a){return(a=vl(a))?ql(a):null},wl=
  function(a){return(a=vl(a))?a.b:null},ol=/(^\w+)(?:\(([\w, ]*)\))?$/;var xl={Ju:0,wu:1},yl={my:0,vn:1,Iw:2},zl={Nv:0,TIMEOUT:1,FAILED:2},Al={ju:0,qw:1,SEEK:2,pv:3,Ax:4,Yr:5},Bl=function(a){yb("MediaRouter.Cast.Session.Ended",a,yl)},Cl=function(a){yb("MediaRouter.Cast.Controller.ActionType",a,Al)},Dl=function(a){yb("MediaRouter.Cast.Session.Fail",a,zl)};var El=function(a,b,c){this.L=db("mr.MediaRouteController."+a);this.h=new mojo.Binding(mojo.MediaController,this,b);this.g=c;this.b=new mojo.MediaStatus({title:"",description:"",duration:new mojo.TimeDelta({microseconds:0}),current_time:new mojo.TimeDelta({microseconds:0})});this.C=!1;this.h.setConnectionErrorHandler(this.l.bind(this));this.g.ptr.setConnectionErrorHandler(this.l.bind(this))};El.prototype.l=function(){this.Oa();this.Ii()};
  El.prototype.Oa=function(){this.C||(this.C=!0,this.Hi(),this.h&&(this.h.close(),this.h=null),this.g&&(this.g.ptr.reset(),this.g=null))};var Fl=function(a){if(a.g)a.g.onMediaStatusUpdated(a.b)};g=El.prototype;g.Hi=function(){};g.Ii=function(){};g.play=function(){};g.pause=function(){};g.Ke=function(){};g.kc=function(){};g.seek=function(){};g.ei=function(a){a.close();throw Error("Not implemented");};El.prototype.connectHangoutsMediaRouteController=El.prototype.ei;El.prototype.seek=El.prototype.seek;
  El.prototype.setVolume=El.prototype.kc;El.prototype.setMute=El.prototype.Ke;El.prototype.pause=El.prototype.pause;El.prototype.play=El.prototype.play;var Gl=function(a){var b=new URL(a);a={};a.scheme=b.protocol.replace(":","");a.host=b.hostname;b=b.port?Number.parseInt(b.port,10):0;switch(a.scheme){case "http":a.port=b||80;break;case "https":a.port=b||443;break;default:throw Error("Scheme must be http or https");}a.suborigin="";return new mojo.Origin(a)},Hl=function(a){return new mojo.TimeDelta({microseconds:Math.floor(1E6*a)})};var Il=function(a,b,c,d){this.type=a;this.mediaSessionId=b;this.requestId=0;this.sessionId=c;this.currentTime=d},Kl=function(a,b,c,d,e){El.call(this,"CastRouteController",a,b);this.session=c;this.f=d;this.j=e;this.s=new Date;this.o=new Set;Jl(this);Cl(0)};n(Kl,El);
  var Jl=function(a){var b=Ll(a);b&&Ml(a,b);b&&a.j||!a.session.statusText||(a.b.title=a.session.statusText.substring(0,256));a.b.volume=null===a.session.receiver.volume.level?0:a.session.receiver.volume.level;a.b.is_muted=!!a.session.receiver.volume.muted;a.b.can_mute=a.session.receiver.volume.controlType!==chrome.cast.ak.FIXED;a.b.can_set_volume=a.b.can_mute;Fl(a)};g=Kl.prototype;g.Ii=function(){Nl(this.f.b,this.session.sessionId)};
  g.play=function(){var a=Ll(this);this.b.can_play_pause&&a&&this.b.play_state===mojo.MediaStatus.PlayState.PAUSED&&Ol(this.f,this.session,new Il("PLAY",a.mediaSessionId,this.session.sessionId));Pl(this,1)};g.pause=function(){var a=Ll(this);this.b.can_play_pause&&a&&this.b.play_state!==mojo.MediaStatus.PlayState.PAUSED&&Ol(this.f,this.session,new Il("PAUSE",a.mediaSessionId,this.session.sessionId));Pl(this,1)};
  g.seek=function(a){var b=Ll(this);a=a?a.microseconds/1E6:0;var c;if(c=this.b.can_seek&&b&&0<=a)c=this.b.duration,c=a<=(c?c.microseconds/1E6:0);c&&Ol(this.f,this.session,new Il("SEEK",b.mediaSessionId,this.session.sessionId,a));Pl(this,2)};g.Ke=function(a){this.b.can_mute&&a!==this.b.is_muted&&Ql(this.f,this.session,new chrome.cast.Volume(null,a));Pl(this,3)};g.kc=function(a){this.b.can_set_volume&&0<=a&&1>=a&&Ql(this.f,this.session,new chrome.cast.Volume(a));Pl(this,4)};
  var Ll=function(a){return a.session.media.find(function(a){return!a.idleReason})||null},Ml=function(a,b){a.j&&b.media&&b.media.metadata&&b.media.metadata.title&&(a.b.title=b.media.metadata.title.substring(0,256));a.b.can_play_pause=b.supportedMediaCommands.includes(chrome.cast.media.de.PAUSE);a.b.can_seek=b.supportedMediaCommands.includes(chrome.cast.media.de.SEEK);var c=b.playerState;a.b.play_state=c===chrome.cast.media.Se.PLAYING?mojo.MediaStatus.PlayState.PLAYING:c===chrome.cast.media.Se.PAUSED?
  mojo.MediaStatus.PlayState.PAUSED:mojo.MediaStatus.PlayState.BUFFERING;a.b.current_time=b.currentTime?Hl(b.playerState===chrome.cast.media.Se.PLAYING?b.currentTime+(new Date-a.s)/1E3:b.currentTime):Hl(0);a.b.duration=b.media&&b.media.duration?Hl(b.media.duration):Hl(0)},Pl=function(a,b){0==a.o.size&&Cl(5);a.o.has(b)||(Cl(b),a.o.add(b))};Kl.prototype.setVolume=Kl.prototype.kc;Kl.prototype.setMute=Kl.prototype.Ke;Kl.prototype.seek=Kl.prototype.seek;Kl.prototype.pause=Kl.prototype.pause;
  Kl.prototype.play=Kl.prototype.play;var Rl=function(a){this.f=a;this.m=db("mr.cast.SessionLauncher")},Sl=function(a,b,c){yb("MediaRouter.Cast.Session.Type",0,xl);return Ak(a.f,b,c).then(a.b.bind(a,c),function(a){a&&Bk==a?Dl(1):Dl(0);throw a;})};Rl.prototype.b=function(a,b){kb(this.m,"Got launch result from "+a.getId());if("LAUNCH_ERROR"==b.type)throw Dl(2),Error(b.reason);a=Xk(a,b.status);this.m.info("Launched session: "+a.sessionId);return a};var Tl=function(a){this.b=a;this.m=db("mr.cast.ReceiverStatusQuerier")},Ul=function(a,b){return(new ne(q(a.f,a,b),3500,5)).start().then(null,function(c){a.m.info("Failed to get receiver status from "+b.getId());throw c;})};Tl.prototype.f=function(a){this.m.info("Query receiver status: "+a.getId());return this.b.sendRequest(new lk,a,Si)};var Vl=function(a,b,c,d,e,f){this.g=a;this.l=b;this.j=c;this.b=d;this.o=e;this.h=f;this.f=new dl(f,c);this.w=new Tl(this.g);this.B=new Rl(this.g)};Vl.prototype.init=function(){this.j.init();this.f.listen("v2_message",this.A.bind(this));this.f.listen("app_message",this.s.bind(this));this.f.listen("leave_session",this.C.bind(this))};
  var Yl=function(a,b,c,d){Wl(a.b,b).slice().forEach(function(b){b!=d&&Xl(a,b,c)})},Xl=function(a,b,c){c.clientId=b;il(a.f,b,c)},Zl=function(a,b,c,d){c={receiver:Vk(c),action:d};Xl(a,b,new cl("receiver_action",c))};
  Vl.prototype.A=function(a){var b=a.message,c=b.sessionId;if(c){var d=$l(this.b,c);if(d)if(c=am(this.b,c))if(c=this.l.ja(c))switch(b.type){case "STOP":bm(this,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":case "PRECACHE":cm(this,a,c,d);break;case "SET_VOLUME":dm(this,a,c);break;default:em.F("Unknown request")}else fm(this,
  a,chrome.cast.ad.INVALID_PARAMETER,"No receiver");else fm(this,a,chrome.cast.ad.INVALID_PARAMETER,"No sink ID");else fm(this,a,chrome.cast.ad.INVALID_PARAMETER,"Unknown session ID")}else fm(this,a,chrome.cast.ad.INVALID_PARAMETER,"No session ID")};
  var fm=function(a,b,c,d){c=new chrome.cast.Error(c,d);gm(a,b,c)},gm=function(a,b,c){il(a.f,b.clientId,new cl("error",c,b.sequenceNumber))},bm=function(a,b,c){var d=b.message;xb("MediaRouter.Cast.Session.End");var e=d.sessionId,f=hm(a.b,e);f&&(f.j=!0);f=function(){ek(a,e,b)};a.g.sendRequest(d,c,Si,b.timeoutMillis,b.clientId).then(f,f)},cm=function(a,b,c,d){var e=b.message,f=e.type;f in kk&&(e.type=kk[f]);a.g.sendRequest(e,c,Ui,b.timeoutMillis,b.clientId,d.transportId).then(function(c){im(a,d,c);il(a.f,
  b.clientId,new cl("v2_message",c,b.sequenceNumber))},function(c){gm(a,b,c)})},dm=function(a,b,c){var d=b.message;delete d.sessionId;a.g.sendRequest(d,c,Si,b.timeoutMillis,b.clientId).then(function(){il(a.f,b.clientId,new cl("v2_message",null,b.sequenceNumber))},function(c){gm(a,b,c)})};
  Vl.prototype.s=function(a){var b=this,c=a.message,d=c.sessionId;if(d){var e=am(this.b,d);e?(e=this.l.ja(e))?(d=$l(this.b,d),Ob(d.namespaces,function(a){return a.name==c.namespaceName})?yk(this.o,e,c.namespaceName,c.message,a.clientId,d.transportId).then(function(){il(b.f,a.clientId,new cl("app_message",null,a.sequenceNumber))},function(){fm(b,a,chrome.cast.ad.CHANNEL_ERROR,"Channel to receiver not available")}):fm(this,a,chrome.cast.ad.INVALID_PARAMETER,"Invalid namespace")):em.F("No receiver from sinkId"):
  em.F("No sinkId from sessionId")}else em.F("No sessionId")};
  Vl.prototype.C=function(a){var b=this;em.info("Leave session");var c=hm(this.b,a.message);if(c){var d=a.clientId,e=el(this.j,d);if(e){var f=[],h=[],l=e.tabId,t=e.origin,u=e.autoJoinPolicy;c.f.forEach(function(a){var c=el(b.j,a);u==chrome.cast.Yc.TAB_AND_ORIGIN_SCOPED&&l==c.tabId&&t==c.origin||u==chrome.cast.Yc.ORIGIN_SCOPED&&t==c.origin?(c.f=!0,f.push(a)):h.push(a)});il(this.f,d,new cl("leave_session",null,a.sequenceNumber));f.forEach(function(a){(a=el(b.j,a))&&jm(b.h,a.routeId,!0,!0)});c.f=h}else em.F("No client record")}else em.F("No session")};
  var km=function(a,b,c){al(b)&&a.g.sendRequest(new lk,c,Ui,void 0,void 0,b.transportId).catch(Na)},Xj=function(a,b,c){var d=b.getId();em.info("Query status for "+d);Ul(a.w,b).then(function(e){lm(a,d,e);c&&(e=mm(a.b,d))&&km(a,e,b)},Na)},nm=function(a,b){if("*"==b.destinationId)return!0;b=b.destinationId;if(b==a.o.l||null!=el(a.j,b))return!0;em.info("Invalid destination "+b);return!1},rm=function(a,b,c){kb(em,function(){return"Cast message: "+JSON.stringify(c)});if(nm(a,c))if(c.namespace_==Ti||c.namespace_==
  Vi)(b=dk(a.b,b))&&b.b.forEach(function(b){var d=a.h,e=d.f.get(b);e&&e.df&&d.g.sh(b,c)});else{var d=JSON.parse(c.data),e=om(a,d);e=e?e.sourceId:void 0;switch(d.type){case "RECEIVER_STATUS":lm(a,b,d);break;case "MEDIA_STATUS":pm(a,b,c,e)}}else qm(a.o,b,c.destinationId,c.sourceId,!1)},om=function(a,b){a=pk(a.g.b,b.requestId);if(!a)return null;var c=a.ob;switch(b.type){case "LAUNCH_ERROR":case "INVALID_REQUEST":case "LOAD_CANCELLED":case "LOAD_FAILED":case "INVALID_PLAYER_STATE":delete b.requestId;c.reject(new chrome.cast.Error(chrome.cast.ad.SESSION_ERROR,
  b.reason||b.type,b));break;default:c.resolve(b)}return a},sm=function(a,b,c){kb(em,function(){return"App message: "+JSON.stringify(c)});if(b=mm(a.b,b)){var d;"*"==c.destinationId?d=Wl(a.b,b.sessionId):d=[c.destinationId];var e=new Tk(b.sessionId,c.namespace_,c.data);d.forEach(function(b){il(a.f,b,new cl("app_message",e))})}else em.F("No session for incoming app message")},tm=function(a,b){a.forEach(function(a){a.sessionId=b;var c=a.supportedMediaCommands,e=[];c&1&&e.push(chrome.cast.media.de.PAUSE);
  c&2&&e.push(chrome.cast.media.de.SEEK);c&4&&e.push(chrome.cast.media.de.STREAM_VOLUME);c&8&&e.push(chrome.cast.media.de.STREAM_MUTE);a.supportedMediaCommands=e});return a},im=function(a,b,c){b=b.sessionId;c.sessionId=b;c=tm(c.status,b);um(a.b,b,c);(a=hm(a.b,b))&&a.controller&&(a=a.controller,a.s=new Date,(c=Ll(a))?Ml(a,c):(a.j&&(a.b.title=""),a.b.can_play_pause=!1,a.b.can_seek=!1),Fl(a))},vm=function(a,b){if(b=mm(a.b,b)){b=b.sessionId;var c=hm(a.b,b);c&&c.j||ek(a,b)}},ek=function(a,b,c){c&&Xl(a,c.clientId,
  c);(c=hm(a.b,b))&&c.b.slice().forEach(function(b){jm(a.h,b,!0)});wm(a.b,b);xm(a.h)},lm=function(a,b,c){kb(em,"Receiver status for "+b);var d=c.status;if(d)if(c=a.l.ja(b)){d=Xk(c,d);var e=dk(a.b,b);e?d?d.sessionId==e.session.sessionId?(b=e.session,Zk(b,d)&&(kb(em,"Updating session "+d.sessionId),e.g&&(b.statusText=d.statusText),b.namespaces=d.namespaces,b.receiver.volume=d.receiver.volume,ym(a.h,e),Yl(a,b.sessionId,new cl("update_session",b)),e.controller&&Jl(e.controller))):(vm(a,b),Bl(1),zm(a.h,
  null,c,null,d)):(vm(a,b),Bl(1)):d&&zm(a.h,null,c,null,d)}else xb("MediaRouter.Cast.Error.Sink.Missing.From.Discovery.Service"),em.F("Got message from receiver "+b+", but sink is no longer available.")},pm=function(a,b,c,d){if(b=mm(a.b,b))if(c=JSON.parse(c.data))im(a,b,c),Yl(a,c.sessionId,new cl("v2_message",c),d)},Am=function(a,b){var c=Yk(b.b);return(b=Ob(a.j,function(a){return Mb(a.capabilities,function(a){return Qb(c,a)})}))?b.appId:ql(a)[0]},Bm=function(a,b,c){var d=vl(b);if(!d)return Promise.reject(Error("Invalid source "+
  b));var e=Am(d,c),f=new ob("MediaRouter.Cast.Session.Launch");return Sl(a.B,new chrome.cast.Vj(e,void 0,null==d.h?chrome.cast.timeout.requestSession:d.h),c).then(function(a){em.info("Launched session "+a.sessionId+" for appId "+e);f.b("Success");return a},function(a){em.error("Failed to session for appId "+e);f.b("Failure");throw a;})};
  Vl.prototype.createMediaRouteController=function(a,b,c){a=Cm(this.b,a);if(!a)return Error("Session not found for the route");var d=a.session;if(a.controller)return Error("Controller already exists for the route");var e=Dm(this,d.sessionId);if(!e)return Error("Sink not found for the route");a.controller=new Kl(b,c,d,this,a.g);km(this,d,e);return null};
  var Ol=function(a,b,c){var d=Dm(a,b.sessionId);d&&a.g.sendRequest(c,d,Ui,0,"",b.transportId).catch(function(a){em.F("Failed to send a media control request: "+a)})},Ql=function(a,b,c){c=new Uk(c);(b=Dm(a,b.sessionId))&&a.g.sendRequest(c,b,Si).catch(function(a){em.F("Failed to send a volume control request: "+a)})},Dm=function(a,b){return(b=am(a.b,b))?a.l.ja(b):null},em=db("mr.cast.ApiHandler");var Em=function(a){return"0F5096E8"==a||"85CDB22F"==a};var Fm=function(a,b,c,d,e){for(var f=[],h=4;h<arguments.length;++h)f[h-4]=arguments[h];var l=this;this.j=a;this.l=b;this.Ri=c;this.f=d;this.h=f;this.b=!1;this.g=function(a){for(var b=[],c=0;c<arguments.length;++c)b[c-0]=arguments[c];return l.Jo.apply(l,m(b))}};g=Fm.prototype;g.addListener=function(){this.b||(this.b=!0,this.f.addListener.apply(this.f,[this.g].concat(m(this.h))))};g.removeListener=function(){this.b&&(this.f.removeListener(this.g),this.b=!1)};
  g.Cg=function(a){for(var b=0;b<arguments.length;++b);return!0};g.Jo=function(a){for(var b=[],c=0;c<arguments.length;++c)b[c-0]=arguments[c];var d=this;og(this.j);if(!this.Cg.apply(this,m(b)))return!1;eg(this.Ri).then(function(a){return a.handleEvent.apply(a,[d.f].concat(m(b)))});return this.gi()};g.Aa=function(){return"mr.EventListener."+this.l};g.gb=function(){return[this.b]};g.fb=function(){cj(this)&&this.addListener()};g.gi=function(){};var Gm=null,Hm=null,Im=function(){Gm||(Gm=new Fm(2,"CastChannelMessageListener","mr.cast.ChannelService",chrome.cast.channel.onMessage));Hm||(Hm=new Fm(1,"CastChannelErrorListener","mr.cast.ChannelService",chrome.cast.channel.onError));return[Gm,Hm]};var Jm=function(){},Km=function(a){if(!a.startsWith("urn:x-org.chromium:media:route:"))return null;var b=a.substring(31);if(!b)return null;var c=b.match(/([^/]*)\/([^-/]*)-([^/]*)\/(.*)/);if(!c)return null;b=new Jm;b.g=a;a=k(c);a.next();b.b=a.next().value;b.h=a.next().value;b.j=a.next().value;b.f=a.next().value;return b};Jm.prototype.fa=function(){return this.f};var Lm=function(a,b,c,d,e,f){this.id=a;this.presentationId=b;this.sinkId=c;this.mediaSource=d;this.isLocal=e;this.description=f;this.iconUrl=null;this.allowStop=!0;this.customControllerPath=null;this.supportsMediaRouteController=!1;this.controllerType=mojo&&mojo.RouteControllerType&&mojo.RouteControllerType.kNone;this.forDisplay=!0;this.offTheRecord=!1;this.df=e;this.isOffscreenPresentation=!1},Mm=function(a,b,c,d,e,f){b=d&&tg(d)?a:"urn:x-org.chromium:media:route:"+a+"/"+b+"-"+c+"/"+d;return new Lm(b,
  a,c,d,e,f)};var Nm=function(a,b,c,d){c=Mm(c,"cast",b.getId(),a,d,"");c.supportsMediaRouteController=!0;mojo&&mojo.RouteControllerType&&(c.controllerType=d&&qg(a)&&b.b&1&&mojo.RouteControllerType.kMirroring?mojo.RouteControllerType.kMirroring:mojo.RouteControllerType.kGeneric);return c},Om=function(a,b){var c=b.ib.cc;c&&(b.description=Eg(c),a.displayName="",a.statusText="mirror_desktop"==c.f?"":c.g||"")};var Pm=function(a,b,c,d){return{namespace_:a,data:Ia(b)?b:JSON.stringify(b),sourceId:c,destinationId:d}};var Qm=function(a){this.type="CLOSE";this.reasonCode=a};var Sm=function(a){return(a=a.exec(Ec))?a[1]:""},Tm=function(){if(fh)return Sm(/Firefox\/([0-9.]+)/);if(gd||hd||fd)return Ad;if(jh)return $c()?Sm(/CriOS\/([0-9.]+)/):Sm(/Chrome\/([0-9.]+)/);if(kh&&!$c())return Sm(/Version\/([0-9.]+)/);if(gh||hh){var a=/Version\/(\S+).*Mobile\/(\S+)/.exec(Ec);if(a)return a[1]+"."+a[2]}else if(ih)return(a=Sm(/Android\s+([0-9.]+)/))?a:Sm(/Version\/([0-9.]+)/);return""}(),Um=function(a){return 0<=Cc(Tm,a)};var Wm=function(a){this.type="CONNECT";this.origin={};this.userAgent=Ec;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:Tm,platform:Vm(),systemVersion:b,connectionType:1};this.connType=a?0:2},Vm=function(){switch(Mf()){case "ChromeOS":return 5;case "Windows":return 3;case "Mac":return 4;case "Linux":return 6}return 0};var Xm=function(a){if(!chrome.runtime.lastError)return null;var b="chrome.cast.channel.send failed, chrome.runtime.lastError: "+(chrome.runtime.lastError.message||"Unknown error");a&&kb(a,b);return Error(b)};var Ym=function(){this.b=new Oj};Ym.prototype.init=function(){fj(this)};var Zm=function(a,b,c,d,e){if(!Rj(a.b,[b.channelId,c,d].join("#"))){var f=Pm(Ri,new Wm(e),c,d);chrome.cast.channel.send(b,f,a.f.bind(a));a.b.set([b.channelId,c,d].join("#"),e)}};Ym.prototype.f=function(){Xm($m)};
  var ak=function(a,b){a.b.rb().forEach(function(c){c.split("#")[0]==b.channelId.toString()&&a.b.remove(c)})},Wj=function(a,b,c){a.b.forEach(function(d,e){var f=e.split("#");f[0]==b.channelId.toString()&&(Zm(a,c,f[1],f[2],d),a.b.remove(e))})};Ym.prototype.Aa=function(){return"cast.VirtualConnectionManager"};Ym.prototype.gb=function(){var a=Tj(this.b);return[new an(a)]};Ym.prototype.fb=function(){var a=cj(this);if(a)for(var b in a.b)this.b.set(b,a.b[b])};Oa(Ym);
  var $m=db("mr.cast.VirtualConnectionManager"),an=function(a){this.b=a};var bn=function(a,b){this.j=b;this.l=a;this.f=new Oj;this.b=new Oj;this.g=Ym.Da();this.ja=null;this.h=new Oj};n(bn,ag);bn.prototype.handleEvent=function(a,b){for(var c=[],d=1;d<arguments.length;++d)c[d-1]=arguments[d];a==chrome.cast.channel.onMessage?this.s.apply(this,m(c)):a==chrome.cast.channel.onError&&this.o.apply(this,m(c))};bn.prototype.init=function(){this.g.init();fj(this);kg("mr.cast.ChannelService",this);Im().forEach(function(a){return a.addListener()})};
  var yk=function(a,b,c,d,e,f){e=e||a.l;f=f||"receiver-0";var h=gk(a,b);return h?cn(a,h,c,d,e,f):Promise.reject("Channel not found for "+b.getId())},qm=function(a,b,c,d,e){if(b=a.f.get(b))a=a.g,Rj(a.b,[b.channelId,c,d].join("#"))&&(a.b.remove([b.channelId,c,d].join("#")),c=Pm(Ri,new Qm(e?5:0),c,d),chrome.cast.channel.send(b,c,a.f.bind(a)))};
  bn.prototype.s=function(a,b){var c=this.b.get(a.channelId);if(c){var d=this.ja(c);if(d){if(Xi.hasOwnProperty(b.namespace_)){var e=JSON.parse(b.data);switch(e.type){case "CLOSE":this.g.b.remove([a.channelId,b.destinationId,b.sourceId].join("#"));return;case "RPC":break;default:kb(Vj,function(){return"Got message "+(e.type||e.responseType)+" "+("from "+d.getId())})}}else kb(Vj,"Got message in "+b.namespace_+" from "+d.getId());dn(this.j,d,b)}else Vj.F("Got message for unknown receiver (receiverId="+
  c+").")}else Vj.F("Got message for unknown channel (channelId="+a.channelId+").")};var en=function(a,b){var c=a.b.get(b.channelId);c&&(a.b.remove(b.channelId),a.f.remove(c))};bn.prototype.o=function(a,b){Vj.F(function(){return"Channel error: "+JSON.stringify(a)+(b?", "+JSON.stringify(b):"")});en(this,a)};
  var gk=function(a,b){b=b.getId();(a=a.f.get(b))||Vj.info("Channel not found for receiver: "+b);return a},cn=function(a,b,c,d,e,f){Zm(a.g,b,e,f,0==f.indexOf("receiver-0"));$k(d);var h=Pm(c,d,e,f);"object"===typeof d&&"RPC"==d.type||kb(Vj,function(){return"Channel is sending message: "+JSON.stringify(h)});return new Promise(function(c,d){chrome.cast.channel.send(b,h,function(b){b?b.errorState?(d(Error("Failed to send message")),en(a,b)):c(!0):(b=Xm(Vj||void 0),d(b))})})};bn.prototype.Aa=function(){return"cast.ChannelService"};
  bn.prototype.gb=function(){return[new fn(Tj(this.f),Tj(this.b),Tj(this.h))]};bn.prototype.fb=function(){var a=cj(this);a&&(Nj(this.f,a.f),Nj(this.b,a.b),Nj(this.h,a.g))};var Vj=db("mr.cast.ChannelService"),fn=function(a,b,c){this.f=a;this.b=b;this.g=c};var gn=function(a,b,c,d,e,f){this.routeId=a;this.clientId=b;this.appIds=c;this.autoJoinPolicy=d;this.origin=e;this.tabId=f;this.f=this.b=!1},hn=function(){this.b=[]};hn.prototype.init=function(){fj(this)};hn.prototype.sa=function(){return this.b.length};var el=function(a,b){return Ob(a.b,function(a){return a.clientId==b})},jn=function(a,b){return Ob(a.b,function(a){return a.routeId==b})},kn=function(a,b){a.b=Ib(a.b,function(a){return a.clientId!=b})};hn.prototype.Aa=function(){return"cast.ClientRecords"};
  hn.prototype.gb=function(){return[new ln(this.b)]};hn.prototype.fb=function(){var a=cj(this);a&&(this.b=a.b)};var ln=function(a){this.b=a};var mn=function(){this.requestId=0;this.type="GET_APP_AVAILABILITY";this.appId=[]};var nn=function(a,b){this.h=a;this.f=b;this.g=new Kk;this.b=new Oj};nn.prototype.init=function(){fj(this)};var on=function(a,b){var c=a.b.get(b);c&&(c.kj--,0<c.kj||(Kj(a.f.b.zb(!1),function(a){switch(Gj(a,b)){case "available":a.Qb[b]="available_rescan";break;case "unavailable":a.Qb[b]="unavailable_rescan"}}),a.b.remove(b)))};g=nn.prototype;
  g.ol=function(a){var b=this;Kj(this.b.zb(!0),function(c){a:{switch(Gj(a,c)){case "unknown":case "available_rescan":case "unavailable_rescan":var d=!0;break a}d=!1}if(d){var e=a.getId()+":"+c;b.g.contains(e)||(b.g.add(e),d=function(){b.g.remove(e)},(new ne(b.Do.bind(b,a,c),5500,3)).start().then(b.tm.bind(b,a,c),function(){b.m.error("Failed to get app availability response for "+a.getId()+", appId "+c+" after 3 attempts.");b.tm(a,c,"unknown")}).then(d,d))}})};
  g.tm=function(a,b,c){c!=Gj(a,b)&&(this.m.info(b+" on "+a.getId()+" is "+c),a.Qb[b]=c,Yj(this.f.h,a))};
  g.Do=function(a,b){var c=this,d=new mn;d.appId=[b];var e=new ob("MediaRouter.Cast.App.Availability");return this.h.sendRequest(d,a,Si,5E3).then(function(a){e.b("Success");kb(c.m,function(){return"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(d){e.b("Failure");c.m.error("checkAppAvailability_ failed for "+a.getId()+", appId "+b);
  throw d;})};g.Aa=function(){return"cast.AppDiscoveryService"};g.gb=function(){return[new pn(Tj(this.b))]};g.fb=function(){var a=cj(this);a&&Nj(this.b,a.b)};g.m=db("mr.cast.AppDiscoveryService");var pn=function(a){this.b=a};var qn=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 rn=function(a,b){this.f=[];this.b=[];this.sinkId=a;this.session=b;this.l=this.h=null;this.offTheRecord=this.j=!1;this.controller=null;this.g=!0},sn=function(){this.m=db("mr.cast.SessionRecords");this.b=[]};sn.prototype.init=function(){fj(this)};
  var wm=function(a,b){a.m.info("Removing session "+b);Nl(a,b);a.b=Ib(a.b,function(a){return a.session.sessionId!=b})},Wl=function(a,b){return(a=hm(a,b))?a.f:[]},mm=function(a,b){return(a=dk(a,b))?a.session:null},tn=function(a,b){return Ob(a.b,function(a){return Qb(a.f,b)})},Cm=function(a,b){return Ob(a.b,function(a){return Qb(a.b,b)})},un=function(a,b){return Ob(a.b,function(a){return null!=Ob(a.b,function(a){return Km(a).b==b})})},dk=function(a,b){return Ob(a.b,function(a){return a.sinkId==b||a.h==
  b})},hm=function(a,b){return Ob(a.b,function(a){return a.session.sessionId==b})},am=function(a,b){return(a=hm(a,b))?a.sinkId:null},$l=function(a,b){return(a=hm(a,b))?a.session:null},um=function(a,b,c){var d=$l(a,b);d&&(a=Ib(c,function(a){return a.playerState!=chrome.cast.media.Se.IDLE}),a.forEach(function(a){if(!a.media){var b=Ob(d.media,function(b){return b.mediaSessionId==a.mediaSessionId});b&&(a.media=b.media)}}),d.media=a)};sn.prototype.Aa=function(){return"cast.SessionRecords"};
  sn.prototype.gb=function(){return[new vn(this.b)]};sn.prototype.fb=function(){var a=cj(this);if(a)for(var b=0;b<a.b.length;b++){var c=a.b[b],d=new rn(c.sinkId,c.session);d.f=c.f;d.b=c.b;d.j=c.j;d.l=c.l;d.h=c.h;d.g=c.g;this.b.push(d)}};
  var Nl=function(a,b){(a=hm(a,b))&&a.controller&&(a.controller.Oa(),a.controller=null)},vn=function(a){var b=[];a=k(a);for(var c=a.next();!c.done;c=a.next()){c=c.value;var d=new rn(c.sinkId,c.session);d.f=c.f;d.b=c.b;d.j=c.j;d.l=c.l;d.h=c.h;d.offTheRecord=c.offTheRecord;d.g=c.g;b.push(d)}this.b=b};var wn=function(a,b,c){var d=Error.call(this);this.message=d.message;"stack"in d&&(this.stack=d.stack);this.name="RouteRequestError";this.message=b||"";if(c)this.stack=c;else if(Error.captureStackTrace)Error.captureStackTrace(this,wn);else if(b=Error().stack)this.stack=b;this.errorCode=a};n(wn,Error);var xn=function(a,b){this.sinks=a;this.origins=b||null},yn=new xn([]);var zn=function(a){this.A="sender-"+Ac();this.f=new Oj;this.s=null;fj(this);this.g=a;this.o=new hn;this.h=new sn;this.C=new bn(this.A,this);this.b=new Uj(this.C,this);this.w=new vk(this.C,this.A);this.l=null;this.j=new Vl(this.w,this.b,this.o,this.h,this.C,this);this.B=new Ok(this.b,this.w)};g=zn.prototype;g.getName=function(){return"cast"};
  g.Ya=function(a){a=a&&"boolean"===typeof a.enable_cast_sink_query?a.enable_cast_sink_query:!0;this.m.info("Query enabled: "+a);this.w.init();this.h.init();this.j.init();this.C.init();this.b.init();a&&(this.l=new nn(this.w,this.b),this.l.init())};g.jd=function(){return this.f.ga()};
  g.Wf=function(a){var b=this;if(null!=An(a))return new xn([]);var c=new Kk;Bn(a).forEach(function(a){ik(b.b,a).map(function(a){return a.f}).forEach(function(a){c.add(a)})});return new xn(c.ga(),-1!=a.indexOf("0F5096E8")?ug:null)};
  g.startObservingMediaSinks=function(a){var b=this,c=An(a);c?(this.m.info("Received broadcast request "+a),Kj(this.b.b.zb(!1),function(a){b.w.sendMessage(c,a,Wi).catch(function(a){b.m.error("Broadcast failed "+a.message)})})):this.l&&Bn(a).forEach(function(a){var c=b.l,d=c.b.get(a);d?d.kj++:c.b.set(a,{kj:1});c.m.info("Scanning sinks for app availability");Kj(c.f.b.zb(!1),c.ol,c)})};g.stopObservingMediaSinks=function(a){var b=this;null!=An(a)||this.l&&Bn(a).forEach(function(a){on(b.l,a)})};
  g.startObservingMediaRoutes=function(){};g.stopObservingMediaRoutes=function(){};g.ja=function(a){return(a=this.b.ja(a))?a.f:null};
  var Cn=function(a,b,c){a.m.error("Error launching.",c);jm(a,b.id,!1,!0,"error");c=new xf(qn,"warning");Bf(c,b.id);Cf(c,b.sinkId);a.g.ze(c)},Fn=function(a,b,c,d,e,f,h,l){zj().f=new wj(c.lc,c.Ob());var t=Nm(b,c,d,!0);t.forDisplay=!1;t.offTheRecord=e;a.f.set(t.id,t);a.g.wf(a,t);xm(a);(e=vl(b))&&e.b&&Dn(a,e,t.id,h,l);sg(b)||tg(b)?(t.ib={tabId:l,sessionId:"",Df:c.Ob()||"",Qd:c.lc||"",mr:c.f.friendlyName||""},tg(b)&&(t.isOffscreenPresentation=!0),a.g.Ji(a,t,d,function(e){return Hf(En(a,b,c,d,f,h,l,e))}).b.then(function(){var b=
  Cm(a.h,t.id);b.g=!1;Om(b.session,t);b.controller&&(b.controller.j=!1,Jl(b.controller))},function(b){Cn(a,t,b)})):En(a,b,c,d,f,h,l,t).then(null,function(b){Cn(a,t,b)});return Promise.resolve(t)},En=function(a,b,c,d,e,f,h,l){return Bm(a.j,Gn(b,c,e),c).then(function(e){zm(a,b,c,d,e,f,h,l);return l})};
  zn.prototype.createRoute=function(a,b,c,d,e,f,h){var l=this,t=this.b.ja(b);if(!t)return Gf(Error("No sink with ID "+b));var u=wl(a);if(u){setTimeout(function(){Zl(l.j,u,t,chrome.cast.Lf.CAST)},0);var A=function(){return Fn(l,a,t,c,d,e,f,h)},G=el(this.o,u);if(G)return Hf(this.terminateRoute(G.routeId).then(A,A));if(f&&h&&(b=Hn(this,a,f,h,d,e,b)))return b}return Hf(Fn(this,a,t,c,d,e,f,h))};
  var jm=function(a,b,c,d,e){d=void 0===d?!1:d;e=void 0===e?"closed":e;a.m.info("Remove route "+b);var f=jn(a.o,b);if(f){c=c||f.f;var h=f.clientId;a.m.info("Remove client "+h);for(var l=a.h,t=0;t<l.b.length;t++)Xb(l.b[t].f,h);kn(a.o,h)}if(h=Cm(a.h,b))Xb(h.b,b),In(a,h.b);if(l=a.f.get(b))if(l.df&&h&&(qm(a.C,l.sinkId,f?f.clientId:a.A,h.session.transportId,c),l.forDisplay&&f&&(a.s={bf:f,Zl:h})),a.f.remove(b),a.g.eg(l),xm(a),d)a.g.onPresentationConnectionClosed(b,e,"Remove route");else a.g.onPresentationConnectionStateChanged(b,
  "terminated")},ym=function(a,b){b.b.forEach(function(c){if(c=a.f.get(c)){var d=b.session;if(c.forDisplay){var e=Em(d.appId);e&&!c.isLocal?(c.description=d.statusText||"",d.displayName="",d.statusText=""):e||(c.description=d.statusText||d.displayName);b.controller&&Jl(b.controller)}a.g.ye(c)}})},Jn=function(a,b){Lb(b,function(b){b=a.f.get(b,null);if(!b||!b.mediaSource)return!1;var c=vl(b.mediaSource);c=c?c.s:!1;return b.isLocal&&!c})&&x(b,function(b){if(b=a.f.get(b,null))b.isLocal=!0})},In=function(a,
  b){var c=[],d=[],e=null;b.forEach(function(b){if(b=a.f.get(b)){b.forDisplay=!1;var f=vl(b.mediaSource);f&&Ob(ql(f),bl)||(b.df?(f=f?rl(f):null,e||f==chrome.cast.Yc.CUSTOM_CONTROLLER_SCOPED||(c.push(b),e=b.sinkId)):e&&e!=b.sinkId?c.push(b):d.push(b))}});x(0<c.length?c:d,function(a){a.forDisplay=!0})},Dn=function(a,b,c,d,e){var f=b.b;if(f&&!el(a.o,f)){a.m.info("Add client "+f);var h=ql(b);a.o.b.push(new gn(c,f,h,rl(b),d||null,Ha(e)?e:null))}},zm=function(a,b,c,d,e,f,h,l){var t=dk(a.h,c.getId());if(!t){var u=
  a.h;t=c.getId();u.m.info("Adding new session: "+t+", "+e.sessionId);var A=hm(u,e.sessionId);A?(Wk(e)?(A.l=e,A.h=t):Wk(A.session)&&(A.l=A.session,A.h=A.sinkId,A.session=e,A.sinkId=t),t=A):(t=new rn(t,e),u.b.push(t))}l&&l.isLocal&&l.ib&&(t.g=!1);var G=null!=b;if(!G&&bl(e.appId))return null;null==b?(A=new ml([{appId:e.appId,capabilities:e.capabilities}]),b=sl(A)[0]):A=vl(b);if(u=l){if(!a.f.get(u.id))return a.m.F("Route "+u.id+" not added"),u}else u=Nm(b,c,d||e.sessionId,G),a.f.set(u.id,u);d=u.id;a.m.info("Add route "+
  d);b=null;A&&(b=A.b,Dn(a,A,d,f,h));Qb(t.b,d)||t.b.push(d);u.df&&(f=a.C,h=b||a.A,d=e.transportId,A=!(A&&A.s),(G=gk(f,c))&&Zm(f.g,G,h,d,A));t.offTheRecord=u.offTheRecord;f=t.b;Jn(a,f);In(a,f);f=u;h=e.sessionId;Em(e.appId)?f.isLocal&&h&&f.ib?f.ib.sessionId=h:(f.description=e.statusText||"",e.displayName="",e.statusText=""):f.description=e.statusText||e.displayName;l?a.g.ye(u):a.g.wf(a,u);xm(a);if(l=b)Qb(t.f,b)?l=!1:(t.f.push(b),l=!0);l&&(a=a.j,il(a.f,b,new cl("new_session",e)),km(a,e,c));return u};
  zn.prototype.terminateRoute=function(a){var b=this,c=this.f.get(a);if(!c)return Promise.reject(new wn(3,"Route in Cast provider not found for routeId  "+a));var d=Cm(this.h,a);if(!d)return jm(this,a,!0),Promise.resolve();var e=d.session.sessionId,f=this.b.ja(c.sinkId);if(!f)return ek(this.j,e),Promise.resolve();(a=jn(this.o,a))&&Zl(this.j,a.clientId,f,chrome.cast.Lf.STOP);Bl(0);return new Promise(function(a){var c=function(){vm(b.j,f.getId());a()};b.w.sendRequest(new sk(e),f,Si).then(c,c)})};
  var Kn=function(a,b){var c=null;Lj(a.f.zb(!1),function(d){if(!d.df)return!1;var e=a.b.ja(d.sinkId);if(!e||!ul(b,Gn(d.mediaSource,e)))return!1;c=d;return!0});if(!c||!c.mediaSource)return null;var d=wl(c.mediaSource);if(!d)return null;var e=el(a.o,d);return e?(d=tn(a.h,d))?{bf:e,Zl:d}:null:null},Hn=function(a,b,c,d,e,f,h){var l=null;Lj(a.f.zb(!1),function(a){var b=a.ib;return b&&null!=b.tabId&&b.tabId==d&&qg(a.mediaSource)?(l=a,!0):!1});if(!l)return null;var t=function(){return a.createRoute(b,h||l.sinkId,
  "",e,f,c,null==d?void 0:d)};return Hf(a.terminateRoute(l.id).then(t,t))};g=zn.prototype;g.connectRouteByRouteId=function(a,b,c,d,e){if(!vl(a))return Gf(Error("Unsupported presentation URL"));if(!b)return Gf(Error("No routeId"));b=Km(b);b=hm(this.h,b.b);if(!b)return Gf(Error("No matching route"));var f=this.b.ja(b.sinkId);return f?(a=zm(this,a,f,c,b.session,d,e))?Ff(a):Gf(Error("Failed to create route")):Gf(Error("No sink"))};
  g.joinRoute=function(a,b,c,d,e,f){var h=vl(a);if(!h)return Gf(Error("Unsupported presentation URL"));if(b==chrome.cast.Dj){a:{var l=Kn(this,h);if(!l){if(!this.s||this.s.bf.origin!=e||this.s.bf.tabId!=f){l=null;break a}l=this.s}switch(rl(h)){case chrome.cast.Yc.PAGE_SCOPED:l=null;break a;case chrome.cast.Yc.ORIGIN_SCOPED:if(e!=l.bf.origin){l=null;break a}break;case chrome.cast.Yc.TAB_AND_ORIGIN_SCOPED:if(e!=l.bf.origin||f!=l.bf.tabId){l=null;break a}}l=hm(this.h,l.Zl.session.sessionId)}if(!l&&(h.g?
  h.g:chrome.cast.Eg.CREATE_SESSION)!=chrome.cast.Eg.CAST_THIS_TAB&&(d=Hn(this,a,e,f,c,d)))return d}else l=Ln(this,b);if(!l)return Gf(Error("No matching route"));if(l.offTheRecord!=c)return Gf(Error("Off the record mismatch"));d=this.b.ja(l.sinkId);if(!d)return Gf(Error("No sink"));a=zm(this,a,d,b,l.session,e,f);a.offTheRecord=c;return Ff(a)};g.detachRoute=function(a){jm(this,a,!1,!0)};
  g.gf=function(a){var b=this.b.ja(a);if(!b)throw Error("Cannot mirror with no sink.");var c=new Lg;b=b.b;b&1||(c.shouldCaptureVideo=!1);b&4||(c.shouldCaptureAudio=!1);c.shouldCaptureAudio&&!c.shouldCaptureVideo&&(c.minLatencyMillis=c.maxLatencyMillis,c.animatedLatencyMillis=c.maxLatencyMillis);c.senderSideLetterboxing=!0;Mg(c);Object.freeze(c);this.m.info(function(){return"Settings for "+a+": "+Kg(c)});if(!c.shouldCaptureAudio&&!c.shouldCaptureVideo)throw Error("Cannot start mirroring without video or audio capture");
  return c};g.te=function(){return"cast_streaming"};g.th=function(a){var b=this.f.get(a);b&&b.ib&&b.ib.cc&&(a=Cm(this.h,a))&&(Om(a.session,b),a.controller&&Jl(a.controller))};
  g.sendRouteMessage=function(a,b,c){var d=this;if(!c)return new Promise(function(a,c){"string"!==typeof b&&c(Error("Cannot send non-string messages via ApiHandler."));c=d.j.f;kb(gl,"Received: "+b);var e=JSON.parse(b),f=e.clientId;"client_connect"==e.type?(kb(gl,"App "+f),(e=el(c.b,f))?(e.b=!0,(c=pk(c.f,e.routeId))&&c.ob.resolve(!0)):gl.F("Client not found "+f)):fl(c,f)?(c=c.g[e.type])&&c(e):gl.F("No route for "+f);a()});var e=Cm(this.h,a);if(!e)return Promise.reject(Error("Not managing the route "+
  a));var f=this.b.ja(e.sinkId);if(!f)return Promise.reject(Error("Sink no longer accessible"));var h=(a=jn(this.o,a))?a.clientId:this.A;return new Promise(function(a){yk(d.C,f,c.namespace,b,h,e.session.transportId).then(a,a)})};g.sendRouteBinaryMessage=function(a){return Promise.reject(Error("Route "+a+" does not support sending binary data."))};g.Pf=function(a,b){var c=this.b.ja(b);if(!c)return!1;if(!this.l)return!0;a=Gn(a,c);return(a=tl(a))&&0!=a.length?Lb(a,function(a){return Yi(Gj(c,a))}):!1};
  g.af=function(a,b,c){var d=Bn(a);return d&&0!=d.length?b==chrome.cast.Dj?!0:c&&c.mediaSource?(a=tl(c.mediaSource),Lb(a,function(a){return Qb(d,a)})):void 0==b||Ln(this,b)?!0:!1:!1};
  var Gn=function(a,b,c){return vl(a)?a:sg(a)||tg(a)?(a={appId:0==(b.b&1)?"85CDB22F":"0F5096E8",capabilities:Yk(b.b)},sl(new ml([a],void 0,void 0,void 0,c))[0]):a},Bn=function(a){var b=[],c=vl(a);if(c)b=ql(c);else if(sg(a)||tg(a))rg(a)||b.push("85CDB22F"),b.push("0F5096E8");return b},An=function(a){var b=vl(a);if(!b)return null;a=Bn(a);var c=b.o||"";b=b.l;return c&&b?new qk(a,c,JSON.stringify(b)):null},Ln=function(a,b){return 0==b.indexOf(chrome.cast.Sj)?hm(a.h,b.substr(chrome.cast.Sj.length)):un(a.h,
  b)},dn=function(a,b,c){var d=a.B;if(Pk(d)&&Xi.hasOwnProperty(c.namespace_)){var e=b.Ob();if(e){var f=JSON.parse(c.data);if("RECEIVER_STATUS"===f.type){var h=f.status&&f.status.applications&&f.status.applications[0],l=f=null;h&&(h.appId&&(f=h.appId),h.sessionId&&(l=h.sessionId));h=d.f.get(e);d.f.set(e,new Oi(e,f,l));h&&h.appId===f||Qk(d)}}}a=a.j;b=b.getId();Xi.hasOwnProperty(c.namespace_)?rm(a,b,c):sm(a,b,c)},Yj=function(a,b){a.l&&a.l.ol(b);fk(a.B);a.g.Sc()};g=zn.prototype;g.Aa=function(){return"cast.Provider"};
  g.gb=function(){return[new Mn(this.A,Tj(this.f),this.s)]};g.fb=function(){var a=cj(this);a&&(this.A=a.g,Nj(this.f,a.f),this.s=a.b)};g.searchSinks=function(){return ab()};g.createMediaRouteController=function(a,b,c){return(a=this.j.createMediaRouteController(a,b,c))?Promise.reject(a):Promise.resolve()};g.provideSinks=function(a){ck(this.b,a)};var xm=function(a){var b=a.jd().some(function(a){return a.isLocal});a.g.Af(a.Aa(),b)};zn.prototype.m=db("mr.CastProvider");
  var Mn=function(a,b,c){this.g=a;this.f=b;this.b=c};var Nn=function(){this.b=[]};Nn.prototype.listen=function(a,b,c){this.b.push({type:a,bb:b,target:c})};var On=function(a,b,c){var d=a.b.findIndex(function(a){return"internal_message"==a.type&&a.bb==b&&a.target==c});-1!=d&&a.b.splice(d,1)},Pn=function(a,b){a.b.forEach(function(a){a.type==b.type&&Promise.resolve().then(function(){return a.bb.call(a.target,b)})})};var Qn=function(a,b,c,d){b="["+b+"]: "+c+" "+d.responseURL+" => "+d.status+" ("+d.statusText+")";200<=d.status&&299>=d.status?a.info(b):kb(a,b)};var Rn=function(){this.name="unknown";this.state="error";this.b=null;this.allowStop=!0;this.resource=null;this.extraData={}},Sn=function(){var a=Error.call(this);this.message=a.message;"stack"in a&&(this.stack=a.stack)};n(Sn,Error);var Un=function(a){if(void 0===b){Tn||(Tn=new pe(10,2E3));var b=Tn}this.f=a;this.b=b;this.m=db("mr.dial.Client")};
  Un.prototype.launchApp=function(a,b){var c=this;return this.b.send(Vn(this,a),"POST",b,{timeoutMillis:15E3}).then(function(a){return Wn(c,"launchApp","POST",a)})};
  var Yn=function(a,b){return Xn(a,b).then(function(c){return c.resource?c.resource:(a.m.F("stopApp: Resource path for not available for app "+b+": using fallback path."),"run")},function(){a.m.F("stopApp: getAppInfo failed: using fallback path.");return"run"}).then(function(c){return a.b.send(Vn(a,b)+"/"+c,"DELETE")}).then(function(b){return Wn(a,"stopApp","DELETE",b)})},Xn=function(a,b){return a.b.send(Vn(a,b),"GET",void 0,{rl:3}).then(function(c){Qn(a.m,"GetAppInfo","GET",c);if(!(200<=c.status&&
  299>=c.status)){if(404==c.status)throw new Sn;throw Error("Response error: "+c.status);}c=c.responseText;c=(new DOMParser).parseFromString(c,"text/xml");c=c.getElementsByTagNameNS("http://www.w3.org/1999/xhtml","parsererror").length?null:c;if(!c)throw a.m.info("Invalid or empty response"),Error("Invalid or empty response");var d=c.getElementsByTagName("service");if(!d||1!=d.length)throw a.m.info("Invalid GET response (invalid service)"),Error("Invalid GET response (invalid service)");c=new Rn;for(var e=
  0,f=d[0].childNodes.length;e<f;e++){var h=d[0].childNodes[e];if("state"==h.nodeName){a:switch(h.textContent){case "running":h="running";break a;case "stopped":h="stopped";break a;default:h="error"}c.state=h}else"name"==h.nodeName?c.name=h.textContent:"link"==h.localName?c.resource=h.getAttribute("href"):"options"==h.nodeName?c.allowStop="false"!=h.getAttribute("allowStop"):c.extraData[h.nodeName]=h.innerHTML}if("unknown"==c.name)throw a.m.info("GET response missing name value"),Error("GET response missing name value");
  if(c.name!=b)throw a.m.info("GET app name mismatch"),Error("GET app name mismatch");if("error"==c.state)throw a.m.info("GET response missing state value"),Error("GET response missing state value");if((d=/installable=(.+)/.exec(c.state))&&d[1])c.state="installable",c.b=d[1];else if("running"!=c.state&&"stopped"!=c.state)throw a.m.info("GET response has invalid state value"),Error("GET response has invalid state value");return c})},Vn=function(a,b){a=a.f.yd;"/"!=a.charAt(a.length-1)&&(a+="/");return a+
  b},Wn=function(a,b,c,d){return new Promise(function(e,f){Qn(a.m,b,c,d);200<=d.status&&299>=d.status?e():f(Error(d.statusText))})},Tn=null;var Zn=function(a,b){this.uc=a;this.appName=b};var $n=function(a){this.b=new Map;this.f=a};$n.prototype.init=function(){fj(this)};$n.prototype.clear=function(){this.b.clear()};$n.prototype.add=function(a){if(!this.b.get(a.uc.id)){this.b.set(a.uc.id,a);var b=this.f;ao(b);b.h.wf(b,a.uc)}};var bo=function(a,b){a=k(a.b);for(var c=a.next();!c.done;c=a.next())if(c=k(c.value),c.next(),c=c.next().value,c.uc.sinkId==b)return c;return null},eo=function(a,b){var c=a.b.get(b);c&&(a.b.delete(b),co(a.f,c))};
  $n.prototype.jd=function(){return Array.from(this.b.values(),function(a){return a.uc})};$n.prototype.Aa=function(){return"dial.ActivityRecords"};$n.prototype.gb=function(){return[Array.from(this.b)]};$n.prototype.fb=function(){var a=cj(this);a&&(this.b=new Map(a))};var fo={tt:0,hx:1,Lv:2,st:3},go=function(a){yb("MediaRouter.Dial.Create.Route",a,fo)};var ho=function(a){this.g=a;this.m=db("mr.dial.SinkDiscoveryService");this.b=new Map;this.f={Nf:0,cg:0};this.h=0};ho.prototype.init=function(){fj(this)};
  var ko=function(a,b){a.m.info("addSinks returned "+b.length+" sinks");kb(a.m,function(){return"....the list is: "+JSON.stringify(b)});var c=new Set(a.b.keys());b.forEach(function(b){var d=b.sink_id,e=b.extra_data.dial_media_sink,f=io.test(e.model_name);b=new Cj(b.name,d);b.Wb=e.ip_address.address_bytes?e.ip_address.address_bytes.join("."):e.ip_address.address.join(".");b.yd=e.app_url.url;b.lc=e.model_name;b.ee=!f;jo(a,b);c.delete(b.getId())});var d=[];c.forEach(function(b){var c=a.b.get(b);d.push(c);
  a.b.delete(b)});0<d.length&&a.g.Gi(d);var e=a.b.size;a.f={Nf:e,cg:e}},jo=function(a,b){kb(a.m,"mayAddSink, id = "+b.getId());var c=a.b.get(b.getId());c?c.update(b)&&(kb(a.m,"Updated sink "+c.getId()),a.g.oh(c)):(kb(a.m,function(){return"Adding new sink "+b.getId()+": "+("name = "+b.mc.friendlyName+(b.Wb?", ip = "+b.Wb:"")+(b.lc?", model = "+b.lc:"")+", apps = "+JSON.stringify(b.Qb))}),a.b.set(b.getId(),b),a.g.Fi(b))};ho.prototype.ja=function(a){return this.b.get(a)||null};
  var mo=function(a,b){var c=[];a.b.forEach(function(a){"available"==Dj(a,b)&&c.push(a.mc)});return new xn(c,lo[b])};ho.prototype.se=function(){return this.f};ho.prototype.Aa=function(){return"dial.DialSinkDiscoveryService"};ho.prototype.gb=function(){return[new no(Array.from(this.b),this.f),{deviceCountMetricsRecordTime:this.h}]};
  ho.prototype.fb=function(){var a=cj(this);if(a){for(var b=k(a.sinks),c=b.next();!c.done;c=b.next())c=c.value,this.b.set(c[0],Ej(c[1]));this.f=a.deviceCounts}if(a=dj(this))this.h=a.deviceCountMetricsRecordTime};
  var lo={YouTube:"https://tv.youtube.com https://tv-green-qa.youtube.com https://tv-release-qa.youtube.com https://web-green-qa.youtube.com https://web-release-qa.youtube.com https://www.youtube.com".split(" "),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"]},io=/Eureka Dongle|Chromecast Audio|Chromecast Ultra/i,
  no=function(a,b){this.sinks=a;this.deviceCounts=b};var oo=function(a){return Promise.all(a.map(function(a){return a.then(function(a){return{Hd:!0,value:a}},function(a){return{Hd:!1,reason:a}})}))};var po=function(a,b){this.m=db("mr.dial.AppDiscoveryService");this.b=new Set;this.f=a;this.l=b;this.j=new Map;this.o=new Map;this.g=null;this.h=!1};po.prototype.init=function(){fj(this)};po.prototype.start=function(){this.m.info("Starting periodic scanning.");this.h||(this.h=!0,qo(this))};po.prototype.stop=function(){this.m.info("Stopping periodic scanning.");this.h&&(this.h=!1,this.g&&(clearTimeout(this.g),this.g=null),this.j.clear())};
  var qo=function(a){a.m.info("Start app status scan.");var b=[];Array.from(a.f.b.values()).forEach(function(c){b.push.apply(b,ro(a,c))});Array.from(a.l.b.values()).forEach(function(c){b.push(so(a,c))});oo(b).then(function(){a.h&&!a.g&&(kb(a.m,"Scan complete; scheduling for next scan."),a.g=setTimeout(function(){kb(a.m,"Start app status scan (timer-based)");a.g=null;qo(a)},6E4))})},ro=function(a,b){if(!b.ee)return[];for(var c=[],d=k(a.b),e=d.next();!e.done;e=d.next())c.push(a.s(e.value,b));return c};
  po.prototype.s=function(a,b){var c=this;if("unknown"!=Dj(b,a)&&36E5>Date.now()-(b.ah[a]||0)||!b.ee)return Promise.resolve();kb(this.m,"Querying "+b.getId()+" for "+a+" to update app status");return to(this,b,a).then(function(d){a:if("Netflix"==d.name)d=!d.extraData||"websocket"!=d.extraData.capabilities||"running"!=d.state&&"stopped"!=d.state?"unavailable":"available";else switch(d.state){case "running":case "stopped":d="available";break a;default:d="unavailable"}uo(c,b,a,d)},function(d){d instanceof
  Sn?uo(c,b,a,"unavailable"):(c.m.F("Failed to process app availability; "+b.getId()+" does not support app availability"),b.ee=!1)})};
  var so=function(a,b){var c=a.f.ja(b.uc.sinkId);if(!c)return a.m.F("Activity refers to nonexistent sink: "+b.uc.id),Promise.resolve();if(!c.ee)return Promise.resolve();var d=b.appName;kb(a.m,"Querying "+c.getId()+" for "+d+" to update activity");return to(a,c,d).then(function(b){"running"!=b.state&&vo(a,c,d)},function(){return vo(a,c,d)})},wo=function(a,b){var c=a.o.get(b.getId());c||(c=new Un(b),kb(a.m,"Created DIAL client for "+b.getId()),a.o.set(b.getId(),c));return c},to=function(a,b,c){var d=
  xo(b,c),e=a.j.get(d);if(e)return e;e=Xn(wo(a,b),c);a.j.set(d,e);b=function(){a.j.delete(d)};e.then(b,b);return e},xo=function(a,b){return a.getId()+":"+b},uo=function(a,b,c,d){kb(a.m,"Got app status "+d+" from "+b.getId()+" for "+c);var e=Dj(b,c);b.Qb[c]=d;b.ah[c]=Date.now();d!=e&&a.f.g.oh(b)},vo=function(a,b,c){(b=bo(a.l,b.getId()))&&b.appName==c&&eo(a.l,b.uc.id)},yo=function(a,b){return Array.from(a.f.b.values()).some(function(a){return"unknown"==Dj(a,b)})};po.prototype.Aa=function(){return"dial.AppDiscoveryService"};
  po.prototype.gb=function(){return[Array.from(this.b)]};po.prototype.fb=function(){var a=cj(this);this.b=new Set(a||[])};var zo=function(a,b){this.appName=a;this.launchParameter=void 0===b?"":b},Co=function(a){try{var b=new URL(a)}catch(c){return Ao.info("Invalid URL: "+a),null}switch(b.protocol){case "dial:":a:if(a=b.pathname,a.match(/^\w+$/)){if(b=b.searchParams.get("postData")||void 0)try{b=rj(b)}catch(c){Ao.F("Invalid base64 encoded postData:"+b);a=null;break a}a=new zo(a,b)}else Ao.F("Invalid app name: "+a),a=null;return a;case "https:":return Bo(b);default:return kb(Ao,"Unhandled protocol: "+b.protocol),null}},
  Bo=function(a){var b=a.hash;if(!b)return null;a=(a=Do.exec(b))?a[1]:null;if(!a)return null;a=decodeURIComponent(a);if(b=(b=Eo.exec(b))?b[1]:void 0)try{b=rj(b)}catch(c){return Ao.F("Invalid base64 encoded postData:"+b),null}return new zo(a,b)},Ao=db("mr.dial.PresentationUrl"),Do=/__dialAppName__=([A-Za-z0-9-._~!$&'()*+,;=%]+)/,Eo=/__dialPostData__=([A-Za-z0-9]+={0,2})/;var Fo=function(a,b){this.h=a;this.f=b||new ho(this);this.g=new $n(this);this.b=null;this.m=db("mr.DialProvider")};g=Fo.prototype;g.getName=function(){return"dial"};g.se=function(){return this.f.se()};g.Ya=function(a){a=a&&0==a.enable_dial_sink_query?!1:!0;this.m.info("Dial sink query enabled: "+a+"...");this.g.init();this.f.init();a?(this.b=this.b||new po(this.f,this.g),this.b.init()):this.b=null;ao(this)};
  g.Wf=function(a){if(!this.b)return yn;kb(this.m,"GetAvailableSinks for "+a);return(a=Co(a))?mo(this.f,a.appName):yn};g.startObservingMediaSinks=function(a){if(this.b){var b=Co(a);if(b){a=this.b;b=b.appName;if(!a.b.has(b)||yo(a,b))a.b.add(b),0!=a.f.b.size&&(a.h?Array.from(a.f.b.values()).forEach(a.s.bind(a,b)):a.start());ao(this)}}};g.stopObservingMediaSinks=function(a){this.b&&(a=Co(a))&&(this.b.b.delete(a.appName),Go(this))};g.startObservingMediaRoutes=function(){ao(this)};
  g.stopObservingMediaRoutes=function(){Go(this)};var Go=function(a){a.b&&(0==a.f.b.size||0==a.b.b.size&&0==a.g.b.size)&&a.b.stop()},ao=function(a){a.b&&0<a.f.b.size&&(0<a.b.b.size||0<a.g.b.size)&&a.b.start()};g=Fo.prototype;g.ja=function(a){return(a=this.f.ja(a))?a.mc:null};g.jd=function(){return this.g.jd()};
  g.createRoute=function(a,b,c,d){var e=this,f=this.f.ja(b);if(!f)return go(0),Gf(Error("Unkown sink: "+b));zj().f=new wj(f.lc,f.Ob());var h=Co(a);if(!h)return Gf(Error("No app name set."));var l=h.appName,t=new Un(f);return Hf(Xn(t,l).then(function(a){if("running"==a.state)return Yn(t,l)}).then(function(){return t.launchApp(l,h.launchParameter)}).then(function(){return Ho(e,b,a,l,c,d)}).catch(function(a){go(3);throw a;}))};g.joinRoute=function(){return Gf(Error("Not supported"))};
  g.connectRouteByRouteId=function(){return Gf(Error("Not supported"))};g.detachRoute=function(){};var Ho=function(a,b,c,d,e,f){go(1);b=Mm(e,a.getName(),b,c,!0,d);b.offTheRecord=f;a.g.add(new Zn(b,d));return b};Fo.prototype.Fi=function(a){this.h.onSinkAvailabilityUpdated(this,1);this.b&&(ao(this),ro(this.b,a));this.h.Sc();zj().b=new wj(a.lc,a.Ob())};
  Fo.prototype.Gi=function(a){var b=this;if(0==this.f.b.size)this.h.onSinkAvailabilityUpdated(this,0);Go(this);a.forEach(function(a){var c=b.g;a=a.getId();if(a=bo(c,a))c.b.delete(a.uc.id),co(c.f,a)});this.h.Sc()};Fo.prototype.oh=function(){this.h.Sc()};var co=function(a,b){b=b.uc;if(b.isLocal)a.h.onPresentationConnectionStateChanged(b.id,"terminated");Go(a);a.h.eg(b)};g=Fo.prototype;
  g.terminateRoute=function(a){var b=this.g.b.get(a)||null;if(!b)return Promise.reject(new wn(3,"Route in DIAL provider not found for routeId "+a));eo(this.g,a);return(a=this.f.ja(b.uc.sinkId))?Yn(new Un(a),b.appName):Promise.reject(new wn(3,"Sink in DIAL provider not found for sinkId "+b.uc.sinkId))};g.gf=function(){throw Error("Not implemented.");};g.te=function(){return null};g.th=function(){};g.sendRouteMessage=function(){return Promise.reject(Error("DIAL sending messages is not supported"))};
  g.sendRouteBinaryMessage=function(){return Promise.reject(Error("DIAL sending messages is not supported"))};g.Pf=function(a,b){b=this.f.ja(b);return!b||sg(a)?!1:(a=Co(a))?"available"==Dj(b,a.appName):!1};g.af=function(){return!1};g.searchSinks=function(){return ab()};g.createMediaRouteController=function(){return ab()};g.provideSinks=function(a){ko(this.f,a)};var Io=function(a){this.o=new ho(this);this.g=new Oj;this.f=a;this.l=this.j=0;this.h=new Kk;this.b=new Fo(this,this.o)};g=Io.prototype;g.Aa=function(){return"cast.DialProviderWrapper"};g.gb=function(){return[new Jo(Tj(this.g),this.j,this.l,this.h.ga())]};g.fb=function(){var a=cj(this);a&&(Nj(this.g,a.f),this.j=a.sequenceNumber,this.l=a.g,Jk(this.h,a.b))};g.getName=function(){return this.b.getName()};g.Ya=function(a){this.b.Ya(a);fj(this)};g.jd=function(){return this.b.jd()};
  g.Wf=function(a){return(a=Ko(a))?this.b.Wf(a):yn};g.startObservingMediaSinks=function(a){(a=Ko(a))&&this.b.startObservingMediaSinks(a)};g.stopObservingMediaSinks=function(a){(a=Ko(a))&&this.b.stopObservingMediaSinks(a)};g.startObservingMediaRoutes=function(a){(a=Ko(a))&&this.b.startObservingMediaRoutes(a)};g.stopObservingMediaRoutes=function(a){(a=Ko(a))&&this.b.stopObservingMediaRoutes(a)};g.ja=function(a){return this.b.ja(a)};
  var No=function(a,b,c,d,e){var f=Ko(b);if(!f)return Promise.reject(Error("Invalid source"));var h=Co(f),l=a.o.ja(c);if(!l)return Promise.reject(Error("Attempting custom launch with closed route"));var t=h.appName;if(!t)return Promise.reject(Error("No app name given"));var u=Lo(b);return u?Xn(new Un(l),t).then(function(f){var A=Ho(a.b,c,b,t,e,d);f={routeId:A.id,sinkId:l.getId(),appName:t,ik:f,launchParameter:h.launchParameter,session:null,clientId:null};a.g.set(A.id,f);var V=Mo(a,f.sinkId),Q=new cl("receiver_action",
  {receiver:V,action:chrome.cast.Lf.CAST});Q.clientId=u;a.f.Kd(f.routeId,Q);Q=chrome.cast.U;var ha=String(a.l);a.l=(a.l+1)%9007199254740992;V=new Q(ha,"",f.appName,[],V);f.session=V;f.clientId=u;V=new cl("new_session",V);V.clientId=u;a.f.Kd(f.routeId,V);return A}):Promise.reject(Error("No client ID"))};Io.prototype.createRoute=function(a,b,c,d,e,f,h){return a.startsWith("cast-dial:")||Oo.test(a)?Hf(No(this,a,b,d,c)):this.b.createRoute(a,b,c,d,e,f,h)};
  Io.prototype.terminateRoute=function(a){var b=this.g.get(a);if(b&&b.session&&b.clientId){var c={receiver:Mo(this,b.sinkId),action:chrome.cast.Lf.STOP};c=new cl("receiver_action",c);c.clientId=b.clientId;this.f.Kd(b.routeId,c);this.f.onPresentationConnectionStateChanged(b.routeId,"terminated")}return this.b.terminateRoute(a)};
  Io.prototype.sendRouteMessage=function(a,b,c){var d=JSON.parse(b);switch(d.type){case "client_connect":return b=d.clientId,(a=this.g.get(a))?(c=Mo(this,a.sinkId),c.receiverType=chrome.cast.Ng.DIAL,c=new cl("custom_dial_launch",new chrome.cast.Hj(c,a.ik.state,a.ik.extraData)),c.clientId=b,b=this.j,this.j=(this.j+1)%9007199254740992,c.sequenceNumber=b,this.h.add(c.sequenceNumber),this.f.Kd(a.routeId,c),a=Promise.resolve()):a=Promise.reject(Error("Unknown route")),a;case "custom_dial_launch":if(this.h.contains(d.sequenceNumber))return this.h.remove(d.sequenceNumber),
  b=d.message,(a=this.g.get(a))?b&&!b.doLaunch?a=Promise.resolve():(c=this.o.ja(a.sinkId))?(c=new Un(c),d=a.launchParameter,d=(b?b.launchParameter:null)||d,a=c.launchApp(a.appName,d)):a=Promise.reject(Error("Custom launch response for sink that no longer exists")):a=Promise.reject(Error("Unknown route")),a;break;case "v2_message":if("STOP"==d.message.type)return this.terminateRoute(a),Promise.resolve()}return this.b.sendRouteMessage(a,b,c)};
  Io.prototype.sendRouteBinaryMessage=function(a){return Promise.reject(Error("Route "+a+" does not support sending binary data."))};var Mo=function(a,b){a=a.o.ja(b);b=Aj(zj(),b);b=new chrome.cast.Ih(b,a.mc.friendlyName);b.ipAddress=a.Ob();b.receiverType=chrome.cast.Ng.DIAL;return b};g=Io.prototype;g.gf=function(a){return this.b.gf(a)};g.te=function(a){return this.b.te(a)};g.th=function(){};g.Pf=function(a,b){return a.startsWith("cast-dial:")||Oo.test(a)||this.b.Pf(a,b)};
  g.af=function(a,b,c){return this.b.af(a,b,c)};g.connectRouteByRouteId=function(a,b,c,d,e){return this.b.connectRouteByRouteId(a,b,c,d,e)};g.joinRoute=function(a,b,c,d,e,f){return this.b.joinRoute(a,b,c,d,e,f)};g.detachRoute=function(a){this.g.remove(a);this.b.detachRoute(a)};g.Sc=function(){this.f.Sc()};g.onSinkAvailabilityUpdated=function(a,b){this.f.onSinkAvailabilityUpdated(a,b)};g.wf=function(a,b){this.f.wf(this,b)};g.eg=function(a){this.f.eg(a)};g.ye=function(a){this.f.ye(a)};g.vi=function(){};
  g.getMirroringServiceHostForTab=function(){};g.getMirroringServiceHostForDesktop=function(){};g.getMirroringServiceHostForOffscreenTab=function(){};g.Kd=function(a,b){this.f.Kd(a,b)};g.onPresentationConnectionStateChanged=function(a,b){this.f.onPresentationConnectionStateChanged(a,b)};g.onPresentationConnectionClosed=function(a,b,c){this.f.onPresentationConnectionClosed(a,b,c)};g.oi=function(a){return this.f.oi(a)};g.ri=function(){return this.f.ri()};g.ze=function(a){this.f.ze(a)};
  g.sh=function(a,b){this.f.sh(a,b)};g.Wi=function(a){this.f.Wi(a)};g.Fi=function(a){this.b.Fi(a)};g.Gi=function(a){this.b.Gi(a)};g.oh=function(a){this.b.oh(a)};g.Ji=function(){};g.jl=function(){};g.searchSinks=function(a,b){return this.b.searchSinks(a,b)};g.provideSinks=function(a){this.b.provideSinks(a)};g.createMediaRouteController=function(){return ab()};g.Af=function(a,b){return this.f.Af(a,b)};g.se=function(){return this.b.se()};
  var Ko=function(a){try{var b=new URL(a)}catch(e){return null}if("dial:"==b.protocol)return a;if("cast-dial:"==b.protocol){var c=b;a="cast-dial:"!=c.protocol?null:new kl(c.pathname,c.searchParams.get("dialPostData"),c.searchParams.get("clientId"));c=a.g;var d=a.b}else if("https:"==b.protocol){a=vl(a);if(!a)return null;c=a.C;d=a.A}c?(a=d||"",c=new URL("dial:"+c),a&&c.searchParams.set("postData",a),c=c.toString()):c=null;return c},Lo=function(a){try{var b=new URL(a)}catch(c){return null}return"cast-dial:"==
  b.protocol?b.searchParams.get("clientId"):"https:"==b.protocol?wl(a):null},Jo=function(a,b,c,d){this.f=a;this.sequenceNumber=b;this.g=c;this.b=d},Oo=/__dialAppName__/;var Po=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^/?#]*)@)?([^/#?]*?)(?::([0-9]+))?(?=[/#?]|$))?([^?#]+)?(?:\?([^#]*))?(?:#([\s\S]*))?$/,Qo=function(a,b){if(a){a=a.split("&");for(var c=0;c<a.length;c++){var d=a[c].indexOf("="),e=null;if(0<=d){var f=a[c].substring(0,d);e=a[c].substring(d+1)}else f=a[c];b(f,e?decodeURIComponent(e.replace(/\+/g," ")):"")}}},Ro=function(a,b,c){c=null!=c?"="+encodeURIComponent(String(c)):"";if(b+=c){c=a.indexOf("#");0>c&&(c=a.length);var d=a.indexOf("?");if(0>d||d>c){d=c;var e=""}else e=
  a.substring(d+1,c);a=[a.substr(0,d),e,a.substr(c)];c=a[1];a[1]=b?c?c+"&"+b:b:c;a=a[0]+(a[1]?"?"+a[1]:"")+a[2]}return a},So=/#|$/,To=function(a,b){var c=a.search(So);a:{var d=0;for(var e=b.length;0<=(d=a.indexOf(b,d))&&d<c;){var f=a.charCodeAt(d-1);if(38==f||63==f)if(f=a.charCodeAt(d+e),!f||61==f||38==f||35==f)break a;d+=e+1}d=-1}if(0>d)return null;e=a.indexOf("&",d);if(0>e||e>c)e=c;d+=b.length+1;return decodeURIComponent(a.substr(d,e-d).replace(/\+/g," "))},Uo=function(a,b){var c=a.length-1;0<=c&&
  a.indexOf("/",c)==c&&(a=a.substr(0,a.length-1));lc(b,"/")&&(b=b.substr(1));return zc(a,"/",b)};var Vo=function(a){this.fc=this.l=this.g="";this.Ea=null;this.h=this.b="";this.j=!1;var b;a instanceof Vo?(this.j=Ha(void 0)?void 0:a.j,Wo(this,a.g),this.l=a.l,this.fc=a.fc,Xo(this,a.vb()),this.b=a.b,Yo(this,a.f.clone()),this.h=a.h):a&&(b=String(a).match(Po))?(this.j=!1,Wo(this,b[1]||"",!0),this.l=Zo(b[2]||""),this.fc=Zo(b[3]||"",!0),Xo(this,b[4]),this.b=Zo(b[5]||"",!0),Yo(this,b[6]||"",!0),this.h=Zo(b[7]||"")):(this.j=!1,this.f=new $o(null,this.j))};
  Vo.prototype.toString=function(){var a=[],b=this.g;b&&a.push(ap(b,bp,!0),":");var c=this.fc;if(c||"file"==b)a.push("//"),(b=this.l)&&a.push(ap(b,bp,!0),"@"),a.push(encodeURIComponent(String(c)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),c=this.vb(),null!=c&&a.push(":",String(c));if(c=this.b)this.fc&&"/"!=c.charAt(0)&&a.push("/"),a.push(ap(c,"/"==c.charAt(0)?cp:dp,!0));(c=this.f.toString())&&a.push("?",c);(c=this.h)&&a.push("#",ap(c,ep));return a.join("")};
  Vo.prototype.resolve=function(a){var b=this.clone(),c=!!a.g;c?Wo(b,a.g):c=!!a.l;c?b.l=a.l:c=!!a.fc;c?b.fc=a.fc:c=null!=a.Ea;var d=a.b;if(c)Xo(b,a.vb());else if(c=!!a.b){if("/"!=d.charAt(0))if(this.fc&&!this.b)d="/"+d;else{var e=b.b.lastIndexOf("/");-1!=e&&(d=b.b.substr(0,e+1)+d)}e=d;if(".."==e||"."==e)d="";else if(-1!=e.indexOf("./")||-1!=e.indexOf("/.")){d=lc(e,"/");e=e.split("/");for(var f=[],h=0;h<e.length;){var l=e[h++];"."==l?d&&h==e.length&&f.push(""):".."==l?((1<f.length||1==f.length&&""!=
  f[0])&&f.pop(),d&&h==e.length&&f.push("")):(f.push(l),d=!0)}d=f.join("/")}else d=e}c?b.b=d:c=""!==a.f.toString();c?Yo(b,a.f.clone()):c=!!a.h;c&&(b.h=a.h);return b};Vo.prototype.clone=function(){return new Vo(this)};var Wo=function(a,b,c){a.g=c?Zo(b,!0):b;a.g&&(a.g=a.g.replace(/:$/,""))};Vo.prototype.vb=function(){return this.Ea};
  var Xo=function(a,b){if(b){b=Number(b);if(isNaN(b)||0>b)throw Error("Bad port number "+b);a.Ea=b}else a.Ea=null},Yo=function(a,b,c){b instanceof $o?(a.f=b,fp(a.f,a.j)):(c||(b=ap(b,gp)),a.f=new $o(b,a.j))},Zo=function(a,b){return a?b?decodeURI(a.replace(/%25/g,"%2525")):decodeURIComponent(a):""},ap=function(a,b,c){return Ia(a)?(a=encodeURI(a).replace(b,hp),c&&(a=a.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),a):null},hp=function(a){a=a.charCodeAt(0);return"%"+(a>>4&15).toString(16)+(a&15).toString(16)},
  bp=/[#\/\?@]/g,dp=/[#\?:]/g,cp=/[#\?]/g,gp=/[#\?@]/g,ep=/#/g,$o=function(a,b){this.f=this.b=null;this.g=a||null;this.h=!!b},ip=function(a){a.b||(a.b=new Oj,a.f=0,a.g&&Qo(a.g,function(b,c){a.add(decodeURIComponent(b.replace(/\+/g," ")),c)}))},kp=function(a){var b=Ek(a);if("undefined"==typeof b)throw Error("Keys are undefined");var c=new $o(null,void 0);a=Dk(a);for(var d=0;d<b.length;d++){var e=b[d],f=a[d];Ra(f)?jp(c,e,f):c.add(e,f)}return c};g=$o.prototype;g.sa=function(){ip(this);return this.f};
  g.add=function(a,b){ip(this);this.g=null;a=lp(this,a);var c=this.b.get(a);c||this.b.set(a,c=[]);c.push(b);this.f+=1;return this};g.remove=function(a){ip(this);a=lp(this,a);return Rj(this.b,a)?(this.g=null,this.f-=this.b.get(a).length,this.b.remove(a)):!1};g.clear=function(){this.b=this.g=null;this.f=0};g.Db=function(){ip(this);return 0==this.f};var mp=function(a,b){ip(a);b=lp(a,b);return Rj(a.b,b)};g=$o.prototype;g.cf=function(a){var b=this.ga();return Qb(b,a)};
  g.forEach=function(a,b){ip(this);this.b.forEach(function(c,d){x(c,function(c){a.call(b,c,d,this)},this)},this)};g.rb=function(){ip(this);for(var a=this.b.ga(),b=this.b.rb(),c=[],d=0;d<b.length;d++)for(var e=a[d],f=0;f<e.length;f++)c.push(b[d]);return c};g.ga=function(a){ip(this);var b=[];if(Ia(a))mp(this,a)&&(b=$b(b,this.b.get(lp(this,a))));else{a=this.b.ga();for(var c=0;c<a.length;c++)b=$b(b,a[c])}return b};
  g.set=function(a,b){ip(this);this.g=null;a=lp(this,a);mp(this,a)&&(this.f-=this.b.get(a).length);this.b.set(a,[b]);this.f+=1;return this};g.get=function(a,b){if(!a)return b;a=this.ga(a);return 0<a.length?String(a[0]):b};var jp=function(a,b,c){a.remove(b);0<c.length&&(a.g=null,a.b.set(lp(a,b),y(c)),a.f+=c.length)};
  $o.prototype.toString=function(){if(this.g)return this.g;if(!this.b)return"";for(var a=[],b=this.b.rb(),c=0;c<b.length;c++){var d=b[c],e=encodeURIComponent(String(d));d=this.ga(d);for(var f=0;f<d.length;f++){var h=e;""!==d[f]&&(h+="="+encodeURIComponent(String(d[f])));a.push(h)}}return this.g=a.join("&")};$o.prototype.clone=function(){var a=new $o;a.g=this.g;this.b&&(a.b=this.b.clone(),a.f=this.f);return a};
  var lp=function(a,b){b=String(b);a.h&&(b=b.toLowerCase());return b},fp=function(a,b){b&&!a.h&&(ip(a),a.g=null,a.b.forEach(function(a,b){var c=b.toLowerCase();b!=c&&(this.remove(b),jp(this,c,a))},a));a.h=b};$o.prototype.extend=function(a){for(var b=0;b<arguments.length;b++)Gk(arguments[b],function(a,b){this.add(b,a)},this)};var np=function(a,b){this.input=a;this.domain=b};var op=function(a){this.b=a;this.m=db("mr.ExternalMessageHandler")};
  op.prototype.onMessage=function(a,b,c){var d=this;this.m.info("Received a message from "+b.id+" type: "+a.type);var e=chrome.runtime.id;"start"==a.type?(a=a.message,this.b.searchSinks("pseudo:cloud","urn:x-org.chromium.media:source:desktop",new np(a.meetingName,a.domain)).then(function(a){var f="PresentationId"+b.id+pp++;d.b.createRoute("urn:x-org.chromium.media:source:desktop",a,f).then(function(a){c(new ye(e,"route",a.id))}).catch(function(a){c(new ye(e,"error",a))})},function(){c(new ye(e,"error",
  Error("Failed to find sink.")))})):"stop"==a.type?this.b.terminateRoute(a.message.routeId).then(function(){c(new ye(e,"stopped"))}):"subscribe_log_data"==a.type?(fb.push(function(a){chrome.runtime.sendMessage(b.id,new ye(e,"log_message",a))}),c(new ye(e,"subscribed"))):(c(new ye(e,"error",Error("Unhandled message type"))),this.m.error("Unhandled message type "+a.type))};var pp=0;var qp=function(){this.b=[];this.f=[]};g=qp.prototype;g.enqueue=function(a){if(1E3<=this.sa()){if(this.Db())throw Error("Empty queue");0==this.b.length&&(this.b=this.f,this.b.reverse(),this.f=[]);this.b.pop()}this.f.push(a)};g.sa=function(){return this.b.length+this.f.length};g.Db=function(){return 0==this.sa()};g.ga=function(){var a=this.b.slice();a.reverse();a.push.apply(a,m(this.f));return a};g.clear=function(){this.b=[];this.f=[]};var rp=function(){this.b=new qp;this.f=Date.now()},tp=function(){null==sp&&(sp=new rp);return sp};rp.prototype.init=function(){eb=1;var a=db("browser"),b=window.onerror;window.onerror=function(c,e,f,h,l){b&&b(c,e,f,h,l);a.error("Error: "+c+" ("+e+" @ Line: "+f+")",l)};fb.push(this.h.bind(this));var c=window.localStorage["debug.logs"];c&&(eb=mb(c.toUpperCase()));(c=window.localStorage["debug.console"])&&"false"!=c.toLowerCase()&&fb.push(this.g.bind(this))};
  rp.prototype.h=function(a){this.b.enqueue(up(this,a,!1));a=a.qc;a instanceof Error&&a.stack&&this.b.enqueue(a.stack)};rp.prototype.g=function(a){var b=[up(this,a,!0)];a.qc&&b.push(a.qc);switch(a.level){case 3:console.error.apply(console,m(b));break;case 2:console.warn.apply(console,m(b));break;case 1:console.log.apply(console,m(b));break;default:console.debug.apply(console,m(b))}};
  var up=function(a,b,c){var d=["["];if(c)d.push(("       "+((Date.now()-a.f)/1E3).toFixed(3)).slice(-7));else{a=new Date(b.time);var e=function(a){return 10>a?"0"+a:a};d.push(a.getFullYear().toString(),"-",e(a.getMonth()+1),"-",e(a.getDate())," ",e(a.getHours()),":",e(a.getMinutes()),":",e(a.getSeconds()),".",e(Math.floor(a.getMilliseconds()/10)))}d.push("][",lb[b.level],"][",b.L,"] ",b.message);if(!c&&null!=b.qc)if(d.push("\n"),b.qc instanceof Error)d.push(b.qc.message);else try{d.push(JSON.stringify(b.qc))}catch(f){d.push(b.qc.toString())}d.push("\n");
  return d.join("")},vp=function(){var a=tp();return 0==a.b.sa()?"NA":a.b.ga().join("")},wp=function(){var a=tp();fj(a)};rp.prototype.Aa=function(){return"LogManager"};rp.prototype.gb=function(){return[this.b.ga()]};rp.prototype.fb=function(){var a=this.b.ga();this.b.clear();for(var b=k(cj(this)||[]),c=b.next();!c.done;c=b.next())this.b.enqueue(c.value);a=k(a);for(c=a.next();!c.done;c=a.next())this.b.enqueue(c.value)};var sp=null;var xp=function(a){this.b=a;this.m=db("mr.InternalMessageHandler")};
  xp.prototype.onMessage=function(a,b,c){var d=this;if("retrieve_log_data"!=a.type)c(new ye(chrome.runtime.id,"error",Error("Unhandled message type")));else{var e={logs:vp(),device:Bj()};b=[];var f=xe(e.device.ip).then(function(a){a.b&&(e.device.version=a.b)});b.push(f);var h=this.b.C;h&&(a=yp(this,h,a.source).then(function(a){a&&(e.castStreamingLogs=a)},function(){d.m.error("Log upload failed for service: "+h)}),b.push(a));e.dialDeviceCounts=zp(this);b.push(Ap(this,e));a=this.b.getMediaSinkServiceStatus().then(function(a){e.mediaSinkServiceStatus=
  a.status},function(){d.m.error("Fail to get media sink service status")});b.push(a);e.dialogType=this.b.G;oo(b).then(function(){c(e)})}};var Ap=function(a,b){return eg("mr.cast.SinkDiscoveryService").then(function(a){a=a.se();b.castDeviceCounts=a.cg+"."+a.Nf},function(){a.m.error("Failed to get device counts for castDeviceCounts.")})},zp=function(a){a=Bp(a.b,"dial");if(!a)return"";a=a.se();return a.cg+"."+a.Nf},yp=function(a,b,c){return Cp(a.b,b).then(function(a){return a.Si(c)})};var Dp={ACCEPTED:0,gt:1,TIMEOUT:2},Ep={SUCCESS:0,yt:1},Fp={ao:0,vn:1,uy:2,Yt:3,Xt:4,iv:5,TIMEOUT:6,yw:7},Gp={Vt:0,Ix:1},Hp={bw:0,Pu:1,USER:2,Qt:3},Ip=function(a){yb("MediaRouter.Cloud.Knock.Result",a,Dp)},Jp=function(a){yb("MediaRouter.Cloud.Session.Start",a,Ep)},Kp=function(a){yb("MediaRouter.Cloud.Session.Type",a,Gp)},Lp=function(a){yb("MediaRouter.Cloud.Device.UserRole",a,Hp)};var Mp=function(a,b){this.b=a;this.f=b},Np=new Mp("https://www.googleapis.com/clouddevices/v1","AIzaSyAOZM8ZYeov685QMjXT3sC7XNizfrTEKjA"),Op=new Mp("https://castedumessaging-pa.googleapis.com/v1","AIzaSyAOZM8ZYeov685QMjXT3sC7XNizfrTEKjA"),Pp=new Mp("https://www.googleapis.com/calendar/v3",""),Qp=new Mp("https://www.googleapis.com/hangouts/v1",""),Rp=new Mp("https://networktraversal.googleapis.com/v1alpha","AIzaSyAOZM8ZYeov685QMjXT3sC7XNizfrTEKjA");var Sp=function(a,b,c,d,e,f){c=void 0===c?null:c;a||null==c&&(c="default");this.cl=a;this.Ha=b;this.fc=c;this.sf=void 0===d?null:d;this.Ic=void 0===e?null:e;this.Ie=void 0===f?null:f};Sp.prototype.f=function(){var a="";this.Ic?a=this.Ic:this.sf&&(a=this.sf);return a};Sp.prototype.Hc=function(){return this.cl};Sp.prototype.getId=function(){return this.Ha};Sp.prototype.merge=function(a){!this.Ie&&a.Ie&&(this.Ie=a.Ie);!this.Ic&&a.Ic&&(this.Ic=a.Ic);this.Ic&&a.Ic&&this.Ie&&(this.Ic=a.Ic)};var Tp=function(a,b){this.f=a;this.g=b;this.m=db("mr.cloud.calendar.CalendarService")},Xp=function(a){return Up(a,a.g.b).then(function(b){a.m.info(Vp(b.length)+" events discovered before filtering.");return Wp(a,b)},function(b){a.m.F("Error getting Hangouts from calendar.",b);return[]})},Vp=function(a){return 20<a?"20+":a.toString()},Up=function(a,b){var c=Date.now();return Yp(a,b,new Date(c),new Date(c+9E5)).then(function(b){return b.filter(a.b)})};
  Tp.prototype.b=function(a){return!(!a.start||!a.end||a.start.date||a.end.date||!a.start.dateTime||!a.end.dateTime)};
  var Yp=function(a,b,c,d){b=Zp(Pp.b,["calendars",b,"events"],{timeMin:c.toJSON(),timeMax:d.toJSON(),singleEvents:!0});kb(a.m,"Retrieving Hangouts from Calendar: "+b);return $p(a.f,b,"GET").then(function(a){return a.items?a.items:[]})},Wp=function(a,b){var c=[];b.filter(function(a){return a.hangoutLink}).forEach(function(b){var d=new Vo(b.hangoutLink);if("meet.google.com"==d.fc)c.push(new Sp(!0,d.b.substring(1),void 0,void 0,b.summary));else if(d=d.b.substring(12).split("/"),2==d.length){var f=k(d);
  d=f.next().value;f=f.next().value;if(-1!=d.indexOf(".")){var h=f;var l=d}c.push(new Sp(!1,f+"@"+d,l,h,b.summary,void 0))}else a.m.F("Invalid hangout link from calendar event: "+b.hangoutLink)});a.m.info(Vp(c.length)+" events discovered with Hangout links.");return c};var aq=function(a){this.b=a;this.id=a.id;this.m=db("mr.cloud.devices.WeaveDevice")};aq.prototype.isAvailable=function(){if(this.getState().appStatus){var a="online"==this.b.connectionStatus,b="available"==this.getState().appStatus,c=bq(this,864E5);kb(this.m,"Device id: "+this.id+", availability: GCM connected "+a+", app Available: "+b+", checked in: "+c);return a&&b&&c}a=bq(this,9E5);this.m.info("Availability for legacy receiver app: "+a);return a};
  var bq=function(a,b){a=a.b.lastUpdateTimeMs?Number(a.b.lastUpdateTimeMs):null;return!!(a&&a>Date.now()-b)};aq.prototype.f=function(){return this.getState().settings.receiverName};aq.prototype.getId=function(){return this.id};aq.prototype.getState=function(){return this.b.state._cloudCast};var cq=function(a){var b=[],c=[],d={},e=function(a,h){var f=h+"  ";try{if(Ha(a))if(null===a)b.push("NULL");else if(Ia(a))b.push('"'+a.replace(/\n/g,"\n"+h)+'"');else if(Ta(a))b.push(String(a).replace(/\n/g,"\n"+h));else if(Ua(a)){a[Va]||c.push(a);var t=a[Va]||(a[Va]=++Xa);if(d[t])b.push("*** reference loop detected (id="+t+") ***");else{d[t]=!0;b.push("{");for(var u in a)Ta(a[u])||(b.push("\n"),b.push(f),b.push(u+" = "),e(a[u],f));b.push("\n"+h+"}");delete d[t]}}else b.push(a);else b.push("undefined")}catch(A){b.push("*** "+
  A+" ***")}};e(a,"");for(a=0;a<c.length;a++)Wa(c[a]);return b.join("")},dq=function(a){var b=dq;var c=Error();if(Error.captureStackTrace)Error.captureStackTrace(c,b),b=String(c.stack);else{try{throw c;}catch(e){c=e}b=(b=c.stack)?String(b):null}if(b)return b;b=[];c=arguments.callee.caller;for(var d=0;c&&(!a||d<a);){b.push(eq(c));b.push("()\n");try{c=c.caller}catch(e){b.push("[exception trying to get caller]\n");break}d++;if(50<=d){b.push("[...long stack...]");break}}a&&d>=a?b.push("[...reached max depth limit...]"):
  b.push("[end]");return b.join("")},eq=function(a){if(fq[a])return fq[a];a=String(a);if(!fq[a]){var b=/function\s+([^\(]+)/m.exec(a);fq[a]=b?b[1]:"[Anonymous]"}return fq[a]},fq={},gq=Object.freeze||function(a){return a};var hq=function(a,b,c){this.reset(a,b,c,void 0,void 0)};hq.prototype.b=null;var iq=0;hq.prototype.reset=function(a,b,c,d,e){"number"==typeof e||iq++;this.j=d||r();this.f=a;this.h=b;this.g=c;delete this.b};hq.prototype.getMessage=function(){return this.h};var jq=function(a){this.j=a;this.b=this.h=this.f=this.g=null},kq=function(a,b){this.name=a;this.value=b};kq.prototype.toString=function(){return this.name};var lq=new kq("SEVERE",1E3),mq=new kq("WARNING",900),nq=new kq("INFO",800),oq=new kq("CONFIG",700),pq=new kq("FINE",500),qq=new kq("FINER",400),rq=new kq("ALL",0);jq.prototype.getName=function(){return this.j};jq.prototype.getChildren=function(){this.h||(this.h={});return this.h};
  var sq=function(a){if(a.f)return a.f;if(a.g)return sq(a.g);Db("Root logger has no level set.");return null};g=jq.prototype;g.log=function(a,b,c){a.value>=sq(this).value&&(Ta(b)&&(b=b()),a=new hq(a,String(b),this.j),c&&(a.b=c),tq(this,a))};g.F=function(a,b){this.log(mq,a,b)};g.info=function(a,b){this.log(nq,a,b)};g.config=function(a,b){this.log(oq,a,b)};g.logRecord=function(a){a.f.value>=sq(this).value&&tq(this,a)};
  var tq=function(a,b){for(;a;){var c,d=a,e=b;if(d.b)for(var f=0;c=d.b[f];f++)c(e);a=a.g}},uq={},vq=null,wq=function(){vq||(vq=new jq(""),uq[""]=vq,vq.f=oq)},xq=function(a){wq();var b;if(!(b=uq[a])){b=new jq(a);var c=a.lastIndexOf("."),d=a.substr(c+1);c=xq(a.substr(0,c));c.getChildren()[d]=b;b.g=c;uq[a]=b}return b};var yq=function(a,b,c,d){a&&a.log(b,c,d)},zq=function(a,b,c){a&&a.log(lq,b,c)},U=function(a,b,c){a&&a.F(b,c)},W=function(a,b){a&&a.info(b,void 0)},Aq=function(a,b){a&&a.log(pq,b,void 0)};var Bq=function(){this.m=xq("mr.cloud.GcmRegistrationSerializer");this.b=Promise.resolve("")};Bq.prototype.register=function(a){var b=this,c=function(){return new Promise(function(c,e){chrome.gcm.register(a,function(a){a?(b.m.info("Got GCM registration ID: "+a),c(a)):e(Error(chrome.runtime.lastError&&chrome.runtime.lastError.message||"unknown error"))})})};return this.b=this.b.then(c,c)};var Cq=function(a){this.email=a;this.imageUrl=null},Dq=function(a){this.type=a},Eq=function(a,b,c,d){this.type="__cloud_webrtc_session_message__";this.sessionDescription=a;this.user=b||null;this.flungUrl=c||null;this.presentationId=d||null};n(Eq,Dq);
  var Fq=function(a,b,c){this.name=a;this.parameters=b;this.minimalRole=null!=c?c:"user"},Gq={_settings:{type:"string"},_presentationRequest:{type:"string"},_optMediaConstraints:{type:"string"},_webrtcMessage:{type:"string"},_user:{type:"string"}},Hq=new Fq("_knockingStartWebrtcSession",Gq,"viewer"),Iq=new Fq("_startWebrtcSession",Gq),Jq=new Fq("_stopSession",{},"viewer");var Kq=function(a,b){this.j=a;this.l=b;this.f=this.g=this.b=null;this.h=!1;this.m=db("mr.cloud.devices.WeaveDevicesService");fj(this)};Kq.prototype.getDevice=function(a){a=Zp(Np.b,["devices",a]);return $p(this.j,a,"GET").then(function(a){return new aq(a)})};
  var Lq=function(a,b){var c=Zp(Np.b,["devices"],b);return $p(a.j,c,"GET").then(function(c){var d=(c.devices||[]).filter(function(a){return null!=a.commandDefs&&null!=a.commandDefs._cloudCast}).map(function(a){return new aq(a)});if(c=c.nextPageToken){var f=Sc(b);f.token=c;return Lq(a,f).then(function(a){return d.concat(a)})}return d})};Kq.prototype.Aa=function(){return"WeaveDevicesService"};Kq.prototype.gb=function(){return[new Mq(this.b,this.f,this.g)]};
  Kq.prototype.fb=function(){var a=cj(this);a&&(this.b=a.sp,this.f=a.gcmRegistrationId,this.g=a.rp)};
  var Nq=function(a){return a.f&&null!=a.g&&a.g+864E5>=Date.now()?Promise.resolve(a.f):a.l.register(["919648714761"]).then(function(b){kb(a.m,"Got GCM ID: "+b);a.f=b;a.g=Date.now();a.b=null;return b},function(b){a.m.F("Error",b);a.f=null;a.g=null;a.b=null;throw b;})},Oq=function(a,b){if(a.h)Promise.resolve();else if(a.h=!0,b&&(!a.b||a.b+864E5<Date.now())){b={filters:["myDevices"],gcmRegistrationId:b,gcmSenderId:"919648714761",expirationTimeMs:864E5};var c=Zp(Np.b,["subscriptions","subscribe"],{});$p(a.j,
  c,"POST",b).then(function(){kb(a.m,"Subscribed on: "+Date.now());a.b=Date.now();a.h=!1;return Promise.resolve()},function(b){a.h=!1;throw b;})}else Promise.resolve()},Mq=function(a,b,c){this.sp=a;this.gcmRegistrationId=b;this.rp=c};var Pq=function(a,b,c,d,e,f,h,l){var t=Aj(zj(),a);this.jb=new Zi(t,b,h,l,e);this.deviceId=a;this.b=c;this.model=d;this.isAvailable=f};ca.Object.defineProperties(Pq.prototype,{id:{configurable:!0,enumerable:!0,get:function(){return this.jb.id}},displayName:{configurable:!0,enumerable:!0,set:function(a){this.jb.friendlyName=a}}});var Qq=function(a,b,c,d,e){Pq.call(this,a,b,"weave","Chrome Streaming Receiver",d,e,"education");this.Xh=c};n(Qq,Pq);
  var Rq=function(a){var b=a.fc,c;a.sf&&a.f()!=a.sf&&(c=a.sf);Pq.call(this,a.getId(),a.f(),"mesi","Hangout",b,!1,a.Hc()?"meeting":"hangout",c);this.Hc=a.Hc();this.He=a.Ie||""};n(Rq,Pq);var Sq=function(a,b,c){Pq.call(this,a,b,"slarti","Cast Receiver for Education","default",c,"education")};n(Sq,Pq);var Tq=function(a,b,c){this.l=a;this.h=b;this.b=new Map;this.g=new Map;this.f=null;this.j=c};Tq.prototype.Ld=function(){var a=this.f+this.j;if(null==this.f||a<Date.now())this.f=Date.now(),Uq(this);return Array.from(this.b.values())};Tq.prototype.ja=function(a){return this.b.get(a)||null};
  var Uq=function(a){a.l().then(function(b){Vq(a,b)})},Vq=function(a,b){var c=new Map(a.b),d=new Map,e=new Map,f=[],h=[];b.forEach(function(a){var b=a.id;d.set(b,a);e.set(b,a.deviceId);c.has(b)?c.has(b)&&JSON.stringify(c.get(b))!=JSON.stringify(a)&&h.push(a.jb):f.push(a.jb);c.delete(b)});b=[].concat(m(c.values())).map(function(a){return a.jb});a.g.clear();a.g=e;a.b.clear();a.b=d;Wq(a,f,h,b)},Wq=function(a,b,c,d){0<b.length&&Xq(a.h,b);0<c.length&&Yq(a.h,c);0<d.length&&Zq(a.h,d)},ar=function(a){for(var b=
  {},c=k(a.b.entries()),d=c.next();!d.done;d=c.next()){var e=k(d.value);d=e.next().value;e=e.next().value;b[d]=e}c={};d=k(a.g.entries());for(e=d.next();!e.done;e=d.next()){var f=k(e.value);e=f.next().value;f=f.next().value;c[e]=f}return new $q(b,c,a.f)},br=function(a,b){for(var c in b.sinks){var d=b.sinks[c],e=null;"Hangout"==d.model?e=new Rq(new Sp(d.Hc,d.deviceId,d.jb.domain,d.jb.description,d.jb.friendlyName,d.He)):"Cast Receiver for Education"==d.model?e=new Sq(d.deviceId,d.jb.friendlyName,d.isAvailable):
  "Chrome Streaming Receiver"==d.model&&(e=new Qq(d.deviceId,d.jb.friendlyName,d.Xh,d.jb.domain,d.isAvailable));a.b.set(c,e)}for(c in b.b)a.g.set(c,b.b[c]);b.f&&(a.f=b.f)},$q=function(a,b,c){this.sinks=a;this.b=b;this.f=c};var er=function(a,b,c){if(!cr){wq();var d=vq;d.f=rq;var e=dr;d.b||(d.b=[]);d.b.push(e);cr=!0}this.g=a;this.h=b;this.b=new Tq(this.j.bind(this),c,2E4);this.f=new Map;fj(this)},dr=function(a){gb({L:a.g,level:nb(a.f.value),time:a.j,message:a.getMessage(),qc:a.b})};er.prototype.Ld=function(){return this.b.Ld()};er.prototype.ja=function(a){return this.b.ja(a)};
  er.prototype.j=function(){var a=this;this.m.info("Fetching hangouts");return oo([fr(this.h),Xp(this.g)]).then(function(b){var c=Array.from(a.f.values());b.forEach(function(b){b.Hd?c=c.concat(b.value):a.m.error("Error discovering Hangouts",b.reason)});var d=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(d).map(function(a){a=d[a];xb("MediaRouter.Cloud.Hangout.Sink.Discovered");return new Rq(a)})})};
  var hr=function(a,b){return eg("mr.mirror.hangouts.MeetingsService").then(function(a){return a.gc(b)}).then(function(b){return gr(a,b)},function(){return b.input.match(/^#/)?Promise.reject(Error("Failed to resolve meeting alias.")):gr(a,b.input,b.domain)})},gr=function(a,b,c){c=c||void 0;var d=!c;b=new Sp(d,d?b:b+"@"+c,c,b,void 0,void 0);a.f.set(b.getId(),b);b=new Rq(b);a.b.b.set(b.id,b);return b.jb};er.prototype.Aa=function(){return"HangoutSinkDiscoveryService"};
  er.prototype.gb=function(){for(var a={},b=k(this.f.entries()),c=b.next();!c.done;c=b.next()){var d=k(c.value);c=d.next().value;d=d.next().value;a[c]=d}return[{cache:ar(this.b),manualHangouts:a}]};er.prototype.fb=function(){var a=cj(this);if(a){br(this.b,a.cache);for(var b in a.manualHangouts){var c=a.manualHangouts[b];this.f.set(b,new Sp(c.cl,c.Ha,c.fc,c.sf,c.Ic,c.Ie))}}};er.prototype.m=db("mr.cloud.discovery.HangoutSinkDiscoveryService");var cr=!1;var kr=function(){this.f=!1;this.b=null;this.g=!1;this.m=db("mr.cloud.identity.IdentityService");fj(this);ir(this);jr(this)},lr=function(a){return a.b?a.b.substr(a.b.indexOf("@")+1):""};kr.prototype.getAuthToken=function(){return chrome.identity?new Promise(function(a,b){chrome.identity.getAuthToken({interactive:!1},function(c){chrome.runtime.lastError?b(Error("Unable to get user auth token: "+chrome.runtime.lastError.message)):null==c?b(Error("User is not logged in (no token found)")):a(c)})}):Promise.reject(Error("chrome.identity permission required for auth."))};
  var nr=function(a){return new Promise(function(b){chrome.identity.removeCachedAuthToken({token:a},function(){b()})})},jr=function(a){a.getAuthToken().then(function(b){chrome.identity.getProfileUserInfo(function(c){a.f=!!c.email||!!c.id;a.b=c.email||null;b&&!a.f&&(a.g=!0)})},function(b){kb(a.m,"Unable to set sign in and email.",b)})},ir=function(a){chrome.identity.onSignInChanged.addListener(function(b,c){og(6);a.f=c;a.m.info("Signed in change: "+a.f);a.f?jr(a):(a.b=null,a.g=!1)})},or=function(a){return a.getAuthToken().then(function(b){var c=
  window.gapi;if(!c)return a.m.error("gapi not loaded."),!1;a.m.info("Setting gapi auth token");c.auth.setToken({access_token:b});return!0})};kr.prototype.Aa=function(){return"IdentityService"};kr.prototype.gb=function(){return[null,{signedIn:this.f,userEmail:this.b,kioskAuth:this.g}]};kr.prototype.fb=function(){var a=dj(this);a&&(a.signedIn&&(this.f=a.signedIn),a.userEmail&&(this.b=a.userEmail),a.kioskAuth&&(this.g=a.kioskAuth))};var pr="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(" ");var qr=function(a){var b=a.method,c=a.uri,d=a.Sb,e=a.vc,f=a.Jl,h=a.headers,l=a.body,t=a.start,u=a.apiKey,A=a.Ag;a=a.eb;this.method=b&&b.toUpperCase()||"GET";(b=c)||(d=[d].concat(m(e||[])).join("/"),d=new Vo(encodeURI(d)),f&&(f=kp(f),Yo(d,f)),b=d);this.uri=b;u&&this.uri.f.add("key",u);this.b=a||null;this.headers=h||{};(this.body=l)&&(this.headers["Content-Type"]="application/json");this.Ag=Ha(A)?A:1E4;this.start=t||r()},rr=function(a){return(a.b?a.b.getAuthToken():Promise.resolve(null)).then(function(b){b&&
  (a.headers.Authorization="Bearer "+b);b={method:a.method,headers:a.headers};a.body&&(b.body=JSON.stringify(a.body));return new Request(a.uri.toString(),b)})};var sr={Xs:100,Mx:101,Xv:200,Ys:201,ACCEPTED:202,Av:203,Ov:204,Rw:205,hw:206,ov:207,nv:300,kv:301,Ft:302,ox:303,Kv:304,oy:305,Px:307,Cm:400,by:401,fn:402,Et:403,Gv:404,fv:405,Dv:406,Cw:407,Pw:408,Ts:409,Ot:410,Mu:411,vw:412,Mw:413,Qw:414,iy:415,Ow:416,qt:417,hy:422,Ou:423,rt:424,ww:428,Sx:429,Nw:431,Tm:500,Hv:501,es:502,ux:503,Jt:504,eu:505,pu:507,uv:511,Fw:1223};var tr=function(a,b){Ab.call(this,b&&b.message||a.statusText);this.code=a.status;this.response=a;this.status=(this.b=b)&&b.status};n(tr,Ab);var xr=function(a){if(ur.has(a.code))return!0;var b=a.b||{};return a.b?vr.has(b.status)?!0:!!(b.errors||[]).find(function(a){return wr.has(a)}):!1},yr=function(a,b){a=new Response(void 0,{status:b||408,statusText:a});return new tr(a)},ur=new Set([400,401,403,404,405,406,501]),vr=new Set(["PERMISSION_DENIED"]),wr=new Set("authError command_is_in_terminal_state forbidden notFound unmanaged_group_acl acl_entry_bad_scope network_error".split(" "));var zr=function(){this.Rb=this.Rb;this.Za=this.Za};zr.prototype.Rb=!1;zr.prototype.C=function(){return this.Rb};zr.prototype.Oa=function(){this.Rb||(this.Rb=!0,this.ca())};zr.prototype.f=function(a){Ar(this,$a(Br,a))};var Ar=function(a,b){a.Rb?Ha(void 0)?b.call(void 0):b():(a.Za||(a.Za=[]),a.Za.push(Ha(void 0)?q(b,void 0):b))};zr.prototype.ca=function(){if(this.Za)for(;this.Za.length;)this.Za.shift()()};
  var Br=function(a){a&&"function"==typeof a.Oa&&a.Oa()},Cr=function(a){for(var b=0,c=arguments.length;b<c;++b){var d=arguments[b];Sa(d)?Cr.apply(null,d):Br(d)}};var X=function(a,b){this.type=a;this.f=this.target=b;this.Sl=!0};X.prototype.h=function(){this.Sl=!1};var Dr=!gd||9<=Number(Cd),Er=gd&&!Bd("9"),Fr=function(){if(!Ga.addEventListener||!Object.defineProperty)return!1;var a=!1,b=Object.defineProperty({},"passive",{get:function(){a=!0}});try{Ga.addEventListener("test",Na,b),Ga.removeEventListener("test",Na,b)}catch(c){}return a}();var Gr=function(a,b){X.call(this,a?a.type:"");this.relatedTarget=this.f=this.target=null;this.button=this.screenY=this.screenX=this.clientY=this.clientX=0;this.key="";this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1;this.state=null;this.pointerId=0;this.pointerType="";this.b=null;a&&this.init(a,b)};w(Gr,X);var Hr=gq({2:"touch",3:"pen",4:"mouse"});
  Gr.prototype.init=function(a,b){var c=this.type=a.type,d=a.changedTouches?a.changedTouches[0]:null;this.target=a.target||a.srcElement;this.f=b;(b=a.relatedTarget)?id&&(bd(b,"nodeName")||(b=null)):"mouseover"==c?b=a.fromElement:"mouseout"==c&&(b=a.toElement);this.relatedTarget=b;null===d?(this.clientX=void 0!==a.clientX?a.clientX:a.pageX,this.clientY=void 0!==a.clientY?a.clientY:a.pageY,this.screenX=a.screenX||0,this.screenY=a.screenY||0):(this.clientX=void 0!==d.clientX?d.clientX:d.pageX,this.clientY=
  void 0!==d.clientY?d.clientY:d.pageY,this.screenX=d.screenX||0,this.screenY=d.screenY||0);this.button=a.button;this.key=a.key||"";this.ctrlKey=a.ctrlKey;this.altKey=a.altKey;this.shiftKey=a.shiftKey;this.metaKey=a.metaKey;this.pointerId=a.pointerId||0;this.pointerType=Ia(a.pointerType)?a.pointerType:Hr[a.pointerType]||"";this.state=a.state;this.b=a;a.defaultPrevented&&this.h()};
  Gr.prototype.h=function(){Gr.ta.h.call(this);var a=this.b;if(a.preventDefault)a.preventDefault();else if(a.returnValue=!1,Er)try{if(a.ctrlKey||112<=a.keyCode&&123>=a.keyCode)a.keyCode=-1}catch(b){}};var Ir="closure_listenable_"+(1E6*Math.random()|0),Jr=function(a){return!(!a||!a[Ir])},Kr=0;var Lr=function(a,b,c,d,e){this.listener=a;this.proxy=null;this.src=b;this.type=c;this.capture=!!d;this.bb=e;this.key=++Kr;this.removed=this.Tg=!1},Mr=function(a){a.removed=!0;a.listener=null;a.proxy=null;a.src=null;a.bb=null};var Nr=function(a){this.src=a;this.b={};this.f=0};Nr.prototype.add=function(a,b,c,d,e){var f=a.toString();a=this.b[f];a||(a=this.b[f]=[],this.f++);var h=Or(a,b,d,e);-1<h?(b=a[h],c||(b.Tg=!1)):(b=new Lr(b,this.src,f,!!d,e),b.Tg=c,a.push(b));return b};Nr.prototype.remove=function(a,b,c,d){a=a.toString();if(!(a in this.b))return!1;var e=this.b[a];b=Or(e,b,c,d);return-1<b?(Mr(e[b]),Wb(e,b),0==e.length&&(delete this.b[a],this.f--),!0):!1};
  var Pr=function(a,b){var c=b.type;if(!(c in a.b))return!1;var d=Xb(a.b[c],b);d&&(Mr(b),0==a.b[c].length&&(delete a.b[c],a.f--));return d};Nr.prototype.removeAll=function(a){a=a&&a.toString();var b=0,c;for(c in this.b)if(!a||c==a){for(var d=this.b[c],e=0;e<d.length;e++)++b,Mr(d[e]);delete this.b[c];this.f--}return b};var Qr=function(a,b,c,d,e){a=a.b[b.toString()];b=-1;a&&(b=Or(a,c,d,e));return-1<b?a[b]:null};
  Nr.prototype.hasListener=function(a,b){var c=Ha(a),d=c?a.toString():"",e=Ha(b);return Jc(this.b,function(a){for(var f=0;f<a.length;++f)if(!(c&&a[f].type!=d||e&&a[f].capture!=b))return!0;return!1})};var Or=function(a,b,c,d){for(var e=0;e<a.length;++e){var f=a[e];if(!f.removed&&f.listener==b&&f.capture==!!c&&f.bb==d)return e}return-1};var Rr="closure_lm_"+(1E6*Math.random()|0),Sr={},Tr=0,Vr=function(a,b,c,d,e){if(d&&d.once)return Ur(a,b,c,d,e);if(Ra(b)){for(var f=0;f<b.length;f++)Vr(a,b[f],c,d,e);return null}c=Wr(c);return Jr(a)?a.listen(b,c,Ua(d)?!!d.capture:!!d,e):Xr(a,b,c,!1,d,e)},Xr=function(a,b,c,d,e,f){if(!b)throw Error("Invalid event type");var h=Ua(e)?!!e.capture:!!e,l=Yr(a);l||(a[Rr]=l=new Nr(a));c=l.add(b,c,d,h,f);if(c.proxy)return c;d=Zr();c.proxy=d;d.src=a;d.listener=c;if(a.addEventListener)Fr||(e=h),void 0===e&&(e=
  !1),a.addEventListener(b.toString(),d,e);else if(a.attachEvent)a.attachEvent($r(b.toString()),d);else if(a.addListener&&a.removeListener)a.addListener(d);else throw Error("addEventListener and attachEvent are unavailable.");Tr++;return c},Zr=function(){var a=as,b=Dr?function(c){return a.call(b.src,b.listener,c)}:function(c){c=a.call(b.src,b.listener,c);if(!c)return c};return b},Ur=function(a,b,c,d,e){if(Ra(b)){for(var f=0;f<b.length;f++)Ur(a,b[f],c,d,e);return null}c=Wr(c);return Jr(a)?bs(a,b,c,Ua(d)?
  !!d.capture:!!d,e):Xr(a,b,c,!0,d,e)},cs=function(a,b,c,d,e){if(Ra(b))for(var f=0;f<b.length;f++)cs(a,b[f],c,d,e);else d=Ua(d)?!!d.capture:!!d,c=Wr(c),Jr(a)?a.W.remove(String(b),c,d,e):a&&(a=Yr(a))&&(b=Qr(a,b,c,d,e))&&ds(b)},ds=function(a){if(p(a)||!a||a.removed)return!1;var b=a.src;if(Jr(b))return Pr(b.W,a);var c=a.type,d=a.proxy;b.removeEventListener?b.removeEventListener(c,d,a.capture):b.detachEvent?b.detachEvent($r(c),d):b.addListener&&b.removeListener&&b.removeListener(d);Tr--;(c=Yr(b))?(Pr(c,
  a),0==c.f&&(c.src=null,b[Rr]=null)):Mr(a);return!0},es=function(a){if(a)if(Jr(a))a.lj(void 0);else if(a=Yr(a)){var b=0,c;for(c in a.b)for(var d=a.b[c].concat(),e=0;e<d.length;++e)ds(d[e])&&++b}},$r=function(a){return a in Sr?Sr[a]:Sr[a]="on"+a},gs=function(a,b,c,d){var e=!0;if(a=Yr(a))if(b=a.b[b.toString()])for(b=b.concat(),a=0;a<b.length;a++){var f=b[a];f&&f.capture==c&&!f.removed&&(f=fs(f,d),e=e&&!1!==f)}return e},fs=function(a,b){var c=a.listener,d=a.bb||a.src;a.Tg&&ds(a);return c.call(d,b)},as=
  function(a,b){if(a.removed)return!0;if(!Dr){var c=b||Ma("window.event");b=new Gr(c,this);var d=!0;if(!(0>c.keyCode||void 0!=c.returnValue)){a:{var e=!1;if(0==c.keyCode)try{c.keyCode=-1;break a}catch(h){e=!0}if(e||void 0==c.returnValue)c.returnValue=!0}c=[];for(e=b.f;e;e=e.parentNode)c.push(e);a=a.type;for(e=c.length-1;0<=e;e--){b.f=c[e];var f=gs(c[e],a,!0,b);d=d&&f}for(e=0;e<c.length;e++)b.f=c[e],f=gs(c[e],a,!1,b),d=d&&f}return d}return fs(a,new Gr(b,this))},Yr=function(a){a=a[Rr];return a instanceof
  Nr?a:null},hs="__closure_events_fn_"+(1E9*Math.random()>>>0),Wr=function(a){if(Ta(a))return a;a[hs]||(a[hs]=function(b){return a.handleEvent(b)});return a[hs]};var Y=function(){zr.call(this);this.W=new Nr(this);this.Kh=this;this.A=null};w(Y,zr);Y.prototype[Ir]=!0;Y.prototype.removeEventListener=function(a,b,c,d){cs(this,a,b,c,d)};
  Y.prototype.J=function(a){var b,c=this.A;if(c)for(b=[];c;c=c.A)b.push(c);c=this.Kh;var d=a.type||a;if(Ia(a))a=new X(a,c);else if(a instanceof X)a.target=a.target||c;else{var e=a;a=new X(d,c);Wc(a,e)}e=!0;if(b)for(var f=b.length-1;0<=f;f--){var h=a.f=b[f];e=h.ef(d,!0,a)&&e}h=a.f=c;e=h.ef(d,!0,a)&&e;e=h.ef(d,!1,a)&&e;if(b)for(f=0;f<b.length;f++)h=a.f=b[f],e=h.ef(d,!1,a)&&e;return e};Y.prototype.ca=function(){Y.ta.ca.call(this);this.lj();this.A=null};
  Y.prototype.listen=function(a,b,c,d){return this.W.add(String(a),b,!1,c,d)};var bs=function(a,b,c,d,e){return a.W.add(String(b),c,!0,d,e)};Y.prototype.lj=function(a){this.W&&this.W.removeAll(a)};Y.prototype.ef=function(a,b,c){a=this.W.b[String(a)];if(!a)return!0;a=a.concat();for(var d=!0,e=0;e<a.length;++e){var f=a[e];if(f&&!f.removed&&f.capture==b){var h=f.listener,l=f.bb||f.src;f.Tg&&Pr(this.W,f);d=!1!==h.call(l,c)&&d}}return d&&0!=c.Sl};
  Y.prototype.hasListener=function(a,b){return this.W.hasListener(Ha(a)?String(a):void 0,b)};var is=function(a,b){this.g=a;this.h=b;this.f=0;this.b=null};is.prototype.get=function(){if(0<this.f){this.f--;var a=this.b;this.b=a.next;a.next=null}else a=this.g();return a};var js=function(a,b){a.h(b);100>a.f&&(a.f++,b.next=a.b,a.b=b)};var ks=function(a){Ga.setTimeout(function(){throw a;},0)},ls,ms=function(){var a=Ga.MessageChannel;"undefined"===typeof a&&"undefined"!==typeof window&&window.postMessage&&window.addEventListener&&!Hc("Presto")&&(a=function(){var a=document.createElement("IFRAME");a.style.display="none";a.src="";document.documentElement.appendChild(a);var b=a.contentWindow;a=b.document;a.open();a.write("");a.close();var c="callImmediate"+Math.random(),d="file:"==b.location.protocol?"*":b.location.protocol+"//"+b.location.host;
  a=q(function(a){if(("*"==d||a.origin==d)&&a.data==c)this.port1.onmessage()},this);b.addEventListener("message",a,!1);this.port1={};this.port2={postMessage:function(){b.postMessage(c,d)}}});if("undefined"!==typeof a&&!Hc("Trident")&&!Hc("MSIE")){var b=new a,c={},d=c;b.port1.onmessage=function(){if(Ha(c.next)){c=c.next;var a=c.sk;c.sk=null;a()}};return function(a){d.next={sk:a};d=d.next;b.port2.postMessage(0)}}return"undefined"!==typeof document&&"onreadystatechange"in document.createElement("SCRIPT")?
  function(a){var b=document.createElement("SCRIPT");b.onreadystatechange=function(){b.onreadystatechange=null;b.parentNode.removeChild(b);b=null;a();a=null};document.documentElement.appendChild(b)}:function(a){Ga.setTimeout(a,0)}};var ns=function(){this.f=this.b=null},ps=new is(function(){return new os},function(a){a.reset()});ns.prototype.add=function(a,b){var c=ps.get();c.set(a,b);this.f?this.f.next=c:this.b=c;this.f=c};ns.prototype.remove=function(){var a=null;this.b&&(a=this.b,this.b=this.b.next,this.b||(this.f=null),a.next=null);return a};var os=function(){this.next=this.scope=this.b=null};os.prototype.set=function(a,b){this.b=a;this.scope=b;this.next=null};os.prototype.reset=function(){this.next=this.scope=this.b=null};var us=function(a,b){qs||rs();ss||(qs(),ss=!0);ts.add(a,b)},qs,rs=function(){if(Ga.Promise&&Ga.Promise.resolve){var a=Ga.Promise.resolve(void 0);qs=function(){a.then(vs)}}else qs=function(){var a=vs;!Ta(Ga.setImmediate)||Ga.Window&&Ga.Window.prototype&&!Hc("Edge")&&Ga.Window.prototype.setImmediate==Ga.setImmediate?(ls||(ls=ms()),ls(a)):Ga.setImmediate(a)}},ss=!1,ts=new ns,vs=function(){for(var a;a=ts.remove();){try{a.b.call(a.scope)}catch(b){ks(b)}js(ps,a)}ss=!1};var ws=function(a){a.prototype.then=a.prototype.then;a.prototype.$goog_Thenable=!0},xs=function(a){if(!a)return!1;try{return!!a.$goog_Thenable}catch(b){return!1}};var As=function(a,b){this.b=0;this.o=void 0;this.h=this.f=this.g=null;this.j=this.l=!1;if(a!=Na)try{var c=this;a.call(b,function(a){ys(c,2,a)},function(a){if(!(a instanceof zs))try{if(a instanceof Error)throw a;throw Error("Promise rejected.");}catch(e){}ys(c,3,a)})}catch(d){ys(this,3,d)}},Bs=function(){this.next=this.context=this.f=this.h=this.b=null;this.g=!1};Bs.prototype.reset=function(){this.context=this.f=this.h=this.b=null;this.g=!1};
  var Cs=new is(function(){return new Bs},function(a){a.reset()}),Ds=function(a,b,c){var d=Cs.get();d.h=a;d.f=b;d.context=c;return d},Es=function(a){if(a instanceof As)return a;var b=new As(Na);ys(b,2,a);return b},Fs=function(a){return new As(function(b,c){c(a)})},Hs=function(a,b,c){Gs(a,b,c,null)||us($a(b,a))},Is=function(a){return new As(function(b,c){a.length||b(void 0);for(var d=0,e;d<a.length;d++)e=a[d],Hs(e,b,c)})},Js=function(a){return new As(function(b,c){var d=a.length,e=[];if(d)for(var f=
  function(a,c){d--;e[a]=c;0==d&&b(e)},h=function(a){c(a)},l=0,t;l<a.length;l++)t=a[l],Hs(t,$a(f,l),h);else b(e)})},Ks=function(a){return new As(function(b){var c=a.length,d=[];if(c)for(var e=function(a,e,f){c--;d[a]=e?{Hd:!0,value:f}:{Hd:!1,reason:f};0==c&&b(d)},f=0,h;f<a.length;f++)h=a[f],Hs(h,$a(e,f,!0),$a(e,f,!1));else b(d)})},Ms=function(){var a,b,c=new As(function(c,e){a=c;b=e});return new Ls(c,a,b)};As.prototype.then=function(a,b,c){return Ns(this,Ta(a)?a:null,Ta(b)?b:null,c)};ws(As);
  var Ps=function(a,b,c){b=Ds(b,b,c);b.g=!0;Os(a,b);return a},Qs=function(a,b,c){return Ns(a,null,b,c)};As.prototype.cancel=function(a){0==this.b&&us(function(){var b=new zs(a);Rs(this,b)},this)};
  var Rs=function(a,b){if(0==a.b)if(a.g){var c=a.g;if(c.f){for(var d=0,e=null,f=null,h=c.f;h&&(h.g||(d++,h.b==a&&(e=h),!(e&&1<d)));h=h.next)e||(f=h);e&&(0==c.b&&1==d?Rs(c,b):(f?(d=f,d.next==c.h&&(c.h=d),d.next=d.next.next):Ss(c),Ts(c,e,3,b)))}a.g=null}else ys(a,3,b)},Os=function(a,b){a.f||2!=a.b&&3!=a.b||Us(a);a.h?a.h.next=b:a.f=b;a.h=b},Ns=function(a,b,c,d){var e=Ds(null,null,null);e.b=new As(function(a,h){e.h=b?function(c){try{var e=b.call(d,c);a(e)}catch(u){h(u)}}:a;e.f=c?function(b){try{var e=c.call(d,
  b);!Ha(e)&&b instanceof zs?h(b):a(e)}catch(u){h(u)}}:h});e.b.g=a;Os(a,e);return e.b};As.prototype.C=function(a){this.b=0;ys(this,2,a)};As.prototype.A=function(a){this.b=0;ys(this,3,a)};
  var ys=function(a,b,c){0==a.b&&(a===c&&(b=3,c=new TypeError("Promise cannot resolve to itself")),a.b=1,Gs(c,a.C,a.A,a)||(a.o=c,a.b=b,a.g=null,Us(a),3!=b||c instanceof zs||Vs(a,c)))},Gs=function(a,b,c,d){if(a instanceof As)return Os(a,Ds(b||Na,c||null,d)),!0;if(xs(a))return a.then(b,c,d),!0;if(Ua(a))try{var e=a.then;if(Ta(e))return Ws(a,e,b,c,d),!0}catch(f){return c.call(d,f),!0}return!1},Ws=function(a,b,c,d,e){var f=!1,h=function(a){f||(f=!0,c.call(e,a))},l=function(a){f||(f=!0,d.call(e,a))};try{b.call(a,
  h,l)}catch(t){l(t)}},Us=function(a){a.l||(a.l=!0,us(a.s,a))},Ss=function(a){var b=null;a.f&&(b=a.f,a.f=b.next,b.next=null);a.f||(a.h=null);return b};As.prototype.s=function(){for(var a;a=Ss(this);)Ts(this,a,this.b,this.o);this.l=!1};
  var Ts=function(a,b,c,d){if(3==c&&b.f&&!b.g)for(;a&&a.j;a=a.g)a.j=!1;if(b.b)b.b.g=null,Xs(b,c,d);else try{b.g?b.h.call(b.context):Xs(b,c,d)}catch(e){Ys.call(null,e)}js(Cs,b)},Xs=function(a,b,c){2==b?a.h.call(a.context,c):a.f&&a.f.call(a.context,c)},Vs=function(a,b){a.j=!0;us(function(){a.j&&Ys.call(null,b)})},Ys=ks,zs=function(a){Ab.call(this,a)};w(zs,Ab);zs.prototype.name="cancel";var Ls=function(a,b,c){this.X=a;this.resolve=b;this.reject=c};var Zs=function(a,b){Y.call(this);this.h=a||1;this.g=b||Ga;this.j=q(this.o,this);this.l=r()};w(Zs,Y);Zs.prototype.enabled=!1;Zs.prototype.b=null;var $s=function(a,b){a.h=b;a.b&&a.enabled?(a.stop(),a.start()):a.b&&a.stop()};Zs.prototype.o=function(){if(this.enabled){var a=r()-this.l;0<a&&a<.8*this.h?this.b=this.g.setTimeout(this.j,this.h-a):(this.b&&(this.g.clearTimeout(this.b),this.b=null),this.J("tick"),this.enabled&&(this.stop(),this.start()))}};
  Zs.prototype.start=function(){this.enabled=!0;this.b||(this.b=this.g.setTimeout(this.j,this.h),this.l=r())};Zs.prototype.stop=function(){this.enabled=!1;this.b&&(this.g.clearTimeout(this.b),this.b=null)};Zs.prototype.ca=function(){Zs.ta.ca.call(this);this.stop();delete this.g};
  var at=function(a,b,c){if(Ta(a))c&&(a=q(a,c));else if(a&&"function"==typeof a.handleEvent)a=q(a.handleEvent,a);else throw Error("Invalid listener argument");return 2147483647<Number(b)?-1:Ga.setTimeout(a,b||0)},bt=function(a){Ga.clearTimeout(a)},ct=function(a){var b=null;return Qs(new As(function(c,d){b=at(function(){c(void 0)},a);-1==b&&d(Error("Failed to schedule timer."))}),function(a){bt(b);throw a;})};var dt=function(){var a=void 0===a?!0:a;this.m=xq("mr.cloud.slarti.Fetcher");this.b=0;this.f=a};dt.prototype.execute=function(a){var b=this,c="Fetch call "+ ++this.b,d=new ne(function(){return et(b,c,a,function(a){return d.abort(a)})},1E3,this.f?5:1);return d.start()};
  var et=function(a,b,c,d){var e=c.uri.toString().replace(/\?.*/,"?<redacted>"),f=c.method+" "+e;W(a.m,b+": "+f);e=[rr(c).then(function(a){return Promise.resolve(fetch(a))})];c.Ag&&e.push(ct(c.Ag).then(function(){throw yr("API call timed out",504);}));return Promise.race(e).then(function(d){if(!d.ok)return d.json().then(function(a){return a},function(){return null}).then(function(a){var b;a&&a instanceof Object&&a.error&&(b=a.error);throw new tr(d,b);});var e=(r()-c.start)/1E3;W(a.m,b+" succeeded: "+
  f+" duration = "+e+"s");return(e=d.headers.get("content-type"))&&e.includes("application/json")?d.json():e&&(e.includes("image")||e.includes("application/octet-stream"))?d.blob():d.text()},function(c){var e="";if(c instanceof tr)e=", ("+c.status+"): "+c.message,xr(c)&&d(c);else{try{e=", "+JSON.stringify(c,null,2)}catch(t){}c instanceof Error&&"Failed to fetch"==c.message&&(c=yr(c.message))}zq(a.m,b+" failed: "+e);throw c;})};var ft=function(a,b){this.b=Op.b;this.eb=a;this.f=b};var gt=function(a,b){ft.call(this,a,b)};n(gt,ft);gt.prototype.register=function(a){a=new qr({method:"POST",Sb:this.b,vc:["user:register"],eb:this.eb,body:{gcmId:a}});return this.f.execute(a)};gt.prototype.unregister=function(a){a=new qr({method:"POST",Sb:this.b,vc:["user:unregister"],eb:this.eb,body:{gcmId:a}});return this.f.execute(a)};var ht=function(a,b,c){this.m=db("mr.cloud.slarti.GcmRegistration");this.g=a;this.f=b;this.h=c;this.b=null},jt=function(a){if(!a.b){var b=a.f["mr.cloud.slarti.GcmRegistration.ID"];a.b=a.h.register(["307539924703"]).then(function(c){if(c==b)kb(a.m,"Slarti GCM ID unchanged: "+c);else return kb(a.m,"Got new Slarti GCM ID: "+c),(b?it(a,b):Promise.resolve()).then(function(){return a.g.register(c).then(function(){a.f["mr.cloud.slarti.GcmRegistration.ID"]=c})})},function(c){a.m.F("Error registering for GCM notifications",
  c);b&&it(a,b).catch(function(b){a.m.F("Failed to unregister GCM ID with Slarti",b)});throw c;});a.b.then(function(){a.b=null},function(){a.b=null})}return a.b},it=function(a,b){return a.g.unregister(b).then(function(){delete a.f["mr.cloud.slarti.GcmRegistration.ID"]},function(b){a.m.F("Failed to unregister GCM ID with Slarti",b)})};var kt=null,lt=function(){Fm.call(this,5,"mr.cloud.slarti.GcmEventListener","mr.cloud.slarti.SinkDiscoveryService",chrome.gcm.onMessage);this.m=db("mr.cloud.slarti.GcmEventListener")};n(lt,Fm);lt.prototype.Cg=function(a){if(a&&"307539924703"==a.from&&"object"==typeof a.data&&"string"==typeof a.data.data){var b=JSON.parse(a.data.data);a=b.type;b=b.id;if(a)return this.m.info("Received Slarti GCM notification: "+a+" ("+b+")"),!0}return!1};var mt=function(){null==kt&&(kt=new lt);return kt};var nt=function(a,b){for(var c=[],d=1;d<arguments.length;++d)c[d-1]=arguments[d];d=a;c=k(c);for(var e=c.next();!e.done;e=c.next()){if(void 0==d||"object"!=typeof d)return;d=d[e.value]}return d};var ot=function(){Fm.call(this,5,"cloud.GcmEventListener","mr.cloud.discovery.WeaveSinkDiscoveryService",chrome.gcm.onMessage);this.m=db("mr.WeaveGcmEventListener")};n(ot,Fm);ot.prototype.Cg=function(a){if(!a||"919648714761"!=a.from)return!1;a=nt(a,"data","notification");if(!a)return this.m.error("Notification json not found"),!1;try{var b=JSON.parse(a);return!!b&&Array.isArray(b.events)&&0<b.events.length}catch(c){return this.m.error("Invalid json: "+a),!1}};
  var qt=function(){pt||(pt=new ot);return pt},pt=null;var rt=function(a){this.b=a;this.m=db("mr.cloud.messaging.WeaveGcmMessageHandler")};rt.prototype.onMessage=function(a){var b=this;a=JSON.parse(a.data.notification);var c=zj();a.events.forEach(function(a){if(a.deviceId){var d=Aj(c,a.deviceId);switch(a.type){case "deviceCreated":st(b,a);break;case "deviceUpdated":tt(b,a,d);break;case "deviceDeleted":ut(b.b,{sinkId:d});break;default:kb(b.m,function(){return"[unhandled event] "+JSON.stringify(a)})}}else b.m.error("Device ID not provided")})};
  var st=function(a,b){var c=nt(b,"statePatch","_cloudCast","settings","receiverName");"string"!=typeof c?a.m.error("Receiver name not a string: "+c):(b=new Qq(b.deviceId,c,"owner","default",!0),a=a.b,a.b.b.set(b.id,b),a.b.f=Date.now(),Xq(a.f,[b.jb]))},tt=function(a,b,c){b=nt(b,"statePatch","_cloudCast","appStatus");if("string"!=typeof b)a.m.error("App status not a string: "+b);else if(a=a.b,b="available"==b,c=a.b.ja(c))c.isAvailable=b||!1,a.b.f=Date.now(),Yq(a.f,[c.jb])};var vt=function(a,b){this.g=a;this.f=b;this.b=new Tq(this.Fp.bind(this),b,2E4);this.h=new rt(this);qt().addListener();fj(this);kg("mr.cloud.discovery.WeaveSinkDiscoveryService",this)};n(vt,ag);g=vt.prototype;g.Ld=function(){var a=this;Nq(this.g).then(function(b){Oq(a.g,b)},function(){});return this.b.Ld().filter(function(a){return a.isAvailable})};g.ja=function(a){return this.b.ja(a)};
  g.handleEvent=function(a,b){for(var c=[],d=1;d<arguments.length;++d)c[d-1]=arguments[d];if(a==chrome.gcm.onMessage)this.h.onMessage.apply(this.h,m(c));else throw Error("Unhandled event: expected chrome.gcm.onMessage");};
  g.Fp=function(){return Lq(this.g,{descriptionSubstring:"Chrome Streaming Receiver"}).then(function(a){return a.map(function(a){xb("MediaRouter.Cloud.CloudReceiver.Sink.Discovered");var b=a.isAvailable()&&!(a.b.invitations&&0!=a.b.invitations.length);return new Qq(a.getId(),a.f(),a.b.personalizedInfo.maxRole,"default",b)})})};g.Aa=function(){return"WeaveSinkDiscoveryService"};g.gb=function(){return[{cache:ar(this.b)}]};g.fb=function(){var a=cj(this);a&&br(this.b,a.cache)};
  var ut=function(a,b){if(b=a.b.ja(b.sinkId))a.b.b.delete(b.id),a.b.f=Date.now(),Zq(a.f,[b.jb])};var wt=Ga.JSON.parse,xt=Ga.JSON.stringify;var yt=function(a,b,c,d,e,f,h,l,t){this.b=null;this.w=!1;this.A=Ms();this.g=[];this.s=a?encodeURIComponent(String(a)):null;this.B=null;!d&&b&&(this.B=b);this.H=c||null;this.h=!d;this.j=null!=e?e:null;this.o=f||null;this.W=!!h;this.D=l||null;this.l=null!=t?t:null};w(yt,zr);var zt=be(Nd(new Md(Kd,"https://apis.google.com/js/client.js")));
  yt.prototype.init=function(){var a=q(function(a){this.b=a;var b=Ma("auth",a);Ma("client.request",a)&&b?this.G():a.load("client",q(this.G,this))},this),b=At("gapi");b?a(b.gapi):Bt(this,a);return this.A.X};
  var At=function(a){for(var b=window,c=Ma(a,b);!c&&b!=window.top&&Ct(b.parent,a);)b=b.parent,c=Ma(a,b);return c?b:null},Ct=function(a,b){try{return!!a&&null!=a.location.href&&bd(a,b)}catch(c){return!1}},Bt=function(a,b){var c=At("gapi_onload");if(c){var d=c.gapi_onload;c.gapi_onload=function(){d();b(c.gapi)}}else{window.gapi_onload=function(){b(window.gapi)};var e=document.createElement("SCRIPT");le(e,zt);a.D&&Fe(e,xt(a.D));document.getElementsByTagName("head")[0].appendChild(e)}};
  yt.prototype.G=function(){for(var a=0;a<this.g.length;a++)this.g[a].ob.resolve(Dt(this,this.g[a].requestData));this.w=!0;this.A.resolve(this.b)};yt.prototype.sendRequest=function(a){if(this.w)return Dt(this,a);var b=Ms();this.g.push({requestData:a,ob:b});return b.X};
  var Dt=function(a,b){var c=Ma("config.get",a.b);if(!a.h){var d=c("googleapis.config/auth/useFirstPartyAuth");var e=c("googleapis.config/auth/useOriginToken")}var f;null!=a.j&&(f=c("client/cors"));var h;null!=a.l&&(h=c("client/xd4"));try{var l=Ma("config.update",a.b);a.h||(l("googleapis.config/auth/useFirstPartyAuth",!1),l("googleapis.config/auth/useOriginToken",!1));null!=a.j&&l("client/cors",a.j);null!=a.l&&l("client/xd4",a.l);var t=Et(a);b.headers&&Wc(t,b.headers);var u={headers:t,root:a.H,path:b.path,
  method:b.method,body:b.body},A=b.params||{};a.s&&!a.o?Wc(A,{key:a.s}):a.o&&Wc(A,{key:null});Qc(A)||(u.params=A);var G=Es(Ma("client.request",a.b)(u));b.callback&&G.then(function(a){b.callback.apply(null,[a.result,a])},function(a){b.callback.apply(null,[a.result,a])});return G}finally{c=Ma("config.update",a.b),a.h||(c("googleapis.config/auth/useFirstPartyAuth",d),c("googleapis.config/auth/useOriginToken",e)),null!=a.j&&c("client/cors",f),null!=a.l&&c("client/xd4",h)}},Et=function(a){if(a.h){if(a.o)return{Authorization:"Bearer "+
  a.o};var b=Ma("auth.getAuthHeaderValueForFirstParty",a.b);return{Authorization:a.W?b([]):b(),"X-Goog-AuthUser":a.B}}return{}};var Ft=function(a){this.b=a},Zp=function(a,b,c){var d="";b.forEach(function(a){d+="/"+encodeURIComponent(a)});a=new Vo(a+d);c&&(c=kp(c),Yo(a,c));return a},$p=function(a,b,c,d){return a.b.getAuthToken().then(function(e){var f=Gt(e);return Ht(f,b,c,d).catch(function(f){if("INVALID_ACCESS_ERROR"==f)return It(a,e,b,c,d);throw f;})})},It=function(a,b,c,d,e){return nr(b).then(function(){return $p(a,c,d,e)})},Ht=function(a,b,c,d){return new Promise(function(e,f){a.sendRequest(Jt(b,c,function(a){a&&!a.error?
  e(a):a&&401==a.error.code?f("INVALID_ACCESS_ERROR"):f(a&&a.error?a.error.errors?a.error.errors[0]:a:Error(a))},d))})},Gt=function(a){a=new yt(void 0,void 0,void 0,!1,!1,a);a.init();return a},Jt=function(a,b,c,d){a={callback:c,method:b,path:a.toString()};d&&(a.body=d);return a};var Kt={Qs:{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"}},Ps:{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"}}},Lt=Kt;Lt=Kt;var Mt={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,"\u20ba","TRY"],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 Nt={Ej:".",Eh:",",Qj:"%",Qh:"0",gn:"+",Nj:"-",Ij:"E",Rj:"\u2030",Fh:"\u221e",bn:"NaN",Fm:"#,##0.###",mx:"#E0",nw:"#,##0%",dt:"\u00a4#,##0.00",Fj:"USD"},Ot=Nt;Ot=Nt;var Qt=function(){this.A=40;this.f=1;this.g=3;this.B=this.l=0;this.H=!1;this.w=this.s="";this.h=Ot.Nj;this.C="";this.b=1;this.o=!1;this.j=[];this.D=this.G=!1;var a=Ot.Fm;a.replace(/ /g,"\u00a0");var b=[0];this.s=Pt(this,a,b);for(var c=b[0],d=-1,e=0,f=0,h=0,l=-1,t=a.length,u=!0;b[0]<t&&u;b[0]++)switch(a.charAt(b[0])){case "#":0<f?h++:e++;0<=l&&0>d&&l++;break;case "0":if(0<h)throw Error('Unexpected "0" in pattern "'+a+'"');f++;0<=l&&0>d&&l++;break;case ",":0<l&&this.j.push(l);l=0;break;case ".":if(0<=
  d)throw Error('Multiple decimal separators in pattern "'+a+'"');d=e+f+h;break;case "E":if(this.D)throw Error('Multiple exponential symbols in pattern "'+a+'"');this.D=!0;this.B=0;b[0]+1<t&&"+"==a.charAt(b[0]+1)&&(b[0]++,this.H=!0);for(;b[0]+1<t&&"0"==a.charAt(b[0]+1);)b[0]++,this.B++;if(1>e+f||1>this.B)throw Error('Malformed exponential pattern "'+a+'"');u=!1;break;default:b[0]--,u=!1}0==f&&0<e&&0<=d&&(f=d,0==f&&f++,h=e-f,e=f-1,f=1);if(0>d&&0<h||0<=d&&(d<e||d>e+f)||0==l)throw Error('Malformed pattern "'+
  a+'"');h=e+f+h;this.g=0<=d?h-d:0;0<=d&&(this.l=e+f-d,0>this.l&&(this.l=0));this.f=(0<=d?d:h)-e;this.D&&(this.A=e+this.f,0==this.g&&0==this.f&&(this.f=1));this.j.push(Math.max(0,l));this.G=0==d||d==h;c=b[0]-c;this.w=Pt(this,a,b);b[0]<a.length&&";"==a.charAt(b[0])?(b[0]++,1!=this.b&&(this.o=!0),this.h=Pt(this,a,b),b[0]+=c,this.C=Pt(this,a,b)):(this.h+=this.s,this.C+=this.w)};
  Qt.prototype.parse=function(a,b){b=b||[0];a=a.replace(/ /g,"\u00a0");var c=a.indexOf(this.s,b[0])==b[0],d=a.indexOf(this.h,b[0])==b[0];c&&d&&(this.s.length>this.h.length?d=!1:this.s.length<this.h.length&&(c=!1));c?b[0]+=this.s.length:d&&(b[0]+=this.h.length);if(a.indexOf(Ot.Fh,b[0])==b[0]){b[0]+=Ot.Fh.length;var e=Infinity}else{e=a;for(var f=!1,h=!1,l=!1,t=-1,u=1,A=Ot.Ej,G=Ot.Eh,V=Ot.Ij,Q="";b[0]<e.length;b[0]++){var ha=e.charAt(b[0]),Da=Rt(ha);if(0<=Da&&9>=Da)Q+=Da,l=!0;else if(ha==A.charAt(0)){if(f||
  h)break;Q+=".";f=!0}else if(ha==G.charAt(0)&&("\u00a0"!=G.charAt(0)||b[0]+1<e.length&&0<=Rt(e.charAt(b[0]+1)))){if(f||h)break}else if(ha==V.charAt(0)){if(h)break;Q+="E";h=!0;t=b[0]}else if("+"==ha||"-"==ha){if(l&&t!=b[0]-1)break;Q+=ha}else if(1==this.b&&ha==Ot.Qj.charAt(0)){if(1!=u)break;u=100;if(l){b[0]++;break}}else if(1==this.b&&ha==Ot.Rj.charAt(0)){if(1!=u)break;u=1E3;if(l){b[0]++;break}}else break}1!=this.b&&(u=this.b);e=parseFloat(Q)/u}if(c){if(a.indexOf(this.w,b[0])!=b[0])return NaN;b[0]+=
  this.w.length}else if(d){if(a.indexOf(this.C,b[0])!=b[0])return NaN;b[0]+=this.C.length}return d?-e:e};
  Qt.prototype.format=function(a){if(isNaN(a))return Ot.bn;var b=[];var c=St;a=Tt(a,-c.Ko);b.push(c.prefix);var d=0>a||0==a&&0>1/a;b.push(d?this.h:this.s);if(isFinite(a))if(a=a*(d?-1:1)*this.b,this.D)if(0==a)Ut(this,a,this.f,b),Vt(this,0,b);else{var e=Math.floor(Math.log(a)/Math.log(10)+2E-15);a=Tt(a,-e);var f=this.f;1<this.A&&this.A>this.f?(f=e%this.A,0>f&&(f=this.A+f),a=Tt(a,f),e-=f,f=1):1>this.f?(e++,a=Tt(a,-1)):(e-=this.f-1,a=Tt(a,this.f-1));Ut(this,a,f,b);Vt(this,e,b)}else Ut(this,a,this.f,b);
  else b.push(Ot.Fh);b.push(d?this.C:this.w);b.push(c.rr);return b.join("")};
  var Ut=function(a,b,c,d){if(a.l>a.g)throw Error("Min value must be less than max value");d||(d=[]);var e=Tt(b,a.g);e=Math.round(e);if(isFinite(e)){b=Math.floor(Tt(e,-a.g));var f=Math.floor(e-Tt(b,a.g))}else f=0;e=b;b=f;var h=e;f=b;var l=0<a.l||0<f||!1;e=a.l;l&&(e=a.l);var t="";for(b=h;1E20<b;)t="0"+t,b=Math.round(Tt(b,-1));t=b+t;var u=Ot.Ej;b=Ot.Qh.charCodeAt(0);var A=t.length,G=0;if(0<h||0<c){for(h=A;h<c;h++)d.push(String.fromCharCode(b));if(2<=a.j.length)for(c=1;c<a.j.length;c++)G+=a.j[c];c=A-G;
  if(0<c){h=a.j;G=A=0;for(var V,Q=Ot.Eh,ha=t.length,Da=0;Da<ha;Da++)if(d.push(String.fromCharCode(b+1*Number(t.charAt(Da)))),1<ha-Da)if(V=h[G],Da<c){var Zd=c-Da;(1===V||0<V&&1===Zd%V)&&d.push(Q)}else G<h.length&&(Da===c?G+=1:V===Da-c-A+1&&(d.push(Q),A+=V,G+=1))}else{c=t;t=a.j;h=Ot.Eh;V=c.length;Q=[];for(A=t.length-1;0<=A&&0<V;A--){G=t[A];for(ha=0;ha<G&&0<=V-ha-1;ha++)Q.push(String.fromCharCode(b+1*Number(c.charAt(V-ha-1))));V-=G;0<V&&Q.push(h)}d.push.apply(d,Q.reverse())}}else l||d.push(String.fromCharCode(b));
  (a.G||l)&&d.push(u);l=String(f);f=l.split("e+");if(2==f.length){if(l=parseFloat(f[0])){u=l;if(isFinite(u)){for(c=0;1<=(u/=10);)c++;u=c}else u=0<u?u:0;u=0-u-1;l=-1>u?l&&isFinite(l)?Tt(Math.round(Tt(l,-1)),1):l:l&&isFinite(l)?Tt(Math.round(Tt(l,u)),-u):l}l=String(l);l=l.replace(".","");l+=wc("0",parseInt(f[1],10)-l.length+1)}a.g+1>l.length&&(l="1"+wc("0",a.g-l.length)+l);for(a=l.length;"0"==l.charAt(a-1)&&a>e+1;)a--;for(h=1;h<a;h++)d.push(String.fromCharCode(b+1*Number(l.charAt(h))))},Vt=function(a,
  b,c){c.push(Ot.Ij);0>b?(b=-b,c.push(Ot.Nj)):a.H&&c.push(Ot.gn);b=""+b;for(var d=Ot.Qh,e=b.length;e<a.B;e++)c.push(d);c.push(b)},Rt=function(a){a=a.charCodeAt(0);if(48<=a&&58>a)return a-48;var b=Ot.Qh.charCodeAt(0);return b<=a&&a<b+10?a-b:-1},Pt=function(a,b,c){for(var d="",e=!1,f=b.length;c[0]<f;c[0]++){var h=b.charAt(c[0]);if("'"==h)c[0]+1<f&&"'"==b.charAt(c[0]+1)?(c[0]++,d+="'"):e=!e;else if(e)d+=h;else switch(h){case "#":case "0":case ",":case ".":case ";":return d;case "\u00a4":c[0]+1<f&&"\u00a4"==
  b.charAt(c[0]+1)?(c[0]++,d+=Ot.Fj):d+=Mt[Ot.Fj][1];break;case "%":if(!a.o&&1!=a.b)throw Error("Too many percent/permill");if(a.o&&100!=a.b)throw Error("Inconsistent use of percent/permill characters");a.b=100;a.o=!1;d+=Ot.Qj;break;case "\u2030":if(!a.o&&1!=a.b)throw Error("Too many percent/permill");if(a.o&&1E3!=a.b)throw Error("Inconsistent use of percent/permill characters");a.b=1E3;a.o=!1;d+=Ot.Rj;break;default:d+=h}}return d},St={prefix:"",rr:"",Ko:0},Tt=function(a,b){if(!a||!isFinite(a)||0==
  b)return a;a=String(a).split("e");return parseFloat(a[0]+"e"+(parseInt(a[1]||0,10)+b))};var Wt=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"},Xt=Wt;Xt=Wt;var Yt=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"},Zt=Yt;Zt=Yt;var du=function(){this.h=$t;this.f=this.b=this.j=null;var a=Ot,b=Lt;if(au!==a||bu!==b)au=a,bu=b,cu=new Qt;this.l=cu},au=null,bu=null,cu=null,eu=/'([{}#].*?)'/g,fu=/''/g;du.prototype.format=function(a){if(this.h){this.j=[];var b=gu(this,this.h);this.f=hu(this,b);this.h=null}if(this.f&&0!=this.f.length)for(this.b=y(this.j),b=[],iu(this,this.f,a,!1,b),a=b.join("");0<this.b.length;)a=a.replace(this.g(this.b),this.b.pop());else a="";return a};
  var iu=function(a,b,c,d,e){for(var f=0;f<b.length;f++)switch(b[f].type){case 4:e.push(b[f].value);break;case 3:var h=b[f].value,l=a,t=e,u=c[h];Ha(u)?(l.b.push(u),t.push(l.g(l.b))):t.push("Undefined parameter - "+h);break;case 2:h=b[f].value;l=e;t=h.Sg;Ha(c[t])?(t=h[c[t]],Ha(t)||(t=h.other),iu(a,t,c,d,l)):l.push("Undefined parameter - "+t);break;case 0:h=b[f].value;ju(a,h,c,Zt,d,e);break;case 1:h=b[f].value;ju(a,h,c,Xt,d,e);break;default:Db("Unrecognized block type: "+b[f].type)}},ju=function(a,b,
  c,d,e,f){var h=b.Sg,l=b.kk,t=+c[h];isNaN(t)?f.push("Undefined or invalid parameter - "+h):(l=t-l,h=b[c[h]],Ha(h)||(d=d(l),h=b[d],Ha(h)||(h=b.other)),b=[],iu(a,h,c,e,b),c=b.join(""),e?f.push(c):(a=a.l.format(l),f.push(c.replace(/#/g,a))))},gu=function(a,b){var c=a.j,d=q(a.g,a);b=b.replace(fu,function(){c.push("'");return d(c)});return b=b.replace(eu,function(a,b){c.push(b);return d(c)})},ku=function(a){var b=0,c=[],d=[],e=/[{}]/g;e.lastIndex=0;for(var f;f=e.exec(a);){var h=f.index;"}"==f[0]?(c.pop(),
  0==c.length&&(f={type:1},f.value=a.substring(b,h),d.push(f),b=h+1)):(0==c.length&&(b=a.substring(b,h),""!=b&&d.push({type:0,value:b}),b=h+1),c.push("{"))}b=a.substring(b);""!=b&&d.push({type:0,value:b});return d},lu=/^\s*(\w+)\s*,\s*plural\s*,(?:\s*offset:(\d+))?/,mu=/^\s*(\w+)\s*,\s*selectordinal\s*,/,nu=/^\s*(\w+)\s*,\s*select\s*,/,hu=function(a,b){var c=[];b=ku(b);for(var d=0;d<b.length;d++){var e={};if(0==b[d].type)e.type=4,e.value=b[d].value;else if(1==b[d].type){var f=b[d].value;switch(lu.test(f)?
  0:mu.test(f)?1:nu.test(f)?2:/^\s*\w+\s*/.test(f)?3:5){case 2:e.type=2;e.value=ou(a,b[d].value);break;case 0:e.type=0;e.value=pu(a,b[d].value);break;case 1:e.type=1;e.value=qu(a,b[d].value);break;case 3:e.type=3;e.value=b[d].value;break;default:Db("Unknown block type for pattern: "+b[d].value)}}else Db("Unknown part of the pattern.");c.push(e)}return c},ou=function(a,b){var c="";b=b.replace(nu,function(a,b){c=b;return""});var d={};d.Sg=c;b=ku(b);for(var e=0;e<b.length;){var f=b[e].value;e++;if(1==
  b[e].type)var h=hu(a,b[e].value);else Db("Expected block type.");d[f.replace(/\s/g,"")]=h;e++}return d},pu=function(a,b){var c="",d=0;b=b.replace(lu,function(a,b,e){c=b;e&&(d=parseInt(e,10));return""});var e={};e.Sg=c;e.kk=d;b=ku(b);for(var f=0;f<b.length;){var h=b[f].value;f++;if(1==b[f].type)var l=hu(a,b[f].value);else Db("Expected block type.");e[h.replace(/\s*(?:=)?(\w+)\s*/,"$1")]=l;f++}return e},qu=function(a,b){var c="";b=b.replace(mu,function(a,b){c=b;return""});var d={};d.Sg=c;d.kk=0;b=ku(b);
  for(var e=0;e<b.length;){var f=b[e].value;e++;if(1==b[e].type)var h=hu(a,b[e].value);else Db("Expected block type.");d[f.replace(/\s*(?:=)?(\w+)\s*/,"$1")]=h;e++}return d};du.prototype.g=function(a){return"\ufddf_"+(a.length-1).toString(10)+"_"};var ru=chrome.i18n.getMessage("1522140683318860351"),su=chrome.i18n.getMessage("4246483347873264186"),tu=chrome.i18n.getMessage("5991427458288444010"),yf=chrome.i18n.getMessage("6063910461797960050"),uu=chrome.i18n.getMessage("7735695102441495789"),vu=chrome.i18n.getMessage("4575332923598659024"),$t=chrome.i18n.getMessage("2297080986956220930"),wu=new du;var xu=function(a){this.b=a;this.m=db("mr.cloud.mesi.MesiService")},fr=function(a){var b=Zp(Qp.b,["hangouts","search"]);a.m.info("Retrieving Hangouts from MESI: "+b);return $p(a.b,b,"POST",yu).then(function(a){var b=[];a.result&&(b=a.result.map(function(a){var b=a.hangout,c=b.meeting_room_name,d;b.meeting_domain?d=b.meeting_domain:"BUSINESS"==b.type&&b.company_title&&(d=b.company_title.toLowerCase());var e=wu.format({ORGANIZER:"",PARTICIPANTS:0});if((a=a.participant)&&0<a.length){var u=a[0].display_name;
  e=a.reduce(function(a,b){a.add(b.user_id);"ORGANIZER"==b.role&&(u=b.display_name);return a},new Set);e=wu.format({ORGANIZER:u,PARTICIPANTS:e.size})}return c&&d?new Sp(!1,c+"@"+d,d,c,e,b.hangout_id):new Sp(!1,b.hangout_id,d,c,e,b.hangout_id)}));return b})},yu={request_header:{client_version:{client_id:"39"}},search_sources:["0"]};var zu=function(a,b){this.f=a;this.b=b},Cu=function(a,b,c,d){switch(b.type){case "REFRESH_AUTH":var e=d.Hc,f=d.deviceId,h=d.He;return or(a.f).then(function(){Au(a.b,new Ng("AUTH_READY",{Hc:e,cb:f,He:h}),c.id)});case "LOCAL_PRESENT":return Au(a.b,new Ng("AUTH_READY",{Hc:d.Hc,cb:d.deviceId,He:d.He,Cd:!b.data.local}),c.id),Promise.resolve();case "STATUS_REQUEST":return Au(a.b,b,c.id),Promise.resolve();case "STATUS_RESPONSE":return Au(a.b,b,c.id,!0),b.data.routeDescription||Au(a.b,b,c.id),Promise.resolve();
  case "HANGOUT_INACTIVE":return Bu(a.b,c,4,Cf(new xf(uu,"warning"),c.sinkId));case "HANGOUT_INVALID":return Bu(a.b,c,3,Cf(new xf(vu,"warning"),c.sinkId));default:return Promise.reject(Error("Unknown type: "+b.type))}};var Du=new Map([["status","status"],["results","result"],["expirationTime","expiration_time"]]),Eu=function(a,b){ft.call(this,a,b);this.m=xq("mr.cloud.slarti.CommandsService")};n(Eu,ft);Eu.prototype.get=function(a){a=new qr({method:"GET",Sb:this.b,vc:["commands",a],eb:this.eb});return this.f.execute(a).then(function(a){return a})};
  Eu.prototype.list=function(a){a=new qr({method:"GET",Sb:this.b,vc:["commands"],Jl:{deviceId:a},eb:this.eb});return this.f.execute(a).then(function(a){return a.command||[]})};Eu.prototype.send=function(a,b){var c=this;a=new qr({method:"POST",Sb:this.b,vc:["commands:send"],eb:this.eb,body:{command:b,deviceId:a}});return this.f.execute(a).then(function(a){c.m.info("Sent Slarti command with ID "+a.id);return a})};
  Eu.prototype.update=function(a,b){for(var c=[],d={},e=k(Du.keys()),f=e.next();!f.done;f=e.next())f=f.value,b[f]&&(d[f]=b[f],c.push(Du.get(f)));d.id=a;a=new qr({method:"PUT",Sb:this.b,vc:["commands",a],eb:this.eb,body:{command:d,updateMask:c}});return this.f.execute(a).then(function(a){return a})};var Fu=Ga.JSON.parse;var Gu=function(){};Gu.prototype.b=null;var Iu=function(a){var b;(b=a.b)||(b={},Hu(a)&&(b[0]=!0,b[1]=!0),b=a.b=b);return b};var Ju,Ku=function(){};w(Ku,Gu);var Lu=function(a){return(a=Hu(a))?new ActiveXObject(a):new XMLHttpRequest},Hu=function(a){if(!a.f&&"undefined"==typeof XMLHttpRequest&&"undefined"!=typeof ActiveXObject){for(var b=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"],c=0;c<b.length;c++){var d=b[c];try{return new ActiveXObject(d),a.f=d}catch(e){}}throw Error("Could not create ActiveXObject. ActiveX might be disabled, or MSXML might not be installed");}return a.f};Ju=new Ku;var Mu=function(a){Y.call(this);this.headers=new Oj;this.N=a||null;this.g=!1;this.M=this.b=null;this.ia=this.G="";this.o=0;this.h="";this.j=this.Z=this.D=this.P=!1;this.l=0;this.w=null;this.s="";this.H=this.B=!1};w(Mu,Y);Mu.prototype.m=xq("goog.net.XhrIo");var Nu=/^https?$/i,Ou=["POST","PUT"],Pu=[],Qu=function(a,b,c,d,e,f,h){var l=new Mu;Pu.push(l);b&&l.listen("complete",b);bs(l,"ready",l.qa);f&&(l.l=Math.max(0,f));h&&(l.B=h);l.send(a,c,d,e);return l};Mu.prototype.qa=function(){this.Oa();Xb(Pu,this)};
  Mu.prototype.send=function(a,b,c,d){if(this.b)throw Error("[goog.net.XhrIo] Object is active with another request="+this.G+"; newUri="+a);b=b?b.toUpperCase():"GET";this.G=a;this.h="";this.o=0;this.ia=b;this.P=!1;this.g=!0;this.b=this.N?Lu(this.N):Lu(Ju);this.M=this.N?Iu(this.N):Iu(Ju);this.b.onreadystatechange=q(this.ka,this);try{Aq(this.m,Ru(this,"Opening Xhr")),this.Z=!0,this.b.open(b,String(a),!0),this.Z=!1}catch(f){Aq(this.m,Ru(this,"Error opening Xhr: "+f.message));Su(this,f);return}a=c||"";
  var e=this.headers.clone();d&&Gk(d,function(a,b){e.set(b,a)});d=Ob(e.rb(),Tu);c=Ga.FormData&&a instanceof Ga.FormData;!Qb(Ou,b)||d||c||e.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");e.forEach(function(a,b){this.b.setRequestHeader(b,a)},this);this.s&&(this.b.responseType=this.s);"withCredentials"in this.b&&this.b.withCredentials!==this.B&&(this.b.withCredentials=this.B);try{Uu(this),0<this.l&&(this.H=Vu(this.b),Aq(this.m,Ru(this,"Will abort after "+this.l+"ms if incomplete, xhr2 "+
  this.H)),this.H?(this.b.timeout=this.l,this.b.ontimeout=q(this.na,this)):this.w=at(this.na,this.l,this)),Aq(this.m,Ru(this,"Sending request")),this.D=!0,this.b.send(a),this.D=!1}catch(f){Aq(this.m,Ru(this,"Send error: "+f.message)),Su(this,f)}};var Vu=function(a){return gd&&Bd(9)&&p(a.timeout)&&Ha(a.ontimeout)},Tu=function(a){return mc("Content-Type",a)};
  Mu.prototype.na=function(){"undefined"!=typeof Fa&&this.b&&(this.h="Timed out after "+this.l+"ms, aborting",this.o=8,Aq(this.m,Ru(this,this.h)),this.J("timeout"),this.abort(8))};var Su=function(a,b){a.g=!1;a.b&&(a.j=!0,a.b.abort(),a.j=!1);a.h=b;a.o=5;Wu(a);Xu(a)},Wu=function(a){a.P||(a.P=!0,a.J("complete"),a.J("error"))};Mu.prototype.abort=function(a){this.b&&this.g&&(Aq(this.m,Ru(this,"Aborting")),this.g=!1,this.j=!0,this.b.abort(),this.j=!1,this.o=a||7,this.J("complete"),this.J("abort"),Xu(this))};
  Mu.prototype.ca=function(){this.b&&(this.g&&(this.g=!1,this.j=!0,this.b.abort(),this.j=!1),Xu(this,!0));Mu.ta.ca.call(this)};Mu.prototype.ka=function(){this.C()||(this.Z||this.D||this.j?Yu(this):this.ra())};Mu.prototype.ra=function(){Yu(this)};
  var Yu=function(a){if(a.g&&"undefined"!=typeof Fa)if(a.M[1]&&4==Zu(a)&&2==a.La())Aq(a.m,Ru(a,"Local request error detected and ignored"));else if(a.D&&4==Zu(a))at(a.ka,0,a);else if(a.J("readystatechange"),4==Zu(a)){Aq(a.m,Ru(a,"Request complete"));a.g=!1;try{if($u(a))a.J("complete"),a.J("success");else{a.o=6;try{var b=2<Zu(a)?a.b.statusText:""}catch(c){Aq(a.m,"Can not get status: "+c.message),b=""}a.h=b+" ["+a.La()+"]";Wu(a)}}finally{Xu(a)}}},Xu=function(a,b){if(a.b){Uu(a);var c=a.b,d=a.M[0]?Na:null;
  a.b=null;a.M=null;b||a.J("ready");try{c.onreadystatechange=d}catch(e){zq(a.m,"Problem encountered resetting onreadystatechange: "+e.message)}}},Uu=function(a){a.b&&a.H&&(a.b.ontimeout=null);a.w&&(bt(a.w),a.w=null)},$u=function(a){var b=a.La();a:switch(b){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var c=!0;break a;default:c=!1}if(!c){if(b=0===b)a=String(a.G).match(Po)[1]||null,!a&&Ga.self&&Ga.self.location&&(a=Ga.self.location.protocol,a=a.substr(0,a.length-1)),b=!Nu.test(a?a.toLowerCase():
  "");c=b}return c},Zu=function(a){return a.b?a.b.readyState:0};Mu.prototype.La=function(){try{return 2<Zu(this)?this.b.status:-1}catch(a){return-1}};
  var av=function(a){try{return a.b?a.b.responseText:""}catch(b){return Aq(a.m,"Can not get responseText: "+b.message),""}},bv=function(a){if(a.b)return Fu(a.b.responseText)},cv=function(a){try{if(!a.b)return null;if("response"in a.b)return a.b.response;switch(a.s){case "":case "text":return a.b.responseText;case "arraybuffer":if("mozResponseArrayBuffer"in a.b)return a.b.mozResponseArrayBuffer}zq(a.m,"Response type "+a.s+" is not supported on this browser");return null}catch(b){return Aq(a.m,"Can not get response: "+
  b.message),null}};Mu.prototype.getResponseHeader=function(a){if(this.b&&4==Zu(this))return a=this.b.getResponseHeader(a),null===a?void 0:a};var dv=function(a){var b={};a=(a.b&&4==Zu(a)?a.b.getAllResponseHeaders()||"":"").split("\r\n");for(var c=0;c<a.length;c++)if(!nc(a[c])){var d=Dc(a[c],": ",2);b[d[0]]=b[d[0]]?b[d[0]]+(", "+d[1]):d[1]}return b},Ru=function(a,b){return b+" ["+a.ia+" "+a.G+" "+a.La()+"]"};var ev=function(){this.m=db("mr.cloud.CredentialService")},hv=function(a){var b=new zb,c=Rp.b+"/iceconfig?key="+Rp.f;a.m.info("Requesting TURN credentials from "+c);var d=Qu(c,function(){$u(d)?(a.m.info("Got TURN credentials: "+av(d)),b.resolve(fv(a,bv(d)))):b.resolve(gv(a))},"POST",void 0,{"Content-Type":"application/json"});return b.b},fv=function(a,b){try{var c=[];b.iceServers.forEach(function(a){a.urls.forEach(function(b){0==b.indexOf("turn:")&&c.push({url:b,credential:a.credential,username:a.username})})});
  return c}catch(d){return a.m.error("Error parsing TURN credentials.",d),[]}},gv=function(a){a.m.error("XHR failed fetching TURN credentials.",null);return[]};var iv=function(a,b,c){this.m=db("mr.cloud.slarti.MessageHandler");this.g=a;this.h=b;this.b=c;this.f=new Map},jv=function(a){if(rg(a.mediaSource))return Promise.resolve({title:"screen"});var b=a.ib&&a.ib.tabId;return null==b?Promise.resolve({title:"",url:""}):new Promise(function(a){chrome.tabs.get(b,function(b){a({title:b&&b.title||"",url:b&&b.url||""})})})},kv=function(a,b,c,d){var e=d.deviceId,f=b.data;return jv(c).then(function(b){b={id:null,issuer:null,name:"stream",status:null,results:null,
  expirationTime:null,parameters:JSON.stringify({info:b,sessionDescription:f.description,mediaConstraints:f.mediaConstraints,settings:f.settings})};return a.g.send(e,b).then(function(b){return new Promise(function(e,f){a.f.set(b.id,{routeId:c.id,sinkId:d.id,resolve:e,reject:f,pp:"PENDING_APPROVAL"==b.status})})},function(){Bu(a.b,c.id,7,Cf(Bf(Af(new xf(ru,"warning")),c.id),d.id))})})},lv=function(a,b){return hv(a.h).then(function(c){Au(a.b,new Ng("TURN_CREDENTIALS",{credentials:c}),b.id)})};var mv=function(a,b,c,d){this.f=a;this.g=b;this.h=c;this.b=d},pv=function(a,b,c,d,e){return new Promise(function(f){switch(b){case "slarti":case "weave":case "mesi":break;default:throw Error("Unrecognized channel type: "+b);}if(!c.type)throw Error("Message has no type");switch(c.type){case "STOP":f(Bu(a.b,d,1,null));return;case "SESSION_START_SUCCESS":Jp(0);break;case "SESSION_END":break;case "SESSION_FAILURE":Jp(1);f(Bu(a.b,d,2,Cf(new xf(ru,"warning"),d?d.sinkId:"")));return;case "__webrtc_stats__":break;
  case "PRESENTATION_CONNECTION_MESSAGE":Au(a.b,c.data,d.id,!0);break;case "OFFER":switch(b){case "slarti":f(kv(a.f,c,d,e));return;case "weave":f(nv(a.g,c,d,e));return;default:throw Error("Unexpected channel type: "+b);}case "GET_TURN_CREDENTIALS":switch(b){case "slarti":f(lv(a.f,d));return;case "weave":f(ov(a.g,d));return;default:throw Error("Unexpected channel type: "+b);}case "REFRESH_AUTH":case "LOCAL_PRESENT":case "MUTE":case "STATUS_REQUEST":case "STATUS_RESPONSE":case "HANGOUT_INACTIVE":case "HANGOUT_INVALID":f(Cu(a.h,
  c,d,e));return;case "new_session":Au(a.b,c,d.id,!0);break;case "remove_session":Au(a.b,c,d.id,!0);a.b.terminateRoute(d.id);break;default:throw Error("Unknown type: "+c.type);}f()})};var qv=function(a,b,c){this.state=a;this.type=null!=b?b:null;this.results=null!=c?c:null},rv=function(a){this.b=a},uv=function(a,b,c,d){return sv(a,Hq,b,c,d,35E3).then(function(b){return tv(a,b)})},wv=function(a,b,c,d){return sv(a,Iq,b,c,d,23E3).then(function(a){var b=a.state;return"done"==b?(a=vv(a),new qv(b,a.type,new Eq(a.sessionDescription))):new qv(b)})},sv=function(a,b,c,d,e,f){var h={_webrtcMessage:JSON.stringify(d.presentationUrl?new Eq(d.description,null,d.presentationUrl,d.presentationId):
  new Eq(d.description))};d.settings&&(h._settings=Kg(d.settings));d.mediaConstraints&&(h._optMediaConstraints=JSON.stringify(d.mediaConstraints));e&&(h._user=JSON.stringify(e));return xv(a,c,b,h,f)},tv=function(a,b){var c=b.state;switch(c){case "done":return Promise.resolve(yv(b));case "queued":case "inProgress":return zv(a,b).then(function(b){return tv(a,b)});default:return Promise.resolve(new qv(c))}},zv=function(a,b){return new Promise(function(c){var d=setInterval(function(){Av(a,b.id).then(function(a){"queued"!=
  a.state&&"inProgress"!=a.state&&(clearInterval(d),c(a))})},2E3)})},yv=function(a){a=vv(a);return"__cloud_webrtc_session_message__"==a.type?new qv("done","knocking_cloud_webrtc_session_message",new Eq(a.sessionDescription)):new qv("done",a.type)},xv=function(a,b,c,d,e){b={deviceId:b,name:"_cloudCast."+c.name,parameters:d,expirationTimeoutMs:e||1E4};c={};e&&(c.responseAwaitMs=Math.min(e+5E3,25E3));e=Zp(Np.b,["commands"],c);return $p(a.b,e,"POST",b)},vv=function(a){return a.results&&a.results.results?
  JSON.parse(a.results.results):null},Av=function(a,b){b=Zp(Np.b,["commands",b]);return $p(a.b,b,"GET")};rv.$inject=["gapiService"];var Bv=function(a,b,c,d){this.f=a;this.g=b;this.h=c;this.b=d},nv=function(a,b,c,d){return Cv(a,b,d).then(function(b){a:{var d=c.id;if("done"!=b.state)d=Promise.reject(Error("Offer not executed by receiver. State: "+b.state));else{switch(b.type){case "__cloud_webrtc_session_message__":b=new Ng("ANSWER",b.results.sessionDescription);Au(a.b,b,d);break;case "knocking_cloud_webrtc_session_message":Ip(0);b=new Ng("KNOCK_ANSWER",b.results.sessionDescription);Au(a.b,b,d);break;case "knock_denied":Ip(1);Dv(a,
  su,d);break;case "knock_timeout":Ip(2);Dv(a,tu,d);break;default:d=Promise.reject(Error("Invalid message type: "+b.type));break a}d=Promise.resolve()}}return d})},ov=function(a,b){return hv(a.h).then(function(c){Au(a.b,new Ng("TURN_CREDENTIALS",{credentials:c}),b.id)})},Cv=function(a,b,c){var d=c.deviceId,e=a.g.b;e=e?new Cq(e):void 0;b=b.data;switch(c.Xh){case "owner":Lp(0);break;case "manager":Lp(1);break;case "user":Lp(2);break;case "viewer":Lp(3)}return"viewer"==c.Xh?uv(a.f,d,b,e):wv(a.f,d,b,e)},
  Dv=function(a,b,c){b=new xf(b,"warning");Af(b);a.b.b.ze(b);Au(a.b,new Ng("STOP"),c)};var Ev=function(){var a=this;this.m=db("mr.cloud.settings.SettingsService");this.b=null;chrome.settingsPrivate.onPrefsChanged.addListener(function(b){og(13);if(a.b){b=k(b);for(var c=b.next();!c.done;c=b.next())if(c=c.value,"media_router.cloudservices.enabled"==c.key){a.b.call(null,c.value);break}}})},Fv=function(a,b){a.b=b},Gv=function(a){var b=a.m;chrome.storage.sync.set({"mr.cloud.cloudEnabled":!0},function(){chrome.runtime.lastError&&b.F("Error setting cloud setting: "+JSON.stringify(chrome.runtime.lastError))})},
  Iv=function(a){return Hv().catch(function(){return Hv().catch(function(b){a.m.F("Error retrieving cloud on setting.",b);return!1})})},Hv=function(){return Jv("mr.cloud.cloudEnabled").then(function(a){return!!a["mr.cloud.cloudEnabled"]})},Jv=function(a){return new Promise(function(b,c){chrome.storage.sync.get(a,function(a){chrome.runtime.lastError?c(chrome.runtime.lastError):b(a)})})},Lv=function(a){return Kv().catch(function(){return Kv().catch(function(b){a.m.F("Error retrieving cloud enabled setting.",
  b);return!1})})},Kv=function(){return Mv().then(function(a){return!!a.value})},Mv=function(){return new Promise(function(a,b){chrome.settingsPrivate.getPref("media_router.cloudservices.enabled",function(c){chrome.runtime.lastError?b(chrome.runtime.lastError):a(c)})})},Nv=function(a){var b=a.m;chrome.storage.sync.set({"mr.cloud.notifiedHangouts":!0},function(){chrome.runtime.lastError&&b.F("Error setting notified Hangout privacy.",chrome.runtime.lastError)})},Pv=function(a){return Ov().catch(function(){return Ov().catch(function(b){a.m.F("Error retrieving hangouts notified setting.",
  b);return!1})})},Ov=function(){return Jv("mr.cloud.notifiedHangouts").then(function(a){return!!a["mr.cloud.notifiedHangouts"]})};var Qv=new Map([["displayName","display_name"],["description","description"],["type","type"],["status","status"],["state","state"],["commandDefs","command_defs"]]),Rv=function(a,b){ft.call(this,a,b)};n(Rv,ft);g=Rv.prototype;g.act=function(a,b){a=new qr({method:"POST",Sb:this.b,vc:["devices:act"],eb:this.eb,body:{gcmId:b,id:a}});return this.f.execute(a).then(function(a){return a})};g.create=function(a){a=new qr({method:"POST",Sb:this.b,vc:["devices"],eb:this.eb,body:a});return this.f.execute(a).then(function(a){return a})};
  g.delete=function(a){a=new qr({method:"DELETE",Sb:this.b,vc:["devices",a],eb:this.eb});return this.f.execute(a)};g.get=function(a){a=new qr({method:"GET",Sb:this.b,vc:["devices",a],eb:this.eb});return this.f.execute(a).then(function(a){return a})};g.list=function(a){var b=a.type,c=a.status;a=a.permission;var d={};b&&(d.type=b);c&&(d.status=c);a&&(d.permission=a);b=new qr({method:"GET",Sb:this.b,vc:["devices"],Jl:d,eb:this.eb});return this.f.execute(b).then(function(a){return a.device||[]})};
  g.update=function(a,b){for(var c=[],d={},e=k(Qv.keys()),f=e.next();!f.done;f=e.next())f=f.value,b[f]&&(d[f]=b[f],c.push(Qv.get(f)));d.id=a;a=new qr({method:"PUT",Sb:this.b,vc:["devices",a],eb:this.eb,body:{device:d,updateMask:c}});return this.f.execute(a).then(function(a){return a})};var Sv=function(a,b,c,d,e,f){f=void 0===f?null:f;this.m=db("mr.cloud.slarti.SinkDiscoveryService");this.l=a;this.g=b;this.f=c;this.j=d;this.h=e;this.b=f||new Tq(this.o.bind(this),c,36E5);mt().addListener();fj(this);kg("mr.cloud.slarti.SinkDiscoveryService",this)};n(Sv,ag);Sv.prototype.Ld=function(){jt(this.h).catch(function(){});return this.b.Ld().filter(function(a){return a.isAvailable})};Sv.prototype.ja=function(a){return this.b.ja(a)};
  Sv.prototype.handleEvent=function(a,b){if(a!=chrome.gcm.onMessage)throw Error("Unhandled event: expected chrome.gcm.onMessage");Tv(this,b)};
  var Tv=function(a,b){var c=JSON.parse(b.data.data);a.m.info("Received Slarti GCM notification: "+c.type);kb(a.m,function(){return"Got notification: "+JSON.stringify(c)});switch(c.type){case "DEVICE_ADDED":Uv(a,c).then(function(b){"cast-receiver"==b.type&&(b=new Sq(b.id,b.displayName,"ONLINE"==b.status),a.b.b.set(b.id,b),Xq(a.f,[b.jb]))});break;case "DEVICE_CHANGED":Uv(a,c).then(function(b){if("cast-receiver"==b.type){var c=Aj(zj(),b.id);if(c=a.b.ja(c))c.displayName=b.displayName,c.isAvailable="ONLINE"==
  b.status,Yq(a.f,[c.jb])}});break;case "DEVICE_REMOVED":Vv(a,Wv(c));Promise.resolve();break;case "COMMAND_CHANGED":Xv(a,c).then(function(b){var c=a.j,d=b.id,h=c.f.get(d);if(h){var l=h.routeId,t=h.sinkId,u=h.resolve,A=h.reject,G=h.pp;h=!0;try{var V=JSON.parse(b.results||"{}"),Q=V.sessionDescription,ha=V.errorCode,Da=V.errorText;switch(b.status){case "SUCCESS":u(Au(c.b,new Ng("ANSWER",Q),l));G&&Ip(0);break;case "ERROR":case "TIMEOUT":var Zd="TIMEOUT"==b.status;u=ru;"KNOCK_DENIED"==ha&&(Ip(Zd?2:1),u=
  Zd?tu:su);Bu(c.b,l,7,Cf(Bf(Af(new xf(u,"warning")),l),t));throw Error("Slarti command "+d+" failed with status: "+(b.status+", errorCode: "+ha+", ")+("errorText: "+Da));default:h=!1}}catch(pg){A(pg)}finally{h&&c.f.delete(d)}}else c.m.F("Received update to unknown command with "+("name = "+b.name+" and id = "+d))});break;default:Promise.resolve()}};
  Sv.prototype.o=function(){return this.g.list({type:"cast-receiver"}).then(function(a){return a.map(function(a){return new Sq(a.id,a.displayName,"ONLINE"==a.status)})})};Sv.prototype.Aa=function(){return"SlartiSinkDiscoveryService"};Sv.prototype.gb=function(){return[{cache:ar(this.b)}]};Sv.prototype.fb=function(){var a=cj(this);a&&br(this.b,a.cache)};
  var Vv=function(a,b){b=Aj(zj(),b);var c=a.b.ja(b);c&&(a.b.b.delete(b),Zq(a.f,[c.jb]))},Wv=function(a){a=a.deviceInfo;return a.device?a.device.id:a.deviceId},Uv=function(a,b){b=b.deviceInfo;return b.device?Promise.resolve(b.device):a.g.get(b.deviceId)},Xv=function(a,b){b=b.commandInfo;return b.command?Promise.resolve(b.command):a.l.get(b.commandId)};var Yv=function(){this.b=null},Zv=function(a,b){if(!a.b||K(a.b,2)<K(b,2))a.b=Gi(b)},$v=function(a){return a.b?K(a.b,2)+";"+K(a.b,1):null};var aw=function(){this.A=this.l=this.H=this.D=this.B=this.w=this.g=this.C=this.h=this.f=this.j=this.Rb=this.Z=this.N=this.G=this.P=this.Za=this.M=this.W=this.o=this.s=this.b=null},bw=function(){var a=aw.Da();null==a.l&&(a.l=new Yv);return a.l},cw=function(a){null==a.b&&(a.b=new kr);return a.b},dw=function(a){null==a.s&&(a.s=new Ft(cw(a)));return a.s},ew=function(a){null==a.o&&(a.o=new dt);return a.o},fw=function(a){null==a.W&&(a.W=new Eu(cw(a),ew(a)));return a.W},hw=function(a,b){null==a.G&&(a.G=
  new iv(fw(a),gw(a),b));return a.G},iw=function(a){null==a.C&&(a.C=new rv(dw(a)));return a.C},gw=function(a){null==a.H&&(a.H=new ev(dw(a)));return a.H},jw=function(a){null==a.A&&(a.A=new Bq);return a.A};Oa(aw);var nw=function(a,b){this.h=a;this.o=b;this.l=new zb;this.f=this.l.b;this.b=kw(a.id);this.g=new zb;this.j=!1;lw(this);mw(this);this.b.sendMessage(new Ng("GET_TURN_CREDENTIALS"))};nw.prototype.start=function(){var a=this;return this.f.then(function(b){if(b.f)return Promise.reject(Error("Presentation already started"));b.start();return a.g.b})};nw.prototype.stop=function(){var a=this;this.j=!1;return this.f.then(function(b){b.stop();a.f=Promise.reject(Error("Peer connection has already been stopped"))})};
  var lw=function(a){a.b.onMessage=function(b){if(b.type)switch(b.type){case "TURN_CREDENTIALS":a.l.resolve(new Sg(a.h.id,b.data.credentials));break;case "ANSWER":a.f.then(function(a){$g(a,b.data)});break;case "STOP":a.g.reject("Stop signal received");a.stop();break;default:throw Error("Unknown message type: "+b.type);}else a.f.then(function(a){var c={type:"PRESENTATION_CONNECTION_MESSAGE",data:b};"string"==typeof c?a.j.send(c):a.j.send(JSON.stringify(c))})}},mw=function(a){a.f.then(function(b){Wg(b,
  function(b){a.b.sendMessage(new Ng("OFFER",new Pg(b,null,null,a.o,a.h.id)))});Xg(b,function(b){b=Og(b);"STOP"==b.type&&a.stop();a.b.sendMessage(b)});Tg(b,function(){a.j=!0;a.b.sendMessage(new Ng("SESSION_START_SUCCESS"));a.g.resolve(a.h)});Vg(b,function(){a.b.sendMessage(new Ng("SESSION_END"))});Ug(b,function(b){a.j||a.g.reject(b);a.b.sendMessage(new Ng("SESSION_FAILURE"))})})};var ow=function(a){this.b=a;this.f=new Map;this.B=new Map;this.D=new Map;this.s=[];this.j=this.H=this.A=this.G=this.l=null;this.o=this.h=this.g=!1;this.w=new Map;this.C=new Map;fj(this)};ow.prototype.getName=function(){return"cloud"};
  ow.prototype.Ya=function(){var a=this;this.m.info("Initializing Cloud MRP");var b=aw.Da();null==b.Rb&&(null==b.Z&&(b.Z=new Kq(dw(b),jw(b))),b.Rb=new vt(b.Z,this));this.s.push(b.Rb);if(null==b.P){var c=fw(b);null==b.M&&(b.M=new Rv(cw(b),ew(b)));var d=b.M,e=hw(b,this);null==b.N&&(null==b.Za&&(b.Za=new gt(cw(b),ew(b))),b.N=new ht(b.Za,window.localStorage,jw(b)));b.P=new Sv(c,d,this,e,b.N)}this.s.push(b.P);null==b.h&&(null==b.f&&(b.f=new Tp(dw(b),cw(b))),c=b.f,null==b.j&&(b.j=new xu(dw(b))),b.h=new er(c,
  b.j,this));this.l=b.h;this.s.push(this.l);this.G=iw(b);hw(b,this);this.A=cw(b);null==b.B&&(c=hw(b,this),null==b.g&&(b.g=new Bv(iw(b),cw(b),gw(b),this)),d=b.g,null==b.w&&(b.w=new zu(cw(b),this)),b.B=new mv(c,d,b.w,this));this.H=b.B;null==b.D&&(b.D=new Ev);this.j=b.D;Lv(this.j).then(function(b){a.g=b;a.m.info("Cloud enabled setting: "+a.g)});Iv(this.j).then(function(b){a.h=b;a.m.info("Cloud on setting: "+a.h)});Fv(this.j,function(b){a.g=b;a.m.info("Cloud enabled setting: "+a.g);a.g&&pw(a)});Pv(this.j).then(function(b){a.o=
  b;a.m.info("Privacy notified setting: "+a.o)})};ow.prototype.jd=function(){return Array.from(this.f.values())};
  ow.prototype.Wf=function(a){if(!qw(this,a))return yn;kb(this.m,"GetAvailableSinks for "+a);var b=[];if(this.h||rw())b=pw(this);this.C.clear();for(var c={},d=k(this.w.values()),e=d.next();!e.done;c={Bf:c.Bf,bh:c.bh},e=d.next())c.Bf=e.value,c.bh=!1,b.forEach(function(a){return function(b){b.id==a.Bf.id&&(a.bh=!0,b.jb.friendlyName=a.Bf.jb.friendlyName)}}(c)),c.bh||this.C.set(c.Bf.id,c.Bf);b=b.concat.apply(b,m(this.C.values()));kb(this.m,function(){return"Available sinks are..."+JSON.stringify(b)});c=
  b.map(function(a){return a.jb});this.l&&(c=c.concat(sw));return new xn(c,-1!=a.indexOf("0F5096E8")?ug:null)};var pw=function(a){var b=[];a.m.info("Checking cloud discovery services");zj().g=r();a.s.forEach(function(a){a=a.Ld();b=b.concat(a)});return b};g=ow.prototype;g.startObservingMediaSinks=function(){};g.stopObservingMediaSinks=function(){};g.startObservingMediaRoutes=function(){};g.stopObservingMediaRoutes=function(){};g.ja=function(a){return(a=tw(this,a))?a.jb:null};
  g.createRoute=function(a,b,c,d,e,f,h){var l=this;this.m.info("createRoute called");kb(this.m,"urn: "+a+" sinkId:"+b);if(e=this.B.get(b))return Ef(this.b.jl(this,e,a,c,h,function(b){b.mediaSource=a;b.ib.tabId=h;return Ff(b)}),function(a){l.b.ye(a);return a});e=tw(this,b);return uw(this,a,e,b,c,d,h)};
  var vw=function(a,b,c,d,e){b instanceof wn&&2==b.errorCode?Bu(a,c,6,null):(a.m.error("Error on start session",b instanceof Error?b:Error("Expected an Error value, got "+b)),a.f.has(c.id)&&Bu(a,c,e,Cf(new xf(ru,"warning"),c.sinkId)));if(b=a.l)b=a.l,b.f.delete(d.deviceId)?(b.b.b.delete(d.id),b=!0):b=!1;b&&Zq(a,[d.jb])},uw=function(a,b,c,d,e,f,h){if(f)return Gf(Error("not supported"));f=!1;switch(c.b){case "slarti":case "weave":Kp(1);break;case "mesi":f=!0;if(!a.o){a.o=!0;Nv(a.j);var l=Cf(zf(),d);a.b.ze(l)}Kp(0)}zj().f=
  new wj(c.model,null);var t=Mm(e,a.getName(),d,b,!0,"");f&&(t.customControllerPath="cloud_route_details/view.html?routeId="+t.id,t.controllerType=mojo.RouteControllerType&&mojo.RouteControllerType.kHangouts);a.f.set(t.id,t);a.B.set(d,t);a.w.set(t.id,c);a.D.set(t.id,c.b);a.b.wf(a,t);a.b.Af(a.Aa(),!0);if(tg(b)&&!f)return a.m.info("starting presentation on route: "+t.id),ww(t,b).catch(function(b){vw(a,b,t,c,7);throw b;});a.m.info("starting mirroring on route: "+t.id);t.ib={tabId:h,sessionId:"",Df:"",
  Qd:c.model};tg(b)&&(t.isOffscreenPresentation=!0);return a.b.Ji(a,t,e).catch(function(b){vw(a,b,t,c,5);throw b;})};ow.prototype.terminateRoute=function(a){return Bu(this,a,0,null)};
  var Bu=function(a,b,c,d){var e="string"==typeof b?a.f.get(b):b;if(!e)return Promise.reject(new wn(3,"Route in cloud provider not found for routeId "+b));a.m.info("terminating route: "+e.id);a.f.delete(e.id);a.B.delete(e.sinkId);b=a.w.get(e.id);a.w.delete(e.id);d&&a.b.ze(d);yb("MediaRouter.Cloud.Session.End",c,Fp);switch(c){case 1:break;default:switch(b.b){case "weave":xv(a.G,b.deviceId,Jq,{})}}a.b.eg(e);0==a.f.size&&a.b.Af(a.Aa(),!1);a.b.onPresentationConnectionStateChanged(e.id,"terminated");a.C.has(e.sinkId)&&
  (c=a.C.get(e.sinkId),Zq(a,[c.jb]),a.C.delete(e.sinkId));return Promise.resolve()};g=ow.prototype;g.sendRouteMessage=function(a,b){var c=this.D.get(a);if(c){var d=(a=this.f.get(a)||void 0)?tw(this,a.sinkId):void 0;return pv(this.H,c,b,a,d)}return Ia(b)?(Au(this,b,a),Promise.resolve()):Promise.reject(Error("Channel type missing"))};g.sendRouteBinaryMessage=function(a){return Promise.reject(Error("Route "+a+" does not support sending binary data."))};
  g.gf=function(a){var b=new Lg;5>b.minFrameRate&&(b.minFrameRate=5);var c=this.te(a);"hangouts"==c||"meetings"==c?(b.maxWidth=Math.min(window.screen&&window.screen.width||Infinity,2400),b.maxHeight=Math.min(window.screen&&window.screen.width||Infinity,1280)):b.senderSideLetterboxing=!0;Mg(b);Object.freeze(b);this.m.info("Settings for "+a+": "+Kg(b));if(!b.shouldCaptureAudio&&!b.shouldCaptureVideo)throw Error("Cannot start mirroring without video or audio capture.");return b};
  g.te=function(a){var b=null;a=tw(this,a);switch(a.b){case "slarti":case "weave":b="webrtc";break;case "mesi":b=a.Hc?"meetings":"hangouts"}return b};g.th=function(){};g.Pf=function(a,b){kb(this.m,"Checking canRoute: "+a+" for sinkId: "+b);return qw(this,a)&&!!this.ja(b)};g.af=function(a,b){return("https://hangouts.google.com/cloudmrp-mirroring"==a||tg(a))&&this.f.has(b)};g.joinRoute=function(a,b){return(a=this.f.get(b))?(this.m.info("joining route: "+a.id),Ff(a)):Gf(Error("not supported"))};
  g.connectRouteByRouteId=function(){return Gf(Error("not supported"))};g.detachRoute=function(){};
  var Xq=function(a,b){a.m.info(b.length+" sinks added");0<b.length&&!a.h&&(Gv(a.j),a.h=!0);b=tw(a,b[0].id);zj().b=new wj(b.model,null);a.b.Sc();a.b.onSinkAvailabilityUpdated(a,2);a.m.info("sinkAvailability changed to AVAILABLE")},Zq=function(a,b){a.m.info(b.length+" sinks removed");a.s.some(function(a){return 0<a.Ld().length})||(a.b.onSinkAvailabilityUpdated(a,0),a.m.info("sinkAvailability changed to UNAVAILABLE"));a.b.Sc()},Yq=function(a,b){a.m.info(b.length+" sinks updated");a.b.Sc()},Au=function(a,
  b,c,d){(void 0===d?0:d)?a.b.Kd(c,b):a.b.sh(c,b)},tw=function(a,b){var c=xw(a,b);c||(c=null,(b=a.B.get(b))&&(c=a.w.get(b.id)));return c},xw=function(a,b){var c=null;a.s.some(function(a){c=a.ja(b);return!!c});return c},rw=function(){var a=zj().g;return 3E5<=Date.now()-a},qw=function(a,b){var c=sg(b);b=tg(b);if(a.A.g&&!a.A.f&&c)return a.b.onSinkAvailabilityUpdated(a,2),!0;var d=!1;a.g&&a.A.f&&(d=!0);var e;if(e=!chrome.declarativeWebRequest)a=a.A,e=!(a.g||a.f&&a.b&&(-1!=pr.indexOf(a.b)||-1!=pr.indexOf(lr(a))))&&
  b;return e?!1:d&&(c||b)};ow.prototype.searchSinks=function(a,b){var c=this;if(!qw(this,a))return Promise.reject(Error("err"));a=hr(this.l,b);a.then(function(a){Xq(c,[a])});return a};var yw=function(a,b){b=a.f.get(b);if(!b)return Promise.reject(Error("Route not found"));a=a.te(b.sinkId);return"hangouts"!=a&&"meetings"!=a?Promise.reject(Error("Unsupported sink channel type")):Cp(bg.get("mr.ProviderManager")||null,a)};g=ow.prototype;
  g.createMediaRouteController=function(a,b,c){return yw(this,a).then(function(d){return d.createMediaRouteController(a,b,c)})};g.provideSinks=function(){};g.Aa=function(){return"CloudProvider"};g.gb=function(){return[void 0,{cloudEnabled:this.g,cloudOn:this.h,notifiedHangoutsPrivacy:this.o}]};g.fb=function(){var a=dj(this);a&&(a.cloudEnabled&&(this.g=a.cloudEnabled),a.cloudOn&&(this.h=a.cloudOn),a.notifiedHangoutsPrivacy&&(this.o=a.notifiedHangoutsPrivacy))};var ww=function(a,b){a=new nw(a,b);return Hf(a.start())};
  ow.prototype.m=db("mr.CloudProvider");var sw=new Zi("pseudo:cloud","","meeting","","default");var zw=function(){Fm.call(this,12,"ExternalMessageListener","mr.ProviderManager",chrome.runtime.onMessageExternal)};n(zw,Fm);zw.prototype.Cg=function(a,b){return b.id&&-1!=Aw.indexOf(b.id)?"start"==a.type||"stop"==a.type||"subscribe_log_data"==a.type:!1};zw.prototype.gi=function(){return!0};var Cw=function(){Bw||(Bw=new zw);return Bw},Bw=null,Aw=["idmofbkcelhplfjnmmdolenpigiiiecc","ggedfkijiiammpnbdadhllnehapomdge","njjegkblellcjnakomndbaloifhcoccg"];var Dw=function(){Fm.call(this,11,"InternalMessageListener","mr.ProviderManager",chrome.runtime.onMessage)};n(Dw,Fm);Dw.prototype.Cg=function(a,b){return"retrieve_log_data"==a.type&&b.id==chrome.runtime.id&&b.url=="chrome-extension://"+b.id+"/feedback.html"};Dw.prototype.gi=function(){return!0};var Fw=function(){Ew||(Ew=new Dw);return Ew},Ew=null;function Gw(){var a=Hw;var b=new zn(a);var c=new Io(a);b=[b,c];b.push(new ow(a));return b};var Iw=function(a,b){this.routeId=a;this.message=b},Jw=function(a){return"string"!=typeof a.message};var Kw=function(a){this.A=a;this.h=this.j=null},Lw=function(a){if(null==a.h)if(null==a.j||Date.now()-a.j>=a.A)a.l();else{var b=Math.max(a.j+a.A-Date.now(),5);a.h=setTimeout(a.l.bind(a),b)}};Kw.prototype.l=function(){null!=this.h&&(clearTimeout(this.h),this.h=null);this.C();this.j=Date.now()};Kw.prototype.C=function(){};var Mw=function(a,b){Kw.call(this,20);this.b=new Map;this.f=new Set;this.s=null;this.o=this.g=0;this.w=!1;this.D=a;this.B=b;this.m=db("mr.RouteMessageSender")};n(Mw,Kw);Mw.prototype.init=function(a){this.s=a;fj(this)};Mw.prototype.stopListeningForRouteMessages=function(a){this.f.delete(a)};
  Mw.prototype.send=function(a,b){var c=this.b.get(a);c||(c=[],this.b.set(a,c));b=new Iw(a,b);c.push(b);50<c.length&&1==c.length%50&&this.m.F(function(){return"Message queue length is excessively large "+("("+c.length+") for route "+a)});this.g+=Jw(b)?0:b.message.length;Jw(b)&&this.o++;Nw(this);this.f.has(a)&&Lw(this)};
  var Ow=function(a,b){if(0!=b.length){b=k(b);for(var c=b.next();!c.done;c=b.next())c=c.value,a.g-=Jw(c)?0:c.message.length,Jw(c)&&a.o--}},Nw=function(a){var b=0<a.o||a.g>a.B;b!=a.w&&(a.w=b,a.D.Af(a.Aa(),b))};Mw.prototype.C=function(){if(this.s){for(var a=k(this.f),b=a.next();!b.done;b=a.next()){b=b.value;var c=this.b.get(b);c&&0!=c.length&&(this.s(b,c),Ow(this,c),this.b.set(b,[]))}Nw(this)}else this.m.error("sendMessagesCallback not set. Messages not delivered.")};Mw.prototype.Aa=function(){return"mr.RouteMessageSender"};
  Mw.prototype.gb=function(){var a=[].concat(m(this.b.entries())).map(function(a){return[a[0],a[1].map(function(a){return a.message})]});return[new Pw(a,Array.from(this.f),this.g)]};Mw.prototype.fb=function(){var a=cj(this);if(a){this.b=new Map;for(var b={},c=k(a.f),d=c.next();!d.done;b={routeId:b.routeId},d=c.next())d=d.value,b.routeId=d[0],d=d[1].map(function(a){return function(b){return new Iw(a.routeId,b)}}(b)),this.b.set(b.routeId,d);this.f=new Set(a.b);this.g=a.g}};
  var Pw=function(a,b,c){this.f=a;this.b=b;this.g=c};var Qw=function(a,b){this.type="internal_message";this.routeId=a;this.message=b};var Rw=function(a,b,c){this.b=a;this.h=b;this.g=c;this.onMessage=function(){};c.listen("internal_message",this.f,this)};Rw.prototype.sendMessage=function(a,b){return this.h(this.b,a,b)};Rw.prototype.f=function(a){if(a.routeId==this.b)this.onMessage(a.message)};Rw.prototype.Oa=function(){this.onMessage=function(){};On(this.g,this.f,this)};
  var Sw=new Rw("",function(){return Promise.resolve()},new Nn),Tw=function(a){this.b=a},kw=function(a){var b=vf,c=b.b.oi(a);return c?new Rw(a,c.sendRouteMessage.bind(c),b.b.ri()):Sw};var Uw=function(a,b){this.l=null!=b?a.bind(b):a;this.j=this.o.bind(this);this.h=[];this.b=!1;this.f=null};Uw.prototype.g=function(a){for(var b=[],c=0;c<arguments.length;++c)b[c-0]=arguments[c];this.h=[].concat(m(b));null==this.f?Vw(this):this.b=!0};var Vw=function(a){a.f=setTimeout(a.j,500);a.l.apply(a,m(a.h))};Uw.prototype.o=function(){this.f=null;this.b&&(this.b=!1,Vw(this))};var Ww=function(){this.m=db("mr.ProviderManager");this.g=[];this.f=new Map;this.o=new Map;this.j=new Set;this.h=new Set;this.A=new Map;this.b=this.C=null;this.W=new Nn;this.M=new Uw(this.Xl,this);this.Za=new Uw(this.D,this);this.l=new Mw(this,524288);this.B=0;this.s=new Map;this.w=[];var a=new xp(this);this.P=a.onMessage.bind(a);a=new op(this);this.N=a.onMessage.bind(a);this.G="";this.H=!1;this.onBeforeInvokeHandler=this.onBeforeInvokeHandler;this.createRoute=this.createRoute;this.joinRoute=this.joinRoute;
  this.connectRouteByRouteId=this.connectRouteByRouteId;this.terminateRoute=this.terminateRoute;this.startObservingMediaSinks=this.startObservingMediaSinks;this.stopObservingMediaSinks=this.stopObservingMediaSinks;this.sendRouteMessage=this.sendRouteMessage;this.sendRouteBinaryMessage=this.sendRouteBinaryMessage;this.startListeningForRouteMessages=this.startListeningForRouteMessages;this.stopListeningForRouteMessages=this.stopListeningForRouteMessages;this.startObservingMediaRoutes=this.startObservingMediaRoutes;
  this.stopObservingMediaRoutes=this.stopObservingMediaRoutes;this.detachRoute=this.detachRoute;this.searchSinks=this.searchSinks;this.provideSinks=this.provideSinks;this.updateMediaSinks=this.updateMediaSinks;this.createMediaRouteController=this.createMediaRouteController};n(Ww,ag);
  Ww.prototype.handleEvent=function(a,b){for(var c=[],d=1;d<arguments.length;++d)c[d-1]=arguments[d];if(a==chrome.runtime.onMessage)this.P.apply(this,m(c));else if(a==chrome.runtime.onMessageExternal)this.N.apply(this,m(c));else throw Error("Unhandled event");};
  var Cp=function(a,b){b=a.A.get(b);return eg(b).then(function(b){b.Ya(a,a.H);return b})},Xw=function(a,b,c){b.forEach(function(b){if(Bp(a,b.getName()))a.m.F("Provider "+b.getName()+" already registered.");else try{b.Ya(c),a.g.push(b),a.s.set(b.getName(),0)}catch(e){a.m.F("Provider "+b.getName()+" failed to initialize.",e)}})};
  Ww.prototype.Ya=function(a,b,c){this.A.set("webrtc","mr.mirror.webrtc.WebRtcService");this.A.set("cast_streaming","mr.mirror.cast.Service");this.A.set("hangouts","mr.mirror.hangouts.HangoutsService");this.A.set("meetings","mr.mirror.hangouts.MeetingsService");var d=new Tw(this);vf||(vf=d);this.b=a;this.l.init(this.b.onRouteMessagesReceived.bind(this.b));Xw(this,b,c);c&&void 0!==c.use_views_dialog&&(this.G=c.use_views_dialog?"Views":"WebUI");c&&void 0!==c.use_mirroring_service&&(this.H=c.use_mirroring_service);
  fj(this);kg("mr.ProviderManager",this)};var Zw=function(a,b,c){return new Promise(function(d,e){var f=null;a.B++;Yw(a);f=window.setTimeout(function(){f=null;b.cancel(new wn(2,"timeout after "+c+" ms."))},c);b.b.then(function(b){a.B--;Yw(a);null!=f&&window.clearTimeout(f);d(b)},function(b){a.B--;Yw(a);null!=f&&window.clearTimeout(f);e(b instanceof wn?b:b instanceof Error?new wn(0,b.message,b.stack):new wn(0))})})};Ww.prototype.onBeforeInvokeHandler=function(){og(0)};
  var $w=function(a){return"string"==typeof a?a:a.unique?"":a.scheme+"://"+a.host+"\n       "+(a.port?":"+a.port:"")+"/"};g=Ww.prototype;
  g.createRoute=function(a,b,c,d,e,f,h){var l=this;h=void 0===h?!1:h;var t=ax(this,a,b);if(!t)return Promise.reject(new wn(7,"No provider supports createRoute with source: "+a+" and sink: "+b));var u=void 0;void 0!==d&&(u=$w(d));f=f&&0<f?f:6E4;a=t.createRoute(a,b,c,h,f,u,e);return Zw(this,a,f).then(function(a){return a},function(a){l.m.error("Error creating route.",a);throw a;})};
  g.connectRouteByRouteId=function(a,b,c,d,e,f){var h=this.f.get(b);if(!h)return Promise.reject(new wn(7,"No provider supports join "+b));a=h.connectRouteByRouteId(a,b,c,$w(d),e);return Zw(this,a,f&&0<f?f:3E4)};g.joinRoute=function(a,b,c,d,e,f){f=void 0===f?!1:f;var h=bx(this,a,b);if(!h)return Promise.reject(new wn(7,"No provider supports join "+b));e=e&&0<e?e:3E4;a=h.joinRoute(a,b,f,e,$w(c),d);return Zw(this,a,e)};
  g.terminateRoute=function(a){var b=this.f.get(a);return b?cx(this,a).then(function(){return b.terminateRoute(a)}):Promise.reject(new wn(3,"Route not found for routeId "+a))};g.startObservingMediaSinks=function(a){this.j.has(a)||(this.j.add(a),this.g.forEach(function(b){b.startObservingMediaSinks(a)}));dx(this,a)};g.stopObservingMediaSinks=function(a){this.j.delete(a)?ex(this,a):this.m.info("No existing query "+a)};
  var ex=function(a,b){a.g.forEach(function(a){a.stopObservingMediaSinks(b)})},dx=function(a,b){if("urn:x-org.chromium.media:source:tab:-1"==b)a.m.F("No sinks for sourceUrn: "+b);else{var c=new Map,d=[];a.g.forEach(function(e){var f=e.Wf(b);0<f.sinks.length&&(d=f.origins);f.sinks.forEach(function(b){c.has(b.id)?a.m.F("Detected duplicate sink "+b.id+" from provider: "+e.getName()):c.set(b.id,b)})});fx(a,b,Array.from(c.values()),d||[])}},fx=function(a,b,c,d){a.m.info("Sending "+c.length+" sinks to MR for "+
  b);a.b.onSinksReceived(b,c,d.map(Gl))};g=Ww.prototype;g.sendRouteMessage=function(a,b,c){var d=this.f.get(a);d?(a=d.sendRouteMessage(a,b,c),a=Zw(this,Hf(a),3E4)):a=Promise.reject(Error("Invalid route ID "+a));return a};g.sendRouteBinaryMessage=function(a,b){var c=this.f.get(a);c?(a=c.sendRouteBinaryMessage(a,b),a=Zw(this,Hf(a),3E4)):a=Promise.reject(Error("Invalid route ID "+a));return a};
  g.startListeningForRouteMessages=function(a){var b=this.l;b.f.has(a)||(b.f.add(a),(a=b.b.get(a))&&0<a.length&&Lw(b))};g.stopListeningForRouteMessages=function(a){this.l.stopListeningForRouteMessages(a)};g.detachRoute=function(a){var b=this.f.get(a);b?b.detachRoute(a):this.m.info("Route "+a+" does not exist.")};g.enableMdnsDiscovery=function(){};var ax=function(a,b,c){return a.g.find(function(a){return a.Pf(b,c)})||null},bx=function(a,b,c){return a.g.find(function(a){return a.af(b,c)})||null};
  Ww.prototype.D=function(){var a=this;this.j.forEach(function(b){dx(a,b)})};var Yw=function(a){a.b.setKeepAlive(0<a.B||0<a.w.length)};g=Ww.prototype;g.startObservingMediaRoutes=function(a){this.h.has(a)||(this.h.add(a),this.g.forEach(function(b){b.startObservingMediaRoutes(a)}));this.M.g()};g.stopObservingMediaRoutes=function(a){this.h.delete(a)?this.g.forEach(function(b){b.stopObservingMediaRoutes(a)}):this.m.info("No existing route query "+a)};
  g.Xl=function(){var a=this;if(0!=this.h.size){var b=[];this.g.forEach(function(a){b=b.concat(a.jd())});this.h.forEach(function(c){var d=[];a.g.forEach(function(a){a.jd().forEach(function(b){!b.df&&a.af(c,void 0,b)&&d.push(b.id)})});a.b.onRoutesUpdated(b,c,d)})}};g.Aa=function(){return"ProviderManager"};
  g.gb=function(){return[new gx(this.g.map(function(a){return a.getName()}),Array.from(this.j),Array.from(this.h),Array.from(this.f,function(a){var b=k(a);a=b.next().value;b=b.next().value;return[a,b.getName()]}),Array.from(this.s),this.C)]};g.fb=function(){var a=cj(this);if(a){this.j=new Set(a.j);this.h=new Set(a.g);for(var b=k(a.f),c=b.next();!c.done;c=b.next()){var d=k(c.value);c=d.next().value;d=d.next().value;d=Bp(this,d);this.f.set(c,d)}this.s=new Map(a.h);this.C=a.b||null}};g.oi=function(a){return this.f.get(a)};
  g.wf=function(a,b){this.f.set(b.id,a);this.ye(b)};g.eg=function(a){cx(this,a.id);this.f.delete(a.id);var b=this.l,c=a.id;b.f.delete(c);var d=b.b.get(c);d&&(b.b.delete(c),Ow(b,d),Nw(b));this.ye(a)};g.ye=function(){0<this.h.size&&this.M.g()};g.vi=function(a){var b=this.f.get(a.id);b&&(b.th(a.id),0<this.h.size&&this.Xl())};g.Kd=function(a,b){this.f.has(a)?("string"===typeof b||b instanceof Uint8Array||(b=JSON.stringify(b)),this.l.send(a,b)):this.m.F("Got route message for closed route "+a)};
  g.onPresentationConnectionStateChanged=function(a,b){"terminated"==b&&this.l.l();this.b.onPresentationConnectionStateChanged(a,b)};g.onPresentationConnectionClosed=function(a,b,c){this.l.l();this.b.onPresentationConnectionClosed(a,b,c)};g.Wi=function(a){this.o.delete(a);var b=this.f.get(a);b&&b.terminateRoute(a)};g.sh=function(a,b){Pn(this.W,new Qw(a,b))};g.Sc=function(){this.Za.g()};
  g.onSinkAvailabilityUpdated=function(a,b){var c=this;if(this.s.get(a.getName())!=b){var d=hx(this);this.s.set(a.getName(),b);a=hx(this);d!=a&&(0==a&&this.D(),this.b.onSinkAvailabilityUpdated(a),0==a&&(this.j.forEach(function(a){ex(c,a)}),this.j.clear()))}};var hx=function(a){return Array.from(a.s.values()).reduce(function(a,c){return Math.max(a,c)},0)};Ww.prototype.ri=function(){return this.W};Ww.prototype.ze=function(a){this.b.onIssue(a)};
  var cx=function(a,b){return a.o.has(b)?Cp(a,a.o.get(b)).then(function(c){a.o.delete(b);return c.l()}):Promise.resolve(!1)};Ww.prototype.Ji=function(a,b,c,d){var e=this,f=a.te(b.sinkId);this.m.info("Starting mirroring using service: "+f);this.o.set(b.id,f);return If(Cp(this,f),function(h){e.C=f;return h.Ti(b,b.mediaSource,a.gf(b.sinkId),c,d).catch(function(a){if(a instanceof Kf&&3==a.reason)throw new wn(8);throw a;})})};
  Ww.prototype.jl=function(a,b,c,d,e,f){var h=this,l=this.o.get(b.id);return l?If(Cp(this,l),function(t){h.C=l;return t.Ui(b,c,a.gf(b.sinkId),d,e,f)}):Gf(Error("Route "+b.id+" is not mirroring"))};Ww.prototype.Af=function(a,b){var c=this.w.indexOf(a),d=0<=c;b&&!d?this.w.push(a):!b&&d&&this.w.splice(c,1);Yw(this)};var Bp=function(a,b){return a.g.find(function(a){return a.getName()==b})||null};g=Ww.prototype;
  g.searchSinks=function(a,b,c){var d=a.startsWith("pseudo:")?a.substring(7):null;return(d=d?Bp(this,d):null)?d.searchSinks(b,c).then(function(a){return a.id}):Promise.reject(Error("No provider supports "+a))};g.provideSinks=function(a,b){var c=Bp(this,a);c?c.provideSinks(b):this.m.error("provideSinks: Provider not found for providerName "+a)};g.updateMediaSinks=function(a){this.j.has(a)||dx(this,a)};
  g.createMediaRouteController=function(a,b,c){var d=this,e=this.f.get(a);return e?e.createMediaRouteController(a,b,c).catch(function(a){d.m.error("createMediaRouteController failed: "+a.message);b.close();c.ptr.reset();throw a;}):(a="createMediaRouteController: Provider not found for "+a,this.m.error(a),b.close(),c.ptr.reset(),Promise.reject(Error(a)))};g.onMediaRemoterCreated=function(a,b,c){this.b.onMediaRemoterCreated(a,b,c)};
  g.getMediaSinkServiceStatus=function(){return"function"!=typeof this.b.getMediaSinkServiceStatus?Promise.resolve({status:""}):this.b.getMediaSinkServiceStatus()};g.getMirroringServiceHostForTab=function(a,b){this.b.getMirroringServiceHostForTab(a,b)};g.getMirroringServiceHostForDesktop=function(a,b,c){this.b.getMirroringServiceHostForDesktop(a,b,c)};g.getMirroringServiceHostForOffscreenTab=function(a,b,c){this.b.getMirroringServiceHostForOffscreenTab(a,b,c)};
  var gx=function(a,b,c,d,e,f){this.j=b;this.g=c;this.f=d;this.h=e;this.b=f};
  