From 2ec4c62a9a2938eee253a6a79f793c12d0ef1174 Mon Sep 17 00:00:00 2001 From: Martti Malmi Date: Mon, 13 Jan 2020 22:21:53 +0200 Subject: [PATCH] init --- .gitignore | 2 + package.json | 12 + src/emoji-button.js | 1087 +++ src/favicon.ico | Bin 0 -> 15086 bytes src/gun.js | 2281 +++++++ src/icon128.png | Bin 0 -> 17095 bytes src/index.html | 120 + src/irisLib.js | 14987 +++++++++++++++++++++++++++++++++++++++++ src/jquery.js | 5 + src/notification.mp3 | Bin 0 -> 17180 bytes src/nts.js | 49 + src/script.js | 487 ++ src/sea.js | 1325 ++++ src/style.css | 296 + 14 files changed, 20651 insertions(+) create mode 100644 .gitignore create mode 100644 package.json create mode 100644 src/emoji-button.js create mode 100644 src/favicon.ico create mode 100644 src/gun.js create mode 100644 src/icon128.png create mode 100644 src/index.html create mode 100644 src/irisLib.js create mode 100644 src/jquery.js create mode 100644 src/notification.mp3 create mode 100644 src/nts.js create mode 100644 src/script.js create mode 100644 src/sea.js create mode 100644 src/style.css diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..a8669b19 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +yarn.lock +node_modules diff --git a/package.json b/package.json new file mode 100644 index 00000000..c28affca --- /dev/null +++ b/package.json @@ -0,0 +1,12 @@ +{ + "name": "iris-messenger", + "version": "1.0.0", + "author": "Martti Malmi ", + "license": "MIT", + "dependencies": { + "http-server": "^0.12.1" + }, + "scripts": { + "start": "http-server src" + } +} diff --git a/src/emoji-button.js b/src/emoji-button.js new file mode 100644 index 00000000..0f7e65cd --- /dev/null +++ b/src/emoji-button.js @@ -0,0 +1,1087 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + (global = global || self, global.EmojiButton = factory()); +}(this, function () { 'use strict'; + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + return Constructor; + } + + function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + + return obj; + } + + function ownKeys(object, enumerableOnly) { + var keys = Object.keys(object); + + if (Object.getOwnPropertySymbols) { + var symbols = Object.getOwnPropertySymbols(object); + if (enumerableOnly) symbols = symbols.filter(function (sym) { + return Object.getOwnPropertyDescriptor(object, sym).enumerable; + }); + keys.push.apply(keys, symbols); + } + + return keys; + } + + function _objectSpread2(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? arguments[i] : {}; + + if (i % 2) { + ownKeys(source, true).forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } else if (Object.getOwnPropertyDescriptors) { + Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); + } else { + ownKeys(source).forEach(function (key) { + Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); + }); + } + } + + return target; + } + + function _toConsumableArray(arr) { + return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); + } + + function _arrayWithoutHoles(arr) { + if (Array.isArray(arr)) { + for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; + + return arr2; + } + } + + function _iterableToArray(iter) { + if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); + } + + function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance"); + } + + function styleInject(css,ref){if(ref===void 0)ref={};var insertAt=ref.insertAt;if(!css||typeof document==='undefined'){return;}var head=document.head||document.getElementsByTagName('head')[0];var style=document.createElement('style');style.type='text/css';if(insertAt==='top'){if(head.firstChild){head.insertBefore(style,head.firstChild);}else{head.appendChild(style);}}else{head.appendChild(style);}if(style.styleSheet){style.styleSheet.cssText=css;}else{style.appendChild(document.createTextNode(css));}} + + var css = ".emoji-picker {\n border: 1px solid #CCCCCC;\n border-radius: 5px;\n background: #FFFFFF;\n width: 23rem;\n font-family: Arial, Helvetica, sans-serif;\n opacity: 0;\n transition: opacity 0.3s;\n margin: 0 0.5em;\n overflow: hidden;\n}\n\n.emoji-picker.visible {\n opacity: 1;\n}\n\n.emoji-picker__content {\n padding: 0.5em;\n height: 20rem;\n overflow: hidden;\n position: relative;\n}\n\n.emoji-picker__preview {\n height: 2em;\n padding: 0.5em;\n border-top: 1px solid #CCCCCC;\n display: flex;\n flex-direction: row;\n align-items: center;\n}\n\n.emoji-picker__preview-emoji {\n font-size: 2em;\n margin-right: 0.25em;\n font-family: \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Segoe UI\", \"Apple Color Emoji\", \"Twemoji Mozilla\", \"Noto Color Emoji\", \"EmojiOne Color\", \"Android Emoji\";\n}\n\n.emoji-picker__preview-name {\n color: #666666;\n font-size: 0.85em;\n overflow-wrap: break-word;\n word-break: break-all;\n}\n\n.emoji-picker__tabs {\n margin: 0;\n padding: 0;\n display: flex;\n}\n\n.emoji-picker__tab {\n font-size: 1.5rem;\n list-style: none;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n flex-grow: 1;\n text-align: center;\n color: #666666;\n border-radius: 3px;\n transition: background 0.25s;\n}\n\n.emoji-picker__tab:hover {\n background: #E8F4F9;\n}\n\n.emoji-picker__tab svg {\n padding: 0.5rem;\n}\n\n.emoji-picker__tab.active {\n background: #4F81E5;\n color: #FFFFFF;\n}\n\n.emoji-picker__tab-body {\n margin-top: 0.5em;\n transform: translateX(25rem);\n transition: transform 0.25s;\n position: absolute;\n}\n\n.emoji-picker__tab-body h2 {\n font-size: 0.85rem;\n color: #333333;\n margin: 0;\n text-align: left;\n}\n\n.emoji-picker__tab-body.active {\n display: block;\n transform: translateX(0);\n}\n\n.emoji-picker__emojis {\n height: 16.5rem;\n overflow-y: scroll;\n display: flex;\n flex-wrap: wrap;\n align-content: flex-start;\n width: calc((1.8rem * 1.5 * 8) + 0.5rem);\n margin: auto;\n}\n\n.emoji-picker__emojis.search-results {\n height: 21rem;\n}\n\n.emoji-picker__emoji {\n background: transparent;\n border: none;\n border-radius: 5px;\n cursor: pointer;\n font-size: 1.8rem;\n width: 1.5em;\n height: 1.5em;\n padding: 0;\n margin: 0;\n outline: none;\n font-family: \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Segoe UI\", \"Apple Color Emoji\", \"Twemoji Mozilla\", \"Noto Color Emoji\", \"EmojiOne Color\", \"Android Emoji\";\n}\n\n.emoji-picker__emoji:focus, .emoji-picker__emoji:hover {\n background: #E8F4F9;\n}\n\n.emoji-picker__search-container {\n margin: 0.5em;\n position: relative;\n height: 2em;\n display: flex;\n}\n\n.emoji-picker__search {\n box-sizing: border-box;\n width: 100%;\n border-radius: 3px;\n border: 1px solid #CCCCCC;\n padding-right: 2em;\n padding: 0.5em 2.25em 0.5em 0.5em;\n font-size: 0.85rem;\n outline: none;\n}\n\n.emoji-picker__search:focus {\n border: 1px solid #4F81E5;\n}\n\n.emoji-picker__search-icon {\n position: absolute;\n color: #CCCCCC;\n width: 1em;\n height: 1em;\n right: 0.75em;\n top: calc(50% - 0.5em);\n}\n\n.emoji-picker__search-not-found {\n color: #666666;\n text-align: center;\n margin-top: 2em;\n}\n\n.emoji-picker__search-not-found-icon {\n font-size: 3em;\n}\n\n.emoji-picker__search-not-found h2 {\n margin: 0.5em 0;\n font-size: 1em;\n}\n\n.emoji-picker__variant-overlay {\n background: rgba(0, 0, 0, 0.7);\n position: absolute;\n top: 0;\n left: 0;\n width: 23rem;\n height: 27.5rem;\n display: flex;\n flex-direction: column;\n justify-content: center;\n}\n\n.emoji-picker__variant-popup {\n background: #FFFFFF;\n margin: 0.5em;\n padding: 0.5em;\n text-align: center;\n}\n\n.emoji-picker__variant-popup-close-button {\n cursor: pointer;\n background: transparent;\n border: none;\n position: absolute;\n right: 1em;\n padding: 0;\n top: calc(50% - 0.5em);\n height: 1em;\n width: 1em;\n}"; + styleInject(css); + + function E(){// Keep this empty so it's easier to inherit from + // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3) + }E.prototype={on:function(name,callback,ctx){var e=this.e||(this.e={});(e[name]||(e[name]=[])).push({fn:callback,ctx:ctx});return this;},once:function(name,callback,ctx){var self=this;function listener(){self.off(name,listener);callback.apply(ctx,arguments);}listener._=callback;return this.on(name,listener,ctx);},emit:function(name){var data=[].slice.call(arguments,1);var evtArr=((this.e||(this.e={}))[name]||[]).slice();var i=0;var len=evtArr.length;for(i;i=0){timeoutDuration=1;break;}}function microtaskDebounce(fn){var called=false;return function(){if(called){return;}called=true;window.Promise.resolve().then(function(){called=false;fn();});};}function taskDebounce(fn){var scheduled=false;return function(){if(!scheduled){scheduled=true;setTimeout(function(){scheduled=false;fn();},timeoutDuration);}};}var supportsMicroTasks=isBrowser&&window.Promise;/** + * Create a debounced version of a method, that's asynchronously deferred + * but called in the minimum time possible. + * + * @method + * @memberof Popper.Utils + * @argument {Function} fn + * @returns {Function} + */var debounce=supportsMicroTasks?microtaskDebounce:taskDebounce;/** + * Check if the given variable is a function + * @method + * @memberof Popper.Utils + * @argument {Any} functionToCheck - variable to check + * @returns {Boolean} answer to: is a function? + */function isFunction(functionToCheck){var getType={};return functionToCheck&&getType.toString.call(functionToCheck)==='[object Function]';}/** + * Get CSS computed property of the given element + * @method + * @memberof Popper.Utils + * @argument {Eement} element + * @argument {String} property + */function getStyleComputedProperty(element,property){if(element.nodeType!==1){return [];}// NOTE: 1 DOM access here + var window=element.ownerDocument.defaultView;var css=window.getComputedStyle(element,null);return property?css[property]:css;}/** + * Returns the parentNode or the host of the element + * @method + * @memberof Popper.Utils + * @argument {Element} element + * @returns {Element} parent + */function getParentNode(element){if(element.nodeName==='HTML'){return element;}return element.parentNode||element.host;}/** + * Returns the scrolling parent of the given element + * @method + * @memberof Popper.Utils + * @argument {Element} element + * @returns {Element} scroll parent + */function getScrollParent(element){// Return body, `getScroll` will take care to get the correct `scrollTop` from it + if(!element){return document.body;}switch(element.nodeName){case'HTML':case'BODY':return element.ownerDocument.body;case'#document':return element.body;}// Firefox want us to check `-x` and `-y` variations as well + var _getStyleComputedProp=getStyleComputedProperty(element),overflow=_getStyleComputedProp.overflow,overflowX=_getStyleComputedProp.overflowX,overflowY=_getStyleComputedProp.overflowY;if(/(auto|scroll|overlay)/.test(overflow+overflowY+overflowX)){return element;}return getScrollParent(getParentNode(element));}var isIE11=isBrowser&&!!(window.MSInputMethodContext&&document.documentMode);var isIE10=isBrowser&&/MSIE 10/.test(navigator.userAgent);/** + * Determines if the browser is Internet Explorer + * @method + * @memberof Popper.Utils + * @param {Number} version to check + * @returns {Boolean} isIE + */function isIE(version){if(version===11){return isIE11;}if(version===10){return isIE10;}return isIE11||isIE10;}/** + * Returns the offset parent of the given element + * @method + * @memberof Popper.Utils + * @argument {Element} element + * @returns {Element} offset parent + */function getOffsetParent(element){if(!element){return document.documentElement;}var noOffsetParent=isIE(10)?document.body:null;// NOTE: 1 DOM access here + var offsetParent=element.offsetParent||null;// Skip hidden elements which don't have an offsetParent + while(offsetParent===noOffsetParent&&element.nextElementSibling){offsetParent=(element=element.nextElementSibling).offsetParent;}var nodeName=offsetParent&&offsetParent.nodeName;if(!nodeName||nodeName==='BODY'||nodeName==='HTML'){return element?element.ownerDocument.documentElement:document.documentElement;}// .offsetParent will return the closest TH, TD or TABLE in case + // no offsetParent is present, I hate this job... + if(['TH','TD','TABLE'].indexOf(offsetParent.nodeName)!==-1&&getStyleComputedProperty(offsetParent,'position')==='static'){return getOffsetParent(offsetParent);}return offsetParent;}function isOffsetContainer(element){var nodeName=element.nodeName;if(nodeName==='BODY'){return false;}return nodeName==='HTML'||getOffsetParent(element.firstElementChild)===element;}/** + * Finds the root node (document, shadowDOM root) of the given element + * @method + * @memberof Popper.Utils + * @argument {Element} node + * @returns {Element} root node + */function getRoot(node){if(node.parentNode!==null){return getRoot(node.parentNode);}return node;}/** + * Finds the offset parent common to the two provided nodes + * @method + * @memberof Popper.Utils + * @argument {Element} element1 + * @argument {Element} element2 + * @returns {Element} common offset parent + */function findCommonOffsetParent(element1,element2){// This check is needed to avoid errors in case one of the elements isn't defined for any reason + if(!element1||!element1.nodeType||!element2||!element2.nodeType){return document.documentElement;}// Here we make sure to give as "start" the element that comes first in the DOM + var order=element1.compareDocumentPosition(element2)&Node.DOCUMENT_POSITION_FOLLOWING;var start=order?element1:element2;var end=order?element2:element1;// Get common ancestor container + var range=document.createRange();range.setStart(start,0);range.setEnd(end,0);var commonAncestorContainer=range.commonAncestorContainer;// Both nodes are inside #document + if(element1!==commonAncestorContainer&&element2!==commonAncestorContainer||start.contains(end)){if(isOffsetContainer(commonAncestorContainer)){return commonAncestorContainer;}return getOffsetParent(commonAncestorContainer);}// one of the nodes is inside shadowDOM, find which one + var element1root=getRoot(element1);if(element1root.host){return findCommonOffsetParent(element1root.host,element2);}else{return findCommonOffsetParent(element1,getRoot(element2).host);}}/** + * Gets the scroll value of the given element in the given side (top and left) + * @method + * @memberof Popper.Utils + * @argument {Element} element + * @argument {String} side `top` or `left` + * @returns {number} amount of scrolled pixels + */function getScroll(element){var side=arguments.length>1&&arguments[1]!==undefined?arguments[1]:'top';var upperSide=side==='top'?'scrollTop':'scrollLeft';var nodeName=element.nodeName;if(nodeName==='BODY'||nodeName==='HTML'){var html=element.ownerDocument.documentElement;var scrollingElement=element.ownerDocument.scrollingElement||html;return scrollingElement[upperSide];}return element[upperSide];}/* + * Sum or subtract the element scroll values (left and top) from a given rect object + * @method + * @memberof Popper.Utils + * @param {Object} rect - Rect object you want to change + * @param {HTMLElement} element - The element from the function reads the scroll values + * @param {Boolean} subtract - set to true if you want to subtract the scroll values + * @return {Object} rect - The modifier rect object + */function includeScroll(rect,element){var subtract=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;var scrollTop=getScroll(element,'top');var scrollLeft=getScroll(element,'left');var modifier=subtract?-1:1;rect.top+=scrollTop*modifier;rect.bottom+=scrollTop*modifier;rect.left+=scrollLeft*modifier;rect.right+=scrollLeft*modifier;return rect;}/* + * Helper to detect borders of a given element + * @method + * @memberof Popper.Utils + * @param {CSSStyleDeclaration} styles + * Result of `getStyleComputedProperty` on the given element + * @param {String} axis - `x` or `y` + * @return {number} borders - The borders size of the given axis + */function getBordersSize(styles,axis){var sideA=axis==='x'?'Left':'Top';var sideB=sideA==='Left'?'Right':'Bottom';return parseFloat(styles['border'+sideA+'Width'],10)+parseFloat(styles['border'+sideB+'Width'],10);}function getSize(axis,body,html,computedStyle){return Math.max(body['offset'+axis],body['scroll'+axis],html['client'+axis],html['offset'+axis],html['scroll'+axis],isIE(10)?parseInt(html['offset'+axis])+parseInt(computedStyle['margin'+(axis==='Height'?'Top':'Left')])+parseInt(computedStyle['margin'+(axis==='Height'?'Bottom':'Right')]):0);}function getWindowSizes(document){var body=document.body;var html=document.documentElement;var computedStyle=isIE(10)&&getComputedStyle(html);return {height:getSize('Height',body,html,computedStyle),width:getSize('Width',body,html,computedStyle)};}var classCallCheck=function(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}};var createClass=function(){function defineProperties(target,props){for(var i=0;i2&&arguments[2]!==undefined?arguments[2]:false;var isIE10=isIE(10);var isHTML=parent.nodeName==='HTML';var childrenRect=getBoundingClientRect(children);var parentRect=getBoundingClientRect(parent);var scrollParent=getScrollParent(children);var styles=getStyleComputedProperty(parent);var borderTopWidth=parseFloat(styles.borderTopWidth,10);var borderLeftWidth=parseFloat(styles.borderLeftWidth,10);// In cases where the parent is fixed, we must ignore negative scroll in offset calc + if(fixedPosition&&isHTML){parentRect.top=Math.max(parentRect.top,0);parentRect.left=Math.max(parentRect.left,0);}var offsets=getClientRect({top:childrenRect.top-parentRect.top-borderTopWidth,left:childrenRect.left-parentRect.left-borderLeftWidth,width:childrenRect.width,height:childrenRect.height});offsets.marginTop=0;offsets.marginLeft=0;// Subtract margins of documentElement in case it's being used as parent + // we do this only on HTML because it's the only element that behaves + // differently when margins are applied to it. The margins are included in + // the box of the documentElement, in the other cases not. + if(!isIE10&&isHTML){var marginTop=parseFloat(styles.marginTop,10);var marginLeft=parseFloat(styles.marginLeft,10);offsets.top-=borderTopWidth-marginTop;offsets.bottom-=borderTopWidth-marginTop;offsets.left-=borderLeftWidth-marginLeft;offsets.right-=borderLeftWidth-marginLeft;// Attach marginTop and marginLeft because in some circumstances we may need them + offsets.marginTop=marginTop;offsets.marginLeft=marginLeft;}if(isIE10&&!fixedPosition?parent.contains(scrollParent):parent===scrollParent&&scrollParent.nodeName!=='BODY'){offsets=includeScroll(offsets,parent);}return offsets;}function getViewportOffsetRectRelativeToArtbitraryNode(element){var excludeScroll=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var html=element.ownerDocument.documentElement;var relativeOffset=getOffsetRectRelativeToArbitraryNode(element,html);var width=Math.max(html.clientWidth,window.innerWidth||0);var height=Math.max(html.clientHeight,window.innerHeight||0);var scrollTop=!excludeScroll?getScroll(html):0;var scrollLeft=!excludeScroll?getScroll(html,'left'):0;var offset={top:scrollTop-relativeOffset.top+relativeOffset.marginTop,left:scrollLeft-relativeOffset.left+relativeOffset.marginLeft,width:width,height:height};return getClientRect(offset);}/** + * Check if the given element is fixed or is inside a fixed parent + * @method + * @memberof Popper.Utils + * @argument {Element} element + * @argument {Element} customContainer + * @returns {Boolean} answer to "isFixed?" + */function isFixed(element){var nodeName=element.nodeName;if(nodeName==='BODY'||nodeName==='HTML'){return false;}if(getStyleComputedProperty(element,'position')==='fixed'){return true;}var parentNode=getParentNode(element);if(!parentNode){return false;}return isFixed(parentNode);}/** + * Finds the first parent of an element that has a transformed property defined + * @method + * @memberof Popper.Utils + * @argument {Element} element + * @returns {Element} first transformed parent or documentElement + */function getFixedPositionOffsetParent(element){// This check is needed to avoid errors in case one of the elements isn't defined for any reason + if(!element||!element.parentElement||isIE()){return document.documentElement;}var el=element.parentElement;while(el&&getStyleComputedProperty(el,'transform')==='none'){el=el.parentElement;}return el||document.documentElement;}/** + * Computed the boundaries limits and return them + * @method + * @memberof Popper.Utils + * @param {HTMLElement} popper + * @param {HTMLElement} reference + * @param {number} padding + * @param {HTMLElement} boundariesElement - Element used to define the boundaries + * @param {Boolean} fixedPosition - Is in fixed position mode + * @returns {Object} Coordinates of the boundaries + */function getBoundaries(popper,reference,padding,boundariesElement){var fixedPosition=arguments.length>4&&arguments[4]!==undefined?arguments[4]:false;// NOTE: 1 DOM access here + var boundaries={top:0,left:0};var offsetParent=fixedPosition?getFixedPositionOffsetParent(popper):findCommonOffsetParent(popper,reference);// Handle viewport case + if(boundariesElement==='viewport'){boundaries=getViewportOffsetRectRelativeToArtbitraryNode(offsetParent,fixedPosition);}else{// Handle other cases based on DOM element used as boundaries + var boundariesNode=void 0;if(boundariesElement==='scrollParent'){boundariesNode=getScrollParent(getParentNode(reference));if(boundariesNode.nodeName==='BODY'){boundariesNode=popper.ownerDocument.documentElement;}}else if(boundariesElement==='window'){boundariesNode=popper.ownerDocument.documentElement;}else{boundariesNode=boundariesElement;}var offsets=getOffsetRectRelativeToArbitraryNode(boundariesNode,offsetParent,fixedPosition);// In case of HTML, we need a different computation + if(boundariesNode.nodeName==='HTML'&&!isFixed(offsetParent)){var _getWindowSizes=getWindowSizes(popper.ownerDocument),height=_getWindowSizes.height,width=_getWindowSizes.width;boundaries.top+=offsets.top-offsets.marginTop;boundaries.bottom=height+offsets.top;boundaries.left+=offsets.left-offsets.marginLeft;boundaries.right=width+offsets.left;}else{// for all the other DOM elements, this one is good + boundaries=offsets;}}// Add paddings + padding=padding||0;var isPaddingNumber=typeof padding==='number';boundaries.left+=isPaddingNumber?padding:padding.left||0;boundaries.top+=isPaddingNumber?padding:padding.top||0;boundaries.right-=isPaddingNumber?padding:padding.right||0;boundaries.bottom-=isPaddingNumber?padding:padding.bottom||0;return boundaries;}function getArea(_ref){var width=_ref.width,height=_ref.height;return width*height;}/** + * Utility used to transform the `auto` placement to the placement with more + * available space. + * @method + * @memberof Popper.Utils + * @argument {Object} data - The data object generated by update method + * @argument {Object} options - Modifiers configuration and options + * @returns {Object} The data object, properly modified + */function computeAutoPlacement(placement,refRect,popper,reference,boundariesElement){var padding=arguments.length>5&&arguments[5]!==undefined?arguments[5]:0;if(placement.indexOf('auto')===-1){return placement;}var boundaries=getBoundaries(popper,reference,padding,boundariesElement);var rects={top:{width:boundaries.width,height:refRect.top-boundaries.top},right:{width:boundaries.right-refRect.right,height:boundaries.height},bottom:{width:boundaries.width,height:boundaries.bottom-refRect.bottom},left:{width:refRect.left-boundaries.left,height:boundaries.height}};var sortedAreas=Object.keys(rects).map(function(key){return _extends({key:key},rects[key],{area:getArea(rects[key])});}).sort(function(a,b){return b.area-a.area;});var filteredAreas=sortedAreas.filter(function(_ref2){var width=_ref2.width,height=_ref2.height;return width>=popper.clientWidth&&height>=popper.clientHeight;});var computedPlacement=filteredAreas.length>0?filteredAreas[0].key:sortedAreas[0].key;var variation=placement.split('-')[1];return computedPlacement+(variation?'-'+variation:'');}/** + * Get offsets to the reference element + * @method + * @memberof Popper.Utils + * @param {Object} state + * @param {Element} popper - the popper element + * @param {Element} reference - the reference element (the popper will be relative to this) + * @param {Element} fixedPosition - is in fixed position mode + * @returns {Object} An object containing the offsets which will be applied to the popper + */function getReferenceOffsets(state,popper,reference){var fixedPosition=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;var commonOffsetParent=fixedPosition?getFixedPositionOffsetParent(popper):findCommonOffsetParent(popper,reference);return getOffsetRectRelativeToArbitraryNode(reference,commonOffsetParent,fixedPosition);}/** + * Get the outer sizes of the given element (offset size + margins) + * @method + * @memberof Popper.Utils + * @argument {Element} element + * @returns {Object} object containing width and height properties + */function getOuterSizes(element){var window=element.ownerDocument.defaultView;var styles=window.getComputedStyle(element);var x=parseFloat(styles.marginTop||0)+parseFloat(styles.marginBottom||0);var y=parseFloat(styles.marginLeft||0)+parseFloat(styles.marginRight||0);var result={width:element.offsetWidth+y,height:element.offsetHeight+x};return result;}/** + * Get the opposite placement of the given one + * @method + * @memberof Popper.Utils + * @argument {String} placement + * @returns {String} flipped placement + */function getOppositePlacement(placement){var hash={left:'right',right:'left',bottom:'top',top:'bottom'};return placement.replace(/left|right|bottom|top/g,function(matched){return hash[matched];});}/** + * Get offsets to the popper + * @method + * @memberof Popper.Utils + * @param {Object} position - CSS position the Popper will get applied + * @param {HTMLElement} popper - the popper element + * @param {Object} referenceOffsets - the reference offsets (the popper will be relative to this) + * @param {String} placement - one of the valid placement options + * @returns {Object} popperOffsets - An object containing the offsets which will be applied to the popper + */function getPopperOffsets(popper,referenceOffsets,placement){placement=placement.split('-')[0];// Get popper node sizes + var popperRect=getOuterSizes(popper);// Add position, width and height to our offsets object + var popperOffsets={width:popperRect.width,height:popperRect.height};// depending by the popper placement we have to compute its offsets slightly differently + var isHoriz=['right','left'].indexOf(placement)!==-1;var mainSide=isHoriz?'top':'left';var secondarySide=isHoriz?'left':'top';var measurement=isHoriz?'height':'width';var secondaryMeasurement=!isHoriz?'height':'width';popperOffsets[mainSide]=referenceOffsets[mainSide]+referenceOffsets[measurement]/2-popperRect[measurement]/2;if(placement===secondarySide){popperOffsets[secondarySide]=referenceOffsets[secondarySide]-popperRect[secondaryMeasurement];}else{popperOffsets[secondarySide]=referenceOffsets[getOppositePlacement(secondarySide)];}return popperOffsets;}/** + * Mimics the `find` method of Array + * @method + * @memberof Popper.Utils + * @argument {Array} arr + * @argument prop + * @argument value + * @returns index or -1 + */function find(arr,check){// use native find if supported + if(Array.prototype.find){return arr.find(check);}// use `filter` to obtain the same behavior of `find` + return arr.filter(check)[0];}/** + * Return the index of the matching object + * @method + * @memberof Popper.Utils + * @argument {Array} arr + * @argument prop + * @argument value + * @returns index or -1 + */function findIndex(arr,prop,value){// use native findIndex if supported + if(Array.prototype.findIndex){return arr.findIndex(function(cur){return cur[prop]===value;});}// use `find` + `indexOf` if `findIndex` isn't supported + var match=find(arr,function(obj){return obj[prop]===value;});return arr.indexOf(match);}/** + * Loop trough the list of modifiers and run them in order, + * each of them will then edit the data object. + * @method + * @memberof Popper.Utils + * @param {dataObject} data + * @param {Array} modifiers + * @param {String} ends - Optional modifier name used as stopper + * @returns {dataObject} + */function runModifiers(modifiers,data,ends){var modifiersToRun=ends===undefined?modifiers:modifiers.slice(0,findIndex(modifiers,'name',ends));modifiersToRun.forEach(function(modifier){if(modifier['function']){// eslint-disable-line dot-notation + console.warn('`modifier.function` is deprecated, use `modifier.fn`!');}var fn=modifier['function']||modifier.fn;// eslint-disable-line dot-notation + if(modifier.enabled&&isFunction(fn)){// Add properties to offsets to make them a complete clientRect object + // we do this before each modifier to make sure the previous one doesn't + // mess with these values + data.offsets.popper=getClientRect(data.offsets.popper);data.offsets.reference=getClientRect(data.offsets.reference);data=fn(data,modifier);}});return data;}/** + * Updates the position of the popper, computing the new offsets and applying + * the new style.
+ * Prefer `scheduleUpdate` over `update` because of performance reasons. + * @method + * @memberof Popper + */function update(){// if popper is destroyed, don't perform any further update + if(this.state.isDestroyed){return;}var data={instance:this,styles:{},arrowStyles:{},attributes:{},flipped:false,offsets:{}};// compute reference element offsets + data.offsets.reference=getReferenceOffsets(this.state,this.popper,this.reference,this.options.positionFixed);// compute auto placement, store placement inside the data object, + // modifiers will be able to edit `placement` if needed + // and refer to originalPlacement to know the original value + data.placement=computeAutoPlacement(this.options.placement,data.offsets.reference,this.popper,this.reference,this.options.modifiers.flip.boundariesElement,this.options.modifiers.flip.padding);// store the computed placement inside `originalPlacement` + data.originalPlacement=data.placement;data.positionFixed=this.options.positionFixed;// compute the popper offsets + data.offsets.popper=getPopperOffsets(this.popper,data.offsets.reference,data.placement);data.offsets.popper.position=this.options.positionFixed?'fixed':'absolute';// run the modifiers + data=runModifiers(this.modifiers,data);// the first `update` will call `onCreate` callback + // the other ones will call `onUpdate` callback + if(!this.state.isCreated){this.state.isCreated=true;this.options.onCreate(data);}else{this.options.onUpdate(data);}}/** + * Helper used to know if the given modifier is enabled. + * @method + * @memberof Popper.Utils + * @returns {Boolean} + */function isModifierEnabled(modifiers,modifierName){return modifiers.some(function(_ref){var name=_ref.name,enabled=_ref.enabled;return enabled&&name===modifierName;});}/** + * Get the prefixed supported property name + * @method + * @memberof Popper.Utils + * @argument {String} property (camelCase) + * @returns {String} prefixed property (camelCase or PascalCase, depending on the vendor prefix) + */function getSupportedPropertyName(property){var prefixes=[false,'ms','Webkit','Moz','O'];var upperProp=property.charAt(0).toUpperCase()+property.slice(1);for(var i=0;i the positioning is relative to the bottom of the screen (excluding the scrollbar) + // and not the bottom of the html element + if(offsetParent.nodeName==='HTML'){top=-offsetParent.clientHeight+offsets.bottom;}else{top=-offsetParentRect.height+offsets.bottom;}}else{top=offsets.top;}if(sideB==='right'){if(offsetParent.nodeName==='HTML'){left=-offsetParent.clientWidth+offsets.right;}else{left=-offsetParentRect.width+offsets.right;}}else{left=offsets.left;}if(gpuAcceleration&&prefixedProperty){styles[prefixedProperty]='translate3d('+left+'px, '+top+'px, 0)';styles[sideA]=0;styles[sideB]=0;styles.willChange='transform';}else{// othwerise, we use the standard `top`, `left`, `bottom` and `right` properties + var invertTop=sideA==='bottom'?-1:1;var invertLeft=sideB==='right'?-1:1;styles[sideA]=top*invertTop;styles[sideB]=left*invertLeft;styles.willChange=sideA+', '+sideB;}// Attributes + var attributes={'x-placement':data.placement};// Update `data` attributes, styles and arrowStyles + data.attributes=_extends({},attributes,data.attributes);data.styles=_extends({},styles,data.styles);data.arrowStyles=_extends({},data.offsets.arrow,data.arrowStyles);return data;}/** + * Helper used to know if the given modifier depends from another one.
+ * It checks if the needed modifier is listed and enabled. + * @method + * @memberof Popper.Utils + * @param {Array} modifiers - list of modifiers + * @param {String} requestingName - name of requesting modifier + * @param {String} requestedName - name of requested modifier + * @returns {Boolean} + */function isModifierRequired(modifiers,requestingName,requestedName){var requesting=find(modifiers,function(_ref){var name=_ref.name;return name===requestingName;});var isRequired=!!requesting&&modifiers.some(function(modifier){return modifier.name===requestedName&&modifier.enabled&&modifier.orderpopper[opSide]){data.offsets.popper[side]+=reference[side]+arrowElementSize-popper[opSide];}data.offsets.popper=getClientRect(data.offsets.popper);// compute center of the popper + var center=reference[side]+reference[len]/2-arrowElementSize/2;// Compute the sideValue using the updated popper offsets + // take popper margin in account because we don't have this info available + var css=getStyleComputedProperty(data.instance.popper);var popperMarginSide=parseFloat(css['margin'+sideCapitalized],10);var popperBorderSide=parseFloat(css['border'+sideCapitalized+'Width'],10);var sideValue=center-data.offsets.popper[side]-popperMarginSide-popperBorderSide;// prevent arrowElement from being placed not contiguously to its popper + sideValue=Math.max(Math.min(popper[len]-arrowElementSize,sideValue),0);data.arrowElement=arrowElement;data.offsets.arrow=(_data$offsets$arrow={},defineProperty(_data$offsets$arrow,side,Math.round(sideValue)),defineProperty(_data$offsets$arrow,altSide,''),_data$offsets$arrow);return data;}/** + * Get the opposite placement variation of the given one + * @method + * @memberof Popper.Utils + * @argument {String} placement variation + * @returns {String} flipped placement variation + */function getOppositeVariation(variation){if(variation==='end'){return 'start';}else if(variation==='start'){return 'end';}return variation;}/** + * List of accepted placements to use as values of the `placement` option.
+ * Valid placements are: + * - `auto` + * - `top` + * - `right` + * - `bottom` + * - `left` + * + * Each placement can have a variation from this list: + * - `-start` + * - `-end` + * + * Variations are interpreted easily if you think of them as the left to right + * written languages. Horizontally (`top` and `bottom`), `start` is left and `end` + * is right.
+ * Vertically (`left` and `right`), `start` is top and `end` is bottom. + * + * Some valid examples are: + * - `top-end` (on top of reference, right aligned) + * - `right-start` (on right of reference, top aligned) + * - `bottom` (on bottom, centered) + * - `auto-end` (on the side with more space available, alignment depends by placement) + * + * @static + * @type {Array} + * @enum {String} + * @readonly + * @method placements + * @memberof Popper + */var placements=['auto-start','auto','auto-end','top-start','top','top-end','right-start','right','right-end','bottom-end','bottom','bottom-start','left-end','left','left-start'];// Get rid of `auto` `auto-start` and `auto-end` + var validPlacements=placements.slice(3);/** + * Given an initial placement, returns all the subsequent placements + * clockwise (or counter-clockwise). + * + * @method + * @memberof Popper.Utils + * @argument {String} placement - A valid placement (it accepts variations) + * @argument {Boolean} counter - Set to true to walk the placements counterclockwise + * @returns {Array} placements including their variations + */function clockwise(placement){var counter=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var index=validPlacements.indexOf(placement);var arr=validPlacements.slice(index+1).concat(validPlacements.slice(0,index));return counter?arr.reverse():arr;}var BEHAVIORS={FLIP:'flip',CLOCKWISE:'clockwise',COUNTERCLOCKWISE:'counterclockwise'};/** + * @function + * @memberof Modifiers + * @argument {Object} data - The data object generated by update method + * @argument {Object} options - Modifiers configuration and options + * @returns {Object} The data object, properly modified + */function flip(data,options){// if `inner` modifier is enabled, we can't use the `flip` modifier + if(isModifierEnabled(data.instance.modifiers,'inner')){return data;}if(data.flipped&&data.placement===data.originalPlacement){// seems like flip is trying to loop, probably there's not enough space on any of the flippable sides + return data;}var boundaries=getBoundaries(data.instance.popper,data.instance.reference,options.padding,options.boundariesElement,data.positionFixed);var placement=data.placement.split('-')[0];var placementOpposite=getOppositePlacement(placement);var variation=data.placement.split('-')[1]||'';var flipOrder=[];switch(options.behavior){case BEHAVIORS.FLIP:flipOrder=[placement,placementOpposite];break;case BEHAVIORS.CLOCKWISE:flipOrder=clockwise(placement);break;case BEHAVIORS.COUNTERCLOCKWISE:flipOrder=clockwise(placement,true);break;default:flipOrder=options.behavior;}flipOrder.forEach(function(step,index){if(placement!==step||flipOrder.length===index+1){return data;}placement=data.placement.split('-')[0];placementOpposite=getOppositePlacement(placement);var popperOffsets=data.offsets.popper;var refOffsets=data.offsets.reference;// using floor because the reference offsets may contain decimals we are not going to consider here + var floor=Math.floor;var overlapsRef=placement==='left'&&floor(popperOffsets.right)>floor(refOffsets.left)||placement==='right'&&floor(popperOffsets.left)floor(refOffsets.top)||placement==='bottom'&&floor(popperOffsets.top)floor(boundaries.right);var overflowsTop=floor(popperOffsets.top)floor(boundaries.bottom);var overflowsBoundaries=placement==='left'&&overflowsLeft||placement==='right'&&overflowsRight||placement==='top'&&overflowsTop||placement==='bottom'&&overflowsBottom;// flip the variation if required + var isVertical=['top','bottom'].indexOf(placement)!==-1;// flips variation if reference element overflows boundaries + var flippedVariationByRef=!!options.flipVariations&&(isVertical&&variation==='start'&&overflowsLeft||isVertical&&variation==='end'&&overflowsRight||!isVertical&&variation==='start'&&overflowsTop||!isVertical&&variation==='end'&&overflowsBottom);// flips variation if popper content overflows boundaries + var flippedVariationByContent=!!options.flipVariationsByContent&&(isVertical&&variation==='start'&&overflowsRight||isVertical&&variation==='end'&&overflowsLeft||!isVertical&&variation==='start'&&overflowsBottom||!isVertical&&variation==='end'&&overflowsTop);var flippedVariation=flippedVariationByRef||flippedVariationByContent;if(overlapsRef||overflowsBoundaries||flippedVariation){// this boolean to detect any flip loop + data.flipped=true;if(overlapsRef||overflowsBoundaries){placement=flipOrder[index+1];}if(flippedVariation){variation=getOppositeVariation(variation);}data.placement=placement+(variation?'-'+variation:'');// this object contains `position`, we want to preserve it along with + // any additional property we may add in the future + data.offsets.popper=_extends({},data.offsets.popper,getPopperOffsets(data.instance.popper,data.offsets.reference,data.placement));data=runModifiers(data.instance.modifiers,data,'flip');}});return data;}/** + * @function + * @memberof Modifiers + * @argument {Object} data - The data object generated by update method + * @argument {Object} options - Modifiers configuration and options + * @returns {Object} The data object, properly modified + */function keepTogether(data){var _data$offsets=data.offsets,popper=_data$offsets.popper,reference=_data$offsets.reference;var placement=data.placement.split('-')[0];var floor=Math.floor;var isVertical=['top','bottom'].indexOf(placement)!==-1;var side=isVertical?'right':'bottom';var opSide=isVertical?'left':'top';var measurement=isVertical?'width':'height';if(popper[side]floor(reference[side])){data.offsets.popper[opSide]=floor(reference[side]);}return data;}/** + * Converts a string containing value + unit into a px value number + * @function + * @memberof {modifiers~offset} + * @private + * @argument {String} str - Value + unit string + * @argument {String} measurement - `height` or `width` + * @argument {Object} popperOffsets + * @argument {Object} referenceOffsets + * @returns {Number|String} + * Value in pixels, or original string if no values were extracted + */function toValue(str,measurement,popperOffsets,referenceOffsets){// separate value from unit + var split=str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/);var value=+split[1];var unit=split[2];// If it's not a number it's an operator, I guess + if(!value){return str;}if(unit.indexOf('%')===0){var element=void 0;switch(unit){case'%p':element=popperOffsets;break;case'%':case'%r':default:element=referenceOffsets;}var rect=getClientRect(element);return rect[measurement]/100*value;}else if(unit==='vh'||unit==='vw'){// if is a vh or vw, we calculate the size based on the viewport + var size=void 0;if(unit==='vh'){size=Math.max(document.documentElement.clientHeight,window.innerHeight||0);}else{size=Math.max(document.documentElement.clientWidth,window.innerWidth||0);}return size/100*value;}else{// if is an explicit pixel unit, we get rid of the unit and keep the value + // if is an implicit unit, it's px, and we return just the value + return value;}}/** + * Parse an `offset` string to extrapolate `x` and `y` numeric offsets. + * @function + * @memberof {modifiers~offset} + * @private + * @argument {String} offset + * @argument {Object} popperOffsets + * @argument {Object} referenceOffsets + * @argument {String} basePlacement + * @returns {Array} a two cells array with x and y offsets in numbers + */function parseOffset(offset,popperOffsets,referenceOffsets,basePlacement){var offsets=[0,0];// Use height if placement is left or right and index is 0 otherwise use width + // in this way the first offset will use an axis and the second one + // will use the other one + var useHeight=['right','left'].indexOf(basePlacement)!==-1;// Split the offset string to obtain a list of values and operands + // The regex addresses values with the plus or minus sign in front (+10, -20, etc) + var fragments=offset.split(/(\+|\-)/).map(function(frag){return frag.trim();});// Detect if the offset string contains a pair of values or a single one + // they could be separated by comma or space + var divider=fragments.indexOf(find(fragments,function(frag){return frag.search(/,|\s/)!==-1;}));if(fragments[divider]&&fragments[divider].indexOf(',')===-1){console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.');}// If divider is found, we divide the list of values and operands to divide + // them by ofset X and Y. + var splitRegex=/\s*,\s*|\s+/;var ops=divider!==-1?[fragments.slice(0,divider).concat([fragments[divider].split(splitRegex)[0]]),[fragments[divider].split(splitRegex)[1]].concat(fragments.slice(divider+1))]:[fragments];// Convert the values with units to absolute pixels to allow our computations + ops=ops.map(function(op,index){// Most of the units rely on the orientation of the popper + var measurement=(index===1?!useHeight:useHeight)?'height':'width';var mergeWithPrevious=false;return op// This aggregates any `+` or `-` sign that aren't considered operators + // e.g.: 10 + +5 => [10, +, +5] + .reduce(function(a,b){if(a[a.length-1]===''&&['+','-'].indexOf(b)!==-1){a[a.length-1]=b;mergeWithPrevious=true;return a;}else if(mergeWithPrevious){a[a.length-1]+=b;mergeWithPrevious=false;return a;}else{return a.concat(b);}},[])// Here we convert the string values into number values (in px) + .map(function(str){return toValue(str,measurement,popperOffsets,referenceOffsets);});});// Loop trough the offsets arrays and execute the operations + ops.forEach(function(op,index){op.forEach(function(frag,index2){if(isNumeric(frag)){offsets[index]+=frag*(op[index2-1]==='-'?-1:1);}});});return offsets;}/** + * @function + * @memberof Modifiers + * @argument {Object} data - The data object generated by update method + * @argument {Object} options - Modifiers configuration and options + * @argument {Number|String} options.offset=0 + * The offset value as described in the modifier description + * @returns {Object} The data object, properly modified + */function offset(data,_ref){var offset=_ref.offset;var placement=data.placement,_data$offsets=data.offsets,popper=_data$offsets.popper,reference=_data$offsets.reference;var basePlacement=placement.split('-')[0];var offsets=void 0;if(isNumeric(+offset)){offsets=[+offset,0];}else{offsets=parseOffset(offset,popper,reference,basePlacement);}if(basePlacement==='left'){popper.top+=offsets[0];popper.left-=offsets[1];}else if(basePlacement==='right'){popper.top+=offsets[0];popper.left+=offsets[1];}else if(basePlacement==='top'){popper.left+=offsets[0];popper.top-=offsets[1];}else if(basePlacement==='bottom'){popper.left+=offsets[0];popper.top+=offsets[1];}data.popper=popper;return data;}/** + * @function + * @memberof Modifiers + * @argument {Object} data - The data object generated by `update` method + * @argument {Object} options - Modifiers configuration and options + * @returns {Object} The data object, properly modified + */function preventOverflow(data,options){var boundariesElement=options.boundariesElement||getOffsetParent(data.instance.popper);// If offsetParent is the reference element, we really want to + // go one step up and use the next offsetParent as reference to + // avoid to make this modifier completely useless and look like broken + if(data.instance.reference===boundariesElement){boundariesElement=getOffsetParent(boundariesElement);}// NOTE: DOM access here + // resets the popper's position so that the document size can be calculated excluding + // the size of the popper element itself + var transformProp=getSupportedPropertyName('transform');var popperStyles=data.instance.popper.style;// assignment to help minification + var top=popperStyles.top,left=popperStyles.left,transform=popperStyles[transformProp];popperStyles.top='';popperStyles.left='';popperStyles[transformProp]='';var boundaries=getBoundaries(data.instance.popper,data.instance.reference,options.padding,boundariesElement,data.positionFixed);// NOTE: DOM access here + // restores the original style properties after the offsets have been computed + popperStyles.top=top;popperStyles.left=left;popperStyles[transformProp]=transform;options.boundaries=boundaries;var order=options.priority;var popper=data.offsets.popper;var check={primary:function primary(placement){var value=popper[placement];if(popper[placement]boundaries[placement]&&!options.escapeWithReference){value=Math.min(popper[mainSide],boundaries[placement]-(placement==='right'?popper.width:popper.height));}return defineProperty({},mainSide,value);}};order.forEach(function(placement){var side=['left','top'].indexOf(placement)!==-1?'primary':'secondary';popper=_extends({},popper,check[side](placement));});data.offsets.popper=popper;return data;}/** + * @function + * @memberof Modifiers + * @argument {Object} data - The data object generated by `update` method + * @argument {Object} options - Modifiers configuration and options + * @returns {Object} The data object, properly modified + */function shift(data){var placement=data.placement;var basePlacement=placement.split('-')[0];var shiftvariation=placement.split('-')[1];// if shift shiftvariation is specified, run the modifier + if(shiftvariation){var _data$offsets=data.offsets,reference=_data$offsets.reference,popper=_data$offsets.popper;var isVertical=['bottom','top'].indexOf(basePlacement)!==-1;var side=isVertical?'left':'top';var measurement=isVertical?'width':'height';var shiftOffsets={start:defineProperty({},side,reference[side]),end:defineProperty({},side,reference[side]+reference[measurement]-popper[measurement])};data.offsets.popper=_extends({},popper,shiftOffsets[shiftvariation]);}return data;}/** + * @function + * @memberof Modifiers + * @argument {Object} data - The data object generated by update method + * @argument {Object} options - Modifiers configuration and options + * @returns {Object} The data object, properly modified + */function hide(data){if(!isModifierRequired(data.instance.modifiers,'hide','preventOverflow')){return data;}var refRect=data.offsets.reference;var bound=find(data.instance.modifiers,function(modifier){return modifier.name==='preventOverflow';}).boundaries;if(refRect.bottombound.right||refRect.top>bound.bottom||refRect.right + * These functions will be called on each update, this means that you must + * make sure they are performant enough to avoid performance bottlenecks. + * + * @function ModifierFn + * @argument {dataObject} data - The data object generated by `update` method + * @argument {Object} options - Modifiers configuration and options + * @returns {dataObject} The data object, properly modified + */ /** + * Modifiers are plugins used to alter the behavior of your poppers.
+ * Popper.js uses a set of 9 modifiers to provide all the basic functionalities + * needed by the library. + * + * Usually you don't want to override the `order`, `fn` and `onLoad` props. + * All the other properties are configurations that could be tweaked. + * @namespace modifiers + */var modifiers={/** + * Modifier used to shift the popper on the start or end of its reference + * element.
+ * It will read the variation of the `placement` property.
+ * It can be one either `-end` or `-start`. + * @memberof modifiers + * @inner + */shift:{/** @prop {number} order=100 - Index used to define the order of execution */order:100,/** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */enabled:true,/** @prop {ModifierFn} */fn:shift},/** + * The `offset` modifier can shift your popper on both its axis. + * + * It accepts the following units: + * - `px` or unit-less, interpreted as pixels + * - `%` or `%r`, percentage relative to the length of the reference element + * - `%p`, percentage relative to the length of the popper element + * - `vw`, CSS viewport width unit + * - `vh`, CSS viewport height unit + * + * For length is intended the main axis relative to the placement of the popper.
+ * This means that if the placement is `top` or `bottom`, the length will be the + * `width`. In case of `left` or `right`, it will be the `height`. + * + * You can provide a single value (as `Number` or `String`), or a pair of values + * as `String` divided by a comma or one (or more) white spaces.
+ * The latter is a deprecated method because it leads to confusion and will be + * removed in v2.
+ * Additionally, it accepts additions and subtractions between different units. + * Note that multiplications and divisions aren't supported. + * + * Valid examples are: + * ``` + * 10 + * '10%' + * '10, 10' + * '10%, 10' + * '10 + 10%' + * '10 - 5vh + 3%' + * '-10px + 5vh, 5px - 6%' + * ``` + * > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap + * > with their reference element, unfortunately, you will have to disable the `flip` modifier. + * > You can read more on this at this [issue](https://github.com/FezVrasta/popper.js/issues/373). + * + * @memberof modifiers + * @inner + */offset:{/** @prop {number} order=200 - Index used to define the order of execution */order:200,/** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */enabled:true,/** @prop {ModifierFn} */fn:offset,/** @prop {Number|String} offset=0 + * The offset value as described in the modifier description + */offset:0},/** + * Modifier used to prevent the popper from being positioned outside the boundary. + * + * A scenario exists where the reference itself is not within the boundaries.
+ * We can say it has "escaped the boundaries" — or just "escaped".
+ * In this case we need to decide whether the popper should either: + * + * - detach from the reference and remain "trapped" in the boundaries, or + * - if it should ignore the boundary and "escape with its reference" + * + * When `escapeWithReference` is set to`true` and reference is completely + * outside its boundaries, the popper will overflow (or completely leave) + * the boundaries in order to remain attached to the edge of the reference. + * + * @memberof modifiers + * @inner + */preventOverflow:{/** @prop {number} order=300 - Index used to define the order of execution */order:300,/** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */enabled:true,/** @prop {ModifierFn} */fn:preventOverflow,/** + * @prop {Array} [priority=['left','right','top','bottom']] + * Popper will try to prevent overflow following these priorities by default, + * then, it could overflow on the left and on top of the `boundariesElement` + */priority:['left','right','top','bottom'],/** + * @prop {number} padding=5 + * Amount of pixel used to define a minimum distance between the boundaries + * and the popper. This makes sure the popper always has a little padding + * between the edges of its container + */padding:5,/** + * @prop {String|HTMLElement} boundariesElement='scrollParent' + * Boundaries used by the modifier. Can be `scrollParent`, `window`, + * `viewport` or any DOM element. + */boundariesElement:'scrollParent'},/** + * Modifier used to make sure the reference and its popper stay near each other + * without leaving any gap between the two. Especially useful when the arrow is + * enabled and you want to ensure that it points to its reference element. + * It cares only about the first axis. You can still have poppers with margin + * between the popper and its reference element. + * @memberof modifiers + * @inner + */keepTogether:{/** @prop {number} order=400 - Index used to define the order of execution */order:400,/** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */enabled:true,/** @prop {ModifierFn} */fn:keepTogether},/** + * This modifier is used to move the `arrowElement` of the popper to make + * sure it is positioned between the reference element and its popper element. + * It will read the outer size of the `arrowElement` node to detect how many + * pixels of conjunction are needed. + * + * It has no effect if no `arrowElement` is provided. + * @memberof modifiers + * @inner + */arrow:{/** @prop {number} order=500 - Index used to define the order of execution */order:500,/** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */enabled:true,/** @prop {ModifierFn} */fn:arrow,/** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */element:'[x-arrow]'},/** + * Modifier used to flip the popper's placement when it starts to overlap its + * reference element. + * + * Requires the `preventOverflow` modifier before it in order to work. + * + * **NOTE:** this modifier will interrupt the current update cycle and will + * restart it if it detects the need to flip the placement. + * @memberof modifiers + * @inner + */flip:{/** @prop {number} order=600 - Index used to define the order of execution */order:600,/** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */enabled:true,/** @prop {ModifierFn} */fn:flip,/** + * @prop {String|Array} behavior='flip' + * The behavior used to change the popper's placement. It can be one of + * `flip`, `clockwise`, `counterclockwise` or an array with a list of valid + * placements (with optional variations) + */behavior:'flip',/** + * @prop {number} padding=5 + * The popper will flip if it hits the edges of the `boundariesElement` + */padding:5,/** + * @prop {String|HTMLElement} boundariesElement='viewport' + * The element which will define the boundaries of the popper position. + * The popper will never be placed outside of the defined boundaries + * (except if `keepTogether` is enabled) + */boundariesElement:'viewport',/** + * @prop {Boolean} flipVariations=false + * The popper will switch placement variation between `-start` and `-end` when + * the reference element overlaps its boundaries. + * + * The original placement should have a set variation. + */flipVariations:false,/** + * @prop {Boolean} flipVariationsByContent=false + * The popper will switch placement variation between `-start` and `-end` when + * the popper element overlaps its reference boundaries. + * + * The original placement should have a set variation. + */flipVariationsByContent:false},/** + * Modifier used to make the popper flow toward the inner of the reference element. + * By default, when this modifier is disabled, the popper will be placed outside + * the reference element. + * @memberof modifiers + * @inner + */inner:{/** @prop {number} order=700 - Index used to define the order of execution */order:700,/** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */enabled:false,/** @prop {ModifierFn} */fn:inner},/** + * Modifier used to hide the popper when its reference element is outside of the + * popper boundaries. It will set a `x-out-of-boundaries` attribute which can + * be used to hide with a CSS selector the popper when its reference is + * out of boundaries. + * + * Requires the `preventOverflow` modifier before it in order to work. + * @memberof modifiers + * @inner + */hide:{/** @prop {number} order=800 - Index used to define the order of execution */order:800,/** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */enabled:true,/** @prop {ModifierFn} */fn:hide},/** + * Computes the style that will be applied to the popper element to gets + * properly positioned. + * + * Note that this modifier will not touch the DOM, it just prepares the styles + * so that `applyStyle` modifier can apply it. This separation is useful + * in case you need to replace `applyStyle` with a custom implementation. + * + * This modifier has `850` as `order` value to maintain backward compatibility + * with previous versions of Popper.js. Expect the modifiers ordering method + * to change in future major versions of the library. + * + * @memberof modifiers + * @inner + */computeStyle:{/** @prop {number} order=850 - Index used to define the order of execution */order:850,/** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */enabled:true,/** @prop {ModifierFn} */fn:computeStyle,/** + * @prop {Boolean} gpuAcceleration=true + * If true, it uses the CSS 3D transformation to position the popper. + * Otherwise, it will use the `top` and `left` properties + */gpuAcceleration:true,/** + * @prop {string} [x='bottom'] + * Where to anchor the X axis (`bottom` or `top`). AKA X offset origin. + * Change this if your popper should grow in a direction different from `bottom` + */x:'bottom',/** + * @prop {string} [x='left'] + * Where to anchor the Y axis (`left` or `right`). AKA Y offset origin. + * Change this if your popper should grow in a direction different from `right` + */y:'right'},/** + * Applies the computed styles to the popper element. + * + * All the DOM manipulations are limited to this modifier. This is useful in case + * you want to integrate Popper.js inside a framework or view library and you + * want to delegate all the DOM manipulations to it. + * + * Note that if you disable this modifier, you must make sure the popper element + * has its position set to `absolute` before Popper.js can do its work! + * + * Just disable this modifier and define your own to achieve the desired effect. + * + * @memberof modifiers + * @inner + */applyStyle:{/** @prop {number} order=900 - Index used to define the order of execution */order:900,/** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */enabled:true,/** @prop {ModifierFn} */fn:applyStyle,/** @prop {Function} */onLoad:applyStyleOnLoad,/** + * @deprecated since version 1.10.0, the property moved to `computeStyle` modifier + * @prop {Boolean} gpuAcceleration=true + * If true, it uses the CSS 3D transformation to position the popper. + * Otherwise, it will use the `top` and `left` properties + */gpuAcceleration:undefined}};/** + * The `dataObject` is an object containing all the information used by Popper.js. + * This object is passed to modifiers and to the `onCreate` and `onUpdate` callbacks. + * @name dataObject + * @property {Object} data.instance The Popper.js instance + * @property {String} data.placement Placement applied to popper + * @property {String} data.originalPlacement Placement originally defined on init + * @property {Boolean} data.flipped True if popper has been flipped by flip modifier + * @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper + * @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier + * @property {Object} data.styles Any CSS property defined here will be applied to the popper. It expects the JavaScript nomenclature (eg. `marginBottom`) + * @property {Object} data.arrowStyles Any CSS property defined here will be applied to the popper arrow. It expects the JavaScript nomenclature (eg. `marginBottom`) + * @property {Object} data.boundaries Offsets of the popper boundaries + * @property {Object} data.offsets The measurements of popper, reference and arrow elements + * @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values + * @property {Object} data.offsets.reference `top`, `left`, `width`, `height` values + * @property {Object} data.offsets.arrow] `top` and `left` offsets, only one of them will be different from 0 + */ /** + * Default options provided to Popper.js constructor.
+ * These can be overridden using the `options` argument of Popper.js.
+ * To override an option, simply pass an object with the same + * structure of the `options` object, as the 3rd argument. For example: + * ``` + * new Popper(ref, pop, { + * modifiers: { + * preventOverflow: { enabled: false } + * } + * }) + * ``` + * @type {Object} + * @static + * @memberof Popper + */var Defaults={/** + * Popper's placement. + * @prop {Popper.placements} placement='bottom' + */placement:'bottom',/** + * Set this to true if you want popper to position it self in 'fixed' mode + * @prop {Boolean} positionFixed=false + */positionFixed:false,/** + * Whether events (resize, scroll) are initially enabled. + * @prop {Boolean} eventsEnabled=true + */eventsEnabled:true,/** + * Set to true if you want to automatically remove the popper when + * you call the `destroy` method. + * @prop {Boolean} removeOnDestroy=false + */removeOnDestroy:false,/** + * Callback called when the popper is created.
+ * By default, it is set to no-op.
+ * Access Popper.js instance with `data.instance`. + * @prop {onCreate} + */onCreate:function onCreate(){},/** + * Callback called when the popper is updated. This callback is not called + * on the initialization/creation of the popper, but only on subsequent + * updates.
+ * By default, it is set to no-op.
+ * Access Popper.js instance with `data.instance`. + * @prop {onUpdate} + */onUpdate:function onUpdate(){},/** + * List of modifiers used to modify the offsets before they are applied to the popper. + * They provide most of the functionalities of Popper.js. + * @prop {modifiers} + */modifiers:modifiers};/** + * @callback onCreate + * @param {dataObject} data + */ /** + * @callback onUpdate + * @param {dataObject} data + */ // Utils + // Methods + var Popper=function(){/** + * Creates a new Popper.js instance. + * @class Popper + * @param {Element|referenceObject} reference - The reference element used to position the popper + * @param {Element} popper - The HTML / XML element used as the popper + * @param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults) + * @return {Object} instance - The generated Popper.js instance + */function Popper(reference,popper){var _this=this;var options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};classCallCheck(this,Popper);this.scheduleUpdate=function(){return requestAnimationFrame(_this.update);};// make update() debounced, so that it only runs at most once-per-tick + this.update=debounce(this.update.bind(this));// with {} we create a new object with the options inside it + this.options=_extends({},Popper.Defaults,options);// init state + this.state={isDestroyed:false,isCreated:false,scrollParents:[]};// get reference and popper elements (allow jQuery wrappers) + this.reference=reference&&reference.jquery?reference[0]:reference;this.popper=popper&&popper.jquery?popper[0]:popper;// Deep merge modifiers options + this.options.modifiers={};Object.keys(_extends({},Popper.Defaults.modifiers,options.modifiers)).forEach(function(name){_this.options.modifiers[name]=_extends({},Popper.Defaults.modifiers[name]||{},options.modifiers?options.modifiers[name]:{});});// Refactoring modifiers' list (Object => Array) + this.modifiers=Object.keys(this.options.modifiers).map(function(name){return _extends({name:name},_this.options.modifiers[name]);})// sort the modifiers by order + .sort(function(a,b){return a.order-b.order;});// modifiers have the ability to execute arbitrary code when Popper.js get inited + // such code is executed in the same order of its modifier + // they could add new properties to their options configuration + // BE AWARE: don't add options to `options.modifiers.name` but to `modifierOptions`! + this.modifiers.forEach(function(modifierOptions){if(modifierOptions.enabled&&isFunction(modifierOptions.onLoad)){modifierOptions.onLoad(_this.reference,_this.popper,_this.options,modifierOptions,_this.state);}});// fire the first update to position the popper in the right place + this.update();var eventsEnabled=this.options.eventsEnabled;if(eventsEnabled){// setup event listeners, they will take care of update the position in specific situations + this.enableEventListeners();}this.state.eventsEnabled=eventsEnabled;}// We can't use class properties because they don't get listed in the + // class prototype and break stuff like Sinon stubs + createClass(Popper,[{key:'update',value:function update$$1(){return update.call(this);}},{key:'destroy',value:function destroy$$1(){return destroy.call(this);}},{key:'enableEventListeners',value:function enableEventListeners$$1(){return enableEventListeners.call(this);}},{key:'disableEventListeners',value:function disableEventListeners$$1(){return disableEventListeners.call(this);}/** + * Schedules an update. It will run on the next UI update available. + * @method scheduleUpdate + * @memberof Popper + */ /** + * Collection of utilities useful when writing custom modifiers. + * Starting from version 1.7, this method is available only if you + * include `popper-utils.js` before `popper.js`. + * + * **DEPRECATION**: This way to access PopperUtils is deprecated + * and will be removed in v2! Use the PopperUtils module directly instead. + * Due to the high instability of the methods contained in Utils, we can't + * guarantee them to follow semver. Use them at your own risk! + * @static + * @private + * @type {Object} + * @deprecated since version 1.8 + * @member Utils + * @memberof Popper + */}]);return Popper;}();/** + * The `referenceObject` is an object that provides an interface compatible with Popper.js + * and lets you use it as replacement of a real DOM node.
+ * You can use this method to position a popper relatively to a set of coordinates + * in case you don't have a DOM node to use as reference. + * + * ``` + * new Popper(referenceObject, popperNode); + * ``` + * + * NB: This feature isn't supported in Internet Explorer 10. + * @name referenceObject + * @property {Function} data.getBoundingClientRect + * A function that returns a set of coordinates compatible with the native `getBoundingClientRect` method. + * @property {number} data.clientWidth + * An ES6 getter that will return the width of the virtual reference element. + * @property {number} data.clientHeight + * An ES6 getter that will return the height of the virtual reference element. + */Popper.Utils=(typeof window!=='undefined'?window:global).PopperUtils;Popper.placements=placements;Popper.Defaults=Defaults; + + var categories=["animals","smileys","skinTones","travel","flags","objects","activities","symbols","food"];var emojiData = [{"n":["monkey_face"],"e":"🐵","c":0},{"n":["grinning"],"e":"😀","c":1},{"n":["skin-tone-2"],"e":"🏻","c":2},{"n":["earth_africa"],"e":"🌍","c":3},{"n":["checkered_flag"],"e":"🏁","c":4},{"n":["mute"],"e":"🔇","c":5},{"n":["jack_o_lantern"],"e":"🎃","c":6},{"n":["atm"],"e":"🏧","c":7},{"n":["grapes"],"e":"🍇","c":8},{"n":["earth_americas"],"e":"🌎","c":3},{"n":["grin"],"e":"😁","c":1},{"n":["melon"],"e":"🍈","c":8},{"n":["triangular_flag_on_post"],"e":"🚩","c":4},{"n":["monkey"],"e":"🐒","c":0},{"n":["christmas_tree"],"e":"🎄","c":6},{"n":["skin-tone-3"],"e":"🏼","c":2},{"n":["put_litter_in_its_place"],"e":"🚮","c":7},{"n":["speaker"],"e":"🔈","c":5},{"n":["earth_asia"],"e":"🌏","c":3},{"n":["crossed_flags"],"e":"🎌","c":4},{"n":["joy"],"e":"😂","c":1},{"n":["sound"],"e":"🔉","c":5},{"n":["watermelon"],"e":"🍉","c":8},{"n":["gorilla"],"e":"🦍","c":0},{"n":["fireworks"],"e":"🎆","c":6},{"n":["potable_water"],"e":"🚰","c":7},{"n":["skin-tone-4"],"e":"🏽","c":2},{"n":["wheelchair"],"e":"♿","c":7},{"n":["rolling_on_the_floor_laughing"],"e":"🤣","c":1},{"n":["loud_sound"],"e":"🔊","c":5},{"n":["waving_black_flag"],"e":"🏴","c":4},{"n":["tangerine"],"e":"🍊","c":8},{"n":["dog"],"e":"🐶","c":0},{"n":["sparkler"],"e":"🎇","c":6},{"n":["skin-tone-5"],"e":"🏾","c":2},{"n":["globe_with_meridians"],"e":"🌐","c":3},{"n":["skin-tone-6"],"e":"🏿","c":2},{"n":["smiley"],"e":"😃","c":1},{"n":["loudspeaker"],"e":"📢","c":5},{"n":["sparkles"],"e":"✨","c":6},{"n":["dog2"],"e":"🐕","c":0},{"n":["waving_white_flag"],"e":"🏳️","c":4},{"n":["world_map"],"e":"🗺️","c":3},{"n":["lemon"],"e":"🍋","c":8},{"n":["mens"],"e":"🚹","c":7},{"n":["womens"],"e":"🚺","c":7},{"n":["rainbow-flag"],"e":"🏳️‍🌈","c":4},{"n":["smile"],"e":"😄","c":1},{"n":["banana"],"e":"🍌","c":8},{"n":["mega"],"e":"📣","c":5},{"n":["japan"],"e":"🗾","c":3},{"n":["poodle"],"e":"🐩","c":0},{"n":["balloon"],"e":"🎈","c":6},{"n":["flag-ac"],"e":"🇦🇨","c":4},{"n":["sweat_smile"],"e":"😅","c":1},{"n":["pineapple"],"e":"🍍","c":8},{"n":["restroom"],"e":"🚻","c":7},{"n":["postal_horn"],"e":"📯","c":5},{"n":["wolf"],"e":"🐺","c":0},{"n":["tada"],"e":"🎉","c":6},{"n":["snow_capped_mountain"],"e":"🏔️","c":3},{"n":["laughing","satisfied"],"e":"😆","c":1},{"n":["apple"],"e":"🍎","c":8},{"n":["flag-ad"],"e":"🇦🇩","c":4},{"n":["fox_face"],"e":"🦊","c":0},{"n":["confetti_ball"],"e":"🎊","c":6},{"n":["bell"],"e":"🔔","c":5},{"n":["mountain"],"e":"⛰️","c":3},{"n":["baby_symbol"],"e":"🚼","c":7},{"n":["wc"],"e":"🚾","c":7},{"n":["wink"],"e":"😉","c":1},{"n":["no_bell"],"e":"🔕","c":5},{"n":["green_apple"],"e":"🍏","c":8},{"n":["tanabata_tree"],"e":"🎋","c":6},{"n":["flag-ae"],"e":"🇦🇪","c":4},{"n":["volcano"],"e":"🌋","c":3},{"n":["cat"],"e":"🐱","c":0},{"n":["flag-af"],"e":"🇦🇫","c":4},{"n":["musical_score"],"e":"🎼","c":5},{"n":["blush"],"e":"😊","c":1},{"n":["pear"],"e":"🍐","c":8},{"n":["bamboo"],"e":"🎍","c":6},{"n":["passport_control"],"e":"🛂","c":7},{"n":["mount_fuji"],"e":"🗻","c":3},{"n":["cat2"],"e":"🐈","c":0},{"n":["musical_note"],"e":"🎵","c":5},{"n":["dolls"],"e":"🎎","c":6},{"n":["lion_face"],"e":"🦁","c":0},{"n":["camping"],"e":"🏕️","c":3},{"n":["flag-ag"],"e":"🇦🇬","c":4},{"n":["customs"],"e":"🛃","c":7},{"n":["yum"],"e":"😋","c":1},{"n":["peach"],"e":"🍑","c":8},{"n":["tiger"],"e":"🐯","c":0},{"n":["notes"],"e":"🎶","c":5},{"n":["flags"],"e":"🎏","c":6},{"n":["beach_with_umbrella"],"e":"🏖️","c":3},{"n":["cherries"],"e":"🍒","c":8},{"n":["flag-ai"],"e":"🇦🇮","c":4},{"n":["baggage_claim"],"e":"🛄","c":7},{"n":["sunglasses"],"e":"😎","c":1},{"n":["left_luggage"],"e":"🛅","c":7},{"n":["wind_chime"],"e":"🎐","c":6},{"n":["strawberry"],"e":"🍓","c":8},{"n":["desert"],"e":"🏜️","c":3},{"n":["studio_microphone"],"e":"🎙️","c":5},{"n":["flag-al"],"e":"🇦🇱","c":4},{"n":["tiger2"],"e":"🐅","c":0},{"n":["heart_eyes"],"e":"😍","c":1},{"n":["desert_island"],"e":"🏝️","c":3},{"n":["kiwifruit"],"e":"🥝","c":8},{"n":["rice_scene"],"e":"🎑","c":6},{"n":["kissing_heart"],"e":"😘","c":1},{"n":["warning"],"e":"⚠️","c":7},{"n":["flag-am"],"e":"🇦🇲","c":4},{"n":["leopard"],"e":"🐆","c":0},{"n":["level_slider"],"e":"🎚️","c":5},{"n":["horse"],"e":"🐴","c":0},{"n":["children_crossing"],"e":"🚸","c":7},{"n":["ribbon"],"e":"🎀","c":6},{"n":["national_park"],"e":"🏞️","c":3},{"n":["control_knobs"],"e":"🎛️","c":5},{"n":["kissing"],"e":"😗","c":1},{"n":["tomato"],"e":"🍅","c":8},{"n":["flag-ao"],"e":"🇦🇴","c":4},{"n":["stadium"],"e":"🏟️","c":3},{"n":["flag-aq"],"e":"🇦🇶","c":4},{"n":["gift"],"e":"🎁","c":6},{"n":["no_entry"],"e":"⛔","c":7},{"n":["kissing_smiling_eyes"],"e":"😙","c":1},{"n":["coconut"],"e":"🥥","c":8},{"n":["racehorse"],"e":"🐎","c":0},{"n":["microphone"],"e":"🎤","c":5},{"n":["classical_building"],"e":"🏛️","c":3},{"n":["no_entry_sign"],"e":"🚫","c":7},{"n":["reminder_ribbon"],"e":"🎗️","c":6},{"n":["kissing_closed_eyes"],"e":"😚","c":1},{"n":["unicorn_face"],"e":"🦄","c":0},{"n":["flag-ar"],"e":"🇦🇷","c":4},{"n":["headphones"],"e":"🎧","c":5},{"n":["avocado"],"e":"🥑","c":8},{"n":["relaxed"],"e":"☺️","c":1},{"n":["zebra_face"],"e":"🦓","c":0},{"n":["eggplant"],"e":"🍆","c":8},{"n":["radio"],"e":"📻","c":5},{"n":["building_construction"],"e":"🏗️","c":3},{"n":["flag-as"],"e":"🇦🇸","c":4},{"n":["admission_tickets"],"e":"🎟️","c":6},{"n":["no_bicycles"],"e":"🚳","c":7},{"n":["no_smoking"],"e":"🚭","c":7},{"n":["slightly_smiling_face"],"e":"🙂","c":1},{"n":["flag-at"],"e":"🇦🇹","c":4},{"n":["ticket"],"e":"🎫","c":6},{"n":["saxophone"],"e":"🎷","c":5},{"n":["deer"],"e":"🦌","c":0},{"n":["house_buildings"],"e":"🏘️","c":3},{"n":["potato"],"e":"🥔","c":8},{"n":["guitar"],"e":"🎸","c":5},{"n":["carrot"],"e":"🥕","c":8},{"n":["cityscape"],"e":"🏙️","c":3},{"n":["flag-au"],"e":"🇦🇺","c":4},{"n":["do_not_litter"],"e":"🚯","c":7},{"n":["hugging_face"],"e":"🤗","c":1},{"n":["cow"],"e":"🐮","c":0},{"n":["medal"],"e":"🎖️","c":6},{"n":["musical_keyboard"],"e":"🎹","c":5},{"n":["corn"],"e":"🌽","c":8},{"n":["derelict_house_building"],"e":"🏚️","c":3},{"n":["non-potable_water"],"e":"🚱","c":7},{"n":["trophy"],"e":"🏆","c":6},{"n":["flag-aw"],"e":"🇦🇼","c":4},{"n":["star-struck","grinning_face_with_star_eyes"],"e":"🤩","c":1},{"n":["ox"],"e":"🐂","c":0},{"n":["trumpet"],"e":"🎺","c":5},{"n":["hot_pepper"],"e":"🌶️","c":8},{"n":["sports_medal"],"e":"🏅","c":6},{"n":["flag-ax"],"e":"🇦🇽","c":4},{"n":["water_buffalo"],"e":"🐃","c":0},{"n":["no_pedestrians"],"e":"🚷","c":7},{"n":["thinking_face"],"e":"🤔","c":1},{"n":["house"],"e":"🏠","c":3},{"n":["no_mobile_phones"],"e":"📵","c":7},{"n":["flag-az"],"e":"🇦🇿","c":4},{"n":["first_place_medal"],"e":"🥇","c":6},{"n":["house_with_garden"],"e":"🏡","c":3},{"n":["violin"],"e":"🎻","c":5},{"n":["face_with_raised_eyebrow","face_with_one_eyebrow_raised"],"e":"🤨","c":1},{"n":["cucumber"],"e":"🥒","c":8},{"n":["cow2"],"e":"🐄","c":0},{"n":["flag-ba"],"e":"🇧🇦","c":4},{"n":["pig"],"e":"🐷","c":0},{"n":["drum_with_drumsticks"],"e":"🥁","c":5},{"n":["underage"],"e":"🔞","c":7},{"n":["broccoli"],"e":"🥦","c":8},{"n":["office"],"e":"🏢","c":3},{"n":["second_place_medal"],"e":"🥈","c":6},{"n":["neutral_face"],"e":"😐","c":1},{"n":["third_place_medal"],"e":"🥉","c":6},{"n":["mushroom"],"e":"🍄","c":8},{"n":["flag-bb"],"e":"🇧🇧","c":4},{"n":["radioactive_sign"],"e":"☢️","c":7},{"n":["pig2"],"e":"🐖","c":0},{"n":["expressionless"],"e":"😑","c":1},{"n":["iphone"],"e":"📱","c":5},{"n":["post_office"],"e":"🏣","c":3},{"n":["european_post_office"],"e":"🏤","c":3},{"n":["soccer"],"e":"⚽","c":6},{"n":["boar"],"e":"🐗","c":0},{"n":["peanuts"],"e":"🥜","c":8},{"n":["calling"],"e":"📲","c":5},{"n":["biohazard_sign"],"e":"☣️","c":7},{"n":["flag-bd"],"e":"🇧🇩","c":4},{"n":["no_mouth"],"e":"😶","c":1},{"n":["face_with_rolling_eyes"],"e":"🙄","c":1},{"n":["phone","telephone"],"e":"☎️","c":5},{"n":["pig_nose"],"e":"🐽","c":0},{"n":["chestnut"],"e":"🌰","c":8},{"n":["arrow_up"],"e":"⬆️","c":7},{"n":["hospital"],"e":"🏥","c":3},{"n":["flag-be"],"e":"🇧🇪","c":4},{"n":["baseball"],"e":"⚾","c":6},{"n":["smirk"],"e":"😏","c":1},{"n":["arrow_upper_right"],"e":"↗️","c":7},{"n":["flag-bf"],"e":"🇧🇫","c":4},{"n":["basketball"],"e":"🏀","c":6},{"n":["ram"],"e":"🐏","c":0},{"n":["bank"],"e":"🏦","c":3},{"n":["bread"],"e":"🍞","c":8},{"n":["telephone_receiver"],"e":"📞","c":5},{"n":["croissant"],"e":"🥐","c":8},{"n":["pager"],"e":"📟","c":5},{"n":["sheep"],"e":"🐑","c":0},{"n":["arrow_right"],"e":"➡️","c":7},{"n":["persevere"],"e":"😣","c":1},{"n":["flag-bg"],"e":"🇧🇬","c":4},{"n":["volleyball"],"e":"🏐","c":6},{"n":["hotel"],"e":"🏨","c":3},{"n":["arrow_lower_right"],"e":"↘️","c":7},{"n":["goat"],"e":"🐐","c":0},{"n":["flag-bh"],"e":"🇧🇭","c":4},{"n":["love_hotel"],"e":"🏩","c":3},{"n":["disappointed_relieved"],"e":"😥","c":1},{"n":["baguette_bread"],"e":"🥖","c":8},{"n":["football"],"e":"🏈","c":6},{"n":["fax"],"e":"📠","c":5},{"n":["convenience_store"],"e":"🏪","c":3},{"n":["dromedary_camel"],"e":"🐪","c":0},{"n":["arrow_down"],"e":"⬇️","c":7},{"n":["battery"],"e":"🔋","c":5},{"n":["rugby_football"],"e":"🏉","c":6},{"n":["pretzel"],"e":"🥨","c":8},{"n":["open_mouth"],"e":"😮","c":1},{"n":["flag-bi"],"e":"🇧🇮","c":4},{"n":["flag-bj"],"e":"🇧🇯","c":4},{"n":["pancakes"],"e":"🥞","c":8},{"n":["school"],"e":"🏫","c":3},{"n":["tennis"],"e":"🎾","c":6},{"n":["zipper_mouth_face"],"e":"🤐","c":1},{"n":["camel"],"e":"🐫","c":0},{"n":["arrow_lower_left"],"e":"↙️","c":7},{"n":["electric_plug"],"e":"🔌","c":5},{"n":["cheese_wedge"],"e":"🧀","c":8},{"n":["hushed"],"e":"😯","c":1},{"n":["computer"],"e":"💻","c":5},{"n":["giraffe_face"],"e":"🦒","c":0},{"n":["8ball"],"e":"🎱","c":6},{"n":["flag-bl"],"e":"🇧🇱","c":4},{"n":["arrow_left"],"e":"⬅️","c":7},{"n":["department_store"],"e":"🏬","c":3},{"n":["meat_on_bone"],"e":"🍖","c":8},{"n":["arrow_upper_left"],"e":"↖️","c":7},{"n":["flag-bm"],"e":"🇧🇲","c":4},{"n":["sleepy"],"e":"😪","c":1},{"n":["bowling"],"e":"🎳","c":6},{"n":["factory"],"e":"🏭","c":3},{"n":["desktop_computer"],"e":"🖥️","c":5},{"n":["elephant"],"e":"🐘","c":0},{"n":["rhinoceros"],"e":"🦏","c":0},{"n":["arrow_up_down"],"e":"↕️","c":7},{"n":["cricket_bat_and_ball"],"e":"🏏","c":6},{"n":["printer"],"e":"🖨️","c":5},{"n":["poultry_leg"],"e":"🍗","c":8},{"n":["tired_face"],"e":"😫","c":1},{"n":["japanese_castle"],"e":"🏯","c":3},{"n":["flag-bn"],"e":"🇧🇳","c":4},{"n":["field_hockey_stick_and_ball"],"e":"🏑","c":6},{"n":["sleeping"],"e":"😴","c":1},{"n":["left_right_arrow"],"e":"↔️","c":7},{"n":["keyboard"],"e":"⌨️","c":5},{"n":["european_castle"],"e":"🏰","c":3},{"n":["mouse"],"e":"🐭","c":0},{"n":["flag-bo"],"e":"🇧🇴","c":4},{"n":["cut_of_meat"],"e":"🥩","c":8},{"n":["ice_hockey_stick_and_puck"],"e":"🏒","c":6},{"n":["mouse2"],"e":"🐁","c":0},{"n":["three_button_mouse"],"e":"🖱️","c":5},{"n":["leftwards_arrow_with_hook"],"e":"↩️","c":7},{"n":["bacon"],"e":"🥓","c":8},{"n":["relieved"],"e":"😌","c":1},{"n":["flag-bq"],"e":"🇧🇶","c":4},{"n":["wedding"],"e":"💒","c":3},{"n":["tokyo_tower"],"e":"🗼","c":3},{"n":["arrow_right_hook"],"e":"↪️","c":7},{"n":["hamburger"],"e":"🍔","c":8},{"n":["stuck_out_tongue"],"e":"😛","c":1},{"n":["trackball"],"e":"🖲️","c":5},{"n":["flag-br"],"e":"🇧🇷","c":4},{"n":["rat"],"e":"🐀","c":0},{"n":["table_tennis_paddle_and_ball"],"e":"🏓","c":6},{"n":["minidisc"],"e":"💽","c":5},{"n":["stuck_out_tongue_winking_eye"],"e":"😜","c":1},{"n":["fries"],"e":"🍟","c":8},{"n":["badminton_racquet_and_shuttlecock"],"e":"🏸","c":6},{"n":["statue_of_liberty"],"e":"🗽","c":3},{"n":["flag-bs"],"e":"🇧🇸","c":4},{"n":["arrow_heading_up"],"e":"⤴️","c":7},{"n":["hamster"],"e":"🐹","c":0},{"n":["stuck_out_tongue_closed_eyes"],"e":"😝","c":1},{"n":["pizza"],"e":"🍕","c":8},{"n":["boxing_glove"],"e":"🥊","c":6},{"n":["floppy_disk"],"e":"💾","c":5},{"n":["arrow_heading_down"],"e":"⤵️","c":7},{"n":["flag-bt"],"e":"🇧🇹","c":4},{"n":["rabbit"],"e":"🐰","c":0},{"n":["church"],"e":"⛪","c":3},{"n":["drooling_face"],"e":"🤤","c":1},{"n":["flag-bv"],"e":"🇧🇻","c":4},{"n":["mosque"],"e":"🕌","c":3},{"n":["rabbit2"],"e":"🐇","c":0},{"n":["hotdog"],"e":"🌭","c":8},{"n":["martial_arts_uniform"],"e":"🥋","c":6},{"n":["arrows_clockwise"],"e":"🔃","c":7},{"n":["cd"],"e":"💿","c":5},{"n":["arrows_counterclockwise"],"e":"🔄","c":7},{"n":["sandwich"],"e":"🥪","c":8},{"n":["chipmunk"],"e":"🐿️","c":0},{"n":["synagogue"],"e":"🕍","c":3},{"n":["unamused"],"e":"😒","c":1},{"n":["goal_net"],"e":"🥅","c":6},{"n":["flag-bw"],"e":"🇧🇼","c":4},{"n":["dvd"],"e":"📀","c":5},{"n":["hedgehog"],"e":"🦔","c":0},{"n":["dart"],"e":"🎯","c":6},{"n":["taco"],"e":"🌮","c":8},{"n":["back"],"e":"🔙","c":7},{"n":["flag-by"],"e":"🇧🇾","c":4},{"n":["shinto_shrine"],"e":"⛩️","c":3},{"n":["movie_camera"],"e":"🎥","c":5},{"n":["sweat"],"e":"😓","c":1},{"n":["burrito"],"e":"🌯","c":8},{"n":["flag-bz"],"e":"🇧🇿","c":4},{"n":["pensive"],"e":"😔","c":1},{"n":["kaaba"],"e":"🕋","c":3},{"n":["film_frames"],"e":"🎞️","c":5},{"n":["bat"],"e":"🦇","c":0},{"n":["golf"],"e":"⛳","c":6},{"n":["end"],"e":"🔚","c":7},{"n":["film_projector"],"e":"📽️","c":5},{"n":["bear"],"e":"🐻","c":0},{"n":["ice_skate"],"e":"⛸️","c":6},{"n":["fountain"],"e":"⛲","c":3},{"n":["confused"],"e":"😕","c":1},{"n":["flag-ca"],"e":"🇨🇦","c":4},{"n":["on"],"e":"🔛","c":7},{"n":["stuffed_flatbread"],"e":"🥙","c":8},{"n":["soon"],"e":"🔜","c":7},{"n":["upside_down_face"],"e":"🙃","c":1},{"n":["fishing_pole_and_fish"],"e":"🎣","c":6},{"n":["tent"],"e":"⛺","c":3},{"n":["clapper"],"e":"🎬","c":5},{"n":["egg"],"e":"🥚","c":8},{"n":["flag-cc"],"e":"🇨🇨","c":4},{"n":["koala"],"e":"🐨","c":0},{"n":["foggy"],"e":"🌁","c":3},{"n":["tv"],"e":"📺","c":5},{"n":["panda_face"],"e":"🐼","c":0},{"n":["fried_egg","cooking"],"e":"🍳","c":8},{"n":["top"],"e":"🔝","c":7},{"n":["flag-cd"],"e":"🇨🇩","c":4},{"n":["money_mouth_face"],"e":"🤑","c":1},{"n":["running_shirt_with_sash"],"e":"🎽","c":6},{"n":["astonished"],"e":"😲","c":1},{"n":["feet","paw_prints"],"e":"🐾","c":0},{"n":["camera"],"e":"📷","c":5},{"n":["flag-cf"],"e":"🇨🇫","c":4},{"n":["place_of_worship"],"e":"🛐","c":7},{"n":["night_with_stars"],"e":"🌃","c":3},{"n":["ski"],"e":"🎿","c":6},{"n":["shallow_pan_of_food"],"e":"🥘","c":8},{"n":["camera_with_flash"],"e":"📸","c":5},{"n":["sunrise_over_mountains"],"e":"🌄","c":3},{"n":["turkey"],"e":"🦃","c":0},{"n":["white_frowning_face"],"e":"☹️","c":1},{"n":["flag-cg"],"e":"🇨🇬","c":4},{"n":["stew"],"e":"🍲","c":8},{"n":["sled"],"e":"🛷","c":6},{"n":["atom_symbol"],"e":"⚛️","c":7},{"n":["curling_stone"],"e":"🥌","c":6},{"n":["slightly_frowning_face"],"e":"🙁","c":1},{"n":["sunrise"],"e":"🌅","c":3},{"n":["om_symbol"],"e":"🕉️","c":7},{"n":["chicken"],"e":"🐔","c":0},{"n":["bowl_with_spoon"],"e":"🥣","c":8},{"n":["flag-ch"],"e":"🇨🇭","c":4},{"n":["video_camera"],"e":"📹","c":5},{"n":["video_game"],"e":"🎮","c":6},{"n":["rooster"],"e":"🐓","c":0},{"n":["vhs"],"e":"📼","c":5},{"n":["city_sunset"],"e":"🌆","c":3},{"n":["confounded"],"e":"😖","c":1},{"n":["green_salad"],"e":"🥗","c":8},{"n":["star_of_david"],"e":"✡️","c":7},{"n":["flag-ci"],"e":"🇨🇮","c":4},{"n":["popcorn"],"e":"🍿","c":8},{"n":["city_sunrise"],"e":"🌇","c":3},{"n":["disappointed"],"e":"😞","c":1},{"n":["mag"],"e":"🔍","c":5},{"n":["hatching_chick"],"e":"🐣","c":0},{"n":["joystick"],"e":"🕹️","c":6},{"n":["wheel_of_dharma"],"e":"☸️","c":7},{"n":["flag-ck"],"e":"🇨🇰","c":4},{"n":["canned_food"],"e":"🥫","c":8},{"n":["worried"],"e":"😟","c":1},{"n":["baby_chick"],"e":"🐤","c":0},{"n":["flag-cl"],"e":"🇨🇱","c":4},{"n":["game_die"],"e":"🎲","c":6},{"n":["mag_right"],"e":"🔎","c":5},{"n":["yin_yang"],"e":"☯️","c":7},{"n":["bridge_at_night"],"e":"🌉","c":3},{"n":["spades"],"e":"♠️","c":6},{"n":["hatched_chick"],"e":"🐥","c":0},{"n":["flag-cm"],"e":"🇨🇲","c":4},{"n":["latin_cross"],"e":"✝️","c":7},{"n":["triumph"],"e":"😤","c":1},{"n":["hotsprings"],"e":"♨️","c":3},{"n":["bento"],"e":"🍱","c":8},{"n":["microscope"],"e":"🔬","c":5},{"n":["cry"],"e":"😢","c":1},{"n":["bird"],"e":"🐦","c":0},{"n":["cn","flag-cn"],"e":"🇨🇳","c":4},{"n":["telescope"],"e":"🔭","c":5},{"n":["rice_cracker"],"e":"🍘","c":8},{"n":["hearts"],"e":"♥️","c":6},{"n":["orthodox_cross"],"e":"☦️","c":7},{"n":["milky_way"],"e":"🌌","c":3},{"n":["rice_ball"],"e":"🍙","c":8},{"n":["satellite_antenna"],"e":"📡","c":5},{"n":["flag-co"],"e":"🇨🇴","c":4},{"n":["carousel_horse"],"e":"🎠","c":3},{"n":["sob"],"e":"😭","c":1},{"n":["diamonds"],"e":"♦️","c":6},{"n":["star_and_crescent"],"e":"☪️","c":7},{"n":["penguin"],"e":"🐧","c":0},{"n":["dove_of_peace"],"e":"🕊️","c":0},{"n":["flag-cp"],"e":"🇨🇵","c":4},{"n":["ferris_wheel"],"e":"🎡","c":3},{"n":["clubs"],"e":"♣️","c":6},{"n":["peace_symbol"],"e":"☮️","c":7},{"n":["candle"],"e":"🕯️","c":5},{"n":["frowning"],"e":"😦","c":1},{"n":["rice"],"e":"🍚","c":8},{"n":["flag-cr"],"e":"🇨🇷","c":4},{"n":["roller_coaster"],"e":"🎢","c":3},{"n":["menorah_with_nine_branches"],"e":"🕎","c":7},{"n":["black_joker"],"e":"🃏","c":6},{"n":["eagle"],"e":"🦅","c":0},{"n":["curry"],"e":"🍛","c":8},{"n":["bulb"],"e":"💡","c":5},{"n":["anguished"],"e":"😧","c":1},{"n":["flag-cu"],"e":"🇨🇺","c":4},{"n":["barber"],"e":"💈","c":3},{"n":["duck"],"e":"🦆","c":0},{"n":["six_pointed_star"],"e":"🔯","c":7},{"n":["ramen"],"e":"🍜","c":8},{"n":["flashlight"],"e":"🔦","c":5},{"n":["mahjong"],"e":"🀄","c":6},{"n":["fearful"],"e":"😨","c":1},{"n":["aries"],"e":"♈","c":7},{"n":["spaghetti"],"e":"🍝","c":8},{"n":["circus_tent"],"e":"🎪","c":3},{"n":["izakaya_lantern","lantern"],"e":"🏮","c":5},{"n":["flag-cv"],"e":"🇨🇻","c":4},{"n":["weary"],"e":"😩","c":1},{"n":["flower_playing_cards"],"e":"🎴","c":6},{"n":["owl"],"e":"🦉","c":0},{"n":["performing_arts"],"e":"🎭","c":3},{"n":["frog"],"e":"🐸","c":0},{"n":["flag-cw"],"e":"🇨🇼","c":4},{"n":["notebook_with_decorative_cover"],"e":"📔","c":5},{"n":["exploding_head","shocked_face_with_exploding_head"],"e":"🤯","c":1},{"n":["taurus"],"e":"♉","c":7},{"n":["sweet_potato"],"e":"🍠","c":8},{"n":["closed_book"],"e":"📕","c":5},{"n":["gemini"],"e":"♊","c":7},{"n":["frame_with_picture"],"e":"🖼️","c":3},{"n":["flag-cx"],"e":"🇨🇽","c":4},{"n":["grimacing"],"e":"😬","c":1},{"n":["crocodile"],"e":"🐊","c":0},{"n":["oden"],"e":"🍢","c":8},{"n":["flag-cy"],"e":"🇨🇾","c":4},{"n":["book","open_book"],"e":"📖","c":5},{"n":["turtle"],"e":"🐢","c":0},{"n":["art"],"e":"🎨","c":3},{"n":["sushi"],"e":"🍣","c":8},{"n":["cold_sweat"],"e":"😰","c":1},{"n":["cancer"],"e":"♋","c":7},{"n":["fried_shrimp"],"e":"🍤","c":8},{"n":["slot_machine"],"e":"🎰","c":3},{"n":["scream"],"e":"😱","c":1},{"n":["green_book"],"e":"📗","c":5},{"n":["leo"],"e":"♌","c":7},{"n":["flag-cz"],"e":"🇨🇿","c":4},{"n":["lizard"],"e":"🦎","c":0},{"n":["virgo"],"e":"♍","c":7},{"n":["steam_locomotive"],"e":"🚂","c":3},{"n":["de","flag-de"],"e":"🇩🇪","c":4},{"n":["flushed"],"e":"😳","c":1},{"n":["blue_book"],"e":"📘","c":5},{"n":["snake"],"e":"🐍","c":0},{"n":["fish_cake"],"e":"🍥","c":8},{"n":["railway_car"],"e":"🚃","c":3},{"n":["dango"],"e":"🍡","c":8},{"n":["orange_book"],"e":"📙","c":5},{"n":["libra"],"e":"♎","c":7},{"n":["dragon_face"],"e":"🐲","c":0},{"n":["flag-dg"],"e":"🇩🇬","c":4},{"n":["zany_face","grinning_face_with_one_large_and_one_small_eye"],"e":"🤪","c":1},{"n":["books"],"e":"📚","c":5},{"n":["dragon"],"e":"🐉","c":0},{"n":["flag-dj"],"e":"🇩🇯","c":4},{"n":["dumpling"],"e":"🥟","c":8},{"n":["dizzy_face"],"e":"😵","c":1},{"n":["scorpius"],"e":"♏","c":7},{"n":["bullettrain_side"],"e":"🚄","c":3},{"n":["bullettrain_front"],"e":"🚅","c":3},{"n":["notebook"],"e":"📓","c":5},{"n":["fortune_cookie"],"e":"🥠","c":8},{"n":["sagittarius"],"e":"♐","c":7},{"n":["sauropod"],"e":"🦕","c":0},{"n":["flag-dk"],"e":"🇩🇰","c":4},{"n":["rage"],"e":"😡","c":1},{"n":["ledger"],"e":"📒","c":5},{"n":["angry"],"e":"😠","c":1},{"n":["t-rex"],"e":"🦖","c":0},{"n":["capricorn"],"e":"♑","c":7},{"n":["takeout_box"],"e":"🥡","c":8},{"n":["flag-dm"],"e":"🇩🇲","c":4},{"n":["train2"],"e":"🚆","c":3},{"n":["page_with_curl"],"e":"📃","c":5},{"n":["whale"],"e":"🐳","c":0},{"n":["face_with_symbols_on_mouth","serious_face_with_symbols_covering_mouth"],"e":"🤬","c":1},{"n":["flag-do"],"e":"🇩🇴","c":4},{"n":["metro"],"e":"🚇","c":3},{"n":["icecream"],"e":"🍦","c":8},{"n":["aquarius"],"e":"♒","c":7},{"n":["flag-dz"],"e":"🇩🇿","c":4},{"n":["whale2"],"e":"🐋","c":0},{"n":["mask"],"e":"😷","c":1},{"n":["scroll"],"e":"📜","c":5},{"n":["shaved_ice"],"e":"🍧","c":8},{"n":["pisces"],"e":"♓","c":7},{"n":["light_rail"],"e":"🚈","c":3},{"n":["dolphin","flipper"],"e":"🐬","c":0},{"n":["face_with_thermometer"],"e":"🤒","c":1},{"n":["flag-ea"],"e":"🇪🇦","c":4},{"n":["ophiuchus"],"e":"⛎","c":7},{"n":["station"],"e":"🚉","c":3},{"n":["ice_cream"],"e":"🍨","c":8},{"n":["page_facing_up"],"e":"📄","c":5},{"n":["doughnut"],"e":"🍩","c":8},{"n":["face_with_head_bandage"],"e":"🤕","c":1},{"n":["fish"],"e":"🐟","c":0},{"n":["newspaper"],"e":"📰","c":5},{"n":["tram"],"e":"🚊","c":3},{"n":["flag-ec"],"e":"🇪🇨","c":4},{"n":["twisted_rightwards_arrows"],"e":"🔀","c":7},{"n":["flag-ee"],"e":"🇪🇪","c":4},{"n":["cookie"],"e":"🍪","c":8},{"n":["monorail"],"e":"🚝","c":3},{"n":["tropical_fish"],"e":"🐠","c":0},{"n":["rolled_up_newspaper"],"e":"🗞️","c":5},{"n":["nauseated_face"],"e":"🤢","c":1},{"n":["repeat"],"e":"🔁","c":7},{"n":["bookmark_tabs"],"e":"📑","c":5},{"n":["repeat_one"],"e":"🔂","c":7},{"n":["flag-eg"],"e":"🇪🇬","c":4},{"n":["mountain_railway"],"e":"🚞","c":3},{"n":["birthday"],"e":"🎂","c":8},{"n":["blowfish"],"e":"🐡","c":0},{"n":["face_vomiting","face_with_open_mouth_vomiting"],"e":"🤮","c":1},{"n":["arrow_forward"],"e":"▶️","c":7},{"n":["bookmark"],"e":"🔖","c":5},{"n":["flag-eh"],"e":"🇪🇭","c":4},{"n":["shark"],"e":"🦈","c":0},{"n":["train"],"e":"🚋","c":3},{"n":["sneezing_face"],"e":"🤧","c":1},{"n":["cake"],"e":"🍰","c":8},{"n":["bus"],"e":"🚌","c":3},{"n":["pie"],"e":"🥧","c":8},{"n":["innocent"],"e":"😇","c":1},{"n":["fast_forward"],"e":"⏩","c":7},{"n":["label"],"e":"🏷️","c":5},{"n":["octopus"],"e":"🐙","c":0},{"n":["flag-er"],"e":"🇪🇷","c":4},{"n":["black_right_pointing_double_triangle_with_vertical_bar"],"e":"⏭️","c":7},{"n":["chocolate_bar"],"e":"🍫","c":8},{"n":["oncoming_bus"],"e":"🚍","c":3},{"n":["shell"],"e":"🐚","c":0},{"n":["face_with_cowboy_hat"],"e":"🤠","c":1},{"n":["moneybag"],"e":"💰","c":5},{"n":["es","flag-es"],"e":"🇪🇸","c":4},{"n":["crab"],"e":"🦀","c":0},{"n":["yen"],"e":"💴","c":5},{"n":["flag-et"],"e":"🇪🇹","c":4},{"n":["clown_face"],"e":"🤡","c":1},{"n":["black_right_pointing_triangle_with_double_vertical_bar"],"e":"⏯️","c":7},{"n":["trolleybus"],"e":"🚎","c":3},{"n":["candy"],"e":"🍬","c":8},{"n":["lying_face"],"e":"🤥","c":1},{"n":["arrow_backward"],"e":"◀️","c":7},{"n":["dollar"],"e":"💵","c":5},{"n":["shrimp"],"e":"🦐","c":0},{"n":["minibus"],"e":"🚐","c":3},{"n":["flag-eu"],"e":"🇪🇺","c":4},{"n":["lollipop"],"e":"🍭","c":8},{"n":["squid"],"e":"🦑","c":0},{"n":["euro"],"e":"💶","c":5},{"n":["flag-fi"],"e":"🇫🇮","c":4},{"n":["ambulance"],"e":"🚑","c":3},{"n":["custard"],"e":"🍮","c":8},{"n":["shushing_face","face_with_finger_covering_closed_lips"],"e":"🤫","c":1},{"n":["rewind"],"e":"⏪","c":7},{"n":["black_left_pointing_double_triangle_with_vertical_bar"],"e":"⏮️","c":7},{"n":["face_with_hand_over_mouth","smiling_face_with_smiling_eyes_and_hand_covering_mouth"],"e":"🤭","c":1},{"n":["flag-fj"],"e":"🇫🇯","c":4},{"n":["honey_pot"],"e":"🍯","c":8},{"n":["snail"],"e":"🐌","c":0},{"n":["pound"],"e":"💷","c":5},{"n":["fire_engine"],"e":"🚒","c":3},{"n":["baby_bottle"],"e":"🍼","c":8},{"n":["flag-fk"],"e":"🇫🇰","c":4},{"n":["butterfly"],"e":"🦋","c":0},{"n":["money_with_wings"],"e":"💸","c":5},{"n":["face_with_monocle"],"e":"🧐","c":1},{"n":["police_car"],"e":"🚓","c":3},{"n":["arrow_up_small"],"e":"🔼","c":7},{"n":["flag-fm"],"e":"🇫🇲","c":4},{"n":["glass_of_milk"],"e":"🥛","c":8},{"n":["credit_card"],"e":"💳","c":5},{"n":["oncoming_police_car"],"e":"🚔","c":3},{"n":["bug"],"e":"🐛","c":0},{"n":["nerd_face"],"e":"🤓","c":1},{"n":["arrow_double_up"],"e":"⏫","c":7},{"n":["chart"],"e":"💹","c":5},{"n":["flag-fo"],"e":"🇫🇴","c":4},{"n":["ant"],"e":"🐜","c":0},{"n":["arrow_down_small"],"e":"🔽","c":7},{"n":["smiling_imp"],"e":"😈","c":1},{"n":["taxi"],"e":"🚕","c":3},{"n":["coffee"],"e":"☕","c":8},{"n":["fr","flag-fr"],"e":"🇫🇷","c":4},{"n":["oncoming_taxi"],"e":"🚖","c":3},{"n":["arrow_double_down"],"e":"⏬","c":7},{"n":["imp"],"e":"👿","c":1},{"n":["currency_exchange"],"e":"💱","c":5},{"n":["tea"],"e":"🍵","c":8},{"n":["bee","honeybee"],"e":"🐝","c":0},{"n":["heavy_dollar_sign"],"e":"💲","c":5},{"n":["car","red_car"],"e":"🚗","c":3},{"n":["sake"],"e":"🍶","c":8},{"n":["flag-ga"],"e":"🇬🇦","c":4},{"n":["beetle"],"e":"🐞","c":0},{"n":["japanese_ogre"],"e":"👹","c":1},{"n":["double_vertical_bar"],"e":"⏸️","c":7},{"n":["champagne"],"e":"🍾","c":8},{"n":["japanese_goblin"],"e":"👺","c":1},{"n":["black_square_for_stop"],"e":"⏹️","c":7},{"n":["oncoming_automobile"],"e":"🚘","c":3},{"n":["email","envelope"],"e":"✉️","c":5},{"n":["cricket"],"e":"🦗","c":0},{"n":["gb","uk","flag-gb"],"e":"🇬🇧","c":4},{"n":["black_circle_for_record"],"e":"⏺️","c":7},{"n":["flag-gd"],"e":"🇬🇩","c":4},{"n":["spider"],"e":"🕷️","c":0},{"n":["blue_car"],"e":"🚙","c":3},{"n":["skull"],"e":"💀","c":1},{"n":["e-mail"],"e":"📧","c":5},{"n":["wine_glass"],"e":"🍷","c":8},{"n":["spider_web"],"e":"🕸️","c":0},{"n":["cocktail"],"e":"🍸","c":8},{"n":["skull_and_crossbones"],"e":"☠️","c":1},{"n":["flag-ge"],"e":"🇬🇪","c":4},{"n":["eject"],"e":"⏏️","c":7},{"n":["truck"],"e":"🚚","c":3},{"n":["incoming_envelope"],"e":"📨","c":5},{"n":["tropical_drink"],"e":"🍹","c":8},{"n":["scorpion"],"e":"🦂","c":0},{"n":["cinema"],"e":"🎦","c":7},{"n":["articulated_lorry"],"e":"🚛","c":3},{"n":["envelope_with_arrow"],"e":"📩","c":5},{"n":["ghost"],"e":"👻","c":1},{"n":["flag-gf"],"e":"🇬🇫","c":4},{"n":["bouquet"],"e":"💐","c":0},{"n":["tractor"],"e":"🚜","c":3},{"n":["beer"],"e":"🍺","c":8},{"n":["outbox_tray"],"e":"📤","c":5},{"n":["low_brightness"],"e":"🔅","c":7},{"n":["alien"],"e":"👽","c":1},{"n":["flag-gg"],"e":"🇬🇬","c":4},{"n":["cherry_blossom"],"e":"🌸","c":0},{"n":["inbox_tray"],"e":"📥","c":5},{"n":["flag-gh"],"e":"🇬🇭","c":4},{"n":["bike"],"e":"🚲","c":3},{"n":["space_invader"],"e":"👾","c":1},{"n":["beers"],"e":"🍻","c":8},{"n":["high_brightness"],"e":"🔆","c":7},{"n":["package"],"e":"📦","c":5},{"n":["scooter"],"e":"🛴","c":3},{"n":["white_flower"],"e":"💮","c":0},{"n":["clinking_glasses"],"e":"🥂","c":8},{"n":["robot_face"],"e":"🤖","c":1},{"n":["signal_strength"],"e":"📶","c":7},{"n":["flag-gi"],"e":"🇬🇮","c":4},{"n":["flag-gl"],"e":"🇬🇱","c":4},{"n":["motor_scooter"],"e":"🛵","c":3},{"n":["mailbox"],"e":"📫","c":5},{"n":["vibration_mode"],"e":"📳","c":7},{"n":["hankey","poop","shit"],"e":"💩","c":1},{"n":["rosette"],"e":"🏵️","c":0},{"n":["tumbler_glass"],"e":"🥃","c":8},{"n":["cup_with_straw"],"e":"🥤","c":8},{"n":["flag-gm"],"e":"🇬🇲","c":4},{"n":["mailbox_closed"],"e":"📪","c":5},{"n":["mobile_phone_off"],"e":"📴","c":7},{"n":["busstop"],"e":"🚏","c":3},{"n":["smiley_cat"],"e":"😺","c":1},{"n":["rose"],"e":"🌹","c":0},{"n":["motorway"],"e":"🛣️","c":3},{"n":["smile_cat"],"e":"😸","c":1},{"n":["flag-gn"],"e":"🇬🇳","c":4},{"n":["wilted_flower"],"e":"🥀","c":0},{"n":["mailbox_with_mail"],"e":"📬","c":5},{"n":["chopsticks"],"e":"🥢","c":8},{"n":["female_sign"],"e":"♀️","c":7},{"n":["mailbox_with_no_mail"],"e":"📭","c":5},{"n":["knife_fork_plate"],"e":"🍽️","c":8},{"n":["hibiscus"],"e":"🌺","c":0},{"n":["flag-gp"],"e":"🇬🇵","c":4},{"n":["railway_track"],"e":"🛤️","c":3},{"n":["male_sign"],"e":"♂️","c":7},{"n":["joy_cat"],"e":"😹","c":1},{"n":["fuelpump"],"e":"⛽","c":3},{"n":["sunflower"],"e":"🌻","c":0},{"n":["postbox"],"e":"📮","c":5},{"n":["flag-gq"],"e":"🇬🇶","c":4},{"n":["heart_eyes_cat"],"e":"😻","c":1},{"n":["fork_and_knife"],"e":"🍴","c":8},{"n":["medical_symbol","staff_of_aesculapius"],"e":"⚕️","c":7},{"n":["recycle"],"e":"♻️","c":7},{"n":["spoon"],"e":"🥄","c":8},{"n":["blossom"],"e":"🌼","c":0},{"n":["rotating_light"],"e":"🚨","c":3},{"n":["smirk_cat"],"e":"😼","c":1},{"n":["ballot_box_with_ballot"],"e":"🗳️","c":5},{"n":["flag-gr"],"e":"🇬🇷","c":4},{"n":["kissing_cat"],"e":"😽","c":1},{"n":["pencil2"],"e":"✏️","c":5},{"n":["traffic_light"],"e":"🚥","c":3},{"n":["fleur_de_lis"],"e":"⚜️","c":7},{"n":["tulip"],"e":"🌷","c":0},{"n":["hocho","knife"],"e":"🔪","c":8},{"n":["flag-gs"],"e":"🇬🇸","c":4},{"n":["seedling"],"e":"🌱","c":0},{"n":["amphora"],"e":"🏺","c":8},{"n":["scream_cat"],"e":"🙀","c":1},{"n":["vertical_traffic_light"],"e":"🚦","c":3},{"n":["black_nib"],"e":"✒️","c":5},{"n":["flag-gt"],"e":"🇬🇹","c":4},{"n":["trident"],"e":"🔱","c":7},{"n":["flag-gu"],"e":"🇬🇺","c":4},{"n":["name_badge"],"e":"📛","c":7},{"n":["construction"],"e":"🚧","c":3},{"n":["lower_left_fountain_pen"],"e":"🖋️","c":5},{"n":["evergreen_tree"],"e":"🌲","c":0},{"n":["crying_cat_face"],"e":"😿","c":1},{"n":["flag-gw"],"e":"🇬🇼","c":4},{"n":["lower_left_ballpoint_pen"],"e":"🖊️","c":5},{"n":["pouting_cat"],"e":"😾","c":1},{"n":["deciduous_tree"],"e":"🌳","c":0},{"n":["octagonal_sign"],"e":"🛑","c":3},{"n":["beginner"],"e":"🔰","c":7},{"n":["flag-gy"],"e":"🇬🇾","c":4},{"n":["lower_left_paintbrush"],"e":"🖌️","c":5},{"n":["o"],"e":"⭕","c":7},{"n":["palm_tree"],"e":"🌴","c":0},{"n":["anchor"],"e":"⚓","c":3},{"n":["see_no_evil"],"e":"🙈","c":1},{"n":["boat","sailboat"],"e":"⛵","c":3},{"n":["white_check_mark"],"e":"✅","c":7},{"n":["flag-hk"],"e":"🇭🇰","c":4},{"n":["lower_left_crayon"],"e":"🖍️","c":5},{"n":["hear_no_evil"],"e":"🙉","c":1},{"n":["cactus"],"e":"🌵","c":0},{"n":["ear_of_rice"],"e":"🌾","c":0},{"n":["speak_no_evil"],"e":"🙊","c":1},{"n":["flag-hm"],"e":"🇭🇲","c":4},{"n":["ballot_box_with_check"],"e":"☑️","c":7},{"n":["canoe"],"e":"🛶","c":3},{"n":["memo","pencil"],"e":"📝","c":5},{"n":["herb"],"e":"🌿","c":0},{"n":["flag-hn"],"e":"🇭🇳","c":4},{"n":["heavy_check_mark"],"e":"✔️","c":7},{"n":["briefcase"],"e":"💼","c":5},{"n":["speedboat"],"e":"🚤","c":3},{"n":["baby"],"e":"👶","c":1,"v":{"1F3FB":{"k":"baby-1F3FB","n":"baby","e":"👶🏻"},"1F3FC":{"k":"baby-1F3FC","n":"baby","e":"👶🏼"},"1F3FD":{"k":"baby-1F3FD","n":"baby","e":"👶🏽"},"1F3FE":{"k":"baby-1F3FE","n":"baby","e":"👶🏾"},"1F3FF":{"k":"baby-1F3FF","n":"baby","e":"👶🏿"}}},{"n":["heavy_multiplication_x"],"e":"✖️","c":7},{"n":["child"],"e":"🧒","c":1,"v":{"1F3FB":{"k":"child-1F3FB","n":"child","e":"🧒🏻"},"1F3FC":{"k":"child-1F3FC","n":"child","e":"🧒🏼"},"1F3FD":{"k":"child-1F3FD","n":"child","e":"🧒🏽"},"1F3FE":{"k":"child-1F3FE","n":"child","e":"🧒🏾"},"1F3FF":{"k":"child-1F3FF","n":"child","e":"🧒🏿"}}},{"n":["shamrock"],"e":"☘️","c":0},{"n":["passenger_ship"],"e":"🛳️","c":3},{"n":["flag-hr"],"e":"🇭🇷","c":4},{"n":["file_folder"],"e":"📁","c":5},{"n":["x"],"e":"❌","c":7},{"n":["four_leaf_clover"],"e":"🍀","c":0},{"n":["open_file_folder"],"e":"📂","c":5},{"n":["boy"],"e":"👦","c":1,"v":{"1F3FB":{"k":"boy-1F3FB","n":"boy","e":"👦🏻"},"1F3FC":{"k":"boy-1F3FC","n":"boy","e":"👦🏼"},"1F3FD":{"k":"boy-1F3FD","n":"boy","e":"👦🏽"},"1F3FE":{"k":"boy-1F3FE","n":"boy","e":"👦🏾"},"1F3FF":{"k":"boy-1F3FF","n":"boy","e":"👦🏿"}}},{"n":["ferry"],"e":"⛴️","c":3},{"n":["flag-ht"],"e":"🇭🇹","c":4},{"n":["girl"],"e":"👧","c":1,"v":{"1F3FB":{"k":"girl-1F3FB","n":"girl","e":"👧🏻"},"1F3FC":{"k":"girl-1F3FC","n":"girl","e":"👧🏼"},"1F3FD":{"k":"girl-1F3FD","n":"girl","e":"👧🏽"},"1F3FE":{"k":"girl-1F3FE","n":"girl","e":"👧🏾"},"1F3FF":{"k":"girl-1F3FF","n":"girl","e":"👧🏿"}}},{"n":["negative_squared_cross_mark"],"e":"❎","c":7},{"n":["flag-hu"],"e":"🇭🇺","c":4},{"n":["card_index_dividers"],"e":"🗂️","c":5},{"n":["maple_leaf"],"e":"🍁","c":0},{"n":["motor_boat"],"e":"🛥️","c":3},{"n":["flag-ic"],"e":"🇮🇨","c":4},{"n":["fallen_leaf"],"e":"🍂","c":0},{"n":["adult"],"e":"🧑","c":1,"v":{"1F3FB":{"k":"adult-1F3FB","n":"adult","e":"🧑🏻"},"1F3FC":{"k":"adult-1F3FC","n":"adult","e":"🧑🏼"},"1F3FD":{"k":"adult-1F3FD","n":"adult","e":"🧑🏽"},"1F3FE":{"k":"adult-1F3FE","n":"adult","e":"🧑🏾"},"1F3FF":{"k":"adult-1F3FF","n":"adult","e":"🧑🏿"}}},{"n":["ship"],"e":"🚢","c":3},{"n":["heavy_plus_sign"],"e":"➕","c":7},{"n":["date"],"e":"📅","c":5},{"n":["man"],"e":"👨","c":1,"v":{"1F3FB":{"k":"man-1F3FB","n":"man","e":"👨🏻"},"1F3FC":{"k":"man-1F3FC","n":"man","e":"👨🏼"},"1F3FD":{"k":"man-1F3FD","n":"man","e":"👨🏽"},"1F3FE":{"k":"man-1F3FE","n":"man","e":"👨🏾"},"1F3FF":{"k":"man-1F3FF","n":"man","e":"👨🏿"}}},{"n":["flag-id"],"e":"🇮🇩","c":4},{"n":["leaves"],"e":"🍃","c":0},{"n":["heavy_minus_sign"],"e":"➖","c":7},{"n":["calendar"],"e":"📆","c":5},{"n":["airplane"],"e":"✈️","c":3},{"n":["spiral_note_pad"],"e":"🗒️","c":5},{"n":["heavy_division_sign"],"e":"➗","c":7},{"n":["small_airplane"],"e":"🛩️","c":3},{"n":["woman"],"e":"👩","c":1,"v":{"1F3FB":{"k":"woman-1F3FB","n":"woman","e":"👩🏻"},"1F3FC":{"k":"woman-1F3FC","n":"woman","e":"👩🏼"},"1F3FD":{"k":"woman-1F3FD","n":"woman","e":"👩🏽"},"1F3FE":{"k":"woman-1F3FE","n":"woman","e":"👩🏾"},"1F3FF":{"k":"woman-1F3FF","n":"woman","e":"👩🏿"}}},{"n":["flag-ie"],"e":"🇮🇪","c":4},{"n":["curly_loop"],"e":"➰","c":7},{"n":["flag-il"],"e":"🇮🇱","c":4},{"n":["airplane_departure"],"e":"🛫","c":3},{"n":["spiral_calendar_pad"],"e":"🗓️","c":5},{"n":["older_adult"],"e":"🧓","c":1,"v":{"1F3FB":{"k":"older_adult-1F3FB","n":"older_adult","e":"🧓🏻"},"1F3FC":{"k":"older_adult-1F3FC","n":"older_adult","e":"🧓🏼"},"1F3FD":{"k":"older_adult-1F3FD","n":"older_adult","e":"🧓🏽"},"1F3FE":{"k":"older_adult-1F3FE","n":"older_adult","e":"🧓🏾"},"1F3FF":{"k":"older_adult-1F3FF","n":"older_adult","e":"🧓🏿"}}},{"n":["airplane_arriving"],"e":"🛬","c":3},{"n":["card_index"],"e":"📇","c":5},{"n":["loop"],"e":"➿","c":7},{"n":["older_man"],"e":"👴","c":1,"v":{"1F3FB":{"k":"older_man-1F3FB","n":"older_man","e":"👴🏻"},"1F3FC":{"k":"older_man-1F3FC","n":"older_man","e":"👴🏼"},"1F3FD":{"k":"older_man-1F3FD","n":"older_man","e":"👴🏽"},"1F3FE":{"k":"older_man-1F3FE","n":"older_man","e":"👴🏾"},"1F3FF":{"k":"older_man-1F3FF","n":"older_man","e":"👴🏿"}}},{"n":["flag-im"],"e":"🇮🇲","c":4},{"n":["flag-in"],"e":"🇮🇳","c":4},{"n":["chart_with_upwards_trend"],"e":"📈","c":5},{"n":["part_alternation_mark"],"e":"〽️","c":7},{"n":["seat"],"e":"💺","c":3},{"n":["older_woman"],"e":"👵","c":1,"v":{"1F3FB":{"k":"older_woman-1F3FB","n":"older_woman","e":"👵🏻"},"1F3FC":{"k":"older_woman-1F3FC","n":"older_woman","e":"👵🏼"},"1F3FD":{"k":"older_woman-1F3FD","n":"older_woman","e":"👵🏽"},"1F3FE":{"k":"older_woman-1F3FE","n":"older_woman","e":"👵🏾"},"1F3FF":{"k":"older_woman-1F3FF","n":"older_woman","e":"👵🏿"}}},{"n":["eight_spoked_asterisk"],"e":"✳️","c":7},{"n":["chart_with_downwards_trend"],"e":"📉","c":5},{"n":["flag-io"],"e":"🇮🇴","c":4},{"n":["male-doctor"],"e":"👨‍⚕️","c":1,"v":{"1F3FB":{"k":"male-doctor-1F3FB","n":"male-doctor","e":"👨🏻‍⚕️"},"1F3FC":{"k":"male-doctor-1F3FC","n":"male-doctor","e":"👨🏼‍⚕️"},"1F3FD":{"k":"male-doctor-1F3FD","n":"male-doctor","e":"👨🏽‍⚕️"},"1F3FE":{"k":"male-doctor-1F3FE","n":"male-doctor","e":"👨🏾‍⚕️"},"1F3FF":{"k":"male-doctor-1F3FF","n":"male-doctor","e":"👨🏿‍⚕️"}}},{"n":["helicopter"],"e":"🚁","c":3},{"n":["female-doctor"],"e":"👩‍⚕️","c":1,"v":{"1F3FB":{"k":"female-doctor-1F3FB","n":"female-doctor","e":"👩🏻‍⚕️"},"1F3FC":{"k":"female-doctor-1F3FC","n":"female-doctor","e":"👩🏼‍⚕️"},"1F3FD":{"k":"female-doctor-1F3FD","n":"female-doctor","e":"👩🏽‍⚕️"},"1F3FE":{"k":"female-doctor-1F3FE","n":"female-doctor","e":"👩🏾‍⚕️"},"1F3FF":{"k":"female-doctor-1F3FF","n":"female-doctor","e":"👩🏿‍⚕️"}}},{"n":["suspension_railway"],"e":"🚟","c":3},{"n":["bar_chart"],"e":"📊","c":5},{"n":["flag-iq"],"e":"🇮🇶","c":4},{"n":["eight_pointed_black_star"],"e":"✴️","c":7},{"n":["mountain_cableway"],"e":"🚠","c":3},{"n":["male-student"],"e":"👨‍🎓","c":1,"v":{"1F3FB":{"k":"male-student-1F3FB","n":"male-student","e":"👨🏻‍🎓"},"1F3FC":{"k":"male-student-1F3FC","n":"male-student","e":"👨🏼‍🎓"},"1F3FD":{"k":"male-student-1F3FD","n":"male-student","e":"👨🏽‍🎓"},"1F3FE":{"k":"male-student-1F3FE","n":"male-student","e":"👨🏾‍🎓"},"1F3FF":{"k":"male-student-1F3FF","n":"male-student","e":"👨🏿‍🎓"}}},{"n":["clipboard"],"e":"📋","c":5},{"n":["flag-ir"],"e":"🇮🇷","c":4},{"n":["sparkle"],"e":"❇️","c":7},{"n":["female-student"],"e":"👩‍🎓","c":1,"v":{"1F3FB":{"k":"female-student-1F3FB","n":"female-student","e":"👩🏻‍🎓"},"1F3FC":{"k":"female-student-1F3FC","n":"female-student","e":"👩🏼‍🎓"},"1F3FD":{"k":"female-student-1F3FD","n":"female-student","e":"👩🏽‍🎓"},"1F3FE":{"k":"female-student-1F3FE","n":"female-student","e":"👩🏾‍🎓"},"1F3FF":{"k":"female-student-1F3FF","n":"female-student","e":"👩🏿‍🎓"}}},{"n":["pushpin"],"e":"📌","c":5},{"n":["aerial_tramway"],"e":"🚡","c":3},{"n":["flag-is"],"e":"🇮🇸","c":4},{"n":["bangbang"],"e":"‼️","c":7},{"n":["interrobang"],"e":"⁉️","c":7},{"n":["satellite"],"e":"🛰️","c":3},{"n":["it","flag-it"],"e":"🇮🇹","c":4},{"n":["male-teacher"],"e":"👨‍🏫","c":1,"v":{"1F3FB":{"k":"male-teacher-1F3FB","n":"male-teacher","e":"👨🏻‍🏫"},"1F3FC":{"k":"male-teacher-1F3FC","n":"male-teacher","e":"👨🏼‍🏫"},"1F3FD":{"k":"male-teacher-1F3FD","n":"male-teacher","e":"👨🏽‍🏫"},"1F3FE":{"k":"male-teacher-1F3FE","n":"male-teacher","e":"👨🏾‍🏫"},"1F3FF":{"k":"male-teacher-1F3FF","n":"male-teacher","e":"👨🏿‍🏫"}}},{"n":["round_pushpin"],"e":"📍","c":5},{"n":["flag-je"],"e":"🇯🇪","c":4},{"n":["question"],"e":"❓","c":7},{"n":["rocket"],"e":"🚀","c":3},{"n":["female-teacher"],"e":"👩‍🏫","c":1,"v":{"1F3FB":{"k":"female-teacher-1F3FB","n":"female-teacher","e":"👩🏻‍🏫"},"1F3FC":{"k":"female-teacher-1F3FC","n":"female-teacher","e":"👩🏼‍🏫"},"1F3FD":{"k":"female-teacher-1F3FD","n":"female-teacher","e":"👩🏽‍🏫"},"1F3FE":{"k":"female-teacher-1F3FE","n":"female-teacher","e":"👩🏾‍🏫"},"1F3FF":{"k":"female-teacher-1F3FF","n":"female-teacher","e":"👩🏿‍🏫"}}},{"n":["paperclip"],"e":"📎","c":5},{"n":["linked_paperclips"],"e":"🖇️","c":5},{"n":["flying_saucer"],"e":"🛸","c":3},{"n":["male-judge"],"e":"👨‍⚖️","c":1,"v":{"1F3FB":{"k":"male-judge-1F3FB","n":"male-judge","e":"👨🏻‍⚖️"},"1F3FC":{"k":"male-judge-1F3FC","n":"male-judge","e":"👨🏼‍⚖️"},"1F3FD":{"k":"male-judge-1F3FD","n":"male-judge","e":"👨🏽‍⚖️"},"1F3FE":{"k":"male-judge-1F3FE","n":"male-judge","e":"👨🏾‍⚖️"},"1F3FF":{"k":"male-judge-1F3FF","n":"male-judge","e":"👨🏿‍⚖️"}}},{"n":["grey_question"],"e":"❔","c":7},{"n":["flag-jm"],"e":"🇯🇲","c":4},{"n":["bellhop_bell"],"e":"🛎️","c":3},{"n":["straight_ruler"],"e":"📏","c":5},{"n":["flag-jo"],"e":"🇯🇴","c":4},{"n":["female-judge"],"e":"👩‍⚖️","c":1,"v":{"1F3FB":{"k":"female-judge-1F3FB","n":"female-judge","e":"👩🏻‍⚖️"},"1F3FC":{"k":"female-judge-1F3FC","n":"female-judge","e":"👩🏼‍⚖️"},"1F3FD":{"k":"female-judge-1F3FD","n":"female-judge","e":"👩🏽‍⚖️"},"1F3FE":{"k":"female-judge-1F3FE","n":"female-judge","e":"👩🏾‍⚖️"},"1F3FF":{"k":"female-judge-1F3FF","n":"female-judge","e":"👩🏿‍⚖️"}}},{"n":["grey_exclamation"],"e":"❕","c":7},{"n":["door"],"e":"🚪","c":3},{"n":["male-farmer"],"e":"👨‍🌾","c":1,"v":{"1F3FB":{"k":"male-farmer-1F3FB","n":"male-farmer","e":"👨🏻‍🌾"},"1F3FC":{"k":"male-farmer-1F3FC","n":"male-farmer","e":"👨🏼‍🌾"},"1F3FD":{"k":"male-farmer-1F3FD","n":"male-farmer","e":"👨🏽‍🌾"},"1F3FE":{"k":"male-farmer-1F3FE","n":"male-farmer","e":"👨🏾‍🌾"},"1F3FF":{"k":"male-farmer-1F3FF","n":"male-farmer","e":"👨🏿‍🌾"}}},{"n":["jp","flag-jp"],"e":"🇯🇵","c":4},{"n":["triangular_ruler"],"e":"📐","c":5},{"n":["exclamation","heavy_exclamation_mark"],"e":"❗","c":7},{"n":["bed"],"e":"🛏️","c":3},{"n":["female-farmer"],"e":"👩‍🌾","c":1,"v":{"1F3FB":{"k":"female-farmer-1F3FB","n":"female-farmer","e":"👩🏻‍🌾"},"1F3FC":{"k":"female-farmer-1F3FC","n":"female-farmer","e":"👩🏼‍🌾"},"1F3FD":{"k":"female-farmer-1F3FD","n":"female-farmer","e":"👩🏽‍🌾"},"1F3FE":{"k":"female-farmer-1F3FE","n":"female-farmer","e":"👩🏾‍🌾"},"1F3FF":{"k":"female-farmer-1F3FF","n":"female-farmer","e":"👩🏿‍🌾"}}},{"n":["scissors"],"e":"✂️","c":5},{"n":["wavy_dash"],"e":"〰️","c":7},{"n":["flag-ke"],"e":"🇰🇪","c":4},{"n":["flag-kg"],"e":"🇰🇬","c":4},{"n":["couch_and_lamp"],"e":"🛋️","c":3},{"n":["male-cook"],"e":"👨‍🍳","c":1,"v":{"1F3FB":{"k":"male-cook-1F3FB","n":"male-cook","e":"👨🏻‍🍳"},"1F3FC":{"k":"male-cook-1F3FC","n":"male-cook","e":"👨🏼‍🍳"},"1F3FD":{"k":"male-cook-1F3FD","n":"male-cook","e":"👨🏽‍🍳"},"1F3FE":{"k":"male-cook-1F3FE","n":"male-cook","e":"👨🏾‍🍳"},"1F3FF":{"k":"male-cook-1F3FF","n":"male-cook","e":"👨🏿‍🍳"}}},{"n":["card_file_box"],"e":"🗃️","c":5},{"n":["copyright"],"e":"©️","c":7},{"n":["file_cabinet"],"e":"🗄️","c":5},{"n":["registered"],"e":"®️","c":7},{"n":["flag-kh"],"e":"🇰🇭","c":4},{"n":["female-cook"],"e":"👩‍🍳","c":1,"v":{"1F3FB":{"k":"female-cook-1F3FB","n":"female-cook","e":"👩🏻‍🍳"},"1F3FC":{"k":"female-cook-1F3FC","n":"female-cook","e":"👩🏼‍🍳"},"1F3FD":{"k":"female-cook-1F3FD","n":"female-cook","e":"👩🏽‍🍳"},"1F3FE":{"k":"female-cook-1F3FE","n":"female-cook","e":"👩🏾‍🍳"},"1F3FF":{"k":"female-cook-1F3FF","n":"female-cook","e":"👩🏿‍🍳"}}},{"n":["toilet"],"e":"🚽","c":3},{"n":["wastebasket"],"e":"🗑️","c":5},{"n":["flag-ki"],"e":"🇰🇮","c":4},{"n":["shower"],"e":"🚿","c":3},{"n":["male-mechanic"],"e":"👨‍🔧","c":1,"v":{"1F3FB":{"k":"male-mechanic-1F3FB","n":"male-mechanic","e":"👨🏻‍🔧"},"1F3FC":{"k":"male-mechanic-1F3FC","n":"male-mechanic","e":"👨🏼‍🔧"},"1F3FD":{"k":"male-mechanic-1F3FD","n":"male-mechanic","e":"👨🏽‍🔧"},"1F3FE":{"k":"male-mechanic-1F3FE","n":"male-mechanic","e":"👨🏾‍🔧"},"1F3FF":{"k":"male-mechanic-1F3FF","n":"male-mechanic","e":"👨🏿‍🔧"}}},{"n":["tm"],"e":"™️","c":7},{"n":["hash"],"e":"#️⃣","c":7},{"n":["flag-km"],"e":"🇰🇲","c":4},{"n":["bathtub"],"e":"🛁","c":3},{"n":["female-mechanic"],"e":"👩‍🔧","c":1,"v":{"1F3FB":{"k":"female-mechanic-1F3FB","n":"female-mechanic","e":"👩🏻‍🔧"},"1F3FC":{"k":"female-mechanic-1F3FC","n":"female-mechanic","e":"👩🏼‍🔧"},"1F3FD":{"k":"female-mechanic-1F3FD","n":"female-mechanic","e":"👩🏽‍🔧"},"1F3FE":{"k":"female-mechanic-1F3FE","n":"female-mechanic","e":"👩🏾‍🔧"},"1F3FF":{"k":"female-mechanic-1F3FF","n":"female-mechanic","e":"👩🏿‍🔧"}}},{"n":["lock"],"e":"🔒","c":5},{"n":["male-factory-worker"],"e":"👨‍🏭","c":1,"v":{"1F3FB":{"k":"male-factory-worker-1F3FB","n":"male-factory-worker","e":"👨🏻‍🏭"},"1F3FC":{"k":"male-factory-worker-1F3FC","n":"male-factory-worker","e":"👨🏼‍🏭"},"1F3FD":{"k":"male-factory-worker-1F3FD","n":"male-factory-worker","e":"👨🏽‍🏭"},"1F3FE":{"k":"male-factory-worker-1F3FE","n":"male-factory-worker","e":"👨🏾‍🏭"},"1F3FF":{"k":"male-factory-worker-1F3FF","n":"male-factory-worker","e":"👨🏿‍🏭"}}},{"n":["flag-kn"],"e":"🇰🇳","c":4},{"n":["hourglass"],"e":"⌛","c":3},{"n":["keycap_star"],"e":"*️⃣","c":7},{"n":["unlock"],"e":"🔓","c":5},{"n":["flag-kp"],"e":"🇰🇵","c":4},{"n":["female-factory-worker"],"e":"👩‍🏭","c":1,"v":{"1F3FB":{"k":"female-factory-worker-1F3FB","n":"female-factory-worker","e":"👩🏻‍🏭"},"1F3FC":{"k":"female-factory-worker-1F3FC","n":"female-factory-worker","e":"👩🏼‍🏭"},"1F3FD":{"k":"female-factory-worker-1F3FD","n":"female-factory-worker","e":"👩🏽‍🏭"},"1F3FE":{"k":"female-factory-worker-1F3FE","n":"female-factory-worker","e":"👩🏾‍🏭"},"1F3FF":{"k":"female-factory-worker-1F3FF","n":"female-factory-worker","e":"👩🏿‍🏭"}}},{"n":["zero"],"e":"0️⃣","c":7},{"n":["lock_with_ink_pen"],"e":"🔏","c":5},{"n":["hourglass_flowing_sand"],"e":"⏳","c":3},{"n":["one"],"e":"1️⃣","c":7},{"n":["kr","flag-kr"],"e":"🇰🇷","c":4},{"n":["watch"],"e":"⌚","c":3},{"n":["male-office-worker"],"e":"👨‍💼","c":1,"v":{"1F3FB":{"k":"male-office-worker-1F3FB","n":"male-office-worker","e":"👨🏻‍💼"},"1F3FC":{"k":"male-office-worker-1F3FC","n":"male-office-worker","e":"👨🏼‍💼"},"1F3FD":{"k":"male-office-worker-1F3FD","n":"male-office-worker","e":"👨🏽‍💼"},"1F3FE":{"k":"male-office-worker-1F3FE","n":"male-office-worker","e":"👨🏾‍💼"},"1F3FF":{"k":"male-office-worker-1F3FF","n":"male-office-worker","e":"👨🏿‍💼"}}},{"n":["closed_lock_with_key"],"e":"🔐","c":5},{"n":["female-office-worker"],"e":"👩‍💼","c":1,"v":{"1F3FB":{"k":"female-office-worker-1F3FB","n":"female-office-worker","e":"👩🏻‍💼"},"1F3FC":{"k":"female-office-worker-1F3FC","n":"female-office-worker","e":"👩🏼‍💼"},"1F3FD":{"k":"female-office-worker-1F3FD","n":"female-office-worker","e":"👩🏽‍💼"},"1F3FE":{"k":"female-office-worker-1F3FE","n":"female-office-worker","e":"👩🏾‍💼"},"1F3FF":{"k":"female-office-worker-1F3FF","n":"female-office-worker","e":"👩🏿‍💼"}}},{"n":["two"],"e":"2️⃣","c":7},{"n":["alarm_clock"],"e":"⏰","c":3},{"n":["key"],"e":"🔑","c":5},{"n":["flag-kw"],"e":"🇰🇼","c":4},{"n":["stopwatch"],"e":"⏱️","c":3},{"n":["male-scientist"],"e":"👨‍🔬","c":1,"v":{"1F3FB":{"k":"male-scientist-1F3FB","n":"male-scientist","e":"👨🏻‍🔬"},"1F3FC":{"k":"male-scientist-1F3FC","n":"male-scientist","e":"👨🏼‍🔬"},"1F3FD":{"k":"male-scientist-1F3FD","n":"male-scientist","e":"👨🏽‍🔬"},"1F3FE":{"k":"male-scientist-1F3FE","n":"male-scientist","e":"👨🏾‍🔬"},"1F3FF":{"k":"male-scientist-1F3FF","n":"male-scientist","e":"👨🏿‍🔬"}}},{"n":["three"],"e":"3️⃣","c":7},{"n":["flag-ky"],"e":"🇰🇾","c":4},{"n":["old_key"],"e":"🗝️","c":5},{"n":["flag-kz"],"e":"🇰🇿","c":4},{"n":["hammer"],"e":"🔨","c":5},{"n":["female-scientist"],"e":"👩‍🔬","c":1,"v":{"1F3FB":{"k":"female-scientist-1F3FB","n":"female-scientist","e":"👩🏻‍🔬"},"1F3FC":{"k":"female-scientist-1F3FC","n":"female-scientist","e":"👩🏼‍🔬"},"1F3FD":{"k":"female-scientist-1F3FD","n":"female-scientist","e":"👩🏽‍🔬"},"1F3FE":{"k":"female-scientist-1F3FE","n":"female-scientist","e":"👩🏾‍🔬"},"1F3FF":{"k":"female-scientist-1F3FF","n":"female-scientist","e":"👩🏿‍🔬"}}},{"n":["timer_clock"],"e":"⏲️","c":3},{"n":["four"],"e":"4️⃣","c":7},{"n":["male-technologist"],"e":"👨‍💻","c":1,"v":{"1F3FB":{"k":"male-technologist-1F3FB","n":"male-technologist","e":"👨🏻‍💻"},"1F3FC":{"k":"male-technologist-1F3FC","n":"male-technologist","e":"👨🏼‍💻"},"1F3FD":{"k":"male-technologist-1F3FD","n":"male-technologist","e":"👨🏽‍💻"},"1F3FE":{"k":"male-technologist-1F3FE","n":"male-technologist","e":"👨🏾‍💻"},"1F3FF":{"k":"male-technologist-1F3FF","n":"male-technologist","e":"👨🏿‍💻"}}},{"n":["mantelpiece_clock"],"e":"🕰️","c":3},{"n":["five"],"e":"5️⃣","c":7},{"n":["flag-la"],"e":"🇱🇦","c":4},{"n":["pick"],"e":"⛏️","c":5},{"n":["flag-lb"],"e":"🇱🇧","c":4},{"n":["clock12"],"e":"🕛","c":3},{"n":["hammer_and_pick"],"e":"⚒️","c":5},{"n":["six"],"e":"6️⃣","c":7},{"n":["female-technologist"],"e":"👩‍💻","c":1,"v":{"1F3FB":{"k":"female-technologist-1F3FB","n":"female-technologist","e":"👩🏻‍💻"},"1F3FC":{"k":"female-technologist-1F3FC","n":"female-technologist","e":"👩🏼‍💻"},"1F3FD":{"k":"female-technologist-1F3FD","n":"female-technologist","e":"👩🏽‍💻"},"1F3FE":{"k":"female-technologist-1F3FE","n":"female-technologist","e":"👩🏾‍💻"},"1F3FF":{"k":"female-technologist-1F3FF","n":"female-technologist","e":"👩🏿‍💻"}}},{"n":["hammer_and_wrench"],"e":"🛠️","c":5},{"n":["flag-lc"],"e":"🇱🇨","c":4},{"n":["clock1230"],"e":"🕧","c":3},{"n":["seven"],"e":"7️⃣","c":7},{"n":["male-singer"],"e":"👨‍🎤","c":1,"v":{"1F3FB":{"k":"male-singer-1F3FB","n":"male-singer","e":"👨🏻‍🎤"},"1F3FC":{"k":"male-singer-1F3FC","n":"male-singer","e":"👨🏼‍🎤"},"1F3FD":{"k":"male-singer-1F3FD","n":"male-singer","e":"👨🏽‍🎤"},"1F3FE":{"k":"male-singer-1F3FE","n":"male-singer","e":"👨🏾‍🎤"},"1F3FF":{"k":"male-singer-1F3FF","n":"male-singer","e":"👨🏿‍🎤"}}},{"n":["eight"],"e":"8️⃣","c":7},{"n":["flag-li"],"e":"🇱🇮","c":4},{"n":["dagger_knife"],"e":"🗡️","c":5},{"n":["clock1"],"e":"🕐","c":3},{"n":["female-singer"],"e":"👩‍🎤","c":1,"v":{"1F3FB":{"k":"female-singer-1F3FB","n":"female-singer","e":"👩🏻‍🎤"},"1F3FC":{"k":"female-singer-1F3FC","n":"female-singer","e":"👩🏼‍🎤"},"1F3FD":{"k":"female-singer-1F3FD","n":"female-singer","e":"👩🏽‍🎤"},"1F3FE":{"k":"female-singer-1F3FE","n":"female-singer","e":"👩🏾‍🎤"},"1F3FF":{"k":"female-singer-1F3FF","n":"female-singer","e":"👩🏿‍🎤"}}},{"n":["male-artist"],"e":"👨‍🎨","c":1,"v":{"1F3FB":{"k":"male-artist-1F3FB","n":"male-artist","e":"👨🏻‍🎨"},"1F3FC":{"k":"male-artist-1F3FC","n":"male-artist","e":"👨🏼‍🎨"},"1F3FD":{"k":"male-artist-1F3FD","n":"male-artist","e":"👨🏽‍🎨"},"1F3FE":{"k":"male-artist-1F3FE","n":"male-artist","e":"👨🏾‍🎨"},"1F3FF":{"k":"male-artist-1F3FF","n":"male-artist","e":"👨🏿‍🎨"}}},{"n":["crossed_swords"],"e":"⚔️","c":5},{"n":["nine"],"e":"9️⃣","c":7},{"n":["flag-lk"],"e":"🇱🇰","c":4},{"n":["clock130"],"e":"🕜","c":3},{"n":["clock2"],"e":"🕑","c":3},{"n":["gun"],"e":"🔫","c":5},{"n":["keycap_ten"],"e":"🔟","c":7},{"n":["female-artist"],"e":"👩‍🎨","c":1,"v":{"1F3FB":{"k":"female-artist-1F3FB","n":"female-artist","e":"👩🏻‍🎨"},"1F3FC":{"k":"female-artist-1F3FC","n":"female-artist","e":"👩🏼‍🎨"},"1F3FD":{"k":"female-artist-1F3FD","n":"female-artist","e":"👩🏽‍🎨"},"1F3FE":{"k":"female-artist-1F3FE","n":"female-artist","e":"👩🏾‍🎨"},"1F3FF":{"k":"female-artist-1F3FF","n":"female-artist","e":"👩🏿‍🎨"}}},{"n":["flag-lr"],"e":"🇱🇷","c":4},{"n":["clock230"],"e":"🕝","c":3},{"n":["100"],"e":"💯","c":7},{"n":["bow_and_arrow"],"e":"🏹","c":5},{"n":["male-pilot"],"e":"👨‍✈️","c":1,"v":{"1F3FB":{"k":"male-pilot-1F3FB","n":"male-pilot","e":"👨🏻‍✈️"},"1F3FC":{"k":"male-pilot-1F3FC","n":"male-pilot","e":"👨🏼‍✈️"},"1F3FD":{"k":"male-pilot-1F3FD","n":"male-pilot","e":"👨🏽‍✈️"},"1F3FE":{"k":"male-pilot-1F3FE","n":"male-pilot","e":"👨🏾‍✈️"},"1F3FF":{"k":"male-pilot-1F3FF","n":"male-pilot","e":"👨🏿‍✈️"}}},{"n":["flag-ls"],"e":"🇱🇸","c":4},{"n":["flag-lt"],"e":"🇱🇹","c":4},{"n":["capital_abcd"],"e":"🔠","c":7},{"n":["female-pilot"],"e":"👩‍✈️","c":1,"v":{"1F3FB":{"k":"female-pilot-1F3FB","n":"female-pilot","e":"👩🏻‍✈️"},"1F3FC":{"k":"female-pilot-1F3FC","n":"female-pilot","e":"👩🏼‍✈️"},"1F3FD":{"k":"female-pilot-1F3FD","n":"female-pilot","e":"👩🏽‍✈️"},"1F3FE":{"k":"female-pilot-1F3FE","n":"female-pilot","e":"👩🏾‍✈️"},"1F3FF":{"k":"female-pilot-1F3FF","n":"female-pilot","e":"👩🏿‍✈️"}}},{"n":["clock3"],"e":"🕒","c":3},{"n":["shield"],"e":"🛡️","c":5},{"n":["male-astronaut"],"e":"👨‍🚀","c":1,"v":{"1F3FB":{"k":"male-astronaut-1F3FB","n":"male-astronaut","e":"👨🏻‍🚀"},"1F3FC":{"k":"male-astronaut-1F3FC","n":"male-astronaut","e":"👨🏼‍🚀"},"1F3FD":{"k":"male-astronaut-1F3FD","n":"male-astronaut","e":"👨🏽‍🚀"},"1F3FE":{"k":"male-astronaut-1F3FE","n":"male-astronaut","e":"👨🏾‍🚀"},"1F3FF":{"k":"male-astronaut-1F3FF","n":"male-astronaut","e":"👨🏿‍🚀"}}},{"n":["abcd"],"e":"🔡","c":7},{"n":["clock330"],"e":"🕞","c":3},{"n":["flag-lu"],"e":"🇱🇺","c":4},{"n":["wrench"],"e":"🔧","c":5},{"n":["nut_and_bolt"],"e":"🔩","c":5},{"n":["1234"],"e":"🔢","c":7},{"n":["clock4"],"e":"🕓","c":3},{"n":["female-astronaut"],"e":"👩‍🚀","c":1,"v":{"1F3FB":{"k":"female-astronaut-1F3FB","n":"female-astronaut","e":"👩🏻‍🚀"},"1F3FC":{"k":"female-astronaut-1F3FC","n":"female-astronaut","e":"👩🏼‍🚀"},"1F3FD":{"k":"female-astronaut-1F3FD","n":"female-astronaut","e":"👩🏽‍🚀"},"1F3FE":{"k":"female-astronaut-1F3FE","n":"female-astronaut","e":"👩🏾‍🚀"},"1F3FF":{"k":"female-astronaut-1F3FF","n":"female-astronaut","e":"👩🏿‍🚀"}}},{"n":["flag-lv"],"e":"🇱🇻","c":4},{"n":["gear"],"e":"⚙️","c":5},{"n":["male-firefighter"],"e":"👨‍🚒","c":1,"v":{"1F3FB":{"k":"male-firefighter-1F3FB","n":"male-firefighter","e":"👨🏻‍🚒"},"1F3FC":{"k":"male-firefighter-1F3FC","n":"male-firefighter","e":"👨🏼‍🚒"},"1F3FD":{"k":"male-firefighter-1F3FD","n":"male-firefighter","e":"👨🏽‍🚒"},"1F3FE":{"k":"male-firefighter-1F3FE","n":"male-firefighter","e":"👨🏾‍🚒"},"1F3FF":{"k":"male-firefighter-1F3FF","n":"male-firefighter","e":"👨🏿‍🚒"}}},{"n":["flag-ly"],"e":"🇱🇾","c":4},{"n":["symbols"],"e":"🔣","c":7},{"n":["clock430"],"e":"🕟","c":3},{"n":["flag-ma"],"e":"🇲🇦","c":4},{"n":["compression"],"e":"🗜️","c":5},{"n":["female-firefighter"],"e":"👩‍🚒","c":1,"v":{"1F3FB":{"k":"female-firefighter-1F3FB","n":"female-firefighter","e":"👩🏻‍🚒"},"1F3FC":{"k":"female-firefighter-1F3FC","n":"female-firefighter","e":"👩🏼‍🚒"},"1F3FD":{"k":"female-firefighter-1F3FD","n":"female-firefighter","e":"👩🏽‍🚒"},"1F3FE":{"k":"female-firefighter-1F3FE","n":"female-firefighter","e":"👩🏾‍🚒"},"1F3FF":{"k":"female-firefighter-1F3FF","n":"female-firefighter","e":"👩🏿‍🚒"}}},{"n":["abc"],"e":"🔤","c":7},{"n":["clock5"],"e":"🕔","c":3},{"n":["clock530"],"e":"🕠","c":3},{"n":["a"],"e":"🅰️","c":7},{"n":["alembic"],"e":"⚗️","c":5},{"n":["flag-mc"],"e":"🇲🇨","c":4},{"n":["cop"],"e":"👮","c":1,"v":{"1F3FB":{"k":"cop-1F3FB","n":"cop","e":"👮🏻"},"1F3FC":{"k":"cop-1F3FC","n":"cop","e":"👮🏼"},"1F3FD":{"k":"cop-1F3FD","n":"cop","e":"👮🏽"},"1F3FE":{"k":"cop-1F3FE","n":"cop","e":"👮🏾"},"1F3FF":{"k":"cop-1F3FF","n":"cop","e":"👮🏿"}}},{"n":["scales"],"e":"⚖️","c":5},{"n":["clock6"],"e":"🕕","c":3},{"n":["flag-md"],"e":"🇲🇩","c":4},{"n":["ab"],"e":"🆎","c":7},{"n":["male-police-officer"],"e":"👮‍♂️","c":1,"v":{"1F3FB":{"k":"male-police-officer-1F3FB","n":"male-police-officer","e":"👮🏻‍♂️"},"1F3FC":{"k":"male-police-officer-1F3FC","n":"male-police-officer","e":"👮🏼‍♂️"},"1F3FD":{"k":"male-police-officer-1F3FD","n":"male-police-officer","e":"👮🏽‍♂️"},"1F3FE":{"k":"male-police-officer-1F3FE","n":"male-police-officer","e":"👮🏾‍♂️"},"1F3FF":{"k":"male-police-officer-1F3FF","n":"male-police-officer","e":"👮🏿‍♂️"}}},{"n":["link"],"e":"🔗","c":5},{"n":["flag-me"],"e":"🇲🇪","c":4},{"n":["clock630"],"e":"🕡","c":3},{"n":["b"],"e":"🅱️","c":7},{"n":["female-police-officer"],"e":"👮‍♀️","c":1,"v":{"1F3FB":{"k":"female-police-officer-1F3FB","n":"female-police-officer","e":"👮🏻‍♀️"},"1F3FC":{"k":"female-police-officer-1F3FC","n":"female-police-officer","e":"👮🏼‍♀️"},"1F3FD":{"k":"female-police-officer-1F3FD","n":"female-police-officer","e":"👮🏽‍♀️"},"1F3FE":{"k":"female-police-officer-1F3FE","n":"female-police-officer","e":"👮🏾‍♀️"},"1F3FF":{"k":"female-police-officer-1F3FF","n":"female-police-officer","e":"👮🏿‍♀️"}}},{"n":["clock7"],"e":"🕖","c":3},{"n":["cl"],"e":"🆑","c":7},{"n":["sleuth_or_spy"],"e":"🕵️","c":1,"v":{"1F3FB":{"k":"sleuth_or_spy-1F3FB","n":"sleuth_or_spy","e":"🕵🏻"},"1F3FC":{"k":"sleuth_or_spy-1F3FC","n":"sleuth_or_spy","e":"🕵🏼"},"1F3FD":{"k":"sleuth_or_spy-1F3FD","n":"sleuth_or_spy","e":"🕵🏽"},"1F3FE":{"k":"sleuth_or_spy-1F3FE","n":"sleuth_or_spy","e":"🕵🏾"},"1F3FF":{"k":"sleuth_or_spy-1F3FF","n":"sleuth_or_spy","e":"🕵🏿"}}},{"n":["flag-mf"],"e":"🇲🇫","c":4},{"n":["chains"],"e":"⛓️","c":5},{"n":["syringe"],"e":"💉","c":5},{"n":["male-detective"],"e":"🕵️‍♂️","c":1,"v":{"1F3FB":{"k":"male-detective-1F3FB","n":"male-detective","e":"🕵🏻‍♂️"},"1F3FC":{"k":"male-detective-1F3FC","n":"male-detective","e":"🕵🏼‍♂️"},"1F3FD":{"k":"male-detective-1F3FD","n":"male-detective","e":"🕵🏽‍♂️"},"1F3FE":{"k":"male-detective-1F3FE","n":"male-detective","e":"🕵🏾‍♂️"},"1F3FF":{"k":"male-detective-1F3FF","n":"male-detective","e":"🕵🏿‍♂️"}}},{"n":["cool"],"e":"🆒","c":7},{"n":["clock730"],"e":"🕢","c":3},{"n":["flag-mg"],"e":"🇲🇬","c":4},{"n":["free"],"e":"🆓","c":7},{"n":["flag-mh"],"e":"🇲🇭","c":4},{"n":["clock8"],"e":"🕗","c":3},{"n":["pill"],"e":"💊","c":5},{"n":["female-detective"],"e":"🕵️‍♀️","c":1,"v":{"1F3FB":{"k":"female-detective-1F3FB","n":"female-detective","e":"🕵🏻‍♀️"},"1F3FC":{"k":"female-detective-1F3FC","n":"female-detective","e":"🕵🏼‍♀️"},"1F3FD":{"k":"female-detective-1F3FD","n":"female-detective","e":"🕵🏽‍♀️"},"1F3FE":{"k":"female-detective-1F3FE","n":"female-detective","e":"🕵🏾‍♀️"},"1F3FF":{"k":"female-detective-1F3FF","n":"female-detective","e":"🕵🏿‍♀️"}}},{"n":["clock830"],"e":"🕣","c":3},{"n":["guardsman"],"e":"💂","c":1,"v":{"1F3FB":{"k":"guardsman-1F3FB","n":"guardsman","e":"💂🏻"},"1F3FC":{"k":"guardsman-1F3FC","n":"guardsman","e":"💂🏼"},"1F3FD":{"k":"guardsman-1F3FD","n":"guardsman","e":"💂🏽"},"1F3FE":{"k":"guardsman-1F3FE","n":"guardsman","e":"💂🏾"},"1F3FF":{"k":"guardsman-1F3FF","n":"guardsman","e":"💂🏿"}}},{"n":["information_source"],"e":"ℹ️","c":7},{"n":["flag-mk"],"e":"🇲🇰","c":4},{"n":["smoking"],"e":"🚬","c":5},{"n":["id"],"e":"🆔","c":7},{"n":["clock9"],"e":"🕘","c":3},{"n":["flag-ml"],"e":"🇲🇱","c":4},{"n":["coffin"],"e":"⚰️","c":5},{"n":["male-guard"],"e":"💂‍♂️","c":1,"v":{"1F3FB":{"k":"male-guard-1F3FB","n":"male-guard","e":"💂🏻‍♂️"},"1F3FC":{"k":"male-guard-1F3FC","n":"male-guard","e":"💂🏼‍♂️"},"1F3FD":{"k":"male-guard-1F3FD","n":"male-guard","e":"💂🏽‍♂️"},"1F3FE":{"k":"male-guard-1F3FE","n":"male-guard","e":"💂🏾‍♂️"},"1F3FF":{"k":"male-guard-1F3FF","n":"male-guard","e":"💂🏿‍♂️"}}},{"n":["m"],"e":"Ⓜ️","c":7},{"n":["funeral_urn"],"e":"⚱️","c":5},{"n":["female-guard"],"e":"💂‍♀️","c":1,"v":{"1F3FB":{"k":"female-guard-1F3FB","n":"female-guard","e":"💂🏻‍♀️"},"1F3FC":{"k":"female-guard-1F3FC","n":"female-guard","e":"💂🏼‍♀️"},"1F3FD":{"k":"female-guard-1F3FD","n":"female-guard","e":"💂🏽‍♀️"},"1F3FE":{"k":"female-guard-1F3FE","n":"female-guard","e":"💂🏾‍♀️"},"1F3FF":{"k":"female-guard-1F3FF","n":"female-guard","e":"💂🏿‍♀️"}}},{"n":["flag-mm"],"e":"🇲🇲","c":4},{"n":["clock930"],"e":"🕤","c":3},{"n":["moyai"],"e":"🗿","c":5},{"n":["new"],"e":"🆕","c":7},{"n":["flag-mn"],"e":"🇲🇳","c":4},{"n":["construction_worker"],"e":"👷","c":1,"v":{"1F3FB":{"k":"construction_worker-1F3FB","n":"construction_worker","e":"👷🏻"},"1F3FC":{"k":"construction_worker-1F3FC","n":"construction_worker","e":"👷🏼"},"1F3FD":{"k":"construction_worker-1F3FD","n":"construction_worker","e":"👷🏽"},"1F3FE":{"k":"construction_worker-1F3FE","n":"construction_worker","e":"👷🏾"},"1F3FF":{"k":"construction_worker-1F3FF","n":"construction_worker","e":"👷🏿"}}},{"n":["clock10"],"e":"🕙","c":3},{"n":["clock1030"],"e":"🕥","c":3},{"n":["ng"],"e":"🆖","c":7},{"n":["male-construction-worker"],"e":"👷‍♂️","c":1,"v":{"1F3FB":{"k":"male-construction-worker-1F3FB","n":"male-construction-worker","e":"👷🏻‍♂️"},"1F3FC":{"k":"male-construction-worker-1F3FC","n":"male-construction-worker","e":"👷🏼‍♂️"},"1F3FD":{"k":"male-construction-worker-1F3FD","n":"male-construction-worker","e":"👷🏽‍♂️"},"1F3FE":{"k":"male-construction-worker-1F3FE","n":"male-construction-worker","e":"👷🏾‍♂️"},"1F3FF":{"k":"male-construction-worker-1F3FF","n":"male-construction-worker","e":"👷🏿‍♂️"}}},{"n":["flag-mo"],"e":"🇲🇴","c":4},{"n":["oil_drum"],"e":"🛢️","c":5},{"n":["o2"],"e":"🅾️","c":7},{"n":["female-construction-worker"],"e":"👷‍♀️","c":1,"v":{"1F3FB":{"k":"female-construction-worker-1F3FB","n":"female-construction-worker","e":"👷🏻‍♀️"},"1F3FC":{"k":"female-construction-worker-1F3FC","n":"female-construction-worker","e":"👷🏼‍♀️"},"1F3FD":{"k":"female-construction-worker-1F3FD","n":"female-construction-worker","e":"👷🏽‍♀️"},"1F3FE":{"k":"female-construction-worker-1F3FE","n":"female-construction-worker","e":"👷🏾‍♀️"},"1F3FF":{"k":"female-construction-worker-1F3FF","n":"female-construction-worker","e":"👷🏿‍♀️"}}},{"n":["clock11"],"e":"🕚","c":3},{"n":["crystal_ball"],"e":"🔮","c":5},{"n":["flag-mp"],"e":"🇲🇵","c":4},{"n":["flag-mq"],"e":"🇲🇶","c":4},{"n":["prince"],"e":"🤴","c":1,"v":{"1F3FB":{"k":"prince-1F3FB","n":"prince","e":"🤴🏻"},"1F3FC":{"k":"prince-1F3FC","n":"prince","e":"🤴🏼"},"1F3FD":{"k":"prince-1F3FD","n":"prince","e":"🤴🏽"},"1F3FE":{"k":"prince-1F3FE","n":"prince","e":"🤴🏾"},"1F3FF":{"k":"prince-1F3FF","n":"prince","e":"🤴🏿"}}},{"n":["ok"],"e":"🆗","c":7},{"n":["clock1130"],"e":"🕦","c":3},{"n":["shopping_trolley"],"e":"🛒","c":5},{"n":["flag-mr"],"e":"🇲🇷","c":4},{"n":["princess"],"e":"👸","c":1,"v":{"1F3FB":{"k":"princess-1F3FB","n":"princess","e":"👸🏻"},"1F3FC":{"k":"princess-1F3FC","n":"princess","e":"👸🏼"},"1F3FD":{"k":"princess-1F3FD","n":"princess","e":"👸🏽"},"1F3FE":{"k":"princess-1F3FE","n":"princess","e":"👸🏾"},"1F3FF":{"k":"princess-1F3FF","n":"princess","e":"👸🏿"}}},{"n":["new_moon"],"e":"🌑","c":3},{"n":["parking"],"e":"🅿️","c":7},{"n":["sos"],"e":"🆘","c":7},{"n":["man_with_turban"],"e":"👳","c":1,"v":{"1F3FB":{"k":"man_with_turban-1F3FB","n":"man_with_turban","e":"👳🏻"},"1F3FC":{"k":"man_with_turban-1F3FC","n":"man_with_turban","e":"👳🏼"},"1F3FD":{"k":"man_with_turban-1F3FD","n":"man_with_turban","e":"👳🏽"},"1F3FE":{"k":"man_with_turban-1F3FE","n":"man_with_turban","e":"👳🏾"},"1F3FF":{"k":"man_with_turban-1F3FF","n":"man_with_turban","e":"👳🏿"}}},{"n":["flag-ms"],"e":"🇲🇸","c":4},{"n":["waxing_crescent_moon"],"e":"🌒","c":3},{"n":["up"],"e":"🆙","c":7},{"n":["first_quarter_moon"],"e":"🌓","c":3},{"n":["flag-mt"],"e":"🇲🇹","c":4},{"n":["man-wearing-turban"],"e":"👳‍♂️","c":1,"v":{"1F3FB":{"k":"man-wearing-turban-1F3FB","n":"man-wearing-turban","e":"👳🏻‍♂️"},"1F3FC":{"k":"man-wearing-turban-1F3FC","n":"man-wearing-turban","e":"👳🏼‍♂️"},"1F3FD":{"k":"man-wearing-turban-1F3FD","n":"man-wearing-turban","e":"👳🏽‍♂️"},"1F3FE":{"k":"man-wearing-turban-1F3FE","n":"man-wearing-turban","e":"👳🏾‍♂️"},"1F3FF":{"k":"man-wearing-turban-1F3FF","n":"man-wearing-turban","e":"👳🏿‍♂️"}}},{"n":["moon","waxing_gibbous_moon"],"e":"🌔","c":3},{"n":["woman-wearing-turban"],"e":"👳‍♀️","c":1,"v":{"1F3FB":{"k":"woman-wearing-turban-1F3FB","n":"woman-wearing-turban","e":"👳🏻‍♀️"},"1F3FC":{"k":"woman-wearing-turban-1F3FC","n":"woman-wearing-turban","e":"👳🏼‍♀️"},"1F3FD":{"k":"woman-wearing-turban-1F3FD","n":"woman-wearing-turban","e":"👳🏽‍♀️"},"1F3FE":{"k":"woman-wearing-turban-1F3FE","n":"woman-wearing-turban","e":"👳🏾‍♀️"},"1F3FF":{"k":"woman-wearing-turban-1F3FF","n":"woman-wearing-turban","e":"👳🏿‍♀️"}}},{"n":["vs"],"e":"🆚","c":7},{"n":["flag-mu"],"e":"🇲🇺","c":4},{"n":["man_with_gua_pi_mao"],"e":"👲","c":1,"v":{"1F3FB":{"k":"man_with_gua_pi_mao-1F3FB","n":"man_with_gua_pi_mao","e":"👲🏻"},"1F3FC":{"k":"man_with_gua_pi_mao-1F3FC","n":"man_with_gua_pi_mao","e":"👲🏼"},"1F3FD":{"k":"man_with_gua_pi_mao-1F3FD","n":"man_with_gua_pi_mao","e":"👲🏽"},"1F3FE":{"k":"man_with_gua_pi_mao-1F3FE","n":"man_with_gua_pi_mao","e":"👲🏾"},"1F3FF":{"k":"man_with_gua_pi_mao-1F3FF","n":"man_with_gua_pi_mao","e":"👲🏿"}}},{"n":["koko"],"e":"🈁","c":7},{"n":["full_moon"],"e":"🌕","c":3},{"n":["flag-mv"],"e":"🇲🇻","c":4},{"n":["person_with_headscarf"],"e":"🧕","c":1,"v":{"1F3FB":{"k":"person_with_headscarf-1F3FB","n":"person_with_headscarf","e":"🧕🏻"},"1F3FC":{"k":"person_with_headscarf-1F3FC","n":"person_with_headscarf","e":"🧕🏼"},"1F3FD":{"k":"person_with_headscarf-1F3FD","n":"person_with_headscarf","e":"🧕🏽"},"1F3FE":{"k":"person_with_headscarf-1F3FE","n":"person_with_headscarf","e":"🧕🏾"},"1F3FF":{"k":"person_with_headscarf-1F3FF","n":"person_with_headscarf","e":"🧕🏿"}}},{"n":["waning_gibbous_moon"],"e":"🌖","c":3},{"n":["sa"],"e":"🈂️","c":7},{"n":["flag-mw"],"e":"🇲🇼","c":4},{"n":["last_quarter_moon"],"e":"🌗","c":3},{"n":["u6708"],"e":"🈷️","c":7},{"n":["bearded_person"],"e":"🧔","c":1,"v":{"1F3FB":{"k":"bearded_person-1F3FB","n":"bearded_person","e":"🧔🏻"},"1F3FC":{"k":"bearded_person-1F3FC","n":"bearded_person","e":"🧔🏼"},"1F3FD":{"k":"bearded_person-1F3FD","n":"bearded_person","e":"🧔🏽"},"1F3FE":{"k":"bearded_person-1F3FE","n":"bearded_person","e":"🧔🏾"},"1F3FF":{"k":"bearded_person-1F3FF","n":"bearded_person","e":"🧔🏿"}}},{"n":["flag-mx"],"e":"🇲🇽","c":4},{"n":["u6709"],"e":"🈶","c":7},{"n":["person_with_blond_hair"],"e":"👱","c":1,"v":{"1F3FB":{"k":"person_with_blond_hair-1F3FB","n":"person_with_blond_hair","e":"👱🏻"},"1F3FC":{"k":"person_with_blond_hair-1F3FC","n":"person_with_blond_hair","e":"👱🏼"},"1F3FD":{"k":"person_with_blond_hair-1F3FD","n":"person_with_blond_hair","e":"👱🏽"},"1F3FE":{"k":"person_with_blond_hair-1F3FE","n":"person_with_blond_hair","e":"👱🏾"},"1F3FF":{"k":"person_with_blond_hair-1F3FF","n":"person_with_blond_hair","e":"👱🏿"}}},{"n":["waning_crescent_moon"],"e":"🌘","c":3},{"n":["flag-my"],"e":"🇲🇾","c":4},{"n":["u6307"],"e":"🈯","c":7},{"n":["blond-haired-man"],"e":"👱‍♂️","c":1,"v":{"1F3FB":{"k":"blond-haired-man-1F3FB","n":"blond-haired-man","e":"👱🏻‍♂️"},"1F3FC":{"k":"blond-haired-man-1F3FC","n":"blond-haired-man","e":"👱🏼‍♂️"},"1F3FD":{"k":"blond-haired-man-1F3FD","n":"blond-haired-man","e":"👱🏽‍♂️"},"1F3FE":{"k":"blond-haired-man-1F3FE","n":"blond-haired-man","e":"👱🏾‍♂️"},"1F3FF":{"k":"blond-haired-man-1F3FF","n":"blond-haired-man","e":"👱🏿‍♂️"}}},{"n":["crescent_moon"],"e":"🌙","c":3},{"n":["flag-mz"],"e":"🇲🇿","c":4},{"n":["new_moon_with_face"],"e":"🌚","c":3},{"n":["flag-na"],"e":"🇳🇦","c":4},{"n":["blond-haired-woman"],"e":"👱‍♀️","c":1,"v":{"1F3FB":{"k":"blond-haired-woman-1F3FB","n":"blond-haired-woman","e":"👱🏻‍♀️"},"1F3FC":{"k":"blond-haired-woman-1F3FC","n":"blond-haired-woman","e":"👱🏼‍♀️"},"1F3FD":{"k":"blond-haired-woman-1F3FD","n":"blond-haired-woman","e":"👱🏽‍♀️"},"1F3FE":{"k":"blond-haired-woman-1F3FE","n":"blond-haired-woman","e":"👱🏾‍♀️"},"1F3FF":{"k":"blond-haired-woman-1F3FF","n":"blond-haired-woman","e":"👱🏿‍♀️"}}},{"n":["ideograph_advantage"],"e":"🉐","c":7},{"n":["first_quarter_moon_with_face"],"e":"🌛","c":3},{"n":["man_in_tuxedo"],"e":"🤵","c":1,"v":{"1F3FB":{"k":"man_in_tuxedo-1F3FB","n":"man_in_tuxedo","e":"🤵🏻"},"1F3FC":{"k":"man_in_tuxedo-1F3FC","n":"man_in_tuxedo","e":"🤵🏼"},"1F3FD":{"k":"man_in_tuxedo-1F3FD","n":"man_in_tuxedo","e":"🤵🏽"},"1F3FE":{"k":"man_in_tuxedo-1F3FE","n":"man_in_tuxedo","e":"🤵🏾"},"1F3FF":{"k":"man_in_tuxedo-1F3FF","n":"man_in_tuxedo","e":"🤵🏿"}}},{"n":["flag-nc"],"e":"🇳🇨","c":4},{"n":["u5272"],"e":"🈹","c":7},{"n":["flag-ne"],"e":"🇳🇪","c":4},{"n":["last_quarter_moon_with_face"],"e":"🌜","c":3},{"n":["u7121"],"e":"🈚","c":7},{"n":["bride_with_veil"],"e":"👰","c":1,"v":{"1F3FB":{"k":"bride_with_veil-1F3FB","n":"bride_with_veil","e":"👰🏻"},"1F3FC":{"k":"bride_with_veil-1F3FC","n":"bride_with_veil","e":"👰🏼"},"1F3FD":{"k":"bride_with_veil-1F3FD","n":"bride_with_veil","e":"👰🏽"},"1F3FE":{"k":"bride_with_veil-1F3FE","n":"bride_with_veil","e":"👰🏾"},"1F3FF":{"k":"bride_with_veil-1F3FF","n":"bride_with_veil","e":"👰🏿"}}},{"n":["u7981"],"e":"🈲","c":7},{"n":["pregnant_woman"],"e":"🤰","c":1,"v":{"1F3FB":{"k":"pregnant_woman-1F3FB","n":"pregnant_woman","e":"🤰🏻"},"1F3FC":{"k":"pregnant_woman-1F3FC","n":"pregnant_woman","e":"🤰🏼"},"1F3FD":{"k":"pregnant_woman-1F3FD","n":"pregnant_woman","e":"🤰🏽"},"1F3FE":{"k":"pregnant_woman-1F3FE","n":"pregnant_woman","e":"🤰🏾"},"1F3FF":{"k":"pregnant_woman-1F3FF","n":"pregnant_woman","e":"🤰🏿"}}},{"n":["thermometer"],"e":"🌡️","c":3},{"n":["flag-nf"],"e":"🇳🇫","c":4},{"n":["sunny"],"e":"☀️","c":3},{"n":["accept"],"e":"🉑","c":7},{"n":["flag-ng"],"e":"🇳🇬","c":4},{"n":["breast-feeding"],"e":"🤱","c":1,"v":{"1F3FB":{"k":"breast-feeding-1F3FB","n":"breast-feeding","e":"🤱🏻"},"1F3FC":{"k":"breast-feeding-1F3FC","n":"breast-feeding","e":"🤱🏼"},"1F3FD":{"k":"breast-feeding-1F3FD","n":"breast-feeding","e":"🤱🏽"},"1F3FE":{"k":"breast-feeding-1F3FE","n":"breast-feeding","e":"🤱🏾"},"1F3FF":{"k":"breast-feeding-1F3FF","n":"breast-feeding","e":"🤱🏿"}}},{"n":["full_moon_with_face"],"e":"🌝","c":3},{"n":["flag-ni"],"e":"🇳🇮","c":4},{"n":["u7533"],"e":"🈸","c":7},{"n":["angel"],"e":"👼","c":1,"v":{"1F3FB":{"k":"angel-1F3FB","n":"angel","e":"👼🏻"},"1F3FC":{"k":"angel-1F3FC","n":"angel","e":"👼🏼"},"1F3FD":{"k":"angel-1F3FD","n":"angel","e":"👼🏽"},"1F3FE":{"k":"angel-1F3FE","n":"angel","e":"👼🏾"},"1F3FF":{"k":"angel-1F3FF","n":"angel","e":"👼🏿"}}},{"n":["sun_with_face"],"e":"🌞","c":3},{"n":["santa"],"e":"🎅","c":1,"v":{"1F3FB":{"k":"santa-1F3FB","n":"santa","e":"🎅🏻"},"1F3FC":{"k":"santa-1F3FC","n":"santa","e":"🎅🏼"},"1F3FD":{"k":"santa-1F3FD","n":"santa","e":"🎅🏽"},"1F3FE":{"k":"santa-1F3FE","n":"santa","e":"🎅🏾"},"1F3FF":{"k":"santa-1F3FF","n":"santa","e":"🎅🏿"}}},{"n":["u5408"],"e":"🈴","c":7},{"n":["flag-nl"],"e":"🇳🇱","c":4},{"n":["mrs_claus","mother_christmas"],"e":"🤶","c":1,"v":{"1F3FB":{"k":"mrs_claus-1F3FB","n":"mrs_claus","e":"🤶🏻"},"1F3FC":{"k":"mrs_claus-1F3FC","n":"mrs_claus","e":"🤶🏼"},"1F3FD":{"k":"mrs_claus-1F3FD","n":"mrs_claus","e":"🤶🏽"},"1F3FE":{"k":"mrs_claus-1F3FE","n":"mrs_claus","e":"🤶🏾"},"1F3FF":{"k":"mrs_claus-1F3FF","n":"mrs_claus","e":"🤶🏿"}}},{"n":["u7a7a"],"e":"🈳","c":7},{"n":["star"],"e":"⭐","c":3},{"n":["flag-no"],"e":"🇳🇴","c":4},{"n":["mage"],"e":"🧙","c":1,"v":{"1F3FB":{"k":"mage-1F3FB","n":"mage","e":"🧙🏻"},"1F3FC":{"k":"mage-1F3FC","n":"mage","e":"🧙🏼"},"1F3FD":{"k":"mage-1F3FD","n":"mage","e":"🧙🏽"},"1F3FE":{"k":"mage-1F3FE","n":"mage","e":"🧙🏾"},"1F3FF":{"k":"mage-1F3FF","n":"mage","e":"🧙🏿"}}},{"n":["star2"],"e":"🌟","c":3},{"n":["flag-np"],"e":"🇳🇵","c":4},{"n":["congratulations"],"e":"㊗️","c":7},{"n":["flag-nr"],"e":"🇳🇷","c":4},{"n":["stars"],"e":"🌠","c":3},{"n":["female_mage"],"e":"🧙‍♀️","c":1,"v":{"1F3FB":{"k":"female_mage-1F3FB","n":"female_mage","e":"🧙🏻‍♀️"},"1F3FC":{"k":"female_mage-1F3FC","n":"female_mage","e":"🧙🏼‍♀️"},"1F3FD":{"k":"female_mage-1F3FD","n":"female_mage","e":"🧙🏽‍♀️"},"1F3FE":{"k":"female_mage-1F3FE","n":"female_mage","e":"🧙🏾‍♀️"},"1F3FF":{"k":"female_mage-1F3FF","n":"female_mage","e":"🧙🏿‍♀️"}}},{"n":["secret"],"e":"㊙️","c":7},{"n":["flag-nu"],"e":"🇳🇺","c":4},{"n":["u55b6"],"e":"🈺","c":7},{"n":["male_mage"],"e":"🧙‍♂️","c":1,"v":{"1F3FB":{"k":"male_mage-1F3FB","n":"male_mage","e":"🧙🏻‍♂️"},"1F3FC":{"k":"male_mage-1F3FC","n":"male_mage","e":"🧙🏼‍♂️"},"1F3FD":{"k":"male_mage-1F3FD","n":"male_mage","e":"🧙🏽‍♂️"},"1F3FE":{"k":"male_mage-1F3FE","n":"male_mage","e":"🧙🏾‍♂️"},"1F3FF":{"k":"male_mage-1F3FF","n":"male_mage","e":"🧙🏿‍♂️"}}},{"n":["cloud"],"e":"☁️","c":3},{"n":["flag-nz"],"e":"🇳🇿","c":4},{"n":["partly_sunny"],"e":"⛅","c":3},{"n":["fairy"],"e":"🧚","c":1,"v":{"1F3FB":{"k":"fairy-1F3FB","n":"fairy","e":"🧚🏻"},"1F3FC":{"k":"fairy-1F3FC","n":"fairy","e":"🧚🏼"},"1F3FD":{"k":"fairy-1F3FD","n":"fairy","e":"🧚🏽"},"1F3FE":{"k":"fairy-1F3FE","n":"fairy","e":"🧚🏾"},"1F3FF":{"k":"fairy-1F3FF","n":"fairy","e":"🧚🏿"}}},{"n":["u6e80"],"e":"🈵","c":7},{"n":["black_small_square"],"e":"▪️","c":7},{"n":["thunder_cloud_and_rain"],"e":"⛈️","c":3},{"n":["female_fairy"],"e":"🧚‍♀️","c":1,"v":{"1F3FB":{"k":"female_fairy-1F3FB","n":"female_fairy","e":"🧚🏻‍♀️"},"1F3FC":{"k":"female_fairy-1F3FC","n":"female_fairy","e":"🧚🏼‍♀️"},"1F3FD":{"k":"female_fairy-1F3FD","n":"female_fairy","e":"🧚🏽‍♀️"},"1F3FE":{"k":"female_fairy-1F3FE","n":"female_fairy","e":"🧚🏾‍♀️"},"1F3FF":{"k":"female_fairy-1F3FF","n":"female_fairy","e":"🧚🏿‍♀️"}}},{"n":["flag-om"],"e":"🇴🇲","c":4},{"n":["white_small_square"],"e":"▫️","c":7},{"n":["flag-pa"],"e":"🇵🇦","c":4},{"n":["mostly_sunny","sun_small_cloud"],"e":"🌤️","c":3},{"n":["male_fairy"],"e":"🧚‍♂️","c":1,"v":{"1F3FB":{"k":"male_fairy-1F3FB","n":"male_fairy","e":"🧚🏻‍♂️"},"1F3FC":{"k":"male_fairy-1F3FC","n":"male_fairy","e":"🧚🏼‍♂️"},"1F3FD":{"k":"male_fairy-1F3FD","n":"male_fairy","e":"🧚🏽‍♂️"},"1F3FE":{"k":"male_fairy-1F3FE","n":"male_fairy","e":"🧚🏾‍♂️"},"1F3FF":{"k":"male_fairy-1F3FF","n":"male_fairy","e":"🧚🏿‍♂️"}}},{"n":["barely_sunny","sun_behind_cloud"],"e":"🌥️","c":3},{"n":["white_medium_square"],"e":"◻️","c":7},{"n":["flag-pe"],"e":"🇵🇪","c":4},{"n":["vampire"],"e":"🧛","c":1,"v":{"1F3FB":{"k":"vampire-1F3FB","n":"vampire","e":"🧛🏻"},"1F3FC":{"k":"vampire-1F3FC","n":"vampire","e":"🧛🏼"},"1F3FD":{"k":"vampire-1F3FD","n":"vampire","e":"🧛🏽"},"1F3FE":{"k":"vampire-1F3FE","n":"vampire","e":"🧛🏾"},"1F3FF":{"k":"vampire-1F3FF","n":"vampire","e":"🧛🏿"}}},{"n":["female_vampire"],"e":"🧛‍♀️","c":1,"v":{"1F3FB":{"k":"female_vampire-1F3FB","n":"female_vampire","e":"🧛🏻‍♀️"},"1F3FC":{"k":"female_vampire-1F3FC","n":"female_vampire","e":"🧛🏼‍♀️"},"1F3FD":{"k":"female_vampire-1F3FD","n":"female_vampire","e":"🧛🏽‍♀️"},"1F3FE":{"k":"female_vampire-1F3FE","n":"female_vampire","e":"🧛🏾‍♀️"},"1F3FF":{"k":"female_vampire-1F3FF","n":"female_vampire","e":"🧛🏿‍♀️"}}},{"n":["partly_sunny_rain","sun_behind_rain_cloud"],"e":"🌦️","c":3},{"n":["flag-pf"],"e":"🇵🇫","c":4},{"n":["black_medium_square"],"e":"◼️","c":7},{"n":["white_medium_small_square"],"e":"◽","c":7},{"n":["rain_cloud"],"e":"🌧️","c":3},{"n":["flag-pg"],"e":"🇵🇬","c":4},{"n":["male_vampire"],"e":"🧛‍♂️","c":1,"v":{"1F3FB":{"k":"male_vampire-1F3FB","n":"male_vampire","e":"🧛🏻‍♂️"},"1F3FC":{"k":"male_vampire-1F3FC","n":"male_vampire","e":"🧛🏼‍♂️"},"1F3FD":{"k":"male_vampire-1F3FD","n":"male_vampire","e":"🧛🏽‍♂️"},"1F3FE":{"k":"male_vampire-1F3FE","n":"male_vampire","e":"🧛🏾‍♂️"},"1F3FF":{"k":"male_vampire-1F3FF","n":"male_vampire","e":"🧛🏿‍♂️"}}},{"n":["flag-ph"],"e":"🇵🇭","c":4},{"n":["merperson"],"e":"🧜","c":1,"v":{"1F3FB":{"k":"merperson-1F3FB","n":"merperson","e":"🧜🏻"},"1F3FC":{"k":"merperson-1F3FC","n":"merperson","e":"🧜🏼"},"1F3FD":{"k":"merperson-1F3FD","n":"merperson","e":"🧜🏽"},"1F3FE":{"k":"merperson-1F3FE","n":"merperson","e":"🧜🏾"},"1F3FF":{"k":"merperson-1F3FF","n":"merperson","e":"🧜🏿"}}},{"n":["black_medium_small_square"],"e":"◾","c":7},{"n":["snow_cloud"],"e":"🌨️","c":3},{"n":["lightning","lightning_cloud"],"e":"🌩️","c":3},{"n":["black_large_square"],"e":"⬛","c":7},{"n":["mermaid"],"e":"🧜‍♀️","c":1,"v":{"1F3FB":{"k":"mermaid-1F3FB","n":"mermaid","e":"🧜🏻‍♀️"},"1F3FC":{"k":"mermaid-1F3FC","n":"mermaid","e":"🧜🏼‍♀️"},"1F3FD":{"k":"mermaid-1F3FD","n":"mermaid","e":"🧜🏽‍♀️"},"1F3FE":{"k":"mermaid-1F3FE","n":"mermaid","e":"🧜🏾‍♀️"},"1F3FF":{"k":"mermaid-1F3FF","n":"mermaid","e":"🧜🏿‍♀️"}}},{"n":["flag-pk"],"e":"🇵🇰","c":4},{"n":["merman"],"e":"🧜‍♂️","c":1,"v":{"1F3FB":{"k":"merman-1F3FB","n":"merman","e":"🧜🏻‍♂️"},"1F3FC":{"k":"merman-1F3FC","n":"merman","e":"🧜🏼‍♂️"},"1F3FD":{"k":"merman-1F3FD","n":"merman","e":"🧜🏽‍♂️"},"1F3FE":{"k":"merman-1F3FE","n":"merman","e":"🧜🏾‍♂️"},"1F3FF":{"k":"merman-1F3FF","n":"merman","e":"🧜🏿‍♂️"}}},{"n":["white_large_square"],"e":"⬜","c":7},{"n":["tornado","tornado_cloud"],"e":"🌪️","c":3},{"n":["flag-pl"],"e":"🇵🇱","c":4},{"n":["elf"],"e":"🧝","c":1,"v":{"1F3FB":{"k":"elf-1F3FB","n":"elf","e":"🧝🏻"},"1F3FC":{"k":"elf-1F3FC","n":"elf","e":"🧝🏼"},"1F3FD":{"k":"elf-1F3FD","n":"elf","e":"🧝🏽"},"1F3FE":{"k":"elf-1F3FE","n":"elf","e":"🧝🏾"},"1F3FF":{"k":"elf-1F3FF","n":"elf","e":"🧝🏿"}}},{"n":["fog"],"e":"🌫️","c":3},{"n":["large_orange_diamond"],"e":"🔶","c":7},{"n":["flag-pm"],"e":"🇵🇲","c":4},{"n":["flag-pn"],"e":"🇵🇳","c":4},{"n":["wind_blowing_face"],"e":"🌬️","c":3},{"n":["female_elf"],"e":"🧝‍♀️","c":1,"v":{"1F3FB":{"k":"female_elf-1F3FB","n":"female_elf","e":"🧝🏻‍♀️"},"1F3FC":{"k":"female_elf-1F3FC","n":"female_elf","e":"🧝🏼‍♀️"},"1F3FD":{"k":"female_elf-1F3FD","n":"female_elf","e":"🧝🏽‍♀️"},"1F3FE":{"k":"female_elf-1F3FE","n":"female_elf","e":"🧝🏾‍♀️"},"1F3FF":{"k":"female_elf-1F3FF","n":"female_elf","e":"🧝🏿‍♀️"}}},{"n":["large_blue_diamond"],"e":"🔷","c":7},{"n":["male_elf"],"e":"🧝‍♂️","c":1,"v":{"1F3FB":{"k":"male_elf-1F3FB","n":"male_elf","e":"🧝🏻‍♂️"},"1F3FC":{"k":"male_elf-1F3FC","n":"male_elf","e":"🧝🏼‍♂️"},"1F3FD":{"k":"male_elf-1F3FD","n":"male_elf","e":"🧝🏽‍♂️"},"1F3FE":{"k":"male_elf-1F3FE","n":"male_elf","e":"🧝🏾‍♂️"},"1F3FF":{"k":"male_elf-1F3FF","n":"male_elf","e":"🧝🏿‍♂️"}}},{"n":["small_orange_diamond"],"e":"🔸","c":7},{"n":["flag-pr"],"e":"🇵🇷","c":4},{"n":["cyclone"],"e":"🌀","c":3},{"n":["rainbow"],"e":"🌈","c":3},{"n":["small_blue_diamond"],"e":"🔹","c":7},{"n":["genie"],"e":"🧞","c":1},{"n":["flag-ps"],"e":"🇵🇸","c":4},{"n":["small_red_triangle"],"e":"🔺","c":7},{"n":["closed_umbrella"],"e":"🌂","c":3},{"n":["female_genie"],"e":"🧞‍♀️","c":1},{"n":["flag-pt"],"e":"🇵🇹","c":4},{"n":["flag-pw"],"e":"🇵🇼","c":4},{"n":["small_red_triangle_down"],"e":"🔻","c":7},{"n":["umbrella"],"e":"☂️","c":3},{"n":["male_genie"],"e":"🧞‍♂️","c":1},{"n":["zombie"],"e":"🧟","c":1},{"n":["flag-py"],"e":"🇵🇾","c":4},{"n":["diamond_shape_with_a_dot_inside"],"e":"💠","c":7},{"n":["umbrella_with_rain_drops"],"e":"☔","c":3},{"n":["radio_button"],"e":"🔘","c":7},{"n":["female_zombie"],"e":"🧟‍♀️","c":1},{"n":["flag-qa"],"e":"🇶🇦","c":4},{"n":["umbrella_on_ground"],"e":"⛱️","c":3},{"n":["black_square_button"],"e":"🔲","c":7},{"n":["zap"],"e":"⚡","c":3},{"n":["male_zombie"],"e":"🧟‍♂️","c":1},{"n":["flag-re"],"e":"🇷🇪","c":4},{"n":["flag-ro"],"e":"🇷🇴","c":4},{"n":["snowflake"],"e":"❄️","c":3},{"n":["white_square_button"],"e":"🔳","c":7},{"n":["person_frowning"],"e":"🙍","c":1,"v":{"1F3FB":{"k":"person_frowning-1F3FB","n":"person_frowning","e":"🙍🏻"},"1F3FC":{"k":"person_frowning-1F3FC","n":"person_frowning","e":"🙍🏼"},"1F3FD":{"k":"person_frowning-1F3FD","n":"person_frowning","e":"🙍🏽"},"1F3FE":{"k":"person_frowning-1F3FE","n":"person_frowning","e":"🙍🏾"},"1F3FF":{"k":"person_frowning-1F3FF","n":"person_frowning","e":"🙍🏿"}}},{"n":["flag-rs"],"e":"🇷🇸","c":4},{"n":["man-frowning"],"e":"🙍‍♂️","c":1,"v":{"1F3FB":{"k":"man-frowning-1F3FB","n":"man-frowning","e":"🙍🏻‍♂️"},"1F3FC":{"k":"man-frowning-1F3FC","n":"man-frowning","e":"🙍🏼‍♂️"},"1F3FD":{"k":"man-frowning-1F3FD","n":"man-frowning","e":"🙍🏽‍♂️"},"1F3FE":{"k":"man-frowning-1F3FE","n":"man-frowning","e":"🙍🏾‍♂️"},"1F3FF":{"k":"man-frowning-1F3FF","n":"man-frowning","e":"🙍🏿‍♂️"}}},{"n":["white_circle"],"e":"⚪","c":7},{"n":["snowman"],"e":"☃️","c":3},{"n":["snowman_without_snow"],"e":"⛄","c":3},{"n":["ru","flag-ru"],"e":"🇷🇺","c":4},{"n":["black_circle"],"e":"⚫","c":7},{"n":["woman-frowning"],"e":"🙍‍♀️","c":1,"v":{"1F3FB":{"k":"woman-frowning-1F3FB","n":"woman-frowning","e":"🙍🏻‍♀️"},"1F3FC":{"k":"woman-frowning-1F3FC","n":"woman-frowning","e":"🙍🏼‍♀️"},"1F3FD":{"k":"woman-frowning-1F3FD","n":"woman-frowning","e":"🙍🏽‍♀️"},"1F3FE":{"k":"woman-frowning-1F3FE","n":"woman-frowning","e":"🙍🏾‍♀️"},"1F3FF":{"k":"woman-frowning-1F3FF","n":"woman-frowning","e":"🙍🏿‍♀️"}}},{"n":["flag-rw"],"e":"🇷🇼","c":4},{"n":["comet"],"e":"☄️","c":3},{"n":["person_with_pouting_face"],"e":"🙎","c":1,"v":{"1F3FB":{"k":"person_with_pouting_face-1F3FB","n":"person_with_pouting_face","e":"🙎🏻"},"1F3FC":{"k":"person_with_pouting_face-1F3FC","n":"person_with_pouting_face","e":"🙎🏼"},"1F3FD":{"k":"person_with_pouting_face-1F3FD","n":"person_with_pouting_face","e":"🙎🏽"},"1F3FE":{"k":"person_with_pouting_face-1F3FE","n":"person_with_pouting_face","e":"🙎🏾"},"1F3FF":{"k":"person_with_pouting_face-1F3FF","n":"person_with_pouting_face","e":"🙎🏿"}}},{"n":["red_circle"],"e":"🔴","c":7},{"n":["large_blue_circle"],"e":"🔵","c":7},{"n":["man-pouting"],"e":"🙎‍♂️","c":1,"v":{"1F3FB":{"k":"man-pouting-1F3FB","n":"man-pouting","e":"🙎🏻‍♂️"},"1F3FC":{"k":"man-pouting-1F3FC","n":"man-pouting","e":"🙎🏼‍♂️"},"1F3FD":{"k":"man-pouting-1F3FD","n":"man-pouting","e":"🙎🏽‍♂️"},"1F3FE":{"k":"man-pouting-1F3FE","n":"man-pouting","e":"🙎🏾‍♂️"},"1F3FF":{"k":"man-pouting-1F3FF","n":"man-pouting","e":"🙎🏿‍♂️"}}},{"n":["flag-sa"],"e":"🇸🇦","c":4},{"n":["fire"],"e":"🔥","c":3},{"n":["woman-pouting"],"e":"🙎‍♀️","c":1,"v":{"1F3FB":{"k":"woman-pouting-1F3FB","n":"woman-pouting","e":"🙎🏻‍♀️"},"1F3FC":{"k":"woman-pouting-1F3FC","n":"woman-pouting","e":"🙎🏼‍♀️"},"1F3FD":{"k":"woman-pouting-1F3FD","n":"woman-pouting","e":"🙎🏽‍♀️"},"1F3FE":{"k":"woman-pouting-1F3FE","n":"woman-pouting","e":"🙎🏾‍♀️"},"1F3FF":{"k":"woman-pouting-1F3FF","n":"woman-pouting","e":"🙎🏿‍♀️"}}},{"n":["flag-sb"],"e":"🇸🇧","c":4},{"n":["droplet"],"e":"💧","c":3},{"n":["no_good"],"e":"🙅","c":1,"v":{"1F3FB":{"k":"no_good-1F3FB","n":"no_good","e":"🙅🏻"},"1F3FC":{"k":"no_good-1F3FC","n":"no_good","e":"🙅🏼"},"1F3FD":{"k":"no_good-1F3FD","n":"no_good","e":"🙅🏽"},"1F3FE":{"k":"no_good-1F3FE","n":"no_good","e":"🙅🏾"},"1F3FF":{"k":"no_good-1F3FF","n":"no_good","e":"🙅🏿"}}},{"n":["flag-sc"],"e":"🇸🇨","c":4},{"n":["ocean"],"e":"🌊","c":3},{"n":["man-gesturing-no"],"e":"🙅‍♂️","c":1,"v":{"1F3FB":{"k":"man-gesturing-no-1F3FB","n":"man-gesturing-no","e":"🙅🏻‍♂️"},"1F3FC":{"k":"man-gesturing-no-1F3FC","n":"man-gesturing-no","e":"🙅🏼‍♂️"},"1F3FD":{"k":"man-gesturing-no-1F3FD","n":"man-gesturing-no","e":"🙅🏽‍♂️"},"1F3FE":{"k":"man-gesturing-no-1F3FE","n":"man-gesturing-no","e":"🙅🏾‍♂️"},"1F3FF":{"k":"man-gesturing-no-1F3FF","n":"man-gesturing-no","e":"🙅🏿‍♂️"}}},{"n":["flag-sd"],"e":"🇸🇩","c":4},{"n":["woman-gesturing-no"],"e":"🙅‍♀️","c":1,"v":{"1F3FB":{"k":"woman-gesturing-no-1F3FB","n":"woman-gesturing-no","e":"🙅🏻‍♀️"},"1F3FC":{"k":"woman-gesturing-no-1F3FC","n":"woman-gesturing-no","e":"🙅🏼‍♀️"},"1F3FD":{"k":"woman-gesturing-no-1F3FD","n":"woman-gesturing-no","e":"🙅🏽‍♀️"},"1F3FE":{"k":"woman-gesturing-no-1F3FE","n":"woman-gesturing-no","e":"🙅🏾‍♀️"},"1F3FF":{"k":"woman-gesturing-no-1F3FF","n":"woman-gesturing-no","e":"🙅🏿‍♀️"}}},{"n":["flag-se"],"e":"🇸🇪","c":4},{"n":["flag-sg"],"e":"🇸🇬","c":4},{"n":["ok_woman"],"e":"🙆","c":1,"v":{"1F3FB":{"k":"ok_woman-1F3FB","n":"ok_woman","e":"🙆🏻"},"1F3FC":{"k":"ok_woman-1F3FC","n":"ok_woman","e":"🙆🏼"},"1F3FD":{"k":"ok_woman-1F3FD","n":"ok_woman","e":"🙆🏽"},"1F3FE":{"k":"ok_woman-1F3FE","n":"ok_woman","e":"🙆🏾"},"1F3FF":{"k":"ok_woman-1F3FF","n":"ok_woman","e":"🙆🏿"}}},{"n":["flag-sh"],"e":"🇸🇭","c":4},{"n":["man-gesturing-ok"],"e":"🙆‍♂️","c":1,"v":{"1F3FB":{"k":"man-gesturing-ok-1F3FB","n":"man-gesturing-ok","e":"🙆🏻‍♂️"},"1F3FC":{"k":"man-gesturing-ok-1F3FC","n":"man-gesturing-ok","e":"🙆🏼‍♂️"},"1F3FD":{"k":"man-gesturing-ok-1F3FD","n":"man-gesturing-ok","e":"🙆🏽‍♂️"},"1F3FE":{"k":"man-gesturing-ok-1F3FE","n":"man-gesturing-ok","e":"🙆🏾‍♂️"},"1F3FF":{"k":"man-gesturing-ok-1F3FF","n":"man-gesturing-ok","e":"🙆🏿‍♂️"}}},{"n":["flag-si"],"e":"🇸🇮","c":4},{"n":["woman-gesturing-ok"],"e":"🙆‍♀️","c":1,"v":{"1F3FB":{"k":"woman-gesturing-ok-1F3FB","n":"woman-gesturing-ok","e":"🙆🏻‍♀️"},"1F3FC":{"k":"woman-gesturing-ok-1F3FC","n":"woman-gesturing-ok","e":"🙆🏼‍♀️"},"1F3FD":{"k":"woman-gesturing-ok-1F3FD","n":"woman-gesturing-ok","e":"🙆🏽‍♀️"},"1F3FE":{"k":"woman-gesturing-ok-1F3FE","n":"woman-gesturing-ok","e":"🙆🏾‍♀️"},"1F3FF":{"k":"woman-gesturing-ok-1F3FF","n":"woman-gesturing-ok","e":"🙆🏿‍♀️"}}},{"n":["information_desk_person"],"e":"💁","c":1,"v":{"1F3FB":{"k":"information_desk_person-1F3FB","n":"information_desk_person","e":"💁🏻"},"1F3FC":{"k":"information_desk_person-1F3FC","n":"information_desk_person","e":"💁🏼"},"1F3FD":{"k":"information_desk_person-1F3FD","n":"information_desk_person","e":"💁🏽"},"1F3FE":{"k":"information_desk_person-1F3FE","n":"information_desk_person","e":"💁🏾"},"1F3FF":{"k":"information_desk_person-1F3FF","n":"information_desk_person","e":"💁🏿"}}},{"n":["flag-sj"],"e":"🇸🇯","c":4},{"n":["man-tipping-hand"],"e":"💁‍♂️","c":1,"v":{"1F3FB":{"k":"man-tipping-hand-1F3FB","n":"man-tipping-hand","e":"💁🏻‍♂️"},"1F3FC":{"k":"man-tipping-hand-1F3FC","n":"man-tipping-hand","e":"💁🏼‍♂️"},"1F3FD":{"k":"man-tipping-hand-1F3FD","n":"man-tipping-hand","e":"💁🏽‍♂️"},"1F3FE":{"k":"man-tipping-hand-1F3FE","n":"man-tipping-hand","e":"💁🏾‍♂️"},"1F3FF":{"k":"man-tipping-hand-1F3FF","n":"man-tipping-hand","e":"💁🏿‍♂️"}}},{"n":["flag-sk"],"e":"🇸🇰","c":4},{"n":["flag-sl"],"e":"🇸🇱","c":4},{"n":["woman-tipping-hand"],"e":"💁‍♀️","c":1,"v":{"1F3FB":{"k":"woman-tipping-hand-1F3FB","n":"woman-tipping-hand","e":"💁🏻‍♀️"},"1F3FC":{"k":"woman-tipping-hand-1F3FC","n":"woman-tipping-hand","e":"💁🏼‍♀️"},"1F3FD":{"k":"woman-tipping-hand-1F3FD","n":"woman-tipping-hand","e":"💁🏽‍♀️"},"1F3FE":{"k":"woman-tipping-hand-1F3FE","n":"woman-tipping-hand","e":"💁🏾‍♀️"},"1F3FF":{"k":"woman-tipping-hand-1F3FF","n":"woman-tipping-hand","e":"💁🏿‍♀️"}}},{"n":["flag-sm"],"e":"🇸🇲","c":4},{"n":["raising_hand"],"e":"🙋","c":1,"v":{"1F3FB":{"k":"raising_hand-1F3FB","n":"raising_hand","e":"🙋🏻"},"1F3FC":{"k":"raising_hand-1F3FC","n":"raising_hand","e":"🙋🏼"},"1F3FD":{"k":"raising_hand-1F3FD","n":"raising_hand","e":"🙋🏽"},"1F3FE":{"k":"raising_hand-1F3FE","n":"raising_hand","e":"🙋🏾"},"1F3FF":{"k":"raising_hand-1F3FF","n":"raising_hand","e":"🙋🏿"}}},{"n":["flag-sn"],"e":"🇸🇳","c":4},{"n":["man-raising-hand"],"e":"🙋‍♂️","c":1,"v":{"1F3FB":{"k":"man-raising-hand-1F3FB","n":"man-raising-hand","e":"🙋🏻‍♂️"},"1F3FC":{"k":"man-raising-hand-1F3FC","n":"man-raising-hand","e":"🙋🏼‍♂️"},"1F3FD":{"k":"man-raising-hand-1F3FD","n":"man-raising-hand","e":"🙋🏽‍♂️"},"1F3FE":{"k":"man-raising-hand-1F3FE","n":"man-raising-hand","e":"🙋🏾‍♂️"},"1F3FF":{"k":"man-raising-hand-1F3FF","n":"man-raising-hand","e":"🙋🏿‍♂️"}}},{"n":["flag-so"],"e":"🇸🇴","c":4},{"n":["woman-raising-hand"],"e":"🙋‍♀️","c":1,"v":{"1F3FB":{"k":"woman-raising-hand-1F3FB","n":"woman-raising-hand","e":"🙋🏻‍♀️"},"1F3FC":{"k":"woman-raising-hand-1F3FC","n":"woman-raising-hand","e":"🙋🏼‍♀️"},"1F3FD":{"k":"woman-raising-hand-1F3FD","n":"woman-raising-hand","e":"🙋🏽‍♀️"},"1F3FE":{"k":"woman-raising-hand-1F3FE","n":"woman-raising-hand","e":"🙋🏾‍♀️"},"1F3FF":{"k":"woman-raising-hand-1F3FF","n":"woman-raising-hand","e":"🙋🏿‍♀️"}}},{"n":["flag-sr"],"e":"🇸🇷","c":4},{"n":["bow"],"e":"🙇","c":1,"v":{"1F3FB":{"k":"bow-1F3FB","n":"bow","e":"🙇🏻"},"1F3FC":{"k":"bow-1F3FC","n":"bow","e":"🙇🏼"},"1F3FD":{"k":"bow-1F3FD","n":"bow","e":"🙇🏽"},"1F3FE":{"k":"bow-1F3FE","n":"bow","e":"🙇🏾"},"1F3FF":{"k":"bow-1F3FF","n":"bow","e":"🙇🏿"}}},{"n":["man-bowing"],"e":"🙇‍♂️","c":1,"v":{"1F3FB":{"k":"man-bowing-1F3FB","n":"man-bowing","e":"🙇🏻‍♂️"},"1F3FC":{"k":"man-bowing-1F3FC","n":"man-bowing","e":"🙇🏼‍♂️"},"1F3FD":{"k":"man-bowing-1F3FD","n":"man-bowing","e":"🙇🏽‍♂️"},"1F3FE":{"k":"man-bowing-1F3FE","n":"man-bowing","e":"🙇🏾‍♂️"},"1F3FF":{"k":"man-bowing-1F3FF","n":"man-bowing","e":"🙇🏿‍♂️"}}},{"n":["flag-ss"],"e":"🇸🇸","c":4},{"n":["woman-bowing"],"e":"🙇‍♀️","c":1,"v":{"1F3FB":{"k":"woman-bowing-1F3FB","n":"woman-bowing","e":"🙇🏻‍♀️"},"1F3FC":{"k":"woman-bowing-1F3FC","n":"woman-bowing","e":"🙇🏼‍♀️"},"1F3FD":{"k":"woman-bowing-1F3FD","n":"woman-bowing","e":"🙇🏽‍♀️"},"1F3FE":{"k":"woman-bowing-1F3FE","n":"woman-bowing","e":"🙇🏾‍♀️"},"1F3FF":{"k":"woman-bowing-1F3FF","n":"woman-bowing","e":"🙇🏿‍♀️"}}},{"n":["flag-st"],"e":"🇸🇹","c":4},{"n":["face_palm"],"e":"🤦","c":1,"v":{"1F3FB":{"k":"face_palm-1F3FB","n":"face_palm","e":"🤦🏻"},"1F3FC":{"k":"face_palm-1F3FC","n":"face_palm","e":"🤦🏼"},"1F3FD":{"k":"face_palm-1F3FD","n":"face_palm","e":"🤦🏽"},"1F3FE":{"k":"face_palm-1F3FE","n":"face_palm","e":"🤦🏾"},"1F3FF":{"k":"face_palm-1F3FF","n":"face_palm","e":"🤦🏿"}}},{"n":["flag-sv"],"e":"🇸🇻","c":4},{"n":["man-facepalming"],"e":"🤦‍♂️","c":1,"v":{"1F3FB":{"k":"man-facepalming-1F3FB","n":"man-facepalming","e":"🤦🏻‍♂️"},"1F3FC":{"k":"man-facepalming-1F3FC","n":"man-facepalming","e":"🤦🏼‍♂️"},"1F3FD":{"k":"man-facepalming-1F3FD","n":"man-facepalming","e":"🤦🏽‍♂️"},"1F3FE":{"k":"man-facepalming-1F3FE","n":"man-facepalming","e":"🤦🏾‍♂️"},"1F3FF":{"k":"man-facepalming-1F3FF","n":"man-facepalming","e":"🤦🏿‍♂️"}}},{"n":["flag-sx"],"e":"🇸🇽","c":4},{"n":["flag-sy"],"e":"🇸🇾","c":4},{"n":["woman-facepalming"],"e":"🤦‍♀️","c":1,"v":{"1F3FB":{"k":"woman-facepalming-1F3FB","n":"woman-facepalming","e":"🤦🏻‍♀️"},"1F3FC":{"k":"woman-facepalming-1F3FC","n":"woman-facepalming","e":"🤦🏼‍♀️"},"1F3FD":{"k":"woman-facepalming-1F3FD","n":"woman-facepalming","e":"🤦🏽‍♀️"},"1F3FE":{"k":"woman-facepalming-1F3FE","n":"woman-facepalming","e":"🤦🏾‍♀️"},"1F3FF":{"k":"woman-facepalming-1F3FF","n":"woman-facepalming","e":"🤦🏿‍♀️"}}},{"n":["shrug"],"e":"🤷","c":1,"v":{"1F3FB":{"k":"shrug-1F3FB","n":"shrug","e":"🤷🏻"},"1F3FC":{"k":"shrug-1F3FC","n":"shrug","e":"🤷🏼"},"1F3FD":{"k":"shrug-1F3FD","n":"shrug","e":"🤷🏽"},"1F3FE":{"k":"shrug-1F3FE","n":"shrug","e":"🤷🏾"},"1F3FF":{"k":"shrug-1F3FF","n":"shrug","e":"🤷🏿"}}},{"n":["flag-sz"],"e":"🇸🇿","c":4},{"n":["flag-ta"],"e":"🇹🇦","c":4},{"n":["man-shrugging"],"e":"🤷‍♂️","c":1,"v":{"1F3FB":{"k":"man-shrugging-1F3FB","n":"man-shrugging","e":"🤷🏻‍♂️"},"1F3FC":{"k":"man-shrugging-1F3FC","n":"man-shrugging","e":"🤷🏼‍♂️"},"1F3FD":{"k":"man-shrugging-1F3FD","n":"man-shrugging","e":"🤷🏽‍♂️"},"1F3FE":{"k":"man-shrugging-1F3FE","n":"man-shrugging","e":"🤷🏾‍♂️"},"1F3FF":{"k":"man-shrugging-1F3FF","n":"man-shrugging","e":"🤷🏿‍♂️"}}},{"n":["woman-shrugging"],"e":"🤷‍♀️","c":1,"v":{"1F3FB":{"k":"woman-shrugging-1F3FB","n":"woman-shrugging","e":"🤷🏻‍♀️"},"1F3FC":{"k":"woman-shrugging-1F3FC","n":"woman-shrugging","e":"🤷🏼‍♀️"},"1F3FD":{"k":"woman-shrugging-1F3FD","n":"woman-shrugging","e":"🤷🏽‍♀️"},"1F3FE":{"k":"woman-shrugging-1F3FE","n":"woman-shrugging","e":"🤷🏾‍♀️"},"1F3FF":{"k":"woman-shrugging-1F3FF","n":"woman-shrugging","e":"🤷🏿‍♀️"}}},{"n":["flag-tc"],"e":"🇹🇨","c":4},{"n":["massage"],"e":"💆","c":1,"v":{"1F3FB":{"k":"massage-1F3FB","n":"massage","e":"💆🏻"},"1F3FC":{"k":"massage-1F3FC","n":"massage","e":"💆🏼"},"1F3FD":{"k":"massage-1F3FD","n":"massage","e":"💆🏽"},"1F3FE":{"k":"massage-1F3FE","n":"massage","e":"💆🏾"},"1F3FF":{"k":"massage-1F3FF","n":"massage","e":"💆🏿"}}},{"n":["flag-td"],"e":"🇹🇩","c":4},{"n":["man-getting-massage"],"e":"💆‍♂️","c":1,"v":{"1F3FB":{"k":"man-getting-massage-1F3FB","n":"man-getting-massage","e":"💆🏻‍♂️"},"1F3FC":{"k":"man-getting-massage-1F3FC","n":"man-getting-massage","e":"💆🏼‍♂️"},"1F3FD":{"k":"man-getting-massage-1F3FD","n":"man-getting-massage","e":"💆🏽‍♂️"},"1F3FE":{"k":"man-getting-massage-1F3FE","n":"man-getting-massage","e":"💆🏾‍♂️"},"1F3FF":{"k":"man-getting-massage-1F3FF","n":"man-getting-massage","e":"💆🏿‍♂️"}}},{"n":["flag-tf"],"e":"🇹🇫","c":4},{"n":["woman-getting-massage"],"e":"💆‍♀️","c":1,"v":{"1F3FB":{"k":"woman-getting-massage-1F3FB","n":"woman-getting-massage","e":"💆🏻‍♀️"},"1F3FC":{"k":"woman-getting-massage-1F3FC","n":"woman-getting-massage","e":"💆🏼‍♀️"},"1F3FD":{"k":"woman-getting-massage-1F3FD","n":"woman-getting-massage","e":"💆🏽‍♀️"},"1F3FE":{"k":"woman-getting-massage-1F3FE","n":"woman-getting-massage","e":"💆🏾‍♀️"},"1F3FF":{"k":"woman-getting-massage-1F3FF","n":"woman-getting-massage","e":"💆🏿‍♀️"}}},{"n":["flag-tg"],"e":"🇹🇬","c":4},{"n":["haircut"],"e":"💇","c":1,"v":{"1F3FB":{"k":"haircut-1F3FB","n":"haircut","e":"💇🏻"},"1F3FC":{"k":"haircut-1F3FC","n":"haircut","e":"💇🏼"},"1F3FD":{"k":"haircut-1F3FD","n":"haircut","e":"💇🏽"},"1F3FE":{"k":"haircut-1F3FE","n":"haircut","e":"💇🏾"},"1F3FF":{"k":"haircut-1F3FF","n":"haircut","e":"💇🏿"}}},{"n":["flag-th"],"e":"🇹🇭","c":4},{"n":["man-getting-haircut"],"e":"💇‍♂️","c":1,"v":{"1F3FB":{"k":"man-getting-haircut-1F3FB","n":"man-getting-haircut","e":"💇🏻‍♂️"},"1F3FC":{"k":"man-getting-haircut-1F3FC","n":"man-getting-haircut","e":"💇🏼‍♂️"},"1F3FD":{"k":"man-getting-haircut-1F3FD","n":"man-getting-haircut","e":"💇🏽‍♂️"},"1F3FE":{"k":"man-getting-haircut-1F3FE","n":"man-getting-haircut","e":"💇🏾‍♂️"},"1F3FF":{"k":"man-getting-haircut-1F3FF","n":"man-getting-haircut","e":"💇🏿‍♂️"}}},{"n":["flag-tj"],"e":"🇹🇯","c":4},{"n":["flag-tk"],"e":"🇹🇰","c":4},{"n":["woman-getting-haircut"],"e":"💇‍♀️","c":1,"v":{"1F3FB":{"k":"woman-getting-haircut-1F3FB","n":"woman-getting-haircut","e":"💇🏻‍♀️"},"1F3FC":{"k":"woman-getting-haircut-1F3FC","n":"woman-getting-haircut","e":"💇🏼‍♀️"},"1F3FD":{"k":"woman-getting-haircut-1F3FD","n":"woman-getting-haircut","e":"💇🏽‍♀️"},"1F3FE":{"k":"woman-getting-haircut-1F3FE","n":"woman-getting-haircut","e":"💇🏾‍♀️"},"1F3FF":{"k":"woman-getting-haircut-1F3FF","n":"woman-getting-haircut","e":"💇🏿‍♀️"}}},{"n":["walking"],"e":"🚶","c":1,"v":{"1F3FB":{"k":"walking-1F3FB","n":"walking","e":"🚶🏻"},"1F3FC":{"k":"walking-1F3FC","n":"walking","e":"🚶🏼"},"1F3FD":{"k":"walking-1F3FD","n":"walking","e":"🚶🏽"},"1F3FE":{"k":"walking-1F3FE","n":"walking","e":"🚶🏾"},"1F3FF":{"k":"walking-1F3FF","n":"walking","e":"🚶🏿"}}},{"n":["flag-tl"],"e":"🇹🇱","c":4},{"n":["man-walking"],"e":"🚶‍♂️","c":1,"v":{"1F3FB":{"k":"man-walking-1F3FB","n":"man-walking","e":"🚶🏻‍♂️"},"1F3FC":{"k":"man-walking-1F3FC","n":"man-walking","e":"🚶🏼‍♂️"},"1F3FD":{"k":"man-walking-1F3FD","n":"man-walking","e":"🚶🏽‍♂️"},"1F3FE":{"k":"man-walking-1F3FE","n":"man-walking","e":"🚶🏾‍♂️"},"1F3FF":{"k":"man-walking-1F3FF","n":"man-walking","e":"🚶🏿‍♂️"}}},{"n":["flag-tm"],"e":"🇹🇲","c":4},{"n":["woman-walking"],"e":"🚶‍♀️","c":1,"v":{"1F3FB":{"k":"woman-walking-1F3FB","n":"woman-walking","e":"🚶🏻‍♀️"},"1F3FC":{"k":"woman-walking-1F3FC","n":"woman-walking","e":"🚶🏼‍♀️"},"1F3FD":{"k":"woman-walking-1F3FD","n":"woman-walking","e":"🚶🏽‍♀️"},"1F3FE":{"k":"woman-walking-1F3FE","n":"woman-walking","e":"🚶🏾‍♀️"},"1F3FF":{"k":"woman-walking-1F3FF","n":"woman-walking","e":"🚶🏿‍♀️"}}},{"n":["flag-tn"],"e":"🇹🇳","c":4},{"n":["runner","running"],"e":"🏃","c":1,"v":{"1F3FB":{"k":"runner-1F3FB","n":"runner","e":"🏃🏻"},"1F3FC":{"k":"runner-1F3FC","n":"runner","e":"🏃🏼"},"1F3FD":{"k":"runner-1F3FD","n":"runner","e":"🏃🏽"},"1F3FE":{"k":"runner-1F3FE","n":"runner","e":"🏃🏾"},"1F3FF":{"k":"runner-1F3FF","n":"runner","e":"🏃🏿"}}},{"n":["flag-to"],"e":"🇹🇴","c":4},{"n":["man-running"],"e":"🏃‍♂️","c":1,"v":{"1F3FB":{"k":"man-running-1F3FB","n":"man-running","e":"🏃🏻‍♂️"},"1F3FC":{"k":"man-running-1F3FC","n":"man-running","e":"🏃🏼‍♂️"},"1F3FD":{"k":"man-running-1F3FD","n":"man-running","e":"🏃🏽‍♂️"},"1F3FE":{"k":"man-running-1F3FE","n":"man-running","e":"🏃🏾‍♂️"},"1F3FF":{"k":"man-running-1F3FF","n":"man-running","e":"🏃🏿‍♂️"}}},{"n":["flag-tr"],"e":"🇹🇷","c":4},{"n":["flag-tt"],"e":"🇹🇹","c":4},{"n":["woman-running"],"e":"🏃‍♀️","c":1,"v":{"1F3FB":{"k":"woman-running-1F3FB","n":"woman-running","e":"🏃🏻‍♀️"},"1F3FC":{"k":"woman-running-1F3FC","n":"woman-running","e":"🏃🏼‍♀️"},"1F3FD":{"k":"woman-running-1F3FD","n":"woman-running","e":"🏃🏽‍♀️"},"1F3FE":{"k":"woman-running-1F3FE","n":"woman-running","e":"🏃🏾‍♀️"},"1F3FF":{"k":"woman-running-1F3FF","n":"woman-running","e":"🏃🏿‍♀️"}}},{"n":["flag-tv"],"e":"🇹🇻","c":4},{"n":["dancer"],"e":"💃","c":1,"v":{"1F3FB":{"k":"dancer-1F3FB","n":"dancer","e":"💃🏻"},"1F3FC":{"k":"dancer-1F3FC","n":"dancer","e":"💃🏼"},"1F3FD":{"k":"dancer-1F3FD","n":"dancer","e":"💃🏽"},"1F3FE":{"k":"dancer-1F3FE","n":"dancer","e":"💃🏾"},"1F3FF":{"k":"dancer-1F3FF","n":"dancer","e":"💃🏿"}}},{"n":["flag-tw"],"e":"🇹🇼","c":4},{"n":["man_dancing"],"e":"🕺","c":1,"v":{"1F3FB":{"k":"man_dancing-1F3FB","n":"man_dancing","e":"🕺🏻"},"1F3FC":{"k":"man_dancing-1F3FC","n":"man_dancing","e":"🕺🏼"},"1F3FD":{"k":"man_dancing-1F3FD","n":"man_dancing","e":"🕺🏽"},"1F3FE":{"k":"man_dancing-1F3FE","n":"man_dancing","e":"🕺🏾"},"1F3FF":{"k":"man_dancing-1F3FF","n":"man_dancing","e":"🕺🏿"}}},{"n":["dancers"],"e":"👯","c":1},{"n":["flag-tz"],"e":"🇹🇿","c":4},{"n":["flag-ua"],"e":"🇺🇦","c":4},{"n":["man-with-bunny-ears-partying"],"e":"👯‍♂️","c":1},{"n":["woman-with-bunny-ears-partying"],"e":"👯‍♀️","c":1},{"n":["flag-ug"],"e":"🇺🇬","c":4},{"n":["flag-um"],"e":"🇺🇲","c":4},{"n":["person_in_steamy_room"],"e":"🧖","c":1,"v":{"1F3FB":{"k":"person_in_steamy_room-1F3FB","n":"person_in_steamy_room","e":"🧖🏻"},"1F3FC":{"k":"person_in_steamy_room-1F3FC","n":"person_in_steamy_room","e":"🧖🏼"},"1F3FD":{"k":"person_in_steamy_room-1F3FD","n":"person_in_steamy_room","e":"🧖🏽"},"1F3FE":{"k":"person_in_steamy_room-1F3FE","n":"person_in_steamy_room","e":"🧖🏾"},"1F3FF":{"k":"person_in_steamy_room-1F3FF","n":"person_in_steamy_room","e":"🧖🏿"}}},{"n":["woman_in_steamy_room"],"e":"🧖‍♀️","c":1,"v":{"1F3FB":{"k":"woman_in_steamy_room-1F3FB","n":"woman_in_steamy_room","e":"🧖🏻‍♀️"},"1F3FC":{"k":"woman_in_steamy_room-1F3FC","n":"woman_in_steamy_room","e":"🧖🏼‍♀️"},"1F3FD":{"k":"woman_in_steamy_room-1F3FD","n":"woman_in_steamy_room","e":"🧖🏽‍♀️"},"1F3FE":{"k":"woman_in_steamy_room-1F3FE","n":"woman_in_steamy_room","e":"🧖🏾‍♀️"},"1F3FF":{"k":"woman_in_steamy_room-1F3FF","n":"woman_in_steamy_room","e":"🧖🏿‍♀️"}}},{"n":["flag-un"],"e":"🇺🇳","c":4},{"n":["us","flag-us"],"e":"🇺🇸","c":4},{"n":["man_in_steamy_room"],"e":"🧖‍♂️","c":1,"v":{"1F3FB":{"k":"man_in_steamy_room-1F3FB","n":"man_in_steamy_room","e":"🧖🏻‍♂️"},"1F3FC":{"k":"man_in_steamy_room-1F3FC","n":"man_in_steamy_room","e":"🧖🏼‍♂️"},"1F3FD":{"k":"man_in_steamy_room-1F3FD","n":"man_in_steamy_room","e":"🧖🏽‍♂️"},"1F3FE":{"k":"man_in_steamy_room-1F3FE","n":"man_in_steamy_room","e":"🧖🏾‍♂️"},"1F3FF":{"k":"man_in_steamy_room-1F3FF","n":"man_in_steamy_room","e":"🧖🏿‍♂️"}}},{"n":["person_climbing"],"e":"🧗","c":1,"v":{"1F3FB":{"k":"person_climbing-1F3FB","n":"person_climbing","e":"🧗🏻"},"1F3FC":{"k":"person_climbing-1F3FC","n":"person_climbing","e":"🧗🏼"},"1F3FD":{"k":"person_climbing-1F3FD","n":"person_climbing","e":"🧗🏽"},"1F3FE":{"k":"person_climbing-1F3FE","n":"person_climbing","e":"🧗🏾"},"1F3FF":{"k":"person_climbing-1F3FF","n":"person_climbing","e":"🧗🏿"}}},{"n":["flag-uy"],"e":"🇺🇾","c":4},{"n":["woman_climbing"],"e":"🧗‍♀️","c":1,"v":{"1F3FB":{"k":"woman_climbing-1F3FB","n":"woman_climbing","e":"🧗🏻‍♀️"},"1F3FC":{"k":"woman_climbing-1F3FC","n":"woman_climbing","e":"🧗🏼‍♀️"},"1F3FD":{"k":"woman_climbing-1F3FD","n":"woman_climbing","e":"🧗🏽‍♀️"},"1F3FE":{"k":"woman_climbing-1F3FE","n":"woman_climbing","e":"🧗🏾‍♀️"},"1F3FF":{"k":"woman_climbing-1F3FF","n":"woman_climbing","e":"🧗🏿‍♀️"}}},{"n":["flag-uz"],"e":"🇺🇿","c":4},{"n":["man_climbing"],"e":"🧗‍♂️","c":1,"v":{"1F3FB":{"k":"man_climbing-1F3FB","n":"man_climbing","e":"🧗🏻‍♂️"},"1F3FC":{"k":"man_climbing-1F3FC","n":"man_climbing","e":"🧗🏼‍♂️"},"1F3FD":{"k":"man_climbing-1F3FD","n":"man_climbing","e":"🧗🏽‍♂️"},"1F3FE":{"k":"man_climbing-1F3FE","n":"man_climbing","e":"🧗🏾‍♂️"},"1F3FF":{"k":"man_climbing-1F3FF","n":"man_climbing","e":"🧗🏿‍♂️"}}},{"n":["flag-va"],"e":"🇻🇦","c":4},{"n":["person_in_lotus_position"],"e":"🧘","c":1,"v":{"1F3FB":{"k":"person_in_lotus_position-1F3FB","n":"person_in_lotus_position","e":"🧘🏻"},"1F3FC":{"k":"person_in_lotus_position-1F3FC","n":"person_in_lotus_position","e":"🧘🏼"},"1F3FD":{"k":"person_in_lotus_position-1F3FD","n":"person_in_lotus_position","e":"🧘🏽"},"1F3FE":{"k":"person_in_lotus_position-1F3FE","n":"person_in_lotus_position","e":"🧘🏾"},"1F3FF":{"k":"person_in_lotus_position-1F3FF","n":"person_in_lotus_position","e":"🧘🏿"}}},{"n":["flag-vc"],"e":"🇻🇨","c":4},{"n":["flag-ve"],"e":"🇻🇪","c":4},{"n":["woman_in_lotus_position"],"e":"🧘‍♀️","c":1,"v":{"1F3FB":{"k":"woman_in_lotus_position-1F3FB","n":"woman_in_lotus_position","e":"🧘🏻‍♀️"},"1F3FC":{"k":"woman_in_lotus_position-1F3FC","n":"woman_in_lotus_position","e":"🧘🏼‍♀️"},"1F3FD":{"k":"woman_in_lotus_position-1F3FD","n":"woman_in_lotus_position","e":"🧘🏽‍♀️"},"1F3FE":{"k":"woman_in_lotus_position-1F3FE","n":"woman_in_lotus_position","e":"🧘🏾‍♀️"},"1F3FF":{"k":"woman_in_lotus_position-1F3FF","n":"woman_in_lotus_position","e":"🧘🏿‍♀️"}}},{"n":["man_in_lotus_position"],"e":"🧘‍♂️","c":1,"v":{"1F3FB":{"k":"man_in_lotus_position-1F3FB","n":"man_in_lotus_position","e":"🧘🏻‍♂️"},"1F3FC":{"k":"man_in_lotus_position-1F3FC","n":"man_in_lotus_position","e":"🧘🏼‍♂️"},"1F3FD":{"k":"man_in_lotus_position-1F3FD","n":"man_in_lotus_position","e":"🧘🏽‍♂️"},"1F3FE":{"k":"man_in_lotus_position-1F3FE","n":"man_in_lotus_position","e":"🧘🏾‍♂️"},"1F3FF":{"k":"man_in_lotus_position-1F3FF","n":"man_in_lotus_position","e":"🧘🏿‍♂️"}}},{"n":["flag-vg"],"e":"🇻🇬","c":4},{"n":["flag-vi"],"e":"🇻🇮","c":4},{"n":["bath"],"e":"🛀","c":1,"v":{"1F3FB":{"k":"bath-1F3FB","n":"bath","e":"🛀🏻"},"1F3FC":{"k":"bath-1F3FC","n":"bath","e":"🛀🏼"},"1F3FD":{"k":"bath-1F3FD","n":"bath","e":"🛀🏽"},"1F3FE":{"k":"bath-1F3FE","n":"bath","e":"🛀🏾"},"1F3FF":{"k":"bath-1F3FF","n":"bath","e":"🛀🏿"}}},{"n":["sleeping_accommodation"],"e":"🛌","c":1,"v":{"1F3FB":{"k":"sleeping_accommodation-1F3FB","n":"sleeping_accommodation","e":"🛌🏻"},"1F3FC":{"k":"sleeping_accommodation-1F3FC","n":"sleeping_accommodation","e":"🛌🏼"},"1F3FD":{"k":"sleeping_accommodation-1F3FD","n":"sleeping_accommodation","e":"🛌🏽"},"1F3FE":{"k":"sleeping_accommodation-1F3FE","n":"sleeping_accommodation","e":"🛌🏾"},"1F3FF":{"k":"sleeping_accommodation-1F3FF","n":"sleeping_accommodation","e":"🛌🏿"}}},{"n":["flag-vn"],"e":"🇻🇳","c":4},{"n":["man_in_business_suit_levitating"],"e":"🕴️","c":1,"v":{"1F3FB":{"k":"man_in_business_suit_levitating-1F3FB","n":"man_in_business_suit_levitating","e":"🕴🏻"},"1F3FC":{"k":"man_in_business_suit_levitating-1F3FC","n":"man_in_business_suit_levitating","e":"🕴🏼"},"1F3FD":{"k":"man_in_business_suit_levitating-1F3FD","n":"man_in_business_suit_levitating","e":"🕴🏽"},"1F3FE":{"k":"man_in_business_suit_levitating-1F3FE","n":"man_in_business_suit_levitating","e":"🕴🏾"},"1F3FF":{"k":"man_in_business_suit_levitating-1F3FF","n":"man_in_business_suit_levitating","e":"🕴🏿"}}},{"n":["flag-vu"],"e":"🇻🇺","c":4},{"n":["flag-wf"],"e":"🇼🇫","c":4},{"n":["speaking_head_in_silhouette"],"e":"🗣️","c":1},{"n":["bust_in_silhouette"],"e":"👤","c":1},{"n":["flag-ws"],"e":"🇼🇸","c":4},{"n":["busts_in_silhouette"],"e":"👥","c":1},{"n":["flag-xk"],"e":"🇽🇰","c":4},{"n":["fencer"],"e":"🤺","c":1},{"n":["flag-ye"],"e":"🇾🇪","c":4},{"n":["flag-yt"],"e":"🇾🇹","c":4},{"n":["horse_racing"],"e":"🏇","c":1,"v":{"1F3FB":{"k":"horse_racing-1F3FB","n":"horse_racing","e":"🏇🏻"},"1F3FC":{"k":"horse_racing-1F3FC","n":"horse_racing","e":"🏇🏼"},"1F3FD":{"k":"horse_racing-1F3FD","n":"horse_racing","e":"🏇🏽"},"1F3FE":{"k":"horse_racing-1F3FE","n":"horse_racing","e":"🏇🏾"},"1F3FF":{"k":"horse_racing-1F3FF","n":"horse_racing","e":"🏇🏿"}}},{"n":["flag-za"],"e":"🇿🇦","c":4},{"n":["skier"],"e":"⛷️","c":1},{"n":["flag-zm"],"e":"🇿🇲","c":4},{"n":["snowboarder"],"e":"🏂","c":1,"v":{"1F3FB":{"k":"snowboarder-1F3FB","n":"snowboarder","e":"🏂🏻"},"1F3FC":{"k":"snowboarder-1F3FC","n":"snowboarder","e":"🏂🏼"},"1F3FD":{"k":"snowboarder-1F3FD","n":"snowboarder","e":"🏂🏽"},"1F3FE":{"k":"snowboarder-1F3FE","n":"snowboarder","e":"🏂🏾"},"1F3FF":{"k":"snowboarder-1F3FF","n":"snowboarder","e":"🏂🏿"}}},{"n":["golfer"],"e":"🏌️","c":1,"v":{"1F3FB":{"k":"golfer-1F3FB","n":"golfer","e":"🏌🏻"},"1F3FC":{"k":"golfer-1F3FC","n":"golfer","e":"🏌🏼"},"1F3FD":{"k":"golfer-1F3FD","n":"golfer","e":"🏌🏽"},"1F3FE":{"k":"golfer-1F3FE","n":"golfer","e":"🏌🏾"},"1F3FF":{"k":"golfer-1F3FF","n":"golfer","e":"🏌🏿"}}},{"n":["flag-zw"],"e":"🇿🇼","c":4},{"n":["man-golfing"],"e":"🏌️‍♂️","c":1,"v":{"1F3FB":{"k":"man-golfing-1F3FB","n":"man-golfing","e":"🏌🏻‍♂️"},"1F3FC":{"k":"man-golfing-1F3FC","n":"man-golfing","e":"🏌🏼‍♂️"},"1F3FD":{"k":"man-golfing-1F3FD","n":"man-golfing","e":"🏌🏽‍♂️"},"1F3FE":{"k":"man-golfing-1F3FE","n":"man-golfing","e":"🏌🏾‍♂️"},"1F3FF":{"k":"man-golfing-1F3FF","n":"man-golfing","e":"🏌🏿‍♂️"}}},{"n":["flag-england"],"e":"🏴󠁧󠁢󠁥󠁮󠁧󠁿","c":4},{"n":["woman-golfing"],"e":"🏌️‍♀️","c":1,"v":{"1F3FB":{"k":"woman-golfing-1F3FB","n":"woman-golfing","e":"🏌🏻‍♀️"},"1F3FC":{"k":"woman-golfing-1F3FC","n":"woman-golfing","e":"🏌🏼‍♀️"},"1F3FD":{"k":"woman-golfing-1F3FD","n":"woman-golfing","e":"🏌🏽‍♀️"},"1F3FE":{"k":"woman-golfing-1F3FE","n":"woman-golfing","e":"🏌🏾‍♀️"},"1F3FF":{"k":"woman-golfing-1F3FF","n":"woman-golfing","e":"🏌🏿‍♀️"}}},{"n":["flag-scotland"],"e":"🏴󠁧󠁢󠁳󠁣󠁴󠁿","c":4},{"n":["flag-wales"],"e":"🏴󠁧󠁢󠁷󠁬󠁳󠁿","c":4},{"n":["surfer"],"e":"🏄","c":1,"v":{"1F3FB":{"k":"surfer-1F3FB","n":"surfer","e":"🏄🏻"},"1F3FC":{"k":"surfer-1F3FC","n":"surfer","e":"🏄🏼"},"1F3FD":{"k":"surfer-1F3FD","n":"surfer","e":"🏄🏽"},"1F3FE":{"k":"surfer-1F3FE","n":"surfer","e":"🏄🏾"},"1F3FF":{"k":"surfer-1F3FF","n":"surfer","e":"🏄🏿"}}},{"n":["man-surfing"],"e":"🏄‍♂️","c":1,"v":{"1F3FB":{"k":"man-surfing-1F3FB","n":"man-surfing","e":"🏄🏻‍♂️"},"1F3FC":{"k":"man-surfing-1F3FC","n":"man-surfing","e":"🏄🏼‍♂️"},"1F3FD":{"k":"man-surfing-1F3FD","n":"man-surfing","e":"🏄🏽‍♂️"},"1F3FE":{"k":"man-surfing-1F3FE","n":"man-surfing","e":"🏄🏾‍♂️"},"1F3FF":{"k":"man-surfing-1F3FF","n":"man-surfing","e":"🏄🏿‍♂️"}}},{"n":["woman-surfing"],"e":"🏄‍♀️","c":1,"v":{"1F3FB":{"k":"woman-surfing-1F3FB","n":"woman-surfing","e":"🏄🏻‍♀️"},"1F3FC":{"k":"woman-surfing-1F3FC","n":"woman-surfing","e":"🏄🏼‍♀️"},"1F3FD":{"k":"woman-surfing-1F3FD","n":"woman-surfing","e":"🏄🏽‍♀️"},"1F3FE":{"k":"woman-surfing-1F3FE","n":"woman-surfing","e":"🏄🏾‍♀️"},"1F3FF":{"k":"woman-surfing-1F3FF","n":"woman-surfing","e":"🏄🏿‍♀️"}}},{"n":["rowboat"],"e":"🚣","c":1,"v":{"1F3FB":{"k":"rowboat-1F3FB","n":"rowboat","e":"🚣🏻"},"1F3FC":{"k":"rowboat-1F3FC","n":"rowboat","e":"🚣🏼"},"1F3FD":{"k":"rowboat-1F3FD","n":"rowboat","e":"🚣🏽"},"1F3FE":{"k":"rowboat-1F3FE","n":"rowboat","e":"🚣🏾"},"1F3FF":{"k":"rowboat-1F3FF","n":"rowboat","e":"🚣🏿"}}},{"n":["man-rowing-boat"],"e":"🚣‍♂️","c":1,"v":{"1F3FB":{"k":"man-rowing-boat-1F3FB","n":"man-rowing-boat","e":"🚣🏻‍♂️"},"1F3FC":{"k":"man-rowing-boat-1F3FC","n":"man-rowing-boat","e":"🚣🏼‍♂️"},"1F3FD":{"k":"man-rowing-boat-1F3FD","n":"man-rowing-boat","e":"🚣🏽‍♂️"},"1F3FE":{"k":"man-rowing-boat-1F3FE","n":"man-rowing-boat","e":"🚣🏾‍♂️"},"1F3FF":{"k":"man-rowing-boat-1F3FF","n":"man-rowing-boat","e":"🚣🏿‍♂️"}}},{"n":["woman-rowing-boat"],"e":"🚣‍♀️","c":1,"v":{"1F3FB":{"k":"woman-rowing-boat-1F3FB","n":"woman-rowing-boat","e":"🚣🏻‍♀️"},"1F3FC":{"k":"woman-rowing-boat-1F3FC","n":"woman-rowing-boat","e":"🚣🏼‍♀️"},"1F3FD":{"k":"woman-rowing-boat-1F3FD","n":"woman-rowing-boat","e":"🚣🏽‍♀️"},"1F3FE":{"k":"woman-rowing-boat-1F3FE","n":"woman-rowing-boat","e":"🚣🏾‍♀️"},"1F3FF":{"k":"woman-rowing-boat-1F3FF","n":"woman-rowing-boat","e":"🚣🏿‍♀️"}}},{"n":["swimmer"],"e":"🏊","c":1,"v":{"1F3FB":{"k":"swimmer-1F3FB","n":"swimmer","e":"🏊🏻"},"1F3FC":{"k":"swimmer-1F3FC","n":"swimmer","e":"🏊🏼"},"1F3FD":{"k":"swimmer-1F3FD","n":"swimmer","e":"🏊🏽"},"1F3FE":{"k":"swimmer-1F3FE","n":"swimmer","e":"🏊🏾"},"1F3FF":{"k":"swimmer-1F3FF","n":"swimmer","e":"🏊🏿"}}},{"n":["man-swimming"],"e":"🏊‍♂️","c":1,"v":{"1F3FB":{"k":"man-swimming-1F3FB","n":"man-swimming","e":"🏊🏻‍♂️"},"1F3FC":{"k":"man-swimming-1F3FC","n":"man-swimming","e":"🏊🏼‍♂️"},"1F3FD":{"k":"man-swimming-1F3FD","n":"man-swimming","e":"🏊🏽‍♂️"},"1F3FE":{"k":"man-swimming-1F3FE","n":"man-swimming","e":"🏊🏾‍♂️"},"1F3FF":{"k":"man-swimming-1F3FF","n":"man-swimming","e":"🏊🏿‍♂️"}}},{"n":["woman-swimming"],"e":"🏊‍♀️","c":1,"v":{"1F3FB":{"k":"woman-swimming-1F3FB","n":"woman-swimming","e":"🏊🏻‍♀️"},"1F3FC":{"k":"woman-swimming-1F3FC","n":"woman-swimming","e":"🏊🏼‍♀️"},"1F3FD":{"k":"woman-swimming-1F3FD","n":"woman-swimming","e":"🏊🏽‍♀️"},"1F3FE":{"k":"woman-swimming-1F3FE","n":"woman-swimming","e":"🏊🏾‍♀️"},"1F3FF":{"k":"woman-swimming-1F3FF","n":"woman-swimming","e":"🏊🏿‍♀️"}}},{"n":["person_with_ball"],"e":"⛹️","c":1,"v":{"1F3FB":{"k":"person_with_ball-1F3FB","n":"person_with_ball","e":"⛹🏻"},"1F3FC":{"k":"person_with_ball-1F3FC","n":"person_with_ball","e":"⛹🏼"},"1F3FD":{"k":"person_with_ball-1F3FD","n":"person_with_ball","e":"⛹🏽"},"1F3FE":{"k":"person_with_ball-1F3FE","n":"person_with_ball","e":"⛹🏾"},"1F3FF":{"k":"person_with_ball-1F3FF","n":"person_with_ball","e":"⛹🏿"}}},{"n":["man-bouncing-ball"],"e":"⛹️‍♂️","c":1,"v":{"1F3FB":{"k":"man-bouncing-ball-1F3FB","n":"man-bouncing-ball","e":"⛹🏻‍♂️"},"1F3FC":{"k":"man-bouncing-ball-1F3FC","n":"man-bouncing-ball","e":"⛹🏼‍♂️"},"1F3FD":{"k":"man-bouncing-ball-1F3FD","n":"man-bouncing-ball","e":"⛹🏽‍♂️"},"1F3FE":{"k":"man-bouncing-ball-1F3FE","n":"man-bouncing-ball","e":"⛹🏾‍♂️"},"1F3FF":{"k":"man-bouncing-ball-1F3FF","n":"man-bouncing-ball","e":"⛹🏿‍♂️"}}},{"n":["woman-bouncing-ball"],"e":"⛹️‍♀️","c":1,"v":{"1F3FB":{"k":"woman-bouncing-ball-1F3FB","n":"woman-bouncing-ball","e":"⛹🏻‍♀️"},"1F3FC":{"k":"woman-bouncing-ball-1F3FC","n":"woman-bouncing-ball","e":"⛹🏼‍♀️"},"1F3FD":{"k":"woman-bouncing-ball-1F3FD","n":"woman-bouncing-ball","e":"⛹🏽‍♀️"},"1F3FE":{"k":"woman-bouncing-ball-1F3FE","n":"woman-bouncing-ball","e":"⛹🏾‍♀️"},"1F3FF":{"k":"woman-bouncing-ball-1F3FF","n":"woman-bouncing-ball","e":"⛹🏿‍♀️"}}},{"n":["weight_lifter"],"e":"🏋️","c":1,"v":{"1F3FB":{"k":"weight_lifter-1F3FB","n":"weight_lifter","e":"🏋🏻"},"1F3FC":{"k":"weight_lifter-1F3FC","n":"weight_lifter","e":"🏋🏼"},"1F3FD":{"k":"weight_lifter-1F3FD","n":"weight_lifter","e":"🏋🏽"},"1F3FE":{"k":"weight_lifter-1F3FE","n":"weight_lifter","e":"🏋🏾"},"1F3FF":{"k":"weight_lifter-1F3FF","n":"weight_lifter","e":"🏋🏿"}}},{"n":["man-lifting-weights"],"e":"🏋️‍♂️","c":1,"v":{"1F3FB":{"k":"man-lifting-weights-1F3FB","n":"man-lifting-weights","e":"🏋🏻‍♂️"},"1F3FC":{"k":"man-lifting-weights-1F3FC","n":"man-lifting-weights","e":"🏋🏼‍♂️"},"1F3FD":{"k":"man-lifting-weights-1F3FD","n":"man-lifting-weights","e":"🏋🏽‍♂️"},"1F3FE":{"k":"man-lifting-weights-1F3FE","n":"man-lifting-weights","e":"🏋🏾‍♂️"},"1F3FF":{"k":"man-lifting-weights-1F3FF","n":"man-lifting-weights","e":"🏋🏿‍♂️"}}},{"n":["woman-lifting-weights"],"e":"🏋️‍♀️","c":1,"v":{"1F3FB":{"k":"woman-lifting-weights-1F3FB","n":"woman-lifting-weights","e":"🏋🏻‍♀️"},"1F3FC":{"k":"woman-lifting-weights-1F3FC","n":"woman-lifting-weights","e":"🏋🏼‍♀️"},"1F3FD":{"k":"woman-lifting-weights-1F3FD","n":"woman-lifting-weights","e":"🏋🏽‍♀️"},"1F3FE":{"k":"woman-lifting-weights-1F3FE","n":"woman-lifting-weights","e":"🏋🏾‍♀️"},"1F3FF":{"k":"woman-lifting-weights-1F3FF","n":"woman-lifting-weights","e":"🏋🏿‍♀️"}}},{"n":["bicyclist"],"e":"🚴","c":1,"v":{"1F3FB":{"k":"bicyclist-1F3FB","n":"bicyclist","e":"🚴🏻"},"1F3FC":{"k":"bicyclist-1F3FC","n":"bicyclist","e":"🚴🏼"},"1F3FD":{"k":"bicyclist-1F3FD","n":"bicyclist","e":"🚴🏽"},"1F3FE":{"k":"bicyclist-1F3FE","n":"bicyclist","e":"🚴🏾"},"1F3FF":{"k":"bicyclist-1F3FF","n":"bicyclist","e":"🚴🏿"}}},{"n":["man-biking"],"e":"🚴‍♂️","c":1,"v":{"1F3FB":{"k":"man-biking-1F3FB","n":"man-biking","e":"🚴🏻‍♂️"},"1F3FC":{"k":"man-biking-1F3FC","n":"man-biking","e":"🚴🏼‍♂️"},"1F3FD":{"k":"man-biking-1F3FD","n":"man-biking","e":"🚴🏽‍♂️"},"1F3FE":{"k":"man-biking-1F3FE","n":"man-biking","e":"🚴🏾‍♂️"},"1F3FF":{"k":"man-biking-1F3FF","n":"man-biking","e":"🚴🏿‍♂️"}}},{"n":["woman-biking"],"e":"🚴‍♀️","c":1,"v":{"1F3FB":{"k":"woman-biking-1F3FB","n":"woman-biking","e":"🚴🏻‍♀️"},"1F3FC":{"k":"woman-biking-1F3FC","n":"woman-biking","e":"🚴🏼‍♀️"},"1F3FD":{"k":"woman-biking-1F3FD","n":"woman-biking","e":"🚴🏽‍♀️"},"1F3FE":{"k":"woman-biking-1F3FE","n":"woman-biking","e":"🚴🏾‍♀️"},"1F3FF":{"k":"woman-biking-1F3FF","n":"woman-biking","e":"🚴🏿‍♀️"}}},{"n":["mountain_bicyclist"],"e":"🚵","c":1,"v":{"1F3FB":{"k":"mountain_bicyclist-1F3FB","n":"mountain_bicyclist","e":"🚵🏻"},"1F3FC":{"k":"mountain_bicyclist-1F3FC","n":"mountain_bicyclist","e":"🚵🏼"},"1F3FD":{"k":"mountain_bicyclist-1F3FD","n":"mountain_bicyclist","e":"🚵🏽"},"1F3FE":{"k":"mountain_bicyclist-1F3FE","n":"mountain_bicyclist","e":"🚵🏾"},"1F3FF":{"k":"mountain_bicyclist-1F3FF","n":"mountain_bicyclist","e":"🚵🏿"}}},{"n":["man-mountain-biking"],"e":"🚵‍♂️","c":1,"v":{"1F3FB":{"k":"man-mountain-biking-1F3FB","n":"man-mountain-biking","e":"🚵🏻‍♂️"},"1F3FC":{"k":"man-mountain-biking-1F3FC","n":"man-mountain-biking","e":"🚵🏼‍♂️"},"1F3FD":{"k":"man-mountain-biking-1F3FD","n":"man-mountain-biking","e":"🚵🏽‍♂️"},"1F3FE":{"k":"man-mountain-biking-1F3FE","n":"man-mountain-biking","e":"🚵🏾‍♂️"},"1F3FF":{"k":"man-mountain-biking-1F3FF","n":"man-mountain-biking","e":"🚵🏿‍♂️"}}},{"n":["woman-mountain-biking"],"e":"🚵‍♀️","c":1,"v":{"1F3FB":{"k":"woman-mountain-biking-1F3FB","n":"woman-mountain-biking","e":"🚵🏻‍♀️"},"1F3FC":{"k":"woman-mountain-biking-1F3FC","n":"woman-mountain-biking","e":"🚵🏼‍♀️"},"1F3FD":{"k":"woman-mountain-biking-1F3FD","n":"woman-mountain-biking","e":"🚵🏽‍♀️"},"1F3FE":{"k":"woman-mountain-biking-1F3FE","n":"woman-mountain-biking","e":"🚵🏾‍♀️"},"1F3FF":{"k":"woman-mountain-biking-1F3FF","n":"woman-mountain-biking","e":"🚵🏿‍♀️"}}},{"n":["racing_car"],"e":"🏎️","c":1},{"n":["racing_motorcycle"],"e":"🏍️","c":1},{"n":["person_doing_cartwheel"],"e":"🤸","c":1,"v":{"1F3FB":{"k":"person_doing_cartwheel-1F3FB","n":"person_doing_cartwheel","e":"🤸🏻"},"1F3FC":{"k":"person_doing_cartwheel-1F3FC","n":"person_doing_cartwheel","e":"🤸🏼"},"1F3FD":{"k":"person_doing_cartwheel-1F3FD","n":"person_doing_cartwheel","e":"🤸🏽"},"1F3FE":{"k":"person_doing_cartwheel-1F3FE","n":"person_doing_cartwheel","e":"🤸🏾"},"1F3FF":{"k":"person_doing_cartwheel-1F3FF","n":"person_doing_cartwheel","e":"🤸🏿"}}},{"n":["man-cartwheeling"],"e":"🤸‍♂️","c":1,"v":{"1F3FB":{"k":"man-cartwheeling-1F3FB","n":"man-cartwheeling","e":"🤸🏻‍♂️"},"1F3FC":{"k":"man-cartwheeling-1F3FC","n":"man-cartwheeling","e":"🤸🏼‍♂️"},"1F3FD":{"k":"man-cartwheeling-1F3FD","n":"man-cartwheeling","e":"🤸🏽‍♂️"},"1F3FE":{"k":"man-cartwheeling-1F3FE","n":"man-cartwheeling","e":"🤸🏾‍♂️"},"1F3FF":{"k":"man-cartwheeling-1F3FF","n":"man-cartwheeling","e":"🤸🏿‍♂️"}}},{"n":["woman-cartwheeling"],"e":"🤸‍♀️","c":1,"v":{"1F3FB":{"k":"woman-cartwheeling-1F3FB","n":"woman-cartwheeling","e":"🤸🏻‍♀️"},"1F3FC":{"k":"woman-cartwheeling-1F3FC","n":"woman-cartwheeling","e":"🤸🏼‍♀️"},"1F3FD":{"k":"woman-cartwheeling-1F3FD","n":"woman-cartwheeling","e":"🤸🏽‍♀️"},"1F3FE":{"k":"woman-cartwheeling-1F3FE","n":"woman-cartwheeling","e":"🤸🏾‍♀️"},"1F3FF":{"k":"woman-cartwheeling-1F3FF","n":"woman-cartwheeling","e":"🤸🏿‍♀️"}}},{"n":["wrestlers"],"e":"🤼","c":1},{"n":["man-wrestling"],"e":"🤼‍♂️","c":1},{"n":["woman-wrestling"],"e":"🤼‍♀️","c":1},{"n":["water_polo"],"e":"🤽","c":1,"v":{"1F3FB":{"k":"water_polo-1F3FB","n":"water_polo","e":"🤽🏻"},"1F3FC":{"k":"water_polo-1F3FC","n":"water_polo","e":"🤽🏼"},"1F3FD":{"k":"water_polo-1F3FD","n":"water_polo","e":"🤽🏽"},"1F3FE":{"k":"water_polo-1F3FE","n":"water_polo","e":"🤽🏾"},"1F3FF":{"k":"water_polo-1F3FF","n":"water_polo","e":"🤽🏿"}}},{"n":["man-playing-water-polo"],"e":"🤽‍♂️","c":1,"v":{"1F3FB":{"k":"man-playing-water-polo-1F3FB","n":"man-playing-water-polo","e":"🤽🏻‍♂️"},"1F3FC":{"k":"man-playing-water-polo-1F3FC","n":"man-playing-water-polo","e":"🤽🏼‍♂️"},"1F3FD":{"k":"man-playing-water-polo-1F3FD","n":"man-playing-water-polo","e":"🤽🏽‍♂️"},"1F3FE":{"k":"man-playing-water-polo-1F3FE","n":"man-playing-water-polo","e":"🤽🏾‍♂️"},"1F3FF":{"k":"man-playing-water-polo-1F3FF","n":"man-playing-water-polo","e":"🤽🏿‍♂️"}}},{"n":["woman-playing-water-polo"],"e":"🤽‍♀️","c":1,"v":{"1F3FB":{"k":"woman-playing-water-polo-1F3FB","n":"woman-playing-water-polo","e":"🤽🏻‍♀️"},"1F3FC":{"k":"woman-playing-water-polo-1F3FC","n":"woman-playing-water-polo","e":"🤽🏼‍♀️"},"1F3FD":{"k":"woman-playing-water-polo-1F3FD","n":"woman-playing-water-polo","e":"🤽🏽‍♀️"},"1F3FE":{"k":"woman-playing-water-polo-1F3FE","n":"woman-playing-water-polo","e":"🤽🏾‍♀️"},"1F3FF":{"k":"woman-playing-water-polo-1F3FF","n":"woman-playing-water-polo","e":"🤽🏿‍♀️"}}},{"n":["handball"],"e":"🤾","c":1,"v":{"1F3FB":{"k":"handball-1F3FB","n":"handball","e":"🤾🏻"},"1F3FC":{"k":"handball-1F3FC","n":"handball","e":"🤾🏼"},"1F3FD":{"k":"handball-1F3FD","n":"handball","e":"🤾🏽"},"1F3FE":{"k":"handball-1F3FE","n":"handball","e":"🤾🏾"},"1F3FF":{"k":"handball-1F3FF","n":"handball","e":"🤾🏿"}}},{"n":["man-playing-handball"],"e":"🤾‍♂️","c":1,"v":{"1F3FB":{"k":"man-playing-handball-1F3FB","n":"man-playing-handball","e":"🤾🏻‍♂️"},"1F3FC":{"k":"man-playing-handball-1F3FC","n":"man-playing-handball","e":"🤾🏼‍♂️"},"1F3FD":{"k":"man-playing-handball-1F3FD","n":"man-playing-handball","e":"🤾🏽‍♂️"},"1F3FE":{"k":"man-playing-handball-1F3FE","n":"man-playing-handball","e":"🤾🏾‍♂️"},"1F3FF":{"k":"man-playing-handball-1F3FF","n":"man-playing-handball","e":"🤾🏿‍♂️"}}},{"n":["woman-playing-handball"],"e":"🤾‍♀️","c":1,"v":{"1F3FB":{"k":"woman-playing-handball-1F3FB","n":"woman-playing-handball","e":"🤾🏻‍♀️"},"1F3FC":{"k":"woman-playing-handball-1F3FC","n":"woman-playing-handball","e":"🤾🏼‍♀️"},"1F3FD":{"k":"woman-playing-handball-1F3FD","n":"woman-playing-handball","e":"🤾🏽‍♀️"},"1F3FE":{"k":"woman-playing-handball-1F3FE","n":"woman-playing-handball","e":"🤾🏾‍♀️"},"1F3FF":{"k":"woman-playing-handball-1F3FF","n":"woman-playing-handball","e":"🤾🏿‍♀️"}}},{"n":["juggling"],"e":"🤹","c":1,"v":{"1F3FB":{"k":"juggling-1F3FB","n":"juggling","e":"🤹🏻"},"1F3FC":{"k":"juggling-1F3FC","n":"juggling","e":"🤹🏼"},"1F3FD":{"k":"juggling-1F3FD","n":"juggling","e":"🤹🏽"},"1F3FE":{"k":"juggling-1F3FE","n":"juggling","e":"🤹🏾"},"1F3FF":{"k":"juggling-1F3FF","n":"juggling","e":"🤹🏿"}}},{"n":["man-juggling"],"e":"🤹‍♂️","c":1,"v":{"1F3FB":{"k":"man-juggling-1F3FB","n":"man-juggling","e":"🤹🏻‍♂️"},"1F3FC":{"k":"man-juggling-1F3FC","n":"man-juggling","e":"🤹🏼‍♂️"},"1F3FD":{"k":"man-juggling-1F3FD","n":"man-juggling","e":"🤹🏽‍♂️"},"1F3FE":{"k":"man-juggling-1F3FE","n":"man-juggling","e":"🤹🏾‍♂️"},"1F3FF":{"k":"man-juggling-1F3FF","n":"man-juggling","e":"🤹🏿‍♂️"}}},{"n":["woman-juggling"],"e":"🤹‍♀️","c":1,"v":{"1F3FB":{"k":"woman-juggling-1F3FB","n":"woman-juggling","e":"🤹🏻‍♀️"},"1F3FC":{"k":"woman-juggling-1F3FC","n":"woman-juggling","e":"🤹🏼‍♀️"},"1F3FD":{"k":"woman-juggling-1F3FD","n":"woman-juggling","e":"🤹🏽‍♀️"},"1F3FE":{"k":"woman-juggling-1F3FE","n":"woman-juggling","e":"🤹🏾‍♀️"},"1F3FF":{"k":"woman-juggling-1F3FF","n":"woman-juggling","e":"🤹🏿‍♀️"}}},{"n":["couple","man_and_woman_holding_hands"],"e":"👫","c":1},{"n":["two_men_holding_hands"],"e":"👬","c":1},{"n":["two_women_holding_hands"],"e":"👭","c":1},{"n":["couplekiss"],"e":"💏","c":1},{"n":["woman-kiss-man"],"e":"👩‍❤️‍💋‍👨","c":1},{"n":["man-kiss-man"],"e":"👨‍❤️‍💋‍👨","c":1},{"n":["woman-kiss-woman"],"e":"👩‍❤️‍💋‍👩","c":1},{"n":["couple_with_heart"],"e":"💑","c":1},{"n":["woman-heart-man"],"e":"👩‍❤️‍👨","c":1},{"n":["man-heart-man"],"e":"👨‍❤️‍👨","c":1},{"n":["woman-heart-woman"],"e":"👩‍❤️‍👩","c":1},{"n":["family","man-woman-boy"],"e":"👪","c":1},{"n":["man-woman-boy","family"],"e":"👨‍👩‍👦","c":1},{"n":["man-woman-girl"],"e":"👨‍👩‍👧","c":1},{"n":["man-woman-girl-boy"],"e":"👨‍👩‍👧‍👦","c":1},{"n":["man-woman-boy-boy"],"e":"👨‍👩‍👦‍👦","c":1},{"n":["man-woman-girl-girl"],"e":"👨‍👩‍👧‍👧","c":1},{"n":["man-man-boy"],"e":"👨‍👨‍👦","c":1},{"n":["man-man-girl"],"e":"👨‍👨‍👧","c":1},{"n":["man-man-girl-boy"],"e":"👨‍👨‍👧‍👦","c":1},{"n":["man-man-boy-boy"],"e":"👨‍👨‍👦‍👦","c":1},{"n":["man-man-girl-girl"],"e":"👨‍👨‍👧‍👧","c":1},{"n":["woman-woman-boy"],"e":"👩‍👩‍👦","c":1},{"n":["woman-woman-girl"],"e":"👩‍👩‍👧","c":1},{"n":["woman-woman-girl-boy"],"e":"👩‍👩‍👧‍👦","c":1},{"n":["woman-woman-boy-boy"],"e":"👩‍👩‍👦‍👦","c":1},{"n":["woman-woman-girl-girl"],"e":"👩‍👩‍👧‍👧","c":1},{"n":["man-boy"],"e":"👨‍👦","c":1},{"n":["man-boy-boy"],"e":"👨‍👦‍👦","c":1},{"n":["man-girl"],"e":"👨‍👧","c":1},{"n":["man-girl-boy"],"e":"👨‍👧‍👦","c":1},{"n":["man-girl-girl"],"e":"👨‍👧‍👧","c":1},{"n":["woman-boy"],"e":"👩‍👦","c":1},{"n":["woman-boy-boy"],"e":"👩‍👦‍👦","c":1},{"n":["woman-girl"],"e":"👩‍👧","c":1},{"n":["woman-girl-boy"],"e":"👩‍👧‍👦","c":1},{"n":["woman-girl-girl"],"e":"👩‍👧‍👧","c":1},{"n":["selfie"],"e":"🤳","c":1,"v":{"1F3FB":{"k":"selfie-1F3FB","n":"selfie","e":"🤳🏻"},"1F3FC":{"k":"selfie-1F3FC","n":"selfie","e":"🤳🏼"},"1F3FD":{"k":"selfie-1F3FD","n":"selfie","e":"🤳🏽"},"1F3FE":{"k":"selfie-1F3FE","n":"selfie","e":"🤳🏾"},"1F3FF":{"k":"selfie-1F3FF","n":"selfie","e":"🤳🏿"}}},{"n":["muscle"],"e":"💪","c":1,"v":{"1F3FB":{"k":"muscle-1F3FB","n":"muscle","e":"💪🏻"},"1F3FC":{"k":"muscle-1F3FC","n":"muscle","e":"💪🏼"},"1F3FD":{"k":"muscle-1F3FD","n":"muscle","e":"💪🏽"},"1F3FE":{"k":"muscle-1F3FE","n":"muscle","e":"💪🏾"},"1F3FF":{"k":"muscle-1F3FF","n":"muscle","e":"💪🏿"}}},{"n":["point_left"],"e":"👈","c":1,"v":{"1F3FB":{"k":"point_left-1F3FB","n":"point_left","e":"👈🏻"},"1F3FC":{"k":"point_left-1F3FC","n":"point_left","e":"👈🏼"},"1F3FD":{"k":"point_left-1F3FD","n":"point_left","e":"👈🏽"},"1F3FE":{"k":"point_left-1F3FE","n":"point_left","e":"👈🏾"},"1F3FF":{"k":"point_left-1F3FF","n":"point_left","e":"👈🏿"}}},{"n":["point_right"],"e":"👉","c":1,"v":{"1F3FB":{"k":"point_right-1F3FB","n":"point_right","e":"👉🏻"},"1F3FC":{"k":"point_right-1F3FC","n":"point_right","e":"👉🏼"},"1F3FD":{"k":"point_right-1F3FD","n":"point_right","e":"👉🏽"},"1F3FE":{"k":"point_right-1F3FE","n":"point_right","e":"👉🏾"},"1F3FF":{"k":"point_right-1F3FF","n":"point_right","e":"👉🏿"}}},{"n":["point_up"],"e":"☝️","c":1,"v":{"1F3FB":{"k":"point_up-1F3FB","n":"point_up","e":"☝🏻"},"1F3FC":{"k":"point_up-1F3FC","n":"point_up","e":"☝🏼"},"1F3FD":{"k":"point_up-1F3FD","n":"point_up","e":"☝🏽"},"1F3FE":{"k":"point_up-1F3FE","n":"point_up","e":"☝🏾"},"1F3FF":{"k":"point_up-1F3FF","n":"point_up","e":"☝🏿"}}},{"n":["point_up_2"],"e":"👆","c":1,"v":{"1F3FB":{"k":"point_up_2-1F3FB","n":"point_up_2","e":"👆🏻"},"1F3FC":{"k":"point_up_2-1F3FC","n":"point_up_2","e":"👆🏼"},"1F3FD":{"k":"point_up_2-1F3FD","n":"point_up_2","e":"👆🏽"},"1F3FE":{"k":"point_up_2-1F3FE","n":"point_up_2","e":"👆🏾"},"1F3FF":{"k":"point_up_2-1F3FF","n":"point_up_2","e":"👆🏿"}}},{"n":["middle_finger","reversed_hand_with_middle_finger_extended"],"e":"🖕","c":1,"v":{"1F3FB":{"k":"middle_finger-1F3FB","n":"middle_finger","e":"🖕🏻"},"1F3FC":{"k":"middle_finger-1F3FC","n":"middle_finger","e":"🖕🏼"},"1F3FD":{"k":"middle_finger-1F3FD","n":"middle_finger","e":"🖕🏽"},"1F3FE":{"k":"middle_finger-1F3FE","n":"middle_finger","e":"🖕🏾"},"1F3FF":{"k":"middle_finger-1F3FF","n":"middle_finger","e":"🖕🏿"}}},{"n":["point_down"],"e":"👇","c":1,"v":{"1F3FB":{"k":"point_down-1F3FB","n":"point_down","e":"👇🏻"},"1F3FC":{"k":"point_down-1F3FC","n":"point_down","e":"👇🏼"},"1F3FD":{"k":"point_down-1F3FD","n":"point_down","e":"👇🏽"},"1F3FE":{"k":"point_down-1F3FE","n":"point_down","e":"👇🏾"},"1F3FF":{"k":"point_down-1F3FF","n":"point_down","e":"👇🏿"}}},{"n":["v"],"e":"✌️","c":1,"v":{"1F3FB":{"k":"v-1F3FB","n":"v","e":"✌🏻"},"1F3FC":{"k":"v-1F3FC","n":"v","e":"✌🏼"},"1F3FD":{"k":"v-1F3FD","n":"v","e":"✌🏽"},"1F3FE":{"k":"v-1F3FE","n":"v","e":"✌🏾"},"1F3FF":{"k":"v-1F3FF","n":"v","e":"✌🏿"}}},{"n":["crossed_fingers","hand_with_index_and_middle_fingers_crossed"],"e":"🤞","c":1,"v":{"1F3FB":{"k":"crossed_fingers-1F3FB","n":"crossed_fingers","e":"🤞🏻"},"1F3FC":{"k":"crossed_fingers-1F3FC","n":"crossed_fingers","e":"🤞🏼"},"1F3FD":{"k":"crossed_fingers-1F3FD","n":"crossed_fingers","e":"🤞🏽"},"1F3FE":{"k":"crossed_fingers-1F3FE","n":"crossed_fingers","e":"🤞🏾"},"1F3FF":{"k":"crossed_fingers-1F3FF","n":"crossed_fingers","e":"🤞🏿"}}},{"n":["spock-hand"],"e":"🖖","c":1,"v":{"1F3FB":{"k":"spock-hand-1F3FB","n":"spock-hand","e":"🖖🏻"},"1F3FC":{"k":"spock-hand-1F3FC","n":"spock-hand","e":"🖖🏼"},"1F3FD":{"k":"spock-hand-1F3FD","n":"spock-hand","e":"🖖🏽"},"1F3FE":{"k":"spock-hand-1F3FE","n":"spock-hand","e":"🖖🏾"},"1F3FF":{"k":"spock-hand-1F3FF","n":"spock-hand","e":"🖖🏿"}}},{"n":["the_horns","sign_of_the_horns"],"e":"🤘","c":1,"v":{"1F3FB":{"k":"the_horns-1F3FB","n":"the_horns","e":"🤘🏻"},"1F3FC":{"k":"the_horns-1F3FC","n":"the_horns","e":"🤘🏼"},"1F3FD":{"k":"the_horns-1F3FD","n":"the_horns","e":"🤘🏽"},"1F3FE":{"k":"the_horns-1F3FE","n":"the_horns","e":"🤘🏾"},"1F3FF":{"k":"the_horns-1F3FF","n":"the_horns","e":"🤘🏿"}}},{"n":["call_me_hand"],"e":"🤙","c":1,"v":{"1F3FB":{"k":"call_me_hand-1F3FB","n":"call_me_hand","e":"🤙🏻"},"1F3FC":{"k":"call_me_hand-1F3FC","n":"call_me_hand","e":"🤙🏼"},"1F3FD":{"k":"call_me_hand-1F3FD","n":"call_me_hand","e":"🤙🏽"},"1F3FE":{"k":"call_me_hand-1F3FE","n":"call_me_hand","e":"🤙🏾"},"1F3FF":{"k":"call_me_hand-1F3FF","n":"call_me_hand","e":"🤙🏿"}}},{"n":["raised_hand_with_fingers_splayed"],"e":"🖐️","c":1,"v":{"1F3FB":{"k":"raised_hand_with_fingers_splayed-1F3FB","n":"raised_hand_with_fingers_splayed","e":"🖐🏻"},"1F3FC":{"k":"raised_hand_with_fingers_splayed-1F3FC","n":"raised_hand_with_fingers_splayed","e":"🖐🏼"},"1F3FD":{"k":"raised_hand_with_fingers_splayed-1F3FD","n":"raised_hand_with_fingers_splayed","e":"🖐🏽"},"1F3FE":{"k":"raised_hand_with_fingers_splayed-1F3FE","n":"raised_hand_with_fingers_splayed","e":"🖐🏾"},"1F3FF":{"k":"raised_hand_with_fingers_splayed-1F3FF","n":"raised_hand_with_fingers_splayed","e":"🖐🏿"}}},{"n":["hand","raised_hand"],"e":"✋","c":1,"v":{"1F3FB":{"k":"hand-1F3FB","n":"hand","e":"✋🏻"},"1F3FC":{"k":"hand-1F3FC","n":"hand","e":"✋🏼"},"1F3FD":{"k":"hand-1F3FD","n":"hand","e":"✋🏽"},"1F3FE":{"k":"hand-1F3FE","n":"hand","e":"✋🏾"},"1F3FF":{"k":"hand-1F3FF","n":"hand","e":"✋🏿"}}},{"n":["ok_hand"],"e":"👌","c":1,"v":{"1F3FB":{"k":"ok_hand-1F3FB","n":"ok_hand","e":"👌🏻"},"1F3FC":{"k":"ok_hand-1F3FC","n":"ok_hand","e":"👌🏼"},"1F3FD":{"k":"ok_hand-1F3FD","n":"ok_hand","e":"👌🏽"},"1F3FE":{"k":"ok_hand-1F3FE","n":"ok_hand","e":"👌🏾"},"1F3FF":{"k":"ok_hand-1F3FF","n":"ok_hand","e":"👌🏿"}}},{"n":["+1","thumbsup"],"e":"👍","c":1,"v":{"1F3FB":{"k":"+1-1F3FB","n":"+1","e":"👍🏻"},"1F3FC":{"k":"+1-1F3FC","n":"+1","e":"👍🏼"},"1F3FD":{"k":"+1-1F3FD","n":"+1","e":"👍🏽"},"1F3FE":{"k":"+1-1F3FE","n":"+1","e":"👍🏾"},"1F3FF":{"k":"+1-1F3FF","n":"+1","e":"👍🏿"}}},{"n":["-1","thumbsdown"],"e":"👎","c":1,"v":{"1F3FB":{"k":"-1-1F3FB","n":"-1","e":"👎🏻"},"1F3FC":{"k":"-1-1F3FC","n":"-1","e":"👎🏼"},"1F3FD":{"k":"-1-1F3FD","n":"-1","e":"👎🏽"},"1F3FE":{"k":"-1-1F3FE","n":"-1","e":"👎🏾"},"1F3FF":{"k":"-1-1F3FF","n":"-1","e":"👎🏿"}}},{"n":["fist"],"e":"✊","c":1,"v":{"1F3FB":{"k":"fist-1F3FB","n":"fist","e":"✊🏻"},"1F3FC":{"k":"fist-1F3FC","n":"fist","e":"✊🏼"},"1F3FD":{"k":"fist-1F3FD","n":"fist","e":"✊🏽"},"1F3FE":{"k":"fist-1F3FE","n":"fist","e":"✊🏾"},"1F3FF":{"k":"fist-1F3FF","n":"fist","e":"✊🏿"}}},{"n":["facepunch","punch"],"e":"👊","c":1,"v":{"1F3FB":{"k":"facepunch-1F3FB","n":"facepunch","e":"👊🏻"},"1F3FC":{"k":"facepunch-1F3FC","n":"facepunch","e":"👊🏼"},"1F3FD":{"k":"facepunch-1F3FD","n":"facepunch","e":"👊🏽"},"1F3FE":{"k":"facepunch-1F3FE","n":"facepunch","e":"👊🏾"},"1F3FF":{"k":"facepunch-1F3FF","n":"facepunch","e":"👊🏿"}}},{"n":["left-facing_fist"],"e":"🤛","c":1,"v":{"1F3FB":{"k":"left-facing_fist-1F3FB","n":"left-facing_fist","e":"🤛🏻"},"1F3FC":{"k":"left-facing_fist-1F3FC","n":"left-facing_fist","e":"🤛🏼"},"1F3FD":{"k":"left-facing_fist-1F3FD","n":"left-facing_fist","e":"🤛🏽"},"1F3FE":{"k":"left-facing_fist-1F3FE","n":"left-facing_fist","e":"🤛🏾"},"1F3FF":{"k":"left-facing_fist-1F3FF","n":"left-facing_fist","e":"🤛🏿"}}},{"n":["right-facing_fist"],"e":"🤜","c":1,"v":{"1F3FB":{"k":"right-facing_fist-1F3FB","n":"right-facing_fist","e":"🤜🏻"},"1F3FC":{"k":"right-facing_fist-1F3FC","n":"right-facing_fist","e":"🤜🏼"},"1F3FD":{"k":"right-facing_fist-1F3FD","n":"right-facing_fist","e":"🤜🏽"},"1F3FE":{"k":"right-facing_fist-1F3FE","n":"right-facing_fist","e":"🤜🏾"},"1F3FF":{"k":"right-facing_fist-1F3FF","n":"right-facing_fist","e":"🤜🏿"}}},{"n":["raised_back_of_hand"],"e":"🤚","c":1,"v":{"1F3FB":{"k":"raised_back_of_hand-1F3FB","n":"raised_back_of_hand","e":"🤚🏻"},"1F3FC":{"k":"raised_back_of_hand-1F3FC","n":"raised_back_of_hand","e":"🤚🏼"},"1F3FD":{"k":"raised_back_of_hand-1F3FD","n":"raised_back_of_hand","e":"🤚🏽"},"1F3FE":{"k":"raised_back_of_hand-1F3FE","n":"raised_back_of_hand","e":"🤚🏾"},"1F3FF":{"k":"raised_back_of_hand-1F3FF","n":"raised_back_of_hand","e":"🤚🏿"}}},{"n":["wave"],"e":"👋","c":1,"v":{"1F3FB":{"k":"wave-1F3FB","n":"wave","e":"👋🏻"},"1F3FC":{"k":"wave-1F3FC","n":"wave","e":"👋🏼"},"1F3FD":{"k":"wave-1F3FD","n":"wave","e":"👋🏽"},"1F3FE":{"k":"wave-1F3FE","n":"wave","e":"👋🏾"},"1F3FF":{"k":"wave-1F3FF","n":"wave","e":"👋🏿"}}},{"n":["i_love_you_hand_sign"],"e":"🤟","c":1,"v":{"1F3FB":{"k":"i_love_you_hand_sign-1F3FB","n":"i_love_you_hand_sign","e":"🤟🏻"},"1F3FC":{"k":"i_love_you_hand_sign-1F3FC","n":"i_love_you_hand_sign","e":"🤟🏼"},"1F3FD":{"k":"i_love_you_hand_sign-1F3FD","n":"i_love_you_hand_sign","e":"🤟🏽"},"1F3FE":{"k":"i_love_you_hand_sign-1F3FE","n":"i_love_you_hand_sign","e":"🤟🏾"},"1F3FF":{"k":"i_love_you_hand_sign-1F3FF","n":"i_love_you_hand_sign","e":"🤟🏿"}}},{"n":["writing_hand"],"e":"✍️","c":1,"v":{"1F3FB":{"k":"writing_hand-1F3FB","n":"writing_hand","e":"✍🏻"},"1F3FC":{"k":"writing_hand-1F3FC","n":"writing_hand","e":"✍🏼"},"1F3FD":{"k":"writing_hand-1F3FD","n":"writing_hand","e":"✍🏽"},"1F3FE":{"k":"writing_hand-1F3FE","n":"writing_hand","e":"✍🏾"},"1F3FF":{"k":"writing_hand-1F3FF","n":"writing_hand","e":"✍🏿"}}},{"n":["clap"],"e":"👏","c":1,"v":{"1F3FB":{"k":"clap-1F3FB","n":"clap","e":"👏🏻"},"1F3FC":{"k":"clap-1F3FC","n":"clap","e":"👏🏼"},"1F3FD":{"k":"clap-1F3FD","n":"clap","e":"👏🏽"},"1F3FE":{"k":"clap-1F3FE","n":"clap","e":"👏🏾"},"1F3FF":{"k":"clap-1F3FF","n":"clap","e":"👏🏿"}}},{"n":["open_hands"],"e":"👐","c":1,"v":{"1F3FB":{"k":"open_hands-1F3FB","n":"open_hands","e":"👐🏻"},"1F3FC":{"k":"open_hands-1F3FC","n":"open_hands","e":"👐🏼"},"1F3FD":{"k":"open_hands-1F3FD","n":"open_hands","e":"👐🏽"},"1F3FE":{"k":"open_hands-1F3FE","n":"open_hands","e":"👐🏾"},"1F3FF":{"k":"open_hands-1F3FF","n":"open_hands","e":"👐🏿"}}},{"n":["raised_hands"],"e":"🙌","c":1,"v":{"1F3FB":{"k":"raised_hands-1F3FB","n":"raised_hands","e":"🙌🏻"},"1F3FC":{"k":"raised_hands-1F3FC","n":"raised_hands","e":"🙌🏼"},"1F3FD":{"k":"raised_hands-1F3FD","n":"raised_hands","e":"🙌🏽"},"1F3FE":{"k":"raised_hands-1F3FE","n":"raised_hands","e":"🙌🏾"},"1F3FF":{"k":"raised_hands-1F3FF","n":"raised_hands","e":"🙌🏿"}}},{"n":["palms_up_together"],"e":"🤲","c":1,"v":{"1F3FB":{"k":"palms_up_together-1F3FB","n":"palms_up_together","e":"🤲🏻"},"1F3FC":{"k":"palms_up_together-1F3FC","n":"palms_up_together","e":"🤲🏼"},"1F3FD":{"k":"palms_up_together-1F3FD","n":"palms_up_together","e":"🤲🏽"},"1F3FE":{"k":"palms_up_together-1F3FE","n":"palms_up_together","e":"🤲🏾"},"1F3FF":{"k":"palms_up_together-1F3FF","n":"palms_up_together","e":"🤲🏿"}}},{"n":["pray"],"e":"🙏","c":1,"v":{"1F3FB":{"k":"pray-1F3FB","n":"pray","e":"🙏🏻"},"1F3FC":{"k":"pray-1F3FC","n":"pray","e":"🙏🏼"},"1F3FD":{"k":"pray-1F3FD","n":"pray","e":"🙏🏽"},"1F3FE":{"k":"pray-1F3FE","n":"pray","e":"🙏🏾"},"1F3FF":{"k":"pray-1F3FF","n":"pray","e":"🙏🏿"}}},{"n":["handshake"],"e":"🤝","c":1},{"n":["nail_care"],"e":"💅","c":1,"v":{"1F3FB":{"k":"nail_care-1F3FB","n":"nail_care","e":"💅🏻"},"1F3FC":{"k":"nail_care-1F3FC","n":"nail_care","e":"💅🏼"},"1F3FD":{"k":"nail_care-1F3FD","n":"nail_care","e":"💅🏽"},"1F3FE":{"k":"nail_care-1F3FE","n":"nail_care","e":"💅🏾"},"1F3FF":{"k":"nail_care-1F3FF","n":"nail_care","e":"💅🏿"}}},{"n":["ear"],"e":"👂","c":1,"v":{"1F3FB":{"k":"ear-1F3FB","n":"ear","e":"👂🏻"},"1F3FC":{"k":"ear-1F3FC","n":"ear","e":"👂🏼"},"1F3FD":{"k":"ear-1F3FD","n":"ear","e":"👂🏽"},"1F3FE":{"k":"ear-1F3FE","n":"ear","e":"👂🏾"},"1F3FF":{"k":"ear-1F3FF","n":"ear","e":"👂🏿"}}},{"n":["nose"],"e":"👃","c":1,"v":{"1F3FB":{"k":"nose-1F3FB","n":"nose","e":"👃🏻"},"1F3FC":{"k":"nose-1F3FC","n":"nose","e":"👃🏼"},"1F3FD":{"k":"nose-1F3FD","n":"nose","e":"👃🏽"},"1F3FE":{"k":"nose-1F3FE","n":"nose","e":"👃🏾"},"1F3FF":{"k":"nose-1F3FF","n":"nose","e":"👃🏿"}}},{"n":["footprints"],"e":"👣","c":1},{"n":["eyes"],"e":"👀","c":1},{"n":["eye"],"e":"👁️","c":1},{"n":["eye-in-speech-bubble"],"e":"👁️‍🗨️","c":1},{"n":["brain"],"e":"🧠","c":1},{"n":["tongue"],"e":"👅","c":1},{"n":["lips"],"e":"👄","c":1},{"n":["kiss"],"e":"💋","c":1},{"n":["cupid"],"e":"💘","c":1},{"n":["heart"],"e":"❤️","c":1},{"n":["heartbeat"],"e":"💓","c":1},{"n":["broken_heart"],"e":"💔","c":1},{"n":["two_hearts"],"e":"💕","c":1},{"n":["sparkling_heart"],"e":"💖","c":1},{"n":["heartpulse"],"e":"💗","c":1},{"n":["blue_heart"],"e":"💙","c":1},{"n":["green_heart"],"e":"💚","c":1},{"n":["yellow_heart"],"e":"💛","c":1},{"n":["orange_heart"],"e":"🧡","c":1},{"n":["purple_heart"],"e":"💜","c":1},{"n":["black_heart"],"e":"🖤","c":1},{"n":["gift_heart"],"e":"💝","c":1},{"n":["revolving_hearts"],"e":"💞","c":1},{"n":["heart_decoration"],"e":"💟","c":1},{"n":["heavy_heart_exclamation_mark_ornament"],"e":"❣️","c":1},{"n":["love_letter"],"e":"💌","c":1},{"n":["zzz"],"e":"💤","c":1},{"n":["anger"],"e":"💢","c":1},{"n":["bomb"],"e":"💣","c":1},{"n":["boom","collision"],"e":"💥","c":1},{"n":["sweat_drops"],"e":"💦","c":1},{"n":["dash"],"e":"💨","c":1},{"n":["dizzy"],"e":"💫","c":1},{"n":["speech_balloon"],"e":"💬","c":1},{"n":["left_speech_bubble"],"e":"🗨️","c":1},{"n":["right_anger_bubble"],"e":"🗯️","c":1},{"n":["thought_balloon"],"e":"💭","c":1},{"n":["hole"],"e":"🕳️","c":1},{"n":["eyeglasses"],"e":"👓","c":1},{"n":["dark_sunglasses"],"e":"🕶️","c":1},{"n":["necktie"],"e":"👔","c":1},{"n":["shirt","tshirt"],"e":"👕","c":1},{"n":["jeans"],"e":"👖","c":1},{"n":["scarf"],"e":"🧣","c":1},{"n":["gloves"],"e":"🧤","c":1},{"n":["coat"],"e":"🧥","c":1},{"n":["socks"],"e":"🧦","c":1},{"n":["dress"],"e":"👗","c":1},{"n":["kimono"],"e":"👘","c":1},{"n":["bikini"],"e":"👙","c":1},{"n":["womans_clothes"],"e":"👚","c":1},{"n":["purse"],"e":"👛","c":1},{"n":["handbag"],"e":"👜","c":1},{"n":["pouch"],"e":"👝","c":1},{"n":["shopping_bags"],"e":"🛍️","c":1},{"n":["school_satchel"],"e":"🎒","c":1},{"n":["mans_shoe","shoe"],"e":"👞","c":1},{"n":["athletic_shoe"],"e":"👟","c":1},{"n":["high_heel"],"e":"👠","c":1},{"n":["sandal"],"e":"👡","c":1},{"n":["boot"],"e":"👢","c":1},{"n":["crown"],"e":"👑","c":1},{"n":["womans_hat"],"e":"👒","c":1},{"n":["tophat"],"e":"🎩","c":1},{"n":["mortar_board"],"e":"🎓","c":1},{"n":["billed_cap"],"e":"🧢","c":1},{"n":["helmet_with_white_cross"],"e":"⛑️","c":1},{"n":["prayer_beads"],"e":"📿","c":1},{"n":["lipstick"],"e":"💄","c":1},{"n":["ring"],"e":"💍","c":1},{"n":["gem"],"e":"💎","c":1}]; + + var EMOJI='emoji';var SHOW_TABS='showTabs';var HIDE_TABS='hideTabs';var SHOW_SEARCH_RESULTS='showSearchResults';var SHOW_PREVIEW='showPreview';var HIDE_PREVIEW='hidePreview';var HIDE_VARIANT_POPUP='hideVariantPopup'; + + function createElement(tagName,className){var element=document.createElement(tagName);if(className){element.className=className;}return element;}function empty(element){while(element.firstChild){element.removeChild(element.firstChild);}}function getEmojiName(emoji){return typeof emoji.n==='string'?emoji.n:emoji.n[0];} + + var CLASS_PREVIEW='emoji-picker__preview';var CLASS_PREVIEW_EMOJI='emoji-picker__preview-emoji';var CLASS_PREVIEW_NAME='emoji-picker__preview-name';var EmojiPreview=/*#__PURE__*/function(){function EmojiPreview(events){_classCallCheck(this,EmojiPreview);this.events=events;}_createClass(EmojiPreview,[{key:"render",value:function render(){var _this=this;var preview=createElement('div',CLASS_PREVIEW);this.emoji=createElement('div',CLASS_PREVIEW_EMOJI);preview.appendChild(this.emoji);this.name=createElement('div',CLASS_PREVIEW_NAME);preview.appendChild(this.name);this.events.on(SHOW_PREVIEW,function(emoji){return _this.showPreview(emoji);});this.events.on(HIDE_PREVIEW,function(){return _this.hidePreview();});return preview;}},{key:"showPreview",value:function showPreview(emoji){this.emoji.innerHTML=emoji.e;this.name.innerHTML=getEmojiName(emoji);}},{key:"hidePreview",value:function hidePreview(){this.emoji.innerHTML='';this.name.innerHTML='';}}]);return EmojiPreview;}(); + + function _classCallCheck$1(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties$1(target,props){for(var i=0;i + if(val==='')return true;if(val==='false')return false;if(val==='true')return true;return val;}if(DOCUMENT&&typeof DOCUMENT.querySelector==='function'){var attrs=[['data-family-prefix','familyPrefix'],['data-replacement-class','replacementClass'],['data-auto-replace-svg','autoReplaceSvg'],['data-auto-add-css','autoAddCss'],['data-auto-a11y','autoA11y'],['data-search-pseudo-elements','searchPseudoElements'],['data-observe-mutations','observeMutations'],['data-mutate-approach','mutateApproach'],['data-keep-original-source','keepOriginalSource'],['data-measure-performance','measurePerformance'],['data-show-missing-icons','showMissingIcons']];attrs.forEach(function(_ref){var _ref2=_slicedToArray(_ref,2),attr=_ref2[0],key=_ref2[1];var val=coerce(getAttrConfig(attr));if(val!==undefined&&val!==null){initial[key]=val;}});}var _default={familyPrefix:DEFAULT_FAMILY_PREFIX,replacementClass:DEFAULT_REPLACEMENT_CLASS,autoReplaceSvg:true,autoAddCss:true,autoA11y:true,searchPseudoElements:false,observeMutations:true,mutateApproach:'async',keepOriginalSource:true,measurePerformance:false,showMissingIcons:true};var _config=_objectSpread({},_default,initial);if(!_config.autoReplaceSvg)_config.observeMutations=false;var config=_objectSpread({},_config);WINDOW.FontAwesomeConfig=config;var w=WINDOW||{};if(!w[NAMESPACE_IDENTIFIER])w[NAMESPACE_IDENTIFIER]={};if(!w[NAMESPACE_IDENTIFIER].styles)w[NAMESPACE_IDENTIFIER].styles={};if(!w[NAMESPACE_IDENTIFIER].hooks)w[NAMESPACE_IDENTIFIER].hooks={};if(!w[NAMESPACE_IDENTIFIER].shims)w[NAMESPACE_IDENTIFIER].shims=[];var namespace=w[NAMESPACE_IDENTIFIER];var functions=[];var listener=function listener(){DOCUMENT.removeEventListener('DOMContentLoaded',listener);loaded=1;functions.map(function(fn){return fn();});};var loaded=false;if(IS_DOM){loaded=(DOCUMENT.documentElement.doScroll?/^loaded|^c/:/^loaded|^i|^c/).test(DOCUMENT.readyState);if(!loaded)DOCUMENT.addEventListener('DOMContentLoaded',listener);}var isNode=typeof global!=='undefined'&&typeof global.process!=='undefined'&&typeof global.process.emit==='function';var meaninglessTransform={size:16,x:0,y:0,rotate:0,flipX:false,flipY:false};function insertCss(css){if(!css||!IS_DOM){return;}var style=DOCUMENT.createElement('style');style.setAttribute('type','text/css');style.innerHTML=css;var headChildren=DOCUMENT.head.childNodes;var beforeChild=null;for(var i=headChildren.length-1;i>-1;i--){var child=headChildren[i];var tagName=(child.tagName||'').toUpperCase();if(['STYLE','LINK'].indexOf(tagName)>-1){beforeChild=child;}}DOCUMENT.head.insertBefore(style,beforeChild);return css;}var idPool='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';function nextUniqueId(){var size=12;var id='';while(size-->0){id+=idPool[Math.random()*62|0];}return id;}function htmlEscape(str){return "".concat(str).replace(/&/g,'&').replace(/"/g,'"').replace(/'/g,''').replace(//g,'>');}function joinAttributes(attributes){return Object.keys(attributes||{}).reduce(function(acc,attributeName){return acc+"".concat(attributeName,"=\"").concat(htmlEscape(attributes[attributeName]),"\" ");},'').trim();}function joinStyles(styles){return Object.keys(styles||{}).reduce(function(acc,styleName){return acc+"".concat(styleName,": ").concat(styles[styleName],";");},'');}function transformIsMeaningful(transform){return transform.size!==meaninglessTransform.size||transform.x!==meaninglessTransform.x||transform.y!==meaninglessTransform.y||transform.rotate!==meaninglessTransform.rotate||transform.flipX||transform.flipY;}function transformForSvg(_ref){var transform=_ref.transform,containerWidth=_ref.containerWidth,iconWidth=_ref.iconWidth;var outer={transform:"translate(".concat(containerWidth/2," 256)")};var innerTranslate="translate(".concat(transform.x*32,", ").concat(transform.y*32,") ");var innerScale="scale(".concat(transform.size/16*(transform.flipX?-1:1),", ").concat(transform.size/16*(transform.flipY?-1:1),") ");var innerRotate="rotate(".concat(transform.rotate," 0 0)");var inner={transform:"".concat(innerTranslate," ").concat(innerScale," ").concat(innerRotate)};var path={transform:"translate(".concat(iconWidth/2*-1," -256)")};return {outer:outer,inner:inner,path:path};}var ALL_SPACE={x:0,y:0,width:'100%',height:'100%'};function fillBlack(abstract){var force=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;if(abstract.attributes&&(abstract.attributes.fill||force)){abstract.attributes.fill='black';}return abstract;}function deGroup(abstract){if(abstract.tag==='g'){return abstract.children;}else{return [abstract];}}function makeIconMasking(_ref){var children=_ref.children,attributes=_ref.attributes,main=_ref.main,mask=_ref.mask,transform=_ref.transform;var mainWidth=main.width,mainPath=main.icon;var maskWidth=mask.width,maskPath=mask.icon;var trans=transformForSvg({transform:transform,containerWidth:maskWidth,iconWidth:mainWidth});var maskRect={tag:'rect',attributes:_objectSpread({},ALL_SPACE,{fill:'white'})};var maskInnerGroupChildrenMixin=mainPath.children?{children:mainPath.children.map(fillBlack)}:{};var maskInnerGroup={tag:'g',attributes:_objectSpread({},trans.inner),children:[fillBlack(_objectSpread({tag:mainPath.tag,attributes:_objectSpread({},mainPath.attributes,trans.path)},maskInnerGroupChildrenMixin))]};var maskOuterGroup={tag:'g',attributes:_objectSpread({},trans.outer),children:[maskInnerGroup]};var maskId="mask-".concat(nextUniqueId());var clipId="clip-".concat(nextUniqueId());var maskTag={tag:'mask',attributes:_objectSpread({},ALL_SPACE,{id:maskId,maskUnits:'userSpaceOnUse',maskContentUnits:'userSpaceOnUse'}),children:[maskRect,maskOuterGroup]};var defs={tag:'defs',children:[{tag:'clipPath',attributes:{id:clipId},children:deGroup(maskPath)},maskTag]};children.push(defs,{tag:'rect',attributes:_objectSpread({fill:'currentColor','clip-path':"url(#".concat(clipId,")"),mask:"url(#".concat(maskId,")")},ALL_SPACE)});return {children:children,attributes:attributes};}function makeIconStandard(_ref){var children=_ref.children,attributes=_ref.attributes,main=_ref.main,transform=_ref.transform,styles=_ref.styles;var styleString=joinStyles(styles);if(styleString.length>0){attributes['style']=styleString;}if(transformIsMeaningful(transform)){var trans=transformForSvg({transform:transform,containerWidth:main.width,iconWidth:main.width});children.push({tag:'g',attributes:_objectSpread({},trans.outer),children:[{tag:'g',attributes:_objectSpread({},trans.inner),children:[{tag:main.icon.tag,children:main.icon.children,attributes:_objectSpread({},main.icon.attributes,trans.path)}]}]});}else{children.push(main.icon);}return {children:children,attributes:attributes};}function asIcon(_ref){var children=_ref.children,main=_ref.main,mask=_ref.mask,attributes=_ref.attributes,styles=_ref.styles,transform=_ref.transform;if(transformIsMeaningful(transform)&&main.found&&!mask.found){var width=main.width,height=main.height;var offset={x:width/height/2,y:0.5};attributes['style']=joinStyles(_objectSpread({},styles,{'transform-origin':"".concat(offset.x+transform.x/16,"em ").concat(offset.y+transform.y/16,"em")}));}return [{tag:'svg',attributes:attributes,children:children}];}function asSymbol(_ref){var prefix=_ref.prefix,iconName=_ref.iconName,children=_ref.children,attributes=_ref.attributes,symbol=_ref.symbol;var id=symbol===true?"".concat(prefix,"-").concat(config.familyPrefix,"-").concat(iconName):symbol;return [{tag:'svg',attributes:{style:'display: none;'},children:[{tag:'symbol',attributes:_objectSpread({},attributes,{id:id}),children:children}]}];}function makeInlineSvgAbstract(params){var _params$icons=params.icons,main=_params$icons.main,mask=_params$icons.mask,prefix=params.prefix,iconName=params.iconName,transform=params.transform,symbol=params.symbol,title=params.title,extra=params.extra,_params$watchable=params.watchable,watchable=_params$watchable===void 0?false:_params$watchable;var _ref=mask.found?mask:main,width=_ref.width,height=_ref.height;var widthClass="fa-w-".concat(Math.ceil(width/height*16));var attrClass=[config.replacementClass,iconName?"".concat(config.familyPrefix,"-").concat(iconName):'',widthClass].filter(function(c){return extra.classes.indexOf(c)===-1;}).concat(extra.classes).join(' ');var content={children:[],attributes:_objectSpread({},extra.attributes,{'data-prefix':prefix,'data-icon':iconName,'class':attrClass,'role':extra.attributes.role||'img','xmlns':'http://www.w3.org/2000/svg','viewBox':"0 0 ".concat(width," ").concat(height)})};if(watchable){content.attributes[DATA_FA_I2SVG]='';}if(title)content.children.push({tag:'title',attributes:{id:content.attributes['aria-labelledby']||"title-".concat(nextUniqueId())},children:[title]});var args=_objectSpread({},content,{prefix:prefix,iconName:iconName,main:main,mask:mask,transform:transform,symbol:symbol,styles:extra.styles});var _ref2=mask.found&&main.found?makeIconMasking(args):makeIconStandard(args),children=_ref2.children,attributes=_ref2.attributes;args.children=children;args.attributes=attributes;if(symbol){return asSymbol(args);}else{return asIcon(args);}}var noop$1=function noop(){};var p=config.measurePerformance&&PERFORMANCE&&PERFORMANCE.mark&&PERFORMANCE.measure?PERFORMANCE:{mark:noop$1,measure:noop$1};/** + * Internal helper to bind a function known to have 4 arguments + * to a given context. + */var bindInternal4=function bindInternal4(func,thisContext){return function(a,b,c,d){return func.call(thisContext,a,b,c,d);};};/** + * # Reduce + * + * A fast object `.reduce()` implementation. + * + * @param {Object} subject The object to reduce over. + * @param {Function} fn The reducer function. + * @param {mixed} initialValue The initial value for the reducer, defaults to subject[0]. + * @param {Object} thisContext The context for the reducer. + * @return {mixed} The final result. + */var reduce=function fastReduceObject(subject,fn,initialValue,thisContext){var keys=Object.keys(subject),length=keys.length,iterator=thisContext!==undefined?bindInternal4(fn,thisContext):fn,i,key,result;if(initialValue===undefined){i=1;result=subject[keys[0]];}else{i=0;result=initialValue;}for(;i2&&arguments[2]!==undefined?arguments[2]:{};var _params$skipHooks=params.skipHooks,skipHooks=_params$skipHooks===void 0?false:_params$skipHooks;var normalized=Object.keys(icons).reduce(function(acc,iconName){var icon=icons[iconName];var expanded=!!icon.icon;if(expanded){acc[icon.iconName]=icon.icon;}else{acc[iconName]=icon;}return acc;},{});if(typeof namespace.hooks.addPack==='function'&&!skipHooks){namespace.hooks.addPack(prefix,normalized);}else{namespace.styles[prefix]=_objectSpread({},namespace.styles[prefix]||{},normalized);}/** + * Font Awesome 4 used the prefix of `fa` for all icons. With the introduction + * of new styles we needed to differentiate between them. Prefix `fa` is now an alias + * for `fas` so we'll easy the upgrade process for our users by automatically defining + * this as well. + */if(prefix==='fas'){defineIcons('fa',icons);}}var styles=namespace.styles,shims=namespace.shims;var _byUnicode={};var _byLigature={};var _byOldName={};var build=function build(){var lookup=function lookup(reducer){return reduce(styles,function(o,style,prefix){o[prefix]=reduce(style,reducer,{});return o;},{});};_byUnicode=lookup(function(acc,icon,iconName){if(icon[3]){acc[icon[3]]=iconName;}return acc;});_byLigature=lookup(function(acc,icon,iconName){var ligatures=icon[2];acc[iconName]=iconName;ligatures.forEach(function(ligature){acc[ligature]=iconName;});return acc;});var hasRegular='far'in styles;_byOldName=reduce(shims,function(acc,shim){var oldName=shim[0];var prefix=shim[1];var iconName=shim[2];if(prefix==='far'&&!hasRegular){prefix='fas';}acc[oldName]={prefix:prefix,iconName:iconName};return acc;},{});};build();var styles$1=namespace.styles;function iconFromMapping(mapping,prefix,iconName){if(mapping&&mapping[prefix]&&mapping[prefix][iconName]){return {prefix:prefix,iconName:iconName,icon:mapping[prefix][iconName]};}}function toHtml(abstractNodes){var tag=abstractNodes.tag,_abstractNodes$attrib=abstractNodes.attributes,attributes=_abstractNodes$attrib===void 0?{}:_abstractNodes$attrib,_abstractNodes$childr=abstractNodes.children,children=_abstractNodes$childr===void 0?[]:_abstractNodes$childr;if(typeof abstractNodes==='string'){return htmlEscape(abstractNodes);}else{return "<".concat(tag," ").concat(joinAttributes(attributes),">").concat(children.map(toHtml).join(''),"");}}function MissingIcon(error){this.name='MissingIcon';this.message=error||'Icon unavailable';this.stack=new Error().stack;}MissingIcon.prototype=Object.create(Error.prototype);MissingIcon.prototype.constructor=MissingIcon;var FILL={fill:'currentColor'};var ANIMATION_BASE={attributeType:'XML',repeatCount:'indefinite',dur:'2s'};var RING={tag:'path',attributes:_objectSpread({},FILL,{d:'M156.5,447.7l-12.6,29.5c-18.7-9.5-35.9-21.2-51.5-34.9l22.7-22.7C127.6,430.5,141.5,440,156.5,447.7z M40.6,272H8.5 c1.4,21.2,5.4,41.7,11.7,61.1L50,321.2C45.1,305.5,41.8,289,40.6,272z M40.6,240c1.4-18.8,5.2-37,11.1-54.1l-29.5-12.6 C14.7,194.3,10,216.7,8.5,240H40.6z M64.3,156.5c7.8-14.9,17.2-28.8,28.1-41.5L69.7,92.3c-13.7,15.6-25.5,32.8-34.9,51.5 L64.3,156.5z M397,419.6c-13.9,12-29.4,22.3-46.1,30.4l11.9,29.8c20.7-9.9,39.8-22.6,56.9-37.6L397,419.6z M115,92.4 c13.9-12,29.4-22.3,46.1-30.4l-11.9-29.8c-20.7,9.9-39.8,22.6-56.8,37.6L115,92.4z M447.7,355.5c-7.8,14.9-17.2,28.8-28.1,41.5 l22.7,22.7c13.7-15.6,25.5-32.9,34.9-51.5L447.7,355.5z M471.4,272c-1.4,18.8-5.2,37-11.1,54.1l29.5,12.6 c7.5-21.1,12.2-43.5,13.6-66.8H471.4z M321.2,462c-15.7,5-32.2,8.2-49.2,9.4v32.1c21.2-1.4,41.7-5.4,61.1-11.7L321.2,462z M240,471.4c-18.8-1.4-37-5.2-54.1-11.1l-12.6,29.5c21.1,7.5,43.5,12.2,66.8,13.6V471.4z M462,190.8c5,15.7,8.2,32.2,9.4,49.2h32.1 c-1.4-21.2-5.4-41.7-11.7-61.1L462,190.8z M92.4,397c-12-13.9-22.3-29.4-30.4-46.1l-29.8,11.9c9.9,20.7,22.6,39.8,37.6,56.9 L92.4,397z M272,40.6c18.8,1.4,36.9,5.2,54.1,11.1l12.6-29.5C317.7,14.7,295.3,10,272,8.5V40.6z M190.8,50 c15.7-5,32.2-8.2,49.2-9.4V8.5c-21.2,1.4-41.7,5.4-61.1,11.7L190.8,50z M442.3,92.3L419.6,115c12,13.9,22.3,29.4,30.5,46.1 l29.8-11.9C470,128.5,457.3,109.4,442.3,92.3z M397,92.4l22.7-22.7c-15.6-13.7-32.8-25.5-51.5-34.9l-12.6,29.5 C370.4,72.1,384.4,81.5,397,92.4z'})};var OPACITY_ANIMATE=_objectSpread({},ANIMATION_BASE,{attributeName:'opacity'});var DOT={tag:'circle',attributes:_objectSpread({},FILL,{cx:'256',cy:'364',r:'28'}),children:[{tag:'animate',attributes:_objectSpread({},ANIMATION_BASE,{attributeName:'r',values:'28;14;28;28;14;28;'})},{tag:'animate',attributes:_objectSpread({},OPACITY_ANIMATE,{values:'1;0;1;1;0;1;'})}]};var QUESTION={tag:'path',attributes:_objectSpread({},FILL,{opacity:'1',d:'M263.7,312h-16c-6.6,0-12-5.4-12-12c0-71,77.4-63.9,77.4-107.8c0-20-17.8-40.2-57.4-40.2c-29.1,0-44.3,9.6-59.2,28.7 c-3.9,5-11.1,6-16.2,2.4l-13.1-9.2c-5.6-3.9-6.9-11.8-2.6-17.2c21.2-27.2,46.4-44.7,91.2-44.7c52.3,0,97.4,29.8,97.4,80.2 c0,67.6-77.4,63.5-77.4,107.8C275.7,306.6,270.3,312,263.7,312z'}),children:[{tag:'animate',attributes:_objectSpread({},OPACITY_ANIMATE,{values:'1;0;0;0;0;1;'})}]};var EXCLAMATION={tag:'path',attributes:_objectSpread({},FILL,{opacity:'0',d:'M232.5,134.5l7,168c0.3,6.4,5.6,11.5,12,11.5h9c6.4,0,11.7-5.1,12-11.5l7-168c0.3-6.8-5.2-12.5-12-12.5h-23 C237.7,122,232.2,127.7,232.5,134.5z'}),children:[{tag:'animate',attributes:_objectSpread({},OPACITY_ANIMATE,{values:'0;0;1;1;0;0;'})}]};var styles$2=namespace.styles;function asFoundIcon(icon){var width=icon[0];var height=icon[1];var _icon$slice=icon.slice(4),_icon$slice2=_slicedToArray(_icon$slice,1),vectorData=_icon$slice2[0];var element=null;if(Array.isArray(vectorData)){element={tag:'g',attributes:{class:"".concat(config.familyPrefix,"-").concat(DUOTONE_CLASSES.GROUP)},children:[{tag:'path',attributes:{class:"".concat(config.familyPrefix,"-").concat(DUOTONE_CLASSES.SECONDARY),fill:'currentColor',d:vectorData[0]}},{tag:'path',attributes:{class:"".concat(config.familyPrefix,"-").concat(DUOTONE_CLASSES.PRIMARY),fill:'currentColor',d:vectorData[1]}}]};}else{element={tag:'path',attributes:{fill:'currentColor',d:vectorData}};}return {found:true,width:width,height:height,icon:element};}var styles$3=namespace.styles;var baseStyles="svg:not(:root).svg-inline--fa {\n overflow: visible;\n}\n\n.svg-inline--fa {\n display: inline-block;\n font-size: inherit;\n height: 1em;\n overflow: visible;\n vertical-align: -0.125em;\n}\n.svg-inline--fa.fa-lg {\n vertical-align: -0.225em;\n}\n.svg-inline--fa.fa-w-1 {\n width: 0.0625em;\n}\n.svg-inline--fa.fa-w-2 {\n width: 0.125em;\n}\n.svg-inline--fa.fa-w-3 {\n width: 0.1875em;\n}\n.svg-inline--fa.fa-w-4 {\n width: 0.25em;\n}\n.svg-inline--fa.fa-w-5 {\n width: 0.3125em;\n}\n.svg-inline--fa.fa-w-6 {\n width: 0.375em;\n}\n.svg-inline--fa.fa-w-7 {\n width: 0.4375em;\n}\n.svg-inline--fa.fa-w-8 {\n width: 0.5em;\n}\n.svg-inline--fa.fa-w-9 {\n width: 0.5625em;\n}\n.svg-inline--fa.fa-w-10 {\n width: 0.625em;\n}\n.svg-inline--fa.fa-w-11 {\n width: 0.6875em;\n}\n.svg-inline--fa.fa-w-12 {\n width: 0.75em;\n}\n.svg-inline--fa.fa-w-13 {\n width: 0.8125em;\n}\n.svg-inline--fa.fa-w-14 {\n width: 0.875em;\n}\n.svg-inline--fa.fa-w-15 {\n width: 0.9375em;\n}\n.svg-inline--fa.fa-w-16 {\n width: 1em;\n}\n.svg-inline--fa.fa-w-17 {\n width: 1.0625em;\n}\n.svg-inline--fa.fa-w-18 {\n width: 1.125em;\n}\n.svg-inline--fa.fa-w-19 {\n width: 1.1875em;\n}\n.svg-inline--fa.fa-w-20 {\n width: 1.25em;\n}\n.svg-inline--fa.fa-pull-left {\n margin-right: 0.3em;\n width: auto;\n}\n.svg-inline--fa.fa-pull-right {\n margin-left: 0.3em;\n width: auto;\n}\n.svg-inline--fa.fa-border {\n height: 1.5em;\n}\n.svg-inline--fa.fa-li {\n width: 2em;\n}\n.svg-inline--fa.fa-fw {\n width: 1.25em;\n}\n\n.fa-layers svg.svg-inline--fa {\n bottom: 0;\n left: 0;\n margin: auto;\n position: absolute;\n right: 0;\n top: 0;\n}\n\n.fa-layers {\n display: inline-block;\n height: 1em;\n position: relative;\n text-align: center;\n vertical-align: -0.125em;\n width: 1em;\n}\n.fa-layers svg.svg-inline--fa {\n -webkit-transform-origin: center center;\n transform-origin: center center;\n}\n\n.fa-layers-counter, .fa-layers-text {\n display: inline-block;\n position: absolute;\n text-align: center;\n}\n\n.fa-layers-text {\n left: 50%;\n top: 50%;\n -webkit-transform: translate(-50%, -50%);\n transform: translate(-50%, -50%);\n -webkit-transform-origin: center center;\n transform-origin: center center;\n}\n\n.fa-layers-counter {\n background-color: #ff253a;\n border-radius: 1em;\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n color: #fff;\n height: 1.5em;\n line-height: 1;\n max-width: 5em;\n min-width: 1.5em;\n overflow: hidden;\n padding: 0.25em;\n right: 0;\n text-overflow: ellipsis;\n top: 0;\n -webkit-transform: scale(0.25);\n transform: scale(0.25);\n -webkit-transform-origin: top right;\n transform-origin: top right;\n}\n\n.fa-layers-bottom-right {\n bottom: 0;\n right: 0;\n top: auto;\n -webkit-transform: scale(0.25);\n transform: scale(0.25);\n -webkit-transform-origin: bottom right;\n transform-origin: bottom right;\n}\n\n.fa-layers-bottom-left {\n bottom: 0;\n left: 0;\n right: auto;\n top: auto;\n -webkit-transform: scale(0.25);\n transform: scale(0.25);\n -webkit-transform-origin: bottom left;\n transform-origin: bottom left;\n}\n\n.fa-layers-top-right {\n right: 0;\n top: 0;\n -webkit-transform: scale(0.25);\n transform: scale(0.25);\n -webkit-transform-origin: top right;\n transform-origin: top right;\n}\n\n.fa-layers-top-left {\n left: 0;\n right: auto;\n top: 0;\n -webkit-transform: scale(0.25);\n transform: scale(0.25);\n -webkit-transform-origin: top left;\n transform-origin: top left;\n}\n\n.fa-lg {\n font-size: 1.3333333333em;\n line-height: 0.75em;\n vertical-align: -0.0667em;\n}\n\n.fa-xs {\n font-size: 0.75em;\n}\n\n.fa-sm {\n font-size: 0.875em;\n}\n\n.fa-1x {\n font-size: 1em;\n}\n\n.fa-2x {\n font-size: 2em;\n}\n\n.fa-3x {\n font-size: 3em;\n}\n\n.fa-4x {\n font-size: 4em;\n}\n\n.fa-5x {\n font-size: 5em;\n}\n\n.fa-6x {\n font-size: 6em;\n}\n\n.fa-7x {\n font-size: 7em;\n}\n\n.fa-8x {\n font-size: 8em;\n}\n\n.fa-9x {\n font-size: 9em;\n}\n\n.fa-10x {\n font-size: 10em;\n}\n\n.fa-fw {\n text-align: center;\n width: 1.25em;\n}\n\n.fa-ul {\n list-style-type: none;\n margin-left: 2.5em;\n padding-left: 0;\n}\n.fa-ul > li {\n position: relative;\n}\n\n.fa-li {\n left: -2em;\n position: absolute;\n text-align: center;\n width: 2em;\n line-height: inherit;\n}\n\n.fa-border {\n border: solid 0.08em #eee;\n border-radius: 0.1em;\n padding: 0.2em 0.25em 0.15em;\n}\n\n.fa-pull-left {\n float: left;\n}\n\n.fa-pull-right {\n float: right;\n}\n\n.fa.fa-pull-left,\n.fas.fa-pull-left,\n.far.fa-pull-left,\n.fal.fa-pull-left,\n.fab.fa-pull-left {\n margin-right: 0.3em;\n}\n.fa.fa-pull-right,\n.fas.fa-pull-right,\n.far.fa-pull-right,\n.fal.fa-pull-right,\n.fab.fa-pull-right {\n margin-left: 0.3em;\n}\n\n.fa-spin {\n -webkit-animation: fa-spin 2s infinite linear;\n animation: fa-spin 2s infinite linear;\n}\n\n.fa-pulse {\n -webkit-animation: fa-spin 1s infinite steps(8);\n animation: fa-spin 1s infinite steps(8);\n}\n\n@-webkit-keyframes fa-spin {\n 0% {\n -webkit-transform: rotate(0deg);\n transform: rotate(0deg);\n }\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n\n@keyframes fa-spin {\n 0% {\n -webkit-transform: rotate(0deg);\n transform: rotate(0deg);\n }\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n.fa-rotate-90 {\n -ms-filter: \"progid:DXImageTransform.Microsoft.BasicImage(rotation=1)\";\n -webkit-transform: rotate(90deg);\n transform: rotate(90deg);\n}\n\n.fa-rotate-180 {\n -ms-filter: \"progid:DXImageTransform.Microsoft.BasicImage(rotation=2)\";\n -webkit-transform: rotate(180deg);\n transform: rotate(180deg);\n}\n\n.fa-rotate-270 {\n -ms-filter: \"progid:DXImageTransform.Microsoft.BasicImage(rotation=3)\";\n -webkit-transform: rotate(270deg);\n transform: rotate(270deg);\n}\n\n.fa-flip-horizontal {\n -ms-filter: \"progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1)\";\n -webkit-transform: scale(-1, 1);\n transform: scale(-1, 1);\n}\n\n.fa-flip-vertical {\n -ms-filter: \"progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)\";\n -webkit-transform: scale(1, -1);\n transform: scale(1, -1);\n}\n\n.fa-flip-both, .fa-flip-horizontal.fa-flip-vertical {\n -ms-filter: \"progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)\";\n -webkit-transform: scale(-1, -1);\n transform: scale(-1, -1);\n}\n\n:root .fa-rotate-90,\n:root .fa-rotate-180,\n:root .fa-rotate-270,\n:root .fa-flip-horizontal,\n:root .fa-flip-vertical,\n:root .fa-flip-both {\n -webkit-filter: none;\n filter: none;\n}\n\n.fa-stack {\n display: inline-block;\n height: 2em;\n position: relative;\n width: 2.5em;\n}\n\n.fa-stack-1x,\n.fa-stack-2x {\n bottom: 0;\n left: 0;\n margin: auto;\n position: absolute;\n right: 0;\n top: 0;\n}\n\n.svg-inline--fa.fa-stack-1x {\n height: 1em;\n width: 1.25em;\n}\n.svg-inline--fa.fa-stack-2x {\n height: 2em;\n width: 2.5em;\n}\n\n.fa-inverse {\n color: #fff;\n}\n\n.sr-only {\n border: 0;\n clip: rect(0, 0, 0, 0);\n height: 1px;\n margin: -1px;\n overflow: hidden;\n padding: 0;\n position: absolute;\n width: 1px;\n}\n\n.sr-only-focusable:active, .sr-only-focusable:focus {\n clip: auto;\n height: auto;\n margin: 0;\n overflow: visible;\n position: static;\n width: auto;\n}\n\n.svg-inline--fa .fa-primary {\n fill: var(--fa-primary-color, currentColor);\n opacity: 1;\n opacity: var(--fa-primary-opacity, 1);\n}\n\n.svg-inline--fa .fa-secondary {\n fill: var(--fa-secondary-color, currentColor);\n opacity: 0.4;\n opacity: var(--fa-secondary-opacity, 0.4);\n}\n\n.svg-inline--fa.fa-swap-opacity .fa-primary {\n opacity: 0.4;\n opacity: var(--fa-secondary-opacity, 0.4);\n}\n\n.svg-inline--fa.fa-swap-opacity .fa-secondary {\n opacity: 1;\n opacity: var(--fa-primary-opacity, 1);\n}\n\n.svg-inline--fa mask .fa-primary,\n.svg-inline--fa mask .fa-secondary {\n fill: black;\n}\n\n.fad.fa-inverse {\n color: #fff;\n}";function css$1(){var dfp=DEFAULT_FAMILY_PREFIX;var drc=DEFAULT_REPLACEMENT_CLASS;var fp=config.familyPrefix;var rc=config.replacementClass;var s=baseStyles;if(fp!==dfp||rc!==drc){var dPatt=new RegExp("\\.".concat(dfp,"\\-"),'g');var customPropPatt=new RegExp("\\--".concat(dfp,"\\-"),'g');var rPatt=new RegExp("\\.".concat(drc),'g');s=s.replace(dPatt,".".concat(fp,"-")).replace(customPropPatt,"--".concat(fp,"-")).replace(rPatt,".".concat(rc));}return s;}var Library=/*#__PURE__*/function(){function Library(){_classCallCheck$1(this,Library);this.definitions={};}_createClass$1(Library,[{key:"add",value:function add(){var _this=this;for(var _len=arguments.length,definitions=new Array(_len),_key=0;_key<_len;_key++){definitions[_key]=arguments[_key];}var additions=definitions.reduce(this._pullDefinitions,{});Object.keys(additions).forEach(function(key){_this.definitions[key]=_objectSpread({},_this.definitions[key]||{},additions[key]);defineIcons(key,additions[key]);build();});}},{key:"reset",value:function reset(){this.definitions={};}},{key:"_pullDefinitions",value:function _pullDefinitions(additions,definition){var normalized=definition.prefix&&definition.iconName&&definition.icon?{0:definition}:definition;Object.keys(normalized).map(function(key){var _normalized$key=normalized[key],prefix=_normalized$key.prefix,iconName=_normalized$key.iconName,icon=_normalized$key.icon;if(!additions[prefix])additions[prefix]={};additions[prefix][iconName]=icon;});return additions;}}]);return Library;}();function ensureCss(){if(config.autoAddCss&&!_cssInserted){insertCss(css$1());_cssInserted=true;}}function apiObject(val,abstractCreator){Object.defineProperty(val,'abstract',{get:abstractCreator});Object.defineProperty(val,'html',{get:function get(){return val.abstract.map(function(a){return toHtml(a);});}});Object.defineProperty(val,'node',{get:function get(){if(!IS_DOM)return;var container=DOCUMENT.createElement('div');container.innerHTML=val.html;return container.children;}});return val;}function findIconDefinition(iconLookup){var _iconLookup$prefix=iconLookup.prefix,prefix=_iconLookup$prefix===void 0?'fa':_iconLookup$prefix,iconName=iconLookup.iconName;if(!iconName)return;return iconFromMapping(library.definitions,prefix,iconName)||iconFromMapping(namespace.styles,prefix,iconName);}function resolveIcons(next){return function(maybeIconDefinition){var params=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var iconDefinition=(maybeIconDefinition||{}).icon?maybeIconDefinition:findIconDefinition(maybeIconDefinition||{});var mask=params.mask;if(mask){mask=(mask||{}).icon?mask:findIconDefinition(mask||{});}return next(iconDefinition,_objectSpread({},params,{mask:mask}));};}var library=new Library();var _cssInserted=false;var icon=resolveIcons(function(iconDefinition){var params=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var _params$transform=params.transform,transform=_params$transform===void 0?meaninglessTransform:_params$transform,_params$symbol=params.symbol,symbol=_params$symbol===void 0?false:_params$symbol,_params$mask=params.mask,mask=_params$mask===void 0?null:_params$mask,_params$title=params.title,title=_params$title===void 0?null:_params$title,_params$classes=params.classes,classes=_params$classes===void 0?[]:_params$classes,_params$attributes=params.attributes,attributes=_params$attributes===void 0?{}:_params$attributes,_params$styles=params.styles,styles=_params$styles===void 0?{}:_params$styles;if(!iconDefinition)return;var prefix=iconDefinition.prefix,iconName=iconDefinition.iconName,icon=iconDefinition.icon;return apiObject(_objectSpread({type:'icon'},iconDefinition),function(){ensureCss();if(config.autoA11y){if(title){attributes['aria-labelledby']="".concat(config.replacementClass,"-title-").concat(nextUniqueId());}else{attributes['aria-hidden']='true';attributes['focusable']='false';}}return makeInlineSvgAbstract({icons:{main:asFoundIcon(icon),mask:mask?asFoundIcon(mask.icon):{found:false,width:null,height:null,icon:{}}},prefix:prefix,iconName:iconName,transform:_objectSpread({},meaninglessTransform,transform),symbol:symbol,title:title,extra:{attributes:attributes,styles:styles,classes:classes}});});}); + + var faCat={prefix:'fas',iconName:'cat',icon:[512,512,[],"f6be","M290.59 192c-20.18 0-106.82 1.98-162.59 85.95V192c0-52.94-43.06-96-96-96-17.67 0-32 14.33-32 32s14.33 32 32 32c17.64 0 32 14.36 32 32v256c0 35.3 28.7 64 64 64h176c8.84 0 16-7.16 16-16v-16c0-17.67-14.33-32-32-32h-32l128-96v144c0 8.84 7.16 16 16 16h32c8.84 0 16-7.16 16-16V289.86c-10.29 2.67-20.89 4.54-32 4.54-61.81 0-113.52-44.05-125.41-102.4zM448 96h-64l-64-64v134.4c0 53.02 42.98 96 96 96s96-42.98 96-96V32l-64 64zm-72 80c-8.84 0-16-7.16-16-16s7.16-16 16-16 16 7.16 16 16-7.16 16-16 16zm80 0c-8.84 0-16-7.16-16-16s7.16-16 16-16 16 7.16 16 16-7.16 16-16 16z"]};var faCoffee={prefix:'fas',iconName:'coffee',icon:[640,512,[],"f0f4","M192 384h192c53 0 96-43 96-96h32c70.6 0 128-57.4 128-128S582.6 32 512 32H120c-13.3 0-24 10.7-24 24v232c0 53 43 96 96 96zM512 96c35.3 0 64 28.7 64 64s-28.7 64-64 64h-32V96h32zm47.7 384H48.3c-47.6 0-61-64-36-64h583.3c25 0 11.8 64-35.9 64z"]};var faFutbol={prefix:'fas',iconName:'futbol',icon:[512,512,[],"f1e3","M504 256c0 136.967-111.033 248-248 248S8 392.967 8 256 119.033 8 256 8s248 111.033 248 248zm-48 0l-.003-.282-26.064 22.741-62.679-58.5 16.454-84.355 34.303 3.072c-24.889-34.216-60.004-60.089-100.709-73.141l13.651 31.939L256 139l-74.953-41.525 13.651-31.939c-40.631 13.028-75.78 38.87-100.709 73.141l34.565-3.073 16.192 84.355-62.678 58.5-26.064-22.741-.003.282c0 43.015 13.497 83.952 38.472 117.991l7.704-33.897 85.138 10.447 36.301 77.826-29.902 17.786c40.202 13.122 84.29 13.148 124.572 0l-29.902-17.786 36.301-77.826 85.138-10.447 7.704 33.897C442.503 339.952 456 299.015 456 256zm-248.102 69.571l-29.894-91.312L256 177.732l77.996 56.527-29.622 91.312h-96.476z"]};var faHistory={prefix:'fas',iconName:'history',icon:[512,512,[],"f1da","M504 255.531c.253 136.64-111.18 248.372-247.82 248.468-59.015.042-113.223-20.53-155.822-54.911-11.077-8.94-11.905-25.541-1.839-35.607l11.267-11.267c8.609-8.609 22.353-9.551 31.891-1.984C173.062 425.135 212.781 440 256 440c101.705 0 184-82.311 184-184 0-101.705-82.311-184-184-184-48.814 0-93.149 18.969-126.068 49.932l50.754 50.754c10.08 10.08 2.941 27.314-11.313 27.314H24c-8.837 0-16-7.163-16-16V38.627c0-14.254 17.234-21.393 27.314-11.314l49.372 49.372C129.209 34.136 189.552 8 256 8c136.81 0 247.747 110.78 248 247.531zm-180.912 78.784l9.823-12.63c8.138-10.463 6.253-25.542-4.21-33.679L288 256.349V152c0-13.255-10.745-24-24-24h-16c-13.255 0-24 10.745-24 24v135.651l65.409 50.874c10.463 8.137 25.541 6.253 33.679-4.21z"]};var faMusic={prefix:'fas',iconName:'music',icon:[512,512,[],"f001","M511.99 32.01c0-21.71-21.1-37.01-41.6-30.51L150.4 96c-13.3 4.2-22.4 16.5-22.4 30.5v261.42c-10.05-2.38-20.72-3.92-32-3.92-53.02 0-96 28.65-96 64s42.98 64 96 64 96-28.65 96-64V214.31l256-75.02v184.63c-10.05-2.38-20.72-3.92-32-3.92-53.02 0-96 28.65-96 64s42.98 64 96 64 96-28.65 96-64l-.01-351.99z"]};var faSearch={prefix:'fas',iconName:'search',icon:[512,512,[],"f002","M505 442.7L405.3 343c-4.5-4.5-10.6-7-17-7H372c27.6-35.3 44-79.7 44-128C416 93.1 322.9 0 208 0S0 93.1 0 208s93.1 208 208 208c48.3 0 92.7-16.4 128-44v16.3c0 6.4 2.5 12.5 7 17l99.7 99.7c9.4 9.4 24.6 9.4 33.9 0l28.3-28.3c9.4-9.4 9.4-24.6.1-34zM208 336c-70.7 0-128-57.2-128-128 0-70.7 57.2-128 128-128 70.7 0 128 57.2 128 128 0 70.7-57.2 128-128 128z"]};var faTimes={prefix:'fas',iconName:'times',icon:[352,512,[],"f00d","M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z"]}; + + var faBuilding={prefix:'far',iconName:'building',icon:[448,512,[],"f1ad","M128 148v-40c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12h-40c-6.6 0-12-5.4-12-12zm140 12h40c6.6 0 12-5.4 12-12v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12zm-128 96h40c6.6 0 12-5.4 12-12v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12zm128 0h40c6.6 0 12-5.4 12-12v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12zm-76 84v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12zm76 12h40c6.6 0 12-5.4 12-12v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12zm180 124v36H0v-36c0-6.6 5.4-12 12-12h19.5V24c0-13.3 10.7-24 24-24h337c13.3 0 24 10.7 24 24v440H436c6.6 0 12 5.4 12 12zM79.5 463H192v-67c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v67h112.5V49L80 48l-.5 415z"]};var faFlag={prefix:'far',iconName:'flag',icon:[512,512,[],"f024","M336.174 80c-49.132 0-93.305-32-161.913-32-31.301 0-58.303 6.482-80.721 15.168a48.04 48.04 0 0 0 2.142-20.727C93.067 19.575 74.167 1.594 51.201.104 23.242-1.71 0 20.431 0 48c0 17.764 9.657 33.262 24 41.562V496c0 8.837 7.163 16 16 16h16c8.837 0 16-7.163 16-16v-83.443C109.869 395.28 143.259 384 199.826 384c49.132 0 93.305 32 161.913 32 58.479 0 101.972-22.617 128.548-39.981C503.846 367.161 512 352.051 512 335.855V95.937c0-34.459-35.264-57.768-66.904-44.117C409.193 67.309 371.641 80 336.174 80zM464 336c-21.783 15.412-60.824 32-102.261 32-59.945 0-102.002-32-161.913-32-43.361 0-96.379 9.403-127.826 24V128c21.784-15.412 60.824-32 102.261-32 59.945 0 102.002 32 161.913 32 43.271 0 96.32-17.366 127.826-32v240z"]};var faFrown={prefix:'far',iconName:'frown',icon:[496,512,[],"f119","M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160-64c-17.7 0-32 14.3-32 32s14.3 32 32 32 32-14.3 32-32-14.3-32-32-32zm-80 128c-40.2 0-78 17.7-103.8 48.6-8.5 10.2-7.1 25.3 3.1 33.8 10.2 8.4 25.3 7.1 33.8-3.1 16.6-19.9 41-31.4 66.9-31.4s50.3 11.4 66.9 31.4c8.1 9.7 23.1 11.9 33.8 3.1 10.2-8.5 11.5-23.6 3.1-33.8C326 321.7 288.2 304 248 304z"]};var faLightbulb={prefix:'far',iconName:'lightbulb',icon:[352,512,[],"f0eb","M176 80c-52.94 0-96 43.06-96 96 0 8.84 7.16 16 16 16s16-7.16 16-16c0-35.3 28.72-64 64-64 8.84 0 16-7.16 16-16s-7.16-16-16-16zM96.06 459.17c0 3.15.93 6.22 2.68 8.84l24.51 36.84c2.97 4.46 7.97 7.14 13.32 7.14h78.85c5.36 0 10.36-2.68 13.32-7.14l24.51-36.84c1.74-2.62 2.67-5.7 2.68-8.84l.05-43.18H96.02l.04 43.18zM176 0C73.72 0 0 82.97 0 176c0 44.37 16.45 84.85 43.56 115.78 16.64 18.99 42.74 58.8 52.42 92.16v.06h48v-.12c-.01-4.77-.72-9.51-2.15-14.07-5.59-17.81-22.82-64.77-62.17-109.67-20.54-23.43-31.52-53.15-31.61-84.14-.2-73.64 59.67-128 127.95-128 70.58 0 128 57.42 128 128 0 30.97-11.24 60.85-31.65 84.14-39.11 44.61-56.42 91.47-62.1 109.46a47.507 47.507 0 0 0-2.22 14.3v.1h48v-.05c9.68-33.37 35.78-73.18 52.42-92.16C335.55 260.85 352 220.37 352 176 352 78.8 273.2 0 176 0z"]};var faSmile={prefix:'far',iconName:'smile',icon:[496,512,[],"f118","M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160 0c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm4 72.6c-20.8 25-51.5 39.4-84 39.4s-63.2-14.3-84-39.4c-8.5-10.2-23.7-11.5-33.8-3.1-10.2 8.5-11.5 23.6-3.1 33.8 30 36 74.1 56.6 120.9 56.6s90.9-20.6 120.9-56.6c8.5-10.2 7.1-25.3-3.1-33.8-10.1-8.4-25.3-7.1-33.8 3.1z"]}; + + library.add(faBuilding,faCat,faCoffee,faFlag,faFrown,faFutbol,faHistory,faLightbulb,faMusic,faSearch,faSmile,faTimes);var building=icon({prefix:'far',iconName:'building'}).html;var cat=icon({prefix:'fas',iconName:'cat'}).html;var coffee=icon({prefix:'fas',iconName:'coffee'}).html;var flag=icon({prefix:'far',iconName:'flag'}).html;var futbol=icon({prefix:'fas',iconName:'futbol'}).html;var frown=icon({prefix:'far',iconName:'frown'}).html;var history=icon({prefix:'fas',iconName:'history'}).html;var lightbulb=icon({prefix:'far',iconName:'lightbulb'}).html;var music=icon({prefix:'fas',iconName:'music'}).html;var search=icon({prefix:'fas',iconName:'search'}).html;var smile=icon({prefix:'far',iconName:'smile'}).html;var times=icon({prefix:'fas',iconName:'times'}).html; + + var LOCAL_STORAGE_KEY='emojiPicker.recent';function load(){return JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY))||[];}function save(emoji,options){var recents=load();var recent={e:emoji.e,n:getEmojiName(emoji),k:emoji.k||getEmojiName(emoji)};localStorage.setItem(LOCAL_STORAGE_KEY,JSON.stringify([recent].concat(_toConsumableArray(recents.filter(function(r){return r.k!==recent.k;}))).slice(0,options.recentsCount)));} + + var CLASS_EMOJI='emoji-picker__emoji';var Emoji=/*#__PURE__*/function(){function Emoji(emoji,showVariants,showPreview,events,options){_classCallCheck(this,Emoji);this.emoji=emoji;this.showVariants=showVariants;this.showPreview=showPreview;this.events=events;this.options=options;}_createClass(Emoji,[{key:"render",value:function render(){var _this=this;var emojiButton=createElement('button',CLASS_EMOJI);emojiButton.innerHTML=this.emoji.e;emojiButton.addEventListener('click',function(){return _this.onEmojiClick();});emojiButton.addEventListener('mouseover',function(){return _this.onEmojiHover();});emojiButton.addEventListener('mouseout',function(){return _this.onEmojiLeave();});return emojiButton;}},{key:"onEmojiClick",value:function onEmojiClick(){// TODO move this side effect out of Emoji, make the recent module listen for event + if((!this.emoji.v||!this.showVariants||!this.options.showVariants)&&this.options.showRecents){save(this.emoji,this.options);}this.events.emit(EMOJI,{emoji:this.emoji,showVariants:this.showVariants});}},{key:"onEmojiHover",value:function onEmojiHover(){if(this.showPreview){this.events.emit(SHOW_PREVIEW,this.emoji);}}},{key:"onEmojiLeave",value:function onEmojiLeave(){if(this.showPreview){this.events.emit(HIDE_PREVIEW);}}}]);return Emoji;}(); + + var CLASS_EMOJI_CONTAINER='emoji-picker__emojis';var EmojiContainer=/*#__PURE__*/function(){function EmojiContainer(emojis,showVariants,events,options){_classCallCheck(this,EmojiContainer);this.emojis=emojis;this.showVariants=showVariants;this.events=events;this.options=options;}_createClass(EmojiContainer,[{key:"render",value:function render(){var _this=this;var emojiContainer=createElement('div',CLASS_EMOJI_CONTAINER);this.emojis.forEach(function(emoji){return emojiContainer.appendChild(new Emoji(emoji,_this.showVariants,true,_this.events,_this.options).render());});return emojiContainer;}}]);return EmojiContainer;}(); + + var CLASS_SEARCH_CONTAINER='emoji-picker__search-container';var CLASS_SEARCH_FIELD='emoji-picker__search';var CLASS_SEARCH_ICON='emoji-picker__search-icon';var CLASS_NOT_FOUND='emoji-picker__search-not-found';var CLASS_NOT_FOUND_ICON='emoji-picker__search-not-found-icon';var Search=/*#__PURE__*/function(){function Search(events,i18n,options,emojiData,autoFocusSearch){_classCallCheck(this,Search);this.events=events;this.i18n=i18n;this.options=options;this.emojiData=emojiData;this.autoFocusSearch=autoFocusSearch;}_createClass(Search,[{key:"render",value:function render(){var _this=this;this.searchContainer=createElement('div',CLASS_SEARCH_CONTAINER);this.searchField=createElement('input',CLASS_SEARCH_FIELD);this.searchField.placeholder=this.i18n.search;this.searchContainer.appendChild(this.searchField);this.searchIcon=createElement('span',CLASS_SEARCH_ICON);this.searchIcon.innerHTML=search;this.searchIcon.addEventListener('click',function(event){return _this.onClearSearch(event);});this.searchContainer.appendChild(this.searchIcon);if(this.autoFocusSearch){setTimeout(function(){return _this.searchField.focus();});}this.searchField.addEventListener('keydown',function(event){return _this.onKeyDown(event);});this.searchField.addEventListener('keyup',function(){return _this.onKeyUp();});return this.searchContainer;}},{key:"onClearSearch",value:function onClearSearch(event){event.stopPropagation();if(this.searchField.value){this.searchField.value='';this.events.emit(SHOW_TABS);this.searchIcon.innerHTML=search;this.searchIcon.style.cursor='default';}}},{key:"onKeyDown",value:function onKeyDown(event){if(event.key==='Escape'&&this.searchField.value!==''){event.stopPropagation();this.searchField.value='';this.events.emit(SHOW_TABS);}}},{key:"onKeyUp",value:function onKeyUp(){var _this2=this;if(!this.searchField.value){this.searchIcon.innerHTML=search;this.searchIcon.style.cursor='default';this.events.emit(SHOW_TABS);}else{this.searchIcon.innerHTML=times;this.searchIcon.style.cursor='pointer';this.events.emit(HIDE_TABS);var searchResults=this.emojiData.filter(function(emoji){return emoji.n.filter(function(name){return name.toLowerCase().indexOf(_this2.searchField.value.toLowerCase())>=0;}).length;});this.events.emit(HIDE_PREVIEW);if(searchResults.length){this.events.emit(SHOW_SEARCH_RESULTS,new EmojiContainer(searchResults,true,this.events,this.options).render());}else{this.events.emit(SHOW_SEARCH_RESULTS,new NotFoundMessage(this.i18n.notFound).render());}}}}]);return Search;}();var NotFoundMessage=/*#__PURE__*/function(){function NotFoundMessage(message){_classCallCheck(this,NotFoundMessage);this.message=message;}_createClass(NotFoundMessage,[{key:"render",value:function render(){var container=createElement('div',CLASS_NOT_FOUND);var iconContainer=createElement('div',CLASS_NOT_FOUND_ICON);iconContainer.innerHTML=frown;container.appendChild(iconContainer);var messageContainer=createElement('h2');messageContainer.innerHTML=this.message;container.appendChild(messageContainer);return container;}}]);return NotFoundMessage;}(); + + var i18n={search:'Search emojis...',categories:{recents:'Recent Emojis',smileys:'Smileys & People',animals:'Animals & Nature',food:'Food & Drink',activities:'Activities',travel:'Travel & Places',objects:'Objects',symbols:'Symbols',flags:'Flags'},notFound:'No emojis found'}; + + var CLASS_ACTIVE_TAB='active';var CLASS_TABS_CONTAINER='emoji-picker__tabs-container';var CLASS_TABS='emoji-picker__tabs';var CLASS_TAB='emoji-picker__tab';var CLASS_TAB_BODY='emoji-picker__tab-body';var emojiCategories={};emojiData.forEach(function(emoji){var categoryList=emojiCategories[categories[emoji.c]];if(!categoryList){categoryList=emojiCategories[categories[emoji.c]]=[];}categoryList.push(emoji);});var categoryIcons={smileys:smile,animals:cat,food:coffee,activities:futbol,travel:building,objects:lightbulb,symbols:music,flags:flag};var Tabs=/*#__PURE__*/function(){function Tabs(events,i18n,options){_classCallCheck(this,Tabs);this.events=events;this.i18n=i18n;this.options=options;this.setActiveTab=this.setActiveTab.bind(this);}_createClass(Tabs,[{key:"setActiveTab",value:function setActiveTab(index){var animate=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;if(index===this.activeTab){return;}var currentActiveTab=this.activeTab;if(currentActiveTab>=0){this.tabs[currentActiveTab].setActive(false);var currentActiveTabBody=this.tabBodies[currentActiveTab].container;var newActiveTabBody=this.tabBodies[index].container;newActiveTabBody.querySelector('.emoji-picker__emojis').scrollTop=0;if(animate){if(index>currentActiveTab){this.transitionTabs(newActiveTabBody,currentActiveTabBody,25,-25);}else{this.transitionTabs(newActiveTabBody,currentActiveTabBody,-25,25);}}}this.activeTab=index;this.tabBodies[this.activeTab].setActive(true);this.tabs[this.activeTab].setActive(true);}},{key:"transitionTabs",value:function transitionTabs(newActiveTabBody,currentActiveTabBody,newTranslate,currentTranslate){requestAnimationFrame(function(){newActiveTabBody.style.transition='none';newActiveTabBody.style.transform="translateX(".concat(newTranslate,"rem)");requestAnimationFrame(function(){currentActiveTabBody.style.transform="translateX(".concat(currentTranslate,"rem)");newActiveTabBody.style.transition='transform 0.25s';requestAnimationFrame(function(){newActiveTabBody.style.transform='translateX(0)';});});});}},{key:"render",value:function render(){var tabsContainer=createElement('div',CLASS_TABS_CONTAINER);tabsContainer.appendChild(this.createTabs());tabsContainer.appendChild(this.createTabBodies());this.setActiveTab(this.options.showRecents?1:0,false);return tabsContainer;}},{key:"createTabs",value:function createTabs(){var _this=this;this.tabsList=createElement('ul',CLASS_TABS);this.tabs=Object.keys(categoryIcons).map(function(category,index){return new Tab(categoryIcons[category],_this.options.showRecents?index+1:index,_this.setActiveTab);});if(this.options.showRecents){var recentTab=new Tab(history,0,this.setActiveTab);this.tabs.splice(0,0,recentTab);}this.tabs.forEach(function(tab){return _this.tabsList.appendChild(tab.render());});return this.tabsList;}},{key:"createTabBodies",value:function createTabBodies(){var _this2=this;this.tabBodyContainer=createElement('div');this.tabBodies=Object.keys(categoryIcons).map(function(category,index){return new TabBody(_this2.i18n.categories[category]||i18n.categories[category],new EmojiContainer(emojiCategories[category],true,_this2.events,_this2.options).render(),_this2.options.showRecents?index+1:index);});if(this.options.showRecents){var recentTabBody=new TabBody(this.i18n.categories.recents||i18n.categories.recents,new EmojiContainer(load(),false,this.events,this.options).render(),0);this.tabBodies.splice(0,0,recentTabBody);this.events.on(EMOJI,function(){var newRecents=new TabBody(_this2.i18n.categories.recents||i18n.categories.recents,new EmojiContainer(load(),false,_this2.events,_this2.options).render(),0);setTimeout(function(){_this2.tabBodyContainer.replaceChild(newRecents.render(),_this2.tabBodyContainer.firstChild);_this2.tabBodies[0]=newRecents;if(_this2.activeTab===0){_this2.setActiveTab(0);}});});}this.tabBodies.forEach(function(tabBody){return _this2.tabBodyContainer.appendChild(tabBody.render());});return this.tabBodyContainer;}}]);return Tabs;}();var Tab=/*#__PURE__*/function(){function Tab(icon,index,setActiveTab){_classCallCheck(this,Tab);this.icon=icon;this.index=index;this.setActiveTab=setActiveTab;}_createClass(Tab,[{key:"render",value:function render(){var _this3=this;this.tab=createElement('li',CLASS_TAB);this.tab.innerHTML=this.icon;this.tab.addEventListener('click',function(){return _this3.setActiveTab(_this3.index);});return this.tab;}},{key:"setActive",value:function setActive(active){if(active){this.tab.classList.add(CLASS_ACTIVE_TAB);}else{this.tab.classList.remove(CLASS_ACTIVE_TAB);}}}]);return Tab;}();var TabBody=/*#__PURE__*/function(){function TabBody(category,content,index){_classCallCheck(this,TabBody);this.category=category;this.content=content;this.index=index;}_createClass(TabBody,[{key:"render",value:function render(){this.container=createElement('div',CLASS_TAB_BODY);var title=createElement('h2');title.innerHTML=this.category;this.container.appendChild(title);this.container.appendChild(this.content);return this.container;}},{key:"setActive",value:function setActive(active){if(active){this.container.classList.add(CLASS_ACTIVE_TAB);}else{this.container.classList.remove(CLASS_ACTIVE_TAB);}}}]);return TabBody;}(); + + var CLASS_OVERLAY='emoji-picker__variant-overlay';var CLASS_POPUP='emoji-picker__variant-popup';var CLASS_CLOSE_BUTTON='emoji-picker__variant-popup-close-button';var VariantPopup=/*#__PURE__*/function(){function VariantPopup(events,emoji,options){_classCallCheck(this,VariantPopup);this.events=events;this.emoji=emoji;this.options=options;}_createClass(VariantPopup,[{key:"render",value:function render(){var _this=this;var popup=createElement('div',CLASS_POPUP);var overlay=createElement('div',CLASS_OVERLAY);overlay.addEventListener('click',function(event){event.stopPropagation();if(!popup.contains(event.target)){_this.events.emit(HIDE_VARIANT_POPUP);}});popup.appendChild(new Emoji(this.emoji,false,false,this.events,this.options).render());Object.keys(this.emoji.v).forEach(function(variant){popup.appendChild(new Emoji(_this.emoji.v[variant],false,false,_this.events,_this.options).render());});var closeButton=createElement('button',CLASS_CLOSE_BUTTON);closeButton.innerHTML=times;closeButton.addEventListener('click',function(event){event.stopPropagation();_this.events.emit(HIDE_VARIANT_POPUP);});popup.appendChild(closeButton);overlay.appendChild(popup);return overlay;}}]);return VariantPopup;}(); + + var CLASS_PICKER='emoji-picker';var CLASS_PICKER_CONTENT='emoji-picker__content';var DEFAULT_OPTIONS={position:'right-start',autoHide:true,autoFocusSearch:true,showPreview:true,showSearch:true,showRecents:true,showVariants:true,recentsCount:50};var EmojiButton=/*#__PURE__*/function(){function EmojiButton(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};_classCallCheck(this,EmojiButton);this.pickerVisible=false;this.options=_objectSpread2({},DEFAULT_OPTIONS,{},options);if(!this.options.rootElement){this.options.rootElement=document.body;}this.i18n=_objectSpread2({},i18n,{},options.i18n);this.onDocumentClick=this.onDocumentClick.bind(this);this.onDocumentKeydown=this.onDocumentKeydown.bind(this);this.events=new tinyEmitter();this.publicEvents=new tinyEmitter();}_createClass(EmojiButton,[{key:"on",value:function on(event,callback){this.publicEvents.on(event,callback);}},{key:"off",value:function off(event,callback){this.publicEvents.off(event,callback);}},{key:"buildPicker",value:function buildPicker(){var _this=this;this.pickerEl=createElement('div',CLASS_PICKER);if(this.options.zIndex){this.pickerEl.style.zIndex=this.options.zIndex;}var pickerContent=createElement('div',CLASS_PICKER_CONTENT);if(this.options.showSearch){var searchContainer=new Search(this.events,this.i18n,this.options,emojiData,this.options.autoFocusSearch).render();this.pickerEl.appendChild(searchContainer);}this.pickerEl.appendChild(pickerContent);var tabs=new Tabs(this.events,this.i18n,this.options).render();pickerContent.appendChild(tabs);this.events.on(HIDE_TABS,function(){if(pickerContent.contains(tabs)){pickerContent.removeChild(tabs);}});this.events.on(SHOW_TABS,function(){if(!pickerContent.contains(tabs)){empty(pickerContent);pickerContent.appendChild(tabs);}});this.events.on(SHOW_SEARCH_RESULTS,function(searchResults){empty(pickerContent);searchResults.classList.add('search-results');pickerContent.appendChild(searchResults);});if(this.options.showPreview){this.pickerEl.appendChild(new EmojiPreview(this.events).render());}var variantPopup;this.events.on(EMOJI,function(_ref){var emoji=_ref.emoji,showVariants=_ref.showVariants;if(emoji.v&&showVariants&&_this.options.showVariants){variantPopup=new VariantPopup(_this.events,emoji,_this.options).render();_this.pickerEl.appendChild(variantPopup);}else{if(variantPopup&&variantPopup.parentNode===_this.pickerEl){_this.pickerEl.removeChild(variantPopup);}_this.publicEvents.emit('emoji',emoji.e);if(_this.options.autoHide){_this.hidePicker();}}});this.events.on(HIDE_VARIANT_POPUP,function(){_this.pickerEl.removeChild(variantPopup);variantPopup=null;});this.options.rootElement.appendChild(this.pickerEl);setTimeout(function(){document.addEventListener('click',_this.onDocumentClick);document.addEventListener('keydown',_this.onDocumentKeydown);});}},{key:"onDocumentClick",value:function onDocumentClick(event){if(!this.pickerEl.contains(event.target)){this.hidePicker();}}},{key:"hidePicker",value:function hidePicker(){var _this2=this;// this.pickerEl.style.opacity = 0; + this.pickerEl.classList.remove('visible');this.pickerVisible=false;this.events.off(EMOJI);this.events.off(HIDE_VARIANT_POPUP);this.hideInProgress=true;setTimeout(function(){_this2.options.rootElement.removeChild(_this2.pickerEl);_this2.popper.destroy();_this2.pickerEl.style.transition='';_this2.hideInProgress=false;},500);document.removeEventListener('click',this.onDocumentClick);document.removeEventListener('keydown',this.onDocumentKeydown);}},{key:"showPicker",value:function showPicker(referenceEl){var _this3=this;var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};if(this.hideInProgress){return;}this.pickerVisible=true;this.buildPicker();this.popper=new Popper(referenceEl,this.pickerEl,{placement:options.position||this.options.position,modifiers:{computeStyle:{gpuAcceleration:false}}});requestAnimationFrame(function(){return _this3.pickerEl.classList.add('visible');});}},{key:"onDocumentKeydown",value:function onDocumentKeydown(event){if(event.key==='Escape'){this.hidePicker();}}}]);return EmojiButton;}(); + + return EmojiButton; + +})); diff --git a/src/favicon.ico b/src/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..786e749251af4770274e4d2d50bcce46ad98a962 GIT binary patch literal 15086 zcmd5@2Ut|swjLNFV!@WHMq@WGO|fIJ0A3TL-e@dQjEV(I%C(WaT(24dHPKY#jZsrj zM4DnR7`uX^MiiyR3Sz;A^g6Wv{cD(mGt3#lm*jnKf8S!CIcM*+{vRw{G2zUAuPeLVivYCQNV^lIL#Sx^>|< z_7qJ^Ls_XKbuIDdry8ePw{PEGNZNVi$dScMmo6RAqel(_5Tb?Q`?&6_uW5FH);19|L!{P^*O?Ck7oxw*N?Lh>x{`0ZDgS+ix!mVZv4K7Bxg z1`Rq04+Af0_y291SlzjEXBL1mrqaT~!ZgY|A0HpTJ~T9R*8A_jKk&Kdo_mS>TaZMb zW<7iM>>LmfF#X1j8(WF-W@%}uj`eGlq^#(bn3%XdI5>D_@7}!~41A@JNqanXI(P0| zfAUSQ3_xV%<>lQ;Nl7_!=FFLIR;^k!nKI|xzkffxxVSj4a`~tIT~bn#|M20%h^Dp%NUfg zA@fL$633Pu`)S})3;vTU(*_bMhDIf1KHoRYAmRtU>S-F9w9sB03KXgg5+>F z-1xOWqW8Pvi?iQgS@Z_{5Fd)2H;*GW?K-llQ+0`bH1EQN3oBZ-Y$PPHJj=-Y=v+2T^HDs)vK7D!-u{R^hn65H${MTjw3pHV4;YVq44jy0q5m$D-f*5~m zJ?@xITEuL!(Nip+PX;%^>?59-bbJXWANQ#scj`0gxHsniwi?G$qV)aCf*8=Ak9O|d z=}zDcNY%})+I#ozEwIE(d0&)!2e(g6Mr=TBVz;WmtYDYCD*TErqKC(crTF>sPNWrD z?zUN3S(g?rTqxT<8P8SqBW-wi_;8MaTm@_8T$gCBXy`B!Z z@Jk)`f6F?=^V{jo&tlH8k1;uXX~ozzwz)h{A@&L3Ut!?6Q|Jbexk%ch-u3I(SEyAi$jrpvPd>u>VMDOt?SJTL+sxN+c6B2&9pVFRaKX<8 zVc%%6#>*a~R*uEn{ekq=#T18?grcE+n8!Y%VDWonms}ej^|0#p;bfjLQWp z$+!<`M~)oXisSs08vbiX4#RKcunO#=!}{TGA$X!IBED=PxG~S!_f-O z8f#G7)(SSZHn3}44=s9igp1c0Ogyw0Q%;o6r6VE(;CS&i91Pe6zfkwM9PCL~Zv$dH z`S#myw<3PyKBVQIvOoLIqssV8bUGYb<^$ii2Akklbl5az5DqWyh^Sv|;pt`#`??yC zw<>9=%gdvBV_cXQhW-|Y?lGxm*p)VzlU$%W4y1nv1qJo1g#Q_?)gIjYn<<@f`xZhb zPo%wvn&H>?CAP!HQA6snC4S zBpA=1KR=Z`}8e^B|jl}QP>18vF z5+a-&geTWxwjx^0_Lp zs_9ba)$ZsNc^6&c%I6(p+spH-#J@bHPz@4@bzAM)wdMS;xBrVTzSxlCdY@Y1h*jTK ziT|g!hTx@Vo4{JD1^pNx-x}#++qwf@IeMM=^HkeG@Grijj-Ocfv}@N+_H%mt?c2Av zmv?ITPkz6u8vKJXY49NUZS)7{0PNeh55tEKhqbkJm3q|f_zGT)NJbZ~SCwtA*x%=_ zMf^Lt4p-QpdemW?1gqgcx53v4zhMp+`oRqq$>L-1`QfiCH}@v z!_o8CO!PRFhi*~1=z6Jq?(f2JE7Xa7XytwN{!grdg4tkyW|~^5si~_>Kp1}f9=4bB z<}hL%&Hcl8Y#KWif#cpo;P_e0XW`ri_2Yt{pC7EOtW&J{%9^p=Wp=x}Rm6MCV}3<03UkAl8+{tjwQ+-KE<7_g@R(P`%M zzX+orY_?z);7W>%iyN%A?=Q&AM%cfD)~vY+ejD4yXzDTr-B-m|iCyg9oA_5>G}{X3p%LTn zJO{K>a4R`|6?Q!PZc@Yl_(n3ey}yus$h-}L#?M8tyC)8KeTy^eHerMJVf1ymfOaqZ z2Q6EBqD8B@XxH&;bnbN=uPx6+-%!hT*Y_P_AG)Iuzgy@##JI6()24EUF-z=M!*fT8S7ad;DK%bSSZ6MfR=Nho{dI=r)YL?U6KJwtfgA)6w zHqkdeidZw%ILTPJe(W^I^P-Br6fnUPQ-&O`+V)DHk~WyZHXvr{J2KbEc-@m&f)WeZ zi6x7eMpp~mP+;!dxwRQz_=fmZIZ8X+i@mI$bHw)FjQ$F)t|{nUo$W=3{-i-{qwn(I z#I<+&Asx=$FI5**Zoo2PS^3E)pNJ2%#wju~vN`*a>Yh$%m;Cfh#O*kM1=Aw+*n9O& z=iEblimfZO<-#wa7^(THCQ?Mmm<^*Z`nehdH!67b>eUyyUYx98ruM+L zNV!*nt?UCI&(Fb#F`00ABZKp1I(ieQkUYyf`6gwyv204!HrGp{|2C5ThL?>XJ@q5~ zcAdy4Tn&2VcRFsjQtp-FLUb_>9@b&U?m|7uv%I^TMtT&!+vk-i*u7&;O8d{Qnk`XTEbwPfzc6>(;HdJmahGfB#Z| z|4*5h_ftB{^yx{Sfn;0o1eHwE=k!>+$ZzV=z>wQA&*X18rAsazHV@RF z%KbaPTS`{brcGgPt^E{99#Ns8g=g6xsAKKduLBiPe&nnc5rZLL*H5> zDMOO7HBMYpM?ZM*;2`~UUouuTmi!!e&q3~L$at|d3SGlI$ z7LsSaJH>D7!@|O5&X_Ty3vtT4TO%BoFJJD<`7cA-kaJ)zeU6v8M+rS~;>0JbSFaw) zb@Ow+i)Z{&SKiK+|B{c6WfOR3VLA8fT@5-^**3d(?{3bu)9j86=VgW$i?SuREK&Un z>y&c+xk#H$<{hWT#35~}n&`8v#d$P9os-I2-uaMwAVr0bkz16@IDHY%3F`Z8;!nSL z@!}HRg_8KBMGW-asru=Rr5EQvKt@ss?wp>9!~@Q_5Y`vV&wPo`qW!Sp${w6~7>7)q zd5D?qmY0y zw%?+kVt`sZczAd;=QxTq!JN<4B76elkk%yAm~d5b_(_caPCDj|wF%piQ*1h9c&99M zz<>dj_n}sDzkxQYIGf9PJUVy-4lMXDT-;!57FUlWp2(0U<#A}*-8B9zar4jd=GlW- zb3e~y(<3rCu7_3X2X#3A_!{f}AR(T9)p7K355ex)-4OLtJ$+0$mUlqn7)w62P7D7p z8erT{?r_^RpRrfoWnuhPV#njdzlCemZ;WAP!#N=r7xPSqFJ=8=+z)>E;fMBYo8J}r zqWj6!M)3{CB11j;;>>@VKw{WSXIP_i2P-tFX9e5(wb8g^b2!c#j0wLk!kAM(qfhiz z#x9=3ttDPzyz!%~1kP*ii9w%u4t~SjYqoc z<2=T(D`|tER8#qs>8{P4$0^vE&hKkFhxXi!ahMGQfQ|)~#CyJ3Biw3@zOM zjUHzU(Dgj~A7g!j!-4j%tUt%Vd__KOAu;+V?H?VDfN>MCY0PBiGwF}}knyljk(Kh~ z3QJmA8n|aMk^fBnCg{B6IQoPZ!D$k$1}k$E_sY100sckkYvs>r7wLFWE! z#Rj>L(y)8p5`!<3aUuHh#Xp;R?WR%$H*Y4QW5MY+Q}Kb*2Pi(w zclH+IeqM!okadQ86&FSR(W6IOa-ED*n3vH>e)i{J#?h466ysCl=iumyHF%J46?d;b zz^qw6qPATd)UtgZ4W4zz3p4!S6qs!qdouVTSNvw`cc-k_!-o$W`%JZ5|JNw;C4Y1! z5nJC|VB*h}I7g_*$N1E38~tr}(9JQH6a&Y8chP5YKKg7iihEJE6LlX#pH|ExP-*a`JF$^~MStNGxID2!A*^rC1ES z%F)YrGU)CVS;RH?NxO?)lo7Cg{d(1NDsgq^+?Xiklq7M!vp#+vi zEBQmkKRPxOy=eny#u=r}E63@`J4s|HI;-W}yH4RytQZS|qqtCq#N&}zqbb^hfO%RBK$K2A5aw^SEiObfWrma{~)iTeXvmY>UdsYc=} z9%ZJ=r++ykqnzaV$?R28O#eV0kI8FZL_~y~i)x$#0|T{eiy>^Y(`58y@-k&#)h|{p zIYS;p`9ByYW39#@Sdj7a=Ipbc95?4F%q)he0-!+3N*&Iz&7VeARb`3eZ?xlEoV&iH zUgFb=rfshZ$ur-D@!JyLbMb91xedC-o!HRYM5wU9j1kNZ?{5Cwx`zl)g- z5bk3o?gk;3WV#s))PT9I&y7)S=s=fw(N_=WsD`Sx}xN@l%LfqAjVy zPod&zcNY5e(@$HpYu8Tv2WE-?6Vr`;y1i_h z|Ik)rj~_oigm(L$bHcfTg2J1HBtA#+-D<9f{ajsLP54~7a-})eNkB^V|GxTZHs8L$_4E?0Oq*DH?Nyg31NIv#9&hK-= zXQx--ySNaX{m-0*?DxiA<6Tt-9*N)E4& z{~>hY{l7lE{}h+Ub-S!ISL$+)IGXkI@5jY*Up9*MhhwdW2UdRjEqe9prRO2{ciMlo z1zlsf_u~Dv^SPY1=);$~-0$`0w3(Kbau3_y`-u02W+KX8Zw`2SiziKk`Y$@6=ek7n z=AL2bkpd*ko~f)fjdlBRzut`Pey+5*gln=t0^DX{*K9BBUwaq>U-w6=7nY&BcO3U1 zI`n27T-M%V!k0R%E50NR+kZZFC`(JajXfWKrswhA;JxMd8k~8rVNR~TuG_vsTuImO zS<0l2)Rn|Id2{kRMjlALnur}s1M!bHlhLbR1{}HmIgiN1>|KS3eXOr5vX4uh^4jHp z*`5yUTl#Z$UQRL2aGeebE!2}dXB+m3EOVOsB-J<>d9)$#Z#nnfA{675wpiZr+e#^8 zEVuGA+th~pc!>edWce?I_&kH}UX^c^%ZrcmM{@L`Z`X$_*$J*FK33`^--MD`E|cZU IyfvEt0U2H=;{X5v literal 0 HcmV?d00001 diff --git a/src/gun.js b/src/gun.js new file mode 100644 index 00000000..868e042b --- /dev/null +++ b/src/gun.js @@ -0,0 +1,2281 @@ +;(function(){ + + /* UNBUILD */ + var root; + if(typeof window !== "undefined"){ root = window } + if(typeof global !== "undefined"){ root = global } + root = root || {}; + var console = root.console || {log: function(){}}; + function USE(arg, req){ + return req? require(arg) : arg.slice? USE[R(arg)] : function(mod, path){ + arg(mod = {exports: {}}); + USE[R(path)] = mod.exports; + } + function R(p){ + return p.split('/').slice(-1).toString().replace('.js',''); + } + } + if(typeof module !== "undefined"){ var common = module } + /* UNBUILD */ + + ;USE(function(module){ + // Generic javascript utilities. + var Type = {}; + //Type.fns = Type.fn = {is: function(fn){ return (!!fn && fn instanceof Function) }} + Type.fn = {is: function(fn){ return (!!fn && 'function' == typeof fn) }} + Type.bi = {is: function(b){ return (b instanceof Boolean || typeof b == 'boolean') }} + Type.num = {is: function(n){ return !list_is(n) && ((n - parseFloat(n) + 1) >= 0 || Infinity === n || -Infinity === n) }} + Type.text = {is: function(t){ return (typeof t == 'string') }} + Type.text.ify = function(t){ + if(Type.text.is(t)){ return t } + if(typeof JSON !== "undefined"){ return JSON.stringify(t) } + return (t && t.toString)? t.toString() : t; + } + Type.text.random = function(l, c){ + var s = ''; + l = l || 24; // you are not going to make a 0 length random number, so no need to check type + c = c || '0123456789ABCDEFGHIJKLMNOPQRSTUVWXZabcdefghijklmnopqrstuvwxyz'; + while(l > 0){ s += c.charAt(Math.floor(Math.random() * c.length)); l-- } + return s; + } + Type.text.match = function(t, o){ var tmp, u; + if('string' !== typeof t){ return false } + if('string' == typeof o){ o = {'=': o} } + o = o || {}; + tmp = (o['='] || o['*'] || o['>'] || o['<']); + if(t === tmp){ return true } + if(u !== o['=']){ return false } + tmp = (o['*'] || o['>'] || o['<']); + if(t.slice(0, (tmp||'').length) === tmp){ return true } + if(u !== o['*']){ return false } + if(u !== o['>'] && u !== o['<']){ + return (t >= o['>'] && t <= o['<'])? true : false; + } + if(u !== o['>'] && t >= o['>']){ return true } + if(u !== o['<'] && t <= o['<']){ return true } + return false; + } + Type.list = {is: function(l){ return (l instanceof Array) }} + Type.list.slit = Array.prototype.slice; + Type.list.sort = function(k){ // creates a new sort function based off some key + return function(A,B){ + if(!A || !B){ return 0 } A = A[k]; B = B[k]; + if(A < B){ return -1 }else if(A > B){ return 1 } + else { return 0 } + } + } + Type.list.map = function(l, c, _){ return obj_map(l, c, _) } + Type.list.index = 1; // change this to 0 if you want non-logical, non-mathematical, non-matrix, non-convenient array notation + Type.obj = {is: function(o){ return o? (o instanceof Object && o.constructor === Object) || Object.prototype.toString.call(o).match(/^\[object (\w+)\]$/)[1] === 'Object' : false }} + Type.obj.put = function(o, k, v){ return (o||{})[k] = v, o } + Type.obj.has = function(o, k){ return o && Object.prototype.hasOwnProperty.call(o, k) } + Type.obj.del = function(o, k){ + if(!o){ return } + o[k] = null; + delete o[k]; + return o; + } + Type.obj.as = function(o, k, v, u){ return o[k] = o[k] || (u === v? {} : v) } + Type.obj.ify = function(o){ + if(obj_is(o)){ return o } + try{o = JSON.parse(o); + }catch(e){o={}}; + return o; + } + ;(function(){ var u; + function map(v,k){ + if(obj_has(this,k) && u !== this[k]){ return } + this[k] = v; + } + Type.obj.to = function(from, to){ + to = to || {}; + obj_map(from, map, to); + return to; + } + }()); + Type.obj.copy = function(o){ // because http://web.archive.org/web/20140328224025/http://jsperf.com/cloning-an-object/2 + return !o? o : JSON.parse(JSON.stringify(o)); // is shockingly faster than anything else, and our data has to be a subset of JSON anyways! + } + ;(function(){ + function empty(v,i){ var n = this.n; + if(n && (i === n || (obj_is(n) && obj_has(n, i)))){ return } + if(i){ return true } + } + Type.obj.empty = function(o, n){ + if(!o){ return true } + return obj_map(o,empty,{n:n})? false : true; + } + }()); + ;(function(){ + function t(k,v){ + if(2 === arguments.length){ + t.r = t.r || {}; + t.r[k] = v; + return; + } t.r = t.r || []; + t.r.push(k); + }; + var keys = Object.keys, map; + Object.keys = Object.keys || function(o){ return map(o, function(v,k,t){t(k)}) } + Type.obj.map = map = function(l, c, _){ + var u, i = 0, x, r, ll, lle, f = fn_is(c); + t.r = null; + if(keys && obj_is(l)){ + ll = keys(l); lle = true; + } + if(list_is(l) || ll){ + x = (ll || l).length; + for(;i < x; i++){ + var ii = (i + Type.list.index); + if(f){ + r = lle? c.call(_ || this, l[ll[i]], ll[i], t) : c.call(_ || this, l[i], ii, t); + if(r !== u){ return r } + } else { + //if(Type.test.is(c,l[i])){ return ii } // should implement deep equality testing! + if(c === l[lle? ll[i] : i]){ return ll? ll[i] : ii } // use this for now + } + } + } else { + for(i in l){ + if(f){ + if(obj_has(l,i)){ + r = _? c.call(_, l[i], i, t) : c(l[i], i, t); + if(r !== u){ return r } + } + } else { + //if(a.test.is(c,l[i])){ return i } // should implement deep equality testing! + if(c === l[i]){ return i } // use this for now + } + } + } + return f? t.r : Type.list.index? 0 : -1; + } + }()); + Type.time = {}; + Type.time.is = function(t){ return t? t instanceof Date : (+new Date().getTime()) } + + var fn_is = Type.fn.is; + var list_is = Type.list.is; + var obj = Type.obj, obj_is = obj.is, obj_has = obj.has, obj_map = obj.map; + module.exports = Type; + })(USE, './type'); + + ;USE(function(module){ + // On event emitter generic javascript utility. + module.exports = function onto(tag, arg, as){ + if(!tag){ return {to: onto} } + var u, tag = (this.tag || (this.tag = {}))[tag] || + (this.tag[tag] = {tag: tag, to: onto._ = { + next: function(arg){ var tmp; + if((tmp = this.to)){ + tmp.next(arg); + }} + }}); + if(arg instanceof Function){ + var be = { + off: onto.off || + (onto.off = function(){ + if(this.next === onto._.next){ return !0 } + if(this === this.the.last){ + this.the.last = this.back; + } + this.to.back = this.back; + this.next = onto._.next; + this.back.to = this.to; + if(this.the.last === this.the){ + delete this.on.tag[this.the.tag]; + } + }), + to: onto._, + next: arg, + the: tag, + on: this, + as: as, + }; + (be.back = tag.last || tag).to = be; + return tag.last = be; + } + if((tag = tag.to) && u !== arg){ tag.next(arg) } + return tag; + }; + })(USE, './onto'); + + ;USE(function(module){ + /* Based on the Hypothetical Amnesia Machine thought experiment */ + function HAM(machineState, incomingState, currentState, incomingValue, currentValue){ + if(machineState < incomingState){ + return {defer: true}; // the incoming value is outside the boundary of the machine's state, it must be reprocessed in another state. + } + if(incomingState < currentState){ + return {historical: true}; // the incoming value is within the boundary of the machine's state, but not within the range. + + } + if(currentState < incomingState){ + return {converge: true, incoming: true}; // the incoming value is within both the boundary and the range of the machine's state. + + } + if(incomingState === currentState){ + incomingValue = Lexical(incomingValue) || ""; + currentValue = Lexical(currentValue) || ""; + if(incomingValue === currentValue){ // Note: while these are practically the same, the deltas could be technically different + return {state: true}; + } + /* + The following is a naive implementation, but will always work. + Never change it unless you have specific needs that absolutely require it. + If changed, your data will diverge unless you guarantee every peer's algorithm has also been changed to be the same. + As a result, it is highly discouraged to modify despite the fact that it is naive, + because convergence (data integrity) is generally more important. + Any difference in this algorithm must be given a new and different name. + */ + if(incomingValue < currentValue){ // Lexical only works on simple value types! + return {converge: true, current: true}; + } + if(currentValue < incomingValue){ // Lexical only works on simple value types! + return {converge: true, incoming: true}; + } + } + return {err: "Invalid CRDT Data: "+ incomingValue +" to "+ currentValue +" at "+ incomingState +" to "+ currentState +"!"}; + } + if(typeof JSON === 'undefined'){ + throw new Error( + 'JSON is not included in this browser. Please load it first: ' + + 'ajax.cdnjs.com/ajax/libs/json2/20110223/json2.js' + ); + } + var Lexical = JSON.stringify, undefined; + module.exports = HAM; + })(USE, './HAM'); + + ;USE(function(module){ + var Type = USE('./type'); + var Val = {}; + Val.is = function(v){ // Valid values are a subset of JSON: null, binary, number (!Infinity), text, or a soul relation. Arrays need special algorithms to handle concurrency, so they are not supported directly. Use an extension that supports them if needed but research their problems first. + if(v === u){ return false } + if(v === null){ return true } // "deletes", nulling out keys. + if(v === Infinity){ return false } // we want this to be, but JSON does not support it, sad face. + if(text_is(v) // by "text" we mean strings. + || bi_is(v) // by "binary" we mean boolean. + || num_is(v)){ // by "number" we mean integers or decimals. + return true; // simple values are valid. + } + return Val.link.is(v) || false; // is the value a soul relation? Then it is valid and return it. If not, everything else remaining is an invalid data type. Custom extensions can be built on top of these primitives to support other types. + } + Val.link = Val.rel = {_: '#'}; + ;(function(){ + Val.link.is = function(v){ // this defines whether an object is a soul relation or not, they look like this: {'#': 'UUID'} + if(v && v[rel_] && !v._ && obj_is(v)){ // must be an object. + var o = {}; + obj_map(v, map, o); + if(o.id){ // a valid id was found. + return o.id; // yay! Return it. + } + } + return false; // the value was not a valid soul relation. + } + function map(s, k){ var o = this; // map over the object... + if(o.id){ return o.id = false } // if ID is already defined AND we're still looping through the object, it is considered invalid. + if(k == rel_ && text_is(s)){ // the key should be '#' and have a text value. + o.id = s; // we found the soul! + } else { + return o.id = false; // if there exists anything else on the object that isn't the soul, then it is considered invalid. + } + } + }()); + Val.link.ify = function(t){ return obj_put({}, rel_, t) } // convert a soul into a relation and return it. + Type.obj.has._ = '.'; + var rel_ = Val.link._, u; + var bi_is = Type.bi.is; + var num_is = Type.num.is; + var text_is = Type.text.is; + var obj = Type.obj, obj_is = obj.is, obj_put = obj.put, obj_map = obj.map; + module.exports = Val; + })(USE, './val'); + + ;USE(function(module){ + var Type = USE('./type'); + var Val = USE('./val'); + var Node = {_: '_'}; + Node.soul = function(n, o){ return (n && n._ && n._[o || soul_]) } // convenience function to check to see if there is a soul on a node and return it. + Node.soul.ify = function(n, o){ // put a soul on an object. + o = (typeof o === 'string')? {soul: o} : o || {}; + n = n || {}; // make sure it exists. + n._ = n._ || {}; // make sure meta exists. + n._[soul_] = o.soul || n._[soul_] || text_random(); // put the soul on it. + return n; + } + Node.soul._ = Val.link._; + ;(function(){ + Node.is = function(n, cb, as){ var s; // checks to see if an object is a valid node. + if(!obj_is(n)){ return false } // must be an object. + if(s = Node.soul(n)){ // must have a soul on it. + return !obj_map(n, map, {as:as,cb:cb,s:s,n:n}); + } + return false; // nope! This was not a valid node. + } + function map(v, k){ // we invert this because the way we check for this is via a negation. + if(k === Node._){ return } // skip over the metadata. + if(!Val.is(v)){ return true } // it is true that this is an invalid node. + if(this.cb){ this.cb.call(this.as, v, k, this.n, this.s) } // optionally callback each key/value. + } + }()); + ;(function(){ + Node.ify = function(obj, o, as){ // returns a node from a shallow object. + if(!o){ o = {} } + else if(typeof o === 'string'){ o = {soul: o} } + else if(o instanceof Function){ o = {map: o} } + if(o.map){ o.node = o.map.call(as, obj, u, o.node || {}) } + if(o.node = Node.soul.ify(o.node || {}, o)){ + obj_map(obj, map, {o:o,as:as}); + } + return o.node; // This will only be a valid node if the object wasn't already deep! + } + function map(v, k){ var o = this.o, tmp, u; // iterate over each key/value. + if(o.map){ + tmp = o.map.call(this.as, v, ''+k, o.node); + if(u === tmp){ + obj_del(o.node, k); + } else + if(o.node){ o.node[k] = tmp } + return; + } + if(Val.is(v)){ + o.node[k] = v; + } + } + }()); + var obj = Type.obj, obj_is = obj.is, obj_del = obj.del, obj_map = obj.map; + var text = Type.text, text_random = text.random; + var soul_ = Node.soul._; + var u; + module.exports = Node; + })(USE, './node'); + + ;USE(function(module){ + var Type = USE('./type'); + var Node = USE('./node'); + function State(){ + var t; + /*if(perf){ + t = start + perf.now(); // Danger: Accuracy decays significantly over time, even if precise. + } else {*/ + t = time(); + //} + if(last < t){ + return N = 0, last = t + State.drift; + } + return last = t + ((N += 1) / D) + State.drift; + } + var time = Type.time.is, last = -Infinity, N = 0, D = 1000; // WARNING! In the future, on machines that are D times faster than 2016AD machines, you will want to increase D by another several orders of magnitude so the processing speed never out paces the decimal resolution (increasing an integer effects the state accuracy). + var perf = (typeof performance !== 'undefined')? (performance.timing && performance) : false, start = (perf && perf.timing && perf.timing.navigationStart) || (perf = false); + State._ = '>'; + State.drift = 0; + State.is = function(n, k, o){ // convenience function to get the state on a key on a node and return it. + var tmp = (k && n && n[N_] && n[N_][State._]) || o; + if(!tmp){ return } + return num_is(tmp = tmp[k])? tmp : -Infinity; + } + State.lex = function(){ return State().toString(36).replace('.','') } + State.ify = function(n, k, s, v, soul){ // put a key's state on a node. + if(!n || !n[N_]){ // reject if it is not node-like. + if(!soul){ // unless they passed a soul + return; + } + n = Node.soul.ify(n, soul); // then make it so! + } + var tmp = obj_as(n[N_], State._); // grab the states data. + if(u !== k && k !== N_){ + if(num_is(s)){ + tmp[k] = s; // add the valid state. + } + if(u !== v){ // Note: Not its job to check for valid values! + n[k] = v; + } + } + return n; + } + State.to = function(from, k, to){ + var val = (from||{})[k]; + if(obj_is(val)){ + val = obj_copy(val); + } + return State.ify(to, k, State.is(from, k), val, Node.soul(from)); + } + ;(function(){ + State.map = function(cb, s, as){ var u; // for use with Node.ify + var o = obj_is(o = cb || s)? o : null; + cb = fn_is(cb = cb || s)? cb : null; + if(o && !cb){ + s = num_is(s)? s : State(); + o[N_] = o[N_] || {}; + obj_map(o, map, {o:o,s:s}); + return o; + } + as = as || obj_is(s)? s : u; + s = num_is(s)? s : State(); + return function(v, k, o, opt){ + if(!cb){ + map.call({o: o, s: s}, v,k); + return v; + } + cb.call(as || this || {}, v, k, o, opt); + if(obj_has(o,k) && u === o[k]){ return } + map.call({o: o, s: s}, v,k); + } + } + function map(v,k){ + if(N_ === k){ return } + State.ify(this.o, k, this.s) ; + } + }()); + var obj = Type.obj, obj_as = obj.as, obj_has = obj.has, obj_is = obj.is, obj_map = obj.map, obj_copy = obj.copy; + var num = Type.num, num_is = num.is; + var fn = Type.fn, fn_is = fn.is; + var N_ = Node._, u; + module.exports = State; + })(USE, './state'); + + ;USE(function(module){ + var Type = USE('./type'); + var Val = USE('./val'); + var Node = USE('./node'); + var Graph = {}; + ;(function(){ + Graph.is = function(g, cb, fn, as){ // checks to see if an object is a valid graph. + if(!g || !obj_is(g) || obj_empty(g)){ return false } // must be an object. + return !obj_map(g, map, {cb:cb,fn:fn,as:as}); // makes sure it wasn't an empty object. + } + function map(n, s){ // we invert this because the way'? we check for this is via a negation. + if(!n || s !== Node.soul(n) || !Node.is(n, this.fn, this.as)){ return true } // it is true that this is an invalid graph. + if(!this.cb){ return } + nf.n = n; nf.as = this.as; // sequential race conditions aren't races. + this.cb.call(nf.as, n, s, nf); + } + function nf(fn){ // optional callback for each node. + if(fn){ Node.is(nf.n, fn, nf.as) } // where we then have an optional callback for each key/value. + } + }()); + ;(function(){ + Graph.ify = function(obj, env, as){ + var at = {path: [], obj: obj}; + if(!env){ + env = {}; + } else + if(typeof env === 'string'){ + env = {soul: env}; + } else + if(env instanceof Function){ + env.map = env; + } + if(env.soul){ + at.link = Val.link.ify(env.soul); + } + env.shell = (as||{}).shell; + env.graph = env.graph || {}; + env.seen = env.seen || []; + env.as = env.as || as; + node(env, at); + env.root = at.node; + return env.graph; + } + function node(env, at){ var tmp; + if(tmp = seen(env, at)){ return tmp } + at.env = env; + at.soul = soul; + if(Node.ify(at.obj, map, at)){ + at.link = at.link || Val.link.ify(Node.soul(at.node)); + if(at.obj !== env.shell){ + env.graph[Val.link.is(at.link)] = at.node; + } + } + return at; + } + function map(v,k,n){ + var at = this, env = at.env, is, tmp; + if(Node._ === k && obj_has(v,Val.link._)){ + return n._; // TODO: Bug? + } + if(!(is = valid(v,k,n, at,env))){ return } + if(!k){ + at.node = at.node || n || {}; + if(obj_has(v, Node._) && Node.soul(v)){ // ? for safety ? + at.node._ = obj_copy(v._); + } + at.node = Node.soul.ify(at.node, Val.link.is(at.link)); + at.link = at.link || Val.link.ify(Node.soul(at.node)); + } + if(tmp = env.map){ + tmp.call(env.as || {}, v,k,n, at); + if(obj_has(n,k)){ + v = n[k]; + if(u === v){ + obj_del(n, k); + return; + } + if(!(is = valid(v,k,n, at,env))){ return } + } + } + if(!k){ return at.node } + if(true === is){ + return v; + } + tmp = node(env, {obj: v, path: at.path.concat(k)}); + if(!tmp.node){ return } + return tmp.link; //{'#': Node.soul(tmp.node)}; + } + function soul(id){ var at = this; + var prev = Val.link.is(at.link), graph = at.env.graph; + at.link = at.link || Val.link.ify(id); + at.link[Val.link._] = id; + if(at.node && at.node[Node._]){ + at.node[Node._][Val.link._] = id; + } + if(obj_has(graph, prev)){ + graph[id] = graph[prev]; + obj_del(graph, prev); + } + } + function valid(v,k,n, at,env){ var tmp; + if(Val.is(v)){ return true } + if(obj_is(v)){ return 1 } + if(tmp = env.invalid){ + v = tmp.call(env.as || {}, v,k,n); + return valid(v,k,n, at,env); + } + env.err = "Invalid value at '" + at.path.concat(k).join('.') + "'!"; + if(Type.list.is(v)){ env.err += " Use `.set(item)` instead of an Array." } + } + function seen(env, at){ + var arr = env.seen, i = arr.length, has; + while(i--){ has = arr[i]; + if(at.obj === has.obj){ return has } + } + arr.push(at); + } + }()); + Graph.node = function(node){ + var soul = Node.soul(node); + if(!soul){ return } + return obj_put({}, soul, node); + } + ;(function(){ + Graph.to = function(graph, root, opt){ + if(!graph){ return } + var obj = {}; + opt = opt || {seen: {}}; + obj_map(graph[root], map, {obj:obj, graph: graph, opt: opt}); + return obj; + } + function map(v,k){ var tmp, obj; + if(Node._ === k){ + if(obj_empty(v, Val.link._)){ + return; + } + this.obj[k] = obj_copy(v); + return; + } + if(!(tmp = Val.link.is(v))){ + this.obj[k] = v; + return; + } + if(obj = this.opt.seen[tmp]){ + this.obj[k] = obj; + return; + } + this.obj[k] = this.opt.seen[tmp] = Graph.to(this.graph, tmp, this.opt); + } + }()); + var fn_is = Type.fn.is; + var obj = Type.obj, obj_is = obj.is, obj_del = obj.del, obj_has = obj.has, obj_empty = obj.empty, obj_put = obj.put, obj_map = obj.map, obj_copy = obj.copy; + var u; + module.exports = Graph; + })(USE, './graph'); + + ;USE(function(module){ + // request / response module, for asking and acking messages. + USE('./onto'); // depends upon onto! + module.exports = function ask(cb, as){ + if(!this.on){ return } + if(!(cb instanceof Function)){ + if(!cb || !as){ return } + var id = cb['#'] || cb, tmp = (this.tag||empty)[id]; + if(!tmp){ return } + tmp = this.on(id, as); + clearTimeout(tmp.err); + return true; + } + var id = (as && as['#']) || Math.random().toString(36).slice(2); + if(!cb){ return id } + var to = this.on(id, cb, as); + to.err = to.err || setTimeout(function(){ + to.next({err: "Error: No ACK received yet.", lack: true}); + to.off(); + }, (this.opt||{}).lack || 9000); + return id; + } + })(USE, './ask'); + + ;USE(function(module){ + var Type = USE('./type'); + function Dup(opt){ + var dup = {s:{}}; + opt = opt || {max: 1000, age: 1000 * 9};//1000 * 60 * 2}; + dup.check = function(id){ var tmp; + if(!(tmp = dup.s[id])){ return false } + if(tmp.pass){ return tmp.pass = false } + return dup.track(id); + } + dup.track = function(id, pass){ + var it = dup.s[id] || (dup.s[id] = {}); + it.was = time_is(); + if(pass){ it.pass = true } + if(!dup.to){ + dup.to = setTimeout(function(){ + var now = time_is(); + Type.obj.map(dup.s, function(it, id){ + if(it && opt.age > (now - it.was)){ return } + Type.obj.del(dup.s, id); + }); + dup.to = null; + }, opt.age + 9); + } + return it; + } + return dup; + } + var time_is = Type.time.is; + module.exports = Dup; + })(USE, './dup'); + + ;USE(function(module){ + + function Gun(o){ + if(o instanceof Gun){ return (this._ = {gun: this, $: this}).$ } + if(!(this instanceof Gun)){ return new Gun(o) } + return Gun.create(this._ = {gun: this, $: this, opt: o}); + } + + Gun.is = function($){ return ($ instanceof Gun) || ($ && $._ && ($ === $._.$)) || false } + + Gun.version = 0.9; + + Gun.chain = Gun.prototype; + Gun.chain.toJSON = function(){}; + + var Type = USE('./type'); + Type.obj.to(Type, Gun); + Gun.HAM = USE('./HAM'); + Gun.val = USE('./val'); + Gun.node = USE('./node'); + Gun.state = USE('./state'); + Gun.graph = USE('./graph'); + Gun.on = USE('./onto'); + Gun.ask = USE('./ask'); + Gun.dup = USE('./dup'); + + ;(function(){ + Gun.create = function(at){ + at.root = at.root || at; + at.graph = at.graph || {}; + at.on = at.on || Gun.on; + at.ask = at.ask || Gun.ask; + at.dup = at.dup || Gun.dup(); + var gun = at.$.opt(at.opt); + if(!at.once){ + at.on('in', root, at); + at.on('out', root, {at: at, out: root}); + Gun.on('create', at); + at.on('create', at); + } + at.once = 1; + return gun; + } + function root(msg){ + //add to.next(at); // TODO: MISSING FEATURE!!! + var ev = this, as = ev.as, at = as.at || as, gun = at.$, dup, tmp; + if(!(tmp = msg['#'])){ tmp = msg['#'] = text_rand(9) } + if((dup = at.dup).check(tmp)){ + if(as.out === msg.out){ + msg.out = u; + ev.to.next(msg); + } + return; + } + dup.track(tmp); + if(!at.ask(msg['@'], msg)){ + if(msg.get){ + Gun.on.get(msg, gun); //at.on('get', get(msg)); + } + if(msg.put){ + Gun.on.put(msg, gun); //at.on('put', put(msg)); + } + } + ev.to.next(msg); + if(!as.out){ + msg.out = root; + at.on('out', msg); + } + } + }()); + + ;(function(){ + Gun.on.put = function(msg, gun){ + var at = gun._, ctx = {$: gun, graph: at.graph, put: {}, map: {}, souls: {}, machine: Gun.state(), ack: msg['@'], cat: at, stop: {}}; + if(!Gun.graph.is(msg.put, null, verify, ctx)){ ctx.err = "Error: Invalid graph!" } + if(ctx.err){ return at.on('in', {'@': msg['#'], err: Gun.log(ctx.err) }) } + obj_map(ctx.put, merge, ctx); + if(!ctx.async){ obj_map(ctx.map, map, ctx) } + if(u !== ctx.defer){ + setTimeout(function(){ + Gun.on.put(msg, gun); + }, ctx.defer - ctx.machine); + } + if(!ctx.diff){ return } + at.on('put', obj_to(msg, {put: ctx.diff})); + }; + function verify(val, key, node, soul){ var ctx = this; + var state = Gun.state.is(node, key), tmp; + if(!state){ return ctx.err = "Error: No state on '"+key+"' in node '"+soul+"'!" } + var vertex = ctx.graph[soul] || empty, was = Gun.state.is(vertex, key, true), known = vertex[key]; + var HAM = Gun.HAM(ctx.machine, state, was, val, known); + if(!HAM.incoming){ + if(HAM.defer){ // pick the lowest + ctx.defer = (state < (ctx.defer || Infinity))? state : ctx.defer; + } + return; + } + ctx.put[soul] = Gun.state.to(node, key, ctx.put[soul]); + (ctx.diff || (ctx.diff = {}))[soul] = Gun.state.to(node, key, ctx.diff[soul]); + ctx.souls[soul] = true; + } + function merge(node, soul){ + var ctx = this, cat = ctx.$._, at = (cat.next || empty)[soul]; + if(!at){ + if(!(cat.opt||empty).super){ + ctx.souls[soul] = false; + return; + } + at = (ctx.$.get(soul)._); + } + var msg = ctx.map[soul] = { + put: node, + get: soul, + $: at.$ + }, as = {ctx: ctx, msg: msg}; + ctx.async = !!cat.tag.node; + if(ctx.ack){ msg['@'] = ctx.ack } + obj_map(node, each, as); + if(!ctx.async){ return } + if(!ctx.and){ + // If it is async, we only need to setup one listener per context (ctx) + cat.on('node', function(m){ + this.to.next(m); // make sure to call other context's listeners. + if(m !== ctx.map[m.get]){ return } // filter out events not from this context! + ctx.souls[m.get] = false; // set our many-async flag + obj_map(m.put, patch, m); // merge into view + if(obj_map(ctx.souls, function(v){ if(v){ return v } })){ return } // if flag still outstanding, keep waiting. + if(ctx.c){ return } ctx.c = 1; // failsafe for only being called once per context. + this.off(); + obj_map(ctx.map, map, ctx); // all done, trigger chains. + }); + } + ctx.and = true; + cat.on('node', msg); // each node on the current context's graph needs to be emitted though. + } + function each(val, key){ + var ctx = this.ctx, graph = ctx.graph, msg = this.msg, soul = msg.get, node = msg.put, at = (msg.$._), tmp; + graph[soul] = Gun.state.to(node, key, graph[soul]); + if(ctx.async){ return } + at.put = Gun.state.to(node, key, at.put); + } + function patch(val, key){ + var msg = this, node = msg.put, at = (msg.$._); + at.put = Gun.state.to(node, key, at.put); + } + function map(msg, soul){ + if(!msg.$){ return } + this.cat.stop = this.stop; // temporary fix till a better solution? + (msg.$._).on('in', msg); + this.cat.stop = null; // temporary fix till a better solution? + } + + Gun.on.get = function(msg, gun){ + var root = gun._, get = msg.get, soul = get[_soul], node = root.graph[soul], has = get[_has], tmp; + var next = root.next || (root.next = {}), at = next[soul]; + // queue concurrent GETs? + if(!node){ return root.on('get', msg) } + if(has){ + if('string' != typeof has || !obj_has(node, has)){ return root.on('get', msg) } + node = Gun.state.to(node, has); + // If we have a key in-memory, do we really need to fetch? + // Maybe... in case the in-memory key we have is a local write + // we still need to trigger a pull/merge from peers. + } else { + node = Gun.obj.copy(node); + } + node = Gun.graph.node(node); + tmp = (at||empty).ack; + root.on('in', { + '@': msg['#'], + how: 'mem', + put: node, + $: gun + }); + //if(0 < tmp){ return } + root.on('get', msg); + } + }()); + + ;(function(){ + Gun.chain.opt = function(opt){ + opt = opt || {}; + var gun = this, at = gun._, tmp = opt.peers || opt; + if(!obj_is(opt)){ opt = {} } + if(!obj_is(at.opt)){ at.opt = opt } + if(text_is(tmp)){ tmp = [tmp] } + if(list_is(tmp)){ + tmp = obj_map(tmp, function(url, i, map){ + i = {}; i.id = i.url = url; map(url, i); + }); + if(!obj_is(at.opt.peers)){ at.opt.peers = {}} + at.opt.peers = obj_to(tmp, at.opt.peers); + } + at.opt.peers = at.opt.peers || {}; + obj_map(opt, function each(v,k){ + if(!obj_has(this, k) || text.is(v) || obj.empty(v)){ this[k] = v ; return } + if(v && v.constructor !== Object && !list_is(v)){ return } + obj_map(v, each, this[k]); + }, at.opt); + Gun.on('opt', at); + at.opt.uuid = at.opt.uuid || function(){ return state_lex() + text_rand(12) } + return gun; + } + }()); + + var list_is = Gun.list.is; + var text = Gun.text, text_is = text.is, text_rand = text.random; + var obj = Gun.obj, obj_is = obj.is, obj_has = obj.has, obj_to = obj.to, obj_map = obj.map, obj_copy = obj.copy; + var state_lex = Gun.state.lex, _soul = Gun.val.link._, _has = '.', node_ = Gun.node._, rel_is = Gun.val.link.is; + var empty = {}, u; + + console.only = function(i, s){ return (console.only.i && i === console.only.i && console.only.i++) && (console.log.apply(console, arguments) || s) }; + + Gun.log = function(){ return (!Gun.log.off && console.log.apply(console, arguments)), [].slice.call(arguments).join(' ') } + Gun.log.once = function(w,s,o){ return (o = Gun.log.once)[w] = o[w] || 0, o[w]++ || Gun.log(s) } + + ;"Please do not remove these messages unless you are paying for a monthly sponsorship, thanks!"; + Gun.log.once("welcome", "Hello wonderful person! :) Thanks for using GUN, feel free to ask for help on https://gitter.im/amark/gun and ask StackOverflow questions tagged with 'gun'!"); + ;"Please do not remove these messages unless you are paying for a monthly sponsorship, thanks!"; + + if(typeof window !== "undefined"){ (window.GUN = window.Gun = Gun).window = window } + try{ if(typeof common !== "undefined"){ common.exports = Gun } }catch(e){} + module.exports = Gun; + + /*Gun.on('opt', function(ctx){ // FOR TESTING PURPOSES + this.to.next(ctx); + if(ctx.once){ return } + ctx.on('node', function(msg){ + var to = this.to; + //Gun.node.is(msg.put, function(v,k){ msg.put[k] = v + v }); + setTimeout(function(){ + to.next(msg); + },1); + }); + });*/ + })(USE, './root'); + + ;USE(function(module){ + var Gun = USE('./root'); + Gun.chain.back = function(n, opt){ var tmp; + n = n || 1; + if(-1 === n || Infinity === n){ + return this._.root.$; + } else + if(1 === n){ + return (this._.back || this._).$; + } + var gun = this, at = gun._; + if(typeof n === 'string'){ + n = n.split('.'); + } + if(n instanceof Array){ + var i = 0, l = n.length, tmp = at; + for(i; i < l; i++){ + tmp = (tmp||empty)[n[i]]; + } + if(u !== tmp){ + return opt? gun : tmp; + } else + if((tmp = at.back)){ + return tmp.$.back(n, opt); + } + return; + } + if(n instanceof Function){ + var yes, tmp = {back: at}; + while((tmp = tmp.back) + && u === (yes = n(tmp, opt))){} + return yes; + } + if(Gun.num.is(n)){ + return (at.back || at).$.back(n - 1); + } + return this; + } + var empty = {}, u; + })(USE, './back'); + + ;USE(function(module){ + // WARNING: GUN is very simple, but the JavaScript chaining API around GUN + // is complicated and was extremely hard to build. If you port GUN to another + // language, consider implementing an easier API to build. + var Gun = USE('./root'); + Gun.chain.chain = function(sub){ + var gun = this, at = gun._, chain = new (sub || gun).constructor(gun), cat = chain._, root; + cat.root = root = at.root; + cat.id = ++root.once; + cat.back = gun._; + cat.on = Gun.on; + cat.on('in', input, cat); // For 'in' if I add my own listeners to each then I MUST do it before in gets called. If I listen globally for all incoming data instead though, regardless of individual listeners, I can transform the data there and then as well. + cat.on('out', output, cat); // However for output, there isn't really the global option. I must listen by adding my own listener individually BEFORE this one is ever called. + return chain; + } + + function output(msg){ + var put, get, at = this.as, back = at.back, root = at.root, tmp; + if(!msg.$){ msg.$ = at.$ } + this.to.next(msg); + if(get = msg.get){ + /*if(u !== at.put){ + at.on('in', at); + return; + }*/ + if(at.lex){ msg.get = obj_to(at.lex, msg.get) } + if(get['#'] || at.soul){ + get['#'] = get['#'] || at.soul; + msg['#'] || (msg['#'] = text_rand(9)); + back = (root.$.get(get['#'])._); + if(!(get = get['.'])){ + tmp = back.ack; + if(!tmp){ back.ack = -1 } + if(obj_has(back, 'put')){ + back.on('in', back); + } + if(tmp && u !== back.put){ return } //if(tmp){ return } + msg.$ = back.$; + } else + if(obj_has(back.put, get)){ // TODO: support #LEX ! + put = (back.$.get(get)._); + if(!(tmp = put.ack)){ put.ack = -1 } + back.on('in', { + $: back.$, + put: Gun.state.to(back.put, get), + get: back.get + }); + if(tmp){ return } + } else + if('string' != typeof get){ + var put = {}, meta = (back.put||{})._; + Gun.obj.map(back.put, function(v,k){ + if(!Gun.text.match(k, get)){ return } + put[k] = v; + }) + if(!Gun.obj.empty(put)){ + put._ = meta; + back.on('in', {$: back.$, put: put, get: back.get}) + } + } + root.ask(ack, msg); + return root.on('in', msg); + } + if(root.now){ root.now[at.id] = root.now[at.id] || true; at.pass = {} } + if(get['.']){ + if(at.get){ + msg = {get: {'.': at.get}, $: at.$}; + //if(back.ask || (back.ask = {})[at.get]){ return } + (back.ask || (back.ask = {})); + back.ask[at.get] = msg.$._; // TODO: PERFORMANCE? More elegant way? + return back.on('out', msg); + } + msg = {get: {}, $: at.$}; + return back.on('out', msg); + } + at.ack = at.ack || -1; + if(at.get){ + msg.$ = at.$; + get['.'] = at.get; + (back.ask || (back.ask = {}))[at.get] = msg.$._; // TODO: PERFORMANCE? More elegant way? + return back.on('out', msg); + } + } + return back.on('out', msg); + } + + function input(msg){ + var eve = this, cat = eve.as, root = cat.root, gun = msg.$, at = (gun||empty)._ || empty, change = msg.put, rel, tmp; + if(cat.get && msg.get !== cat.get){ + msg = obj_to(msg, {get: cat.get}); + } + if(cat.has && at !== cat){ + msg = obj_to(msg, {$: cat.$}); + if(at.ack){ + cat.ack = at.ack; + //cat.ack = cat.ack || at.ack; + } + } + if(u === change){ + tmp = at.put; + eve.to.next(msg); + if(cat.soul){ return } // TODO: BUG, I believee the fresh input refactor caught an edge case that a `gun.get('soul').get('key')` that points to a soul that doesn't exist will not trigger val/get etc. + if(u === tmp && u !== at.put){ return } + echo(cat, msg, eve); + if(cat.has){ + not(cat, msg); + } + obj_del(at.echo, cat.id); + obj_del(cat.map, at.id); + return; + } + if(cat.soul){ + eve.to.next(msg); + echo(cat, msg, eve); + if(cat.next){ obj_map(change, map, {msg: msg, cat: cat}) } + return; + } + if(!(rel = Gun.val.link.is(change))){ + if(Gun.val.is(change)){ + if(cat.has || cat.soul){ + not(cat, msg); + } else + if(at.has || at.soul){ + (at.echo || (at.echo = {}))[cat.id] = at.echo[at.id] || cat; + (cat.map || (cat.map = {}))[at.id] = cat.map[at.id] || {at: at}; + //if(u === at.put){ return } // Not necessary but improves performance. If we have it but at does not, that means we got things out of order and at will get it. Once at gets it, it will tell us again. + } + eve.to.next(msg); + echo(cat, msg, eve); + return; + } + if(cat.has && at !== cat && obj_has(at, 'put')){ + cat.put = at.put; + }; + if((rel = Gun.node.soul(change)) && at.has){ + at.put = (cat.root.$.get(rel)._).put; + } + tmp = (root.stop || {})[at.id]; + //if(tmp && tmp[cat.id]){ } else { + eve.to.next(msg); + //} + relate(cat, msg, at, rel); + echo(cat, msg, eve); + if(cat.next){ obj_map(change, map, {msg: msg, cat: cat}) } + return; + } + var was = root.stop; + tmp = root.stop || {}; + tmp = tmp[at.id] || (tmp[at.id] = {}); + //if(tmp[cat.id]){ return } + tmp.is = tmp.is || at.put; + tmp[cat.id] = at.put || true; + //if(root.stop){ + eve.to.next(msg) + //} + relate(cat, msg, at, rel); + echo(cat, msg, eve); + } + + function relate(at, msg, from, rel){ + if(!rel || node_ === at.get){ return } + var tmp = (at.root.$.get(rel)._); + if(at.has){ + from = tmp; + } else + if(from.has){ + relate(from, msg, from, rel); + } + if(from === at){ return } + if(!from.$){ from = {} } + (from.echo || (from.echo = {}))[at.id] = from.echo[at.id] || at; + if(at.has && !(at.map||empty)[from.id]){ // if we haven't seen this before. + not(at, msg); + } + tmp = from.id? ((at.map || (at.map = {}))[from.id] = at.map[from.id] || {at: from}) : {}; + if(rel === tmp.link){ + if(!(tmp.pass || at.pass)){ + return; + } + } + if(at.pass){ + Gun.obj.map(at.map, function(tmp){ tmp.pass = true }) + obj_del(at, 'pass'); + } + if(tmp.pass){ obj_del(tmp, 'pass') } + if(at.has){ at.link = rel } + ask(at, tmp.link = rel); + } + function echo(at, msg, ev){ + if(!at.echo){ return } // || node_ === at.get ? + //if(at.has){ msg = obj_to(msg, {event: ev}) } + obj_map(at.echo, reverb, msg); + } + function reverb(to){ + if(!to || !to.on){ return } + to.on('in', this); + } + function map(data, key){ // Map over only the changes on every update. + var cat = this.cat, next = cat.next || empty, via = this.msg, chain, at, tmp; + if(node_ === key && !next[key]){ return } + if(!(at = next[key])){ + return; + } + //if(data && data[_soul] && (tmp = Gun.val.link.is(data)) && (tmp = (cat.root.$.get(tmp)._)) && obj_has(tmp, 'put')){ + // data = tmp.put; + //} + if(at.has){ + //if(!(data && data[_soul] && Gun.val.link.is(data) === Gun.node.soul(at.put))){ + if(u === at.put || !Gun.val.link.is(data)){ + at.put = data; + } + chain = at.$; + } else + if(tmp = via.$){ + tmp = (chain = via.$.get(key))._; + if(u === tmp.put || !Gun.val.link.is(data)){ + tmp.put = data; + } + } + at.on('in', { + put: data, + get: key, + $: chain, + via: via + }); + } + function not(at, msg){ + if(!(at.has || at.soul)){ return } + var tmp = at.map, root = at.root; + at.map = null; + if(at.has){ + if(at.dub && at.root.stop){ at.dub = null } + at.link = null; + } + //if(!root.now || !root.now[at.id]){ + if(!at.pass){ + if((!msg['@']) && null === tmp){ return } + //obj_del(at, 'pass'); + } + if(u === tmp && Gun.val.link.is(at.put)){ return } // This prevents the very first call of a thing from triggering a "clean up" call. // TODO: link.is(at.put) || !val.is(at.put) ? + obj_map(tmp, function(proxy){ + if(!(proxy = proxy.at)){ return } + obj_del(proxy.echo, at.id); + }); + tmp = at.put; + obj_map(at.next, function(neat, key){ + if(u === tmp && u !== at.put){ return true } + neat.put = u; + if(neat.ack){ + neat.ack = -1; // Shouldn't this be reset to 0? If we do that, SEA test `set user ref should be found` fails, odd. + } + neat.on('in', { + get: key, + $: neat.$, + put: u + }); + }); + } + function ask(at, soul){ + var tmp = (at.root.$.get(soul)._), lex = at.lex; + if(at.ack || lex){ + (lex = lex||{})['#'] = soul; + tmp.on('out', {get: lex}); + if(!at.ask){ return } // TODO: PERFORMANCE? More elegant way? + } + tmp = at.ask; Gun.obj.del(at, 'ask'); + obj_map(tmp || at.next, function(neat, key){ + var lex = neat.lex || {}; lex['#'] = soul; lex['.'] = lex['.'] || key; + neat.on('out', {get: lex}); + }); + Gun.obj.del(at, 'ask'); // TODO: PERFORMANCE? More elegant way? + } + function ack(msg, ev){ + var as = this.as, get = as.get || empty, at = as.$._, tmp = (msg.put||empty)[get['#']]; + if(at.ack){ at.ack = (at.ack + 1) || 1; } + if(!msg.put || ('string' == typeof get['.'] && !obj_has(tmp, at.get))){ + if(at.put !== u){ return } + at.on('in', { + get: at.get, + put: at.put = u, + $: at.$, + '@': msg['@'] + }); + return; + } + if(node_ == get['.']){ // is this a security concern? + at.on('in', {get: at.get, put: Gun.val.link.ify(get['#']), $: at.$, '@': msg['@']}); + return; + } + Gun.on.put(msg, at.root.$); + } + var empty = {}, u; + var obj = Gun.obj, obj_has = obj.has, obj_put = obj.put, obj_del = obj.del, obj_to = obj.to, obj_map = obj.map; + var text_rand = Gun.text.random; + var _soul = Gun.val.link._, node_ = Gun.node._; + })(USE, './chain'); + + ;USE(function(module){ + var Gun = USE('./root'); + Gun.chain.get = function(key, cb, as){ + var gun, tmp; + if(typeof key === 'string'){ + var back = this, cat = back._; + var next = cat.next || empty; + if(!(gun = next[key])){ + gun = cache(key, back); + } + gun = gun.$; + } else + if(key instanceof Function){ + if(true === cb){ return soul(this, key, cb, as), this } + gun = this; + var at = gun._, root = at.root, tmp = root.now, ev; + as = cb || {}; + as.at = at; + as.use = key; + as.out = as.out || {}; + as.out.get = as.out.get || {}; + (ev = at.on('in', use, as)).rid = rid; + (root.now = {$:1})[as.now = at.id] = ev; + var mum = root.mum; root.mum = {}; + at.on('out', as.out); + root.mum = mum; + root.now = tmp; + return gun; + } else + if(num_is(key)){ + return this.get(''+key, cb, as); + } else + if(tmp = rel.is(key)){ + return this.get(tmp, cb, as); + } else + if(obj.is(key)){ + gun = this; + if(tmp = ((tmp = key['#'])||empty)['='] || tmp){ gun = gun.get(tmp) } + gun._.lex = key; + return gun; + } else { + (as = this.chain())._.err = {err: Gun.log('Invalid get request!', key)}; // CLEAN UP + if(cb){ cb.call(as, as._.err) } + return as; + } + if(tmp = this._.stun){ // TODO: Refactor? + gun._.stun = gun._.stun || tmp; + } + if(cb && cb instanceof Function){ + gun.get(cb, as); + } + return gun; + } + function cache(key, back){ + var cat = back._, next = cat.next, gun = back.chain(), at = gun._; + if(!next){ next = cat.next = {} } + next[at.get = key] = at; + if(back === cat.root.$){ + at.soul = key; + } else + if(cat.soul || cat.has){ + at.has = key; + //if(obj_has(cat.put, key)){ + //at.put = cat.put[key]; + //} + } + return at; + } + function soul(gun, cb, opt, as){ + var cat = gun._, acks = 0, tmp; + if(tmp = cat.soul || cat.link || cat.dub){ return cb(tmp, as, cat) } + if(cat.jam){ return cat.jam.push([cb, as]) } + cat.jam = [[cb,as]]; + gun.get(function go(msg, eve){ + if(u === msg.put && (tmp = Object.keys(cat.root.opt.peers).length) && ++acks < tmp){ + return; + } + eve.rid(msg); + var at = ((at = msg.$) && at._) || {}, i = 0, as; + tmp = cat.jam; delete cat.jam; // tmp = cat.jam.splice(0, 100); + //if(tmp.length){ process.nextTick(function(){ go(msg, eve) }) } + while(as = tmp[i++]){ //Gun.obj.map(tmp, function(as, cb){ + var cb = as[0], id; as = as[1]; + cb && cb(id = at.link || at.soul || rel.is(msg.put) || node_soul(msg.put) || at.dub, as, msg, eve); + } //); + }, {out: {get: {'.':true}}}); + return gun; + } + function use(msg){ + var eve = this, as = eve.as, cat = as.at, root = cat.root, gun = msg.$, at = (gun||{})._ || {}, data = msg.put || at.put, tmp; + if((tmp = root.now) && eve !== tmp[as.now]){ return eve.to.next(msg) } + //if(at.async && msg.root){ return } + //if(at.async === 1 && cat.async !== true){ return } + //if(root.stop && root.stop[at.id]){ return } root.stop && (root.stop[at.id] = true); + //if(!at.async && !cat.async && at.put && msg.put === at.put){ return } + //else if(!cat.async && msg.put !== at.put && root.stop && root.stop[at.id]){ return } root.stop && (root.stop[at.id] = true); + + + //root.stop && (root.stop.id = root.stop.id || Gun.text.random(2)); + //if((tmp = root.stop) && (tmp = tmp[at.id] || (tmp[at.id] = {})) && tmp[cat.id]){ return } tmp && (tmp[cat.id] = true); + if(eve.seen && at.id && eve.seen[at.id]){ return eve.to.next(msg) } + //if((tmp = root.stop)){ if(tmp[at.id]){ return } tmp[at.id] = msg.root; } // temporary fix till a better solution? + if((tmp = data) && tmp[rel._] && (tmp = rel.is(tmp))){ + tmp = ((msg.$$ = at.root.gun.get(tmp))._); + if(u !== tmp.put){ + msg = obj_to(msg, {put: data = tmp.put}); + } + } + if((tmp = root.mum) && at.id){ // TODO: can we delete mum entirely now? + var id = at.id + (eve.id || (eve.id = Gun.text.random(9))); + if(tmp[id]){ return } + if(u !== data && !rel.is(data)){ tmp[id] = true; } + } + as.use(msg, eve); + if(eve.stun){ + eve.stun = null; + return; + } + eve.to.next(msg); + } + function rid(at){ + var cat = this.on; + if(!at || cat.soul || cat.has){ return this.off() } + if(!(at = (at = (at = at.$ || at)._ || at).id)){ return } + var map = cat.map, tmp, seen; + //if(!map || !(tmp = map[at]) || !(tmp = tmp.at)){ return } + if(tmp = (seen = this.seen || (this.seen = {}))[at]){ return true } + seen[at] = true; + return; + //tmp.echo[cat.id] = {}; // TODO: Warning: This unsubscribes ALL of this chain's listeners from this link, not just the one callback event. + //obj.del(map, at); // TODO: Warning: This unsubscribes ALL of this chain's listeners from this link, not just the one callback event. + return; + } + var obj = Gun.obj, obj_map = obj.map, obj_has = obj.has, obj_to = Gun.obj.to; + var num_is = Gun.num.is; + var rel = Gun.val.link, node_soul = Gun.node.soul, node_ = Gun.node._; + var empty = {}, u; + })(USE, './get'); + + ;USE(function(module){ + var Gun = USE('./root'); + Gun.chain.put = function(data, cb, as){ + // #soul.has=value>state + // ~who#where.where=what>when@was + // TODO: BUG! Put probably cannot handle plural chains! `!as` is quickfix test. + var gun = this, at = (gun._), root = at.root.$, ctx = root._, M = 100, tmp; + /*if(!ctx.puta && !as){ if(tmp = ctx.puts){ if(tmp > M){ // without this, when synchronous, writes to a 'not found' pile up, when 'not found' resolves it recursively calls `put` which incrementally resolves each write. Stack overflow limits can be as low as 10K, so this limit is hardcoded to 1% of 10K. + (ctx.stack || (ctx.stack = [])).push([gun, data, cb, as]); + if(ctx.puto){ return } + ctx.puto = setTimeout(function drain(){ + var d = ctx.stack.splice(0,M), i = 0, at; ctx.puta = true; + while(at = d[i++]){ at[0].put(at[1], at[2], at[3]) } delete ctx.puta; + if(ctx.stack.length){ return ctx.puto = setTimeout(drain, 0) } + ctx.stack = ctx.puts = ctx.puto = null; + }, 0); + return gun; + } ++ctx.puts } else { ctx.puts = 1 } }*/ + as = as || {}; + as.data = data; + as.via = as.$ = as.via || as.$ || gun; + if(typeof cb === 'string'){ + as.soul = cb; + } else { + as.ack = as.ack || cb; + } + if(at.soul){ + as.soul = at.soul; + } + if(as.soul || root === gun){ + if(!obj_is(as.data)){ + (as.ack||noop).call(as, as.out = {err: Gun.log("Data saved to the root level of the graph must be a node (an object), not a", (typeof as.data), 'of "' + as.data + '"!')}); + if(as.res){ as.res() } + return gun; + } + as.soul = as.soul || (as.not = Gun.node.soul(as.data) || (as.via.back('opt.uuid') || Gun.text.random)()); + if(!as.soul){ // polyfill async uuid for SEA + as.via.back('opt.uuid')(function(err, soul){ // TODO: improve perf without anonymous callback + if(err){ return Gun.log(err) } // TODO: Handle error! + (as.ref||as.$).put(as.data, as.soul = soul, as); + }); + return gun; + } + as.$ = root.get(as.soul); + as.ref = as.$; + ify(as); + return gun; + } + if(Gun.is(data)){ + data.get(function(soul, o, msg){ + if(!soul){ + return Gun.log("The reference you are saving is a", typeof msg.put, '"'+ msg.put +'", not a node (object)!'); + } + gun.put(Gun.val.link.ify(soul), cb, as); + }, true); + return gun; + } + if(at.has && (tmp = Gun.val.link.is(data))){ at.dub = tmp } + as.ref = as.ref || (root._ === (tmp = at.back))? gun : tmp.$; + if(as.ref._.soul && Gun.val.is(as.data) && at.get){ + as.data = obj_put({}, at.get, as.data); + as.ref.put(as.data, as.soul, as); + return gun; + } + as.ref.get(any, true, {as: as}); + if(!as.out){ + // TODO: Perf idea! Make a global lock, that blocks everything while it is on, but if it is on the lock it does the expensive lookup to see if it is a dependent write or not and if not then it proceeds full speed. Meh? For write heavy async apps that would be terrible. + as.res = as.res || stun; // Gun.on.stun(as.ref); // TODO: BUG! Deal with locking? + as.$._.stun = as.ref._.stun; + } + return gun; + }; + + function ify(as){ + as.batch = batch; + var opt = as.opt||{}, env = as.env = Gun.state.map(map, opt.state); + env.soul = as.soul; + as.graph = Gun.graph.ify(as.data, env, as); + if(env.err){ + (as.ack||noop).call(as, as.out = {err: Gun.log(env.err)}); + if(as.res){ as.res() } + return; + } + as.batch(); + } + + function stun(cb){ + if(cb){ cb() } + return; + var as = this; + if(!as.ref){ return } + if(cb){ + as.after = as.ref._.tag; + as.now = as.ref._.tag = {}; + cb(); + return; + } + if(as.after){ + as.ref._.tag = as.after; + } + } + + function batch(){ var as = this; + if(!as.graph || obj_map(as.stun, no)){ return } + as.res = as.res || function(cb){ if(cb){ cb() } }; + as.res(function(){ + var cat = (as.$.back(-1)._), ask = cat.ask(function(ack){ + cat.root.on('ack', ack); + if(ack.err){ Gun.log(ack) } + if(++acks > (as.acks || 0)){ this.off() } // Adjustable ACKs! Only 1 by default. + if(!as.ack){ return } + as.ack(ack, this); + //--C; + }, as.opt), acks = 0; + //C++; + // NOW is a hack to get synchronous replies to correctly call. + // and STOP is a hack to get async behavior to correctly call. + // neither of these are ideal, need to be fixed without hacks, + // but for now, this works for current tests. :/ + var tmp = cat.root.now; obj.del(cat.root, 'now'); + var mum = cat.root.mum; cat.root.mum = {}; + (as.ref._).on('out', { + $: as.ref, put: as.out = as.env.graph, opt: as.opt, '#': ask + }); + cat.root.mum = mum? obj.to(mum, cat.root.mum) : mum; + cat.root.now = tmp; + }, as); + if(as.res){ as.res() } + } function no(v,k){ if(v){ return true } } + + function map(v,k,n, at){ var as = this; + var is = Gun.is(v); + if(k || !at.path.length){ return } + (as.res||iife)(function(){ + var path = at.path, ref = as.ref, opt = as.opt; + var i = 0, l = path.length; + for(i; i < l; i++){ + ref = ref.get(path[i]); + } + if(is){ ref = v } + //if(as.not){ (ref._).dub = Gun.text.random() } // This might optimize stuff? Maybe not needed anymore. Make sure it doesn't introduce bugs. + var id = (ref._).dub; + if(id || (id = Gun.node.soul(at.obj))){ + ref.back(-1).get(id); + at.soul(id); + return; + } + (as.stun = as.stun || {})[path] = true; + ref.get(soul, true, {as: {at: at, as: as, p:path}}); + }, {as: as, at: at}); + //if(is){ return {} } + } + + function soul(id, as, msg, eve){ + var as = as.as, cat = as.at; as = as.as; + var at = ((msg || {}).$ || {})._ || {}; + id = at.dub = at.dub || id || Gun.node.soul(cat.obj) || Gun.node.soul(msg.put || at.put) || Gun.val.link.is(msg.put || at.put) || (as.via.back('opt.uuid') || Gun.text.random)(); // TODO: BUG!? Do we really want the soul of the object given to us? Could that be dangerous? + if(eve){ eve.stun = true } + if(!id){ // polyfill async uuid for SEA + as.via.back('opt.uuid')(function(err, id){ // TODO: improve perf without anonymous callback + if(err){ return Gun.log(err) } // TODO: Handle error. + solve(at, at.dub = at.dub || id, cat, as); + }); + return; + } + solve(at, at.dub = id, cat, as); + } + + function solve(at, id, cat, as){ + at.$.back(-1).get(id); + cat.soul(id); + as.stun[cat.path] = false; + as.batch(); + } + + function any(soul, as, msg, eve){ + as = as.as; + if(!msg.$ || !msg.$._){ return } // TODO: Handle + if(msg.err){ // TODO: Handle + Gun.log("Please report this as an issue! Put.any.err"); + return; + } + var at = (msg.$._), data = at.put, opt = as.opt||{}, root, tmp; + if((tmp = as.ref) && tmp._.now){ return } + if(eve){ eve.stun = true } + if(as.ref !== as.$){ + tmp = (as.$._).get || at.get; + if(!tmp){ // TODO: Handle + Gun.log("Please report this as an issue! Put.no.get"); // TODO: BUG!?? + return; + } + as.data = obj_put({}, tmp, as.data); + tmp = null; + } + if(u === data){ + if(!at.get){ return } // TODO: Handle + if(!soul){ + tmp = at.$.back(function(at){ + if(at.link || at.soul){ return at.link || at.soul } + as.data = obj_put({}, at.get, as.data); + }); + as.not = true; // maybe consider this? + } + tmp = tmp || at.soul || at.link || at.dub;// || at.get; + at = tmp? (at.root.$.get(tmp)._) : at; + as.soul = tmp; + data = as.data; + } + if(!as.not && !(as.soul = as.soul || soul)){ + if(as.path && obj_is(as.data)){ + as.soul = (opt.uuid || as.via.back('opt.uuid') || Gun.text.random)(); + } else { + //as.data = obj_put({}, as.$._.get, as.data); + if(node_ == at.get){ + as.soul = (at.put||empty)['#'] || at.dub; + } + as.soul = as.soul || at.soul || at.link || (opt.uuid || as.via.back('opt.uuid') || Gun.text.random)(); + } + if(!as.soul){ // polyfill async uuid for SEA + as.via.back('opt.uuid')(function(err, soul){ // TODO: improve perf without anonymous callback + if(err){ return Gun.log(err) } // Handle error. + as.ref.put(as.data, as.soul = soul, as); + }); + return; + } + } + as.ref.put(as.data, as.soul, as); + } + var obj = Gun.obj, obj_is = obj.is, obj_put = obj.put, obj_map = obj.map; + var u, empty = {}, noop = function(){}, iife = function(fn,as){fn.call(as||empty)}; + var node_ = Gun.node._; + })(USE, './put'); + + ;USE(function(module){ + var Gun = USE('./root'); + USE('./chain'); + USE('./back'); + USE('./put'); + USE('./get'); + module.exports = Gun; + })(USE, './index'); + + ;USE(function(module){ + var Gun = USE('./index'); + Gun.chain.on = function(tag, arg, eas, as){ + var gun = this, at = gun._, tmp, act, off; + if(typeof tag === 'string'){ + if(!arg){ return at.on(tag) } + act = at.on(tag, arg, eas || at, as); + if(eas && eas.$){ + (eas.subs || (eas.subs = [])).push(act); + } + return gun; + } + var opt = arg; + opt = (true === opt)? {change: true} : opt || {}; + opt.at = at; + opt.ok = tag; + //opt.last = {}; + gun.get(ok, opt); // TODO: PERF! Event listener leak!!!? + return gun; + } + + function ok(msg, ev){ var opt = this; + var gun = msg.$, at = (gun||{})._ || {}, data = at.put || msg.put, cat = opt.at, tmp; + if(u === data){ + return; + } + if(tmp = msg.$$){ + tmp = (msg.$$._); + if(u === tmp.put){ + return; + } + data = tmp.put; + } + if(opt.change){ // TODO: BUG? Move above the undef checks? + data = msg.put; + } + // DEDUPLICATE // TODO: NEEDS WORK! BAD PROTOTYPE + //if(tmp.put === data && tmp.get === id && !Gun.node.soul(data)){ return } + //tmp.put = data; + //tmp.get = id; + // DEDUPLICATE // TODO: NEEDS WORK! BAD PROTOTYPE + //at.last = data; + if(opt.as){ + opt.ok.call(opt.as, msg, ev); + } else { + opt.ok.call(gun, data, msg.get, msg, ev); + } + } + + Gun.chain.val = function(cb, opt){ + Gun.log.once("onceval", "Future Breaking API Change: .val -> .once, apologies unexpected."); + return this.once(cb, opt); + } + Gun.chain.once = function(cb, opt){ + var gun = this, at = gun._, data = at.put; + if(0 < at.ack && u !== data){ + (cb || noop).call(gun, data, at.get); + return gun; + } + if(cb){ + (opt = opt || {}).ok = cb; + opt.at = at; + opt.out = {'#': Gun.text.random(9)}; + gun.get(val, {as: opt}); + opt.async = true; //opt.async = at.stun? 1 : true; + } else { + Gun.log.once("valonce", "Chainable val is experimental, its behavior and API may change moving forward. Please play with it and report bugs and ideas on how to improve it."); + var chain = gun.chain(); + chain._.nix = gun.once(function(){ + chain._.on('in', gun._); + }); + return chain; + } + return gun; + } + + function val(msg, eve, to){ + if(!msg.$){ eve.off(); return } + var opt = this.as, cat = opt.at, gun = msg.$, at = gun._, data = at.put || msg.put, link, tmp; + if(tmp = msg.$$){ + link = tmp = (msg.$$._); + if(u !== link.put){ + data = link.put; + } + } + if((tmp = eve.wait) && (tmp = tmp[at.id])){ clearTimeout(tmp) } + eve.ack = (eve.ack||0)+1; + if(!to && u === data && eve.ack <= (opt.acks || Object.keys(at.root.opt.peers).length)){ return } + if((!to && (u === data || at.soul || at.link || (link && !(0 < link.ack)))) + || (u === data && (tmp = Object.keys(at.root.opt.peers).length) && (!to && (link||at).ack < tmp))){ + tmp = (eve.wait = {})[at.id] = setTimeout(function(){ + val.call({as:opt}, msg, eve, tmp || 1); + }, opt.wait || 99); + return; + } + if(link && u === link.put && (tmp = rel.is(data))){ data = Gun.node.ify({}, tmp) } + eve.rid? eve.rid(msg) : eve.off(); + opt.ok.call(gun || opt.$, data, msg.get); + } + + Gun.chain.off = function(){ + // make off more aggressive. Warning, it might backfire! + var gun = this, at = gun._, tmp; + var cat = at.back; + if(!cat){ return } + at.ack = 0; // so can resubscribe. + if(tmp = cat.next){ + if(tmp[at.get]){ + obj_del(tmp, at.get); + } else { + + } + } + if(tmp = cat.ask){ + obj_del(tmp, at.get); + } + if(tmp = cat.put){ + obj_del(tmp, at.get); + } + if(tmp = at.soul){ + obj_del(cat.root.graph, tmp); + } + if(tmp = at.map){ + obj_map(tmp, function(at){ + if(at.link){ + cat.root.$.get(at.link).off(); + } + }); + } + if(tmp = at.next){ + obj_map(tmp, function(neat){ + neat.$.off(); + }); + } + at.on('off', {}); + return gun; + } + var obj = Gun.obj, obj_map = obj.map, obj_has = obj.has, obj_del = obj.del, obj_to = obj.to; + var rel = Gun.val.link; + var empty = {}, noop = function(){}, u; + })(USE, './on'); + + ;USE(function(module){ + var Gun = USE('./index'); + Gun.chain.map = function(cb, opt, t){ + var gun = this, cat = gun._, chain; + if(!cb){ + if(chain = cat.each){ return chain } + cat.each = chain = gun.chain(); + chain._.nix = gun.back('nix'); + gun.on('in', map, chain._); + return chain; + } + Gun.log.once("mapfn", "Map functions are experimental, their behavior and API may change moving forward. Please play with it and report bugs and ideas on how to improve it."); + chain = gun.chain(); + gun.map().on(function(data, key, at, ev){ + var next = (cb||noop).call(this, data, key, at, ev); + if(u === next){ return } + if(data === next){ return chain._.on('in', at) } + if(Gun.is(next)){ return chain._.on('in', next._) } + chain._.on('in', {get: key, put: next}); + }); + return chain; + } + function map(msg){ + if(!msg.put || Gun.val.is(msg.put)){ return this.to.next(msg) } + if(this.as.nix){ this.off() } // TODO: Ugly hack! + obj_map(msg.put, each, {at: this.as, msg: msg}); + this.to.next(msg); + } + function each(v,k){ + if(n_ === k){ return } + var msg = this.msg, gun = msg.$, at = gun._, cat = this.at, tmp = at.lex; + if(tmp && !Gun.text.match(k, tmp['.'] || tmp['#'] || tmp)){ return } // review? + ((tmp = gun.get(k)._).echo || (tmp.echo = {}))[cat.id] = tmp.echo[cat.id] || cat; + } + var obj_map = Gun.obj.map, noop = function(){}, event = {stun: noop, off: noop}, n_ = Gun.node._, u; + })(USE, './map'); + + ;USE(function(module){ + var Gun = USE('./index'); + Gun.chain.set = function(item, cb, opt){ + var gun = this, soul; + cb = cb || function(){}; + opt = opt || {}; opt.item = opt.item || item; + if(soul = Gun.node.soul(item)){ item = Gun.obj.put({}, soul, Gun.val.link.ify(soul)) } + if(!Gun.is(item)){ + if(Gun.obj.is(item)){; + item = gun.back(-1).get(soul = soul || Gun.node.soul(item) || gun.back('opt.uuid')()).put(item); + } + return gun.get(soul || (Gun.state.lex() + Gun.text.random(7))).put(item, cb, opt); + } + item.get(function(soul, o, msg){ + if(!soul){ return cb.call(gun, {err: Gun.log('Only a node can be linked! Not "' + msg.put + '"!')}) } + gun.put(Gun.obj.put({}, soul, Gun.val.link.ify(soul)), cb, opt); + },true); + return item; + } + })(USE, './set'); + + ;USE(function(module){ + if(typeof Gun === 'undefined'){ return } // TODO: localStorage is Browser only. But it would be nice if it could somehow plugin into NodeJS compatible localStorage APIs? + + var root, noop = function(){}, store, u; + try{store = (Gun.window||noop).localStorage}catch(e){} + if(!store){ + Gun.log("Warning: No localStorage exists to persist data to!"); + store = {setItem: function(k,v){this[k]=v}, removeItem: function(k){delete this[k]}, getItem: function(k){return this[k]}}; + } + /* + NOTE: Both `lib/file.js` and `lib/memdisk.js` are based on this design! + If you update anything here, consider updating the other adapters as well. + */ + + Gun.on('create', function(root){ + // This code is used to queue offline writes for resync. + // See the next 'opt' code below for actual saving of data. + var ev = this.to, opt = root.opt; + if(root.once){ return ev.next(root) } + if(false === opt.localStorage){ return ev.next(root) } // we want offline resynce queue regardless! // actually, this doesn't help, per @go1dfish 's observation. Disabling for now, will need better solution later. + opt.prefix = opt.file || 'gun/'; + var gap = Gun.obj.ify(store.getItem('gap/'+opt.prefix)) || {}; + var empty = Gun.obj.empty, id, to, go; + // add re-sync command. + if(!empty(gap)){ + var disk = Gun.obj.ify(store.getItem(opt.prefix)) || {}, send = {}; + Gun.obj.map(gap, function(node, soul){ + Gun.obj.map(node, function(val, key){ + send[soul] = Gun.state.to(disk[soul], key, send[soul]); + }); + }); + setTimeout(function(){ + // TODO: Holy Grail dangling by this thread! If gap / offline resync doesn't trigger, it doesn't work. Ouch, and this is a localStorage specific adapter. :( + root.on('out', {put: send, '#': root.ask(ack)}); + },1); + } + + root.on('out', function(msg){ + if(msg.lS){ return } // TODO: for IndexedDB and others, shouldn't send to peers ACKs to our own GETs. + if(Gun.is(msg.$) && msg.put && !msg['@']){ + id = msg['#']; + Gun.graph.is(msg.put, null, map); + if(!to){ to = setTimeout(flush, opt.wait || 1) } + } + this.to.next(msg); + }); + root.on('ack', ack); + + function ack(ack){ // TODO: This is experimental, not sure if we should keep this type of event hook. + if(ack.err || !ack.ok){ return } + var id = ack['@']; + setTimeout(function(){ + Gun.obj.map(gap, function(node, soul){ + Gun.obj.map(node, function(val, key){ + if(id !== val){ return } + delete node[key]; + }); + if(empty(node)){ + delete gap[soul]; + } + }); + flush(); + }, opt.wait || 1); + }; + ev.next(root); + + var map = function(val, key, node, soul){ + (gap[soul] || (gap[soul] = {}))[key] = id; + } + var flush = function(){ + clearTimeout(to); + to = false; + try{store.setItem('gap/'+opt.prefix, JSON.stringify(gap)); + }catch(e){ Gun.log(err = e || "localStorage failure") } + } + }); + + Gun.on('create', function(root){ + this.to.next(root); + var opt = root.opt; + if(root.once){ return } + if(false === opt.localStorage){ return } + opt.prefix = opt.file || 'gun/'; + var graph = root.graph, acks = {}, count = 0, to; + var disk = Gun.obj.ify(store.getItem(opt.prefix)) || {}; + var lS = function(){}, u; + root.on('localStorage', disk); // NON-STANDARD EVENT! + + root.on('put', function(at){ + this.to.next(at); + Gun.graph.is(at.put, null, map); + if(!at['@']){ acks[at['#']] = true; } // only ack non-acks. + count += 1; + if(count >= (opt.batch || 1000)){ + return flush(); + } + if(to){ return } + to = setTimeout(flush, opt.wait || 1); + }); + + root.on('get', function(msg){ + this.to.next(msg); + var lex = msg.get, soul, data, u; + function to(){ + if(!lex || !(soul = lex['#'])){ return } + //if(0 >= msg.cap){ return } + var has = lex['.']; + data = disk[soul] || u; + if(data && has){ + data = Gun.state.to(data, has); + } + //if(!data && !Gun.obj.empty(opt.peers)){ return } // if data not found, don't ack if there are peers. // Hmm, what if we have peers but we are disconnected? + root.on('in', {'@': msg['#'], put: Gun.graph.node(data), how: 'lS', lS: msg.$});// || root.$}); + }; + Gun.debug? setTimeout(to,1) : to(); + }); + + var map = function(val, key, node, soul){ + disk[soul] = Gun.state.to(node, key, disk[soul]); + } + + var flush = function(data){ + var err; + count = 0; + clearTimeout(to); + to = false; + var ack = acks; + acks = {}; + if(data){ disk = data } + try{store.setItem(opt.prefix, JSON.stringify(disk)); + }catch(e){ + Gun.log(err = (e || "localStorage failure") + " Consider using GUN's IndexedDB plugin for RAD for more storage space, https://gun.eco/docs/RAD#install"); + root.on('localStorage:error', {err: err, file: opt.prefix, flush: disk, retry: flush}); + } + if(!err && !Gun.obj.empty(opt.peers)){ return } // only ack if there are no peers. + Gun.obj.map(ack, function(yes, id){ + root.on('in', { + '@': id, + err: err, + ok: 0 // localStorage isn't reliable, so make its `ok` code be a low number. + }); + }); + } + }); + })(USE, './adapters/localStorage'); + + ;USE(function(module){ + var Type = USE('../type'); + var puff = (typeof setImmediate !== "undefined")? setImmediate : setTimeout; + + function Mesh(root){ + var mesh = function(){}; + var opt = root.opt || {}; + opt.log = opt.log || console.log; + opt.gap = opt.gap || opt.wait || 1; + opt.pack = opt.pack || (opt.memory? (opt.memory * 1000 * 1000) : 1399000000) * 0.3; // max_old_space_size defaults to 1400 MB. + + var dup = root.dup; + + mesh.hear = function(raw, peer){ + if(!raw){ return } + var msg, id, hash, tmp = raw[0]; + if(opt.pack <= raw.length){ return mesh.say({dam: '!', err: "Message too big!"}, peer) } + if('{' != raw[2]){ mesh.hear.d += raw.length||0; ++mesh.hear.c; } // STATS! // ugh, stupid double JSON encoding + if('[' === tmp){ + try{msg = JSON.parse(raw);}catch(e){opt.log('DAM JSON parse error', e)} + if(!msg){ return } + LOG && opt.log(+new Date, msg.length, 'in hear batch'); + (function go(){ + var S; LOG && (S = +new Date); // STATS! + var m, c = 100; // hardcoded for now? + while(c-- && (m = msg.shift())){ + mesh.hear(m, peer); + } + LOG && opt.log(S, +new Date - S, 'batch heard'); + if(!msg.length){ return } + puff(go, 0); + }()); + return; + } + if('{' === tmp || (Type.obj.is(raw) && (msg = raw))){ + try{msg = msg || JSON.parse(raw); + }catch(e){return opt.log('DAM JSON parse error', e)} + if(!msg){ return } + if(!(id = msg['#'])){ id = msg['#'] = Type.text.random(9) } + if(msg.DBG_s){ opt.log(+new Date - msg.DBG_s, 'to hear', id) } + if(dup.check(id)){ return } + dup.track(id, true).it = msg; // GUN core also dedups, so `true` is needed. // Does GUN core need to dedup anymore? + if(!(hash = msg['##']) && u !== msg.put){ hash = msg['##'] = Type.obj.hash(msg.put) } + if(hash && (tmp = msg['@'] || (msg.get && id))){ // Reduces backward daisy in case varying hashes at different daisy depths are the same. + if(dup.check(tmp+hash)){ return } + dup.track(tmp+hash, true).it = msg; // GUN core also dedups, so `true` is needed. // Does GUN core need to dedup anymore? + } + (msg._ = function(){}).via = peer; + if(tmp = msg['><']){ (msg._).to = Type.obj.map(tmp.split(','), tomap) } + if(msg.dam){ + if(tmp = mesh.hear[msg.dam]){ + tmp(msg, peer, root); + } + return; + } + var S; LOG && (S = +new Date); + root.on('in', msg); + LOG && !msg.nts && opt.log(S, +new Date - S, 'msg', msg['#']); + return; + } + } + var tomap = function(k,i,m){m(k,true)}; + mesh.hear.c = mesh.hear.d = 0; + + ;(function(){ + var message; + function each(peer){ mesh.say(message, peer) } + mesh.say = function(msg, peer){ + if(this.to){ this.to.next(msg) } // compatible with middleware adapters. + if(!msg){ return false } + var id, hash, tmp, raw; + var S; LOG && (S = +new Date); //msg.DBG_s = msg.DBG_s || +new Date; + var meta = msg._||(msg._=function(){}); + if(!(id = msg['#'])){ id = msg['#'] = Type.text.random(9) } + if(!(hash = msg['##']) && u !== msg.put){ hash = msg['##'] = Type.obj.hash(msg.put) } + if(!(raw = meta.raw)){ + raw = meta.raw = mesh.raw(msg); + if(hash && (tmp = msg['@'])){ + dup.track(tmp+hash).it = msg; + if(tmp = (dup.s[tmp]||ok).it){ + if(hash === tmp['##']){ return false } + tmp['##'] = hash; + } + } + } + LOG && opt.log(S, +new Date - S, 'say prep'); + dup.track(id).it = msg; // track for 9 seconds, default. Earth<->Mars would need more! + if(!peer){ peer = (tmp = dup.s[msg['@']]) && (tmp = tmp.it) && (tmp = tmp._) && (tmp = tmp.via) } + if(!peer && mesh.way){ return mesh.way(msg) } + if(!peer || !peer.id){ message = msg; + if(!Type.obj.is(peer || opt.peers)){ return false } + var S; LOG && (S = +new Date); + Type.obj.map(peer || opt.peers, each); // in case peer is a peer list. + LOG && opt.log(S, +new Date - S, 'say loop'); + return; + } + if(!peer.wire && mesh.wire){ mesh.wire(peer) } + if(id === peer.last){ return } peer.last = id; // was it just sent? + if(peer === meta.via){ return false } + if((tmp = meta.to) && (tmp[peer.url] || tmp[peer.pid] || tmp[peer.id]) /*&& !o*/){ return false } + if(peer.batch){ + peer.tail = (tmp = peer.tail || 0) + raw.length; + if(peer.tail <= opt.pack){ + peer.batch.push(raw); // peer.batch += (tmp?'':',')+raw; // TODO: Prevent double JSON! // FOR v1.0 !? + return; + } + flush(peer); + } + peer.batch = []; // peer.batch = '['; // TODO: Prevent double JSON! + setTimeout(function(){flush(peer)}, opt.gap); + send(raw, peer); + } + function flush(peer){ + var tmp = peer.batch; // var tmp = peer.batch + ']'; // TODO: Prevent double JSON! + peer.batch = peer.tail = null; + if(!tmp){ return } + if(!tmp.length){ return } // if(3 > tmp.length){ return } // TODO: ^ + var S; LOG && (S = +new Date); + try{tmp = (1 === tmp.length? tmp[0] : JSON.stringify(tmp)); + }catch(e){return opt.log('DAM JSON stringify error', e)} + LOG && opt.log(S, +new Date - S, 'say stringify', tmp.length); + if(!tmp){ return } + send(tmp, peer); + } + mesh.say.c = mesh.say.d = 0; + }()); + + // for now - find better place later. + function send(raw, peer){ try{ + var wire = peer.wire; + var S; LOG && (S = +new Date); + if(peer.say){ + peer.say(raw); + } else + if(wire.send){ + wire.send(raw); + } + LOG && opt.log(S, +new Date - S, 'wire send', raw.length); + mesh.say.d += raw.length||0; ++mesh.say.c; // STATS! + }catch(e){ + (peer.queue = peer.queue || []).push(raw); + }} + + ;(function(){ + mesh.raw = function(msg){ // TODO: Clean this up / delete it / move logic out! + if(!msg){ return '' } + var meta = (msg._) || {}, put, hash, tmp; + if(tmp = meta.raw){ return tmp } + if(typeof msg === 'string'){ return msg } + if(!msg.dam){ + var i = 0, to = []; Type.obj.map(opt.peers, function(p){ + to.push(p.url || p.pid || p.id); if(++i > 9){ return true } // limit server, fast fix, improve later! // For "tower" peer, MUST include 6 surrounding ids. + }); if(i > 1){ msg['><'] = to.join() } + } + var raw = $(msg); // optimize by reusing put = the JSON.stringify from .hash? + /*if(u !== put){ + tmp = raw.indexOf(_, raw.indexOf('put')); + raw = raw.slice(0, tmp-1) + put + raw.slice(tmp + _.length + 1); + //raw = raw.replace('"'+ _ +'"', put); // NEVER USE THIS! ALSO NEVER DELETE IT TO NOT MAKE SAME MISTAKE! https://github.com/amark/gun/wiki/@$$ Heisenbug + }*/ + if(meta){ meta.raw = raw } + return raw; + } + var $ = JSON.stringify, _ = ':])([:'; + + }()); + + mesh.hi = function(peer){ + var tmp = peer.wire || {}; + if(peer.id){ + opt.peers[peer.url || peer.id] = peer; + } else { + tmp = peer.id = peer.id || Type.text.random(9); + mesh.say({dam: '?', pid: root.opt.pid}, opt.peers[tmp] = peer); + delete dup.s[peer.last]; // IMPORTANT: see https://gun.eco/docs/DAM#self + } + peer.met = peer.met || +(new Date); + if(!tmp.hied){ root.on(tmp.hied = 'hi', peer) } + // @rogowski I need this here by default for now to fix go1dfish's bug + tmp = peer.queue; peer.queue = []; + Type.obj.map(tmp, function(msg){ + send(msg, peer); + }); + } + mesh.bye = function(peer){ + root.on('bye', peer); + var tmp = +(new Date); tmp = (tmp - (peer.met||tmp)); + mesh.bye.time = ((mesh.bye.time || tmp) + tmp) / 2; + LOG = console.LOG; // dirty place to cheaply update LOG settings over time. + } + mesh.hear['!'] = function(msg, peer){ opt.log('Error:', msg.err) } + mesh.hear['?'] = function(msg, peer){ + if(msg.pid){ + if(!peer.pid){ peer.pid = msg.pid } + if(msg['@']){ return } + } + mesh.say({dam: '?', pid: opt.pid, '@': msg['#']}, peer); + delete dup.s[peer.last]; // IMPORTANT: see https://gun.eco/docs/DAM#self + } + + root.on('create', function(root){ + root.opt.pid = root.opt.pid || Type.text.random(9); + this.to.next(root); + root.on('out', mesh.say); + }); + + root.on('bye', function(peer, tmp){ + peer = opt.peers[peer.id || peer] || peer; + this.to.next(peer); + peer.bye? peer.bye() : (tmp = peer.wire) && tmp.close && tmp.close(); + Type.obj.del(opt.peers, peer.id); + peer.wire = null; + }); + + var gets = {}; + root.on('bye', function(peer, tmp){ this.to.next(peer); + if(!(tmp = peer.url)){ return } gets[tmp] = true; + setTimeout(function(){ delete gets[tmp] },opt.lack || 9000); + }); + root.on('hi', function(peer, tmp){ this.to.next(peer); + if(!(tmp = peer.url) || !gets[tmp]){ return } delete gets[tmp]; + Type.obj.map(root.next, function(node, soul){ + tmp = {}; tmp[soul] = root.graph[soul]; + mesh.say({'##': Type.obj.hash(tmp), get: {'#': soul}}, peer); + }) + }); + + return mesh; + } + + ;(function(){ + Type.text.hash = function(s){ // via SO + if(typeof s !== 'string'){ return {err: 1} } + var c = 0; + if(!s.length){ return c } + for(var i=0,l=s.length,n; iK` zJKafFMJdWlAj09ofq;M@N=b?;|H}jalVG6!orn01CjVuiF3J+ZAhk32=l?3Oj*?m~ zARr8+|4E>pB?9jM09sb6ny#91vfL&Pb__$eZp4|V6c4n?d#GZDx z_AcC>d_VsS!TqoNA2Q%4@qa;FZTNm_$|(|yI5?XTvoWwTF#hC+BPJ&1bv8BURu&ci zANGGWzMqz^u8!OQfQN?%g9i(PgR=#IiHnO1z{m_>W~Tp#pm*`IcQx{)w|61^Zz2Dm z98ohD6K5+&S1Sj5;{V7sGInrt<@@>bKZ^eM`0sYQTABafFe|Iq$N4=><9%Kxv%{I{k5Mg3Xn!|m%^q%>}^!W?S!4>YvxdTQcg?1EU_30>Cfug;O*4O>s z2)87zd;a`ycvXG|CbME}%^dj&a5dmdBX%NfXfE<^Xz>0Xhz#Ro*h6QT6PKu$p1OD} z_eq9{F$M<4FAW1fHkX@@(^BLh%d29dFUygI5*c(vM8x|Bld;bC+s!sWTfjH)vFBwc z`@JmSy-feF1ysoW<}Q$(-|ziV)4{>vW(3P%O4n%wBczl7Vf2z37>N#|UFaBJtJ}f6 zvb>zibN)M7Sqwt1`}6N)Tr!1RR+c1LsYLO-RfDFjGZ|W@U}wW;?X-E*GOvbXg&3X_ zT9*DnS9_b&b#abfrmQ*7YMLs|6Af5nNkxSf*6lk?1}k{GC>g@7?%)y?YV%^Y<LO9C3{@! zj*!TOX4HO==-4@p8Ude$_b2I~7NKfA3JPmcZ+eTI)uqZizm!mTmEdlz$vb_wXzRL} zi@Ul$Oq#1LVyLPysm%M-5dbv6Jq5=_WZ2NLvIO`3AYCB>{`e5i#nr0zJbobZGtzyL z=e3kVU|GJuH;w2A#IPRy1tx^T(P~jD)(@Q(lS0NL7Ugudj0lBV{T}bEy0Qzpn!SK; zp&ct6jBnuW_l@>f1pi~9w(8dh@k%uBG17)1YOBH}jpT#3?~mHSjszB|?Y!Hwv-X=R zgD>k`Y@kNKlLqX3;8=Ia2Q&#xV~FQ?YHwqg`!zRKmzM`9r5G=lo&?$={M_wBId?fj zWitHIll~~i%*zuNJy6j%B(hVyaA|XzW0#k3`SqnamR$k==Ax(v7280O{H2_`!k*ui zG3&KOg3!w}2?Eqbk!0iUHGCNgmwqy#cm5)M4lT{gni#^Gyz#-|v4HyoGRRvXid_@e zI^+y*flRUogVXzdW@aVumV@4MDg7%D8A5Z3yT&dxSSN|@zpr8Gl zXrQB0=ik-GJlA{o_g-jsr}#~KTMQlxo5$1oAC5BGoMX#TM45Hz;TL93QyCnLQ@F$~ z!q6(T+El_um;mykTx{sTIxEF0OXrW1ci+s%f$owcJR`P(gytZ0h`hF|?XH)f^GGUt zT@w0R0O6^7OVg3P4Jd^*~| z=elLv*k4a?+rucf{FH{3`A)3Eh&yN1I{q^TA7T1x%j$eOo36>f$84phg-*ksZwFYCC52#Zw$$Ht(Bz>iV{ z*Hrbh8)21tDANb-rj>%>aaPvh>>cxlWch~SdrEEN0k9Z_TwG(~W;oF*Npu2P)#v0g zy^H=J@YTk%<1vmMPZKjaIl1T(OUa$Yzr3bFd0-+GyrN(Ok-YC`#eZ04IE!t@;t5Wh z@GmWf;|~8~aEd-J=u1u0dXAoUcGY++(_H$!dZhKf*iUY|Yk-t{<%m&mWG*-Ii_ojB zH!`w=n~WH?tnoJSE($Y8IxSE!L6C{-Z(}S}bK6Mx*oqLdUwJ6~^3b)te*iQ`H_bFg zdr1(nq7y!!!3*I5m%2vd@I0X7YA#L%zP$jekzt0v!R8{~E?4UeVqx2HDA+_wcpo0v zH-6Q23rx^vi5G)b=5AZ*d=GkOJ6;B8AIE)9F6f{{LpISd8%1l8)9Z$6&|)qQJ3^+X z3IGX*k^ZI+=IFli{2_yJ+QOn#9F`He+Olr7Mh|A6Immx2P&06f8ZkFwKiK~vA>XZ( zSvw~*LBq8%kEU%)qRVbF8hgyzPJ@ddA3L;Sq|4kK97;Mcb3Ae`BYnN=eOaTj``p_0 zmBZ#`0b&5d6X8HMHMT#)!k_(TqcXK_wZ$xht#DIX0X36e| zrU5D?#3NFk_f^9f1JA=03y08$v?YK<5jzdVa}PA~FL2_9QdsAQiSp?t-E=P$isL{{ zE5_9zTnc1v^x$V;msZivPnJ0H)V7JcRz(jvax*dh%xztNH) zj!{md`NB6wHODA(nW%N=qqgZW3p!RPD)7zEH=!|lauIEV(_iS4R#W2+wZL>3{HfPd zy|WSAyZWji_~&Vki@a`S{xtTfx`sx8zM>#w+!vNCpe34tEAkDl@#W*Wbv>6uz{JD< z+pH=#u|5;thJHD@Mb#mGG~y!chr-HK!}|3ieGvP&sHsoLC(`)-Cpe_@Hj0t;@BzIM zo-=!2h%$~!c~9aCE#1>uN80wk*TpA8%mFPYdJ%V8T}2Lxpw8-^Dhz8MVZ_Iu(a}+Z zNoq2A`3PYxQS5kq=gRMc7=ZlugTVI#S?C_m+7~9Ad{DtvFA9|oZch(%c#T2Vw*BY( z(DU4Mw%x=QZdG-Zjze2Bks)NJOsSzw_k_0NBW_oIi>oWbyxB5=;1Gf_cy7>ZHcH?+ z@uAc$Hayb0eGFNtHW~YN<7S`Hx}F`T6(=_eSc#K=5RJ0BB9xjUZ}NnKx|$jRO91e5 zv##@^QvF01O#pbGAojaan5vij)amO>@ySAS;jzJ!x7KV9ckprJ_f?kH349EOLR}Lc z|2Lk_!?1p~muyWl9KC=@F&7M`*=4gJ;HAv^RNKQhYs50CJ(gUHemZtqI2i?==i;nkUvQUHfEvxulQ*2-F4_F~gqVrH0K+hw(w|=j0 z2g@Yy2P=8dlPoQH1Bk>LmPXLxeAtCRU1Q_lAtQ0SDBQFQfNAg5mq+hAXHRXUoONZ< zvPJF+ovA-b5gW>V$FL?($BAe5syALR!#Ts6_}cO?O2Ku1%$!0c1uW&)KC4mD{)FI{y+9 zkJw~*@`|BG>9LjJbDzpRrnS6pP!rXHmv=R5trUPMkQBMP*}-?8Nk)ClcIp-G@*Ivz zXYLMCfQWTQBk1NjaBg;KswHntHKw6OfpE|WUU9O;AJb{%L|N?%GZVV1g#$KIJ!i;7 zl4C_VfxhAKVi$r6$pD?IkA`MLg9+?|`UWvw*IBC0bJ*oip(>~%2I(3;s6s>NxwY!| zn-TSm-XHRC*piK}y_v=cjrF$P*Y>!9^{S*Efbtvo!1IBgNK8Pjakrf~JXvGc8Db;@ z@LG^70*5lO2$OWUK`et9k*VsGi;Pn_l!7G5u%4!OTsa}%;ygV7>&R7Dk-c{!v5cpi zGrc3-13ewdD|b9-2s(@3R}`l`egmF2=TFbqb#zS| z_pserocjI-K16AYx23pA3pD$K{?)V5S;f^H?2z>RviTwvwnfjh#R?EDt~CKaG19Kf zs5w~}M5STnVK#86mrNIgL-%NWgUgUkTq}?EW=Zl?D`}`UVxZM^bbJVCYqj^3$~;Tj zm4&InP>lGwJI$wYOQv%JfNvUyzWB6zj0-G%bkUue^1(EE()Jztp(u7`0R z7IIbu^T_#*5_?}opl{p%v&L+tvugEXRIQyKXgHHMtK+LtxB#{c(_d>jnCGEws9X+d zS`#j}6e8wz;-MskO_V=G%iU$x0t}f00sGTv85~_aPlc>${U)H@3jW9WzE?mi!)VR| zz;+N69wpc9^|~K%>UU*Abcr?#HLZ1LOaPS6`N#Z0ob!fH`~P;&eQS%gU!ZvHvE4 zb?~O}yK~6uYox!4!2XD_?Gi7||Af*~C8Ms;fl_NED&q6{H^IgX&rSQ`PT^7?@Tty) zGxXq=FyGi}7Cy80D<&5?bv>^7oU?)l02v2HyMQDq>>KtR9DopJhiYm}z z65Rg6LYgkB;S70K{+hmDFfINg39K-ZX1II@1MR~Ow zP5*cmq|=UIasKNCnXZFof2kGCZrL(z&$J$;-XxuXxn1Opugxxl`Zz$d&e!n%y5Gb# zmMCZ$B(|#;TUIlcO}x2%0TfmTG})x^6Y*8O-tpeAD2a!`mAbq(%C~`~As@KhLCL?O zvQzYF{!yv2Ge7oLQz;>kbZ|3oQFY;j5$_n{z;6kjK%MYqK~zUzntZ+U&Fg^1NV?pV zp^lP)U(%p#3Uz7#`_|p9?i~ttwMIb+&IDdb9q#L&iVfv#!;R0P)2y4hx`qv|2J{7J zI8FRVsbdpLfe6=G%UFOlLqQYyu0~doURjc z-9@YJ_|%J2xX}@LkYCKm6d=A*(xFi$96&=(bortTkWSsW zxjn6cd(<`NJ;$o4kI^R^)76o|cqx7n4u5L$4!#OaZTp~BM&Iaf4xjZ`-j6j5dgO?a zY7L#b%4#^l;@6OAkXQLu4$91S(nM+;hq{Ch^)BU^J{*<@$gv-o$6}xQr#hAf&g;a{ znYn9vFVm+~RfsbxK~BO83xL;MU{~}6p00%;^OrN>k049h^LT9LEx%jQ$AU0}7XHS)Br4Qu^4u`~9v+7qMP`+Gy^tYj{YsU;w3X9A zet^!@(|fLJd1`%H*Y>t0NUN@Cp~=V&T%-1e|Ip-WPGt+j&ve@ugvi%lxTRbcAhD^061m$HGewPCG|dtv={x(RkhA3aC=ANpk#M+x>UqFylt=H-!Gk4+{RJCdXAr2acM*^SixQ zri$_T85F|Eln{(TlcDqRPr2$50H=X29oy$_DRy^V#L4IS&y+SNiHK`G%!Vj~_dvIq z@|J7*nCoMLO2aN?PhU4CVD&*vKnwmF2?Ja(}eg zV&E2@?#(?p-Vrh_aDyY<;^FnF8L zxG}+UR}S$4r~gSH2@;#kL7L6sfH|Y2UYG~l_uGLeo#GX^4r>wLCQ++sM&nyCYpmUitCkJ3PYQ zslqRyE2w~>xgRHO`?*g`#Ia+flsV`~QV;D9%l4?AW08sYkrRg{C&%B=?(uy%ZGIK0?Cl)X?Xv6-VojYeEZD!JASKg`VpI{VZh)_0rY6obyVQunFq3N8mGb|2sm<^ zqtK5b(?g<2?rZayK$ZLi^^t$z!19f;evMNs^$jZuIUBTI-R`VgD+qLt;FhW~f_XYJ zjtkKpCPWfS1TOsrbbH6^{Vk)^F(XGGluTh@(mN4P4;AfeNz&ZP;&CbUyS@d^q~!(l z@^!e^lw@Vw5nLj2+}opjaU|N)KYyDYJo4s!(%+ZMi5=*Bv6%$CO+P)i?P{6L);cu7 z$s&vGQKbd>a!DO~G0Wy`JM-ub5g5%R!7noTco9Z zZk5C9R*R+driMns8EY2L9>~SJ+iik9nqB7Ec6!_U6h3R;8vr|M)Zp~;$hDyDo|SIP z*q&nr%ntQB5;Hl8z+w|`5;|C+l$EPaKSnQZ;k)(AIuEH<`z=coJnRkdS{fBk>H)%o z)xsN(LOApIxQ)m6@-N$UP@et1y87MT`h*<{bYaD_dKl0UtzVwS$K3X9SMlliy+|UC zH00$w5HHZ3vf=mE{Wzf{6g%%8(!b{vz{k}cg~QNB6-i?BXv%&Jm7zHZlZnJ=cNkZV z(0*X3{7fOvtom_>bamF!1jsT$rݠ#9srGkyXlAO6~=>uN&mFi@)NX1p3D}&TZ zUIMVnENg%K%6=w+xz@_&p}u2E18z%qeRuT8!~BMoK8k_X8Pv-V1Q=Sh@<$;@V!~%= z3-9z>hr&XRuc?&Z2d;IxUH-(MEVh1v9m!D&K3na5W;3fb5i}CY(C+&%L)v}n>nO64 z^4YMRe(0(xCE>Rfj_SX-^k^xwGj>Ux&g586rEDRR_WAxBV@w7C7i*4NmATD=$G~Qo zgoT8qbw^npT*ca>?&D=KdLj!Gx<_x||0k`^ss(N;bnpx=Xo{_5>{Q$Sw%9UwyEax( zbZBhAAy1+cKJkKzaAh1>v(Z$Fsqe!ka8CVqrc{=sMv;`@1Z+Gu3GOD&%WhA_WKt^K z(Mi~j*I*hF`eyw0wYALVkrvy^oT7^N3S$X`7+7)tYj{^v{LI;Y`>6=5GD&aU)y&#f zR1nH%n?p@2B2NXLKP;Pzqxh$Ut4njTW5O78`)p$uM;r{@;O=Mct#5=GT^i0fGF1wU zhO6Z_OGdDjsk=l*7^HMgA2RXNTxxaum! z9VFCM2U05E?g9?+pR!aaDvs`MT9n{2j*=_rzHMv0YQtzA78M4vg&5hq%B0yJ0ehd)Bazcu|N*Ea2Jl&~wPdTGy5?B74N($S##OmXuQ3~B; zUj!d{B>5i=m{j2Q1a;DDHs`G8DmC6kDQ?N2zILNX?gK?A71&|y-`d;J|-5wW$%)`#B@MlL|Jv1w`0wub8>1DYZGHitIW6 zHZ%ud3^1c4JH@7hNTMX&z=aCy(NorL8ZRv^ z9K$$+rPpXS4EE$nwI$*-9sCvns?)2A$njEtPV#kKZ_AXfQA;f2NdsWKj{#CHF#GB5F2t#Ja(ryDR|wm)4!^IYrhMj?>#?ibI_Nur5XuS*y(ht z$j&@&u-9&X+85KVmyl>yAPuS{)LN`_(pm+oRKmT``+mJYjk>c#N1*@N?h%~q*cJJ@ zA70x{Z5qu2DWf#t>W9FZp~1t<<&x>Y;+|S2i?7aHw>dwtpJesWa`$dCqja`c%7yaL zg*POX8FysTqZq&-{91z;H=SwR)s$YaUz6+>|fJE>$q;+ z3OahR_FmVx%*KYgDN7X`&pOJ&=G4xA@%?&OjPETTvj`2kp!K8-uX@!#NMOa;OTAVC^=W{k-*P z%!~tg8YaMbWU9=y#)`8@Abv-=K(W61eb22QfRYdk?1B`8)8CsqB_o`9`a4FFTxGn? z_1MPdvXzk6gVljp)Gt~sIw&Nm@aqALWIqwRjTGZ!9_qS9>0@G*(CFNSQJUgJ8eI~_ z^<`F{@ob`#lj++f|08D~7O%{1S7HOacX}5dJ(&m?SlL5b)$#wGe@;=&!%_A zSh`<2@!3uOlg@^u`z_w?Yq%06w2tf;p8G8nU3I9Wf?Blu{xSiV;~-tf3ZhiWOsZsh zBA{D0o&-qMgZ^PSMUoDiqn1dqlgcSZ85z0@jsF2^o z7}Dg#g_w@FKQyGz2K>7e)oTYxx~z+1y))$PO+{~_BnaE!0o~*LAM2ML28Pqq)40#B zV8m{-Qf8xnHlK%xfODGURcsG8NrIA+(oaNCV=yfJ-aZ~Y|m0h@r&x%|T z-ltKRTQ1tX+WvudUe|g~pZ8;9L;;^p54_KN?=XQ0p^25^#Qs9R$Hpmf{^q%(vlR=* z6eTTHZt{2=ddApo)erW59s@dJSX{2oiW5c|G%Av`p;9%T(2!taYKxt+dqlquTKRL@%a%@{Bg}*Ij>@()!Ms=8MtRYYw$w)$Rp|XiM?O3v(`9;Rc*bbB}*$ ze-gx&g@GlGfeR(>s-5Xq$(zB7;UnwO?>nN1sPwzFu#LjjGk%-l@w5gxecjI>-=*%& z(QLNbWivHj7Y+OF3j1aK+F`>Ylh7zE5>{Cd@|*m*R3Hf>4U!%IP*5T5`)mKQ^59&k zz-TmxSYoACkM?9yi(EpG)BaeEHWNW8p%Mb(Rl?+oOdhIu$!X>0db4d;&nWkOi}z3> z`;8{_R&6tHr6AZXR`tCxhiDEu#yP;VD9q!T8-Y~O%&%t!);~IosdVvl$el|h;97KkhZF})^VGwjV{Mn27(c0D`b9y6E%Udrjr7@%(=`_382>e zs$4rX;He;nNp?KsS=zlUjtw?37I!674V&UfhKc0IQ}^%YV|ASu5$YZ$Nh94~_3rfi zI{)|RDh%p(Jd!84lPCT-*O!KwbdefcBBz&v|7GVI84IQdA%TzzRbI6Sft5Pxq>OTS z5)J6p4IX+OQ=nkrD;}hXH~A~R9XJnzgi!5-hhAW?HTx$OdiNo|%ab~e5Ya1VtWgof z8J{Q3XN+fuB)kk;(rHK`@9YgH!d~ofy zUPnO5Jm{uig3>bm@J-BdL6kY)+O@09J(A3`;9CqciQ$vr8B`~)O?3BFp&-`TRLx<$ zPF`h9FaavAkfa{lZmWS{dq2+^jyaQb#mrCxuZ=R_Mj-cZN$f$p@Ng^bHkN3_w@tyv znWdG9!6t7s$S!R+Vw3S1K+pIac_HFS1Ew8A;AP~c)|@0(IUf$g0*>bR2A=2MPqmwc zMc&LJc#HQ-(y%PJMtTzAZ~T~+ou`t!uzWY5nb=1Os3Xg{*L-8=7g6tLX9VoB+Jbd~hl_+n1^wE|fko76J}l%k8#vn_Lv?8aeU@ zR>i0W5y6pT1jJssD5XQ{IkD&HwYfMn5s!WsQrW=@?C*nK_2Rm);_sd(S1E!Fzv3HI zDJRF>XFk|*qVd2hU;4rB8*0>-coi*AqMDAovO)^d3(3c0;>c&V&zWxsPr6<=YKCC; zQpG}1f=L4FhVp;nHKR$wrQWS0vu+$krLIhpEtfCP79#052Z3W(WgSj9KM{!c)PHy7 zc^<%KK6sAnj9EaZ2!w&{9dLpx_SW#fH$!hW%u~`mF$i;#Pz=T59NLjQHx#q5aPK&g zpy7s_tZNmu?%?u2qBf9q1Ykf?WCA21E z*~oYRY79(JNT~`8)Z>cmhu^v~a*bKGH<<@~z$~+T4<-2jqH+Z_B)0iU(_#kZyhq9A zR(2z)PgldKT(&`9-1>oF0Plve1$t-X`JIyN)(3uFjF4lPQ$1oh4?SPu#`OomK5nkf@wpPLbDPFCv6;!Vn3Xg6 z;@t(0p5+<%ncu^?;^oKrnnK_tUxmHnsd+GO+bG_KdGa(QB37{i*h_W)--N&Y9 zdzpXrx%9Gz8CP~ajmaK!Z{xO3l3?xIbDMg+?g9agT&V|{F&(@GKxod%NHg{}19E|< znuYA0sUq+T8EqUvl#A35Lw>lHQK)Z<-{fA8uoGEgHrx6%N7v#5`S&~+^x@Zs@-0_d znwTaY_O-0erBm`%$KvVQhLc;GDJw|&Rg3^jwnyXov)feBU_u8hHRwfweY+@ z)x{=GaM|T%XyHWI%Tu)yUk3e7pbsL9KmD{A3F;KTd9N~pTm zxn;A>W--}Zuyj^xbVC?LIoUHrrkHXlnSRwH!1n;1qlpC6vGJ*!X@sCX#bu6#6s59M zgeqwkvNJYE5RnwEZq1}O_GiGvs77p*78|%`r^l__CTPa4vvska&rq2Af=X;~~KGxP&X8qE@wzFKJp-X6Sh zLriVMRd6!>%WF?s*Mkpdq`xk0H8&Valm=rM0!wE794xW*FD;6MyOnxg`VwtOU9s@g3ir3G$*2IpO`W} z&Gchr_5%Y5^Ft`?N~0%DetBWcD)Wr>m^xRug=X{#L}$VrB#uh+GmUEB&5JwR+Kp^j zPlr1Tg>gPQ*c+rseCg!kQ59v!l1MY~+w6X$-~%hsn^;UQ&~;bho&v6xkIr9j)J0vS zAOG%~O)N$}hfzhzltl~#N1jagb0Rrj+^m_j?Y50&S*Ui72`pQICnJRPVexI-#m^7}vciIapNrrf2xgBjoJj z*VZb~Ih#A9$zmUpG$OS2K$59VKT*OiT71E_t5Ada*4u03;rnGHJ>PEh(`)_JjPbolPao-4D0}$t}VO#=7@uirHbbK=BR!Eec{BA zV-k{ibG@d{TAzSVE4_eqmX%vk#_Z`h{(}rPOTM`99w3#ZCNLrKazxb8Vl+l+0>J_k zjA)D@%%X1BUw^mdy?1LOgz!vAN({p;q{=M708sf|`YisT_kn*o)4(6BA3P;Qv~a#> zB+qutiBhJ6j&A5*jV73=)t-*2T8$RN!F0AEp8pM+$3mAj-Pj)y{bIrI6jJE|I@K7i zi(}$TaU#}|60&-Wjlk0myrX53vFvpW5+# zn5Le|Qpxh8qv_W9g#t@}V+nc#4yM*QNIYvW)@Vt)I^w`L!=R-+8>yY3Hvcs7mti6+ zh|0RpZQj)9xw(VWrzLH8=kQM~(gXajKLXIY?qo=W4-VpoLcY_)5YBj`3o?lYj*Fm3 zWfz&o7^vdns0eX-cUmqP-#q4D3=Ppz4iUWzu?ukE4d#kds^Cmo-AtZtlx<%J+YbH@ zcoqJX*jpd>HucKR_*5xA|9o{9e95P96uZYGu+itrlbQo#7F{Yx)<{yCtYWu%z5xo& z*IkP%(`3@h@|dwZPNQ@_rb_4*pU#}57n(Y!OC!qDNHQpULr}c^n!>~rANRpEk4UWg zcL;}&%s-;a<++MCp>=2|{BlGxOQYN6VZdO>zuaV>c!MNpfrkRXLsVyR>@S&^hy(Jz z4<>^-XlF1Cq5-QpzG#jL7q?1I4oiVuBEBPz7vr}0|AnJwG!N9M5lin@bjRHAigaG~Nn4G(TvVALF!}08S#5_h^ z?8-sFSs};W&*F#<-CQ}jJ@|$Xj)gln8Tp>A`O#l)*fm6*(dpWMpK99rzOG*k+}F*R zJlDcV^G|Nr1p6isD?ueQb^h)5rd=Ocxi50_IM4FEY=sF{s|o2I+kie6^4f5PYkZwc zxv%d|x9DI_H$LOU&Kcd(dW{8&2$1cfpsLCoLZp@hrMJqUJ1N)cr@C+DJ~^uL-Yp6* zA{369cBO3B-rc%)FARWx(_aMZ@C}guM0y+)`bTI8C=*6+cvFH#k%CC^W2(JOJNUB< zna3os)Zay+Bn75dLk{w;^%~wEWf9o9e}3U{m9W`KINd$qibjVGdxab?COq@O@^PPK z14QA!{`}6@GV`T<&iXYlq|cmFa3i(y)>iVehb~uti5W0j$}#m*-vlwFWek*>xHMWK z4|)UU0mEHnyWiISb6$eT&g7~u`=$2YnMkpRpi-2QEvF_OQZdVJx|qGrH+#A!|ZKZ&T+u?H2+k)c+|hFJfik***kx-J!JAKWxZDDEylJ z#=jVliOsm>4G8xO@cepOb=adNf&FZ;Z+1@;;$4kIhP0IgC2k5dP2gK0*+iPFkj3f> zvTixphk^}~4I1>4P-yI$=?5?6d1cNrB-|FW0t*W%I`Aj_6(CwBnu4*={7Kjiq&@Z9 zz*G=eUKYEB!xN3dKuEO|Bz=EJp339FQ0AMtdHmxB@uj%^n!i^a z_xxyInbsh{^X|>#G>TJ;h6|0&fQX7uuuCL@*Cz1wxVQ_k$KQKr9Q$7Jls@cBq7)5s zzG~=R4PqKo+-lT zy#_)fAcv@S3oh!(sfwb9jDcTsu5FoE7z2ouKLz>IF@Yl4?o$&iK7|f|zy)T?-0m5q z&$OcFZ&>H+_RPAw5IVpoOKddMlUJub_=ZL#dg+CNBx4gbsvlm--j3}M)sw62+MG^% zbuFu{oa#7cZu1%NU=VY&u%Sg2zi(>ZdNG&S6H~Ou}q=imN^lId2tHj25b%7 z8lW`O;%vek79)&4-97zn-MMD(xUlRhcr$6W+^DE+;qgKK4wqt|^=+{qW6A0H9)r0y zaqybdL5qE~DpkkbXagp#Gyf($$hfDg3g3TQcVDGWvT5|kfJKs}?a>G9>^OVF)VbBKMDXXi=T;=t{kHvg^I2N+6 z8(d2DO#-|=Pp@9j%T6-^`-CJ9VlG&kHGV28DvJqksK;wvgx=y*yb-2DOmVFX%SI^UId7sL8|((`yKS<)<)svd$lssDU)k}Dv;>mZsouS`e(e*4zH4Wqorcag}p1J&XYHMs6BgKjF*K$@mN1ZaOpt>!#zUnL3{JlnA4uAjX0TOYUxk0Nd*+b zt&yR!OxI?^W$w6Iu3UAF$yh?i+(|6YsCob6JzH{)BOFnSXPA;{cYlRj%v)}bvp-*z zum8)9M_<>05`{NR;|FyHphJBh)X0;HQZQIZ=3Tn`0578ia%W zqkrFbf8{!;Cx@2ERsWl?m$Kf=Aibx%Y*GE@ycGl5`^p_EbqjV$`vt&U!82VXS7q6R zEdSN2Hm2U_>_K;}ZsWt|sUo(eX;YqIo4l68RpOo|N5C>ku_E94UfD3dG~n)%feoNL zUW$6#Mi}(--X9F>>wZ0mL4O?IAo4ydj4v%M)mMKSGTgte2L7g<3^+aDY7SP{^sf>ZP+x#P>_ksK74IhIwrRd?^u^CO#c?cN39k@w$% z`OmenKlIe?@gC;wQ&ljys`GD4h&NJSc6prv%>w%;Iu@Y9Ir){6v~sr!PkJw>AXwB*+m~vc6tI zns&c|FO++q9k9eLjihWaE`_@ugz#=dS_dp;0tS)FK_9;iTQPa$n^;~o6I0${ zn? z-L_BEr>7t_^~k`$cRpipL>OSdQ{=wn%}h#oUxW`j0z2HjlLrGI7N|1Uh?AI9{CIw4 z-Ngx*zCX0}7v9yj06KRYV--h&7(tU~UO$+we1jt}owXVF+(@MhJPYJKn}+qH1mGw2 z70`x_Qk@$|)_YZeOL}kIZCK9yB?}9|)$ieN?R9F7BX!wroP=CnG9iBOk`m-yK2inr z{XxG+y4gZB*cxDQzECphl|IjG&%W2X>-Vy)cXe`p9Ey2+-qk%3&^`yi1TiWHgh!rL zOal74VN09K?@->7$dxcC6EbF|nV1wn21t7&j*qkF837IHc954F`h$8kyz$pfJoS0;{tSlDOr2fK2yZdp?sO9{);(s}xz6Ws(2reTc|`WV1D`&73Vqgp za`Q?R=x!&-OO%)iv7q+~U7-RU4|_JakTjw?8CvXajyazhbwYLqM;_RiN&Gv>nK4^u z&$bRcypkA)-S$ilyngElmP#8NtaktDXMI9WM=-q@}T3V%@$ z1LY$j{6%k)_bwv+?Ll@J-eX=|)_b7Z%irV4t^ygrlgzKtHtzwH?x7ja3CF?=PbF>B zU=?A~+kZZHV+|Nr>b`-=lGLSi0FIIa69I4O0a^)m znkTc6EK~j@aCtTKuSm&D0PzKlmE}%TczPo+rZKNZ}h=awK3>JVN1C%RH10E&(0Mx%E+1FbrF%b;|Vgw8Ld@uH534V6;~+7C*_@!zt@3A9<<;@9Qr!;z(D{xj6Q$OBZ{B$xHBeq%!qF;=iqHuG>@w7* zr4_ZJ)ec=?QaG zCsbtdP=N;sBI1VT*Z+c_KLpBM>9^C&cpZRCW&FoDHzn#Kqwl&lP*Ms`WLAKt2rpQR z7Hdq<2}d(j7_}9an)(B82BhBQbHWjxc%fHpQLLsz&RE#qkgCi-5PD-&l!l(3(siuM zw!bPVry>5z3yZKGjLVD4#EMW|bXY4Mr|M$p&eREwOxB%?sd>1#IkqUD=-WQo`=;bF zxLQguF~`@Ul$|+7+*#&TC`|2nVVH;LfIw0|NBHt50>;QT?EskEnDav z1m4hI-3GcqEcq4eg$dr~h|dw!6d-F!lAc93iPC_AqcO7ex}45n_ry|p-cLXpq|M&4 z!a5wpvJKx$8N<|}gZN1XnfziY|33le0T}*r)kT-rULJo3(Enj&jt}s4P#Os8Z; z&>j&qg@;v2xyCA-oKD!*rdZ_52|chfn8FNNF^#Zz8n_k?PM+ziXCWdUw403-0L!Uf_mf}QTgHTBB&3ljIKjT_iIt%LY(z{s7v@4zb7j17Q@|B{9E~s x*f1C&j@Swffq1F)eM2#M2%7xy^&c_?{y&K%w;jV-PA32W002ovPDHLkV1m4yOUVEL literal 0 HcmV?d00001 diff --git a/src/index.html b/src/index.html new file mode 100644 index 00000000..6111bc7d --- /dev/null +++ b/src/index.html @@ -0,0 +1,120 @@ + + + + + Iris Chat + + + + + + + +
+ + +
+
+
+
+
+ + +
+ + + + +
+

+

+

Exchange chat links with someone you want to chat with!

+
+ + +
+

Profile

+

+ Your name: +

+

+ +

+

Account

+

+ Save a backup of your private key first! Otherwise you can't log in back to this account. +

+

+ +

+

+ +

+

Private key

+

+ Private key is used to log in to your account. Keep your private key safe! +

+

+ + +

+

Peers

+
+
+ + +
+

+ You cannot log in again unless you have saved a copy of your private key. +

+

+ +

+

+ +

+
+ + +
+ +
+ +
+
+ + + + + + + + + + + diff --git a/src/irisLib.js b/src/irisLib.js new file mode 100644 index 00000000..4b4f59da --- /dev/null +++ b/src/irisLib.js @@ -0,0 +1,14987 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('gun')) : + typeof define === 'function' && define.amd ? define(['gun'], factory) : + (global.irisLib = factory(global.Gun)); +}(this, (function (Gun) { 'use strict'; + + Gun = Gun && Gun.hasOwnProperty('default') ? Gun['default'] : Gun; + + function unwrapExports (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; + } + + function createCommonjsModule(fn, module) { + return module = { exports: {} }, fn(module, module.exports), module.exports; + } + + // 7.2.1 RequireObjectCoercible(argument) + var _defined = function (it) { + if (it == undefined) throw TypeError("Can't call method on " + it); + return it; + }; + + // 7.1.13 ToObject(argument) + + var _toObject = function (it) { + return Object(_defined(it)); + }; + + var hasOwnProperty = {}.hasOwnProperty; + var _has = function (it, key) { + return hasOwnProperty.call(it, key); + }; + + var toString = {}.toString; + + var _cof = function (it) { + return toString.call(it).slice(8, -1); + }; + + // fallback for non-array-like ES3 and non-enumerable old V8 strings + + // eslint-disable-next-line no-prototype-builtins + var _iobject = Object('z').propertyIsEnumerable(0) ? Object : function (it) { + return _cof(it) == 'String' ? it.split('') : Object(it); + }; + + // to indexed object, toObject with fallback for non-array-like ES3 strings + + + var _toIobject = function (it) { + return _iobject(_defined(it)); + }; + + // 7.1.4 ToInteger + var ceil = Math.ceil; + var floor = Math.floor; + var _toInteger = function (it) { + return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it); + }; + + // 7.1.15 ToLength + + var min = Math.min; + var _toLength = function (it) { + return it > 0 ? min(_toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 + }; + + var max = Math.max; + var min$1 = Math.min; + var _toAbsoluteIndex = function (index, length) { + index = _toInteger(index); + return index < 0 ? max(index + length, 0) : min$1(index, length); + }; + + // false -> Array#indexOf + // true -> Array#includes + + + + var _arrayIncludes = function (IS_INCLUDES) { + return function ($this, el, fromIndex) { + var O = _toIobject($this); + var length = _toLength(O.length); + var index = _toAbsoluteIndex(fromIndex, length); + var value; + // Array#includes uses SameValueZero equality algorithm + // eslint-disable-next-line no-self-compare + if (IS_INCLUDES && el != el) while (length > index) { + value = O[index++]; + // eslint-disable-next-line no-self-compare + if (value != value) return true; + // Array#indexOf ignores holes, Array#includes - not + } else for (;length > index; index++) if (IS_INCLUDES || index in O) { + if (O[index] === el) return IS_INCLUDES || index || 0; + } return !IS_INCLUDES && -1; + }; + }; + + var _core = createCommonjsModule(function (module) { + var core = module.exports = { version: '2.6.9' }; + if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef + }); + var _core_1 = _core.version; + + var _global = createCommonjsModule(function (module) { + // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 + var global = module.exports = typeof window != 'undefined' && window.Math == Math + ? window : typeof self != 'undefined' && self.Math == Math ? self + // eslint-disable-next-line no-new-func + : Function('return this')(); + if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef + }); + + var _library = true; + + var _shared = createCommonjsModule(function (module) { + var SHARED = '__core-js_shared__'; + var store = _global[SHARED] || (_global[SHARED] = {}); + + (module.exports = function (key, value) { + return store[key] || (store[key] = value !== undefined ? value : {}); + })('versions', []).push({ + version: _core.version, + mode: 'pure', + copyright: '© 2019 Denis Pushkarev (zloirock.ru)' + }); + }); + + var id = 0; + var px = Math.random(); + var _uid = function (key) { + return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36)); + }; + + var shared = _shared('keys'); + + var _sharedKey = function (key) { + return shared[key] || (shared[key] = _uid(key)); + }; + + var arrayIndexOf = _arrayIncludes(false); + var IE_PROTO = _sharedKey('IE_PROTO'); + + var _objectKeysInternal = function (object, names) { + var O = _toIobject(object); + var i = 0; + var result = []; + var key; + for (key in O) if (key != IE_PROTO) _has(O, key) && result.push(key); + // Don't enum bug & hidden keys + while (names.length > i) if (_has(O, key = names[i++])) { + ~arrayIndexOf(result, key) || result.push(key); + } + return result; + }; + + // IE 8- don't enum bug keys + var _enumBugKeys = ( + 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf' + ).split(','); + + // 19.1.2.14 / 15.2.3.14 Object.keys(O) + + + + var _objectKeys = Object.keys || function keys(O) { + return _objectKeysInternal(O, _enumBugKeys); + }; + + var _aFunction = function (it) { + if (typeof it != 'function') throw TypeError(it + ' is not a function!'); + return it; + }; + + // optional / simple context binding + + var _ctx = function (fn, that, length) { + _aFunction(fn); + if (that === undefined) return fn; + switch (length) { + case 1: return function (a) { + return fn.call(that, a); + }; + case 2: return function (a, b) { + return fn.call(that, a, b); + }; + case 3: return function (a, b, c) { + return fn.call(that, a, b, c); + }; + } + return function (/* ...args */) { + return fn.apply(that, arguments); + }; + }; + + var _isObject = function (it) { + return typeof it === 'object' ? it !== null : typeof it === 'function'; + }; + + var _anObject = function (it) { + if (!_isObject(it)) throw TypeError(it + ' is not an object!'); + return it; + }; + + var _fails = function (exec) { + try { + return !!exec(); + } catch (e) { + return true; + } + }; + + // Thank's IE8 for his funny defineProperty + var _descriptors = !_fails(function () { + return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7; + }); + + var document$1 = _global.document; + // typeof document.createElement is 'object' in old IE + var is = _isObject(document$1) && _isObject(document$1.createElement); + var _domCreate = function (it) { + return is ? document$1.createElement(it) : {}; + }; + + var _ie8DomDefine = !_descriptors && !_fails(function () { + return Object.defineProperty(_domCreate('div'), 'a', { get: function () { return 7; } }).a != 7; + }); + + // 7.1.1 ToPrimitive(input [, PreferredType]) + + // instead of the ES6 spec version, we didn't implement @@toPrimitive case + // and the second argument - flag - preferred type is a string + var _toPrimitive = function (it, S) { + if (!_isObject(it)) return it; + var fn, val; + if (S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val; + if (typeof (fn = it.valueOf) == 'function' && !_isObject(val = fn.call(it))) return val; + if (!S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val; + throw TypeError("Can't convert object to primitive value"); + }; + + var dP = Object.defineProperty; + + var f = _descriptors ? Object.defineProperty : function defineProperty(O, P, Attributes) { + _anObject(O); + P = _toPrimitive(P, true); + _anObject(Attributes); + if (_ie8DomDefine) try { + return dP(O, P, Attributes); + } catch (e) { /* empty */ } + if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!'); + if ('value' in Attributes) O[P] = Attributes.value; + return O; + }; + + var _objectDp = { + f: f + }; + + var _propertyDesc = function (bitmap, value) { + return { + enumerable: !(bitmap & 1), + configurable: !(bitmap & 2), + writable: !(bitmap & 4), + value: value + }; + }; + + var _hide = _descriptors ? function (object, key, value) { + return _objectDp.f(object, key, _propertyDesc(1, value)); + } : function (object, key, value) { + object[key] = value; + return object; + }; + + var PROTOTYPE = 'prototype'; + + var $export = function (type, name, source) { + var IS_FORCED = type & $export.F; + var IS_GLOBAL = type & $export.G; + var IS_STATIC = type & $export.S; + var IS_PROTO = type & $export.P; + var IS_BIND = type & $export.B; + var IS_WRAP = type & $export.W; + var exports = IS_GLOBAL ? _core : _core[name] || (_core[name] = {}); + var expProto = exports[PROTOTYPE]; + var target = IS_GLOBAL ? _global : IS_STATIC ? _global[name] : (_global[name] || {})[PROTOTYPE]; + var key, own, out; + if (IS_GLOBAL) source = name; + for (key in source) { + // contains in native + own = !IS_FORCED && target && target[key] !== undefined; + if (own && _has(exports, key)) continue; + // export native or passed + out = own ? target[key] : source[key]; + // prevent global pollution for namespaces + exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key] + // bind timers to global for call from export context + : IS_BIND && own ? _ctx(out, _global) + // wrap global constructors for prevent change them in library + : IS_WRAP && target[key] == out ? (function (C) { + var F = function (a, b, c) { + if (this instanceof C) { + switch (arguments.length) { + case 0: return new C(); + case 1: return new C(a); + case 2: return new C(a, b); + } return new C(a, b, c); + } return C.apply(this, arguments); + }; + F[PROTOTYPE] = C[PROTOTYPE]; + return F; + // make static versions for prototype methods + })(out) : IS_PROTO && typeof out == 'function' ? _ctx(Function.call, out) : out; + // export proto methods to core.%CONSTRUCTOR%.methods.%NAME% + if (IS_PROTO) { + (exports.virtual || (exports.virtual = {}))[key] = out; + // export proto methods to core.%CONSTRUCTOR%.prototype.%NAME% + if (type & $export.R && expProto && !expProto[key]) _hide(expProto, key, out); + } + } + }; + // type bitmap + $export.F = 1; // forced + $export.G = 2; // global + $export.S = 4; // static + $export.P = 8; // proto + $export.B = 16; // bind + $export.W = 32; // wrap + $export.U = 64; // safe + $export.R = 128; // real proto method for `library` + var _export = $export; + + // most Object methods by ES6 should accept primitives + + + + var _objectSap = function (KEY, exec) { + var fn = (_core.Object || {})[KEY] || Object[KEY]; + var exp = {}; + exp[KEY] = exec(fn); + _export(_export.S + _export.F * _fails(function () { fn(1); }), 'Object', exp); + }; + + // 19.1.2.14 Object.keys(O) + + + + _objectSap('keys', function () { + return function keys(it) { + return _objectKeys(_toObject(it)); + }; + }); + + var keys = _core.Object.keys; + + var keys$1 = createCommonjsModule(function (module) { + module.exports = { "default": keys, __esModule: true }; + }); + + var _Object$keys = unwrapExports(keys$1); + + var classCallCheck = createCommonjsModule(function (module, exports) { + + exports.__esModule = true; + + exports.default = function (instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + }; + }); + + var _classCallCheck = unwrapExports(classCallCheck); + + /** + * Gun object collection that provides tools for indexing and search. Decentralize everything! + * + * If opt.class is passed, object.serialize() and opt.class.deserialize() must be defined. + * + * Supports search from multiple indexes. + * For example, retrieve message feed from your own index and your friends' indexes. + * + * TODO: aggregation + * TODO: example + * TODO: scrollable and stretchable "search result window" + * @param {Object} opt {gun, class, indexes = [], askPeers = true, name = class.name} + */ + + var Collection = function () { + function Collection() { + var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + _classCallCheck(this, Collection); + + if (!opt.gun) { + throw new Error('Missing opt.gun'); + } + if (!(opt.class || opt.name)) { + throw new Error('You must supply either opt.name or opt.class'); + } + this.class = opt.class; + this.serializer = opt.serializer; + if (this.class && !this.class.deserialize && !this.serializer) { + throw new Error('opt.class must have deserialize() method or opt.serializer must be defined'); + } + this.name = opt.name || opt.class.name; + this.gun = opt.gun; + this.indexes = opt.indexes || []; + this.indexer = opt.indexer; + this.askPeers = typeof opt.askPeers === 'undefined' ? true : opt.askPeers; + } + + /** + * @return {String} id of added object, which can be used for collection.get(id) + */ + + + Collection.prototype.put = function put(object) { + var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + var data = object; + if (this.serializer) { + data = this.serializer.serialize(object); + }if (this.class) { + data = object.serialize(); + } + // TODO: optionally use gun hash table + var node = void 0; + if (opt.id || data.id) { + node = this.gun.get(this.name).get('id').get(opt.id || data.id).put(data); // TODO: use .top() + } else if (object.getId) { + node = this.gun.get(this.name).get('id').get(object.getId()).put(data); + } else { + node = this.gun.get(this.name).get('id').set(data); + } + this._addToIndexes(data, node); + return data.id || Gun.node.soul(node) || node._.link; + }; + + Collection.prototype._addToIndexes = async function _addToIndexes(serializedObject, node) { + var _this = this; + + if (Gun.node.is(serializedObject)) { + serializedObject = await serializedObject.open(); + } + var addToIndex = function addToIndex(indexName, indexKey) { + _this.gun.get(_this.name).get(indexName).get(indexKey).put(node); + }; + if (this.indexer) { + var customIndexes = await this.indexer(serializedObject); + var customIndexKeys = _Object$keys(customIndexes); + for (var i = 0; i < customIndexKeys; i++) { + var key = customIndexKeys[i]; + addToIndex(key, customIndexes[key]); + } + } + for (var _i = 0; _i < this.indexes.length; _i++) { + var indexName = this.indexes[_i]; + if (Object.prototype.hasOwnProperty.call(serializedObject, indexName)) { + addToIndex(indexName, serializedObject[indexName]); + } + } + }; + + // TODO: method for terminating the query + // TODO: query ttl. https://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html + /** + * @param {Object} opt {callback, id, selector, limit, orderBy} + */ + + + Collection.prototype.get = function get() { + var _this2 = this; + + var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + if (!opt.callback) { + return; + } + var results = 0; + var matcher = function matcher(data, id, node) { + if (!data) { + return; + } + if (opt.limit && results++ >= opt.limit) { + return; // TODO: terminate query + } + if (opt.selector) { + // TODO: deep compare selector object? + var keys = _Object$keys(opt.selector); + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + if (!Object.prototype.hasOwnProperty.call(data, key)) { + return; + } + var v1 = void 0, + v2 = void 0; + if (opt.caseSensitive === false) { + v1 = data[key].toLowerCase(); + v2 = opt.selector[key].toLowerCase(); + } else { + v1 = data[key]; + v2 = opt.selector[key]; + } + if (v1 !== v2) { + return; + } + } + } + if (opt.query) { + // TODO: use gun.get() lt / gt operators + var _keys = _Object$keys(opt.query); + for (var _i2 = 0; _i2 < _keys.length; _i2++) { + var _key = _keys[_i2]; + if (!Object.prototype.hasOwnProperty.call(data, _key)) { + return; + } + var _v = void 0, + _v2 = void 0; + if (opt.caseSensitive === false) { + _v = data[_key].toLowerCase(); + _v2 = opt.query[_key].toLowerCase(); + } else { + _v = data[_key]; + _v2 = opt.query[_key]; + } + if (_v.indexOf(_v2) !== 0) { + return; + } + } + } + if (_this2.serializer) { + opt.callback(_this2.serializer.deserialize(data, { id: id, gun: node.$ })); + } else if (_this2.class) { + opt.callback(_this2.class.deserialize(data, { id: id, gun: node.$ })); + } else { + opt.callback(data); + } + }; + + if (opt.id) { + opt.limit = 1; + this.gun.get(this.name).get('id').get(opt.id).on(matcher); + return; + } + + var indexName = 'id'; + if (opt.orderBy && this.indexes.indexOf(opt.orderBy) > -1) { + indexName = opt.orderBy; + } + + // TODO: query from indexes + this.gun.get(this.name).get(indexName).map().on(matcher); // TODO: limit .open recursion + if (this.askPeers) { + this.gun.get('trustedIndexes').on(function (val, key) { + _this2.gun.user(key).get(_this2.name).get(indexName).map().on(matcher); + }); + } + }; + + Collection.prototype.delete = function _delete() { + // gun.unset() + }; + + return Collection; + }(); + + var $JSON = _core.JSON || (_core.JSON = { stringify: JSON.stringify }); + var stringify = function stringify(it) { // eslint-disable-line no-unused-vars + return $JSON.stringify.apply($JSON, arguments); + }; + + var stringify$1 = createCommonjsModule(function (module) { + module.exports = { "default": stringify, __esModule: true }; + }); + + var _JSON$stringify = unwrapExports(stringify$1); + + // true -> String#at + // false -> String#codePointAt + var _stringAt = function (TO_STRING) { + return function (that, pos) { + var s = String(_defined(that)); + var i = _toInteger(pos); + var l = s.length; + var a, b; + if (i < 0 || i >= l) return TO_STRING ? '' : undefined; + a = s.charCodeAt(i); + return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff + ? TO_STRING ? s.charAt(i) : a + : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000; + }; + }; + + var _redefine = _hide; + + var _iterators = {}; + + var _objectDps = _descriptors ? Object.defineProperties : function defineProperties(O, Properties) { + _anObject(O); + var keys = _objectKeys(Properties); + var length = keys.length; + var i = 0; + var P; + while (length > i) _objectDp.f(O, P = keys[i++], Properties[P]); + return O; + }; + + var document$2 = _global.document; + var _html = document$2 && document$2.documentElement; + + // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) + + + + var IE_PROTO$1 = _sharedKey('IE_PROTO'); + var Empty = function () { /* empty */ }; + var PROTOTYPE$1 = 'prototype'; + + // Create object with fake `null` prototype: use iframe Object with cleared prototype + var createDict = function () { + // Thrash, waste and sodomy: IE GC bug + var iframe = _domCreate('iframe'); + var i = _enumBugKeys.length; + var lt = '<'; + var gt = '>'; + var iframeDocument; + iframe.style.display = 'none'; + _html.appendChild(iframe); + iframe.src = 'javascript:'; // eslint-disable-line no-script-url + // createDict = iframe.contentWindow.Object; + // html.removeChild(iframe); + iframeDocument = iframe.contentWindow.document; + iframeDocument.open(); + iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt); + iframeDocument.close(); + createDict = iframeDocument.F; + while (i--) delete createDict[PROTOTYPE$1][_enumBugKeys[i]]; + return createDict(); + }; + + var _objectCreate = Object.create || function create(O, Properties) { + var result; + if (O !== null) { + Empty[PROTOTYPE$1] = _anObject(O); + result = new Empty(); + Empty[PROTOTYPE$1] = null; + // add "__proto__" for Object.getPrototypeOf polyfill + result[IE_PROTO$1] = O; + } else result = createDict(); + return Properties === undefined ? result : _objectDps(result, Properties); + }; + + var _wks = createCommonjsModule(function (module) { + var store = _shared('wks'); + + var Symbol = _global.Symbol; + var USE_SYMBOL = typeof Symbol == 'function'; + + var $exports = module.exports = function (name) { + return store[name] || (store[name] = + USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : _uid)('Symbol.' + name)); + }; + + $exports.store = store; + }); + + var def = _objectDp.f; + + var TAG = _wks('toStringTag'); + + var _setToStringTag = function (it, tag, stat) { + if (it && !_has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag }); + }; + + var IteratorPrototype = {}; + + // 25.1.2.1.1 %IteratorPrototype%[@@iterator]() + _hide(IteratorPrototype, _wks('iterator'), function () { return this; }); + + var _iterCreate = function (Constructor, NAME, next) { + Constructor.prototype = _objectCreate(IteratorPrototype, { next: _propertyDesc(1, next) }); + _setToStringTag(Constructor, NAME + ' Iterator'); + }; + + // 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O) + + + var IE_PROTO$2 = _sharedKey('IE_PROTO'); + var ObjectProto = Object.prototype; + + var _objectGpo = Object.getPrototypeOf || function (O) { + O = _toObject(O); + if (_has(O, IE_PROTO$2)) return O[IE_PROTO$2]; + if (typeof O.constructor == 'function' && O instanceof O.constructor) { + return O.constructor.prototype; + } return O instanceof Object ? ObjectProto : null; + }; + + var ITERATOR = _wks('iterator'); + var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next` + var FF_ITERATOR = '@@iterator'; + var KEYS = 'keys'; + var VALUES = 'values'; + + var returnThis = function () { return this; }; + + var _iterDefine = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) { + _iterCreate(Constructor, NAME, next); + var getMethod = function (kind) { + if (!BUGGY && kind in proto) return proto[kind]; + switch (kind) { + case KEYS: return function keys() { return new Constructor(this, kind); }; + case VALUES: return function values() { return new Constructor(this, kind); }; + } return function entries() { return new Constructor(this, kind); }; + }; + var TAG = NAME + ' Iterator'; + var DEF_VALUES = DEFAULT == VALUES; + var VALUES_BUG = false; + var proto = Base.prototype; + var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT]; + var $default = $native || getMethod(DEFAULT); + var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined; + var $anyNative = NAME == 'Array' ? proto.entries || $native : $native; + var methods, key, IteratorPrototype; + // Fix native + if ($anyNative) { + IteratorPrototype = _objectGpo($anyNative.call(new Base())); + if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) { + // Set @@toStringTag to native iterators + _setToStringTag(IteratorPrototype, TAG, true); + // fix for some old engines + if (!_library && typeof IteratorPrototype[ITERATOR] != 'function') _hide(IteratorPrototype, ITERATOR, returnThis); + } + } + // fix Array#{values, @@iterator}.name in V8 / FF + if (DEF_VALUES && $native && $native.name !== VALUES) { + VALUES_BUG = true; + $default = function values() { return $native.call(this); }; + } + // Define iterator + if ((!_library || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) { + _hide(proto, ITERATOR, $default); + } + // Plug for library + _iterators[NAME] = $default; + _iterators[TAG] = returnThis; + if (DEFAULT) { + methods = { + values: DEF_VALUES ? $default : getMethod(VALUES), + keys: IS_SET ? $default : getMethod(KEYS), + entries: $entries + }; + if (FORCED) for (key in methods) { + if (!(key in proto)) _redefine(proto, key, methods[key]); + } else _export(_export.P + _export.F * (BUGGY || VALUES_BUG), NAME, methods); + } + return methods; + }; + + var $at = _stringAt(true); + + // 21.1.3.27 String.prototype[@@iterator]() + _iterDefine(String, 'String', function (iterated) { + this._t = String(iterated); // target + this._i = 0; // next index + // 21.1.5.2.1 %StringIteratorPrototype%.next() + }, function () { + var O = this._t; + var index = this._i; + var point; + if (index >= O.length) return { value: undefined, done: true }; + point = $at(O, index); + this._i += point.length; + return { value: point, done: false }; + }); + + var _iterStep = function (done, value) { + return { value: value, done: !!done }; + }; + + // 22.1.3.4 Array.prototype.entries() + // 22.1.3.13 Array.prototype.keys() + // 22.1.3.29 Array.prototype.values() + // 22.1.3.30 Array.prototype[@@iterator]() + var es6_array_iterator = _iterDefine(Array, 'Array', function (iterated, kind) { + this._t = _toIobject(iterated); // target + this._i = 0; // next index + this._k = kind; // kind + // 22.1.5.2.1 %ArrayIteratorPrototype%.next() + }, function () { + var O = this._t; + var kind = this._k; + var index = this._i++; + if (!O || index >= O.length) { + this._t = undefined; + return _iterStep(1); + } + if (kind == 'keys') return _iterStep(0, index); + if (kind == 'values') return _iterStep(0, O[index]); + return _iterStep(0, [index, O[index]]); + }, 'values'); + + // argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7) + _iterators.Arguments = _iterators.Array; + + var TO_STRING_TAG = _wks('toStringTag'); + + var DOMIterables = ('CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,' + + 'DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,' + + 'MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,' + + 'SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,' + + 'TextTrackList,TouchList').split(','); + + for (var i = 0; i < DOMIterables.length; i++) { + var NAME = DOMIterables[i]; + var Collection$1 = _global[NAME]; + var proto = Collection$1 && Collection$1.prototype; + if (proto && !proto[TO_STRING_TAG]) _hide(proto, TO_STRING_TAG, NAME); + _iterators[NAME] = _iterators.Array; + } + + // getting tag from 19.1.3.6 Object.prototype.toString() + + var TAG$1 = _wks('toStringTag'); + // ES3 wrong here + var ARG = _cof(function () { return arguments; }()) == 'Arguments'; + + // fallback for IE11 Script Access Denied error + var tryGet = function (it, key) { + try { + return it[key]; + } catch (e) { /* empty */ } + }; + + var _classof = function (it) { + var O, T, B; + return it === undefined ? 'Undefined' : it === null ? 'Null' + // @@toStringTag case + : typeof (T = tryGet(O = Object(it), TAG$1)) == 'string' ? T + // builtinTag case + : ARG ? _cof(O) + // ES3 arguments fallback + : (B = _cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B; + }; + + var _anInstance = function (it, Constructor, name, forbiddenField) { + if (!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)) { + throw TypeError(name + ': incorrect invocation!'); + } return it; + }; + + // call something on iterator step with safe closing on error + + var _iterCall = function (iterator, fn, value, entries) { + try { + return entries ? fn(_anObject(value)[0], value[1]) : fn(value); + // 7.4.6 IteratorClose(iterator, completion) + } catch (e) { + var ret = iterator['return']; + if (ret !== undefined) _anObject(ret.call(iterator)); + throw e; + } + }; + + // check on default Array iterator + + var ITERATOR$1 = _wks('iterator'); + var ArrayProto = Array.prototype; + + var _isArrayIter = function (it) { + return it !== undefined && (_iterators.Array === it || ArrayProto[ITERATOR$1] === it); + }; + + var ITERATOR$2 = _wks('iterator'); + + var core_getIteratorMethod = _core.getIteratorMethod = function (it) { + if (it != undefined) return it[ITERATOR$2] + || it['@@iterator'] + || _iterators[_classof(it)]; + }; + + var _forOf = createCommonjsModule(function (module) { + var BREAK = {}; + var RETURN = {}; + var exports = module.exports = function (iterable, entries, fn, that, ITERATOR) { + var iterFn = ITERATOR ? function () { return iterable; } : core_getIteratorMethod(iterable); + var f = _ctx(fn, that, entries ? 2 : 1); + var index = 0; + var length, step, iterator, result; + if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!'); + // fast case for arrays with default iterator + if (_isArrayIter(iterFn)) for (length = _toLength(iterable.length); length > index; index++) { + result = entries ? f(_anObject(step = iterable[index])[0], step[1]) : f(iterable[index]); + if (result === BREAK || result === RETURN) return result; + } else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) { + result = _iterCall(iterator, f, step.value, entries); + if (result === BREAK || result === RETURN) return result; + } + }; + exports.BREAK = BREAK; + exports.RETURN = RETURN; + }); + + // 7.3.20 SpeciesConstructor(O, defaultConstructor) + + + var SPECIES = _wks('species'); + var _speciesConstructor = function (O, D) { + var C = _anObject(O).constructor; + var S; + return C === undefined || (S = _anObject(C)[SPECIES]) == undefined ? D : _aFunction(S); + }; + + // fast apply, http://jsperf.lnkit.com/fast-apply/5 + var _invoke = function (fn, args, that) { + var un = that === undefined; + switch (args.length) { + case 0: return un ? fn() + : fn.call(that); + case 1: return un ? fn(args[0]) + : fn.call(that, args[0]); + case 2: return un ? fn(args[0], args[1]) + : fn.call(that, args[0], args[1]); + case 3: return un ? fn(args[0], args[1], args[2]) + : fn.call(that, args[0], args[1], args[2]); + case 4: return un ? fn(args[0], args[1], args[2], args[3]) + : fn.call(that, args[0], args[1], args[2], args[3]); + } return fn.apply(that, args); + }; + + var process = _global.process; + var setTask = _global.setImmediate; + var clearTask = _global.clearImmediate; + var MessageChannel = _global.MessageChannel; + var Dispatch = _global.Dispatch; + var counter = 0; + var queue = {}; + var ONREADYSTATECHANGE = 'onreadystatechange'; + var defer, channel, port; + var run = function () { + var id = +this; + // eslint-disable-next-line no-prototype-builtins + if (queue.hasOwnProperty(id)) { + var fn = queue[id]; + delete queue[id]; + fn(); + } + }; + var listener = function (event) { + run.call(event.data); + }; + // Node.js 0.9+ & IE10+ has setImmediate, otherwise: + if (!setTask || !clearTask) { + setTask = function setImmediate(fn) { + var args = []; + var i = 1; + while (arguments.length > i) args.push(arguments[i++]); + queue[++counter] = function () { + // eslint-disable-next-line no-new-func + _invoke(typeof fn == 'function' ? fn : Function(fn), args); + }; + defer(counter); + return counter; + }; + clearTask = function clearImmediate(id) { + delete queue[id]; + }; + // Node.js 0.8- + if (_cof(process) == 'process') { + defer = function (id) { + process.nextTick(_ctx(run, id, 1)); + }; + // Sphere (JS game engine) Dispatch API + } else if (Dispatch && Dispatch.now) { + defer = function (id) { + Dispatch.now(_ctx(run, id, 1)); + }; + // Browsers with MessageChannel, includes WebWorkers + } else if (MessageChannel) { + channel = new MessageChannel(); + port = channel.port2; + channel.port1.onmessage = listener; + defer = _ctx(port.postMessage, port, 1); + // Browsers with postMessage, skip WebWorkers + // IE8 has postMessage, but it's sync & typeof its postMessage is 'object' + } else if (_global.addEventListener && typeof postMessage == 'function' && !_global.importScripts) { + defer = function (id) { + _global.postMessage(id + '', '*'); + }; + _global.addEventListener('message', listener, false); + // IE8- + } else if (ONREADYSTATECHANGE in _domCreate('script')) { + defer = function (id) { + _html.appendChild(_domCreate('script'))[ONREADYSTATECHANGE] = function () { + _html.removeChild(this); + run.call(id); + }; + }; + // Rest old browsers + } else { + defer = function (id) { + setTimeout(_ctx(run, id, 1), 0); + }; + } + } + var _task = { + set: setTask, + clear: clearTask + }; + + var macrotask = _task.set; + var Observer = _global.MutationObserver || _global.WebKitMutationObserver; + var process$1 = _global.process; + var Promise$1 = _global.Promise; + var isNode = _cof(process$1) == 'process'; + + var _microtask = function () { + var head, last, notify; + + var flush = function () { + var parent, fn; + if (isNode && (parent = process$1.domain)) parent.exit(); + while (head) { + fn = head.fn; + head = head.next; + try { + fn(); + } catch (e) { + if (head) notify(); + else last = undefined; + throw e; + } + } last = undefined; + if (parent) parent.enter(); + }; + + // Node.js + if (isNode) { + notify = function () { + process$1.nextTick(flush); + }; + // browsers with MutationObserver, except iOS Safari - https://github.com/zloirock/core-js/issues/339 + } else if (Observer && !(_global.navigator && _global.navigator.standalone)) { + var toggle = true; + var node = document.createTextNode(''); + new Observer(flush).observe(node, { characterData: true }); // eslint-disable-line no-new + notify = function () { + node.data = toggle = !toggle; + }; + // environments with maybe non-completely correct, but existent Promise + } else if (Promise$1 && Promise$1.resolve) { + // Promise.resolve without an argument throws an error in LG WebOS 2 + var promise = Promise$1.resolve(undefined); + notify = function () { + promise.then(flush); + }; + // for other environments - macrotask based on: + // - setImmediate + // - MessageChannel + // - window.postMessag + // - onreadystatechange + // - setTimeout + } else { + notify = function () { + // strange IE + webpack dev server bug - use .call(global) + macrotask.call(_global, flush); + }; + } + + return function (fn) { + var task = { fn: fn, next: undefined }; + if (last) last.next = task; + if (!head) { + head = task; + notify(); + } last = task; + }; + }; + + // 25.4.1.5 NewPromiseCapability(C) + + + function PromiseCapability(C) { + var resolve, reject; + this.promise = new C(function ($$resolve, $$reject) { + if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor'); + resolve = $$resolve; + reject = $$reject; + }); + this.resolve = _aFunction(resolve); + this.reject = _aFunction(reject); + } + + var f$1 = function (C) { + return new PromiseCapability(C); + }; + + var _newPromiseCapability = { + f: f$1 + }; + + var _perform = function (exec) { + try { + return { e: false, v: exec() }; + } catch (e) { + return { e: true, v: e }; + } + }; + + var navigator = _global.navigator; + + var _userAgent = navigator && navigator.userAgent || ''; + + var _promiseResolve = function (C, x) { + _anObject(C); + if (_isObject(x) && x.constructor === C) return x; + var promiseCapability = _newPromiseCapability.f(C); + var resolve = promiseCapability.resolve; + resolve(x); + return promiseCapability.promise; + }; + + var _redefineAll = function (target, src, safe) { + for (var key in src) { + if (safe && target[key]) target[key] = src[key]; + else _hide(target, key, src[key]); + } return target; + }; + + var SPECIES$1 = _wks('species'); + + var _setSpecies = function (KEY) { + var C = typeof _core[KEY] == 'function' ? _core[KEY] : _global[KEY]; + if (_descriptors && C && !C[SPECIES$1]) _objectDp.f(C, SPECIES$1, { + configurable: true, + get: function () { return this; } + }); + }; + + var ITERATOR$3 = _wks('iterator'); + var SAFE_CLOSING = false; + + try { + var riter = [7][ITERATOR$3](); + riter['return'] = function () { SAFE_CLOSING = true; }; + } catch (e) { /* empty */ } + + var _iterDetect = function (exec, skipClosing) { + if (!skipClosing && !SAFE_CLOSING) return false; + var safe = false; + try { + var arr = [7]; + var iter = arr[ITERATOR$3](); + iter.next = function () { return { done: safe = true }; }; + arr[ITERATOR$3] = function () { return iter; }; + exec(arr); + } catch (e) { /* empty */ } + return safe; + }; + + var task = _task.set; + var microtask = _microtask(); + + + + + var PROMISE = 'Promise'; + var TypeError$1 = _global.TypeError; + var process$2 = _global.process; + var versions = process$2 && process$2.versions; + var v8 = versions && versions.v8 || ''; + var $Promise = _global[PROMISE]; + var isNode$1 = _classof(process$2) == 'process'; + var empty = function () { /* empty */ }; + var Internal, newGenericPromiseCapability, OwnPromiseCapability, Wrapper; + var newPromiseCapability = newGenericPromiseCapability = _newPromiseCapability.f; + + var USE_NATIVE = !!function () { + try { + // correct subclassing with @@species support + var promise = $Promise.resolve(1); + var FakePromise = (promise.constructor = {})[_wks('species')] = function (exec) { + exec(empty, empty); + }; + // unhandled rejections tracking support, NodeJS Promise without it fails @@species test + return (isNode$1 || typeof PromiseRejectionEvent == 'function') + && promise.then(empty) instanceof FakePromise + // v8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables + // https://bugs.chromium.org/p/chromium/issues/detail?id=830565 + // we can't detect it synchronously, so just check versions + && v8.indexOf('6.6') !== 0 + && _userAgent.indexOf('Chrome/66') === -1; + } catch (e) { /* empty */ } + }(); + + // helpers + var isThenable = function (it) { + var then; + return _isObject(it) && typeof (then = it.then) == 'function' ? then : false; + }; + var notify = function (promise, isReject) { + if (promise._n) return; + promise._n = true; + var chain = promise._c; + microtask(function () { + var value = promise._v; + var ok = promise._s == 1; + var i = 0; + var run = function (reaction) { + var handler = ok ? reaction.ok : reaction.fail; + var resolve = reaction.resolve; + var reject = reaction.reject; + var domain = reaction.domain; + var result, then, exited; + try { + if (handler) { + if (!ok) { + if (promise._h == 2) onHandleUnhandled(promise); + promise._h = 1; + } + if (handler === true) result = value; + else { + if (domain) domain.enter(); + result = handler(value); // may throw + if (domain) { + domain.exit(); + exited = true; + } + } + if (result === reaction.promise) { + reject(TypeError$1('Promise-chain cycle')); + } else if (then = isThenable(result)) { + then.call(result, resolve, reject); + } else resolve(result); + } else reject(value); + } catch (e) { + if (domain && !exited) domain.exit(); + reject(e); + } + }; + while (chain.length > i) run(chain[i++]); // variable length - can't use forEach + promise._c = []; + promise._n = false; + if (isReject && !promise._h) onUnhandled(promise); + }); + }; + var onUnhandled = function (promise) { + task.call(_global, function () { + var value = promise._v; + var unhandled = isUnhandled(promise); + var result, handler, console; + if (unhandled) { + result = _perform(function () { + if (isNode$1) { + process$2.emit('unhandledRejection', value, promise); + } else if (handler = _global.onunhandledrejection) { + handler({ promise: promise, reason: value }); + } else if ((console = _global.console) && console.error) { + console.error('Unhandled promise rejection', value); + } + }); + // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should + promise._h = isNode$1 || isUnhandled(promise) ? 2 : 1; + } promise._a = undefined; + if (unhandled && result.e) throw result.v; + }); + }; + var isUnhandled = function (promise) { + return promise._h !== 1 && (promise._a || promise._c).length === 0; + }; + var onHandleUnhandled = function (promise) { + task.call(_global, function () { + var handler; + if (isNode$1) { + process$2.emit('rejectionHandled', promise); + } else if (handler = _global.onrejectionhandled) { + handler({ promise: promise, reason: promise._v }); + } + }); + }; + var $reject = function (value) { + var promise = this; + if (promise._d) return; + promise._d = true; + promise = promise._w || promise; // unwrap + promise._v = value; + promise._s = 2; + if (!promise._a) promise._a = promise._c.slice(); + notify(promise, true); + }; + var $resolve = function (value) { + var promise = this; + var then; + if (promise._d) return; + promise._d = true; + promise = promise._w || promise; // unwrap + try { + if (promise === value) throw TypeError$1("Promise can't be resolved itself"); + if (then = isThenable(value)) { + microtask(function () { + var wrapper = { _w: promise, _d: false }; // wrap + try { + then.call(value, _ctx($resolve, wrapper, 1), _ctx($reject, wrapper, 1)); + } catch (e) { + $reject.call(wrapper, e); + } + }); + } else { + promise._v = value; + promise._s = 1; + notify(promise, false); + } + } catch (e) { + $reject.call({ _w: promise, _d: false }, e); // wrap + } + }; + + // constructor polyfill + if (!USE_NATIVE) { + // 25.4.3.1 Promise(executor) + $Promise = function Promise(executor) { + _anInstance(this, $Promise, PROMISE, '_h'); + _aFunction(executor); + Internal.call(this); + try { + executor(_ctx($resolve, this, 1), _ctx($reject, this, 1)); + } catch (err) { + $reject.call(this, err); + } + }; + // eslint-disable-next-line no-unused-vars + Internal = function Promise(executor) { + this._c = []; // <- awaiting reactions + this._a = undefined; // <- checked in isUnhandled reactions + this._s = 0; // <- state + this._d = false; // <- done + this._v = undefined; // <- value + this._h = 0; // <- rejection state, 0 - default, 1 - handled, 2 - unhandled + this._n = false; // <- notify + }; + Internal.prototype = _redefineAll($Promise.prototype, { + // 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected) + then: function then(onFulfilled, onRejected) { + var reaction = newPromiseCapability(_speciesConstructor(this, $Promise)); + reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true; + reaction.fail = typeof onRejected == 'function' && onRejected; + reaction.domain = isNode$1 ? process$2.domain : undefined; + this._c.push(reaction); + if (this._a) this._a.push(reaction); + if (this._s) notify(this, false); + return reaction.promise; + }, + // 25.4.5.1 Promise.prototype.catch(onRejected) + 'catch': function (onRejected) { + return this.then(undefined, onRejected); + } + }); + OwnPromiseCapability = function () { + var promise = new Internal(); + this.promise = promise; + this.resolve = _ctx($resolve, promise, 1); + this.reject = _ctx($reject, promise, 1); + }; + _newPromiseCapability.f = newPromiseCapability = function (C) { + return C === $Promise || C === Wrapper + ? new OwnPromiseCapability(C) + : newGenericPromiseCapability(C); + }; + } + + _export(_export.G + _export.W + _export.F * !USE_NATIVE, { Promise: $Promise }); + _setToStringTag($Promise, PROMISE); + _setSpecies(PROMISE); + Wrapper = _core[PROMISE]; + + // statics + _export(_export.S + _export.F * !USE_NATIVE, PROMISE, { + // 25.4.4.5 Promise.reject(r) + reject: function reject(r) { + var capability = newPromiseCapability(this); + var $$reject = capability.reject; + $$reject(r); + return capability.promise; + } + }); + _export(_export.S + _export.F * (_library || !USE_NATIVE), PROMISE, { + // 25.4.4.6 Promise.resolve(x) + resolve: function resolve(x) { + return _promiseResolve(_library && this === Wrapper ? $Promise : this, x); + } + }); + _export(_export.S + _export.F * !(USE_NATIVE && _iterDetect(function (iter) { + $Promise.all(iter)['catch'](empty); + })), PROMISE, { + // 25.4.4.1 Promise.all(iterable) + all: function all(iterable) { + var C = this; + var capability = newPromiseCapability(C); + var resolve = capability.resolve; + var reject = capability.reject; + var result = _perform(function () { + var values = []; + var index = 0; + var remaining = 1; + _forOf(iterable, false, function (promise) { + var $index = index++; + var alreadyCalled = false; + values.push(undefined); + remaining++; + C.resolve(promise).then(function (value) { + if (alreadyCalled) return; + alreadyCalled = true; + values[$index] = value; + --remaining || resolve(values); + }, reject); + }); + --remaining || resolve(values); + }); + if (result.e) reject(result.v); + return capability.promise; + }, + // 25.4.4.4 Promise.race(iterable) + race: function race(iterable) { + var C = this; + var capability = newPromiseCapability(C); + var reject = capability.reject; + var result = _perform(function () { + _forOf(iterable, false, function (promise) { + C.resolve(promise).then(capability.resolve, reject); + }); + }); + if (result.e) reject(result.v); + return capability.promise; + } + }); + + _export(_export.P + _export.R, 'Promise', { 'finally': function (onFinally) { + var C = _speciesConstructor(this, _core.Promise || _global.Promise); + var isFunction = typeof onFinally == 'function'; + return this.then( + isFunction ? function (x) { + return _promiseResolve(C, onFinally()).then(function () { return x; }); + } : onFinally, + isFunction ? function (e) { + return _promiseResolve(C, onFinally()).then(function () { throw e; }); + } : onFinally + ); + } }); + + // https://github.com/tc39/proposal-promise-try + + + + + _export(_export.S, 'Promise', { 'try': function (callbackfn) { + var promiseCapability = _newPromiseCapability.f(this); + var result = _perform(callbackfn); + (result.e ? promiseCapability.reject : promiseCapability.resolve)(result.v); + return promiseCapability.promise; + } }); + + var promise = _core.Promise; + + var promise$1 = createCommonjsModule(function (module) { + module.exports = { "default": promise, __esModule: true }; + }); + + var _Promise = unwrapExports(promise$1); + + var core_getIterator = _core.getIterator = function (it) { + var iterFn = core_getIteratorMethod(it); + if (typeof iterFn != 'function') throw TypeError(it + ' is not iterable!'); + return _anObject(iterFn.call(it)); + }; + + var getIterator = core_getIterator; + + var getIterator$1 = createCommonjsModule(function (module) { + module.exports = { "default": getIterator, __esModule: true }; + }); + + var _getIterator = unwrapExports(getIterator$1); + + var f$2 = _wks; + + var _wksExt = { + f: f$2 + }; + + var iterator = _wksExt.f('iterator'); + + var iterator$1 = createCommonjsModule(function (module) { + module.exports = { "default": iterator, __esModule: true }; + }); + + var _Symbol$iterator = unwrapExports(iterator$1); + + var _meta = createCommonjsModule(function (module) { + var META = _uid('meta'); + + + var setDesc = _objectDp.f; + var id = 0; + var isExtensible = Object.isExtensible || function () { + return true; + }; + var FREEZE = !_fails(function () { + return isExtensible(Object.preventExtensions({})); + }); + var setMeta = function (it) { + setDesc(it, META, { value: { + i: 'O' + ++id, // object ID + w: {} // weak collections IDs + } }); + }; + var fastKey = function (it, create) { + // return primitive with prefix + if (!_isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it; + if (!_has(it, META)) { + // can't set metadata to uncaught frozen object + if (!isExtensible(it)) return 'F'; + // not necessary to add metadata + if (!create) return 'E'; + // add missing metadata + setMeta(it); + // return object ID + } return it[META].i; + }; + var getWeak = function (it, create) { + if (!_has(it, META)) { + // can't set metadata to uncaught frozen object + if (!isExtensible(it)) return true; + // not necessary to add metadata + if (!create) return false; + // add missing metadata + setMeta(it); + // return hash weak collections IDs + } return it[META].w; + }; + // add metadata on freeze-family methods calling + var onFreeze = function (it) { + if (FREEZE && meta.NEED && isExtensible(it) && !_has(it, META)) setMeta(it); + return it; + }; + var meta = module.exports = { + KEY: META, + NEED: false, + fastKey: fastKey, + getWeak: getWeak, + onFreeze: onFreeze + }; + }); + var _meta_1 = _meta.KEY; + var _meta_2 = _meta.NEED; + var _meta_3 = _meta.fastKey; + var _meta_4 = _meta.getWeak; + var _meta_5 = _meta.onFreeze; + + var defineProperty = _objectDp.f; + var _wksDefine = function (name) { + var $Symbol = _core.Symbol || (_core.Symbol = {}); + if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty($Symbol, name, { value: _wksExt.f(name) }); + }; + + var f$3 = Object.getOwnPropertySymbols; + + var _objectGops = { + f: f$3 + }; + + var f$4 = {}.propertyIsEnumerable; + + var _objectPie = { + f: f$4 + }; + + // all enumerable object keys, includes symbols + + + + var _enumKeys = function (it) { + var result = _objectKeys(it); + var getSymbols = _objectGops.f; + if (getSymbols) { + var symbols = getSymbols(it); + var isEnum = _objectPie.f; + var i = 0; + var key; + while (symbols.length > i) if (isEnum.call(it, key = symbols[i++])) result.push(key); + } return result; + }; + + // 7.2.2 IsArray(argument) + + var _isArray = Array.isArray || function isArray(arg) { + return _cof(arg) == 'Array'; + }; + + // 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O) + + var hiddenKeys = _enumBugKeys.concat('length', 'prototype'); + + var f$5 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { + return _objectKeysInternal(O, hiddenKeys); + }; + + var _objectGopn = { + f: f$5 + }; + + // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window + + var gOPN = _objectGopn.f; + var toString$1 = {}.toString; + + var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames + ? Object.getOwnPropertyNames(window) : []; + + var getWindowNames = function (it) { + try { + return gOPN(it); + } catch (e) { + return windowNames.slice(); + } + }; + + var f$6 = function getOwnPropertyNames(it) { + return windowNames && toString$1.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(_toIobject(it)); + }; + + var _objectGopnExt = { + f: f$6 + }; + + var gOPD = Object.getOwnPropertyDescriptor; + + var f$7 = _descriptors ? gOPD : function getOwnPropertyDescriptor(O, P) { + O = _toIobject(O); + P = _toPrimitive(P, true); + if (_ie8DomDefine) try { + return gOPD(O, P); + } catch (e) { /* empty */ } + if (_has(O, P)) return _propertyDesc(!_objectPie.f.call(O, P), O[P]); + }; + + var _objectGopd = { + f: f$7 + }; + + // ECMAScript 6 symbols shim + + + + + + var META = _meta.KEY; + + + + + + + + + + + + + + + + + + + + + + var gOPD$1 = _objectGopd.f; + var dP$1 = _objectDp.f; + var gOPN$1 = _objectGopnExt.f; + var $Symbol = _global.Symbol; + var $JSON$1 = _global.JSON; + var _stringify = $JSON$1 && $JSON$1.stringify; + var PROTOTYPE$2 = 'prototype'; + var HIDDEN = _wks('_hidden'); + var TO_PRIMITIVE = _wks('toPrimitive'); + var isEnum = {}.propertyIsEnumerable; + var SymbolRegistry = _shared('symbol-registry'); + var AllSymbols = _shared('symbols'); + var OPSymbols = _shared('op-symbols'); + var ObjectProto$1 = Object[PROTOTYPE$2]; + var USE_NATIVE$1 = typeof $Symbol == 'function' && !!_objectGops.f; + var QObject = _global.QObject; + // Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173 + var setter = !QObject || !QObject[PROTOTYPE$2] || !QObject[PROTOTYPE$2].findChild; + + // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687 + var setSymbolDesc = _descriptors && _fails(function () { + return _objectCreate(dP$1({}, 'a', { + get: function () { return dP$1(this, 'a', { value: 7 }).a; } + })).a != 7; + }) ? function (it, key, D) { + var protoDesc = gOPD$1(ObjectProto$1, key); + if (protoDesc) delete ObjectProto$1[key]; + dP$1(it, key, D); + if (protoDesc && it !== ObjectProto$1) dP$1(ObjectProto$1, key, protoDesc); + } : dP$1; + + var wrap = function (tag) { + var sym = AllSymbols[tag] = _objectCreate($Symbol[PROTOTYPE$2]); + sym._k = tag; + return sym; + }; + + var isSymbol = USE_NATIVE$1 && typeof $Symbol.iterator == 'symbol' ? function (it) { + return typeof it == 'symbol'; + } : function (it) { + return it instanceof $Symbol; + }; + + var $defineProperty = function defineProperty(it, key, D) { + if (it === ObjectProto$1) $defineProperty(OPSymbols, key, D); + _anObject(it); + key = _toPrimitive(key, true); + _anObject(D); + if (_has(AllSymbols, key)) { + if (!D.enumerable) { + if (!_has(it, HIDDEN)) dP$1(it, HIDDEN, _propertyDesc(1, {})); + it[HIDDEN][key] = true; + } else { + if (_has(it, HIDDEN) && it[HIDDEN][key]) it[HIDDEN][key] = false; + D = _objectCreate(D, { enumerable: _propertyDesc(0, false) }); + } return setSymbolDesc(it, key, D); + } return dP$1(it, key, D); + }; + var $defineProperties = function defineProperties(it, P) { + _anObject(it); + var keys = _enumKeys(P = _toIobject(P)); + var i = 0; + var l = keys.length; + var key; + while (l > i) $defineProperty(it, key = keys[i++], P[key]); + return it; + }; + var $create = function create(it, P) { + return P === undefined ? _objectCreate(it) : $defineProperties(_objectCreate(it), P); + }; + var $propertyIsEnumerable = function propertyIsEnumerable(key) { + var E = isEnum.call(this, key = _toPrimitive(key, true)); + if (this === ObjectProto$1 && _has(AllSymbols, key) && !_has(OPSymbols, key)) return false; + return E || !_has(this, key) || !_has(AllSymbols, key) || _has(this, HIDDEN) && this[HIDDEN][key] ? E : true; + }; + var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key) { + it = _toIobject(it); + key = _toPrimitive(key, true); + if (it === ObjectProto$1 && _has(AllSymbols, key) && !_has(OPSymbols, key)) return; + var D = gOPD$1(it, key); + if (D && _has(AllSymbols, key) && !(_has(it, HIDDEN) && it[HIDDEN][key])) D.enumerable = true; + return D; + }; + var $getOwnPropertyNames = function getOwnPropertyNames(it) { + var names = gOPN$1(_toIobject(it)); + var result = []; + var i = 0; + var key; + while (names.length > i) { + if (!_has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META) result.push(key); + } return result; + }; + var $getOwnPropertySymbols = function getOwnPropertySymbols(it) { + var IS_OP = it === ObjectProto$1; + var names = gOPN$1(IS_OP ? OPSymbols : _toIobject(it)); + var result = []; + var i = 0; + var key; + while (names.length > i) { + if (_has(AllSymbols, key = names[i++]) && (IS_OP ? _has(ObjectProto$1, key) : true)) result.push(AllSymbols[key]); + } return result; + }; + + // 19.4.1.1 Symbol([description]) + if (!USE_NATIVE$1) { + $Symbol = function Symbol() { + if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor!'); + var tag = _uid(arguments.length > 0 ? arguments[0] : undefined); + var $set = function (value) { + if (this === ObjectProto$1) $set.call(OPSymbols, value); + if (_has(this, HIDDEN) && _has(this[HIDDEN], tag)) this[HIDDEN][tag] = false; + setSymbolDesc(this, tag, _propertyDesc(1, value)); + }; + if (_descriptors && setter) setSymbolDesc(ObjectProto$1, tag, { configurable: true, set: $set }); + return wrap(tag); + }; + _redefine($Symbol[PROTOTYPE$2], 'toString', function toString() { + return this._k; + }); + + _objectGopd.f = $getOwnPropertyDescriptor; + _objectDp.f = $defineProperty; + _objectGopn.f = _objectGopnExt.f = $getOwnPropertyNames; + _objectPie.f = $propertyIsEnumerable; + _objectGops.f = $getOwnPropertySymbols; + + if (_descriptors && !_library) { + _redefine(ObjectProto$1, 'propertyIsEnumerable', $propertyIsEnumerable, true); + } + + _wksExt.f = function (name) { + return wrap(_wks(name)); + }; + } + + _export(_export.G + _export.W + _export.F * !USE_NATIVE$1, { Symbol: $Symbol }); + + for (var es6Symbols = ( + // 19.4.2.2, 19.4.2.3, 19.4.2.4, 19.4.2.6, 19.4.2.8, 19.4.2.9, 19.4.2.10, 19.4.2.11, 19.4.2.12, 19.4.2.13, 19.4.2.14 + 'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables' + ).split(','), j = 0; es6Symbols.length > j;)_wks(es6Symbols[j++]); + + for (var wellKnownSymbols = _objectKeys(_wks.store), k = 0; wellKnownSymbols.length > k;) _wksDefine(wellKnownSymbols[k++]); + + _export(_export.S + _export.F * !USE_NATIVE$1, 'Symbol', { + // 19.4.2.1 Symbol.for(key) + 'for': function (key) { + return _has(SymbolRegistry, key += '') + ? SymbolRegistry[key] + : SymbolRegistry[key] = $Symbol(key); + }, + // 19.4.2.5 Symbol.keyFor(sym) + keyFor: function keyFor(sym) { + if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol!'); + for (var key in SymbolRegistry) if (SymbolRegistry[key] === sym) return key; + }, + useSetter: function () { setter = true; }, + useSimple: function () { setter = false; } + }); + + _export(_export.S + _export.F * !USE_NATIVE$1, 'Object', { + // 19.1.2.2 Object.create(O [, Properties]) + create: $create, + // 19.1.2.4 Object.defineProperty(O, P, Attributes) + defineProperty: $defineProperty, + // 19.1.2.3 Object.defineProperties(O, Properties) + defineProperties: $defineProperties, + // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P) + getOwnPropertyDescriptor: $getOwnPropertyDescriptor, + // 19.1.2.7 Object.getOwnPropertyNames(O) + getOwnPropertyNames: $getOwnPropertyNames, + // 19.1.2.8 Object.getOwnPropertySymbols(O) + getOwnPropertySymbols: $getOwnPropertySymbols + }); + + // Chrome 38 and 39 `Object.getOwnPropertySymbols` fails on primitives + // https://bugs.chromium.org/p/v8/issues/detail?id=3443 + var FAILS_ON_PRIMITIVES = _fails(function () { _objectGops.f(1); }); + + _export(_export.S + _export.F * FAILS_ON_PRIMITIVES, 'Object', { + getOwnPropertySymbols: function getOwnPropertySymbols(it) { + return _objectGops.f(_toObject(it)); + } + }); + + // 24.3.2 JSON.stringify(value [, replacer [, space]]) + $JSON$1 && _export(_export.S + _export.F * (!USE_NATIVE$1 || _fails(function () { + var S = $Symbol(); + // MS Edge converts symbol values to JSON as {} + // WebKit converts symbol values to JSON as null + // V8 throws on boxed symbols + return _stringify([S]) != '[null]' || _stringify({ a: S }) != '{}' || _stringify(Object(S)) != '{}'; + })), 'JSON', { + stringify: function stringify(it) { + var args = [it]; + var i = 1; + var replacer, $replacer; + while (arguments.length > i) args.push(arguments[i++]); + $replacer = replacer = args[1]; + if (!_isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined + if (!_isArray(replacer)) replacer = function (key, value) { + if (typeof $replacer == 'function') value = $replacer.call(this, key, value); + if (!isSymbol(value)) return value; + }; + args[1] = replacer; + return _stringify.apply($JSON$1, args); + } + }); + + // 19.4.3.4 Symbol.prototype[@@toPrimitive](hint) + $Symbol[PROTOTYPE$2][TO_PRIMITIVE] || _hide($Symbol[PROTOTYPE$2], TO_PRIMITIVE, $Symbol[PROTOTYPE$2].valueOf); + // 19.4.3.5 Symbol.prototype[@@toStringTag] + _setToStringTag($Symbol, 'Symbol'); + // 20.2.1.9 Math[@@toStringTag] + _setToStringTag(Math, 'Math', true); + // 24.3.3 JSON[@@toStringTag] + _setToStringTag(_global.JSON, 'JSON', true); + + _wksDefine('asyncIterator'); + + _wksDefine('observable'); + + var symbol = _core.Symbol; + + var symbol$1 = createCommonjsModule(function (module) { + module.exports = { "default": symbol, __esModule: true }; + }); + + unwrapExports(symbol$1); + + var _typeof_1 = createCommonjsModule(function (module, exports) { + + exports.__esModule = true; + + + + var _iterator2 = _interopRequireDefault(iterator$1); + + + + var _symbol2 = _interopRequireDefault(symbol$1); + + var _typeof = typeof _symbol2.default === "function" && typeof _iterator2.default === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj; }; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + + exports.default = typeof _symbol2.default === "function" && _typeof(_iterator2.default) === "symbol" ? function (obj) { + return typeof obj === "undefined" ? "undefined" : _typeof(obj); + } : function (obj) { + return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof(obj); + }; + }); + + var _typeof = unwrapExports(_typeof_1); + + var runtime = createCommonjsModule(function (module) { + /** + * Copyright (c) 2014-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + + !(function(global) { + + var Op = Object.prototype; + var hasOwn = Op.hasOwnProperty; + var undefined; // More compressible than void 0. + var $Symbol = typeof Symbol === "function" ? Symbol : {}; + var iteratorSymbol = $Symbol.iterator || "@@iterator"; + var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; + var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; + var runtime = global.regeneratorRuntime; + if (runtime) { + { + // If regeneratorRuntime is defined globally and we're in a module, + // make the exports object identical to regeneratorRuntime. + module.exports = runtime; + } + // Don't bother evaluating the rest of this file if the runtime was + // already defined globally. + return; + } + + // Define the runtime globally (as expected by generated code) as either + // module.exports (if we're in a module) or a new, empty object. + runtime = global.regeneratorRuntime = module.exports; + + function wrap(innerFn, outerFn, self, tryLocsList) { + // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. + var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; + var generator = Object.create(protoGenerator.prototype); + var context = new Context(tryLocsList || []); + + // The ._invoke method unifies the implementations of the .next, + // .throw, and .return methods. + generator._invoke = makeInvokeMethod(innerFn, self, context); + + return generator; + } + runtime.wrap = wrap; + + // Try/catch helper to minimize deoptimizations. Returns a completion + // record like context.tryEntries[i].completion. This interface could + // have been (and was previously) designed to take a closure to be + // invoked without arguments, but in all the cases we care about we + // already have an existing method we want to call, so there's no need + // to create a new function object. We can even get away with assuming + // the method takes exactly one argument, since that happens to be true + // in every case, so we don't have to touch the arguments object. The + // only additional allocation required is the completion record, which + // has a stable shape and so hopefully should be cheap to allocate. + function tryCatch(fn, obj, arg) { + try { + return { type: "normal", arg: fn.call(obj, arg) }; + } catch (err) { + return { type: "throw", arg: err }; + } + } + + var GenStateSuspendedStart = "suspendedStart"; + var GenStateSuspendedYield = "suspendedYield"; + var GenStateExecuting = "executing"; + var GenStateCompleted = "completed"; + + // Returning this object from the innerFn has the same effect as + // breaking out of the dispatch switch statement. + var ContinueSentinel = {}; + + // Dummy constructor functions that we use as the .constructor and + // .constructor.prototype properties for functions that return Generator + // objects. For full spec compliance, you may wish to configure your + // minifier not to mangle the names of these two functions. + function Generator() {} + function GeneratorFunction() {} + function GeneratorFunctionPrototype() {} + + // This is a polyfill for %IteratorPrototype% for environments that + // don't natively support it. + var IteratorPrototype = {}; + IteratorPrototype[iteratorSymbol] = function () { + return this; + }; + + var getProto = Object.getPrototypeOf; + var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); + if (NativeIteratorPrototype && + NativeIteratorPrototype !== Op && + hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { + // This environment has a native %IteratorPrototype%; use it instead + // of the polyfill. + IteratorPrototype = NativeIteratorPrototype; + } + + var Gp = GeneratorFunctionPrototype.prototype = + Generator.prototype = Object.create(IteratorPrototype); + GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; + GeneratorFunctionPrototype.constructor = GeneratorFunction; + GeneratorFunctionPrototype[toStringTagSymbol] = + GeneratorFunction.displayName = "GeneratorFunction"; + + // Helper for defining the .next, .throw, and .return methods of the + // Iterator interface in terms of a single ._invoke method. + function defineIteratorMethods(prototype) { + ["next", "throw", "return"].forEach(function(method) { + prototype[method] = function(arg) { + return this._invoke(method, arg); + }; + }); + } + + runtime.isGeneratorFunction = function(genFun) { + var ctor = typeof genFun === "function" && genFun.constructor; + return ctor + ? ctor === GeneratorFunction || + // For the native GeneratorFunction constructor, the best we can + // do is to check its .name property. + (ctor.displayName || ctor.name) === "GeneratorFunction" + : false; + }; + + runtime.mark = function(genFun) { + if (Object.setPrototypeOf) { + Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); + } else { + genFun.__proto__ = GeneratorFunctionPrototype; + if (!(toStringTagSymbol in genFun)) { + genFun[toStringTagSymbol] = "GeneratorFunction"; + } + } + genFun.prototype = Object.create(Gp); + return genFun; + }; + + // Within the body of any async function, `await x` is transformed to + // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test + // `hasOwn.call(value, "__await")` to determine if the yielded value is + // meant to be awaited. + runtime.awrap = function(arg) { + return { __await: arg }; + }; + + function AsyncIterator(generator) { + function invoke(method, arg, resolve, reject) { + var record = tryCatch(generator[method], generator, arg); + if (record.type === "throw") { + reject(record.arg); + } else { + var result = record.arg; + var value = result.value; + if (value && + typeof value === "object" && + hasOwn.call(value, "__await")) { + return Promise.resolve(value.__await).then(function(value) { + invoke("next", value, resolve, reject); + }, function(err) { + invoke("throw", err, resolve, reject); + }); + } + + return Promise.resolve(value).then(function(unwrapped) { + // When a yielded Promise is resolved, its final value becomes + // the .value of the Promise<{value,done}> result for the + // current iteration. If the Promise is rejected, however, the + // result for this iteration will be rejected with the same + // reason. Note that rejections of yielded Promises are not + // thrown back into the generator function, as is the case + // when an awaited Promise is rejected. This difference in + // behavior between yield and await is important, because it + // allows the consumer to decide what to do with the yielded + // rejection (swallow it and continue, manually .throw it back + // into the generator, abandon iteration, whatever). With + // await, by contrast, there is no opportunity to examine the + // rejection reason outside the generator function, so the + // only option is to throw it from the await expression, and + // let the generator function handle the exception. + result.value = unwrapped; + resolve(result); + }, reject); + } + } + + var previousPromise; + + function enqueue(method, arg) { + function callInvokeWithMethodAndArg() { + return new Promise(function(resolve, reject) { + invoke(method, arg, resolve, reject); + }); + } + + return previousPromise = + // If enqueue has been called before, then we want to wait until + // all previous Promises have been resolved before calling invoke, + // so that results are always delivered in the correct order. If + // enqueue has not been called before, then it is important to + // call invoke immediately, without waiting on a callback to fire, + // so that the async generator function has the opportunity to do + // any necessary setup in a predictable way. This predictability + // is why the Promise constructor synchronously invokes its + // executor callback, and why async functions synchronously + // execute code before the first await. Since we implement simple + // async functions in terms of async generators, it is especially + // important to get this right, even though it requires care. + previousPromise ? previousPromise.then( + callInvokeWithMethodAndArg, + // Avoid propagating failures to Promises returned by later + // invocations of the iterator. + callInvokeWithMethodAndArg + ) : callInvokeWithMethodAndArg(); + } + + // Define the unified helper method that is used to implement .next, + // .throw, and .return (see defineIteratorMethods). + this._invoke = enqueue; + } + + defineIteratorMethods(AsyncIterator.prototype); + AsyncIterator.prototype[asyncIteratorSymbol] = function () { + return this; + }; + runtime.AsyncIterator = AsyncIterator; + + // Note that simple async functions are implemented on top of + // AsyncIterator objects; they just return a Promise for the value of + // the final result produced by the iterator. + runtime.async = function(innerFn, outerFn, self, tryLocsList) { + var iter = new AsyncIterator( + wrap(innerFn, outerFn, self, tryLocsList) + ); + + return runtime.isGeneratorFunction(outerFn) + ? iter // If outerFn is a generator, return the full iterator. + : iter.next().then(function(result) { + return result.done ? result.value : iter.next(); + }); + }; + + function makeInvokeMethod(innerFn, self, context) { + var state = GenStateSuspendedStart; + + return function invoke(method, arg) { + if (state === GenStateExecuting) { + throw new Error("Generator is already running"); + } + + if (state === GenStateCompleted) { + if (method === "throw") { + throw arg; + } + + // Be forgiving, per 25.3.3.3.3 of the spec: + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume + return doneResult(); + } + + context.method = method; + context.arg = arg; + + while (true) { + var delegate = context.delegate; + if (delegate) { + var delegateResult = maybeInvokeDelegate(delegate, context); + if (delegateResult) { + if (delegateResult === ContinueSentinel) continue; + return delegateResult; + } + } + + if (context.method === "next") { + // Setting context._sent for legacy support of Babel's + // function.sent implementation. + context.sent = context._sent = context.arg; + + } else if (context.method === "throw") { + if (state === GenStateSuspendedStart) { + state = GenStateCompleted; + throw context.arg; + } + + context.dispatchException(context.arg); + + } else if (context.method === "return") { + context.abrupt("return", context.arg); + } + + state = GenStateExecuting; + + var record = tryCatch(innerFn, self, context); + if (record.type === "normal") { + // If an exception is thrown from innerFn, we leave state === + // GenStateExecuting and loop back for another invocation. + state = context.done + ? GenStateCompleted + : GenStateSuspendedYield; + + if (record.arg === ContinueSentinel) { + continue; + } + + return { + value: record.arg, + done: context.done + }; + + } else if (record.type === "throw") { + state = GenStateCompleted; + // Dispatch the exception by looping back around to the + // context.dispatchException(context.arg) call above. + context.method = "throw"; + context.arg = record.arg; + } + } + }; + } + + // Call delegate.iterator[context.method](context.arg) and handle the + // result, either by returning a { value, done } result from the + // delegate iterator, or by modifying context.method and context.arg, + // setting context.delegate to null, and returning the ContinueSentinel. + function maybeInvokeDelegate(delegate, context) { + var method = delegate.iterator[context.method]; + if (method === undefined) { + // A .throw or .return when the delegate iterator has no .throw + // method always terminates the yield* loop. + context.delegate = null; + + if (context.method === "throw") { + if (delegate.iterator.return) { + // If the delegate iterator has a return method, give it a + // chance to clean up. + context.method = "return"; + context.arg = undefined; + maybeInvokeDelegate(delegate, context); + + if (context.method === "throw") { + // If maybeInvokeDelegate(context) changed context.method from + // "return" to "throw", let that override the TypeError below. + return ContinueSentinel; + } + } + + context.method = "throw"; + context.arg = new TypeError( + "The iterator does not provide a 'throw' method"); + } + + return ContinueSentinel; + } + + var record = tryCatch(method, delegate.iterator, context.arg); + + if (record.type === "throw") { + context.method = "throw"; + context.arg = record.arg; + context.delegate = null; + return ContinueSentinel; + } + + var info = record.arg; + + if (! info) { + context.method = "throw"; + context.arg = new TypeError("iterator result is not an object"); + context.delegate = null; + return ContinueSentinel; + } + + if (info.done) { + // Assign the result of the finished delegate to the temporary + // variable specified by delegate.resultName (see delegateYield). + context[delegate.resultName] = info.value; + + // Resume execution at the desired location (see delegateYield). + context.next = delegate.nextLoc; + + // If context.method was "throw" but the delegate handled the + // exception, let the outer generator proceed normally. If + // context.method was "next", forget context.arg since it has been + // "consumed" by the delegate iterator. If context.method was + // "return", allow the original .return call to continue in the + // outer generator. + if (context.method !== "return") { + context.method = "next"; + context.arg = undefined; + } + + } else { + // Re-yield the result returned by the delegate method. + return info; + } + + // The delegate iterator is finished, so forget it and continue with + // the outer generator. + context.delegate = null; + return ContinueSentinel; + } + + // Define Generator.prototype.{next,throw,return} in terms of the + // unified ._invoke helper method. + defineIteratorMethods(Gp); + + Gp[toStringTagSymbol] = "Generator"; + + // A Generator should always return itself as the iterator object when the + // @@iterator function is called on it. Some browsers' implementations of the + // iterator prototype chain incorrectly implement this, causing the Generator + // object to not be returned from this call. This ensures that doesn't happen. + // See https://github.com/facebook/regenerator/issues/274 for more details. + Gp[iteratorSymbol] = function() { + return this; + }; + + Gp.toString = function() { + return "[object Generator]"; + }; + + function pushTryEntry(locs) { + var entry = { tryLoc: locs[0] }; + + if (1 in locs) { + entry.catchLoc = locs[1]; + } + + if (2 in locs) { + entry.finallyLoc = locs[2]; + entry.afterLoc = locs[3]; + } + + this.tryEntries.push(entry); + } + + function resetTryEntry(entry) { + var record = entry.completion || {}; + record.type = "normal"; + delete record.arg; + entry.completion = record; + } + + function Context(tryLocsList) { + // The root entry object (effectively a try statement without a catch + // or a finally block) gives us a place to store values thrown from + // locations where there is no enclosing try statement. + this.tryEntries = [{ tryLoc: "root" }]; + tryLocsList.forEach(pushTryEntry, this); + this.reset(true); + } + + runtime.keys = function(object) { + var keys = []; + for (var key in object) { + keys.push(key); + } + keys.reverse(); + + // Rather than returning an object with a next method, we keep + // things simple and return the next function itself. + return function next() { + while (keys.length) { + var key = keys.pop(); + if (key in object) { + next.value = key; + next.done = false; + return next; + } + } + + // To avoid creating an additional object, we just hang the .value + // and .done properties off the next function object itself. This + // also ensures that the minifier will not anonymize the function. + next.done = true; + return next; + }; + }; + + function values(iterable) { + if (iterable) { + var iteratorMethod = iterable[iteratorSymbol]; + if (iteratorMethod) { + return iteratorMethod.call(iterable); + } + + if (typeof iterable.next === "function") { + return iterable; + } + + if (!isNaN(iterable.length)) { + var i = -1, next = function next() { + while (++i < iterable.length) { + if (hasOwn.call(iterable, i)) { + next.value = iterable[i]; + next.done = false; + return next; + } + } + + next.value = undefined; + next.done = true; + + return next; + }; + + return next.next = next; + } + } + + // Return an iterator with no values. + return { next: doneResult }; + } + runtime.values = values; + + function doneResult() { + return { value: undefined, done: true }; + } + + Context.prototype = { + constructor: Context, + + reset: function(skipTempReset) { + this.prev = 0; + this.next = 0; + // Resetting context._sent for legacy support of Babel's + // function.sent implementation. + this.sent = this._sent = undefined; + this.done = false; + this.delegate = null; + + this.method = "next"; + this.arg = undefined; + + this.tryEntries.forEach(resetTryEntry); + + if (!skipTempReset) { + for (var name in this) { + // Not sure about the optimal order of these conditions: + if (name.charAt(0) === "t" && + hasOwn.call(this, name) && + !isNaN(+name.slice(1))) { + this[name] = undefined; + } + } + } + }, + + stop: function() { + this.done = true; + + var rootEntry = this.tryEntries[0]; + var rootRecord = rootEntry.completion; + if (rootRecord.type === "throw") { + throw rootRecord.arg; + } + + return this.rval; + }, + + dispatchException: function(exception) { + if (this.done) { + throw exception; + } + + var context = this; + function handle(loc, caught) { + record.type = "throw"; + record.arg = exception; + context.next = loc; + + if (caught) { + // If the dispatched exception was caught by a catch block, + // then let that catch block handle the exception normally. + context.method = "next"; + context.arg = undefined; + } + + return !! caught; + } + + for (var i = this.tryEntries.length - 1; i >= 0; --i) { + var entry = this.tryEntries[i]; + var record = entry.completion; + + if (entry.tryLoc === "root") { + // Exception thrown outside of any try block that could handle + // it, so set the completion value of the entire function to + // throw the exception. + return handle("end"); + } + + if (entry.tryLoc <= this.prev) { + var hasCatch = hasOwn.call(entry, "catchLoc"); + var hasFinally = hasOwn.call(entry, "finallyLoc"); + + if (hasCatch && hasFinally) { + if (this.prev < entry.catchLoc) { + return handle(entry.catchLoc, true); + } else if (this.prev < entry.finallyLoc) { + return handle(entry.finallyLoc); + } + + } else if (hasCatch) { + if (this.prev < entry.catchLoc) { + return handle(entry.catchLoc, true); + } + + } else if (hasFinally) { + if (this.prev < entry.finallyLoc) { + return handle(entry.finallyLoc); + } + + } else { + throw new Error("try statement without catch or finally"); + } + } + } + }, + + abrupt: function(type, arg) { + for (var i = this.tryEntries.length - 1; i >= 0; --i) { + var entry = this.tryEntries[i]; + if (entry.tryLoc <= this.prev && + hasOwn.call(entry, "finallyLoc") && + this.prev < entry.finallyLoc) { + var finallyEntry = entry; + break; + } + } + + if (finallyEntry && + (type === "break" || + type === "continue") && + finallyEntry.tryLoc <= arg && + arg <= finallyEntry.finallyLoc) { + // Ignore the finally entry if control is not jumping to a + // location outside the try/catch block. + finallyEntry = null; + } + + var record = finallyEntry ? finallyEntry.completion : {}; + record.type = type; + record.arg = arg; + + if (finallyEntry) { + this.method = "next"; + this.next = finallyEntry.finallyLoc; + return ContinueSentinel; + } + + return this.complete(record); + }, + + complete: function(record, afterLoc) { + if (record.type === "throw") { + throw record.arg; + } + + if (record.type === "break" || + record.type === "continue") { + this.next = record.arg; + } else if (record.type === "return") { + this.rval = this.arg = record.arg; + this.method = "return"; + this.next = "end"; + } else if (record.type === "normal" && afterLoc) { + this.next = afterLoc; + } + + return ContinueSentinel; + }, + + finish: function(finallyLoc) { + for (var i = this.tryEntries.length - 1; i >= 0; --i) { + var entry = this.tryEntries[i]; + if (entry.finallyLoc === finallyLoc) { + this.complete(entry.completion, entry.afterLoc); + resetTryEntry(entry); + return ContinueSentinel; + } + } + }, + + "catch": function(tryLoc) { + for (var i = this.tryEntries.length - 1; i >= 0; --i) { + var entry = this.tryEntries[i]; + if (entry.tryLoc === tryLoc) { + var record = entry.completion; + if (record.type === "throw") { + var thrown = record.arg; + resetTryEntry(entry); + } + return thrown; + } + } + + // The context.catch method must only be called with a location + // argument that corresponds to a known catch block. + throw new Error("illegal catch attempt"); + }, + + delegateYield: function(iterable, resultName, nextLoc) { + this.delegate = { + iterator: values(iterable), + resultName: resultName, + nextLoc: nextLoc + }; + + if (this.method === "next") { + // Deliberately forget the last sent value so that we don't + // accidentally pass it on to the delegate. + this.arg = undefined; + } + + return ContinueSentinel; + } + }; + })( + // In sloppy mode, unbound `this` refers to the global object, fallback to + // Function constructor if we're in global strict mode. That is sadly a form + // of indirect eval which violates Content Security Policy. + (function() { return this })() || Function("return this")() + ); + }); + + /** + * Copyright (c) 2014-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + + // This method of obtaining a reference to the global object needs to be + // kept identical to the way it is obtained in runtime.js + var g = (function() { return this })() || Function("return this")(); + + // Use `getOwnPropertyNames` because not all browsers support calling + // `hasOwnProperty` on the global `self` object in a worker. See #183. + var hadRuntime = g.regeneratorRuntime && + Object.getOwnPropertyNames(g).indexOf("regeneratorRuntime") >= 0; + + // Save the old regeneratorRuntime in case it needs to be restored later. + var oldRuntime = hadRuntime && g.regeneratorRuntime; + + // Force reevalutation of runtime.js. + g.regeneratorRuntime = undefined; + + var runtimeModule = runtime; + + if (hadRuntime) { + // Restore the original runtime. + g.regeneratorRuntime = oldRuntime; + } else { + // Remove the global property added by runtime.js. + try { + delete g.regeneratorRuntime; + } catch(e) { + g.regeneratorRuntime = undefined; + } + } + + var regenerator = runtimeModule; + + var possibleConstructorReturn = createCommonjsModule(function (module, exports) { + + exports.__esModule = true; + + + + var _typeof3 = _interopRequireDefault(_typeof_1); + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + + exports.default = function (self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return call && ((typeof call === "undefined" ? "undefined" : (0, _typeof3.default)(call)) === "object" || typeof call === "function") ? call : self; + }; + }); + + var _possibleConstructorReturn = unwrapExports(possibleConstructorReturn); + + // Works with __proto__ only. Old v8 can't work with null proto objects. + /* eslint-disable no-proto */ + + + var check = function (O, proto) { + _anObject(O); + if (!_isObject(proto) && proto !== null) throw TypeError(proto + ": can't set as prototype!"); + }; + var _setProto = { + set: Object.setPrototypeOf || ('__proto__' in {} ? // eslint-disable-line + function (test, buggy, set) { + try { + set = _ctx(Function.call, _objectGopd.f(Object.prototype, '__proto__').set, 2); + set(test, []); + buggy = !(test instanceof Array); + } catch (e) { buggy = true; } + return function setPrototypeOf(O, proto) { + check(O, proto); + if (buggy) O.__proto__ = proto; + else set(O, proto); + return O; + }; + }({}, false) : undefined), + check: check + }; + + // 19.1.3.19 Object.setPrototypeOf(O, proto) + + _export(_export.S, 'Object', { setPrototypeOf: _setProto.set }); + + var setPrototypeOf = _core.Object.setPrototypeOf; + + var setPrototypeOf$1 = createCommonjsModule(function (module) { + module.exports = { "default": setPrototypeOf, __esModule: true }; + }); + + unwrapExports(setPrototypeOf$1); + + // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) + _export(_export.S, 'Object', { create: _objectCreate }); + + var $Object = _core.Object; + var create = function create(P, D) { + return $Object.create(P, D); + }; + + var create$1 = createCommonjsModule(function (module) { + module.exports = { "default": create, __esModule: true }; + }); + + unwrapExports(create$1); + + var inherits = createCommonjsModule(function (module, exports) { + + exports.__esModule = true; + + + + var _setPrototypeOf2 = _interopRequireDefault(setPrototypeOf$1); + + + + var _create2 = _interopRequireDefault(create$1); + + + + var _typeof3 = _interopRequireDefault(_typeof_1); + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + + exports.default = function (subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + (typeof superClass === "undefined" ? "undefined" : (0, _typeof3.default)(superClass))); + } + + subClass.prototype = (0, _create2.default)(superClass && superClass.prototype, { + constructor: { + value: subClass, + enumerable: false, + writable: true, + configurable: true + } + }); + if (superClass) _setPrototypeOf2.default ? (0, _setPrototypeOf2.default)(subClass, superClass) : subClass.__proto__ = superClass; + }; + }); + + var _inherits = unwrapExports(inherits); + + var global$1 = (typeof global !== "undefined" ? global : + typeof self !== "undefined" ? self : + typeof window !== "undefined" ? window : {}); + + var isEnum$1 = _objectPie.f; + var _objectToArray = function (isEntries) { + return function (it) { + var O = _toIobject(it); + var keys = _objectKeys(O); + var length = keys.length; + var i = 0; + var result = []; + var key; + while (length > i) { + key = keys[i++]; + if (!_descriptors || isEnum$1.call(O, key)) { + result.push(isEntries ? [key, O[key]] : O[key]); + } + } + return result; + }; + }; + + // https://github.com/tc39/proposal-object-values-entries + + var $values = _objectToArray(false); + + _export(_export.S, 'Object', { + values: function values(it) { + return $values(it); + } + }); + + var values = _core.Object.values; + + var values$1 = createCommonjsModule(function (module) { + module.exports = { "default": values, __esModule: true }; + }); + + var _Object$values = unwrapExports(values$1); + + var inherits_browser = createCommonjsModule(function (module) { + if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor; + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); + } + }; + } else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor; + var TempCtor = function () {}; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; + } + }; + } + }); + + var lookup = []; + var revLookup = []; + var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array; + var inited = false; + function init () { + inited = true; + var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; + for (var i = 0, len = code.length; i < len; ++i) { + lookup[i] = code[i]; + revLookup[code.charCodeAt(i)] = i; + } + + revLookup['-'.charCodeAt(0)] = 62; + revLookup['_'.charCodeAt(0)] = 63; + } + + function toByteArray (b64) { + if (!inited) { + init(); + } + var i, j, l, tmp, placeHolders, arr; + var len = b64.length; + + if (len % 4 > 0) { + throw new Error('Invalid string. Length must be a multiple of 4') + } + + // the number of equal signs (place holders) + // if there are two placeholders, than the two characters before it + // represent one byte + // if there is only one, then the three characters before it represent 2 bytes + // this is just a cheap hack to not do indexOf twice + placeHolders = b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0; + + // base64 is 4/3 + up to two characters of the original data + arr = new Arr(len * 3 / 4 - placeHolders); + + // if there are placeholders, only get up to the last complete 4 chars + l = placeHolders > 0 ? len - 4 : len; + + var L = 0; + + for (i = 0, j = 0; i < l; i += 4, j += 3) { + tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]; + arr[L++] = (tmp >> 16) & 0xFF; + arr[L++] = (tmp >> 8) & 0xFF; + arr[L++] = tmp & 0xFF; + } + + if (placeHolders === 2) { + tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4); + arr[L++] = tmp & 0xFF; + } else if (placeHolders === 1) { + tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2); + arr[L++] = (tmp >> 8) & 0xFF; + arr[L++] = tmp & 0xFF; + } + + return arr + } + + function tripletToBase64 (num) { + return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] + } + + function encodeChunk (uint8, start, end) { + var tmp; + var output = []; + for (var i = start; i < end; i += 3) { + tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]); + output.push(tripletToBase64(tmp)); + } + return output.join('') + } + + function fromByteArray (uint8) { + if (!inited) { + init(); + } + var tmp; + var len = uint8.length; + var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes + var output = ''; + var parts = []; + var maxChunkLength = 16383; // must be multiple of 3 + + // go through the array every three bytes, we'll deal with trailing stuff later + for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { + parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))); + } + + // pad the end with zeros, but make sure to not forget the extra bytes + if (extraBytes === 1) { + tmp = uint8[len - 1]; + output += lookup[tmp >> 2]; + output += lookup[(tmp << 4) & 0x3F]; + output += '=='; + } else if (extraBytes === 2) { + tmp = (uint8[len - 2] << 8) + (uint8[len - 1]); + output += lookup[tmp >> 10]; + output += lookup[(tmp >> 4) & 0x3F]; + output += lookup[(tmp << 2) & 0x3F]; + output += '='; + } + + parts.push(output); + + return parts.join('') + } + + function read (buffer, offset, isLE, mLen, nBytes) { + var e, m; + var eLen = nBytes * 8 - mLen - 1; + var eMax = (1 << eLen) - 1; + var eBias = eMax >> 1; + var nBits = -7; + var i = isLE ? (nBytes - 1) : 0; + var d = isLE ? -1 : 1; + var s = buffer[offset + i]; + + i += d; + + e = s & ((1 << (-nBits)) - 1); + s >>= (-nBits); + nBits += eLen; + for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} + + m = e & ((1 << (-nBits)) - 1); + e >>= (-nBits); + nBits += mLen; + for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} + + if (e === 0) { + e = 1 - eBias; + } else if (e === eMax) { + return m ? NaN : ((s ? -1 : 1) * Infinity) + } else { + m = m + Math.pow(2, mLen); + e = e - eBias; + } + return (s ? -1 : 1) * m * Math.pow(2, e - mLen) + } + + function write (buffer, value, offset, isLE, mLen, nBytes) { + var e, m, c; + var eLen = nBytes * 8 - mLen - 1; + var eMax = (1 << eLen) - 1; + var eBias = eMax >> 1; + var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0); + var i = isLE ? 0 : (nBytes - 1); + var d = isLE ? 1 : -1; + var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0; + + value = Math.abs(value); + + if (isNaN(value) || value === Infinity) { + m = isNaN(value) ? 1 : 0; + e = eMax; + } else { + e = Math.floor(Math.log(value) / Math.LN2); + if (value * (c = Math.pow(2, -e)) < 1) { + e--; + c *= 2; + } + if (e + eBias >= 1) { + value += rt / c; + } else { + value += rt * Math.pow(2, 1 - eBias); + } + if (value * c >= 2) { + e++; + c /= 2; + } + + if (e + eBias >= eMax) { + m = 0; + e = eMax; + } else if (e + eBias >= 1) { + m = (value * c - 1) * Math.pow(2, mLen); + e = e + eBias; + } else { + m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen); + e = 0; + } + } + + for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} + + e = (e << mLen) | m; + eLen += mLen; + for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} + + buffer[offset + i - d] |= s * 128; + } + + var toString$2 = {}.toString; + + var isArray = Array.isArray || function (arr) { + return toString$2.call(arr) == '[object Array]'; + }; + + var INSPECT_MAX_BYTES = 50; + + /** + * If `Buffer.TYPED_ARRAY_SUPPORT`: + * === true Use Uint8Array implementation (fastest) + * === false Use Object implementation (most compatible, even IE6) + * + * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, + * Opera 11.6+, iOS 4.2+. + * + * Due to various browser bugs, sometimes the Object implementation will be used even + * when the browser supports typed arrays. + * + * Note: + * + * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances, + * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. + * + * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. + * + * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of + * incorrect length in some situations. + + * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they + * get the Object implementation, which is slower but behaves correctly. + */ + Buffer.TYPED_ARRAY_SUPPORT = global$1.TYPED_ARRAY_SUPPORT !== undefined + ? global$1.TYPED_ARRAY_SUPPORT + : true; + + /* + * Export kMaxLength after typed array support is determined. + */ + var _kMaxLength = kMaxLength(); + + function kMaxLength () { + return Buffer.TYPED_ARRAY_SUPPORT + ? 0x7fffffff + : 0x3fffffff + } + + function createBuffer (that, length) { + if (kMaxLength() < length) { + throw new RangeError('Invalid typed array length') + } + if (Buffer.TYPED_ARRAY_SUPPORT) { + // Return an augmented `Uint8Array` instance, for best performance + that = new Uint8Array(length); + that.__proto__ = Buffer.prototype; + } else { + // Fallback: Return an object instance of the Buffer class + if (that === null) { + that = new Buffer(length); + } + that.length = length; + } + + return that + } + + /** + * The Buffer constructor returns instances of `Uint8Array` that have their + * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of + * `Uint8Array`, so the returned instances will have all the node `Buffer` methods + * and the `Uint8Array` methods. Square bracket notation works as expected -- it + * returns a single octet. + * + * The `Uint8Array` prototype remains unmodified. + */ + + function Buffer (arg, encodingOrOffset, length) { + if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) { + return new Buffer(arg, encodingOrOffset, length) + } + + // Common case. + if (typeof arg === 'number') { + if (typeof encodingOrOffset === 'string') { + throw new Error( + 'If encoding is specified then the first argument must be a string' + ) + } + return allocUnsafe(this, arg) + } + return from(this, arg, encodingOrOffset, length) + } + + Buffer.poolSize = 8192; // not used by this implementation + + // TODO: Legacy, not needed anymore. Remove in next major version. + Buffer._augment = function (arr) { + arr.__proto__ = Buffer.prototype; + return arr + }; + + function from (that, value, encodingOrOffset, length) { + if (typeof value === 'number') { + throw new TypeError('"value" argument must not be a number') + } + + if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) { + return fromArrayBuffer(that, value, encodingOrOffset, length) + } + + if (typeof value === 'string') { + return fromString(that, value, encodingOrOffset) + } + + return fromObject(that, value) + } + + /** + * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError + * if value is a number. + * Buffer.from(str[, encoding]) + * Buffer.from(array) + * Buffer.from(buffer) + * Buffer.from(arrayBuffer[, byteOffset[, length]]) + **/ + Buffer.from = function (value, encodingOrOffset, length) { + return from(null, value, encodingOrOffset, length) + }; + + if (Buffer.TYPED_ARRAY_SUPPORT) { + Buffer.prototype.__proto__ = Uint8Array.prototype; + Buffer.__proto__ = Uint8Array; + } + + function assertSize (size) { + if (typeof size !== 'number') { + throw new TypeError('"size" argument must be a number') + } else if (size < 0) { + throw new RangeError('"size" argument must not be negative') + } + } + + function alloc (that, size, fill, encoding) { + assertSize(size); + if (size <= 0) { + return createBuffer(that, size) + } + if (fill !== undefined) { + // Only pay attention to encoding if it's a string. This + // prevents accidentally sending in a number that would + // be interpretted as a start offset. + return typeof encoding === 'string' + ? createBuffer(that, size).fill(fill, encoding) + : createBuffer(that, size).fill(fill) + } + return createBuffer(that, size) + } + + /** + * Creates a new filled Buffer instance. + * alloc(size[, fill[, encoding]]) + **/ + Buffer.alloc = function (size, fill, encoding) { + return alloc(null, size, fill, encoding) + }; + + function allocUnsafe (that, size) { + assertSize(size); + that = createBuffer(that, size < 0 ? 0 : checked(size) | 0); + if (!Buffer.TYPED_ARRAY_SUPPORT) { + for (var i = 0; i < size; ++i) { + that[i] = 0; + } + } + return that + } + + /** + * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. + * */ + Buffer.allocUnsafe = function (size) { + return allocUnsafe(null, size) + }; + /** + * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. + */ + Buffer.allocUnsafeSlow = function (size) { + return allocUnsafe(null, size) + }; + + function fromString (that, string, encoding) { + if (typeof encoding !== 'string' || encoding === '') { + encoding = 'utf8'; + } + + if (!Buffer.isEncoding(encoding)) { + throw new TypeError('"encoding" must be a valid string encoding') + } + + var length = byteLength(string, encoding) | 0; + that = createBuffer(that, length); + + var actual = that.write(string, encoding); + + if (actual !== length) { + // Writing a hex string, for example, that contains invalid characters will + // cause everything after the first invalid character to be ignored. (e.g. + // 'abxxcd' will be treated as 'ab') + that = that.slice(0, actual); + } + + return that + } + + function fromArrayLike (that, array) { + var length = array.length < 0 ? 0 : checked(array.length) | 0; + that = createBuffer(that, length); + for (var i = 0; i < length; i += 1) { + that[i] = array[i] & 255; + } + return that + } + + function fromArrayBuffer (that, array, byteOffset, length) { + array.byteLength; // this throws if `array` is not a valid ArrayBuffer + + if (byteOffset < 0 || array.byteLength < byteOffset) { + throw new RangeError('\'offset\' is out of bounds') + } + + if (array.byteLength < byteOffset + (length || 0)) { + throw new RangeError('\'length\' is out of bounds') + } + + if (byteOffset === undefined && length === undefined) { + array = new Uint8Array(array); + } else if (length === undefined) { + array = new Uint8Array(array, byteOffset); + } else { + array = new Uint8Array(array, byteOffset, length); + } + + if (Buffer.TYPED_ARRAY_SUPPORT) { + // Return an augmented `Uint8Array` instance, for best performance + that = array; + that.__proto__ = Buffer.prototype; + } else { + // Fallback: Return an object instance of the Buffer class + that = fromArrayLike(that, array); + } + return that + } + + function fromObject (that, obj) { + if (internalIsBuffer(obj)) { + var len = checked(obj.length) | 0; + that = createBuffer(that, len); + + if (that.length === 0) { + return that + } + + obj.copy(that, 0, 0, len); + return that + } + + if (obj) { + if ((typeof ArrayBuffer !== 'undefined' && + obj.buffer instanceof ArrayBuffer) || 'length' in obj) { + if (typeof obj.length !== 'number' || isnan(obj.length)) { + return createBuffer(that, 0) + } + return fromArrayLike(that, obj) + } + + if (obj.type === 'Buffer' && isArray(obj.data)) { + return fromArrayLike(that, obj.data) + } + } + + throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.') + } + + function checked (length) { + // Note: cannot use `length < kMaxLength()` here because that fails when + // length is NaN (which is otherwise coerced to zero.) + if (length >= kMaxLength()) { + throw new RangeError('Attempt to allocate Buffer larger than maximum ' + + 'size: 0x' + kMaxLength().toString(16) + ' bytes') + } + return length | 0 + } + + function SlowBuffer (length) { + if (+length != length) { // eslint-disable-line eqeqeq + length = 0; + } + return Buffer.alloc(+length) + } + Buffer.isBuffer = isBuffer; + function internalIsBuffer (b) { + return !!(b != null && b._isBuffer) + } + + Buffer.compare = function compare (a, b) { + if (!internalIsBuffer(a) || !internalIsBuffer(b)) { + throw new TypeError('Arguments must be Buffers') + } + + if (a === b) return 0 + + var x = a.length; + var y = b.length; + + for (var i = 0, len = Math.min(x, y); i < len; ++i) { + if (a[i] !== b[i]) { + x = a[i]; + y = b[i]; + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 + }; + + Buffer.isEncoding = function isEncoding (encoding) { + switch (String(encoding).toLowerCase()) { + case 'hex': + case 'utf8': + case 'utf-8': + case 'ascii': + case 'latin1': + case 'binary': + case 'base64': + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return true + default: + return false + } + }; + + Buffer.concat = function concat (list, length) { + if (!isArray(list)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + + if (list.length === 0) { + return Buffer.alloc(0) + } + + var i; + if (length === undefined) { + length = 0; + for (i = 0; i < list.length; ++i) { + length += list[i].length; + } + } + + var buffer = Buffer.allocUnsafe(length); + var pos = 0; + for (i = 0; i < list.length; ++i) { + var buf = list[i]; + if (!internalIsBuffer(buf)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + buf.copy(buffer, pos); + pos += buf.length; + } + return buffer + }; + + function byteLength (string, encoding) { + if (internalIsBuffer(string)) { + return string.length + } + if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' && + (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) { + return string.byteLength + } + if (typeof string !== 'string') { + string = '' + string; + } + + var len = string.length; + if (len === 0) return 0 + + // Use a for loop to avoid recursion + var loweredCase = false; + for (;;) { + switch (encoding) { + case 'ascii': + case 'latin1': + case 'binary': + return len + case 'utf8': + case 'utf-8': + case undefined: + return utf8ToBytes(string).length + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return len * 2 + case 'hex': + return len >>> 1 + case 'base64': + return base64ToBytes(string).length + default: + if (loweredCase) return utf8ToBytes(string).length // assume utf8 + encoding = ('' + encoding).toLowerCase(); + loweredCase = true; + } + } + } + Buffer.byteLength = byteLength; + + function slowToString (encoding, start, end) { + var loweredCase = false; + + // No need to verify that "this.length <= MAX_UINT32" since it's a read-only + // property of a typed array. + + // This behaves neither like String nor Uint8Array in that we set start/end + // to their upper/lower bounds if the value passed is out of range. + // undefined is handled specially as per ECMA-262 6th Edition, + // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. + if (start === undefined || start < 0) { + start = 0; + } + // Return early if start > this.length. Done here to prevent potential uint32 + // coercion fail below. + if (start > this.length) { + return '' + } + + if (end === undefined || end > this.length) { + end = this.length; + } + + if (end <= 0) { + return '' + } + + // Force coersion to uint32. This will also coerce falsey/NaN values to 0. + end >>>= 0; + start >>>= 0; + + if (end <= start) { + return '' + } + + if (!encoding) encoding = 'utf8'; + + while (true) { + switch (encoding) { + case 'hex': + return hexSlice(this, start, end) + + case 'utf8': + case 'utf-8': + return utf8Slice(this, start, end) + + case 'ascii': + return asciiSlice(this, start, end) + + case 'latin1': + case 'binary': + return latin1Slice(this, start, end) + + case 'base64': + return base64Slice(this, start, end) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return utf16leSlice(this, start, end) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = (encoding + '').toLowerCase(); + loweredCase = true; + } + } + } + + // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect + // Buffer instances. + Buffer.prototype._isBuffer = true; + + function swap (b, n, m) { + var i = b[n]; + b[n] = b[m]; + b[m] = i; + } + + Buffer.prototype.swap16 = function swap16 () { + var len = this.length; + if (len % 2 !== 0) { + throw new RangeError('Buffer size must be a multiple of 16-bits') + } + for (var i = 0; i < len; i += 2) { + swap(this, i, i + 1); + } + return this + }; + + Buffer.prototype.swap32 = function swap32 () { + var len = this.length; + if (len % 4 !== 0) { + throw new RangeError('Buffer size must be a multiple of 32-bits') + } + for (var i = 0; i < len; i += 4) { + swap(this, i, i + 3); + swap(this, i + 1, i + 2); + } + return this + }; + + Buffer.prototype.swap64 = function swap64 () { + var len = this.length; + if (len % 8 !== 0) { + throw new RangeError('Buffer size must be a multiple of 64-bits') + } + for (var i = 0; i < len; i += 8) { + swap(this, i, i + 7); + swap(this, i + 1, i + 6); + swap(this, i + 2, i + 5); + swap(this, i + 3, i + 4); + } + return this + }; + + Buffer.prototype.toString = function toString () { + var length = this.length | 0; + if (length === 0) return '' + if (arguments.length === 0) return utf8Slice(this, 0, length) + return slowToString.apply(this, arguments) + }; + + Buffer.prototype.equals = function equals (b) { + if (!internalIsBuffer(b)) throw new TypeError('Argument must be a Buffer') + if (this === b) return true + return Buffer.compare(this, b) === 0 + }; + + Buffer.prototype.inspect = function inspect () { + var str = ''; + var max = INSPECT_MAX_BYTES; + if (this.length > 0) { + str = this.toString('hex', 0, max).match(/.{2}/g).join(' '); + if (this.length > max) str += ' ... '; + } + return '' + }; + + Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { + if (!internalIsBuffer(target)) { + throw new TypeError('Argument must be a Buffer') + } + + if (start === undefined) { + start = 0; + } + if (end === undefined) { + end = target ? target.length : 0; + } + if (thisStart === undefined) { + thisStart = 0; + } + if (thisEnd === undefined) { + thisEnd = this.length; + } + + if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { + throw new RangeError('out of range index') + } + + if (thisStart >= thisEnd && start >= end) { + return 0 + } + if (thisStart >= thisEnd) { + return -1 + } + if (start >= end) { + return 1 + } + + start >>>= 0; + end >>>= 0; + thisStart >>>= 0; + thisEnd >>>= 0; + + if (this === target) return 0 + + var x = thisEnd - thisStart; + var y = end - start; + var len = Math.min(x, y); + + var thisCopy = this.slice(thisStart, thisEnd); + var targetCopy = target.slice(start, end); + + for (var i = 0; i < len; ++i) { + if (thisCopy[i] !== targetCopy[i]) { + x = thisCopy[i]; + y = targetCopy[i]; + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 + }; + + // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, + // OR the last index of `val` in `buffer` at offset <= `byteOffset`. + // + // Arguments: + // - buffer - a Buffer to search + // - val - a string, Buffer, or number + // - byteOffset - an index into `buffer`; will be clamped to an int32 + // - encoding - an optional encoding, relevant is val is a string + // - dir - true for indexOf, false for lastIndexOf + function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { + // Empty buffer means no match + if (buffer.length === 0) return -1 + + // Normalize byteOffset + if (typeof byteOffset === 'string') { + encoding = byteOffset; + byteOffset = 0; + } else if (byteOffset > 0x7fffffff) { + byteOffset = 0x7fffffff; + } else if (byteOffset < -0x80000000) { + byteOffset = -0x80000000; + } + byteOffset = +byteOffset; // Coerce to Number. + if (isNaN(byteOffset)) { + // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer + byteOffset = dir ? 0 : (buffer.length - 1); + } + + // Normalize byteOffset: negative offsets start from the end of the buffer + if (byteOffset < 0) byteOffset = buffer.length + byteOffset; + if (byteOffset >= buffer.length) { + if (dir) return -1 + else byteOffset = buffer.length - 1; + } else if (byteOffset < 0) { + if (dir) byteOffset = 0; + else return -1 + } + + // Normalize val + if (typeof val === 'string') { + val = Buffer.from(val, encoding); + } + + // Finally, search either indexOf (if dir is true) or lastIndexOf + if (internalIsBuffer(val)) { + // Special case: looking for empty string/buffer always fails + if (val.length === 0) { + return -1 + } + return arrayIndexOf$1(buffer, val, byteOffset, encoding, dir) + } else if (typeof val === 'number') { + val = val & 0xFF; // Search for a byte value [0-255] + if (Buffer.TYPED_ARRAY_SUPPORT && + typeof Uint8Array.prototype.indexOf === 'function') { + if (dir) { + return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) + } else { + return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) + } + } + return arrayIndexOf$1(buffer, [ val ], byteOffset, encoding, dir) + } + + throw new TypeError('val must be string, number or Buffer') + } + + function arrayIndexOf$1 (arr, val, byteOffset, encoding, dir) { + var indexSize = 1; + var arrLength = arr.length; + var valLength = val.length; + + if (encoding !== undefined) { + encoding = String(encoding).toLowerCase(); + if (encoding === 'ucs2' || encoding === 'ucs-2' || + encoding === 'utf16le' || encoding === 'utf-16le') { + if (arr.length < 2 || val.length < 2) { + return -1 + } + indexSize = 2; + arrLength /= 2; + valLength /= 2; + byteOffset /= 2; + } + } + + function read$$1 (buf, i) { + if (indexSize === 1) { + return buf[i] + } else { + return buf.readUInt16BE(i * indexSize) + } + } + + var i; + if (dir) { + var foundIndex = -1; + for (i = byteOffset; i < arrLength; i++) { + if (read$$1(arr, i) === read$$1(val, foundIndex === -1 ? 0 : i - foundIndex)) { + if (foundIndex === -1) foundIndex = i; + if (i - foundIndex + 1 === valLength) return foundIndex * indexSize + } else { + if (foundIndex !== -1) i -= i - foundIndex; + foundIndex = -1; + } + } + } else { + if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength; + for (i = byteOffset; i >= 0; i--) { + var found = true; + for (var j = 0; j < valLength; j++) { + if (read$$1(arr, i + j) !== read$$1(val, j)) { + found = false; + break + } + } + if (found) return i + } + } + + return -1 + } + + Buffer.prototype.includes = function includes (val, byteOffset, encoding) { + return this.indexOf(val, byteOffset, encoding) !== -1 + }; + + Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, true) + }; + + Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, false) + }; + + function hexWrite (buf, string, offset, length) { + offset = Number(offset) || 0; + var remaining = buf.length - offset; + if (!length) { + length = remaining; + } else { + length = Number(length); + if (length > remaining) { + length = remaining; + } + } + + // must be an even number of digits + var strLen = string.length; + if (strLen % 2 !== 0) throw new TypeError('Invalid hex string') + + if (length > strLen / 2) { + length = strLen / 2; + } + for (var i = 0; i < length; ++i) { + var parsed = parseInt(string.substr(i * 2, 2), 16); + if (isNaN(parsed)) return i + buf[offset + i] = parsed; + } + return i + } + + function utf8Write (buf, string, offset, length) { + return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) + } + + function asciiWrite (buf, string, offset, length) { + return blitBuffer(asciiToBytes(string), buf, offset, length) + } + + function latin1Write (buf, string, offset, length) { + return asciiWrite(buf, string, offset, length) + } + + function base64Write (buf, string, offset, length) { + return blitBuffer(base64ToBytes(string), buf, offset, length) + } + + function ucs2Write (buf, string, offset, length) { + return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) + } + + Buffer.prototype.write = function write$$1 (string, offset, length, encoding) { + // Buffer#write(string) + if (offset === undefined) { + encoding = 'utf8'; + length = this.length; + offset = 0; + // Buffer#write(string, encoding) + } else if (length === undefined && typeof offset === 'string') { + encoding = offset; + length = this.length; + offset = 0; + // Buffer#write(string, offset[, length][, encoding]) + } else if (isFinite(offset)) { + offset = offset | 0; + if (isFinite(length)) { + length = length | 0; + if (encoding === undefined) encoding = 'utf8'; + } else { + encoding = length; + length = undefined; + } + // legacy write(string, encoding, offset, length) - remove in v0.13 + } else { + throw new Error( + 'Buffer.write(string, encoding, offset[, length]) is no longer supported' + ) + } + + var remaining = this.length - offset; + if (length === undefined || length > remaining) length = remaining; + + if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { + throw new RangeError('Attempt to write outside buffer bounds') + } + + if (!encoding) encoding = 'utf8'; + + var loweredCase = false; + for (;;) { + switch (encoding) { + case 'hex': + return hexWrite(this, string, offset, length) + + case 'utf8': + case 'utf-8': + return utf8Write(this, string, offset, length) + + case 'ascii': + return asciiWrite(this, string, offset, length) + + case 'latin1': + case 'binary': + return latin1Write(this, string, offset, length) + + case 'base64': + // Warning: maxLength not taken into account in base64Write + return base64Write(this, string, offset, length) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return ucs2Write(this, string, offset, length) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = ('' + encoding).toLowerCase(); + loweredCase = true; + } + } + }; + + Buffer.prototype.toJSON = function toJSON () { + return { + type: 'Buffer', + data: Array.prototype.slice.call(this._arr || this, 0) + } + }; + + function base64Slice (buf, start, end) { + if (start === 0 && end === buf.length) { + return fromByteArray(buf) + } else { + return fromByteArray(buf.slice(start, end)) + } + } + + function utf8Slice (buf, start, end) { + end = Math.min(buf.length, end); + var res = []; + + var i = start; + while (i < end) { + var firstByte = buf[i]; + var codePoint = null; + var bytesPerSequence = (firstByte > 0xEF) ? 4 + : (firstByte > 0xDF) ? 3 + : (firstByte > 0xBF) ? 2 + : 1; + + if (i + bytesPerSequence <= end) { + var secondByte, thirdByte, fourthByte, tempCodePoint; + + switch (bytesPerSequence) { + case 1: + if (firstByte < 0x80) { + codePoint = firstByte; + } + break + case 2: + secondByte = buf[i + 1]; + if ((secondByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F); + if (tempCodePoint > 0x7F) { + codePoint = tempCodePoint; + } + } + break + case 3: + secondByte = buf[i + 1]; + thirdByte = buf[i + 2]; + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F); + if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { + codePoint = tempCodePoint; + } + } + break + case 4: + secondByte = buf[i + 1]; + thirdByte = buf[i + 2]; + fourthByte = buf[i + 3]; + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F); + if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { + codePoint = tempCodePoint; + } + } + } + } + + if (codePoint === null) { + // we did not generate a valid codePoint so insert a + // replacement char (U+FFFD) and advance only 1 byte + codePoint = 0xFFFD; + bytesPerSequence = 1; + } else if (codePoint > 0xFFFF) { + // encode to utf16 (surrogate pair dance) + codePoint -= 0x10000; + res.push(codePoint >>> 10 & 0x3FF | 0xD800); + codePoint = 0xDC00 | codePoint & 0x3FF; + } + + res.push(codePoint); + i += bytesPerSequence; + } + + return decodeCodePointsArray(res) + } + + // Based on http://stackoverflow.com/a/22747272/680742, the browser with + // the lowest limit is Chrome, with 0x10000 args. + // We go 1 magnitude less, for safety + var MAX_ARGUMENTS_LENGTH = 0x1000; + + function decodeCodePointsArray (codePoints) { + var len = codePoints.length; + if (len <= MAX_ARGUMENTS_LENGTH) { + return String.fromCharCode.apply(String, codePoints) // avoid extra slice() + } + + // Decode in chunks to avoid "call stack size exceeded". + var res = ''; + var i = 0; + while (i < len) { + res += String.fromCharCode.apply( + String, + codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) + ); + } + return res + } + + function asciiSlice (buf, start, end) { + var ret = ''; + end = Math.min(buf.length, end); + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i] & 0x7F); + } + return ret + } + + function latin1Slice (buf, start, end) { + var ret = ''; + end = Math.min(buf.length, end); + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i]); + } + return ret + } + + function hexSlice (buf, start, end) { + var len = buf.length; + + if (!start || start < 0) start = 0; + if (!end || end < 0 || end > len) end = len; + + var out = ''; + for (var i = start; i < end; ++i) { + out += toHex(buf[i]); + } + return out + } + + function utf16leSlice (buf, start, end) { + var bytes = buf.slice(start, end); + var res = ''; + for (var i = 0; i < bytes.length; i += 2) { + res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256); + } + return res + } + + Buffer.prototype.slice = function slice (start, end) { + var len = this.length; + start = ~~start; + end = end === undefined ? len : ~~end; + + if (start < 0) { + start += len; + if (start < 0) start = 0; + } else if (start > len) { + start = len; + } + + if (end < 0) { + end += len; + if (end < 0) end = 0; + } else if (end > len) { + end = len; + } + + if (end < start) end = start; + + var newBuf; + if (Buffer.TYPED_ARRAY_SUPPORT) { + newBuf = this.subarray(start, end); + newBuf.__proto__ = Buffer.prototype; + } else { + var sliceLen = end - start; + newBuf = new Buffer(sliceLen, undefined); + for (var i = 0; i < sliceLen; ++i) { + newBuf[i] = this[i + start]; + } + } + + return newBuf + }; + + /* + * Need to make sure that buffer isn't trying to write out of bounds. + */ + function checkOffset (offset, ext, length) { + if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') + if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') + } + + Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { + offset = offset | 0; + byteLength = byteLength | 0; + if (!noAssert) checkOffset(offset, byteLength, this.length); + + var val = this[offset]; + var mul = 1; + var i = 0; + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul; + } + + return val + }; + + Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { + offset = offset | 0; + byteLength = byteLength | 0; + if (!noAssert) { + checkOffset(offset, byteLength, this.length); + } + + var val = this[offset + --byteLength]; + var mul = 1; + while (byteLength > 0 && (mul *= 0x100)) { + val += this[offset + --byteLength] * mul; + } + + return val + }; + + Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { + if (!noAssert) checkOffset(offset, 1, this.length); + return this[offset] + }; + + Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length); + return this[offset] | (this[offset + 1] << 8) + }; + + Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length); + return (this[offset] << 8) | this[offset + 1] + }; + + Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length); + + return ((this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16)) + + (this[offset + 3] * 0x1000000) + }; + + Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length); + + return (this[offset] * 0x1000000) + + ((this[offset + 1] << 16) | + (this[offset + 2] << 8) | + this[offset + 3]) + }; + + Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { + offset = offset | 0; + byteLength = byteLength | 0; + if (!noAssert) checkOffset(offset, byteLength, this.length); + + var val = this[offset]; + var mul = 1; + var i = 0; + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul; + } + mul *= 0x80; + + if (val >= mul) val -= Math.pow(2, 8 * byteLength); + + return val + }; + + Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { + offset = offset | 0; + byteLength = byteLength | 0; + if (!noAssert) checkOffset(offset, byteLength, this.length); + + var i = byteLength; + var mul = 1; + var val = this[offset + --i]; + while (i > 0 && (mul *= 0x100)) { + val += this[offset + --i] * mul; + } + mul *= 0x80; + + if (val >= mul) val -= Math.pow(2, 8 * byteLength); + + return val + }; + + Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { + if (!noAssert) checkOffset(offset, 1, this.length); + if (!(this[offset] & 0x80)) return (this[offset]) + return ((0xff - this[offset] + 1) * -1) + }; + + Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length); + var val = this[offset] | (this[offset + 1] << 8); + return (val & 0x8000) ? val | 0xFFFF0000 : val + }; + + Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length); + var val = this[offset + 1] | (this[offset] << 8); + return (val & 0x8000) ? val | 0xFFFF0000 : val + }; + + Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length); + + return (this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16) | + (this[offset + 3] << 24) + }; + + Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length); + + return (this[offset] << 24) | + (this[offset + 1] << 16) | + (this[offset + 2] << 8) | + (this[offset + 3]) + }; + + Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length); + return read(this, offset, true, 23, 4) + }; + + Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length); + return read(this, offset, false, 23, 4) + }; + + Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 8, this.length); + return read(this, offset, true, 52, 8) + }; + + Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 8, this.length); + return read(this, offset, false, 52, 8) + }; + + function checkInt (buf, value, offset, ext, max, min) { + if (!internalIsBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') + if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') + if (offset + ext > buf.length) throw new RangeError('Index out of range') + } + + Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { + value = +value; + offset = offset | 0; + byteLength = byteLength | 0; + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1; + checkInt(this, value, offset, byteLength, maxBytes, 0); + } + + var mul = 1; + var i = 0; + this[offset] = value & 0xFF; + while (++i < byteLength && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF; + } + + return offset + byteLength + }; + + Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { + value = +value; + offset = offset | 0; + byteLength = byteLength | 0; + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1; + checkInt(this, value, offset, byteLength, maxBytes, 0); + } + + var i = byteLength - 1; + var mul = 1; + this[offset + i] = value & 0xFF; + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF; + } + + return offset + byteLength + }; + + Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { + value = +value; + offset = offset | 0; + if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0); + if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value); + this[offset] = (value & 0xff); + return offset + 1 + }; + + function objectWriteUInt16 (buf, value, offset, littleEndian) { + if (value < 0) value = 0xffff + value + 1; + for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) { + buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> + (littleEndian ? i : 1 - i) * 8; + } + } + + Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { + value = +value; + offset = offset | 0; + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0); + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value & 0xff); + this[offset + 1] = (value >>> 8); + } else { + objectWriteUInt16(this, value, offset, true); + } + return offset + 2 + }; + + Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { + value = +value; + offset = offset | 0; + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0); + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 8); + this[offset + 1] = (value & 0xff); + } else { + objectWriteUInt16(this, value, offset, false); + } + return offset + 2 + }; + + function objectWriteUInt32 (buf, value, offset, littleEndian) { + if (value < 0) value = 0xffffffff + value + 1; + for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) { + buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff; + } + } + + Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { + value = +value; + offset = offset | 0; + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0); + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset + 3] = (value >>> 24); + this[offset + 2] = (value >>> 16); + this[offset + 1] = (value >>> 8); + this[offset] = (value & 0xff); + } else { + objectWriteUInt32(this, value, offset, true); + } + return offset + 4 + }; + + Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { + value = +value; + offset = offset | 0; + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0); + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 24); + this[offset + 1] = (value >>> 16); + this[offset + 2] = (value >>> 8); + this[offset + 3] = (value & 0xff); + } else { + objectWriteUInt32(this, value, offset, false); + } + return offset + 4 + }; + + Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { + value = +value; + offset = offset | 0; + if (!noAssert) { + var limit = Math.pow(2, 8 * byteLength - 1); + + checkInt(this, value, offset, byteLength, limit - 1, -limit); + } + + var i = 0; + var mul = 1; + var sub = 0; + this[offset] = value & 0xFF; + while (++i < byteLength && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { + sub = 1; + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF; + } + + return offset + byteLength + }; + + Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { + value = +value; + offset = offset | 0; + if (!noAssert) { + var limit = Math.pow(2, 8 * byteLength - 1); + + checkInt(this, value, offset, byteLength, limit - 1, -limit); + } + + var i = byteLength - 1; + var mul = 1; + var sub = 0; + this[offset + i] = value & 0xFF; + while (--i >= 0 && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { + sub = 1; + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF; + } + + return offset + byteLength + }; + + Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { + value = +value; + offset = offset | 0; + if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80); + if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value); + if (value < 0) value = 0xff + value + 1; + this[offset] = (value & 0xff); + return offset + 1 + }; + + Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { + value = +value; + offset = offset | 0; + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000); + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value & 0xff); + this[offset + 1] = (value >>> 8); + } else { + objectWriteUInt16(this, value, offset, true); + } + return offset + 2 + }; + + Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { + value = +value; + offset = offset | 0; + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000); + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 8); + this[offset + 1] = (value & 0xff); + } else { + objectWriteUInt16(this, value, offset, false); + } + return offset + 2 + }; + + Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { + value = +value; + offset = offset | 0; + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000); + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value & 0xff); + this[offset + 1] = (value >>> 8); + this[offset + 2] = (value >>> 16); + this[offset + 3] = (value >>> 24); + } else { + objectWriteUInt32(this, value, offset, true); + } + return offset + 4 + }; + + Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { + value = +value; + offset = offset | 0; + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000); + if (value < 0) value = 0xffffffff + value + 1; + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 24); + this[offset + 1] = (value >>> 16); + this[offset + 2] = (value >>> 8); + this[offset + 3] = (value & 0xff); + } else { + objectWriteUInt32(this, value, offset, false); + } + return offset + 4 + }; + + function checkIEEE754 (buf, value, offset, ext, max, min) { + if (offset + ext > buf.length) throw new RangeError('Index out of range') + if (offset < 0) throw new RangeError('Index out of range') + } + + function writeFloat (buf, value, offset, littleEndian, noAssert) { + if (!noAssert) { + checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38); + } + write(buf, value, offset, littleEndian, 23, 4); + return offset + 4 + } + + Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { + return writeFloat(this, value, offset, true, noAssert) + }; + + Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { + return writeFloat(this, value, offset, false, noAssert) + }; + + function writeDouble (buf, value, offset, littleEndian, noAssert) { + if (!noAssert) { + checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308); + } + write(buf, value, offset, littleEndian, 52, 8); + return offset + 8 + } + + Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { + return writeDouble(this, value, offset, true, noAssert) + }; + + Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { + return writeDouble(this, value, offset, false, noAssert) + }; + + // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) + Buffer.prototype.copy = function copy (target, targetStart, start, end) { + if (!start) start = 0; + if (!end && end !== 0) end = this.length; + if (targetStart >= target.length) targetStart = target.length; + if (!targetStart) targetStart = 0; + if (end > 0 && end < start) end = start; + + // Copy 0 bytes; we're done + if (end === start) return 0 + if (target.length === 0 || this.length === 0) return 0 + + // Fatal error conditions + if (targetStart < 0) { + throw new RangeError('targetStart out of bounds') + } + if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds') + if (end < 0) throw new RangeError('sourceEnd out of bounds') + + // Are we oob? + if (end > this.length) end = this.length; + if (target.length - targetStart < end - start) { + end = target.length - targetStart + start; + } + + var len = end - start; + var i; + + if (this === target && start < targetStart && targetStart < end) { + // descending copy from end + for (i = len - 1; i >= 0; --i) { + target[i + targetStart] = this[i + start]; + } + } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { + // ascending copy from start + for (i = 0; i < len; ++i) { + target[i + targetStart] = this[i + start]; + } + } else { + Uint8Array.prototype.set.call( + target, + this.subarray(start, start + len), + targetStart + ); + } + + return len + }; + + // Usage: + // buffer.fill(number[, offset[, end]]) + // buffer.fill(buffer[, offset[, end]]) + // buffer.fill(string[, offset[, end]][, encoding]) + Buffer.prototype.fill = function fill (val, start, end, encoding) { + // Handle string cases: + if (typeof val === 'string') { + if (typeof start === 'string') { + encoding = start; + start = 0; + end = this.length; + } else if (typeof end === 'string') { + encoding = end; + end = this.length; + } + if (val.length === 1) { + var code = val.charCodeAt(0); + if (code < 256) { + val = code; + } + } + if (encoding !== undefined && typeof encoding !== 'string') { + throw new TypeError('encoding must be a string') + } + if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } + } else if (typeof val === 'number') { + val = val & 255; + } + + // Invalid ranges are not set to a default, so can range check early. + if (start < 0 || this.length < start || this.length < end) { + throw new RangeError('Out of range index') + } + + if (end <= start) { + return this + } + + start = start >>> 0; + end = end === undefined ? this.length : end >>> 0; + + if (!val) val = 0; + + var i; + if (typeof val === 'number') { + for (i = start; i < end; ++i) { + this[i] = val; + } + } else { + var bytes = internalIsBuffer(val) + ? val + : utf8ToBytes(new Buffer(val, encoding).toString()); + var len = bytes.length; + for (i = 0; i < end - start; ++i) { + this[i + start] = bytes[i % len]; + } + } + + return this + }; + + // HELPER FUNCTIONS + // ================ + + var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g; + + function base64clean (str) { + // Node strips out invalid characters like \n and \t from the string, base64-js does not + str = stringtrim(str).replace(INVALID_BASE64_RE, ''); + // Node converts strings with length < 2 to '' + if (str.length < 2) return '' + // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not + while (str.length % 4 !== 0) { + str = str + '='; + } + return str + } + + function stringtrim (str) { + if (str.trim) return str.trim() + return str.replace(/^\s+|\s+$/g, '') + } + + function toHex (n) { + if (n < 16) return '0' + n.toString(16) + return n.toString(16) + } + + function utf8ToBytes (string, units) { + units = units || Infinity; + var codePoint; + var length = string.length; + var leadSurrogate = null; + var bytes = []; + + for (var i = 0; i < length; ++i) { + codePoint = string.charCodeAt(i); + + // is surrogate component + if (codePoint > 0xD7FF && codePoint < 0xE000) { + // last char was a lead + if (!leadSurrogate) { + // no lead yet + if (codePoint > 0xDBFF) { + // unexpected trail + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); + continue + } else if (i + 1 === length) { + // unpaired lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); + continue + } + + // valid lead + leadSurrogate = codePoint; + + continue + } + + // 2 leads in a row + if (codePoint < 0xDC00) { + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); + leadSurrogate = codePoint; + continue + } + + // valid surrogate pair + codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000; + } else if (leadSurrogate) { + // valid bmp char, but last char was a lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); + } + + leadSurrogate = null; + + // encode utf8 + if (codePoint < 0x80) { + if ((units -= 1) < 0) break + bytes.push(codePoint); + } else if (codePoint < 0x800) { + if ((units -= 2) < 0) break + bytes.push( + codePoint >> 0x6 | 0xC0, + codePoint & 0x3F | 0x80 + ); + } else if (codePoint < 0x10000) { + if ((units -= 3) < 0) break + bytes.push( + codePoint >> 0xC | 0xE0, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ); + } else if (codePoint < 0x110000) { + if ((units -= 4) < 0) break + bytes.push( + codePoint >> 0x12 | 0xF0, + codePoint >> 0xC & 0x3F | 0x80, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ); + } else { + throw new Error('Invalid code point') + } + } + + return bytes + } + + function asciiToBytes (str) { + var byteArray = []; + for (var i = 0; i < str.length; ++i) { + // Node's code seems to be doing this and not & 0x7F.. + byteArray.push(str.charCodeAt(i) & 0xFF); + } + return byteArray + } + + function utf16leToBytes (str, units) { + var c, hi, lo; + var byteArray = []; + for (var i = 0; i < str.length; ++i) { + if ((units -= 2) < 0) break + + c = str.charCodeAt(i); + hi = c >> 8; + lo = c % 256; + byteArray.push(lo); + byteArray.push(hi); + } + + return byteArray + } + + + function base64ToBytes (str) { + return toByteArray(base64clean(str)) + } + + function blitBuffer (src, dst, offset, length) { + for (var i = 0; i < length; ++i) { + if ((i + offset >= dst.length) || (i >= src.length)) break + dst[i + offset] = src[i]; + } + return i + } + + function isnan (val) { + return val !== val // eslint-disable-line no-self-compare + } + + + // the following is from is-buffer, also by Feross Aboukhadijeh and with same lisence + // The _isBuffer check is for Safari 5-7 support, because it's missing + // Object.prototype.constructor. Remove this eventually + function isBuffer(obj) { + return obj != null && (!!obj._isBuffer || isFastBuffer(obj) || isSlowBuffer(obj)) + } + + function isFastBuffer (obj) { + return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj) + } + + // For Node v0.10 support. Remove this eventually. + function isSlowBuffer (obj) { + return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isFastBuffer(obj.slice(0, 0)) + } + + var buffer = /*#__PURE__*/Object.freeze({ + INSPECT_MAX_BYTES: INSPECT_MAX_BYTES, + kMaxLength: _kMaxLength, + Buffer: Buffer, + SlowBuffer: SlowBuffer, + isBuffer: isBuffer + }); + + var safeBuffer = createCommonjsModule(function (module, exports) { + /* eslint-disable node/no-deprecated-api */ + + var Buffer = buffer.Buffer; + + // alternative to using Object.keys for old browsers + function copyProps (src, dst) { + for (var key in src) { + dst[key] = src[key]; + } + } + if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) { + module.exports = buffer; + } else { + // Copy properties from require('buffer') + copyProps(buffer, exports); + exports.Buffer = SafeBuffer; + } + + function SafeBuffer (arg, encodingOrOffset, length) { + return Buffer(arg, encodingOrOffset, length) + } + + SafeBuffer.prototype = Object.create(Buffer.prototype); + + // Copy static methods from Buffer + copyProps(Buffer, SafeBuffer); + + SafeBuffer.from = function (arg, encodingOrOffset, length) { + if (typeof arg === 'number') { + throw new TypeError('Argument must not be a number') + } + return Buffer(arg, encodingOrOffset, length) + }; + + SafeBuffer.alloc = function (size, fill, encoding) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + var buf = Buffer(size); + if (fill !== undefined) { + if (typeof encoding === 'string') { + buf.fill(fill, encoding); + } else { + buf.fill(fill); + } + } else { + buf.fill(0); + } + return buf + }; + + SafeBuffer.allocUnsafe = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + return Buffer(size) + }; + + SafeBuffer.allocUnsafeSlow = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + return buffer.SlowBuffer(size) + }; + }); + var safeBuffer_1 = safeBuffer.Buffer; + + var domain; + + // This constructor is used to store event handlers. Instantiating this is + // faster than explicitly calling `Object.create(null)` to get a "clean" empty + // object (tested with v8 v4.9). + function EventHandlers() {} + EventHandlers.prototype = Object.create(null); + + function EventEmitter() { + EventEmitter.init.call(this); + } + + // nodejs oddity + // require('events') === require('events').EventEmitter + EventEmitter.EventEmitter = EventEmitter; + + EventEmitter.usingDomains = false; + + EventEmitter.prototype.domain = undefined; + EventEmitter.prototype._events = undefined; + EventEmitter.prototype._maxListeners = undefined; + + // By default EventEmitters will print a warning if more than 10 listeners are + // added to it. This is a useful default which helps finding memory leaks. + EventEmitter.defaultMaxListeners = 10; + + EventEmitter.init = function() { + this.domain = null; + if (EventEmitter.usingDomains) { + // if there is an active domain, then attach to it. + if (domain.active && !(this instanceof domain.Domain)) ; + } + + if (!this._events || this._events === Object.getPrototypeOf(this)._events) { + this._events = new EventHandlers(); + this._eventsCount = 0; + } + + this._maxListeners = this._maxListeners || undefined; + }; + + // Obviously not all Emitters should be limited to 10. This function allows + // that to be increased. Set to zero for unlimited. + EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) { + if (typeof n !== 'number' || n < 0 || isNaN(n)) + throw new TypeError('"n" argument must be a positive number'); + this._maxListeners = n; + return this; + }; + + function $getMaxListeners(that) { + if (that._maxListeners === undefined) + return EventEmitter.defaultMaxListeners; + return that._maxListeners; + } + + EventEmitter.prototype.getMaxListeners = function getMaxListeners() { + return $getMaxListeners(this); + }; + + // These standalone emit* functions are used to optimize calling of event + // handlers for fast cases because emit() itself often has a variable number of + // arguments and can be deoptimized because of that. These functions always have + // the same number of arguments and thus do not get deoptimized, so the code + // inside them can execute faster. + function emitNone(handler, isFn, self) { + if (isFn) + handler.call(self); + else { + var len = handler.length; + var listeners = arrayClone(handler, len); + for (var i = 0; i < len; ++i) + listeners[i].call(self); + } + } + function emitOne(handler, isFn, self, arg1) { + if (isFn) + handler.call(self, arg1); + else { + var len = handler.length; + var listeners = arrayClone(handler, len); + for (var i = 0; i < len; ++i) + listeners[i].call(self, arg1); + } + } + function emitTwo(handler, isFn, self, arg1, arg2) { + if (isFn) + handler.call(self, arg1, arg2); + else { + var len = handler.length; + var listeners = arrayClone(handler, len); + for (var i = 0; i < len; ++i) + listeners[i].call(self, arg1, arg2); + } + } + function emitThree(handler, isFn, self, arg1, arg2, arg3) { + if (isFn) + handler.call(self, arg1, arg2, arg3); + else { + var len = handler.length; + var listeners = arrayClone(handler, len); + for (var i = 0; i < len; ++i) + listeners[i].call(self, arg1, arg2, arg3); + } + } + + function emitMany(handler, isFn, self, args) { + if (isFn) + handler.apply(self, args); + else { + var len = handler.length; + var listeners = arrayClone(handler, len); + for (var i = 0; i < len; ++i) + listeners[i].apply(self, args); + } + } + + EventEmitter.prototype.emit = function emit(type) { + var er, handler, len, args, i, events, domain; + var doError = (type === 'error'); + + events = this._events; + if (events) + doError = (doError && events.error == null); + else if (!doError) + return false; + + domain = this.domain; + + // If there is no 'error' event listener then throw. + if (doError) { + er = arguments[1]; + if (domain) { + if (!er) + er = new Error('Uncaught, unspecified "error" event'); + er.domainEmitter = this; + er.domain = domain; + er.domainThrown = false; + domain.emit('error', er); + } else if (er instanceof Error) { + throw er; // Unhandled 'error' event + } else { + // At least give some kind of context to the user + var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); + err.context = er; + throw err; + } + return false; + } + + handler = events[type]; + + if (!handler) + return false; + + var isFn = typeof handler === 'function'; + len = arguments.length; + switch (len) { + // fast cases + case 1: + emitNone(handler, isFn, this); + break; + case 2: + emitOne(handler, isFn, this, arguments[1]); + break; + case 3: + emitTwo(handler, isFn, this, arguments[1], arguments[2]); + break; + case 4: + emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]); + break; + // slower + default: + args = new Array(len - 1); + for (i = 1; i < len; i++) + args[i - 1] = arguments[i]; + emitMany(handler, isFn, this, args); + } + + return true; + }; + + function _addListener(target, type, listener, prepend) { + var m; + var events; + var existing; + + if (typeof listener !== 'function') + throw new TypeError('"listener" argument must be a function'); + + events = target._events; + if (!events) { + events = target._events = new EventHandlers(); + target._eventsCount = 0; + } else { + // To avoid recursion in the case that type === "newListener"! Before + // adding it to the listeners, first emit "newListener". + if (events.newListener) { + target.emit('newListener', type, + listener.listener ? listener.listener : listener); + + // Re-assign `events` because a newListener handler could have caused the + // this._events to be assigned to a new object + events = target._events; + } + existing = events[type]; + } + + if (!existing) { + // Optimize the case of one listener. Don't need the extra array object. + existing = events[type] = listener; + ++target._eventsCount; + } else { + if (typeof existing === 'function') { + // Adding the second element, need to change to array. + existing = events[type] = prepend ? [listener, existing] : + [existing, listener]; + } else { + // If we've already got an array, just append. + if (prepend) { + existing.unshift(listener); + } else { + existing.push(listener); + } + } + + // Check for listener leak + if (!existing.warned) { + m = $getMaxListeners(target); + if (m && m > 0 && existing.length > m) { + existing.warned = true; + var w = new Error('Possible EventEmitter memory leak detected. ' + + existing.length + ' ' + type + ' listeners added. ' + + 'Use emitter.setMaxListeners() to increase limit'); + w.name = 'MaxListenersExceededWarning'; + w.emitter = target; + w.type = type; + w.count = existing.length; + emitWarning(w); + } + } + } + + return target; + } + function emitWarning(e) { + typeof console.warn === 'function' ? console.warn(e) : console.log(e); + } + EventEmitter.prototype.addListener = function addListener(type, listener) { + return _addListener(this, type, listener, false); + }; + + EventEmitter.prototype.on = EventEmitter.prototype.addListener; + + EventEmitter.prototype.prependListener = + function prependListener(type, listener) { + return _addListener(this, type, listener, true); + }; + + function _onceWrap(target, type, listener) { + var fired = false; + function g() { + target.removeListener(type, g); + if (!fired) { + fired = true; + listener.apply(target, arguments); + } + } + g.listener = listener; + return g; + } + + EventEmitter.prototype.once = function once(type, listener) { + if (typeof listener !== 'function') + throw new TypeError('"listener" argument must be a function'); + this.on(type, _onceWrap(this, type, listener)); + return this; + }; + + EventEmitter.prototype.prependOnceListener = + function prependOnceListener(type, listener) { + if (typeof listener !== 'function') + throw new TypeError('"listener" argument must be a function'); + this.prependListener(type, _onceWrap(this, type, listener)); + return this; + }; + + // emits a 'removeListener' event iff the listener was removed + EventEmitter.prototype.removeListener = + function removeListener(type, listener) { + var list, events, position, i, originalListener; + + if (typeof listener !== 'function') + throw new TypeError('"listener" argument must be a function'); + + events = this._events; + if (!events) + return this; + + list = events[type]; + if (!list) + return this; + + if (list === listener || (list.listener && list.listener === listener)) { + if (--this._eventsCount === 0) + this._events = new EventHandlers(); + else { + delete events[type]; + if (events.removeListener) + this.emit('removeListener', type, list.listener || listener); + } + } else if (typeof list !== 'function') { + position = -1; + + for (i = list.length; i-- > 0;) { + if (list[i] === listener || + (list[i].listener && list[i].listener === listener)) { + originalListener = list[i].listener; + position = i; + break; + } + } + + if (position < 0) + return this; + + if (list.length === 1) { + list[0] = undefined; + if (--this._eventsCount === 0) { + this._events = new EventHandlers(); + return this; + } else { + delete events[type]; + } + } else { + spliceOne(list, position); + } + + if (events.removeListener) + this.emit('removeListener', type, originalListener || listener); + } + + return this; + }; + + EventEmitter.prototype.removeAllListeners = + function removeAllListeners(type) { + var listeners, events; + + events = this._events; + if (!events) + return this; + + // not listening for removeListener, no need to emit + if (!events.removeListener) { + if (arguments.length === 0) { + this._events = new EventHandlers(); + this._eventsCount = 0; + } else if (events[type]) { + if (--this._eventsCount === 0) + this._events = new EventHandlers(); + else + delete events[type]; + } + return this; + } + + // emit removeListener for all listeners on all events + if (arguments.length === 0) { + var keys = Object.keys(events); + for (var i = 0, key; i < keys.length; ++i) { + key = keys[i]; + if (key === 'removeListener') continue; + this.removeAllListeners(key); + } + this.removeAllListeners('removeListener'); + this._events = new EventHandlers(); + this._eventsCount = 0; + return this; + } + + listeners = events[type]; + + if (typeof listeners === 'function') { + this.removeListener(type, listeners); + } else if (listeners) { + // LIFO order + do { + this.removeListener(type, listeners[listeners.length - 1]); + } while (listeners[0]); + } + + return this; + }; + + EventEmitter.prototype.listeners = function listeners(type) { + var evlistener; + var ret; + var events = this._events; + + if (!events) + ret = []; + else { + evlistener = events[type]; + if (!evlistener) + ret = []; + else if (typeof evlistener === 'function') + ret = [evlistener.listener || evlistener]; + else + ret = unwrapListeners(evlistener); + } + + return ret; + }; + + EventEmitter.listenerCount = function(emitter, type) { + if (typeof emitter.listenerCount === 'function') { + return emitter.listenerCount(type); + } else { + return listenerCount.call(emitter, type); + } + }; + + EventEmitter.prototype.listenerCount = listenerCount; + function listenerCount(type) { + var events = this._events; + + if (events) { + var evlistener = events[type]; + + if (typeof evlistener === 'function') { + return 1; + } else if (evlistener) { + return evlistener.length; + } + } + + return 0; + } + + EventEmitter.prototype.eventNames = function eventNames() { + return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : []; + }; + + // About 1.5x faster than the two-arg version of Array#splice(). + function spliceOne(list, index) { + for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) + list[i] = list[k]; + list.pop(); + } + + function arrayClone(arr, i) { + var copy = new Array(i); + while (i--) + copy[i] = arr[i]; + return copy; + } + + function unwrapListeners(arr) { + var ret = new Array(arr.length); + for (var i = 0; i < ret.length; ++i) { + ret[i] = arr[i].listener || arr[i]; + } + return ret; + } + + // shim for using process in browser + // based off https://github.com/defunctzombie/node-process/blob/master/browser.js + + function defaultSetTimout() { + throw new Error('setTimeout has not been defined'); + } + function defaultClearTimeout () { + throw new Error('clearTimeout has not been defined'); + } + var cachedSetTimeout = defaultSetTimout; + var cachedClearTimeout = defaultClearTimeout; + if (typeof global$1.setTimeout === 'function') { + cachedSetTimeout = setTimeout; + } + if (typeof global$1.clearTimeout === 'function') { + cachedClearTimeout = clearTimeout; + } + + function runTimeout(fun) { + if (cachedSetTimeout === setTimeout) { + //normal enviroments in sane situations + return setTimeout(fun, 0); + } + // if setTimeout wasn't available but was latter defined + if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { + cachedSetTimeout = setTimeout; + return setTimeout(fun, 0); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedSetTimeout(fun, 0); + } catch(e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedSetTimeout.call(null, fun, 0); + } catch(e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error + return cachedSetTimeout.call(this, fun, 0); + } + } + + + } + function runClearTimeout(marker) { + if (cachedClearTimeout === clearTimeout) { + //normal enviroments in sane situations + return clearTimeout(marker); + } + // if clearTimeout wasn't available but was latter defined + if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { + cachedClearTimeout = clearTimeout; + return clearTimeout(marker); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedClearTimeout(marker); + } catch (e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedClearTimeout.call(null, marker); + } catch (e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. + // Some versions of I.E. have different rules for clearTimeout vs setTimeout + return cachedClearTimeout.call(this, marker); + } + } + + + + } + var queue$1 = []; + var draining = false; + var currentQueue; + var queueIndex = -1; + + function cleanUpNextTick() { + if (!draining || !currentQueue) { + return; + } + draining = false; + if (currentQueue.length) { + queue$1 = currentQueue.concat(queue$1); + } else { + queueIndex = -1; + } + if (queue$1.length) { + drainQueue(); + } + } + + function drainQueue() { + if (draining) { + return; + } + var timeout = runTimeout(cleanUpNextTick); + draining = true; + + var len = queue$1.length; + while(len) { + currentQueue = queue$1; + queue$1 = []; + while (++queueIndex < len) { + if (currentQueue) { + currentQueue[queueIndex].run(); + } + } + queueIndex = -1; + len = queue$1.length; + } + currentQueue = null; + draining = false; + runClearTimeout(timeout); + } + function nextTick(fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue$1.push(new Item(fun, args)); + if (queue$1.length === 1 && !draining) { + runTimeout(drainQueue); + } + } + // v8 likes predictible objects + function Item(fun, array) { + this.fun = fun; + this.array = array; + } + Item.prototype.run = function () { + this.fun.apply(null, this.array); + }; + var title = 'browser'; + var platform = 'browser'; + var browser = true; + var env = {}; + var argv = []; + var version = ''; // empty string to avoid regexp issues + var versions$1 = {}; + var release = {}; + var config = {}; + + function noop() {} + + var on = noop; + var addListener = noop; + var once = noop; + var off = noop; + var removeListener = noop; + var removeAllListeners = noop; + var emit = noop; + + function binding(name) { + throw new Error('process.binding is not supported'); + } + + function cwd () { return '/' } + function chdir (dir) { + throw new Error('process.chdir is not supported'); + }function umask() { return 0; } + + // from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js + var performance = global$1.performance || {}; + var performanceNow = + performance.now || + performance.mozNow || + performance.msNow || + performance.oNow || + performance.webkitNow || + function(){ return (new Date()).getTime() }; + + // generate timestamp or delta + // see http://nodejs.org/api/process.html#process_process_hrtime + function hrtime(previousTimestamp){ + var clocktime = performanceNow.call(performance)*1e-3; + var seconds = Math.floor(clocktime); + var nanoseconds = Math.floor((clocktime%1)*1e9); + if (previousTimestamp) { + seconds = seconds - previousTimestamp[0]; + nanoseconds = nanoseconds - previousTimestamp[1]; + if (nanoseconds<0) { + seconds--; + nanoseconds += 1e9; + } + } + return [seconds,nanoseconds] + } + + var startTime = new Date(); + function uptime() { + var currentTime = new Date(); + var dif = currentTime - startTime; + return dif / 1000; + } + + var process$3 = { + nextTick: nextTick, + title: title, + browser: browser, + env: env, + argv: argv, + version: version, + versions: versions$1, + on: on, + addListener: addListener, + once: once, + off: off, + removeListener: removeListener, + removeAllListeners: removeAllListeners, + emit: emit, + binding: binding, + cwd: cwd, + chdir: chdir, + umask: umask, + hrtime: hrtime, + platform: platform, + release: release, + config: config, + uptime: uptime + }; + + var inherits$1; + if (typeof Object.create === 'function'){ + inherits$1 = function inherits(ctor, superCtor) { + // implementation from standard node.js 'util' module + ctor.super_ = superCtor; + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); + }; + } else { + inherits$1 = function inherits(ctor, superCtor) { + ctor.super_ = superCtor; + var TempCtor = function () {}; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; + }; + } + var inherits$2 = inherits$1; + + var formatRegExp = /%[sdj%]/g; + function format(f) { + if (!isString(f)) { + var objects = []; + for (var i = 0; i < arguments.length; i++) { + objects.push(inspect(arguments[i])); + } + return objects.join(' '); + } + + var i = 1; + var args = arguments; + var len = args.length; + var str = String(f).replace(formatRegExp, function(x) { + if (x === '%%') return '%'; + if (i >= len) return x; + switch (x) { + case '%s': return String(args[i++]); + case '%d': return Number(args[i++]); + case '%j': + try { + return JSON.stringify(args[i++]); + } catch (_) { + return '[Circular]'; + } + default: + return x; + } + }); + for (var x = args[i]; i < len; x = args[++i]) { + if (isNull(x) || !isObject(x)) { + str += ' ' + x; + } else { + str += ' ' + inspect(x); + } + } + return str; + } + + // Mark that a method should not be used. + // Returns a modified function which warns once by default. + // If --no-deprecation is set, then it is a no-op. + function deprecate(fn, msg) { + // Allow for deprecating things in the process of starting up. + if (isUndefined(global$1.process)) { + return function() { + return deprecate(fn, msg).apply(this, arguments); + }; + } + + var warned = false; + function deprecated() { + if (!warned) { + { + console.error(msg); + } + warned = true; + } + return fn.apply(this, arguments); + } + + return deprecated; + } + + var debugs = {}; + var debugEnviron; + function debuglog(set) { + if (isUndefined(debugEnviron)) + debugEnviron = process$3.env.NODE_DEBUG || ''; + set = set.toUpperCase(); + if (!debugs[set]) { + if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) { + var pid = 0; + debugs[set] = function() { + var msg = format.apply(null, arguments); + console.error('%s %d: %s', set, pid, msg); + }; + } else { + debugs[set] = function() {}; + } + } + return debugs[set]; + } + + /** + * Echos the value of a value. Trys to print the value out + * in the best way possible given the different types. + * + * @param {Object} obj The object to print out. + * @param {Object} opts Optional options object that alters the output. + */ + /* legacy: obj, showHidden, depth, colors*/ + function inspect(obj, opts) { + // default options + var ctx = { + seen: [], + stylize: stylizeNoColor + }; + // legacy... + if (arguments.length >= 3) ctx.depth = arguments[2]; + if (arguments.length >= 4) ctx.colors = arguments[3]; + if (isBoolean(opts)) { + // legacy... + ctx.showHidden = opts; + } else if (opts) { + // got an "options" object + _extend(ctx, opts); + } + // set default options + if (isUndefined(ctx.showHidden)) ctx.showHidden = false; + if (isUndefined(ctx.depth)) ctx.depth = 2; + if (isUndefined(ctx.colors)) ctx.colors = false; + if (isUndefined(ctx.customInspect)) ctx.customInspect = true; + if (ctx.colors) ctx.stylize = stylizeWithColor; + return formatValue(ctx, obj, ctx.depth); + } + + // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics + inspect.colors = { + 'bold' : [1, 22], + 'italic' : [3, 23], + 'underline' : [4, 24], + 'inverse' : [7, 27], + 'white' : [37, 39], + 'grey' : [90, 39], + 'black' : [30, 39], + 'blue' : [34, 39], + 'cyan' : [36, 39], + 'green' : [32, 39], + 'magenta' : [35, 39], + 'red' : [31, 39], + 'yellow' : [33, 39] + }; + + // Don't use 'blue' not visible on cmd.exe + inspect.styles = { + 'special': 'cyan', + 'number': 'yellow', + 'boolean': 'yellow', + 'undefined': 'grey', + 'null': 'bold', + 'string': 'green', + 'date': 'magenta', + // "name": intentionally not styling + 'regexp': 'red' + }; + + + function stylizeWithColor(str, styleType) { + var style = inspect.styles[styleType]; + + if (style) { + return '\u001b[' + inspect.colors[style][0] + 'm' + str + + '\u001b[' + inspect.colors[style][1] + 'm'; + } else { + return str; + } + } + + + function stylizeNoColor(str, styleType) { + return str; + } + + + function arrayToHash(array) { + var hash = {}; + + array.forEach(function(val, idx) { + hash[val] = true; + }); + + return hash; + } + + + function formatValue(ctx, value, recurseTimes) { + // Provide a hook for user-specified inspect functions. + // Check that value is an object with an inspect function on it + if (ctx.customInspect && + value && + isFunction(value.inspect) && + // Filter out the util module, it's inspect function is special + value.inspect !== inspect && + // Also filter out any prototype objects using the circular check. + !(value.constructor && value.constructor.prototype === value)) { + var ret = value.inspect(recurseTimes, ctx); + if (!isString(ret)) { + ret = formatValue(ctx, ret, recurseTimes); + } + return ret; + } + + // Primitive types cannot have properties + var primitive = formatPrimitive(ctx, value); + if (primitive) { + return primitive; + } + + // Look up the keys of the object. + var keys = Object.keys(value); + var visibleKeys = arrayToHash(keys); + + if (ctx.showHidden) { + keys = Object.getOwnPropertyNames(value); + } + + // IE doesn't make error fields non-enumerable + // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx + if (isError(value) + && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) { + return formatError(value); + } + + // Some type of object without properties can be shortcutted. + if (keys.length === 0) { + if (isFunction(value)) { + var name = value.name ? ': ' + value.name : ''; + return ctx.stylize('[Function' + name + ']', 'special'); + } + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + } + if (isDate(value)) { + return ctx.stylize(Date.prototype.toString.call(value), 'date'); + } + if (isError(value)) { + return formatError(value); + } + } + + var base = '', array = false, braces = ['{', '}']; + + // Make Array say that they are Array + if (isArray$1(value)) { + array = true; + braces = ['[', ']']; + } + + // Make functions say that they are functions + if (isFunction(value)) { + var n = value.name ? ': ' + value.name : ''; + base = ' [Function' + n + ']'; + } + + // Make RegExps say that they are RegExps + if (isRegExp(value)) { + base = ' ' + RegExp.prototype.toString.call(value); + } + + // Make dates with properties first say the date + if (isDate(value)) { + base = ' ' + Date.prototype.toUTCString.call(value); + } + + // Make error with message first say the error + if (isError(value)) { + base = ' ' + formatError(value); + } + + if (keys.length === 0 && (!array || value.length == 0)) { + return braces[0] + base + braces[1]; + } + + if (recurseTimes < 0) { + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + } else { + return ctx.stylize('[Object]', 'special'); + } + } + + ctx.seen.push(value); + + var output; + if (array) { + output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); + } else { + output = keys.map(function(key) { + return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); + }); + } + + ctx.seen.pop(); + + return reduceToSingleString(output, base, braces); + } + + + function formatPrimitive(ctx, value) { + if (isUndefined(value)) + return ctx.stylize('undefined', 'undefined'); + if (isString(value)) { + var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') + .replace(/'/g, "\\'") + .replace(/\\"/g, '"') + '\''; + return ctx.stylize(simple, 'string'); + } + if (isNumber(value)) + return ctx.stylize('' + value, 'number'); + if (isBoolean(value)) + return ctx.stylize('' + value, 'boolean'); + // For some reason typeof null is "object", so special case here. + if (isNull(value)) + return ctx.stylize('null', 'null'); + } + + + function formatError(value) { + return '[' + Error.prototype.toString.call(value) + ']'; + } + + + function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { + var output = []; + for (var i = 0, l = value.length; i < l; ++i) { + if (hasOwnProperty$1(value, String(i))) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + String(i), true)); + } else { + output.push(''); + } + } + keys.forEach(function(key) { + if (!key.match(/^\d+$/)) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + key, true)); + } + }); + return output; + } + + + function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { + var name, str, desc; + desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; + if (desc.get) { + if (desc.set) { + str = ctx.stylize('[Getter/Setter]', 'special'); + } else { + str = ctx.stylize('[Getter]', 'special'); + } + } else { + if (desc.set) { + str = ctx.stylize('[Setter]', 'special'); + } + } + if (!hasOwnProperty$1(visibleKeys, key)) { + name = '[' + key + ']'; + } + if (!str) { + if (ctx.seen.indexOf(desc.value) < 0) { + if (isNull(recurseTimes)) { + str = formatValue(ctx, desc.value, null); + } else { + str = formatValue(ctx, desc.value, recurseTimes - 1); + } + if (str.indexOf('\n') > -1) { + if (array) { + str = str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n').substr(2); + } else { + str = '\n' + str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n'); + } + } + } else { + str = ctx.stylize('[Circular]', 'special'); + } + } + if (isUndefined(name)) { + if (array && key.match(/^\d+$/)) { + return str; + } + name = JSON.stringify('' + key); + if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { + name = name.substr(1, name.length - 2); + name = ctx.stylize(name, 'name'); + } else { + name = name.replace(/'/g, "\\'") + .replace(/\\"/g, '"') + .replace(/(^"|"$)/g, "'"); + name = ctx.stylize(name, 'string'); + } + } + + return name + ': ' + str; + } + + + function reduceToSingleString(output, base, braces) { + var length = output.reduce(function(prev, cur) { + if (cur.indexOf('\n') >= 0) ; + return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; + }, 0); + + if (length > 60) { + return braces[0] + + (base === '' ? '' : base + '\n ') + + ' ' + + output.join(',\n ') + + ' ' + + braces[1]; + } + + return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; + } + + + // NOTE: These type checking functions intentionally don't use `instanceof` + // because it is fragile and can be easily faked with `Object.create()`. + function isArray$1(ar) { + return Array.isArray(ar); + } + + function isBoolean(arg) { + return typeof arg === 'boolean'; + } + + function isNull(arg) { + return arg === null; + } + + function isNullOrUndefined(arg) { + return arg == null; + } + + function isNumber(arg) { + return typeof arg === 'number'; + } + + function isString(arg) { + return typeof arg === 'string'; + } + + function isUndefined(arg) { + return arg === void 0; + } + + function isRegExp(re) { + return isObject(re) && objectToString(re) === '[object RegExp]'; + } + + function isObject(arg) { + return typeof arg === 'object' && arg !== null; + } + + function isDate(d) { + return isObject(d) && objectToString(d) === '[object Date]'; + } + + function isError(e) { + return isObject(e) && + (objectToString(e) === '[object Error]' || e instanceof Error); + } + + function isFunction(arg) { + return typeof arg === 'function'; + } + + function objectToString(o) { + return Object.prototype.toString.call(o); + } + + function _extend(origin, add) { + // Don't do anything if add isn't an object + if (!add || !isObject(add)) return origin; + + var keys = Object.keys(add); + var i = keys.length; + while (i--) { + origin[keys[i]] = add[keys[i]]; + } + return origin; + } + function hasOwnProperty$1(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); + } + + function BufferList() { + this.head = null; + this.tail = null; + this.length = 0; + } + + BufferList.prototype.push = function (v) { + var entry = { data: v, next: null }; + if (this.length > 0) this.tail.next = entry;else this.head = entry; + this.tail = entry; + ++this.length; + }; + + BufferList.prototype.unshift = function (v) { + var entry = { data: v, next: this.head }; + if (this.length === 0) this.tail = entry; + this.head = entry; + ++this.length; + }; + + BufferList.prototype.shift = function () { + if (this.length === 0) return; + var ret = this.head.data; + if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next; + --this.length; + return ret; + }; + + BufferList.prototype.clear = function () { + this.head = this.tail = null; + this.length = 0; + }; + + BufferList.prototype.join = function (s) { + if (this.length === 0) return ''; + var p = this.head; + var ret = '' + p.data; + while (p = p.next) { + ret += s + p.data; + }return ret; + }; + + BufferList.prototype.concat = function (n) { + if (this.length === 0) return Buffer.alloc(0); + if (this.length === 1) return this.head.data; + var ret = Buffer.allocUnsafe(n >>> 0); + var p = this.head; + var i = 0; + while (p) { + p.data.copy(ret, i); + i += p.data.length; + p = p.next; + } + return ret; + }; + + // Copyright Joyent, Inc. and other Node contributors. + var isBufferEncoding = Buffer.isEncoding + || function(encoding) { + switch (encoding && encoding.toLowerCase()) { + case 'hex': case 'utf8': case 'utf-8': case 'ascii': case 'binary': case 'base64': case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': case 'raw': return true; + default: return false; + } + }; + + + function assertEncoding(encoding) { + if (encoding && !isBufferEncoding(encoding)) { + throw new Error('Unknown encoding: ' + encoding); + } + } + + // StringDecoder provides an interface for efficiently splitting a series of + // buffers into a series of JS strings without breaking apart multi-byte + // characters. CESU-8 is handled as part of the UTF-8 encoding. + // + // @TODO Handling all encodings inside a single object makes it very difficult + // to reason about this code, so it should be split up in the future. + // @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code + // points as used by CESU-8. + function StringDecoder(encoding) { + this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, ''); + assertEncoding(encoding); + switch (this.encoding) { + case 'utf8': + // CESU-8 represents each of Surrogate Pair by 3-bytes + this.surrogateSize = 3; + break; + case 'ucs2': + case 'utf16le': + // UTF-16 represents each of Surrogate Pair by 2-bytes + this.surrogateSize = 2; + this.detectIncompleteChar = utf16DetectIncompleteChar; + break; + case 'base64': + // Base-64 stores 3 bytes in 4 chars, and pads the remainder. + this.surrogateSize = 3; + this.detectIncompleteChar = base64DetectIncompleteChar; + break; + default: + this.write = passThroughWrite; + return; + } + + // Enough space to store all bytes of a single character. UTF-8 needs 4 + // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate). + this.charBuffer = new Buffer(6); + // Number of bytes received for the current incomplete multi-byte character. + this.charReceived = 0; + // Number of bytes expected for the current incomplete multi-byte character. + this.charLength = 0; + } + + // write decodes the given buffer and returns it as JS string that is + // guaranteed to not contain any partial multi-byte characters. Any partial + // character found at the end of the buffer is buffered up, and will be + // returned when calling write again with the remaining bytes. + // + // Note: Converting a Buffer containing an orphan surrogate to a String + // currently works, but converting a String to a Buffer (via `new Buffer`, or + // Buffer#write) will replace incomplete surrogates with the unicode + // replacement character. See https://codereview.chromium.org/121173009/ . + StringDecoder.prototype.write = function(buffer) { + var charStr = ''; + // if our last write ended with an incomplete multibyte character + while (this.charLength) { + // determine how many remaining bytes this buffer has to offer for this char + var available = (buffer.length >= this.charLength - this.charReceived) ? + this.charLength - this.charReceived : + buffer.length; + + // add the new bytes to the char buffer + buffer.copy(this.charBuffer, this.charReceived, 0, available); + this.charReceived += available; + + if (this.charReceived < this.charLength) { + // still not enough chars in this buffer? wait for more ... + return ''; + } + + // remove bytes belonging to the current character from the buffer + buffer = buffer.slice(available, buffer.length); + + // get the character that was split + charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding); + + // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character + var charCode = charStr.charCodeAt(charStr.length - 1); + if (charCode >= 0xD800 && charCode <= 0xDBFF) { + this.charLength += this.surrogateSize; + charStr = ''; + continue; + } + this.charReceived = this.charLength = 0; + + // if there are no more bytes in this buffer, just emit our char + if (buffer.length === 0) { + return charStr; + } + break; + } + + // determine and set charLength / charReceived + this.detectIncompleteChar(buffer); + + var end = buffer.length; + if (this.charLength) { + // buffer the incomplete character bytes we got + buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end); + end -= this.charReceived; + } + + charStr += buffer.toString(this.encoding, 0, end); + + var end = charStr.length - 1; + var charCode = charStr.charCodeAt(end); + // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character + if (charCode >= 0xD800 && charCode <= 0xDBFF) { + var size = this.surrogateSize; + this.charLength += size; + this.charReceived += size; + this.charBuffer.copy(this.charBuffer, size, 0, size); + buffer.copy(this.charBuffer, 0, 0, size); + return charStr.substring(0, end); + } + + // or just emit the charStr + return charStr; + }; + + // detectIncompleteChar determines if there is an incomplete UTF-8 character at + // the end of the given buffer. If so, it sets this.charLength to the byte + // length that character, and sets this.charReceived to the number of bytes + // that are available for this character. + StringDecoder.prototype.detectIncompleteChar = function(buffer) { + // determine how many bytes we have to check at the end of this buffer + var i = (buffer.length >= 3) ? 3 : buffer.length; + + // Figure out if one of the last i bytes of our buffer announces an + // incomplete char. + for (; i > 0; i--) { + var c = buffer[buffer.length - i]; + + // See http://en.wikipedia.org/wiki/UTF-8#Description + + // 110XXXXX + if (i == 1 && c >> 5 == 0x06) { + this.charLength = 2; + break; + } + + // 1110XXXX + if (i <= 2 && c >> 4 == 0x0E) { + this.charLength = 3; + break; + } + + // 11110XXX + if (i <= 3 && c >> 3 == 0x1E) { + this.charLength = 4; + break; + } + } + this.charReceived = i; + }; + + StringDecoder.prototype.end = function(buffer) { + var res = ''; + if (buffer && buffer.length) + res = this.write(buffer); + + if (this.charReceived) { + var cr = this.charReceived; + var buf = this.charBuffer; + var enc = this.encoding; + res += buf.slice(0, cr).toString(enc); + } + + return res; + }; + + function passThroughWrite(buffer) { + return buffer.toString(this.encoding); + } + + function utf16DetectIncompleteChar(buffer) { + this.charReceived = buffer.length % 2; + this.charLength = this.charReceived ? 2 : 0; + } + + function base64DetectIncompleteChar(buffer) { + this.charReceived = buffer.length % 3; + this.charLength = this.charReceived ? 3 : 0; + } + + var stringDecoder = /*#__PURE__*/Object.freeze({ + StringDecoder: StringDecoder + }); + + Readable.ReadableState = ReadableState; + + var debug = debuglog('stream'); + inherits$2(Readable, EventEmitter); + + function prependListener(emitter, event, fn) { + // Sadly this is not cacheable as some libraries bundle their own + // event emitter implementation with them. + if (typeof emitter.prependListener === 'function') { + return emitter.prependListener(event, fn); + } else { + // This is a hack to make sure that our error handler is attached before any + // userland ones. NEVER DO THIS. This is here only because this code needs + // to continue to work with older versions of Node.js that do not include + // the prependListener() method. The goal is to eventually remove this hack. + if (!emitter._events || !emitter._events[event]) + emitter.on(event, fn); + else if (Array.isArray(emitter._events[event])) + emitter._events[event].unshift(fn); + else + emitter._events[event] = [fn, emitter._events[event]]; + } + } + function listenerCount$1 (emitter, type) { + return emitter.listeners(type).length; + } + function ReadableState(options, stream) { + + options = options || {}; + + // object stream flag. Used to make read(n) ignore n and to + // make all the buffer merging and length checks go away + this.objectMode = !!options.objectMode; + + if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.readableObjectMode; + + // the point at which it stops calling _read() to fill the buffer + // Note: 0 is a valid value, means "don't call _read preemptively ever" + var hwm = options.highWaterMark; + var defaultHwm = this.objectMode ? 16 : 16 * 1024; + this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm; + + // cast to ints. + this.highWaterMark = ~ ~this.highWaterMark; + + // A linked list is used to store data chunks instead of an array because the + // linked list can remove elements from the beginning faster than + // array.shift() + this.buffer = new BufferList(); + this.length = 0; + this.pipes = null; + this.pipesCount = 0; + this.flowing = null; + this.ended = false; + this.endEmitted = false; + this.reading = false; + + // a flag to be able to tell if the onwrite cb is called immediately, + // or on a later tick. We set this to true at first, because any + // actions that shouldn't happen until "later" should generally also + // not happen before the first write call. + this.sync = true; + + // whenever we return null, then we set a flag to say + // that we're awaiting a 'readable' event emission. + this.needReadable = false; + this.emittedReadable = false; + this.readableListening = false; + this.resumeScheduled = false; + + // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + this.defaultEncoding = options.defaultEncoding || 'utf8'; + + // when piping, we only care about 'readable' events that happen + // after read()ing all the bytes and not getting any pushback. + this.ranOut = false; + + // the number of writers that are awaiting a drain event in .pipe()s + this.awaitDrain = 0; + + // if true, a maybeReadMore has been scheduled + this.readingMore = false; + + this.decoder = null; + this.encoding = null; + if (options.encoding) { + this.decoder = new StringDecoder(options.encoding); + this.encoding = options.encoding; + } + } + function Readable(options) { + + if (!(this instanceof Readable)) return new Readable(options); + + this._readableState = new ReadableState(options, this); + + // legacy + this.readable = true; + + if (options && typeof options.read === 'function') this._read = options.read; + + EventEmitter.call(this); + } + + // Manually shove something into the read() buffer. + // This returns true if the highWaterMark has not been hit yet, + // similar to how Writable.write() returns true if you should + // write() some more. + Readable.prototype.push = function (chunk, encoding) { + var state = this._readableState; + + if (!state.objectMode && typeof chunk === 'string') { + encoding = encoding || state.defaultEncoding; + if (encoding !== state.encoding) { + chunk = Buffer.from(chunk, encoding); + encoding = ''; + } + } + + return readableAddChunk(this, state, chunk, encoding, false); + }; + + // Unshift should *always* be something directly out of read() + Readable.prototype.unshift = function (chunk) { + var state = this._readableState; + return readableAddChunk(this, state, chunk, '', true); + }; + + Readable.prototype.isPaused = function () { + return this._readableState.flowing === false; + }; + + function readableAddChunk(stream, state, chunk, encoding, addToFront) { + var er = chunkInvalid(state, chunk); + if (er) { + stream.emit('error', er); + } else if (chunk === null) { + state.reading = false; + onEofChunk(stream, state); + } else if (state.objectMode || chunk && chunk.length > 0) { + if (state.ended && !addToFront) { + var e = new Error('stream.push() after EOF'); + stream.emit('error', e); + } else if (state.endEmitted && addToFront) { + var _e = new Error('stream.unshift() after end event'); + stream.emit('error', _e); + } else { + var skipAdd; + if (state.decoder && !addToFront && !encoding) { + chunk = state.decoder.write(chunk); + skipAdd = !state.objectMode && chunk.length === 0; + } + + if (!addToFront) state.reading = false; + + // Don't add to the buffer if we've decoded to an empty string chunk and + // we're not in object mode + if (!skipAdd) { + // if we want the data now, just emit it. + if (state.flowing && state.length === 0 && !state.sync) { + stream.emit('data', chunk); + stream.read(0); + } else { + // update the buffer info. + state.length += state.objectMode ? 1 : chunk.length; + if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); + + if (state.needReadable) emitReadable(stream); + } + } + + maybeReadMore(stream, state); + } + } else if (!addToFront) { + state.reading = false; + } + + return needMoreData(state); + } + + // if it's past the high water mark, we can push in some more. + // Also, if we have no data yet, we can stand some + // more bytes. This is to work around cases where hwm=0, + // such as the repl. Also, if the push() triggered a + // readable event, and the user called read(largeNumber) such that + // needReadable was set, then we ought to push more, so that another + // 'readable' event will be triggered. + function needMoreData(state) { + return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0); + } + + // backwards compatibility. + Readable.prototype.setEncoding = function (enc) { + this._readableState.decoder = new StringDecoder(enc); + this._readableState.encoding = enc; + return this; + }; + + // Don't raise the hwm > 8MB + var MAX_HWM = 0x800000; + function computeNewHighWaterMark(n) { + if (n >= MAX_HWM) { + n = MAX_HWM; + } else { + // Get the next highest power of 2 to prevent increasing hwm excessively in + // tiny amounts + n--; + n |= n >>> 1; + n |= n >>> 2; + n |= n >>> 4; + n |= n >>> 8; + n |= n >>> 16; + n++; + } + return n; + } + + // This function is designed to be inlinable, so please take care when making + // changes to the function body. + function howMuchToRead(n, state) { + if (n <= 0 || state.length === 0 && state.ended) return 0; + if (state.objectMode) return 1; + if (n !== n) { + // Only flow one buffer at a time + if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length; + } + // If we're asking for more than the current hwm, then raise the hwm. + if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n); + if (n <= state.length) return n; + // Don't have enough + if (!state.ended) { + state.needReadable = true; + return 0; + } + return state.length; + } + + // you can override either this method, or the async _read(n) below. + Readable.prototype.read = function (n) { + debug('read', n); + n = parseInt(n, 10); + var state = this._readableState; + var nOrig = n; + + if (n !== 0) state.emittedReadable = false; + + // if we're doing read(0) to trigger a readable event, but we + // already have a bunch of data in the buffer, then just trigger + // the 'readable' event and move on. + if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) { + debug('read: emitReadable', state.length, state.ended); + if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this); + return null; + } + + n = howMuchToRead(n, state); + + // if we've ended, and we're now clear, then finish it up. + if (n === 0 && state.ended) { + if (state.length === 0) endReadable(this); + return null; + } + + // All the actual chunk generation logic needs to be + // *below* the call to _read. The reason is that in certain + // synthetic stream cases, such as passthrough streams, _read + // may be a completely synchronous operation which may change + // the state of the read buffer, providing enough data when + // before there was *not* enough. + // + // So, the steps are: + // 1. Figure out what the state of things will be after we do + // a read from the buffer. + // + // 2. If that resulting state will trigger a _read, then call _read. + // Note that this may be asynchronous, or synchronous. Yes, it is + // deeply ugly to write APIs this way, but that still doesn't mean + // that the Readable class should behave improperly, as streams are + // designed to be sync/async agnostic. + // Take note if the _read call is sync or async (ie, if the read call + // has returned yet), so that we know whether or not it's safe to emit + // 'readable' etc. + // + // 3. Actually pull the requested chunks out of the buffer and return. + + // if we need a readable event, then we need to do some reading. + var doRead = state.needReadable; + debug('need readable', doRead); + + // if we currently have less than the highWaterMark, then also read some + if (state.length === 0 || state.length - n < state.highWaterMark) { + doRead = true; + debug('length less than watermark', doRead); + } + + // however, if we've ended, then there's no point, and if we're already + // reading, then it's unnecessary. + if (state.ended || state.reading) { + doRead = false; + debug('reading or ended', doRead); + } else if (doRead) { + debug('do read'); + state.reading = true; + state.sync = true; + // if the length is currently zero, then we *need* a readable event. + if (state.length === 0) state.needReadable = true; + // call internal read method + this._read(state.highWaterMark); + state.sync = false; + // If _read pushed data synchronously, then `reading` will be false, + // and we need to re-evaluate how much data we can return to the user. + if (!state.reading) n = howMuchToRead(nOrig, state); + } + + var ret; + if (n > 0) ret = fromList(n, state);else ret = null; + + if (ret === null) { + state.needReadable = true; + n = 0; + } else { + state.length -= n; + } + + if (state.length === 0) { + // If we have nothing in the buffer, then we want to know + // as soon as we *do* get something into the buffer. + if (!state.ended) state.needReadable = true; + + // If we tried to read() past the EOF, then emit end on the next tick. + if (nOrig !== n && state.ended) endReadable(this); + } + + if (ret !== null) this.emit('data', ret); + + return ret; + }; + + function chunkInvalid(state, chunk) { + var er = null; + if (!isBuffer(chunk) && typeof chunk !== 'string' && chunk !== null && chunk !== undefined && !state.objectMode) { + er = new TypeError('Invalid non-string/buffer chunk'); + } + return er; + } + + function onEofChunk(stream, state) { + if (state.ended) return; + if (state.decoder) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) { + state.buffer.push(chunk); + state.length += state.objectMode ? 1 : chunk.length; + } + } + state.ended = true; + + // emit 'readable' now to make sure it gets picked up. + emitReadable(stream); + } + + // Don't emit readable right away in sync mode, because this can trigger + // another read() call => stack overflow. This way, it might trigger + // a nextTick recursion warning, but that's not so bad. + function emitReadable(stream) { + var state = stream._readableState; + state.needReadable = false; + if (!state.emittedReadable) { + debug('emitReadable', state.flowing); + state.emittedReadable = true; + if (state.sync) nextTick(emitReadable_, stream);else emitReadable_(stream); + } + } + + function emitReadable_(stream) { + debug('emit readable'); + stream.emit('readable'); + flow(stream); + } + + // at this point, the user has presumably seen the 'readable' event, + // and called read() to consume some data. that may have triggered + // in turn another _read(n) call, in which case reading = true if + // it's in progress. + // However, if we're not ended, or reading, and the length < hwm, + // then go ahead and try to read some more preemptively. + function maybeReadMore(stream, state) { + if (!state.readingMore) { + state.readingMore = true; + nextTick(maybeReadMore_, stream, state); + } + } + + function maybeReadMore_(stream, state) { + var len = state.length; + while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) { + debug('maybeReadMore read 0'); + stream.read(0); + if (len === state.length) + // didn't get any data, stop spinning. + break;else len = state.length; + } + state.readingMore = false; + } + + // abstract method. to be overridden in specific implementation classes. + // call cb(er, data) where data is <= n in length. + // for virtual (non-string, non-buffer) streams, "length" is somewhat + // arbitrary, and perhaps not very meaningful. + Readable.prototype._read = function (n) { + this.emit('error', new Error('not implemented')); + }; + + Readable.prototype.pipe = function (dest, pipeOpts) { + var src = this; + var state = this._readableState; + + switch (state.pipesCount) { + case 0: + state.pipes = dest; + break; + case 1: + state.pipes = [state.pipes, dest]; + break; + default: + state.pipes.push(dest); + break; + } + state.pipesCount += 1; + debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts); + + var doEnd = (!pipeOpts || pipeOpts.end !== false); + + var endFn = doEnd ? onend : cleanup; + if (state.endEmitted) nextTick(endFn);else src.once('end', endFn); + + dest.on('unpipe', onunpipe); + function onunpipe(readable) { + debug('onunpipe'); + if (readable === src) { + cleanup(); + } + } + + function onend() { + debug('onend'); + dest.end(); + } + + // when the dest drains, it reduces the awaitDrain counter + // on the source. This would be more elegant with a .once() + // handler in flow(), but adding and removing repeatedly is + // too slow. + var ondrain = pipeOnDrain(src); + dest.on('drain', ondrain); + + var cleanedUp = false; + function cleanup() { + debug('cleanup'); + // cleanup event handlers once the pipe is broken + dest.removeListener('close', onclose); + dest.removeListener('finish', onfinish); + dest.removeListener('drain', ondrain); + dest.removeListener('error', onerror); + dest.removeListener('unpipe', onunpipe); + src.removeListener('end', onend); + src.removeListener('end', cleanup); + src.removeListener('data', ondata); + + cleanedUp = true; + + // if the reader is waiting for a drain event from this + // specific writer, then it would cause it to never start + // flowing again. + // So, if this is awaiting a drain, then we just call it now. + // If we don't know, then assume that we are waiting for one. + if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain(); + } + + // If the user pushes more data while we're writing to dest then we'll end up + // in ondata again. However, we only want to increase awaitDrain once because + // dest will only emit one 'drain' event for the multiple writes. + // => Introduce a guard on increasing awaitDrain. + var increasedAwaitDrain = false; + src.on('data', ondata); + function ondata(chunk) { + debug('ondata'); + increasedAwaitDrain = false; + var ret = dest.write(chunk); + if (false === ret && !increasedAwaitDrain) { + // If the user unpiped during `dest.write()`, it is possible + // to get stuck in a permanently paused state if that write + // also returned false. + // => Check whether `dest` is still a piping destination. + if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) { + debug('false write response, pause', src._readableState.awaitDrain); + src._readableState.awaitDrain++; + increasedAwaitDrain = true; + } + src.pause(); + } + } + + // if the dest has an error, then stop piping into it. + // however, don't suppress the throwing behavior for this. + function onerror(er) { + debug('onerror', er); + unpipe(); + dest.removeListener('error', onerror); + if (listenerCount$1(dest, 'error') === 0) dest.emit('error', er); + } + + // Make sure our error handler is attached before userland ones. + prependListener(dest, 'error', onerror); + + // Both close and finish should trigger unpipe, but only once. + function onclose() { + dest.removeListener('finish', onfinish); + unpipe(); + } + dest.once('close', onclose); + function onfinish() { + debug('onfinish'); + dest.removeListener('close', onclose); + unpipe(); + } + dest.once('finish', onfinish); + + function unpipe() { + debug('unpipe'); + src.unpipe(dest); + } + + // tell the dest that it's being piped to + dest.emit('pipe', src); + + // start the flow if it hasn't been started already. + if (!state.flowing) { + debug('pipe resume'); + src.resume(); + } + + return dest; + }; + + function pipeOnDrain(src) { + return function () { + var state = src._readableState; + debug('pipeOnDrain', state.awaitDrain); + if (state.awaitDrain) state.awaitDrain--; + if (state.awaitDrain === 0 && src.listeners('data').length) { + state.flowing = true; + flow(src); + } + }; + } + + Readable.prototype.unpipe = function (dest) { + var state = this._readableState; + + // if we're not piping anywhere, then do nothing. + if (state.pipesCount === 0) return this; + + // just one destination. most common case. + if (state.pipesCount === 1) { + // passed in one, but it's not the right one. + if (dest && dest !== state.pipes) return this; + + if (!dest) dest = state.pipes; + + // got a match. + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + if (dest) dest.emit('unpipe', this); + return this; + } + + // slow case. multiple pipe destinations. + + if (!dest) { + // remove all. + var dests = state.pipes; + var len = state.pipesCount; + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + + for (var _i = 0; _i < len; _i++) { + dests[_i].emit('unpipe', this); + }return this; + } + + // try to find the right one. + var i = indexOf(state.pipes, dest); + if (i === -1) return this; + + state.pipes.splice(i, 1); + state.pipesCount -= 1; + if (state.pipesCount === 1) state.pipes = state.pipes[0]; + + dest.emit('unpipe', this); + + return this; + }; + + // set up data events if they are asked for + // Ensure readable listeners eventually get something + Readable.prototype.on = function (ev, fn) { + var res = EventEmitter.prototype.on.call(this, ev, fn); + + if (ev === 'data') { + // Start flowing on next tick if stream isn't explicitly paused + if (this._readableState.flowing !== false) this.resume(); + } else if (ev === 'readable') { + var state = this._readableState; + if (!state.endEmitted && !state.readableListening) { + state.readableListening = state.needReadable = true; + state.emittedReadable = false; + if (!state.reading) { + nextTick(nReadingNextTick, this); + } else if (state.length) { + emitReadable(this, state); + } + } + } + + return res; + }; + Readable.prototype.addListener = Readable.prototype.on; + + function nReadingNextTick(self) { + debug('readable nexttick read 0'); + self.read(0); + } + + // pause() and resume() are remnants of the legacy readable stream API + // If the user uses them, then switch into old mode. + Readable.prototype.resume = function () { + var state = this._readableState; + if (!state.flowing) { + debug('resume'); + state.flowing = true; + resume(this, state); + } + return this; + }; + + function resume(stream, state) { + if (!state.resumeScheduled) { + state.resumeScheduled = true; + nextTick(resume_, stream, state); + } + } + + function resume_(stream, state) { + if (!state.reading) { + debug('resume read 0'); + stream.read(0); + } + + state.resumeScheduled = false; + state.awaitDrain = 0; + stream.emit('resume'); + flow(stream); + if (state.flowing && !state.reading) stream.read(0); + } + + Readable.prototype.pause = function () { + debug('call pause flowing=%j', this._readableState.flowing); + if (false !== this._readableState.flowing) { + debug('pause'); + this._readableState.flowing = false; + this.emit('pause'); + } + return this; + }; + + function flow(stream) { + var state = stream._readableState; + debug('flow', state.flowing); + while (state.flowing && stream.read() !== null) {} + } + + // wrap an old-style stream as the async data source. + // This is *not* part of the readable stream interface. + // It is an ugly unfortunate mess of history. + Readable.prototype.wrap = function (stream) { + var state = this._readableState; + var paused = false; + + var self = this; + stream.on('end', function () { + debug('wrapped end'); + if (state.decoder && !state.ended) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) self.push(chunk); + } + + self.push(null); + }); + + stream.on('data', function (chunk) { + debug('wrapped data'); + if (state.decoder) chunk = state.decoder.write(chunk); + + // don't skip over falsy values in objectMode + if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return; + + var ret = self.push(chunk); + if (!ret) { + paused = true; + stream.pause(); + } + }); + + // proxy all the other methods. + // important when wrapping filters and duplexes. + for (var i in stream) { + if (this[i] === undefined && typeof stream[i] === 'function') { + this[i] = function (method) { + return function () { + return stream[method].apply(stream, arguments); + }; + }(i); + } + } + + // proxy certain important events. + var events = ['error', 'close', 'destroy', 'pause', 'resume']; + forEach(events, function (ev) { + stream.on(ev, self.emit.bind(self, ev)); + }); + + // when we try to consume some more bytes, simply unpause the + // underlying stream. + self._read = function (n) { + debug('wrapped _read', n); + if (paused) { + paused = false; + stream.resume(); + } + }; + + return self; + }; + + // exposed for testing purposes only. + Readable._fromList = fromList; + + // Pluck off n bytes from an array of buffers. + // Length is the combined lengths of all the buffers in the list. + // This function is designed to be inlinable, so please take care when making + // changes to the function body. + function fromList(n, state) { + // nothing buffered + if (state.length === 0) return null; + + var ret; + if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) { + // read it all, truncate the list + if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length); + state.buffer.clear(); + } else { + // read part of list + ret = fromListPartial(n, state.buffer, state.decoder); + } + + return ret; + } + + // Extracts only enough buffered data to satisfy the amount requested. + // This function is designed to be inlinable, so please take care when making + // changes to the function body. + function fromListPartial(n, list, hasStrings) { + var ret; + if (n < list.head.data.length) { + // slice is the same for buffers and strings + ret = list.head.data.slice(0, n); + list.head.data = list.head.data.slice(n); + } else if (n === list.head.data.length) { + // first chunk is a perfect match + ret = list.shift(); + } else { + // result spans more than one buffer + ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list); + } + return ret; + } + + // Copies a specified amount of characters from the list of buffered data + // chunks. + // This function is designed to be inlinable, so please take care when making + // changes to the function body. + function copyFromBufferString(n, list) { + var p = list.head; + var c = 1; + var ret = p.data; + n -= ret.length; + while (p = p.next) { + var str = p.data; + var nb = n > str.length ? str.length : n; + if (nb === str.length) ret += str;else ret += str.slice(0, n); + n -= nb; + if (n === 0) { + if (nb === str.length) { + ++c; + if (p.next) list.head = p.next;else list.head = list.tail = null; + } else { + list.head = p; + p.data = str.slice(nb); + } + break; + } + ++c; + } + list.length -= c; + return ret; + } + + // Copies a specified amount of bytes from the list of buffered data chunks. + // This function is designed to be inlinable, so please take care when making + // changes to the function body. + function copyFromBuffer(n, list) { + var ret = Buffer.allocUnsafe(n); + var p = list.head; + var c = 1; + p.data.copy(ret); + n -= p.data.length; + while (p = p.next) { + var buf = p.data; + var nb = n > buf.length ? buf.length : n; + buf.copy(ret, ret.length - n, 0, nb); + n -= nb; + if (n === 0) { + if (nb === buf.length) { + ++c; + if (p.next) list.head = p.next;else list.head = list.tail = null; + } else { + list.head = p; + p.data = buf.slice(nb); + } + break; + } + ++c; + } + list.length -= c; + return ret; + } + + function endReadable(stream) { + var state = stream._readableState; + + // If we get here before consuming all the bytes, then that is a + // bug in node. Should never happen. + if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream'); + + if (!state.endEmitted) { + state.ended = true; + nextTick(endReadableNT, state, stream); + } + } + + function endReadableNT(state, stream) { + // Check that we didn't get one last unshift. + if (!state.endEmitted && state.length === 0) { + state.endEmitted = true; + stream.readable = false; + stream.emit('end'); + } + } + + function forEach(xs, f) { + for (var i = 0, l = xs.length; i < l; i++) { + f(xs[i], i); + } + } + + function indexOf(xs, x) { + for (var i = 0, l = xs.length; i < l; i++) { + if (xs[i] === x) return i; + } + return -1; + } + + // A bit simpler than readable streams. + Writable.WritableState = WritableState; + inherits$2(Writable, EventEmitter); + + function nop() {} + + function WriteReq(chunk, encoding, cb) { + this.chunk = chunk; + this.encoding = encoding; + this.callback = cb; + this.next = null; + } + + function WritableState(options, stream) { + Object.defineProperty(this, 'buffer', { + get: deprecate(function () { + return this.getBuffer(); + }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.') + }); + options = options || {}; + + // object stream flag to indicate whether or not this stream + // contains buffers or objects. + this.objectMode = !!options.objectMode; + + if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.writableObjectMode; + + // the point at which write() starts returning false + // Note: 0 is a valid value, means that we always return false if + // the entire buffer is not flushed immediately on write() + var hwm = options.highWaterMark; + var defaultHwm = this.objectMode ? 16 : 16 * 1024; + this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm; + + // cast to ints. + this.highWaterMark = ~ ~this.highWaterMark; + + this.needDrain = false; + // at the start of calling end() + this.ending = false; + // when end() has been called, and returned + this.ended = false; + // when 'finish' is emitted + this.finished = false; + + // should we decode strings into buffers before passing to _write? + // this is here so that some node-core streams can optimize string + // handling at a lower level. + var noDecode = options.decodeStrings === false; + this.decodeStrings = !noDecode; + + // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + this.defaultEncoding = options.defaultEncoding || 'utf8'; + + // not an actual buffer we keep track of, but a measurement + // of how much we're waiting to get pushed to some underlying + // socket or file. + this.length = 0; + + // a flag to see when we're in the middle of a write. + this.writing = false; + + // when true all writes will be buffered until .uncork() call + this.corked = 0; + + // a flag to be able to tell if the onwrite cb is called immediately, + // or on a later tick. We set this to true at first, because any + // actions that shouldn't happen until "later" should generally also + // not happen before the first write call. + this.sync = true; + + // a flag to know if we're processing previously buffered items, which + // may call the _write() callback in the same tick, so that we don't + // end up in an overlapped onwrite situation. + this.bufferProcessing = false; + + // the callback that's passed to _write(chunk,cb) + this.onwrite = function (er) { + onwrite(stream, er); + }; + + // the callback that the user supplies to write(chunk,encoding,cb) + this.writecb = null; + + // the amount that is being written when _write is called. + this.writelen = 0; + + this.bufferedRequest = null; + this.lastBufferedRequest = null; + + // number of pending user-supplied write callbacks + // this must be 0 before 'finish' can be emitted + this.pendingcb = 0; + + // emit prefinish if the only thing we're waiting for is _write cbs + // This is relevant for synchronous Transform streams + this.prefinished = false; + + // True if the error was already emitted and should not be thrown again + this.errorEmitted = false; + + // count buffered requests + this.bufferedRequestCount = 0; + + // allocate the first CorkedRequest, there is always + // one allocated and free to use, and we maintain at most two + this.corkedRequestsFree = new CorkedRequest(this); + } + + WritableState.prototype.getBuffer = function writableStateGetBuffer() { + var current = this.bufferedRequest; + var out = []; + while (current) { + out.push(current); + current = current.next; + } + return out; + }; + function Writable(options) { + + // Writable ctor is applied to Duplexes, though they're not + // instanceof Writable, they're instanceof Readable. + if (!(this instanceof Writable) && !(this instanceof Duplex)) return new Writable(options); + + this._writableState = new WritableState(options, this); + + // legacy. + this.writable = true; + + if (options) { + if (typeof options.write === 'function') this._write = options.write; + + if (typeof options.writev === 'function') this._writev = options.writev; + } + + EventEmitter.call(this); + } + + // Otherwise people can pipe Writable streams, which is just wrong. + Writable.prototype.pipe = function () { + this.emit('error', new Error('Cannot pipe, not readable')); + }; + + function writeAfterEnd(stream, cb) { + var er = new Error('write after end'); + // TODO: defer error events consistently everywhere, not just the cb + stream.emit('error', er); + nextTick(cb, er); + } + + // If we get something that is not a buffer, string, null, or undefined, + // and we're not in objectMode, then that's an error. + // Otherwise stream chunks are all considered to be of length=1, and the + // watermarks determine how many objects to keep in the buffer, rather than + // how many bytes or characters. + function validChunk(stream, state, chunk, cb) { + var valid = true; + var er = false; + // Always throw error if a null is written + // if we are not in object mode then throw + // if it is not a buffer, string, or undefined. + if (chunk === null) { + er = new TypeError('May not write null values to stream'); + } else if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { + er = new TypeError('Invalid non-string/buffer chunk'); + } + if (er) { + stream.emit('error', er); + nextTick(cb, er); + valid = false; + } + return valid; + } + + Writable.prototype.write = function (chunk, encoding, cb) { + var state = this._writableState; + var ret = false; + + if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } + + if (Buffer.isBuffer(chunk)) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding; + + if (typeof cb !== 'function') cb = nop; + + if (state.ended) writeAfterEnd(this, cb);else if (validChunk(this, state, chunk, cb)) { + state.pendingcb++; + ret = writeOrBuffer(this, state, chunk, encoding, cb); + } + + return ret; + }; + + Writable.prototype.cork = function () { + var state = this._writableState; + + state.corked++; + }; + + Writable.prototype.uncork = function () { + var state = this._writableState; + + if (state.corked) { + state.corked--; + + if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); + } + }; + + Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { + // node::ParseEncoding() requires lower case. + if (typeof encoding === 'string') encoding = encoding.toLowerCase(); + if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding); + this._writableState.defaultEncoding = encoding; + return this; + }; + + function decodeChunk(state, chunk, encoding) { + if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') { + chunk = Buffer.from(chunk, encoding); + } + return chunk; + } + + // if we're already writing something, then just put this + // in the queue, and wait our turn. Otherwise, call _write + // If we return false, then we need a drain event, so set that flag. + function writeOrBuffer(stream, state, chunk, encoding, cb) { + chunk = decodeChunk(state, chunk, encoding); + + if (Buffer.isBuffer(chunk)) encoding = 'buffer'; + var len = state.objectMode ? 1 : chunk.length; + + state.length += len; + + var ret = state.length < state.highWaterMark; + // we must ensure that previous needDrain will not be reset to false. + if (!ret) state.needDrain = true; + + if (state.writing || state.corked) { + var last = state.lastBufferedRequest; + state.lastBufferedRequest = new WriteReq(chunk, encoding, cb); + if (last) { + last.next = state.lastBufferedRequest; + } else { + state.bufferedRequest = state.lastBufferedRequest; + } + state.bufferedRequestCount += 1; + } else { + doWrite(stream, state, false, len, chunk, encoding, cb); + } + + return ret; + } + + function doWrite(stream, state, writev, len, chunk, encoding, cb) { + state.writelen = len; + state.writecb = cb; + state.writing = true; + state.sync = true; + if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite); + state.sync = false; + } + + function onwriteError(stream, state, sync, er, cb) { + --state.pendingcb; + if (sync) nextTick(cb, er);else cb(er); + + stream._writableState.errorEmitted = true; + stream.emit('error', er); + } + + function onwriteStateUpdate(state) { + state.writing = false; + state.writecb = null; + state.length -= state.writelen; + state.writelen = 0; + } + + function onwrite(stream, er) { + var state = stream._writableState; + var sync = state.sync; + var cb = state.writecb; + + onwriteStateUpdate(state); + + if (er) onwriteError(stream, state, sync, er, cb);else { + // Check if we're actually ready to finish, but don't emit yet + var finished = needFinish(state); + + if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) { + clearBuffer(stream, state); + } + + if (sync) { + /**/ + nextTick(afterWrite, stream, state, finished, cb); + /**/ + } else { + afterWrite(stream, state, finished, cb); + } + } + } + + function afterWrite(stream, state, finished, cb) { + if (!finished) onwriteDrain(stream, state); + state.pendingcb--; + cb(); + finishMaybe(stream, state); + } + + // Must force callback to be called on nextTick, so that we don't + // emit 'drain' before the write() consumer gets the 'false' return + // value, and has a chance to attach a 'drain' listener. + function onwriteDrain(stream, state) { + if (state.length === 0 && state.needDrain) { + state.needDrain = false; + stream.emit('drain'); + } + } + + // if there's something in the buffer waiting, then process it + function clearBuffer(stream, state) { + state.bufferProcessing = true; + var entry = state.bufferedRequest; + + if (stream._writev && entry && entry.next) { + // Fast case, write everything using _writev() + var l = state.bufferedRequestCount; + var buffer = new Array(l); + var holder = state.corkedRequestsFree; + holder.entry = entry; + + var count = 0; + while (entry) { + buffer[count] = entry; + entry = entry.next; + count += 1; + } + + doWrite(stream, state, true, state.length, buffer, '', holder.finish); + + // doWrite is almost always async, defer these to save a bit of time + // as the hot path ends with doWrite + state.pendingcb++; + state.lastBufferedRequest = null; + if (holder.next) { + state.corkedRequestsFree = holder.next; + holder.next = null; + } else { + state.corkedRequestsFree = new CorkedRequest(state); + } + } else { + // Slow case, write chunks one-by-one + while (entry) { + var chunk = entry.chunk; + var encoding = entry.encoding; + var cb = entry.callback; + var len = state.objectMode ? 1 : chunk.length; + + doWrite(stream, state, false, len, chunk, encoding, cb); + entry = entry.next; + // if we didn't call the onwrite immediately, then + // it means that we need to wait until it does. + // also, that means that the chunk and cb are currently + // being processed, so move the buffer counter past them. + if (state.writing) { + break; + } + } + + if (entry === null) state.lastBufferedRequest = null; + } + + state.bufferedRequestCount = 0; + state.bufferedRequest = entry; + state.bufferProcessing = false; + } + + Writable.prototype._write = function (chunk, encoding, cb) { + cb(new Error('not implemented')); + }; + + Writable.prototype._writev = null; + + Writable.prototype.end = function (chunk, encoding, cb) { + var state = this._writableState; + + if (typeof chunk === 'function') { + cb = chunk; + chunk = null; + encoding = null; + } else if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } + + if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); + + // .end() fully uncorks + if (state.corked) { + state.corked = 1; + this.uncork(); + } + + // ignore unnecessary end() calls. + if (!state.ending && !state.finished) endWritable(this, state, cb); + }; + + function needFinish(state) { + return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; + } + + function prefinish(stream, state) { + if (!state.prefinished) { + state.prefinished = true; + stream.emit('prefinish'); + } + } + + function finishMaybe(stream, state) { + var need = needFinish(state); + if (need) { + if (state.pendingcb === 0) { + prefinish(stream, state); + state.finished = true; + stream.emit('finish'); + } else { + prefinish(stream, state); + } + } + return need; + } + + function endWritable(stream, state, cb) { + state.ending = true; + finishMaybe(stream, state); + if (cb) { + if (state.finished) nextTick(cb);else stream.once('finish', cb); + } + state.ended = true; + stream.writable = false; + } + + // It seems a linked list but it is not + // there will be only 2 of these for each stream + function CorkedRequest(state) { + var _this = this; + + this.next = null; + this.entry = null; + + this.finish = function (err) { + var entry = _this.entry; + _this.entry = null; + while (entry) { + var cb = entry.callback; + state.pendingcb--; + cb(err); + entry = entry.next; + } + if (state.corkedRequestsFree) { + state.corkedRequestsFree.next = _this; + } else { + state.corkedRequestsFree = _this; + } + }; + } + + inherits$2(Duplex, Readable); + + var keys$2 = Object.keys(Writable.prototype); + for (var v = 0; v < keys$2.length; v++) { + var method = keys$2[v]; + if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; + } + function Duplex(options) { + if (!(this instanceof Duplex)) return new Duplex(options); + + Readable.call(this, options); + Writable.call(this, options); + + if (options && options.readable === false) this.readable = false; + + if (options && options.writable === false) this.writable = false; + + this.allowHalfOpen = true; + if (options && options.allowHalfOpen === false) this.allowHalfOpen = false; + + this.once('end', onend); + } + + // the no-half-open enforcer + function onend() { + // if we allow half-open state, or if the writable side ended, + // then we're ok. + if (this.allowHalfOpen || this._writableState.ended) return; + + // no more data can be written. + // But allow more writes to happen in this tick. + nextTick(onEndNT, this); + } + + function onEndNT(self) { + self.end(); + } + + // a transform stream is a readable/writable stream where you do + inherits$2(Transform, Duplex); + + function TransformState(stream) { + this.afterTransform = function (er, data) { + return afterTransform(stream, er, data); + }; + + this.needTransform = false; + this.transforming = false; + this.writecb = null; + this.writechunk = null; + this.writeencoding = null; + } + + function afterTransform(stream, er, data) { + var ts = stream._transformState; + ts.transforming = false; + + var cb = ts.writecb; + + if (!cb) return stream.emit('error', new Error('no writecb in Transform class')); + + ts.writechunk = null; + ts.writecb = null; + + if (data !== null && data !== undefined) stream.push(data); + + cb(er); + + var rs = stream._readableState; + rs.reading = false; + if (rs.needReadable || rs.length < rs.highWaterMark) { + stream._read(rs.highWaterMark); + } + } + function Transform(options) { + if (!(this instanceof Transform)) return new Transform(options); + + Duplex.call(this, options); + + this._transformState = new TransformState(this); + + // when the writable side finishes, then flush out anything remaining. + var stream = this; + + // start out asking for a readable event once data is transformed. + this._readableState.needReadable = true; + + // we have implemented the _read method, and done the other things + // that Readable wants before the first _read call, so unset the + // sync guard flag. + this._readableState.sync = false; + + if (options) { + if (typeof options.transform === 'function') this._transform = options.transform; + + if (typeof options.flush === 'function') this._flush = options.flush; + } + + this.once('prefinish', function () { + if (typeof this._flush === 'function') this._flush(function (er) { + done(stream, er); + });else done(stream); + }); + } + + Transform.prototype.push = function (chunk, encoding) { + this._transformState.needTransform = false; + return Duplex.prototype.push.call(this, chunk, encoding); + }; + + // This is the part where you do stuff! + // override this function in implementation classes. + // 'chunk' is an input chunk. + // + // Call `push(newChunk)` to pass along transformed output + // to the readable side. You may call 'push' zero or more times. + // + // Call `cb(err)` when you are done with this chunk. If you pass + // an error, then that'll put the hurt on the whole operation. If you + // never call cb(), then you'll never get another chunk. + Transform.prototype._transform = function (chunk, encoding, cb) { + throw new Error('Not implemented'); + }; + + Transform.prototype._write = function (chunk, encoding, cb) { + var ts = this._transformState; + ts.writecb = cb; + ts.writechunk = chunk; + ts.writeencoding = encoding; + if (!ts.transforming) { + var rs = this._readableState; + if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark); + } + }; + + // Doesn't matter what the args are here. + // _transform does all the work. + // That we got here means that the readable side wants more data. + Transform.prototype._read = function (n) { + var ts = this._transformState; + + if (ts.writechunk !== null && ts.writecb && !ts.transforming) { + ts.transforming = true; + this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); + } else { + // mark that we need a transform, so that any data that comes in + // will get processed, now that we've asked for it. + ts.needTransform = true; + } + }; + + function done(stream, er) { + if (er) return stream.emit('error', er); + + // if there's nothing in the write buffer, then that means + // that nothing more will ever be provided + var ws = stream._writableState; + var ts = stream._transformState; + + if (ws.length) throw new Error('Calling transform done when ws.length != 0'); + + if (ts.transforming) throw new Error('Calling transform done when still transforming'); + + return stream.push(null); + } + + inherits$2(PassThrough, Transform); + function PassThrough(options) { + if (!(this instanceof PassThrough)) return new PassThrough(options); + + Transform.call(this, options); + } + + PassThrough.prototype._transform = function (chunk, encoding, cb) { + cb(null, chunk); + }; + + inherits$2(Stream, EventEmitter); + Stream.Readable = Readable; + Stream.Writable = Writable; + Stream.Duplex = Duplex; + Stream.Transform = Transform; + Stream.PassThrough = PassThrough; + + // Backwards-compat with node 0.4.x + Stream.Stream = Stream; + + // old-style streams. Note that the pipe method (the only relevant + // part of this class) is overridden in the Readable class. + + function Stream() { + EventEmitter.call(this); + } + + Stream.prototype.pipe = function(dest, options) { + var source = this; + + function ondata(chunk) { + if (dest.writable) { + if (false === dest.write(chunk) && source.pause) { + source.pause(); + } + } + } + + source.on('data', ondata); + + function ondrain() { + if (source.readable && source.resume) { + source.resume(); + } + } + + dest.on('drain', ondrain); + + // If the 'end' option is not supplied, dest.end() will be called when + // source gets the 'end' or 'close' events. Only dest.end() once. + if (!dest._isStdio && (!options || options.end !== false)) { + source.on('end', onend); + source.on('close', onclose); + } + + var didOnEnd = false; + function onend() { + if (didOnEnd) return; + didOnEnd = true; + + dest.end(); + } + + + function onclose() { + if (didOnEnd) return; + didOnEnd = true; + + if (typeof dest.destroy === 'function') dest.destroy(); + } + + // don't leave dangling pipes when there are errors. + function onerror(er) { + cleanup(); + if (EventEmitter.listenerCount(this, 'error') === 0) { + throw er; // Unhandled stream error in pipe. + } + } + + source.on('error', onerror); + dest.on('error', onerror); + + // remove all the event listeners that were added. + function cleanup() { + source.removeListener('data', ondata); + dest.removeListener('drain', ondrain); + + source.removeListener('end', onend); + source.removeListener('close', onclose); + + source.removeListener('error', onerror); + dest.removeListener('error', onerror); + + source.removeListener('end', cleanup); + source.removeListener('close', cleanup); + + dest.removeListener('close', cleanup); + } + + source.on('end', cleanup); + source.on('close', cleanup); + + dest.on('close', cleanup); + + dest.emit('pipe', source); + + // Allow for unix-like usage: A.pipe(B).pipe(C) + return dest; + }; + + var Buffer$1 = safeBuffer.Buffer; + var Transform$1 = Stream.Transform; + + + function throwIfNotStringOrBuffer (val, prefix) { + if (!Buffer$1.isBuffer(val) && typeof val !== 'string') { + throw new TypeError(prefix + ' must be a string or a buffer') + } + } + + function HashBase (blockSize) { + Transform$1.call(this); + + this._block = Buffer$1.allocUnsafe(blockSize); + this._blockSize = blockSize; + this._blockOffset = 0; + this._length = [0, 0, 0, 0]; + + this._finalized = false; + } + + inherits_browser(HashBase, Transform$1); + + HashBase.prototype._transform = function (chunk, encoding, callback) { + var error = null; + try { + this.update(chunk, encoding); + } catch (err) { + error = err; + } + + callback(error); + }; + + HashBase.prototype._flush = function (callback) { + var error = null; + try { + this.push(this.digest()); + } catch (err) { + error = err; + } + + callback(error); + }; + + HashBase.prototype.update = function (data, encoding) { + throwIfNotStringOrBuffer(data, 'Data'); + if (this._finalized) throw new Error('Digest already called') + if (!Buffer$1.isBuffer(data)) data = Buffer$1.from(data, encoding); + + // consume data + var block = this._block; + var offset = 0; + while (this._blockOffset + data.length - offset >= this._blockSize) { + for (var i = this._blockOffset; i < this._blockSize;) block[i++] = data[offset++]; + this._update(); + this._blockOffset = 0; + } + while (offset < data.length) block[this._blockOffset++] = data[offset++]; + + // update length + for (var j = 0, carry = data.length * 8; carry > 0; ++j) { + this._length[j] += carry; + carry = (this._length[j] / 0x0100000000) | 0; + if (carry > 0) this._length[j] -= 0x0100000000 * carry; + } + + return this + }; + + HashBase.prototype._update = function () { + throw new Error('_update is not implemented') + }; + + HashBase.prototype.digest = function (encoding) { + if (this._finalized) throw new Error('Digest already called') + this._finalized = true; + + var digest = this._digest(); + if (encoding !== undefined) digest = digest.toString(encoding); + + // reset state + this._block.fill(0); + this._blockOffset = 0; + for (var i = 0; i < 4; ++i) this._length[i] = 0; + + return digest + }; + + HashBase.prototype._digest = function () { + throw new Error('_digest is not implemented') + }; + + var hashBase = HashBase; + + var Buffer$2 = safeBuffer.Buffer; + + var ARRAY16 = new Array(16); + + function MD5 () { + hashBase.call(this, 64); + + // state + this._a = 0x67452301; + this._b = 0xefcdab89; + this._c = 0x98badcfe; + this._d = 0x10325476; + } + + inherits_browser(MD5, hashBase); + + MD5.prototype._update = function () { + var M = ARRAY16; + for (var i = 0; i < 16; ++i) M[i] = this._block.readInt32LE(i * 4); + + var a = this._a; + var b = this._b; + var c = this._c; + var d = this._d; + + a = fnF(a, b, c, d, M[0], 0xd76aa478, 7); + d = fnF(d, a, b, c, M[1], 0xe8c7b756, 12); + c = fnF(c, d, a, b, M[2], 0x242070db, 17); + b = fnF(b, c, d, a, M[3], 0xc1bdceee, 22); + a = fnF(a, b, c, d, M[4], 0xf57c0faf, 7); + d = fnF(d, a, b, c, M[5], 0x4787c62a, 12); + c = fnF(c, d, a, b, M[6], 0xa8304613, 17); + b = fnF(b, c, d, a, M[7], 0xfd469501, 22); + a = fnF(a, b, c, d, M[8], 0x698098d8, 7); + d = fnF(d, a, b, c, M[9], 0x8b44f7af, 12); + c = fnF(c, d, a, b, M[10], 0xffff5bb1, 17); + b = fnF(b, c, d, a, M[11], 0x895cd7be, 22); + a = fnF(a, b, c, d, M[12], 0x6b901122, 7); + d = fnF(d, a, b, c, M[13], 0xfd987193, 12); + c = fnF(c, d, a, b, M[14], 0xa679438e, 17); + b = fnF(b, c, d, a, M[15], 0x49b40821, 22); + + a = fnG(a, b, c, d, M[1], 0xf61e2562, 5); + d = fnG(d, a, b, c, M[6], 0xc040b340, 9); + c = fnG(c, d, a, b, M[11], 0x265e5a51, 14); + b = fnG(b, c, d, a, M[0], 0xe9b6c7aa, 20); + a = fnG(a, b, c, d, M[5], 0xd62f105d, 5); + d = fnG(d, a, b, c, M[10], 0x02441453, 9); + c = fnG(c, d, a, b, M[15], 0xd8a1e681, 14); + b = fnG(b, c, d, a, M[4], 0xe7d3fbc8, 20); + a = fnG(a, b, c, d, M[9], 0x21e1cde6, 5); + d = fnG(d, a, b, c, M[14], 0xc33707d6, 9); + c = fnG(c, d, a, b, M[3], 0xf4d50d87, 14); + b = fnG(b, c, d, a, M[8], 0x455a14ed, 20); + a = fnG(a, b, c, d, M[13], 0xa9e3e905, 5); + d = fnG(d, a, b, c, M[2], 0xfcefa3f8, 9); + c = fnG(c, d, a, b, M[7], 0x676f02d9, 14); + b = fnG(b, c, d, a, M[12], 0x8d2a4c8a, 20); + + a = fnH(a, b, c, d, M[5], 0xfffa3942, 4); + d = fnH(d, a, b, c, M[8], 0x8771f681, 11); + c = fnH(c, d, a, b, M[11], 0x6d9d6122, 16); + b = fnH(b, c, d, a, M[14], 0xfde5380c, 23); + a = fnH(a, b, c, d, M[1], 0xa4beea44, 4); + d = fnH(d, a, b, c, M[4], 0x4bdecfa9, 11); + c = fnH(c, d, a, b, M[7], 0xf6bb4b60, 16); + b = fnH(b, c, d, a, M[10], 0xbebfbc70, 23); + a = fnH(a, b, c, d, M[13], 0x289b7ec6, 4); + d = fnH(d, a, b, c, M[0], 0xeaa127fa, 11); + c = fnH(c, d, a, b, M[3], 0xd4ef3085, 16); + b = fnH(b, c, d, a, M[6], 0x04881d05, 23); + a = fnH(a, b, c, d, M[9], 0xd9d4d039, 4); + d = fnH(d, a, b, c, M[12], 0xe6db99e5, 11); + c = fnH(c, d, a, b, M[15], 0x1fa27cf8, 16); + b = fnH(b, c, d, a, M[2], 0xc4ac5665, 23); + + a = fnI(a, b, c, d, M[0], 0xf4292244, 6); + d = fnI(d, a, b, c, M[7], 0x432aff97, 10); + c = fnI(c, d, a, b, M[14], 0xab9423a7, 15); + b = fnI(b, c, d, a, M[5], 0xfc93a039, 21); + a = fnI(a, b, c, d, M[12], 0x655b59c3, 6); + d = fnI(d, a, b, c, M[3], 0x8f0ccc92, 10); + c = fnI(c, d, a, b, M[10], 0xffeff47d, 15); + b = fnI(b, c, d, a, M[1], 0x85845dd1, 21); + a = fnI(a, b, c, d, M[8], 0x6fa87e4f, 6); + d = fnI(d, a, b, c, M[15], 0xfe2ce6e0, 10); + c = fnI(c, d, a, b, M[6], 0xa3014314, 15); + b = fnI(b, c, d, a, M[13], 0x4e0811a1, 21); + a = fnI(a, b, c, d, M[4], 0xf7537e82, 6); + d = fnI(d, a, b, c, M[11], 0xbd3af235, 10); + c = fnI(c, d, a, b, M[2], 0x2ad7d2bb, 15); + b = fnI(b, c, d, a, M[9], 0xeb86d391, 21); + + this._a = (this._a + a) | 0; + this._b = (this._b + b) | 0; + this._c = (this._c + c) | 0; + this._d = (this._d + d) | 0; + }; + + MD5.prototype._digest = function () { + // create padding and handle blocks + this._block[this._blockOffset++] = 0x80; + if (this._blockOffset > 56) { + this._block.fill(0, this._blockOffset, 64); + this._update(); + this._blockOffset = 0; + } + + this._block.fill(0, this._blockOffset, 56); + this._block.writeUInt32LE(this._length[0], 56); + this._block.writeUInt32LE(this._length[1], 60); + this._update(); + + // produce result + var buffer = Buffer$2.allocUnsafe(16); + buffer.writeInt32LE(this._a, 0); + buffer.writeInt32LE(this._b, 4); + buffer.writeInt32LE(this._c, 8); + buffer.writeInt32LE(this._d, 12); + return buffer + }; + + function rotl (x, n) { + return (x << n) | (x >>> (32 - n)) + } + + function fnF (a, b, c, d, m, k, s) { + return (rotl((a + ((b & c) | ((~b) & d)) + m + k) | 0, s) + b) | 0 + } + + function fnG (a, b, c, d, m, k, s) { + return (rotl((a + ((b & d) | (c & (~d))) + m + k) | 0, s) + b) | 0 + } + + function fnH (a, b, c, d, m, k, s) { + return (rotl((a + (b ^ c ^ d) + m + k) | 0, s) + b) | 0 + } + + function fnI (a, b, c, d, m, k, s) { + return (rotl((a + ((c ^ (b | (~d)))) + m + k) | 0, s) + b) | 0 + } + + var md5_js = MD5; + + var Buffer$3 = buffer.Buffer; + + + + var ARRAY16$1 = new Array(16); + + var zl = [ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, + 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, + 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, + 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13 + ]; + + var zr = [ + 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, + 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, + 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, + 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, + 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11 + ]; + + var sl = [ + 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, + 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, + 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, + 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, + 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 + ]; + + var sr = [ + 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, + 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, + 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, + 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, + 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 + ]; + + var hl = [0x00000000, 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xa953fd4e]; + var hr = [0x50a28be6, 0x5c4dd124, 0x6d703ef3, 0x7a6d76e9, 0x00000000]; + + function RIPEMD160 () { + hashBase.call(this, 64); + + // state + this._a = 0x67452301; + this._b = 0xefcdab89; + this._c = 0x98badcfe; + this._d = 0x10325476; + this._e = 0xc3d2e1f0; + } + + inherits_browser(RIPEMD160, hashBase); + + RIPEMD160.prototype._update = function () { + var words = ARRAY16$1; + for (var j = 0; j < 16; ++j) words[j] = this._block.readInt32LE(j * 4); + + var al = this._a | 0; + var bl = this._b | 0; + var cl = this._c | 0; + var dl = this._d | 0; + var el = this._e | 0; + + var ar = this._a | 0; + var br = this._b | 0; + var cr = this._c | 0; + var dr = this._d | 0; + var er = this._e | 0; + + // computation + for (var i = 0; i < 80; i += 1) { + var tl; + var tr; + if (i < 16) { + tl = fn1(al, bl, cl, dl, el, words[zl[i]], hl[0], sl[i]); + tr = fn5(ar, br, cr, dr, er, words[zr[i]], hr[0], sr[i]); + } else if (i < 32) { + tl = fn2(al, bl, cl, dl, el, words[zl[i]], hl[1], sl[i]); + tr = fn4(ar, br, cr, dr, er, words[zr[i]], hr[1], sr[i]); + } else if (i < 48) { + tl = fn3(al, bl, cl, dl, el, words[zl[i]], hl[2], sl[i]); + tr = fn3(ar, br, cr, dr, er, words[zr[i]], hr[2], sr[i]); + } else if (i < 64) { + tl = fn4(al, bl, cl, dl, el, words[zl[i]], hl[3], sl[i]); + tr = fn2(ar, br, cr, dr, er, words[zr[i]], hr[3], sr[i]); + } else { // if (i<80) { + tl = fn5(al, bl, cl, dl, el, words[zl[i]], hl[4], sl[i]); + tr = fn1(ar, br, cr, dr, er, words[zr[i]], hr[4], sr[i]); + } + + al = el; + el = dl; + dl = rotl$1(cl, 10); + cl = bl; + bl = tl; + + ar = er; + er = dr; + dr = rotl$1(cr, 10); + cr = br; + br = tr; + } + + // update state + var t = (this._b + cl + dr) | 0; + this._b = (this._c + dl + er) | 0; + this._c = (this._d + el + ar) | 0; + this._d = (this._e + al + br) | 0; + this._e = (this._a + bl + cr) | 0; + this._a = t; + }; + + RIPEMD160.prototype._digest = function () { + // create padding and handle blocks + this._block[this._blockOffset++] = 0x80; + if (this._blockOffset > 56) { + this._block.fill(0, this._blockOffset, 64); + this._update(); + this._blockOffset = 0; + } + + this._block.fill(0, this._blockOffset, 56); + this._block.writeUInt32LE(this._length[0], 56); + this._block.writeUInt32LE(this._length[1], 60); + this._update(); + + // produce result + var buffer$$1 = Buffer$3.alloc ? Buffer$3.alloc(20) : new Buffer$3(20); + buffer$$1.writeInt32LE(this._a, 0); + buffer$$1.writeInt32LE(this._b, 4); + buffer$$1.writeInt32LE(this._c, 8); + buffer$$1.writeInt32LE(this._d, 12); + buffer$$1.writeInt32LE(this._e, 16); + return buffer$$1 + }; + + function rotl$1 (x, n) { + return (x << n) | (x >>> (32 - n)) + } + + function fn1 (a, b, c, d, e, m, k, s) { + return (rotl$1((a + (b ^ c ^ d) + m + k) | 0, s) + e) | 0 + } + + function fn2 (a, b, c, d, e, m, k, s) { + return (rotl$1((a + ((b & c) | ((~b) & d)) + m + k) | 0, s) + e) | 0 + } + + function fn3 (a, b, c, d, e, m, k, s) { + return (rotl$1((a + ((b | (~c)) ^ d) + m + k) | 0, s) + e) | 0 + } + + function fn4 (a, b, c, d, e, m, k, s) { + return (rotl$1((a + ((b & d) | (c & (~d))) + m + k) | 0, s) + e) | 0 + } + + function fn5 (a, b, c, d, e, m, k, s) { + return (rotl$1((a + (b ^ (c | (~d))) + m + k) | 0, s) + e) | 0 + } + + var ripemd160 = RIPEMD160; + + var Buffer$4 = safeBuffer.Buffer; + + // prototype class for hash functions + function Hash (blockSize, finalSize) { + this._block = Buffer$4.alloc(blockSize); + this._finalSize = finalSize; + this._blockSize = blockSize; + this._len = 0; + } + + Hash.prototype.update = function (data, enc) { + if (typeof data === 'string') { + enc = enc || 'utf8'; + data = Buffer$4.from(data, enc); + } + + var block = this._block; + var blockSize = this._blockSize; + var length = data.length; + var accum = this._len; + + for (var offset = 0; offset < length;) { + var assigned = accum % blockSize; + var remainder = Math.min(length - offset, blockSize - assigned); + + for (var i = 0; i < remainder; i++) { + block[assigned + i] = data[offset + i]; + } + + accum += remainder; + offset += remainder; + + if ((accum % blockSize) === 0) { + this._update(block); + } + } + + this._len += length; + return this + }; + + Hash.prototype.digest = function (enc) { + var rem = this._len % this._blockSize; + + this._block[rem] = 0x80; + + // zero (rem + 1) trailing bits, where (rem + 1) is the smallest + // non-negative solution to the equation (length + 1 + (rem + 1)) === finalSize mod blockSize + this._block.fill(0, rem + 1); + + if (rem >= this._finalSize) { + this._update(this._block); + this._block.fill(0); + } + + var bits = this._len * 8; + + // uint32 + if (bits <= 0xffffffff) { + this._block.writeUInt32BE(bits, this._blockSize - 4); + + // uint64 + } else { + var lowBits = (bits & 0xffffffff) >>> 0; + var highBits = (bits - lowBits) / 0x100000000; + + this._block.writeUInt32BE(highBits, this._blockSize - 8); + this._block.writeUInt32BE(lowBits, this._blockSize - 4); + } + + this._update(this._block); + var hash = this._hash(); + + return enc ? hash.toString(enc) : hash + }; + + Hash.prototype._update = function () { + throw new Error('_update must be implemented by subclass') + }; + + var hash = Hash; + + /* + * A JavaScript implementation of the Secure Hash Algorithm, SHA-0, as defined + * in FIPS PUB 180-1 + * This source code is derived from sha1.js of the same repository. + * The difference between SHA-0 and SHA-1 is just a bitwise rotate left + * operation was added. + */ + + + + var Buffer$5 = safeBuffer.Buffer; + + var K = [ + 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0 + ]; + + var W = new Array(80); + + function Sha () { + this.init(); + this._w = W; + + hash.call(this, 64, 56); + } + + inherits_browser(Sha, hash); + + Sha.prototype.init = function () { + this._a = 0x67452301; + this._b = 0xefcdab89; + this._c = 0x98badcfe; + this._d = 0x10325476; + this._e = 0xc3d2e1f0; + + return this + }; + + function rotl5 (num) { + return (num << 5) | (num >>> 27) + } + + function rotl30 (num) { + return (num << 30) | (num >>> 2) + } + + function ft (s, b, c, d) { + if (s === 0) return (b & c) | ((~b) & d) + if (s === 2) return (b & c) | (b & d) | (c & d) + return b ^ c ^ d + } + + Sha.prototype._update = function (M) { + var W = this._w; + + var a = this._a | 0; + var b = this._b | 0; + var c = this._c | 0; + var d = this._d | 0; + var e = this._e | 0; + + for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4); + for (; i < 80; ++i) W[i] = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]; + + for (var j = 0; j < 80; ++j) { + var s = ~~(j / 20); + var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0; + + e = d; + d = c; + c = rotl30(b); + b = a; + a = t; + } + + this._a = (a + this._a) | 0; + this._b = (b + this._b) | 0; + this._c = (c + this._c) | 0; + this._d = (d + this._d) | 0; + this._e = (e + this._e) | 0; + }; + + Sha.prototype._hash = function () { + var H = Buffer$5.allocUnsafe(20); + + H.writeInt32BE(this._a | 0, 0); + H.writeInt32BE(this._b | 0, 4); + H.writeInt32BE(this._c | 0, 8); + H.writeInt32BE(this._d | 0, 12); + H.writeInt32BE(this._e | 0, 16); + + return H + }; + + var sha = Sha; + + /* + * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined + * in FIPS PUB 180-1 + * Version 2.1a Copyright Paul Johnston 2000 - 2002. + * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet + * Distributed under the BSD License + * See http://pajhome.org.uk/crypt/md5 for details. + */ + + + + var Buffer$6 = safeBuffer.Buffer; + + var K$1 = [ + 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0 + ]; + + var W$1 = new Array(80); + + function Sha1 () { + this.init(); + this._w = W$1; + + hash.call(this, 64, 56); + } + + inherits_browser(Sha1, hash); + + Sha1.prototype.init = function () { + this._a = 0x67452301; + this._b = 0xefcdab89; + this._c = 0x98badcfe; + this._d = 0x10325476; + this._e = 0xc3d2e1f0; + + return this + }; + + function rotl1 (num) { + return (num << 1) | (num >>> 31) + } + + function rotl5$1 (num) { + return (num << 5) | (num >>> 27) + } + + function rotl30$1 (num) { + return (num << 30) | (num >>> 2) + } + + function ft$1 (s, b, c, d) { + if (s === 0) return (b & c) | ((~b) & d) + if (s === 2) return (b & c) | (b & d) | (c & d) + return b ^ c ^ d + } + + Sha1.prototype._update = function (M) { + var W = this._w; + + var a = this._a | 0; + var b = this._b | 0; + var c = this._c | 0; + var d = this._d | 0; + var e = this._e | 0; + + for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4); + for (; i < 80; ++i) W[i] = rotl1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]); + + for (var j = 0; j < 80; ++j) { + var s = ~~(j / 20); + var t = (rotl5$1(a) + ft$1(s, b, c, d) + e + W[j] + K$1[s]) | 0; + + e = d; + d = c; + c = rotl30$1(b); + b = a; + a = t; + } + + this._a = (a + this._a) | 0; + this._b = (b + this._b) | 0; + this._c = (c + this._c) | 0; + this._d = (d + this._d) | 0; + this._e = (e + this._e) | 0; + }; + + Sha1.prototype._hash = function () { + var H = Buffer$6.allocUnsafe(20); + + H.writeInt32BE(this._a | 0, 0); + H.writeInt32BE(this._b | 0, 4); + H.writeInt32BE(this._c | 0, 8); + H.writeInt32BE(this._d | 0, 12); + H.writeInt32BE(this._e | 0, 16); + + return H + }; + + var sha1 = Sha1; + + /** + * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined + * in FIPS 180-2 + * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009. + * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet + * + */ + + + + var Buffer$7 = safeBuffer.Buffer; + + var K$2 = [ + 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5, + 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5, + 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3, + 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174, + 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC, + 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA, + 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7, + 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967, + 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13, + 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85, + 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3, + 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070, + 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5, + 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3, + 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208, + 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2 + ]; + + var W$2 = new Array(64); + + function Sha256 () { + this.init(); + + this._w = W$2; // new Array(64) + + hash.call(this, 64, 56); + } + + inherits_browser(Sha256, hash); + + Sha256.prototype.init = function () { + this._a = 0x6a09e667; + this._b = 0xbb67ae85; + this._c = 0x3c6ef372; + this._d = 0xa54ff53a; + this._e = 0x510e527f; + this._f = 0x9b05688c; + this._g = 0x1f83d9ab; + this._h = 0x5be0cd19; + + return this + }; + + function ch (x, y, z) { + return z ^ (x & (y ^ z)) + } + + function maj (x, y, z) { + return (x & y) | (z & (x | y)) + } + + function sigma0 (x) { + return (x >>> 2 | x << 30) ^ (x >>> 13 | x << 19) ^ (x >>> 22 | x << 10) + } + + function sigma1 (x) { + return (x >>> 6 | x << 26) ^ (x >>> 11 | x << 21) ^ (x >>> 25 | x << 7) + } + + function gamma0 (x) { + return (x >>> 7 | x << 25) ^ (x >>> 18 | x << 14) ^ (x >>> 3) + } + + function gamma1 (x) { + return (x >>> 17 | x << 15) ^ (x >>> 19 | x << 13) ^ (x >>> 10) + } + + Sha256.prototype._update = function (M) { + var W = this._w; + + var a = this._a | 0; + var b = this._b | 0; + var c = this._c | 0; + var d = this._d | 0; + var e = this._e | 0; + var f = this._f | 0; + var g = this._g | 0; + var h = this._h | 0; + + for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4); + for (; i < 64; ++i) W[i] = (gamma1(W[i - 2]) + W[i - 7] + gamma0(W[i - 15]) + W[i - 16]) | 0; + + for (var j = 0; j < 64; ++j) { + var T1 = (h + sigma1(e) + ch(e, f, g) + K$2[j] + W[j]) | 0; + var T2 = (sigma0(a) + maj(a, b, c)) | 0; + + h = g; + g = f; + f = e; + e = (d + T1) | 0; + d = c; + c = b; + b = a; + a = (T1 + T2) | 0; + } + + this._a = (a + this._a) | 0; + this._b = (b + this._b) | 0; + this._c = (c + this._c) | 0; + this._d = (d + this._d) | 0; + this._e = (e + this._e) | 0; + this._f = (f + this._f) | 0; + this._g = (g + this._g) | 0; + this._h = (h + this._h) | 0; + }; + + Sha256.prototype._hash = function () { + var H = Buffer$7.allocUnsafe(32); + + H.writeInt32BE(this._a, 0); + H.writeInt32BE(this._b, 4); + H.writeInt32BE(this._c, 8); + H.writeInt32BE(this._d, 12); + H.writeInt32BE(this._e, 16); + H.writeInt32BE(this._f, 20); + H.writeInt32BE(this._g, 24); + H.writeInt32BE(this._h, 28); + + return H + }; + + var sha256 = Sha256; + + /** + * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined + * in FIPS 180-2 + * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009. + * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet + * + */ + + + + + var Buffer$8 = safeBuffer.Buffer; + + var W$3 = new Array(64); + + function Sha224 () { + this.init(); + + this._w = W$3; // new Array(64) + + hash.call(this, 64, 56); + } + + inherits_browser(Sha224, sha256); + + Sha224.prototype.init = function () { + this._a = 0xc1059ed8; + this._b = 0x367cd507; + this._c = 0x3070dd17; + this._d = 0xf70e5939; + this._e = 0xffc00b31; + this._f = 0x68581511; + this._g = 0x64f98fa7; + this._h = 0xbefa4fa4; + + return this + }; + + Sha224.prototype._hash = function () { + var H = Buffer$8.allocUnsafe(28); + + H.writeInt32BE(this._a, 0); + H.writeInt32BE(this._b, 4); + H.writeInt32BE(this._c, 8); + H.writeInt32BE(this._d, 12); + H.writeInt32BE(this._e, 16); + H.writeInt32BE(this._f, 20); + H.writeInt32BE(this._g, 24); + + return H + }; + + var sha224 = Sha224; + + var Buffer$9 = safeBuffer.Buffer; + + var K$3 = [ + 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, + 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc, + 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019, + 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118, + 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe, + 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2, + 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1, + 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694, + 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3, + 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65, + 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483, + 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5, + 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210, + 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4, + 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725, + 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70, + 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926, + 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df, + 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8, + 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b, + 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001, + 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30, + 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910, + 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8, + 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53, + 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8, + 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb, + 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3, + 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60, + 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec, + 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9, + 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b, + 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207, + 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178, + 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6, + 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b, + 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493, + 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c, + 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a, + 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817 + ]; + + var W$4 = new Array(160); + + function Sha512 () { + this.init(); + this._w = W$4; + + hash.call(this, 128, 112); + } + + inherits_browser(Sha512, hash); + + Sha512.prototype.init = function () { + this._ah = 0x6a09e667; + this._bh = 0xbb67ae85; + this._ch = 0x3c6ef372; + this._dh = 0xa54ff53a; + this._eh = 0x510e527f; + this._fh = 0x9b05688c; + this._gh = 0x1f83d9ab; + this._hh = 0x5be0cd19; + + this._al = 0xf3bcc908; + this._bl = 0x84caa73b; + this._cl = 0xfe94f82b; + this._dl = 0x5f1d36f1; + this._el = 0xade682d1; + this._fl = 0x2b3e6c1f; + this._gl = 0xfb41bd6b; + this._hl = 0x137e2179; + + return this + }; + + function Ch (x, y, z) { + return z ^ (x & (y ^ z)) + } + + function maj$1 (x, y, z) { + return (x & y) | (z & (x | y)) + } + + function sigma0$1 (x, xl) { + return (x >>> 28 | xl << 4) ^ (xl >>> 2 | x << 30) ^ (xl >>> 7 | x << 25) + } + + function sigma1$1 (x, xl) { + return (x >>> 14 | xl << 18) ^ (x >>> 18 | xl << 14) ^ (xl >>> 9 | x << 23) + } + + function Gamma0 (x, xl) { + return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7) + } + + function Gamma0l (x, xl) { + return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7 | xl << 25) + } + + function Gamma1 (x, xl) { + return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6) + } + + function Gamma1l (x, xl) { + return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6 | xl << 26) + } + + function getCarry (a, b) { + return (a >>> 0) < (b >>> 0) ? 1 : 0 + } + + Sha512.prototype._update = function (M) { + var W = this._w; + + var ah = this._ah | 0; + var bh = this._bh | 0; + var ch = this._ch | 0; + var dh = this._dh | 0; + var eh = this._eh | 0; + var fh = this._fh | 0; + var gh = this._gh | 0; + var hh = this._hh | 0; + + var al = this._al | 0; + var bl = this._bl | 0; + var cl = this._cl | 0; + var dl = this._dl | 0; + var el = this._el | 0; + var fl = this._fl | 0; + var gl = this._gl | 0; + var hl = this._hl | 0; + + for (var i = 0; i < 32; i += 2) { + W[i] = M.readInt32BE(i * 4); + W[i + 1] = M.readInt32BE(i * 4 + 4); + } + for (; i < 160; i += 2) { + var xh = W[i - 15 * 2]; + var xl = W[i - 15 * 2 + 1]; + var gamma0 = Gamma0(xh, xl); + var gamma0l = Gamma0l(xl, xh); + + xh = W[i - 2 * 2]; + xl = W[i - 2 * 2 + 1]; + var gamma1 = Gamma1(xh, xl); + var gamma1l = Gamma1l(xl, xh); + + // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16] + var Wi7h = W[i - 7 * 2]; + var Wi7l = W[i - 7 * 2 + 1]; + + var Wi16h = W[i - 16 * 2]; + var Wi16l = W[i - 16 * 2 + 1]; + + var Wil = (gamma0l + Wi7l) | 0; + var Wih = (gamma0 + Wi7h + getCarry(Wil, gamma0l)) | 0; + Wil = (Wil + gamma1l) | 0; + Wih = (Wih + gamma1 + getCarry(Wil, gamma1l)) | 0; + Wil = (Wil + Wi16l) | 0; + Wih = (Wih + Wi16h + getCarry(Wil, Wi16l)) | 0; + + W[i] = Wih; + W[i + 1] = Wil; + } + + for (var j = 0; j < 160; j += 2) { + Wih = W[j]; + Wil = W[j + 1]; + + var majh = maj$1(ah, bh, ch); + var majl = maj$1(al, bl, cl); + + var sigma0h = sigma0$1(ah, al); + var sigma0l = sigma0$1(al, ah); + var sigma1h = sigma1$1(eh, el); + var sigma1l = sigma1$1(el, eh); + + // t1 = h + sigma1 + ch + K[j] + W[j] + var Kih = K$3[j]; + var Kil = K$3[j + 1]; + + var chh = Ch(eh, fh, gh); + var chl = Ch(el, fl, gl); + + var t1l = (hl + sigma1l) | 0; + var t1h = (hh + sigma1h + getCarry(t1l, hl)) | 0; + t1l = (t1l + chl) | 0; + t1h = (t1h + chh + getCarry(t1l, chl)) | 0; + t1l = (t1l + Kil) | 0; + t1h = (t1h + Kih + getCarry(t1l, Kil)) | 0; + t1l = (t1l + Wil) | 0; + t1h = (t1h + Wih + getCarry(t1l, Wil)) | 0; + + // t2 = sigma0 + maj + var t2l = (sigma0l + majl) | 0; + var t2h = (sigma0h + majh + getCarry(t2l, sigma0l)) | 0; + + hh = gh; + hl = gl; + gh = fh; + gl = fl; + fh = eh; + fl = el; + el = (dl + t1l) | 0; + eh = (dh + t1h + getCarry(el, dl)) | 0; + dh = ch; + dl = cl; + ch = bh; + cl = bl; + bh = ah; + bl = al; + al = (t1l + t2l) | 0; + ah = (t1h + t2h + getCarry(al, t1l)) | 0; + } + + this._al = (this._al + al) | 0; + this._bl = (this._bl + bl) | 0; + this._cl = (this._cl + cl) | 0; + this._dl = (this._dl + dl) | 0; + this._el = (this._el + el) | 0; + this._fl = (this._fl + fl) | 0; + this._gl = (this._gl + gl) | 0; + this._hl = (this._hl + hl) | 0; + + this._ah = (this._ah + ah + getCarry(this._al, al)) | 0; + this._bh = (this._bh + bh + getCarry(this._bl, bl)) | 0; + this._ch = (this._ch + ch + getCarry(this._cl, cl)) | 0; + this._dh = (this._dh + dh + getCarry(this._dl, dl)) | 0; + this._eh = (this._eh + eh + getCarry(this._el, el)) | 0; + this._fh = (this._fh + fh + getCarry(this._fl, fl)) | 0; + this._gh = (this._gh + gh + getCarry(this._gl, gl)) | 0; + this._hh = (this._hh + hh + getCarry(this._hl, hl)) | 0; + }; + + Sha512.prototype._hash = function () { + var H = Buffer$9.allocUnsafe(64); + + function writeInt64BE (h, l, offset) { + H.writeInt32BE(h, offset); + H.writeInt32BE(l, offset + 4); + } + + writeInt64BE(this._ah, this._al, 0); + writeInt64BE(this._bh, this._bl, 8); + writeInt64BE(this._ch, this._cl, 16); + writeInt64BE(this._dh, this._dl, 24); + writeInt64BE(this._eh, this._el, 32); + writeInt64BE(this._fh, this._fl, 40); + writeInt64BE(this._gh, this._gl, 48); + writeInt64BE(this._hh, this._hl, 56); + + return H + }; + + var sha512 = Sha512; + + var Buffer$a = safeBuffer.Buffer; + + var W$5 = new Array(160); + + function Sha384 () { + this.init(); + this._w = W$5; + + hash.call(this, 128, 112); + } + + inherits_browser(Sha384, sha512); + + Sha384.prototype.init = function () { + this._ah = 0xcbbb9d5d; + this._bh = 0x629a292a; + this._ch = 0x9159015a; + this._dh = 0x152fecd8; + this._eh = 0x67332667; + this._fh = 0x8eb44a87; + this._gh = 0xdb0c2e0d; + this._hh = 0x47b5481d; + + this._al = 0xc1059ed8; + this._bl = 0x367cd507; + this._cl = 0x3070dd17; + this._dl = 0xf70e5939; + this._el = 0xffc00b31; + this._fl = 0x68581511; + this._gl = 0x64f98fa7; + this._hl = 0xbefa4fa4; + + return this + }; + + Sha384.prototype._hash = function () { + var H = Buffer$a.allocUnsafe(48); + + function writeInt64BE (h, l, offset) { + H.writeInt32BE(h, offset); + H.writeInt32BE(l, offset + 4); + } + + writeInt64BE(this._ah, this._al, 0); + writeInt64BE(this._bh, this._bl, 8); + writeInt64BE(this._ch, this._cl, 16); + writeInt64BE(this._dh, this._dl, 24); + writeInt64BE(this._eh, this._el, 32); + writeInt64BE(this._fh, this._fl, 40); + + return H + }; + + var sha384 = Sha384; + + var sha_js = createCommonjsModule(function (module) { + var exports = module.exports = function SHA (algorithm) { + algorithm = algorithm.toLowerCase(); + + var Algorithm = exports[algorithm]; + if (!Algorithm) throw new Error(algorithm + ' is not supported (we accept pull requests)') + + return new Algorithm() + }; + + exports.sha = sha; + exports.sha1 = sha1; + exports.sha224 = sha224; + exports.sha256 = sha256; + exports.sha384 = sha384; + exports.sha512 = sha512; + }); + + var Buffer$b = safeBuffer.Buffer; + var Transform$2 = Stream.Transform; + var StringDecoder$1 = stringDecoder.StringDecoder; + + + function CipherBase (hashMode) { + Transform$2.call(this); + this.hashMode = typeof hashMode === 'string'; + if (this.hashMode) { + this[hashMode] = this._finalOrDigest; + } else { + this.final = this._finalOrDigest; + } + if (this._final) { + this.__final = this._final; + this._final = null; + } + this._decoder = null; + this._encoding = null; + } + inherits_browser(CipherBase, Transform$2); + + CipherBase.prototype.update = function (data, inputEnc, outputEnc) { + if (typeof data === 'string') { + data = Buffer$b.from(data, inputEnc); + } + + var outData = this._update(data); + if (this.hashMode) return this + + if (outputEnc) { + outData = this._toString(outData, outputEnc); + } + + return outData + }; + + CipherBase.prototype.setAutoPadding = function () {}; + CipherBase.prototype.getAuthTag = function () { + throw new Error('trying to get auth tag in unsupported state') + }; + + CipherBase.prototype.setAuthTag = function () { + throw new Error('trying to set auth tag in unsupported state') + }; + + CipherBase.prototype.setAAD = function () { + throw new Error('trying to set aad in unsupported state') + }; + + CipherBase.prototype._transform = function (data, _, next) { + var err; + try { + if (this.hashMode) { + this._update(data); + } else { + this.push(this._update(data)); + } + } catch (e) { + err = e; + } finally { + next(err); + } + }; + CipherBase.prototype._flush = function (done) { + var err; + try { + this.push(this.__final()); + } catch (e) { + err = e; + } + + done(err); + }; + CipherBase.prototype._finalOrDigest = function (outputEnc) { + var outData = this.__final() || Buffer$b.alloc(0); + if (outputEnc) { + outData = this._toString(outData, outputEnc, true); + } + return outData + }; + + CipherBase.prototype._toString = function (value, enc, fin) { + if (!this._decoder) { + this._decoder = new StringDecoder$1(enc); + this._encoding = enc; + } + + if (this._encoding !== enc) throw new Error('can\'t switch encodings') + + var out = this._decoder.write(value); + if (fin) { + out += this._decoder.end(); + } + + return out + }; + + var cipherBase = CipherBase; + + function Hash$1 (hash) { + cipherBase.call(this, 'digest'); + + this._hash = hash; + } + + inherits_browser(Hash$1, cipherBase); + + Hash$1.prototype._update = function (data) { + this._hash.update(data); + }; + + Hash$1.prototype._final = function () { + return this._hash.digest() + }; + + var browser$1 = function createHash (alg) { + alg = alg.toLowerCase(); + if (alg === 'md5') return new md5_js() + if (alg === 'rmd160' || alg === 'ripemd160') return new ripemd160() + + return new Hash$1(sha_js(alg)) + }; + + var hasFetch = isFunction$1(global$1.fetch) && isFunction$1(global$1.ReadableStream); + + var _blobConstructor; + function blobConstructor() { + if (typeof _blobConstructor !== 'undefined') { + return _blobConstructor; + } + try { + new global$1.Blob([new ArrayBuffer(1)]); + _blobConstructor = true; + } catch (e) { + _blobConstructor = false; + } + return _blobConstructor + } + var xhr; + + function checkTypeSupport(type) { + if (!xhr) { + xhr = new global$1.XMLHttpRequest(); + // If location.host is empty, e.g. if this page/worker was loaded + // from a Blob, then use example.com to avoid an error + xhr.open('GET', global$1.location.host ? '/' : 'https://example.com'); + } + try { + xhr.responseType = type; + return xhr.responseType === type + } catch (e) { + return false + } + + } + + // For some strange reason, Safari 7.0 reports typeof global.ArrayBuffer === 'object'. + // Safari 7.1 appears to have fixed this bug. + var haveArrayBuffer = typeof global$1.ArrayBuffer !== 'undefined'; + var haveSlice = haveArrayBuffer && isFunction$1(global$1.ArrayBuffer.prototype.slice); + + var arraybuffer = haveArrayBuffer && checkTypeSupport('arraybuffer'); + // These next two tests unavoidably show warnings in Chrome. Since fetch will always + // be used if it's available, just return false for these to avoid the warnings. + var msstream = !hasFetch && haveSlice && checkTypeSupport('ms-stream'); + var mozchunkedarraybuffer = !hasFetch && haveArrayBuffer && + checkTypeSupport('moz-chunked-arraybuffer'); + var overrideMimeType = isFunction$1(xhr.overrideMimeType); + var vbArray = isFunction$1(global$1.VBArray); + + function isFunction$1(value) { + return typeof value === 'function' + } + + xhr = null; // Help gc + + var rStates = { + UNSENT: 0, + OPENED: 1, + HEADERS_RECEIVED: 2, + LOADING: 3, + DONE: 4 + }; + function IncomingMessage(xhr, response, mode) { + var self = this; + Readable.call(self); + + self._mode = mode; + self.headers = {}; + self.rawHeaders = []; + self.trailers = {}; + self.rawTrailers = []; + + // Fake the 'close' event, but only once 'end' fires + self.on('end', function() { + // The nextTick is necessary to prevent the 'request' module from causing an infinite loop + nextTick(function() { + self.emit('close'); + }); + }); + var read; + if (mode === 'fetch') { + self._fetchResponse = response; + + self.url = response.url; + self.statusCode = response.status; + self.statusMessage = response.statusText; + // backwards compatible version of for ( of ): + // for (var ,_i,_it = [Symbol.iterator](); = (_i = _it.next()).value,!_i.done;) + for (var header, _i, _it = response.headers[Symbol.iterator](); header = (_i = _it.next()).value, !_i.done;) { + self.headers[header[0].toLowerCase()] = header[1]; + self.rawHeaders.push(header[0], header[1]); + } + + // TODO: this doesn't respect backpressure. Once WritableStream is available, this can be fixed + var reader = response.body.getReader(); + + read = function () { + reader.read().then(function(result) { + if (self._destroyed) + return + if (result.done) { + self.push(null); + return + } + self.push(new Buffer(result.value)); + read(); + }); + }; + read(); + + } else { + self._xhr = xhr; + self._pos = 0; + + self.url = xhr.responseURL; + self.statusCode = xhr.status; + self.statusMessage = xhr.statusText; + var headers = xhr.getAllResponseHeaders().split(/\r?\n/); + headers.forEach(function(header) { + var matches = header.match(/^([^:]+):\s*(.*)/); + if (matches) { + var key = matches[1].toLowerCase(); + if (key === 'set-cookie') { + if (self.headers[key] === undefined) { + self.headers[key] = []; + } + self.headers[key].push(matches[2]); + } else if (self.headers[key] !== undefined) { + self.headers[key] += ', ' + matches[2]; + } else { + self.headers[key] = matches[2]; + } + self.rawHeaders.push(matches[1], matches[2]); + } + }); + + self._charset = 'x-user-defined'; + if (!overrideMimeType) { + var mimeType = self.rawHeaders['mime-type']; + if (mimeType) { + var charsetMatch = mimeType.match(/;\s*charset=([^;])(;|$)/); + if (charsetMatch) { + self._charset = charsetMatch[1].toLowerCase(); + } + } + if (!self._charset) + self._charset = 'utf-8'; // best guess + } + } + } + + inherits$2(IncomingMessage, Readable); + + IncomingMessage.prototype._read = function() {}; + + IncomingMessage.prototype._onXHRProgress = function() { + var self = this; + + var xhr = self._xhr; + + var response = null; + switch (self._mode) { + case 'text:vbarray': // For IE9 + if (xhr.readyState !== rStates.DONE) + break + try { + // This fails in IE8 + response = new global$1.VBArray(xhr.responseBody).toArray(); + } catch (e) { + // pass + } + if (response !== null) { + self.push(new Buffer(response)); + break + } + // Falls through in IE8 + case 'text': + try { // This will fail when readyState = 3 in IE9. Switch mode and wait for readyState = 4 + response = xhr.responseText; + } catch (e) { + self._mode = 'text:vbarray'; + break + } + if (response.length > self._pos) { + var newData = response.substr(self._pos); + if (self._charset === 'x-user-defined') { + var buffer = new Buffer(newData.length); + for (var i = 0; i < newData.length; i++) + buffer[i] = newData.charCodeAt(i) & 0xff; + + self.push(buffer); + } else { + self.push(newData, self._charset); + } + self._pos = response.length; + } + break + case 'arraybuffer': + if (xhr.readyState !== rStates.DONE || !xhr.response) + break + response = xhr.response; + self.push(new Buffer(new Uint8Array(response))); + break + case 'moz-chunked-arraybuffer': // take whole + response = xhr.response; + if (xhr.readyState !== rStates.LOADING || !response) + break + self.push(new Buffer(new Uint8Array(response))); + break + case 'ms-stream': + response = xhr.response; + if (xhr.readyState !== rStates.LOADING) + break + var reader = new global$1.MSStreamReader(); + reader.onprogress = function() { + if (reader.result.byteLength > self._pos) { + self.push(new Buffer(new Uint8Array(reader.result.slice(self._pos)))); + self._pos = reader.result.byteLength; + } + }; + reader.onload = function() { + self.push(null); + }; + // reader.onerror = ??? // TODO: this + reader.readAsArrayBuffer(response); + break + } + + // The ms-stream case handles end separately in reader.onload() + if (self._xhr.readyState === rStates.DONE && self._mode !== 'ms-stream') { + self.push(null); + } + }; + + // from https://github.com/jhiesey/to-arraybuffer/blob/6502d9850e70ba7935a7df4ad86b358fc216f9f0/index.js + function toArrayBuffer (buf) { + // If the buffer is backed by a Uint8Array, a faster version will work + if (buf instanceof Uint8Array) { + // If the buffer isn't a subarray, return the underlying ArrayBuffer + if (buf.byteOffset === 0 && buf.byteLength === buf.buffer.byteLength) { + return buf.buffer + } else if (typeof buf.buffer.slice === 'function') { + // Otherwise we need to get a proper copy + return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength) + } + } + + if (isBuffer(buf)) { + // This is the slow version that will work with any Buffer + // implementation (even in old browsers) + var arrayCopy = new Uint8Array(buf.length); + var len = buf.length; + for (var i = 0; i < len; i++) { + arrayCopy[i] = buf[i]; + } + return arrayCopy.buffer + } else { + throw new Error('Argument must be a Buffer') + } + } + + function decideMode(preferBinary, useFetch) { + if (hasFetch && useFetch) { + return 'fetch' + } else if (mozchunkedarraybuffer) { + return 'moz-chunked-arraybuffer' + } else if (msstream) { + return 'ms-stream' + } else if (arraybuffer && preferBinary) { + return 'arraybuffer' + } else if (vbArray && preferBinary) { + return 'text:vbarray' + } else { + return 'text' + } + } + + function ClientRequest(opts) { + var self = this; + Writable.call(self); + + self._opts = opts; + self._body = []; + self._headers = {}; + if (opts.auth) + self.setHeader('Authorization', 'Basic ' + new Buffer(opts.auth).toString('base64')); + Object.keys(opts.headers).forEach(function(name) { + self.setHeader(name, opts.headers[name]); + }); + + var preferBinary; + var useFetch = true; + if (opts.mode === 'disable-fetch') { + // If the use of XHR should be preferred and includes preserving the 'content-type' header + useFetch = false; + preferBinary = true; + } else if (opts.mode === 'prefer-streaming') { + // If streaming is a high priority but binary compatibility and + // the accuracy of the 'content-type' header aren't + preferBinary = false; + } else if (opts.mode === 'allow-wrong-content-type') { + // If streaming is more important than preserving the 'content-type' header + preferBinary = !overrideMimeType; + } else if (!opts.mode || opts.mode === 'default' || opts.mode === 'prefer-fast') { + // Use binary if text streaming may corrupt data or the content-type header, or for speed + preferBinary = true; + } else { + throw new Error('Invalid value for opts.mode') + } + self._mode = decideMode(preferBinary, useFetch); + + self.on('finish', function() { + self._onFinish(); + }); + } + + inherits$2(ClientRequest, Writable); + // Taken from http://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader%28%29-method + var unsafeHeaders = [ + 'accept-charset', + 'accept-encoding', + 'access-control-request-headers', + 'access-control-request-method', + 'connection', + 'content-length', + 'cookie', + 'cookie2', + 'date', + 'dnt', + 'expect', + 'host', + 'keep-alive', + 'origin', + 'referer', + 'te', + 'trailer', + 'transfer-encoding', + 'upgrade', + 'user-agent', + 'via' + ]; + ClientRequest.prototype.setHeader = function(name, value) { + var self = this; + var lowerName = name.toLowerCase(); + // This check is not necessary, but it prevents warnings from browsers about setting unsafe + // headers. To be honest I'm not entirely sure hiding these warnings is a good thing, but + // http-browserify did it, so I will too. + if (unsafeHeaders.indexOf(lowerName) !== -1) + return + + self._headers[lowerName] = { + name: name, + value: value + }; + }; + + ClientRequest.prototype.getHeader = function(name) { + var self = this; + return self._headers[name.toLowerCase()].value + }; + + ClientRequest.prototype.removeHeader = function(name) { + var self = this; + delete self._headers[name.toLowerCase()]; + }; + + ClientRequest.prototype._onFinish = function() { + var self = this; + + if (self._destroyed) + return + var opts = self._opts; + + var headersObj = self._headers; + var body; + if (opts.method === 'POST' || opts.method === 'PUT' || opts.method === 'PATCH') { + if (blobConstructor()) { + body = new global$1.Blob(self._body.map(function(buffer) { + return toArrayBuffer(buffer) + }), { + type: (headersObj['content-type'] || {}).value || '' + }); + } else { + // get utf8 string + body = Buffer.concat(self._body).toString(); + } + } + + if (self._mode === 'fetch') { + var headers = Object.keys(headersObj).map(function(name) { + return [headersObj[name].name, headersObj[name].value] + }); + + global$1.fetch(self._opts.url, { + method: self._opts.method, + headers: headers, + body: body, + mode: 'cors', + credentials: opts.withCredentials ? 'include' : 'same-origin' + }).then(function(response) { + self._fetchResponse = response; + self._connect(); + }, function(reason) { + self.emit('error', reason); + }); + } else { + var xhr = self._xhr = new global$1.XMLHttpRequest(); + try { + xhr.open(self._opts.method, self._opts.url, true); + } catch (err) { + nextTick(function() { + self.emit('error', err); + }); + return + } + + // Can't set responseType on really old browsers + if ('responseType' in xhr) + xhr.responseType = self._mode.split(':')[0]; + + if ('withCredentials' in xhr) + xhr.withCredentials = !!opts.withCredentials; + + if (self._mode === 'text' && 'overrideMimeType' in xhr) + xhr.overrideMimeType('text/plain; charset=x-user-defined'); + + Object.keys(headersObj).forEach(function(name) { + xhr.setRequestHeader(headersObj[name].name, headersObj[name].value); + }); + + self._response = null; + xhr.onreadystatechange = function() { + switch (xhr.readyState) { + case rStates.LOADING: + case rStates.DONE: + self._onXHRProgress(); + break + } + }; + // Necessary for streaming in Firefox, since xhr.response is ONLY defined + // in onprogress, not in onreadystatechange with xhr.readyState = 3 + if (self._mode === 'moz-chunked-arraybuffer') { + xhr.onprogress = function() { + self._onXHRProgress(); + }; + } + + xhr.onerror = function() { + if (self._destroyed) + return + self.emit('error', new Error('XHR error')); + }; + + try { + xhr.send(body); + } catch (err) { + nextTick(function() { + self.emit('error', err); + }); + return + } + } + }; + + /** + * Checks if xhr.status is readable and non-zero, indicating no error. + * Even though the spec says it should be available in readyState 3, + * accessing it throws an exception in IE8 + */ + function statusValid(xhr) { + try { + var status = xhr.status; + return (status !== null && status !== 0) + } catch (e) { + return false + } + } + + ClientRequest.prototype._onXHRProgress = function() { + var self = this; + + if (!statusValid(self._xhr) || self._destroyed) + return + + if (!self._response) + self._connect(); + + self._response._onXHRProgress(); + }; + + ClientRequest.prototype._connect = function() { + var self = this; + + if (self._destroyed) + return + + self._response = new IncomingMessage(self._xhr, self._fetchResponse, self._mode); + self.emit('response', self._response); + }; + + ClientRequest.prototype._write = function(chunk, encoding, cb) { + var self = this; + + self._body.push(chunk); + cb(); + }; + + ClientRequest.prototype.abort = ClientRequest.prototype.destroy = function() { + var self = this; + self._destroyed = true; + if (self._response) + self._response._destroyed = true; + if (self._xhr) + self._xhr.abort(); + // Currently, there isn't a way to truly abort a fetch. + // If you like bikeshedding, see https://github.com/whatwg/fetch/issues/27 + }; + + ClientRequest.prototype.end = function(data, encoding, cb) { + var self = this; + if (typeof data === 'function') { + cb = data; + data = undefined; + } + + Writable.prototype.end.call(self, data, encoding, cb); + }; + + ClientRequest.prototype.flushHeaders = function() {}; + ClientRequest.prototype.setTimeout = function() {}; + ClientRequest.prototype.setNoDelay = function() {}; + ClientRequest.prototype.setSocketKeepAlive = function() {}; + + /*! https://mths.be/punycode v1.4.1 by @mathias */ + + + /** Highest positive signed 32-bit float value */ + var maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1 + + /** Bootstring parameters */ + var base = 36; + var tMin = 1; + var tMax = 26; + var skew = 38; + var damp = 700; + var initialBias = 72; + var initialN = 128; // 0x80 + var delimiter = '-'; // '\x2D' + var regexNonASCII = /[^\x20-\x7E]/; // unprintable ASCII chars + non-ASCII chars + var regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g; // RFC 3490 separators + + /** Error messages */ + var errors = { + 'overflow': 'Overflow: input needs wider integers to process', + 'not-basic': 'Illegal input >= 0x80 (not a basic code point)', + 'invalid-input': 'Invalid input' + }; + + /** Convenience shortcuts */ + var baseMinusTMin = base - tMin; + var floor$1 = Math.floor; + var stringFromCharCode = String.fromCharCode; + + /*--------------------------------------------------------------------------*/ + + /** + * A generic error utility function. + * @private + * @param {String} type The error type. + * @returns {Error} Throws a `RangeError` with the applicable error message. + */ + function error(type) { + throw new RangeError(errors[type]); + } + + /** + * A generic `Array#map` utility function. + * @private + * @param {Array} array The array to iterate over. + * @param {Function} callback The function that gets called for every array + * item. + * @returns {Array} A new array of values returned by the callback function. + */ + function map(array, fn) { + var length = array.length; + var result = []; + while (length--) { + result[length] = fn(array[length]); + } + return result; + } + + /** + * A simple `Array#map`-like wrapper to work with domain name strings or email + * addresses. + * @private + * @param {String} domain The domain name or email address. + * @param {Function} callback The function that gets called for every + * character. + * @returns {Array} A new string of characters returned by the callback + * function. + */ + function mapDomain(string, fn) { + var parts = string.split('@'); + var result = ''; + if (parts.length > 1) { + // In email addresses, only the domain name should be punycoded. Leave + // the local part (i.e. everything up to `@`) intact. + result = parts[0] + '@'; + string = parts[1]; + } + // Avoid `split(regex)` for IE8 compatibility. See #17. + string = string.replace(regexSeparators, '\x2E'); + var labels = string.split('.'); + var encoded = map(labels, fn).join('.'); + return result + encoded; + } + + /** + * Creates an array containing the numeric code points of each Unicode + * character in the string. While JavaScript uses UCS-2 internally, + * this function will convert a pair of surrogate halves (each of which + * UCS-2 exposes as separate characters) into a single code point, + * matching UTF-16. + * @see `punycode.ucs2.encode` + * @see + * @memberOf punycode.ucs2 + * @name decode + * @param {String} string The Unicode input string (UCS-2). + * @returns {Array} The new array of code points. + */ + function ucs2decode(string) { + var output = [], + counter = 0, + length = string.length, + value, + extra; + while (counter < length) { + value = string.charCodeAt(counter++); + if (value >= 0xD800 && value <= 0xDBFF && counter < length) { + // high surrogate, and there is a next character + extra = string.charCodeAt(counter++); + if ((extra & 0xFC00) == 0xDC00) { // low surrogate + output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000); + } else { + // unmatched surrogate; only append this code unit, in case the next + // code unit is the high surrogate of a surrogate pair + output.push(value); + counter--; + } + } else { + output.push(value); + } + } + return output; + } + + /** + * Converts a digit/integer into a basic code point. + * @see `basicToDigit()` + * @private + * @param {Number} digit The numeric value of a basic code point. + * @returns {Number} The basic code point whose value (when used for + * representing integers) is `digit`, which needs to be in the range + * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is + * used; else, the lowercase form is used. The behavior is undefined + * if `flag` is non-zero and `digit` has no uppercase form. + */ + function digitToBasic(digit, flag) { + // 0..25 map to ASCII a..z or A..Z + // 26..35 map to ASCII 0..9 + return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5); + } + + /** + * Bias adaptation function as per section 3.4 of RFC 3492. + * https://tools.ietf.org/html/rfc3492#section-3.4 + * @private + */ + function adapt(delta, numPoints, firstTime) { + var k = 0; + delta = firstTime ? floor$1(delta / damp) : delta >> 1; + delta += floor$1(delta / numPoints); + for ( /* no initialization */ ; delta > baseMinusTMin * tMax >> 1; k += base) { + delta = floor$1(delta / baseMinusTMin); + } + return floor$1(k + (baseMinusTMin + 1) * delta / (delta + skew)); + } + + /** + * Converts a string of Unicode symbols (e.g. a domain name label) to a + * Punycode string of ASCII-only symbols. + * @memberOf punycode + * @param {String} input The string of Unicode symbols. + * @returns {String} The resulting Punycode string of ASCII-only symbols. + */ + function encode(input) { + var n, + delta, + handledCPCount, + basicLength, + bias, + j, + m, + q, + k, + t, + currentValue, + output = [], + /** `inputLength` will hold the number of code points in `input`. */ + inputLength, + /** Cached calculation results */ + handledCPCountPlusOne, + baseMinusT, + qMinusT; + + // Convert the input in UCS-2 to Unicode + input = ucs2decode(input); + + // Cache the length + inputLength = input.length; + + // Initialize the state + n = initialN; + delta = 0; + bias = initialBias; + + // Handle the basic code points + for (j = 0; j < inputLength; ++j) { + currentValue = input[j]; + if (currentValue < 0x80) { + output.push(stringFromCharCode(currentValue)); + } + } + + handledCPCount = basicLength = output.length; + + // `handledCPCount` is the number of code points that have been handled; + // `basicLength` is the number of basic code points. + + // Finish the basic string - if it is not empty - with a delimiter + if (basicLength) { + output.push(delimiter); + } + + // Main encoding loop: + while (handledCPCount < inputLength) { + + // All non-basic code points < n have been handled already. Find the next + // larger one: + for (m = maxInt, j = 0; j < inputLength; ++j) { + currentValue = input[j]; + if (currentValue >= n && currentValue < m) { + m = currentValue; + } + } + + // Increase `delta` enough to advance the decoder's state to , + // but guard against overflow + handledCPCountPlusOne = handledCPCount + 1; + if (m - n > floor$1((maxInt - delta) / handledCPCountPlusOne)) { + error('overflow'); + } + + delta += (m - n) * handledCPCountPlusOne; + n = m; + + for (j = 0; j < inputLength; ++j) { + currentValue = input[j]; + + if (currentValue < n && ++delta > maxInt) { + error('overflow'); + } + + if (currentValue == n) { + // Represent delta as a generalized variable-length integer + for (q = delta, k = base; /* no condition */ ; k += base) { + t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); + if (q < t) { + break; + } + qMinusT = q - t; + baseMinusT = base - t; + output.push( + stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)) + ); + q = floor$1(qMinusT / baseMinusT); + } + + output.push(stringFromCharCode(digitToBasic(q, 0))); + bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength); + delta = 0; + ++handledCPCount; + } + } + + ++delta; + ++n; + + } + return output.join(''); + } + + /** + * Converts a Unicode string representing a domain name or an email address to + * Punycode. Only the non-ASCII parts of the domain name will be converted, + * i.e. it doesn't matter if you call it with a domain that's already in + * ASCII. + * @memberOf punycode + * @param {String} input The domain name or email address to convert, as a + * Unicode string. + * @returns {String} The Punycode representation of the given domain name or + * email address. + */ + function toASCII(input) { + return mapDomain(input, function(string) { + return regexNonASCII.test(string) ? + 'xn--' + encode(string) : + string; + }); + } + + // Copyright Joyent, Inc. and other Node contributors. + // + // Permission is hereby granted, free of charge, to any person obtaining a + // copy of this software and associated documentation files (the + // "Software"), to deal in the Software without restriction, including + // without limitation the rights to use, copy, modify, merge, publish, + // distribute, sublicense, and/or sell copies of the Software, and to permit + // persons to whom the Software is furnished to do so, subject to the + // following conditions: + // + // The above copyright notice and this permission notice shall be included + // in all copies or substantial portions of the Software. + // + // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + // USE OR OTHER DEALINGS IN THE SOFTWARE. + + + // If obj.hasOwnProperty has been overridden, then calling + // obj.hasOwnProperty(prop) will break. + // See: https://github.com/joyent/node/issues/1707 + function hasOwnProperty$2(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); + } + var isArray$2 = Array.isArray || function (xs) { + return Object.prototype.toString.call(xs) === '[object Array]'; + }; + function stringifyPrimitive(v) { + switch (typeof v) { + case 'string': + return v; + + case 'boolean': + return v ? 'true' : 'false'; + + case 'number': + return isFinite(v) ? v : ''; + + default: + return ''; + } + } + + function stringify$2 (obj, sep, eq, name) { + sep = sep || '&'; + eq = eq || '='; + if (obj === null) { + obj = undefined; + } + + if (typeof obj === 'object') { + return map$1(objectKeys(obj), function(k) { + var ks = encodeURIComponent(stringifyPrimitive(k)) + eq; + if (isArray$2(obj[k])) { + return map$1(obj[k], function(v) { + return ks + encodeURIComponent(stringifyPrimitive(v)); + }).join(sep); + } else { + return ks + encodeURIComponent(stringifyPrimitive(obj[k])); + } + }).join(sep); + + } + + if (!name) return ''; + return encodeURIComponent(stringifyPrimitive(name)) + eq + + encodeURIComponent(stringifyPrimitive(obj)); + } + function map$1 (xs, f) { + if (xs.map) return xs.map(f); + var res = []; + for (var i = 0; i < xs.length; i++) { + res.push(f(xs[i], i)); + } + return res; + } + + var objectKeys = Object.keys || function (obj) { + var res = []; + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key); + } + return res; + }; + + function parse(qs, sep, eq, options) { + sep = sep || '&'; + eq = eq || '='; + var obj = {}; + + if (typeof qs !== 'string' || qs.length === 0) { + return obj; + } + + var regexp = /\+/g; + qs = qs.split(sep); + + var maxKeys = 1000; + if (options && typeof options.maxKeys === 'number') { + maxKeys = options.maxKeys; + } + + var len = qs.length; + // maxKeys <= 0 means that we should not limit keys count + if (maxKeys > 0 && len > maxKeys) { + len = maxKeys; + } + + for (var i = 0; i < len; ++i) { + var x = qs[i].replace(regexp, '%20'), + idx = x.indexOf(eq), + kstr, vstr, k, v; + + if (idx >= 0) { + kstr = x.substr(0, idx); + vstr = x.substr(idx + 1); + } else { + kstr = x; + vstr = ''; + } + + k = decodeURIComponent(kstr); + v = decodeURIComponent(vstr); + + if (!hasOwnProperty$2(obj, k)) { + obj[k] = v; + } else if (isArray$2(obj[k])) { + obj[k].push(v); + } else { + obj[k] = [obj[k], v]; + } + } + + return obj; + } + + // Copyright Joyent, Inc. and other Node contributors. + function Url() { + this.protocol = null; + this.slashes = null; + this.auth = null; + this.host = null; + this.port = null; + this.hostname = null; + this.hash = null; + this.search = null; + this.query = null; + this.pathname = null; + this.path = null; + this.href = null; + } + + // Reference: RFC 3986, RFC 1808, RFC 2396 + + // define these here so at least they only have to be + // compiled once on the first module load. + var protocolPattern = /^([a-z0-9.+-]+:)/i, + portPattern = /:[0-9]*$/, + + // Special case for a simple path URL + simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/, + + // RFC 2396: characters reserved for delimiting URLs. + // We actually just auto-escape these. + delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'], + + // RFC 2396: characters not allowed for various reasons. + unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims), + + // Allowed by RFCs, but cause of XSS attacks. Always escape these. + autoEscape = ['\''].concat(unwise), + // Characters that are never ever allowed in a hostname. + // Note that any invalid chars are also handled, but these + // are the ones that are *expected* to be seen, so we fast-path + // them. + nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape), + hostEndingChars = ['/', '?', '#'], + hostnameMaxLen = 255, + hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/, + hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/, + // protocols that can allow "unsafe" and "unwise" chars. + unsafeProtocol = { + 'javascript': true, + 'javascript:': true + }, + // protocols that never have a hostname. + hostlessProtocol = { + 'javascript': true, + 'javascript:': true + }, + // protocols that always contain a // bit. + slashedProtocol = { + 'http': true, + 'https': true, + 'ftp': true, + 'gopher': true, + 'file': true, + 'http:': true, + 'https:': true, + 'ftp:': true, + 'gopher:': true, + 'file:': true + }; + + function urlParse(url, parseQueryString, slashesDenoteHost) { + if (url && isObject(url) && url instanceof Url) return url; + + var u = new Url; + u.parse(url, parseQueryString, slashesDenoteHost); + return u; + } + Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) { + return parse$1(this, url, parseQueryString, slashesDenoteHost); + }; + + function parse$1(self, url, parseQueryString, slashesDenoteHost) { + if (!isString(url)) { + throw new TypeError('Parameter \'url\' must be a string, not ' + typeof url); + } + + // Copy chrome, IE, opera backslash-handling behavior. + // Back slashes before the query string get converted to forward slashes + // See: https://code.google.com/p/chromium/issues/detail?id=25916 + var queryIndex = url.indexOf('?'), + splitter = + (queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#', + uSplit = url.split(splitter), + slashRegex = /\\/g; + uSplit[0] = uSplit[0].replace(slashRegex, '/'); + url = uSplit.join(splitter); + + var rest = url; + + // trim before proceeding. + // This is to support parse stuff like " http://foo.com \n" + rest = rest.trim(); + + if (!slashesDenoteHost && url.split('#').length === 1) { + // Try fast path regexp + var simplePath = simplePathPattern.exec(rest); + if (simplePath) { + self.path = rest; + self.href = rest; + self.pathname = simplePath[1]; + if (simplePath[2]) { + self.search = simplePath[2]; + if (parseQueryString) { + self.query = parse(self.search.substr(1)); + } else { + self.query = self.search.substr(1); + } + } else if (parseQueryString) { + self.search = ''; + self.query = {}; + } + return self; + } + } + + var proto = protocolPattern.exec(rest); + if (proto) { + proto = proto[0]; + var lowerProto = proto.toLowerCase(); + self.protocol = lowerProto; + rest = rest.substr(proto.length); + } + + // figure out if it's got a host + // user@server is *always* interpreted as a hostname, and url + // resolution will treat //foo/bar as host=foo,path=bar because that's + // how the browser resolves relative URLs. + if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) { + var slashes = rest.substr(0, 2) === '//'; + if (slashes && !(proto && hostlessProtocol[proto])) { + rest = rest.substr(2); + self.slashes = true; + } + } + var i, hec, l, p; + if (!hostlessProtocol[proto] && + (slashes || (proto && !slashedProtocol[proto]))) { + + // there's a hostname. + // the first instance of /, ?, ;, or # ends the host. + // + // If there is an @ in the hostname, then non-host chars *are* allowed + // to the left of the last @ sign, unless some host-ending character + // comes *before* the @-sign. + // URLs are obnoxious. + // + // ex: + // http://a@b@c/ => user:a@b host:c + // http://a@b?@c => user:a host:c path:/?@c + + // v0.12 TODO(isaacs): This is not quite how Chrome does things. + // Review our test case against browsers more comprehensively. + + // find the first instance of any hostEndingChars + var hostEnd = -1; + for (i = 0; i < hostEndingChars.length; i++) { + hec = rest.indexOf(hostEndingChars[i]); + if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) + hostEnd = hec; + } + + // at this point, either we have an explicit point where the + // auth portion cannot go past, or the last @ char is the decider. + var auth, atSign; + if (hostEnd === -1) { + // atSign can be anywhere. + atSign = rest.lastIndexOf('@'); + } else { + // atSign must be in auth portion. + // http://a@b/c@d => host:b auth:a path:/c@d + atSign = rest.lastIndexOf('@', hostEnd); + } + + // Now we have a portion which is definitely the auth. + // Pull that off. + if (atSign !== -1) { + auth = rest.slice(0, atSign); + rest = rest.slice(atSign + 1); + self.auth = decodeURIComponent(auth); + } + + // the host is the remaining to the left of the first non-host char + hostEnd = -1; + for (i = 0; i < nonHostChars.length; i++) { + hec = rest.indexOf(nonHostChars[i]); + if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) + hostEnd = hec; + } + // if we still have not hit it, then the entire thing is a host. + if (hostEnd === -1) + hostEnd = rest.length; + + self.host = rest.slice(0, hostEnd); + rest = rest.slice(hostEnd); + + // pull out port. + parseHost(self); + + // we've indicated that there is a hostname, + // so even if it's empty, it has to be present. + self.hostname = self.hostname || ''; + + // if hostname begins with [ and ends with ] + // assume that it's an IPv6 address. + var ipv6Hostname = self.hostname[0] === '[' && + self.hostname[self.hostname.length - 1] === ']'; + + // validate a little. + if (!ipv6Hostname) { + var hostparts = self.hostname.split(/\./); + for (i = 0, l = hostparts.length; i < l; i++) { + var part = hostparts[i]; + if (!part) continue; + if (!part.match(hostnamePartPattern)) { + var newpart = ''; + for (var j = 0, k = part.length; j < k; j++) { + if (part.charCodeAt(j) > 127) { + // we replace non-ASCII char with a temporary placeholder + // we need this to make sure size of hostname is not + // broken by replacing non-ASCII by nothing + newpart += 'x'; + } else { + newpart += part[j]; + } + } + // we test again with ASCII char only + if (!newpart.match(hostnamePartPattern)) { + var validParts = hostparts.slice(0, i); + var notHost = hostparts.slice(i + 1); + var bit = part.match(hostnamePartStart); + if (bit) { + validParts.push(bit[1]); + notHost.unshift(bit[2]); + } + if (notHost.length) { + rest = '/' + notHost.join('.') + rest; + } + self.hostname = validParts.join('.'); + break; + } + } + } + } + + if (self.hostname.length > hostnameMaxLen) { + self.hostname = ''; + } else { + // hostnames are always lower case. + self.hostname = self.hostname.toLowerCase(); + } + + if (!ipv6Hostname) { + // IDNA Support: Returns a punycoded representation of "domain". + // It only converts parts of the domain name that + // have non-ASCII characters, i.e. it doesn't matter if + // you call it with a domain that already is ASCII-only. + self.hostname = toASCII(self.hostname); + } + + p = self.port ? ':' + self.port : ''; + var h = self.hostname || ''; + self.host = h + p; + self.href += self.host; + + // strip [ and ] from the hostname + // the host field still retains them, though + if (ipv6Hostname) { + self.hostname = self.hostname.substr(1, self.hostname.length - 2); + if (rest[0] !== '/') { + rest = '/' + rest; + } + } + } + + // now rest is set to the post-host stuff. + // chop off any delim chars. + if (!unsafeProtocol[lowerProto]) { + + // First, make 100% sure that any "autoEscape" chars get + // escaped, even if encodeURIComponent doesn't think they + // need to be. + for (i = 0, l = autoEscape.length; i < l; i++) { + var ae = autoEscape[i]; + if (rest.indexOf(ae) === -1) + continue; + var esc = encodeURIComponent(ae); + if (esc === ae) { + esc = escape(ae); + } + rest = rest.split(ae).join(esc); + } + } + + + // chop off from the tail first. + var hash = rest.indexOf('#'); + if (hash !== -1) { + // got a fragment string. + self.hash = rest.substr(hash); + rest = rest.slice(0, hash); + } + var qm = rest.indexOf('?'); + if (qm !== -1) { + self.search = rest.substr(qm); + self.query = rest.substr(qm + 1); + if (parseQueryString) { + self.query = parse(self.query); + } + rest = rest.slice(0, qm); + } else if (parseQueryString) { + // no query string, but parseQueryString still requested + self.search = ''; + self.query = {}; + } + if (rest) self.pathname = rest; + if (slashedProtocol[lowerProto] && + self.hostname && !self.pathname) { + self.pathname = '/'; + } + + //to support http.request + if (self.pathname || self.search) { + p = self.pathname || ''; + var s = self.search || ''; + self.path = p + s; + } + + // finally, reconstruct the href based on what has been validated. + self.href = format$1(self); + return self; + } + + function format$1(self) { + var auth = self.auth || ''; + if (auth) { + auth = encodeURIComponent(auth); + auth = auth.replace(/%3A/i, ':'); + auth += '@'; + } + + var protocol = self.protocol || '', + pathname = self.pathname || '', + hash = self.hash || '', + host = false, + query = ''; + + if (self.host) { + host = auth + self.host; + } else if (self.hostname) { + host = auth + (self.hostname.indexOf(':') === -1 ? + self.hostname : + '[' + this.hostname + ']'); + if (self.port) { + host += ':' + self.port; + } + } + + if (self.query && + isObject(self.query) && + Object.keys(self.query).length) { + query = stringify$2(self.query); + } + + var search = self.search || (query && ('?' + query)) || ''; + + if (protocol && protocol.substr(-1) !== ':') protocol += ':'; + + // only the slashedProtocols get the //. Not mailto:, xmpp:, etc. + // unless they had them to begin with. + if (self.slashes || + (!protocol || slashedProtocol[protocol]) && host !== false) { + host = '//' + (host || ''); + if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname; + } else if (!host) { + host = ''; + } + + if (hash && hash.charAt(0) !== '#') hash = '#' + hash; + if (search && search.charAt(0) !== '?') search = '?' + search; + + pathname = pathname.replace(/[?#]/g, function(match) { + return encodeURIComponent(match); + }); + search = search.replace('#', '%23'); + + return protocol + host + pathname + search + hash; + } + + Url.prototype.format = function() { + return format$1(this); + }; + + Url.prototype.resolve = function(relative) { + return this.resolveObject(urlParse(relative, false, true)).format(); + }; + + Url.prototype.resolveObject = function(relative) { + if (isString(relative)) { + var rel = new Url(); + rel.parse(relative, false, true); + relative = rel; + } + + var result = new Url(); + var tkeys = Object.keys(this); + for (var tk = 0; tk < tkeys.length; tk++) { + var tkey = tkeys[tk]; + result[tkey] = this[tkey]; + } + + // hash is always overridden, no matter what. + // even href="" will remove it. + result.hash = relative.hash; + + // if the relative url is empty, then there's nothing left to do here. + if (relative.href === '') { + result.href = result.format(); + return result; + } + + // hrefs like //foo/bar always cut to the protocol. + if (relative.slashes && !relative.protocol) { + // take everything except the protocol from relative + var rkeys = Object.keys(relative); + for (var rk = 0; rk < rkeys.length; rk++) { + var rkey = rkeys[rk]; + if (rkey !== 'protocol') + result[rkey] = relative[rkey]; + } + + //urlParse appends trailing / to urls like http://www.example.com + if (slashedProtocol[result.protocol] && + result.hostname && !result.pathname) { + result.path = result.pathname = '/'; + } + + result.href = result.format(); + return result; + } + var relPath; + if (relative.protocol && relative.protocol !== result.protocol) { + // if it's a known url protocol, then changing + // the protocol does weird things + // first, if it's not file:, then we MUST have a host, + // and if there was a path + // to begin with, then we MUST have a path. + // if it is file:, then the host is dropped, + // because that's known to be hostless. + // anything else is assumed to be absolute. + if (!slashedProtocol[relative.protocol]) { + var keys = Object.keys(relative); + for (var v = 0; v < keys.length; v++) { + var k = keys[v]; + result[k] = relative[k]; + } + result.href = result.format(); + return result; + } + + result.protocol = relative.protocol; + if (!relative.host && !hostlessProtocol[relative.protocol]) { + relPath = (relative.pathname || '').split('/'); + while (relPath.length && !(relative.host = relPath.shift())); + if (!relative.host) relative.host = ''; + if (!relative.hostname) relative.hostname = ''; + if (relPath[0] !== '') relPath.unshift(''); + if (relPath.length < 2) relPath.unshift(''); + result.pathname = relPath.join('/'); + } else { + result.pathname = relative.pathname; + } + result.search = relative.search; + result.query = relative.query; + result.host = relative.host || ''; + result.auth = relative.auth; + result.hostname = relative.hostname || relative.host; + result.port = relative.port; + // to support http.request + if (result.pathname || result.search) { + var p = result.pathname || ''; + var s = result.search || ''; + result.path = p + s; + } + result.slashes = result.slashes || relative.slashes; + result.href = result.format(); + return result; + } + + var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'), + isRelAbs = ( + relative.host || + relative.pathname && relative.pathname.charAt(0) === '/' + ), + mustEndAbs = (isRelAbs || isSourceAbs || + (result.host && relative.pathname)), + removeAllDots = mustEndAbs, + srcPath = result.pathname && result.pathname.split('/') || [], + psychotic = result.protocol && !slashedProtocol[result.protocol]; + relPath = relative.pathname && relative.pathname.split('/') || []; + // if the url is a non-slashed url, then relative + // links like ../.. should be able + // to crawl up to the hostname, as well. This is strange. + // result.protocol has already been set by now. + // Later on, put the first path part into the host field. + if (psychotic) { + result.hostname = ''; + result.port = null; + if (result.host) { + if (srcPath[0] === '') srcPath[0] = result.host; + else srcPath.unshift(result.host); + } + result.host = ''; + if (relative.protocol) { + relative.hostname = null; + relative.port = null; + if (relative.host) { + if (relPath[0] === '') relPath[0] = relative.host; + else relPath.unshift(relative.host); + } + relative.host = null; + } + mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === ''); + } + var authInHost; + if (isRelAbs) { + // it's absolute. + result.host = (relative.host || relative.host === '') ? + relative.host : result.host; + result.hostname = (relative.hostname || relative.hostname === '') ? + relative.hostname : result.hostname; + result.search = relative.search; + result.query = relative.query; + srcPath = relPath; + // fall through to the dot-handling below. + } else if (relPath.length) { + // it's relative + // throw away the existing file, and take the new path instead. + if (!srcPath) srcPath = []; + srcPath.pop(); + srcPath = srcPath.concat(relPath); + result.search = relative.search; + result.query = relative.query; + } else if (!isNullOrUndefined(relative.search)) { + // just pull out the search. + // like href='?foo'. + // Put this after the other two cases because it simplifies the booleans + if (psychotic) { + result.hostname = result.host = srcPath.shift(); + //occationaly the auth can get stuck only in host + //this especially happens in cases like + //url.resolveObject('mailto:local1@domain1', 'local2@domain2') + authInHost = result.host && result.host.indexOf('@') > 0 ? + result.host.split('@') : false; + if (authInHost) { + result.auth = authInHost.shift(); + result.host = result.hostname = authInHost.shift(); + } + } + result.search = relative.search; + result.query = relative.query; + //to support http.request + if (!isNull(result.pathname) || !isNull(result.search)) { + result.path = (result.pathname ? result.pathname : '') + + (result.search ? result.search : ''); + } + result.href = result.format(); + return result; + } + + if (!srcPath.length) { + // no path at all. easy. + // we've already handled the other stuff above. + result.pathname = null; + //to support http.request + if (result.search) { + result.path = '/' + result.search; + } else { + result.path = null; + } + result.href = result.format(); + return result; + } + + // if a url ENDs in . or .., then it must get a trailing slash. + // however, if it ends in anything else non-slashy, + // then it must NOT get a trailing slash. + var last = srcPath.slice(-1)[0]; + var hasTrailingSlash = ( + (result.host || relative.host || srcPath.length > 1) && + (last === '.' || last === '..') || last === ''); + + // strip single dots, resolve double dots to parent dir + // if the path tries to go above the root, `up` ends up > 0 + var up = 0; + for (var i = srcPath.length; i >= 0; i--) { + last = srcPath[i]; + if (last === '.') { + srcPath.splice(i, 1); + } else if (last === '..') { + srcPath.splice(i, 1); + up++; + } else if (up) { + srcPath.splice(i, 1); + up--; + } + } + + // if the path is allowed to go above the root, restore leading ..s + if (!mustEndAbs && !removeAllDots) { + for (; up--; up) { + srcPath.unshift('..'); + } + } + + if (mustEndAbs && srcPath[0] !== '' && + (!srcPath[0] || srcPath[0].charAt(0) !== '/')) { + srcPath.unshift(''); + } + + if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) { + srcPath.push(''); + } + + var isAbsolute = srcPath[0] === '' || + (srcPath[0] && srcPath[0].charAt(0) === '/'); + + // put the host back + if (psychotic) { + result.hostname = result.host = isAbsolute ? '' : + srcPath.length ? srcPath.shift() : ''; + //occationaly the auth can get stuck only in host + //this especially happens in cases like + //url.resolveObject('mailto:local1@domain1', 'local2@domain2') + authInHost = result.host && result.host.indexOf('@') > 0 ? + result.host.split('@') : false; + if (authInHost) { + result.auth = authInHost.shift(); + result.host = result.hostname = authInHost.shift(); + } + } + + mustEndAbs = mustEndAbs || (result.host && srcPath.length); + + if (mustEndAbs && !isAbsolute) { + srcPath.unshift(''); + } + + if (!srcPath.length) { + result.pathname = null; + result.path = null; + } else { + result.pathname = srcPath.join('/'); + } + + //to support request.http + if (!isNull(result.pathname) || !isNull(result.search)) { + result.path = (result.pathname ? result.pathname : '') + + (result.search ? result.search : ''); + } + result.auth = relative.auth || result.auth; + result.slashes = result.slashes || relative.slashes; + result.href = result.format(); + return result; + }; + + Url.prototype.parseHost = function() { + return parseHost(this); + }; + + function parseHost(self) { + var host = self.host; + var port = portPattern.exec(host); + if (port) { + port = port[0]; + if (port !== ':') { + self.port = port.substr(1); + } + host = host.substr(0, host.length - port.length); + } + if (host) self.hostname = host; + } + + function request(opts, cb) { + if (typeof opts === 'string') + opts = urlParse(opts); + + + // Normally, the page is loaded from http or https, so not specifying a protocol + // will result in a (valid) protocol-relative url. However, this won't work if + // the protocol is something else, like 'file:' + var defaultProtocol = global$1.location.protocol.search(/^https?:$/) === -1 ? 'http:' : ''; + + var protocol = opts.protocol || defaultProtocol; + var host = opts.hostname || opts.host; + var port = opts.port; + var path = opts.path || '/'; + + // Necessary for IPv6 addresses + if (host && host.indexOf(':') !== -1) + host = '[' + host + ']'; + + // This may be a relative url. The browser should always be able to interpret it correctly. + opts.url = (host ? (protocol + '//' + host) : '') + (port ? ':' + port : '') + path; + opts.method = (opts.method || 'GET').toUpperCase(); + opts.headers = opts.headers || {}; + + // Also valid opts.auth, opts.mode + + var req = new ClientRequest(opts); + if (cb) + req.on('response', cb); + return req + } + + function get(opts, cb) { + var req = request(opts, cb); + req.end(); + return req + } + + function Agent() {} + Agent.defaultMaxSockets = 4; + + var METHODS = [ + 'CHECKOUT', + 'CONNECT', + 'COPY', + 'DELETE', + 'GET', + 'HEAD', + 'LOCK', + 'M-SEARCH', + 'MERGE', + 'MKACTIVITY', + 'MKCOL', + 'MOVE', + 'NOTIFY', + 'OPTIONS', + 'PATCH', + 'POST', + 'PROPFIND', + 'PROPPATCH', + 'PURGE', + 'PUT', + 'REPORT', + 'SEARCH', + 'SUBSCRIBE', + 'TRACE', + 'UNLOCK', + 'UNSUBSCRIBE' + ]; + var STATUS_CODES = { + 100: 'Continue', + 101: 'Switching Protocols', + 102: 'Processing', // RFC 2518, obsoleted by RFC 4918 + 200: 'OK', + 201: 'Created', + 202: 'Accepted', + 203: 'Non-Authoritative Information', + 204: 'No Content', + 205: 'Reset Content', + 206: 'Partial Content', + 207: 'Multi-Status', // RFC 4918 + 300: 'Multiple Choices', + 301: 'Moved Permanently', + 302: 'Moved Temporarily', + 303: 'See Other', + 304: 'Not Modified', + 305: 'Use Proxy', + 307: 'Temporary Redirect', + 400: 'Bad Request', + 401: 'Unauthorized', + 402: 'Payment Required', + 403: 'Forbidden', + 404: 'Not Found', + 405: 'Method Not Allowed', + 406: 'Not Acceptable', + 407: 'Proxy Authentication Required', + 408: 'Request Time-out', + 409: 'Conflict', + 410: 'Gone', + 411: 'Length Required', + 412: 'Precondition Failed', + 413: 'Request Entity Too Large', + 414: 'Request-URI Too Large', + 415: 'Unsupported Media Type', + 416: 'Requested Range Not Satisfiable', + 417: 'Expectation Failed', + 418: 'I\'m a teapot', // RFC 2324 + 422: 'Unprocessable Entity', // RFC 4918 + 423: 'Locked', // RFC 4918 + 424: 'Failed Dependency', // RFC 4918 + 425: 'Unordered Collection', // RFC 4918 + 426: 'Upgrade Required', // RFC 2817 + 428: 'Precondition Required', // RFC 6585 + 429: 'Too Many Requests', // RFC 6585 + 431: 'Request Header Fields Too Large', // RFC 6585 + 500: 'Internal Server Error', + 501: 'Not Implemented', + 502: 'Bad Gateway', + 503: 'Service Unavailable', + 504: 'Gateway Time-out', + 505: 'HTTP Version Not Supported', + 506: 'Variant Also Negotiates', // RFC 2295 + 507: 'Insufficient Storage', // RFC 4918 + 509: 'Bandwidth Limit Exceeded', + 510: 'Not Extended', // RFC 2774 + 511: 'Network Authentication Required' // RFC 6585 + }; + + var http = { + request, + get, + Agent, + METHODS, + STATUS_CODES + }; + + var isNode$2 = false; + try { + isNode$2 = Object.prototype.toString.call(global$1.process) === '[object process]'; + } catch (e) { + } + + async function loadGunDepth(chain) { + var maxDepth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2; + var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; + + opts.maxBreadth = opts.maxBreadth || 50; + opts.cache = opts.cache || {}; + + return chain.then().then(function (layer) { + + // Depth limit reached, or non-object, or array value returned + if (maxDepth < 1 || !layer || (typeof layer === 'undefined' ? 'undefined' : _typeof(layer)) !== 'object' || layer.constructor === Array) { + return layer; + } + + var bcount = 0; + var promises = _Object$keys(layer).map(function (key) { + // Only fetch links & restrict total search queries to maxBreadth ^ maxDepth requests + if (!Gun.val.link.is(layer[key]) || ++bcount >= opts.maxBreadth) { + return; + } + + // During one recursive lookup, don't fetch the same key multiple times + if (opts.cache[key]) { + return opts.cache[key].then(function (data) { + layer[key] = data; + }); + } + + return opts.cache[key] = loadGunDepth(chain.get(key), maxDepth - 1, opts).then(function (data) { + layer[key] = data; + }); + }); + + return _Promise.all(promises).then(function () { + return layer; + }); + }); + } + + /* + * Helper for managing pools of Gun nodes. Primarily meant to simplify toplogy tracking in Iris tests. + * For reference, here's a run-through by example. Under each call, is an explanation of what happens. + * + * Instances can be identified by the port they're listening on, which is saved under .netPort for reference. + * + * const nets = GunNets(); + * + * nets.spawnNodes(2): * net ID: 1, A root, B points to A + * - returns [A, B] + * - B peers with A + * - netId is 1 for both + * + * nets.spawnNodes(1): + * - returns [C] + * - C has no peers + * - netId is 2 + * + * nets.spawnNodes(2, C.netId) + * - returns [D, E] + * - D, E both peer with C + * - netId is 2 + * + * nets.spawnNodes(1, E.netId) + * - returns [F] + * - F peers with C + * - netId is 2 + * + * nets.spawnNodes(2, 'test') + * - returns [G, H] + * - H peers with G + * - netId is 'test' + * + * nets.joinNets(B, H) + * - A peers with G (and B by proxy), G is root, so peering goes like: + * B -> A -> G + * H -> G + * - All nodes now have G.netID, so 'test' as .netID + * + * nets.joinNets(D, H) + * - D,E,F still point to C, which now peers with G, meaning: + * B -> A -> G + * H -> G + * D,E,F -> C -> G + * - All share netId 'test' + * + * @param fromPort + * @param ip + * @constructor + */ + function GunNets() { + var _this = this; + + var fromPort = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 12500; + var ip = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '127.0.0.1'; + + var gunNets = {}; + var nextNetId = 1; + var nextPort = fromPort; + + // Small internal helper function. Just adds a new peer to the given gun instance. + function addPeer(gun, ip, port) { + //const oldPeers = gun.opt()['_'].opt.peers; + return gun.opt({ peers: ['http: *' + ip + ':' + port + '/gun'] }); // Should these be linked both ways? + } + + async function dropPeer(gun, peerUrl) { + // If peerUrl not specified -> drop all + if (!peerUrl) { + return await _Promise.all(_Object$keys(gun._.opt.peers).map(function (key) { + return dropPeer(gun, key); + })); + } + + var peer = gun._.opt.peers[peerUrl]; + if (peer.wire) { + peer.url = peer.id = null; // Prevent reconnecting to URL + if (peer.wire) { + await peer.wire.close(); // Websocket, if open + } + } + + delete gun._.opt.peers[peerUrl]; + } + + /* + * When called, creates a number of Gun nodes, all having the root node as their peer. If netId is not given, + * next sequential number is used. If netId of an existing net is provided, will use its root node as the + * target and add new nodes to the same net. + * + * Returns the list of newly created nodes. + * + * @param number + * @param netId + * + */ + this.spawnNodes = function () { + var number = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; + var netId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; + + if (!netId) { + netId = nextNetId++; + } + + var ports = []; + for (var i = 0; i < number; ++i) { + ports.push(nextPort++); + } + + // Spawn guns, connect them to each other + var newGuns = ports.map(function (port) { + var server = http.createServer(Gun.serve).listen(port, ip); + var g = new Gun({ + radisk: false, + port: port, + multicast: false, + peers: {}, + // file: `${configDir}/${gunDBName}.${port}`, + web: server + }); + g.netPort = port; + g.netId = netId; + return g; + }); + + // Connect root node to other peers, if applicable + var root = gunNets[netId] || newGuns[0]; + newGuns.forEach(function (gun) { + // Don't connect to itself, if root is newGuns[0] + if (gun.netPort === root.netPort) { + return; + } + addPeer(gun, ip, root.netPort); + addPeer(root, ip, gun.netPort); + }); + + // Store in gunNets + if (!gunNets[netId]) { + gunNets[netId] = newGuns; + } else { + var _gunNets$netId; + + (_gunNets$netId = gunNets[netId]).push.apply(_gunNets$netId, newGuns); + } + + return newGuns; + }; + + /* + * Peer-connects childMember's root node to parentMember's root. + * + * All childMember's nodes are re-tagged with parentMember's netId and the old child netId ceases to exist. + * If netId was already the same between groups, nothing happens. + * + * @param parentMember + * @param childMember + * @returns {*} + */ + this.joinNets = function (childMember, parentMember) { + var _gunNets$root$netId; + + // If already in the same net, just return the full list of nodes + if (parentMember.netId === childMember.netId) { + return gunNets[parentMember.netId]; + } + + // Move child net under parent + var root = gunNets[parentMember.netId][0]; + var subChain = gunNets[childMember.netId]; + if (!root || !subChain) { + throw new Error('What are you feeding me??? Either of the gun instances does not seem to be known to us!'); + } + + delete gunNets[childMember.netId]; + addPeer(subChain[0], ip, root.netPort); + subChain.forEach(function (gun) { + gun.netId = root.netId; + }); + + (_gunNets$root$netId = gunNets[root.netId]).push.apply(_gunNets$root$netId, subChain); + + return gunNets[root.netId]; + }; + + this.describe = function () { + var mapping = _Object$keys(gunNets).map(function (key) { + var rows = gunNets[key].map(function (gun) { + var peers = _Object$keys(gun._.opt.peers).filter(function (key) { + return key.length > 2; + }).join(' '); + return ' :' + gun.netPort + ' ' + peers; + }).join('\n'); + return key + ' ->\n' + rows; + }).join('\n'); + return '== Net mapping / -> [: [, ...], ...] ==\n' + mapping; + }; + + this.close = function () { + _this.nets = null; + return _Promise.all(_Object$values(gunNets).map(function (net) { + return _Promise.all(net.map(async function (gun) { + await dropPeer(gun); // Drops all peers + await gun._.opt.web.close(); // And closes the web instance + })); + })); + }; + + this.nets = gunNets; // Purely for convenience + } + + var util$1 = { + loadGunDepth: loadGunDepth, + + GunNets: GunNets, + + getHash: function getHash(str) { + var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'base64'; + + if (!str) { + return undefined; + } + var hash = browser$1('sha256'); + hash.update(str); + return hash.digest(format); + }, + + timeoutPromise: function timeoutPromise(promise, timeout) { + return _Promise.race([promise, new _Promise(function (resolve) { + setTimeout(function () { + resolve(); + }, timeout); + })]); + }, + injectCss: function injectCss() { + var elementId = 'irisStyle'; + if (document.getElementById(elementId)) { + return; + } + var sheet = document.createElement('style'); + sheet.id = elementId; + sheet.innerHTML = '\n .iris-identicon * {\n box-sizing: border-box;\n }\n\n .iris-identicon {\n vertical-align: middle;\n border-radius: 50%;\n text-align: center;\n display: inline-block;\n position: relative;\n max-width: 100%;\n }\n\n .iris-distance {\n z-index: 2;\n position: absolute;\n left:0%;\n top:2px;\n width: 100%;\n text-align: right;\n color: #fff;\n text-shadow: 0 0 1px #000;\n font-size: 75%;\n line-height: 75%;\n font-weight: bold;\n }\n\n .iris-pie {\n border-radius: 50%;\n position: absolute;\n top: 0;\n left: 0;\n box-shadow: 0px 0px 0px 0px #82FF84;\n padding-bottom: 100%;\n max-width: 100%;\n -webkit-transition: all 0.2s ease-in-out;\n -moz-transition: all 0.2s ease-in-out;\n transition: all 0.2s ease-in-out;\n }\n\n .iris-card {\n padding: 10px;\n background-color: #f7f7f7;\n color: #777;\n border: 1px solid #ddd;\n display: flex;\n flex-direction: row;\n overflow: hidden;\n }\n\n .iris-card a {\n -webkit-transition: color 150ms;\n transition: color 150ms;\n text-decoration: none;\n color: #337ab7;\n }\n\n .iris-card a:hover, .iris-card a:active {\n text-decoration: underline;\n color: #23527c;\n }\n\n .iris-pos {\n color: #3c763d;\n }\n\n .iris-neg {\n color: #a94442;\n }\n\n .iris-identicon img {\n position: absolute;\n top: 0;\n left: 0;\n max-width: 100%;\n border-radius: 50%;\n border-color: transparent;\n border-style: solid;\n }'; + document.body.appendChild(sheet); + }, + + + isNode: isNode$2 + }; + + // 19.1.2.1 Object.assign(target, source, ...) + + + + + + + var $assign = Object.assign; + + // should work with symbols and should have deterministic property order (V8 bug) + var _objectAssign = !$assign || _fails(function () { + var A = {}; + var B = {}; + // eslint-disable-next-line no-undef + var S = Symbol(); + var K = 'abcdefghijklmnopqrst'; + A[S] = 7; + K.split('').forEach(function (k) { B[k] = k; }); + return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K; + }) ? function assign(target, source) { // eslint-disable-line no-unused-vars + var T = _toObject(target); + var aLen = arguments.length; + var index = 1; + var getSymbols = _objectGops.f; + var isEnum = _objectPie.f; + while (aLen > index) { + var S = _iobject(arguments[index++]); + var keys = getSymbols ? _objectKeys(S).concat(getSymbols(S)) : _objectKeys(S); + var length = keys.length; + var j = 0; + var key; + while (length > j) { + key = keys[j++]; + if (!_descriptors || isEnum.call(S, key)) T[key] = S[key]; + } + } return T; + } : $assign; + + // 19.1.3.1 Object.assign(target, source) + + + _export(_export.S + _export.F, 'Object', { assign: _objectAssign }); + + var assign = _core.Object.assign; + + var assign$1 = createCommonjsModule(function (module) { + module.exports = { "default": assign, __esModule: true }; + }); + + var _Object$assign = unwrapExports(assign$1); + + var pnglib = createCommonjsModule(function (module) { + /** + * A handy class to calculate color values. + * + * @version 1.0 + * @author Robert Eisele + * @copyright Copyright (c) 2010, Robert Eisele + * @link http://www.xarg.org/2010/03/generate-client-side-png-files-using-javascript/ + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * + */ + + (function() { + + // helper functions for that ctx + function write(buffer, offs) { + for (var i = 2; i < arguments.length; i++) { + for (var j = 0; j < arguments[i].length; j++) { + buffer[offs++] = arguments[i].charAt(j); + } + } + } + + function byte2(w) { + return String.fromCharCode((w >> 8) & 255, w & 255); + } + + function byte4(w) { + return String.fromCharCode((w >> 24) & 255, (w >> 16) & 255, (w >> 8) & 255, w & 255); + } + + function byte2lsb(w) { + return String.fromCharCode(w & 255, (w >> 8) & 255); + } + + // modified from original source to support NPM + var PNGlib = function(width,height,depth) { + + this.width = width; + this.height = height; + this.depth = depth; + + // pixel data and row filter identifier size + this.pix_size = height * (width + 1); + + // deflate header, pix_size, block headers, adler32 checksum + this.data_size = 2 + this.pix_size + 5 * Math.floor((0xfffe + this.pix_size) / 0xffff) + 4; + + // offsets and sizes of Png chunks + this.ihdr_offs = 0; // IHDR offset and size + this.ihdr_size = 4 + 4 + 13 + 4; + this.plte_offs = this.ihdr_offs + this.ihdr_size; // PLTE offset and size + this.plte_size = 4 + 4 + 3 * depth + 4; + this.trns_offs = this.plte_offs + this.plte_size; // tRNS offset and size + this.trns_size = 4 + 4 + depth + 4; + this.idat_offs = this.trns_offs + this.trns_size; // IDAT offset and size + this.idat_size = 4 + 4 + this.data_size + 4; + this.iend_offs = this.idat_offs + this.idat_size; // IEND offset and size + this.iend_size = 4 + 4 + 4; + this.buffer_size = this.iend_offs + this.iend_size; // total PNG size + + this.buffer = new Array(); + this.palette = new Object(); + this.pindex = 0; + + var _crc32 = new Array(); + + // initialize buffer with zero bytes + for (var i = 0; i < this.buffer_size; i++) { + this.buffer[i] = "\x00"; + } + + // initialize non-zero elements + write(this.buffer, this.ihdr_offs, byte4(this.ihdr_size - 12), 'IHDR', byte4(width), byte4(height), "\x08\x03"); + write(this.buffer, this.plte_offs, byte4(this.plte_size - 12), 'PLTE'); + write(this.buffer, this.trns_offs, byte4(this.trns_size - 12), 'tRNS'); + write(this.buffer, this.idat_offs, byte4(this.idat_size - 12), 'IDAT'); + write(this.buffer, this.iend_offs, byte4(this.iend_size - 12), 'IEND'); + + // initialize deflate header + var header = ((8 + (7 << 4)) << 8) | (3 << 6); + header+= 31 - (header % 31); + + write(this.buffer, this.idat_offs + 8, byte2(header)); + + // initialize deflate block headers + for (var i = 0; (i << 16) - 1 < this.pix_size; i++) { + var size, bits; + if (i + 0xffff < this.pix_size) { + size = 0xffff; + bits = "\x00"; + } else { + size = this.pix_size - (i << 16) - i; + bits = "\x01"; + } + write(this.buffer, this.idat_offs + 8 + 2 + (i << 16) + (i << 2), bits, byte2lsb(size), byte2lsb(~size)); + } + + /* Create crc32 lookup table */ + for (var i = 0; i < 256; i++) { + var c = i; + for (var j = 0; j < 8; j++) { + if (c & 1) { + c = -306674912 ^ ((c >> 1) & 0x7fffffff); + } else { + c = (c >> 1) & 0x7fffffff; + } + } + _crc32[i] = c; + } + + // compute the index into a png for a given pixel + this.index = function(x,y) { + var i = y * (this.width + 1) + x + 1; + var j = this.idat_offs + 8 + 2 + 5 * Math.floor((i / 0xffff) + 1) + i; + return j; + }; + + // convert a color and build up the palette + this.color = function(red, green, blue, alpha) { + + alpha = alpha >= 0 ? alpha : 255; + var color = (((((alpha << 8) | red) << 8) | green) << 8) | blue; + + if (typeof this.palette[color] == "undefined") { + if (this.pindex == this.depth) return "\x00"; + + var ndx = this.plte_offs + 8 + 3 * this.pindex; + + this.buffer[ndx + 0] = String.fromCharCode(red); + this.buffer[ndx + 1] = String.fromCharCode(green); + this.buffer[ndx + 2] = String.fromCharCode(blue); + this.buffer[this.trns_offs+8+this.pindex] = String.fromCharCode(alpha); + + this.palette[color] = String.fromCharCode(this.pindex++); + } + return this.palette[color]; + }; + + // output a PNG string, Base64 encoded + this.getBase64 = function() { + + var s = this.getDump(); + + var ch = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; + var c1, c2, c3, e1, e2, e3, e4; + var l = s.length; + var i = 0; + var r = ""; + + do { + c1 = s.charCodeAt(i); + e1 = c1 >> 2; + c2 = s.charCodeAt(i+1); + e2 = ((c1 & 3) << 4) | (c2 >> 4); + c3 = s.charCodeAt(i+2); + if (l < i+2) { e3 = 64; } else { e3 = ((c2 & 0xf) << 2) | (c3 >> 6); } + if (l < i+3) { e4 = 64; } else { e4 = c3 & 0x3f; } + r+= ch.charAt(e1) + ch.charAt(e2) + ch.charAt(e3) + ch.charAt(e4); + } while ((i+= 3) < l); + return r; + }; + + // output a PNG string + this.getDump = function() { + + // compute adler32 of output pixels + row filter bytes + var BASE = 65521; /* largest prime smaller than 65536 */ + var NMAX = 5552; /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ + var s1 = 1; + var s2 = 0; + var n = NMAX; + + for (var y = 0; y < this.height; y++) { + for (var x = -1; x < this.width; x++) { + s1+= this.buffer[this.index(x, y)].charCodeAt(0); + s2+= s1; + if ((n-= 1) == 0) { + s1%= BASE; + s2%= BASE; + n = NMAX; + } + } + } + s1%= BASE; + s2%= BASE; + write(this.buffer, this.idat_offs + this.idat_size - 8, byte4((s2 << 16) | s1)); + + // compute crc32 of the PNG chunks + function crc32(png, offs, size) { + var crc = -1; + for (var i = 4; i < size-4; i += 1) { + crc = _crc32[(crc ^ png[offs+i].charCodeAt(0)) & 0xff] ^ ((crc >> 8) & 0x00ffffff); + } + write(png, offs+size-4, byte4(crc ^ -1)); + } + + crc32(this.buffer, this.ihdr_offs, this.ihdr_size); + crc32(this.buffer, this.plte_offs, this.plte_size); + crc32(this.buffer, this.trns_offs, this.trns_size); + crc32(this.buffer, this.idat_offs, this.idat_size); + crc32(this.buffer, this.iend_offs, this.iend_size); + + // convert PNG to string + return "\x89PNG\r\n\x1a\n"+this.buffer.join(''); + }; + }; + + // modified from original source to support NPM + { + module.exports = PNGlib; + } + })(); + }); + + var identicon = createCommonjsModule(function (module) { + /** + * Identicon.js 2.3.3 + * http://github.com/stewartlord/identicon.js + * + * PNGLib required for PNG output + * http://www.xarg.org/download/pnglib.js + * + * Copyright 2018, Stewart Lord + * Released under the BSD license + * http://www.opensource.org/licenses/bsd-license.php + */ + + (function() { + var PNGlib; + { + PNGlib = pnglib; + } + + var Identicon = function(hash, options){ + if (typeof(hash) !== 'string' || hash.length < 15) { + throw 'A hash of at least 15 characters is required.'; + } + + this.defaults = { + background: [240, 240, 240, 255], + margin: 0.08, + size: 64, + saturation: 0.7, + brightness: 0.5, + format: 'png' + }; + + this.options = typeof(options) === 'object' ? options : this.defaults; + + // backward compatibility with old constructor (hash, size, margin) + if (typeof(arguments[1]) === 'number') { this.options.size = arguments[1]; } + if (arguments[2]) { this.options.margin = arguments[2]; } + + this.hash = hash; + this.background = this.options.background || this.defaults.background; + this.size = this.options.size || this.defaults.size; + this.format = this.options.format || this.defaults.format; + this.margin = this.options.margin !== undefined ? this.options.margin : this.defaults.margin; + + // foreground defaults to last 7 chars as hue at 70% saturation, 50% brightness + var hue = parseInt(this.hash.substr(-7), 16) / 0xfffffff; + var saturation = this.options.saturation || this.defaults.saturation; + var brightness = this.options.brightness || this.defaults.brightness; + this.foreground = this.options.foreground || this.hsl2rgb(hue, saturation, brightness); + }; + + Identicon.prototype = { + background: null, + foreground: null, + hash: null, + margin: null, + size: null, + format: null, + + image: function(){ + return this.isSvg() + ? new Svg(this.size, this.foreground, this.background) + : new PNGlib(this.size, this.size, 256); + }, + + render: function(){ + var image = this.image(), + size = this.size, + baseMargin = Math.floor(size * this.margin), + cell = Math.floor((size - (baseMargin * 2)) / 5), + margin = Math.floor((size - cell * 5) / 2), + bg = image.color.apply(image, this.background), + fg = image.color.apply(image, this.foreground); + + // the first 15 characters of the hash control the pixels (even/odd) + // they are drawn down the middle first, then mirrored outwards + var i, color; + for (i = 0; i < 15; i++) { + color = parseInt(this.hash.charAt(i), 16) % 2 ? bg : fg; + if (i < 5) { + this.rectangle(2 * cell + margin, i * cell + margin, cell, cell, color, image); + } else if (i < 10) { + this.rectangle(1 * cell + margin, (i - 5) * cell + margin, cell, cell, color, image); + this.rectangle(3 * cell + margin, (i - 5) * cell + margin, cell, cell, color, image); + } else if (i < 15) { + this.rectangle(0 * cell + margin, (i - 10) * cell + margin, cell, cell, color, image); + this.rectangle(4 * cell + margin, (i - 10) * cell + margin, cell, cell, color, image); + } + } + + return image; + }, + + rectangle: function(x, y, w, h, color, image){ + if (this.isSvg()) { + image.rectangles.push({x: x, y: y, w: w, h: h, color: color}); + } else { + var i, j; + for (i = x; i < x + w; i++) { + for (j = y; j < y + h; j++) { + image.buffer[image.index(i, j)] = color; + } + } + } + }, + + // adapted from: https://gist.github.com/aemkei/1325937 + hsl2rgb: function(h, s, b){ + h *= 6; + s = [ + b += s *= b < .5 ? b : 1 - b, + b - h % 1 * s * 2, + b -= s *= 2, + b, + b + h % 1 * s, + b + s + ]; + + return [ + s[ ~~h % 6 ] * 255, // red + s[ (h|16) % 6 ] * 255, // green + s[ (h|8) % 6 ] * 255 // blue + ]; + }, + + toString: function(raw){ + // backward compatibility with old toString, default to base64 + if (raw) { + return this.render().getDump(); + } else { + return this.render().getBase64(); + } + }, + + isSvg: function(){ + return this.format.match(/svg/i) + } + }; + + var Svg = function(size, foreground, background){ + this.size = size; + this.foreground = this.color.apply(this, foreground); + this.background = this.color.apply(this, background); + this.rectangles = []; + }; + + Svg.prototype = { + size: null, + foreground: null, + background: null, + rectangles: null, + + color: function(r, g, b, a){ + var values = [r, g, b].map(Math.round); + values.push((a >= 0) && (a <= 255) ? a/255 : 1); + return 'rgba(' + values.join(',') + ')'; + }, + + getDump: function(){ + var i, + xml, + rect, + fg = this.foreground, + bg = this.background, + stroke = this.size * 0.005; + + xml = "" + + ""; + + for (i = 0; i < this.rectangles.length; i++) { + rect = this.rectangles[i]; + if (rect.color == bg) continue; + xml += ""; + } + xml += ""; + + return xml; + }, + + getBase64: function(){ + if ('function' === typeof btoa) { + return btoa(this.getDump()); + } else if (Buffer) { + return new Buffer(this.getDump(), 'binary').toString('base64'); + } else { + throw 'Cannot generate base64 output'; + } + } + }; + + { + module.exports = Identicon; + } + })(); + }); + + var UNIQUE_ID_VALIDATORS = { + email: /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i, + bitcoin: /^[13][a-km-zA-HJ-NP-Z0-9]{26,33}$/, + bitcoin_address: /^[13][a-km-zA-HJ-NP-Z0-9]{26,33}$/, + ip: /^(([1-9]?\d|1\d\d|2[0-5][0-5]|2[0-4]\d)\.){3}([1-9]?\d|1\d\d|2[0-5][0-5]|2[0-4]\d)$/, + ipv6: /^(?:[A-F0-9]{1,4}:){7}[A-F0-9]{1,4}$/, + gpg_fingerprint: null, + gpg_keyid: null, + google_oauth2: null, + tel: /^\d{7,}$/, + phone: /^\d{7,}$/, + keyID: null, + url: /[-a-zA-Z0-9@:%_\+.~#?&//=]{2,256}\.[a-z]{2,4}\b(\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?/gi, + account: /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i, + uuid: /[0-9a-f]{8}\-[0-9a-f]{4}\-[0-9a-f]{4}\-[0-9a-f]{4}\-[0-9a-f]{12}/ + }; + + /** + * A simple key-value pair with helper functions. + * + * Constructor: new Attribute(value), new Attribute(type, value) or new Attribute({type, value}) + */ + + var Attribute = function () { + /** + * @param {string} a + * @param {string} b + */ + function Attribute(a, b) { + _classCallCheck(this, Attribute); + + if (typeof a === 'object' && typeof a.type === 'string' && typeof a.value === 'string') { + b = a.value; + a = a.type; + } + if (typeof a !== 'string') { + throw new Error('First param must be a string, got ' + (typeof a === 'undefined' ? 'undefined' : _typeof(a)) + ': ' + _JSON$stringify(a)); + } + if (!a.length) { + throw new Error('First param string is empty'); + } + if (b) { + if (typeof b !== 'string') { + throw new Error('Second parameter must be a string, got ' + (typeof b === 'undefined' ? 'undefined' : _typeof(b)) + ': ' + _JSON$stringify(b)); + } + if (!b.length) { + throw new Error('Second param string is empty'); + } + this.type = a; + this.value = b; + } else { + this.value = a; + var t = Attribute.guessTypeOf(this.value); + if (t) { + this.type = t; + } else { + throw new Error('Type of attribute was omitted and could not be guessed'); + } + } + } + + /** + * @returns {Attribute} uuid + */ + + + Attribute.getUuid = function getUuid() { + var b = function b(a) { + return a ? (a ^ Math.random() * 16 >> a / 4).toString(16) : ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, b); + }; + return new Attribute('uuid', b()); + }; + + /** + * @returns {Object} an object with attribute types as keys and regex patterns as values + */ + + + Attribute.getUniqueIdValidators = function getUniqueIdValidators() { + return UNIQUE_ID_VALIDATORS; + }; + + /** + * @param {string} type attribute type + * @returns {boolean} true if the attribute type is unique + */ + + + Attribute.isUniqueType = function isUniqueType(type) { + return _Object$keys(UNIQUE_ID_VALIDATORS).indexOf(type) > -1; + }; + + /** + * @returns {boolean} true if the attribute type is unique + */ + + + Attribute.prototype.isUniqueType = function isUniqueType() { + return Attribute.isUniqueType(this.type); + }; + + /** + * @param {string} value guess type of this attribute value + * @returns {string} type of attribute value or undefined + */ + + + Attribute.guessTypeOf = function guessTypeOf(value) { + for (var key in UNIQUE_ID_VALIDATORS) { + if (value.match(UNIQUE_ID_VALIDATORS[key])) { + return key; + } + } + }; + + /** + * @param {Attribute} a + * @param {Attribute} b + * @returns {boolean} true if params are equal + */ + + + Attribute.equals = function equals(a, b) { + return a.equals(b); + }; + + /** + * @param {Attribute} a attribute to compare to + * @returns {boolean} true if attribute matches param + */ + + + Attribute.prototype.equals = function equals(a) { + return a && this.type === a.type && this.value === a.value; + }; + + /** + * @returns {string} uri - `${encodeURIComponent(this.value)}:${encodeURIComponent(this.type)}` + * @example + * user%20example.com:email + */ + + + Attribute.prototype.uri = function uri() { + return encodeURIComponent(this.value) + ':' + encodeURIComponent(this.type); + }; + + /** + * Generate a visually recognizable representation of the attribute + * @param {object} options {width} + * @returns {HTMLElement} identicon div element + */ + + + Attribute.prototype.identicon = function identicon$$1() { + var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + options = _Object$assign({ + width: 50, + showType: true + }, options); + util$1.injectCss(); // some other way that is not called on each identicon generation? + + var div = document.createElement('div'); + div.className = 'iris-identicon'; + div.style.width = options.width + 'px'; + div.style.height = options.width + 'px'; + + var img = document.createElement('img'); + img.alt = ''; + img.width = options.width; + img.height = options.width; + var hash = util$1.getHash(encodeURIComponent(this.type) + ':' + encodeURIComponent(this.value), 'hex'); + var identicon$$1 = new identicon(hash, { width: options.width, format: 'svg' }); + img.src = 'data:image/svg+xml;base64,' + identicon$$1.toString(); + + if (options.showType) { + var name = document.createElement('span'); + name.className = 'iris-distance'; + name.style.fontSize = options.width > 50 ? options.width / 4 + 'px' : '10px'; + name.textContent = this.type.slice(0, 5); + div.appendChild(name); + } + + div.appendChild(img); + + return div; + }; + + return Attribute; + }(); + + var myKey = void 0; + + /** + * Key management utils. Wraps GUN's SEA. https://gun.eco/docs/SEA + */ + + var Key = function () { + function Key() { + _classCallCheck(this, Key); + } + + /** + * Load default key from datadir/private.key on node.js or from local storage 'iris.myKey' in browser. + * + * If default key does not exist, it is generated. + * @param {string} datadir directory to find key from. In browser, localStorage is used instead. + * @returns {Promise} keypair object + */ + Key.getDefault = async function getDefault() { + var datadir = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '.'; + var keyfile = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'identifi.key'; + + if (myKey) { + return myKey; + } + if (util$1.isNode) { + var fs = require('fs'); + var privKeyFile = datadir + '/' + keyfile; + if (fs.existsSync(privKeyFile)) { + var f = fs.readFileSync(privKeyFile, 'utf8'); + myKey = Key.fromString(f); + } else { + var newKey = await Key.generate(); + myKey = myKey || newKey; // eslint-disable-line require-atomic-updates + fs.writeFileSync(privKeyFile, Key.toString(myKey)); + fs.chmodSync(privKeyFile, 400); + } + if (!myKey) { + throw new Error('loading default key failed - check ' + datadir + '/' + keyfile); + } + } else { + var str = window.localStorage.getItem('iris.myKey'); + if (str) { + myKey = Key.fromString(str); + } else { + var _newKey = await Key.generate(); + myKey = myKey || _newKey; // eslint-disable-line require-atomic-updates + window.localStorage.setItem('iris.myKey', Key.toString(myKey)); + } + if (!myKey) { + throw new Error('loading default key failed - check localStorage iris.myKey'); + } + } + return myKey; + }; + + /** + * Serialize key as JSON string + * @param {Object} key key to serialize + * @returns {String} JSON Web Key string + */ + + + Key.toString = function toString(key) { + return _JSON$stringify(key); + }; + + /** + * Get keyID + * @param {Object} key key to get an id for. Currently just returns the public key string. + * @returns {String} public key string + */ + + + Key.getId = function getId(key) { + if (!(key && key.pub)) { + throw new Error('missing param'); + } + return key.pub; // hack until GUN supports lookups by keyID + //return util.getHash(key.pub); + }; + + /** + * Get a keypair from a JSON string. + * @param {String} str key JSON + * @returns {Object} Gun.SEA keypair object + */ + + + Key.fromString = function fromString(str) { + return JSON.parse(str); + }; + + /** + * Generate a new keypair + * @returns {Promise} Gun.SEA keypair object + */ + + + Key.generate = function generate() { + return Gun.SEA.pair(); + }; + + /** + * Sign a message + * @param {String} msg message to sign + * @param {Object} pair signing keypair + * @returns {Promise} signed message string + */ + + + Key.sign = async function sign(msg, pair) { + var sig = await Gun.SEA.sign(msg, pair); + return 'a' + sig; + }; + + /** + * Verify a signed message + * @param {String} msg message to verify + * @param {Object} pubKey public key of the signer + * @returns {Promise} signature string + */ + + + Key.verify = function verify(msg, pubKey) { + return Gun.SEA.verify(msg.slice(1), pubKey); + }; + + return Key; + }(); + + var errorMsg = 'Invalid message:'; + + var ValidationError = function (_Error) { + _inherits(ValidationError, _Error); + + function ValidationError() { + _classCallCheck(this, ValidationError); + + return _possibleConstructorReturn(this, _Error.apply(this, arguments)); + } + + return ValidationError; + }(Error); + + /** + * Signed message object. + * + * Fields: signedData, signer (public key) and signature. + * + * signedData has an author, signer, type, time and optionally other fields. + * + * signature covers the utf8 string representation of signedData. Since messages are digitally signed, users only need to care about the message signer and not who relayed it or whose index it was found from. + * + * signer is the entity that verified its origin. In other words: message author and signer can be different entities, and only the signer needs to use Iris. + * + * For example, a crawler can import and sign other people's messages from Twitter. Only the users who trust the crawler will see the messages. + * + * "Rating" type messages, when added to an SocialNetwork, can add or remove Identities from the web of trust. Verification/unverification messages can add or remove Attributes from an Contact. Other types of messages such as social media "post" are just indexed by their author, recipient and time. + * + * Constructor: creates a message from the param obj.signedData that must contain at least the mandatory fields: author, recipient, type and time. You can use createRating() and createVerification() to automatically populate some of these fields and optionally sign the message. + * @param obj + * + * @example + * https://github.com/irislib/iris-lib/blob/master/__tests__/message.js + * + * Rating message: + * { + * signedData: { + * author: {name:'Alice', key:'ABCD1234'}, + * recipient: {name:'Bob', email:'bob@example.com'}, + * type: 'rating', + * rating: 1, + * maxRating: 10, + * minRating: -10, + * text: 'Traded 1 BTC' + * }, + * signer: 'ABCD1234', + * signature: '1234ABCD' + * } + * + * Verification message: + * { + * signedData: { + * author: {name:'Alice', key:'ABCD1234'}, + * recipient: { + * name: 'Bob', + * email: ['bob@example.com', 'bob.saget@example.com'], + * bitcoin: '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa' + * }, + * type: 'verification' + * }, + * signer: 'ABCD1234', + * signature: '1234ABCD' + * } + */ + + + var Message = function () { + function Message(obj) { + _classCallCheck(this, Message); + + if (obj.signedData) { + this.signedData = obj.signedData; + } + if (obj.pubKey) { + this.pubKey = obj.pubKey; + } + if (obj.ipfsUri) { + this.ipfsUri = obj.ipfsUri; + } + if (obj.sig) { + if (typeof obj.sig !== 'string') { + throw new ValidationError('Message signature must be a string'); + } + this.sig = obj.sig; + this.getHash(); + } + this._validate(); + } + + Message._getArray = function _getArray(authorOrRecipient) { + var arr = []; + var keys = _Object$keys(authorOrRecipient); + for (var i = 0; i < keys.length; i++) { + var type = keys[i]; + var value = authorOrRecipient[keys[i]]; + if (typeof value === 'string') { + arr.push(new Attribute(type, value)); + } else { + // array + for (var j = 0; j < value.length; j++) { + var elementValue = value[j]; + arr.push(new Attribute(type, elementValue)); + } + } + } + return arr; + }; + + Message._getIterable = function _getIterable(authorOrRecipient) { + var _ref; + + return _ref = {}, _ref[_Symbol$iterator] = /*#__PURE__*/regenerator.mark(function _callee() { + var keys, i, type, value, j, elementValue; + return regenerator.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + keys = _Object$keys(authorOrRecipient); + i = 0; + + case 2: + if (!(i < keys.length)) { + _context.next = 21; + break; + } + + type = keys[i]; + value = authorOrRecipient[keys[i]]; + + if (!(typeof value === 'string')) { + _context.next = 10; + break; + } + + _context.next = 8; + return new Attribute(type, value); + + case 8: + _context.next = 18; + break; + + case 10: + j = 0; + + case 11: + if (!(j < value.length)) { + _context.next = 18; + break; + } + + elementValue = value[j]; + _context.next = 15; + return new Attribute(type, elementValue); + + case 15: + j++; + _context.next = 11; + break; + + case 18: + i++; + _context.next = 2; + break; + + case 21: + case 'end': + return _context.stop(); + } + } + }, _callee, this); + }), _ref; + }; + + /** + * @returns {object} Javascript iterator over author attributes + */ + + + Message.prototype.getAuthorIterable = function getAuthorIterable() { + return Message._getIterable(this.signedData.author); + }; + + /** + * @returns {object} Javascript iterator over recipient attributes + */ + + + Message.prototype.getRecipientIterable = function getRecipientIterable() { + return Message._getIterable(this.signedData.recipient); + }; + + /** + * @returns {array} Array containing author attributes + */ + + + Message.prototype.getAuthorArray = function getAuthorArray() { + return Message._getArray(this.signedData.author); + }; + + /** + * @returns {array} Array containing recipient attributes + */ + + + Message.prototype.getRecipientArray = function getRecipientArray() { + return this.signedData.recipient ? Message._getArray(this.signedData.recipient) : []; + }; + + /** + * @returns {string} Message signer keyID, i.e. base64 hash of public key + */ + + + Message.prototype.getSignerKeyID = function getSignerKeyID() { + return this.pubKey; // hack until gun supports keyID lookups + //return util.getHash(this.pubKey); + }; + + Message.prototype._validate = function _validate() { + if (!this.signedData) { + throw new ValidationError(errorMsg + ' Missing signedData'); + } + if (typeof this.signedData !== 'object') { + throw new ValidationError(errorMsg + ' signedData must be an object'); + } + var d = this.signedData; + + if (!d.type) { + throw new ValidationError(errorMsg + ' Missing type definition'); + } + if (!d.author) { + throw new ValidationError(errorMsg + ' Missing author'); + } + if (typeof d.author !== 'object') { + throw new ValidationError(errorMsg + ' Author must be object'); + } + if (Array.isArray(d.author)) { + throw new ValidationError(errorMsg + ' Author must not be an array'); + } + if (_Object$keys(d.author).length === 0) { + throw new ValidationError(errorMsg + ' Author empty'); + } + if (this.pubKey) { + this.signerKeyHash = this.getSignerKeyID(); + } + for (var attr in d.author) { + var t = _typeof(d.author[attr]); + if (t !== 'string') { + if (Array.isArray(d.author[attr])) { + for (var i = 0; i < d.author[attr].length; i++) { + if (typeof d.author[attr][i] !== 'string') { + throw new ValidationError(errorMsg + ' Author attribute must be string, got ' + attr + ': [' + d.author[attr][i] + ']'); + } + if (d.author[attr][i].length === 0) { + throw new ValidationError(errorMsg + ' author ' + attr + ' in array[' + i + '] is empty'); + } + } + } else { + throw new ValidationError(errorMsg + ' Author attribute must be string or array, got ' + attr + ': ' + d.author[attr]); + } + } + if (attr === 'keyID') { + if (t !== 'string') { + throw new ValidationError(errorMsg + ' Author keyID must be string, got ' + t); + } + if (this.signerKeyHash && d.author[attr] !== this.signerKeyHash) { + throw new ValidationError(errorMsg + ' If message has a keyID author, it must be signed by the same key'); + } + } + } + if (d.recipient) { + if (typeof d.recipient !== 'object') { + throw new ValidationError(errorMsg + ' Recipient must be object'); + } + if (Array.isArray(d.recipient)) { + throw new ValidationError(errorMsg + ' Recipient must not be an array'); + } + if (_Object$keys(d.recipient).length === 0) { + throw new ValidationError(errorMsg + ' Recipient empty'); + } + for (var _attr in d.recipient) { + var _t = _typeof(d.recipient[_attr]); + if (_t !== 'string') { + if (Array.isArray(d.recipient[_attr])) { + for (var _i = 0; _i < d.recipient[_attr].length; _i++) { + if (typeof d.recipient[_attr][_i] !== 'string') { + throw new ValidationError(errorMsg + ' Recipient attribute must be string, got ' + _attr + ': [' + d.recipient[_attr][_i] + ']'); + } + if (d.recipient[_attr][_i].length === 0) { + throw new ValidationError(errorMsg + ' recipient ' + _attr + ' in array[' + _i + '] is empty'); + } + } + } else { + throw new ValidationError(errorMsg + ' Recipient attribute must be string or array, got ' + _attr + ': ' + d.recipient[_attr]); + } + } + } + } + if (!(d.time || d.timestamp)) { + throw new ValidationError(errorMsg + ' Missing time field'); + } + + if (!Date.parse(d.time || d.timestamp)) { + throw new ValidationError(errorMsg + ' Invalid time field'); + } + + if (d.type === 'rating') { + if (isNaN(d.rating)) { + throw new ValidationError(errorMsg + ' Invalid rating'); + } + if (isNaN(d.maxRating)) { + throw new ValidationError(errorMsg + ' Invalid maxRating'); + } + if (isNaN(d.minRating)) { + throw new ValidationError(errorMsg + ' Invalid minRating'); + } + if (d.rating > d.maxRating) { + throw new ValidationError(errorMsg + ' Rating is above maxRating'); + } + if (d.rating < d.minRating) { + throw new ValidationError(errorMsg + ' Rating is below minRating'); + } + if (typeof d.context !== 'string' || !d.context.length) { + throw new ValidationError(errorMsg + ' Rating messages must have a context field'); + } + } + + if (d.type === 'verification' || d.type === 'unverification') { + if (d.recipient.length < 2) { + throw new ValidationError(errorMsg + ' At least 2 recipient attributes are needed for a connection / disconnection. Got: ' + d.recipient); + } + } + + return true; + }; + + /** + * @returns {boolean} true if message has a positive rating + */ + + + Message.prototype.isPositive = function isPositive() { + return this.signedData.type === 'rating' && this.signedData.rating > (this.signedData.maxRating + this.signedData.minRating) / 2; + }; + + /** + * @returns {boolean} true if message has a negative rating + */ + + + Message.prototype.isNegative = function isNegative() { + return this.signedData.type === 'rating' && this.signedData.rating < (this.signedData.maxRating + this.signedData.minRating) / 2; + }; + + /** + * @returns {boolean} true if message has a neutral rating + */ + + + Message.prototype.isNeutral = function isNeutral() { + return this.signedData.type === 'rating' && this.signedData.rating === (this.signedData.maxRating + this.signedData.minRating) / 2; + }; + + /** + * @param {Object} key Gun.SEA keypair to sign the message with + */ + + + Message.prototype.sign = async function sign(key) { + this.sig = await Key.sign(this.signedData, key); + this.pubKey = key.pub; + this.getHash(); + return true; + }; + + /** + * Create an iris message. Message time is automatically set. If signingKey is specified and author omitted, signingKey will be used as author. + * @param {Object} signedData message data object including author, recipient and other possible attributes + * @param {Object} signingKey optionally, you can set the key to sign the message with + * @returns {Promise} message + */ + + + Message.create = async function create(signedData, signingKey) { + if (!signedData.author && signingKey) { + signedData.author = { keyID: Key.getId(signingKey) }; + } + signedData.time = signedData.time || new Date().toISOString(); + var m = new Message({ signedData: signedData }); + if (signingKey) { + await m.sign(signingKey); + } + return m; + }; + + /** + * Create an verification message. Message signedData's type and time are automatically set. Recipient must be set. If signingKey is specified and author omitted, signingKey will be used as author. + * @returns {Promise} message object promise + */ + + + Message.createVerification = function createVerification(signedData, signingKey) { + signedData.type = 'verification'; + return Message.create(signedData, signingKey); + }; + + /** + * Create an rating message. Message signedData's type, maxRating, minRating, time and context are set automatically. Recipient and rating must be set. If signingKey is specified and author omitted, signingKey will be used as author. + * @returns {Promise} message object promise + */ + + + Message.createRating = function createRating(signedData, signingKey) { + signedData.type = 'rating'; + signedData.context = signedData.context || 'iris'; + signedData.maxRating = signedData.maxRating || 10; + signedData.minRating = signedData.minRating || -10; + return Message.create(signedData, signingKey); + }; + + /** + * @param {Index} index index to look up the message author from + * @returns {Contact} message author identity + */ + + + Message.prototype.getAuthor = function getAuthor(index) { + for (var _iterator = this.getAuthorIterable(), _isArray = Array.isArray(_iterator), _i2 = 0, _iterator = _isArray ? _iterator : _getIterator(_iterator);;) { + var _ref2; + + if (_isArray) { + if (_i2 >= _iterator.length) break; + _ref2 = _iterator[_i2++]; + } else { + _i2 = _iterator.next(); + if (_i2.done) break; + _ref2 = _i2.value; + } + + var a = _ref2; + + if (a.isUniqueType()) { + return index.getContacts(a); + } + } + }; + + /** + * @param {Index} index index to look up the message recipient from + * @returns {Contact} message recipient identity or undefined + */ + + + Message.prototype.getRecipient = function getRecipient(index) { + if (!this.signedData.recipient) { + return undefined; + } + for (var _iterator2 = this.getRecipientIterable(), _isArray2 = Array.isArray(_iterator2), _i3 = 0, _iterator2 = _isArray2 ? _iterator2 : _getIterator(_iterator2);;) { + var _ref3; + + if (_isArray2) { + if (_i3 >= _iterator2.length) break; + _ref3 = _iterator2[_i3++]; + } else { + _i3 = _iterator2.next(); + if (_i3.done) break; + _ref3 = _i3.value; + } + + var a = _ref3; + + if (a.isUniqueType()) { + return index.getContacts(a); + } + } + }; + + /** + * @returns {string} base64 sha256 hash of message + */ + + + Message.prototype.getHash = function getHash() { + if (this.sig && !this.hash) { + this.hash = util$1.getHash(this.sig); + } + return this.hash; + }; + + Message.prototype.getId = function getId() { + return this.getHash(); + }; + + Message.fromSig = async function fromSig(obj) { + if (!obj.sig) { + throw new Error('Missing signature in object:', obj); + } + if (!obj.pubKey) { + throw new Error('Missing pubKey in object:'); + } + var signedData = await Key.verify(obj.sig, obj.pubKey); + var o = { signedData: signedData, sig: obj.sig, pubKey: obj.pubKey }; + return new Message(o); + }; + + /** + * @return {boolean} true if message signature is valid. Otherwise throws ValidationError. + */ + + + Message.prototype.verify = async function verify() { + if (!this.pubKey) { + throw new ValidationError(errorMsg + ' Message has no .pubKey'); + } + if (!this.sig) { + throw new ValidationError(errorMsg + ' Message has no .sig'); + } + this.signedData = await Key.verify(this.sig, this.pubKey); + if (!this.signedData) { + throw new ValidationError(errorMsg + ' Invalid signature'); + } + if (this.hash) { + if (this.hash !== util$1.getHash(this.sig)) { + throw new ValidationError(errorMsg + ' Invalid message hash'); + } + } else { + this.getHash(); + } + return true; + }; + + /** + * + */ + + + Message.prototype.saveToIpfs = async function saveToIpfs(ipfs) { + var s = this.toString(); + var r = await ipfs.add(ipfs.types.Buffer.from(s)); + if (r.length) { + this.ipfsUri = r[0].hash; + } + return this.ipfsUri; + }; + + /** + * + */ + + + Message.loadFromIpfs = async function loadFromIpfs(ipfs, uri) { + var f = await ipfs.cat(uri); + var s = ipfs.types.Buffer.from(f).toString('utf8'); + try { + return Message.fromString(s); + } catch (e) { + console.log('loading message from ipfs failed'); + return _Promise.reject(); + } + }; + + /** + * @returns {string} JSON string of signature and public key + */ + + + Message.prototype.serialize = function serialize() { + return { sig: this.sig, pubKey: this.pubKey }; + }; + + Message.prototype.toString = function toString() { + return _JSON$stringify(this.serialize()); + }; + + /** + * @returns {Promise} message from JSON string produced by toString + */ + + + Message.deserialize = async function deserialize(s) { + return Message.fromSig(s); + }; + + Message.fromString = async function fromString(s) { + return Message.fromSig(JSON.parse(s)); + }; + + /** + * + */ + + + Message.setReaction = function setReaction(gun, msg, reaction) { + gun.get('reactions').get(msg.getHash()).put(reaction); + gun.get('reactions').get(msg.getHash()).put(reaction); + gun.get('messagesByHash').get(msg.getHash()).get('reactions').get(this.rootContact.value).put(reaction); + gun.get('messagesByHash').get(msg.getHash()).get('reactions').get(this.rootContact.value).put(reaction); + }; + + return Message; + }(); + + /** + * An Iris Contact, such as person, organization or group. More abstractly speaking: an Identity. + * + * Usually you don't create Contacts yourself, but get them + * from SocialNetwork methods such as get() and search(). + */ + + var Contact = function () { + /** + * @param {Object} gun node where the Contact data lives + */ + function Contact(gun, linkTo) { + _classCallCheck(this, Contact); + + this.gun = gun; + this.linkTo = linkTo; + } + + Contact.create = function create(gun, data, index) { + if (!data.linkTo && !data.attrs) { + throw new Error('You must specify either data.linkTo or data.attrs'); + } + if (data.linkTo && !data.attrs) { + var linkTo = new Attribute(data.linkTo); + data.attrs = {}; + if (!Object.prototype.hasOwnProperty.call(data.attrs, linkTo.uri())) { + data.attrs[linkTo.uri()] = linkTo; + } + } else { + data.linkTo = Contact.getLinkTo(data.attrs); + } + var uri = data.linkTo.uri(); + var attrs = gun.top(uri + '/attrs').put(data.attrs); + delete data['attrs']; + gun.put(data); + gun.get('attrs').put(attrs); + return new Contact(gun, uri, index); + }; + + Contact.getLinkTo = function getLinkTo(attrs) { + var mva = Contact.getMostVerifiedAttributes(attrs); + var keys = _Object$keys(mva); + var linkTo = void 0; + for (var i = 0; i < keys.length; i++) { + if (keys[i] === 'keyID') { + linkTo = mva[keys[i]].attribute; + break; + } else if (Attribute.isUniqueType(keys[i])) { + linkTo = mva[keys[i]].attribute; + } + } + return linkTo; + }; + + Contact.getMostVerifiedAttributes = function getMostVerifiedAttributes(attrs) { + var mostVerifiedAttributes = {}; + _Object$keys(attrs).forEach(function (k) { + var a = attrs[k]; + var keyExists = _Object$keys(mostVerifiedAttributes).indexOf(a.type) > -1; + a.verifications = isNaN(a.verifications) ? 1 : a.verifications; + a.unverifications = isNaN(a.unverifications) ? 0 : a.unverifications; + if (a.verifications * 2 > a.unverifications * 3 && (!keyExists || a.verifications - a.unverifications > mostVerifiedAttributes[a.type].verificationScore)) { + mostVerifiedAttributes[a.type] = { + attribute: a, + verificationScore: a.verifications - a.unverifications + }; + if (a.verified) { + mostVerifiedAttributes[a.type].verified = true; + } + } + }); + return mostVerifiedAttributes; + }; + + Contact.getAttrs = async function getAttrs(identity) { + var attrs = await util$1.loadGunDepth(identity.get('attrs'), 2); + if (attrs && attrs['_'] !== undefined) { + delete attrs['_']; + } + return attrs || {}; + }; + + Contact.prototype.getId = function getId() { + return this.linkTo.value; + }; + + /** + * Get sent Messages + * @param {Object} index + * @param {Object} options + */ + + + Contact.prototype.sent = function sent(index, options) { + index._getSentMsgs(this, options); + }; + + /** + * Get received Messages + * @param {Object} index + * @param {Object} options + */ + + + Contact.prototype.received = function received(index, options) { + index._getReceivedMsgs(this, options); + }; + + /** + * @param {string} attribute attribute type + * @returns {string} most verified value of the param type + */ + + + Contact.prototype.verified = async function verified(attribute) { + var attrs = await Contact.getAttrs(this.gun).then(); + var mva = Contact.getMostVerifiedAttributes(attrs); + return Object.prototype.hasOwnProperty.call(mva, attribute) ? mva[attribute].attribute.value : undefined; + }; + + /** + * @param {Object} ipfs (optional) an IPFS instance that is used to fetch images + * @returns {HTMLElement} profile card html element describing the identity + */ + + + Contact.prototype.profileCard = function profileCard(ipfs) { + var _this = this; + + var card = document.createElement('div'); + card.className = 'iris-card'; + + var identicon$$1 = this.identicon({ width: 60, ipfs: ipfs }); + identicon$$1.style.order = 1; + identicon$$1.style.flexShrink = 0; + identicon$$1.style.marginRight = '15px'; + + var details = document.createElement('div'); + details.style.padding = '5px'; + details.style.order = 2; + details.style.flexGrow = 1; + + var linkEl = document.createElement('span'); + var links = document.createElement('small'); + card.appendChild(identicon$$1); + card.appendChild(details); + details.appendChild(linkEl); + details.appendChild(links); + + this.gun.on(async function (data) { + if (!data) { + return; + } + var attrs = await Contact.getAttrs(_this.gun); + var linkTo = await _this.gun.get('linkTo').then(); + var link = 'https://iris.to/#/identities/' + linkTo.type + '/' + linkTo.value; + var mva = Contact.getMostVerifiedAttributes(attrs); + linkEl.innerHTML = '' + (mva.type && mva.type.attribute.value || mva.nickname && mva.nickname.attribute.value || linkTo.type + ':' + linkTo.value) + '
'; + linkEl.innerHTML += 'Received: +' + (data.receivedPositive || 0) + ' / -' + (data.receivedNegative || 0) + '
'; + links.innerHTML = ''; + _Object$keys(attrs).forEach(function (k) { + var a = attrs[k]; + if (a.link) { + links.innerHTML += a.type + ': ' + a.value + ' '; + } + }); + }); + + /* + const template = ``` + + + + rootContact + + + + +
+ + + + + + + + + + + + + + + + + + + + + ```;*/ + return card; + }; + + /** + * Appends an identity search widget to the given HTMLElement + * @param {HTMLElement} parentElement element where the search widget is added and event listener attached + * @param {Index} index index root to use for search + */ + + + Contact.appendSearchWidget = function appendSearchWidget(parentElement, index) { + var form = document.createElement('form'); + + var input = document.createElement('input'); + input.type = 'text'; + input.placeholder = 'Search'; + input.id = 'irisSearchInput'; + form.innerHTML += '
'; + + var searchResults = document.createElement('div'); + + parentElement.appendChild(form); + form.appendChild(input); + form.appendChild(searchResults); + input.addEventListener('keyup', async function () { + var r = await index.search(input.value); + searchResults.innerHTML = ''; + r.sort(function (a, b) { + return a.trustDistance - b.trustDistance; + }); + r.forEach(function (i) { + searchResults.appendChild(i.profileCard()); + }); + }); + + return form; + }; + + Contact._ordinal = function _ordinal(n) { + if (n === 0) { + return ''; + } + var s = ['th', 'st', 'nd', 'rd']; + var v = n % 100; + return n + (s[(v - 20) % 10] || s[v] || s[0]); + }; + + /** + * @param {Object} options {width: 50, border: 4, showDistance: true, ipfs: null, outerGlow: false} + * @returns {HTMLElement} identicon element that can be appended to DOM + */ + + + Contact.prototype.identicon = function identicon$$1() { + var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + options = _Object$assign({ + width: 50, + border: 4, + showDistance: true, + outerGlow: false, + ipfs: null + }, options); + util$1.injectCss(); // some other way that is not called on each identicon generation? + var identicon$$1 = document.createElement('div'); + identicon$$1.className = 'iris-identicon'; + identicon$$1.style.width = options.width + 'px'; + identicon$$1.style.height = options.width + 'px'; + + var pie = document.createElement('div'); + pie.className = 'iris-pie'; + pie.style.width = options.width + 'px'; + + var img = document.createElement('img'); + img.alt = ''; + img.width = options.width; + img.height = options.width; + img.style.borderWidth = options.border + 'px'; + + var distance = void 0; + if (options.border) { + distance = document.createElement('span'); + distance.className = 'iris-distance'; + distance.style.fontSize = options.width > 50 ? options.width / 4 + 'px' : '10px'; + identicon$$1.appendChild(distance); + } + identicon$$1.appendChild(pie); + identicon$$1.appendChild(img); + + function setPie(data) { + if (!data) { + return; + } + // Define colors etc + var bgColor = 'rgba(0,0,0,0.2)'; + var bgImage = 'none'; + var transform = ''; + if (options.outerGlow) { + var boxShadow = '0px 0px 0px 0px #82FF84'; + if (data.receivedPositive > data.receivedNegative * 20) { + boxShadow = '0px 0px ' + options.border * data.receivedPositive / 50 + 'px 0px #82FF84'; + } else if (data.receivedPositive < data.receivedNegative * 3) { + boxShadow = '0px 0px ' + options.border * data.receivedNegative / 10 + 'px 0px #BF0400'; + } + pie.style.boxShadow = boxShadow; + } + if (data.receivedPositive + data.receivedNegative > 0) { + if (data.receivedPositive > data.receivedNegative) { + transform = 'rotate(' + (-data.receivedPositive / (data.receivedPositive + data.receivedNegative) * 360 - 180) / 2 + 'deg)'; + bgColor = '#A94442'; + bgImage = 'linear-gradient(' + data.receivedPositive / (data.receivedPositive + data.receivedNegative) * 360 + 'deg, transparent 50%, #3C763D 50%), linear-gradient(0deg, #3C763D 50%, transparent 50%)'; + } else { + transform = 'rotate(' + ((-data.receivedNegative / (data.receivedPositive + data.receivedNegative) * 360 - 180) / 2 + 180) + 'deg)'; + bgColor = '#3C763D'; + bgImage = 'linear-gradient(' + data.receivedNegative / (data.receivedPositive + data.receivedNegative) * 360 + 'deg, transparent 50%, #A94442 50%), linear-gradient(0deg, #A94442 50%, transparent 50%)'; + } + } + + pie.style.backgroundColor = bgColor; + pie.style.backgroundImage = bgImage; + pie.style.transform = transform; + pie.style.opacity = (data.receivedPositive + data.receivedNegative) / 10 * 0.5 + 0.35; + + if (options.showDistance) { + distance.textContent = typeof data.trustDistance === 'number' ? Contact._ordinal(data.trustDistance) : '\u2715'; + } + } + + function setIdenticonImg(data) { + var hash = util$1.getHash(encodeURIComponent(data.type) + ':' + encodeURIComponent(data.value), 'hex'); + var identiconImg = new identicon(hash, { width: options.width, format: 'svg' }); + img.src = img.src || 'data:image/svg+xml;base64,' + identiconImg.toString(); + } + + if (this.linkTo) { + setIdenticonImg(this.linkTo); + } else { + this.gun.get('linkTo').on(setIdenticonImg); + } + + this.gun.on(setPie); + + if (options.ipfs) { + Contact.getAttrs(this.gun).then(function (attrs) { + var mva = Contact.getMostVerifiedAttributes(attrs); + if (mva.profilePhoto) { + var go = function go() { + options.ipfs.cat(mva.profilePhoto.attribute.value).then(function (file) { + var f = options.ipfs.types.Buffer.from(file).toString('base64'); + img.src = 'data:image;base64,' + f; + }); + }; + options.ipfs.isOnline() ? go() : options.ipfs.on('ready', go); + } + }); + } + + return identicon$$1; + }; + + Contact.prototype.serialize = function serialize() { + return this.gun; + }; + + Contact.deserialize = function deserialize(data, opt) { + var linkTo = new Attribute({ type: 'uuid', value: opt.id }); + return new Contact(opt.gun, linkTo); + }; + + return Contact; + }(); + + // 20.1.2.4 Number.isNaN(number) + + + _export(_export.S, 'Number', { + isNaN: function isNaN(number) { + // eslint-disable-next-line no-self-compare + return number != number; + } + }); + + var isNan = _core.Number.isNaN; + + var isNan$1 = createCommonjsModule(function (module) { + module.exports = { "default": isNan, __esModule: true }; + }); + + var _Number$isNaN = unwrapExports(isNan$1); + + var _stringWs = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' + + '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF'; + + var space = '[' + _stringWs + ']'; + var non = '\u200b\u0085'; + var ltrim = RegExp('^' + space + space + '*'); + var rtrim = RegExp(space + space + '*$'); + + var exporter = function (KEY, exec, ALIAS) { + var exp = {}; + var FORCE = _fails(function () { + return !!_stringWs[KEY]() || non[KEY]() != non; + }); + var fn = exp[KEY] = FORCE ? exec(trim) : _stringWs[KEY]; + if (ALIAS) exp[ALIAS] = fn; + _export(_export.P + _export.F * FORCE, 'String', exp); + }; + + // 1 -> String#trimLeft + // 2 -> String#trimRight + // 3 -> String#trim + var trim = exporter.trim = function (string, TYPE) { + string = String(_defined(string)); + if (TYPE & 1) string = string.replace(ltrim, ''); + if (TYPE & 2) string = string.replace(rtrim, ''); + return string; + }; + + var _stringTrim = exporter; + + var $parseInt = _global.parseInt; + var $trim = _stringTrim.trim; + + var hex = /^[-+]?0[xX]/; + + var _parseInt = $parseInt(_stringWs + '08') !== 8 || $parseInt(_stringWs + '0x16') !== 22 ? function parseInt(str, radix) { + var string = $trim(String(str), 3); + return $parseInt(string, (radix >>> 0) || (hex.test(string) ? 16 : 10)); + } : $parseInt; + + // 20.1.2.13 Number.parseInt(string, radix) + _export(_export.S + _export.F * (Number.parseInt != _parseInt), 'Number', { parseInt: _parseInt }); + + var _parseInt$1 = _core.Number.parseInt; + + var _parseInt$2 = createCommonjsModule(function (module) { + module.exports = { "default": _parseInt$1, __esModule: true }; + }); + + var _Number$parseInt = unwrapExports(_parseInt$2); + + /** + * Private communication channel between two or more participants. Can be used + * independently of other Iris stuff. + * + * Messages are encrypted and chat ids obfuscated, but it is possible to guess + * who are communicating with each other by looking at Gun timestamps and subscriptions. + * + * options.onMessage callback is not guaranteed to receive messages ordered by timestamp. + * You should sort them in the presentation layer. + * + * @param {Object} options {key, gun, onMessage, participants} + * @example https://github.com/irislib/iris-lib/blob/master/__tests__/chat.js + */ + + var Chat = function () { + function Chat(options) { + _classCallCheck(this, Chat); + + this.key = options.key; + this.gun = options.gun; + this.user = this.gun.user(); + this.user.auth(this.key); + this.user.put({ epub: this.key.epub }); + this.secrets = {}; // maps participant public key to shared secret + this.ourSecretChatIds = {}; // maps participant public key to our secret chat id + this.theirSecretChatIds = {}; // maps participant public key to their secret chat id + this.onMessage = options.onMessage; + + if (typeof options.participants === 'string') { + this.addPub(options.participants); + } else if (Array.isArray(options.participants)) { + for (var i = 0; i < options.participants.length; i++) { + if (typeof options.participants[i] === 'string') { + this.addPub(options.participants[i]); + } else { + console.log('participant public key must be string, got', _typeof(options.participants[i]), options.participants[i]); + } + } + } + } + + Chat.prototype.getSecret = async function getSecret(pub) { + if (!this.secrets[pub]) { + var epub = await this.gun.user(pub).get('epub').once().then(); + this.secrets[pub] = await Gun.SEA.secret(epub, this.key); + } + return this.secrets[pub]; + }; + + /** + * + */ + + + Chat.getOurSecretChatId = async function getOurSecretChatId(gun, pub, pair) { + var epub = await gun.user(pub).get('epub').once().then(); + var secret = await Gun.SEA.secret(epub, pair); + return Gun.SEA.work(secret + pub, null, null, { name: 'SHA-256' }); + }; + + /** + * + */ + + + Chat.getTheirSecretChatId = async function getTheirSecretChatId(gun, pub, pair) { + var epub = await gun.user(pub).get('epub').once().then(); + var secret = await Gun.SEA.secret(epub, pair); + return Gun.SEA.work(secret + pair.pub, null, null, { name: 'SHA-256' }); + }; + + /** + * Return a list of public keys that you have initiated a chat with or replied to. + * (Chats that are initiated by others and unreplied by you don't show up, because + * this method doesn't know where to look for them. Use socialNetwork.getChats() to listen to new chats from friends.) + * @param {Object} gun user.authed gun instance + * @param {Object} keypair SEA keypair that the gun instance is authenticated with + * @param callback callback function that is called for each public key you have a chat with + */ + + + Chat.getChats = async function getChats(gun, keypair, callback) { + var mySecret = await Gun.SEA.secret(keypair.epub, keypair); + gun.user().get('chats').map().on(async function (value, ourSecretChatId) { + if (value) { + gun.user().get('chats').get(ourSecretChatId).get('pub').once(async function (encryptedPub) { + var pub = await Gun.SEA.decrypt(encryptedPub, mySecret); + callback(pub); + }); + } + }); + }; + + Chat.prototype.getOurSecretChatId = async function getOurSecretChatId(pub) { + if (!this.ourSecretChatIds[pub]) { + var secret = await this.getSecret(pub); + this.ourSecretChatIds[pub] = await Gun.SEA.work(secret + pub, null, null, { name: 'SHA-256' }); + } + return this.ourSecretChatIds[pub]; + }; + + Chat.prototype.getTheirSecretChatId = async function getTheirSecretChatId(pub) { + if (!this.theirSecretChatIds[pub]) { + var secret = await this.getSecret(pub); + this.theirSecretChatIds[pub] = await Gun.SEA.work(secret + this.key.pub, null, null, { name: 'SHA-256' }); + } + return this.theirSecretChatIds[pub]; + }; + + Chat.prototype.messageReceived = async function messageReceived(data, pub, selfAuthored) { + if (this.onMessage) { + var decrypted = await Gun.SEA.decrypt(data, (await this.getSecret(pub))); + if (typeof decrypted !== 'object') { + // console.log(`chat data received`, decrypted); + return; + } + this.onMessage(decrypted, { selfAuthored: selfAuthored }); + } + }; + + /** + * Get latest message in this chat. Useful for chat listing. + */ + + + Chat.prototype.getLatestMsg = async function getLatestMsg(callback) { + var _this = this; + + var keys = _Object$keys(this.secrets); + + var _loop = async function _loop(i) { + var ourSecretChatId = await _this.getOurSecretChatId(keys[i]); + _this.user.get('chats').get(ourSecretChatId).get('latestMsg').on(async function (data) { + var decrypted = await Gun.SEA.decrypt(data, (await _this.getSecret(keys[i]))); + if (typeof decrypted !== 'object') { + // console.log(`chat data received`, decrypted); + return; + } + callback(decrypted, {}); + }); + }; + + for (var i = 0; i < keys.length; i++) { + await _loop(i); + } + }; + + /** + * Useful for notifications + * @param {integer} time last seen msg time (default: now) + */ + + + Chat.prototype.setMyMsgsLastSeenTime = async function setMyMsgsLastSeenTime(time) { + var keys = _Object$keys(this.secrets); + time = time || new Date().toISOString(); + for (var i = 0; i < keys.length; i++) { + var encrypted = await Gun.SEA.encrypt(time, (await this.getSecret(keys[i]))); + var ourSecretChatId = await this.getOurSecretChatId(keys[i]); + this.user.get('chats').get(ourSecretChatId).get('msgsLastSeenTime').put(encrypted); + } + }; + + /** + * Useful for notifications + */ + + + Chat.prototype.getMyMsgsLastSeenTime = async function getMyMsgsLastSeenTime(callback) { + var _this2 = this; + + var keys = _Object$keys(this.secrets); + + var _loop2 = async function _loop2(i) { + var ourSecretChatId = await _this2.getOurSecretChatId(keys[i]); + _this2.gun.user().get('chats').get(ourSecretChatId).get('msgsLastSeenTime').on(async function (data) { + _this2.myMsgsLastSeenTime = await Gun.SEA.decrypt(data, (await _this2.getSecret(keys[i]))); + if (callback) { + callback(_this2.myMsgsLastSeenTime); + } + }); + }; + + for (var i = 0; i < keys.length; i++) { + await _loop2(i); + } + }; + + /** + * For "seen" status indicator + */ + + + Chat.prototype.getTheirMsgsLastSeenTime = async function getTheirMsgsLastSeenTime(callback) { + var _this3 = this; + + var keys = _Object$keys(this.secrets); + + var _loop3 = async function _loop3(i) { + var theirSecretChatId = await _this3.getTheirSecretChatId(keys[i]); + _this3.gun.user(keys[i]).get('chats').get(theirSecretChatId).get('msgsLastSeenTime').on(async function (data) { + _this3.theirMsgsLastSeenTime = await Gun.SEA.decrypt(data, (await _this3.getSecret(keys[i]))); + if (callback) { + callback(_this3.theirMsgsLastSeenTime, keys[i]); + } + }); + }; + + for (var i = 0; i < keys.length; i++) { + await _loop3(i); + } + }; + + /** + * Add a public key to the chat + * @param {string} pub + */ + + + Chat.prototype.addPub = async function addPub(pub) { + var _this4 = this; + + this.secrets[pub] = null; + this.getSecret(pub); + // Save their public key in encrypted format, so in chat listing we know who we are chatting with + var ourSecretChatId = await this.getOurSecretChatId(pub); + var mySecret = await Gun.SEA.secret(this.key.epub, this.key); + this.gun.user().get('chats').get(ourSecretChatId).get('pub').put((await Gun.SEA.encrypt(pub, mySecret))); + // Subscribe to their messages + var theirSecretChatId = await this.getTheirSecretChatId(pub); + this.gun.user(pub).get('chats').get(theirSecretChatId).get('msgs').map().once(function (data) { + _this4.messageReceived(data, pub); + }); + // Subscribe to our messages + this.user.get('chats').get(ourSecretChatId).get('msgs').map().once(function (data) { + _this4.messageReceived(data, pub, true); + }); + }; + + /** + * Send a message to the chat + * @param msg string or {time, author, text} object + */ + + + Chat.prototype.send = async function send(msg) { + if (typeof msg === 'string') { + msg = { + time: new Date().toISOString(), + author: 'anonymous', + text: msg + }; + } + + //this.gun.user().get('message').set(temp); + var keys = _Object$keys(this.secrets); + for (var i = 0; i < keys.length; i++) { + var encrypted = await Gun.SEA.encrypt(_JSON$stringify(msg), (await this.getSecret(keys[i]))); + var ourSecretChatId = await this.getOurSecretChatId(keys[i]); + this.user.get('chats').get(ourSecretChatId).get('msgs').get('' + msg.time).put(encrypted); + this.user.get('chats').get(ourSecretChatId).get('latestMsg').put(encrypted); + } + }; + + /** + * Set the user's online status + * @param {object} gun + * @param {boolean} isOnline true: update the user's lastActive time every 3 seconds, false: stop updating + */ + + + Chat.setOnline = function setOnline(gun, isOnline) { + if (isOnline) { + var update = function update() { + gun.user().get('lastActive').put(Math.round(Gun.state() / 1000)); + }; + update(); + gun.setOnlineInterval = setInterval(update, 3000); + } else { + clearInterval(gun.setOnlineInterval); + } + }; + + /** + * Get the online status of a user. + * + * @param {object} gun + * @param {string} pubKey public key of the user + * @param {boolean} callback receives a boolean each time the user's online status changes + */ + + + Chat.getOnline = function getOnline(gun, pubKey, callback) { + var timeout = void 0; + gun.user(pubKey).get('lastActive').on(function (lastActive) { + clearTimeout(timeout); + var now = Math.round(Gun.state() / 1000); + var isOnline = lastActive > now - 10 && lastActive < now + 30; + callback({ isOnline: isOnline, lastActive: lastActive }); + if (isOnline) { + timeout = setTimeout(function () { + return callback({ isOnline: false, lastActive: lastActive }); + }, 10000); + } + }); + }; + + /** + * In order to receive messages from others, this method must be called for newly created + * users that have not started a chat with an existing user yet. + * + * It saves the user's key.epub (public key for encryption) into their gun user space, + * so others can find it and write encrypted messages to them. + * + * If you start a chat with an existing user, key.epub is saved automatically and you don't need + * to call this method. + */ + + + Chat.initUser = function initUser(gun, key) { + var user = gun.user(); + user.auth(key); + user.put({ epub: key.epub }); + }; + + return Chat; + }(); + + Gun.User.prototype.top = function (key) { + var gun = this, + root = gun.back(-1), + user = root.user(); + if (!user.is) { + throw { err: 'Not logged in!' }; + } + var top = user.chain(), + at = top._; + at.soul = at.get = '~' + user.is.pub + '.' + key; + var tmp = root.get(at.soul)._; + (tmp.echo || (tmp.echo = {}))[at.id] = at; + return top; + }; + + // temp method for GUN search + async function searchText(node, callback, query, limit) { + // , cursor, desc + var seen = {}; + node.map().once(function (value, key) { + //console.log(`searchText`, value, key, desc); + if (key.indexOf(query) === 0) { + if (typeof limit === 'number' && _Object$keys(seen).length >= limit) { + return; + } + if (Object.prototype.hasOwnProperty.call(seen, key)) { + return; + } + if (value && _Object$keys(value).length > 1) { + seen[key] = true; + callback({ value: value, key: key }); + } + } + }); + } + + // TODO: flush onto IPFS + /** + * The essence of Iris: A database of Contacts and Messages within your web of trust. + * + * NOTE: these docs reflect the latest commit at https://github.com/irislib/iris-lib + * + * To use someone else's index (read-only): set options.pubKey + * + * To use your own index: set options.keypair or omit it to use Key.getDefaultKey(). + * + * Each added Message updates the Message and Contacts indexes and web of trust accordingly. + * + * You can pass options.gun to use custom gun storages and networking settings. + * + * If you want messages saved to IPFS, pass options.ipfs = instance. + * + * Wait for index.ready promise to resolve before calling instance methods. + * @param {Object} options see default options in example + * @example + * https://github.com/irislib/iris-lib/blob/master/__tests__/socialNetwork.js + * + * Default options: + *{ + * ipfs: undefined, + * keypair: undefined, + * pubKey: undefined, + * gun: undefined, + * self: undefined, + * indexSync: { + * importOnAdd: { + * enabled: true, + * maxMsgCount: 500, + * maxMsgDistance: 2 + * }, + * subscribe: { + * enabled: true, + * maxMsgDistance: 1 + * }, + * query: { + * enabled: true + * }, + * msgTypes: { + * all: false, + * rating: true, + * verification: true, + * unverification: true + * }, + * debug: false + * } + *} + * @returns {SocialNetwork} index object + */ + + var SocialNetwork = function () { + function SocialNetwork(options) { + var _this = this; + + _classCallCheck(this, SocialNetwork); + + this.options = _Object$assign({ + ipfs: undefined, + keypair: undefined, + pubKey: undefined, + self: undefined, + indexSync: { + importOnAdd: { + enabled: true, + maxMsgCount: 100, + maxMsgDistance: 2 + }, + subscribe: { + enabled: true, + maxMsgDistance: 1 + }, + query: { + enabled: true + }, + msgTypes: { + all: false, + rating: true, + verification: true, + unverification: true + }, + debug: false + } + }, options); + + if (options.pubKey) { + // someone else's index + var gun = options.gun || new Gun(); + var user = gun.user(options.pubKey); + this.gun = user.get('iris'); + this.rootContact = new Attribute({ type: 'keyID', value: options.pubKey }); + this.ready = _Promise.resolve(); + } else { + // our own index + this.ready = this._init(); + } + this.ready.then(function () { + return _this._subscribeToTrustedIndexes(); + }); + } + + SocialNetwork.prototype._init = async function _init() { + var _this2 = this; + + var keypair = this.options.keypair; + if (!keypair) { + keypair = await Key.getDefault(); + } + var gun = this.options.gun || new Gun(); + var user = gun.user(); + user.auth(keypair); + this.writable = true; + this.rootContact = new Attribute('keyID', Key.getId(keypair)); + user.get('epub').put(keypair.epub); + // Initialize indexes with deterministic gun souls (.top) + this.gun = user.get('iris').put(user.top('iris')); + this.gun.get('identitiesBySearchKey').put(user.top('identitiesBySearchKey')); + this.gun.get('identitiesByTrustDistance').put(user.top('identitiesByTrustDistance')); + this.gun.get('messages').put(user.top('messages')); + this.gun.get('messagesByTimestamp').put(user.top('messagesByTimestamp')); + this.gun.get('messagesByHash').put(user.top('messagesByHash')); + this.gun.get('messagesByDistance').put(user.top('messagesByDistance')); + + this.messages = new Collection({ gun: this.gun, class: Message, indexes: ['time', 'trustDistance'] }); + this.contacts = new Collection({ gun: this.gun, class: Contact }); + + var uri = this.rootContact.uri(); + var g = user.top(uri); + this.gun.get('identitiesBySearchKey').get(uri).put(g); + var attrs = {}; + attrs[uri] = this.rootContact; + if (this.options.self) { + var keys = _Object$keys(this.options.self); + for (var i = 0; i < keys.length; i++) { + var a = new Attribute(keys[i], this.options.self[keys[i]]); + attrs[a.uri()] = a; + } + } + var id = Contact.create(g, { trustDistance: 0, linkTo: this.rootContact, attrs: attrs }, this); + await this._addContactToIndexes(id.gun); + if (this.options.self) { + var recipient = _Object$assign(this.options.self, { keyID: this.rootContact.value }); + Message.createVerification({ recipient: recipient }, keypair).then(function (msg) { + _this2.addMessage(msg); + }); + } + }; + + SocialNetwork.prototype._subscribeToTrustedIndexes = function _subscribeToTrustedIndexes() { + var _this3 = this; + + if (this.writable && this.options.indexSync.subscribe.enabled) { + setTimeout(function () { + _this3.gun.get('trustedIndexes').map().once(function (val, uri) { + if (val) { + // TODO: only get new messages? + _this3.gun.user(uri).get('iris').get('messagesByDistance').map(function (val, key) { + var d = _Number$parseInt(key.split(':')[0]); + if (!isNaN(d) && d <= _this3.options.indexSync.subscribe.maxMsgDistance) { + Message.fromSig(val).then(function (msg) { + if (_this3.options.indexSync.msgTypes.all || Object.prototype.hasOwnProperty.call(_this3.options.indexSync.msgTypes, msg.signedData.type)) { + _this3.addMessage(msg, { checkIfExists: true }); + } + }); + } + }); + _this3.gun.user(uri).get('iris').get('reactions').map(function (reaction, msgHash) { + _this3.gun.get('messagesByHash').get(msgHash).get('reactions').get(uri).put(reaction); + _this3.gun.get('messagesByHash').get(msgHash).get('reactions').get(uri).put(reaction); + }); + } + }); + }, 5000); // TODO: this should be made to work without timeout + } + }; + + SocialNetwork.prototype.debug = function debug() { + var d = util$1.isNode && process$3.env.DEBUG ? process$3.env.DEBUG === 'true' : this.options.debug; + if (d) { + console.log.apply(console, arguments); + } + }; + + SocialNetwork.getMsgIndexKey = function getMsgIndexKey(msg) { + var distance = parseInt(msg.distance); + distance = _Number$isNaN(distance) ? 99 : distance; + distance = ('00' + distance).substring(distance.toString().length); // pad with zeros + var key = distance + ':' + Math.floor(Date.parse(msg.signedData.time || msg.signedData.timestamp)) + ':' + (msg.ipfs_hash || msg.hash).substr(0, 9); + return key; + }; + + // TODO: GUN indexing module that does this automatically + + + SocialNetwork.getMsgIndexKeys = function getMsgIndexKeys(msg) { + var keys = {}; + var distance = parseInt(msg.distance); + distance = _Number$isNaN(distance) ? 99 : distance; + distance = ('00' + distance).substring(distance.toString().length); // pad with zeros + var timestamp = Math.floor(Date.parse(msg.signedData.time || msg.signedData.timestamp)); + var hashSlice = msg.getHash().substr(0, 9); + + if (msg.signedData.type === 'chat') { + if (msg.signedData.recipient.uuid) { + keys.chatMessagesByUuid = {}; + keys.chatMessagesByUuid[msg.signedData.recipient.uuid] = msg.signedData.time + ':' + hashSlice; + } + return keys; + } + + keys.messagesByHash = [msg.getHash()]; + keys.messagesByTimestamp = [timestamp + ':' + hashSlice]; + keys.messagesByDistance = [distance + ':' + keys.messagesByTimestamp[0]]; + keys.messagesByType = [msg.signedData.type + ':' + timestamp + ':' + hashSlice]; + + keys.messagesByAuthor = {}; + var authors = msg.getAuthorArray(); + for (var i = 0; i < authors.length; i++) { + if (authors[i].isUniqueType()) { + keys.messagesByAuthor[authors[i].uri()] = msg.signedData.timestamp + ':' + hashSlice; + } + } + keys.messagesByRecipient = {}; + var recipients = msg.getRecipientArray(); + for (var _i = 0; _i < recipients.length; _i++) { + if (recipients[_i].isUniqueType()) { + keys.messagesByRecipient[recipients[_i].uri()] = msg.signedData.timestamp + ':' + hashSlice; + } + } + + if (['verification', 'unverification'].indexOf(msg.signedData.type) > -1) { + keys.verificationsByRecipient = {}; + for (var _i2 = 0; _i2 < recipients.length; _i2++) { + var r = recipients[_i2]; + if (!r.isUniqueType()) { + continue; + } + for (var j = 0; j < authors.length; j++) { + var a = authors[j]; + if (!a.isUniqueType()) { + continue; + } + keys.verificationsByRecipient[r.uri()] = a.uri(); + } + } + } else if (msg.signedData.type === 'rating') { + keys.ratingsByRecipient = {}; + for (var _i3 = 0; _i3 < recipients.length; _i3++) { + var _r = recipients[_i3]; + if (!_r.isUniqueType()) { + continue; + } + for (var _j = 0; _j < authors.length; _j++) { + var _a = authors[_j]; + if (!_a.isUniqueType()) { + continue; + } + keys.ratingsByRecipient[_r.uri()] = _a.uri(); + } + } + } + return keys; + }; + + SocialNetwork.prototype.getContactIndexKeys = async function getContactIndexKeys(contact, hash) { + var indexKeys = { identitiesByTrustDistance: [], identitiesBySearchKey: [] }; + var d = void 0; + if (contact.keyID && this.rootContact.equals(contact.linkTo)) { + // TODO: contact is a gun instance, no linkTo + d = 0; + } else { + d = await contact.get('trustDistance').then(); + } + + function addIndexKey(a) { + if (!(a && a.value && a.type)) { + // TODO: this sometimes returns undefined + return; + } + var distance = d !== undefined ? d : parseInt(a.dist); + distance = _Number$isNaN(distance) ? 99 : distance; + distance = ('00' + distance).substring(distance.toString().length); // pad with zeros + var v = a.value || a[1]; + var n = a.type || a[0]; + var value = encodeURIComponent(v); + var lowerCaseValue = encodeURIComponent(v.toLowerCase()); + var name = encodeURIComponent(n); + var key = value + ':' + name; + var lowerCaseKey = lowerCaseValue + ':' + name; + if (!Attribute.isUniqueType(n)) { + // allow for multiple index keys with same non-unique attribute + key = key + ':' + hash.substr(0, 9); + lowerCaseKey = lowerCaseKey + ':' + hash.substr(0, 9); + } + indexKeys.identitiesBySearchKey.push(key); + indexKeys.identitiesByTrustDistance.push(distance + ':' + key); + if (key !== lowerCaseKey) { + indexKeys.identitiesBySearchKey.push(lowerCaseKey); + indexKeys.identitiesByTrustDistance.push(distance + ':' + lowerCaseKey); + } + if (v.indexOf(' ') > -1) { + var words = v.toLowerCase().split(' '); + for (var l = 0; l < words.length; l += 1) { + var k = encodeURIComponent(words[l]) + ':' + name; + if (!Attribute.isUniqueType(n)) { + k = k + ':' + hash.substr(0, 9); + } + indexKeys.identitiesBySearchKey.push(k); + indexKeys.identitiesByTrustDistance.push(distance + ':' + k); + } + } + if (key.match(/^http(s)?:\/\/.+\/[a-zA-Z0-9_]+$/)) { + var split = key.split('/'); + indexKeys.identitiesBySearchKey.push(split[split.length - 1]); + indexKeys.identitiesByTrustDistance.push(distance + ':' + split[split.length - 1]); + } + } + + if (this.rootContact.equals(contact.keyID)) { + addIndexKey(contact.keyID); + } + + var attrs = await Contact.getAttrs(contact); + _Object$values(attrs).map(addIndexKey); + + return indexKeys; + }; + + /** + * + */ + + + SocialNetwork.prototype.addContact = async function addContact(attributes) { + var follow = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; + + // TODO: add uuid to attributes + var msg = void 0; + if (follow) { + msg = await Message.createRating({ recipient: attributes, rating: 1 }); + } else { + msg = await Message.createVerification({ recipient: attributes }); + } + return this.addMessage(msg); + }; + + /* + * Get an contact referenced by an identifier. + * get(type, value) + * get(Attribute) + * get(value) - guesses the type or throws an error + * @returns {Contact} contact that is connected to the identifier param + */ + + + SocialNetwork.prototype.getContact = function getContact(a, b) { + var _this4 = this; + + var reload = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; + + if (!a) { + throw new Error('getContact failed: first param must be defined'); + } + var attr = a; + if (a.constructor.name !== 'Attribute') { + var type = void 0, + value = void 0; + if (b) { + type = a; + value = b; + } else { + value = a; + type = Attribute.guessTypeOf(value); + } + attr = new Attribute(type, value); + } + if (reload) { + // 1) get verifications connecting attr to other attributes + // 2) recurse + // 3) get messages received by this list of attributes + // 4) calculate stats + // 5) update contact index entry + var o = { + attributes: {}, + sent: {}, + received: {}, + receivedPositive: 0, + receivedNeutral: 0, + receivedNegative: 0, + sentPositive: 0, + sentNeutral: 0, + sentNegative: 0 + }; + var node = this.gun.get('identities').set(o); + var updateContactByLinkedAttribute = function updateContactByLinkedAttribute(attribute) { + _this4.gun.get('verificationsByRecipient').get(attribute.uri()).map().once(function (val) { + var m = Message.fromSig(val); + var recipients = m.getRecipientArray(); + for (var i = 0; i < recipients.length; i++) { + var a2 = recipients[i]; + if (!Object.prototype.hasOwnProperty.call(o.attributes), a2.uri()) { + // TODO remove attribute from contact if not enough verifications / too many unverifications + o.attributes[a2.uri()] = a2; + _this4.gun.get('messagesByRecipient').get(a2.uri()).map().once(function (val) { + var m2 = Message.fromSig(val); + if (!Object.prototype.hasOwnProperty.call(o.received.hasOwnProperty, m2.getHash())) { + o.received[m2.getHash()] = m2; + if (m2.isPositive()) { + o.receivedPositive++; + m2.getAuthor(_this4).gun.get('trustDistance').on(function (d) { + if (typeof d === 'number') { + if (typeof o.trustDistance !== 'number' || o.trustDistance > d + 1) { + o.trustDistance = d + 1; + node.get('trustDistance').put(d + 1); + } + } + }); + } else if (m2.isNegative()) { + o.receivedNegative++; + } else { + o.receivedNeutral++; + } + node.put(o); + } + }); + _this4.gun.get('messagesByAuthor').get(a2.uri()).map().once(function (val) { + var m2 = Message.fromSig(val); + if (!Object.prototype.hasOwnProperty.call(o.sent, m2.getHash())) { + o.sent[m2.getHash()] = m2; + if (m2.isPositive()) { + o.sentPositive++; + } else if (m2.isNegative()) { + o.sentNegative++; + } else { + o.sentNeutral++; + } + node.put(o); + } + }); + updateContactByLinkedAttribute(a2); + } + } + }); + }; + updateContactByLinkedAttribute(attr); + if (this.writable) { + this._addContactToIndexes(node); + } + return new Contact(node, attr, this); + } else { + return new Contact(this.gun.get('identitiesBySearchKey').get(attr.uri()), attr, this); + } + }; + + /** + * + */ + + + SocialNetwork.prototype.getContacts = function getContacts() { + var _this5 = this; + + var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + // cursor // TODO: param 'exact', type param + if (opt.value) { + if (opt.type) { + return this.getContact(opt.type, opt.value, opt.reload); + } else { + return this.getContact(opt.value); + } + } + opt.query = opt.query || ''; + var seen = {}; + function searchTermCheck(key) { + var arr = key.split(':'); + if (arr.length < 2) { + return false; + } + var keyValue = arr[0]; + var keyType = arr[1]; + if (keyValue.indexOf(encodeURIComponent(opt.query)) !== 0) { + return false; + } + if (opt.type && keyType !== opt.type) { + return false; + } + return true; + } + var node = this.gun.get('identitiesBySearchKey'); + node.map().on(function (id, key) { + if (_Object$keys(seen).length >= opt.limit) { + // TODO: turn off .map cb + return; + } + if (!searchTermCheck(key)) { + return; + } + var soul = Gun.node.soul(id); + if (soul && !Object.prototype.hasOwnProperty.call(seen, soul)) { + seen[soul] = true; + var contact = new Contact(node.get(key), undefined, _this5); + contact.cursor = key; + opt.callback(contact); + } + }); + if (this.options.indexSync.query.enabled) { + this.gun.get('trustedIndexes').map().once(function (val, key) { + if (val) { + _this5.gun.user(key).get('iris').get('identitiesBySearchKey').map().on(function (id, k) { + if (_Object$keys(seen).length >= opt.limit) { + // TODO: turn off .map cb + return; + } + if (!searchTermCheck(key)) { + return; + } + var soul = Gun.node.soul(id); + if (soul && !Object.prototype.hasOwnProperty.call(seen, soul)) { + seen[soul] = true; + opt.callback(new Contact(_this5.gun.user(key).get('iris').get('identitiesBySearchKey').get(k), undefined, _this5)); + } + }); + } + }); + } + }; + + /** + * @returns {Contact} root contact (center of the social graph, trustDistance == 0) + */ + + + SocialNetwork.prototype.getRootContact = function getRootContact() { + return new Contact(this.gun.get('identitiesBySearchKey').get(this.rootContact.uri()), undefined, this); + }; + + /** + * Return existing chats and listen to new chats initiated by friends. + * Like Chat.getChats(), but also listens to chats initiated by friends. + */ + + + SocialNetwork.prototype.getChats = async function getChats(callback) { + var _this6 = this; + + Chat.getChats(this.gun, this.options.keypair, callback); + this.gun.get('trustedIndexes').map().on(async function (value, pub) { + if (value && pub) { + var theirSecretChatId = await Chat.getTheirSecretChatId(_this6.gun, pub, _this6.options.keypair); + _this6.gun.user(pub).get('chats').get(theirSecretChatId).on(function (v) { + if (v) { + callback(pub); + } + }); + } + }); + }; + + SocialNetwork.prototype._getMsgs = async function _getMsgs(msgIndex, callback, limit, cursor, desc, filter) { + var results = 0; + async function resultFound(result) { + if (results >= limit) { + return; + } + var msg = await Message.fromSig(result.value); + if (filter && !filter(msg)) { + return; + } + results++; + msg.cursor = result.key; + if (result.value && result.value.ipfsUri) { + msg.ipfsUri = result.value.ipfsUri; + } + msg.gun = msgIndex.get(result.key); + callback(msg); + } + searchText(msgIndex, resultFound, '', undefined, cursor, desc); + }; + + SocialNetwork.prototype._addContactToIndexes = async function _addContactToIndexes(id) { + if (typeof id === 'undefined') { + var e = new Error('id is undefined'); + console.error(e.stack); + throw e; + } + var hash = Gun.node.soul(id) || id._ && id._.link || 'todo'; + var indexKeys = await this.getContactIndexKeys(id, hash.substr(0, 6)); + + var indexes = _Object$keys(indexKeys); + for (var i = 0; i < indexes.length; i++) { + var index = indexes[i]; + for (var j = 0; j < indexKeys[index].length; j++) { + var key = indexKeys[index][j]; + // this.debug(`adding to index ${index} key ${key}, saving data: ${id}`); + this.gun.get(index).get(key).put(id); // FIXME: Check, why this can't be `await`ed for in tests? [index.ready promise gets stuck] + } + } + }; + + SocialNetwork.prototype._getSentMsgs = async function _getSentMsgs(contact, options) { + var _this7 = this; + + this._getMsgs(contact.gun.get('sent'), options.callback, options.limit, options.cursor, true, options.filter); + if (this.options.indexSync.query.enabled) { + this.gun.get('trustedIndexes').map().once(function (val, key) { + if (val) { + var n = _this7.gun.user(key).get('iris').get('messagesByAuthor').get(contact.linkTo.uri()); + _this7._getMsgs(n, options.callback, options.limit, options.cursor, false, options.filter); + } + }); + } + }; + + SocialNetwork.prototype._getReceivedMsgs = async function _getReceivedMsgs(contact, options) { + var _this8 = this; + + this._getMsgs(contact.gun.get('received'), options.callback, options.limit, options.cursor, true, options.filter); + if (this.options.indexSync.query.enabled) { + this.gun.get('trustedIndexes').map().once(function (val, key) { + if (val) { + var n = _this8.gun.user(key).get('iris').get('messagesByRecipient').get(contact.linkTo.uri()); + _this8._getMsgs(n, options.callback, options.limit, options.cursor, false, options.filter); + } + }); + } + }; + + SocialNetwork.prototype.getChatMsgs = async function getChatMsgs(uuid, options) { + var _this9 = this; + + this._getMsgs(this.gun.get('chatMessagesByUuid').get(uuid), options.callback, options.limit, options.cursor, true, options.filter); + var callback = function callback(msg) { + if (options.callback) { + options.callback(msg); + } + _this9.addMessage(msg, { checkIfExists: true }); + }; + this.gun.get('trustedIndexes').map().once(function (val, key) { + if (val) { + var n = _this9.gun.user(key).get('iris').get('chatMessagesByUuid').get(uuid); + _this9._getMsgs(n, callback, options.limit, options.cursor, false, options.filter); + } + }); + }; + + SocialNetwork.prototype._getAttributeTrustDistance = async function _getAttributeTrustDistance(a) { + if (!Attribute.isUniqueType(a.type)) { + return; + } + if (this.rootContact.equals(a)) { + return 0; + } + var id = this.getContact(a); + var d = await id.gun.get('trustDistance').then(); + if (isNaN(d)) { + d = Infinity; + } + return d; + }; + + SocialNetwork.prototype._getMsgTrustDistance = async function _getMsgTrustDistance(msg) { + var shortestDistance = Infinity; + var signerAttr = new Attribute('keyID', msg.getSignerKeyID()); + if (!signerAttr.equals(this.rootContact)) { + var signer = this.getContact(signerAttr); + var d = await signer.gun.get('trustDistance').then(); + if (isNaN(d)) { + return; + } + } + for (var _iterator = msg.getAuthorArray(), _isArray = Array.isArray(_iterator), _i4 = 0, _iterator = _isArray ? _iterator : _getIterator(_iterator);;) { + var _ref; + + if (_isArray) { + if (_i4 >= _iterator.length) break; + _ref = _iterator[_i4++]; + } else { + _i4 = _iterator.next(); + if (_i4.done) break; + _ref = _i4.value; + } + + var a = _ref; + + var _d = await this._getAttributeTrustDistance(a); + if (_d < shortestDistance) { + shortestDistance = _d; + } + } + return shortestDistance < Infinity ? shortestDistance : undefined; + }; + + SocialNetwork.prototype._updateMsgRecipientContact = async function _updateMsgRecipientContact(msg, msgIndexKey, recipient) { + var hash = recipient._ && recipient._.link || 'todo'; + var contactIndexKeysBefore = await this.getContactIndexKeys(recipient, hash.substr(0, 6)); + var attrs = await Contact.getAttrs(recipient); + if (['verification', 'unverification'].indexOf(msg.signedData.type) > -1) { + var isVerification = msg.signedData.type === 'verification'; + + var _loop = function _loop() { + if (_isArray2) { + if (_i5 >= _iterator2.length) return 'break'; + _ref2 = _iterator2[_i5++]; + } else { + _i5 = _iterator2.next(); + if (_i5.done) return 'break'; + _ref2 = _i5.value; + } + + var a = _ref2; + + var hasAttr = false; + var v = { + verifications: isVerification ? 1 : 0, + unverifications: isVerification ? 0 : 1 + }; + _Object$keys(attrs).forEach(function (k) { + // TODO: if author is self, mark as self verified + // TODO: only 1 verif / unverif per author + if (a.equals(attrs[k])) { + attrs[k].verifications = (attrs[k].verifications || 0) + v.verifications; + attrs[k].unverifications = (attrs[k].unverifications || 0) + v.unverifications; + hasAttr = true; + } + }); + if (!hasAttr) { + attrs[a.uri()] = _Object$assign({ type: a.type, value: a.value }, v); + } + if (msg.goodVerification) { + if (isVerification) { + attrs[a.uri()].wellVerified = true; + } else { + attrs[a.uri()].wellUnverified = true; + } + } + }; + + for (var _iterator2 = msg.getRecipientArray(), _isArray2 = Array.isArray(_iterator2), _i5 = 0, _iterator2 = _isArray2 ? _iterator2 : _getIterator(_iterator2);;) { + var _ref2; + + var _ret = _loop(); + + if (_ret === 'break') break; + } + var mva = Contact.getMostVerifiedAttributes(attrs); + recipient.get('mostVerifiedAttributes').put(mva); // TODO: why this needs to be done twice to register? + recipient.get('mostVerifiedAttributes').put(mva); + var k = mva.keyID && mva.keyID.attribute.value || mva.uuid && mva.uuid.attribute.value || hash; + console.log('k', k); + recipient.get('attrs').put(this.gun.user().top(k + '/attrs')); + recipient.get('attrs').put(attrs); + recipient.get('attrs').put(attrs); + } + if (msg.signedData.type === 'rating') { + var id = await recipient.then(); + id.receivedPositive = id.receivedPositive || 0; + id.receivedNegative = id.receivedNegative || 0; + id.receivedNeutral = id.receivedNeutral || 0; + if (msg.isPositive()) { + if (typeof id.trustDistance !== 'number' || msg.distance + 1 < id.trustDistance) { + recipient.get('trustDistance').put(msg.distance + 1); + } + id.receivedPositive++; + } else { + if (msg.distance < id.trustDistance) { + recipient.get('trustDistance').put(false); // TODO: this should take into account the aggregate score of the contact + } + if (msg.isNegative()) { + id.receivedNegative++; + } else { + id.receivedNeutral++; + } + } + + recipient.put({ + receivedPositive: id.receivedPositive, + receivedNegative: id.receivedNegative, + receivedNeutral: id.receivedNeutral + }); + + if (msg.signedData.context === 'verifier') { + if (msg.distance === 0) { + if (msg.isPositive) { + recipient.get('scores').get(msg.signedData.context).get('score').put(10); + } else if (msg.isNegative()) { + recipient.get('scores').get(msg.signedData.context).get('score').put(0); + } else { + recipient.get('scores').get(msg.signedData.context).get('score').put(-10); + } + } + } + } + var obj = { sig: msg.sig, pubKey: msg.pubKey }; + if (msg.ipfsUri) { + obj.ipfsUri = msg.ipfsUri; + } + + recipient.get('received').get(msgIndexKey).put(obj); + recipient.get('received').get(msgIndexKey).put(obj); + + var contactIndexKeysAfter = await this.getContactIndexKeys(recipient, hash.substr(0, 6)); + var indexesBefore = _Object$keys(contactIndexKeysBefore); + for (var i = 0; i < indexesBefore.length; i++) { + var index = indexesBefore[i]; + for (var j = 0; j < contactIndexKeysBefore[index].length; j++) { + var key = contactIndexKeysBefore[index][j]; + if (!contactIndexKeysAfter[index] || contactIndexKeysAfter[index].indexOf(key) === -1) { + this.gun.get(index).get(key).put(null); + } + } + } + }; + + SocialNetwork.prototype._updateMsgAuthorContact = async function _updateMsgAuthorContact(msg, msgIndexKey, author) { + if (msg.signedData.type === 'rating') { + var id = await author.then(); + id.sentPositive = id.sentPositive || 0; + id.sentNegative = id.sentNegative || 0; + id.sentNeutral = id.sentNeutral || 0; + if (msg.isPositive()) { + id.sentPositive++; + } else if (msg.isNegative()) { + id.sentNegative++; + } else { + id.sentNeutral++; + } + author.get('sentPositive').put(id.sentPositive); + author.get('sentNegative').put(id.sentNegative); + author.get('sentNeutral').put(id.sentNeutral); + } + var obj = { sig: msg.sig, pubKey: msg.pubKey }; + if (msg.ipfsUri) { + obj.ipfsUri = msg.ipfsUri; + } + author.get('sent').get(msgIndexKey).put(obj); // for some reason, doesn't work unless I do it twice + author.get('sent').get(msgIndexKey).put(obj); + return; + }; + + SocialNetwork.prototype._updateContactProfilesByMsg = async function _updateContactProfilesByMsg(msg, authorIdentities, recipientIdentities) { + var start = void 0; + var msgIndexKey = SocialNetwork.getMsgIndexKey(msg); + msgIndexKey = msgIndexKey.substr(msgIndexKey.indexOf(':') + 1); + var ids = _Object$values(_Object$assign({}, authorIdentities, recipientIdentities)); + for (var i = 0; i < ids.length; i++) { + // add new identifiers to contact + if (Object.prototype.hasOwnProperty.call(recipientIdentities, ids[i].gun['_'].link)) { + start = new Date(); + await this._updateMsgRecipientContact(msg, msgIndexKey, ids[i].gun); + this.debug(new Date() - start, 'ms _updateMsgRecipientContact'); + } + if (Object.prototype.hasOwnProperty.call(authorIdentities, ids[i].gun['_'].link)) { + start = new Date(); + await this._updateMsgAuthorContact(msg, msgIndexKey, ids[i].gun); + this.debug(new Date() - start, 'ms _updateMsgAuthorContact'); + } + start = new Date(); + await this._addContactToIndexes(ids[i].gun); + this.debug(new Date() - start, 'ms _addContactToIndexes'); + } + }; + + SocialNetwork.prototype.removeTrustedIndex = async function removeTrustedIndex(gunUri) { + this.gun.get('trustedIndexes').get(gunUri).put(null); + }; + + SocialNetwork.prototype.addTrustedIndex = async function addTrustedIndex(gunUri) { + var _this10 = this; + + var maxMsgsToCrawl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.options.indexSync.importOnAdd.maxMsgCount; + // maxMsgDistance = this.options.indexSync.importOnAdd.maxMsgDistance + if (gunUri === this.rootContact.value) { + return; + } + var exists = await this.gun.get('trustedIndexes').get(gunUri).then(); + if (exists) { + return; + } + this.gun.get('trustedIndexes').get(gunUri).put(true); + var msgs = []; + if (this.options.indexSync.importOnAdd.enabled) { + await util$1.timeoutPromise(new _Promise(function (resolve) { + var gun = _this10.gun.user(gunUri).get('iris'); + var callback = function callback(msg) { + msgs.push(msg); + if (msgs.length >= maxMsgsToCrawl) { + resolve(); + } + }; + var messages = new Collection({ gun: gun, class: Message, indexes: ['trustDistance'] }); + messages.get({ callback: callback, orderBy: 'trustDistance', desc: false }); + }), 10000); + this.debug('adding', msgs.length, 'msgs'); + this.addMessages(msgs); + } + }; + + SocialNetwork.prototype._updateContactIndexesByMsg = async function _updateContactIndexesByMsg(msg) { + var recipientIdentities = {}; + var authorIdentities = {}; + var selfAuthored = false; + var start = void 0; + start = new Date(); + for (var _iterator3 = msg.getAuthorArray(), _isArray3 = Array.isArray(_iterator3), _i6 = 0, _iterator3 = _isArray3 ? _iterator3 : _getIterator(_iterator3);;) { + var _ref3; + + if (_isArray3) { + if (_i6 >= _iterator3.length) break; + _ref3 = _iterator3[_i6++]; + } else { + _i6 = _iterator3.next(); + if (_i6.done) break; + _ref3 = _i6.value; + } + + var _a3 = _ref3; + + var _id = this.getContact(_a3); + var start2 = new Date(); + var td = await _id.gun.get('trustDistance').then(); + this.debug(new Date() - start2, 'ms get trustDistance'); + if (!isNaN(td)) { + authorIdentities[_id.gun['_'].link] = _id; + start2 = new Date(); + var scores = await _id.gun.get('scores').then(); + this.debug(new Date() - start2, 'ms get scores'); + if (scores && scores.verifier && msg.signedData.type === 'verification') { + msg.goodVerification = true; + } + if (td === 0) { + selfAuthored = true; + } + } + } + this.debug(new Date() - start, 'ms getAuthorArray'); + if (!_Object$keys(authorIdentities).length) { + return; // unknown author, do nothing + } + start = new Date(); + for (var _iterator4 = msg.getRecipientArray(), _isArray4 = Array.isArray(_iterator4), _i7 = 0, _iterator4 = _isArray4 ? _iterator4 : _getIterator(_iterator4);;) { + var _ref4; + + if (_isArray4) { + if (_i7 >= _iterator4.length) break; + _ref4 = _iterator4[_i7++]; + } else { + _i7 = _iterator4.next(); + if (_i7.done) break; + _ref4 = _i7.value; + } + + var _a4 = _ref4; + + var _id2 = this.getContact(_a4); + var _td = await _id2.gun.get('trustDistance').then(); + + if (!isNaN(_td)) { + recipientIdentities[_id2.gun['_'].link] = _id2; + } + if (selfAuthored && _a4.type === 'keyID' && _a4.value !== this.rootContact.value) { + // TODO: not if already added - causes infinite loop? + if (msg.isPositive()) { + this.addTrustedIndex(_a4.value); + } else { + this.removeTrustedIndex(_a4.value); + } + } + } + this.debug(new Date() - start, 'ms getRecipientArray'); + if (!msg.signedData.recipient) { + // message to self + recipientIdentities = authorIdentities; + } + if (!_Object$keys(recipientIdentities).length) { + // recipient is previously unknown + var attrs = {}; + var u = void 0; + for (var _iterator5 = msg.getRecipientArray(), _isArray5 = Array.isArray(_iterator5), _i8 = 0, _iterator5 = _isArray5 ? _iterator5 : _getIterator(_iterator5);;) { + var _ref5; + + if (_isArray5) { + if (_i8 >= _iterator5.length) break; + _ref5 = _iterator5[_i8++]; + } else { + _i8 = _iterator5.next(); + if (_i8.done) break; + _ref5 = _i8.value; + } + + var _a2 = _ref5; + + attrs[_a2.uri()] = _a2; + if (!u && _a2.isUniqueType()) { + u = _a2; + } + } + var linkTo = Contact.getLinkTo(attrs); + var trustDistance = msg.isPositive() && typeof msg.distance === 'number' ? msg.distance + 1 : false; + var _start = new Date(); + var node = this.gun.get('identitiesBySearchKey').get(u.uri()); + node.put({ a: 1 }); // {a:1} because inserting {} causes a "no signature on data" error from gun + var id = Contact.create(node, { attrs: attrs, linkTo: linkTo, trustDistance: trustDistance }, this); + this.debug(new Date() - _start, 'ms contact.create'); + + // TODO: take msg author trust into account + recipientIdentities[id.gun['_'].link] = id; + } + + return this._updateContactProfilesByMsg(msg, authorIdentities, recipientIdentities); + }; + + /** + * Add a message to messagesByTimestamp and other relevant indexes. Update identities in the web of trust according to message data. + * + * @param msg Message (or an array of messages) to add to the index + */ + + + SocialNetwork.prototype.addMessage = async function addMessage(msg) { + var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + if (!this.writable) { + throw new Error('Cannot write to a read-only index (initialized with options.pubKey)'); + } + if (Array.isArray(msg)) { + return this.addMessages(msg, options); + } + var start = void 0; + if (msg.constructor.name !== 'Message') { + throw new Error('addMessage failed: param must be a Message, received ' + msg.constructor.name); + } + var hash = msg.getHash(); + if (true === options.checkIfExists) { + var exists = await this.gun.get('messagesByHash').get(hash).then(); + if (exists) { + return; + } + } + var obj = { sig: msg.sig, pubKey: msg.pubKey }; + //const node = this.gun.get(`messagesByHash`).get(hash).put(obj); + var node = this.gun.back(-1).get('messagesByHash').get(hash).put(obj); // TODO: needs fix to https://github.com/amark/gun/issues/719 + start = new Date(); + var d = await this._getMsgTrustDistance(msg); + msg.distance = Object.prototype.hasOwnProperty.call(msg, 'distance') ? msg.distance : d; // eslint-disable-line require-atomic-updates + this.debug('----'); + this.debug(new Date() - start, 'ms _getMsgTrustDistance'); + if (msg.distance === undefined) { + return false; // do not save messages from untrusted author + } + if (msg.signedData.replyTo) { + this.gun.back(-1).get('messagesByHash').get(msg.signedData.replyTo).get('replies').get(hash).put(node); + this.gun.back(-1).get('messagesByHash').get(msg.signedData.replyTo).get('replies').get(hash).put(node); + } + if (msg.signedData.sharedMsg) { + this.gun.back(-1).get('messagesByHash').get(msg.signedData.sharedMsg).get('shares').get(hash).put(node); + this.gun.back(-1).get('messagesByHash').get(msg.signedData.sharedMsg).get('shares').get(hash).put(node); + } + start = new Date(); + + this.messages.put(msg); + + // TODO: this should be moved to Collection + var indexKeys = SocialNetwork.getMsgIndexKeys(msg); + this.debug(new Date() - start, 'ms getMsgIndexKeys'); + for (var index in indexKeys) { + if (Array.isArray(indexKeys[index])) { + for (var i = 0; i < indexKeys[index].length; i++) { + var key = indexKeys[index][i]; + // this.debug(`adding to index ${index} key ${key}`); + this.gun.get(index).get(key).put(node); + this.gun.get(index).get(key).put(node); // umm, what? doesn't work unless I write it twice + } + } else if (typeof indexKeys[index] === 'object') { + for (var _key in indexKeys[index]) { + this.gun.get(index).get(_key).get(indexKeys[index][_key]).put(node); + this.gun.get(index).get(_key).get(indexKeys[index][_key]).put(node); + } + } + } + + if (this.options.ipfs) { + try { + var ipfsUri = await msg.saveToIpfs(this.options.ipfs); + this.gun.get('messagesByHash').get(ipfsUri).put(node); + this.gun.get('messagesByHash').get(ipfsUri).put(node); + this.gun.get('messagesByHash').get(ipfsUri).put({ ipfsUri: ipfsUri }); + } catch (e) { + console.error('adding msg ' + msg + ' to ipfs failed: ' + e); + } + } + if (msg.signedData.type !== 'chat') { + start = new Date(); + await this._updateContactIndexesByMsg(msg); + this.debug(new Date() - start, 'ms _updateContactIndexesByMsg'); + } + return true; + }; + + /** + * Alias to socialNetwork.messages.get(opt) (but with opt.orderBy = 'time') + * @param {Object} opt {hash, orderBy, callback, limit, cursor, desc, filter} + */ + + + SocialNetwork.prototype.getMessages = async function getMessages(opt) { + if (opt.hash) { + return this.messages.get({ id: opt.hash }); + } + opt.orderBy = opt.orderBy || 'time'; + return this.messages.get(opt); + }; + + /* + * Add a list of messages to the index. + * Useful for example when adding a new WoT dataset that contains previously + * unknown authors. + * + * Iteratively performs sorted merge joins on [previously known contacts] and + * [new msgs authors], until all messages from within the WoT have been added. + * + * @param {Array} msgs an array of messages. + * @returns {boolean} true on success + */ + + + SocialNetwork.prototype.addMessages = async function addMessages(msgs) { + var _this11 = this; + + if (!this.writable) { + throw new Error('Cannot write to a read-only index (initialized with options.pubKey)'); + } + var msgsByAuthor = {}; + if (Array.isArray(msgs)) { + this.debug('sorting ' + msgs.length + ' messages onto a search tree...'); + for (var i = 0; i < msgs.length; i++) { + for (var _iterator6 = msgs[i].getAuthorArray(), _isArray6 = Array.isArray(_iterator6), _i9 = 0, _iterator6 = _isArray6 ? _iterator6 : _getIterator(_iterator6);;) { + var _ref6; + + if (_isArray6) { + if (_i9 >= _iterator6.length) break; + _ref6 = _iterator6[_i9++]; + } else { + _i9 = _iterator6.next(); + if (_i9.done) break; + _ref6 = _i9.value; + } + + var _a5 = _ref6; + + if (_a5.isUniqueType()) { + var key = _a5.uri() + ':' + msgs[i].getHash(); + msgsByAuthor[key] = msgs[i]; + } + } + } + this.debug('...done'); + } else { + throw 'msgs param must be an array'; + } + var msgAuthors = _Object$keys(msgsByAuthor).sort(); + if (!msgAuthors.length) { + return; + } + var initialMsgCount = void 0, + msgCountAfterwards = void 0; + var index = this.gun.get('identitiesBySearchKey'); + + var _loop2 = async function _loop2() { + var knownIdentities = []; + var stop = false; + searchText(index, function (result) { + if (stop) { + return; + } + knownIdentities.push(result); + }, ''); + await new _Promise(function (r) { + return setTimeout(r, 2000); + }); // wait for results to accumulate + stop = true; + knownIdentities.sort(function (a, b) { + if (a.key === b.key) { + return 0; + } else if (a.key > b.key) { + return 1; + } else { + return -1; + } + }); + var i = 0; + var author = msgAuthors[i]; + var knownContact = knownIdentities.shift(); + initialMsgCount = msgAuthors.length; + // sort-merge join identitiesBySearchKey and msgsByAuthor + while (author && knownContact) { + if (author.indexOf(knownContact.key) === 0) { + try { + await util$1.timeoutPromise(_this11.addMessage(msgsByAuthor[author], { checkIfExists: true }), 10000); + } catch (e) { + _this11.debug('adding failed:', e, _JSON$stringify(msgsByAuthor[author], null, 2)); + } + msgAuthors.splice(i, 1); + author = i < msgAuthors.length ? msgAuthors[i] : undefined; + //knownContact = knownIdentities.shift(); + } else if (author < knownContact.key) { + author = i < msgAuthors.length ? msgAuthors[++i] : undefined; + } else { + knownContact = knownIdentities.shift(); + } + } + msgCountAfterwards = msgAuthors.length; + }; + + do { + await _loop2(); + } while (msgCountAfterwards !== initialMsgCount); + return true; + }; + + /* + * @returns {Object} message matching the hash + */ + + + SocialNetwork.prototype.getMessageByHash = function getMessageByHash(hash) { + var _this12 = this; + + var isIpfsUri = hash.indexOf('Qm') === 0; + return new _Promise(async function (resolve) { + var resolveIfHashMatches = async function resolveIfHashMatches(d, fromIpfs) { + var obj = typeof d === 'object' ? d : JSON.parse(d); + var m = await Message.fromSig(obj); + var h = void 0; + var republished = false; + if (fromIpfs) { + return resolve(m); + } else if (isIpfsUri && _this12.options.ipfs) { + h = await m.saveToIpfs(_this12.options.ipfs); + republished = true; + } else { + h = m.getHash(); + } + if (h === hash || isIpfsUri && !_this12.options.ipfs) { + // does not check hash validity if it's an ipfs uri and we don't have ipfs + if (!fromIpfs && _this12.options.ipfs && _this12.writable && !republished) { + m.saveToIpfs(_this12.options.ipfs).then(function (ipfsUri) { + obj.ipfsUri = ipfsUri; + _this12.gun.get('messagesByHash').get(hash).put(obj); + _this12.gun.get('messagesByHash').get(ipfsUri).put(obj); + }); + } + resolve(m); + } else { + console.error('queried index for message ' + hash + ' but received ' + h); + } + }; + if (isIpfsUri && _this12.options.ipfs) { + _this12.options.ipfs.cat(hash).then(function (file) { + var s = _this12.options.ipfs.types.Buffer.from(file).toString('utf8'); + _this12.debug('got msg ' + hash + ' from ipfs'); + resolveIfHashMatches(s, true); + }); + } + _this12.gun.get('messagesByHash').get(hash).on(function (d) { + _this12.debug('got msg ' + hash + ' from own gun index'); + resolveIfHashMatches(d); + }); + if (_this12.options.indexSync.query.enabled) { + _this12.gun.get('trustedIndexes').map().once(function (val, key) { + if (val) { + _this12.gun.user(key).get('iris').get('messagesByHash').get(hash).on(function (d) { + _this12.debug('got msg ' + hash + ' from friend\'s gun index ' + val); + resolveIfHashMatches(d); + }); + } + }); + } + }); + }; + + /* + * @returns {Array} list of messages + */ + + + SocialNetwork.prototype.getMessagesByTimestamp = function getMessagesByTimestamp(callback, limit, cursor) { + var _this13 = this; + + var desc = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true; + var filter = arguments[4]; + + var seen = {}; + var cb = function cb(msg) { + if ((!limit || _Object$keys(seen).length < limit) && !Object.prototype.hasOwnProperty.call(seen, msg.hash)) { + seen[msg.getHash()] = true; + callback(msg); + } + }; + + this._getMsgs(this.gun.get('messagesByTimestamp'), cb, limit, cursor, desc, filter); + if (this.options.indexSync.query.enabled) { + this.gun.get('trustedIndexes').map().once(function (val, key) { + if (val) { + var n = _this13.gun.user(key).get('iris').get('messagesByTimestamp'); + _this13._getMsgs(n, cb, limit, cursor, desc, filter); + } + }); + } + }; + + /* + * @returns {Array} list of messages + */ + + + SocialNetwork.prototype.getMessagesByDistance = function getMessagesByDistance(callback, limit, cursor, desc, filter) { + var _this14 = this; + + var seen = {}; + var cb = function cb(msg) { + if (!Object.prototype.hasOwnProperty.call(seen, msg.hash)) { + if ((!limit || _Object$keys(seen).length <= limit) && !Object.prototype.hasOwnProperty.call(seen, msg.hash)) { + seen[msg.hash] = true; + callback(msg); + } + } + }; + this._getMsgs(this.gun.get('messagesByDistance'), cb, limit, cursor, desc, filter); + if (this.options.indexSync.query.enabled) { + this.gun.get('trustedIndexes').map().once(function (val, key) { + if (val) { + var n = _this14.gun.user(key).get('iris').get('messagesByDistance'); + _this14._getMsgs(n, cb, limit, cursor, desc, filter); + } + }); + } + }; + + return SocialNetwork; + }(); + + var version$2 = "0.0.132"; + + /*eslint no-useless-escape: "off", camelcase: "off" */ + + var index = { + VERSION: version$2, + Collection: Collection, + Message: Message, + Contact: Contact, + Attribute: Attribute, + SocialNetwork: SocialNetwork, + Key: Key, + Chat: Chat, + util: util$1 + }; + + return index; + +}))); diff --git a/src/jquery.js b/src/jquery.js new file mode 100644 index 00000000..b0ecadde --- /dev/null +++ b/src/jquery.js @@ -0,0 +1,5 @@ +/*! jQuery v1.12.4 | (c) jQuery Foundation | jquery.org/license */ +!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=a.document,e=c.slice,f=c.concat,g=c.push,h=c.indexOf,i={},j=i.toString,k=i.hasOwnProperty,l={},m="1.12.4",n=function(a,b){return new n.fn.init(a,b)},o=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype={jquery:m,constructor:n,selector:"",length:0,toArray:function(){return e.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:e.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a){return n.each(this,a)},map:function(a){return this.pushStack(n.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(e.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor()},push:g,sort:c.sort,splice:c.splice},n.extend=n.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||n.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(e=arguments[h]))for(d in e)a=g[d],c=e[d],g!==c&&(j&&c&&(n.isPlainObject(c)||(b=n.isArray(c)))?(b?(b=!1,f=a&&n.isArray(a)?a:[]):f=a&&n.isPlainObject(a)?a:{},g[d]=n.extend(j,f,c)):void 0!==c&&(g[d]=c));return g},n.extend({expando:"jQuery"+(m+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===n.type(a)},isArray:Array.isArray||function(a){return"array"===n.type(a)},isWindow:function(a){return null!=a&&a==a.window},isNumeric:function(a){var b=a&&a.toString();return!n.isArray(a)&&b-parseFloat(b)+1>=0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},isPlainObject:function(a){var b;if(!a||"object"!==n.type(a)||a.nodeType||n.isWindow(a))return!1;try{if(a.constructor&&!k.call(a,"constructor")&&!k.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}if(!l.ownFirst)for(b in a)return k.call(a,b);for(b in a);return void 0===b||k.call(a,b)},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?i[j.call(a)]||"object":typeof a},globalEval:function(b){b&&n.trim(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(p,"ms-").replace(q,r)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b){var c,d=0;if(s(a)){for(c=a.length;c>d;d++)if(b.call(a[d],d,a[d])===!1)break}else for(d in a)if(b.call(a[d],d,a[d])===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(o,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(s(Object(a))?n.merge(c,"string"==typeof a?[a]:a):g.call(c,a)),c},inArray:function(a,b,c){var d;if(b){if(h)return h.call(b,a,c);for(d=b.length,c=c?0>c?Math.max(0,d+c):c:0;d>c;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,b){var c=+b.length,d=0,e=a.length;while(c>d)a[e++]=b[d++];if(c!==c)while(void 0!==b[d])a[e++]=b[d++];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,e,g=0,h=[];if(s(a))for(d=a.length;d>g;g++)e=b(a[g],g,c),null!=e&&h.push(e);else for(g in a)e=b(a[g],g,c),null!=e&&h.push(e);return f.apply([],h)},guid:1,proxy:function(a,b){var c,d,f;return"string"==typeof b&&(f=a[b],b=a,a=f),n.isFunction(a)?(c=e.call(arguments,2),d=function(){return a.apply(b||this,c.concat(e.call(arguments)))},d.guid=a.guid=a.guid||n.guid++,d):void 0},now:function(){return+new Date},support:l}),"function"==typeof Symbol&&(n.fn[Symbol.iterator]=c[Symbol.iterator]),n.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(a,b){i["[object "+b+"]"]=b.toLowerCase()});function s(a){var b=!!a&&"length"in a&&a.length,c=n.type(a);return"function"===c||n.isWindow(a)?!1:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var t=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=ga(),z=ga(),A=ga(),B=function(a,b){return a===b&&(l=!0),0},C=1<<31,D={}.hasOwnProperty,E=[],F=E.pop,G=E.push,H=E.push,I=E.slice,J=function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},K="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",L="[\\x20\\t\\r\\n\\f]",M="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",N="\\["+L+"*("+M+")(?:"+L+"*([*^$|!~]?=)"+L+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+M+"))|)"+L+"*\\]",O=":("+M+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+N+")*)|.*)\\)|)",P=new RegExp(L+"+","g"),Q=new RegExp("^"+L+"+|((?:^|[^\\\\])(?:\\\\.)*)"+L+"+$","g"),R=new RegExp("^"+L+"*,"+L+"*"),S=new RegExp("^"+L+"*([>+~]|"+L+")"+L+"*"),T=new RegExp("="+L+"*([^\\]'\"]*?)"+L+"*\\]","g"),U=new RegExp(O),V=new RegExp("^"+M+"$"),W={ID:new RegExp("^#("+M+")"),CLASS:new RegExp("^\\.("+M+")"),TAG:new RegExp("^("+M+"|[*])"),ATTR:new RegExp("^"+N),PSEUDO:new RegExp("^"+O),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+L+"*(even|odd|(([+-]|)(\\d*)n|)"+L+"*(?:([+-]|)"+L+"*(\\d+)|))"+L+"*\\)|)","i"),bool:new RegExp("^(?:"+K+")$","i"),needsContext:new RegExp("^"+L+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+L+"*((?:-\\d)?\\d*)"+L+"*\\)|)(?=[^-]|$)","i")},X=/^(?:input|select|textarea|button)$/i,Y=/^h\d$/i,Z=/^[^{]+\{\s*\[native \w/,$=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,_=/[+~]/,aa=/'|\\/g,ba=new RegExp("\\\\([\\da-f]{1,6}"+L+"?|("+L+")|.)","ig"),ca=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)},da=function(){m()};try{H.apply(E=I.call(v.childNodes),v.childNodes),E[v.childNodes.length].nodeType}catch(ea){H={apply:E.length?function(a,b){G.apply(a,I.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function fa(a,b,d,e){var f,h,j,k,l,o,r,s,w=b&&b.ownerDocument,x=b?b.nodeType:9;if(d=d||[],"string"!=typeof a||!a||1!==x&&9!==x&&11!==x)return d;if(!e&&((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,p)){if(11!==x&&(o=$.exec(a)))if(f=o[1]){if(9===x){if(!(j=b.getElementById(f)))return d;if(j.id===f)return d.push(j),d}else if(w&&(j=w.getElementById(f))&&t(b,j)&&j.id===f)return d.push(j),d}else{if(o[2])return H.apply(d,b.getElementsByTagName(a)),d;if((f=o[3])&&c.getElementsByClassName&&b.getElementsByClassName)return H.apply(d,b.getElementsByClassName(f)),d}if(c.qsa&&!A[a+" "]&&(!q||!q.test(a))){if(1!==x)w=b,s=a;else if("object"!==b.nodeName.toLowerCase()){(k=b.getAttribute("id"))?k=k.replace(aa,"\\$&"):b.setAttribute("id",k=u),r=g(a),h=r.length,l=V.test(k)?"#"+k:"[id='"+k+"']";while(h--)r[h]=l+" "+qa(r[h]);s=r.join(","),w=_.test(a)&&oa(b.parentNode)||b}if(s)try{return H.apply(d,w.querySelectorAll(s)),d}catch(y){}finally{k===u&&b.removeAttribute("id")}}}return i(a.replace(Q,"$1"),b,d,e)}function ga(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function ha(a){return a[u]=!0,a}function ia(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function ja(a,b){var c=a.split("|"),e=c.length;while(e--)d.attrHandle[c[e]]=b}function ka(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||C)-(~a.sourceIndex||C);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function la(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function ma(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function na(a){return ha(function(b){return b=+b,ha(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function oa(a){return a&&"undefined"!=typeof a.getElementsByTagName&&a}c=fa.support={},f=fa.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=fa.setDocument=function(a){var b,e,g=a?a.ownerDocument||a:v;return g!==n&&9===g.nodeType&&g.documentElement?(n=g,o=n.documentElement,p=!f(n),(e=n.defaultView)&&e.top!==e&&(e.addEventListener?e.addEventListener("unload",da,!1):e.attachEvent&&e.attachEvent("onunload",da)),c.attributes=ia(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ia(function(a){return a.appendChild(n.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=Z.test(n.getElementsByClassName),c.getById=ia(function(a){return o.appendChild(a).id=u,!n.getElementsByName||!n.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c=b.getElementById(a);return c?[c]:[]}},d.filter.ID=function(a){var b=a.replace(ba,ca);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(ba,ca);return function(a){var c="undefined"!=typeof a.getAttributeNode&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return"undefined"!=typeof b.getElementsByTagName?b.getElementsByTagName(a):c.qsa?b.querySelectorAll(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return"undefined"!=typeof b.getElementsByClassName&&p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=Z.test(n.querySelectorAll))&&(ia(function(a){o.appendChild(a).innerHTML="",a.querySelectorAll("[msallowcapture^='']").length&&q.push("[*^$]="+L+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+L+"*(?:value|"+K+")"),a.querySelectorAll("[id~="+u+"-]").length||q.push("~="),a.querySelectorAll(":checked").length||q.push(":checked"),a.querySelectorAll("a#"+u+"+*").length||q.push(".#.+[+~]")}),ia(function(a){var b=n.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+L+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=Z.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ia(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",O)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=Z.test(o.compareDocumentPosition),t=b||Z.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===n||a.ownerDocument===v&&t(v,a)?-1:b===n||b.ownerDocument===v&&t(v,b)?1:k?J(k,a)-J(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,e=a.parentNode,f=b.parentNode,g=[a],h=[b];if(!e||!f)return a===n?-1:b===n?1:e?-1:f?1:k?J(k,a)-J(k,b):0;if(e===f)return ka(a,b);c=a;while(c=c.parentNode)g.unshift(c);c=b;while(c=c.parentNode)h.unshift(c);while(g[d]===h[d])d++;return d?ka(g[d],h[d]):g[d]===v?-1:h[d]===v?1:0},n):n},fa.matches=function(a,b){return fa(a,null,null,b)},fa.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(T,"='$1']"),c.matchesSelector&&p&&!A[b+" "]&&(!r||!r.test(b))&&(!q||!q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return fa(b,n,null,[a]).length>0},fa.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},fa.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&D.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},fa.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},fa.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=fa.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=fa.selectors={cacheLength:50,createPseudo:ha,match:W,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(ba,ca),a[3]=(a[3]||a[4]||a[5]||"").replace(ba,ca),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||fa.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&fa.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return W.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&U.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(ba,ca).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+L+")"+a+"("+L+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||"undefined"!=typeof a.getAttribute&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=fa.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e.replace(P," ")+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h,t=!1;if(q){if(f){while(p){m=b;while(m=m[p])if(h?m.nodeName.toLowerCase()===r:1===m.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){m=q,l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),j=k[a]||[],n=j[0]===w&&j[1],t=n&&j[2],m=n&&q.childNodes[n];while(m=++n&&m&&m[p]||(t=n=0)||o.pop())if(1===m.nodeType&&++t&&m===b){k[a]=[w,n,t];break}}else if(s&&(m=b,l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),j=k[a]||[],n=j[0]===w&&j[1],t=n),t===!1)while(m=++n&&m&&m[p]||(t=n=0)||o.pop())if((h?m.nodeName.toLowerCase()===r:1===m.nodeType)&&++t&&(s&&(l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),k[a]=[w,t]),m===b))break;return t-=e,t===d||t%d===0&&t/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||fa.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?ha(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=J(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:ha(function(a){var b=[],c=[],d=h(a.replace(Q,"$1"));return d[u]?ha(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),b[0]=null,!c.pop()}}),has:ha(function(a){return function(b){return fa(a,b).length>0}}),contains:ha(function(a){return a=a.replace(ba,ca),function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:ha(function(a){return V.test(a||"")||fa.error("unsupported lang: "+a),a=a.replace(ba,ca).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Y.test(a.nodeName)},input:function(a){return X.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:na(function(){return[0]}),last:na(function(a,b){return[b-1]}),eq:na(function(a,b,c){return[0>c?c+b:c]}),even:na(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:na(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:na(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:na(function(a,b,c){for(var d=0>c?c+b:c;++db;b++)d+=a[b].value;return d}function ra(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j,k=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(j=b[u]||(b[u]={}),i=j[b.uniqueID]||(j[b.uniqueID]={}),(h=i[d])&&h[0]===w&&h[1]===f)return k[2]=h[2];if(i[d]=k,k[2]=a(b,c,g))return!0}}}function sa(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function ta(a,b,c){for(var d=0,e=b.length;e>d;d++)fa(a,b[d],c);return c}function ua(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(c&&!c(f,d,e)||(g.push(f),j&&b.push(h)));return g}function va(a,b,c,d,e,f){return d&&!d[u]&&(d=va(d)),e&&!e[u]&&(e=va(e,f)),ha(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||ta(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:ua(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=ua(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?J(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=ua(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):H.apply(g,r)})}function wa(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=ra(function(a){return a===b},h,!0),l=ra(function(a){return J(b,a)>-1},h,!0),m=[function(a,c,d){var e=!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d));return b=null,e}];f>i;i++)if(c=d.relative[a[i].type])m=[ra(sa(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return va(i>1&&sa(m),i>1&&qa(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(Q,"$1"),c,e>i&&wa(a.slice(i,e)),f>e&&wa(a=a.slice(e)),f>e&&qa(a))}m.push(c)}return sa(m)}function xa(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,o,q,r=0,s="0",t=f&&[],u=[],v=j,x=f||e&&d.find.TAG("*",k),y=w+=null==v?1:Math.random()||.1,z=x.length;for(k&&(j=g===n||g||k);s!==z&&null!=(l=x[s]);s++){if(e&&l){o=0,g||l.ownerDocument===n||(m(l),h=!p);while(q=a[o++])if(q(l,g||n,h)){i.push(l);break}k&&(w=y)}c&&((l=!q&&l)&&r--,f&&t.push(l))}if(r+=s,c&&s!==r){o=0;while(q=b[o++])q(t,u,g,h);if(f){if(r>0)while(s--)t[s]||u[s]||(u[s]=F.call(i));u=ua(u)}H.apply(i,u),k&&!f&&u.length>0&&r+b.length>1&&fa.uniqueSort(i)}return k&&(w=y,j=v),t};return c?ha(f):f}return h=fa.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=wa(b[c]),f[u]?d.push(f):e.push(f);f=A(a,xa(e,d)),f.selector=a}return f},i=fa.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(ba,ca),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=W.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(ba,ca),_.test(j[0].type)&&oa(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&qa(j),!a)return H.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,!b||_.test(a)&&oa(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ia(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),ia(function(a){return a.innerHTML="","#"===a.firstChild.getAttribute("href")})||ja("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ia(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||ja("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),ia(function(a){return null==a.getAttribute("disabled")})||ja(K,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),fa}(a);n.find=t,n.expr=t.selectors,n.expr[":"]=n.expr.pseudos,n.uniqueSort=n.unique=t.uniqueSort,n.text=t.getText,n.isXMLDoc=t.isXML,n.contains=t.contains;var u=function(a,b,c){var d=[],e=void 0!==c;while((a=a[b])&&9!==a.nodeType)if(1===a.nodeType){if(e&&n(a).is(c))break;d.push(a)}return d},v=function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c},w=n.expr.match.needsContext,x=/^<([\w-]+)\s*\/?>(?:<\/\1>|)$/,y=/^.[^:#\[\.,]*$/;function z(a,b,c){if(n.isFunction(b))return n.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return n.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(y.test(b))return n.filter(b,a,c);b=n.filter(b,a)}return n.grep(a,function(a){return n.inArray(a,b)>-1!==c})}n.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?n.find.matchesSelector(d,a)?[d]:[]:n.find.matches(a,n.grep(b,function(a){return 1===a.nodeType}))},n.fn.extend({find:function(a){var b,c=[],d=this,e=d.length;if("string"!=typeof a)return this.pushStack(n(a).filter(function(){for(b=0;e>b;b++)if(n.contains(d[b],this))return!0}));for(b=0;e>b;b++)n.find(a,d[b],c);return c=this.pushStack(e>1?n.unique(c):c),c.selector=this.selector?this.selector+" "+a:a,c},filter:function(a){return this.pushStack(z(this,a||[],!1))},not:function(a){return this.pushStack(z(this,a||[],!0))},is:function(a){return!!z(this,"string"==typeof a&&w.test(a)?n(a):a||[],!1).length}});var A,B=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,C=n.fn.init=function(a,b,c){var e,f;if(!a)return this;if(c=c||A,"string"==typeof a){if(e="<"===a.charAt(0)&&">"===a.charAt(a.length-1)&&a.length>=3?[null,a,null]:B.exec(a),!e||!e[1]&&b)return!b||b.jquery?(b||c).find(a):this.constructor(b).find(a);if(e[1]){if(b=b instanceof n?b[0]:b,n.merge(this,n.parseHTML(e[1],b&&b.nodeType?b.ownerDocument||b:d,!0)),x.test(e[1])&&n.isPlainObject(b))for(e in b)n.isFunction(this[e])?this[e](b[e]):this.attr(e,b[e]);return this}if(f=d.getElementById(e[2]),f&&f.parentNode){if(f.id!==e[2])return A.find(a);this.length=1,this[0]=f}return this.context=d,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):n.isFunction(a)?"undefined"!=typeof c.ready?c.ready(a):a(n):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),n.makeArray(a,this))};C.prototype=n.fn,A=n(d);var D=/^(?:parents|prev(?:Until|All))/,E={children:!0,contents:!0,next:!0,prev:!0};n.fn.extend({has:function(a){var b,c=n(a,this),d=c.length;return this.filter(function(){for(b=0;d>b;b++)if(n.contains(this,c[b]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=w.test(a)||"string"!=typeof a?n(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&n.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?n.uniqueSort(f):f)},index:function(a){return a?"string"==typeof a?n.inArray(this[0],n(a)):n.inArray(a.jquery?a[0]:a,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(n.uniqueSort(n.merge(this.get(),n(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function F(a,b){do a=a[b];while(a&&1!==a.nodeType);return a}n.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return u(a,"parentNode")},parentsUntil:function(a,b,c){return u(a,"parentNode",c)},next:function(a){return F(a,"nextSibling")},prev:function(a){return F(a,"previousSibling")},nextAll:function(a){return u(a,"nextSibling")},prevAll:function(a){return u(a,"previousSibling")},nextUntil:function(a,b,c){return u(a,"nextSibling",c)},prevUntil:function(a,b,c){return u(a,"previousSibling",c)},siblings:function(a){return v((a.parentNode||{}).firstChild,a)},children:function(a){return v(a.firstChild)},contents:function(a){return n.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:n.merge([],a.childNodes)}},function(a,b){n.fn[a]=function(c,d){var e=n.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=n.filter(d,e)),this.length>1&&(E[a]||(e=n.uniqueSort(e)),D.test(a)&&(e=e.reverse())),this.pushStack(e)}});var G=/\S+/g;function H(a){var b={};return n.each(a.match(G)||[],function(a,c){b[c]=!0}),b}n.Callbacks=function(a){a="string"==typeof a?H(a):n.extend({},a);var b,c,d,e,f=[],g=[],h=-1,i=function(){for(e=a.once,d=b=!0;g.length;h=-1){c=g.shift();while(++h-1)f.splice(c,1),h>=c&&h--}),this},has:function(a){return a?n.inArray(a,f)>-1:f.length>0},empty:function(){return f&&(f=[]),this},disable:function(){return e=g=[],f=c="",this},disabled:function(){return!f},lock:function(){return e=!0,c||j.disable(),this},locked:function(){return!!e},fireWith:function(a,c){return e||(c=c||[],c=[a,c.slice?c.slice():c],g.push(c),b||i()),this},fire:function(){return j.fireWith(this,arguments),this},fired:function(){return!!d}};return j},n.extend({Deferred:function(a){var b=[["resolve","done",n.Callbacks("once memory"),"resolved"],["reject","fail",n.Callbacks("once memory"),"rejected"],["notify","progress",n.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return n.Deferred(function(c){n.each(b,function(b,f){var g=n.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&n.isFunction(a.promise)?a.promise().progress(c.notify).done(c.resolve).fail(c.reject):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?n.extend(a,d):d}},e={};return d.pipe=d.then,n.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=e.call(arguments),d=c.length,f=1!==d||a&&n.isFunction(a.promise)?d:0,g=1===f?a:n.Deferred(),h=function(a,b,c){return function(d){b[a]=this,c[a]=arguments.length>1?e.call(arguments):d,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(d>1)for(i=new Array(d),j=new Array(d),k=new Array(d);d>b;b++)c[b]&&n.isFunction(c[b].promise)?c[b].promise().progress(h(b,j,i)).done(h(b,k,c)).fail(g.reject):--f;return f||g.resolveWith(k,c),g.promise()}});var I;n.fn.ready=function(a){return n.ready.promise().done(a),this},n.extend({isReady:!1,readyWait:1,holdReady:function(a){a?n.readyWait++:n.ready(!0)},ready:function(a){(a===!0?--n.readyWait:n.isReady)||(n.isReady=!0,a!==!0&&--n.readyWait>0||(I.resolveWith(d,[n]),n.fn.triggerHandler&&(n(d).triggerHandler("ready"),n(d).off("ready"))))}});function J(){d.addEventListener?(d.removeEventListener("DOMContentLoaded",K),a.removeEventListener("load",K)):(d.detachEvent("onreadystatechange",K),a.detachEvent("onload",K))}function K(){(d.addEventListener||"load"===a.event.type||"complete"===d.readyState)&&(J(),n.ready())}n.ready.promise=function(b){if(!I)if(I=n.Deferred(),"complete"===d.readyState||"loading"!==d.readyState&&!d.documentElement.doScroll)a.setTimeout(n.ready);else if(d.addEventListener)d.addEventListener("DOMContentLoaded",K),a.addEventListener("load",K);else{d.attachEvent("onreadystatechange",K),a.attachEvent("onload",K);var c=!1;try{c=null==a.frameElement&&d.documentElement}catch(e){}c&&c.doScroll&&!function f(){if(!n.isReady){try{c.doScroll("left")}catch(b){return a.setTimeout(f,50)}J(),n.ready()}}()}return I.promise(b)},n.ready.promise();var L;for(L in n(l))break;l.ownFirst="0"===L,l.inlineBlockNeedsLayout=!1,n(function(){var a,b,c,e;c=d.getElementsByTagName("body")[0],c&&c.style&&(b=d.createElement("div"),e=d.createElement("div"),e.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",c.appendChild(e).appendChild(b),"undefined"!=typeof b.style.zoom&&(b.style.cssText="display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1",l.inlineBlockNeedsLayout=a=3===b.offsetWidth,a&&(c.style.zoom=1)),c.removeChild(e))}),function(){var a=d.createElement("div");l.deleteExpando=!0;try{delete a.test}catch(b){l.deleteExpando=!1}a=null}();var M=function(a){var b=n.noData[(a.nodeName+" ").toLowerCase()],c=+a.nodeType||1;return 1!==c&&9!==c?!1:!b||b!==!0&&a.getAttribute("classid")===b},N=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,O=/([A-Z])/g;function P(a,b,c){if(void 0===c&&1===a.nodeType){var d="data-"+b.replace(O,"-$1").toLowerCase();if(c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:N.test(c)?n.parseJSON(c):c}catch(e){}n.data(a,b,c)}else c=void 0; +}return c}function Q(a){var b;for(b in a)if(("data"!==b||!n.isEmptyObject(a[b]))&&"toJSON"!==b)return!1;return!0}function R(a,b,d,e){if(M(a)){var f,g,h=n.expando,i=a.nodeType,j=i?n.cache:a,k=i?a[h]:a[h]&&h;if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return k||(k=i?a[h]=c.pop()||n.guid++:h),j[k]||(j[k]=i?{}:{toJSON:n.noop}),"object"!=typeof b&&"function"!=typeof b||(e?j[k]=n.extend(j[k],b):j[k].data=n.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void 0!==d&&(g[n.camelCase(b)]=d),"string"==typeof b?(f=g[b],null==f&&(f=g[n.camelCase(b)])):f=g,f}}function S(a,b,c){if(M(a)){var d,e,f=a.nodeType,g=f?n.cache:a,h=f?a[n.expando]:n.expando;if(g[h]){if(b&&(d=c?g[h]:g[h].data)){n.isArray(b)?b=b.concat(n.map(b,n.camelCase)):b in d?b=[b]:(b=n.camelCase(b),b=b in d?[b]:b.split(" ")),e=b.length;while(e--)delete d[b[e]];if(c?!Q(d):!n.isEmptyObject(d))return}(c||(delete g[h].data,Q(g[h])))&&(f?n.cleanData([a],!0):l.deleteExpando||g!=g.window?delete g[h]:g[h]=void 0)}}}n.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(a){return a=a.nodeType?n.cache[a[n.expando]]:a[n.expando],!!a&&!Q(a)},data:function(a,b,c){return R(a,b,c)},removeData:function(a,b){return S(a,b)},_data:function(a,b,c){return R(a,b,c,!0)},_removeData:function(a,b){return S(a,b,!0)}}),n.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=n.data(f),1===f.nodeType&&!n._data(f,"parsedAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=n.camelCase(d.slice(5)),P(f,d,e[d])));n._data(f,"parsedAttrs",!0)}return e}return"object"==typeof a?this.each(function(){n.data(this,a)}):arguments.length>1?this.each(function(){n.data(this,a,b)}):f?P(f,a,n.data(f,a)):void 0},removeData:function(a){return this.each(function(){n.removeData(this,a)})}}),n.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=n._data(a,b),c&&(!d||n.isArray(c)?d=n._data(a,b,n.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=n.queue(a,b),d=c.length,e=c.shift(),f=n._queueHooks(a,b),g=function(){n.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return n._data(a,c)||n._data(a,c,{empty:n.Callbacks("once memory").add(function(){n._removeData(a,b+"queue"),n._removeData(a,c)})})}}),n.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.lengthh;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},Z=/^(?:checkbox|radio)$/i,$=/<([\w:-]+)/,_=/^$|\/(?:java|ecma)script/i,aa=/^\s+/,ba="abbr|article|aside|audio|bdi|canvas|data|datalist|details|dialog|figcaption|figure|footer|header|hgroup|main|mark|meter|nav|output|picture|progress|section|summary|template|time|video";function ca(a){var b=ba.split("|"),c=a.createDocumentFragment();if(c.createElement)while(b.length)c.createElement(b.pop());return c}!function(){var a=d.createElement("div"),b=d.createDocumentFragment(),c=d.createElement("input");a.innerHTML="
a",l.leadingWhitespace=3===a.firstChild.nodeType,l.tbody=!a.getElementsByTagName("tbody").length,l.htmlSerialize=!!a.getElementsByTagName("link").length,l.html5Clone="<:nav>"!==d.createElement("nav").cloneNode(!0).outerHTML,c.type="checkbox",c.checked=!0,b.appendChild(c),l.appendChecked=c.checked,a.innerHTML="",l.noCloneChecked=!!a.cloneNode(!0).lastChild.defaultValue,b.appendChild(a),c=d.createElement("input"),c.setAttribute("type","radio"),c.setAttribute("checked","checked"),c.setAttribute("name","t"),a.appendChild(c),l.checkClone=a.cloneNode(!0).cloneNode(!0).lastChild.checked,l.noCloneEvent=!!a.addEventListener,a[n.expando]=1,l.attributes=!a.getAttribute(n.expando)}();var da={option:[1,""],legend:[1,"
","
"],area:[1,"",""],param:[1,"",""],thead:[1,"","
"],tr:[2,"","
"],col:[2,"","
"],td:[3,"","
"],_default:l.htmlSerialize?[0,"",""]:[1,"X
","
"]};da.optgroup=da.option,da.tbody=da.tfoot=da.colgroup=da.caption=da.thead,da.th=da.td;function ea(a,b){var c,d,e=0,f="undefined"!=typeof a.getElementsByTagName?a.getElementsByTagName(b||"*"):"undefined"!=typeof a.querySelectorAll?a.querySelectorAll(b||"*"):void 0;if(!f)for(f=[],c=a.childNodes||a;null!=(d=c[e]);e++)!b||n.nodeName(d,b)?f.push(d):n.merge(f,ea(d,b));return void 0===b||b&&n.nodeName(a,b)?n.merge([a],f):f}function fa(a,b){for(var c,d=0;null!=(c=a[d]);d++)n._data(c,"globalEval",!b||n._data(b[d],"globalEval"))}var ga=/<|&#?\w+;/,ha=/r;r++)if(g=a[r],g||0===g)if("object"===n.type(g))n.merge(q,g.nodeType?[g]:g);else if(ga.test(g)){i=i||p.appendChild(b.createElement("div")),j=($.exec(g)||["",""])[1].toLowerCase(),m=da[j]||da._default,i.innerHTML=m[1]+n.htmlPrefilter(g)+m[2],f=m[0];while(f--)i=i.lastChild;if(!l.leadingWhitespace&&aa.test(g)&&q.push(b.createTextNode(aa.exec(g)[0])),!l.tbody){g="table"!==j||ha.test(g)?""!==m[1]||ha.test(g)?0:i:i.firstChild,f=g&&g.childNodes.length;while(f--)n.nodeName(k=g.childNodes[f],"tbody")&&!k.childNodes.length&&g.removeChild(k)}n.merge(q,i.childNodes),i.textContent="";while(i.firstChild)i.removeChild(i.firstChild);i=p.lastChild}else q.push(b.createTextNode(g));i&&p.removeChild(i),l.appendChecked||n.grep(ea(q,"input"),ia),r=0;while(g=q[r++])if(d&&n.inArray(g,d)>-1)e&&e.push(g);else if(h=n.contains(g.ownerDocument,g),i=ea(p.appendChild(g),"script"),h&&fa(i),c){f=0;while(g=i[f++])_.test(g.type||"")&&c.push(g)}return i=null,p}!function(){var b,c,e=d.createElement("div");for(b in{submit:!0,change:!0,focusin:!0})c="on"+b,(l[b]=c in a)||(e.setAttribute(c,"t"),l[b]=e.attributes[c].expando===!1);e=null}();var ka=/^(?:input|select|textarea)$/i,la=/^key/,ma=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,na=/^(?:focusinfocus|focusoutblur)$/,oa=/^([^.]*)(?:\.(.+)|)/;function pa(){return!0}function qa(){return!1}function ra(){try{return d.activeElement}catch(a){}}function sa(a,b,c,d,e,f){var g,h;if("object"==typeof b){"string"!=typeof c&&(d=d||c,c=void 0);for(h in b)sa(a,h,c,d,b[h],f);return a}if(null==d&&null==e?(e=c,d=c=void 0):null==e&&("string"==typeof c?(e=d,d=void 0):(e=d,d=c,c=void 0)),e===!1)e=qa;else if(!e)return a;return 1===f&&(g=e,e=function(a){return n().off(a),g.apply(this,arguments)},e.guid=g.guid||(g.guid=n.guid++)),a.each(function(){n.event.add(this,b,e,d,c)})}n.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=n._data(a);if(r){c.handler&&(i=c,c=i.handler,e=i.selector),c.guid||(c.guid=n.guid++),(g=r.events)||(g=r.events={}),(k=r.handle)||(k=r.handle=function(a){return"undefined"==typeof n||a&&n.event.triggered===a.type?void 0:n.event.dispatch.apply(k.elem,arguments)},k.elem=a),b=(b||"").match(G)||[""],h=b.length;while(h--)f=oa.exec(b[h])||[],o=q=f[1],p=(f[2]||"").split(".").sort(),o&&(j=n.event.special[o]||{},o=(e?j.delegateType:j.bindType)||o,j=n.event.special[o]||{},l=n.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&n.expr.match.needsContext.test(e),namespace:p.join(".")},i),(m=g[o])||(m=g[o]=[],m.delegateCount=0,j.setup&&j.setup.call(a,d,p,k)!==!1||(a.addEventListener?a.addEventListener(o,k,!1):a.attachEvent&&a.attachEvent("on"+o,k))),j.add&&(j.add.call(a,l),l.handler.guid||(l.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,l):m.push(l),n.event.global[o]=!0);a=null}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=n.hasData(a)&&n._data(a);if(r&&(k=r.events)){b=(b||"").match(G)||[""],j=b.length;while(j--)if(h=oa.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=n.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,m=k[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),i=f=m.length;while(f--)g=m[f],!e&&q!==g.origType||c&&c.guid!==g.guid||h&&!h.test(g.namespace)||d&&d!==g.selector&&("**"!==d||!g.selector)||(m.splice(f,1),g.selector&&m.delegateCount--,l.remove&&l.remove.call(a,g));i&&!m.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||n.removeEvent(a,o,r.handle),delete k[o])}else for(o in k)n.event.remove(a,o+b[j],c,d,!0);n.isEmptyObject(k)&&(delete r.handle,n._removeData(a,"events"))}},trigger:function(b,c,e,f){var g,h,i,j,l,m,o,p=[e||d],q=k.call(b,"type")?b.type:b,r=k.call(b,"namespace")?b.namespace.split("."):[];if(i=m=e=e||d,3!==e.nodeType&&8!==e.nodeType&&!na.test(q+n.event.triggered)&&(q.indexOf(".")>-1&&(r=q.split("."),q=r.shift(),r.sort()),h=q.indexOf(":")<0&&"on"+q,b=b[n.expando]?b:new n.Event(q,"object"==typeof b&&b),b.isTrigger=f?2:3,b.namespace=r.join("."),b.rnamespace=b.namespace?new RegExp("(^|\\.)"+r.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=e),c=null==c?[b]:n.makeArray(c,[b]),l=n.event.special[q]||{},f||!l.trigger||l.trigger.apply(e,c)!==!1)){if(!f&&!l.noBubble&&!n.isWindow(e)){for(j=l.delegateType||q,na.test(j+q)||(i=i.parentNode);i;i=i.parentNode)p.push(i),m=i;m===(e.ownerDocument||d)&&p.push(m.defaultView||m.parentWindow||a)}o=0;while((i=p[o++])&&!b.isPropagationStopped())b.type=o>1?j:l.bindType||q,g=(n._data(i,"events")||{})[b.type]&&n._data(i,"handle"),g&&g.apply(i,c),g=h&&i[h],g&&g.apply&&M(i)&&(b.result=g.apply(i,c),b.result===!1&&b.preventDefault());if(b.type=q,!f&&!b.isDefaultPrevented()&&(!l._default||l._default.apply(p.pop(),c)===!1)&&M(e)&&h&&e[q]&&!n.isWindow(e)){m=e[h],m&&(e[h]=null),n.event.triggered=q;try{e[q]()}catch(s){}n.event.triggered=void 0,m&&(e[h]=m)}return b.result}},dispatch:function(a){a=n.event.fix(a);var b,c,d,f,g,h=[],i=e.call(arguments),j=(n._data(this,"events")||{})[a.type]||[],k=n.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=n.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,c=0;while((g=f.handlers[c++])&&!a.isImmediatePropagationStopped())a.rnamespace&&!a.rnamespace.test(g.namespace)||(a.handleObj=g,a.data=g.data,d=((n.event.special[g.origType]||{}).handle||g.handler).apply(f.elem,i),void 0!==d&&(a.result=d)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&("click"!==a.type||isNaN(a.button)||a.button<1))for(;i!=this;i=i.parentNode||this)if(1===i.nodeType&&(i.disabled!==!0||"click"!==a.type)){for(d=[],c=0;h>c;c++)f=b[c],e=f.selector+" ",void 0===d[e]&&(d[e]=f.needsContext?n(e,this).index(i)>-1:n.find(e,this,null,[i]).length),d[e]&&d.push(f);d.length&&g.push({elem:i,handlers:d})}return h]","i"),va=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi,wa=/\s*$/g,Aa=ca(d),Ba=Aa.appendChild(d.createElement("div"));function Ca(a,b){return n.nodeName(a,"table")&&n.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function Da(a){return a.type=(null!==n.find.attr(a,"type"))+"/"+a.type,a}function Ea(a){var b=ya.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function Fa(a,b){if(1===b.nodeType&&n.hasData(a)){var c,d,e,f=n._data(a),g=n._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;e>d;d++)n.event.add(b,c,h[c][d])}g.data&&(g.data=n.extend({},g.data))}}function Ga(a,b){var c,d,e;if(1===b.nodeType){if(c=b.nodeName.toLowerCase(),!l.noCloneEvent&&b[n.expando]){e=n._data(b);for(d in e.events)n.removeEvent(b,d,e.handle);b.removeAttribute(n.expando)}"script"===c&&b.text!==a.text?(Da(b).text=a.text,Ea(b)):"object"===c?(b.parentNode&&(b.outerHTML=a.outerHTML),l.html5Clone&&a.innerHTML&&!n.trim(b.innerHTML)&&(b.innerHTML=a.innerHTML)):"input"===c&&Z.test(a.type)?(b.defaultChecked=b.checked=a.checked,b.value!==a.value&&(b.value=a.value)):"option"===c?b.defaultSelected=b.selected=a.defaultSelected:"input"!==c&&"textarea"!==c||(b.defaultValue=a.defaultValue)}}function Ha(a,b,c,d){b=f.apply([],b);var e,g,h,i,j,k,m=0,o=a.length,p=o-1,q=b[0],r=n.isFunction(q);if(r||o>1&&"string"==typeof q&&!l.checkClone&&xa.test(q))return a.each(function(e){var f=a.eq(e);r&&(b[0]=q.call(this,e,f.html())),Ha(f,b,c,d)});if(o&&(k=ja(b,a[0].ownerDocument,!1,a,d),e=k.firstChild,1===k.childNodes.length&&(k=e),e||d)){for(i=n.map(ea(k,"script"),Da),h=i.length;o>m;m++)g=k,m!==p&&(g=n.clone(g,!0,!0),h&&n.merge(i,ea(g,"script"))),c.call(a[m],g,m);if(h)for(j=i[i.length-1].ownerDocument,n.map(i,Ea),m=0;h>m;m++)g=i[m],_.test(g.type||"")&&!n._data(g,"globalEval")&&n.contains(j,g)&&(g.src?n._evalUrl&&n._evalUrl(g.src):n.globalEval((g.text||g.textContent||g.innerHTML||"").replace(za,"")));k=e=null}return a}function Ia(a,b,c){for(var d,e=b?n.filter(b,a):a,f=0;null!=(d=e[f]);f++)c||1!==d.nodeType||n.cleanData(ea(d)),d.parentNode&&(c&&n.contains(d.ownerDocument,d)&&fa(ea(d,"script")),d.parentNode.removeChild(d));return a}n.extend({htmlPrefilter:function(a){return a.replace(va,"<$1>")},clone:function(a,b,c){var d,e,f,g,h,i=n.contains(a.ownerDocument,a);if(l.html5Clone||n.isXMLDoc(a)||!ua.test("<"+a.nodeName+">")?f=a.cloneNode(!0):(Ba.innerHTML=a.outerHTML,Ba.removeChild(f=Ba.firstChild)),!(l.noCloneEvent&&l.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||n.isXMLDoc(a)))for(d=ea(f),h=ea(a),g=0;null!=(e=h[g]);++g)d[g]&&Ga(e,d[g]);if(b)if(c)for(h=h||ea(a),d=d||ea(f),g=0;null!=(e=h[g]);g++)Fa(e,d[g]);else Fa(a,f);return d=ea(f,"script"),d.length>0&&fa(d,!i&&ea(a,"script")),d=h=e=null,f},cleanData:function(a,b){for(var d,e,f,g,h=0,i=n.expando,j=n.cache,k=l.attributes,m=n.event.special;null!=(d=a[h]);h++)if((b||M(d))&&(f=d[i],g=f&&j[f])){if(g.events)for(e in g.events)m[e]?n.event.remove(d,e):n.removeEvent(d,e,g.handle);j[f]&&(delete j[f],k||"undefined"==typeof d.removeAttribute?d[i]=void 0:d.removeAttribute(i),c.push(f))}}}),n.fn.extend({domManip:Ha,detach:function(a){return Ia(this,a,!0)},remove:function(a){return Ia(this,a)},text:function(a){return Y(this,function(a){return void 0===a?n.text(this):this.empty().append((this[0]&&this[0].ownerDocument||d).createTextNode(a))},null,a,arguments.length)},append:function(){return Ha(this,arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=Ca(this,a);b.appendChild(a)}})},prepend:function(){return Ha(this,arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=Ca(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return Ha(this,arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return Ha(this,arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},empty:function(){for(var a,b=0;null!=(a=this[b]);b++){1===a.nodeType&&n.cleanData(ea(a,!1));while(a.firstChild)a.removeChild(a.firstChild);a.options&&n.nodeName(a,"select")&&(a.options.length=0)}return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return n.clone(this,a,b)})},html:function(a){return Y(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a)return 1===b.nodeType?b.innerHTML.replace(ta,""):void 0;if("string"==typeof a&&!wa.test(a)&&(l.htmlSerialize||!ua.test(a))&&(l.leadingWhitespace||!aa.test(a))&&!da[($.exec(a)||["",""])[1].toLowerCase()]){a=n.htmlPrefilter(a);try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(n.cleanData(ea(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=[];return Ha(this,arguments,function(b){var c=this.parentNode;n.inArray(this,a)<0&&(n.cleanData(ea(this)),c&&c.replaceChild(b,this))},a)}}),n.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){n.fn[a]=function(a){for(var c,d=0,e=[],f=n(a),h=f.length-1;h>=d;d++)c=d===h?this:this.clone(!0),n(f[d])[b](c),g.apply(e,c.get());return this.pushStack(e)}});var Ja,Ka={HTML:"block",BODY:"block"};function La(a,b){var c=n(b.createElement(a)).appendTo(b.body),d=n.css(c[0],"display");return c.detach(),d}function Ma(a){var b=d,c=Ka[a];return c||(c=La(a,b),"none"!==c&&c||(Ja=(Ja||n("