");return b.bind(c.html,c)}(),d=/<\/?p>|
/gi;return{stripTags:function(b){return b=b.replace(d," ").replace(/<[\/\w!\[][^>]*>/g,""),a.trim(c(b).text().replace(/\u200b/g,""))},replaceAnchors:function(a,c){var d;try{d=(new DOMParser).parseFromString(a,"text/html")}catch(e){}return d||(d=document.implementation.createHTMLDocument(""),d.body.innerHTML=a),b.each(d.querySelectorAll("a"),function(a){var b=a.getAttribute("href")||"",d=a.innerHTML,e=c(a);0===b.indexOf(d.slice(0,-3))?d=e:b.length&&-1!==d.indexOf(b)?d=d.replace(b,e):d+=" "+e,a.insertAdjacentHTML("afterend",d),a.parentNode.removeChild(a)}),d.body.innerHTML.trim()}}}),define("core/advice",["underscore"],function(a){"use strict";function b(){a.each(["before","after","around"],function(a){this[a]=function(b,d){return this[b]="function"==typeof this[b]?c[a](this[b],d):d}},this)}var c={around:function(b,c){return function(){var d=a.toArray(arguments);return c.apply(this,[a.bind(b,this)].concat(d))}},before:function(b,d){return c.around(b,function(){var b=a.toArray(arguments),c=b.shift();return d.apply(this,b),c.apply(this,b)})},after:function(b,d){return c.around(b,function(){var b=a.toArray(arguments),c=b.shift(),e=c.apply(this,b);return d.apply(this,b),e})}};return{withAdvice:b}}),define("core/models/mixins",["underscore","moment","core/time"],function(a,b,c){"use strict";function d(){this._getCreatedMoment=a.memoize(function(){var a=this.get("createdAt");if(a)return b(c.assureTzOffset(a),c.ISO_8601)},function(){return this.get("createdAt")}),this.getRelativeCreatedAt=function(){var a=this._getCreatedMoment();return a&&a.from(+new Date)},this.getFormattedCreatedAt=a.memoize(function(){var a=this._getCreatedMoment();return a&&a.format("LLLL")},function(){return this.get("createdAt")})}return{withCreatedAt:d}}),define("core/collections/UserCollection",["underscore","backbone","core/api","core/models/User"],function(a,b,c,d){"use strict";var e=b.Collection.extend({model:d,initialize:function(a,c){b.Collection.prototype.initialize.apply(this,arguments),this.thread=c&&c.thread}});return e}),define("core/collections/UpvotersUserCollection",["underscore","backbone","core/api","core/collections/UserCollection"],function(a,b,c,d){"use strict";var e=d.extend({LIMIT:50,url:function(){return c.getURL("posts/listUsersVotedPost")},initialize:function(a,b){this.postId=b.postId,this.threadId=b.threadId},fetch:function(c){return b.Collection.prototype.fetch.call(this,a.extend({data:{post:this.postId,thread:this.threadId,vote:1,limit:this.LIMIT}},c))}});return e}),define("core/models/Vote",["backbone"],function(a){"use strict";var b=a.Model.extend({defaults:{score:0}});return b}),define("core/collections/VoteCollection",["backbone","core/models/Vote"],function(a,b){"use strict";var c=a.Collection.extend({model:b});return c}),define("core/models/Post",["jquery","underscore","backbone","moment","core/api","core/strings","core/time","core/utils","core/utils/html","core/advice","core/models/mixins","core/models/User","core/collections/UserCollection","core/collections/UpvotersUserCollection","core/collections/VoteCollection"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o){"use strict";var p=1e3,q=0,r=function(){var b=a.now();return p>b-q?!1:(q=b,!0)},s=f.get,t=c.Model.extend({upvotersCollectionClass:n,defaults:function(){return{createdAt:d().format(g.ISO_8601),dislikes:0,isApproved:!0,isDeleted:!1,isEdited:!1,isFlagged:!1,isFlaggedByUser:!1,isHighlighted:!1,isRealtime:!1,isImmediateReply:!1,isMinimized:null,hasMedia:!1,message:null,raw_message:null,likes:0,media:[],parent:null,points:0,depth:0,userScore:0}},initialize:function(){this.votes=new o},messageText:function(){var a=this.get("message");return a&&i.stripTags(a)},relatedIds:function(){var a=this.get("forum");b.isObject(a)&&(a=a.id);var c=this.get("thread");return b.isObject(c)&&(c=c.id),{forum:a,thread:c,post:this.id}},permalink:function(a,b){var c=this.id;if(!c||!a)return"";var d=b!==!1&&a.currentUrl||a.permalink(),e=document.createElement("a");return e.href=d,e.hash="#comment-"+c,e.href},twitterText:function(a){var b=140,c=this.author.get("name")||this.author.get("username");b-=c.length+3,b-=a.length+1,b-=2;var d=h.niceTruncate(this.messageText(),b);return'"'+d+'" — '+c},toJSON:function(a){var b=c.Model.prototype.toJSON.call(this);if(a){var d=a.session,e=a.thread;b.canBeEdited=this.canBeEdited(d,e),b.canBeRepliedTo=this.canBeRepliedTo(d,e),b.canBeShared=this.canBeShared(),b.permalink=this.permalink(e)}return b.isMinimized=this.isMinimized(),b.plaintext=this.messageText(),b.relativeCreatedAt=this.getRelativeCreatedAt(),b.formattedCreatedAt=this.getFormattedCreatedAt(),b.cid=this.cid,b
},isPublic:function(){return this.get("isHighlighted")||this.get("isSponsored")?!0:this.get("isDeleted")?!1:this.get("isApproved")},isMinimized:function(){return this.get("isHighlighted")?!1:this.get("isMinimized")===!1?!1:!this.get("isApproved")},isAuthorSessionUser:function(){return!1},canBeEdited:function(){return!1},canBeRepliedTo:function(){return!1},canBeShared:function(){return!1},validate:function(c){if(!this.id&&!c.id){if(b.isString(c.raw_message)){if(""===c.raw_message)return s("Comments can't be blank.");if(c.raw_message.length<2)return s("Comments must have at least 2 characters.")}return c.author_email&&(c.author_email=a.trim(c.author_email)),c.author_name&&(c.author_name=a.trim(c.author_name)),""===c.author_email&&""===c.author_name?s("Please sign in or enter a name and email address."):""===c.author_email||""===c.author_name?s("Please enter both a name and email address."):b.isString(c.author_email)&&!this.validateEmail(c.author_email)?s("Invalid email address format."):void 0}},validateEmail:function(a){return h.validateEmail(a)},report:function(){this.set("isFlagged",!0),e.call("posts/report.json",{data:{post:this.id},method:"POST"})},_highlight:function(a){this.set("isHighlighted",a),e.call("posts/"+(a?"highlight":"unhighlight")+".json",{data:{post:this.id},method:"POST"})},highlight:function(){this._highlight(!0)},unhighlight:function(){this._highlight(!1)},getThreadId:function(){return this.get("thread")},getUpvotersUserCollection:b.memoize(function(){var a=this.upvotersCollectionClass;return new a(void 0,{postId:this.id,threadId:this.getThreadId()})},function(){return this.id}),_vote:function(a,b,c){var d=a-b,e={likes:this.get("likes"),dislikes:this.get("dislikes"),points:this.get("points")};return 0===d?d:(a>0?(e.likes+=a,e.dislikes+=b):0>a?(e.dislikes-=a,e.likes-=b):b>0?e.likes-=b:e.dislikes+=b,e.points+=d,c&&this.getUpvotersUserCollection()[a>0?"add":"remove"](c),this.set(e),d)},vote:function(a){if(!r())return 0;var b=this,c=b._vote(a,b.get("userScore"));0!==c&&(b.set("userScore",a),e.call("posts/vote.json",{data:{post:b.id,vote:a},method:"POST",success:function(c){b.votes.add({id:c.response.id,score:a},{merge:!0})}}))},_delete:function(){return this.set({isApproved:!1,isDeleted:!0}),e.call("posts/remove.json",{data:{post:this.id},method:"POST"})},spam:function(){this.set({isApproved:!1,isDeleted:!0,isSpam:!0}),this.trigger("spam"),e.call("posts/spam.json",{data:{post:this.id},method:"POST"})},_create:function(a,b){var c=this,d=a.attributes,f={thread:d.thread,message:d.raw_message};return d.parent&&(f.parent=d.parent),d.author_name&&(f.author_name=d.author_name,f.author_email=d.author_email),e.call("posts/create.json",{data:f,method:"POST",success:function(a){c.set(a.response),b.success&&b.success()},error:b.error})},_update:function(a,b){var c=this,d=a.attributes,f={post:d.id,message:d.raw_message};return e.call("posts/update.json",{data:f,method:"POST",success:function(a){c.set(a.response),b.success&&b.success()},error:b.error})},_read:function(a,b){var c=this;return b=b||{},e.call("posts/details.json",{data:{post:c.id},method:"GET",success:function(a){c.set(a.response),b.success&&b.success()},error:b.error})},sync:function(a,b,c){c=c||{};var d=c.error;switch(d&&(c.error=function(a){d(JSON.parse(a.responseText||"{}"))}),a){case"create":return this._create(b,c);case"update":return this._update(b,c);case"delete":return this._delete();case"read":return this._read(b,c)}},storageKey:function(a){return this.isNew()&&this.getThreadId()?[a||"drafts","thread",this.getThreadId(),"parent",this.get("parent")||0].join(":"):void 0}},{formatMessage:function(){var a=/(?:\r\n|\r|\n){2,}/,c=/\r\n|\r|\n/;return function(d){var e=b.chain(d.split(a)).compact().value(),f=b.map(e,function(a){return b.chain(a.split(c)).compact().map(b.escape).join("
").value()}).join("
");return"
"+f+"
"}}()});return k.withCreatedAt.call(t.prototype),j.withAdvice.call(t.prototype),t.withAuthor=function(a){this.around("set",function(c,d,e,f){var g;if(null==d)return this;"object"==typeof d?(g=d,f=e):(g={},g[d]=e);var h=g.author;if(h){if(b.isString(h)||b.isNumber(h)){var i=h;h={},h[a.prototype.idAttribute||"id"]=i}this.author=new a(h),delete g.author}return c.call(this,g,f)}),this.around("toJSON",function(a){var c=a.apply(this,b.rest(arguments));return this.author&&(c.author=this.author.toJSON()),c})},t.withMediaCollection=function(a){this.after("set",function(c){c&&"string"!=typeof c&&(b.isUndefined(c.media)||(this.media?this.media.reset(c.media):this.media=new a(c.media),delete c.media))}),this.around("toJSON",function(a){var c=a.apply(this,b.rest(arguments));return this.media&&(c.media=this.media.toJSON()),c})},t}),define("core/models/Thread",["underscore","backbone","core/utils","core/api","core/config","core/advice","core/models/User"],function(a,b,c,d,e,f,g){"use strict";var h=b.Model.extend({defaults:{author:null,category:null,createdAt:null,forum:null,identifiers:[],ipAddress:null,isClosed:!1,isDeleted:!1,hasStreaming:!1,link:null,message:null,slug:null,title:null,userSubscription:!1,posts:0,likes:0,dislikes:0,userScore:0},initialize:function(a,b){var c=this;b=b||{},c.moderators=b.moderators,c.forum=b.forum,c.on("change:userScore",function(){var a=c.get("userScore");a>0&&0===c.get("likes")&&c.set("likes",a)})},_vote:function(a,b){var c=a-b;return 0===c?c:(this.set("likes",this.get("likes")+c),c)},vote:function(a){var b=this,c=b._vote(a,b.get("userScore"));0!==c&&(this.set("userScore",a),d.call("threads/vote.json",{data:{thread:this.id,vote:a},method:"POST",success:function(a){a.response.id&&b.trigger("vote:success",a)}}))},fetch:function(a){var b,c=this,f=c.attributes;a=a||{},b=f.identifier?"ident:"+f.identifier:"link:"+f.url,d.call("threads/details.json",{data:{thread:b,forum:f.forum},success:function(b){c.set(b.response),a.success&&a.success()},error:function(){return e.debug?void c.save({},{success:a.success}):void console.log("Couldn't find thread; not creating in production.")}})},_toggleState:function(a,b){b||(b={});var c=a?"open.json":"close.json";this.set("isClosed",!a),d.call("threads/"+c,{method:"POST",data:{thread:this.id},success:b.success,error:b.error})},open:function(a){this._toggleState(!0,a)},close:function(a){this._toggleState(!1,a)},sync:function(){var a=this,b=a.attributes;d.call("threads/create.json",{data:{title:b.title,forum:b.forum,identifier:b.identifier,url:b.url},method:"POST",success:function(b){a.set(b.response)}})},incrementPostCount:function(a){var b=this.get("posts")+a;this.set("posts",b>0?b:0)},isModerator:function(b){var c;if(this.moderators)return c=b instanceof g||a.isObject(b)?b.id:b,c=parseInt(c,10),a(this.moderators).contains(c)},subscribe:function(a,b){a=a!==!1;var c=this.get("userSubscription");if(c!==a){a?this.set("userSubscription",b||!0):this.set("userSubscription",!1);var e=a?"subscribe.json":"unsubscribe.json",f={thread:this.id};b?f.email=b:a||"string"!=typeof c||(f.email=c),d.call("threads/"+e,{data:f,method:"POST"})}},relatedIds:function(){var b=this.get("forum");return a.isObject(b)&&(b=b.id),{forum:this.get("forum"),thread:this.id}},twitterText:function(a){var b=140-(a.length+1),d=c.htmlDecode(this.get("clean_title"));return d=c.niceTruncate(d,b)},permalink:function(){return this.get("url")||this.get("link")||this.currentUrl},toJSON:function(){var a=b.Model.prototype.toJSON.call(this);return a.permalink=this.permalink(),a}});return f.withAdvice.call(h.prototype),h.withThreadVoteCollection=function(a){this.after("initialize",function(){this.votes=new a,this.on("vote:success",function(a){this.votes.get(a.response.id)||this.votes.add({id:a.response.id,score:a.response.vote,currentUser:!0})},this)})},h.withPostCollection=function(b){this.after("initialize",function(c){c=c||{},this.posts=new b(c.posts,{thread:this,cursor:c.postCursor,order:c.order,perPage:this.postsPerPage}),this.listenTo(this.posts,"add reset",function(b){b=b.models?b.models:[b],this.users&&a.each(b,function(a){this.users.get(a.author.id)||this.users.add(a.author)}),this.recalculatePostCount()}),this.listenTo(this.posts,"change:isDeleted change:isFlagged",function(a,b){b&&this.incrementPostCount(-1)})}),this.recalculatePostCount=function(){var a=this.get("posts");a>50||(a=this.posts.reduce(function(a,b){return b.isPublic()?a+1:a},0),this.set("posts",a))}},h}),define("core/models/Media",["underscore","backbone"],function(a,b){"use strict";var c=b.Model.extend({idAttribute:"url",defaults:{mediaType:null,html:"",htmlWidth:null,htmlHeight:null,thumbnailUrl:"",thumbnailWidth:null,thumbnailHeight:null,url:"",resolvedUrl:"",title:"",description:"",providerName:""}},{MEDIA_TYPES:{IMAGE:"1",IMAGE_UPLOAD:"2",YOUTUBE_VIDEO:"3",WEBPAGE:"4",TWITTER_STATUS:"5",FACEBOOK_PAGE:"6",FACEBOOK_POST:"7",FACEBOOK_PHOTO:"8",FACEBOOK_VIDEO:"9",SOUNDCLOUD_SOUND:"10",GOOGLE_MAP:"11",VIMEO_VIDEO:"12",VINE_VIDEO:"14"},WEBPAGE_TYPES:["4","6","7"]});return c}),define("core/collections/MediaCollection",["backbone","core/models/Media"],function(a,b){"use strict";var c=a.Collection.extend({model:b});return c}),function(a,b){if("function"==typeof define&&define.amd)define("backbone.uniquemodel",["backbone"],function(a){a.UniqueModel=b(a)});else if("undefined"!=typeof exports){var c=require("backbone");c.UniqueModel=b(c)}else a.Backbone.UniqueModel=b(a.Backbone)}(this,function(a){"use strict";function b(a,c,d){c=c||_.uniqueId("UniqueModel_"),d=d||b.STORAGE_DEFAULT_ADAPTER;var e=b.addModel(a,c,d);return e.modelConstructor}function c(b,c,e){var f=this;this.instances={},this.Model=b,this.modelName=c,this.storage=null,"localStorage"===e?this.storage=new d(this.modelName,localStorage):"sessionStorage"===e&&(this.storage=new d(this.modelName,sessionStorage)),this.storage&&(this.storage.on("sync",this.storageSync,this),this.storage.on("destroy",this.storageDestroy,this));var g=function(a,b){return f.get(a,b)};_.extend(g,a.Events),g.prototype=this.Model.prototype,this.modelConstructor=g}function d(a,b){this.modelName=a,this.store=b,d.instances[a]=this,d.listener||(d.listener=window.addEventListener?window.addEventListener("storage",d.onStorage,!1):window.attachEvent("onstorage",d.onStorage))}var e={};return b.STORAGE_DEFAULT_ADAPTER="memory",b.STORAGE_KEY_DELIMETER=".",b.STORAGE_NAMESPACE="UniqueModel",b.getModelCache=function(a){var b=e[a];if(!b)throw"Unrecognized model: "+a;return b},b.addModel=function(a,b,d){if(e[b])return e[b];var f=new c(a,b,d);return e[b]=f,f},b.clear=function(){for(var a in e)e.hasOwnProperty(a)&&delete e[a]},_.extend(c.prototype,{newModel:function(a,b){var c=new this.Model(a,b);return this.storage&&(c.id&&this.storage.save(c.id,c.attributes),c.on("sync",this.instanceSync,this),c.on("destroy",this.instanceDestroy,this)),c},instanceSync:function(a){this.storage&&this.storage.save(a.id,a.attributes)},instanceDestroy:function(a){this.storage&&this.storage.remove(a.id)},storageSync:function(a,b){this.get(b,{fromStorage:!0})},storageDestroy:function(a){var b=this.instances[a];b&&(b.trigger("destroy",b),delete this.instances[a])},add:function(a,b,c){var d=this.newModel(b,c);return this.instances[a]=d,d},get:function(a,b){b=b||{};var c=this.Model,d=a&&a[c.prototype.idAttribute];if(!d)return this.newModel(a,b);var e=this.instances[d];if(this.storage&&!b.fromStorage&&!e){var f=this.storage.getFromStorage(this.storage.getStorageKey(d));f&&(e=this.add(d,f,b))}return e?(e.set(a),b.fromStorage||this.instanceSync(e)):(e=this.add(d,a,b),b.fromStorage&&this.modelConstructor.trigger("uniquemodel.add",e)),e}}),d.instances={},d.listener=null,d.onStorage=function(a){var c=a.key,e=new RegExp([b.STORAGE_NAMESPACE,"(\\w+)","(.+)"].join("\\"+b.STORAGE_KEY_DELIMETER)),f=c.match(e);if(f){var g=f[1],h=f[2],i=d.instances[g];i&&i.handleStorageEvent(c,h)}},_.extend(d.prototype,{handleStorageEvent:function(a,b){var c=this.getFromStorage(a);c?this.trigger("sync",b,c):this.trigger("destroy",b)},getFromStorage:function(a){try{return JSON.parse(this.store.getItem(a))}catch(b){return}},getStorageKey:function(a){var c=[b.STORAGE_NAMESPACE,this.modelName,a].join(b.STORAGE_KEY_DELIMETER);return c},save:function(a,b){if(!a)throw"Cannot save without id";var c=JSON.stringify(b);this.store.setItem(this.getStorageKey(a),c)},remove:function(a){if(!a)throw"Cannot remove without id";this.store.removeItem(this.getStorageKey(a))}},a.Events),_.extend(b,{ModelCache:c,StorageAdapter:d}),b}),define("common/models",["require","jquery","underscore","backbone","moment","modernizr","core/api","core/UniqueModel","core/models/User","core/models/Post","core/models/Thread","core/collections/MediaCollection","core/utils/guid","common/utils","core/utils","common/urls","shared/corefuncs","shared/urls","backbone.uniquemodel"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r){"use strict";var s=d.Model.extend({defaults:{settings:{}},toJSON:function(){return c.extend(d.Model.prototype.toJSON.apply(this,arguments),{homeUrl:r.apps.home+"home/forums/"+this.id+"/"})}}),t=k.extend({initialize:function(b,d){k.prototype.initialize.apply(this,arguments),d=d||{};var e=this,f=a("common/collections");e.users=new f.UserCollection(d.users,{thread:e}),e.forum&&(e.moderatorList=new f.ModeratorCollection(null,{forum:e.forum.get("id")})),e.posts=new f.SubpaginatedPostCollection(d.posts,{thread:e,cursor:d.postCursor,order:d.order,perPage:o.isMobileUserAgent()?20:50}),e.votes=new f.ThreadVoteCollection,e.posts.on("add reset",function(a){a=a.models?a.models:[a],c.each(a,function(a){e.users.get(a.author.id)||e.users.add(a.author)}),e.recalculatePostCount()}),e.listenTo(e.posts,"change:isDeleted change:isFlagged",function(a,b){b&&e.incrementPostCount(-1)}),e.queue=new f.QueuedPostCollection(null,{thread:e})},recalculatePostCount:function(){var a=this.get("posts");a>50||(a=this.posts.buffer.reduce(function(a,b){return b.isPublic()?a+1:a},0),this.set("posts",a))},toJSON:function(){return c.extend(k.prototype.toJSON.apply(this,arguments),{homeUrl:r.apps.home+"home/discussions/"+this.relatedIds().forum+"/"+this.get("slug")+"/"})}});k.withThreadVoteCollection.call(t.prototype,d.Collection);var u=t.extend({defaults:c.extend({postsInInterval:0,posts:0,topPost:null},t.prototype.defaults)}),v=j.extend({initialize:function(){j.prototype.initialize.apply(this,arguments);var b=a("common/collections");this.usersTyping=new b.TypingUserCollection},isAuthorSessionUser:function(a){return a.user.id&&this.author&&this.author.id?this.author.id===a.user.id:!1},canBeEdited:function(a,b){return!b.get("isClosed")&&!this.get("isDeleted")&&a.isLoggedIn()&&this.isAuthorSessionUser(a)&&this.get("raw_message")&&!this.get("isHighlighted")&&!this.get("isSponsored")},canBeRepliedTo:function(a,b){return!b.get("isClosed")&&a.get("canReply")&&!this.get("isDeleted")&&(this.get("isApproved")||b.isModerator(a.user))},canBeShared:function(){return!this.get("isDeleted")&&!this.get("isSponsored")},getParent:function(){var a=this.get("parent");if(a)return new h(v,{id:a+""})}},{fetchContext:function(a,d,e){e=e||{};var f=b.Deferred();return g.call("posts/getContext.json",{method:"GET",data:{post:a},success:function(a){var b=c.filter(a.response,function(a){return a.thread===d.get("id")});return b?(c.each(b,function(a){a=new h(v,a),e.requestedByPermalink&&(a.requestedByPermalink=!0),d.posts.add(a)}),void f.resolve(b)):void f.reject()}}),f.promise()}});j.withAuthor.call(v.prototype,h.wrap(i)),j.withMediaCollection.call(v.prototype,l),h.addType("Post",v);var w=d.Model.extend({defaults:{user:null,message:null,parentId:null,immedReply:!1,createdAt:void 0},getVisibleParent:function(a){for(var b,c=this;c.get("parentId");){if(b=a.posts.get(c.get("parentId")))return b;if(c=a.queue.get(c.get("parentId")),!c)return null}return null},toPost:function(a){var b=this,c=a.posts.get(b.get("parentId")),d=c?c.get("depth")+1:0,e=new h(v,{id:b.id,thread:a.id,message:b.get("message"),parent:b.get("parentId"),depth:d,createdAt:b.get("createdAt"),isRealtime:!0,media:b.get("media"),isImmediateReply:b.get("immedReply")});return e.author=b.get("user"),e}}),x=d.Model.extend({defaults:{user:null,post:null,thread:null,client_context:null,typing:!0},idAttribute:"client_context",set:function(){return this.lastModified=new Date,d.Model.prototype.set.apply(this,arguments)},sync:function(){var a=this.toJSON(),b=q.serialize(p.realertime+"/api/typing",a);try{n.CORS.request("GET",b).send()}catch(c){}}},{make:function(a){return a.client_context||(a.client_context=m.generate()),new h(x,a)}});h.addType("TypingUser",x),c.extend(i.prototype,{getFollowing:function(){var b=a("common/collections/profile");return this.following||(this.following=new b.FollowingCollection(null,{user:this}))}}),h.addType("User",i);var y=i.extend({defaults:c.extend({numPosts:0},i.prototype.defaults)}),z=f.sessionstorage?"sessionStorage":null,A=d.UniqueModel(i,"User",z),B=d.UniqueModel(y,"User",z),C=d.Model.extend({});return{Forum:s,Thread:t,TopThread:u,Post:v,QueuedPost:w,TypingUser:x,User:i,TopUser:y,Switch:C,SyncedUser:A,SyncedTopUser:B}}),define("common/Session",["jquery","underscore","backbone","modernizr","core/api","core/bus","core/models/Session","core/strings","core/UniqueModel","core/utils/cookies","common/collections/LoggedOutCache","common/models","common/urls","common/utils","shared/corefuncs"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o){"use strict";var p,q=c.Model.extend({storageKey:"disqus.bus",initialize:function(){d.localstorage&&a(window).on("storage",b.bind(this.onStorageEvent,this))},broadcast:function(a,b){if(d.localstorage){var c=JSON.stringify({name:a,data:b,time:(new Date).getTime()});try{window.localStorage.setItem(this.storageKey,c)}catch(e){return}}},onStorageEvent:function(a){var b=a.originalEvent.key,c=a.originalEvent.newValue;if(c&&b===this.storageKey)try{c=JSON.parse(c),this.trigger(c.name,c.data)}catch(d){return}}}),r=new q,s=g.extend({_defaults:{canReply:!0,canModerate:!1,mustVerifyEmail:!1,audienceSyncVerified:!1,sso:null},defaults:function(){var a=new k.Collection(k.LOGGED_OUT_NOTES,{session:this});return b.extend(this._defaults,{notificationCount:a.getUnread().length})},openAuthWindow:function(a,b,c){return n.windowOpen(a,"_blank",{width:b,height:c})},start:function(a){this.set(a),this.listenTo(r,"auth:success",this.fetch),this.listenTo(f.frame,{"!auth:success":function(a){a&&(a.sessionId&&e.headers({"X-Sessionid":a.sessionId}),a.message&&this.trigger("alert",a.message,{type:"info"}),a.logEvent&&f.trigger("uiAction:"+a.logEvent)),r.broadcast("auth:success"),this.fetch()}}),this.bindAudienceSyncHandlers()},stop:function(){this.stopListening(),this.off()},shouldFetchSession:function(){return this.get("remoteAuthS3")||j.read("disqusauth")},getUserInstance:function(a){return new i(l.User,a)},toJSON:function(){var a=this.user.toJSON.apply(this.user,arguments);return a.thread.canReply=this.get("canReply"),a.thread.canModerate||(a.thread.canModerate=this.get("canModerate")),a},fetch:function(){var a=this.has("thread")?this.fetchThreadDetails(this.get("thread")):g.prototype.fetch.apply(this,arguments),b=this;return a.done(function(){b.set("notificationCount",0)}),a},fetchNotificationCount:function(){var b=this;return b.isLoggedIn()?e.call("timelines/getUnreadCount.json",{data:{type:"notifications"}}).done(function(a){b.set("notificationCount",a.response)}):a.Deferred().resolve()},fetchThreadDetails:function(a){var c=this;c._request&&(c._request.abort(),c._request=null);var d={thread:a.id,post:a.posts.pluck("id")};return d["_"+(new Date).getTime()]=1,c._request=e.call("embed/threadDetails.json",{data:d,success:function(d){var e=d.response,f={};e.user&&b.extend(f,e.user,{votes:e.votes}),c.set(e.session),f.id?(c.setUser(new i(l.User,f)),a.users.add(c.user),e.thread&&(a.set("userScore",e.thread.userScore),a.set("userSubscription",e.thread.userSubscription))):c.setUser(c.getAnonUserInstance())},complete:function(){c._request=null}}),c._request},logout:function(){var a=this.get("sso");this.isSSO()&&a&&a.logout?f.frame.sendHostMessage("navigate",a.logout):window.location.replace(o.serialize(m.logout,{redirect:window.location.href}))},isSSO:function(){return this.user&&"sso"===this.user.get("user_type")},authenticate:function(a){var c=this.authServices[a];if(c){if(b.isFunction(c))return c.call(this);f.trigger("uiAction:openLogin",a);var d={forum:this.get("thread")&&this.get("thread").forum.id};"https:"===window.location.protocol&&(d.redirect_secure=1),c.csrf&&(d.ctkn=this.getCsrfToken()),b.extend(d,c.params),this.openAuthWindow(o.serialize(c.url,d),c.width,c.height)}},authServices:{disqus:{url:m.login,width:460,height:355},disqusDotcom:{url:m.dotcomLogin,width:478,height:590,params:{next:m.login}},twitter:{url:m.oauth.twitter,width:650,height:680,csrf:!0},facebook:{url:m.oauth.facebook,width:550,height:300,csrf:!0},google:{url:m.oauth.google,width:445,height:635,csrf:!0},sso:function(){var a=this.get("sso"),c=parseInt(a.width||"800",10),d=parseInt(a.height||"500",10),e=this.openAuthWindow(a.url,c,d);!function g(){n.isWindowClosed(e)?f.frame.sendHostMessage("reload"):b.delay(g,500)}()}},verifyEmail:function(){var a=o.serialize(m.verifyEmail,{f:this.get("thread").forum.id});this.openAuthWindow(a,460,355)},bindAudienceSyncHandlers:function(){this.listenTo(this,"change:id change:audienceSyncVerified",function(){this.get("audienceSyncVerified")&&f.frame.sendHostMessage("session.identify",this.user.id)}),this.listenTo(f.frame,{"!audiencesync:grant":function(){this.set("audienceSyncVerified",!0)}})},getAudienceSyncUrl:function(){var a={client_id:this.get("apiKey"),response_type:"audiencesync",forum_id:this.get("thread").forum.id};return"https:"===window.location.protocol&&(a.ssl=1),o.serialize(m.authorize,a)},audienceSync:function(){this.openAuthWindow(this.getAudienceSyncUrl(),460,355)},needsAudienceSyncAuth:function(a){return a.get("settings").audienceSyncEnabled&&this.isLoggedIn()&&!this.get("audienceSyncVerified")},getLoggedOutUserFlags:function(){return this._loggedOutUserFlags?this._loggedOutUserFlags:(this._loggedOutUserFlags=new k.Collection(k.LOGGED_OUT_FLAGS,{session:this}),this._loggedOutUserFlags)}});return{get:function(){return p=p||new s},setDefaults:function(a){if(p)throw new Error("Session defaults cannot be changed after a session instance is created!");return s._defaults=b.extend(s.prototype._defaults,a),s._defaults},forget:function(){p&&(p.stop(),p=null)}}}),define("common/analytics/google",["require","common/keys","common/defines"],function(a,b,c){"use strict";var d,e=function(a){d=a},f=function(a){d?d(a):window._gaq.push(a)},g=function(){var d="";if(!c.debug||d){l(b.googleAnalytics),m(".disqus.com");var e=function(){};a([d?"ga-debug":"ga"],e,e)}},h={component:1,"package":2,forum:3,version:4,userType:5},i=function(a,b){f(["_setCustomVar",h[a],a,b])},j=function(){f(["_trackPageview"])},k=function(a,b,c){f(["_trackEvent",b,a,c,1])},l=function(a){f(["_setAccount",a])},m=function(a){f(["_setDomainName",a])};return window._gaq||(window._gaq=[]),g(),{setCaller:e,setAccount:l,setCustomVar:i,trackPageview:j,trackEvent:k,setDomainName:m}}),define("core/collections/PaginatedCollection",["underscore","backbone"],function(a,b){"use strict";var c=b.Collection.extend({PER_PAGE:30,initialize:function(a,b){b=b||{},this.cursor=b.cursor||{}},fetch:function(c){return c=c||{},c.data=a.defaults(c.data||{},{cursor:c.cursor||"",limit:c.PER_PAGE||this.PER_PAGE}),b.Collection.prototype.fetch.call(this,c)},hasNext:function(){return this.cursor.hasNext},more:function(b){function c(a){e.push(a)}var d=this;if(b=b||{},!this.cursor.hasNext)return void d.trigger("nodata");var e=[];this.on("add",c),this.fetch(a.extend({},b,{add:!0,remove:!1,cursor:this.cursor.next,limit:this.PER_PAGE,success:function(){d.trigger("add:many",e,d,b),d.off("add",c),b.success&&b.success.apply(this,arguments)}}))},parse:function(a){return this.cursor=a.cursor||{hasNext:!1},a.response},getLength:function(){return this.length}});return c}),define("core/models/ThreadVote",["backbone"],function(a){"use strict";var b=a.Model.extend({defaults:{score:0}});return b}),define("common/collections",["underscore","backbone","moment","core/api","core/collections/UserCollection","core/collections/PaginatedCollection","core/models/ThreadVote","core/UniqueModel","common/models","common/cached-storage"],function(a,b,c,d,e,f,g,h,i,j){"use strict";var k=b.Collection.extend({model:g}),l=f.extend({PER_PAGE:50,model:h.wrap(i.Post),url:d.getURL("threads/listPostsThreaded"),initialize:function(a,b){f.prototype.initialize.apply(this,arguments),b=b||{},this.thread=b.thread,this.setOrder(b.order)},fetch:function(b){return b=b||{},b=a.extend(b,{data:{limit:this.PER_PAGE,thread:this.thread.id,forum:this.thread.get("forum"),order:this.getOrder()}}),f.prototype.fetch.call(this,b)},getOrder:function(){return this.order},setOrder:function(a){this.order=a}}),m=b.Collection.extend({collection:b.Collection,initialize:function(a,b){this.thread=b.thread,this.perPage=b.perPage||20,this.buffer=new this.collection(a,b),this.resetPage(),this.listenTo(this.buffer,"reset",this.resetPage)},resetPage:function(a,c,d){return c=this.buffer.slice(0,this.perPage),b.Collection.prototype.reset.call(this,c,d)},currentPage:function(){var a=Math.floor(this.length/this.perPage);return this.length%this.perPage&&a++,a},setPageFor:function(a,b){var c=this.buffer.get(a),d=this.perPage;c&&(d=Math.floor(this.buffer.indexOf(c)/this.perPage+1)*this.perPage),this.add(this.buffer.slice(0,d),b)},hasNext:function(){return this.buffer.length>this.length||this.buffer.hasNext()},more:function(a){a=a||{};var b=this,c=b.length+this.perPage,d=a.success;a.success=function(){b.add(b.buffer.slice(0,c)),d&&d()},b.buffer.length
0&&null===b.gc?void(b.gc=setInterval(a.bind(b.cleanup,b),6e4)):void(0>=c&&null!==b.gc&&(clearInterval(b.gc),b.gc=null))},b)},count:function(a){var b=this.filter(function(b){return!(a&&b.id===a)&&b.get("typing")});return b.length},cleanup:function(){var a=c();this.reset(this.filter(function(b){return a.diff(b.lastModified,"minutes")<5}))}}),q=f.extend({model:h.wrap(i.Post),url:d.getURL("users/listPostActivity")}),r=b.Collection.extend({model:i.TopThread,url:d.getURL("threads/listPopular"),initialize:function(a,b){this.forum=b.forum,this.limit=b.limit},set:function(c,d){d.parse&&(c=this.parse(c,d),delete d.parse),a.isArray(c)||(c=c?[c]:[]),c=a.reject(c,function(a){return a.title.match(/^http/i)}),b.Collection.prototype.set.call(this,c,d)},fetch:function(c){return b.Collection.prototype.fetch.call(this,a.extend({data:{forum:this.forum,limit:this.limit,interval:"7d",with_top_post:!0}},c))}}),s=b.Collection.extend({model:i.SyncedTopUser,url:d.getURL("forums/listMostActiveUsers"),initialize:function(a,b){this.forum=b.forum,this.limit=b.limit},fetch:function(c){return b.Collection.prototype.fetch.call(this,a.extend({data:{forum:this.forum,limit:this.limit}},c))},parse:function(b){return a.filter(b.response,function(a){return parseFloat(a.rep)>.7?a:void 0})}});e.prototype.model=h.wrap(i.User);var t=b.Collection.extend({model:i.SyncedUser,url:d.getURL("forums/listModerators"),initialize:function(a,b){this.forum=b.forum},fetch:function(c){return b.Collection.prototype.fetch.call(this,a.extend({data:{forum:this.forum}},c))},parse:function(b){return a.map(b.response,function(a){return a.user})}});return{PaginatedCollection:f,UserCollection:e,PostCollection:l,SubpaginatedPostCollection:n,TypingUserCollection:p,TopUserCollection:s,TopThreadCollection:r,ThreadVoteCollection:k,PostActivityCollection:q,QueuedPostCollection:o,ModeratorCollection:t}}),define("common/collections/profile",["underscore","backbone","core/api","common/models","common/collections"],function(a,b,c,d,e){"use strict";var f=e.PaginatedCollection.extend({initialize:function(a,b){this.user=b.user,e.PaginatedCollection.prototype.initialize.apply(this,arguments)},fetch:function(a){return a=a||{},a.data=a.data||{},a.data.user=this.user.id,e.PaginatedCollection.prototype.fetch.call(this,a)}}),g=f.extend({model:d.SyncedUser,url:c.getURL("users/listFollowing"),PER_PAGE:20});return{SessionPaginatedCollection:f,FollowingCollection:g}}),define("common/intelligence",["underscore","common/analytics/google"],function(a,b){"use strict";function c(a){return a.has("remote")?a.get("remote").domain:a.id?"disqus":"not_logged_in"}function d(a){return a.support_preferred?"plus":a.support_priority?"pro":a.support_vip?"vip":"free"}function e(){b.trackPageview()}function f(a,c){b.setCustomVar(a,c)}function g(){this.version="next",this.forum=null,this.userType=null}return g.prototype.init=function(a){a=a||{},f("component","embed"),a.version&&(this.version=a.version),f("version",this.version),a.forum&&(this.forum=a.forum,f("forum",a.forum)),a.features&&f("package",d(a.features)),this.setSession(a.session||"not_logged_in"),e()},g.prototype.setSession=function(b){var d=a.isString(b)?b:c(b);d!==this.userType&&(this.userType=d,f("userType",d))},g.prototype.trackEvent=function(a){b.trackEvent(a,this.version,this.forum)},{Intelligence:g,setCustomVar:f,trackPageview:e,getUserType:c,getPackageType:d}}),define("common/juggler",["core/analytics/identity","shared/corefuncs"],function(a,b){"use strict";var c={},d=function(a){c[a]=this,this._emit=null,this.meta={},this.allowedOverwrites=["thread","forum","forum_id","user_id"],this.reservedKeys=this.allowedOverwrites.slice().concat(["imp","event","prev_imp"]),this.preloadBuffer=[]};return b.extend(d.prototype,{copySettings:function(){return b.extend({},this.settings,this.meta)},overwrite:function(a){for(var b=0,c=this.allowedOverwrites.length;c>b;b++){var d=this.allowedOverwrites[b];a.hasOwnProperty(d)&&(this.meta[d]=a[d])}},load:function(c){var d=this;d.settings=c,d.url=c.url,"https:"===window.location.protocol&&(d.url=d.url.replace("http:","https:")),b.each(d.allowedOverwrites,function(a){d.meta[a]=c[a]}),d.meta.imp=a.impression.impId,d.meta.prev_imp=a.impression.prevImp,d._emit=function(a){b.each(d.meta,function(b,c){a[c]=d.meta[c]
}),b.require(d.url,a,!1)},b.each(d.preloadBuffer,function(a){d._emit(a)})},emit:function(a,c){var d=this;c=b.extend({},c),b.each(d.reservedKeys,function(a){if(null!=c[a])throw'Error: cannot overwrite event context "'+a+'"'}),c.event=a,null==d._emit?d.preloadBuffer.push(c):d._emit(c)}}),{client:function(a,b){return c[a]||b&&new d(a)}}}),define("common/outboundlinkhandler",["jquery","underscore","common/utils"],function(a,b,c){"use strict";function d(){this.handlers=[],this.locked={},this.timeout=1e3}return b.extend(d.prototype,{handleClick:function(d){var e=a(d.currentTarget),f=this.getLinkTrackingId(e);if(this.shouldHandleClick(d,e,f)){var g=b.chain(this.handlers).map(function(a){return a[0].call(a[1],d,e)}).compact().value();c.willOpenNewWindow(d,e)||(d.preventDefault(),this.setLatestClick(f),this.delayNavigation(d,e,g))}},delayNavigation:function(d,e,f){this.lockLink(this.getLinkTrackingId(e));var g=b.bind(function(){this.isLatestClick(this.getLinkTrackingId(e))&&c.triggerClick(e,d.originalEvent)},this);b.delay(g,this.timeout),a.when.apply(a,f).always(g)},registerBeforeNavigationHandler:function(a,b){this.handlers.push([a,b])},getLinkTrackingId:function(a){var c=a.attr("data-tid");return c||(c=b.uniqueId(),a.attr("data-tid",c)),c},shouldHandleClick:function(a,b){if(!this.isLinkLocked(this.getLinkTrackingId(b))){if(a.isDefaultPrevented())return!1;if(!b.is("a"))return!1;var c=/\#.*/,d=(b.attr("href")||"").replace(c,"");return d?!0:!1}},setLatestClick:function(a){this.latestLinkId=a},isLatestClick:function(a){return this.latestLinkId===a},lockLink:function(a){this.locked[a]=!0},isLinkLocked:function(a){return this.locked[a]}}),d}),define("common/views/mixins",["jquery","modernizr","underscore","core/bus","core/utils","common/Session"],function(a,b,c,d,e,f){"use strict";function g(){this._getStyleProperty=function(a){var b=this.forum.get("settings");return this.config.forceAutoStyles||"auto"===b[a]?this.config[a]:b[a]},this.getTypeface=function(){return this._getStyleProperty("typeface")},this.getColorScheme=function(){return this._getStyleProperty("colorScheme")},this.applyPublisherClasses=function(){var b=a("body");"serif"===this.getTypeface()&&b.addClass("serif"),"dark"===this.getColorScheme()&&b.addClass("dark")}}var h={proxyViewEvents:function(a){this.listenTo(a,"all",function(a){0===a.indexOf("uiAction:")&&this.trigger.apply(this,arguments)},this)}},i={showOnboardApp:function(a){b.sessionstorage&&sessionStorage.setItem("onboard.session",JSON.stringify(a.session.user.toJSON()));var f=c.pick(a,"threadId","forumId","forumPk","activeSection");e.isMobileUserAgent()&&(window.open("",a.windowName),f.windowName=a.windowName),d.frame.sendHostMessage("onboard.show",f),this.trigger("uiAction:onboardOpen")}},j={updateUserAvatarHelper:function(b,c){a("img[data-user="+b+'][data-role="user-avatar"]').attr("src",c)},updateUserNameHelper:function(b,d){var e='[data-username="'+b+'"][data-role=username]';a("a"+e+", span"+e).html(c.escape(d))},bindProfileUIListeners:function(a){this.listenTo(a,{"change:avatar":function(){this.updateUserAvatarHelper(a.user.id,a.user.get("avatar").cache)},"change:name":function(){this.updateUserNameHelper(a.user.get("username"),a.user.get("name"))}})}},k={toggleFollow:function(b){b.preventDefault(),b.stopPropagation();var c=b&&a(b.target).closest("a[data-user]").attr("data-user"),d=this.collection&&c?this.collection.get(c):this.user,e=f.get();return e.isLoggedOut()?(this.trigger("authenticating"),this.listenToOnce(e,"change:id",function(){e.isLoggedIn()&&this.follow(d)}),void e.authenticate("disqusDotcom")):void(d.get("isFollowing")?this.unfollow(d):this.follow(d))},unfollow:function(a){a.unfollow(),d.trigger("uiAction:unfollowUser",a)},follow:function(a){a.follow(),d.trigger("uiAction:followUser",a)}};return{FollowButtonMixin:k,UiActionEventProxy:h,appliesPublisherClasses:g,ProfileHtmlHelpers:j,OnboardHelper:i}}),define("common/views/popup",["jquery","underscore","backbone","core/bus","core/utils","common/models","common/utils","common/Session"],function(a,b,c,d,e,f,g,h){"use strict";var i=c.View.extend({el:document.body,events:{"click .overlay":"handleClick",keydown:"handleKeyPress","click [data-action=close]":"close"},initialize:function(){this.user=null,this.session=h.get(),this.fullscreen=!0,this.$overlay=this.$el.find(".overlay");var a=this;if(g.isIframed(window))this.listenTo(d.frame,"init",this.bootstrap),this.listenTo(d.frame,"open",this._open);else{var b=g.getConfigFromHash(window);a.bootstrap(b),a.load(b)}},handleClick:function(b){a(b.target).closest(this.containerId).length||this.close()},handleKeyPress:function(a){return 27===a.which?(a.preventDefault(),a.stopPropagation(),void this.close()):void 0},open:function(){g.isIframed(window)?d.frame.sendHostMessage("openReady"):this._open()},_open:function(){this.trigger("open"),this.$overlay.addClass("active"),window.focus()},close:function(){var a=this;if(a.fullscreen){a.$overlay.removeClass("active");var c=e.transitionEndEvent;c?a.$overlay.one(c,function(){a._closeWindow()}):b.defer(b.bind(a._closeWindow,a))}},_closeWindow:function(){g.isIframed(window)?d.frame.sendHostMessage("close"):window.close()},bootstrap:a.noop,load:a.noop});return{PopupManager:i}}),function(a){"use strict";a("when",[],function(){function a(a,c,d,e){return b(a).then(c,d,e)}function b(a){var b,c;return a instanceof d?b=a:h(a)?(c=g(),a.then(function(a){c.resolve(a)},function(a){c.reject(a)},function(a){c.progress(a)}),b=c.promise):b=e(a),b}function c(b){return a(b,f)}function d(a){this.then=a}function e(a){var c=new d(function(c){try{return b(c?c(a):a)}catch(d){return f(d)}});return c}function f(a){var c=new d(function(c,d){try{return d?b(d(a)):f(a)}catch(e){return f(e)}});return c}function g(){function a(a,b,c){return m(a,b,c)}function c(a){return o(a)}function e(a){return o(f(a))}function h(a){return n(a)}var i,j,k,l,m,n,o;return j=new d(a),i={then:a,resolve:c,reject:e,progress:h,promise:j,resolver:{resolve:c,reject:e,progress:h}},k=[],l=[],m=function(a,b,c){var d,e;return d=g(),e="function"==typeof c?function(a){try{d.progress(c(a))}catch(b){d.progress(b)}}:function(a){d.progress(a)},k.push(function(c){c.then(a,b).then(d.resolve,d.reject,e)}),l.push(e),d.promise},n=function(a){return p(l,a),a},o=function(a){return a=b(a),m=a.then,o=b,n=r,p(k,a),l=k=v,a},i}function h(a){return a&&"function"==typeof a.then}function i(b,c,d,e,f){return q(2,arguments),a(b,function(b){function h(a){p(a)}function i(a){o(a)}var j,k,l,m,n,o,p,q,s,t;if(s=b.length>>>0,j=Math.max(0,Math.min(c,s)),l=[],k=s-j+1,m=[],n=g(),j)for(q=n.progress,p=function(a){m.push(a),--k||(o=p=r,n.reject(m))},o=function(a){l.push(a),--j||(o=p=r,n.resolve(l))},t=0;s>t;++t)t in b&&a(b[t],i,h,q);else n.resolve(l);return n.then(d,e,f)})}function j(a,b,c,d){function e(a){return b?b(a[0]):a[0]}return i(a,1,e,c,d)}function k(a,b,c,d){return q(1,arguments),m(a,s).then(b,c,d)}function l(){return m(arguments,s)}function m(b,c){return a(b,function(b){var d,e,f,h,i,j;if(f=e=b.length>>>0,d=[],j=g(),f)for(h=function(b,e){a(b,c).then(function(a){d[e]=a,--f||j.resolve(d)},j.reject)},i=0;e>i;i++)i in b?h(b[i],i):--f;else j.resolve(d);return j.promise})}function n(b,c){var d=u.call(arguments,1);return a(b,function(b){var e;return e=b.length,d[0]=function(b,d,f){return a(b,function(b){return a(d,function(a){return c(b,a,f,e)})})},t.apply(b,d)})}function o(b,c,d){var e=arguments.length>2;return a(b,function(a){return a=e?d:a,c.resolve(a),a},function(a){return c.reject(a),f(a)},c.progress)}function p(a,b){for(var c,d=0;c=a[d++];)c(b)}function q(a,b){for(var c,d=b.length;d>a;)if(c=b[--d],null!=c&&"function"!=typeof c)throw new Error("arg "+d+" must be a function")}function r(){}function s(a){return a}var t,u,v;return a.defer=g,a.resolve=b,a.reject=c,a.join=l,a.all=k,a.map=m,a.reduce=n,a.any=j,a.some=i,a.chain=o,a.isPromise=h,d.prototype={always:function(a,b){return this.then(a,a,b)},otherwise:function(a){return this.then(v,a)},spread:function(a){return this.then(function(b){return k(b,function(b){return a.apply(v,b)})})}},u=[].slice,t=[].reduce||function(a){var b,c,d,e,f;if(f=0,b=Object(this),e=b.length>>>0,c=arguments,c.length<=1)for(;;){if(f in b){d=b[f++];break}if(++f>=e)throw new TypeError}else d=c[1];for(;e>f;++f)f in b&&(d=a(d,b[f],f,b));return d},a})}("function"==typeof define&&define.amd?define:function(a){"object"==typeof exports?module.exports=a():this.when=a()}),function(a,b){"use strict";function c(a,b){var c,d;b=b||{},a="raven"+a.substr(0,1).toUpperCase()+a.substr(1),document.createEvent?(c=document.createEvent("HTMLEvents"),c.initEvent(a,!0,!0)):(c=document.createEventObject(),c.eventType=a);for(d in b)l(b,d)&&(c[d]=b[d]);if(document.createEvent)document.dispatchEvent(c);else try{document.fireEvent("on"+c.eventType.toLowerCase(),c)}catch(e){}}function d(a){this.name="RavenConfigError",this.message=a}function e(a){var b=V.exec(a),c={},e=7;try{for(;e--;)c[U[e]]=b[e]||""}catch(f){throw new d("Invalid DSN: "+a)}if(c.pass)throw new d("Do not specify your private key in the DSN!");return c}function f(a){return"undefined"==typeof a}function g(a){return"function"==typeof a}function h(a){return"string"==typeof a}function i(a){return"object"==typeof a&&null!==a}function j(a){for(var b in a)return!1;return!0}function k(a){return i(a)&&"[object Error]"===R.toString.call(a)||a instanceof Error}function l(a,b){return R.hasOwnProperty.call(a,b)}function m(a,b){var c,d;if(f(a.length))for(c in a)l(a,c)&&b.call(null,c,a[c]);else if(d=a.length)for(c=0;d>c;c++)b.call(null,c,a[c])}function n(){M="?sentry_version=4&sentry_client=raven-js/"+T.VERSION+"&sentry_key="+K}function o(a,b){var d=[];a.stack&&a.stack.length&&m(a.stack,function(a,b){var c=p(b);c&&d.push(c)}),c("handle",{stackInfo:a,options:b}),r(a.name,a.message,a.url,a.lineno,d,b)}function p(a){if(a.url){var b,c={filename:a.url,lineno:a.line,colno:a.column,"function":a.func||"?"},d=q(a);if(d){var e=["pre_context","context_line","post_context"];for(b=3;b--;)c[e[b]]=d[b]}return c.in_app=!(!P.includePaths.test(c.filename)||/(Raven|TraceKit)\./.test(c["function"])||/raven\.(min\.)?js$/.test(c.filename)),c}}function q(a){if(a.context&&P.fetchContext){for(var b=a.context,c=~~(b.length/2),d=b.length,e=!1;d--;)if(b[d].length>300){e=!0;break}if(e){if(f(a.column))return;return[[],b[c].substr(a.column,50),[]]}return[b.slice(0,c),b[c],b.slice(c+1)]}}function r(a,b,c,d,e,f){var g,h;b+="",("Error"!==a||b)&&(P.ignoreErrors.test(b)||(e&&e.length?(c=e[0].filename||c,e.reverse(),g={frames:e}):c&&(g={frames:[{filename:c,lineno:d,in_app:!0}]}),b=t(b,P.maxMessageLength),P.ignoreUrls&&P.ignoreUrls.test(c)||(!P.whitelistUrls||P.whitelistUrls.test(c))&&(h=d?b+" at "+d:b,w(s({exception:{type:a,value:b},stacktrace:g,culprit:c,message:h},f)))))}function s(a,b){return b?(m(b,function(b,c){a[b]=c}),a):a}function t(a,b){return a.length<=b?a:a.substr(0,b)+"…"}function u(){return+new Date}function v(){var a={url:document.location.href,headers:{"User-Agent":navigator.userAgent}};return document.referrer&&(a.headers.Referer=document.referrer),a}function w(a){y()&&(a=s({project:L,logger:P.logger,platform:"javascript",request:v()},a),a.tags=s(s({},P.tags),a.tags),a.extra=s(s({},P.extra),a.extra),a.extra=s({"session:duration":u()-S},a.extra),j(a.tags)&&delete a.tags,J&&(a.user=J),P.release&&(a.release=P.release),g(P.dataCallback)&&(a=P.dataCallback(a)),(!g(P.shouldSendCallback)||P.shouldSendCallback(a))&&(H=a.event_id||(a.event_id=A()),x(a)))}function x(a){var b=new Image,d=I+M+"&sentry_data="+encodeURIComponent(JSON.stringify(a));b.crossOrigin="anonymous",b.onload=function(){c("success",{data:a,src:d})},b.onerror=b.onabort=function(){c("failure",{data:a,src:d})},b.src=d}function y(){return O?I?!0:(B("error","Error: Raven has not been configured."),!1):!1}function z(a){for(var b,c=[],d=0,e=a.length;e>d;d++)b=a[d],h(b)?c.push(b.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1")):b&&b.source&&c.push(b.source);return new RegExp(c.join("|"),"i")}function A(){return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0,c="x"==a?b:3&b|8;return c.toString(16)})}function B(b,c){a.console&&console[b]&&T.debug&&console[b](c)}function C(){var b=a.RavenConfig;b&&T.config(b.dsn,b.config).install()}var D={remoteFetching:!1,collectWindowErrors:!0,linesOfContext:7},E=[].slice,F="?";D.wrap=function(a){function b(){try{return a.apply(this,arguments)}catch(b){throw D.report(b),b}}return b},D.report=function(){function c(a){h(),o.push(a)}function d(a){for(var b=o.length-1;b>=0;--b)o[b]===a&&o.splice(b,1)}function e(){i(),o=[]}function f(a,b){var c=null;if(!b||D.collectWindowErrors){for(var d in o)if(l(o,d))try{o[d].apply(null,[a].concat(E.call(arguments,2)))}catch(e){c=e}if(c)throw c}}function g(a,b,c,d,e){var g=null;if(r)D.computeStackTrace.augmentStackTraceWithInitialElement(r,b,c,a),j();else if(e)g=D.computeStackTrace(e),f(g,!0);else{var h={url:b,line:c,column:d};h.func=D.computeStackTrace.guessFunctionName(h.url,h.line),h.context=D.computeStackTrace.gatherContext(h.url,h.line),g={message:a,url:document.location.href,stack:[h]},f(g,!0)}return m?m.apply(this,arguments):!1}function h(){n||(m=a.onerror,a.onerror=g,n=!0)}function i(){n&&(a.onerror=m,n=!1,m=b)}function j(){var a=r,b=p;p=null,r=null,q=null,f.apply(null,[a,!1].concat(b))}function k(b,c){var d=E.call(arguments,1);if(r){if(q===b)return;j()}var e=D.computeStackTrace(b);if(r=e,q=b,p=d,a.setTimeout(function(){q===b&&j()},e.incomplete?2e3:0),c!==!1)throw b}var m,n,o=[],p=null,q=null,r=null;return k.subscribe=c,k.unsubscribe=d,k.uninstall=e,k}(),D.computeStackTrace=function(){function b(b){if(!D.remoteFetching)return"";try{var c=function(){try{return new a.XMLHttpRequest}catch(b){return new a.ActiveXObject("Microsoft.XMLHTTP")}},d=c();return d.open("GET",b,!1),d.send(""),d.responseText}catch(e){return""}}function c(a){if(!h(a))return[];if(!l(u,a)){var c="";-1!==a.indexOf(document.domain)&&(c=b(a)),u[a]=c?c.split("\n"):[]}return u[a]}function d(a,b){var d,e=/function ([^(]*)\(([^)]*)\)/,g=/['"]?([0-9A-Za-z$_]+)['"]?\s*[:=]\s*(function|eval|new Function)/,h="",i=10,j=c(a);if(!j.length)return F;for(var k=0;i>k;++k)if(h=j[b-k]+h,!f(h)){if(d=g.exec(h))return d[1];if(d=e.exec(h))return d[1]}return F}function e(a,b){var d=c(a);if(!d.length)return null;var e=[],g=Math.floor(D.linesOfContext/2),h=g+D.linesOfContext%2,i=Math.max(0,b-g-1),j=Math.min(d.length,b+h-1);b-=1;for(var k=i;j>k;++k)f(d[k])||e.push(d[k]);return e.length>0?e:null}function g(a){return a.replace(/[\-\[\]{}()*+?.,\\\^$|#]/g,"\\$&")}function i(a){return g(a).replace("<","(?:<|<)").replace(">","(?:>|>)").replace("&","(?:&|&)").replace('"','(?:"|")').replace(/\s+/g,"\\s+")}function j(a,b){for(var d,e,f=0,g=b.length;g>f;++f)if((d=c(b[f])).length&&(d=d.join("\n"),e=a.exec(d)))return{url:b[f],line:d.substring(0,e.index).split("\n").length,column:e.index-d.lastIndexOf("\n",e.index)-1};return null}function k(a,b,d){var e,f=c(b),h=new RegExp("\\b"+g(a)+"\\b");return d-=1,f&&f.length>d&&(e=h.exec(f[d]))?e.index:null}function m(b){for(var c,d,e,f,h=[a.location.href],k=document.getElementsByTagName("script"),l=""+b,m=/^function(?:\s+([\w$]+))?\s*\(([\w\s,]*)\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/,n=/^function on([\w$]+)\s*\(event\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/,o=0;om;++m){if(b=h.exec(i[m]))c={url:b[3],func:b[1]||F,args:b[2]?b[2].split(","):"",line:+b[4],column:b[5]?+b[5]:null};else{if(!(b=g.exec(i[m])))continue;c={url:b[2],func:b[1]||F,line:+b[3],column:b[4]?+b[4]:null}}!c.func&&c.line&&(c.func=d(c.url,c.line)),c.line&&(c.context=e(c.url,c.line)),j.push(c)}return j.length?(j[0].line&&!j[0].column&&l?j[0].column=k(l[1],j[0].url,j[0].line):j[0].column||f(a.columnNumber)||(j[0].column=a.columnNumber+1),{name:a.name,message:a.message,url:document.location.href,stack:j}):null}function o(a){for(var b,c=a.stacktrace,f=/ line (\d+), column (\d+) in (?:]+)>|([^\)]+))\((.*)\) in (.*):\s*$/i,g=c.split("\n"),h=[],i=0,j=g.length;j>i;i+=2)if(b=f.exec(g[i])){var k={line:+b[1],column:+b[2],func:b[3]||b[4],args:b[5]?b[5].split(","):[],url:b[6]};if(!k.func&&k.line&&(k.func=d(k.url,k.line)),k.line)try{k.context=e(k.url,k.line)}catch(l){}k.context||(k.context=[g[i+1]]),h.push(k)}return h.length?{name:a.name,message:a.message,url:document.location.href,stack:h}:null}function p(b){var f=b.message.split("\n");if(f.length<4)return null;var g,h,k,m,n=/^\s*Line (\d+) of linked script ((?:file|https?)\S+)(?:: in function (\S+))?\s*$/i,o=/^\s*Line (\d+) of inline#(\d+) script in ((?:file|https?)\S+)(?:: in function (\S+))?\s*$/i,p=/^\s*Line (\d+) of function script\s*$/i,q=[],r=document.getElementsByTagName("script"),s=[];for(h in r)l(r,h)&&!r[h].src&&s.push(r[h]);for(h=2,k=f.length;k>h;h+=2){var t=null;if(g=n.exec(f[h]))t={url:g[2],func:g[3],line:+g[1]};else if(g=o.exec(f[h])){t={url:g[3],func:g[4]};var u=+g[1],v=s[g[2]-1];if(v&&(m=c(t.url))){m=m.join("\n");var w=m.indexOf(v.innerText);w>=0&&(t.line=u+m.substring(0,w).split("\n").length)}}else if(g=p.exec(f[h])){var x=a.location.href.replace(/#.*$/,""),y=g[1],z=new RegExp(i(f[h+1]));m=j(z,[x]),t={url:x,line:m?m.line:y,func:""}}if(t){t.func||(t.func=d(t.url,t.line));var A=e(t.url,t.line),B=A?A[Math.floor(A.length/2)]:null;t.context=A&&B.replace(/^\s*/,"")===f[h+1].replace(/^\s*/,"")?A:[f[h+1]],q.push(t)}}return q.length?{name:b.name,message:f[0],url:document.location.href,stack:q}:null}function q(a,b,c,f){var g={url:b,line:c};if(g.url&&g.line){a.incomplete=!1,g.func||(g.func=d(g.url,g.line)),g.context||(g.context=e(g.url,g.line));var h=/ '([^']+)' /.exec(f);if(h&&(g.column=k(h[1],g.url,g.line)),a.stack.length>0&&a.stack[0].url===g.url){if(a.stack[0].line===g.line)return!1;if(!a.stack[0].line&&a.stack[0].func===g.func)return a.stack[0].line=g.line,a.stack[0].context=g.context,!1}return a.stack.unshift(g),a.partial=!0,!0}return a.incomplete=!0,!1}function r(a,b){for(var c,e,f,g=/function\s+([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)?\s*\(/i,h=[],i={},j=!1,l=r.caller;l&&!j;l=l.caller)if(l!==s&&l!==D.report){if(e={url:null,func:F,line:null,column:null},l.name?e.func=l.name:(c=g.exec(l.toString()))&&(e.func=c[1]),f=m(l)){e.url=f.url,e.line=f.line,e.func===F&&(e.func=d(e.url,e.line));var n=/ '([^']+)' /.exec(a.message||a.description);n&&(e.column=k(n[1],f.url,f.line))}i[""+l]?j=!0:i[""+l]=!0,h.push(e)}b&&h.splice(0,b);var o={name:a.name,message:a.message,url:document.location.href,stack:h};return q(o,a.sourceURL||a.fileName,a.line||a.lineNumber,a.message||a.description),o}function s(a,b){var c=null;b=null==b?0:+b;try{if(c=o(a))return c}catch(d){if(t)throw d}try{if(c=n(a))return c}catch(d){if(t)throw d}try{if(c=p(a))return c}catch(d){if(t)throw d}try{if(c=r(a,b+1))return c}catch(d){if(t)throw d}return{}}var t=!1,u={};return s.augmentStackTraceWithInitialElement=q,s.computeStackTraceFromStackProp=n,s.guessFunctionName=d,s.gatherContext=e,s}();var G,H,I,J,K,L,M,N=a.Raven,O=!("object"!=typeof JSON||!JSON.stringify),P={logger:"javascript",ignoreErrors:[],ignoreUrls:[],whitelistUrls:[],includePaths:[],collectWindowErrors:!0,tags:{},maxMessageLength:100,extra:{}},Q=!1,R=Object.prototype,S=u(),T={VERSION:"1.1.18",debug:!0,noConflict:function(){return a.Raven=N,T},config:function(a,b){if(I)return B("error","Error: Raven has already been configured"),T;if(!a)return T;var c=e(a),d=c.path.lastIndexOf("/"),f=c.path.substr(1,d);return b&&m(b,function(a,b){P[a]=b}),P.ignoreErrors.push(/^Script error\.?$/),P.ignoreErrors.push(/^Javascript error: Script error\.? on line 0$/),P.ignoreErrors=z(P.ignoreErrors),P.ignoreUrls=P.ignoreUrls.length?z(P.ignoreUrls):!1,P.whitelistUrls=P.whitelistUrls.length?z(P.whitelistUrls):!1,P.includePaths=z(P.includePaths),K=c.user,L=c.path.substr(d+1),I="//"+c.host+(c.port?":"+c.port:"")+"/"+f+"api/"+L+"/store/",c.protocol&&(I=c.protocol+":"+I),P.fetchContext&&(D.remoteFetching=!0),P.linesOfContext&&(D.linesOfContext=P.linesOfContext),D.collectWindowErrors=!!P.collectWindowErrors,n(),T},install:function(){return y()&&!Q&&(D.report.subscribe(o),Q=!0),T},context:function(a,c,d){return g(a)&&(d=c||[],c=a,a=b),T.wrap(a,c).apply(this,d)},wrap:function(a,c){function d(){for(var b=[],d=arguments.length,e=!a||a&&a.deep!==!1;d--;)b[d]=e?T.wrap(a,arguments[d]):arguments[d];try{return c.apply(this,b)}catch(f){throw T.captureException(f,a),f}}if(f(c)&&!g(a))return a;if(g(a)&&(c=a,a=b),!g(c))return c;if(c.__raven__)return c;for(var e in c)l(c,e)&&(d[e]=c[e]);return d.__raven__=!0,d.__inner__=c,d},uninstall:function(){return D.report.uninstall(),Q=!1,T},captureException:function(a,b){if(!k(a))return T.captureMessage(a,b);G=a;try{D.report(a,b)}catch(c){if(a!==c)throw c}return T},captureMessage:function(a,b){return P.ignoreErrors.test&&P.ignoreErrors.test(a)?void 0:(w(s({message:a+""},b)),T)},setUserContext:function(a){return J=a,T},setExtraContext:function(a){return P.extra=a||{},T},setTagsContext:function(a){return P.tags=a||{},T},setReleaseContext:function(a){return P.release=a,T},lastException:function(){return G},lastEventId:function(){return H},isSetup:function(){return y()}};T.setUser=T.setUserContext;var U="source protocol user pass host port path".split(" "),V=/^(?:(\w+):)?\/\/(\w+)(:\w+)?@([\w\.-]+)(?::(\d+))?(\/.*)/;d.prototype=new Error,d.prototype.constructor=d,C(),"function"==typeof define&&define.amd?(a.Raven=T,define("raven",[],function(){return T})):"object"==typeof module?module.exports=T:"object"==typeof exports?exports=T:a.Raven=T}(window),function(){for(var a=0,b=["webkit","moz"],c=0;c