// Adds to the provider a 'register#{handlerName}' function that manages multiple plugins and buffer flushing.
functiong(a){vard="register"+f(a);o[d]=function(b,c){e(a,b,c)},n[a]=c(a,b(a))}varh={pageTracking:{autoTrackFirstPage:!0,autoTrackVirtualPages:!0,trackRelativePath:!1,autoBasePath:!1,basePath:"",excludedRoutes:[]},eventTracking:{},bufferFlushDelay:1e3,// Support only one configuration for buffer flush delay to simplify buffering
// Set up register functions for each known handler
a.forEach(i,g);for(varqino)this[q]=o[q]}functiond(b,c,d,e){functionf(a){for(varb=0;b<d.settings.pageTracking.excludedRoutes.length;b++){varc=d.settings.pageTracking.excludedRoutes[b];if(cinstanceofRegExp&&c.test(a)||a.indexOf(c)>-1)return!0}return!1}functiong(a,b){f(a)||d.pageTrack(a,b)}d.settings.pageTracking.autoTrackFirstPage&&e.invoke(["$location",function(a){/* Only track the 'first page' if there are no routes or states on the page */
varb=!0;if(e.has("$route")){varf=e.get("$route");if(f)for(varhinf.routes){b=!1;break}elsenull===f&&(b=!1)}elseif(e.has("$state")){vari=e.get("$state");for(varjini.get()){b=!1;break}}if(b)if(d.settings.pageTracking.autoBasePath&&(d.settings.pageTracking.basePath=c.location.pathname),d.settings.pageTracking.trackRelativePath){vark=d.settings.pageTracking.basePath+a.url();g(k,a)}elseg(a.absUrl(),a)}]),d.settings.pageTracking.autoTrackVirtualPages&&e.invoke(["$location",function(a){d.settings.pageTracking.autoBasePath&&(/* Add the full route to the base. */
e.analyticsProperties&&a.extend(g,c.$eval(e.analyticsProperties)),b.eventTrack(i,g))})}}}functionf(a){a.decorator("$exceptionHandler",["$delegate","$injector",function(a,b){returnfunction(c,d){vare=a(c,d),f=b.get("$analytics");returnf.settings.trackExceptions&&f.exceptionTrack(c,d),e}}])}functiong(a){return["a:","button:","button:button","button:submit","input:button","input:submit"].indexOf(a.tagName.toLowerCase()+":"+(a.type||""))>=0}functionh(a){returng(a)?a.innerText||a.value:a.id||a.name||a.tagName}functioni(a){return"analytics"===a.substr(0,9)&&["On","Event","If","Properties","EventType"].indexOf(a.substr(9))===-1}functionj(a){varb=a.slice(9);// slice off the 'analytics' prefix