/*
 Tackle.js v1.2.1
 Docs & License: http://www.tacklehealth.com/docs
 (c) 2016 Tackle, Inc.
*/
var $jscomp={scope:{}};$jscomp.defineProperty="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){if(c.get||c.set)throw new TypeError("ES3 does not support getters and setters.");a!=Array.prototype&&a!=Object.prototype&&(a[b]=c.value)};$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this);$jscomp.SYMBOL_PREFIX="jscomp_symbol_";
$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.symbolCounter_=0;$jscomp.Symbol=function(a){return $jscomp.SYMBOL_PREFIX+(a||"")+$jscomp.symbolCounter_++};
$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var a=$jscomp.global.Symbol.iterator;a||(a=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("iterator"));"function"!=typeof Array.prototype[a]&&$jscomp.defineProperty(Array.prototype,a,{configurable:!0,writable:!0,value:function(){return $jscomp.arrayIterator(this)}});$jscomp.initSymbolIterator=function(){}};$jscomp.arrayIterator=function(a){var b=0;return $jscomp.iteratorPrototype(function(){return b<a.length?{done:!1,value:a[b++]}:{done:!0}})};
$jscomp.iteratorPrototype=function(a){$jscomp.initSymbolIterator();a={next:a};a[$jscomp.global.Symbol.iterator]=function(){return this};return a};$jscomp.array=$jscomp.array||{};$jscomp.iteratorFromArray=function(a,b){$jscomp.initSymbolIterator();a instanceof String&&(a+="");var c=0,d={next:function(){if(c<a.length){var e=c++;return{value:b(e,a[e]),done:!1}}d.next=function(){return{done:!0,value:void 0}};return d.next()}};d[Symbol.iterator]=function(){return d};return d};
$jscomp.polyfill=function(a,b,c,d){if(b){c=$jscomp.global;a=a.split(".");for(d=0;d<a.length-1;d++){var e=a[d];e in c||(c[e]={});c=c[e]}a=a[a.length-1];d=c[a];b=b(d);b!=d&&null!=b&&$jscomp.defineProperty(c,a,{configurable:!0,writable:!0,value:b})}};$jscomp.polyfill("Array.prototype.keys",function(a){return a?a:function(){return $jscomp.iteratorFromArray(this,function(a){return a})}},"es6-impl","es3");
$jscomp.findInternal=function(a,b,c){a instanceof String&&(a=String(a));for(var d=a.length,e=0;e<d;e++){var l=a[e];if(b.call(c,l,e,a))return{i:e,v:l}}return{i:-1,v:void 0}};$jscomp.polyfill("Array.prototype.find",function(a){return a?a:function(a,c){return $jscomp.findInternal(this,a,c).v}},"es6-impl","es3");
(function(){var a,b,c;if(b=!!/tacklehealth\.com$/.test("undefined"!=typeof window&&null!==window?window.location.host:void 0),a="console"in window&&"warn"in window.console,!b&&"querySelectorAll"in document&&a&&(c=document.querySelectorAll('script[src^="https://www.tacklehealth.com"]'),c.length||console.warn("It looks like Tackle.js is not being loaded from https://www.tacklehealth.com/Tackle.js. Tackle does not support serving Tackle.js from your own domain. You will miss any updates we make to the library.")),
this.Tackle)return!a||this.Tackle.isDoubleLoaded||this.Tackle.earlyError||console.warn("It looks like Tackle.js was loaded more than one time. Please only load it once per page."),void(this.Tackle.isDoubleLoaded=!0);this.Tackle=function(){function a(){}return a.version=1,a.endpoint="https://www.tacklehealth.com:3456",a.setKey=function(d){return a.key=d,a.utils.validateKey(a.key)},a.formatParams=function(a){return null!=a&&""!=a?"?"+Object.keys(a).map(function(d){return d+"="+encodeURIComponent(a[d])}).join("&"):
""},a.request=function(d,l,b,c,h){var e=new XMLHttpRequest;e.onreadystatechange=function(){4===e.readyState&&(200===e.status?h(e.status,Tackle.requestSuccess(e.responseText)):h(e.status,Tackle.requestError(e.status,e.responseText)))};l=(Tackle.endpoint+l).concat(Tackle.formatParams(b));e.open(d,l,!0);e.setRequestHeader("Authorization","Bearer "+a.key);""!=c?(e.setRequestHeader("Content-Type","application/json"),e.send(c)):e.send()},a.requestSuccess=function(a){return{error:!1,data:JSON.parse(a)}},
a.requestError=function(a,d){return"console"in window&&"warn"in window.console,b=Math.round((new Date).getTime()/1E3),{error:!0,status:a,message:d}},a.formatData=function(a,d){var e;Tackle.utils.isElement(a);for(e in a)-1==d.indexOf(e)&&delete a[e];return a},a}();this.Tackle.time=function(a,e){function d(){return d.__super__.constructor.apply(this,arguments)}return Tackle.utils.validateKey(Tackle.key),d.whitelist=["startTime","endTime","providerId","appointmentTypeId"],Tackle.request("GET","/available-appointments/",
Tackle.formatData(a,d.whitelist),"",e)};this.Tackle.resources=function(a){return Tackle.utils.validateKey(Tackle.key),Tackle.request("GET","/available-providers/","","",a)}}).call(this);
(function(){var a=[].indexOf||function(a){for(var b=0,d=this.length;b<d;b++)if(b in this&&this[b]===a)return b;return-1};this.Tackle.isDoubleLoaded||(this.Tackle.utils=function(){function b(){}var c;return c=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,b.trim=function(a){return null===a?"":(a+"").replace(c,"")},b.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)},b.serialize=function(a,e,b){var d,l;null==e&&(e=[]);try{for(d in a)l=a[d],b&&(d=""+b+"["+d+"]"),"object"==typeof l?
this.serialize(l,e,d):e.push(""+d+"="+encodeURIComponent(l));return e.join("&").replace(/%20/g,"+")}catch(h){throw Error("Unable to serialize: "+a);}},b.underscore=function(a){return(a+"").replace(/([A-Z])/g,function(a){return"_"+a.toLowerCase()}).replace(/-/g,"_")},b.underscoreKeys=function(a){var d,b,c;c=[];for(d in a)b=a[d],delete a[d],c.push(a[this.underscore(d)]=b);return c},b.isElement=function(a){return"object"==typeof a},b.addClass=function(a,e){return a.className=this._removedClassString(a,
e)+" "+e},b.removeClass=function(a,e){return a.className=this._removedClassString(a,e)},b._removedClassString=function(a,e){return Tackle.utils.trim(a.className.replace(new RegExp("( |^)"+e+"( |$)","g")," "))},b.paramsFromForm=function(d,e){var b,c,g,h,m,n,f;null==e&&(e=[]);d.jquery&&(d=d[0]);g=d.getElementsByTagName("input");h=d.getElementsByTagName("select");m={};n=0;for(f=g.length;n<f;n++)c=g[n],b=this.underscore(c.getAttribute("data")),0>a.call(e,b)||(m[b]=c.value);g=0;for(n=h.length;g<n;g++)c=
h[g],b=this.underscore(c.getAttribute("data")),0>a.call(e,b)||null!=c.selectedIndex&&(m[b]=c.options[c.selectedIndex].value);return m},b.validateKey=function(a){if(!a||"string"!=typeof a)throw Error("You did not set a valid key. Call Tackle.setKey() with your publishable key. For more info, see Tackle.js documentation");if(/\s/g.test(a))throw Error("Your key is invalid, as it contains whitespace. For more info, see Tackle.js documentation");},b.parseExpString=function(a){var d,b,c,g,h,m,n,f;h=function(d){throw Error("You passed an invalid expiration date `"+
a+"`. "+(d||"")+"Please pass an unix integer such as 1479499314 For more info, see https://developer.tacklehealth.com/docs/");};"string"!=typeof a&&h();g=a.split(/[\.\-\/\s]+/g);2!==g.length&&h();d=n=0;for(f=g.length;n<f;d=++n)c=g[d],c=parseInt(c),isNaN(c)&&h(""+g+" is not a number. "),1>c&&h(""+c+" is less than one. "),g[d]=c;return 12<g[0]?(m=g[0],b=g[1]):(b=g[0],m=g[1]),12<b&&h("Month must be a number 1-12, not "+b+". "),100>m&&(m+=2E3),[b,m]},b.formatAmountWithCurrency=function(d,b){var e,c,g;
return e=parseFloat(d),c="bif clp djf gnf jpy kmf krw mga pyg rwf vnd vuv xaf xof xpf".split(" "),g=b.toLowerCase(),0>a.call(c,g)&&(e=Math.round(100*e)),parseInt(e)},b.formatTime=function(a){return(new Date(1E3*a)).toLocaleTimeString(navigator.language,{hour:"2-digit",minute:"2-digit",hour12:!0}).replace(/^([^\d]*\d{1,2}:\d{1,2}):\d{1,2}([^\d]*)$/,"$1$2")},b.formatTimeShort=function(a){return(new Date(1E3*a)).toLocaleTimeString(navigator.language,{hour:"2-digit",minute:"2-digit",hour12:!0}).replace(/^([^\d]*\d{1,2}:\d{1,2}):\d{1,2}([^\d]*)$/,
"$1$2").replace(/(:\d{2}| [AP]M)$/,"")},b.formatDate=function(a){a=new Date(1E3*a);return"Sun Mon Tue Wed Thu Fri Sat".split(" ")[a.getDay()]+" "+a.toLocaleDateString(navigator.language,{month:"numeric",day:"numeric"})},b}())}).call(this);
(function(a){"function"===typeof define&&define.amd?define(["jquery"],a):"object"===typeof exports?module.exports=a(require("jquery")):a(jQuery)})(function(a){function b(a,d){var e={},c,f,k,q,g;if(d)for(c=0;c<d.length;c++){f=d[c];k=[];for(q=a.length-1;0<=q;q--)if(g=a[q][f],"object"===typeof g)k.unshift(g);else if(void 0!==g){e[f]=g;break}k.length&&(e[f]=b(k))}for(c=a.length-1;0<=c;c--)for(f in k=a[c],k)f in e||(e[f]=k[f]);return e}function c(a){var b=function(){};b.prototype=a;return new b}function d(a,
b){for(var d in a)m.call(a,d)&&(b[d]=a[d])}function e(){Date.now||(Date.now=function(){return(new Date).getTime()});return Math.floor(Date.now()/1E3)}function l(){}function A(a,b){var e;m.call(b,"constructor")&&(e=b.constructor);"function"!==typeof e&&(e=b.constructor=function(){a.apply(this,arguments)});e.prototype=c(a.prototype);d(b,e.prototype);d(a,e);return e}function g(b){function e(){var c=a("<div></div>"),e=a('<div class="tw-provider tw-width-12"></div>'),f=b.options,g=a("<select id='tw-provider' class='tw-select'></select>");
g.append("<option disabled selected>Which provider are you seeing?</option>");a.each(f.resources,function(a,b){var c="Dr. "+b.firstName+" "+b.lastName;"NP"==b.degree?c=b.firstName+" "+b.lastName+", NP":"PA"==b.firstName&&(c=b.firstName+" "+b.lastName+", PA");g.append("<option value='"+a+"'>"+c+"</option>")});g.on("change",function(){var a=f.resources[this.value],c=new Date;c.setTime(c.getTime()+36E5);document.cookie="tackleProvCookie="+a.id+"; expires="+c.toUTCString()+"; path=/";f.appointmentTypes.split(",");
d(a);b.renderInitialEvents()});e.append(g);c.append(e).append(d(f.resources[0]));return c}function d(c){g?g.empty():g=this.apptEl=a('<div class="tw-reason tw-width-12"></div>');var e=b.options,d=e.appointmentTypes.split(","),f=a("<select id='tw-appointment' class='tw-select'></select>");f.append("<option disabled selected>What is your visit for?</option>");if(void 0!=c){var q=!1;f.on("change",function(){var a=c.appointmentTypes[this.value].id,d=new Date;d.setTime(d.getTime()+36E5);document.cookie=
"tackleApptCookie="+a+"; expires="+d.toUTCString()+"; path=/";b.refetchEvents(e.start,e.end,c.id,a)});a.each(c.appointmentTypes,function(a,b){if(""===d[0]||-1<d.indexOf(b.id))f.append("<option value="+a+">"+b.name+"</option>"),q=!0});q||f.append("<option disabled>No appointments found</option>")}else f.append("<option disabled>No appointments found</option>");g.append(f);return g}var c=this;c.render=function(){var c,d=a("<div class='tw-title-bar'><div class='tw-fill tw-inline-block'><span class='tw-header'>Schedule an Appoinment</span></div></div>");
f?f.empty():f=this.el=a("<div class='tw-menu-bar'></div>");c=a("<div class='tw-fill tw-inline-block'></div>");c.append(e());f.append(d).append(c);b.renderInitialEvents()};c.removeElement=function(){f&&(f.remove(),f=c.el=null)};c.updateTitle=function(a){f&&f.find(".tw-header").text(a)};c.activateButton=function(a){f&&f.find(".tw-"+a+"-select").addClass("tw-state-active")};c.deactivateButton=function(a){f&&f.find(".tw-"+a+"-select").removeClass("tw-state-active")};c.disableButton=function(a){f&&f.find(".tw-"+
a+"-select").prop("disabled",!0).addClass("tw-state-disabled")};c.enableButton=function(a){f&&f.find(".tw-"+a+"-select").prop("disabled",!1).removeClass("tw-state-disabled")};c.el=null;c.apptEl=null;c.resources=null;var f,g}var h=a.tackleWidget={version:"1.2.1",internalApiVersion:5};a.fn.tackleWidget=function(b){var c=Array.prototype.slice.call(arguments,1),d=this;this.each(function(e,f){var g=a(f),k=g.data("tackleWidget");"string"===typeof b?k&&a.isFunction(k[b])&&(k=k[b].apply(k,c),e||(d=k),"destroy"===
b&&g.removeData("tackleWidget")):k||(k=new n(g,b),g.data("tackleWidget",k),k.render())});return d};var m={}.hasOwnProperty;h.Class=l;l.extend=function(){var a=arguments.length,b,c;for(b=0;b<a;b++)c=arguments[b],b<a-1&&d(c,this.prototype);return A(this,c||{})};l.mixin=function(a){d(a,this.prototype)};h.EmitterMixin={on:function(b,c){var d=function(a,b){return c.apply(b.context||this,b.args||[])};c.guid||(c.guid=a.guid++);d.guid=c.guid;a(this).on(b,d);return this},off:function(b,c){a(this).off(b,c);
return this},trigger:function(b){var c=Array.prototype.slice.call(arguments,1);a(this).triggerHandler(b,{args:c});return this},triggerWith:function(b,c,d){a(this).triggerHandler(b,{context:c,args:d});return this}};var n=h.widget=l.extend({options:null,overrides:null,dynamicOverrides:null,header:null,loadingLevel:0,constructor:function(b,c){function d(){r.resources=u;r.render();r.el&&b.prepend(r.el).prepend()}function e(a,b){b.error?k([]):0<b.data.count?k(b.data.payload):k([])}function f(b,c){if(c.error)throw z({resources:[]}),
u=[],d(),Error("There was an error with your request. The widget may not load");var e=c.data;if(""!=v.providers){var f=v.providers.split(","),e=[];a.each(f,function(b,d){var f=a.grep(c.data,function(a){return a.id==d});void 0!=f[0]&&e.push(f[0]);console.warn("Specified provider with id "+d.id+" is not a part of the system for which this key is defined.")})}if(0===e.length)throw u=[],Error("Your specified options do not correspond to any allowed resources. This will cause the widget not to render.");
u=e;z({resources:u});d()}function h(b){a("#tw-timeslots-container").html("<div id='tw-loading' class='tw-inline-block'><span>Loading...</span></div>");a("#tw-loading").show();Tackle.resources(f)}function k(a){b.is(":visible")&&(m(),l(a,!1),w())}function l(b,c){a("#tw-timeslots-container").empty();var d=5<b.length?b.slice(0,5):b;a("#tw-timeslots-container").html("");c?a("#tw-timeslots-container").append("<div class='tw-notification'><span>Select a provider and an appointment type to see their availability.</span></div>"):
0===d.length&&a("#tw-timeslots-container").append("<div class='tw-notification'><span>There are no appointments of this type available at this time</span></div>");for(i=0;i<d.length;i++)a("#tw-timeslots-container").append(n(d[i]));a("#tw-timeslots").scrollTop(0)}function n(b){var c=a("<div class='tw-interactionRow'></div>");a("#tw-provider");var d="<b>"+Tackle.utils.formatDate(b.startTime)+"</b>: "+Tackle.utils.formatTime(b.startTime)+" - "+Tackle.utils.formatTime(b.endTime);c.on("click",function(){window.location=
"https://"+b.linkToBook});c.append("<div class='tw-width-11 tw-inline-block'><span class='tw-addText'>"+d+"</span></div><div class='tw-width-1'><svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 1792 1792' class='tw-svg'><path d='M1171 960q0 13-10 23l-466 466q-10 10-23 10t-23-10l-50-50q-10-10-10-23t10-23l393-393-393-393q-10-10-10-23t10-23l50-50q10-10 23-10t23 10l466 466q10 10 10 23z'></path></svg></div>");return c}function m(){t.css({width:"100%",height:t.height(),overflow:"hidden"})}
function w(){t.css({width:"",height:"",overflow:""})}function z(a){for(var b in a){if("resources"===b)for(x in a[b])null===a[b][x].appointmentTypes&&a[b].splice(x,1);p.dynamicOverrides[b]=a[b]}p.populateOptionsHash()}var p=this;p.render=function(){t?b.is(":visible")&&(calcSize(),renderView()):(b.addClass("tw"),t=a("<div class='tw-time-container' id='tw-timeslots'><div id='tw-timeslots-container' class='tw-width-12'></div></div>").prependTo(b),b.after("<div class='tw-footer tw-width-12'><a class='tw-link' href='https://www.tacklehealth.com/more_appointments'>See all appointments</a></div><div class='tw-powered'><a href='https://www.tacklehealth.com'><img class='tw-max-width-half' src='http://i.imgur.com/IDGf9hT.png' /></a></div>"),
r=p.header=new g(p),h())};p.destroy=function(){r.removeElement();t.remove();b.removeClass("tw");b.off(".tw")};p.refetchEvents=function(b,c,d,f){a("#tw-timeslots-container").html("<div id='tw-loading' class='tw-inline-block'><span>Loading...</span></div>");a("#tw-loading").show();Tackle.time({startTime:b,endTime:c,providerId:d,appointmentTypeId:f},e)};p.refetchResources=h;p.renderInitialEvents=function(){b.is(":visible")&&(m(),l([],!0),w())};p.dynamicOverrides={};p.overrides=a.extend({},c);p.populateOptionsHash();
var v=this.options,r,t,u;Tackle.setKey(v.key);var y=new Date;y.setTime(y.getTime()+36E5);document.cookie="tackleWidgetCookie="+v.key+"; expires="+y.toUTCString()+"; path=/";p.freezeContentHeight=m;p.unfreezeContentHeight=w;p.initialize()},populateOptionsHash:function(){this.options=b([n.defaults,this.overrides,this.dynamicOverrides])},initialize:function(){}});n.defaults={providers:"",offices:"",appointmentTypes:"",resources:null,height:"10em",start:e(),end:e()+1209600,lazyFetching:!0,timezoneParam:"timezone",
timezone:!1,handleWindowResize:!0,windowResizeDelay:0};return h});
