fox-send/public/upload.js

59 lines
142 KiB
JavaScript
Raw Normal View History

2017-07-24 16:41:37 +00:00
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
window.Raven=require("raven-js"),window.Raven.config(window.dsn).install(),window.dsn=void 0;const testPilotGA=require("testpilot-ga");window.analytics=new testPilotGA({an:"Firefox Send",ds:"web",tid:window.trackerId});
},{"raven-js":13,"testpilot-ga":17}],2:[function(require,module,exports){
const EventEmitter=require("events"),{arrayToHex:arrayToHex}=require("./utils"),Raven=window.Raven;class FileSender extends EventEmitter{constructor(e){super(),this.file=e,this.iv=window.crypto.getRandomValues(new Uint8Array(12)),this.uploadXHR=new XMLHttpRequest}static delete(e,t){return new Promise((n,a)=>{if(!e||!t)return a();const r=new XMLHttpRequest;r.open("post","/delete/"+e,!0),r.setRequestHeader("Content-Type","application/json"),r.onreadystatechange=(()=>{r.readyState===XMLHttpRequest.DONE&&n(),200===r.status?console.log("The file was successfully deleted."):console.log("The file has expired, or has already been deleted.")}),r.send(JSON.stringify({delete_token:t}))})}cancel(){this.uploadXHR.abort()}upload(){const e=this;return e.emit("loading",!0),Promise.all([window.crypto.subtle.generateKey({name:"AES-GCM",length:128},!0,["encrypt","decrypt"]).catch(e=>console.log("There was an error generating a crypto key")),new Promise((t,n)=>{const a=new FileReader;a.readAsArrayBuffer(this.file),a.onload=function(n){e.emit("loading",!1),e.emit("hashing",!0);const a=new Uint8Array(this.result);window.crypto.subtle.digest("SHA-256",a).then(n=>{e.emit("hashing",!1),e.emit("encrypting",!0),t({plaintext:a,hash:new Uint8Array(n)})})},a.onerror=function(e){n(e)}})]).then(([t,n])=>Promise.all([window.crypto.subtle.encrypt({name:"AES-GCM",iv:this.iv,additionalData:n.hash,tagLength:128},t,n.plaintext).then(t=>(e.emit("encrypting",!1),new Promise((e,n)=>{e(t)}))),window.crypto.subtle.exportKey("jwk",t),new Promise((e,t)=>{e(n.hash)})])).then(([t,n,a])=>new Promise((r,s)=>{const o=this.file,i=arrayToHex(this.iv),l=new DataView(t),d=new Blob([l],{type:o.type}),p=new FormData;p.append("data",d,o.name);const c=e.uploadXHR;c.upload.addEventListener("progress",t=>{t.lengthComputable&&e.emit("progress",[t.loaded,t.total])}),c.onreadystatechange=(()=>{if(c.readyState===XMLHttpRequest.DONE){if(200===c.status){const e=JSON.parse(c.responseText);return r({url:e.url,fileId:e.id,secretKey:n.k,deleteToken:e.delete})}s(c.status)}}),c.open("post","/upload",!0),c.setRequestHeader("X-File-Metadata",JSON.stringify({aad:arrayToHex(a),id:i,filename:encodeURIComponent(o.name)})),c.send(p)})).catch(e=>(Raven.captureException(e),Promise.reject(e)))}}module.exports=FileSender;
},{"./utils":5,"events":7}],3:[function(require,module,exports){
const{isFile:isFile}=require("./utils");class Storage{constructor(e){this.engine=e}get totalDownloads(){return Number(this.engine.getItem("totalDownloads"))}set totalDownloads(e){this.engine.setItem("totalDownloads",e)}get totalUploads(){return Number(this.engine.getItem("totalUploads"))}set totalUploads(e){this.engine.setItem("totalUploads",e)}get referrer(){return this.engine.getItem("referrer")}set referrer(e){this.engine.setItem("referrer",e)}get files(){const e=[];for(let t=0;t<this.engine.length;t++){const n=this.engine.key(t);isFile(n)&&e.push(JSON.parse(this.engine.getItem(n)))}return e}get numFiles(){let e=0;for(let t=0;t<this.engine.length;t++){const n=this.engine.key(t);isFile(n)&&(e+=1)}return e}getFileById(e){return this.engine.getItem(e)}has(e){return this.engine.hasOwnProperty(e)}remove(e){this.engine.removeItem(e)}addFile(e,t){this.engine.setItem(e,JSON.stringify(t))}}module.exports=Storage;
},{"./utils":5}],4:[function(require,module,exports){
2017-07-25 16:23:42 +00:00
require("./common");const FileSender=require("./fileSender"),{notify:notify,gcmCompliant:gcmCompliant,findMetric:findMetric,sendEvent:sendEvent,ONE_DAY_IN_MS:ONE_DAY_IN_MS}=require("./utils"),bytes=require("bytes"),Storage=require("./storage"),storage=new Storage(localStorage),$=require("jquery");require("jquery-circle-progress");const Raven=window.Raven;storage.has("referrer")?(window.referrer=storage.referrer,storage.remove("referrer")):window.referrer="external",$(document).ready(function(){function e(o){if(o.preventDefault(),$("#page-one").attr("hidden"))return;storage.totalUploads+=1;let n="";if("drop"===o.type){if(!o.originalEvent.dataTransfer.files[0])return void $(".upload-window").removeClass("ondrag");if(o.originalEvent.dataTransfer.files.length>1||0===o.originalEvent.dataTransfer.files[0].size)return $(".upload-window").removeClass("ondrag"),void document.l10n.formatValue("uploadPageMultipleFilesAlert").then(e=>{alert(e)});n=o.originalEvent.dataTransfer.files[0]}else n=o.target.files[0];if(n.size>MAXFILESIZE)return document.l10n.formatValue("fileTooBig",{size:bytes(MAXFILESIZE)}).then(alert);$("#page-one").attr("hidden",!0),$("#upload-error").attr("hidden",!0),$("#upload-progress").removeAttr("hidden"),document.l10n.formatValue("importingFile").then(e=>{$(".progress-text").text(e)}),$("body").off("drop",e);const r=new FileSender(n);$("#cancel-upload").click(()=>{r.cancel(),location.reload(),document.l10n.formatValue("uploadCancelNotification").then(e=>{notify(e)}),storage.referrer="cancelled-upload",sendEvent("sender","upload-stopped",{cm1:n.size,cm5:storage.totalUploads,cm6:s,cm7:storage.totalDownloads,cd1:"drop"===o.type?"drop":"click",cd2:"cancelled"})}),r.on("progress",e=>{const t=e[0]/e[1];$("#ul-progress").circleProgress("value",t),$("#ul-progress").circleProgress().on("circle-animation-end",function(){$(".percent-number").text(`${Math.floor(100*t)}`)}),$(".progress-text").text(`${n.name} (${bytes(e[0],{decimalPlaces:1,fixedDecimals:!0})} of ${bytes(e[1],{decimalPlaces:1})})`)}),r.on("hashing",e=>{e?document.l10n.formatValue("verifyingFile").then(e=>{$(".progress-text").text(e)}):console.log("Finished hashing")});let a;r.on("encrypting",e=>{e?document.l10n.formatValue("encryptingFile").then(e=>{$(".progress-text").text(e)}):(console.log("Finished encrypting"),a=Date.now())});let d;const l=Date.now(),s=storage.numFiles+1;sendEvent("sender","upload-started",{cm1:n.size,cm5:storage.totalUploads,cm6:s,cm7:storage.totalDownloads,cd1:"drop"===o.type?"drop":"click",cd5:window.referrer}),setTimeout(()=>{r.upload().then(e=>{const r=Date.now(),c=r-l,i=r-a,p=n.size/(i/1e3),u=1e3*EXPIRE_SECONDS;sendEvent("sender","upload-stopped",{cm1:n.size,cm2:c,cm3:p,cm5:storage.totalUploads,cm6:s,cm7:storage.totalDownloads,cd1:"drop"===o.type?"drop":"click",cd2:"completed"});const m={name:n.name,size:n.size,fileId:e.fileId,url:e.url,secretKey:e.secretKey,deleteToken:e.deleteToken,creationDate:new Date,expiry:u,totalTime:c,typeOfUpload:"drop"===o.type?"drop":"click",uploadSpeed:p};storage.addFile(e.fileId,m),$("#upload-filename").attr("data-l10n-id","uploadSuccessConfirmHeader"),d=window.setTimeout(()=>{$("#page-one").attr("hidden",!0),$("#upload-progress").attr("hidden",!0),$("#upload-error").attr("hidden",!0),$("#share-link").removeAttr("hidden")},1e3),t(m),document.l10n.formatValue("notifyUploadDone").then(e=>{notify(e)})}).catch(e=>{0!==e&&(Raven.captureException(e),$("#page-one").attr("hidden",!0),$("#upload-progress").attr("hidden",!0),$("#upload-error").removeAttr("hidden"),window.clearTimeout(d),sendEvent("sender","upload-stopped",{cm1:n.size,cm5:storage.totalUploads,cm6:s,cm7:storage.totalDownloads,cd1:"drop"===o.type?"drop":"click",cd2:"errored",cd6:e}))})},10)}function t(e){function t(){v=h.getTime()-Date.now(),w=Math.floor(v/1e3/60),y=Math.floor(w/60),E=Math.floor(v/1e3%60);let n;y>=1?(l.innerHTML=y+"h "+w%60+"m",n=window.setTimeout(()=>{t()},6e4)):0===y&&(l.innerHTML=w+"m "+E+"s",n=window.setTimeout(()=>{t()},1e3)),v<=0&&(storage.remove(e.fileId),$(l).parents("tr").remove(),window.clearTimeout(n),o())}const n=docume
2017-07-24 16:41:37 +00:00
},{"./common":1,"./fileSender":2,"./storage":3,"./utils":5,"bytes":6,"jquery":9,"jquery-circle-progress":8}],5:[function(require,module,exports){
function arrayToHex(t){let e="";for(const n in t)t[n]<16?e+="0"+t[n].toString(16):e+=t[n].toString(16);return e}function hexToArray(t){const e=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)e[n/2]=parseInt(t.charAt(n)+t.charAt(n+1),16);return e}function notify(t){"Notification"in window&&("granted"===Notification.permission?new Notification(t):"denied"!==Notification.permission&&Notification.requestPermission(function(e){"granted"===e&&new Notification(t)}))}function gcmCompliant(){try{return window.crypto.subtle.generateKey({name:"AES-GCM",length:128},!0,["encrypt","decrypt"]).then(t=>window.crypto.subtle.encrypt({name:"AES-GCM",iv:window.crypto.getRandomValues(new Uint8Array(12)),additionalData:window.crypto.getRandomValues(new Uint8Array(6)),tagLength:128},t,new ArrayBuffer(8)).then(()=>Promise.resolve()).catch(t=>Promise.reject())).catch(t=>Promise.reject())}catch(t){return Promise.reject()}}function findMetric(t){switch(t){case"https://www.mozilla.org/":return"mozilla";case"https://www.mozilla.org/about/legal":return"legal";case"https://testpilot.firefox.com/about":return"about";case"https://testpilot.firefox.com/privacy":return"privacy";case"https://testpilot.firefox.com/terms":return"terms";case"https://www.mozilla.org/en-US/privacy/websites/#cookies":return"cookies";case"https://github.com/mozilla/send":return"github";case"https://twitter.com/FxTestPilot":return"twitter";case"https://www.mozilla.org/firefox/new/?scene=2":return"download-firefox";default:return"other"}}function isFile(t){return!["referrer","totalDownloads","totalUploads","testpilot_ga__cid"].includes(t)}function sendEvent(){return window.analytics.sendEvent.apply(window.analytics,arguments).catch(()=>0)}const ONE_DAY_IN_MS=864e5;module.exports={arrayToHex:arrayToHex,hexToArray:hexToArray,notify:notify,gcmCompliant:gcmCompliant,findMetric:findMetric,isFile:isFile,sendEvent:sendEvent,ONE_DAY_IN_MS:864e5};
},{}],6:[function(require,module,exports){
"use strict";function bytes(e,r){return"string"==typeof e?parse(e):"number"==typeof e?format(e,r):null}function format(e,r){if(!numberIsFinite(e))return null;var a=Math.abs(e),t=r&&r.thousandsSeparator||"",o=r&&r.unitSeparator||"",s=r&&void 0!==r.decimalPlaces?r.decimalPlaces:2,n=Boolean(r&&r.fixedDecimals),p=r&&r.unit||"";p&&map[p.toLowerCase()]||(p=a>=map.tb?"TB":a>=map.gb?"GB":a>=map.mb?"MB":a>=map.kb?"kB":"B");var m=(e/map[p.toLowerCase()]).toFixed(s);return n||(m=m.replace(formatDecimalsRegExp,"$1")),t&&(m=m.replace(formatThousandsRegExp,t)),m+o+p}function parse(e){if("number"==typeof e&&!isNaN(e))return e;if("string"!=typeof e)return null;var r,a=parseRegExp.exec(e),t="b";return a?(r=parseFloat(a[1]),t=a[4].toLowerCase()):(r=parseInt(e,10),t="b"),Math.floor(map[t]*r)}module.exports=bytes,module.exports.format=format,module.exports.parse=parse;var formatThousandsRegExp=/\B(?=(\d{3})+(?!\d))/g,formatDecimalsRegExp=/(?:\.0*|(\.[^0]+)0+)$/,map={b:1,kb:1024,mb:1<<20,gb:1<<30,tb:1024*(1<<30)},numberIsFinite=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},parseRegExp=/^((-|\+)?(\d+(?:\.\d+)?)) *(kb|mb|gb|tb)$/i;
},{}],7:[function(require,module,exports){
function EventEmitter(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function isFunction(e){return"function"==typeof e}function isNumber(e){return"number"==typeof e}function isObject(e){return"object"==typeof e&&null!==e}function isUndefined(e){return void 0===e}module.exports=EventEmitter,EventEmitter.EventEmitter=EventEmitter,EventEmitter.prototype._events=void 0,EventEmitter.prototype._maxListeners=void 0,EventEmitter.defaultMaxListeners=10,EventEmitter.prototype.setMaxListeners=function(e){if(!isNumber(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},EventEmitter.prototype.emit=function(e){var t,i,n,s,r,o;if(this._events||(this._events={}),"error"===e&&(!this._events.error||isObject(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}if(i=this._events[e],isUndefined(i))return!1;if(isFunction(i))switch(arguments.length){case 1:i.call(this);break;case 2:i.call(this,arguments[1]);break;case 3:i.call(this,arguments[1],arguments[2]);break;default:s=Array.prototype.slice.call(arguments,1),i.apply(this,s)}else if(isObject(i))for(s=Array.prototype.slice.call(arguments,1),n=(o=i.slice()).length,r=0;r<n;r++)o[r].apply(this,s);return!0},EventEmitter.prototype.addListener=function(e,t){var i;if(!isFunction(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,isFunction(t.listener)?t.listener:t),this._events[e]?isObject(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,isObject(this._events[e])&&!this._events[e].warned&&(i=isUndefined(this._maxListeners)?EventEmitter.defaultMaxListeners:this._maxListeners)&&i>0&&this._events[e].length>i&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},EventEmitter.prototype.on=EventEmitter.prototype.addListener,EventEmitter.prototype.once=function(e,t){function i(){this.removeListener(e,i),n||(n=!0,t.apply(this,arguments))}if(!isFunction(t))throw TypeError("listener must be a function");var n=!1;return i.listener=t,this.on(e,i),this},EventEmitter.prototype.removeListener=function(e,t){var i,n,s,r;if(!isFunction(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(i=this._events[e],s=i.length,n=-1,i===t||isFunction(i.listener)&&i.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(isObject(i)){for(r=s;r-- >0;)if(i[r]===t||i[r].listener&&i[r].listener===t){n=r;break}if(n<0)return this;1===i.length?(i.length=0,delete this._events[e]):i.splice(n,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},EventEmitter.prototype.removeAllListeners=function(e){var t,i;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(i=this._events[e],isFunction(i))this.removeListener(e,i);else if(i)for(;i.length;)this.removeListener(e,i[i.length-1]);return delete this._events[e],this},EventEmitter.prototype.listeners=function(e){return this._events&&this._events[e]?isFunction(this._events[e])?[this._events[e]]:this._events[e].slice():[]},EventEmitter.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(isFunction(t))return 1;if(t)return t.length}return 0},EventEmitter.listenerCount=function(e,t){return e.listenerCount(t)};
},{}],8:[function(require,module,exports){
!function(i){if("function"==typeof define&&define.amd)define(["jquery"],i);else if("object"==typeof module&&module.exports){var t=require("jquery");i(t),module.exports=t}else i(jQuery)}(function(i){function t(i){this.init(i)}t.prototype={value:0,size:100,startAngle:-Math.PI,thickness:"auto",fill:{gradient:["#3aeabb","#fdd250"]},emptyFill:"rgba(0, 0, 0, .1)",animation:{duration:1200,easing:"circleProgressEasing"},animationStartValue:0,reverse:!1,lineCap:"butt",insertMode:"prepend",constructor:t,el:null,canvas:null,ctx:null,radius:0,arcFill:null,lastFrameValue:0,init:function(t){i.extend(this,t),this.radius=this.size/2,this.initWidget(),this.initFill(),this.draw(),this.el.trigger("circle-inited")},initWidget:function(){this.canvas||(this.canvas=i("<canvas>")["prepend"==this.insertMode?"prependTo":"appendTo"](this.el)[0]);var t=this.canvas;if(t.width=this.size,t.height=this.size,this.ctx=t.getContext("2d"),window.devicePixelRatio>1){var e=window.devicePixelRatio;t.style.width=t.style.height=this.size+"px",t.width=t.height=this.size*e,this.ctx.scale(e,e)}},initFill:function(){function t(){var t=i("<canvas>")[0];t.width=e.size,t.height=e.size,t.getContext("2d").drawImage(g,0,0,r,r),e.arcFill=e.ctx.createPattern(t,"no-repeat"),e.drawFrame(e.lastFrameValue)}var e=this,a=this.fill,n=this.ctx,r=this.size;if(!a)throw Error("The fill is not specified!");if("string"==typeof a&&(a={color:a}),a.color&&(this.arcFill=a.color),a.gradient){var s=a.gradient;if(1==s.length)this.arcFill=s[0];else if(s.length>1){for(var l=a.gradientAngle||0,o=a.gradientDirection||[r/2*(1-Math.cos(l)),r/2*(1+Math.sin(l)),r/2*(1+Math.cos(l)),r/2*(1-Math.sin(l))],h=n.createLinearGradient.apply(n,o),c=0;c<s.length;c++){var d=s[c],u=c/(s.length-1);i.isArray(d)&&(u=d[1],d=d[0]),h.addColorStop(u,d)}this.arcFill=h}}if(a.image){var g;a.image instanceof Image?g=a.image:(g=new Image).src=a.image,g.complete?t():g.onload=t}},draw:function(){this.animation?this.drawAnimated(this.value):this.drawFrame(this.value)},drawFrame:function(i){this.lastFrameValue=i,this.ctx.clearRect(0,0,this.size,this.size),this.drawEmptyArc(i),this.drawArc(i)},drawArc:function(i){if(0!==i){var t=this.ctx,e=this.radius,a=this.getThickness(),n=this.startAngle;t.save(),t.beginPath(),this.reverse?t.arc(e,e,e-a/2,n-2*Math.PI*i,n):t.arc(e,e,e-a/2,n,n+2*Math.PI*i),t.lineWidth=a,t.lineCap=this.lineCap,t.strokeStyle=this.arcFill,t.stroke(),t.restore()}},drawEmptyArc:function(i){var t=this.ctx,e=this.radius,a=this.getThickness(),n=this.startAngle;i<1&&(t.save(),t.beginPath(),i<=0?t.arc(e,e,e-a/2,0,2*Math.PI):this.reverse?t.arc(e,e,e-a/2,n,n-2*Math.PI*i):t.arc(e,e,e-a/2,n+2*Math.PI*i,n),t.lineWidth=a,t.strokeStyle=this.emptyFill,t.stroke(),t.restore())},drawAnimated:function(t){var e=this,a=this.el,n=i(this.canvas);n.stop(!0,!1),a.trigger("circle-animation-start"),n.css({animationProgress:0}).animate({animationProgress:1},i.extend({},this.animation,{step:function(i){var n=e.animationStartValue*(1-i)+t*i;e.drawFrame(n),a.trigger("circle-animation-progress",[i,n])}})).promise().always(function(){a.trigger("circle-animation-end")})},getThickness:function(){return i.isNumeric(this.thickness)?this.thickness:this.size/14},getValue:function(){return this.value},setValue:function(i){this.animation&&(this.animationStartValue=this.lastFrameValue),this.value=i,this.draw()}},i.circleProgress={defaults:t.prototype},i.easing.circleProgressEasing=function(i){return i<.5?.5*(i*=2)*i*i:1-.5*(i=2-2*i)*i*i},i.fn.circleProgress=function(e,a){var n="circle-progress",r=this.data(n);if("widget"==e){if(!r)throw Error('Calling "widget" method on not initialized instance is forbidden');return r.canvas}if("value"==e){if(!r)throw Error('Calling "value" method on not initialized instance is forbidden');if(void 0===a)return r.getValue();var s=arguments[1];return this.each(function(){i(this).data(n).setValue(s)})}return this.each(function(){var a=i(this),r=a.data(n),s=i.isPlainObject(e)?e:{};if(r)r.init(s);else{var l=i.extend({},a.data());"string"==typeof l.fill&&(l.fill=JSON.parse(l.fill)),"string"==typeof l.animation&&(l.animation=JSO
},{"jquery":9}],9:[function(require,module,exports){
!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(e,t){"use strict";function n(e,t){var n=(t=t||te).createElement("script");n.text=e,t.head.appendChild(n).parentNode.removeChild(n)}function r(e){var t=!!e&&"length"in e&&e.length,n=de.type(e);return"function"!==n&&!de.isWindow(e)&&("array"===n||0===t||"number"==typeof t&&t>0&&t-1 in e)}function i(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()}function o(e,t,n){return de.isFunction(t)?de.grep(e,function(e,r){return!!t.call(e,r,e)!==n}):t.nodeType?de.grep(e,function(e){return e===t!==n}):"string"!=typeof t?de.grep(e,function(e){return ae.call(t,e)>-1!==n}):Ce.test(t)?de.filter(t,e,n):(t=de.filter(t,e),de.grep(e,function(e){return ae.call(t,e)>-1!==n&&1===e.nodeType}))}function a(e,t){for(;(e=e[t])&&1!==e.nodeType;);return e}function s(e){var t={};return de.each(e.match(De)||[],function(e,n){t[n]=!0}),t}function u(e){return e}function l(e){throw e}function c(e,t,n,r){var i;try{e&&de.isFunction(i=e.promise)?i.call(e).done(t).fail(n):e&&de.isFunction(i=e.then)?i.call(e,t,n):t.apply(void 0,[e].slice(r))}catch(e){n.apply(void 0,[e])}}function f(){te.removeEventListener("DOMContentLoaded",f),e.removeEventListener("load",f),de.ready()}function p(){this.expando=de.expando+p.uid++}function d(e){return"true"===e||"false"!==e&&("null"===e?null:e===+e+""?+e:Oe.test(e)?JSON.parse(e):e)}function h(e,t,n){var r;if(void 0===n&&1===e.nodeType)if(r="data-"+t.replace(Pe,"-$&").toLowerCase(),"string"==typeof(n=e.getAttribute(r))){try{n=d(n)}catch(e){}Fe.set(e,t,n)}else n=void 0;return n}function g(e,t,n,r){var i,o=1,a=20,s=r?function(){return r.cur()}:function(){return de.css(e,t,"")},u=s(),l=n&&n[3]||(de.cssNumber[t]?"":"px"),c=(de.cssNumber[t]||"px"!==l&&+u)&&Me.exec(de.css(e,t));if(c&&c[3]!==l){l=l||c[3],n=n||[],c=+u||1;do{c/=o=o||".5",de.style(e,t,c+l)}while(o!==(o=s()/u)&&1!==o&&--a)}return n&&(c=+c||+u||0,i=n[1]?c+(n[1]+1)*n[2]:+n[2],r&&(r.unit=l,r.start=c,r.end=i)),i}function v(e){var t,n=e.ownerDocument,r=e.nodeName,i=Be[r];return i||(t=n.body.appendChild(n.createElement(r)),i=de.css(t,"display"),t.parentNode.removeChild(t),"none"===i&&(i="block"),Be[r]=i,i)}function m(e,t){for(var n,r,i=[],o=0,a=e.length;o<a;o++)(r=e[o]).style&&(n=r.style.display,t?("none"===n&&(i[o]=He.get(r,"display")||null,i[o]||(r.style.display="")),""===r.style.display&&We(r)&&(i[o]=v(r))):"none"!==n&&(i[o]="none",He.set(r,"display",n)));for(o=0;o<a;o++)null!=i[o]&&(e[o].style.display=i[o]);return e}function y(e,t){var n;return n=void 0!==e.getElementsByTagName?e.getElementsByTagName(t||"*"):void 0!==e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&i(e,t)?de.merge([e],n):n}function x(e,t){for(var n=0,r=e.length;n<r;n++)He.set(e[n],"globalEval",!t||He.get(t[n],"globalEval"))}function b(e,t,n,r,i){for(var o,a,s,u,l,c,f=t.createDocumentFragment(),p=[],d=0,h=e.length;d<h;d++)if((o=e[d])||0===o)if("object"===de.type(o))de.merge(p,o.nodeType?[o]:o);else if(Ve.test(o)){for(a=a||f.appendChild(t.createElement("div")),s=(ze.exec(o)||["",""])[1].toLowerCase(),u=Ue[s]||Ue._default,a.innerHTML=u[1]+de.htmlPrefilter(o)+u[2],c=u[0];c--;)a=a.lastChild;de.merge(p,a.childNodes),(a=f.firstChild).textContent=""}else p.push(t.createTextNode(o));for(f.textContent="",d=0;o=p[d++];)if(r&&de.inArray(o,r)>-1)i&&i.push(o);else if(l=de.contains(o.ownerDocument,o),a=y(f.appendChild(o),"script"),l&&x(a),n)for(c=0;o=a[c++];)Xe.test(o.type||"")&&n.push(o);return f}function w(){return!0}function T(){return!1}function C(){try{return te.activeElement}catch(e){}}function E(e,t,n,r,i,o){var a,s;if("object"==typeof t){"string"!=typeof n&&(r=r||n,n=void 0);for(s in t)E(e,s,n,r,t[s],o);return e}if(null==r&&null==i?(i=n,r=n=void 0):null==i&&("string"==typeof n?(i=r,r=void 0):(i=r,r=n,n=void 0)),!1===i)i=T;else if(!i)return e;return 1===o&&(a=i,(i=function(e){return de().off(e),a.apply(this,arguments
},{}],10:[function(require,module,exports){
"use strict";function RavenConfigError(r){this.name="RavenConfigError",this.message=r}RavenConfigError.prototype=new Error,RavenConfigError.prototype.constructor=RavenConfigError,module.exports=RavenConfigError;
},{}],11:[function(require,module,exports){
"use strict";var wrapMethod=function(r,a,e){var o=r[a],n=r;if(a in r){var t="warn"===a?"warning":a;r[a]=function(){var r=[].slice.call(arguments),a=""+r.join(" "),l={level:t,logger:"console",extra:{arguments:r}};e&&e(a,l),o&&Function.prototype.apply.call(o,n,r)}}};module.exports={wrapMethod:wrapMethod};
},{}],12:[function(require,module,exports){
(function (global){
"use strict";function now(){return+new Date}function keepOriginalCallback(t,e){return isFunction(e)?function(r){return e(r,t)}:e}function Raven(){this._hasJSON=!("object"!=typeof JSON||!JSON.stringify),this._hasDocument=!isUndefined(_document),this._hasNavigator=!isUndefined(_navigator),this._lastCapturedException=null,this._lastData=null,this._lastEventId=null,this._globalServer=null,this._globalKey=null,this._globalProject=null,this._globalContext={},this._globalOptions={logger:"javascript",ignoreErrors:[],ignoreUrls:[],whitelistUrls:[],includePaths:[],crossOrigin:"anonymous",collectWindowErrors:!0,maxMessageLength:0,maxUrlLength:250,stackTraceLimit:50,autoBreadcrumbs:!0,instrument:!0,sampleRate:1},this._ignoreOnError=0,this._isRavenInstalled=!1,this._originalErrorStackTraceLimit=Error.stackTraceLimit,this._originalConsole=_window.console||{},this._originalConsoleMethods={},this._plugins=[],this._startTime=now(),this._wrappedBuiltIns=[],this._breadcrumbs=[],this._lastCapturedEvent=null,this._keypressTimeout,this._location=_window.location,this._lastHref=this._location&&this._location.href,this._resetBackoff();for(var t in this._originalConsole)this._originalConsoleMethods[t]=this._originalConsole[t]}function isUndefined(t){return void 0===t}function isFunction(t){return"function"==typeof t}function isString(t){return"[object String]"===objectPrototype.toString.call(t)}function isEmptyObject(t){for(var e in t)return!1;return!0}function each(t,e){var r,n;if(isUndefined(t.length))for(r in t)hasKey(t,r)&&e.call(null,r,t[r]);else if(n=t.length)for(r=0;r<n;r++)e.call(null,r,t[r])}function objectMerge(t,e){return e?(each(e,function(e,r){t[e]=r}),t):t}function objectFrozen(t){return!!Object.isFrozen&&Object.isFrozen(t)}function truncate(t,e){return!e||t.length<=e?t:t.substr(0,e)+"…"}function hasKey(t,e){return objectPrototype.hasOwnProperty.call(t,e)}function joinRegExp(t){for(var e,r=[],n=0,a=t.length;n<a;n++)isString(e=t[n])?r.push(e.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1")):e&&e.source&&r.push(e.source);return new RegExp(r.join("|"),"i")}function urlencode(t){var e=[];return each(t,function(t,r){e.push(encodeURIComponent(t)+"="+encodeURIComponent(r))}),e.join("&")}function parseUrl(t){var e=t.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!e)return{};var r=e[6]||"",n=e[8]||"";return{protocol:e[2],host:e[4],path:e[5],relative:e[5]+r+n}}function uuid4(){var t=_window.crypto||_window.msCrypto;if(!isUndefined(t)&&t.getRandomValues){var e=new Uint16Array(8);t.getRandomValues(e),e[3]=4095&e[3]|16384,e[4]=16383&e[4]|32768;var r=function(t){for(var e=t.toString(16);e.length<4;)e="0"+e;return e};return r(e[0])+r(e[1])+r(e[2])+r(e[3])+r(e[4])+r(e[5])+r(e[6])+r(e[7])}return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})}function htmlTreeAsString(t){for(var e,r=[],n=0,a=0,i=" > ".length;t&&n++<5&&!("html"===(e=htmlElementAsString(t))||n>1&&a+r.length*i+e.length>=80);)r.push(e),a+=e.length,t=t.parentNode;return r.reverse().join(" > ")}function htmlElementAsString(t){var e,r,n,a,i,o=[];if(!t||!t.tagName)return"";if(o.push(t.tagName.toLowerCase()),t.id&&o.push("#"+t.id),(e=t.className)&&isString(e))for(r=e.split(/\s+/),i=0;i<r.length;i++)o.push("."+r[i]);var s=["type","name","title","alt"];for(i=0;i<s.length;i++)n=s[i],(a=t.getAttribute(n))&&o.push("["+n+'="'+a+'"]');return o.join("")}function isOnlyOneTruthy(t,e){return!!(!!t^!!e)}function isSameException(t,e){return!isOnlyOneTruthy(t,e)&&(t=t.values[0],e=e.values[0],t.type===e.type&&t.value===e.value&&isSameStacktrace(t.stacktrace,e.stacktrace))}function isSameStacktrace(t,e){if(isOnlyOneTruthy(t,e))return!1;var r=t.frames,n=e.frames;if(r.length!==n.length)return!1;for(var a,i,o=0;o<r.length;o++)if(a=r[o],i=n[o],a.filename!==i.filename||a.lineno!==i.lineno||a.colno!==i.colno||a.function!==i.function)return!1;return!0}function fill(t,e,r,n){var a=t[e];t[e]=r(a),n&&n.push([t,e,a])}var TraceKit=require("../vendor/TraceKit/tracekit"),stringify=require("../vendor/json-stringify-
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"../vendor/TraceKit/tracekit":15,"../vendor/json-stringify-safe/stringify":16,"./configError":10,"./console":11,"./utils":14}],13:[function(require,module,exports){
(function (global){
"use strict";var RavenConstructor=require("./raven"),_window="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},_Raven=_window.Raven,Raven=new RavenConstructor;Raven.noConflict=function(){return _window.Raven=_Raven,Raven},Raven.afterLoad(),module.exports=Raven;
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"./raven":12}],14:[function(require,module,exports){
"use strict";function isObject(r){return"object"==typeof r&&null!==r}function isError(r){switch({}.toString.call(r)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return r instanceof Error}}function wrappedCallback(r){return function(t,e){var c=r(t)||t;return e?e(c)||c:c}}module.exports={isObject:isObject,isError:isError,wrappedCallback:wrappedCallback};
},{}],15:[function(require,module,exports){
(function (global){
"use strict";function getLocationHref(){return"undefined"==typeof document||void 0===document.location?"":document.location.href}var utils=require("../../src/utils"),TraceKit={collectWindowErrors:!0,debug:!1},_window="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},_slice=[].slice,UNKNOWN_FUNCTION="?",ERROR_TYPES_RE=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/;TraceKit.report=function(){function e(e,n){var t=null;if(!n||TraceKit.collectWindowErrors){for(var i in a)if(a.hasOwnProperty(i))try{a[i].apply(null,[e].concat(_slice.call(arguments,2)))}catch(e){t=e}if(t)throw t}}function n(n,t,i,l,u){if(f)TraceKit.computeStackTrace.augmentStackTraceWithInitialElement(f,t,i,n),c();else if(u&&utils.isError(u))e(TraceKit.computeStackTrace(u),!0);else{var a,o={url:t,line:i,column:l},s=void 0,m=n;"[object String]"==={}.toString.call(n)&&(a=n.match(ERROR_TYPES_RE))&&(s=a[1],m=a[2]),o.func=UNKNOWN_FUNCTION,e({name:s,message:m,url:getLocationHref(),stack:[o]},!0)}return!!r&&r.apply(this,arguments)}function t(){u||(r=_window.onerror,_window.onerror=n,u=!0)}function i(){u&&(_window.onerror=r,u=!1,r=void 0)}function c(){var n=f,t=o;o=null,f=null,s=null,e.apply(null,[n,!1].concat(t))}function l(e,n){var t=_slice.call(arguments,1);if(f){if(s===e)return;c()}var i=TraceKit.computeStackTrace(e);if(f=i,s=e,o=t,setTimeout(function(){s===e&&c()},i.incomplete?2e3:0),!1!==n)throw e}var r,u,a=[],o=null,s=null,f=null;return l.subscribe=function(e){t(),a.push(e)},l.unsubscribe=function(e){for(var n=a.length-1;n>=0;--n)a[n]===e&&a.splice(n,1)},l.uninstall=function(){i(),a=[]},l}(),TraceKit.computeStackTrace=function(){function e(e){if(void 0!==e.stack&&e.stack){for(var n,t,i,c=/^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack|<anonymous>|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,l=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i,r=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,u=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,a=/\((\S*)(?::(\d+))(?::(\d+))\)/,o=e.stack.split("\n"),s=[],f=(/^(.*) is undefined$/.exec(e.message),0),m=o.length;f<m;++f){if(t=c.exec(o[f])){var d=t[2]&&0===t[2].indexOf("native");(p=t[2]&&0===t[2].indexOf("eval"))&&(n=a.exec(t[2]))&&(t[2]=n[1],t[3]=n[2],t[4]=n[3]),i={url:d?null:t[2],func:t[1]||UNKNOWN_FUNCTION,args:d?[t[2]]:[],line:t[3]?+t[3]:null,column:t[4]?+t[4]:null}}else if(t=r.exec(o[f]))i={url:t[2],func:t[1]||UNKNOWN_FUNCTION,args:[],line:+t[3],column:t[4]?+t[4]:null};else{if(!(t=l.exec(o[f])))continue;var p=t[3]&&t[3].indexOf(" > eval")>-1;p&&(n=u.exec(t[3]))?(t[3]=n[1],t[4]=n[2],t[5]=null):0!==f||t[5]||void 0===e.columnNumber||(s[0].column=e.columnNumber+1),i={url:t[3],func:t[1]||UNKNOWN_FUNCTION,args:t[2]?t[2].split(","):[],line:t[4]?+t[4]:null,column:t[5]?+t[5]:null}}!i.func&&i.line&&(i.func=UNKNOWN_FUNCTION),s.push(i)}return s.length?{name:e.name,message:e.message,url:getLocationHref(),stack:s}:null}}function n(e,n,t,i){var c={url:n,line:t};if(c.url&&c.line){if(e.incomplete=!1,c.func||(c.func=UNKNOWN_FUNCTION),e.stack.length>0&&e.stack[0].url===c.url){if(e.stack[0].line===c.line)return!1;if(!e.stack[0].line&&e.stack[0].func===c.func)return e.stack[0].line=c.line,!1}return e.stack.unshift(c),e.partial=!0,!0}return e.incomplete=!0,!1}function t(e,c){for(var l,r,u=/function\s+([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)?\s*\(/i,a=[],o={},s=!1,f=t.caller;f&&!s;f=f.caller)if(f!==i&&f!==TraceKit.report){if(r={url:null,func:UNKNOWN_FUNCTION,line:null,column:null},f.name?r.func=f.name:(l=u.exec(f.toString()))&&(r.func=l[1]),void 0===r.func)try{r.func=l.input.substring(0,l.input.indexOf("{"))}catch(e){}o[""+f]?s=!0:o[""+f]=!0,a.push(r)}c&&a.splice(0,c);var m={name:e.name,message:e.message,url:getLocationHref(),stack:a};return n(m,e.sourceURL||e.fileName,e.line||e.lineNumber,e.message||e.description),m}function i(n,i){var c=null;i=null==i?0:+i;tr
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"../../src/utils":14}],16:[function(require,module,exports){
"use strict";function indexOf(i,r){for(var e=0;e<i.length;++e)if(i[e]===r)return e;return-1}function stringify(i,r,e,n){return JSON.stringify(i,serializer(r,n),e)}function serializer(i,r){var e=[],n=[];return null==r&&(r=function(i,r){return e[0]===r?"[Circular ~]":"[Circular ~."+n.slice(0,indexOf(e,r)).join(".")+"]"}),function(t,s){if(e.length>0){var l=indexOf(e,this);~l?e.splice(l+1):e.push(this),~l?n.splice(l,1/0,t):n.push(t),~indexOf(e,s)&&(s=r.call(this,t,s))}else e.push(s);return null==i?s:i.call(this,t,s)}}exports=module.exports=stringify,exports.getSerialize=serializer;
},{}],17:[function(require,module,exports){
!function(e,t){if("function"==typeof define&&define.amd)define(["module","exports"],t);else if("undefined"!=typeof exports)t(module,exports);else{var s={exports:{}};t(s,s.exports),e.TestPilotGA=s.exports}}(this,function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const s={FIREFOX_NIGHTLY:"nightly",FIREFOX_AURORA:"release",FIREFOX_ESR:"esr",FIREFOX_ESR_NEXT:"esr",LATEST_FIREFOX_DEVEL_VERSION:"developer",LATEST_FIREFOX_RELEASED_DEVEL_VERSION:"developer",LATEST_FIREFOX_VERSION:"release"},n="testpilot_ga__cid",o="https://product-details.mozilla.org/1.0/firefox_versions.json";class r{constructor(e){this.debug=e.debug||!1,this.setOptions(e),this.getChannel(),this.validateOptions()}getChannel(){"undefined"!=typeof browser&&Promise.all([this.getProductDetails(),browser.runtime.getBrowserInfo()]).then(([e,t])=>{const s=this.getVersionMap(e);this.cd20=this.getChannelConstant(t,s)})}getVersionMap(e){const t={};return Object.entries(e).forEach(([e,s])=>{s&&s.length&&(t[s]=e);const n=s.match(/^[^a-z]+/);n&&n.length&&(t[n[0]]=e)}),t}getChannelConstant(e,t){return e&&e.version&&t.hasOwnProperty(e.version)&&s.hasOwnProperty(t[e.version])?s[t[e.version]]:"other"}getProductDetails(){return new Promise((e,t)=>{const s=new window.XMLHttpRequest;s.open("GET",o),s.onload=function(){s.status<400?e(JSON.parse(s.response)):t(s,Error(s.statusText))},s.onerror=function(){t(s,Error("Network Error"))},s.send()})}setOptions(e){const t=Object.assign({},r.defaultOptions,e);Object.entries(t).forEach(([e,t])=>this[e]=t)}validateOptions(e){const t=r.requiredOptions.reduce((e,t)=>(this.hasOwnProperty(t)||e.push(t),e),[]);t.length&&console.error(`Missing required options: ${t.join(", ")}`)}makeUUID(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16))}getCID(){let e=window.localStorage.getItem(n);return e||(e=this.makeUUID(),window.localStorage.setItem(n,e)),e}getParams(e){const{an:t,aid:s,aiid:n,aip:o,av:r,cd19:i,cd20:a,ds:d,t:l,tid:u,uid:c,v:p,xid:g,xvar:h}=this,O=Object.assign({an:t,aid:s,aiid:n,aip:o,av:r,cd19:i,cd20:a,ds:d,t:l,tid:u,uid:c,v:p,xid:g,xvar:h},{cid:this.getCID(),ua:navigator.userAgent,ul:navigator.language,z:Date.now()},e);return Object.keys(O).forEach(e=>{null===O[e]&&delete O[e]}),O}serializeObject(e){return Object.keys(e).reduce((t,s)=>(t.push(`${encodeURIComponent(s)}=${encodeURIComponent(e[s])}`),t),[]).join("&")}requestBody(e){const t=this.getParams(e);return{allParams:t,requestBody:this.serializeObject(t)}}requestURI(){return`https://www.google-analytics.com/${this.debug?"debug/":""}collect`}sendEvent(e,t,s={}){const n=Object.assign({ec:e,ea:t},s),{allParams:o,requestBody:r}=this.requestBody(n);console.log(`Sending '${e}' '${t}':`,o);const i=this.requestURI();return new Promise((e,t)=>{if("1"===navigator.doNotTrack)t("Metrics not sent due to DNT.");else{const s=new window.XMLHttpRequest;s.open("POST",i),s.onload=function(){s.status<400?e(s):t(`Request error: ${s.statusText}`)},s.onerror=function(){t(`Request error: ${s.status}`)},s.send(r)}})}}t.default=r,r.defaultOptions={aid:null,aiid:"testpilot",aip:"1",av:null,cd19:"dev",cd20:null,ds:"addon",t:"event",uid:null,v:"1",xid:null,xvar:null},r.requiredOptions=["an","ds","tid"],e.exports=t.default});
},{}]},{},[4]);