@bi-nova/ui-taro 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ad/index.d.mts +11 -5
- package/dist/ad/index.d.ts +11 -5
- package/dist/ad/index.js +1 -1
- package/dist/ad/index.mjs +1 -1
- package/package.json +1 -1
package/dist/ad/index.d.mts
CHANGED
|
@@ -5,7 +5,7 @@ import React from 'react';
|
|
|
5
5
|
* @Author wutao
|
|
6
6
|
* @Date 2026-04-14
|
|
7
7
|
* @LastEditors wutao
|
|
8
|
-
* @LastEditTime 2026-
|
|
8
|
+
* @LastEditTime 2026-09-07 18:12:19
|
|
9
9
|
*/
|
|
10
10
|
/**
|
|
11
11
|
* 广告提供方类型
|
|
@@ -77,7 +77,7 @@ interface BiDisplayCustomAd$1 extends BiBaseCustomAd {
|
|
|
77
77
|
poster?: string;
|
|
78
78
|
bottomImage?: string;
|
|
79
79
|
fitMode?: 'contain' | 'cover';
|
|
80
|
-
jumpType?: 'miniProgram' | 'internal' | 'web' | 'none';
|
|
80
|
+
jumpType?: 'miniProgram' | 'internal' | 'web' | 'api' | 'none';
|
|
81
81
|
targetAppId?: string;
|
|
82
82
|
targetPath?: string;
|
|
83
83
|
jumpUrl?: string;
|
|
@@ -111,7 +111,7 @@ interface BiDisplayCustomAd$1 extends BiBaseCustomAd {
|
|
|
111
111
|
* @Author wutao
|
|
112
112
|
* @Date 2026-04-14
|
|
113
113
|
* @LastEditors wutao
|
|
114
|
-
* @LastEditTime 2026-
|
|
114
|
+
* @LastEditTime 2026-09-07 18:12:19
|
|
115
115
|
*/
|
|
116
116
|
|
|
117
117
|
/** 自定义 Banner 广告数据 */
|
|
@@ -141,6 +141,8 @@ interface BiBannerAdProps {
|
|
|
141
141
|
customAd?: BiBannerCustomAd | null;
|
|
142
142
|
priority?: DisplayAdPriority;
|
|
143
143
|
adIntervals?: number;
|
|
144
|
+
equipmentValue?: string;
|
|
145
|
+
userId?: number;
|
|
144
146
|
className?: string;
|
|
145
147
|
onLoad?: (detail: BiBannerAdEventDetail | Record<string, unknown>) => void;
|
|
146
148
|
onError?: (detail: BiBannerAdEventDetail | Record<string, unknown>) => void;
|
|
@@ -157,7 +159,7 @@ declare const BiBannerAd: React.FC<BiBannerAdProps>;
|
|
|
157
159
|
* @Author wutao
|
|
158
160
|
* @Date 2026-04-14
|
|
159
161
|
* @LastEditors wutao
|
|
160
|
-
* @LastEditTime 2026-
|
|
162
|
+
* @LastEditTime 2026-09-07 18:12:19
|
|
161
163
|
*/
|
|
162
164
|
|
|
163
165
|
/** 自定义开屏广告数据 */
|
|
@@ -184,6 +186,8 @@ interface BiSplashAdProps {
|
|
|
184
186
|
pictureInPicture?: boolean;
|
|
185
187
|
checkNativeSplash?: boolean;
|
|
186
188
|
jumpSeconds?: number;
|
|
189
|
+
equipmentValue?: string;
|
|
190
|
+
userId?: number;
|
|
187
191
|
className?: string;
|
|
188
192
|
onLoad?: (detail: BiSplashAdEventDetail | Record<string, unknown>) => void;
|
|
189
193
|
onError?: (detail: BiSplashAdEventDetail | Record<string, unknown>) => void;
|
|
@@ -200,7 +204,7 @@ declare const BiSplashAd: React.FC<BiSplashAdProps>;
|
|
|
200
204
|
* @Author wutao
|
|
201
205
|
* @Date 2026-04-14
|
|
202
206
|
* @LastEditors wutao
|
|
203
|
-
* @LastEditTime 2026-
|
|
207
|
+
* @LastEditTime 2026-09-07 18:12:19
|
|
204
208
|
*/
|
|
205
209
|
|
|
206
210
|
/**
|
|
@@ -257,6 +261,8 @@ interface BiDisplayAdProps {
|
|
|
257
261
|
checkNativeSplash?: boolean;
|
|
258
262
|
nativeSplashCache?: boolean;
|
|
259
263
|
jumpSeconds?: number;
|
|
264
|
+
equipmentValue?: string;
|
|
265
|
+
userId?: number;
|
|
260
266
|
className?: string;
|
|
261
267
|
onLoad?: (detail: BiDisplayAdEventDetail) => void;
|
|
262
268
|
onError?: (detail: BiDisplayAdEventDetail) => void;
|
package/dist/ad/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import React from 'react';
|
|
|
5
5
|
* @Author wutao
|
|
6
6
|
* @Date 2026-04-14
|
|
7
7
|
* @LastEditors wutao
|
|
8
|
-
* @LastEditTime 2026-
|
|
8
|
+
* @LastEditTime 2026-09-07 18:12:19
|
|
9
9
|
*/
|
|
10
10
|
/**
|
|
11
11
|
* 广告提供方类型
|
|
@@ -77,7 +77,7 @@ interface BiDisplayCustomAd$1 extends BiBaseCustomAd {
|
|
|
77
77
|
poster?: string;
|
|
78
78
|
bottomImage?: string;
|
|
79
79
|
fitMode?: 'contain' | 'cover';
|
|
80
|
-
jumpType?: 'miniProgram' | 'internal' | 'web' | 'none';
|
|
80
|
+
jumpType?: 'miniProgram' | 'internal' | 'web' | 'api' | 'none';
|
|
81
81
|
targetAppId?: string;
|
|
82
82
|
targetPath?: string;
|
|
83
83
|
jumpUrl?: string;
|
|
@@ -111,7 +111,7 @@ interface BiDisplayCustomAd$1 extends BiBaseCustomAd {
|
|
|
111
111
|
* @Author wutao
|
|
112
112
|
* @Date 2026-04-14
|
|
113
113
|
* @LastEditors wutao
|
|
114
|
-
* @LastEditTime 2026-
|
|
114
|
+
* @LastEditTime 2026-09-07 18:12:19
|
|
115
115
|
*/
|
|
116
116
|
|
|
117
117
|
/** 自定义 Banner 广告数据 */
|
|
@@ -141,6 +141,8 @@ interface BiBannerAdProps {
|
|
|
141
141
|
customAd?: BiBannerCustomAd | null;
|
|
142
142
|
priority?: DisplayAdPriority;
|
|
143
143
|
adIntervals?: number;
|
|
144
|
+
equipmentValue?: string;
|
|
145
|
+
userId?: number;
|
|
144
146
|
className?: string;
|
|
145
147
|
onLoad?: (detail: BiBannerAdEventDetail | Record<string, unknown>) => void;
|
|
146
148
|
onError?: (detail: BiBannerAdEventDetail | Record<string, unknown>) => void;
|
|
@@ -157,7 +159,7 @@ declare const BiBannerAd: React.FC<BiBannerAdProps>;
|
|
|
157
159
|
* @Author wutao
|
|
158
160
|
* @Date 2026-04-14
|
|
159
161
|
* @LastEditors wutao
|
|
160
|
-
* @LastEditTime 2026-
|
|
162
|
+
* @LastEditTime 2026-09-07 18:12:19
|
|
161
163
|
*/
|
|
162
164
|
|
|
163
165
|
/** 自定义开屏广告数据 */
|
|
@@ -184,6 +186,8 @@ interface BiSplashAdProps {
|
|
|
184
186
|
pictureInPicture?: boolean;
|
|
185
187
|
checkNativeSplash?: boolean;
|
|
186
188
|
jumpSeconds?: number;
|
|
189
|
+
equipmentValue?: string;
|
|
190
|
+
userId?: number;
|
|
187
191
|
className?: string;
|
|
188
192
|
onLoad?: (detail: BiSplashAdEventDetail | Record<string, unknown>) => void;
|
|
189
193
|
onError?: (detail: BiSplashAdEventDetail | Record<string, unknown>) => void;
|
|
@@ -200,7 +204,7 @@ declare const BiSplashAd: React.FC<BiSplashAdProps>;
|
|
|
200
204
|
* @Author wutao
|
|
201
205
|
* @Date 2026-04-14
|
|
202
206
|
* @LastEditors wutao
|
|
203
|
-
* @LastEditTime 2026-
|
|
207
|
+
* @LastEditTime 2026-09-07 18:12:19
|
|
204
208
|
*/
|
|
205
209
|
|
|
206
210
|
/**
|
|
@@ -257,6 +261,8 @@ interface BiDisplayAdProps {
|
|
|
257
261
|
checkNativeSplash?: boolean;
|
|
258
262
|
nativeSplashCache?: boolean;
|
|
259
263
|
jumpSeconds?: number;
|
|
264
|
+
equipmentValue?: string;
|
|
265
|
+
userId?: number;
|
|
260
266
|
className?: string;
|
|
261
267
|
onLoad?: (detail: BiDisplayAdEventDetail) => void;
|
|
262
268
|
onError?: (detail: BiDisplayAdEventDetail) => void;
|
package/dist/ad/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var ct=Object.create;var xe=Object.defineProperty,ut=Object.defineProperties,dt=Object.getOwnPropertyDescriptor,pt=Object.getOwnPropertyDescriptors,mt=Object.getOwnPropertyNames,ze=Object.getOwnPropertySymbols,gt=Object.getPrototypeOf,Qe=Object.prototype.hasOwnProperty,ft=Object.prototype.propertyIsEnumerable;var Xe=(e,r,n)=>r in e?xe(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n,y=(e,r)=>{for(var n in r||(r={}))Qe.call(r,n)&&Xe(e,n,r[n]);if(ze)for(var n of ze(r))ft.call(r,n)&&Xe(e,n,r[n]);return e},F=(e,r)=>ut(e,pt(r));var ht=(e,r)=>{for(var n in r)xe(e,n,{get:r[n],enumerable:!0})},Ze=(e,r,n,h)=>{if(r&&typeof r=="object"||typeof r=="function")for(let D of mt(r))!Qe.call(e,D)&&D!==n&&xe(e,D,{get:()=>r[D],enumerable:!(h=dt(r,D))||h.enumerable});return e};var Je=(e,r,n)=>(n=e!=null?ct(gt(e)):{},Ze(r||!e||!e.__esModule?xe(n,"default",{value:e,enumerable:!0}):n,e)),yt=e=>Ze(xe({},"__esModule",{value:!0}),e);var Et={};ht(Et,{BiBannerAd:()=>$e,BiDisplayAd:()=>lt,BiSplashAd:()=>je});module.exports=yt(Et);var qt=require("./banner/index.scss"),zt=require("./splash/index.scss");var B=require("react"),te=require("@tarojs/components"),at=Je(require("@tarojs/taro"));var Bt=Je(require("@tarojs/components")),ke;function Fe(){if(ke!==void 0)return ke;try{let e=Bt;ke=(e==null?void 0:e.AdCustom)||null}catch(e){ke=null}return ke}var Re=Je(require("@tarojs/taro"));function Ue(){return typeof wx!="undefined"?wx:null}function Be(e,r){let n=e==null?void 0:e.detail;return n&&typeof n=="object"?y(y({},r),n):e&&typeof e=="object"?y(y({},r),e):y({},r)}function et(e){return e?e.mediaType==="video"?e.video||"":e.mediaType==="image"?e.image||"":e.video||e.image||"":""}function tt(e,r=""){return e&&(e.poster||e.image||r)||""}function rt(e,r=""){return e?e.mediaType==="video"?!1:e.mediaType==="image"?!0:e.video?!1:e.image?!0:/\.(jpg|jpeg|png|gif|bmp|webp|svg|ico)$/i.test(String(r).trim()):!0}function nt(e){return String((e==null?void 0:e.fitMode)||"").trim().toLowerCase()==="contain"?"contain":"cover"}function Ve(e){return e&&(e.badgeText||e.adLabel)||"\u5E7F\u544A"}function it(e,r=5){let n=e==null?void 0:e.jumpSeconds,h=n!=null?n:r;return Math.min(99,Math.max(0,Number(h)||0))}function We(e){var n;let r=(n=e==null?void 0:e.loadTimeout)!=null?n:e==null?void 0:e.timeout;return Math.max(1e3,Number(r)||5e3)}function At(e,r=!1){var n,h,D,b;if(!e)return"none";if(r){let R=String(((n=e.action)==null?void 0:n.type)||e.jumpType||"").trim().toLowerCase();if(R==="miniprogram")return"miniProgram";if(R==="internal")return"internal";if(R==="web")return"web";if(R==="none")return"none"}return r&&((h=e.action)!=null&&h.appId||e.targetAppId)||e.appId||e.miniProgramAppId||e.jumpAppId?"miniProgram":r&&((D=e.action)!=null&&D.path||e.targetPath)||e.path||e.pagePath||e.jumpPath||e.targetUrl?"internal":r&&((b=e.action)!=null&&b.url||e.jumpUrl)||e.url||e.webUrl||e.h5Url?"web":"none"}function St(e,r=!1){var n;return e&&((r?((n=e.action)==null?void 0:n.appId)||e.targetAppId:"")||e.appId||e.miniProgramAppId||e.jumpAppId)||""}function Dt(e,r=!1){var n;return e&&((r?((n=e.action)==null?void 0:n.path)||e.targetPath:"")||e.path||e.pagePath||e.jumpPath||e.targetUrl)||""}function Ct(e,r=!1){var h;if(!e)return"full";let n=(r?(h=e.action)==null?void 0:h.miniProgramOpenMode:"")||e.miniProgramOpenMode;return String(n||"").trim().toLowerCase()==="half"?"half":"full"}function vt(e,r=!1){var n;return e&&((r?((n=e.action)==null?void 0:n.url)||e.jumpUrl:"")||e.url||e.webUrl||e.h5Url)||""}function He(e){let{customAd:r,actionDetail:n,onOpenWebview:h,onError:D,miniProgramErrorCode:b,navigateErrorCode:R,miniProgramUnsupportedErrorCode:re,preferStandardFields:j=!1}=e;if(!r)return;let E=At(r,j),ee=St(r,j),W=Dt(r,j),g=vt(r,j);if(E==="miniProgram"&&ee){let p=Ue(),q=Ct(r,j),I=q==="half"?p==null?void 0:p.openEmbeddedMiniProgram:p==null?void 0:p.navigateToMiniProgram;if(!p||typeof I!="function"){D==null||D(F(y({},n),{errCode:re||b,errMsg:q==="half"?"\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u534A\u5C4F\u6253\u5F00\u5176\u4ED6\u5C0F\u7A0B\u5E8F":"\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u8DF3\u8F6C\u5230\u5176\u4ED6\u5C0F\u7A0B\u5E8F"}));return}I.call(p,{appId:ee,path:W||"",fail:u=>{D==null||D(F(y({},n),{errCode:b,errMsg:(u==null?void 0:u.errMsg)||"\u8DF3\u8F6C\u5230\u5176\u4ED6\u5C0F\u7A0B\u5E8F\u5931\u8D25"}))}});return}if(E==="internal"&&W){Re.navigateTo({url:W,fail:p=>{D==null||D(F(y({},n),{errCode:R,errMsg:(p==null?void 0:p.errMsg)||"\u9875\u9762\u8DF3\u8F6C\u5931\u8D25"}))}});return}E==="web"&&g&&(h==null||h(F(y({},n),{url:g})))}function ot(){var I;let e=Ue(),r=e&&typeof e.getMenuButtonBoundingClientRect=="function"?e.getMenuButtonBoundingClientRect():{},n=e&&typeof e.getWindowInfo=="function"?e.getWindowInfo():typeof Re.getSystemInfoSync=="function"?Re.getSystemInfoSync():{},h=Number(n.windowHeight||0),D=Number(n.screenHeight||0),b=!!(h&&D&&h===D),R=16,re=16,j=16,E=32,ee=b&&r.top?r.top:Math.max(R,Number(n.statusBarHeight||0)+4),W=b&&r.height?r.height:E,g=b&&r.top?r.top:R,p=b&&r.height?r.height:E,q=Math.max(j,Number(((I=n.safeArea)==null?void 0:I.left)||0)+j);return{isFullScreen:b,skipStyle:{top:`${g}px`,width:"156rpx",height:`${p}px`,lineHeight:`${p}px`,borderRadius:`${Math.round(p/2)}px`,left:b?`${j}px`:void 0,right:b?void 0:`${re}px`},disclosureStyle:{top:`${g}px`,left:`${q}px`,height:`${p}px`,lineHeight:`${p}px`},combinedControlStyle:{top:`${ee}px`,left:`${q}px`,height:`${W}px`}}}var Y=require("react/jsx-runtime"),wt=[{label:"\u4E0E\u6211\u65E0\u5173",value:"irrelevant"},{label:"\u91CD\u590D\u6536\u5230\u591A\u6B21",value:"repeated"},{label:"\u5185\u5BB9\u592A\u5DEE",value:"poorContent"}];function bt(e,r,n){return e&&r?n==="custom-first"||n==="custom-only"?"custom":"wechat":e?"wechat":r?"custom":null}var $e=({unitId:e="",customAd:r,priority:n="wechat-first",adIntervals:h=30,className:D,onLoad:b,onError:R,onClose:re,onAction:j,onFeedback:E,onOpenWebview:ee})=>{let W=(0,B.useMemo)(()=>Fe(),[]),g=r||null,p=!!(g!=null&&g.image),q=!!(e&&W),I=bt(q,p,n),u=JSON.stringify([e,g,n,!!W]),[J,he]=(0,B.useState)(!!I),[z,ce]=(0,B.useState)(I),[ie,Ae]=(0,B.useState)(!1),[ue,X]=(0,B.useState)("primary"),k=(0,B.useRef)(I),L=(0,B.useRef)({wechat:!1,custom:!1}),O=(0,B.useRef)(!1),G=(0,B.useRef)(null),_=(0,B.useRef)(b),f=(0,B.useRef)(R),C=(0,B.useRef)(re),de=(0,B.useRef)(j),N=(0,B.useRef)(E),K=(0,B.useRef)(ee);(0,B.useEffect)(()=>{_.current=b,f.current=R,C.current=re,de.current=j,N.current=E,K.current=ee},[j,re,R,E,b,ee]);let M=(0,B.useCallback)(o=>{let s=o==="custom"&&g?{configId:g.configId,placementId:g.placementId,configName:g.configName,advertPlatform:g.advertPlatform}:{};return y({provider:o,type:"banner"},s)},[g]),v=(0,B.useCallback)(()=>{G.current&&(clearTimeout(G.current),G.current=null)},[]),Q=(0,B.useCallback)(()=>{Ae(!1),X("primary")},[]),pe=(0,B.useCallback)(o=>{v(),k.current=o,O.current=!1,ce(o),he(!0),Q()},[v,Q]),me=(0,B.useCallback)((o,s)=>{var $;let m=!!e&&p?"allProvidersFailed":o==="wechat"?"wechatAdLoadFail":"customMediaLoadFail";v(),k.current=null,ce(null),he(!1),Q(),($=C.current)==null||$.call(C,{provider:o,type:"banner",reason:m,error:s})},[v,Q,p,e]),ge=(0,B.useCallback)((o,s,d,m)=>{var ve;if(k.current!=="custom"||L.current.custom)return;v();let $=Be(o,M("custom")),ae=F(y({},$),{errorType:s,errCode:d,errMsg:m,mediaType:"image",rawErrCode:$.errCode,rawErrMsg:$.errMsg});if(L.current.custom=!0,(ve=f.current)==null||ve.call(f,ae),q&&!L.current.wechat){pe("wechat");return}me("custom",ae)},[q,v,M,me,pe]);(0,B.useEffect)(()=>(v(),L.current={wechat:!1,custom:!1},O.current=!1,k.current=I,ce(I),he(!!I),Q(),v),[v,Q,u,I]),(0,B.useEffect)(()=>{if(v(),!(!J||z!=="custom"||!p))return G.current=setTimeout(()=>{O.current||k.current!=="custom"||ge(void 0,"CUSTOM_MEDIA_LOAD_TIMEOUT","BI_BANNER_CUSTOM_MEDIA_LOAD_TIMEOUT","Banner \u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u8D85\u65F6")},We(g)),v},[v,ge,p,z,g,J]),(0,B.useEffect)(()=>{var s,d;if(!e||W)return;let o=F(y({},M("wechat")),{errCode:"BI_BANNER_NATIVE_AD_UNSUPPORTED",errMsg:"\u5F53\u524D\u7AEF\u4E0D\u652F\u6301\u5FAE\u4FE1\u539F\u751F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7EC4\u4EF6"});(s=f.current)==null||s.call(f,o),p||(d=C.current)==null||d.call(C,F(y({},M("wechat")),{reason:"wechatAdLoadFail",error:o}))},[W,M,p,e]);let U=o=>{var s;k.current==="wechat"&&((s=_.current)==null||s.call(_,Be(o,M("wechat"))))},V=o=>{var m;if(k.current!=="wechat"||L.current.wechat)return;let s=o!=null&&o.detail&&typeof o.detail=="object"?o.detail:{},d=F(y({},Be(o,M("wechat"))),{errCode:"BI_BANNER_WECHAT_AD_LOAD_FAIL",errMsg:String(s.errMsg||"\u5FAE\u4FE1 Banner \u5E7F\u544A\u52A0\u8F7D\u5931\u8D25"),rawErrCode:s.errCode,rawErrMsg:s.errMsg});if(L.current.wechat=!0,(m=f.current)==null||m.call(f,d),p&&!L.current.custom){pe("custom");return}me("wechat",d)},oe=o=>{var s;k.current==="wechat"&&((s=C.current)==null||s.call(C,Be(o,M("wechat"))))},H=()=>{var o;k.current!=="custom"||O.current||(v(),O.current=!0,(o=_.current)==null||o.call(_,M("custom")))},Se=()=>{var s;if(ie){Q();return}let o=M("custom");(s=de.current)==null||s.call(de,o),He({customAd:g,actionDetail:o,onOpenWebview:d=>{var m;return(m=K.current)==null?void 0:m.call(K,d)},onError:d=>{var m;return(m=f.current)==null?void 0:m.call(f,d)},miniProgramErrorCode:"BI_BANNER_NAVIGATE_MINI_PROGRAM_FAIL",navigateErrorCode:"BI_BANNER_NAVIGATE_FAIL",preferStandardFields:!0})},Ee=o=>{var s;(s=o.stopPropagation)==null||s.call(o),Ae(d=>!d),X("primary")},De=o=>{var s;(s=o.stopPropagation)==null||s.call(o)},ye=o=>{var s,d;(s=o.stopPropagation)==null||s.call(o),Q(),(d=N.current)==null||d.call(N,F(y({},M("custom")),{provider:"custom",action:"report"})),at.showToast({title:"\u5DF2\u6536\u5230\u60A8\u7684\u53CD\u9988\uFF0C\u6211\u4EEC\u4F1A\u5C3D\u5FEB\u5904\u7406~",icon:"none",duration:2e3})},fe=(o,s)=>{var m,$,ae;(m=o.stopPropagation)==null||m.call(o);let d=F(y({},M("custom")),{provider:"custom",action:"dislike",reason:s.value,reasonText:s.label});v(),k.current=null,ce(null),he(!1),Q(),($=N.current)==null||$.call(N,d),(ae=C.current)==null||ae.call(C,F(y({},M("custom")),{reason:"notInterested",feedbackReason:s.value,feedbackReasonText:s.label}))},Ce=`bi-banner-ad${D?` ${D}`:""}`;return!J||!z?null:z==="wechat"&&W?(0,Y.jsx)(W,{className:Ce,unitId:e,adIntervals:h,onLoad:U,onError:V,onClose:oe}):z!=="custom"||!(g!=null&&g.image)?null:(0,Y.jsxs)(te.View,{className:Ce,children:[(0,Y.jsx)(te.View,{className:"bi-banner-ad__surface",onClick:Se,children:(0,Y.jsx)(te.Image,{className:"bi-banner-ad__image",src:g.image,mode:"widthFix",onLoad:H,onError:o=>ge(o,"CUSTOM_MEDIA_LOAD_FAIL","BI_BANNER_CUSTOM_MEDIA_LOAD_FAIL","Banner \u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u5931\u8D25")})}),(0,Y.jsxs)(te.View,{className:"bi-banner-ad__badge",onClick:Ee,children:[(0,Y.jsx)(te.Text,{children:Ve(g)}),(0,Y.jsx)(te.View,{className:"bi-banner-ad__badge-arrow"})]}),ie?(0,Y.jsx)(te.View,{className:"bi-banner-ad__feedback-panel",onClick:De,children:ue==="primary"?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(te.View,{className:"bi-banner-ad__feedback-source",children:"\u7531\u8D5E\u52A9\u5546\u63D0\u4F9B\u7684\u5185\u5BB9"}),(0,Y.jsx)(te.View,{className:"bi-banner-ad__feedback-item",onClick:o=>{var s;(s=o.stopPropagation)==null||s.call(o),X("dislike")},children:"\u4E0D\u611F\u5174\u8DA3"}),(0,Y.jsx)(te.View,{className:"bi-banner-ad__feedback-item",onClick:ye,children:"\u53CD\u9988\u95EE\u9898"})]}):wt.map(o=>(0,Y.jsx)(te.View,{className:"bi-banner-ad__feedback-item",onClick:s=>fe(s,o),children:o.label},o.value))}):null]})};var l=require("react"),A=require("@tarojs/components");var S=require("react/jsx-runtime");function _t(e,r,n){return e&&r?n==="custom-first"||n==="custom-only"?"custom":"wechat":e?"wechat":r?"custom":null}var je=({unitId:e="",customAd:r,priority:n="wechat-first",show:h=!0,zIndex:D=999,pictureInPicture:b=!1,checkNativeSplash:R=!0,jumpSeconds:re=5,className:j,onLoad:E,onError:ee,onClose:W,onAction:g,onHide:p,onOpenWebview:q})=>{let I=(0,l.useMemo)(()=>Fe(),[]),u=r||null,J=(0,l.useMemo)(()=>et(u),[u]),he=(0,l.useMemo)(()=>tt(u,J),[J,u]),z=(0,l.useMemo)(()=>rt(u,J),[J,u]),ce=(0,l.useMemo)(()=>nt(u),[u]),ie=(0,l.useMemo)(()=>it(u,re),[re,u]),Ae=(0,l.useMemo)(()=>Ve(u),[u]),ue=(0,l.useMemo)(()=>ot(),[]),X=!!(e&&I),k=!!(J||u!=null&&u.mediaType),L=!!J,O=_t(X,k,n),G=JSON.stringify([e,u,n,!!I]),[_,f]=(0,l.useState)(!1),[C,de]=(0,l.useState)(O),[N,K]=(0,l.useState)(!1),[M,v]=(0,l.useState)(0),[Q,pe]=(0,l.useState)(!1),[me,ge]=(0,l.useState)(!1),U=(0,l.useRef)(O),V=(0,l.useRef)({wechat:!1,custom:!1}),oe=(0,l.useRef)(!1),H=(0,l.useRef)(!1),Se=(0,l.useRef)(!1),Ee=(0,l.useRef)({identity:G,show:!1}),De=(0,l.useRef)(0),ye=(0,l.useRef)(null),fe=(0,l.useRef)(null),Ce=(0,l.useRef)(null),o=(0,l.useRef)(null),s=(0,l.useRef)(E),d=(0,l.useRef)(ee),m=(0,l.useRef)(W),$=(0,l.useRef)(g),ae=(0,l.useRef)(p),ve=(0,l.useRef)(q);(0,l.useEffect)(()=>{s.current=E,d.current=ee,m.current=W,$.current=g,ae.current=p,ve.current=q},[g,W,ee,p,E,q]),(0,l.useEffect)(()=>{var t;!h||!e||I||(t=d.current)==null||t.call(d,{provider:"wechat",type:"splash",errCode:"BI_SPLASH_NATIVE_AD_UNSUPPORTED",errMsg:"\u5F53\u524D\u7AEF\u4E0D\u652F\u6301\u5FAE\u4FE1\u539F\u751F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7EC4\u4EF6"})},[I,h,e]);let ne=t=>{let c=t==="custom"&&u?{configId:u.configId,placementId:u.placementId,configName:u.configName,advertPlatform:u.advertPlatform}:{};return y({provider:t,type:"splash"},c)},x=(0,l.useCallback)(()=>{ye.current&&clearInterval(ye.current),fe.current&&clearTimeout(fe.current),Ce.current&&clearTimeout(Ce.current),o.current&&clearTimeout(o.current),ye.current=null,fe.current=null,Ce.current=null,o.current=null},[]),se=(0,l.useCallback)((t,c)=>{x(),U.current=t,oe.current=!1,de(t),f(c),K(!1),v(ie),pe(!1),ge(!1)},[x,ie]),be=(0,l.useCallback)((t,c)=>{var Me;let Pe=k&&(t==="custom"||X&&V.current.wechat&&V.current.custom),Ie=Pe?"allProvidersFailed":"wechatAdLoadFail";x(),f(!1),K(!1),v(0),pe(!1),ge(!1),(Me=m.current)==null||Me.call(m,{provider:Pe?"none":t,type:"splash",reason:Ie,error:c})},[X,x,k]),we=(0,l.useCallback)(()=>{if(!(ye.current||!U.current)){if(pe(!0),ie<=0){v(0);return}v(ie),ye.current=setInterval(()=>{v(t=>Math.max(0,t-1))},1e3)}},[ie]),Ne=(0,l.useCallback)(()=>{L&&(fe.current=setTimeout(()=>{var c;if(oe.current||U.current!=="custom")return;let t=F(y({},ne("custom")),{errorType:"CUSTOM_MEDIA_LOAD_TIMEOUT",errCode:"BI_SPLASH_CUSTOM_MEDIA_LOAD_TIMEOUT",errMsg:"\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u8D85\u65F6",mediaType:z?"image":"video",rawErrCode:void 0,rawErrMsg:void 0});(c=d.current)==null||c.call(d,t),V.current.custom=!0,X&&!V.current.wechat?(se("wechat",!0),we()):be("custom",t)},We(u)))},[X,be,L,z,se,u,we]),_e=(0,l.useCallback)(t=>{se(t,!0),t==="wechat"?we():L&&Ne()},[L,se,we,Ne]),Te=(0,l.useCallback)((t,c,T,w)=>{var Me;if(U.current!=="custom"||V.current.custom)return;let Pe=Be(t,ne("custom")),Ie=F(y({},Pe),{errorType:c,errCode:T,errMsg:w,mediaType:z?"image":"video",rawErrCode:Pe.errCode,rawErrMsg:Pe.errMsg});(Me=d.current)==null||Me.call(d,Ie),V.current.custom=!0,X&&!V.current.wechat?_e("wechat"):be("custom",Ie)},[X,be,z,_e]),le=(0,l.useCallback)(()=>{var t;if(H.current){f(!1);return}if(!O){se(null,!1),Se.current||(Se.current=!0,(t=m.current)==null||t.call(m,{provider:"none",type:"splash",reason:"noAd"}));return}_e(O),O==="custom"&&!L&&Te(void 0,"CUSTOM_MEDIA_LOAD_FAIL","BI_SPLASH_CUSTOM_MEDIA_LOAD_FAIL","\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u4E3B\u7D20\u6750\u5730\u5740\u4E3A\u7A7A")},[Te,L,O,se,_e]),Le=(0,l.useCallback)(()=>{if(!h||H.current)return;if(!R){le();return}let t=Ue();if(!(t!=null&&t.getShowSplashAdStatus)||De.current>=3){le();return}t.getShowSplashAdStatus({success:c=>{var T;if((c==null?void 0:c.code)===-1){De.current+=1,Ce.current=setTimeout(Le,300);return}if((c==null?void 0:c.code)===1){x(),H.current=!0,f(!1),(T=s.current)==null||T.call(s,{provider:"wechat",type:"splash",nativeSplash:!0});return}le()},fail:le})},[le,R,x,h]);(0,l.useEffect)(()=>{let t=Ee.current,c=h&&!t.show||t.identity!==G;if(Ee.current={identity:G,show:h},!h){H.current=!1,Se.current=!1,V.current={wechat:!1,custom:!1},se(O,!1);return}if(!H.current)return c&&(Se.current=!1),V.current={wechat:!1,custom:!1},H.current=!1,De.current=0,se(O,!1),Le(),x},[Le,x,G,O,se,h]),(0,l.useEffect)(()=>{var c;if(!Q||M!==0||!_||N||!U.current)return;let t=U.current;if(b){x(),ge(!0),o.current=setTimeout(()=>{var T;K(!0),ge(!1),(T=ae.current)==null||T.call(ae,ne(t))},280);return}x(),f(!1),(c=m.current)==null||c.call(m,ne(t))},[x,Q,b,M,N,_]);let Ge=t=>{var c;U.current==="wechat"&&(we(),(c=s.current)==null||c.call(s,Be(t,ne("wechat"))))},Ke=t=>{var w;if(U.current!=="wechat"||V.current.wechat)return;let c=t!=null&&t.detail&&typeof t.detail=="object"?t.detail:{},T=F(y({},Be(t,ne("wechat"))),{errCode:"BI_SPLASH_WECHAT_AD_LOAD_FAIL",errMsg:String(c.errMsg||"\u5FAE\u4FE1\u5F00\u5C4F\u5E7F\u544A\u52A0\u8F7D\u5931\u8D25"),rawErrCode:c.errCode,rawErrMsg:c.errMsg});(w=d.current)==null||w.call(d,T),V.current.wechat=!0,k&&!V.current.custom?(_e("custom"),L||Te(void 0,"CUSTOM_MEDIA_LOAD_FAIL","BI_SPLASH_CUSTOM_MEDIA_LOAD_FAIL","\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u4E3B\u7D20\u6750\u5730\u5740\u4E3A\u7A7A")):be("wechat",T)},Z=()=>{var t;U.current!=="custom"||oe.current||(fe.current&&clearTimeout(fe.current),fe.current=null,oe.current=!0,we(),(t=s.current)==null||t.call(s,ne("custom")))},Ye=t=>{var T;(T=t==null?void 0:t.stopPropagation)==null||T.call(t),U.current&&(pe(!0),v(0))},Oe=()=>{var c;if(U.current!=="custom")return;let t=ne("custom");(c=$.current)==null||c.call($,t),He({customAd:u,actionDetail:t,onOpenWebview:T=>{var w;return(w=ve.current)==null?void 0:w.call(ve,T)},onError:T=>{var w;return(w=d.current)==null?void 0:w.call(d,T)},miniProgramErrorCode:"BI_SPLASH_NAVIGATE_MINI_PROGRAM_FAIL",navigateErrorCode:"BI_SPLASH_NAVIGATE_FAIL",preferStandardFields:!0})},i=t=>{var c;x(),f(!1),K(!1),v(0),pe(!1),(c=m.current)==null||c.call(m,t)},a=["bi-splash-ad",N?"bi-splash-ad--pip":"",me?"bi-splash-ad--pip-animating":"",j||""].filter(Boolean).join(" ");return!_||!C?null:(0,S.jsxs)(A.View,{className:a,style:{zIndex:D},children:[C==="wechat"&&I?(0,S.jsx)(A.View,{className:"bi-splash-ad__popup",children:(0,S.jsx)(A.View,{className:`bi-splash-ad__media-wrapper${N?" bi-splash-ad__media-wrapper--pip":""}`,children:(0,S.jsx)(I,{className:"bi-splash-ad__wechat-unit",unitId:e,onLoad:Ge,onError:Ke,onClose:t=>i(Be(t,ne("wechat")))})})}):C==="custom"&&L?(0,S.jsx)(A.View,{className:"bi-splash-ad__popup bi-splash-ad__custom",children:(0,S.jsxs)(A.View,{className:"bi-splash-ad__media-shell",onClick:Oe,children:[z?(0,S.jsx)(A.Image,{className:"bi-splash-ad__media",src:J,mode:ce==="cover"?"aspectFill":"aspectFit",onLoad:Z,onError:t=>Te(t,"CUSTOM_MEDIA_LOAD_FAIL","BI_SPLASH_CUSTOM_MEDIA_LOAD_FAIL","\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u5931\u8D25")}):(0,S.jsx)(A.Video,{className:"bi-splash-ad__video",src:J,poster:he,autoplay:!0,muted:(u==null?void 0:u.muted)!==!1,loop:!0,objectFit:ce,showCenterPlayBtn:!1,showPlayBtn:!1,controls:!1,onLoadedMetaData:Z,onError:t=>Te(t,"CUSTOM_MEDIA_LOAD_FAIL","BI_SPLASH_CUSTOM_MEDIA_LOAD_FAIL","\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u5931\u8D25")}),N?(0,S.jsx)(A.View,{className:"bi-splash-ad__pip-mask"}):null,!N&&!ue.isFullScreen?(0,S.jsxs)(A.View,{className:"bi-splash-ad__disclosure",style:ue.disclosureStyle,children:[(0,S.jsx)(A.Text,{children:Ae}),(0,S.jsx)(A.View,{className:"bi-splash-ad__disclosure-arrow"})]}):null,!N&&(u!=null&&u.bottomImage)?(0,S.jsx)(A.Image,{className:"bi-splash-ad__bottom-image",src:u.bottomImage,mode:"widthFix"}):null]})}):null,N?(0,S.jsx)(A.View,{className:"bi-splash-ad__pip-close",onClick:()=>i(ne(C)),children:(0,S.jsx)(A.View,{className:"bi-splash-ad__pip-close-text",children:"\u5173\u95ED"})}):null,!N&&ue.isFullScreen&&C==="custom"?(0,S.jsxs)(A.View,{className:"bi-splash-ad__combined-control",style:ue.combinedControlStyle,children:[(0,S.jsxs)(A.View,{className:"bi-splash-ad__combined-capsule",children:[(0,S.jsxs)(A.View,{className:"bi-splash-ad__combined-disclosure",children:[(0,S.jsx)(A.Text,{children:Ae}),(0,S.jsx)(A.View,{className:"bi-splash-ad__disclosure-arrow"})]}),(0,S.jsx)(A.View,{className:"bi-splash-ad__combined-divider"}),(0,S.jsx)(A.View,{className:"bi-splash-ad__combined-skip",onClick:Ye,children:"\u8DF3\u8FC7"})]}),(0,S.jsxs)(A.Text,{className:"bi-splash-ad__combined-countdown",children:[M," \u79D2"]})]}):N?null:(0,S.jsxs)(A.View,{className:"bi-splash-ad__skip",style:ue.skipStyle,onClick:Ye,children:[(0,S.jsxs)(A.Text,{children:[M,"s"]}),(0,S.jsx)(A.View,{className:"bi-splash-ad__skip-divider"}),(0,S.jsx)(A.Text,{className:"bi-splash-ad__skip-text",children:"\u8DF3\u8FC7"})]})]})};var P=require("react");var qe=require("react/jsx-runtime"),Tt="BI_DISPLAY_NATIVE_SPLASH_CONSUMED",Pt=300*1e3,st=["banner","splash"],lt=({adId:e="",unitId:r,type:n="banner",customAd:h,priority:D="wechat-first",adOptions:b=null,sdkKey:R="biNova",autoLoad:re=!0,adIntervals:j=30,show:E=!0,zIndex:ee=999,pictureInPicture:W=!1,checkNativeSplash:g=!0,nativeSplashCache:p=!0,jumpSeconds:q=5,className:I,onLoad:u,onError:J,onClose:he,onAction:z,onFeedback:ce,onHide:ie,onOpenWebview:Ae,onConfigLoad:ue,onConfigError:X})=>{var Oe;let k=(0,P.useRef)(0),L=(0,P.useRef)(""),O=(0,P.useRef)(null),G=(0,P.useRef)(u),_=(0,P.useRef)(J),f=(0,P.useRef)(he),C=(0,P.useRef)(z),de=(0,P.useRef)(ce),N=(0,P.useRef)(ie),K=(0,P.useRef)(Ae),M=(0,P.useRef)(ue),v=(0,P.useRef)(X),Q=(0,P.useRef)(E),[pe,me]=(0,P.useState)(!1),[ge,U]=(0,P.useState)(!1),[V,oe]=(0,P.useState)(null);(0,P.useEffect)(()=>{G.current=u,_.current=J,f.current=he,C.current=z,de.current=ce,N.current=ie,K.current=Ae,M.current=ue,v.current=X,Q.current=E},[z,he,X,ue,J,ce,ie,u,Ae,E]);let H=(0,P.useMemo)(()=>st.includes(n)?n:"banner",[n]),Se=()=>!!(re&&e),Ee=()=>{var c;let i=globalThis.getApp,a=typeof i=="function"?i():null;if(!a)return null;let t=a;return t[R]||((c=t.globalData)==null?void 0:c[R])||null},De=()=>{var i;try{if(typeof wx!="undefined"&&typeof wx.getAccountInfoSync=="function"){let a=wx.getAccountInfoSync();return((i=a==null?void 0:a.miniProgram)==null?void 0:i.appId)||""}}catch(a){return""}return""},ye=(i,a)=>`${Tt}_${a||"unknown"}_${i||"empty"}`,fe=(i,a)=>{if(!p||!i||typeof wx=="undefined"||typeof wx.getStorageSync!="function")return!1;try{let t=ye(i,a),c=Number(wx.getStorageSync(t)||0),T=Date.now()-c;return c>0&&T>=0&&T<=Pt}catch(t){return!1}},Ce=()=>{if(p&&!(!e||typeof wx=="undefined"||typeof wx.setStorageSync!="function"))try{let i=ye(e,De());wx.setStorageSync(i,Date.now())}catch(i){}},o=()=>{k.current+=1,L.current="",me(!1),U(!1),oe(null)},s=()=>{let i=b&&typeof b=="object"?b:{},a=De();return F(y({},i),{adId:e,placementId:i.placementId||e,appId:i.appId||a,type:H})},d=i=>{try{return JSON.stringify(i||{})}catch(a){return`${String(i.appId||"")}_${String(i.placementId||"")}`}},m=i=>{let a=(i==null?void 0:i.unitId)||"",t=(i==null?void 0:i.customAd)||(i==null?void 0:i.custom)||null,c=typeof(i==null?void 0:i.show)=="boolean"?i.show:!!(a||t);return{unitId:a,customAd:t,priority:(i==null?void 0:i.priority)||"wechat-first",show:c}},$=i=>{var a,t;(a=v.current)==null||a.call(v,i),(t=_.current)==null||t.call(_,i)},ae=i=>{var a;(a=f.current)==null||a.call(f,{type:H,adId:e||i.adId||"",provider:"none",reason:"noAd"})},ve=async()=>{var T;if(!Se())return;let i=s(),a=d(i);if(L.current===a&&(pe||ge))return;let t=Ee();if(!(t!=null&&t.ads)||typeof t.ads.getDisplayAdConfig!="function"){o(),$({type:H,adId:e,errCode:"DISPLAY_AD_SDK_NOT_READY",errMsg:"\u672A\u83B7\u53D6\u5230\u53EF\u7528\u7684\u5E7F\u544A\u670D\u52A1 SDK\uFF0C\u8BF7\u5148\u6CE8\u5165\u5168\u5C40 biNova \u5B9E\u4F8B"});return}let c=k.current+1;k.current=c,L.current=a,me(!0),U(!1),oe(null);try{let w=await t.ads.getDisplayAdConfig(i);if(c!==k.current)return;if(!w||w.code!==0||!w.data){me(!1),U(!0),oe(null),$({type:H,adId:e,errCode:"DISPLAY_AD_REMOTE_CONFIG_FAIL",errMsg:(w==null?void 0:w.message)||"\u83B7\u53D6\u5C55\u793A\u5E7F\u544A\u914D\u7F6E\u5931\u8D25",rawResult:w||null});return}let Pe=m(w.data),Ie=!!(Q.current&&!Pe.show);me(!1),U(!0),oe(w.data),(T=M.current)==null||T.call(M,{type:H,adId:e,requestOptions:i,data:w.data}),Ie&&ae(w.data)}catch(w){if(c!==k.current)return;me(!1),U(!0),oe(null),$({type:H,adId:e,errCode:"DISPLAY_AD_REMOTE_CONFIG_EXCEPTION",errMsg:w instanceof Error?w.message:"\u83B7\u53D6\u5C55\u793A\u5E7F\u544A\u914D\u7F6E\u5F02\u5E38",error:w})}};(0,P.useEffect)(()=>{var i;st.includes(n)||(i=_.current)==null||i.call(_,{type:"banner",errCode:"UNSUPPORTED_DISPLAY_AD_TYPE",errMsg:`\u4E0D\u652F\u6301\u7684\u5C55\u793A\u5E7F\u544A\u7C7B\u578B\uFF1A${n}\uFF0C\u8BF7\u4F7F\u7528 "banner" \u6216 "splash"`})},[n]),(0,P.useEffect)(()=>{if(!e){o();return}ve()},[e,b,re,H,R]);let ne=Se(),x=ne?m(V):null,se=x?x.unitId:r||"",be=x?x.customAd:h||null,we=x?x.priority:D,Ne=!!(E&&(!ne||!e||ge&&(x!=null&&x.show))),_e=De(),Te=JSON.stringify([H,_e,e,g,p]),le=O.current;!!(!le||le.identity!==Te||!le.show&&E)?O.current={identity:Te,show:E,shouldCheck:!!(g&&!fe(e,_e))}:le&&le.show!==E&&(O.current=F(y({},le),{show:E}));let Ge=!!((Oe=O.current)!=null&&Oe.shouldCheck),Ke=e||(V==null?void 0:V.adId)||"",Z=i=>y({adId:Ke},i);return H==="splash"?(0,qe.jsx)(je,y({},{unitId:se,customAd:be,priority:we,show:Ne,zIndex:ee,pictureInPicture:W,checkNativeSplash:Ge,jumpSeconds:q,className:I,onLoad:a=>{var t;a&&typeof a=="object"&&a.nativeSplash===!0&&Ce(),(t=G.current)==null||t.call(G,Z(a))},onError:a=>{var t;(t=_.current)==null||t.call(_,Z(a))},onClose:a=>{var t;(t=f.current)==null||t.call(f,Z(a))},onAction:a=>{var t;(t=C.current)==null||t.call(C,Z(a))},onHide:a=>{var t;(t=N.current)==null||t.call(N,Z(a))},onOpenWebview:a=>{var t;(t=K.current)==null||t.call(K,Z(a))}})):Ne?(0,qe.jsx)($e,y({},{unitId:se,customAd:be,priority:we,adIntervals:j,className:I,onLoad:i=>{var a;(a=G.current)==null||a.call(G,Z(i))},onError:i=>{var a;(a=_.current)==null||a.call(_,Z(i))},onClose:i=>{var a;(a=f.current)==null||a.call(f,Z(i))},onAction:i=>{var a;(a=C.current)==null||a.call(C,Z(i))},onFeedback:i=>{var a;(a=de.current)==null||a.call(de,Z(i))},onOpenWebview:i=>{var a;(a=K.current)==null||a.call(K,Z(i))}})):null};0&&(module.exports={BiBannerAd,BiDisplayAd,BiSplashAd});
|
|
1
|
+
"use strict";var pt=Object.create;var Le=Object.defineProperty,mt=Object.defineProperties,gt=Object.getOwnPropertyDescriptor,ft=Object.getOwnPropertyDescriptors,ht=Object.getOwnPropertyNames,Xe=Object.getOwnPropertySymbols,yt=Object.getPrototypeOf,et=Object.prototype.hasOwnProperty,At=Object.prototype.propertyIsEnumerable;var Ze=(e,n,r)=>n in e?Le(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,h=(e,n)=>{for(var r in n||(n={}))et.call(n,r)&&Ze(e,r,n[r]);if(Xe)for(var r of Xe(n))At.call(n,r)&&Ze(e,r,n[r]);return e},E=(e,n)=>mt(e,ft(n));var Bt=(e,n)=>{for(var r in n)Le(e,r,{get:n[r],enumerable:!0})},tt=(e,n,r,p)=>{if(n&&typeof n=="object"||typeof n=="function")for(let d of ht(n))!et.call(e,d)&&d!==r&&Le(e,d,{get:()=>n[d],enumerable:!(p=gt(n,d))||p.enumerable});return e};var Qe=(e,n,r)=>(r=e!=null?pt(yt(e)):{},tt(n||!e||!e.__esModule?Le(r,"default",{value:e,enumerable:!0}):r,e)),St=e=>tt(Le({},"__esModule",{value:!0}),e);var Rt={};Bt(Rt,{BiBannerAd:()=>je,BiDisplayAd:()=>dt,BiSplashAd:()=>Ge});module.exports=St(Rt);var tr=require("./banner/index.scss"),rr=require("./splash/index.scss");var B=require("react"),ae=require("@tarojs/components"),ct=Qe(require("@tarojs/taro"));var Dt=Qe(require("@tarojs/components")),Oe;function $e(){if(Oe!==void 0)return Oe;try{let e=Dt;Oe=(e==null?void 0:e.AdCustom)||null}catch(e){Oe=null}return Oe}var Ne=Qe(require("@tarojs/taro"));function We(){return typeof wx!="undefined"?wx:null}function Se(e,n){let r=e==null?void 0:e.detail;return r&&typeof r=="object"?h(h({},n),r):e&&typeof e=="object"?h(h({},n),e):h({},n)}function nt(e){return e?e.mediaType==="video"?e.video||"":e.mediaType==="image"?e.image||"":e.video||e.image||"":""}function it(e,n=""){return e&&(e.poster||e.image||n)||""}function at(e,n=""){return e?e.mediaType==="video"?!1:e.mediaType==="image"?!0:e.video?!1:e.image?!0:/\.(jpg|jpeg|png|gif|bmp|webp|svg|ico)$/i.test(String(n).trim()):!0}function ot(e){return String((e==null?void 0:e.fitMode)||"").trim().toLowerCase()==="contain"?"contain":"cover"}function qe(e){return e&&(e.badgeText||e.adLabel)||"\u5E7F\u544A"}function st(e,n=5){let r=e==null?void 0:e.jumpSeconds,p=r!=null?r:n;return Math.min(99,Math.max(0,Number(p)||0))}function He(e){var r;let n=(r=e==null?void 0:e.loadTimeout)!=null?r:e==null?void 0:e.timeout;return Math.max(1e3,Number(n)||5e3)}function Ct(e,n=!1){var r,p,d,D;if(!e)return"none";if(n){let M=String(((r=e.action)==null?void 0:r.type)||e.jumpType||"").trim().toLowerCase();if(M==="miniprogram")return"miniProgram";if(M==="internal")return"internal";if(M==="web")return"web";if(M==="api")return"api";if(M==="none")return"none"}return n&&((p=e.action)!=null&&p.appId||e.targetAppId)||e.appId||e.miniProgramAppId||e.jumpAppId?"miniProgram":n&&((d=e.action)!=null&&d.path||e.targetPath)||e.path||e.pagePath||e.jumpPath||e.targetUrl?"internal":n&&((D=e.action)!=null&&D.url||e.jumpUrl)||e.url||e.webUrl||e.h5Url?"web":"none"}function bt(e,n=!1){var r;return e&&((n?((r=e.action)==null?void 0:r.appId)||e.targetAppId:"")||e.appId||e.miniProgramAppId||e.jumpAppId)||""}function wt(e,n=!1){var r;return e&&((n?((r=e.action)==null?void 0:r.path)||e.targetPath:"")||e.path||e.pagePath||e.jumpPath||e.targetUrl)||""}function _t(e,n=!1){var p;if(!e)return"full";let r=(n?(p=e.action)==null?void 0:p.miniProgramOpenMode:"")||e.miniProgramOpenMode;return String(r||"").trim().toLowerCase()==="half"?"half":"full"}function vt(e,n=!1){var r;return e&&((n?((r=e.action)==null?void 0:r.url)||e.jumpUrl:"")||e.url||e.webUrl||e.h5Url)||""}function It(e){return e!=null&&e!==""}function rt(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Tt(e,n){let r=e.indexOf("#"),p=r>=0?e.slice(r):"",d=r>=0?e.slice(0,r):e,D=Object.keys(n).map(V=>`${encodeURIComponent(V)}=${encodeURIComponent(String(n[V]))}`).join("&");if(!D)return e;let M=d.includes("?")?/[?&]$/.test(d)?"":"&":"?";return`${d}${M}${D}${p}`}function Pt(e,n){var V;let r=rt(e==null?void 0:e.data)?e.data:null,p=rt(r==null?void 0:r.body)?r.body:null,d=String((p==null?void 0:p.appId)||"").trim(),D=String((p==null?void 0:p.url)||"").trim().replace(/^\/+/,"");if(String((r==null?void 0:r.code)||"")!=="200"||!d||!D){(V=n.onError)==null||V.call(n,E(h({},n.actionDetail),{errCode:n.apiRequestErrorCode||"BI_CUSTOM_AD_API_REQUEST_FAIL",errMsg:String((r==null?void 0:r.message)||"\u5E7F\u544A\u63A5\u53E3\u54CD\u5E94\u5F02\u5E38")}));return}Ue(E(h({},n),{customAd:{action:{type:"miniProgram",appId:d,path:D}},preferStandardFields:!0}))}function Ue(e){let{customAd:n,actionDetail:r,onOpenWebview:p,onError:d,miniProgramErrorCode:D,navigateErrorCode:M,miniProgramUnsupportedErrorCode:V,apiRequestErrorCode:ne,apiRequestParams:$,preferStandardFields:X=!1}=e;if(!n)return;let Q=Ct(n,X),z=bt(n,X),T=wt(n,X),f=vt(n,X);if(Q==="miniProgram"&&z){let g=We(),H=_t(n,X),k=H==="half"?g==null?void 0:g.openEmbeddedMiniProgram:g==null?void 0:g.navigateToMiniProgram;if(!g||typeof k!="function"){d==null||d(E(h({},r),{errCode:V||D,errMsg:H==="half"?"\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u534A\u5C4F\u6253\u5F00\u5176\u4ED6\u5C0F\u7A0B\u5E8F":"\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u8DF3\u8F6C\u5230\u5176\u4ED6\u5C0F\u7A0B\u5E8F"}));return}k.call(g,{appId:z,path:T||"",fail:u=>{d==null||d(E(h({},r),{errCode:D,errMsg:(u==null?void 0:u.errMsg)||"\u8DF3\u8F6C\u5230\u5176\u4ED6\u5C0F\u7A0B\u5E8F\u5931\u8D25"}))}});return}if(Q==="internal"&&T){Ne.navigateTo({url:T,fail:g=>{d==null||d(E(h({},r),{errCode:M,errMsg:(g==null?void 0:g.errMsg)||"\u9875\u9762\u8DF3\u8F6C\u5931\u8D25"}))}});return}if(Q==="web"&&f){p==null||p(E(h({},r),{url:f}));return}if(Q==="api"&&f){let g=$||{},k=["configId","equipmentValue","userId"].filter(v=>{let ie=g[v];return v==="userId"?!Number.isInteger(ie)||Number(ie)<=0:!It(ie)});if(k.length){d==null||d(E(h({},r),{errCode:ne||"BI_CUSTOM_AD_API_REQUEST_FAIL",errMsg:`\u63A5\u53E3\u578B\u5E7F\u544A\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570\u6216\u53C2\u6570\u503C\u65E0\u6548\uFF1A${k.join("\u3001")}`}));return}let u=Tt(f,{configId:g.configId,equipmentValue:g.equipmentValue,userId:g.userId});Ne.request({url:u,method:"GET",success:v=>{Pt(v,e)},fail:v=>{d==null||d(E(h({},r),{errCode:ne||"BI_CUSTOM_AD_API_REQUEST_FAIL",errMsg:(v==null?void 0:v.errMsg)||"\u5E7F\u544A\u63A5\u53E3\u8BF7\u6C42\u5931\u8D25"}))}})}}function lt(){var g;let e=We(),n=e&&typeof e.getMenuButtonBoundingClientRect=="function"?e.getMenuButtonBoundingClientRect():{},r=e&&typeof e.getWindowInfo=="function"?e.getWindowInfo():typeof Ne.getSystemInfoSync=="function"?Ne.getSystemInfoSync():{},p=Number(r.windowHeight||0),d=Number(r.screenHeight||0),D=!!(p&&d&&p===d),M=16,V=16,ne=16,$=32,X=D&&n.top?n.top:Math.max(M,Number(r.statusBarHeight||0)+4),Q=D&&n.height?n.height:$,z=D&&n.top?n.top:M,T=D&&n.height?n.height:$,f=Math.max(ne,Number(((g=r.safeArea)==null?void 0:g.left)||0)+ne);return{isFullScreen:D,skipStyle:{top:`${z}px`,width:"156rpx",height:`${T}px`,lineHeight:`${T}px`,borderRadius:`${Math.round(T/2)}px`,left:D?`${ne}px`:void 0,right:D?void 0:`${V}px`},disclosureStyle:{top:`${z}px`,left:`${f}px`,height:`${T}px`,lineHeight:`${T}px`},combinedControlStyle:{top:`${X}px`,left:`${f}px`,height:`${Q}px`}}}var J=require("react/jsx-runtime"),Et=[{label:"\u4E0E\u6211\u65E0\u5173",value:"irrelevant"},{label:"\u91CD\u590D\u6536\u5230\u591A\u6B21",value:"repeated"},{label:"\u5185\u5BB9\u592A\u5DEE",value:"poorContent"}];function Nt(e,n,r){return e&&n?r==="custom-first"||r==="custom-only"?"custom":"wechat":e?"wechat":n?"custom":null}var je=({unitId:e="",customAd:n,priority:r="wechat-first",adIntervals:p=30,equipmentValue:d="",userId:D=0,className:M,onLoad:V,onError:ne,onClose:$,onAction:X,onFeedback:Q,onOpenWebview:z})=>{let T=(0,B.useMemo)(()=>$e(),[]),f=n||null,g=!!(f!=null&&f.image),H=!!(e&&T),k=Nt(H,g,r),u=JSON.stringify([e,f,r,!!T]),[v,ie]=(0,B.useState)(!!k),[Z,pe]=(0,B.useState)(k),[se,De]=(0,B.useState)(!1),[me,ee]=(0,B.useState)("primary"),O=(0,B.useRef)(k),U=(0,B.useRef)({wechat:!1,custom:!1}),F=(0,B.useRef)(!1),K=(0,B.useRef)(null),I=(0,B.useRef)(V),A=(0,B.useRef)(ne),b=(0,B.useRef)($),ge=(0,B.useRef)(X),x=(0,B.useRef)(Q),Y=(0,B.useRef)(z);(0,B.useEffect)(()=>{I.current=V,A.current=ne,b.current=$,ge.current=X,x.current=Q,Y.current=z},[X,$,ne,Q,V,z]);let R=(0,B.useCallback)(a=>{let s=a==="custom"&&f?{configId:f.configId,placementId:f.placementId,configName:f.configName,advertPlatform:f.advertPlatform}:{};return h({provider:a,type:"banner"},s)},[f]),w=(0,B.useCallback)(()=>{K.current&&(clearTimeout(K.current),K.current=null)},[]),te=(0,B.useCallback)(()=>{De(!1),ee("primary")},[]),fe=(0,B.useCallback)(a=>{w(),O.current=a,F.current=!1,pe(a),ie(!0),te()},[w,te]),he=(0,B.useCallback)((a,s)=>{var G;let y=!!e&&g?"allProvidersFailed":a==="wechat"?"wechatAdLoadFail":"customMediaLoadFail";w(),O.current=null,pe(null),ie(!1),te(),(G=b.current)==null||G.call(b,{provider:a,type:"banner",reason:y,error:s})},[w,te,g,e]),ye=(0,B.useCallback)((a,s,m,y)=>{var _e;if(O.current!=="custom"||U.current.custom)return;w();let G=Se(a,R("custom")),ce=E(h({},G),{errorType:s,errCode:m,errMsg:y,mediaType:"image",rawErrCode:G.errCode,rawErrMsg:G.errMsg});if(U.current.custom=!0,(_e=A.current)==null||_e.call(A,ce),H&&!U.current.wechat){fe("wechat");return}he("custom",ce)},[H,w,R,he,fe]);(0,B.useEffect)(()=>(w(),U.current={wechat:!1,custom:!1},F.current=!1,O.current=k,pe(k),ie(!!k),te(),w),[w,te,u,k]),(0,B.useEffect)(()=>{if(w(),!(!v||Z!=="custom"||!g))return K.current=setTimeout(()=>{F.current||O.current!=="custom"||ye(void 0,"CUSTOM_MEDIA_LOAD_TIMEOUT","BI_BANNER_CUSTOM_MEDIA_LOAD_TIMEOUT","Banner \u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u8D85\u65F6")},He(f)),w},[w,ye,g,Z,f,v]),(0,B.useEffect)(()=>{var s,m;if(!e||T)return;let a=E(h({},R("wechat")),{errCode:"BI_BANNER_NATIVE_AD_UNSUPPORTED",errMsg:"\u5F53\u524D\u7AEF\u4E0D\u652F\u6301\u5FAE\u4FE1\u539F\u751F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7EC4\u4EF6"});(s=A.current)==null||s.call(A,a),g||(m=b.current)==null||m.call(b,E(h({},R("wechat")),{reason:"wechatAdLoadFail",error:a}))},[T,R,g,e]);let W=a=>{var s;O.current==="wechat"&&((s=I.current)==null||s.call(I,Se(a,R("wechat"))))},q=a=>{var y;if(O.current!=="wechat"||U.current.wechat)return;let s=a!=null&&a.detail&&typeof a.detail=="object"?a.detail:{},m=E(h({},Se(a,R("wechat"))),{errCode:"BI_BANNER_WECHAT_AD_LOAD_FAIL",errMsg:String(s.errMsg||"\u5FAE\u4FE1 Banner \u5E7F\u544A\u52A0\u8F7D\u5931\u8D25"),rawErrCode:s.errCode,rawErrMsg:s.errMsg});if(U.current.wechat=!0,(y=A.current)==null||y.call(A,m),g&&!U.current.custom){fe("custom");return}he("wechat",m)},le=a=>{var s;O.current==="wechat"&&((s=b.current)==null||s.call(b,Se(a,R("wechat"))))},j=()=>{var a;O.current!=="custom"||F.current||(w(),F.current=!0,(a=I.current)==null||a.call(I,R("custom")))},Ce=()=>{var s;if(se){te();return}let a=R("custom");(s=ge.current)==null||s.call(ge,a),Ue({customAd:f,actionDetail:a,onOpenWebview:m=>{var y;return(y=Y.current)==null?void 0:y.call(Y,m)},onError:m=>{var y;return(y=A.current)==null?void 0:y.call(A,m)},miniProgramErrorCode:"BI_BANNER_NAVIGATE_MINI_PROGRAM_FAIL",navigateErrorCode:"BI_BANNER_NAVIGATE_FAIL",apiRequestErrorCode:"BI_BANNER_API_REQUEST_FAIL",apiRequestParams:{configId:f==null?void 0:f.configId,equipmentValue:d,userId:D},preferStandardFields:!0})},Me=a=>{var s;(s=a.stopPropagation)==null||s.call(a),De(m=>!m),ee("primary")},be=a=>{var s;(s=a.stopPropagation)==null||s.call(a)},Be=a=>{var s,m;(s=a.stopPropagation)==null||s.call(a),te(),(m=x.current)==null||m.call(x,E(h({},R("custom")),{provider:"custom",action:"report"})),ct.showToast({title:"\u5DF2\u6536\u5230\u60A8\u7684\u53CD\u9988\uFF0C\u6211\u4EEC\u4F1A\u5C3D\u5FEB\u5904\u7406~",icon:"none",duration:2e3})},Ae=(a,s)=>{var y,G,ce;(y=a.stopPropagation)==null||y.call(a);let m=E(h({},R("custom")),{provider:"custom",action:"dislike",reason:s.value,reasonText:s.label});w(),O.current=null,pe(null),ie(!1),te(),(G=x.current)==null||G.call(x,m),(ce=b.current)==null||ce.call(b,E(h({},R("custom")),{reason:"notInterested",feedbackReason:s.value,feedbackReasonText:s.label}))},we=`bi-banner-ad${M?` ${M}`:""}`;return!v||!Z?null:Z==="wechat"&&T?(0,J.jsx)(T,{className:we,unitId:e,adIntervals:p,onLoad:W,onError:q,onClose:le}):Z!=="custom"||!(f!=null&&f.image)?null:(0,J.jsxs)(ae.View,{className:we,children:[(0,J.jsx)(ae.View,{className:"bi-banner-ad__surface",onClick:Ce,children:(0,J.jsx)(ae.Image,{className:"bi-banner-ad__image",src:f.image,mode:"widthFix",onLoad:j,onError:a=>ye(a,"CUSTOM_MEDIA_LOAD_FAIL","BI_BANNER_CUSTOM_MEDIA_LOAD_FAIL","Banner \u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u5931\u8D25")})}),(0,J.jsxs)(ae.View,{className:"bi-banner-ad__badge",onClick:Me,children:[(0,J.jsx)(ae.Text,{children:qe(f)}),(0,J.jsx)(ae.View,{className:"bi-banner-ad__badge-arrow"})]}),se?(0,J.jsx)(ae.View,{className:"bi-banner-ad__feedback-panel",onClick:be,children:me==="primary"?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(ae.View,{className:"bi-banner-ad__feedback-source",children:"\u7531\u8D5E\u52A9\u5546\u63D0\u4F9B\u7684\u5185\u5BB9"}),(0,J.jsx)(ae.View,{className:"bi-banner-ad__feedback-item",onClick:a=>{var s;(s=a.stopPropagation)==null||s.call(a),ee("dislike")},children:"\u4E0D\u611F\u5174\u8DA3"}),(0,J.jsx)(ae.View,{className:"bi-banner-ad__feedback-item",onClick:Be,children:"\u53CD\u9988\u95EE\u9898"})]}):Et.map(a=>(0,J.jsx)(ae.View,{className:"bi-banner-ad__feedback-item",onClick:s=>Ae(s,a),children:a.label},a.value))}):null]})};var l=require("react"),S=require("@tarojs/components");var C=require("react/jsx-runtime");function Mt(e,n,r){return e&&n?r==="custom-first"||r==="custom-only"?"custom":"wechat":e?"wechat":n?"custom":null}var Ge=({unitId:e="",customAd:n,priority:r="wechat-first",show:p=!0,zIndex:d=999,pictureInPicture:D=!1,checkNativeSplash:M=!0,jumpSeconds:V=5,equipmentValue:ne="",userId:$=0,className:X,onLoad:Q,onError:z,onClose:T,onAction:f,onHide:g,onOpenWebview:H})=>{let k=(0,l.useMemo)(()=>$e(),[]),u=n||null,v=(0,l.useMemo)(()=>nt(u),[u]),ie=(0,l.useMemo)(()=>it(u,v),[v,u]),Z=(0,l.useMemo)(()=>at(u,v),[v,u]),pe=(0,l.useMemo)(()=>ot(u),[u]),se=(0,l.useMemo)(()=>st(u,V),[V,u]),De=(0,l.useMemo)(()=>qe(u),[u]),me=(0,l.useMemo)(()=>lt(),[]),ee=!!(e&&k),O=!!(v||u!=null&&u.mediaType),U=!!v,F=Mt(ee,O,r),K=JSON.stringify([e,u,r,!!k]),[I,A]=(0,l.useState)(!1),[b,ge]=(0,l.useState)(F),[x,Y]=(0,l.useState)(!1),[R,w]=(0,l.useState)(0),[te,fe]=(0,l.useState)(!1),[he,ye]=(0,l.useState)(!1),W=(0,l.useRef)(F),q=(0,l.useRef)({wechat:!1,custom:!1}),le=(0,l.useRef)(!1),j=(0,l.useRef)(!1),Ce=(0,l.useRef)(!1),Me=(0,l.useRef)({identity:K,show:!1}),be=(0,l.useRef)(0),Be=(0,l.useRef)(null),Ae=(0,l.useRef)(null),we=(0,l.useRef)(null),a=(0,l.useRef)(null),s=(0,l.useRef)(Q),m=(0,l.useRef)(z),y=(0,l.useRef)(T),G=(0,l.useRef)(f),ce=(0,l.useRef)(g),_e=(0,l.useRef)(H);(0,l.useEffect)(()=>{s.current=Q,m.current=z,y.current=T,G.current=f,ce.current=g,_e.current=H},[f,T,z,g,Q,H]),(0,l.useEffect)(()=>{var t;!p||!e||k||(t=m.current)==null||t.call(m,{provider:"wechat",type:"splash",errCode:"BI_SPLASH_NATIVE_AD_UNSUPPORTED",errMsg:"\u5F53\u524D\u7AEF\u4E0D\u652F\u6301\u5FAE\u4FE1\u539F\u751F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7EC4\u4EF6"})},[k,p,e]);let oe=t=>{let c=t==="custom"&&u?{configId:u.configId,placementId:u.placementId,configName:u.configName,advertPlatform:u.advertPlatform}:{};return h({provider:t,type:"splash"},c)},L=(0,l.useCallback)(()=>{Be.current&&clearInterval(Be.current),Ae.current&&clearTimeout(Ae.current),we.current&&clearTimeout(we.current),a.current&&clearTimeout(a.current),Be.current=null,Ae.current=null,we.current=null,a.current=null},[]),ue=(0,l.useCallback)((t,c)=>{L(),W.current=t,le.current=!1,ge(t),A(c),Y(!1),w(se),fe(!1),ye(!1)},[L,se]),Ie=(0,l.useCallback)((t,c)=>{var Re;let Ee=O&&(t==="custom"||ee&&q.current.wechat&&q.current.custom),ke=Ee?"allProvidersFailed":"wechatAdLoadFail";L(),A(!1),Y(!1),w(0),fe(!1),ye(!1),(Re=y.current)==null||Re.call(y,{provider:Ee?"none":t,type:"splash",reason:ke,error:c})},[ee,L,O]),ve=(0,l.useCallback)(()=>{if(!(Be.current||!W.current)){if(fe(!0),se<=0){w(0);return}w(se),Be.current=setInterval(()=>{w(t=>Math.max(0,t-1))},1e3)}},[se]),xe=(0,l.useCallback)(()=>{U&&(Ae.current=setTimeout(()=>{var c;if(le.current||W.current!=="custom")return;let t=E(h({},oe("custom")),{errorType:"CUSTOM_MEDIA_LOAD_TIMEOUT",errCode:"BI_SPLASH_CUSTOM_MEDIA_LOAD_TIMEOUT",errMsg:"\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u8D85\u65F6",mediaType:Z?"image":"video",rawErrCode:void 0,rawErrMsg:void 0});(c=m.current)==null||c.call(m,t),q.current.custom=!0,ee&&!q.current.wechat?(ue("wechat",!0),ve()):Ie("custom",t)},He(u)))},[ee,Ie,U,Z,ue,u,ve]),Te=(0,l.useCallback)(t=>{ue(t,!0),t==="wechat"?ve():U&&xe()},[U,ue,ve,xe]),Pe=(0,l.useCallback)((t,c,P,_)=>{var Re;if(W.current!=="custom"||q.current.custom)return;let Ee=Se(t,oe("custom")),ke=E(h({},Ee),{errorType:c,errCode:P,errMsg:_,mediaType:Z?"image":"video",rawErrCode:Ee.errCode,rawErrMsg:Ee.errMsg});(Re=m.current)==null||Re.call(m,ke),q.current.custom=!0,ee&&!q.current.wechat?Te("wechat"):Ie("custom",ke)},[ee,Ie,Z,Te]),de=(0,l.useCallback)(()=>{var t;if(j.current){A(!1);return}if(!F){ue(null,!1),Ce.current||(Ce.current=!0,(t=y.current)==null||t.call(y,{provider:"none",type:"splash",reason:"noAd"}));return}Te(F),F==="custom"&&!U&&Pe(void 0,"CUSTOM_MEDIA_LOAD_FAIL","BI_SPLASH_CUSTOM_MEDIA_LOAD_FAIL","\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u4E3B\u7D20\u6750\u5730\u5740\u4E3A\u7A7A")},[Pe,U,F,ue,Te]),Fe=(0,l.useCallback)(()=>{if(!p||j.current)return;if(!M){de();return}let t=We();if(!(t!=null&&t.getShowSplashAdStatus)||be.current>=3){de();return}t.getShowSplashAdStatus({success:c=>{var P;if((c==null?void 0:c.code)===-1){be.current+=1,we.current=setTimeout(Fe,300);return}if((c==null?void 0:c.code)===1){L(),j.current=!0,A(!1),(P=s.current)==null||P.call(s,{provider:"wechat",type:"splash",nativeSplash:!0});return}de()},fail:de})},[de,M,L,p]);(0,l.useEffect)(()=>{let t=Me.current,c=p&&!t.show||t.identity!==K;if(Me.current={identity:K,show:p},!p){j.current=!1,Ce.current=!1,q.current={wechat:!1,custom:!1},ue(F,!1);return}if(!j.current)return c&&(Ce.current=!1),q.current={wechat:!1,custom:!1},j.current=!1,be.current=0,ue(F,!1),Fe(),L},[Fe,L,K,F,ue,p]),(0,l.useEffect)(()=>{var c;if(!te||R!==0||!I||x||!W.current)return;let t=W.current;if(D){L(),ye(!0),a.current=setTimeout(()=>{var P;Y(!0),ye(!1),(P=ce.current)==null||P.call(ce,oe(t))},280);return}L(),A(!1),(c=y.current)==null||c.call(y,oe(t))},[L,te,D,R,x,I]);let Ke=t=>{var c;W.current==="wechat"&&(ve(),(c=s.current)==null||c.call(s,Se(t,oe("wechat"))))},Ye=t=>{var _;if(W.current!=="wechat"||q.current.wechat)return;let c=t!=null&&t.detail&&typeof t.detail=="object"?t.detail:{},P=E(h({},Se(t,oe("wechat"))),{errCode:"BI_SPLASH_WECHAT_AD_LOAD_FAIL",errMsg:String(c.errMsg||"\u5FAE\u4FE1\u5F00\u5C4F\u5E7F\u544A\u52A0\u8F7D\u5931\u8D25"),rawErrCode:c.errCode,rawErrMsg:c.errMsg});(_=m.current)==null||_.call(m,P),q.current.wechat=!0,O&&!q.current.custom?(Te("custom"),U||Pe(void 0,"CUSTOM_MEDIA_LOAD_FAIL","BI_SPLASH_CUSTOM_MEDIA_LOAD_FAIL","\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u4E3B\u7D20\u6750\u5730\u5740\u4E3A\u7A7A")):Ie("wechat",P)},re=()=>{var t;W.current!=="custom"||le.current||(Ae.current&&clearTimeout(Ae.current),Ae.current=null,le.current=!0,ve(),(t=s.current)==null||t.call(s,oe("custom")))},Je=t=>{var P;(P=t==null?void 0:t.stopPropagation)==null||P.call(t),W.current&&(fe(!0),w(0))},Ve=()=>{var c;if(W.current!=="custom")return;let t=oe("custom");(c=G.current)==null||c.call(G,t),Ue({customAd:u,actionDetail:t,onOpenWebview:P=>{var _;return(_=_e.current)==null?void 0:_.call(_e,P)},onError:P=>{var _;return(_=m.current)==null?void 0:_.call(m,P)},miniProgramErrorCode:"BI_SPLASH_NAVIGATE_MINI_PROGRAM_FAIL",navigateErrorCode:"BI_SPLASH_NAVIGATE_FAIL",apiRequestErrorCode:"BI_SPLASH_API_REQUEST_FAIL",apiRequestParams:{configId:u==null?void 0:u.configId,equipmentValue:ne,userId:$},preferStandardFields:!0})},i=t=>{var c;L(),A(!1),Y(!1),w(0),fe(!1),(c=y.current)==null||c.call(y,t)},o=["bi-splash-ad",x?"bi-splash-ad--pip":"",he?"bi-splash-ad--pip-animating":"",X||""].filter(Boolean).join(" ");return!I||!b?null:(0,C.jsxs)(S.View,{className:o,style:{zIndex:d},children:[b==="wechat"&&k?(0,C.jsx)(S.View,{className:"bi-splash-ad__popup",children:(0,C.jsx)(S.View,{className:`bi-splash-ad__media-wrapper${x?" bi-splash-ad__media-wrapper--pip":""}`,children:(0,C.jsx)(k,{className:"bi-splash-ad__wechat-unit",unitId:e,onLoad:Ke,onError:Ye,onClose:t=>i(Se(t,oe("wechat")))})})}):b==="custom"&&U?(0,C.jsx)(S.View,{className:"bi-splash-ad__popup bi-splash-ad__custom",children:(0,C.jsxs)(S.View,{className:"bi-splash-ad__media-shell",onClick:Ve,children:[Z?(0,C.jsx)(S.Image,{className:"bi-splash-ad__media",src:v,mode:pe==="cover"?"aspectFill":"aspectFit",onLoad:re,onError:t=>Pe(t,"CUSTOM_MEDIA_LOAD_FAIL","BI_SPLASH_CUSTOM_MEDIA_LOAD_FAIL","\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u5931\u8D25")}):(0,C.jsx)(S.Video,{className:"bi-splash-ad__video",src:v,poster:ie,autoplay:!0,muted:(u==null?void 0:u.muted)!==!1,loop:!0,objectFit:pe,showCenterPlayBtn:!1,showPlayBtn:!1,controls:!1,onLoadedMetaData:re,onError:t=>Pe(t,"CUSTOM_MEDIA_LOAD_FAIL","BI_SPLASH_CUSTOM_MEDIA_LOAD_FAIL","\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u5931\u8D25")}),x?(0,C.jsx)(S.View,{className:"bi-splash-ad__pip-mask"}):null,!x&&!me.isFullScreen?(0,C.jsxs)(S.View,{className:"bi-splash-ad__disclosure",style:me.disclosureStyle,children:[(0,C.jsx)(S.Text,{children:De}),(0,C.jsx)(S.View,{className:"bi-splash-ad__disclosure-arrow"})]}):null,!x&&(u!=null&&u.bottomImage)?(0,C.jsx)(S.Image,{className:"bi-splash-ad__bottom-image",src:u.bottomImage,mode:"widthFix"}):null]})}):null,x?(0,C.jsx)(S.View,{className:"bi-splash-ad__pip-close",onClick:()=>i(oe(b)),children:(0,C.jsx)(S.View,{className:"bi-splash-ad__pip-close-text",children:"\u5173\u95ED"})}):null,!x&&me.isFullScreen&&b==="custom"?(0,C.jsxs)(S.View,{className:"bi-splash-ad__combined-control",style:me.combinedControlStyle,children:[(0,C.jsxs)(S.View,{className:"bi-splash-ad__combined-capsule",children:[(0,C.jsxs)(S.View,{className:"bi-splash-ad__combined-disclosure",children:[(0,C.jsx)(S.Text,{children:De}),(0,C.jsx)(S.View,{className:"bi-splash-ad__disclosure-arrow"})]}),(0,C.jsx)(S.View,{className:"bi-splash-ad__combined-divider"}),(0,C.jsx)(S.View,{className:"bi-splash-ad__combined-skip",onClick:Je,children:"\u8DF3\u8FC7"})]}),(0,C.jsxs)(S.Text,{className:"bi-splash-ad__combined-countdown",children:[R," \u79D2"]})]}):x?null:(0,C.jsxs)(S.View,{className:"bi-splash-ad__skip",style:me.skipStyle,onClick:Je,children:[(0,C.jsxs)(S.Text,{children:[R,"s"]}),(0,C.jsx)(S.View,{className:"bi-splash-ad__skip-divider"}),(0,C.jsx)(S.Text,{className:"bi-splash-ad__skip-text",children:"\u8DF3\u8FC7"})]})]})};var N=require("react");var ze=require("react/jsx-runtime"),kt="BI_DISPLAY_NATIVE_SPLASH_CONSUMED",xt=300*1e3,ut=["banner","splash"],dt=({adId:e="",unitId:n,type:r="banner",customAd:p,priority:d="wechat-first",adOptions:D=null,sdkKey:M="biNova",autoLoad:V=!0,adIntervals:ne=30,show:$=!0,zIndex:X=999,pictureInPicture:Q=!1,checkNativeSplash:z=!0,nativeSplashCache:T=!0,jumpSeconds:f=5,equipmentValue:g="",userId:H=0,className:k,onLoad:u,onError:v,onClose:ie,onAction:Z,onFeedback:pe,onHide:se,onOpenWebview:De,onConfigLoad:me,onConfigError:ee})=>{var Ve;let O=(0,N.useRef)(0),U=(0,N.useRef)(""),F=(0,N.useRef)(null),K=(0,N.useRef)(u),I=(0,N.useRef)(v),A=(0,N.useRef)(ie),b=(0,N.useRef)(Z),ge=(0,N.useRef)(pe),x=(0,N.useRef)(se),Y=(0,N.useRef)(De),R=(0,N.useRef)(me),w=(0,N.useRef)(ee),te=(0,N.useRef)($),[fe,he]=(0,N.useState)(!1),[ye,W]=(0,N.useState)(!1),[q,le]=(0,N.useState)(null);(0,N.useEffect)(()=>{K.current=u,I.current=v,A.current=ie,b.current=Z,ge.current=pe,x.current=se,Y.current=De,R.current=me,w.current=ee,te.current=$},[Z,ie,ee,me,v,pe,se,u,De,$]);let j=(0,N.useMemo)(()=>ut.includes(r)?r:"banner",[r]),Ce=()=>!!(V&&e),Me=()=>{var c;let i=globalThis.getApp,o=typeof i=="function"?i():null;if(!o)return null;let t=o;return t[M]||((c=t.globalData)==null?void 0:c[M])||null},be=()=>{var i;try{if(typeof wx!="undefined"&&typeof wx.getAccountInfoSync=="function"){let o=wx.getAccountInfoSync();return((i=o==null?void 0:o.miniProgram)==null?void 0:i.appId)||""}}catch(o){return""}return""},Be=(i,o)=>`${kt}_${o||"unknown"}_${i||"empty"}`,Ae=(i,o)=>{if(!T||!i||typeof wx=="undefined"||typeof wx.getStorageSync!="function")return!1;try{let t=Be(i,o),c=Number(wx.getStorageSync(t)||0),P=Date.now()-c;return c>0&&P>=0&&P<=xt}catch(t){return!1}},we=()=>{if(T&&!(!e||typeof wx=="undefined"||typeof wx.setStorageSync!="function"))try{let i=Be(e,be());wx.setStorageSync(i,Date.now())}catch(i){}},a=()=>{O.current+=1,U.current="",he(!1),W(!1),le(null)},s=()=>{let i=D&&typeof D=="object"?D:{},o=be(),t=E(h({},i),{adId:e,placementId:i.placementId||e,appId:i.appId||o,type:j});return Number.isInteger(H)&&H>0?t.userId=H:delete t.userId,t},m=i=>{try{return JSON.stringify(i||{})}catch(o){return`${String(i.appId||"")}_${String(i.placementId||"")}`}},y=i=>{let o=(i==null?void 0:i.unitId)||"",t=(i==null?void 0:i.customAd)||(i==null?void 0:i.custom)||null,c=typeof(i==null?void 0:i.show)=="boolean"?i.show:!!(o||t);return{unitId:o,customAd:t,priority:(i==null?void 0:i.priority)||"wechat-first",show:c}},G=i=>{var o,t;(o=w.current)==null||o.call(w,i),(t=I.current)==null||t.call(I,i)},ce=i=>{var o;(o=A.current)==null||o.call(A,{type:j,adId:e||i.adId||"",provider:"none",reason:"noAd"})},_e=async()=>{var P;if(!Ce())return;let i=s(),o=m(i);if(U.current===o&&(fe||ye))return;let t=Me();if(!(t!=null&&t.ads)||typeof t.ads.getDisplayAdConfig!="function"){a(),G({type:j,adId:e,errCode:"DISPLAY_AD_SDK_NOT_READY",errMsg:"\u672A\u83B7\u53D6\u5230\u53EF\u7528\u7684\u5E7F\u544A\u670D\u52A1 SDK\uFF0C\u8BF7\u5148\u6CE8\u5165\u5168\u5C40 biNova \u5B9E\u4F8B"});return}let c=O.current+1;O.current=c,U.current=o,he(!0),W(!1),le(null);try{let _=await t.ads.getDisplayAdConfig(i);if(c!==O.current)return;if(!_||_.code!==0||!_.data){he(!1),W(!0),le(null),G({type:j,adId:e,errCode:"DISPLAY_AD_REMOTE_CONFIG_FAIL",errMsg:(_==null?void 0:_.message)||"\u83B7\u53D6\u5C55\u793A\u5E7F\u544A\u914D\u7F6E\u5931\u8D25",rawResult:_||null});return}let Ee=y(_.data),ke=!!(te.current&&!Ee.show);he(!1),W(!0),le(_.data),(P=R.current)==null||P.call(R,{type:j,adId:e,requestOptions:i,data:_.data}),ke&&ce(_.data)}catch(_){if(c!==O.current)return;he(!1),W(!0),le(null),G({type:j,adId:e,errCode:"DISPLAY_AD_REMOTE_CONFIG_EXCEPTION",errMsg:_ instanceof Error?_.message:"\u83B7\u53D6\u5C55\u793A\u5E7F\u544A\u914D\u7F6E\u5F02\u5E38",error:_})}};(0,N.useEffect)(()=>{var i;ut.includes(r)||(i=I.current)==null||i.call(I,{type:"banner",errCode:"UNSUPPORTED_DISPLAY_AD_TYPE",errMsg:`\u4E0D\u652F\u6301\u7684\u5C55\u793A\u5E7F\u544A\u7C7B\u578B\uFF1A${r}\uFF0C\u8BF7\u4F7F\u7528 "banner" \u6216 "splash"`})},[r]),(0,N.useEffect)(()=>{if(!e){a();return}_e()},[e,D,V,j,M,H]);let oe=Ce(),L=oe?y(q):null,ue=L?L.unitId:n||"",Ie=L?L.customAd:p||null,ve=L?L.priority:d,xe=!!($&&(!oe||!e||ye&&(L!=null&&L.show))),Te=be(),Pe=JSON.stringify([j,Te,e,z,T]),de=F.current;!!(!de||de.identity!==Pe||!de.show&&$)?F.current={identity:Pe,show:$,shouldCheck:!!(z&&!Ae(e,Te))}:de&&de.show!==$&&(F.current=E(h({},de),{show:$}));let Ke=!!((Ve=F.current)!=null&&Ve.shouldCheck),Ye=e||(q==null?void 0:q.adId)||"",re=i=>h({adId:Ye},i);return j==="splash"?(0,ze.jsx)(Ge,h({},{unitId:ue,customAd:Ie,priority:ve,show:xe,zIndex:X,pictureInPicture:Q,checkNativeSplash:Ke,jumpSeconds:f,equipmentValue:g,userId:H,className:k,onLoad:o=>{var t;o&&typeof o=="object"&&o.nativeSplash===!0&&we(),(t=K.current)==null||t.call(K,re(o))},onError:o=>{var t;(t=I.current)==null||t.call(I,re(o))},onClose:o=>{var t;(t=A.current)==null||t.call(A,re(o))},onAction:o=>{var t;(t=b.current)==null||t.call(b,re(o))},onHide:o=>{var t;(t=x.current)==null||t.call(x,re(o))},onOpenWebview:o=>{var t;(t=Y.current)==null||t.call(Y,re(o))}})):xe?(0,ze.jsx)(je,h({},{unitId:ue,customAd:Ie,priority:ve,adIntervals:ne,equipmentValue:g,userId:H,className:k,onLoad:i=>{var o;(o=K.current)==null||o.call(K,re(i))},onError:i=>{var o;(o=I.current)==null||o.call(I,re(i))},onClose:i=>{var o;(o=A.current)==null||o.call(A,re(i))},onAction:i=>{var o;(o=b.current)==null||o.call(b,re(i))},onFeedback:i=>{var o;(o=ge.current)==null||o.call(ge,re(i))},onOpenWebview:i=>{var o;(o=Y.current)==null||o.call(Y,re(i))}})):null};0&&(module.exports={BiBannerAd,BiDisplayAd,BiSplashAd});
|
package/dist/ad/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var yt=Object.defineProperty,Bt=Object.defineProperties;var At=Object.getOwnPropertyDescriptors;var ot=Object.getOwnPropertySymbols;var St=Object.prototype.hasOwnProperty,Dt=Object.prototype.propertyIsEnumerable;var at=(e,n,o)=>n in e?yt(e,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[n]=o,f=(e,n)=>{for(var o in n||(n={}))St.call(n,o)&&at(e,o,n[o]);if(ot)for(var o of ot(n))Dt.call(n,o)&&at(e,o,n[o]);return e},x=(e,n)=>Bt(e,At(n));import"./banner/index.scss";import"./splash/index.scss";import{useCallback as ke,useEffect as Je,useMemo as Pt,useRef as he,useState as qe}from"react";import{Image as Et,Text as It,View as we}from"@tarojs/components";import*as mt from"@tarojs/taro";import*as Ct from"@tarojs/components";var Fe;function $e(){if(Fe!==void 0)return Fe;try{let e=Ct;Fe=(e==null?void 0:e.AdCustom)||null}catch(e){Fe=null}return Fe}import*as Ue from"@tarojs/taro";function je(){return typeof wx!="undefined"?wx:null}function fe(e,n){let o=e==null?void 0:e.detail;return o&&typeof o=="object"?f(f({},n),o):e&&typeof e=="object"?f(f({},n),e):f({},n)}function st(e){return e?e.mediaType==="video"?e.video||"":e.mediaType==="image"?e.image||"":e.video||e.image||"":""}function lt(e,n=""){return e&&(e.poster||e.image||n)||""}function ct(e,n=""){return e?e.mediaType==="video"?!1:e.mediaType==="image"?!0:e.video?!1:e.image?!0:/\.(jpg|jpeg|png|gif|bmp|webp|svg|ico)$/i.test(String(n).trim()):!0}function ut(e){return String((e==null?void 0:e.fitMode)||"").trim().toLowerCase()==="contain"?"contain":"cover"}function Ge(e){return e&&(e.badgeText||e.adLabel)||"\u5E7F\u544A"}function dt(e,n=5){let o=e==null?void 0:e.jumpSeconds,h=o!=null?o:n;return Math.min(99,Math.max(0,Number(h)||0))}function Ke(e){var o;let n=(o=e==null?void 0:e.loadTimeout)!=null?o:e==null?void 0:e.timeout;return Math.max(1e3,Number(n)||5e3)}function vt(e,n=!1){var o,h,T,S;if(!e)return"none";if(n){let I=String(((o=e.action)==null?void 0:o.type)||e.jumpType||"").trim().toLowerCase();if(I==="miniprogram")return"miniProgram";if(I==="internal")return"internal";if(I==="web")return"web";if(I==="none")return"none"}return n&&((h=e.action)!=null&&h.appId||e.targetAppId)||e.appId||e.miniProgramAppId||e.jumpAppId?"miniProgram":n&&((T=e.action)!=null&&T.path||e.targetPath)||e.path||e.pagePath||e.jumpPath||e.targetUrl?"internal":n&&((S=e.action)!=null&&S.url||e.jumpUrl)||e.url||e.webUrl||e.h5Url?"web":"none"}function wt(e,n=!1){var o;return e&&((n?((o=e.action)==null?void 0:o.appId)||e.targetAppId:"")||e.appId||e.miniProgramAppId||e.jumpAppId)||""}function bt(e,n=!1){var o;return e&&((n?((o=e.action)==null?void 0:o.path)||e.targetPath:"")||e.path||e.pagePath||e.jumpPath||e.targetUrl)||""}function _t(e,n=!1){var h;if(!e)return"full";let o=(n?(h=e.action)==null?void 0:h.miniProgramOpenMode:"")||e.miniProgramOpenMode;return String(o||"").trim().toLowerCase()==="half"?"half":"full"}function Tt(e,n=!1){var o;return e&&((n?((o=e.action)==null?void 0:o.url)||e.jumpUrl:"")||e.url||e.webUrl||e.h5Url)||""}function Ye(e){let{customAd:n,actionDetail:o,onOpenWebview:h,onError:T,miniProgramErrorCode:S,navigateErrorCode:I,miniProgramUnsupportedErrorCode:Q,preferStandardFields:W=!1}=e;if(!n)return;let v=vt(n,W),X=wt(n,W),L=bt(n,W),m=Tt(n,W);if(v==="miniProgram"&&X){let d=je(),K=_t(n,W),w=K==="half"?d==null?void 0:d.openEmbeddedMiniProgram:d==null?void 0:d.navigateToMiniProgram;if(!d||typeof w!="function"){T==null||T(x(f({},o),{errCode:Q||S,errMsg:K==="half"?"\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u534A\u5C4F\u6253\u5F00\u5176\u4ED6\u5C0F\u7A0B\u5E8F":"\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u8DF3\u8F6C\u5230\u5176\u4ED6\u5C0F\u7A0B\u5E8F"}));return}w.call(d,{appId:X,path:L||"",fail:c=>{T==null||T(x(f({},o),{errCode:S,errMsg:(c==null?void 0:c.errMsg)||"\u8DF3\u8F6C\u5230\u5176\u4ED6\u5C0F\u7A0B\u5E8F\u5931\u8D25"}))}});return}if(v==="internal"&&L){Ue.navigateTo({url:L,fail:d=>{T==null||T(x(f({},o),{errCode:I,errMsg:(d==null?void 0:d.errMsg)||"\u9875\u9762\u8DF3\u8F6C\u5931\u8D25"}))}});return}v==="web"&&m&&(h==null||h(x(f({},o),{url:m})))}function pt(){var w;let e=je(),n=e&&typeof e.getMenuButtonBoundingClientRect=="function"?e.getMenuButtonBoundingClientRect():{},o=e&&typeof e.getWindowInfo=="function"?e.getWindowInfo():typeof Ue.getSystemInfoSync=="function"?Ue.getSystemInfoSync():{},h=Number(o.windowHeight||0),T=Number(o.screenHeight||0),S=!!(h&&T&&h===T),I=16,Q=16,W=16,v=32,X=S&&n.top?n.top:Math.max(I,Number(o.statusBarHeight||0)+4),L=S&&n.height?n.height:v,m=S&&n.top?n.top:I,d=S&&n.height?n.height:v,K=Math.max(W,Number(((w=o.safeArea)==null?void 0:w.left)||0)+W);return{isFullScreen:S,skipStyle:{top:`${m}px`,width:"156rpx",height:`${d}px`,lineHeight:`${d}px`,borderRadius:`${Math.round(d/2)}px`,left:S?`${W}px`:void 0,right:S?void 0:`${Q}px`},disclosureStyle:{top:`${m}px`,left:`${K}px`,height:`${d}px`,lineHeight:`${d}px`},combinedControlStyle:{top:`${X}px`,left:`${K}px`,height:`${L}px`}}}import{Fragment as xt,jsx as ye,jsxs as et}from"react/jsx-runtime";var Nt=[{label:"\u4E0E\u6211\u65E0\u5173",value:"irrelevant"},{label:"\u91CD\u590D\u6536\u5230\u591A\u6B21",value:"repeated"},{label:"\u5185\u5BB9\u592A\u5DEE",value:"poorContent"}];function Mt(e,n,o){return e&&n?o==="custom-first"||o==="custom-only"?"custom":"wechat":e?"wechat":n?"custom":null}var tt=({unitId:e="",customAd:n,priority:o="wechat-first",adIntervals:h=30,className:T,onLoad:S,onError:I,onClose:Q,onAction:W,onFeedback:v,onOpenWebview:X})=>{let L=Pt(()=>$e(),[]),m=n||null,d=!!(m!=null&&m.image),K=!!(e&&L),w=Mt(K,d,o),c=JSON.stringify([e,m,o,!!L]),[G,me]=qe(!!w),[Y,ae]=qe(w),[te,Be]=qe(!1),[se,J]=qe("primary"),E=he(w),N=he({wechat:!1,custom:!1}),M=he(!1),H=he(null),D=he(S),g=he(I),y=he(Q),le=he(W),b=he(v),$=he(X);Je(()=>{D.current=S,g.current=I,y.current=Q,le.current=W,b.current=v,$.current=X},[W,Q,I,v,S,X]);let _=ke(i=>{let s=i==="custom"&&m?{configId:m.configId,placementId:m.placementId,configName:m.configName,advertPlatform:m.advertPlatform}:{};return f({provider:i,type:"banner"},s)},[m]),B=ke(()=>{H.current&&(clearTimeout(H.current),H.current=null)},[]),q=ke(()=>{Be(!1),J("primary")},[]),ce=ke(i=>{B(),E.current=i,M.current=!1,ae(i),me(!0),q()},[B,q]),ue=ke((i,s)=>{var F;let p=!!e&&d?"allProvidersFailed":i==="wechat"?"wechatAdLoadFail":"customMediaLoadFail";B(),E.current=null,ae(null),me(!1),q(),(F=y.current)==null||F.call(y,{provider:i,type:"banner",reason:p,error:s})},[B,q,d,e]),de=ke((i,s,u,p)=>{var Ce;if(E.current!=="custom"||N.current.custom)return;B();let F=fe(i,_("custom")),ne=x(f({},F),{errorType:s,errCode:u,errMsg:p,mediaType:"image",rawErrCode:F.errCode,rawErrMsg:F.errMsg});if(N.current.custom=!0,(Ce=g.current)==null||Ce.call(g,ne),K&&!N.current.wechat){ce("wechat");return}ue("custom",ne)},[K,B,_,ue,ce]);Je(()=>(B(),N.current={wechat:!1,custom:!1},M.current=!1,E.current=w,ae(w),me(!!w),q(),B),[B,q,c,w]),Je(()=>{if(B(),!(!G||Y!=="custom"||!d))return H.current=setTimeout(()=>{M.current||E.current!=="custom"||de(void 0,"CUSTOM_MEDIA_LOAD_TIMEOUT","BI_BANNER_CUSTOM_MEDIA_LOAD_TIMEOUT","Banner \u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u8D85\u65F6")},Ke(m)),B},[B,de,d,Y,m,G]),Je(()=>{var s,u;if(!e||L)return;let i=x(f({},_("wechat")),{errCode:"BI_BANNER_NATIVE_AD_UNSUPPORTED",errMsg:"\u5F53\u524D\u7AEF\u4E0D\u652F\u6301\u5FAE\u4FE1\u539F\u751F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7EC4\u4EF6"});(s=g.current)==null||s.call(g,i),d||(u=y.current)==null||u.call(y,x(f({},_("wechat")),{reason:"wechatAdLoadFail",error:i}))},[L,_,d,e]);let k=i=>{var s;E.current==="wechat"&&((s=D.current)==null||s.call(D,fe(i,_("wechat"))))},R=i=>{var p;if(E.current!=="wechat"||N.current.wechat)return;let s=i!=null&&i.detail&&typeof i.detail=="object"?i.detail:{},u=x(f({},fe(i,_("wechat"))),{errCode:"BI_BANNER_WECHAT_AD_LOAD_FAIL",errMsg:String(s.errMsg||"\u5FAE\u4FE1 Banner \u5E7F\u544A\u52A0\u8F7D\u5931\u8D25"),rawErrCode:s.errCode,rawErrMsg:s.errMsg});if(N.current.wechat=!0,(p=g.current)==null||p.call(g,u),d&&!N.current.custom){ce("custom");return}ue("wechat",u)},re=i=>{var s;E.current==="wechat"&&((s=y.current)==null||s.call(y,fe(i,_("wechat"))))},O=()=>{var i;E.current!=="custom"||M.current||(B(),M.current=!0,(i=D.current)==null||i.call(D,_("custom")))},Ae=()=>{var s;if(te){q();return}let i=_("custom");(s=le.current)==null||s.call(le,i),Ye({customAd:m,actionDetail:i,onOpenWebview:u=>{var p;return(p=$.current)==null?void 0:p.call($,u)},onError:u=>{var p;return(p=g.current)==null?void 0:p.call(g,u)},miniProgramErrorCode:"BI_BANNER_NAVIGATE_MINI_PROGRAM_FAIL",navigateErrorCode:"BI_BANNER_NAVIGATE_FAIL",preferStandardFields:!0})},Me=i=>{var s;(s=i.stopPropagation)==null||s.call(i),Be(u=>!u),J("primary")},Se=i=>{var s;(s=i.stopPropagation)==null||s.call(i)},ge=i=>{var s,u;(s=i.stopPropagation)==null||s.call(i),q(),(u=b.current)==null||u.call(b,x(f({},_("custom")),{provider:"custom",action:"report"})),mt.showToast({title:"\u5DF2\u6536\u5230\u60A8\u7684\u53CD\u9988\uFF0C\u6211\u4EEC\u4F1A\u5C3D\u5FEB\u5904\u7406~",icon:"none",duration:2e3})},pe=(i,s)=>{var p,F,ne;(p=i.stopPropagation)==null||p.call(i);let u=x(f({},_("custom")),{provider:"custom",action:"dislike",reason:s.value,reasonText:s.label});B(),E.current=null,ae(null),me(!1),q(),(F=b.current)==null||F.call(b,u),(ne=y.current)==null||ne.call(y,x(f({},_("custom")),{reason:"notInterested",feedbackReason:s.value,feedbackReasonText:s.label}))},De=`bi-banner-ad${T?` ${T}`:""}`;return!G||!Y?null:Y==="wechat"&&L?ye(L,{className:De,unitId:e,adIntervals:h,onLoad:k,onError:R,onClose:re}):Y!=="custom"||!(m!=null&&m.image)?null:et(we,{className:De,children:[ye(we,{className:"bi-banner-ad__surface",onClick:Ae,children:ye(Et,{className:"bi-banner-ad__image",src:m.image,mode:"widthFix",onLoad:O,onError:i=>de(i,"CUSTOM_MEDIA_LOAD_FAIL","BI_BANNER_CUSTOM_MEDIA_LOAD_FAIL","Banner \u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u5931\u8D25")})}),et(we,{className:"bi-banner-ad__badge",onClick:Me,children:[ye(It,{children:Ge(m)}),ye(we,{className:"bi-banner-ad__badge-arrow"})]}),te?ye(we,{className:"bi-banner-ad__feedback-panel",onClick:Se,children:se==="primary"?et(xt,{children:[ye(we,{className:"bi-banner-ad__feedback-source",children:"\u7531\u8D5E\u52A9\u5546\u63D0\u4F9B\u7684\u5185\u5BB9"}),ye(we,{className:"bi-banner-ad__feedback-item",onClick:i=>{var s;(s=i.stopPropagation)==null||s.call(i),J("dislike")},children:"\u4E0D\u611F\u5174\u8DA3"}),ye(we,{className:"bi-banner-ad__feedback-item",onClick:ge,children:"\u53CD\u9988\u95EE\u9898"})]}):Nt.map(i=>ye(we,{className:"bi-banner-ad__feedback-item",onClick:s=>pe(s,i),children:i.label},i.value))}):null]})};import{useCallback as be,useEffect as ze,useMemo as Ne,useRef as j,useState as Re}from"react";import{Image as gt,Text as Ve,Video as kt,View as U}from"@tarojs/components";import{jsx as V,jsxs as _e}from"react/jsx-runtime";function Rt(e,n,o){return e&&n?o==="custom-first"||o==="custom-only"?"custom":"wechat":e?"wechat":n?"custom":null}var rt=({unitId:e="",customAd:n,priority:o="wechat-first",show:h=!0,zIndex:T=999,pictureInPicture:S=!1,checkNativeSplash:I=!0,jumpSeconds:Q=5,className:W,onLoad:v,onError:X,onClose:L,onAction:m,onHide:d,onOpenWebview:K})=>{let w=Ne(()=>$e(),[]),c=n||null,G=Ne(()=>st(c),[c]),me=Ne(()=>lt(c,G),[G,c]),Y=Ne(()=>ct(c,G),[G,c]),ae=Ne(()=>ut(c),[c]),te=Ne(()=>dt(c,Q),[Q,c]),Be=Ne(()=>Ge(c),[c]),se=Ne(()=>pt(),[]),J=!!(e&&w),E=!!(G||c!=null&&c.mediaType),N=!!G,M=Rt(J,E,o),H=JSON.stringify([e,c,o,!!w]),[D,g]=Re(!1),[y,le]=Re(M),[b,$]=Re(!1),[_,B]=Re(0),[q,ce]=Re(!1),[ue,de]=Re(!1),k=j(M),R=j({wechat:!1,custom:!1}),re=j(!1),O=j(!1),Ae=j(!1),Me=j({identity:H,show:!1}),Se=j(0),ge=j(null),pe=j(null),De=j(null),i=j(null),s=j(v),u=j(X),p=j(L),F=j(m),ne=j(d),Ce=j(K);ze(()=>{s.current=v,u.current=X,p.current=L,F.current=m,ne.current=d,Ce.current=K},[m,L,X,d,v,K]),ze(()=>{var t;!h||!e||w||(t=u.current)==null||t.call(u,{provider:"wechat",type:"splash",errCode:"BI_SPLASH_NATIVE_AD_UNSUPPORTED",errMsg:"\u5F53\u524D\u7AEF\u4E0D\u652F\u6301\u5FAE\u4FE1\u539F\u751F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7EC4\u4EF6"})},[w,h,e]);let Z=t=>{let l=t==="custom"&&c?{configId:c.configId,placementId:c.placementId,configName:c.configName,advertPlatform:c.advertPlatform}:{};return f({provider:t,type:"splash"},l)},P=be(()=>{ge.current&&clearInterval(ge.current),pe.current&&clearTimeout(pe.current),De.current&&clearTimeout(De.current),i.current&&clearTimeout(i.current),ge.current=null,pe.current=null,De.current=null,i.current=null},[]),ie=be((t,l)=>{P(),k.current=t,re.current=!1,le(t),g(l),$(!1),B(te),ce(!1),de(!1)},[P,te]),Te=be((t,l)=>{var Oe;let Ie=E&&(t==="custom"||J&&R.current.wechat&&R.current.custom),xe=Ie?"allProvidersFailed":"wechatAdLoadFail";P(),g(!1),$(!1),B(0),ce(!1),de(!1),(Oe=p.current)==null||Oe.call(p,{provider:Ie?"none":t,type:"splash",reason:xe,error:l})},[J,P,E]),ve=be(()=>{if(!(ge.current||!k.current)){if(ce(!0),te<=0){B(0);return}B(te),ge.current=setInterval(()=>{B(t=>Math.max(0,t-1))},1e3)}},[te]),Le=be(()=>{N&&(pe.current=setTimeout(()=>{var l;if(re.current||k.current!=="custom")return;let t=x(f({},Z("custom")),{errorType:"CUSTOM_MEDIA_LOAD_TIMEOUT",errCode:"BI_SPLASH_CUSTOM_MEDIA_LOAD_TIMEOUT",errMsg:"\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u8D85\u65F6",mediaType:Y?"image":"video",rawErrCode:void 0,rawErrMsg:void 0});(l=u.current)==null||l.call(u,t),R.current.custom=!0,J&&!R.current.wechat?(ie("wechat",!0),ve()):Te("custom",t)},Ke(c)))},[J,Te,N,Y,ie,c,ve]),Pe=be(t=>{ie(t,!0),t==="wechat"?ve():N&&Le()},[N,ie,ve,Le]),Ee=be((t,l,C,A)=>{var Oe;if(k.current!=="custom"||R.current.custom)return;let Ie=fe(t,Z("custom")),xe=x(f({},Ie),{errorType:l,errCode:C,errMsg:A,mediaType:Y?"image":"video",rawErrCode:Ie.errCode,rawErrMsg:Ie.errMsg});(Oe=u.current)==null||Oe.call(u,xe),R.current.custom=!0,J&&!R.current.wechat?Pe("wechat"):Te("custom",xe)},[J,Te,Y,Pe]),oe=be(()=>{var t;if(O.current){g(!1);return}if(!M){ie(null,!1),Ae.current||(Ae.current=!0,(t=p.current)==null||t.call(p,{provider:"none",type:"splash",reason:"noAd"}));return}Pe(M),M==="custom"&&!N&&Ee(void 0,"CUSTOM_MEDIA_LOAD_FAIL","BI_SPLASH_CUSTOM_MEDIA_LOAD_FAIL","\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u4E3B\u7D20\u6750\u5730\u5740\u4E3A\u7A7A")},[Ee,N,M,ie,Pe]),We=be(()=>{if(!h||O.current)return;if(!I){oe();return}let t=je();if(!(t!=null&&t.getShowSplashAdStatus)||Se.current>=3){oe();return}t.getShowSplashAdStatus({success:l=>{var C;if((l==null?void 0:l.code)===-1){Se.current+=1,De.current=setTimeout(We,300);return}if((l==null?void 0:l.code)===1){P(),O.current=!0,g(!1),(C=s.current)==null||C.call(s,{provider:"wechat",type:"splash",nativeSplash:!0});return}oe()},fail:oe})},[oe,I,P,h]);ze(()=>{let t=Me.current,l=h&&!t.show||t.identity!==H;if(Me.current={identity:H,show:h},!h){O.current=!1,Ae.current=!1,R.current={wechat:!1,custom:!1},ie(M,!1);return}if(!O.current)return l&&(Ae.current=!1),R.current={wechat:!1,custom:!1},O.current=!1,Se.current=0,ie(M,!1),We(),P},[We,P,H,M,ie,h]),ze(()=>{var l;if(!q||_!==0||!D||b||!k.current)return;let t=k.current;if(S){P(),de(!0),i.current=setTimeout(()=>{var C;$(!0),de(!1),(C=ne.current)==null||C.call(ne,Z(t))},280);return}P(),g(!1),(l=p.current)==null||l.call(p,Z(t))},[P,q,S,_,b,D]);let Xe=t=>{var l;k.current==="wechat"&&(ve(),(l=s.current)==null||l.call(s,fe(t,Z("wechat"))))},Qe=t=>{var A;if(k.current!=="wechat"||R.current.wechat)return;let l=t!=null&&t.detail&&typeof t.detail=="object"?t.detail:{},C=x(f({},fe(t,Z("wechat"))),{errCode:"BI_SPLASH_WECHAT_AD_LOAD_FAIL",errMsg:String(l.errMsg||"\u5FAE\u4FE1\u5F00\u5C4F\u5E7F\u544A\u52A0\u8F7D\u5931\u8D25"),rawErrCode:l.errCode,rawErrMsg:l.errMsg});(A=u.current)==null||A.call(u,C),R.current.wechat=!0,E&&!R.current.custom?(Pe("custom"),N||Ee(void 0,"CUSTOM_MEDIA_LOAD_FAIL","BI_SPLASH_CUSTOM_MEDIA_LOAD_FAIL","\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u4E3B\u7D20\u6750\u5730\u5740\u4E3A\u7A7A")):Te("wechat",C)},z=()=>{var t;k.current!=="custom"||re.current||(pe.current&&clearTimeout(pe.current),pe.current=null,re.current=!0,ve(),(t=s.current)==null||t.call(s,Z("custom")))},Ze=t=>{var C;(C=t==null?void 0:t.stopPropagation)==null||C.call(t),k.current&&(ce(!0),B(0))},He=()=>{var l;if(k.current!=="custom")return;let t=Z("custom");(l=F.current)==null||l.call(F,t),Ye({customAd:c,actionDetail:t,onOpenWebview:C=>{var A;return(A=Ce.current)==null?void 0:A.call(Ce,C)},onError:C=>{var A;return(A=u.current)==null?void 0:A.call(u,C)},miniProgramErrorCode:"BI_SPLASH_NAVIGATE_MINI_PROGRAM_FAIL",navigateErrorCode:"BI_SPLASH_NAVIGATE_FAIL",preferStandardFields:!0})},r=t=>{var l;P(),g(!1),$(!1),B(0),ce(!1),(l=p.current)==null||l.call(p,t)},a=["bi-splash-ad",b?"bi-splash-ad--pip":"",ue?"bi-splash-ad--pip-animating":"",W||""].filter(Boolean).join(" ");return!D||!y?null:_e(U,{className:a,style:{zIndex:T},children:[y==="wechat"&&w?V(U,{className:"bi-splash-ad__popup",children:V(U,{className:`bi-splash-ad__media-wrapper${b?" bi-splash-ad__media-wrapper--pip":""}`,children:V(w,{className:"bi-splash-ad__wechat-unit",unitId:e,onLoad:Xe,onError:Qe,onClose:t=>r(fe(t,Z("wechat")))})})}):y==="custom"&&N?V(U,{className:"bi-splash-ad__popup bi-splash-ad__custom",children:_e(U,{className:"bi-splash-ad__media-shell",onClick:He,children:[Y?V(gt,{className:"bi-splash-ad__media",src:G,mode:ae==="cover"?"aspectFill":"aspectFit",onLoad:z,onError:t=>Ee(t,"CUSTOM_MEDIA_LOAD_FAIL","BI_SPLASH_CUSTOM_MEDIA_LOAD_FAIL","\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u5931\u8D25")}):V(kt,{className:"bi-splash-ad__video",src:G,poster:me,autoplay:!0,muted:(c==null?void 0:c.muted)!==!1,loop:!0,objectFit:ae,showCenterPlayBtn:!1,showPlayBtn:!1,controls:!1,onLoadedMetaData:z,onError:t=>Ee(t,"CUSTOM_MEDIA_LOAD_FAIL","BI_SPLASH_CUSTOM_MEDIA_LOAD_FAIL","\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u5931\u8D25")}),b?V(U,{className:"bi-splash-ad__pip-mask"}):null,!b&&!se.isFullScreen?_e(U,{className:"bi-splash-ad__disclosure",style:se.disclosureStyle,children:[V(Ve,{children:Be}),V(U,{className:"bi-splash-ad__disclosure-arrow"})]}):null,!b&&(c!=null&&c.bottomImage)?V(gt,{className:"bi-splash-ad__bottom-image",src:c.bottomImage,mode:"widthFix"}):null]})}):null,b?V(U,{className:"bi-splash-ad__pip-close",onClick:()=>r(Z(y)),children:V(U,{className:"bi-splash-ad__pip-close-text",children:"\u5173\u95ED"})}):null,!b&&se.isFullScreen&&y==="custom"?_e(U,{className:"bi-splash-ad__combined-control",style:se.combinedControlStyle,children:[_e(U,{className:"bi-splash-ad__combined-capsule",children:[_e(U,{className:"bi-splash-ad__combined-disclosure",children:[V(Ve,{children:Be}),V(U,{className:"bi-splash-ad__disclosure-arrow"})]}),V(U,{className:"bi-splash-ad__combined-divider"}),V(U,{className:"bi-splash-ad__combined-skip",onClick:Ze,children:"\u8DF3\u8FC7"})]}),_e(Ve,{className:"bi-splash-ad__combined-countdown",children:[_," \u79D2"]})]}):b?null:_e(U,{className:"bi-splash-ad__skip",style:se.skipStyle,onClick:Ze,children:[_e(Ve,{children:[_,"s"]}),V(U,{className:"bi-splash-ad__skip-divider"}),V(Ve,{className:"bi-splash-ad__skip-text",children:"\u8DF3\u8FC7"})]})]})};import{useEffect as nt,useMemo as Lt,useRef as ee,useState as it}from"react";import{jsx as ht}from"react/jsx-runtime";var Ot="BI_DISPLAY_NATIVE_SPLASH_CONSUMED",Ft=300*1e3,ft=["banner","splash"],Ut=({adId:e="",unitId:n,type:o="banner",customAd:h,priority:T="wechat-first",adOptions:S=null,sdkKey:I="biNova",autoLoad:Q=!0,adIntervals:W=30,show:v=!0,zIndex:X=999,pictureInPicture:L=!1,checkNativeSplash:m=!0,nativeSplashCache:d=!0,jumpSeconds:K=5,className:w,onLoad:c,onError:G,onClose:me,onAction:Y,onFeedback:ae,onHide:te,onOpenWebview:Be,onConfigLoad:se,onConfigError:J})=>{var He;let E=ee(0),N=ee(""),M=ee(null),H=ee(c),D=ee(G),g=ee(me),y=ee(Y),le=ee(ae),b=ee(te),$=ee(Be),_=ee(se),B=ee(J),q=ee(v),[ce,ue]=it(!1),[de,k]=it(!1),[R,re]=it(null);nt(()=>{H.current=c,D.current=G,g.current=me,y.current=Y,le.current=ae,b.current=te,$.current=Be,_.current=se,B.current=J,q.current=v},[Y,me,J,se,G,ae,te,c,Be,v]);let O=Lt(()=>ft.includes(o)?o:"banner",[o]),Ae=()=>!!(Q&&e),Me=()=>{var l;let r=globalThis.getApp,a=typeof r=="function"?r():null;if(!a)return null;let t=a;return t[I]||((l=t.globalData)==null?void 0:l[I])||null},Se=()=>{var r;try{if(typeof wx!="undefined"&&typeof wx.getAccountInfoSync=="function"){let a=wx.getAccountInfoSync();return((r=a==null?void 0:a.miniProgram)==null?void 0:r.appId)||""}}catch(a){return""}return""},ge=(r,a)=>`${Ot}_${a||"unknown"}_${r||"empty"}`,pe=(r,a)=>{if(!d||!r||typeof wx=="undefined"||typeof wx.getStorageSync!="function")return!1;try{let t=ge(r,a),l=Number(wx.getStorageSync(t)||0),C=Date.now()-l;return l>0&&C>=0&&C<=Ft}catch(t){return!1}},De=()=>{if(d&&!(!e||typeof wx=="undefined"||typeof wx.setStorageSync!="function"))try{let r=ge(e,Se());wx.setStorageSync(r,Date.now())}catch(r){}},i=()=>{E.current+=1,N.current="",ue(!1),k(!1),re(null)},s=()=>{let r=S&&typeof S=="object"?S:{},a=Se();return x(f({},r),{adId:e,placementId:r.placementId||e,appId:r.appId||a,type:O})},u=r=>{try{return JSON.stringify(r||{})}catch(a){return`${String(r.appId||"")}_${String(r.placementId||"")}`}},p=r=>{let a=(r==null?void 0:r.unitId)||"",t=(r==null?void 0:r.customAd)||(r==null?void 0:r.custom)||null,l=typeof(r==null?void 0:r.show)=="boolean"?r.show:!!(a||t);return{unitId:a,customAd:t,priority:(r==null?void 0:r.priority)||"wechat-first",show:l}},F=r=>{var a,t;(a=B.current)==null||a.call(B,r),(t=D.current)==null||t.call(D,r)},ne=r=>{var a;(a=g.current)==null||a.call(g,{type:O,adId:e||r.adId||"",provider:"none",reason:"noAd"})},Ce=async()=>{var C;if(!Ae())return;let r=s(),a=u(r);if(N.current===a&&(ce||de))return;let t=Me();if(!(t!=null&&t.ads)||typeof t.ads.getDisplayAdConfig!="function"){i(),F({type:O,adId:e,errCode:"DISPLAY_AD_SDK_NOT_READY",errMsg:"\u672A\u83B7\u53D6\u5230\u53EF\u7528\u7684\u5E7F\u544A\u670D\u52A1 SDK\uFF0C\u8BF7\u5148\u6CE8\u5165\u5168\u5C40 biNova \u5B9E\u4F8B"});return}let l=E.current+1;E.current=l,N.current=a,ue(!0),k(!1),re(null);try{let A=await t.ads.getDisplayAdConfig(r);if(l!==E.current)return;if(!A||A.code!==0||!A.data){ue(!1),k(!0),re(null),F({type:O,adId:e,errCode:"DISPLAY_AD_REMOTE_CONFIG_FAIL",errMsg:(A==null?void 0:A.message)||"\u83B7\u53D6\u5C55\u793A\u5E7F\u544A\u914D\u7F6E\u5931\u8D25",rawResult:A||null});return}let Ie=p(A.data),xe=!!(q.current&&!Ie.show);ue(!1),k(!0),re(A.data),(C=_.current)==null||C.call(_,{type:O,adId:e,requestOptions:r,data:A.data}),xe&&ne(A.data)}catch(A){if(l!==E.current)return;ue(!1),k(!0),re(null),F({type:O,adId:e,errCode:"DISPLAY_AD_REMOTE_CONFIG_EXCEPTION",errMsg:A instanceof Error?A.message:"\u83B7\u53D6\u5C55\u793A\u5E7F\u544A\u914D\u7F6E\u5F02\u5E38",error:A})}};nt(()=>{var r;ft.includes(o)||(r=D.current)==null||r.call(D,{type:"banner",errCode:"UNSUPPORTED_DISPLAY_AD_TYPE",errMsg:`\u4E0D\u652F\u6301\u7684\u5C55\u793A\u5E7F\u544A\u7C7B\u578B\uFF1A${o}\uFF0C\u8BF7\u4F7F\u7528 "banner" \u6216 "splash"`})},[o]),nt(()=>{if(!e){i();return}Ce()},[e,S,Q,O,I]);let Z=Ae(),P=Z?p(R):null,ie=P?P.unitId:n||"",Te=P?P.customAd:h||null,ve=P?P.priority:T,Le=!!(v&&(!Z||!e||de&&(P!=null&&P.show))),Pe=Se(),Ee=JSON.stringify([O,Pe,e,m,d]),oe=M.current;!!(!oe||oe.identity!==Ee||!oe.show&&v)?M.current={identity:Ee,show:v,shouldCheck:!!(m&&!pe(e,Pe))}:oe&&oe.show!==v&&(M.current=x(f({},oe),{show:v}));let Xe=!!((He=M.current)!=null&&He.shouldCheck),Qe=e||(R==null?void 0:R.adId)||"",z=r=>f({adId:Qe},r);return O==="splash"?ht(rt,f({},{unitId:ie,customAd:Te,priority:ve,show:Le,zIndex:X,pictureInPicture:L,checkNativeSplash:Xe,jumpSeconds:K,className:w,onLoad:a=>{var t;a&&typeof a=="object"&&a.nativeSplash===!0&&De(),(t=H.current)==null||t.call(H,z(a))},onError:a=>{var t;(t=D.current)==null||t.call(D,z(a))},onClose:a=>{var t;(t=g.current)==null||t.call(g,z(a))},onAction:a=>{var t;(t=y.current)==null||t.call(y,z(a))},onHide:a=>{var t;(t=b.current)==null||t.call(b,z(a))},onOpenWebview:a=>{var t;(t=$.current)==null||t.call($,z(a))}})):Le?ht(tt,f({},{unitId:ie,customAd:Te,priority:ve,adIntervals:W,className:w,onLoad:r=>{var a;(a=H.current)==null||a.call(H,z(r))},onError:r=>{var a;(a=D.current)==null||a.call(D,z(r))},onClose:r=>{var a;(a=g.current)==null||a.call(g,z(r))},onAction:r=>{var a;(a=y.current)==null||a.call(y,z(r))},onFeedback:r=>{var a;(a=le.current)==null||a.call(le,z(r))},onOpenWebview:r=>{var a;(a=$.current)==null||a.call($,z(r))}})):null};export{tt as BiBannerAd,Ut as BiDisplayAd,rt as BiSplashAd};
|
|
1
|
+
var St=Object.defineProperty,Dt=Object.defineProperties;var Ct=Object.getOwnPropertyDescriptors;var st=Object.getOwnPropertySymbols;var bt=Object.prototype.hasOwnProperty,wt=Object.prototype.propertyIsEnumerable;var lt=(e,n,r)=>n in e?St(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,f=(e,n)=>{for(var r in n||(n={}))bt.call(n,r)&<(e,r,n[r]);if(st)for(var r of st(n))wt.call(n,r)&<(e,r,n[r]);return e},v=(e,n)=>Dt(e,Ct(n));import"./banner/index.scss";import"./splash/index.scss";import{useCallback as Oe,useEffect as Qe,useMemo as xt,useRef as Ae,useState as ze}from"react";import{Image as Rt,Text as Lt,View as ve}from"@tarojs/components";import*as ht from"@tarojs/taro";import*as _t from"@tarojs/components";var $e;function Ge(){if($e!==void 0)return $e;try{let e=_t;$e=(e==null?void 0:e.AdCustom)||null}catch(e){$e=null}return $e}import*as xe from"@tarojs/taro";function Ke(){return typeof wx!="undefined"?wx:null}function ye(e,n){let r=e==null?void 0:e.detail;return r&&typeof r=="object"?f(f({},n),r):e&&typeof e=="object"?f(f({},n),e):f({},n)}function ut(e){return e?e.mediaType==="video"?e.video||"":e.mediaType==="image"?e.image||"":e.video||e.image||"":""}function dt(e,n=""){return e&&(e.poster||e.image||n)||""}function pt(e,n=""){return e?e.mediaType==="video"?!1:e.mediaType==="image"?!0:e.video?!1:e.image?!0:/\.(jpg|jpeg|png|gif|bmp|webp|svg|ico)$/i.test(String(n).trim()):!0}function mt(e){return String((e==null?void 0:e.fitMode)||"").trim().toLowerCase()==="contain"?"contain":"cover"}function Ye(e){return e&&(e.badgeText||e.adLabel)||"\u5E7F\u544A"}function gt(e,n=5){let r=e==null?void 0:e.jumpSeconds,d=r!=null?r:n;return Math.min(99,Math.max(0,Number(d)||0))}function Je(e){var r;let n=(r=e==null?void 0:e.loadTimeout)!=null?r:e==null?void 0:e.timeout;return Math.max(1e3,Number(n)||5e3)}function vt(e,n=!1){var r,d,g,A;if(!e)return"none";if(n){let I=String(((r=e.action)==null?void 0:r.type)||e.jumpType||"").trim().toLowerCase();if(I==="miniprogram")return"miniProgram";if(I==="internal")return"internal";if(I==="web")return"web";if(I==="api")return"api";if(I==="none")return"none"}return n&&((d=e.action)!=null&&d.appId||e.targetAppId)||e.appId||e.miniProgramAppId||e.jumpAppId?"miniProgram":n&&((g=e.action)!=null&&g.path||e.targetPath)||e.path||e.pagePath||e.jumpPath||e.targetUrl?"internal":n&&((A=e.action)!=null&&A.url||e.jumpUrl)||e.url||e.webUrl||e.h5Url?"web":"none"}function It(e,n=!1){var r;return e&&((n?((r=e.action)==null?void 0:r.appId)||e.targetAppId:"")||e.appId||e.miniProgramAppId||e.jumpAppId)||""}function Tt(e,n=!1){var r;return e&&((n?((r=e.action)==null?void 0:r.path)||e.targetPath:"")||e.path||e.pagePath||e.jumpPath||e.targetUrl)||""}function Pt(e,n=!1){var d;if(!e)return"full";let r=(n?(d=e.action)==null?void 0:d.miniProgramOpenMode:"")||e.miniProgramOpenMode;return String(r||"").trim().toLowerCase()==="half"?"half":"full"}function Et(e,n=!1){var r;return e&&((n?((r=e.action)==null?void 0:r.url)||e.jumpUrl:"")||e.url||e.webUrl||e.h5Url)||""}function Nt(e){return e!=null&&e!==""}function ct(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Mt(e,n){let r=e.indexOf("#"),d=r>=0?e.slice(r):"",g=r>=0?e.slice(0,r):e,A=Object.keys(n).map(R=>`${encodeURIComponent(R)}=${encodeURIComponent(String(n[R]))}`).join("&");if(!A)return e;let I=g.includes("?")?/[?&]$/.test(g)?"":"&":"?";return`${g}${I}${A}${d}`}function kt(e,n){var R;let r=ct(e==null?void 0:e.data)?e.data:null,d=ct(r==null?void 0:r.body)?r.body:null,g=String((d==null?void 0:d.appId)||"").trim(),A=String((d==null?void 0:d.url)||"").trim().replace(/^\/+/,"");if(String((r==null?void 0:r.code)||"")!=="200"||!g||!A){(R=n.onError)==null||R.call(n,v(f({},n.actionDetail),{errCode:n.apiRequestErrorCode||"BI_CUSTOM_AD_API_REQUEST_FAIL",errMsg:String((r==null?void 0:r.message)||"\u5E7F\u544A\u63A5\u53E3\u54CD\u5E94\u5F02\u5E38")}));return}We(v(f({},n),{customAd:{action:{type:"miniProgram",appId:g,path:A}},preferStandardFields:!0}))}function We(e){let{customAd:n,actionDetail:r,onOpenWebview:d,onError:g,miniProgramErrorCode:A,navigateErrorCode:I,miniProgramUnsupportedErrorCode:R,apiRequestErrorCode:ee,apiRequestParams:L,preferStandardFields:J=!1}=e;if(!n)return;let K=vt(n,J),Y=It(n,J),w=Tt(n,J),m=Et(n,J);if(K==="miniProgram"&&Y){let p=Ke(),F=Pt(n,J),T=F==="half"?p==null?void 0:p.openEmbeddedMiniProgram:p==null?void 0:p.navigateToMiniProgram;if(!p||typeof T!="function"){g==null||g(v(f({},r),{errCode:R||A,errMsg:F==="half"?"\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u534A\u5C4F\u6253\u5F00\u5176\u4ED6\u5C0F\u7A0B\u5E8F":"\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u8DF3\u8F6C\u5230\u5176\u4ED6\u5C0F\u7A0B\u5E8F"}));return}T.call(p,{appId:Y,path:w||"",fail:c=>{g==null||g(v(f({},r),{errCode:A,errMsg:(c==null?void 0:c.errMsg)||"\u8DF3\u8F6C\u5230\u5176\u4ED6\u5C0F\u7A0B\u5E8F\u5931\u8D25"}))}});return}if(K==="internal"&&w){xe.navigateTo({url:w,fail:p=>{g==null||g(v(f({},r),{errCode:I,errMsg:(p==null?void 0:p.errMsg)||"\u9875\u9762\u8DF3\u8F6C\u5931\u8D25"}))}});return}if(K==="web"&&m){d==null||d(v(f({},r),{url:m}));return}if(K==="api"&&m){let p=L||{},T=["configId","equipmentValue","userId"].filter(C=>{let te=p[C];return C==="userId"?!Number.isInteger(te)||Number(te)<=0:!Nt(te)});if(T.length){g==null||g(v(f({},r),{errCode:ee||"BI_CUSTOM_AD_API_REQUEST_FAIL",errMsg:`\u63A5\u53E3\u578B\u5E7F\u544A\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570\u6216\u53C2\u6570\u503C\u65E0\u6548\uFF1A${T.join("\u3001")}`}));return}let c=Mt(m,{configId:p.configId,equipmentValue:p.equipmentValue,userId:p.userId});xe.request({url:c,method:"GET",success:C=>{kt(C,e)},fail:C=>{g==null||g(v(f({},r),{errCode:ee||"BI_CUSTOM_AD_API_REQUEST_FAIL",errMsg:(C==null?void 0:C.errMsg)||"\u5E7F\u544A\u63A5\u53E3\u8BF7\u6C42\u5931\u8D25"}))}})}}function ft(){var p;let e=Ke(),n=e&&typeof e.getMenuButtonBoundingClientRect=="function"?e.getMenuButtonBoundingClientRect():{},r=e&&typeof e.getWindowInfo=="function"?e.getWindowInfo():typeof xe.getSystemInfoSync=="function"?xe.getSystemInfoSync():{},d=Number(r.windowHeight||0),g=Number(r.screenHeight||0),A=!!(d&&g&&d===g),I=16,R=16,ee=16,L=32,J=A&&n.top?n.top:Math.max(I,Number(r.statusBarHeight||0)+4),K=A&&n.height?n.height:L,Y=A&&n.top?n.top:I,w=A&&n.height?n.height:L,m=Math.max(ee,Number(((p=r.safeArea)==null?void 0:p.left)||0)+ee);return{isFullScreen:A,skipStyle:{top:`${Y}px`,width:"156rpx",height:`${w}px`,lineHeight:`${w}px`,borderRadius:`${Math.round(w/2)}px`,left:A?`${ee}px`:void 0,right:A?void 0:`${R}px`},disclosureStyle:{top:`${Y}px`,left:`${m}px`,height:`${w}px`,lineHeight:`${w}px`},combinedControlStyle:{top:`${J}px`,left:`${m}px`,height:`${K}px`}}}import{Fragment as Ft,jsx as Be,jsxs as rt}from"react/jsx-runtime";var Ot=[{label:"\u4E0E\u6211\u65E0\u5173",value:"irrelevant"},{label:"\u91CD\u590D\u6536\u5230\u591A\u6B21",value:"repeated"},{label:"\u5185\u5BB9\u592A\u5DEE",value:"poorContent"}];function Ut(e,n,r){return e&&n?r==="custom-first"||r==="custom-only"?"custom":"wechat":e?"wechat":n?"custom":null}var nt=({unitId:e="",customAd:n,priority:r="wechat-first",adIntervals:d=30,equipmentValue:g="",userId:A=0,className:I,onLoad:R,onError:ee,onClose:L,onAction:J,onFeedback:K,onOpenWebview:Y})=>{let w=xt(()=>Ge(),[]),m=n||null,p=!!(m!=null&&m.image),F=!!(e&&w),T=Ut(F,p,r),c=JSON.stringify([e,m,r,!!w]),[C,te]=ze(!!T),[Q,ce]=ze(T),[ie,Se]=ze(!1),[ue,z]=ze("primary"),M=Ae(T),k=Ae({wechat:!1,custom:!1}),x=Ae(!1),H=Ae(null),b=Ae(R),y=Ae(ee),B=Ae(L),de=Ae(J),P=Ae(K),j=Ae(Y);Qe(()=>{b.current=R,y.current=ee,B.current=L,de.current=J,P.current=K,j.current=Y},[J,L,ee,K,R,Y]);let E=Oe(a=>{let s=a==="custom"&&m?{configId:m.configId,placementId:m.placementId,configName:m.configName,advertPlatform:m.advertPlatform}:{};return f({provider:a,type:"banner"},s)},[m]),S=Oe(()=>{H.current&&(clearTimeout(H.current),H.current=null)},[]),X=Oe(()=>{Se(!1),z("primary")},[]),pe=Oe(a=>{S(),M.current=a,x.current=!1,ce(a),te(!0),X()},[S,X]),me=Oe((a,s)=>{var $;let h=!!e&&p?"allProvidersFailed":a==="wechat"?"wechatAdLoadFail":"customMediaLoadFail";S(),M.current=null,ce(null),te(!1),X(),($=B.current)==null||$.call(B,{provider:a,type:"banner",reason:h,error:s})},[S,X,p,e]),ge=Oe((a,s,u,h)=>{var we;if(M.current!=="custom"||k.current.custom)return;S();let $=ye(a,E("custom")),oe=v(f({},$),{errorType:s,errCode:u,errMsg:h,mediaType:"image",rawErrCode:$.errCode,rawErrMsg:$.errMsg});if(k.current.custom=!0,(we=y.current)==null||we.call(y,oe),F&&!k.current.wechat){pe("wechat");return}me("custom",oe)},[F,S,E,me,pe]);Qe(()=>(S(),k.current={wechat:!1,custom:!1},x.current=!1,M.current=T,ce(T),te(!!T),X(),S),[S,X,c,T]),Qe(()=>{if(S(),!(!C||Q!=="custom"||!p))return H.current=setTimeout(()=>{x.current||M.current!=="custom"||ge(void 0,"CUSTOM_MEDIA_LOAD_TIMEOUT","BI_BANNER_CUSTOM_MEDIA_LOAD_TIMEOUT","Banner \u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u8D85\u65F6")},Je(m)),S},[S,ge,p,Q,m,C]),Qe(()=>{var s,u;if(!e||w)return;let a=v(f({},E("wechat")),{errCode:"BI_BANNER_NATIVE_AD_UNSUPPORTED",errMsg:"\u5F53\u524D\u7AEF\u4E0D\u652F\u6301\u5FAE\u4FE1\u539F\u751F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7EC4\u4EF6"});(s=y.current)==null||s.call(y,a),p||(u=B.current)==null||u.call(B,v(f({},E("wechat")),{reason:"wechatAdLoadFail",error:a}))},[w,E,p,e]);let O=a=>{var s;M.current==="wechat"&&((s=b.current)==null||s.call(b,ye(a,E("wechat"))))},U=a=>{var h;if(M.current!=="wechat"||k.current.wechat)return;let s=a!=null&&a.detail&&typeof a.detail=="object"?a.detail:{},u=v(f({},ye(a,E("wechat"))),{errCode:"BI_BANNER_WECHAT_AD_LOAD_FAIL",errMsg:String(s.errMsg||"\u5FAE\u4FE1 Banner \u5E7F\u544A\u52A0\u8F7D\u5931\u8D25"),rawErrCode:s.errCode,rawErrMsg:s.errMsg});if(k.current.wechat=!0,(h=y.current)==null||h.call(y,u),p&&!k.current.custom){pe("custom");return}me("wechat",u)},ae=a=>{var s;M.current==="wechat"&&((s=B.current)==null||s.call(B,ye(a,E("wechat"))))},V=()=>{var a;M.current!=="custom"||x.current||(S(),x.current=!0,(a=b.current)==null||a.call(b,E("custom")))},De=()=>{var s;if(ie){X();return}let a=E("custom");(s=de.current)==null||s.call(de,a),We({customAd:m,actionDetail:a,onOpenWebview:u=>{var h;return(h=j.current)==null?void 0:h.call(j,u)},onError:u=>{var h;return(h=y.current)==null?void 0:h.call(y,u)},miniProgramErrorCode:"BI_BANNER_NAVIGATE_MINI_PROGRAM_FAIL",navigateErrorCode:"BI_BANNER_NAVIGATE_FAIL",apiRequestErrorCode:"BI_BANNER_API_REQUEST_FAIL",apiRequestParams:{configId:m==null?void 0:m.configId,equipmentValue:g,userId:A},preferStandardFields:!0})},Re=a=>{var s;(s=a.stopPropagation)==null||s.call(a),Se(u=>!u),z("primary")},Ce=a=>{var s;(s=a.stopPropagation)==null||s.call(a)},he=a=>{var s,u;(s=a.stopPropagation)==null||s.call(a),X(),(u=P.current)==null||u.call(P,v(f({},E("custom")),{provider:"custom",action:"report"})),ht.showToast({title:"\u5DF2\u6536\u5230\u60A8\u7684\u53CD\u9988\uFF0C\u6211\u4EEC\u4F1A\u5C3D\u5FEB\u5904\u7406~",icon:"none",duration:2e3})},fe=(a,s)=>{var h,$,oe;(h=a.stopPropagation)==null||h.call(a);let u=v(f({},E("custom")),{provider:"custom",action:"dislike",reason:s.value,reasonText:s.label});S(),M.current=null,ce(null),te(!1),X(),($=P.current)==null||$.call(P,u),(oe=B.current)==null||oe.call(B,v(f({},E("custom")),{reason:"notInterested",feedbackReason:s.value,feedbackReasonText:s.label}))},be=`bi-banner-ad${I?` ${I}`:""}`;return!C||!Q?null:Q==="wechat"&&w?Be(w,{className:be,unitId:e,adIntervals:d,onLoad:O,onError:U,onClose:ae}):Q!=="custom"||!(m!=null&&m.image)?null:rt(ve,{className:be,children:[Be(ve,{className:"bi-banner-ad__surface",onClick:De,children:Be(Rt,{className:"bi-banner-ad__image",src:m.image,mode:"widthFix",onLoad:V,onError:a=>ge(a,"CUSTOM_MEDIA_LOAD_FAIL","BI_BANNER_CUSTOM_MEDIA_LOAD_FAIL","Banner \u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u5931\u8D25")})}),rt(ve,{className:"bi-banner-ad__badge",onClick:Re,children:[Be(Lt,{children:Ye(m)}),Be(ve,{className:"bi-banner-ad__badge-arrow"})]}),ie?Be(ve,{className:"bi-banner-ad__feedback-panel",onClick:Ce,children:ue==="primary"?rt(Ft,{children:[Be(ve,{className:"bi-banner-ad__feedback-source",children:"\u7531\u8D5E\u52A9\u5546\u63D0\u4F9B\u7684\u5185\u5BB9"}),Be(ve,{className:"bi-banner-ad__feedback-item",onClick:a=>{var s;(s=a.stopPropagation)==null||s.call(a),z("dislike")},children:"\u4E0D\u611F\u5174\u8DA3"}),Be(ve,{className:"bi-banner-ad__feedback-item",onClick:he,children:"\u53CD\u9988\u95EE\u9898"})]}):Ot.map(a=>Be(ve,{className:"bi-banner-ad__feedback-item",onClick:s=>fe(s,a),children:a.label},a.value))}):null]})};import{useCallback as Ie,useEffect as Xe,useMemo as ke,useRef as G,useState as Ue}from"react";import{Image as yt,Text as qe,Video as Vt,View as W}from"@tarojs/components";import{jsx as q,jsxs as Te}from"react/jsx-runtime";function $t(e,n,r){return e&&n?r==="custom-first"||r==="custom-only"?"custom":"wechat":e?"wechat":n?"custom":null}var it=({unitId:e="",customAd:n,priority:r="wechat-first",show:d=!0,zIndex:g=999,pictureInPicture:A=!1,checkNativeSplash:I=!0,jumpSeconds:R=5,equipmentValue:ee="",userId:L=0,className:J,onLoad:K,onError:Y,onClose:w,onAction:m,onHide:p,onOpenWebview:F})=>{let T=ke(()=>Ge(),[]),c=n||null,C=ke(()=>ut(c),[c]),te=ke(()=>dt(c,C),[C,c]),Q=ke(()=>pt(c,C),[C,c]),ce=ke(()=>mt(c),[c]),ie=ke(()=>gt(c,R),[R,c]),Se=ke(()=>Ye(c),[c]),ue=ke(()=>ft(),[]),z=!!(e&&T),M=!!(C||c!=null&&c.mediaType),k=!!C,x=$t(z,M,r),H=JSON.stringify([e,c,r,!!T]),[b,y]=Ue(!1),[B,de]=Ue(x),[P,j]=Ue(!1),[E,S]=Ue(0),[X,pe]=Ue(!1),[me,ge]=Ue(!1),O=G(x),U=G({wechat:!1,custom:!1}),ae=G(!1),V=G(!1),De=G(!1),Re=G({identity:H,show:!1}),Ce=G(0),he=G(null),fe=G(null),be=G(null),a=G(null),s=G(K),u=G(Y),h=G(w),$=G(m),oe=G(p),we=G(F);Xe(()=>{s.current=K,u.current=Y,h.current=w,$.current=m,oe.current=p,we.current=F},[m,w,Y,p,K,F]),Xe(()=>{var t;!d||!e||T||(t=u.current)==null||t.call(u,{provider:"wechat",type:"splash",errCode:"BI_SPLASH_NATIVE_AD_UNSUPPORTED",errMsg:"\u5F53\u524D\u7AEF\u4E0D\u652F\u6301\u5FAE\u4FE1\u539F\u751F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7EC4\u4EF6"})},[T,d,e]);let re=t=>{let l=t==="custom"&&c?{configId:c.configId,placementId:c.placementId,configName:c.configName,advertPlatform:c.advertPlatform}:{};return f({provider:t,type:"splash"},l)},N=Ie(()=>{he.current&&clearInterval(he.current),fe.current&&clearTimeout(fe.current),be.current&&clearTimeout(be.current),a.current&&clearTimeout(a.current),he.current=null,fe.current=null,be.current=null,a.current=null},[]),se=Ie((t,l)=>{N(),O.current=t,ae.current=!1,de(t),y(l),j(!1),S(ie),pe(!1),ge(!1)},[N,ie]),Pe=Ie((t,l)=>{var Ve;let Me=M&&(t==="custom"||z&&U.current.wechat&&U.current.custom),Le=Me?"allProvidersFailed":"wechatAdLoadFail";N(),y(!1),j(!1),S(0),pe(!1),ge(!1),(Ve=h.current)==null||Ve.call(h,{provider:Me?"none":t,type:"splash",reason:Le,error:l})},[z,N,M]),_e=Ie(()=>{if(!(he.current||!O.current)){if(pe(!0),ie<=0){S(0);return}S(ie),he.current=setInterval(()=>{S(t=>Math.max(0,t-1))},1e3)}},[ie]),Fe=Ie(()=>{k&&(fe.current=setTimeout(()=>{var l;if(ae.current||O.current!=="custom")return;let t=v(f({},re("custom")),{errorType:"CUSTOM_MEDIA_LOAD_TIMEOUT",errCode:"BI_SPLASH_CUSTOM_MEDIA_LOAD_TIMEOUT",errMsg:"\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u8D85\u65F6",mediaType:Q?"image":"video",rawErrCode:void 0,rawErrMsg:void 0});(l=u.current)==null||l.call(u,t),U.current.custom=!0,z&&!U.current.wechat?(se("wechat",!0),_e()):Pe("custom",t)},Je(c)))},[z,Pe,k,Q,se,c,_e]),Ee=Ie(t=>{se(t,!0),t==="wechat"?_e():k&&Fe()},[k,se,_e,Fe]),Ne=Ie((t,l,_,D)=>{var Ve;if(O.current!=="custom"||U.current.custom)return;let Me=ye(t,re("custom")),Le=v(f({},Me),{errorType:l,errCode:_,errMsg:D,mediaType:Q?"image":"video",rawErrCode:Me.errCode,rawErrMsg:Me.errMsg});(Ve=u.current)==null||Ve.call(u,Le),U.current.custom=!0,z&&!U.current.wechat?Ee("wechat"):Pe("custom",Le)},[z,Pe,Q,Ee]),le=Ie(()=>{var t;if(V.current){y(!1);return}if(!x){se(null,!1),De.current||(De.current=!0,(t=h.current)==null||t.call(h,{provider:"none",type:"splash",reason:"noAd"}));return}Ee(x),x==="custom"&&!k&&Ne(void 0,"CUSTOM_MEDIA_LOAD_FAIL","BI_SPLASH_CUSTOM_MEDIA_LOAD_FAIL","\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u4E3B\u7D20\u6750\u5730\u5740\u4E3A\u7A7A")},[Ne,k,x,se,Ee]),He=Ie(()=>{if(!d||V.current)return;if(!I){le();return}let t=Ke();if(!(t!=null&&t.getShowSplashAdStatus)||Ce.current>=3){le();return}t.getShowSplashAdStatus({success:l=>{var _;if((l==null?void 0:l.code)===-1){Ce.current+=1,be.current=setTimeout(He,300);return}if((l==null?void 0:l.code)===1){N(),V.current=!0,y(!1),(_=s.current)==null||_.call(s,{provider:"wechat",type:"splash",nativeSplash:!0});return}le()},fail:le})},[le,I,N,d]);Xe(()=>{let t=Re.current,l=d&&!t.show||t.identity!==H;if(Re.current={identity:H,show:d},!d){V.current=!1,De.current=!1,U.current={wechat:!1,custom:!1},se(x,!1);return}if(!V.current)return l&&(De.current=!1),U.current={wechat:!1,custom:!1},V.current=!1,Ce.current=0,se(x,!1),He(),N},[He,N,H,x,se,d]),Xe(()=>{var l;if(!X||E!==0||!b||P||!O.current)return;let t=O.current;if(A){N(),ge(!0),a.current=setTimeout(()=>{var _;j(!0),ge(!1),(_=oe.current)==null||_.call(oe,re(t))},280);return}N(),y(!1),(l=h.current)==null||l.call(h,re(t))},[N,X,A,E,P,b]);let Ze=t=>{var l;O.current==="wechat"&&(_e(),(l=s.current)==null||l.call(s,ye(t,re("wechat"))))},et=t=>{var D;if(O.current!=="wechat"||U.current.wechat)return;let l=t!=null&&t.detail&&typeof t.detail=="object"?t.detail:{},_=v(f({},ye(t,re("wechat"))),{errCode:"BI_SPLASH_WECHAT_AD_LOAD_FAIL",errMsg:String(l.errMsg||"\u5FAE\u4FE1\u5F00\u5C4F\u5E7F\u544A\u52A0\u8F7D\u5931\u8D25"),rawErrCode:l.errCode,rawErrMsg:l.errMsg});(D=u.current)==null||D.call(u,_),U.current.wechat=!0,M&&!U.current.custom?(Ee("custom"),k||Ne(void 0,"CUSTOM_MEDIA_LOAD_FAIL","BI_SPLASH_CUSTOM_MEDIA_LOAD_FAIL","\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u4E3B\u7D20\u6750\u5730\u5740\u4E3A\u7A7A")):Pe("wechat",_)},Z=()=>{var t;O.current!=="custom"||ae.current||(fe.current&&clearTimeout(fe.current),fe.current=null,ae.current=!0,_e(),(t=s.current)==null||t.call(s,re("custom")))},tt=t=>{var _;(_=t==null?void 0:t.stopPropagation)==null||_.call(t),O.current&&(pe(!0),S(0))},je=()=>{var l;if(O.current!=="custom")return;let t=re("custom");(l=$.current)==null||l.call($,t),We({customAd:c,actionDetail:t,onOpenWebview:_=>{var D;return(D=we.current)==null?void 0:D.call(we,_)},onError:_=>{var D;return(D=u.current)==null?void 0:D.call(u,_)},miniProgramErrorCode:"BI_SPLASH_NAVIGATE_MINI_PROGRAM_FAIL",navigateErrorCode:"BI_SPLASH_NAVIGATE_FAIL",apiRequestErrorCode:"BI_SPLASH_API_REQUEST_FAIL",apiRequestParams:{configId:c==null?void 0:c.configId,equipmentValue:ee,userId:L},preferStandardFields:!0})},i=t=>{var l;N(),y(!1),j(!1),S(0),pe(!1),(l=h.current)==null||l.call(h,t)},o=["bi-splash-ad",P?"bi-splash-ad--pip":"",me?"bi-splash-ad--pip-animating":"",J||""].filter(Boolean).join(" ");return!b||!B?null:Te(W,{className:o,style:{zIndex:g},children:[B==="wechat"&&T?q(W,{className:"bi-splash-ad__popup",children:q(W,{className:`bi-splash-ad__media-wrapper${P?" bi-splash-ad__media-wrapper--pip":""}`,children:q(T,{className:"bi-splash-ad__wechat-unit",unitId:e,onLoad:Ze,onError:et,onClose:t=>i(ye(t,re("wechat")))})})}):B==="custom"&&k?q(W,{className:"bi-splash-ad__popup bi-splash-ad__custom",children:Te(W,{className:"bi-splash-ad__media-shell",onClick:je,children:[Q?q(yt,{className:"bi-splash-ad__media",src:C,mode:ce==="cover"?"aspectFill":"aspectFit",onLoad:Z,onError:t=>Ne(t,"CUSTOM_MEDIA_LOAD_FAIL","BI_SPLASH_CUSTOM_MEDIA_LOAD_FAIL","\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u5931\u8D25")}):q(Vt,{className:"bi-splash-ad__video",src:C,poster:te,autoplay:!0,muted:(c==null?void 0:c.muted)!==!1,loop:!0,objectFit:ce,showCenterPlayBtn:!1,showPlayBtn:!1,controls:!1,onLoadedMetaData:Z,onError:t=>Ne(t,"CUSTOM_MEDIA_LOAD_FAIL","BI_SPLASH_CUSTOM_MEDIA_LOAD_FAIL","\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u5931\u8D25")}),P?q(W,{className:"bi-splash-ad__pip-mask"}):null,!P&&!ue.isFullScreen?Te(W,{className:"bi-splash-ad__disclosure",style:ue.disclosureStyle,children:[q(qe,{children:Se}),q(W,{className:"bi-splash-ad__disclosure-arrow"})]}):null,!P&&(c!=null&&c.bottomImage)?q(yt,{className:"bi-splash-ad__bottom-image",src:c.bottomImage,mode:"widthFix"}):null]})}):null,P?q(W,{className:"bi-splash-ad__pip-close",onClick:()=>i(re(B)),children:q(W,{className:"bi-splash-ad__pip-close-text",children:"\u5173\u95ED"})}):null,!P&&ue.isFullScreen&&B==="custom"?Te(W,{className:"bi-splash-ad__combined-control",style:ue.combinedControlStyle,children:[Te(W,{className:"bi-splash-ad__combined-capsule",children:[Te(W,{className:"bi-splash-ad__combined-disclosure",children:[q(qe,{children:Se}),q(W,{className:"bi-splash-ad__disclosure-arrow"})]}),q(W,{className:"bi-splash-ad__combined-divider"}),q(W,{className:"bi-splash-ad__combined-skip",onClick:tt,children:"\u8DF3\u8FC7"})]}),Te(qe,{className:"bi-splash-ad__combined-countdown",children:[E," \u79D2"]})]}):P?null:Te(W,{className:"bi-splash-ad__skip",style:ue.skipStyle,onClick:tt,children:[Te(qe,{children:[E,"s"]}),q(W,{className:"bi-splash-ad__skip-divider"}),q(qe,{className:"bi-splash-ad__skip-text",children:"\u8DF3\u8FC7"})]})]})};import{useEffect as at,useMemo as Wt,useRef as ne,useState as ot}from"react";import{jsx as Bt}from"react/jsx-runtime";var qt="BI_DISPLAY_NATIVE_SPLASH_CONSUMED",Ht=300*1e3,At=["banner","splash"],jt=({adId:e="",unitId:n,type:r="banner",customAd:d,priority:g="wechat-first",adOptions:A=null,sdkKey:I="biNova",autoLoad:R=!0,adIntervals:ee=30,show:L=!0,zIndex:J=999,pictureInPicture:K=!1,checkNativeSplash:Y=!0,nativeSplashCache:w=!0,jumpSeconds:m=5,equipmentValue:p="",userId:F=0,className:T,onLoad:c,onError:C,onClose:te,onAction:Q,onFeedback:ce,onHide:ie,onOpenWebview:Se,onConfigLoad:ue,onConfigError:z})=>{var je;let M=ne(0),k=ne(""),x=ne(null),H=ne(c),b=ne(C),y=ne(te),B=ne(Q),de=ne(ce),P=ne(ie),j=ne(Se),E=ne(ue),S=ne(z),X=ne(L),[pe,me]=ot(!1),[ge,O]=ot(!1),[U,ae]=ot(null);at(()=>{H.current=c,b.current=C,y.current=te,B.current=Q,de.current=ce,P.current=ie,j.current=Se,E.current=ue,S.current=z,X.current=L},[Q,te,z,ue,C,ce,ie,c,Se,L]);let V=Wt(()=>At.includes(r)?r:"banner",[r]),De=()=>!!(R&&e),Re=()=>{var l;let i=globalThis.getApp,o=typeof i=="function"?i():null;if(!o)return null;let t=o;return t[I]||((l=t.globalData)==null?void 0:l[I])||null},Ce=()=>{var i;try{if(typeof wx!="undefined"&&typeof wx.getAccountInfoSync=="function"){let o=wx.getAccountInfoSync();return((i=o==null?void 0:o.miniProgram)==null?void 0:i.appId)||""}}catch(o){return""}return""},he=(i,o)=>`${qt}_${o||"unknown"}_${i||"empty"}`,fe=(i,o)=>{if(!w||!i||typeof wx=="undefined"||typeof wx.getStorageSync!="function")return!1;try{let t=he(i,o),l=Number(wx.getStorageSync(t)||0),_=Date.now()-l;return l>0&&_>=0&&_<=Ht}catch(t){return!1}},be=()=>{if(w&&!(!e||typeof wx=="undefined"||typeof wx.setStorageSync!="function"))try{let i=he(e,Ce());wx.setStorageSync(i,Date.now())}catch(i){}},a=()=>{M.current+=1,k.current="",me(!1),O(!1),ae(null)},s=()=>{let i=A&&typeof A=="object"?A:{},o=Ce(),t=v(f({},i),{adId:e,placementId:i.placementId||e,appId:i.appId||o,type:V});return Number.isInteger(F)&&F>0?t.userId=F:delete t.userId,t},u=i=>{try{return JSON.stringify(i||{})}catch(o){return`${String(i.appId||"")}_${String(i.placementId||"")}`}},h=i=>{let o=(i==null?void 0:i.unitId)||"",t=(i==null?void 0:i.customAd)||(i==null?void 0:i.custom)||null,l=typeof(i==null?void 0:i.show)=="boolean"?i.show:!!(o||t);return{unitId:o,customAd:t,priority:(i==null?void 0:i.priority)||"wechat-first",show:l}},$=i=>{var o,t;(o=S.current)==null||o.call(S,i),(t=b.current)==null||t.call(b,i)},oe=i=>{var o;(o=y.current)==null||o.call(y,{type:V,adId:e||i.adId||"",provider:"none",reason:"noAd"})},we=async()=>{var _;if(!De())return;let i=s(),o=u(i);if(k.current===o&&(pe||ge))return;let t=Re();if(!(t!=null&&t.ads)||typeof t.ads.getDisplayAdConfig!="function"){a(),$({type:V,adId:e,errCode:"DISPLAY_AD_SDK_NOT_READY",errMsg:"\u672A\u83B7\u53D6\u5230\u53EF\u7528\u7684\u5E7F\u544A\u670D\u52A1 SDK\uFF0C\u8BF7\u5148\u6CE8\u5165\u5168\u5C40 biNova \u5B9E\u4F8B"});return}let l=M.current+1;M.current=l,k.current=o,me(!0),O(!1),ae(null);try{let D=await t.ads.getDisplayAdConfig(i);if(l!==M.current)return;if(!D||D.code!==0||!D.data){me(!1),O(!0),ae(null),$({type:V,adId:e,errCode:"DISPLAY_AD_REMOTE_CONFIG_FAIL",errMsg:(D==null?void 0:D.message)||"\u83B7\u53D6\u5C55\u793A\u5E7F\u544A\u914D\u7F6E\u5931\u8D25",rawResult:D||null});return}let Me=h(D.data),Le=!!(X.current&&!Me.show);me(!1),O(!0),ae(D.data),(_=E.current)==null||_.call(E,{type:V,adId:e,requestOptions:i,data:D.data}),Le&&oe(D.data)}catch(D){if(l!==M.current)return;me(!1),O(!0),ae(null),$({type:V,adId:e,errCode:"DISPLAY_AD_REMOTE_CONFIG_EXCEPTION",errMsg:D instanceof Error?D.message:"\u83B7\u53D6\u5C55\u793A\u5E7F\u544A\u914D\u7F6E\u5F02\u5E38",error:D})}};at(()=>{var i;At.includes(r)||(i=b.current)==null||i.call(b,{type:"banner",errCode:"UNSUPPORTED_DISPLAY_AD_TYPE",errMsg:`\u4E0D\u652F\u6301\u7684\u5C55\u793A\u5E7F\u544A\u7C7B\u578B\uFF1A${r}\uFF0C\u8BF7\u4F7F\u7528 "banner" \u6216 "splash"`})},[r]),at(()=>{if(!e){a();return}we()},[e,A,R,V,I,F]);let re=De(),N=re?h(U):null,se=N?N.unitId:n||"",Pe=N?N.customAd:d||null,_e=N?N.priority:g,Fe=!!(L&&(!re||!e||ge&&(N!=null&&N.show))),Ee=Ce(),Ne=JSON.stringify([V,Ee,e,Y,w]),le=x.current;!!(!le||le.identity!==Ne||!le.show&&L)?x.current={identity:Ne,show:L,shouldCheck:!!(Y&&!fe(e,Ee))}:le&&le.show!==L&&(x.current=v(f({},le),{show:L}));let Ze=!!((je=x.current)!=null&&je.shouldCheck),et=e||(U==null?void 0:U.adId)||"",Z=i=>f({adId:et},i);return V==="splash"?Bt(it,f({},{unitId:se,customAd:Pe,priority:_e,show:Fe,zIndex:J,pictureInPicture:K,checkNativeSplash:Ze,jumpSeconds:m,equipmentValue:p,userId:F,className:T,onLoad:o=>{var t;o&&typeof o=="object"&&o.nativeSplash===!0&&be(),(t=H.current)==null||t.call(H,Z(o))},onError:o=>{var t;(t=b.current)==null||t.call(b,Z(o))},onClose:o=>{var t;(t=y.current)==null||t.call(y,Z(o))},onAction:o=>{var t;(t=B.current)==null||t.call(B,Z(o))},onHide:o=>{var t;(t=P.current)==null||t.call(P,Z(o))},onOpenWebview:o=>{var t;(t=j.current)==null||t.call(j,Z(o))}})):Fe?Bt(nt,f({},{unitId:se,customAd:Pe,priority:_e,adIntervals:ee,equipmentValue:p,userId:F,className:T,onLoad:i=>{var o;(o=H.current)==null||o.call(H,Z(i))},onError:i=>{var o;(o=b.current)==null||o.call(b,Z(i))},onClose:i=>{var o;(o=y.current)==null||o.call(y,Z(i))},onAction:i=>{var o;(o=B.current)==null||o.call(B,Z(i))},onFeedback:i=>{var o;(o=de.current)==null||o.call(de,Z(i))},onOpenWebview:i=>{var o;(o=j.current)==null||o.call(j,Z(i))}})):null};export{nt as BiBannerAd,jt as BiDisplayAd,it as BiSplashAd};
|