'use strict';var gi;var hi=chrome.i18n.getMessage("545449835455981095");w("mr.IssueSeverity",{nv:"fatal",nA:"warning",wx:"notification"});w("mr.IssueAction",{cv:"dismiss",Cw:"learn_more"});
var ii=function(a,c){this.sinkId=this.routeId=null;this.severity=c;this.isBlocking="fatal"==this.severity?!0:!1;this.title=a;this.message=null;this.defaultAction="dismiss";this.helpPageId=this.secondaryActions=null},ki=function(){var a=new ii(ji,"notification");a.helpPageId=6320939;a.defaultAction="learn_more";a.secondaryActions=["dismiss"];return a},li=function(a){a.isBlocking=!0;return a},mi=function(a,c){a.routeId=c;return a},ni=function(a,c){a.sinkId=c;return a};var oi=function(a,c){var b=this;this.f=void 0===c?null:c;this.b=new Promise(function(d,e){var f=function(g){b.f=null;e(g)};b.g=f;a(function(g){b.f=null;d(g)},f)})};oi.prototype.cancel=function(a){this.g(a);if(this.f){var c=this.f;this.f=null;setTimeout(function(){return c(a)},0)}};var pi=function(a,c,b){b=void 0===b?null:b;return new oi(function(d,e){a.b.then(function(f){if(c)try{d(c(f))}catch(g){e(g)}else d(f)},function(f){if(b)try{d(b(f))}catch(g){e(g)}else e(f)})},function(d){a.cancel(d)})};
oi.prototype.then=function(a,c){return pi(this,a,void 0===c?null:c)};oi.prototype.catch=function(a){return pi(this,null,a)};var qi=function(a){return new oi(function(c){c(a)})},ri=function(a){return new oi(function(c,b){b(a)})},si=function(a){return new oi(function(c,b){a.then(c,b)})},ti=function(a,c){var b=!1,d=null;return new oi(function(e,f){a.then(function(g){b||(d=c(g),d.b.then(e,f))},f)},function(e){d?d.cancel(e):b=!0})};var ui={ou:0,mu:1,qu:2,nu:3,Ot:4,pu:5,Uv:6,Nz:7,Xu:8,kp:9},vi=function(a,c){a=Error.call(this,a);this.message=a.message;"stack"in a&&(this.stack=a.stack);this.reason=0<=c&&9>=c?c:9};q(vi,Error);var wi=function(){var a=l(navigator.userAgent.match(/Windows NT (\d+.\d+)/)||[]);a.next();a=a.next().value;return 6.2<=parseFloat(a)},xi=function(){var a=navigator.userAgent;return a.includes("CrOS")?"ChromeOS":a.includes("Windows")?"Windows":a.includes("Macintosh")?"Mac":a.includes("Linux")?"Linux":"Other"};var yi=!("undefined"==typeof chrome||!chrome.networkingPrivate||!chrome.networkingPrivate.setWifiTDLSEnabledState||"ChromeOS"!=xi()),zi=["ChromeOS","Windows"].includes(xi());var Ai=function(a,c,b,d){this.f=a;this.b=c;this.g=b||null;this.presentationId=d||null},Ei=function(a,c){if("tab"==a.f)a=Bi(a);else if("offscreen_tab"==a.f)c=Bi(a),c.presentationId=a.presentationId,a=c;else{var b={audio:!1,video:!1};a.b.shouldCaptureVideo?(b.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:c}},Ci(a,b.video.mandatory),zi&&a.b.shouldCaptureAudio&&(b.audio={mandatory:{chromeMediaSource:"system",chromeMediaSourceId:c}})):a.b.shouldCaptureAudio&&(b.audio={mandatory:{chromeMediaSource:"system"}});
a=b}return a},Bi=function(a){var c={audio:a.b.shouldCaptureAudio,video:a.b.shouldCaptureVideo};a.b.shouldCaptureVideo&&(c.videoConstraints={mandatory:{enableAutoThrottling:!0}},Ci(a,c.videoConstraints.mandatory));return c},Ci=function(a,c){var b=a.b.minWidth,d=a.b.minHeight;if(a.b.senderSideLetterboxing){b=a.b;if(0==b.minHeight||0==b.maxHeight?0:Math.floor(100*b.minWidth/b.minHeight)==Math.floor(100*b.maxWidth/b.maxHeight))b={width:b.minWidth,height:b.minHeight};else{d=b.maxWidth;for(var e=b.maxHeight;0!=
e;){var f=d%e;d=e;e=f}e=b.maxWidth/d;d=b.maxHeight/d;if(e<b.minWidth||d<b.minHeight)if(f=Math.max(b.minWidth/e,b.minHeight/d),e*=f,d*=f,e>b.maxWidth||d>b.maxHeight)e=b.maxWidth,d=b.maxHeight;e=Math.round(e);d=Math.round(d);b={width:e,height:d}}d=b;b=d.width;d=d.height}Object.assign(c,{minWidth:b,minHeight:d,maxWidth:a.b.maxWidth,maxHeight:a.b.maxHeight,minFrameRate:a.b.minFrameRate,maxFrameRate:a.b.maxFrameRate})};var Fi=function(a){this.b=a;this.f=this.Vf=null;this.l=hb("mr.mirror.MirrorMediaStream")};Fi.prototype.start=function(){return"tab"==this.b.f?Gi(this):"offscreen_tab"==this.b.f?Hi(this):Ii(this)};var Gi=function(a){var c=Ei(a.b);a.l.info("Starting tab capture with constraints "+JSON.stringify(c));return new Promise(function(b,d){chrome.tabCapture.capture(c,function(e){e?(Ji(a,e),b(a)):d(Ki())});window.setTimeout(function(){d(new vi("chrome.tabCapture.capture failed to call its callback",2))},5E3)})};
Fi.prototype.g=function(a){a&&this.l.info(function(){return"Track "+JSON.stringify(a.target)+" ended"});this.stop()};
var Ki=function(){return chrome.runtime.lastError&&chrome.runtime.lastError.message?new vi(chrome.runtime.lastError.message,7):new vi("empty_stream",0)},Li=function(a){var c=void 0===c?6E4:c;return new Promise(function(b,d){var e=["screen","audio"];"Linux"==xi()&&e.push("window");var f=window.setTimeout(function(){g&&chrome.desktopCapture.cancelChooseDesktopMedia(g);d(new vi("timeout",1))},c);var g=chrome.desktopCapture.chooseDesktopMedia(e,a||null,function(k){window.clearTimeout(f);k?b(k):d(new vi("User cancelled capture dialog",
3))})})},Mi=function(a,c){return new Promise(function(b,d){a.l.info(function(){return"Starting desktop capture with constraints "+JSON.stringify(c)});navigator.mediaDevices.getUserMedia(c).then(function(e){e||d(new vi("empty_stream",8));Ji(a,e);b(e)},function(e){var f=8;"NotAllowedError"==e.name&&(f=3);d(new vi(e.name+" "+e.constraintName+": "+e.message,f))})})},Ii=function(a){return zi&&a.b.b.shouldCaptureAudio&&!a.b.b.shouldCaptureVideo?Mi(a,Ei(a.b)).then(function(){return a}):Li().then(function(c){c=
Ei(a.b,c);return Mi(a,c).then(function(){return a})})},Hi=function(a){var c=Ei(a.b);a.l.info(function(){return"Starting offscreen tab capture with constraints "+JSON.stringify(c)});return new Promise(function(b,d){chrome.tabCapture.captureOffscreenTab(a.b.g.toString(),c,function(e){e?(Ji(a,e),b(a)):d(Ki())})})},Ji=function(a,c){a.f=c;c.getAudioTracks().length||c.getVideoTracks();c.getTracks().forEach(function(b){b.onended=a.g.bind(a)})};
Fi.prototype.stop=function(){this.f&&(this.f.getTracks().forEach(function(a){a.onended=null;a.stop()}),this.f=null,this.Vf&&this.Vf())};var Ni=function(){},Ri=function(a){var c=Oi.get(a)||null;if(c)return Promise.resolve(c);c=Pi.get(a);c||(c=new Db,Pi.set(a,c),Qi(a,c));return c.b},Qi=function(a,c){var b=Si.get(a)||null;if(!b)c.reject(Error("No corresponding bundle for "+a));else if(!Ti.has(b)){var d=Ui.get(b);d||(Vi.info("Loading bundle "+b+" for module "+a),d=Wi(b),Ui.set(b,d));d.catch(function(e){c.reject(e)})}},Wi=function(a){var c=new Db;c.b.then(function(){Vi.info("Bundle "+a+" loaded")},function(d){Vi.error("Failed to load bundle "+
a);throw d;});var b=document.createElement("script");b.src=chrome.extension.getURL(a);b.setAttribute("type","text/javascript");b.async=!0;b.onload=function(){return c.resolve(void 0)};b.onerror=function(){return c.reject(Error("Failed to load bundle "+a))};document.head.appendChild(b);return c.b},Xi=function(a,c){if(Oi.has(a))throw Error("Duplicate module "+a);Oi.set(a,c);(a=Pi.get(a))&&a.resolve(c)};
Ni.prototype.handleEvent=function(a,c){for(var b=1;b<arguments.length;++b);throw Error("Not implemented");};
var Si=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"]]),Ti=new Set(["background_script.js"]),Vi=hb("mr.Module"),Oi=new Map,Pi=new Map,Ui=new Map;var Yi,Zi={Lw:0,ru:1,su:2,Yu:3,Zu:4,zv:5,Wv:6,Jw:7,mx:8,nx:9,vy:10,gz:11,hz:12,xz:13,Mz:14},$i=function(a){void 0==Yi&&(Cb("MediaRouter.Provider.WakeEvent",a,Zi),Yi=a)};var cj=function(a){return aj(a)||bj(a)},dj=function(a){try{var c=new URL(a);return"http:"!=c.protocol&&"https:"!=c.protocol?!1:-1==c.hash.indexOf("__castAppId__")}catch(b){return!1}},ej=["https://docs.google.com"],aj=function(a){return a.startsWith("urn:x-org.chromium.media:source:tab:")||-1!=a.indexOf("0F5096E8")},bj=function(a){return"urn:x-org.chromium.media:source:desktop"==a},fj=function(a){var c=a.search("urn:x-org.chromium.media:source:tab:");return-1==c?null:parseInt(a.substr(c+36),10)||null};var gj=function(a,c){this.ua=a;this.g=c||null;this.f=this.b=null;this.R=hb("mr.mirror.Service."+a);this.ha=this.pa.bind(this);this.D=!1};q(gj,Ni);h=gj.prototype;h.initialize=function(a,c){this.D||(this.g=a,this.D=!0,this.Ag(c))};h.Ag=function(){};h.getName=function(){return this.ua};
h.Gj=function(a,c,b,d,e){var f=this;this.R.info("Start mirroring on route "+a.id);if(!this.D)return ri(Error("Not initialized"));var g=new Promise(function(k,m){f.m().then(function(){var p=hj(c,b,d);return(new Fi(p)).start()}).then(function(p){if(f.f)throw p.stop(),new vi("Cannot start multiple streams");f.f=p;p=f.C.bind(f);f.f.Vf=p;return e?e(a).b:a}).then(function(p){if(f.b)throw new vi("Cannot start multiple sessions");if(!f.f)throw new vi("Media stream ended before session could start.");f.b=
f.xh(b,p);p.mb.qc=f.b.qc;p=f.g.Si.bind(f.g);f.b.H=p;ij(f.b);return f.b.start(f.f.f)}).then(function(){aj(c)&&!chrome.tabs.onUpdated.hasListener(f.ha)&&chrome.tabs.onUpdated.addListener(f.ha);return f.Oc(a,c,b)}).then(function(){k(a)}).catch(function(p){jj(f,p);return f.C().then(function(){m(p)})})});return si(g)};h.Hj=function(a,c,b,d,e,f){this.R.info("Update mirroring on route "+a.id);return this.D?si(kj(this,a,c,b,d,f)):ri(Error("Not initialized"))};
var kj=function(a,c,b,d,e,f){if(!a.b)return Promise.reject(new vi("No session to update streams on",7));if(!a.b.wn())return Promise.reject(new vi("Session does not support updating stream",7));var g=!1;return new Promise(function(k,m){var p=hj(b,d,e);(new Fi(p)).start().then(function(v){a.f&&(a.f.Vf=null,a.f.stop(),a.bh());a.f=v;v=a.C.bind(a);a.f.Vf=v;g=!0;return f?f(c).b:c}).then(function(){if(!a.b)throw new vi("Session ended while updating stream");if(!a.f)throw new vi("Media stream ended before session could be updated.");
return a.b.Cn(a.f.f)}).then(a.Oc.bind(a,c,b,d)).then(function(){return k(c)}).catch(function(v){jj(a,v);if(g)return a.C().then(function(){m(v)});m(v)})})};
gj.prototype.Oc=function(a,c,b){var d=this;return new Promise(function(e,f){if(d.b){aj(c)?(lj(d.b,a.mb.tabId),d.dh()):dj(c)?(lj(d.b,a.mb.tabId),d.Xh()):d.Yg();f=d.f;var g=a.sinkId;b.shouldCaptureAudio&&f.f&&!f.f.getAudioTracks().length&&d.g.Ze(ni(new ii(hi,"notification"),g));ij(d.b);e()}else f(new vi("Session gone before executing post-startup steps",7))})};
var jj=function(a,c){c.reason=null!=c.reason?c.reason:9;a.R.error("Failed to start mirroring: "+c.message+(",  reason = "+c.reason+": "+c.stack));a.ah(c.reason)};gj.prototype.m=function(){var a=this;return this.D?this.C().then(function(c){c&&a.Zg();return c}):Promise.reject("Not initialized")};
gj.prototype.C=function(){var a=this;chrome.tabs.onUpdated.removeListener(this.ha);var c=this.f;this.f=null;c&&(c.Vf=null);var b=this.b;this.b=null;var d;b?d=this.vi(b).catch(function(e){return a.R.error("Error in before-cleanup steps",e)}).then(function(){return b.stop()}).catch(function(e){return a.R.error("Error stopping session",e)}).then(function(){a.g.Th(b.f.id)}).catch(function(e){return a.R.error("Error in ended callbacks",e)}).then(function(){return!0}):d=Promise.resolve(!1);c&&(d=d.then(function(e){c.stop();
a.bh();return e}));return d};gj.prototype.vi=function(){return Promise.resolve()};gj.prototype.pa=function(a,c,b){$i(14);this.b&&mj(this.b,a,c,b)};var hj=function(a,c,b){if(aj(a))return new Ai("tab",c);if(bj(a))return new Ai("desktop",c);if(dj(a)){if(!b)throw new vi("Missing offscreen tab presentation id");return new Ai("offscreen_tab",c,a,b)}throw new vi("Source URN does not suggest a known capture type.");};h=gj.prototype;h.xh=function(){};h.dh=function(){};h.Yg=function(){};h.Xh=function(){};
h.Zg=function(){};h.ah=function(){};h.bh=function(){};h.Fj=function(){return eb()};h.createMediaRouteController=function(){return eb()};var nj=function(a,c,b){this.f=a;this.h=c;this.b=void 0===b?null:b;this.g=null},oj=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""}},pj=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 qj=function(a){return(new Promise(function(c){chrome.tabs.get(a,c)})).then(function(c){if(!c)throw Error("No such tab "+a);return c})};var rj=function(a,c){this.f=a;this.H=void 0===c?null:c;c=null;var b=a.mediaSource;if(dj(b)){var d="presentation";c=(new URL(b)).origin}else aj(b)?d="mirror_tab":bj(b)&&(d="mirror_desktop");this.qc=new nj(d,a.offTheRecord,c);this.j=this.tabId=null;this.F=!1},lj=function(a,c){a.tabId!=c?(a.tabId=c,qj(c).then(function(b){a.j=b;ij(a)})):Promise.resolve()},mj=function(a,c,b,d){c==a.tabId&&("complete"==b.status||b.favIconUrl&&"complete"==d.status)&&(a.j=d,ij(a))},ij=function(a){if(a.j){a.qc.g=a.j.title;
a.qc.h=a.j.incognito;var c=new URL(a.j.url);"file:"==c.protocol?(a.qc.f="mirror_file",a.qc.b=null):(a.qc.f=a.F?"media_remoting":"mirror_tab",a.qc.b="https:"==c.protocol?c.origin.substr(8):c.origin)}a.f.description=oj(a.qc);a.H&&a.H(a.f,a.qc);a.cn()};h=rj.prototype;h.start=function(){};h.wn=function(){return!1};h.Cn=function(){};h.stop=function(){return Promise.resolve()};h.cn=function(){};var vj=function(){var a=this;this.f=1920;this.b=1080;this.maxWidth=this.f;this.maxHeight=this.b;this.minHeight=this.minWidth=180;this.senderSideLetterboxing=!1;this.minFrameRate=0;this.maxFrameRate=30;this.minVideoBitrate=300;this.maxVideoBitrate=5E3;this.audioBitrate=0;this.animatedLatencyMillis=this.minLatencyMillis=this.maxLatencyMillis=400;this.dscpEnabled=["Mac","Linux","ChromeOS"].includes(xi())||wi();this.enableLogging=!0;this.useTdls=!1;this.shouldCaptureAudio=this.shouldCaptureVideo=!0;var c=
window.localStorage?window.localStorage.getItem(sj):null;if(c)try{var b=JSON.parse(String(c));if(b instanceof Object)tj(this,b),hb("mr.mirror.Settings").G(function(){return"Initial mr.mirror.Settings overridden to: "+uj(a)});else throw Error("localStorage["+sj+"] "+("does not parse as an Object: "+c));}catch(d){throw hb("mr.mirror.Settings").error(sj+' must be of the form \'{"maxWidth":640, "maxHeight":360}\'.',d),Error("Overrides not parseable.  See ERROR log for details.");}};
vj.prototype.clone=function(){var a=new vj;tj(a,this);return a};
var uj=function(a){return JSON.stringify(a,function(c,b){if(0==c.length||!c.endsWith("_"))return b})},tj=function(a,c){for(var b=l(Object.keys(c)),d=b.next();!d.done;d=b.next())d=d.value,d.endsWith("_")||typeof c[d]!==typeof a[d]||(a[d]=c[d])},wj=function(a){var c=Math.round(screen.width*window.devicePixelRatio),b=Math.round(screen.height*window.devicePixelRatio);b>c&&(b=l([b,c]),c=b.next().value,b=b.next().value);a.maxHeight*c<a.maxWidth*b?(c=Math.min(a.maxWidth,c),c-=c%160,b=90*c/160):(b=Math.min(a.maxHeight,
b),b-=b%90,c=160*b/90);if(c<Math.max(160,a.minWidth)||b<Math.max(90,a.minHeight))c=Math.max(160,a.minWidth),b=Math.max(90,a.minHeight);a.maxWidth=c;a.maxHeight=b},sj="mr.mirror.Settings.Overrides";var xj=function(a,c){this.type=a;this.data=c},yj=function(a){a=JSON.parse(a);if(!a.type)throw Error("Invalid message");return new xj(a.type,a.data)},zj=function(a,c,b,d,e){this.description=a;this.settings=c||null;this.mediaConstraints=b||null;this.presentationUrl=d||null;this.presentationId=e||null};var Cj=function(a,c){this.l=hb("cv2.PeerConnection");this.H=Aj;this.ja=Bj(this,c);this.h=this.ja.createDataChannel(a,{reliable:!1});this.F=new Db;this.m=!1;this.g=0;this.f=null;this.o=this.j=0;this.b=!1;this.C=function(){};this.w=function(){};this.D=function(){};this.s=function(){}},Dj=function(a,c){a.w=c},Ej=function(a,c){a.D=c},Fj=function(a,c){a.s=c},Gj=function(a,c){a.C=c},Hj=function(a,c){a.h.onmessage=function(b){c(b.data)}},Ij=function(a){var c={};c.iceServers=[{url:"stun:stun.l.google.com:19302"}].concat(a);
return c},Bj=function(a,c){var b=Ij(c);c=new webkitRTCPeerConnection(b);c.onicecandidate=a.J.bind(a);c.onicegatheringstatechange=a.T.bind(a);c.oniceconnectionstatechange=a.O.bind(a);a.l.info(function(){return"Created webkitRTCPeerConnnection with config: "+JSON.stringify(b)});return c};Cj.prototype.start=function(){this.b||(this.b=!0,Jj(this))};Cj.prototype.stop=function(){this.l.info("Stopping peer connection...");this.b&&(this.b=!1,"closed"!=this.ja.signalingState&&this.ja.close());this.ja=null};
var Jj=function(a){a.l.info("Sending offer to peer.");a.j=Date.now();a.ja.createOffer(a.L.bind(a),function(c){a.l.G("Error creating offer.",c)},a.H);a.F.b.then(function(c){a.C(c)})};Cj.prototype.L=function(a){var c=this;this.l.info(function(){return"Setting local description: "+JSON.stringify(a)});this.ja.setLocalDescription(a,function(){c.l.info("Local description set successfully")},function(b){c.l.G("Error setting local description.",b)})};
var Kj=function(a,c){ob(a.l,function(){return"<===: "+JSON.stringify(c)});var b=new RTCSessionDescription(c);a.l.info(function(){return"Setting remote description: "+JSON.stringify(b)});a.ja.setRemoteDescription(b,function(){a.l.info("Remote description set successfully.")},function(d){a.l.G("Error setting remote description.",d)})};
Cj.prototype.J=function(a){var c=this;a.candidate?(this.g++,this.o=Date.now(),1==this.g?this.f=setTimeout(function(){c.l.info("ICE candidate gathering timed out.");c.f=null;Lj(c)},5E3):this.m&&this.l.G("Received ICE candidate after resolving session description.")):(this.l.info("End of ICE candidates."),ub("MediaRouter.WebRtc.IceCandidateGathering.Duration.Reported",Date.now()-this.j),Lj(this),0<this.g&&ub("MediaRouter.WebRtc.IceCandidateGathering.Duration.Real",this.o-this.j))};
Cj.prototype.T=function(){"completed"==this.ja.iceGatheringState&&Lj(this)};var Lj=function(a){clearTimeout(a.f);a.f=null;if(!a.m){a.l.info("Resolving sesion description after gathering "+a.g+" ICE candidates.");var c=a.ja.localDescription;a.F.resolve({type:c.type,sdp:c.sdp});a.m=!0}};
Cj.prototype.O=function(a){var c=this;if(this.ja){var b=this.ja.iceConnectionState;this.l.info("New ICE connection state: "+b+".");"connected"==b?this.w("iceconnected"):"completed"==b?this.w("icecompleted"):"failed"==b?(this.l.G(function(){return"Ice connection failed: "+JSON.stringify(a)}),this.D("icefailed")):"closed"==b?this.s("iceclosed"):"disconnected"==b&&(this.l.G("Ice connection state is bad."),this.b&&(this.l.info("Restarting ICE."),this.ja.createOffer(this.L.bind(this),function(d){c.l.G("Error creating new offer.",
d)},Mj)))}};var Aj={mandatory:{OfferToReceiveAudio:!0,OfferToReceiveVideo:!0}},Mj={mandatory:{IceRestart:!0,OfferToReceiveAudio:!0,OfferToReceiveVideo:!0}};var Nj=function(){var a=window.crypto.getRandomValues(new Uint8Array(16));return Nb(a,function(c){c=c.toString(16);return 1<c.length?c:"0"+c}).join("")},Oj=function(a){for(var c=[],b=0,d=0;d<a.length;d++){var e=a.charCodeAt(d);128>e?c[b++]=e:(2048>e?c[b++]=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),c[b++]=e>>18|240,c[b++]=e>>12&63|128):c[b++]=e>>12|224,c[b++]=e>>6&63|128),c[b++]=e&63|128)}return c},Pj=function(a){for(var c=
[],b=0,d=0;b<a.length;){var e=a[b++];if(128>e)c[d++]=String.fromCharCode(e);else if(191<e&&224>e){var f=a[b++];c[d++]=String.fromCharCode((e&31)<<6|f&63)}else if(239<e&&365>e){f=a[b++];var g=a[b++],k=a[b++];e=((e&7)<<18|(f&63)<<12|(g&63)<<6|k&63)-65536;c[d++]=String.fromCharCode(55296+(e>>10));c[d++]=String.fromCharCode(56320+(e&1023))}else f=a[b++],g=a[b++],c[d++]=String.fromCharCode((e&15)<<12|(f&63)<<6|g&63)}return c.join("")};var Qj=null,Rj=null,Tj=function(a){Sj();for(var c=Qj,b=[],d=0;d<a.length;d+=3){var e=a[d],f=d+1<a.length,g=f?a[d+1]:0,k=d+2<a.length,m=k?a[d+2]:0,p=e>>2;e=(e&3)<<4|g>>4;g=(g&15)<<2|m>>6;m&=63;k||(m=64,f||(g=64));b.push(c[p],c[e],c[g],c[m])}return b.join("")},Vj=function(a){var c=a.length,b=0;"="===a[c-2]?b=2:"="===a[c-1]&&(b=1);var d=new Uint8Array(Math.ceil(3*c/4)-b),e=0;Uj(a,function(f){d[e++]=f});return d.subarray(0,e)},Uj=function(a,c){function b(m){for(;d<a.length;){var p=a.charAt(d++),v=Rj[p];
if(null!=v)return v;if(!kd(p))throw Error("Unknown base64 encoding at char: "+p);}return m}Sj();for(var d=0;;){var e=b(-1),f=b(0),g=b(64),k=b(64);if(64===k&&-1===e)break;c(e<<2|f>>4);64!=g&&(c(f<<4&240|g>>2),64!=k&&c(g<<6&192|k))}},Sj=function(){if(!Qj){Qj={};Rj={};for(var a=0;65>a;a++)Qj[a]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(a),Rj[Qj[a]]=a,62<=a&&(Rj["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.".charAt(a)]=a)}};var Wj=0,Xj=0,Yj=function(a){var c=0>a;a=Math.abs(a);var b=a>>>0;a=Math.floor((a-b)/4294967296);a>>>=0;c&&(a=~a>>>0,b=(~b>>>0)+1,4294967295<b&&(b=0,a++,4294967295<a&&(a=0)));Wj=b;Xj=a},Zj=function(a){var c=0>a?1:0;a=c?-a:a;if(0===a)0<1/a?Wj=Xj=0:(Xj=0,Wj=2147483648);else if(isNaN(a))Xj=0,Wj=2147483647;else if(3.4028234663852886E38<a)Xj=0,Wj=(c<<31|2139095040)>>>0;else if(1.1754943508222875E-38>a)a=Math.round(a/Math.pow(2,-149)),Xj=0,Wj=(c<<31|a)>>>0;else{var b=Math.floor(Math.log(a)/Math.LN2);a*=
Math.pow(2,-b);a=Math.round(8388608*a)&8388607;Xj=0;Wj=(c<<31|b+127<<23|a)>>>0}},ak="0123456789abcdef".split(""),bk=function(a,c){function b(k){for(var m=1E7,p=0;7>p;p++){m/=10;var v=k/m%10>>>0;if(0!=v||f)f=!0,g+=e[v]}}if(2097151>=c)return""+(4294967296*c+a);var d=(a>>>24|c<<8)>>>0&16777215;c=c>>16&65535;a=(a&16777215)+6777216*d+6710656*c;d+=8147497*c;c*=2;1E7<=a&&(d+=Math.floor(a/1E7),a%=1E7);1E7<=d&&(c+=Math.floor(d/1E7),d%=1E7);var e=ak,f=!1,g="";(c||f)&&b(c);(d||f)&&b(d);(a||f)&&b(a);return g},
ck=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 Vj(a);Hb("Type not convertible to Uint8Array.");return new Uint8Array(0)};var ek=function(a,c,b){this.f=null;this.m=this.o=this.b=this.g=this.j=0;this.s=!1;a&&dk(this,a,c,b)},fk=[],gk=function(a,c,b){if(fk.length){var d=fk.pop();a&&dk(d,a,c,b);return d}return new ek(a,c,b)};ek.prototype.clone=function(){return gk(this.f,this.j,this.g-this.j)};ek.prototype.clear=function(){this.f=null;this.b=this.g=this.j=0;this.s=!1};var dk=function(a,c,b,d){a.f=ck(c);a.j=Ia(b)?b:0;a.g=Ia(d)?a.j+d:a.f.length;a.b=a.j};ek.prototype.reset=function(){this.b=this.j};
var hk=function(a){for(var c,b=0,d,e=0;4>e;e++)if(c=a.f[a.b++],b|=(c&127)<<7*e,128>c){a.o=b>>>0;a.m=0;return}c=a.f[a.b++];b|=(c&127)<<28;d=0|(c&127)>>4;if(128>c)a.o=b>>>0,a.m=d>>>0;else{for(e=0;5>e;e++)if(c=a.f[a.b++],d|=(c&127)<<7*e+3,128>c){a.o=b>>>0;a.m=d>>>0;return}Hb("Failed to read varint, encoding is invalid.");a.s=!0}};
ek.prototype.h=function(){var a=this.f;var c=a[this.b+0];var b=c&127;if(128>c)return this.b+=1,b;c=a[this.b+1];b|=(c&127)<<7;if(128>c)return this.b+=2,b;c=a[this.b+2];b|=(c&127)<<14;if(128>c)return this.b+=3,b;c=a[this.b+3];b|=(c&127)<<21;if(128>c)return this.b+=4,b;c=a[this.b+4];b|=(c&15)<<28;if(128>c)return this.b+=5,b>>>0;this.b+=5;128<=a[this.b++]&&128<=a[this.b++]&&128<=a[this.b++]&&128<=a[this.b++]&&this.b++;return b};ek.prototype.w=ek.prototype.h;
var ik=function(a){hk(a);return 4294967296*a.m+a.o},jk=function(a){hk(a);var c=a.o,b=a.m;if(a=b&2147483648)c=~c+1>>>0,b=~b>>>0,0==c&&(b=b+1>>>0);c=4294967296*b+c;return a?-c:c},kk=function(a){var c=a.f[a.b+0];var b=a.f[a.b+1];var d=a.f[a.b+2],e=a.f[a.b+3];a.b+=4;b=(c<<0|b<<8|d<<16|e<<24)>>>0;a=2*(b>>31)+1;c=b>>>23&255;b&=8388607;return 255==c?b?NaN:Infinity*a:0==c?a*Math.pow(2,-149)*b:a*Math.pow(2,c-150)*(b+Math.pow(2,23))};ek.prototype.D=function(){return this.w()};var lk=function(a){this.b=gk(a,void 0,void 0);this.w=this.b.b;this.h=this.f=-1;this.j=!1},mk=function(a){return 4==a.h};lk.prototype.reset=function(){this.b.reset();this.h=this.f=-1};
var nk=function(a){var c=a.b;if(c.b==c.g)return!1;(c=a.j)||(c=a.b,c=c.s||0>c.b||c.b>c.g);if(c)return Hb("Decoder hit an error"),!1;a.w=a.b.b;var b=a.b.h();c=b>>>3;b&=7;if(0!=b&&5!=b&&1!=b&&2!=b&&3!=b&&4!=b)return Hb("Invalid wire type: %s (at position %s)",b,a.w),a.j=!0,!1;a.f=c;a.h=b;return!0},ok=function(a){switch(a.h){case 0:if(0!=a.h)Hb("Invalid wire type for skipVarintField"),ok(a);else{for(a=a.b;a.f[a.b]&128;)a.b++;a.b++}break;case 1:1!=a.h?(Hb("Invalid wire type for skipFixed64Field"),ok(a)):
(a=a.b,a.b+=8);break;case 2:if(2!=a.h)Hb("Invalid wire type for skipDelimitedField"),ok(a);else{var c=a.b.h();a=a.b;a.b+=c}break;case 5:5!=a.h?(Hb("Invalid wire type for skipFixed32Field"),ok(a)):(a=a.b,a.b+=4);break;case 3:c=a.f;do{if(!nk(a)){Hb("Unmatched start-group tag: stream EOF");a.j=!0;break}if(4==a.h){a.f!=c&&(Hb("Unmatched end-group tag"),a.j=!0);break}ok(a)}while(1);break;default:Hb("Invalid wire encoding for field.")}};
lk.prototype.g=function(a,c){var b=this.b.g,d=this.b.h();d=this.b.b+d;this.b.g=d;c(a,this);this.b.b=d;this.b.g=b};
var pk=function(a){return!!a.b.h()},qk=function(a){return jk(a.b)},rk=function(a){var c=a.b.h();a=a.b;var b=a.f,d=a.b,e=d+c,f=[];for(c="";d<e;){var g=b[d++];if(128>g)f.push(g);else if(192>g)continue;else if(224>g){var k=b[d++];f.push((g&31)<<6|k&63)}else if(240>g){k=b[d++];var m=b[d++];f.push((g&15)<<12|(k&63)<<6|m&63)}else if(248>g){k=b[d++];m=b[d++];var p=b[d++];g=(g&7)<<18|(k&63)<<12|(m&63)<<6|p&63;g-=65536;f.push((g>>10&1023)+55296,(g&1023)+56320)}8192<=f.length&&(c+=String.fromCharCode.apply(null,
f),f.length=0)}if(8192>=f.length)f=String.fromCharCode.apply(null,f);else{b="";for(e=0;e<f.length;e+=8192)b+=String.fromCharCode.apply(null,gc(f,e,e+8192));f=b}a.b=d;return c+f},sk=function(a,c){var b=a.b.h();b=a.b.b+b;for(var d=[];a.b.b<b;)d.push(c.call(a.b));return d};var tk=function(a,c){this.b=a;this.f=c},uk=function(a){return new tk((a.b>>>1|(a.f&1)<<31)>>>0,a.f>>>1>>>0)},vk=function(a){return new tk(a.b<<1>>>0,(a.f<<1|a.b>>>31)>>>0)};tk.prototype.add=function(a){return new tk((this.b+a.b&4294967295)>>>0>>>0,((this.f+a.f&4294967295)>>>0)+(4294967296<=this.b+a.b?1:0)>>>0)};tk.prototype.sub=function(a){return new tk((this.b-a.b&4294967295)>>>0>>>0,((this.f-a.f&4294967295)>>>0)-(0>this.b-a.b?1:0)>>>0)};
var wk=function(a){var c=a&65535,b=a>>>16;a=10*c+65536*(0*c&65535)+65536*(10*b&65535);for(c=0*b+(0*c>>>16)+(10*b>>>16);4294967296<=a;)a-=4294967296,c+=1;return new tk(a>>>0,c>>>0)};
tk.prototype.toString=function(){for(var a="",c=this;0!=c.b||0!=c.f;){var b=new tk(0,0);c=new tk(c.b,c.f);for(var d=new tk(10,0),e=new tk(1,0);!(d.f&2147483648);)d=vk(d),e=vk(e);for(;0!=e.b||0!=e.f;)0>=(d.f<c.f||d.f==c.f&&d.b<c.b?-1:d.f==c.f&&d.b==c.b?0:1)&&(b=b.add(e),c=c.sub(d)),d=uk(d),e=uk(e);b=[b,c];c=b[0];a=b[1].b+a}""==a&&(a="0");return a};
var xk=function(a){for(var c=new tk(0,0),b=new tk(0,0),d=0;d<a.length;d++){if("0">a[d]||"9"<a[d])return null;b.b=parseInt(a[d],10);var e=wk(c.b);c=wk(c.f);c.f=c.b;c.b=0;c=e.add(c).add(b)}return c};tk.prototype.clone=function(){return new tk(this.b,this.f)};var yk=function(a,c){this.b=a;this.f=c};yk.prototype.add=function(a){return new yk((this.b+a.b&4294967295)>>>0>>>0,((this.f+a.f&4294967295)>>>0)+(4294967296<=this.b+a.b?1:0)>>>0)};
yk.prototype.sub=function(a){return new yk((this.b-a.b&4294967295)>>>0>>>0,((this.f-a.f&4294967295)>>>0)-(0>this.b-a.b?1:0)>>>0)};yk.prototype.clone=function(){return new yk(this.b,this.f)};yk.prototype.toString=function(){var a=0!=(this.f&2147483648),c=new tk(this.b,this.f);a&&(c=(new tk(0,0)).sub(c));return(a?"-":"")+c.toString()};var zk=function(){this.b=[]};zk.prototype.length=function(){return this.b.length};zk.prototype.end=function(){var a=this.b;this.b=[];return a};
var Ak=function(a,c,b){for(;0<b||127<c;)a.b.push(c&127|128),c=(c>>>7|b<<25)>>>0,b>>>=7;a.b.push(c)},Bk=function(a,c){for(;127<c;)a.b.push(c&127|128),c>>>=7;a.b.push(c)},Ck=function(a,c){if(0<=c)Bk(a,c);else{for(var b=0;9>b;b++)a.b.push(c&127|128),c>>=7;a.b.push(1)}},Dk=function(a,c){a.b.push(c>>>0&255);a.b.push(c>>>8&255);a.b.push(c>>>16&255);a.b.push(c>>>24&255)};var D=function(){this.w=[];this.j=0;this.g=new zk},Fk=function(a,c){Ek(a,c,2);c=a.g.end();a.w.push(c);a.j+=c.length;c.push(a.j);return c},Gk=function(a,c){var b=c.pop();for(b=a.j+a.g.length()-b;127<b;)c.push(b&127|128),b>>>=7,a.j++;c.push(b);a.j++};D.prototype.reset=function(){this.w=[];this.g.end();this.j=0};
var F=function(a){for(var c=new Uint8Array(a.j+a.g.length()),b=a.w,d=b.length,e=0,f=0;f<d;f++){var g=b[f];c.set(g,e);e+=g.length}b=a.g.end();c.set(b,e);a.w=[c];return c},Ek=function(a,c,b){Bk(a.g,8*c+b)};D.prototype.f=function(a,c){null!=c&&null!=c&&(Ek(this,a,0),Ck(this.g,c))};
var H=function(a,c,b){null!=b&&null!=b&&(Ek(a,c,0),a=a.g,Yj(b),Ak(a,Wj,Xj))},Hk=function(a,c,b){if(null!=b){var d=b;(b=0<d.length&&"-"==d[0])&&(d=d.substring(1));d=xk(d);null===d?b=null:(b&&(d=(new tk(0,0)).sub(d)),b=new yk(d.b,d.f));Ek(a,c,0);Ak(a.g,b.b,b.f)}};D.prototype.h=function(a,c){null!=c&&null!=c&&(Ek(this,a,0),Bk(this.g,c))};
var Ik=function(a,c,b){null!=b&&null!=b&&(Ek(a,c,0),a=a.g,Yj(b),Ak(a,Wj,Xj))},Jk=function(a,c,b){null!=b&&(b=xk(b),Ek(a,c,0),Ak(a.g,b.b,b.f))},Kk=function(a,c,b){null!=b&&(Ek(a,c,5),Dk(a.g,b))},Lk=function(a,c,b){null!=b&&(Ek(a,c,5),a=a.g,Zj(b),Dk(a,Wj))},Mk=function(a,c,b){if(null!=b){Ek(a,c,1);a=a.g;var d=b;d=(b=0>d?1:0)?-d:d;0===d?(Xj=0<1/d?0:2147483648,Wj=0):isNaN(d)?(Xj=2147483647,Wj=4294967295):1.7976931348623157E308<d?(Xj=(b<<31|2146435072)>>>0,Wj=0):2.2250738585072014E-308>d?(d/=Math.pow(2,
-1074),Xj=(b<<31|d/4294967296)>>>0,Wj=d>>>0):(c=Math.floor(Math.log(d)/Math.LN2),1024==c&&(c=1023),d*=Math.pow(2,-c),Xj=(b<<31|c+1023<<20|1048576*d&1048575)>>>0,Wj=4503599627370496*d>>>0);Dk(a,Wj);Dk(a,Xj)}},I=function(a,c,b){null!=b&&(Ek(a,c,0),a.g.b.push(b?1:0))},J=function(a,c,b){null!=b&&(Ek(a,c,0),Ck(a.g,b))},K=function(a,c,b){if(null!=b){c=Fk(a,c);for(var d=a.g,e=0;e<b.length;e++){var f=b.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<b.length){var g=b.charCodeAt(e+1);56320<=g&&57343>=g&&(f=1024*(f-55296)+g-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)}Gk(a,c)}},Nk=function(a,c,b){null!=b&&(b=ck(b),Ek(a,c,2),Bk(a.g,b.length),c=a.g.end(),a.w.push(c),a.w.push(b),a.j+=c.length+b.length)};D.prototype.b=function(a,c,b){null!=c&&(a=Fk(this,a),b(c,this),Gk(this,a))};
var Ok=function(a,c,b){if(null!=b)for(var d=0;d<b.length;d++){var e=a,f=b[d];null!=f&&(Ek(e,c,0),Ck(e.g,f))}},Pk=function(a,c,b){if(null!=b)for(var d=0;d<b.length;d++){var e=a,f=b[d];null!=f&&(Ek(e,c,0),e=e.g,Yj(f),Ak(e,Wj,Xj))}},Qk=function(a,c,b){if(null!=b)for(var d=0;d<b.length;d++){var e=a,f=b[d];null!=f&&(Ek(e,c,0),Bk(e.g,f))}},Rk=function(a,c,b){if(null!=b)for(var d=0;d<b.length;d++)Kk(a,c,b[d])},Sk=function(a,c,b){if(null!=b)for(var d=0;d<b.length;d++)J(a,c,b[d])},Tk=function(a,c,b){if(null!=
b)for(var d=0;d<b.length;d++)K(a,c,b[d])},Uk=function(a,c,b){if(null!=b)for(var d=0;d<b.length;d++)Nk(a,c,b[d])},L=function(a,c,b,d){if(null!=b)for(var e=0;e<b.length;e++){var f=Fk(a,c);d(b[e],a);Gk(a,f)}},Vk=function(a,c,b,d){if(null!=b)for(var e=0;e<b.length;e++)Ek(a,c,3),d(b[e],a),Ek(a,c,4)},Wk=function(a,c,b){if(null!=b&&b.length){c=Fk(a,c);for(var d=0;d<b.length;d++)Ck(a.g,b[d]);Gk(a,c)}},Xk=function(a,c,b){if(null!=b&&b.length){c=Fk(a,c);for(var d=0;d<b.length;d++)Ck(a.g,b[d]);Gk(a,c)}};var M=function(){},Yk="function"==typeof Uint8Array,N=function(a,c,b,d,e,f){a.b=null;c||(c=b?[b]:[]);a.mg=b?String(b):void 0;a.j=0===b?-1:0;a.f=c;a:{b=a.f.length;c=-1;if(b&&(c=b-1,b=a.f[c],!(null===b||"object"!=typeof b||Ua(b)||Yk&&b instanceof Uint8Array))){a.m=c-a.j;a.g=b;break a}-1<d?(a.m=Math.max(d,c+1-a.j),a.g=null):a.m=Number.MAX_VALUE}a.o={};if(e)for(d=0;d<e.length;d++)c=e[d],c<a.m?(c+=a.j,a.f[c]=a.f[c]||Zk):($k(a),a.g[c]=a.g[c]||Zk);if(f&&f.length)for(d=0;d<f.length;d++)al(a,f[d])},Zk=Object.freeze?
Object.freeze([]):[],$k=function(a){var c=a.m+a.j;a.f[c]||(a.g=a.f[c]={})},bl=function(a,c,b,d){for(var e in b){var f=b[e],g=f.kq;if(!f.xi)throw Error("Message extension present that was generated without binary serialization support");var k=d.call(a,g);if(null!=k)if(g.Vd)if(f.nl)f.xi.call(c,g.wl,k,f.nl);else throw Error("Message extension present holding submessage without binary support enabled, and message is being serialized to binary format");else f.xi.call(c,g.wl,k)}},O=function(a,c){if(c<a.m){c+=
a.j;var b=a.f[c];return b===Zk?a.f[c]=[]:b}if(a.g)return b=a.g[c],b===Zk?a.g[c]=[]:b},cl=function(a,c){a=O(a,c);return null==a?a:+a},dl=function(a,c){a=O(a,c);return null==a?a:!!a},el=function(a,c){var b=O(a,c);a.o||(a.o={});if(!a.o[c]){for(var d=0;d<b.length;d++)b[d]=+b[d];a.o[c]=!0}return b},fl=function(a){if(null==a||a instanceof Uint8Array)return a;if(Ja(a))return Vj(a);Hb("Cannot coerce to Uint8Array: "+Sa(a));return null},hl=function(a){gl(a);return!a.length||a[0]instanceof Uint8Array?a:Nb(a,
fl)},gl=function(a){if(a&&1<a.length){var c=Sa(a[0]);y(a,function(b){Sa(b)!=c&&Hb("Inconsistent type in JSPB repeated field array. Got "+Sa(b)+" expected "+c)})}},R=function(a,c,b){a=O(a,c);return null==a?b:a},il=function(a,c,b){a=dl(a,c);return null==a?b:a},jl=function(a,c){a=cl(a,c);return null==a?0:a},S=function(a,c,b){c<a.m?a.f[c+a.j]=b:($k(a),a.g[c]=b)},ll=function(a,c,b){kl(a,c,b,"")},ml=function(a,c,b){kl(a,c,b,0)},kl=function(a,c,b,d){b!==d?S(a,c,b):a.f[c+a.j]=null},nl=function(a,c,b,d){(b=
al(a,b))&&b!==c&&void 0!==d&&(a.b&&b in a.b&&(a.b[b]=void 0),S(a,b,void 0));S(a,c,d)},al=function(a,c){for(var b,d,e=0;e<c.length;e++){var f=c[e],g=O(a,f);null!=g&&(b=f,d=g,S(a,f,void 0))}return b?(S(a,b,d),b):0},T=function(a,c,b,d){a.b||(a.b={});if(!a.b[b]){var e=O(a,b);if(d||e)a.b[b]=new c(e)}return a.b[b]},U=function(a,c,b){ol(a,c,b);c=a.b[b];c==Zk&&(c=a.b[b]=[]);return c},ol=function(a,c,b){a.b||(a.b={});if(!a.b[b]){for(var d=O(a,b),e=[],f=0;f<d.length;f++)e[f]=new c(d[f]);a.b[b]=e}},V=function(a,
c,b){a.b||(a.b={});var d=b?b.Kc():b;a.b[c]=b;S(a,c,d)},ql=function(a,c,b){var d=pl[0];a.b||(a.b={});var e=b?b.Kc():b;a.b[c]=b;nl(a,c,d,e)},rl=function(a,c,b){a.b||(a.b={});b=b||[];for(var d=[],e=0;e<b.length;e++)d[e]=b[e].Kc();a.b[c]=b;S(a,c,d)},sl=function(a,c,b,d,e){ol(a,d,c);var f=a.b[c];f||(f=a.b[c]=[]);b=b?b:new d;a=O(a,c);void 0!=e?(f.splice(e,0,b),a.splice(e,0,b.Kc())):(f.push(b),a.push(b.Kc()));return b},tl=function(a){if(a.b)for(var c in a.b){var b=a.b[c];if(Ua(b))for(var d=0;d<b.length;d++)b[d]&&
b[d].Kc();else b&&b.Kc()}};M.prototype.Kc=function(){tl(this);return this.f};M.prototype.Ba=Yk?function(){var a=Uint8Array.prototype.toJSON;Uint8Array.prototype.toJSON=function(){return Tj(this)};try{return JSON.stringify(this.f&&this.Kc(),ul)}finally{Uint8Array.prototype.toJSON=a}}:function(){return JSON.stringify(this.f&&this.Kc(),ul)};
var ul=function(a,c){return r(c)&&(isNaN(c)||Infinity===c||-Infinity===c)?String(c):c},wl=function(a){var c=vl[a[0]];if(!c)throw Error("Unknown JsPb message type: "+a[0]);return new c(a)};M.prototype.toString=function(){tl(this);return this.f.toString()};M.prototype.w=function(a){if(this.g)return this.b||(this.b={}),a.Vd?(!this.b[175237375]&&this.g[175237375]&&(this.b[175237375]=new a.Vd(this.g[175237375])),this.b[175237375]):this.g[175237375]};
var yl=function(a,c){a=a||{};c=c||{};var b={},d;for(d in a)b[d]=0;for(d in c)b[d]=0;for(d in b)if(!xl(a[d],c[d]))return!1;return!0},xl=function(a,c){if(a==c)return!0;if(!Ya(a)||!Ya(c))return r(a)&&isNaN(a)||r(c)&&isNaN(c)?String(a)==String(c):!1;if(a.constructor!=c.constructor)return!1;if(Yk&&a.constructor===Uint8Array){if(a.length!=c.length)return!1;for(var b=0;b<a.length;b++)if(a[b]!=c[b])return!1;return!0}if(a.constructor===Array){var d=void 0,e=void 0,f=Math.max(a.length,c.length);for(b=0;b<f;b++){var g=
a[b],k=c[b];g&&g.constructor==Object&&(d=g,g=void 0);k&&k.constructor==Object&&(e=k,k=void 0);if(!xl(g,k))return!1}return d||e?(d=d||{},e=e||{},yl(d,e)):!0}if(a.constructor===Object)return yl(a,c);throw Error("Invalid type in JSPB array");};M.prototype.clone=function(){return zl(this)};
var zl=function(a){return new a.constructor(Al(a.Kc()))},Al=function(a){if(Ua(a)){for(var c=Array(a.length),b=0;b<a.length;b++){var d=a[b];null!=d&&(c[b]="object"==typeof d?Al(d):d)}return c}if(Yk&&a instanceof Uint8Array)return new Uint8Array(a);c={};for(b in a)d=a[b],null!=d&&(c[b]="object"==typeof d?Al(d):d);return c},Bl=function(a,c){vl[a]=c;c.messageId=a},vl={};var Cl=function(a){N(this,a,0,-1,null,null)};x(Cl,M);var Dl=function(a){N(this,a,0,-1,null,null)};x(Dl,M);var Fl=function(a,c){for(;nk(c)&&!mk(c);)switch(c.f){case 1:var b=jk(c.b);S(a,1,b);break;case 2:b=rk(c);S(a,2,b);break;case 3:b=new Dl;c.g(b,El);V(a,3,b);break;default:ok(c)}return a};Cl.prototype.u=function(){var a=new D;Gl(this,a);return F(a)};
var Gl=function(a,c){var b=O(a,1);null!=b&&H(c,1,b);b=O(a,2);null!=b&&K(c,2,b);b=T(a,Dl,3);null!=b&&c.b(3,b,Hl)},El=function(a,c){for(;nk(c)&&!mk(c);)switch(c.f){case 1:var b=rk(c);S(a,1,b);break;case 2:b=jk(c.b);S(a,2,b);break;default:ok(c)}return a};Dl.prototype.u=function(){var a=new D;Hl(this,a);return F(a)};var Hl=function(a,c){var b=O(a,1);null!=b&&K(c,1,b);b=O(a,2);null!=b&&H(c,2,b)};Cl.prototype.Hb=function(){return O(this,1)};var Il=function(a,c){this.type="cast_app";this.originId=window["castApp.eventPage.Message.OriginID"]||void 0;this.subtype=a;this.devices=c;this.logRecord=this.deviceJustSetUp=void 0};w("castApp.eventPage.Message",Il);var Jl=function(a,c,b){this.ipAddress=a;this.appId=c;this.sessionId=b};Il.DeviceData=Jl;Il.DeviceJustSetUp=function(a,c,b,d){this.ipAddress=a;this.name=c;this.udn=b;this.modelName=d};Il.DeviceCapabilities=function(){};
Il.LogRecord=function(a,c,b,d){this.levelValue=a;this.msg=c;this.loggerName=b;this.time=d};var Kl=function(a,c){this.type=a;this.entryPoint=c};w("castApp.frontEnd.ExtensionMessage",Kl);var Ll=function(a){return"urn:x-cast:com.google.cast."+a},Ml=Ll("tp.connection"),Nl=Ll("receiver"),Ol=Ll("remoting"),Pl=Ll("media"),Ql=Ll("webrtc"),Rl=Ll("broadcast"),Sl=Nc({Sz:Ml,Tz:Ll("tp.heartbeat"),Cy:Nl,Hy:Ol,Kw:Pl,Nw:Ll("media.universalRemote.optIn"),pA:Ql,au:Rl});var Tl=function(a){return"available"==a||"available_rescan"==a};var Ul=function(a,c,b,d,e){this.id=a;this.friendlyName=c;this.iconType=b||"generic";this.description=void 0===d?null:d;this.domain=void 0===e?null:e};var Vl=window.localStorage,Wl=0,Yl=function(a){return(a=window.localStorage.getItem(Xl(a,!1)))?JSON.parse(a):null},Zl=function(a){return(a=window.localStorage.getItem(Xl(a,!0)))?JSON.parse(a):null},am=function(a){if($l.has(a.Ea()))throw Error("Duplicate instance name "+a.Ea());$l.set(a.Ea(),a);a.ib()},gm=function(a){for(var c=0,b=l(Object.keys(Vl)),d=b.next();!d.done;d=b.next()){d=d.value;var e=d.length+window.localStorage.getItem(d).length;d.startsWith("mr.")?Wl+=e:c+=e}bm=a;(window.localStorage.getItem("version")&&
window.localStorage.getItem("version")!==chrome.runtime.getManifest().version||cm(a))&&dm();em.info("initialize: "+Wl+" chars used, "+c+" other chars");chrome.runtime.onSuspend.addListener(fm)},bm=null,em=hb("mr.PersistentDataManager"),$l=new Map,Xl=function(a,c){return"mr."+(c?"persistent.":"temp.")+a.Ea()},cm=function(a){return!!window.localStorage.getItem("mrInstanceId")&&window.localStorage.getItem("mrInstanceId")!==a},fm=function(){em.info("onSuspend");hm("version",chrome.runtime.getManifest().version);
bm&&hm("mrInstanceId",bm);for(var a=$l.get("LogManager"),c=l($l),b=c.next();!b.done;b=c.next())b=l(b.value),b.next(),b=b.next().value,b!=a&&im(b);a&&im(a)},im=function(a){try{var c=a.jb();c&&void 0!=c[0]&&hm(Xl(a,!1),JSON.stringify(c[0]));c&&void 0!=c[1]&&hm(Xl(a,!0),JSON.stringify(c[1]))}catch(b){em.error("Error while saving data for "+a.Ea()+": "+b.message)}},hm=function(a,c){var b=window.localStorage.getItem(a);b=null!=b?c.length-b.length:a.length+c.length;52E5<Wl+b&&(em.G("Unable to write "+b+
" chars"),dm());if(52E5<Wl+b)throw em.error("Unable to write "+b+" chars after clearing temporary"),Error("Setting the value of '"+a+"' would exceed the quota, according to accounting.");try{window.localStorage.setItem(a,c)}catch(d){throw Error("Setting the value of '"+a+"' would exceed the quota, according to the browser.");}Wl+=b},jm=function(a){a=0==a.size%2?new Blob([a,new Uint8Array([0,0])]):new Blob([a,new Uint8Array([1])]);return new Promise(function(c,b){var d=new FileReader;d.onloadend=function(){if(d.error)b(d.error);
else try{for(var e=d.result,f=[],g=0,k=e.byteLength;g<k;g+=8192)f.push(String.fromCharCode.apply(null,new Uint16Array(e,g,Math.min(k-g,8192)/2)));hm("mr.temp.mirror.cast.Service.eventsBlob",f.join(""));c()}catch(m){b(m)}};d.readAsArrayBuffer(a)})},dm=function(){for(var a=l(Object.keys(Vl)),c=a.next();!c.done;c=a.next())c=c.value,c.startsWith("mr.temp.")&&(Wl-=c.length+window.localStorage.getItem(c).length,delete window.localStorage[c]);em.info("removeTemporary_: "+Wl+" chars used")};var km=(new Map).set("+","-").set("/","_").set("=","."),lm=(new Map).set("-","+").set("_","/").set(".","="),mm=function(a){return atob(a.replace(/[-_.]/g,function(c){return lm.get(c)}))},nm=function(a){return btoa(String.fromCharCode.apply(String,n(a))).replace(/[+/=]/g,function(c){return km.get(c)})};var om=function(){this.b=[];this.j=[];this.w=[];this.g=[];this.g[0]=128;for(var a=1;64>a;++a)this.g[a]=0;this.h=this.f=0;this.reset()};om.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 pm=function(a,c,b){b=void 0===b?0:b;var d=a.w;if("string"===typeof c)for(var e=0;16>e;e++)d[e]=c.charCodeAt(b)<<24|c.charCodeAt(b+1)<<16|c.charCodeAt(b+2)<<8|c.charCodeAt(b+3),b+=4;else for(e=0;16>e;e++)d[e]=c[b]<<24|c[b+1]<<16|c[b+2]<<8|c[b+3],b+=4;for(c=16;80>c;c++)b=d[c-3]^d[c-8]^d[c-14]^d[c-16],d[c]=(b<<1|b>>>31)&4294967295;c=a.b[0];b=a.b[1];e=a.b[2];for(var f=a.b[3],g=a.b[4],k,m,p=0;80>p;p++)40>p?20>p?(k=f^b&(e^f),m=1518500249):(k=b^e^f,m=1859775393):60>p?(k=b&e|f&(b|e),m=2400959708):(k=
b^e^f,m=3395469782),k=(c<<5|c>>>27)+k+g+m+d[p]&4294967295,g=f,f=e,e=(b<<30|b>>>2)&4294967295,b=c,c=k;a.b[0]=a.b[0]+c&4294967295;a.b[1]=a.b[1]+b&4294967295;a.b[2]=a.b[2]+e&4294967295;a.b[3]=a.b[3]+f&4294967295;a.b[4]=a.b[4]+g&4294967295};
om.prototype.update=function(a,c){c=void 0===c?a.length:c;for(var b=c-64,d=0,e=this.j,f=this.f;d<c;){if(0==f)for(;d<=b;)pm(this,a,d),d+=64;if("string"===typeof a)for(;d<c;){if(e[f]=a.charCodeAt(d),++f,++d,64==f){pm(this,e);f=0;break}}else for(;d<c;)if(e[f]=a[d],++f,++d,64==f){pm(this,e);f=0;break}}this.f=f;this.h+=c};
om.prototype.digest=function(){var a=[],c=8*this.h;56>this.f?this.update(this.g,56-this.f):this.update(this.g,64-(this.f-56));for(var b=63;56<=b;b--)this.j[b]=c&255,c/=256;pm(this,this.j);for(b=c=0;5>b;b++)for(var d=24;0<=d;d-=8)a[c]=this.b[b]>>d&255,++c;return a};var qm=function(){return Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)};var sm=function(){this.j=qm();this.f=new rm(null,null);this.b=new rm(null,null);this.w=[];this.g=this.h=0;am(this)},um=function(){tm||(tm=new sm);return tm},vm=function(a,c){c=c.toLowerCase();var b=new om;b.update(c);b.update(a.j);return"r"+nm(b.digest())},wm=function(){var a=um();return a.f.model?a.f:a.b.model?a.b:new rm(null,null)};sm.prototype.Ea=function(){return"SinkUtils"};
sm.prototype.jb=function(){return[{recentLaunchedDevice:this.f,recentDiscoveredDevice:this.b},{receiverIdToken:this.j,fixedIpList:this.w.join(","),castControlPort:this.h,lastCloudSinkCheckTimeMillis:this.g}]};
sm.prototype.ib=function(){var a=Yl(this);a&&(this.f=a.recentLaunchedDevice||new rm(null,null),this.b=a.recentDiscoveredDevice||new rm(null,null));if(a=Zl(this))this.j=a.receiverIdToken||qm(),this.w=a.fixedIpList&&a.fixedIpList.split(",")||[],this.h=a.castControlPort||0,this.g=a.lastCloudSinkCheckTimeMillis||0};var tm=null,rm=function(a,c){this.model=a;this.ip=c};var xm=function(a,c){this.zc=this.wf=this.Td=this.La=this.kc=null;this.Ac=new Ul(c,a);this.ec={};this.Kh={};this.Fe=!1};xm.prototype.getId=function(){return this.Ac.id};xm.prototype.update=function(a){if(this.getId()!=a.getId())return!1;var c=!1;this.Ac.friendlyName!=a.Ac.friendlyName&&(this.Ac.friendlyName=a.Ac.friendlyName,c=!0);this.Td!=a.Td&&(this.Td=a.Td,c=!0);this.wf!=a.wf&&(this.wf=a.wf,c=!0);this.kc!=a.kc&&(this.kc=a.kc,c=!0);this.La!=a.La&&(this.La=a.La,c=!0);return c};xm.prototype.Sb=function(){return this.kc};
xm.prototype.xb=function(){return this.La};var ym=function(a,c){return a.ec[c]||"unknown"},zm=function(a){var c=new xm(a.Ac.friendlyName,"");c.Ac.id=a.Ac.id;c.kc=a.kc;c.La=a.La;c.Td=a.Td;c.wf=a.wf;c.zc=a.zc;c.ec=a.ec;c.Kh=a.Kh;c.Fe=a.Fe;return c};var Am=function(a,c,b,d,e,f){this.f=new Ul(a,c,d&1?"cast":d&32?"cast_audio_group":"cast_audio");this.zc=b||null;this.b=d||null;this.kc=e||null;this.La=f||null;this.ec={};this.Ci=!1};Am.prototype.update=function(a,c,b,d){var e=!1;this.f.friendlyName!=a&&(this.f.friendlyName=a,e=!0);null!=c&&this.kc!=c&&(this.kc=c,e=!0);null!=b&&this.La!=b&&(this.La=b,e=!0);null!=d&&this.b!=d&&(this.b=d,e=!0);return e};Am.prototype.getId=function(){return this.f.id};Am.prototype.Sb=function(){return this.kc};
Am.prototype.xb=function(){return this.La};var Bm=function(a,c){return a.ec[c]||"unknown"};var Cm="StopIteration"in Ha?Ha.StopIteration:{message:"StopIteration",stack:""},Dm=function(){};Dm.prototype.next=function(){throw Cm;};Dm.prototype.Jb=function(){return this};
var Em=function(a){if(a instanceof Dm)return a;if("function"==typeof a.Jb)return a.Jb(!1);if(Wa(a)){var c=0,b=new Dm;b.next=function(){for(;;){if(c>=a.length)throw Cm;if(c in a)return a[c++];c++}};return b}throw Error("Not implemented");},Fm=function(a,c,b){if(Wa(a))try{y(a,c,b)}catch(d){if(d!==Cm)throw d;}else{a=Em(a);try{for(;;)c.call(b,a.next(),void 0,a)}catch(d){if(d!==Cm)throw d;}}},Gm=function(a,c){a=Em(a);try{for(;!c.call(void 0,a.next(),void 0,a););}catch(b){if(b!==Cm)throw b;}},Hm=function(a){if(Wa(a))return z(a);
a=Em(a);var c=[];Fm(a,function(b){c.push(b)});return c};var Jm=function(a,c){this.f={};this.b=[];this.h=this.g=0;var b=arguments.length;if(1<b){if(b%2)throw Error("Uneven number of arguments");for(var d=0;d<b;d+=2)this.set(arguments[d],arguments[d+1])}else a&&Im(this,a)};Jm.prototype.sa=function(){return this.g};Jm.prototype.na=function(){Km(this);for(var a=[],c=0;c<this.b.length;c++)a.push(this.f[this.b[c]]);return a};Jm.prototype.wb=function(){Km(this);return this.b.concat()};var Mm=function(a,c){return Lm(a.f,c)};
Jm.prototype.Bf=function(a){for(var c=0;c<this.b.length;c++){var b=this.b[c];if(Lm(this.f,b)&&this.f[b]==a)return!0}return!1};Jm.prototype.equals=function(a,c){if(this===a)return!0;if(this.g!=a.sa())return!1;c=c||Nm;Km(this);for(var b,d=0;b=this.b[d];d++)if(!c(this.get(b),a.get(b)))return!1;return!0};var Nm=function(a,c){return a===c};Jm.prototype.Nb=function(){return 0==this.g};Jm.prototype.clear=function(){this.f={};this.h=this.g=this.b.length=0};
Jm.prototype.remove=function(a){return Lm(this.f,a)?(delete this.f[a],this.g--,this.h++,this.b.length>2*this.g&&Km(this),!0):!1};var Km=function(a){if(a.g!=a.b.length){for(var c=0,b=0;c<a.b.length;){var d=a.b[c];Lm(a.f,d)&&(a.b[b++]=d);c++}a.b.length=b}if(a.g!=a.b.length){var e={};for(b=c=0;c<a.b.length;)d=a.b[c],Lm(e,d)||(a.b[b++]=d,e[d]=1),c++;a.b.length=b}};Jm.prototype.get=function(a,c){return Lm(this.f,a)?this.f[a]:c};
Jm.prototype.set=function(a,c){Lm(this.f,a)||(this.g++,this.b.push(a),this.h++);this.f[a]=c};var Im=function(a,c){if(c instanceof Jm)for(var b=c.wb(),d=0;d<b.length;d++)a.set(b[d],c.get(b[d]));else for(b in c)a.set(b,c[b])};Jm.prototype.forEach=function(a,c){for(var b=this.wb(),d=0;d<b.length;d++){var e=b[d],f=this.get(e);a.call(c,f,e,this)}};Jm.prototype.clone=function(){return new Jm(this)};var Om=function(a){Km(a);for(var c={},b=0;b<a.b.length;b++){var d=a.b[b];c[d]=a.f[d]}return c};
Jm.prototype.Jb=function(a){Km(this);var c=0,b=this.h,d=this,e=new Dm;e.next=function(){if(b!=d.h)throw Error("The map has changed since the iterator was created");if(c>=d.b.length)throw Cm;var f=d.b[c++];return a?f:d.f[f]};return e};var Lm=function(a,c){return Object.prototype.hasOwnProperty.call(a,c)};var Pm=function(a,c){this.h=c;this.f=a;this.f.ra=this.ra.bind(this);this.b=new Jm;this.j=new Jm;this.l=hb("mr.cast.SinkDiscoveryService");this.g={sg:0,Eg:0}};q(Pm,Ni);Pm.prototype.init=function(){am(this);Xi("mr.cast.SinkDiscoveryService",this)};
var Xm=function(a,c){a.l.info("addSinks returned "+c.length+" sinks");ob(a.l,function(){return"....the list is: "+JSON.stringify(c)});var b=new Set(a.b.wb());c.forEach(function(e){var f=e.sink_id;var g=e.extra_data.cast_media_sink,k=g.ip_endpoint?g.ip_endpoint.address:g.ip_address,m=g.ip_endpoint?g.ip_endpoint.port:um().h||8009;f=new Am(f,e.name,g.model_name,g.capabilities,k.address_bytes.join("."),m);g=a.b.get(f.getId());k=a.f;e=e.extra_data.cast_media_sink.cast_channel_id;m=f.getId();var p=k.f.get(m);
if(!p||p.channelId!=e){Qm.info("Added cast channel "+e+" to receiver: "+m);p&&k.b.remove(p.channelId);p={auth:"ssl_verified",ipAddress:f.Sb(),port:f.xb()};p={channelId:e,readyState:"open",keepAlive:!0,audioOnly:!(f.b&1),connectInfo:p};k.f.set(m,p);k.b.set(e,m);var v=k.h.get(m);v&&v.channelId!=e&&(Qm.info("Re-connected to receiver: "+f.getId()),Rm(k.g,v,p),Sm(k.j.j,f,!0));k.h.set(m,p)}if(g){if(k=g.update(f.f.friendlyName,f.Sb(),f.xb(),f.b))g.Ci=!1;k&&Tm(a.h,g)}else a.l.info("Adding sink "+f.getId()),
Um(a,f),g=a.h,g.g.onSinkAvailabilityUpdated(g,1),Tm(g,f),Sm(g.j,f),um().b=new rm(f.zc,f.Sb());b.delete(f.getId())});b.forEach(function(e){var f=a.f,g=f.h.get(e);g&&(Vm(f.g,g),f.h.remove(e));Wm(a,e)});var d=a.b.sa();a.g={sg:d,Eg:d}};Pm.prototype.Ue=function(){return this.g};
var Um=function(a,c){var b=a.b.get(c.getId()),d=null,e=c.Sb(),f=c.xb();null!=e&&null!=f&&(d=a.j.get(e+":"+f));if(b&&!d){var g=c.Sb(),k=c.xb();g&&k&&a.j.remove(g+":"+k)}d&&!b&&a.b.remove(d.getId());a.b.set(c.getId(),c);null!=e&&null!=f&&a.j.set(e+":"+f,c)},Wm=function(a,c){var b=a.b.get(c);if(b){a.l.info("Removing sink "+c);a.b.remove(c);c=b.Sb();var d=b.xb();null!=c&&null!=d&&a.j.remove(c+":"+d);a=a.h;if(0==a.b.b.sa())a.g.onSinkAvailabilityUpdated(a,0);c=a.j;b=b.getId();(b=Ym(c.b,b))&&b.session&&
Zm(c,b.session.sessionId);$m(a.F);a.g.dd()}},bn=function(a){a.l.info("Pruning inactive sinks.");var c=new Set;a.b.forEach(function(b){an(a.f,b)||c.add(b.getId())});c.forEach(function(b){return Wm(a,b)})};Pm.prototype.ra=function(a){return this.b.get(a,null)};var cn=function(a,c){var b=[];Fm(a.b.Jb(!1),function(d){Tl(Bm(d,c))&&b.push(d)});return b};Pm.prototype.Ea=function(){return"cast.SinkDiscoveryService"};
Pm.prototype.jb=function(){var a=this,c={};Fm(this.b.Jb(!0),function(b){var d=a.b.get(b);d={id:d.getId(),ip:d.Sb(),port:d.xb(),friendlyName:d.f.friendlyName,modelName:d.zc,capabilities:d.b,discoveredByDial:d.Ci,appStatusMap:d.ec};c[b]=d});return[new dn(c,this.g)]};
Pm.prototype.ib=function(){var a=Yl(this);if(a&&4==a.version){this.g=a.deviceCounts;a=a.sinkMap;for(var c in a){var b=void 0,d=a[c],e=new Am("",d.friendlyName,d.modelName,d.capabilities,d.ip,d.port);e.f.id=d.id;e.Ci=d.discoveredByDial;e.ec=d.appStatusMap;for(b in e.ec)"unavailable"==e.ec[b]&&(e.ec[b]="unavailable_rescan");b=e;this.ra(b.getId())||Um(this,b)}bn(this)}};var dn=function(a,c){this.sinkMap=a;this.deviceCounts=c;this.version=4};var en={STOP_MEDIA:"STOP",MEDIA_SET_VOLUME:"SET_VOLUME",MEDIA_GET_STATUS:"GET_STATUS"};var fn=function(){this.type="GET_STATUS";this.requestId=0};var gn=function(a,c){this.requestId=a;this.fh=c;this.xn=null};gn.prototype.b=function(){};var hn=function(){this.b=new Jm},jn=function(a,c){a.b.set(c.requestId,c);c.xn=setTimeout(function(){a.b.remove(c.requestId);c.b()},c.fh)},kn=function(a,c){var b=a.b.get(c);if(!b)return null;clearTimeout(b.xn);a.b.remove(c);return b};var ln=function(a,c,b){this.type="APPLICATION_BROADCAST";this.requestId=0;this.appIds=a;this.namespace=c;this.message=b};var mn=function(a){this.type="LAUNCH";this.requestId=0;this.appId=a;this.language=null};var nn=function(a){this.type="STOP";this.requestId=0;this.sessionId=a||null};var on=function(a){this.f=a;this.b=1E3*Math.floor(1E6*Math.random())},pn=function(a){var c=a.b++;0==c&&(c=a.b++);return c};on.prototype.Ea=function(){return"IdGenerator."+this.f};on.prototype.jb=function(){return[this.b]};on.prototype.ib=function(){var a=Yl(this);a&&(this.b=a)};var qn=function(a,c){this.f=a;this.g=c;this.b=new hn;this.h=new on("cast.RequestIdGenerator")};qn.prototype.init=function(){am(this.h)};var sn=function(a,c,b,d){var e=pn(a.h);c.requestId=e;c=new Db;b=new rn(e,c,r(b)&&0<b?b:6E5,d);jn(a.b,b);return b};
qn.prototype.sendRequest=function(a,c,b,d,e,f){var g=this;if(!Sl.hasOwnProperty(b))return Promise.reject(Error("Custom namespace is not supported"));var k=sn(this,a,Ia(d)?d:3E3,e),m=k.ub;tn(this.f,c,b,a,e||this.g,f).then(null,function(){kn(g.b,k.requestId);m.reject(un)});return m.b};
qn.prototype.sendMessage=function(a,c,b,d,e,f){var g=this,k=sn(this,a,Ia(d)?d:3E3,e),m=k.ub;tn(this.f,c,b,a,e||this.g,f).then(function(){kn(g.b,k.requestId);m.resolve(!0)},function(){kn(g.b,k.requestId);m.reject(un)});return m.b};
var vn=function(a,c,b){var d=new mn(c.appId);d.language=c.language?c.language:chrome.i18n.getUILanguage?chrome.i18n.getUILanguage():chrome.runtime.getManifest().default_locale;return a.sendRequest(d,b,Nl,c.requestSessionTimeout)},wn=Error("Timeout"),un=Error("Failed to send message"),rn=function(a,c,b,d){gn.call(this,a,b);this.ub=c;this.sourceId=d};q(rn,gn);rn.prototype.b=function(){this.ub.reject(wn)};var xn=function(a){return a.sa&&"function"==typeof a.sa?a.sa():Wa(a)||Ja(a)?a.length:Bc(a)},yn=function(a){if(a.na&&"function"==typeof a.na)return a.na();if(Ja(a))return a.split("");if(Wa(a)){for(var c=[],b=a.length,d=0;d<b;d++)c.push(a[d]);return c}return Fc(a)},zn=function(a){if(a.wb&&"function"==typeof a.wb)return a.wb();if(!a.na||"function"!=typeof a.na){if(Wa(a)||Ja(a)){var c=[];a=a.length;for(var b=0;b<a;b++)c.push(b);return c}return Gc(a)}},An=function(a){return a.Nb&&"function"==typeof a.Nb?
a.Nb():Wa(a)||Ja(a)?Vb(a):Jc(a)},Bn=function(a,c,b){if(a.forEach&&"function"==typeof a.forEach)a.forEach(c,b);else if(Wa(a)||Ja(a))y(a,c,b);else for(var d=zn(a),e=yn(a),f=e.length,g=0;g<f;g++)c.call(b,e[g],d&&d[g],a)},Cn=function(a,c,b){if("function"==typeof a.map)return a.map(c,b);if(Wa(a)||Ja(a))return Nb(a,c,b);var d=zn(a),e=yn(a),f=e.length;if(d){var g={};for(var k=0;k<f;k++)g[d[k]]=c.call(b,e[k],d[k],a)}else for(g=[],k=0;k<f;k++)g[k]=c.call(b,e[k],void 0,a);return g},Dn=function(a,c){if("function"==
typeof a.every)return a.every(c,void 0);if(Wa(a)||Ja(a))return Qb(a,c,void 0);for(var b=zn(a),d=yn(a),e=d.length,f=0;f<e;f++)if(!c.call(void 0,d[f],b&&b[f],a))return!1;return!0};var Fn=function(a){this.b=new Jm;a&&En(this,a)},Gn=function(a){var c=typeof a;return"object"==c&&a||"function"==c?"o"+(a[Za]||(a[Za]=++ab)):c.substr(0,1)+a};Fn.prototype.sa=function(){return this.b.sa()};Fn.prototype.add=function(a){this.b.set(Gn(a),a)};var En=function(a,c){c=yn(c);for(var b=c.length,d=0;d<b;d++)a.add(c[d])};h=Fn.prototype;h.removeAll=function(a){a=yn(a);for(var c=a.length,b=0;b<c;b++)this.remove(a[b])};h.remove=function(a){return this.b.remove(Gn(a))};h.clear=function(){this.b.clear()};
h.Nb=function(){return this.b.Nb()};h.contains=function(a){return Mm(this.b,Gn(a))};h.na=function(){return this.b.na()};h.clone=function(){return new Fn(this)};h.equals=function(a){return this.sa()==xn(a)&&Hn(this,a)};var Hn=function(a,c){var b=xn(c);if(a.sa()>b)return!1;!(c instanceof Fn)&&5<b&&(c=new Fn(c));return Dn(a,function(d){var e=c;return e.contains&&"function"==typeof e.contains?e.contains(d):e.Bf&&"function"==typeof e.Bf?e.Bf(d):Wa(e)||Ja(e)?Ub(e,d):Ic(e,d)})};Fn.prototype.Jb=function(){return this.b.Jb(!1)};var Jn=function(a,c){this.h=a;this.g=c;this.f=new Jm;this.b=new Fn;this.j=0;this.o=new Jm("serviceCheck",this.xq.bind(this),"startDeviceMonitor",this.yq.bind(this),"releaseDeviceMonitor",this.wq.bind(this),"deviceJustSetUp",this.sq.bind(this),"logRecord",this.tq.bind(this));chrome.runtime.onMessage.addListener(this.m.bind(this));chrome.runtime.onMessageExternal.addListener(this.w.bind(this));In(this,"serviceReady")};Jn.prototype.l=hb("castApp.eventPage.Service");
var $m=function(a){if(Kn(a)){var c=new Fn;Fm(a.h.b.Jb(!1),function(d){var e=d.Sb();c.add(e);Mm(this.f,e)||this.g.sendRequest(new fn,d,Nl)}.bind(a));var b=!1;a.f.wb().forEach(function(d){c.contains(d)||(this.f.remove(d),b=!0)}.bind(a));b&&Ln(a)}},Kn=function(a){if(0===a.b.sa())return!1;var c=u();3E4<c-a.j&&(a.j=c,chrome.tabs.query({url:["chrome://cast/*","chrome-extension://"+chrome.runtime.id+"/cast_setup/*"]},function(b){0===b.length?(this.l.info("No tabs found. Clearing device monitor clients."),
this.b.clear()):this.l.info(function(){return"Tab check found active tabs: "+b.map(function(d){return d.id})})}.bind(a)));c=a.b.sa();a.l.info("Monitor client count: "+c);return 0<c};Jn.prototype.m=function(a,c,b){if("object"!==typeof a||"cast_app"!==a.type)return!1;var d=this.o.get(a.subtype);if(!d)return!1;if(!a.originId)return Hb("Missing origin ID in the incoming message."),!1;try{var e=d(a,c,b);e&&b(e)}catch(f){this.l.error("Error while handling request",f)}return!1};
var In=function(a,c,b){var d=new Il(c,b);ob(a.l,function(){return"Sending message: "+JSON.stringify(d)});chrome.runtime.sendMessage(d)};h=Jn.prototype;h.xq=function(){In(this,"serviceReady")};h.yq=function(a){this.b.contains(a.originId)?this.l.info("Client: "+a.originId+"already registered, dispatching current device list."):(this.l.info("Registering monitor client: "+a.originId),this.b.add(a.originId));Ln(this);Mn(this)};h.wq=function(a){this.l.info("Unregistering monitor client: "+a.originId);this.b.remove(a.originId)};
h.sq=function(a){a=a.deviceJustSetUp.udn.replace(/-/g,"").toLowerCase();this.l.info("Device just set up: "+a.slice(-4))};h.tq=function(a){a=a.logRecord;kb({level:rb(a.levelValue),R:a.loggerName,time:a.time,message:a.msg})};var Ln=function(a){var c=a.f.na();In(a,"devices",c)},Mn=function(a){a.h.b.na().forEach(function(c){this.g.sendRequest(new fn,c,Nl)}.bind(a))};
Jn.prototype.w=function(a,c,b){switch(a.type){case "handshake":b(new Kl("handshake"));break;case "launch":c=c.tab&&r(c.tab.id)?c.tab.id:null,null===c||"setup"!==a.entryPoint&&"offers"!==a.entryPoint&&"devices"!==a.entryPoint||chrome.tabs.update(c,{url:"chrome://cast#"+a.entryPoint})}};chrome.cast.VERSION=[1,2];w("chrome.cast.VERSION",chrome.cast.VERSION);chrome.cast.vt=!0;w("chrome.cast.usingPresentationApi",chrome.cast.vt);chrome.cast.Error=function(a,c,b){this.code=a;this.description=c||null;this.details=b||null};w("chrome.cast.Error",chrome.cast.Error);chrome.cast.Xo=function(a){this.platform=a;this.packageId=this.url=null};w("chrome.cast.SenderApplication",chrome.cast.Xo);chrome.cast.Image=function(a){this.url=a;this.width=this.height=null};w("chrome.cast.Image",chrome.cast.Image);
chrome.cast.Volume=function(a,c){this.level=Ia(a)?a:null;this.muted=Ia(c)?c:null};w("chrome.cast.Volume",chrome.cast.Volume);chrome.cast.jd={CUSTOM_CONTROLLER_SCOPED:"custom_controller_scoped",TAB_AND_ORIGIN_SCOPED:"tab_and_origin_scoped",ORIGIN_SCOPED:"origin_scoped",PAGE_SCOPED:"page_scoped"};w("chrome.cast.AutoJoinPolicy",chrome.cast.jd);chrome.cast.nh={CREATE_SESSION:"create_session",CAST_THIS_TAB:"cast_this_tab"};w("chrome.cast.DefaultActionPolicy",chrome.cast.nh);chrome.cast.Sd={VIDEO_OUT:"video_out",AUDIO_OUT:"audio_out",VIDEO_IN:"video_in",AUDIO_IN:"audio_in",MULTIZONE_GROUP:"multizone_group"};
w("chrome.cast.Capability",chrome.cast.Sd);chrome.cast.nd={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"};w("chrome.cast.ErrorCode",chrome.cast.nd);chrome.cast.Jo={AVAILABLE:"available",UNAVAILABLE:"unavailable"};
w("chrome.cast.ReceiverAvailability",chrome.cast.Jo);chrome.cast.Yo={CHROME:"chrome",IOS:"ios",ANDROID:"android"};w("chrome.cast.SenderPlatform",chrome.cast.Yo);chrome.cast.oh={CAST:"cast",DIAL:"dial",HANGOUT:"hangout",CUSTOM:"custom"};w("chrome.cast.ReceiverType",chrome.cast.oh);chrome.cast.Wn={RUNNING:"running",STOPPED:"stopped",ERROR:"error"};w("chrome.cast.DialAppState",chrome.cast.Wn);chrome.cast.ig={CAST:"cast",STOP:"stop"};w("chrome.cast.ReceiverAction",chrome.cast.ig);
chrome.cast.Qk={CONNECTED:"connected",DISCONNECTED:"disconnected",STOPPED:"stopped"};w("chrome.cast.SessionStatus",chrome.cast.Qk);chrome.cast.Uk={ATTENUATION:"attenuation",FIXED:"fixed",MASTER:"master"};w("chrome.cast.VolumeControlType",chrome.cast.Uk);chrome.cast.Kn=function(a,c,b,d,e){this.sessionRequest=a;this.sessionListener=c;this.receiverListener=b;this.autoJoinPolicy=d||chrome.cast.jd.TAB_AND_ORIGIN_SCOPED;this.defaultActionPolicy=e||chrome.cast.nh.CREATE_SESSION;this.customDialLaunchCallback=null;this.invisibleSender=!1;this.additionalSessionRequests=[]};w("chrome.cast.ApiConfig",chrome.cast.Kn);chrome.cast.Yn=function(a,c){this.appName=a;this.launchParameter=c||null};w("chrome.cast.DialRequest",chrome.cast.Yn);
chrome.cast.xk=function(a,c,b){this.receiver=a;this.appState=c;this.extraData=b||null};w("chrome.cast.DialLaunchData",chrome.cast.xk);chrome.cast.Xn=function(a,c){this.doLaunch=a;this.launchParameter=c||null};w("chrome.cast.DialLaunchResponse",chrome.cast.Xn);chrome.cast.Pk=function(a,c,b){this.appId=a;this.capabilities=Ua(c)?c:[chrome.cast.Sd.VIDEO_OUT,chrome.cast.Sd.AUDIO_OUT];this.requestSessionTimeout=b||chrome.cast.timeout.requestSession;this.dialRequest=this.language=null};
w("chrome.cast.SessionRequest",chrome.cast.Pk);
chrome.cast.hi=function(a,c,b,d){this.label=a;a=c;ud.test(a)&&(-1!=a.indexOf("&")&&(a=a.replace(od,"&amp;")),-1!=a.indexOf("<")&&(a=a.replace(pd,"&lt;")),-1!=a.indexOf(">")&&(a=a.replace(qd,"&gt;")),-1!=a.indexOf('"')&&(a=a.replace(rd,"&quot;")),-1!=a.indexOf("'")&&(a=a.replace(sd,"&#39;")),-1!=a.indexOf("\x00")&&(a=a.replace(td,"&#0;")));this.friendlyName=a;this.capabilities=b||[];this.volume=d||null;this.receiverType=chrome.cast.oh.CAST;this.displayStatus=this.isActiveInput=null};
w("chrome.cast.Receiver",chrome.cast.hi);chrome.cast.Ko=function(a,c){this.statusText=a;this.appImages=c;this.showStop=null};w("chrome.cast.ReceiverDisplayStatus",chrome.cast.Ko);chrome.cast.Sk=function(){this.requestSession=6E4;this.sendCustomMessage=this.setReceiverVolume=this.stopSession=this.leaveSession=3E3};w("chrome.cast.Timeout",chrome.cast.Sk);chrome.cast.timeout=new chrome.cast.Sk;w("chrome.cast.timeout",chrome.cast.timeout);chrome.cast.rk="auto-join";chrome.cast.Lk="cast-session_";chrome.cast.media.fo={SDR:"sdr",HDR:"hdr",DV:"dv"};w("chrome.cast.media.HdrType",chrome.cast.media.fo);chrome.cast.media.ho={AAC:"aac",AC3:"ac3",MP3:"mp3",TS:"ts",TS_AAC:"ts_aac",E_AC3:"e_ac3",FMP4:"fmp4"};w("chrome.cast.media.HlsSegmentFormat",chrome.cast.media.ho);chrome.cast.media.io={MPEG2_TS:"mpeg2_ts",FMP4:"fmp4"};w("chrome.cast.media.HlsVideoSegmentFormat",chrome.cast.media.io);chrome.cast.media.ve={PAUSE:"pause",SEEK:"seek",STREAM_VOLUME:"stream_volume",STREAM_MUTE:"stream_mute"};
w("chrome.cast.media.MediaCommand",chrome.cast.media.ve);chrome.cast.media.Go={ALBUM:"ALBUM",PLAYLIST:"PLAYLIST",AUDIOBOOK:"AUDIOBOOK",RADIO_STATION:"RADIO_STATION",PODCAST_SERIES:"PODCAST_SERIES",TV_SERIES:"TV_SERIES",VIDEO_PLAYLIST:"VIDEO_PLAYLIST",LIVE_TV:"LIVE_TV",MOVIE:"MOVIE"};w("chrome.cast.media.QueueType",chrome.cast.media.Go);chrome.cast.media.ci={GENERIC_CONTAINER:0,AUDIOBOOK_CONTAINER:1};w("chrome.cast.media.ContainerType",chrome.cast.media.ci);
chrome.cast.media.we={GENERIC:0,MOVIE:1,TV_SHOW:2,MUSIC_TRACK:3,PHOTO:4,AUDIOBOOK_CHAPTER:5};w("chrome.cast.media.MetadataType",chrome.cast.media.we);chrome.cast.media.PlayerState={IDLE:"IDLE",PLAYING:"PLAYING",PAUSED:"PAUSED",BUFFERING:"BUFFERING"};w("chrome.cast.media.PlayerState",chrome.cast.media.PlayerState);chrome.cast.media.ii={OFF:"REPEAT_OFF",ALL:"REPEAT_ALL",SINGLE:"REPEAT_SINGLE",ALL_AND_SHUFFLE:"REPEAT_ALL_AND_SHUFFLE"};w("chrome.cast.media.RepeatMode",chrome.cast.media.ii);
chrome.cast.media.Lo={PLAYBACK_START:"PLAYBACK_START",PLAYBACK_PAUSE:"PLAYBACK_PAUSE"};w("chrome.cast.media.ResumeState",chrome.cast.media.Lo);chrome.cast.media.Rk={BUFFERED:"BUFFERED",LIVE:"LIVE",OTHER:"OTHER"};w("chrome.cast.media.StreamType",chrome.cast.media.Rk);chrome.cast.media.ko={CANCELLED:"CANCELLED",INTERRUPTED:"INTERRUPTED",FINISHED:"FINISHED",ERROR:"ERROR"};w("chrome.cast.media.IdleReason",chrome.cast.media.ko);chrome.cast.media.jp={TEXT:"TEXT",AUDIO:"AUDIO",VIDEO:"VIDEO"};
w("chrome.cast.media.TrackType",chrome.cast.media.jp);chrome.cast.media.fp={SUBTITLES:"SUBTITLES",CAPTIONS:"CAPTIONS",DESCRIPTIONS:"DESCRIPTIONS",CHAPTERS:"CHAPTERS",METADATA:"METADATA"};w("chrome.cast.media.TextTrackType",chrome.cast.media.fp);chrome.cast.media.ap={NONE:"NONE",OUTLINE:"OUTLINE",DROP_SHADOW:"DROP_SHADOW",RAISED:"RAISED",DEPRESSED:"DEPRESSED"};w("chrome.cast.media.TextTrackEdgeType",chrome.cast.media.ap);chrome.cast.media.gp={NONE:"NONE",NORMAL:"NORMAL",ROUNDED_CORNERS:"ROUNDED_CORNERS"};
w("chrome.cast.media.TextTrackWindowType",chrome.cast.media.gp);chrome.cast.media.bp={SANS_SERIF:"SANS_SERIF",MONOSPACED_SANS_SERIF:"MONOSPACED_SANS_SERIF",SERIF:"SERIF",MONOSPACED_SERIF:"MONOSPACED_SERIF",CASUAL:"CASUAL",CURSIVE:"CURSIVE",SMALL_CAPITALS:"SMALL_CAPITALS"};w("chrome.cast.media.TextTrackFontGenericFamily",chrome.cast.media.bp);chrome.cast.media.cp={NORMAL:"NORMAL",BOLD:"BOLD",BOLD_ITALIC:"BOLD_ITALIC",ITALIC:"ITALIC"};w("chrome.cast.media.TextTrackFontStyle",chrome.cast.media.cp);
chrome.cast.media.mp={LIKE:"LIKE",DISLIKE:"DISLIKE",FOLLOW:"FOLLOW",UNFOLLOW:"UNFOLLOW"};w("chrome.cast.media.UserAction",chrome.cast.media.mp);chrome.cast.media.co=function(){this.customData=null};w("chrome.cast.media.GetStatusRequest",chrome.cast.media.co);chrome.cast.media.vo=function(){this.customData=null};w("chrome.cast.media.PauseRequest",chrome.cast.media.vo);chrome.cast.media.wo=function(){this.customData=null};w("chrome.cast.media.PlayRequest",chrome.cast.media.wo);chrome.cast.media.Wo=function(){this.customData=this.resumeState=this.currentTime=null};w("chrome.cast.media.SeekRequest",chrome.cast.media.Wo);
chrome.cast.media.Zo=function(){this.customData=null};w("chrome.cast.media.StopRequest",chrome.cast.media.Zo);chrome.cast.media.qp=function(a){this.volume=a;this.customData=null};w("chrome.cast.media.VolumeRequest",chrome.cast.media.qp);chrome.cast.media.mo=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};w("chrome.cast.media.LoadRequest",chrome.cast.media.mo);
chrome.cast.media.zy=function(a){this.type="PRECACHE";this.requestId=0;this.precacheData=a};chrome.cast.media.bo=function(a,c){this.requestId=0;this.activeTrackIds=a||null;this.textTrackStyle=c||null};w("chrome.cast.media.EditTracksInfoRequest",chrome.cast.media.bo);chrome.cast.media.bi=function(a){this.containerType=a=void 0===a?chrome.cast.media.ci.GENERIC_CONTAINER:a;this.containerDuration=this.containerImages=this.sections=this.title=void 0};w("chrome.cast.media.ContainerMetadata",chrome.cast.media.bi);
chrome.cast.media.nc=function(a){this.metadataType=this.type=a;this.queueItemId=this.sectionStartTimeInContainer=this.sectionStartAbsoluteTime=this.sectionStartTimeInMedia=this.sectionDuration=void 0};w("chrome.cast.media.MediaMetadata",chrome.cast.media.nc);chrome.cast.media.Dk=function(){chrome.cast.media.nc.call(this,chrome.cast.media.we.GENERIC);this.releaseDate=this.releaseYear=this.images=this.subtitle=this.title=void 0};q(chrome.cast.media.Dk,chrome.cast.media.nc);
w("chrome.cast.media.GenericMediaMetadata",chrome.cast.media.Dk);chrome.cast.media.Fk=function(){chrome.cast.media.nc.call(this,chrome.cast.media.we.MOVIE);this.releaseDate=this.releaseYear=this.images=this.subtitle=this.studio=this.title=void 0};q(chrome.cast.media.Fk,chrome.cast.media.nc);w("chrome.cast.media.MovieMediaMetadata",chrome.cast.media.Fk);
chrome.cast.media.Tk=function(){chrome.cast.media.nc.call(this,chrome.cast.media.we.TV_SHOW);this.originalAirdate=this.releaseYear=this.images=this.episode=this.episodeNumber=this.season=this.seasonNumber=this.episodeTitle=this.title=this.seriesTitle=void 0};q(chrome.cast.media.Tk,chrome.cast.media.nc);w("chrome.cast.media.TvShowMediaMetadata",chrome.cast.media.Tk);
chrome.cast.media.Gk=function(){chrome.cast.media.nc.call(this,chrome.cast.media.we.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=void 0};q(chrome.cast.media.Gk,chrome.cast.media.nc);w("chrome.cast.media.MusicTrackMediaMetadata",chrome.cast.media.Gk);
chrome.cast.media.Mk=function(){chrome.cast.media.nc.call(this,chrome.cast.media.we.PHOTO);this.creationDateTime=this.height=this.width=this.longitude=this.latitude=this.images=this.location=this.artist=this.title=void 0};q(chrome.cast.media.Mk,chrome.cast.media.nc);w("chrome.cast.media.PhotoMediaMetadata",chrome.cast.media.Mk);chrome.cast.media.tk=function(){chrome.cast.media.bi.call(this,chrome.cast.media.ci.AUDIOBOOK_CONTAINER);this.releaseDate=this.publisher=this.narrators=this.authors=void 0};
q(chrome.cast.media.tk,chrome.cast.media.bi);w("chrome.cast.media.AudiobookContainerMetadata",chrome.cast.media.tk);chrome.cast.media.sk=function(){chrome.cast.media.nc.call(this,chrome.cast.media.we.AUDIOBOOK_CHAPTER);this.images=this.subtitle=this.bookTitle=this.chapterNumber=this.title=this.chapterTitle=void 0};q(chrome.cast.media.sk,chrome.cast.media.nc);w("chrome.cast.media.AudiobookChapterMediaMetadata",chrome.cast.media.sk);
chrome.cast.media.oo=function(a,c){this.contentId=a;this.contentUrl=void 0;this.streamType=chrome.cast.media.Rk.BUFFERED;this.contentType=c;this.metadata=null;this.entity=void 0;this.duration=null;this.startAbsoluteTime=void 0;this.customData=this.textTrackStyle=this.tracks=null;this.userActionStates=this.hlsVideoSegmentFormat=this.hlsSegmentFormat=this.vmapAdsRequest=this.breakClips=this.breaks=void 0};w("chrome.cast.media.MediaInfo",chrome.cast.media.oo);
chrome.cast.media.Ao=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};w("chrome.cast.media.QueueItem",chrome.cast.media.Ao);chrome.cast.media.Un="CC1AD845";w("chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID",chrome.cast.media.Un);chrome.cast.media.timeout={};chrome.cast.media.timeout.load=0;w("chrome.cast.media.timeout.load",chrome.cast.media.timeout.load);
chrome.cast.media.timeout.Va=0;w("chrome.cast.media.timeout.getStatus",chrome.cast.media.timeout.Va);chrome.cast.media.timeout.play=0;w("chrome.cast.media.timeout.play",chrome.cast.media.timeout.play);chrome.cast.media.timeout.pause=0;w("chrome.cast.media.timeout.pause",chrome.cast.media.timeout.pause);chrome.cast.media.timeout.seek=0;w("chrome.cast.media.timeout.seek",chrome.cast.media.timeout.seek);chrome.cast.media.timeout.stop=0;w("chrome.cast.media.timeout.stop",chrome.cast.media.timeout.stop);
chrome.cast.media.timeout.setVolume=0;w("chrome.cast.media.timeout.setVolume",chrome.cast.media.timeout.setVolume);chrome.cast.media.timeout.Ei=0;w("chrome.cast.media.timeout.editTracksInfo",chrome.cast.media.timeout.Ei);chrome.cast.media.timeout.ls=0;w("chrome.cast.media.timeout.queue",chrome.cast.media.timeout.ls);chrome.cast.media.hp=function(a,c){this.trackId=a;this.trackContentType=this.trackContentId=null;this.type=c;this.customData=this.subtype=this.language=this.name=null};
w("chrome.cast.media.Track",chrome.cast.media.hp);chrome.cast.media.ep=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};w("chrome.cast.media.TextTrackStyle",chrome.cast.media.ep);
chrome.cast.media.Co=function(a){this.type="QUEUE_LOAD";this.sessionId=this.requestId=null;this.items=a;this.startIndex=0;this.repeatMode=chrome.cast.media.ii.OFF;this.customData=null};w("chrome.cast.media.QueueLoadRequest",chrome.cast.media.Co);chrome.cast.media.zo=function(a){this.type="QUEUE_INSERT";this.sessionId=this.requestId=null;this.items=a;this.customData=this.insertBefore=null};w("chrome.cast.media.QueueInsertItemsRequest",chrome.cast.media.zo);
chrome.cast.media.Ho=function(a){this.type="QUEUE_UPDATE";this.sessionId=this.requestId=null;this.items=a;this.customData=null};w("chrome.cast.media.QueueUpdateItemsRequest",chrome.cast.media.Ho);chrome.cast.media.Bo=function(){this.type="QUEUE_UPDATE";this.customData=this.jump=this.currentItemId=this.sessionId=this.requestId=null};w("chrome.cast.media.QueueJumpRequest",chrome.cast.media.Bo);
chrome.cast.media.Fo=function(){this.type="QUEUE_UPDATE";this.customData=this.repeatMode=this.sessionId=this.requestId=null};w("chrome.cast.media.QueueSetPropertiesRequest",chrome.cast.media.Fo);chrome.cast.media.Do=function(a){this.type="QUEUE_REMOVE";this.sessionId=this.requestId=null;this.itemIds=a;this.customData=null};w("chrome.cast.media.QueueRemoveItemsRequest",chrome.cast.media.Do);
chrome.cast.media.Eo=function(a){this.type="QUEUE_REORDER";this.sessionId=this.requestId=null;this.itemIds=a;this.customData=this.insertBefore=null};w("chrome.cast.media.QueueReorderItemsRequest",chrome.cast.media.Eo);chrome.cast.media.Nn=function(a,c,b){this.id=a;this.breakClipIds=c;this.position=b;this.duration=void 0;this.isWatched=!1;this.isEmbedded=void 0};w("chrome.cast.media.Break",chrome.cast.media.Nn);
chrome.cast.media.On=function(a){this.id=a;this.vastAdsRequest=this.customData=this.hlsSegmentFormat=this.clickThroughUrl=this.posterUrl=this.whenSkippable=this.duration=this.title=this.contentType=this.contentUrl=this.contentId=void 0};w("chrome.cast.media.BreakClip",chrome.cast.media.On);chrome.cast.media.op=function(){this.adsResponse=this.adTagUrl=void 0};w("chrome.cast.media.VastAdsRequest",chrome.cast.media.op);
chrome.cast.media.Pn=function(){this.whenSkippable=this.breakClipId=this.breakId=this.currentBreakClipTime=this.currentBreakTime=void 0};w("chrome.cast.media.BreakStatus",chrome.cast.media.Pn);chrome.cast.media.lo=function(a,c,b,d){this.start=a;this.end=c;this.isMovingWindow=b;this.isLiveDone=d};w("chrome.cast.media.LiveSeekableRange",chrome.cast.media.lo);
chrome.cast.media.yo=function(a,c,b,d,e,f,g){this.id=a;this.queueType=this.entity=void 0;this.name=c;this.description=b;this.repeatMode=d;this.shuffle=!1;this.items=e;this.startIndex=f;this.startTime=g;this.containerMetadata=void 0};w("chrome.cast.media.QueueData",chrome.cast.media.yo);chrome.cast.media.np=function(a){this.userAction=a;this.customData=void 0};w("chrome.cast.media.UserActionState",chrome.cast.media.np);chrome.cast.media.pp=function(a,c,b){this.width=a;this.height=c;this.hdrType=b};
w("chrome.cast.media.VideoInformation",chrome.cast.media.pp);chrome.cast.media.X=function(a,c){this.sessionId=a;this.mediaSessionId=c;this.media=null;this.videoInfo=this.queueData=void 0;this.playbackRate=1;this.playerState=chrome.cast.media.PlayerState.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.ii.OFF;this.liveSeekableRange=this.breakStatus=void 0};
w("chrome.cast.media.Media",chrome.cast.media.X);chrome.cast.media.X.prototype.Va=function(){};chrome.cast.media.X.prototype.getStatus=chrome.cast.media.X.prototype.Va;chrome.cast.media.X.prototype.play=function(){};chrome.cast.media.X.prototype.play=chrome.cast.media.X.prototype.play;chrome.cast.media.X.prototype.bs=function(){};chrome.cast.media.X.prototype.playWithContext=chrome.cast.media.X.prototype.bs;chrome.cast.media.X.prototype.pause=function(){};chrome.cast.media.X.prototype.pause=chrome.cast.media.X.prototype.pause;
chrome.cast.media.X.prototype.Yr=function(){};chrome.cast.media.X.prototype.pauseWithContext=chrome.cast.media.X.prototype.Yr;chrome.cast.media.X.prototype.seek=function(){};chrome.cast.media.X.prototype.seek=chrome.cast.media.X.prototype.seek;chrome.cast.media.X.prototype.stop=function(){};chrome.cast.media.X.prototype.stop=chrome.cast.media.X.prototype.stop;chrome.cast.media.X.prototype.setVolume=function(){};chrome.cast.media.X.prototype.setVolume=chrome.cast.media.X.prototype.setVolume;
chrome.cast.media.X.prototype.Ei=function(){};chrome.cast.media.X.prototype.editTracksInfo=chrome.cast.media.X.prototype.Ei;chrome.cast.media.X.prototype.ns=function(){};chrome.cast.media.X.prototype.queueInsertItems=chrome.cast.media.X.prototype.ns;chrome.cast.media.X.prototype.ms=function(){};chrome.cast.media.X.prototype.queueAppendItem=chrome.cast.media.X.prototype.ms;chrome.cast.media.X.prototype.zs=function(){};chrome.cast.media.X.prototype.queueUpdateItems=chrome.cast.media.X.prototype.zs;
chrome.cast.media.X.prototype.us=function(){};chrome.cast.media.X.prototype.queuePrev=chrome.cast.media.X.prototype.us;chrome.cast.media.X.prototype.ts=function(){};chrome.cast.media.X.prototype.queueNext=chrome.cast.media.X.prototype.ts;chrome.cast.media.X.prototype.os=function(a){Nn(this,a)};chrome.cast.media.X.prototype.queueJumpToItem=chrome.cast.media.X.prototype.os;chrome.cast.media.X.prototype.ys=function(){};chrome.cast.media.X.prototype.queueSetRepeatMode=chrome.cast.media.X.prototype.ys;
chrome.cast.media.X.prototype.ws=function(){};chrome.cast.media.X.prototype.queueRemoveItems=chrome.cast.media.X.prototype.ws;chrome.cast.media.X.prototype.vs=function(a){Nn(this,a)};chrome.cast.media.X.prototype.queueRemoveItem=chrome.cast.media.X.prototype.vs;chrome.cast.media.X.prototype.xs=function(){};chrome.cast.media.X.prototype.queueReorderItems=chrome.cast.media.X.prototype.xs;
chrome.cast.media.X.prototype.rs=function(a,c,b,d){a=Nn(this,a);0>a||(0>c?d&&d(new chrome.cast.Error(chrome.cast.nd.INVALID_PARAMETER)):a==c&&b&&b())};chrome.cast.media.X.prototype.queueMoveItemToNewIndex=chrome.cast.media.X.prototype.rs;chrome.cast.media.X.prototype.rt=function(a){return-1<this.supportedMediaCommands.indexOf(a)};chrome.cast.media.X.prototype.supportsCommand=chrome.cast.media.X.prototype.rt;chrome.cast.media.X.prototype.mq=function(){return this.currentTime};
chrome.cast.media.X.prototype.getEstimatedTime=chrome.cast.media.X.prototype.mq;chrome.cast.media.X.prototype.si=function(){};chrome.cast.media.X.prototype.addUpdateListener=chrome.cast.media.X.prototype.si;chrome.cast.media.X.prototype.ti=function(){};chrome.cast.media.X.prototype.addUpdateListenerWithContext=chrome.cast.media.X.prototype.ti;chrome.cast.media.X.prototype.Wj=function(){};chrome.cast.media.X.prototype.removeUpdateListener=chrome.cast.media.X.prototype.Wj;
chrome.cast.media.X.prototype.Xj=function(){};chrome.cast.media.X.prototype.removeUpdateListenerWithContext=chrome.cast.media.X.prototype.Xj;var Nn=function(a,c){return Rb(a.items,function(b){return b.itemId==c})};var On=function(a,c,b){this.sessionId=a;this.namespaceName=c;this.message=b};var Pn=function(a,c){this.type="SET_VOLUME";this.requestId=0;this.volume=a;this.expectedVolume=c||null};chrome.cast.ca=function(a,c,b,d,e){this.sessionId=a;this.appId=c;this.displayName=b;this.statusText=null;this.appImages=d;this.receiver=e;this.senderApps=[];this.namespaces=[];this.media=[];this.status=chrome.cast.Qk.CONNECTED;this.transportId=""};w("chrome.cast.Session",chrome.cast.ca);chrome.cast.ca.prototype.et=function(a,c,b){this.pn(null,a,c,b)};chrome.cast.ca.prototype.setReceiverVolumeLevel=chrome.cast.ca.prototype.et;
chrome.cast.ca.prototype.pn=function(a,c,b,d){c=new Pn(new chrome.cast.Volume(c,null),this.receiver.volume);a.setReceiverVolume(this.sessionId,c,b,d)};chrome.cast.ca.prototype.setReceiverVolumeLevelWithContext=chrome.cast.ca.prototype.pn;chrome.cast.ca.prototype.dt=function(a,c,b){this.nn(null,a,c,b)};chrome.cast.ca.prototype.setReceiverMuted=chrome.cast.ca.prototype.dt;
chrome.cast.ca.prototype.nn=function(a,c,b,d){a=new Pn(new chrome.cast.Volume(null,c),this.receiver.volume);null.setReceiverVolume(this.sessionId,a,b,d)};chrome.cast.ca.prototype.setReceiverMutedWithContext=chrome.cast.ca.prototype.nn;chrome.cast.ca.prototype.leave=function(a,c){null.leaveSession(this.sessionId,a,c)};chrome.cast.ca.prototype.leave=chrome.cast.ca.prototype.leave;chrome.cast.ca.prototype.stop=function(){};chrome.cast.ca.prototype.stop=chrome.cast.ca.prototype.stop;
chrome.cast.ca.prototype.ot=function(){};chrome.cast.ca.prototype.stopWithContext=chrome.cast.ca.prototype.ot;chrome.cast.ca.prototype.sendMessage=function(){};chrome.cast.ca.prototype.sendMessage=chrome.cast.ca.prototype.sendMessage;chrome.cast.ca.prototype.Qs=function(){};chrome.cast.ca.prototype.sendMessageWithContext=chrome.cast.ca.prototype.Qs;chrome.cast.ca.prototype.si=function(){};chrome.cast.ca.prototype.addUpdateListener=chrome.cast.ca.prototype.si;chrome.cast.ca.prototype.ti=function(){};
chrome.cast.ca.prototype.addUpdateListenerWithContext=chrome.cast.ca.prototype.ti;chrome.cast.ca.prototype.Wj=function(){};chrome.cast.ca.prototype.removeUpdateListener=chrome.cast.ca.prototype.Wj;chrome.cast.ca.prototype.Xj=function(){};chrome.cast.ca.prototype.removeUpdateListenerWithContext=chrome.cast.ca.prototype.Xj;chrome.cast.ca.prototype.Ep=function(){};chrome.cast.ca.prototype.addMessageListener=chrome.cast.ca.prototype.Ep;chrome.cast.ca.prototype.Fp=function(){};
chrome.cast.ca.prototype.addMessageListenerWithContext=chrome.cast.ca.prototype.Fp;chrome.cast.ca.prototype.Cp=function(){};chrome.cast.ca.prototype.addMediaListener=chrome.cast.ca.prototype.Cp;chrome.cast.ca.prototype.Dp=function(){};chrome.cast.ca.prototype.addMediaListenerWithContext=chrome.cast.ca.prototype.Dp;chrome.cast.ca.prototype.Is=function(){};chrome.cast.ca.prototype.removeMediaListener=chrome.cast.ca.prototype.Is;chrome.cast.ca.prototype.Js=function(){};
chrome.cast.ca.prototype.removeMediaListenerWithContext=chrome.cast.ca.prototype.Js;chrome.cast.ca.prototype.Ks=function(){};chrome.cast.ca.prototype.removeMessageListener=chrome.cast.ca.prototype.Ks;chrome.cast.ca.prototype.Ls=function(){};chrome.cast.ca.prototype.removeMessageListenerWithContext=chrome.cast.ca.prototype.Ls;chrome.cast.ca.prototype.Qq=function(a){a.sessionId=this.sessionId};chrome.cast.ca.prototype.loadMedia=chrome.cast.ca.prototype.Qq;
chrome.cast.ca.prototype.qs=function(a){a.sessionId=this.sessionId};chrome.cast.ca.prototype.queueLoad=chrome.cast.ca.prototype.qs;var Sn=function(a,c){if(!c.applications||1!=c.applications.length)return null;var b=c.applications[0];a=Qn(a);a=new chrome.cast.ca(b.sessionId,b.appId,b.displayName,b.appImages,a);a.senderApps=b.senderApps;a.namespaces=b.namespaces||[];a.transportId=b.transportId;a.statusText=b.statusText;if(!a.sessionId||!(a.namespaces&&0!=a.namespaces.length||Rn(a)))return null;a.receiver.volume=c.volume;Ka(c.isActiveInput)&&(a.receiver.isActiveInput=c.isActiveInput);return a},Tn=function(a){var c=[];if(!a)return c;
a&1&&c.push(chrome.cast.Sd.VIDEO_OUT);a&2&&c.push(chrome.cast.Sd.VIDEO_IN);a&4&&c.push(chrome.cast.Sd.AUDIO_OUT);a&8&&c.push(chrome.cast.Sd.AUDIO_IN);a&32&&c.push(chrome.cast.Sd.MULTIZONE_GROUP);return c},Qn=function(a){var c=vm(um(),a.getId());return new chrome.cast.hi(c,a.f.friendlyName,Tn(a.b))},Un=function(a,c){if(a.statusText!=c.statusText)return!0;var b=a.namespaces||[],d=c.namespaces||[];if(b.length!=d.length)return!0;for(var e={fg:0};e.fg<b.length;e={fg:e.fg},e.fg++)if(!d.some(function(f){return function(g){return g.name==
b[f.fg].name}}(e)))return!0;return a.receiver.volume.level!==c.receiver.volume.level||a.receiver.volume.muted!==c.receiver.volume.muted?!0:!1},Vn=function(a){Ua(a)?a.forEach(Vn):Ya(a)&&Object.keys(a).forEach(function(c){null===a[c]?delete a[c]:(Ya(a[c])||Ua(a[c]))&&Vn(a[c])})},Wn=function(a){return a.namespaces.some(function(c){return c.name==Pl})},Rn=function(a){return null!==a&&"MultizoneLeader"==a.appId},Xn=function(a){return"E8C28D3C"==a||"00000000-0000-0000-0000-000000000000"==a};var Yn=function(a,c,b){this.type=a;this.message=c;this.sequenceNumber=Ia(b)?b:-1;this.timeoutMillis=0;this.clientId=""};var Zn=function(a,c){this.h=a;this.b=c;this.g=[];this.f=new hn},ao=function(a,c){return(a=$n(a.b,c))?a.routeId:null};Zn.prototype.listen=function(a,c){this.g[a]=c};var co=function(a,c,b,d){ob(bo,"Sending to "+b);ob(bo,JSON.stringify(d));d.clientId=b;a.h.g.ee(c,d)},eo=function(a,c,b){var d=$n(a.b,c);d&&d.b?co(a,d.routeId,c,b):a.connect(c).then(function(e){e?(e=ao(a,c))?co(a,e,c,b):bo.G("No route for "+c):bo.G("No connected client "+c)},null)};
Zn.prototype.connect=function(a){var c=$n(this.b,a);if(null!=c&&c.b)return Promise.resolve(!0);c=ao(this,a);if(!c)return bo.G("No route for client "+a),Promise.resolve(!1);if(a=this.f.b.get(c,null))return a.ub.b;a=new Db;jn(this.f,new fo(c,a));return a.b};var bo=hb("mr.cast.ApiMessenger"),fo=function(a,c){gn.call(this,a,3E4);this.ub=c};q(fo,gn);fo.prototype.b=function(){this.ub.resolve(!1)};var go=function(a,c,b){this.g=a;this.b=c;this.f=b},ho=function(a){var c="cast-dial:"+a.g,b=new URLSearchParams;a.b&&b.set("dialPostData",a.b);a.f&&b.set("clientId",a.f);(a=b.toString())&&(c+="?"+a);return c};var io=function(a,c,b,d,e,f,g,k,m,p){this.j=a;this.b=c||null;this.f=b||null;this.g=d||null;this.h=Ia(e)?e:null;this.s=f||null;this.D=g||null;this.o=k||!1;this.m=m||null;this.w=p||null},jo=function(a,c){return(a=a.match(c+"=([^/]*)"))?a[1]:null},lo=function(a){a=a.match(/__castAppId__=([^/]*)/g);return null==a?[]:Mb(Nb(a,function(c){c=jo(c,"__castAppId__");if(!c)return null;c=c.match(ko);if(!c||0==c.length)return null;var b=[];3==c.length&&c[2]&&(b=c[2].split(","));return{appId:c[1],capabilities:b}}),
function(c){return null!=c})},mo=function(a){return Nb(a.j,function(c){return c.appId})},no=function(a){return a.f?a.f:chrome.cast.jd.TAB_AND_ORIGIN_SCOPED},oo=function(a){var c=a.j.map(function(b){var d="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.o&&e.set("invisibleSender",
"true");a.m&&(e.set("broadcastNamespace",a.m),e.set("broadcastId",String(Math.random())));a.w&&e.set("broadcastMessage",encodeURIComponent(JSON.stringify(a.w)));return d+"?"+e.toString()});a.s&&c.push(ho(new go(a.s,a.D,a.b)));return c},qo=function(a,c){a=mo(a);var b=po(c);return Pb(a,function(d){return Ub(b,d)})},ro=function(a){try{var c=new URL(a)}catch(v){return null}if("https:"==c.protocol)if("https:"!=c.protocol||"google.com"!=c.host||"/cast"!=c.pathname)a=null;else{var b=c.hash;if((a=lo(b))&&
0!=a.length){c=jo(b,"__castClientId__");var d=jo(b,"__castAutoJoinPolicy__"),e=jo(b,"__castDefaultActionPolicy__");var f=jo(b,"__castLaunchTimeout__");null==f?f=null:(f=Number(f),f=!isNaN(f)&&0<f?f:null);var g=jo(b,"__dialAppName__"),k=jo(b,"__dialPostData__");var m=jo(b,"__castInvisibleSender__");m=null===m?null:"true"==m;var p=jo(b,"__castBroadcastNamespace__");b=(b=jo(b,"__castBroadcastMessage__"))?JSON.parse(decodeURIComponent(b)):null;a=new io(a,c,d,e,f,g,k,m,p,b)}else a=null}else if("cast:"==
c.protocol){a=c.pathname;d=c.searchParams.get("capabilities");a={appId:a,capabilities:d?d.split(","):[]};k=c.searchParams;c=k.get("clientId");d=k.get("autoJoinPolicy");e=k.get("defaultActionPolicy");b=Number(k.get("launchTimeout"));if(isNaN(b)||0>=b)b=null;f="true"==k.get("invisibleSender");g=k.get("broadcastNamespace");k=(k=k.get("broadcastMessage"))?JSON.parse(decodeURIComponent(k)):null;a=new io([a],c,d,e,b,void 0,void 0,f,g,k)}else a=null;return a},po=function(a){return(a=ro(a))?mo(a):null},so=
function(a){return(a=ro(a))?a.b:null},ko=/(^\w+)(?:\(([\w, ]*)\))?$/;var to={Bw:0,nw:1},uo={jA:0,Io:1,Dy:2},vo={Gx:0,TIMEOUT:1,FAILED:2},wo={Zv:0,ly:1,SEEK:2,jx:3,yz:4,Pt:5},xo=function(a){Cb("MediaRouter.Cast.Session.Ended",a,uo)},yo=function(a){Cb("MediaRouter.Cast.Controller.ActionType",a,wo)},zo=function(a){Cb("MediaRouter.Cast.Session.Fail",a,vo)};var Ao=function(a,c,b){this.R=hb("mr.MediaRouteController."+a);this.h=new mojo.Binding(mojo.MediaController,this,c);this.g=b;this.b=new mojo.MediaStatus({title:"",description:"",duration:new mojo.TimeDelta({microseconds:0}),current_time:new mojo.TimeDelta({microseconds:0})});this.s=!1;this.h.setConnectionErrorHandler(this.w.bind(this));this.g.ptr.setConnectionErrorHandler(this.w.bind(this))};Ao.prototype.w=function(){this.Za();this.qj()};
Ao.prototype.Za=function(){this.s||(this.s=!0,this.pj(),this.h&&(this.h.close(),this.h=null),this.g&&(this.g.ptr.reset(),this.g=null))};var Bo=function(a){if(a.g)a.g.onMediaStatusUpdated(a.b)};h=Ao.prototype;h.pj=function(){};h.qj=function(){};h.play=function(){};h.pause=function(){};h.hf=function(){};h.setVolume=function(){};h.seek=function(){};h.yi=function(a){a.close();throw Error("Not implemented");};Ao.prototype.connectHangoutsMediaRouteController=Ao.prototype.yi;Ao.prototype.seek=Ao.prototype.seek;
Ao.prototype.setVolume=Ao.prototype.setVolume;Ao.prototype.setMute=Ao.prototype.hf;Ao.prototype.pause=Ao.prototype.pause;Ao.prototype.play=Ao.prototype.play;var Co=function(a){var c=new URL(a);a={};a.scheme=c.protocol.replace(":","");a.host=c.hostname;c=c.port?Number.parseInt(c.port,10):0;switch(a.scheme){case "http":a.port=c||80;break;case "https":a.port=c||443;break;default:throw Error("Scheme must be http or https");}a.suborigin="";return new mojo.Origin(a)},Do=function(a){return new mojo.TimeDelta({microseconds:Math.floor(1E6*a)})};var Eo=function(a,c,b,d){this.type=a;this.mediaSessionId=c;this.requestId=0;this.sessionId=b;this.currentTime=d},Go=function(a,c,b,d,e){Ao.call(this,"CastRouteController",a,c);this.session=b;this.f=d;this.j=e;this.o=new Date;this.m=new Set;Fo(this);yo(0)};q(Go,Ao);
var Fo=function(a){var c=Ho(a);c&&Io(a,c);c&&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.Uk.FIXED;a.b.can_set_volume=a.b.can_mute;Bo(a)};h=Go.prototype;h.qj=function(){Jo(this.f.b,this.session.sessionId)};
h.play=function(){var a=Ho(this);this.b.can_play_pause&&a&&this.b.play_state===mojo.MediaStatus.PlayState.PAUSED&&Ko(this.f,this.session,new Eo("PLAY",a.mediaSessionId,this.session.sessionId));Lo(this,1)};h.pause=function(){var a=Ho(this);this.b.can_play_pause&&a&&this.b.play_state!==mojo.MediaStatus.PlayState.PAUSED&&Ko(this.f,this.session,new Eo("PAUSE",a.mediaSessionId,this.session.sessionId));Lo(this,1)};
h.seek=function(a){var c=Ho(this);a=a?a.microseconds/1E6:0;var b;if(b=this.b.can_seek&&c&&0<=a)b=this.b.duration,b=a<=(b?b.microseconds/1E6:0);b&&Ko(this.f,this.session,new Eo("SEEK",c.mediaSessionId,this.session.sessionId,a));Lo(this,2)};h.hf=function(a){this.b.can_mute&&a!==this.b.is_muted&&Mo(this.f,this.session,new chrome.cast.Volume(null,a));Lo(this,3)};h.setVolume=function(a){this.b.can_set_volume&&0<=a&&1>=a&&Mo(this.f,this.session,new chrome.cast.Volume(a));Lo(this,4)};
var Ho=function(a){return a.session.media.find(function(c){return!c.idleReason})||null},Io=function(a,c){a.j&&c.media&&c.media.metadata&&c.media.metadata.title&&(a.b.title=c.media.metadata.title.substring(0,256));a.b.can_play_pause=c.supportedMediaCommands.includes(chrome.cast.media.ve.PAUSE);a.b.can_seek=c.supportedMediaCommands.includes(chrome.cast.media.ve.SEEK);var b=c.playerState;a.b.play_state=b===chrome.cast.media.PlayerState.PLAYING?mojo.MediaStatus.PlayState.PLAYING:b===chrome.cast.media.PlayerState.PAUSED?
mojo.MediaStatus.PlayState.PAUSED:mojo.MediaStatus.PlayState.BUFFERING;a.b.current_time=c.currentTime?Do(c.playerState===chrome.cast.media.PlayerState.PLAYING?c.currentTime+(new Date-a.o)/1E3:c.currentTime):Do(0);a.b.duration=c.media&&c.media.duration?Do(c.media.duration):Do(0)},Lo=function(a,c){0==a.m.size&&yo(5);a.m.has(c)||(yo(c),a.m.add(c))};Go.prototype.setVolume=Go.prototype.setVolume;Go.prototype.setMute=Go.prototype.hf;Go.prototype.seek=Go.prototype.seek;Go.prototype.pause=Go.prototype.pause;
Go.prototype.play=Go.prototype.play;var No=function(a){this.f=a;this.l=hb("mr.cast.SessionLauncher")},Oo=function(a,c,b){Cb("MediaRouter.Cast.Session.Type",0,to);return vn(a.f,c,b).then(a.b.bind(a,b),function(d){d&&wn==d?zo(1):zo(0);throw d;})};No.prototype.b=function(a,c){ob(this.l,"Got launch result from "+a.getId());if("LAUNCH_ERROR"==c.type)throw zo(2),Error(c.reason);a=Sn(a,c.status);this.l.info("Launched session: "+a.sessionId);return a};var Po=function(a){this.b=a;this.l=hb("mr.cast.ReceiverStatusQuerier")},Qo=function(a,c){return(new ef(t(a.f,a,c),3500,5)).start().then(null,function(b){a.l.info("Failed to get receiver status from "+c.getId());throw b;})};Po.prototype.f=function(a){this.l.info("Query receiver status: "+a.getId());return this.b.sendRequest(new fn,a,Nl)};var Ro=function(a,c,b,d,e,f){this.g=a;this.w=c;this.j=b;this.b=d;this.m=e;this.h=f;this.f=new Zn(f,b);this.C=new Po(this.g);this.F=new No(this.g)};Ro.prototype.init=function(){this.j.init();this.f.listen("v2_message",this.D.bind(this));this.f.listen("app_message",this.o.bind(this));this.f.listen("leave_session",this.s.bind(this))};
var Uo=function(a,c,b,d){So(a.b,c).slice().forEach(function(e){e!=d&&To(a,e,b)})},To=function(a,c,b){b.clientId=c;eo(a.f,c,b)},Vo=function(a,c,b,d){b={receiver:Qn(b),action:d};To(a,c,new Yn("receiver_action",b))};
Ro.prototype.D=function(a){var c=a.message,b=c.sessionId;if(b){var d=Wo(this.b,b);if(d)if(b=Xo(this.b,b))if(b=this.w.ra(b))switch(c.type){case "STOP":Yo(this,a,b);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":Zo(this,a,b,d);break;case "SET_VOLUME":$o(this,a,b);break;default:ap.G("Unknown request")}else bp(this,
a,chrome.cast.nd.INVALID_PARAMETER,"No receiver");else bp(this,a,chrome.cast.nd.INVALID_PARAMETER,"No sink ID");else bp(this,a,chrome.cast.nd.INVALID_PARAMETER,"Unknown session ID")}else bp(this,a,chrome.cast.nd.INVALID_PARAMETER,"No session ID")};
var bp=function(a,c,b,d){b=new chrome.cast.Error(b,d);cp(a,c,b)},cp=function(a,c,b){eo(a.f,c.clientId,new Yn("error",b,c.sequenceNumber))},Yo=function(a,c,b){var d=c.message;Bb("MediaRouter.Cast.Session.End");var e=d.sessionId,f=dp(a.b,e);f&&(f.j=!0);f=function(){Zm(a,e,c)};a.g.sendRequest(d,b,Nl,c.timeoutMillis,c.clientId).then(f,f)},Zo=function(a,c,b,d){var e=c.message,f=e.type;f in en&&(e.type=en[f]);a.g.sendRequest(e,b,Pl,c.timeoutMillis,c.clientId,d.transportId).then(function(g){ep(a,d,g);eo(a.f,
c.clientId,new Yn("v2_message",g,c.sequenceNumber))},function(g){cp(a,c,g)})},$o=function(a,c,b){var d=c.message;delete d.sessionId;a.g.sendRequest(d,b,Nl,c.timeoutMillis,c.clientId).then(function(){eo(a.f,c.clientId,new Yn("v2_message",null,c.sequenceNumber))},function(e){cp(a,c,e)})};
Ro.prototype.o=function(a){var c=this,b=a.message,d=b.sessionId;if(d){var e=Xo(this.b,d);e?(e=this.w.ra(e))?(d=Wo(this.b,d),Sb(d.namespaces,function(f){return f.name==b.namespaceName})?tn(this.m,e,b.namespaceName,b.message,a.clientId,d.transportId).then(function(){eo(c.f,a.clientId,new Yn("app_message",null,a.sequenceNumber))},function(){bp(c,a,chrome.cast.nd.CHANNEL_ERROR,"Channel to receiver not available")}):bp(this,a,chrome.cast.nd.INVALID_PARAMETER,"Invalid namespace")):ap.G("No receiver from sinkId"):
ap.G("No sinkId from sessionId")}else ap.G("No sessionId")};
Ro.prototype.s=function(a){var c=this;ap.info("Leave session");var b=dp(this.b,a.message);if(b){var d=a.clientId,e=$n(this.j,d);if(e){var f=[],g=[],k=e.tabId,m=e.origin,p=e.autoJoinPolicy;b.f.forEach(function(v){var A=$n(c.j,v);p==chrome.cast.jd.TAB_AND_ORIGIN_SCOPED&&k==A.tabId&&m==A.origin||p==chrome.cast.jd.ORIGIN_SCOPED&&m==A.origin?(A.f=!0,f.push(v)):g.push(v)});eo(this.f,d,new Yn("leave_session",null,a.sequenceNumber));f.forEach(function(v){(v=$n(c.j,v))&&fp(c.h,v.routeId,!0,!0)});b.f=g}else ap.G("No client record")}else ap.G("No session")};
var gp=function(a,c,b){Wn(c)&&a.g.sendRequest(new fn,b,Pl,void 0,void 0,c.transportId).catch(Qa)},Sm=function(a,c,b){var d=c.getId();ap.info("Query status for "+d);Qo(a.C,c).then(function(e){hp(a,d,e);b&&(e=ip(a.b,d))&&gp(a,e,c)},Qa)},jp=function(a,c){if("*"==c.destinationId)return!0;c=c.destinationId;if(c==a.m.w||null!=$n(a.j,c))return!0;ap.info("Invalid destination "+c);return!1},np=function(a,c,b){ob(ap,function(){return"Cast message: "+JSON.stringify(b)});if(jp(a,b))if(b.namespace_==Ol||b.namespace_==
Ql)(c=Ym(a.b,c))&&c.b.forEach(function(f){var g=a.h,k=g.f.get(f);k&&k.Cf&&g.g.Rh(f,b)});else{var d=JSON.parse(b.data),e=kp(a,d);e=e?e.sourceId:void 0;switch(d.type){case "RECEIVER_STATUS":hp(a,c,d);break;case "MEDIA_STATUS":lp(a,c,b,e)}}else mp(a.m,c,b.destinationId,b.sourceId,!1)},kp=function(a,c){a=kn(a.g.b,c.requestId);if(!a)return null;var b=a.ub;switch(c.type){case "LAUNCH_ERROR":case "INVALID_REQUEST":case "LOAD_CANCELLED":case "LOAD_FAILED":case "INVALID_PLAYER_STATE":delete c.requestId;b.reject(new chrome.cast.Error(chrome.cast.nd.SESSION_ERROR,
c.reason||c.type,c));break;default:b.resolve(c)}return a},op=function(a,c,b){ob(ap,function(){return"App message: "+JSON.stringify(b)});if(c=ip(a.b,c)){var d;"*"==b.destinationId?d=So(a.b,c.sessionId):d=[b.destinationId];var e=new On(c.sessionId,b.namespace_,b.data);d.forEach(function(f){eo(a.f,f,new Yn("app_message",e))})}else ap.G("No session for incoming app message")},pp=function(a,c){a.forEach(function(b){b.sessionId=c;var d=b.supportedMediaCommands,e=[];d&1&&e.push(chrome.cast.media.ve.PAUSE);
d&2&&e.push(chrome.cast.media.ve.SEEK);d&4&&e.push(chrome.cast.media.ve.STREAM_VOLUME);d&8&&e.push(chrome.cast.media.ve.STREAM_MUTE);b.supportedMediaCommands=e});return a},ep=function(a,c,b){c=c.sessionId;b.sessionId=c;b=pp(b.status,c);qp(a.b,c,b);(a=dp(a.b,c))&&a.controller&&(a=a.controller,a.o=new Date,(b=Ho(a))?Io(a,b):(a.j&&(a.b.title=""),a.b.can_play_pause=!1,a.b.can_seek=!1),Bo(a))},rp=function(a,c){if(c=ip(a.b,c)){c=c.sessionId;var b=dp(a.b,c);b&&b.j||Zm(a,c)}},Zm=function(a,c,b){b&&To(a,b.clientId,
b);(b=dp(a.b,c))&&b.b.slice().forEach(function(d){fp(a.h,d,!0)});sp(a.b,c);tp(a.h)},hp=function(a,c,b){ob(ap,"Receiver status for "+c);var d=b.status;if(d)if(b=a.w.ra(c)){d=Sn(b,d);var e=Ym(a.b,c);e?d?d.sessionId==e.session.sessionId?(c=e.session,Un(c,d)&&(ob(ap,"Updating session "+d.sessionId),e.g&&(c.statusText=d.statusText),c.namespaces=d.namespaces,c.receiver.volume=d.receiver.volume,up(a.h,e),Uo(a,c.sessionId,new Yn("update_session",c)),e.controller&&Fo(e.controller))):(rp(a,c),xo(1),vp(a.h,
null,b,null,d)):(rp(a,c),xo(1)):d&&vp(a.h,null,b,null,d)}else Bb("MediaRouter.Cast.Error.Sink.Missing.From.Discovery.Service"),ap.G("Got message from receiver "+c+", but sink is no longer available.")},lp=function(a,c,b,d){if(c=ip(a.b,c))if(b=JSON.parse(b.data))ep(a,c,b),Uo(a,b.sessionId,new Yn("v2_message",b),d)},wp=function(a,c){var b=Tn(c.b);return(c=Sb(a.j,function(d){return Qb(d.capabilities,function(e){return Ub(b,e)})}))?c.appId:mo(a)[0]},xp=function(a,c,b){var d=ro(c);if(!d)return Promise.reject(Error("Invalid source "+
c));var e=wp(d,b),f=new sb("MediaRouter.Cast.Session.Launch");return Oo(a.F,new chrome.cast.Pk(e,void 0,null==d.h?chrome.cast.timeout.requestSession:d.h),b).then(function(g){ap.info("Launched session "+g.sessionId+" for appId "+e);f.end("Success");return g},function(g){ap.error("Failed to session for appId "+e);f.end("Failure");throw g;})};
Ro.prototype.createMediaRouteController=function(a,c,b){a=yp(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=zp(this,d.sessionId);if(!e)return Error("Sink not found for the route");a.controller=new Go(c,b,d,this,a.g);gp(this,d,e);return null};
var Ko=function(a,c,b){var d=zp(a,c.sessionId);d&&a.g.sendRequest(b,d,Pl,0,"",c.transportId).catch(function(e){ap.G("Failed to send a media control request: "+e)})},Mo=function(a,c,b){b=new Pn(b);(c=zp(a,c.sessionId))&&a.g.sendRequest(b,c,Nl).catch(function(d){ap.G("Failed to send a volume control request: "+d)})},zp=function(a,c){return(c=Xo(a.b,c))?a.w.ra(c):null},ap=hb("mr.cast.ApiHandler");var Ap=function(a){return"0F5096E8"==a||"85CDB22F"==a};var Bp=function(a,c,b,d,e){for(var f=[],g=4;g<arguments.length;++g)f[g-4]=arguments[g];var k=this;this.j=a;this.w=c;this.Ej=b;this.f=d;this.h=f;this.b=!1;this.g=function(m){for(var p=[],v=0;v<arguments.length;++v)p[v-0]=arguments[v];return k.bq.apply(k,n(p))}};h=Bp.prototype;h.addListener=function(){this.b||(this.b=!0,this.f.addListener.apply(this.f,[this.g].concat(n(this.h))))};h.removeListener=function(){this.b&&(this.f.removeListener(this.g),this.b=!1)};
h.hh=function(a){for(var c=0;c<arguments.length;++c);return!0};h.bq=function(a){for(var c=[],b=0;b<arguments.length;++b)c[b-0]=arguments[b];var d=this;$i(this.j);if(!this.hh.apply(this,n(c)))return!1;Ri(this.Ej).then(function(e){return e.handleEvent.apply(e,[d.f].concat(n(c)))});return this.Ai()};h.Ea=function(){return"mr.EventListener."+this.w};h.jb=function(){return[this.b]};h.ib=function(){Yl(this)&&this.addListener()};h.Ai=function(){};var Cp=null,Dp=null,Ep=function(){Cp||(Cp=new Bp(2,"CastChannelMessageListener","mr.cast.ChannelService",chrome.cast.channel.onMessage));Dp||(Dp=new Bp(1,"CastChannelErrorListener","mr.cast.ChannelService",chrome.cast.channel.onError));return[Cp,Dp]};var Fp=function(){},Gp=function(a){if(!a.startsWith("urn:x-org.chromium:media:route:"))return null;var c=a.substring(31);if(!c)return null;var b=c.match(/([^/]*)\/([^-/]*)-([^/]*)\/(.*)/);if(!b)return null;c=new Fp;c.f=a;a=l(b);a.next();c.b=a.next().value;c.h=a.next().value;c.j=a.next().value;c.g=a.next().value;return c};var Hp=function(a,c,b,d,e,f){this.id=a;this.presentationId=c;this.sinkId=b;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.Cf=e;this.isOffscreenPresentation=!1},Ip=function(a,c,b,d,e,f){c=d&&dj(d)?a:"urn:x-org.chromium:media:route:"+a+"/"+c+"-"+b+"/"+d;return new Hp(c,
a,b,d,e,f)};var Jp=function(a,c,b,d){b=Ip(b,"cast",c.getId(),a,d,"");b.supportsMediaRouteController=!0;mojo&&mojo.RouteControllerType&&(b.controllerType=d&&aj(a)&&c.b&1&&mojo.RouteControllerType.kMirroring?mojo.RouteControllerType.kMirroring:mojo.RouteControllerType.kGeneric);return b},Kp=function(a,c){var b=c.mb.qc;b&&(c.description=oj(b),a.displayName="",a.statusText="mirror_desktop"==b.f?"":b.g||"")};var Lp=function(a,c,b,d){return{namespace_:a,data:Ja(c)?c:JSON.stringify(c),sourceId:b,destinationId:d}};var Mp=function(a){this.type="CLOSE";this.reasonCode=a};var Np=function(a){return(a=a.exec(Xd))?a[1]:""},Op=function(){if(Ye)return Np(/Firefox\/([0-9.]+)/);if(Be||Ce||Ae)return Ue;if(bf)return ue()||$d("iPad")||$d("iPod")?Np(/CriOS\/([0-9.]+)/):Np(/Chrome\/([0-9.]+)/);if(cf&&!(ue()||$d("iPad")||$d("iPod")))return Np(/Version\/([0-9.]+)/);if(Ze||$e){var a=/Version\/(\S+).*Mobile\/(\S+)/.exec(Xd);if(a)return a[1]+"."+a[2]}else if(af)return(a=Np(/Android\s+([0-9.]+)/))?a:Np(/Version\/([0-9.]+)/);return""}(),Pp=function(a){return 0<=wd(Op,a)};var Rp=function(a){this.type="CONNECT";this.origin={};this.userAgent=Xd;var c=this.userAgent.indexOf("(")+1;c=this.userAgent.substr(c,this.userAgent.indexOf(")",c)-1-c+1);this.senderInfo={sdkType:2,version:chrome.runtime.getManifest().version,browserVersion:Op,platform:Qp(),systemVersion:c,connectionType:1};this.connType=a?0:2},Qp=function(){switch(xi()){case "ChromeOS":return 5;case "Windows":return 3;case "Mac":return 4;case "Linux":return 6}return 0};var Sp=function(a){if(!chrome.runtime.lastError)return null;var c="chrome.cast.channel.send failed, chrome.runtime.lastError: "+(chrome.runtime.lastError.message||"Unknown error");a&&ob(a,c);return Error(c)};var Tp=function(){this.b=new Jm};Tp.prototype.init=function(){am(this)};var Up=function(a,c,b,d,e){if(!Mm(a.b,[c.channelId,b,d].join("#"))){var f=Lp(Ml,new Rp(e),b,d);chrome.cast.channel.send(c,f,a.f.bind(a));a.b.set([c.channelId,b,d].join("#"),e)}};Tp.prototype.f=function(){Sp(Vp)};
var Vm=function(a,c){a.b.wb().forEach(function(b){b.split("#")[0]==c.channelId.toString()&&a.b.remove(b)})},Rm=function(a,c,b){a.b.forEach(function(d,e){var f=e.split("#");f[0]==c.channelId.toString()&&(Up(a,b,f[1],f[2],d),a.b.remove(e))})};Tp.prototype.Ea=function(){return"cast.VirtualConnectionManager"};Tp.prototype.jb=function(){var a=Om(this.b);return[new Wp(a)]};Tp.prototype.ib=function(){var a=Yl(this);if(a)for(var c in a.b)this.b.set(c,a.b[c])};Ra(Tp);
var Vp=hb("mr.cast.VirtualConnectionManager"),Wp=function(a){this.b=a};var Xp=function(a,c){this.j=c;this.w=a;this.f=new Jm;this.b=new Jm;this.g=Tp.Ja();this.ra=null;this.h=new Jm};q(Xp,Ni);Xp.prototype.handleEvent=function(a,c){for(var b=[],d=1;d<arguments.length;++d)b[d-1]=arguments[d];a==chrome.cast.channel.onMessage?this.o.apply(this,n(b)):a==chrome.cast.channel.onError&&this.m.apply(this,n(b))};Xp.prototype.init=function(){this.g.init();am(this);Xi("mr.cast.ChannelService",this);Ep().forEach(function(a){return a.addListener()})};
var tn=function(a,c,b,d,e,f){e=e||a.w;f=f||"receiver-0";var g=an(a,c);return g?Yp(a,g,b,d,e,f):Promise.reject("Channel not found for "+c.getId())},mp=function(a,c,b,d,e){if(c=a.f.get(c))a=a.g,Mm(a.b,[c.channelId,b,d].join("#"))&&(a.b.remove([c.channelId,b,d].join("#")),b=Lp(Ml,new Mp(e?5:0),b,d),chrome.cast.channel.send(c,b,a.f.bind(a)))};
Xp.prototype.o=function(a,c){var b=this.b.get(a.channelId);if(b){var d=this.ra(b);if(d){if(Sl.hasOwnProperty(c.namespace_)){var e=JSON.parse(c.data);switch(e.type){case "CLOSE":this.g.b.remove([a.channelId,c.destinationId,c.sourceId].join("#"));return;case "RPC":break;default:ob(Qm,function(){return"Got message "+(e.type||e.responseType)+" "+("from "+d.getId())})}}else ob(Qm,"Got message in "+c.namespace_+" from "+d.getId());Zp(this.j,d,c)}else Qm.G("Got message for unknown receiver (receiverId="+
b+").")}else Qm.G("Got message for unknown channel (channelId="+a.channelId+").")};var $p=function(a,c){var b=a.b.get(c.channelId);b&&(a.b.remove(c.channelId),a.f.remove(b))};Xp.prototype.m=function(a,c){Qm.G(function(){return"Channel error: "+JSON.stringify(a)+(c?", "+JSON.stringify(c):"")});$p(this,a)};
var an=function(a,c){c=c.getId();(a=a.f.get(c))||Qm.info("Channel not found for receiver: "+c);return a},Yp=function(a,c,b,d,e,f){Up(a.g,c,e,f,0==f.indexOf("receiver-0"));Vn(d);var g=Lp(b,d,e,f);"object"===typeof d&&"RPC"==d.type||ob(Qm,function(){return"Channel is sending message: "+JSON.stringify(g)});return new Promise(function(k,m){chrome.cast.channel.send(c,g,function(p){p?p.errorState?(m(Error("Failed to send message")),$p(a,p)):k(!0):(p=Sp(Qm||void 0),m(p))})})};Xp.prototype.Ea=function(){return"cast.ChannelService"};
Xp.prototype.jb=function(){return[new aq(Om(this.f),Om(this.b),Om(this.h))]};Xp.prototype.ib=function(){var a=Yl(this);a&&(Im(this.f,a.f),Im(this.b,a.b),Im(this.h,a.g))};var Qm=hb("mr.cast.ChannelService"),aq=function(a,c,b){this.f=a;this.b=c;this.g=b};var bq=function(a,c,b,d,e,f){this.routeId=a;this.clientId=c;this.appIds=b;this.autoJoinPolicy=d;this.origin=e;this.tabId=f;this.f=this.b=!1},cq=function(){this.b=[]};cq.prototype.init=function(){am(this)};cq.prototype.sa=function(){return this.b.length};var $n=function(a,c){return Sb(a.b,function(b){return b.clientId==c})},dq=function(a,c){return Sb(a.b,function(b){return b.routeId==c})},eq=function(a,c){a.b=Mb(a.b,function(b){return b.clientId!=c})};cq.prototype.Ea=function(){return"cast.ClientRecords"};
cq.prototype.jb=function(){return[new fq(this.b)]};cq.prototype.ib=function(){var a=Yl(this);a&&(this.b=a.b)};var fq=function(a){this.b=a};var gq=function(){this.requestId=0;this.type="GET_APP_AVAILABILITY";this.appId=[]};var hq=function(a,c){this.h=a;this.f=c;this.g=new Fn;this.b=new Jm};hq.prototype.init=function(){am(this)};var iq=function(a,c){var b=a.b.get(c);b&&(b.Uj--,0<b.Uj||(Fm(a.f.b.Jb(!1),function(d){switch(Bm(d,c)){case "available":d.ec[c]="available_rescan";break;case "unavailable":d.ec[c]="unavailable_rescan"}}),a.b.remove(c)))};h=hq.prototype;
h.tm=function(a){var c=this;Fm(this.b.Jb(!0),function(b){a:{switch(Bm(a,b)){case "unknown":case "available_rescan":case "unavailable_rescan":var d=!0;break a}d=!1}if(d){var e=a.getId()+":"+b;c.g.contains(e)||(c.g.add(e),d=function(){c.g.remove(e)},(new ef(c.Rp.bind(c,a,b),5500,3)).start().then(c.zn.bind(c,a,b),function(){c.l.error("Failed to get app availability response for "+a.getId()+", appId "+b+" after 3 attempts.");c.zn(a,b,"unknown")}).then(d,d))}})};
h.zn=function(a,c,b){b!=Bm(a,c)&&(this.l.info(c+" on "+a.getId()+" is "+b),a.ec[c]=b,Tm(this.f.h,a))};
h.Rp=function(a,c){var b=this,d=new gq;d.appId=[c];var e=new sb("MediaRouter.Cast.App.Availability");return this.h.sendRequest(d,a,Nl,5E3).then(function(f){e.end("Success");ob(b.l,function(){return"App availability response "+JSON.stringify(f)});for(var g in f.availability){if("APP_AVAILABLE"==f.availability[g])return"available";if("APP_UNAVAILABLE"==f.availability[g])return"unavailable"}return"unknown"},function(f){e.end("Failure");b.l.error("checkAppAvailability_ failed for "+a.getId()+", appId "+
c);throw f;})};h.Ea=function(){return"cast.AppDiscoveryService"};h.jb=function(){return[new jq(Om(this.b))]};h.ib=function(){var a=Yl(this);a&&Im(this.b,a.b)};h.l=hb("mr.cast.AppDiscoveryService");var jq=function(a){this.b=a};var kq=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 lq=function(a,c){this.f=[];this.b=[];this.sinkId=a;this.session=c;this.w=this.h=null;this.offTheRecord=this.j=!1;this.controller=null;this.g=!0},mq=function(){this.l=hb("mr.cast.SessionRecords");this.b=[]};mq.prototype.init=function(){am(this)};
var sp=function(a,c){a.l.info("Removing session "+c);Jo(a,c);a.b=Mb(a.b,function(b){return b.session.sessionId!=c})},So=function(a,c){return(a=dp(a,c))?a.f:[]},ip=function(a,c){return(a=Ym(a,c))?a.session:null},nq=function(a,c){return Sb(a.b,function(b){return Ub(b.f,c)})},yp=function(a,c){return Sb(a.b,function(b){return Ub(b.b,c)})},oq=function(a,c){return Sb(a.b,function(b){return null!=Sb(b.b,function(d){return Gp(d).b==c})})},Ym=function(a,c){return Sb(a.b,function(b){return b.sinkId==c||b.h==
c})},dp=function(a,c){return Sb(a.b,function(b){return b.session.sessionId==c})},Xo=function(a,c){return(a=dp(a,c))?a.sinkId:null},Wo=function(a,c){return(a=dp(a,c))?a.session:null},qp=function(a,c,b){var d=Wo(a,c);d&&(a=Mb(b,function(e){return e.playerState!=chrome.cast.media.PlayerState.IDLE}),a.forEach(function(e){if(!e.media){var f=Sb(d.media,function(g){return g.mediaSessionId==e.mediaSessionId});f&&(e.media=f.media)}}),d.media=a)};mq.prototype.Ea=function(){return"cast.SessionRecords"};
mq.prototype.jb=function(){return[new pq(this.b)]};mq.prototype.ib=function(){var a=Yl(this);if(a)for(var c=0;c<a.b.length;c++){var b=a.b[c],d=new lq(b.sinkId,b.session);d.f=b.f;d.b=b.b;d.j=b.j;d.w=b.w;d.h=b.h;d.g=b.g;this.b.push(d)}};
var Jo=function(a,c){(a=dp(a,c))&&a.controller&&(a.controller.Za(),a.controller=null)},pq=function(a){var c=[];a=l(a);for(var b=a.next();!b.done;b=a.next()){b=b.value;var d=new lq(b.sinkId,b.session);d.f=b.f;d.b=b.b;d.j=b.j;d.w=b.w;d.h=b.h;d.offTheRecord=b.offTheRecord;d.g=b.g;c.push(d)}this.b=c};var qq=function(a,c,b){var d=Error.call(this);this.message=d.message;"stack"in d&&(this.stack=d.stack);this.name="RouteRequestError";this.message=c||"";if(b)this.stack=b;else if(Error.captureStackTrace)Error.captureStackTrace(this,qq);else if(c=Error().stack)this.stack=c;this.errorCode=a};q(qq,Error);var rq=function(a,c){this.sinks=a;this.origins=c||null},sq=new rq([]);var tq=function(a){this.D="sender-"+se();this.f=new Jm;this.o=null;am(this);this.g=a;this.m=new cq;this.h=new mq;this.s=new Xp(this.D,this);this.b=new Pm(this.s,this);this.C=new qn(this.s,this.D);this.w=null;this.j=new Ro(this.C,this.b,this.m,this.h,this.s,this);this.F=new Jn(this.b,this.C)};h=tq.prototype;h.getName=function(){return"cast"};
h.initialize=function(a){a=a&&"boolean"===typeof a.enable_cast_sink_query?a.enable_cast_sink_query:!0;this.l.info("Query enabled: "+a);this.C.init();this.h.init();this.j.init();this.s.init();this.b.init();a&&(this.w=new hq(this.C,this.b),this.w.init())};h.Bd=function(){return this.f.na()};
h.Bg=function(a){var c=this;if(null!=uq(a))return new rq([]);var b=new Fn;vq(a).forEach(function(d){cn(c.b,d).map(function(e){return e.f}).forEach(function(e){b.add(e)})});return new rq(b.na(),-1!=a.indexOf("0F5096E8")?ej:null)};
h.startObservingMediaSinks=function(a){var c=this,b=uq(a);b?(this.l.info("Received broadcast request "+a),Fm(this.b.b.Jb(!1),function(d){c.C.sendMessage(b,d,Rl).catch(function(e){c.l.error("Broadcast failed "+e.message)})})):this.w&&vq(a).forEach(function(d){var e=c.w,f=e.b.get(d);f?f.Uj++:e.b.set(d,{Uj:1});e.l.info("Scanning sinks for app availability");Fm(e.f.b.Jb(!1),e.tm,e)})};h.stopObservingMediaSinks=function(a){var c=this;null!=uq(a)||this.w&&vq(a).forEach(function(b){iq(c.w,b)})};
h.startObservingMediaRoutes=function(){};h.stopObservingMediaRoutes=function(){};h.ra=function(a){return(a=this.b.ra(a))?a.f:null};
var wq=function(a,c,b){a.l.error("Error launching.",b);fp(a,c.id,!1,!0,"error");b=new ii(kq,"warning");mi(b,c.id);ni(b,c.sinkId);a.g.Ze(b)},zq=function(a,c,b,d,e,f,g,k){um().f=new rm(b.zc,b.Sb());var m=Jp(c,b,d,!0);m.forDisplay=!1;m.offTheRecord=e;a.f.set(m.id,m);a.g.Uf(a,m);tp(a);(e=ro(c))&&e.b&&xq(a,e,m.id,g,k);return new Promise(function(p,v){cj(c)||dj(c)?(m.mb={tabId:k,sessionId:"",ag:b.Sb()||"",ke:b.zc||"",jt:b.f.friendlyName||""},dj(c)&&(m.isOffscreenPresentation=!0),a.g.rj(a,m,d,function(A){return si(yq(a,
c,b,d,f,g,k,A))}).b.then(function(){var A=yp(a.h,m.id);A.g=!1;Kp(A.session,m);A.controller&&(A.controller.j=!1,Fo(A.controller));p(m)},function(A){wq(a,m,A);v(A)})):yq(a,c,b,d,f,g,k,m).then(function(){p(m)},function(A){wq(a,m,A);v(A)})})},yq=function(a,c,b,d,e,f,g,k){return xp(a.j,Aq(c,b,e),b).then(function(m){vp(a,c,b,d,m,f,g,k);return k})};
tq.prototype.createRoute=function(a,c,b,d,e,f,g){var k=this,m=this.b.ra(c);if(!m)return ri(Error("No sink with ID "+c));var p=so(a);if(p){setTimeout(function(){Vo(k.j,p,m,chrome.cast.ig.CAST)},0);var v=function(){return zq(k,a,m,b,d,e,f,g)},A=$n(this.m,p);if(A)return si(this.terminateRoute(A.routeId).then(v,v));if(f&&g&&(c=Bq(this,a,f,g,d,e,c)))return c}return si(zq(this,a,m,b,d,e,f,g))};
var fp=function(a,c,b,d,e){d=void 0===d?!1:d;e=void 0===e?"closed":e;a.l.info("Remove route "+c);var f=dq(a.m,c);if(f){b=b||f.f;var g=f.clientId;a.l.info("Remove client "+g);for(var k=a.h,m=0;m<k.b.length;m++)ac(k.b[m].f,g);eq(a.m,g)}if(g=yp(a.h,c))ac(g.b,c),Cq(a,g.b);if(k=a.f.get(c))if(k.Cf&&g&&(mp(a.s,k.sinkId,f?f.clientId:a.D,g.session.transportId,b),k.forDisplay&&f&&(a.o={Af:f,hn:g})),a.f.remove(c),a.g.Ig(k),tp(a),d)a.g.onPresentationConnectionClosed(c,e,"Remove route");else a.g.onPresentationConnectionStateChanged(c,
"terminated")},up=function(a,c){c.b.forEach(function(b){if(b=a.f.get(b)){var d=c.session;if(b.forDisplay){var e=Ap(d.appId);e&&!b.isLocal?(b.description=d.statusText||"",d.displayName="",d.statusText=""):e||(b.description=d.statusText||d.displayName);c.controller&&Fo(c.controller)}a.g.Ye(b)}})},Dq=function(a,c){Pb(c,function(b){b=a.f.get(b,null);if(!b||!b.mediaSource)return!1;var d=ro(b.mediaSource);d=d?d.o:!1;return b.isLocal&&!d})&&y(c,function(b){if(b=a.f.get(b,null))b.isLocal=!0})},Cq=function(a,
c){var b=[],d=[],e=null;c.forEach(function(f){if(f=a.f.get(f)){f.forDisplay=!1;var g=ro(f.mediaSource);g&&Sb(mo(g),Xn)||(f.Cf?(g=g?no(g):null,e||g==chrome.cast.jd.CUSTOM_CONTROLLER_SCOPED||(b.push(f),e=f.sinkId)):e&&e!=f.sinkId?b.push(f):d.push(f))}});y(0<b.length?b:d,function(f){f.forDisplay=!0})},xq=function(a,c,b,d,e){var f=c.b;if(f&&!$n(a.m,f)){a.l.info("Add client "+f);var g=mo(c);a.m.b.push(new bq(b,f,g,no(c),d||null,Ia(e)?e:null))}},vp=function(a,c,b,d,e,f,g,k){var m=Ym(a.h,b.getId());if(!m){var p=
a.h;m=b.getId();p.l.info("Adding new session: "+m+", "+e.sessionId);var v=dp(p,e.sessionId);v?(Rn(e)?(v.w=e,v.h=m):Rn(v.session)&&(v.w=v.session,v.h=v.sinkId,v.session=e,v.sinkId=m),m=v):(m=new lq(m,e),p.b.push(m))}k&&k.isLocal&&k.mb&&(m.g=!1);var A=null!=c;if(!A&&Xn(e.appId))return null;null==c?(v=new io([{appId:e.appId,capabilities:e.capabilities}]),c=oo(v)[0]):v=ro(c);if(p=k){if(!a.f.get(p.id))return a.l.G("Route "+p.id+" not added"),p}else p=Jp(c,b,d||e.sessionId,A),a.f.set(p.id,p);d=p.id;a.l.info("Add route "+
d);c=null;v&&(c=v.b,xq(a,v,d,f,g));Ub(m.b,d)||m.b.push(d);p.Cf&&(f=a.s,g=c||a.D,d=e.transportId,v=!(v&&v.o),(A=an(f,b))&&Up(f.g,A,g,d,v));m.offTheRecord=p.offTheRecord;f=m.b;Dq(a,f);Cq(a,f);f=p;g=e.sessionId;Ap(e.appId)?f.isLocal&&g&&f.mb?f.mb.sessionId=g:(f.description=e.statusText||"",e.displayName="",e.statusText=""):f.description=e.statusText||e.displayName;k?a.g.Ye(p):a.g.Uf(a,p);tp(a);if(k=c)Ub(m.f,c)?k=!1:(m.f.push(c),k=!0);k&&(a=a.j,eo(a.f,c,new Yn("new_session",e)),gp(a,e,b));return p};
tq.prototype.terminateRoute=function(a){var c=this,b=this.f.get(a);if(!b)return Promise.reject(new qq(3,"Route in Cast provider not found for routeId  "+a));var d=yp(this.h,a);if(!d)return fp(this,a,!0),Promise.resolve();var e=d.session.sessionId,f=this.b.ra(b.sinkId);if(!f)return Zm(this.j,e),Promise.resolve();(a=dq(this.m,a))&&Vo(this.j,a.clientId,f,chrome.cast.ig.STOP);xo(0);return new Promise(function(g){var k=function(){rp(c.j,f.getId());g()};c.C.sendRequest(new nn(e),f,Nl).then(k,k)})};
var Eq=function(a,c){var b=null;Gm(a.f.Jb(!1),function(f){if(!f.Cf)return!1;var g=a.b.ra(f.sinkId);if(!g||!qo(c,Aq(f.mediaSource,g)))return!1;b=f;return!0});if(!b||!b.mediaSource)return null;var d=so(b.mediaSource);if(!d)return null;var e=$n(a.m,d);return e?(d=nq(a.h,d))?{Af:e,hn:d}:null:null},Bq=function(a,c,b,d,e,f,g){var k=null;Gm(a.f.Jb(!1),function(p){var v=p.mb;return v&&null!=v.tabId&&v.tabId==d&&aj(p.mediaSource)?(k=p,!0):!1});if(!k)return null;var m=function(){return a.createRoute(c,g||k.sinkId,
"",e,f,b,null==d?void 0:d)};return si(a.terminateRoute(k.id).then(m,m))};h=tq.prototype;h.connectRouteByRouteId=function(a,c,b,d,e){if(!ro(a))return ri(Error("Unsupported presentation URL"));if(!c)return ri(Error("No routeId"));c=Gp(c);c=dp(this.h,c.b);if(!c)return ri(Error("No matching route"));var f=this.b.ra(c.sinkId);return f?(a=vp(this,a,f,b,c.session,d,e))?qi(a):ri(Error("Failed to create route")):ri(Error("No sink"))};
h.joinRoute=function(a,c,b,d,e,f){var g=ro(a);if(!g)return ri(Error("Unsupported presentation URL"));if(c==chrome.cast.rk){a:{var k=Eq(this,g);if(!k){if(!this.o||this.o.Af.origin!=e||this.o.Af.tabId!=f){k=null;break a}k=this.o}switch(no(g)){case chrome.cast.jd.PAGE_SCOPED:k=null;break a;case chrome.cast.jd.ORIGIN_SCOPED:if(e!=k.Af.origin){k=null;break a}break;case chrome.cast.jd.TAB_AND_ORIGIN_SCOPED:if(e!=k.Af.origin||f!=k.Af.tabId){k=null;break a}}k=dp(this.h,k.hn.session.sessionId)}if(!k&&(g.g?
g.g:chrome.cast.nh.CREATE_SESSION)!=chrome.cast.nh.CAST_THIS_TAB&&(d=Bq(this,a,e,f,b,d)))return d}else k=Fq(this,c);if(!k)return ri(Error("No matching route"));if(k.offTheRecord!=b)return ri(Error("Off the record mismatch"));d=this.b.ra(k.sinkId);if(!d)return ri(Error("No sink"));a=vp(this,a,d,c,k.session,e,f);a.offTheRecord=b;return qi(a)};h.detachRoute=function(a){fp(this,a,!1,!0)};
h.Gf=function(a){var c=this.b.ra(a);if(!c)throw Error("Cannot mirror with no sink.");var b=new vj;c=c.b;c&1||(b.shouldCaptureVideo=!1);c&4||(b.shouldCaptureAudio=!1);b.shouldCaptureAudio&&!b.shouldCaptureVideo&&(b.minLatencyMillis=b.maxLatencyMillis,b.animatedLatencyMillis=b.maxLatencyMillis);b.senderSideLetterboxing=!0;wj(b);Object.freeze(b);this.l.info(function(){return"Settings for "+a+": "+uj(b)});if(!b.shouldCaptureAudio&&!b.shouldCaptureVideo)throw Error("Cannot start mirroring without video or audio capture");
return b};h.Ve=function(){return"cast_streaming"};h.Sh=function(a){var c=this.f.get(a);c&&c.mb&&c.mb.qc&&(a=yp(this.h,a))&&(Kp(a.session,c),a.controller&&Fo(a.controller))};
h.sendRouteMessage=function(a,c,b){var d=this;if(!b)return new Promise(function(k,m){"string"!==typeof c&&m(Error("Cannot send non-string messages via ApiHandler."));m=d.j.f;ob(bo,"Received: "+c);var p=JSON.parse(c),v=p.clientId;"client_connect"==p.type?(ob(bo,"App "+v),(p=$n(m.b,v))?(p.b=!0,(m=kn(m.f,p.routeId))&&m.ub.resolve(!0)):bo.G("Client not found "+v)):ao(m,v)?(m=m.g[p.type])&&m(p):bo.G("No route for "+v);k()});var e=yp(this.h,a);if(!e)return Promise.reject(Error("Not managing the route "+
a));var f=this.b.ra(e.sinkId);if(!f)return Promise.reject(Error("Sink no longer accessible"));var g=(a=dq(this.m,a))?a.clientId:this.D;return new Promise(function(k){tn(d.s,f,b.namespace,c,g,e.session.transportId).then(k,k)})};h.sendRouteBinaryMessage=function(a){return Promise.reject(Error("Route "+a+" does not support sending binary data."))};h.ug=function(a,c){var b=this.b.ra(c);if(!b)return!1;if(!this.w)return!0;a=Aq(a,b);return(a=po(a))&&0!=a.length?Pb(a,function(d){return Tl(Bm(b,d))}):!1};
h.zf=function(a,c,b){var d=vq(a);return d&&0!=d.length?c==chrome.cast.rk?!0:b&&b.mediaSource?(a=po(b.mediaSource),Pb(a,function(e){return Ub(d,e)})):void 0==c||Fq(this,c)?!0:!1:!1};
var Aq=function(a,c,b){return ro(a)?a:cj(a)||dj(a)?(a={appId:0==(c.b&1)?"85CDB22F":"0F5096E8",capabilities:Tn(c.b)},oo(new io([a],void 0,void 0,void 0,b))[0]):a},vq=function(a){var c=[],b=ro(a);if(b)c=mo(b);else if(cj(a)||dj(a))bj(a)||c.push("85CDB22F"),c.push("0F5096E8");return c},uq=function(a){var c=ro(a);if(!c)return null;a=vq(a);var b=c.m||"";c=c.w;return b&&c?new ln(a,b,JSON.stringify(c)):null},Fq=function(a,c){return 0==c.indexOf(chrome.cast.Lk)?dp(a.h,c.substr(chrome.cast.Lk.length)):oq(a.h,
c)},Zp=function(a,c,b){var d=a.F;if(Kn(d)&&Sl.hasOwnProperty(b.namespace_)){var e=c.Sb();if(e){var f=JSON.parse(b.data);if("RECEIVER_STATUS"===f.type){var g=f.status&&f.status.applications&&f.status.applications[0],k=f=null;g&&(g.appId&&(f=g.appId),g.sessionId&&(k=g.sessionId));g=d.f.get(e);d.f.set(e,new Jl(e,f,k));g&&g.appId===f||Ln(d)}}}a=a.j;c=c.getId();Sl.hasOwnProperty(b.namespace_)?np(a,c,b):op(a,c,b)},Tm=function(a,c){a.w&&a.w.tm(c);$m(a.F);a.g.dd()};h=tq.prototype;h.Ea=function(){return"cast.Provider"};
h.jb=function(){return[new Gq(this.D,Om(this.f),this.o)]};h.ib=function(){var a=Yl(this);a&&(this.D=a.g,Im(this.f,a.f),this.o=a.b)};h.searchSinks=function(){return eb()};h.createMediaRouteController=function(a,c,b){return(a=this.j.createMediaRouteController(a,c,b))?Promise.reject(a):Promise.resolve()};h.provideSinks=function(a){Xm(this.b,a)};var tp=function(a){var c=a.Bd().some(function(b){return b.isLocal});a.g.Wf(a.Ea(),c)};tq.prototype.l=hb("mr.CastProvider");
var Gq=function(a,c,b){this.g=a;this.f=c;this.b=b};var Hq=function(){this.b=[]};Hq.prototype.listen=function(a,c,b){this.b.push({type:a,Sc:c,target:b})};var Iq=function(a,c,b){var d=a.b.findIndex(function(e){return"internal_message"==e.type&&e.Sc==c&&e.target==b});-1!=d&&a.b.splice(d,1)},Jq=function(a,c){a.b.forEach(function(b){b.type==c.type&&Promise.resolve().then(function(){return b.Sc.call(b.target,c)})})};var Kq={SUCCESS:0,Po:1,Qt:2,Rt:3,fA:4,cz:5},Lq={SUCCESS:0,dz:1,Po:2,Gz:3},Mq={SUCCESS:0,ay:1,jw:2},Nq=function(a){Cb("MediaRouter.Dial.CreateRoute",a,Kq)},Oq=function(a){Cb("MediaRouter.Dial.TerminateRoute",a,Lq)},Pq=function(a){Cb("MediaRouter.Dial.ParseMessage",a,Mq)};var Qq=function(a,c,b,d){c="["+c+"]: "+b+" "+d.responseURL+" => "+d.status+" ("+d.statusText+")";200<=d.status&&299>=d.status?a.info(c):ob(a,c)};var Rq=function(){this.name="unknown";this.state="error";this.b=null;this.allowStop=!0;this.resource=null;this.extraData={}},Sq=function(){var a=Error.call(this);this.message=a.message;"stack"in a&&(this.stack=a.stack)};q(Sq,Error);var Uq=function(a){if(void 0===c){Tq||(Tq=new gf(10,2E3));var c=Tq}this.f=a;this.b=c;this.l=hb("mr.dial.Client")};
Uq.prototype.launchApp=function(a,c){var b=this;return this.b.send(Vq(this,a),"POST",c,{timeoutMillis:15E3}).then(function(d){return Wq(b,"launchApp","POST",d)})};
var Yq=function(a,c){return Xq(a,c).then(function(b){return b.resource?b.resource:(a.l.G("stopApp: Resource path for not available for app "+c+": using fallback path."),"run")},function(){a.l.G("stopApp: getAppInfo failed: using fallback path.");return"run"}).then(function(b){return a.b.send(Vq(a,c)+"/"+b,"DELETE")}).then(function(b){return Wq(a,"stopApp","DELETE",b)})},Xq=function(a,c){return a.b.send(Vq(a,c),"GET",void 0,{xm:3}).then(function(b){Qq(a.l,"GetAppInfo","GET",b);if(!(200<=b.status&&
299>=b.status)){if(404==b.status)throw new Sq;throw Error("Response error: "+b.status);}b=b.responseText;b=(new DOMParser).parseFromString(b,"text/xml");b=b.getElementsByTagNameNS("http://www.w3.org/1999/xhtml","parsererror").length?null:b;if(!b)throw a.l.info("Invalid or empty response"),Error("Invalid or empty response");var d=b.getElementsByTagName("service");if(!d||1!=d.length)throw a.l.info("Invalid GET response (invalid service)"),Error("Invalid GET response (invalid service)");b=new Rq;for(var e=
0,f=d[0].childNodes.length;e<f;e++){var g=d[0].childNodes[e];if("state"==g.nodeName){a:switch(g.textContent){case "running":g="running";break a;case "stopped":g="stopped";break a;default:g="error"}b.state=g}else"name"==g.nodeName?b.name=g.textContent:"link"==g.localName?b.resource=g.getAttribute("href"):"options"==g.nodeName?b.allowStop="false"!=g.getAttribute("allowStop"):b.extraData[g.nodeName]=g.innerHTML}if("unknown"==b.name)throw a.l.info("GET response missing name value"),Error("GET response missing name value");
if(b.name!=c)throw a.l.info("GET app name mismatch"),Error("GET app name mismatch");if("error"==b.state)throw a.l.info("GET response missing state value"),Error("GET response missing state value");if((d=/installable=(.+)/.exec(b.state))&&d[1])b.state="installable",b.b=d[1];else if("running"!=b.state&&"stopped"!=b.state)throw a.l.info("GET response has invalid state value"),Error("GET response has invalid state value");return b})},Vq=function(a,c){a=a.f.Td;"/"!=a.charAt(a.length-1)&&(a+="/");return a+
c},Wq=function(a,c,b,d){return new Promise(function(e,f){Qq(a.l,c,b,d);200<=d.status&&299>=d.status?e():f(Error(d.statusText))})},Tq=null;var Zq=function(a,c){this.Gc=a;this.appName=c};var $q=function(a){this.b=new Map;this.f=a};$q.prototype.init=function(){am(this)};$q.prototype.clear=function(){this.b.clear()};$q.prototype.add=function(a){if(!this.b.get(a.Gc.id)){this.b.set(a.Gc.id,a);var c=this.f;ar(c);c.h.Uf(c,a.Gc)}};var br=function(a,c){a=l(a.b);for(var b=a.next();!b.done;b=a.next())if(b=l(b.value),b.next(),b=b.next().value,b.Gc.sinkId==c)return b;return null},dr=function(a,c){var b=a.b.get(c);b&&(a.b.delete(c),cr(a.f,b))};
$q.prototype.Bd=function(){return Array.from(this.b.values(),function(a){return a.Gc})};$q.prototype.Ea=function(){return"dial.ActivityRecords"};$q.prototype.jb=function(){return[Array.from(this.b)]};$q.prototype.ib=function(){var a=Yl(this);a&&(this.b=new Map(a))};var er=function(a){this.g=a;this.l=hb("mr.dial.SinkDiscoveryService");this.b=new Map;this.f={sg:0,Eg:0};this.h=0};er.prototype.init=function(){am(this)};
var hr=function(a,c){a.l.info("addSinks returned "+c.length+" sinks");ob(a.l,function(){return"....the list is: "+JSON.stringify(c)});var b=new Set(a.b.keys());c.forEach(function(f){var g=f.sink_id,k=f.extra_data.dial_media_sink,m=fr.test(k.model_name);f=new xm(f.name,g);f.kc=k.ip_address.address_bytes?k.ip_address.address_bytes.join("."):k.ip_address.address.join(".");f.Td=k.app_url.url;f.zc=k.model_name;f.Fe=!m;gr(a,f);b.delete(f.getId())});var d=[];b.forEach(function(f){var g=a.b.get(f);d.push(g);
a.b.delete(f)});0<d.length&&a.g.oj(d);var e=a.b.size;a.f={sg:e,Eg:e}},gr=function(a,c){ob(a.l,"mayAddSink, id = "+c.getId());var b=a.b.get(c.getId());b?b.update(c)&&(ob(a.l,"Updated sink "+b.getId()),a.g.Mh(b)):(ob(a.l,function(){return"Adding new sink "+c.getId()+": "+("name = "+c.Ac.friendlyName+(c.kc?", ip = "+c.kc:"")+(c.zc?", model = "+c.zc:"")+", apps = "+JSON.stringify(c.ec))}),a.b.set(c.getId(),c),a.g.nj(c))};er.prototype.ra=function(a){return this.b.get(a)||null};
var jr=function(a,c){var b=[];a.b.forEach(function(d){"available"==ym(d,c)&&b.push(d.Ac)});return new rq(b,ir[c])};er.prototype.Ue=function(){return this.f};er.prototype.Ea=function(){return"dial.DialSinkDiscoveryService"};er.prototype.jb=function(){return[new kr(Array.from(this.b),this.f),{deviceCountMetricsRecordTime:this.h}]};
er.prototype.ib=function(){var a=Yl(this);if(a){for(var c=l(a.sinks),b=c.next();!b.done;b=c.next())b=b.value,this.b.set(b[0],zm(b[1]));this.f=a.deviceCounts}if(a=Zl(this))this.h=a.deviceCountMetricsRecordTime};
var ir={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"]},fr=/Eureka Dongle|Chromecast Audio|Chromecast Ultra/i,
kr=function(a,c){this.sinks=a;this.deviceCounts=c};var lr=function(a){return Promise.all(a.map(function(c){return c.then(function(b){return{ae:!0,value:b}},function(b){return{ae:!1,reason:b}})}))};var nr=function(a,c){this.l=hb("mr.dial.AppDiscoveryService");this.b=new Set;this.f=a;this.w=c;this.j=new Map;this.m=new Map;this.g=null;this.h=!1};nr.prototype.init=function(){am(this)};nr.prototype.start=function(){this.l.info("Starting periodic scanning.");this.h||(this.h=!0,or(this))};nr.prototype.stop=function(){this.l.info("Stopping periodic scanning.");this.h&&(this.h=!1,this.g&&(clearTimeout(this.g),this.g=null),this.j.clear())};
var or=function(a){a.l.info("Start app status scan.");var c=[];Array.from(a.f.b.values()).forEach(function(b){c.push.apply(c,pr(a,b))});Array.from(a.w.b.values()).forEach(function(b){c.push(qr(a,b))});lr(c).then(function(){a.h&&!a.g&&(ob(a.l,"Scan complete; scheduling for next scan."),a.g=setTimeout(function(){ob(a.l,"Start app status scan (timer-based)");a.g=null;or(a)},6E4))})},pr=function(a,c){if(!c.Fe)return[];for(var b=[],d=l(a.b),e=d.next();!e.done;e=d.next())b.push(a.o(e.value,c));return b};
nr.prototype.o=function(a,c){var b=this;if("unknown"!=ym(c,a)&&36E5>Date.now()-(c.Kh[a]||0)||!c.Fe)return Promise.resolve();ob(this.l,"Querying "+c.getId()+" for "+a+" to update app status");return rr(this,c,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"}sr(b,c,a,d)},function(d){d instanceof
Sq?sr(b,c,a,"unavailable"):(b.l.G("Failed to process app availability; "+c.getId()+" does not support app availability"),c.Fe=!1)})};
var qr=function(a,c){var b=a.f.ra(c.Gc.sinkId);if(!b)return a.l.G("Activity refers to nonexistent sink: "+c.Gc.id),Promise.resolve();if(!b.Fe)return Promise.resolve();var d=c.appName;ob(a.l,"Querying "+b.getId()+" for "+d+" to update activity");return rr(a,b,d).then(function(e){"running"!=e.state&&tr(a,b,d)},function(){return tr(a,b,d)})},ur=function(a,c){var b=a.m.get(c.getId());b||(b=new Uq(c),ob(a.l,"Created DIAL client for "+c.getId()),a.m.set(c.getId(),b));return b},rr=function(a,c,b){var d=
vr(c,b),e=a.j.get(d);if(e)return e;e=Xq(ur(a,c),b);a.j.set(d,e);c=function(){a.j.delete(d)};e.then(c,c);return e},vr=function(a,c){return a.getId()+":"+c},sr=function(a,c,b,d){ob(a.l,"Got app status "+d+" from "+c.getId()+" for "+b);var e=ym(c,b);c.ec[b]=d;c.Kh[b]=Date.now();d!=e&&a.f.g.Mh(c)},tr=function(a,c,b){(c=br(a.w,c.getId()))&&c.appName==b&&dr(a.w,c.Gc.id)},wr=function(a,c){return Array.from(a.f.b.values()).some(function(b){return"unknown"==ym(b,c)})};nr.prototype.Ea=function(){return"dial.AppDiscoveryService"};
nr.prototype.jb=function(){return[Array.from(this.b)]};nr.prototype.ib=function(){var a=Yl(this);this.b=new Set(a||[])};var xr=function(a,c){this.appName=a;this.launchParameter=void 0===c?"":c},Ar=function(a){try{var c=new URL(a)}catch(b){return yr.info("Invalid URL: "+a),null}switch(c.protocol){case "dial:":a:if(a=c.pathname,a.match(/^\w+$/)){if(c=c.searchParams.get("postData")||void 0)try{c=mm(c)}catch(b){yr.G("Invalid base64 encoded postData:"+c);a=null;break a}a=new xr(a,c)}else yr.G("Invalid app name: "+a),a=null;return a;case "https:":return zr(c);default:return ob(yr,"Unhandled protocol: "+c.protocol),null}},
zr=function(a){var c=a.hash;if(!c)return null;a=(a=Br.exec(c))?a[1]:null;if(!a)return null;a=decodeURIComponent(a);if(c=(c=Cr.exec(c))?c[1]:void 0)try{c=mm(c)}catch(b){return yr.G("Invalid base64 encoded postData:"+c),null}return new xr(a,c)},yr=hb("mr.dial.PresentationUrl"),Br=/__dialAppName__=([A-Za-z0-9-._~!$&'()*+,;=%]+)/,Cr=/__dialPostData__=([A-Za-z0-9]+={0,2})/;var Dr=function(a,c){this.h=a;this.f=c||new er(this);this.g=new $q(this);this.b=null;this.l=hb("mr.DialProvider")};h=Dr.prototype;h.getName=function(){return"dial"};h.Ue=function(){return this.f.Ue()};h.initialize=function(a){a=a&&0==a.enable_dial_sink_query?!1:!0;this.l.info("Dial sink query enabled: "+a+"...");this.g.init();this.f.init();a?(this.b=this.b||new nr(this.f,this.g),this.b.init()):this.b=null;ar(this)};
h.Bg=function(a){if(!this.b)return sq;ob(this.l,"GetAvailableSinks for "+a);return(a=Ar(a))?jr(this.f,a.appName):sq};h.startObservingMediaSinks=function(a){if(this.b){var c=Ar(a);if(c){a=this.b;c=c.appName;if(!a.b.has(c)||wr(a,c))a.b.add(c),0!=a.f.b.size&&(a.h?Array.from(a.f.b.values()).forEach(a.o.bind(a,c)):a.start());ar(this)}}};h.stopObservingMediaSinks=function(a){this.b&&(a=Ar(a))&&(this.b.b.delete(a.appName),Er(this))};h.startObservingMediaRoutes=function(){ar(this)};
h.stopObservingMediaRoutes=function(){Er(this)};var Er=function(a){a.b&&(0==a.f.b.size||0==a.b.b.size&&0==a.g.b.size)&&a.b.stop()},ar=function(a){a.b&&0<a.f.b.size&&(0<a.b.b.size||0<a.g.b.size)&&a.b.start()};h=Dr.prototype;h.ra=function(a){return(a=this.f.ra(a))?a.Ac:null};h.Bd=function(){return this.g.Bd()};
h.createRoute=function(a,c,b,d){var e=this,f=this.f.ra(c);if(!f)return Nq(1),ri(Error("Unkown sink: "+c));um().f=new rm(f.zc,f.Sb());var g=Ar(a);if(!g)return Nq(4),ri(Error("No app name set."));var k=g.appName,m=new Uq(f);return si(Xq(m,k).then(function(p){if("running"==p.state)return Yq(m,k)}).then(function(){return m.launchApp(k,g.launchParameter)}).then(function(){return Fr(e,c,a,k,b,d)}).catch(function(p){Nq(3);throw p;}))};h.joinRoute=function(){return ri(Error("Not supported"))};
h.connectRouteByRouteId=function(){return ri(Error("Not supported"))};h.detachRoute=function(){};var Fr=function(a,c,b,d,e,f){Nq(0);c=Ip(e,a.getName(),c,b,!0,d);c.offTheRecord=f;a.g.add(new Zq(c,d));return c};Dr.prototype.nj=function(a){this.h.onSinkAvailabilityUpdated(this,1);this.b&&(ar(this),pr(this.b,a));this.h.dd();um().b=new rm(a.zc,a.Sb())};
Dr.prototype.oj=function(a){var c=this;if(0==this.f.b.size)this.h.onSinkAvailabilityUpdated(this,0);Er(this);a.forEach(function(b){var d=c.g;b=b.getId();if(b=br(d,b))d.b.delete(b.Gc.id),cr(d.f,b)});this.h.dd()};Dr.prototype.Mh=function(){this.h.dd()};var cr=function(a,c){c=c.Gc;if(c.isLocal)a.h.onPresentationConnectionStateChanged(c.id,"terminated");Er(a);a.h.Ig(c)};h=Dr.prototype;
h.terminateRoute=function(a){var c=this.g.b.get(a)||null;if(!c)return Oq(1),Promise.reject(new qq(3,"Route in DIAL provider not found for routeId "+a));dr(this.g,a);a=this.f.ra(c.Gc.sinkId);return a?Yq(new Uq(a),c.appName).then(function(){Oq(0);return Promise.resolve()}).catch(function(b){Oq(3);return Promise.reject(b)}):(Oq(1),Promise.reject(new qq(3,"Sink in DIAL provider not found for sinkId "+c.Gc.sinkId)))};h.Gf=function(){throw Error("Not implemented.");};h.Ve=function(){return null};h.Sh=function(){};
h.sendRouteMessage=function(){return Promise.reject(Error("DIAL sending messages is not supported"))};h.sendRouteBinaryMessage=function(){return Promise.reject(Error("DIAL sending messages is not supported"))};h.ug=function(a,c){c=this.f.ra(c);return!c||cj(a)?!1:(a=Ar(a))?"available"==ym(c,a.appName):!1};h.zf=function(){return!1};h.searchSinks=function(){return eb()};h.createMediaRouteController=function(){return eb()};h.provideSinks=function(a){hr(this.f,a)};var Gr=function(a){this.m=new er(this);this.g=new Jm;this.f=a;this.w=this.j=0;this.h=new Fn;this.b=new Dr(this,this.m)};h=Gr.prototype;h.Ea=function(){return"cast.DialProviderWrapper"};h.jb=function(){return[new Hr(Om(this.g),this.j,this.w,this.h.na())]};h.ib=function(){var a=Yl(this);a&&(Im(this.g,a.f),this.j=a.sequenceNumber,this.w=a.g,En(this.h,a.b))};h.getName=function(){return this.b.getName()};h.initialize=function(a){this.b.initialize(a);am(this)};h.Bd=function(){return this.b.Bd()};
h.Bg=function(a){return(a=Ir(a))?this.b.Bg(a):sq};h.startObservingMediaSinks=function(a){(a=Ir(a))&&this.b.startObservingMediaSinks(a)};h.stopObservingMediaSinks=function(a){(a=Ir(a))&&this.b.stopObservingMediaSinks(a)};h.startObservingMediaRoutes=function(a){(a=Ir(a))&&this.b.startObservingMediaRoutes(a)};h.stopObservingMediaRoutes=function(a){(a=Ir(a))&&this.b.stopObservingMediaRoutes(a)};h.ra=function(a){return this.b.ra(a)};
var Lr=function(a,c,b,d,e){var f=Ir(c);if(!f)return Promise.reject(Error("Invalid source"));var g=Ar(f),k=a.m.ra(b);if(!k)return Promise.reject(Error("Attempting custom launch with closed route"));var m=g.appName;if(!m)return Promise.reject(Error("No app name given"));var p=Jr(c);return p?Xq(new Uq(k),m).then(function(v){var A=Fr(a.b,b,c,m,e,d);v={routeId:A.id,sinkId:k.getId(),appName:m,dl:v,launchParameter:g.launchParameter,session:null,clientId:null};a.g.set(A.id,v);var G=Kr(a,v.sinkId),E=new Yn("receiver_action",
{receiver:G,action:chrome.cast.ig.CAST});E.clientId=p;a.f.ee(v.routeId,E);E=chrome.cast.ca;var P=String(a.w);a.w=(a.w+1)%9007199254740992;G=new E(P,"",v.appName,[],G);v.session=G;v.clientId=p;G=new Yn("new_session",G);G.clientId=p;a.f.ee(v.routeId,G);return A}):Promise.reject(Error("No client ID"))};Gr.prototype.createRoute=function(a,c,b,d,e,f,g){return a.startsWith("cast-dial:")||Mr.test(a)?si(Lr(this,a,c,d,b)):this.b.createRoute(a,c,b,d,e,f,g)};
Gr.prototype.terminateRoute=function(a){var c=this.g.get(a);if(c&&c.session&&c.clientId){var b={receiver:Kr(this,c.sinkId),action:chrome.cast.ig.STOP};b=new Yn("receiver_action",b);b.clientId=c.clientId;this.f.ee(c.routeId,b);this.f.onPresentationConnectionStateChanged(c.routeId,"terminated")}return this.b.terminateRoute(a)};
Gr.prototype.sendRouteMessage=function(a,c,b){try{var d=JSON.parse(c)}catch(e){return Pq(1),Promise.reject(e)}switch(d.type){case "client_connect":return Pq(0),c=d.clientId,(a=this.g.get(a))?(b=Kr(this,a.sinkId),b.receiverType=chrome.cast.oh.DIAL,b=new Yn("custom_dial_launch",new chrome.cast.xk(b,a.dl.state,a.dl.extraData)),b.clientId=c,c=this.j,this.j=(this.j+1)%9007199254740992,b.sequenceNumber=c,this.h.add(b.sequenceNumber),this.f.ee(a.routeId,b),a=Promise.resolve()):a=Promise.reject(Error("Unknown route")),
a;case "custom_dial_launch":if(this.h.contains(d.sequenceNumber))return Pq(0),c=d,this.h.remove(c.sequenceNumber),c=c.message,(a=this.g.get(a))?c&&!c.doLaunch?a=Promise.resolve():(b=this.m.ra(a.sinkId))?(b=new Uq(b),d=a.launchParameter,d=(c?c.launchParameter:null)||d,a=b.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 Pq(0),this.terminateRoute(a),
Promise.resolve()}Pq(2);return this.b.sendRouteMessage(a,c,b)};Gr.prototype.sendRouteBinaryMessage=function(a){return Promise.reject(Error("Route "+a+" does not support sending binary data."))};var Kr=function(a,c){a=a.m.ra(c);c=vm(um(),c);c=new chrome.cast.hi(c,a.Ac.friendlyName);c.ipAddress=a.Sb();c.receiverType=chrome.cast.oh.DIAL;return c};h=Gr.prototype;h.Gf=function(a){return this.b.Gf(a)};h.Ve=function(a){return this.b.Ve(a)};h.Sh=function(){};
h.ug=function(a,c){return a.startsWith("cast-dial:")||Mr.test(a)||this.b.ug(a,c)};h.zf=function(a,c,b){return this.b.zf(a,c,b)};h.connectRouteByRouteId=function(a,c,b,d,e){return this.b.connectRouteByRouteId(a,c,b,d,e)};h.joinRoute=function(a,c,b,d,e,f){return this.b.joinRoute(a,c,b,d,e,f)};h.detachRoute=function(a){this.g.remove(a);this.b.detachRoute(a)};h.dd=function(){this.f.dd()};h.onSinkAvailabilityUpdated=function(a,c){this.f.onSinkAvailabilityUpdated(a,c)};
h.Uf=function(a,c){this.f.Uf(this,c)};h.Ig=function(a){this.f.Ig(a)};h.Ye=function(a){this.f.Ye(a)};h.Si=function(){};h.getMirroringServiceHostForTab=function(){};h.getMirroringServiceHostForDesktop=function(){};h.getMirroringServiceHostForOffscreenTab=function(){};h.ee=function(a,c){this.f.ee(a,c)};h.onPresentationConnectionStateChanged=function(a,c){this.f.onPresentationConnectionStateChanged(a,c)};h.onPresentationConnectionClosed=function(a,c,b){this.f.onPresentationConnectionClosed(a,c,b)};
h.Mi=function(a){return this.f.Mi(a)};h.Oi=function(){return this.f.Oi()};h.Ze=function(a){this.f.Ze(a)};h.Rh=function(a,c){this.f.Rh(a,c)};h.Th=function(a){this.f.Th(a)};h.nj=function(a){this.b.nj(a)};h.oj=function(a){this.b.oj(a)};h.Mh=function(a){this.b.Mh(a)};h.rj=function(){};h.im=function(){};h.searchSinks=function(a,c){return this.b.searchSinks(a,c)};h.provideSinks=function(a){this.b.provideSinks(a)};h.createMediaRouteController=function(){return eb()};
h.Wf=function(a,c){return this.f.Wf(a,c)};h.Ue=function(){return this.b.Ue()};
var Ir=function(a){try{var c=new URL(a)}catch(e){return null}if("dial:"==c.protocol)return a;if("cast-dial:"==c.protocol){var b=c;a="cast-dial:"!=b.protocol?null:new go(b.pathname,b.searchParams.get("dialPostData"),b.searchParams.get("clientId"));b=a.g;var d=a.b}else if("https:"==c.protocol){a=ro(a);if(!a)return null;b=a.s;d=a.D}b?(a=d||"",b=new URL("dial:"+b),a&&b.searchParams.set("postData",a),b=b.toString()):b=null;return b},Jr=function(a){try{var c=new URL(a)}catch(b){return null}return"cast-dial:"==
c.protocol?c.searchParams.get("clientId"):"https:"==c.protocol?so(a):null},Hr=function(a,c,b,d){this.f=a;this.sequenceNumber=c;this.g=b;this.b=d},Mr=/__dialAppName__/;var Nr=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^/?#]*)@)?([^/#?]*?)(?::([0-9]+))?(?=[/#?]|$))?([^?#]+)?(?:\?([^#]*))?(?:#([\s\S]*))?$/,Or=function(a,c){if(a){a=a.split("&");for(var b=0;b<a.length;b++){var d=a[b].indexOf("="),e=null;if(0<=d){var f=a[b].substring(0,d);e=a[b].substring(d+1)}else f=a[b];c(f,e?decodeURIComponent(e.replace(/\+/g," ")):"")}}},Pr=function(a,c,b){b=null!=b?"="+encodeURIComponent(String(b)):"";if(c+=b){b=a.indexOf("#");0>b&&(b=a.length);var d=a.indexOf("?");if(0>d||d>b){d=b;var e=""}else e=
a.substring(d+1,b);a=[a.substr(0,d),e,a.substr(b)];b=a[1];a[1]=c?b?b+"&"+c:c:b;a=a[0]+(a[1]?"?"+a[1]:"")+a[2]}return a},Qr=/#|$/,Rr=function(a,c){var b=a.search(Qr);a:{var d=0;for(var e=c.length;0<=(d=a.indexOf(c,d))&&d<b;){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>b)e=b;d+=c.length+1;return decodeURIComponent(a.substr(d,e-d).replace(/\+/g," "))},Sr=function(a,c){var b=a.length-1;0<=b&&
a.indexOf("/",b)==b&&(a=a.substr(0,a.length-1));id(c,"/")&&(c=c.substr(1));return qe(a,"/",c)};var Tr=function(a){this.sc=this.w=this.g="";this.La=null;this.h=this.b="";this.j=!1;var c;a instanceof Tr?(this.j=Ia(void 0)?void 0:a.j,Ur(this,a.g),this.w=a.w,this.sc=a.sc,Vr(this,a.xb()),this.b=a.b,Wr(this,a.f.clone()),this.h=a.h):a&&(c=String(a).match(Nr))?(this.j=!1,Ur(this,c[1]||"",!0),this.w=Xr(c[2]||""),this.sc=Xr(c[3]||"",!0),Vr(this,c[4]),this.b=Xr(c[5]||"",!0),Wr(this,c[6]||"",!0),this.h=Xr(c[7]||"")):(this.j=!1,this.f=new Yr(null,this.j))};
Tr.prototype.toString=function(){var a=[],c=this.g;c&&a.push(Zr(c,$r,!0),":");var b=this.sc;if(b||"file"==c)a.push("//"),(c=this.w)&&a.push(Zr(c,$r,!0),"@"),a.push(encodeURIComponent(String(b)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),b=this.xb(),null!=b&&a.push(":",String(b));if(b=this.b)this.sc&&"/"!=b.charAt(0)&&a.push("/"),a.push(Zr(b,"/"==b.charAt(0)?as:bs,!0));(b=this.f.toString())&&a.push("?",b);(b=this.h)&&a.push("#",Zr(b,cs));return a.join("")};
Tr.prototype.resolve=function(a){var c=this.clone(),b=!!a.g;b?Ur(c,a.g):b=!!a.w;b?c.w=a.w:b=!!a.sc;b?c.sc=a.sc:b=null!=a.La;var d=a.b;if(b)Vr(c,a.xb());else if(b=!!a.b){if("/"!=d.charAt(0))if(this.sc&&!this.b)d="/"+d;else{var e=c.b.lastIndexOf("/");-1!=e&&(d=c.b.substr(0,e+1)+d)}e=d;if(".."==e||"."==e)d="";else if(-1!=e.indexOf("./")||-1!=e.indexOf("/.")){d=id(e,"/");e=e.split("/");for(var f=[],g=0;g<e.length;){var k=e[g++];"."==k?d&&g==e.length&&f.push(""):".."==k?((1<f.length||1==f.length&&""!=
f[0])&&f.pop(),d&&g==e.length&&f.push("")):(f.push(k),d=!0)}d=f.join("/")}else d=e}b?c.b=d:b=""!==a.f.toString();b?Wr(c,a.f.clone()):b=!!a.h;b&&(c.h=a.h);return c};Tr.prototype.clone=function(){return new Tr(this)};var Ur=function(a,c,b){a.g=b?Xr(c,!0):c;a.g&&(a.g=a.g.replace(/:$/,""))};Tr.prototype.xb=function(){return this.La};
var Vr=function(a,c){if(c){c=Number(c);if(isNaN(c)||0>c)throw Error("Bad port number "+c);a.La=c}else a.La=null},Wr=function(a,c,b){c instanceof Yr?(a.f=c,ds(a.f,a.j)):(b||(c=Zr(c,es)),a.f=new Yr(c,a.j))},Xr=function(a,c){return a?c?decodeURI(a.replace(/%25/g,"%2525")):decodeURIComponent(a):""},Zr=function(a,c,b){return Ja(a)?(a=encodeURI(a).replace(c,fs),b&&(a=a.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),a):null},fs=function(a){a=a.charCodeAt(0);return"%"+(a>>4&15).toString(16)+(a&15).toString(16)},
$r=/[#\/\?@]/g,bs=/[#\?:]/g,as=/[#\?]/g,es=/[#\?@]/g,cs=/#/g,Yr=function(a,c){this.f=this.b=null;this.g=a||null;this.h=!!c},gs=function(a){a.b||(a.b=new Jm,a.f=0,a.g&&Or(a.g,function(c,b){a.add(decodeURIComponent(c.replace(/\+/g," ")),b)}))},is=function(a){var c=zn(a);if("undefined"==typeof c)throw Error("Keys are undefined");var b=new Yr(null,void 0);a=yn(a);for(var d=0;d<c.length;d++){var e=c[d],f=a[d];Ua(f)?hs(b,e,f):b.add(e,f)}return b};h=Yr.prototype;h.sa=function(){gs(this);return this.f};
h.add=function(a,c){gs(this);this.g=null;a=js(this,a);var b=this.b.get(a);b||this.b.set(a,b=[]);b.push(c);this.f+=1;return this};h.remove=function(a){gs(this);a=js(this,a);return Mm(this.b,a)?(this.g=null,this.f-=this.b.get(a).length,this.b.remove(a)):!1};h.clear=function(){this.b=this.g=null;this.f=0};h.Nb=function(){gs(this);return 0==this.f};var ks=function(a,c){gs(a);c=js(a,c);return Mm(a.b,c)};h=Yr.prototype;h.Bf=function(a){var c=this.na();return Ub(c,a)};
h.forEach=function(a,c){gs(this);this.b.forEach(function(b,d){y(b,function(e){a.call(c,e,d,this)},this)},this)};h.wb=function(){gs(this);for(var a=this.b.na(),c=this.b.wb(),b=[],d=0;d<c.length;d++)for(var e=a[d],f=0;f<e.length;f++)b.push(c[d]);return b};h.na=function(a){gs(this);var c=[];if(Ja(a))ks(this,a)&&(c=dc(c,this.b.get(js(this,a))));else{a=this.b.na();for(var b=0;b<a.length;b++)c=dc(c,a[b])}return c};
h.set=function(a,c){gs(this);this.g=null;a=js(this,a);ks(this,a)&&(this.f-=this.b.get(a).length);this.b.set(a,[c]);this.f+=1;return this};h.get=function(a,c){if(!a)return c;a=this.na(a);return 0<a.length?String(a[0]):c};var hs=function(a,c,b){a.remove(c);0<b.length&&(a.g=null,a.b.set(js(a,c),z(b)),a.f+=b.length)};
Yr.prototype.toString=function(){if(this.g)return this.g;if(!this.b)return"";for(var a=[],c=this.b.wb(),b=0;b<c.length;b++){var d=c[b],e=encodeURIComponent(String(d));d=this.na(d);for(var f=0;f<d.length;f++){var g=e;""!==d[f]&&(g+="="+encodeURIComponent(String(d[f])));a.push(g)}}return this.g=a.join("&")};Yr.prototype.clone=function(){var a=new Yr;a.g=this.g;this.b&&(a.b=this.b.clone(),a.f=this.f);return a};
var js=function(a,c){c=String(c);a.h&&(c=c.toLowerCase());return c},ds=function(a,c){c&&!a.h&&(gs(a),a.g=null,a.b.forEach(function(b,d){var e=d.toLowerCase();d!=e&&(this.remove(d),hs(this,e,b))},a));a.h=c};Yr.prototype.extend=function(a){for(var c=0;c<arguments.length;c++)Bn(arguments[c],function(b,d){this.add(d,b)},this)};var ls=function(a,c){this.input=a;this.domain=c};var ms=function(a){this.b=a;this.l=hb("mr.ExternalMessageHandler")};
ms.prototype.onMessage=function(a,c,b){var d=this;this.l.info("Received a message from "+c.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 ls(a.meetingName,a.domain)).then(function(f){var g="PresentationId"+c.id+ns++;d.b.createRoute("urn:x-org.chromium.media:source:desktop",f,g).then(function(k){b(new qf(e,"route",k.id))}).catch(function(k){b(new qf(e,"error",k))})},function(){b(new qf(e,"error",
Error("Failed to find sink.")))})):"stop"==a.type?this.b.terminateRoute(a.message.routeId).then(function(){b(new qf(e,"stopped"))}):"subscribe_log_data"==a.type?(jb.push(function(f){chrome.runtime.sendMessage(c.id,new qf(e,"log_message",f))}),b(new qf(e,"subscribed"))):(b(new qf(e,"error",Error("Unhandled message type"))),this.l.error("Unhandled message type "+a.type))};var ns=0;var os=function(){this.b=[];this.f=[]};h=os.prototype;h.enqueue=function(a){if(1E3<=this.sa()){if(this.Nb())throw Error("Empty queue");0==this.b.length&&(this.b=this.f,this.b.reverse(),this.f=[]);this.b.pop()}this.f.push(a)};h.sa=function(){return this.b.length+this.f.length};h.Nb=function(){return 0==this.sa()};h.na=function(){var a=this.b.slice();a.reverse();a.push.apply(a,n(this.f));return a};h.clear=function(){this.b=[];this.f=[]};var ps=function(){this.b=new os;this.f=Date.now()},rs=function(){null==qs&&(qs=new ps);return qs};ps.prototype.init=function(){ib=1;var a=hb("browser"),c=window.onerror;window.onerror=function(d,e,f,g,k){c&&c(d,e,f,g,k);a.error("Error: "+d+" ("+e+" @ Line: "+f+")",k)};jb.push(this.h.bind(this));var b=window.localStorage["debug.logs"];b&&(ib=qb(b.toUpperCase()));(b=window.localStorage["debug.console"])&&"false"!=b.toLowerCase()&&jb.push(this.g.bind(this))};
ps.prototype.h=function(a){this.b.enqueue(ss(this,a,!1));a=a.Ec;a instanceof Error&&a.stack&&this.b.enqueue(a.stack)};ps.prototype.g=function(a){var c=[ss(this,a,!0)];a.Ec&&c.push(a.Ec);switch(a.level){case 3:console.error.apply(console,n(c));break;case 2:console.warn.apply(console,n(c));break;case 1:console.log.apply(console,n(c));break;default:console.debug.apply(console,n(c))}};
var ss=function(a,c,b){var d=["["];if(b)d.push(("       "+((Date.now()-a.f)/1E3).toFixed(3)).slice(-7));else{a=new Date(c.time);var e=function(f){return 10>f?"0"+f:f};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("][",pb[c.level],"][",c.R,"] ",c.message);if(!b&&null!=c.Ec)if(d.push("\n"),c.Ec instanceof Error)d.push(c.Ec.message);else try{d.push(JSON.stringify(c.Ec))}catch(f){d.push(c.Ec.toString())}d.push("\n");
return d.join("")},ts=function(){var a=rs();return 0==a.b.sa()?"NA":a.b.na().join("")},us=function(){var a=rs();am(a)};ps.prototype.Ea=function(){return"LogManager"};ps.prototype.jb=function(){return[this.b.na()]};ps.prototype.ib=function(){var a=this.b.na();this.b.clear();for(var c=l(Yl(this)||[]),b=c.next();!b.done;b=c.next())this.b.enqueue(b.value);a=l(a);for(b=a.next();!b.done;b=a.next())this.b.enqueue(b.value)};var qs=null;var vs=function(a){this.b=a;this.l=hb("mr.InternalMessageHandler")};
vs.prototype.onMessage=function(a,c,b){var d=this;if("retrieve_log_data"!=a.type)b(new qf(chrome.runtime.id,"error",Error("Unhandled message type")));else{var e={logs:ts(),device:wm()};c=[];var f=pf(e.device.ip).then(function(k){k.b&&(e.device.version=k.b)});c.push(f);var g=this.b.s;g&&(a=ws(this,g,a.source).then(function(k){k&&(e.castStreamingLogs=k)},function(){d.l.error("Log upload failed for service: "+g)}),c.push(a));e.dialDeviceCounts=xs(this);c.push(ys(this,e));a=this.b.getMediaSinkServiceStatus().then(function(k){e.mediaSinkServiceStatus=
k.status},function(){d.l.error("Fail to get media sink service status")});c.push(a);e.dialogType=this.b.H;lr(c).then(function(){b(e)})}};var ys=function(a,c){return Ri("mr.cast.SinkDiscoveryService").then(function(b){b=b.Ue();c.castDeviceCounts=b.Eg+"."+b.sg},function(){a.l.error("Failed to get device counts for castDeviceCounts.")})},xs=function(a){a=zs(a.b,"dial");if(!a)return"";a=a.Ue();return a.Eg+"."+a.sg},ws=function(a,c,b){return As(a.b,c).then(function(d){return d.Fj(b)})};var Bs={ACCEPTED:0,Wu:1,TIMEOUT:2},Cs={SUCCESS:0,mv:1},Ds={lp:0,Io:1,rA:2,Nv:3,Mv:4,bx:5,TIMEOUT:6,ty:7},Es={Kv:0,Hz:1},Fs={Ux:0,Iw:1,USER:2,Fv:3},Gs=function(a){Cb("MediaRouter.Cloud.Knock.Result",a,Bs)},Hs=function(a){Cb("MediaRouter.Cloud.Session.Start",a,Cs)},Is=function(a){Cb("MediaRouter.Cloud.Session.Type",a,Es)},Js=function(a){Cb("MediaRouter.Cloud.Device.UserRole",a,Fs)};var Ks=function(a,c){this.b=a;this.f=c},Ls=new Ks("https://www.googleapis.com/clouddevices/v1","AIzaSyAOZM8ZYeov685QMjXT3sC7XNizfrTEKjA"),Ms=new Ks("https://castedumessaging-pa.googleapis.com/v1","AIzaSyAOZM8ZYeov685QMjXT3sC7XNizfrTEKjA"),Ns=new Ks("https://www.googleapis.com/calendar/v3",""),Os=new Ks("https://www.googleapis.com/hangouts/v1",""),Ps=new Ks("https://networktraversal.googleapis.com/v1alpha","AIzaSyAOZM8ZYeov685QMjXT3sC7XNizfrTEKjA");var Qs=function(a,c,b,d,e,f){b=void 0===b?null:b;a||null==b&&(b="default");this.Yl=a;this.Ka=c;this.sc=b;this.Pf=void 0===d?null:d;this.Tc=void 0===e?null:e;this.gf=void 0===f?null:f};Qs.prototype.f=function(){var a="";this.Tc?a=this.Tc:this.Pf&&(a=this.Pf);return a};Qs.prototype.Hd=function(){return this.Yl};Qs.prototype.getId=function(){return this.Ka};Qs.prototype.merge=function(a){!this.gf&&a.gf&&(this.gf=a.gf);!this.Tc&&a.Tc&&(this.Tc=a.Tc);this.Tc&&a.Tc&&this.gf&&(this.Tc=a.Tc)};var Rs=function(a,c){this.f=a;this.g=c;this.l=hb("mr.cloud.calendar.CalendarService")},Vs=function(a){return Ss(a,a.g.b).then(function(c){a.l.info(Ts(c.length)+" events discovered before filtering.");return Us(a,c)},function(c){a.l.G("Error getting Hangouts from calendar.",c);return[]})},Ts=function(a){return 20<a?"20+":a.toString()},Ss=function(a,c){var b=Date.now();return Ws(a,c,new Date(b),new Date(b+9E5)).then(function(d){return d.filter(a.b)})};
Rs.prototype.b=function(a){return!(!a.start||!a.end||a.start.date||a.end.date||!a.start.dateTime||!a.end.dateTime)};
var Ws=function(a,c,b,d){c=Xs(Ns.b,["calendars",c,"events"],{timeMin:b.toJSON(),timeMax:d.toJSON(),singleEvents:!0});ob(a.l,"Retrieving Hangouts from Calendar: "+c);return Ys(a.f,c,"GET").then(function(e){return e.items?e.items:[]})},Us=function(a,c){var b=[];c.filter(function(d){return d.hangoutLink}).forEach(function(d){var e=new Tr(d.hangoutLink);if("meet.google.com"==e.sc)b.push(new Qs(!0,e.b.substring(1),void 0,void 0,d.summary));else if(e=e.b.substring(12).split("/"),2==e.length){var f=l(e);
e=f.next().value;f=f.next().value;if(-1!=e.indexOf(".")){var g=f;var k=e}b.push(new Qs(!1,f+"@"+e,k,g,d.summary,void 0))}else a.l.G("Invalid hangout link from calendar event: "+d.hangoutLink)});a.l.info(Ts(b.length)+" events discovered with Hangout links.");return b};var Zs=function(a){this.b=a;this.id=a.id;this.l=hb("mr.cloud.devices.WeaveDevice")};Zs.prototype.isAvailable=function(){if(this.getState().appStatus){var a="online"==this.b.connectionStatus,c="available"==this.getState().appStatus,b=$s(this,864E5);ob(this.l,"Device id: "+this.id+", availability: GCM connected "+a+", app Available: "+c+", checked in: "+b);return a&&c&&b}a=$s(this,9E5);this.l.info("Availability for legacy receiver app: "+a);return a};
var $s=function(a,c){a=a.b.lastUpdateTimeMs?Number(a.b.lastUpdateTimeMs):null;return!!(a&&a>Date.now()-c)};Zs.prototype.f=function(){return this.getState().settings.receiverName};Zs.prototype.getId=function(){return this.id};Zs.prototype.getState=function(){return this.b.state._cloudCast};var at=function(){this.l=Mf("mr.cloud.GcmRegistrationSerializer");this.b=Promise.resolve("")};at.prototype.register=function(a){var c=this,b=function(){return new Promise(function(d,e){chrome.gcm.register(a,function(f){f?(c.l.info("Got GCM registration ID: "+f),d(f)):e(Error(chrome.runtime.lastError&&chrome.runtime.lastError.message||"unknown error"))})})};return this.b=this.b.then(b,b)};var bt=function(a){this.email=a;this.imageUrl=null},ct=function(a){this.type=a},dt=function(a,c,b,d){this.type="__cloud_webrtc_session_message__";this.sessionDescription=a;this.user=c||null;this.flungUrl=b||null;this.presentationId=d||null};q(dt,ct);
var et=function(a,c,b){this.name=a;this.parameters=c;this.minimalRole=null!=b?b:"user"},ft={_settings:{type:"string"},_presentationRequest:{type:"string"},_optMediaConstraints:{type:"string"},_webrtcMessage:{type:"string"},_user:{type:"string"}},gt=new et("_knockingStartWebrtcSession",ft,"viewer"),ht=new et("_startWebrtcSession",ft),it=new et("_stopSession",{},"viewer");var jt=function(a,c){this.j=a;this.w=c;this.f=this.g=this.b=null;this.h=!1;this.l=hb("mr.cloud.devices.WeaveDevicesService");am(this)};jt.prototype.getDevice=function(a){a=Xs(Ls.b,["devices",a]);return Ys(this.j,a,"GET").then(function(c){return new Zs(c)})};
var kt=function(a,c){var b=Xs(Ls.b,["devices"],c);return Ys(a.j,b,"GET").then(function(d){var e=(d.devices||[]).filter(function(g){return null!=g.commandDefs&&null!=g.commandDefs._cloudCast}).map(function(g){return new Zs(g)});if(d=d.nextPageToken){var f=Lc(c);f.token=d;return kt(a,f).then(function(g){return e.concat(g)})}return e})};jt.prototype.Ea=function(){return"WeaveDevicesService"};jt.prototype.jb=function(){return[new lt(this.b,this.f,this.g)]};
jt.prototype.ib=function(){var a=Yl(this);a&&(this.b=a.Nq,this.f=a.gcmRegistrationId,this.g=a.Mq)};var mt=function(a){return a.f&&null!=a.g&&a.g+864E5>=Date.now()?Promise.resolve(a.f):a.w.register(["919648714761"]).then(function(c){ob(a.l,"Got GCM ID: "+c);a.f=c;a.g=Date.now();a.b=null;return c},function(c){a.l.G("Error",c);a.f=null;a.g=null;a.b=null;throw c;})};
jt.prototype.subscribe=function(a){var c=this;if(this.h)return Promise.resolve();this.h=!0;if(!a||this.b&&!(this.b+864E5<Date.now()))return Promise.resolve();a={filters:["myDevices"],gcmRegistrationId:a,gcmSenderId:"919648714761",expirationTimeMs:864E5};var b=Xs(Ls.b,["subscriptions","subscribe"],{});return Ys(this.j,b,"POST",a).then(function(){ob(c.l,"Subscribed on: "+Date.now());c.b=Date.now();c.h=!1;return Promise.resolve()},function(d){c.h=!1;throw d;})};
var lt=function(a,c,b){this.Nq=a;this.gcmRegistrationId=c;this.Mq=b};var nt=function(a,c,b,d,e,f,g,k){var m=vm(um(),a);this.nb=new Ul(m,c,g,k,e);this.deviceId=a;this.b=b;this.model=d;this.isAvailable=f};ca.Object.defineProperties(nt.prototype,{id:{configurable:!0,enumerable:!0,get:function(){return this.nb.id}},displayName:{configurable:!0,enumerable:!0,set:function(a){this.nb.friendlyName=a}}});var ot=function(a,c,b,d,e){nt.call(this,a,c,"weave","Chrome Streaming Receiver",d,e,"education");this.ri=b};q(ot,nt);
var pt=function(a){var c=a.sc,b;a.Pf&&a.f()!=a.Pf&&(b=a.Pf);nt.call(this,a.getId(),a.f(),"mesi","Hangout",c,!1,a.Hd()?"meeting":"hangout",b);this.Hd=a.Hd();this.eh=a.gf||""};q(pt,nt);var qt=function(a,c,b){nt.call(this,a,c,"slarti","Cast Receiver for Education","default",b,"education")};q(qt,nt);var rt=function(a,c,b){this.w=a;this.h=c;this.b=new Map;this.g=new Map;this.f=null;this.j=b};rt.prototype.fe=function(){var a=this.f+this.j;if(null==this.f||a<Date.now())this.f=Date.now(),st(this);return Array.from(this.b.values())};rt.prototype.ra=function(a){return this.b.get(a)||null};
var st=function(a){a.w().then(function(c){tt(a,c)})},tt=function(a,c){var b=new Map(a.b),d=new Map,e=new Map,f=[],g=[];c.forEach(function(k){var m=k.id;d.set(m,k);e.set(m,k.deviceId);b.has(m)?b.has(m)&&JSON.stringify(b.get(m))!=JSON.stringify(k)&&g.push(k.nb):f.push(k.nb);b.delete(m)});c=[].concat(n(b.values())).map(function(k){return k.nb});a.g.clear();a.g=e;a.b.clear();a.b=d;ut(a,f,g,c)},ut=function(a,c,b,d){0<c.length&&vt(a.h,c);0<b.length&&wt(a.h,b);0<d.length&&xt(a.h,d)},zt=function(a){for(var c=
{},b=l(a.b.entries()),d=b.next();!d.done;d=b.next()){var e=l(d.value);d=e.next().value;e=e.next().value;c[d]=e}b={};d=l(a.g.entries());for(e=d.next();!e.done;e=d.next()){var f=l(e.value);e=f.next().value;f=f.next().value;b[e]=f}return new yt(c,b,a.f)},At=function(a,c){for(var b in c.sinks){var d=c.sinks[b],e=null;"Hangout"==d.model?e=new pt(new Qs(d.Hd,d.deviceId,d.nb.domain,d.nb.description,d.nb.friendlyName,d.eh)):"Cast Receiver for Education"==d.model?e=new qt(d.deviceId,d.nb.friendlyName,d.isAvailable):
"Chrome Streaming Receiver"==d.model&&(e=new ot(d.deviceId,d.nb.friendlyName,d.ri,d.nb.domain,d.isAvailable));a.b.set(b,e)}for(b in c.b)a.g.set(b,c.b[b]);c.f&&(a.f=c.f)},yt=function(a,c,b){this.sinks=a;this.b=c;this.f=b};var Dt=function(a,c,b){if(!Bt){Lf();var d=Kf;d.f=Gf;var e=Ct;d.b||(d.b=[]);d.b.push(e);Bt=!0}this.g=a;this.h=c;this.b=new rt(this.j.bind(this),b,2E4);this.f=new Map;am(this)},Ct=function(a){kb({R:a.g,level:rb(a.f.value),time:a.j,message:a.getMessage(),Ec:a.b})};Dt.prototype.fe=function(){return this.b.fe()};Dt.prototype.ra=function(a){return this.b.ra(a)};
Dt.prototype.j=function(){var a=this;this.l.info("Fetching hangouts");return lr([Et(this.h),Vs(this.g)]).then(function(c){var b=Array.from(a.f.values());c.forEach(function(e){e.ae?b=b.concat(e.value):a.l.error("Error discovering Hangouts",e.reason)});var d=b.reduce(function(e,f){var g=e[f.getId()];g?g.merge(f):g=f;e[g.getId()]=g;return e},{});return Object.keys(d).map(function(e){e=d[e];Bb("MediaRouter.Cloud.Hangout.Sink.Discovered");return new pt(e)})})};
var Gt=function(a,c){return Ri("mr.mirror.hangouts.MeetingsService").then(function(b){return b.tc(c)}).then(function(b){return Ft(a,b)},function(){return c.input.match(/^#/)?Promise.reject(Error("Failed to resolve meeting alias.")):Ft(a,c.input,c.domain)})},Ft=function(a,c,b){b=b||void 0;var d=!b;c=new Qs(d,d?c:c+"@"+b,b,c,void 0,void 0);a.f.set(c.getId(),c);c=new pt(c);a.b.b.set(c.id,c);return c.nb};Dt.prototype.Ea=function(){return"HangoutSinkDiscoveryService"};
Dt.prototype.jb=function(){for(var a={},c=l(this.f.entries()),b=c.next();!b.done;b=c.next()){var d=l(b.value);b=d.next().value;d=d.next().value;a[b]=d}return[{cache:zt(this.b),manualHangouts:a}]};Dt.prototype.ib=function(){var a=Yl(this);if(a){At(this.b,a.cache);for(var c in a.manualHangouts){var b=a.manualHangouts[c];this.f.set(c,new Qs(b.Yl,b.Ka,b.sc,b.Pf,b.Tc,b.gf))}}};Dt.prototype.l=hb("mr.cloud.discovery.HangoutSinkDiscoveryService");var Bt=!1;var Jt=function(){this.f=!1;this.b=null;this.g=!1;this.l=hb("mr.cloud.identity.IdentityService");am(this);Ht(this);It(this)},Kt=function(a){return a.b?a.b.substr(a.b.indexOf("@")+1):""};Jt.prototype.getAuthToken=function(){return chrome.identity?new Promise(function(a,c){chrome.identity.getAuthToken({interactive:!1},function(b){chrome.runtime.lastError?c(Error("Unable to get user auth token: "+chrome.runtime.lastError.message)):null==b?c(Error("User is not logged in (no token found)")):a(b)})}):Promise.reject(Error("chrome.identity permission required for auth."))};
var Lt=function(a){return new Promise(function(c){chrome.identity.removeCachedAuthToken({token:a},function(){c()})})},It=function(a){a.getAuthToken().then(function(c){chrome.identity.getProfileUserInfo(function(b){a.f=!!b.email||!!b.id;a.b=b.email||null;c&&!a.f&&(a.g=!0)})},function(c){ob(a.l,"Unable to set sign in and email.",c)})},Ht=function(a){chrome.identity.onSignInChanged.addListener(function(c,b){$i(6);a.f=b;a.l.info("Signed in change: "+a.f);a.f?It(a):(a.b=null,a.g=!1)})},Mt=function(a){return a.getAuthToken().then(function(c){var b=
window.gapi;if(!b)return a.l.error("gapi not loaded."),!1;a.l.info("Setting gapi auth token");b.auth.setToken({access_token:c});return!0})};Jt.prototype.Ea=function(){return"IdentityService"};Jt.prototype.jb=function(){return[null,{signedIn:this.f,userEmail:this.b,kioskAuth:this.g}]};Jt.prototype.ib=function(){var a=Zl(this);a&&(a.signedIn&&(this.f=a.signedIn),a.userEmail&&(this.b=a.userEmail),a.kioskAuth&&(this.g=a.kioskAuth))};var Nt="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 Ot=function(a){var c=a.method,b=a.uri,d=a.baseUrl,e=a.Hc,f=a.Qm,g=a.headers,k=a.body,m=a.start,p=a.apiKey,v=a.fh;a=a.hb;this.method=c&&c.toUpperCase()||"GET";(c=b)||(d=[d].concat(n(e||[])).join("/"),d=new Tr(encodeURI(d)),f&&(f=is(f),Wr(d,f)),c=d);this.uri=c;p&&this.uri.f.add("key",p);this.b=a||null;this.headers=g||{};(this.body=k)&&(this.headers["Content-Type"]="application/json");this.fh=Ia(v)?v:1E4;this.start=m||u()},Pt=function(a){return(a.b?a.b.getAuthToken():Promise.resolve(null)).then(function(c){c&&
(a.headers.Authorization="Bearer "+c);c={method:a.method,headers:a.headers};a.body&&(c.body=JSON.stringify(a.body));return new Request(a.uri.toString(),c)})};var Qt={Nu:100,Lz:101,Qx:200,Ou:201,ACCEPTED:202,ux:203,Hx:204,Ny:205,by:206,ix:207,hx:300,dx:301,tv:302,kz:303,Ex:304,lA:305,Oz:307,iy:308,Ln:400,Xz:401,to:402,sv:403,Ax:404,Yw:405,xx:406,xy:407,Ly:408,Ju:409,Dv:410,Ew:411,qy:412,Iy:413,My:414,eA:415,Ky:416,gv:417,dA:422,Hw:423,hv:424,ry:428,Rz:429,Jy:431,jo:500,Bx:501,Wt:502,rz:503,yv:504,Tv:505,fw:507,ox:511,Ay:1223};var Rt=function(a,c){Eb.call(this,c&&c.message||a.statusText);this.code=a.status;this.response=a;this.status=(this.b=c)&&c.status};q(Rt,Eb);var Vt=function(a){if(St.has(a.code))return!0;var c=a.b||{};return a.b?Tt.has(c.status)?!0:!!(c.errors||[]).find(function(b){return Ut.has(b)}):!1},Wt=function(a,c){a=new Response(void 0,{status:c||408,statusText:a});return new Rt(a)},St=new Set([400,401,403,404,405,406,501]),Tt=new Set(["PERMISSION_DENIED"]),Ut=new Set("authError command_is_in_terminal_state forbidden notFound unmanaged_group_acl acl_entry_bad_scope network_error".split(" "));var W=function(){this.Oc=this.Oc;this.Ua=this.Ua};W.prototype.Oc=!1;W.prototype.w=function(){return this.Oc};W.prototype.Za=function(){this.Oc||(this.Oc=!0,this.ia())};W.prototype.b=function(a){Xt(this,db(Yt,a))};var Xt=function(a,c){a.Oc?Ia(void 0)?c.call(void 0):c():(a.Ua||(a.Ua=[]),a.Ua.push(Ia(void 0)?t(c,void 0):c))};W.prototype.ia=function(){if(this.Ua)for(;this.Ua.length;)this.Ua.shift()()};
var Yt=function(a){a&&"function"==typeof a.Za&&a.Za()},Zt=function(a){for(var c=0,b=arguments.length;c<b;++c){var d=arguments[c];Wa(d)?Zt.apply(null,d):Yt(d)}};var X=function(a,c){this.type=a;this.g=this.target=c;this.Zm=!0};X.prototype.h=function(){this.Zm=!1};var $t=!Be||9<=Number(We),au=Be&&!Ve("9"),bu=function(){if(!Ha.addEventListener||!Object.defineProperty)return!1;var a=!1,c=Object.defineProperty({},"passive",{get:function(){a=!0}});try{Ha.addEventListener("test",Qa,c),Ha.removeEventListener("test",Qa,c)}catch(b){}return a}();var cu=function(a,c){X.call(this,a?a.type:"");this.relatedTarget=this.g=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,c)};x(cu,X);var du=vf({2:"touch",3:"pen",4:"mouse"});
cu.prototype.init=function(a,c){var b=this.type=a.type,d=a.changedTouches&&a.changedTouches.length?a.changedTouches[0]:null;this.target=a.target||a.srcElement;this.g=c;(c=a.relatedTarget)?De&&(we(c,"nodeName")||(c=null)):"mouseover"==b?c=a.fromElement:"mouseout"==b&&(c=a.toElement);this.relatedTarget=c;d?(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.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.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=Ja(a.pointerType)?a.pointerType:du[a.pointerType]||"";this.state=a.state;this.b=a;a.defaultPrevented&&this.h()};
cu.prototype.h=function(){cu.Ga.h.call(this);var a=this.b;if(a.preventDefault)a.preventDefault();else if(a.returnValue=!1,au)try{if(a.ctrlKey||112<=a.keyCode&&123>=a.keyCode)a.keyCode=-1}catch(c){}};var eu="closure_listenable_"+(1E6*Math.random()|0),fu=function(a){return!(!a||!a[eu])},gu=0;var hu=function(a,c,b,d,e){this.listener=a;this.proxy=null;this.src=c;this.type=b;this.capture=!!d;this.Sc=e;this.key=++gu;this.removed=this.uh=!1},iu=function(a){a.removed=!0;a.listener=null;a.proxy=null;a.src=null;a.Sc=null};var ju=function(a){this.src=a;this.b={};this.f=0};ju.prototype.add=function(a,c,b,d,e){var f=a.toString();a=this.b[f];a||(a=this.b[f]=[],this.f++);var g=ku(a,c,d,e);-1<g?(c=a[g],b||(c.uh=!1)):(c=new hu(c,this.src,f,!!d,e),c.uh=b,a.push(c));return c};ju.prototype.remove=function(a,c,b,d){a=a.toString();if(!(a in this.b))return!1;var e=this.b[a];c=ku(e,c,b,d);return-1<c?(iu(e[c]),$b(e,c),0==e.length&&(delete this.b[a],this.f--),!0):!1};
var lu=function(a,c){var b=c.type;if(!(b in a.b))return!1;var d=ac(a.b[b],c);d&&(iu(c),0==a.b[b].length&&(delete a.b[b],a.f--));return d};ju.prototype.removeAll=function(a){a=a&&a.toString();var c=0,b;for(b in this.b)if(!a||b==a){for(var d=this.b[b],e=0;e<d.length;e++)++c,iu(d[e]);delete this.b[b];this.f--}return c};var mu=function(a,c,b,d,e){a=a.b[c.toString()];c=-1;a&&(c=ku(a,b,d,e));return-1<c?a[c]:null};
ju.prototype.hasListener=function(a,c){var b=Ia(a),d=b?a.toString():"",e=Ia(c);return Ac(this.b,function(f){for(var g=0;g<f.length;++g)if(!(b&&f[g].type!=d||e&&f[g].capture!=c))return!0;return!1})};var ku=function(a,c,b,d){for(var e=0;e<a.length;++e){var f=a[e];if(!f.removed&&f.listener==c&&f.capture==!!b&&f.Sc==d)return e}return-1};var nu="closure_lm_"+(1E6*Math.random()|0),ou={},pu=0,ru=function(a,c,b,d,e){if(d&&d.once)return qu(a,c,b,d,e);if(Ua(c)){for(var f=0;f<c.length;f++)ru(a,c[f],b,d,e);return null}b=su(b);return fu(a)?a.listen(c,b,Ya(d)?!!d.capture:!!d,e):tu(a,c,b,!1,d,e)},tu=function(a,c,b,d,e,f){if(!c)throw Error("Invalid event type");var g=Ya(e)?!!e.capture:!!e,k=uu(a);k||(a[nu]=k=new ju(a));b=k.add(c,b,d,g,f);if(b.proxy)return b;d=aaa();b.proxy=d;d.src=a;d.listener=b;if(a.addEventListener)bu||(e=g),void 0===e&&(e=
!1),a.addEventListener(c.toString(),d,e);else if(a.attachEvent)a.attachEvent(vu(c.toString()),d);else if(a.addListener&&a.removeListener)a.addListener(d);else throw Error("addEventListener and attachEvent are unavailable.");pu++;return b},aaa=function(){var a=baa,c=$t?function(b){return a.call(c.src,c.listener,b)}:function(b){b=a.call(c.src,c.listener,b);if(!b)return b};return c},qu=function(a,c,b,d,e){if(Ua(c)){for(var f=0;f<c.length;f++)qu(a,c[f],b,d,e);return null}b=su(b);return fu(a)?wu(a,c,b,
Ya(d)?!!d.capture:!!d,e):tu(a,c,b,!0,d,e)},xu=function(a,c,b,d,e){if(Ua(c))for(var f=0;f<c.length;f++)xu(a,c[f],b,d,e);else d=Ya(d)?!!d.capture:!!d,b=su(b),fu(a)?a.L.remove(String(c),b,d,e):a&&(a=uu(a))&&(c=mu(a,c,b,d,e))&&yu(c)},yu=function(a){if(r(a)||!a||a.removed)return!1;var c=a.src;if(fu(c))return lu(c.L,a);var b=a.type,d=a.proxy;c.removeEventListener?c.removeEventListener(b,d,a.capture):c.detachEvent?c.detachEvent(vu(b),d):c.addListener&&c.removeListener&&c.removeListener(d);pu--;(b=uu(c))?
(lu(b,a),0==b.f&&(b.src=null,c[nu]=null)):iu(a);return!0},zu=function(a){if(a)if(fu(a))a.Vj(void 0);else if(a=uu(a)){var c=0,b;for(b in a.b)for(var d=a.b[b].concat(),e=0;e<d.length;++e)yu(d[e])&&++c}},vu=function(a){return a in ou?ou[a]:ou[a]="on"+a},Bu=function(a,c,b,d){var e=!0;if(a=uu(a))if(c=a.b[c.toString()])for(c=c.concat(),a=0;a<c.length;a++){var f=c[a];f&&f.capture==b&&!f.removed&&(f=Au(f,d),e=e&&!1!==f)}return e},Au=function(a,c){var b=a.listener,d=a.Sc||a.src;a.uh&&yu(a);return b.call(d,
c)},baa=function(a,c){if(a.removed)return!0;if(!$t){var b=c||Pa("window.event");c=new cu(b,this);var d=!0;if(!(0>b.keyCode||void 0!=b.returnValue)){a:{var e=!1;if(0==b.keyCode)try{b.keyCode=-1;break a}catch(g){e=!0}if(e||void 0==b.returnValue)b.returnValue=!0}b=[];for(e=c.g;e;e=e.parentNode)b.push(e);a=a.type;for(e=b.length-1;0<=e;e--){c.g=b[e];var f=Bu(b[e],a,!0,c);d=d&&f}for(e=0;e<b.length;e++)c.g=b[e],f=Bu(b[e],a,!1,c),d=d&&f}return d}return Au(a,new cu(c,this))},uu=function(a){a=a[nu];return a instanceof
ju?a:null},Cu="__closure_events_fn_"+(1E9*Math.random()>>>0),su=function(a){if(Xa(a))return a;a[Cu]||(a[Cu]=function(c){return a.handleEvent(c)});return a[Cu]};var Y=function(){W.call(this);this.L=new ju(this);this.jg=this;this.D=null};x(Y,W);Y.prototype[eu]=!0;h=Y.prototype;h.addEventListener=function(a,c,b,d){ru(this,a,c,b,d)};h.removeEventListener=function(a,c,b,d){xu(this,a,c,b,d)};
h.N=function(a){var c,b=this.D;if(b)for(c=[];b;b=b.D)c.push(b);b=this.jg;var d=a.type||a;if(Ja(a))a=new X(a,b);else if(a instanceof X)a.target=a.target||b;else{var e=a;a=new X(d,b);Pc(a,e)}e=!0;if(c)for(var f=c.length-1;0<=f;f--){var g=a.g=c[f];e=g.Ff(d,!0,a)&&e}g=a.g=b;e=g.Ff(d,!0,a)&&e;e=g.Ff(d,!1,a)&&e;if(c)for(f=0;f<c.length;f++)g=a.g=c[f],e=g.Ff(d,!1,a)&&e;return e};h.ia=function(){Y.Ga.ia.call(this);this.Vj();this.D=null};h.listen=function(a,c,b,d){return this.L.add(String(a),c,!1,b,d)};
var wu=function(a,c,b,d,e){return a.L.add(String(c),b,!0,d,e)};Y.prototype.Vj=function(a){this.L&&this.L.removeAll(a)};Y.prototype.Ff=function(a,c,b){a=this.L.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==c){var g=f.listener,k=f.Sc||f.src;f.uh&&lu(this.L,f);d=!1!==g.call(k,b)&&d}}return d&&0!=b.Zm};Y.prototype.hasListener=function(a,c){return this.L.hasListener(Ia(a)?String(a):void 0,c)};var Du=function(a,c){this.g=a;this.h=c;this.f=0;this.b=null};Du.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 Eu=function(a,c){a.h(c);100>a.f&&(a.f++,c.next=a.b,a.b=c)};var Fu=function(a){Ha.setTimeout(function(){throw a;},0)},Gu,caa=function(){var a=Ha.MessageChannel;"undefined"===typeof a&&"undefined"!==typeof window&&window.postMessage&&window.addEventListener&&!$d("Presto")&&(a=function(){var e=document.createElement("IFRAME");e.style.display="none";le(e);document.documentElement.appendChild(e);var f=e.contentWindow;e=f.document;e.open();e.write(ee(ge));e.close();var g="callImmediate"+Math.random(),k="file:"==f.location.protocol?"*":f.location.protocol+"//"+
f.location.host;e=t(function(m){if(("*"==k||m.origin==k)&&m.data==g)this.port1.onmessage()},this);f.addEventListener("message",e,!1);this.port1={};this.port2={postMessage:function(){f.postMessage(g,k)}}});if("undefined"!==typeof a&&!$d("Trident")&&!$d("MSIE")){var c=new a,b={},d=b;c.port1.onmessage=function(){if(Ia(b.next)){b=b.next;var e=b.rl;b.rl=null;e()}};return function(e){d.next={rl:e};d=d.next;c.port2.postMessage(0)}}return"undefined"!==typeof document&&"onreadystatechange"in document.createElement("SCRIPT")?
function(e){var f=document.createElement("SCRIPT");f.onreadystatechange=function(){f.onreadystatechange=null;f.parentNode.removeChild(f);f=null;e();e=null};document.documentElement.appendChild(f)}:function(e){Ha.setTimeout(e,0)}};var Hu=function(){this.f=this.b=null},Ju=new Du(function(){return new Iu},function(a){a.reset()});Hu.prototype.add=function(a,c){var b=Ju.get();b.set(a,c);this.f?this.f.next=b:this.b=b;this.f=b};Hu.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 Iu=function(){this.next=this.scope=this.b=null};Iu.prototype.set=function(a,c){this.b=a;this.scope=c;this.next=null};Iu.prototype.reset=function(){this.next=this.scope=this.b=null};var Nu=function(a,c){Ku||daa();Lu||(Ku(),Lu=!0);Mu.add(a,c)},Ku,daa=function(){if(Ha.Promise&&Ha.Promise.resolve){var a=Ha.Promise.resolve(void 0);Ku=function(){a.then(Ou)}}else Ku=function(){var c=Ou;!Xa(Ha.setImmediate)||Ha.Window&&Ha.Window.prototype&&!$d("Edge")&&Ha.Window.prototype.setImmediate==Ha.setImmediate?(Gu||(Gu=caa()),Gu(c)):Ha.setImmediate(c)}},Lu=!1,Mu=new Hu,Ou=function(){for(var a;a=Mu.remove();){try{a.b.call(a.scope)}catch(c){Fu(c)}Eu(Ju,a)}Lu=!1};var Pu=function(a){a.prototype.$goog_Thenable=!0},Qu=function(a){if(!a)return!1;try{return!!a.$goog_Thenable}catch(c){return!1}};var Tu=function(a,c){this.b=0;this.m=void 0;this.h=this.f=this.g=null;this.j=this.w=!1;if(a!=Qa)try{var b=this;a.call(c,function(d){Ru(b,2,d)},function(d){if(!(d instanceof Su))try{if(d instanceof Error)throw d;throw Error("Promise rejected.");}catch(e){}Ru(b,3,d)})}catch(d){Ru(this,3,d)}},Uu=function(){this.next=this.context=this.f=this.h=this.b=null;this.g=!1};Uu.prototype.reset=function(){this.context=this.f=this.h=this.b=null;this.g=!1};
var Vu=new Du(function(){return new Uu},function(a){a.reset()}),Wu=function(a,c,b){var d=Vu.get();d.h=a;d.f=c;d.context=b;return d},Xu=function(a){if(a instanceof Tu)return a;var c=new Tu(Qa);Ru(c,2,a);return c},Yu=function(a){return new Tu(function(c,b){b(a)})},$u=function(a,c,b){Zu(a,c,b,null)||Nu(db(c,a))},av=function(a){return new Tu(function(c,b){a.length||c(void 0);for(var d=0,e;d<a.length;d++)e=a[d],$u(e,c,b)})},bv=function(a){return new Tu(function(c,b){var d=a.length,e=[];if(d)for(var f=
function(p,v){d--;e[p]=v;0==d&&c(e)},g=function(p){b(p)},k=0,m;k<a.length;k++)m=a[k],$u(m,db(f,k),g);else c(e)})},cv=function(a){return new Tu(function(c){var b=a.length,d=[];if(b)for(var e=function(k,m,p){b--;d[k]=m?{ae:!0,value:p}:{ae:!1,reason:p};0==b&&c(d)},f=0,g;f<a.length;f++)g=a[f],$u(g,db(e,f,!0),db(e,f,!1));else c(d)})},dv=function(){var a,c,b=new Tu(function(d,e){a=d;c=e});return new eaa(b,a,c)};Tu.prototype.then=function(a,c,b){return ev(this,Xa(a)?a:null,Xa(c)?c:null,b)};Pu(Tu);
var gv=function(a,c,b){c=Wu(c,c,b);c.g=!0;fv(a,c);return a},hv=function(a,c,b){return ev(a,null,c,b)};Tu.prototype.cancel=function(a){0==this.b&&Nu(function(){var c=new Su(a);iv(this,c)},this)};
var iv=function(a,c){if(0==a.b)if(a.g){var b=a.g;if(b.f){for(var d=0,e=null,f=null,g=b.f;g&&(g.g||(d++,g.b==a&&(e=g),!(e&&1<d)));g=g.next)e||(f=g);e&&(0==b.b&&1==d?iv(b,c):(f?(d=f,d.next==b.h&&(b.h=d),d.next=d.next.next):jv(b),kv(b,e,3,c)))}a.g=null}else Ru(a,3,c)},fv=function(a,c){a.f||2!=a.b&&3!=a.b||lv(a);a.h?a.h.next=c:a.f=c;a.h=c},ev=function(a,c,b,d){var e=Wu(null,null,null);e.b=new Tu(function(f,g){e.h=c?function(k){try{var m=c.call(d,k);f(m)}catch(p){g(p)}}:f;e.f=b?function(k){try{var m=b.call(d,
k);!Ia(m)&&k instanceof Su?g(k):f(m)}catch(p){g(p)}}:g});e.b.g=a;fv(a,e);return e.b};Tu.prototype.s=function(a){this.b=0;Ru(this,2,a)};Tu.prototype.D=function(a){this.b=0;Ru(this,3,a)};
var Ru=function(a,c,b){0==a.b&&(a===b&&(c=3,b=new TypeError("Promise cannot resolve to itself")),a.b=1,Zu(b,a.s,a.D,a)||(a.m=b,a.b=c,a.g=null,lv(a),3!=c||b instanceof Su||faa(a,b)))},Zu=function(a,c,b,d){if(a instanceof Tu)return fv(a,Wu(c||Qa,b||null,d)),!0;if(Qu(a))return a.then(c,b,d),!0;if(Ya(a))try{var e=a.then;if(Xa(e))return gaa(a,e,c,b,d),!0}catch(f){return b.call(d,f),!0}return!1},gaa=function(a,c,b,d,e){var f=!1,g=function(m){f||(f=!0,b.call(e,m))},k=function(m){f||(f=!0,d.call(e,m))};try{c.call(a,
g,k)}catch(m){k(m)}},lv=function(a){a.w||(a.w=!0,Nu(a.o,a))},jv=function(a){var c=null;a.f&&(c=a.f,a.f=c.next,c.next=null);a.f||(a.h=null);return c};Tu.prototype.o=function(){for(var a;a=jv(this);)kv(this,a,this.b,this.m);this.w=!1};
var kv=function(a,c,b,d){if(3==b&&c.f&&!c.g)for(;a&&a.j;a=a.g)a.j=!1;if(c.b)c.b.g=null,mv(c,b,d);else try{c.g?c.h.call(c.context):mv(c,b,d)}catch(e){nv.call(null,e)}Eu(Vu,c)},mv=function(a,c,b){2==c?a.h.call(a.context,b):a.f&&a.f.call(a.context,b)},faa=function(a,c){a.j=!0;Nu(function(){a.j&&nv.call(null,c)})},nv=Fu,Su=function(a){Eb.call(this,a)};x(Su,Eb);Su.prototype.name="cancel";var eaa=function(a,c,b){this.Y=a;this.resolve=c;this.reject=b};var ov=function(a,c){Y.call(this);this.h=a||1;this.g=c||Ha;this.j=t(this.o,this);this.m=u()};x(ov,Y);ov.prototype.enabled=!1;ov.prototype.f=null;var pv=function(a,c){a.h=c;a.f&&a.enabled?(a.stop(),a.start()):a.f&&a.stop()};ov.prototype.o=function(){if(this.enabled){var a=u()-this.m;0<a&&a<.8*this.h?this.f=this.g.setTimeout(this.j,this.h-a):(this.f&&(this.g.clearTimeout(this.f),this.f=null),this.N("tick"),this.enabled&&(this.stop(),this.start()))}};
ov.prototype.start=function(){this.enabled=!0;this.f||(this.f=this.g.setTimeout(this.j,this.h),this.m=u())};ov.prototype.stop=function(){this.enabled=!1;this.f&&(this.g.clearTimeout(this.f),this.f=null)};ov.prototype.ia=function(){ov.Ga.ia.call(this);this.stop();delete this.g};
var qv=function(a,c,b){if(Xa(a))b&&(a=t(a,b));else if(a&&"function"==typeof a.handleEvent)a=t(a.handleEvent,a);else throw Error("Invalid listener argument");return 2147483647<Number(c)?-1:Ha.setTimeout(a,c||0)},rv=function(a){Ha.clearTimeout(a)},sv=function(a){var c=null;return hv(new Tu(function(b,d){c=qv(function(){b(void 0)},a);-1==c&&d(Error("Failed to schedule timer."))}),function(b){rv(c);throw b;})};var tv=function(){var a=void 0===a?!0:a;this.l=Mf("mr.cloud.slarti.Fetcher");this.b=0;this.f=a};tv.prototype.execute=function(a){var c=this,b="Fetch call "+ ++this.b,d=new ef(function(){return haa(c,b,a,function(e){return d.abort(e)})},1E3,this.f?5:1);return d.start()};
var haa=function(a,c,b,d){var e=b.uri.toString().replace(/\?.*/,"?<redacted>"),f=b.method+" "+e;C(a.l,c+": "+f);e=[Pt(b).then(function(g){return Promise.resolve(fetch(g))})];b.fh&&e.push(sv(b.fh).then(function(){throw Wt("API call timed out",504);}));return Promise.race(e).then(function(g){if(!g.ok)return g.json().then(function(m){return m},function(){return null}).then(function(m){var p;m&&m instanceof Object&&m.error&&(p=m.error);throw new Rt(g,p);});var k=(u()-b.start)/1E3;C(a.l,c+" succeeded: "+
f+" duration = "+k+"s");return(k=g.headers.get("content-type"))&&k.includes("application/json")?g.json():k&&(k.includes("image")||k.includes("application/octet-stream"))?g.blob():g.text()},function(g){var k="";if(g instanceof Rt)k=", ("+g.status+"): "+g.message,Vt(g)&&d(g);else{try{k=", "+JSON.stringify(g,null,2)}catch(m){}g instanceof Error&&"Failed to fetch"==g.message&&(g=Wt(g.message))}Of(a.l,c+" failed: "+k);throw g;})};var uv=function(a,c){this.b=Ms.b;this.hb=a;this.f=c};var vv=function(a,c){uv.call(this,a,c)};q(vv,uv);vv.prototype.register=function(a){a=new Ot({method:"POST",baseUrl:this.b,Hc:["user:register"],hb:this.hb,body:{gcmId:a}});return this.f.execute(a)};vv.prototype.unregister=function(a){a=new Ot({method:"POST",baseUrl:this.b,Hc:["user:unregister"],hb:this.hb,body:{gcmId:a}});return this.f.execute(a)};var iaa=function(a,c,b){this.l=hb("mr.cloud.slarti.GcmRegistration");this.g=a;this.f=c;this.h=b;this.b=null},jaa=function(a){if(!a.b){var c=a.f["mr.cloud.slarti.GcmRegistration.ID"];a.b=a.h.register(["307539924703"]).then(function(b){if(b==c)ob(a.l,"Slarti GCM ID unchanged: "+b);else return ob(a.l,"Got new Slarti GCM ID: "+b),(c?wv(a,c):Promise.resolve()).then(function(){return a.g.register(b).then(function(){a.f["mr.cloud.slarti.GcmRegistration.ID"]=b})})},function(b){a.l.G("Error registering for GCM notifications",
b);c&&wv(a,c).catch(function(d){a.l.G("Failed to unregister GCM ID with Slarti",d)});throw b;});a.b.then(function(){a.b=null},function(){a.b=null})}return a.b},wv=function(a,c){return a.g.unregister(c).then(function(){delete a.f["mr.cloud.slarti.GcmRegistration.ID"]},function(b){a.l.G("Failed to unregister GCM ID with Slarti",b)})};var xv=null,yv=function(){Bp.call(this,5,"mr.cloud.slarti.GcmEventListener","mr.cloud.slarti.SinkDiscoveryService",chrome.gcm.onMessage);this.l=hb("mr.cloud.slarti.GcmEventListener")};q(yv,Bp);yv.prototype.hh=function(a){if(a&&"307539924703"==a.from&&"object"==typeof a.data&&"string"==typeof a.data.data){var c=JSON.parse(a.data.data);a=c.type;c=c.id;if(a)return this.l.info("Received Slarti GCM notification: "+a+" ("+c+")"),!0}return!1};var zv=function(){null==xv&&(xv=new yv);return xv};var Av=function(a,c){for(var b=[],d=1;d<arguments.length;++d)b[d-1]=arguments[d];d=a;b=l(b);for(var e=b.next();!e.done;e=b.next()){if(void 0==d||"object"!=typeof d)return;d=d[e.value]}return d};var Bv=function(){Bp.call(this,5,"cloud.GcmEventListener","mr.cloud.discovery.WeaveSinkDiscoveryService",chrome.gcm.onMessage);this.l=hb("mr.WeaveGcmEventListener")};q(Bv,Bp);Bv.prototype.hh=function(a){if(!a||"919648714761"!=a.from)return!1;a=Av(a,"data","notification");if(!a)return this.l.error("Notification json not found"),!1;try{var c=JSON.parse(a);return!!c&&Array.isArray(c.events)&&0<c.events.length}catch(b){return this.l.error("Invalid json: "+a),!1}};
var Dv=function(){Cv||(Cv=new Bv);return Cv},Cv=null;var Ev=function(a){this.b=a;this.l=hb("mr.cloud.messaging.WeaveGcmMessageHandler")};Ev.prototype.onMessage=function(a){var c=this;a=JSON.parse(a.data.notification);var b=um();a.events.forEach(function(d){if(d.deviceId){var e=vm(b,d.deviceId);switch(d.type){case "deviceCreated":kaa(c,d);break;case "deviceUpdated":laa(c,d,e);break;case "deviceDeleted":maa(c.b,{sinkId:e});break;default:ob(c.l,function(){return"[unhandled event] "+JSON.stringify(d)})}}else c.l.error("Device ID not provided")})};
var kaa=function(a,c){var b=Av(c,"statePatch","_cloudCast","settings","receiverName");"string"!=typeof b?a.l.error("Receiver name not a string: "+b):(c=new ot(c.deviceId,b,"owner","default",!0),a=a.b,a.b.b.set(c.id,c),a.b.f=Date.now(),vt(a.f,[c.nb]))},laa=function(a,c,b){c=Av(c,"statePatch","_cloudCast","appStatus");if("string"!=typeof c)a.l.error("App status not a string: "+c);else if(a=a.b,c="available"==c,b=a.b.ra(b))b.isAvailable=c||!1,a.b.f=Date.now(),wt(a.f,[b.nb])};var Fv=function(a,c){this.g=a;this.f=c;this.b=new rt(this.fr.bind(this),c,2E4);this.h=new Ev(this);Dv().addListener();am(this);Xi("mr.cloud.discovery.WeaveSinkDiscoveryService",this)};q(Fv,Ni);h=Fv.prototype;h.fe=function(){var a=this;mt(this.g).then(function(c){a.g.subscribe(c)},function(){});return this.b.fe().filter(function(c){return c.isAvailable})};h.ra=function(a){return this.b.ra(a)};
h.handleEvent=function(a,c){for(var b=[],d=1;d<arguments.length;++d)b[d-1]=arguments[d];if(a==chrome.gcm.onMessage)this.h.onMessage.apply(this.h,n(b));else throw Error("Unhandled event: expected chrome.gcm.onMessage");};
h.fr=function(){return kt(this.g,{descriptionSubstring:"Chrome Streaming Receiver"}).then(function(a){return a.map(function(c){Bb("MediaRouter.Cloud.CloudReceiver.Sink.Discovered");var b=c.isAvailable()&&!(c.b.invitations&&0!=c.b.invitations.length);return new ot(c.getId(),c.f(),c.b.personalizedInfo.maxRole,"default",b)})})};h.Ea=function(){return"WeaveSinkDiscoveryService"};h.jb=function(){return[{cache:zt(this.b)}]};h.ib=function(){var a=Yl(this);a&&At(this.b,a.cache)};
var maa=function(a,c){if(c=a.b.ra(c.sinkId))a.b.b.delete(c.id),a.b.f=Date.now(),xt(a.f,[c.nb])};var Gv=Ha.JSON.parse,Hv=Ha.JSON.stringify;var Iv=function(a,c,b,d,e,f,g,k,m){W.call(this);this.f=null;this.C=!1;this.D=dv();this.g=[];this.s=a?encodeURIComponent(String(a)):null;this.F=null;!d&&c&&(this.F=c);this.J=b||null;this.h=!d;this.j=null!=e?e:null;this.o=f||null;this.O=!!g;this.L=k||null;this.m=null!=m?m:null};q(Iv,W);Iv.prototype.init=function(){var a=t(function(b){this.f=b;var d=Pa("auth",b);Pa("client.request",b)&&d?this.H():b.load("client",t(this.H,this))},this),c=Jv("gapi");c?a(c.gapi):naa(this,a);return this.D.Y};
var Jv=function(a){for(var c=window,b=Pa(a,c);!b&&c!=window.top&&oaa(c.parent,a);)c=c.parent,b=Pa(a,c);return b?c:null},oaa=function(a,c){try{return!!a&&null!=a.location.href&&we(a,c)}catch(b){return!1}},naa=function(a,c){var b=Jv("gapi_onload");if(b){var d=b.gapi_onload;b.gapi_onload=function(){d();c(b.gapi)}}else{window.gapi_onload=function(){c(window.gapi)};var e=document.createElement("SCRIPT");me(e,paa);a.L&&Yf(e,Hv(a.L));document.getElementsByTagName("head")[0].appendChild(e)}};
Iv.prototype.H=function(){for(var a=0;a<this.g.length;a++)this.g[a].ub.resolve(Kv(this,this.g[a].requestData));this.C=!0;this.D.resolve(this.f)};Iv.prototype.sendRequest=function(a){if(this.C)return Kv(this,a);var c=dv();this.g.push({requestData:a,ub:c});return c.Y};
var Kv=function(a,c){var b=Pa("config.get",a.f);if(!a.h){var d=b("googleapis.config/auth/useFirstPartyAuth");var e=b("googleapis.config/auth/useOriginToken")}var f;null!=a.j&&(f=b("client/cors"));var g;null!=a.m&&(g=b("client/xd4"));try{var k=Pa("config.update",a.f);a.h||(k("googleapis.config/auth/useFirstPartyAuth",!1),k("googleapis.config/auth/useOriginToken",!1));null!=a.j&&k("client/cors",a.j);null!=a.m&&k("client/xd4",a.m);var m=qaa(a);c.headers&&Pc(m,c.headers);var p={headers:m,root:a.J,path:c.path,
method:c.method,body:c.body},v=c.params||{};a.s&&!a.o?Pc(v,{key:a.s}):a.o&&Pc(v,{key:null});Jc(v)||(p.params=v);var A=Xu(Pa("client.request",a.f)(p));c.callback&&A.then(function(G){c.callback.apply(null,[G.result,G])},function(G){c.callback.apply(null,[G.result,G])});return A}finally{b=Pa("config.update",a.f),a.h||(b("googleapis.config/auth/useFirstPartyAuth",d),b("googleapis.config/auth/useOriginToken",e)),null!=a.j&&b("client/cors",f),null!=a.m&&b("client/xd4",g)}},qaa=function(a){if(a.h){if(a.o)return{Authorization:"Bearer "+
a.o};var c=Pa("auth.getAuthHeaderValueForFirstParty",a.f);return{Authorization:a.O?c([]):c(),"X-Goog-AuthUser":a.F}}return{}},paa=hd(Uc(new Tc(Rc,"https://apis.google.com/js/client.js")));var raa=function(a){this.b=a},Xs=function(a,c,b){var d="";c.forEach(function(e){d+="/"+encodeURIComponent(e)});a=new Tr(a+d);b&&(b=is(b),Wr(a,b));return a},Ys=function(a,c,b,d){return a.b.getAuthToken().then(function(e){var f=saa(e);return taa(f,c,b,d).catch(function(g){if("INVALID_ACCESS_ERROR"==g)return uaa(a,e,c,b,d);throw g;})})},uaa=function(a,c,b,d,e){return Lt(c).then(function(){return Ys(a,b,d,e)})},taa=function(a,c,b,d){return new Promise(function(e,f){a.sendRequest(vaa(c,b,function(g){g&&
!g.error?e(g):g&&401==g.error.code?f("INVALID_ACCESS_ERROR"):f(g&&g.error?g.error.errors?g.error.errors[0]:g:Error(g))},d))})},saa=function(a){a=new Iv(void 0,void 0,void 0,!1,!1,a);a.init();return a},vaa=function(a,c,b,d){a={callback:b,method:c,path:a.toString()};d&&(a.body=d);return a};var Lv={Gu:{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"}},Fu:{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"}}},Mv=Lv;Mv=Lv;var waa={AED:[2,"dh","\u062f.\u0625."],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 Nv={uk:".",di:",",Jk:"%",ji:"0",uo:"+",Ek:"-",yk:"E",Kk:"\u2030",ei:"\u221e",po:"NaN",Sn:"#,##0.###",iz:"#E0",hy:"#,##0%",Tu:"\u00a4#,##0.00",vk:"USD"},Ov=Nv;Ov=Nv;var Qv=function(){this.D=40;this.f=1;this.g=3;this.F=this.w=0;this.J=!1;this.C=this.o="";this.h=Ov.Ek;this.s="";this.b=1;this.m=!1;this.j=[];this.L=this.H=!1;var a=Ov.Sn;a.replace(/ /g,"\u00a0");var c=[0];this.o=Pv(this,a,c);for(var b=c[0],d=-1,e=0,f=0,g=0,k=-1,m=a.length,p=!0;c[0]<m&&p;c[0]++)switch(a.charAt(c[0])){case "#":0<f?g++:e++;0<=k&&0>d&&k++;break;case "0":if(0<g)throw Error('Unexpected "0" in pattern "'+a+'"');f++;0<=k&&0>d&&k++;break;case ",":0<k&&this.j.push(k);k=0;break;case ".":if(0<=
d)throw Error('Multiple decimal separators in pattern "'+a+'"');d=e+f+g;break;case "E":if(this.L)throw Error('Multiple exponential symbols in pattern "'+a+'"');this.L=!0;this.F=0;c[0]+1<m&&"+"==a.charAt(c[0]+1)&&(c[0]++,this.J=!0);for(;c[0]+1<m&&"0"==a.charAt(c[0]+1);)c[0]++,this.F++;if(1>e+f||1>this.F)throw Error('Malformed exponential pattern "'+a+'"');p=!1;break;default:c[0]--,p=!1}0==f&&0<e&&0<=d&&(f=d,0==f&&f++,g=e-f,e=f-1,f=1);if(0>d&&0<g||0<=d&&(d<e||d>e+f)||0==k)throw Error('Malformed pattern "'+
a+'"');g=e+f+g;this.g=0<=d?g-d:0;0<=d&&(this.w=e+f-d,0>this.w&&(this.w=0));this.f=(0<=d?d:g)-e;this.L&&(this.D=e+this.f,0==this.g&&0==this.f&&(this.f=1));this.j.push(Math.max(0,k));this.H=0==d||d==g;b=c[0]-b;this.C=Pv(this,a,c);c[0]<a.length&&";"==a.charAt(c[0])?(c[0]++,1!=this.b&&(this.m=!0),this.h=Pv(this,a,c),c[0]+=b,this.s=Pv(this,a,c)):(this.h+=this.o,this.s+=this.C)};
Qv.prototype.parse=function(a,c){c=c||[0];a=a.replace(/ |\u202f/g,"\u00a0");var b=a.indexOf(this.o,c[0])==c[0],d=a.indexOf(this.h,c[0])==c[0];b&&d&&(this.o.length>this.h.length?d=!1:this.o.length<this.h.length&&(b=!1));b?c[0]+=this.o.length:d&&(c[0]+=this.h.length);if(a.indexOf(Ov.ei,c[0])==c[0]){c[0]+=Ov.ei.length;var e=Infinity}else{e=a;var f=!1,g=!1,k=!1,m=-1,p=1,v=Ov.uk,A=Ov.di,G=Ov.yk;A=A.replace(/\u202f/g,"\u00a0");for(var E="";c[0]<e.length;c[0]++){var P=e.charAt(c[0]),ea=Rv(P);if(0<=ea&&9>=
ea)E+=ea,k=!0;else if(P==v.charAt(0)){if(f||g)break;E+=".";f=!0}else if(P==A.charAt(0)&&("\u00a0"!=A.charAt(0)||c[0]+1<e.length&&0<=Rv(e.charAt(c[0]+1)))){if(f||g)break}else if(P==G.charAt(0)){if(g)break;E+="E";g=!0;m=c[0]}else if("+"==P||"-"==P){if(k&&m!=c[0]-1)break;E+=P}else if(1==this.b&&P==Ov.Jk.charAt(0)){if(1!=p)break;p=100;if(k){c[0]++;break}}else if(1==this.b&&P==Ov.Kk.charAt(0)){if(1!=p)break;p=1E3;if(k){c[0]++;break}}else break}1!=this.b&&(p=this.b);e=parseFloat(E)/p}if(b){if(a.indexOf(this.C,
c[0])!=c[0])return NaN;c[0]+=this.C.length}else if(d){if(a.indexOf(this.s,c[0])!=c[0])return NaN;c[0]+=this.s.length}return d?-e:e};
Qv.prototype.format=function(a){if(isNaN(a))return Ov.po;var c=[];var b=xaa;a=Sv(a,-b.cq);c.push(b.prefix);var d=0>a||0==a&&0>1/a;c.push(d?this.h:this.o);if(isFinite(a))if(a=a*(d?-1:1)*this.b,this.L)if(0==a)Tv(this,a,this.f,c),Uv(this,0,c);else{var e=Math.floor(Math.log(a)/Math.log(10)+2E-15);a=Sv(a,-e);var f=this.f;1<this.D&&this.D>this.f?(f=e%this.D,0>f&&(f=this.D+f),a=Sv(a,f),e-=f,f=1):1>this.f?(e++,a=Sv(a,-1)):(e-=this.f-1,a=Sv(a,this.f-1));Tv(this,a,f,c);Uv(this,e,c)}else Tv(this,a,this.f,c);
else c.push(Ov.ei);c.push(d?this.s:this.C);c.push(b.qt);return c.join("")};
var Tv=function(a,c,b,d){if(a.w>a.g)throw Error("Min value must be less than max value");d||(d=[]);var e=Sv(c,a.g);e=Math.round(e);if(isFinite(e)){c=Math.floor(Sv(e,-a.g));var f=Math.floor(e-Sv(c,a.g))}else f=0;e=c;c=f;var g=e;f=c;var k=0<a.w||0<f||!1;e=a.w;k&&(e=a.w);var m="";for(c=g;1E20<c;)m="0"+m,c=Math.round(Sv(c,-1));m=c+m;var p=Ov.uk;c=Ov.ji.charCodeAt(0);var v=m.length,A=0;if(0<g||0<b){for(g=v;g<b;g++)d.push(String.fromCharCode(c));if(2<=a.j.length)for(b=1;b<a.j.length;b++)A+=a.j[b];b=v-A;
if(0<b){g=a.j;A=v=0;for(var G,E=Ov.di,P=m.length,ea=0;ea<P;ea++)if(d.push(String.fromCharCode(c+1*Number(m.charAt(ea)))),1<P-ea)if(G=g[A],ea<b){var Va=b-ea;(1===G||0<G&&1===Va%G)&&d.push(E)}else A<g.length&&(ea===b?A+=1:G===ea-b-v+1&&(d.push(E),v+=G,A+=1))}else{b=m;m=a.j;g=Ov.di;G=b.length;E=[];for(v=m.length-1;0<=v&&0<G;v--){A=m[v];for(P=0;P<A&&0<=G-P-1;P++)E.push(String.fromCharCode(c+1*Number(b.charAt(G-P-1))));G-=A;0<G&&E.push(g)}d.push.apply(d,E.reverse())}}else k||d.push(String.fromCharCode(c));
(a.H||k)&&d.push(p);k=String(f);f=k.split("e+");if(2==f.length){if(k=parseFloat(f[0])){p=k;if(isFinite(p)){for(b=0;1<=(p/=10);)b++;p=b}else p=0<p?p:0;p=0-p-1;k=-1>p?k&&isFinite(k)?Sv(Math.round(Sv(k,-1)),1):k:k&&isFinite(k)?Sv(Math.round(Sv(k,p)),-p):k}k=String(k);k=k.replace(".","");k+=ne("0",parseInt(f[1],10)-k.length+1)}a.g+1>k.length&&(k="1"+ne("0",a.g-k.length)+k);for(a=k.length;"0"==k.charAt(a-1)&&a>e+1;)a--;for(g=1;g<a;g++)d.push(String.fromCharCode(c+1*Number(k.charAt(g))))},Uv=function(a,
c,b){b.push(Ov.yk);0>c?(c=-c,b.push(Ov.Ek)):a.J&&b.push(Ov.uo);c=""+c;for(var d=Ov.ji,e=c.length;e<a.F;e++)b.push(d);b.push(c)},Rv=function(a){a=a.charCodeAt(0);if(48<=a&&58>a)return a-48;var c=Ov.ji.charCodeAt(0);return c<=a&&a<c+10?a-c:-1},Pv=function(a,c,b){for(var d="",e=!1,f=c.length;b[0]<f;b[0]++){var g=c.charAt(b[0]);if("'"==g)b[0]+1<f&&"'"==c.charAt(b[0]+1)?(b[0]++,d+="'"):e=!e;else if(e)d+=g;else switch(g){case "#":case "0":case ",":case ".":case ";":return d;case "\u00a4":b[0]+1<f&&"\u00a4"==
c.charAt(b[0]+1)?(b[0]++,d+=Ov.vk):d+=waa[Ov.vk][1];break;case "%":if(!a.m&&1!=a.b)throw Error("Too many percent/permill");if(a.m&&100!=a.b)throw Error("Inconsistent use of percent/permill characters");a.b=100;a.m=!1;d+=Ov.Jk;break;case "\u2030":if(!a.m&&1!=a.b)throw Error("Too many percent/permill");if(a.m&&1E3!=a.b)throw Error("Inconsistent use of percent/permill characters");a.b=1E3;a.m=!1;d+=Ov.Kk;break;default:d+=g}}return d},xaa={prefix:"",qt:"",cq:0},Sv=function(a,c){if(!a||!isFinite(a)||0==
c)return a;a=String(a).split("e");return parseFloat(a[0]+"e"+(parseInt(a[1]||0,10)+c))};var Vv=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"},Wv=Vv;Wv=Vv;var Xv=function(a,c){if(void 0===c){c=a+"";var b=c.indexOf(".");c=Math.min(-1==b?0:c.length-b-1,3)}return 1==(a|0)&&0==c?"one":"other"},Yv=Xv;Yv=Xv;var bw=function(){this.h=yaa;this.f=this.b=this.j=null;var a=Ov,c=Mv;if(Zv!==a||$v!==c)Zv=a,$v=c,aw=new Qv;this.w=aw},Zv=null,$v=null,aw=null,zaa=/'([{}#].*?)'/g,Aaa=/''/g;bw.prototype.format=function(a){if(this.h){this.j=[];var c=Baa(this,this.h);this.f=cw(this,c);this.h=null}if(this.f&&0!=this.f.length)for(this.b=z(this.j),c=[],dw(this,this.f,a,!1,c),a=c.join("");0<this.b.length;)a=a.replace(this.g(this.b),this.b.pop());else a="";return a};
var dw=function(a,c,b,d,e){for(var f=0;f<c.length;f++)switch(c[f].type){case 4:e.push(c[f].value);break;case 3:var g=c[f].value,k=a,m=e,p=b[g];Ia(p)?(k.b.push(p),m.push(k.g(k.b))):m.push("Undefined parameter - "+g);break;case 2:g=c[f].value;k=e;m=g.sh;Ia(b[m])?(m=g[b[m]],Ia(m)||(m=g.other),dw(a,m,b,d,k)):k.push("Undefined parameter - "+m);break;case 0:g=c[f].value;ew(a,g,b,Yv,d,e);break;case 1:g=c[f].value;ew(a,g,b,Wv,d,e);break;default:Hb("Unrecognized block type: "+c[f].type)}},ew=function(a,c,
b,d,e,f){var g=c.sh,k=c.jl,m=+b[g];isNaN(m)?f.push("Undefined or invalid parameter - "+g):(k=m-k,g=c[b[g]],Ia(g)||(d=d(k),g=c[d],Ia(g)||(g=c.other)),c=[],dw(a,g,b,e,c),b=c.join(""),e?f.push(b):(a=a.w.format(k),f.push(b.replace(/#/g,a))))},Baa=function(a,c){var b=a.j,d=t(a.g,a);c=c.replace(Aaa,function(){b.push("'");return d(b)});return c=c.replace(zaa,function(e,f){b.push(f);return d(b)})},fw=function(a){var c=0,b=[],d=[],e=/[{}]/g;e.lastIndex=0;for(var f;f=e.exec(a);){var g=f.index;"}"==f[0]?(b.pop(),
0==b.length&&(f={type:1},f.value=a.substring(c,g),d.push(f),c=g+1)):(0==b.length&&(c=a.substring(c,g),""!=c&&d.push({type:0,value:c}),c=g+1),b.push("{"))}c=a.substring(c);""!=c&&d.push({type:0,value:c});return d},gw=/^\s*(\w+)\s*,\s*plural\s*,(?:\s*offset:(\d+))?/,hw=/^\s*(\w+)\s*,\s*selectordinal\s*,/,iw=/^\s*(\w+)\s*,\s*select\s*,/,cw=function(a,c){var b=[];c=fw(c);for(var d=0;d<c.length;d++){var e={};if(0==c[d].type)e.type=4,e.value=c[d].value;else if(1==c[d].type){var f=c[d].value;switch(gw.test(f)?
0:hw.test(f)?1:iw.test(f)?2:/^\s*\w+\s*/.test(f)?3:5){case 2:e.type=2;e.value=Caa(a,c[d].value);break;case 0:e.type=0;e.value=Daa(a,c[d].value);break;case 1:e.type=1;e.value=Eaa(a,c[d].value);break;case 3:e.type=3;e.value=c[d].value;break;default:Hb("Unknown block type for pattern: "+c[d].value)}}else Hb("Unknown part of the pattern.");b.push(e)}return b},Caa=function(a,c){var b="";c=c.replace(iw,function(k,m){b=m;return""});var d={};d.sh=b;c=fw(c);for(var e=0;e<c.length;){var f=c[e].value;e++;if(1==
c[e].type)var g=cw(a,c[e].value);else Hb("Expected block type.");d[f.replace(/\s/g,"")]=g;e++}return d},Daa=function(a,c){var b="",d=0;c=c.replace(gw,function(m,p,v){b=p;v&&(d=parseInt(v,10));return""});var e={};e.sh=b;e.jl=d;c=fw(c);for(var f=0;f<c.length;){var g=c[f].value;f++;if(1==c[f].type)var k=cw(a,c[f].value);else Hb("Expected block type.");e[g.replace(/\s*(?:=)?(\w+)\s*/,"$1")]=k;f++}return e},Eaa=function(a,c){var b="";c=c.replace(hw,function(k,m){b=m;return""});var d={};d.sh=b;d.jl=0;c=
fw(c);for(var e=0;e<c.length;){var f=c[e].value;e++;if(1==c[e].type)var g=cw(a,c[e].value);else Hb("Expected block type.");d[f.replace(/\s*(?:=)?(\w+)\s*/,"$1")]=g;e++}return d};bw.prototype.g=function(a){return"\ufddf_"+(a.length-1).toString(10)+"_"};var jw=chrome.i18n.getMessage("1522140683318860351"),kw=chrome.i18n.getMessage("4246483347873264186"),lw=chrome.i18n.getMessage("5991427458288444010"),ji=chrome.i18n.getMessage("6063910461797960050"),Faa=chrome.i18n.getMessage("7735695102441495789"),Gaa=chrome.i18n.getMessage("4575332923598659024"),yaa=chrome.i18n.getMessage("2297080986956220930"),mw=new bw;var Haa=function(a){this.b=a;this.l=hb("mr.cloud.mesi.MesiService")},Et=function(a){var c=Xs(Os.b,["hangouts","search"]);a.l.info("Retrieving Hangouts from MESI: "+c);return Ys(a.b,c,"POST",Iaa).then(function(b){var d=[];b.result&&(d=b.result.map(function(e){var f=e.hangout,g=f.meeting_room_name,k;f.meeting_domain?k=f.meeting_domain:"BUSINESS"==f.type&&f.company_title&&(k=f.company_title.toLowerCase());var m=mw.format({ORGANIZER:"",PARTICIPANTS:0});if((e=e.participant)&&0<e.length){var p=e[0].display_name;
m=e.reduce(function(v,A){v.add(A.user_id);"ORGANIZER"==A.role&&(p=A.display_name);return v},new Set);m=mw.format({ORGANIZER:p,PARTICIPANTS:m.size})}return g&&k?new Qs(!1,g+"@"+k,k,g,m,f.hangout_id):new Qs(!1,f.hangout_id,k,g,m,f.hangout_id)}));return d})},Iaa={request_header:{client_version:{client_id:"39"}},search_sources:["0"]};var Jaa=function(a,c){this.f=a;this.b=c},Kaa=function(a,c,b,d){switch(c.type){case "REFRESH_AUTH":var e=d.Hd,f=d.deviceId,g=d.eh;return Mt(a.f).then(function(){nw(a.b,new xj("AUTH_READY",{Hd:e,cb:f,eh:g}),b.id)});case "STATUS_REQUEST":return nw(a.b,c,b.id),Promise.resolve();case "STATUS_RESPONSE":return nw(a.b,c,b.id,!0),c.data.routeDescription||nw(a.b,c,b.id),Promise.resolve();case "HANGOUT_INACTIVE":return ow(a.b,b,4,ni(new ii(Faa,"warning"),b.sinkId));case "HANGOUT_INVALID":return ow(a.b,b,3,ni(new ii(Gaa,
"warning"),b.sinkId));default:return Promise.reject(Error("Unknown type: "+c.type))}};var pw=new Map([["status","status"],["results","result"],["expirationTime","expiration_time"]]),qw=function(a,c){uv.call(this,a,c);this.l=Mf("mr.cloud.slarti.CommandsService")};q(qw,uv);qw.prototype.get=function(a){a=new Ot({method:"GET",baseUrl:this.b,Hc:["commands",a],hb:this.hb});return this.f.execute(a).then(function(c){return c})};
qw.prototype.list=function(a){a=new Ot({method:"GET",baseUrl:this.b,Hc:["commands"],Qm:{deviceId:a},hb:this.hb});return this.f.execute(a).then(function(c){return c.command||[]})};qw.prototype.send=function(a,c){var b=this;a=new Ot({method:"POST",baseUrl:this.b,Hc:["commands:send"],hb:this.hb,body:{command:c,deviceId:a}});return this.f.execute(a).then(function(d){b.l.info("Sent Slarti command with ID "+d.id);return d})};
qw.prototype.update=function(a,c){for(var b=[],d={},e=l(pw.keys()),f=e.next();!f.done;f=e.next())f=f.value,c[f]&&(d[f]=c[f],b.push(pw.get(f)));d.id=a;a=new Ot({method:"PUT",baseUrl:this.b,Hc:["commands",a],hb:this.hb,body:{command:d,updateMask:b}});return this.f.execute(a).then(function(g){return g})};var Laa=Ha.JSON.parse;var rw=function(){};rw.prototype.b=null;rw.prototype.getOptions=function(){var a;(a=this.b)||(a={},sw(this)&&(a[0]=!0,a[1]=!0),a=this.b=a);return a};var tw,uw=function(){};x(uw,rw);var vw=function(a){return(a=sw(a))?new ActiveXObject(a):new XMLHttpRequest},sw=function(a){if(!a.f&&"undefined"==typeof XMLHttpRequest&&"undefined"!=typeof ActiveXObject){for(var c=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"],b=0;b<c.length;b++){var d=c[b];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};tw=new uw;var ww=function(a){Y.call(this);this.headers=new Jm;this.W=a||null;this.g=!1;this.T=this.f=null;this.fa=this.J="";this.o=0;this.h="";this.j=this.ha=this.H=this.da=!1;this.m=0;this.C=null;this.s="";this.O=this.F=!1};x(ww,Y);ww.prototype.l=Mf("goog.net.XhrIo");var Maa=/^https?$/i,Naa=["POST","PUT"],xw=[],yw=function(a,c,b,d,e,f,g){var k=new ww;xw.push(k);c&&k.listen("complete",c);wu(k,"ready",k.qa);f&&(k.m=Math.max(0,f));g&&(k.F=g);k.send(a,b,d,e);return k};
ww.prototype.qa=function(){this.Za();ac(xw,this)};
ww.prototype.send=function(a,c,b,d){if(this.f)throw Error("[goog.net.XhrIo] Object is active with another request="+this.J+"; newUri="+a);c=c?c.toUpperCase():"GET";this.J=a;this.h="";this.o=0;this.fa=c;this.da=!1;this.g=!0;this.f=this.W?vw(this.W):vw(tw);this.T=this.W?this.W.getOptions():tw.getOptions();this.f.onreadystatechange=t(this.pa,this);try{Pf(this.l,zw(this,"Opening Xhr")),this.ha=!0,this.f.open(c,String(a),!0),this.ha=!1}catch(f){Pf(this.l,zw(this,"Error opening Xhr: "+f.message));Aw(this,
f);return}a=b||"";var e=this.headers.clone();d&&Bn(d,function(f,g){e.set(g,f)});d=Sb(e.wb(),Oaa);b=Ha.FormData&&a instanceof Ha.FormData;!Ub(Naa,c)||d||b||e.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");e.forEach(function(f,g){this.f.setRequestHeader(g,f)},this);this.s&&(this.f.responseType=this.s);"withCredentials"in this.f&&this.f.withCredentials!==this.F&&(this.f.withCredentials=this.F);try{Bw(this),0<this.m&&(this.O=Paa(this.f),Pf(this.l,zw(this,"Will abort after "+this.m+
"ms if incomplete, xhr2 "+this.O)),this.O?(this.f.timeout=this.m,this.f.ontimeout=t(this.ua,this)):this.C=qv(this.ua,this.m,this)),Pf(this.l,zw(this,"Sending request")),this.H=!0,this.f.send(a),this.H=!1}catch(f){Pf(this.l,zw(this,"Send error: "+f.message)),Aw(this,f)}};var Paa=function(a){return Be&&Ve(9)&&r(a.timeout)&&Ia(a.ontimeout)},Oaa=function(a){return jd("Content-Type",a)};
ww.prototype.ua=function(){"undefined"!=typeof Ga&&this.f&&(this.h="Timed out after "+this.m+"ms, aborting",this.o=8,Pf(this.l,zw(this,this.h)),this.N("timeout"),this.abort(8))};var Aw=function(a,c){a.g=!1;a.f&&(a.j=!0,a.f.abort(),a.j=!1);a.h=c;a.o=5;Cw(a);Dw(a)},Cw=function(a){a.da||(a.da=!0,a.N("complete"),a.N("error"))};ww.prototype.abort=function(a){this.f&&this.g&&(Pf(this.l,zw(this,"Aborting")),this.g=!1,this.j=!0,this.f.abort(),this.j=!1,this.o=a||7,this.N("complete"),this.N("abort"),Dw(this))};
ww.prototype.ia=function(){this.f&&(this.g&&(this.g=!1,this.j=!0,this.f.abort(),this.j=!1),Dw(this,!0));ww.Ga.ia.call(this)};ww.prototype.pa=function(){this.w()||(this.ha||this.H||this.j?Ew(this):this.Aa())};ww.prototype.Aa=function(){Ew(this)};
var Ew=function(a){if(a.g&&"undefined"!=typeof Ga)if(a.T[1]&&4==Fw(a)&&2==a.Va())Pf(a.l,zw(a,"Local request error detected and ignored"));else if(a.H&&4==Fw(a))qv(a.pa,0,a);else if(a.N("readystatechange"),4==Fw(a)){Pf(a.l,zw(a,"Request complete"));a.g=!1;try{if(Gw(a))a.N("complete"),a.N("success");else{a.o=6;try{var c=2<Fw(a)?a.f.statusText:""}catch(b){Pf(a.l,"Can not get status: "+b.message),c=""}a.h=c+" ["+a.Va()+"]";Cw(a)}}finally{Dw(a)}}},Dw=function(a,c){if(a.f){Bw(a);var b=a.f,d=a.T[0]?Qa:null;
a.f=null;a.T=null;c||a.N("ready");try{b.onreadystatechange=d}catch(e){Of(a.l,"Problem encountered resetting onreadystatechange: "+e.message)}}},Bw=function(a){a.f&&a.O&&(a.f.ontimeout=null);a.C&&(rv(a.C),a.C=null)},Gw=function(a){var c=a.Va();a:switch(c){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var b=!0;break a;default:b=!1}if(!b){if(c=0===c)a=String(a.J).match(Nr)[1]||null,!a&&Ha.self&&Ha.self.location&&(a=Ha.self.location.protocol,a=a.substr(0,a.length-1)),c=!Maa.test(a?a.toLowerCase():
"");b=c}return b},Fw=function(a){return a.f?a.f.readyState:0};ww.prototype.Va=function(){try{return 2<Fw(this)?this.f.status:-1}catch(a){return-1}};
var Hw=function(a){try{return a.f?a.f.responseText:""}catch(c){return Pf(a.l,"Can not get responseText: "+c.message),""}},Qaa=function(a){if(a.f)return Laa(a.f.responseText)},Raa=function(a){try{if(!a.f)return null;if("response"in a.f)return a.f.response;switch(a.s){case "":case "text":return a.f.responseText;case "arraybuffer":if("mozResponseArrayBuffer"in a.f)return a.f.mozResponseArrayBuffer}Of(a.l,"Response type "+a.s+" is not supported on this browser");return null}catch(c){return Pf(a.l,"Can not get response: "+
c.message),null}};ww.prototype.getResponseHeader=function(a){if(this.f&&4==Fw(this))return a=this.f.getResponseHeader(a),null===a?void 0:a};var Saa=function(a){var c={};a=(a.f&&4==Fw(a)?a.f.getAllResponseHeaders()||"":"").split("\r\n");for(var b=0;b<a.length;b++)if(!kd(a[b])){var d=te(a[b],":",1),e=d[0];d=d[1];if(Ja(d)){d=d.trim();var f=c[e]||[];c[e]=f;f.push(d)}}return zc(c,function(g){return g.join(", ")})},zw=function(a,c){return c+" ["+a.fa+" "+a.J+" "+a.Va()+"]"};var Taa=function(){this.l=hb("mr.cloud.CredentialService")},Iw=function(a){var c=new Db,b=Ps.b+"/iceconfig?key="+Ps.f;a.l.info("Requesting TURN credentials from "+b);var d=yw(b,function(){Gw(d)?(a.l.info("Got TURN credentials: "+Hw(d)),c.resolve(Uaa(a,Qaa(d)))):c.resolve(Vaa(a))},"POST",void 0,{"Content-Type":"application/json"});return c.b},Uaa=function(a,c){try{var b=[];c.iceServers.forEach(function(d){d.urls.forEach(function(e){0==e.indexOf("turn:")&&b.push({url:e,credential:d.credential,username:d.username})})});
return b}catch(d){return a.l.error("Error parsing TURN credentials.",d),[]}},Vaa=function(a){a.l.error("XHR failed fetching TURN credentials.",null);return[]};var Waa=function(a,c,b){this.l=hb("mr.cloud.slarti.MessageHandler");this.g=a;this.h=c;this.b=b;this.f=new Map},Xaa=function(a){if(bj(a.mediaSource))return Promise.resolve({title:"screen"});var c=a.mb&&a.mb.tabId;return null==c?Promise.resolve({title:"",url:""}):new Promise(function(b){chrome.tabs.get(c,function(d){b({title:d&&d.title||"",url:d&&d.url||""})})})},Yaa=function(a,c,b,d){var e=d.deviceId,f=c.data;return Xaa(b).then(function(g){g={id:null,issuer:null,name:"stream",status:null,results:null,
expirationTime:null,parameters:JSON.stringify({info:g,sessionDescription:f.description,mediaConstraints:f.mediaConstraints,settings:f.settings})};return a.g.send(e,g).then(function(k){return new Promise(function(m,p){a.f.set(k.id,{routeId:b.id,sinkId:d.id,resolve:m,reject:p,Eq:"PENDING_APPROVAL"==k.status})})},function(){ow(a.b,b.id,7,ni(mi(li(new ii(jw,"warning")),b.id),d.id))})})},Zaa=function(a,c){return Iw(a.h).then(function(b){nw(a.b,new xj("TURN_CREDENTIALS",{credentials:b}),c.id)})};var $aa=function(a,c,b,d){this.f=a;this.g=c;this.h=b;this.b=d},cba=function(a,c,b,d,e){return new Promise(function(f){switch(c){case "slarti":case "weave":case "mesi":break;default:throw Error("Unrecognized channel type: "+c);}if(!b.type)throw Error("Message has no type");switch(b.type){case "STOP":f(ow(a.b,d,1,null));return;case "SESSION_START_SUCCESS":Hs(0);break;case "SESSION_END":break;case "SESSION_FAILURE":Hs(1);f(ow(a.b,d,2,ni(new ii(jw,"warning"),d?d.sinkId:"")));return;case "__webrtc_stats__":break;
case "PRESENTATION_CONNECTION_MESSAGE":nw(a.b,b.data,d.id,!0);break;case "OFFER":switch(c){case "slarti":f(Yaa(a.f,b,d,e));return;case "weave":f(aba(a.g,b,d,e));return;default:throw Error("Unexpected channel type: "+c);}case "GET_TURN_CREDENTIALS":switch(c){case "slarti":f(Zaa(a.f,d));return;case "weave":f(bba(a.g,d));return;default:throw Error("Unexpected channel type: "+c);}case "REFRESH_AUTH":case "LOCAL_PRESENT":case "MUTE":case "STATUS_REQUEST":case "STATUS_RESPONSE":case "HANGOUT_INACTIVE":case "HANGOUT_INVALID":f(Kaa(a.h,
b,d,e));return;case "new_session":nw(a.b,b,d.id,!0);break;case "remove_session":nw(a.b,b,d.id,!0);a.b.terminateRoute(d.id);break;default:throw Error("Unknown type: "+b.type);}f()})};var Jw=function(a,c,b){this.state=a;this.type=null!=c?c:null;this.results=null!=b?b:null},Kw=function(a){this.b=a},dba=function(a,c,b,d){return Lw(a,gt,c,b,d,35E3).then(function(e){return Mw(a,e)})},eba=function(a,c,b,d){return Lw(a,ht,c,b,d,23E3).then(function(e){var f=e.state;return"done"==f?(e=Nw(e),new Jw(f,e.type,new dt(e.sessionDescription))):new Jw(f)})},Lw=function(a,c,b,d,e,f){var g={_webrtcMessage:JSON.stringify(d.presentationUrl?new dt(d.description,null,d.presentationUrl,d.presentationId):
new dt(d.description))};d.settings&&(g._settings=uj(d.settings));d.mediaConstraints&&(g._optMediaConstraints=JSON.stringify(d.mediaConstraints));e&&(g._user=JSON.stringify(e));return Ow(a,b,c,g,f)},Mw=function(a,c){var b=c.state;switch(b){case "done":return Promise.resolve(fba(c));case "queued":case "inProgress":return gba(a,c).then(function(d){return Mw(a,d)});default:return Promise.resolve(new Jw(b))}},gba=function(a,c){return new Promise(function(b){var d=setInterval(function(){hba(a,c.id).then(function(e){"queued"!=
e.state&&"inProgress"!=e.state&&(clearInterval(d),b(e))})},2E3)})},fba=function(a){a=Nw(a);return"__cloud_webrtc_session_message__"==a.type?new Jw("done","knocking_cloud_webrtc_session_message",new dt(a.sessionDescription)):new Jw("done",a.type)},Ow=function(a,c,b,d,e){c={deviceId:c,name:"_cloudCast."+b.name,parameters:d,expirationTimeoutMs:e||1E4};b={};e&&(b.responseAwaitMs=Math.min(e+5E3,25E3));e=Xs(Ls.b,["commands"],b);return Ys(a.b,e,"POST",c)},Nw=function(a){return a.results&&a.results.results?
JSON.parse(a.results.results):null},hba=function(a,c){c=Xs(Ls.b,["commands",c]);return Ys(a.b,c,"GET")};Kw.$inject=["gapiService"];var iba=function(a,c,b,d){this.f=a;this.g=c;this.h=b;this.b=d},aba=function(a,c,b,d){return jba(a,c,d).then(function(e){a:{var f=b.id;if("done"!=e.state)f=Promise.reject(Error("Offer not executed by receiver. State: "+e.state));else{switch(e.type){case "__cloud_webrtc_session_message__":e=new xj("ANSWER",e.results.sessionDescription);nw(a.b,e,f);break;case "knocking_cloud_webrtc_session_message":Gs(0);e=new xj("KNOCK_ANSWER",e.results.sessionDescription);nw(a.b,e,f);break;case "knock_denied":Gs(1);
Pw(a,kw,f);break;case "knock_timeout":Gs(2);Pw(a,lw,f);break;default:f=Promise.reject(Error("Invalid message type: "+e.type));break a}f=Promise.resolve()}}return f})},bba=function(a,c){return Iw(a.h).then(function(b){nw(a.b,new xj("TURN_CREDENTIALS",{credentials:b}),c.id)})},jba=function(a,c,b){var d=b.deviceId,e=a.g.b;e=e?new bt(e):void 0;c=c.data;switch(b.ri){case "owner":Js(0);break;case "manager":Js(1);break;case "user":Js(2);break;case "viewer":Js(3)}return"viewer"==b.ri?dba(a.f,d,c,e):eba(a.f,
d,c,e)},Pw=function(a,c,b){c=new ii(c,"warning");li(c);a.b.b.Ze(c);nw(a.b,new xj("STOP"),b)};var kba=function(){var a=this;this.l=hb("mr.cloud.settings.SettingsService");this.b=null;chrome.settingsPrivate.onPrefsChanged.addListener(function(c){$i(13);if(a.b){c=l(c);for(var b=c.next();!b.done;b=c.next())if(b=b.value,"media_router.cloudservices.enabled"==b.key){a.b.call(null,b.value);break}}})},lba=function(a,c){a.b=c},mba=function(a){var c=a.l;chrome.storage.sync.set({"mr.cloud.cloudEnabled":!0},function(){chrome.runtime.lastError&&c.G("Error setting cloud setting: "+JSON.stringify(chrome.runtime.lastError))})},
nba=function(a){return Qw().catch(function(){return Qw().catch(function(c){a.l.G("Error retrieving cloud on setting.",c);return!1})})},Qw=function(){return Rw("mr.cloud.cloudEnabled").then(function(a){return!!a["mr.cloud.cloudEnabled"]})},Rw=function(a){return new Promise(function(c,b){chrome.storage.sync.get(a,function(d){chrome.runtime.lastError?b(chrome.runtime.lastError):c(d)})})},oba=function(a){return Sw().catch(function(){return Sw().catch(function(c){a.l.G("Error retrieving cloud enabled setting.",
c);return!1})})},Sw=function(){return pba().then(function(a){return!!a.value})},pba=function(){return new Promise(function(a,c){chrome.settingsPrivate.getPref("media_router.cloudservices.enabled",function(b){chrome.runtime.lastError?c(chrome.runtime.lastError):a(b)})})},qba=function(a){var c=a.l;chrome.storage.sync.set({"mr.cloud.notifiedHangouts":!0},function(){chrome.runtime.lastError&&c.G("Error setting notified Hangout privacy.",chrome.runtime.lastError)})},rba=function(a){return Tw().catch(function(){return Tw().catch(function(c){a.l.G("Error retrieving hangouts notified setting.",
c);return!1})})},Tw=function(){return Rw("mr.cloud.notifiedHangouts").then(function(a){return!!a["mr.cloud.notifiedHangouts"]})};var Uw=new Map([["displayName","display_name"],["description","description"],["type","type"],["status","status"],["state","state"],["commandDefs","command_defs"]]),Vw=function(a,c){uv.call(this,a,c)};q(Vw,uv);h=Vw.prototype;h.act=function(a,c){a=new Ot({method:"POST",baseUrl:this.b,Hc:["devices:act"],hb:this.hb,body:{gcmId:c,id:a}});return this.f.execute(a).then(function(b){return b})};h.create=function(a){a=new Ot({method:"POST",baseUrl:this.b,Hc:["devices"],hb:this.hb,body:a});return this.f.execute(a).then(function(c){return c})};
h.delete=function(a){a=new Ot({method:"DELETE",baseUrl:this.b,Hc:["devices",a],hb:this.hb});return this.f.execute(a)};h.get=function(a){a=new Ot({method:"GET",baseUrl:this.b,Hc:["devices",a],hb:this.hb});return this.f.execute(a).then(function(c){return c})};
h.list=function(a){var c=a.type,b=a.status;a=a.permission;var d={};c&&(d.type=c);b&&(d.status=b);a&&(d.permission=a);c=new Ot({method:"GET",baseUrl:this.b,Hc:["devices"],Qm:d,hb:this.hb});return this.f.execute(c).then(function(e){return e.device||[]})};h.update=function(a,c){for(var b=[],d={},e=l(Uw.keys()),f=e.next();!f.done;f=e.next())f=f.value,c[f]&&(d[f]=c[f],b.push(Uw.get(f)));d.id=a;a=new Ot({method:"PUT",baseUrl:this.b,Hc:["devices",a],hb:this.hb,body:{device:d,updateMask:b}});return this.f.execute(a).then(function(g){return g})};var Ww=function(a,c,b,d,e,f){f=void 0===f?null:f;this.l=hb("mr.cloud.slarti.SinkDiscoveryService");this.w=a;this.g=c;this.f=b;this.j=d;this.h=e;this.b=f||new rt(this.m.bind(this),b,36E5);zv().addListener();am(this);Xi("mr.cloud.slarti.SinkDiscoveryService",this)};q(Ww,Ni);Ww.prototype.fe=function(){jaa(this.h).catch(function(){});return this.b.fe().filter(function(a){return a.isAvailable})};Ww.prototype.ra=function(a){return this.b.ra(a)};
Ww.prototype.handleEvent=function(a,c){if(a!=chrome.gcm.onMessage)throw Error("Unhandled event: expected chrome.gcm.onMessage");sba(this,c)};
var sba=function(a,c){var b=JSON.parse(c.data.data);a.l.info("Received Slarti GCM notification: "+b.type);ob(a.l,function(){return"Got notification: "+JSON.stringify(b)});switch(b.type){case "DEVICE_ADDED":Xw(a,b).then(function(d){"cast-receiver"==d.type&&(d=new qt(d.id,d.displayName,"ONLINE"==d.status),a.b.b.set(d.id,d),vt(a.f,[d.nb]))});break;case "DEVICE_CHANGED":Xw(a,b).then(function(d){if("cast-receiver"==d.type){var e=vm(um(),d.id);if(e=a.b.ra(e))e.displayName=d.displayName,e.isAvailable="ONLINE"==
d.status,wt(a.f,[e.nb])}});break;case "DEVICE_REMOVED":tba(a,uba(b));Promise.resolve();break;case "COMMAND_CHANGED":vba(a,b).then(function(d){var e=a.j,f=d.id,g=e.f.get(f);if(g){var k=g.routeId,m=g.sinkId,p=g.resolve,v=g.reject,A=g.Eq;g=!0;try{var G=JSON.parse(d.results||"{}"),E=G.sessionDescription,P=G.errorCode,ea=G.errorText;switch(d.status){case "SUCCESS":p(nw(e.b,new xj("ANSWER",E),k));A&&Gs(0);break;case "ERROR":case "TIMEOUT":var Va="TIMEOUT"==d.status;p=jw;"KNOCK_DENIED"==P&&(Gs(Va?2:1),p=
Va?lw:kw);ow(e.b,k,7,ni(mi(li(new ii(p,"warning")),k),m));throw Error("Slarti command "+f+" failed with status: "+(d.status+", errorCode: "+P+", ")+("errorText: "+ea));default:g=!1}}catch(Dc){v(Dc)}finally{g&&e.f.delete(f)}}else e.l.G("Received update to unknown command with "+("name = "+d.name+" and id = "+f))});break;default:Promise.resolve()}};
Ww.prototype.m=function(){return this.g.list({type:"cast-receiver"}).then(function(a){return a.map(function(c){return new qt(c.id,c.displayName,"ONLINE"==c.status)})})};Ww.prototype.Ea=function(){return"SlartiSinkDiscoveryService"};Ww.prototype.jb=function(){return[{cache:zt(this.b)}]};Ww.prototype.ib=function(){var a=Yl(this);a&&At(this.b,a.cache)};
var tba=function(a,c){c=vm(um(),c);var b=a.b.ra(c);b&&(a.b.b.delete(c),xt(a.f,[b.nb]))},uba=function(a){a=a.deviceInfo;return a.device?a.device.id:a.deviceId},Xw=function(a,c){c=c.deviceInfo;return c.device?Promise.resolve(c.device):a.g.get(c.deviceId)},vba=function(a,c){c=c.commandInfo;return c.command?Promise.resolve(c.command):a.w.get(c.commandId)};var Yw=function(){this.b=null},Zw=function(a,c){if(!a.b||O(a.b,2)<O(c,2))a.b=zl(c)},$w=function(a){return a.b?O(a.b,2)+";"+O(a.b,1):null};var ax=function(){this.D=this.w=this.J=this.L=this.F=this.C=this.g=this.s=this.h=this.f=this.j=this.fa=this.ha=this.W=this.H=this.Ua=this.da=this.T=this.O=this.m=this.o=this.b=null},bx=function(){var a=ax.Ja();null==a.w&&(a.w=new Yw);return a.w},cx=function(a){null==a.b&&(a.b=new Jt);return a.b},dx=function(a){null==a.o&&(a.o=new raa(cx(a)));return a.o},ex=function(a){null==a.m&&(a.m=new tv);return a.m},fx=function(a){null==a.O&&(a.O=new qw(cx(a),ex(a)));return a.O},hx=function(a,c){null==a.H&&(a.H=
new Waa(fx(a),gx(a),c));return a.H},ix=function(a){null==a.s&&(a.s=new Kw(dx(a)));return a.s},gx=function(a){null==a.J&&(a.J=new Taa(dx(a)));return a.J},jx=function(a){null==a.D&&(a.D=new at);return a.D};Ra(ax);var lx=function(a,c){this.g=a;this.w=c;this.j=new Db;this.ja=this.j.b;this.b=kx(a.id);this.f=new Db;this.h=!1;wba(this);xba(this);this.b.sendMessage(new xj("GET_TURN_CREDENTIALS"))};lx.prototype.start=function(){var a=this;return this.ja.then(function(c){if(c.b)return Promise.reject(Error("Presentation already started"));c.start();return a.f.b})};lx.prototype.stop=function(){var a=this;this.h=!1;return this.ja.then(function(c){c.stop();a.ja=Promise.reject(Error("Peer connection has already been stopped"))})};
var wba=function(a){a.b.onMessage=function(c){if(c.type)switch(c.type){case "TURN_CREDENTIALS":a.j.resolve(new Cj(a.g.id,c.data.credentials));break;case "ANSWER":a.ja.then(function(b){Kj(b,c.data)});break;case "STOP":a.f.reject("Stop signal received");a.stop();break;default:throw Error("Unknown message type: "+c.type);}else a.ja.then(function(b){var d={type:"PRESENTATION_CONNECTION_MESSAGE",data:c};"string"==typeof d?b.h.send(d):b.h.send(JSON.stringify(d))})}},xba=function(a){a.ja.then(function(c){Gj(c,
function(b){a.b.sendMessage(new xj("OFFER",new zj(b,null,null,a.w,a.g.id)))});Hj(c,function(b){b=yj(b);"STOP"==b.type&&a.stop();a.b.sendMessage(b)});Dj(c,function(){a.h=!0;a.b.sendMessage(new xj("SESSION_START_SUCCESS"));a.f.resolve(a.g)});Fj(c,function(){a.b.sendMessage(new xj("SESSION_END"))});Ej(c,function(b){a.h||a.f.reject(b);a.b.sendMessage(new xj("SESSION_FAILURE"))})})};var mx=function(a){this.b=a;this.f=new Map;this.F=new Map;this.L=new Map;this.o=[];this.j=this.J=this.D=this.H=this.w=null;this.m=this.h=this.g=!1;this.C=new Map;this.s=new Map;am(this)};mx.prototype.getName=function(){return"cloud"};
mx.prototype.initialize=function(){var a=this;this.l.info("Initializing Cloud MRP");var c=ax.Ja();null==c.fa&&(null==c.ha&&(c.ha=new jt(dx(c),jx(c))),c.fa=new Fv(c.ha,this));this.o.push(c.fa);if(null==c.Ua){var b=fx(c);null==c.T&&(c.T=new Vw(cx(c),ex(c)));var d=c.T,e=hx(c,this);null==c.W&&(null==c.da&&(c.da=new vv(cx(c),ex(c))),c.W=new iaa(c.da,window.localStorage,jx(c)));c.Ua=new Ww(b,d,this,e,c.W)}this.o.push(c.Ua);null==c.h&&(null==c.f&&(c.f=new Rs(dx(c),cx(c))),b=c.f,null==c.j&&(c.j=new Haa(dx(c))),
c.h=new Dt(b,c.j,this));this.w=c.h;this.o.push(this.w);this.H=ix(c);hx(c,this);this.D=cx(c);null==c.F&&(b=hx(c,this),null==c.g&&(c.g=new iba(ix(c),cx(c),gx(c),this)),d=c.g,null==c.C&&(c.C=new Jaa(cx(c),this)),c.F=new $aa(b,d,c.C,this));this.J=c.F;null==c.L&&(c.L=new kba);this.j=c.L;oba(this.j).then(function(f){a.g=f;a.l.info("Cloud enabled setting: "+a.g)});nba(this.j).then(function(f){a.h=f;a.l.info("Cloud on setting: "+a.h)});lba(this.j,function(f){a.g=f;a.l.info("Cloud enabled setting: "+a.g);
a.g&&nx(a)});rba(this.j).then(function(f){a.m=f;a.l.info("Privacy notified setting: "+a.m)})};mx.prototype.Bd=function(){return Array.from(this.f.values())};
mx.prototype.Bg=function(a){if(!ox(this,a))return sq;ob(this.l,"GetAvailableSinks for "+a);var c=[];if(this.h||yba())c=nx(this);this.s.clear();for(var b={},d=l(this.C.values()),e=d.next();!e.done;b={qf:b.qf,jh:b.jh},e=d.next())b.qf=e.value,b.jh=!1,c.forEach(function(f){return function(g){g.id==f.qf.id&&(f.jh=!0,g.nb.friendlyName=f.qf.nb.friendlyName)}}(b)),b.jh||this.s.set(b.qf.id,b.qf);c=c.concat.apply(c,n(this.s.values()));ob(this.l,function(){return"Available sinks are..."+JSON.stringify(c)});
b=c.map(function(f){return f.nb});this.w&&(b=b.concat(zba));return new rq(b,-1!=a.indexOf("0F5096E8")?ej:null)};var nx=function(a){var c=[];a.l.info("Checking cloud discovery services");um().g=u();a.o.forEach(function(b){b=b.fe();c=c.concat(b)});return c};h=mx.prototype;h.startObservingMediaSinks=function(){};h.stopObservingMediaSinks=function(){};h.startObservingMediaRoutes=function(){};h.stopObservingMediaRoutes=function(){};h.ra=function(a){return(a=px(this,a))?a.nb:null};
h.createRoute=function(a,c,b,d,e,f,g){var k=this;this.l.info("createRoute called");ob(this.l,"urn: "+a+" sinkId:"+c);if(e=this.F.get(c))return pi(this.b.im(this,e,a,b,g,function(m){m.mediaSource=a;m.mb.tabId=g;return qi(m)}),function(m){k.b.Ye(m);return m});e=px(this,c);return Aba(this,a,e,c,b,d,g)};
var qx=function(a,c,b,d,e){c instanceof qq&&2==c.errorCode?ow(a,b,6,null):(a.l.error("Error on start session",c instanceof Error?c:Error("Expected an Error value, got "+c)),a.f.has(b.id)&&ow(a,b,e,ni(new ii(jw,"warning"),b.sinkId)));if(c=a.w)c=a.w,c.f.delete(d.deviceId)?(c.b.b.delete(d.id),c=!0):c=!1;c&&xt(a,[d.nb])},Aba=function(a,c,b,d,e,f,g){if(f)return ri(Error("not supported"));f=!1;switch(b.b){case "slarti":case "weave":Is(1);break;case "mesi":f=!0;if(!a.m){a.m=!0;qba(a.j);var k=ni(ki(),d);
a.b.Ze(k)}Is(0)}um().f=new rm(b.model,null);var m=Ip(e,a.getName(),d,c,!0,"");f&&(m.customControllerPath="cloud_route_details/view.html?routeId="+m.id,m.controllerType=mojo.RouteControllerType&&mojo.RouteControllerType.kHangouts);a.f.set(m.id,m);a.F.set(d,m);a.C.set(m.id,b);a.L.set(m.id,b.b);a.b.Uf(a,m);a.b.Wf(a.Ea(),!0);if(dj(c)&&!f)return a.l.info("starting presentation on route: "+m.id),Bba(m,c).catch(function(p){qx(a,p,m,b,7);throw p;});a.l.info("starting mirroring on route: "+m.id);m.mb={tabId:g,
sessionId:"",ag:"",ke:b.model};dj(c)&&(m.isOffscreenPresentation=!0);return a.b.rj(a,m,e).catch(function(p){qx(a,p,m,b,5);throw p;})};mx.prototype.terminateRoute=function(a){return ow(this,a,0,null)};
var ow=function(a,c,b,d){var e="string"==typeof c?a.f.get(c):c;if(!e)return Promise.reject(new qq(3,"Route in cloud provider not found for routeId "+c));a.l.info("terminating route: "+e.id);a.f.delete(e.id);a.F.delete(e.sinkId);c=a.C.get(e.id);a.C.delete(e.id);d&&a.b.Ze(d);Cb("MediaRouter.Cloud.Session.End",b,Ds);switch(b){case 1:break;default:switch(c.b){case "weave":Ow(a.H,c.deviceId,it,{})}}a.b.Ig(e);0==a.f.size&&a.b.Wf(a.Ea(),!1);a.b.onPresentationConnectionStateChanged(e.id,"terminated");a.s.has(e.sinkId)&&
(b=a.s.get(e.sinkId),xt(a,[b.nb]),a.s.delete(e.sinkId));return Promise.resolve()};h=mx.prototype;h.sendRouteMessage=function(a,c){var b=this.L.get(a);if(b){var d=(a=this.f.get(a)||void 0)?px(this,a.sinkId):void 0;return cba(this.J,b,c,a,d)}return Ja(c)?(nw(this,c,a),Promise.resolve()):Promise.reject(Error("Channel type missing"))};h.sendRouteBinaryMessage=function(a){return Promise.reject(Error("Route "+a+" does not support sending binary data."))};
h.Gf=function(a){var c=new vj;5>c.minFrameRate&&(c.minFrameRate=5);var b=this.Ve(a);"hangouts"==b||"meetings"==b?(c.maxWidth=Math.min(window.screen&&window.screen.width||Infinity,2880),c.maxHeight=Math.min(window.screen&&window.screen.height||Infinity,1800)):c.senderSideLetterboxing=!0;wj(c);Object.freeze(c);this.l.info("Settings for "+a+": "+uj(c));if(!c.shouldCaptureAudio&&!c.shouldCaptureVideo)throw Error("Cannot start mirroring without video or audio capture.");return c};
h.Ve=function(a){var c=null;a=px(this,a);switch(a.b){case "slarti":case "weave":c="webrtc";break;case "mesi":c=a.Hd?"meetings":"hangouts"}return c};h.Sh=function(){};h.ug=function(a,c){ob(this.l,"Checking canRoute: "+a+" for sinkId: "+c);return ox(this,a)&&!!this.ra(c)};h.zf=function(a,c){return("https://hangouts.google.com/cloudmrp-mirroring"==a||dj(a))&&this.f.has(c)};h.joinRoute=function(a,c){return(a=this.f.get(c))?(this.l.info("joining route: "+a.id),qi(a)):ri(Error("not supported"))};
h.connectRouteByRouteId=function(){return ri(Error("not supported"))};h.detachRoute=function(){};
var vt=function(a,c){a.l.info(c.length+" sinks added");0<c.length&&!a.h&&(mba(a.j),a.h=!0);c=px(a,c[0].id);um().b=new rm(c.model,null);a.b.dd();a.b.onSinkAvailabilityUpdated(a,2);a.l.info("sinkAvailability changed to AVAILABLE")},xt=function(a,c){a.l.info(c.length+" sinks removed");a.o.some(function(b){return 0<b.fe().length})||(a.b.onSinkAvailabilityUpdated(a,0),a.l.info("sinkAvailability changed to UNAVAILABLE"));a.b.dd()},wt=function(a,c){a.l.info(c.length+" sinks updated");a.b.dd()},nw=function(a,
c,b,d){(void 0===d?0:d)?a.b.ee(b,c):a.b.Rh(b,c)},px=function(a,c){var b=Cba(a,c);b||(b=null,(c=a.F.get(c))&&(b=a.C.get(c.id)));return b},Cba=function(a,c){var b=null;a.o.some(function(d){b=d.ra(c);return!!b});return b},yba=function(){var a=um().g;return 3E5<=Date.now()-a},ox=function(a,c){var b=cj(c);c=dj(c);if(a.D.g&&!a.D.f&&b)return a.b.onSinkAvailabilityUpdated(a,2),!0;var d=!1;a.g&&a.D.f&&(d=!0);var e;if(e=!chrome.declarativeWebRequest)a=a.D,e=!(a.g||a.f&&a.b&&(-1!=Nt.indexOf(a.b)||-1!=Nt.indexOf(Kt(a))))&&
c;return e?!1:d&&(b||c)};mx.prototype.searchSinks=function(a,c){var b=this;if(!ox(this,a))return Promise.reject(Error("err"));a=Gt(this.w,c);a.then(function(d){vt(b,[d])});return a};var Dba=function(a,c){c=a.f.get(c);if(!c)return Promise.reject(Error("Route not found"));a=a.Ve(c.sinkId);return"hangouts"!=a&&"meetings"!=a?Promise.reject(Error("Unsupported sink channel type")):As(Oi.get("mr.ProviderManager")||null,a)};h=mx.prototype;
h.createMediaRouteController=function(a,c,b){return Dba(this,a).then(function(d){return d.createMediaRouteController(a,c,b)})};h.provideSinks=function(){};h.Ea=function(){return"CloudProvider"};h.jb=function(){return[void 0,{cloudEnabled:this.g,cloudOn:this.h,notifiedHangoutsPrivacy:this.m}]};h.ib=function(){var a=Zl(this);a&&(a.cloudEnabled&&(this.g=a.cloudEnabled),a.cloudOn&&(this.h=a.cloudOn),a.notifiedHangoutsPrivacy&&(this.m=a.notifiedHangoutsPrivacy))};var Bba=function(a,c){a=new lx(a,c);return si(a.start())};
mx.prototype.l=hb("mr.CloudProvider");var zba=new Ul("pseudo:cloud","","meeting","","default");var rx=function(){Bp.call(this,12,"ExternalMessageListener","mr.ProviderManager",chrome.runtime.onMessageExternal)};q(rx,Bp);rx.prototype.hh=function(a,c){return c.id&&-1!=Eba.indexOf(c.id)?"start"==a.type||"stop"==a.type||"subscribe_log_data"==a.type:!1};rx.prototype.Ai=function(){return!0};var tx=function(){sx||(sx=new rx);return sx},sx=null,Eba=["idmofbkcelhplfjnmmdolenpigiiiecc","ggedfkijiiammpnbdadhllnehapomdge","njjegkblellcjnakomndbaloifhcoccg"];var ux=function(){Bp.call(this,11,"InternalMessageListener","mr.ProviderManager",chrome.runtime.onMessage)};q(ux,Bp);ux.prototype.hh=function(a,c){return"retrieve_log_data"==a.type&&c.id==chrome.runtime.id&&c.url=="chrome-extension://"+c.id+"/feedback.html"};ux.prototype.Ai=function(){return!0};var wx=function(){vx||(vx=new ux);return vx},vx=null;function Fba(){var a=xx;var c=new tq(a);var b=new Gr(a);c=[c,b];c.push(new mx(a));return c};var yx=function(a,c){this.routeId=a;this.message=c},zx=function(a){return"string"!=typeof a.message};var Ax=function(a){this.D=a;this.h=this.j=null},Bx=function(a){if(null==a.h)if(null==a.j||Date.now()-a.j>=a.D)a.w();else{var c=Math.max(a.j+a.D-Date.now(),5);a.h=setTimeout(a.w.bind(a),c)}};Ax.prototype.w=function(){null!=this.h&&(clearTimeout(this.h),this.h=null);this.s();this.j=Date.now()};Ax.prototype.s=function(){};var Cx=function(a,c){Ax.call(this,20);this.b=new Map;this.f=new Set;this.o=null;this.m=this.g=0;this.C=!1;this.L=a;this.F=c;this.l=hb("mr.RouteMessageSender")};q(Cx,Ax);Cx.prototype.init=function(a){this.o=a;am(this)};Cx.prototype.stopListeningForRouteMessages=function(a){this.f.delete(a)};
Cx.prototype.send=function(a,c){var b=this.b.get(a);b||(b=[],this.b.set(a,b));c=new yx(a,c);b.push(c);50<b.length&&1==b.length%50&&this.l.G(function(){return"Message queue length is excessively large "+("("+b.length+") for route "+a)});this.g+=zx(c)?0:c.message.length;zx(c)&&this.m++;Dx(this);this.f.has(a)&&Bx(this)};
var Ex=function(a,c){if(0!=c.length){c=l(c);for(var b=c.next();!b.done;b=c.next())b=b.value,a.g-=zx(b)?0:b.message.length,zx(b)&&a.m--}},Dx=function(a){var c=0<a.m||a.g>a.F;c!=a.C&&(a.C=c,a.L.Wf(a.Ea(),c))};Cx.prototype.s=function(){if(this.o){for(var a=l(this.f),c=a.next();!c.done;c=a.next()){c=c.value;var b=this.b.get(c);b&&0!=b.length&&(this.o(c,b),Ex(this,b),this.b.set(c,[]))}Dx(this)}else this.l.error("sendMessagesCallback not set. Messages not delivered.")};Cx.prototype.Ea=function(){return"mr.RouteMessageSender"};
Cx.prototype.jb=function(){var a=[].concat(n(this.b.entries())).map(function(c){return[c[0],c[1].map(function(b){return b.message})]});return[new Gba(a,Array.from(this.f),this.g)]};Cx.prototype.ib=function(){var a=Yl(this);if(a){this.b=new Map;for(var c={},b=l(a.f),d=b.next();!d.done;c={mh:c.mh},d=b.next())d=d.value,c.mh=d[0],d=d[1].map(function(e){return function(f){return new yx(e.mh,f)}}(c)),this.b.set(c.mh,d);this.f=new Set(a.b);this.g=a.g}};var Gba=function(a,c,b){this.f=a;this.b=c;this.g=b};var Hba=function(a,c){this.type="internal_message";this.routeId=a;this.message=c};var Fx=function(a,c,b){this.b=a;this.h=c;this.g=b;this.onMessage=function(){};b.listen("internal_message",this.f,this)};Fx.prototype.sendMessage=function(a,c){return this.h(this.b,a,c)};Fx.prototype.f=function(a){if(a.routeId==this.b)this.onMessage(a.message)};Fx.prototype.Za=function(){this.onMessage=function(){};Iq(this.g,this.f,this)};
var Iba=new Fx("",function(){return Promise.resolve()},new Hq),Jba=function(a){this.b=a},kx=function(a){var c=gi,b=c.b.Mi(a);return b?new Fx(a,b.sendRouteMessage.bind(b),c.b.Oi()):Iba};var Gx=function(a,c){this.w=null!=c?a.bind(c):a;this.j=this.m.bind(this);this.h=[];this.b=!1;this.f=null};Gx.prototype.g=function(a){for(var c=[],b=0;b<arguments.length;++b)c[b-0]=arguments[b];this.h=[].concat(n(c));null==this.f?Hx(this):this.b=!0};var Hx=function(a){a.f=setTimeout(a.j,500);a.w.apply(a,n(a.h))};Gx.prototype.m=function(){this.f=null;this.b&&(this.b=!1,Hx(this))};var Ix=function(){this.l=hb("mr.ProviderManager");this.g=[];this.f=new Map;this.m=new Map;this.j=new Set;this.h=new Set;this.D=new Map;this.b=this.s=null;this.O=new Hq;this.T=new Gx(this.fn,this);this.da=new Gx(this.L,this);this.w=new Cx(this,524288);this.F=0;this.o=new Map;this.C=[];var a=new vs(this);this.Ua=a.onMessage.bind(a);a=new ms(this);this.W=a.onMessage.bind(a);this.H="";this.J=!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};q(Ix,Ni);
Ix.prototype.handleEvent=function(a,c){for(var b=[],d=1;d<arguments.length;++d)b[d-1]=arguments[d];if(a==chrome.runtime.onMessage)this.Ua.apply(this,n(b));else if(a==chrome.runtime.onMessageExternal)this.W.apply(this,n(b));else throw Error("Unhandled event");};
var As=function(a,c){c=a.D.get(c);return Ri(c).then(function(b){b.initialize(a,a.J);return b})},Kba=function(a,c,b){c.forEach(function(d){if(zs(a,d.getName()))a.l.G("Provider "+d.getName()+" already registered.");else try{d.initialize(b),a.g.push(d),a.o.set(d.getName(),0)}catch(e){a.l.G("Provider "+d.getName()+" failed to initialize.",e)}})};
Ix.prototype.initialize=function(a,c,b){this.D.set("webrtc","mr.mirror.webrtc.WebRtcService");this.D.set("cast_streaming","mr.mirror.cast.Service");this.D.set("hangouts","mr.mirror.hangouts.HangoutsService");this.D.set("meetings","mr.mirror.hangouts.MeetingsService");var d=new Jba(this);gi||(gi=d);this.b=a;this.w.init(this.b.onRouteMessagesReceived.bind(this.b));Kba(this,c,b);b&&void 0!==b.use_views_dialog&&(this.H=b.use_views_dialog?"Views":"WebUI");b&&void 0!==b.use_mirroring_service&&(this.J=b.use_mirroring_service);
am(this);Xi("mr.ProviderManager",this)};var Kx=function(a,c,b){return new Promise(function(d,e){var f=null;a.F++;Jx(a);f=window.setTimeout(function(){f=null;c.cancel(new qq(2,"timeout after "+b+" ms."))},b);c.b.then(function(g){a.F--;Jx(a);null!=f&&window.clearTimeout(f);d(g)},function(g){a.F--;Jx(a);null!=f&&window.clearTimeout(f);e(g instanceof qq?g:g instanceof Error?new qq(0,g.message,g.stack):new qq(0))})})};Ix.prototype.onBeforeInvokeHandler=function(){$i(0)};
var Lx=function(a){return"string"==typeof a?a:a.unique?"":a.scheme+"://"+a.host+"\n       "+(a.port?":"+a.port:"")+"/"};h=Ix.prototype;
h.createRoute=function(a,c,b,d,e,f,g){var k=this;g=void 0===g?!1:g;var m=Lba(this,a,c);if(!m)return Promise.reject(new qq(7,"No provider supports createRoute with source: "+a+" and sink: "+c));var p=void 0;void 0!==d&&(p=Lx(d));f=f&&0<f?f:6E4;a=m.createRoute(a,c,b,g,f,p,e);return Kx(this,a,f).then(function(v){return v},function(v){k.l.error("Error creating route.",v);throw v;})};
h.connectRouteByRouteId=function(a,c,b,d,e,f){var g=this.f.get(c);if(!g)return Promise.reject(new qq(7,"No provider supports join "+c));a=g.connectRouteByRouteId(a,c,b,Lx(d),e);return Kx(this,a,f&&0<f?f:3E4)};h.joinRoute=function(a,c,b,d,e,f){f=void 0===f?!1:f;var g=Mba(this,a,c);if(!g)return Promise.reject(new qq(7,"No provider supports join "+c));e=e&&0<e?e:3E4;a=g.joinRoute(a,c,f,e,Lx(b),d);return Kx(this,a,e)};
h.terminateRoute=function(a){var c=this.f.get(a);return c?Mx(this,a).then(function(){return c.terminateRoute(a)}):Promise.reject(new qq(3,"Route not found for routeId "+a))};h.startObservingMediaSinks=function(a){this.j.has(a)||(this.j.add(a),this.g.forEach(function(c){c.startObservingMediaSinks(a)}));Nx(this,a)};h.stopObservingMediaSinks=function(a){this.j.delete(a)?Ox(this,a):this.l.info("No existing query "+a)};
var Ox=function(a,c){a.g.forEach(function(b){b.stopObservingMediaSinks(c)})},Nx=function(a,c){if("urn:x-org.chromium.media:source:tab:-1"==c)a.l.G("No sinks for sourceUrn: "+c);else{var b=new Map,d=[];a.g.forEach(function(e){var f=e.Bg(c);0<f.sinks.length&&(d=f.origins);f.sinks.forEach(function(g){b.has(g.id)?a.l.G("Detected duplicate sink "+g.id+" from provider: "+e.getName()):b.set(g.id,g)})});Nba(a,c,Array.from(b.values()),d||[])}},Nba=function(a,c,b,d){a.l.info("Sending "+b.length+" sinks to MR for "+
c);a.b.onSinksReceived(c,b,d.map(Co))};h=Ix.prototype;h.sendRouteMessage=function(a,c,b){var d=this.f.get(a);d?(a=d.sendRouteMessage(a,c,b),a=Kx(this,si(a),3E4)):a=Promise.reject(Error("Invalid route ID "+a));return a};h.sendRouteBinaryMessage=function(a,c){var b=this.f.get(a);b?(a=b.sendRouteBinaryMessage(a,c),a=Kx(this,si(a),3E4)):a=Promise.reject(Error("Invalid route ID "+a));return a};
h.startListeningForRouteMessages=function(a){var c=this.w;c.f.has(a)||(c.f.add(a),(a=c.b.get(a))&&0<a.length&&Bx(c))};h.stopListeningForRouteMessages=function(a){this.w.stopListeningForRouteMessages(a)};h.detachRoute=function(a){var c=this.f.get(a);c?c.detachRoute(a):this.l.info("Route "+a+" does not exist.")};h.enableMdnsDiscovery=function(){};var Lba=function(a,c,b){return a.g.find(function(d){return d.ug(c,b)})||null},Mba=function(a,c,b){return a.g.find(function(d){return d.zf(c,b)})||null};
Ix.prototype.L=function(){var a=this;this.j.forEach(function(c){Nx(a,c)})};var Jx=function(a){a.b.setKeepAlive(0<a.F||0<a.C.length)};h=Ix.prototype;h.startObservingMediaRoutes=function(a){this.h.has(a)||(this.h.add(a),this.g.forEach(function(c){c.startObservingMediaRoutes(a)}));this.T.g()};h.stopObservingMediaRoutes=function(a){this.h.delete(a)?this.g.forEach(function(c){c.stopObservingMediaRoutes(a)}):this.l.info("No existing route query "+a)};
h.fn=function(){var a=this;if(0!=this.h.size){var c=[];this.g.forEach(function(b){c=c.concat(b.Bd())});this.h.forEach(function(b){var d=[];a.g.forEach(function(e){e.Bd().forEach(function(f){!f.Cf&&e.zf(b,void 0,f)&&d.push(f.id)})});a.b.onRoutesUpdated(c,b,d)})}};h.Ea=function(){return"ProviderManager"};
h.jb=function(){return[new Oba(this.g.map(function(a){return a.getName()}),Array.from(this.j),Array.from(this.h),Array.from(this.f,function(a){var c=l(a);a=c.next().value;c=c.next().value;return[a,c.getName()]}),Array.from(this.o),this.s)]};h.ib=function(){var a=Yl(this);if(a){this.j=new Set(a.j);this.h=new Set(a.g);for(var c=l(a.f),b=c.next();!b.done;b=c.next()){var d=l(b.value);b=d.next().value;d=d.next().value;d=zs(this,d);this.f.set(b,d)}this.o=new Map(a.h);this.s=a.b||null}};h.Mi=function(a){return this.f.get(a)};
h.Uf=function(a,c){this.f.set(c.id,a);this.Ye(c)};h.Ig=function(a){Mx(this,a.id);this.f.delete(a.id);var c=this.w,b=a.id;c.f.delete(b);var d=c.b.get(b);d&&(c.b.delete(b),Ex(c,d),Dx(c));this.Ye(a)};h.Ye=function(){0<this.h.size&&this.T.g()};h.Si=function(a){var c=this.f.get(a.id);c&&(c.Sh(a.id),0<this.h.size&&this.fn())};h.ee=function(a,c){this.f.has(a)?("string"===typeof c||c instanceof Uint8Array||(c=JSON.stringify(c)),this.w.send(a,c)):this.l.G("Got route message for closed route "+a)};
h.onPresentationConnectionStateChanged=function(a,c){"terminated"==c&&this.w.w();this.b.onPresentationConnectionStateChanged(a,c)};h.onPresentationConnectionClosed=function(a,c,b){this.w.w();this.b.onPresentationConnectionClosed(a,c,b)};h.Th=function(a){this.m.delete(a);var c=this.f.get(a);c&&c.terminateRoute(a)};h.Rh=function(a,c){Jq(this.O,new Hba(a,c))};h.dd=function(){this.da.g()};
h.onSinkAvailabilityUpdated=function(a,c){var b=this;if(this.o.get(a.getName())!=c){var d=Px(this);this.o.set(a.getName(),c);a=Px(this);d!=a&&(0==a&&this.L(),this.b.onSinkAvailabilityUpdated(a),0==a&&(this.j.forEach(function(e){Ox(b,e)}),this.j.clear()))}};var Px=function(a){return Array.from(a.o.values()).reduce(function(c,b){return Math.max(c,b)},0)};Ix.prototype.Oi=function(){return this.O};Ix.prototype.Ze=function(a){this.b.onIssue(a)};
var Mx=function(a,c){return a.m.has(c)?As(a,a.m.get(c)).then(function(b){a.m.delete(c);return b.m()}):Promise.resolve(!1)};Ix.prototype.rj=function(a,c,b,d){var e=this,f=a.Ve(c.sinkId);this.l.info("Starting mirroring using service: "+f);this.m.set(c.id,f);return ti(As(this,f),function(g){e.s=f;return g.Gj(c,c.mediaSource,a.Gf(c.sinkId),b,d).catch(function(k){if(k instanceof vi&&3==k.reason)throw new qq(8);throw k;})})};
Ix.prototype.im=function(a,c,b,d,e,f){var g=this,k=this.m.get(c.id);return k?ti(As(this,k),function(m){g.s=k;return m.Hj(c,b,a.Gf(c.sinkId),d,e,f)}):ri(Error("Route "+c.id+" is not mirroring"))};Ix.prototype.Wf=function(a,c){var b=this.C.indexOf(a),d=0<=b;c&&!d?this.C.push(a):!c&&d&&this.C.splice(b,1);Jx(this)};var zs=function(a,c){return a.g.find(function(b){return b.getName()==c})||null};h=Ix.prototype;
h.searchSinks=function(a,c,b){var d=a.startsWith("pseudo:")?a.substring(7):null;return(d=d?zs(this,d):null)?d.searchSinks(c,b).then(function(e){return e.id}):Promise.reject(Error("No provider supports "+a))};h.provideSinks=function(a,c){var b=zs(this,a);b?b.provideSinks(c):this.l.error("provideSinks: Provider not found for providerName "+a)};h.updateMediaSinks=function(a){this.j.has(a)||Nx(this,a)};
h.createMediaRouteController=function(a,c,b){var d=this,e=this.f.get(a);return e?e.createMediaRouteController(a,c,b).catch(function(f){d.l.error("createMediaRouteController failed: "+f.message);c.close();b.ptr.reset();throw f;}):(a="createMediaRouteController: Provider not found for "+a,this.l.error(a),c.close(),b.ptr.reset(),Promise.reject(Error(a)))};h.onMediaRemoterCreated=function(a,c,b){this.b.onMediaRemoterCreated(a,c,b)};
h.getMediaSinkServiceStatus=function(){return"function"!=typeof this.b.getMediaSinkServiceStatus?Promise.resolve({status:""}):this.b.getMediaSinkServiceStatus()};h.getMirroringServiceHostForTab=function(a,c){this.b.getMirroringServiceHostForTab(a,c)};h.getMirroringServiceHostForDesktop=function(a,c,b){this.b.getMirroringServiceHostForDesktop(a,c,b)};h.getMirroringServiceHostForOffscreenTab=function(a,c,b){this.b.getMirroringServiceHostForOffscreenTab(a,c,b)};
var Oba=function(a,c,b,d,e,f){this.j=c;this.g=b;this.f=d;this.h=e;this.b=f};
