/*! *****************************************************************************
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var e=function(){return e=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var o in n=arguments[t])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e},e.apply(this,arguments)};function n(){for(var e=0,n=0,t=arguments.length;n<t;n++)e+=arguments[n].length;var r=Array(e),o=0;for(n=0;n<t;n++)for(var i=arguments[n],u=0,a=i.length;u<a;u++,o++)r[o]=i[u];return r}var t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto),r=new Uint8Array(16);function o(){if(!t)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return t(r)}for(var i=[],u=0;u<256;++u)i[u]=(u+256).toString(16).substr(1);function a(e,n,t){var r=n&&t||0;"string"==typeof e&&(n="binary"===e?new Array(16):null,e=null);var u=(e=e||{}).random||(e.rng||o)();if(u[6]=15&u[6]|64,u[8]=63&u[8]|128,n)for(var a=0;a<16;++a)n[r+a]=u[a];return n||function(e,n){var t=n||0,r=i;return[r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]]].join("")}(u)}var c=Object.prototype.hasOwnProperty,s=function(e){return null==e},l=Array.isArray,f=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;function d(e,n){if(l(e))return e;if(n&&(t=n,r=e,c.call(t,r)))return[e];var t,r,o=[];return e.replace(f,(function(e,n,t,r){return o.push(t?r.replace(/\\(\\)?/g,"$1"):n||e),r})),o}function p(e,n){var t,r=d(n,e);for(t=r.shift();!s(t);){if(null==(e=e[t]))return;t=r.shift()}return e}function g(e){return e._uid||e.uid}var v=new Map;function m(e){var n,t;if(!function(e){if(e){var n=e.tagName;return 0===n.indexOf("UNI-")||"BODY"===n||0===n.indexOf("V-UNI-")||e.__isUniElement}return!1}(e))throw Error("no such element");var r,o,i,u={elementId:(r=e,o=r._id,o||(o=a(),r._id=o,v.set(o,{id:o,element:r})),o),tagName:e.tagName.toLocaleLowerCase().replace("uni-","")};e.__vue__?(i=e.__vue__)&&(i.$parent&&i.$parent.$el===e&&(i=i.$parent),i&&!(null===(n=i.$options)||void 0===n?void 0:n.isReserved)&&(u.nodeId=g(i))):(i=e.__vnode)&&(i.el===e&&(i=i.ctx.parent),i&&!(null===(t=i.type)||void 0===t?void 0:t.__reserved)&&(u.nodeId=g(i)));return"video"===u.tagName&&(u.videoId=u.nodeId),u}var h={input:{input:function(e,n){var t=e.__vue__;t?(t.valueSync=n,t.$triggerInput({},{value:n})):(t=e.__vnode).ctx.exposed.$triggerInput({value:n})}},textarea:{input:function(e,n){var t=e.__vue__;t?(t.valueSync=n,t.$triggerInput({},{value:n})):(t=e.__vnode).ctx.exposed.$triggerInput({value:n})}},"scroll-view":{scrollTo:function(e,n,t){var r=e.__vue__?e.__vue__.$refs.main:e;r.scrollLeft=n,r.scrollTop=t},scrollTop:function(e){return e.__vue__?e.__vue__.$refs.main.scrollTop:e.scrollTop},scrollLeft:function(e){return e.__vue__?e.__vue__.$refs.main.scrollLeft:e.scrollLeft},scrollWidth:function(e){return e.__vue__?e.__vue__.$refs.main.scrollWidth:e.scrollWidth},scrollHeight:function(e){return e.__vue__?e.__vue__.$refs.main.scrollHeight:e.scrollHeight}},swiper:{swipeTo:function(e,n){e.__vue__.current=n}},"movable-view":{moveTo:function(e,n,t){e.__vue__._animationTo(n,t)}},switch:{tap:function(e){e.click()}},slider:{slideTo:function(e,n){var t=e.__vue__,r=t.$refs["uni-slider"],o=r.offsetWidth,i=r.getBoundingClientRect().left;t.value=n,t._onClick({x:(n-t.min)*o/(t.max-t.min)+i})}}};function _(e){var n,t=e.map((function(e){return function(e){if(document.createTouch)return document.createTouch(window,e.target,e.identifier,e.pageX,e.pageY,e.screenX,e.screenY);return new Touch(e)}(e)}));return document.createTouchList?(n=document).createTouchList.apply(n,t):t}var y={getWindow:function(e){return window},getDocument:function(e){return document},getEl:function(e){var n=v.get(e);if(!n)throw Error("element destroyed");return n.element},getOffset:function(e){var n=e.getBoundingClientRect();return Promise.resolve({left:n.left+window.pageXOffset,top:n.top+window.pageYOffset})},querySelector:function(e,n){return"page"===n&&(n="body"),Promise.resolve(m(e.querySelector(n)))},querySelectorAll:function(e,n){var t=[],r=document.querySelectorAll(n);return[].forEach.call(r,(function(e){try{t.push(m(e))}catch(e){}})),Promise.resolve({elements:t})},queryProperties:function(e,n){return Promise.resolve({properties:n.map((function(n){var t=p(e,n.replace(/-([a-z])/g,(function(e){return e[1].toUpperCase()})));return"document.documentElement.scrollTop"===n&&0===t&&(t=p(e,"document.body.scrollTop")),"innerText"===n?t.replace(/\n/g,""):t}))})},queryAttributes:function(e,n){return Promise.resolve({attributes:n.map((function(n){return String(e.getAttribute(n))}))})},queryStyles:function(e,n){var t=getComputedStyle(e);return Promise.resolve({styles:n.map((function(e){return t[e]}))})},queryHTML:function(e,n){return Promise.resolve({html:(t="outer"===n?e.outerHTML:e.innerHTML,t.replace(/\n/g,"").replace(/(<uni-text[^>]*>)(<span[^>]*>[^<]*<\/span>)(.*?<\/uni-text>)/g,"$1$3").replace(/<\/?[^>]*>/g,(function(e){return-1<e.indexOf("<body")?"<page>":"</body>"===e?"</page>":0!==e.indexOf("<uni-")&&0!==e.indexOf("</uni-")?"":e.replace(/uni-/g,"").replace(/ role=""/g,"").replace(/ aria-label=""/g,"")})))});var t},dispatchTapEvent:function(e){return e.click(),Promise.resolve()},dispatchLongpressEvent:function(e){return Promise.resolve()},dispatchTouchEvent:function(e,n,t){t||(t={}),t.touches||(t.touches=[]),t.changedTouches||(t.changedTouches=[]),t.touches.length||t.touches.push({identifier:Date.now(),target:e});var r=_(t.touches),o=_(t.changedTouches),i=_([]);return e.dispatchEvent(new TouchEvent(n,{cancelable:!0,bubbles:!0,touches:r,targetTouches:i,changedTouches:o})),Promise.resolve()},callFunction:function(e,t,r){var o=p(h,t);return o?Promise.resolve({result:o.apply(null,n([e],r))}):Promise.reject(Error(t+" not exists"))},triggerEvent:function(e,n,t){var r=e.__vue__;return r.$trigger&&r.$trigger(n,{},t),Promise.resolve()}};var T,S=Object.assign({},function(e){return{"Page.getElement":function(n){return e.querySelector(e.getDocument(n.pageId),n.selector)},"Page.getElements":function(n){return e.querySelectorAll(e.getDocument(n.pageId),n.selector)},"Page.getWindowProperties":function(n){return e.queryProperties(e.getWindow(n.pageId),n.names)}}}(y),function(e){var n=function(n){return e.getEl(n.elementId,n.pageId)};return{"Element.getElement":function(t){return e.querySelector(n(t),t.selector)},"Element.getElements":function(t){return e.querySelectorAll(n(t),t.selector)},"Element.getDOMProperties":function(t){return e.queryProperties(n(t),t.names)},"Element.getProperties":function(t){var r=n(t),o=r.__vue__||r.attr||{};return r.__vueParentComponent&&(o=Object.assign({},o,r.__vueParentComponent.attrs,r.__vueParentComponent.props)),e.queryProperties(o,t.names)},"Element.getOffset":function(t){return e.getOffset(n(t))},"Element.getAttributes":function(t){return e.queryAttributes(n(t),t.names)},"Element.getStyles":function(t){return e.queryStyles(n(t),t.names)},"Element.getHTML":function(t){return e.queryHTML(n(t),t.type)},"Element.tap":function(t){return e.dispatchTapEvent(n(t))},"Element.longpress":function(t){return e.dispatchLongpressEvent(n(t))},"Element.touchstart":function(t){return e.dispatchTouchEvent(n(t),"touchstart",t)},"Element.touchmove":function(t){return e.dispatchTouchEvent(n(t),"touchmove",t)},"Element.touchend":function(t){return e.dispatchTouchEvent(n(t),"touchend",t)},"Element.callFunction":function(t){return e.callFunction(n(t),t.functionName,t.args)},"Element.triggerEvent":function(t){return e.triggerEvent(n(t),t.type,t.detail)}}}(y));function E(e){return UniViewJSBridge.publishHandler("onAutoMessageReceive",e)}function w(e){return e.__wxWebviewId__?e.__wxWebviewId__:e.privateProperties?e.privateProperties.slaveId:e.$page?e.$page.id:void 0}function P(e){return e.route||e.uri}function O(e){return e.options||e.$page&&e.$page.options||{}}function b(e){return{id:w(e),path:P(e),query:O(e)}}function I(e){var n=function(e){return getCurrentPages().find((function(n){return w(n)===e}))}(e);return n&&n.$vm}function M(e,n){return e._uid===n||e.uid===n}function C(e,n,t){var r,o,i;if(void 0===t&&(t=!1),t)if(e.component&&M(e.component,n))i=e.component;else{var u=[];e.children instanceof Array?u=e.children:(null===(o=null===(r=e.component)||void 0===r?void 0:r.subTree)||void 0===o?void 0:o.children)&&(u=e.component.subTree.children),u.find((function(e){return i=C(e,n,!0)}))}else e&&(M(e,n)?i=e:e.$children.find((function(e){return i=C(e,n)})));return i}function x(e,n){var t=I(e);if(t)return N(t)?C(t.$.subTree,n,!0):C(t,n)}function $(e,n){var t,r=e.$data||e.data;return e&&(t=n?p(r,n):Object.assign({},r)),Promise.resolve({data:t})}function k(e,n){if(e){var t=N(e);Object.keys(n).forEach((function(r){t?(e.$data||e.data)[r]=n[r]:e[r]=n[r]}))}return Promise.resolve()}function A(e,n,t){return N(e)&&(e=e.$vm||e.ctx),new Promise((function(r,o){var i,u;if(!e)return o(T.VM_NOT_EXISTS);if(!e[n]&&!(null===(u=e.$.exposed)||void 0===u?void 0:u[n]))return o(T.METHOD_NOT_EXISTS);var a,c=e[n]?e[n].apply(e,t):(i=e.$.exposed)[n].apply(i,t);!(a=c)||"object"!=typeof a&&"function"!=typeof a||"function"!=typeof a.then?r({result:c}):c.then((function(e){r({result:e})}))}))}function N(e){return!e.$children}function W(){return"undefined"!=typeof window&&window.__uniapp_x_}UniViewJSBridge.subscribe("sendAutoMessage",(function(e){var n=e.id,t=e.method,r=e.params,o={id:n};if("ping"==t)return o.result="pong",void E(o);var i=S[t];if(!i)return o.error={message:t+" unimplemented"},E(o);try{i(r).then((function(e){e&&(o.result=e)})).catch((function(e){o.error={message:e.message}})).finally((function(){E(o)}))}catch(e){o.error={message:e.message},E(o)}})),function(e){e.VM_NOT_EXISTS="VM_NOT_EXISTS",e.METHOD_NOT_EXISTS="METHOD_NOT_EXISTS"}(T||(T={}));var B=1,D={};function V(e,n){var t=0;n&&(t=B++,D[t]=n);var r={data:{id:t,type:"automator",data:e}};console.log("postMessageToUniXWebView",r),"undefined"!=typeof window&&window.__uniapp_x_.postMessage(JSON.stringify(r))}var q=new Map,L=function(n){return new Promise((function(t,r){var o=q.values().next().value;if(o){var i=n.method;if("onOpen"===i)return U(o,t);if(i.startsWith("on"))return o.instance[i]((function(e){t(e)}));"sendMessage"===i&&(i="send"),o.instance[i](e(e({},n),{success:function(e){t({result:e}),"close"===i&&q.delete(q.keys().next().value)},fail:function(e){r(e)}}))}else r({errMsg:"socketTask not exists."})}))};function U(e,n){if(e.isOpend)n({data:e.openData});else{var t=setInterval((function(){e.isOpend&&(clearInterval(t),n(e.openData))}),200);setTimeout((function(){clearInterval(t)}),2e3)}}var H=["stopRecord","getRecorderManager","pauseVoice","stopVoice","pauseBackgroundAudio","stopBackgroundAudio","getBackgroundAudioManager","createAudioContext","createInnerAudioContext","createVideoContext","createCameraContext","createMapContext","canIUse","startAccelerometer","stopAccelerometer","startCompass","stopCompass","hideToast","hideLoading","showNavigationBarLoading","hideNavigationBarLoading","navigateBack","createAnimation","pageScrollTo","createSelectorQuery","createCanvasContext","createContext","drawCanvas","hideKeyboard","stopPullDownRefresh","arrayBufferToBase64","base64ToArrayBuffer"],R=new Map,X=["onCompassChange","onThemeChange","onUserCaptureScreen","onWindowResize","onMemoryWarning","onAccelerometerChange","onKeyboardHeightChange","onNetworkStatusChange","onPushMessage","onLocationChange","onGetWifiList","onWifiConnected","onWifiConnectedWithPartialInfo","onSocketOpen","onSocketError","onSocketMessage","onSocketClose"],j={},J=/^\$|Sync$|Window$|WindowStyle$|sendHostEvent|sendNativeEvent|restoreGlobal|requireGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64|getLocale|setLocale|invokePushCallback|getWindowInfo|getDeviceInfo|getAppBaseInfo|getSystemSetting|getAppAuthorizeSetting|initUTS|requireUTS|registerUTS/,F=/^on|^off/;function Y(e){return J.test(e)||-1!==H.indexOf(e)}var z={getPageStack:function(){return Promise.resolve({pageStack:getCurrentPages().map((function(e){return b(e)}))})},getCurrentPage:function(){var e=getCurrentPages(),n=e.length;return new Promise((function(t,r){n?t(b(e[n-1])):r(Error("getCurrentPages().length=0"))}))},callUniMethod:function(n,t){var r=n.method,o=n.args;return new Promise((function(n,i){if("connectSocket"!==r){var u,a;if(X.includes(r)){R.has(r)||R.set(r,new Map);var c=o[0],s=function(e){t({id:c,result:{method:r,data:e}})};return r.startsWith("onSocket")?L({method:r.replace("Socket","")}).then((function(e){return s(e)})).catch((function(e){return s(e)})):(R.get(r).set(c,s),uni[r](s)),n({result:null})}if(r.startsWith("off")&&X.includes(r.replace("off","on"))){var l=r.replace("off","on");if(R.has(l)){var f=o[0];if(void 0!==f){var d=R.get(l).get(f);uni[r](d),R.get(l).delete(f)}else{R.get(l).forEach((function(e){uni[r](e)})),R.delete(l)}}return n({result:null})}if(r.indexOf("Socket")>0)return L(e({method:r.replace("Socket","")},o[0])).then((function(e){return n(e)})).catch((function(e){return i(e)}));if(!uni[r])return i(Error("uni."+r+" not exists"));if(Y(r))return n({result:uni[r].apply(uni,o)});var p=[Object.assign({},o[0]||{},{success:function(e){setTimeout((function(){n({result:e})}),"pageScrollTo"===r?350:0)},fail:function(e){i(Error(e.errMsg.replace(r+":fail ","")))}})];uni[r].apply(uni,p)}else(u=o[0].id,a=o[0].url,new Promise((function(e,n){var t=uni.connectSocket({url:a,success:function(){e({result:{errMsg:"connectSocket:ok"}})},fail:function(){n({result:{errMsg:"connectSocket:fail"}})}});q.set(u,{instance:t,isOpend:!1}),t.onOpen((function(e){q.get(u).isOpend=!0,q.get(u).openData=e}))}))).then((function(e){return n(e)})).catch((function(e){return i(e)}))}))},mockUniMethod:function(e){var n=e.method;if(!uni[n])throw Error("uni."+n+" not exists");if(!function(e){return!F.test(e)}(n))throw Error("You can't mock uni."+n);var t,r=e.result,o=e.functionDeclaration;return s(r)&&s(o)?(j[n]&&(uni[n]=j[n],delete j[n]),Promise.resolve()):(t=s(o)?Y(n)?function(){return r}:function(e){setTimeout((function(){r.errMsg&&-1!==r.errMsg.indexOf(":fail")?e.fail&&e.fail(r):e.success&&e.success(r),e.complete&&e.complete(r)}),4)}:function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return new Function("return "+o)().apply(t,n.concat(e.args))},t.origin=j[n]||uni[n],j[n]||(j[n]=uni[n]),uni[n]=t,Promise.resolve())},captureScreenshot:function(e){return new Promise((function(n,t){W()?V({action:"captureScreenshot",args:e},(function(e,r){e?t(Error("captureScreenshot fail: "+e)):n(r)})):t(Error("captureScreenshot fail: supported only on the app platform."))}))},socketEmitter:function(n){return new Promise((function(t,r){(function(n){return new Promise((function(t,r){if(q.has(n.id)){var o=q.get(n.id),i=o.instance,u=n.method,a=n.id;if("onOpen"==u)return U(o,t);if(u.startsWith("on"))return i[u]((function(e){t({method:"Socket."+u,id:a,data:e})}));i[u](e(e({},n),{success:function(e){t(e),"close"===u&&q.delete(n.id)},fail:function(e){r(e)}}))}else r({errMsg:"socketTask not exists."})}))})(n).then((function(e){return t(e)})).catch((function(e){return r(e)}))}))}},G=z,K={getData:function(e){return $(I(e.pageId),e.path)},setData:function(e){return k(I(e.pageId),e.data)},callMethod:function(e){var n,t=((n={})[T.VM_NOT_EXISTS]="Page["+e.pageId+"] not exists",n[T.METHOD_NOT_EXISTS]="page."+e.method+" not exists",n);return new Promise((function(n,r){A(I(e.pageId),e.method,e.args).then((function(e){return n(e)})).catch((function(e){r(Error(t[e]))}))}))},callMethodWithCallback:function(e){var n,t=((n={})[T.VM_NOT_EXISTS]="callMethodWithCallback:fail, Page["+e.pageId+"] not exists",n[T.METHOD_NOT_EXISTS]="callMethodWithCallback:fail, page."+e.method+" not exists",n),r=e.args[e.args.length-1];A(I(e.pageId),e.method,e.args).catch((function(e){r({errMsg:t[e]})}))}};function Q(e){return e.nodeId||e.elementId}var Z={getData:function(e){return $(x(e.pageId,Q(e)),e.path)},setData:function(e){return k(x(e.pageId,Q(e)),e.data)},callMethod:function(e){var n,t=Q(e),r=((n={})[T.VM_NOT_EXISTS]="Component["+e.pageId+":"+t+"] not exists",n[T.METHOD_NOT_EXISTS]="component."+e.method+" not exists",n);return new Promise((function(n,o){A(x(e.pageId,t),e.method,e.args).then((function(e){return n(e)})).catch((function(e){o(Error(r[e]))}))}))}};window.initRuntimeAutomator=ue,window.onPostMessageFromUniXWebView=function(e,n,t){console.log("onPostMessageFromUniXWebView",e,n,t,D);var r=D[e];r&&(delete D[e],r(t,n))};var ee={};Object.keys(G).forEach((function(e){ee["App."+e]=G[e]})),Object.keys(K).forEach((function(e){ee["Page."+e]=K[e]})),Object.keys(Z).forEach((function(e){ee["Element."+e]=Z[e]}));var ne,te,re=process.env.UNI_AUTOMATOR_WS_ENDPOINT;function oe(e){te.send({data:JSON.stringify(e)})}function ie(e){var n=JSON.parse(e.data),t=n.id,r=n.method,o=n.params,i={id:t},u=ee[r];if(!u){if(ne){var a=ne(t,r,o,i);if(!0===a)return;u=a}if(!u)return i.error={message:r+" unimplemented"},oe(i)}try{u(o,oe).then((function(e){e&&(i.result=e)})).catch((function(e){i.error={message:e.message}})).finally((function(){oe(i)}))}catch(e){i.error={message:e.message},oe(i)}}function ue(e){void 0===e&&(e={}),(te=uni.connectSocket({url:e.wsEndpoint||re,complete:function(){}})).onMessage(ie),te.onOpen((function(n){e.success&&e.success(),console.log("已开启自动化测试...")})),te.onError((function(e){console.log("automator.onError",e)})),te.onClose((function(){e.fail&&e.fail({errMsg:"$$initRuntimeAutomator:fail"}),console.log("automator.onClose")}))}ne=function(e,n,t,r){var o=t.pageId,i=function(e){var n=getCurrentPages();if(!e)return n[n.length-1];return n.find((function(n){return n.$page.id===e}))}(o);return i?(i.$page.meta.isNVue,UniServiceJSBridge.publishHandler("sendAutoMessage",{id:e,method:n,params:t},o),!0):(r.error={message:"page["+o+"] not exists"},oe(r),!0)},UniServiceJSBridge.subscribe("onAutoMessageReceive",(function(e){oe(e)})),setTimeout((function(){if(W())V({action:"ready"});else{if(re&&re.endsWith(":0000"))return;ue()}}),500);
