!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).suplink={})}(this,(function(e){"use strict";function t(){return window.navigator.userAgent.includes("Zhizhi")}function n(){return window.self!==window.top}function o(e,...t){const n={code:"404",msg:`暂不支持此方法: ${e}`,data:""};return Promise.reject(n)}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var r={exports:{}};!function(e,t){!function(e){var t,n=new Uint8Array(16);function o(){if(!t&&!(t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return t(n)}var r=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function i(e){return"string"==typeof e&&r.test(e)}for(var s=[],a=0;a<256;++a)s.push((a+256).toString(16).substr(1));function c(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(s[e[t+0]]+s[e[t+1]]+s[e[t+2]]+s[e[t+3]]+"-"+s[e[t+4]]+s[e[t+5]]+"-"+s[e[t+6]]+s[e[t+7]]+"-"+s[e[t+8]]+s[e[t+9]]+"-"+s[e[t+10]]+s[e[t+11]]+s[e[t+12]]+s[e[t+13]]+s[e[t+14]]+s[e[t+15]]).toLowerCase();if(!i(n))throw TypeError("Stringified UUID is invalid");return n}function u(e,t,n){function o(e,o,r,s){if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));for(var t=[],n=0;n>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=255&t,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=255&t,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=255&t,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=255&t,n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=255&t,n}(o)),16!==o.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var a=new Uint8Array(16+e.length);if(a.set(o),a.set(e,o.length),(a=n(a))[6]=15&a[6]|t,a[8]=63&a[8]|128,r){s=s||0;for(var u=0;u<16;++u)r[s+u]=a[u];return r}return c(a)}try{o.name=e}catch(e){}return o.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",o.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",o}function d(e){return 14+(e+64>>>9<<4)+1}function l(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function f(e,t,n,o,r,i){return l((s=l(l(t,e),l(o,i)))<<(a=r)|s>>>32-a,n);var s,a}function p(e,t,n,o,r,i,s){return f(t&n|~t&o,e,t,r,i,s)}function g(e,t,n,o,r,i,s){return f(t&o|n&~o,e,t,r,i,s)}function h(e,t,n,o,r,i,s){return f(t^n^o,e,t,r,i,s)}function m(e,t,n,o,r,i,s){return f(n^(t|~o),e,t,r,i,s)}function y(e,t,n){var r=(e=e||{}).random||(e.rng||o)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(var i=0;i<16;++i)t[n+i]=r[i];return t}return c(r)}function w(e,t,n,o){switch(e){case 0:return t&n^~t&o;case 1:case 3:return t^n^o;case 2:return t&n^t&o^n&o}}function b(e,t){return e<>>32-t}u("v3",48,(function(e){if("string"==typeof e){var t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(var n=0;n>5]>>>r%32&255,s=parseInt(o.charAt(i>>>4&15)+o.charAt(15&i),16);t.push(s)}return t}(function(e,t){e[t>>5]|=128<>5]|=(255&e[o/8])<>>0;O=v,v=y,y=b(m,30)>>>0,m=h,h=I}n[0]=n[0]+h>>>0,n[1]=n[1]+m>>>0,n[2]=n[2]+y>>>0,n[3]=n[3]+v>>>0,n[4]=n[4]+O>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,255&n[0],n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,255&n[1],n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,255&n[2],n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,255&n[3],n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,255&n[4]]}));class v{constructor(e){this.config={},this.listenerMap={},this.createId=()=>y(),this.init=e=>{this.setConfig(e),this.close(),this.connect()},this.connect=()=>{this.onMessage&&window.addEventListener("message",this.onMessage)},this.disconnect=()=>{this.onMessage&&window.removeEventListener("message",this.onMessage)},this.close=()=>{this.disconnect(),this.listenerMap={}},this.onMessage=e=>{Object.values(this.listenerMap).forEach((t=>t(e)))},this.dispatch=(e,t)=>{const n=Object.assign(Object.assign({},this.config),t),o={targetOrigin:n.origin||window.location.origin};(n.target||window.top||window).postMessage(e,o)},this.subscribe=e=>{const t=this.createId();return this.listenerMap[t]=e,t},this.unsubscribe=e=>{(Array.isArray(e)?e:[e]).forEach((e=>delete this.listenerMap[e]))},this.init(e)}setConfig(e){this.config=Object.assign(Object.assign({},this.config),e)}}class O{constructor(e){this.responseListenerMap={},this.resume=()=>{this.messageId=this.message.subscribe(this.onResponse)},this.cancel=()=>{this.message.unsubscribe(this.messageId)},this.onResponse=e=>{const{type:t,id:n}=e.data;if("response"===t&&this.responseListenerMap[n]){const t=this.responseListenerMap[n];delete this.responseListenerMap[n],t(e.data)}},this.request=(e,t,n)=>{const o=this.message.createId(),r={type:"request",path:e,id:o,data:t};return new Promise(((e,t)=>{try{this.responseListenerMap[o]=t=>e(t),this.message.dispatch(r,n)}catch(e){t(e)}}))},this.message=new v(e),this.messageId=this.message.subscribe(this.onResponse)}}var S=window&&window.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{c(o.next(e))}catch(e){i(e)}}function a(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((o=o.apply(e,t||[])).next())}))};class P{constructor(e){this.routerMap={},this.resume=()=>{this.messageId=this.message.subscribe(this.onRequest)},this.cancel=()=>{this.message.unsubscribe(this.messageId)},this.onRequest=e=>S(this,void 0,void 0,(function*(){const{type:t}=e.data;if("request"!==t)return;const{source:n,origin:o}=e,{path:r,id:i}=e.data;if(n&&this.routerMap[r]){const t=(0,this.routerMap[r])(e.data,e),s={type:"response",path:r,id:i,data:"object"==typeof t&&"then"in t?yield t:t};n.postMessage(s,{targetOrigin:o})}})),this.router=(e,t)=>{this.routerMap[e]=t},this.message=new v(e),this.messageId=this.message.subscribe(this.onRequest)}}var I={Message:v,Client:O,Server:P};e.Client=O,e.Message=v,e.Server=P,e.default=I,Object.defineProperty(e,"__esModule",{value:!0})}(t)}(0,r.exports);const i=new r.exports.Client({origin:"*"}),s=(e,t={})=>i.request(e,t).then((e=>{const{data:t}=e;return t}));function a(){return{code:"200",msg:"",data:{suplink:t(),iframe:n()}}}var c={getSystemInfo:function(){return s("/base/getSystemInfo")},getEnvInfo:a};var u=window&&window.__rest||function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r{let t;try{t=JSON.parse(e.data)}catch(n){t=e.data}return Object.assign(Object.assign({},e),{data:t})}))},setStorage:function(e){const{key:t,value:n}=e;let o;try{o=JSON.stringify(n)}catch(e){o=n}return s("/storage/setStorage",{key:t,value:o})}};const g=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},c),d),l),f),p),h=n(),m=new r.exports.Client({origin:"*"}),y=new r.exports.Server,w={};function b(e,t){return m.request("/iframe/callHandler",{handlerName:e,data:t}).then((e=>e.data))}function v(){return("undefined"!=typeof window?navigator.userAgent.toLowerCase():"android").indexOf("android")>-1}function O(e){if("undefined"!=typeof window&&window.WebViewJavascriptBridge)e(window.WebViewJavascriptBridge);else{if("undefined"!=typeof window&&window.WVJBCallbacks)return console.log("callback存到WVJBCallbacks"),void window.WVJBCallbacks.push(e);if("undefined"!=typeof window){window.WVJBCallbacks=[e];const t=window.document.createElement("iframe");t.style.display="none",t.src="https://__bridge_loaded__",window.document.documentElement.appendChild(t),setTimeout((function(){window.document.documentElement.removeChild(t)}),0)}}}function S(e,t){h?function(e,t){w[e]=t,m.request("/iframe/registerHandler",{handlerName:e})}(e,t):O((function(n){n.registerHandler(e,(function(e,n){try{const o=JSON.parse(e),r={code:o.responseCode,msg:o.responseMsg,data:o.responseResult};t(r,n)}catch(e){t(e,n)}}))}))}function P(e,t={}){return h?b(e,t):v()?new Promise(((n,o)=>{"undefined"!=typeof window&&window.WebViewJavascriptBridge&&window.WebViewJavascriptBridge.callHandler?window.WebViewJavascriptBridge.callHandler(e,JSON.stringify(t),(e=>{try{const t=JSON.parse(e),r={code:t.responseCode,msg:t.responseMsg,data:t.responseResult};"200"===r.code?n(r):o(r)}catch(e){o(e)}})):(console.log("dispatchAppEvent - fail"),o(new Error("window.WebViewJavascriptBridge.callHandler is undefined")))})):new Promise(((n,o)=>{!function(e,t,n){h?b(e,t).then((e=>{n(e)})):O((function(o){o.callHandler(e,t,n)}))}(e,JSON.stringify(t),(e=>{try{const t=JSON.parse(e),r={code:t.responseCode,msg:t.responseMsg,data:t.responseResult};"200"===r.code?n(r):o(r)}catch(e){o(e)}}))}))}"undefined"!=typeof window&&(v()?function(){if("undefined"!=typeof window&&window.WebViewJavascriptBridge)return;let e,t,n,o=[],r=[],i=1;const s={},a={};function c(e,n){if(n){const t=`cb_${i++}_${(new Date).getTime()}`;a[t]=n,e.callbackId=t}o.push(e),t.src="yy://__bridge_loaded__"}function u(e){setTimeout((function(){const t=JSON.parse(e);let n;if(t.responseId){if(n=a[t.responseId],!n)return;n(t.responseData),delete a[t.responseId]}else{if(t.callbackId){const e=t.callbackId;n=function(t){c({responseId:e,responseData:t})}}if("undefined"!=typeof window){let e=window.WebViewJavascriptBridge._messageHandler;t.handlerName&&(e=s[t.handlerName]);try{e&&e(t.data,n)}catch(e){"undefined"!=typeof console&&console.log(e)}}}}))}var d;"undefined"!=typeof window&&(e={init:function(e){if("undefined"!=typeof window&&window.WebViewJavascriptBridge._messageHandler)throw new Error("WebViewJavascriptBridge.init called twice");if("undefined"!=typeof window){window.WebViewJavascriptBridge._messageHandler=e;const t=r||[];r=null;for(let e=0;e{const{handlerName:t,data:n}=e.data;w[t]&&w[t](n)})):(y.router("/iframe/callHandler",(e=>{const{handlerName:t,data:n}=e.data;let o;try{o=JSON.parse(n)}catch(e){o=n}return P(t,o)})),y.router("/iframe/registerHandler",((e,t)=>{const{handlerName:n}=e.data;S(n,(e=>{m.request("/iframe/registerHandler/result",{handlerName:n,data:e},{origin:t.origin,target:t.source||void 0})}))}))));var I={getSystemInfo:function(){return P("sl.system.deviceInfo")},renderFinish:function(){return P("sl.notification.webRenderFinish")},getEnvInfo:a};var j={biometrics:function(){return P("sl.security.biometrics")},compass:function(){return P("sl.location.compass")},flashlight:function(e){const{open:t}=e;return P("sl.camera.flashlight",{open:t?1:0})},gesture:function(){return P("sl.security.gesture")},getNetworkInfo:function(){return P("reqGetNetworkType")},makePhoneCall:function(e){const{phoneNumber:t}=e;return P("sl.other.call",{phoneNum:t})},nfc:function(e){const{type:t}=e||{};return P("sl.security.nfc",{functionType:t||0})},ocr:function(){return P("sl.intelligentFunction.ocr")},scanCode:function(){return P("sl.camera.scan")},scanner:function(e){const{outputMode:t=1,success:n}=e||{};return"function"==typeof n&&S("sl.camera.scanner.data",(e=>{n(e)})),P("sl.camera.scanner.setConfig",{mode:t})},setScreenOrientation:function(e){const{mode:t}=e;return P("sl.operation.setScreenOrientation",{type:t})},startContinuousScan:function(e){const{interval:t=1e3,vibrate:n=!1,success:o}=e;return"function"!=typeof o?Promise.reject(new Error("success must be a function!")):(S("sl.camera.continuousScan.responseData",o),P("sl.camera.continuousScan.requestOpen",{scanTimeInterval:t,vibrate:n}))},stopContinuousScan:function(){return P("sl.camera.continuousScan.requestClose")},connectPrinter:function(e){const{mode:t,host:n="",mac:o=""}=e,[r="",i=0]=(n||"").split(":");return P("sl.printer.connect",{mode:t,ipAddress:r,port:i,bluetoothAddress:o})},disconnectPrinter:function(){return P("sl.printer.disconnect")},print:function(e){const{content:t}=e;return P("sl.printer.print",{content:t})},oncePrint:function(e){const{mode:t,content:n,host:o="",mac:r=""}=e,[i="",s=0]=(o||"").split(":");return P("sl.printer.singlePrint",{mode:t,content:n,ipAddress:i,port:s,bluetoothAddress:r})},getBluetoothPairedDevices:function(){return P("sl.printer.getBluetoothDevices")},vibrate:function(){return P("sl.notification.vibrate")}};function C(){const e=[],t="0123456789abcdef";for(let n=0;n<36;n++)e[n]=t.substring(Math.floor(16*Math.random()),1);return e[14]="4",e[19]=t.substring(Number(e[19])?3:8,1),e[8]="-",e[13]="-",e[18]="-",e[23]="-",e.join("")}const M=new class{constructor(){this._events=[]}on(e,t){const n=C();t._uuid=n,this._events.push({[e]:t,type:"always",key:n})}once(e,t){const n=C();t._uuid=n,this._events.push({type:"once",[e]:t,key:n})}off(e,t){"function"==typeof t?t._uuid&&(this._events=this._events.filter((n=>!(n[e]&&n.key===t._uuid)))):this._events=this._events.filter((t=>!t[e]))}emit(e){this._events.filter((t=>t[e])).forEach((t=>{try{"done"!==t.type&&(t[e](),"once"===t.type&&(t.type="done"))}catch(e){console.log(e)}})),this._events=this._events.filter((e=>"done"!==e.type))}};const k={show:"1002",hide:"1003"},_={1002:{},1003:{}};let A=!1;function N(e,t){_[k[e]][t._uuid]=t,A||(A=!0,S("sl.lifeCycle.status",(e=>{const t=_[e.data];Object.getOwnPropertySymbols(t).forEach((e=>t[e]()))})))}"undefined"!=typeof window&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState?M.emit("pageShow"):M.emit("pageHide")}));var B={offPageHide:function(e){const{listener:t}=e||{};M.off("pageHide",t)},offPageShow:function(e){const{listener:t}=e||{};M.off("pageShow",t)},onPageHide:function(e){const{listener:t}=e;"function"==typeof t?M.on("pageHide",t):console.error("listener must be a function")},onPageShow:function(e){const{listener:t}=e;"function"==typeof t?M.on("pageShow",t):console.error("listener must be a function")},onAppHide:function(e){const{listener:t}=e;"function"==typeof t?(t._uuid=Symbol("app hide"),N("hide",t)):console.error("listener must be a function")},onAppShow:function(e){const{listener:t}=e;"function"==typeof t?(t._uuid=Symbol("app show"),N("show",t)):console.error("listener must be a function")}};var E={previewFile:function(e){const{url:t,title:n="预览"}=e;return t?P("sl.multiMedia.preview",{previewUrl:t,sourceFileUrl:t,title:n}):Promise.reject(new Error("invalid url"))}};var U={getLocation:function(e){const{inverseEnabled:t=!1}=e;return P("sl.location.singleLocation",{reGeocodeEnabled:t})},startLocationUpdate:function(e){const{success:t}=e;return"function"!=typeof t?Promise.reject(new Error("success must be a function!")):(S("sl.location.serialLocation.response",t),P("sl.location.serialLocation.start"))},stopLocationUpdate:function(){return P("sl.location.serialLocation.stop")}};var H={record:function(){return P("sl.multiMedia.voiceRecording")}};var x=window&&window.__rest||function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r0?o:9,mediaContentType:r,saveDays:Math.floor(i)})}};var R=window&&window.__rest||function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r({uuid:e}))),selectedCode:r.map((e=>({code:e})))})},employeeSelector:function(e){const{type:t=1,title:n="人员选择",max:o,selected:r=[]}=e;return P("sl.contact.selector",{type:t,title:n,maxLimit:o,selected:r.map((e=>({staffCode:e})))})},getStepCount:function(){return P("sl.health.stepCount")},getUserInfo:function(){return P("sl.contact.userInfo").then((e=>{const t=e.data,{userInfo:n={}}=t,o=R(t,["userInfo"]);return{code:e.code,msg:e.msg,data:Object.assign(Object.assign({},o),n)}}))},getLoginInfo:function(){return P("reqGetOpenId").then((e=>{const{data:t}=e,n=T(e,["data"]);return Object.assign(Object.assign({},n),{data:{token:t.token,userName:t.requestUser,appId:t.appId,baseUrl:t.baseUrl,appName:t.minappName,suposToken:t.supostoken}})}))},signature:function(){return P("sl.security.signature")},openUserInfo:function(e){return P("sl.contact.openUserInfoPage",e)}};var D={getStorage:function(e){return P("sl.storage.json.get",e).then((e=>{let t;try{t=JSON.parse(e.data)}catch(n){t=e.data}return Object.assign(Object.assign({},e),{data:t})}))},setStorage:function(e){const{key:t,value:n}=e;let o;try{o=JSON.stringify(n)}catch(e){o=n}return P("sl.storage.json.set",{key:t,value:o})}};var q={setNavigationBar:function(e){const{title:t="",backgroundColor:n="#ffffff",backButton:o=!0,theme:r="dark",goast:i=!1,hidden:s=!1,atomicBond:a=!0,underline:c=!0}=e;return P("sl.config.viewInterface",{toolbarTitle:t,toolbarBackColor:n,isShowBackBtn:o,toolbarMode:r,isFloat:i,isHideToolBar:s,isHideFunctionButton:!a,isHideBottomLine:!c})},datePicker:function(e){const{title:t,min:n,max:o,value:r,showTime:i}=e;return P("reqDatePicker",{format:"yyyy-MM-dd"+(i?" HH:mm:ss":""),title:t,startDate:n,enzzate:o,currentDate:"number"==typeof r?r:(new Date).getTime()})},dateRangePicker:function(e){const{value:t=[0,0],min:n,max:o,showTime:r,limitMin:i,limitMax:s}=e,[a,c]=t;return P("reqBegEndDatePicker",{format:"yyyy-MM-dd"+(r?" HH:mm:ss":""),beginDate:a,endDate:c,startDate:n,enzzate:o,minMillsecond:i,maxMillsecond:s})}};const W=function(e,n){const r=Object.keys(e),i=Object.keys(n),s=[...new Set([...r,...i])],a=t(),c={};for(let t=0;t