(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
"use strict";var _message=require(7),_retailerMode=require(5),_dom=require(3),_utils=require(4),_wowPage=require(8),openRetailerWindowDiv="open-retailer-window-div",openRetailerWindowBtn="open-retailer-window-btn",loginBox=(0,_dom.$)("#J_LoginBox")||"",userNameSelector=".user-name",MutationObserver=window.MutationObserver,mo=new MutationObserver(function(){function e(e,n){var o=(0,_dom.$$)(userNameSelector)[n].parentNode;o.appendChild(t()),o.querySelector("."+openRetailerWindowBtn).addEventListener("click",function(){var t=location.href;(0,_wowPage.wowLog)("5.10.1.1.22",{title:e}),(0,_dom.$$)(".user-pic")[n].click(),(0,_message.sendMessageAsync)(_retailerMode.MSG_EVENT_OPEN_NEW_RETAILER_WINDOW,{userName:e,redirectUrl:t}).then(function(e){var t=(0,_dom.$)("#J_SubmitQuick"),n=(0,_dom.$)("#J_SubmitMiser");e&&(t.getBoundingClientRect().width>0?t.click():n.getBoundingClientRect().width>0&&n.click())})})}function t(){var e=document.createElement("div");return e.classList.add(openRetailerWindowDiv),e.innerHTML='<button type="button" class='+openRetailerWindowBtn+">\n                      "+chrome.i18n.getMessage("open_retailer_window_btn")+"\n                    </button>",e}var n=(0,_dom.$$)(userNameSelector);mo.disconnect(),(0,_message.sendMessageAsync)(_retailerMode.MSG_EVENT_CAN_OPEN_NEW_RETAILER_WINDOW,{userNames:n.map(function(e){return e.textContent})}).then(function(t){(0,_utils.forEach)(t,function(t,n){t.support&&e(n,t.index)})})});loginBox&&mo.observe(loginBox,{childList:!0,characterData:!0,attributes:!0});


},{"3":3,"4":4,"5":5,"7":7,"8":8}],2:[function(require,module,exports){
"use strict";function defer(){var e=void 0,r=void 0,n=new Promise(function(n,o){e=n,r=o});return{resolve:function(r){e(r)},reject:function(e){r(e)},promise:n}}exports.defer=defer;


},{}],3:[function(require,module,exports){
"use strict";function $(e,o){return e instanceof HTMLElement?e:(o||document).querySelector(e)}function _$(e,o){return(o||document).shadowRoot.querySelector(e)}function _$$(e,o){return slice.call((o||document).shadowRoot.querySelectorAll(e))}function $$(e,o){return slice.call((o||document).querySelectorAll(e))}function toggleClass(e,o,t){var r=2==arguments.length?e.classList.contains(o):!t;e.classList[r?"remove":"add"](o)}function removeNodeFromParent(e){return e&&e.parentNode?(e.parentNode.removeChild(e),!0):!1}exports.$=$,exports._$=_$,exports._$$=_$$,exports.$$=$$,exports.toggleClass=toggleClass,exports.removeNodeFromParent=removeNodeFromParent;var slice=Array.prototype.slice;


},{}],4:[function(require,module,exports){
"use strict";function forEach(r,t,n){if(isObj(r))if(void 0===n&&(n=r),r instanceof Array||r.hasOwnProperty("length"))for(var e=0,o=r.length;o>e;e++)t.call(n,r[e],e);else for(var i in r)r.hasOwnProperty(i)&&t.call(n,r[i],i);return r}function arrAdd(r,t,n){return-1==r.indexOf(t)?(r[n?"unshift":"push"](t),!0):void 0}function arrFind(r,t){var n=0,e=!0,o=!1,i=void 0;try{for(var a,s=r[Symbol.iterator]();!(e=(a=s.next()).done);e=!0){var f=a.value;if(t(f,n++))return f}}catch(u){o=!0,i=u}finally{try{!e&&s["return"]&&s["return"]()}finally{if(o)throw i}}}function arrFirst(r,t){var n=0,e=!0,o=!1,i=void 0;try{for(var a,s=r[Symbol.iterator]();!(e=(a=s.next()).done);e=!0){var f=a.value,u=t(f,n++);if(u)return u}}catch(c){o=!0,i=c}finally{try{!e&&s["return"]&&s["return"]()}finally{if(o)throw i}}}function arrRemove(r,t){var n=r.indexOf(t);return n>-1&&r.splice(n,1),-1!=n}function arrFilterMappedResult(r,t,n){var e=[],o=void 0;return forEach(r,function(r,n){(o=t.call(this,r,n))&&e.push(o)},n),e}function isFunc(r){return"function"==typeof r}function isObj(r){return r&&"object"==typeof r}function isStr(r){return"string"==typeof r}function noop(){}exports.forEach=forEach,exports.arrAdd=arrAdd,exports.arrFind=arrFind,exports.arrFirst=arrFirst,exports.arrRemove=arrRemove,exports.arrFilterMappedResult=arrFilterMappedResult,exports.isFunc=isFunc,exports.isObj=isObj,exports.isStr=isStr,exports.noop=noop;


},{}],5:[function(require,module,exports){
"use strict";var MSG_EVENT_SHOULD_INJECT_QN_BTN=exports.MSG_EVENT_SHOULD_INJECT_QN_BTN="inject-QNBTN?",MSG_EVENT_DISABLE_QN_INJECTION=exports.MSG_EVENT_DISABLE_QN_INJECTION="disable-QNBTN",STORAGE_KEY_USER_DISABLE_QN_INJECTION=exports.STORAGE_KEY_USER_DISABLE_QN_INJECTION="QN_Injection_Disabled",MSG_EVENT_QUERY_RETAILER_AUTOCOMPLETE_INFO=exports.MSG_EVENT_QUERY_RETAILER_AUTOCOMPLETE_INFO="query-retailer-autocomplete-info",MSG_EVENT_SAVE_RETAILER_AUTOCOMPLETE_INFO=exports.MSG_EVENT_SAVE_RETAILER_AUTOCOMPLETE_INFO="save-retailer-autocomplete-info",MSG_EVENT_CAN_OPEN_NEW_RETAILER_WINDOW=exports.MSG_EVENT_CAN_OPEN_NEW_RETAILER_WINDOW="can-open-new-retailer-window",MSG_EVENT_OPEN_NEW_RETAILER_WINDOW=exports.MSG_EVENT_OPEN_NEW_RETAILER_WINDOW="open-new-retailer-window";


},{}],6:[function(require,module,exports){
"use strict";var MSG_EVENT_STATISTIC_RECORD=exports.MSG_EVENT_STATISTIC_RECORD="statistic-record";


},{}],7:[function(require,module,exports){
"use strict";function sendMessageAsync(e,r){var t=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],n=t.noReply,o=t.extId,s={type:e,data:r,sync:!1,noReply:n,d:"req"};if(n)return sendMsg(o,s),Promise.resolve();var c=guid(),d=(0,_defer.defer)();return s.guid=c,deferCache[c]=d,sendMsg(o,s),d.promise["catch"](noop)}function initPort(){deferCache=Object.create(null);try{extPort=chrome.runtime.connect({name:"page:connect"}),extPort.onMessage.addListener(onMsg),extPort.onDisconnect.addListener(function(){disposePort(),setTimeout(initPort,0)})}catch(e){console.log(e)}}function disposePort(){for(var e in deferCache){var r=deferCache[e];r&&r.reject&&r.reject("disconnect")}deferCache=Object.create(null),extPort=null}function onMsg(e){var r=e.guid,t=e.d,n=deferCache[r];if("postTab"===t){var o=bkMsgHandlers[e.type];o&&o(e.data)}else n&&"res"===t&&(e.success?n.resolve(e.data):n.reject(e.error),delete deferCache[r])}function registerMsgHandler(e,r){"function"==typeof r&&(bkMsgHandlers[e]=r)}function sendMsg(e,r){if(e&&r)throw Error("not support external");r&&(extPort?extPort.postMessage(r):chrome.runtime.sendMessage(r))}function noop(){}function guid(){function e(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+Date.now()}exports.sendMessageAsync=sendMessageAsync,exports.registerMsgHandler=registerMsgHandler;var _defer=require(2),deferCache=void 0,bkMsgHandlers=Object.create(null),extPort=void 0;"object"==typeof chrome&&chrome.runtime&&chrome.runtime.onMessage&&chrome.runtime.onMessage.addListener(onMsg),window.addEventListener("unload",function(){extPort.disconnect(),disposePort()}),initPort();


},{"2":2}],8:[function(require,module,exports){
"use strict";function wowLog(s,e){(0,_message.sendMessageAsync)(_statistic.MSG_EVENT_STATISTIC_RECORD,{id:s,param:e},{noReply:!1})}exports.wowLog=wowLog;var _message=require(7),_statistic=require(6);


},{"6":6,"7":7}]},{},[1]);
