(function(w){typeof define=="function"&&define.amd?define(w):w()})(function(){"use strict";var ue=Object.defineProperty;var I=Object.getOwnPropertySymbols;var ve=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable;var O=(w,E,u)=>E in w?ue(w,E,{enumerable:!0,configurable:!0,writable:!0,value:u}):w[E]=u,b=(w,E)=>{for(var u in E||(E={}))ve.call(E,u)&&O(w,u,E[u]);if(I)for(var u of I(E))Ee.call(E,u)&&O(w,u,E[u]);return w};const w=(()=>{const e=(o,r)=>{var i={source:"all",ref:"all",data:r};typeof a2w!="undefined"&&(typeof a2w.sendFinanceAppEvent!="undefined"?a2w.sendFinanceAppEvent("sima",o,JSON.stringify(i)):typeof a2w.exec!="undefined"&&window.a2w.exec("reported","["+JSON.stringify(i)+"]",""))},n=()=>{try{const r=navigator.userAgent.toLowerCase().match(/(sinafinance|sinafinancepro|sinafinancelite)\w*__([^_]*)/);if(r){const i=r[1],c=r[2];return{appType:i,version:c}}return null}catch(o){return console.warn(o),null}};return{sendSima:e,getVersion:n,isSupportAutoLogin:()=>{var o=!0,r=n().replace(/\./g,"");return r&&(r=r.replace(/\./g,"").slice(0,4)),r<481&&(o=!1),o},getImgBase64Async:(o,r)=>{const i=document.createElement("img");i.setAttribute("crossOrigin","anonymous"),i.onload=function(){const c=document.createElement("canvas");c.width=i.width,c.height=i.height,c.getContext("2d").drawImage(i,0,0,i.width,i.height);const S=c.toDataURL("image/png");r(S)},i.src=o},convertURL:o=>{let r=o.trim().replace("vt=4&wm=6121&","");r=r.startsWith("//")?location.protocol+r:r;const i=new URL(r);if(r.startsWith("sinafinance://"))return r;if(/^(finance|tech|client)\.sina(\.com|)\.cn$/gi.test(i.hostname)&&i.pathname.startsWith("/zt_d/"))return"sinafinance://type=42&weexType=1&url="+encodeURIComponent(r);if(/^rl\.cj\.sina(\.com|)\.cn$/gi.test(i.hostname)&&i.pathname.startsWith("/imeeting/")){const c=i.pathname.match(/\/detail\/([\d]{4,})/i);return Array.isArray(c)&&c[1]?"sinafinance://type=42&weexType=2&roadshow_id="+c[1]:r}else if(/^(t\.|)cj\.sina(\.com|)\.cn$/gi.test(i.hostname)&&(i.pathname.startsWith("/article/")||i.pathname.startsWith("/articles/"))){const c=i.searchParams.get("url");return c?"sinafinance://type=17&url="+encodeURIComponent(c):"sinafinance://type=17&url="+encodeURIComponent(r)}else return/^(finance|tech|client|video|news)\.sina(\.com|)\.cn$/gi.test(i.hostname)&&(i.pathname.includes("/doc-")||i.pathname.includes("/detail-"))?"sinafinance://type=17&url="+encodeURIComponent(r):"sinafinance://type=20&url="+encodeURIComponent(r)},b64Encode:o=>window.btoa(encodeURIComponent(o)),b64Decode:o=>decodeURIComponent(window.atob(o)),creatGuid:()=>([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,o=>(o^crypto.getRandomValues(new Uint8Array(1))[0]&15>>o/4).toString(16)),isAppVersionSince:o=>{var c;const r=(c=/sinafinance__([\d\.]+)__/g.exec(navigator.userAgent))!=null?c:/sinafinancepro__([\d\.]+)__/g.exec(navigator.userAgent),i=/sinafinancelite__([\d\.]+)__/g.exec(navigator.userAgent);if(Array.isArray(r)){const f=r[1].split("."),S=(o+"").split(".");for(let l=0;lh)return!0;if(mh)return!0;if(m{const e={motionBegan:[],motionEnded:[],motionCancelled:[],userInfoGot:[],homeShortcutsInfoGot:[],payComplete:[],login:[],logout:[],viewDidAppear:[],viewDidDisappear:[],shareComplete:[],didEnterBackground:[],didEnterForeground:[],darkModeInfoUpdate:[],permissionChange:[],appStorageGot:[],openAppResponse:[],privacyModalResponse:[],jsbridgeReady:[]},n={onEvent:(t,s)=>{t in e&&e[t].push(s)},onEventOnce:(t,s)=>{if(t in e){const p=(...g)=>{s(...g),window.a2wWebSide.offEvent(t,p)};e[t].push(p)}},offEvent:(t,s=void 0)=>{if(t in e){const p=[];typeof s=="function"?(e[t].forEach(g=>{g!==s&&p.push(g)}),e[t]=p):e[t]=[]}},dispatchEvent:(t,s)=>{const p=typeof s=="string"?JSON.parse(s):s;t in e&&e[t].forEach(g=>{g(p)})}},a=window.w2a||{onShared:t=>{n.dispatchEvent("shareComplete",JSON.parse(t))}};window.a2wWebSide=typeof window.a2wWebSide=="object"?b(b({},window.a2wWebSide),n):n,window.w2a=typeof window.w2a=="object"?b(b({},window.w2a),a):a,window.onUserInfo=function(t){n.dispatchEvent("userInfoGot",t)},window.onLoginSuc=function(t){n.dispatchEvent("login",JSON.parse(t))},typeof window.loadNightStyle=="function"?console.warn("检测到window.loadNightStyle已被赋值,组件内置的夜间模式body自定义类名、darkModeInfoUpdate自定义事件等机制已失效"):window.loadNightStyle=(t,s)=>{u(t),n.dispatchEvent("darkModeInfoUpdate",{isNightMode:t,isRedUp:s})},window.addEventListener("DOMContentLoaded",()=>{const s=new URL(location.href).searchParams.get("isBlackTheme")==="1";u(s)}),window.webViewGetNewsHomeFunctions=function(t){n.dispatchEvent("homeShortcutsInfoGot",JSON.parse(t))}};function u(e){const n="sf-app-dark",a="sf-app-dark-html",t="sf-app-light",s="sf-app-light-html";if(e){document.body.classList.remove(t),document.body.classList.add(n);try{document.documentElement.classList.remove(s),document.documentElement.classList.add(a)}catch(p){}}else{document.body.classList.remove(n),document.body.classList.add(t);try{document.documentElement.classList.remove(a),document.documentElement.classList.add(s)}catch(p){}}}const _={bindEvent:e=>{a2w.registerEvent("motion"),window.a2wWebSide.onEvent("motionEnded",e),window.a2wWebSide.onEvent("motionCancelled",e)},bindEventOnce:e=>{a2w.registerEvent("motion"),window.a2wWebSide.onEventOnce("motionEnded",e),window.a2wWebSide.onEventOnce("motionCancelled",e)},unbindEvent:e=>{typeof e=="function"?(window.a2wWebSide.offEvent("motionEnded",e),window.a2wWebSide.offEvent("motionCancelled",e)):(window.a2wWebSide.offEvent("motionEnded"),window.a2wWebSide.offEvent("motionCancelled"))}},x={bindEvent:e=>{window.a2wWebSide.onEvent("login",e)},bindEventOnce:e=>{window.a2wWebSide.onEventOnce("login",e)},unbindEvent:e=>{typeof e=="function"?window.a2wWebSide.offEvent("login",e):window.a2wWebSide.offEvent("login")}},B={bindEvent:e=>{window.a2wWebSide.onEvent("logout",e)},bindEventOnce:e=>{window.a2wWebSide.onEventOnce("logout",e)},unbindEvent:e=>{typeof e=="function"?window.a2wWebSide.offEvent("logout",e):window.a2wWebSide.offEvent("logout")}},C={bindEvent:e=>{window.a2wWebSide.onEvent("payComplete",e)},bindEventOnce:e=>{window.a2wWebSide.onEventOnce("payComplete",e)},unbindEvent:e=>{typeof e=="function"?window.a2wWebSide.offEvent("payComplete",e):window.a2wWebSide.offEvent("payComplete")}},L={bindEvent:e=>{window.a2wWebSide.onEvent("viewDidAppear",e)},bindEventOnce:e=>{window.a2wWebSide.onEventOnce("viewDidAppear",e)},unbindEvent:e=>{typeof e=="function"?window.a2wWebSide.offEvent("viewDidAppear",e):window.a2wWebSide.offEvent("viewDidAppear")}},R={bindEvent:e=>{window.a2wWebSide.onEvent("viewDidDisappear",e)},bindEventOnce:e=>{window.a2wWebSide.onEventOnce("viewDidDisappear",e)},unbindEvent:e=>{typeof e=="function"?window.a2wWebSide.offEvent("viewDidDisappear",e):window.a2wWebSide.offEvent("viewDidDisappear")}},J={bindEvent:e=>{window.a2wWebSide.onEvent("didEnterBackground",e)},bindEventOnce:e=>{window.a2wWebSide.onEventOnce("didEnterBackground",e)},unbindEvent:e=>{typeof e=="function"?window.a2wWebSide.offEvent("didEnterBackground",e):window.a2wWebSide.offEvent("didEnterBackground")}},N={bindEvent:e=>{window.a2wWebSide.onEvent("didEnterForeground",e)},bindEventOnce:e=>{window.a2wWebSide.onEventOnce("didEnterForeground",e)},unbindEvent:e=>{typeof e=="function"?window.a2wWebSide.offEvent("didEnterForeground",e):window.a2wWebSide.offEvent("didEnterForeground")}},U={bindEvent:e=>{window.a2wWebSide.onEvent("shareComplete",e)},bindEventOnce:e=>{window.a2wWebSide.onEventOnce("shareComplete",e)},unbindEvent:e=>{typeof e=="function"?window.a2wWebSide.offEvent("shareComplete",e):window.a2wWebSide.offEvent("shareComplete")}},D={bindEvent:e=>{window.a2wWebSide.onEvent("darkModeInfoUpdate",e)},bindEventOnce:e=>{window.a2wWebSide.onEventOnce("darkModeInfoUpdate",e)},unbindEvent:e=>{typeof e=="function"?window.a2wWebSide.offEvent("darkModeInfoUpdate",e):window.a2wWebSide.offEvent("darkModeInfoUpdate")}},G={bindEvent:e=>{window.a2wWebSide.onEvent("permissionChange",e)},bindEventOnce:e=>{window.a2wWebSide.onEventOnce("permissionChange",e)},unbindEvent:e=>{typeof e=="function"?window.a2wWebSide.offEvent("permissionChange",e):window.a2wWebSide.offEvent("permissionChange")}},M={bindEvent:e=>{window.a2wWebSide.onEvent("privacyModalResponse",e)},bindEventOnce:e=>{window.a2wWebSide.onEventOnce("privacyModalResponse",e)},unbindEvent:e=>{typeof e=="function"?window.a2wWebSide.offEvent("privacyModalResponse",e):window.a2wWebSide.offEvent("privacyModalResponse")}},V={exec:e=>{const[n,a,t,s]=[e.title||document.title||"",e.cont||document.description||"",e.url||window.location.href||"",e.icon||null];a2w.setShareConfig(n,a,t),window.a2wWebSide.getShareConf=function(){return{title:n,cont:a,url:t,icon:s}}}},F={exec:e=>{const n={};e.title&&(n.title=e.title),e.cont&&(n.cont=e.cont),e.url&&(n.url=e.url),e.icon&&(n.icon=e.icon),a2w.share(JSON.stringify(n))}},T={exec:e=>{if(typeof e.img!="string"||e.img.split(",").length!==2)if(typeof e.img=="string"&&(e.img.startsWith("http")||e.img.startsWith("//"))){w.getImgBase64Async(e.img,a=>{const t={title:e.cont||"",cont:e.cont||"",imgData:a.split(",")[1],imgDataPrefix:a.split(",")[0]};a2w.shareIMG(JSON.stringify(t))});return}else e.img.split(",").length!==2&&console.warn("shareImg失败,原因:shareImg必须指定合法的img参数内容");const n={title:e.cont||"",cont:e.cont||"",imgData:e.img.split(",")[1],imgDataPrefix:e.img.split(",")[0]};a2w.shareIMG(JSON.stringify(n))}},k={exec:()=>{a2w.showLogin()}},H={exec:()=>{a2w.loginByWeibo()}},j={exec:e=>{e&&typeof e.confirmText=="string"?a2w.logout(e.confirmText):a2w.logout("")}},K={exec:()=>{a2w.logout("disable")}},$={exec:e=>{!e||typeof e.eventKey!="string"?console.warn("sima日志上报失败,原因:logSima参数有误,请查阅文档"):typeof e.eventAttribute!="object"&&(e.eventAttribute={});const n={source:"all",ref:"all",data:Y({title:document.title,url:location.href,url_key:location.href.replace(/\?.+/gi,"").replace(/\#.+/gi,"")},e.eventAttribute)};typeof a2w!="undefined"?typeof a2w.sendFinanceAppEvent!="undefined"?a2w.sendFinanceAppEvent("sima",e.eventKey,JSON.stringify(n)):typeof a2w.exec!="undefined"&&a2w.exec("reported",'["sima","'+e.eventKey+'",'+JSON.stringify(n)+"]",""):console.warn("sima日志上报失败,原因:a2w暂不存在")}};function Y(e,n){for(const a in n)e[a]=n[a];return JSON.parse(JSON.stringify(e))}const X={exec:e=>{if(typeof a2w!="undefined")if(typeof e=="object"){const{url:n}=e;typeof n=="string"?a2w.onBackPressedByJs(n):a2w.onBackPressedByJs()}else a2w.onBackPressedByJs()}},z={exec:e=>{e.isPrevent===!1?delete window.a2wWebSide.webViewWillGoback:window.a2wWebSide.webViewWillGoback=()=>{e.onPrevented&&e.onPrevented()}}},q={exec:e=>{if(typeof a2w!="undefined")if(typeof e=="object"){const{isPrevent:n}=e;n?a2w.disableSystemPanGesture("1"):a2w.disableSystemPanGesture("0")}else a2w.disableSystemPanGesture(e+"")}},Q={exec:e=>{if(typeof a2w!="undefined"){if(!e||!e.to){console.warn("toPanel 失败,原因:必须指定所前往的目的面板");return}e.to==="settings_notification"&&a2w.openNotification()}}},Z={exec:e=>{a2w.setNativeShareButtonState(1)}},ee={exec:()=>{a2w.setNativeShareButtonState(0)}},ne={exec:()=>{a2w.hiddenTitleBar(!1)}},te={exec:()=>{a2w.hiddenTitleBar(!0)}},oe={exec:e=>{const{type:n,message:a}=e;a2w.dispatchNativeEvent("applyForPermission",JSON.stringify({type:n,message:a}))}},ie={exec:e=>{a2w.webViewUpdateHomeFunctions(JSON.stringify(e))}},se={exec:({key:e,value:n})=>{const a=e.startsWith("SINAH5_")?e:"SINAH5_"+e;a2w.setAPPStorage(a,w.b64Encode(String.raw`${n}`))}},ae={exec:({key:e})=>{const n=e.startsWith("SINAH5_")?e:"SINAH5_"+e;a2w.deleteAPPStorage(n)}},re={exec:({scheme:e,onSuccess:n,onFail:a})=>{const t=w.creatGuid();a2w.dispatchNativeEvent("openAPP",JSON.stringify({scheme:encodeURIComponent(e),openGuid:t})),a2wWebSide.onEvent("openAppResponse",s=>{s.openGuid===t&&(s.status+""=="1"?n&&n():a&&a())})}},de={exec:e=>{const{type:n}=e;if(!isNaN(n))a2w.dispatchNativeEvent("privacyConfirmed",JSON.stringify({type:n}));else throw new Error(`privacyConfirmed 参数 type 错误(当前传入${n})`)}},ce={exec:({type:e,onConfirm:n,onCancel:a})=>{if(isNaN(e))throw new Error(`openPrivacyModal 参数 type 错误(当前传入${e})`);{const t=w.creatGuid();a2w.openPrivacyModal(JSON.stringify({type:e,id:t})),a2wWebSide.onEvent("privacyModalResponse",s=>{s.id===t&&(s.result===!0?n&&n():a&&a())})}}},we={exec:e=>{const n=e.panel;if(typeof n!="string")throw new Error("toExtPanel 参数错误,panel必须为字符串类型");a2w.dispatchNativeEvent("toExtPanel",JSON.stringify({panel:n}))}},pe={exec:e=>a2w.webViewGetUserInfo(),addCallBack:e=>{window.a2wWebSide.onEventOnce("userInfoGot",e)}},fe={exec:e=>a2w.webViewGetHomeFunctions(),addCallBack:e=>{window.a2wWebSide.onEventOnce("homeShortcutsInfoGot",e)}},le={exec:({key:e,isH5Storage:n=!0})=>{if(typeof e=="string"&&e.trim()!==""){const a=n?"SINAH5_"+e:e,t=a2w.getAPPStorage(a);return t==="NONE_EXIST_KEY"?null:t}else throw new Error("appStorage key必须为有效字符串")},addCallBack:e=>{window.a2wWebSide.onEventOnce("appStorageGot",n=>{const a=n.value==="NONE_EXIST_KEY"?null:w.b64Decode(n.value);e(a)})}},y=(()=>{const e={motion:_,login:x,logout:B,payComplete:C,didAppear:L,didDisappear:R,shareComplete:U,didEnterBackground:J,didEnterForeground:N,darkModeInfoUpdate:D,permissionChange:G,privacyModalResponse:M},n={setShareConfig:V,share:F,shareImg:T,showLogin:k,loginByWeibo:H,confirmLogout:j,silentLogout:K,logSIMA:$,goBack:X,preventGoBack:z,preventIOSPanRight:q,toPanel:Q,showShareBtn:Z,hideShareBtn:ee,showAppBar:ne,hideAppBar:te,applyForPermission:oe,replaceHomeShortcut:ie,setAppStorage:se,deleteAppStorage:ae,openApp:re,privacyConfirmed:de,openPrivacyModal:ce,toExtPanel:we},a={},t={userData:pe,homeShortcuts:fe,appStorage:le},s=navigator.userAgent.toLocaleLowerCase(),p=/android/.test(s)||/xiaomi/.test(s),g=/(ipad|iphone|ipod|itouch)/.test(s)&&!p,A=/(iphone|ipod|itouch)/.test(s)&&!p,W=A||p,o={isInAPP:s.indexOf("sinafinance")>-1,isReady:!!(window.a2w&&window.a2w.getLoginStatus),isIOS:g,isAndroid:p,isIphone:A,isMobile:W,version:"1.2.5",appVersion:w.getVersion(),actionList:Object.keys(n),eventList:Object.keys(e),asyncInfoList:Object.keys(t)},r=()=>JSON.parse(JSON.stringify(o));let i=!0;const c=d=>{o.isIOS?i?(d(),i=!1,setTimeout(()=>i=!0,20)):setTimeout(()=>{c(d)},20):d()},f=[],S=d=>{typeof d!="function"&&console.warn("onJSBridgeReady 参数 必须是 Funtion 类型"),o.isReady?c(d):f.push(d)};if(!o.isReady){const d=setInterval(()=>{window.a2w&&window.a2w.getLoginStatus&&(o.isReady=!0,f.forEach(v=>{c(v)}),clearInterval(d))},50)}return{getState:r,utils:w,onJSBridgeReady:S,onEvent:(d,v)=>{o.isInAPP?d in e?e[d].bindEvent(v):console.warn("该事件不存在"):console.warn("执行失败,请在APP内置webview使用APP JSBridge")},onEventOnce:(d,v)=>{o.isInAPP?d in e?e[d].bindEventOnce(v):console.warn("该事件不存在"):console.warn("执行失败,请在APP内置webview使用APP JSBridge")},offEvent:(d,v)=>{o.isInAPP?d in e?e[d].unbindEvent(v):console.warn("该事件不存在"):console.warn("执行失败,请在APP内置webview使用APP JSBridge")},invokeAction:(d,v,...P)=>{o.isInAPP?S(()=>{d in n?n[d].exec(v,...P):console.warn(`${d} 不在支持的actions清单内`)}):console.warn("执行失败,请在APP内置webview使用APP JSBridge")},getInfo:(d,v)=>{if(o.isInAPP)if(o.isReady){if(d in a)return t[d].exec(v);throw new Error("该info并未支持")}else throw new Error("执行getInfo失败,JSBridge尚未初始化完成");else console.warn("执行失败,请在APP内置webview使用APP JSBridge")},getInfoAsync:(d,v,P)=>{o.isInAPP?S(()=>{d in t?(t[d].addCallBack(v),t[d].exec(P)):console.warn(`infoName:${d}不存在`)}):console.warn("执行失败,请在APP内置webview使用APP JSBridge")}}})();window.SFJSBridge||(E(),window.SFJSBridge=y,y.getState().isInAPP&&y.invokeAction("logSIMA",{eventKey:"h5_app_open"}))});